ltmain.sh revision 6257f37d
16257f37dSmrg#! /bin/sh
26257f37dSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
36257f37dSmrg##               by inline-source v2014-01-03.01
4f3561b8bSmrg
56257f37dSmrg# libtool (GNU libtool) 2.4.6
66257f37dSmrg# Provide generalized library-building support services.
7f3561b8bSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
8f3561b8bSmrg
96257f37dSmrg# Copyright (C) 1996-2015 Free Software Foundation, Inc.
10f3561b8bSmrg# This is free software; see the source for copying conditions.  There is NO
11f3561b8bSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12f3561b8bSmrg
13f3561b8bSmrg# GNU Libtool is free software; you can redistribute it and/or modify
14fc5a983dSmrg# it under the terms of the GNU General Public License as published by
15fc5a983dSmrg# the Free Software Foundation; either version 2 of the License, or
16fc5a983dSmrg# (at your option) any later version.
17fc5a983dSmrg#
18f3561b8bSmrg# As a special exception to the GNU General Public License,
19f3561b8bSmrg# if you distribute this file as part of a program or library that
20f3561b8bSmrg# is built using GNU Libtool, you may include this file under the
21f3561b8bSmrg# same distribution terms that you use for the rest of that program.
22f3561b8bSmrg#
23f3561b8bSmrg# GNU Libtool is distributed in the hope that it will be useful, but
24fc5a983dSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
25fc5a983dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26fc5a983dSmrg# General Public License for more details.
27fc5a983dSmrg#
28fc5a983dSmrg# You should have received a copy of the GNU General Public License
296257f37dSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
30fc5a983dSmrg
31fc5a983dSmrg
32bd304fc0SmrgPROGRAM=libtool
33fc5a983dSmrgPACKAGE=libtool
346257f37dSmrgVERSION=2.4.6
356257f37dSmrgpackage_revision=2.4.6
36fc5a983dSmrg
376257f37dSmrg
386257f37dSmrg## ------ ##
396257f37dSmrg## Usage. ##
406257f37dSmrg## ------ ##
416257f37dSmrg
426257f37dSmrg# Run './libtool --help' for help with using this script from the
436257f37dSmrg# command line.
446257f37dSmrg
456257f37dSmrg
466257f37dSmrg## ------------------------------- ##
476257f37dSmrg## User overridable command paths. ##
486257f37dSmrg## ------------------------------- ##
496257f37dSmrg
506257f37dSmrg# After configure completes, it has a better idea of some of the
516257f37dSmrg# shell tools we need than the defaults used by the functions shared
526257f37dSmrg# with bootstrap, so set those here where they can still be over-
536257f37dSmrg# ridden by the user, but otherwise take precedence.
546257f37dSmrg
556257f37dSmrg: ${AUTOCONF="autoconf"}
566257f37dSmrg: ${AUTOMAKE="automake"}
576257f37dSmrg
586257f37dSmrg
596257f37dSmrg## -------------------------- ##
606257f37dSmrg## Source external libraries. ##
616257f37dSmrg## -------------------------- ##
626257f37dSmrg
636257f37dSmrg# Much of our low-level functionality needs to be sourced from external
646257f37dSmrg# libraries, which are installed to $pkgauxdir.
656257f37dSmrg
666257f37dSmrg# Set a version string for this script.
676257f37dSmrgscriptversion=2015-01-20.17; # UTC
686257f37dSmrg
696257f37dSmrg# General shell script boiler plate, and helper functions.
706257f37dSmrg# Written by Gary V. Vaughan, 2004
716257f37dSmrg
726257f37dSmrg# Copyright (C) 2004-2015 Free Software Foundation, Inc.
736257f37dSmrg# This is free software; see the source for copying conditions.  There is NO
746257f37dSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
756257f37dSmrg
766257f37dSmrg# This program is free software; you can redistribute it and/or modify
776257f37dSmrg# it under the terms of the GNU General Public License as published by
786257f37dSmrg# the Free Software Foundation; either version 3 of the License, or
796257f37dSmrg# (at your option) any later version.
806257f37dSmrg
816257f37dSmrg# As a special exception to the GNU General Public License, if you distribute
826257f37dSmrg# this file as part of a program or library that is built using GNU Libtool,
836257f37dSmrg# you may include this file under the same distribution terms that you use
846257f37dSmrg# for the rest of that program.
856257f37dSmrg
866257f37dSmrg# This program is distributed in the hope that it will be useful,
876257f37dSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
886257f37dSmrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
896257f37dSmrg# General Public License for more details.
906257f37dSmrg
916257f37dSmrg# You should have received a copy of the GNU General Public License
926257f37dSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>.
936257f37dSmrg
946257f37dSmrg# Please report bugs or propose patches to gary@gnu.org.
956257f37dSmrg
966257f37dSmrg
976257f37dSmrg## ------ ##
986257f37dSmrg## Usage. ##
996257f37dSmrg## ------ ##
1006257f37dSmrg
1016257f37dSmrg# Evaluate this file near the top of your script to gain access to
1026257f37dSmrg# the functions and variables defined here:
1036257f37dSmrg#
1046257f37dSmrg#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
1056257f37dSmrg#
1066257f37dSmrg# If you need to override any of the default environment variable
1076257f37dSmrg# settings, do that before evaluating this file.
1086257f37dSmrg
1096257f37dSmrg
1106257f37dSmrg## -------------------- ##
1116257f37dSmrg## Shell normalisation. ##
1126257f37dSmrg## -------------------- ##
1136257f37dSmrg
1146257f37dSmrg# Some shells need a little help to be as Bourne compatible as possible.
1156257f37dSmrg# Before doing anything else, make sure all that help has been provided!
1166257f37dSmrg
1176257f37dSmrgDUALCASE=1; export DUALCASE # for MKS sh
1186257f37dSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
119fc5a983dSmrg  emulate sh
120fc5a983dSmrg  NULLCMD=:
1216257f37dSmrg  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
122fc5a983dSmrg  # is contrary to our usage.  Disable this feature.
123fc5a983dSmrg  alias -g '${1+"$@"}'='"$@"'
124fc5a983dSmrg  setopt NO_GLOB_SUBST
125fc5a983dSmrgelse
1266257f37dSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
127fc5a983dSmrgfi
128bd304fc0Smrg
1296257f37dSmrg# NLS nuisances: We save the old values in case they are required later.
1306257f37dSmrg_G_user_locale=
1316257f37dSmrg_G_safe_locale=
1326257f37dSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
133fc5a983dSmrgdo
1346257f37dSmrg  eval "if test set = \"\${$_G_var+set}\"; then
1356257f37dSmrg          save_$_G_var=\$$_G_var
1366257f37dSmrg          $_G_var=C
1376257f37dSmrg	  export $_G_var
1386257f37dSmrg	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
1396257f37dSmrg	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
140fc5a983dSmrg	fi"
141fc5a983dSmrgdone
142fc5a983dSmrg
1436257f37dSmrg# CDPATH.
1446257f37dSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
145f3561b8bSmrg
1466257f37dSmrg# Make sure IFS has a sensible default
1476257f37dSmrgsp=' '
1486257f37dSmrgnl='
1496257f37dSmrg'
1506257f37dSmrgIFS="$sp	$nl"
1516257f37dSmrg
1526257f37dSmrg# There are apparently some retarded systems that use ';' as a PATH separator!
1536257f37dSmrgif test "${PATH_SEPARATOR+set}" != set; then
1546257f37dSmrg  PATH_SEPARATOR=:
1556257f37dSmrg  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
1566257f37dSmrg    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
1576257f37dSmrg      PATH_SEPARATOR=';'
1586257f37dSmrg  }
1596257f37dSmrgfi
160f3561b8bSmrg
161f3561b8bSmrg
162f3561b8bSmrg
1636257f37dSmrg## ------------------------- ##
1646257f37dSmrg## Locate command utilities. ##
1656257f37dSmrg## ------------------------- ##
1666257f37dSmrg
1676257f37dSmrg
1686257f37dSmrg# func_executable_p FILE
1696257f37dSmrg# ----------------------
1706257f37dSmrg# Check that FILE is an executable regular file.
1716257f37dSmrgfunc_executable_p ()
1726257f37dSmrg{
1736257f37dSmrg    test -f "$1" && test -x "$1"
1746257f37dSmrg}
1756257f37dSmrg
1766257f37dSmrg
1776257f37dSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
1786257f37dSmrg# --------------------------------------------
1796257f37dSmrg# Search for either a program that responds to --version with output
1806257f37dSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by
1816257f37dSmrg# trying all the directories in PATH with each of the elements of
1826257f37dSmrg# PROGS_LIST.
1836257f37dSmrg#
1846257f37dSmrg# CHECK_FUNC should accept the path to a candidate program, and
1856257f37dSmrg# set $func_check_prog_result if it truncates its output less than
1866257f37dSmrg# $_G_path_prog_max characters.
1876257f37dSmrgfunc_path_progs ()
1886257f37dSmrg{
1896257f37dSmrg    _G_progs_list=$1
1906257f37dSmrg    _G_check_func=$2
1916257f37dSmrg    _G_PATH=${3-"$PATH"}
1926257f37dSmrg
1936257f37dSmrg    _G_path_prog_max=0
1946257f37dSmrg    _G_path_prog_found=false
1956257f37dSmrg    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
1966257f37dSmrg    for _G_dir in $_G_PATH; do
1976257f37dSmrg      IFS=$_G_save_IFS
1986257f37dSmrg      test -z "$_G_dir" && _G_dir=.
1996257f37dSmrg      for _G_prog_name in $_G_progs_list; do
2006257f37dSmrg        for _exeext in '' .EXE; do
2016257f37dSmrg          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
2026257f37dSmrg          func_executable_p "$_G_path_prog" || continue
2036257f37dSmrg          case `"$_G_path_prog" --version 2>&1` in
2046257f37dSmrg            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
2056257f37dSmrg            *)     $_G_check_func $_G_path_prog
2066257f37dSmrg		   func_path_progs_result=$func_check_prog_result
2076257f37dSmrg		   ;;
2086257f37dSmrg          esac
2096257f37dSmrg          $_G_path_prog_found && break 3
2106257f37dSmrg        done
2116257f37dSmrg      done
2126257f37dSmrg    done
2136257f37dSmrg    IFS=$_G_save_IFS
2146257f37dSmrg    test -z "$func_path_progs_result" && {
2156257f37dSmrg      echo "no acceptable sed could be found in \$PATH" >&2
2166257f37dSmrg      exit 1
2176257f37dSmrg    }
2186257f37dSmrg}
2196257f37dSmrg
2206257f37dSmrg
2216257f37dSmrg# We want to be able to use the functions in this file before configure
2226257f37dSmrg# has figured out where the best binaries are kept, which means we have
2236257f37dSmrg# to search for them ourselves - except when the results are already set
2246257f37dSmrg# where we skip the searches.
2256257f37dSmrg
2266257f37dSmrg# Unless the user overrides by setting SED, search the path for either GNU
2276257f37dSmrg# sed, or the sed that truncates its output the least.
2286257f37dSmrgtest -z "$SED" && {
2296257f37dSmrg  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
2306257f37dSmrg  for _G_i in 1 2 3 4 5 6 7; do
2316257f37dSmrg    _G_sed_script=$_G_sed_script$nl$_G_sed_script
2326257f37dSmrg  done
2336257f37dSmrg  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
2346257f37dSmrg  _G_sed_script=
2356257f37dSmrg
2366257f37dSmrg  func_check_prog_sed ()
2376257f37dSmrg  {
2386257f37dSmrg    _G_path_prog=$1
2396257f37dSmrg
2406257f37dSmrg    _G_count=0
2416257f37dSmrg    printf 0123456789 >conftest.in
2426257f37dSmrg    while :
2436257f37dSmrg    do
2446257f37dSmrg      cat conftest.in conftest.in >conftest.tmp
2456257f37dSmrg      mv conftest.tmp conftest.in
2466257f37dSmrg      cp conftest.in conftest.nl
2476257f37dSmrg      echo '' >> conftest.nl
2486257f37dSmrg      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
2496257f37dSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
2506257f37dSmrg      _G_count=`expr $_G_count + 1`
2516257f37dSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
2526257f37dSmrg        # Best one so far, save it but keep looking for a better one
2536257f37dSmrg        func_check_prog_result=$_G_path_prog
2546257f37dSmrg        _G_path_prog_max=$_G_count
2556257f37dSmrg      fi
2566257f37dSmrg      # 10*(2^10) chars as input seems more than enough
2576257f37dSmrg      test 10 -lt "$_G_count" && break
2586257f37dSmrg    done
2596257f37dSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
2606257f37dSmrg  }
2616257f37dSmrg
2626257f37dSmrg  func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
2636257f37dSmrg  rm -f conftest.sed
2646257f37dSmrg  SED=$func_path_progs_result
2656257f37dSmrg}
2666257f37dSmrg
2676257f37dSmrg
2686257f37dSmrg# Unless the user overrides by setting GREP, search the path for either GNU
2696257f37dSmrg# grep, or the grep that truncates its output the least.
2706257f37dSmrgtest -z "$GREP" && {
2716257f37dSmrg  func_check_prog_grep ()
2726257f37dSmrg  {
2736257f37dSmrg    _G_path_prog=$1
2746257f37dSmrg
2756257f37dSmrg    _G_count=0
2766257f37dSmrg    _G_path_prog_max=0
2776257f37dSmrg    printf 0123456789 >conftest.in
2786257f37dSmrg    while :
2796257f37dSmrg    do
2806257f37dSmrg      cat conftest.in conftest.in >conftest.tmp
2816257f37dSmrg      mv conftest.tmp conftest.in
2826257f37dSmrg      cp conftest.in conftest.nl
2836257f37dSmrg      echo 'GREP' >> conftest.nl
2846257f37dSmrg      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
2856257f37dSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
2866257f37dSmrg      _G_count=`expr $_G_count + 1`
2876257f37dSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
2886257f37dSmrg        # Best one so far, save it but keep looking for a better one
2896257f37dSmrg        func_check_prog_result=$_G_path_prog
2906257f37dSmrg        _G_path_prog_max=$_G_count
2916257f37dSmrg      fi
2926257f37dSmrg      # 10*(2^10) chars as input seems more than enough
2936257f37dSmrg      test 10 -lt "$_G_count" && break
2946257f37dSmrg    done
2956257f37dSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
2966257f37dSmrg  }
2976257f37dSmrg
2986257f37dSmrg  func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
2996257f37dSmrg  GREP=$func_path_progs_result
3006257f37dSmrg}
3016257f37dSmrg
3026257f37dSmrg
3036257f37dSmrg## ------------------------------- ##
3046257f37dSmrg## User overridable command paths. ##
3056257f37dSmrg## ------------------------------- ##
3066257f37dSmrg
3076257f37dSmrg# All uppercase variable names are used for environment variables.  These
3086257f37dSmrg# variables can be overridden by the user before calling a script that
3096257f37dSmrg# uses them if a suitable command of that name is not already available
3106257f37dSmrg# in the command search PATH.
311f3561b8bSmrg
312f3561b8bSmrg: ${CP="cp -f"}
3136257f37dSmrg: ${ECHO="printf %s\n"}
3146257f37dSmrg: ${EGREP="$GREP -E"}
3156257f37dSmrg: ${FGREP="$GREP -F"}
3166257f37dSmrg: ${LN_S="ln -s"}
317f3561b8bSmrg: ${MAKE="make"}
318f3561b8bSmrg: ${MKDIR="mkdir"}
319f3561b8bSmrg: ${MV="mv -f"}
320f3561b8bSmrg: ${RM="rm -f"}
321f3561b8bSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
322fc5a983dSmrg
323f3561b8bSmrg
3246257f37dSmrg## -------------------- ##
3256257f37dSmrg## Useful sed snippets. ##
3266257f37dSmrg## -------------------- ##
327bd304fc0Smrg
3286257f37dSmrgsed_dirname='s|/[^/]*$||'
3296257f37dSmrgsed_basename='s|^.*/||'
330bd304fc0Smrg
3316257f37dSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
3326257f37dSmrg# metacharacters that are still active within double-quoted strings.
3336257f37dSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g'
334bd304fc0Smrg
3356257f37dSmrg# Same as above, but do not quote variable references.
3366257f37dSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
337bd304fc0Smrg
3386257f37dSmrg# Sed substitution that turns a string into a regex matching for the
3396257f37dSmrg# string literally.
3406257f37dSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
341bd304fc0Smrg
3426257f37dSmrg# Sed substitution that converts a w32 file name or path
3436257f37dSmrg# that contains forward slashes, into one that contains
3446257f37dSmrg# (escaped) backslashes.  A very naive implementation.
3456257f37dSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3466257f37dSmrg
3476257f37dSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that
3486257f37dSmrg# were '\'-ed in input to the same.  If an odd number of '\' preceded a
3496257f37dSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from
3506257f37dSmrg# expansion.  Since each input '\' is now two '\'s, look for any number
3516257f37dSmrg# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
3526257f37dSmrg_G_bs='\\'
3536257f37dSmrg_G_bs2='\\\\'
3546257f37dSmrg_G_bs4='\\\\\\\\'
3556257f37dSmrg_G_dollar='\$'
3566257f37dSmrgsed_double_backslash="\
3576257f37dSmrg  s/$_G_bs4/&\\
3586257f37dSmrg/g
3596257f37dSmrg  s/^$_G_bs2$_G_dollar/$_G_bs&/
3606257f37dSmrg  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
3616257f37dSmrg  s/\n//g"
362bd304fc0Smrg
363bd304fc0Smrg
3646257f37dSmrg## ----------------- ##
3656257f37dSmrg## Global variables. ##
3666257f37dSmrg## ----------------- ##
367bd304fc0Smrg
3686257f37dSmrg# Except for the global variables explicitly listed below, the following
3696257f37dSmrg# functions in the '^func_' namespace, and the '^require_' namespace
3706257f37dSmrg# variables initialised in the 'Resource management' section, sourcing
3716257f37dSmrg# this file will not pollute your global namespace with anything
3726257f37dSmrg# else. There's no portable way to scope variables in Bourne shell
3736257f37dSmrg# though, so actually running these functions will sometimes place
3746257f37dSmrg# results into a variable named after the function, and often use
3756257f37dSmrg# temporary variables in the '^_G_' namespace. If you are careful to
3766257f37dSmrg# avoid using those namespaces casually in your sourcing script, things
3776257f37dSmrg# should continue to work as you expect. And, of course, you can freely
3786257f37dSmrg# overwrite any of the functions or variables defined here before
3796257f37dSmrg# calling anything to customize them.
380bd304fc0Smrg
3816257f37dSmrgEXIT_SUCCESS=0
3826257f37dSmrgEXIT_FAILURE=1
3836257f37dSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
3846257f37dSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
385fc5a983dSmrg
3866257f37dSmrg# Allow overriding, eg assuming that you follow the convention of
3876257f37dSmrg# putting '$debug_cmd' at the start of all your functions, you can get
3886257f37dSmrg# bash to show function call trace with:
3896257f37dSmrg#
3906257f37dSmrg#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
3916257f37dSmrgdebug_cmd=${debug_cmd-":"}
3926257f37dSmrgexit_cmd=:
393f3561b8bSmrg
3946257f37dSmrg# By convention, finish your script with:
3956257f37dSmrg#
3966257f37dSmrg#    exit $exit_status
3976257f37dSmrg#
3986257f37dSmrg# so that you can set exit_status to non-zero if you want to indicate
3996257f37dSmrg# something went wrong during execution without actually bailing out at
4006257f37dSmrg# the point of failure.
4016257f37dSmrgexit_status=$EXIT_SUCCESS
402bd304fc0Smrg
4036257f37dSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
4046257f37dSmrg# is ksh but when the shell is invoked as "sh" and the current value of
4056257f37dSmrg# the _XPG environment variable is not equal to 1 (one), the special
4066257f37dSmrg# positional parameter $0, within a function call, is the name of the
4076257f37dSmrg# function.
4086257f37dSmrgprogpath=$0
409f3561b8bSmrg
4106257f37dSmrg# The name of this program.
4116257f37dSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"`
412f3561b8bSmrg
4136257f37dSmrg# Make sure we have an absolute progpath for reexecution:
414f3561b8bSmrgcase $progpath in
415f3561b8bSmrg  [\\/]*|[A-Za-z]:\\*) ;;
416f3561b8bSmrg  *[\\/]*)
4176257f37dSmrg     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
418f3561b8bSmrg     progdir=`cd "$progdir" && pwd`
4196257f37dSmrg     progpath=$progdir/$progname
420f3561b8bSmrg     ;;
421f3561b8bSmrg  *)
4226257f37dSmrg     _G_IFS=$IFS
423bd304fc0Smrg     IFS=${PATH_SEPARATOR-:}
424f3561b8bSmrg     for progdir in $PATH; do
4256257f37dSmrg       IFS=$_G_IFS
426f3561b8bSmrg       test -x "$progdir/$progname" && break
427f3561b8bSmrg     done
4286257f37dSmrg     IFS=$_G_IFS
429f3561b8bSmrg     test -n "$progdir" || progdir=`pwd`
4306257f37dSmrg     progpath=$progdir/$progname
431f3561b8bSmrg     ;;
432f3561b8bSmrgesac
433f3561b8bSmrg
434f3561b8bSmrg
4356257f37dSmrg## ----------------- ##
4366257f37dSmrg## Standard options. ##
4376257f37dSmrg## ----------------- ##
438bd304fc0Smrg
4396257f37dSmrg# The following options affect the operation of the functions defined
4406257f37dSmrg# below, and should be set appropriately depending on run-time para-
4416257f37dSmrg# meters passed on the command line.
442f3561b8bSmrg
443f3561b8bSmrgopt_dry_run=false
444f3561b8bSmrgopt_quiet=false
445f3561b8bSmrgopt_verbose=false
446f3561b8bSmrg
4476257f37dSmrg# Categories 'all' and 'none' are always available.  Append any others
4486257f37dSmrg# you will pass as the first argument to func_warning from your own
4496257f37dSmrg# code.
4506257f37dSmrgwarning_categories=
451f3561b8bSmrg
4526257f37dSmrg# By default, display warnings according to 'opt_warning_types'.  Set
4536257f37dSmrg# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
4546257f37dSmrg# treat the next displayed warning as a fatal error.
4556257f37dSmrgwarning_func=func_warn_and_continue
456f3561b8bSmrg
4576257f37dSmrg# Set to 'all' to display all warnings, 'none' to suppress all
4586257f37dSmrg# warnings, or a space delimited list of some subset of
4596257f37dSmrg# 'warning_categories' to display only the listed warnings.
4606257f37dSmrgopt_warning_types=all
461f3561b8bSmrg
462bd304fc0Smrg
4636257f37dSmrg## -------------------- ##
4646257f37dSmrg## Resource management. ##
4656257f37dSmrg## -------------------- ##
466f3561b8bSmrg
4676257f37dSmrg# This section contains definitions for functions that each ensure a
4686257f37dSmrg# particular resource (a file, or a non-empty configuration variable for
4696257f37dSmrg# example) is available, and if appropriate to extract default values
4706257f37dSmrg# from pertinent package files. Call them using their associated
4716257f37dSmrg# 'require_*' variable to ensure that they are executed, at most, once.
4726257f37dSmrg#
4736257f37dSmrg# It's entirely deliberate that calling these functions can set
4746257f37dSmrg# variables that don't obey the namespace limitations obeyed by the rest
4756257f37dSmrg# of this file, in order that that they be as useful as possible to
4766257f37dSmrg# callers.
477f3561b8bSmrg
478f3561b8bSmrg
4796257f37dSmrg# require_term_colors
4806257f37dSmrg# -------------------
4816257f37dSmrg# Allow display of bold text on terminals that support it.
4826257f37dSmrgrequire_term_colors=func_require_term_colors
4836257f37dSmrgfunc_require_term_colors ()
484f3561b8bSmrg{
4856257f37dSmrg    $debug_cmd
4866257f37dSmrg
4876257f37dSmrg    test -t 1 && {
4886257f37dSmrg      # COLORTERM and USE_ANSI_COLORS environment variables take
4896257f37dSmrg      # precedence, because most terminfo databases neglect to describe
4906257f37dSmrg      # whether color sequences are supported.
4916257f37dSmrg      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
4926257f37dSmrg
4936257f37dSmrg      if test 1 = "$USE_ANSI_COLORS"; then
4946257f37dSmrg        # Standard ANSI escape sequences
4956257f37dSmrg        tc_reset='[0m'
4966257f37dSmrg        tc_bold='[1m';   tc_standout='[7m'
4976257f37dSmrg        tc_red='[31m';   tc_green='[32m'
4986257f37dSmrg        tc_blue='[34m';  tc_cyan='[36m'
4996257f37dSmrg      else
5006257f37dSmrg        # Otherwise trust the terminfo database after all.
5016257f37dSmrg        test -n "`tput sgr0 2>/dev/null`" && {
5026257f37dSmrg          tc_reset=`tput sgr0`
5036257f37dSmrg          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
5046257f37dSmrg          tc_standout=$tc_bold
5056257f37dSmrg          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
5066257f37dSmrg          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
5076257f37dSmrg          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
5086257f37dSmrg          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
5096257f37dSmrg          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
5106257f37dSmrg        }
5116257f37dSmrg      fi
5126257f37dSmrg    }
513f3561b8bSmrg
5146257f37dSmrg    require_term_colors=:
515f3561b8bSmrg}
516f3561b8bSmrg
517f3561b8bSmrg
5186257f37dSmrg## ----------------- ##
5196257f37dSmrg## Function library. ##
5206257f37dSmrg## ----------------- ##
5216257f37dSmrg
5226257f37dSmrg# This section contains a variety of useful functions to call in your
5236257f37dSmrg# scripts. Take note of the portable wrappers for features provided by
5246257f37dSmrg# some modern shells, which will fall back to slower equivalents on
5256257f37dSmrg# less featureful shells.
5266257f37dSmrg
5276257f37dSmrg
5286257f37dSmrg# func_append VAR VALUE
5296257f37dSmrg# ---------------------
5306257f37dSmrg# Append VALUE onto the existing contents of VAR.
5316257f37dSmrg
5326257f37dSmrg  # We should try to minimise forks, especially on Windows where they are
5336257f37dSmrg  # unreasonably slow, so skip the feature probes when bash or zsh are
5346257f37dSmrg  # being used:
5356257f37dSmrg  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
5366257f37dSmrg    : ${_G_HAVE_ARITH_OP="yes"}
5376257f37dSmrg    : ${_G_HAVE_XSI_OPS="yes"}
5386257f37dSmrg    # The += operator was introduced in bash 3.1
5396257f37dSmrg    case $BASH_VERSION in
5406257f37dSmrg      [12].* | 3.0 | 3.0*) ;;
5416257f37dSmrg      *)
5426257f37dSmrg        : ${_G_HAVE_PLUSEQ_OP="yes"}
5436257f37dSmrg        ;;
5446257f37dSmrg    esac
5456257f37dSmrg  fi
5466257f37dSmrg
5476257f37dSmrg  # _G_HAVE_PLUSEQ_OP
5486257f37dSmrg  # Can be empty, in which case the shell is probed, "yes" if += is
5496257f37dSmrg  # useable or anything else if it does not work.
5506257f37dSmrg  test -z "$_G_HAVE_PLUSEQ_OP" \
5516257f37dSmrg    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
5526257f37dSmrg    && _G_HAVE_PLUSEQ_OP=yes
5536257f37dSmrg
5546257f37dSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"
5556257f37dSmrgthen
5566257f37dSmrg  # This is an XSI compatible shell, allowing a faster implementation...
5576257f37dSmrg  eval 'func_append ()
5586257f37dSmrg  {
5596257f37dSmrg    $debug_cmd
5606257f37dSmrg
5616257f37dSmrg    eval "$1+=\$2"
5626257f37dSmrg  }'
5636257f37dSmrgelse
5646257f37dSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
5656257f37dSmrg  func_append ()
5666257f37dSmrg  {
5676257f37dSmrg    $debug_cmd
5686257f37dSmrg
5696257f37dSmrg    eval "$1=\$$1\$2"
5706257f37dSmrg  }
5716257f37dSmrgfi
5726257f37dSmrg
5736257f37dSmrg
5746257f37dSmrg# func_append_quoted VAR VALUE
5756257f37dSmrg# ----------------------------
5766257f37dSmrg# Quote VALUE and append to the end of shell variable VAR, separated
5776257f37dSmrg# by a space.
5786257f37dSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then
5796257f37dSmrg  eval 'func_append_quoted ()
5806257f37dSmrg  {
5816257f37dSmrg    $debug_cmd
5826257f37dSmrg
5836257f37dSmrg    func_quote_for_eval "$2"
5846257f37dSmrg    eval "$1+=\\ \$func_quote_for_eval_result"
5856257f37dSmrg  }'
5866257f37dSmrgelse
5876257f37dSmrg  func_append_quoted ()
5886257f37dSmrg  {
5896257f37dSmrg    $debug_cmd
5906257f37dSmrg
5916257f37dSmrg    func_quote_for_eval "$2"
5926257f37dSmrg    eval "$1=\$$1\\ \$func_quote_for_eval_result"
5936257f37dSmrg  }
5946257f37dSmrgfi
5956257f37dSmrg
5966257f37dSmrg
5976257f37dSmrg# func_append_uniq VAR VALUE
5986257f37dSmrg# --------------------------
5996257f37dSmrg# Append unique VALUE onto the existing contents of VAR, assuming
6006257f37dSmrg# entries are delimited by the first character of VALUE.  For example:
6016257f37dSmrg#
6026257f37dSmrg#   func_append_uniq options " --another-option option-argument"
6036257f37dSmrg#
6046257f37dSmrg# will only append to $options if " --another-option option-argument "
6056257f37dSmrg# is not already present somewhere in $options already (note spaces at
6066257f37dSmrg# each end implied by leading space in second argument).
6076257f37dSmrgfunc_append_uniq ()
6086257f37dSmrg{
6096257f37dSmrg    $debug_cmd
6106257f37dSmrg
6116257f37dSmrg    eval _G_current_value='`$ECHO $'$1'`'
6126257f37dSmrg    _G_delim=`expr "$2" : '\(.\)'`
6136257f37dSmrg
6146257f37dSmrg    case $_G_delim$_G_current_value$_G_delim in
6156257f37dSmrg      *"$2$_G_delim"*) ;;
6166257f37dSmrg      *) func_append "$@" ;;
6176257f37dSmrg    esac
6186257f37dSmrg}
6196257f37dSmrg
6206257f37dSmrg
6216257f37dSmrg# func_arith TERM...
6226257f37dSmrg# ------------------
6236257f37dSmrg# Set func_arith_result to the result of evaluating TERMs.
6246257f37dSmrg  test -z "$_G_HAVE_ARITH_OP" \
6256257f37dSmrg    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
6266257f37dSmrg    && _G_HAVE_ARITH_OP=yes
6276257f37dSmrg
6286257f37dSmrgif test yes = "$_G_HAVE_ARITH_OP"; then
6296257f37dSmrg  eval 'func_arith ()
6306257f37dSmrg  {
6316257f37dSmrg    $debug_cmd
6326257f37dSmrg
6336257f37dSmrg    func_arith_result=$(( $* ))
6346257f37dSmrg  }'
6356257f37dSmrgelse
6366257f37dSmrg  func_arith ()
6376257f37dSmrg  {
6386257f37dSmrg    $debug_cmd
6396257f37dSmrg
6406257f37dSmrg    func_arith_result=`expr "$@"`
6416257f37dSmrg  }
6426257f37dSmrgfi
6436257f37dSmrg
6446257f37dSmrg
6456257f37dSmrg# func_basename FILE
6466257f37dSmrg# ------------------
6476257f37dSmrg# Set func_basename_result to FILE with everything up to and including
6486257f37dSmrg# the last / stripped.
6496257f37dSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
6506257f37dSmrg  # If this shell supports suffix pattern removal, then use it to avoid
6516257f37dSmrg  # forking. Hide the definitions single quotes in case the shell chokes
6526257f37dSmrg  # on unsupported syntax...
6536257f37dSmrg  _b='func_basename_result=${1##*/}'
6546257f37dSmrg  _d='case $1 in
6556257f37dSmrg        */*) func_dirname_result=${1%/*}$2 ;;
6566257f37dSmrg        *  ) func_dirname_result=$3        ;;
6576257f37dSmrg      esac'
6586257f37dSmrg
6596257f37dSmrgelse
6606257f37dSmrg  # ...otherwise fall back to using sed.
6616257f37dSmrg  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
6626257f37dSmrg  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
6636257f37dSmrg      if test "X$func_dirname_result" = "X$1"; then
6646257f37dSmrg        func_dirname_result=$3
6656257f37dSmrg      else
6666257f37dSmrg        func_append func_dirname_result "$2"
6676257f37dSmrg      fi'
6686257f37dSmrgfi
6696257f37dSmrg
6706257f37dSmrgeval 'func_basename ()
6716257f37dSmrg{
6726257f37dSmrg    $debug_cmd
6736257f37dSmrg
6746257f37dSmrg    '"$_b"'
6756257f37dSmrg}'
6766257f37dSmrg
6776257f37dSmrg
6786257f37dSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT
6796257f37dSmrg# -------------------------------------------
6806257f37dSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
6816257f37dSmrg# otherwise set result to NONDIR_REPLACEMENT.
6826257f37dSmrgeval 'func_dirname ()
6836257f37dSmrg{
6846257f37dSmrg    $debug_cmd
6856257f37dSmrg
6866257f37dSmrg    '"$_d"'
6876257f37dSmrg}'
6886257f37dSmrg
6896257f37dSmrg
6906257f37dSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
6916257f37dSmrg# --------------------------------------------------------
6926257f37dSmrg# Perform func_basename and func_dirname in a single function
6936257f37dSmrg# call:
6946257f37dSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
6956257f37dSmrg#             add APPEND to the result, otherwise set result
6966257f37dSmrg#             to NONDIR_REPLACEMENT.
6976257f37dSmrg#             value returned in "$func_dirname_result"
6986257f37dSmrg#   basename: Compute filename of FILE.
6996257f37dSmrg#             value retuned in "$func_basename_result"
7006257f37dSmrg# For efficiency, we do not delegate to the functions above but instead
7016257f37dSmrg# duplicate the functionality here.
7026257f37dSmrgeval 'func_dirname_and_basename ()
7036257f37dSmrg{
7046257f37dSmrg    $debug_cmd
7056257f37dSmrg
7066257f37dSmrg    '"$_b"'
7076257f37dSmrg    '"$_d"'
7086257f37dSmrg}'
7096257f37dSmrg
7106257f37dSmrg
7116257f37dSmrg# func_echo ARG...
7126257f37dSmrg# ----------------
7136257f37dSmrg# Echo program name prefixed message.
7146257f37dSmrgfunc_echo ()
7156257f37dSmrg{
7166257f37dSmrg    $debug_cmd
7176257f37dSmrg
7186257f37dSmrg    _G_message=$*
7196257f37dSmrg
7206257f37dSmrg    func_echo_IFS=$IFS
7216257f37dSmrg    IFS=$nl
7226257f37dSmrg    for _G_line in $_G_message; do
7236257f37dSmrg      IFS=$func_echo_IFS
7246257f37dSmrg      $ECHO "$progname: $_G_line"
7256257f37dSmrg    done
7266257f37dSmrg    IFS=$func_echo_IFS
7276257f37dSmrg}
7286257f37dSmrg
7296257f37dSmrg
7306257f37dSmrg# func_echo_all ARG...
7316257f37dSmrg# --------------------
7326257f37dSmrg# Invoke $ECHO with all args, space-separated.
7336257f37dSmrgfunc_echo_all ()
7346257f37dSmrg{
7356257f37dSmrg    $ECHO "$*"
7366257f37dSmrg}
7376257f37dSmrg
7386257f37dSmrg
7396257f37dSmrg# func_echo_infix_1 INFIX ARG...
7406257f37dSmrg# ------------------------------
7416257f37dSmrg# Echo program name, followed by INFIX on the first line, with any
7426257f37dSmrg# additional lines not showing INFIX.
7436257f37dSmrgfunc_echo_infix_1 ()
7446257f37dSmrg{
7456257f37dSmrg    $debug_cmd
7466257f37dSmrg
7476257f37dSmrg    $require_term_colors
7486257f37dSmrg
7496257f37dSmrg    _G_infix=$1; shift
7506257f37dSmrg    _G_indent=$_G_infix
7516257f37dSmrg    _G_prefix="$progname: $_G_infix: "
7526257f37dSmrg    _G_message=$*
7536257f37dSmrg
7546257f37dSmrg    # Strip color escape sequences before counting printable length
7556257f37dSmrg    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
7566257f37dSmrg    do
7576257f37dSmrg      test -n "$_G_tc" && {
7586257f37dSmrg        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
7596257f37dSmrg        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
7606257f37dSmrg      }
7616257f37dSmrg    done
7626257f37dSmrg    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
7636257f37dSmrg
7646257f37dSmrg    func_echo_infix_1_IFS=$IFS
7656257f37dSmrg    IFS=$nl
7666257f37dSmrg    for _G_line in $_G_message; do
7676257f37dSmrg      IFS=$func_echo_infix_1_IFS
7686257f37dSmrg      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
7696257f37dSmrg      _G_prefix=$_G_indent
7706257f37dSmrg    done
7716257f37dSmrg    IFS=$func_echo_infix_1_IFS
7726257f37dSmrg}
7736257f37dSmrg
7746257f37dSmrg
7756257f37dSmrg# func_error ARG...
7766257f37dSmrg# -----------------
7776257f37dSmrg# Echo program name prefixed message to standard error.
7786257f37dSmrgfunc_error ()
7796257f37dSmrg{
7806257f37dSmrg    $debug_cmd
7816257f37dSmrg
7826257f37dSmrg    $require_term_colors
7836257f37dSmrg
7846257f37dSmrg    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
7856257f37dSmrg}
7866257f37dSmrg
7876257f37dSmrg
7886257f37dSmrg# func_fatal_error ARG...
7896257f37dSmrg# -----------------------
7906257f37dSmrg# Echo program name prefixed message to standard error, and exit.
7916257f37dSmrgfunc_fatal_error ()
7926257f37dSmrg{
7936257f37dSmrg    $debug_cmd
7946257f37dSmrg
7956257f37dSmrg    func_error "$*"
7966257f37dSmrg    exit $EXIT_FAILURE
7976257f37dSmrg}
7986257f37dSmrg
7996257f37dSmrg
8006257f37dSmrg# func_grep EXPRESSION FILENAME
8016257f37dSmrg# -----------------------------
802f3561b8bSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
803f3561b8bSmrgfunc_grep ()
804f3561b8bSmrg{
8056257f37dSmrg    $debug_cmd
8066257f37dSmrg
807f3561b8bSmrg    $GREP "$1" "$2" >/dev/null 2>&1
808f3561b8bSmrg}
809f3561b8bSmrg
810f3561b8bSmrg
8116257f37dSmrg# func_len STRING
8126257f37dSmrg# ---------------
8136257f37dSmrg# Set func_len_result to the length of STRING. STRING may not
8146257f37dSmrg# start with a hyphen.
8156257f37dSmrg  test -z "$_G_HAVE_XSI_OPS" \
8166257f37dSmrg    && (eval 'x=a/b/c;
8176257f37dSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
8186257f37dSmrg    && _G_HAVE_XSI_OPS=yes
8196257f37dSmrg
8206257f37dSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
8216257f37dSmrg  eval 'func_len ()
8226257f37dSmrg  {
8236257f37dSmrg    $debug_cmd
8246257f37dSmrg
8256257f37dSmrg    func_len_result=${#1}
8266257f37dSmrg  }'
8276257f37dSmrgelse
8286257f37dSmrg  func_len ()
8296257f37dSmrg  {
8306257f37dSmrg    $debug_cmd
8316257f37dSmrg
8326257f37dSmrg    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
8336257f37dSmrg  }
8346257f37dSmrgfi
8356257f37dSmrg
8366257f37dSmrg
8376257f37dSmrg# func_mkdir_p DIRECTORY-PATH
8386257f37dSmrg# ---------------------------
839f3561b8bSmrg# Make sure the entire path to DIRECTORY-PATH is available.
840f3561b8bSmrgfunc_mkdir_p ()
841f3561b8bSmrg{
8426257f37dSmrg    $debug_cmd
843f3561b8bSmrg
8446257f37dSmrg    _G_directory_path=$1
8456257f37dSmrg    _G_dir_list=
846f3561b8bSmrg
8476257f37dSmrg    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
8486257f37dSmrg
8496257f37dSmrg      # Protect directory names starting with '-'
8506257f37dSmrg      case $_G_directory_path in
8516257f37dSmrg        -*) _G_directory_path=./$_G_directory_path ;;
852f3561b8bSmrg      esac
853f3561b8bSmrg
854f3561b8bSmrg      # While some portion of DIR does not yet exist...
8556257f37dSmrg      while test ! -d "$_G_directory_path"; do
856f3561b8bSmrg        # ...make a list in topmost first order.  Use a colon delimited
857f3561b8bSmrg	# list incase some portion of path contains whitespace.
8586257f37dSmrg        _G_dir_list=$_G_directory_path:$_G_dir_list
859f3561b8bSmrg
860f3561b8bSmrg        # If the last portion added has no slash in it, the list is done
8616257f37dSmrg        case $_G_directory_path in */*) ;; *) break ;; esac
862f3561b8bSmrg
863f3561b8bSmrg        # ...otherwise throw away the child directory and loop
8646257f37dSmrg        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
865f3561b8bSmrg      done
8666257f37dSmrg      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
867f3561b8bSmrg
8686257f37dSmrg      func_mkdir_p_IFS=$IFS; IFS=:
8696257f37dSmrg      for _G_dir in $_G_dir_list; do
8706257f37dSmrg	IFS=$func_mkdir_p_IFS
8716257f37dSmrg        # mkdir can fail with a 'File exist' error if two processes
872f3561b8bSmrg        # try to create one of the directories concurrently.  Don't
873f3561b8bSmrg        # stop in that case!
8746257f37dSmrg        $MKDIR "$_G_dir" 2>/dev/null || :
875f3561b8bSmrg      done
8766257f37dSmrg      IFS=$func_mkdir_p_IFS
877f3561b8bSmrg
878f3561b8bSmrg      # Bail out if we (or some other process) failed to create a directory.
8796257f37dSmrg      test -d "$_G_directory_path" || \
8806257f37dSmrg        func_fatal_error "Failed to create '$1'"
881f3561b8bSmrg    fi
882f3561b8bSmrg}
883fc5a983dSmrg
884fc5a983dSmrg
8856257f37dSmrg# func_mktempdir [BASENAME]
8866257f37dSmrg# -------------------------
887fc5a983dSmrg# Make a temporary directory that won't clash with other running
888fc5a983dSmrg# libtool processes, and avoids race conditions if possible.  If
8896257f37dSmrg# given, BASENAME is the basename for that directory.
890fc5a983dSmrgfunc_mktempdir ()
891fc5a983dSmrg{
8926257f37dSmrg    $debug_cmd
8936257f37dSmrg
8946257f37dSmrg    _G_template=${TMPDIR-/tmp}/${1-$progname}
895fc5a983dSmrg
8966257f37dSmrg    if test : = "$opt_dry_run"; then
897fc5a983dSmrg      # Return a directory name, but don't create it in dry-run mode
8986257f37dSmrg      _G_tmpdir=$_G_template-$$
899fc5a983dSmrg    else
900fc5a983dSmrg
901fc5a983dSmrg      # If mktemp works, use that first and foremost
9026257f37dSmrg      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
903fc5a983dSmrg
9046257f37dSmrg      if test ! -d "$_G_tmpdir"; then
905f3561b8bSmrg        # Failing that, at least try and use $RANDOM to avoid a race
9066257f37dSmrg        _G_tmpdir=$_G_template-${RANDOM-0}$$
907fc5a983dSmrg
9086257f37dSmrg        func_mktempdir_umask=`umask`
909f3561b8bSmrg        umask 0077
9106257f37dSmrg        $MKDIR "$_G_tmpdir"
9116257f37dSmrg        umask $func_mktempdir_umask
912fc5a983dSmrg      fi
913fc5a983dSmrg
914fc5a983dSmrg      # If we're not in dry-run mode, bomb out on failure
9156257f37dSmrg      test -d "$_G_tmpdir" || \
9166257f37dSmrg        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
9176257f37dSmrg    fi
9186257f37dSmrg
9196257f37dSmrg    $ECHO "$_G_tmpdir"
9206257f37dSmrg}
9216257f37dSmrg
9226257f37dSmrg
9236257f37dSmrg# func_normal_abspath PATH
9246257f37dSmrg# ------------------------
9256257f37dSmrg# Remove doubled-up and trailing slashes, "." path components,
9266257f37dSmrg# and cancel out any ".." path components in PATH after making
9276257f37dSmrg# it an absolute path.
9286257f37dSmrgfunc_normal_abspath ()
9296257f37dSmrg{
9306257f37dSmrg    $debug_cmd
9316257f37dSmrg
9326257f37dSmrg    # These SED scripts presuppose an absolute path with a trailing slash.
9336257f37dSmrg    _G_pathcar='s|^/\([^/]*\).*$|\1|'
9346257f37dSmrg    _G_pathcdr='s|^/[^/]*||'
9356257f37dSmrg    _G_removedotparts=':dotsl
9366257f37dSmrg		s|/\./|/|g
9376257f37dSmrg		t dotsl
9386257f37dSmrg		s|/\.$|/|'
9396257f37dSmrg    _G_collapseslashes='s|/\{1,\}|/|g'
9406257f37dSmrg    _G_finalslash='s|/*$|/|'
9416257f37dSmrg
9426257f37dSmrg    # Start from root dir and reassemble the path.
9436257f37dSmrg    func_normal_abspath_result=
9446257f37dSmrg    func_normal_abspath_tpath=$1
9456257f37dSmrg    func_normal_abspath_altnamespace=
9466257f37dSmrg    case $func_normal_abspath_tpath in
9476257f37dSmrg      "")
9486257f37dSmrg        # Empty path, that just means $cwd.
9496257f37dSmrg        func_stripname '' '/' "`pwd`"
9506257f37dSmrg        func_normal_abspath_result=$func_stripname_result
9516257f37dSmrg        return
9526257f37dSmrg        ;;
9536257f37dSmrg      # The next three entries are used to spot a run of precisely
9546257f37dSmrg      # two leading slashes without using negated character classes;
9556257f37dSmrg      # we take advantage of case's first-match behaviour.
9566257f37dSmrg      ///*)
9576257f37dSmrg        # Unusual form of absolute path, do nothing.
9586257f37dSmrg        ;;
9596257f37dSmrg      //*)
9606257f37dSmrg        # Not necessarily an ordinary path; POSIX reserves leading '//'
9616257f37dSmrg        # and for example Cygwin uses it to access remote file shares
9626257f37dSmrg        # over CIFS/SMB, so we conserve a leading double slash if found.
9636257f37dSmrg        func_normal_abspath_altnamespace=/
9646257f37dSmrg        ;;
9656257f37dSmrg      /*)
9666257f37dSmrg        # Absolute path, do nothing.
9676257f37dSmrg        ;;
9686257f37dSmrg      *)
9696257f37dSmrg        # Relative path, prepend $cwd.
9706257f37dSmrg        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
9716257f37dSmrg        ;;
9726257f37dSmrg    esac
9736257f37dSmrg
9746257f37dSmrg    # Cancel out all the simple stuff to save iterations.  We also want
9756257f37dSmrg    # the path to end with a slash for ease of parsing, so make sure
9766257f37dSmrg    # there is one (and only one) here.
9776257f37dSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
9786257f37dSmrg          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
9796257f37dSmrg    while :; do
9806257f37dSmrg      # Processed it all yet?
9816257f37dSmrg      if test / = "$func_normal_abspath_tpath"; then
9826257f37dSmrg        # If we ascended to the root using ".." the result may be empty now.
9836257f37dSmrg        if test -z "$func_normal_abspath_result"; then
9846257f37dSmrg          func_normal_abspath_result=/
9856257f37dSmrg        fi
9866257f37dSmrg        break
9876257f37dSmrg      fi
9886257f37dSmrg      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
9896257f37dSmrg          -e "$_G_pathcar"`
9906257f37dSmrg      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
9916257f37dSmrg          -e "$_G_pathcdr"`
9926257f37dSmrg      # Figure out what to do with it
9936257f37dSmrg      case $func_normal_abspath_tcomponent in
9946257f37dSmrg        "")
9956257f37dSmrg          # Trailing empty path component, ignore it.
9966257f37dSmrg          ;;
9976257f37dSmrg        ..)
9986257f37dSmrg          # Parent dir; strip last assembled component from result.
9996257f37dSmrg          func_dirname "$func_normal_abspath_result"
10006257f37dSmrg          func_normal_abspath_result=$func_dirname_result
10016257f37dSmrg          ;;
10026257f37dSmrg        *)
10036257f37dSmrg          # Actual path component, append it.
10046257f37dSmrg          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
10056257f37dSmrg          ;;
10066257f37dSmrg      esac
10076257f37dSmrg    done
10086257f37dSmrg    # Restore leading double-slash if one was found on entry.
10096257f37dSmrg    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
10106257f37dSmrg}
10116257f37dSmrg
10126257f37dSmrg
10136257f37dSmrg# func_notquiet ARG...
10146257f37dSmrg# --------------------
10156257f37dSmrg# Echo program name prefixed message only when not in quiet mode.
10166257f37dSmrgfunc_notquiet ()
10176257f37dSmrg{
10186257f37dSmrg    $debug_cmd
10196257f37dSmrg
10206257f37dSmrg    $opt_quiet || func_echo ${1+"$@"}
10216257f37dSmrg
10226257f37dSmrg    # A bug in bash halts the script if the last line of a function
10236257f37dSmrg    # fails when set -e is in force, so we need another command to
10246257f37dSmrg    # work around that:
10256257f37dSmrg    :
10266257f37dSmrg}
10276257f37dSmrg
10286257f37dSmrg
10296257f37dSmrg# func_relative_path SRCDIR DSTDIR
10306257f37dSmrg# --------------------------------
10316257f37dSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
10326257f37dSmrgfunc_relative_path ()
10336257f37dSmrg{
10346257f37dSmrg    $debug_cmd
10356257f37dSmrg
10366257f37dSmrg    func_relative_path_result=
10376257f37dSmrg    func_normal_abspath "$1"
10386257f37dSmrg    func_relative_path_tlibdir=$func_normal_abspath_result
10396257f37dSmrg    func_normal_abspath "$2"
10406257f37dSmrg    func_relative_path_tbindir=$func_normal_abspath_result
10416257f37dSmrg
10426257f37dSmrg    # Ascend the tree starting from libdir
10436257f37dSmrg    while :; do
10446257f37dSmrg      # check if we have found a prefix of bindir
10456257f37dSmrg      case $func_relative_path_tbindir in
10466257f37dSmrg        $func_relative_path_tlibdir)
10476257f37dSmrg          # found an exact match
10486257f37dSmrg          func_relative_path_tcancelled=
10496257f37dSmrg          break
10506257f37dSmrg          ;;
10516257f37dSmrg        $func_relative_path_tlibdir*)
10526257f37dSmrg          # found a matching prefix
10536257f37dSmrg          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
10546257f37dSmrg          func_relative_path_tcancelled=$func_stripname_result
10556257f37dSmrg          if test -z "$func_relative_path_result"; then
10566257f37dSmrg            func_relative_path_result=.
10576257f37dSmrg          fi
10586257f37dSmrg          break
10596257f37dSmrg          ;;
10606257f37dSmrg        *)
10616257f37dSmrg          func_dirname $func_relative_path_tlibdir
10626257f37dSmrg          func_relative_path_tlibdir=$func_dirname_result
10636257f37dSmrg          if test -z "$func_relative_path_tlibdir"; then
10646257f37dSmrg            # Have to descend all the way to the root!
10656257f37dSmrg            func_relative_path_result=../$func_relative_path_result
10666257f37dSmrg            func_relative_path_tcancelled=$func_relative_path_tbindir
10676257f37dSmrg            break
10686257f37dSmrg          fi
10696257f37dSmrg          func_relative_path_result=../$func_relative_path_result
10706257f37dSmrg          ;;
10716257f37dSmrg      esac
10726257f37dSmrg    done
10736257f37dSmrg
10746257f37dSmrg    # Now calculate path; take care to avoid doubling-up slashes.
10756257f37dSmrg    func_stripname '' '/' "$func_relative_path_result"
10766257f37dSmrg    func_relative_path_result=$func_stripname_result
10776257f37dSmrg    func_stripname '/' '/' "$func_relative_path_tcancelled"
10786257f37dSmrg    if test -n "$func_stripname_result"; then
10796257f37dSmrg      func_append func_relative_path_result "/$func_stripname_result"
10806257f37dSmrg    fi
10816257f37dSmrg
10826257f37dSmrg    # Normalisation. If bindir is libdir, return '.' else relative path.
10836257f37dSmrg    if test -n "$func_relative_path_result"; then
10846257f37dSmrg      func_stripname './' '' "$func_relative_path_result"
10856257f37dSmrg      func_relative_path_result=$func_stripname_result
1086fc5a983dSmrg    fi
1087fc5a983dSmrg
10886257f37dSmrg    test -n "$func_relative_path_result" || func_relative_path_result=.
10896257f37dSmrg
10906257f37dSmrg    :
10916257f37dSmrg}
10926257f37dSmrg
10936257f37dSmrg
10946257f37dSmrg# func_quote_for_eval ARG...
10956257f37dSmrg# --------------------------
10966257f37dSmrg# Aesthetically quote ARGs to be evaled later.
10976257f37dSmrg# This function returns two values:
10986257f37dSmrg#   i) func_quote_for_eval_result
10996257f37dSmrg#      double-quoted, suitable for a subsequent eval
11006257f37dSmrg#  ii) func_quote_for_eval_unquoted_result
11016257f37dSmrg#      has all characters that are still active within double
11026257f37dSmrg#      quotes backslashified.
11036257f37dSmrgfunc_quote_for_eval ()
11046257f37dSmrg{
11056257f37dSmrg    $debug_cmd
11066257f37dSmrg
11076257f37dSmrg    func_quote_for_eval_unquoted_result=
11086257f37dSmrg    func_quote_for_eval_result=
11096257f37dSmrg    while test 0 -lt $#; do
11106257f37dSmrg      case $1 in
11116257f37dSmrg        *[\\\`\"\$]*)
11126257f37dSmrg	  _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
11136257f37dSmrg        *)
11146257f37dSmrg          _G_unquoted_arg=$1 ;;
11156257f37dSmrg      esac
11166257f37dSmrg      if test -n "$func_quote_for_eval_unquoted_result"; then
11176257f37dSmrg	func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
11186257f37dSmrg      else
11196257f37dSmrg        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
11206257f37dSmrg      fi
11216257f37dSmrg
11226257f37dSmrg      case $_G_unquoted_arg in
11236257f37dSmrg        # Double-quote args containing shell metacharacters to delay
11246257f37dSmrg        # word splitting, command substitution and variable expansion
11256257f37dSmrg        # for a subsequent eval.
11266257f37dSmrg        # Many Bourne shells cannot handle close brackets correctly
11276257f37dSmrg        # in scan sets, so we specify it separately.
11286257f37dSmrg        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
11296257f37dSmrg          _G_quoted_arg=\"$_G_unquoted_arg\"
11306257f37dSmrg          ;;
11316257f37dSmrg        *)
11326257f37dSmrg          _G_quoted_arg=$_G_unquoted_arg
11336257f37dSmrg	  ;;
11346257f37dSmrg      esac
11356257f37dSmrg
11366257f37dSmrg      if test -n "$func_quote_for_eval_result"; then
11376257f37dSmrg	func_append func_quote_for_eval_result " $_G_quoted_arg"
11386257f37dSmrg      else
11396257f37dSmrg        func_append func_quote_for_eval_result "$_G_quoted_arg"
11406257f37dSmrg      fi
11416257f37dSmrg      shift
11426257f37dSmrg    done
11436257f37dSmrg}
11446257f37dSmrg
11456257f37dSmrg
11466257f37dSmrg# func_quote_for_expand ARG
11476257f37dSmrg# -------------------------
11486257f37dSmrg# Aesthetically quote ARG to be evaled later; same as above,
11496257f37dSmrg# but do not quote variable references.
11506257f37dSmrgfunc_quote_for_expand ()
11516257f37dSmrg{
11526257f37dSmrg    $debug_cmd
11536257f37dSmrg
11546257f37dSmrg    case $1 in
11556257f37dSmrg      *[\\\`\"]*)
11566257f37dSmrg	_G_arg=`$ECHO "$1" | $SED \
11576257f37dSmrg	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
11586257f37dSmrg      *)
11596257f37dSmrg        _G_arg=$1 ;;
11606257f37dSmrg    esac
11616257f37dSmrg
11626257f37dSmrg    case $_G_arg in
11636257f37dSmrg      # Double-quote args containing shell metacharacters to delay
11646257f37dSmrg      # word splitting and command substitution for a subsequent eval.
11656257f37dSmrg      # Many Bourne shells cannot handle close brackets correctly
11666257f37dSmrg      # in scan sets, so we specify it separately.
11676257f37dSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
11686257f37dSmrg        _G_arg=\"$_G_arg\"
11696257f37dSmrg        ;;
11706257f37dSmrg    esac
11716257f37dSmrg
11726257f37dSmrg    func_quote_for_expand_result=$_G_arg
11736257f37dSmrg}
11746257f37dSmrg
11756257f37dSmrg
11766257f37dSmrg# func_stripname PREFIX SUFFIX NAME
11776257f37dSmrg# ---------------------------------
11786257f37dSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
11796257f37dSmrg# PREFIX and SUFFIX must not contain globbing or regex special
11806257f37dSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
11816257f37dSmrg# dot (in which case that matches only a dot).
11826257f37dSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
11836257f37dSmrg  eval 'func_stripname ()
11846257f37dSmrg  {
11856257f37dSmrg    $debug_cmd
11866257f37dSmrg
11876257f37dSmrg    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
11886257f37dSmrg    # positional parameters, so assign one to ordinary variable first.
11896257f37dSmrg    func_stripname_result=$3
11906257f37dSmrg    func_stripname_result=${func_stripname_result#"$1"}
11916257f37dSmrg    func_stripname_result=${func_stripname_result%"$2"}
11926257f37dSmrg  }'
11936257f37dSmrgelse
11946257f37dSmrg  func_stripname ()
11956257f37dSmrg  {
11966257f37dSmrg    $debug_cmd
11976257f37dSmrg
11986257f37dSmrg    case $2 in
11996257f37dSmrg      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
12006257f37dSmrg      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
12016257f37dSmrg    esac
12026257f37dSmrg  }
12036257f37dSmrgfi
12046257f37dSmrg
12056257f37dSmrg
12066257f37dSmrg# func_show_eval CMD [FAIL_EXP]
12076257f37dSmrg# -----------------------------
12086257f37dSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
12096257f37dSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
12106257f37dSmrg# is given, then evaluate it.
12116257f37dSmrgfunc_show_eval ()
12126257f37dSmrg{
12136257f37dSmrg    $debug_cmd
12146257f37dSmrg
12156257f37dSmrg    _G_cmd=$1
12166257f37dSmrg    _G_fail_exp=${2-':'}
12176257f37dSmrg
12186257f37dSmrg    func_quote_for_expand "$_G_cmd"
12196257f37dSmrg    eval "func_notquiet $func_quote_for_expand_result"
12206257f37dSmrg
12216257f37dSmrg    $opt_dry_run || {
12226257f37dSmrg      eval "$_G_cmd"
12236257f37dSmrg      _G_status=$?
12246257f37dSmrg      if test 0 -ne "$_G_status"; then
12256257f37dSmrg	eval "(exit $_G_status); $_G_fail_exp"
12266257f37dSmrg      fi
12276257f37dSmrg    }
12286257f37dSmrg}
12296257f37dSmrg
12306257f37dSmrg
12316257f37dSmrg# func_show_eval_locale CMD [FAIL_EXP]
12326257f37dSmrg# ------------------------------------
12336257f37dSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
12346257f37dSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
12356257f37dSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
12366257f37dSmrgfunc_show_eval_locale ()
12376257f37dSmrg{
12386257f37dSmrg    $debug_cmd
12396257f37dSmrg
12406257f37dSmrg    _G_cmd=$1
12416257f37dSmrg    _G_fail_exp=${2-':'}
12426257f37dSmrg
12436257f37dSmrg    $opt_quiet || {
12446257f37dSmrg      func_quote_for_expand "$_G_cmd"
12456257f37dSmrg      eval "func_echo $func_quote_for_expand_result"
12466257f37dSmrg    }
12476257f37dSmrg
12486257f37dSmrg    $opt_dry_run || {
12496257f37dSmrg      eval "$_G_user_locale
12506257f37dSmrg	    $_G_cmd"
12516257f37dSmrg      _G_status=$?
12526257f37dSmrg      eval "$_G_safe_locale"
12536257f37dSmrg      if test 0 -ne "$_G_status"; then
12546257f37dSmrg	eval "(exit $_G_status); $_G_fail_exp"
12556257f37dSmrg      fi
12566257f37dSmrg    }
12576257f37dSmrg}
12586257f37dSmrg
12596257f37dSmrg
12606257f37dSmrg# func_tr_sh
12616257f37dSmrg# ----------
12626257f37dSmrg# Turn $1 into a string suitable for a shell variable name.
12636257f37dSmrg# Result is stored in $func_tr_sh_result.  All characters
12646257f37dSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
12656257f37dSmrg# if $1 begins with a digit, a '_' is prepended as well.
12666257f37dSmrgfunc_tr_sh ()
12676257f37dSmrg{
12686257f37dSmrg    $debug_cmd
12696257f37dSmrg
12706257f37dSmrg    case $1 in
12716257f37dSmrg    [0-9]* | *[!a-zA-Z0-9_]*)
12726257f37dSmrg      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
12736257f37dSmrg      ;;
12746257f37dSmrg    * )
12756257f37dSmrg      func_tr_sh_result=$1
12766257f37dSmrg      ;;
12776257f37dSmrg    esac
12786257f37dSmrg}
12796257f37dSmrg
12806257f37dSmrg
12816257f37dSmrg# func_verbose ARG...
12826257f37dSmrg# -------------------
12836257f37dSmrg# Echo program name prefixed message in verbose mode only.
12846257f37dSmrgfunc_verbose ()
12856257f37dSmrg{
12866257f37dSmrg    $debug_cmd
12876257f37dSmrg
12886257f37dSmrg    $opt_verbose && func_echo "$*"
12896257f37dSmrg
12906257f37dSmrg    :
12916257f37dSmrg}
12926257f37dSmrg
12936257f37dSmrg
12946257f37dSmrg# func_warn_and_continue ARG...
12956257f37dSmrg# -----------------------------
12966257f37dSmrg# Echo program name prefixed warning message to standard error.
12976257f37dSmrgfunc_warn_and_continue ()
12986257f37dSmrg{
12996257f37dSmrg    $debug_cmd
13006257f37dSmrg
13016257f37dSmrg    $require_term_colors
13026257f37dSmrg
13036257f37dSmrg    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
13046257f37dSmrg}
13056257f37dSmrg
13066257f37dSmrg
13076257f37dSmrg# func_warning CATEGORY ARG...
13086257f37dSmrg# ----------------------------
13096257f37dSmrg# Echo program name prefixed warning message to standard error. Warning
13106257f37dSmrg# messages can be filtered according to CATEGORY, where this function
13116257f37dSmrg# elides messages where CATEGORY is not listed in the global variable
13126257f37dSmrg# 'opt_warning_types'.
13136257f37dSmrgfunc_warning ()
13146257f37dSmrg{
13156257f37dSmrg    $debug_cmd
13166257f37dSmrg
13176257f37dSmrg    # CATEGORY must be in the warning_categories list!
13186257f37dSmrg    case " $warning_categories " in
13196257f37dSmrg      *" $1 "*) ;;
13206257f37dSmrg      *) func_internal_error "invalid warning category '$1'" ;;
13216257f37dSmrg    esac
13226257f37dSmrg
13236257f37dSmrg    _G_category=$1
13246257f37dSmrg    shift
13256257f37dSmrg
13266257f37dSmrg    case " $opt_warning_types " in
13276257f37dSmrg      *" $_G_category "*) $warning_func ${1+"$@"} ;;
13286257f37dSmrg    esac
13296257f37dSmrg}
13306257f37dSmrg
13316257f37dSmrg
13326257f37dSmrg# func_sort_ver VER1 VER2
13336257f37dSmrg# -----------------------
13346257f37dSmrg# 'sort -V' is not generally available.
13356257f37dSmrg# Note this deviates from the version comparison in automake
13366257f37dSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
13376257f37dSmrg# but this should suffice as we won't be specifying old
13386257f37dSmrg# version formats or redundant trailing .0 in bootstrap.conf.
13396257f37dSmrg# If we did want full compatibility then we should probably
13406257f37dSmrg# use m4_version_compare from autoconf.
13416257f37dSmrgfunc_sort_ver ()
13426257f37dSmrg{
13436257f37dSmrg    $debug_cmd
13446257f37dSmrg
13456257f37dSmrg    printf '%s\n%s\n' "$1" "$2" \
13466257f37dSmrg      | 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
13476257f37dSmrg}
13486257f37dSmrg
13496257f37dSmrg# func_lt_ver PREV CURR
13506257f37dSmrg# ---------------------
13516257f37dSmrg# Return true if PREV and CURR are in the correct order according to
13526257f37dSmrg# func_sort_ver, otherwise false.  Use it like this:
13536257f37dSmrg#
13546257f37dSmrg#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
13556257f37dSmrgfunc_lt_ver ()
13566257f37dSmrg{
13576257f37dSmrg    $debug_cmd
13586257f37dSmrg
13596257f37dSmrg    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
13606257f37dSmrg}
13616257f37dSmrg
13626257f37dSmrg
13636257f37dSmrg# Local variables:
13646257f37dSmrg# mode: shell-script
13656257f37dSmrg# sh-indentation: 2
13666257f37dSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
13676257f37dSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
13686257f37dSmrg# time-stamp-time-zone: "UTC"
13696257f37dSmrg# End:
13706257f37dSmrg#! /bin/sh
13716257f37dSmrg
13726257f37dSmrg# Set a version string for this script.
13736257f37dSmrgscriptversion=2014-01-07.03; # UTC
13746257f37dSmrg
13756257f37dSmrg# A portable, pluggable option parser for Bourne shell.
13766257f37dSmrg# Written by Gary V. Vaughan, 2010
13776257f37dSmrg
13786257f37dSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc.
13796257f37dSmrg# This is free software; see the source for copying conditions.  There is NO
13806257f37dSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13816257f37dSmrg
13826257f37dSmrg# This program is free software: you can redistribute it and/or modify
13836257f37dSmrg# it under the terms of the GNU General Public License as published by
13846257f37dSmrg# the Free Software Foundation, either version 3 of the License, or
13856257f37dSmrg# (at your option) any later version.
13866257f37dSmrg
13876257f37dSmrg# This program is distributed in the hope that it will be useful,
13886257f37dSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
13896257f37dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13906257f37dSmrg# GNU General Public License for more details.
13916257f37dSmrg
13926257f37dSmrg# You should have received a copy of the GNU General Public License
13936257f37dSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
13946257f37dSmrg
13956257f37dSmrg# Please report bugs or propose patches to gary@gnu.org.
13966257f37dSmrg
13976257f37dSmrg
13986257f37dSmrg## ------ ##
13996257f37dSmrg## Usage. ##
14006257f37dSmrg## ------ ##
14016257f37dSmrg
14026257f37dSmrg# This file is a library for parsing options in your shell scripts along
14036257f37dSmrg# with assorted other useful supporting features that you can make use
14046257f37dSmrg# of too.
14056257f37dSmrg#
14066257f37dSmrg# For the simplest scripts you might need only:
14076257f37dSmrg#
14086257f37dSmrg#   #!/bin/sh
14096257f37dSmrg#   . relative/path/to/funclib.sh
14106257f37dSmrg#   . relative/path/to/options-parser
14116257f37dSmrg#   scriptversion=1.0
14126257f37dSmrg#   func_options ${1+"$@"}
14136257f37dSmrg#   eval set dummy "$func_options_result"; shift
14146257f37dSmrg#   ...rest of your script...
14156257f37dSmrg#
14166257f37dSmrg# In order for the '--version' option to work, you will need to have a
14176257f37dSmrg# suitably formatted comment like the one at the top of this file
14186257f37dSmrg# starting with '# Written by ' and ending with '# warranty; '.
14196257f37dSmrg#
14206257f37dSmrg# For '-h' and '--help' to work, you will also need a one line
14216257f37dSmrg# description of your script's purpose in a comment directly above the
14226257f37dSmrg# '# Written by ' line, like the one at the top of this file.
14236257f37dSmrg#
14246257f37dSmrg# The default options also support '--debug', which will turn on shell
14256257f37dSmrg# execution tracing (see the comment above debug_cmd below for another
14266257f37dSmrg# use), and '--verbose' and the func_verbose function to allow your script
14276257f37dSmrg# to display verbose messages only when your user has specified
14286257f37dSmrg# '--verbose'.
14296257f37dSmrg#
14306257f37dSmrg# After sourcing this file, you can plug processing for additional
14316257f37dSmrg# options by amending the variables from the 'Configuration' section
14326257f37dSmrg# below, and following the instructions in the 'Option parsing'
14336257f37dSmrg# section further down.
14346257f37dSmrg
14356257f37dSmrg## -------------- ##
14366257f37dSmrg## Configuration. ##
14376257f37dSmrg## -------------- ##
14386257f37dSmrg
14396257f37dSmrg# You should override these variables in your script after sourcing this
14406257f37dSmrg# file so that they reflect the customisations you have added to the
14416257f37dSmrg# option parser.
14426257f37dSmrg
14436257f37dSmrg# The usage line for option parsing errors and the start of '-h' and
14446257f37dSmrg# '--help' output messages. You can embed shell variables for delayed
14456257f37dSmrg# expansion at the time the message is displayed, but you will need to
14466257f37dSmrg# quote other shell meta-characters carefully to prevent them being
14476257f37dSmrg# expanded when the contents are evaled.
14486257f37dSmrgusage='$progpath [OPTION]...'
14496257f37dSmrg
14506257f37dSmrg# Short help message in response to '-h' and '--help'.  Add to this or
14516257f37dSmrg# override it after sourcing this library to reflect the full set of
14526257f37dSmrg# options your script accepts.
14536257f37dSmrgusage_message="\
14546257f37dSmrg       --debug        enable verbose shell tracing
14556257f37dSmrg   -W, --warnings=CATEGORY
14566257f37dSmrg                      report the warnings falling in CATEGORY [all]
14576257f37dSmrg   -v, --verbose      verbosely report processing
14586257f37dSmrg       --version      print version information and exit
14596257f37dSmrg   -h, --help         print short or long help message and exit
14606257f37dSmrg"
14616257f37dSmrg
14626257f37dSmrg# Additional text appended to 'usage_message' in response to '--help'.
14636257f37dSmrglong_help_message="
14646257f37dSmrgWarning categories include:
14656257f37dSmrg       'all'          show all warnings
14666257f37dSmrg       'none'         turn off all the warnings
14676257f37dSmrg       'error'        warnings are treated as fatal errors"
14686257f37dSmrg
14696257f37dSmrg# Help message printed before fatal option parsing errors.
14706257f37dSmrgfatal_help="Try '\$progname --help' for more information."
14716257f37dSmrg
14726257f37dSmrg
14736257f37dSmrg
14746257f37dSmrg## ------------------------- ##
14756257f37dSmrg## Hook function management. ##
14766257f37dSmrg## ------------------------- ##
14776257f37dSmrg
14786257f37dSmrg# This section contains functions for adding, removing, and running hooks
14796257f37dSmrg# to the main code.  A hook is just a named list of of function, that can
14806257f37dSmrg# be run in order later on.
14816257f37dSmrg
14826257f37dSmrg# func_hookable FUNC_NAME
14836257f37dSmrg# -----------------------
14846257f37dSmrg# Declare that FUNC_NAME will run hooks added with
14856257f37dSmrg# 'func_add_hook FUNC_NAME ...'.
14866257f37dSmrgfunc_hookable ()
14876257f37dSmrg{
14886257f37dSmrg    $debug_cmd
14896257f37dSmrg
14906257f37dSmrg    func_append hookable_fns " $1"
14916257f37dSmrg}
14926257f37dSmrg
14936257f37dSmrg
14946257f37dSmrg# func_add_hook FUNC_NAME HOOK_FUNC
14956257f37dSmrg# ---------------------------------
14966257f37dSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
14976257f37dSmrg# first have been declared "hookable" by a call to 'func_hookable'.
14986257f37dSmrgfunc_add_hook ()
14996257f37dSmrg{
15006257f37dSmrg    $debug_cmd
15016257f37dSmrg
15026257f37dSmrg    case " $hookable_fns " in
15036257f37dSmrg      *" $1 "*) ;;
15046257f37dSmrg      *) func_fatal_error "'$1' does not accept hook functions." ;;
15056257f37dSmrg    esac
15066257f37dSmrg
15076257f37dSmrg    eval func_append ${1}_hooks '" $2"'
15086257f37dSmrg}
15096257f37dSmrg
15106257f37dSmrg
15116257f37dSmrg# func_remove_hook FUNC_NAME HOOK_FUNC
15126257f37dSmrg# ------------------------------------
15136257f37dSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
15146257f37dSmrgfunc_remove_hook ()
15156257f37dSmrg{
15166257f37dSmrg    $debug_cmd
15176257f37dSmrg
15186257f37dSmrg    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
15196257f37dSmrg}
15206257f37dSmrg
15216257f37dSmrg
15226257f37dSmrg# func_run_hooks FUNC_NAME [ARG]...
15236257f37dSmrg# ---------------------------------
15246257f37dSmrg# Run all hook functions registered to FUNC_NAME.
15256257f37dSmrg# It is assumed that the list of hook functions contains nothing more
15266257f37dSmrg# than a whitespace-delimited list of legal shell function names, and
15276257f37dSmrg# no effort is wasted trying to catch shell meta-characters or preserve
15286257f37dSmrg# whitespace.
15296257f37dSmrgfunc_run_hooks ()
15306257f37dSmrg{
15316257f37dSmrg    $debug_cmd
15326257f37dSmrg
15336257f37dSmrg    case " $hookable_fns " in
15346257f37dSmrg      *" $1 "*) ;;
15356257f37dSmrg      *) func_fatal_error "'$1' does not support hook funcions.n" ;;
15366257f37dSmrg    esac
15376257f37dSmrg
15386257f37dSmrg    eval _G_hook_fns=\$$1_hooks; shift
15396257f37dSmrg
15406257f37dSmrg    for _G_hook in $_G_hook_fns; do
15416257f37dSmrg      eval $_G_hook '"$@"'
15426257f37dSmrg
15436257f37dSmrg      # store returned options list back into positional
15446257f37dSmrg      # parameters for next 'cmd' execution.
15456257f37dSmrg      eval _G_hook_result=\$${_G_hook}_result
15466257f37dSmrg      eval set dummy "$_G_hook_result"; shift
15476257f37dSmrg    done
15486257f37dSmrg
15496257f37dSmrg    func_quote_for_eval ${1+"$@"}
15506257f37dSmrg    func_run_hooks_result=$func_quote_for_eval_result
15516257f37dSmrg}
15526257f37dSmrg
15536257f37dSmrg
15546257f37dSmrg
15556257f37dSmrg## --------------- ##
15566257f37dSmrg## Option parsing. ##
15576257f37dSmrg## --------------- ##
15586257f37dSmrg
15596257f37dSmrg# In order to add your own option parsing hooks, you must accept the
15606257f37dSmrg# full positional parameter list in your hook function, remove any
15616257f37dSmrg# options that you action, and then pass back the remaining unprocessed
15626257f37dSmrg# options in '<hooked_function_name>_result', escaped suitably for
15636257f37dSmrg# 'eval'.  Like this:
15646257f37dSmrg#
15656257f37dSmrg#    my_options_prep ()
15666257f37dSmrg#    {
15676257f37dSmrg#        $debug_cmd
15686257f37dSmrg#
15696257f37dSmrg#        # Extend the existing usage message.
15706257f37dSmrg#        usage_message=$usage_message'
15716257f37dSmrg#      -s, --silent       don'\''t print informational messages
15726257f37dSmrg#    '
15736257f37dSmrg#
15746257f37dSmrg#        func_quote_for_eval ${1+"$@"}
15756257f37dSmrg#        my_options_prep_result=$func_quote_for_eval_result
15766257f37dSmrg#    }
15776257f37dSmrg#    func_add_hook func_options_prep my_options_prep
15786257f37dSmrg#
15796257f37dSmrg#
15806257f37dSmrg#    my_silent_option ()
15816257f37dSmrg#    {
15826257f37dSmrg#        $debug_cmd
15836257f37dSmrg#
15846257f37dSmrg#        # Note that for efficiency, we parse as many options as we can
15856257f37dSmrg#        # recognise in a loop before passing the remainder back to the
15866257f37dSmrg#        # caller on the first unrecognised argument we encounter.
15876257f37dSmrg#        while test $# -gt 0; do
15886257f37dSmrg#          opt=$1; shift
15896257f37dSmrg#          case $opt in
15906257f37dSmrg#            --silent|-s) opt_silent=: ;;
15916257f37dSmrg#            # Separate non-argument short options:
15926257f37dSmrg#            -s*)         func_split_short_opt "$_G_opt"
15936257f37dSmrg#                         set dummy "$func_split_short_opt_name" \
15946257f37dSmrg#                             "-$func_split_short_opt_arg" ${1+"$@"}
15956257f37dSmrg#                         shift
15966257f37dSmrg#                         ;;
15976257f37dSmrg#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
15986257f37dSmrg#          esac
15996257f37dSmrg#        done
16006257f37dSmrg#
16016257f37dSmrg#        func_quote_for_eval ${1+"$@"}
16026257f37dSmrg#        my_silent_option_result=$func_quote_for_eval_result
16036257f37dSmrg#    }
16046257f37dSmrg#    func_add_hook func_parse_options my_silent_option
16056257f37dSmrg#
16066257f37dSmrg#
16076257f37dSmrg#    my_option_validation ()
16086257f37dSmrg#    {
16096257f37dSmrg#        $debug_cmd
16106257f37dSmrg#
16116257f37dSmrg#        $opt_silent && $opt_verbose && func_fatal_help "\
16126257f37dSmrg#    '--silent' and '--verbose' options are mutually exclusive."
16136257f37dSmrg#
16146257f37dSmrg#        func_quote_for_eval ${1+"$@"}
16156257f37dSmrg#        my_option_validation_result=$func_quote_for_eval_result
16166257f37dSmrg#    }
16176257f37dSmrg#    func_add_hook func_validate_options my_option_validation
16186257f37dSmrg#
16196257f37dSmrg# You'll alse need to manually amend $usage_message to reflect the extra
16206257f37dSmrg# options you parse.  It's preferable to append if you can, so that
16216257f37dSmrg# multiple option parsing hooks can be added safely.
16226257f37dSmrg
16236257f37dSmrg
16246257f37dSmrg# func_options [ARG]...
16256257f37dSmrg# ---------------------
16266257f37dSmrg# All the functions called inside func_options are hookable. See the
16276257f37dSmrg# individual implementations for details.
16286257f37dSmrgfunc_hookable func_options
16296257f37dSmrgfunc_options ()
16306257f37dSmrg{
16316257f37dSmrg    $debug_cmd
16326257f37dSmrg
16336257f37dSmrg    func_options_prep ${1+"$@"}
16346257f37dSmrg    eval func_parse_options \
16356257f37dSmrg        ${func_options_prep_result+"$func_options_prep_result"}
16366257f37dSmrg    eval func_validate_options \
16376257f37dSmrg        ${func_parse_options_result+"$func_parse_options_result"}
16386257f37dSmrg
16396257f37dSmrg    eval func_run_hooks func_options \
16406257f37dSmrg        ${func_validate_options_result+"$func_validate_options_result"}
16416257f37dSmrg
16426257f37dSmrg    # save modified positional parameters for caller
16436257f37dSmrg    func_options_result=$func_run_hooks_result
1644fc5a983dSmrg}
1645fc5a983dSmrg
1646fc5a983dSmrg
16476257f37dSmrg# func_options_prep [ARG]...
16486257f37dSmrg# --------------------------
16496257f37dSmrg# All initialisations required before starting the option parse loop.
16506257f37dSmrg# Note that when calling hook functions, we pass through the list of
16516257f37dSmrg# positional parameters.  If a hook function modifies that list, and
16526257f37dSmrg# needs to propogate that back to rest of this script, then the complete
16536257f37dSmrg# modified list must be put in 'func_run_hooks_result' before
16546257f37dSmrg# returning.
16556257f37dSmrgfunc_hookable func_options_prep
16566257f37dSmrgfunc_options_prep ()
1657fc5a983dSmrg{
16586257f37dSmrg    $debug_cmd
1659f3561b8bSmrg
16606257f37dSmrg    # Option defaults:
16616257f37dSmrg    opt_verbose=false
16626257f37dSmrg    opt_warning_types=
16636257f37dSmrg
16646257f37dSmrg    func_run_hooks func_options_prep ${1+"$@"}
16656257f37dSmrg
16666257f37dSmrg    # save modified positional parameters for caller
16676257f37dSmrg    func_options_prep_result=$func_run_hooks_result
1668fc5a983dSmrg}
1669fc5a983dSmrg
1670fc5a983dSmrg
16716257f37dSmrg# func_parse_options [ARG]...
16726257f37dSmrg# ---------------------------
16736257f37dSmrg# The main option parsing loop.
16746257f37dSmrgfunc_hookable func_parse_options
16756257f37dSmrgfunc_parse_options ()
1676fc5a983dSmrg{
16776257f37dSmrg    $debug_cmd
1678f3561b8bSmrg
16796257f37dSmrg    func_parse_options_result=
1680f3561b8bSmrg
16816257f37dSmrg    # this just eases exit handling
16826257f37dSmrg    while test $# -gt 0; do
16836257f37dSmrg      # Defer to hook functions for initial option parsing, so they
16846257f37dSmrg      # get priority in the event of reusing an option name.
16856257f37dSmrg      func_run_hooks func_parse_options ${1+"$@"}
1686fc5a983dSmrg
16876257f37dSmrg      # Adjust func_parse_options positional parameters to match
16886257f37dSmrg      eval set dummy "$func_run_hooks_result"; shift
1689fc5a983dSmrg
16906257f37dSmrg      # Break out of the loop if we already parsed every option.
16916257f37dSmrg      test $# -gt 0 || break
1692fc5a983dSmrg
16936257f37dSmrg      _G_opt=$1
16946257f37dSmrg      shift
16956257f37dSmrg      case $_G_opt in
16966257f37dSmrg        --debug|-x)   debug_cmd='set -x'
16976257f37dSmrg                      func_echo "enabling shell trace mode"
16986257f37dSmrg                      $debug_cmd
16996257f37dSmrg                      ;;
17006257f37dSmrg
17016257f37dSmrg        --no-warnings|--no-warning|--no-warn)
17026257f37dSmrg                      set dummy --warnings none ${1+"$@"}
17036257f37dSmrg                      shift
17046257f37dSmrg		      ;;
1705f3561b8bSmrg
17066257f37dSmrg        --warnings|--warning|-W)
17076257f37dSmrg                      test $# = 0 && func_missing_arg $_G_opt && break
17086257f37dSmrg                      case " $warning_categories $1" in
17096257f37dSmrg                        *" $1 "*)
17106257f37dSmrg                          # trailing space prevents matching last $1 above
17116257f37dSmrg                          func_append_uniq opt_warning_types " $1"
17126257f37dSmrg                          ;;
17136257f37dSmrg                        *all)
17146257f37dSmrg                          opt_warning_types=$warning_categories
17156257f37dSmrg                          ;;
17166257f37dSmrg                        *none)
17176257f37dSmrg                          opt_warning_types=none
17186257f37dSmrg                          warning_func=:
17196257f37dSmrg                          ;;
17206257f37dSmrg                        *error)
17216257f37dSmrg                          opt_warning_types=$warning_categories
17226257f37dSmrg                          warning_func=func_fatal_error
17236257f37dSmrg                          ;;
17246257f37dSmrg                        *)
17256257f37dSmrg                          func_fatal_error \
17266257f37dSmrg                             "unsupported warning category: '$1'"
17276257f37dSmrg                          ;;
17286257f37dSmrg                      esac
17296257f37dSmrg                      shift
17306257f37dSmrg                      ;;
17316257f37dSmrg
17326257f37dSmrg        --verbose|-v) opt_verbose=: ;;
17336257f37dSmrg        --version)    func_version ;;
17346257f37dSmrg        -\?|-h)       func_usage ;;
17356257f37dSmrg        --help)       func_help ;;
17366257f37dSmrg
17376257f37dSmrg	# Separate optargs to long options (plugins may need this):
17386257f37dSmrg	--*=*)        func_split_equals "$_G_opt"
17396257f37dSmrg	              set dummy "$func_split_equals_lhs" \
17406257f37dSmrg                          "$func_split_equals_rhs" ${1+"$@"}
17416257f37dSmrg                      shift
17426257f37dSmrg                      ;;
17436257f37dSmrg
17446257f37dSmrg       # Separate optargs to short options:
17456257f37dSmrg        -W*)
17466257f37dSmrg                      func_split_short_opt "$_G_opt"
17476257f37dSmrg                      set dummy "$func_split_short_opt_name" \
17486257f37dSmrg                          "$func_split_short_opt_arg" ${1+"$@"}
17496257f37dSmrg                      shift
17506257f37dSmrg                      ;;
17516257f37dSmrg
17526257f37dSmrg        # Separate non-argument short options:
17536257f37dSmrg        -\?*|-h*|-v*|-x*)
17546257f37dSmrg                      func_split_short_opt "$_G_opt"
17556257f37dSmrg                      set dummy "$func_split_short_opt_name" \
17566257f37dSmrg                          "-$func_split_short_opt_arg" ${1+"$@"}
17576257f37dSmrg                      shift
17586257f37dSmrg                      ;;
17596257f37dSmrg
17606257f37dSmrg        --)           break ;;
17616257f37dSmrg        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
17626257f37dSmrg        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
17636257f37dSmrg      esac
17646257f37dSmrg    done
17656257f37dSmrg
17666257f37dSmrg    # save modified positional parameters for caller
17676257f37dSmrg    func_quote_for_eval ${1+"$@"}
17686257f37dSmrg    func_parse_options_result=$func_quote_for_eval_result
1769fc5a983dSmrg}
1770fc5a983dSmrg
1771f3561b8bSmrg
17726257f37dSmrg# func_validate_options [ARG]...
17736257f37dSmrg# ------------------------------
17746257f37dSmrg# Perform any sanity checks on option settings and/or unconsumed
17756257f37dSmrg# arguments.
17766257f37dSmrgfunc_hookable func_validate_options
17776257f37dSmrgfunc_validate_options ()
1778fc5a983dSmrg{
17796257f37dSmrg    $debug_cmd
1780f3561b8bSmrg
17816257f37dSmrg    # Display all warnings if -W was not given.
17826257f37dSmrg    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
1783f3561b8bSmrg
17846257f37dSmrg    func_run_hooks func_validate_options ${1+"$@"}
1785fc5a983dSmrg
17866257f37dSmrg    # Bail if the options were screwed!
17876257f37dSmrg    $exit_cmd $EXIT_FAILURE
17886257f37dSmrg
17896257f37dSmrg    # save modified positional parameters for caller
17906257f37dSmrg    func_validate_options_result=$func_run_hooks_result
1791bd304fc0Smrg}
1792f3561b8bSmrg
1793f3561b8bSmrg
1794bd304fc0Smrg
17956257f37dSmrg## ----------------- ##
17966257f37dSmrg## Helper functions. ##
17976257f37dSmrg## ----------------- ##
1798f3561b8bSmrg
17996257f37dSmrg# This section contains the helper functions used by the rest of the
18006257f37dSmrg# hookable option parser framework in ascii-betical order.
18016257f37dSmrg
18026257f37dSmrg
18036257f37dSmrg# func_fatal_help ARG...
18046257f37dSmrg# ----------------------
18056257f37dSmrg# Echo program name prefixed message to standard error, followed by
18066257f37dSmrg# a help hint, and exit.
18076257f37dSmrgfunc_fatal_help ()
1808f3561b8bSmrg{
18096257f37dSmrg    $debug_cmd
1810bd304fc0Smrg
18116257f37dSmrg    eval \$ECHO \""Usage: $usage"\"
18126257f37dSmrg    eval \$ECHO \""$fatal_help"\"
18136257f37dSmrg    func_error ${1+"$@"}
18146257f37dSmrg    exit $EXIT_FAILURE
1815f3561b8bSmrg}
1816f3561b8bSmrg
18176257f37dSmrg
18186257f37dSmrg# func_help
18196257f37dSmrg# ---------
18206257f37dSmrg# Echo long help message to standard output and exit.
1821f3561b8bSmrgfunc_help ()
1822f3561b8bSmrg{
18236257f37dSmrg    $debug_cmd
18246257f37dSmrg
18256257f37dSmrg    func_usage_message
18266257f37dSmrg    $ECHO "$long_help_message"
18276257f37dSmrg    exit 0
1828f3561b8bSmrg}
1829f3561b8bSmrg
18306257f37dSmrg
18316257f37dSmrg# func_missing_arg ARGNAME
18326257f37dSmrg# ------------------------
1833f3561b8bSmrg# Echo program name prefixed message to standard error and set global
1834f3561b8bSmrg# exit_cmd.
1835f3561b8bSmrgfunc_missing_arg ()
1836f3561b8bSmrg{
18376257f37dSmrg    $debug_cmd
1838bd304fc0Smrg
18396257f37dSmrg    func_error "Missing argument for '$1'."
1840f3561b8bSmrg    exit_cmd=exit
1841fc5a983dSmrg}
1842fc5a983dSmrg
1843fc5a983dSmrg
18446257f37dSmrg# func_split_equals STRING
18456257f37dSmrg# ------------------------
18466257f37dSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
18476257f37dSmrg# splitting STRING at the '=' sign.
18486257f37dSmrgtest -z "$_G_HAVE_XSI_OPS" \
18496257f37dSmrg    && (eval 'x=a/b/c;
18506257f37dSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
18516257f37dSmrg    && _G_HAVE_XSI_OPS=yes
18526257f37dSmrg
18536257f37dSmrgif test yes = "$_G_HAVE_XSI_OPS"
18546257f37dSmrgthen
18556257f37dSmrg  # This is an XSI compatible shell, allowing a faster implementation...
18566257f37dSmrg  eval 'func_split_equals ()
18576257f37dSmrg  {
18586257f37dSmrg      $debug_cmd
18596257f37dSmrg
18606257f37dSmrg      func_split_equals_lhs=${1%%=*}
18616257f37dSmrg      func_split_equals_rhs=${1#*=}
18626257f37dSmrg      test "x$func_split_equals_lhs" = "x$1" \
18636257f37dSmrg        && func_split_equals_rhs=
18646257f37dSmrg  }'
18656257f37dSmrgelse
18666257f37dSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
18676257f37dSmrg  func_split_equals ()
18686257f37dSmrg  {
18696257f37dSmrg      $debug_cmd
18706257f37dSmrg
18716257f37dSmrg      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
18726257f37dSmrg      func_split_equals_rhs=
18736257f37dSmrg      test "x$func_split_equals_lhs" = "x$1" \
18746257f37dSmrg        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
18756257f37dSmrg  }
18766257f37dSmrgfi #func_split_equals
18776257f37dSmrg
18786257f37dSmrg
18796257f37dSmrg# func_split_short_opt SHORTOPT
18806257f37dSmrg# -----------------------------
1881bd304fc0Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
1882bd304fc0Smrg# variables after splitting SHORTOPT after the 2nd character.
18836257f37dSmrgif test yes = "$_G_HAVE_XSI_OPS"
18846257f37dSmrgthen
18856257f37dSmrg  # This is an XSI compatible shell, allowing a faster implementation...
18866257f37dSmrg  eval 'func_split_short_opt ()
18876257f37dSmrg  {
18886257f37dSmrg      $debug_cmd
18896257f37dSmrg
18906257f37dSmrg      func_split_short_opt_arg=${1#??}
18916257f37dSmrg      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
18926257f37dSmrg  }'
18936257f37dSmrgelse
18946257f37dSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
18956257f37dSmrg  func_split_short_opt ()
18966257f37dSmrg  {
18976257f37dSmrg      $debug_cmd
18986257f37dSmrg
18996257f37dSmrg      func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
19006257f37dSmrg      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
19016257f37dSmrg  }
19026257f37dSmrgfi #func_split_short_opt
19036257f37dSmrg
19046257f37dSmrg
19056257f37dSmrg# func_usage
19066257f37dSmrg# ----------
19076257f37dSmrg# Echo short help message to standard output and exit.
19086257f37dSmrgfunc_usage ()
1909bd304fc0Smrg{
19106257f37dSmrg    $debug_cmd
1911bd304fc0Smrg
19126257f37dSmrg    func_usage_message
19136257f37dSmrg    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
19146257f37dSmrg    exit 0
19156257f37dSmrg}
1916fc5a983dSmrg
1917f3561b8bSmrg
19186257f37dSmrg# func_usage_message
19196257f37dSmrg# ------------------
19206257f37dSmrg# Echo short help message to standard output.
19216257f37dSmrgfunc_usage_message ()
1922bd304fc0Smrg{
19236257f37dSmrg    $debug_cmd
1924bd304fc0Smrg
19256257f37dSmrg    eval \$ECHO \""Usage: $usage"\"
19266257f37dSmrg    echo
19276257f37dSmrg    $SED -n 's|^# ||
19286257f37dSmrg        /^Written by/{
19296257f37dSmrg          x;p;x
19306257f37dSmrg        }
19316257f37dSmrg	h
19326257f37dSmrg	/^Written by/q' < "$progpath"
19336257f37dSmrg    echo
19346257f37dSmrg    eval \$ECHO \""$usage_message"\"
19356257f37dSmrg}
1936bd304fc0Smrg
1937bd304fc0Smrg
19386257f37dSmrg# func_version
19396257f37dSmrg# ------------
19406257f37dSmrg# Echo version message to standard output and exit.
19416257f37dSmrgfunc_version ()
19426257f37dSmrg{
19436257f37dSmrg    $debug_cmd
1944f3561b8bSmrg
19456257f37dSmrg    printf '%s\n' "$progname $scriptversion"
19466257f37dSmrg    $SED -n '
19476257f37dSmrg        /(C)/!b go
19486257f37dSmrg        :more
19496257f37dSmrg        /\./!{
19506257f37dSmrg          N
19516257f37dSmrg          s|\n# | |
19526257f37dSmrg          b more
19536257f37dSmrg        }
19546257f37dSmrg        :go
19556257f37dSmrg        /^# Written by /,/# warranty; / {
19566257f37dSmrg          s|^# ||
19576257f37dSmrg          s|^# *$||
19586257f37dSmrg          s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
19596257f37dSmrg          p
19606257f37dSmrg        }
19616257f37dSmrg        /^# Written by / {
19626257f37dSmrg          s|^# ||
19636257f37dSmrg          p
19646257f37dSmrg        }
19656257f37dSmrg        /^warranty; /q' < "$progpath"
1966f3561b8bSmrg
19676257f37dSmrg    exit $?
19686257f37dSmrg}
1969fc5a983dSmrg
1970fc5a983dSmrg
19716257f37dSmrg# Local variables:
19726257f37dSmrg# mode: shell-script
19736257f37dSmrg# sh-indentation: 2
19746257f37dSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
19756257f37dSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
19766257f37dSmrg# time-stamp-time-zone: "UTC"
19776257f37dSmrg# End:
1978fc5a983dSmrg
19796257f37dSmrg# Set a version string.
19806257f37dSmrgscriptversion='(GNU libtool) 2.4.6'
1981fc5a983dSmrg
1982f3561b8bSmrg
19836257f37dSmrg# func_echo ARG...
19846257f37dSmrg# ----------------
19856257f37dSmrg# Libtool also displays the current mode in messages, so override
19866257f37dSmrg# funclib.sh func_echo with this custom definition.
19876257f37dSmrgfunc_echo ()
1988bd304fc0Smrg{
19896257f37dSmrg    $debug_cmd
1990bd304fc0Smrg
19916257f37dSmrg    _G_message=$*
1992bd304fc0Smrg
19936257f37dSmrg    func_echo_IFS=$IFS
19946257f37dSmrg    IFS=$nl
19956257f37dSmrg    for _G_line in $_G_message; do
19966257f37dSmrg      IFS=$func_echo_IFS
19976257f37dSmrg      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
19986257f37dSmrg    done
19996257f37dSmrg    IFS=$func_echo_IFS
20006257f37dSmrg}
2001bd304fc0Smrg
20026257f37dSmrg
20036257f37dSmrg# func_warning ARG...
20046257f37dSmrg# -------------------
20056257f37dSmrg# Libtool warnings are not categorized, so override funclib.sh
20066257f37dSmrg# func_warning with this simpler definition.
20076257f37dSmrgfunc_warning ()
2008bd304fc0Smrg{
20096257f37dSmrg    $debug_cmd
2010bd304fc0Smrg
20116257f37dSmrg    $warning_func ${1+"$@"}
20126257f37dSmrg}
2013bd304fc0Smrg
2014bd304fc0Smrg
20156257f37dSmrg## ---------------- ##
20166257f37dSmrg## Options parsing. ##
20176257f37dSmrg## ---------------- ##
20186257f37dSmrg
20196257f37dSmrg# Hook in the functions to make sure our own options are parsed during
20206257f37dSmrg# the option parsing loop.
20216257f37dSmrg
20226257f37dSmrgusage='$progpath [OPTION]... [MODE-ARG]...'
20236257f37dSmrg
20246257f37dSmrg# Short help message in response to '-h'.
20256257f37dSmrgusage_message="Options:
20266257f37dSmrg       --config             show all configuration variables
20276257f37dSmrg       --debug              enable verbose shell tracing
20286257f37dSmrg   -n, --dry-run            display commands without modifying any files
20296257f37dSmrg       --features           display basic configuration information and exit
20306257f37dSmrg       --mode=MODE          use operation mode MODE
20316257f37dSmrg       --no-warnings        equivalent to '-Wnone'
20326257f37dSmrg       --preserve-dup-deps  don't remove duplicate dependency libraries
20336257f37dSmrg       --quiet, --silent    don't print informational messages
20346257f37dSmrg       --tag=TAG            use configuration variables from tag TAG
20356257f37dSmrg   -v, --verbose            print more informational messages than default
20366257f37dSmrg       --version            print version information
20376257f37dSmrg   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
20386257f37dSmrg   -h, --help, --help-all   print short, long, or detailed help message
20396257f37dSmrg"
2040bd304fc0Smrg
20416257f37dSmrg# Additional text appended to 'usage_message' in response to '--help'.
20426257f37dSmrgfunc_help ()
2043bd304fc0Smrg{
20446257f37dSmrg    $debug_cmd
20456257f37dSmrg
20466257f37dSmrg    func_usage_message
20476257f37dSmrg    $ECHO "$long_help_message
20486257f37dSmrg
20496257f37dSmrgMODE must be one of the following:
20506257f37dSmrg
20516257f37dSmrg       clean           remove files from the build directory
20526257f37dSmrg       compile         compile a source file into a libtool object
20536257f37dSmrg       execute         automatically set library path, then run a program
20546257f37dSmrg       finish          complete the installation of libtool libraries
20556257f37dSmrg       install         install libraries or executables
20566257f37dSmrg       link            create a library or an executable
20576257f37dSmrg       uninstall       remove libraries from an installed directory
20586257f37dSmrg
20596257f37dSmrgMODE-ARGS vary depending on the MODE.  When passed as first option,
20606257f37dSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
20616257f37dSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE.
20626257f37dSmrg
20636257f37dSmrgWhen reporting a bug, please describe a test case to reproduce it and
20646257f37dSmrginclude the following information:
20656257f37dSmrg
20666257f37dSmrg       host-triplet:   $host
20676257f37dSmrg       shell:          $SHELL
20686257f37dSmrg       compiler:       $LTCC
20696257f37dSmrg       compiler flags: $LTCFLAGS
20706257f37dSmrg       linker:         $LD (gnu? $with_gnu_ld)
20716257f37dSmrg       version:        $progname (GNU libtool) 2.4.6
20726257f37dSmrg       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
20736257f37dSmrg       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
20746257f37dSmrg
20756257f37dSmrgReport bugs to <bug-libtool@gnu.org>.
20766257f37dSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>.
20776257f37dSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>."
20786257f37dSmrg    exit 0
20796257f37dSmrg}
2080bd304fc0Smrg
2081bd304fc0Smrg
20826257f37dSmrg# func_lo2o OBJECT-NAME
20836257f37dSmrg# ---------------------
20846257f37dSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
20856257f37dSmrg# object suffix.
20866257f37dSmrg
20876257f37dSmrglo2o=s/\\.lo\$/.$objext/
20886257f37dSmrgo2lo=s/\\.$objext\$/.lo/
20896257f37dSmrg
20906257f37dSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
20916257f37dSmrg  eval 'func_lo2o ()
20926257f37dSmrg  {
20936257f37dSmrg    case $1 in
20946257f37dSmrg      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
20956257f37dSmrg      *   ) func_lo2o_result=$1               ;;
20966257f37dSmrg    esac
20976257f37dSmrg  }'
20986257f37dSmrg
20996257f37dSmrg  # func_xform LIBOBJ-OR-SOURCE
21006257f37dSmrg  # ---------------------------
21016257f37dSmrg  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
21026257f37dSmrg  # suffix to a '.lo' libtool-object suffix.
21036257f37dSmrg  eval 'func_xform ()
21046257f37dSmrg  {
21056257f37dSmrg    func_xform_result=${1%.*}.lo
21066257f37dSmrg  }'
21076257f37dSmrgelse
21086257f37dSmrg  # ...otherwise fall back to using sed.
21096257f37dSmrg  func_lo2o ()
21106257f37dSmrg  {
21116257f37dSmrg    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
21126257f37dSmrg  }
21136257f37dSmrg
21146257f37dSmrg  func_xform ()
21156257f37dSmrg  {
21166257f37dSmrg    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
21176257f37dSmrg  }
21186257f37dSmrgfi
2119bd304fc0Smrg
2120bd304fc0Smrg
21216257f37dSmrg# func_fatal_configuration ARG...
21226257f37dSmrg# -------------------------------
2123f3561b8bSmrg# Echo program name prefixed message to standard error, followed by
2124f3561b8bSmrg# a configuration failure hint, and exit.
2125f3561b8bSmrgfunc_fatal_configuration ()
2126f3561b8bSmrg{
21276257f37dSmrg    func__fatal_error ${1+"$@"} \
21286257f37dSmrg      "See the $PACKAGE documentation for more information." \
21296257f37dSmrg      "Fatal configuration error."
2130f3561b8bSmrg}
2131fc5a983dSmrg
2132fc5a983dSmrg
2133f3561b8bSmrg# func_config
21346257f37dSmrg# -----------
2135f3561b8bSmrg# Display the configuration for all the tags in this script.
2136f3561b8bSmrgfunc_config ()
2137f3561b8bSmrg{
2138f3561b8bSmrg    re_begincf='^# ### BEGIN LIBTOOL'
2139f3561b8bSmrg    re_endcf='^# ### END LIBTOOL'
2140f3561b8bSmrg
2141f3561b8bSmrg    # Default configuration.
2142f3561b8bSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
2143fc5a983dSmrg
2144fc5a983dSmrg    # Now print the configurations for the tags.
2145fc5a983dSmrg    for tagname in $taglist; do
2146f3561b8bSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
2147fc5a983dSmrg    done
2148fc5a983dSmrg
2149f3561b8bSmrg    exit $?
2150f3561b8bSmrg}
2151fc5a983dSmrg
21526257f37dSmrg
2153f3561b8bSmrg# func_features
21546257f37dSmrg# -------------
2155f3561b8bSmrg# Display the features supported by this script.
2156f3561b8bSmrgfunc_features ()
2157f3561b8bSmrg{
2158bd304fc0Smrg    echo "host: $host"
21596257f37dSmrg    if test yes = "$build_libtool_libs"; then
2160bd304fc0Smrg      echo "enable shared libraries"
2161fc5a983dSmrg    else
2162bd304fc0Smrg      echo "disable shared libraries"
2163fc5a983dSmrg    fi
21646257f37dSmrg    if test yes = "$build_old_libs"; then
2165bd304fc0Smrg      echo "enable static libraries"
2166fc5a983dSmrg    else
2167bd304fc0Smrg      echo "disable static libraries"
2168fc5a983dSmrg    fi
2169f3561b8bSmrg
2170fc5a983dSmrg    exit $?
2171f3561b8bSmrg}
2172fc5a983dSmrg
21736257f37dSmrg
21746257f37dSmrg# func_enable_tag TAGNAME
21756257f37dSmrg# -----------------------
2176f3561b8bSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
2177f3561b8bSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
2178f3561b8bSmrg# variable here.
2179f3561b8bSmrgfunc_enable_tag ()
2180f3561b8bSmrg{
21816257f37dSmrg    # Global variable:
21826257f37dSmrg    tagname=$1
2183fc5a983dSmrg
21846257f37dSmrg    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
21856257f37dSmrg    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
21866257f37dSmrg    sed_extractcf=/$re_begincf/,/$re_endcf/p
2187fc5a983dSmrg
21886257f37dSmrg    # Validate tagname.
21896257f37dSmrg    case $tagname in
21906257f37dSmrg      *[!-_A-Za-z0-9,/]*)
21916257f37dSmrg        func_fatal_error "invalid tag name: $tagname"
21926257f37dSmrg        ;;
21936257f37dSmrg    esac
2194fc5a983dSmrg
21956257f37dSmrg    # Don't test for the "default" C tag, as we know it's
21966257f37dSmrg    # there but not specially marked.
21976257f37dSmrg    case $tagname in
21986257f37dSmrg        CC) ;;
2199f3561b8bSmrg    *)
22006257f37dSmrg        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
22016257f37dSmrg	  taglist="$taglist $tagname"
22026257f37dSmrg
22036257f37dSmrg	  # Evaluate the configuration.  Be careful to quote the path
22046257f37dSmrg	  # and the sed script, to avoid splitting on whitespace, but
22056257f37dSmrg	  # also don't use non-portable quotes within backquotes within
22066257f37dSmrg	  # quotes we have to do it in 2 steps:
22076257f37dSmrg	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
22086257f37dSmrg	  eval "$extractedcf"
22096257f37dSmrg        else
22106257f37dSmrg	  func_error "ignoring unknown tag $tagname"
22116257f37dSmrg        fi
22126257f37dSmrg        ;;
22136257f37dSmrg    esac
2214f3561b8bSmrg}
2215f3561b8bSmrg
22166257f37dSmrg
2217bd304fc0Smrg# func_check_version_match
22186257f37dSmrg# ------------------------
2219bd304fc0Smrg# Ensure that we are using m4 macros, and libtool script from the same
2220bd304fc0Smrg# release of libtool.
2221bd304fc0Smrgfunc_check_version_match ()
2222f3561b8bSmrg{
22236257f37dSmrg    if test "$package_revision" != "$macro_revision"; then
22246257f37dSmrg      if test "$VERSION" != "$macro_version"; then
22256257f37dSmrg        if test -z "$macro_version"; then
22266257f37dSmrg          cat >&2 <<_LT_EOF
2227bd304fc0Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2228bd304fc0Smrg$progname: definition of this LT_INIT comes from an older release.
2229bd304fc0Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2230bd304fc0Smrg$progname: and run autoconf again.
2231bd304fc0Smrg_LT_EOF
22326257f37dSmrg        else
22336257f37dSmrg          cat >&2 <<_LT_EOF
2234bd304fc0Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2235bd304fc0Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
2236bd304fc0Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2237bd304fc0Smrg$progname: and run autoconf again.
2238bd304fc0Smrg_LT_EOF
22396257f37dSmrg        fi
22406257f37dSmrg      else
22416257f37dSmrg        cat >&2 <<_LT_EOF
2242bd304fc0Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
2243bd304fc0Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
2244bd304fc0Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
2245bd304fc0Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
2246bd304fc0Smrg_LT_EOF
22476257f37dSmrg      fi
2248bd304fc0Smrg
22496257f37dSmrg      exit $EXIT_MISMATCH
22506257f37dSmrg    fi
2251bd304fc0Smrg}
2252bd304fc0Smrg
2253bd304fc0Smrg
22546257f37dSmrg# libtool_options_prep [ARG]...
22556257f37dSmrg# -----------------------------
22566257f37dSmrg# Preparation for options parsed by libtool.
22576257f37dSmrglibtool_options_prep ()
22586257f37dSmrg{
22596257f37dSmrg    $debug_mode
2260fc5a983dSmrg
22616257f37dSmrg    # Option defaults:
22626257f37dSmrg    opt_config=false
22636257f37dSmrg    opt_dlopen=
22646257f37dSmrg    opt_dry_run=false
22656257f37dSmrg    opt_help=false
22666257f37dSmrg    opt_mode=
22676257f37dSmrg    opt_preserve_dup_deps=false
22686257f37dSmrg    opt_quiet=false
2269fc5a983dSmrg
22706257f37dSmrg    nonopt=
22716257f37dSmrg    preserve_args=
2272bd304fc0Smrg
22736257f37dSmrg    # Shorthand for --mode=foo, only valid as the first argument
22746257f37dSmrg    case $1 in
22756257f37dSmrg    clean|clea|cle|cl)
22766257f37dSmrg      shift; set dummy --mode clean ${1+"$@"}; shift
22776257f37dSmrg      ;;
22786257f37dSmrg    compile|compil|compi|comp|com|co|c)
22796257f37dSmrg      shift; set dummy --mode compile ${1+"$@"}; shift
22806257f37dSmrg      ;;
22816257f37dSmrg    execute|execut|execu|exec|exe|ex|e)
22826257f37dSmrg      shift; set dummy --mode execute ${1+"$@"}; shift
22836257f37dSmrg      ;;
22846257f37dSmrg    finish|finis|fini|fin|fi|f)
22856257f37dSmrg      shift; set dummy --mode finish ${1+"$@"}; shift
22866257f37dSmrg      ;;
22876257f37dSmrg    install|instal|insta|inst|ins|in|i)
22886257f37dSmrg      shift; set dummy --mode install ${1+"$@"}; shift
22896257f37dSmrg      ;;
22906257f37dSmrg    link|lin|li|l)
22916257f37dSmrg      shift; set dummy --mode link ${1+"$@"}; shift
22926257f37dSmrg      ;;
22936257f37dSmrg    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
22946257f37dSmrg      shift; set dummy --mode uninstall ${1+"$@"}; shift
22956257f37dSmrg      ;;
22966257f37dSmrg    esac
22976257f37dSmrg
22986257f37dSmrg    # Pass back the list of options.
22996257f37dSmrg    func_quote_for_eval ${1+"$@"}
23006257f37dSmrg    libtool_options_prep_result=$func_quote_for_eval_result
23016257f37dSmrg}
23026257f37dSmrgfunc_add_hook func_options_prep libtool_options_prep
2303bd304fc0Smrg
2304bd304fc0Smrg
23056257f37dSmrg# libtool_parse_options [ARG]...
23066257f37dSmrg# ---------------------------------
23076257f37dSmrg# Provide handling for libtool specific options.
23086257f37dSmrglibtool_parse_options ()
2309bd304fc0Smrg{
23106257f37dSmrg    $debug_cmd
2311f3561b8bSmrg
23126257f37dSmrg    # Perform our own loop to consume as many options as possible in
23136257f37dSmrg    # each iteration.
23146257f37dSmrg    while test $# -gt 0; do
23156257f37dSmrg      _G_opt=$1
23166257f37dSmrg      shift
23176257f37dSmrg      case $_G_opt in
23186257f37dSmrg        --dry-run|--dryrun|-n)
23196257f37dSmrg                        opt_dry_run=:
23206257f37dSmrg                        ;;
23216257f37dSmrg
23226257f37dSmrg        --config)       func_config ;;
23236257f37dSmrg
23246257f37dSmrg        --dlopen|-dlopen)
23256257f37dSmrg                        opt_dlopen="${opt_dlopen+$opt_dlopen
23266257f37dSmrg}$1"
23276257f37dSmrg                        shift
23286257f37dSmrg                        ;;
23296257f37dSmrg
23306257f37dSmrg        --preserve-dup-deps)
23316257f37dSmrg                        opt_preserve_dup_deps=: ;;
23326257f37dSmrg
23336257f37dSmrg        --features)     func_features ;;
23346257f37dSmrg
23356257f37dSmrg        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
23366257f37dSmrg
23376257f37dSmrg        --help)         opt_help=: ;;
23386257f37dSmrg
23396257f37dSmrg        --help-all)     opt_help=': help-all' ;;
23406257f37dSmrg
23416257f37dSmrg        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
23426257f37dSmrg                        opt_mode=$1
23436257f37dSmrg                        case $1 in
23446257f37dSmrg                          # Valid mode arguments:
23456257f37dSmrg                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
23466257f37dSmrg
23476257f37dSmrg                          # Catch anything else as an error
23486257f37dSmrg                          *) func_error "invalid argument for $_G_opt"
23496257f37dSmrg                             exit_cmd=exit
23506257f37dSmrg                             break
23516257f37dSmrg                             ;;
23526257f37dSmrg                        esac
23536257f37dSmrg                        shift
23546257f37dSmrg                        ;;
23556257f37dSmrg
23566257f37dSmrg        --no-silent|--no-quiet)
23576257f37dSmrg                        opt_quiet=false
23586257f37dSmrg                        func_append preserve_args " $_G_opt"
23596257f37dSmrg                        ;;
23606257f37dSmrg
23616257f37dSmrg        --no-warnings|--no-warning|--no-warn)
23626257f37dSmrg                        opt_warning=false
23636257f37dSmrg                        func_append preserve_args " $_G_opt"
23646257f37dSmrg                        ;;
23656257f37dSmrg
23666257f37dSmrg        --no-verbose)
23676257f37dSmrg                        opt_verbose=false
23686257f37dSmrg                        func_append preserve_args " $_G_opt"
23696257f37dSmrg                        ;;
23706257f37dSmrg
23716257f37dSmrg        --silent|--quiet)
23726257f37dSmrg                        opt_quiet=:
23736257f37dSmrg                        opt_verbose=false
23746257f37dSmrg                        func_append preserve_args " $_G_opt"
23756257f37dSmrg                        ;;
23766257f37dSmrg
23776257f37dSmrg        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
23786257f37dSmrg                        opt_tag=$1
23796257f37dSmrg                        func_append preserve_args " $_G_opt $1"
23806257f37dSmrg                        func_enable_tag "$1"
23816257f37dSmrg                        shift
23826257f37dSmrg                        ;;
23836257f37dSmrg
23846257f37dSmrg        --verbose|-v)   opt_quiet=false
23856257f37dSmrg                        opt_verbose=:
23866257f37dSmrg                        func_append preserve_args " $_G_opt"
23876257f37dSmrg                        ;;
23886257f37dSmrg
23896257f37dSmrg	# An option not handled by this hook function:
23906257f37dSmrg        *)		set dummy "$_G_opt" ${1+"$@"};	shift; break  ;;
23916257f37dSmrg      esac
23926257f37dSmrg    done
2393bd304fc0Smrg
2394bd304fc0Smrg
23956257f37dSmrg    # save modified positional parameters for caller
23966257f37dSmrg    func_quote_for_eval ${1+"$@"}
23976257f37dSmrg    libtool_parse_options_result=$func_quote_for_eval_result
23986257f37dSmrg}
23996257f37dSmrgfunc_add_hook func_parse_options libtool_parse_options
2400f3561b8bSmrg
2401fc5a983dSmrg
2402f3561b8bSmrg
24036257f37dSmrg# libtool_validate_options [ARG]...
24046257f37dSmrg# ---------------------------------
24056257f37dSmrg# Perform any sanity checks on option settings and/or unconsumed
24066257f37dSmrg# arguments.
24076257f37dSmrglibtool_validate_options ()
24086257f37dSmrg{
24096257f37dSmrg    # save first non-option argument
24106257f37dSmrg    if test 0 -lt $#; then
24116257f37dSmrg      nonopt=$1
24126257f37dSmrg      shift
2413f3561b8bSmrg    fi
2414f3561b8bSmrg
24156257f37dSmrg    # preserve --debug
24166257f37dSmrg    test : = "$debug_cmd" || func_append preserve_args " --debug"
2417f3561b8bSmrg
24186257f37dSmrg    case $host in
24196257f37dSmrg      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
24206257f37dSmrg      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
24216257f37dSmrg      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
24226257f37dSmrg        # don't eliminate duplications in $postdeps and $predeps
24236257f37dSmrg        opt_duplicate_compiler_generated_deps=:
24246257f37dSmrg        ;;
24256257f37dSmrg      *)
24266257f37dSmrg        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
24276257f37dSmrg        ;;
24286257f37dSmrg    esac
2429fc5a983dSmrg
24306257f37dSmrg    $opt_help || {
24316257f37dSmrg      # Sanity checks first:
24326257f37dSmrg      func_check_version_match
24336257f37dSmrg
24346257f37dSmrg      test yes != "$build_libtool_libs" \
24356257f37dSmrg        && test yes != "$build_old_libs" \
24366257f37dSmrg        && func_fatal_configuration "not configured to build any kind of library"
24376257f37dSmrg
24386257f37dSmrg      # Darwin sucks
24396257f37dSmrg      eval std_shrext=\"$shrext_cmds\"
24406257f37dSmrg
24416257f37dSmrg      # Only execute mode is allowed to have -dlopen flags.
24426257f37dSmrg      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
24436257f37dSmrg        func_error "unrecognized option '-dlopen'"
24446257f37dSmrg        $ECHO "$help" 1>&2
24456257f37dSmrg        exit $EXIT_FAILURE
24466257f37dSmrg      fi
2447f3561b8bSmrg
24486257f37dSmrg      # Change the help message to a mode-specific one.
24496257f37dSmrg      generic_help=$help
24506257f37dSmrg      help="Try '$progname --help --mode=$opt_mode' for more information."
24516257f37dSmrg    }
2452f3561b8bSmrg
24536257f37dSmrg    # Pass back the unparsed argument list
24546257f37dSmrg    func_quote_for_eval ${1+"$@"}
24556257f37dSmrg    libtool_validate_options_result=$func_quote_for_eval_result
2456bd304fc0Smrg}
24576257f37dSmrgfunc_add_hook func_validate_options libtool_validate_options
2458f3561b8bSmrg
2459f3561b8bSmrg
24606257f37dSmrg# Process options as early as possible so that --help and --version
24616257f37dSmrg# can return quickly.
24626257f37dSmrgfunc_options ${1+"$@"}
24636257f37dSmrgeval set dummy "$func_options_result"; shift
24646257f37dSmrg
2465fc5a983dSmrg
2466fc5a983dSmrg
2467bd304fc0Smrg## ----------- ##
2468bd304fc0Smrg##    Main.    ##
2469bd304fc0Smrg## ----------- ##
2470fc5a983dSmrg
24716257f37dSmrgmagic='%%%MAGIC variable%%%'
24726257f37dSmrgmagic_exe='%%%MAGIC EXE variable%%%'
24736257f37dSmrg
24746257f37dSmrg# Global variables.
24756257f37dSmrgextracted_archives=
24766257f37dSmrgextracted_serial=0
24776257f37dSmrg
24786257f37dSmrg# If this variable is set in any of the actions, the command in it
24796257f37dSmrg# will be execed at the end.  This prevents here-documents from being
24806257f37dSmrg# left over by shells.
24816257f37dSmrgexec_cmd=
24826257f37dSmrg
24836257f37dSmrg
24846257f37dSmrg# A function that is used when there is no print builtin or printf.
24856257f37dSmrgfunc_fallback_echo ()
24866257f37dSmrg{
24876257f37dSmrg  eval 'cat <<_LTECHO_EOF
24886257f37dSmrg$1
24896257f37dSmrg_LTECHO_EOF'
24906257f37dSmrg}
24916257f37dSmrg
24926257f37dSmrg# func_generated_by_libtool
24936257f37dSmrg# True iff stdin has been generated by Libtool. This function is only
24946257f37dSmrg# a basic sanity check; it will hardly flush out determined imposters.
24956257f37dSmrgfunc_generated_by_libtool_p ()
24966257f37dSmrg{
24976257f37dSmrg  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
24986257f37dSmrg}
24996257f37dSmrg
2500f3561b8bSmrg# func_lalib_p file
25016257f37dSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
2502f3561b8bSmrg# This function is only a basic sanity check; it will hardly flush out
2503f3561b8bSmrg# determined imposters.
2504f3561b8bSmrgfunc_lalib_p ()
2505f3561b8bSmrg{
2506f3561b8bSmrg    test -f "$1" &&
25076257f37dSmrg      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
2508f3561b8bSmrg}
2509fc5a983dSmrg
2510f3561b8bSmrg# func_lalib_unsafe_p file
25116257f37dSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
2512f3561b8bSmrg# This function implements the same check as func_lalib_p without
2513f3561b8bSmrg# resorting to external programs.  To this end, it redirects stdin and
2514f3561b8bSmrg# closes it afterwards, without saving the original file descriptor.
2515f3561b8bSmrg# As a safety measure, use it only where a negative result would be
25166257f37dSmrg# fatal anyway.  Works if 'file' does not exist.
2517f3561b8bSmrgfunc_lalib_unsafe_p ()
2518f3561b8bSmrg{
2519f3561b8bSmrg    lalib_p=no
2520f3561b8bSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
2521f3561b8bSmrg	for lalib_p_l in 1 2 3 4
2522f3561b8bSmrg	do
2523f3561b8bSmrg	    read lalib_p_line
25246257f37dSmrg	    case $lalib_p_line in
2525f3561b8bSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
2526f3561b8bSmrg	    esac
2527f3561b8bSmrg	done
2528f3561b8bSmrg	exec 0<&5 5<&-
2529f3561b8bSmrg    fi
25306257f37dSmrg    test yes = "$lalib_p"
2531f3561b8bSmrg}
2532fc5a983dSmrg
2533f3561b8bSmrg# func_ltwrapper_script_p file
2534f3561b8bSmrg# True iff FILE is a libtool wrapper script
2535f3561b8bSmrg# This function is only a basic sanity check; it will hardly flush out
2536f3561b8bSmrg# determined imposters.
2537f3561b8bSmrgfunc_ltwrapper_script_p ()
2538f3561b8bSmrg{
25396257f37dSmrg    test -f "$1" &&
25406257f37dSmrg      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
2541f3561b8bSmrg}
2542fc5a983dSmrg
2543f3561b8bSmrg# func_ltwrapper_executable_p file
2544f3561b8bSmrg# True iff FILE is a libtool wrapper executable
2545f3561b8bSmrg# This function is only a basic sanity check; it will hardly flush out
2546f3561b8bSmrg# determined imposters.
2547f3561b8bSmrgfunc_ltwrapper_executable_p ()
2548f3561b8bSmrg{
2549f3561b8bSmrg    func_ltwrapper_exec_suffix=
2550f3561b8bSmrg    case $1 in
2551f3561b8bSmrg    *.exe) ;;
2552f3561b8bSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
2553f3561b8bSmrg    esac
2554f3561b8bSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
2555f3561b8bSmrg}
2556fc5a983dSmrg
2557f3561b8bSmrg# func_ltwrapper_scriptname file
2558f3561b8bSmrg# Assumes file is an ltwrapper_executable
2559f3561b8bSmrg# uses $file to determine the appropriate filename for a
2560f3561b8bSmrg# temporary ltwrapper_script.
2561f3561b8bSmrgfunc_ltwrapper_scriptname ()
2562f3561b8bSmrg{
2563bd304fc0Smrg    func_dirname_and_basename "$1" "" "."
2564bd304fc0Smrg    func_stripname '' '.exe' "$func_basename_result"
25656257f37dSmrg    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
2566f3561b8bSmrg}
2567f3561b8bSmrg
2568f3561b8bSmrg# func_ltwrapper_p file
2569f3561b8bSmrg# True iff FILE is a libtool wrapper script or wrapper executable
2570f3561b8bSmrg# This function is only a basic sanity check; it will hardly flush out
2571f3561b8bSmrg# determined imposters.
2572f3561b8bSmrgfunc_ltwrapper_p ()
2573f3561b8bSmrg{
2574f3561b8bSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
2575f3561b8bSmrg}
2576f3561b8bSmrg
2577f3561b8bSmrg
2578f3561b8bSmrg# func_execute_cmds commands fail_cmd
2579f3561b8bSmrg# Execute tilde-delimited COMMANDS.
2580f3561b8bSmrg# If FAIL_CMD is given, eval that upon failure.
2581f3561b8bSmrg# FAIL_CMD may read-access the current command in variable CMD!
2582f3561b8bSmrgfunc_execute_cmds ()
2583f3561b8bSmrg{
25846257f37dSmrg    $debug_cmd
25856257f37dSmrg
2586f3561b8bSmrg    save_ifs=$IFS; IFS='~'
2587f3561b8bSmrg    for cmd in $1; do
25886257f37dSmrg      IFS=$sp$nl
2589f3561b8bSmrg      eval cmd=\"$cmd\"
25906257f37dSmrg      IFS=$save_ifs
2591f3561b8bSmrg      func_show_eval "$cmd" "${2-:}"
2592f3561b8bSmrg    done
2593f3561b8bSmrg    IFS=$save_ifs
2594f3561b8bSmrg}
2595f3561b8bSmrg
2596f3561b8bSmrg
2597f3561b8bSmrg# func_source file
2598f3561b8bSmrg# Source FILE, adding directory component if necessary.
2599f3561b8bSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
2600f3561b8bSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
2601f3561b8bSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
26026257f37dSmrg# 'FILE.' does not work on cygwin managed mounts.
2603f3561b8bSmrgfunc_source ()
2604f3561b8bSmrg{
26056257f37dSmrg    $debug_cmd
26066257f37dSmrg
2607f3561b8bSmrg    case $1 in
2608f3561b8bSmrg    */* | *\\*)	. "$1" ;;
2609f3561b8bSmrg    *)		. "./$1" ;;
2610f3561b8bSmrg    esac
2611f3561b8bSmrg}
2612f3561b8bSmrg
2613f3561b8bSmrg
2614bd304fc0Smrg# func_resolve_sysroot PATH
2615bd304fc0Smrg# Replace a leading = in PATH with a sysroot.  Store the result into
2616bd304fc0Smrg# func_resolve_sysroot_result
2617bd304fc0Smrgfunc_resolve_sysroot ()
2618bd304fc0Smrg{
2619bd304fc0Smrg  func_resolve_sysroot_result=$1
2620bd304fc0Smrg  case $func_resolve_sysroot_result in
2621bd304fc0Smrg  =*)
2622bd304fc0Smrg    func_stripname '=' '' "$func_resolve_sysroot_result"
2623bd304fc0Smrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
2624bd304fc0Smrg    ;;
2625bd304fc0Smrg  esac
2626bd304fc0Smrg}
2627bd304fc0Smrg
2628bd304fc0Smrg# func_replace_sysroot PATH
2629bd304fc0Smrg# If PATH begins with the sysroot, replace it with = and
2630bd304fc0Smrg# store the result into func_replace_sysroot_result.
2631bd304fc0Smrgfunc_replace_sysroot ()
2632bd304fc0Smrg{
26336257f37dSmrg  case $lt_sysroot:$1 in
2634bd304fc0Smrg  ?*:"$lt_sysroot"*)
2635bd304fc0Smrg    func_stripname "$lt_sysroot" '' "$1"
26366257f37dSmrg    func_replace_sysroot_result='='$func_stripname_result
2637bd304fc0Smrg    ;;
2638bd304fc0Smrg  *)
2639bd304fc0Smrg    # Including no sysroot.
2640bd304fc0Smrg    func_replace_sysroot_result=$1
2641bd304fc0Smrg    ;;
2642bd304fc0Smrg  esac
2643bd304fc0Smrg}
2644bd304fc0Smrg
2645f3561b8bSmrg# func_infer_tag arg
2646f3561b8bSmrg# Infer tagged configuration to use if any are available and
2647f3561b8bSmrg# if one wasn't chosen via the "--tag" command line option.
2648f3561b8bSmrg# Only attempt this if the compiler in the base compile
2649f3561b8bSmrg# command doesn't match the default compiler.
2650f3561b8bSmrg# arg is usually of the form 'gcc ...'
2651f3561b8bSmrgfunc_infer_tag ()
2652f3561b8bSmrg{
26536257f37dSmrg    $debug_cmd
26546257f37dSmrg
2655f3561b8bSmrg    if test -n "$available_tags" && test -z "$tagname"; then
2656f3561b8bSmrg      CC_quoted=
2657f3561b8bSmrg      for arg in $CC; do
2658bd304fc0Smrg	func_append_quoted CC_quoted "$arg"
2659f3561b8bSmrg      done
2660bd304fc0Smrg      CC_expanded=`func_echo_all $CC`
2661bd304fc0Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
2662f3561b8bSmrg      case $@ in
2663f3561b8bSmrg      # Blanks in the command may have been stripped by the calling shell,
2664f3561b8bSmrg      # but not from the CC environment variable when configure was run.
2665bd304fc0Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2666bd304fc0Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
2667f3561b8bSmrg      # Blanks at the start of $base_compile will cause this to fail
2668f3561b8bSmrg      # if we don't check for them as well.
2669f3561b8bSmrg      *)
2670f3561b8bSmrg	for z in $available_tags; do
2671f3561b8bSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
2672f3561b8bSmrg	    # Evaluate the configuration.
26736257f37dSmrg	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
2674f3561b8bSmrg	    CC_quoted=
2675f3561b8bSmrg	    for arg in $CC; do
2676f3561b8bSmrg	      # Double-quote args containing other shell metacharacters.
2677bd304fc0Smrg	      func_append_quoted CC_quoted "$arg"
2678f3561b8bSmrg	    done
2679bd304fc0Smrg	    CC_expanded=`func_echo_all $CC`
2680bd304fc0Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
2681f3561b8bSmrg	    case "$@ " in
2682bd304fc0Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2683bd304fc0Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
2684f3561b8bSmrg	      # The compiler in the base compile command matches
2685f3561b8bSmrg	      # the one in the tagged configuration.
2686f3561b8bSmrg	      # Assume this is the tagged configuration we want.
2687f3561b8bSmrg	      tagname=$z
2688f3561b8bSmrg	      break
2689f3561b8bSmrg	      ;;
2690f3561b8bSmrg	    esac
2691f3561b8bSmrg	  fi
2692f3561b8bSmrg	done
2693f3561b8bSmrg	# If $tagname still isn't set, then no tagged configuration
2694f3561b8bSmrg	# was found and let the user know that the "--tag" command
2695f3561b8bSmrg	# line option must be used.
2696f3561b8bSmrg	if test -z "$tagname"; then
2697f3561b8bSmrg	  func_echo "unable to infer tagged configuration"
26986257f37dSmrg	  func_fatal_error "specify a tag with '--tag'"
2699f3561b8bSmrg#	else
2700f3561b8bSmrg#	  func_verbose "using $tagname tagged configuration"
2701f3561b8bSmrg	fi
2702f3561b8bSmrg	;;
2703f3561b8bSmrg      esac
2704f3561b8bSmrg    fi
2705f3561b8bSmrg}
2706f3561b8bSmrg
2707f3561b8bSmrg
2708f3561b8bSmrg
2709f3561b8bSmrg# func_write_libtool_object output_name pic_name nonpic_name
2710f3561b8bSmrg# Create a libtool object file (analogous to a ".la" file),
2711f3561b8bSmrg# but don't create it if we're doing a dry run.
2712f3561b8bSmrgfunc_write_libtool_object ()
2713f3561b8bSmrg{
27146257f37dSmrg    write_libobj=$1
27156257f37dSmrg    if test yes = "$build_libtool_libs"; then
27166257f37dSmrg      write_lobj=\'$2\'
2717f3561b8bSmrg    else
2718f3561b8bSmrg      write_lobj=none
2719f3561b8bSmrg    fi
2720f3561b8bSmrg
27216257f37dSmrg    if test yes = "$build_old_libs"; then
27226257f37dSmrg      write_oldobj=\'$3\'
2723f3561b8bSmrg    else
2724f3561b8bSmrg      write_oldobj=none
2725f3561b8bSmrg    fi
2726f3561b8bSmrg
2727f3561b8bSmrg    $opt_dry_run || {
2728f3561b8bSmrg      cat >${write_libobj}T <<EOF
2729f3561b8bSmrg# $write_libobj - a libtool object file
27306257f37dSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
2731f3561b8bSmrg#
2732f3561b8bSmrg# Please DO NOT delete this file!
2733f3561b8bSmrg# It is necessary for linking the library.
2734f3561b8bSmrg
2735f3561b8bSmrg# Name of the PIC object.
2736f3561b8bSmrgpic_object=$write_lobj
2737f3561b8bSmrg
2738f3561b8bSmrg# Name of the non-PIC object
2739f3561b8bSmrgnon_pic_object=$write_oldobj
2740f3561b8bSmrg
2741f3561b8bSmrgEOF
27426257f37dSmrg      $MV "${write_libobj}T" "$write_libobj"
2743f3561b8bSmrg    }
2744f3561b8bSmrg}
2745f3561b8bSmrg
2746bd304fc0Smrg
2747bd304fc0Smrg##################################################
2748bd304fc0Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
2749bd304fc0Smrg##################################################
2750bd304fc0Smrg
2751bd304fc0Smrg# func_convert_core_file_wine_to_w32 ARG
2752bd304fc0Smrg# Helper function used by file name conversion functions when $build is *nix,
2753bd304fc0Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
2754bd304fc0Smrg# correctly configured wine environment available, with the winepath program
2755bd304fc0Smrg# in $build's $PATH.
2756bd304fc0Smrg#
2757bd304fc0Smrg# ARG is the $build file name to be converted to w32 format.
2758bd304fc0Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
2759bd304fc0Smrg# be empty on error (or when ARG is empty)
2760bd304fc0Smrgfunc_convert_core_file_wine_to_w32 ()
2761bd304fc0Smrg{
27626257f37dSmrg  $debug_cmd
27636257f37dSmrg
27646257f37dSmrg  func_convert_core_file_wine_to_w32_result=$1
2765bd304fc0Smrg  if test -n "$1"; then
2766bd304fc0Smrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
2767bd304fc0Smrg    # are forced to check the contents of stdout. On the other hand, if the
2768bd304fc0Smrg    # command is not found, the shell will set an exit code of 127 and print
2769bd304fc0Smrg    # *an error message* to stdout. So we must check for both error code of
2770bd304fc0Smrg    # zero AND non-empty stdout, which explains the odd construction:
2771bd304fc0Smrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
27726257f37dSmrg    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
2773bd304fc0Smrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
27746257f37dSmrg        $SED -e "$sed_naive_backslashify"`
2775bd304fc0Smrg    else
2776bd304fc0Smrg      func_convert_core_file_wine_to_w32_result=
2777bd304fc0Smrg    fi
2778bd304fc0Smrg  fi
2779bd304fc0Smrg}
2780bd304fc0Smrg# end: func_convert_core_file_wine_to_w32
2781bd304fc0Smrg
2782bd304fc0Smrg
2783bd304fc0Smrg# func_convert_core_path_wine_to_w32 ARG
2784bd304fc0Smrg# Helper function used by path conversion functions when $build is *nix, and
2785bd304fc0Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
2786bd304fc0Smrg# configured wine environment available, with the winepath program in $build's
2787bd304fc0Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
2788bd304fc0Smrg#
2789bd304fc0Smrg# ARG is path to be converted from $build format to win32.
2790bd304fc0Smrg# Result is available in $func_convert_core_path_wine_to_w32_result.
2791bd304fc0Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
2792bd304fc0Smrg# are convertible, then the result may be empty.
2793bd304fc0Smrgfunc_convert_core_path_wine_to_w32 ()
2794bd304fc0Smrg{
27956257f37dSmrg  $debug_cmd
27966257f37dSmrg
2797bd304fc0Smrg  # unfortunately, winepath doesn't convert paths, only file names
27986257f37dSmrg  func_convert_core_path_wine_to_w32_result=
2799bd304fc0Smrg  if test -n "$1"; then
2800bd304fc0Smrg    oldIFS=$IFS
2801bd304fc0Smrg    IFS=:
2802bd304fc0Smrg    for func_convert_core_path_wine_to_w32_f in $1; do
2803bd304fc0Smrg      IFS=$oldIFS
2804bd304fc0Smrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
28056257f37dSmrg      if test -n "$func_convert_core_file_wine_to_w32_result"; then
2806bd304fc0Smrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
28076257f37dSmrg          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
2808bd304fc0Smrg        else
2809bd304fc0Smrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
2810bd304fc0Smrg        fi
2811bd304fc0Smrg      fi
2812bd304fc0Smrg    done
2813bd304fc0Smrg    IFS=$oldIFS
2814bd304fc0Smrg  fi
2815bd304fc0Smrg}
2816bd304fc0Smrg# end: func_convert_core_path_wine_to_w32
2817bd304fc0Smrg
2818bd304fc0Smrg
2819bd304fc0Smrg# func_cygpath ARGS...
2820bd304fc0Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
2821bd304fc0Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
2822bd304fc0Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
2823bd304fc0Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
2824bd304fc0Smrg# file name or path is assumed to be in w32 format, as previously converted
2825bd304fc0Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
2826bd304fc0Smrg# or path in func_cygpath_result (input file name or path is assumed to be in
2827bd304fc0Smrg# Cygwin format). Returns an empty string on error.
2828bd304fc0Smrg#
2829bd304fc0Smrg# ARGS are passed to cygpath, with the last one being the file name or path to
2830bd304fc0Smrg# be converted.
2831bd304fc0Smrg#
2832bd304fc0Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
2833bd304fc0Smrg# environment variable; do not put it in $PATH.
2834bd304fc0Smrgfunc_cygpath ()
2835bd304fc0Smrg{
28366257f37dSmrg  $debug_cmd
28376257f37dSmrg
2838bd304fc0Smrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
2839bd304fc0Smrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
2840bd304fc0Smrg    if test "$?" -ne 0; then
2841bd304fc0Smrg      # on failure, ensure result is empty
2842bd304fc0Smrg      func_cygpath_result=
2843bd304fc0Smrg    fi
2844bd304fc0Smrg  else
2845bd304fc0Smrg    func_cygpath_result=
28466257f37dSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
2847bd304fc0Smrg  fi
2848bd304fc0Smrg}
2849bd304fc0Smrg#end: func_cygpath
2850bd304fc0Smrg
2851bd304fc0Smrg
2852bd304fc0Smrg# func_convert_core_msys_to_w32 ARG
2853bd304fc0Smrg# Convert file name or path ARG from MSYS format to w32 format.  Return
2854bd304fc0Smrg# result in func_convert_core_msys_to_w32_result.
2855bd304fc0Smrgfunc_convert_core_msys_to_w32 ()
2856bd304fc0Smrg{
28576257f37dSmrg  $debug_cmd
28586257f37dSmrg
2859bd304fc0Smrg  # awkward: cmd appends spaces to result
2860bd304fc0Smrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
28616257f37dSmrg    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
2862bd304fc0Smrg}
2863bd304fc0Smrg#end: func_convert_core_msys_to_w32
2864bd304fc0Smrg
2865bd304fc0Smrg
2866bd304fc0Smrg# func_convert_file_check ARG1 ARG2
2867bd304fc0Smrg# Verify that ARG1 (a file name in $build format) was converted to $host
2868bd304fc0Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
2869bd304fc0Smrg# func_to_host_file_result to ARG1).
2870bd304fc0Smrgfunc_convert_file_check ()
2871bd304fc0Smrg{
28726257f37dSmrg  $debug_cmd
28736257f37dSmrg
28746257f37dSmrg  if test -z "$2" && test -n "$1"; then
2875bd304fc0Smrg    func_error "Could not determine host file name corresponding to"
28766257f37dSmrg    func_error "  '$1'"
2877bd304fc0Smrg    func_error "Continuing, but uninstalled executables may not work."
2878bd304fc0Smrg    # Fallback:
28796257f37dSmrg    func_to_host_file_result=$1
2880bd304fc0Smrg  fi
2881bd304fc0Smrg}
2882bd304fc0Smrg# end func_convert_file_check
2883bd304fc0Smrg
2884bd304fc0Smrg
2885bd304fc0Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
2886bd304fc0Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host
2887bd304fc0Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
2888bd304fc0Smrg# func_to_host_file_result to a simplistic fallback value (see below).
2889bd304fc0Smrgfunc_convert_path_check ()
2890bd304fc0Smrg{
28916257f37dSmrg  $debug_cmd
28926257f37dSmrg
2893bd304fc0Smrg  if test -z "$4" && test -n "$3"; then
2894bd304fc0Smrg    func_error "Could not determine the host path corresponding to"
28956257f37dSmrg    func_error "  '$3'"
2896bd304fc0Smrg    func_error "Continuing, but uninstalled executables may not work."
2897bd304fc0Smrg    # Fallback.  This is a deliberately simplistic "conversion" and
2898bd304fc0Smrg    # should not be "improved".  See libtool.info.
2899bd304fc0Smrg    if test "x$1" != "x$2"; then
2900bd304fc0Smrg      lt_replace_pathsep_chars="s|$1|$2|g"
2901bd304fc0Smrg      func_to_host_path_result=`echo "$3" |
2902bd304fc0Smrg        $SED -e "$lt_replace_pathsep_chars"`
2903bd304fc0Smrg    else
29046257f37dSmrg      func_to_host_path_result=$3
2905bd304fc0Smrg    fi
2906bd304fc0Smrg  fi
2907bd304fc0Smrg}
2908bd304fc0Smrg# end func_convert_path_check
2909bd304fc0Smrg
2910bd304fc0Smrg
2911bd304fc0Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
2912bd304fc0Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
2913bd304fc0Smrg# and appending REPL if ORIG matches BACKPAT.
2914bd304fc0Smrgfunc_convert_path_front_back_pathsep ()
2915bd304fc0Smrg{
29166257f37dSmrg  $debug_cmd
29176257f37dSmrg
2918bd304fc0Smrg  case $4 in
29196257f37dSmrg  $1 ) func_to_host_path_result=$3$func_to_host_path_result
2920bd304fc0Smrg    ;;
2921bd304fc0Smrg  esac
2922bd304fc0Smrg  case $4 in
2923bd304fc0Smrg  $2 ) func_append func_to_host_path_result "$3"
2924bd304fc0Smrg    ;;
2925bd304fc0Smrg  esac
2926bd304fc0Smrg}
2927bd304fc0Smrg# end func_convert_path_front_back_pathsep
2928bd304fc0Smrg
2929bd304fc0Smrg
2930bd304fc0Smrg##################################################
2931bd304fc0Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
2932bd304fc0Smrg##################################################
29336257f37dSmrg# invoked via '$to_host_file_cmd ARG'
2934bd304fc0Smrg#
2935bd304fc0Smrg# In each case, ARG is the path to be converted from $build to $host format.
2936bd304fc0Smrg# Result will be available in $func_to_host_file_result.
2937bd304fc0Smrg
2938bd304fc0Smrg
2939bd304fc0Smrg# func_to_host_file ARG
2940bd304fc0Smrg# Converts the file name ARG from $build format to $host format. Return result
2941bd304fc0Smrg# in func_to_host_file_result.
2942bd304fc0Smrgfunc_to_host_file ()
2943bd304fc0Smrg{
29446257f37dSmrg  $debug_cmd
29456257f37dSmrg
2946bd304fc0Smrg  $to_host_file_cmd "$1"
2947bd304fc0Smrg}
2948bd304fc0Smrg# end func_to_host_file
2949bd304fc0Smrg
2950bd304fc0Smrg
2951bd304fc0Smrg# func_to_tool_file ARG LAZY
2952bd304fc0Smrg# converts the file name ARG from $build format to toolchain format. Return
2953bd304fc0Smrg# result in func_to_tool_file_result.  If the conversion in use is listed
2954bd304fc0Smrg# in (the comma separated) LAZY, no conversion takes place.
2955bd304fc0Smrgfunc_to_tool_file ()
2956bd304fc0Smrg{
29576257f37dSmrg  $debug_cmd
29586257f37dSmrg
2959bd304fc0Smrg  case ,$2, in
2960bd304fc0Smrg    *,"$to_tool_file_cmd",*)
2961bd304fc0Smrg      func_to_tool_file_result=$1
2962bd304fc0Smrg      ;;
2963bd304fc0Smrg    *)
2964bd304fc0Smrg      $to_tool_file_cmd "$1"
2965bd304fc0Smrg      func_to_tool_file_result=$func_to_host_file_result
2966bd304fc0Smrg      ;;
2967bd304fc0Smrg  esac
2968bd304fc0Smrg}
2969bd304fc0Smrg# end func_to_tool_file
2970bd304fc0Smrg
2971bd304fc0Smrg
2972bd304fc0Smrg# func_convert_file_noop ARG
2973bd304fc0Smrg# Copy ARG to func_to_host_file_result.
2974bd304fc0Smrgfunc_convert_file_noop ()
2975bd304fc0Smrg{
29766257f37dSmrg  func_to_host_file_result=$1
2977bd304fc0Smrg}
2978bd304fc0Smrg# end func_convert_file_noop
2979bd304fc0Smrg
2980bd304fc0Smrg
2981bd304fc0Smrg# func_convert_file_msys_to_w32 ARG
2982bd304fc0Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
2983bd304fc0Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
2984bd304fc0Smrg# func_to_host_file_result.
2985bd304fc0Smrgfunc_convert_file_msys_to_w32 ()
2986bd304fc0Smrg{
29876257f37dSmrg  $debug_cmd
29886257f37dSmrg
29896257f37dSmrg  func_to_host_file_result=$1
2990bd304fc0Smrg  if test -n "$1"; then
2991bd304fc0Smrg    func_convert_core_msys_to_w32 "$1"
29926257f37dSmrg    func_to_host_file_result=$func_convert_core_msys_to_w32_result
2993bd304fc0Smrg  fi
2994bd304fc0Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
2995bd304fc0Smrg}
2996bd304fc0Smrg# end func_convert_file_msys_to_w32
2997bd304fc0Smrg
2998bd304fc0Smrg
2999bd304fc0Smrg# func_convert_file_cygwin_to_w32 ARG
3000bd304fc0Smrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
3001bd304fc0Smrg# func_to_host_file_result.
3002bd304fc0Smrgfunc_convert_file_cygwin_to_w32 ()
3003bd304fc0Smrg{
30046257f37dSmrg  $debug_cmd
30056257f37dSmrg
30066257f37dSmrg  func_to_host_file_result=$1
3007bd304fc0Smrg  if test -n "$1"; then
3008bd304fc0Smrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
3009bd304fc0Smrg    # LT_CYGPATH in this case.
3010bd304fc0Smrg    func_to_host_file_result=`cygpath -m "$1"`
3011bd304fc0Smrg  fi
3012bd304fc0Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3013bd304fc0Smrg}
3014bd304fc0Smrg# end func_convert_file_cygwin_to_w32
3015bd304fc0Smrg
3016bd304fc0Smrg
3017bd304fc0Smrg# func_convert_file_nix_to_w32 ARG
3018bd304fc0Smrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
3019bd304fc0Smrg# and a working winepath. Returns result in func_to_host_file_result.
3020bd304fc0Smrgfunc_convert_file_nix_to_w32 ()
3021bd304fc0Smrg{
30226257f37dSmrg  $debug_cmd
30236257f37dSmrg
30246257f37dSmrg  func_to_host_file_result=$1
3025bd304fc0Smrg  if test -n "$1"; then
3026bd304fc0Smrg    func_convert_core_file_wine_to_w32 "$1"
30276257f37dSmrg    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
3028bd304fc0Smrg  fi
3029bd304fc0Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3030bd304fc0Smrg}
3031bd304fc0Smrg# end func_convert_file_nix_to_w32
3032bd304fc0Smrg
3033bd304fc0Smrg
3034bd304fc0Smrg# func_convert_file_msys_to_cygwin ARG
3035bd304fc0Smrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3036bd304fc0Smrg# Returns result in func_to_host_file_result.
3037bd304fc0Smrgfunc_convert_file_msys_to_cygwin ()
3038bd304fc0Smrg{
30396257f37dSmrg  $debug_cmd
30406257f37dSmrg
30416257f37dSmrg  func_to_host_file_result=$1
3042bd304fc0Smrg  if test -n "$1"; then
3043bd304fc0Smrg    func_convert_core_msys_to_w32 "$1"
3044bd304fc0Smrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
30456257f37dSmrg    func_to_host_file_result=$func_cygpath_result
3046bd304fc0Smrg  fi
3047bd304fc0Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3048bd304fc0Smrg}
3049bd304fc0Smrg# end func_convert_file_msys_to_cygwin
3050bd304fc0Smrg
3051bd304fc0Smrg
3052bd304fc0Smrg# func_convert_file_nix_to_cygwin ARG
3053bd304fc0Smrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
3054bd304fc0Smrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
3055bd304fc0Smrg# in func_to_host_file_result.
3056bd304fc0Smrgfunc_convert_file_nix_to_cygwin ()
3057bd304fc0Smrg{
30586257f37dSmrg  $debug_cmd
30596257f37dSmrg
30606257f37dSmrg  func_to_host_file_result=$1
3061bd304fc0Smrg  if test -n "$1"; then
3062bd304fc0Smrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
3063bd304fc0Smrg    func_convert_core_file_wine_to_w32 "$1"
3064bd304fc0Smrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
30656257f37dSmrg    func_to_host_file_result=$func_cygpath_result
3066bd304fc0Smrg  fi
3067bd304fc0Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3068bd304fc0Smrg}
3069bd304fc0Smrg# end func_convert_file_nix_to_cygwin
3070bd304fc0Smrg
3071bd304fc0Smrg
3072bd304fc0Smrg#############################################
3073bd304fc0Smrg# $build to $host PATH CONVERSION FUNCTIONS #
3074bd304fc0Smrg#############################################
30756257f37dSmrg# invoked via '$to_host_path_cmd ARG'
3076bd304fc0Smrg#
3077bd304fc0Smrg# In each case, ARG is the path to be converted from $build to $host format.
3078bd304fc0Smrg# The result will be available in $func_to_host_path_result.
3079bd304fc0Smrg#
3080bd304fc0Smrg# Path separators are also converted from $build format to $host format.  If
3081bd304fc0Smrg# ARG begins or ends with a path separator character, it is preserved (but
3082bd304fc0Smrg# converted to $host format) on output.
3083bd304fc0Smrg#
3084bd304fc0Smrg# All path conversion functions are named using the following convention:
3085bd304fc0Smrg#   file name conversion function    : func_convert_file_X_to_Y ()
3086bd304fc0Smrg#   path conversion function         : func_convert_path_X_to_Y ()
3087bd304fc0Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the
3088bd304fc0Smrg# same.  If conversion functions are added for new $build/$host combinations,
3089bd304fc0Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
3090bd304fc0Smrg# will break.
3091bd304fc0Smrg
3092bd304fc0Smrg
3093bd304fc0Smrg# func_init_to_host_path_cmd
3094bd304fc0Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
3095bd304fc0Smrg# appropriate value, based on the value of $to_host_file_cmd.
3096bd304fc0Smrgto_host_path_cmd=
3097bd304fc0Smrgfunc_init_to_host_path_cmd ()
3098bd304fc0Smrg{
30996257f37dSmrg  $debug_cmd
31006257f37dSmrg
3101bd304fc0Smrg  if test -z "$to_host_path_cmd"; then
3102bd304fc0Smrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
31036257f37dSmrg    to_host_path_cmd=func_convert_path_$func_stripname_result
3104bd304fc0Smrg  fi
3105bd304fc0Smrg}
3106bd304fc0Smrg
3107bd304fc0Smrg
3108bd304fc0Smrg# func_to_host_path ARG
3109bd304fc0Smrg# Converts the path ARG from $build format to $host format. Return result
3110bd304fc0Smrg# in func_to_host_path_result.
3111bd304fc0Smrgfunc_to_host_path ()
3112bd304fc0Smrg{
31136257f37dSmrg  $debug_cmd
31146257f37dSmrg
3115bd304fc0Smrg  func_init_to_host_path_cmd
3116bd304fc0Smrg  $to_host_path_cmd "$1"
3117bd304fc0Smrg}
3118bd304fc0Smrg# end func_to_host_path
3119bd304fc0Smrg
3120bd304fc0Smrg
3121bd304fc0Smrg# func_convert_path_noop ARG
3122bd304fc0Smrg# Copy ARG to func_to_host_path_result.
3123bd304fc0Smrgfunc_convert_path_noop ()
3124bd304fc0Smrg{
31256257f37dSmrg  func_to_host_path_result=$1
3126bd304fc0Smrg}
3127bd304fc0Smrg# end func_convert_path_noop
3128bd304fc0Smrg
3129bd304fc0Smrg
3130bd304fc0Smrg# func_convert_path_msys_to_w32 ARG
3131bd304fc0Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
3132bd304fc0Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
3133bd304fc0Smrg# func_to_host_path_result.
3134bd304fc0Smrgfunc_convert_path_msys_to_w32 ()
3135bd304fc0Smrg{
31366257f37dSmrg  $debug_cmd
31376257f37dSmrg
31386257f37dSmrg  func_to_host_path_result=$1
3139bd304fc0Smrg  if test -n "$1"; then
3140bd304fc0Smrg    # Remove leading and trailing path separator characters from ARG.  MSYS
3141bd304fc0Smrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
3142bd304fc0Smrg    # and winepath ignores them completely.
3143bd304fc0Smrg    func_stripname : : "$1"
3144bd304fc0Smrg    func_to_host_path_tmp1=$func_stripname_result
3145bd304fc0Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
31466257f37dSmrg    func_to_host_path_result=$func_convert_core_msys_to_w32_result
3147bd304fc0Smrg    func_convert_path_check : ";" \
3148bd304fc0Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3149bd304fc0Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3150bd304fc0Smrg  fi
3151bd304fc0Smrg}
3152bd304fc0Smrg# end func_convert_path_msys_to_w32
3153bd304fc0Smrg
3154bd304fc0Smrg
3155bd304fc0Smrg# func_convert_path_cygwin_to_w32 ARG
3156bd304fc0Smrg# Convert path ARG from Cygwin to w32 format.  Returns result in
3157bd304fc0Smrg# func_to_host_file_result.
3158bd304fc0Smrgfunc_convert_path_cygwin_to_w32 ()
3159bd304fc0Smrg{
31606257f37dSmrg  $debug_cmd
31616257f37dSmrg
31626257f37dSmrg  func_to_host_path_result=$1
3163bd304fc0Smrg  if test -n "$1"; then
3164bd304fc0Smrg    # See func_convert_path_msys_to_w32:
3165bd304fc0Smrg    func_stripname : : "$1"
3166bd304fc0Smrg    func_to_host_path_tmp1=$func_stripname_result
3167bd304fc0Smrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
3168bd304fc0Smrg    func_convert_path_check : ";" \
3169bd304fc0Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3170bd304fc0Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3171bd304fc0Smrg  fi
3172bd304fc0Smrg}
3173bd304fc0Smrg# end func_convert_path_cygwin_to_w32
3174bd304fc0Smrg
3175bd304fc0Smrg
3176bd304fc0Smrg# func_convert_path_nix_to_w32 ARG
3177bd304fc0Smrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
3178bd304fc0Smrg# a working winepath.  Returns result in func_to_host_file_result.
3179bd304fc0Smrgfunc_convert_path_nix_to_w32 ()
3180bd304fc0Smrg{
31816257f37dSmrg  $debug_cmd
31826257f37dSmrg
31836257f37dSmrg  func_to_host_path_result=$1
3184bd304fc0Smrg  if test -n "$1"; then
3185bd304fc0Smrg    # See func_convert_path_msys_to_w32:
3186bd304fc0Smrg    func_stripname : : "$1"
3187bd304fc0Smrg    func_to_host_path_tmp1=$func_stripname_result
3188bd304fc0Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
31896257f37dSmrg    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
3190bd304fc0Smrg    func_convert_path_check : ";" \
3191bd304fc0Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3192bd304fc0Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3193bd304fc0Smrg  fi
3194bd304fc0Smrg}
3195bd304fc0Smrg# end func_convert_path_nix_to_w32
3196bd304fc0Smrg
3197bd304fc0Smrg
3198bd304fc0Smrg# func_convert_path_msys_to_cygwin ARG
3199bd304fc0Smrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3200bd304fc0Smrg# Returns result in func_to_host_file_result.
3201bd304fc0Smrgfunc_convert_path_msys_to_cygwin ()
3202bd304fc0Smrg{
32036257f37dSmrg  $debug_cmd
32046257f37dSmrg
32056257f37dSmrg  func_to_host_path_result=$1
3206bd304fc0Smrg  if test -n "$1"; then
3207bd304fc0Smrg    # See func_convert_path_msys_to_w32:
3208bd304fc0Smrg    func_stripname : : "$1"
3209bd304fc0Smrg    func_to_host_path_tmp1=$func_stripname_result
3210bd304fc0Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3211bd304fc0Smrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
32126257f37dSmrg    func_to_host_path_result=$func_cygpath_result
3213bd304fc0Smrg    func_convert_path_check : : \
3214bd304fc0Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3215bd304fc0Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3216bd304fc0Smrg  fi
3217bd304fc0Smrg}
3218bd304fc0Smrg# end func_convert_path_msys_to_cygwin
3219bd304fc0Smrg
3220bd304fc0Smrg
3221bd304fc0Smrg# func_convert_path_nix_to_cygwin ARG
3222bd304fc0Smrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
3223bd304fc0Smrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
3224bd304fc0Smrg# func_to_host_file_result.
3225bd304fc0Smrgfunc_convert_path_nix_to_cygwin ()
3226bd304fc0Smrg{
32276257f37dSmrg  $debug_cmd
32286257f37dSmrg
32296257f37dSmrg  func_to_host_path_result=$1
3230bd304fc0Smrg  if test -n "$1"; then
3231bd304fc0Smrg    # Remove leading and trailing path separator characters from
3232bd304fc0Smrg    # ARG. msys behavior is inconsistent here, cygpath turns them
3233bd304fc0Smrg    # into '.;' and ';.', and winepath ignores them completely.
3234bd304fc0Smrg    func_stripname : : "$1"
3235bd304fc0Smrg    func_to_host_path_tmp1=$func_stripname_result
3236bd304fc0Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3237bd304fc0Smrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
32386257f37dSmrg    func_to_host_path_result=$func_cygpath_result
3239bd304fc0Smrg    func_convert_path_check : : \
3240bd304fc0Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3241bd304fc0Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3242bd304fc0Smrg  fi
3243bd304fc0Smrg}
3244bd304fc0Smrg# end func_convert_path_nix_to_cygwin
3245bd304fc0Smrg
3246bd304fc0Smrg
32476257f37dSmrg# func_dll_def_p FILE
32486257f37dSmrg# True iff FILE is a Windows DLL '.def' file.
32496257f37dSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4
32506257f37dSmrgfunc_dll_def_p ()
32516257f37dSmrg{
32526257f37dSmrg  $debug_cmd
32536257f37dSmrg
32546257f37dSmrg  func_dll_def_p_tmp=`$SED -n \
32556257f37dSmrg    -e 's/^[	 ]*//' \
32566257f37dSmrg    -e '/^\(;.*\)*$/d' \
32576257f37dSmrg    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
32586257f37dSmrg    -e q \
32596257f37dSmrg    "$1"`
32606257f37dSmrg  test DEF = "$func_dll_def_p_tmp"
32616257f37dSmrg}
32626257f37dSmrg
32636257f37dSmrg
3264f3561b8bSmrg# func_mode_compile arg...
3265f3561b8bSmrgfunc_mode_compile ()
3266f3561b8bSmrg{
32676257f37dSmrg    $debug_cmd
32686257f37dSmrg
3269f3561b8bSmrg    # Get the compilation command and the source file.
3270f3561b8bSmrg    base_compile=
32716257f37dSmrg    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
3272f3561b8bSmrg    suppress_opt=yes
3273f3561b8bSmrg    suppress_output=
3274f3561b8bSmrg    arg_mode=normal
3275f3561b8bSmrg    libobj=
3276f3561b8bSmrg    later=
3277f3561b8bSmrg    pie_flag=
3278f3561b8bSmrg
3279f3561b8bSmrg    for arg
3280f3561b8bSmrg    do
3281f3561b8bSmrg      case $arg_mode in
3282f3561b8bSmrg      arg  )
3283f3561b8bSmrg	# do not "continue".  Instead, add this to base_compile
32846257f37dSmrg	lastarg=$arg
3285f3561b8bSmrg	arg_mode=normal
3286f3561b8bSmrg	;;
3287f3561b8bSmrg
3288f3561b8bSmrg      target )
32896257f37dSmrg	libobj=$arg
3290f3561b8bSmrg	arg_mode=normal
3291f3561b8bSmrg	continue
3292f3561b8bSmrg	;;
3293f3561b8bSmrg
3294f3561b8bSmrg      normal )
3295f3561b8bSmrg	# Accept any command-line options.
3296f3561b8bSmrg	case $arg in
3297f3561b8bSmrg	-o)
3298f3561b8bSmrg	  test -n "$libobj" && \
32996257f37dSmrg	    func_fatal_error "you cannot specify '-o' more than once"
3300f3561b8bSmrg	  arg_mode=target
3301f3561b8bSmrg	  continue
3302f3561b8bSmrg	  ;;
3303f3561b8bSmrg
3304f3561b8bSmrg	-pie | -fpie | -fPIE)
3305bd304fc0Smrg          func_append pie_flag " $arg"
3306f3561b8bSmrg	  continue
3307f3561b8bSmrg	  ;;
3308f3561b8bSmrg
3309f3561b8bSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
3310bd304fc0Smrg	  func_append later " $arg"
3311f3561b8bSmrg	  continue
3312f3561b8bSmrg	  ;;
3313f3561b8bSmrg
3314f3561b8bSmrg	-no-suppress)
3315fc5a983dSmrg	  suppress_opt=no
3316fc5a983dSmrg	  continue
3317fc5a983dSmrg	  ;;
3318fc5a983dSmrg
3319fc5a983dSmrg	-Xcompiler)
3320fc5a983dSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
3321fc5a983dSmrg	  continue      #  The current "srcfile" will either be retained or
3322fc5a983dSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
3323fc5a983dSmrg
3324fc5a983dSmrg	-Wc,*)
3325f3561b8bSmrg	  func_stripname '-Wc,' '' "$arg"
3326f3561b8bSmrg	  args=$func_stripname_result
3327fc5a983dSmrg	  lastarg=
33286257f37dSmrg	  save_ifs=$IFS; IFS=,
3329f3561b8bSmrg	  for arg in $args; do
33306257f37dSmrg	    IFS=$save_ifs
3331bd304fc0Smrg	    func_append_quoted lastarg "$arg"
3332fc5a983dSmrg	  done
33336257f37dSmrg	  IFS=$save_ifs
3334f3561b8bSmrg	  func_stripname ' ' '' "$lastarg"
3335f3561b8bSmrg	  lastarg=$func_stripname_result
3336fc5a983dSmrg
3337fc5a983dSmrg	  # Add the arguments to base_compile.
3338bd304fc0Smrg	  func_append base_compile " $lastarg"
3339fc5a983dSmrg	  continue
3340fc5a983dSmrg	  ;;
3341fc5a983dSmrg
3342f3561b8bSmrg	*)
3343fc5a983dSmrg	  # Accept the current argument as the source file.
3344fc5a983dSmrg	  # The previous "srcfile" becomes the current argument.
3345fc5a983dSmrg	  #
33466257f37dSmrg	  lastarg=$srcfile
33476257f37dSmrg	  srcfile=$arg
3348fc5a983dSmrg	  ;;
3349fc5a983dSmrg	esac  #  case $arg
3350fc5a983dSmrg	;;
3351fc5a983dSmrg      esac    #  case $arg_mode
3352fc5a983dSmrg
3353fc5a983dSmrg      # Aesthetically quote the previous argument.
3354bd304fc0Smrg      func_append_quoted base_compile "$lastarg"
3355fc5a983dSmrg    done # for arg
3356fc5a983dSmrg
3357fc5a983dSmrg    case $arg_mode in
3358fc5a983dSmrg    arg)
3359f3561b8bSmrg      func_fatal_error "you must specify an argument for -Xcompile"
3360fc5a983dSmrg      ;;
3361fc5a983dSmrg    target)
33626257f37dSmrg      func_fatal_error "you must specify a target with '-o'"
3363fc5a983dSmrg      ;;
3364fc5a983dSmrg    *)
3365fc5a983dSmrg      # Get the name of the library object.
3366f3561b8bSmrg      test -z "$libobj" && {
3367f3561b8bSmrg	func_basename "$srcfile"
33686257f37dSmrg	libobj=$func_basename_result
3369f3561b8bSmrg      }
3370fc5a983dSmrg      ;;
3371fc5a983dSmrg    esac
3372fc5a983dSmrg
3373fc5a983dSmrg    # Recognize several different file suffixes.
3374fc5a983dSmrg    # If the user specifies -o file.o, it is replaced with file.lo
3375fc5a983dSmrg    case $libobj in
3376f3561b8bSmrg    *.[cCFSifmso] | \
3377f3561b8bSmrg    *.ada | *.adb | *.ads | *.asm | \
3378f3561b8bSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
3379bd304fc0Smrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
3380f3561b8bSmrg      func_xform "$libobj"
3381f3561b8bSmrg      libobj=$func_xform_result
3382f3561b8bSmrg      ;;
3383fc5a983dSmrg    esac
3384fc5a983dSmrg
3385fc5a983dSmrg    case $libobj in
3386f3561b8bSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
3387fc5a983dSmrg    *)
33886257f37dSmrg      func_fatal_error "cannot determine name of library object from '$libobj'"
3389fc5a983dSmrg      ;;
3390fc5a983dSmrg    esac
3391fc5a983dSmrg
3392fc5a983dSmrg    func_infer_tag $base_compile
3393fc5a983dSmrg
3394fc5a983dSmrg    for arg in $later; do
3395fc5a983dSmrg      case $arg in
3396f3561b8bSmrg      -shared)
33976257f37dSmrg	test yes = "$build_libtool_libs" \
33986257f37dSmrg	  || func_fatal_configuration "cannot build a shared library"
3399f3561b8bSmrg	build_old_libs=no
3400f3561b8bSmrg	continue
3401f3561b8bSmrg	;;
3402f3561b8bSmrg
3403fc5a983dSmrg      -static)
3404f3561b8bSmrg	build_libtool_libs=no
3405fc5a983dSmrg	build_old_libs=yes
3406fc5a983dSmrg	continue
3407fc5a983dSmrg	;;
3408fc5a983dSmrg
3409fc5a983dSmrg      -prefer-pic)
3410fc5a983dSmrg	pic_mode=yes
3411fc5a983dSmrg	continue
3412fc5a983dSmrg	;;
3413fc5a983dSmrg
3414fc5a983dSmrg      -prefer-non-pic)
3415fc5a983dSmrg	pic_mode=no
3416fc5a983dSmrg	continue
3417fc5a983dSmrg	;;
3418fc5a983dSmrg      esac
3419fc5a983dSmrg    done
3420fc5a983dSmrg
3421f3561b8bSmrg    func_quote_for_eval "$libobj"
3422f3561b8bSmrg    test "X$libobj" != "X$func_quote_for_eval_result" \
3423f3561b8bSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
34246257f37dSmrg      && func_warning "libobj name '$libobj' may not contain shell special characters."
3425f3561b8bSmrg    func_dirname_and_basename "$obj" "/" ""
34266257f37dSmrg    objname=$func_basename_result
34276257f37dSmrg    xdir=$func_dirname_result
34286257f37dSmrg    lobj=$xdir$objdir/$objname
3429fc5a983dSmrg
3430f3561b8bSmrg    test -z "$base_compile" && \
3431f3561b8bSmrg      func_fatal_help "you must specify a compilation command"
3432fc5a983dSmrg
3433fc5a983dSmrg    # Delete any leftover library objects.
34346257f37dSmrg    if test yes = "$build_old_libs"; then
3435fc5a983dSmrg      removelist="$obj $lobj $libobj ${libobj}T"
3436fc5a983dSmrg    else
3437fc5a983dSmrg      removelist="$lobj $libobj ${libobj}T"
3438fc5a983dSmrg    fi
3439fc5a983dSmrg
3440fc5a983dSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
3441fc5a983dSmrg    case $host_os in
3442f3561b8bSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
3443fc5a983dSmrg      pic_mode=default
3444fc5a983dSmrg      ;;
3445fc5a983dSmrg    esac
34466257f37dSmrg    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
3447fc5a983dSmrg      # non-PIC code in shared libraries is not supported
3448fc5a983dSmrg      pic_mode=default
3449fc5a983dSmrg    fi
3450fc5a983dSmrg
3451fc5a983dSmrg    # Calculate the filename of the output object if compiler does
3452fc5a983dSmrg    # not support -o with -c
34536257f37dSmrg    if test no = "$compiler_c_o"; then
34546257f37dSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
34556257f37dSmrg      lockfile=$output_obj.lock
3456fc5a983dSmrg    else
3457fc5a983dSmrg      output_obj=
3458fc5a983dSmrg      need_locks=no
3459fc5a983dSmrg      lockfile=
3460fc5a983dSmrg    fi
3461fc5a983dSmrg
3462fc5a983dSmrg    # Lock this critical section if it is needed
3463fc5a983dSmrg    # We use this script file to make the link, it avoids creating a new file
34646257f37dSmrg    if test yes = "$need_locks"; then
3465f3561b8bSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3466f3561b8bSmrg	func_echo "Waiting for $lockfile to be removed"
3467fc5a983dSmrg	sleep 2
3468fc5a983dSmrg      done
34696257f37dSmrg    elif test warn = "$need_locks"; then
3470fc5a983dSmrg      if test -f "$lockfile"; then
3471f3561b8bSmrg	$ECHO "\
3472fc5a983dSmrg*** ERROR, $lockfile exists and contains:
3473fc5a983dSmrg`cat $lockfile 2>/dev/null`
3474fc5a983dSmrg
3475fc5a983dSmrgThis indicates that another process is trying to use the same
3476fc5a983dSmrgtemporary object file, and libtool could not work around it because
34776257f37dSmrgyour compiler does not support '-c' and '-o' together.  If you
3478fc5a983dSmrgrepeat this compilation, it may succeed, by chance, but you had better
3479fc5a983dSmrgavoid parallel builds (make -j) in this platform, or get a better
3480fc5a983dSmrgcompiler."
3481fc5a983dSmrg
3482f3561b8bSmrg	$opt_dry_run || $RM $removelist
3483fc5a983dSmrg	exit $EXIT_FAILURE
3484fc5a983dSmrg      fi
3485bd304fc0Smrg      func_append removelist " $output_obj"
3486f3561b8bSmrg      $ECHO "$srcfile" > "$lockfile"
3487fc5a983dSmrg    fi
3488fc5a983dSmrg
3489f3561b8bSmrg    $opt_dry_run || $RM $removelist
3490bd304fc0Smrg    func_append removelist " $lockfile"
3491f3561b8bSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
3492f3561b8bSmrg
3493bd304fc0Smrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
3494bd304fc0Smrg    srcfile=$func_to_tool_file_result
3495f3561b8bSmrg    func_quote_for_eval "$srcfile"
3496f3561b8bSmrg    qsrcfile=$func_quote_for_eval_result
3497fc5a983dSmrg
3498fc5a983dSmrg    # Only build a PIC object if we are building libtool libraries.
34996257f37dSmrg    if test yes = "$build_libtool_libs"; then
3500fc5a983dSmrg      # Without this assignment, base_compile gets emptied.
3501fc5a983dSmrg      fbsd_hideous_sh_bug=$base_compile
3502fc5a983dSmrg
35036257f37dSmrg      if test no != "$pic_mode"; then
3504fc5a983dSmrg	command="$base_compile $qsrcfile $pic_flag"
3505fc5a983dSmrg      else
3506fc5a983dSmrg	# Don't build PIC code
3507fc5a983dSmrg	command="$base_compile $qsrcfile"
3508fc5a983dSmrg      fi
3509fc5a983dSmrg
3510f3561b8bSmrg      func_mkdir_p "$xdir$objdir"
3511fc5a983dSmrg
3512fc5a983dSmrg      if test -z "$output_obj"; then
3513fc5a983dSmrg	# Place PIC objects in $objdir
3514bd304fc0Smrg	func_append command " -o $lobj"
3515fc5a983dSmrg      fi
3516fc5a983dSmrg
3517f3561b8bSmrg      func_show_eval_locale "$command"	\
3518f3561b8bSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
3519fc5a983dSmrg
35206257f37dSmrg      if test warn = "$need_locks" &&
3521fc5a983dSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3522f3561b8bSmrg	$ECHO "\
3523fc5a983dSmrg*** ERROR, $lockfile contains:
3524fc5a983dSmrg`cat $lockfile 2>/dev/null`
3525fc5a983dSmrg
3526fc5a983dSmrgbut it should contain:
3527fc5a983dSmrg$srcfile
3528fc5a983dSmrg
3529fc5a983dSmrgThis indicates that another process is trying to use the same
3530fc5a983dSmrgtemporary object file, and libtool could not work around it because
35316257f37dSmrgyour compiler does not support '-c' and '-o' together.  If you
3532fc5a983dSmrgrepeat this compilation, it may succeed, by chance, but you had better
3533fc5a983dSmrgavoid parallel builds (make -j) in this platform, or get a better
3534fc5a983dSmrgcompiler."
3535fc5a983dSmrg
3536f3561b8bSmrg	$opt_dry_run || $RM $removelist
3537fc5a983dSmrg	exit $EXIT_FAILURE
3538fc5a983dSmrg      fi
3539fc5a983dSmrg
3540fc5a983dSmrg      # Just move the object if needed, then go on to compile the next one
3541fc5a983dSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
3542f3561b8bSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
3543f3561b8bSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3544fc5a983dSmrg      fi
3545fc5a983dSmrg
3546fc5a983dSmrg      # Allow error messages only from the first compilation.
35476257f37dSmrg      if test yes = "$suppress_opt"; then
3548f3561b8bSmrg	suppress_output=' >/dev/null 2>&1'
3549fc5a983dSmrg      fi
3550fc5a983dSmrg    fi
3551fc5a983dSmrg
3552fc5a983dSmrg    # Only build a position-dependent object if we build old libraries.
35536257f37dSmrg    if test yes = "$build_old_libs"; then
35546257f37dSmrg      if test yes != "$pic_mode"; then
3555fc5a983dSmrg	# Don't build PIC code
3556f3561b8bSmrg	command="$base_compile $qsrcfile$pie_flag"
3557fc5a983dSmrg      else
3558fc5a983dSmrg	command="$base_compile $qsrcfile $pic_flag"
3559fc5a983dSmrg      fi
35606257f37dSmrg      if test yes = "$compiler_c_o"; then
3561bd304fc0Smrg	func_append command " -o $obj"
3562fc5a983dSmrg      fi
3563fc5a983dSmrg
3564fc5a983dSmrg      # Suppress compiler output if we already did a PIC compilation.
3565bd304fc0Smrg      func_append command "$suppress_output"
3566f3561b8bSmrg      func_show_eval_locale "$command" \
3567f3561b8bSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
3568fc5a983dSmrg
35696257f37dSmrg      if test warn = "$need_locks" &&
3570fc5a983dSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3571f3561b8bSmrg	$ECHO "\
3572fc5a983dSmrg*** ERROR, $lockfile contains:
3573fc5a983dSmrg`cat $lockfile 2>/dev/null`
3574fc5a983dSmrg
3575fc5a983dSmrgbut it should contain:
3576fc5a983dSmrg$srcfile
3577fc5a983dSmrg
3578fc5a983dSmrgThis indicates that another process is trying to use the same
3579fc5a983dSmrgtemporary object file, and libtool could not work around it because
35806257f37dSmrgyour compiler does not support '-c' and '-o' together.  If you
3581fc5a983dSmrgrepeat this compilation, it may succeed, by chance, but you had better
3582fc5a983dSmrgavoid parallel builds (make -j) in this platform, or get a better
3583fc5a983dSmrgcompiler."
3584fc5a983dSmrg
3585f3561b8bSmrg	$opt_dry_run || $RM $removelist
3586fc5a983dSmrg	exit $EXIT_FAILURE
3587fc5a983dSmrg      fi
3588fc5a983dSmrg
3589fc5a983dSmrg      # Just move the object if needed
3590fc5a983dSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
3591f3561b8bSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
3592f3561b8bSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3593fc5a983dSmrg      fi
3594fc5a983dSmrg    fi
3595fc5a983dSmrg
3596f3561b8bSmrg    $opt_dry_run || {
3597f3561b8bSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
3598fc5a983dSmrg
3599f3561b8bSmrg      # Unlock the critical section if it was locked
36006257f37dSmrg      if test no != "$need_locks"; then
3601f3561b8bSmrg	removelist=$lockfile
3602f3561b8bSmrg        $RM "$lockfile"
3603f3561b8bSmrg      fi
3604f3561b8bSmrg    }
3605fc5a983dSmrg
3606fc5a983dSmrg    exit $EXIT_SUCCESS
3607f3561b8bSmrg}
3608fc5a983dSmrg
3609f3561b8bSmrg$opt_help || {
36106257f37dSmrg  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
3611f3561b8bSmrg}
3612fc5a983dSmrg
3613f3561b8bSmrgfunc_mode_help ()
3614f3561b8bSmrg{
3615f3561b8bSmrg    # We need to display help for each of the modes.
3616bd304fc0Smrg    case $opt_mode in
3617f3561b8bSmrg      "")
3618f3561b8bSmrg        # Generic help is extracted from the usage comments
3619f3561b8bSmrg        # at the start of this file.
3620f3561b8bSmrg        func_help
3621f3561b8bSmrg        ;;
3622fc5a983dSmrg
3623f3561b8bSmrg      clean)
3624f3561b8bSmrg        $ECHO \
3625f3561b8bSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
3626fc5a983dSmrg
3627f3561b8bSmrgRemove files from the build directory.
3628fc5a983dSmrg
3629f3561b8bSmrgRM is the name of the program to use to delete files associated with each FILE
36306257f37dSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
3631f3561b8bSmrgto RM.
3632fc5a983dSmrg
3633f3561b8bSmrgIf FILE is a libtool library, object or program, all the files associated
3634f3561b8bSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
3635f3561b8bSmrg        ;;
3636fc5a983dSmrg
3637f3561b8bSmrg      compile)
3638f3561b8bSmrg      $ECHO \
3639f3561b8bSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
3640fc5a983dSmrg
3641f3561b8bSmrgCompile a source file into a libtool library object.
3642fc5a983dSmrg
3643f3561b8bSmrgThis mode accepts the following additional options:
3644fc5a983dSmrg
3645f3561b8bSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
3646f3561b8bSmrg  -no-suppress      do not suppress compiler output for multiple passes
3647bd304fc0Smrg  -prefer-pic       try to build PIC objects only
3648bd304fc0Smrg  -prefer-non-pic   try to build non-PIC objects only
36496257f37dSmrg  -shared           do not build a '.o' file suitable for static linking
36506257f37dSmrg  -static           only build a '.o' file suitable for static linking
3651bd304fc0Smrg  -Wc,FLAG          pass FLAG directly to the compiler
3652fc5a983dSmrg
36536257f37dSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file
3654f3561b8bSmrgfrom the given SOURCEFILE.
3655fc5a983dSmrg
3656f3561b8bSmrgThe output file name is determined by removing the directory component from
36576257f37dSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the
36586257f37dSmrglibrary object suffix, '.lo'."
3659f3561b8bSmrg        ;;
3660fc5a983dSmrg
3661f3561b8bSmrg      execute)
3662f3561b8bSmrg        $ECHO \
3663f3561b8bSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
3664fc5a983dSmrg
3665f3561b8bSmrgAutomatically set library path, then run a program.
3666fc5a983dSmrg
3667f3561b8bSmrgThis mode accepts the following additional options:
3668fc5a983dSmrg
3669f3561b8bSmrg  -dlopen FILE      add the directory containing FILE to the library path
3670fc5a983dSmrg
36716257f37dSmrgThis mode sets the library path environment variable according to '-dlopen'
3672f3561b8bSmrgflags.
3673fc5a983dSmrg
3674f3561b8bSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
3675f3561b8bSmrginto their corresponding uninstalled binary, and any of their required library
3676f3561b8bSmrgdirectories are added to the library path.
3677fc5a983dSmrg
3678f3561b8bSmrgThen, COMMAND is executed, with ARGS as arguments."
3679f3561b8bSmrg        ;;
3680fc5a983dSmrg
3681f3561b8bSmrg      finish)
3682f3561b8bSmrg        $ECHO \
3683f3561b8bSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
3684fc5a983dSmrg
3685f3561b8bSmrgComplete the installation of libtool libraries.
3686fc5a983dSmrg
3687f3561b8bSmrgEach LIBDIR is a directory that contains libtool libraries.
3688fc5a983dSmrg
3689f3561b8bSmrgThe commands that this mode executes may require superuser privileges.  Use
36906257f37dSmrgthe '--dry-run' option if you just want to see what would be executed."
3691f3561b8bSmrg        ;;
3692fc5a983dSmrg
3693f3561b8bSmrg      install)
3694f3561b8bSmrg        $ECHO \
3695f3561b8bSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
3696fc5a983dSmrg
3697f3561b8bSmrgInstall executables or libraries.
3698fc5a983dSmrg
3699f3561b8bSmrgINSTALL-COMMAND is the installation command.  The first component should be
37006257f37dSmrgeither the 'install' or 'cp' program.
3701fc5a983dSmrg
3702f3561b8bSmrgThe following components of INSTALL-COMMAND are treated specially:
3703fc5a983dSmrg
3704bd304fc0Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
3705fc5a983dSmrg
3706f3561b8bSmrgThe rest of the components are interpreted as arguments to that command (only
3707f3561b8bSmrgBSD-compatible install options are recognized)."
3708f3561b8bSmrg        ;;
3709fc5a983dSmrg
3710f3561b8bSmrg      link)
3711f3561b8bSmrg        $ECHO \
3712f3561b8bSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
3713fc5a983dSmrg
3714f3561b8bSmrgLink object files or libraries together to form another library, or to
3715f3561b8bSmrgcreate an executable program.
3716fc5a983dSmrg
3717f3561b8bSmrgLINK-COMMAND is a command using the C compiler that you would use to create
3718f3561b8bSmrga program from several object files.
3719fc5a983dSmrg
3720f3561b8bSmrgThe following components of LINK-COMMAND are treated specially:
3721fc5a983dSmrg
3722f3561b8bSmrg  -all-static       do not do any dynamic linking at all
3723f3561b8bSmrg  -avoid-version    do not add a version suffix if possible
3724bd304fc0Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
3725bd304fc0Smrg                    libraries must be found in the PATH setting at runtime)
37266257f37dSmrg  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
3727f3561b8bSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
3728f3561b8bSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
3729f3561b8bSmrg  -export-symbols SYMFILE
3730f3561b8bSmrg                    try to export only the symbols listed in SYMFILE
3731f3561b8bSmrg  -export-symbols-regex REGEX
3732f3561b8bSmrg                    try to export only the symbols matching REGEX
3733f3561b8bSmrg  -LLIBDIR          search LIBDIR for required installed libraries
3734f3561b8bSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
3735f3561b8bSmrg  -module           build a library that can dlopened
3736f3561b8bSmrg  -no-fast-install  disable the fast-install mode
3737f3561b8bSmrg  -no-install       link a not-installable executable
3738f3561b8bSmrg  -no-undefined     declare that a library does not refer to external symbols
3739f3561b8bSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
37406257f37dSmrg  -objectlist FILE  use a list of object files found in FILE to specify objects
37416257f37dSmrg  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
3742f3561b8bSmrg  -precious-files-regex REGEX
3743f3561b8bSmrg                    don't remove output files matching REGEX
3744f3561b8bSmrg  -release RELEASE  specify package release information
3745f3561b8bSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
3746f3561b8bSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
3747f3561b8bSmrg  -shared           only do dynamic linking of libtool libraries
3748f3561b8bSmrg  -shrext SUFFIX    override the standard shared library file extension
3749f3561b8bSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
3750f3561b8bSmrg  -static-libtool-libs
3751f3561b8bSmrg                    do not do any dynamic linking of libtool libraries
3752f3561b8bSmrg  -version-info CURRENT[:REVISION[:AGE]]
3753f3561b8bSmrg                    specify library version info [each variable defaults to 0]
3754f3561b8bSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
3755bd304fc0Smrg  -Wc,FLAG
3756bd304fc0Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
3757bd304fc0Smrg  -Wl,FLAG
3758bd304fc0Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
3759bd304fc0Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
3760fc5a983dSmrg
37616257f37dSmrgAll other options (arguments beginning with '-') are ignored.
3762fc5a983dSmrg
37636257f37dSmrgEvery other argument is treated as a filename.  Files ending in '.la' are
3764f3561b8bSmrgtreated as uninstalled libtool libraries, other files are standard or library
3765f3561b8bSmrgobject files.
3766fc5a983dSmrg
37676257f37dSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created,
37686257f37dSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is
3769f3561b8bSmrgrequired, except when creating a convenience library.
3770fc5a983dSmrg
37716257f37dSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
37726257f37dSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'.
3773fc5a983dSmrg
37746257f37dSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
3775f3561b8bSmrgis created, otherwise an executable program is created."
3776fc5a983dSmrg        ;;
3777fc5a983dSmrg
3778f3561b8bSmrg      uninstall)
3779f3561b8bSmrg        $ECHO \
3780f3561b8bSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
3781fc5a983dSmrg
3782f3561b8bSmrgRemove libraries from an installation directory.
3783fc5a983dSmrg
3784f3561b8bSmrgRM is the name of the program to use to delete files associated with each FILE
37856257f37dSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
3786f3561b8bSmrgto RM.
3787fc5a983dSmrg
3788f3561b8bSmrgIf FILE is a libtool library, all the files associated with it are deleted.
3789f3561b8bSmrgOtherwise, only FILE itself is deleted using RM."
3790f3561b8bSmrg        ;;
3791fc5a983dSmrg
3792f3561b8bSmrg      *)
37936257f37dSmrg        func_fatal_help "invalid operation mode '$opt_mode'"
3794f3561b8bSmrg        ;;
3795f3561b8bSmrg    esac
3796fc5a983dSmrg
3797bd304fc0Smrg    echo
37986257f37dSmrg    $ECHO "Try '$progname --help' for more information about other modes."
3799f3561b8bSmrg}
3800fc5a983dSmrg
3801bd304fc0Smrg# Now that we've collected a possible --mode arg, show help if necessary
3802bd304fc0Smrgif $opt_help; then
38036257f37dSmrg  if test : = "$opt_help"; then
3804bd304fc0Smrg    func_mode_help
3805bd304fc0Smrg  else
3806bd304fc0Smrg    {
3807bd304fc0Smrg      func_help noexit
3808bd304fc0Smrg      for opt_mode in compile link execute install finish uninstall clean; do
3809bd304fc0Smrg	func_mode_help
3810bd304fc0Smrg      done
38116257f37dSmrg    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
3812bd304fc0Smrg    {
3813bd304fc0Smrg      func_help noexit
3814bd304fc0Smrg      for opt_mode in compile link execute install finish uninstall clean; do
3815bd304fc0Smrg	echo
3816bd304fc0Smrg	func_mode_help
3817bd304fc0Smrg      done
3818bd304fc0Smrg    } |
38196257f37dSmrg    $SED '1d
3820bd304fc0Smrg      /^When reporting/,/^Report/{
3821bd304fc0Smrg	H
3822bd304fc0Smrg	d
3823bd304fc0Smrg      }
3824bd304fc0Smrg      $x
3825bd304fc0Smrg      /information about other modes/d
3826bd304fc0Smrg      /more detailed .*MODE/d
3827bd304fc0Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
3828bd304fc0Smrg  fi
3829bd304fc0Smrg  exit $?
3830bd304fc0Smrgfi
3831fc5a983dSmrg
3832fc5a983dSmrg
3833f3561b8bSmrg# func_mode_execute arg...
3834f3561b8bSmrgfunc_mode_execute ()
3835f3561b8bSmrg{
38366257f37dSmrg    $debug_cmd
38376257f37dSmrg
3838f3561b8bSmrg    # The first argument is the command name.
38396257f37dSmrg    cmd=$nonopt
3840f3561b8bSmrg    test -z "$cmd" && \
3841f3561b8bSmrg      func_fatal_help "you must specify a COMMAND"
3842fc5a983dSmrg
3843f3561b8bSmrg    # Handle -dlopen flags immediately.
3844bd304fc0Smrg    for file in $opt_dlopen; do
3845f3561b8bSmrg      test -f "$file" \
38466257f37dSmrg	|| func_fatal_help "'$file' is not a file"
3847fc5a983dSmrg
3848f3561b8bSmrg      dir=
3849f3561b8bSmrg      case $file in
3850f3561b8bSmrg      *.la)
3851bd304fc0Smrg	func_resolve_sysroot "$file"
3852bd304fc0Smrg	file=$func_resolve_sysroot_result
3853bd304fc0Smrg
3854f3561b8bSmrg	# Check to see that this really is a libtool archive.
3855f3561b8bSmrg	func_lalib_unsafe_p "$file" \
38566257f37dSmrg	  || func_fatal_help "'$lib' is not a valid libtool archive"
3857fc5a983dSmrg
3858f3561b8bSmrg	# Read the libtool library.
3859f3561b8bSmrg	dlname=
3860f3561b8bSmrg	library_names=
3861f3561b8bSmrg	func_source "$file"
3862fc5a983dSmrg
3863f3561b8bSmrg	# Skip this library if it cannot be dlopened.
3864f3561b8bSmrg	if test -z "$dlname"; then
3865f3561b8bSmrg	  # Warn if it was a shared library.
3866f3561b8bSmrg	  test -n "$library_names" && \
38676257f37dSmrg	    func_warning "'$file' was not linked with '-export-dynamic'"
3868f3561b8bSmrg	  continue
3869f3561b8bSmrg	fi
3870fc5a983dSmrg
3871f3561b8bSmrg	func_dirname "$file" "" "."
38726257f37dSmrg	dir=$func_dirname_result
3873fc5a983dSmrg
3874f3561b8bSmrg	if test -f "$dir/$objdir/$dlname"; then
3875bd304fc0Smrg	  func_append dir "/$objdir"
3876f3561b8bSmrg	else
3877f3561b8bSmrg	  if test ! -f "$dir/$dlname"; then
38786257f37dSmrg	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
3879f3561b8bSmrg	  fi
3880f3561b8bSmrg	fi
3881fc5a983dSmrg	;;
3882fc5a983dSmrg
3883f3561b8bSmrg      *.lo)
3884f3561b8bSmrg	# Just add the directory containing the .lo file.
3885f3561b8bSmrg	func_dirname "$file" "" "."
38866257f37dSmrg	dir=$func_dirname_result
3887fc5a983dSmrg	;;
3888fc5a983dSmrg
3889f3561b8bSmrg      *)
38906257f37dSmrg	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
3891fc5a983dSmrg	continue
3892fc5a983dSmrg	;;
3893f3561b8bSmrg      esac
3894fc5a983dSmrg
3895f3561b8bSmrg      # Get the absolute pathname.
3896f3561b8bSmrg      absdir=`cd "$dir" && pwd`
38976257f37dSmrg      test -n "$absdir" && dir=$absdir
3898fc5a983dSmrg
3899f3561b8bSmrg      # Now add the directory to shlibpath_var.
3900f3561b8bSmrg      if eval "test -z \"\$$shlibpath_var\""; then
3901f3561b8bSmrg	eval "$shlibpath_var=\"\$dir\""
3902f3561b8bSmrg      else
3903f3561b8bSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
3904f3561b8bSmrg      fi
3905f3561b8bSmrg    done
3906fc5a983dSmrg
3907f3561b8bSmrg    # This variable tells wrapper scripts just to set shlibpath_var
3908f3561b8bSmrg    # rather than running their programs.
39096257f37dSmrg    libtool_execute_magic=$magic
3910fc5a983dSmrg
3911f3561b8bSmrg    # Check if any of the arguments is a wrapper script.
3912f3561b8bSmrg    args=
3913f3561b8bSmrg    for file
3914f3561b8bSmrg    do
3915f3561b8bSmrg      case $file in
3916bd304fc0Smrg      -* | *.la | *.lo ) ;;
3917f3561b8bSmrg      *)
3918f3561b8bSmrg	# Do a test to see if this is really a libtool program.
3919f3561b8bSmrg	if func_ltwrapper_script_p "$file"; then
3920f3561b8bSmrg	  func_source "$file"
3921f3561b8bSmrg	  # Transform arg to wrapped name.
39226257f37dSmrg	  file=$progdir/$program
3923f3561b8bSmrg	elif func_ltwrapper_executable_p "$file"; then
3924f3561b8bSmrg	  func_ltwrapper_scriptname "$file"
3925f3561b8bSmrg	  func_source "$func_ltwrapper_scriptname_result"
3926f3561b8bSmrg	  # Transform arg to wrapped name.
39276257f37dSmrg	  file=$progdir/$program
3928f3561b8bSmrg	fi
3929f3561b8bSmrg	;;
3930f3561b8bSmrg      esac
3931f3561b8bSmrg      # Quote arguments (to preserve shell metacharacters).
3932bd304fc0Smrg      func_append_quoted args "$file"
3933f3561b8bSmrg    done
3934fc5a983dSmrg
39356257f37dSmrg    if $opt_dry_run; then
39366257f37dSmrg      # Display what would be done.
39376257f37dSmrg      if test -n "$shlibpath_var"; then
39386257f37dSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
39396257f37dSmrg	echo "export $shlibpath_var"
39406257f37dSmrg      fi
39416257f37dSmrg      $ECHO "$cmd$args"
39426257f37dSmrg      exit $EXIT_SUCCESS
39436257f37dSmrg    else
3944f3561b8bSmrg      if test -n "$shlibpath_var"; then
3945f3561b8bSmrg	# Export the shlibpath_var.
3946f3561b8bSmrg	eval "export $shlibpath_var"
3947f3561b8bSmrg      fi
3948fc5a983dSmrg
3949f3561b8bSmrg      # Restore saved environment variables
3950f3561b8bSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
3951f3561b8bSmrg      do
3952f3561b8bSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
3953f3561b8bSmrg                $lt_var=\$save_$lt_var; export $lt_var
3954fc5a983dSmrg	      else
3955f3561b8bSmrg		$lt_unset $lt_var
3956f3561b8bSmrg	      fi"
3957f3561b8bSmrg      done
3958fc5a983dSmrg
3959f3561b8bSmrg      # Now prepare to actually exec the command.
39606257f37dSmrg      exec_cmd=\$cmd$args
3961f3561b8bSmrg    fi
3962f3561b8bSmrg}
3963fc5a983dSmrg
39646257f37dSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"}
3965fc5a983dSmrg
3966fc5a983dSmrg
3967f3561b8bSmrg# func_mode_finish arg...
3968f3561b8bSmrgfunc_mode_finish ()
3969f3561b8bSmrg{
39706257f37dSmrg    $debug_cmd
39716257f37dSmrg
3972bd304fc0Smrg    libs=
3973bd304fc0Smrg    libdirs=
3974f3561b8bSmrg    admincmds=
3975fc5a983dSmrg
3976bd304fc0Smrg    for opt in "$nonopt" ${1+"$@"}
3977bd304fc0Smrg    do
3978bd304fc0Smrg      if test -d "$opt"; then
3979bd304fc0Smrg	func_append libdirs " $opt"
3980bd304fc0Smrg
3981bd304fc0Smrg      elif test -f "$opt"; then
3982bd304fc0Smrg	if func_lalib_unsafe_p "$opt"; then
3983bd304fc0Smrg	  func_append libs " $opt"
3984bd304fc0Smrg	else
39856257f37dSmrg	  func_warning "'$opt' is not a valid libtool archive"
3986bd304fc0Smrg	fi
3987bd304fc0Smrg
3988bd304fc0Smrg      else
39896257f37dSmrg	func_fatal_error "invalid argument '$opt'"
3990bd304fc0Smrg      fi
3991bd304fc0Smrg    done
3992bd304fc0Smrg
3993bd304fc0Smrg    if test -n "$libs"; then
3994bd304fc0Smrg      if test -n "$lt_sysroot"; then
3995bd304fc0Smrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
3996bd304fc0Smrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
3997bd304fc0Smrg      else
3998bd304fc0Smrg        sysroot_cmd=
3999bd304fc0Smrg      fi
4000bd304fc0Smrg
4001bd304fc0Smrg      # Remove sysroot references
4002bd304fc0Smrg      if $opt_dry_run; then
4003bd304fc0Smrg        for lib in $libs; do
40046257f37dSmrg          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
4005bd304fc0Smrg        done
4006bd304fc0Smrg      else
4007bd304fc0Smrg        tmpdir=`func_mktempdir`
4008bd304fc0Smrg        for lib in $libs; do
40096257f37dSmrg	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
4010bd304fc0Smrg	    > $tmpdir/tmp-la
4011bd304fc0Smrg	  mv -f $tmpdir/tmp-la $lib
4012bd304fc0Smrg	done
4013bd304fc0Smrg        ${RM}r "$tmpdir"
4014bd304fc0Smrg      fi
4015bd304fc0Smrg    fi
4016fc5a983dSmrg
4017bd304fc0Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4018f3561b8bSmrg      for libdir in $libdirs; do
4019f3561b8bSmrg	if test -n "$finish_cmds"; then
4020f3561b8bSmrg	  # Do each command in the finish commands.
4021f3561b8bSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
4022f3561b8bSmrg'"$cmd"'"'
4023fc5a983dSmrg	fi
4024f3561b8bSmrg	if test -n "$finish_eval"; then
4025f3561b8bSmrg	  # Do the single finish_eval.
4026f3561b8bSmrg	  eval cmds=\"$finish_eval\"
4027bd304fc0Smrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
4028f3561b8bSmrg       $cmds"
4029f3561b8bSmrg	fi
4030f3561b8bSmrg      done
4031f3561b8bSmrg    fi
4032fc5a983dSmrg
4033f3561b8bSmrg    # Exit here if they wanted silent mode.
40346257f37dSmrg    $opt_quiet && exit $EXIT_SUCCESS
4035fc5a983dSmrg
4036bd304fc0Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4037bd304fc0Smrg      echo "----------------------------------------------------------------------"
4038bd304fc0Smrg      echo "Libraries have been installed in:"
4039bd304fc0Smrg      for libdir in $libdirs; do
4040bd304fc0Smrg	$ECHO "   $libdir"
4041bd304fc0Smrg      done
4042bd304fc0Smrg      echo
4043bd304fc0Smrg      echo "If you ever happen to want to link against installed libraries"
4044bd304fc0Smrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
40456257f37dSmrg      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
4046bd304fc0Smrg      echo "flag during linking and do at least one of the following:"
4047bd304fc0Smrg      if test -n "$shlibpath_var"; then
40486257f37dSmrg	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
4049bd304fc0Smrg	echo "     during execution"
4050bd304fc0Smrg      fi
4051bd304fc0Smrg      if test -n "$runpath_var"; then
40526257f37dSmrg	echo "   - add LIBDIR to the '$runpath_var' environment variable"
4053bd304fc0Smrg	echo "     during linking"
4054bd304fc0Smrg      fi
4055bd304fc0Smrg      if test -n "$hardcode_libdir_flag_spec"; then
4056bd304fc0Smrg	libdir=LIBDIR
4057bd304fc0Smrg	eval flag=\"$hardcode_libdir_flag_spec\"
4058bd304fc0Smrg
40596257f37dSmrg	$ECHO "   - use the '$flag' linker flag"
4060bd304fc0Smrg      fi
4061bd304fc0Smrg      if test -n "$admincmds"; then
4062bd304fc0Smrg	$ECHO "   - have your system administrator run these commands:$admincmds"
4063bd304fc0Smrg      fi
4064bd304fc0Smrg      if test -f /etc/ld.so.conf; then
40656257f37dSmrg	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
4066bd304fc0Smrg      fi
4067bd304fc0Smrg      echo
4068f3561b8bSmrg
4069bd304fc0Smrg      echo "See any operating system documentation about shared libraries for"
4070bd304fc0Smrg      case $host in
4071bd304fc0Smrg	solaris2.[6789]|solaris2.1[0-9])
4072bd304fc0Smrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
4073bd304fc0Smrg	  echo "pages."
4074bd304fc0Smrg	  ;;
4075bd304fc0Smrg	*)
4076bd304fc0Smrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
4077bd304fc0Smrg	  ;;
4078bd304fc0Smrg      esac
4079bd304fc0Smrg      echo "----------------------------------------------------------------------"
4080f3561b8bSmrg    fi
4081f3561b8bSmrg    exit $EXIT_SUCCESS
4082f3561b8bSmrg}
4083f3561b8bSmrg
40846257f37dSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"}
4085f3561b8bSmrg
4086f3561b8bSmrg
4087f3561b8bSmrg# func_mode_install arg...
4088f3561b8bSmrgfunc_mode_install ()
4089f3561b8bSmrg{
40906257f37dSmrg    $debug_cmd
40916257f37dSmrg
4092f3561b8bSmrg    # There may be an optional sh(1) argument at the beginning of
4093f3561b8bSmrg    # install_prog (especially on Windows NT).
40946257f37dSmrg    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
4095f3561b8bSmrg       # Allow the use of GNU shtool's install command.
40966257f37dSmrg       case $nonopt in *shtool*) :;; *) false;; esac
40976257f37dSmrg    then
4098f3561b8bSmrg      # Aesthetically quote it.
4099f3561b8bSmrg      func_quote_for_eval "$nonopt"
4100f3561b8bSmrg      install_prog="$func_quote_for_eval_result "
4101f3561b8bSmrg      arg=$1
4102f3561b8bSmrg      shift
4103f3561b8bSmrg    else
4104f3561b8bSmrg      install_prog=
4105f3561b8bSmrg      arg=$nonopt
4106f3561b8bSmrg    fi
4107f3561b8bSmrg
4108f3561b8bSmrg    # The real first argument should be the name of the installation program.
4109f3561b8bSmrg    # Aesthetically quote it.
4110f3561b8bSmrg    func_quote_for_eval "$arg"
4111bd304fc0Smrg    func_append install_prog "$func_quote_for_eval_result"
4112bd304fc0Smrg    install_shared_prog=$install_prog
4113bd304fc0Smrg    case " $install_prog " in
4114bd304fc0Smrg      *[\\\ /]cp\ *) install_cp=: ;;
4115bd304fc0Smrg      *) install_cp=false ;;
4116bd304fc0Smrg    esac
4117f3561b8bSmrg
4118f3561b8bSmrg    # We need to accept at least all the BSD install flags.
4119f3561b8bSmrg    dest=
4120f3561b8bSmrg    files=
4121f3561b8bSmrg    opts=
4122f3561b8bSmrg    prev=
4123f3561b8bSmrg    install_type=
41246257f37dSmrg    isdir=false
4125f3561b8bSmrg    stripme=
4126bd304fc0Smrg    no_mode=:
4127f3561b8bSmrg    for arg
4128f3561b8bSmrg    do
4129bd304fc0Smrg      arg2=
4130f3561b8bSmrg      if test -n "$dest"; then
4131bd304fc0Smrg	func_append files " $dest"
4132f3561b8bSmrg	dest=$arg
4133f3561b8bSmrg	continue
4134f3561b8bSmrg      fi
4135f3561b8bSmrg
4136f3561b8bSmrg      case $arg in
41376257f37dSmrg      -d) isdir=: ;;
4138f3561b8bSmrg      -f)
4139bd304fc0Smrg	if $install_cp; then :; else
4140bd304fc0Smrg	  prev=$arg
4141bd304fc0Smrg	fi
4142f3561b8bSmrg	;;
4143f3561b8bSmrg      -g | -m | -o)
4144f3561b8bSmrg	prev=$arg
4145f3561b8bSmrg	;;
4146f3561b8bSmrg      -s)
4147f3561b8bSmrg	stripme=" -s"
4148f3561b8bSmrg	continue
4149f3561b8bSmrg	;;
4150f3561b8bSmrg      -*)
4151f3561b8bSmrg	;;
4152f3561b8bSmrg      *)
4153f3561b8bSmrg	# If the previous option needed an argument, then skip it.
4154f3561b8bSmrg	if test -n "$prev"; then
41556257f37dSmrg	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
4156bd304fc0Smrg	    arg2=$install_override_mode
4157bd304fc0Smrg	    no_mode=false
4158bd304fc0Smrg	  fi
4159fc5a983dSmrg	  prev=
4160fc5a983dSmrg	else
4161f3561b8bSmrg	  dest=$arg
4162f3561b8bSmrg	  continue
4163fc5a983dSmrg	fi
4164fc5a983dSmrg	;;
4165f3561b8bSmrg      esac
4166fc5a983dSmrg
4167f3561b8bSmrg      # Aesthetically quote the argument.
4168f3561b8bSmrg      func_quote_for_eval "$arg"
4169bd304fc0Smrg      func_append install_prog " $func_quote_for_eval_result"
4170bd304fc0Smrg      if test -n "$arg2"; then
4171bd304fc0Smrg	func_quote_for_eval "$arg2"
4172bd304fc0Smrg      fi
4173bd304fc0Smrg      func_append install_shared_prog " $func_quote_for_eval_result"
4174f3561b8bSmrg    done
4175fc5a983dSmrg
4176f3561b8bSmrg    test -z "$install_prog" && \
4177f3561b8bSmrg      func_fatal_help "you must specify an install program"
4178fc5a983dSmrg
4179f3561b8bSmrg    test -n "$prev" && \
41806257f37dSmrg      func_fatal_help "the '$prev' option requires an argument"
4181fc5a983dSmrg
4182bd304fc0Smrg    if test -n "$install_override_mode" && $no_mode; then
4183bd304fc0Smrg      if $install_cp; then :; else
4184bd304fc0Smrg	func_quote_for_eval "$install_override_mode"
4185bd304fc0Smrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
4186bd304fc0Smrg      fi
4187bd304fc0Smrg    fi
4188bd304fc0Smrg
4189f3561b8bSmrg    if test -z "$files"; then
4190f3561b8bSmrg      if test -z "$dest"; then
4191f3561b8bSmrg	func_fatal_help "no file or destination specified"
4192f3561b8bSmrg      else
4193f3561b8bSmrg	func_fatal_help "you must specify a destination"
4194f3561b8bSmrg      fi
4195fc5a983dSmrg    fi
4196fc5a983dSmrg
4197f3561b8bSmrg    # Strip any trailing slash from the destination.
4198f3561b8bSmrg    func_stripname '' '/' "$dest"
4199f3561b8bSmrg    dest=$func_stripname_result
4200fc5a983dSmrg
4201f3561b8bSmrg    # Check to see that the destination is a directory.
42026257f37dSmrg    test -d "$dest" && isdir=:
42036257f37dSmrg    if $isdir; then
42046257f37dSmrg      destdir=$dest
4205f3561b8bSmrg      destname=
4206fc5a983dSmrg    else
4207f3561b8bSmrg      func_dirname_and_basename "$dest" "" "."
42086257f37dSmrg      destdir=$func_dirname_result
42096257f37dSmrg      destname=$func_basename_result
4210fc5a983dSmrg
4211f3561b8bSmrg      # Not a directory, so check to see that there is only one file specified.
4212f3561b8bSmrg      set dummy $files; shift
4213f3561b8bSmrg      test "$#" -gt 1 && \
42146257f37dSmrg	func_fatal_help "'$dest' is not a directory"
4215fc5a983dSmrg    fi
4216f3561b8bSmrg    case $destdir in
4217f3561b8bSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
4218fc5a983dSmrg    *)
4219f3561b8bSmrg      for file in $files; do
4220f3561b8bSmrg	case $file in
4221f3561b8bSmrg	*.lo) ;;
4222f3561b8bSmrg	*)
42236257f37dSmrg	  func_fatal_help "'$destdir' must be an absolute directory name"
4224f3561b8bSmrg	  ;;
4225f3561b8bSmrg	esac
4226f3561b8bSmrg      done
4227fc5a983dSmrg      ;;
4228fc5a983dSmrg    esac
4229fc5a983dSmrg
4230f3561b8bSmrg    # This variable tells wrapper scripts just to set variables rather
4231f3561b8bSmrg    # than running their programs.
42326257f37dSmrg    libtool_install_magic=$magic
4233fc5a983dSmrg
4234f3561b8bSmrg    staticlibs=
4235f3561b8bSmrg    future_libdirs=
4236f3561b8bSmrg    current_libdirs=
4237f3561b8bSmrg    for file in $files; do
4238fc5a983dSmrg
4239f3561b8bSmrg      # Do each installation.
4240f3561b8bSmrg      case $file in
4241f3561b8bSmrg      *.$libext)
4242f3561b8bSmrg	# Do the static libraries later.
4243bd304fc0Smrg	func_append staticlibs " $file"
4244f3561b8bSmrg	;;
4245f3561b8bSmrg
4246f3561b8bSmrg      *.la)
4247bd304fc0Smrg	func_resolve_sysroot "$file"
4248bd304fc0Smrg	file=$func_resolve_sysroot_result
4249bd304fc0Smrg
4250f3561b8bSmrg	# Check to see that this really is a libtool archive.
4251f3561b8bSmrg	func_lalib_unsafe_p "$file" \
42526257f37dSmrg	  || func_fatal_help "'$file' is not a valid libtool archive"
4253f3561b8bSmrg
4254f3561b8bSmrg	library_names=
4255f3561b8bSmrg	old_library=
4256f3561b8bSmrg	relink_command=
4257f3561b8bSmrg	func_source "$file"
4258f3561b8bSmrg
4259f3561b8bSmrg	# Add the libdir to current_libdirs if it is the destination.
4260f3561b8bSmrg	if test "X$destdir" = "X$libdir"; then
4261f3561b8bSmrg	  case "$current_libdirs " in
4262f3561b8bSmrg	  *" $libdir "*) ;;
4263bd304fc0Smrg	  *) func_append current_libdirs " $libdir" ;;
4264fc5a983dSmrg	  esac
4265f3561b8bSmrg	else
4266f3561b8bSmrg	  # Note the libdir as a future libdir.
4267f3561b8bSmrg	  case "$future_libdirs " in
4268f3561b8bSmrg	  *" $libdir "*) ;;
4269bd304fc0Smrg	  *) func_append future_libdirs " $libdir" ;;
4270f3561b8bSmrg	  esac
4271f3561b8bSmrg	fi
4272fc5a983dSmrg
4273f3561b8bSmrg	func_dirname "$file" "/" ""
42746257f37dSmrg	dir=$func_dirname_result
4275bd304fc0Smrg	func_append dir "$objdir"
4276f3561b8bSmrg
4277f3561b8bSmrg	if test -n "$relink_command"; then
4278f3561b8bSmrg	  # Determine the prefix the user has applied to our future dir.
4279bd304fc0Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
4280f3561b8bSmrg
4281f3561b8bSmrg	  # Don't allow the user to place us outside of our expected
4282f3561b8bSmrg	  # location b/c this prevents finding dependent libraries that
4283f3561b8bSmrg	  # are installed to the same prefix.
4284f3561b8bSmrg	  # At present, this check doesn't affect windows .dll's that
4285f3561b8bSmrg	  # are installed into $libdir/../bin (currently, that works fine)
4286f3561b8bSmrg	  # but it's something to keep an eye on.
4287f3561b8bSmrg	  test "$inst_prefix_dir" = "$destdir" && \
42886257f37dSmrg	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
4289f3561b8bSmrg
4290f3561b8bSmrg	  if test -n "$inst_prefix_dir"; then
4291f3561b8bSmrg	    # Stick the inst_prefix_dir data into the link command.
4292bd304fc0Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
4293f3561b8bSmrg	  else
4294bd304fc0Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
4295f3561b8bSmrg	  fi
4296f3561b8bSmrg
42976257f37dSmrg	  func_warning "relinking '$file'"
4298f3561b8bSmrg	  func_show_eval "$relink_command" \
42996257f37dSmrg	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
4300f3561b8bSmrg	fi
4301f3561b8bSmrg
4302f3561b8bSmrg	# See the names of the shared library.
4303f3561b8bSmrg	set dummy $library_names; shift
4304f3561b8bSmrg	if test -n "$1"; then
43056257f37dSmrg	  realname=$1
4306f3561b8bSmrg	  shift
4307f3561b8bSmrg
43086257f37dSmrg	  srcname=$realname
43096257f37dSmrg	  test -n "$relink_command" && srcname=${realname}T
4310f3561b8bSmrg
4311f3561b8bSmrg	  # Install the shared library and build the symlinks.
4312bd304fc0Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
4313f3561b8bSmrg	      'exit $?'
43146257f37dSmrg	  tstripme=$stripme
4315f3561b8bSmrg	  case $host_os in
4316f3561b8bSmrg	  cygwin* | mingw* | pw32* | cegcc*)
4317f3561b8bSmrg	    case $realname in
4318f3561b8bSmrg	    *.dll.a)
43196257f37dSmrg	      tstripme=
43206257f37dSmrg	      ;;
43216257f37dSmrg	    esac
43226257f37dSmrg	    ;;
43236257f37dSmrg	  os2*)
43246257f37dSmrg	    case $realname in
43256257f37dSmrg	    *_dll.a)
43266257f37dSmrg	      tstripme=
4327f3561b8bSmrg	      ;;
4328f3561b8bSmrg	    esac
4329fc5a983dSmrg	    ;;
4330fc5a983dSmrg	  esac
4331f3561b8bSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
4332f3561b8bSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
4333fc5a983dSmrg	  fi
4334f3561b8bSmrg
4335f3561b8bSmrg	  if test "$#" -gt 0; then
4336f3561b8bSmrg	    # Delete the old symlinks, and create new ones.
43376257f37dSmrg	    # Try 'ln -sf' first, because the 'ln' binary might depend on
4338f3561b8bSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
4339f3561b8bSmrg	    # so we also need to try rm && ln -s.
4340f3561b8bSmrg	    for linkname
4341f3561b8bSmrg	    do
4342f3561b8bSmrg	      test "$linkname" != "$realname" \
4343f3561b8bSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
4344fc5a983dSmrg	    done
4345fc5a983dSmrg	  fi
4346fc5a983dSmrg
4347f3561b8bSmrg	  # Do each command in the postinstall commands.
43486257f37dSmrg	  lib=$destdir/$realname
4349f3561b8bSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
4350fc5a983dSmrg	fi
4351fc5a983dSmrg
4352f3561b8bSmrg	# Install the pseudo-library for information purposes.
4353f3561b8bSmrg	func_basename "$file"
43546257f37dSmrg	name=$func_basename_result
43556257f37dSmrg	instname=$dir/${name}i
4356f3561b8bSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
4357fc5a983dSmrg
4358f3561b8bSmrg	# Maybe install the static library, too.
4359bd304fc0Smrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
4360f3561b8bSmrg	;;
4361fc5a983dSmrg
4362f3561b8bSmrg      *.lo)
4363f3561b8bSmrg	# Install (i.e. copy) a libtool object.
4364fc5a983dSmrg
4365f3561b8bSmrg	# Figure out destination file name, if it wasn't already specified.
4366f3561b8bSmrg	if test -n "$destname"; then
43676257f37dSmrg	  destfile=$destdir/$destname
4368f3561b8bSmrg	else
4369f3561b8bSmrg	  func_basename "$file"
43706257f37dSmrg	  destfile=$func_basename_result
43716257f37dSmrg	  destfile=$destdir/$destfile
4372fc5a983dSmrg	fi
4373fc5a983dSmrg
4374f3561b8bSmrg	# Deduce the name of the destination old-style object file.
4375f3561b8bSmrg	case $destfile in
4376f3561b8bSmrg	*.lo)
4377f3561b8bSmrg	  func_lo2o "$destfile"
4378f3561b8bSmrg	  staticdest=$func_lo2o_result
4379f3561b8bSmrg	  ;;
4380f3561b8bSmrg	*.$objext)
43816257f37dSmrg	  staticdest=$destfile
4382f3561b8bSmrg	  destfile=
4383f3561b8bSmrg	  ;;
4384f3561b8bSmrg	*)
43856257f37dSmrg	  func_fatal_help "cannot copy a libtool object to '$destfile'"
4386f3561b8bSmrg	  ;;
4387f3561b8bSmrg	esac
4388fc5a983dSmrg
4389f3561b8bSmrg	# Install the libtool object if requested.
4390f3561b8bSmrg	test -n "$destfile" && \
4391f3561b8bSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
4392fc5a983dSmrg
4393f3561b8bSmrg	# Install the old object if enabled.
43946257f37dSmrg	if test yes = "$build_old_libs"; then
4395f3561b8bSmrg	  # Deduce the name of the old-style object file.
4396f3561b8bSmrg	  func_lo2o "$file"
4397f3561b8bSmrg	  staticobj=$func_lo2o_result
4398f3561b8bSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
4399fc5a983dSmrg	fi
4400f3561b8bSmrg	exit $EXIT_SUCCESS
4401f3561b8bSmrg	;;
4402fc5a983dSmrg
4403f3561b8bSmrg      *)
4404f3561b8bSmrg	# Figure out destination file name, if it wasn't already specified.
4405f3561b8bSmrg	if test -n "$destname"; then
44066257f37dSmrg	  destfile=$destdir/$destname
4407f3561b8bSmrg	else
4408f3561b8bSmrg	  func_basename "$file"
44096257f37dSmrg	  destfile=$func_basename_result
44106257f37dSmrg	  destfile=$destdir/$destfile
4411f3561b8bSmrg	fi
4412fc5a983dSmrg
4413f3561b8bSmrg	# If the file is missing, and there is a .exe on the end, strip it
4414f3561b8bSmrg	# because it is most likely a libtool script we actually want to
4415f3561b8bSmrg	# install
44166257f37dSmrg	stripped_ext=
4417f3561b8bSmrg	case $file in
4418f3561b8bSmrg	  *.exe)
4419f3561b8bSmrg	    if test ! -f "$file"; then
4420f3561b8bSmrg	      func_stripname '' '.exe' "$file"
4421f3561b8bSmrg	      file=$func_stripname_result
44226257f37dSmrg	      stripped_ext=.exe
4423f3561b8bSmrg	    fi
4424f3561b8bSmrg	    ;;
4425f3561b8bSmrg	esac
4426f3561b8bSmrg
4427f3561b8bSmrg	# Do a test to see if this is really a libtool program.
4428f3561b8bSmrg	case $host in
4429f3561b8bSmrg	*cygwin* | *mingw*)
4430f3561b8bSmrg	    if func_ltwrapper_executable_p "$file"; then
4431f3561b8bSmrg	      func_ltwrapper_scriptname "$file"
4432f3561b8bSmrg	      wrapper=$func_ltwrapper_scriptname_result
4433f3561b8bSmrg	    else
4434f3561b8bSmrg	      func_stripname '' '.exe' "$file"
4435f3561b8bSmrg	      wrapper=$func_stripname_result
4436f3561b8bSmrg	    fi
4437f3561b8bSmrg	    ;;
4438fc5a983dSmrg	*)
4439f3561b8bSmrg	    wrapper=$file
4440f3561b8bSmrg	    ;;
4441f3561b8bSmrg	esac
4442f3561b8bSmrg	if func_ltwrapper_script_p "$wrapper"; then
4443f3561b8bSmrg	  notinst_deplibs=
4444f3561b8bSmrg	  relink_command=
4445f3561b8bSmrg
4446f3561b8bSmrg	  func_source "$wrapper"
4447f3561b8bSmrg
4448f3561b8bSmrg	  # Check the variables that should have been set.
4449f3561b8bSmrg	  test -z "$generated_by_libtool_version" && \
44506257f37dSmrg	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
4451f3561b8bSmrg
44526257f37dSmrg	  finalize=:
4453f3561b8bSmrg	  for lib in $notinst_deplibs; do
4454f3561b8bSmrg	    # Check to see that each library is installed.
4455f3561b8bSmrg	    libdir=
4456f3561b8bSmrg	    if test -f "$lib"; then
4457f3561b8bSmrg	      func_source "$lib"
4458f3561b8bSmrg	    fi
44596257f37dSmrg	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
4460f3561b8bSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
44616257f37dSmrg	      func_warning "'$lib' has not been installed in '$libdir'"
44626257f37dSmrg	      finalize=false
4463f3561b8bSmrg	    fi
4464f3561b8bSmrg	  done
4465f3561b8bSmrg
4466f3561b8bSmrg	  relink_command=
4467f3561b8bSmrg	  func_source "$wrapper"
4468f3561b8bSmrg
4469f3561b8bSmrg	  outputname=
44706257f37dSmrg	  if test no = "$fast_install" && test -n "$relink_command"; then
4471f3561b8bSmrg	    $opt_dry_run || {
44726257f37dSmrg	      if $finalize; then
4473f3561b8bSmrg	        tmpdir=`func_mktempdir`
4474f3561b8bSmrg		func_basename "$file$stripped_ext"
44756257f37dSmrg		file=$func_basename_result
44766257f37dSmrg	        outputname=$tmpdir/$file
4477f3561b8bSmrg	        # Replace the output file specification.
4478bd304fc0Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
4479f3561b8bSmrg
44806257f37dSmrg	        $opt_quiet || {
4481f3561b8bSmrg	          func_quote_for_expand "$relink_command"
4482f3561b8bSmrg		  eval "func_echo $func_quote_for_expand_result"
4483f3561b8bSmrg	        }
4484f3561b8bSmrg	        if eval "$relink_command"; then :
4485f3561b8bSmrg	          else
44866257f37dSmrg		  func_error "error: relink '$file' with the above command before installing it"
4487f3561b8bSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
4488f3561b8bSmrg		  continue
4489f3561b8bSmrg	        fi
44906257f37dSmrg	        file=$outputname
4491f3561b8bSmrg	      else
44926257f37dSmrg	        func_warning "cannot relink '$file'"
4493f3561b8bSmrg	      fi
4494f3561b8bSmrg	    }
4495f3561b8bSmrg	  else
4496f3561b8bSmrg	    # Install the binary that we compiled earlier.
4497bd304fc0Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
4498fc5a983dSmrg	  fi
4499f3561b8bSmrg	fi
4500f3561b8bSmrg
4501f3561b8bSmrg	# remove .exe since cygwin /usr/bin/install will append another
4502f3561b8bSmrg	# one anyway
4503f3561b8bSmrg	case $install_prog,$host in
4504f3561b8bSmrg	*/usr/bin/install*,*cygwin*)
4505f3561b8bSmrg	  case $file:$destfile in
4506f3561b8bSmrg	  *.exe:*.exe)
4507f3561b8bSmrg	    # this is ok
4508f3561b8bSmrg	    ;;
4509f3561b8bSmrg	  *.exe:*)
4510f3561b8bSmrg	    destfile=$destfile.exe
4511f3561b8bSmrg	    ;;
4512f3561b8bSmrg	  *:*.exe)
4513f3561b8bSmrg	    func_stripname '' '.exe' "$destfile"
4514f3561b8bSmrg	    destfile=$func_stripname_result
4515f3561b8bSmrg	    ;;
4516f3561b8bSmrg	  esac
4517fc5a983dSmrg	  ;;
4518fc5a983dSmrg	esac
4519f3561b8bSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
4520f3561b8bSmrg	$opt_dry_run || if test -n "$outputname"; then
4521f3561b8bSmrg	  ${RM}r "$tmpdir"
4522f3561b8bSmrg	fi
4523f3561b8bSmrg	;;
4524f3561b8bSmrg      esac
4525f3561b8bSmrg    done
4526fc5a983dSmrg
4527f3561b8bSmrg    for file in $staticlibs; do
4528f3561b8bSmrg      func_basename "$file"
45296257f37dSmrg      name=$func_basename_result
4530f3561b8bSmrg
4531f3561b8bSmrg      # Set up the ranlib parameters.
45326257f37dSmrg      oldlib=$destdir/$name
4533bd304fc0Smrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
4534bd304fc0Smrg      tool_oldlib=$func_to_tool_file_result
4535f3561b8bSmrg
4536f3561b8bSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
4537f3561b8bSmrg
4538f3561b8bSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
4539bd304fc0Smrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
4540f3561b8bSmrg      fi
4541f3561b8bSmrg
4542f3561b8bSmrg      # Do each command in the postinstall commands.
4543f3561b8bSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
4544f3561b8bSmrg    done
4545f3561b8bSmrg
4546f3561b8bSmrg    test -n "$future_libdirs" && \
45476257f37dSmrg      func_warning "remember to run '$progname --finish$future_libdirs'"
4548f3561b8bSmrg
4549f3561b8bSmrg    if test -n "$current_libdirs"; then
4550f3561b8bSmrg      # Maybe just do a dry run.
4551f3561b8bSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
45526257f37dSmrg      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
4553f3561b8bSmrg    else
4554f3561b8bSmrg      exit $EXIT_SUCCESS
4555f3561b8bSmrg    fi
4556f3561b8bSmrg}
4557f3561b8bSmrg
45586257f37dSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"}
4559f3561b8bSmrg
4560f3561b8bSmrg
4561f3561b8bSmrg# func_generate_dlsyms outputname originator pic_p
4562f3561b8bSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
4563f3561b8bSmrg# a dlpreopen symbol table.
4564f3561b8bSmrgfunc_generate_dlsyms ()
4565f3561b8bSmrg{
45666257f37dSmrg    $debug_cmd
45676257f37dSmrg
45686257f37dSmrg    my_outputname=$1
45696257f37dSmrg    my_originator=$2
45706257f37dSmrg    my_pic_p=${3-false}
45716257f37dSmrg    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
4572f3561b8bSmrg    my_dlsyms=
4573f3561b8bSmrg
45746257f37dSmrg    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
4575f3561b8bSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
45766257f37dSmrg	my_dlsyms=${my_outputname}S.c
4577f3561b8bSmrg      else
4578f3561b8bSmrg	func_error "not configured to extract global symbols from dlpreopened files"
4579f3561b8bSmrg      fi
4580f3561b8bSmrg    fi
4581f3561b8bSmrg
4582f3561b8bSmrg    if test -n "$my_dlsyms"; then
4583f3561b8bSmrg      case $my_dlsyms in
4584f3561b8bSmrg      "") ;;
4585f3561b8bSmrg      *.c)
4586f3561b8bSmrg	# Discover the nlist of each of the dlfiles.
45876257f37dSmrg	nlist=$output_objdir/$my_outputname.nm
4588f3561b8bSmrg
4589f3561b8bSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
4590f3561b8bSmrg
4591f3561b8bSmrg	# Parse the name list into a source file.
4592f3561b8bSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
4593f3561b8bSmrg
4594f3561b8bSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
45956257f37dSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
45966257f37dSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
4597f3561b8bSmrg
4598f3561b8bSmrg#ifdef __cplusplus
4599f3561b8bSmrgextern \"C\" {
4600f3561b8bSmrg#endif
4601f3561b8bSmrg
46026257f37dSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
4603bd304fc0Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
4604bd304fc0Smrg#endif
4605bd304fc0Smrg
4606bd304fc0Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
46076257f37dSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
46086257f37dSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime
4609bd304fc0Smrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
4610bd304fc0Smrg# define LT_DLSYM_CONST
46116257f37dSmrg#elif defined __osf__
4612bd304fc0Smrg/* This system does not cope well with relocations in const data.  */
4613bd304fc0Smrg# define LT_DLSYM_CONST
4614bd304fc0Smrg#else
4615bd304fc0Smrg# define LT_DLSYM_CONST const
4616bd304fc0Smrg#endif
4617bd304fc0Smrg
46186257f37dSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
46196257f37dSmrg
4620f3561b8bSmrg/* External symbol declarations for the compiler. */\
4621f3561b8bSmrg"
4622f3561b8bSmrg
46236257f37dSmrg	if test yes = "$dlself"; then
46246257f37dSmrg	  func_verbose "generating symbol list for '$output'"
4625f3561b8bSmrg
4626f3561b8bSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
4627f3561b8bSmrg
4628f3561b8bSmrg	  # Add our own program objects to the symbol list.
4629bd304fc0Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
4630f3561b8bSmrg	  for progfile in $progfiles; do
4631bd304fc0Smrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
46326257f37dSmrg	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
4633bd304fc0Smrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
4634f3561b8bSmrg	  done
4635f3561b8bSmrg
4636f3561b8bSmrg	  if test -n "$exclude_expsyms"; then
4637f3561b8bSmrg	    $opt_dry_run || {
4638f3561b8bSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4639f3561b8bSmrg	      eval '$MV "$nlist"T "$nlist"'
4640f3561b8bSmrg	    }
4641fc5a983dSmrg	  fi
4642f3561b8bSmrg
4643f3561b8bSmrg	  if test -n "$export_symbols_regex"; then
4644f3561b8bSmrg	    $opt_dry_run || {
4645f3561b8bSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4646f3561b8bSmrg	      eval '$MV "$nlist"T "$nlist"'
4647f3561b8bSmrg	    }
4648f3561b8bSmrg	  fi
4649f3561b8bSmrg
4650f3561b8bSmrg	  # Prepare the list of exported symbols
4651f3561b8bSmrg	  if test -z "$export_symbols"; then
46526257f37dSmrg	    export_symbols=$output_objdir/$outputname.exp
4653f3561b8bSmrg	    $opt_dry_run || {
4654f3561b8bSmrg	      $RM $export_symbols
46556257f37dSmrg	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4656f3561b8bSmrg	      case $host in
4657f3561b8bSmrg	      *cygwin* | *mingw* | *cegcc* )
4658f3561b8bSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4659f3561b8bSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4660f3561b8bSmrg	        ;;
4661f3561b8bSmrg	      esac
4662f3561b8bSmrg	    }
4663fc5a983dSmrg	  else
4664f3561b8bSmrg	    $opt_dry_run || {
46656257f37dSmrg	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4666f3561b8bSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4667f3561b8bSmrg	      eval '$MV "$nlist"T "$nlist"'
4668f3561b8bSmrg	      case $host in
4669bd304fc0Smrg	        *cygwin* | *mingw* | *cegcc* )
4670f3561b8bSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4671f3561b8bSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4672f3561b8bSmrg	          ;;
4673f3561b8bSmrg	      esac
4674f3561b8bSmrg	    }
4675fc5a983dSmrg	  fi
4676f3561b8bSmrg	fi
4677fc5a983dSmrg
4678f3561b8bSmrg	for dlprefile in $dlprefiles; do
46796257f37dSmrg	  func_verbose "extracting global C symbols from '$dlprefile'"
4680f3561b8bSmrg	  func_basename "$dlprefile"
46816257f37dSmrg	  name=$func_basename_result
4682bd304fc0Smrg          case $host in
4683bd304fc0Smrg	    *cygwin* | *mingw* | *cegcc* )
4684bd304fc0Smrg	      # if an import library, we need to obtain dlname
4685bd304fc0Smrg	      if func_win32_import_lib_p "$dlprefile"; then
4686bd304fc0Smrg	        func_tr_sh "$dlprefile"
4687bd304fc0Smrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
46886257f37dSmrg	        dlprefile_dlbasename=
4689bd304fc0Smrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
4690bd304fc0Smrg	          # Use subshell, to avoid clobbering current variable values
4691bd304fc0Smrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
46926257f37dSmrg	          if test -n "$dlprefile_dlname"; then
4693bd304fc0Smrg	            func_basename "$dlprefile_dlname"
46946257f37dSmrg	            dlprefile_dlbasename=$func_basename_result
4695bd304fc0Smrg	          else
4696bd304fc0Smrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
4697bd304fc0Smrg	            $sharedlib_from_linklib_cmd "$dlprefile"
4698bd304fc0Smrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
4699bd304fc0Smrg	          fi
4700bd304fc0Smrg	        fi
4701bd304fc0Smrg	        $opt_dry_run || {
47026257f37dSmrg	          if test -n "$dlprefile_dlbasename"; then
4703bd304fc0Smrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
4704bd304fc0Smrg	          else
4705bd304fc0Smrg	            func_warning "Could not compute DLL name from $name"
4706bd304fc0Smrg	            eval '$ECHO ": $name " >> "$nlist"'
4707bd304fc0Smrg	          fi
4708bd304fc0Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4709bd304fc0Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
4710bd304fc0Smrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
4711bd304fc0Smrg	        }
4712bd304fc0Smrg	      else # not an import lib
4713bd304fc0Smrg	        $opt_dry_run || {
4714bd304fc0Smrg	          eval '$ECHO ": $name " >> "$nlist"'
4715bd304fc0Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4716bd304fc0Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4717bd304fc0Smrg	        }
4718bd304fc0Smrg	      fi
4719bd304fc0Smrg	    ;;
4720bd304fc0Smrg	    *)
4721bd304fc0Smrg	      $opt_dry_run || {
4722bd304fc0Smrg	        eval '$ECHO ": $name " >> "$nlist"'
4723bd304fc0Smrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4724bd304fc0Smrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4725bd304fc0Smrg	      }
4726bd304fc0Smrg	    ;;
4727bd304fc0Smrg          esac
4728f3561b8bSmrg	done
4729f3561b8bSmrg
4730f3561b8bSmrg	$opt_dry_run || {
4731f3561b8bSmrg	  # Make sure we have at least an empty file.
4732f3561b8bSmrg	  test -f "$nlist" || : > "$nlist"
4733f3561b8bSmrg
4734f3561b8bSmrg	  if test -n "$exclude_expsyms"; then
4735f3561b8bSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4736f3561b8bSmrg	    $MV "$nlist"T "$nlist"
4737fc5a983dSmrg	  fi
4738f3561b8bSmrg
4739f3561b8bSmrg	  # Try sorting and uniquifying the output.
4740f3561b8bSmrg	  if $GREP -v "^: " < "$nlist" |
4741f3561b8bSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
4742f3561b8bSmrg		sort -k 3
4743f3561b8bSmrg	      else
4744f3561b8bSmrg		sort +2
4745f3561b8bSmrg	      fi |
4746f3561b8bSmrg	      uniq > "$nlist"S; then
4747f3561b8bSmrg	    :
4748fc5a983dSmrg	  else
4749f3561b8bSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
4750fc5a983dSmrg	  fi
4751fc5a983dSmrg
4752f3561b8bSmrg	  if test -f "$nlist"S; then
4753f3561b8bSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
4754fc5a983dSmrg	  else
4755bd304fc0Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
4756fc5a983dSmrg	  fi
4757fc5a983dSmrg
47586257f37dSmrg	  func_show_eval '$RM "${nlist}I"'
47596257f37dSmrg	  if test -n "$global_symbol_to_import"; then
47606257f37dSmrg	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
47616257f37dSmrg	  fi
47626257f37dSmrg
4763bd304fc0Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
4764fc5a983dSmrg
4765f3561b8bSmrg/* The mapping between symbol names and symbols.  */
4766f3561b8bSmrgtypedef struct {
4767f3561b8bSmrg  const char *name;
4768f3561b8bSmrg  void *address;
4769f3561b8bSmrg} lt_dlsymlist;
4770bd304fc0Smrgextern LT_DLSYM_CONST lt_dlsymlist
47716257f37dSmrglt_${my_prefix}_LTX_preloaded_symbols[];\
47726257f37dSmrg"
47736257f37dSmrg
47746257f37dSmrg	  if test -s "$nlist"I; then
47756257f37dSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
47766257f37dSmrgstatic void lt_syminit(void)
47776257f37dSmrg{
47786257f37dSmrg  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
47796257f37dSmrg  for (; symbol->name; ++symbol)
47806257f37dSmrg    {"
47816257f37dSmrg	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
47826257f37dSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
47836257f37dSmrg    }
47846257f37dSmrg}"
47856257f37dSmrg	  fi
47866257f37dSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
4787bd304fc0SmrgLT_DLSYM_CONST lt_dlsymlist
4788f3561b8bSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
47896257f37dSmrg{ {\"$my_originator\", (void *) 0},"
47906257f37dSmrg
47916257f37dSmrg	  if test -s "$nlist"I; then
47926257f37dSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
47936257f37dSmrg  {\"@INIT@\", (void *) &lt_syminit},"
47946257f37dSmrg	  fi
4795fc5a983dSmrg
4796f3561b8bSmrg	  case $need_lib_prefix in
4797f3561b8bSmrg	  no)
4798f3561b8bSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
4799f3561b8bSmrg	    ;;
4800f3561b8bSmrg	  *)
4801f3561b8bSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
4802f3561b8bSmrg	    ;;
4803f3561b8bSmrg	  esac
4804bd304fc0Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
4805f3561b8bSmrg  {0, (void *) 0}
4806f3561b8bSmrg};
4807fc5a983dSmrg
4808f3561b8bSmrg/* This works around a problem in FreeBSD linker */
4809f3561b8bSmrg#ifdef FREEBSD_WORKAROUND
4810f3561b8bSmrgstatic const void *lt_preloaded_setup() {
4811f3561b8bSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
4812f3561b8bSmrg}
4813f3561b8bSmrg#endif
4814f3561b8bSmrg
4815f3561b8bSmrg#ifdef __cplusplus
4816f3561b8bSmrg}
4817f3561b8bSmrg#endif\
4818f3561b8bSmrg"
4819f3561b8bSmrg	} # !$opt_dry_run
4820f3561b8bSmrg
4821f3561b8bSmrg	pic_flag_for_symtable=
4822f3561b8bSmrg	case "$compile_command " in
4823f3561b8bSmrg	*" -static "*) ;;
4824f3561b8bSmrg	*)
4825f3561b8bSmrg	  case $host in
4826f3561b8bSmrg	  # compiling the symbol table file with pic_flag works around
4827f3561b8bSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
4828f3561b8bSmrg	  # linked before any other PIC object.  But we must not use
4829f3561b8bSmrg	  # pic_flag when linking with -static.  The problem exists in
4830f3561b8bSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4831bd304fc0Smrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4832f3561b8bSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
4833f3561b8bSmrg	  *-*-hpux*)
4834f3561b8bSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
4835f3561b8bSmrg	  *)
48366257f37dSmrg	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
4837f3561b8bSmrg	    ;;
4838f3561b8bSmrg	  esac
4839f3561b8bSmrg	  ;;
4840f3561b8bSmrg	esac
4841f3561b8bSmrg	symtab_cflags=
4842f3561b8bSmrg	for arg in $LTCFLAGS; do
4843f3561b8bSmrg	  case $arg in
4844f3561b8bSmrg	  -pie | -fpie | -fPIE) ;;
4845bd304fc0Smrg	  *) func_append symtab_cflags " $arg" ;;
4846f3561b8bSmrg	  esac
4847f3561b8bSmrg	done
4848fc5a983dSmrg
4849f3561b8bSmrg	# Now compile the dynamic symbol file.
4850f3561b8bSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
4851fc5a983dSmrg
4852f3561b8bSmrg	# Clean up the generated files.
48536257f37dSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
4854fc5a983dSmrg
4855f3561b8bSmrg	# Transform the symbol file into the correct name.
48566257f37dSmrg	symfileobj=$output_objdir/${my_outputname}S.$objext
4857f3561b8bSmrg	case $host in
4858f3561b8bSmrg	*cygwin* | *mingw* | *cegcc* )
4859f3561b8bSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
4860bd304fc0Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4861bd304fc0Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4862f3561b8bSmrg	  else
4863bd304fc0Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4864bd304fc0Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4865fc5a983dSmrg	  fi
4866f3561b8bSmrg	  ;;
4867f3561b8bSmrg	*)
4868bd304fc0Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4869bd304fc0Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4870f3561b8bSmrg	  ;;
4871f3561b8bSmrg	esac
4872f3561b8bSmrg	;;
4873f3561b8bSmrg      *)
48746257f37dSmrg	func_fatal_error "unknown suffix for '$my_dlsyms'"
4875f3561b8bSmrg	;;
4876f3561b8bSmrg      esac
4877f3561b8bSmrg    else
4878f3561b8bSmrg      # We keep going just in case the user didn't refer to
4879f3561b8bSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
4880f3561b8bSmrg      # really was required.
4881fc5a983dSmrg
4882f3561b8bSmrg      # Nullify the symbol file.
4883bd304fc0Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
4884bd304fc0Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
4885f3561b8bSmrg    fi
4886f3561b8bSmrg}
4887fc5a983dSmrg
48886257f37dSmrg# func_cygming_gnu_implib_p ARG
48896257f37dSmrg# This predicate returns with zero status (TRUE) if
48906257f37dSmrg# ARG is a GNU/binutils-style import library. Returns
48916257f37dSmrg# with nonzero status (FALSE) otherwise.
48926257f37dSmrgfunc_cygming_gnu_implib_p ()
48936257f37dSmrg{
48946257f37dSmrg  $debug_cmd
48956257f37dSmrg
48966257f37dSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
48976257f37dSmrg  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)$'`
48986257f37dSmrg  test -n "$func_cygming_gnu_implib_tmp"
48996257f37dSmrg}
49006257f37dSmrg
49016257f37dSmrg# func_cygming_ms_implib_p ARG
49026257f37dSmrg# This predicate returns with zero status (TRUE) if
49036257f37dSmrg# ARG is an MS-style import library. Returns
49046257f37dSmrg# with nonzero status (FALSE) otherwise.
49056257f37dSmrgfunc_cygming_ms_implib_p ()
49066257f37dSmrg{
49076257f37dSmrg  $debug_cmd
49086257f37dSmrg
49096257f37dSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
49106257f37dSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
49116257f37dSmrg  test -n "$func_cygming_ms_implib_tmp"
49126257f37dSmrg}
49136257f37dSmrg
4914f3561b8bSmrg# func_win32_libid arg
4915f3561b8bSmrg# return the library type of file 'arg'
4916f3561b8bSmrg#
4917f3561b8bSmrg# Need a lot of goo to handle *both* DLLs and import libs
4918f3561b8bSmrg# Has to be a shell function in order to 'eat' the argument
4919f3561b8bSmrg# that is supplied when $file_magic_command is called.
4920bd304fc0Smrg# Despite the name, also deal with 64 bit binaries.
4921f3561b8bSmrgfunc_win32_libid ()
4922f3561b8bSmrg{
49236257f37dSmrg  $debug_cmd
49246257f37dSmrg
49256257f37dSmrg  win32_libid_type=unknown
4926f3561b8bSmrg  win32_fileres=`file -L $1 2>/dev/null`
4927f3561b8bSmrg  case $win32_fileres in
4928f3561b8bSmrg  *ar\ archive\ import\ library*) # definitely import
4929f3561b8bSmrg    win32_libid_type="x86 archive import"
4930f3561b8bSmrg    ;;
4931f3561b8bSmrg  *ar\ archive*) # could be an import, or static
4932bd304fc0Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
4933f3561b8bSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
4934bd304fc0Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
49356257f37dSmrg      case $nm_interface in
49366257f37dSmrg      "MS dumpbin")
49376257f37dSmrg	if func_cygming_ms_implib_p "$1" ||
49386257f37dSmrg	   func_cygming_gnu_implib_p "$1"
49396257f37dSmrg	then
49406257f37dSmrg	  win32_nmres=import
49416257f37dSmrg	else
49426257f37dSmrg	  win32_nmres=
49436257f37dSmrg	fi
49446257f37dSmrg	;;
49456257f37dSmrg      *)
49466257f37dSmrg	func_to_tool_file "$1" func_convert_file_msys_to_w32
49476257f37dSmrg	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
49486257f37dSmrg	  $SED -n -e '
4949f3561b8bSmrg	    1,100{
4950f3561b8bSmrg		/ I /{
49516257f37dSmrg		    s|.*|import|
4952f3561b8bSmrg		    p
4953f3561b8bSmrg		    q
4954f3561b8bSmrg		}
4955f3561b8bSmrg	    }'`
49566257f37dSmrg	;;
49576257f37dSmrg      esac
4958f3561b8bSmrg      case $win32_nmres in
4959f3561b8bSmrg      import*)  win32_libid_type="x86 archive import";;
4960f3561b8bSmrg      *)        win32_libid_type="x86 archive static";;
4961f3561b8bSmrg      esac
4962f3561b8bSmrg    fi
4963f3561b8bSmrg    ;;
4964f3561b8bSmrg  *DLL*)
4965f3561b8bSmrg    win32_libid_type="x86 DLL"
4966f3561b8bSmrg    ;;
4967f3561b8bSmrg  *executable*) # but shell scripts are "executable" too...
4968f3561b8bSmrg    case $win32_fileres in
4969f3561b8bSmrg    *MS\ Windows\ PE\ Intel*)
4970f3561b8bSmrg      win32_libid_type="x86 DLL"
4971f3561b8bSmrg      ;;
4972f3561b8bSmrg    esac
4973f3561b8bSmrg    ;;
4974f3561b8bSmrg  esac
4975f3561b8bSmrg  $ECHO "$win32_libid_type"
4976f3561b8bSmrg}
4977fc5a983dSmrg
4978bd304fc0Smrg# func_cygming_dll_for_implib ARG
4979bd304fc0Smrg#
4980bd304fc0Smrg# Platform-specific function to extract the
4981bd304fc0Smrg# name of the DLL associated with the specified
4982bd304fc0Smrg# import library ARG.
4983bd304fc0Smrg# Invoked by eval'ing the libtool variable
4984bd304fc0Smrg#    $sharedlib_from_linklib_cmd
4985bd304fc0Smrg# Result is available in the variable
4986bd304fc0Smrg#    $sharedlib_from_linklib_result
4987bd304fc0Smrgfunc_cygming_dll_for_implib ()
4988bd304fc0Smrg{
49896257f37dSmrg  $debug_cmd
49906257f37dSmrg
4991bd304fc0Smrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
4992bd304fc0Smrg}
4993bd304fc0Smrg
4994bd304fc0Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
4995bd304fc0Smrg#
4996bd304fc0Smrg# The is the core of a fallback implementation of a
4997bd304fc0Smrg# platform-specific function to extract the name of the
4998bd304fc0Smrg# DLL associated with the specified import library LIBNAME.
4999bd304fc0Smrg#
5000bd304fc0Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending
5001bd304fc0Smrg# on the platform and compiler that created the implib.
5002bd304fc0Smrg#
5003bd304fc0Smrg# Echos the name of the DLL associated with the
5004bd304fc0Smrg# specified import library.
5005bd304fc0Smrgfunc_cygming_dll_for_implib_fallback_core ()
5006bd304fc0Smrg{
50076257f37dSmrg  $debug_cmd
50086257f37dSmrg
5009bd304fc0Smrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
5010bd304fc0Smrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
5011bd304fc0Smrg    $SED '/^Contents of section '"$match_literal"':/{
5012bd304fc0Smrg      # Place marker at beginning of archive member dllname section
5013bd304fc0Smrg      s/.*/====MARK====/
5014bd304fc0Smrg      p
5015bd304fc0Smrg      d
5016bd304fc0Smrg    }
5017bd304fc0Smrg    # These lines can sometimes be longer than 43 characters, but
5018bd304fc0Smrg    # are always uninteresting
5019bd304fc0Smrg    /:[	 ]*file format pe[i]\{,1\}-/d
5020bd304fc0Smrg    /^In archive [^:]*:/d
5021bd304fc0Smrg    # Ensure marker is printed
5022bd304fc0Smrg    /^====MARK====/p
5023bd304fc0Smrg    # Remove all lines with less than 43 characters
5024bd304fc0Smrg    /^.\{43\}/!d
5025bd304fc0Smrg    # From remaining lines, remove first 43 characters
5026bd304fc0Smrg    s/^.\{43\}//' |
5027bd304fc0Smrg    $SED -n '
5028bd304fc0Smrg      # Join marker and all lines until next marker into a single line
5029bd304fc0Smrg      /^====MARK====/ b para
5030bd304fc0Smrg      H
5031bd304fc0Smrg      $ b para
5032bd304fc0Smrg      b
5033bd304fc0Smrg      :para
5034bd304fc0Smrg      x
5035bd304fc0Smrg      s/\n//g
5036bd304fc0Smrg      # Remove the marker
5037bd304fc0Smrg      s/^====MARK====//
5038bd304fc0Smrg      # Remove trailing dots and whitespace
5039bd304fc0Smrg      s/[\. \t]*$//
5040bd304fc0Smrg      # Print
5041bd304fc0Smrg      /./p' |
5042bd304fc0Smrg    # we now have a list, one entry per line, of the stringified
5043bd304fc0Smrg    # contents of the appropriate section of all members of the
50446257f37dSmrg    # archive that possess that section. Heuristic: eliminate
50456257f37dSmrg    # all those that have a first or second character that is
5046bd304fc0Smrg    # a '.' (that is, objdump's representation of an unprintable
5047bd304fc0Smrg    # character.) This should work for all archives with less than
5048bd304fc0Smrg    # 0x302f exports -- but will fail for DLLs whose name actually
5049bd304fc0Smrg    # begins with a literal '.' or a single character followed by
5050bd304fc0Smrg    # a '.'.
5051bd304fc0Smrg    #
5052bd304fc0Smrg    # Of those that remain, print the first one.
5053bd304fc0Smrg    $SED -e '/^\./d;/^.\./d;q'
5054bd304fc0Smrg}
5055bd304fc0Smrg
5056bd304fc0Smrg# func_cygming_dll_for_implib_fallback ARG
5057bd304fc0Smrg# Platform-specific function to extract the
5058bd304fc0Smrg# name of the DLL associated with the specified
5059bd304fc0Smrg# import library ARG.
5060bd304fc0Smrg#
5061bd304fc0Smrg# This fallback implementation is for use when $DLLTOOL
5062bd304fc0Smrg# does not support the --identify-strict option.
5063bd304fc0Smrg# Invoked by eval'ing the libtool variable
5064bd304fc0Smrg#    $sharedlib_from_linklib_cmd
5065bd304fc0Smrg# Result is available in the variable
5066bd304fc0Smrg#    $sharedlib_from_linklib_result
5067bd304fc0Smrgfunc_cygming_dll_for_implib_fallback ()
5068bd304fc0Smrg{
50696257f37dSmrg  $debug_cmd
50706257f37dSmrg
50716257f37dSmrg  if func_cygming_gnu_implib_p "$1"; then
5072bd304fc0Smrg    # binutils import library
5073bd304fc0Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
50746257f37dSmrg  elif func_cygming_ms_implib_p "$1"; then
5075bd304fc0Smrg    # ms-generated import library
5076bd304fc0Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
5077bd304fc0Smrg  else
5078bd304fc0Smrg    # unknown
50796257f37dSmrg    sharedlib_from_linklib_result=
5080bd304fc0Smrg  fi
5081bd304fc0Smrg}
5082fc5a983dSmrg
5083fc5a983dSmrg
5084f3561b8bSmrg# func_extract_an_archive dir oldlib
5085f3561b8bSmrgfunc_extract_an_archive ()
5086f3561b8bSmrg{
50876257f37dSmrg    $debug_cmd
50886257f37dSmrg
50896257f37dSmrg    f_ex_an_ar_dir=$1; shift
50906257f37dSmrg    f_ex_an_ar_oldlib=$1
50916257f37dSmrg    if test yes = "$lock_old_archive_extraction"; then
5092bd304fc0Smrg      lockfile=$f_ex_an_ar_oldlib.lock
5093bd304fc0Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
5094bd304fc0Smrg	func_echo "Waiting for $lockfile to be removed"
5095bd304fc0Smrg	sleep 2
5096bd304fc0Smrg      done
5097bd304fc0Smrg    fi
5098bd304fc0Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
5099bd304fc0Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
51006257f37dSmrg    if test yes = "$lock_old_archive_extraction"; then
5101bd304fc0Smrg      $opt_dry_run || rm -f "$lockfile"
5102bd304fc0Smrg    fi
5103f3561b8bSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
5104f3561b8bSmrg     :
5105f3561b8bSmrg    else
5106f3561b8bSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
5107f3561b8bSmrg    fi
5108f3561b8bSmrg}
5109fc5a983dSmrg
5110fc5a983dSmrg
5111f3561b8bSmrg# func_extract_archives gentop oldlib ...
5112f3561b8bSmrgfunc_extract_archives ()
5113f3561b8bSmrg{
51146257f37dSmrg    $debug_cmd
51156257f37dSmrg
51166257f37dSmrg    my_gentop=$1; shift
5117f3561b8bSmrg    my_oldlibs=${1+"$@"}
51186257f37dSmrg    my_oldobjs=
51196257f37dSmrg    my_xlib=
51206257f37dSmrg    my_xabs=
51216257f37dSmrg    my_xdir=
5122fc5a983dSmrg
5123f3561b8bSmrg    for my_xlib in $my_oldlibs; do
5124f3561b8bSmrg      # Extract the objects.
5125f3561b8bSmrg      case $my_xlib in
51266257f37dSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
5127f3561b8bSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
5128f3561b8bSmrg      esac
5129f3561b8bSmrg      func_basename "$my_xlib"
51306257f37dSmrg      my_xlib=$func_basename_result
5131f3561b8bSmrg      my_xlib_u=$my_xlib
5132f3561b8bSmrg      while :; do
5133f3561b8bSmrg        case " $extracted_archives " in
5134f3561b8bSmrg	*" $my_xlib_u "*)
5135f3561b8bSmrg	  func_arith $extracted_serial + 1
5136f3561b8bSmrg	  extracted_serial=$func_arith_result
5137f3561b8bSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
5138f3561b8bSmrg	*) break ;;
5139f3561b8bSmrg	esac
5140f3561b8bSmrg      done
5141f3561b8bSmrg      extracted_archives="$extracted_archives $my_xlib_u"
51426257f37dSmrg      my_xdir=$my_gentop/$my_xlib_u
5143fc5a983dSmrg
5144f3561b8bSmrg      func_mkdir_p "$my_xdir"
5145fc5a983dSmrg
5146f3561b8bSmrg      case $host in
5147f3561b8bSmrg      *-darwin*)
5148f3561b8bSmrg	func_verbose "Extracting $my_xabs"
5149f3561b8bSmrg	# Do not bother doing anything if just a dry run
5150f3561b8bSmrg	$opt_dry_run || {
5151f3561b8bSmrg	  darwin_orig_dir=`pwd`
5152f3561b8bSmrg	  cd $my_xdir || exit $?
5153f3561b8bSmrg	  darwin_archive=$my_xabs
5154f3561b8bSmrg	  darwin_curdir=`pwd`
51556257f37dSmrg	  func_basename "$darwin_archive"
51566257f37dSmrg	  darwin_base_archive=$func_basename_result
5157f3561b8bSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
5158f3561b8bSmrg	  if test -n "$darwin_arches"; then
5159f3561b8bSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
5160f3561b8bSmrg	    darwin_arch=
5161f3561b8bSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
51626257f37dSmrg	    for darwin_arch in  $darwin_arches; do
51636257f37dSmrg	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
51646257f37dSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
51656257f37dSmrg	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
51666257f37dSmrg	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
5167f3561b8bSmrg	      cd "$darwin_curdir"
51686257f37dSmrg	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
5169f3561b8bSmrg	    done # $darwin_arches
5170f3561b8bSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
51716257f37dSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
5172f3561b8bSmrg	    darwin_file=
5173f3561b8bSmrg	    darwin_files=
5174f3561b8bSmrg	    for darwin_file in $darwin_filelist; do
5175bd304fc0Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
5176f3561b8bSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
5177f3561b8bSmrg	    done # $darwin_filelist
5178f3561b8bSmrg	    $RM -rf unfat-$$
5179f3561b8bSmrg	    cd "$darwin_orig_dir"
5180fc5a983dSmrg	  else
5181f3561b8bSmrg	    cd $darwin_orig_dir
5182f3561b8bSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
5183f3561b8bSmrg	  fi # $darwin_arches
5184f3561b8bSmrg	} # !$opt_dry_run
5185f3561b8bSmrg	;;
5186f3561b8bSmrg      *)
5187f3561b8bSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
5188f3561b8bSmrg	;;
5189f3561b8bSmrg      esac
5190bd304fc0Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
5191f3561b8bSmrg    done
5192fc5a983dSmrg
51936257f37dSmrg    func_extract_archives_result=$my_oldobjs
5194f3561b8bSmrg}
5195fc5a983dSmrg
5196fc5a983dSmrg
5197bd304fc0Smrg# func_emit_wrapper [arg=no]
5198bd304fc0Smrg#
5199bd304fc0Smrg# Emit a libtool wrapper script on stdout.
5200bd304fc0Smrg# Don't directly open a file because we may want to
5201bd304fc0Smrg# incorporate the script contents within a cygwin/mingw
5202bd304fc0Smrg# wrapper executable.  Must ONLY be called from within
5203bd304fc0Smrg# func_mode_link because it depends on a number of variables
5204bd304fc0Smrg# set therein.
5205f3561b8bSmrg#
5206bd304fc0Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
5207bd304fc0Smrg# variable will take.  If 'yes', then the emitted script
52086257f37dSmrg# will assume that the directory where it is stored is
5209bd304fc0Smrg# the $objdir directory.  This is a cygwin/mingw-specific
5210bd304fc0Smrg# behavior.
5211bd304fc0Smrgfunc_emit_wrapper ()
5212f3561b8bSmrg{
5213bd304fc0Smrg	func_emit_wrapper_arg1=${1-no}
5214fc5a983dSmrg
5215f3561b8bSmrg	$ECHO "\
5216f3561b8bSmrg#! $SHELL
5217fc5a983dSmrg
5218f3561b8bSmrg# $output - temporary wrapper script for $objdir/$outputname
52196257f37dSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5220f3561b8bSmrg#
5221f3561b8bSmrg# The $output program cannot be directly executed until all the libtool
5222f3561b8bSmrg# libraries that it depends on are installed.
5223f3561b8bSmrg#
5224f3561b8bSmrg# This wrapper script should never be moved out of the build directory.
5225f3561b8bSmrg# If it is, it will not operate correctly.
5226fc5a983dSmrg
5227f3561b8bSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
5228f3561b8bSmrg# metacharacters that are still active within double-quoted strings.
5229f3561b8bSmrgsed_quote_subst='$sed_quote_subst'
5230fc5a983dSmrg
5231f3561b8bSmrg# Be Bourne compatible
5232f3561b8bSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5233f3561b8bSmrg  emulate sh
5234f3561b8bSmrg  NULLCMD=:
5235f3561b8bSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5236f3561b8bSmrg  # is contrary to our usage.  Disable this feature.
5237f3561b8bSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
5238f3561b8bSmrg  setopt NO_GLOB_SUBST
5239f3561b8bSmrgelse
5240f3561b8bSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5241f3561b8bSmrgfi
5242f3561b8bSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
5243f3561b8bSmrgDUALCASE=1; export DUALCASE # for MKS sh
5244fc5a983dSmrg
5245f3561b8bSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
5246f3561b8bSmrg# if CDPATH is set.
5247f3561b8bSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5248fc5a983dSmrg
5249f3561b8bSmrgrelink_command=\"$relink_command\"
5250fc5a983dSmrg
5251f3561b8bSmrg# This environment variable determines our operation mode.
5252f3561b8bSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
5253f3561b8bSmrg  # install mode needs the following variables:
5254f3561b8bSmrg  generated_by_libtool_version='$macro_version'
5255f3561b8bSmrg  notinst_deplibs='$notinst_deplibs'
5256f3561b8bSmrgelse
5257f3561b8bSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
5258f3561b8bSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
5259bd304fc0Smrg    file=\"\$0\""
5260bd304fc0Smrg
5261bd304fc0Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
5262bd304fc0Smrg    $ECHO "\
5263bd304fc0Smrg
5264bd304fc0Smrg# A function that is used when there is no print builtin or printf.
5265bd304fc0Smrgfunc_fallback_echo ()
5266bd304fc0Smrg{
5267bd304fc0Smrg  eval 'cat <<_LTECHO_EOF
5268bd304fc0Smrg\$1
5269bd304fc0Smrg_LTECHO_EOF'
5270bd304fc0Smrg}
5271bd304fc0Smrg    ECHO=\"$qECHO\"
5272bd304fc0Smrg  fi
5273bd304fc0Smrg
5274bd304fc0Smrg# Very basic option parsing. These options are (a) specific to
5275bd304fc0Smrg# the libtool wrapper, (b) are identical between the wrapper
52766257f37dSmrg# /script/ and the wrapper /executable/ that is used only on
5277bd304fc0Smrg# windows platforms, and (c) all begin with the string "--lt-"
52786257f37dSmrg# (application programs are unlikely to have options that match
5279bd304fc0Smrg# this pattern).
5280bd304fc0Smrg#
5281bd304fc0Smrg# There are only two supported options: --lt-debug and
5282bd304fc0Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
5283bd304fc0Smrg#
5284bd304fc0Smrg# The first argument to this parsing function should be the
5285bd304fc0Smrg# script's $0 value, followed by "$@".
5286bd304fc0Smrglt_option_debug=
5287bd304fc0Smrgfunc_parse_lt_options ()
5288bd304fc0Smrg{
5289bd304fc0Smrg  lt_script_arg0=\$0
5290bd304fc0Smrg  shift
5291bd304fc0Smrg  for lt_opt
5292bd304fc0Smrg  do
5293bd304fc0Smrg    case \"\$lt_opt\" in
5294bd304fc0Smrg    --lt-debug) lt_option_debug=1 ;;
5295bd304fc0Smrg    --lt-dump-script)
5296bd304fc0Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
5297bd304fc0Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
5298bd304fc0Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
5299bd304fc0Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
5300bd304fc0Smrg        exit 0
5301bd304fc0Smrg      ;;
5302bd304fc0Smrg    --lt-*)
5303bd304fc0Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
5304bd304fc0Smrg        exit 1
5305bd304fc0Smrg      ;;
5306bd304fc0Smrg    esac
5307bd304fc0Smrg  done
5308bd304fc0Smrg
5309bd304fc0Smrg  # Print the debug banner immediately:
5310bd304fc0Smrg  if test -n \"\$lt_option_debug\"; then
53116257f37dSmrg    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
5312bd304fc0Smrg  fi
5313bd304fc0Smrg}
5314bd304fc0Smrg
5315bd304fc0Smrg# Used when --lt-debug. Prints its arguments to stdout
5316bd304fc0Smrg# (redirection is the responsibility of the caller)
5317bd304fc0Smrgfunc_lt_dump_args ()
5318bd304fc0Smrg{
5319bd304fc0Smrg  lt_dump_args_N=1;
5320bd304fc0Smrg  for lt_arg
5321bd304fc0Smrg  do
53226257f37dSmrg    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
5323bd304fc0Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
5324bd304fc0Smrg  done
5325bd304fc0Smrg}
5326bd304fc0Smrg
5327bd304fc0Smrg# Core function for launching the target application
5328bd304fc0Smrgfunc_exec_program_core ()
5329bd304fc0Smrg{
5330f3561b8bSmrg"
5331bd304fc0Smrg  case $host in
5332bd304fc0Smrg  # Backslashes separate directories on plain windows
5333bd304fc0Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
5334bd304fc0Smrg    $ECHO "\
5335bd304fc0Smrg      if test -n \"\$lt_option_debug\"; then
53366257f37dSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
5337bd304fc0Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5338bd304fc0Smrg      fi
5339bd304fc0Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5340bd304fc0Smrg"
5341bd304fc0Smrg    ;;
5342bd304fc0Smrg
5343bd304fc0Smrg  *)
5344bd304fc0Smrg    $ECHO "\
5345bd304fc0Smrg      if test -n \"\$lt_option_debug\"; then
53466257f37dSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
5347bd304fc0Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5348bd304fc0Smrg      fi
5349bd304fc0Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
5350bd304fc0Smrg"
5351bd304fc0Smrg    ;;
5352bd304fc0Smrg  esac
5353bd304fc0Smrg  $ECHO "\
5354bd304fc0Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
5355bd304fc0Smrg      exit 1
5356bd304fc0Smrg}
5357bd304fc0Smrg
5358bd304fc0Smrg# A function to encapsulate launching the target application
5359bd304fc0Smrg# Strips options in the --lt-* namespace from \$@ and
5360bd304fc0Smrg# launches target application with the remaining arguments.
5361bd304fc0Smrgfunc_exec_program ()
5362bd304fc0Smrg{
5363bd304fc0Smrg  case \" \$* \" in
5364bd304fc0Smrg  *\\ --lt-*)
5365bd304fc0Smrg    for lt_wr_arg
5366bd304fc0Smrg    do
5367bd304fc0Smrg      case \$lt_wr_arg in
5368bd304fc0Smrg      --lt-*) ;;
5369bd304fc0Smrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
5370bd304fc0Smrg      esac
5371bd304fc0Smrg      shift
5372bd304fc0Smrg    done ;;
5373bd304fc0Smrg  esac
5374bd304fc0Smrg  func_exec_program_core \${1+\"\$@\"}
5375bd304fc0Smrg}
5376bd304fc0Smrg
5377bd304fc0Smrg  # Parse options
5378bd304fc0Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
5379fc5a983dSmrg
5380f3561b8bSmrg  # Find the directory that this script lives in.
5381bd304fc0Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
5382f3561b8bSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
5383fc5a983dSmrg
5384f3561b8bSmrg  # Follow symbolic links until we get to the real thisdir.
5385bd304fc0Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
5386f3561b8bSmrg  while test -n \"\$file\"; do
5387bd304fc0Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
5388fc5a983dSmrg
5389f3561b8bSmrg    # If there was a directory component, then change thisdir.
5390f3561b8bSmrg    if test \"x\$destdir\" != \"x\$file\"; then
5391f3561b8bSmrg      case \"\$destdir\" in
5392f3561b8bSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5393f3561b8bSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
5394fc5a983dSmrg      esac
5395f3561b8bSmrg    fi
5396fc5a983dSmrg
5397bd304fc0Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
5398bd304fc0Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
5399f3561b8bSmrg  done
5400fc5a983dSmrg
5401f3561b8bSmrg  # Usually 'no', except on cygwin/mingw when embedded into
5402f3561b8bSmrg  # the cwrapper.
5403bd304fc0Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
5404f3561b8bSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
5405f3561b8bSmrg    # special case for '.'
5406f3561b8bSmrg    if test \"\$thisdir\" = \".\"; then
5407f3561b8bSmrg      thisdir=\`pwd\`
5408f3561b8bSmrg    fi
5409f3561b8bSmrg    # remove .libs from thisdir
5410f3561b8bSmrg    case \"\$thisdir\" in
5411bd304fc0Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
5412f3561b8bSmrg    $objdir )   thisdir=. ;;
5413f3561b8bSmrg    esac
5414f3561b8bSmrg  fi
5415f3561b8bSmrg
5416f3561b8bSmrg  # Try to get the absolute directory name.
5417f3561b8bSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
5418f3561b8bSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
5419f3561b8bSmrg"
5420f3561b8bSmrg
54216257f37dSmrg	if test yes = "$fast_install"; then
5422f3561b8bSmrg	  $ECHO "\
5423f3561b8bSmrg  program=lt-'$outputname'$exeext
5424f3561b8bSmrg  progdir=\"\$thisdir/$objdir\"
5425f3561b8bSmrg
5426f3561b8bSmrg  if test ! -f \"\$progdir/\$program\" ||
54276257f37dSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
5428f3561b8bSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
5429f3561b8bSmrg
5430f3561b8bSmrg    file=\"\$\$-\$program\"
5431f3561b8bSmrg
5432f3561b8bSmrg    if test ! -d \"\$progdir\"; then
5433f3561b8bSmrg      $MKDIR \"\$progdir\"
5434f3561b8bSmrg    else
5435f3561b8bSmrg      $RM \"\$progdir/\$file\"
5436f3561b8bSmrg    fi"
5437f3561b8bSmrg
5438f3561b8bSmrg	  $ECHO "\
5439f3561b8bSmrg
5440f3561b8bSmrg    # relink executable if necessary
5441f3561b8bSmrg    if test -n \"\$relink_command\"; then
5442f3561b8bSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5443f3561b8bSmrg      else
54446257f37dSmrg	\$ECHO \"\$relink_command_output\" >&2
5445f3561b8bSmrg	$RM \"\$progdir/\$file\"
5446f3561b8bSmrg	exit 1
5447fc5a983dSmrg      fi
5448f3561b8bSmrg    fi
5449fc5a983dSmrg
5450f3561b8bSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5451f3561b8bSmrg    { $RM \"\$progdir/\$program\";
5452f3561b8bSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5453f3561b8bSmrg    $RM \"\$progdir/\$file\"
5454f3561b8bSmrg  fi"
5455f3561b8bSmrg	else
5456f3561b8bSmrg	  $ECHO "\
5457f3561b8bSmrg  program='$outputname'
5458f3561b8bSmrg  progdir=\"\$thisdir/$objdir\"
5459f3561b8bSmrg"
5460fc5a983dSmrg	fi
5461fc5a983dSmrg
5462f3561b8bSmrg	$ECHO "\
5463fc5a983dSmrg
5464f3561b8bSmrg  if test -f \"\$progdir/\$program\"; then"
5465fc5a983dSmrg
5466bd304fc0Smrg	# fixup the dll searchpath if we need to.
5467bd304fc0Smrg	#
5468bd304fc0Smrg	# Fix the DLL searchpath if we need to.  Do this before prepending
5469bd304fc0Smrg	# to shlibpath, because on Windows, both are PATH and uninstalled
5470bd304fc0Smrg	# libraries must come first.
5471bd304fc0Smrg	if test -n "$dllsearchpath"; then
5472bd304fc0Smrg	  $ECHO "\
5473bd304fc0Smrg    # Add the dll search path components to the executable PATH
5474bd304fc0Smrg    PATH=$dllsearchpath:\$PATH
5475bd304fc0Smrg"
5476bd304fc0Smrg	fi
5477bd304fc0Smrg
5478f3561b8bSmrg	# Export our shlibpath_var if we have one.
54796257f37dSmrg	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5480f3561b8bSmrg	  $ECHO "\
5481f3561b8bSmrg    # Add our own library path to $shlibpath_var
5482f3561b8bSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
5483f3561b8bSmrg
5484f3561b8bSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
5485f3561b8bSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
5486bd304fc0Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
5487fc5a983dSmrg
5488f3561b8bSmrg    export $shlibpath_var
5489f3561b8bSmrg"
5490fc5a983dSmrg	fi
5491fc5a983dSmrg
5492f3561b8bSmrg	$ECHO "\
5493f3561b8bSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
5494f3561b8bSmrg      # Run the actual program with our arguments.
5495bd304fc0Smrg      func_exec_program \${1+\"\$@\"}
5496f3561b8bSmrg    fi
5497f3561b8bSmrg  else
5498f3561b8bSmrg    # The program doesn't exist.
54996257f37dSmrg    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
5500f3561b8bSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
5501bd304fc0Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
5502f3561b8bSmrg    exit 1
5503f3561b8bSmrg  fi
5504f3561b8bSmrgfi\
5505f3561b8bSmrg"
5506f3561b8bSmrg}
5507fc5a983dSmrg
5508fc5a983dSmrg
5509f3561b8bSmrg# func_emit_cwrapperexe_src
5510f3561b8bSmrg# emit the source code for a wrapper executable on stdout
5511f3561b8bSmrg# Must ONLY be called from within func_mode_link because
5512f3561b8bSmrg# it depends on a number of variable set therein.
5513f3561b8bSmrgfunc_emit_cwrapperexe_src ()
5514f3561b8bSmrg{
5515f3561b8bSmrg	cat <<EOF
5516fc5a983dSmrg
5517f3561b8bSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
55186257f37dSmrg   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5519fc5a983dSmrg
5520f3561b8bSmrg   The $output program cannot be directly executed until all the libtool
5521f3561b8bSmrg   libraries that it depends on are installed.
5522fc5a983dSmrg
5523f3561b8bSmrg   This wrapper executable should never be moved out of the build directory.
5524f3561b8bSmrg   If it is, it will not operate correctly.
5525f3561b8bSmrg*/
5526f3561b8bSmrgEOF
5527f3561b8bSmrg	    cat <<"EOF"
5528bd304fc0Smrg#ifdef _MSC_VER
5529bd304fc0Smrg# define _CRT_SECURE_NO_DEPRECATE 1
5530bd304fc0Smrg#endif
5531f3561b8bSmrg#include <stdio.h>
5532f3561b8bSmrg#include <stdlib.h>
5533f3561b8bSmrg#ifdef _MSC_VER
5534f3561b8bSmrg# include <direct.h>
5535f3561b8bSmrg# include <process.h>
5536f3561b8bSmrg# include <io.h>
5537f3561b8bSmrg#else
5538f3561b8bSmrg# include <unistd.h>
5539f3561b8bSmrg# include <stdint.h>
5540f3561b8bSmrg# ifdef __CYGWIN__
5541f3561b8bSmrg#  include <io.h>
5542f3561b8bSmrg# endif
5543f3561b8bSmrg#endif
5544f3561b8bSmrg#include <malloc.h>
5545f3561b8bSmrg#include <stdarg.h>
5546f3561b8bSmrg#include <assert.h>
5547f3561b8bSmrg#include <string.h>
5548f3561b8bSmrg#include <ctype.h>
5549f3561b8bSmrg#include <errno.h>
5550f3561b8bSmrg#include <fcntl.h>
5551f3561b8bSmrg#include <sys/stat.h>
5552fc5a983dSmrg
55536257f37dSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
55546257f37dSmrg
5555bd304fc0Smrg/* declarations of non-ANSI functions */
55566257f37dSmrg#if defined __MINGW32__
5557bd304fc0Smrg# ifdef __STRICT_ANSI__
5558bd304fc0Smrgint _putenv (const char *);
5559bd304fc0Smrg# endif
55606257f37dSmrg#elif defined __CYGWIN__
5561bd304fc0Smrg# ifdef __STRICT_ANSI__
5562bd304fc0Smrgchar *realpath (const char *, char *);
5563bd304fc0Smrgint putenv (char *);
5564bd304fc0Smrgint setenv (const char *, const char *, int);
5565bd304fc0Smrg# endif
55666257f37dSmrg/* #elif defined other_platform || defined ... */
5567bd304fc0Smrg#endif
5568bd304fc0Smrg
5569bd304fc0Smrg/* portability defines, excluding path handling macros */
55706257f37dSmrg#if defined _MSC_VER
5571bd304fc0Smrg# define setmode _setmode
5572bd304fc0Smrg# define stat    _stat
5573bd304fc0Smrg# define chmod   _chmod
5574bd304fc0Smrg# define getcwd  _getcwd
5575bd304fc0Smrg# define putenv  _putenv
5576bd304fc0Smrg# define S_IXUSR _S_IEXEC
55776257f37dSmrg#elif defined __MINGW32__
5578bd304fc0Smrg# define setmode _setmode
5579bd304fc0Smrg# define stat    _stat
5580bd304fc0Smrg# define chmod   _chmod
5581bd304fc0Smrg# define getcwd  _getcwd
5582bd304fc0Smrg# define putenv  _putenv
55836257f37dSmrg#elif defined __CYGWIN__
5584bd304fc0Smrg# define HAVE_SETENV
5585bd304fc0Smrg# define FOPEN_WB "wb"
55866257f37dSmrg/* #elif defined other platforms ... */
5587bd304fc0Smrg#endif
5588bd304fc0Smrg
55896257f37dSmrg#if defined PATH_MAX
5590f3561b8bSmrg# define LT_PATHMAX PATH_MAX
55916257f37dSmrg#elif defined MAXPATHLEN
5592f3561b8bSmrg# define LT_PATHMAX MAXPATHLEN
5593f3561b8bSmrg#else
5594f3561b8bSmrg# define LT_PATHMAX 1024
5595f3561b8bSmrg#endif
5596fc5a983dSmrg
5597f3561b8bSmrg#ifndef S_IXOTH
5598f3561b8bSmrg# define S_IXOTH 0
5599f3561b8bSmrg#endif
5600f3561b8bSmrg#ifndef S_IXGRP
5601f3561b8bSmrg# define S_IXGRP 0
5602f3561b8bSmrg#endif
5603fc5a983dSmrg
5604bd304fc0Smrg/* path handling portability macros */
5605f3561b8bSmrg#ifndef DIR_SEPARATOR
5606f3561b8bSmrg# define DIR_SEPARATOR '/'
5607f3561b8bSmrg# define PATH_SEPARATOR ':'
5608f3561b8bSmrg#endif
5609fc5a983dSmrg
56106257f37dSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
56116257f37dSmrg  defined __OS2__
5612f3561b8bSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
5613f3561b8bSmrg# define FOPEN_WB "wb"
5614f3561b8bSmrg# ifndef DIR_SEPARATOR_2
5615f3561b8bSmrg#  define DIR_SEPARATOR_2 '\\'
5616f3561b8bSmrg# endif
5617f3561b8bSmrg# ifndef PATH_SEPARATOR_2
5618f3561b8bSmrg#  define PATH_SEPARATOR_2 ';'
5619f3561b8bSmrg# endif
5620f3561b8bSmrg#endif
5621fc5a983dSmrg
5622f3561b8bSmrg#ifndef DIR_SEPARATOR_2
5623f3561b8bSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
5624f3561b8bSmrg#else /* DIR_SEPARATOR_2 */
5625f3561b8bSmrg# define IS_DIR_SEPARATOR(ch) \
5626f3561b8bSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
5627f3561b8bSmrg#endif /* DIR_SEPARATOR_2 */
5628fc5a983dSmrg
5629f3561b8bSmrg#ifndef PATH_SEPARATOR_2
5630f3561b8bSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5631f3561b8bSmrg#else /* PATH_SEPARATOR_2 */
5632f3561b8bSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5633f3561b8bSmrg#endif /* PATH_SEPARATOR_2 */
5634fc5a983dSmrg
5635f3561b8bSmrg#ifndef FOPEN_WB
5636f3561b8bSmrg# define FOPEN_WB "w"
5637f3561b8bSmrg#endif
5638f3561b8bSmrg#ifndef _O_BINARY
5639f3561b8bSmrg# define _O_BINARY 0
5640f3561b8bSmrg#endif
5641fc5a983dSmrg
5642f3561b8bSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
5643f3561b8bSmrg#define XFREE(stale) do { \
56446257f37dSmrg  if (stale) { free (stale); stale = 0; } \
5645f3561b8bSmrg} while (0)
5646fc5a983dSmrg
56476257f37dSmrg#if defined LT_DEBUGWRAPPER
5648bd304fc0Smrgstatic int lt_debug = 1;
5649f3561b8bSmrg#else
5650bd304fc0Smrgstatic int lt_debug = 0;
5651f3561b8bSmrg#endif
5652fc5a983dSmrg
5653bd304fc0Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
5654fc5a983dSmrg
5655f3561b8bSmrgvoid *xmalloc (size_t num);
5656f3561b8bSmrgchar *xstrdup (const char *string);
5657f3561b8bSmrgconst char *base_name (const char *name);
5658f3561b8bSmrgchar *find_executable (const char *wrapper);
5659f3561b8bSmrgchar *chase_symlinks (const char *pathspec);
5660f3561b8bSmrgint make_executable (const char *path);
5661f3561b8bSmrgint check_executable (const char *path);
5662f3561b8bSmrgchar *strendzap (char *str, const char *pat);
5663bd304fc0Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
5664bd304fc0Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
5665bd304fc0Smrgstatic const char *nonnull (const char *s);
5666bd304fc0Smrgstatic const char *nonempty (const char *s);
5667f3561b8bSmrgvoid lt_setenv (const char *name, const char *value);
5668f3561b8bSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
5669f3561b8bSmrgvoid lt_update_exe_path (const char *name, const char *value);
5670f3561b8bSmrgvoid lt_update_lib_path (const char *name, const char *value);
5671bd304fc0Smrgchar **prepare_spawn (char **argv);
5672bd304fc0Smrgvoid lt_dump_script (FILE *f);
5673f3561b8bSmrgEOF
5674f3561b8bSmrg
5675f3561b8bSmrg	    cat <<EOF
56766257f37dSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
56776257f37dSmrg# define externally_visible volatile
56786257f37dSmrg#else
56796257f37dSmrg# define externally_visible __attribute__((externally_visible)) volatile
56806257f37dSmrg#endif
56816257f37dSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe";
5682f3561b8bSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
5683f3561b8bSmrgEOF
5684fc5a983dSmrg
56856257f37dSmrg	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5686bd304fc0Smrg              func_to_host_path "$temp_rpath"
5687f3561b8bSmrg	      cat <<EOF
5688bd304fc0Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
5689f3561b8bSmrgEOF
5690f3561b8bSmrg	    else
5691f3561b8bSmrg	      cat <<"EOF"
5692f3561b8bSmrgconst char * LIB_PATH_VALUE   = "";
5693f3561b8bSmrgEOF
5694fc5a983dSmrg	    fi
5695fc5a983dSmrg
5696f3561b8bSmrg	    if test -n "$dllsearchpath"; then
5697bd304fc0Smrg              func_to_host_path "$dllsearchpath:"
5698f3561b8bSmrg	      cat <<EOF
5699f3561b8bSmrgconst char * EXE_PATH_VARNAME = "PATH";
5700bd304fc0Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
5701fc5a983dSmrgEOF
5702fc5a983dSmrg	    else
5703f3561b8bSmrg	      cat <<"EOF"
5704f3561b8bSmrgconst char * EXE_PATH_VARNAME = "";
5705f3561b8bSmrgconst char * EXE_PATH_VALUE   = "";
5706f3561b8bSmrgEOF
5707fc5a983dSmrg	    fi
5708f3561b8bSmrg
57096257f37dSmrg	    if test yes = "$fast_install"; then
5710f3561b8bSmrg	      cat <<EOF
5711f3561b8bSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
5712f3561b8bSmrgEOF
5713fc5a983dSmrg	    else
5714f3561b8bSmrg	      cat <<EOF
5715f3561b8bSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
5716f3561b8bSmrgEOF
5717fc5a983dSmrg	    fi
5718fc5a983dSmrg
5719fc5a983dSmrg
5720f3561b8bSmrg	    cat <<"EOF"
5721fc5a983dSmrg
5722f3561b8bSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
5723fc5a983dSmrg
5724f3561b8bSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
5725f3561b8bSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
5726bd304fc0Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
5727fc5a983dSmrg
5728f3561b8bSmrgint
5729f3561b8bSmrgmain (int argc, char *argv[])
5730f3561b8bSmrg{
5731f3561b8bSmrg  char **newargz;
5732f3561b8bSmrg  int  newargc;
5733f3561b8bSmrg  char *tmp_pathspec;
5734f3561b8bSmrg  char *actual_cwrapper_path;
5735f3561b8bSmrg  char *actual_cwrapper_name;
5736f3561b8bSmrg  char *target_name;
5737f3561b8bSmrg  char *lt_argv_zero;
57386257f37dSmrg  int rval = 127;
5739fc5a983dSmrg
5740f3561b8bSmrg  int i;
5741fc5a983dSmrg
5742f3561b8bSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
57436257f37dSmrg  newargz = XMALLOC (char *, (size_t) argc + 1);
5744fc5a983dSmrg
5745bd304fc0Smrg  /* very simple arg parsing; don't want to rely on getopt
5746bd304fc0Smrg   * also, copy all non cwrapper options to newargz, except
5747bd304fc0Smrg   * argz[0], which is handled differently
5748bd304fc0Smrg   */
5749bd304fc0Smrg  newargc=0;
5750f3561b8bSmrg  for (i = 1; i < argc; i++)
5751f3561b8bSmrg    {
57526257f37dSmrg      if (STREQ (argv[i], dumpscript_opt))
5753f3561b8bSmrg	{
5754f3561b8bSmrgEOF
57556257f37dSmrg	    case $host in
5756f3561b8bSmrg	      *mingw* | *cygwin* )
5757f3561b8bSmrg		# make stdout use "unix" line endings
5758f3561b8bSmrg		echo "          setmode(1,_O_BINARY);"
5759f3561b8bSmrg		;;
5760f3561b8bSmrg	      esac
5761fc5a983dSmrg
5762f3561b8bSmrg	    cat <<"EOF"
5763bd304fc0Smrg	  lt_dump_script (stdout);
5764f3561b8bSmrg	  return 0;
5765f3561b8bSmrg	}
57666257f37dSmrg      if (STREQ (argv[i], debug_opt))
5767bd304fc0Smrg	{
5768bd304fc0Smrg          lt_debug = 1;
5769bd304fc0Smrg          continue;
5770bd304fc0Smrg	}
57716257f37dSmrg      if (STREQ (argv[i], ltwrapper_option_prefix))
5772bd304fc0Smrg        {
5773bd304fc0Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
5774bd304fc0Smrg             namespace, but it is not one of the ones we know about and
5775bd304fc0Smrg             have already dealt with, above (inluding dump-script), then
5776bd304fc0Smrg             report an error. Otherwise, targets might begin to believe
5777bd304fc0Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
5778bd304fc0Smrg             namespace. The first time any user complains about this, we'll
5779bd304fc0Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
5780bd304fc0Smrg             or a configure.ac-settable value.
5781bd304fc0Smrg           */
5782bd304fc0Smrg          lt_fatal (__FILE__, __LINE__,
5783bd304fc0Smrg		    "unrecognized %s option: '%s'",
5784bd304fc0Smrg                    ltwrapper_option_prefix, argv[i]);
5785bd304fc0Smrg        }
5786bd304fc0Smrg      /* otherwise ... */
5787bd304fc0Smrg      newargz[++newargc] = xstrdup (argv[i]);
5788f3561b8bSmrg    }
5789bd304fc0Smrg  newargz[++newargc] = NULL;
5790bd304fc0Smrg
5791bd304fc0SmrgEOF
5792bd304fc0Smrg	    cat <<EOF
5793bd304fc0Smrg  /* The GNU banner must be the first non-error debug message */
57946257f37dSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
5795bd304fc0SmrgEOF
5796bd304fc0Smrg	    cat <<"EOF"
5797bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
5798bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
5799fc5a983dSmrg
5800f3561b8bSmrg  tmp_pathspec = find_executable (argv[0]);
5801f3561b8bSmrg  if (tmp_pathspec == NULL)
5802bd304fc0Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
5803bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__,
5804bd304fc0Smrg                  "(main) found exe (before symlink chase) at: %s\n",
5805bd304fc0Smrg		  tmp_pathspec);
5806f3561b8bSmrg
5807f3561b8bSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
5808bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__,
5809bd304fc0Smrg                  "(main) found exe (after symlink chase) at: %s\n",
5810bd304fc0Smrg		  actual_cwrapper_path);
5811f3561b8bSmrg  XFREE (tmp_pathspec);
5812f3561b8bSmrg
5813bd304fc0Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
5814f3561b8bSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
5815f3561b8bSmrg
5816f3561b8bSmrg  /* wrapper name transforms */
5817f3561b8bSmrg  strendzap (actual_cwrapper_name, ".exe");
5818f3561b8bSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
5819f3561b8bSmrg  XFREE (actual_cwrapper_name);
5820f3561b8bSmrg  actual_cwrapper_name = tmp_pathspec;
5821f3561b8bSmrg  tmp_pathspec = 0;
5822f3561b8bSmrg
5823f3561b8bSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
5824f3561b8bSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
5825f3561b8bSmrg  strendzap (target_name, ".exe");
5826f3561b8bSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
5827f3561b8bSmrg  XFREE (target_name);
5828f3561b8bSmrg  target_name = tmp_pathspec;
5829f3561b8bSmrg  tmp_pathspec = 0;
5830f3561b8bSmrg
5831bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__,
5832bd304fc0Smrg		  "(main) libtool target name: %s\n",
5833bd304fc0Smrg		  target_name);
5834f3561b8bSmrgEOF
5835fc5a983dSmrg
5836f3561b8bSmrg	    cat <<EOF
5837f3561b8bSmrg  newargz[0] =
5838f3561b8bSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
5839f3561b8bSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
5840f3561b8bSmrg  strcpy (newargz[0], actual_cwrapper_path);
5841f3561b8bSmrg  strcat (newargz[0], "$objdir");
5842f3561b8bSmrg  strcat (newargz[0], "/");
5843f3561b8bSmrgEOF
5844fc5a983dSmrg
5845f3561b8bSmrg	    cat <<"EOF"
5846f3561b8bSmrg  /* stop here, and copy so we don't have to do this twice */
5847f3561b8bSmrg  tmp_pathspec = xstrdup (newargz[0]);
5848fc5a983dSmrg
5849f3561b8bSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
5850f3561b8bSmrg  strcat (newargz[0], actual_cwrapper_name);
5851fc5a983dSmrg
5852f3561b8bSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
5853f3561b8bSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
5854f3561b8bSmrg  XFREE (tmp_pathspec);
5855f3561b8bSmrg  tmp_pathspec = NULL;
5856f3561b8bSmrgEOF
5857fc5a983dSmrg
5858f3561b8bSmrg	    case $host_os in
5859f3561b8bSmrg	      mingw*)
5860f3561b8bSmrg	    cat <<"EOF"
5861f3561b8bSmrg  {
5862f3561b8bSmrg    char* p;
5863f3561b8bSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
5864f3561b8bSmrg      {
5865f3561b8bSmrg	*p = '/';
5866f3561b8bSmrg      }
5867f3561b8bSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
5868f3561b8bSmrg      {
5869f3561b8bSmrg	*p = '/';
5870f3561b8bSmrg      }
5871f3561b8bSmrg  }
5872f3561b8bSmrgEOF
5873f3561b8bSmrg	    ;;
5874f3561b8bSmrg	    esac
5875fc5a983dSmrg
5876f3561b8bSmrg	    cat <<"EOF"
5877f3561b8bSmrg  XFREE (target_name);
5878f3561b8bSmrg  XFREE (actual_cwrapper_path);
5879f3561b8bSmrg  XFREE (actual_cwrapper_name);
5880fc5a983dSmrg
5881f3561b8bSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
5882f3561b8bSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
5883bd304fc0Smrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
5884bd304fc0Smrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
5885bd304fc0Smrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
5886bd304fc0Smrg     libraries must come first. */
5887f3561b8bSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
5888bd304fc0Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
5889fc5a983dSmrg
5890bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
5891bd304fc0Smrg		  nonnull (lt_argv_zero));
5892f3561b8bSmrg  for (i = 0; i < newargc; i++)
5893f3561b8bSmrg    {
5894bd304fc0Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
5895bd304fc0Smrg		      i, nonnull (newargz[i]));
5896f3561b8bSmrg    }
5897fc5a983dSmrg
5898f3561b8bSmrgEOF
5899fc5a983dSmrg
5900f3561b8bSmrg	    case $host_os in
5901f3561b8bSmrg	      mingw*)
5902f3561b8bSmrg		cat <<"EOF"
5903f3561b8bSmrg  /* execv doesn't actually work on mingw as expected on unix */
5904bd304fc0Smrg  newargz = prepare_spawn (newargz);
59056257f37dSmrg  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
5906f3561b8bSmrg  if (rval == -1)
5907f3561b8bSmrg    {
5908f3561b8bSmrg      /* failed to start process */
5909bd304fc0Smrg      lt_debugprintf (__FILE__, __LINE__,
5910bd304fc0Smrg		      "(main) failed to launch target \"%s\": %s\n",
5911bd304fc0Smrg		      lt_argv_zero, nonnull (strerror (errno)));
5912f3561b8bSmrg      return 127;
5913f3561b8bSmrg    }
5914f3561b8bSmrg  return rval;
5915f3561b8bSmrgEOF
5916f3561b8bSmrg		;;
5917f3561b8bSmrg	      *)
5918f3561b8bSmrg		cat <<"EOF"
5919f3561b8bSmrg  execv (lt_argv_zero, newargz);
5920f3561b8bSmrg  return rval; /* =127, but avoids unused variable warning */
5921f3561b8bSmrgEOF
5922f3561b8bSmrg		;;
5923f3561b8bSmrg	    esac
5924fc5a983dSmrg
5925f3561b8bSmrg	    cat <<"EOF"
5926f3561b8bSmrg}
5927fc5a983dSmrg
5928f3561b8bSmrgvoid *
5929f3561b8bSmrgxmalloc (size_t num)
5930f3561b8bSmrg{
5931f3561b8bSmrg  void *p = (void *) malloc (num);
5932f3561b8bSmrg  if (!p)
5933bd304fc0Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
5934fc5a983dSmrg
5935f3561b8bSmrg  return p;
5936f3561b8bSmrg}
5937fc5a983dSmrg
5938f3561b8bSmrgchar *
5939f3561b8bSmrgxstrdup (const char *string)
5940f3561b8bSmrg{
5941f3561b8bSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
5942f3561b8bSmrg			  string) : NULL;
5943f3561b8bSmrg}
5944fc5a983dSmrg
5945f3561b8bSmrgconst char *
5946f3561b8bSmrgbase_name (const char *name)
5947f3561b8bSmrg{
5948f3561b8bSmrg  const char *base;
5949fc5a983dSmrg
59506257f37dSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
5951f3561b8bSmrg  /* Skip over the disk name in MSDOS pathnames. */
5952f3561b8bSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
5953f3561b8bSmrg    name += 2;
5954f3561b8bSmrg#endif
5955fc5a983dSmrg
5956f3561b8bSmrg  for (base = name; *name; name++)
5957f3561b8bSmrg    if (IS_DIR_SEPARATOR (*name))
5958f3561b8bSmrg      base = name + 1;
5959f3561b8bSmrg  return base;
5960f3561b8bSmrg}
5961fc5a983dSmrg
5962f3561b8bSmrgint
5963f3561b8bSmrgcheck_executable (const char *path)
5964f3561b8bSmrg{
5965f3561b8bSmrg  struct stat st;
5966fc5a983dSmrg
5967bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
5968bd304fc0Smrg                  nonempty (path));
5969f3561b8bSmrg  if ((!path) || (!*path))
5970f3561b8bSmrg    return 0;
5971fc5a983dSmrg
5972f3561b8bSmrg  if ((stat (path, &st) >= 0)
5973f3561b8bSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
5974f3561b8bSmrg    return 1;
5975f3561b8bSmrg  else
5976f3561b8bSmrg    return 0;
5977f3561b8bSmrg}
5978fc5a983dSmrg
5979f3561b8bSmrgint
5980f3561b8bSmrgmake_executable (const char *path)
5981f3561b8bSmrg{
5982f3561b8bSmrg  int rval = 0;
5983f3561b8bSmrg  struct stat st;
5984fc5a983dSmrg
5985bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
5986bd304fc0Smrg                  nonempty (path));
5987f3561b8bSmrg  if ((!path) || (!*path))
5988f3561b8bSmrg    return 0;
5989fc5a983dSmrg
5990f3561b8bSmrg  if (stat (path, &st) >= 0)
5991f3561b8bSmrg    {
5992f3561b8bSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
5993f3561b8bSmrg    }
5994f3561b8bSmrg  return rval;
5995f3561b8bSmrg}
5996fc5a983dSmrg
5997f3561b8bSmrg/* Searches for the full path of the wrapper.  Returns
5998f3561b8bSmrg   newly allocated full path name if found, NULL otherwise
5999f3561b8bSmrg   Does not chase symlinks, even on platforms that support them.
6000f3561b8bSmrg*/
6001f3561b8bSmrgchar *
6002f3561b8bSmrgfind_executable (const char *wrapper)
6003f3561b8bSmrg{
6004f3561b8bSmrg  int has_slash = 0;
6005f3561b8bSmrg  const char *p;
6006f3561b8bSmrg  const char *p_next;
6007f3561b8bSmrg  /* static buffer for getcwd */
6008f3561b8bSmrg  char tmp[LT_PATHMAX + 1];
60096257f37dSmrg  size_t tmp_len;
6010f3561b8bSmrg  char *concat_name;
6011fc5a983dSmrg
6012bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
6013bd304fc0Smrg                  nonempty (wrapper));
6014fc5a983dSmrg
6015f3561b8bSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
6016f3561b8bSmrg    return NULL;
6017fc5a983dSmrg
6018f3561b8bSmrg  /* Absolute path? */
60196257f37dSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
6020f3561b8bSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
6021f3561b8bSmrg    {
6022f3561b8bSmrg      concat_name = xstrdup (wrapper);
6023f3561b8bSmrg      if (check_executable (concat_name))
6024f3561b8bSmrg	return concat_name;
6025f3561b8bSmrg      XFREE (concat_name);
6026f3561b8bSmrg    }
6027f3561b8bSmrg  else
6028f3561b8bSmrg    {
6029f3561b8bSmrg#endif
6030f3561b8bSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
6031f3561b8bSmrg	{
6032f3561b8bSmrg	  concat_name = xstrdup (wrapper);
6033f3561b8bSmrg	  if (check_executable (concat_name))
6034f3561b8bSmrg	    return concat_name;
6035f3561b8bSmrg	  XFREE (concat_name);
6036f3561b8bSmrg	}
60376257f37dSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
6038f3561b8bSmrg    }
6039f3561b8bSmrg#endif
6040fc5a983dSmrg
6041f3561b8bSmrg  for (p = wrapper; *p; p++)
6042f3561b8bSmrg    if (*p == '/')
6043f3561b8bSmrg      {
6044f3561b8bSmrg	has_slash = 1;
6045f3561b8bSmrg	break;
6046f3561b8bSmrg      }
6047f3561b8bSmrg  if (!has_slash)
6048f3561b8bSmrg    {
6049f3561b8bSmrg      /* no slashes; search PATH */
6050f3561b8bSmrg      const char *path = getenv ("PATH");
6051f3561b8bSmrg      if (path != NULL)
6052f3561b8bSmrg	{
6053f3561b8bSmrg	  for (p = path; *p; p = p_next)
6054f3561b8bSmrg	    {
6055f3561b8bSmrg	      const char *q;
6056f3561b8bSmrg	      size_t p_len;
6057f3561b8bSmrg	      for (q = p; *q; q++)
6058f3561b8bSmrg		if (IS_PATH_SEPARATOR (*q))
6059f3561b8bSmrg		  break;
60606257f37dSmrg	      p_len = (size_t) (q - p);
6061f3561b8bSmrg	      p_next = (*q == '\0' ? q : q + 1);
6062f3561b8bSmrg	      if (p_len == 0)
6063f3561b8bSmrg		{
6064f3561b8bSmrg		  /* empty path: current directory */
6065f3561b8bSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
6066bd304fc0Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6067bd304fc0Smrg                              nonnull (strerror (errno)));
6068f3561b8bSmrg		  tmp_len = strlen (tmp);
6069f3561b8bSmrg		  concat_name =
6070f3561b8bSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6071f3561b8bSmrg		  memcpy (concat_name, tmp, tmp_len);
6072f3561b8bSmrg		  concat_name[tmp_len] = '/';
6073f3561b8bSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
6074f3561b8bSmrg		}
6075f3561b8bSmrg	      else
6076f3561b8bSmrg		{
6077f3561b8bSmrg		  concat_name =
6078f3561b8bSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
6079f3561b8bSmrg		  memcpy (concat_name, p, p_len);
6080f3561b8bSmrg		  concat_name[p_len] = '/';
6081f3561b8bSmrg		  strcpy (concat_name + p_len + 1, wrapper);
6082f3561b8bSmrg		}
6083f3561b8bSmrg	      if (check_executable (concat_name))
6084f3561b8bSmrg		return concat_name;
6085f3561b8bSmrg	      XFREE (concat_name);
6086f3561b8bSmrg	    }
6087f3561b8bSmrg	}
6088f3561b8bSmrg      /* not found in PATH; assume curdir */
6089f3561b8bSmrg    }
6090f3561b8bSmrg  /* Relative path | not found in path: prepend cwd */
6091f3561b8bSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
6092bd304fc0Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6093bd304fc0Smrg              nonnull (strerror (errno)));
6094f3561b8bSmrg  tmp_len = strlen (tmp);
6095f3561b8bSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6096f3561b8bSmrg  memcpy (concat_name, tmp, tmp_len);
6097f3561b8bSmrg  concat_name[tmp_len] = '/';
6098f3561b8bSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
6099fc5a983dSmrg
6100f3561b8bSmrg  if (check_executable (concat_name))
6101f3561b8bSmrg    return concat_name;
6102f3561b8bSmrg  XFREE (concat_name);
6103f3561b8bSmrg  return NULL;
6104f3561b8bSmrg}
6105fc5a983dSmrg
6106f3561b8bSmrgchar *
6107f3561b8bSmrgchase_symlinks (const char *pathspec)
6108f3561b8bSmrg{
6109f3561b8bSmrg#ifndef S_ISLNK
6110f3561b8bSmrg  return xstrdup (pathspec);
6111f3561b8bSmrg#else
6112f3561b8bSmrg  char buf[LT_PATHMAX];
6113f3561b8bSmrg  struct stat s;
6114f3561b8bSmrg  char *tmp_pathspec = xstrdup (pathspec);
6115f3561b8bSmrg  char *p;
6116f3561b8bSmrg  int has_symlinks = 0;
6117f3561b8bSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
6118f3561b8bSmrg    {
6119bd304fc0Smrg      lt_debugprintf (__FILE__, __LINE__,
6120bd304fc0Smrg		      "checking path component for symlinks: %s\n",
6121bd304fc0Smrg		      tmp_pathspec);
6122f3561b8bSmrg      if (lstat (tmp_pathspec, &s) == 0)
6123f3561b8bSmrg	{
6124f3561b8bSmrg	  if (S_ISLNK (s.st_mode) != 0)
6125f3561b8bSmrg	    {
6126f3561b8bSmrg	      has_symlinks = 1;
6127f3561b8bSmrg	      break;
6128f3561b8bSmrg	    }
6129fc5a983dSmrg
6130f3561b8bSmrg	  /* search backwards for last DIR_SEPARATOR */
6131f3561b8bSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
6132f3561b8bSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6133f3561b8bSmrg	    p--;
6134f3561b8bSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6135f3561b8bSmrg	    {
6136f3561b8bSmrg	      /* no more DIR_SEPARATORS left */
6137f3561b8bSmrg	      break;
6138f3561b8bSmrg	    }
6139f3561b8bSmrg	  *p = '\0';
6140f3561b8bSmrg	}
6141f3561b8bSmrg      else
6142f3561b8bSmrg	{
6143bd304fc0Smrg	  lt_fatal (__FILE__, __LINE__,
6144bd304fc0Smrg		    "error accessing file \"%s\": %s",
6145bd304fc0Smrg		    tmp_pathspec, nonnull (strerror (errno)));
6146f3561b8bSmrg	}
6147f3561b8bSmrg    }
6148f3561b8bSmrg  XFREE (tmp_pathspec);
6149fc5a983dSmrg
6150f3561b8bSmrg  if (!has_symlinks)
6151f3561b8bSmrg    {
6152f3561b8bSmrg      return xstrdup (pathspec);
6153f3561b8bSmrg    }
6154fc5a983dSmrg
6155f3561b8bSmrg  tmp_pathspec = realpath (pathspec, buf);
6156f3561b8bSmrg  if (tmp_pathspec == 0)
6157f3561b8bSmrg    {
6158bd304fc0Smrg      lt_fatal (__FILE__, __LINE__,
6159bd304fc0Smrg		"could not follow symlinks for %s", pathspec);
6160f3561b8bSmrg    }
6161f3561b8bSmrg  return xstrdup (tmp_pathspec);
6162f3561b8bSmrg#endif
6163f3561b8bSmrg}
6164fc5a983dSmrg
6165f3561b8bSmrgchar *
6166f3561b8bSmrgstrendzap (char *str, const char *pat)
6167f3561b8bSmrg{
6168f3561b8bSmrg  size_t len, patlen;
6169fc5a983dSmrg
6170f3561b8bSmrg  assert (str != NULL);
6171f3561b8bSmrg  assert (pat != NULL);
6172fc5a983dSmrg
6173f3561b8bSmrg  len = strlen (str);
6174f3561b8bSmrg  patlen = strlen (pat);
6175fc5a983dSmrg
6176f3561b8bSmrg  if (patlen <= len)
6177f3561b8bSmrg    {
6178f3561b8bSmrg      str += len - patlen;
61796257f37dSmrg      if (STREQ (str, pat))
6180f3561b8bSmrg	*str = '\0';
6181f3561b8bSmrg    }
6182f3561b8bSmrg  return str;
6183f3561b8bSmrg}
6184fc5a983dSmrg
6185bd304fc0Smrgvoid
6186bd304fc0Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
6187bd304fc0Smrg{
6188bd304fc0Smrg  va_list args;
6189bd304fc0Smrg  if (lt_debug)
6190bd304fc0Smrg    {
6191bd304fc0Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
6192bd304fc0Smrg      va_start (args, fmt);
6193bd304fc0Smrg      (void) vfprintf (stderr, fmt, args);
6194bd304fc0Smrg      va_end (args);
6195bd304fc0Smrg    }
6196bd304fc0Smrg}
6197bd304fc0Smrg
6198f3561b8bSmrgstatic void
6199bd304fc0Smrglt_error_core (int exit_status, const char *file,
6200bd304fc0Smrg	       int line, const char *mode,
6201f3561b8bSmrg	       const char *message, va_list ap)
6202f3561b8bSmrg{
6203bd304fc0Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
6204f3561b8bSmrg  vfprintf (stderr, message, ap);
6205f3561b8bSmrg  fprintf (stderr, ".\n");
6206fc5a983dSmrg
6207f3561b8bSmrg  if (exit_status >= 0)
6208f3561b8bSmrg    exit (exit_status);
6209f3561b8bSmrg}
6210fc5a983dSmrg
6211f3561b8bSmrgvoid
6212bd304fc0Smrglt_fatal (const char *file, int line, const char *message, ...)
6213f3561b8bSmrg{
6214f3561b8bSmrg  va_list ap;
6215f3561b8bSmrg  va_start (ap, message);
6216bd304fc0Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
6217f3561b8bSmrg  va_end (ap);
6218f3561b8bSmrg}
6219fc5a983dSmrg
6220bd304fc0Smrgstatic const char *
6221bd304fc0Smrgnonnull (const char *s)
6222bd304fc0Smrg{
6223bd304fc0Smrg  return s ? s : "(null)";
6224bd304fc0Smrg}
6225bd304fc0Smrg
6226bd304fc0Smrgstatic const char *
6227bd304fc0Smrgnonempty (const char *s)
6228bd304fc0Smrg{
6229bd304fc0Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
6230bd304fc0Smrg}
6231bd304fc0Smrg
6232f3561b8bSmrgvoid
6233f3561b8bSmrglt_setenv (const char *name, const char *value)
6234f3561b8bSmrg{
6235bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__,
6236bd304fc0Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
6237bd304fc0Smrg                  nonnull (name), nonnull (value));
6238f3561b8bSmrg  {
6239f3561b8bSmrg#ifdef HAVE_SETENV
6240f3561b8bSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
6241f3561b8bSmrg    char *str = xstrdup (value);
6242f3561b8bSmrg    setenv (name, str, 1);
6243f3561b8bSmrg#else
62446257f37dSmrg    size_t len = strlen (name) + 1 + strlen (value) + 1;
6245f3561b8bSmrg    char *str = XMALLOC (char, len);
6246f3561b8bSmrg    sprintf (str, "%s=%s", name, value);
6247f3561b8bSmrg    if (putenv (str) != EXIT_SUCCESS)
6248f3561b8bSmrg      {
6249f3561b8bSmrg        XFREE (str);
6250f3561b8bSmrg      }
6251f3561b8bSmrg#endif
6252f3561b8bSmrg  }
6253f3561b8bSmrg}
6254fc5a983dSmrg
6255f3561b8bSmrgchar *
6256f3561b8bSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
6257f3561b8bSmrg{
6258f3561b8bSmrg  char *new_value;
6259f3561b8bSmrg  if (orig_value && *orig_value)
6260f3561b8bSmrg    {
62616257f37dSmrg      size_t orig_value_len = strlen (orig_value);
62626257f37dSmrg      size_t add_len = strlen (add);
6263f3561b8bSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
6264f3561b8bSmrg      if (to_end)
6265f3561b8bSmrg        {
6266f3561b8bSmrg          strcpy (new_value, orig_value);
6267f3561b8bSmrg          strcpy (new_value + orig_value_len, add);
6268f3561b8bSmrg        }
6269f3561b8bSmrg      else
6270f3561b8bSmrg        {
6271f3561b8bSmrg          strcpy (new_value, add);
6272f3561b8bSmrg          strcpy (new_value + add_len, orig_value);
6273f3561b8bSmrg        }
6274f3561b8bSmrg    }
6275f3561b8bSmrg  else
6276f3561b8bSmrg    {
6277f3561b8bSmrg      new_value = xstrdup (add);
6278f3561b8bSmrg    }
6279f3561b8bSmrg  return new_value;
6280f3561b8bSmrg}
6281fc5a983dSmrg
6282f3561b8bSmrgvoid
6283f3561b8bSmrglt_update_exe_path (const char *name, const char *value)
6284f3561b8bSmrg{
6285bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__,
6286bd304fc0Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
6287bd304fc0Smrg                  nonnull (name), nonnull (value));
6288fc5a983dSmrg
6289f3561b8bSmrg  if (name && *name && value && *value)
6290f3561b8bSmrg    {
6291f3561b8bSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
6292f3561b8bSmrg      /* some systems can't cope with a ':'-terminated path #' */
62936257f37dSmrg      size_t len = strlen (new_value);
62946257f37dSmrg      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
6295f3561b8bSmrg        {
62966257f37dSmrg          new_value[--len] = '\0';
6297f3561b8bSmrg        }
6298f3561b8bSmrg      lt_setenv (name, new_value);
6299f3561b8bSmrg      XFREE (new_value);
6300f3561b8bSmrg    }
6301f3561b8bSmrg}
6302fc5a983dSmrg
6303f3561b8bSmrgvoid
6304f3561b8bSmrglt_update_lib_path (const char *name, const char *value)
6305f3561b8bSmrg{
6306bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__,
6307bd304fc0Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
6308bd304fc0Smrg                  nonnull (name), nonnull (value));
6309fc5a983dSmrg
6310f3561b8bSmrg  if (name && *name && value && *value)
6311f3561b8bSmrg    {
6312f3561b8bSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
6313f3561b8bSmrg      lt_setenv (name, new_value);
6314f3561b8bSmrg      XFREE (new_value);
6315f3561b8bSmrg    }
6316f3561b8bSmrg}
6317fc5a983dSmrg
6318bd304fc0SmrgEOF
6319bd304fc0Smrg	    case $host_os in
6320bd304fc0Smrg	      mingw*)
6321bd304fc0Smrg		cat <<"EOF"
6322bd304fc0Smrg
6323bd304fc0Smrg/* Prepares an argument vector before calling spawn().
6324bd304fc0Smrg   Note that spawn() does not by itself call the command interpreter
6325bd304fc0Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
6326bd304fc0Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
6327bd304fc0Smrg         GetVersionEx(&v);
6328bd304fc0Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
6329bd304fc0Smrg      }) ? "cmd.exe" : "command.com").
6330bd304fc0Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
6331bd304fc0Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
6332bd304fc0Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
6333bd304fc0Smrg   special way:
6334bd304fc0Smrg   - Space and tab are interpreted as delimiters. They are not treated as
6335bd304fc0Smrg     delimiters if they are surrounded by double quotes: "...".
6336bd304fc0Smrg   - Unescaped double quotes are removed from the input. Their only effect is
6337bd304fc0Smrg     that within double quotes, space and tab are treated like normal
6338bd304fc0Smrg     characters.
6339bd304fc0Smrg   - Backslashes not followed by double quotes are not special.
6340bd304fc0Smrg   - But 2*n+1 backslashes followed by a double quote become
6341bd304fc0Smrg     n backslashes followed by a double quote (n >= 0):
6342bd304fc0Smrg       \" -> "
6343bd304fc0Smrg       \\\" -> \"
6344bd304fc0Smrg       \\\\\" -> \\"
6345bd304fc0Smrg */
6346bd304fc0Smrg#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"
6347bd304fc0Smrg#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"
6348bd304fc0Smrgchar **
6349bd304fc0Smrgprepare_spawn (char **argv)
6350bd304fc0Smrg{
6351bd304fc0Smrg  size_t argc;
6352bd304fc0Smrg  char **new_argv;
6353bd304fc0Smrg  size_t i;
6354bd304fc0Smrg
6355bd304fc0Smrg  /* Count number of arguments.  */
6356bd304fc0Smrg  for (argc = 0; argv[argc] != NULL; argc++)
6357bd304fc0Smrg    ;
6358bd304fc0Smrg
6359bd304fc0Smrg  /* Allocate new argument vector.  */
6360bd304fc0Smrg  new_argv = XMALLOC (char *, argc + 1);
6361bd304fc0Smrg
6362bd304fc0Smrg  /* Put quoted arguments into the new argument vector.  */
6363bd304fc0Smrg  for (i = 0; i < argc; i++)
6364bd304fc0Smrg    {
6365bd304fc0Smrg      const char *string = argv[i];
6366bd304fc0Smrg
6367bd304fc0Smrg      if (string[0] == '\0')
6368bd304fc0Smrg	new_argv[i] = xstrdup ("\"\"");
6369bd304fc0Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
6370bd304fc0Smrg	{
6371bd304fc0Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
6372bd304fc0Smrg	  size_t length;
6373bd304fc0Smrg	  unsigned int backslashes;
6374bd304fc0Smrg	  const char *s;
6375bd304fc0Smrg	  char *quoted_string;
6376bd304fc0Smrg	  char *p;
6377bd304fc0Smrg
6378bd304fc0Smrg	  length = 0;
6379bd304fc0Smrg	  backslashes = 0;
6380bd304fc0Smrg	  if (quote_around)
6381bd304fc0Smrg	    length++;
6382bd304fc0Smrg	  for (s = string; *s != '\0'; s++)
6383bd304fc0Smrg	    {
6384bd304fc0Smrg	      char c = *s;
6385bd304fc0Smrg	      if (c == '"')
6386bd304fc0Smrg		length += backslashes + 1;
6387bd304fc0Smrg	      length++;
6388bd304fc0Smrg	      if (c == '\\')
6389bd304fc0Smrg		backslashes++;
6390bd304fc0Smrg	      else
6391bd304fc0Smrg		backslashes = 0;
6392bd304fc0Smrg	    }
6393bd304fc0Smrg	  if (quote_around)
6394bd304fc0Smrg	    length += backslashes + 1;
6395bd304fc0Smrg
6396bd304fc0Smrg	  quoted_string = XMALLOC (char, length + 1);
6397bd304fc0Smrg
6398bd304fc0Smrg	  p = quoted_string;
6399bd304fc0Smrg	  backslashes = 0;
6400bd304fc0Smrg	  if (quote_around)
6401bd304fc0Smrg	    *p++ = '"';
6402bd304fc0Smrg	  for (s = string; *s != '\0'; s++)
6403bd304fc0Smrg	    {
6404bd304fc0Smrg	      char c = *s;
6405bd304fc0Smrg	      if (c == '"')
6406bd304fc0Smrg		{
6407bd304fc0Smrg		  unsigned int j;
6408bd304fc0Smrg		  for (j = backslashes + 1; j > 0; j--)
6409bd304fc0Smrg		    *p++ = '\\';
6410bd304fc0Smrg		}
6411bd304fc0Smrg	      *p++ = c;
6412bd304fc0Smrg	      if (c == '\\')
6413bd304fc0Smrg		backslashes++;
6414bd304fc0Smrg	      else
6415bd304fc0Smrg		backslashes = 0;
6416bd304fc0Smrg	    }
6417bd304fc0Smrg	  if (quote_around)
6418bd304fc0Smrg	    {
6419bd304fc0Smrg	      unsigned int j;
6420bd304fc0Smrg	      for (j = backslashes; j > 0; j--)
6421bd304fc0Smrg		*p++ = '\\';
6422bd304fc0Smrg	      *p++ = '"';
6423bd304fc0Smrg	    }
6424bd304fc0Smrg	  *p = '\0';
6425bd304fc0Smrg
6426bd304fc0Smrg	  new_argv[i] = quoted_string;
6427bd304fc0Smrg	}
6428bd304fc0Smrg      else
6429bd304fc0Smrg	new_argv[i] = (char *) string;
6430bd304fc0Smrg    }
6431bd304fc0Smrg  new_argv[argc] = NULL;
6432bd304fc0Smrg
6433bd304fc0Smrg  return new_argv;
6434bd304fc0Smrg}
6435bd304fc0SmrgEOF
6436bd304fc0Smrg		;;
6437bd304fc0Smrg	    esac
6438fc5a983dSmrg
6439bd304fc0Smrg            cat <<"EOF"
6440bd304fc0Smrgvoid lt_dump_script (FILE* f)
6441bd304fc0Smrg{
6442bd304fc0SmrgEOF
6443bd304fc0Smrg	    func_emit_wrapper yes |
6444bd304fc0Smrg	      $SED -n -e '
6445bd304fc0Smrgs/^\(.\{79\}\)\(..*\)/\1\
6446bd304fc0Smrg\2/
6447bd304fc0Smrgh
6448bd304fc0Smrgs/\([\\"]\)/\\\1/g
6449bd304fc0Smrgs/$/\\n/
6450bd304fc0Smrgs/\([^\n]*\).*/  fputs ("\1", f);/p
6451bd304fc0Smrgg
6452bd304fc0SmrgD'
6453bd304fc0Smrg            cat <<"EOF"
6454bd304fc0Smrg}
6455f3561b8bSmrgEOF
6456f3561b8bSmrg}
6457f3561b8bSmrg# end: func_emit_cwrapperexe_src
6458fc5a983dSmrg
6459bd304fc0Smrg# func_win32_import_lib_p ARG
6460bd304fc0Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
6461bd304fc0Smrgfunc_win32_import_lib_p ()
6462bd304fc0Smrg{
64636257f37dSmrg    $debug_cmd
64646257f37dSmrg
6465bd304fc0Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
6466bd304fc0Smrg    *import*) : ;;
6467bd304fc0Smrg    *) false ;;
6468bd304fc0Smrg    esac
6469bd304fc0Smrg}
6470bd304fc0Smrg
64716257f37dSmrg# func_suncc_cstd_abi
64726257f37dSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
64736257f37dSmrg# Several compiler flags select an ABI that is incompatible with the
64746257f37dSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS.
64756257f37dSmrgfunc_suncc_cstd_abi ()
64766257f37dSmrg{
64776257f37dSmrg    $debug_cmd
64786257f37dSmrg
64796257f37dSmrg    case " $compile_command " in
64806257f37dSmrg    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
64816257f37dSmrg      suncc_use_cstd_abi=no
64826257f37dSmrg      ;;
64836257f37dSmrg    *)
64846257f37dSmrg      suncc_use_cstd_abi=yes
64856257f37dSmrg      ;;
64866257f37dSmrg    esac
64876257f37dSmrg}
64886257f37dSmrg
6489f3561b8bSmrg# func_mode_link arg...
6490f3561b8bSmrgfunc_mode_link ()
6491f3561b8bSmrg{
64926257f37dSmrg    $debug_cmd
64936257f37dSmrg
6494f3561b8bSmrg    case $host in
6495f3561b8bSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6496f3561b8bSmrg      # It is impossible to link a dll without this setting, and
6497f3561b8bSmrg      # we shouldn't force the makefile maintainer to figure out
64986257f37dSmrg      # what system we are compiling for in order to pass an extra
6499f3561b8bSmrg      # flag for every libtool invocation.
6500f3561b8bSmrg      # allow_undefined=no
6501fc5a983dSmrg
6502f3561b8bSmrg      # FIXME: Unfortunately, there are problems with the above when trying
65036257f37dSmrg      # to make a dll that has undefined symbols, in which case not
6504f3561b8bSmrg      # even a static library is built.  For now, we need to specify
6505f3561b8bSmrg      # -no-undefined on the libtool link line when we can be certain
6506f3561b8bSmrg      # that all symbols are satisfied, otherwise we get a static library.
6507f3561b8bSmrg      allow_undefined=yes
6508f3561b8bSmrg      ;;
6509f3561b8bSmrg    *)
6510f3561b8bSmrg      allow_undefined=yes
6511f3561b8bSmrg      ;;
6512f3561b8bSmrg    esac
6513f3561b8bSmrg    libtool_args=$nonopt
6514f3561b8bSmrg    base_compile="$nonopt $@"
6515f3561b8bSmrg    compile_command=$nonopt
6516f3561b8bSmrg    finalize_command=$nonopt
6517fc5a983dSmrg
6518f3561b8bSmrg    compile_rpath=
6519f3561b8bSmrg    finalize_rpath=
6520f3561b8bSmrg    compile_shlibpath=
6521f3561b8bSmrg    finalize_shlibpath=
6522f3561b8bSmrg    convenience=
6523f3561b8bSmrg    old_convenience=
6524f3561b8bSmrg    deplibs=
6525f3561b8bSmrg    old_deplibs=
6526f3561b8bSmrg    compiler_flags=
6527f3561b8bSmrg    linker_flags=
6528f3561b8bSmrg    dllsearchpath=
6529f3561b8bSmrg    lib_search_path=`pwd`
6530f3561b8bSmrg    inst_prefix_dir=
6531f3561b8bSmrg    new_inherited_linker_flags=
6532fc5a983dSmrg
6533f3561b8bSmrg    avoid_version=no
6534bd304fc0Smrg    bindir=
6535f3561b8bSmrg    dlfiles=
6536f3561b8bSmrg    dlprefiles=
6537f3561b8bSmrg    dlself=no
6538f3561b8bSmrg    export_dynamic=no
6539f3561b8bSmrg    export_symbols=
6540f3561b8bSmrg    export_symbols_regex=
6541f3561b8bSmrg    generated=
6542f3561b8bSmrg    libobjs=
6543f3561b8bSmrg    ltlibs=
6544f3561b8bSmrg    module=no
6545f3561b8bSmrg    no_install=no
6546f3561b8bSmrg    objs=
65476257f37dSmrg    os2dllname=
6548f3561b8bSmrg    non_pic_objects=
6549f3561b8bSmrg    precious_files_regex=
6550f3561b8bSmrg    prefer_static_libs=no
65516257f37dSmrg    preload=false
6552f3561b8bSmrg    prev=
6553f3561b8bSmrg    prevarg=
6554f3561b8bSmrg    release=
6555f3561b8bSmrg    rpath=
6556f3561b8bSmrg    xrpath=
6557f3561b8bSmrg    perm_rpath=
6558f3561b8bSmrg    temp_rpath=
6559f3561b8bSmrg    thread_safe=no
6560f3561b8bSmrg    vinfo=
6561f3561b8bSmrg    vinfo_number=no
6562f3561b8bSmrg    weak_libs=
65636257f37dSmrg    single_module=$wl-single_module
6564f3561b8bSmrg    func_infer_tag $base_compile
6565f3561b8bSmrg
6566f3561b8bSmrg    # We need to know -static, to get the right output filenames.
6567f3561b8bSmrg    for arg
6568f3561b8bSmrg    do
6569f3561b8bSmrg      case $arg in
6570f3561b8bSmrg      -shared)
65716257f37dSmrg	test yes != "$build_libtool_libs" \
65726257f37dSmrg	  && func_fatal_configuration "cannot build a shared library"
6573f3561b8bSmrg	build_old_libs=no
6574f3561b8bSmrg	break
6575f3561b8bSmrg	;;
6576f3561b8bSmrg      -all-static | -static | -static-libtool-libs)
6577f3561b8bSmrg	case $arg in
6578f3561b8bSmrg	-all-static)
65796257f37dSmrg	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
6580f3561b8bSmrg	    func_warning "complete static linking is impossible in this configuration"
6581f3561b8bSmrg	  fi
6582f3561b8bSmrg	  if test -n "$link_static_flag"; then
6583f3561b8bSmrg	    dlopen_self=$dlopen_self_static
6584f3561b8bSmrg	  fi
6585f3561b8bSmrg	  prefer_static_libs=yes
6586f3561b8bSmrg	  ;;
6587f3561b8bSmrg	-static)
6588f3561b8bSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
6589f3561b8bSmrg	    dlopen_self=$dlopen_self_static
6590f3561b8bSmrg	  fi
6591f3561b8bSmrg	  prefer_static_libs=built
6592f3561b8bSmrg	  ;;
6593f3561b8bSmrg	-static-libtool-libs)
6594f3561b8bSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
6595f3561b8bSmrg	    dlopen_self=$dlopen_self_static
6596fc5a983dSmrg	  fi
6597f3561b8bSmrg	  prefer_static_libs=yes
6598f3561b8bSmrg	  ;;
6599f3561b8bSmrg	esac
6600f3561b8bSmrg	build_libtool_libs=no
6601f3561b8bSmrg	build_old_libs=yes
6602f3561b8bSmrg	break
6603f3561b8bSmrg	;;
6604f3561b8bSmrg      esac
6605f3561b8bSmrg    done
6606fc5a983dSmrg
6607f3561b8bSmrg    # See if our shared archives depend on static archives.
6608f3561b8bSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
6609fc5a983dSmrg
6610f3561b8bSmrg    # Go through the arguments, transforming them on the way.
6611f3561b8bSmrg    while test "$#" -gt 0; do
66126257f37dSmrg      arg=$1
6613f3561b8bSmrg      shift
6614f3561b8bSmrg      func_quote_for_eval "$arg"
6615f3561b8bSmrg      qarg=$func_quote_for_eval_unquoted_result
6616f3561b8bSmrg      func_append libtool_args " $func_quote_for_eval_result"
6617fc5a983dSmrg
6618f3561b8bSmrg      # If the previous option needs an argument, assign it.
6619f3561b8bSmrg      if test -n "$prev"; then
6620f3561b8bSmrg	case $prev in
6621f3561b8bSmrg	output)
6622f3561b8bSmrg	  func_append compile_command " @OUTPUT@"
6623f3561b8bSmrg	  func_append finalize_command " @OUTPUT@"
6624f3561b8bSmrg	  ;;
6625f3561b8bSmrg	esac
6626fc5a983dSmrg
6627f3561b8bSmrg	case $prev in
6628bd304fc0Smrg	bindir)
66296257f37dSmrg	  bindir=$arg
6630bd304fc0Smrg	  prev=
6631bd304fc0Smrg	  continue
6632bd304fc0Smrg	  ;;
6633f3561b8bSmrg	dlfiles|dlprefiles)
66346257f37dSmrg	  $preload || {
6635f3561b8bSmrg	    # Add the symbol object into the linking commands.
6636f3561b8bSmrg	    func_append compile_command " @SYMFILE@"
6637f3561b8bSmrg	    func_append finalize_command " @SYMFILE@"
66386257f37dSmrg	    preload=:
66396257f37dSmrg	  }
6640f3561b8bSmrg	  case $arg in
6641f3561b8bSmrg	  *.la | *.lo) ;;  # We handle these cases below.
6642f3561b8bSmrg	  force)
66436257f37dSmrg	    if test no = "$dlself"; then
6644f3561b8bSmrg	      dlself=needless
6645f3561b8bSmrg	      export_dynamic=yes
6646f3561b8bSmrg	    fi
6647f3561b8bSmrg	    prev=
6648f3561b8bSmrg	    continue
6649f3561b8bSmrg	    ;;
6650f3561b8bSmrg	  self)
66516257f37dSmrg	    if test dlprefiles = "$prev"; then
6652f3561b8bSmrg	      dlself=yes
66536257f37dSmrg	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
6654f3561b8bSmrg	      dlself=yes
6655fc5a983dSmrg	    else
6656f3561b8bSmrg	      dlself=needless
6657f3561b8bSmrg	      export_dynamic=yes
6658fc5a983dSmrg	    fi
6659f3561b8bSmrg	    prev=
6660f3561b8bSmrg	    continue
6661f3561b8bSmrg	    ;;
6662f3561b8bSmrg	  *)
66636257f37dSmrg	    if test dlfiles = "$prev"; then
6664bd304fc0Smrg	      func_append dlfiles " $arg"
6665fc5a983dSmrg	    else
6666bd304fc0Smrg	      func_append dlprefiles " $arg"
6667fc5a983dSmrg	    fi
6668f3561b8bSmrg	    prev=
6669f3561b8bSmrg	    continue
6670f3561b8bSmrg	    ;;
6671f3561b8bSmrg	  esac
6672f3561b8bSmrg	  ;;
6673f3561b8bSmrg	expsyms)
66746257f37dSmrg	  export_symbols=$arg
6675f3561b8bSmrg	  test -f "$arg" \
66766257f37dSmrg	    || func_fatal_error "symbol file '$arg' does not exist"
6677f3561b8bSmrg	  prev=
6678f3561b8bSmrg	  continue
6679f3561b8bSmrg	  ;;
6680f3561b8bSmrg	expsyms_regex)
66816257f37dSmrg	  export_symbols_regex=$arg
6682f3561b8bSmrg	  prev=
6683f3561b8bSmrg	  continue
6684f3561b8bSmrg	  ;;
6685f3561b8bSmrg	framework)
6686fc5a983dSmrg	  case $host in
6687f3561b8bSmrg	    *-*-darwin*)
6688f3561b8bSmrg	      case "$deplibs " in
6689f3561b8bSmrg		*" $qarg.ltframework "*) ;;
6690bd304fc0Smrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
6691f3561b8bSmrg		   ;;
6692f3561b8bSmrg	      esac
6693f3561b8bSmrg	      ;;
6694fc5a983dSmrg	  esac
6695f3561b8bSmrg	  prev=
6696f3561b8bSmrg	  continue
6697fc5a983dSmrg	  ;;
6698f3561b8bSmrg	inst_prefix)
66996257f37dSmrg	  inst_prefix_dir=$arg
67006257f37dSmrg	  prev=
67016257f37dSmrg	  continue
67026257f37dSmrg	  ;;
67036257f37dSmrg	mllvm)
67046257f37dSmrg	  # Clang does not use LLVM to link, so we can simply discard any
67056257f37dSmrg	  # '-mllvm $arg' options when doing the link step.
6706f3561b8bSmrg	  prev=
6707f3561b8bSmrg	  continue
6708fc5a983dSmrg	  ;;
6709f3561b8bSmrg	objectlist)
6710f3561b8bSmrg	  if test -f "$arg"; then
6711f3561b8bSmrg	    save_arg=$arg
6712f3561b8bSmrg	    moreargs=
6713f3561b8bSmrg	    for fil in `cat "$save_arg"`
6714f3561b8bSmrg	    do
6715bd304fc0Smrg#	      func_append moreargs " $fil"
6716f3561b8bSmrg	      arg=$fil
6717f3561b8bSmrg	      # A libtool-controlled object.
6718fc5a983dSmrg
6719f3561b8bSmrg	      # Check to see that this really is a libtool object.
6720f3561b8bSmrg	      if func_lalib_unsafe_p "$arg"; then
6721f3561b8bSmrg		pic_object=
6722f3561b8bSmrg		non_pic_object=
6723fc5a983dSmrg
6724f3561b8bSmrg		# Read the .lo file
6725f3561b8bSmrg		func_source "$arg"
6726fc5a983dSmrg
6727f3561b8bSmrg		if test -z "$pic_object" ||
6728f3561b8bSmrg		   test -z "$non_pic_object" ||
67296257f37dSmrg		   test none = "$pic_object" &&
67306257f37dSmrg		   test none = "$non_pic_object"; then
67316257f37dSmrg		  func_fatal_error "cannot find name of object for '$arg'"
6732f3561b8bSmrg		fi
6733fc5a983dSmrg
6734f3561b8bSmrg		# Extract subdirectory from the argument.
6735f3561b8bSmrg		func_dirname "$arg" "/" ""
67366257f37dSmrg		xdir=$func_dirname_result
6737fc5a983dSmrg
67386257f37dSmrg		if test none != "$pic_object"; then
6739f3561b8bSmrg		  # Prepend the subdirectory the object is found in.
67406257f37dSmrg		  pic_object=$xdir$pic_object
6741fc5a983dSmrg
67426257f37dSmrg		  if test dlfiles = "$prev"; then
67436257f37dSmrg		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
6744bd304fc0Smrg		      func_append dlfiles " $pic_object"
6745f3561b8bSmrg		      prev=
6746f3561b8bSmrg		      continue
6747f3561b8bSmrg		    else
6748f3561b8bSmrg		      # If libtool objects are unsupported, then we need to preload.
6749f3561b8bSmrg		      prev=dlprefiles
6750f3561b8bSmrg		    fi
6751f3561b8bSmrg		  fi
6752fc5a983dSmrg
6753f3561b8bSmrg		  # CHECK ME:  I think I busted this.  -Ossama
67546257f37dSmrg		  if test dlprefiles = "$prev"; then
6755f3561b8bSmrg		    # Preload the old-style object.
6756bd304fc0Smrg		    func_append dlprefiles " $pic_object"
6757f3561b8bSmrg		    prev=
6758f3561b8bSmrg		  fi
6759fc5a983dSmrg
6760f3561b8bSmrg		  # A PIC object.
6761f3561b8bSmrg		  func_append libobjs " $pic_object"
67626257f37dSmrg		  arg=$pic_object
6763f3561b8bSmrg		fi
6764fc5a983dSmrg
6765f3561b8bSmrg		# Non-PIC object.
67666257f37dSmrg		if test none != "$non_pic_object"; then
6767f3561b8bSmrg		  # Prepend the subdirectory the object is found in.
67686257f37dSmrg		  non_pic_object=$xdir$non_pic_object
6769fc5a983dSmrg
6770f3561b8bSmrg		  # A standard non-PIC object
6771f3561b8bSmrg		  func_append non_pic_objects " $non_pic_object"
67726257f37dSmrg		  if test -z "$pic_object" || test none = "$pic_object"; then
67736257f37dSmrg		    arg=$non_pic_object
6774f3561b8bSmrg		  fi
6775f3561b8bSmrg		else
6776f3561b8bSmrg		  # If the PIC object exists, use it instead.
6777f3561b8bSmrg		  # $xdir was prepended to $pic_object above.
67786257f37dSmrg		  non_pic_object=$pic_object
6779f3561b8bSmrg		  func_append non_pic_objects " $non_pic_object"
6780f3561b8bSmrg		fi
6781f3561b8bSmrg	      else
6782f3561b8bSmrg		# Only an error if not doing a dry-run.
6783f3561b8bSmrg		if $opt_dry_run; then
6784f3561b8bSmrg		  # Extract subdirectory from the argument.
6785f3561b8bSmrg		  func_dirname "$arg" "/" ""
67866257f37dSmrg		  xdir=$func_dirname_result
6787f3561b8bSmrg
6788f3561b8bSmrg		  func_lo2o "$arg"
6789f3561b8bSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
6790f3561b8bSmrg		  non_pic_object=$xdir$func_lo2o_result
6791f3561b8bSmrg		  func_append libobjs " $pic_object"
6792f3561b8bSmrg		  func_append non_pic_objects " $non_pic_object"
6793f3561b8bSmrg	        else
67946257f37dSmrg		  func_fatal_error "'$arg' is not a valid libtool object"
6795f3561b8bSmrg		fi
6796f3561b8bSmrg	      fi
6797f3561b8bSmrg	    done
6798fc5a983dSmrg	  else
67996257f37dSmrg	    func_fatal_error "link input file '$arg' does not exist"
6800fc5a983dSmrg	  fi
6801f3561b8bSmrg	  arg=$save_arg
6802f3561b8bSmrg	  prev=
6803f3561b8bSmrg	  continue
6804f3561b8bSmrg	  ;;
68056257f37dSmrg	os2dllname)
68066257f37dSmrg	  os2dllname=$arg
68076257f37dSmrg	  prev=
68086257f37dSmrg	  continue
68096257f37dSmrg	  ;;
6810f3561b8bSmrg	precious_regex)
68116257f37dSmrg	  precious_files_regex=$arg
6812f3561b8bSmrg	  prev=
6813f3561b8bSmrg	  continue
6814f3561b8bSmrg	  ;;
6815f3561b8bSmrg	release)
68166257f37dSmrg	  release=-$arg
6817f3561b8bSmrg	  prev=
6818f3561b8bSmrg	  continue
6819f3561b8bSmrg	  ;;
6820f3561b8bSmrg	rpath | xrpath)
6821f3561b8bSmrg	  # We need an absolute path.
6822f3561b8bSmrg	  case $arg in
6823f3561b8bSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
6824f3561b8bSmrg	  *)
6825f3561b8bSmrg	    func_fatal_error "only absolute run-paths are allowed"
6826f3561b8bSmrg	    ;;
6827f3561b8bSmrg	  esac
68286257f37dSmrg	  if test rpath = "$prev"; then
6829f3561b8bSmrg	    case "$rpath " in
6830f3561b8bSmrg	    *" $arg "*) ;;
6831bd304fc0Smrg	    *) func_append rpath " $arg" ;;
6832f3561b8bSmrg	    esac
6833fc5a983dSmrg	  else
6834f3561b8bSmrg	    case "$xrpath " in
6835f3561b8bSmrg	    *" $arg "*) ;;
6836bd304fc0Smrg	    *) func_append xrpath " $arg" ;;
6837f3561b8bSmrg	    esac
6838fc5a983dSmrg	  fi
6839f3561b8bSmrg	  prev=
6840f3561b8bSmrg	  continue
6841f3561b8bSmrg	  ;;
6842f3561b8bSmrg	shrext)
68436257f37dSmrg	  shrext_cmds=$arg
6844f3561b8bSmrg	  prev=
6845f3561b8bSmrg	  continue
6846f3561b8bSmrg	  ;;
6847f3561b8bSmrg	weak)
6848bd304fc0Smrg	  func_append weak_libs " $arg"
6849f3561b8bSmrg	  prev=
6850f3561b8bSmrg	  continue
6851f3561b8bSmrg	  ;;
6852f3561b8bSmrg	xcclinker)
6853bd304fc0Smrg	  func_append linker_flags " $qarg"
6854bd304fc0Smrg	  func_append compiler_flags " $qarg"
6855f3561b8bSmrg	  prev=
6856f3561b8bSmrg	  func_append compile_command " $qarg"
6857f3561b8bSmrg	  func_append finalize_command " $qarg"
6858f3561b8bSmrg	  continue
6859f3561b8bSmrg	  ;;
6860f3561b8bSmrg	xcompiler)
6861bd304fc0Smrg	  func_append compiler_flags " $qarg"
6862f3561b8bSmrg	  prev=
6863f3561b8bSmrg	  func_append compile_command " $qarg"
6864f3561b8bSmrg	  func_append finalize_command " $qarg"
6865f3561b8bSmrg	  continue
6866f3561b8bSmrg	  ;;
6867f3561b8bSmrg	xlinker)
6868bd304fc0Smrg	  func_append linker_flags " $qarg"
6869bd304fc0Smrg	  func_append compiler_flags " $wl$qarg"
6870f3561b8bSmrg	  prev=
6871f3561b8bSmrg	  func_append compile_command " $wl$qarg"
6872f3561b8bSmrg	  func_append finalize_command " $wl$qarg"
6873f3561b8bSmrg	  continue
6874f3561b8bSmrg	  ;;
6875f3561b8bSmrg	*)
6876f3561b8bSmrg	  eval "$prev=\"\$arg\""
6877f3561b8bSmrg	  prev=
6878f3561b8bSmrg	  continue
6879f3561b8bSmrg	  ;;
6880fc5a983dSmrg	esac
6881f3561b8bSmrg      fi # test -n "$prev"
6882fc5a983dSmrg
68836257f37dSmrg      prevarg=$arg
6884fc5a983dSmrg
6885f3561b8bSmrg      case $arg in
6886f3561b8bSmrg      -all-static)
6887f3561b8bSmrg	if test -n "$link_static_flag"; then
6888f3561b8bSmrg	  # See comment for -static flag below, for more details.
6889f3561b8bSmrg	  func_append compile_command " $link_static_flag"
6890f3561b8bSmrg	  func_append finalize_command " $link_static_flag"
6891f3561b8bSmrg	fi
6892f3561b8bSmrg	continue
6893f3561b8bSmrg	;;
6894fc5a983dSmrg
6895f3561b8bSmrg      -allow-undefined)
6896f3561b8bSmrg	# FIXME: remove this flag sometime in the future.
68976257f37dSmrg	func_fatal_error "'-allow-undefined' must not be used because it is the default"
6898f3561b8bSmrg	;;
6899fc5a983dSmrg
6900f3561b8bSmrg      -avoid-version)
6901f3561b8bSmrg	avoid_version=yes
6902f3561b8bSmrg	continue
6903f3561b8bSmrg	;;
6904fc5a983dSmrg
6905bd304fc0Smrg      -bindir)
6906bd304fc0Smrg	prev=bindir
6907bd304fc0Smrg	continue
6908bd304fc0Smrg	;;
6909bd304fc0Smrg
6910f3561b8bSmrg      -dlopen)
6911f3561b8bSmrg	prev=dlfiles
6912f3561b8bSmrg	continue
6913f3561b8bSmrg	;;
6914fc5a983dSmrg
6915f3561b8bSmrg      -dlpreopen)
6916f3561b8bSmrg	prev=dlprefiles
6917f3561b8bSmrg	continue
6918f3561b8bSmrg	;;
6919fc5a983dSmrg
6920f3561b8bSmrg      -export-dynamic)
6921f3561b8bSmrg	export_dynamic=yes
6922f3561b8bSmrg	continue
6923f3561b8bSmrg	;;
6924fc5a983dSmrg
6925f3561b8bSmrg      -export-symbols | -export-symbols-regex)
6926f3561b8bSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
6927f3561b8bSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
6928f3561b8bSmrg	fi
69296257f37dSmrg	if test X-export-symbols = "X$arg"; then
6930f3561b8bSmrg	  prev=expsyms
6931f3561b8bSmrg	else
6932f3561b8bSmrg	  prev=expsyms_regex
6933f3561b8bSmrg	fi
6934f3561b8bSmrg	continue
6935f3561b8bSmrg	;;
6936fc5a983dSmrg
6937f3561b8bSmrg      -framework)
6938f3561b8bSmrg	prev=framework
6939f3561b8bSmrg	continue
6940f3561b8bSmrg	;;
6941fc5a983dSmrg
6942f3561b8bSmrg      -inst-prefix-dir)
6943f3561b8bSmrg	prev=inst_prefix
6944f3561b8bSmrg	continue
6945f3561b8bSmrg	;;
6946fc5a983dSmrg
6947f3561b8bSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
6948f3561b8bSmrg      # so, if we see these flags be careful not to treat them like -L
6949f3561b8bSmrg      -L[A-Z][A-Z]*:*)
6950f3561b8bSmrg	case $with_gcc/$host in
6951f3561b8bSmrg	no/*-*-irix* | /*-*-irix*)
6952f3561b8bSmrg	  func_append compile_command " $arg"
6953f3561b8bSmrg	  func_append finalize_command " $arg"
6954f3561b8bSmrg	  ;;
6955f3561b8bSmrg	esac
6956f3561b8bSmrg	continue
6957f3561b8bSmrg	;;
6958fc5a983dSmrg
6959f3561b8bSmrg      -L*)
6960bd304fc0Smrg	func_stripname "-L" '' "$arg"
6961bd304fc0Smrg	if test -z "$func_stripname_result"; then
6962f3561b8bSmrg	  if test "$#" -gt 0; then
69636257f37dSmrg	    func_fatal_error "require no space between '-L' and '$1'"
6964f3561b8bSmrg	  else
69656257f37dSmrg	    func_fatal_error "need path for '-L' option"
6966f3561b8bSmrg	  fi
6967f3561b8bSmrg	fi
6968bd304fc0Smrg	func_resolve_sysroot "$func_stripname_result"
6969bd304fc0Smrg	dir=$func_resolve_sysroot_result
6970f3561b8bSmrg	# We need an absolute path.
6971f3561b8bSmrg	case $dir in
6972f3561b8bSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
6973f3561b8bSmrg	*)
6974f3561b8bSmrg	  absdir=`cd "$dir" && pwd`
6975f3561b8bSmrg	  test -z "$absdir" && \
69766257f37dSmrg	    func_fatal_error "cannot determine absolute directory name of '$dir'"
69776257f37dSmrg	  dir=$absdir
6978f3561b8bSmrg	  ;;
6979f3561b8bSmrg	esac
6980f3561b8bSmrg	case "$deplibs " in
6981bd304fc0Smrg	*" -L$dir "* | *" $arg "*)
6982bd304fc0Smrg	  # Will only happen for absolute or sysroot arguments
6983bd304fc0Smrg	  ;;
6984f3561b8bSmrg	*)
6985bd304fc0Smrg	  # Preserve sysroot, but never include relative directories
6986bd304fc0Smrg	  case $dir in
6987bd304fc0Smrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
6988bd304fc0Smrg	    *) func_append deplibs " -L$dir" ;;
6989bd304fc0Smrg	  esac
6990bd304fc0Smrg	  func_append lib_search_path " $dir"
6991f3561b8bSmrg	  ;;
6992f3561b8bSmrg	esac
6993f3561b8bSmrg	case $host in
6994f3561b8bSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6995bd304fc0Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
6996f3561b8bSmrg	  case :$dllsearchpath: in
6997f3561b8bSmrg	  *":$dir:"*) ;;
6998f3561b8bSmrg	  ::) dllsearchpath=$dir;;
6999bd304fc0Smrg	  *) func_append dllsearchpath ":$dir";;
7000f3561b8bSmrg	  esac
7001f3561b8bSmrg	  case :$dllsearchpath: in
7002f3561b8bSmrg	  *":$testbindir:"*) ;;
7003f3561b8bSmrg	  ::) dllsearchpath=$testbindir;;
7004bd304fc0Smrg	  *) func_append dllsearchpath ":$testbindir";;
7005f3561b8bSmrg	  esac
7006f3561b8bSmrg	  ;;
7007f3561b8bSmrg	esac
7008f3561b8bSmrg	continue
7009f3561b8bSmrg	;;
7010fc5a983dSmrg
7011f3561b8bSmrg      -l*)
70126257f37dSmrg	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
7013f3561b8bSmrg	  case $host in
7014bd304fc0Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
7015f3561b8bSmrg	    # These systems don't actually have a C or math library (as such)
7016f3561b8bSmrg	    continue
7017f3561b8bSmrg	    ;;
7018f3561b8bSmrg	  *-*-os2*)
7019f3561b8bSmrg	    # These systems don't actually have a C library (as such)
70206257f37dSmrg	    test X-lc = "X$arg" && continue
7021f3561b8bSmrg	    ;;
70226257f37dSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
7023f3561b8bSmrg	    # Do not include libc due to us having libc/libc_r.
70246257f37dSmrg	    test X-lc = "X$arg" && continue
7025f3561b8bSmrg	    ;;
7026f3561b8bSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
7027f3561b8bSmrg	    # Rhapsody C and math libraries are in the System framework
7028bd304fc0Smrg	    func_append deplibs " System.ltframework"
7029f3561b8bSmrg	    continue
7030f3561b8bSmrg	    ;;
7031f3561b8bSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
7032f3561b8bSmrg	    # Causes problems with __ctype
70336257f37dSmrg	    test X-lc = "X$arg" && continue
7034f3561b8bSmrg	    ;;
7035f3561b8bSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7036f3561b8bSmrg	    # Compiler inserts libc in the correct place for threads to work
70376257f37dSmrg	    test X-lc = "X$arg" && continue
7038f3561b8bSmrg	    ;;
7039f3561b8bSmrg	  esac
70406257f37dSmrg	elif test X-lc_r = "X$arg"; then
7041f3561b8bSmrg	 case $host in
70426257f37dSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
7043f3561b8bSmrg	   # Do not include libc_r directly, use -pthread flag.
7044f3561b8bSmrg	   continue
7045f3561b8bSmrg	   ;;
7046f3561b8bSmrg	 esac
7047f3561b8bSmrg	fi
7048bd304fc0Smrg	func_append deplibs " $arg"
7049f3561b8bSmrg	continue
7050f3561b8bSmrg	;;
7051fc5a983dSmrg
70526257f37dSmrg      -mllvm)
70536257f37dSmrg	prev=mllvm
70546257f37dSmrg	continue
70556257f37dSmrg	;;
70566257f37dSmrg
7057f3561b8bSmrg      -module)
7058f3561b8bSmrg	module=yes
7059f3561b8bSmrg	continue
7060f3561b8bSmrg	;;
7061fc5a983dSmrg
7062f3561b8bSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
7063f3561b8bSmrg      # classes, name mangling, and exception handling.
7064f3561b8bSmrg      # Darwin uses the -arch flag to determine output architecture.
7065bd304fc0Smrg      -model|-arch|-isysroot|--sysroot)
7066bd304fc0Smrg	func_append compiler_flags " $arg"
7067f3561b8bSmrg	func_append compile_command " $arg"
7068f3561b8bSmrg	func_append finalize_command " $arg"
7069f3561b8bSmrg	prev=xcompiler
7070f3561b8bSmrg	continue
7071f3561b8bSmrg	;;
7072fc5a983dSmrg
7073bd304fc0Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7074bd304fc0Smrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7075bd304fc0Smrg	func_append compiler_flags " $arg"
7076f3561b8bSmrg	func_append compile_command " $arg"
7077f3561b8bSmrg	func_append finalize_command " $arg"
7078f3561b8bSmrg	case "$new_inherited_linker_flags " in
7079f3561b8bSmrg	    *" $arg "*) ;;
7080bd304fc0Smrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
7081f3561b8bSmrg	esac
7082f3561b8bSmrg	continue
7083f3561b8bSmrg	;;
7084fc5a983dSmrg
7085f3561b8bSmrg      -multi_module)
70866257f37dSmrg	single_module=$wl-multi_module
7087f3561b8bSmrg	continue
7088f3561b8bSmrg	;;
7089fc5a983dSmrg
7090f3561b8bSmrg      -no-fast-install)
7091f3561b8bSmrg	fast_install=no
7092f3561b8bSmrg	continue
7093f3561b8bSmrg	;;
7094fc5a983dSmrg
7095f3561b8bSmrg      -no-install)
7096f3561b8bSmrg	case $host in
7097f3561b8bSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
7098f3561b8bSmrg	  # The PATH hackery in wrapper scripts is required on Windows
7099f3561b8bSmrg	  # and Darwin in order for the loader to find any dlls it needs.
71006257f37dSmrg	  func_warning "'-no-install' is ignored for $host"
71016257f37dSmrg	  func_warning "assuming '-no-fast-install' instead"
7102f3561b8bSmrg	  fast_install=no
7103f3561b8bSmrg	  ;;
7104f3561b8bSmrg	*) no_install=yes ;;
7105f3561b8bSmrg	esac
7106f3561b8bSmrg	continue
7107f3561b8bSmrg	;;
7108fc5a983dSmrg
7109f3561b8bSmrg      -no-undefined)
7110f3561b8bSmrg	allow_undefined=no
7111f3561b8bSmrg	continue
7112f3561b8bSmrg	;;
7113fc5a983dSmrg
7114f3561b8bSmrg      -objectlist)
7115f3561b8bSmrg	prev=objectlist
7116f3561b8bSmrg	continue
7117f3561b8bSmrg	;;
7118fc5a983dSmrg
71196257f37dSmrg      -os2dllname)
71206257f37dSmrg	prev=os2dllname
71216257f37dSmrg	continue
71226257f37dSmrg	;;
71236257f37dSmrg
7124f3561b8bSmrg      -o) prev=output ;;
7125fc5a983dSmrg
7126f3561b8bSmrg      -precious-files-regex)
7127f3561b8bSmrg	prev=precious_regex
7128f3561b8bSmrg	continue
7129f3561b8bSmrg	;;
7130fc5a983dSmrg
7131f3561b8bSmrg      -release)
7132f3561b8bSmrg	prev=release
7133f3561b8bSmrg	continue
7134f3561b8bSmrg	;;
7135fc5a983dSmrg
7136f3561b8bSmrg      -rpath)
7137f3561b8bSmrg	prev=rpath
7138f3561b8bSmrg	continue
7139f3561b8bSmrg	;;
7140fc5a983dSmrg
7141f3561b8bSmrg      -R)
7142f3561b8bSmrg	prev=xrpath
7143f3561b8bSmrg	continue
7144f3561b8bSmrg	;;
7145fc5a983dSmrg
7146f3561b8bSmrg      -R*)
7147f3561b8bSmrg	func_stripname '-R' '' "$arg"
7148f3561b8bSmrg	dir=$func_stripname_result
7149f3561b8bSmrg	# We need an absolute path.
7150f3561b8bSmrg	case $dir in
7151f3561b8bSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
7152bd304fc0Smrg	=*)
7153bd304fc0Smrg	  func_stripname '=' '' "$dir"
7154bd304fc0Smrg	  dir=$lt_sysroot$func_stripname_result
7155bd304fc0Smrg	  ;;
7156f3561b8bSmrg	*)
7157f3561b8bSmrg	  func_fatal_error "only absolute run-paths are allowed"
7158f3561b8bSmrg	  ;;
7159f3561b8bSmrg	esac
7160f3561b8bSmrg	case "$xrpath " in
7161f3561b8bSmrg	*" $dir "*) ;;
7162bd304fc0Smrg	*) func_append xrpath " $dir" ;;
7163f3561b8bSmrg	esac
7164f3561b8bSmrg	continue
7165f3561b8bSmrg	;;
7166fc5a983dSmrg
7167f3561b8bSmrg      -shared)
7168f3561b8bSmrg	# The effects of -shared are defined in a previous loop.
7169f3561b8bSmrg	continue
7170f3561b8bSmrg	;;
7171fc5a983dSmrg
7172f3561b8bSmrg      -shrext)
7173f3561b8bSmrg	prev=shrext
7174f3561b8bSmrg	continue
7175f3561b8bSmrg	;;
7176fc5a983dSmrg
7177f3561b8bSmrg      -static | -static-libtool-libs)
7178f3561b8bSmrg	# The effects of -static are defined in a previous loop.
7179f3561b8bSmrg	# We used to do the same as -all-static on platforms that
7180f3561b8bSmrg	# didn't have a PIC flag, but the assumption that the effects
7181f3561b8bSmrg	# would be equivalent was wrong.  It would break on at least
7182f3561b8bSmrg	# Digital Unix and AIX.
7183f3561b8bSmrg	continue
7184f3561b8bSmrg	;;
7185fc5a983dSmrg
7186f3561b8bSmrg      -thread-safe)
7187f3561b8bSmrg	thread_safe=yes
7188f3561b8bSmrg	continue
7189f3561b8bSmrg	;;
7190fc5a983dSmrg
7191f3561b8bSmrg      -version-info)
7192f3561b8bSmrg	prev=vinfo
7193f3561b8bSmrg	continue
7194f3561b8bSmrg	;;
7195fc5a983dSmrg
7196f3561b8bSmrg      -version-number)
7197f3561b8bSmrg	prev=vinfo
7198f3561b8bSmrg	vinfo_number=yes
7199f3561b8bSmrg	continue
7200f3561b8bSmrg	;;
7201fc5a983dSmrg
7202f3561b8bSmrg      -weak)
7203f3561b8bSmrg        prev=weak
7204f3561b8bSmrg	continue
7205f3561b8bSmrg	;;
7206fc5a983dSmrg
7207f3561b8bSmrg      -Wc,*)
7208f3561b8bSmrg	func_stripname '-Wc,' '' "$arg"
7209f3561b8bSmrg	args=$func_stripname_result
7210f3561b8bSmrg	arg=
72116257f37dSmrg	save_ifs=$IFS; IFS=,
7212f3561b8bSmrg	for flag in $args; do
72136257f37dSmrg	  IFS=$save_ifs
7214f3561b8bSmrg          func_quote_for_eval "$flag"
7215bd304fc0Smrg	  func_append arg " $func_quote_for_eval_result"
7216bd304fc0Smrg	  func_append compiler_flags " $func_quote_for_eval_result"
7217f3561b8bSmrg	done
72186257f37dSmrg	IFS=$save_ifs
7219f3561b8bSmrg	func_stripname ' ' '' "$arg"
7220f3561b8bSmrg	arg=$func_stripname_result
7221f3561b8bSmrg	;;
7222fc5a983dSmrg
7223f3561b8bSmrg      -Wl,*)
7224f3561b8bSmrg	func_stripname '-Wl,' '' "$arg"
7225f3561b8bSmrg	args=$func_stripname_result
7226f3561b8bSmrg	arg=
72276257f37dSmrg	save_ifs=$IFS; IFS=,
7228f3561b8bSmrg	for flag in $args; do
72296257f37dSmrg	  IFS=$save_ifs
7230f3561b8bSmrg          func_quote_for_eval "$flag"
7231bd304fc0Smrg	  func_append arg " $wl$func_quote_for_eval_result"
7232bd304fc0Smrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
7233bd304fc0Smrg	  func_append linker_flags " $func_quote_for_eval_result"
7234f3561b8bSmrg	done
72356257f37dSmrg	IFS=$save_ifs
7236f3561b8bSmrg	func_stripname ' ' '' "$arg"
7237f3561b8bSmrg	arg=$func_stripname_result
7238f3561b8bSmrg	;;
7239fc5a983dSmrg
7240f3561b8bSmrg      -Xcompiler)
7241f3561b8bSmrg	prev=xcompiler
7242f3561b8bSmrg	continue
7243f3561b8bSmrg	;;
7244fc5a983dSmrg
7245f3561b8bSmrg      -Xlinker)
7246f3561b8bSmrg	prev=xlinker
7247f3561b8bSmrg	continue
7248f3561b8bSmrg	;;
7249fc5a983dSmrg
7250f3561b8bSmrg      -XCClinker)
7251f3561b8bSmrg	prev=xcclinker
7252f3561b8bSmrg	continue
7253f3561b8bSmrg	;;
7254fc5a983dSmrg
7255f3561b8bSmrg      # -msg_* for osf cc
7256f3561b8bSmrg      -msg_*)
7257f3561b8bSmrg	func_quote_for_eval "$arg"
72586257f37dSmrg	arg=$func_quote_for_eval_result
7259f3561b8bSmrg	;;
7260fc5a983dSmrg
7261bd304fc0Smrg      # Flags to be passed through unchanged, with rationale:
7262bd304fc0Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
7263bd304fc0Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
7264bd304fc0Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
7265bd304fc0Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
7266bd304fc0Smrg      # -q*                  compiler args for the IBM compiler
7267bd304fc0Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
7268bd304fc0Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
7269bd304fc0Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
72706257f37dSmrg      # -fstack-protector*   stack protector flags for GCC
7271bd304fc0Smrg      # @file                GCC response files
7272bd304fc0Smrg      # -tp=*                Portland pgcc target processor selection
7273bd304fc0Smrg      # --sysroot=*          for sysroot support
72746257f37dSmrg      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
72756257f37dSmrg      # -stdlib=*            select c++ std lib with clang
7276f3561b8bSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
7277bd304fc0Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
72786257f37dSmrg      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*)
7279f3561b8bSmrg        func_quote_for_eval "$arg"
72806257f37dSmrg	arg=$func_quote_for_eval_result
7281f3561b8bSmrg        func_append compile_command " $arg"
7282f3561b8bSmrg        func_append finalize_command " $arg"
7283bd304fc0Smrg        func_append compiler_flags " $arg"
7284f3561b8bSmrg        continue
7285f3561b8bSmrg        ;;
7286fc5a983dSmrg
72876257f37dSmrg      -Z*)
72886257f37dSmrg        if test os2 = "`expr $host : '.*\(os2\)'`"; then
72896257f37dSmrg          # OS/2 uses -Zxxx to specify OS/2-specific options
72906257f37dSmrg	  compiler_flags="$compiler_flags $arg"
72916257f37dSmrg	  func_append compile_command " $arg"
72926257f37dSmrg	  func_append finalize_command " $arg"
72936257f37dSmrg	  case $arg in
72946257f37dSmrg	  -Zlinker | -Zstack)
72956257f37dSmrg	    prev=xcompiler
72966257f37dSmrg	    ;;
72976257f37dSmrg	  esac
72986257f37dSmrg	  continue
72996257f37dSmrg        else
73006257f37dSmrg	  # Otherwise treat like 'Some other compiler flag' below
73016257f37dSmrg	  func_quote_for_eval "$arg"
73026257f37dSmrg	  arg=$func_quote_for_eval_result
73036257f37dSmrg        fi
73046257f37dSmrg	;;
73056257f37dSmrg
7306f3561b8bSmrg      # Some other compiler flag.
7307f3561b8bSmrg      -* | +*)
7308f3561b8bSmrg        func_quote_for_eval "$arg"
73096257f37dSmrg	arg=$func_quote_for_eval_result
7310f3561b8bSmrg	;;
7311fc5a983dSmrg
7312f3561b8bSmrg      *.$objext)
7313f3561b8bSmrg	# A standard object.
7314bd304fc0Smrg	func_append objs " $arg"
7315f3561b8bSmrg	;;
7316fc5a983dSmrg
7317f3561b8bSmrg      *.lo)
7318f3561b8bSmrg	# A libtool-controlled object.
7319fc5a983dSmrg
7320f3561b8bSmrg	# Check to see that this really is a libtool object.
7321f3561b8bSmrg	if func_lalib_unsafe_p "$arg"; then
7322f3561b8bSmrg	  pic_object=
7323f3561b8bSmrg	  non_pic_object=
7324fc5a983dSmrg
7325f3561b8bSmrg	  # Read the .lo file
7326f3561b8bSmrg	  func_source "$arg"
7327fc5a983dSmrg
7328f3561b8bSmrg	  if test -z "$pic_object" ||
7329f3561b8bSmrg	     test -z "$non_pic_object" ||
73306257f37dSmrg	     test none = "$pic_object" &&
73316257f37dSmrg	     test none = "$non_pic_object"; then
73326257f37dSmrg	    func_fatal_error "cannot find name of object for '$arg'"
7333f3561b8bSmrg	  fi
7334fc5a983dSmrg
7335f3561b8bSmrg	  # Extract subdirectory from the argument.
7336f3561b8bSmrg	  func_dirname "$arg" "/" ""
73376257f37dSmrg	  xdir=$func_dirname_result
7338fc5a983dSmrg
73396257f37dSmrg	  test none = "$pic_object" || {
7340f3561b8bSmrg	    # Prepend the subdirectory the object is found in.
73416257f37dSmrg	    pic_object=$xdir$pic_object
7342fc5a983dSmrg
73436257f37dSmrg	    if test dlfiles = "$prev"; then
73446257f37dSmrg	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
7345bd304fc0Smrg		func_append dlfiles " $pic_object"
7346f3561b8bSmrg		prev=
7347f3561b8bSmrg		continue
7348f3561b8bSmrg	      else
7349f3561b8bSmrg		# If libtool objects are unsupported, then we need to preload.
7350f3561b8bSmrg		prev=dlprefiles
7351f3561b8bSmrg	      fi
7352f3561b8bSmrg	    fi
7353fc5a983dSmrg
7354f3561b8bSmrg	    # CHECK ME:  I think I busted this.  -Ossama
73556257f37dSmrg	    if test dlprefiles = "$prev"; then
7356f3561b8bSmrg	      # Preload the old-style object.
7357bd304fc0Smrg	      func_append dlprefiles " $pic_object"
7358f3561b8bSmrg	      prev=
7359f3561b8bSmrg	    fi
7360fc5a983dSmrg
7361f3561b8bSmrg	    # A PIC object.
7362f3561b8bSmrg	    func_append libobjs " $pic_object"
73636257f37dSmrg	    arg=$pic_object
73646257f37dSmrg	  }
7365fc5a983dSmrg
7366f3561b8bSmrg	  # Non-PIC object.
73676257f37dSmrg	  if test none != "$non_pic_object"; then
7368f3561b8bSmrg	    # Prepend the subdirectory the object is found in.
73696257f37dSmrg	    non_pic_object=$xdir$non_pic_object
7370fc5a983dSmrg
7371f3561b8bSmrg	    # A standard non-PIC object
7372f3561b8bSmrg	    func_append non_pic_objects " $non_pic_object"
73736257f37dSmrg	    if test -z "$pic_object" || test none = "$pic_object"; then
73746257f37dSmrg	      arg=$non_pic_object
7375f3561b8bSmrg	    fi
7376f3561b8bSmrg	  else
7377f3561b8bSmrg	    # If the PIC object exists, use it instead.
7378f3561b8bSmrg	    # $xdir was prepended to $pic_object above.
73796257f37dSmrg	    non_pic_object=$pic_object
7380f3561b8bSmrg	    func_append non_pic_objects " $non_pic_object"
7381f3561b8bSmrg	  fi
7382f3561b8bSmrg	else
7383f3561b8bSmrg	  # Only an error if not doing a dry-run.
7384f3561b8bSmrg	  if $opt_dry_run; then
7385f3561b8bSmrg	    # Extract subdirectory from the argument.
7386f3561b8bSmrg	    func_dirname "$arg" "/" ""
73876257f37dSmrg	    xdir=$func_dirname_result
7388f3561b8bSmrg
7389f3561b8bSmrg	    func_lo2o "$arg"
7390f3561b8bSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
7391f3561b8bSmrg	    non_pic_object=$xdir$func_lo2o_result
7392f3561b8bSmrg	    func_append libobjs " $pic_object"
7393f3561b8bSmrg	    func_append non_pic_objects " $non_pic_object"
7394f3561b8bSmrg	  else
73956257f37dSmrg	    func_fatal_error "'$arg' is not a valid libtool object"
7396f3561b8bSmrg	  fi
7397f3561b8bSmrg	fi
7398f3561b8bSmrg	;;
7399fc5a983dSmrg
7400f3561b8bSmrg      *.$libext)
7401f3561b8bSmrg	# An archive.
7402bd304fc0Smrg	func_append deplibs " $arg"
7403bd304fc0Smrg	func_append old_deplibs " $arg"
7404f3561b8bSmrg	continue
7405f3561b8bSmrg	;;
7406fc5a983dSmrg
7407f3561b8bSmrg      *.la)
7408f3561b8bSmrg	# A libtool-controlled library.
7409fc5a983dSmrg
7410bd304fc0Smrg	func_resolve_sysroot "$arg"
74116257f37dSmrg	if test dlfiles = "$prev"; then
7412f3561b8bSmrg	  # This library was specified with -dlopen.
7413bd304fc0Smrg	  func_append dlfiles " $func_resolve_sysroot_result"
7414f3561b8bSmrg	  prev=
74156257f37dSmrg	elif test dlprefiles = "$prev"; then
7416f3561b8bSmrg	  # The library was specified with -dlpreopen.
7417bd304fc0Smrg	  func_append dlprefiles " $func_resolve_sysroot_result"
7418f3561b8bSmrg	  prev=
7419f3561b8bSmrg	else
7420bd304fc0Smrg	  func_append deplibs " $func_resolve_sysroot_result"
7421f3561b8bSmrg	fi
7422f3561b8bSmrg	continue
7423f3561b8bSmrg	;;
7424fc5a983dSmrg
7425f3561b8bSmrg      # Some other compiler argument.
7426f3561b8bSmrg      *)
7427f3561b8bSmrg	# Unknown arguments in both finalize_command and compile_command need
7428f3561b8bSmrg	# to be aesthetically quoted because they are evaled later.
7429f3561b8bSmrg	func_quote_for_eval "$arg"
74306257f37dSmrg	arg=$func_quote_for_eval_result
7431f3561b8bSmrg	;;
7432f3561b8bSmrg      esac # arg
7433f3561b8bSmrg
7434f3561b8bSmrg      # Now actually substitute the argument into the commands.
7435f3561b8bSmrg      if test -n "$arg"; then
7436f3561b8bSmrg	func_append compile_command " $arg"
7437f3561b8bSmrg	func_append finalize_command " $arg"
7438f3561b8bSmrg      fi
7439f3561b8bSmrg    done # argument parsing loop
7440f3561b8bSmrg
7441f3561b8bSmrg    test -n "$prev" && \
74426257f37dSmrg      func_fatal_help "the '$prevarg' option requires an argument"
7443f3561b8bSmrg
74446257f37dSmrg    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
7445f3561b8bSmrg      eval arg=\"$export_dynamic_flag_spec\"
7446f3561b8bSmrg      func_append compile_command " $arg"
7447f3561b8bSmrg      func_append finalize_command " $arg"
7448f3561b8bSmrg    fi
7449f3561b8bSmrg
7450f3561b8bSmrg    oldlibs=
7451f3561b8bSmrg    # calculate the name of the file, without its directory
7452f3561b8bSmrg    func_basename "$output"
74536257f37dSmrg    outputname=$func_basename_result
74546257f37dSmrg    libobjs_save=$libobjs
7455f3561b8bSmrg
7456f3561b8bSmrg    if test -n "$shlibpath_var"; then
7457f3561b8bSmrg      # get the directories listed in $shlibpath_var
74586257f37dSmrg      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
7459f3561b8bSmrg    else
7460f3561b8bSmrg      shlib_search_path=
7461f3561b8bSmrg    fi
7462f3561b8bSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
7463f3561b8bSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
7464f3561b8bSmrg
74656257f37dSmrg    # Definition is injected by LT_CONFIG during libtool generation.
74666257f37dSmrg    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
74676257f37dSmrg
7468f3561b8bSmrg    func_dirname "$output" "/" ""
74696257f37dSmrg    output_objdir=$func_dirname_result$objdir
7470bd304fc0Smrg    func_to_tool_file "$output_objdir/"
7471bd304fc0Smrg    tool_output_objdir=$func_to_tool_file_result
7472f3561b8bSmrg    # Create the object directory.
7473f3561b8bSmrg    func_mkdir_p "$output_objdir"
7474f3561b8bSmrg
7475f3561b8bSmrg    # Determine the type of output
7476f3561b8bSmrg    case $output in
7477f3561b8bSmrg    "")
7478f3561b8bSmrg      func_fatal_help "you must specify an output file"
7479f3561b8bSmrg      ;;
7480f3561b8bSmrg    *.$libext) linkmode=oldlib ;;
7481f3561b8bSmrg    *.lo | *.$objext) linkmode=obj ;;
7482f3561b8bSmrg    *.la) linkmode=lib ;;
7483f3561b8bSmrg    *) linkmode=prog ;; # Anything else should be a program.
7484f3561b8bSmrg    esac
7485f3561b8bSmrg
7486f3561b8bSmrg    specialdeplibs=
7487f3561b8bSmrg
7488f3561b8bSmrg    libs=
7489f3561b8bSmrg    # Find all interdependent deplibs by searching for libraries
7490f3561b8bSmrg    # that are linked more than once (e.g. -la -lb -la)
7491f3561b8bSmrg    for deplib in $deplibs; do
74926257f37dSmrg      if $opt_preserve_dup_deps; then
7493f3561b8bSmrg	case "$libs " in
7494bd304fc0Smrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
7495f3561b8bSmrg	esac
7496f3561b8bSmrg      fi
7497bd304fc0Smrg      func_append libs " $deplib"
7498f3561b8bSmrg    done
7499f3561b8bSmrg
75006257f37dSmrg    if test lib = "$linkmode"; then
7501f3561b8bSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
7502f3561b8bSmrg
7503f3561b8bSmrg      # Compute libraries that are listed more than once in $predeps
7504f3561b8bSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
7505f3561b8bSmrg      # not to be eliminated).
7506f3561b8bSmrg      pre_post_deps=
7507f3561b8bSmrg      if $opt_duplicate_compiler_generated_deps; then
7508f3561b8bSmrg	for pre_post_dep in $predeps $postdeps; do
7509f3561b8bSmrg	  case "$pre_post_deps " in
7510bd304fc0Smrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
7511f3561b8bSmrg	  esac
7512bd304fc0Smrg	  func_append pre_post_deps " $pre_post_dep"
7513f3561b8bSmrg	done
7514f3561b8bSmrg      fi
7515f3561b8bSmrg      pre_post_deps=
7516f3561b8bSmrg    fi
7517f3561b8bSmrg
7518f3561b8bSmrg    deplibs=
7519f3561b8bSmrg    newdependency_libs=
7520f3561b8bSmrg    newlib_search_path=
7521f3561b8bSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
7522f3561b8bSmrg    notinst_deplibs= # not-installed libtool libraries
7523f3561b8bSmrg    notinst_path= # paths that contain not-installed libtool libraries
7524f3561b8bSmrg
7525f3561b8bSmrg    case $linkmode in
7526f3561b8bSmrg    lib)
7527f3561b8bSmrg	passes="conv dlpreopen link"
7528f3561b8bSmrg	for file in $dlfiles $dlprefiles; do
7529f3561b8bSmrg	  case $file in
7530f3561b8bSmrg	  *.la) ;;
7531f3561b8bSmrg	  *)
75326257f37dSmrg	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
7533f3561b8bSmrg	    ;;
7534f3561b8bSmrg	  esac
7535f3561b8bSmrg	done
7536f3561b8bSmrg	;;
7537f3561b8bSmrg    prog)
7538f3561b8bSmrg	compile_deplibs=
7539f3561b8bSmrg	finalize_deplibs=
75406257f37dSmrg	alldeplibs=false
7541f3561b8bSmrg	newdlfiles=
7542f3561b8bSmrg	newdlprefiles=
7543f3561b8bSmrg	passes="conv scan dlopen dlpreopen link"
7544f3561b8bSmrg	;;
7545f3561b8bSmrg    *)  passes="conv"
7546f3561b8bSmrg	;;
7547f3561b8bSmrg    esac
7548f3561b8bSmrg
7549f3561b8bSmrg    for pass in $passes; do
7550f3561b8bSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
7551f3561b8bSmrg      # so that -L comes before libs that need it for instance...
75526257f37dSmrg      if test lib,link = "$linkmode,$pass"; then
7553f3561b8bSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
7554f3561b8bSmrg	##        order, and fix it there properly
7555f3561b8bSmrg        tmp_deplibs=
7556f3561b8bSmrg	for deplib in $deplibs; do
7557f3561b8bSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
7558f3561b8bSmrg	done
75596257f37dSmrg	deplibs=$tmp_deplibs
7560f3561b8bSmrg      fi
7561f3561b8bSmrg
75626257f37dSmrg      if test lib,link = "$linkmode,$pass" ||
75636257f37dSmrg	 test prog,scan = "$linkmode,$pass"; then
75646257f37dSmrg	libs=$deplibs
7565f3561b8bSmrg	deplibs=
7566f3561b8bSmrg      fi
75676257f37dSmrg      if test prog = "$linkmode"; then
7568f3561b8bSmrg	case $pass in
75696257f37dSmrg	dlopen) libs=$dlfiles ;;
75706257f37dSmrg	dlpreopen) libs=$dlprefiles ;;
7571bd304fc0Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
7572f3561b8bSmrg	esac
7573f3561b8bSmrg      fi
75746257f37dSmrg      if test lib,dlpreopen = "$linkmode,$pass"; then
7575f3561b8bSmrg	# Collect and forward deplibs of preopened libtool libs
7576f3561b8bSmrg	for lib in $dlprefiles; do
7577f3561b8bSmrg	  # Ignore non-libtool-libs
7578f3561b8bSmrg	  dependency_libs=
7579bd304fc0Smrg	  func_resolve_sysroot "$lib"
7580f3561b8bSmrg	  case $lib in
7581bd304fc0Smrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
7582f3561b8bSmrg	  esac
7583f3561b8bSmrg
7584f3561b8bSmrg	  # Collect preopened libtool deplibs, except any this library
7585f3561b8bSmrg	  # has declared as weak libs
7586f3561b8bSmrg	  for deplib in $dependency_libs; do
7587bd304fc0Smrg	    func_basename "$deplib"
7588bd304fc0Smrg            deplib_base=$func_basename_result
7589f3561b8bSmrg	    case " $weak_libs " in
7590f3561b8bSmrg	    *" $deplib_base "*) ;;
7591bd304fc0Smrg	    *) func_append deplibs " $deplib" ;;
7592f3561b8bSmrg	    esac
7593f3561b8bSmrg	  done
7594f3561b8bSmrg	done
75956257f37dSmrg	libs=$dlprefiles
7596f3561b8bSmrg      fi
75976257f37dSmrg      if test dlopen = "$pass"; then
7598f3561b8bSmrg	# Collect dlpreopened libraries
75996257f37dSmrg	save_deplibs=$deplibs
7600f3561b8bSmrg	deplibs=
7601f3561b8bSmrg      fi
7602f3561b8bSmrg
7603f3561b8bSmrg      for deplib in $libs; do
7604f3561b8bSmrg	lib=
76056257f37dSmrg	found=false
7606f3561b8bSmrg	case $deplib in
7607bd304fc0Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7608bd304fc0Smrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
76096257f37dSmrg	  if test prog,link = "$linkmode,$pass"; then
7610f3561b8bSmrg	    compile_deplibs="$deplib $compile_deplibs"
7611f3561b8bSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
7612f3561b8bSmrg	  else
7613bd304fc0Smrg	    func_append compiler_flags " $deplib"
76146257f37dSmrg	    if test lib = "$linkmode"; then
7615f3561b8bSmrg		case "$new_inherited_linker_flags " in
7616f3561b8bSmrg		    *" $deplib "*) ;;
7617bd304fc0Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
7618f3561b8bSmrg		esac
7619f3561b8bSmrg	    fi
7620f3561b8bSmrg	  fi
7621f3561b8bSmrg	  continue
7622f3561b8bSmrg	  ;;
7623f3561b8bSmrg	-l*)
76246257f37dSmrg	  if test lib != "$linkmode" && test prog != "$linkmode"; then
76256257f37dSmrg	    func_warning "'-l' is ignored for archives/objects"
7626f3561b8bSmrg	    continue
7627f3561b8bSmrg	  fi
7628f3561b8bSmrg	  func_stripname '-l' '' "$deplib"
7629f3561b8bSmrg	  name=$func_stripname_result
76306257f37dSmrg	  if test lib = "$linkmode"; then
7631f3561b8bSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
7632f3561b8bSmrg	  else
7633f3561b8bSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
7634f3561b8bSmrg	  fi
7635f3561b8bSmrg	  for searchdir in $searchdirs; do
7636f3561b8bSmrg	    for search_ext in .la $std_shrext .so .a; do
7637f3561b8bSmrg	      # Search the libtool library
76386257f37dSmrg	      lib=$searchdir/lib$name$search_ext
7639f3561b8bSmrg	      if test -f "$lib"; then
76406257f37dSmrg		if test .la = "$search_ext"; then
76416257f37dSmrg		  found=:
7642f3561b8bSmrg		else
76436257f37dSmrg		  found=false
7644f3561b8bSmrg		fi
7645f3561b8bSmrg		break 2
7646f3561b8bSmrg	      fi
7647f3561b8bSmrg	    done
7648f3561b8bSmrg	  done
76496257f37dSmrg	  if $found; then
76506257f37dSmrg	    # deplib is a libtool library
7651f3561b8bSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
7652f3561b8bSmrg	    # We need to do some special things here, and not later.
76536257f37dSmrg	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
7654f3561b8bSmrg	      case " $predeps $postdeps " in
7655f3561b8bSmrg	      *" $deplib "*)
7656f3561b8bSmrg		if func_lalib_p "$lib"; then
7657f3561b8bSmrg		  library_names=
7658f3561b8bSmrg		  old_library=
7659f3561b8bSmrg		  func_source "$lib"
7660f3561b8bSmrg		  for l in $old_library $library_names; do
76616257f37dSmrg		    ll=$l
7662f3561b8bSmrg		  done
76636257f37dSmrg		  if test "X$ll" = "X$old_library"; then # only static version available
76646257f37dSmrg		    found=false
7665f3561b8bSmrg		    func_dirname "$lib" "" "."
76666257f37dSmrg		    ladir=$func_dirname_result
7667f3561b8bSmrg		    lib=$ladir/$old_library
76686257f37dSmrg		    if test prog,link = "$linkmode,$pass"; then
7669f3561b8bSmrg		      compile_deplibs="$deplib $compile_deplibs"
7670f3561b8bSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
7671f3561b8bSmrg		    else
7672f3561b8bSmrg		      deplibs="$deplib $deplibs"
76736257f37dSmrg		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7674f3561b8bSmrg		    fi
7675f3561b8bSmrg		    continue
7676f3561b8bSmrg		  fi
7677f3561b8bSmrg		fi
7678f3561b8bSmrg		;;
7679f3561b8bSmrg	      *) ;;
7680f3561b8bSmrg	      esac
7681f3561b8bSmrg	    fi
76826257f37dSmrg	  else
76836257f37dSmrg	    # deplib doesn't seem to be a libtool library
76846257f37dSmrg	    if test prog,link = "$linkmode,$pass"; then
76856257f37dSmrg	      compile_deplibs="$deplib $compile_deplibs"
76866257f37dSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
76876257f37dSmrg	    else
76886257f37dSmrg	      deplibs="$deplib $deplibs"
76896257f37dSmrg	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
76906257f37dSmrg	    fi
76916257f37dSmrg	    continue
7692f3561b8bSmrg	  fi
7693f3561b8bSmrg	  ;; # -l
7694f3561b8bSmrg	*.ltframework)
76956257f37dSmrg	  if test prog,link = "$linkmode,$pass"; then
7696f3561b8bSmrg	    compile_deplibs="$deplib $compile_deplibs"
7697f3561b8bSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
7698f3561b8bSmrg	  else
7699f3561b8bSmrg	    deplibs="$deplib $deplibs"
77006257f37dSmrg	    if test lib = "$linkmode"; then
7701f3561b8bSmrg		case "$new_inherited_linker_flags " in
7702f3561b8bSmrg		    *" $deplib "*) ;;
7703bd304fc0Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
7704f3561b8bSmrg		esac
7705f3561b8bSmrg	    fi
7706f3561b8bSmrg	  fi
7707f3561b8bSmrg	  continue
7708f3561b8bSmrg	  ;;
7709f3561b8bSmrg	-L*)
7710f3561b8bSmrg	  case $linkmode in
7711f3561b8bSmrg	  lib)
7712f3561b8bSmrg	    deplibs="$deplib $deplibs"
77136257f37dSmrg	    test conv = "$pass" && continue
7714f3561b8bSmrg	    newdependency_libs="$deplib $newdependency_libs"
7715f3561b8bSmrg	    func_stripname '-L' '' "$deplib"
7716bd304fc0Smrg	    func_resolve_sysroot "$func_stripname_result"
7717bd304fc0Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
7718f3561b8bSmrg	    ;;
7719f3561b8bSmrg	  prog)
77206257f37dSmrg	    if test conv = "$pass"; then
7721f3561b8bSmrg	      deplibs="$deplib $deplibs"
7722f3561b8bSmrg	      continue
7723f3561b8bSmrg	    fi
77246257f37dSmrg	    if test scan = "$pass"; then
7725f3561b8bSmrg	      deplibs="$deplib $deplibs"
7726f3561b8bSmrg	    else
7727f3561b8bSmrg	      compile_deplibs="$deplib $compile_deplibs"
7728f3561b8bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
7729f3561b8bSmrg	    fi
7730f3561b8bSmrg	    func_stripname '-L' '' "$deplib"
7731bd304fc0Smrg	    func_resolve_sysroot "$func_stripname_result"
7732bd304fc0Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
7733f3561b8bSmrg	    ;;
7734f3561b8bSmrg	  *)
77356257f37dSmrg	    func_warning "'-L' is ignored for archives/objects"
7736f3561b8bSmrg	    ;;
7737f3561b8bSmrg	  esac # linkmode
7738f3561b8bSmrg	  continue
7739f3561b8bSmrg	  ;; # -L
7740f3561b8bSmrg	-R*)
77416257f37dSmrg	  if test link = "$pass"; then
7742f3561b8bSmrg	    func_stripname '-R' '' "$deplib"
7743bd304fc0Smrg	    func_resolve_sysroot "$func_stripname_result"
7744bd304fc0Smrg	    dir=$func_resolve_sysroot_result
7745f3561b8bSmrg	    # Make sure the xrpath contains only unique directories.
7746f3561b8bSmrg	    case "$xrpath " in
7747f3561b8bSmrg	    *" $dir "*) ;;
7748bd304fc0Smrg	    *) func_append xrpath " $dir" ;;
7749f3561b8bSmrg	    esac
7750f3561b8bSmrg	  fi
7751f3561b8bSmrg	  deplibs="$deplib $deplibs"
7752f3561b8bSmrg	  continue
7753f3561b8bSmrg	  ;;
7754bd304fc0Smrg	*.la)
7755bd304fc0Smrg	  func_resolve_sysroot "$deplib"
7756bd304fc0Smrg	  lib=$func_resolve_sysroot_result
7757bd304fc0Smrg	  ;;
7758f3561b8bSmrg	*.$libext)
77596257f37dSmrg	  if test conv = "$pass"; then
7760f3561b8bSmrg	    deplibs="$deplib $deplibs"
7761f3561b8bSmrg	    continue
7762f3561b8bSmrg	  fi
7763f3561b8bSmrg	  case $linkmode in
7764f3561b8bSmrg	  lib)
7765f3561b8bSmrg	    # Linking convenience modules into shared libraries is allowed,
7766f3561b8bSmrg	    # but linking other static libraries is non-portable.
7767f3561b8bSmrg	    case " $dlpreconveniencelibs " in
7768f3561b8bSmrg	    *" $deplib "*) ;;
7769f3561b8bSmrg	    *)
77706257f37dSmrg	      valid_a_lib=false
7771f3561b8bSmrg	      case $deplibs_check_method in
7772f3561b8bSmrg		match_pattern*)
7773f3561b8bSmrg		  set dummy $deplibs_check_method; shift
7774f3561b8bSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7775bd304fc0Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
7776f3561b8bSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
77776257f37dSmrg		    valid_a_lib=:
7778f3561b8bSmrg		  fi
7779f3561b8bSmrg		;;
7780f3561b8bSmrg		pass_all)
77816257f37dSmrg		  valid_a_lib=:
7782f3561b8bSmrg		;;
7783f3561b8bSmrg	      esac
77846257f37dSmrg	      if $valid_a_lib; then
77856257f37dSmrg		echo
77866257f37dSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
77876257f37dSmrg		$ECHO "*** static library $deplib is not portable!"
77886257f37dSmrg		deplibs="$deplib $deplibs"
77896257f37dSmrg	      else
7790bd304fc0Smrg		echo
7791f3561b8bSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
7792bd304fc0Smrg		echo "*** I have the capability to make that library automatically link in when"
7793bd304fc0Smrg		echo "*** you link to this library.  But I can only do this if you have a"
7794bd304fc0Smrg		echo "*** shared version of the library, which you do not appear to have"
7795bd304fc0Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
7796bd304fc0Smrg		echo "*** that it is just a static archive that I should not use here."
7797f3561b8bSmrg	      fi
7798f3561b8bSmrg	      ;;
7799f3561b8bSmrg	    esac
7800f3561b8bSmrg	    continue
7801f3561b8bSmrg	    ;;
7802f3561b8bSmrg	  prog)
78036257f37dSmrg	    if test link != "$pass"; then
7804f3561b8bSmrg	      deplibs="$deplib $deplibs"
7805f3561b8bSmrg	    else
7806f3561b8bSmrg	      compile_deplibs="$deplib $compile_deplibs"
7807f3561b8bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
7808f3561b8bSmrg	    fi
7809f3561b8bSmrg	    continue
7810f3561b8bSmrg	    ;;
7811f3561b8bSmrg	  esac # linkmode
7812f3561b8bSmrg	  ;; # *.$libext
7813f3561b8bSmrg	*.lo | *.$objext)
78146257f37dSmrg	  if test conv = "$pass"; then
7815f3561b8bSmrg	    deplibs="$deplib $deplibs"
78166257f37dSmrg	  elif test prog = "$linkmode"; then
78176257f37dSmrg	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
7818f3561b8bSmrg	      # If there is no dlopen support or we're linking statically,
7819f3561b8bSmrg	      # we need to preload.
7820bd304fc0Smrg	      func_append newdlprefiles " $deplib"
7821f3561b8bSmrg	      compile_deplibs="$deplib $compile_deplibs"
7822f3561b8bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
7823f3561b8bSmrg	    else
7824bd304fc0Smrg	      func_append newdlfiles " $deplib"
7825f3561b8bSmrg	    fi
7826f3561b8bSmrg	  fi
7827f3561b8bSmrg	  continue
7828f3561b8bSmrg	  ;;
7829f3561b8bSmrg	%DEPLIBS%)
78306257f37dSmrg	  alldeplibs=:
7831f3561b8bSmrg	  continue
7832f3561b8bSmrg	  ;;
7833f3561b8bSmrg	esac # case $deplib
7834f3561b8bSmrg
78356257f37dSmrg	$found || test -f "$lib" \
78366257f37dSmrg	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
7837f3561b8bSmrg
7838f3561b8bSmrg	# Check to see that this really is a libtool archive.
7839f3561b8bSmrg	func_lalib_unsafe_p "$lib" \
78406257f37dSmrg	  || func_fatal_error "'$lib' is not a valid libtool archive"
7841f3561b8bSmrg
7842f3561b8bSmrg	func_dirname "$lib" "" "."
78436257f37dSmrg	ladir=$func_dirname_result
7844f3561b8bSmrg
7845f3561b8bSmrg	dlname=
7846f3561b8bSmrg	dlopen=
7847f3561b8bSmrg	dlpreopen=
7848f3561b8bSmrg	libdir=
7849f3561b8bSmrg	library_names=
7850f3561b8bSmrg	old_library=
7851f3561b8bSmrg	inherited_linker_flags=
7852f3561b8bSmrg	# If the library was installed with an old release of libtool,
7853f3561b8bSmrg	# it will not redefine variables installed, or shouldnotlink
7854f3561b8bSmrg	installed=yes
7855f3561b8bSmrg	shouldnotlink=no
7856f3561b8bSmrg	avoidtemprpath=
7857f3561b8bSmrg
7858f3561b8bSmrg
7859f3561b8bSmrg	# Read the .la file
7860f3561b8bSmrg	func_source "$lib"
7861f3561b8bSmrg
7862f3561b8bSmrg	# Convert "-framework foo" to "foo.ltframework"
7863f3561b8bSmrg	if test -n "$inherited_linker_flags"; then
7864bd304fc0Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
7865f3561b8bSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
7866f3561b8bSmrg	    case " $new_inherited_linker_flags " in
7867f3561b8bSmrg	      *" $tmp_inherited_linker_flag "*) ;;
7868bd304fc0Smrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
7869f3561b8bSmrg	    esac
7870f3561b8bSmrg	  done
7871f3561b8bSmrg	fi
7872bd304fc0Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
78736257f37dSmrg	if test lib,link = "$linkmode,$pass" ||
78746257f37dSmrg	   test prog,scan = "$linkmode,$pass" ||
78756257f37dSmrg	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
7876bd304fc0Smrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
7877bd304fc0Smrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
7878f3561b8bSmrg	fi
7879f3561b8bSmrg
78806257f37dSmrg	if test conv = "$pass"; then
7881f3561b8bSmrg	  # Only check for convenience libraries
7882f3561b8bSmrg	  deplibs="$lib $deplibs"
7883f3561b8bSmrg	  if test -z "$libdir"; then
7884f3561b8bSmrg	    if test -z "$old_library"; then
78856257f37dSmrg	      func_fatal_error "cannot find name of link library for '$lib'"
7886f3561b8bSmrg	    fi
7887f3561b8bSmrg	    # It is a libtool convenience library, so add in its objects.
7888bd304fc0Smrg	    func_append convenience " $ladir/$objdir/$old_library"
7889bd304fc0Smrg	    func_append old_convenience " $ladir/$objdir/$old_library"
78906257f37dSmrg	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
78916257f37dSmrg	    func_fatal_error "'$lib' is not a convenience library"
7892f3561b8bSmrg	  fi
7893bd304fc0Smrg	  tmp_libs=
7894bd304fc0Smrg	  for deplib in $dependency_libs; do
7895bd304fc0Smrg	    deplibs="$deplib $deplibs"
78966257f37dSmrg	    if $opt_preserve_dup_deps; then
7897bd304fc0Smrg	      case "$tmp_libs " in
7898bd304fc0Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
7899bd304fc0Smrg	      esac
7900bd304fc0Smrg	    fi
7901bd304fc0Smrg	    func_append tmp_libs " $deplib"
7902bd304fc0Smrg	  done
7903f3561b8bSmrg	  continue
7904f3561b8bSmrg	fi # $pass = conv
7905f3561b8bSmrg
7906f3561b8bSmrg
7907f3561b8bSmrg	# Get the name of the library we link against.
7908f3561b8bSmrg	linklib=
7909bd304fc0Smrg	if test -n "$old_library" &&
79106257f37dSmrg	   { test yes = "$prefer_static_libs" ||
79116257f37dSmrg	     test built,no = "$prefer_static_libs,$installed"; }; then
7912bd304fc0Smrg	  linklib=$old_library
7913bd304fc0Smrg	else
7914bd304fc0Smrg	  for l in $old_library $library_names; do
79156257f37dSmrg	    linklib=$l
7916bd304fc0Smrg	  done
7917bd304fc0Smrg	fi
7918f3561b8bSmrg	if test -z "$linklib"; then
79196257f37dSmrg	  func_fatal_error "cannot find name of link library for '$lib'"
7920f3561b8bSmrg	fi
7921f3561b8bSmrg
7922f3561b8bSmrg	# This library was specified with -dlopen.
79236257f37dSmrg	if test dlopen = "$pass"; then
79246257f37dSmrg	  test -z "$libdir" \
79256257f37dSmrg	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
7926f3561b8bSmrg	  if test -z "$dlname" ||
79276257f37dSmrg	     test yes != "$dlopen_support" ||
79286257f37dSmrg	     test no = "$build_libtool_libs"
79296257f37dSmrg	  then
7930f3561b8bSmrg	    # If there is no dlname, no dlopen support or we're linking
7931f3561b8bSmrg	    # statically, we need to preload.  We also need to preload any
7932f3561b8bSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
7933f3561b8bSmrg	    # bomb out in the load deplibs phase.
7934bd304fc0Smrg	    func_append dlprefiles " $lib $dependency_libs"
7935f3561b8bSmrg	  else
7936bd304fc0Smrg	    func_append newdlfiles " $lib"
7937f3561b8bSmrg	  fi
7938f3561b8bSmrg	  continue
7939f3561b8bSmrg	fi # $pass = dlopen
7940f3561b8bSmrg
7941f3561b8bSmrg	# We need an absolute path.
7942f3561b8bSmrg	case $ladir in
79436257f37dSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
7944f3561b8bSmrg	*)
7945f3561b8bSmrg	  abs_ladir=`cd "$ladir" && pwd`
7946f3561b8bSmrg	  if test -z "$abs_ladir"; then
79476257f37dSmrg	    func_warning "cannot determine absolute directory name of '$ladir'"
7948f3561b8bSmrg	    func_warning "passing it literally to the linker, although it might fail"
79496257f37dSmrg	    abs_ladir=$ladir
7950f3561b8bSmrg	  fi
7951f3561b8bSmrg	  ;;
7952f3561b8bSmrg	esac
7953f3561b8bSmrg	func_basename "$lib"
79546257f37dSmrg	laname=$func_basename_result
7955f3561b8bSmrg
7956f3561b8bSmrg	# Find the relevant object directory and library name.
79576257f37dSmrg	if test yes = "$installed"; then
7958bd304fc0Smrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
79596257f37dSmrg	    func_warning "library '$lib' was moved."
79606257f37dSmrg	    dir=$ladir
79616257f37dSmrg	    absdir=$abs_ladir
79626257f37dSmrg	    libdir=$abs_ladir
7963f3561b8bSmrg	  else
79646257f37dSmrg	    dir=$lt_sysroot$libdir
79656257f37dSmrg	    absdir=$lt_sysroot$libdir
7966f3561b8bSmrg	  fi
79676257f37dSmrg	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
7968f3561b8bSmrg	else
7969f3561b8bSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
79706257f37dSmrg	    dir=$ladir
79716257f37dSmrg	    absdir=$abs_ladir
7972f3561b8bSmrg	    # Remove this search path later
7973bd304fc0Smrg	    func_append notinst_path " $abs_ladir"
7974f3561b8bSmrg	  else
79756257f37dSmrg	    dir=$ladir/$objdir
79766257f37dSmrg	    absdir=$abs_ladir/$objdir
7977f3561b8bSmrg	    # Remove this search path later
7978bd304fc0Smrg	    func_append notinst_path " $abs_ladir"
7979f3561b8bSmrg	  fi
7980f3561b8bSmrg	fi # $installed = yes
7981f3561b8bSmrg	func_stripname 'lib' '.la' "$laname"
7982f3561b8bSmrg	name=$func_stripname_result
7983f3561b8bSmrg
7984f3561b8bSmrg	# This library was specified with -dlpreopen.
79856257f37dSmrg	if test dlpreopen = "$pass"; then
79866257f37dSmrg	  if test -z "$libdir" && test prog = "$linkmode"; then
79876257f37dSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
7988f3561b8bSmrg	  fi
79896257f37dSmrg	  case $host in
7990bd304fc0Smrg	    # special handling for platforms with PE-DLLs.
7991bd304fc0Smrg	    *cygwin* | *mingw* | *cegcc* )
7992bd304fc0Smrg	      # Linker will automatically link against shared library if both
7993bd304fc0Smrg	      # static and shared are present.  Therefore, ensure we extract
7994bd304fc0Smrg	      # symbols from the import library if a shared library is present
7995bd304fc0Smrg	      # (otherwise, the dlopen module name will be incorrect).  We do
7996bd304fc0Smrg	      # this by putting the import library name into $newdlprefiles.
7997bd304fc0Smrg	      # We recover the dlopen module name by 'saving' the la file
7998bd304fc0Smrg	      # name in a special purpose variable, and (later) extracting the
7999bd304fc0Smrg	      # dlname from the la file.
8000bd304fc0Smrg	      if test -n "$dlname"; then
8001bd304fc0Smrg	        func_tr_sh "$dir/$linklib"
8002bd304fc0Smrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
8003bd304fc0Smrg	        func_append newdlprefiles " $dir/$linklib"
8004bd304fc0Smrg	      else
8005bd304fc0Smrg	        func_append newdlprefiles " $dir/$old_library"
8006bd304fc0Smrg	        # Keep a list of preopened convenience libraries to check
8007bd304fc0Smrg	        # that they are being used correctly in the link pass.
8008bd304fc0Smrg	        test -z "$libdir" && \
8009bd304fc0Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8010bd304fc0Smrg	      fi
8011bd304fc0Smrg	    ;;
8012bd304fc0Smrg	    * )
8013bd304fc0Smrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
8014bd304fc0Smrg	      # are required to link).
8015bd304fc0Smrg	      if test -n "$old_library"; then
8016bd304fc0Smrg	        func_append newdlprefiles " $dir/$old_library"
8017bd304fc0Smrg	        # Keep a list of preopened convenience libraries to check
8018bd304fc0Smrg	        # that they are being used correctly in the link pass.
8019bd304fc0Smrg	        test -z "$libdir" && \
8020bd304fc0Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8021bd304fc0Smrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
8022bd304fc0Smrg	      elif test -n "$dlname"; then
8023bd304fc0Smrg	        func_append newdlprefiles " $dir/$dlname"
8024bd304fc0Smrg	      else
8025bd304fc0Smrg	        func_append newdlprefiles " $dir/$linklib"
8026bd304fc0Smrg	      fi
8027bd304fc0Smrg	    ;;
8028bd304fc0Smrg	  esac
8029f3561b8bSmrg	fi # $pass = dlpreopen
8030f3561b8bSmrg
8031f3561b8bSmrg	if test -z "$libdir"; then
8032f3561b8bSmrg	  # Link the convenience library
80336257f37dSmrg	  if test lib = "$linkmode"; then
8034f3561b8bSmrg	    deplibs="$dir/$old_library $deplibs"
80356257f37dSmrg	  elif test prog,link = "$linkmode,$pass"; then
8036f3561b8bSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
8037f3561b8bSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
8038f3561b8bSmrg	  else
8039f3561b8bSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
8040f3561b8bSmrg	  fi
8041f3561b8bSmrg	  continue
8042f3561b8bSmrg	fi
8043f3561b8bSmrg
8044f3561b8bSmrg
80456257f37dSmrg	if test prog = "$linkmode" && test link != "$pass"; then
8046bd304fc0Smrg	  func_append newlib_search_path " $ladir"
8047f3561b8bSmrg	  deplibs="$lib $deplibs"
8048f3561b8bSmrg
80496257f37dSmrg	  linkalldeplibs=false
80506257f37dSmrg	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
80516257f37dSmrg	     test no = "$build_libtool_libs"; then
80526257f37dSmrg	    linkalldeplibs=:
8053f3561b8bSmrg	  fi
8054f3561b8bSmrg
8055f3561b8bSmrg	  tmp_libs=
8056f3561b8bSmrg	  for deplib in $dependency_libs; do
8057f3561b8bSmrg	    case $deplib in
8058f3561b8bSmrg	    -L*) func_stripname '-L' '' "$deplib"
8059bd304fc0Smrg	         func_resolve_sysroot "$func_stripname_result"
8060bd304fc0Smrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
8061f3561b8bSmrg		 ;;
8062f3561b8bSmrg	    esac
8063f3561b8bSmrg	    # Need to link against all dependency_libs?
80646257f37dSmrg	    if $linkalldeplibs; then
8065f3561b8bSmrg	      deplibs="$deplib $deplibs"
8066f3561b8bSmrg	    else
8067f3561b8bSmrg	      # Need to hardcode shared library paths
8068f3561b8bSmrg	      # or/and link against static libraries
8069f3561b8bSmrg	      newdependency_libs="$deplib $newdependency_libs"
8070f3561b8bSmrg	    fi
80716257f37dSmrg	    if $opt_preserve_dup_deps; then
8072f3561b8bSmrg	      case "$tmp_libs " in
8073bd304fc0Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
8074f3561b8bSmrg	      esac
8075f3561b8bSmrg	    fi
8076bd304fc0Smrg	    func_append tmp_libs " $deplib"
8077f3561b8bSmrg	  done # for deplib
8078f3561b8bSmrg	  continue
8079f3561b8bSmrg	fi # $linkmode = prog...
8080f3561b8bSmrg
80816257f37dSmrg	if test prog,link = "$linkmode,$pass"; then
8082f3561b8bSmrg	  if test -n "$library_names" &&
80836257f37dSmrg	     { { test no = "$prefer_static_libs" ||
80846257f37dSmrg	         test built,yes = "$prefer_static_libs,$installed"; } ||
8085f3561b8bSmrg	       test -z "$old_library"; }; then
8086f3561b8bSmrg	    # We need to hardcode the library path
80876257f37dSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
8088f3561b8bSmrg	      # Make sure the rpath contains only unique directories.
80896257f37dSmrg	      case $temp_rpath: in
8090f3561b8bSmrg	      *"$absdir:"*) ;;
8091bd304fc0Smrg	      *) func_append temp_rpath "$absdir:" ;;
8092f3561b8bSmrg	      esac
8093f3561b8bSmrg	    fi
8094f3561b8bSmrg
8095f3561b8bSmrg	    # Hardcode the library path.
8096f3561b8bSmrg	    # Skip directories that are in the system default run-time
8097f3561b8bSmrg	    # search path.
8098f3561b8bSmrg	    case " $sys_lib_dlsearch_path " in
8099f3561b8bSmrg	    *" $absdir "*) ;;
8100f3561b8bSmrg	    *)
8101f3561b8bSmrg	      case "$compile_rpath " in
8102f3561b8bSmrg	      *" $absdir "*) ;;
8103bd304fc0Smrg	      *) func_append compile_rpath " $absdir" ;;
8104f3561b8bSmrg	      esac
8105f3561b8bSmrg	      ;;
8106f3561b8bSmrg	    esac
8107f3561b8bSmrg	    case " $sys_lib_dlsearch_path " in
8108f3561b8bSmrg	    *" $libdir "*) ;;
8109f3561b8bSmrg	    *)
8110f3561b8bSmrg	      case "$finalize_rpath " in
8111f3561b8bSmrg	      *" $libdir "*) ;;
8112bd304fc0Smrg	      *) func_append finalize_rpath " $libdir" ;;
8113f3561b8bSmrg	      esac
8114f3561b8bSmrg	      ;;
8115f3561b8bSmrg	    esac
8116f3561b8bSmrg	  fi # $linkmode,$pass = prog,link...
8117f3561b8bSmrg
81186257f37dSmrg	  if $alldeplibs &&
81196257f37dSmrg	     { test pass_all = "$deplibs_check_method" ||
81206257f37dSmrg	       { test yes = "$build_libtool_libs" &&
8121f3561b8bSmrg		 test -n "$library_names"; }; }; then
8122f3561b8bSmrg	    # We only need to search for static libraries
8123f3561b8bSmrg	    continue
8124f3561b8bSmrg	  fi
8125f3561b8bSmrg	fi
8126f3561b8bSmrg
8127f3561b8bSmrg	link_static=no # Whether the deplib will be linked statically
8128f3561b8bSmrg	use_static_libs=$prefer_static_libs
81296257f37dSmrg	if test built = "$use_static_libs" && test yes = "$installed"; then
8130f3561b8bSmrg	  use_static_libs=no
8131f3561b8bSmrg	fi
8132f3561b8bSmrg	if test -n "$library_names" &&
81336257f37dSmrg	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
8134f3561b8bSmrg	  case $host in
81356257f37dSmrg	  *cygwin* | *mingw* | *cegcc* | *os2*)
8136f3561b8bSmrg	      # No point in relinking DLLs because paths are not encoded
8137bd304fc0Smrg	      func_append notinst_deplibs " $lib"
8138f3561b8bSmrg	      need_relink=no
8139f3561b8bSmrg	    ;;
8140f3561b8bSmrg	  *)
81416257f37dSmrg	    if test no = "$installed"; then
8142bd304fc0Smrg	      func_append notinst_deplibs " $lib"
8143f3561b8bSmrg	      need_relink=yes
8144f3561b8bSmrg	    fi
8145f3561b8bSmrg	    ;;
8146f3561b8bSmrg	  esac
8147f3561b8bSmrg	  # This is a shared library
8148f3561b8bSmrg
8149f3561b8bSmrg	  # Warn about portability, can't link against -module's on some
8150f3561b8bSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
81516257f37dSmrg	  dlopenmodule=
8152f3561b8bSmrg	  for dlpremoduletest in $dlprefiles; do
8153f3561b8bSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
81546257f37dSmrg	      dlopenmodule=$dlpremoduletest
8155f3561b8bSmrg	      break
8156f3561b8bSmrg	    fi
8157f3561b8bSmrg	  done
81586257f37dSmrg	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
8159bd304fc0Smrg	    echo
81606257f37dSmrg	    if test prog = "$linkmode"; then
8161f3561b8bSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
8162f3561b8bSmrg	    else
8163f3561b8bSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
8164f3561b8bSmrg	    fi
8165f3561b8bSmrg	    $ECHO "*** $linklib is not portable!"
8166f3561b8bSmrg	  fi
81676257f37dSmrg	  if test lib = "$linkmode" &&
81686257f37dSmrg	     test yes = "$hardcode_into_libs"; then
8169f3561b8bSmrg	    # Hardcode the library path.
8170f3561b8bSmrg	    # Skip directories that are in the system default run-time
8171f3561b8bSmrg	    # search path.
8172f3561b8bSmrg	    case " $sys_lib_dlsearch_path " in
8173f3561b8bSmrg	    *" $absdir "*) ;;
8174f3561b8bSmrg	    *)
8175f3561b8bSmrg	      case "$compile_rpath " in
8176f3561b8bSmrg	      *" $absdir "*) ;;
8177bd304fc0Smrg	      *) func_append compile_rpath " $absdir" ;;
8178f3561b8bSmrg	      esac
8179f3561b8bSmrg	      ;;
8180f3561b8bSmrg	    esac
8181f3561b8bSmrg	    case " $sys_lib_dlsearch_path " in
8182f3561b8bSmrg	    *" $libdir "*) ;;
8183f3561b8bSmrg	    *)
8184f3561b8bSmrg	      case "$finalize_rpath " in
8185f3561b8bSmrg	      *" $libdir "*) ;;
8186bd304fc0Smrg	      *) func_append finalize_rpath " $libdir" ;;
8187f3561b8bSmrg	      esac
8188f3561b8bSmrg	      ;;
8189f3561b8bSmrg	    esac
8190f3561b8bSmrg	  fi
8191f3561b8bSmrg
8192f3561b8bSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
8193f3561b8bSmrg	    # figure out the soname
8194f3561b8bSmrg	    set dummy $library_names
8195f3561b8bSmrg	    shift
81966257f37dSmrg	    realname=$1
8197f3561b8bSmrg	    shift
8198f3561b8bSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
8199f3561b8bSmrg	    # use dlname if we got it. it's perfectly good, no?
8200f3561b8bSmrg	    if test -n "$dlname"; then
82016257f37dSmrg	      soname=$dlname
8202f3561b8bSmrg	    elif test -n "$soname_spec"; then
8203f3561b8bSmrg	      # bleh windows
8204f3561b8bSmrg	      case $host in
82056257f37dSmrg	      *cygwin* | mingw* | *cegcc* | *os2*)
8206f3561b8bSmrg	        func_arith $current - $age
8207f3561b8bSmrg		major=$func_arith_result
82086257f37dSmrg		versuffix=-$major
8209f3561b8bSmrg		;;
8210f3561b8bSmrg	      esac
8211f3561b8bSmrg	      eval soname=\"$soname_spec\"
8212f3561b8bSmrg	    else
82136257f37dSmrg	      soname=$realname
8214f3561b8bSmrg	    fi
8215f3561b8bSmrg
8216f3561b8bSmrg	    # Make a new name for the extract_expsyms_cmds to use
82176257f37dSmrg	    soroot=$soname
8218f3561b8bSmrg	    func_basename "$soroot"
82196257f37dSmrg	    soname=$func_basename_result
8220f3561b8bSmrg	    func_stripname 'lib' '.dll' "$soname"
8221f3561b8bSmrg	    newlib=libimp-$func_stripname_result.a
8222f3561b8bSmrg
8223f3561b8bSmrg	    # If the library has no export list, then create one now
8224f3561b8bSmrg	    if test -f "$output_objdir/$soname-def"; then :
8225f3561b8bSmrg	    else
82266257f37dSmrg	      func_verbose "extracting exported symbol list from '$soname'"
8227f3561b8bSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
8228f3561b8bSmrg	    fi
8229f3561b8bSmrg
8230f3561b8bSmrg	    # Create $newlib
8231f3561b8bSmrg	    if test -f "$output_objdir/$newlib"; then :; else
82326257f37dSmrg	      func_verbose "generating import library for '$soname'"
8233f3561b8bSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
8234f3561b8bSmrg	    fi
8235f3561b8bSmrg	    # make sure the library variables are pointing to the new library
8236f3561b8bSmrg	    dir=$output_objdir
8237f3561b8bSmrg	    linklib=$newlib
8238f3561b8bSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
8239f3561b8bSmrg
82406257f37dSmrg	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
8241f3561b8bSmrg	    add_shlibpath=
8242f3561b8bSmrg	    add_dir=
8243f3561b8bSmrg	    add=
8244f3561b8bSmrg	    lib_linked=yes
8245f3561b8bSmrg	    case $hardcode_action in
8246f3561b8bSmrg	    immediate | unsupported)
82476257f37dSmrg	      if test no = "$hardcode_direct"; then
82486257f37dSmrg		add=$dir/$linklib
8249f3561b8bSmrg		case $host in
82506257f37dSmrg		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
82516257f37dSmrg		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
8252f3561b8bSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
82536257f37dSmrg		    *-*-unixware7*) add_dir=-L$dir ;;
8254f3561b8bSmrg		  *-*-darwin* )
82556257f37dSmrg		    # if the lib is a (non-dlopened) module then we cannot
8256f3561b8bSmrg		    # link against it, someone is ignoring the earlier warnings
8257f3561b8bSmrg		    if /usr/bin/file -L $add 2> /dev/null |
82586257f37dSmrg			 $GREP ": [^:]* bundle" >/dev/null; then
8259f3561b8bSmrg		      if test "X$dlopenmodule" != "X$lib"; then
8260f3561b8bSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
82616257f37dSmrg			if test -z "$old_library"; then
8262bd304fc0Smrg			  echo
8263bd304fc0Smrg			  echo "*** And there doesn't seem to be a static archive available"
8264bd304fc0Smrg			  echo "*** The link will probably fail, sorry"
8265f3561b8bSmrg			else
82666257f37dSmrg			  add=$dir/$old_library
8267f3561b8bSmrg			fi
8268f3561b8bSmrg		      elif test -n "$old_library"; then
82696257f37dSmrg			add=$dir/$old_library
8270f3561b8bSmrg		      fi
8271f3561b8bSmrg		    fi
8272f3561b8bSmrg		esac
82736257f37dSmrg	      elif test no = "$hardcode_minus_L"; then
8274f3561b8bSmrg		case $host in
82756257f37dSmrg		*-*-sunos*) add_shlibpath=$dir ;;
8276f3561b8bSmrg		esac
82776257f37dSmrg		add_dir=-L$dir
82786257f37dSmrg		add=-l$name
82796257f37dSmrg	      elif test no = "$hardcode_shlibpath_var"; then
82806257f37dSmrg		add_shlibpath=$dir
82816257f37dSmrg		add=-l$name
8282f3561b8bSmrg	      else
8283f3561b8bSmrg		lib_linked=no
8284f3561b8bSmrg	      fi
8285f3561b8bSmrg	      ;;
8286f3561b8bSmrg	    relink)
82876257f37dSmrg	      if test yes = "$hardcode_direct" &&
82886257f37dSmrg	         test no = "$hardcode_direct_absolute"; then
82896257f37dSmrg		add=$dir/$linklib
82906257f37dSmrg	      elif test yes = "$hardcode_minus_L"; then
82916257f37dSmrg		add_dir=-L$absdir
8292f3561b8bSmrg		# Try looking first in the location we're being installed to.
8293f3561b8bSmrg		if test -n "$inst_prefix_dir"; then
8294f3561b8bSmrg		  case $libdir in
8295f3561b8bSmrg		    [\\/]*)
8296bd304fc0Smrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
8297f3561b8bSmrg		      ;;
8298f3561b8bSmrg		  esac
8299f3561b8bSmrg		fi
83006257f37dSmrg		add=-l$name
83016257f37dSmrg	      elif test yes = "$hardcode_shlibpath_var"; then
83026257f37dSmrg		add_shlibpath=$dir
83036257f37dSmrg		add=-l$name
8304f3561b8bSmrg	      else
8305f3561b8bSmrg		lib_linked=no
8306f3561b8bSmrg	      fi
8307f3561b8bSmrg	      ;;
8308f3561b8bSmrg	    *) lib_linked=no ;;
8309f3561b8bSmrg	    esac
8310f3561b8bSmrg
83116257f37dSmrg	    if test yes != "$lib_linked"; then
8312f3561b8bSmrg	      func_fatal_configuration "unsupported hardcode properties"
8313f3561b8bSmrg	    fi
8314f3561b8bSmrg
8315f3561b8bSmrg	    if test -n "$add_shlibpath"; then
8316f3561b8bSmrg	      case :$compile_shlibpath: in
8317f3561b8bSmrg	      *":$add_shlibpath:"*) ;;
8318bd304fc0Smrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
8319f3561b8bSmrg	      esac
8320f3561b8bSmrg	    fi
83216257f37dSmrg	    if test prog = "$linkmode"; then
8322f3561b8bSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
8323f3561b8bSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
8324f3561b8bSmrg	    else
8325f3561b8bSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
8326f3561b8bSmrg	      test -n "$add" && deplibs="$add $deplibs"
83276257f37dSmrg	      if test yes != "$hardcode_direct" &&
83286257f37dSmrg		 test yes != "$hardcode_minus_L" &&
83296257f37dSmrg		 test yes = "$hardcode_shlibpath_var"; then
8330f3561b8bSmrg		case :$finalize_shlibpath: in
8331f3561b8bSmrg		*":$libdir:"*) ;;
8332bd304fc0Smrg		*) func_append finalize_shlibpath "$libdir:" ;;
8333f3561b8bSmrg		esac
8334f3561b8bSmrg	      fi
8335f3561b8bSmrg	    fi
8336f3561b8bSmrg	  fi
8337f3561b8bSmrg
83386257f37dSmrg	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
8339f3561b8bSmrg	    add_shlibpath=
8340f3561b8bSmrg	    add_dir=
8341f3561b8bSmrg	    add=
8342f3561b8bSmrg	    # Finalize command for both is simple: just hardcode it.
83436257f37dSmrg	    if test yes = "$hardcode_direct" &&
83446257f37dSmrg	       test no = "$hardcode_direct_absolute"; then
83456257f37dSmrg	      add=$libdir/$linklib
83466257f37dSmrg	    elif test yes = "$hardcode_minus_L"; then
83476257f37dSmrg	      add_dir=-L$libdir
83486257f37dSmrg	      add=-l$name
83496257f37dSmrg	    elif test yes = "$hardcode_shlibpath_var"; then
8350f3561b8bSmrg	      case :$finalize_shlibpath: in
8351f3561b8bSmrg	      *":$libdir:"*) ;;
8352bd304fc0Smrg	      *) func_append finalize_shlibpath "$libdir:" ;;
8353f3561b8bSmrg	      esac
83546257f37dSmrg	      add=-l$name
83556257f37dSmrg	    elif test yes = "$hardcode_automatic"; then
8356f3561b8bSmrg	      if test -n "$inst_prefix_dir" &&
83576257f37dSmrg		 test -f "$inst_prefix_dir$libdir/$linklib"; then
83586257f37dSmrg		add=$inst_prefix_dir$libdir/$linklib
8359f3561b8bSmrg	      else
83606257f37dSmrg		add=$libdir/$linklib
8361f3561b8bSmrg	      fi
8362f3561b8bSmrg	    else
8363f3561b8bSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
83646257f37dSmrg	      add_dir=-L$libdir
8365f3561b8bSmrg	      # Try looking first in the location we're being installed to.
8366f3561b8bSmrg	      if test -n "$inst_prefix_dir"; then
8367f3561b8bSmrg		case $libdir in
8368f3561b8bSmrg		  [\\/]*)
8369bd304fc0Smrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
8370f3561b8bSmrg		    ;;
8371f3561b8bSmrg		esac
8372f3561b8bSmrg	      fi
83736257f37dSmrg	      add=-l$name
8374f3561b8bSmrg	    fi
8375f3561b8bSmrg
83766257f37dSmrg	    if test prog = "$linkmode"; then
8377f3561b8bSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
8378f3561b8bSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
8379f3561b8bSmrg	    else
8380f3561b8bSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
8381f3561b8bSmrg	      test -n "$add" && deplibs="$add $deplibs"
8382f3561b8bSmrg	    fi
8383f3561b8bSmrg	  fi
83846257f37dSmrg	elif test prog = "$linkmode"; then
8385f3561b8bSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
8386f3561b8bSmrg	  # is not unsupported.  This is valid on all known static and
8387f3561b8bSmrg	  # shared platforms.
83886257f37dSmrg	  if test unsupported != "$hardcode_direct"; then
83896257f37dSmrg	    test -n "$old_library" && linklib=$old_library
8390f3561b8bSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
8391f3561b8bSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
8392f3561b8bSmrg	  else
8393f3561b8bSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
8394f3561b8bSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
8395f3561b8bSmrg	  fi
83966257f37dSmrg	elif test yes = "$build_libtool_libs"; then
8397f3561b8bSmrg	  # Not a shared library
83986257f37dSmrg	  if test pass_all != "$deplibs_check_method"; then
8399f3561b8bSmrg	    # We're trying link a shared library against a static one
8400f3561b8bSmrg	    # but the system doesn't support it.
8401f3561b8bSmrg
8402f3561b8bSmrg	    # Just print a warning and add the library to dependency_libs so
8403f3561b8bSmrg	    # that the program can be linked against the static library.
8404bd304fc0Smrg	    echo
84056257f37dSmrg	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
8406bd304fc0Smrg	    echo "*** I have the capability to make that library automatically link in when"
8407bd304fc0Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
8408bd304fc0Smrg	    echo "*** shared version of the library, which you do not appear to have."
84096257f37dSmrg	    if test yes = "$module"; then
8410bd304fc0Smrg	      echo "*** But as you try to build a module library, libtool will still create "
8411bd304fc0Smrg	      echo "*** a static module, that should work as long as the dlopening application"
8412bd304fc0Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
8413f3561b8bSmrg	      if test -z "$global_symbol_pipe"; then
8414bd304fc0Smrg		echo
8415bd304fc0Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
84166257f37dSmrg		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
8417bd304fc0Smrg		echo "*** not find such a program.  So, this module is probably useless."
84186257f37dSmrg		echo "*** 'nm' from GNU binutils and a full rebuild may help."
8419f3561b8bSmrg	      fi
84206257f37dSmrg	      if test no = "$build_old_libs"; then
8421f3561b8bSmrg		build_libtool_libs=module
8422f3561b8bSmrg		build_old_libs=yes
8423f3561b8bSmrg	      else
8424f3561b8bSmrg		build_libtool_libs=no
8425f3561b8bSmrg	      fi
8426f3561b8bSmrg	    fi
8427f3561b8bSmrg	  else
8428f3561b8bSmrg	    deplibs="$dir/$old_library $deplibs"
8429f3561b8bSmrg	    link_static=yes
8430f3561b8bSmrg	  fi
8431f3561b8bSmrg	fi # link shared/static library?
8432f3561b8bSmrg
84336257f37dSmrg	if test lib = "$linkmode"; then
8434f3561b8bSmrg	  if test -n "$dependency_libs" &&
84356257f37dSmrg	     { test yes != "$hardcode_into_libs" ||
84366257f37dSmrg	       test yes = "$build_old_libs" ||
84376257f37dSmrg	       test yes = "$link_static"; }; then
8438f3561b8bSmrg	    # Extract -R from dependency_libs
8439f3561b8bSmrg	    temp_deplibs=
8440f3561b8bSmrg	    for libdir in $dependency_libs; do
8441f3561b8bSmrg	      case $libdir in
8442f3561b8bSmrg	      -R*) func_stripname '-R' '' "$libdir"
8443f3561b8bSmrg	           temp_xrpath=$func_stripname_result
8444f3561b8bSmrg		   case " $xrpath " in
8445f3561b8bSmrg		   *" $temp_xrpath "*) ;;
8446bd304fc0Smrg		   *) func_append xrpath " $temp_xrpath";;
8447f3561b8bSmrg		   esac;;
8448bd304fc0Smrg	      *) func_append temp_deplibs " $libdir";;
8449f3561b8bSmrg	      esac
8450f3561b8bSmrg	    done
84516257f37dSmrg	    dependency_libs=$temp_deplibs
8452f3561b8bSmrg	  fi
8453f3561b8bSmrg
8454bd304fc0Smrg	  func_append newlib_search_path " $absdir"
8455f3561b8bSmrg	  # Link against this library
84566257f37dSmrg	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
8457f3561b8bSmrg	  # ... and its dependency_libs
8458f3561b8bSmrg	  tmp_libs=
8459f3561b8bSmrg	  for deplib in $dependency_libs; do
8460f3561b8bSmrg	    newdependency_libs="$deplib $newdependency_libs"
8461bd304fc0Smrg	    case $deplib in
8462bd304fc0Smrg              -L*) func_stripname '-L' '' "$deplib"
8463bd304fc0Smrg                   func_resolve_sysroot "$func_stripname_result";;
8464bd304fc0Smrg              *) func_resolve_sysroot "$deplib" ;;
8465bd304fc0Smrg            esac
84666257f37dSmrg	    if $opt_preserve_dup_deps; then
8467f3561b8bSmrg	      case "$tmp_libs " in
8468bd304fc0Smrg	      *" $func_resolve_sysroot_result "*)
8469bd304fc0Smrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
8470f3561b8bSmrg	      esac
8471f3561b8bSmrg	    fi
8472bd304fc0Smrg	    func_append tmp_libs " $func_resolve_sysroot_result"
8473f3561b8bSmrg	  done
8474f3561b8bSmrg
84756257f37dSmrg	  if test no != "$link_all_deplibs"; then
8476f3561b8bSmrg	    # Add the search paths of all dependency libraries
8477f3561b8bSmrg	    for deplib in $dependency_libs; do
84786086d97eSmrg	      path=
8479f3561b8bSmrg	      case $deplib in
84806257f37dSmrg	      -L*) path=$deplib ;;
8481f3561b8bSmrg	      *.la)
8482bd304fc0Smrg	        func_resolve_sysroot "$deplib"
8483bd304fc0Smrg	        deplib=$func_resolve_sysroot_result
8484f3561b8bSmrg	        func_dirname "$deplib" "" "."
8485bd304fc0Smrg		dir=$func_dirname_result
8486f3561b8bSmrg		# We need an absolute path.
8487f3561b8bSmrg		case $dir in
84886257f37dSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
8489f3561b8bSmrg		*)
8490f3561b8bSmrg		  absdir=`cd "$dir" && pwd`
8491f3561b8bSmrg		  if test -z "$absdir"; then
84926257f37dSmrg		    func_warning "cannot determine absolute directory name of '$dir'"
84936257f37dSmrg		    absdir=$dir
8494f3561b8bSmrg		  fi
8495f3561b8bSmrg		  ;;
8496f3561b8bSmrg		esac
8497f3561b8bSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
8498f3561b8bSmrg		case $host in
8499f3561b8bSmrg		*-*-darwin*)
8500f3561b8bSmrg		  depdepl=
85016257f37dSmrg		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
85026257f37dSmrg		  if test -n "$deplibrary_names"; then
85036257f37dSmrg		    for tmp in $deplibrary_names; do
8504f3561b8bSmrg		      depdepl=$tmp
8505f3561b8bSmrg		    done
85066257f37dSmrg		    if test -f "$absdir/$objdir/$depdepl"; then
85076257f37dSmrg		      depdepl=$absdir/$objdir/$depdepl
85086257f37dSmrg		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
8509f3561b8bSmrg                      if test -z "$darwin_install_name"; then
85106257f37dSmrg                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
8511f3561b8bSmrg                      fi
85126257f37dSmrg		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
85136257f37dSmrg		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
8514f3561b8bSmrg		      path=
8515f3561b8bSmrg		    fi
8516f3561b8bSmrg		  fi
8517f3561b8bSmrg		  ;;
8518f3561b8bSmrg		*)
85196257f37dSmrg		  path=-L$absdir/$objdir
8520f3561b8bSmrg		  ;;
8521f3561b8bSmrg		esac
8522f3561b8bSmrg		else
85236257f37dSmrg		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8524f3561b8bSmrg		  test -z "$libdir" && \
85256257f37dSmrg		    func_fatal_error "'$deplib' is not a valid libtool archive"
8526f3561b8bSmrg		  test "$absdir" != "$libdir" && \
85276257f37dSmrg		    func_warning "'$deplib' seems to be moved"
8528f3561b8bSmrg
85296257f37dSmrg		  path=-L$absdir
8530f3561b8bSmrg		fi
8531f3561b8bSmrg		;;
8532f3561b8bSmrg	      esac
8533f3561b8bSmrg	      case " $deplibs " in
8534f3561b8bSmrg	      *" $path "*) ;;
8535f3561b8bSmrg	      *) deplibs="$path $deplibs" ;;
8536f3561b8bSmrg	      esac
8537f3561b8bSmrg	    done
8538f3561b8bSmrg	  fi # link_all_deplibs != no
8539f3561b8bSmrg	fi # linkmode = lib
8540f3561b8bSmrg      done # for deplib in $libs
85416257f37dSmrg      if test link = "$pass"; then
85426257f37dSmrg	if test prog = "$linkmode"; then
8543f3561b8bSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
8544f3561b8bSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
8545f3561b8bSmrg	else
8546bd304fc0Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8547f3561b8bSmrg	fi
8548f3561b8bSmrg      fi
85496257f37dSmrg      dependency_libs=$newdependency_libs
85506257f37dSmrg      if test dlpreopen = "$pass"; then
8551f3561b8bSmrg	# Link the dlpreopened libraries before other libraries
8552f3561b8bSmrg	for deplib in $save_deplibs; do
8553f3561b8bSmrg	  deplibs="$deplib $deplibs"
8554f3561b8bSmrg	done
8555f3561b8bSmrg      fi
85566257f37dSmrg      if test dlopen != "$pass"; then
85576257f37dSmrg	test conv = "$pass" || {
8558f3561b8bSmrg	  # Make sure lib_search_path contains only unique directories.
8559f3561b8bSmrg	  lib_search_path=
8560f3561b8bSmrg	  for dir in $newlib_search_path; do
8561f3561b8bSmrg	    case "$lib_search_path " in
8562f3561b8bSmrg	    *" $dir "*) ;;
8563bd304fc0Smrg	    *) func_append lib_search_path " $dir" ;;
8564f3561b8bSmrg	    esac
8565f3561b8bSmrg	  done
8566f3561b8bSmrg	  newlib_search_path=
85676257f37dSmrg	}
8568f3561b8bSmrg
85696257f37dSmrg	if test prog,link = "$linkmode,$pass"; then
8570f3561b8bSmrg	  vars="compile_deplibs finalize_deplibs"
85716257f37dSmrg	else
85726257f37dSmrg	  vars=deplibs
8573f3561b8bSmrg	fi
8574f3561b8bSmrg	for var in $vars dependency_libs; do
8575f3561b8bSmrg	  # Add libraries to $var in reverse order
8576f3561b8bSmrg	  eval tmp_libs=\"\$$var\"
8577f3561b8bSmrg	  new_libs=
8578f3561b8bSmrg	  for deplib in $tmp_libs; do
8579f3561b8bSmrg	    # FIXME: Pedantically, this is the right thing to do, so
8580f3561b8bSmrg	    #        that some nasty dependency loop isn't accidentally
8581f3561b8bSmrg	    #        broken:
8582f3561b8bSmrg	    #new_libs="$deplib $new_libs"
8583f3561b8bSmrg	    # Pragmatically, this seems to cause very few problems in
8584f3561b8bSmrg	    # practice:
8585f3561b8bSmrg	    case $deplib in
8586f3561b8bSmrg	    -L*) new_libs="$deplib $new_libs" ;;
8587f3561b8bSmrg	    -R*) ;;
8588f3561b8bSmrg	    *)
8589f3561b8bSmrg	      # And here is the reason: when a library appears more
8590f3561b8bSmrg	      # than once as an explicit dependence of a library, or
8591f3561b8bSmrg	      # is implicitly linked in more than once by the
8592f3561b8bSmrg	      # compiler, it is considered special, and multiple
8593f3561b8bSmrg	      # occurrences thereof are not removed.  Compare this
8594f3561b8bSmrg	      # with having the same library being listed as a
8595f3561b8bSmrg	      # dependency of multiple other libraries: in this case,
8596f3561b8bSmrg	      # we know (pedantically, we assume) the library does not
8597f3561b8bSmrg	      # need to be listed more than once, so we keep only the
8598f3561b8bSmrg	      # last copy.  This is not always right, but it is rare
8599f3561b8bSmrg	      # enough that we require users that really mean to play
8600f3561b8bSmrg	      # such unportable linking tricks to link the library
8601f3561b8bSmrg	      # using -Wl,-lname, so that libtool does not consider it
8602f3561b8bSmrg	      # for duplicate removal.
8603f3561b8bSmrg	      case " $specialdeplibs " in
8604f3561b8bSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
8605f3561b8bSmrg	      *)
8606f3561b8bSmrg		case " $new_libs " in
8607f3561b8bSmrg		*" $deplib "*) ;;
8608f3561b8bSmrg		*) new_libs="$deplib $new_libs" ;;
8609f3561b8bSmrg		esac
8610f3561b8bSmrg		;;
8611f3561b8bSmrg	      esac
8612f3561b8bSmrg	      ;;
8613f3561b8bSmrg	    esac
8614f3561b8bSmrg	  done
8615f3561b8bSmrg	  tmp_libs=
8616f3561b8bSmrg	  for deplib in $new_libs; do
8617f3561b8bSmrg	    case $deplib in
8618f3561b8bSmrg	    -L*)
8619f3561b8bSmrg	      case " $tmp_libs " in
8620f3561b8bSmrg	      *" $deplib "*) ;;
8621bd304fc0Smrg	      *) func_append tmp_libs " $deplib" ;;
8622f3561b8bSmrg	      esac
8623f3561b8bSmrg	      ;;
8624bd304fc0Smrg	    *) func_append tmp_libs " $deplib" ;;
8625f3561b8bSmrg	    esac
8626f3561b8bSmrg	  done
8627f3561b8bSmrg	  eval $var=\"$tmp_libs\"
8628f3561b8bSmrg	done # for var
8629f3561b8bSmrg      fi
86306257f37dSmrg
86316257f37dSmrg      # Add Sun CC postdeps if required:
86326257f37dSmrg      test CXX = "$tagname" && {
86336257f37dSmrg        case $host_os in
86346257f37dSmrg        linux*)
86356257f37dSmrg          case `$CC -V 2>&1 | sed 5q` in
86366257f37dSmrg          *Sun\ C*) # Sun C++ 5.9
86376257f37dSmrg            func_suncc_cstd_abi
86386257f37dSmrg
86396257f37dSmrg            if test no != "$suncc_use_cstd_abi"; then
86406257f37dSmrg              func_append postdeps ' -library=Cstd -library=Crun'
86416257f37dSmrg            fi
86426257f37dSmrg            ;;
86436257f37dSmrg          esac
86446257f37dSmrg          ;;
86456257f37dSmrg
86466257f37dSmrg        solaris*)
86476257f37dSmrg          func_cc_basename "$CC"
86486257f37dSmrg          case $func_cc_basename_result in
86496257f37dSmrg          CC* | sunCC*)
86506257f37dSmrg            func_suncc_cstd_abi
86516257f37dSmrg
86526257f37dSmrg            if test no != "$suncc_use_cstd_abi"; then
86536257f37dSmrg              func_append postdeps ' -library=Cstd -library=Crun'
86546257f37dSmrg            fi
86556257f37dSmrg            ;;
86566257f37dSmrg          esac
86576257f37dSmrg          ;;
86586257f37dSmrg        esac
86596257f37dSmrg      }
86606257f37dSmrg
8661f3561b8bSmrg      # Last step: remove runtime libs from dependency_libs
8662f3561b8bSmrg      # (they stay in deplibs)
8663f3561b8bSmrg      tmp_libs=
86646257f37dSmrg      for i in $dependency_libs; do
8665f3561b8bSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
8666f3561b8bSmrg	*" $i "*)
86676257f37dSmrg	  i=
8668f3561b8bSmrg	  ;;
8669f3561b8bSmrg	esac
86706257f37dSmrg	if test -n "$i"; then
8671bd304fc0Smrg	  func_append tmp_libs " $i"
8672f3561b8bSmrg	fi
8673f3561b8bSmrg      done
8674f3561b8bSmrg      dependency_libs=$tmp_libs
8675f3561b8bSmrg    done # for pass
86766257f37dSmrg    if test prog = "$linkmode"; then
86776257f37dSmrg      dlfiles=$newdlfiles
8678f3561b8bSmrg    fi
86796257f37dSmrg    if test prog = "$linkmode" || test lib = "$linkmode"; then
86806257f37dSmrg      dlprefiles=$newdlprefiles
8681f3561b8bSmrg    fi
8682f3561b8bSmrg
8683f3561b8bSmrg    case $linkmode in
8684f3561b8bSmrg    oldlib)
86856257f37dSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
86866257f37dSmrg	func_warning "'-dlopen' is ignored for archives"
8687f3561b8bSmrg      fi
8688f3561b8bSmrg
8689f3561b8bSmrg      case " $deplibs" in
8690f3561b8bSmrg      *\ -l* | *\ -L*)
86916257f37dSmrg	func_warning "'-l' and '-L' are ignored for archives" ;;
8692f3561b8bSmrg      esac
8693f3561b8bSmrg
8694f3561b8bSmrg      test -n "$rpath" && \
86956257f37dSmrg	func_warning "'-rpath' is ignored for archives"
8696f3561b8bSmrg
8697f3561b8bSmrg      test -n "$xrpath" && \
86986257f37dSmrg	func_warning "'-R' is ignored for archives"
8699f3561b8bSmrg
8700f3561b8bSmrg      test -n "$vinfo" && \
87016257f37dSmrg	func_warning "'-version-info/-version-number' is ignored for archives"
8702f3561b8bSmrg
8703f3561b8bSmrg      test -n "$release" && \
87046257f37dSmrg	func_warning "'-release' is ignored for archives"
8705f3561b8bSmrg
8706f3561b8bSmrg      test -n "$export_symbols$export_symbols_regex" && \
87076257f37dSmrg	func_warning "'-export-symbols' is ignored for archives"
8708f3561b8bSmrg
8709f3561b8bSmrg      # Now set the variables for building old libraries.
8710f3561b8bSmrg      build_libtool_libs=no
87116257f37dSmrg      oldlibs=$output
8712bd304fc0Smrg      func_append objs "$old_deplibs"
8713f3561b8bSmrg      ;;
8714f3561b8bSmrg
8715f3561b8bSmrg    lib)
87166257f37dSmrg      # Make sure we only generate libraries of the form 'libNAME.la'.
8717f3561b8bSmrg      case $outputname in
8718f3561b8bSmrg      lib*)
8719f3561b8bSmrg	func_stripname 'lib' '.la' "$outputname"
8720f3561b8bSmrg	name=$func_stripname_result
8721f3561b8bSmrg	eval shared_ext=\"$shrext_cmds\"
8722f3561b8bSmrg	eval libname=\"$libname_spec\"
8723f3561b8bSmrg	;;
8724f3561b8bSmrg      *)
87256257f37dSmrg	test no = "$module" \
87266257f37dSmrg	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
8727f3561b8bSmrg
87286257f37dSmrg	if test no != "$need_lib_prefix"; then
8729f3561b8bSmrg	  # Add the "lib" prefix for modules if required
8730f3561b8bSmrg	  func_stripname '' '.la' "$outputname"
8731f3561b8bSmrg	  name=$func_stripname_result
8732f3561b8bSmrg	  eval shared_ext=\"$shrext_cmds\"
8733f3561b8bSmrg	  eval libname=\"$libname_spec\"
8734f3561b8bSmrg	else
8735f3561b8bSmrg	  func_stripname '' '.la' "$outputname"
8736f3561b8bSmrg	  libname=$func_stripname_result
8737f3561b8bSmrg	fi
8738f3561b8bSmrg	;;
8739f3561b8bSmrg      esac
8740f3561b8bSmrg
8741f3561b8bSmrg      if test -n "$objs"; then
87426257f37dSmrg	if test pass_all != "$deplibs_check_method"; then
87436257f37dSmrg	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
8744f3561b8bSmrg	else
8745bd304fc0Smrg	  echo
8746f3561b8bSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
8747f3561b8bSmrg	  $ECHO "*** objects $objs is not portable!"
8748bd304fc0Smrg	  func_append libobjs " $objs"
8749f3561b8bSmrg	fi
8750f3561b8bSmrg      fi
8751f3561b8bSmrg
87526257f37dSmrg      test no = "$dlself" \
87536257f37dSmrg	|| func_warning "'-dlopen self' is ignored for libtool libraries"
8754f3561b8bSmrg
8755f3561b8bSmrg      set dummy $rpath
8756f3561b8bSmrg      shift
87576257f37dSmrg      test 1 -lt "$#" \
87586257f37dSmrg	&& func_warning "ignoring multiple '-rpath's for a libtool library"
8759f3561b8bSmrg
87606257f37dSmrg      install_libdir=$1
8761f3561b8bSmrg
8762f3561b8bSmrg      oldlibs=
8763f3561b8bSmrg      if test -z "$rpath"; then
87646257f37dSmrg	if test yes = "$build_libtool_libs"; then
8765f3561b8bSmrg	  # Building a libtool convenience library.
87666257f37dSmrg	  # Some compilers have problems with a '.al' extension so
8767f3561b8bSmrg	  # convenience libraries should have the same extension an
8768f3561b8bSmrg	  # archive normally would.
8769f3561b8bSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
8770f3561b8bSmrg	  build_libtool_libs=convenience
8771f3561b8bSmrg	  build_old_libs=yes
8772f3561b8bSmrg	fi
8773f3561b8bSmrg
8774f3561b8bSmrg	test -n "$vinfo" && \
87756257f37dSmrg	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
8776f3561b8bSmrg
8777f3561b8bSmrg	test -n "$release" && \
87786257f37dSmrg	  func_warning "'-release' is ignored for convenience libraries"
8779f3561b8bSmrg      else
8780f3561b8bSmrg
8781f3561b8bSmrg	# Parse the version information argument.
87826257f37dSmrg	save_ifs=$IFS; IFS=:
8783f3561b8bSmrg	set dummy $vinfo 0 0 0
8784f3561b8bSmrg	shift
87856257f37dSmrg	IFS=$save_ifs
8786f3561b8bSmrg
8787f3561b8bSmrg	test -n "$7" && \
87886257f37dSmrg	  func_fatal_help "too many parameters to '-version-info'"
8789f3561b8bSmrg
8790f3561b8bSmrg	# convert absolute version numbers to libtool ages
8791f3561b8bSmrg	# this retains compatibility with .la files and attempts
8792f3561b8bSmrg	# to make the code below a bit more comprehensible
8793f3561b8bSmrg
8794f3561b8bSmrg	case $vinfo_number in
8795f3561b8bSmrg	yes)
87966257f37dSmrg	  number_major=$1
87976257f37dSmrg	  number_minor=$2
87986257f37dSmrg	  number_revision=$3
8799f3561b8bSmrg	  #
8800f3561b8bSmrg	  # There are really only two kinds -- those that
8801f3561b8bSmrg	  # use the current revision as the major version
8802f3561b8bSmrg	  # and those that subtract age and use age as
8803f3561b8bSmrg	  # a minor version.  But, then there is irix
88046257f37dSmrg	  # that has an extra 1 added just for fun
8805f3561b8bSmrg	  #
8806f3561b8bSmrg	  case $version_type in
8807bd304fc0Smrg	  # correct linux to gnu/linux during the next big refactor
88086257f37dSmrg	  darwin|freebsd-elf|linux|osf|windows|none)
8809f3561b8bSmrg	    func_arith $number_major + $number_minor
8810f3561b8bSmrg	    current=$func_arith_result
88116257f37dSmrg	    age=$number_minor
88126257f37dSmrg	    revision=$number_revision
8813f3561b8bSmrg	    ;;
88146257f37dSmrg	  freebsd-aout|qnx|sunos)
88156257f37dSmrg	    current=$number_major
88166257f37dSmrg	    revision=$number_minor
88176257f37dSmrg	    age=0
8818f3561b8bSmrg	    ;;
8819f3561b8bSmrg	  irix|nonstopux)
8820f3561b8bSmrg	    func_arith $number_major + $number_minor
8821f3561b8bSmrg	    current=$func_arith_result
88226257f37dSmrg	    age=$number_minor
88236257f37dSmrg	    revision=$number_minor
8824f3561b8bSmrg	    lt_irix_increment=no
8825f3561b8bSmrg	    ;;
8826f3561b8bSmrg	  esac
8827f3561b8bSmrg	  ;;
8828f3561b8bSmrg	no)
88296257f37dSmrg	  current=$1
88306257f37dSmrg	  revision=$2
88316257f37dSmrg	  age=$3
8832f3561b8bSmrg	  ;;
8833f3561b8bSmrg	esac
8834f3561b8bSmrg
8835f3561b8bSmrg	# Check that each of the things are valid numbers.
8836f3561b8bSmrg	case $current in
8837f3561b8bSmrg	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]) ;;
8838f3561b8bSmrg	*)
88396257f37dSmrg	  func_error "CURRENT '$current' must be a nonnegative integer"
88406257f37dSmrg	  func_fatal_error "'$vinfo' is not valid version information"
8841f3561b8bSmrg	  ;;
8842f3561b8bSmrg	esac
8843f3561b8bSmrg
8844f3561b8bSmrg	case $revision in
8845f3561b8bSmrg	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]) ;;
8846f3561b8bSmrg	*)
88476257f37dSmrg	  func_error "REVISION '$revision' must be a nonnegative integer"
88486257f37dSmrg	  func_fatal_error "'$vinfo' is not valid version information"
8849f3561b8bSmrg	  ;;
8850f3561b8bSmrg	esac
8851f3561b8bSmrg
8852f3561b8bSmrg	case $age in
8853f3561b8bSmrg	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]) ;;
8854f3561b8bSmrg	*)
88556257f37dSmrg	  func_error "AGE '$age' must be a nonnegative integer"
88566257f37dSmrg	  func_fatal_error "'$vinfo' is not valid version information"
8857f3561b8bSmrg	  ;;
8858f3561b8bSmrg	esac
8859f3561b8bSmrg
8860f3561b8bSmrg	if test "$age" -gt "$current"; then
88616257f37dSmrg	  func_error "AGE '$age' is greater than the current interface number '$current'"
88626257f37dSmrg	  func_fatal_error "'$vinfo' is not valid version information"
8863f3561b8bSmrg	fi
8864f3561b8bSmrg
8865f3561b8bSmrg	# Calculate the version variables.
8866f3561b8bSmrg	major=
8867f3561b8bSmrg	versuffix=
8868f3561b8bSmrg	verstring=
8869f3561b8bSmrg	case $version_type in
8870f3561b8bSmrg	none) ;;
8871f3561b8bSmrg
8872f3561b8bSmrg	darwin)
8873f3561b8bSmrg	  # Like Linux, but with the current version available in
8874f3561b8bSmrg	  # verstring for coding it into the library header
8875f3561b8bSmrg	  func_arith $current - $age
8876f3561b8bSmrg	  major=.$func_arith_result
88776257f37dSmrg	  versuffix=$major.$age.$revision
8878f3561b8bSmrg	  # Darwin ld doesn't like 0 for these options...
8879f3561b8bSmrg	  func_arith $current + 1
8880f3561b8bSmrg	  minor_current=$func_arith_result
88816257f37dSmrg	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8882f3561b8bSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
88836257f37dSmrg          # On Darwin other compilers
88846257f37dSmrg          case $CC in
88856257f37dSmrg              nagfor*)
88866257f37dSmrg                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
88876257f37dSmrg                  ;;
88886257f37dSmrg              *)
88896257f37dSmrg                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
88906257f37dSmrg                  ;;
88916257f37dSmrg          esac
8892f3561b8bSmrg	  ;;
8893f3561b8bSmrg
8894f3561b8bSmrg	freebsd-aout)
88956257f37dSmrg	  major=.$current
88966257f37dSmrg	  versuffix=.$current.$revision
8897f3561b8bSmrg	  ;;
8898f3561b8bSmrg
8899f3561b8bSmrg	freebsd-elf)
89006257f37dSmrg	  func_arith $current - $age
89016257f37dSmrg	  major=.$func_arith_result
89026257f37dSmrg	  versuffix=$major.$age.$revision
8903f3561b8bSmrg	  ;;
8904f3561b8bSmrg
8905f3561b8bSmrg	irix | nonstopux)
89066257f37dSmrg	  if test no = "$lt_irix_increment"; then
8907f3561b8bSmrg	    func_arith $current - $age
8908f3561b8bSmrg	  else
8909f3561b8bSmrg	    func_arith $current - $age + 1
8910f3561b8bSmrg	  fi
8911f3561b8bSmrg	  major=$func_arith_result
8912f3561b8bSmrg
8913f3561b8bSmrg	  case $version_type in
8914f3561b8bSmrg	    nonstopux) verstring_prefix=nonstopux ;;
8915f3561b8bSmrg	    *)         verstring_prefix=sgi ;;
8916f3561b8bSmrg	  esac
89176257f37dSmrg	  verstring=$verstring_prefix$major.$revision
8918f3561b8bSmrg
8919f3561b8bSmrg	  # Add in all the interfaces that we are compatible with.
8920f3561b8bSmrg	  loop=$revision
89216257f37dSmrg	  while test 0 -ne "$loop"; do
8922f3561b8bSmrg	    func_arith $revision - $loop
8923f3561b8bSmrg	    iface=$func_arith_result
8924f3561b8bSmrg	    func_arith $loop - 1
8925f3561b8bSmrg	    loop=$func_arith_result
89266257f37dSmrg	    verstring=$verstring_prefix$major.$iface:$verstring
8927f3561b8bSmrg	  done
8928f3561b8bSmrg
89296257f37dSmrg	  # Before this point, $major must not contain '.'.
8930f3561b8bSmrg	  major=.$major
89316257f37dSmrg	  versuffix=$major.$revision
8932f3561b8bSmrg	  ;;
8933f3561b8bSmrg
8934bd304fc0Smrg	linux) # correct to gnu/linux during the next big refactor
8935f3561b8bSmrg	  func_arith $current - $age
8936f3561b8bSmrg	  major=.$func_arith_result
89376257f37dSmrg	  versuffix=$major.$age.$revision
8938f3561b8bSmrg	  ;;
8939f3561b8bSmrg
8940f3561b8bSmrg	osf)
8941f3561b8bSmrg	  func_arith $current - $age
8942f3561b8bSmrg	  major=.$func_arith_result
89436257f37dSmrg	  versuffix=.$current.$age.$revision
89446257f37dSmrg	  verstring=$current.$age.$revision
8945f3561b8bSmrg
8946f3561b8bSmrg	  # Add in all the interfaces that we are compatible with.
8947f3561b8bSmrg	  loop=$age
89486257f37dSmrg	  while test 0 -ne "$loop"; do
8949f3561b8bSmrg	    func_arith $current - $loop
8950f3561b8bSmrg	    iface=$func_arith_result
8951f3561b8bSmrg	    func_arith $loop - 1
8952f3561b8bSmrg	    loop=$func_arith_result
89536257f37dSmrg	    verstring=$verstring:$iface.0
8954f3561b8bSmrg	  done
8955f3561b8bSmrg
8956f3561b8bSmrg	  # Make executables depend on our current version.
89576257f37dSmrg	  func_append verstring ":$current.0"
8958f3561b8bSmrg	  ;;
8959f3561b8bSmrg
8960f3561b8bSmrg	qnx)
89616257f37dSmrg	  major=.$current
89626257f37dSmrg	  versuffix=.$current
89636257f37dSmrg	  ;;
89646257f37dSmrg
89656257f37dSmrg	sco)
89666257f37dSmrg	  major=.$current
89676257f37dSmrg	  versuffix=.$current
8968f3561b8bSmrg	  ;;
8969f3561b8bSmrg
8970f3561b8bSmrg	sunos)
89716257f37dSmrg	  major=.$current
89726257f37dSmrg	  versuffix=.$current.$revision
8973f3561b8bSmrg	  ;;
8974f3561b8bSmrg
8975f3561b8bSmrg	windows)
8976f3561b8bSmrg	  # Use '-' rather than '.', since we only want one
89776257f37dSmrg	  # extension on DOS 8.3 file systems.
8978f3561b8bSmrg	  func_arith $current - $age
8979f3561b8bSmrg	  major=$func_arith_result
89806257f37dSmrg	  versuffix=-$major
8981f3561b8bSmrg	  ;;
8982f3561b8bSmrg
8983f3561b8bSmrg	*)
89846257f37dSmrg	  func_fatal_configuration "unknown library version type '$version_type'"
8985f3561b8bSmrg	  ;;
8986f3561b8bSmrg	esac
8987f3561b8bSmrg
8988f3561b8bSmrg	# Clear the version info if we defaulted, and they specified a release.
8989f3561b8bSmrg	if test -z "$vinfo" && test -n "$release"; then
8990f3561b8bSmrg	  major=
8991f3561b8bSmrg	  case $version_type in
8992f3561b8bSmrg	  darwin)
8993f3561b8bSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
8994f3561b8bSmrg	    # problems, so we reset it completely
8995f3561b8bSmrg	    verstring=
8996f3561b8bSmrg	    ;;
8997f3561b8bSmrg	  *)
89986257f37dSmrg	    verstring=0.0
8999f3561b8bSmrg	    ;;
9000f3561b8bSmrg	  esac
90016257f37dSmrg	  if test no = "$need_version"; then
9002f3561b8bSmrg	    versuffix=
9003f3561b8bSmrg	  else
90046257f37dSmrg	    versuffix=.0.0
9005f3561b8bSmrg	  fi
9006f3561b8bSmrg	fi
9007f3561b8bSmrg
9008f3561b8bSmrg	# Remove version info from name if versioning should be avoided
90096257f37dSmrg	if test yes,no = "$avoid_version,$need_version"; then
9010f3561b8bSmrg	  major=
9011f3561b8bSmrg	  versuffix=
90126257f37dSmrg	  verstring=
9013f3561b8bSmrg	fi
9014f3561b8bSmrg
9015f3561b8bSmrg	# Check to see if the archive will have undefined symbols.
90166257f37dSmrg	if test yes = "$allow_undefined"; then
90176257f37dSmrg	  if test unsupported = "$allow_undefined_flag"; then
90186257f37dSmrg	    if test yes = "$build_old_libs"; then
90196257f37dSmrg	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
90206257f37dSmrg	      build_libtool_libs=no
90216257f37dSmrg	    else
90226257f37dSmrg	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
90236257f37dSmrg	    fi
9024f3561b8bSmrg	  fi
9025f3561b8bSmrg	else
9026f3561b8bSmrg	  # Don't allow undefined symbols.
90276257f37dSmrg	  allow_undefined_flag=$no_undefined_flag
9028f3561b8bSmrg	fi
9029f3561b8bSmrg
9030f3561b8bSmrg      fi
9031f3561b8bSmrg
90326257f37dSmrg      func_generate_dlsyms "$libname" "$libname" :
9033bd304fc0Smrg      func_append libobjs " $symfileobj"
90346257f37dSmrg      test " " = "$libobjs" && libobjs=
9035f3561b8bSmrg
90366257f37dSmrg      if test relink != "$opt_mode"; then
9037f3561b8bSmrg	# Remove our outputs, but don't remove object files since they
9038f3561b8bSmrg	# may have been created when compiling PIC objects.
9039f3561b8bSmrg	removelist=
9040f3561b8bSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
9041f3561b8bSmrg	for p in $tempremovelist; do
9042f3561b8bSmrg	  case $p in
9043f3561b8bSmrg	    *.$objext | *.gcno)
9044f3561b8bSmrg	       ;;
90456257f37dSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
90466257f37dSmrg	       if test -n "$precious_files_regex"; then
9047f3561b8bSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
9048f3561b8bSmrg		 then
9049f3561b8bSmrg		   continue
9050f3561b8bSmrg		 fi
9051f3561b8bSmrg	       fi
9052bd304fc0Smrg	       func_append removelist " $p"
9053f3561b8bSmrg	       ;;
9054f3561b8bSmrg	    *) ;;
9055f3561b8bSmrg	  esac
9056f3561b8bSmrg	done
9057f3561b8bSmrg	test -n "$removelist" && \
9058f3561b8bSmrg	  func_show_eval "${RM}r \$removelist"
9059f3561b8bSmrg      fi
9060f3561b8bSmrg
9061f3561b8bSmrg      # Now set the variables for building old libraries.
90626257f37dSmrg      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
9063bd304fc0Smrg	func_append oldlibs " $output_objdir/$libname.$libext"
9064f3561b8bSmrg
9065f3561b8bSmrg	# Transform .lo files to .o files.
90666257f37dSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
9067f3561b8bSmrg      fi
9068f3561b8bSmrg
9069f3561b8bSmrg      # Eliminate all temporary directories.
9070f3561b8bSmrg      #for path in $notinst_path; do
9071bd304fc0Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
9072bd304fc0Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
9073bd304fc0Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
9074f3561b8bSmrg      #done
9075f3561b8bSmrg
9076f3561b8bSmrg      if test -n "$xrpath"; then
9077f3561b8bSmrg	# If the user specified any rpath flags, then add them.
9078f3561b8bSmrg	temp_xrpath=
9079f3561b8bSmrg	for libdir in $xrpath; do
9080bd304fc0Smrg	  func_replace_sysroot "$libdir"
9081bd304fc0Smrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
9082f3561b8bSmrg	  case "$finalize_rpath " in
9083f3561b8bSmrg	  *" $libdir "*) ;;
9084bd304fc0Smrg	  *) func_append finalize_rpath " $libdir" ;;
9085f3561b8bSmrg	  esac
9086f3561b8bSmrg	done
90876257f37dSmrg	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
9088f3561b8bSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
9089f3561b8bSmrg	fi
9090f3561b8bSmrg      fi
9091f3561b8bSmrg
9092f3561b8bSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
90936257f37dSmrg      old_dlfiles=$dlfiles
9094f3561b8bSmrg      dlfiles=
9095f3561b8bSmrg      for lib in $old_dlfiles; do
9096f3561b8bSmrg	case " $dlprefiles $dlfiles " in
9097f3561b8bSmrg	*" $lib "*) ;;
9098bd304fc0Smrg	*) func_append dlfiles " $lib" ;;
9099f3561b8bSmrg	esac
9100f3561b8bSmrg      done
9101f3561b8bSmrg
9102f3561b8bSmrg      # Make sure dlprefiles contains only unique files
91036257f37dSmrg      old_dlprefiles=$dlprefiles
9104f3561b8bSmrg      dlprefiles=
9105f3561b8bSmrg      for lib in $old_dlprefiles; do
9106f3561b8bSmrg	case "$dlprefiles " in
9107f3561b8bSmrg	*" $lib "*) ;;
9108bd304fc0Smrg	*) func_append dlprefiles " $lib" ;;
9109f3561b8bSmrg	esac
9110f3561b8bSmrg      done
9111f3561b8bSmrg
91126257f37dSmrg      if test yes = "$build_libtool_libs"; then
9113f3561b8bSmrg	if test -n "$rpath"; then
9114f3561b8bSmrg	  case $host in
9115bd304fc0Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
9116f3561b8bSmrg	    # these systems don't actually have a c library (as such)!
9117f3561b8bSmrg	    ;;
9118f3561b8bSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
9119f3561b8bSmrg	    # Rhapsody C library is in the System framework
9120bd304fc0Smrg	    func_append deplibs " System.ltframework"
9121f3561b8bSmrg	    ;;
9122f3561b8bSmrg	  *-*-netbsd*)
9123f3561b8bSmrg	    # Don't link with libc until the a.out ld.so is fixed.
9124f3561b8bSmrg	    ;;
9125f3561b8bSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
9126f3561b8bSmrg	    # Do not include libc due to us having libc/libc_r.
9127f3561b8bSmrg	    ;;
9128f3561b8bSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
9129f3561b8bSmrg	    # Causes problems with __ctype
9130f3561b8bSmrg	    ;;
9131f3561b8bSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
9132f3561b8bSmrg	    # Compiler inserts libc in the correct place for threads to work
9133f3561b8bSmrg	    ;;
9134f3561b8bSmrg	  *)
9135f3561b8bSmrg	    # Add libc to deplibs on all other systems if necessary.
91366257f37dSmrg	    if test yes = "$build_libtool_need_lc"; then
9137bd304fc0Smrg	      func_append deplibs " -lc"
9138f3561b8bSmrg	    fi
9139f3561b8bSmrg	    ;;
9140f3561b8bSmrg	  esac
9141f3561b8bSmrg	fi
9142f3561b8bSmrg
9143f3561b8bSmrg	# Transform deplibs into only deplibs that can be linked in shared.
9144f3561b8bSmrg	name_save=$name
9145f3561b8bSmrg	libname_save=$libname
9146f3561b8bSmrg	release_save=$release
9147f3561b8bSmrg	versuffix_save=$versuffix
9148f3561b8bSmrg	major_save=$major
9149f3561b8bSmrg	# I'm not sure if I'm treating the release correctly.  I think
9150f3561b8bSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
9151f3561b8bSmrg	# add it in twice.  Is that correct?
91526257f37dSmrg	release=
91536257f37dSmrg	versuffix=
91546257f37dSmrg	major=
9155f3561b8bSmrg	newdeplibs=
9156f3561b8bSmrg	droppeddeps=no
9157f3561b8bSmrg	case $deplibs_check_method in
9158f3561b8bSmrg	pass_all)
9159f3561b8bSmrg	  # Don't check for shared/static.  Everything works.
9160f3561b8bSmrg	  # This might be a little naive.  We might want to check
9161f3561b8bSmrg	  # whether the library exists or not.  But this is on
9162f3561b8bSmrg	  # osf3 & osf4 and I'm not really sure... Just
9163f3561b8bSmrg	  # implementing what was already the behavior.
9164f3561b8bSmrg	  newdeplibs=$deplibs
9165f3561b8bSmrg	  ;;
9166f3561b8bSmrg	test_compile)
9167f3561b8bSmrg	  # This code stresses the "libraries are programs" paradigm to its
9168f3561b8bSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
9169f3561b8bSmrg	  # against the deplibs as a proxy for the library.  Then we can check
9170f3561b8bSmrg	  # whether they linked in statically or dynamically with ldd.
9171f3561b8bSmrg	  $opt_dry_run || $RM conftest.c
9172f3561b8bSmrg	  cat > conftest.c <<EOF
9173f3561b8bSmrg	  int main() { return 0; }
9174f3561b8bSmrgEOF
9175f3561b8bSmrg	  $opt_dry_run || $RM conftest
9176f3561b8bSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
9177f3561b8bSmrg	    ldd_output=`ldd conftest`
9178f3561b8bSmrg	    for i in $deplibs; do
9179f3561b8bSmrg	      case $i in
9180f3561b8bSmrg	      -l*)
9181f3561b8bSmrg		func_stripname -l '' "$i"
9182f3561b8bSmrg		name=$func_stripname_result
91836257f37dSmrg		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9184f3561b8bSmrg		  case " $predeps $postdeps " in
9185f3561b8bSmrg		  *" $i "*)
9186bd304fc0Smrg		    func_append newdeplibs " $i"
91876257f37dSmrg		    i=
9188f3561b8bSmrg		    ;;
9189f3561b8bSmrg		  esac
9190f3561b8bSmrg		fi
91916257f37dSmrg		if test -n "$i"; then
9192f3561b8bSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
9193f3561b8bSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9194f3561b8bSmrg		  set dummy $deplib_matches; shift
9195f3561b8bSmrg		  deplib_match=$1
91966257f37dSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9197bd304fc0Smrg		    func_append newdeplibs " $i"
9198f3561b8bSmrg		  else
9199f3561b8bSmrg		    droppeddeps=yes
9200bd304fc0Smrg		    echo
9201f3561b8bSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9202bd304fc0Smrg		    echo "*** I have the capability to make that library automatically link in when"
9203bd304fc0Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
9204bd304fc0Smrg		    echo "*** shared version of the library, which I believe you do not have"
9205bd304fc0Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
9206bd304fc0Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
9207f3561b8bSmrg		  fi
9208f3561b8bSmrg		fi
9209f3561b8bSmrg		;;
9210f3561b8bSmrg	      *)
9211bd304fc0Smrg		func_append newdeplibs " $i"
9212f3561b8bSmrg		;;
9213f3561b8bSmrg	      esac
9214f3561b8bSmrg	    done
9215f3561b8bSmrg	  else
9216f3561b8bSmrg	    # Error occurred in the first compile.  Let's try to salvage
9217f3561b8bSmrg	    # the situation: Compile a separate program for each library.
9218f3561b8bSmrg	    for i in $deplibs; do
9219f3561b8bSmrg	      case $i in
9220f3561b8bSmrg	      -l*)
9221f3561b8bSmrg		func_stripname -l '' "$i"
9222f3561b8bSmrg		name=$func_stripname_result
9223f3561b8bSmrg		$opt_dry_run || $RM conftest
9224f3561b8bSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
9225f3561b8bSmrg		  ldd_output=`ldd conftest`
92266257f37dSmrg		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9227f3561b8bSmrg		    case " $predeps $postdeps " in
9228f3561b8bSmrg		    *" $i "*)
9229bd304fc0Smrg		      func_append newdeplibs " $i"
92306257f37dSmrg		      i=
9231f3561b8bSmrg		      ;;
9232f3561b8bSmrg		    esac
9233f3561b8bSmrg		  fi
92346257f37dSmrg		  if test -n "$i"; then
9235f3561b8bSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
9236f3561b8bSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9237f3561b8bSmrg		    set dummy $deplib_matches; shift
9238f3561b8bSmrg		    deplib_match=$1
92396257f37dSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9240bd304fc0Smrg		      func_append newdeplibs " $i"
9241f3561b8bSmrg		    else
9242f3561b8bSmrg		      droppeddeps=yes
9243bd304fc0Smrg		      echo
9244f3561b8bSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9245bd304fc0Smrg		      echo "*** I have the capability to make that library automatically link in when"
9246bd304fc0Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
9247bd304fc0Smrg		      echo "*** shared version of the library, which you do not appear to have"
9248bd304fc0Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
9249bd304fc0Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
9250f3561b8bSmrg		    fi
9251f3561b8bSmrg		  fi
9252f3561b8bSmrg		else
9253f3561b8bSmrg		  droppeddeps=yes
9254bd304fc0Smrg		  echo
9255f3561b8bSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
9256bd304fc0Smrg		  echo "*** make it link in!  You will probably need to install it or some"
9257bd304fc0Smrg		  echo "*** library that it depends on before this library will be fully"
9258bd304fc0Smrg		  echo "*** functional.  Installing it before continuing would be even better."
9259f3561b8bSmrg		fi
9260f3561b8bSmrg		;;
9261f3561b8bSmrg	      *)
9262bd304fc0Smrg		func_append newdeplibs " $i"
9263f3561b8bSmrg		;;
9264f3561b8bSmrg	      esac
9265f3561b8bSmrg	    done
9266f3561b8bSmrg	  fi
9267f3561b8bSmrg	  ;;
9268f3561b8bSmrg	file_magic*)
9269f3561b8bSmrg	  set dummy $deplibs_check_method; shift
9270f3561b8bSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9271f3561b8bSmrg	  for a_deplib in $deplibs; do
9272f3561b8bSmrg	    case $a_deplib in
9273f3561b8bSmrg	    -l*)
9274f3561b8bSmrg	      func_stripname -l '' "$a_deplib"
9275f3561b8bSmrg	      name=$func_stripname_result
92766257f37dSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9277f3561b8bSmrg		case " $predeps $postdeps " in
9278f3561b8bSmrg		*" $a_deplib "*)
9279bd304fc0Smrg		  func_append newdeplibs " $a_deplib"
92806257f37dSmrg		  a_deplib=
9281f3561b8bSmrg		  ;;
9282f3561b8bSmrg		esac
9283f3561b8bSmrg	      fi
92846257f37dSmrg	      if test -n "$a_deplib"; then
9285f3561b8bSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
9286bd304fc0Smrg		if test -n "$file_magic_glob"; then
9287bd304fc0Smrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
9288bd304fc0Smrg		else
9289bd304fc0Smrg		  libnameglob=$libname
9290bd304fc0Smrg		fi
92916257f37dSmrg		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
9292f3561b8bSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
92936257f37dSmrg		  if test yes = "$want_nocaseglob"; then
9294bd304fc0Smrg		    shopt -s nocaseglob
9295bd304fc0Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9296bd304fc0Smrg		    $nocaseglob
9297bd304fc0Smrg		  else
9298bd304fc0Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9299bd304fc0Smrg		  fi
9300f3561b8bSmrg		  for potent_lib in $potential_libs; do
9301f3561b8bSmrg		      # Follow soft links.
9302f3561b8bSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
9303f3561b8bSmrg			 $GREP " -> " >/dev/null; then
9304f3561b8bSmrg			continue
9305f3561b8bSmrg		      fi
9306f3561b8bSmrg		      # The statement above tries to avoid entering an
9307f3561b8bSmrg		      # endless loop below, in case of cyclic links.
9308f3561b8bSmrg		      # We might still enter an endless loop, since a link
9309f3561b8bSmrg		      # loop can be closed while we follow links,
9310f3561b8bSmrg		      # but so what?
93116257f37dSmrg		      potlib=$potent_lib
9312f3561b8bSmrg		      while test -h "$potlib" 2>/dev/null; do
93136257f37dSmrg			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
9314f3561b8bSmrg			case $potliblink in
93156257f37dSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
93166257f37dSmrg			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
9317f3561b8bSmrg			esac
9318f3561b8bSmrg		      done
9319f3561b8bSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
9320f3561b8bSmrg			 $SED -e 10q |
9321f3561b8bSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
9322bd304fc0Smrg			func_append newdeplibs " $a_deplib"
93236257f37dSmrg			a_deplib=
9324f3561b8bSmrg			break 2
9325f3561b8bSmrg		      fi
9326f3561b8bSmrg		  done
9327f3561b8bSmrg		done
9328f3561b8bSmrg	      fi
93296257f37dSmrg	      if test -n "$a_deplib"; then
9330f3561b8bSmrg		droppeddeps=yes
9331bd304fc0Smrg		echo
9332f3561b8bSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9333bd304fc0Smrg		echo "*** I have the capability to make that library automatically link in when"
9334bd304fc0Smrg		echo "*** you link to this library.  But I can only do this if you have a"
9335bd304fc0Smrg		echo "*** shared version of the library, which you do not appear to have"
9336bd304fc0Smrg		echo "*** because I did check the linker path looking for a file starting"
93376257f37dSmrg		if test -z "$potlib"; then
9338f3561b8bSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
9339f3561b8bSmrg		else
9340f3561b8bSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
9341f3561b8bSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
9342f3561b8bSmrg		fi
9343f3561b8bSmrg	      fi
9344f3561b8bSmrg	      ;;
9345f3561b8bSmrg	    *)
9346f3561b8bSmrg	      # Add a -L argument.
9347bd304fc0Smrg	      func_append newdeplibs " $a_deplib"
9348f3561b8bSmrg	      ;;
9349f3561b8bSmrg	    esac
9350f3561b8bSmrg	  done # Gone through all deplibs.
9351f3561b8bSmrg	  ;;
9352f3561b8bSmrg	match_pattern*)
9353f3561b8bSmrg	  set dummy $deplibs_check_method; shift
9354f3561b8bSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9355f3561b8bSmrg	  for a_deplib in $deplibs; do
9356f3561b8bSmrg	    case $a_deplib in
9357f3561b8bSmrg	    -l*)
9358f3561b8bSmrg	      func_stripname -l '' "$a_deplib"
9359f3561b8bSmrg	      name=$func_stripname_result
93606257f37dSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9361f3561b8bSmrg		case " $predeps $postdeps " in
9362f3561b8bSmrg		*" $a_deplib "*)
9363bd304fc0Smrg		  func_append newdeplibs " $a_deplib"
93646257f37dSmrg		  a_deplib=
9365f3561b8bSmrg		  ;;
9366f3561b8bSmrg		esac
9367f3561b8bSmrg	      fi
93686257f37dSmrg	      if test -n "$a_deplib"; then
9369f3561b8bSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
9370f3561b8bSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9371f3561b8bSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
9372f3561b8bSmrg		  for potent_lib in $potential_libs; do
93736257f37dSmrg		    potlib=$potent_lib # see symlink-check above in file_magic test
9374bd304fc0Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
9375f3561b8bSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
9376bd304fc0Smrg		      func_append newdeplibs " $a_deplib"
93776257f37dSmrg		      a_deplib=
9378f3561b8bSmrg		      break 2
9379f3561b8bSmrg		    fi
9380f3561b8bSmrg		  done
9381f3561b8bSmrg		done
9382f3561b8bSmrg	      fi
93836257f37dSmrg	      if test -n "$a_deplib"; then
9384f3561b8bSmrg		droppeddeps=yes
9385bd304fc0Smrg		echo
9386f3561b8bSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9387bd304fc0Smrg		echo "*** I have the capability to make that library automatically link in when"
9388bd304fc0Smrg		echo "*** you link to this library.  But I can only do this if you have a"
9389bd304fc0Smrg		echo "*** shared version of the library, which you do not appear to have"
9390bd304fc0Smrg		echo "*** because I did check the linker path looking for a file starting"
93916257f37dSmrg		if test -z "$potlib"; then
9392f3561b8bSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
9393f3561b8bSmrg		else
9394f3561b8bSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
9395f3561b8bSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
9396f3561b8bSmrg		fi
9397f3561b8bSmrg	      fi
9398f3561b8bSmrg	      ;;
9399f3561b8bSmrg	    *)
9400f3561b8bSmrg	      # Add a -L argument.
9401bd304fc0Smrg	      func_append newdeplibs " $a_deplib"
9402f3561b8bSmrg	      ;;
9403f3561b8bSmrg	    esac
9404f3561b8bSmrg	  done # Gone through all deplibs.
9405f3561b8bSmrg	  ;;
9406f3561b8bSmrg	none | unknown | *)
94076257f37dSmrg	  newdeplibs=
9408bd304fc0Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
94096257f37dSmrg	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
94106257f37dSmrg	    for i in $predeps $postdeps; do
9411f3561b8bSmrg	      # can't use Xsed below, because $i might contain '/'
94126257f37dSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
9413f3561b8bSmrg	    done
9414f3561b8bSmrg	  fi
9415bd304fc0Smrg	  case $tmp_deplibs in
9416bd304fc0Smrg	  *[!\	\ ]*)
9417bd304fc0Smrg	    echo
94186257f37dSmrg	    if test none = "$deplibs_check_method"; then
9419bd304fc0Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
9420f3561b8bSmrg	    else
9421bd304fc0Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
9422f3561b8bSmrg	    fi
9423bd304fc0Smrg	    echo "*** All declared inter-library dependencies are being dropped."
9424f3561b8bSmrg	    droppeddeps=yes
9425bd304fc0Smrg	    ;;
9426bd304fc0Smrg	  esac
9427f3561b8bSmrg	  ;;
9428f3561b8bSmrg	esac
9429f3561b8bSmrg	versuffix=$versuffix_save
9430f3561b8bSmrg	major=$major_save
9431f3561b8bSmrg	release=$release_save
9432f3561b8bSmrg	libname=$libname_save
9433f3561b8bSmrg	name=$name_save
9434f3561b8bSmrg
9435f3561b8bSmrg	case $host in
9436f3561b8bSmrg	*-*-rhapsody* | *-*-darwin1.[012])
9437f3561b8bSmrg	  # On Rhapsody replace the C library with the System framework
9438bd304fc0Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
9439f3561b8bSmrg	  ;;
9440f3561b8bSmrg	esac
9441f3561b8bSmrg
94426257f37dSmrg	if test yes = "$droppeddeps"; then
94436257f37dSmrg	  if test yes = "$module"; then
9444bd304fc0Smrg	    echo
9445bd304fc0Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
9446f3561b8bSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
9447bd304fc0Smrg	    echo "*** a static module, that should work as long as the dlopening"
9448bd304fc0Smrg	    echo "*** application is linked with the -dlopen flag."
9449f3561b8bSmrg	    if test -z "$global_symbol_pipe"; then
9450bd304fc0Smrg	      echo
9451bd304fc0Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
94526257f37dSmrg	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
9453bd304fc0Smrg	      echo "*** not find such a program.  So, this module is probably useless."
94546257f37dSmrg	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
9455f3561b8bSmrg	    fi
94566257f37dSmrg	    if test no = "$build_old_libs"; then
94576257f37dSmrg	      oldlibs=$output_objdir/$libname.$libext
9458f3561b8bSmrg	      build_libtool_libs=module
9459f3561b8bSmrg	      build_old_libs=yes
9460f3561b8bSmrg	    else
9461f3561b8bSmrg	      build_libtool_libs=no
9462f3561b8bSmrg	    fi
9463f3561b8bSmrg	  else
9464bd304fc0Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
9465bd304fc0Smrg	    echo "*** automatically added whenever a program is linked with this library"
9466bd304fc0Smrg	    echo "*** or is declared to -dlopen it."
9467f3561b8bSmrg
94686257f37dSmrg	    if test no = "$allow_undefined"; then
9469bd304fc0Smrg	      echo
9470bd304fc0Smrg	      echo "*** Since this library must not contain undefined symbols,"
9471bd304fc0Smrg	      echo "*** because either the platform does not support them or"
9472bd304fc0Smrg	      echo "*** it was explicitly requested with -no-undefined,"
9473bd304fc0Smrg	      echo "*** libtool will only create a static version of it."
94746257f37dSmrg	      if test no = "$build_old_libs"; then
94756257f37dSmrg		oldlibs=$output_objdir/$libname.$libext
9476f3561b8bSmrg		build_libtool_libs=module
9477f3561b8bSmrg		build_old_libs=yes
9478f3561b8bSmrg	      else
9479f3561b8bSmrg		build_libtool_libs=no
9480f3561b8bSmrg	      fi
9481f3561b8bSmrg	    fi
9482f3561b8bSmrg	  fi
9483f3561b8bSmrg	fi
9484f3561b8bSmrg	# Done checking deplibs!
9485f3561b8bSmrg	deplibs=$newdeplibs
9486f3561b8bSmrg      fi
9487f3561b8bSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
9488f3561b8bSmrg      case $host in
9489f3561b8bSmrg	*-*-darwin*)
9490bd304fc0Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9491bd304fc0Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9492bd304fc0Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9493f3561b8bSmrg	  ;;
9494f3561b8bSmrg      esac
9495f3561b8bSmrg
9496f3561b8bSmrg      # move library search paths that coincide with paths to not yet
9497f3561b8bSmrg      # installed libraries to the beginning of the library search list
9498f3561b8bSmrg      new_libs=
9499f3561b8bSmrg      for path in $notinst_path; do
9500f3561b8bSmrg	case " $new_libs " in
9501f3561b8bSmrg	*" -L$path/$objdir "*) ;;
9502f3561b8bSmrg	*)
9503f3561b8bSmrg	  case " $deplibs " in
9504f3561b8bSmrg	  *" -L$path/$objdir "*)
9505bd304fc0Smrg	    func_append new_libs " -L$path/$objdir" ;;
9506f3561b8bSmrg	  esac
9507f3561b8bSmrg	  ;;
9508f3561b8bSmrg	esac
9509f3561b8bSmrg      done
9510f3561b8bSmrg      for deplib in $deplibs; do
9511f3561b8bSmrg	case $deplib in
9512f3561b8bSmrg	-L*)
9513f3561b8bSmrg	  case " $new_libs " in
9514f3561b8bSmrg	  *" $deplib "*) ;;
9515bd304fc0Smrg	  *) func_append new_libs " $deplib" ;;
9516f3561b8bSmrg	  esac
9517f3561b8bSmrg	  ;;
9518bd304fc0Smrg	*) func_append new_libs " $deplib" ;;
9519f3561b8bSmrg	esac
9520f3561b8bSmrg      done
95216257f37dSmrg      deplibs=$new_libs
9522f3561b8bSmrg
9523f3561b8bSmrg      # All the library-specific variables (install_libdir is set above).
9524f3561b8bSmrg      library_names=
9525f3561b8bSmrg      old_library=
9526f3561b8bSmrg      dlname=
9527fc5a983dSmrg
9528f3561b8bSmrg      # Test again, we may have decided not to build it any more
95296257f37dSmrg      if test yes = "$build_libtool_libs"; then
95306257f37dSmrg	# Remove $wl instances when linking with ld.
9531bd304fc0Smrg	# FIXME: should test the right _cmds variable.
9532bd304fc0Smrg	case $archive_cmds in
9533bd304fc0Smrg	  *\$LD\ *) wl= ;;
9534bd304fc0Smrg        esac
95356257f37dSmrg	if test yes = "$hardcode_into_libs"; then
9536f3561b8bSmrg	  # Hardcode the library paths
9537f3561b8bSmrg	  hardcode_libdirs=
9538f3561b8bSmrg	  dep_rpath=
95396257f37dSmrg	  rpath=$finalize_rpath
95406257f37dSmrg	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
9541f3561b8bSmrg	  for libdir in $rpath; do
9542f3561b8bSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
9543f3561b8bSmrg	      if test -n "$hardcode_libdir_separator"; then
9544bd304fc0Smrg		func_replace_sysroot "$libdir"
9545bd304fc0Smrg		libdir=$func_replace_sysroot_result
9546f3561b8bSmrg		if test -z "$hardcode_libdirs"; then
95476257f37dSmrg		  hardcode_libdirs=$libdir
9548f3561b8bSmrg		else
9549f3561b8bSmrg		  # Just accumulate the unique libdirs.
9550f3561b8bSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
9551f3561b8bSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
9552f3561b8bSmrg		    ;;
9553f3561b8bSmrg		  *)
9554bd304fc0Smrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
9555f3561b8bSmrg		    ;;
9556f3561b8bSmrg		  esac
9557f3561b8bSmrg		fi
9558f3561b8bSmrg	      else
9559f3561b8bSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
9560bd304fc0Smrg		func_append dep_rpath " $flag"
9561f3561b8bSmrg	      fi
9562f3561b8bSmrg	    elif test -n "$runpath_var"; then
9563f3561b8bSmrg	      case "$perm_rpath " in
9564f3561b8bSmrg	      *" $libdir "*) ;;
9565bd304fc0Smrg	      *) func_append perm_rpath " $libdir" ;;
9566f3561b8bSmrg	      esac
9567f3561b8bSmrg	    fi
9568f3561b8bSmrg	  done
9569f3561b8bSmrg	  # Substitute the hardcoded libdirs into the rpath.
9570f3561b8bSmrg	  if test -n "$hardcode_libdir_separator" &&
9571f3561b8bSmrg	     test -n "$hardcode_libdirs"; then
95726257f37dSmrg	    libdir=$hardcode_libdirs
9573bd304fc0Smrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
9574f3561b8bSmrg	  fi
9575f3561b8bSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
9576f3561b8bSmrg	    # We should set the runpath_var.
9577f3561b8bSmrg	    rpath=
9578f3561b8bSmrg	    for dir in $perm_rpath; do
9579bd304fc0Smrg	      func_append rpath "$dir:"
9580f3561b8bSmrg	    done
9581f3561b8bSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
9582f3561b8bSmrg	  fi
9583f3561b8bSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
9584f3561b8bSmrg	fi
9585fc5a983dSmrg
95866257f37dSmrg	shlibpath=$finalize_shlibpath
95876257f37dSmrg	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
9588f3561b8bSmrg	if test -n "$shlibpath"; then
9589f3561b8bSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
9590f3561b8bSmrg	fi
9591fc5a983dSmrg
9592f3561b8bSmrg	# Get the real and link names of the library.
9593f3561b8bSmrg	eval shared_ext=\"$shrext_cmds\"
9594f3561b8bSmrg	eval library_names=\"$library_names_spec\"
9595f3561b8bSmrg	set dummy $library_names
9596f3561b8bSmrg	shift
95976257f37dSmrg	realname=$1
9598f3561b8bSmrg	shift
9599fc5a983dSmrg
9600f3561b8bSmrg	if test -n "$soname_spec"; then
9601f3561b8bSmrg	  eval soname=\"$soname_spec\"
9602fc5a983dSmrg	else
96036257f37dSmrg	  soname=$realname
9604f3561b8bSmrg	fi
9605f3561b8bSmrg	if test -z "$dlname"; then
9606f3561b8bSmrg	  dlname=$soname
9607fc5a983dSmrg	fi
9608fc5a983dSmrg
96096257f37dSmrg	lib=$output_objdir/$realname
9610f3561b8bSmrg	linknames=
9611f3561b8bSmrg	for link
9612f3561b8bSmrg	do
9613bd304fc0Smrg	  func_append linknames " $link"
9614f3561b8bSmrg	done
9615fc5a983dSmrg
9616f3561b8bSmrg	# Use standard objects if they are pic
9617bd304fc0Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
9618f3561b8bSmrg	test "X$libobjs" = "X " && libobjs=
9619fc5a983dSmrg
9620f3561b8bSmrg	delfiles=
9621f3561b8bSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
9622f3561b8bSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
96236257f37dSmrg	  export_symbols=$output_objdir/$libname.uexp
9624bd304fc0Smrg	  func_append delfiles " $export_symbols"
9625f3561b8bSmrg	fi
9626fc5a983dSmrg
9627f3561b8bSmrg	orig_export_symbols=
9628f3561b8bSmrg	case $host_os in
9629f3561b8bSmrg	cygwin* | mingw* | cegcc*)
9630f3561b8bSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
9631f3561b8bSmrg	    # exporting using user supplied symfile
96326257f37dSmrg	    func_dll_def_p "$export_symbols" || {
9633f3561b8bSmrg	      # and it's NOT already a .def file. Must figure out
9634f3561b8bSmrg	      # which of the given symbols are data symbols and tag
9635f3561b8bSmrg	      # them as such. So, trigger use of export_symbols_cmds.
9636f3561b8bSmrg	      # export_symbols gets reassigned inside the "prepare
9637f3561b8bSmrg	      # the list of exported symbols" if statement, so the
9638f3561b8bSmrg	      # include_expsyms logic still works.
96396257f37dSmrg	      orig_export_symbols=$export_symbols
9640f3561b8bSmrg	      export_symbols=
9641f3561b8bSmrg	      always_export_symbols=yes
96426257f37dSmrg	    }
9643f3561b8bSmrg	  fi
9644f3561b8bSmrg	  ;;
9645f3561b8bSmrg	esac
9646fc5a983dSmrg
9647f3561b8bSmrg	# Prepare the list of exported symbols
9648f3561b8bSmrg	if test -z "$export_symbols"; then
96496257f37dSmrg	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
96506257f37dSmrg	    func_verbose "generating symbol list for '$libname.la'"
96516257f37dSmrg	    export_symbols=$output_objdir/$libname.exp
9652f3561b8bSmrg	    $opt_dry_run || $RM $export_symbols
9653f3561b8bSmrg	    cmds=$export_symbols_cmds
96546257f37dSmrg	    save_ifs=$IFS; IFS='~'
9655bd304fc0Smrg	    for cmd1 in $cmds; do
96566257f37dSmrg	      IFS=$save_ifs
9657bd304fc0Smrg	      # Take the normal branch if the nm_file_list_spec branch
9658bd304fc0Smrg	      # doesn't work or if tool conversion is not needed.
9659bd304fc0Smrg	      case $nm_file_list_spec~$to_tool_file_cmd in
9660bd304fc0Smrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
9661bd304fc0Smrg		  try_normal_branch=yes
9662bd304fc0Smrg		  eval cmd=\"$cmd1\"
9663bd304fc0Smrg		  func_len " $cmd"
9664bd304fc0Smrg		  len=$func_len_result
9665bd304fc0Smrg		  ;;
9666bd304fc0Smrg		*)
9667bd304fc0Smrg		  try_normal_branch=no
9668bd304fc0Smrg		  ;;
9669bd304fc0Smrg	      esac
96706257f37dSmrg	      if test yes = "$try_normal_branch" \
9671bd304fc0Smrg		 && { test "$len" -lt "$max_cmd_len" \
9672bd304fc0Smrg		      || test "$max_cmd_len" -le -1; }
9673bd304fc0Smrg	      then
9674bd304fc0Smrg		func_show_eval "$cmd" 'exit $?'
9675bd304fc0Smrg		skipped_export=false
9676bd304fc0Smrg	      elif test -n "$nm_file_list_spec"; then
9677bd304fc0Smrg		func_basename "$output"
9678bd304fc0Smrg		output_la=$func_basename_result
9679bd304fc0Smrg		save_libobjs=$libobjs
9680bd304fc0Smrg		save_output=$output
96816257f37dSmrg		output=$output_objdir/$output_la.nm
9682bd304fc0Smrg		func_to_tool_file "$output"
9683bd304fc0Smrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
9684bd304fc0Smrg		func_append delfiles " $output"
9685bd304fc0Smrg		func_verbose "creating $NM input file list: $output"
9686bd304fc0Smrg		for obj in $save_libobjs; do
9687bd304fc0Smrg		  func_to_tool_file "$obj"
9688bd304fc0Smrg		  $ECHO "$func_to_tool_file_result"
9689bd304fc0Smrg		done > "$output"
9690bd304fc0Smrg		eval cmd=\"$cmd1\"
9691f3561b8bSmrg		func_show_eval "$cmd" 'exit $?'
9692bd304fc0Smrg		output=$save_output
9693bd304fc0Smrg		libobjs=$save_libobjs
9694f3561b8bSmrg		skipped_export=false
9695f3561b8bSmrg	      else
9696f3561b8bSmrg		# The command line is too long to execute in one step.
9697f3561b8bSmrg		func_verbose "using reloadable object file for export list..."
9698f3561b8bSmrg		skipped_export=:
9699f3561b8bSmrg		# Break out early, otherwise skipped_export may be
9700f3561b8bSmrg		# set to false by a later but shorter cmd.
9701f3561b8bSmrg		break
9702f3561b8bSmrg	      fi
9703f3561b8bSmrg	    done
97046257f37dSmrg	    IFS=$save_ifs
97056257f37dSmrg	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
9706f3561b8bSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9707f3561b8bSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9708f3561b8bSmrg	    fi
9709f3561b8bSmrg	  fi
9710fc5a983dSmrg	fi
9711fc5a983dSmrg
9712f3561b8bSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
97136257f37dSmrg	  tmp_export_symbols=$export_symbols
97146257f37dSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9715bd304fc0Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9716fc5a983dSmrg	fi
9717fc5a983dSmrg
97186257f37dSmrg	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
9719f3561b8bSmrg	  # The given exports_symbols file has to be filtered, so filter it.
97206257f37dSmrg	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9721f3561b8bSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
97226257f37dSmrg	  # 's' commands, which not all seds can handle. GNU sed should be fine
9723f3561b8bSmrg	  # though. Also, the filter scales superlinearly with the number of
9724f3561b8bSmrg	  # global variables. join(1) would be nice here, but unfortunately
9725f3561b8bSmrg	  # isn't a blessed tool.
9726f3561b8bSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9727bd304fc0Smrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9728f3561b8bSmrg	  export_symbols=$output_objdir/$libname.def
9729f3561b8bSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9730f3561b8bSmrg	fi
9731fc5a983dSmrg
9732f3561b8bSmrg	tmp_deplibs=
9733f3561b8bSmrg	for test_deplib in $deplibs; do
9734f3561b8bSmrg	  case " $convenience " in
9735f3561b8bSmrg	  *" $test_deplib "*) ;;
9736f3561b8bSmrg	  *)
9737bd304fc0Smrg	    func_append tmp_deplibs " $test_deplib"
9738f3561b8bSmrg	    ;;
9739f3561b8bSmrg	  esac
9740f3561b8bSmrg	done
97416257f37dSmrg	deplibs=$tmp_deplibs
9742fc5a983dSmrg
9743f3561b8bSmrg	if test -n "$convenience"; then
9744f3561b8bSmrg	  if test -n "$whole_archive_flag_spec" &&
97456257f37dSmrg	    test yes = "$compiler_needs_object" &&
9746f3561b8bSmrg	    test -z "$libobjs"; then
9747f3561b8bSmrg	    # extract the archives, so we have objects to list.
9748f3561b8bSmrg	    # TODO: could optimize this to just extract one archive.
9749f3561b8bSmrg	    whole_archive_flag_spec=
9750f3561b8bSmrg	  fi
9751f3561b8bSmrg	  if test -n "$whole_archive_flag_spec"; then
9752f3561b8bSmrg	    save_libobjs=$libobjs
9753f3561b8bSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9754f3561b8bSmrg	    test "X$libobjs" = "X " && libobjs=
9755f3561b8bSmrg	  else
97566257f37dSmrg	    gentop=$output_objdir/${outputname}x
9757bd304fc0Smrg	    func_append generated " $gentop"
9758fc5a983dSmrg
9759f3561b8bSmrg	    func_extract_archives $gentop $convenience
9760bd304fc0Smrg	    func_append libobjs " $func_extract_archives_result"
9761f3561b8bSmrg	    test "X$libobjs" = "X " && libobjs=
9762f3561b8bSmrg	  fi
9763f3561b8bSmrg	fi
9764fc5a983dSmrg
97656257f37dSmrg	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
9766f3561b8bSmrg	  eval flag=\"$thread_safe_flag_spec\"
9767bd304fc0Smrg	  func_append linker_flags " $flag"
9768fc5a983dSmrg	fi
9769fc5a983dSmrg
9770f3561b8bSmrg	# Make a backup of the uninstalled library when relinking
97716257f37dSmrg	if test relink = "$opt_mode"; then
9772f3561b8bSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
9773f3561b8bSmrg	fi
9774fc5a983dSmrg
9775f3561b8bSmrg	# Do each of the archive commands.
97766257f37dSmrg	if test yes = "$module" && test -n "$module_cmds"; then
9777f3561b8bSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
9778f3561b8bSmrg	    eval test_cmds=\"$module_expsym_cmds\"
9779f3561b8bSmrg	    cmds=$module_expsym_cmds
9780f3561b8bSmrg	  else
9781f3561b8bSmrg	    eval test_cmds=\"$module_cmds\"
9782f3561b8bSmrg	    cmds=$module_cmds
9783f3561b8bSmrg	  fi
9784f3561b8bSmrg	else
9785f3561b8bSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
9786f3561b8bSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
9787f3561b8bSmrg	    cmds=$archive_expsym_cmds
9788f3561b8bSmrg	  else
9789f3561b8bSmrg	    eval test_cmds=\"$archive_cmds\"
9790f3561b8bSmrg	    cmds=$archive_cmds
9791f3561b8bSmrg	  fi
9792f3561b8bSmrg	fi
9793fc5a983dSmrg
97946257f37dSmrg	if test : != "$skipped_export" &&
9795f3561b8bSmrg	   func_len " $test_cmds" &&
9796f3561b8bSmrg	   len=$func_len_result &&
9797f3561b8bSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9798fc5a983dSmrg	  :
9799fc5a983dSmrg	else
9800f3561b8bSmrg	  # The command line is too long to link in one step, link piecewise
9801f3561b8bSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
9802f3561b8bSmrg	  # script.
9803f3561b8bSmrg
9804f3561b8bSmrg	  # Save the value of $output and $libobjs because we want to
9805f3561b8bSmrg	  # use them later.  If we have whole_archive_flag_spec, we
9806f3561b8bSmrg	  # want to use save_libobjs as it was before
9807f3561b8bSmrg	  # whole_archive_flag_spec was expanded, because we can't
9808f3561b8bSmrg	  # assume the linker understands whole_archive_flag_spec.
9809f3561b8bSmrg	  # This may have to be revisited, in case too many
9810f3561b8bSmrg	  # convenience libraries get linked in and end up exceeding
9811f3561b8bSmrg	  # the spec.
9812f3561b8bSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
9813f3561b8bSmrg	    save_libobjs=$libobjs
9814f3561b8bSmrg	  fi
9815f3561b8bSmrg	  save_output=$output
9816bd304fc0Smrg	  func_basename "$output"
9817bd304fc0Smrg	  output_la=$func_basename_result
9818f3561b8bSmrg
9819f3561b8bSmrg	  # Clear the reloadable object creation command queue and
9820f3561b8bSmrg	  # initialize k to one.
9821f3561b8bSmrg	  test_cmds=
9822f3561b8bSmrg	  concat_cmds=
9823f3561b8bSmrg	  objlist=
9824f3561b8bSmrg	  last_robj=
9825f3561b8bSmrg	  k=1
9826f3561b8bSmrg
98276257f37dSmrg	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
98286257f37dSmrg	    output=$output_objdir/$output_la.lnkscript
9829f3561b8bSmrg	    func_verbose "creating GNU ld script: $output"
9830bd304fc0Smrg	    echo 'INPUT (' > $output
9831f3561b8bSmrg	    for obj in $save_libobjs
9832f3561b8bSmrg	    do
9833bd304fc0Smrg	      func_to_tool_file "$obj"
9834bd304fc0Smrg	      $ECHO "$func_to_tool_file_result" >> $output
9835f3561b8bSmrg	    done
9836bd304fc0Smrg	    echo ')' >> $output
9837bd304fc0Smrg	    func_append delfiles " $output"
9838bd304fc0Smrg	    func_to_tool_file "$output"
9839bd304fc0Smrg	    output=$func_to_tool_file_result
98406257f37dSmrg	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
98416257f37dSmrg	    output=$output_objdir/$output_la.lnk
9842f3561b8bSmrg	    func_verbose "creating linker input file list: $output"
9843f3561b8bSmrg	    : > $output
9844f3561b8bSmrg	    set x $save_libobjs
9845f3561b8bSmrg	    shift
9846f3561b8bSmrg	    firstobj=
98476257f37dSmrg	    if test yes = "$compiler_needs_object"; then
9848f3561b8bSmrg	      firstobj="$1 "
9849f3561b8bSmrg	      shift
9850f3561b8bSmrg	    fi
9851f3561b8bSmrg	    for obj
9852f3561b8bSmrg	    do
9853bd304fc0Smrg	      func_to_tool_file "$obj"
9854bd304fc0Smrg	      $ECHO "$func_to_tool_file_result" >> $output
9855f3561b8bSmrg	    done
9856bd304fc0Smrg	    func_append delfiles " $output"
9857bd304fc0Smrg	    func_to_tool_file "$output"
9858bd304fc0Smrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
9859f3561b8bSmrg	  else
9860f3561b8bSmrg	    if test -n "$save_libobjs"; then
9861f3561b8bSmrg	      func_verbose "creating reloadable object files..."
98626257f37dSmrg	      output=$output_objdir/$output_la-$k.$objext
9863f3561b8bSmrg	      eval test_cmds=\"$reload_cmds\"
9864f3561b8bSmrg	      func_len " $test_cmds"
9865f3561b8bSmrg	      len0=$func_len_result
9866f3561b8bSmrg	      len=$len0
9867f3561b8bSmrg
9868f3561b8bSmrg	      # Loop over the list of objects to be linked.
9869f3561b8bSmrg	      for obj in $save_libobjs
9870f3561b8bSmrg	      do
9871f3561b8bSmrg		func_len " $obj"
9872f3561b8bSmrg		func_arith $len + $func_len_result
9873f3561b8bSmrg		len=$func_arith_result
98746257f37dSmrg		if test -z "$objlist" ||
9875f3561b8bSmrg		   test "$len" -lt "$max_cmd_len"; then
9876f3561b8bSmrg		  func_append objlist " $obj"
9877f3561b8bSmrg		else
9878f3561b8bSmrg		  # The command $test_cmds is almost too long, add a
9879f3561b8bSmrg		  # command to the queue.
98806257f37dSmrg		  if test 1 -eq "$k"; then
9881f3561b8bSmrg		    # The first file doesn't have a previous command to add.
9882bd304fc0Smrg		    reload_objs=$objlist
9883bd304fc0Smrg		    eval concat_cmds=\"$reload_cmds\"
9884f3561b8bSmrg		  else
9885f3561b8bSmrg		    # All subsequent reloadable object files will link in
9886f3561b8bSmrg		    # the last one created.
9887bd304fc0Smrg		    reload_objs="$objlist $last_robj"
9888bd304fc0Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
9889f3561b8bSmrg		  fi
98906257f37dSmrg		  last_robj=$output_objdir/$output_la-$k.$objext
9891f3561b8bSmrg		  func_arith $k + 1
9892f3561b8bSmrg		  k=$func_arith_result
98936257f37dSmrg		  output=$output_objdir/$output_la-$k.$objext
9894bd304fc0Smrg		  objlist=" $obj"
9895f3561b8bSmrg		  func_len " $last_robj"
9896f3561b8bSmrg		  func_arith $len0 + $func_len_result
9897f3561b8bSmrg		  len=$func_arith_result
9898f3561b8bSmrg		fi
9899f3561b8bSmrg	      done
9900f3561b8bSmrg	      # Handle the remaining objects by creating one last
9901f3561b8bSmrg	      # reloadable object file.  All subsequent reloadable object
9902f3561b8bSmrg	      # files will link in the last one created.
9903f3561b8bSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9904bd304fc0Smrg	      reload_objs="$objlist $last_robj"
99056257f37dSmrg	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
9906f3561b8bSmrg	      if test -n "$last_robj"; then
99076257f37dSmrg	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9908f3561b8bSmrg	      fi
9909bd304fc0Smrg	      func_append delfiles " $output"
9910fc5a983dSmrg
9911f3561b8bSmrg	    else
9912f3561b8bSmrg	      output=
9913f3561b8bSmrg	    fi
9914fc5a983dSmrg
99156257f37dSmrg	    ${skipped_export-false} && {
99166257f37dSmrg	      func_verbose "generating symbol list for '$libname.la'"
99176257f37dSmrg	      export_symbols=$output_objdir/$libname.exp
9918f3561b8bSmrg	      $opt_dry_run || $RM $export_symbols
9919f3561b8bSmrg	      libobjs=$output
9920f3561b8bSmrg	      # Append the command to create the export file.
9921f3561b8bSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9922f3561b8bSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
9923f3561b8bSmrg	      if test -n "$last_robj"; then
9924f3561b8bSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9925f3561b8bSmrg	      fi
99266257f37dSmrg	    }
9927fc5a983dSmrg
9928f3561b8bSmrg	    test -n "$save_libobjs" &&
9929f3561b8bSmrg	      func_verbose "creating a temporary reloadable object file: $output"
9930fc5a983dSmrg
9931f3561b8bSmrg	    # Loop through the commands generated above and execute them.
99326257f37dSmrg	    save_ifs=$IFS; IFS='~'
9933f3561b8bSmrg	    for cmd in $concat_cmds; do
99346257f37dSmrg	      IFS=$save_ifs
99356257f37dSmrg	      $opt_quiet || {
9936f3561b8bSmrg		  func_quote_for_expand "$cmd"
9937f3561b8bSmrg		  eval "func_echo $func_quote_for_expand_result"
9938f3561b8bSmrg	      }
9939f3561b8bSmrg	      $opt_dry_run || eval "$cmd" || {
9940f3561b8bSmrg		lt_exit=$?
9941f3561b8bSmrg
9942f3561b8bSmrg		# Restore the uninstalled library and exit
99436257f37dSmrg		if test relink = "$opt_mode"; then
9944f3561b8bSmrg		  ( cd "$output_objdir" && \
9945f3561b8bSmrg		    $RM "${realname}T" && \
9946f3561b8bSmrg		    $MV "${realname}U" "$realname" )
9947f3561b8bSmrg		fi
9948fc5a983dSmrg
9949f3561b8bSmrg		exit $lt_exit
9950f3561b8bSmrg	      }
9951f3561b8bSmrg	    done
99526257f37dSmrg	    IFS=$save_ifs
9953fc5a983dSmrg
9954f3561b8bSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
9955f3561b8bSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9956f3561b8bSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9957fc5a983dSmrg	    fi
9958fc5a983dSmrg	  fi
9959fc5a983dSmrg
99606257f37dSmrg          ${skipped_export-false} && {
9961f3561b8bSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
99626257f37dSmrg	      tmp_export_symbols=$export_symbols
99636257f37dSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9964bd304fc0Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9965f3561b8bSmrg	    fi
9966fc5a983dSmrg
9967f3561b8bSmrg	    if test -n "$orig_export_symbols"; then
9968f3561b8bSmrg	      # The given exports_symbols file has to be filtered, so filter it.
99696257f37dSmrg	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9970f3561b8bSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
99716257f37dSmrg	      # 's' commands, which not all seds can handle. GNU sed should be fine
9972f3561b8bSmrg	      # though. Also, the filter scales superlinearly with the number of
9973f3561b8bSmrg	      # global variables. join(1) would be nice here, but unfortunately
9974f3561b8bSmrg	      # isn't a blessed tool.
9975f3561b8bSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9976bd304fc0Smrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9977f3561b8bSmrg	      export_symbols=$output_objdir/$libname.def
9978f3561b8bSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9979f3561b8bSmrg	    fi
99806257f37dSmrg	  }
9981fc5a983dSmrg
9982f3561b8bSmrg	  libobjs=$output
9983f3561b8bSmrg	  # Restore the value of output.
9984f3561b8bSmrg	  output=$save_output
9985fc5a983dSmrg
9986f3561b8bSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
9987f3561b8bSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9988f3561b8bSmrg	    test "X$libobjs" = "X " && libobjs=
9989f3561b8bSmrg	  fi
9990f3561b8bSmrg	  # Expand the library linking commands again to reset the
9991f3561b8bSmrg	  # value of $libobjs for piecewise linking.
9992fc5a983dSmrg
9993f3561b8bSmrg	  # Do each of the archive commands.
99946257f37dSmrg	  if test yes = "$module" && test -n "$module_cmds"; then
9995f3561b8bSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
9996f3561b8bSmrg	      cmds=$module_expsym_cmds
9997f3561b8bSmrg	    else
9998f3561b8bSmrg	      cmds=$module_cmds
9999fc5a983dSmrg	    fi
10000fc5a983dSmrg	  else
10001f3561b8bSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
10002f3561b8bSmrg	      cmds=$archive_expsym_cmds
10003f3561b8bSmrg	    else
10004f3561b8bSmrg	      cmds=$archive_cmds
10005f3561b8bSmrg	    fi
10006fc5a983dSmrg	  fi
10007f3561b8bSmrg	fi
10008fc5a983dSmrg
10009f3561b8bSmrg	if test -n "$delfiles"; then
10010f3561b8bSmrg	  # Append the command to remove temporary files to $cmds.
10011f3561b8bSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
10012f3561b8bSmrg	fi
10013fc5a983dSmrg
10014f3561b8bSmrg	# Add any objects from preloaded convenience libraries
10015f3561b8bSmrg	if test -n "$dlprefiles"; then
100166257f37dSmrg	  gentop=$output_objdir/${outputname}x
10017bd304fc0Smrg	  func_append generated " $gentop"
10018fc5a983dSmrg
10019f3561b8bSmrg	  func_extract_archives $gentop $dlprefiles
10020bd304fc0Smrg	  func_append libobjs " $func_extract_archives_result"
10021f3561b8bSmrg	  test "X$libobjs" = "X " && libobjs=
10022f3561b8bSmrg	fi
10023fc5a983dSmrg
100246257f37dSmrg	save_ifs=$IFS; IFS='~'
10025f3561b8bSmrg	for cmd in $cmds; do
100266257f37dSmrg	  IFS=$sp$nl
10027f3561b8bSmrg	  eval cmd=\"$cmd\"
100286257f37dSmrg	  IFS=$save_ifs
100296257f37dSmrg	  $opt_quiet || {
10030f3561b8bSmrg	    func_quote_for_expand "$cmd"
10031f3561b8bSmrg	    eval "func_echo $func_quote_for_expand_result"
10032f3561b8bSmrg	  }
10033f3561b8bSmrg	  $opt_dry_run || eval "$cmd" || {
10034f3561b8bSmrg	    lt_exit=$?
10035fc5a983dSmrg
10036f3561b8bSmrg	    # Restore the uninstalled library and exit
100376257f37dSmrg	    if test relink = "$opt_mode"; then
10038f3561b8bSmrg	      ( cd "$output_objdir" && \
10039f3561b8bSmrg	        $RM "${realname}T" && \
10040f3561b8bSmrg		$MV "${realname}U" "$realname" )
10041f3561b8bSmrg	    fi
10042fc5a983dSmrg
10043f3561b8bSmrg	    exit $lt_exit
10044f3561b8bSmrg	  }
10045f3561b8bSmrg	done
100466257f37dSmrg	IFS=$save_ifs
10047fc5a983dSmrg
10048f3561b8bSmrg	# Restore the uninstalled library and exit
100496257f37dSmrg	if test relink = "$opt_mode"; then
10050f3561b8bSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
10051fc5a983dSmrg
10052f3561b8bSmrg	  if test -n "$convenience"; then
10053f3561b8bSmrg	    if test -z "$whole_archive_flag_spec"; then
10054f3561b8bSmrg	      func_show_eval '${RM}r "$gentop"'
10055f3561b8bSmrg	    fi
10056f3561b8bSmrg	  fi
10057fc5a983dSmrg
10058f3561b8bSmrg	  exit $EXIT_SUCCESS
10059f3561b8bSmrg	fi
10060f3561b8bSmrg
10061f3561b8bSmrg	# Create links to the real library.
10062f3561b8bSmrg	for linkname in $linknames; do
10063f3561b8bSmrg	  if test "$realname" != "$linkname"; then
10064f3561b8bSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
10065fc5a983dSmrg	  fi
10066fc5a983dSmrg	done
10067fc5a983dSmrg
10068f3561b8bSmrg	# If -module or -export-dynamic was specified, set the dlname.
100696257f37dSmrg	if test yes = "$module" || test yes = "$export_dynamic"; then
10070f3561b8bSmrg	  # On all known operating systems, these are identical.
100716257f37dSmrg	  dlname=$soname
10072f3561b8bSmrg	fi
10073f3561b8bSmrg      fi
10074fc5a983dSmrg      ;;
10075fc5a983dSmrg
10076f3561b8bSmrg    obj)
100776257f37dSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
100786257f37dSmrg	func_warning "'-dlopen' is ignored for objects"
10079f3561b8bSmrg      fi
10080fc5a983dSmrg
10081f3561b8bSmrg      case " $deplibs" in
10082f3561b8bSmrg      *\ -l* | *\ -L*)
100836257f37dSmrg	func_warning "'-l' and '-L' are ignored for objects" ;;
10084fc5a983dSmrg      esac
10085fc5a983dSmrg
10086f3561b8bSmrg      test -n "$rpath" && \
100876257f37dSmrg	func_warning "'-rpath' is ignored for objects"
10088f3561b8bSmrg
10089f3561b8bSmrg      test -n "$xrpath" && \
100906257f37dSmrg	func_warning "'-R' is ignored for objects"
10091fc5a983dSmrg
10092f3561b8bSmrg      test -n "$vinfo" && \
100936257f37dSmrg	func_warning "'-version-info' is ignored for objects"
10094fc5a983dSmrg
10095f3561b8bSmrg      test -n "$release" && \
100966257f37dSmrg	func_warning "'-release' is ignored for objects"
10097f3561b8bSmrg
10098f3561b8bSmrg      case $output in
10099f3561b8bSmrg      *.lo)
10100f3561b8bSmrg	test -n "$objs$old_deplibs" && \
101016257f37dSmrg	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
10102f3561b8bSmrg
10103f3561b8bSmrg	libobj=$output
10104f3561b8bSmrg	func_lo2o "$libobj"
10105f3561b8bSmrg	obj=$func_lo2o_result
10106fc5a983dSmrg	;;
10107fc5a983dSmrg      *)
10108f3561b8bSmrg	libobj=
101096257f37dSmrg	obj=$output
10110fc5a983dSmrg	;;
10111fc5a983dSmrg      esac
10112fc5a983dSmrg
10113f3561b8bSmrg      # Delete the old objects.
10114f3561b8bSmrg      $opt_dry_run || $RM $obj $libobj
10115fc5a983dSmrg
10116f3561b8bSmrg      # Objects from convenience libraries.  This assumes
10117f3561b8bSmrg      # single-version convenience libraries.  Whenever we create
10118f3561b8bSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
10119f3561b8bSmrg      # the extraction.
10120f3561b8bSmrg      reload_conv_objs=
10121f3561b8bSmrg      gentop=
101226257f37dSmrg      # if reload_cmds runs $LD directly, get rid of -Wl from
101236257f37dSmrg      # whole_archive_flag_spec and hope we can get by with turning comma
101246257f37dSmrg      # into space.
101256257f37dSmrg      case $reload_cmds in
101266257f37dSmrg        *\$LD[\ \$]*) wl= ;;
101276257f37dSmrg      esac
10128f3561b8bSmrg      if test -n "$convenience"; then
10129f3561b8bSmrg	if test -n "$whole_archive_flag_spec"; then
10130f3561b8bSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
101316257f37dSmrg	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
101326257f37dSmrg	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
10133f3561b8bSmrg	else
101346257f37dSmrg	  gentop=$output_objdir/${obj}x
10135bd304fc0Smrg	  func_append generated " $gentop"
10136fc5a983dSmrg
10137f3561b8bSmrg	  func_extract_archives $gentop $convenience
10138f3561b8bSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
10139f3561b8bSmrg	fi
10140fc5a983dSmrg      fi
10141fc5a983dSmrg
10142bd304fc0Smrg      # If we're not building shared, we need to use non_pic_objs
101436257f37dSmrg      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
10144bd304fc0Smrg
10145f3561b8bSmrg      # Create the old-style object.
101466257f37dSmrg      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
10147fc5a983dSmrg
101486257f37dSmrg      output=$obj
10149f3561b8bSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
10150fc5a983dSmrg
10151f3561b8bSmrg      # Exit if we aren't doing a library object file.
10152f3561b8bSmrg      if test -z "$libobj"; then
10153f3561b8bSmrg	if test -n "$gentop"; then
10154f3561b8bSmrg	  func_show_eval '${RM}r "$gentop"'
10155f3561b8bSmrg	fi
10156f3561b8bSmrg
10157f3561b8bSmrg	exit $EXIT_SUCCESS
10158fc5a983dSmrg      fi
10159f3561b8bSmrg
101606257f37dSmrg      test yes = "$build_libtool_libs" || {
10161f3561b8bSmrg	if test -n "$gentop"; then
10162f3561b8bSmrg	  func_show_eval '${RM}r "$gentop"'
10163f3561b8bSmrg	fi
10164f3561b8bSmrg
10165f3561b8bSmrg	# Create an invalid libtool object if no PIC, so that we don't
10166f3561b8bSmrg	# accidentally link it into a program.
10167f3561b8bSmrg	# $show "echo timestamp > $libobj"
10168f3561b8bSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
10169f3561b8bSmrg	exit $EXIT_SUCCESS
101706257f37dSmrg      }
10171f3561b8bSmrg
101726257f37dSmrg      if test -n "$pic_flag" || test default != "$pic_mode"; then
10173f3561b8bSmrg	# Only do commands if we really have different PIC objects.
10174f3561b8bSmrg	reload_objs="$libobjs $reload_conv_objs"
101756257f37dSmrg	output=$libobj
10176f3561b8bSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
10177f3561b8bSmrg      fi
10178f3561b8bSmrg
10179f3561b8bSmrg      if test -n "$gentop"; then
10180f3561b8bSmrg	func_show_eval '${RM}r "$gentop"'
10181f3561b8bSmrg      fi
10182f3561b8bSmrg
10183f3561b8bSmrg      exit $EXIT_SUCCESS
10184fc5a983dSmrg      ;;
10185fc5a983dSmrg
10186f3561b8bSmrg    prog)
10187f3561b8bSmrg      case $host in
10188f3561b8bSmrg	*cygwin*) func_stripname '' '.exe' "$output"
10189f3561b8bSmrg	          output=$func_stripname_result.exe;;
10190f3561b8bSmrg      esac
10191f3561b8bSmrg      test -n "$vinfo" && \
101926257f37dSmrg	func_warning "'-version-info' is ignored for programs"
10193fc5a983dSmrg
10194f3561b8bSmrg      test -n "$release" && \
101956257f37dSmrg	func_warning "'-release' is ignored for programs"
10196fc5a983dSmrg
101976257f37dSmrg      $preload \
101986257f37dSmrg	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
101996257f37dSmrg	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
10200f3561b8bSmrg
10201f3561b8bSmrg      case $host in
10202f3561b8bSmrg      *-*-rhapsody* | *-*-darwin1.[012])
10203f3561b8bSmrg	# On Rhapsody replace the C library is the System framework
10204bd304fc0Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
10205bd304fc0Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
10206fc5a983dSmrg	;;
10207f3561b8bSmrg      esac
10208fc5a983dSmrg
10209f3561b8bSmrg      case $host in
10210f3561b8bSmrg      *-*-darwin*)
10211f3561b8bSmrg	# Don't allow lazy linking, it breaks C++ global constructors
10212f3561b8bSmrg	# But is supposedly fixed on 10.4 or later (yay!).
102136257f37dSmrg	if test CXX = "$tagname"; then
10214f3561b8bSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
10215f3561b8bSmrg	    10.[0123])
102166257f37dSmrg	      func_append compile_command " $wl-bind_at_load"
102176257f37dSmrg	      func_append finalize_command " $wl-bind_at_load"
10218f3561b8bSmrg	    ;;
10219f3561b8bSmrg	  esac
10220fc5a983dSmrg	fi
10221f3561b8bSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
10222bd304fc0Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10223bd304fc0Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10224f3561b8bSmrg	;;
10225f3561b8bSmrg      esac
10226fc5a983dSmrg
10227fc5a983dSmrg
10228f3561b8bSmrg      # move library search paths that coincide with paths to not yet
10229f3561b8bSmrg      # installed libraries to the beginning of the library search list
10230f3561b8bSmrg      new_libs=
10231f3561b8bSmrg      for path in $notinst_path; do
10232f3561b8bSmrg	case " $new_libs " in
10233f3561b8bSmrg	*" -L$path/$objdir "*) ;;
10234f3561b8bSmrg	*)
10235f3561b8bSmrg	  case " $compile_deplibs " in
10236f3561b8bSmrg	  *" -L$path/$objdir "*)
10237bd304fc0Smrg	    func_append new_libs " -L$path/$objdir" ;;
10238fc5a983dSmrg	  esac
10239f3561b8bSmrg	  ;;
10240f3561b8bSmrg	esac
10241f3561b8bSmrg      done
10242f3561b8bSmrg      for deplib in $compile_deplibs; do
10243f3561b8bSmrg	case $deplib in
10244f3561b8bSmrg	-L*)
10245f3561b8bSmrg	  case " $new_libs " in
10246f3561b8bSmrg	  *" $deplib "*) ;;
10247bd304fc0Smrg	  *) func_append new_libs " $deplib" ;;
10248fc5a983dSmrg	  esac
10249f3561b8bSmrg	  ;;
10250bd304fc0Smrg	*) func_append new_libs " $deplib" ;;
10251f3561b8bSmrg	esac
10252f3561b8bSmrg      done
102536257f37dSmrg      compile_deplibs=$new_libs
10254fc5a983dSmrg
10255fc5a983dSmrg
10256bd304fc0Smrg      func_append compile_command " $compile_deplibs"
10257bd304fc0Smrg      func_append finalize_command " $finalize_deplibs"
10258fc5a983dSmrg
10259f3561b8bSmrg      if test -n "$rpath$xrpath"; then
10260f3561b8bSmrg	# If the user specified any rpath flags, then add them.
10261f3561b8bSmrg	for libdir in $rpath $xrpath; do
10262f3561b8bSmrg	  # This is the magic to use -rpath.
10263f3561b8bSmrg	  case "$finalize_rpath " in
10264f3561b8bSmrg	  *" $libdir "*) ;;
10265bd304fc0Smrg	  *) func_append finalize_rpath " $libdir" ;;
10266f3561b8bSmrg	  esac
10267f3561b8bSmrg	done
10268f3561b8bSmrg      fi
10269fc5a983dSmrg
10270f3561b8bSmrg      # Now hardcode the library paths
10271f3561b8bSmrg      rpath=
10272f3561b8bSmrg      hardcode_libdirs=
10273f3561b8bSmrg      for libdir in $compile_rpath $finalize_rpath; do
10274f3561b8bSmrg	if test -n "$hardcode_libdir_flag_spec"; then
10275f3561b8bSmrg	  if test -n "$hardcode_libdir_separator"; then
10276f3561b8bSmrg	    if test -z "$hardcode_libdirs"; then
102776257f37dSmrg	      hardcode_libdirs=$libdir
10278f3561b8bSmrg	    else
10279f3561b8bSmrg	      # Just accumulate the unique libdirs.
10280f3561b8bSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10281f3561b8bSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10282f3561b8bSmrg		;;
10283f3561b8bSmrg	      *)
10284bd304fc0Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10285f3561b8bSmrg		;;
10286f3561b8bSmrg	      esac
10287f3561b8bSmrg	    fi
10288fc5a983dSmrg	  else
10289f3561b8bSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10290bd304fc0Smrg	    func_append rpath " $flag"
10291fc5a983dSmrg	  fi
10292f3561b8bSmrg	elif test -n "$runpath_var"; then
10293f3561b8bSmrg	  case "$perm_rpath " in
10294f3561b8bSmrg	  *" $libdir "*) ;;
10295bd304fc0Smrg	  *) func_append perm_rpath " $libdir" ;;
10296f3561b8bSmrg	  esac
10297f3561b8bSmrg	fi
10298f3561b8bSmrg	case $host in
10299f3561b8bSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
103006257f37dSmrg	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
10301f3561b8bSmrg	  case :$dllsearchpath: in
10302f3561b8bSmrg	  *":$libdir:"*) ;;
10303f3561b8bSmrg	  ::) dllsearchpath=$libdir;;
10304bd304fc0Smrg	  *) func_append dllsearchpath ":$libdir";;
10305f3561b8bSmrg	  esac
10306f3561b8bSmrg	  case :$dllsearchpath: in
10307f3561b8bSmrg	  *":$testbindir:"*) ;;
10308f3561b8bSmrg	  ::) dllsearchpath=$testbindir;;
10309bd304fc0Smrg	  *) func_append dllsearchpath ":$testbindir";;
10310f3561b8bSmrg	  esac
10311f3561b8bSmrg	  ;;
10312f3561b8bSmrg	esac
10313f3561b8bSmrg      done
10314f3561b8bSmrg      # Substitute the hardcoded libdirs into the rpath.
10315f3561b8bSmrg      if test -n "$hardcode_libdir_separator" &&
10316f3561b8bSmrg	 test -n "$hardcode_libdirs"; then
103176257f37dSmrg	libdir=$hardcode_libdirs
10318f3561b8bSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
10319f3561b8bSmrg      fi
103206257f37dSmrg      compile_rpath=$rpath
10321fc5a983dSmrg
10322f3561b8bSmrg      rpath=
10323f3561b8bSmrg      hardcode_libdirs=
10324f3561b8bSmrg      for libdir in $finalize_rpath; do
10325f3561b8bSmrg	if test -n "$hardcode_libdir_flag_spec"; then
10326f3561b8bSmrg	  if test -n "$hardcode_libdir_separator"; then
10327f3561b8bSmrg	    if test -z "$hardcode_libdirs"; then
103286257f37dSmrg	      hardcode_libdirs=$libdir
10329f3561b8bSmrg	    else
10330f3561b8bSmrg	      # Just accumulate the unique libdirs.
10331f3561b8bSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10332f3561b8bSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10333f3561b8bSmrg		;;
10334f3561b8bSmrg	      *)
10335bd304fc0Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10336f3561b8bSmrg		;;
10337f3561b8bSmrg	      esac
10338f3561b8bSmrg	    fi
10339fc5a983dSmrg	  else
10340f3561b8bSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10341bd304fc0Smrg	    func_append rpath " $flag"
10342fc5a983dSmrg	  fi
10343f3561b8bSmrg	elif test -n "$runpath_var"; then
10344f3561b8bSmrg	  case "$finalize_perm_rpath " in
10345f3561b8bSmrg	  *" $libdir "*) ;;
10346bd304fc0Smrg	  *) func_append finalize_perm_rpath " $libdir" ;;
10347f3561b8bSmrg	  esac
10348fc5a983dSmrg	fi
10349f3561b8bSmrg      done
10350f3561b8bSmrg      # Substitute the hardcoded libdirs into the rpath.
10351f3561b8bSmrg      if test -n "$hardcode_libdir_separator" &&
10352f3561b8bSmrg	 test -n "$hardcode_libdirs"; then
103536257f37dSmrg	libdir=$hardcode_libdirs
10354f3561b8bSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
10355f3561b8bSmrg      fi
103566257f37dSmrg      finalize_rpath=$rpath
10357fc5a983dSmrg
103586257f37dSmrg      if test -n "$libobjs" && test yes = "$build_old_libs"; then
10359f3561b8bSmrg	# Transform all the library objects into standard objects.
10360bd304fc0Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10361bd304fc0Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10362f3561b8bSmrg      fi
10363fc5a983dSmrg
103646257f37dSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" false
10365fc5a983dSmrg
10366f3561b8bSmrg      # template prelinking step
10367f3561b8bSmrg      if test -n "$prelink_cmds"; then
10368f3561b8bSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
10369f3561b8bSmrg      fi
10370fc5a983dSmrg
103716257f37dSmrg      wrappers_required=:
10372f3561b8bSmrg      case $host in
10373bd304fc0Smrg      *cegcc* | *mingw32ce*)
10374bd304fc0Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
103756257f37dSmrg        wrappers_required=false
10376bd304fc0Smrg        ;;
10377f3561b8bSmrg      *cygwin* | *mingw* )
103786257f37dSmrg        test yes = "$build_libtool_libs" || wrappers_required=false
10379f3561b8bSmrg        ;;
10380f3561b8bSmrg      *)
103816257f37dSmrg        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
103826257f37dSmrg          wrappers_required=false
10383f3561b8bSmrg        fi
10384f3561b8bSmrg        ;;
10385f3561b8bSmrg      esac
103866257f37dSmrg      $wrappers_required || {
10387f3561b8bSmrg	# Replace the output file specification.
10388bd304fc0Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
103896257f37dSmrg	link_command=$compile_command$compile_rpath
10390fc5a983dSmrg
10391f3561b8bSmrg	# We have no uninstalled library dependencies, so finalize right now.
10392f3561b8bSmrg	exit_status=0
10393f3561b8bSmrg	func_show_eval "$link_command" 'exit_status=$?'
10394fc5a983dSmrg
10395bd304fc0Smrg	if test -n "$postlink_cmds"; then
10396bd304fc0Smrg	  func_to_tool_file "$output"
10397bd304fc0Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10398bd304fc0Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
10399bd304fc0Smrg	fi
10400bd304fc0Smrg
10401f3561b8bSmrg	# Delete the generated files.
104026257f37dSmrg	if test -f "$output_objdir/${outputname}S.$objext"; then
104036257f37dSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
10404fc5a983dSmrg	fi
10405fc5a983dSmrg
10406f3561b8bSmrg	exit $exit_status
104076257f37dSmrg      }
10408fc5a983dSmrg
10409f3561b8bSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
10410f3561b8bSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
10411f3561b8bSmrg      fi
10412f3561b8bSmrg      if test -n "$finalize_shlibpath"; then
10413f3561b8bSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
10414f3561b8bSmrg      fi
10415fc5a983dSmrg
10416f3561b8bSmrg      compile_var=
10417f3561b8bSmrg      finalize_var=
10418f3561b8bSmrg      if test -n "$runpath_var"; then
10419f3561b8bSmrg	if test -n "$perm_rpath"; then
10420f3561b8bSmrg	  # We should set the runpath_var.
10421f3561b8bSmrg	  rpath=
10422f3561b8bSmrg	  for dir in $perm_rpath; do
10423bd304fc0Smrg	    func_append rpath "$dir:"
10424f3561b8bSmrg	  done
10425f3561b8bSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
10426fc5a983dSmrg	fi
10427f3561b8bSmrg	if test -n "$finalize_perm_rpath"; then
10428f3561b8bSmrg	  # We should set the runpath_var.
10429f3561b8bSmrg	  rpath=
10430f3561b8bSmrg	  for dir in $finalize_perm_rpath; do
10431bd304fc0Smrg	    func_append rpath "$dir:"
10432f3561b8bSmrg	  done
10433f3561b8bSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
10434fc5a983dSmrg	fi
10435f3561b8bSmrg      fi
10436fc5a983dSmrg
104376257f37dSmrg      if test yes = "$no_install"; then
10438f3561b8bSmrg	# We don't need to create a wrapper script.
104396257f37dSmrg	link_command=$compile_var$compile_command$compile_rpath
10440f3561b8bSmrg	# Replace the output file specification.
10441bd304fc0Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10442f3561b8bSmrg	# Delete the old output file.
10443f3561b8bSmrg	$opt_dry_run || $RM $output
10444f3561b8bSmrg	# Link the executable and exit
10445f3561b8bSmrg	func_show_eval "$link_command" 'exit $?'
10446bd304fc0Smrg
10447bd304fc0Smrg	if test -n "$postlink_cmds"; then
10448bd304fc0Smrg	  func_to_tool_file "$output"
10449bd304fc0Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10450bd304fc0Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
10451bd304fc0Smrg	fi
10452bd304fc0Smrg
10453fc5a983dSmrg	exit $EXIT_SUCCESS
10454f3561b8bSmrg      fi
10455fc5a983dSmrg
104566257f37dSmrg      case $hardcode_action,$fast_install in
104576257f37dSmrg        relink,*)
104586257f37dSmrg	  # Fast installation is not supported
104596257f37dSmrg	  link_command=$compile_var$compile_command$compile_rpath
104606257f37dSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
10461f3561b8bSmrg
104626257f37dSmrg	  func_warning "this platform does not like uninstalled shared libraries"
104636257f37dSmrg	  func_warning "'$output' will be relinked during installation"
104646257f37dSmrg	  ;;
104656257f37dSmrg        *,yes)
104666257f37dSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
104676257f37dSmrg	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
104686257f37dSmrg          ;;
104696257f37dSmrg	*,no)
104706257f37dSmrg	  link_command=$compile_var$compile_command$compile_rpath
104716257f37dSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
104726257f37dSmrg          ;;
104736257f37dSmrg	*,needless)
104746257f37dSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
104756257f37dSmrg	  relink_command=
104766257f37dSmrg          ;;
104776257f37dSmrg      esac
10478fc5a983dSmrg
10479f3561b8bSmrg      # Replace the output file specification.
10480bd304fc0Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
10481fc5a983dSmrg
10482f3561b8bSmrg      # Delete the old output files.
10483f3561b8bSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
10484fc5a983dSmrg
10485f3561b8bSmrg      func_show_eval "$link_command" 'exit $?'
10486fc5a983dSmrg
10487bd304fc0Smrg      if test -n "$postlink_cmds"; then
10488bd304fc0Smrg	func_to_tool_file "$output_objdir/$outputname"
10489bd304fc0Smrg	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'`
10490bd304fc0Smrg	func_execute_cmds "$postlink_cmds" 'exit $?'
10491bd304fc0Smrg      fi
10492bd304fc0Smrg
10493f3561b8bSmrg      # Now create the wrapper script.
10494f3561b8bSmrg      func_verbose "creating $output"
10495fc5a983dSmrg
10496f3561b8bSmrg      # Quote the relink command for shipping.
10497f3561b8bSmrg      if test -n "$relink_command"; then
10498f3561b8bSmrg	# Preserve any variables that may affect compiler behavior
10499f3561b8bSmrg	for var in $variables_saved_for_relink; do
10500f3561b8bSmrg	  if eval test -z \"\${$var+set}\"; then
10501f3561b8bSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10502f3561b8bSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
10503f3561b8bSmrg	    relink_command="$var=; export $var; $relink_command"
10504fc5a983dSmrg	  else
10505f3561b8bSmrg	    func_quote_for_eval "$var_value"
10506f3561b8bSmrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10507fc5a983dSmrg	  fi
10508f3561b8bSmrg	done
10509f3561b8bSmrg	relink_command="(cd `pwd`; $relink_command)"
10510bd304fc0Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10511f3561b8bSmrg      fi
10512f3561b8bSmrg
10513f3561b8bSmrg      # Only actually do things if not in dry run mode.
10514f3561b8bSmrg      $opt_dry_run || {
10515f3561b8bSmrg	# win32 will think the script is a binary if it has
10516f3561b8bSmrg	# a .exe suffix, so we strip it off here.
10517f3561b8bSmrg	case $output in
10518f3561b8bSmrg	  *.exe) func_stripname '' '.exe' "$output"
10519f3561b8bSmrg	         output=$func_stripname_result ;;
10520f3561b8bSmrg	esac
10521f3561b8bSmrg	# test for cygwin because mv fails w/o .exe extensions
10522f3561b8bSmrg	case $host in
10523f3561b8bSmrg	  *cygwin*)
10524f3561b8bSmrg	    exeext=.exe
10525f3561b8bSmrg	    func_stripname '' '.exe' "$outputname"
10526f3561b8bSmrg	    outputname=$func_stripname_result ;;
10527f3561b8bSmrg	  *) exeext= ;;
10528fc5a983dSmrg	esac
10529f3561b8bSmrg	case $host in
10530f3561b8bSmrg	  *cygwin* | *mingw* )
10531f3561b8bSmrg	    func_dirname_and_basename "$output" "" "."
10532f3561b8bSmrg	    output_name=$func_basename_result
10533f3561b8bSmrg	    output_path=$func_dirname_result
105346257f37dSmrg	    cwrappersource=$output_path/$objdir/lt-$output_name.c
105356257f37dSmrg	    cwrapper=$output_path/$output_name.exe
10536f3561b8bSmrg	    $RM $cwrappersource $cwrapper
10537f3561b8bSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
10538f3561b8bSmrg
10539f3561b8bSmrg	    func_emit_cwrapperexe_src > $cwrappersource
10540f3561b8bSmrg
10541f3561b8bSmrg	    # The wrapper executable is built using the $host compiler,
10542f3561b8bSmrg	    # because it contains $host paths and files. If cross-
10543f3561b8bSmrg	    # compiling, it, like the target executable, must be
10544f3561b8bSmrg	    # executed on the $host or under an emulation environment.
10545f3561b8bSmrg	    $opt_dry_run || {
10546f3561b8bSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
10547f3561b8bSmrg	      $STRIP $cwrapper
10548f3561b8bSmrg	    }
10549fc5a983dSmrg
10550f3561b8bSmrg	    # Now, create the wrapper script for func_source use:
10551f3561b8bSmrg	    func_ltwrapper_scriptname $cwrapper
10552f3561b8bSmrg	    $RM $func_ltwrapper_scriptname_result
10553f3561b8bSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
10554f3561b8bSmrg	    $opt_dry_run || {
10555f3561b8bSmrg	      # note: this script will not be executed, so do not chmod.
105566257f37dSmrg	      if test "x$build" = "x$host"; then
10557f3561b8bSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
10558f3561b8bSmrg	      else
10559f3561b8bSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
10560f3561b8bSmrg	      fi
10561f3561b8bSmrg	    }
10562f3561b8bSmrg	  ;;
10563f3561b8bSmrg	  * )
10564f3561b8bSmrg	    $RM $output
10565f3561b8bSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
10566fc5a983dSmrg
10567f3561b8bSmrg	    func_emit_wrapper no > $output
10568f3561b8bSmrg	    chmod +x $output
10569f3561b8bSmrg	  ;;
10570f3561b8bSmrg	esac
10571f3561b8bSmrg      }
10572f3561b8bSmrg      exit $EXIT_SUCCESS
10573f3561b8bSmrg      ;;
10574f3561b8bSmrg    esac
10575fc5a983dSmrg
10576f3561b8bSmrg    # See if we need to build an old-fashioned archive.
10577f3561b8bSmrg    for oldlib in $oldlibs; do
10578fc5a983dSmrg
105796257f37dSmrg      case $build_libtool_libs in
105806257f37dSmrg        convenience)
105816257f37dSmrg	  oldobjs="$libobjs_save $symfileobj"
105826257f37dSmrg	  addlibs=$convenience
10583f3561b8bSmrg	  build_libtool_libs=no
105846257f37dSmrg	  ;;
105856257f37dSmrg	module)
105866257f37dSmrg	  oldobjs=$libobjs_save
105876257f37dSmrg	  addlibs=$old_convenience
105886257f37dSmrg	  build_libtool_libs=no
105896257f37dSmrg          ;;
105906257f37dSmrg	*)
10591f3561b8bSmrg	  oldobjs="$old_deplibs $non_pic_objects"
105926257f37dSmrg	  $preload && test -f "$symfileobj" \
105936257f37dSmrg	    && func_append oldobjs " $symfileobj"
105946257f37dSmrg	  addlibs=$old_convenience
105956257f37dSmrg	  ;;
105966257f37dSmrg      esac
10597fc5a983dSmrg
10598f3561b8bSmrg      if test -n "$addlibs"; then
105996257f37dSmrg	gentop=$output_objdir/${outputname}x
10600bd304fc0Smrg	func_append generated " $gentop"
10601fc5a983dSmrg
10602f3561b8bSmrg	func_extract_archives $gentop $addlibs
10603bd304fc0Smrg	func_append oldobjs " $func_extract_archives_result"
10604f3561b8bSmrg      fi
10605fc5a983dSmrg
10606f3561b8bSmrg      # Do each command in the archive commands.
106076257f37dSmrg      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
10608f3561b8bSmrg	cmds=$old_archive_from_new_cmds
10609f3561b8bSmrg      else
10610fc5a983dSmrg
10611f3561b8bSmrg	# Add any objects from preloaded convenience libraries
10612f3561b8bSmrg	if test -n "$dlprefiles"; then
106136257f37dSmrg	  gentop=$output_objdir/${outputname}x
10614bd304fc0Smrg	  func_append generated " $gentop"
10615fc5a983dSmrg
10616f3561b8bSmrg	  func_extract_archives $gentop $dlprefiles
10617bd304fc0Smrg	  func_append oldobjs " $func_extract_archives_result"
10618f3561b8bSmrg	fi
10619fc5a983dSmrg
10620f3561b8bSmrg	# POSIX demands no paths to be encoded in archives.  We have
10621f3561b8bSmrg	# to avoid creating archives with duplicate basenames if we
10622f3561b8bSmrg	# might have to extract them afterwards, e.g., when creating a
10623f3561b8bSmrg	# static archive out of a convenience library, or when linking
10624f3561b8bSmrg	# the entirety of a libtool archive into another (currently
10625f3561b8bSmrg	# not supported by libtool).
10626f3561b8bSmrg	if (for obj in $oldobjs
10627f3561b8bSmrg	    do
10628f3561b8bSmrg	      func_basename "$obj"
10629f3561b8bSmrg	      $ECHO "$func_basename_result"
10630f3561b8bSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
10631f3561b8bSmrg	  :
10632f3561b8bSmrg	else
10633bd304fc0Smrg	  echo "copying selected object files to avoid basename conflicts..."
106346257f37dSmrg	  gentop=$output_objdir/${outputname}x
10635bd304fc0Smrg	  func_append generated " $gentop"
10636f3561b8bSmrg	  func_mkdir_p "$gentop"
10637f3561b8bSmrg	  save_oldobjs=$oldobjs
10638f3561b8bSmrg	  oldobjs=
10639f3561b8bSmrg	  counter=1
10640f3561b8bSmrg	  for obj in $save_oldobjs
10641f3561b8bSmrg	  do
10642f3561b8bSmrg	    func_basename "$obj"
106436257f37dSmrg	    objbase=$func_basename_result
10644f3561b8bSmrg	    case " $oldobjs " in
10645f3561b8bSmrg	    " ") oldobjs=$obj ;;
10646f3561b8bSmrg	    *[\ /]"$objbase "*)
10647f3561b8bSmrg	      while :; do
10648f3561b8bSmrg		# Make sure we don't pick an alternate name that also
10649f3561b8bSmrg		# overlaps.
10650f3561b8bSmrg		newobj=lt$counter-$objbase
10651f3561b8bSmrg		func_arith $counter + 1
10652f3561b8bSmrg		counter=$func_arith_result
10653f3561b8bSmrg		case " $oldobjs " in
10654f3561b8bSmrg		*[\ /]"$newobj "*) ;;
10655f3561b8bSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
10656f3561b8bSmrg		esac
10657f3561b8bSmrg	      done
10658f3561b8bSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
10659bd304fc0Smrg	      func_append oldobjs " $gentop/$newobj"
10660f3561b8bSmrg	      ;;
10661bd304fc0Smrg	    *) func_append oldobjs " $obj" ;;
10662f3561b8bSmrg	    esac
10663fc5a983dSmrg	  done
10664fc5a983dSmrg	fi
10665bd304fc0Smrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
10666bd304fc0Smrg	tool_oldlib=$func_to_tool_file_result
10667f3561b8bSmrg	eval cmds=\"$old_archive_cmds\"
10668fc5a983dSmrg
10669f3561b8bSmrg	func_len " $cmds"
10670f3561b8bSmrg	len=$func_len_result
10671f3561b8bSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
10672f3561b8bSmrg	  cmds=$old_archive_cmds
10673bd304fc0Smrg	elif test -n "$archiver_list_spec"; then
10674bd304fc0Smrg	  func_verbose "using command file archive linking..."
10675bd304fc0Smrg	  for obj in $oldobjs
10676bd304fc0Smrg	  do
10677bd304fc0Smrg	    func_to_tool_file "$obj"
10678bd304fc0Smrg	    $ECHO "$func_to_tool_file_result"
10679bd304fc0Smrg	  done > $output_objdir/$libname.libcmd
10680bd304fc0Smrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
10681bd304fc0Smrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
10682bd304fc0Smrg	  cmds=$old_archive_cmds
10683f3561b8bSmrg	else
10684f3561b8bSmrg	  # the command line is too long to link in one step, link in parts
10685f3561b8bSmrg	  func_verbose "using piecewise archive linking..."
10686f3561b8bSmrg	  save_RANLIB=$RANLIB
10687f3561b8bSmrg	  RANLIB=:
10688f3561b8bSmrg	  objlist=
10689f3561b8bSmrg	  concat_cmds=
10690f3561b8bSmrg	  save_oldobjs=$oldobjs
10691f3561b8bSmrg	  oldobjs=
10692f3561b8bSmrg	  # Is there a better way of finding the last object in the list?
10693f3561b8bSmrg	  for obj in $save_oldobjs
10694f3561b8bSmrg	  do
10695f3561b8bSmrg	    last_oldobj=$obj
10696f3561b8bSmrg	  done
10697f3561b8bSmrg	  eval test_cmds=\"$old_archive_cmds\"
10698f3561b8bSmrg	  func_len " $test_cmds"
10699f3561b8bSmrg	  len0=$func_len_result
10700f3561b8bSmrg	  len=$len0
10701f3561b8bSmrg	  for obj in $save_oldobjs
10702f3561b8bSmrg	  do
10703f3561b8bSmrg	    func_len " $obj"
10704f3561b8bSmrg	    func_arith $len + $func_len_result
10705f3561b8bSmrg	    len=$func_arith_result
10706f3561b8bSmrg	    func_append objlist " $obj"
10707f3561b8bSmrg	    if test "$len" -lt "$max_cmd_len"; then
10708f3561b8bSmrg	      :
10709f3561b8bSmrg	    else
10710f3561b8bSmrg	      # the above command should be used before it gets too long
10711f3561b8bSmrg	      oldobjs=$objlist
107126257f37dSmrg	      if test "$obj" = "$last_oldobj"; then
10713f3561b8bSmrg		RANLIB=$save_RANLIB
10714f3561b8bSmrg	      fi
10715f3561b8bSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
107166257f37dSmrg	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
10717f3561b8bSmrg	      objlist=
10718f3561b8bSmrg	      len=$len0
10719f3561b8bSmrg	    fi
10720f3561b8bSmrg	  done
10721f3561b8bSmrg	  RANLIB=$save_RANLIB
10722f3561b8bSmrg	  oldobjs=$objlist
107236257f37dSmrg	  if test -z "$oldobjs"; then
10724f3561b8bSmrg	    eval cmds=\"\$concat_cmds\"
10725f3561b8bSmrg	  else
10726f3561b8bSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
10727f3561b8bSmrg	  fi
10728f3561b8bSmrg	fi
10729f3561b8bSmrg      fi
10730f3561b8bSmrg      func_execute_cmds "$cmds" 'exit $?'
10731fc5a983dSmrg    done
10732fc5a983dSmrg
10733f3561b8bSmrg    test -n "$generated" && \
10734f3561b8bSmrg      func_show_eval "${RM}r$generated"
10735fc5a983dSmrg
10736f3561b8bSmrg    # Now create the libtool archive.
10737f3561b8bSmrg    case $output in
10738f3561b8bSmrg    *.la)
10739f3561b8bSmrg      old_library=
107406257f37dSmrg      test yes = "$build_old_libs" && old_library=$libname.$libext
10741f3561b8bSmrg      func_verbose "creating $output"
10742fc5a983dSmrg
10743f3561b8bSmrg      # Preserve any variables that may affect compiler behavior
10744f3561b8bSmrg      for var in $variables_saved_for_relink; do
10745f3561b8bSmrg	if eval test -z \"\${$var+set}\"; then
10746f3561b8bSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10747f3561b8bSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
10748f3561b8bSmrg	  relink_command="$var=; export $var; $relink_command"
10749fc5a983dSmrg	else
10750f3561b8bSmrg	  func_quote_for_eval "$var_value"
10751f3561b8bSmrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10752fc5a983dSmrg	fi
10753f3561b8bSmrg      done
10754f3561b8bSmrg      # Quote the link command for shipping.
107556257f37dSmrg      relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
10756bd304fc0Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
107576257f37dSmrg      if test yes = "$hardcode_automatic"; then
10758f3561b8bSmrg	relink_command=
10759f3561b8bSmrg      fi
10760fc5a983dSmrg
10761f3561b8bSmrg      # Only create the output if not a dry run.
10762f3561b8bSmrg      $opt_dry_run || {
10763f3561b8bSmrg	for installed in no yes; do
107646257f37dSmrg	  if test yes = "$installed"; then
10765f3561b8bSmrg	    if test -z "$install_libdir"; then
10766f3561b8bSmrg	      break
10767f3561b8bSmrg	    fi
107686257f37dSmrg	    output=$output_objdir/${outputname}i
10769f3561b8bSmrg	    # Replace all uninstalled libtool libraries with the installed ones
10770f3561b8bSmrg	    newdependency_libs=
10771f3561b8bSmrg	    for deplib in $dependency_libs; do
10772f3561b8bSmrg	      case $deplib in
10773f3561b8bSmrg	      *.la)
10774f3561b8bSmrg		func_basename "$deplib"
107756257f37dSmrg		name=$func_basename_result
10776bd304fc0Smrg		func_resolve_sysroot "$deplib"
107776257f37dSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
10778f3561b8bSmrg		test -z "$libdir" && \
107796257f37dSmrg		  func_fatal_error "'$deplib' is not a valid libtool archive"
10780bd304fc0Smrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
10781bd304fc0Smrg		;;
10782bd304fc0Smrg	      -L*)
10783bd304fc0Smrg		func_stripname -L '' "$deplib"
10784bd304fc0Smrg		func_replace_sysroot "$func_stripname_result"
10785bd304fc0Smrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
10786f3561b8bSmrg		;;
10787bd304fc0Smrg	      -R*)
10788bd304fc0Smrg		func_stripname -R '' "$deplib"
10789bd304fc0Smrg		func_replace_sysroot "$func_stripname_result"
10790bd304fc0Smrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
10791bd304fc0Smrg		;;
10792bd304fc0Smrg	      *) func_append newdependency_libs " $deplib" ;;
10793f3561b8bSmrg	      esac
10794f3561b8bSmrg	    done
107956257f37dSmrg	    dependency_libs=$newdependency_libs
10796f3561b8bSmrg	    newdlfiles=
10797f3561b8bSmrg
10798f3561b8bSmrg	    for lib in $dlfiles; do
10799f3561b8bSmrg	      case $lib in
10800f3561b8bSmrg	      *.la)
10801f3561b8bSmrg	        func_basename "$lib"
108026257f37dSmrg		name=$func_basename_result
108036257f37dSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10804f3561b8bSmrg		test -z "$libdir" && \
108056257f37dSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
10806bd304fc0Smrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
10807f3561b8bSmrg		;;
10808bd304fc0Smrg	      *) func_append newdlfiles " $lib" ;;
10809f3561b8bSmrg	      esac
10810f3561b8bSmrg	    done
108116257f37dSmrg	    dlfiles=$newdlfiles
10812f3561b8bSmrg	    newdlprefiles=
10813f3561b8bSmrg	    for lib in $dlprefiles; do
10814f3561b8bSmrg	      case $lib in
10815f3561b8bSmrg	      *.la)
10816f3561b8bSmrg		# Only pass preopened files to the pseudo-archive (for
10817f3561b8bSmrg		# eventual linking with the app. that links it) if we
10818f3561b8bSmrg		# didn't already link the preopened objects directly into
10819f3561b8bSmrg		# the library:
10820f3561b8bSmrg		func_basename "$lib"
108216257f37dSmrg		name=$func_basename_result
108226257f37dSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10823f3561b8bSmrg		test -z "$libdir" && \
108246257f37dSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
10825bd304fc0Smrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
10826f3561b8bSmrg		;;
10827f3561b8bSmrg	      esac
10828f3561b8bSmrg	    done
108296257f37dSmrg	    dlprefiles=$newdlprefiles
10830f3561b8bSmrg	  else
10831f3561b8bSmrg	    newdlfiles=
10832f3561b8bSmrg	    for lib in $dlfiles; do
10833f3561b8bSmrg	      case $lib in
108346257f37dSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10835f3561b8bSmrg		*) abs=`pwd`"/$lib" ;;
10836f3561b8bSmrg	      esac
10837bd304fc0Smrg	      func_append newdlfiles " $abs"
10838f3561b8bSmrg	    done
108396257f37dSmrg	    dlfiles=$newdlfiles
10840f3561b8bSmrg	    newdlprefiles=
10841f3561b8bSmrg	    for lib in $dlprefiles; do
10842f3561b8bSmrg	      case $lib in
108436257f37dSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10844f3561b8bSmrg		*) abs=`pwd`"/$lib" ;;
10845f3561b8bSmrg	      esac
10846bd304fc0Smrg	      func_append newdlprefiles " $abs"
10847f3561b8bSmrg	    done
108486257f37dSmrg	    dlprefiles=$newdlprefiles
10849f3561b8bSmrg	  fi
10850f3561b8bSmrg	  $RM $output
10851f3561b8bSmrg	  # place dlname in correct position for cygwin
10852bd304fc0Smrg	  # In fact, it would be nice if we could use this code for all target
10853bd304fc0Smrg	  # systems that can't hard-code library paths into their executables
10854bd304fc0Smrg	  # and that have no shared library path variable independent of PATH,
10855bd304fc0Smrg	  # but it turns out we can't easily determine that from inspecting
10856bd304fc0Smrg	  # libtool variables, so we have to hard-code the OSs to which it
10857bd304fc0Smrg	  # applies here; at the moment, that means platforms that use the PE
10858bd304fc0Smrg	  # object format with DLL files.  See the long comment at the top of
10859bd304fc0Smrg	  # tests/bindir.at for full details.
10860f3561b8bSmrg	  tdlname=$dlname
10861f3561b8bSmrg	  case $host,$output,$installed,$module,$dlname in
10862bd304fc0Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
10863bd304fc0Smrg	      # If a -bindir argument was supplied, place the dll there.
108646257f37dSmrg	      if test -n "$bindir"; then
10865bd304fc0Smrg		func_relative_path "$install_libdir" "$bindir"
108666257f37dSmrg		tdlname=$func_relative_path_result/$dlname
10867bd304fc0Smrg	      else
10868bd304fc0Smrg		# Otherwise fall back on heuristic.
10869bd304fc0Smrg		tdlname=../bin/$dlname
10870bd304fc0Smrg	      fi
10871bd304fc0Smrg	      ;;
10872f3561b8bSmrg	  esac
10873f3561b8bSmrg	  $ECHO > $output "\
10874f3561b8bSmrg# $outputname - a libtool library file
108756257f37dSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
10876f3561b8bSmrg#
10877f3561b8bSmrg# Please DO NOT delete this file!
10878f3561b8bSmrg# It is necessary for linking the library.
10879fc5a983dSmrg
10880f3561b8bSmrg# The name that we can dlopen(3).
10881f3561b8bSmrgdlname='$tdlname'
10882fc5a983dSmrg
10883f3561b8bSmrg# Names of this library.
10884f3561b8bSmrglibrary_names='$library_names'
10885fc5a983dSmrg
10886f3561b8bSmrg# The name of the static archive.
10887f3561b8bSmrgold_library='$old_library'
10888fc5a983dSmrg
108896257f37dSmrg# Linker flags that cannot go in dependency_libs.
10890f3561b8bSmrginherited_linker_flags='$new_inherited_linker_flags'
10891fc5a983dSmrg
10892f3561b8bSmrg# Libraries that this one depends upon.
10893f3561b8bSmrgdependency_libs='$dependency_libs'
10894fc5a983dSmrg
10895f3561b8bSmrg# Names of additional weak libraries provided by this library
10896f3561b8bSmrgweak_library_names='$weak_libs'
10897fc5a983dSmrg
10898f3561b8bSmrg# Version information for $libname.
10899f3561b8bSmrgcurrent=$current
10900f3561b8bSmrgage=$age
10901f3561b8bSmrgrevision=$revision
10902fc5a983dSmrg
10903f3561b8bSmrg# Is this an already installed library?
10904f3561b8bSmrginstalled=$installed
10905fc5a983dSmrg
10906f3561b8bSmrg# Should we warn about portability when linking against -modules?
10907f3561b8bSmrgshouldnotlink=$module
10908fc5a983dSmrg
10909f3561b8bSmrg# Files to dlopen/dlpreopen
10910f3561b8bSmrgdlopen='$dlfiles'
10911f3561b8bSmrgdlpreopen='$dlprefiles'
10912fc5a983dSmrg
10913f3561b8bSmrg# Directory that this library needs to be installed in:
10914f3561b8bSmrglibdir='$install_libdir'"
109156257f37dSmrg	  if test no,yes = "$installed,$need_relink"; then
10916f3561b8bSmrg	    $ECHO >> $output "\
10917f3561b8bSmrgrelink_command=\"$relink_command\""
10918f3561b8bSmrg	  fi
10919f3561b8bSmrg	done
10920f3561b8bSmrg      }
10921fc5a983dSmrg
10922f3561b8bSmrg      # Do a symbolic link so that the libtool archive can be found in
10923f3561b8bSmrg      # LD_LIBRARY_PATH before the program is installed.
10924f3561b8bSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
10925f3561b8bSmrg      ;;
10926f3561b8bSmrg    esac
10927f3561b8bSmrg    exit $EXIT_SUCCESS
10928f3561b8bSmrg}
10929fc5a983dSmrg
109306257f37dSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then
109316257f37dSmrg  func_mode_link ${1+"$@"}
109326257f37dSmrgfi
10933fc5a983dSmrg
10934fc5a983dSmrg
10935f3561b8bSmrg# func_mode_uninstall arg...
10936f3561b8bSmrgfunc_mode_uninstall ()
10937f3561b8bSmrg{
109386257f37dSmrg    $debug_cmd
109396257f37dSmrg
109406257f37dSmrg    RM=$nonopt
10941fc5a983dSmrg    files=
109426257f37dSmrg    rmforce=false
10943fc5a983dSmrg    exit_status=0
10944fc5a983dSmrg
10945fc5a983dSmrg    # This variable tells wrapper scripts just to set variables rather
10946fc5a983dSmrg    # than running their programs.
109476257f37dSmrg    libtool_install_magic=$magic
10948fc5a983dSmrg
10949fc5a983dSmrg    for arg
10950fc5a983dSmrg    do
10951fc5a983dSmrg      case $arg in
109526257f37dSmrg      -f) func_append RM " $arg"; rmforce=: ;;
10953bd304fc0Smrg      -*) func_append RM " $arg" ;;
10954bd304fc0Smrg      *) func_append files " $arg" ;;
10955fc5a983dSmrg      esac
10956fc5a983dSmrg    done
10957fc5a983dSmrg
10958f3561b8bSmrg    test -z "$RM" && \
10959f3561b8bSmrg      func_fatal_help "you must specify an RM program"
10960fc5a983dSmrg
10961fc5a983dSmrg    rmdirs=
10962fc5a983dSmrg
10963fc5a983dSmrg    for file in $files; do
10964f3561b8bSmrg      func_dirname "$file" "" "."
109656257f37dSmrg      dir=$func_dirname_result
109666257f37dSmrg      if test . = "$dir"; then
109676257f37dSmrg	odir=$objdir
10968fc5a983dSmrg      else
109696257f37dSmrg	odir=$dir/$objdir
10970fc5a983dSmrg      fi
10971f3561b8bSmrg      func_basename "$file"
109726257f37dSmrg      name=$func_basename_result
109736257f37dSmrg      test uninstall = "$opt_mode" && odir=$dir
10974fc5a983dSmrg
10975bd304fc0Smrg      # Remember odir for removal later, being careful to avoid duplicates
109766257f37dSmrg      if test clean = "$opt_mode"; then
10977fc5a983dSmrg	case " $rmdirs " in
10978bd304fc0Smrg	  *" $odir "*) ;;
10979bd304fc0Smrg	  *) func_append rmdirs " $odir" ;;
10980fc5a983dSmrg	esac
10981fc5a983dSmrg      fi
10982fc5a983dSmrg
10983fc5a983dSmrg      # Don't error if the file doesn't exist and rm -f was used.
10984f3561b8bSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
10985f3561b8bSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
10986f3561b8bSmrg	 test -f "$file"; then
10987fc5a983dSmrg	:
10988fc5a983dSmrg      elif test -d "$file"; then
10989fc5a983dSmrg	exit_status=1
10990fc5a983dSmrg	continue
109916257f37dSmrg      elif $rmforce; then
10992fc5a983dSmrg	continue
10993fc5a983dSmrg      fi
10994fc5a983dSmrg
109956257f37dSmrg      rmfiles=$file
10996fc5a983dSmrg
10997fc5a983dSmrg      case $name in
10998fc5a983dSmrg      *.la)
10999fc5a983dSmrg	# Possibly a libtool archive, so verify it.
11000f3561b8bSmrg	if func_lalib_p "$file"; then
11001f3561b8bSmrg	  func_source $dir/$name
11002fc5a983dSmrg
11003fc5a983dSmrg	  # Delete the libtool libraries and symlinks.
11004fc5a983dSmrg	  for n in $library_names; do
11005bd304fc0Smrg	    func_append rmfiles " $odir/$n"
11006fc5a983dSmrg	  done
11007bd304fc0Smrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
11008fc5a983dSmrg
110096257f37dSmrg	  case $opt_mode in
11010fc5a983dSmrg	  clean)
11011bd304fc0Smrg	    case " $library_names " in
11012fc5a983dSmrg	    *" $dlname "*) ;;
11013bd304fc0Smrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
11014fc5a983dSmrg	    esac
11015bd304fc0Smrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
11016fc5a983dSmrg	    ;;
11017fc5a983dSmrg	  uninstall)
11018fc5a983dSmrg	    if test -n "$library_names"; then
11019fc5a983dSmrg	      # Do each command in the postuninstall commands.
110206257f37dSmrg	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
11021fc5a983dSmrg	    fi
11022fc5a983dSmrg
11023fc5a983dSmrg	    if test -n "$old_library"; then
11024fc5a983dSmrg	      # Do each command in the old_postuninstall commands.
110256257f37dSmrg	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
11026fc5a983dSmrg	    fi
11027fc5a983dSmrg	    # FIXME: should reinstall the best remaining shared library.
11028fc5a983dSmrg	    ;;
11029fc5a983dSmrg	  esac
11030fc5a983dSmrg	fi
11031fc5a983dSmrg	;;
11032fc5a983dSmrg
11033fc5a983dSmrg      *.lo)
11034fc5a983dSmrg	# Possibly a libtool object, so verify it.
11035f3561b8bSmrg	if func_lalib_p "$file"; then
11036fc5a983dSmrg
11037fc5a983dSmrg	  # Read the .lo file
11038f3561b8bSmrg	  func_source $dir/$name
11039fc5a983dSmrg
11040fc5a983dSmrg	  # Add PIC object to the list of files to remove.
110416257f37dSmrg	  if test -n "$pic_object" && test none != "$pic_object"; then
11042bd304fc0Smrg	    func_append rmfiles " $dir/$pic_object"
11043fc5a983dSmrg	  fi
11044fc5a983dSmrg
11045fc5a983dSmrg	  # Add non-PIC object to the list of files to remove.
110466257f37dSmrg	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
11047bd304fc0Smrg	    func_append rmfiles " $dir/$non_pic_object"
11048fc5a983dSmrg	  fi
11049fc5a983dSmrg	fi
11050fc5a983dSmrg	;;
11051fc5a983dSmrg
11052fc5a983dSmrg      *)
110536257f37dSmrg	if test clean = "$opt_mode"; then
11054fc5a983dSmrg	  noexename=$name
11055fc5a983dSmrg	  case $file in
11056fc5a983dSmrg	  *.exe)
11057f3561b8bSmrg	    func_stripname '' '.exe' "$file"
11058f3561b8bSmrg	    file=$func_stripname_result
11059f3561b8bSmrg	    func_stripname '' '.exe' "$name"
11060f3561b8bSmrg	    noexename=$func_stripname_result
11061fc5a983dSmrg	    # $file with .exe has already been added to rmfiles,
11062fc5a983dSmrg	    # add $file without .exe
11063bd304fc0Smrg	    func_append rmfiles " $file"
11064fc5a983dSmrg	    ;;
11065fc5a983dSmrg	  esac
11066fc5a983dSmrg	  # Do a test to see if this is a libtool program.
11067f3561b8bSmrg	  if func_ltwrapper_p "$file"; then
11068f3561b8bSmrg	    if func_ltwrapper_executable_p "$file"; then
11069f3561b8bSmrg	      func_ltwrapper_scriptname "$file"
11070f3561b8bSmrg	      relink_command=
11071f3561b8bSmrg	      func_source $func_ltwrapper_scriptname_result
11072bd304fc0Smrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
11073f3561b8bSmrg	    else
11074f3561b8bSmrg	      relink_command=
11075f3561b8bSmrg	      func_source $dir/$noexename
11076f3561b8bSmrg	    fi
11077fc5a983dSmrg
11078fc5a983dSmrg	    # note $name still contains .exe if it was in $file originally
11079fc5a983dSmrg	    # as does the version of $file that was added into $rmfiles
110806257f37dSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
110816257f37dSmrg	    if test yes = "$fast_install" && test -n "$relink_command"; then
11082bd304fc0Smrg	      func_append rmfiles " $odir/lt-$name"
11083fc5a983dSmrg	    fi
110846257f37dSmrg	    if test "X$noexename" != "X$name"; then
110856257f37dSmrg	      func_append rmfiles " $odir/lt-$noexename.c"
11086fc5a983dSmrg	    fi
11087fc5a983dSmrg	  fi
11088fc5a983dSmrg	fi
11089fc5a983dSmrg	;;
11090fc5a983dSmrg      esac
11091f3561b8bSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
11092fc5a983dSmrg    done
11093fc5a983dSmrg
110946257f37dSmrg    # Try to remove the $objdir's in the directories where we deleted files
11095fc5a983dSmrg    for dir in $rmdirs; do
11096fc5a983dSmrg      if test -d "$dir"; then
11097f3561b8bSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
11098fc5a983dSmrg      fi
11099fc5a983dSmrg    done
11100fc5a983dSmrg
11101fc5a983dSmrg    exit $exit_status
11102f3561b8bSmrg}
11103fc5a983dSmrg
111046257f37dSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
111056257f37dSmrg  func_mode_uninstall ${1+"$@"}
111066257f37dSmrgfi
11107fc5a983dSmrg
11108bd304fc0Smrgtest -z "$opt_mode" && {
111096257f37dSmrg  help=$generic_help
11110f3561b8bSmrg  func_fatal_help "you must specify a MODE"
11111f3561b8bSmrg}
11112f3561b8bSmrg
11113f3561b8bSmrgtest -z "$exec_cmd" && \
111146257f37dSmrg  func_fatal_help "invalid operation mode '$opt_mode'"
11115fc5a983dSmrg
11116fc5a983dSmrgif test -n "$exec_cmd"; then
11117f3561b8bSmrg  eval exec "$exec_cmd"
11118fc5a983dSmrg  exit $EXIT_FAILURE
11119fc5a983dSmrgfi
11120fc5a983dSmrg
11121f3561b8bSmrgexit $exit_status
11122fc5a983dSmrg
11123fc5a983dSmrg
11124fc5a983dSmrg# The TAGs below are defined such that we never get into a situation
111256257f37dSmrg# where we disable both kinds of libraries.  Given conflicting
11126fc5a983dSmrg# choices, we go for a static library, that is the most portable,
11127fc5a983dSmrg# since we can't tell whether shared libraries were disabled because
11128fc5a983dSmrg# the user asked for that or because the platform doesn't support
11129fc5a983dSmrg# them.  This is particularly important on AIX, because we don't
11130fc5a983dSmrg# support having both static and shared libraries enabled at the same
11131fc5a983dSmrg# time on that platform, so we default to a shared-only configuration.
11132fc5a983dSmrg# If a disable-shared tag is given, we'll fallback to a static-only
11133fc5a983dSmrg# configuration.  But we'll never go from static-only to shared-only.
11134fc5a983dSmrg
11135fc5a983dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
11136f3561b8bSmrgbuild_libtool_libs=no
11137f3561b8bSmrgbuild_old_libs=yes
11138fc5a983dSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
11139fc5a983dSmrg
11140fc5a983dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
11141f3561b8bSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
11142fc5a983dSmrg# ### END LIBTOOL TAG CONFIG: disable-static
11143fc5a983dSmrg
11144fc5a983dSmrg# Local Variables:
11145fc5a983dSmrg# mode:shell-script
11146fc5a983dSmrg# sh-indentation:2
11147fc5a983dSmrg# End:
11148