ltmain.sh revision 2f60eb46
12f60eb46Smrg#! /bin/sh
22f60eb46Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
32f60eb46Smrg##               by inline-source v2014-01-03.01
4c3c9db83Smrg
52f60eb46Smrg# libtool (GNU libtool) 2.4.6
62f60eb46Smrg# Provide generalized library-building support services.
7c3c9db83Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
8c3c9db83Smrg
92f60eb46Smrg# Copyright (C) 1996-2015 Free Software Foundation, Inc.
10c3c9db83Smrg# This is free software; see the source for copying conditions.  There is NO
11c3c9db83Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12c3c9db83Smrg
13c3c9db83Smrg# GNU Libtool is free software; you can redistribute it and/or modify
14692f60a7Smrg# it under the terms of the GNU General Public License as published by
15692f60a7Smrg# the Free Software Foundation; either version 2 of the License, or
16692f60a7Smrg# (at your option) any later version.
17692f60a7Smrg#
18c3c9db83Smrg# As a special exception to the GNU General Public License,
19c3c9db83Smrg# if you distribute this file as part of a program or library that
20c3c9db83Smrg# is built using GNU Libtool, you may include this file under the
21c3c9db83Smrg# same distribution terms that you use for the rest of that program.
22c3c9db83Smrg#
23c3c9db83Smrg# GNU Libtool is distributed in the hope that it will be useful, but
24692f60a7Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
25692f60a7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26692f60a7Smrg# General Public License for more details.
27692f60a7Smrg#
28692f60a7Smrg# You should have received a copy of the GNU General Public License
292f60eb46Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
302e71ea71Smrg
31692f60a7Smrg
323f6d0e1dSmrgPROGRAM=libtool
33692f60a7SmrgPACKAGE=libtool
342f60eb46SmrgVERSION="2.4.6 Debian-2.4.6-0.1"
352f60eb46Smrgpackage_revision=2.4.6
3654569438Smrg
372f60eb46Smrg
382f60eb46Smrg## ------ ##
392f60eb46Smrg## Usage. ##
402f60eb46Smrg## ------ ##
412f60eb46Smrg
422f60eb46Smrg# Run './libtool --help' for help with using this script from the
432f60eb46Smrg# command line.
442f60eb46Smrg
452f60eb46Smrg
462f60eb46Smrg## ------------------------------- ##
472f60eb46Smrg## User overridable command paths. ##
482f60eb46Smrg## ------------------------------- ##
492f60eb46Smrg
502f60eb46Smrg# After configure completes, it has a better idea of some of the
512f60eb46Smrg# shell tools we need than the defaults used by the functions shared
522f60eb46Smrg# with bootstrap, so set those here where they can still be over-
532f60eb46Smrg# ridden by the user, but otherwise take precedence.
542f60eb46Smrg
552f60eb46Smrg: ${AUTOCONF="autoconf"}
562f60eb46Smrg: ${AUTOMAKE="automake"}
572f60eb46Smrg
582f60eb46Smrg
592f60eb46Smrg## -------------------------- ##
602f60eb46Smrg## Source external libraries. ##
612f60eb46Smrg## -------------------------- ##
622f60eb46Smrg
632f60eb46Smrg# Much of our low-level functionality needs to be sourced from external
642f60eb46Smrg# libraries, which are installed to $pkgauxdir.
652f60eb46Smrg
662f60eb46Smrg# Set a version string for this script.
672f60eb46Smrgscriptversion=2015-01-20.17; # UTC
682f60eb46Smrg
692f60eb46Smrg# General shell script boiler plate, and helper functions.
702f60eb46Smrg# Written by Gary V. Vaughan, 2004
712f60eb46Smrg
722f60eb46Smrg# Copyright (C) 2004-2015 Free Software Foundation, Inc.
732f60eb46Smrg# This is free software; see the source for copying conditions.  There is NO
742f60eb46Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
752f60eb46Smrg
762f60eb46Smrg# This program is free software; you can redistribute it and/or modify
772f60eb46Smrg# it under the terms of the GNU General Public License as published by
782f60eb46Smrg# the Free Software Foundation; either version 3 of the License, or
792f60eb46Smrg# (at your option) any later version.
802f60eb46Smrg
812f60eb46Smrg# As a special exception to the GNU General Public License, if you distribute
822f60eb46Smrg# this file as part of a program or library that is built using GNU Libtool,
832f60eb46Smrg# you may include this file under the same distribution terms that you use
842f60eb46Smrg# for the rest of that program.
852f60eb46Smrg
862f60eb46Smrg# This program is distributed in the hope that it will be useful,
872f60eb46Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
882f60eb46Smrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
892f60eb46Smrg# General Public License for more details.
902f60eb46Smrg
912f60eb46Smrg# You should have received a copy of the GNU General Public License
922f60eb46Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>.
932f60eb46Smrg
942f60eb46Smrg# Please report bugs or propose patches to gary@gnu.org.
952f60eb46Smrg
962f60eb46Smrg
972f60eb46Smrg## ------ ##
982f60eb46Smrg## Usage. ##
992f60eb46Smrg## ------ ##
1002f60eb46Smrg
1012f60eb46Smrg# Evaluate this file near the top of your script to gain access to
1022f60eb46Smrg# the functions and variables defined here:
1032f60eb46Smrg#
1042f60eb46Smrg#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
1052f60eb46Smrg#
1062f60eb46Smrg# If you need to override any of the default environment variable
1072f60eb46Smrg# settings, do that before evaluating this file.
1082f60eb46Smrg
1092f60eb46Smrg
1102f60eb46Smrg## -------------------- ##
1112f60eb46Smrg## Shell normalisation. ##
1122f60eb46Smrg## -------------------- ##
1132f60eb46Smrg
1142f60eb46Smrg# Some shells need a little help to be as Bourne compatible as possible.
1152f60eb46Smrg# Before doing anything else, make sure all that help has been provided!
1162f60eb46Smrg
1172f60eb46SmrgDUALCASE=1; export DUALCASE # for MKS sh
1182f60eb46Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
11954569438Smrg  emulate sh
12054569438Smrg  NULLCMD=:
1212f60eb46Smrg  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
12254569438Smrg  # is contrary to our usage.  Disable this feature.
12354569438Smrg  alias -g '${1+"$@"}'='"$@"'
124692f60a7Smrg  setopt NO_GLOB_SUBST
12554569438Smrgelse
1262f60eb46Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
127692f60a7Smrgfi
1283f6d0e1dSmrg
1292f60eb46Smrg# NLS nuisances: We save the old values in case they are required later.
1302f60eb46Smrg_G_user_locale=
1312f60eb46Smrg_G_safe_locale=
1322f60eb46Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
13354569438Smrgdo
1342f60eb46Smrg  eval "if test set = \"\${$_G_var+set}\"; then
1352f60eb46Smrg          save_$_G_var=\$$_G_var
1362f60eb46Smrg          $_G_var=C
1372f60eb46Smrg	  export $_G_var
1382f60eb46Smrg	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
1392f60eb46Smrg	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
14054569438Smrg	fi"
14154569438Smrgdone
14254569438Smrg
1432f60eb46Smrg# CDPATH.
1442f60eb46Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
145c3c9db83Smrg
1462f60eb46Smrg# Make sure IFS has a sensible default
1472f60eb46Smrgsp=' '
1482f60eb46Smrgnl='
1492f60eb46Smrg'
1502f60eb46SmrgIFS="$sp	$nl"
1512f60eb46Smrg
1522f60eb46Smrg# There are apparently some retarded systems that use ';' as a PATH separator!
1532f60eb46Smrgif test "${PATH_SEPARATOR+set}" != set; then
1542f60eb46Smrg  PATH_SEPARATOR=:
1552f60eb46Smrg  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
1562f60eb46Smrg    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
1572f60eb46Smrg      PATH_SEPARATOR=';'
1582f60eb46Smrg  }
1592f60eb46Smrgfi
160c3c9db83Smrg
161c3c9db83Smrg
162c3c9db83Smrg
1632f60eb46Smrg## ------------------------- ##
1642f60eb46Smrg## Locate command utilities. ##
1652f60eb46Smrg## ------------------------- ##
1662f60eb46Smrg
1672f60eb46Smrg
1682f60eb46Smrg# func_executable_p FILE
1692f60eb46Smrg# ----------------------
1702f60eb46Smrg# Check that FILE is an executable regular file.
1712f60eb46Smrgfunc_executable_p ()
1722f60eb46Smrg{
1732f60eb46Smrg    test -f "$1" && test -x "$1"
1742f60eb46Smrg}
1752f60eb46Smrg
1762f60eb46Smrg
1772f60eb46Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
1782f60eb46Smrg# --------------------------------------------
1792f60eb46Smrg# Search for either a program that responds to --version with output
1802f60eb46Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by
1812f60eb46Smrg# trying all the directories in PATH with each of the elements of
1822f60eb46Smrg# PROGS_LIST.
1832f60eb46Smrg#
1842f60eb46Smrg# CHECK_FUNC should accept the path to a candidate program, and
1852f60eb46Smrg# set $func_check_prog_result if it truncates its output less than
1862f60eb46Smrg# $_G_path_prog_max characters.
1872f60eb46Smrgfunc_path_progs ()
1882f60eb46Smrg{
1892f60eb46Smrg    _G_progs_list=$1
1902f60eb46Smrg    _G_check_func=$2
1912f60eb46Smrg    _G_PATH=${3-"$PATH"}
1922f60eb46Smrg
1932f60eb46Smrg    _G_path_prog_max=0
1942f60eb46Smrg    _G_path_prog_found=false
1952f60eb46Smrg    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
1962f60eb46Smrg    for _G_dir in $_G_PATH; do
1972f60eb46Smrg      IFS=$_G_save_IFS
1982f60eb46Smrg      test -z "$_G_dir" && _G_dir=.
1992f60eb46Smrg      for _G_prog_name in $_G_progs_list; do
2002f60eb46Smrg        for _exeext in '' .EXE; do
2012f60eb46Smrg          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
2022f60eb46Smrg          func_executable_p "$_G_path_prog" || continue
2032f60eb46Smrg          case `"$_G_path_prog" --version 2>&1` in
2042f60eb46Smrg            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
2052f60eb46Smrg            *)     $_G_check_func $_G_path_prog
2062f60eb46Smrg		   func_path_progs_result=$func_check_prog_result
2072f60eb46Smrg		   ;;
2082f60eb46Smrg          esac
2092f60eb46Smrg          $_G_path_prog_found && break 3
2102f60eb46Smrg        done
2112f60eb46Smrg      done
2122f60eb46Smrg    done
2132f60eb46Smrg    IFS=$_G_save_IFS
2142f60eb46Smrg    test -z "$func_path_progs_result" && {
2152f60eb46Smrg      echo "no acceptable sed could be found in \$PATH" >&2
2162f60eb46Smrg      exit 1
2172f60eb46Smrg    }
2182f60eb46Smrg}
2192f60eb46Smrg
2202f60eb46Smrg
2212f60eb46Smrg# We want to be able to use the functions in this file before configure
2222f60eb46Smrg# has figured out where the best binaries are kept, which means we have
2232f60eb46Smrg# to search for them ourselves - except when the results are already set
2242f60eb46Smrg# where we skip the searches.
2252f60eb46Smrg
2262f60eb46Smrg# Unless the user overrides by setting SED, search the path for either GNU
2272f60eb46Smrg# sed, or the sed that truncates its output the least.
2282f60eb46Smrgtest -z "$SED" && {
2292f60eb46Smrg  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
2302f60eb46Smrg  for _G_i in 1 2 3 4 5 6 7; do
2312f60eb46Smrg    _G_sed_script=$_G_sed_script$nl$_G_sed_script
2322f60eb46Smrg  done
2332f60eb46Smrg  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
2342f60eb46Smrg  _G_sed_script=
2352f60eb46Smrg
2362f60eb46Smrg  func_check_prog_sed ()
2372f60eb46Smrg  {
2382f60eb46Smrg    _G_path_prog=$1
2392f60eb46Smrg
2402f60eb46Smrg    _G_count=0
2412f60eb46Smrg    printf 0123456789 >conftest.in
2422f60eb46Smrg    while :
2432f60eb46Smrg    do
2442f60eb46Smrg      cat conftest.in conftest.in >conftest.tmp
2452f60eb46Smrg      mv conftest.tmp conftest.in
2462f60eb46Smrg      cp conftest.in conftest.nl
2472f60eb46Smrg      echo '' >> conftest.nl
2482f60eb46Smrg      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
2492f60eb46Smrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
2502f60eb46Smrg      _G_count=`expr $_G_count + 1`
2512f60eb46Smrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
2522f60eb46Smrg        # Best one so far, save it but keep looking for a better one
2532f60eb46Smrg        func_check_prog_result=$_G_path_prog
2542f60eb46Smrg        _G_path_prog_max=$_G_count
2552f60eb46Smrg      fi
2562f60eb46Smrg      # 10*(2^10) chars as input seems more than enough
2572f60eb46Smrg      test 10 -lt "$_G_count" && break
2582f60eb46Smrg    done
2592f60eb46Smrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
2602f60eb46Smrg  }
2612f60eb46Smrg
2622f60eb46Smrg  func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
2632f60eb46Smrg  rm -f conftest.sed
2642f60eb46Smrg  SED=$func_path_progs_result
2652f60eb46Smrg}
2662f60eb46Smrg
2672f60eb46Smrg
2682f60eb46Smrg# Unless the user overrides by setting GREP, search the path for either GNU
2692f60eb46Smrg# grep, or the grep that truncates its output the least.
2702f60eb46Smrgtest -z "$GREP" && {
2712f60eb46Smrg  func_check_prog_grep ()
2722f60eb46Smrg  {
2732f60eb46Smrg    _G_path_prog=$1
2742f60eb46Smrg
2752f60eb46Smrg    _G_count=0
2762f60eb46Smrg    _G_path_prog_max=0
2772f60eb46Smrg    printf 0123456789 >conftest.in
2782f60eb46Smrg    while :
2792f60eb46Smrg    do
2802f60eb46Smrg      cat conftest.in conftest.in >conftest.tmp
2812f60eb46Smrg      mv conftest.tmp conftest.in
2822f60eb46Smrg      cp conftest.in conftest.nl
2832f60eb46Smrg      echo 'GREP' >> conftest.nl
2842f60eb46Smrg      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
2852f60eb46Smrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
2862f60eb46Smrg      _G_count=`expr $_G_count + 1`
2872f60eb46Smrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
2882f60eb46Smrg        # Best one so far, save it but keep looking for a better one
2892f60eb46Smrg        func_check_prog_result=$_G_path_prog
2902f60eb46Smrg        _G_path_prog_max=$_G_count
2912f60eb46Smrg      fi
2922f60eb46Smrg      # 10*(2^10) chars as input seems more than enough
2932f60eb46Smrg      test 10 -lt "$_G_count" && break
2942f60eb46Smrg    done
2952f60eb46Smrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
2962f60eb46Smrg  }
2972f60eb46Smrg
2982f60eb46Smrg  func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
2992f60eb46Smrg  GREP=$func_path_progs_result
3002f60eb46Smrg}
3012f60eb46Smrg
3022f60eb46Smrg
3032f60eb46Smrg## ------------------------------- ##
3042f60eb46Smrg## User overridable command paths. ##
3052f60eb46Smrg## ------------------------------- ##
3062f60eb46Smrg
3072f60eb46Smrg# All uppercase variable names are used for environment variables.  These
3082f60eb46Smrg# variables can be overridden by the user before calling a script that
3092f60eb46Smrg# uses them if a suitable command of that name is not already available
3102f60eb46Smrg# in the command search PATH.
311c3c9db83Smrg
312c3c9db83Smrg: ${CP="cp -f"}
3132f60eb46Smrg: ${ECHO="printf %s\n"}
3142f60eb46Smrg: ${EGREP="$GREP -E"}
3152f60eb46Smrg: ${FGREP="$GREP -F"}
3162f60eb46Smrg: ${LN_S="ln -s"}
317c3c9db83Smrg: ${MAKE="make"}
318c3c9db83Smrg: ${MKDIR="mkdir"}
319c3c9db83Smrg: ${MV="mv -f"}
320c3c9db83Smrg: ${RM="rm -f"}
321c3c9db83Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
322692f60a7Smrg
323c3c9db83Smrg
3242f60eb46Smrg## -------------------- ##
3252f60eb46Smrg## Useful sed snippets. ##
3262f60eb46Smrg## -------------------- ##
3273f6d0e1dSmrg
3282f60eb46Smrgsed_dirname='s|/[^/]*$||'
3292f60eb46Smrgsed_basename='s|^.*/||'
3303f6d0e1dSmrg
3312f60eb46Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
3322f60eb46Smrg# metacharacters that are still active within double-quoted strings.
3332f60eb46Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g'
3343f6d0e1dSmrg
3352f60eb46Smrg# Same as above, but do not quote variable references.
3362f60eb46Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
3373f6d0e1dSmrg
3382f60eb46Smrg# Sed substitution that turns a string into a regex matching for the
3392f60eb46Smrg# string literally.
3402f60eb46Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
3413f6d0e1dSmrg
3422f60eb46Smrg# Sed substitution that converts a w32 file name or path
3432f60eb46Smrg# that contains forward slashes, into one that contains
3442f60eb46Smrg# (escaped) backslashes.  A very naive implementation.
3452f60eb46Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3462f60eb46Smrg
3472f60eb46Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that
3482f60eb46Smrg# were '\'-ed in input to the same.  If an odd number of '\' preceded a
3492f60eb46Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from
3502f60eb46Smrg# expansion.  Since each input '\' is now two '\'s, look for any number
3512f60eb46Smrg# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
3522f60eb46Smrg_G_bs='\\'
3532f60eb46Smrg_G_bs2='\\\\'
3542f60eb46Smrg_G_bs4='\\\\\\\\'
3552f60eb46Smrg_G_dollar='\$'
3562f60eb46Smrgsed_double_backslash="\
3572f60eb46Smrg  s/$_G_bs4/&\\
3582f60eb46Smrg/g
3592f60eb46Smrg  s/^$_G_bs2$_G_dollar/$_G_bs&/
3602f60eb46Smrg  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
3612f60eb46Smrg  s/\n//g"
3623f6d0e1dSmrg
3633f6d0e1dSmrg
3642f60eb46Smrg## ----------------- ##
3652f60eb46Smrg## Global variables. ##
3662f60eb46Smrg## ----------------- ##
3673f6d0e1dSmrg
3682f60eb46Smrg# Except for the global variables explicitly listed below, the following
3692f60eb46Smrg# functions in the '^func_' namespace, and the '^require_' namespace
3702f60eb46Smrg# variables initialised in the 'Resource management' section, sourcing
3712f60eb46Smrg# this file will not pollute your global namespace with anything
3722f60eb46Smrg# else. There's no portable way to scope variables in Bourne shell
3732f60eb46Smrg# though, so actually running these functions will sometimes place
3742f60eb46Smrg# results into a variable named after the function, and often use
3752f60eb46Smrg# temporary variables in the '^_G_' namespace. If you are careful to
3762f60eb46Smrg# avoid using those namespaces casually in your sourcing script, things
3772f60eb46Smrg# should continue to work as you expect. And, of course, you can freely
3782f60eb46Smrg# overwrite any of the functions or variables defined here before
3792f60eb46Smrg# calling anything to customize them.
3803f6d0e1dSmrg
3812f60eb46SmrgEXIT_SUCCESS=0
3822f60eb46SmrgEXIT_FAILURE=1
3832f60eb46SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
3842f60eb46SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
38585ee4c00Smrg
3862f60eb46Smrg# Allow overriding, eg assuming that you follow the convention of
3872f60eb46Smrg# putting '$debug_cmd' at the start of all your functions, you can get
3882f60eb46Smrg# bash to show function call trace with:
3892f60eb46Smrg#
3902f60eb46Smrg#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
3912f60eb46Smrgdebug_cmd=${debug_cmd-":"}
3922f60eb46Smrgexit_cmd=:
393c3c9db83Smrg
3942f60eb46Smrg# By convention, finish your script with:
3952f60eb46Smrg#
3962f60eb46Smrg#    exit $exit_status
3972f60eb46Smrg#
3982f60eb46Smrg# so that you can set exit_status to non-zero if you want to indicate
3992f60eb46Smrg# something went wrong during execution without actually bailing out at
4002f60eb46Smrg# the point of failure.
4012f60eb46Smrgexit_status=$EXIT_SUCCESS
4023f6d0e1dSmrg
4032f60eb46Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
4042f60eb46Smrg# is ksh but when the shell is invoked as "sh" and the current value of
4052f60eb46Smrg# the _XPG environment variable is not equal to 1 (one), the special
4062f60eb46Smrg# positional parameter $0, within a function call, is the name of the
4072f60eb46Smrg# function.
4082f60eb46Smrgprogpath=$0
409c3c9db83Smrg
4102f60eb46Smrg# The name of this program.
4112f60eb46Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"`
412c3c9db83Smrg
4132f60eb46Smrg# Make sure we have an absolute progpath for reexecution:
414c3c9db83Smrgcase $progpath in
415c3c9db83Smrg  [\\/]*|[A-Za-z]:\\*) ;;
416c3c9db83Smrg  *[\\/]*)
4172f60eb46Smrg     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
418c3c9db83Smrg     progdir=`cd "$progdir" && pwd`
4192f60eb46Smrg     progpath=$progdir/$progname
420c3c9db83Smrg     ;;
421c3c9db83Smrg  *)
4222f60eb46Smrg     _G_IFS=$IFS
42395903e71Smrg     IFS=${PATH_SEPARATOR-:}
424c3c9db83Smrg     for progdir in $PATH; do
4252f60eb46Smrg       IFS=$_G_IFS
426c3c9db83Smrg       test -x "$progdir/$progname" && break
427c3c9db83Smrg     done
4282f60eb46Smrg     IFS=$_G_IFS
429c3c9db83Smrg     test -n "$progdir" || progdir=`pwd`
4302f60eb46Smrg     progpath=$progdir/$progname
431c3c9db83Smrg     ;;
432c3c9db83Smrgesac
433c3c9db83Smrg
434c3c9db83Smrg
4352f60eb46Smrg## ----------------- ##
4362f60eb46Smrg## Standard options. ##
4372f60eb46Smrg## ----------------- ##
4383f6d0e1dSmrg
4392f60eb46Smrg# The following options affect the operation of the functions defined
4402f60eb46Smrg# below, and should be set appropriately depending on run-time para-
4412f60eb46Smrg# meters passed on the command line.
442c3c9db83Smrg
443c3c9db83Smrgopt_dry_run=false
444c3c9db83Smrgopt_quiet=false
445c3c9db83Smrgopt_verbose=false
446c3c9db83Smrg
4472f60eb46Smrg# Categories 'all' and 'none' are always available.  Append any others
4482f60eb46Smrg# you will pass as the first argument to func_warning from your own
4492f60eb46Smrg# code.
4502f60eb46Smrgwarning_categories=
451c3c9db83Smrg
4522f60eb46Smrg# By default, display warnings according to 'opt_warning_types'.  Set
4532f60eb46Smrg# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
4542f60eb46Smrg# treat the next displayed warning as a fatal error.
4552f60eb46Smrgwarning_func=func_warn_and_continue
456c3c9db83Smrg
4572f60eb46Smrg# Set to 'all' to display all warnings, 'none' to suppress all
4582f60eb46Smrg# warnings, or a space delimited list of some subset of
4592f60eb46Smrg# 'warning_categories' to display only the listed warnings.
4602f60eb46Smrgopt_warning_types=all
461c3c9db83Smrg
4623f6d0e1dSmrg
4632f60eb46Smrg## -------------------- ##
4642f60eb46Smrg## Resource management. ##
4652f60eb46Smrg## -------------------- ##
466c3c9db83Smrg
4672f60eb46Smrg# This section contains definitions for functions that each ensure a
4682f60eb46Smrg# particular resource (a file, or a non-empty configuration variable for
4692f60eb46Smrg# example) is available, and if appropriate to extract default values
4702f60eb46Smrg# from pertinent package files. Call them using their associated
4712f60eb46Smrg# 'require_*' variable to ensure that they are executed, at most, once.
4722f60eb46Smrg#
4732f60eb46Smrg# It's entirely deliberate that calling these functions can set
4742f60eb46Smrg# variables that don't obey the namespace limitations obeyed by the rest
4752f60eb46Smrg# of this file, in order that that they be as useful as possible to
4762f60eb46Smrg# callers.
477c3c9db83Smrg
478c3c9db83Smrg
4792f60eb46Smrg# require_term_colors
4802f60eb46Smrg# -------------------
4812f60eb46Smrg# Allow display of bold text on terminals that support it.
4822f60eb46Smrgrequire_term_colors=func_require_term_colors
4832f60eb46Smrgfunc_require_term_colors ()
484c3c9db83Smrg{
4852f60eb46Smrg    $debug_cmd
4862f60eb46Smrg
4872f60eb46Smrg    test -t 1 && {
4882f60eb46Smrg      # COLORTERM and USE_ANSI_COLORS environment variables take
4892f60eb46Smrg      # precedence, because most terminfo databases neglect to describe
4902f60eb46Smrg      # whether color sequences are supported.
4912f60eb46Smrg      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
4922f60eb46Smrg
4932f60eb46Smrg      if test 1 = "$USE_ANSI_COLORS"; then
4942f60eb46Smrg        # Standard ANSI escape sequences
4952f60eb46Smrg        tc_reset='[0m'
4962f60eb46Smrg        tc_bold='[1m';   tc_standout='[7m'
4972f60eb46Smrg        tc_red='[31m';   tc_green='[32m'
4982f60eb46Smrg        tc_blue='[34m';  tc_cyan='[36m'
4992f60eb46Smrg      else
5002f60eb46Smrg        # Otherwise trust the terminfo database after all.
5012f60eb46Smrg        test -n "`tput sgr0 2>/dev/null`" && {
5022f60eb46Smrg          tc_reset=`tput sgr0`
5032f60eb46Smrg          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
5042f60eb46Smrg          tc_standout=$tc_bold
5052f60eb46Smrg          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
5062f60eb46Smrg          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
5072f60eb46Smrg          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
5082f60eb46Smrg          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
5092f60eb46Smrg          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
5102f60eb46Smrg        }
5112f60eb46Smrg      fi
5122f60eb46Smrg    }
513c3c9db83Smrg
5142f60eb46Smrg    require_term_colors=:
515c3c9db83Smrg}
516c3c9db83Smrg
517c3c9db83Smrg
5182f60eb46Smrg## ----------------- ##
5192f60eb46Smrg## Function library. ##
5202f60eb46Smrg## ----------------- ##
5212f60eb46Smrg
5222f60eb46Smrg# This section contains a variety of useful functions to call in your
5232f60eb46Smrg# scripts. Take note of the portable wrappers for features provided by
5242f60eb46Smrg# some modern shells, which will fall back to slower equivalents on
5252f60eb46Smrg# less featureful shells.
5262f60eb46Smrg
5272f60eb46Smrg
5282f60eb46Smrg# func_append VAR VALUE
5292f60eb46Smrg# ---------------------
5302f60eb46Smrg# Append VALUE onto the existing contents of VAR.
5312f60eb46Smrg
5322f60eb46Smrg  # We should try to minimise forks, especially on Windows where they are
5332f60eb46Smrg  # unreasonably slow, so skip the feature probes when bash or zsh are
5342f60eb46Smrg  # being used:
5352f60eb46Smrg  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
5362f60eb46Smrg    : ${_G_HAVE_ARITH_OP="yes"}
5372f60eb46Smrg    : ${_G_HAVE_XSI_OPS="yes"}
5382f60eb46Smrg    # The += operator was introduced in bash 3.1
5392f60eb46Smrg    case $BASH_VERSION in
5402f60eb46Smrg      [12].* | 3.0 | 3.0*) ;;
5412f60eb46Smrg      *)
5422f60eb46Smrg        : ${_G_HAVE_PLUSEQ_OP="yes"}
5432f60eb46Smrg        ;;
5442f60eb46Smrg    esac
5452f60eb46Smrg  fi
5462f60eb46Smrg
5472f60eb46Smrg  # _G_HAVE_PLUSEQ_OP
5482f60eb46Smrg  # Can be empty, in which case the shell is probed, "yes" if += is
5492f60eb46Smrg  # useable or anything else if it does not work.
5502f60eb46Smrg  test -z "$_G_HAVE_PLUSEQ_OP" \
5512f60eb46Smrg    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
5522f60eb46Smrg    && _G_HAVE_PLUSEQ_OP=yes
5532f60eb46Smrg
5542f60eb46Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"
5552f60eb46Smrgthen
5562f60eb46Smrg  # This is an XSI compatible shell, allowing a faster implementation...
5572f60eb46Smrg  eval 'func_append ()
5582f60eb46Smrg  {
5592f60eb46Smrg    $debug_cmd
5602f60eb46Smrg
5612f60eb46Smrg    eval "$1+=\$2"
5622f60eb46Smrg  }'
5632f60eb46Smrgelse
5642f60eb46Smrg  # ...otherwise fall back to using expr, which is often a shell builtin.
5652f60eb46Smrg  func_append ()
5662f60eb46Smrg  {
5672f60eb46Smrg    $debug_cmd
5682f60eb46Smrg
5692f60eb46Smrg    eval "$1=\$$1\$2"
5702f60eb46Smrg  }
5712f60eb46Smrgfi
5722f60eb46Smrg
5732f60eb46Smrg
5742f60eb46Smrg# func_append_quoted VAR VALUE
5752f60eb46Smrg# ----------------------------
5762f60eb46Smrg# Quote VALUE and append to the end of shell variable VAR, separated
5772f60eb46Smrg# by a space.
5782f60eb46Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then
5792f60eb46Smrg  eval 'func_append_quoted ()
5802f60eb46Smrg  {
5812f60eb46Smrg    $debug_cmd
5822f60eb46Smrg
5832f60eb46Smrg    func_quote_for_eval "$2"
5842f60eb46Smrg    eval "$1+=\\ \$func_quote_for_eval_result"
5852f60eb46Smrg  }'
5862f60eb46Smrgelse
5872f60eb46Smrg  func_append_quoted ()
5882f60eb46Smrg  {
5892f60eb46Smrg    $debug_cmd
5902f60eb46Smrg
5912f60eb46Smrg    func_quote_for_eval "$2"
5922f60eb46Smrg    eval "$1=\$$1\\ \$func_quote_for_eval_result"
5932f60eb46Smrg  }
5942f60eb46Smrgfi
5952f60eb46Smrg
5962f60eb46Smrg
5972f60eb46Smrg# func_append_uniq VAR VALUE
5982f60eb46Smrg# --------------------------
5992f60eb46Smrg# Append unique VALUE onto the existing contents of VAR, assuming
6002f60eb46Smrg# entries are delimited by the first character of VALUE.  For example:
6012f60eb46Smrg#
6022f60eb46Smrg#   func_append_uniq options " --another-option option-argument"
6032f60eb46Smrg#
6042f60eb46Smrg# will only append to $options if " --another-option option-argument "
6052f60eb46Smrg# is not already present somewhere in $options already (note spaces at
6062f60eb46Smrg# each end implied by leading space in second argument).
6072f60eb46Smrgfunc_append_uniq ()
6082f60eb46Smrg{
6092f60eb46Smrg    $debug_cmd
6102f60eb46Smrg
6112f60eb46Smrg    eval _G_current_value='`$ECHO $'$1'`'
6122f60eb46Smrg    _G_delim=`expr "$2" : '\(.\)'`
6132f60eb46Smrg
6142f60eb46Smrg    case $_G_delim$_G_current_value$_G_delim in
6152f60eb46Smrg      *"$2$_G_delim"*) ;;
6162f60eb46Smrg      *) func_append "$@" ;;
6172f60eb46Smrg    esac
6182f60eb46Smrg}
6192f60eb46Smrg
6202f60eb46Smrg
6212f60eb46Smrg# func_arith TERM...
6222f60eb46Smrg# ------------------
6232f60eb46Smrg# Set func_arith_result to the result of evaluating TERMs.
6242f60eb46Smrg  test -z "$_G_HAVE_ARITH_OP" \
6252f60eb46Smrg    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
6262f60eb46Smrg    && _G_HAVE_ARITH_OP=yes
6272f60eb46Smrg
6282f60eb46Smrgif test yes = "$_G_HAVE_ARITH_OP"; then
6292f60eb46Smrg  eval 'func_arith ()
6302f60eb46Smrg  {
6312f60eb46Smrg    $debug_cmd
6322f60eb46Smrg
6332f60eb46Smrg    func_arith_result=$(( $* ))
6342f60eb46Smrg  }'
6352f60eb46Smrgelse
6362f60eb46Smrg  func_arith ()
6372f60eb46Smrg  {
6382f60eb46Smrg    $debug_cmd
6392f60eb46Smrg
6402f60eb46Smrg    func_arith_result=`expr "$@"`
6412f60eb46Smrg  }
6422f60eb46Smrgfi
6432f60eb46Smrg
6442f60eb46Smrg
6452f60eb46Smrg# func_basename FILE
6462f60eb46Smrg# ------------------
6472f60eb46Smrg# Set func_basename_result to FILE with everything up to and including
6482f60eb46Smrg# the last / stripped.
6492f60eb46Smrgif test yes = "$_G_HAVE_XSI_OPS"; then
6502f60eb46Smrg  # If this shell supports suffix pattern removal, then use it to avoid
6512f60eb46Smrg  # forking. Hide the definitions single quotes in case the shell chokes
6522f60eb46Smrg  # on unsupported syntax...
6532f60eb46Smrg  _b='func_basename_result=${1##*/}'
6542f60eb46Smrg  _d='case $1 in
6552f60eb46Smrg        */*) func_dirname_result=${1%/*}$2 ;;
6562f60eb46Smrg        *  ) func_dirname_result=$3        ;;
6572f60eb46Smrg      esac'
6582f60eb46Smrg
6592f60eb46Smrgelse
6602f60eb46Smrg  # ...otherwise fall back to using sed.
6612f60eb46Smrg  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
6622f60eb46Smrg  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
6632f60eb46Smrg      if test "X$func_dirname_result" = "X$1"; then
6642f60eb46Smrg        func_dirname_result=$3
6652f60eb46Smrg      else
6662f60eb46Smrg        func_append func_dirname_result "$2"
6672f60eb46Smrg      fi'
6682f60eb46Smrgfi
6692f60eb46Smrg
6702f60eb46Smrgeval 'func_basename ()
6712f60eb46Smrg{
6722f60eb46Smrg    $debug_cmd
6732f60eb46Smrg
6742f60eb46Smrg    '"$_b"'
6752f60eb46Smrg}'
6762f60eb46Smrg
6772f60eb46Smrg
6782f60eb46Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT
6792f60eb46Smrg# -------------------------------------------
6802f60eb46Smrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
6812f60eb46Smrg# otherwise set result to NONDIR_REPLACEMENT.
6822f60eb46Smrgeval 'func_dirname ()
6832f60eb46Smrg{
6842f60eb46Smrg    $debug_cmd
6852f60eb46Smrg
6862f60eb46Smrg    '"$_d"'
6872f60eb46Smrg}'
6882f60eb46Smrg
6892f60eb46Smrg
6902f60eb46Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
6912f60eb46Smrg# --------------------------------------------------------
6922f60eb46Smrg# Perform func_basename and func_dirname in a single function
6932f60eb46Smrg# call:
6942f60eb46Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
6952f60eb46Smrg#             add APPEND to the result, otherwise set result
6962f60eb46Smrg#             to NONDIR_REPLACEMENT.
6972f60eb46Smrg#             value returned in "$func_dirname_result"
6982f60eb46Smrg#   basename: Compute filename of FILE.
6992f60eb46Smrg#             value retuned in "$func_basename_result"
7002f60eb46Smrg# For efficiency, we do not delegate to the functions above but instead
7012f60eb46Smrg# duplicate the functionality here.
7022f60eb46Smrgeval 'func_dirname_and_basename ()
7032f60eb46Smrg{
7042f60eb46Smrg    $debug_cmd
7052f60eb46Smrg
7062f60eb46Smrg    '"$_b"'
7072f60eb46Smrg    '"$_d"'
7082f60eb46Smrg}'
7092f60eb46Smrg
7102f60eb46Smrg
7112f60eb46Smrg# func_echo ARG...
7122f60eb46Smrg# ----------------
7132f60eb46Smrg# Echo program name prefixed message.
7142f60eb46Smrgfunc_echo ()
7152f60eb46Smrg{
7162f60eb46Smrg    $debug_cmd
7172f60eb46Smrg
7182f60eb46Smrg    _G_message=$*
7192f60eb46Smrg
7202f60eb46Smrg    func_echo_IFS=$IFS
7212f60eb46Smrg    IFS=$nl
7222f60eb46Smrg    for _G_line in $_G_message; do
7232f60eb46Smrg      IFS=$func_echo_IFS
7242f60eb46Smrg      $ECHO "$progname: $_G_line"
7252f60eb46Smrg    done
7262f60eb46Smrg    IFS=$func_echo_IFS
7272f60eb46Smrg}
7282f60eb46Smrg
7292f60eb46Smrg
7302f60eb46Smrg# func_echo_all ARG...
7312f60eb46Smrg# --------------------
7322f60eb46Smrg# Invoke $ECHO with all args, space-separated.
7332f60eb46Smrgfunc_echo_all ()
7342f60eb46Smrg{
7352f60eb46Smrg    $ECHO "$*"
7362f60eb46Smrg}
7372f60eb46Smrg
7382f60eb46Smrg
7392f60eb46Smrg# func_echo_infix_1 INFIX ARG...
7402f60eb46Smrg# ------------------------------
7412f60eb46Smrg# Echo program name, followed by INFIX on the first line, with any
7422f60eb46Smrg# additional lines not showing INFIX.
7432f60eb46Smrgfunc_echo_infix_1 ()
7442f60eb46Smrg{
7452f60eb46Smrg    $debug_cmd
7462f60eb46Smrg
7472f60eb46Smrg    $require_term_colors
7482f60eb46Smrg
7492f60eb46Smrg    _G_infix=$1; shift
7502f60eb46Smrg    _G_indent=$_G_infix
7512f60eb46Smrg    _G_prefix="$progname: $_G_infix: "
7522f60eb46Smrg    _G_message=$*
7532f60eb46Smrg
7542f60eb46Smrg    # Strip color escape sequences before counting printable length
7552f60eb46Smrg    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
7562f60eb46Smrg    do
7572f60eb46Smrg      test -n "$_G_tc" && {
7582f60eb46Smrg        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
7592f60eb46Smrg        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
7602f60eb46Smrg      }
7612f60eb46Smrg    done
7622f60eb46Smrg    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
7632f60eb46Smrg
7642f60eb46Smrg    func_echo_infix_1_IFS=$IFS
7652f60eb46Smrg    IFS=$nl
7662f60eb46Smrg    for _G_line in $_G_message; do
7672f60eb46Smrg      IFS=$func_echo_infix_1_IFS
7682f60eb46Smrg      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
7692f60eb46Smrg      _G_prefix=$_G_indent
7702f60eb46Smrg    done
7712f60eb46Smrg    IFS=$func_echo_infix_1_IFS
7722f60eb46Smrg}
7732f60eb46Smrg
7742f60eb46Smrg
7752f60eb46Smrg# func_error ARG...
7762f60eb46Smrg# -----------------
7772f60eb46Smrg# Echo program name prefixed message to standard error.
7782f60eb46Smrgfunc_error ()
7792f60eb46Smrg{
7802f60eb46Smrg    $debug_cmd
7812f60eb46Smrg
7822f60eb46Smrg    $require_term_colors
7832f60eb46Smrg
7842f60eb46Smrg    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
7852f60eb46Smrg}
7862f60eb46Smrg
7872f60eb46Smrg
7882f60eb46Smrg# func_fatal_error ARG...
7892f60eb46Smrg# -----------------------
7902f60eb46Smrg# Echo program name prefixed message to standard error, and exit.
7912f60eb46Smrgfunc_fatal_error ()
7922f60eb46Smrg{
7932f60eb46Smrg    $debug_cmd
7942f60eb46Smrg
7952f60eb46Smrg    func_error "$*"
7962f60eb46Smrg    exit $EXIT_FAILURE
7972f60eb46Smrg}
7982f60eb46Smrg
7992f60eb46Smrg
8002f60eb46Smrg# func_grep EXPRESSION FILENAME
8012f60eb46Smrg# -----------------------------
802c3c9db83Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
803c3c9db83Smrgfunc_grep ()
804c3c9db83Smrg{
8052f60eb46Smrg    $debug_cmd
8062f60eb46Smrg
807c3c9db83Smrg    $GREP "$1" "$2" >/dev/null 2>&1
808c3c9db83Smrg}
809c3c9db83Smrg
810c3c9db83Smrg
8112f60eb46Smrg# func_len STRING
8122f60eb46Smrg# ---------------
8132f60eb46Smrg# Set func_len_result to the length of STRING. STRING may not
8142f60eb46Smrg# start with a hyphen.
8152f60eb46Smrg  test -z "$_G_HAVE_XSI_OPS" \
8162f60eb46Smrg    && (eval 'x=a/b/c;
8172f60eb46Smrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
8182f60eb46Smrg    && _G_HAVE_XSI_OPS=yes
8192f60eb46Smrg
8202f60eb46Smrgif test yes = "$_G_HAVE_XSI_OPS"; then
8212f60eb46Smrg  eval 'func_len ()
8222f60eb46Smrg  {
8232f60eb46Smrg    $debug_cmd
8242f60eb46Smrg
8252f60eb46Smrg    func_len_result=${#1}
8262f60eb46Smrg  }'
8272f60eb46Smrgelse
8282f60eb46Smrg  func_len ()
8292f60eb46Smrg  {
8302f60eb46Smrg    $debug_cmd
8312f60eb46Smrg
8322f60eb46Smrg    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
8332f60eb46Smrg  }
8342f60eb46Smrgfi
8352f60eb46Smrg
8362f60eb46Smrg
8372f60eb46Smrg# func_mkdir_p DIRECTORY-PATH
8382f60eb46Smrg# ---------------------------
839c3c9db83Smrg# Make sure the entire path to DIRECTORY-PATH is available.
840c3c9db83Smrgfunc_mkdir_p ()
841c3c9db83Smrg{
8422f60eb46Smrg    $debug_cmd
843c3c9db83Smrg
8442f60eb46Smrg    _G_directory_path=$1
8452f60eb46Smrg    _G_dir_list=
846c3c9db83Smrg
8472f60eb46Smrg    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
8482f60eb46Smrg
8492f60eb46Smrg      # Protect directory names starting with '-'
8502f60eb46Smrg      case $_G_directory_path in
8512f60eb46Smrg        -*) _G_directory_path=./$_G_directory_path ;;
852c3c9db83Smrg      esac
853c3c9db83Smrg
854c3c9db83Smrg      # While some portion of DIR does not yet exist...
8552f60eb46Smrg      while test ! -d "$_G_directory_path"; do
856c3c9db83Smrg        # ...make a list in topmost first order.  Use a colon delimited
857c3c9db83Smrg	# list incase some portion of path contains whitespace.
8582f60eb46Smrg        _G_dir_list=$_G_directory_path:$_G_dir_list
859c3c9db83Smrg
860c3c9db83Smrg        # If the last portion added has no slash in it, the list is done
8612f60eb46Smrg        case $_G_directory_path in */*) ;; *) break ;; esac
862c3c9db83Smrg
863c3c9db83Smrg        # ...otherwise throw away the child directory and loop
8642f60eb46Smrg        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
865c3c9db83Smrg      done
8662f60eb46Smrg      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
867c3c9db83Smrg
8682f60eb46Smrg      func_mkdir_p_IFS=$IFS; IFS=:
8692f60eb46Smrg      for _G_dir in $_G_dir_list; do
8702f60eb46Smrg	IFS=$func_mkdir_p_IFS
8712f60eb46Smrg        # mkdir can fail with a 'File exist' error if two processes
872c3c9db83Smrg        # try to create one of the directories concurrently.  Don't
873c3c9db83Smrg        # stop in that case!
8742f60eb46Smrg        $MKDIR "$_G_dir" 2>/dev/null || :
875c3c9db83Smrg      done
8762f60eb46Smrg      IFS=$func_mkdir_p_IFS
877c3c9db83Smrg
878c3c9db83Smrg      # Bail out if we (or some other process) failed to create a directory.
8792f60eb46Smrg      test -d "$_G_directory_path" || \
8802f60eb46Smrg        func_fatal_error "Failed to create '$1'"
881c3c9db83Smrg    fi
882c3c9db83Smrg}
883692f60a7Smrg
884692f60a7Smrg
8852f60eb46Smrg# func_mktempdir [BASENAME]
8862f60eb46Smrg# -------------------------
887692f60a7Smrg# Make a temporary directory that won't clash with other running
888692f60a7Smrg# libtool processes, and avoids race conditions if possible.  If
8892f60eb46Smrg# given, BASENAME is the basename for that directory.
890692f60a7Smrgfunc_mktempdir ()
891692f60a7Smrg{
8922f60eb46Smrg    $debug_cmd
8932f60eb46Smrg
8942f60eb46Smrg    _G_template=${TMPDIR-/tmp}/${1-$progname}
895692f60a7Smrg
8962f60eb46Smrg    if test : = "$opt_dry_run"; then
897692f60a7Smrg      # Return a directory name, but don't create it in dry-run mode
8982f60eb46Smrg      _G_tmpdir=$_G_template-$$
899692f60a7Smrg    else
900692f60a7Smrg
901692f60a7Smrg      # If mktemp works, use that first and foremost
9022f60eb46Smrg      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
903692f60a7Smrg
9042f60eb46Smrg      if test ! -d "$_G_tmpdir"; then
905c3c9db83Smrg        # Failing that, at least try and use $RANDOM to avoid a race
9062f60eb46Smrg        _G_tmpdir=$_G_template-${RANDOM-0}$$
907692f60a7Smrg
9082f60eb46Smrg        func_mktempdir_umask=`umask`
909c3c9db83Smrg        umask 0077
9102f60eb46Smrg        $MKDIR "$_G_tmpdir"
9112f60eb46Smrg        umask $func_mktempdir_umask
912692f60a7Smrg      fi
913692f60a7Smrg
914692f60a7Smrg      # If we're not in dry-run mode, bomb out on failure
9152f60eb46Smrg      test -d "$_G_tmpdir" || \
9162f60eb46Smrg        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
9172f60eb46Smrg    fi
9182f60eb46Smrg
9192f60eb46Smrg    $ECHO "$_G_tmpdir"
9202f60eb46Smrg}
9212f60eb46Smrg
9222f60eb46Smrg
9232f60eb46Smrg# func_normal_abspath PATH
9242f60eb46Smrg# ------------------------
9252f60eb46Smrg# Remove doubled-up and trailing slashes, "." path components,
9262f60eb46Smrg# and cancel out any ".." path components in PATH after making
9272f60eb46Smrg# it an absolute path.
9282f60eb46Smrgfunc_normal_abspath ()
9292f60eb46Smrg{
9302f60eb46Smrg    $debug_cmd
9312f60eb46Smrg
9322f60eb46Smrg    # These SED scripts presuppose an absolute path with a trailing slash.
9332f60eb46Smrg    _G_pathcar='s|^/\([^/]*\).*$|\1|'
9342f60eb46Smrg    _G_pathcdr='s|^/[^/]*||'
9352f60eb46Smrg    _G_removedotparts=':dotsl
9362f60eb46Smrg		s|/\./|/|g
9372f60eb46Smrg		t dotsl
9382f60eb46Smrg		s|/\.$|/|'
9392f60eb46Smrg    _G_collapseslashes='s|/\{1,\}|/|g'
9402f60eb46Smrg    _G_finalslash='s|/*$|/|'
9412f60eb46Smrg
9422f60eb46Smrg    # Start from root dir and reassemble the path.
9432f60eb46Smrg    func_normal_abspath_result=
9442f60eb46Smrg    func_normal_abspath_tpath=$1
9452f60eb46Smrg    func_normal_abspath_altnamespace=
9462f60eb46Smrg    case $func_normal_abspath_tpath in
9472f60eb46Smrg      "")
9482f60eb46Smrg        # Empty path, that just means $cwd.
9492f60eb46Smrg        func_stripname '' '/' "`pwd`"
9502f60eb46Smrg        func_normal_abspath_result=$func_stripname_result
9512f60eb46Smrg        return
9522f60eb46Smrg        ;;
9532f60eb46Smrg      # The next three entries are used to spot a run of precisely
9542f60eb46Smrg      # two leading slashes without using negated character classes;
9552f60eb46Smrg      # we take advantage of case's first-match behaviour.
9562f60eb46Smrg      ///*)
9572f60eb46Smrg        # Unusual form of absolute path, do nothing.
9582f60eb46Smrg        ;;
9592f60eb46Smrg      //*)
9602f60eb46Smrg        # Not necessarily an ordinary path; POSIX reserves leading '//'
9612f60eb46Smrg        # and for example Cygwin uses it to access remote file shares
9622f60eb46Smrg        # over CIFS/SMB, so we conserve a leading double slash if found.
9632f60eb46Smrg        func_normal_abspath_altnamespace=/
9642f60eb46Smrg        ;;
9652f60eb46Smrg      /*)
9662f60eb46Smrg        # Absolute path, do nothing.
9672f60eb46Smrg        ;;
9682f60eb46Smrg      *)
9692f60eb46Smrg        # Relative path, prepend $cwd.
9702f60eb46Smrg        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
9712f60eb46Smrg        ;;
9722f60eb46Smrg    esac
9732f60eb46Smrg
9742f60eb46Smrg    # Cancel out all the simple stuff to save iterations.  We also want
9752f60eb46Smrg    # the path to end with a slash for ease of parsing, so make sure
9762f60eb46Smrg    # there is one (and only one) here.
9772f60eb46Smrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
9782f60eb46Smrg          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
9792f60eb46Smrg    while :; do
9802f60eb46Smrg      # Processed it all yet?
9812f60eb46Smrg      if test / = "$func_normal_abspath_tpath"; then
9822f60eb46Smrg        # If we ascended to the root using ".." the result may be empty now.
9832f60eb46Smrg        if test -z "$func_normal_abspath_result"; then
9842f60eb46Smrg          func_normal_abspath_result=/
9852f60eb46Smrg        fi
9862f60eb46Smrg        break
9872f60eb46Smrg      fi
9882f60eb46Smrg      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
9892f60eb46Smrg          -e "$_G_pathcar"`
9902f60eb46Smrg      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
9912f60eb46Smrg          -e "$_G_pathcdr"`
9922f60eb46Smrg      # Figure out what to do with it
9932f60eb46Smrg      case $func_normal_abspath_tcomponent in
9942f60eb46Smrg        "")
9952f60eb46Smrg          # Trailing empty path component, ignore it.
9962f60eb46Smrg          ;;
9972f60eb46Smrg        ..)
9982f60eb46Smrg          # Parent dir; strip last assembled component from result.
9992f60eb46Smrg          func_dirname "$func_normal_abspath_result"
10002f60eb46Smrg          func_normal_abspath_result=$func_dirname_result
10012f60eb46Smrg          ;;
10022f60eb46Smrg        *)
10032f60eb46Smrg          # Actual path component, append it.
10042f60eb46Smrg          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
10052f60eb46Smrg          ;;
10062f60eb46Smrg      esac
10072f60eb46Smrg    done
10082f60eb46Smrg    # Restore leading double-slash if one was found on entry.
10092f60eb46Smrg    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
10102f60eb46Smrg}
10112f60eb46Smrg
10122f60eb46Smrg
10132f60eb46Smrg# func_notquiet ARG...
10142f60eb46Smrg# --------------------
10152f60eb46Smrg# Echo program name prefixed message only when not in quiet mode.
10162f60eb46Smrgfunc_notquiet ()
10172f60eb46Smrg{
10182f60eb46Smrg    $debug_cmd
10192f60eb46Smrg
10202f60eb46Smrg    $opt_quiet || func_echo ${1+"$@"}
10212f60eb46Smrg
10222f60eb46Smrg    # A bug in bash halts the script if the last line of a function
10232f60eb46Smrg    # fails when set -e is in force, so we need another command to
10242f60eb46Smrg    # work around that:
10252f60eb46Smrg    :
10262f60eb46Smrg}
10272f60eb46Smrg
10282f60eb46Smrg
10292f60eb46Smrg# func_relative_path SRCDIR DSTDIR
10302f60eb46Smrg# --------------------------------
10312f60eb46Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
10322f60eb46Smrgfunc_relative_path ()
10332f60eb46Smrg{
10342f60eb46Smrg    $debug_cmd
10352f60eb46Smrg
10362f60eb46Smrg    func_relative_path_result=
10372f60eb46Smrg    func_normal_abspath "$1"
10382f60eb46Smrg    func_relative_path_tlibdir=$func_normal_abspath_result
10392f60eb46Smrg    func_normal_abspath "$2"
10402f60eb46Smrg    func_relative_path_tbindir=$func_normal_abspath_result
10412f60eb46Smrg
10422f60eb46Smrg    # Ascend the tree starting from libdir
10432f60eb46Smrg    while :; do
10442f60eb46Smrg      # check if we have found a prefix of bindir
10452f60eb46Smrg      case $func_relative_path_tbindir in
10462f60eb46Smrg        $func_relative_path_tlibdir)
10472f60eb46Smrg          # found an exact match
10482f60eb46Smrg          func_relative_path_tcancelled=
10492f60eb46Smrg          break
10502f60eb46Smrg          ;;
10512f60eb46Smrg        $func_relative_path_tlibdir*)
10522f60eb46Smrg          # found a matching prefix
10532f60eb46Smrg          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
10542f60eb46Smrg          func_relative_path_tcancelled=$func_stripname_result
10552f60eb46Smrg          if test -z "$func_relative_path_result"; then
10562f60eb46Smrg            func_relative_path_result=.
10572f60eb46Smrg          fi
10582f60eb46Smrg          break
10592f60eb46Smrg          ;;
10602f60eb46Smrg        *)
10612f60eb46Smrg          func_dirname $func_relative_path_tlibdir
10622f60eb46Smrg          func_relative_path_tlibdir=$func_dirname_result
10632f60eb46Smrg          if test -z "$func_relative_path_tlibdir"; then
10642f60eb46Smrg            # Have to descend all the way to the root!
10652f60eb46Smrg            func_relative_path_result=../$func_relative_path_result
10662f60eb46Smrg            func_relative_path_tcancelled=$func_relative_path_tbindir
10672f60eb46Smrg            break
10682f60eb46Smrg          fi
10692f60eb46Smrg          func_relative_path_result=../$func_relative_path_result
10702f60eb46Smrg          ;;
10712f60eb46Smrg      esac
10722f60eb46Smrg    done
10732f60eb46Smrg
10742f60eb46Smrg    # Now calculate path; take care to avoid doubling-up slashes.
10752f60eb46Smrg    func_stripname '' '/' "$func_relative_path_result"
10762f60eb46Smrg    func_relative_path_result=$func_stripname_result
10772f60eb46Smrg    func_stripname '/' '/' "$func_relative_path_tcancelled"
10782f60eb46Smrg    if test -n "$func_stripname_result"; then
10792f60eb46Smrg      func_append func_relative_path_result "/$func_stripname_result"
10802f60eb46Smrg    fi
10812f60eb46Smrg
10822f60eb46Smrg    # Normalisation. If bindir is libdir, return '.' else relative path.
10832f60eb46Smrg    if test -n "$func_relative_path_result"; then
10842f60eb46Smrg      func_stripname './' '' "$func_relative_path_result"
10852f60eb46Smrg      func_relative_path_result=$func_stripname_result
1086692f60a7Smrg    fi
1087692f60a7Smrg
10882f60eb46Smrg    test -n "$func_relative_path_result" || func_relative_path_result=.
10892f60eb46Smrg
10902f60eb46Smrg    :
10912f60eb46Smrg}
10922f60eb46Smrg
10932f60eb46Smrg
10942f60eb46Smrg# func_quote_for_eval ARG...
10952f60eb46Smrg# --------------------------
10962f60eb46Smrg# Aesthetically quote ARGs to be evaled later.
10972f60eb46Smrg# This function returns two values:
10982f60eb46Smrg#   i) func_quote_for_eval_result
10992f60eb46Smrg#      double-quoted, suitable for a subsequent eval
11002f60eb46Smrg#  ii) func_quote_for_eval_unquoted_result
11012f60eb46Smrg#      has all characters that are still active within double
11022f60eb46Smrg#      quotes backslashified.
11032f60eb46Smrgfunc_quote_for_eval ()
11042f60eb46Smrg{
11052f60eb46Smrg    $debug_cmd
11062f60eb46Smrg
11072f60eb46Smrg    func_quote_for_eval_unquoted_result=
11082f60eb46Smrg    func_quote_for_eval_result=
11092f60eb46Smrg    while test 0 -lt $#; do
11102f60eb46Smrg      case $1 in
11112f60eb46Smrg        *[\\\`\"\$]*)
11122f60eb46Smrg	  _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
11132f60eb46Smrg        *)
11142f60eb46Smrg          _G_unquoted_arg=$1 ;;
11152f60eb46Smrg      esac
11162f60eb46Smrg      if test -n "$func_quote_for_eval_unquoted_result"; then
11172f60eb46Smrg	func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
11182f60eb46Smrg      else
11192f60eb46Smrg        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
11202f60eb46Smrg      fi
11212f60eb46Smrg
11222f60eb46Smrg      case $_G_unquoted_arg in
11232f60eb46Smrg        # Double-quote args containing shell metacharacters to delay
11242f60eb46Smrg        # word splitting, command substitution and variable expansion
11252f60eb46Smrg        # for a subsequent eval.
11262f60eb46Smrg        # Many Bourne shells cannot handle close brackets correctly
11272f60eb46Smrg        # in scan sets, so we specify it separately.
11282f60eb46Smrg        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
11292f60eb46Smrg          _G_quoted_arg=\"$_G_unquoted_arg\"
11302f60eb46Smrg          ;;
11312f60eb46Smrg        *)
11322f60eb46Smrg          _G_quoted_arg=$_G_unquoted_arg
11332f60eb46Smrg	  ;;
11342f60eb46Smrg      esac
11352f60eb46Smrg
11362f60eb46Smrg      if test -n "$func_quote_for_eval_result"; then
11372f60eb46Smrg	func_append func_quote_for_eval_result " $_G_quoted_arg"
11382f60eb46Smrg      else
11392f60eb46Smrg        func_append func_quote_for_eval_result "$_G_quoted_arg"
11402f60eb46Smrg      fi
11412f60eb46Smrg      shift
11422f60eb46Smrg    done
11432f60eb46Smrg}
11442f60eb46Smrg
11452f60eb46Smrg
11462f60eb46Smrg# func_quote_for_expand ARG
11472f60eb46Smrg# -------------------------
11482f60eb46Smrg# Aesthetically quote ARG to be evaled later; same as above,
11492f60eb46Smrg# but do not quote variable references.
11502f60eb46Smrgfunc_quote_for_expand ()
11512f60eb46Smrg{
11522f60eb46Smrg    $debug_cmd
11532f60eb46Smrg
11542f60eb46Smrg    case $1 in
11552f60eb46Smrg      *[\\\`\"]*)
11562f60eb46Smrg	_G_arg=`$ECHO "$1" | $SED \
11572f60eb46Smrg	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
11582f60eb46Smrg      *)
11592f60eb46Smrg        _G_arg=$1 ;;
11602f60eb46Smrg    esac
11612f60eb46Smrg
11622f60eb46Smrg    case $_G_arg in
11632f60eb46Smrg      # Double-quote args containing shell metacharacters to delay
11642f60eb46Smrg      # word splitting and command substitution for a subsequent eval.
11652f60eb46Smrg      # Many Bourne shells cannot handle close brackets correctly
11662f60eb46Smrg      # in scan sets, so we specify it separately.
11672f60eb46Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
11682f60eb46Smrg        _G_arg=\"$_G_arg\"
11692f60eb46Smrg        ;;
11702f60eb46Smrg    esac
11712f60eb46Smrg
11722f60eb46Smrg    func_quote_for_expand_result=$_G_arg
11732f60eb46Smrg}
11742f60eb46Smrg
11752f60eb46Smrg
11762f60eb46Smrg# func_stripname PREFIX SUFFIX NAME
11772f60eb46Smrg# ---------------------------------
11782f60eb46Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
11792f60eb46Smrg# PREFIX and SUFFIX must not contain globbing or regex special
11802f60eb46Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading
11812f60eb46Smrg# dot (in which case that matches only a dot).
11822f60eb46Smrgif test yes = "$_G_HAVE_XSI_OPS"; then
11832f60eb46Smrg  eval 'func_stripname ()
11842f60eb46Smrg  {
11852f60eb46Smrg    $debug_cmd
11862f60eb46Smrg
11872f60eb46Smrg    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
11882f60eb46Smrg    # positional parameters, so assign one to ordinary variable first.
11892f60eb46Smrg    func_stripname_result=$3
11902f60eb46Smrg    func_stripname_result=${func_stripname_result#"$1"}
11912f60eb46Smrg    func_stripname_result=${func_stripname_result%"$2"}
11922f60eb46Smrg  }'
11932f60eb46Smrgelse
11942f60eb46Smrg  func_stripname ()
11952f60eb46Smrg  {
11962f60eb46Smrg    $debug_cmd
11972f60eb46Smrg
11982f60eb46Smrg    case $2 in
11992f60eb46Smrg      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
12002f60eb46Smrg      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
12012f60eb46Smrg    esac
12022f60eb46Smrg  }
12032f60eb46Smrgfi
12042f60eb46Smrg
12052f60eb46Smrg
12062f60eb46Smrg# func_show_eval CMD [FAIL_EXP]
12072f60eb46Smrg# -----------------------------
12082f60eb46Smrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
12092f60eb46Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
12102f60eb46Smrg# is given, then evaluate it.
12112f60eb46Smrgfunc_show_eval ()
12122f60eb46Smrg{
12132f60eb46Smrg    $debug_cmd
12142f60eb46Smrg
12152f60eb46Smrg    _G_cmd=$1
12162f60eb46Smrg    _G_fail_exp=${2-':'}
12172f60eb46Smrg
12182f60eb46Smrg    func_quote_for_expand "$_G_cmd"
12192f60eb46Smrg    eval "func_notquiet $func_quote_for_expand_result"
12202f60eb46Smrg
12212f60eb46Smrg    $opt_dry_run || {
12222f60eb46Smrg      eval "$_G_cmd"
12232f60eb46Smrg      _G_status=$?
12242f60eb46Smrg      if test 0 -ne "$_G_status"; then
12252f60eb46Smrg	eval "(exit $_G_status); $_G_fail_exp"
12262f60eb46Smrg      fi
12272f60eb46Smrg    }
12282f60eb46Smrg}
12292f60eb46Smrg
12302f60eb46Smrg
12312f60eb46Smrg# func_show_eval_locale CMD [FAIL_EXP]
12322f60eb46Smrg# ------------------------------------
12332f60eb46Smrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
12342f60eb46Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
12352f60eb46Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
12362f60eb46Smrgfunc_show_eval_locale ()
12372f60eb46Smrg{
12382f60eb46Smrg    $debug_cmd
12392f60eb46Smrg
12402f60eb46Smrg    _G_cmd=$1
12412f60eb46Smrg    _G_fail_exp=${2-':'}
12422f60eb46Smrg
12432f60eb46Smrg    $opt_quiet || {
12442f60eb46Smrg      func_quote_for_expand "$_G_cmd"
12452f60eb46Smrg      eval "func_echo $func_quote_for_expand_result"
12462f60eb46Smrg    }
12472f60eb46Smrg
12482f60eb46Smrg    $opt_dry_run || {
12492f60eb46Smrg      eval "$_G_user_locale
12502f60eb46Smrg	    $_G_cmd"
12512f60eb46Smrg      _G_status=$?
12522f60eb46Smrg      eval "$_G_safe_locale"
12532f60eb46Smrg      if test 0 -ne "$_G_status"; then
12542f60eb46Smrg	eval "(exit $_G_status); $_G_fail_exp"
12552f60eb46Smrg      fi
12562f60eb46Smrg    }
12572f60eb46Smrg}
12582f60eb46Smrg
12592f60eb46Smrg
12602f60eb46Smrg# func_tr_sh
12612f60eb46Smrg# ----------
12622f60eb46Smrg# Turn $1 into a string suitable for a shell variable name.
12632f60eb46Smrg# Result is stored in $func_tr_sh_result.  All characters
12642f60eb46Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
12652f60eb46Smrg# if $1 begins with a digit, a '_' is prepended as well.
12662f60eb46Smrgfunc_tr_sh ()
12672f60eb46Smrg{
12682f60eb46Smrg    $debug_cmd
12692f60eb46Smrg
12702f60eb46Smrg    case $1 in
12712f60eb46Smrg    [0-9]* | *[!a-zA-Z0-9_]*)
12722f60eb46Smrg      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
12732f60eb46Smrg      ;;
12742f60eb46Smrg    * )
12752f60eb46Smrg      func_tr_sh_result=$1
12762f60eb46Smrg      ;;
12772f60eb46Smrg    esac
12782f60eb46Smrg}
12792f60eb46Smrg
12802f60eb46Smrg
12812f60eb46Smrg# func_verbose ARG...
12822f60eb46Smrg# -------------------
12832f60eb46Smrg# Echo program name prefixed message in verbose mode only.
12842f60eb46Smrgfunc_verbose ()
12852f60eb46Smrg{
12862f60eb46Smrg    $debug_cmd
12872f60eb46Smrg
12882f60eb46Smrg    $opt_verbose && func_echo "$*"
12892f60eb46Smrg
12902f60eb46Smrg    :
12912f60eb46Smrg}
12922f60eb46Smrg
12932f60eb46Smrg
12942f60eb46Smrg# func_warn_and_continue ARG...
12952f60eb46Smrg# -----------------------------
12962f60eb46Smrg# Echo program name prefixed warning message to standard error.
12972f60eb46Smrgfunc_warn_and_continue ()
12982f60eb46Smrg{
12992f60eb46Smrg    $debug_cmd
13002f60eb46Smrg
13012f60eb46Smrg    $require_term_colors
13022f60eb46Smrg
13032f60eb46Smrg    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
13042f60eb46Smrg}
13052f60eb46Smrg
13062f60eb46Smrg
13072f60eb46Smrg# func_warning CATEGORY ARG...
13082f60eb46Smrg# ----------------------------
13092f60eb46Smrg# Echo program name prefixed warning message to standard error. Warning
13102f60eb46Smrg# messages can be filtered according to CATEGORY, where this function
13112f60eb46Smrg# elides messages where CATEGORY is not listed in the global variable
13122f60eb46Smrg# 'opt_warning_types'.
13132f60eb46Smrgfunc_warning ()
13142f60eb46Smrg{
13152f60eb46Smrg    $debug_cmd
13162f60eb46Smrg
13172f60eb46Smrg    # CATEGORY must be in the warning_categories list!
13182f60eb46Smrg    case " $warning_categories " in
13192f60eb46Smrg      *" $1 "*) ;;
13202f60eb46Smrg      *) func_internal_error "invalid warning category '$1'" ;;
13212f60eb46Smrg    esac
13222f60eb46Smrg
13232f60eb46Smrg    _G_category=$1
13242f60eb46Smrg    shift
13252f60eb46Smrg
13262f60eb46Smrg    case " $opt_warning_types " in
13272f60eb46Smrg      *" $_G_category "*) $warning_func ${1+"$@"} ;;
13282f60eb46Smrg    esac
13292f60eb46Smrg}
13302f60eb46Smrg
13312f60eb46Smrg
13322f60eb46Smrg# func_sort_ver VER1 VER2
13332f60eb46Smrg# -----------------------
13342f60eb46Smrg# 'sort -V' is not generally available.
13352f60eb46Smrg# Note this deviates from the version comparison in automake
13362f60eb46Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
13372f60eb46Smrg# but this should suffice as we won't be specifying old
13382f60eb46Smrg# version formats or redundant trailing .0 in bootstrap.conf.
13392f60eb46Smrg# If we did want full compatibility then we should probably
13402f60eb46Smrg# use m4_version_compare from autoconf.
13412f60eb46Smrgfunc_sort_ver ()
13422f60eb46Smrg{
13432f60eb46Smrg    $debug_cmd
13442f60eb46Smrg
13452f60eb46Smrg    printf '%s\n%s\n' "$1" "$2" \
13462f60eb46Smrg      | 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
13472f60eb46Smrg}
13482f60eb46Smrg
13492f60eb46Smrg# func_lt_ver PREV CURR
13502f60eb46Smrg# ---------------------
13512f60eb46Smrg# Return true if PREV and CURR are in the correct order according to
13522f60eb46Smrg# func_sort_ver, otherwise false.  Use it like this:
13532f60eb46Smrg#
13542f60eb46Smrg#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
13552f60eb46Smrgfunc_lt_ver ()
13562f60eb46Smrg{
13572f60eb46Smrg    $debug_cmd
13582f60eb46Smrg
13592f60eb46Smrg    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
13602f60eb46Smrg}
13612f60eb46Smrg
13622f60eb46Smrg
13632f60eb46Smrg# Local variables:
13642f60eb46Smrg# mode: shell-script
13652f60eb46Smrg# sh-indentation: 2
13662f60eb46Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
13672f60eb46Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
13682f60eb46Smrg# time-stamp-time-zone: "UTC"
13692f60eb46Smrg# End:
13702f60eb46Smrg#! /bin/sh
13712f60eb46Smrg
13722f60eb46Smrg# Set a version string for this script.
13732f60eb46Smrgscriptversion=2014-01-07.03; # UTC
13742f60eb46Smrg
13752f60eb46Smrg# A portable, pluggable option parser for Bourne shell.
13762f60eb46Smrg# Written by Gary V. Vaughan, 2010
13772f60eb46Smrg
13782f60eb46Smrg# Copyright (C) 2010-2015 Free Software Foundation, Inc.
13792f60eb46Smrg# This is free software; see the source for copying conditions.  There is NO
13802f60eb46Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13812f60eb46Smrg
13822f60eb46Smrg# This program is free software: you can redistribute it and/or modify
13832f60eb46Smrg# it under the terms of the GNU General Public License as published by
13842f60eb46Smrg# the Free Software Foundation, either version 3 of the License, or
13852f60eb46Smrg# (at your option) any later version.
13862f60eb46Smrg
13872f60eb46Smrg# This program is distributed in the hope that it will be useful,
13882f60eb46Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
13892f60eb46Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13902f60eb46Smrg# GNU General Public License for more details.
13912f60eb46Smrg
13922f60eb46Smrg# You should have received a copy of the GNU General Public License
13932f60eb46Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
13942f60eb46Smrg
13952f60eb46Smrg# Please report bugs or propose patches to gary@gnu.org.
13962f60eb46Smrg
13972f60eb46Smrg
13982f60eb46Smrg## ------ ##
13992f60eb46Smrg## Usage. ##
14002f60eb46Smrg## ------ ##
14012f60eb46Smrg
14022f60eb46Smrg# This file is a library for parsing options in your shell scripts along
14032f60eb46Smrg# with assorted other useful supporting features that you can make use
14042f60eb46Smrg# of too.
14052f60eb46Smrg#
14062f60eb46Smrg# For the simplest scripts you might need only:
14072f60eb46Smrg#
14082f60eb46Smrg#   #!/bin/sh
14092f60eb46Smrg#   . relative/path/to/funclib.sh
14102f60eb46Smrg#   . relative/path/to/options-parser
14112f60eb46Smrg#   scriptversion=1.0
14122f60eb46Smrg#   func_options ${1+"$@"}
14132f60eb46Smrg#   eval set dummy "$func_options_result"; shift
14142f60eb46Smrg#   ...rest of your script...
14152f60eb46Smrg#
14162f60eb46Smrg# In order for the '--version' option to work, you will need to have a
14172f60eb46Smrg# suitably formatted comment like the one at the top of this file
14182f60eb46Smrg# starting with '# Written by ' and ending with '# warranty; '.
14192f60eb46Smrg#
14202f60eb46Smrg# For '-h' and '--help' to work, you will also need a one line
14212f60eb46Smrg# description of your script's purpose in a comment directly above the
14222f60eb46Smrg# '# Written by ' line, like the one at the top of this file.
14232f60eb46Smrg#
14242f60eb46Smrg# The default options also support '--debug', which will turn on shell
14252f60eb46Smrg# execution tracing (see the comment above debug_cmd below for another
14262f60eb46Smrg# use), and '--verbose' and the func_verbose function to allow your script
14272f60eb46Smrg# to display verbose messages only when your user has specified
14282f60eb46Smrg# '--verbose'.
14292f60eb46Smrg#
14302f60eb46Smrg# After sourcing this file, you can plug processing for additional
14312f60eb46Smrg# options by amending the variables from the 'Configuration' section
14322f60eb46Smrg# below, and following the instructions in the 'Option parsing'
14332f60eb46Smrg# section further down.
14342f60eb46Smrg
14352f60eb46Smrg## -------------- ##
14362f60eb46Smrg## Configuration. ##
14372f60eb46Smrg## -------------- ##
14382f60eb46Smrg
14392f60eb46Smrg# You should override these variables in your script after sourcing this
14402f60eb46Smrg# file so that they reflect the customisations you have added to the
14412f60eb46Smrg# option parser.
14422f60eb46Smrg
14432f60eb46Smrg# The usage line for option parsing errors and the start of '-h' and
14442f60eb46Smrg# '--help' output messages. You can embed shell variables for delayed
14452f60eb46Smrg# expansion at the time the message is displayed, but you will need to
14462f60eb46Smrg# quote other shell meta-characters carefully to prevent them being
14472f60eb46Smrg# expanded when the contents are evaled.
14482f60eb46Smrgusage='$progpath [OPTION]...'
14492f60eb46Smrg
14502f60eb46Smrg# Short help message in response to '-h' and '--help'.  Add to this or
14512f60eb46Smrg# override it after sourcing this library to reflect the full set of
14522f60eb46Smrg# options your script accepts.
14532f60eb46Smrgusage_message="\
14542f60eb46Smrg       --debug        enable verbose shell tracing
14552f60eb46Smrg   -W, --warnings=CATEGORY
14562f60eb46Smrg                      report the warnings falling in CATEGORY [all]
14572f60eb46Smrg   -v, --verbose      verbosely report processing
14582f60eb46Smrg       --version      print version information and exit
14592f60eb46Smrg   -h, --help         print short or long help message and exit
14602f60eb46Smrg"
14612f60eb46Smrg
14622f60eb46Smrg# Additional text appended to 'usage_message' in response to '--help'.
14632f60eb46Smrglong_help_message="
14642f60eb46SmrgWarning categories include:
14652f60eb46Smrg       'all'          show all warnings
14662f60eb46Smrg       'none'         turn off all the warnings
14672f60eb46Smrg       'error'        warnings are treated as fatal errors"
14682f60eb46Smrg
14692f60eb46Smrg# Help message printed before fatal option parsing errors.
14702f60eb46Smrgfatal_help="Try '\$progname --help' for more information."
14712f60eb46Smrg
14722f60eb46Smrg
14732f60eb46Smrg
14742f60eb46Smrg## ------------------------- ##
14752f60eb46Smrg## Hook function management. ##
14762f60eb46Smrg## ------------------------- ##
14772f60eb46Smrg
14782f60eb46Smrg# This section contains functions for adding, removing, and running hooks
14792f60eb46Smrg# to the main code.  A hook is just a named list of of function, that can
14802f60eb46Smrg# be run in order later on.
14812f60eb46Smrg
14822f60eb46Smrg# func_hookable FUNC_NAME
14832f60eb46Smrg# -----------------------
14842f60eb46Smrg# Declare that FUNC_NAME will run hooks added with
14852f60eb46Smrg# 'func_add_hook FUNC_NAME ...'.
14862f60eb46Smrgfunc_hookable ()
14872f60eb46Smrg{
14882f60eb46Smrg    $debug_cmd
14892f60eb46Smrg
14902f60eb46Smrg    func_append hookable_fns " $1"
14912f60eb46Smrg}
14922f60eb46Smrg
14932f60eb46Smrg
14942f60eb46Smrg# func_add_hook FUNC_NAME HOOK_FUNC
14952f60eb46Smrg# ---------------------------------
14962f60eb46Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
14972f60eb46Smrg# first have been declared "hookable" by a call to 'func_hookable'.
14982f60eb46Smrgfunc_add_hook ()
14992f60eb46Smrg{
15002f60eb46Smrg    $debug_cmd
15012f60eb46Smrg
15022f60eb46Smrg    case " $hookable_fns " in
15032f60eb46Smrg      *" $1 "*) ;;
15042f60eb46Smrg      *) func_fatal_error "'$1' does not accept hook functions." ;;
15052f60eb46Smrg    esac
15062f60eb46Smrg
15072f60eb46Smrg    eval func_append ${1}_hooks '" $2"'
15082f60eb46Smrg}
15092f60eb46Smrg
15102f60eb46Smrg
15112f60eb46Smrg# func_remove_hook FUNC_NAME HOOK_FUNC
15122f60eb46Smrg# ------------------------------------
15132f60eb46Smrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
15142f60eb46Smrgfunc_remove_hook ()
15152f60eb46Smrg{
15162f60eb46Smrg    $debug_cmd
15172f60eb46Smrg
15182f60eb46Smrg    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
15192f60eb46Smrg}
15202f60eb46Smrg
15212f60eb46Smrg
15222f60eb46Smrg# func_run_hooks FUNC_NAME [ARG]...
15232f60eb46Smrg# ---------------------------------
15242f60eb46Smrg# Run all hook functions registered to FUNC_NAME.
15252f60eb46Smrg# It is assumed that the list of hook functions contains nothing more
15262f60eb46Smrg# than a whitespace-delimited list of legal shell function names, and
15272f60eb46Smrg# no effort is wasted trying to catch shell meta-characters or preserve
15282f60eb46Smrg# whitespace.
15292f60eb46Smrgfunc_run_hooks ()
15302f60eb46Smrg{
15312f60eb46Smrg    $debug_cmd
15322f60eb46Smrg
15332f60eb46Smrg    case " $hookable_fns " in
15342f60eb46Smrg      *" $1 "*) ;;
15352f60eb46Smrg      *) func_fatal_error "'$1' does not support hook funcions.n" ;;
15362f60eb46Smrg    esac
15372f60eb46Smrg
15382f60eb46Smrg    eval _G_hook_fns=\$$1_hooks; shift
15392f60eb46Smrg
15402f60eb46Smrg    for _G_hook in $_G_hook_fns; do
15412f60eb46Smrg      eval $_G_hook '"$@"'
15422f60eb46Smrg
15432f60eb46Smrg      # store returned options list back into positional
15442f60eb46Smrg      # parameters for next 'cmd' execution.
15452f60eb46Smrg      eval _G_hook_result=\$${_G_hook}_result
15462f60eb46Smrg      eval set dummy "$_G_hook_result"; shift
15472f60eb46Smrg    done
15482f60eb46Smrg
15492f60eb46Smrg    func_quote_for_eval ${1+"$@"}
15502f60eb46Smrg    func_run_hooks_result=$func_quote_for_eval_result
15512f60eb46Smrg}
15522f60eb46Smrg
15532f60eb46Smrg
15542f60eb46Smrg
15552f60eb46Smrg## --------------- ##
15562f60eb46Smrg## Option parsing. ##
15572f60eb46Smrg## --------------- ##
15582f60eb46Smrg
15592f60eb46Smrg# In order to add your own option parsing hooks, you must accept the
15602f60eb46Smrg# full positional parameter list in your hook function, remove any
15612f60eb46Smrg# options that you action, and then pass back the remaining unprocessed
15622f60eb46Smrg# options in '<hooked_function_name>_result', escaped suitably for
15632f60eb46Smrg# 'eval'.  Like this:
15642f60eb46Smrg#
15652f60eb46Smrg#    my_options_prep ()
15662f60eb46Smrg#    {
15672f60eb46Smrg#        $debug_cmd
15682f60eb46Smrg#
15692f60eb46Smrg#        # Extend the existing usage message.
15702f60eb46Smrg#        usage_message=$usage_message'
15712f60eb46Smrg#      -s, --silent       don'\''t print informational messages
15722f60eb46Smrg#    '
15732f60eb46Smrg#
15742f60eb46Smrg#        func_quote_for_eval ${1+"$@"}
15752f60eb46Smrg#        my_options_prep_result=$func_quote_for_eval_result
15762f60eb46Smrg#    }
15772f60eb46Smrg#    func_add_hook func_options_prep my_options_prep
15782f60eb46Smrg#
15792f60eb46Smrg#
15802f60eb46Smrg#    my_silent_option ()
15812f60eb46Smrg#    {
15822f60eb46Smrg#        $debug_cmd
15832f60eb46Smrg#
15842f60eb46Smrg#        # Note that for efficiency, we parse as many options as we can
15852f60eb46Smrg#        # recognise in a loop before passing the remainder back to the
15862f60eb46Smrg#        # caller on the first unrecognised argument we encounter.
15872f60eb46Smrg#        while test $# -gt 0; do
15882f60eb46Smrg#          opt=$1; shift
15892f60eb46Smrg#          case $opt in
15902f60eb46Smrg#            --silent|-s) opt_silent=: ;;
15912f60eb46Smrg#            # Separate non-argument short options:
15922f60eb46Smrg#            -s*)         func_split_short_opt "$_G_opt"
15932f60eb46Smrg#                         set dummy "$func_split_short_opt_name" \
15942f60eb46Smrg#                             "-$func_split_short_opt_arg" ${1+"$@"}
15952f60eb46Smrg#                         shift
15962f60eb46Smrg#                         ;;
15972f60eb46Smrg#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
15982f60eb46Smrg#          esac
15992f60eb46Smrg#        done
16002f60eb46Smrg#
16012f60eb46Smrg#        func_quote_for_eval ${1+"$@"}
16022f60eb46Smrg#        my_silent_option_result=$func_quote_for_eval_result
16032f60eb46Smrg#    }
16042f60eb46Smrg#    func_add_hook func_parse_options my_silent_option
16052f60eb46Smrg#
16062f60eb46Smrg#
16072f60eb46Smrg#    my_option_validation ()
16082f60eb46Smrg#    {
16092f60eb46Smrg#        $debug_cmd
16102f60eb46Smrg#
16112f60eb46Smrg#        $opt_silent && $opt_verbose && func_fatal_help "\
16122f60eb46Smrg#    '--silent' and '--verbose' options are mutually exclusive."
16132f60eb46Smrg#
16142f60eb46Smrg#        func_quote_for_eval ${1+"$@"}
16152f60eb46Smrg#        my_option_validation_result=$func_quote_for_eval_result
16162f60eb46Smrg#    }
16172f60eb46Smrg#    func_add_hook func_validate_options my_option_validation
16182f60eb46Smrg#
16192f60eb46Smrg# You'll alse need to manually amend $usage_message to reflect the extra
16202f60eb46Smrg# options you parse.  It's preferable to append if you can, so that
16212f60eb46Smrg# multiple option parsing hooks can be added safely.
16222f60eb46Smrg
16232f60eb46Smrg
16242f60eb46Smrg# func_options [ARG]...
16252f60eb46Smrg# ---------------------
16262f60eb46Smrg# All the functions called inside func_options are hookable. See the
16272f60eb46Smrg# individual implementations for details.
16282f60eb46Smrgfunc_hookable func_options
16292f60eb46Smrgfunc_options ()
16302f60eb46Smrg{
16312f60eb46Smrg    $debug_cmd
16322f60eb46Smrg
16332f60eb46Smrg    func_options_prep ${1+"$@"}
16342f60eb46Smrg    eval func_parse_options \
16352f60eb46Smrg        ${func_options_prep_result+"$func_options_prep_result"}
16362f60eb46Smrg    eval func_validate_options \
16372f60eb46Smrg        ${func_parse_options_result+"$func_parse_options_result"}
16382f60eb46Smrg
16392f60eb46Smrg    eval func_run_hooks func_options \
16402f60eb46Smrg        ${func_validate_options_result+"$func_validate_options_result"}
16412f60eb46Smrg
16422f60eb46Smrg    # save modified positional parameters for caller
16432f60eb46Smrg    func_options_result=$func_run_hooks_result
1644692f60a7Smrg}
1645692f60a7Smrg
1646692f60a7Smrg
16472f60eb46Smrg# func_options_prep [ARG]...
16482f60eb46Smrg# --------------------------
16492f60eb46Smrg# All initialisations required before starting the option parse loop.
16502f60eb46Smrg# Note that when calling hook functions, we pass through the list of
16512f60eb46Smrg# positional parameters.  If a hook function modifies that list, and
16522f60eb46Smrg# needs to propogate that back to rest of this script, then the complete
16532f60eb46Smrg# modified list must be put in 'func_run_hooks_result' before
16542f60eb46Smrg# returning.
16552f60eb46Smrgfunc_hookable func_options_prep
16562f60eb46Smrgfunc_options_prep ()
1657692f60a7Smrg{
16582f60eb46Smrg    $debug_cmd
1659c3c9db83Smrg
16602f60eb46Smrg    # Option defaults:
16612f60eb46Smrg    opt_verbose=false
16622f60eb46Smrg    opt_warning_types=
16632f60eb46Smrg
16642f60eb46Smrg    func_run_hooks func_options_prep ${1+"$@"}
16652f60eb46Smrg
16662f60eb46Smrg    # save modified positional parameters for caller
16672f60eb46Smrg    func_options_prep_result=$func_run_hooks_result
1668692f60a7Smrg}
1669692f60a7Smrg
1670692f60a7Smrg
16712f60eb46Smrg# func_parse_options [ARG]...
16722f60eb46Smrg# ---------------------------
16732f60eb46Smrg# The main option parsing loop.
16742f60eb46Smrgfunc_hookable func_parse_options
16752f60eb46Smrgfunc_parse_options ()
1676692f60a7Smrg{
16772f60eb46Smrg    $debug_cmd
1678c3c9db83Smrg
16792f60eb46Smrg    func_parse_options_result=
1680c3c9db83Smrg
16812f60eb46Smrg    # this just eases exit handling
16822f60eb46Smrg    while test $# -gt 0; do
16832f60eb46Smrg      # Defer to hook functions for initial option parsing, so they
16842f60eb46Smrg      # get priority in the event of reusing an option name.
16852f60eb46Smrg      func_run_hooks func_parse_options ${1+"$@"}
1686692f60a7Smrg
16872f60eb46Smrg      # Adjust func_parse_options positional parameters to match
16882f60eb46Smrg      eval set dummy "$func_run_hooks_result"; shift
1689692f60a7Smrg
16902f60eb46Smrg      # Break out of the loop if we already parsed every option.
16912f60eb46Smrg      test $# -gt 0 || break
169285ee4c00Smrg
16932f60eb46Smrg      _G_opt=$1
16942f60eb46Smrg      shift
16952f60eb46Smrg      case $_G_opt in
16962f60eb46Smrg        --debug|-x)   debug_cmd='set -x'
16972f60eb46Smrg                      func_echo "enabling shell trace mode"
16982f60eb46Smrg                      $debug_cmd
16992f60eb46Smrg                      ;;
17002f60eb46Smrg
17012f60eb46Smrg        --no-warnings|--no-warning|--no-warn)
17022f60eb46Smrg                      set dummy --warnings none ${1+"$@"}
17032f60eb46Smrg                      shift
17042f60eb46Smrg		      ;;
1705c3c9db83Smrg
17062f60eb46Smrg        --warnings|--warning|-W)
17072f60eb46Smrg                      test $# = 0 && func_missing_arg $_G_opt && break
17082f60eb46Smrg                      case " $warning_categories $1" in
17092f60eb46Smrg                        *" $1 "*)
17102f60eb46Smrg                          # trailing space prevents matching last $1 above
17112f60eb46Smrg                          func_append_uniq opt_warning_types " $1"
17122f60eb46Smrg                          ;;
17132f60eb46Smrg                        *all)
17142f60eb46Smrg                          opt_warning_types=$warning_categories
17152f60eb46Smrg                          ;;
17162f60eb46Smrg                        *none)
17172f60eb46Smrg                          opt_warning_types=none
17182f60eb46Smrg                          warning_func=:
17192f60eb46Smrg                          ;;
17202f60eb46Smrg                        *error)
17212f60eb46Smrg                          opt_warning_types=$warning_categories
17222f60eb46Smrg                          warning_func=func_fatal_error
17232f60eb46Smrg                          ;;
17242f60eb46Smrg                        *)
17252f60eb46Smrg                          func_fatal_error \
17262f60eb46Smrg                             "unsupported warning category: '$1'"
17272f60eb46Smrg                          ;;
17282f60eb46Smrg                      esac
17292f60eb46Smrg                      shift
17302f60eb46Smrg                      ;;
17312f60eb46Smrg
17322f60eb46Smrg        --verbose|-v) opt_verbose=: ;;
17332f60eb46Smrg        --version)    func_version ;;
17342f60eb46Smrg        -\?|-h)       func_usage ;;
17352f60eb46Smrg        --help)       func_help ;;
17362f60eb46Smrg
17372f60eb46Smrg	# Separate optargs to long options (plugins may need this):
17382f60eb46Smrg	--*=*)        func_split_equals "$_G_opt"
17392f60eb46Smrg	              set dummy "$func_split_equals_lhs" \
17402f60eb46Smrg                          "$func_split_equals_rhs" ${1+"$@"}
17412f60eb46Smrg                      shift
17422f60eb46Smrg                      ;;
17432f60eb46Smrg
17442f60eb46Smrg       # Separate optargs to short options:
17452f60eb46Smrg        -W*)
17462f60eb46Smrg                      func_split_short_opt "$_G_opt"
17472f60eb46Smrg                      set dummy "$func_split_short_opt_name" \
17482f60eb46Smrg                          "$func_split_short_opt_arg" ${1+"$@"}
17492f60eb46Smrg                      shift
17502f60eb46Smrg                      ;;
17512f60eb46Smrg
17522f60eb46Smrg        # Separate non-argument short options:
17532f60eb46Smrg        -\?*|-h*|-v*|-x*)
17542f60eb46Smrg                      func_split_short_opt "$_G_opt"
17552f60eb46Smrg                      set dummy "$func_split_short_opt_name" \
17562f60eb46Smrg                          "-$func_split_short_opt_arg" ${1+"$@"}
17572f60eb46Smrg                      shift
17582f60eb46Smrg                      ;;
17592f60eb46Smrg
17602f60eb46Smrg        --)           break ;;
17612f60eb46Smrg        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
17622f60eb46Smrg        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
17632f60eb46Smrg      esac
17642f60eb46Smrg    done
17652f60eb46Smrg
17662f60eb46Smrg    # save modified positional parameters for caller
17672f60eb46Smrg    func_quote_for_eval ${1+"$@"}
17682f60eb46Smrg    func_parse_options_result=$func_quote_for_eval_result
1769692f60a7Smrg}
1770692f60a7Smrg
1771c3c9db83Smrg
17722f60eb46Smrg# func_validate_options [ARG]...
17732f60eb46Smrg# ------------------------------
17742f60eb46Smrg# Perform any sanity checks on option settings and/or unconsumed
17752f60eb46Smrg# arguments.
17762f60eb46Smrgfunc_hookable func_validate_options
17772f60eb46Smrgfunc_validate_options ()
1778692f60a7Smrg{
17792f60eb46Smrg    $debug_cmd
1780c3c9db83Smrg
17812f60eb46Smrg    # Display all warnings if -W was not given.
17822f60eb46Smrg    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
1783c3c9db83Smrg
17842f60eb46Smrg    func_run_hooks func_validate_options ${1+"$@"}
1785692f60a7Smrg
17862f60eb46Smrg    # Bail if the options were screwed!
17872f60eb46Smrg    $exit_cmd $EXIT_FAILURE
17882f60eb46Smrg
17892f60eb46Smrg    # save modified positional parameters for caller
17902f60eb46Smrg    func_validate_options_result=$func_run_hooks_result
17913f6d0e1dSmrg}
1792c3c9db83Smrg
1793c3c9db83Smrg
17943f6d0e1dSmrg
17952f60eb46Smrg## ----------------- ##
17962f60eb46Smrg## Helper functions. ##
17972f60eb46Smrg## ----------------- ##
1798c3c9db83Smrg
17992f60eb46Smrg# This section contains the helper functions used by the rest of the
18002f60eb46Smrg# hookable option parser framework in ascii-betical order.
18012f60eb46Smrg
18022f60eb46Smrg
18032f60eb46Smrg# func_fatal_help ARG...
18042f60eb46Smrg# ----------------------
18052f60eb46Smrg# Echo program name prefixed message to standard error, followed by
18062f60eb46Smrg# a help hint, and exit.
18072f60eb46Smrgfunc_fatal_help ()
1808c3c9db83Smrg{
18092f60eb46Smrg    $debug_cmd
18103f6d0e1dSmrg
18112f60eb46Smrg    eval \$ECHO \""Usage: $usage"\"
18122f60eb46Smrg    eval \$ECHO \""$fatal_help"\"
18132f60eb46Smrg    func_error ${1+"$@"}
18142f60eb46Smrg    exit $EXIT_FAILURE
1815c3c9db83Smrg}
1816c3c9db83Smrg
18172f60eb46Smrg
18182f60eb46Smrg# func_help
18192f60eb46Smrg# ---------
18202f60eb46Smrg# Echo long help message to standard output and exit.
1821c3c9db83Smrgfunc_help ()
1822c3c9db83Smrg{
18232f60eb46Smrg    $debug_cmd
18242f60eb46Smrg
18252f60eb46Smrg    func_usage_message
18262f60eb46Smrg    $ECHO "$long_help_message"
18272f60eb46Smrg    exit 0
1828c3c9db83Smrg}
1829c3c9db83Smrg
18302f60eb46Smrg
18312f60eb46Smrg# func_missing_arg ARGNAME
18322f60eb46Smrg# ------------------------
1833c3c9db83Smrg# Echo program name prefixed message to standard error and set global
1834c3c9db83Smrg# exit_cmd.
1835c3c9db83Smrgfunc_missing_arg ()
1836c3c9db83Smrg{
18372f60eb46Smrg    $debug_cmd
18383f6d0e1dSmrg
18392f60eb46Smrg    func_error "Missing argument for '$1'."
1840c3c9db83Smrg    exit_cmd=exit
1841692f60a7Smrg}
1842692f60a7Smrg
184385ee4c00Smrg
18442f60eb46Smrg# func_split_equals STRING
18452f60eb46Smrg# ------------------------
18462f60eb46Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
18472f60eb46Smrg# splitting STRING at the '=' sign.
18482f60eb46Smrgtest -z "$_G_HAVE_XSI_OPS" \
18492f60eb46Smrg    && (eval 'x=a/b/c;
18502f60eb46Smrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
18512f60eb46Smrg    && _G_HAVE_XSI_OPS=yes
18522f60eb46Smrg
18532f60eb46Smrgif test yes = "$_G_HAVE_XSI_OPS"
18542f60eb46Smrgthen
18552f60eb46Smrg  # This is an XSI compatible shell, allowing a faster implementation...
18562f60eb46Smrg  eval 'func_split_equals ()
18572f60eb46Smrg  {
18582f60eb46Smrg      $debug_cmd
18592f60eb46Smrg
18602f60eb46Smrg      func_split_equals_lhs=${1%%=*}
18612f60eb46Smrg      func_split_equals_rhs=${1#*=}
18622f60eb46Smrg      test "x$func_split_equals_lhs" = "x$1" \
18632f60eb46Smrg        && func_split_equals_rhs=
18642f60eb46Smrg  }'
18652f60eb46Smrgelse
18662f60eb46Smrg  # ...otherwise fall back to using expr, which is often a shell builtin.
18672f60eb46Smrg  func_split_equals ()
18682f60eb46Smrg  {
18692f60eb46Smrg      $debug_cmd
18702f60eb46Smrg
18712f60eb46Smrg      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
18722f60eb46Smrg      func_split_equals_rhs=
18732f60eb46Smrg      test "x$func_split_equals_lhs" = "x$1" \
18742f60eb46Smrg        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
18752f60eb46Smrg  }
18762f60eb46Smrgfi #func_split_equals
18772f60eb46Smrg
18782f60eb46Smrg
18792f60eb46Smrg# func_split_short_opt SHORTOPT
18802f60eb46Smrg# -----------------------------
18813f6d0e1dSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
18823f6d0e1dSmrg# variables after splitting SHORTOPT after the 2nd character.
18832f60eb46Smrgif test yes = "$_G_HAVE_XSI_OPS"
18842f60eb46Smrgthen
18852f60eb46Smrg  # This is an XSI compatible shell, allowing a faster implementation...
18862f60eb46Smrg  eval 'func_split_short_opt ()
18872f60eb46Smrg  {
18882f60eb46Smrg      $debug_cmd
18892f60eb46Smrg
18902f60eb46Smrg      func_split_short_opt_arg=${1#??}
18912f60eb46Smrg      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
18922f60eb46Smrg  }'
18932f60eb46Smrgelse
18942f60eb46Smrg  # ...otherwise fall back to using expr, which is often a shell builtin.
18952f60eb46Smrg  func_split_short_opt ()
18962f60eb46Smrg  {
18972f60eb46Smrg      $debug_cmd
18982f60eb46Smrg
18992f60eb46Smrg      func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
19002f60eb46Smrg      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
19012f60eb46Smrg  }
19022f60eb46Smrgfi #func_split_short_opt
19032f60eb46Smrg
19042f60eb46Smrg
19052f60eb46Smrg# func_usage
19062f60eb46Smrg# ----------
19072f60eb46Smrg# Echo short help message to standard output and exit.
19082f60eb46Smrgfunc_usage ()
19093f6d0e1dSmrg{
19102f60eb46Smrg    $debug_cmd
191185ee4c00Smrg
19122f60eb46Smrg    func_usage_message
19132f60eb46Smrg    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
19142f60eb46Smrg    exit 0
19152f60eb46Smrg}
19163f6d0e1dSmrg
19173f6d0e1dSmrg
19182f60eb46Smrg# func_usage_message
19192f60eb46Smrg# ------------------
19202f60eb46Smrg# Echo short help message to standard output.
19212f60eb46Smrgfunc_usage_message ()
19223f6d0e1dSmrg{
19232f60eb46Smrg    $debug_cmd
19243f6d0e1dSmrg
19252f60eb46Smrg    eval \$ECHO \""Usage: $usage"\"
19262f60eb46Smrg    echo
19272f60eb46Smrg    $SED -n 's|^# ||
19282f60eb46Smrg        /^Written by/{
19292f60eb46Smrg          x;p;x
19302f60eb46Smrg        }
19312f60eb46Smrg	h
19322f60eb46Smrg	/^Written by/q' < "$progpath"
19332f60eb46Smrg    echo
19342f60eb46Smrg    eval \$ECHO \""$usage_message"\"
19352f60eb46Smrg}
19363f6d0e1dSmrg
1937c3c9db83Smrg
19382f60eb46Smrg# func_version
19392f60eb46Smrg# ------------
19402f60eb46Smrg# Echo version message to standard output and exit.
19412f60eb46Smrgfunc_version ()
19422f60eb46Smrg{
19432f60eb46Smrg    $debug_cmd
1944c3c9db83Smrg
19452f60eb46Smrg    printf '%s\n' "$progname $scriptversion"
19462f60eb46Smrg    $SED -n '
19472f60eb46Smrg        /(C)/!b go
19482f60eb46Smrg        :more
19492f60eb46Smrg        /\./!{
19502f60eb46Smrg          N
19512f60eb46Smrg          s|\n# | |
19522f60eb46Smrg          b more
19532f60eb46Smrg        }
19542f60eb46Smrg        :go
19552f60eb46Smrg        /^# Written by /,/# warranty; / {
19562f60eb46Smrg          s|^# ||
19572f60eb46Smrg          s|^# *$||
19582f60eb46Smrg          s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
19592f60eb46Smrg          p
19602f60eb46Smrg        }
19612f60eb46Smrg        /^# Written by / {
19622f60eb46Smrg          s|^# ||
19632f60eb46Smrg          p
19642f60eb46Smrg        }
19652f60eb46Smrg        /^warranty; /q' < "$progpath"
1966c3c9db83Smrg
19672f60eb46Smrg    exit $?
19682f60eb46Smrg}
1969692f60a7Smrg
1970692f60a7Smrg
19712f60eb46Smrg# Local variables:
19722f60eb46Smrg# mode: shell-script
19732f60eb46Smrg# sh-indentation: 2
19742f60eb46Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
19752f60eb46Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
19762f60eb46Smrg# time-stamp-time-zone: "UTC"
19772f60eb46Smrg# End:
1978692f60a7Smrg
19792f60eb46Smrg# Set a version string.
19802f60eb46Smrgscriptversion='(GNU libtool) 2.4.6'
198185ee4c00Smrg
1982c3c9db83Smrg
19832f60eb46Smrg# func_echo ARG...
19842f60eb46Smrg# ----------------
19852f60eb46Smrg# Libtool also displays the current mode in messages, so override
19862f60eb46Smrg# funclib.sh func_echo with this custom definition.
19872f60eb46Smrgfunc_echo ()
19883f6d0e1dSmrg{
19892f60eb46Smrg    $debug_cmd
19903f6d0e1dSmrg
19912f60eb46Smrg    _G_message=$*
19923f6d0e1dSmrg
19932f60eb46Smrg    func_echo_IFS=$IFS
19942f60eb46Smrg    IFS=$nl
19952f60eb46Smrg    for _G_line in $_G_message; do
19962f60eb46Smrg      IFS=$func_echo_IFS
19972f60eb46Smrg      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
19982f60eb46Smrg    done
19992f60eb46Smrg    IFS=$func_echo_IFS
20002f60eb46Smrg}
20013f6d0e1dSmrg
20022f60eb46Smrg
20032f60eb46Smrg# func_warning ARG...
20042f60eb46Smrg# -------------------
20052f60eb46Smrg# Libtool warnings are not categorized, so override funclib.sh
20062f60eb46Smrg# func_warning with this simpler definition.
20072f60eb46Smrgfunc_warning ()
20083f6d0e1dSmrg{
20092f60eb46Smrg    $debug_cmd
20103f6d0e1dSmrg
20112f60eb46Smrg    $warning_func ${1+"$@"}
20122f60eb46Smrg}
20133f6d0e1dSmrg
20143f6d0e1dSmrg
20152f60eb46Smrg## ---------------- ##
20162f60eb46Smrg## Options parsing. ##
20172f60eb46Smrg## ---------------- ##
20182f60eb46Smrg
20192f60eb46Smrg# Hook in the functions to make sure our own options are parsed during
20202f60eb46Smrg# the option parsing loop.
20212f60eb46Smrg
20222f60eb46Smrgusage='$progpath [OPTION]... [MODE-ARG]...'
20232f60eb46Smrg
20242f60eb46Smrg# Short help message in response to '-h'.
20252f60eb46Smrgusage_message="Options:
20262f60eb46Smrg       --config             show all configuration variables
20272f60eb46Smrg       --debug              enable verbose shell tracing
20282f60eb46Smrg   -n, --dry-run            display commands without modifying any files
20292f60eb46Smrg       --features           display basic configuration information and exit
20302f60eb46Smrg       --mode=MODE          use operation mode MODE
20312f60eb46Smrg       --no-warnings        equivalent to '-Wnone'
20322f60eb46Smrg       --preserve-dup-deps  don't remove duplicate dependency libraries
20332f60eb46Smrg       --quiet, --silent    don't print informational messages
20342f60eb46Smrg       --tag=TAG            use configuration variables from tag TAG
20352f60eb46Smrg   -v, --verbose            print more informational messages than default
20362f60eb46Smrg       --version            print version information
20372f60eb46Smrg   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
20382f60eb46Smrg   -h, --help, --help-all   print short, long, or detailed help message
20392f60eb46Smrg"
20403f6d0e1dSmrg
20412f60eb46Smrg# Additional text appended to 'usage_message' in response to '--help'.
20422f60eb46Smrgfunc_help ()
20433f6d0e1dSmrg{
20442f60eb46Smrg    $debug_cmd
20452f60eb46Smrg
20462f60eb46Smrg    func_usage_message
20472f60eb46Smrg    $ECHO "$long_help_message
20482f60eb46Smrg
20492f60eb46SmrgMODE must be one of the following:
20502f60eb46Smrg
20512f60eb46Smrg       clean           remove files from the build directory
20522f60eb46Smrg       compile         compile a source file into a libtool object
20532f60eb46Smrg       execute         automatically set library path, then run a program
20542f60eb46Smrg       finish          complete the installation of libtool libraries
20552f60eb46Smrg       install         install libraries or executables
20562f60eb46Smrg       link            create a library or an executable
20572f60eb46Smrg       uninstall       remove libraries from an installed directory
20582f60eb46Smrg
20592f60eb46SmrgMODE-ARGS vary depending on the MODE.  When passed as first option,
20602f60eb46Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
20612f60eb46SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE.
20622f60eb46Smrg
20632f60eb46SmrgWhen reporting a bug, please describe a test case to reproduce it and
20642f60eb46Smrginclude the following information:
20652f60eb46Smrg
20662f60eb46Smrg       host-triplet:   $host
20672f60eb46Smrg       shell:          $SHELL
20682f60eb46Smrg       compiler:       $LTCC
20692f60eb46Smrg       compiler flags: $LTCFLAGS
20702f60eb46Smrg       linker:         $LD (gnu? $with_gnu_ld)
20712f60eb46Smrg       version:        $progname (GNU libtool) 2.4.6
20722f60eb46Smrg       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
20732f60eb46Smrg       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
20742f60eb46Smrg
20752f60eb46SmrgReport bugs to <bug-libtool@gnu.org>.
20762f60eb46SmrgGNU libtool home page: <http://www.gnu.org/s/libtool/>.
20772f60eb46SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>."
20782f60eb46Smrg    exit 0
20792f60eb46Smrg}
20803f6d0e1dSmrg
20813f6d0e1dSmrg
20822f60eb46Smrg# func_lo2o OBJECT-NAME
20832f60eb46Smrg# ---------------------
20842f60eb46Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
20852f60eb46Smrg# object suffix.
20862f60eb46Smrg
20872f60eb46Smrglo2o=s/\\.lo\$/.$objext/
20882f60eb46Smrgo2lo=s/\\.$objext\$/.lo/
20892f60eb46Smrg
20902f60eb46Smrgif test yes = "$_G_HAVE_XSI_OPS"; then
20912f60eb46Smrg  eval 'func_lo2o ()
20922f60eb46Smrg  {
20932f60eb46Smrg    case $1 in
20942f60eb46Smrg      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
20952f60eb46Smrg      *   ) func_lo2o_result=$1               ;;
20962f60eb46Smrg    esac
20972f60eb46Smrg  }'
20982f60eb46Smrg
20992f60eb46Smrg  # func_xform LIBOBJ-OR-SOURCE
21002f60eb46Smrg  # ---------------------------
21012f60eb46Smrg  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
21022f60eb46Smrg  # suffix to a '.lo' libtool-object suffix.
21032f60eb46Smrg  eval 'func_xform ()
21042f60eb46Smrg  {
21052f60eb46Smrg    func_xform_result=${1%.*}.lo
21062f60eb46Smrg  }'
21072f60eb46Smrgelse
21082f60eb46Smrg  # ...otherwise fall back to using sed.
21092f60eb46Smrg  func_lo2o ()
21102f60eb46Smrg  {
21112f60eb46Smrg    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
21122f60eb46Smrg  }
21132f60eb46Smrg
21142f60eb46Smrg  func_xform ()
21152f60eb46Smrg  {
21162f60eb46Smrg    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
21172f60eb46Smrg  }
21182f60eb46Smrgfi
21193f6d0e1dSmrg
21203f6d0e1dSmrg
21212f60eb46Smrg# func_fatal_configuration ARG...
21222f60eb46Smrg# -------------------------------
2123c3c9db83Smrg# Echo program name prefixed message to standard error, followed by
2124c3c9db83Smrg# a configuration failure hint, and exit.
2125c3c9db83Smrgfunc_fatal_configuration ()
2126c3c9db83Smrg{
21272f60eb46Smrg    func__fatal_error ${1+"$@"} \
21282f60eb46Smrg      "See the $PACKAGE documentation for more information." \
21292f60eb46Smrg      "Fatal configuration error."
2130c3c9db83Smrg}
213154569438Smrg
213285ee4c00Smrg
2133c3c9db83Smrg# func_config
21342f60eb46Smrg# -----------
2135c3c9db83Smrg# Display the configuration for all the tags in this script.
2136c3c9db83Smrgfunc_config ()
2137c3c9db83Smrg{
2138c3c9db83Smrg    re_begincf='^# ### BEGIN LIBTOOL'
2139c3c9db83Smrg    re_endcf='^# ### END LIBTOOL'
2140c3c9db83Smrg
2141c3c9db83Smrg    # Default configuration.
2142c3c9db83Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
2143692f60a7Smrg
2144692f60a7Smrg    # Now print the configurations for the tags.
2145692f60a7Smrg    for tagname in $taglist; do
2146c3c9db83Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
2147692f60a7Smrg    done
21482e71ea71Smrg
2149c3c9db83Smrg    exit $?
2150c3c9db83Smrg}
21512e71ea71Smrg
21522f60eb46Smrg
2153c3c9db83Smrg# func_features
21542f60eb46Smrg# -------------
2155c3c9db83Smrg# Display the features supported by this script.
2156c3c9db83Smrgfunc_features ()
2157c3c9db83Smrg{
21583f6d0e1dSmrg    echo "host: $host"
21592f60eb46Smrg    if test yes = "$build_libtool_libs"; then
21603f6d0e1dSmrg      echo "enable shared libraries"
2161692f60a7Smrg    else
21623f6d0e1dSmrg      echo "disable shared libraries"
2163692f60a7Smrg    fi
21642f60eb46Smrg    if test yes = "$build_old_libs"; then
21653f6d0e1dSmrg      echo "enable static libraries"
2166692f60a7Smrg    else
21673f6d0e1dSmrg      echo "disable static libraries"
2168692f60a7Smrg    fi
2169c3c9db83Smrg
2170692f60a7Smrg    exit $?
2171c3c9db83Smrg}
2172692f60a7Smrg
21732f60eb46Smrg
21742f60eb46Smrg# func_enable_tag TAGNAME
21752f60eb46Smrg# -----------------------
2176c3c9db83Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
2177c3c9db83Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
2178c3c9db83Smrg# variable here.
2179c3c9db83Smrgfunc_enable_tag ()
2180c3c9db83Smrg{
21812f60eb46Smrg    # Global variable:
21822f60eb46Smrg    tagname=$1
2183692f60a7Smrg
21842f60eb46Smrg    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
21852f60eb46Smrg    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
21862f60eb46Smrg    sed_extractcf=/$re_begincf/,/$re_endcf/p
218785ee4c00Smrg
21882f60eb46Smrg    # Validate tagname.
21892f60eb46Smrg    case $tagname in
21902f60eb46Smrg      *[!-_A-Za-z0-9,/]*)
21912f60eb46Smrg        func_fatal_error "invalid tag name: $tagname"
21922f60eb46Smrg        ;;
21932f60eb46Smrg    esac
2194692f60a7Smrg
21952f60eb46Smrg    # Don't test for the "default" C tag, as we know it's
21962f60eb46Smrg    # there but not specially marked.
21972f60eb46Smrg    case $tagname in
21982f60eb46Smrg        CC) ;;
2199c3c9db83Smrg    *)
22002f60eb46Smrg        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
22012f60eb46Smrg	  taglist="$taglist $tagname"
22022f60eb46Smrg
22032f60eb46Smrg	  # Evaluate the configuration.  Be careful to quote the path
22042f60eb46Smrg	  # and the sed script, to avoid splitting on whitespace, but
22052f60eb46Smrg	  # also don't use non-portable quotes within backquotes within
22062f60eb46Smrg	  # quotes we have to do it in 2 steps:
22072f60eb46Smrg	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
22082f60eb46Smrg	  eval "$extractedcf"
22092f60eb46Smrg        else
22102f60eb46Smrg	  func_error "ignoring unknown tag $tagname"
22112f60eb46Smrg        fi
22122f60eb46Smrg        ;;
22132f60eb46Smrg    esac
2214c3c9db83Smrg}
2215c3c9db83Smrg
22162f60eb46Smrg
22173f6d0e1dSmrg# func_check_version_match
22182f60eb46Smrg# ------------------------
22193f6d0e1dSmrg# Ensure that we are using m4 macros, and libtool script from the same
22203f6d0e1dSmrg# release of libtool.
22213f6d0e1dSmrgfunc_check_version_match ()
2222c3c9db83Smrg{
22232f60eb46Smrg    if test "$package_revision" != "$macro_revision"; then
22242f60eb46Smrg      if test "$VERSION" != "$macro_version"; then
22252f60eb46Smrg        if test -z "$macro_version"; then
22262f60eb46Smrg          cat >&2 <<_LT_EOF
22273f6d0e1dSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
22283f6d0e1dSmrg$progname: definition of this LT_INIT comes from an older release.
22293f6d0e1dSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
22303f6d0e1dSmrg$progname: and run autoconf again.
22313f6d0e1dSmrg_LT_EOF
22322f60eb46Smrg        else
22332f60eb46Smrg          cat >&2 <<_LT_EOF
22343f6d0e1dSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
22353f6d0e1dSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
22363f6d0e1dSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
22373f6d0e1dSmrg$progname: and run autoconf again.
22383f6d0e1dSmrg_LT_EOF
22392f60eb46Smrg        fi
22402f60eb46Smrg      else
22412f60eb46Smrg        cat >&2 <<_LT_EOF
22423f6d0e1dSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
22433f6d0e1dSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
22443f6d0e1dSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
22453f6d0e1dSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
22463f6d0e1dSmrg_LT_EOF
22472f60eb46Smrg      fi
22483f6d0e1dSmrg
22492f60eb46Smrg      exit $EXIT_MISMATCH
22502f60eb46Smrg    fi
22513f6d0e1dSmrg}
22523f6d0e1dSmrg
22533f6d0e1dSmrg
22542f60eb46Smrg# libtool_options_prep [ARG]...
22552f60eb46Smrg# -----------------------------
22562f60eb46Smrg# Preparation for options parsed by libtool.
22572f60eb46Smrglibtool_options_prep ()
22582f60eb46Smrg{
22592f60eb46Smrg    $debug_mode
22603f6d0e1dSmrg
22612f60eb46Smrg    # Option defaults:
22622f60eb46Smrg    opt_config=false
22632f60eb46Smrg    opt_dlopen=
22642f60eb46Smrg    opt_dry_run=false
22652f60eb46Smrg    opt_help=false
22662f60eb46Smrg    opt_mode=
22672f60eb46Smrg    opt_preserve_dup_deps=false
22682f60eb46Smrg    opt_quiet=false
22693f6d0e1dSmrg
22702f60eb46Smrg    nonopt=
22712f60eb46Smrg    preserve_args=
22723f6d0e1dSmrg
22732f60eb46Smrg    # Shorthand for --mode=foo, only valid as the first argument
22742f60eb46Smrg    case $1 in
22752f60eb46Smrg    clean|clea|cle|cl)
22762f60eb46Smrg      shift; set dummy --mode clean ${1+"$@"}; shift
22772f60eb46Smrg      ;;
22782f60eb46Smrg    compile|compil|compi|comp|com|co|c)
22792f60eb46Smrg      shift; set dummy --mode compile ${1+"$@"}; shift
22802f60eb46Smrg      ;;
22812f60eb46Smrg    execute|execut|execu|exec|exe|ex|e)
22822f60eb46Smrg      shift; set dummy --mode execute ${1+"$@"}; shift
22832f60eb46Smrg      ;;
22842f60eb46Smrg    finish|finis|fini|fin|fi|f)
22852f60eb46Smrg      shift; set dummy --mode finish ${1+"$@"}; shift
22862f60eb46Smrg      ;;
22872f60eb46Smrg    install|instal|insta|inst|ins|in|i)
22882f60eb46Smrg      shift; set dummy --mode install ${1+"$@"}; shift
22892f60eb46Smrg      ;;
22902f60eb46Smrg    link|lin|li|l)
22912f60eb46Smrg      shift; set dummy --mode link ${1+"$@"}; shift
22922f60eb46Smrg      ;;
22932f60eb46Smrg    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
22942f60eb46Smrg      shift; set dummy --mode uninstall ${1+"$@"}; shift
22952f60eb46Smrg      ;;
22962f60eb46Smrg    esac
22972f60eb46Smrg
22982f60eb46Smrg    # Pass back the list of options.
22992f60eb46Smrg    func_quote_for_eval ${1+"$@"}
23002f60eb46Smrg    libtool_options_prep_result=$func_quote_for_eval_result
23012f60eb46Smrg}
23022f60eb46Smrgfunc_add_hook func_options_prep libtool_options_prep
23032e71ea71Smrg
2304692f60a7Smrg
23052f60eb46Smrg# libtool_parse_options [ARG]...
23062f60eb46Smrg# ---------------------------------
23072f60eb46Smrg# Provide handling for libtool specific options.
23082f60eb46Smrglibtool_parse_options ()
23093f6d0e1dSmrg{
23102f60eb46Smrg    $debug_cmd
2311c3c9db83Smrg
23122f60eb46Smrg    # Perform our own loop to consume as many options as possible in
23132f60eb46Smrg    # each iteration.
23142f60eb46Smrg    while test $# -gt 0; do
23152f60eb46Smrg      _G_opt=$1
23162f60eb46Smrg      shift
23172f60eb46Smrg      case $_G_opt in
23182f60eb46Smrg        --dry-run|--dryrun|-n)
23192f60eb46Smrg                        opt_dry_run=:
23202f60eb46Smrg                        ;;
23212f60eb46Smrg
23222f60eb46Smrg        --config)       func_config ;;
23232f60eb46Smrg
23242f60eb46Smrg        --dlopen|-dlopen)
23252f60eb46Smrg                        opt_dlopen="${opt_dlopen+$opt_dlopen
23262f60eb46Smrg}$1"
23272f60eb46Smrg                        shift
23282f60eb46Smrg                        ;;
23292f60eb46Smrg
23302f60eb46Smrg        --preserve-dup-deps)
23312f60eb46Smrg                        opt_preserve_dup_deps=: ;;
23322f60eb46Smrg
23332f60eb46Smrg        --features)     func_features ;;
23342f60eb46Smrg
23352f60eb46Smrg        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
23362f60eb46Smrg
23372f60eb46Smrg        --help)         opt_help=: ;;
23382f60eb46Smrg
23392f60eb46Smrg        --help-all)     opt_help=': help-all' ;;
23402f60eb46Smrg
23412f60eb46Smrg        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
23422f60eb46Smrg                        opt_mode=$1
23432f60eb46Smrg                        case $1 in
23442f60eb46Smrg                          # Valid mode arguments:
23452f60eb46Smrg                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
23462f60eb46Smrg
23472f60eb46Smrg                          # Catch anything else as an error
23482f60eb46Smrg                          *) func_error "invalid argument for $_G_opt"
23492f60eb46Smrg                             exit_cmd=exit
23502f60eb46Smrg                             break
23512f60eb46Smrg                             ;;
23522f60eb46Smrg                        esac
23532f60eb46Smrg                        shift
23542f60eb46Smrg                        ;;
23552f60eb46Smrg
23562f60eb46Smrg        --no-silent|--no-quiet)
23572f60eb46Smrg                        opt_quiet=false
23582f60eb46Smrg                        func_append preserve_args " $_G_opt"
23592f60eb46Smrg                        ;;
23602f60eb46Smrg
23612f60eb46Smrg        --no-warnings|--no-warning|--no-warn)
23622f60eb46Smrg                        opt_warning=false
23632f60eb46Smrg                        func_append preserve_args " $_G_opt"
23642f60eb46Smrg                        ;;
23652f60eb46Smrg
23662f60eb46Smrg        --no-verbose)
23672f60eb46Smrg                        opt_verbose=false
23682f60eb46Smrg                        func_append preserve_args " $_G_opt"
23692f60eb46Smrg                        ;;
23702f60eb46Smrg
23712f60eb46Smrg        --silent|--quiet)
23722f60eb46Smrg                        opt_quiet=:
23732f60eb46Smrg                        opt_verbose=false
23742f60eb46Smrg                        func_append preserve_args " $_G_opt"
23752f60eb46Smrg                        ;;
23762f60eb46Smrg
23772f60eb46Smrg        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
23782f60eb46Smrg                        opt_tag=$1
23792f60eb46Smrg                        func_append preserve_args " $_G_opt $1"
23802f60eb46Smrg                        func_enable_tag "$1"
23812f60eb46Smrg                        shift
23822f60eb46Smrg                        ;;
23832f60eb46Smrg
23842f60eb46Smrg        --verbose|-v)   opt_quiet=false
23852f60eb46Smrg                        opt_verbose=:
23862f60eb46Smrg                        func_append preserve_args " $_G_opt"
23872f60eb46Smrg                        ;;
23882f60eb46Smrg
23892f60eb46Smrg	# An option not handled by this hook function:
23902f60eb46Smrg        *)		set dummy "$_G_opt" ${1+"$@"};	shift; break  ;;
23912f60eb46Smrg      esac
23922f60eb46Smrg    done
23933f6d0e1dSmrg
23943f6d0e1dSmrg
23952f60eb46Smrg    # save modified positional parameters for caller
23962f60eb46Smrg    func_quote_for_eval ${1+"$@"}
23972f60eb46Smrg    libtool_parse_options_result=$func_quote_for_eval_result
23982f60eb46Smrg}
23992f60eb46Smrgfunc_add_hook func_parse_options libtool_parse_options
2400c3c9db83Smrg
240185ee4c00Smrg
2402c3c9db83Smrg
24032f60eb46Smrg# libtool_validate_options [ARG]...
24042f60eb46Smrg# ---------------------------------
24052f60eb46Smrg# Perform any sanity checks on option settings and/or unconsumed
24062f60eb46Smrg# arguments.
24072f60eb46Smrglibtool_validate_options ()
24082f60eb46Smrg{
24092f60eb46Smrg    # save first non-option argument
24102f60eb46Smrg    if test 0 -lt $#; then
24112f60eb46Smrg      nonopt=$1
24122f60eb46Smrg      shift
2413c3c9db83Smrg    fi
2414c3c9db83Smrg
24152f60eb46Smrg    # preserve --debug
24162f60eb46Smrg    test : = "$debug_cmd" || func_append preserve_args " --debug"
2417c3c9db83Smrg
24182f60eb46Smrg    case $host in
24192f60eb46Smrg      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
24202f60eb46Smrg      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
24212f60eb46Smrg      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
24222f60eb46Smrg        # don't eliminate duplications in $postdeps and $predeps
24232f60eb46Smrg        opt_duplicate_compiler_generated_deps=:
24242f60eb46Smrg        ;;
24252f60eb46Smrg      *)
24262f60eb46Smrg        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
24272f60eb46Smrg        ;;
24282f60eb46Smrg    esac
2429692f60a7Smrg
24302f60eb46Smrg    $opt_help || {
24312f60eb46Smrg      # Sanity checks first:
24322f60eb46Smrg      func_check_version_match
24332f60eb46Smrg
24342f60eb46Smrg      test yes != "$build_libtool_libs" \
24352f60eb46Smrg        && test yes != "$build_old_libs" \
24362f60eb46Smrg        && func_fatal_configuration "not configured to build any kind of library"
24372f60eb46Smrg
24382f60eb46Smrg      # Darwin sucks
24392f60eb46Smrg      eval std_shrext=\"$shrext_cmds\"
24402f60eb46Smrg
24412f60eb46Smrg      # Only execute mode is allowed to have -dlopen flags.
24422f60eb46Smrg      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
24432f60eb46Smrg        func_error "unrecognized option '-dlopen'"
24442f60eb46Smrg        $ECHO "$help" 1>&2
24452f60eb46Smrg        exit $EXIT_FAILURE
24462f60eb46Smrg      fi
2447c3c9db83Smrg
24482f60eb46Smrg      # Change the help message to a mode-specific one.
24492f60eb46Smrg      generic_help=$help
24502f60eb46Smrg      help="Try '$progname --help --mode=$opt_mode' for more information."
24512f60eb46Smrg    }
2452c3c9db83Smrg
24532f60eb46Smrg    # Pass back the unparsed argument list
24542f60eb46Smrg    func_quote_for_eval ${1+"$@"}
24552f60eb46Smrg    libtool_validate_options_result=$func_quote_for_eval_result
24563f6d0e1dSmrg}
24572f60eb46Smrgfunc_add_hook func_validate_options libtool_validate_options
2458c3c9db83Smrg
2459c3c9db83Smrg
24602f60eb46Smrg# Process options as early as possible so that --help and --version
24612f60eb46Smrg# can return quickly.
24622f60eb46Smrgfunc_options ${1+"$@"}
24632f60eb46Smrgeval set dummy "$func_options_result"; shift
24642f60eb46Smrg
2465692f60a7Smrg
2466692f60a7Smrg
24673f6d0e1dSmrg## ----------- ##
24683f6d0e1dSmrg##    Main.    ##
24693f6d0e1dSmrg## ----------- ##
2470692f60a7Smrg
24712f60eb46Smrgmagic='%%%MAGIC variable%%%'
24722f60eb46Smrgmagic_exe='%%%MAGIC EXE variable%%%'
24732f60eb46Smrg
24742f60eb46Smrg# Global variables.
24752f60eb46Smrgextracted_archives=
24762f60eb46Smrgextracted_serial=0
24772f60eb46Smrg
24782f60eb46Smrg# If this variable is set in any of the actions, the command in it
24792f60eb46Smrg# will be execed at the end.  This prevents here-documents from being
24802f60eb46Smrg# left over by shells.
24812f60eb46Smrgexec_cmd=
24822f60eb46Smrg
24832f60eb46Smrg
24842f60eb46Smrg# A function that is used when there is no print builtin or printf.
24852f60eb46Smrgfunc_fallback_echo ()
24862f60eb46Smrg{
24872f60eb46Smrg  eval 'cat <<_LTECHO_EOF
24882f60eb46Smrg$1
24892f60eb46Smrg_LTECHO_EOF'
24902f60eb46Smrg}
24912f60eb46Smrg
24922f60eb46Smrg# func_generated_by_libtool
24932f60eb46Smrg# True iff stdin has been generated by Libtool. This function is only
24942f60eb46Smrg# a basic sanity check; it will hardly flush out determined imposters.
24952f60eb46Smrgfunc_generated_by_libtool_p ()
24962f60eb46Smrg{
24972f60eb46Smrg  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
24982f60eb46Smrg}
24992f60eb46Smrg
2500c3c9db83Smrg# func_lalib_p file
25012f60eb46Smrg# True iff FILE is a libtool '.la' library or '.lo' object file.
2502c3c9db83Smrg# This function is only a basic sanity check; it will hardly flush out
2503c3c9db83Smrg# determined imposters.
2504c3c9db83Smrgfunc_lalib_p ()
2505c3c9db83Smrg{
2506c3c9db83Smrg    test -f "$1" &&
25072f60eb46Smrg      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
2508c3c9db83Smrg}
2509692f60a7Smrg
2510c3c9db83Smrg# func_lalib_unsafe_p file
25112f60eb46Smrg# True iff FILE is a libtool '.la' library or '.lo' object file.
2512c3c9db83Smrg# This function implements the same check as func_lalib_p without
2513c3c9db83Smrg# resorting to external programs.  To this end, it redirects stdin and
2514c3c9db83Smrg# closes it afterwards, without saving the original file descriptor.
2515c3c9db83Smrg# As a safety measure, use it only where a negative result would be
25162f60eb46Smrg# fatal anyway.  Works if 'file' does not exist.
2517c3c9db83Smrgfunc_lalib_unsafe_p ()
2518c3c9db83Smrg{
2519c3c9db83Smrg    lalib_p=no
2520c3c9db83Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
2521c3c9db83Smrg	for lalib_p_l in 1 2 3 4
2522c3c9db83Smrg	do
2523c3c9db83Smrg	    read lalib_p_line
25242f60eb46Smrg	    case $lalib_p_line in
2525c3c9db83Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
2526c3c9db83Smrg	    esac
2527c3c9db83Smrg	done
2528c3c9db83Smrg	exec 0<&5 5<&-
2529c3c9db83Smrg    fi
25302f60eb46Smrg    test yes = "$lalib_p"
2531c3c9db83Smrg}
2532692f60a7Smrg
2533c3c9db83Smrg# func_ltwrapper_script_p file
2534c3c9db83Smrg# True iff FILE is a libtool wrapper script
2535c3c9db83Smrg# This function is only a basic sanity check; it will hardly flush out
2536c3c9db83Smrg# determined imposters.
2537c3c9db83Smrgfunc_ltwrapper_script_p ()
2538c3c9db83Smrg{
25392f60eb46Smrg    test -f "$1" &&
25402f60eb46Smrg      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
2541c3c9db83Smrg}
2542692f60a7Smrg
2543c3c9db83Smrg# func_ltwrapper_executable_p file
2544c3c9db83Smrg# True iff FILE is a libtool wrapper executable
2545c3c9db83Smrg# This function is only a basic sanity check; it will hardly flush out
2546c3c9db83Smrg# determined imposters.
2547c3c9db83Smrgfunc_ltwrapper_executable_p ()
2548c3c9db83Smrg{
2549c3c9db83Smrg    func_ltwrapper_exec_suffix=
2550c3c9db83Smrg    case $1 in
2551c3c9db83Smrg    *.exe) ;;
2552c3c9db83Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
2553c3c9db83Smrg    esac
2554c3c9db83Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
2555c3c9db83Smrg}
255685ee4c00Smrg
2557c3c9db83Smrg# func_ltwrapper_scriptname file
2558c3c9db83Smrg# Assumes file is an ltwrapper_executable
2559c3c9db83Smrg# uses $file to determine the appropriate filename for a
2560c3c9db83Smrg# temporary ltwrapper_script.
2561c3c9db83Smrgfunc_ltwrapper_scriptname ()
2562c3c9db83Smrg{
25633f6d0e1dSmrg    func_dirname_and_basename "$1" "" "."
25643f6d0e1dSmrg    func_stripname '' '.exe' "$func_basename_result"
25652f60eb46Smrg    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
2566c3c9db83Smrg}
2567c3c9db83Smrg
2568c3c9db83Smrg# func_ltwrapper_p file
2569c3c9db83Smrg# True iff FILE is a libtool wrapper script or wrapper executable
2570c3c9db83Smrg# This function is only a basic sanity check; it will hardly flush out
2571c3c9db83Smrg# determined imposters.
2572c3c9db83Smrgfunc_ltwrapper_p ()
2573c3c9db83Smrg{
2574c3c9db83Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
2575c3c9db83Smrg}
2576c3c9db83Smrg
2577c3c9db83Smrg
2578c3c9db83Smrg# func_execute_cmds commands fail_cmd
2579c3c9db83Smrg# Execute tilde-delimited COMMANDS.
2580c3c9db83Smrg# If FAIL_CMD is given, eval that upon failure.
2581c3c9db83Smrg# FAIL_CMD may read-access the current command in variable CMD!
2582c3c9db83Smrgfunc_execute_cmds ()
2583c3c9db83Smrg{
25842f60eb46Smrg    $debug_cmd
25852f60eb46Smrg
2586c3c9db83Smrg    save_ifs=$IFS; IFS='~'
2587c3c9db83Smrg    for cmd in $1; do
25882f60eb46Smrg      IFS=$sp$nl
2589c3c9db83Smrg      eval cmd=\"$cmd\"
25902f60eb46Smrg      IFS=$save_ifs
2591c3c9db83Smrg      func_show_eval "$cmd" "${2-:}"
2592c3c9db83Smrg    done
2593c3c9db83Smrg    IFS=$save_ifs
2594c3c9db83Smrg}
2595c3c9db83Smrg
2596c3c9db83Smrg
2597c3c9db83Smrg# func_source file
2598c3c9db83Smrg# Source FILE, adding directory component if necessary.
2599c3c9db83Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
2600c3c9db83Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
2601c3c9db83Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
26022f60eb46Smrg# 'FILE.' does not work on cygwin managed mounts.
2603c3c9db83Smrgfunc_source ()
2604c3c9db83Smrg{
26052f60eb46Smrg    $debug_cmd
26062f60eb46Smrg
2607c3c9db83Smrg    case $1 in
2608c3c9db83Smrg    */* | *\\*)	. "$1" ;;
2609c3c9db83Smrg    *)		. "./$1" ;;
2610c3c9db83Smrg    esac
2611c3c9db83Smrg}
2612c3c9db83Smrg
2613c3c9db83Smrg
26143f6d0e1dSmrg# func_resolve_sysroot PATH
26153f6d0e1dSmrg# Replace a leading = in PATH with a sysroot.  Store the result into
26163f6d0e1dSmrg# func_resolve_sysroot_result
26173f6d0e1dSmrgfunc_resolve_sysroot ()
26183f6d0e1dSmrg{
26193f6d0e1dSmrg  func_resolve_sysroot_result=$1
26203f6d0e1dSmrg  case $func_resolve_sysroot_result in
26213f6d0e1dSmrg  =*)
26223f6d0e1dSmrg    func_stripname '=' '' "$func_resolve_sysroot_result"
26233f6d0e1dSmrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
26243f6d0e1dSmrg    ;;
26253f6d0e1dSmrg  esac
26263f6d0e1dSmrg}
26273f6d0e1dSmrg
26283f6d0e1dSmrg# func_replace_sysroot PATH
26293f6d0e1dSmrg# If PATH begins with the sysroot, replace it with = and
26303f6d0e1dSmrg# store the result into func_replace_sysroot_result.
26313f6d0e1dSmrgfunc_replace_sysroot ()
26323f6d0e1dSmrg{
26332f60eb46Smrg  case $lt_sysroot:$1 in
26343f6d0e1dSmrg  ?*:"$lt_sysroot"*)
26353f6d0e1dSmrg    func_stripname "$lt_sysroot" '' "$1"
26362f60eb46Smrg    func_replace_sysroot_result='='$func_stripname_result
26373f6d0e1dSmrg    ;;
26383f6d0e1dSmrg  *)
26393f6d0e1dSmrg    # Including no sysroot.
26403f6d0e1dSmrg    func_replace_sysroot_result=$1
26413f6d0e1dSmrg    ;;
26423f6d0e1dSmrg  esac
26433f6d0e1dSmrg}
26443f6d0e1dSmrg
2645c3c9db83Smrg# func_infer_tag arg
2646c3c9db83Smrg# Infer tagged configuration to use if any are available and
2647c3c9db83Smrg# if one wasn't chosen via the "--tag" command line option.
2648c3c9db83Smrg# Only attempt this if the compiler in the base compile
2649c3c9db83Smrg# command doesn't match the default compiler.
2650c3c9db83Smrg# arg is usually of the form 'gcc ...'
2651c3c9db83Smrgfunc_infer_tag ()
2652c3c9db83Smrg{
26532f60eb46Smrg    $debug_cmd
26542f60eb46Smrg
2655c3c9db83Smrg    if test -n "$available_tags" && test -z "$tagname"; then
2656c3c9db83Smrg      CC_quoted=
2657c3c9db83Smrg      for arg in $CC; do
26583f6d0e1dSmrg	func_append_quoted CC_quoted "$arg"
2659c3c9db83Smrg      done
26603f6d0e1dSmrg      CC_expanded=`func_echo_all $CC`
26613f6d0e1dSmrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
2662c3c9db83Smrg      case $@ in
2663c3c9db83Smrg      # Blanks in the command may have been stripped by the calling shell,
2664c3c9db83Smrg      # but not from the CC environment variable when configure was run.
26653f6d0e1dSmrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
26663f6d0e1dSmrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
2667c3c9db83Smrg      # Blanks at the start of $base_compile will cause this to fail
2668c3c9db83Smrg      # if we don't check for them as well.
2669c3c9db83Smrg      *)
2670c3c9db83Smrg	for z in $available_tags; do
2671c3c9db83Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
2672c3c9db83Smrg	    # Evaluate the configuration.
26732f60eb46Smrg	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
2674c3c9db83Smrg	    CC_quoted=
2675c3c9db83Smrg	    for arg in $CC; do
2676c3c9db83Smrg	      # Double-quote args containing other shell metacharacters.
26773f6d0e1dSmrg	      func_append_quoted CC_quoted "$arg"
2678c3c9db83Smrg	    done
26793f6d0e1dSmrg	    CC_expanded=`func_echo_all $CC`
26803f6d0e1dSmrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
2681c3c9db83Smrg	    case "$@ " in
26823f6d0e1dSmrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
26833f6d0e1dSmrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
2684c3c9db83Smrg	      # The compiler in the base compile command matches
2685c3c9db83Smrg	      # the one in the tagged configuration.
2686c3c9db83Smrg	      # Assume this is the tagged configuration we want.
2687c3c9db83Smrg	      tagname=$z
2688c3c9db83Smrg	      break
2689c3c9db83Smrg	      ;;
2690c3c9db83Smrg	    esac
2691c3c9db83Smrg	  fi
2692c3c9db83Smrg	done
2693c3c9db83Smrg	# If $tagname still isn't set, then no tagged configuration
2694c3c9db83Smrg	# was found and let the user know that the "--tag" command
2695c3c9db83Smrg	# line option must be used.
2696c3c9db83Smrg	if test -z "$tagname"; then
2697c3c9db83Smrg	  func_echo "unable to infer tagged configuration"
26982f60eb46Smrg	  func_fatal_error "specify a tag with '--tag'"
2699c3c9db83Smrg#	else
2700c3c9db83Smrg#	  func_verbose "using $tagname tagged configuration"
2701c3c9db83Smrg	fi
2702c3c9db83Smrg	;;
2703c3c9db83Smrg      esac
2704c3c9db83Smrg    fi
2705c3c9db83Smrg}
2706c3c9db83Smrg
2707c3c9db83Smrg
2708c3c9db83Smrg
2709c3c9db83Smrg# func_write_libtool_object output_name pic_name nonpic_name
2710c3c9db83Smrg# Create a libtool object file (analogous to a ".la" file),
2711c3c9db83Smrg# but don't create it if we're doing a dry run.
2712c3c9db83Smrgfunc_write_libtool_object ()
2713c3c9db83Smrg{
27142f60eb46Smrg    write_libobj=$1
27152f60eb46Smrg    if test yes = "$build_libtool_libs"; then
27162f60eb46Smrg      write_lobj=\'$2\'
2717c3c9db83Smrg    else
2718c3c9db83Smrg      write_lobj=none
2719c3c9db83Smrg    fi
2720c3c9db83Smrg
27212f60eb46Smrg    if test yes = "$build_old_libs"; then
27222f60eb46Smrg      write_oldobj=\'$3\'
2723c3c9db83Smrg    else
2724c3c9db83Smrg      write_oldobj=none
2725c3c9db83Smrg    fi
2726c3c9db83Smrg
2727c3c9db83Smrg    $opt_dry_run || {
2728c3c9db83Smrg      cat >${write_libobj}T <<EOF
2729c3c9db83Smrg# $write_libobj - a libtool object file
27302f60eb46Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
2731c3c9db83Smrg#
2732c3c9db83Smrg# Please DO NOT delete this file!
2733c3c9db83Smrg# It is necessary for linking the library.
2734c3c9db83Smrg
2735c3c9db83Smrg# Name of the PIC object.
2736c3c9db83Smrgpic_object=$write_lobj
2737c3c9db83Smrg
2738c3c9db83Smrg# Name of the non-PIC object
2739c3c9db83Smrgnon_pic_object=$write_oldobj
2740c3c9db83Smrg
2741c3c9db83SmrgEOF
27422f60eb46Smrg      $MV "${write_libobj}T" "$write_libobj"
2743c3c9db83Smrg    }
2744c3c9db83Smrg}
2745c3c9db83Smrg
27463f6d0e1dSmrg
27473f6d0e1dSmrg##################################################
27483f6d0e1dSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
27493f6d0e1dSmrg##################################################
27503f6d0e1dSmrg
27513f6d0e1dSmrg# func_convert_core_file_wine_to_w32 ARG
27523f6d0e1dSmrg# Helper function used by file name conversion functions when $build is *nix,
27533f6d0e1dSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
27543f6d0e1dSmrg# correctly configured wine environment available, with the winepath program
27553f6d0e1dSmrg# in $build's $PATH.
27563f6d0e1dSmrg#
27573f6d0e1dSmrg# ARG is the $build file name to be converted to w32 format.
27583f6d0e1dSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
27593f6d0e1dSmrg# be empty on error (or when ARG is empty)
27603f6d0e1dSmrgfunc_convert_core_file_wine_to_w32 ()
27613f6d0e1dSmrg{
27622f60eb46Smrg  $debug_cmd
27632f60eb46Smrg
27642f60eb46Smrg  func_convert_core_file_wine_to_w32_result=$1
27653f6d0e1dSmrg  if test -n "$1"; then
27663f6d0e1dSmrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
27673f6d0e1dSmrg    # are forced to check the contents of stdout. On the other hand, if the
27683f6d0e1dSmrg    # command is not found, the shell will set an exit code of 127 and print
27693f6d0e1dSmrg    # *an error message* to stdout. So we must check for both error code of
27703f6d0e1dSmrg    # zero AND non-empty stdout, which explains the odd construction:
27713f6d0e1dSmrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
27722f60eb46Smrg    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
27733f6d0e1dSmrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
27742f60eb46Smrg        $SED -e "$sed_naive_backslashify"`
27753f6d0e1dSmrg    else
27763f6d0e1dSmrg      func_convert_core_file_wine_to_w32_result=
27773f6d0e1dSmrg    fi
27783f6d0e1dSmrg  fi
27793f6d0e1dSmrg}
27803f6d0e1dSmrg# end: func_convert_core_file_wine_to_w32
27813f6d0e1dSmrg
27823f6d0e1dSmrg
27833f6d0e1dSmrg# func_convert_core_path_wine_to_w32 ARG
27843f6d0e1dSmrg# Helper function used by path conversion functions when $build is *nix, and
27853f6d0e1dSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
27863f6d0e1dSmrg# configured wine environment available, with the winepath program in $build's
27873f6d0e1dSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
27883f6d0e1dSmrg#
27893f6d0e1dSmrg# ARG is path to be converted from $build format to win32.
27903f6d0e1dSmrg# Result is available in $func_convert_core_path_wine_to_w32_result.
27913f6d0e1dSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
27923f6d0e1dSmrg# are convertible, then the result may be empty.
27933f6d0e1dSmrgfunc_convert_core_path_wine_to_w32 ()
27943f6d0e1dSmrg{
27952f60eb46Smrg  $debug_cmd
27962f60eb46Smrg
27973f6d0e1dSmrg  # unfortunately, winepath doesn't convert paths, only file names
27982f60eb46Smrg  func_convert_core_path_wine_to_w32_result=
27993f6d0e1dSmrg  if test -n "$1"; then
28003f6d0e1dSmrg    oldIFS=$IFS
28013f6d0e1dSmrg    IFS=:
28023f6d0e1dSmrg    for func_convert_core_path_wine_to_w32_f in $1; do
28033f6d0e1dSmrg      IFS=$oldIFS
28043f6d0e1dSmrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
28052f60eb46Smrg      if test -n "$func_convert_core_file_wine_to_w32_result"; then
28063f6d0e1dSmrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
28072f60eb46Smrg          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
28083f6d0e1dSmrg        else
28093f6d0e1dSmrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
28103f6d0e1dSmrg        fi
28113f6d0e1dSmrg      fi
28123f6d0e1dSmrg    done
28133f6d0e1dSmrg    IFS=$oldIFS
28143f6d0e1dSmrg  fi
28153f6d0e1dSmrg}
28163f6d0e1dSmrg# end: func_convert_core_path_wine_to_w32
28173f6d0e1dSmrg
28183f6d0e1dSmrg
28193f6d0e1dSmrg# func_cygpath ARGS...
28203f6d0e1dSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
28213f6d0e1dSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
28223f6d0e1dSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
28233f6d0e1dSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
28243f6d0e1dSmrg# file name or path is assumed to be in w32 format, as previously converted
28253f6d0e1dSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
28263f6d0e1dSmrg# or path in func_cygpath_result (input file name or path is assumed to be in
28273f6d0e1dSmrg# Cygwin format). Returns an empty string on error.
28283f6d0e1dSmrg#
28293f6d0e1dSmrg# ARGS are passed to cygpath, with the last one being the file name or path to
28303f6d0e1dSmrg# be converted.
28313f6d0e1dSmrg#
28323f6d0e1dSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
28333f6d0e1dSmrg# environment variable; do not put it in $PATH.
28343f6d0e1dSmrgfunc_cygpath ()
28353f6d0e1dSmrg{
28362f60eb46Smrg  $debug_cmd
28372f60eb46Smrg
28383f6d0e1dSmrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
28393f6d0e1dSmrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
28403f6d0e1dSmrg    if test "$?" -ne 0; then
28413f6d0e1dSmrg      # on failure, ensure result is empty
28423f6d0e1dSmrg      func_cygpath_result=
28433f6d0e1dSmrg    fi
28443f6d0e1dSmrg  else
28453f6d0e1dSmrg    func_cygpath_result=
28462f60eb46Smrg    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
28473f6d0e1dSmrg  fi
28483f6d0e1dSmrg}
28493f6d0e1dSmrg#end: func_cygpath
28503f6d0e1dSmrg
28513f6d0e1dSmrg
28523f6d0e1dSmrg# func_convert_core_msys_to_w32 ARG
28533f6d0e1dSmrg# Convert file name or path ARG from MSYS format to w32 format.  Return
28543f6d0e1dSmrg# result in func_convert_core_msys_to_w32_result.
28553f6d0e1dSmrgfunc_convert_core_msys_to_w32 ()
28563f6d0e1dSmrg{
28572f60eb46Smrg  $debug_cmd
28582f60eb46Smrg
28593f6d0e1dSmrg  # awkward: cmd appends spaces to result
28603f6d0e1dSmrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
28612f60eb46Smrg    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
28623f6d0e1dSmrg}
28633f6d0e1dSmrg#end: func_convert_core_msys_to_w32
28643f6d0e1dSmrg
28653f6d0e1dSmrg
28663f6d0e1dSmrg# func_convert_file_check ARG1 ARG2
28673f6d0e1dSmrg# Verify that ARG1 (a file name in $build format) was converted to $host
28683f6d0e1dSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
28693f6d0e1dSmrg# func_to_host_file_result to ARG1).
28703f6d0e1dSmrgfunc_convert_file_check ()
28713f6d0e1dSmrg{
28722f60eb46Smrg  $debug_cmd
28732f60eb46Smrg
28742f60eb46Smrg  if test -z "$2" && test -n "$1"; then
28753f6d0e1dSmrg    func_error "Could not determine host file name corresponding to"
28762f60eb46Smrg    func_error "  '$1'"
28773f6d0e1dSmrg    func_error "Continuing, but uninstalled executables may not work."
28783f6d0e1dSmrg    # Fallback:
28792f60eb46Smrg    func_to_host_file_result=$1
28803f6d0e1dSmrg  fi
28813f6d0e1dSmrg}
28823f6d0e1dSmrg# end func_convert_file_check
28833f6d0e1dSmrg
28843f6d0e1dSmrg
28853f6d0e1dSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
28863f6d0e1dSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host
28873f6d0e1dSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
28883f6d0e1dSmrg# func_to_host_file_result to a simplistic fallback value (see below).
28893f6d0e1dSmrgfunc_convert_path_check ()
28903f6d0e1dSmrg{
28912f60eb46Smrg  $debug_cmd
28922f60eb46Smrg
28933f6d0e1dSmrg  if test -z "$4" && test -n "$3"; then
28943f6d0e1dSmrg    func_error "Could not determine the host path corresponding to"
28952f60eb46Smrg    func_error "  '$3'"
28963f6d0e1dSmrg    func_error "Continuing, but uninstalled executables may not work."
28973f6d0e1dSmrg    # Fallback.  This is a deliberately simplistic "conversion" and
28983f6d0e1dSmrg    # should not be "improved".  See libtool.info.
28993f6d0e1dSmrg    if test "x$1" != "x$2"; then
29003f6d0e1dSmrg      lt_replace_pathsep_chars="s|$1|$2|g"
29013f6d0e1dSmrg      func_to_host_path_result=`echo "$3" |
29023f6d0e1dSmrg        $SED -e "$lt_replace_pathsep_chars"`
29033f6d0e1dSmrg    else
29042f60eb46Smrg      func_to_host_path_result=$3
29053f6d0e1dSmrg    fi
29063f6d0e1dSmrg  fi
29073f6d0e1dSmrg}
29083f6d0e1dSmrg# end func_convert_path_check
29093f6d0e1dSmrg
29103f6d0e1dSmrg
29113f6d0e1dSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
29123f6d0e1dSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
29133f6d0e1dSmrg# and appending REPL if ORIG matches BACKPAT.
29143f6d0e1dSmrgfunc_convert_path_front_back_pathsep ()
29153f6d0e1dSmrg{
29162f60eb46Smrg  $debug_cmd
29172f60eb46Smrg
29183f6d0e1dSmrg  case $4 in
29192f60eb46Smrg  $1 ) func_to_host_path_result=$3$func_to_host_path_result
29203f6d0e1dSmrg    ;;
29213f6d0e1dSmrg  esac
29223f6d0e1dSmrg  case $4 in
29233f6d0e1dSmrg  $2 ) func_append func_to_host_path_result "$3"
29243f6d0e1dSmrg    ;;
29253f6d0e1dSmrg  esac
29263f6d0e1dSmrg}
29273f6d0e1dSmrg# end func_convert_path_front_back_pathsep
29283f6d0e1dSmrg
29293f6d0e1dSmrg
29303f6d0e1dSmrg##################################################
29313f6d0e1dSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
29323f6d0e1dSmrg##################################################
29332f60eb46Smrg# invoked via '$to_host_file_cmd ARG'
29343f6d0e1dSmrg#
29353f6d0e1dSmrg# In each case, ARG is the path to be converted from $build to $host format.
29363f6d0e1dSmrg# Result will be available in $func_to_host_file_result.
29373f6d0e1dSmrg
29383f6d0e1dSmrg
29393f6d0e1dSmrg# func_to_host_file ARG
29403f6d0e1dSmrg# Converts the file name ARG from $build format to $host format. Return result
29413f6d0e1dSmrg# in func_to_host_file_result.
29423f6d0e1dSmrgfunc_to_host_file ()
29433f6d0e1dSmrg{
29442f60eb46Smrg  $debug_cmd
29452f60eb46Smrg
29463f6d0e1dSmrg  $to_host_file_cmd "$1"
29473f6d0e1dSmrg}
29483f6d0e1dSmrg# end func_to_host_file
29493f6d0e1dSmrg
29503f6d0e1dSmrg
29513f6d0e1dSmrg# func_to_tool_file ARG LAZY
29523f6d0e1dSmrg# converts the file name ARG from $build format to toolchain format. Return
29533f6d0e1dSmrg# result in func_to_tool_file_result.  If the conversion in use is listed
29543f6d0e1dSmrg# in (the comma separated) LAZY, no conversion takes place.
29553f6d0e1dSmrgfunc_to_tool_file ()
29563f6d0e1dSmrg{
29572f60eb46Smrg  $debug_cmd
29582f60eb46Smrg
29593f6d0e1dSmrg  case ,$2, in
29603f6d0e1dSmrg    *,"$to_tool_file_cmd",*)
29613f6d0e1dSmrg      func_to_tool_file_result=$1
29623f6d0e1dSmrg      ;;
29633f6d0e1dSmrg    *)
29643f6d0e1dSmrg      $to_tool_file_cmd "$1"
29653f6d0e1dSmrg      func_to_tool_file_result=$func_to_host_file_result
29663f6d0e1dSmrg      ;;
29673f6d0e1dSmrg  esac
29683f6d0e1dSmrg}
29693f6d0e1dSmrg# end func_to_tool_file
29703f6d0e1dSmrg
29713f6d0e1dSmrg
29723f6d0e1dSmrg# func_convert_file_noop ARG
29733f6d0e1dSmrg# Copy ARG to func_to_host_file_result.
29743f6d0e1dSmrgfunc_convert_file_noop ()
29753f6d0e1dSmrg{
29762f60eb46Smrg  func_to_host_file_result=$1
29773f6d0e1dSmrg}
29783f6d0e1dSmrg# end func_convert_file_noop
29793f6d0e1dSmrg
29803f6d0e1dSmrg
29813f6d0e1dSmrg# func_convert_file_msys_to_w32 ARG
29823f6d0e1dSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
29833f6d0e1dSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
29843f6d0e1dSmrg# func_to_host_file_result.
29853f6d0e1dSmrgfunc_convert_file_msys_to_w32 ()
29863f6d0e1dSmrg{
29872f60eb46Smrg  $debug_cmd
29882f60eb46Smrg
29892f60eb46Smrg  func_to_host_file_result=$1
29903f6d0e1dSmrg  if test -n "$1"; then
29913f6d0e1dSmrg    func_convert_core_msys_to_w32 "$1"
29922f60eb46Smrg    func_to_host_file_result=$func_convert_core_msys_to_w32_result
29933f6d0e1dSmrg  fi
29943f6d0e1dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
29953f6d0e1dSmrg}
29963f6d0e1dSmrg# end func_convert_file_msys_to_w32
29973f6d0e1dSmrg
29983f6d0e1dSmrg
29993f6d0e1dSmrg# func_convert_file_cygwin_to_w32 ARG
30003f6d0e1dSmrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
30013f6d0e1dSmrg# func_to_host_file_result.
30023f6d0e1dSmrgfunc_convert_file_cygwin_to_w32 ()
30033f6d0e1dSmrg{
30042f60eb46Smrg  $debug_cmd
30052f60eb46Smrg
30062f60eb46Smrg  func_to_host_file_result=$1
30073f6d0e1dSmrg  if test -n "$1"; then
30083f6d0e1dSmrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
30093f6d0e1dSmrg    # LT_CYGPATH in this case.
30103f6d0e1dSmrg    func_to_host_file_result=`cygpath -m "$1"`
30113f6d0e1dSmrg  fi
30123f6d0e1dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
30133f6d0e1dSmrg}
30143f6d0e1dSmrg# end func_convert_file_cygwin_to_w32
30153f6d0e1dSmrg
30163f6d0e1dSmrg
30173f6d0e1dSmrg# func_convert_file_nix_to_w32 ARG
30183f6d0e1dSmrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
30193f6d0e1dSmrg# and a working winepath. Returns result in func_to_host_file_result.
30203f6d0e1dSmrgfunc_convert_file_nix_to_w32 ()
30213f6d0e1dSmrg{
30222f60eb46Smrg  $debug_cmd
30232f60eb46Smrg
30242f60eb46Smrg  func_to_host_file_result=$1
30253f6d0e1dSmrg  if test -n "$1"; then
30263f6d0e1dSmrg    func_convert_core_file_wine_to_w32 "$1"
30272f60eb46Smrg    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
30283f6d0e1dSmrg  fi
30293f6d0e1dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
30303f6d0e1dSmrg}
30313f6d0e1dSmrg# end func_convert_file_nix_to_w32
30323f6d0e1dSmrg
30333f6d0e1dSmrg
30343f6d0e1dSmrg# func_convert_file_msys_to_cygwin ARG
30353f6d0e1dSmrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
30363f6d0e1dSmrg# Returns result in func_to_host_file_result.
30373f6d0e1dSmrgfunc_convert_file_msys_to_cygwin ()
30383f6d0e1dSmrg{
30392f60eb46Smrg  $debug_cmd
30402f60eb46Smrg
30412f60eb46Smrg  func_to_host_file_result=$1
30423f6d0e1dSmrg  if test -n "$1"; then
30433f6d0e1dSmrg    func_convert_core_msys_to_w32 "$1"
30443f6d0e1dSmrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
30452f60eb46Smrg    func_to_host_file_result=$func_cygpath_result
30463f6d0e1dSmrg  fi
30473f6d0e1dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
30483f6d0e1dSmrg}
30493f6d0e1dSmrg# end func_convert_file_msys_to_cygwin
30503f6d0e1dSmrg
30513f6d0e1dSmrg
30523f6d0e1dSmrg# func_convert_file_nix_to_cygwin ARG
30533f6d0e1dSmrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
30543f6d0e1dSmrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
30553f6d0e1dSmrg# in func_to_host_file_result.
30563f6d0e1dSmrgfunc_convert_file_nix_to_cygwin ()
30573f6d0e1dSmrg{
30582f60eb46Smrg  $debug_cmd
30592f60eb46Smrg
30602f60eb46Smrg  func_to_host_file_result=$1
30613f6d0e1dSmrg  if test -n "$1"; then
30623f6d0e1dSmrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
30633f6d0e1dSmrg    func_convert_core_file_wine_to_w32 "$1"
30643f6d0e1dSmrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
30652f60eb46Smrg    func_to_host_file_result=$func_cygpath_result
30663f6d0e1dSmrg  fi
30673f6d0e1dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
30683f6d0e1dSmrg}
30693f6d0e1dSmrg# end func_convert_file_nix_to_cygwin
30703f6d0e1dSmrg
30713f6d0e1dSmrg
30723f6d0e1dSmrg#############################################
30733f6d0e1dSmrg# $build to $host PATH CONVERSION FUNCTIONS #
30743f6d0e1dSmrg#############################################
30752f60eb46Smrg# invoked via '$to_host_path_cmd ARG'
30763f6d0e1dSmrg#
30773f6d0e1dSmrg# In each case, ARG is the path to be converted from $build to $host format.
30783f6d0e1dSmrg# The result will be available in $func_to_host_path_result.
30793f6d0e1dSmrg#
30803f6d0e1dSmrg# Path separators are also converted from $build format to $host format.  If
30813f6d0e1dSmrg# ARG begins or ends with a path separator character, it is preserved (but
30823f6d0e1dSmrg# converted to $host format) on output.
30833f6d0e1dSmrg#
30843f6d0e1dSmrg# All path conversion functions are named using the following convention:
30853f6d0e1dSmrg#   file name conversion function    : func_convert_file_X_to_Y ()
30863f6d0e1dSmrg#   path conversion function         : func_convert_path_X_to_Y ()
30873f6d0e1dSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the
30883f6d0e1dSmrg# same.  If conversion functions are added for new $build/$host combinations,
30893f6d0e1dSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
30903f6d0e1dSmrg# will break.
30913f6d0e1dSmrg
30923f6d0e1dSmrg
30933f6d0e1dSmrg# func_init_to_host_path_cmd
30943f6d0e1dSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
30953f6d0e1dSmrg# appropriate value, based on the value of $to_host_file_cmd.
30963f6d0e1dSmrgto_host_path_cmd=
30973f6d0e1dSmrgfunc_init_to_host_path_cmd ()
30983f6d0e1dSmrg{
30992f60eb46Smrg  $debug_cmd
31002f60eb46Smrg
31013f6d0e1dSmrg  if test -z "$to_host_path_cmd"; then
31023f6d0e1dSmrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
31032f60eb46Smrg    to_host_path_cmd=func_convert_path_$func_stripname_result
31043f6d0e1dSmrg  fi
31053f6d0e1dSmrg}
31063f6d0e1dSmrg
31073f6d0e1dSmrg
31083f6d0e1dSmrg# func_to_host_path ARG
31093f6d0e1dSmrg# Converts the path ARG from $build format to $host format. Return result
31103f6d0e1dSmrg# in func_to_host_path_result.
31113f6d0e1dSmrgfunc_to_host_path ()
31123f6d0e1dSmrg{
31132f60eb46Smrg  $debug_cmd
31142f60eb46Smrg
31153f6d0e1dSmrg  func_init_to_host_path_cmd
31163f6d0e1dSmrg  $to_host_path_cmd "$1"
31173f6d0e1dSmrg}
31183f6d0e1dSmrg# end func_to_host_path
31193f6d0e1dSmrg
31203f6d0e1dSmrg
31213f6d0e1dSmrg# func_convert_path_noop ARG
31223f6d0e1dSmrg# Copy ARG to func_to_host_path_result.
31233f6d0e1dSmrgfunc_convert_path_noop ()
31243f6d0e1dSmrg{
31252f60eb46Smrg  func_to_host_path_result=$1
31263f6d0e1dSmrg}
31273f6d0e1dSmrg# end func_convert_path_noop
31283f6d0e1dSmrg
31293f6d0e1dSmrg
31303f6d0e1dSmrg# func_convert_path_msys_to_w32 ARG
31313f6d0e1dSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
31323f6d0e1dSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
31333f6d0e1dSmrg# func_to_host_path_result.
31343f6d0e1dSmrgfunc_convert_path_msys_to_w32 ()
31353f6d0e1dSmrg{
31362f60eb46Smrg  $debug_cmd
31372f60eb46Smrg
31382f60eb46Smrg  func_to_host_path_result=$1
31393f6d0e1dSmrg  if test -n "$1"; then
31403f6d0e1dSmrg    # Remove leading and trailing path separator characters from ARG.  MSYS
31413f6d0e1dSmrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
31423f6d0e1dSmrg    # and winepath ignores them completely.
31433f6d0e1dSmrg    func_stripname : : "$1"
31443f6d0e1dSmrg    func_to_host_path_tmp1=$func_stripname_result
31453f6d0e1dSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
31462f60eb46Smrg    func_to_host_path_result=$func_convert_core_msys_to_w32_result
31473f6d0e1dSmrg    func_convert_path_check : ";" \
31483f6d0e1dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
31493f6d0e1dSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
31503f6d0e1dSmrg  fi
31513f6d0e1dSmrg}
31523f6d0e1dSmrg# end func_convert_path_msys_to_w32
31533f6d0e1dSmrg
31543f6d0e1dSmrg
31553f6d0e1dSmrg# func_convert_path_cygwin_to_w32 ARG
31563f6d0e1dSmrg# Convert path ARG from Cygwin to w32 format.  Returns result in
31573f6d0e1dSmrg# func_to_host_file_result.
31583f6d0e1dSmrgfunc_convert_path_cygwin_to_w32 ()
31593f6d0e1dSmrg{
31602f60eb46Smrg  $debug_cmd
31612f60eb46Smrg
31622f60eb46Smrg  func_to_host_path_result=$1
31633f6d0e1dSmrg  if test -n "$1"; then
31643f6d0e1dSmrg    # See func_convert_path_msys_to_w32:
31653f6d0e1dSmrg    func_stripname : : "$1"
31663f6d0e1dSmrg    func_to_host_path_tmp1=$func_stripname_result
31673f6d0e1dSmrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
31683f6d0e1dSmrg    func_convert_path_check : ";" \
31693f6d0e1dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
31703f6d0e1dSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
31713f6d0e1dSmrg  fi
31723f6d0e1dSmrg}
31733f6d0e1dSmrg# end func_convert_path_cygwin_to_w32
31743f6d0e1dSmrg
31753f6d0e1dSmrg
31763f6d0e1dSmrg# func_convert_path_nix_to_w32 ARG
31773f6d0e1dSmrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
31783f6d0e1dSmrg# a working winepath.  Returns result in func_to_host_file_result.
31793f6d0e1dSmrgfunc_convert_path_nix_to_w32 ()
31803f6d0e1dSmrg{
31812f60eb46Smrg  $debug_cmd
31822f60eb46Smrg
31832f60eb46Smrg  func_to_host_path_result=$1
31843f6d0e1dSmrg  if test -n "$1"; then
31853f6d0e1dSmrg    # See func_convert_path_msys_to_w32:
31863f6d0e1dSmrg    func_stripname : : "$1"
31873f6d0e1dSmrg    func_to_host_path_tmp1=$func_stripname_result
31883f6d0e1dSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
31892f60eb46Smrg    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
31903f6d0e1dSmrg    func_convert_path_check : ";" \
31913f6d0e1dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
31923f6d0e1dSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
31933f6d0e1dSmrg  fi
31943f6d0e1dSmrg}
31953f6d0e1dSmrg# end func_convert_path_nix_to_w32
31963f6d0e1dSmrg
31973f6d0e1dSmrg
31983f6d0e1dSmrg# func_convert_path_msys_to_cygwin ARG
31993f6d0e1dSmrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
32003f6d0e1dSmrg# Returns result in func_to_host_file_result.
32013f6d0e1dSmrgfunc_convert_path_msys_to_cygwin ()
32023f6d0e1dSmrg{
32032f60eb46Smrg  $debug_cmd
32042f60eb46Smrg
32052f60eb46Smrg  func_to_host_path_result=$1
32063f6d0e1dSmrg  if test -n "$1"; then
32073f6d0e1dSmrg    # See func_convert_path_msys_to_w32:
32083f6d0e1dSmrg    func_stripname : : "$1"
32093f6d0e1dSmrg    func_to_host_path_tmp1=$func_stripname_result
32103f6d0e1dSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
32113f6d0e1dSmrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
32122f60eb46Smrg    func_to_host_path_result=$func_cygpath_result
32133f6d0e1dSmrg    func_convert_path_check : : \
32143f6d0e1dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
32153f6d0e1dSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
32163f6d0e1dSmrg  fi
32173f6d0e1dSmrg}
32183f6d0e1dSmrg# end func_convert_path_msys_to_cygwin
32193f6d0e1dSmrg
32203f6d0e1dSmrg
32213f6d0e1dSmrg# func_convert_path_nix_to_cygwin ARG
32223f6d0e1dSmrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
32233f6d0e1dSmrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
32243f6d0e1dSmrg# func_to_host_file_result.
32253f6d0e1dSmrgfunc_convert_path_nix_to_cygwin ()
32263f6d0e1dSmrg{
32272f60eb46Smrg  $debug_cmd
32282f60eb46Smrg
32292f60eb46Smrg  func_to_host_path_result=$1
32303f6d0e1dSmrg  if test -n "$1"; then
32313f6d0e1dSmrg    # Remove leading and trailing path separator characters from
32323f6d0e1dSmrg    # ARG. msys behavior is inconsistent here, cygpath turns them
32333f6d0e1dSmrg    # into '.;' and ';.', and winepath ignores them completely.
32343f6d0e1dSmrg    func_stripname : : "$1"
32353f6d0e1dSmrg    func_to_host_path_tmp1=$func_stripname_result
32363f6d0e1dSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
32373f6d0e1dSmrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
32382f60eb46Smrg    func_to_host_path_result=$func_cygpath_result
32393f6d0e1dSmrg    func_convert_path_check : : \
32403f6d0e1dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
32413f6d0e1dSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
32423f6d0e1dSmrg  fi
32433f6d0e1dSmrg}
32443f6d0e1dSmrg# end func_convert_path_nix_to_cygwin
32453f6d0e1dSmrg
32463f6d0e1dSmrg
32472f60eb46Smrg# func_dll_def_p FILE
32482f60eb46Smrg# True iff FILE is a Windows DLL '.def' file.
32492f60eb46Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4
32502f60eb46Smrgfunc_dll_def_p ()
32512f60eb46Smrg{
32522f60eb46Smrg  $debug_cmd
32532f60eb46Smrg
32542f60eb46Smrg  func_dll_def_p_tmp=`$SED -n \
32552f60eb46Smrg    -e 's/^[	 ]*//' \
32562f60eb46Smrg    -e '/^\(;.*\)*$/d' \
32572f60eb46Smrg    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
32582f60eb46Smrg    -e q \
32592f60eb46Smrg    "$1"`
32602f60eb46Smrg  test DEF = "$func_dll_def_p_tmp"
32612f60eb46Smrg}
32622f60eb46Smrg
32632f60eb46Smrg
3264c3c9db83Smrg# func_mode_compile arg...
3265c3c9db83Smrgfunc_mode_compile ()
3266c3c9db83Smrg{
32672f60eb46Smrg    $debug_cmd
32682f60eb46Smrg
3269c3c9db83Smrg    # Get the compilation command and the source file.
3270c3c9db83Smrg    base_compile=
32712f60eb46Smrg    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
3272c3c9db83Smrg    suppress_opt=yes
3273c3c9db83Smrg    suppress_output=
3274c3c9db83Smrg    arg_mode=normal
3275c3c9db83Smrg    libobj=
3276c3c9db83Smrg    later=
3277c3c9db83Smrg    pie_flag=
3278c3c9db83Smrg
3279c3c9db83Smrg    for arg
3280c3c9db83Smrg    do
3281c3c9db83Smrg      case $arg_mode in
3282c3c9db83Smrg      arg  )
3283c3c9db83Smrg	# do not "continue".  Instead, add this to base_compile
32842f60eb46Smrg	lastarg=$arg
3285c3c9db83Smrg	arg_mode=normal
3286c3c9db83Smrg	;;
3287c3c9db83Smrg
3288c3c9db83Smrg      target )
32892f60eb46Smrg	libobj=$arg
3290c3c9db83Smrg	arg_mode=normal
3291c3c9db83Smrg	continue
3292c3c9db83Smrg	;;
3293c3c9db83Smrg
3294c3c9db83Smrg      normal )
3295c3c9db83Smrg	# Accept any command-line options.
3296c3c9db83Smrg	case $arg in
3297c3c9db83Smrg	-o)
3298c3c9db83Smrg	  test -n "$libobj" && \
32992f60eb46Smrg	    func_fatal_error "you cannot specify '-o' more than once"
3300c3c9db83Smrg	  arg_mode=target
3301c3c9db83Smrg	  continue
3302c3c9db83Smrg	  ;;
3303c3c9db83Smrg
3304c3c9db83Smrg	-pie | -fpie | -fPIE)
33053f6d0e1dSmrg          func_append pie_flag " $arg"
3306c3c9db83Smrg	  continue
3307c3c9db83Smrg	  ;;
3308c3c9db83Smrg
3309c3c9db83Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
33103f6d0e1dSmrg	  func_append later " $arg"
3311c3c9db83Smrg	  continue
3312c3c9db83Smrg	  ;;
3313c3c9db83Smrg
3314c3c9db83Smrg	-no-suppress)
3315692f60a7Smrg	  suppress_opt=no
3316692f60a7Smrg	  continue
3317692f60a7Smrg	  ;;
3318692f60a7Smrg
3319692f60a7Smrg	-Xcompiler)
3320692f60a7Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
3321692f60a7Smrg	  continue      #  The current "srcfile" will either be retained or
3322692f60a7Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
3323692f60a7Smrg
3324692f60a7Smrg	-Wc,*)
3325c3c9db83Smrg	  func_stripname '-Wc,' '' "$arg"
3326c3c9db83Smrg	  args=$func_stripname_result
3327692f60a7Smrg	  lastarg=
33282f60eb46Smrg	  save_ifs=$IFS; IFS=,
3329c3c9db83Smrg	  for arg in $args; do
33302f60eb46Smrg	    IFS=$save_ifs
33313f6d0e1dSmrg	    func_append_quoted lastarg "$arg"
3332692f60a7Smrg	  done
33332f60eb46Smrg	  IFS=$save_ifs
3334c3c9db83Smrg	  func_stripname ' ' '' "$lastarg"
3335c3c9db83Smrg	  lastarg=$func_stripname_result
3336692f60a7Smrg
3337692f60a7Smrg	  # Add the arguments to base_compile.
33383f6d0e1dSmrg	  func_append base_compile " $lastarg"
3339692f60a7Smrg	  continue
3340692f60a7Smrg	  ;;
3341692f60a7Smrg
3342c3c9db83Smrg	*)
3343692f60a7Smrg	  # Accept the current argument as the source file.
3344692f60a7Smrg	  # The previous "srcfile" becomes the current argument.
3345692f60a7Smrg	  #
33462f60eb46Smrg	  lastarg=$srcfile
33472f60eb46Smrg	  srcfile=$arg
3348692f60a7Smrg	  ;;
3349692f60a7Smrg	esac  #  case $arg
3350692f60a7Smrg	;;
3351692f60a7Smrg      esac    #  case $arg_mode
3352692f60a7Smrg
3353692f60a7Smrg      # Aesthetically quote the previous argument.
33543f6d0e1dSmrg      func_append_quoted base_compile "$lastarg"
3355692f60a7Smrg    done # for arg
3356692f60a7Smrg
3357692f60a7Smrg    case $arg_mode in
3358692f60a7Smrg    arg)
3359c3c9db83Smrg      func_fatal_error "you must specify an argument for -Xcompile"
3360692f60a7Smrg      ;;
3361692f60a7Smrg    target)
33622f60eb46Smrg      func_fatal_error "you must specify a target with '-o'"
3363692f60a7Smrg      ;;
3364692f60a7Smrg    *)
3365692f60a7Smrg      # Get the name of the library object.
3366c3c9db83Smrg      test -z "$libobj" && {
3367c3c9db83Smrg	func_basename "$srcfile"
33682f60eb46Smrg	libobj=$func_basename_result
3369c3c9db83Smrg      }
3370692f60a7Smrg      ;;
3371692f60a7Smrg    esac
3372692f60a7Smrg
3373692f60a7Smrg    # Recognize several different file suffixes.
3374692f60a7Smrg    # If the user specifies -o file.o, it is replaced with file.lo
3375692f60a7Smrg    case $libobj in
3376c3c9db83Smrg    *.[cCFSifmso] | \
3377c3c9db83Smrg    *.ada | *.adb | *.ads | *.asm | \
3378c3c9db83Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
337995903e71Smrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
3380c3c9db83Smrg      func_xform "$libobj"
3381c3c9db83Smrg      libobj=$func_xform_result
3382c3c9db83Smrg      ;;
3383692f60a7Smrg    esac
3384692f60a7Smrg
3385692f60a7Smrg    case $libobj in
3386c3c9db83Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
3387692f60a7Smrg    *)
33882f60eb46Smrg      func_fatal_error "cannot determine name of library object from '$libobj'"
3389692f60a7Smrg      ;;
3390692f60a7Smrg    esac
3391692f60a7Smrg
3392692f60a7Smrg    func_infer_tag $base_compile
3393692f60a7Smrg
3394692f60a7Smrg    for arg in $later; do
3395692f60a7Smrg      case $arg in
3396c3c9db83Smrg      -shared)
33972f60eb46Smrg	test yes = "$build_libtool_libs" \
33982f60eb46Smrg	  || func_fatal_configuration "cannot build a shared library"
3399c3c9db83Smrg	build_old_libs=no
3400c3c9db83Smrg	continue
3401c3c9db83Smrg	;;
3402c3c9db83Smrg
3403692f60a7Smrg      -static)
3404c3c9db83Smrg	build_libtool_libs=no
3405692f60a7Smrg	build_old_libs=yes
3406692f60a7Smrg	continue
3407692f60a7Smrg	;;
3408692f60a7Smrg
3409692f60a7Smrg      -prefer-pic)
3410692f60a7Smrg	pic_mode=yes
3411692f60a7Smrg	continue
3412692f60a7Smrg	;;
3413692f60a7Smrg
3414692f60a7Smrg      -prefer-non-pic)
3415692f60a7Smrg	pic_mode=no
3416692f60a7Smrg	continue
3417692f60a7Smrg	;;
3418692f60a7Smrg      esac
3419692f60a7Smrg    done
3420692f60a7Smrg
3421c3c9db83Smrg    func_quote_for_eval "$libobj"
3422c3c9db83Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
3423c3c9db83Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
34242f60eb46Smrg      && func_warning "libobj name '$libobj' may not contain shell special characters."
3425c3c9db83Smrg    func_dirname_and_basename "$obj" "/" ""
34262f60eb46Smrg    objname=$func_basename_result
34272f60eb46Smrg    xdir=$func_dirname_result
34282f60eb46Smrg    lobj=$xdir$objdir/$objname
3429692f60a7Smrg
3430c3c9db83Smrg    test -z "$base_compile" && \
3431c3c9db83Smrg      func_fatal_help "you must specify a compilation command"
3432692f60a7Smrg
3433692f60a7Smrg    # Delete any leftover library objects.
34342f60eb46Smrg    if test yes = "$build_old_libs"; then
3435692f60a7Smrg      removelist="$obj $lobj $libobj ${libobj}T"
3436692f60a7Smrg    else
3437692f60a7Smrg      removelist="$lobj $libobj ${libobj}T"
3438692f60a7Smrg    fi
3439692f60a7Smrg
3440692f60a7Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
3441692f60a7Smrg    case $host_os in
3442c3c9db83Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
3443692f60a7Smrg      pic_mode=default
3444692f60a7Smrg      ;;
3445692f60a7Smrg    esac
34462f60eb46Smrg    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
3447692f60a7Smrg      # non-PIC code in shared libraries is not supported
3448692f60a7Smrg      pic_mode=default
3449692f60a7Smrg    fi
3450692f60a7Smrg
3451692f60a7Smrg    # Calculate the filename of the output object if compiler does
3452692f60a7Smrg    # not support -o with -c
34532f60eb46Smrg    if test no = "$compiler_c_o"; then
34542f60eb46Smrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
34552f60eb46Smrg      lockfile=$output_obj.lock
3456692f60a7Smrg    else
3457692f60a7Smrg      output_obj=
3458692f60a7Smrg      need_locks=no
3459692f60a7Smrg      lockfile=
3460692f60a7Smrg    fi
3461692f60a7Smrg
3462692f60a7Smrg    # Lock this critical section if it is needed
3463692f60a7Smrg    # We use this script file to make the link, it avoids creating a new file
34642f60eb46Smrg    if test yes = "$need_locks"; then
3465c3c9db83Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3466c3c9db83Smrg	func_echo "Waiting for $lockfile to be removed"
3467692f60a7Smrg	sleep 2
3468692f60a7Smrg      done
34692f60eb46Smrg    elif test warn = "$need_locks"; then
3470692f60a7Smrg      if test -f "$lockfile"; then
3471c3c9db83Smrg	$ECHO "\
3472692f60a7Smrg*** ERROR, $lockfile exists and contains:
3473692f60a7Smrg`cat $lockfile 2>/dev/null`
3474692f60a7Smrg
3475692f60a7SmrgThis indicates that another process is trying to use the same
3476692f60a7Smrgtemporary object file, and libtool could not work around it because
34772f60eb46Smrgyour compiler does not support '-c' and '-o' together.  If you
3478692f60a7Smrgrepeat this compilation, it may succeed, by chance, but you had better
3479692f60a7Smrgavoid parallel builds (make -j) in this platform, or get a better
3480692f60a7Smrgcompiler."
3481692f60a7Smrg
3482c3c9db83Smrg	$opt_dry_run || $RM $removelist
3483692f60a7Smrg	exit $EXIT_FAILURE
3484692f60a7Smrg      fi
34853f6d0e1dSmrg      func_append removelist " $output_obj"
3486c3c9db83Smrg      $ECHO "$srcfile" > "$lockfile"
3487692f60a7Smrg    fi
3488692f60a7Smrg
3489c3c9db83Smrg    $opt_dry_run || $RM $removelist
34903f6d0e1dSmrg    func_append removelist " $lockfile"
3491c3c9db83Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
3492c3c9db83Smrg
34933f6d0e1dSmrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
34943f6d0e1dSmrg    srcfile=$func_to_tool_file_result
3495c3c9db83Smrg    func_quote_for_eval "$srcfile"
3496c3c9db83Smrg    qsrcfile=$func_quote_for_eval_result
3497692f60a7Smrg
3498692f60a7Smrg    # Only build a PIC object if we are building libtool libraries.
34992f60eb46Smrg    if test yes = "$build_libtool_libs"; then
3500692f60a7Smrg      # Without this assignment, base_compile gets emptied.
3501692f60a7Smrg      fbsd_hideous_sh_bug=$base_compile
3502692f60a7Smrg
35032f60eb46Smrg      if test no != "$pic_mode"; then
3504692f60a7Smrg	command="$base_compile $qsrcfile $pic_flag"
3505692f60a7Smrg      else
3506692f60a7Smrg	# Don't build PIC code
3507692f60a7Smrg	command="$base_compile $qsrcfile"
3508692f60a7Smrg      fi
3509692f60a7Smrg
3510c3c9db83Smrg      func_mkdir_p "$xdir$objdir"
3511692f60a7Smrg
3512692f60a7Smrg      if test -z "$output_obj"; then
3513692f60a7Smrg	# Place PIC objects in $objdir
35143f6d0e1dSmrg	func_append command " -o $lobj"
3515692f60a7Smrg      fi
3516692f60a7Smrg
3517c3c9db83Smrg      func_show_eval_locale "$command"	\
3518c3c9db83Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
3519692f60a7Smrg
35202f60eb46Smrg      if test warn = "$need_locks" &&
3521692f60a7Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3522c3c9db83Smrg	$ECHO "\
3523692f60a7Smrg*** ERROR, $lockfile contains:
3524692f60a7Smrg`cat $lockfile 2>/dev/null`
3525692f60a7Smrg
3526692f60a7Smrgbut it should contain:
3527692f60a7Smrg$srcfile
3528692f60a7Smrg
3529692f60a7SmrgThis indicates that another process is trying to use the same
3530692f60a7Smrgtemporary object file, and libtool could not work around it because
35312f60eb46Smrgyour compiler does not support '-c' and '-o' together.  If you
3532692f60a7Smrgrepeat this compilation, it may succeed, by chance, but you had better
3533692f60a7Smrgavoid parallel builds (make -j) in this platform, or get a better
3534692f60a7Smrgcompiler."
3535692f60a7Smrg
3536c3c9db83Smrg	$opt_dry_run || $RM $removelist
3537692f60a7Smrg	exit $EXIT_FAILURE
3538692f60a7Smrg      fi
3539692f60a7Smrg
3540692f60a7Smrg      # Just move the object if needed, then go on to compile the next one
3541692f60a7Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
3542c3c9db83Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
3543c3c9db83Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3544692f60a7Smrg      fi
3545692f60a7Smrg
3546692f60a7Smrg      # Allow error messages only from the first compilation.
35472f60eb46Smrg      if test yes = "$suppress_opt"; then
3548c3c9db83Smrg	suppress_output=' >/dev/null 2>&1'
3549692f60a7Smrg      fi
3550692f60a7Smrg    fi
3551692f60a7Smrg
3552692f60a7Smrg    # Only build a position-dependent object if we build old libraries.
35532f60eb46Smrg    if test yes = "$build_old_libs"; then
35542f60eb46Smrg      if test yes != "$pic_mode"; then
3555692f60a7Smrg	# Don't build PIC code
3556c3c9db83Smrg	command="$base_compile $qsrcfile$pie_flag"
3557692f60a7Smrg      else
3558692f60a7Smrg	command="$base_compile $qsrcfile $pic_flag"
3559692f60a7Smrg      fi
35602f60eb46Smrg      if test yes = "$compiler_c_o"; then
35613f6d0e1dSmrg	func_append command " -o $obj"
3562692f60a7Smrg      fi
3563692f60a7Smrg
3564692f60a7Smrg      # Suppress compiler output if we already did a PIC compilation.
35653f6d0e1dSmrg      func_append command "$suppress_output"
3566c3c9db83Smrg      func_show_eval_locale "$command" \
3567c3c9db83Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
3568692f60a7Smrg
35692f60eb46Smrg      if test warn = "$need_locks" &&
3570692f60a7Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3571c3c9db83Smrg	$ECHO "\
3572692f60a7Smrg*** ERROR, $lockfile contains:
3573692f60a7Smrg`cat $lockfile 2>/dev/null`
3574692f60a7Smrg
3575692f60a7Smrgbut it should contain:
3576692f60a7Smrg$srcfile
3577692f60a7Smrg
3578692f60a7SmrgThis indicates that another process is trying to use the same
3579692f60a7Smrgtemporary object file, and libtool could not work around it because
35802f60eb46Smrgyour compiler does not support '-c' and '-o' together.  If you
3581692f60a7Smrgrepeat this compilation, it may succeed, by chance, but you had better
3582692f60a7Smrgavoid parallel builds (make -j) in this platform, or get a better
3583692f60a7Smrgcompiler."
3584692f60a7Smrg
3585c3c9db83Smrg	$opt_dry_run || $RM $removelist
3586692f60a7Smrg	exit $EXIT_FAILURE
3587692f60a7Smrg      fi
3588692f60a7Smrg
3589692f60a7Smrg      # Just move the object if needed
3590692f60a7Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
3591c3c9db83Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
3592c3c9db83Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3593692f60a7Smrg      fi
3594692f60a7Smrg    fi
3595692f60a7Smrg
3596c3c9db83Smrg    $opt_dry_run || {
3597c3c9db83Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
3598692f60a7Smrg
3599c3c9db83Smrg      # Unlock the critical section if it was locked
36002f60eb46Smrg      if test no != "$need_locks"; then
3601c3c9db83Smrg	removelist=$lockfile
3602c3c9db83Smrg        $RM "$lockfile"
3603c3c9db83Smrg      fi
3604c3c9db83Smrg    }
3605692f60a7Smrg
3606692f60a7Smrg    exit $EXIT_SUCCESS
3607c3c9db83Smrg}
3608692f60a7Smrg
3609c3c9db83Smrg$opt_help || {
36102f60eb46Smrg  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
3611c3c9db83Smrg}
3612692f60a7Smrg
3613c3c9db83Smrgfunc_mode_help ()
3614c3c9db83Smrg{
3615c3c9db83Smrg    # We need to display help for each of the modes.
36163f6d0e1dSmrg    case $opt_mode in
3617c3c9db83Smrg      "")
3618c3c9db83Smrg        # Generic help is extracted from the usage comments
3619c3c9db83Smrg        # at the start of this file.
3620c3c9db83Smrg        func_help
3621c3c9db83Smrg        ;;
3622692f60a7Smrg
3623c3c9db83Smrg      clean)
3624c3c9db83Smrg        $ECHO \
3625c3c9db83Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
3626692f60a7Smrg
3627c3c9db83SmrgRemove files from the build directory.
3628692f60a7Smrg
3629c3c9db83SmrgRM is the name of the program to use to delete files associated with each FILE
36302f60eb46Smrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
3631c3c9db83Smrgto RM.
3632692f60a7Smrg
3633c3c9db83SmrgIf FILE is a libtool library, object or program, all the files associated
3634c3c9db83Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
3635c3c9db83Smrg        ;;
3636692f60a7Smrg
3637c3c9db83Smrg      compile)
3638c3c9db83Smrg      $ECHO \
3639c3c9db83Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
3640692f60a7Smrg
3641c3c9db83SmrgCompile a source file into a libtool library object.
3642692f60a7Smrg
3643c3c9db83SmrgThis mode accepts the following additional options:
3644692f60a7Smrg
3645c3c9db83Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
3646c3c9db83Smrg  -no-suppress      do not suppress compiler output for multiple passes
36473f6d0e1dSmrg  -prefer-pic       try to build PIC objects only
36483f6d0e1dSmrg  -prefer-non-pic   try to build non-PIC objects only
36492f60eb46Smrg  -shared           do not build a '.o' file suitable for static linking
36502f60eb46Smrg  -static           only build a '.o' file suitable for static linking
36513f6d0e1dSmrg  -Wc,FLAG          pass FLAG directly to the compiler
3652692f60a7Smrg
36532f60eb46SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file
3654c3c9db83Smrgfrom the given SOURCEFILE.
3655692f60a7Smrg
3656c3c9db83SmrgThe output file name is determined by removing the directory component from
36572f60eb46SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the
36582f60eb46Smrglibrary object suffix, '.lo'."
3659c3c9db83Smrg        ;;
3660692f60a7Smrg
3661c3c9db83Smrg      execute)
3662c3c9db83Smrg        $ECHO \
3663c3c9db83Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
3664692f60a7Smrg
3665c3c9db83SmrgAutomatically set library path, then run a program.
3666692f60a7Smrg
3667c3c9db83SmrgThis mode accepts the following additional options:
3668692f60a7Smrg
3669c3c9db83Smrg  -dlopen FILE      add the directory containing FILE to the library path
3670692f60a7Smrg
36712f60eb46SmrgThis mode sets the library path environment variable according to '-dlopen'
3672c3c9db83Smrgflags.
3673692f60a7Smrg
3674c3c9db83SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
3675c3c9db83Smrginto their corresponding uninstalled binary, and any of their required library
3676c3c9db83Smrgdirectories are added to the library path.
3677692f60a7Smrg
3678c3c9db83SmrgThen, COMMAND is executed, with ARGS as arguments."
3679c3c9db83Smrg        ;;
3680692f60a7Smrg
3681c3c9db83Smrg      finish)
3682c3c9db83Smrg        $ECHO \
3683c3c9db83Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
3684692f60a7Smrg
3685c3c9db83SmrgComplete the installation of libtool libraries.
3686692f60a7Smrg
3687c3c9db83SmrgEach LIBDIR is a directory that contains libtool libraries.
3688692f60a7Smrg
3689c3c9db83SmrgThe commands that this mode executes may require superuser privileges.  Use
36902f60eb46Smrgthe '--dry-run' option if you just want to see what would be executed."
3691c3c9db83Smrg        ;;
3692692f60a7Smrg
3693c3c9db83Smrg      install)
3694c3c9db83Smrg        $ECHO \
3695c3c9db83Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
3696692f60a7Smrg
3697c3c9db83SmrgInstall executables or libraries.
3698692f60a7Smrg
3699c3c9db83SmrgINSTALL-COMMAND is the installation command.  The first component should be
37002f60eb46Smrgeither the 'install' or 'cp' program.
3701692f60a7Smrg
3702c3c9db83SmrgThe following components of INSTALL-COMMAND are treated specially:
3703692f60a7Smrg
37043f6d0e1dSmrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
3705692f60a7Smrg
3706c3c9db83SmrgThe rest of the components are interpreted as arguments to that command (only
3707c3c9db83SmrgBSD-compatible install options are recognized)."
3708c3c9db83Smrg        ;;
3709692f60a7Smrg
3710c3c9db83Smrg      link)
3711c3c9db83Smrg        $ECHO \
3712c3c9db83Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
3713692f60a7Smrg
3714c3c9db83SmrgLink object files or libraries together to form another library, or to
3715c3c9db83Smrgcreate an executable program.
3716692f60a7Smrg
3717c3c9db83SmrgLINK-COMMAND is a command using the C compiler that you would use to create
3718c3c9db83Smrga program from several object files.
3719692f60a7Smrg
3720c3c9db83SmrgThe following components of LINK-COMMAND are treated specially:
3721692f60a7Smrg
3722c3c9db83Smrg  -all-static       do not do any dynamic linking at all
3723c3c9db83Smrg  -avoid-version    do not add a version suffix if possible
37243f6d0e1dSmrg  -bindir BINDIR    specify path to binaries directory (for systems where
37253f6d0e1dSmrg                    libraries must be found in the PATH setting at runtime)
37262f60eb46Smrg  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
3727c3c9db83Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
3728c3c9db83Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
3729c3c9db83Smrg  -export-symbols SYMFILE
3730c3c9db83Smrg                    try to export only the symbols listed in SYMFILE
3731c3c9db83Smrg  -export-symbols-regex REGEX
3732c3c9db83Smrg                    try to export only the symbols matching REGEX
3733c3c9db83Smrg  -LLIBDIR          search LIBDIR for required installed libraries
3734c3c9db83Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
3735c3c9db83Smrg  -module           build a library that can dlopened
3736c3c9db83Smrg  -no-fast-install  disable the fast-install mode
3737c3c9db83Smrg  -no-install       link a not-installable executable
3738c3c9db83Smrg  -no-undefined     declare that a library does not refer to external symbols
3739c3c9db83Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
37402f60eb46Smrg  -objectlist FILE  use a list of object files found in FILE to specify objects
37412f60eb46Smrg  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
3742c3c9db83Smrg  -precious-files-regex REGEX
3743c3c9db83Smrg                    don't remove output files matching REGEX
3744c3c9db83Smrg  -release RELEASE  specify package release information
3745c3c9db83Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
3746c3c9db83Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
3747c3c9db83Smrg  -shared           only do dynamic linking of libtool libraries
3748c3c9db83Smrg  -shrext SUFFIX    override the standard shared library file extension
3749c3c9db83Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
3750c3c9db83Smrg  -static-libtool-libs
3751c3c9db83Smrg                    do not do any dynamic linking of libtool libraries
3752c3c9db83Smrg  -version-info CURRENT[:REVISION[:AGE]]
3753c3c9db83Smrg                    specify library version info [each variable defaults to 0]
3754c3c9db83Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
37553f6d0e1dSmrg  -Wc,FLAG
37563f6d0e1dSmrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
37573f6d0e1dSmrg  -Wl,FLAG
37583f6d0e1dSmrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
37593f6d0e1dSmrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
3760692f60a7Smrg
37612f60eb46SmrgAll other options (arguments beginning with '-') are ignored.
3762692f60a7Smrg
37632f60eb46SmrgEvery other argument is treated as a filename.  Files ending in '.la' are
3764c3c9db83Smrgtreated as uninstalled libtool libraries, other files are standard or library
3765c3c9db83Smrgobject files.
3766692f60a7Smrg
37672f60eb46SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created,
37682f60eb46Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is
3769c3c9db83Smrgrequired, except when creating a convenience library.
3770692f60a7Smrg
37712f60eb46SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
37722f60eb46Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'.
3773692f60a7Smrg
37742f60eb46SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
3775c3c9db83Smrgis created, otherwise an executable program is created."
37762e71ea71Smrg        ;;
3777692f60a7Smrg
3778c3c9db83Smrg      uninstall)
3779c3c9db83Smrg        $ECHO \
3780c3c9db83Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
3781692f60a7Smrg
3782c3c9db83SmrgRemove libraries from an installation directory.
3783692f60a7Smrg
3784c3c9db83SmrgRM is the name of the program to use to delete files associated with each FILE
37852f60eb46Smrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
3786c3c9db83Smrgto RM.
378785ee4c00Smrg
3788c3c9db83SmrgIf FILE is a libtool library, all the files associated with it are deleted.
3789c3c9db83SmrgOtherwise, only FILE itself is deleted using RM."
3790c3c9db83Smrg        ;;
379185ee4c00Smrg
3792c3c9db83Smrg      *)
37932f60eb46Smrg        func_fatal_help "invalid operation mode '$opt_mode'"
3794c3c9db83Smrg        ;;
3795c3c9db83Smrg    esac
379685ee4c00Smrg
37973f6d0e1dSmrg    echo
37982f60eb46Smrg    $ECHO "Try '$progname --help' for more information about other modes."
3799c3c9db83Smrg}
380085ee4c00Smrg
38013f6d0e1dSmrg# Now that we've collected a possible --mode arg, show help if necessary
38023f6d0e1dSmrgif $opt_help; then
38032f60eb46Smrg  if test : = "$opt_help"; then
38043f6d0e1dSmrg    func_mode_help
38053f6d0e1dSmrg  else
38063f6d0e1dSmrg    {
38073f6d0e1dSmrg      func_help noexit
38083f6d0e1dSmrg      for opt_mode in compile link execute install finish uninstall clean; do
38093f6d0e1dSmrg	func_mode_help
38103f6d0e1dSmrg      done
38112f60eb46Smrg    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
38123f6d0e1dSmrg    {
38133f6d0e1dSmrg      func_help noexit
38143f6d0e1dSmrg      for opt_mode in compile link execute install finish uninstall clean; do
38153f6d0e1dSmrg	echo
38163f6d0e1dSmrg	func_mode_help
38173f6d0e1dSmrg      done
38183f6d0e1dSmrg    } |
38192f60eb46Smrg    $SED '1d
38203f6d0e1dSmrg      /^When reporting/,/^Report/{
38213f6d0e1dSmrg	H
38223f6d0e1dSmrg	d
38233f6d0e1dSmrg      }
38243f6d0e1dSmrg      $x
38253f6d0e1dSmrg      /information about other modes/d
38263f6d0e1dSmrg      /more detailed .*MODE/d
38273f6d0e1dSmrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
38283f6d0e1dSmrg  fi
38293f6d0e1dSmrg  exit $?
38303f6d0e1dSmrgfi
383185ee4c00Smrg
383285ee4c00Smrg
3833c3c9db83Smrg# func_mode_execute arg...
3834c3c9db83Smrgfunc_mode_execute ()
3835c3c9db83Smrg{
38362f60eb46Smrg    $debug_cmd
38372f60eb46Smrg
3838c3c9db83Smrg    # The first argument is the command name.
38392f60eb46Smrg    cmd=$nonopt
3840c3c9db83Smrg    test -z "$cmd" && \
3841c3c9db83Smrg      func_fatal_help "you must specify a COMMAND"
38422e71ea71Smrg
3843c3c9db83Smrg    # Handle -dlopen flags immediately.
38443f6d0e1dSmrg    for file in $opt_dlopen; do
3845c3c9db83Smrg      test -f "$file" \
38462f60eb46Smrg	|| func_fatal_help "'$file' is not a file"
38472e71ea71Smrg
3848c3c9db83Smrg      dir=
3849c3c9db83Smrg      case $file in
3850c3c9db83Smrg      *.la)
38513f6d0e1dSmrg	func_resolve_sysroot "$file"
38523f6d0e1dSmrg	file=$func_resolve_sysroot_result
38533f6d0e1dSmrg
3854c3c9db83Smrg	# Check to see that this really is a libtool archive.
3855c3c9db83Smrg	func_lalib_unsafe_p "$file" \
38562f60eb46Smrg	  || func_fatal_help "'$lib' is not a valid libtool archive"
38572e71ea71Smrg
3858c3c9db83Smrg	# Read the libtool library.
3859c3c9db83Smrg	dlname=
3860c3c9db83Smrg	library_names=
3861c3c9db83Smrg	func_source "$file"
3862692f60a7Smrg
3863c3c9db83Smrg	# Skip this library if it cannot be dlopened.
3864c3c9db83Smrg	if test -z "$dlname"; then
3865c3c9db83Smrg	  # Warn if it was a shared library.
3866c3c9db83Smrg	  test -n "$library_names" && \
38672f60eb46Smrg	    func_warning "'$file' was not linked with '-export-dynamic'"
3868c3c9db83Smrg	  continue
3869c3c9db83Smrg	fi
3870692f60a7Smrg
3871c3c9db83Smrg	func_dirname "$file" "" "."
38722f60eb46Smrg	dir=$func_dirname_result
3873692f60a7Smrg
3874c3c9db83Smrg	if test -f "$dir/$objdir/$dlname"; then
38753f6d0e1dSmrg	  func_append dir "/$objdir"
3876c3c9db83Smrg	else
3877c3c9db83Smrg	  if test ! -f "$dir/$dlname"; then
38782f60eb46Smrg	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
3879c3c9db83Smrg	  fi
3880c3c9db83Smrg	fi
38812e71ea71Smrg	;;
3882692f60a7Smrg
3883c3c9db83Smrg      *.lo)
3884c3c9db83Smrg	# Just add the directory containing the .lo file.
3885c3c9db83Smrg	func_dirname "$file" "" "."
38862f60eb46Smrg	dir=$func_dirname_result
38872e71ea71Smrg	;;
3888692f60a7Smrg
3889c3c9db83Smrg      *)
38902f60eb46Smrg	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
38912e71ea71Smrg	continue
38922e71ea71Smrg	;;
3893c3c9db83Smrg      esac
3894692f60a7Smrg
3895c3c9db83Smrg      # Get the absolute pathname.
3896c3c9db83Smrg      absdir=`cd "$dir" && pwd`
38972f60eb46Smrg      test -n "$absdir" && dir=$absdir
389885ee4c00Smrg
3899c3c9db83Smrg      # Now add the directory to shlibpath_var.
3900c3c9db83Smrg      if eval "test -z \"\$$shlibpath_var\""; then
3901c3c9db83Smrg	eval "$shlibpath_var=\"\$dir\""
3902c3c9db83Smrg      else
3903c3c9db83Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
3904c3c9db83Smrg      fi
3905c3c9db83Smrg    done
390685ee4c00Smrg
3907c3c9db83Smrg    # This variable tells wrapper scripts just to set shlibpath_var
3908c3c9db83Smrg    # rather than running their programs.
39092f60eb46Smrg    libtool_execute_magic=$magic
391085ee4c00Smrg
3911c3c9db83Smrg    # Check if any of the arguments is a wrapper script.
3912c3c9db83Smrg    args=
3913c3c9db83Smrg    for file
3914c3c9db83Smrg    do
3915c3c9db83Smrg      case $file in
39163f6d0e1dSmrg      -* | *.la | *.lo ) ;;
3917c3c9db83Smrg      *)
3918c3c9db83Smrg	# Do a test to see if this is really a libtool program.
3919c3c9db83Smrg	if func_ltwrapper_script_p "$file"; then
3920c3c9db83Smrg	  func_source "$file"
3921c3c9db83Smrg	  # Transform arg to wrapped name.
39222f60eb46Smrg	  file=$progdir/$program
3923c3c9db83Smrg	elif func_ltwrapper_executable_p "$file"; then
3924c3c9db83Smrg	  func_ltwrapper_scriptname "$file"
3925c3c9db83Smrg	  func_source "$func_ltwrapper_scriptname_result"
3926c3c9db83Smrg	  # Transform arg to wrapped name.
39272f60eb46Smrg	  file=$progdir/$program
3928c3c9db83Smrg	fi
3929c3c9db83Smrg	;;
3930c3c9db83Smrg      esac
3931c3c9db83Smrg      # Quote arguments (to preserve shell metacharacters).
39323f6d0e1dSmrg      func_append_quoted args "$file"
3933c3c9db83Smrg    done
393485ee4c00Smrg
39352f60eb46Smrg    if $opt_dry_run; then
39362f60eb46Smrg      # Display what would be done.
39372f60eb46Smrg      if test -n "$shlibpath_var"; then
39382f60eb46Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
39392f60eb46Smrg	echo "export $shlibpath_var"
39402f60eb46Smrg      fi
39412f60eb46Smrg      $ECHO "$cmd$args"
39422f60eb46Smrg      exit $EXIT_SUCCESS
39432f60eb46Smrg    else
3944c3c9db83Smrg      if test -n "$shlibpath_var"; then
3945c3c9db83Smrg	# Export the shlibpath_var.
3946c3c9db83Smrg	eval "export $shlibpath_var"
3947c3c9db83Smrg      fi
394885ee4c00Smrg
3949c3c9db83Smrg      # Restore saved environment variables
3950c3c9db83Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
3951c3c9db83Smrg      do
3952c3c9db83Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
3953c3c9db83Smrg                $lt_var=\$save_$lt_var; export $lt_var
39542e71ea71Smrg	      else
3955c3c9db83Smrg		$lt_unset $lt_var
3956c3c9db83Smrg	      fi"
3957c3c9db83Smrg      done
395885ee4c00Smrg
3959c3c9db83Smrg      # Now prepare to actually exec the command.
39602f60eb46Smrg      exec_cmd=\$cmd$args
3961c3c9db83Smrg    fi
3962c3c9db83Smrg}
396385ee4c00Smrg
39642f60eb46Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"}
396585ee4c00Smrg
39662e71ea71Smrg
3967c3c9db83Smrg# func_mode_finish arg...
3968c3c9db83Smrgfunc_mode_finish ()
3969c3c9db83Smrg{
39702f60eb46Smrg    $debug_cmd
39712f60eb46Smrg
39723f6d0e1dSmrg    libs=
39733f6d0e1dSmrg    libdirs=
3974c3c9db83Smrg    admincmds=
3975692f60a7Smrg
39763f6d0e1dSmrg    for opt in "$nonopt" ${1+"$@"}
39773f6d0e1dSmrg    do
39783f6d0e1dSmrg      if test -d "$opt"; then
39793f6d0e1dSmrg	func_append libdirs " $opt"
39803f6d0e1dSmrg
39813f6d0e1dSmrg      elif test -f "$opt"; then
39823f6d0e1dSmrg	if func_lalib_unsafe_p "$opt"; then
39833f6d0e1dSmrg	  func_append libs " $opt"
39843f6d0e1dSmrg	else
39852f60eb46Smrg	  func_warning "'$opt' is not a valid libtool archive"
39863f6d0e1dSmrg	fi
39873f6d0e1dSmrg
39883f6d0e1dSmrg      else
39892f60eb46Smrg	func_fatal_error "invalid argument '$opt'"
39903f6d0e1dSmrg      fi
39913f6d0e1dSmrg    done
39923f6d0e1dSmrg
39933f6d0e1dSmrg    if test -n "$libs"; then
39943f6d0e1dSmrg      if test -n "$lt_sysroot"; then
39953f6d0e1dSmrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
39963f6d0e1dSmrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
39973f6d0e1dSmrg      else
39983f6d0e1dSmrg        sysroot_cmd=
39993f6d0e1dSmrg      fi
40003f6d0e1dSmrg
40013f6d0e1dSmrg      # Remove sysroot references
40023f6d0e1dSmrg      if $opt_dry_run; then
40033f6d0e1dSmrg        for lib in $libs; do
40042f60eb46Smrg          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
40053f6d0e1dSmrg        done
40063f6d0e1dSmrg      else
40073f6d0e1dSmrg        tmpdir=`func_mktempdir`
40083f6d0e1dSmrg        for lib in $libs; do
40092f60eb46Smrg	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
40103f6d0e1dSmrg	    > $tmpdir/tmp-la
40113f6d0e1dSmrg	  mv -f $tmpdir/tmp-la $lib
40123f6d0e1dSmrg	done
40133f6d0e1dSmrg        ${RM}r "$tmpdir"
40143f6d0e1dSmrg      fi
40153f6d0e1dSmrg    fi
4016692f60a7Smrg
40173f6d0e1dSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4018c3c9db83Smrg      for libdir in $libdirs; do
4019c3c9db83Smrg	if test -n "$finish_cmds"; then
4020c3c9db83Smrg	  # Do each command in the finish commands.
4021c3c9db83Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
4022c3c9db83Smrg'"$cmd"'"'
40232e71ea71Smrg	fi
4024c3c9db83Smrg	if test -n "$finish_eval"; then
4025c3c9db83Smrg	  # Do the single finish_eval.
4026c3c9db83Smrg	  eval cmds=\"$finish_eval\"
40273f6d0e1dSmrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
4028c3c9db83Smrg       $cmds"
4029c3c9db83Smrg	fi
4030c3c9db83Smrg      done
4031c3c9db83Smrg    fi
4032692f60a7Smrg
4033c3c9db83Smrg    # Exit here if they wanted silent mode.
40342f60eb46Smrg    $opt_quiet && exit $EXIT_SUCCESS
4035692f60a7Smrg
40363f6d0e1dSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
40373f6d0e1dSmrg      echo "----------------------------------------------------------------------"
40383f6d0e1dSmrg      echo "Libraries have been installed in:"
40393f6d0e1dSmrg      for libdir in $libdirs; do
40403f6d0e1dSmrg	$ECHO "   $libdir"
40413f6d0e1dSmrg      done
40423f6d0e1dSmrg      echo
40433f6d0e1dSmrg      echo "If you ever happen to want to link against installed libraries"
40443f6d0e1dSmrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
40452f60eb46Smrg      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
40463f6d0e1dSmrg      echo "flag during linking and do at least one of the following:"
40473f6d0e1dSmrg      if test -n "$shlibpath_var"; then
40482f60eb46Smrg	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
40493f6d0e1dSmrg	echo "     during execution"
40503f6d0e1dSmrg      fi
40513f6d0e1dSmrg      if test -n "$runpath_var"; then
40522f60eb46Smrg	echo "   - add LIBDIR to the '$runpath_var' environment variable"
40533f6d0e1dSmrg	echo "     during linking"
40543f6d0e1dSmrg      fi
40553f6d0e1dSmrg      if test -n "$hardcode_libdir_flag_spec"; then
40563f6d0e1dSmrg	libdir=LIBDIR
40573f6d0e1dSmrg	eval flag=\"$hardcode_libdir_flag_spec\"
4058c3c9db83Smrg
40592f60eb46Smrg	$ECHO "   - use the '$flag' linker flag"
40603f6d0e1dSmrg      fi
40613f6d0e1dSmrg      if test -n "$admincmds"; then
40623f6d0e1dSmrg	$ECHO "   - have your system administrator run these commands:$admincmds"
40633f6d0e1dSmrg      fi
40643f6d0e1dSmrg      if test -f /etc/ld.so.conf; then
40652f60eb46Smrg	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
40663f6d0e1dSmrg      fi
40673f6d0e1dSmrg      echo
4068c3c9db83Smrg
40693f6d0e1dSmrg      echo "See any operating system documentation about shared libraries for"
40703f6d0e1dSmrg      case $host in
40713f6d0e1dSmrg	solaris2.[6789]|solaris2.1[0-9])
40723f6d0e1dSmrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
40733f6d0e1dSmrg	  echo "pages."
40743f6d0e1dSmrg	  ;;
40753f6d0e1dSmrg	*)
40763f6d0e1dSmrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
40773f6d0e1dSmrg	  ;;
40783f6d0e1dSmrg      esac
40793f6d0e1dSmrg      echo "----------------------------------------------------------------------"
40803f6d0e1dSmrg    fi
4081c3c9db83Smrg    exit $EXIT_SUCCESS
4082c3c9db83Smrg}
4083c3c9db83Smrg
40842f60eb46Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"}
4085c3c9db83Smrg
4086c3c9db83Smrg
4087c3c9db83Smrg# func_mode_install arg...
4088c3c9db83Smrgfunc_mode_install ()
4089c3c9db83Smrg{
40902f60eb46Smrg    $debug_cmd
40912f60eb46Smrg
4092c3c9db83Smrg    # There may be an optional sh(1) argument at the beginning of
4093c3c9db83Smrg    # install_prog (especially on Windows NT).
40942f60eb46Smrg    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
4095c3c9db83Smrg       # Allow the use of GNU shtool's install command.
40962f60eb46Smrg       case $nonopt in *shtool*) :;; *) false;; esac
40972f60eb46Smrg    then
4098c3c9db83Smrg      # Aesthetically quote it.
4099c3c9db83Smrg      func_quote_for_eval "$nonopt"
4100c3c9db83Smrg      install_prog="$func_quote_for_eval_result "
4101c3c9db83Smrg      arg=$1
4102c3c9db83Smrg      shift
4103c3c9db83Smrg    else
4104c3c9db83Smrg      install_prog=
4105c3c9db83Smrg      arg=$nonopt
4106c3c9db83Smrg    fi
4107c3c9db83Smrg
4108c3c9db83Smrg    # The real first argument should be the name of the installation program.
4109c3c9db83Smrg    # Aesthetically quote it.
4110c3c9db83Smrg    func_quote_for_eval "$arg"
41113f6d0e1dSmrg    func_append install_prog "$func_quote_for_eval_result"
41123f6d0e1dSmrg    install_shared_prog=$install_prog
41133f6d0e1dSmrg    case " $install_prog " in
41143f6d0e1dSmrg      *[\\\ /]cp\ *) install_cp=: ;;
41153f6d0e1dSmrg      *) install_cp=false ;;
41163f6d0e1dSmrg    esac
4117c3c9db83Smrg
4118c3c9db83Smrg    # We need to accept at least all the BSD install flags.
4119c3c9db83Smrg    dest=
4120c3c9db83Smrg    files=
4121c3c9db83Smrg    opts=
4122c3c9db83Smrg    prev=
4123c3c9db83Smrg    install_type=
41242f60eb46Smrg    isdir=false
4125c3c9db83Smrg    stripme=
41263f6d0e1dSmrg    no_mode=:
4127c3c9db83Smrg    for arg
4128c3c9db83Smrg    do
41293f6d0e1dSmrg      arg2=
4130c3c9db83Smrg      if test -n "$dest"; then
41313f6d0e1dSmrg	func_append files " $dest"
4132c3c9db83Smrg	dest=$arg
4133c3c9db83Smrg	continue
4134c3c9db83Smrg      fi
4135c3c9db83Smrg
4136c3c9db83Smrg      case $arg in
41372f60eb46Smrg      -d) isdir=: ;;
4138c3c9db83Smrg      -f)
41393f6d0e1dSmrg	if $install_cp; then :; else
41403f6d0e1dSmrg	  prev=$arg
41413f6d0e1dSmrg	fi
4142c3c9db83Smrg	;;
4143c3c9db83Smrg      -g | -m | -o)
4144c3c9db83Smrg	prev=$arg
4145c3c9db83Smrg	;;
4146c3c9db83Smrg      -s)
4147c3c9db83Smrg	stripme=" -s"
4148c3c9db83Smrg	continue
4149c3c9db83Smrg	;;
4150c3c9db83Smrg      -*)
4151c3c9db83Smrg	;;
4152c3c9db83Smrg      *)
4153c3c9db83Smrg	# If the previous option needed an argument, then skip it.
4154c3c9db83Smrg	if test -n "$prev"; then
41552f60eb46Smrg	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
41563f6d0e1dSmrg	    arg2=$install_override_mode
41573f6d0e1dSmrg	    no_mode=false
41583f6d0e1dSmrg	  fi
41592e71ea71Smrg	  prev=
416085ee4c00Smrg	else
4161c3c9db83Smrg	  dest=$arg
4162c3c9db83Smrg	  continue
4163692f60a7Smrg	fi
41642e71ea71Smrg	;;
4165c3c9db83Smrg      esac
4166692f60a7Smrg
4167c3c9db83Smrg      # Aesthetically quote the argument.
4168c3c9db83Smrg      func_quote_for_eval "$arg"
41693f6d0e1dSmrg      func_append install_prog " $func_quote_for_eval_result"
41703f6d0e1dSmrg      if test -n "$arg2"; then
41713f6d0e1dSmrg	func_quote_for_eval "$arg2"
41723f6d0e1dSmrg      fi
41733f6d0e1dSmrg      func_append install_shared_prog " $func_quote_for_eval_result"
4174c3c9db83Smrg    done
4175692f60a7Smrg
4176c3c9db83Smrg    test -z "$install_prog" && \
4177c3c9db83Smrg      func_fatal_help "you must specify an install program"
4178692f60a7Smrg
4179c3c9db83Smrg    test -n "$prev" && \
41802f60eb46Smrg      func_fatal_help "the '$prev' option requires an argument"
418185ee4c00Smrg
41823f6d0e1dSmrg    if test -n "$install_override_mode" && $no_mode; then
41833f6d0e1dSmrg      if $install_cp; then :; else
41843f6d0e1dSmrg	func_quote_for_eval "$install_override_mode"
41853f6d0e1dSmrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
41863f6d0e1dSmrg      fi
41873f6d0e1dSmrg    fi
41883f6d0e1dSmrg
4189c3c9db83Smrg    if test -z "$files"; then
4190c3c9db83Smrg      if test -z "$dest"; then
4191c3c9db83Smrg	func_fatal_help "no file or destination specified"
4192c3c9db83Smrg      else
4193c3c9db83Smrg	func_fatal_help "you must specify a destination"
4194c3c9db83Smrg      fi
41952e71ea71Smrg    fi
419685ee4c00Smrg
4197c3c9db83Smrg    # Strip any trailing slash from the destination.
4198c3c9db83Smrg    func_stripname '' '/' "$dest"
4199c3c9db83Smrg    dest=$func_stripname_result
420085ee4c00Smrg
4201c3c9db83Smrg    # Check to see that the destination is a directory.
42022f60eb46Smrg    test -d "$dest" && isdir=:
42032f60eb46Smrg    if $isdir; then
42042f60eb46Smrg      destdir=$dest
4205c3c9db83Smrg      destname=
42062e71ea71Smrg    else
4207c3c9db83Smrg      func_dirname_and_basename "$dest" "" "."
42082f60eb46Smrg      destdir=$func_dirname_result
42092f60eb46Smrg      destname=$func_basename_result
421085ee4c00Smrg
4211c3c9db83Smrg      # Not a directory, so check to see that there is only one file specified.
4212c3c9db83Smrg      set dummy $files; shift
4213c3c9db83Smrg      test "$#" -gt 1 && \
42142f60eb46Smrg	func_fatal_help "'$dest' is not a directory"
421585ee4c00Smrg    fi
4216c3c9db83Smrg    case $destdir in
4217c3c9db83Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
42182e71ea71Smrg    *)
4219c3c9db83Smrg      for file in $files; do
4220c3c9db83Smrg	case $file in
4221c3c9db83Smrg	*.lo) ;;
4222c3c9db83Smrg	*)
42232f60eb46Smrg	  func_fatal_help "'$destdir' must be an absolute directory name"
4224c3c9db83Smrg	  ;;
4225c3c9db83Smrg	esac
4226c3c9db83Smrg      done
42272e71ea71Smrg      ;;
42282e71ea71Smrg    esac
4229692f60a7Smrg
4230c3c9db83Smrg    # This variable tells wrapper scripts just to set variables rather
4231c3c9db83Smrg    # than running their programs.
42322f60eb46Smrg    libtool_install_magic=$magic
4233692f60a7Smrg
4234c3c9db83Smrg    staticlibs=
4235c3c9db83Smrg    future_libdirs=
4236c3c9db83Smrg    current_libdirs=
4237c3c9db83Smrg    for file in $files; do
4238692f60a7Smrg
4239c3c9db83Smrg      # Do each installation.
4240c3c9db83Smrg      case $file in
4241c3c9db83Smrg      *.$libext)
4242c3c9db83Smrg	# Do the static libraries later.
42433f6d0e1dSmrg	func_append staticlibs " $file"
4244c3c9db83Smrg	;;
4245c3c9db83Smrg
4246c3c9db83Smrg      *.la)
42473f6d0e1dSmrg	func_resolve_sysroot "$file"
42483f6d0e1dSmrg	file=$func_resolve_sysroot_result
42493f6d0e1dSmrg
4250c3c9db83Smrg	# Check to see that this really is a libtool archive.
4251c3c9db83Smrg	func_lalib_unsafe_p "$file" \
42522f60eb46Smrg	  || func_fatal_help "'$file' is not a valid libtool archive"
4253c3c9db83Smrg
4254c3c9db83Smrg	library_names=
4255c3c9db83Smrg	old_library=
4256c3c9db83Smrg	relink_command=
4257c3c9db83Smrg	func_source "$file"
4258c3c9db83Smrg
4259c3c9db83Smrg	# Add the libdir to current_libdirs if it is the destination.
4260c3c9db83Smrg	if test "X$destdir" = "X$libdir"; then
4261c3c9db83Smrg	  case "$current_libdirs " in
4262c3c9db83Smrg	  *" $libdir "*) ;;
42633f6d0e1dSmrg	  *) func_append current_libdirs " $libdir" ;;
426485ee4c00Smrg	  esac
4265c3c9db83Smrg	else
4266c3c9db83Smrg	  # Note the libdir as a future libdir.
4267c3c9db83Smrg	  case "$future_libdirs " in
4268c3c9db83Smrg	  *" $libdir "*) ;;
42693f6d0e1dSmrg	  *) func_append future_libdirs " $libdir" ;;
4270c3c9db83Smrg	  esac
4271c3c9db83Smrg	fi
427285ee4c00Smrg
4273c3c9db83Smrg	func_dirname "$file" "/" ""
42742f60eb46Smrg	dir=$func_dirname_result
42753f6d0e1dSmrg	func_append dir "$objdir"
4276c3c9db83Smrg
4277c3c9db83Smrg	if test -n "$relink_command"; then
4278c3c9db83Smrg	  # Determine the prefix the user has applied to our future dir.
42793f6d0e1dSmrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
4280c3c9db83Smrg
4281c3c9db83Smrg	  # Don't allow the user to place us outside of our expected
4282c3c9db83Smrg	  # location b/c this prevents finding dependent libraries that
4283c3c9db83Smrg	  # are installed to the same prefix.
4284c3c9db83Smrg	  # At present, this check doesn't affect windows .dll's that
4285c3c9db83Smrg	  # are installed into $libdir/../bin (currently, that works fine)
4286c3c9db83Smrg	  # but it's something to keep an eye on.
4287c3c9db83Smrg	  test "$inst_prefix_dir" = "$destdir" && \
42882f60eb46Smrg	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
4289c3c9db83Smrg
4290c3c9db83Smrg	  if test -n "$inst_prefix_dir"; then
4291c3c9db83Smrg	    # Stick the inst_prefix_dir data into the link command.
42923f6d0e1dSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
4293c3c9db83Smrg	  else
42943f6d0e1dSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
4295c3c9db83Smrg	  fi
4296c3c9db83Smrg
42972f60eb46Smrg	  func_warning "relinking '$file'"
4298c3c9db83Smrg	  func_show_eval "$relink_command" \
42992f60eb46Smrg	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
4300c3c9db83Smrg	fi
4301c3c9db83Smrg
4302c3c9db83Smrg	# See the names of the shared library.
4303c3c9db83Smrg	set dummy $library_names; shift
4304c3c9db83Smrg	if test -n "$1"; then
43052f60eb46Smrg	  realname=$1
4306c3c9db83Smrg	  shift
4307c3c9db83Smrg
43082f60eb46Smrg	  srcname=$realname
43092f60eb46Smrg	  test -n "$relink_command" && srcname=${realname}T
4310c3c9db83Smrg
4311c3c9db83Smrg	  # Install the shared library and build the symlinks.
43123f6d0e1dSmrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
4313c3c9db83Smrg	      'exit $?'
43142f60eb46Smrg	  tstripme=$stripme
4315c3c9db83Smrg	  case $host_os in
4316c3c9db83Smrg	  cygwin* | mingw* | pw32* | cegcc*)
4317c3c9db83Smrg	    case $realname in
4318c3c9db83Smrg	    *.dll.a)
43192f60eb46Smrg	      tstripme=
43202f60eb46Smrg	      ;;
43212f60eb46Smrg	    esac
43222f60eb46Smrg	    ;;
43232f60eb46Smrg	  os2*)
43242f60eb46Smrg	    case $realname in
43252f60eb46Smrg	    *_dll.a)
43262f60eb46Smrg	      tstripme=
4327c3c9db83Smrg	      ;;
4328c3c9db83Smrg	    esac
432985ee4c00Smrg	    ;;
433085ee4c00Smrg	  esac
4331c3c9db83Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
4332c3c9db83Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
43332e71ea71Smrg	  fi
4334c3c9db83Smrg
4335c3c9db83Smrg	  if test "$#" -gt 0; then
4336c3c9db83Smrg	    # Delete the old symlinks, and create new ones.
43372f60eb46Smrg	    # Try 'ln -sf' first, because the 'ln' binary might depend on
4338c3c9db83Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
4339c3c9db83Smrg	    # so we also need to try rm && ln -s.
4340c3c9db83Smrg	    for linkname
4341c3c9db83Smrg	    do
4342c3c9db83Smrg	      test "$linkname" != "$realname" \
4343c3c9db83Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
43442e71ea71Smrg	    done
43452e71ea71Smrg	  fi
4346692f60a7Smrg
4347c3c9db83Smrg	  # Do each command in the postinstall commands.
43482f60eb46Smrg	  lib=$destdir/$realname
4349c3c9db83Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
43502e71ea71Smrg	fi
4351692f60a7Smrg
4352c3c9db83Smrg	# Install the pseudo-library for information purposes.
4353c3c9db83Smrg	func_basename "$file"
43542f60eb46Smrg	name=$func_basename_result
43552f60eb46Smrg	instname=$dir/${name}i
4356c3c9db83Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
4357692f60a7Smrg
4358c3c9db83Smrg	# Maybe install the static library, too.
43593f6d0e1dSmrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
4360c3c9db83Smrg	;;
4361692f60a7Smrg
4362c3c9db83Smrg      *.lo)
4363c3c9db83Smrg	# Install (i.e. copy) a libtool object.
4364692f60a7Smrg
4365c3c9db83Smrg	# Figure out destination file name, if it wasn't already specified.
4366c3c9db83Smrg	if test -n "$destname"; then
43672f60eb46Smrg	  destfile=$destdir/$destname
4368c3c9db83Smrg	else
4369c3c9db83Smrg	  func_basename "$file"
43702f60eb46Smrg	  destfile=$func_basename_result
43712f60eb46Smrg	  destfile=$destdir/$destfile
43722e71ea71Smrg	fi
4373692f60a7Smrg
4374c3c9db83Smrg	# Deduce the name of the destination old-style object file.
4375c3c9db83Smrg	case $destfile in
4376c3c9db83Smrg	*.lo)
4377c3c9db83Smrg	  func_lo2o "$destfile"
4378c3c9db83Smrg	  staticdest=$func_lo2o_result
4379c3c9db83Smrg	  ;;
4380c3c9db83Smrg	*.$objext)
43812f60eb46Smrg	  staticdest=$destfile
4382c3c9db83Smrg	  destfile=
4383c3c9db83Smrg	  ;;
4384c3c9db83Smrg	*)
43852f60eb46Smrg	  func_fatal_help "cannot copy a libtool object to '$destfile'"
4386c3c9db83Smrg	  ;;
4387c3c9db83Smrg	esac
4388692f60a7Smrg
4389c3c9db83Smrg	# Install the libtool object if requested.
4390c3c9db83Smrg	test -n "$destfile" && \
4391c3c9db83Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
4392692f60a7Smrg
4393c3c9db83Smrg	# Install the old object if enabled.
43942f60eb46Smrg	if test yes = "$build_old_libs"; then
4395c3c9db83Smrg	  # Deduce the name of the old-style object file.
4396c3c9db83Smrg	  func_lo2o "$file"
4397c3c9db83Smrg	  staticobj=$func_lo2o_result
4398c3c9db83Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
4399692f60a7Smrg	fi
4400c3c9db83Smrg	exit $EXIT_SUCCESS
4401c3c9db83Smrg	;;
4402692f60a7Smrg
4403c3c9db83Smrg      *)
4404c3c9db83Smrg	# Figure out destination file name, if it wasn't already specified.
4405c3c9db83Smrg	if test -n "$destname"; then
44062f60eb46Smrg	  destfile=$destdir/$destname
4407c3c9db83Smrg	else
4408c3c9db83Smrg	  func_basename "$file"
44092f60eb46Smrg	  destfile=$func_basename_result
44102f60eb46Smrg	  destfile=$destdir/$destfile
4411c3c9db83Smrg	fi
4412692f60a7Smrg
4413c3c9db83Smrg	# If the file is missing, and there is a .exe on the end, strip it
4414c3c9db83Smrg	# because it is most likely a libtool script we actually want to
4415c3c9db83Smrg	# install
44162f60eb46Smrg	stripped_ext=
4417c3c9db83Smrg	case $file in
4418c3c9db83Smrg	  *.exe)
4419c3c9db83Smrg	    if test ! -f "$file"; then
4420c3c9db83Smrg	      func_stripname '' '.exe' "$file"
4421c3c9db83Smrg	      file=$func_stripname_result
44222f60eb46Smrg	      stripped_ext=.exe
4423c3c9db83Smrg	    fi
4424c3c9db83Smrg	    ;;
4425c3c9db83Smrg	esac
4426c3c9db83Smrg
4427c3c9db83Smrg	# Do a test to see if this is really a libtool program.
4428c3c9db83Smrg	case $host in
4429c3c9db83Smrg	*cygwin* | *mingw*)
4430c3c9db83Smrg	    if func_ltwrapper_executable_p "$file"; then
4431c3c9db83Smrg	      func_ltwrapper_scriptname "$file"
4432c3c9db83Smrg	      wrapper=$func_ltwrapper_scriptname_result
4433c3c9db83Smrg	    else
4434c3c9db83Smrg	      func_stripname '' '.exe' "$file"
4435c3c9db83Smrg	      wrapper=$func_stripname_result
4436c3c9db83Smrg	    fi
4437c3c9db83Smrg	    ;;
44382e71ea71Smrg	*)
4439c3c9db83Smrg	    wrapper=$file
4440c3c9db83Smrg	    ;;
4441c3c9db83Smrg	esac
4442c3c9db83Smrg	if func_ltwrapper_script_p "$wrapper"; then
4443c3c9db83Smrg	  notinst_deplibs=
4444c3c9db83Smrg	  relink_command=
4445c3c9db83Smrg
4446c3c9db83Smrg	  func_source "$wrapper"
4447c3c9db83Smrg
4448c3c9db83Smrg	  # Check the variables that should have been set.
4449c3c9db83Smrg	  test -z "$generated_by_libtool_version" && \
44502f60eb46Smrg	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
4451c3c9db83Smrg
44522f60eb46Smrg	  finalize=:
4453c3c9db83Smrg	  for lib in $notinst_deplibs; do
4454c3c9db83Smrg	    # Check to see that each library is installed.
4455c3c9db83Smrg	    libdir=
4456c3c9db83Smrg	    if test -f "$lib"; then
4457c3c9db83Smrg	      func_source "$lib"
4458c3c9db83Smrg	    fi
44592f60eb46Smrg	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
4460c3c9db83Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
44612f60eb46Smrg	      func_warning "'$lib' has not been installed in '$libdir'"
44622f60eb46Smrg	      finalize=false
4463c3c9db83Smrg	    fi
4464c3c9db83Smrg	  done
4465c3c9db83Smrg
4466c3c9db83Smrg	  relink_command=
4467c3c9db83Smrg	  func_source "$wrapper"
4468c3c9db83Smrg
4469c3c9db83Smrg	  outputname=
44702f60eb46Smrg	  if test no = "$fast_install" && test -n "$relink_command"; then
4471c3c9db83Smrg	    $opt_dry_run || {
44722f60eb46Smrg	      if $finalize; then
4473c3c9db83Smrg	        tmpdir=`func_mktempdir`
4474c3c9db83Smrg		func_basename "$file$stripped_ext"
44752f60eb46Smrg		file=$func_basename_result
44762f60eb46Smrg	        outputname=$tmpdir/$file
4477c3c9db83Smrg	        # Replace the output file specification.
44783f6d0e1dSmrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
4479c3c9db83Smrg
44802f60eb46Smrg	        $opt_quiet || {
4481c3c9db83Smrg	          func_quote_for_expand "$relink_command"
4482c3c9db83Smrg		  eval "func_echo $func_quote_for_expand_result"
4483c3c9db83Smrg	        }
4484c3c9db83Smrg	        if eval "$relink_command"; then :
4485c3c9db83Smrg	          else
44862f60eb46Smrg		  func_error "error: relink '$file' with the above command before installing it"
4487c3c9db83Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
4488c3c9db83Smrg		  continue
4489c3c9db83Smrg	        fi
44902f60eb46Smrg	        file=$outputname
4491c3c9db83Smrg	      else
44922f60eb46Smrg	        func_warning "cannot relink '$file'"
4493c3c9db83Smrg	      fi
4494c3c9db83Smrg	    }
4495c3c9db83Smrg	  else
4496c3c9db83Smrg	    # Install the binary that we compiled earlier.
44973f6d0e1dSmrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
44982e71ea71Smrg	  fi
4499c3c9db83Smrg	fi
4500c3c9db83Smrg
4501c3c9db83Smrg	# remove .exe since cygwin /usr/bin/install will append another
4502c3c9db83Smrg	# one anyway
4503c3c9db83Smrg	case $install_prog,$host in
4504c3c9db83Smrg	*/usr/bin/install*,*cygwin*)
4505c3c9db83Smrg	  case $file:$destfile in
4506c3c9db83Smrg	  *.exe:*.exe)
4507c3c9db83Smrg	    # this is ok
4508c3c9db83Smrg	    ;;
4509c3c9db83Smrg	  *.exe:*)
4510c3c9db83Smrg	    destfile=$destfile.exe
4511c3c9db83Smrg	    ;;
4512c3c9db83Smrg	  *:*.exe)
4513c3c9db83Smrg	    func_stripname '' '.exe' "$destfile"
4514c3c9db83Smrg	    destfile=$func_stripname_result
4515c3c9db83Smrg	    ;;
4516c3c9db83Smrg	  esac
45172e71ea71Smrg	  ;;
45182e71ea71Smrg	esac
4519c3c9db83Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
4520c3c9db83Smrg	$opt_dry_run || if test -n "$outputname"; then
4521c3c9db83Smrg	  ${RM}r "$tmpdir"
4522c3c9db83Smrg	fi
4523c3c9db83Smrg	;;
4524c3c9db83Smrg      esac
4525c3c9db83Smrg    done
4526692f60a7Smrg
4527c3c9db83Smrg    for file in $staticlibs; do
4528c3c9db83Smrg      func_basename "$file"
45292f60eb46Smrg      name=$func_basename_result
4530c3c9db83Smrg
4531c3c9db83Smrg      # Set up the ranlib parameters.
45322f60eb46Smrg      oldlib=$destdir/$name
453395903e71Smrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
453495903e71Smrg      tool_oldlib=$func_to_tool_file_result
4535c3c9db83Smrg
4536c3c9db83Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
4537c3c9db83Smrg
4538c3c9db83Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
453995903e71Smrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
4540c3c9db83Smrg      fi
4541c3c9db83Smrg
4542c3c9db83Smrg      # Do each command in the postinstall commands.
4543c3c9db83Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
4544c3c9db83Smrg    done
4545c3c9db83Smrg
4546c3c9db83Smrg    test -n "$future_libdirs" && \
45472f60eb46Smrg      func_warning "remember to run '$progname --finish$future_libdirs'"
4548c3c9db83Smrg
4549c3c9db83Smrg    if test -n "$current_libdirs"; then
4550c3c9db83Smrg      # Maybe just do a dry run.
4551c3c9db83Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
45522f60eb46Smrg      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
4553c3c9db83Smrg    else
4554c3c9db83Smrg      exit $EXIT_SUCCESS
4555c3c9db83Smrg    fi
4556c3c9db83Smrg}
4557c3c9db83Smrg
45582f60eb46Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"}
4559c3c9db83Smrg
4560c3c9db83Smrg
4561c3c9db83Smrg# func_generate_dlsyms outputname originator pic_p
4562c3c9db83Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
4563c3c9db83Smrg# a dlpreopen symbol table.
4564c3c9db83Smrgfunc_generate_dlsyms ()
4565c3c9db83Smrg{
45662f60eb46Smrg    $debug_cmd
45672f60eb46Smrg
45682f60eb46Smrg    my_outputname=$1
45692f60eb46Smrg    my_originator=$2
45702f60eb46Smrg    my_pic_p=${3-false}
45712f60eb46Smrg    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
4572c3c9db83Smrg    my_dlsyms=
4573c3c9db83Smrg
45742f60eb46Smrg    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
4575c3c9db83Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
45762f60eb46Smrg	my_dlsyms=${my_outputname}S.c
4577c3c9db83Smrg      else
4578c3c9db83Smrg	func_error "not configured to extract global symbols from dlpreopened files"
4579c3c9db83Smrg      fi
4580c3c9db83Smrg    fi
4581c3c9db83Smrg
4582c3c9db83Smrg    if test -n "$my_dlsyms"; then
4583c3c9db83Smrg      case $my_dlsyms in
4584c3c9db83Smrg      "") ;;
4585c3c9db83Smrg      *.c)
4586c3c9db83Smrg	# Discover the nlist of each of the dlfiles.
45872f60eb46Smrg	nlist=$output_objdir/$my_outputname.nm
4588c3c9db83Smrg
4589c3c9db83Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
4590c3c9db83Smrg
4591c3c9db83Smrg	# Parse the name list into a source file.
4592c3c9db83Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
4593c3c9db83Smrg
4594c3c9db83Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
45952f60eb46Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
45962f60eb46Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
4597c3c9db83Smrg
4598c3c9db83Smrg#ifdef __cplusplus
4599c3c9db83Smrgextern \"C\" {
4600c3c9db83Smrg#endif
4601c3c9db83Smrg
46022f60eb46Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
46033f6d0e1dSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
46043f6d0e1dSmrg#endif
46053f6d0e1dSmrg
46063f6d0e1dSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
46072f60eb46Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
46082f60eb46Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime
46093f6d0e1dSmrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
46103f6d0e1dSmrg# define LT_DLSYM_CONST
46112f60eb46Smrg#elif defined __osf__
46123f6d0e1dSmrg/* This system does not cope well with relocations in const data.  */
46133f6d0e1dSmrg# define LT_DLSYM_CONST
46143f6d0e1dSmrg#else
46153f6d0e1dSmrg# define LT_DLSYM_CONST const
46163f6d0e1dSmrg#endif
46173f6d0e1dSmrg
46182f60eb46Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
46192f60eb46Smrg
4620c3c9db83Smrg/* External symbol declarations for the compiler. */\
4621c3c9db83Smrg"
4622c3c9db83Smrg
46232f60eb46Smrg	if test yes = "$dlself"; then
46242f60eb46Smrg	  func_verbose "generating symbol list for '$output'"
4625c3c9db83Smrg
4626c3c9db83Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
4627c3c9db83Smrg
4628c3c9db83Smrg	  # Add our own program objects to the symbol list.
46293f6d0e1dSmrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
4630c3c9db83Smrg	  for progfile in $progfiles; do
46313f6d0e1dSmrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
46322f60eb46Smrg	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
46333f6d0e1dSmrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
4634c3c9db83Smrg	  done
4635c3c9db83Smrg
4636c3c9db83Smrg	  if test -n "$exclude_expsyms"; then
4637c3c9db83Smrg	    $opt_dry_run || {
4638c3c9db83Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4639c3c9db83Smrg	      eval '$MV "$nlist"T "$nlist"'
4640c3c9db83Smrg	    }
46412e71ea71Smrg	  fi
4642c3c9db83Smrg
4643c3c9db83Smrg	  if test -n "$export_symbols_regex"; then
4644c3c9db83Smrg	    $opt_dry_run || {
4645c3c9db83Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4646c3c9db83Smrg	      eval '$MV "$nlist"T "$nlist"'
4647c3c9db83Smrg	    }
4648c3c9db83Smrg	  fi
4649c3c9db83Smrg
4650c3c9db83Smrg	  # Prepare the list of exported symbols
4651c3c9db83Smrg	  if test -z "$export_symbols"; then
46522f60eb46Smrg	    export_symbols=$output_objdir/$outputname.exp
4653c3c9db83Smrg	    $opt_dry_run || {
4654c3c9db83Smrg	      $RM $export_symbols
46552f60eb46Smrg	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4656c3c9db83Smrg	      case $host in
4657c3c9db83Smrg	      *cygwin* | *mingw* | *cegcc* )
4658c3c9db83Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4659c3c9db83Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4660c3c9db83Smrg	        ;;
4661c3c9db83Smrg	      esac
4662c3c9db83Smrg	    }
46632e71ea71Smrg	  else
4664c3c9db83Smrg	    $opt_dry_run || {
46652f60eb46Smrg	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4666c3c9db83Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4667c3c9db83Smrg	      eval '$MV "$nlist"T "$nlist"'
4668c3c9db83Smrg	      case $host in
46693f6d0e1dSmrg	        *cygwin* | *mingw* | *cegcc* )
4670c3c9db83Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4671c3c9db83Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4672c3c9db83Smrg	          ;;
4673c3c9db83Smrg	      esac
4674c3c9db83Smrg	    }
46752e71ea71Smrg	  fi
4676c3c9db83Smrg	fi
4677692f60a7Smrg
4678c3c9db83Smrg	for dlprefile in $dlprefiles; do
46792f60eb46Smrg	  func_verbose "extracting global C symbols from '$dlprefile'"
4680c3c9db83Smrg	  func_basename "$dlprefile"
46812f60eb46Smrg	  name=$func_basename_result
46823f6d0e1dSmrg          case $host in
46833f6d0e1dSmrg	    *cygwin* | *mingw* | *cegcc* )
46843f6d0e1dSmrg	      # if an import library, we need to obtain dlname
46853f6d0e1dSmrg	      if func_win32_import_lib_p "$dlprefile"; then
46863f6d0e1dSmrg	        func_tr_sh "$dlprefile"
46873f6d0e1dSmrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
46882f60eb46Smrg	        dlprefile_dlbasename=
46893f6d0e1dSmrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
46903f6d0e1dSmrg	          # Use subshell, to avoid clobbering current variable values
46913f6d0e1dSmrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
46922f60eb46Smrg	          if test -n "$dlprefile_dlname"; then
46933f6d0e1dSmrg	            func_basename "$dlprefile_dlname"
46942f60eb46Smrg	            dlprefile_dlbasename=$func_basename_result
46953f6d0e1dSmrg	          else
46963f6d0e1dSmrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
46973f6d0e1dSmrg	            $sharedlib_from_linklib_cmd "$dlprefile"
46983f6d0e1dSmrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
46993f6d0e1dSmrg	          fi
47003f6d0e1dSmrg	        fi
47013f6d0e1dSmrg	        $opt_dry_run || {
47022f60eb46Smrg	          if test -n "$dlprefile_dlbasename"; then
47033f6d0e1dSmrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
47043f6d0e1dSmrg	          else
47053f6d0e1dSmrg	            func_warning "Could not compute DLL name from $name"
47063f6d0e1dSmrg	            eval '$ECHO ": $name " >> "$nlist"'
47073f6d0e1dSmrg	          fi
47083f6d0e1dSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
47093f6d0e1dSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
47103f6d0e1dSmrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
47113f6d0e1dSmrg	        }
47123f6d0e1dSmrg	      else # not an import lib
47133f6d0e1dSmrg	        $opt_dry_run || {
47143f6d0e1dSmrg	          eval '$ECHO ": $name " >> "$nlist"'
47153f6d0e1dSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
47163f6d0e1dSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
47173f6d0e1dSmrg	        }
47183f6d0e1dSmrg	      fi
47193f6d0e1dSmrg	    ;;
47203f6d0e1dSmrg	    *)
47213f6d0e1dSmrg	      $opt_dry_run || {
47223f6d0e1dSmrg	        eval '$ECHO ": $name " >> "$nlist"'
47233f6d0e1dSmrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
47243f6d0e1dSmrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
47253f6d0e1dSmrg	      }
47263f6d0e1dSmrg	    ;;
47273f6d0e1dSmrg          esac
4728c3c9db83Smrg	done
4729c3c9db83Smrg
4730c3c9db83Smrg	$opt_dry_run || {
4731c3c9db83Smrg	  # Make sure we have at least an empty file.
4732c3c9db83Smrg	  test -f "$nlist" || : > "$nlist"
4733c3c9db83Smrg
4734c3c9db83Smrg	  if test -n "$exclude_expsyms"; then
4735c3c9db83Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4736c3c9db83Smrg	    $MV "$nlist"T "$nlist"
47372e71ea71Smrg	  fi
4738c3c9db83Smrg
4739c3c9db83Smrg	  # Try sorting and uniquifying the output.
4740c3c9db83Smrg	  if $GREP -v "^: " < "$nlist" |
4741c3c9db83Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
4742c3c9db83Smrg		sort -k 3
4743c3c9db83Smrg	      else
4744c3c9db83Smrg		sort +2
4745c3c9db83Smrg	      fi |
4746c3c9db83Smrg	      uniq > "$nlist"S; then
4747c3c9db83Smrg	    :
47482e71ea71Smrg	  else
4749c3c9db83Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
47502e71ea71Smrg	  fi
4751692f60a7Smrg
4752c3c9db83Smrg	  if test -f "$nlist"S; then
4753c3c9db83Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
47542e71ea71Smrg	  else
47553f6d0e1dSmrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
47562e71ea71Smrg	  fi
4757692f60a7Smrg
47582f60eb46Smrg	  func_show_eval '$RM "${nlist}I"'
47592f60eb46Smrg	  if test -n "$global_symbol_to_import"; then
47602f60eb46Smrg	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
47612f60eb46Smrg	  fi
47622f60eb46Smrg
47633f6d0e1dSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
4764692f60a7Smrg
4765c3c9db83Smrg/* The mapping between symbol names and symbols.  */
4766c3c9db83Smrgtypedef struct {
4767c3c9db83Smrg  const char *name;
4768c3c9db83Smrg  void *address;
4769c3c9db83Smrg} lt_dlsymlist;
47703f6d0e1dSmrgextern LT_DLSYM_CONST lt_dlsymlist
47712f60eb46Smrglt_${my_prefix}_LTX_preloaded_symbols[];\
47722f60eb46Smrg"
47732f60eb46Smrg
47742f60eb46Smrg	  if test -s "$nlist"I; then
47752f60eb46Smrg	    echo >> "$output_objdir/$my_dlsyms" "\
47762f60eb46Smrgstatic void lt_syminit(void)
47772f60eb46Smrg{
47782f60eb46Smrg  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
47792f60eb46Smrg  for (; symbol->name; ++symbol)
47802f60eb46Smrg    {"
47812f60eb46Smrg	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
47822f60eb46Smrg	    echo >> "$output_objdir/$my_dlsyms" "\
47832f60eb46Smrg    }
47842f60eb46Smrg}"
47852f60eb46Smrg	  fi
47862f60eb46Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
47873f6d0e1dSmrgLT_DLSYM_CONST lt_dlsymlist
4788c3c9db83Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
47892f60eb46Smrg{ {\"$my_originator\", (void *) 0},"
47902f60eb46Smrg
47912f60eb46Smrg	  if test -s "$nlist"I; then
47922f60eb46Smrg	    echo >> "$output_objdir/$my_dlsyms" "\
47932f60eb46Smrg  {\"@INIT@\", (void *) &lt_syminit},"
47942f60eb46Smrg	  fi
4795692f60a7Smrg
4796c3c9db83Smrg	  case $need_lib_prefix in
4797c3c9db83Smrg	  no)
4798c3c9db83Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
4799c3c9db83Smrg	    ;;
4800c3c9db83Smrg	  *)
4801c3c9db83Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
4802c3c9db83Smrg	    ;;
4803c3c9db83Smrg	  esac
48043f6d0e1dSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
4805c3c9db83Smrg  {0, (void *) 0}
4806c3c9db83Smrg};
4807692f60a7Smrg
4808c3c9db83Smrg/* This works around a problem in FreeBSD linker */
4809c3c9db83Smrg#ifdef FREEBSD_WORKAROUND
4810c3c9db83Smrgstatic const void *lt_preloaded_setup() {
4811c3c9db83Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
4812c3c9db83Smrg}
4813c3c9db83Smrg#endif
4814c3c9db83Smrg
4815c3c9db83Smrg#ifdef __cplusplus
4816c3c9db83Smrg}
4817c3c9db83Smrg#endif\
4818c3c9db83Smrg"
4819c3c9db83Smrg	} # !$opt_dry_run
4820c3c9db83Smrg
4821c3c9db83Smrg	pic_flag_for_symtable=
4822c3c9db83Smrg	case "$compile_command " in
4823c3c9db83Smrg	*" -static "*) ;;
4824c3c9db83Smrg	*)
4825c3c9db83Smrg	  case $host in
4826c3c9db83Smrg	  # compiling the symbol table file with pic_flag works around
4827c3c9db83Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
4828c3c9db83Smrg	  # linked before any other PIC object.  But we must not use
4829c3c9db83Smrg	  # pic_flag when linking with -static.  The problem exists in
4830c3c9db83Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
483195903e71Smrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4832c3c9db83Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
4833c3c9db83Smrg	  *-*-hpux*)
4834c3c9db83Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
4835c3c9db83Smrg	  *)
48362f60eb46Smrg	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
4837c3c9db83Smrg	    ;;
4838c3c9db83Smrg	  esac
4839c3c9db83Smrg	  ;;
4840c3c9db83Smrg	esac
4841c3c9db83Smrg	symtab_cflags=
4842c3c9db83Smrg	for arg in $LTCFLAGS; do
4843c3c9db83Smrg	  case $arg in
4844c3c9db83Smrg	  -pie | -fpie | -fPIE) ;;
48453f6d0e1dSmrg	  *) func_append symtab_cflags " $arg" ;;
4846c3c9db83Smrg	  esac
4847c3c9db83Smrg	done
4848692f60a7Smrg
4849c3c9db83Smrg	# Now compile the dynamic symbol file.
4850c3c9db83Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
485185ee4c00Smrg
4852c3c9db83Smrg	# Clean up the generated files.
48532f60eb46Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
4854692f60a7Smrg
4855c3c9db83Smrg	# Transform the symbol file into the correct name.
48562f60eb46Smrg	symfileobj=$output_objdir/${my_outputname}S.$objext
4857c3c9db83Smrg	case $host in
4858c3c9db83Smrg	*cygwin* | *mingw* | *cegcc* )
4859c3c9db83Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
48603f6d0e1dSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
48613f6d0e1dSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4862c3c9db83Smrg	  else
48633f6d0e1dSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
48643f6d0e1dSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
48652e71ea71Smrg	  fi
4866c3c9db83Smrg	  ;;
4867c3c9db83Smrg	*)
48683f6d0e1dSmrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
48693f6d0e1dSmrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4870c3c9db83Smrg	  ;;
4871c3c9db83Smrg	esac
4872c3c9db83Smrg	;;
4873c3c9db83Smrg      *)
48742f60eb46Smrg	func_fatal_error "unknown suffix for '$my_dlsyms'"
4875c3c9db83Smrg	;;
4876c3c9db83Smrg      esac
4877c3c9db83Smrg    else
4878c3c9db83Smrg      # We keep going just in case the user didn't refer to
4879c3c9db83Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
4880c3c9db83Smrg      # really was required.
4881692f60a7Smrg
4882c3c9db83Smrg      # Nullify the symbol file.
48833f6d0e1dSmrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
48843f6d0e1dSmrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
4885c3c9db83Smrg    fi
4886c3c9db83Smrg}
488785ee4c00Smrg
48882f60eb46Smrg# func_cygming_gnu_implib_p ARG
48892f60eb46Smrg# This predicate returns with zero status (TRUE) if
48902f60eb46Smrg# ARG is a GNU/binutils-style import library. Returns
48912f60eb46Smrg# with nonzero status (FALSE) otherwise.
48922f60eb46Smrgfunc_cygming_gnu_implib_p ()
48932f60eb46Smrg{
48942f60eb46Smrg  $debug_cmd
48952f60eb46Smrg
48962f60eb46Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
48972f60eb46Smrg  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)$'`
48982f60eb46Smrg  test -n "$func_cygming_gnu_implib_tmp"
48992f60eb46Smrg}
49002f60eb46Smrg
49012f60eb46Smrg# func_cygming_ms_implib_p ARG
49022f60eb46Smrg# This predicate returns with zero status (TRUE) if
49032f60eb46Smrg# ARG is an MS-style import library. Returns
49042f60eb46Smrg# with nonzero status (FALSE) otherwise.
49052f60eb46Smrgfunc_cygming_ms_implib_p ()
49062f60eb46Smrg{
49072f60eb46Smrg  $debug_cmd
49082f60eb46Smrg
49092f60eb46Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
49102f60eb46Smrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
49112f60eb46Smrg  test -n "$func_cygming_ms_implib_tmp"
49122f60eb46Smrg}
49132f60eb46Smrg
4914c3c9db83Smrg# func_win32_libid arg
4915c3c9db83Smrg# return the library type of file 'arg'
4916c3c9db83Smrg#
4917c3c9db83Smrg# Need a lot of goo to handle *both* DLLs and import libs
4918c3c9db83Smrg# Has to be a shell function in order to 'eat' the argument
4919c3c9db83Smrg# that is supplied when $file_magic_command is called.
49203f6d0e1dSmrg# Despite the name, also deal with 64 bit binaries.
4921c3c9db83Smrgfunc_win32_libid ()
4922c3c9db83Smrg{
49232f60eb46Smrg  $debug_cmd
49242f60eb46Smrg
49252f60eb46Smrg  win32_libid_type=unknown
4926c3c9db83Smrg  win32_fileres=`file -L $1 2>/dev/null`
4927c3c9db83Smrg  case $win32_fileres in
4928c3c9db83Smrg  *ar\ archive\ import\ library*) # definitely import
4929c3c9db83Smrg    win32_libid_type="x86 archive import"
4930c3c9db83Smrg    ;;
4931c3c9db83Smrg  *ar\ archive*) # could be an import, or static
49323f6d0e1dSmrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
4933c3c9db83Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
49343f6d0e1dSmrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
49352f60eb46Smrg      case $nm_interface in
49362f60eb46Smrg      "MS dumpbin")
49372f60eb46Smrg	if func_cygming_ms_implib_p "$1" ||
49382f60eb46Smrg	   func_cygming_gnu_implib_p "$1"
49392f60eb46Smrg	then
49402f60eb46Smrg	  win32_nmres=import
49412f60eb46Smrg	else
49422f60eb46Smrg	  win32_nmres=
49432f60eb46Smrg	fi
49442f60eb46Smrg	;;
49452f60eb46Smrg      *)
49462f60eb46Smrg	func_to_tool_file "$1" func_convert_file_msys_to_w32
49472f60eb46Smrg	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
49482f60eb46Smrg	  $SED -n -e '
4949c3c9db83Smrg	    1,100{
4950c3c9db83Smrg		/ I /{
49512f60eb46Smrg		    s|.*|import|
4952c3c9db83Smrg		    p
4953c3c9db83Smrg		    q
4954c3c9db83Smrg		}
4955c3c9db83Smrg	    }'`
49562f60eb46Smrg	;;
49572f60eb46Smrg      esac
4958c3c9db83Smrg      case $win32_nmres in
4959c3c9db83Smrg      import*)  win32_libid_type="x86 archive import";;
4960c3c9db83Smrg      *)        win32_libid_type="x86 archive static";;
4961c3c9db83Smrg      esac
4962c3c9db83Smrg    fi
4963c3c9db83Smrg    ;;
4964c3c9db83Smrg  *DLL*)
4965c3c9db83Smrg    win32_libid_type="x86 DLL"
4966c3c9db83Smrg    ;;
4967c3c9db83Smrg  *executable*) # but shell scripts are "executable" too...
4968c3c9db83Smrg    case $win32_fileres in
4969c3c9db83Smrg    *MS\ Windows\ PE\ Intel*)
4970c3c9db83Smrg      win32_libid_type="x86 DLL"
4971c3c9db83Smrg      ;;
4972c3c9db83Smrg    esac
4973c3c9db83Smrg    ;;
4974c3c9db83Smrg  esac
4975c3c9db83Smrg  $ECHO "$win32_libid_type"
4976c3c9db83Smrg}
497785ee4c00Smrg
49783f6d0e1dSmrg# func_cygming_dll_for_implib ARG
49793f6d0e1dSmrg#
49803f6d0e1dSmrg# Platform-specific function to extract the
49813f6d0e1dSmrg# name of the DLL associated with the specified
49823f6d0e1dSmrg# import library ARG.
49833f6d0e1dSmrg# Invoked by eval'ing the libtool variable
49843f6d0e1dSmrg#    $sharedlib_from_linklib_cmd
49853f6d0e1dSmrg# Result is available in the variable
49863f6d0e1dSmrg#    $sharedlib_from_linklib_result
49873f6d0e1dSmrgfunc_cygming_dll_for_implib ()
49883f6d0e1dSmrg{
49892f60eb46Smrg  $debug_cmd
49902f60eb46Smrg
49913f6d0e1dSmrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
49923f6d0e1dSmrg}
49933f6d0e1dSmrg
49943f6d0e1dSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
49953f6d0e1dSmrg#
49963f6d0e1dSmrg# The is the core of a fallback implementation of a
49973f6d0e1dSmrg# platform-specific function to extract the name of the
49983f6d0e1dSmrg# DLL associated with the specified import library LIBNAME.
49993f6d0e1dSmrg#
50003f6d0e1dSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending
50013f6d0e1dSmrg# on the platform and compiler that created the implib.
50023f6d0e1dSmrg#
50033f6d0e1dSmrg# Echos the name of the DLL associated with the
50043f6d0e1dSmrg# specified import library.
50053f6d0e1dSmrgfunc_cygming_dll_for_implib_fallback_core ()
50063f6d0e1dSmrg{
50072f60eb46Smrg  $debug_cmd
50082f60eb46Smrg
50093f6d0e1dSmrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
50103f6d0e1dSmrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
50113f6d0e1dSmrg    $SED '/^Contents of section '"$match_literal"':/{
50123f6d0e1dSmrg      # Place marker at beginning of archive member dllname section
50133f6d0e1dSmrg      s/.*/====MARK====/
50143f6d0e1dSmrg      p
50153f6d0e1dSmrg      d
50163f6d0e1dSmrg    }
50173f6d0e1dSmrg    # These lines can sometimes be longer than 43 characters, but
50183f6d0e1dSmrg    # are always uninteresting
50193f6d0e1dSmrg    /:[	 ]*file format pe[i]\{,1\}-/d
50203f6d0e1dSmrg    /^In archive [^:]*:/d
50213f6d0e1dSmrg    # Ensure marker is printed
50223f6d0e1dSmrg    /^====MARK====/p
50233f6d0e1dSmrg    # Remove all lines with less than 43 characters
50243f6d0e1dSmrg    /^.\{43\}/!d
50253f6d0e1dSmrg    # From remaining lines, remove first 43 characters
50263f6d0e1dSmrg    s/^.\{43\}//' |
50273f6d0e1dSmrg    $SED -n '
50283f6d0e1dSmrg      # Join marker and all lines until next marker into a single line
50293f6d0e1dSmrg      /^====MARK====/ b para
50303f6d0e1dSmrg      H
50313f6d0e1dSmrg      $ b para
50323f6d0e1dSmrg      b
50333f6d0e1dSmrg      :para
50343f6d0e1dSmrg      x
50353f6d0e1dSmrg      s/\n//g
50363f6d0e1dSmrg      # Remove the marker
50373f6d0e1dSmrg      s/^====MARK====//
50383f6d0e1dSmrg      # Remove trailing dots and whitespace
50393f6d0e1dSmrg      s/[\. \t]*$//
50403f6d0e1dSmrg      # Print
50413f6d0e1dSmrg      /./p' |
50423f6d0e1dSmrg    # we now have a list, one entry per line, of the stringified
50433f6d0e1dSmrg    # contents of the appropriate section of all members of the
50442f60eb46Smrg    # archive that possess that section. Heuristic: eliminate
50452f60eb46Smrg    # all those that have a first or second character that is
50463f6d0e1dSmrg    # a '.' (that is, objdump's representation of an unprintable
50473f6d0e1dSmrg    # character.) This should work for all archives with less than
50483f6d0e1dSmrg    # 0x302f exports -- but will fail for DLLs whose name actually
50493f6d0e1dSmrg    # begins with a literal '.' or a single character followed by
50503f6d0e1dSmrg    # a '.'.
50513f6d0e1dSmrg    #
50523f6d0e1dSmrg    # Of those that remain, print the first one.
50533f6d0e1dSmrg    $SED -e '/^\./d;/^.\./d;q'
50543f6d0e1dSmrg}
50553f6d0e1dSmrg
50563f6d0e1dSmrg# func_cygming_dll_for_implib_fallback ARG
50573f6d0e1dSmrg# Platform-specific function to extract the
50583f6d0e1dSmrg# name of the DLL associated with the specified
50593f6d0e1dSmrg# import library ARG.
50603f6d0e1dSmrg#
50613f6d0e1dSmrg# This fallback implementation is for use when $DLLTOOL
50623f6d0e1dSmrg# does not support the --identify-strict option.
50633f6d0e1dSmrg# Invoked by eval'ing the libtool variable
50643f6d0e1dSmrg#    $sharedlib_from_linklib_cmd
50653f6d0e1dSmrg# Result is available in the variable
50663f6d0e1dSmrg#    $sharedlib_from_linklib_result
50673f6d0e1dSmrgfunc_cygming_dll_for_implib_fallback ()
50683f6d0e1dSmrg{
50692f60eb46Smrg  $debug_cmd
50702f60eb46Smrg
50712f60eb46Smrg  if func_cygming_gnu_implib_p "$1"; then
50723f6d0e1dSmrg    # binutils import library
50733f6d0e1dSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
50742f60eb46Smrg  elif func_cygming_ms_implib_p "$1"; then
50753f6d0e1dSmrg    # ms-generated import library
50763f6d0e1dSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
50773f6d0e1dSmrg  else
50783f6d0e1dSmrg    # unknown
50792f60eb46Smrg    sharedlib_from_linklib_result=
50803f6d0e1dSmrg  fi
50813f6d0e1dSmrg}
508285ee4c00Smrg
508385ee4c00Smrg
5084c3c9db83Smrg# func_extract_an_archive dir oldlib
5085c3c9db83Smrgfunc_extract_an_archive ()
5086c3c9db83Smrg{
50872f60eb46Smrg    $debug_cmd
50882f60eb46Smrg
50892f60eb46Smrg    f_ex_an_ar_dir=$1; shift
50902f60eb46Smrg    f_ex_an_ar_oldlib=$1
50912f60eb46Smrg    if test yes = "$lock_old_archive_extraction"; then
50923f6d0e1dSmrg      lockfile=$f_ex_an_ar_oldlib.lock
50933f6d0e1dSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
50943f6d0e1dSmrg	func_echo "Waiting for $lockfile to be removed"
50953f6d0e1dSmrg	sleep 2
50963f6d0e1dSmrg      done
50973f6d0e1dSmrg    fi
50983f6d0e1dSmrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
50993f6d0e1dSmrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
51002f60eb46Smrg    if test yes = "$lock_old_archive_extraction"; then
51013f6d0e1dSmrg      $opt_dry_run || rm -f "$lockfile"
51023f6d0e1dSmrg    fi
5103c3c9db83Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
5104c3c9db83Smrg     :
5105c3c9db83Smrg    else
5106c3c9db83Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
5107c3c9db83Smrg    fi
5108c3c9db83Smrg}
5109692f60a7Smrg
5110692f60a7Smrg
5111c3c9db83Smrg# func_extract_archives gentop oldlib ...
5112c3c9db83Smrgfunc_extract_archives ()
5113c3c9db83Smrg{
51142f60eb46Smrg    $debug_cmd
51152f60eb46Smrg
51162f60eb46Smrg    my_gentop=$1; shift
5117c3c9db83Smrg    my_oldlibs=${1+"$@"}
51182f60eb46Smrg    my_oldobjs=
51192f60eb46Smrg    my_xlib=
51202f60eb46Smrg    my_xabs=
51212f60eb46Smrg    my_xdir=
5122692f60a7Smrg
5123c3c9db83Smrg    for my_xlib in $my_oldlibs; do
5124c3c9db83Smrg      # Extract the objects.
5125c3c9db83Smrg      case $my_xlib in
51262f60eb46Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
5127c3c9db83Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
5128c3c9db83Smrg      esac
5129c3c9db83Smrg      func_basename "$my_xlib"
51302f60eb46Smrg      my_xlib=$func_basename_result
5131c3c9db83Smrg      my_xlib_u=$my_xlib
5132c3c9db83Smrg      while :; do
5133c3c9db83Smrg        case " $extracted_archives " in
5134c3c9db83Smrg	*" $my_xlib_u "*)
5135c3c9db83Smrg	  func_arith $extracted_serial + 1
5136c3c9db83Smrg	  extracted_serial=$func_arith_result
5137c3c9db83Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
5138c3c9db83Smrg	*) break ;;
5139c3c9db83Smrg	esac
5140c3c9db83Smrg      done
5141c3c9db83Smrg      extracted_archives="$extracted_archives $my_xlib_u"
51422f60eb46Smrg      my_xdir=$my_gentop/$my_xlib_u
5143692f60a7Smrg
5144c3c9db83Smrg      func_mkdir_p "$my_xdir"
514585ee4c00Smrg
5146c3c9db83Smrg      case $host in
5147c3c9db83Smrg      *-darwin*)
5148c3c9db83Smrg	func_verbose "Extracting $my_xabs"
5149c3c9db83Smrg	# Do not bother doing anything if just a dry run
5150c3c9db83Smrg	$opt_dry_run || {
5151c3c9db83Smrg	  darwin_orig_dir=`pwd`
5152c3c9db83Smrg	  cd $my_xdir || exit $?
5153c3c9db83Smrg	  darwin_archive=$my_xabs
5154c3c9db83Smrg	  darwin_curdir=`pwd`
51552f60eb46Smrg	  func_basename "$darwin_archive"
51562f60eb46Smrg	  darwin_base_archive=$func_basename_result
5157c3c9db83Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
5158c3c9db83Smrg	  if test -n "$darwin_arches"; then
5159c3c9db83Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
5160c3c9db83Smrg	    darwin_arch=
5161c3c9db83Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
51622f60eb46Smrg	    for darwin_arch in  $darwin_arches; do
51632f60eb46Smrg	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
51642f60eb46Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
51652f60eb46Smrg	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
51662f60eb46Smrg	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
5167c3c9db83Smrg	      cd "$darwin_curdir"
51682f60eb46Smrg	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
5169c3c9db83Smrg	    done # $darwin_arches
5170c3c9db83Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
51712f60eb46Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
5172c3c9db83Smrg	    darwin_file=
5173c3c9db83Smrg	    darwin_files=
5174c3c9db83Smrg	    for darwin_file in $darwin_filelist; do
51753f6d0e1dSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
5176c3c9db83Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
5177c3c9db83Smrg	    done # $darwin_filelist
5178c3c9db83Smrg	    $RM -rf unfat-$$
5179c3c9db83Smrg	    cd "$darwin_orig_dir"
51802e71ea71Smrg	  else
5181c3c9db83Smrg	    cd $darwin_orig_dir
5182c3c9db83Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
5183c3c9db83Smrg	  fi # $darwin_arches
5184c3c9db83Smrg	} # !$opt_dry_run
5185c3c9db83Smrg	;;
5186c3c9db83Smrg      *)
5187c3c9db83Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
5188c3c9db83Smrg	;;
5189c3c9db83Smrg      esac
51903f6d0e1dSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
5191c3c9db83Smrg    done
5192692f60a7Smrg
51932f60eb46Smrg    func_extract_archives_result=$my_oldobjs
5194c3c9db83Smrg}
5195692f60a7Smrg
5196692f60a7Smrg
51973f6d0e1dSmrg# func_emit_wrapper [arg=no]
51983f6d0e1dSmrg#
51993f6d0e1dSmrg# Emit a libtool wrapper script on stdout.
52003f6d0e1dSmrg# Don't directly open a file because we may want to
52013f6d0e1dSmrg# incorporate the script contents within a cygwin/mingw
52023f6d0e1dSmrg# wrapper executable.  Must ONLY be called from within
52033f6d0e1dSmrg# func_mode_link because it depends on a number of variables
52043f6d0e1dSmrg# set therein.
5205c3c9db83Smrg#
52063f6d0e1dSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
52073f6d0e1dSmrg# variable will take.  If 'yes', then the emitted script
52082f60eb46Smrg# will assume that the directory where it is stored is
52093f6d0e1dSmrg# the $objdir directory.  This is a cygwin/mingw-specific
52103f6d0e1dSmrg# behavior.
52113f6d0e1dSmrgfunc_emit_wrapper ()
5212c3c9db83Smrg{
52133f6d0e1dSmrg	func_emit_wrapper_arg1=${1-no}
52142e71ea71Smrg
5215c3c9db83Smrg	$ECHO "\
5216c3c9db83Smrg#! $SHELL
5217692f60a7Smrg
5218c3c9db83Smrg# $output - temporary wrapper script for $objdir/$outputname
52192f60eb46Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5220c3c9db83Smrg#
5221c3c9db83Smrg# The $output program cannot be directly executed until all the libtool
5222c3c9db83Smrg# libraries that it depends on are installed.
5223c3c9db83Smrg#
5224c3c9db83Smrg# This wrapper script should never be moved out of the build directory.
5225c3c9db83Smrg# If it is, it will not operate correctly.
5226692f60a7Smrg
5227c3c9db83Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
5228c3c9db83Smrg# metacharacters that are still active within double-quoted strings.
5229c3c9db83Smrgsed_quote_subst='$sed_quote_subst'
5230692f60a7Smrg
5231c3c9db83Smrg# Be Bourne compatible
5232c3c9db83Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5233c3c9db83Smrg  emulate sh
5234c3c9db83Smrg  NULLCMD=:
5235c3c9db83Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5236c3c9db83Smrg  # is contrary to our usage.  Disable this feature.
5237c3c9db83Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
5238c3c9db83Smrg  setopt NO_GLOB_SUBST
5239c3c9db83Smrgelse
5240c3c9db83Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5241c3c9db83Smrgfi
5242c3c9db83SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
5243c3c9db83SmrgDUALCASE=1; export DUALCASE # for MKS sh
5244692f60a7Smrg
5245c3c9db83Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
5246c3c9db83Smrg# if CDPATH is set.
5247c3c9db83Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5248692f60a7Smrg
5249c3c9db83Smrgrelink_command=\"$relink_command\"
5250692f60a7Smrg
5251c3c9db83Smrg# This environment variable determines our operation mode.
5252c3c9db83Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
5253c3c9db83Smrg  # install mode needs the following variables:
5254c3c9db83Smrg  generated_by_libtool_version='$macro_version'
5255c3c9db83Smrg  notinst_deplibs='$notinst_deplibs'
5256c3c9db83Smrgelse
5257c3c9db83Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
5258c3c9db83Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
52593f6d0e1dSmrg    file=\"\$0\""
52603f6d0e1dSmrg
52613f6d0e1dSmrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
52623f6d0e1dSmrg    $ECHO "\
52633f6d0e1dSmrg
52643f6d0e1dSmrg# A function that is used when there is no print builtin or printf.
52653f6d0e1dSmrgfunc_fallback_echo ()
52663f6d0e1dSmrg{
52673f6d0e1dSmrg  eval 'cat <<_LTECHO_EOF
52683f6d0e1dSmrg\$1
52693f6d0e1dSmrg_LTECHO_EOF'
52703f6d0e1dSmrg}
52713f6d0e1dSmrg    ECHO=\"$qECHO\"
52723f6d0e1dSmrg  fi
52733f6d0e1dSmrg
52743f6d0e1dSmrg# Very basic option parsing. These options are (a) specific to
52753f6d0e1dSmrg# the libtool wrapper, (b) are identical between the wrapper
52762f60eb46Smrg# /script/ and the wrapper /executable/ that is used only on
52773f6d0e1dSmrg# windows platforms, and (c) all begin with the string "--lt-"
52782f60eb46Smrg# (application programs are unlikely to have options that match
52793f6d0e1dSmrg# this pattern).
52803f6d0e1dSmrg#
52813f6d0e1dSmrg# There are only two supported options: --lt-debug and
52823f6d0e1dSmrg# --lt-dump-script. There is, deliberately, no --lt-help.
52833f6d0e1dSmrg#
52843f6d0e1dSmrg# The first argument to this parsing function should be the
52853f6d0e1dSmrg# script's $0 value, followed by "$@".
52863f6d0e1dSmrglt_option_debug=
52873f6d0e1dSmrgfunc_parse_lt_options ()
52883f6d0e1dSmrg{
52893f6d0e1dSmrg  lt_script_arg0=\$0
52903f6d0e1dSmrg  shift
52913f6d0e1dSmrg  for lt_opt
52923f6d0e1dSmrg  do
52933f6d0e1dSmrg    case \"\$lt_opt\" in
52943f6d0e1dSmrg    --lt-debug) lt_option_debug=1 ;;
52953f6d0e1dSmrg    --lt-dump-script)
52963f6d0e1dSmrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
52973f6d0e1dSmrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
52983f6d0e1dSmrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
52993f6d0e1dSmrg        cat \"\$lt_dump_D/\$lt_dump_F\"
53003f6d0e1dSmrg        exit 0
53013f6d0e1dSmrg      ;;
53023f6d0e1dSmrg    --lt-*)
53033f6d0e1dSmrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
53043f6d0e1dSmrg        exit 1
53053f6d0e1dSmrg      ;;
53063f6d0e1dSmrg    esac
53073f6d0e1dSmrg  done
53083f6d0e1dSmrg
53093f6d0e1dSmrg  # Print the debug banner immediately:
53103f6d0e1dSmrg  if test -n \"\$lt_option_debug\"; then
53112f60eb46Smrg    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
53123f6d0e1dSmrg  fi
53133f6d0e1dSmrg}
53143f6d0e1dSmrg
53153f6d0e1dSmrg# Used when --lt-debug. Prints its arguments to stdout
53163f6d0e1dSmrg# (redirection is the responsibility of the caller)
53173f6d0e1dSmrgfunc_lt_dump_args ()
53183f6d0e1dSmrg{
53193f6d0e1dSmrg  lt_dump_args_N=1;
53203f6d0e1dSmrg  for lt_arg
53213f6d0e1dSmrg  do
53222f60eb46Smrg    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
53233f6d0e1dSmrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
53243f6d0e1dSmrg  done
53253f6d0e1dSmrg}
53263f6d0e1dSmrg
53273f6d0e1dSmrg# Core function for launching the target application
53283f6d0e1dSmrgfunc_exec_program_core ()
53293f6d0e1dSmrg{
5330c3c9db83Smrg"
53313f6d0e1dSmrg  case $host in
53323f6d0e1dSmrg  # Backslashes separate directories on plain windows
53333f6d0e1dSmrg  *-*-mingw | *-*-os2* | *-cegcc*)
53343f6d0e1dSmrg    $ECHO "\
53353f6d0e1dSmrg      if test -n \"\$lt_option_debug\"; then
53362f60eb46Smrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
53373f6d0e1dSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
53383f6d0e1dSmrg      fi
53393f6d0e1dSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
53403f6d0e1dSmrg"
53413f6d0e1dSmrg    ;;
53423f6d0e1dSmrg
53433f6d0e1dSmrg  *)
53443f6d0e1dSmrg    $ECHO "\
53453f6d0e1dSmrg      if test -n \"\$lt_option_debug\"; then
53462f60eb46Smrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
53473f6d0e1dSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
53483f6d0e1dSmrg      fi
53493f6d0e1dSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
53503f6d0e1dSmrg"
53513f6d0e1dSmrg    ;;
53523f6d0e1dSmrg  esac
53533f6d0e1dSmrg  $ECHO "\
53543f6d0e1dSmrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
53553f6d0e1dSmrg      exit 1
53563f6d0e1dSmrg}
53573f6d0e1dSmrg
53583f6d0e1dSmrg# A function to encapsulate launching the target application
53593f6d0e1dSmrg# Strips options in the --lt-* namespace from \$@ and
53603f6d0e1dSmrg# launches target application with the remaining arguments.
53613f6d0e1dSmrgfunc_exec_program ()
53623f6d0e1dSmrg{
536395903e71Smrg  case \" \$* \" in
536495903e71Smrg  *\\ --lt-*)
536595903e71Smrg    for lt_wr_arg
536695903e71Smrg    do
536795903e71Smrg      case \$lt_wr_arg in
536895903e71Smrg      --lt-*) ;;
536995903e71Smrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
537095903e71Smrg      esac
537195903e71Smrg      shift
537295903e71Smrg    done ;;
537395903e71Smrg  esac
53743f6d0e1dSmrg  func_exec_program_core \${1+\"\$@\"}
53753f6d0e1dSmrg}
53763f6d0e1dSmrg
53773f6d0e1dSmrg  # Parse options
53783f6d0e1dSmrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
5379692f60a7Smrg
5380c3c9db83Smrg  # Find the directory that this script lives in.
53813f6d0e1dSmrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
5382c3c9db83Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
5383692f60a7Smrg
5384c3c9db83Smrg  # Follow symbolic links until we get to the real thisdir.
53853f6d0e1dSmrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
5386c3c9db83Smrg  while test -n \"\$file\"; do
53873f6d0e1dSmrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
5388692f60a7Smrg
5389c3c9db83Smrg    # If there was a directory component, then change thisdir.
5390c3c9db83Smrg    if test \"x\$destdir\" != \"x\$file\"; then
5391c3c9db83Smrg      case \"\$destdir\" in
5392c3c9db83Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5393c3c9db83Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
53942e71ea71Smrg      esac
5395c3c9db83Smrg    fi
5396692f60a7Smrg
53973f6d0e1dSmrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
53983f6d0e1dSmrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
5399c3c9db83Smrg  done
5400692f60a7Smrg
5401c3c9db83Smrg  # Usually 'no', except on cygwin/mingw when embedded into
5402c3c9db83Smrg  # the cwrapper.
54033f6d0e1dSmrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
5404c3c9db83Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
5405c3c9db83Smrg    # special case for '.'
5406c3c9db83Smrg    if test \"\$thisdir\" = \".\"; then
5407c3c9db83Smrg      thisdir=\`pwd\`
5408c3c9db83Smrg    fi
5409c3c9db83Smrg    # remove .libs from thisdir
5410c3c9db83Smrg    case \"\$thisdir\" in
54113f6d0e1dSmrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
5412c3c9db83Smrg    $objdir )   thisdir=. ;;
5413c3c9db83Smrg    esac
5414c3c9db83Smrg  fi
5415c3c9db83Smrg
5416c3c9db83Smrg  # Try to get the absolute directory name.
5417c3c9db83Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
5418c3c9db83Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
5419c3c9db83Smrg"
5420c3c9db83Smrg
54212f60eb46Smrg	if test yes = "$fast_install"; then
5422c3c9db83Smrg	  $ECHO "\
5423c3c9db83Smrg  program=lt-'$outputname'$exeext
5424c3c9db83Smrg  progdir=\"\$thisdir/$objdir\"
5425c3c9db83Smrg
5426c3c9db83Smrg  if test ! -f \"\$progdir/\$program\" ||
54272f60eb46Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
5428c3c9db83Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
5429c3c9db83Smrg
5430c3c9db83Smrg    file=\"\$\$-\$program\"
5431c3c9db83Smrg
5432c3c9db83Smrg    if test ! -d \"\$progdir\"; then
5433c3c9db83Smrg      $MKDIR \"\$progdir\"
5434c3c9db83Smrg    else
5435c3c9db83Smrg      $RM \"\$progdir/\$file\"
5436c3c9db83Smrg    fi"
5437c3c9db83Smrg
5438c3c9db83Smrg	  $ECHO "\
5439c3c9db83Smrg
5440c3c9db83Smrg    # relink executable if necessary
5441c3c9db83Smrg    if test -n \"\$relink_command\"; then
5442c3c9db83Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5443c3c9db83Smrg      else
54442f60eb46Smrg	\$ECHO \"\$relink_command_output\" >&2
5445c3c9db83Smrg	$RM \"\$progdir/\$file\"
5446c3c9db83Smrg	exit 1
54472e71ea71Smrg      fi
5448c3c9db83Smrg    fi
5449692f60a7Smrg
5450c3c9db83Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5451c3c9db83Smrg    { $RM \"\$progdir/\$program\";
5452c3c9db83Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5453c3c9db83Smrg    $RM \"\$progdir/\$file\"
5454c3c9db83Smrg  fi"
5455c3c9db83Smrg	else
5456c3c9db83Smrg	  $ECHO "\
5457c3c9db83Smrg  program='$outputname'
5458c3c9db83Smrg  progdir=\"\$thisdir/$objdir\"
5459c3c9db83Smrg"
54602e71ea71Smrg	fi
5461692f60a7Smrg
5462c3c9db83Smrg	$ECHO "\
5463692f60a7Smrg
5464c3c9db83Smrg  if test -f \"\$progdir/\$program\"; then"
5465692f60a7Smrg
54663f6d0e1dSmrg	# fixup the dll searchpath if we need to.
54673f6d0e1dSmrg	#
54683f6d0e1dSmrg	# Fix the DLL searchpath if we need to.  Do this before prepending
54693f6d0e1dSmrg	# to shlibpath, because on Windows, both are PATH and uninstalled
54703f6d0e1dSmrg	# libraries must come first.
54713f6d0e1dSmrg	if test -n "$dllsearchpath"; then
54723f6d0e1dSmrg	  $ECHO "\
54733f6d0e1dSmrg    # Add the dll search path components to the executable PATH
54743f6d0e1dSmrg    PATH=$dllsearchpath:\$PATH
54753f6d0e1dSmrg"
54763f6d0e1dSmrg	fi
54773f6d0e1dSmrg
5478c3c9db83Smrg	# Export our shlibpath_var if we have one.
54792f60eb46Smrg	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5480c3c9db83Smrg	  $ECHO "\
5481c3c9db83Smrg    # Add our own library path to $shlibpath_var
5482c3c9db83Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
5483c3c9db83Smrg
5484c3c9db83Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
5485c3c9db83Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
54863f6d0e1dSmrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
5487692f60a7Smrg
5488c3c9db83Smrg    export $shlibpath_var
5489c3c9db83Smrg"
54902e71ea71Smrg	fi
5491692f60a7Smrg
5492c3c9db83Smrg	$ECHO "\
5493c3c9db83Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
5494c3c9db83Smrg      # Run the actual program with our arguments.
54953f6d0e1dSmrg      func_exec_program \${1+\"\$@\"}
5496c3c9db83Smrg    fi
5497c3c9db83Smrg  else
5498c3c9db83Smrg    # The program doesn't exist.
54992f60eb46Smrg    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
5500c3c9db83Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
55013f6d0e1dSmrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
5502c3c9db83Smrg    exit 1
5503c3c9db83Smrg  fi
5504c3c9db83Smrgfi\
5505c3c9db83Smrg"
5506c3c9db83Smrg}
5507692f60a7Smrg
550885ee4c00Smrg
5509c3c9db83Smrg# func_emit_cwrapperexe_src
5510c3c9db83Smrg# emit the source code for a wrapper executable on stdout
5511c3c9db83Smrg# Must ONLY be called from within func_mode_link because
5512c3c9db83Smrg# it depends on a number of variable set therein.
5513c3c9db83Smrgfunc_emit_cwrapperexe_src ()
5514c3c9db83Smrg{
5515c3c9db83Smrg	cat <<EOF
5516692f60a7Smrg
5517c3c9db83Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
55182f60eb46Smrg   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5519692f60a7Smrg
5520c3c9db83Smrg   The $output program cannot be directly executed until all the libtool
5521c3c9db83Smrg   libraries that it depends on are installed.
5522692f60a7Smrg
5523c3c9db83Smrg   This wrapper executable should never be moved out of the build directory.
5524c3c9db83Smrg   If it is, it will not operate correctly.
5525c3c9db83Smrg*/
5526c3c9db83SmrgEOF
5527c3c9db83Smrg	    cat <<"EOF"
55283f6d0e1dSmrg#ifdef _MSC_VER
55293f6d0e1dSmrg# define _CRT_SECURE_NO_DEPRECATE 1
55303f6d0e1dSmrg#endif
5531c3c9db83Smrg#include <stdio.h>
5532c3c9db83Smrg#include <stdlib.h>
5533c3c9db83Smrg#ifdef _MSC_VER
5534c3c9db83Smrg# include <direct.h>
5535c3c9db83Smrg# include <process.h>
5536c3c9db83Smrg# include <io.h>
5537c3c9db83Smrg#else
5538c3c9db83Smrg# include <unistd.h>
5539c3c9db83Smrg# include <stdint.h>
5540c3c9db83Smrg# ifdef __CYGWIN__
5541c3c9db83Smrg#  include <io.h>
5542c3c9db83Smrg# endif
5543c3c9db83Smrg#endif
5544c3c9db83Smrg#include <malloc.h>
5545c3c9db83Smrg#include <stdarg.h>
5546c3c9db83Smrg#include <assert.h>
5547c3c9db83Smrg#include <string.h>
5548c3c9db83Smrg#include <ctype.h>
5549c3c9db83Smrg#include <errno.h>
5550c3c9db83Smrg#include <fcntl.h>
5551c3c9db83Smrg#include <sys/stat.h>
5552692f60a7Smrg
55532f60eb46Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
55542f60eb46Smrg
55553f6d0e1dSmrg/* declarations of non-ANSI functions */
55562f60eb46Smrg#if defined __MINGW32__
55573f6d0e1dSmrg# ifdef __STRICT_ANSI__
55583f6d0e1dSmrgint _putenv (const char *);
55593f6d0e1dSmrg# endif
55602f60eb46Smrg#elif defined __CYGWIN__
55613f6d0e1dSmrg# ifdef __STRICT_ANSI__
55623f6d0e1dSmrgchar *realpath (const char *, char *);
55633f6d0e1dSmrgint putenv (char *);
55643f6d0e1dSmrgint setenv (const char *, const char *, int);
55653f6d0e1dSmrg# endif
55662f60eb46Smrg/* #elif defined other_platform || defined ... */
55673f6d0e1dSmrg#endif
55683f6d0e1dSmrg
55693f6d0e1dSmrg/* portability defines, excluding path handling macros */
55702f60eb46Smrg#if defined _MSC_VER
55713f6d0e1dSmrg# define setmode _setmode
55723f6d0e1dSmrg# define stat    _stat
55733f6d0e1dSmrg# define chmod   _chmod
55743f6d0e1dSmrg# define getcwd  _getcwd
55753f6d0e1dSmrg# define putenv  _putenv
55763f6d0e1dSmrg# define S_IXUSR _S_IEXEC
55772f60eb46Smrg#elif defined __MINGW32__
55783f6d0e1dSmrg# define setmode _setmode
55793f6d0e1dSmrg# define stat    _stat
55803f6d0e1dSmrg# define chmod   _chmod
55813f6d0e1dSmrg# define getcwd  _getcwd
55823f6d0e1dSmrg# define putenv  _putenv
55832f60eb46Smrg#elif defined __CYGWIN__
55843f6d0e1dSmrg# define HAVE_SETENV
55853f6d0e1dSmrg# define FOPEN_WB "wb"
55862f60eb46Smrg/* #elif defined other platforms ... */
55873f6d0e1dSmrg#endif
55883f6d0e1dSmrg
55892f60eb46Smrg#if defined PATH_MAX
5590c3c9db83Smrg# define LT_PATHMAX PATH_MAX
55912f60eb46Smrg#elif defined MAXPATHLEN
5592c3c9db83Smrg# define LT_PATHMAX MAXPATHLEN
5593c3c9db83Smrg#else
5594c3c9db83Smrg# define LT_PATHMAX 1024
5595c3c9db83Smrg#endif
5596692f60a7Smrg
5597c3c9db83Smrg#ifndef S_IXOTH
5598c3c9db83Smrg# define S_IXOTH 0
5599c3c9db83Smrg#endif
5600c3c9db83Smrg#ifndef S_IXGRP
5601c3c9db83Smrg# define S_IXGRP 0
5602c3c9db83Smrg#endif
5603692f60a7Smrg
56043f6d0e1dSmrg/* path handling portability macros */
5605c3c9db83Smrg#ifndef DIR_SEPARATOR
5606c3c9db83Smrg# define DIR_SEPARATOR '/'
5607c3c9db83Smrg# define PATH_SEPARATOR ':'
5608c3c9db83Smrg#endif
5609692f60a7Smrg
56102f60eb46Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
56112f60eb46Smrg  defined __OS2__
5612c3c9db83Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
5613c3c9db83Smrg# define FOPEN_WB "wb"
5614c3c9db83Smrg# ifndef DIR_SEPARATOR_2
5615c3c9db83Smrg#  define DIR_SEPARATOR_2 '\\'
5616c3c9db83Smrg# endif
5617c3c9db83Smrg# ifndef PATH_SEPARATOR_2
5618c3c9db83Smrg#  define PATH_SEPARATOR_2 ';'
5619c3c9db83Smrg# endif
5620c3c9db83Smrg#endif
5621692f60a7Smrg
5622c3c9db83Smrg#ifndef DIR_SEPARATOR_2
5623c3c9db83Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
5624c3c9db83Smrg#else /* DIR_SEPARATOR_2 */
5625c3c9db83Smrg# define IS_DIR_SEPARATOR(ch) \
5626c3c9db83Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
5627c3c9db83Smrg#endif /* DIR_SEPARATOR_2 */
5628692f60a7Smrg
5629c3c9db83Smrg#ifndef PATH_SEPARATOR_2
5630c3c9db83Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5631c3c9db83Smrg#else /* PATH_SEPARATOR_2 */
5632c3c9db83Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5633c3c9db83Smrg#endif /* PATH_SEPARATOR_2 */
5634692f60a7Smrg
5635c3c9db83Smrg#ifndef FOPEN_WB
5636c3c9db83Smrg# define FOPEN_WB "w"
5637c3c9db83Smrg#endif
5638c3c9db83Smrg#ifndef _O_BINARY
5639c3c9db83Smrg# define _O_BINARY 0
5640c3c9db83Smrg#endif
5641692f60a7Smrg
5642c3c9db83Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
5643c3c9db83Smrg#define XFREE(stale) do { \
56442f60eb46Smrg  if (stale) { free (stale); stale = 0; } \
5645c3c9db83Smrg} while (0)
5646692f60a7Smrg
56472f60eb46Smrg#if defined LT_DEBUGWRAPPER
56483f6d0e1dSmrgstatic int lt_debug = 1;
5649c3c9db83Smrg#else
56503f6d0e1dSmrgstatic int lt_debug = 0;
5651c3c9db83Smrg#endif
5652692f60a7Smrg
56533f6d0e1dSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
5654692f60a7Smrg
5655c3c9db83Smrgvoid *xmalloc (size_t num);
5656c3c9db83Smrgchar *xstrdup (const char *string);
5657c3c9db83Smrgconst char *base_name (const char *name);
5658c3c9db83Smrgchar *find_executable (const char *wrapper);
5659c3c9db83Smrgchar *chase_symlinks (const char *pathspec);
5660c3c9db83Smrgint make_executable (const char *path);
5661c3c9db83Smrgint check_executable (const char *path);
5662c3c9db83Smrgchar *strendzap (char *str, const char *pat);
56633f6d0e1dSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
56643f6d0e1dSmrgvoid lt_fatal (const char *file, int line, const char *message, ...);
56653f6d0e1dSmrgstatic const char *nonnull (const char *s);
56663f6d0e1dSmrgstatic const char *nonempty (const char *s);
5667c3c9db83Smrgvoid lt_setenv (const char *name, const char *value);
5668c3c9db83Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
5669c3c9db83Smrgvoid lt_update_exe_path (const char *name, const char *value);
5670c3c9db83Smrgvoid lt_update_lib_path (const char *name, const char *value);
56713f6d0e1dSmrgchar **prepare_spawn (char **argv);
56723f6d0e1dSmrgvoid lt_dump_script (FILE *f);
5673c3c9db83SmrgEOF
5674c3c9db83Smrg
5675c3c9db83Smrg	    cat <<EOF
56762f60eb46Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
56772f60eb46Smrg# define externally_visible volatile
56782f60eb46Smrg#else
56792f60eb46Smrg# define externally_visible __attribute__((externally_visible)) volatile
56802f60eb46Smrg#endif
56812f60eb46Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe";
5682c3c9db83Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
5683c3c9db83SmrgEOF
5684692f60a7Smrg
56852f60eb46Smrg	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
56863f6d0e1dSmrg              func_to_host_path "$temp_rpath"
5687c3c9db83Smrg	      cat <<EOF
56883f6d0e1dSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
5689c3c9db83SmrgEOF
5690c3c9db83Smrg	    else
5691c3c9db83Smrg	      cat <<"EOF"
5692c3c9db83Smrgconst char * LIB_PATH_VALUE   = "";
5693c3c9db83SmrgEOF
56942e71ea71Smrg	    fi
5695692f60a7Smrg
5696c3c9db83Smrg	    if test -n "$dllsearchpath"; then
56973f6d0e1dSmrg              func_to_host_path "$dllsearchpath:"
5698c3c9db83Smrg	      cat <<EOF
5699c3c9db83Smrgconst char * EXE_PATH_VARNAME = "PATH";
57003f6d0e1dSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
57012e71ea71SmrgEOF
57022e71ea71Smrg	    else
5703c3c9db83Smrg	      cat <<"EOF"
5704c3c9db83Smrgconst char * EXE_PATH_VARNAME = "";
5705c3c9db83Smrgconst char * EXE_PATH_VALUE   = "";
5706c3c9db83SmrgEOF
57072e71ea71Smrg	    fi
5708c3c9db83Smrg
57092f60eb46Smrg	    if test yes = "$fast_install"; then
5710c3c9db83Smrg	      cat <<EOF
5711c3c9db83Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
5712c3c9db83SmrgEOF
57132e71ea71Smrg	    else
5714c3c9db83Smrg	      cat <<EOF
5715c3c9db83Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
5716c3c9db83SmrgEOF
57172e71ea71Smrg	    fi
5718692f60a7Smrg
5719692f60a7Smrg
5720c3c9db83Smrg	    cat <<"EOF"
5721692f60a7Smrg
5722c3c9db83Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
5723692f60a7Smrg
5724c3c9db83Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
5725c3c9db83Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
57263f6d0e1dSmrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
5727692f60a7Smrg
5728c3c9db83Smrgint
5729c3c9db83Smrgmain (int argc, char *argv[])
5730c3c9db83Smrg{
5731c3c9db83Smrg  char **newargz;
5732c3c9db83Smrg  int  newargc;
5733c3c9db83Smrg  char *tmp_pathspec;
5734c3c9db83Smrg  char *actual_cwrapper_path;
5735c3c9db83Smrg  char *actual_cwrapper_name;
5736c3c9db83Smrg  char *target_name;
5737c3c9db83Smrg  char *lt_argv_zero;
57382f60eb46Smrg  int rval = 127;
5739692f60a7Smrg
5740c3c9db83Smrg  int i;
5741692f60a7Smrg
5742c3c9db83Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
57432f60eb46Smrg  newargz = XMALLOC (char *, (size_t) argc + 1);
5744692f60a7Smrg
57453f6d0e1dSmrg  /* very simple arg parsing; don't want to rely on getopt
57463f6d0e1dSmrg   * also, copy all non cwrapper options to newargz, except
57473f6d0e1dSmrg   * argz[0], which is handled differently
57483f6d0e1dSmrg   */
57493f6d0e1dSmrg  newargc=0;
5750c3c9db83Smrg  for (i = 1; i < argc; i++)
5751c3c9db83Smrg    {
57522f60eb46Smrg      if (STREQ (argv[i], dumpscript_opt))
5753c3c9db83Smrg	{
5754c3c9db83SmrgEOF
57552f60eb46Smrg	    case $host in
5756c3c9db83Smrg	      *mingw* | *cygwin* )
5757c3c9db83Smrg		# make stdout use "unix" line endings
5758c3c9db83Smrg		echo "          setmode(1,_O_BINARY);"
5759c3c9db83Smrg		;;
5760c3c9db83Smrg	      esac
5761692f60a7Smrg
5762c3c9db83Smrg	    cat <<"EOF"
57633f6d0e1dSmrg	  lt_dump_script (stdout);
5764c3c9db83Smrg	  return 0;
5765c3c9db83Smrg	}
57662f60eb46Smrg      if (STREQ (argv[i], debug_opt))
57673f6d0e1dSmrg	{
57683f6d0e1dSmrg          lt_debug = 1;
57693f6d0e1dSmrg          continue;
57703f6d0e1dSmrg	}
57712f60eb46Smrg      if (STREQ (argv[i], ltwrapper_option_prefix))
57723f6d0e1dSmrg        {
57733f6d0e1dSmrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
57743f6d0e1dSmrg             namespace, but it is not one of the ones we know about and
57753f6d0e1dSmrg             have already dealt with, above (inluding dump-script), then
57763f6d0e1dSmrg             report an error. Otherwise, targets might begin to believe
57773f6d0e1dSmrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
57783f6d0e1dSmrg             namespace. The first time any user complains about this, we'll
57793f6d0e1dSmrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
57803f6d0e1dSmrg             or a configure.ac-settable value.
57813f6d0e1dSmrg           */
57823f6d0e1dSmrg          lt_fatal (__FILE__, __LINE__,
57833f6d0e1dSmrg		    "unrecognized %s option: '%s'",
57843f6d0e1dSmrg                    ltwrapper_option_prefix, argv[i]);
57853f6d0e1dSmrg        }
57863f6d0e1dSmrg      /* otherwise ... */
57873f6d0e1dSmrg      newargz[++newargc] = xstrdup (argv[i]);
5788c3c9db83Smrg    }
57893f6d0e1dSmrg  newargz[++newargc] = NULL;
57903f6d0e1dSmrg
57913f6d0e1dSmrgEOF
57923f6d0e1dSmrg	    cat <<EOF
57933f6d0e1dSmrg  /* The GNU banner must be the first non-error debug message */
57942f60eb46Smrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
57953f6d0e1dSmrgEOF
57963f6d0e1dSmrg	    cat <<"EOF"
57973f6d0e1dSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
57983f6d0e1dSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
5799692f60a7Smrg
5800c3c9db83Smrg  tmp_pathspec = find_executable (argv[0]);
5801c3c9db83Smrg  if (tmp_pathspec == NULL)
58023f6d0e1dSmrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
58033f6d0e1dSmrg  lt_debugprintf (__FILE__, __LINE__,
58043f6d0e1dSmrg                  "(main) found exe (before symlink chase) at: %s\n",
58053f6d0e1dSmrg		  tmp_pathspec);
5806c3c9db83Smrg
5807c3c9db83Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
58083f6d0e1dSmrg  lt_debugprintf (__FILE__, __LINE__,
58093f6d0e1dSmrg                  "(main) found exe (after symlink chase) at: %s\n",
58103f6d0e1dSmrg		  actual_cwrapper_path);
5811c3c9db83Smrg  XFREE (tmp_pathspec);
5812c3c9db83Smrg
58133f6d0e1dSmrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
5814c3c9db83Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
5815c3c9db83Smrg
5816c3c9db83Smrg  /* wrapper name transforms */
5817c3c9db83Smrg  strendzap (actual_cwrapper_name, ".exe");
5818c3c9db83Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
5819c3c9db83Smrg  XFREE (actual_cwrapper_name);
5820c3c9db83Smrg  actual_cwrapper_name = tmp_pathspec;
5821c3c9db83Smrg  tmp_pathspec = 0;
5822c3c9db83Smrg
5823c3c9db83Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
5824c3c9db83Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
5825c3c9db83Smrg  strendzap (target_name, ".exe");
5826c3c9db83Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
5827c3c9db83Smrg  XFREE (target_name);
5828c3c9db83Smrg  target_name = tmp_pathspec;
5829c3c9db83Smrg  tmp_pathspec = 0;
5830c3c9db83Smrg
58313f6d0e1dSmrg  lt_debugprintf (__FILE__, __LINE__,
58323f6d0e1dSmrg		  "(main) libtool target name: %s\n",
58333f6d0e1dSmrg		  target_name);
5834c3c9db83SmrgEOF
5835692f60a7Smrg
5836c3c9db83Smrg	    cat <<EOF
5837c3c9db83Smrg  newargz[0] =
5838c3c9db83Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
5839c3c9db83Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
5840c3c9db83Smrg  strcpy (newargz[0], actual_cwrapper_path);
5841c3c9db83Smrg  strcat (newargz[0], "$objdir");
5842c3c9db83Smrg  strcat (newargz[0], "/");
5843c3c9db83SmrgEOF
5844692f60a7Smrg
5845c3c9db83Smrg	    cat <<"EOF"
5846c3c9db83Smrg  /* stop here, and copy so we don't have to do this twice */
5847c3c9db83Smrg  tmp_pathspec = xstrdup (newargz[0]);
5848692f60a7Smrg
5849c3c9db83Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
5850c3c9db83Smrg  strcat (newargz[0], actual_cwrapper_name);
5851692f60a7Smrg
5852c3c9db83Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
5853c3c9db83Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
5854c3c9db83Smrg  XFREE (tmp_pathspec);
5855c3c9db83Smrg  tmp_pathspec = NULL;
5856c3c9db83SmrgEOF
5857692f60a7Smrg
5858c3c9db83Smrg	    case $host_os in
5859c3c9db83Smrg	      mingw*)
5860c3c9db83Smrg	    cat <<"EOF"
5861c3c9db83Smrg  {
5862c3c9db83Smrg    char* p;
5863c3c9db83Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
5864c3c9db83Smrg      {
5865c3c9db83Smrg	*p = '/';
5866c3c9db83Smrg      }
5867c3c9db83Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
5868c3c9db83Smrg      {
5869c3c9db83Smrg	*p = '/';
5870c3c9db83Smrg      }
5871c3c9db83Smrg  }
5872c3c9db83SmrgEOF
5873c3c9db83Smrg	    ;;
5874c3c9db83Smrg	    esac
5875692f60a7Smrg
5876c3c9db83Smrg	    cat <<"EOF"
5877c3c9db83Smrg  XFREE (target_name);
5878c3c9db83Smrg  XFREE (actual_cwrapper_path);
5879c3c9db83Smrg  XFREE (actual_cwrapper_name);
5880692f60a7Smrg
5881c3c9db83Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
5882c3c9db83Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
58833f6d0e1dSmrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
58843f6d0e1dSmrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
58853f6d0e1dSmrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
58863f6d0e1dSmrg     libraries must come first. */
5887c3c9db83Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
58883f6d0e1dSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
5889692f60a7Smrg
58903f6d0e1dSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
58913f6d0e1dSmrg		  nonnull (lt_argv_zero));
5892c3c9db83Smrg  for (i = 0; i < newargc; i++)
5893c3c9db83Smrg    {
58943f6d0e1dSmrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
58953f6d0e1dSmrg		      i, nonnull (newargz[i]));
5896c3c9db83Smrg    }
5897692f60a7Smrg
5898c3c9db83SmrgEOF
5899692f60a7Smrg
5900c3c9db83Smrg	    case $host_os in
5901c3c9db83Smrg	      mingw*)
5902c3c9db83Smrg		cat <<"EOF"
5903c3c9db83Smrg  /* execv doesn't actually work on mingw as expected on unix */
59043f6d0e1dSmrg  newargz = prepare_spawn (newargz);
59052f60eb46Smrg  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
5906c3c9db83Smrg  if (rval == -1)
5907c3c9db83Smrg    {
5908c3c9db83Smrg      /* failed to start process */
59093f6d0e1dSmrg      lt_debugprintf (__FILE__, __LINE__,
59103f6d0e1dSmrg		      "(main) failed to launch target \"%s\": %s\n",
59113f6d0e1dSmrg		      lt_argv_zero, nonnull (strerror (errno)));
5912c3c9db83Smrg      return 127;
5913c3c9db83Smrg    }
5914c3c9db83Smrg  return rval;
5915c3c9db83SmrgEOF
5916c3c9db83Smrg		;;
5917c3c9db83Smrg	      *)
5918c3c9db83Smrg		cat <<"EOF"
5919c3c9db83Smrg  execv (lt_argv_zero, newargz);
5920c3c9db83Smrg  return rval; /* =127, but avoids unused variable warning */
5921c3c9db83SmrgEOF
5922c3c9db83Smrg		;;
5923c3c9db83Smrg	    esac
5924692f60a7Smrg
5925c3c9db83Smrg	    cat <<"EOF"
5926c3c9db83Smrg}
5927692f60a7Smrg
5928c3c9db83Smrgvoid *
5929c3c9db83Smrgxmalloc (size_t num)
5930c3c9db83Smrg{
5931c3c9db83Smrg  void *p = (void *) malloc (num);
5932c3c9db83Smrg  if (!p)
59333f6d0e1dSmrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
5934692f60a7Smrg
5935c3c9db83Smrg  return p;
5936c3c9db83Smrg}
5937692f60a7Smrg
5938c3c9db83Smrgchar *
5939c3c9db83Smrgxstrdup (const char *string)
5940c3c9db83Smrg{
5941c3c9db83Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
5942c3c9db83Smrg			  string) : NULL;
5943c3c9db83Smrg}
5944692f60a7Smrg
5945c3c9db83Smrgconst char *
5946c3c9db83Smrgbase_name (const char *name)
5947c3c9db83Smrg{
5948c3c9db83Smrg  const char *base;
59492e71ea71Smrg
59502f60eb46Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
5951c3c9db83Smrg  /* Skip over the disk name in MSDOS pathnames. */
5952c3c9db83Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
5953c3c9db83Smrg    name += 2;
5954c3c9db83Smrg#endif
59552e71ea71Smrg
5956c3c9db83Smrg  for (base = name; *name; name++)
5957c3c9db83Smrg    if (IS_DIR_SEPARATOR (*name))
5958c3c9db83Smrg      base = name + 1;
5959c3c9db83Smrg  return base;
5960c3c9db83Smrg}
59612e71ea71Smrg
5962c3c9db83Smrgint
5963c3c9db83Smrgcheck_executable (const char *path)
5964c3c9db83Smrg{
5965c3c9db83Smrg  struct stat st;
59662e71ea71Smrg
59673f6d0e1dSmrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
59683f6d0e1dSmrg                  nonempty (path));
5969c3c9db83Smrg  if ((!path) || (!*path))
5970c3c9db83Smrg    return 0;
59712e71ea71Smrg
5972c3c9db83Smrg  if ((stat (path, &st) >= 0)
5973c3c9db83Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
5974c3c9db83Smrg    return 1;
5975c3c9db83Smrg  else
5976c3c9db83Smrg    return 0;
5977c3c9db83Smrg}
5978692f60a7Smrg
5979c3c9db83Smrgint
5980c3c9db83Smrgmake_executable (const char *path)
5981c3c9db83Smrg{
5982c3c9db83Smrg  int rval = 0;
5983c3c9db83Smrg  struct stat st;
5984692f60a7Smrg
59853f6d0e1dSmrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
59863f6d0e1dSmrg                  nonempty (path));
5987c3c9db83Smrg  if ((!path) || (!*path))
5988c3c9db83Smrg    return 0;
598985ee4c00Smrg
5990c3c9db83Smrg  if (stat (path, &st) >= 0)
5991c3c9db83Smrg    {
5992c3c9db83Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
5993c3c9db83Smrg    }
5994c3c9db83Smrg  return rval;
5995c3c9db83Smrg}
59962e71ea71Smrg
5997c3c9db83Smrg/* Searches for the full path of the wrapper.  Returns
5998c3c9db83Smrg   newly allocated full path name if found, NULL otherwise
5999c3c9db83Smrg   Does not chase symlinks, even on platforms that support them.
6000c3c9db83Smrg*/
6001c3c9db83Smrgchar *
6002c3c9db83Smrgfind_executable (const char *wrapper)
6003c3c9db83Smrg{
6004c3c9db83Smrg  int has_slash = 0;
6005c3c9db83Smrg  const char *p;
6006c3c9db83Smrg  const char *p_next;
6007c3c9db83Smrg  /* static buffer for getcwd */
6008c3c9db83Smrg  char tmp[LT_PATHMAX + 1];
60092f60eb46Smrg  size_t tmp_len;
6010c3c9db83Smrg  char *concat_name;
60112e71ea71Smrg
60123f6d0e1dSmrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
60133f6d0e1dSmrg                  nonempty (wrapper));
60142e71ea71Smrg
6015c3c9db83Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
6016c3c9db83Smrg    return NULL;
60172e71ea71Smrg
6018c3c9db83Smrg  /* Absolute path? */
60192f60eb46Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
6020c3c9db83Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
6021c3c9db83Smrg    {
6022c3c9db83Smrg      concat_name = xstrdup (wrapper);
6023c3c9db83Smrg      if (check_executable (concat_name))
6024c3c9db83Smrg	return concat_name;
6025c3c9db83Smrg      XFREE (concat_name);
6026c3c9db83Smrg    }
6027c3c9db83Smrg  else
6028c3c9db83Smrg    {
6029c3c9db83Smrg#endif
6030c3c9db83Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
6031c3c9db83Smrg	{
6032c3c9db83Smrg	  concat_name = xstrdup (wrapper);
6033c3c9db83Smrg	  if (check_executable (concat_name))
6034c3c9db83Smrg	    return concat_name;
6035c3c9db83Smrg	  XFREE (concat_name);
6036c3c9db83Smrg	}
60372f60eb46Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
6038c3c9db83Smrg    }
6039c3c9db83Smrg#endif
6040692f60a7Smrg
6041c3c9db83Smrg  for (p = wrapper; *p; p++)
6042c3c9db83Smrg    if (*p == '/')
6043c3c9db83Smrg      {
6044c3c9db83Smrg	has_slash = 1;
6045c3c9db83Smrg	break;
6046c3c9db83Smrg      }
6047c3c9db83Smrg  if (!has_slash)
6048c3c9db83Smrg    {
6049c3c9db83Smrg      /* no slashes; search PATH */
6050c3c9db83Smrg      const char *path = getenv ("PATH");
6051c3c9db83Smrg      if (path != NULL)
6052c3c9db83Smrg	{
6053c3c9db83Smrg	  for (p = path; *p; p = p_next)
6054c3c9db83Smrg	    {
6055c3c9db83Smrg	      const char *q;
6056c3c9db83Smrg	      size_t p_len;
6057c3c9db83Smrg	      for (q = p; *q; q++)
6058c3c9db83Smrg		if (IS_PATH_SEPARATOR (*q))
6059c3c9db83Smrg		  break;
60602f60eb46Smrg	      p_len = (size_t) (q - p);
6061c3c9db83Smrg	      p_next = (*q == '\0' ? q : q + 1);
6062c3c9db83Smrg	      if (p_len == 0)
6063c3c9db83Smrg		{
6064c3c9db83Smrg		  /* empty path: current directory */
6065c3c9db83Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
60663f6d0e1dSmrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
60673f6d0e1dSmrg                              nonnull (strerror (errno)));
6068c3c9db83Smrg		  tmp_len = strlen (tmp);
6069c3c9db83Smrg		  concat_name =
6070c3c9db83Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6071c3c9db83Smrg		  memcpy (concat_name, tmp, tmp_len);
6072c3c9db83Smrg		  concat_name[tmp_len] = '/';
6073c3c9db83Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
6074c3c9db83Smrg		}
6075c3c9db83Smrg	      else
6076c3c9db83Smrg		{
6077c3c9db83Smrg		  concat_name =
6078c3c9db83Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
6079c3c9db83Smrg		  memcpy (concat_name, p, p_len);
6080c3c9db83Smrg		  concat_name[p_len] = '/';
6081c3c9db83Smrg		  strcpy (concat_name + p_len + 1, wrapper);
6082c3c9db83Smrg		}
6083c3c9db83Smrg	      if (check_executable (concat_name))
6084c3c9db83Smrg		return concat_name;
6085c3c9db83Smrg	      XFREE (concat_name);
6086c3c9db83Smrg	    }
6087c3c9db83Smrg	}
6088c3c9db83Smrg      /* not found in PATH; assume curdir */
6089c3c9db83Smrg    }
6090c3c9db83Smrg  /* Relative path | not found in path: prepend cwd */
6091c3c9db83Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
60923f6d0e1dSmrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
60933f6d0e1dSmrg              nonnull (strerror (errno)));
6094c3c9db83Smrg  tmp_len = strlen (tmp);
6095c3c9db83Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6096c3c9db83Smrg  memcpy (concat_name, tmp, tmp_len);
6097c3c9db83Smrg  concat_name[tmp_len] = '/';
6098c3c9db83Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
6099692f60a7Smrg
6100c3c9db83Smrg  if (check_executable (concat_name))
6101c3c9db83Smrg    return concat_name;
6102c3c9db83Smrg  XFREE (concat_name);
6103c3c9db83Smrg  return NULL;
6104c3c9db83Smrg}
6105692f60a7Smrg
6106c3c9db83Smrgchar *
6107c3c9db83Smrgchase_symlinks (const char *pathspec)
6108c3c9db83Smrg{
6109c3c9db83Smrg#ifndef S_ISLNK
6110c3c9db83Smrg  return xstrdup (pathspec);
6111c3c9db83Smrg#else
6112c3c9db83Smrg  char buf[LT_PATHMAX];
6113c3c9db83Smrg  struct stat s;
6114c3c9db83Smrg  char *tmp_pathspec = xstrdup (pathspec);
6115c3c9db83Smrg  char *p;
6116c3c9db83Smrg  int has_symlinks = 0;
6117c3c9db83Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
6118c3c9db83Smrg    {
61193f6d0e1dSmrg      lt_debugprintf (__FILE__, __LINE__,
61203f6d0e1dSmrg		      "checking path component for symlinks: %s\n",
61213f6d0e1dSmrg		      tmp_pathspec);
6122c3c9db83Smrg      if (lstat (tmp_pathspec, &s) == 0)
6123c3c9db83Smrg	{
6124c3c9db83Smrg	  if (S_ISLNK (s.st_mode) != 0)
6125c3c9db83Smrg	    {
6126c3c9db83Smrg	      has_symlinks = 1;
6127c3c9db83Smrg	      break;
6128c3c9db83Smrg	    }
6129692f60a7Smrg
6130c3c9db83Smrg	  /* search backwards for last DIR_SEPARATOR */
6131c3c9db83Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
6132c3c9db83Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6133c3c9db83Smrg	    p--;
6134c3c9db83Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6135c3c9db83Smrg	    {
6136c3c9db83Smrg	      /* no more DIR_SEPARATORS left */
6137c3c9db83Smrg	      break;
6138c3c9db83Smrg	    }
6139c3c9db83Smrg	  *p = '\0';
6140c3c9db83Smrg	}
6141c3c9db83Smrg      else
6142c3c9db83Smrg	{
61433f6d0e1dSmrg	  lt_fatal (__FILE__, __LINE__,
61443f6d0e1dSmrg		    "error accessing file \"%s\": %s",
61453f6d0e1dSmrg		    tmp_pathspec, nonnull (strerror (errno)));
6146c3c9db83Smrg	}
6147c3c9db83Smrg    }
6148c3c9db83Smrg  XFREE (tmp_pathspec);
6149692f60a7Smrg
6150c3c9db83Smrg  if (!has_symlinks)
6151c3c9db83Smrg    {
6152c3c9db83Smrg      return xstrdup (pathspec);
6153c3c9db83Smrg    }
6154692f60a7Smrg
6155c3c9db83Smrg  tmp_pathspec = realpath (pathspec, buf);
6156c3c9db83Smrg  if (tmp_pathspec == 0)
6157c3c9db83Smrg    {
61583f6d0e1dSmrg      lt_fatal (__FILE__, __LINE__,
61593f6d0e1dSmrg		"could not follow symlinks for %s", pathspec);
6160c3c9db83Smrg    }
6161c3c9db83Smrg  return xstrdup (tmp_pathspec);
6162c3c9db83Smrg#endif
6163c3c9db83Smrg}
6164692f60a7Smrg
6165c3c9db83Smrgchar *
6166c3c9db83Smrgstrendzap (char *str, const char *pat)
6167c3c9db83Smrg{
6168c3c9db83Smrg  size_t len, patlen;
6169692f60a7Smrg
6170c3c9db83Smrg  assert (str != NULL);
6171c3c9db83Smrg  assert (pat != NULL);
6172692f60a7Smrg
6173c3c9db83Smrg  len = strlen (str);
6174c3c9db83Smrg  patlen = strlen (pat);
6175692f60a7Smrg
6176c3c9db83Smrg  if (patlen <= len)
6177c3c9db83Smrg    {
6178c3c9db83Smrg      str += len - patlen;
61792f60eb46Smrg      if (STREQ (str, pat))
6180c3c9db83Smrg	*str = '\0';
6181c3c9db83Smrg    }
6182c3c9db83Smrg  return str;
6183c3c9db83Smrg}
6184692f60a7Smrg
61853f6d0e1dSmrgvoid
61863f6d0e1dSmrglt_debugprintf (const char *file, int line, const char *fmt, ...)
61873f6d0e1dSmrg{
61883f6d0e1dSmrg  va_list args;
61893f6d0e1dSmrg  if (lt_debug)
61903f6d0e1dSmrg    {
61913f6d0e1dSmrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
61923f6d0e1dSmrg      va_start (args, fmt);
61933f6d0e1dSmrg      (void) vfprintf (stderr, fmt, args);
61943f6d0e1dSmrg      va_end (args);
61953f6d0e1dSmrg    }
61963f6d0e1dSmrg}
61973f6d0e1dSmrg
6198c3c9db83Smrgstatic void
61993f6d0e1dSmrglt_error_core (int exit_status, const char *file,
62003f6d0e1dSmrg	       int line, const char *mode,
6201c3c9db83Smrg	       const char *message, va_list ap)
6202c3c9db83Smrg{
62033f6d0e1dSmrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
6204c3c9db83Smrg  vfprintf (stderr, message, ap);
6205c3c9db83Smrg  fprintf (stderr, ".\n");
6206692f60a7Smrg
6207c3c9db83Smrg  if (exit_status >= 0)
6208c3c9db83Smrg    exit (exit_status);
6209c3c9db83Smrg}
6210692f60a7Smrg
6211c3c9db83Smrgvoid
62123f6d0e1dSmrglt_fatal (const char *file, int line, const char *message, ...)
6213c3c9db83Smrg{
6214c3c9db83Smrg  va_list ap;
6215c3c9db83Smrg  va_start (ap, message);
62163f6d0e1dSmrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
6217c3c9db83Smrg  va_end (ap);
6218c3c9db83Smrg}
6219692f60a7Smrg
62203f6d0e1dSmrgstatic const char *
62213f6d0e1dSmrgnonnull (const char *s)
62223f6d0e1dSmrg{
62233f6d0e1dSmrg  return s ? s : "(null)";
62243f6d0e1dSmrg}
62253f6d0e1dSmrg
62263f6d0e1dSmrgstatic const char *
62273f6d0e1dSmrgnonempty (const char *s)
62283f6d0e1dSmrg{
62293f6d0e1dSmrg  return (s && !*s) ? "(empty)" : nonnull (s);
62303f6d0e1dSmrg}
62313f6d0e1dSmrg
6232c3c9db83Smrgvoid
6233c3c9db83Smrglt_setenv (const char *name, const char *value)
6234c3c9db83Smrg{
62353f6d0e1dSmrg  lt_debugprintf (__FILE__, __LINE__,
62363f6d0e1dSmrg		  "(lt_setenv) setting '%s' to '%s'\n",
62373f6d0e1dSmrg                  nonnull (name), nonnull (value));
6238c3c9db83Smrg  {
6239c3c9db83Smrg#ifdef HAVE_SETENV
6240c3c9db83Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
6241c3c9db83Smrg    char *str = xstrdup (value);
6242c3c9db83Smrg    setenv (name, str, 1);
6243c3c9db83Smrg#else
62442f60eb46Smrg    size_t len = strlen (name) + 1 + strlen (value) + 1;
6245c3c9db83Smrg    char *str = XMALLOC (char, len);
6246c3c9db83Smrg    sprintf (str, "%s=%s", name, value);
6247c3c9db83Smrg    if (putenv (str) != EXIT_SUCCESS)
6248c3c9db83Smrg      {
6249c3c9db83Smrg        XFREE (str);
6250c3c9db83Smrg      }
6251c3c9db83Smrg#endif
6252c3c9db83Smrg  }
6253c3c9db83Smrg}
6254692f60a7Smrg
6255c3c9db83Smrgchar *
6256c3c9db83Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
6257c3c9db83Smrg{
6258c3c9db83Smrg  char *new_value;
6259c3c9db83Smrg  if (orig_value && *orig_value)
6260c3c9db83Smrg    {
62612f60eb46Smrg      size_t orig_value_len = strlen (orig_value);
62622f60eb46Smrg      size_t add_len = strlen (add);
6263c3c9db83Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
6264c3c9db83Smrg      if (to_end)
6265c3c9db83Smrg        {
6266c3c9db83Smrg          strcpy (new_value, orig_value);
6267c3c9db83Smrg          strcpy (new_value + orig_value_len, add);
6268c3c9db83Smrg        }
6269c3c9db83Smrg      else
6270c3c9db83Smrg        {
6271c3c9db83Smrg          strcpy (new_value, add);
6272c3c9db83Smrg          strcpy (new_value + add_len, orig_value);
6273c3c9db83Smrg        }
6274c3c9db83Smrg    }
6275c3c9db83Smrg  else
6276c3c9db83Smrg    {
6277c3c9db83Smrg      new_value = xstrdup (add);
6278c3c9db83Smrg    }
6279c3c9db83Smrg  return new_value;
6280c3c9db83Smrg}
6281692f60a7Smrg
6282c3c9db83Smrgvoid
6283c3c9db83Smrglt_update_exe_path (const char *name, const char *value)
6284c3c9db83Smrg{
62853f6d0e1dSmrg  lt_debugprintf (__FILE__, __LINE__,
62863f6d0e1dSmrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
62873f6d0e1dSmrg                  nonnull (name), nonnull (value));
6288692f60a7Smrg
6289c3c9db83Smrg  if (name && *name && value && *value)
6290c3c9db83Smrg    {
6291c3c9db83Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
6292c3c9db83Smrg      /* some systems can't cope with a ':'-terminated path #' */
62932f60eb46Smrg      size_t len = strlen (new_value);
62942f60eb46Smrg      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
6295c3c9db83Smrg        {
62962f60eb46Smrg          new_value[--len] = '\0';
6297c3c9db83Smrg        }
6298c3c9db83Smrg      lt_setenv (name, new_value);
6299c3c9db83Smrg      XFREE (new_value);
6300c3c9db83Smrg    }
6301c3c9db83Smrg}
6302692f60a7Smrg
6303c3c9db83Smrgvoid
6304c3c9db83Smrglt_update_lib_path (const char *name, const char *value)
6305c3c9db83Smrg{
63063f6d0e1dSmrg  lt_debugprintf (__FILE__, __LINE__,
63073f6d0e1dSmrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
63083f6d0e1dSmrg                  nonnull (name), nonnull (value));
6309692f60a7Smrg
6310c3c9db83Smrg  if (name && *name && value && *value)
6311c3c9db83Smrg    {
6312c3c9db83Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
6313c3c9db83Smrg      lt_setenv (name, new_value);
6314c3c9db83Smrg      XFREE (new_value);
6315c3c9db83Smrg    }
6316c3c9db83Smrg}
6317692f60a7Smrg
63183f6d0e1dSmrgEOF
63193f6d0e1dSmrg	    case $host_os in
63203f6d0e1dSmrg	      mingw*)
63213f6d0e1dSmrg		cat <<"EOF"
63223f6d0e1dSmrg
63233f6d0e1dSmrg/* Prepares an argument vector before calling spawn().
63243f6d0e1dSmrg   Note that spawn() does not by itself call the command interpreter
63253f6d0e1dSmrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
63263f6d0e1dSmrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
63273f6d0e1dSmrg         GetVersionEx(&v);
63283f6d0e1dSmrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
63293f6d0e1dSmrg      }) ? "cmd.exe" : "command.com").
63303f6d0e1dSmrg   Instead it simply concatenates the arguments, separated by ' ', and calls
63313f6d0e1dSmrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
63323f6d0e1dSmrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
63333f6d0e1dSmrg   special way:
63343f6d0e1dSmrg   - Space and tab are interpreted as delimiters. They are not treated as
63353f6d0e1dSmrg     delimiters if they are surrounded by double quotes: "...".
63363f6d0e1dSmrg   - Unescaped double quotes are removed from the input. Their only effect is
63373f6d0e1dSmrg     that within double quotes, space and tab are treated like normal
63383f6d0e1dSmrg     characters.
63393f6d0e1dSmrg   - Backslashes not followed by double quotes are not special.
63403f6d0e1dSmrg   - But 2*n+1 backslashes followed by a double quote become
63413f6d0e1dSmrg     n backslashes followed by a double quote (n >= 0):
63423f6d0e1dSmrg       \" -> "
63433f6d0e1dSmrg       \\\" -> \"
63443f6d0e1dSmrg       \\\\\" -> \\"
63453f6d0e1dSmrg */
63463f6d0e1dSmrg#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"
63473f6d0e1dSmrg#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"
63483f6d0e1dSmrgchar **
63493f6d0e1dSmrgprepare_spawn (char **argv)
63503f6d0e1dSmrg{
63513f6d0e1dSmrg  size_t argc;
63523f6d0e1dSmrg  char **new_argv;
63533f6d0e1dSmrg  size_t i;
63543f6d0e1dSmrg
63553f6d0e1dSmrg  /* Count number of arguments.  */
63563f6d0e1dSmrg  for (argc = 0; argv[argc] != NULL; argc++)
63573f6d0e1dSmrg    ;
63583f6d0e1dSmrg
63593f6d0e1dSmrg  /* Allocate new argument vector.  */
63603f6d0e1dSmrg  new_argv = XMALLOC (char *, argc + 1);
63613f6d0e1dSmrg
63623f6d0e1dSmrg  /* Put quoted arguments into the new argument vector.  */
63633f6d0e1dSmrg  for (i = 0; i < argc; i++)
63643f6d0e1dSmrg    {
63653f6d0e1dSmrg      const char *string = argv[i];
63663f6d0e1dSmrg
63673f6d0e1dSmrg      if (string[0] == '\0')
63683f6d0e1dSmrg	new_argv[i] = xstrdup ("\"\"");
63693f6d0e1dSmrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
63703f6d0e1dSmrg	{
63713f6d0e1dSmrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
63723f6d0e1dSmrg	  size_t length;
63733f6d0e1dSmrg	  unsigned int backslashes;
63743f6d0e1dSmrg	  const char *s;
63753f6d0e1dSmrg	  char *quoted_string;
63763f6d0e1dSmrg	  char *p;
63773f6d0e1dSmrg
63783f6d0e1dSmrg	  length = 0;
63793f6d0e1dSmrg	  backslashes = 0;
63803f6d0e1dSmrg	  if (quote_around)
63813f6d0e1dSmrg	    length++;
63823f6d0e1dSmrg	  for (s = string; *s != '\0'; s++)
63833f6d0e1dSmrg	    {
63843f6d0e1dSmrg	      char c = *s;
63853f6d0e1dSmrg	      if (c == '"')
63863f6d0e1dSmrg		length += backslashes + 1;
63873f6d0e1dSmrg	      length++;
63883f6d0e1dSmrg	      if (c == '\\')
63893f6d0e1dSmrg		backslashes++;
63903f6d0e1dSmrg	      else
63913f6d0e1dSmrg		backslashes = 0;
63923f6d0e1dSmrg	    }
63933f6d0e1dSmrg	  if (quote_around)
63943f6d0e1dSmrg	    length += backslashes + 1;
63953f6d0e1dSmrg
63963f6d0e1dSmrg	  quoted_string = XMALLOC (char, length + 1);
63973f6d0e1dSmrg
63983f6d0e1dSmrg	  p = quoted_string;
63993f6d0e1dSmrg	  backslashes = 0;
64003f6d0e1dSmrg	  if (quote_around)
64013f6d0e1dSmrg	    *p++ = '"';
64023f6d0e1dSmrg	  for (s = string; *s != '\0'; s++)
64033f6d0e1dSmrg	    {
64043f6d0e1dSmrg	      char c = *s;
64053f6d0e1dSmrg	      if (c == '"')
64063f6d0e1dSmrg		{
64073f6d0e1dSmrg		  unsigned int j;
64083f6d0e1dSmrg		  for (j = backslashes + 1; j > 0; j--)
64093f6d0e1dSmrg		    *p++ = '\\';
64103f6d0e1dSmrg		}
64113f6d0e1dSmrg	      *p++ = c;
64123f6d0e1dSmrg	      if (c == '\\')
64133f6d0e1dSmrg		backslashes++;
64143f6d0e1dSmrg	      else
64153f6d0e1dSmrg		backslashes = 0;
64163f6d0e1dSmrg	    }
64173f6d0e1dSmrg	  if (quote_around)
64183f6d0e1dSmrg	    {
64193f6d0e1dSmrg	      unsigned int j;
64203f6d0e1dSmrg	      for (j = backslashes; j > 0; j--)
64213f6d0e1dSmrg		*p++ = '\\';
64223f6d0e1dSmrg	      *p++ = '"';
64233f6d0e1dSmrg	    }
64243f6d0e1dSmrg	  *p = '\0';
64253f6d0e1dSmrg
64263f6d0e1dSmrg	  new_argv[i] = quoted_string;
64273f6d0e1dSmrg	}
64283f6d0e1dSmrg      else
64293f6d0e1dSmrg	new_argv[i] = (char *) string;
64303f6d0e1dSmrg    }
64313f6d0e1dSmrg  new_argv[argc] = NULL;
64323f6d0e1dSmrg
64333f6d0e1dSmrg  return new_argv;
64343f6d0e1dSmrg}
64353f6d0e1dSmrgEOF
64363f6d0e1dSmrg		;;
64373f6d0e1dSmrg	    esac
6438692f60a7Smrg
64393f6d0e1dSmrg            cat <<"EOF"
64403f6d0e1dSmrgvoid lt_dump_script (FILE* f)
64413f6d0e1dSmrg{
64423f6d0e1dSmrgEOF
64433f6d0e1dSmrg	    func_emit_wrapper yes |
644495903e71Smrg	      $SED -n -e '
644595903e71Smrgs/^\(.\{79\}\)\(..*\)/\1\
644695903e71Smrg\2/
644795903e71Smrgh
644895903e71Smrgs/\([\\"]\)/\\\1/g
644995903e71Smrgs/$/\\n/
645095903e71Smrgs/\([^\n]*\).*/  fputs ("\1", f);/p
645195903e71Smrgg
645295903e71SmrgD'
64533f6d0e1dSmrg            cat <<"EOF"
64543f6d0e1dSmrg}
6455c3c9db83SmrgEOF
6456c3c9db83Smrg}
6457c3c9db83Smrg# end: func_emit_cwrapperexe_src
6458692f60a7Smrg
64593f6d0e1dSmrg# func_win32_import_lib_p ARG
64603f6d0e1dSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd
64613f6d0e1dSmrgfunc_win32_import_lib_p ()
64623f6d0e1dSmrg{
64632f60eb46Smrg    $debug_cmd
64642f60eb46Smrg
64653f6d0e1dSmrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
64663f6d0e1dSmrg    *import*) : ;;
64673f6d0e1dSmrg    *) false ;;
64683f6d0e1dSmrg    esac
64693f6d0e1dSmrg}
64703f6d0e1dSmrg
64712f60eb46Smrg# func_suncc_cstd_abi
64722f60eb46Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
64732f60eb46Smrg# Several compiler flags select an ABI that is incompatible with the
64742f60eb46Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS.
64752f60eb46Smrgfunc_suncc_cstd_abi ()
64762f60eb46Smrg{
64772f60eb46Smrg    $debug_cmd
64782f60eb46Smrg
64792f60eb46Smrg    case " $compile_command " in
64802f60eb46Smrg    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
64812f60eb46Smrg      suncc_use_cstd_abi=no
64822f60eb46Smrg      ;;
64832f60eb46Smrg    *)
64842f60eb46Smrg      suncc_use_cstd_abi=yes
64852f60eb46Smrg      ;;
64862f60eb46Smrg    esac
64872f60eb46Smrg}
64882f60eb46Smrg
6489c3c9db83Smrg# func_mode_link arg...
6490c3c9db83Smrgfunc_mode_link ()
6491c3c9db83Smrg{
64922f60eb46Smrg    $debug_cmd
64932f60eb46Smrg
6494c3c9db83Smrg    case $host in
6495c3c9db83Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6496c3c9db83Smrg      # It is impossible to link a dll without this setting, and
6497c3c9db83Smrg      # we shouldn't force the makefile maintainer to figure out
64982f60eb46Smrg      # what system we are compiling for in order to pass an extra
6499c3c9db83Smrg      # flag for every libtool invocation.
6500c3c9db83Smrg      # allow_undefined=no
6501692f60a7Smrg
6502c3c9db83Smrg      # FIXME: Unfortunately, there are problems with the above when trying
65032f60eb46Smrg      # to make a dll that has undefined symbols, in which case not
6504c3c9db83Smrg      # even a static library is built.  For now, we need to specify
6505c3c9db83Smrg      # -no-undefined on the libtool link line when we can be certain
6506c3c9db83Smrg      # that all symbols are satisfied, otherwise we get a static library.
6507c3c9db83Smrg      allow_undefined=yes
6508c3c9db83Smrg      ;;
6509c3c9db83Smrg    *)
6510c3c9db83Smrg      allow_undefined=yes
6511c3c9db83Smrg      ;;
6512c3c9db83Smrg    esac
6513c3c9db83Smrg    libtool_args=$nonopt
6514c3c9db83Smrg    base_compile="$nonopt $@"
6515c3c9db83Smrg    compile_command=$nonopt
6516c3c9db83Smrg    finalize_command=$nonopt
6517692f60a7Smrg
6518c3c9db83Smrg    compile_rpath=
6519c3c9db83Smrg    finalize_rpath=
6520c3c9db83Smrg    compile_shlibpath=
6521c3c9db83Smrg    finalize_shlibpath=
6522c3c9db83Smrg    convenience=
6523c3c9db83Smrg    old_convenience=
6524c3c9db83Smrg    deplibs=
6525c3c9db83Smrg    old_deplibs=
6526c3c9db83Smrg    compiler_flags=
6527c3c9db83Smrg    linker_flags=
6528c3c9db83Smrg    dllsearchpath=
6529c3c9db83Smrg    lib_search_path=`pwd`
6530c3c9db83Smrg    inst_prefix_dir=
6531c3c9db83Smrg    new_inherited_linker_flags=
6532692f60a7Smrg
6533c3c9db83Smrg    avoid_version=no
65343f6d0e1dSmrg    bindir=
6535c3c9db83Smrg    dlfiles=
6536c3c9db83Smrg    dlprefiles=
6537c3c9db83Smrg    dlself=no
6538c3c9db83Smrg    export_dynamic=no
6539c3c9db83Smrg    export_symbols=
6540c3c9db83Smrg    export_symbols_regex=
6541c3c9db83Smrg    generated=
6542c3c9db83Smrg    libobjs=
6543c3c9db83Smrg    ltlibs=
6544c3c9db83Smrg    module=no
6545c3c9db83Smrg    no_install=no
6546c3c9db83Smrg    objs=
65472f60eb46Smrg    os2dllname=
6548c3c9db83Smrg    non_pic_objects=
6549c3c9db83Smrg    precious_files_regex=
6550c3c9db83Smrg    prefer_static_libs=no
65512f60eb46Smrg    preload=false
6552c3c9db83Smrg    prev=
6553c3c9db83Smrg    prevarg=
6554c3c9db83Smrg    release=
6555c3c9db83Smrg    rpath=
6556c3c9db83Smrg    xrpath=
6557c3c9db83Smrg    perm_rpath=
6558c3c9db83Smrg    temp_rpath=
6559c3c9db83Smrg    thread_safe=no
6560c3c9db83Smrg    vinfo=
6561c3c9db83Smrg    vinfo_number=no
6562c3c9db83Smrg    weak_libs=
65632f60eb46Smrg    single_module=$wl-single_module
6564c3c9db83Smrg    func_infer_tag $base_compile
6565c3c9db83Smrg
6566c3c9db83Smrg    # We need to know -static, to get the right output filenames.
6567c3c9db83Smrg    for arg
6568c3c9db83Smrg    do
6569c3c9db83Smrg      case $arg in
6570c3c9db83Smrg      -shared)
65712f60eb46Smrg	test yes != "$build_libtool_libs" \
65722f60eb46Smrg	  && func_fatal_configuration "cannot build a shared library"
6573c3c9db83Smrg	build_old_libs=no
6574c3c9db83Smrg	break
6575c3c9db83Smrg	;;
6576c3c9db83Smrg      -all-static | -static | -static-libtool-libs)
6577c3c9db83Smrg	case $arg in
6578c3c9db83Smrg	-all-static)
65792f60eb46Smrg	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
6580c3c9db83Smrg	    func_warning "complete static linking is impossible in this configuration"
6581c3c9db83Smrg	  fi
6582c3c9db83Smrg	  if test -n "$link_static_flag"; then
6583c3c9db83Smrg	    dlopen_self=$dlopen_self_static
6584c3c9db83Smrg	  fi
6585c3c9db83Smrg	  prefer_static_libs=yes
6586c3c9db83Smrg	  ;;
6587c3c9db83Smrg	-static)
6588c3c9db83Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
6589c3c9db83Smrg	    dlopen_self=$dlopen_self_static
6590c3c9db83Smrg	  fi
6591c3c9db83Smrg	  prefer_static_libs=built
6592c3c9db83Smrg	  ;;
6593c3c9db83Smrg	-static-libtool-libs)
6594c3c9db83Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
6595c3c9db83Smrg	    dlopen_self=$dlopen_self_static
65962e71ea71Smrg	  fi
6597c3c9db83Smrg	  prefer_static_libs=yes
6598c3c9db83Smrg	  ;;
6599c3c9db83Smrg	esac
6600c3c9db83Smrg	build_libtool_libs=no
6601c3c9db83Smrg	build_old_libs=yes
6602c3c9db83Smrg	break
6603c3c9db83Smrg	;;
6604c3c9db83Smrg      esac
6605c3c9db83Smrg    done
6606692f60a7Smrg
6607c3c9db83Smrg    # See if our shared archives depend on static archives.
6608c3c9db83Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
6609692f60a7Smrg
6610c3c9db83Smrg    # Go through the arguments, transforming them on the way.
6611c3c9db83Smrg    while test "$#" -gt 0; do
66122f60eb46Smrg      arg=$1
6613c3c9db83Smrg      shift
6614c3c9db83Smrg      func_quote_for_eval "$arg"
6615c3c9db83Smrg      qarg=$func_quote_for_eval_unquoted_result
6616c3c9db83Smrg      func_append libtool_args " $func_quote_for_eval_result"
6617692f60a7Smrg
6618c3c9db83Smrg      # If the previous option needs an argument, assign it.
6619c3c9db83Smrg      if test -n "$prev"; then
6620c3c9db83Smrg	case $prev in
6621c3c9db83Smrg	output)
6622c3c9db83Smrg	  func_append compile_command " @OUTPUT@"
6623c3c9db83Smrg	  func_append finalize_command " @OUTPUT@"
6624c3c9db83Smrg	  ;;
6625c3c9db83Smrg	esac
6626692f60a7Smrg
6627c3c9db83Smrg	case $prev in
66283f6d0e1dSmrg	bindir)
66292f60eb46Smrg	  bindir=$arg
66303f6d0e1dSmrg	  prev=
66313f6d0e1dSmrg	  continue
66323f6d0e1dSmrg	  ;;
6633c3c9db83Smrg	dlfiles|dlprefiles)
66342f60eb46Smrg	  $preload || {
6635c3c9db83Smrg	    # Add the symbol object into the linking commands.
6636c3c9db83Smrg	    func_append compile_command " @SYMFILE@"
6637c3c9db83Smrg	    func_append finalize_command " @SYMFILE@"
66382f60eb46Smrg	    preload=:
66392f60eb46Smrg	  }
6640c3c9db83Smrg	  case $arg in
6641c3c9db83Smrg	  *.la | *.lo) ;;  # We handle these cases below.
6642c3c9db83Smrg	  force)
66432f60eb46Smrg	    if test no = "$dlself"; then
6644c3c9db83Smrg	      dlself=needless
6645c3c9db83Smrg	      export_dynamic=yes
6646c3c9db83Smrg	    fi
6647c3c9db83Smrg	    prev=
6648c3c9db83Smrg	    continue
6649c3c9db83Smrg	    ;;
6650c3c9db83Smrg	  self)
66512f60eb46Smrg	    if test dlprefiles = "$prev"; then
6652c3c9db83Smrg	      dlself=yes
66532f60eb46Smrg	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
6654c3c9db83Smrg	      dlself=yes
66552e71ea71Smrg	    else
6656c3c9db83Smrg	      dlself=needless
6657c3c9db83Smrg	      export_dynamic=yes
66582e71ea71Smrg	    fi
6659c3c9db83Smrg	    prev=
6660c3c9db83Smrg	    continue
6661c3c9db83Smrg	    ;;
6662c3c9db83Smrg	  *)
66632f60eb46Smrg	    if test dlfiles = "$prev"; then
66643f6d0e1dSmrg	      func_append dlfiles " $arg"
66652e71ea71Smrg	    else
66663f6d0e1dSmrg	      func_append dlprefiles " $arg"
66672e71ea71Smrg	    fi
6668c3c9db83Smrg	    prev=
6669c3c9db83Smrg	    continue
6670c3c9db83Smrg	    ;;
6671c3c9db83Smrg	  esac
6672c3c9db83Smrg	  ;;
6673c3c9db83Smrg	expsyms)
66742f60eb46Smrg	  export_symbols=$arg
6675c3c9db83Smrg	  test -f "$arg" \
66762f60eb46Smrg	    || func_fatal_error "symbol file '$arg' does not exist"
6677c3c9db83Smrg	  prev=
6678c3c9db83Smrg	  continue
6679c3c9db83Smrg	  ;;
6680c3c9db83Smrg	expsyms_regex)
66812f60eb46Smrg	  export_symbols_regex=$arg
6682c3c9db83Smrg	  prev=
6683c3c9db83Smrg	  continue
6684c3c9db83Smrg	  ;;
6685c3c9db83Smrg	framework)
66862e71ea71Smrg	  case $host in
6687c3c9db83Smrg	    *-*-darwin*)
6688c3c9db83Smrg	      case "$deplibs " in
6689c3c9db83Smrg		*" $qarg.ltframework "*) ;;
66903f6d0e1dSmrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
6691c3c9db83Smrg		   ;;
6692c3c9db83Smrg	      esac
6693c3c9db83Smrg	      ;;
66942e71ea71Smrg	  esac
6695c3c9db83Smrg	  prev=
6696c3c9db83Smrg	  continue
66972e71ea71Smrg	  ;;
6698c3c9db83Smrg	inst_prefix)
66992f60eb46Smrg	  inst_prefix_dir=$arg
67002f60eb46Smrg	  prev=
67012f60eb46Smrg	  continue
67022f60eb46Smrg	  ;;
67032f60eb46Smrg	mllvm)
67042f60eb46Smrg	  # Clang does not use LLVM to link, so we can simply discard any
67052f60eb46Smrg	  # '-mllvm $arg' options when doing the link step.
6706c3c9db83Smrg	  prev=
6707c3c9db83Smrg	  continue
67082e71ea71Smrg	  ;;
6709c3c9db83Smrg	objectlist)
6710c3c9db83Smrg	  if test -f "$arg"; then
6711c3c9db83Smrg	    save_arg=$arg
6712c3c9db83Smrg	    moreargs=
6713c3c9db83Smrg	    for fil in `cat "$save_arg"`
6714c3c9db83Smrg	    do
67153f6d0e1dSmrg#	      func_append moreargs " $fil"
6716c3c9db83Smrg	      arg=$fil
6717c3c9db83Smrg	      # A libtool-controlled object.
6718692f60a7Smrg
6719c3c9db83Smrg	      # Check to see that this really is a libtool object.
6720c3c9db83Smrg	      if func_lalib_unsafe_p "$arg"; then
6721c3c9db83Smrg		pic_object=
6722c3c9db83Smrg		non_pic_object=
672385ee4c00Smrg
6724c3c9db83Smrg		# Read the .lo file
6725c3c9db83Smrg		func_source "$arg"
672685ee4c00Smrg
6727c3c9db83Smrg		if test -z "$pic_object" ||
6728c3c9db83Smrg		   test -z "$non_pic_object" ||
67292f60eb46Smrg		   test none = "$pic_object" &&
67302f60eb46Smrg		   test none = "$non_pic_object"; then
67312f60eb46Smrg		  func_fatal_error "cannot find name of object for '$arg'"
6732c3c9db83Smrg		fi
673385ee4c00Smrg
6734c3c9db83Smrg		# Extract subdirectory from the argument.
6735c3c9db83Smrg		func_dirname "$arg" "/" ""
67362f60eb46Smrg		xdir=$func_dirname_result
673785ee4c00Smrg
67382f60eb46Smrg		if test none != "$pic_object"; then
6739c3c9db83Smrg		  # Prepend the subdirectory the object is found in.
67402f60eb46Smrg		  pic_object=$xdir$pic_object
674185ee4c00Smrg
67422f60eb46Smrg		  if test dlfiles = "$prev"; then
67432f60eb46Smrg		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
67443f6d0e1dSmrg		      func_append dlfiles " $pic_object"
6745c3c9db83Smrg		      prev=
6746c3c9db83Smrg		      continue
6747c3c9db83Smrg		    else
6748c3c9db83Smrg		      # If libtool objects are unsupported, then we need to preload.
6749c3c9db83Smrg		      prev=dlprefiles
6750c3c9db83Smrg		    fi
6751c3c9db83Smrg		  fi
675285ee4c00Smrg
6753c3c9db83Smrg		  # CHECK ME:  I think I busted this.  -Ossama
67542f60eb46Smrg		  if test dlprefiles = "$prev"; then
6755c3c9db83Smrg		    # Preload the old-style object.
67563f6d0e1dSmrg		    func_append dlprefiles " $pic_object"
6757c3c9db83Smrg		    prev=
6758c3c9db83Smrg		  fi
675985ee4c00Smrg
6760c3c9db83Smrg		  # A PIC object.
6761c3c9db83Smrg		  func_append libobjs " $pic_object"
67622f60eb46Smrg		  arg=$pic_object
6763c3c9db83Smrg		fi
676485ee4c00Smrg
6765c3c9db83Smrg		# Non-PIC object.
67662f60eb46Smrg		if test none != "$non_pic_object"; then
6767c3c9db83Smrg		  # Prepend the subdirectory the object is found in.
67682f60eb46Smrg		  non_pic_object=$xdir$non_pic_object
676985ee4c00Smrg
6770c3c9db83Smrg		  # A standard non-PIC object
6771c3c9db83Smrg		  func_append non_pic_objects " $non_pic_object"
67722f60eb46Smrg		  if test -z "$pic_object" || test none = "$pic_object"; then
67732f60eb46Smrg		    arg=$non_pic_object
6774c3c9db83Smrg		  fi
6775c3c9db83Smrg		else
6776c3c9db83Smrg		  # If the PIC object exists, use it instead.
6777c3c9db83Smrg		  # $xdir was prepended to $pic_object above.
67782f60eb46Smrg		  non_pic_object=$pic_object
6779c3c9db83Smrg		  func_append non_pic_objects " $non_pic_object"
6780c3c9db83Smrg		fi
6781c3c9db83Smrg	      else
6782c3c9db83Smrg		# Only an error if not doing a dry-run.
6783c3c9db83Smrg		if $opt_dry_run; then
6784c3c9db83Smrg		  # Extract subdirectory from the argument.
6785c3c9db83Smrg		  func_dirname "$arg" "/" ""
67862f60eb46Smrg		  xdir=$func_dirname_result
6787c3c9db83Smrg
6788c3c9db83Smrg		  func_lo2o "$arg"
6789c3c9db83Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
6790c3c9db83Smrg		  non_pic_object=$xdir$func_lo2o_result
6791c3c9db83Smrg		  func_append libobjs " $pic_object"
6792c3c9db83Smrg		  func_append non_pic_objects " $non_pic_object"
6793c3c9db83Smrg	        else
67942f60eb46Smrg		  func_fatal_error "'$arg' is not a valid libtool object"
6795c3c9db83Smrg		fi
6796c3c9db83Smrg	      fi
6797c3c9db83Smrg	    done
67982e71ea71Smrg	  else
67992f60eb46Smrg	    func_fatal_error "link input file '$arg' does not exist"
68002e71ea71Smrg	  fi
6801c3c9db83Smrg	  arg=$save_arg
6802c3c9db83Smrg	  prev=
6803c3c9db83Smrg	  continue
6804c3c9db83Smrg	  ;;
68052f60eb46Smrg	os2dllname)
68062f60eb46Smrg	  os2dllname=$arg
68072f60eb46Smrg	  prev=
68082f60eb46Smrg	  continue
68092f60eb46Smrg	  ;;
6810c3c9db83Smrg	precious_regex)
68112f60eb46Smrg	  precious_files_regex=$arg
6812c3c9db83Smrg	  prev=
6813c3c9db83Smrg	  continue
6814c3c9db83Smrg	  ;;
6815c3c9db83Smrg	release)
68162f60eb46Smrg	  release=-$arg
6817c3c9db83Smrg	  prev=
6818c3c9db83Smrg	  continue
6819c3c9db83Smrg	  ;;
6820c3c9db83Smrg	rpath | xrpath)
6821c3c9db83Smrg	  # We need an absolute path.
6822c3c9db83Smrg	  case $arg in
6823c3c9db83Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
6824c3c9db83Smrg	  *)
6825c3c9db83Smrg	    func_fatal_error "only absolute run-paths are allowed"
6826c3c9db83Smrg	    ;;
6827c3c9db83Smrg	  esac
68282f60eb46Smrg	  if test rpath = "$prev"; then
6829c3c9db83Smrg	    case "$rpath " in
6830c3c9db83Smrg	    *" $arg "*) ;;
68313f6d0e1dSmrg	    *) func_append rpath " $arg" ;;
6832c3c9db83Smrg	    esac
68332e71ea71Smrg	  else
6834c3c9db83Smrg	    case "$xrpath " in
6835c3c9db83Smrg	    *" $arg "*) ;;
68363f6d0e1dSmrg	    *) func_append xrpath " $arg" ;;
6837c3c9db83Smrg	    esac
68382e71ea71Smrg	  fi
6839c3c9db83Smrg	  prev=
6840c3c9db83Smrg	  continue
6841c3c9db83Smrg	  ;;
6842c3c9db83Smrg	shrext)
68432f60eb46Smrg	  shrext_cmds=$arg
6844c3c9db83Smrg	  prev=
6845c3c9db83Smrg	  continue
6846c3c9db83Smrg	  ;;
6847c3c9db83Smrg	weak)
68483f6d0e1dSmrg	  func_append weak_libs " $arg"
6849c3c9db83Smrg	  prev=
6850c3c9db83Smrg	  continue
6851c3c9db83Smrg	  ;;
6852c3c9db83Smrg	xcclinker)
68533f6d0e1dSmrg	  func_append linker_flags " $qarg"
68543f6d0e1dSmrg	  func_append compiler_flags " $qarg"
6855c3c9db83Smrg	  prev=
6856c3c9db83Smrg	  func_append compile_command " $qarg"
6857c3c9db83Smrg	  func_append finalize_command " $qarg"
6858c3c9db83Smrg	  continue
6859c3c9db83Smrg	  ;;
6860c3c9db83Smrg	xcompiler)
68613f6d0e1dSmrg	  func_append compiler_flags " $qarg"
6862c3c9db83Smrg	  prev=
6863c3c9db83Smrg	  func_append compile_command " $qarg"
6864c3c9db83Smrg	  func_append finalize_command " $qarg"
6865c3c9db83Smrg	  continue
6866c3c9db83Smrg	  ;;
6867c3c9db83Smrg	xlinker)
68683f6d0e1dSmrg	  func_append linker_flags " $qarg"
68693f6d0e1dSmrg	  func_append compiler_flags " $wl$qarg"
6870c3c9db83Smrg	  prev=
6871c3c9db83Smrg	  func_append compile_command " $wl$qarg"
6872c3c9db83Smrg	  func_append finalize_command " $wl$qarg"
6873c3c9db83Smrg	  continue
6874c3c9db83Smrg	  ;;
6875c3c9db83Smrg	*)
6876c3c9db83Smrg	  eval "$prev=\"\$arg\""
6877c3c9db83Smrg	  prev=
6878c3c9db83Smrg	  continue
6879c3c9db83Smrg	  ;;
688085ee4c00Smrg	esac
6881c3c9db83Smrg      fi # test -n "$prev"
688285ee4c00Smrg
68832f60eb46Smrg      prevarg=$arg
688485ee4c00Smrg
6885c3c9db83Smrg      case $arg in
6886c3c9db83Smrg      -all-static)
6887c3c9db83Smrg	if test -n "$link_static_flag"; then
6888c3c9db83Smrg	  # See comment for -static flag below, for more details.
6889c3c9db83Smrg	  func_append compile_command " $link_static_flag"
6890c3c9db83Smrg	  func_append finalize_command " $link_static_flag"
6891c3c9db83Smrg	fi
6892c3c9db83Smrg	continue
6893c3c9db83Smrg	;;
689485ee4c00Smrg
6895c3c9db83Smrg      -allow-undefined)
6896c3c9db83Smrg	# FIXME: remove this flag sometime in the future.
68972f60eb46Smrg	func_fatal_error "'-allow-undefined' must not be used because it is the default"
6898c3c9db83Smrg	;;
689985ee4c00Smrg
6900c3c9db83Smrg      -avoid-version)
6901c3c9db83Smrg	avoid_version=yes
6902c3c9db83Smrg	continue
6903c3c9db83Smrg	;;
690485ee4c00Smrg
69053f6d0e1dSmrg      -bindir)
69063f6d0e1dSmrg	prev=bindir
69073f6d0e1dSmrg	continue
69083f6d0e1dSmrg	;;
69093f6d0e1dSmrg
6910c3c9db83Smrg      -dlopen)
6911c3c9db83Smrg	prev=dlfiles
6912c3c9db83Smrg	continue
6913c3c9db83Smrg	;;
691485ee4c00Smrg
6915c3c9db83Smrg      -dlpreopen)
6916c3c9db83Smrg	prev=dlprefiles
6917c3c9db83Smrg	continue
6918c3c9db83Smrg	;;
691985ee4c00Smrg
6920c3c9db83Smrg      -export-dynamic)
6921c3c9db83Smrg	export_dynamic=yes
6922c3c9db83Smrg	continue
6923c3c9db83Smrg	;;
692485ee4c00Smrg
6925c3c9db83Smrg      -export-symbols | -export-symbols-regex)
6926c3c9db83Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
6927c3c9db83Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
6928c3c9db83Smrg	fi
69292f60eb46Smrg	if test X-export-symbols = "X$arg"; then
6930c3c9db83Smrg	  prev=expsyms
6931c3c9db83Smrg	else
6932c3c9db83Smrg	  prev=expsyms_regex
6933c3c9db83Smrg	fi
6934c3c9db83Smrg	continue
6935c3c9db83Smrg	;;
693685ee4c00Smrg
6937c3c9db83Smrg      -framework)
6938c3c9db83Smrg	prev=framework
6939c3c9db83Smrg	continue
6940c3c9db83Smrg	;;
694185ee4c00Smrg
6942c3c9db83Smrg      -inst-prefix-dir)
6943c3c9db83Smrg	prev=inst_prefix
6944c3c9db83Smrg	continue
6945c3c9db83Smrg	;;
694685ee4c00Smrg
6947c3c9db83Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
6948c3c9db83Smrg      # so, if we see these flags be careful not to treat them like -L
6949c3c9db83Smrg      -L[A-Z][A-Z]*:*)
6950c3c9db83Smrg	case $with_gcc/$host in
6951c3c9db83Smrg	no/*-*-irix* | /*-*-irix*)
6952c3c9db83Smrg	  func_append compile_command " $arg"
6953c3c9db83Smrg	  func_append finalize_command " $arg"
6954c3c9db83Smrg	  ;;
6955c3c9db83Smrg	esac
6956c3c9db83Smrg	continue
6957c3c9db83Smrg	;;
695885ee4c00Smrg
6959c3c9db83Smrg      -L*)
69603f6d0e1dSmrg	func_stripname "-L" '' "$arg"
69613f6d0e1dSmrg	if test -z "$func_stripname_result"; then
6962c3c9db83Smrg	  if test "$#" -gt 0; then
69632f60eb46Smrg	    func_fatal_error "require no space between '-L' and '$1'"
6964c3c9db83Smrg	  else
69652f60eb46Smrg	    func_fatal_error "need path for '-L' option"
6966c3c9db83Smrg	  fi
6967c3c9db83Smrg	fi
69683f6d0e1dSmrg	func_resolve_sysroot "$func_stripname_result"
69693f6d0e1dSmrg	dir=$func_resolve_sysroot_result
6970c3c9db83Smrg	# We need an absolute path.
6971c3c9db83Smrg	case $dir in
6972c3c9db83Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
6973c3c9db83Smrg	*)
6974c3c9db83Smrg	  absdir=`cd "$dir" && pwd`
6975c3c9db83Smrg	  test -z "$absdir" && \
69762f60eb46Smrg	    func_fatal_error "cannot determine absolute directory name of '$dir'"
69772f60eb46Smrg	  dir=$absdir
6978c3c9db83Smrg	  ;;
6979c3c9db83Smrg	esac
6980c3c9db83Smrg	case "$deplibs " in
69813f6d0e1dSmrg	*" -L$dir "* | *" $arg "*)
69823f6d0e1dSmrg	  # Will only happen for absolute or sysroot arguments
69833f6d0e1dSmrg	  ;;
6984c3c9db83Smrg	*)
69853f6d0e1dSmrg	  # Preserve sysroot, but never include relative directories
69863f6d0e1dSmrg	  case $dir in
69873f6d0e1dSmrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
69883f6d0e1dSmrg	    *) func_append deplibs " -L$dir" ;;
69893f6d0e1dSmrg	  esac
69903f6d0e1dSmrg	  func_append lib_search_path " $dir"
6991c3c9db83Smrg	  ;;
6992c3c9db83Smrg	esac
6993c3c9db83Smrg	case $host in
6994c3c9db83Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
69953f6d0e1dSmrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
6996c3c9db83Smrg	  case :$dllsearchpath: in
6997c3c9db83Smrg	  *":$dir:"*) ;;
6998c3c9db83Smrg	  ::) dllsearchpath=$dir;;
69993f6d0e1dSmrg	  *) func_append dllsearchpath ":$dir";;
7000c3c9db83Smrg	  esac
7001c3c9db83Smrg	  case :$dllsearchpath: in
7002c3c9db83Smrg	  *":$testbindir:"*) ;;
7003c3c9db83Smrg	  ::) dllsearchpath=$testbindir;;
70043f6d0e1dSmrg	  *) func_append dllsearchpath ":$testbindir";;
7005c3c9db83Smrg	  esac
7006c3c9db83Smrg	  ;;
7007c3c9db83Smrg	esac
7008c3c9db83Smrg	continue
7009c3c9db83Smrg	;;
701085ee4c00Smrg
7011c3c9db83Smrg      -l*)
70122f60eb46Smrg	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
7013c3c9db83Smrg	  case $host in
70143f6d0e1dSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
7015c3c9db83Smrg	    # These systems don't actually have a C or math library (as such)
7016c3c9db83Smrg	    continue
7017c3c9db83Smrg	    ;;
7018c3c9db83Smrg	  *-*-os2*)
7019c3c9db83Smrg	    # These systems don't actually have a C library (as such)
70202f60eb46Smrg	    test X-lc = "X$arg" && continue
7021c3c9db83Smrg	    ;;
70222f60eb46Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
7023c3c9db83Smrg	    # Do not include libc due to us having libc/libc_r.
70242f60eb46Smrg	    test X-lc = "X$arg" && continue
7025c3c9db83Smrg	    ;;
7026c3c9db83Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
7027c3c9db83Smrg	    # Rhapsody C and math libraries are in the System framework
70283f6d0e1dSmrg	    func_append deplibs " System.ltframework"
7029c3c9db83Smrg	    continue
7030c3c9db83Smrg	    ;;
7031c3c9db83Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
7032c3c9db83Smrg	    # Causes problems with __ctype
70332f60eb46Smrg	    test X-lc = "X$arg" && continue
7034c3c9db83Smrg	    ;;
7035c3c9db83Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7036c3c9db83Smrg	    # Compiler inserts libc in the correct place for threads to work
70372f60eb46Smrg	    test X-lc = "X$arg" && continue
7038c3c9db83Smrg	    ;;
7039c3c9db83Smrg	  esac
70402f60eb46Smrg	elif test X-lc_r = "X$arg"; then
7041c3c9db83Smrg	 case $host in
70422f60eb46Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
7043c3c9db83Smrg	   # Do not include libc_r directly, use -pthread flag.
7044c3c9db83Smrg	   continue
7045c3c9db83Smrg	   ;;
7046c3c9db83Smrg	 esac
7047c3c9db83Smrg	fi
70483f6d0e1dSmrg	func_append deplibs " $arg"
7049c3c9db83Smrg	continue
7050c3c9db83Smrg	;;
705185ee4c00Smrg
70522f60eb46Smrg      -mllvm)
70532f60eb46Smrg	prev=mllvm
70542f60eb46Smrg	continue
70552f60eb46Smrg	;;
70562f60eb46Smrg
7057c3c9db83Smrg      -module)
7058c3c9db83Smrg	module=yes
7059c3c9db83Smrg	continue
7060c3c9db83Smrg	;;
706185ee4c00Smrg
7062c3c9db83Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
7063c3c9db83Smrg      # classes, name mangling, and exception handling.
7064c3c9db83Smrg      # Darwin uses the -arch flag to determine output architecture.
70653f6d0e1dSmrg      -model|-arch|-isysroot|--sysroot)
70663f6d0e1dSmrg	func_append compiler_flags " $arg"
7067c3c9db83Smrg	func_append compile_command " $arg"
7068c3c9db83Smrg	func_append finalize_command " $arg"
7069c3c9db83Smrg	prev=xcompiler
7070c3c9db83Smrg	continue
7071c3c9db83Smrg	;;
707285ee4c00Smrg
707395903e71Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
707495903e71Smrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
70753f6d0e1dSmrg	func_append compiler_flags " $arg"
7076c3c9db83Smrg	func_append compile_command " $arg"
7077c3c9db83Smrg	func_append finalize_command " $arg"
7078c3c9db83Smrg	case "$new_inherited_linker_flags " in
7079c3c9db83Smrg	    *" $arg "*) ;;
70803f6d0e1dSmrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
7081c3c9db83Smrg	esac
7082c3c9db83Smrg	continue
7083c3c9db83Smrg	;;
708485ee4c00Smrg
7085c3c9db83Smrg      -multi_module)
70862f60eb46Smrg	single_module=$wl-multi_module
7087c3c9db83Smrg	continue
7088c3c9db83Smrg	;;
708985ee4c00Smrg
7090c3c9db83Smrg      -no-fast-install)
7091c3c9db83Smrg	fast_install=no
7092c3c9db83Smrg	continue
7093c3c9db83Smrg	;;
709485ee4c00Smrg
7095c3c9db83Smrg      -no-install)
7096c3c9db83Smrg	case $host in
7097c3c9db83Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
7098c3c9db83Smrg	  # The PATH hackery in wrapper scripts is required on Windows
7099c3c9db83Smrg	  # and Darwin in order for the loader to find any dlls it needs.
71002f60eb46Smrg	  func_warning "'-no-install' is ignored for $host"
71012f60eb46Smrg	  func_warning "assuming '-no-fast-install' instead"
7102c3c9db83Smrg	  fast_install=no
7103c3c9db83Smrg	  ;;
7104c3c9db83Smrg	*) no_install=yes ;;
7105c3c9db83Smrg	esac
7106c3c9db83Smrg	continue
7107c3c9db83Smrg	;;
710885ee4c00Smrg
7109c3c9db83Smrg      -no-undefined)
7110c3c9db83Smrg	allow_undefined=no
7111c3c9db83Smrg	continue
7112c3c9db83Smrg	;;
711385ee4c00Smrg
7114c3c9db83Smrg      -objectlist)
7115c3c9db83Smrg	prev=objectlist
7116c3c9db83Smrg	continue
7117c3c9db83Smrg	;;
711885ee4c00Smrg
71192f60eb46Smrg      -os2dllname)
71202f60eb46Smrg	prev=os2dllname
71212f60eb46Smrg	continue
71222f60eb46Smrg	;;
71232f60eb46Smrg
7124c3c9db83Smrg      -o) prev=output ;;
712585ee4c00Smrg
7126c3c9db83Smrg      -precious-files-regex)
7127c3c9db83Smrg	prev=precious_regex
7128c3c9db83Smrg	continue
7129c3c9db83Smrg	;;
713085ee4c00Smrg
7131c3c9db83Smrg      -release)
7132c3c9db83Smrg	prev=release
7133c3c9db83Smrg	continue
7134c3c9db83Smrg	;;
713585ee4c00Smrg
7136c3c9db83Smrg      -rpath)
7137c3c9db83Smrg	prev=rpath
7138c3c9db83Smrg	continue
7139c3c9db83Smrg	;;
714085ee4c00Smrg
7141c3c9db83Smrg      -R)
7142c3c9db83Smrg	prev=xrpath
7143c3c9db83Smrg	continue
7144c3c9db83Smrg	;;
714585ee4c00Smrg
7146c3c9db83Smrg      -R*)
7147c3c9db83Smrg	func_stripname '-R' '' "$arg"
7148c3c9db83Smrg	dir=$func_stripname_result
7149c3c9db83Smrg	# We need an absolute path.
7150c3c9db83Smrg	case $dir in
7151c3c9db83Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
71523f6d0e1dSmrg	=*)
71533f6d0e1dSmrg	  func_stripname '=' '' "$dir"
71543f6d0e1dSmrg	  dir=$lt_sysroot$func_stripname_result
71553f6d0e1dSmrg	  ;;
7156c3c9db83Smrg	*)
7157c3c9db83Smrg	  func_fatal_error "only absolute run-paths are allowed"
7158c3c9db83Smrg	  ;;
7159c3c9db83Smrg	esac
7160c3c9db83Smrg	case "$xrpath " in
7161c3c9db83Smrg	*" $dir "*) ;;
71623f6d0e1dSmrg	*) func_append xrpath " $dir" ;;
7163c3c9db83Smrg	esac
7164c3c9db83Smrg	continue
7165c3c9db83Smrg	;;
716685ee4c00Smrg
7167c3c9db83Smrg      -shared)
7168c3c9db83Smrg	# The effects of -shared are defined in a previous loop.
7169c3c9db83Smrg	continue
7170c3c9db83Smrg	;;
717185ee4c00Smrg
7172c3c9db83Smrg      -shrext)
7173c3c9db83Smrg	prev=shrext
7174c3c9db83Smrg	continue
7175c3c9db83Smrg	;;
717685ee4c00Smrg
7177c3c9db83Smrg      -static | -static-libtool-libs)
7178c3c9db83Smrg	# The effects of -static are defined in a previous loop.
7179c3c9db83Smrg	# We used to do the same as -all-static on platforms that
7180c3c9db83Smrg	# didn't have a PIC flag, but the assumption that the effects
7181c3c9db83Smrg	# would be equivalent was wrong.  It would break on at least
7182c3c9db83Smrg	# Digital Unix and AIX.
7183c3c9db83Smrg	continue
7184c3c9db83Smrg	;;
718585ee4c00Smrg
7186c3c9db83Smrg      -thread-safe)
7187c3c9db83Smrg	thread_safe=yes
7188c3c9db83Smrg	continue
7189c3c9db83Smrg	;;
719085ee4c00Smrg
7191c3c9db83Smrg      -version-info)
7192c3c9db83Smrg	prev=vinfo
7193c3c9db83Smrg	continue
7194c3c9db83Smrg	;;
719585ee4c00Smrg
7196c3c9db83Smrg      -version-number)
7197c3c9db83Smrg	prev=vinfo
7198c3c9db83Smrg	vinfo_number=yes
7199c3c9db83Smrg	continue
7200c3c9db83Smrg	;;
720185ee4c00Smrg
7202c3c9db83Smrg      -weak)
7203c3c9db83Smrg        prev=weak
7204c3c9db83Smrg	continue
7205c3c9db83Smrg	;;
7206692f60a7Smrg
7207c3c9db83Smrg      -Wc,*)
7208c3c9db83Smrg	func_stripname '-Wc,' '' "$arg"
7209c3c9db83Smrg	args=$func_stripname_result
7210c3c9db83Smrg	arg=
72112f60eb46Smrg	save_ifs=$IFS; IFS=,
7212c3c9db83Smrg	for flag in $args; do
72132f60eb46Smrg	  IFS=$save_ifs
7214c3c9db83Smrg          func_quote_for_eval "$flag"
72153f6d0e1dSmrg	  func_append arg " $func_quote_for_eval_result"
72163f6d0e1dSmrg	  func_append compiler_flags " $func_quote_for_eval_result"
7217c3c9db83Smrg	done
72182f60eb46Smrg	IFS=$save_ifs
7219c3c9db83Smrg	func_stripname ' ' '' "$arg"
7220c3c9db83Smrg	arg=$func_stripname_result
7221c3c9db83Smrg	;;
72222e71ea71Smrg
7223c3c9db83Smrg      -Wl,*)
7224c3c9db83Smrg	func_stripname '-Wl,' '' "$arg"
7225c3c9db83Smrg	args=$func_stripname_result
7226c3c9db83Smrg	arg=
72272f60eb46Smrg	save_ifs=$IFS; IFS=,
7228c3c9db83Smrg	for flag in $args; do
72292f60eb46Smrg	  IFS=$save_ifs
7230c3c9db83Smrg          func_quote_for_eval "$flag"
72313f6d0e1dSmrg	  func_append arg " $wl$func_quote_for_eval_result"
72323f6d0e1dSmrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
72333f6d0e1dSmrg	  func_append linker_flags " $func_quote_for_eval_result"
7234c3c9db83Smrg	done
72352f60eb46Smrg	IFS=$save_ifs
7236c3c9db83Smrg	func_stripname ' ' '' "$arg"
7237c3c9db83Smrg	arg=$func_stripname_result
7238c3c9db83Smrg	;;
72392e71ea71Smrg
7240c3c9db83Smrg      -Xcompiler)
7241c3c9db83Smrg	prev=xcompiler
7242c3c9db83Smrg	continue
7243c3c9db83Smrg	;;
72442e71ea71Smrg
7245c3c9db83Smrg      -Xlinker)
7246c3c9db83Smrg	prev=xlinker
7247c3c9db83Smrg	continue
7248c3c9db83Smrg	;;
72492e71ea71Smrg
7250c3c9db83Smrg      -XCClinker)
7251c3c9db83Smrg	prev=xcclinker
7252c3c9db83Smrg	continue
7253c3c9db83Smrg	;;
72542e71ea71Smrg
7255c3c9db83Smrg      # -msg_* for osf cc
7256c3c9db83Smrg      -msg_*)
7257c3c9db83Smrg	func_quote_for_eval "$arg"
72582f60eb46Smrg	arg=$func_quote_for_eval_result
7259c3c9db83Smrg	;;
72602e71ea71Smrg
72613f6d0e1dSmrg      # Flags to be passed through unchanged, with rationale:
72623f6d0e1dSmrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
72633f6d0e1dSmrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
72643f6d0e1dSmrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
72653f6d0e1dSmrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
72663f6d0e1dSmrg      # -q*                  compiler args for the IBM compiler
72673f6d0e1dSmrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
72683f6d0e1dSmrg      # -F/path              path to uninstalled frameworks, gcc on darwin
72693f6d0e1dSmrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
72702f60eb46Smrg      # -fstack-protector*   stack protector flags for GCC
72713f6d0e1dSmrg      # @file                GCC response files
72723f6d0e1dSmrg      # -tp=*                Portland pgcc target processor selection
72733f6d0e1dSmrg      # --sysroot=*          for sysroot support
72742f60eb46Smrg      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
72752f60eb46Smrg      # -specs=*             GCC specs files
72762f60eb46Smrg      # -stdlib=*            select c++ std lib with clang
72772f60eb46Smrg      # -fsanitize=*         Clang/GCC memory and address sanitizer
7278c3c9db83Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
72793f6d0e1dSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
72802f60eb46Smrg      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
72812f60eb46Smrg      -specs=*|-fsanitize=*)
7282c3c9db83Smrg        func_quote_for_eval "$arg"
72832f60eb46Smrg	arg=$func_quote_for_eval_result
7284c3c9db83Smrg        func_append compile_command " $arg"
7285c3c9db83Smrg        func_append finalize_command " $arg"
72863f6d0e1dSmrg        func_append compiler_flags " $arg"
7287c3c9db83Smrg        continue
7288c3c9db83Smrg        ;;
72892e71ea71Smrg
72902f60eb46Smrg      -Z*)
72912f60eb46Smrg        if test os2 = "`expr $host : '.*\(os2\)'`"; then
72922f60eb46Smrg          # OS/2 uses -Zxxx to specify OS/2-specific options
72932f60eb46Smrg	  compiler_flags="$compiler_flags $arg"
72942f60eb46Smrg	  func_append compile_command " $arg"
72952f60eb46Smrg	  func_append finalize_command " $arg"
72962f60eb46Smrg	  case $arg in
72972f60eb46Smrg	  -Zlinker | -Zstack)
72982f60eb46Smrg	    prev=xcompiler
72992f60eb46Smrg	    ;;
73002f60eb46Smrg	  esac
73012f60eb46Smrg	  continue
73022f60eb46Smrg        else
73032f60eb46Smrg	  # Otherwise treat like 'Some other compiler flag' below
73042f60eb46Smrg	  func_quote_for_eval "$arg"
73052f60eb46Smrg	  arg=$func_quote_for_eval_result
73062f60eb46Smrg        fi
73072f60eb46Smrg	;;
73082f60eb46Smrg
7309c3c9db83Smrg      # Some other compiler flag.
7310c3c9db83Smrg      -* | +*)
7311c3c9db83Smrg        func_quote_for_eval "$arg"
73122f60eb46Smrg	arg=$func_quote_for_eval_result
7313c3c9db83Smrg	;;
73142e71ea71Smrg
7315c3c9db83Smrg      *.$objext)
7316c3c9db83Smrg	# A standard object.
73173f6d0e1dSmrg	func_append objs " $arg"
7318c3c9db83Smrg	;;
73192e71ea71Smrg
7320c3c9db83Smrg      *.lo)
7321c3c9db83Smrg	# A libtool-controlled object.
73222e71ea71Smrg
7323c3c9db83Smrg	# Check to see that this really is a libtool object.
7324c3c9db83Smrg	if func_lalib_unsafe_p "$arg"; then
7325c3c9db83Smrg	  pic_object=
7326c3c9db83Smrg	  non_pic_object=
73272e71ea71Smrg
7328c3c9db83Smrg	  # Read the .lo file
7329c3c9db83Smrg	  func_source "$arg"
73302e71ea71Smrg
7331c3c9db83Smrg	  if test -z "$pic_object" ||
7332c3c9db83Smrg	     test -z "$non_pic_object" ||
73332f60eb46Smrg	     test none = "$pic_object" &&
73342f60eb46Smrg	     test none = "$non_pic_object"; then
73352f60eb46Smrg	    func_fatal_error "cannot find name of object for '$arg'"
7336c3c9db83Smrg	  fi
73372e71ea71Smrg
7338c3c9db83Smrg	  # Extract subdirectory from the argument.
7339c3c9db83Smrg	  func_dirname "$arg" "/" ""
73402f60eb46Smrg	  xdir=$func_dirname_result
73412e71ea71Smrg
73422f60eb46Smrg	  test none = "$pic_object" || {
7343c3c9db83Smrg	    # Prepend the subdirectory the object is found in.
73442f60eb46Smrg	    pic_object=$xdir$pic_object
73452e71ea71Smrg
73462f60eb46Smrg	    if test dlfiles = "$prev"; then
73472f60eb46Smrg	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
73483f6d0e1dSmrg		func_append dlfiles " $pic_object"
7349c3c9db83Smrg		prev=
7350c3c9db83Smrg		continue
7351c3c9db83Smrg	      else
7352c3c9db83Smrg		# If libtool objects are unsupported, then we need to preload.
7353c3c9db83Smrg		prev=dlprefiles
7354c3c9db83Smrg	      fi
7355c3c9db83Smrg	    fi
73562e71ea71Smrg
7357c3c9db83Smrg	    # CHECK ME:  I think I busted this.  -Ossama
73582f60eb46Smrg	    if test dlprefiles = "$prev"; then
7359c3c9db83Smrg	      # Preload the old-style object.
73603f6d0e1dSmrg	      func_append dlprefiles " $pic_object"
7361c3c9db83Smrg	      prev=
7362c3c9db83Smrg	    fi
7363692f60a7Smrg
7364c3c9db83Smrg	    # A PIC object.
7365c3c9db83Smrg	    func_append libobjs " $pic_object"
73662f60eb46Smrg	    arg=$pic_object
73672f60eb46Smrg	  }
7368692f60a7Smrg
7369c3c9db83Smrg	  # Non-PIC object.
73702f60eb46Smrg	  if test none != "$non_pic_object"; then
7371c3c9db83Smrg	    # Prepend the subdirectory the object is found in.
73722f60eb46Smrg	    non_pic_object=$xdir$non_pic_object
7373692f60a7Smrg
7374c3c9db83Smrg	    # A standard non-PIC object
7375c3c9db83Smrg	    func_append non_pic_objects " $non_pic_object"
73762f60eb46Smrg	    if test -z "$pic_object" || test none = "$pic_object"; then
73772f60eb46Smrg	      arg=$non_pic_object
7378c3c9db83Smrg	    fi
7379c3c9db83Smrg	  else
7380c3c9db83Smrg	    # If the PIC object exists, use it instead.
7381c3c9db83Smrg	    # $xdir was prepended to $pic_object above.
73822f60eb46Smrg	    non_pic_object=$pic_object
7383c3c9db83Smrg	    func_append non_pic_objects " $non_pic_object"
7384c3c9db83Smrg	  fi
7385c3c9db83Smrg	else
7386c3c9db83Smrg	  # Only an error if not doing a dry-run.
7387c3c9db83Smrg	  if $opt_dry_run; then
7388c3c9db83Smrg	    # Extract subdirectory from the argument.
7389c3c9db83Smrg	    func_dirname "$arg" "/" ""
73902f60eb46Smrg	    xdir=$func_dirname_result
7391c3c9db83Smrg
7392c3c9db83Smrg	    func_lo2o "$arg"
7393c3c9db83Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
7394c3c9db83Smrg	    non_pic_object=$xdir$func_lo2o_result
7395c3c9db83Smrg	    func_append libobjs " $pic_object"
7396c3c9db83Smrg	    func_append non_pic_objects " $non_pic_object"
7397c3c9db83Smrg	  else
73982f60eb46Smrg	    func_fatal_error "'$arg' is not a valid libtool object"
7399c3c9db83Smrg	  fi
7400c3c9db83Smrg	fi
7401c3c9db83Smrg	;;
7402692f60a7Smrg
7403c3c9db83Smrg      *.$libext)
7404c3c9db83Smrg	# An archive.
74053f6d0e1dSmrg	func_append deplibs " $arg"
74063f6d0e1dSmrg	func_append old_deplibs " $arg"
7407c3c9db83Smrg	continue
7408c3c9db83Smrg	;;
7409c3c9db83Smrg
7410c3c9db83Smrg      *.la)
7411c3c9db83Smrg	# A libtool-controlled library.
7412c3c9db83Smrg
74133f6d0e1dSmrg	func_resolve_sysroot "$arg"
74142f60eb46Smrg	if test dlfiles = "$prev"; then
7415c3c9db83Smrg	  # This library was specified with -dlopen.
74163f6d0e1dSmrg	  func_append dlfiles " $func_resolve_sysroot_result"
7417c3c9db83Smrg	  prev=
74182f60eb46Smrg	elif test dlprefiles = "$prev"; then
7419c3c9db83Smrg	  # The library was specified with -dlpreopen.
74203f6d0e1dSmrg	  func_append dlprefiles " $func_resolve_sysroot_result"
7421c3c9db83Smrg	  prev=
7422c3c9db83Smrg	else
74233f6d0e1dSmrg	  func_append deplibs " $func_resolve_sysroot_result"
7424c3c9db83Smrg	fi
7425c3c9db83Smrg	continue
7426c3c9db83Smrg	;;
7427c3c9db83Smrg
7428c3c9db83Smrg      # Some other compiler argument.
7429c3c9db83Smrg      *)
7430c3c9db83Smrg	# Unknown arguments in both finalize_command and compile_command need
7431c3c9db83Smrg	# to be aesthetically quoted because they are evaled later.
7432c3c9db83Smrg	func_quote_for_eval "$arg"
74332f60eb46Smrg	arg=$func_quote_for_eval_result
7434c3c9db83Smrg	;;
7435c3c9db83Smrg      esac # arg
7436c3c9db83Smrg
7437c3c9db83Smrg      # Now actually substitute the argument into the commands.
7438c3c9db83Smrg      if test -n "$arg"; then
7439c3c9db83Smrg	func_append compile_command " $arg"
7440c3c9db83Smrg	func_append finalize_command " $arg"
7441c3c9db83Smrg      fi
7442c3c9db83Smrg    done # argument parsing loop
7443c3c9db83Smrg
7444c3c9db83Smrg    test -n "$prev" && \
74452f60eb46Smrg      func_fatal_help "the '$prevarg' option requires an argument"
7446c3c9db83Smrg
74472f60eb46Smrg    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
7448c3c9db83Smrg      eval arg=\"$export_dynamic_flag_spec\"
7449c3c9db83Smrg      func_append compile_command " $arg"
7450c3c9db83Smrg      func_append finalize_command " $arg"
7451c3c9db83Smrg    fi
7452c3c9db83Smrg
7453c3c9db83Smrg    oldlibs=
7454c3c9db83Smrg    # calculate the name of the file, without its directory
7455c3c9db83Smrg    func_basename "$output"
74562f60eb46Smrg    outputname=$func_basename_result
74572f60eb46Smrg    libobjs_save=$libobjs
7458c3c9db83Smrg
7459c3c9db83Smrg    if test -n "$shlibpath_var"; then
7460c3c9db83Smrg      # get the directories listed in $shlibpath_var
74612f60eb46Smrg      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
7462c3c9db83Smrg    else
7463c3c9db83Smrg      shlib_search_path=
7464c3c9db83Smrg    fi
7465c3c9db83Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
7466c3c9db83Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
7467c3c9db83Smrg
74682f60eb46Smrg    # Definition is injected by LT_CONFIG during libtool generation.
74692f60eb46Smrg    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
74702f60eb46Smrg
7471c3c9db83Smrg    func_dirname "$output" "/" ""
74722f60eb46Smrg    output_objdir=$func_dirname_result$objdir
74733f6d0e1dSmrg    func_to_tool_file "$output_objdir/"
74743f6d0e1dSmrg    tool_output_objdir=$func_to_tool_file_result
7475c3c9db83Smrg    # Create the object directory.
7476c3c9db83Smrg    func_mkdir_p "$output_objdir"
7477c3c9db83Smrg
7478c3c9db83Smrg    # Determine the type of output
7479c3c9db83Smrg    case $output in
7480c3c9db83Smrg    "")
7481c3c9db83Smrg      func_fatal_help "you must specify an output file"
7482c3c9db83Smrg      ;;
7483c3c9db83Smrg    *.$libext) linkmode=oldlib ;;
7484c3c9db83Smrg    *.lo | *.$objext) linkmode=obj ;;
7485c3c9db83Smrg    *.la) linkmode=lib ;;
7486c3c9db83Smrg    *) linkmode=prog ;; # Anything else should be a program.
7487c3c9db83Smrg    esac
7488c3c9db83Smrg
7489c3c9db83Smrg    specialdeplibs=
7490c3c9db83Smrg
7491c3c9db83Smrg    libs=
7492c3c9db83Smrg    # Find all interdependent deplibs by searching for libraries
7493c3c9db83Smrg    # that are linked more than once (e.g. -la -lb -la)
7494c3c9db83Smrg    for deplib in $deplibs; do
74952f60eb46Smrg      if $opt_preserve_dup_deps; then
7496c3c9db83Smrg	case "$libs " in
74973f6d0e1dSmrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
7498c3c9db83Smrg	esac
7499c3c9db83Smrg      fi
75003f6d0e1dSmrg      func_append libs " $deplib"
7501c3c9db83Smrg    done
7502c3c9db83Smrg
75032f60eb46Smrg    if test lib = "$linkmode"; then
7504c3c9db83Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
7505c3c9db83Smrg
7506c3c9db83Smrg      # Compute libraries that are listed more than once in $predeps
7507c3c9db83Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
7508c3c9db83Smrg      # not to be eliminated).
7509c3c9db83Smrg      pre_post_deps=
7510c3c9db83Smrg      if $opt_duplicate_compiler_generated_deps; then
7511c3c9db83Smrg	for pre_post_dep in $predeps $postdeps; do
7512c3c9db83Smrg	  case "$pre_post_deps " in
75133f6d0e1dSmrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
7514c3c9db83Smrg	  esac
75153f6d0e1dSmrg	  func_append pre_post_deps " $pre_post_dep"
7516c3c9db83Smrg	done
7517c3c9db83Smrg      fi
7518c3c9db83Smrg      pre_post_deps=
7519c3c9db83Smrg    fi
7520c3c9db83Smrg
7521c3c9db83Smrg    deplibs=
7522c3c9db83Smrg    newdependency_libs=
7523c3c9db83Smrg    newlib_search_path=
7524c3c9db83Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
7525c3c9db83Smrg    notinst_deplibs= # not-installed libtool libraries
7526c3c9db83Smrg    notinst_path= # paths that contain not-installed libtool libraries
7527c3c9db83Smrg
7528c3c9db83Smrg    case $linkmode in
7529c3c9db83Smrg    lib)
7530c3c9db83Smrg	passes="conv dlpreopen link"
7531c3c9db83Smrg	for file in $dlfiles $dlprefiles; do
7532c3c9db83Smrg	  case $file in
7533c3c9db83Smrg	  *.la) ;;
7534c3c9db83Smrg	  *)
75352f60eb46Smrg	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
7536c3c9db83Smrg	    ;;
7537c3c9db83Smrg	  esac
7538c3c9db83Smrg	done
7539c3c9db83Smrg	;;
7540c3c9db83Smrg    prog)
7541c3c9db83Smrg	compile_deplibs=
7542c3c9db83Smrg	finalize_deplibs=
75432f60eb46Smrg	alldeplibs=false
7544c3c9db83Smrg	newdlfiles=
7545c3c9db83Smrg	newdlprefiles=
7546c3c9db83Smrg	passes="conv scan dlopen dlpreopen link"
7547c3c9db83Smrg	;;
7548c3c9db83Smrg    *)  passes="conv"
7549c3c9db83Smrg	;;
7550c3c9db83Smrg    esac
7551c3c9db83Smrg
7552c3c9db83Smrg    for pass in $passes; do
7553c3c9db83Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
7554c3c9db83Smrg      # so that -L comes before libs that need it for instance...
75552f60eb46Smrg      if test lib,link = "$linkmode,$pass"; then
7556c3c9db83Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
7557c3c9db83Smrg	##        order, and fix it there properly
7558c3c9db83Smrg        tmp_deplibs=
7559c3c9db83Smrg	for deplib in $deplibs; do
7560c3c9db83Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
7561c3c9db83Smrg	done
75622f60eb46Smrg	deplibs=$tmp_deplibs
7563c3c9db83Smrg      fi
7564c3c9db83Smrg
75652f60eb46Smrg      if test lib,link = "$linkmode,$pass" ||
75662f60eb46Smrg	 test prog,scan = "$linkmode,$pass"; then
75672f60eb46Smrg	libs=$deplibs
7568c3c9db83Smrg	deplibs=
7569c3c9db83Smrg      fi
75702f60eb46Smrg      if test prog = "$linkmode"; then
7571c3c9db83Smrg	case $pass in
75722f60eb46Smrg	dlopen) libs=$dlfiles ;;
75732f60eb46Smrg	dlpreopen) libs=$dlprefiles ;;
757495903e71Smrg	link)
757595903e71Smrg	  libs="$deplibs %DEPLIBS%"
757695903e71Smrg	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
757795903e71Smrg	  ;;
7578c3c9db83Smrg	esac
7579c3c9db83Smrg      fi
75802f60eb46Smrg      if test lib,dlpreopen = "$linkmode,$pass"; then
7581c3c9db83Smrg	# Collect and forward deplibs of preopened libtool libs
7582c3c9db83Smrg	for lib in $dlprefiles; do
7583c3c9db83Smrg	  # Ignore non-libtool-libs
7584c3c9db83Smrg	  dependency_libs=
75853f6d0e1dSmrg	  func_resolve_sysroot "$lib"
7586c3c9db83Smrg	  case $lib in
75873f6d0e1dSmrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
7588c3c9db83Smrg	  esac
7589c3c9db83Smrg
7590c3c9db83Smrg	  # Collect preopened libtool deplibs, except any this library
7591c3c9db83Smrg	  # has declared as weak libs
7592c3c9db83Smrg	  for deplib in $dependency_libs; do
75933f6d0e1dSmrg	    func_basename "$deplib"
75943f6d0e1dSmrg            deplib_base=$func_basename_result
7595c3c9db83Smrg	    case " $weak_libs " in
7596c3c9db83Smrg	    *" $deplib_base "*) ;;
75973f6d0e1dSmrg	    *) func_append deplibs " $deplib" ;;
7598c3c9db83Smrg	    esac
7599c3c9db83Smrg	  done
7600c3c9db83Smrg	done
76012f60eb46Smrg	libs=$dlprefiles
7602c3c9db83Smrg      fi
76032f60eb46Smrg      if test dlopen = "$pass"; then
7604c3c9db83Smrg	# Collect dlpreopened libraries
76052f60eb46Smrg	save_deplibs=$deplibs
7606c3c9db83Smrg	deplibs=
7607c3c9db83Smrg      fi
7608c3c9db83Smrg
7609c3c9db83Smrg      for deplib in $libs; do
7610c3c9db83Smrg	lib=
76112f60eb46Smrg	found=false
7612c3c9db83Smrg	case $deplib in
761395903e71Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
761495903e71Smrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
76152f60eb46Smrg	  if test prog,link = "$linkmode,$pass"; then
7616c3c9db83Smrg	    compile_deplibs="$deplib $compile_deplibs"
7617c3c9db83Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
7618c3c9db83Smrg	  else
76193f6d0e1dSmrg	    func_append compiler_flags " $deplib"
76202f60eb46Smrg	    if test lib = "$linkmode"; then
7621c3c9db83Smrg		case "$new_inherited_linker_flags " in
7622c3c9db83Smrg		    *" $deplib "*) ;;
76233f6d0e1dSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
7624c3c9db83Smrg		esac
7625c3c9db83Smrg	    fi
7626c3c9db83Smrg	  fi
7627c3c9db83Smrg	  continue
7628c3c9db83Smrg	  ;;
7629c3c9db83Smrg	-l*)
76302f60eb46Smrg	  if test lib != "$linkmode" && test prog != "$linkmode"; then
76312f60eb46Smrg	    func_warning "'-l' is ignored for archives/objects"
7632c3c9db83Smrg	    continue
7633c3c9db83Smrg	  fi
7634c3c9db83Smrg	  func_stripname '-l' '' "$deplib"
7635c3c9db83Smrg	  name=$func_stripname_result
76362f60eb46Smrg	  if test lib = "$linkmode"; then
7637c3c9db83Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
7638c3c9db83Smrg	  else
7639c3c9db83Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
7640c3c9db83Smrg	  fi
7641c3c9db83Smrg	  for searchdir in $searchdirs; do
7642c3c9db83Smrg	    for search_ext in .la $std_shrext .so .a; do
7643c3c9db83Smrg	      # Search the libtool library
76442f60eb46Smrg	      lib=$searchdir/lib$name$search_ext
7645c3c9db83Smrg	      if test -f "$lib"; then
76462f60eb46Smrg		if test .la = "$search_ext"; then
76472f60eb46Smrg		  found=:
7648c3c9db83Smrg		else
76492f60eb46Smrg		  found=false
7650c3c9db83Smrg		fi
7651c3c9db83Smrg		break 2
7652c3c9db83Smrg	      fi
7653c3c9db83Smrg	    done
7654c3c9db83Smrg	  done
76552f60eb46Smrg	  if $found; then
76562f60eb46Smrg	    # deplib is a libtool library
7657c3c9db83Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
7658c3c9db83Smrg	    # We need to do some special things here, and not later.
76592f60eb46Smrg	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
7660c3c9db83Smrg	      case " $predeps $postdeps " in
7661c3c9db83Smrg	      *" $deplib "*)
7662c3c9db83Smrg		if func_lalib_p "$lib"; then
7663c3c9db83Smrg		  library_names=
7664c3c9db83Smrg		  old_library=
7665c3c9db83Smrg		  func_source "$lib"
7666c3c9db83Smrg		  for l in $old_library $library_names; do
76672f60eb46Smrg		    ll=$l
7668c3c9db83Smrg		  done
76692f60eb46Smrg		  if test "X$ll" = "X$old_library"; then # only static version available
76702f60eb46Smrg		    found=false
7671c3c9db83Smrg		    func_dirname "$lib" "" "."
76722f60eb46Smrg		    ladir=$func_dirname_result
7673c3c9db83Smrg		    lib=$ladir/$old_library
76742f60eb46Smrg		    if test prog,link = "$linkmode,$pass"; then
7675c3c9db83Smrg		      compile_deplibs="$deplib $compile_deplibs"
7676c3c9db83Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
7677c3c9db83Smrg		    else
7678c3c9db83Smrg		      deplibs="$deplib $deplibs"
76792f60eb46Smrg		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7680c3c9db83Smrg		    fi
7681c3c9db83Smrg		    continue
7682c3c9db83Smrg		  fi
7683c3c9db83Smrg		fi
7684c3c9db83Smrg		;;
7685c3c9db83Smrg	      *) ;;
7686c3c9db83Smrg	      esac
7687c3c9db83Smrg	    fi
76882f60eb46Smrg	  else
76892f60eb46Smrg	    # deplib doesn't seem to be a libtool library
76902f60eb46Smrg	    if test prog,link = "$linkmode,$pass"; then
76912f60eb46Smrg	      compile_deplibs="$deplib $compile_deplibs"
76922f60eb46Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
76932f60eb46Smrg	    else
76942f60eb46Smrg	      deplibs="$deplib $deplibs"
76952f60eb46Smrg	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
76962f60eb46Smrg	    fi
76972f60eb46Smrg	    continue
7698c3c9db83Smrg	  fi
7699c3c9db83Smrg	  ;; # -l
7700c3c9db83Smrg	*.ltframework)
77012f60eb46Smrg	  if test prog,link = "$linkmode,$pass"; then
7702c3c9db83Smrg	    compile_deplibs="$deplib $compile_deplibs"
7703c3c9db83Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
7704c3c9db83Smrg	  else
7705c3c9db83Smrg	    deplibs="$deplib $deplibs"
77062f60eb46Smrg	    if test lib = "$linkmode"; then
7707c3c9db83Smrg		case "$new_inherited_linker_flags " in
7708c3c9db83Smrg		    *" $deplib "*) ;;
77093f6d0e1dSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
7710c3c9db83Smrg		esac
7711c3c9db83Smrg	    fi
7712c3c9db83Smrg	  fi
7713c3c9db83Smrg	  continue
7714c3c9db83Smrg	  ;;
7715c3c9db83Smrg	-L*)
7716c3c9db83Smrg	  case $linkmode in
7717c3c9db83Smrg	  lib)
7718c3c9db83Smrg	    deplibs="$deplib $deplibs"
77192f60eb46Smrg	    test conv = "$pass" && continue
7720c3c9db83Smrg	    newdependency_libs="$deplib $newdependency_libs"
7721c3c9db83Smrg	    func_stripname '-L' '' "$deplib"
77223f6d0e1dSmrg	    func_resolve_sysroot "$func_stripname_result"
77233f6d0e1dSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
7724c3c9db83Smrg	    ;;
7725c3c9db83Smrg	  prog)
77262f60eb46Smrg	    if test conv = "$pass"; then
7727c3c9db83Smrg	      deplibs="$deplib $deplibs"
7728c3c9db83Smrg	      continue
7729c3c9db83Smrg	    fi
77302f60eb46Smrg	    if test scan = "$pass"; then
7731c3c9db83Smrg	      deplibs="$deplib $deplibs"
7732c3c9db83Smrg	    else
7733c3c9db83Smrg	      compile_deplibs="$deplib $compile_deplibs"
7734c3c9db83Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
7735c3c9db83Smrg	    fi
7736c3c9db83Smrg	    func_stripname '-L' '' "$deplib"
77373f6d0e1dSmrg	    func_resolve_sysroot "$func_stripname_result"
77383f6d0e1dSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
7739c3c9db83Smrg	    ;;
7740c3c9db83Smrg	  *)
77412f60eb46Smrg	    func_warning "'-L' is ignored for archives/objects"
7742c3c9db83Smrg	    ;;
7743c3c9db83Smrg	  esac # linkmode
7744c3c9db83Smrg	  continue
7745c3c9db83Smrg	  ;; # -L
7746c3c9db83Smrg	-R*)
77472f60eb46Smrg	  if test link = "$pass"; then
7748c3c9db83Smrg	    func_stripname '-R' '' "$deplib"
77493f6d0e1dSmrg	    func_resolve_sysroot "$func_stripname_result"
77503f6d0e1dSmrg	    dir=$func_resolve_sysroot_result
7751c3c9db83Smrg	    # Make sure the xrpath contains only unique directories.
7752c3c9db83Smrg	    case "$xrpath " in
7753c3c9db83Smrg	    *" $dir "*) ;;
77543f6d0e1dSmrg	    *) func_append xrpath " $dir" ;;
7755c3c9db83Smrg	    esac
7756c3c9db83Smrg	  fi
7757c3c9db83Smrg	  deplibs="$deplib $deplibs"
7758c3c9db83Smrg	  continue
7759c3c9db83Smrg	  ;;
77603f6d0e1dSmrg	*.la)
77613f6d0e1dSmrg	  func_resolve_sysroot "$deplib"
77623f6d0e1dSmrg	  lib=$func_resolve_sysroot_result
77633f6d0e1dSmrg	  ;;
7764c3c9db83Smrg	*.$libext)
77652f60eb46Smrg	  if test conv = "$pass"; then
7766c3c9db83Smrg	    deplibs="$deplib $deplibs"
7767c3c9db83Smrg	    continue
7768c3c9db83Smrg	  fi
7769c3c9db83Smrg	  case $linkmode in
7770c3c9db83Smrg	  lib)
7771c3c9db83Smrg	    # Linking convenience modules into shared libraries is allowed,
7772c3c9db83Smrg	    # but linking other static libraries is non-portable.
7773c3c9db83Smrg	    case " $dlpreconveniencelibs " in
7774c3c9db83Smrg	    *" $deplib "*) ;;
7775c3c9db83Smrg	    *)
77762f60eb46Smrg	      valid_a_lib=false
7777c3c9db83Smrg	      case $deplibs_check_method in
7778c3c9db83Smrg		match_pattern*)
7779c3c9db83Smrg		  set dummy $deplibs_check_method; shift
7780c3c9db83Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
77813f6d0e1dSmrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
7782c3c9db83Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
77832f60eb46Smrg		    valid_a_lib=:
7784c3c9db83Smrg		  fi
7785c3c9db83Smrg		;;
7786c3c9db83Smrg		pass_all)
77872f60eb46Smrg		  valid_a_lib=:
7788c3c9db83Smrg		;;
7789c3c9db83Smrg	      esac
77902f60eb46Smrg	      if $valid_a_lib; then
77912f60eb46Smrg		echo
77922f60eb46Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
77932f60eb46Smrg		$ECHO "*** static library $deplib is not portable!"
77942f60eb46Smrg		deplibs="$deplib $deplibs"
77952f60eb46Smrg	      else
77963f6d0e1dSmrg		echo
7797c3c9db83Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
77983f6d0e1dSmrg		echo "*** I have the capability to make that library automatically link in when"
77993f6d0e1dSmrg		echo "*** you link to this library.  But I can only do this if you have a"
78003f6d0e1dSmrg		echo "*** shared version of the library, which you do not appear to have"
78013f6d0e1dSmrg		echo "*** because the file extensions .$libext of this argument makes me believe"
78023f6d0e1dSmrg		echo "*** that it is just a static archive that I should not use here."
7803c3c9db83Smrg	      fi
7804c3c9db83Smrg	      ;;
7805c3c9db83Smrg	    esac
7806c3c9db83Smrg	    continue
7807c3c9db83Smrg	    ;;
7808c3c9db83Smrg	  prog)
78092f60eb46Smrg	    if test link != "$pass"; then
7810c3c9db83Smrg	      deplibs="$deplib $deplibs"
7811c3c9db83Smrg	    else
7812c3c9db83Smrg	      compile_deplibs="$deplib $compile_deplibs"
7813c3c9db83Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
7814c3c9db83Smrg	    fi
7815c3c9db83Smrg	    continue
7816c3c9db83Smrg	    ;;
7817c3c9db83Smrg	  esac # linkmode
7818c3c9db83Smrg	  ;; # *.$libext
7819c3c9db83Smrg	*.lo | *.$objext)
78202f60eb46Smrg	  if test conv = "$pass"; then
7821c3c9db83Smrg	    deplibs="$deplib $deplibs"
78222f60eb46Smrg	  elif test prog = "$linkmode"; then
78232f60eb46Smrg	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
7824c3c9db83Smrg	      # If there is no dlopen support or we're linking statically,
7825c3c9db83Smrg	      # we need to preload.
78263f6d0e1dSmrg	      func_append newdlprefiles " $deplib"
7827c3c9db83Smrg	      compile_deplibs="$deplib $compile_deplibs"
7828c3c9db83Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
7829c3c9db83Smrg	    else
78303f6d0e1dSmrg	      func_append newdlfiles " $deplib"
7831c3c9db83Smrg	    fi
7832c3c9db83Smrg	  fi
7833c3c9db83Smrg	  continue
7834c3c9db83Smrg	  ;;
7835c3c9db83Smrg	%DEPLIBS%)
78362f60eb46Smrg	  alldeplibs=:
7837c3c9db83Smrg	  continue
7838c3c9db83Smrg	  ;;
7839c3c9db83Smrg	esac # case $deplib
7840c3c9db83Smrg
78412f60eb46Smrg	$found || test -f "$lib" \
78422f60eb46Smrg	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
7843c3c9db83Smrg
7844c3c9db83Smrg	# Check to see that this really is a libtool archive.
7845c3c9db83Smrg	func_lalib_unsafe_p "$lib" \
78462f60eb46Smrg	  || func_fatal_error "'$lib' is not a valid libtool archive"
7847c3c9db83Smrg
7848c3c9db83Smrg	func_dirname "$lib" "" "."
78492f60eb46Smrg	ladir=$func_dirname_result
7850c3c9db83Smrg
7851c3c9db83Smrg	dlname=
7852c3c9db83Smrg	dlopen=
7853c3c9db83Smrg	dlpreopen=
7854c3c9db83Smrg	libdir=
7855c3c9db83Smrg	library_names=
7856c3c9db83Smrg	old_library=
7857c3c9db83Smrg	inherited_linker_flags=
7858c3c9db83Smrg	# If the library was installed with an old release of libtool,
7859c3c9db83Smrg	# it will not redefine variables installed, or shouldnotlink
7860c3c9db83Smrg	installed=yes
7861c3c9db83Smrg	shouldnotlink=no
7862c3c9db83Smrg	avoidtemprpath=
7863c3c9db83Smrg
7864c3c9db83Smrg
7865c3c9db83Smrg	# Read the .la file
7866c3c9db83Smrg	func_source "$lib"
7867c3c9db83Smrg
7868c3c9db83Smrg	# Convert "-framework foo" to "foo.ltframework"
7869c3c9db83Smrg	if test -n "$inherited_linker_flags"; then
78703f6d0e1dSmrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
7871c3c9db83Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
7872c3c9db83Smrg	    case " $new_inherited_linker_flags " in
7873c3c9db83Smrg	      *" $tmp_inherited_linker_flag "*) ;;
78743f6d0e1dSmrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
7875c3c9db83Smrg	    esac
7876c3c9db83Smrg	  done
7877c3c9db83Smrg	fi
78783f6d0e1dSmrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
78792f60eb46Smrg	if test lib,link = "$linkmode,$pass" ||
78802f60eb46Smrg	   test prog,scan = "$linkmode,$pass" ||
78812f60eb46Smrg	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
78823f6d0e1dSmrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
78833f6d0e1dSmrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
7884c3c9db83Smrg	fi
7885c3c9db83Smrg
78862f60eb46Smrg	if test conv = "$pass"; then
7887c3c9db83Smrg	  # Only check for convenience libraries
7888c3c9db83Smrg	  deplibs="$lib $deplibs"
7889c3c9db83Smrg	  if test -z "$libdir"; then
7890c3c9db83Smrg	    if test -z "$old_library"; then
78912f60eb46Smrg	      func_fatal_error "cannot find name of link library for '$lib'"
7892c3c9db83Smrg	    fi
7893c3c9db83Smrg	    # It is a libtool convenience library, so add in its objects.
78943f6d0e1dSmrg	    func_append convenience " $ladir/$objdir/$old_library"
78953f6d0e1dSmrg	    func_append old_convenience " $ladir/$objdir/$old_library"
789695903e71Smrg	    tmp_libs=
789795903e71Smrg	    for deplib in $dependency_libs; do
789895903e71Smrg	      deplibs="$deplib $deplibs"
78992f60eb46Smrg	      if $opt_preserve_dup_deps; then
790095903e71Smrg		case "$tmp_libs " in
790195903e71Smrg		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
790295903e71Smrg		esac
790395903e71Smrg	      fi
790495903e71Smrg	      func_append tmp_libs " $deplib"
790595903e71Smrg	    done
79062f60eb46Smrg	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
79072f60eb46Smrg	    func_fatal_error "'$lib' is not a convenience library"
7908c3c9db83Smrg	  fi
7909c3c9db83Smrg	  continue
7910c3c9db83Smrg	fi # $pass = conv
7911c3c9db83Smrg
7912c3c9db83Smrg
7913c3c9db83Smrg	# Get the name of the library we link against.
7914c3c9db83Smrg	linklib=
79153f6d0e1dSmrg	if test -n "$old_library" &&
79162f60eb46Smrg	   { test yes = "$prefer_static_libs" ||
79172f60eb46Smrg	     test built,no = "$prefer_static_libs,$installed"; }; then
79183f6d0e1dSmrg	  linklib=$old_library
79193f6d0e1dSmrg	else
79203f6d0e1dSmrg	  for l in $old_library $library_names; do
79212f60eb46Smrg	    linklib=$l
79223f6d0e1dSmrg	  done
79233f6d0e1dSmrg	fi
7924c3c9db83Smrg	if test -z "$linklib"; then
79252f60eb46Smrg	  func_fatal_error "cannot find name of link library for '$lib'"
7926c3c9db83Smrg	fi
7927c3c9db83Smrg
7928c3c9db83Smrg	# This library was specified with -dlopen.
79292f60eb46Smrg	if test dlopen = "$pass"; then
79302f60eb46Smrg	  test -z "$libdir" \
79312f60eb46Smrg	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
7932c3c9db83Smrg	  if test -z "$dlname" ||
79332f60eb46Smrg	     test yes != "$dlopen_support" ||
79342f60eb46Smrg	     test no = "$build_libtool_libs"
79352f60eb46Smrg	  then
7936c3c9db83Smrg	    # If there is no dlname, no dlopen support or we're linking
7937c3c9db83Smrg	    # statically, we need to preload.  We also need to preload any
7938c3c9db83Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
7939c3c9db83Smrg	    # bomb out in the load deplibs phase.
79403f6d0e1dSmrg	    func_append dlprefiles " $lib $dependency_libs"
7941c3c9db83Smrg	  else
79423f6d0e1dSmrg	    func_append newdlfiles " $lib"
7943c3c9db83Smrg	  fi
7944c3c9db83Smrg	  continue
7945c3c9db83Smrg	fi # $pass = dlopen
7946c3c9db83Smrg
7947c3c9db83Smrg	# We need an absolute path.
7948c3c9db83Smrg	case $ladir in
79492f60eb46Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
7950c3c9db83Smrg	*)
7951c3c9db83Smrg	  abs_ladir=`cd "$ladir" && pwd`
7952c3c9db83Smrg	  if test -z "$abs_ladir"; then
79532f60eb46Smrg	    func_warning "cannot determine absolute directory name of '$ladir'"
7954c3c9db83Smrg	    func_warning "passing it literally to the linker, although it might fail"
79552f60eb46Smrg	    abs_ladir=$ladir
7956c3c9db83Smrg	  fi
7957c3c9db83Smrg	  ;;
7958c3c9db83Smrg	esac
7959c3c9db83Smrg	func_basename "$lib"
79602f60eb46Smrg	laname=$func_basename_result
7961c3c9db83Smrg
7962c3c9db83Smrg	# Find the relevant object directory and library name.
79632f60eb46Smrg	if test yes = "$installed"; then
79643f6d0e1dSmrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
79652f60eb46Smrg	    func_warning "library '$lib' was moved."
79662f60eb46Smrg	    dir=$ladir
79672f60eb46Smrg	    absdir=$abs_ladir
79682f60eb46Smrg	    libdir=$abs_ladir
7969c3c9db83Smrg	  else
79702f60eb46Smrg	    dir=$lt_sysroot$libdir
79712f60eb46Smrg	    absdir=$lt_sysroot$libdir
7972c3c9db83Smrg	  fi
79732f60eb46Smrg	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
7974c3c9db83Smrg	else
7975c3c9db83Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
79762f60eb46Smrg	    dir=$ladir
79772f60eb46Smrg	    absdir=$abs_ladir
7978c3c9db83Smrg	    # Remove this search path later
79793f6d0e1dSmrg	    func_append notinst_path " $abs_ladir"
7980c3c9db83Smrg	  else
79812f60eb46Smrg	    dir=$ladir/$objdir
79822f60eb46Smrg	    absdir=$abs_ladir/$objdir
7983c3c9db83Smrg	    # Remove this search path later
79843f6d0e1dSmrg	    func_append notinst_path " $abs_ladir"
7985c3c9db83Smrg	  fi
7986c3c9db83Smrg	fi # $installed = yes
7987c3c9db83Smrg	func_stripname 'lib' '.la' "$laname"
7988c3c9db83Smrg	name=$func_stripname_result
7989c3c9db83Smrg
7990c3c9db83Smrg	# This library was specified with -dlpreopen.
79912f60eb46Smrg	if test dlpreopen = "$pass"; then
79922f60eb46Smrg	  if test -z "$libdir" && test prog = "$linkmode"; then
79932f60eb46Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
7994c3c9db83Smrg	  fi
79952f60eb46Smrg	  case $host in
79963f6d0e1dSmrg	    # special handling for platforms with PE-DLLs.
79973f6d0e1dSmrg	    *cygwin* | *mingw* | *cegcc* )
79983f6d0e1dSmrg	      # Linker will automatically link against shared library if both
79993f6d0e1dSmrg	      # static and shared are present.  Therefore, ensure we extract
80003f6d0e1dSmrg	      # symbols from the import library if a shared library is present
80013f6d0e1dSmrg	      # (otherwise, the dlopen module name will be incorrect).  We do
80023f6d0e1dSmrg	      # this by putting the import library name into $newdlprefiles.
80033f6d0e1dSmrg	      # We recover the dlopen module name by 'saving' the la file
80043f6d0e1dSmrg	      # name in a special purpose variable, and (later) extracting the
80053f6d0e1dSmrg	      # dlname from the la file.
80063f6d0e1dSmrg	      if test -n "$dlname"; then
80073f6d0e1dSmrg	        func_tr_sh "$dir/$linklib"
80083f6d0e1dSmrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
80093f6d0e1dSmrg	        func_append newdlprefiles " $dir/$linklib"
80103f6d0e1dSmrg	      else
80113f6d0e1dSmrg	        func_append newdlprefiles " $dir/$old_library"
80123f6d0e1dSmrg	        # Keep a list of preopened convenience libraries to check
80133f6d0e1dSmrg	        # that they are being used correctly in the link pass.
80143f6d0e1dSmrg	        test -z "$libdir" && \
80153f6d0e1dSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
80163f6d0e1dSmrg	      fi
80173f6d0e1dSmrg	    ;;
80183f6d0e1dSmrg	    * )
80193f6d0e1dSmrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
80203f6d0e1dSmrg	      # are required to link).
80213f6d0e1dSmrg	      if test -n "$old_library"; then
80223f6d0e1dSmrg	        func_append newdlprefiles " $dir/$old_library"
80233f6d0e1dSmrg	        # Keep a list of preopened convenience libraries to check
80243f6d0e1dSmrg	        # that they are being used correctly in the link pass.
80253f6d0e1dSmrg	        test -z "$libdir" && \
80263f6d0e1dSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
80273f6d0e1dSmrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
80283f6d0e1dSmrg	      elif test -n "$dlname"; then
80293f6d0e1dSmrg	        func_append newdlprefiles " $dir/$dlname"
80303f6d0e1dSmrg	      else
80313f6d0e1dSmrg	        func_append newdlprefiles " $dir/$linklib"
80323f6d0e1dSmrg	      fi
80333f6d0e1dSmrg	    ;;
80343f6d0e1dSmrg	  esac
8035c3c9db83Smrg	fi # $pass = dlpreopen
8036c3c9db83Smrg
8037c3c9db83Smrg	if test -z "$libdir"; then
8038c3c9db83Smrg	  # Link the convenience library
80392f60eb46Smrg	  if test lib = "$linkmode"; then
8040c3c9db83Smrg	    deplibs="$dir/$old_library $deplibs"
80412f60eb46Smrg	  elif test prog,link = "$linkmode,$pass"; then
8042c3c9db83Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
8043c3c9db83Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
8044c3c9db83Smrg	  else
8045c3c9db83Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
8046c3c9db83Smrg	  fi
8047c3c9db83Smrg	  continue
8048c3c9db83Smrg	fi
8049c3c9db83Smrg
8050c3c9db83Smrg
80512f60eb46Smrg	if test prog = "$linkmode" && test link != "$pass"; then
80523f6d0e1dSmrg	  func_append newlib_search_path " $ladir"
8053c3c9db83Smrg	  deplibs="$lib $deplibs"
8054c3c9db83Smrg
80552f60eb46Smrg	  linkalldeplibs=false
80562f60eb46Smrg	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
80572f60eb46Smrg	     test no = "$build_libtool_libs"; then
80582f60eb46Smrg	    linkalldeplibs=:
8059c3c9db83Smrg	  fi
8060c3c9db83Smrg
8061c3c9db83Smrg	  tmp_libs=
8062c3c9db83Smrg	  for deplib in $dependency_libs; do
8063c3c9db83Smrg	    case $deplib in
8064c3c9db83Smrg	    -L*) func_stripname '-L' '' "$deplib"
80653f6d0e1dSmrg	         func_resolve_sysroot "$func_stripname_result"
80663f6d0e1dSmrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
8067c3c9db83Smrg		 ;;
8068c3c9db83Smrg	    esac
8069c3c9db83Smrg	    # Need to link against all dependency_libs?
80702f60eb46Smrg	    if $linkalldeplibs; then
8071c3c9db83Smrg	      deplibs="$deplib $deplibs"
8072c3c9db83Smrg	    else
8073c3c9db83Smrg	      # Need to hardcode shared library paths
8074c3c9db83Smrg	      # or/and link against static libraries
8075c3c9db83Smrg	      newdependency_libs="$deplib $newdependency_libs"
8076c3c9db83Smrg	    fi
80772f60eb46Smrg	    if $opt_preserve_dup_deps; then
8078c3c9db83Smrg	      case "$tmp_libs " in
80793f6d0e1dSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
8080c3c9db83Smrg	      esac
8081c3c9db83Smrg	    fi
80823f6d0e1dSmrg	    func_append tmp_libs " $deplib"
8083c3c9db83Smrg	  done # for deplib
8084c3c9db83Smrg	  continue
8085c3c9db83Smrg	fi # $linkmode = prog...
8086c3c9db83Smrg
80872f60eb46Smrg	if test prog,link = "$linkmode,$pass"; then
8088c3c9db83Smrg	  if test -n "$library_names" &&
80892f60eb46Smrg	     { { test no = "$prefer_static_libs" ||
80902f60eb46Smrg	         test built,yes = "$prefer_static_libs,$installed"; } ||
8091c3c9db83Smrg	       test -z "$old_library"; }; then
8092c3c9db83Smrg	    # We need to hardcode the library path
80932f60eb46Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
8094c3c9db83Smrg	      # Make sure the rpath contains only unique directories.
80952f60eb46Smrg	      case $temp_rpath: in
8096c3c9db83Smrg	      *"$absdir:"*) ;;
80973f6d0e1dSmrg	      *) func_append temp_rpath "$absdir:" ;;
8098c3c9db83Smrg	      esac
8099c3c9db83Smrg	    fi
8100c3c9db83Smrg
8101c3c9db83Smrg	    # Hardcode the library path.
8102c3c9db83Smrg	    # Skip directories that are in the system default run-time
8103c3c9db83Smrg	    # search path.
8104c3c9db83Smrg	    case " $sys_lib_dlsearch_path " in
8105c3c9db83Smrg	    *" $absdir "*) ;;
8106c3c9db83Smrg	    *)
8107c3c9db83Smrg	      case "$compile_rpath " in
8108c3c9db83Smrg	      *" $absdir "*) ;;
81093f6d0e1dSmrg	      *) func_append compile_rpath " $absdir" ;;
8110c3c9db83Smrg	      esac
8111c3c9db83Smrg	      ;;
8112c3c9db83Smrg	    esac
8113c3c9db83Smrg	    case " $sys_lib_dlsearch_path " in
8114c3c9db83Smrg	    *" $libdir "*) ;;
8115c3c9db83Smrg	    *)
8116c3c9db83Smrg	      case "$finalize_rpath " in
8117c3c9db83Smrg	      *" $libdir "*) ;;
81183f6d0e1dSmrg	      *) func_append finalize_rpath " $libdir" ;;
8119c3c9db83Smrg	      esac
8120c3c9db83Smrg	      ;;
8121c3c9db83Smrg	    esac
8122c3c9db83Smrg	  fi # $linkmode,$pass = prog,link...
8123c3c9db83Smrg
81242f60eb46Smrg	  if $alldeplibs &&
81252f60eb46Smrg	     { test pass_all = "$deplibs_check_method" ||
81262f60eb46Smrg	       { test yes = "$build_libtool_libs" &&
8127c3c9db83Smrg		 test -n "$library_names"; }; }; then
8128c3c9db83Smrg	    # We only need to search for static libraries
8129c3c9db83Smrg	    continue
8130c3c9db83Smrg	  fi
8131c3c9db83Smrg	fi
8132c3c9db83Smrg
8133c3c9db83Smrg	link_static=no # Whether the deplib will be linked statically
8134c3c9db83Smrg	use_static_libs=$prefer_static_libs
81352f60eb46Smrg	if test built = "$use_static_libs" && test yes = "$installed"; then
8136c3c9db83Smrg	  use_static_libs=no
8137c3c9db83Smrg	fi
8138c3c9db83Smrg	if test -n "$library_names" &&
81392f60eb46Smrg	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
8140c3c9db83Smrg	  case $host in
81412f60eb46Smrg	  *cygwin* | *mingw* | *cegcc* | *os2*)
8142c3c9db83Smrg	      # No point in relinking DLLs because paths are not encoded
81433f6d0e1dSmrg	      func_append notinst_deplibs " $lib"
8144c3c9db83Smrg	      need_relink=no
8145c3c9db83Smrg	    ;;
8146c3c9db83Smrg	  *)
81472f60eb46Smrg	    if test no = "$installed"; then
81483f6d0e1dSmrg	      func_append notinst_deplibs " $lib"
8149c3c9db83Smrg	      need_relink=yes
8150c3c9db83Smrg	    fi
8151c3c9db83Smrg	    ;;
8152c3c9db83Smrg	  esac
8153c3c9db83Smrg	  # This is a shared library
8154c3c9db83Smrg
8155c3c9db83Smrg	  # Warn about portability, can't link against -module's on some
8156c3c9db83Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
81572f60eb46Smrg	  dlopenmodule=
8158c3c9db83Smrg	  for dlpremoduletest in $dlprefiles; do
8159c3c9db83Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
81602f60eb46Smrg	      dlopenmodule=$dlpremoduletest
8161c3c9db83Smrg	      break
8162c3c9db83Smrg	    fi
8163c3c9db83Smrg	  done
81642f60eb46Smrg	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
81653f6d0e1dSmrg	    echo
81662f60eb46Smrg	    if test prog = "$linkmode"; then
8167c3c9db83Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
8168c3c9db83Smrg	    else
8169c3c9db83Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
8170c3c9db83Smrg	    fi
8171c3c9db83Smrg	    $ECHO "*** $linklib is not portable!"
8172c3c9db83Smrg	  fi
81732f60eb46Smrg	  if test lib = "$linkmode" &&
81742f60eb46Smrg	     test yes = "$hardcode_into_libs"; then
8175c3c9db83Smrg	    # Hardcode the library path.
8176c3c9db83Smrg	    # Skip directories that are in the system default run-time
8177c3c9db83Smrg	    # search path.
8178c3c9db83Smrg	    case " $sys_lib_dlsearch_path " in
8179c3c9db83Smrg	    *" $absdir "*) ;;
8180c3c9db83Smrg	    *)
8181c3c9db83Smrg	      case "$compile_rpath " in
8182c3c9db83Smrg	      *" $absdir "*) ;;
81833f6d0e1dSmrg	      *) func_append compile_rpath " $absdir" ;;
8184c3c9db83Smrg	      esac
8185c3c9db83Smrg	      ;;
8186c3c9db83Smrg	    esac
8187c3c9db83Smrg	    case " $sys_lib_dlsearch_path " in
8188c3c9db83Smrg	    *" $libdir "*) ;;
8189c3c9db83Smrg	    *)
8190c3c9db83Smrg	      case "$finalize_rpath " in
8191c3c9db83Smrg	      *" $libdir "*) ;;
81923f6d0e1dSmrg	      *) func_append finalize_rpath " $libdir" ;;
8193c3c9db83Smrg	      esac
8194c3c9db83Smrg	      ;;
8195c3c9db83Smrg	    esac
8196c3c9db83Smrg	  fi
8197c3c9db83Smrg
8198c3c9db83Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
8199c3c9db83Smrg	    # figure out the soname
8200c3c9db83Smrg	    set dummy $library_names
8201c3c9db83Smrg	    shift
82022f60eb46Smrg	    realname=$1
8203c3c9db83Smrg	    shift
8204c3c9db83Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
8205c3c9db83Smrg	    # use dlname if we got it. it's perfectly good, no?
8206c3c9db83Smrg	    if test -n "$dlname"; then
82072f60eb46Smrg	      soname=$dlname
8208c3c9db83Smrg	    elif test -n "$soname_spec"; then
8209c3c9db83Smrg	      # bleh windows
8210c3c9db83Smrg	      case $host in
82112f60eb46Smrg	      *cygwin* | mingw* | *cegcc* | *os2*)
8212c3c9db83Smrg	        func_arith $current - $age
8213c3c9db83Smrg		major=$func_arith_result
82142f60eb46Smrg		versuffix=-$major
8215c3c9db83Smrg		;;
8216c3c9db83Smrg	      esac
8217c3c9db83Smrg	      eval soname=\"$soname_spec\"
8218c3c9db83Smrg	    else
82192f60eb46Smrg	      soname=$realname
8220c3c9db83Smrg	    fi
8221c3c9db83Smrg
8222c3c9db83Smrg	    # Make a new name for the extract_expsyms_cmds to use
82232f60eb46Smrg	    soroot=$soname
8224c3c9db83Smrg	    func_basename "$soroot"
82252f60eb46Smrg	    soname=$func_basename_result
8226c3c9db83Smrg	    func_stripname 'lib' '.dll' "$soname"
8227c3c9db83Smrg	    newlib=libimp-$func_stripname_result.a
8228c3c9db83Smrg
8229c3c9db83Smrg	    # If the library has no export list, then create one now
8230c3c9db83Smrg	    if test -f "$output_objdir/$soname-def"; then :
8231c3c9db83Smrg	    else
82322f60eb46Smrg	      func_verbose "extracting exported symbol list from '$soname'"
8233c3c9db83Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
8234c3c9db83Smrg	    fi
8235c3c9db83Smrg
8236c3c9db83Smrg	    # Create $newlib
8237c3c9db83Smrg	    if test -f "$output_objdir/$newlib"; then :; else
82382f60eb46Smrg	      func_verbose "generating import library for '$soname'"
8239c3c9db83Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
8240c3c9db83Smrg	    fi
8241c3c9db83Smrg	    # make sure the library variables are pointing to the new library
8242c3c9db83Smrg	    dir=$output_objdir
8243c3c9db83Smrg	    linklib=$newlib
8244c3c9db83Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
8245c3c9db83Smrg
82462f60eb46Smrg	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
8247c3c9db83Smrg	    add_shlibpath=
8248c3c9db83Smrg	    add_dir=
8249c3c9db83Smrg	    add=
8250c3c9db83Smrg	    lib_linked=yes
8251c3c9db83Smrg	    case $hardcode_action in
8252c3c9db83Smrg	    immediate | unsupported)
82532f60eb46Smrg	      if test no = "$hardcode_direct"; then
82542f60eb46Smrg		add=$dir/$linklib
8255c3c9db83Smrg		case $host in
82562f60eb46Smrg		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
82572f60eb46Smrg		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
8258c3c9db83Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
82592f60eb46Smrg		    *-*-unixware7*) add_dir=-L$dir ;;
8260c3c9db83Smrg		  *-*-darwin* )
82612f60eb46Smrg		    # if the lib is a (non-dlopened) module then we cannot
8262c3c9db83Smrg		    # link against it, someone is ignoring the earlier warnings
8263c3c9db83Smrg		    if /usr/bin/file -L $add 2> /dev/null |
82642f60eb46Smrg			 $GREP ": [^:]* bundle" >/dev/null; then
8265c3c9db83Smrg		      if test "X$dlopenmodule" != "X$lib"; then
8266c3c9db83Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
82672f60eb46Smrg			if test -z "$old_library"; then
82683f6d0e1dSmrg			  echo
82693f6d0e1dSmrg			  echo "*** And there doesn't seem to be a static archive available"
82703f6d0e1dSmrg			  echo "*** The link will probably fail, sorry"
8271c3c9db83Smrg			else
82722f60eb46Smrg			  add=$dir/$old_library
8273c3c9db83Smrg			fi
8274c3c9db83Smrg		      elif test -n "$old_library"; then
82752f60eb46Smrg			add=$dir/$old_library
8276c3c9db83Smrg		      fi
8277c3c9db83Smrg		    fi
8278c3c9db83Smrg		esac
82792f60eb46Smrg	      elif test no = "$hardcode_minus_L"; then
8280c3c9db83Smrg		case $host in
82812f60eb46Smrg		*-*-sunos*) add_shlibpath=$dir ;;
8282c3c9db83Smrg		esac
82832f60eb46Smrg		add_dir=-L$dir
82842f60eb46Smrg		add=-l$name
82852f60eb46Smrg	      elif test no = "$hardcode_shlibpath_var"; then
82862f60eb46Smrg		add_shlibpath=$dir
82872f60eb46Smrg		add=-l$name
8288c3c9db83Smrg	      else
8289c3c9db83Smrg		lib_linked=no
8290c3c9db83Smrg	      fi
8291c3c9db83Smrg	      ;;
8292c3c9db83Smrg	    relink)
82932f60eb46Smrg	      if test yes = "$hardcode_direct" &&
82942f60eb46Smrg	         test no = "$hardcode_direct_absolute"; then
82952f60eb46Smrg		add=$dir/$linklib
82962f60eb46Smrg	      elif test yes = "$hardcode_minus_L"; then
82972f60eb46Smrg		add_dir=-L$absdir
8298c3c9db83Smrg		# Try looking first in the location we're being installed to.
8299c3c9db83Smrg		if test -n "$inst_prefix_dir"; then
8300c3c9db83Smrg		  case $libdir in
8301c3c9db83Smrg		    [\\/]*)
83023f6d0e1dSmrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
8303c3c9db83Smrg		      ;;
8304c3c9db83Smrg		  esac
8305c3c9db83Smrg		fi
83062f60eb46Smrg		add=-l$name
83072f60eb46Smrg	      elif test yes = "$hardcode_shlibpath_var"; then
83082f60eb46Smrg		add_shlibpath=$dir
83092f60eb46Smrg		add=-l$name
8310c3c9db83Smrg	      else
8311c3c9db83Smrg		lib_linked=no
8312c3c9db83Smrg	      fi
8313c3c9db83Smrg	      ;;
8314c3c9db83Smrg	    *) lib_linked=no ;;
8315c3c9db83Smrg	    esac
8316c3c9db83Smrg
83172f60eb46Smrg	    if test yes != "$lib_linked"; then
8318c3c9db83Smrg	      func_fatal_configuration "unsupported hardcode properties"
8319c3c9db83Smrg	    fi
8320c3c9db83Smrg
8321c3c9db83Smrg	    if test -n "$add_shlibpath"; then
8322c3c9db83Smrg	      case :$compile_shlibpath: in
8323c3c9db83Smrg	      *":$add_shlibpath:"*) ;;
83243f6d0e1dSmrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
8325c3c9db83Smrg	      esac
8326c3c9db83Smrg	    fi
83272f60eb46Smrg	    if test prog = "$linkmode"; then
8328c3c9db83Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
8329c3c9db83Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
8330c3c9db83Smrg	    else
8331c3c9db83Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
8332c3c9db83Smrg	      test -n "$add" && deplibs="$add $deplibs"
83332f60eb46Smrg	      if test yes != "$hardcode_direct" &&
83342f60eb46Smrg		 test yes != "$hardcode_minus_L" &&
83352f60eb46Smrg		 test yes = "$hardcode_shlibpath_var"; then
8336c3c9db83Smrg		case :$finalize_shlibpath: in
8337c3c9db83Smrg		*":$libdir:"*) ;;
83383f6d0e1dSmrg		*) func_append finalize_shlibpath "$libdir:" ;;
8339c3c9db83Smrg		esac
8340c3c9db83Smrg	      fi
8341c3c9db83Smrg	    fi
8342c3c9db83Smrg	  fi
8343c3c9db83Smrg
83442f60eb46Smrg	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
8345c3c9db83Smrg	    add_shlibpath=
8346c3c9db83Smrg	    add_dir=
8347c3c9db83Smrg	    add=
8348c3c9db83Smrg	    # Finalize command for both is simple: just hardcode it.
83492f60eb46Smrg	    if test yes = "$hardcode_direct" &&
83502f60eb46Smrg	       test no = "$hardcode_direct_absolute"; then
83512f60eb46Smrg	      add=$libdir/$linklib
83522f60eb46Smrg	    elif test yes = "$hardcode_minus_L"; then
83532f60eb46Smrg	      add_dir=-L$libdir
83542f60eb46Smrg	      add=-l$name
83552f60eb46Smrg	    elif test yes = "$hardcode_shlibpath_var"; then
8356c3c9db83Smrg	      case :$finalize_shlibpath: in
8357c3c9db83Smrg	      *":$libdir:"*) ;;
83583f6d0e1dSmrg	      *) func_append finalize_shlibpath "$libdir:" ;;
8359c3c9db83Smrg	      esac
83602f60eb46Smrg	      add=-l$name
83612f60eb46Smrg	    elif test yes = "$hardcode_automatic"; then
8362c3c9db83Smrg	      if test -n "$inst_prefix_dir" &&
83632f60eb46Smrg		 test -f "$inst_prefix_dir$libdir/$linklib"; then
83642f60eb46Smrg		add=$inst_prefix_dir$libdir/$linklib
8365c3c9db83Smrg	      else
83662f60eb46Smrg		add=$libdir/$linklib
8367c3c9db83Smrg	      fi
8368c3c9db83Smrg	    else
8369c3c9db83Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
83702f60eb46Smrg	      add_dir=-L$libdir
8371c3c9db83Smrg	      # Try looking first in the location we're being installed to.
8372c3c9db83Smrg	      if test -n "$inst_prefix_dir"; then
8373c3c9db83Smrg		case $libdir in
8374c3c9db83Smrg		  [\\/]*)
83753f6d0e1dSmrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
8376c3c9db83Smrg		    ;;
8377c3c9db83Smrg		esac
8378c3c9db83Smrg	      fi
83792f60eb46Smrg	      add=-l$name
8380c3c9db83Smrg	    fi
8381c3c9db83Smrg
83822f60eb46Smrg	    if test prog = "$linkmode"; then
8383c3c9db83Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
8384c3c9db83Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
8385c3c9db83Smrg	    else
8386c3c9db83Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
8387c3c9db83Smrg	      test -n "$add" && deplibs="$add $deplibs"
8388c3c9db83Smrg	    fi
8389c3c9db83Smrg	  fi
83902f60eb46Smrg	elif test prog = "$linkmode"; then
8391c3c9db83Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
8392c3c9db83Smrg	  # is not unsupported.  This is valid on all known static and
8393c3c9db83Smrg	  # shared platforms.
83942f60eb46Smrg	  if test unsupported != "$hardcode_direct"; then
83952f60eb46Smrg	    test -n "$old_library" && linklib=$old_library
8396c3c9db83Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
8397c3c9db83Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
8398c3c9db83Smrg	  else
8399c3c9db83Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
8400c3c9db83Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
8401c3c9db83Smrg	  fi
84022f60eb46Smrg	elif test yes = "$build_libtool_libs"; then
8403c3c9db83Smrg	  # Not a shared library
84042f60eb46Smrg	  if test pass_all != "$deplibs_check_method"; then
8405c3c9db83Smrg	    # We're trying link a shared library against a static one
8406c3c9db83Smrg	    # but the system doesn't support it.
8407c3c9db83Smrg
8408c3c9db83Smrg	    # Just print a warning and add the library to dependency_libs so
8409c3c9db83Smrg	    # that the program can be linked against the static library.
84103f6d0e1dSmrg	    echo
84112f60eb46Smrg	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
84123f6d0e1dSmrg	    echo "*** I have the capability to make that library automatically link in when"
84133f6d0e1dSmrg	    echo "*** you link to this library.  But I can only do this if you have a"
84143f6d0e1dSmrg	    echo "*** shared version of the library, which you do not appear to have."
84152f60eb46Smrg	    if test yes = "$module"; then
84163f6d0e1dSmrg	      echo "*** But as you try to build a module library, libtool will still create "
84173f6d0e1dSmrg	      echo "*** a static module, that should work as long as the dlopening application"
84183f6d0e1dSmrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
8419c3c9db83Smrg	      if test -z "$global_symbol_pipe"; then
84203f6d0e1dSmrg		echo
84213f6d0e1dSmrg		echo "*** However, this would only work if libtool was able to extract symbol"
84222f60eb46Smrg		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
84233f6d0e1dSmrg		echo "*** not find such a program.  So, this module is probably useless."
84242f60eb46Smrg		echo "*** 'nm' from GNU binutils and a full rebuild may help."
8425c3c9db83Smrg	      fi
84262f60eb46Smrg	      if test no = "$build_old_libs"; then
8427c3c9db83Smrg		build_libtool_libs=module
8428c3c9db83Smrg		build_old_libs=yes
8429c3c9db83Smrg	      else
8430c3c9db83Smrg		build_libtool_libs=no
8431c3c9db83Smrg	      fi
8432c3c9db83Smrg	    fi
8433c3c9db83Smrg	  else
8434c3c9db83Smrg	    deplibs="$dir/$old_library $deplibs"
8435c3c9db83Smrg	    link_static=yes
8436c3c9db83Smrg	  fi
8437c3c9db83Smrg	fi # link shared/static library?
8438c3c9db83Smrg
84392f60eb46Smrg	if test lib = "$linkmode"; then
8440c3c9db83Smrg	  if test -n "$dependency_libs" &&
84412f60eb46Smrg	     { test yes != "$hardcode_into_libs" ||
84422f60eb46Smrg	       test yes = "$build_old_libs" ||
84432f60eb46Smrg	       test yes = "$link_static"; }; then
8444c3c9db83Smrg	    # Extract -R from dependency_libs
8445c3c9db83Smrg	    temp_deplibs=
8446c3c9db83Smrg	    for libdir in $dependency_libs; do
8447c3c9db83Smrg	      case $libdir in
8448c3c9db83Smrg	      -R*) func_stripname '-R' '' "$libdir"
8449c3c9db83Smrg	           temp_xrpath=$func_stripname_result
8450c3c9db83Smrg		   case " $xrpath " in
8451c3c9db83Smrg		   *" $temp_xrpath "*) ;;
84523f6d0e1dSmrg		   *) func_append xrpath " $temp_xrpath";;
8453c3c9db83Smrg		   esac;;
84543f6d0e1dSmrg	      *) func_append temp_deplibs " $libdir";;
8455c3c9db83Smrg	      esac
8456c3c9db83Smrg	    done
84572f60eb46Smrg	    dependency_libs=$temp_deplibs
8458c3c9db83Smrg	  fi
8459c3c9db83Smrg
84603f6d0e1dSmrg	  func_append newlib_search_path " $absdir"
8461c3c9db83Smrg	  # Link against this library
84622f60eb46Smrg	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
8463c3c9db83Smrg	  # ... and its dependency_libs
8464c3c9db83Smrg	  tmp_libs=
8465c3c9db83Smrg	  for deplib in $dependency_libs; do
8466c3c9db83Smrg	    newdependency_libs="$deplib $newdependency_libs"
84673f6d0e1dSmrg	    case $deplib in
84683f6d0e1dSmrg              -L*) func_stripname '-L' '' "$deplib"
84693f6d0e1dSmrg                   func_resolve_sysroot "$func_stripname_result";;
84703f6d0e1dSmrg              *) func_resolve_sysroot "$deplib" ;;
84713f6d0e1dSmrg            esac
84722f60eb46Smrg	    if $opt_preserve_dup_deps; then
8473c3c9db83Smrg	      case "$tmp_libs " in
84743f6d0e1dSmrg	      *" $func_resolve_sysroot_result "*)
84753f6d0e1dSmrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
8476c3c9db83Smrg	      esac
8477c3c9db83Smrg	    fi
84783f6d0e1dSmrg	    func_append tmp_libs " $func_resolve_sysroot_result"
8479c3c9db83Smrg	  done
8480c3c9db83Smrg
84812f60eb46Smrg	  if test no != "$link_all_deplibs"; then
8482c3c9db83Smrg	    # Add the search paths of all dependency libraries
8483c3c9db83Smrg	    for deplib in $dependency_libs; do
84843f6d0e1dSmrg	      path=
8485c3c9db83Smrg	      case $deplib in
84862f60eb46Smrg	      -L*) path=$deplib ;;
8487c3c9db83Smrg	      *.la)
84883f6d0e1dSmrg	        func_resolve_sysroot "$deplib"
84893f6d0e1dSmrg	        deplib=$func_resolve_sysroot_result
8490c3c9db83Smrg	        func_dirname "$deplib" "" "."
84913f6d0e1dSmrg		dir=$func_dirname_result
8492c3c9db83Smrg		# We need an absolute path.
8493c3c9db83Smrg		case $dir in
84942f60eb46Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
8495c3c9db83Smrg		*)
8496c3c9db83Smrg		  absdir=`cd "$dir" && pwd`
8497c3c9db83Smrg		  if test -z "$absdir"; then
84982f60eb46Smrg		    func_warning "cannot determine absolute directory name of '$dir'"
84992f60eb46Smrg		    absdir=$dir
8500c3c9db83Smrg		  fi
8501c3c9db83Smrg		  ;;
8502c3c9db83Smrg		esac
8503c3c9db83Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
8504c3c9db83Smrg		case $host in
8505c3c9db83Smrg		*-*-darwin*)
8506c3c9db83Smrg		  depdepl=
85072f60eb46Smrg		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
85082f60eb46Smrg		  if test -n "$deplibrary_names"; then
85092f60eb46Smrg		    for tmp in $deplibrary_names; do
8510c3c9db83Smrg		      depdepl=$tmp
8511c3c9db83Smrg		    done
85122f60eb46Smrg		    if test -f "$absdir/$objdir/$depdepl"; then
85132f60eb46Smrg		      depdepl=$absdir/$objdir/$depdepl
85142f60eb46Smrg		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
8515c3c9db83Smrg                      if test -z "$darwin_install_name"; then
85162f60eb46Smrg                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
8517c3c9db83Smrg                      fi
85182f60eb46Smrg		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
85192f60eb46Smrg		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
8520c3c9db83Smrg		      path=
8521c3c9db83Smrg		    fi
8522c3c9db83Smrg		  fi
8523c3c9db83Smrg		  ;;
8524c3c9db83Smrg		*)
85252f60eb46Smrg		  path=-L$absdir/$objdir
8526c3c9db83Smrg		  ;;
8527c3c9db83Smrg		esac
8528c3c9db83Smrg		else
85292f60eb46Smrg		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8530c3c9db83Smrg		  test -z "$libdir" && \
85312f60eb46Smrg		    func_fatal_error "'$deplib' is not a valid libtool archive"
8532c3c9db83Smrg		  test "$absdir" != "$libdir" && \
85332f60eb46Smrg		    func_warning "'$deplib' seems to be moved"
8534c3c9db83Smrg
85352f60eb46Smrg		  path=-L$absdir
8536c3c9db83Smrg		fi
8537c3c9db83Smrg		;;
8538c3c9db83Smrg	      esac
8539c3c9db83Smrg	      case " $deplibs " in
8540c3c9db83Smrg	      *" $path "*) ;;
8541c3c9db83Smrg	      *) deplibs="$path $deplibs" ;;
8542c3c9db83Smrg	      esac
8543c3c9db83Smrg	    done
8544c3c9db83Smrg	  fi # link_all_deplibs != no
8545c3c9db83Smrg	fi # linkmode = lib
8546c3c9db83Smrg      done # for deplib in $libs
85472f60eb46Smrg      if test link = "$pass"; then
85482f60eb46Smrg	if test prog = "$linkmode"; then
8549c3c9db83Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
8550c3c9db83Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
8551c3c9db83Smrg	else
85523f6d0e1dSmrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8553c3c9db83Smrg	fi
8554c3c9db83Smrg      fi
85552f60eb46Smrg      dependency_libs=$newdependency_libs
85562f60eb46Smrg      if test dlpreopen = "$pass"; then
8557c3c9db83Smrg	# Link the dlpreopened libraries before other libraries
8558c3c9db83Smrg	for deplib in $save_deplibs; do
8559c3c9db83Smrg	  deplibs="$deplib $deplibs"
8560c3c9db83Smrg	done
8561c3c9db83Smrg      fi
85622f60eb46Smrg      if test dlopen != "$pass"; then
85632f60eb46Smrg	test conv = "$pass" || {
8564c3c9db83Smrg	  # Make sure lib_search_path contains only unique directories.
8565c3c9db83Smrg	  lib_search_path=
8566c3c9db83Smrg	  for dir in $newlib_search_path; do
8567c3c9db83Smrg	    case "$lib_search_path " in
8568c3c9db83Smrg	    *" $dir "*) ;;
85693f6d0e1dSmrg	    *) func_append lib_search_path " $dir" ;;
8570c3c9db83Smrg	    esac
8571c3c9db83Smrg	  done
8572c3c9db83Smrg	  newlib_search_path=
85732f60eb46Smrg	}
8574c3c9db83Smrg
85752f60eb46Smrg	if test prog,link = "$linkmode,$pass"; then
8576c3c9db83Smrg	  vars="compile_deplibs finalize_deplibs"
85772f60eb46Smrg	else
85782f60eb46Smrg	  vars=deplibs
8579c3c9db83Smrg	fi
8580c3c9db83Smrg	for var in $vars dependency_libs; do
8581c3c9db83Smrg	  # Add libraries to $var in reverse order
8582c3c9db83Smrg	  eval tmp_libs=\"\$$var\"
8583c3c9db83Smrg	  new_libs=
8584c3c9db83Smrg	  for deplib in $tmp_libs; do
8585c3c9db83Smrg	    # FIXME: Pedantically, this is the right thing to do, so
8586c3c9db83Smrg	    #        that some nasty dependency loop isn't accidentally
8587c3c9db83Smrg	    #        broken:
8588c3c9db83Smrg	    #new_libs="$deplib $new_libs"
8589c3c9db83Smrg	    # Pragmatically, this seems to cause very few problems in
8590c3c9db83Smrg	    # practice:
8591c3c9db83Smrg	    case $deplib in
8592c3c9db83Smrg	    -L*) new_libs="$deplib $new_libs" ;;
8593c3c9db83Smrg	    -R*) ;;
8594c3c9db83Smrg	    *)
8595c3c9db83Smrg	      # And here is the reason: when a library appears more
8596c3c9db83Smrg	      # than once as an explicit dependence of a library, or
8597c3c9db83Smrg	      # is implicitly linked in more than once by the
8598c3c9db83Smrg	      # compiler, it is considered special, and multiple
8599c3c9db83Smrg	      # occurrences thereof are not removed.  Compare this
8600c3c9db83Smrg	      # with having the same library being listed as a
8601c3c9db83Smrg	      # dependency of multiple other libraries: in this case,
8602c3c9db83Smrg	      # we know (pedantically, we assume) the library does not
8603c3c9db83Smrg	      # need to be listed more than once, so we keep only the
8604c3c9db83Smrg	      # last copy.  This is not always right, but it is rare
8605c3c9db83Smrg	      # enough that we require users that really mean to play
8606c3c9db83Smrg	      # such unportable linking tricks to link the library
8607c3c9db83Smrg	      # using -Wl,-lname, so that libtool does not consider it
8608c3c9db83Smrg	      # for duplicate removal.
8609c3c9db83Smrg	      case " $specialdeplibs " in
8610c3c9db83Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
8611c3c9db83Smrg	      *)
8612c3c9db83Smrg		case " $new_libs " in
8613c3c9db83Smrg		*" $deplib "*) ;;
8614c3c9db83Smrg		*) new_libs="$deplib $new_libs" ;;
8615c3c9db83Smrg		esac
8616c3c9db83Smrg		;;
8617c3c9db83Smrg	      esac
8618c3c9db83Smrg	      ;;
8619c3c9db83Smrg	    esac
8620c3c9db83Smrg	  done
8621c3c9db83Smrg	  tmp_libs=
8622c3c9db83Smrg	  for deplib in $new_libs; do
8623c3c9db83Smrg	    case $deplib in
8624c3c9db83Smrg	    -L*)
8625c3c9db83Smrg	      case " $tmp_libs " in
8626c3c9db83Smrg	      *" $deplib "*) ;;
86273f6d0e1dSmrg	      *) func_append tmp_libs " $deplib" ;;
8628c3c9db83Smrg	      esac
8629c3c9db83Smrg	      ;;
86303f6d0e1dSmrg	    *) func_append tmp_libs " $deplib" ;;
8631c3c9db83Smrg	    esac
8632c3c9db83Smrg	  done
8633c3c9db83Smrg	  eval $var=\"$tmp_libs\"
8634c3c9db83Smrg	done # for var
8635c3c9db83Smrg      fi
86362f60eb46Smrg
86372f60eb46Smrg      # Add Sun CC postdeps if required:
86382f60eb46Smrg      test CXX = "$tagname" && {
86392f60eb46Smrg        case $host_os in
86402f60eb46Smrg        linux*)
86412f60eb46Smrg          case `$CC -V 2>&1 | sed 5q` in
86422f60eb46Smrg          *Sun\ C*) # Sun C++ 5.9
86432f60eb46Smrg            func_suncc_cstd_abi
86442f60eb46Smrg
86452f60eb46Smrg            if test no != "$suncc_use_cstd_abi"; then
86462f60eb46Smrg              func_append postdeps ' -library=Cstd -library=Crun'
86472f60eb46Smrg            fi
86482f60eb46Smrg            ;;
86492f60eb46Smrg          esac
86502f60eb46Smrg          ;;
86512f60eb46Smrg
86522f60eb46Smrg        solaris*)
86532f60eb46Smrg          func_cc_basename "$CC"
86542f60eb46Smrg          case $func_cc_basename_result in
86552f60eb46Smrg          CC* | sunCC*)
86562f60eb46Smrg            func_suncc_cstd_abi
86572f60eb46Smrg
86582f60eb46Smrg            if test no != "$suncc_use_cstd_abi"; then
86592f60eb46Smrg              func_append postdeps ' -library=Cstd -library=Crun'
86602f60eb46Smrg            fi
86612f60eb46Smrg            ;;
86622f60eb46Smrg          esac
86632f60eb46Smrg          ;;
86642f60eb46Smrg        esac
86652f60eb46Smrg      }
86662f60eb46Smrg
8667c3c9db83Smrg      # Last step: remove runtime libs from dependency_libs
8668c3c9db83Smrg      # (they stay in deplibs)
8669c3c9db83Smrg      tmp_libs=
86702f60eb46Smrg      for i in $dependency_libs; do
8671c3c9db83Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
8672c3c9db83Smrg	*" $i "*)
86732f60eb46Smrg	  i=
8674c3c9db83Smrg	  ;;
8675c3c9db83Smrg	esac
86762f60eb46Smrg	if test -n "$i"; then
86773f6d0e1dSmrg	  func_append tmp_libs " $i"
8678c3c9db83Smrg	fi
8679c3c9db83Smrg      done
8680c3c9db83Smrg      dependency_libs=$tmp_libs
8681c3c9db83Smrg    done # for pass
86822f60eb46Smrg    if test prog = "$linkmode"; then
86832f60eb46Smrg      dlfiles=$newdlfiles
8684c3c9db83Smrg    fi
86852f60eb46Smrg    if test prog = "$linkmode" || test lib = "$linkmode"; then
86862f60eb46Smrg      dlprefiles=$newdlprefiles
8687c3c9db83Smrg    fi
8688c3c9db83Smrg
8689c3c9db83Smrg    case $linkmode in
8690c3c9db83Smrg    oldlib)
86912f60eb46Smrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
86922f60eb46Smrg	func_warning "'-dlopen' is ignored for archives"
8693c3c9db83Smrg      fi
8694c3c9db83Smrg
8695c3c9db83Smrg      case " $deplibs" in
8696c3c9db83Smrg      *\ -l* | *\ -L*)
86972f60eb46Smrg	func_warning "'-l' and '-L' are ignored for archives" ;;
8698c3c9db83Smrg      esac
8699c3c9db83Smrg
8700c3c9db83Smrg      test -n "$rpath" && \
87012f60eb46Smrg	func_warning "'-rpath' is ignored for archives"
8702c3c9db83Smrg
8703c3c9db83Smrg      test -n "$xrpath" && \
87042f60eb46Smrg	func_warning "'-R' is ignored for archives"
8705c3c9db83Smrg
8706c3c9db83Smrg      test -n "$vinfo" && \
87072f60eb46Smrg	func_warning "'-version-info/-version-number' is ignored for archives"
8708c3c9db83Smrg
8709c3c9db83Smrg      test -n "$release" && \
87102f60eb46Smrg	func_warning "'-release' is ignored for archives"
8711c3c9db83Smrg
8712c3c9db83Smrg      test -n "$export_symbols$export_symbols_regex" && \
87132f60eb46Smrg	func_warning "'-export-symbols' is ignored for archives"
8714c3c9db83Smrg
8715c3c9db83Smrg      # Now set the variables for building old libraries.
8716c3c9db83Smrg      build_libtool_libs=no
87172f60eb46Smrg      oldlibs=$output
87183f6d0e1dSmrg      func_append objs "$old_deplibs"
8719c3c9db83Smrg      ;;
8720c3c9db83Smrg
8721c3c9db83Smrg    lib)
87222f60eb46Smrg      # Make sure we only generate libraries of the form 'libNAME.la'.
8723c3c9db83Smrg      case $outputname in
8724c3c9db83Smrg      lib*)
8725c3c9db83Smrg	func_stripname 'lib' '.la' "$outputname"
8726c3c9db83Smrg	name=$func_stripname_result
8727c3c9db83Smrg	eval shared_ext=\"$shrext_cmds\"
8728c3c9db83Smrg	eval libname=\"$libname_spec\"
8729c3c9db83Smrg	;;
8730c3c9db83Smrg      *)
87312f60eb46Smrg	test no = "$module" \
87322f60eb46Smrg	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
8733c3c9db83Smrg
87342f60eb46Smrg	if test no != "$need_lib_prefix"; then
8735c3c9db83Smrg	  # Add the "lib" prefix for modules if required
8736c3c9db83Smrg	  func_stripname '' '.la' "$outputname"
8737c3c9db83Smrg	  name=$func_stripname_result
8738c3c9db83Smrg	  eval shared_ext=\"$shrext_cmds\"
8739c3c9db83Smrg	  eval libname=\"$libname_spec\"
8740c3c9db83Smrg	else
8741c3c9db83Smrg	  func_stripname '' '.la' "$outputname"
8742c3c9db83Smrg	  libname=$func_stripname_result
8743c3c9db83Smrg	fi
8744c3c9db83Smrg	;;
8745c3c9db83Smrg      esac
8746c3c9db83Smrg
8747c3c9db83Smrg      if test -n "$objs"; then
87482f60eb46Smrg	if test pass_all != "$deplibs_check_method"; then
87492f60eb46Smrg	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
8750c3c9db83Smrg	else
87513f6d0e1dSmrg	  echo
8752c3c9db83Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
8753c3c9db83Smrg	  $ECHO "*** objects $objs is not portable!"
87543f6d0e1dSmrg	  func_append libobjs " $objs"
8755c3c9db83Smrg	fi
8756c3c9db83Smrg      fi
8757c3c9db83Smrg
87582f60eb46Smrg      test no = "$dlself" \
87592f60eb46Smrg	|| func_warning "'-dlopen self' is ignored for libtool libraries"
8760c3c9db83Smrg
8761c3c9db83Smrg      set dummy $rpath
8762c3c9db83Smrg      shift
87632f60eb46Smrg      test 1 -lt "$#" \
87642f60eb46Smrg	&& func_warning "ignoring multiple '-rpath's for a libtool library"
8765c3c9db83Smrg
87662f60eb46Smrg      install_libdir=$1
8767c3c9db83Smrg
8768c3c9db83Smrg      oldlibs=
8769c3c9db83Smrg      if test -z "$rpath"; then
87702f60eb46Smrg	if test yes = "$build_libtool_libs"; then
8771c3c9db83Smrg	  # Building a libtool convenience library.
87722f60eb46Smrg	  # Some compilers have problems with a '.al' extension so
8773c3c9db83Smrg	  # convenience libraries should have the same extension an
8774c3c9db83Smrg	  # archive normally would.
8775c3c9db83Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
8776c3c9db83Smrg	  build_libtool_libs=convenience
8777c3c9db83Smrg	  build_old_libs=yes
8778c3c9db83Smrg	fi
8779c3c9db83Smrg
8780c3c9db83Smrg	test -n "$vinfo" && \
87812f60eb46Smrg	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
8782c3c9db83Smrg
8783c3c9db83Smrg	test -n "$release" && \
87842f60eb46Smrg	  func_warning "'-release' is ignored for convenience libraries"
8785c3c9db83Smrg      else
8786c3c9db83Smrg
8787c3c9db83Smrg	# Parse the version information argument.
87882f60eb46Smrg	save_ifs=$IFS; IFS=:
8789c3c9db83Smrg	set dummy $vinfo 0 0 0
8790c3c9db83Smrg	shift
87912f60eb46Smrg	IFS=$save_ifs
8792c3c9db83Smrg
8793c3c9db83Smrg	test -n "$7" && \
87942f60eb46Smrg	  func_fatal_help "too many parameters to '-version-info'"
8795c3c9db83Smrg
8796c3c9db83Smrg	# convert absolute version numbers to libtool ages
8797c3c9db83Smrg	# this retains compatibility with .la files and attempts
8798c3c9db83Smrg	# to make the code below a bit more comprehensible
8799c3c9db83Smrg
8800c3c9db83Smrg	case $vinfo_number in
8801c3c9db83Smrg	yes)
88022f60eb46Smrg	  number_major=$1
88032f60eb46Smrg	  number_minor=$2
88042f60eb46Smrg	  number_revision=$3
8805c3c9db83Smrg	  #
8806c3c9db83Smrg	  # There are really only two kinds -- those that
8807c3c9db83Smrg	  # use the current revision as the major version
8808c3c9db83Smrg	  # and those that subtract age and use age as
8809c3c9db83Smrg	  # a minor version.  But, then there is irix
88102f60eb46Smrg	  # that has an extra 1 added just for fun
8811c3c9db83Smrg	  #
8812c3c9db83Smrg	  case $version_type in
881395903e71Smrg	  # correct linux to gnu/linux during the next big refactor
88142f60eb46Smrg	  darwin|freebsd-elf|linux|osf|windows|none)
8815c3c9db83Smrg	    func_arith $number_major + $number_minor
8816c3c9db83Smrg	    current=$func_arith_result
88172f60eb46Smrg	    age=$number_minor
88182f60eb46Smrg	    revision=$number_revision
8819c3c9db83Smrg	    ;;
88202f60eb46Smrg	  freebsd-aout|qnx|sunos)
88212f60eb46Smrg	    current=$number_major
88222f60eb46Smrg	    revision=$number_minor
88232f60eb46Smrg	    age=0
8824c3c9db83Smrg	    ;;
8825c3c9db83Smrg	  irix|nonstopux)
8826c3c9db83Smrg	    func_arith $number_major + $number_minor
8827c3c9db83Smrg	    current=$func_arith_result
88282f60eb46Smrg	    age=$number_minor
88292f60eb46Smrg	    revision=$number_minor
8830c3c9db83Smrg	    lt_irix_increment=no
8831c3c9db83Smrg	    ;;
883295903e71Smrg	  *)
88332f60eb46Smrg	    func_fatal_configuration "$modename: unknown library version type '$version_type'"
883495903e71Smrg	    ;;
8835c3c9db83Smrg	  esac
8836c3c9db83Smrg	  ;;
8837c3c9db83Smrg	no)
88382f60eb46Smrg	  current=$1
88392f60eb46Smrg	  revision=$2
88402f60eb46Smrg	  age=$3
8841c3c9db83Smrg	  ;;
8842c3c9db83Smrg	esac
8843c3c9db83Smrg
8844c3c9db83Smrg	# Check that each of the things are valid numbers.
8845c3c9db83Smrg	case $current in
8846c3c9db83Smrg	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]) ;;
8847c3c9db83Smrg	*)
88482f60eb46Smrg	  func_error "CURRENT '$current' must be a nonnegative integer"
88492f60eb46Smrg	  func_fatal_error "'$vinfo' is not valid version information"
8850c3c9db83Smrg	  ;;
8851c3c9db83Smrg	esac
8852c3c9db83Smrg
8853c3c9db83Smrg	case $revision in
8854c3c9db83Smrg	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]) ;;
8855c3c9db83Smrg	*)
88562f60eb46Smrg	  func_error "REVISION '$revision' must be a nonnegative integer"
88572f60eb46Smrg	  func_fatal_error "'$vinfo' is not valid version information"
8858c3c9db83Smrg	  ;;
8859c3c9db83Smrg	esac
8860c3c9db83Smrg
8861c3c9db83Smrg	case $age in
8862c3c9db83Smrg	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]) ;;
8863c3c9db83Smrg	*)
88642f60eb46Smrg	  func_error "AGE '$age' must be a nonnegative integer"
88652f60eb46Smrg	  func_fatal_error "'$vinfo' is not valid version information"
8866c3c9db83Smrg	  ;;
8867c3c9db83Smrg	esac
8868c3c9db83Smrg
8869c3c9db83Smrg	if test "$age" -gt "$current"; then
88702f60eb46Smrg	  func_error "AGE '$age' is greater than the current interface number '$current'"
88712f60eb46Smrg	  func_fatal_error "'$vinfo' is not valid version information"
8872c3c9db83Smrg	fi
8873c3c9db83Smrg
8874c3c9db83Smrg	# Calculate the version variables.
8875c3c9db83Smrg	major=
8876c3c9db83Smrg	versuffix=
8877c3c9db83Smrg	verstring=
8878c3c9db83Smrg	case $version_type in
8879c3c9db83Smrg	none) ;;
8880c3c9db83Smrg
8881c3c9db83Smrg	darwin)
8882c3c9db83Smrg	  # Like Linux, but with the current version available in
8883c3c9db83Smrg	  # verstring for coding it into the library header
8884c3c9db83Smrg	  func_arith $current - $age
8885c3c9db83Smrg	  major=.$func_arith_result
88862f60eb46Smrg	  versuffix=$major.$age.$revision
8887c3c9db83Smrg	  # Darwin ld doesn't like 0 for these options...
8888c3c9db83Smrg	  func_arith $current + 1
8889c3c9db83Smrg	  minor_current=$func_arith_result
88902f60eb46Smrg	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8891c3c9db83Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
88922f60eb46Smrg          # On Darwin other compilers
88932f60eb46Smrg          case $CC in
88942f60eb46Smrg              nagfor*)
88952f60eb46Smrg                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
88962f60eb46Smrg                  ;;
88972f60eb46Smrg              *)
88982f60eb46Smrg                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
88992f60eb46Smrg                  ;;
89002f60eb46Smrg          esac
8901c3c9db83Smrg	  ;;
8902c3c9db83Smrg
8903c3c9db83Smrg	freebsd-aout)
89042f60eb46Smrg	  major=.$current
89052f60eb46Smrg	  versuffix=.$current.$revision
8906c3c9db83Smrg	  ;;
8907c3c9db83Smrg
8908c3c9db83Smrg	freebsd-elf)
89092f60eb46Smrg	  func_arith $current - $age
89102f60eb46Smrg	  major=.$func_arith_result
89112f60eb46Smrg	  versuffix=$major.$age.$revision
8912c3c9db83Smrg	  ;;
8913c3c9db83Smrg
8914c3c9db83Smrg	irix | nonstopux)
89152f60eb46Smrg	  if test no = "$lt_irix_increment"; then
8916c3c9db83Smrg	    func_arith $current - $age
8917c3c9db83Smrg	  else
8918c3c9db83Smrg	    func_arith $current - $age + 1
8919c3c9db83Smrg	  fi
8920c3c9db83Smrg	  major=$func_arith_result
8921c3c9db83Smrg
8922c3c9db83Smrg	  case $version_type in
8923c3c9db83Smrg	    nonstopux) verstring_prefix=nonstopux ;;
8924c3c9db83Smrg	    *)         verstring_prefix=sgi ;;
8925c3c9db83Smrg	  esac
89262f60eb46Smrg	  verstring=$verstring_prefix$major.$revision
8927c3c9db83Smrg
8928c3c9db83Smrg	  # Add in all the interfaces that we are compatible with.
8929c3c9db83Smrg	  loop=$revision
89302f60eb46Smrg	  while test 0 -ne "$loop"; do
8931c3c9db83Smrg	    func_arith $revision - $loop
8932c3c9db83Smrg	    iface=$func_arith_result
8933c3c9db83Smrg	    func_arith $loop - 1
8934c3c9db83Smrg	    loop=$func_arith_result
89352f60eb46Smrg	    verstring=$verstring_prefix$major.$iface:$verstring
8936c3c9db83Smrg	  done
8937c3c9db83Smrg
89382f60eb46Smrg	  # Before this point, $major must not contain '.'.
8939c3c9db83Smrg	  major=.$major
89402f60eb46Smrg	  versuffix=$major.$revision
8941c3c9db83Smrg	  ;;
8942c3c9db83Smrg
894395903e71Smrg	linux) # correct to gnu/linux during the next big refactor
8944c3c9db83Smrg	  func_arith $current - $age
8945c3c9db83Smrg	  major=.$func_arith_result
89462f60eb46Smrg	  versuffix=$major.$age.$revision
8947c3c9db83Smrg	  ;;
8948c3c9db83Smrg
8949c3c9db83Smrg	osf)
8950c3c9db83Smrg	  func_arith $current - $age
8951c3c9db83Smrg	  major=.$func_arith_result
89522f60eb46Smrg	  versuffix=.$current.$age.$revision
89532f60eb46Smrg	  verstring=$current.$age.$revision
8954c3c9db83Smrg
8955c3c9db83Smrg	  # Add in all the interfaces that we are compatible with.
8956c3c9db83Smrg	  loop=$age
89572f60eb46Smrg	  while test 0 -ne "$loop"; do
8958c3c9db83Smrg	    func_arith $current - $loop
8959c3c9db83Smrg	    iface=$func_arith_result
8960c3c9db83Smrg	    func_arith $loop - 1
8961c3c9db83Smrg	    loop=$func_arith_result
89622f60eb46Smrg	    verstring=$verstring:$iface.0
8963c3c9db83Smrg	  done
8964c3c9db83Smrg
8965c3c9db83Smrg	  # Make executables depend on our current version.
89662f60eb46Smrg	  func_append verstring ":$current.0"
8967c3c9db83Smrg	  ;;
8968c3c9db83Smrg
8969c3c9db83Smrg	qnx)
89702f60eb46Smrg	  major=.$current
89712f60eb46Smrg	  versuffix=.$current
89722f60eb46Smrg	  ;;
89732f60eb46Smrg
89742f60eb46Smrg	sco)
89752f60eb46Smrg	  major=.$current
89762f60eb46Smrg	  versuffix=.$current
8977c3c9db83Smrg	  ;;
8978c3c9db83Smrg
8979c3c9db83Smrg	sunos)
89802f60eb46Smrg	  major=.$current
89812f60eb46Smrg	  versuffix=.$current.$revision
8982c3c9db83Smrg	  ;;
8983c3c9db83Smrg
8984c3c9db83Smrg	windows)
8985c3c9db83Smrg	  # Use '-' rather than '.', since we only want one
89862f60eb46Smrg	  # extension on DOS 8.3 file systems.
8987c3c9db83Smrg	  func_arith $current - $age
8988c3c9db83Smrg	  major=$func_arith_result
89892f60eb46Smrg	  versuffix=-$major
8990c3c9db83Smrg	  ;;
8991c3c9db83Smrg
8992c3c9db83Smrg	*)
89932f60eb46Smrg	  func_fatal_configuration "unknown library version type '$version_type'"
8994c3c9db83Smrg	  ;;
8995c3c9db83Smrg	esac
8996c3c9db83Smrg
8997c3c9db83Smrg	# Clear the version info if we defaulted, and they specified a release.
8998c3c9db83Smrg	if test -z "$vinfo" && test -n "$release"; then
8999c3c9db83Smrg	  major=
9000c3c9db83Smrg	  case $version_type in
9001c3c9db83Smrg	  darwin)
9002c3c9db83Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
9003c3c9db83Smrg	    # problems, so we reset it completely
9004c3c9db83Smrg	    verstring=
9005c3c9db83Smrg	    ;;
9006c3c9db83Smrg	  *)
90072f60eb46Smrg	    verstring=0.0
9008c3c9db83Smrg	    ;;
9009c3c9db83Smrg	  esac
90102f60eb46Smrg	  if test no = "$need_version"; then
9011c3c9db83Smrg	    versuffix=
9012c3c9db83Smrg	  else
90132f60eb46Smrg	    versuffix=.0.0
9014c3c9db83Smrg	  fi
9015c3c9db83Smrg	fi
9016c3c9db83Smrg
9017c3c9db83Smrg	# Remove version info from name if versioning should be avoided
90182f60eb46Smrg	if test yes,no = "$avoid_version,$need_version"; then
9019c3c9db83Smrg	  major=
9020c3c9db83Smrg	  versuffix=
90212f60eb46Smrg	  verstring=
9022c3c9db83Smrg	fi
9023c3c9db83Smrg
9024c3c9db83Smrg	# Check to see if the archive will have undefined symbols.
90252f60eb46Smrg	if test yes = "$allow_undefined"; then
90262f60eb46Smrg	  if test unsupported = "$allow_undefined_flag"; then
90272f60eb46Smrg	    if test yes = "$build_old_libs"; then
90282f60eb46Smrg	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
90292f60eb46Smrg	      build_libtool_libs=no
90302f60eb46Smrg	    else
90312f60eb46Smrg	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
90322f60eb46Smrg	    fi
9033c3c9db83Smrg	  fi
9034c3c9db83Smrg	else
9035c3c9db83Smrg	  # Don't allow undefined symbols.
90362f60eb46Smrg	  allow_undefined_flag=$no_undefined_flag
9037c3c9db83Smrg	fi
9038c3c9db83Smrg
9039c3c9db83Smrg      fi
9040c3c9db83Smrg
90412f60eb46Smrg      func_generate_dlsyms "$libname" "$libname" :
90423f6d0e1dSmrg      func_append libobjs " $symfileobj"
90432f60eb46Smrg      test " " = "$libobjs" && libobjs=
9044c3c9db83Smrg
90452f60eb46Smrg      if test relink != "$opt_mode"; then
9046c3c9db83Smrg	# Remove our outputs, but don't remove object files since they
9047c3c9db83Smrg	# may have been created when compiling PIC objects.
9048c3c9db83Smrg	removelist=
9049c3c9db83Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
9050c3c9db83Smrg	for p in $tempremovelist; do
9051c3c9db83Smrg	  case $p in
9052c3c9db83Smrg	    *.$objext | *.gcno)
9053c3c9db83Smrg	       ;;
90542f60eb46Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
90552f60eb46Smrg	       if test -n "$precious_files_regex"; then
9056c3c9db83Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
9057c3c9db83Smrg		 then
9058c3c9db83Smrg		   continue
9059c3c9db83Smrg		 fi
9060c3c9db83Smrg	       fi
90613f6d0e1dSmrg	       func_append removelist " $p"
9062c3c9db83Smrg	       ;;
9063c3c9db83Smrg	    *) ;;
9064c3c9db83Smrg	  esac
9065c3c9db83Smrg	done
9066c3c9db83Smrg	test -n "$removelist" && \
9067c3c9db83Smrg	  func_show_eval "${RM}r \$removelist"
9068c3c9db83Smrg      fi
9069c3c9db83Smrg
9070c3c9db83Smrg      # Now set the variables for building old libraries.
90712f60eb46Smrg      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
90723f6d0e1dSmrg	func_append oldlibs " $output_objdir/$libname.$libext"
9073c3c9db83Smrg
9074c3c9db83Smrg	# Transform .lo files to .o files.
90752f60eb46Smrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
9076c3c9db83Smrg      fi
9077c3c9db83Smrg
9078c3c9db83Smrg      # Eliminate all temporary directories.
9079c3c9db83Smrg      #for path in $notinst_path; do
90803f6d0e1dSmrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
90813f6d0e1dSmrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
90823f6d0e1dSmrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
9083c3c9db83Smrg      #done
9084c3c9db83Smrg
9085c3c9db83Smrg      if test -n "$xrpath"; then
9086c3c9db83Smrg	# If the user specified any rpath flags, then add them.
9087c3c9db83Smrg	temp_xrpath=
9088c3c9db83Smrg	for libdir in $xrpath; do
90893f6d0e1dSmrg	  func_replace_sysroot "$libdir"
90903f6d0e1dSmrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
9091c3c9db83Smrg	  case "$finalize_rpath " in
9092c3c9db83Smrg	  *" $libdir "*) ;;
90933f6d0e1dSmrg	  *) func_append finalize_rpath " $libdir" ;;
9094c3c9db83Smrg	  esac
9095c3c9db83Smrg	done
90962f60eb46Smrg	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
9097c3c9db83Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
9098c3c9db83Smrg	fi
9099c3c9db83Smrg      fi
9100c3c9db83Smrg
9101c3c9db83Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
91022f60eb46Smrg      old_dlfiles=$dlfiles
9103c3c9db83Smrg      dlfiles=
9104c3c9db83Smrg      for lib in $old_dlfiles; do
9105c3c9db83Smrg	case " $dlprefiles $dlfiles " in
9106c3c9db83Smrg	*" $lib "*) ;;
91073f6d0e1dSmrg	*) func_append dlfiles " $lib" ;;
9108c3c9db83Smrg	esac
9109c3c9db83Smrg      done
9110c3c9db83Smrg
9111c3c9db83Smrg      # Make sure dlprefiles contains only unique files
91122f60eb46Smrg      old_dlprefiles=$dlprefiles
9113c3c9db83Smrg      dlprefiles=
9114c3c9db83Smrg      for lib in $old_dlprefiles; do
9115c3c9db83Smrg	case "$dlprefiles " in
9116c3c9db83Smrg	*" $lib "*) ;;
91173f6d0e1dSmrg	*) func_append dlprefiles " $lib" ;;
9118c3c9db83Smrg	esac
9119c3c9db83Smrg      done
9120c3c9db83Smrg
91212f60eb46Smrg      if test yes = "$build_libtool_libs"; then
9122c3c9db83Smrg	if test -n "$rpath"; then
9123c3c9db83Smrg	  case $host in
91243f6d0e1dSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
9125c3c9db83Smrg	    # these systems don't actually have a c library (as such)!
9126c3c9db83Smrg	    ;;
9127c3c9db83Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
9128c3c9db83Smrg	    # Rhapsody C library is in the System framework
91293f6d0e1dSmrg	    func_append deplibs " System.ltframework"
9130c3c9db83Smrg	    ;;
9131c3c9db83Smrg	  *-*-netbsd*)
9132c3c9db83Smrg	    # Don't link with libc until the a.out ld.so is fixed.
9133c3c9db83Smrg	    ;;
9134c3c9db83Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
9135c3c9db83Smrg	    # Do not include libc due to us having libc/libc_r.
9136c3c9db83Smrg	    ;;
9137c3c9db83Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
9138c3c9db83Smrg	    # Causes problems with __ctype
9139c3c9db83Smrg	    ;;
9140c3c9db83Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
9141c3c9db83Smrg	    # Compiler inserts libc in the correct place for threads to work
9142c3c9db83Smrg	    ;;
9143c3c9db83Smrg	  *)
9144c3c9db83Smrg	    # Add libc to deplibs on all other systems if necessary.
91452f60eb46Smrg	    if test yes = "$build_libtool_need_lc"; then
91463f6d0e1dSmrg	      func_append deplibs " -lc"
9147c3c9db83Smrg	    fi
9148c3c9db83Smrg	    ;;
9149c3c9db83Smrg	  esac
9150c3c9db83Smrg	fi
9151c3c9db83Smrg
9152c3c9db83Smrg	# Transform deplibs into only deplibs that can be linked in shared.
9153c3c9db83Smrg	name_save=$name
9154c3c9db83Smrg	libname_save=$libname
9155c3c9db83Smrg	release_save=$release
9156c3c9db83Smrg	versuffix_save=$versuffix
9157c3c9db83Smrg	major_save=$major
9158c3c9db83Smrg	# I'm not sure if I'm treating the release correctly.  I think
9159c3c9db83Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
9160c3c9db83Smrg	# add it in twice.  Is that correct?
91612f60eb46Smrg	release=
91622f60eb46Smrg	versuffix=
91632f60eb46Smrg	major=
9164c3c9db83Smrg	newdeplibs=
9165c3c9db83Smrg	droppeddeps=no
9166c3c9db83Smrg	case $deplibs_check_method in
9167c3c9db83Smrg	pass_all)
9168c3c9db83Smrg	  # Don't check for shared/static.  Everything works.
9169c3c9db83Smrg	  # This might be a little naive.  We might want to check
9170c3c9db83Smrg	  # whether the library exists or not.  But this is on
9171c3c9db83Smrg	  # osf3 & osf4 and I'm not really sure... Just
9172c3c9db83Smrg	  # implementing what was already the behavior.
9173c3c9db83Smrg	  newdeplibs=$deplibs
9174c3c9db83Smrg	  ;;
9175c3c9db83Smrg	test_compile)
9176c3c9db83Smrg	  # This code stresses the "libraries are programs" paradigm to its
9177c3c9db83Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
9178c3c9db83Smrg	  # against the deplibs as a proxy for the library.  Then we can check
9179c3c9db83Smrg	  # whether they linked in statically or dynamically with ldd.
9180c3c9db83Smrg	  $opt_dry_run || $RM conftest.c
9181c3c9db83Smrg	  cat > conftest.c <<EOF
9182c3c9db83Smrg	  int main() { return 0; }
9183c3c9db83SmrgEOF
9184c3c9db83Smrg	  $opt_dry_run || $RM conftest
9185c3c9db83Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
9186c3c9db83Smrg	    ldd_output=`ldd conftest`
9187c3c9db83Smrg	    for i in $deplibs; do
9188c3c9db83Smrg	      case $i in
9189c3c9db83Smrg	      -l*)
9190c3c9db83Smrg		func_stripname -l '' "$i"
9191c3c9db83Smrg		name=$func_stripname_result
91922f60eb46Smrg		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9193c3c9db83Smrg		  case " $predeps $postdeps " in
9194c3c9db83Smrg		  *" $i "*)
91953f6d0e1dSmrg		    func_append newdeplibs " $i"
91962f60eb46Smrg		    i=
9197c3c9db83Smrg		    ;;
9198c3c9db83Smrg		  esac
9199c3c9db83Smrg		fi
92002f60eb46Smrg		if test -n "$i"; then
9201c3c9db83Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
9202c3c9db83Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9203c3c9db83Smrg		  set dummy $deplib_matches; shift
9204c3c9db83Smrg		  deplib_match=$1
92052f60eb46Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
92063f6d0e1dSmrg		    func_append newdeplibs " $i"
9207c3c9db83Smrg		  else
9208c3c9db83Smrg		    droppeddeps=yes
92093f6d0e1dSmrg		    echo
9210c3c9db83Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
92113f6d0e1dSmrg		    echo "*** I have the capability to make that library automatically link in when"
92123f6d0e1dSmrg		    echo "*** you link to this library.  But I can only do this if you have a"
92133f6d0e1dSmrg		    echo "*** shared version of the library, which I believe you do not have"
92143f6d0e1dSmrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
92153f6d0e1dSmrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
9216c3c9db83Smrg		  fi
9217c3c9db83Smrg		fi
9218c3c9db83Smrg		;;
9219c3c9db83Smrg	      *)
92203f6d0e1dSmrg		func_append newdeplibs " $i"
9221c3c9db83Smrg		;;
9222c3c9db83Smrg	      esac
9223c3c9db83Smrg	    done
9224c3c9db83Smrg	  else
9225c3c9db83Smrg	    # Error occurred in the first compile.  Let's try to salvage
9226c3c9db83Smrg	    # the situation: Compile a separate program for each library.
9227c3c9db83Smrg	    for i in $deplibs; do
9228c3c9db83Smrg	      case $i in
9229c3c9db83Smrg	      -l*)
9230c3c9db83Smrg		func_stripname -l '' "$i"
9231c3c9db83Smrg		name=$func_stripname_result
9232c3c9db83Smrg		$opt_dry_run || $RM conftest
9233c3c9db83Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
9234c3c9db83Smrg		  ldd_output=`ldd conftest`
92352f60eb46Smrg		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9236c3c9db83Smrg		    case " $predeps $postdeps " in
9237c3c9db83Smrg		    *" $i "*)
92383f6d0e1dSmrg		      func_append newdeplibs " $i"
92392f60eb46Smrg		      i=
9240c3c9db83Smrg		      ;;
9241c3c9db83Smrg		    esac
9242c3c9db83Smrg		  fi
92432f60eb46Smrg		  if test -n "$i"; then
9244c3c9db83Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
9245c3c9db83Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9246c3c9db83Smrg		    set dummy $deplib_matches; shift
9247c3c9db83Smrg		    deplib_match=$1
92482f60eb46Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
92493f6d0e1dSmrg		      func_append newdeplibs " $i"
9250c3c9db83Smrg		    else
9251c3c9db83Smrg		      droppeddeps=yes
92523f6d0e1dSmrg		      echo
9253c3c9db83Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
92543f6d0e1dSmrg		      echo "*** I have the capability to make that library automatically link in when"
92553f6d0e1dSmrg		      echo "*** you link to this library.  But I can only do this if you have a"
92563f6d0e1dSmrg		      echo "*** shared version of the library, which you do not appear to have"
92573f6d0e1dSmrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
92583f6d0e1dSmrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
9259c3c9db83Smrg		    fi
9260c3c9db83Smrg		  fi
9261c3c9db83Smrg		else
9262c3c9db83Smrg		  droppeddeps=yes
92633f6d0e1dSmrg		  echo
9264c3c9db83Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
92653f6d0e1dSmrg		  echo "*** make it link in!  You will probably need to install it or some"
92663f6d0e1dSmrg		  echo "*** library that it depends on before this library will be fully"
92673f6d0e1dSmrg		  echo "*** functional.  Installing it before continuing would be even better."
9268c3c9db83Smrg		fi
9269c3c9db83Smrg		;;
9270c3c9db83Smrg	      *)
92713f6d0e1dSmrg		func_append newdeplibs " $i"
9272c3c9db83Smrg		;;
9273c3c9db83Smrg	      esac
9274c3c9db83Smrg	    done
9275c3c9db83Smrg	  fi
9276c3c9db83Smrg	  ;;
9277c3c9db83Smrg	file_magic*)
9278c3c9db83Smrg	  set dummy $deplibs_check_method; shift
9279c3c9db83Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9280c3c9db83Smrg	  for a_deplib in $deplibs; do
9281c3c9db83Smrg	    case $a_deplib in
9282c3c9db83Smrg	    -l*)
9283c3c9db83Smrg	      func_stripname -l '' "$a_deplib"
9284c3c9db83Smrg	      name=$func_stripname_result
92852f60eb46Smrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9286c3c9db83Smrg		case " $predeps $postdeps " in
9287c3c9db83Smrg		*" $a_deplib "*)
92883f6d0e1dSmrg		  func_append newdeplibs " $a_deplib"
92892f60eb46Smrg		  a_deplib=
9290c3c9db83Smrg		  ;;
9291c3c9db83Smrg		esac
9292c3c9db83Smrg	      fi
92932f60eb46Smrg	      if test -n "$a_deplib"; then
9294c3c9db83Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
92953f6d0e1dSmrg		if test -n "$file_magic_glob"; then
92963f6d0e1dSmrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
92973f6d0e1dSmrg		else
92983f6d0e1dSmrg		  libnameglob=$libname
92993f6d0e1dSmrg		fi
93002f60eb46Smrg		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
9301c3c9db83Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
93022f60eb46Smrg		  if test yes = "$want_nocaseglob"; then
93033f6d0e1dSmrg		    shopt -s nocaseglob
93043f6d0e1dSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
93053f6d0e1dSmrg		    $nocaseglob
93063f6d0e1dSmrg		  else
93073f6d0e1dSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
93083f6d0e1dSmrg		  fi
9309c3c9db83Smrg		  for potent_lib in $potential_libs; do
9310c3c9db83Smrg		      # Follow soft links.
9311c3c9db83Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
9312c3c9db83Smrg			 $GREP " -> " >/dev/null; then
9313c3c9db83Smrg			continue
9314c3c9db83Smrg		      fi
9315c3c9db83Smrg		      # The statement above tries to avoid entering an
9316c3c9db83Smrg		      # endless loop below, in case of cyclic links.
9317c3c9db83Smrg		      # We might still enter an endless loop, since a link
9318c3c9db83Smrg		      # loop can be closed while we follow links,
9319c3c9db83Smrg		      # but so what?
93202f60eb46Smrg		      potlib=$potent_lib
9321c3c9db83Smrg		      while test -h "$potlib" 2>/dev/null; do
93222f60eb46Smrg			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
9323c3c9db83Smrg			case $potliblink in
93242f60eb46Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
93252f60eb46Smrg			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
9326c3c9db83Smrg			esac
9327c3c9db83Smrg		      done
9328c3c9db83Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
9329c3c9db83Smrg			 $SED -e 10q |
9330c3c9db83Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
93313f6d0e1dSmrg			func_append newdeplibs " $a_deplib"
93322f60eb46Smrg			a_deplib=
9333c3c9db83Smrg			break 2
9334c3c9db83Smrg		      fi
9335c3c9db83Smrg		  done
9336c3c9db83Smrg		done
9337c3c9db83Smrg	      fi
93382f60eb46Smrg	      if test -n "$a_deplib"; then
9339c3c9db83Smrg		droppeddeps=yes
93403f6d0e1dSmrg		echo
9341c3c9db83Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
93423f6d0e1dSmrg		echo "*** I have the capability to make that library automatically link in when"
93433f6d0e1dSmrg		echo "*** you link to this library.  But I can only do this if you have a"
93443f6d0e1dSmrg		echo "*** shared version of the library, which you do not appear to have"
93453f6d0e1dSmrg		echo "*** because I did check the linker path looking for a file starting"
93462f60eb46Smrg		if test -z "$potlib"; then
9347c3c9db83Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
9348c3c9db83Smrg		else
9349c3c9db83Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
9350c3c9db83Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
9351c3c9db83Smrg		fi
9352c3c9db83Smrg	      fi
9353c3c9db83Smrg	      ;;
9354c3c9db83Smrg	    *)
9355c3c9db83Smrg	      # Add a -L argument.
93563f6d0e1dSmrg	      func_append newdeplibs " $a_deplib"
9357c3c9db83Smrg	      ;;
9358c3c9db83Smrg	    esac
9359c3c9db83Smrg	  done # Gone through all deplibs.
9360c3c9db83Smrg	  ;;
9361c3c9db83Smrg	match_pattern*)
9362c3c9db83Smrg	  set dummy $deplibs_check_method; shift
9363c3c9db83Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9364c3c9db83Smrg	  for a_deplib in $deplibs; do
9365c3c9db83Smrg	    case $a_deplib in
9366c3c9db83Smrg	    -l*)
9367c3c9db83Smrg	      func_stripname -l '' "$a_deplib"
9368c3c9db83Smrg	      name=$func_stripname_result
93692f60eb46Smrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9370c3c9db83Smrg		case " $predeps $postdeps " in
9371c3c9db83Smrg		*" $a_deplib "*)
93723f6d0e1dSmrg		  func_append newdeplibs " $a_deplib"
93732f60eb46Smrg		  a_deplib=
9374c3c9db83Smrg		  ;;
9375c3c9db83Smrg		esac
9376c3c9db83Smrg	      fi
93772f60eb46Smrg	      if test -n "$a_deplib"; then
9378c3c9db83Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
9379c3c9db83Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9380c3c9db83Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
9381c3c9db83Smrg		  for potent_lib in $potential_libs; do
93822f60eb46Smrg		    potlib=$potent_lib # see symlink-check above in file_magic test
93833f6d0e1dSmrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
9384c3c9db83Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
93853f6d0e1dSmrg		      func_append newdeplibs " $a_deplib"
93862f60eb46Smrg		      a_deplib=
9387c3c9db83Smrg		      break 2
9388c3c9db83Smrg		    fi
9389c3c9db83Smrg		  done
9390c3c9db83Smrg		done
9391c3c9db83Smrg	      fi
93922f60eb46Smrg	      if test -n "$a_deplib"; then
9393c3c9db83Smrg		droppeddeps=yes
93943f6d0e1dSmrg		echo
9395c3c9db83Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
93963f6d0e1dSmrg		echo "*** I have the capability to make that library automatically link in when"
93973f6d0e1dSmrg		echo "*** you link to this library.  But I can only do this if you have a"
93983f6d0e1dSmrg		echo "*** shared version of the library, which you do not appear to have"
93993f6d0e1dSmrg		echo "*** because I did check the linker path looking for a file starting"
94002f60eb46Smrg		if test -z "$potlib"; then
9401c3c9db83Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
9402c3c9db83Smrg		else
9403c3c9db83Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
9404c3c9db83Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
9405c3c9db83Smrg		fi
9406c3c9db83Smrg	      fi
9407c3c9db83Smrg	      ;;
9408c3c9db83Smrg	    *)
9409c3c9db83Smrg	      # Add a -L argument.
94103f6d0e1dSmrg	      func_append newdeplibs " $a_deplib"
9411c3c9db83Smrg	      ;;
9412c3c9db83Smrg	    esac
9413c3c9db83Smrg	  done # Gone through all deplibs.
9414c3c9db83Smrg	  ;;
9415c3c9db83Smrg	none | unknown | *)
94162f60eb46Smrg	  newdeplibs=
94173f6d0e1dSmrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
94182f60eb46Smrg	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
94192f60eb46Smrg	    for i in $predeps $postdeps; do
9420c3c9db83Smrg	      # can't use Xsed below, because $i might contain '/'
94212f60eb46Smrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
9422c3c9db83Smrg	    done
9423c3c9db83Smrg	  fi
94243f6d0e1dSmrg	  case $tmp_deplibs in
94253f6d0e1dSmrg	  *[!\	\ ]*)
94263f6d0e1dSmrg	    echo
94272f60eb46Smrg	    if test none = "$deplibs_check_method"; then
94283f6d0e1dSmrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
9429c3c9db83Smrg	    else
94303f6d0e1dSmrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
9431c3c9db83Smrg	    fi
94323f6d0e1dSmrg	    echo "*** All declared inter-library dependencies are being dropped."
9433c3c9db83Smrg	    droppeddeps=yes
94343f6d0e1dSmrg	    ;;
94353f6d0e1dSmrg	  esac
9436c3c9db83Smrg	  ;;
9437c3c9db83Smrg	esac
9438c3c9db83Smrg	versuffix=$versuffix_save
9439c3c9db83Smrg	major=$major_save
9440c3c9db83Smrg	release=$release_save
9441c3c9db83Smrg	libname=$libname_save
9442c3c9db83Smrg	name=$name_save
9443c3c9db83Smrg
9444c3c9db83Smrg	case $host in
9445c3c9db83Smrg	*-*-rhapsody* | *-*-darwin1.[012])
9446c3c9db83Smrg	  # On Rhapsody replace the C library with the System framework
94473f6d0e1dSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
9448c3c9db83Smrg	  ;;
9449c3c9db83Smrg	esac
9450c3c9db83Smrg
94512f60eb46Smrg	if test yes = "$droppeddeps"; then
94522f60eb46Smrg	  if test yes = "$module"; then
94533f6d0e1dSmrg	    echo
94543f6d0e1dSmrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
9455c3c9db83Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
94563f6d0e1dSmrg	    echo "*** a static module, that should work as long as the dlopening"
94573f6d0e1dSmrg	    echo "*** application is linked with the -dlopen flag."
9458c3c9db83Smrg	    if test -z "$global_symbol_pipe"; then
94593f6d0e1dSmrg	      echo
94603f6d0e1dSmrg	      echo "*** However, this would only work if libtool was able to extract symbol"
94612f60eb46Smrg	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
94623f6d0e1dSmrg	      echo "*** not find such a program.  So, this module is probably useless."
94632f60eb46Smrg	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
9464c3c9db83Smrg	    fi
94652f60eb46Smrg	    if test no = "$build_old_libs"; then
94662f60eb46Smrg	      oldlibs=$output_objdir/$libname.$libext
9467c3c9db83Smrg	      build_libtool_libs=module
9468c3c9db83Smrg	      build_old_libs=yes
9469c3c9db83Smrg	    else
9470c3c9db83Smrg	      build_libtool_libs=no
9471c3c9db83Smrg	    fi
9472c3c9db83Smrg	  else
94733f6d0e1dSmrg	    echo "*** The inter-library dependencies that have been dropped here will be"
94743f6d0e1dSmrg	    echo "*** automatically added whenever a program is linked with this library"
94753f6d0e1dSmrg	    echo "*** or is declared to -dlopen it."
9476c3c9db83Smrg
94772f60eb46Smrg	    if test no = "$allow_undefined"; then
94783f6d0e1dSmrg	      echo
94793f6d0e1dSmrg	      echo "*** Since this library must not contain undefined symbols,"
94803f6d0e1dSmrg	      echo "*** because either the platform does not support them or"
94813f6d0e1dSmrg	      echo "*** it was explicitly requested with -no-undefined,"
94823f6d0e1dSmrg	      echo "*** libtool will only create a static version of it."
94832f60eb46Smrg	      if test no = "$build_old_libs"; then
94842f60eb46Smrg		oldlibs=$output_objdir/$libname.$libext
9485c3c9db83Smrg		build_libtool_libs=module
9486c3c9db83Smrg		build_old_libs=yes
9487c3c9db83Smrg	      else
9488c3c9db83Smrg		build_libtool_libs=no
9489c3c9db83Smrg	      fi
9490c3c9db83Smrg	    fi
9491c3c9db83Smrg	  fi
9492c3c9db83Smrg	fi
9493c3c9db83Smrg	# Done checking deplibs!
9494c3c9db83Smrg	deplibs=$newdeplibs
9495c3c9db83Smrg      fi
9496c3c9db83Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
9497c3c9db83Smrg      case $host in
9498c3c9db83Smrg	*-*-darwin*)
94993f6d0e1dSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
95003f6d0e1dSmrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
95013f6d0e1dSmrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9502c3c9db83Smrg	  ;;
9503c3c9db83Smrg      esac
9504c3c9db83Smrg
9505c3c9db83Smrg      # move library search paths that coincide with paths to not yet
9506c3c9db83Smrg      # installed libraries to the beginning of the library search list
9507c3c9db83Smrg      new_libs=
9508c3c9db83Smrg      for path in $notinst_path; do
9509c3c9db83Smrg	case " $new_libs " in
9510c3c9db83Smrg	*" -L$path/$objdir "*) ;;
9511c3c9db83Smrg	*)
9512c3c9db83Smrg	  case " $deplibs " in
9513c3c9db83Smrg	  *" -L$path/$objdir "*)
95143f6d0e1dSmrg	    func_append new_libs " -L$path/$objdir" ;;
9515c3c9db83Smrg	  esac
9516c3c9db83Smrg	  ;;
9517c3c9db83Smrg	esac
9518c3c9db83Smrg      done
9519c3c9db83Smrg      for deplib in $deplibs; do
9520c3c9db83Smrg	case $deplib in
9521c3c9db83Smrg	-L*)
9522c3c9db83Smrg	  case " $new_libs " in
9523c3c9db83Smrg	  *" $deplib "*) ;;
95243f6d0e1dSmrg	  *) func_append new_libs " $deplib" ;;
9525c3c9db83Smrg	  esac
9526c3c9db83Smrg	  ;;
95273f6d0e1dSmrg	*) func_append new_libs " $deplib" ;;
9528c3c9db83Smrg	esac
9529c3c9db83Smrg      done
95302f60eb46Smrg      deplibs=$new_libs
9531c3c9db83Smrg
9532c3c9db83Smrg      # All the library-specific variables (install_libdir is set above).
9533c3c9db83Smrg      library_names=
9534c3c9db83Smrg      old_library=
9535c3c9db83Smrg      dlname=
9536c3c9db83Smrg
9537c3c9db83Smrg      # Test again, we may have decided not to build it any more
95382f60eb46Smrg      if test yes = "$build_libtool_libs"; then
95392f60eb46Smrg	# Remove $wl instances when linking with ld.
954095903e71Smrg	# FIXME: should test the right _cmds variable.
954195903e71Smrg	case $archive_cmds in
954295903e71Smrg	  *\$LD\ *) wl= ;;
954395903e71Smrg        esac
95442f60eb46Smrg	if test yes = "$hardcode_into_libs"; then
9545c3c9db83Smrg	  # Hardcode the library paths
9546c3c9db83Smrg	  hardcode_libdirs=
9547c3c9db83Smrg	  dep_rpath=
95482f60eb46Smrg	  rpath=$finalize_rpath
95492f60eb46Smrg	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
9550c3c9db83Smrg	  for libdir in $rpath; do
9551c3c9db83Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
9552c3c9db83Smrg	      if test -n "$hardcode_libdir_separator"; then
95533f6d0e1dSmrg		func_replace_sysroot "$libdir"
95543f6d0e1dSmrg		libdir=$func_replace_sysroot_result
9555c3c9db83Smrg		if test -z "$hardcode_libdirs"; then
95562f60eb46Smrg		  hardcode_libdirs=$libdir
9557c3c9db83Smrg		else
9558c3c9db83Smrg		  # Just accumulate the unique libdirs.
9559c3c9db83Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
9560c3c9db83Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
9561c3c9db83Smrg		    ;;
9562c3c9db83Smrg		  *)
95633f6d0e1dSmrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
9564c3c9db83Smrg		    ;;
9565c3c9db83Smrg		  esac
9566c3c9db83Smrg		fi
9567c3c9db83Smrg	      else
9568c3c9db83Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
95693f6d0e1dSmrg		func_append dep_rpath " $flag"
9570c3c9db83Smrg	      fi
9571c3c9db83Smrg	    elif test -n "$runpath_var"; then
9572c3c9db83Smrg	      case "$perm_rpath " in
9573c3c9db83Smrg	      *" $libdir "*) ;;
957495903e71Smrg	      *) func_append perm_rpath " $libdir" ;;
9575c3c9db83Smrg	      esac
9576c3c9db83Smrg	    fi
9577c3c9db83Smrg	  done
9578c3c9db83Smrg	  # Substitute the hardcoded libdirs into the rpath.
9579c3c9db83Smrg	  if test -n "$hardcode_libdir_separator" &&
9580c3c9db83Smrg	     test -n "$hardcode_libdirs"; then
95812f60eb46Smrg	    libdir=$hardcode_libdirs
958295903e71Smrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
9583c3c9db83Smrg	  fi
9584c3c9db83Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
9585c3c9db83Smrg	    # We should set the runpath_var.
9586c3c9db83Smrg	    rpath=
9587c3c9db83Smrg	    for dir in $perm_rpath; do
95883f6d0e1dSmrg	      func_append rpath "$dir:"
9589c3c9db83Smrg	    done
9590c3c9db83Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
9591c3c9db83Smrg	  fi
9592c3c9db83Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
9593c3c9db83Smrg	fi
9594692f60a7Smrg
95952f60eb46Smrg	shlibpath=$finalize_shlibpath
95962f60eb46Smrg	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
9597c3c9db83Smrg	if test -n "$shlibpath"; then
9598c3c9db83Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
9599c3c9db83Smrg	fi
9600692f60a7Smrg
9601c3c9db83Smrg	# Get the real and link names of the library.
9602c3c9db83Smrg	eval shared_ext=\"$shrext_cmds\"
9603c3c9db83Smrg	eval library_names=\"$library_names_spec\"
9604c3c9db83Smrg	set dummy $library_names
9605c3c9db83Smrg	shift
96062f60eb46Smrg	realname=$1
9607c3c9db83Smrg	shift
9608692f60a7Smrg
9609c3c9db83Smrg	if test -n "$soname_spec"; then
9610c3c9db83Smrg	  eval soname=\"$soname_spec\"
9611c3c9db83Smrg	else
96122f60eb46Smrg	  soname=$realname
9613c3c9db83Smrg	fi
9614c3c9db83Smrg	if test -z "$dlname"; then
9615c3c9db83Smrg	  dlname=$soname
9616c3c9db83Smrg	fi
9617692f60a7Smrg
96182f60eb46Smrg	lib=$output_objdir/$realname
9619c3c9db83Smrg	linknames=
9620c3c9db83Smrg	for link
9621c3c9db83Smrg	do
96223f6d0e1dSmrg	  func_append linknames " $link"
9623c3c9db83Smrg	done
9624692f60a7Smrg
9625c3c9db83Smrg	# Use standard objects if they are pic
96263f6d0e1dSmrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
9627c3c9db83Smrg	test "X$libobjs" = "X " && libobjs=
9628692f60a7Smrg
9629c3c9db83Smrg	delfiles=
9630c3c9db83Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
9631c3c9db83Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
96322f60eb46Smrg	  export_symbols=$output_objdir/$libname.uexp
96333f6d0e1dSmrg	  func_append delfiles " $export_symbols"
9634c3c9db83Smrg	fi
9635692f60a7Smrg
9636c3c9db83Smrg	orig_export_symbols=
9637c3c9db83Smrg	case $host_os in
9638c3c9db83Smrg	cygwin* | mingw* | cegcc*)
9639c3c9db83Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
9640c3c9db83Smrg	    # exporting using user supplied symfile
96412f60eb46Smrg	    func_dll_def_p "$export_symbols" || {
9642c3c9db83Smrg	      # and it's NOT already a .def file. Must figure out
9643c3c9db83Smrg	      # which of the given symbols are data symbols and tag
9644c3c9db83Smrg	      # them as such. So, trigger use of export_symbols_cmds.
9645c3c9db83Smrg	      # export_symbols gets reassigned inside the "prepare
9646c3c9db83Smrg	      # the list of exported symbols" if statement, so the
9647c3c9db83Smrg	      # include_expsyms logic still works.
96482f60eb46Smrg	      orig_export_symbols=$export_symbols
9649c3c9db83Smrg	      export_symbols=
9650c3c9db83Smrg	      always_export_symbols=yes
96512f60eb46Smrg	    }
9652c3c9db83Smrg	  fi
9653c3c9db83Smrg	  ;;
9654c3c9db83Smrg	esac
9655692f60a7Smrg
9656c3c9db83Smrg	# Prepare the list of exported symbols
9657c3c9db83Smrg	if test -z "$export_symbols"; then
96582f60eb46Smrg	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
96592f60eb46Smrg	    func_verbose "generating symbol list for '$libname.la'"
96602f60eb46Smrg	    export_symbols=$output_objdir/$libname.exp
9661c3c9db83Smrg	    $opt_dry_run || $RM $export_symbols
9662c3c9db83Smrg	    cmds=$export_symbols_cmds
96632f60eb46Smrg	    save_ifs=$IFS; IFS='~'
96643f6d0e1dSmrg	    for cmd1 in $cmds; do
96652f60eb46Smrg	      IFS=$save_ifs
96663f6d0e1dSmrg	      # Take the normal branch if the nm_file_list_spec branch
96673f6d0e1dSmrg	      # doesn't work or if tool conversion is not needed.
96683f6d0e1dSmrg	      case $nm_file_list_spec~$to_tool_file_cmd in
96693f6d0e1dSmrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
96703f6d0e1dSmrg		  try_normal_branch=yes
96713f6d0e1dSmrg		  eval cmd=\"$cmd1\"
96723f6d0e1dSmrg		  func_len " $cmd"
96733f6d0e1dSmrg		  len=$func_len_result
96743f6d0e1dSmrg		  ;;
96753f6d0e1dSmrg		*)
96763f6d0e1dSmrg		  try_normal_branch=no
96773f6d0e1dSmrg		  ;;
96783f6d0e1dSmrg	      esac
96792f60eb46Smrg	      if test yes = "$try_normal_branch" \
96803f6d0e1dSmrg		 && { test "$len" -lt "$max_cmd_len" \
96813f6d0e1dSmrg		      || test "$max_cmd_len" -le -1; }
96823f6d0e1dSmrg	      then
96833f6d0e1dSmrg		func_show_eval "$cmd" 'exit $?'
96843f6d0e1dSmrg		skipped_export=false
96853f6d0e1dSmrg	      elif test -n "$nm_file_list_spec"; then
96863f6d0e1dSmrg		func_basename "$output"
96873f6d0e1dSmrg		output_la=$func_basename_result
96883f6d0e1dSmrg		save_libobjs=$libobjs
96893f6d0e1dSmrg		save_output=$output
96902f60eb46Smrg		output=$output_objdir/$output_la.nm
96913f6d0e1dSmrg		func_to_tool_file "$output"
96923f6d0e1dSmrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
96933f6d0e1dSmrg		func_append delfiles " $output"
96943f6d0e1dSmrg		func_verbose "creating $NM input file list: $output"
96953f6d0e1dSmrg		for obj in $save_libobjs; do
96963f6d0e1dSmrg		  func_to_tool_file "$obj"
96973f6d0e1dSmrg		  $ECHO "$func_to_tool_file_result"
96983f6d0e1dSmrg		done > "$output"
96993f6d0e1dSmrg		eval cmd=\"$cmd1\"
9700c3c9db83Smrg		func_show_eval "$cmd" 'exit $?'
97013f6d0e1dSmrg		output=$save_output
97023f6d0e1dSmrg		libobjs=$save_libobjs
9703c3c9db83Smrg		skipped_export=false
9704c3c9db83Smrg	      else
9705c3c9db83Smrg		# The command line is too long to execute in one step.
9706c3c9db83Smrg		func_verbose "using reloadable object file for export list..."
9707c3c9db83Smrg		skipped_export=:
9708c3c9db83Smrg		# Break out early, otherwise skipped_export may be
9709c3c9db83Smrg		# set to false by a later but shorter cmd.
9710c3c9db83Smrg		break
9711c3c9db83Smrg	      fi
9712c3c9db83Smrg	    done
97132f60eb46Smrg	    IFS=$save_ifs
97142f60eb46Smrg	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
9715c3c9db83Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9716c3c9db83Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9717c3c9db83Smrg	    fi
9718c3c9db83Smrg	  fi
9719692f60a7Smrg	fi
9720692f60a7Smrg
9721c3c9db83Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
97222f60eb46Smrg	  tmp_export_symbols=$export_symbols
97232f60eb46Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
97243f6d0e1dSmrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9725c3c9db83Smrg	fi
9726692f60a7Smrg
97272f60eb46Smrg	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
9728c3c9db83Smrg	  # The given exports_symbols file has to be filtered, so filter it.
97292f60eb46Smrg	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9730c3c9db83Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
97312f60eb46Smrg	  # 's' commands, which not all seds can handle. GNU sed should be fine
9732c3c9db83Smrg	  # though. Also, the filter scales superlinearly with the number of
9733c3c9db83Smrg	  # global variables. join(1) would be nice here, but unfortunately
9734c3c9db83Smrg	  # isn't a blessed tool.
9735c3c9db83Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
97363f6d0e1dSmrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9737c3c9db83Smrg	  export_symbols=$output_objdir/$libname.def
9738c3c9db83Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9739c3c9db83Smrg	fi
9740692f60a7Smrg
9741c3c9db83Smrg	tmp_deplibs=
9742c3c9db83Smrg	for test_deplib in $deplibs; do
9743c3c9db83Smrg	  case " $convenience " in
9744c3c9db83Smrg	  *" $test_deplib "*) ;;
9745c3c9db83Smrg	  *)
97463f6d0e1dSmrg	    func_append tmp_deplibs " $test_deplib"
9747c3c9db83Smrg	    ;;
9748c3c9db83Smrg	  esac
9749c3c9db83Smrg	done
97502f60eb46Smrg	deplibs=$tmp_deplibs
9751692f60a7Smrg
9752c3c9db83Smrg	if test -n "$convenience"; then
9753c3c9db83Smrg	  if test -n "$whole_archive_flag_spec" &&
97542f60eb46Smrg	    test yes = "$compiler_needs_object" &&
9755c3c9db83Smrg	    test -z "$libobjs"; then
9756c3c9db83Smrg	    # extract the archives, so we have objects to list.
9757c3c9db83Smrg	    # TODO: could optimize this to just extract one archive.
9758c3c9db83Smrg	    whole_archive_flag_spec=
9759c3c9db83Smrg	  fi
9760c3c9db83Smrg	  if test -n "$whole_archive_flag_spec"; then
9761c3c9db83Smrg	    save_libobjs=$libobjs
9762c3c9db83Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9763c3c9db83Smrg	    test "X$libobjs" = "X " && libobjs=
9764c3c9db83Smrg	  else
97652f60eb46Smrg	    gentop=$output_objdir/${outputname}x
97663f6d0e1dSmrg	    func_append generated " $gentop"
9767692f60a7Smrg
9768c3c9db83Smrg	    func_extract_archives $gentop $convenience
97693f6d0e1dSmrg	    func_append libobjs " $func_extract_archives_result"
9770c3c9db83Smrg	    test "X$libobjs" = "X " && libobjs=
9771c3c9db83Smrg	  fi
97722e71ea71Smrg	fi
9773692f60a7Smrg
97742f60eb46Smrg	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
9775c3c9db83Smrg	  eval flag=\"$thread_safe_flag_spec\"
97763f6d0e1dSmrg	  func_append linker_flags " $flag"
97772e71ea71Smrg	fi
977885ee4c00Smrg
9779c3c9db83Smrg	# Make a backup of the uninstalled library when relinking
97802f60eb46Smrg	if test relink = "$opt_mode"; then
9781c3c9db83Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
9782c3c9db83Smrg	fi
9783692f60a7Smrg
9784c3c9db83Smrg	# Do each of the archive commands.
97852f60eb46Smrg	if test yes = "$module" && test -n "$module_cmds"; then
9786c3c9db83Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
9787c3c9db83Smrg	    eval test_cmds=\"$module_expsym_cmds\"
9788c3c9db83Smrg	    cmds=$module_expsym_cmds
9789c3c9db83Smrg	  else
9790c3c9db83Smrg	    eval test_cmds=\"$module_cmds\"
9791c3c9db83Smrg	    cmds=$module_cmds
9792c3c9db83Smrg	  fi
97932e71ea71Smrg	else
9794c3c9db83Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
9795c3c9db83Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
9796c3c9db83Smrg	    cmds=$archive_expsym_cmds
9797c3c9db83Smrg	  else
9798c3c9db83Smrg	    eval test_cmds=\"$archive_cmds\"
9799c3c9db83Smrg	    cmds=$archive_cmds
9800c3c9db83Smrg	  fi
98012e71ea71Smrg	fi
9802692f60a7Smrg
98032f60eb46Smrg	if test : != "$skipped_export" &&
9804c3c9db83Smrg	   func_len " $test_cmds" &&
9805c3c9db83Smrg	   len=$func_len_result &&
9806c3c9db83Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9807c3c9db83Smrg	  :
9808c3c9db83Smrg	else
9809c3c9db83Smrg	  # The command line is too long to link in one step, link piecewise
9810c3c9db83Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
9811c3c9db83Smrg	  # script.
9812692f60a7Smrg
9813c3c9db83Smrg	  # Save the value of $output and $libobjs because we want to
9814c3c9db83Smrg	  # use them later.  If we have whole_archive_flag_spec, we
9815c3c9db83Smrg	  # want to use save_libobjs as it was before
9816c3c9db83Smrg	  # whole_archive_flag_spec was expanded, because we can't
9817c3c9db83Smrg	  # assume the linker understands whole_archive_flag_spec.
9818c3c9db83Smrg	  # This may have to be revisited, in case too many
9819c3c9db83Smrg	  # convenience libraries get linked in and end up exceeding
9820c3c9db83Smrg	  # the spec.
9821c3c9db83Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
9822c3c9db83Smrg	    save_libobjs=$libobjs
9823c3c9db83Smrg	  fi
9824c3c9db83Smrg	  save_output=$output
98253f6d0e1dSmrg	  func_basename "$output"
98263f6d0e1dSmrg	  output_la=$func_basename_result
9827692f60a7Smrg
9828c3c9db83Smrg	  # Clear the reloadable object creation command queue and
9829c3c9db83Smrg	  # initialize k to one.
9830c3c9db83Smrg	  test_cmds=
9831c3c9db83Smrg	  concat_cmds=
9832c3c9db83Smrg	  objlist=
9833c3c9db83Smrg	  last_robj=
9834c3c9db83Smrg	  k=1
9835c3c9db83Smrg
98362f60eb46Smrg	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
98372f60eb46Smrg	    output=$output_objdir/$output_la.lnkscript
9838c3c9db83Smrg	    func_verbose "creating GNU ld script: $output"
98393f6d0e1dSmrg	    echo 'INPUT (' > $output
9840c3c9db83Smrg	    for obj in $save_libobjs
98412e71ea71Smrg	    do
98423f6d0e1dSmrg	      func_to_tool_file "$obj"
98433f6d0e1dSmrg	      $ECHO "$func_to_tool_file_result" >> $output
9844c3c9db83Smrg	    done
98453f6d0e1dSmrg	    echo ')' >> $output
98463f6d0e1dSmrg	    func_append delfiles " $output"
98473f6d0e1dSmrg	    func_to_tool_file "$output"
98483f6d0e1dSmrg	    output=$func_to_tool_file_result
98492f60eb46Smrg	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
98502f60eb46Smrg	    output=$output_objdir/$output_la.lnk
9851c3c9db83Smrg	    func_verbose "creating linker input file list: $output"
9852c3c9db83Smrg	    : > $output
9853c3c9db83Smrg	    set x $save_libobjs
9854c3c9db83Smrg	    shift
9855c3c9db83Smrg	    firstobj=
98562f60eb46Smrg	    if test yes = "$compiler_needs_object"; then
9857c3c9db83Smrg	      firstobj="$1 "
9858c3c9db83Smrg	      shift
9859c3c9db83Smrg	    fi
9860c3c9db83Smrg	    for obj
9861c3c9db83Smrg	    do
98623f6d0e1dSmrg	      func_to_tool_file "$obj"
98633f6d0e1dSmrg	      $ECHO "$func_to_tool_file_result" >> $output
9864c3c9db83Smrg	    done
98653f6d0e1dSmrg	    func_append delfiles " $output"
98663f6d0e1dSmrg	    func_to_tool_file "$output"
98673f6d0e1dSmrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
9868c3c9db83Smrg	  else
9869c3c9db83Smrg	    if test -n "$save_libobjs"; then
9870c3c9db83Smrg	      func_verbose "creating reloadable object files..."
98712f60eb46Smrg	      output=$output_objdir/$output_la-$k.$objext
9872c3c9db83Smrg	      eval test_cmds=\"$reload_cmds\"
9873c3c9db83Smrg	      func_len " $test_cmds"
9874c3c9db83Smrg	      len0=$func_len_result
9875c3c9db83Smrg	      len=$len0
9876c3c9db83Smrg
9877c3c9db83Smrg	      # Loop over the list of objects to be linked.
9878c3c9db83Smrg	      for obj in $save_libobjs
9879c3c9db83Smrg	      do
9880c3c9db83Smrg		func_len " $obj"
9881c3c9db83Smrg		func_arith $len + $func_len_result
9882c3c9db83Smrg		len=$func_arith_result
98832f60eb46Smrg		if test -z "$objlist" ||
9884c3c9db83Smrg		   test "$len" -lt "$max_cmd_len"; then
9885c3c9db83Smrg		  func_append objlist " $obj"
9886c3c9db83Smrg		else
9887c3c9db83Smrg		  # The command $test_cmds is almost too long, add a
9888c3c9db83Smrg		  # command to the queue.
98892f60eb46Smrg		  if test 1 -eq "$k"; then
9890c3c9db83Smrg		    # The first file doesn't have a previous command to add.
98913f6d0e1dSmrg		    reload_objs=$objlist
98923f6d0e1dSmrg		    eval concat_cmds=\"$reload_cmds\"
9893c3c9db83Smrg		  else
9894c3c9db83Smrg		    # All subsequent reloadable object files will link in
9895c3c9db83Smrg		    # the last one created.
98963f6d0e1dSmrg		    reload_objs="$objlist $last_robj"
98973f6d0e1dSmrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
9898c3c9db83Smrg		  fi
98992f60eb46Smrg		  last_robj=$output_objdir/$output_la-$k.$objext
9900c3c9db83Smrg		  func_arith $k + 1
9901c3c9db83Smrg		  k=$func_arith_result
99022f60eb46Smrg		  output=$output_objdir/$output_la-$k.$objext
99033f6d0e1dSmrg		  objlist=" $obj"
9904c3c9db83Smrg		  func_len " $last_robj"
9905c3c9db83Smrg		  func_arith $len0 + $func_len_result
9906c3c9db83Smrg		  len=$func_arith_result
9907c3c9db83Smrg		fi
9908c3c9db83Smrg	      done
9909c3c9db83Smrg	      # Handle the remaining objects by creating one last
9910c3c9db83Smrg	      # reloadable object file.  All subsequent reloadable object
9911c3c9db83Smrg	      # files will link in the last one created.
9912c3c9db83Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
99133f6d0e1dSmrg	      reload_objs="$objlist $last_robj"
99142f60eb46Smrg	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
9915c3c9db83Smrg	      if test -n "$last_robj"; then
99162f60eb46Smrg	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9917c3c9db83Smrg	      fi
99183f6d0e1dSmrg	      func_append delfiles " $output"
9919692f60a7Smrg
9920c3c9db83Smrg	    else
9921c3c9db83Smrg	      output=
9922c3c9db83Smrg	    fi
9923692f60a7Smrg
99242f60eb46Smrg	    ${skipped_export-false} && {
99252f60eb46Smrg	      func_verbose "generating symbol list for '$libname.la'"
99262f60eb46Smrg	      export_symbols=$output_objdir/$libname.exp
9927c3c9db83Smrg	      $opt_dry_run || $RM $export_symbols
9928c3c9db83Smrg	      libobjs=$output
9929c3c9db83Smrg	      # Append the command to create the export file.
9930c3c9db83Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9931c3c9db83Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
9932c3c9db83Smrg	      if test -n "$last_robj"; then
9933c3c9db83Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9934c3c9db83Smrg	      fi
99352f60eb46Smrg	    }
9936692f60a7Smrg
9937c3c9db83Smrg	    test -n "$save_libobjs" &&
9938c3c9db83Smrg	      func_verbose "creating a temporary reloadable object file: $output"
9939692f60a7Smrg
9940c3c9db83Smrg	    # Loop through the commands generated above and execute them.
99412f60eb46Smrg	    save_ifs=$IFS; IFS='~'
9942c3c9db83Smrg	    for cmd in $concat_cmds; do
99432f60eb46Smrg	      IFS=$save_ifs
99442f60eb46Smrg	      $opt_quiet || {
9945c3c9db83Smrg		  func_quote_for_expand "$cmd"
9946c3c9db83Smrg		  eval "func_echo $func_quote_for_expand_result"
9947c3c9db83Smrg	      }
9948c3c9db83Smrg	      $opt_dry_run || eval "$cmd" || {
9949c3c9db83Smrg		lt_exit=$?
9950c3c9db83Smrg
9951c3c9db83Smrg		# Restore the uninstalled library and exit
99522f60eb46Smrg		if test relink = "$opt_mode"; then
9953c3c9db83Smrg		  ( cd "$output_objdir" && \
9954c3c9db83Smrg		    $RM "${realname}T" && \
9955c3c9db83Smrg		    $MV "${realname}U" "$realname" )
9956c3c9db83Smrg		fi
9957692f60a7Smrg
9958c3c9db83Smrg		exit $lt_exit
9959c3c9db83Smrg	      }
9960c3c9db83Smrg	    done
99612f60eb46Smrg	    IFS=$save_ifs
99622e71ea71Smrg
9963c3c9db83Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
9964c3c9db83Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9965c3c9db83Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9966692f60a7Smrg	    fi
9967692f60a7Smrg	  fi
9968692f60a7Smrg
99692f60eb46Smrg          ${skipped_export-false} && {
9970c3c9db83Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
99712f60eb46Smrg	      tmp_export_symbols=$export_symbols
99722f60eb46Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
99733f6d0e1dSmrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9974c3c9db83Smrg	    fi
997585ee4c00Smrg
9976c3c9db83Smrg	    if test -n "$orig_export_symbols"; then
9977c3c9db83Smrg	      # The given exports_symbols file has to be filtered, so filter it.
99782f60eb46Smrg	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9979c3c9db83Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
99802f60eb46Smrg	      # 's' commands, which not all seds can handle. GNU sed should be fine
9981c3c9db83Smrg	      # though. Also, the filter scales superlinearly with the number of
9982c3c9db83Smrg	      # global variables. join(1) would be nice here, but unfortunately
9983c3c9db83Smrg	      # isn't a blessed tool.
9984c3c9db83Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
99853f6d0e1dSmrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9986c3c9db83Smrg	      export_symbols=$output_objdir/$libname.def
9987c3c9db83Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9988c3c9db83Smrg	    fi
99892f60eb46Smrg	  }
9990692f60a7Smrg
9991c3c9db83Smrg	  libobjs=$output
9992c3c9db83Smrg	  # Restore the value of output.
9993c3c9db83Smrg	  output=$save_output
9994692f60a7Smrg
9995c3c9db83Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
9996c3c9db83Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9997c3c9db83Smrg	    test "X$libobjs" = "X " && libobjs=
9998c3c9db83Smrg	  fi
9999c3c9db83Smrg	  # Expand the library linking commands again to reset the
10000c3c9db83Smrg	  # value of $libobjs for piecewise linking.
10001692f60a7Smrg
10002c3c9db83Smrg	  # Do each of the archive commands.
100032f60eb46Smrg	  if test yes = "$module" && test -n "$module_cmds"; then
10004c3c9db83Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
10005c3c9db83Smrg	      cmds=$module_expsym_cmds
10006c3c9db83Smrg	    else
10007c3c9db83Smrg	      cmds=$module_cmds
100082e71ea71Smrg	    fi
100092e71ea71Smrg	  else
10010c3c9db83Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
10011c3c9db83Smrg	      cmds=$archive_expsym_cmds
10012c3c9db83Smrg	    else
10013c3c9db83Smrg	      cmds=$archive_cmds
10014c3c9db83Smrg	    fi
100152e71ea71Smrg	  fi
10016c3c9db83Smrg	fi
10017692f60a7Smrg
10018c3c9db83Smrg	if test -n "$delfiles"; then
10019c3c9db83Smrg	  # Append the command to remove temporary files to $cmds.
10020c3c9db83Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
10021c3c9db83Smrg	fi
10022692f60a7Smrg
10023c3c9db83Smrg	# Add any objects from preloaded convenience libraries
10024c3c9db83Smrg	if test -n "$dlprefiles"; then
100252f60eb46Smrg	  gentop=$output_objdir/${outputname}x
100263f6d0e1dSmrg	  func_append generated " $gentop"
10027692f60a7Smrg
10028c3c9db83Smrg	  func_extract_archives $gentop $dlprefiles
100293f6d0e1dSmrg	  func_append libobjs " $func_extract_archives_result"
10030c3c9db83Smrg	  test "X$libobjs" = "X " && libobjs=
10031c3c9db83Smrg	fi
10032692f60a7Smrg
100332f60eb46Smrg	save_ifs=$IFS; IFS='~'
10034c3c9db83Smrg	for cmd in $cmds; do
100352f60eb46Smrg	  IFS=$sp$nl
10036c3c9db83Smrg	  eval cmd=\"$cmd\"
100372f60eb46Smrg	  IFS=$save_ifs
100382f60eb46Smrg	  $opt_quiet || {
10039c3c9db83Smrg	    func_quote_for_expand "$cmd"
10040c3c9db83Smrg	    eval "func_echo $func_quote_for_expand_result"
10041c3c9db83Smrg	  }
10042c3c9db83Smrg	  $opt_dry_run || eval "$cmd" || {
10043c3c9db83Smrg	    lt_exit=$?
1004485ee4c00Smrg
10045c3c9db83Smrg	    # Restore the uninstalled library and exit
100462f60eb46Smrg	    if test relink = "$opt_mode"; then
10047c3c9db83Smrg	      ( cd "$output_objdir" && \
10048c3c9db83Smrg	        $RM "${realname}T" && \
10049c3c9db83Smrg		$MV "${realname}U" "$realname" )
10050c3c9db83Smrg	    fi
1005185ee4c00Smrg
10052c3c9db83Smrg	    exit $lt_exit
10053c3c9db83Smrg	  }
10054c3c9db83Smrg	done
100552f60eb46Smrg	IFS=$save_ifs
1005685ee4c00Smrg
10057c3c9db83Smrg	# Restore the uninstalled library and exit
100582f60eb46Smrg	if test relink = "$opt_mode"; then
10059c3c9db83Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
1006085ee4c00Smrg
10061c3c9db83Smrg	  if test -n "$convenience"; then
10062c3c9db83Smrg	    if test -z "$whole_archive_flag_spec"; then
10063c3c9db83Smrg	      func_show_eval '${RM}r "$gentop"'
10064c3c9db83Smrg	    fi
10065c3c9db83Smrg	  fi
1006685ee4c00Smrg
10067c3c9db83Smrg	  exit $EXIT_SUCCESS
10068c3c9db83Smrg	fi
10069c3c9db83Smrg
10070c3c9db83Smrg	# Create links to the real library.
10071c3c9db83Smrg	for linkname in $linknames; do
10072c3c9db83Smrg	  if test "$realname" != "$linkname"; then
10073c3c9db83Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
100742e71ea71Smrg	  fi
100752e71ea71Smrg	done
1007685ee4c00Smrg
10077c3c9db83Smrg	# If -module or -export-dynamic was specified, set the dlname.
100782f60eb46Smrg	if test yes = "$module" || test yes = "$export_dynamic"; then
10079c3c9db83Smrg	  # On all known operating systems, these are identical.
100802f60eb46Smrg	  dlname=$soname
10081c3c9db83Smrg	fi
10082c3c9db83Smrg      fi
10083692f60a7Smrg      ;;
10084692f60a7Smrg
10085c3c9db83Smrg    obj)
100862f60eb46Smrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
100872f60eb46Smrg	func_warning "'-dlopen' is ignored for objects"
10088c3c9db83Smrg      fi
100892e71ea71Smrg
10090c3c9db83Smrg      case " $deplibs" in
10091c3c9db83Smrg      *\ -l* | *\ -L*)
100922f60eb46Smrg	func_warning "'-l' and '-L' are ignored for objects" ;;
1009385ee4c00Smrg      esac
10094692f60a7Smrg
10095c3c9db83Smrg      test -n "$rpath" && \
100962f60eb46Smrg	func_warning "'-rpath' is ignored for objects"
10097c3c9db83Smrg
10098c3c9db83Smrg      test -n "$xrpath" && \
100992f60eb46Smrg	func_warning "'-R' is ignored for objects"
10100692f60a7Smrg
10101c3c9db83Smrg      test -n "$vinfo" && \
101022f60eb46Smrg	func_warning "'-version-info' is ignored for objects"
1010385ee4c00Smrg
10104c3c9db83Smrg      test -n "$release" && \
101052f60eb46Smrg	func_warning "'-release' is ignored for objects"
10106c3c9db83Smrg
10107c3c9db83Smrg      case $output in
10108c3c9db83Smrg      *.lo)
10109c3c9db83Smrg	test -n "$objs$old_deplibs" && \
101102f60eb46Smrg	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
10111c3c9db83Smrg
10112c3c9db83Smrg	libobj=$output
10113c3c9db83Smrg	func_lo2o "$libobj"
10114c3c9db83Smrg	obj=$func_lo2o_result
101152e71ea71Smrg	;;
101162e71ea71Smrg      *)
10117c3c9db83Smrg	libobj=
101182f60eb46Smrg	obj=$output
10119692f60a7Smrg	;;
1012085ee4c00Smrg      esac
10121692f60a7Smrg
10122c3c9db83Smrg      # Delete the old objects.
10123c3c9db83Smrg      $opt_dry_run || $RM $obj $libobj
10124692f60a7Smrg
10125c3c9db83Smrg      # Objects from convenience libraries.  This assumes
10126c3c9db83Smrg      # single-version convenience libraries.  Whenever we create
10127c3c9db83Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
10128c3c9db83Smrg      # the extraction.
10129c3c9db83Smrg      reload_conv_objs=
10130c3c9db83Smrg      gentop=
101312f60eb46Smrg      # if reload_cmds runs $LD directly, get rid of -Wl from
101322f60eb46Smrg      # whole_archive_flag_spec and hope we can get by with turning comma
101332f60eb46Smrg      # into space.
101342f60eb46Smrg      case $reload_cmds in
101352f60eb46Smrg        *\$LD[\ \$]*) wl= ;;
101362f60eb46Smrg      esac
10137c3c9db83Smrg      if test -n "$convenience"; then
10138c3c9db83Smrg	if test -n "$whole_archive_flag_spec"; then
10139c3c9db83Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
101402f60eb46Smrg	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
101412f60eb46Smrg	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
10142c3c9db83Smrg	else
101432f60eb46Smrg	  gentop=$output_objdir/${obj}x
101443f6d0e1dSmrg	  func_append generated " $gentop"
101452e71ea71Smrg
10146c3c9db83Smrg	  func_extract_archives $gentop $convenience
10147c3c9db83Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
10148c3c9db83Smrg	fi
101492e71ea71Smrg      fi
101502e71ea71Smrg
101513f6d0e1dSmrg      # If we're not building shared, we need to use non_pic_objs
101522f60eb46Smrg      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
101533f6d0e1dSmrg
10154c3c9db83Smrg      # Create the old-style object.
101552f60eb46Smrg      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
101562e71ea71Smrg
101572f60eb46Smrg      output=$obj
10158c3c9db83Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
101592e71ea71Smrg
10160c3c9db83Smrg      # Exit if we aren't doing a library object file.
10161c3c9db83Smrg      if test -z "$libobj"; then
10162c3c9db83Smrg	if test -n "$gentop"; then
10163c3c9db83Smrg	  func_show_eval '${RM}r "$gentop"'
10164c3c9db83Smrg	fi
10165c3c9db83Smrg
10166c3c9db83Smrg	exit $EXIT_SUCCESS
101672e71ea71Smrg      fi
10168c3c9db83Smrg
101692f60eb46Smrg      test yes = "$build_libtool_libs" || {
10170c3c9db83Smrg	if test -n "$gentop"; then
10171c3c9db83Smrg	  func_show_eval '${RM}r "$gentop"'
10172c3c9db83Smrg	fi
10173c3c9db83Smrg
10174c3c9db83Smrg	# Create an invalid libtool object if no PIC, so that we don't
10175c3c9db83Smrg	# accidentally link it into a program.
10176c3c9db83Smrg	# $show "echo timestamp > $libobj"
10177c3c9db83Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
10178c3c9db83Smrg	exit $EXIT_SUCCESS
101792f60eb46Smrg      }
10180c3c9db83Smrg
101812f60eb46Smrg      if test -n "$pic_flag" || test default != "$pic_mode"; then
10182c3c9db83Smrg	# Only do commands if we really have different PIC objects.
10183c3c9db83Smrg	reload_objs="$libobjs $reload_conv_objs"
101842f60eb46Smrg	output=$libobj
10185c3c9db83Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
10186c3c9db83Smrg      fi
10187c3c9db83Smrg
10188c3c9db83Smrg      if test -n "$gentop"; then
10189c3c9db83Smrg	func_show_eval '${RM}r "$gentop"'
10190c3c9db83Smrg      fi
10191c3c9db83Smrg
10192c3c9db83Smrg      exit $EXIT_SUCCESS
101932e71ea71Smrg      ;;
10194692f60a7Smrg
10195c3c9db83Smrg    prog)
10196c3c9db83Smrg      case $host in
10197c3c9db83Smrg	*cygwin*) func_stripname '' '.exe' "$output"
10198c3c9db83Smrg	          output=$func_stripname_result.exe;;
10199c3c9db83Smrg      esac
10200c3c9db83Smrg      test -n "$vinfo" && \
102012f60eb46Smrg	func_warning "'-version-info' is ignored for programs"
10202692f60a7Smrg
10203c3c9db83Smrg      test -n "$release" && \
102042f60eb46Smrg	func_warning "'-release' is ignored for programs"
10205692f60a7Smrg
102062f60eb46Smrg      $preload \
102072f60eb46Smrg	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
102082f60eb46Smrg	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
10209c3c9db83Smrg
10210c3c9db83Smrg      case $host in
10211c3c9db83Smrg      *-*-rhapsody* | *-*-darwin1.[012])
10212c3c9db83Smrg	# On Rhapsody replace the C library is the System framework
102133f6d0e1dSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
102143f6d0e1dSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
102152e71ea71Smrg	;;
10216c3c9db83Smrg      esac
102172e71ea71Smrg
10218c3c9db83Smrg      case $host in
10219c3c9db83Smrg      *-*-darwin*)
10220c3c9db83Smrg	# Don't allow lazy linking, it breaks C++ global constructors
10221c3c9db83Smrg	# But is supposedly fixed on 10.4 or later (yay!).
102222f60eb46Smrg	if test CXX = "$tagname"; then
10223c3c9db83Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
10224c3c9db83Smrg	    10.[0123])
102252f60eb46Smrg	      func_append compile_command " $wl-bind_at_load"
102262f60eb46Smrg	      func_append finalize_command " $wl-bind_at_load"
10227c3c9db83Smrg	    ;;
10228c3c9db83Smrg	  esac
102292e71ea71Smrg	fi
10230c3c9db83Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
102313f6d0e1dSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
102323f6d0e1dSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10233c3c9db83Smrg	;;
10234c3c9db83Smrg      esac
102352e71ea71Smrg
102362e71ea71Smrg
10237c3c9db83Smrg      # move library search paths that coincide with paths to not yet
10238c3c9db83Smrg      # installed libraries to the beginning of the library search list
10239c3c9db83Smrg      new_libs=
10240c3c9db83Smrg      for path in $notinst_path; do
10241c3c9db83Smrg	case " $new_libs " in
10242c3c9db83Smrg	*" -L$path/$objdir "*) ;;
10243c3c9db83Smrg	*)
10244c3c9db83Smrg	  case " $compile_deplibs " in
10245c3c9db83Smrg	  *" -L$path/$objdir "*)
102463f6d0e1dSmrg	    func_append new_libs " -L$path/$objdir" ;;
1024785ee4c00Smrg	  esac
10248c3c9db83Smrg	  ;;
10249c3c9db83Smrg	esac
10250c3c9db83Smrg      done
10251c3c9db83Smrg      for deplib in $compile_deplibs; do
10252c3c9db83Smrg	case $deplib in
10253c3c9db83Smrg	-L*)
10254c3c9db83Smrg	  case " $new_libs " in
10255c3c9db83Smrg	  *" $deplib "*) ;;
102563f6d0e1dSmrg	  *) func_append new_libs " $deplib" ;;
1025785ee4c00Smrg	  esac
10258c3c9db83Smrg	  ;;
102593f6d0e1dSmrg	*) func_append new_libs " $deplib" ;;
10260c3c9db83Smrg	esac
10261c3c9db83Smrg      done
102622f60eb46Smrg      compile_deplibs=$new_libs
10263692f60a7Smrg
102642e71ea71Smrg
102653f6d0e1dSmrg      func_append compile_command " $compile_deplibs"
102663f6d0e1dSmrg      func_append finalize_command " $finalize_deplibs"
102672e71ea71Smrg
10268c3c9db83Smrg      if test -n "$rpath$xrpath"; then
10269c3c9db83Smrg	# If the user specified any rpath flags, then add them.
10270c3c9db83Smrg	for libdir in $rpath $xrpath; do
10271c3c9db83Smrg	  # This is the magic to use -rpath.
10272c3c9db83Smrg	  case "$finalize_rpath " in
10273c3c9db83Smrg	  *" $libdir "*) ;;
102743f6d0e1dSmrg	  *) func_append finalize_rpath " $libdir" ;;
10275c3c9db83Smrg	  esac
10276c3c9db83Smrg	done
10277c3c9db83Smrg      fi
102782e71ea71Smrg
10279c3c9db83Smrg      # Now hardcode the library paths
10280c3c9db83Smrg      rpath=
10281c3c9db83Smrg      hardcode_libdirs=
10282c3c9db83Smrg      for libdir in $compile_rpath $finalize_rpath; do
10283c3c9db83Smrg	if test -n "$hardcode_libdir_flag_spec"; then
10284c3c9db83Smrg	  if test -n "$hardcode_libdir_separator"; then
10285c3c9db83Smrg	    if test -z "$hardcode_libdirs"; then
102862f60eb46Smrg	      hardcode_libdirs=$libdir
10287c3c9db83Smrg	    else
10288c3c9db83Smrg	      # Just accumulate the unique libdirs.
10289c3c9db83Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10290c3c9db83Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10291c3c9db83Smrg		;;
10292c3c9db83Smrg	      *)
102933f6d0e1dSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10294c3c9db83Smrg		;;
10295c3c9db83Smrg	      esac
10296c3c9db83Smrg	    fi
102972e71ea71Smrg	  else
10298c3c9db83Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
102993f6d0e1dSmrg	    func_append rpath " $flag"
103002e71ea71Smrg	  fi
10301c3c9db83Smrg	elif test -n "$runpath_var"; then
10302c3c9db83Smrg	  case "$perm_rpath " in
10303c3c9db83Smrg	  *" $libdir "*) ;;
103043f6d0e1dSmrg	  *) func_append perm_rpath " $libdir" ;;
10305c3c9db83Smrg	  esac
10306c3c9db83Smrg	fi
10307c3c9db83Smrg	case $host in
10308c3c9db83Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
103092f60eb46Smrg	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
10310c3c9db83Smrg	  case :$dllsearchpath: in
10311c3c9db83Smrg	  *":$libdir:"*) ;;
10312c3c9db83Smrg	  ::) dllsearchpath=$libdir;;
103133f6d0e1dSmrg	  *) func_append dllsearchpath ":$libdir";;
10314c3c9db83Smrg	  esac
10315c3c9db83Smrg	  case :$dllsearchpath: in
10316c3c9db83Smrg	  *":$testbindir:"*) ;;
10317c3c9db83Smrg	  ::) dllsearchpath=$testbindir;;
103183f6d0e1dSmrg	  *) func_append dllsearchpath ":$testbindir";;
10319c3c9db83Smrg	  esac
10320c3c9db83Smrg	  ;;
10321c3c9db83Smrg	esac
10322c3c9db83Smrg      done
10323c3c9db83Smrg      # Substitute the hardcoded libdirs into the rpath.
10324c3c9db83Smrg      if test -n "$hardcode_libdir_separator" &&
10325c3c9db83Smrg	 test -n "$hardcode_libdirs"; then
103262f60eb46Smrg	libdir=$hardcode_libdirs
10327c3c9db83Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
10328c3c9db83Smrg      fi
103292f60eb46Smrg      compile_rpath=$rpath
103302e71ea71Smrg
10331c3c9db83Smrg      rpath=
10332c3c9db83Smrg      hardcode_libdirs=
10333c3c9db83Smrg      for libdir in $finalize_rpath; do
10334c3c9db83Smrg	if test -n "$hardcode_libdir_flag_spec"; then
10335c3c9db83Smrg	  if test -n "$hardcode_libdir_separator"; then
10336c3c9db83Smrg	    if test -z "$hardcode_libdirs"; then
103372f60eb46Smrg	      hardcode_libdirs=$libdir
10338c3c9db83Smrg	    else
10339c3c9db83Smrg	      # Just accumulate the unique libdirs.
10340c3c9db83Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10341c3c9db83Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10342c3c9db83Smrg		;;
10343c3c9db83Smrg	      *)
103443f6d0e1dSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10345c3c9db83Smrg		;;
10346c3c9db83Smrg	      esac
10347c3c9db83Smrg	    fi
10348692f60a7Smrg	  else
10349c3c9db83Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
103503f6d0e1dSmrg	    func_append rpath " $flag"
10351692f60a7Smrg	  fi
10352c3c9db83Smrg	elif test -n "$runpath_var"; then
10353c3c9db83Smrg	  case "$finalize_perm_rpath " in
10354c3c9db83Smrg	  *" $libdir "*) ;;
103553f6d0e1dSmrg	  *) func_append finalize_perm_rpath " $libdir" ;;
10356c3c9db83Smrg	  esac
10357692f60a7Smrg	fi
10358c3c9db83Smrg      done
10359c3c9db83Smrg      # Substitute the hardcoded libdirs into the rpath.
10360c3c9db83Smrg      if test -n "$hardcode_libdir_separator" &&
10361c3c9db83Smrg	 test -n "$hardcode_libdirs"; then
103622f60eb46Smrg	libdir=$hardcode_libdirs
10363c3c9db83Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
10364c3c9db83Smrg      fi
103652f60eb46Smrg      finalize_rpath=$rpath
10366692f60a7Smrg
103672f60eb46Smrg      if test -n "$libobjs" && test yes = "$build_old_libs"; then
10368c3c9db83Smrg	# Transform all the library objects into standard objects.
103693f6d0e1dSmrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
103703f6d0e1dSmrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10371c3c9db83Smrg      fi
10372692f60a7Smrg
103732f60eb46Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" false
10374692f60a7Smrg
10375c3c9db83Smrg      # template prelinking step
10376c3c9db83Smrg      if test -n "$prelink_cmds"; then
10377c3c9db83Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
10378c3c9db83Smrg      fi
10379692f60a7Smrg
103802f60eb46Smrg      wrappers_required=:
10381c3c9db83Smrg      case $host in
103823f6d0e1dSmrg      *cegcc* | *mingw32ce*)
103833f6d0e1dSmrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
103842f60eb46Smrg        wrappers_required=false
103853f6d0e1dSmrg        ;;
10386c3c9db83Smrg      *cygwin* | *mingw* )
103872f60eb46Smrg        test yes = "$build_libtool_libs" || wrappers_required=false
10388c3c9db83Smrg        ;;
10389c3c9db83Smrg      *)
103902f60eb46Smrg        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
103912f60eb46Smrg          wrappers_required=false
10392c3c9db83Smrg        fi
10393c3c9db83Smrg        ;;
10394c3c9db83Smrg      esac
103952f60eb46Smrg      $wrappers_required || {
10396c3c9db83Smrg	# Replace the output file specification.
103973f6d0e1dSmrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
103982f60eb46Smrg	link_command=$compile_command$compile_rpath
10399692f60a7Smrg
10400c3c9db83Smrg	# We have no uninstalled library dependencies, so finalize right now.
10401c3c9db83Smrg	exit_status=0
10402c3c9db83Smrg	func_show_eval "$link_command" 'exit_status=$?'
10403692f60a7Smrg
104043f6d0e1dSmrg	if test -n "$postlink_cmds"; then
104053f6d0e1dSmrg	  func_to_tool_file "$output"
104063f6d0e1dSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
104073f6d0e1dSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
104083f6d0e1dSmrg	fi
104093f6d0e1dSmrg
10410c3c9db83Smrg	# Delete the generated files.
104112f60eb46Smrg	if test -f "$output_objdir/${outputname}S.$objext"; then
104122f60eb46Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
10413692f60a7Smrg	fi
10414692f60a7Smrg
10415c3c9db83Smrg	exit $exit_status
104162f60eb46Smrg      }
10417692f60a7Smrg
10418c3c9db83Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
10419c3c9db83Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
10420c3c9db83Smrg      fi
10421c3c9db83Smrg      if test -n "$finalize_shlibpath"; then
10422c3c9db83Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
10423c3c9db83Smrg      fi
104242e71ea71Smrg
10425c3c9db83Smrg      compile_var=
10426c3c9db83Smrg      finalize_var=
10427c3c9db83Smrg      if test -n "$runpath_var"; then
10428c3c9db83Smrg	if test -n "$perm_rpath"; then
10429c3c9db83Smrg	  # We should set the runpath_var.
10430c3c9db83Smrg	  rpath=
10431c3c9db83Smrg	  for dir in $perm_rpath; do
104323f6d0e1dSmrg	    func_append rpath "$dir:"
10433c3c9db83Smrg	  done
10434c3c9db83Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
10435692f60a7Smrg	fi
10436c3c9db83Smrg	if test -n "$finalize_perm_rpath"; then
10437c3c9db83Smrg	  # We should set the runpath_var.
10438c3c9db83Smrg	  rpath=
10439c3c9db83Smrg	  for dir in $finalize_perm_rpath; do
104403f6d0e1dSmrg	    func_append rpath "$dir:"
10441c3c9db83Smrg	  done
10442c3c9db83Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
10443692f60a7Smrg	fi
10444c3c9db83Smrg      fi
10445692f60a7Smrg
104462f60eb46Smrg      if test yes = "$no_install"; then
10447c3c9db83Smrg	# We don't need to create a wrapper script.
104482f60eb46Smrg	link_command=$compile_var$compile_command$compile_rpath
10449c3c9db83Smrg	# Replace the output file specification.
104503f6d0e1dSmrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10451c3c9db83Smrg	# Delete the old output file.
10452c3c9db83Smrg	$opt_dry_run || $RM $output
10453c3c9db83Smrg	# Link the executable and exit
10454c3c9db83Smrg	func_show_eval "$link_command" 'exit $?'
104553f6d0e1dSmrg
104563f6d0e1dSmrg	if test -n "$postlink_cmds"; then
104573f6d0e1dSmrg	  func_to_tool_file "$output"
104583f6d0e1dSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
104593f6d0e1dSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
104603f6d0e1dSmrg	fi
104613f6d0e1dSmrg
104622e71ea71Smrg	exit $EXIT_SUCCESS
10463c3c9db83Smrg      fi
1046485ee4c00Smrg
104652f60eb46Smrg      case $hardcode_action,$fast_install in
104662f60eb46Smrg        relink,*)
104672f60eb46Smrg	  # Fast installation is not supported
104682f60eb46Smrg	  link_command=$compile_var$compile_command$compile_rpath
104692f60eb46Smrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
10470c3c9db83Smrg
104712f60eb46Smrg	  func_warning "this platform does not like uninstalled shared libraries"
104722f60eb46Smrg	  func_warning "'$output' will be relinked during installation"
104732f60eb46Smrg	  ;;
104742f60eb46Smrg        *,yes)
104752f60eb46Smrg	  link_command=$finalize_var$compile_command$finalize_rpath
104762f60eb46Smrg	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
104772f60eb46Smrg          ;;
104782f60eb46Smrg	*,no)
104792f60eb46Smrg	  link_command=$compile_var$compile_command$compile_rpath
104802f60eb46Smrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
104812f60eb46Smrg          ;;
104822f60eb46Smrg	*,needless)
104832f60eb46Smrg	  link_command=$finalize_var$compile_command$finalize_rpath
104842f60eb46Smrg	  relink_command=
104852f60eb46Smrg          ;;
104862f60eb46Smrg      esac
10487692f60a7Smrg
10488c3c9db83Smrg      # Replace the output file specification.
104893f6d0e1dSmrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
10490692f60a7Smrg
10491c3c9db83Smrg      # Delete the old output files.
10492c3c9db83Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
10493692f60a7Smrg
10494c3c9db83Smrg      func_show_eval "$link_command" 'exit $?'
104952e71ea71Smrg
104963f6d0e1dSmrg      if test -n "$postlink_cmds"; then
104973f6d0e1dSmrg	func_to_tool_file "$output_objdir/$outputname"
104983f6d0e1dSmrg	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'`
104993f6d0e1dSmrg	func_execute_cmds "$postlink_cmds" 'exit $?'
105003f6d0e1dSmrg      fi
105013f6d0e1dSmrg
10502c3c9db83Smrg      # Now create the wrapper script.
10503c3c9db83Smrg      func_verbose "creating $output"
105042e71ea71Smrg
10505c3c9db83Smrg      # Quote the relink command for shipping.
10506c3c9db83Smrg      if test -n "$relink_command"; then
10507c3c9db83Smrg	# Preserve any variables that may affect compiler behavior
10508c3c9db83Smrg	for var in $variables_saved_for_relink; do
10509c3c9db83Smrg	  if eval test -z \"\${$var+set}\"; then
10510c3c9db83Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10511c3c9db83Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
10512c3c9db83Smrg	    relink_command="$var=; export $var; $relink_command"
10513692f60a7Smrg	  else
10514c3c9db83Smrg	    func_quote_for_eval "$var_value"
10515c3c9db83Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10516692f60a7Smrg	  fi
10517c3c9db83Smrg	done
10518c3c9db83Smrg	relink_command="(cd `pwd`; $relink_command)"
105193f6d0e1dSmrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10520c3c9db83Smrg      fi
10521c3c9db83Smrg
10522c3c9db83Smrg      # Only actually do things if not in dry run mode.
10523c3c9db83Smrg      $opt_dry_run || {
10524c3c9db83Smrg	# win32 will think the script is a binary if it has
10525c3c9db83Smrg	# a .exe suffix, so we strip it off here.
10526c3c9db83Smrg	case $output in
10527c3c9db83Smrg	  *.exe) func_stripname '' '.exe' "$output"
10528c3c9db83Smrg	         output=$func_stripname_result ;;
10529c3c9db83Smrg	esac
10530c3c9db83Smrg	# test for cygwin because mv fails w/o .exe extensions
10531c3c9db83Smrg	case $host in
10532c3c9db83Smrg	  *cygwin*)
10533c3c9db83Smrg	    exeext=.exe
10534c3c9db83Smrg	    func_stripname '' '.exe' "$outputname"
10535c3c9db83Smrg	    outputname=$func_stripname_result ;;
10536c3c9db83Smrg	  *) exeext= ;;
10537692f60a7Smrg	esac
10538c3c9db83Smrg	case $host in
10539c3c9db83Smrg	  *cygwin* | *mingw* )
10540c3c9db83Smrg	    func_dirname_and_basename "$output" "" "."
10541c3c9db83Smrg	    output_name=$func_basename_result
10542c3c9db83Smrg	    output_path=$func_dirname_result
105432f60eb46Smrg	    cwrappersource=$output_path/$objdir/lt-$output_name.c
105442f60eb46Smrg	    cwrapper=$output_path/$output_name.exe
10545c3c9db83Smrg	    $RM $cwrappersource $cwrapper
10546c3c9db83Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
10547c3c9db83Smrg
10548c3c9db83Smrg	    func_emit_cwrapperexe_src > $cwrappersource
10549c3c9db83Smrg
10550c3c9db83Smrg	    # The wrapper executable is built using the $host compiler,
10551c3c9db83Smrg	    # because it contains $host paths and files. If cross-
10552c3c9db83Smrg	    # compiling, it, like the target executable, must be
10553c3c9db83Smrg	    # executed on the $host or under an emulation environment.
10554c3c9db83Smrg	    $opt_dry_run || {
10555c3c9db83Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
10556c3c9db83Smrg	      $STRIP $cwrapper
10557c3c9db83Smrg	    }
10558692f60a7Smrg
10559c3c9db83Smrg	    # Now, create the wrapper script for func_source use:
10560c3c9db83Smrg	    func_ltwrapper_scriptname $cwrapper
10561c3c9db83Smrg	    $RM $func_ltwrapper_scriptname_result
10562c3c9db83Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
10563c3c9db83Smrg	    $opt_dry_run || {
10564c3c9db83Smrg	      # note: this script will not be executed, so do not chmod.
105652f60eb46Smrg	      if test "x$build" = "x$host"; then
10566c3c9db83Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
10567c3c9db83Smrg	      else
10568c3c9db83Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
10569c3c9db83Smrg	      fi
10570c3c9db83Smrg	    }
10571c3c9db83Smrg	  ;;
10572c3c9db83Smrg	  * )
10573c3c9db83Smrg	    $RM $output
10574c3c9db83Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
10575692f60a7Smrg
10576c3c9db83Smrg	    func_emit_wrapper no > $output
10577c3c9db83Smrg	    chmod +x $output
10578c3c9db83Smrg	  ;;
10579c3c9db83Smrg	esac
10580c3c9db83Smrg      }
10581c3c9db83Smrg      exit $EXIT_SUCCESS
10582c3c9db83Smrg      ;;
10583c3c9db83Smrg    esac
10584692f60a7Smrg
10585c3c9db83Smrg    # See if we need to build an old-fashioned archive.
10586c3c9db83Smrg    for oldlib in $oldlibs; do
10587692f60a7Smrg
105882f60eb46Smrg      case $build_libtool_libs in
105892f60eb46Smrg        convenience)
105902f60eb46Smrg	  oldobjs="$libobjs_save $symfileobj"
105912f60eb46Smrg	  addlibs=$convenience
10592c3c9db83Smrg	  build_libtool_libs=no
105932f60eb46Smrg	  ;;
105942f60eb46Smrg	module)
105952f60eb46Smrg	  oldobjs=$libobjs_save
105962f60eb46Smrg	  addlibs=$old_convenience
105972f60eb46Smrg	  build_libtool_libs=no
105982f60eb46Smrg          ;;
105992f60eb46Smrg	*)
10600c3c9db83Smrg	  oldobjs="$old_deplibs $non_pic_objects"
106012f60eb46Smrg	  $preload && test -f "$symfileobj" \
106022f60eb46Smrg	    && func_append oldobjs " $symfileobj"
106032f60eb46Smrg	  addlibs=$old_convenience
106042f60eb46Smrg	  ;;
106052f60eb46Smrg      esac
10606692f60a7Smrg
10607c3c9db83Smrg      if test -n "$addlibs"; then
106082f60eb46Smrg	gentop=$output_objdir/${outputname}x
106093f6d0e1dSmrg	func_append generated " $gentop"
10610692f60a7Smrg
10611c3c9db83Smrg	func_extract_archives $gentop $addlibs
106123f6d0e1dSmrg	func_append oldobjs " $func_extract_archives_result"
10613c3c9db83Smrg      fi
10614692f60a7Smrg
10615c3c9db83Smrg      # Do each command in the archive commands.
106162f60eb46Smrg      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
10617c3c9db83Smrg	cmds=$old_archive_from_new_cmds
10618c3c9db83Smrg      else
10619692f60a7Smrg
10620c3c9db83Smrg	# Add any objects from preloaded convenience libraries
10621c3c9db83Smrg	if test -n "$dlprefiles"; then
106222f60eb46Smrg	  gentop=$output_objdir/${outputname}x
106233f6d0e1dSmrg	  func_append generated " $gentop"
10624692f60a7Smrg
10625c3c9db83Smrg	  func_extract_archives $gentop $dlprefiles
106263f6d0e1dSmrg	  func_append oldobjs " $func_extract_archives_result"
10627c3c9db83Smrg	fi
10628692f60a7Smrg
10629c3c9db83Smrg	# POSIX demands no paths to be encoded in archives.  We have
10630c3c9db83Smrg	# to avoid creating archives with duplicate basenames if we
10631c3c9db83Smrg	# might have to extract them afterwards, e.g., when creating a
10632c3c9db83Smrg	# static archive out of a convenience library, or when linking
10633c3c9db83Smrg	# the entirety of a libtool archive into another (currently
10634c3c9db83Smrg	# not supported by libtool).
10635c3c9db83Smrg	if (for obj in $oldobjs
10636c3c9db83Smrg	    do
10637c3c9db83Smrg	      func_basename "$obj"
10638c3c9db83Smrg	      $ECHO "$func_basename_result"
10639c3c9db83Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
10640c3c9db83Smrg	  :
10641c3c9db83Smrg	else
106423f6d0e1dSmrg	  echo "copying selected object files to avoid basename conflicts..."
106432f60eb46Smrg	  gentop=$output_objdir/${outputname}x
106443f6d0e1dSmrg	  func_append generated " $gentop"
10645c3c9db83Smrg	  func_mkdir_p "$gentop"
10646c3c9db83Smrg	  save_oldobjs=$oldobjs
10647c3c9db83Smrg	  oldobjs=
10648c3c9db83Smrg	  counter=1
10649c3c9db83Smrg	  for obj in $save_oldobjs
10650c3c9db83Smrg	  do
10651c3c9db83Smrg	    func_basename "$obj"
106522f60eb46Smrg	    objbase=$func_basename_result
10653c3c9db83Smrg	    case " $oldobjs " in
10654c3c9db83Smrg	    " ") oldobjs=$obj ;;
10655c3c9db83Smrg	    *[\ /]"$objbase "*)
10656c3c9db83Smrg	      while :; do
10657c3c9db83Smrg		# Make sure we don't pick an alternate name that also
10658c3c9db83Smrg		# overlaps.
10659c3c9db83Smrg		newobj=lt$counter-$objbase
10660c3c9db83Smrg		func_arith $counter + 1
10661c3c9db83Smrg		counter=$func_arith_result
10662c3c9db83Smrg		case " $oldobjs " in
10663c3c9db83Smrg		*[\ /]"$newobj "*) ;;
10664c3c9db83Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
10665c3c9db83Smrg		esac
10666c3c9db83Smrg	      done
10667c3c9db83Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
106683f6d0e1dSmrg	      func_append oldobjs " $gentop/$newobj"
10669c3c9db83Smrg	      ;;
106703f6d0e1dSmrg	    *) func_append oldobjs " $obj" ;;
10671c3c9db83Smrg	    esac
10672692f60a7Smrg	  done
1067385ee4c00Smrg	fi
1067495903e71Smrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
1067595903e71Smrg	tool_oldlib=$func_to_tool_file_result
10676c3c9db83Smrg	eval cmds=\"$old_archive_cmds\"
106772e71ea71Smrg
10678c3c9db83Smrg	func_len " $cmds"
10679c3c9db83Smrg	len=$func_len_result
10680c3c9db83Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
10681c3c9db83Smrg	  cmds=$old_archive_cmds
106823f6d0e1dSmrg	elif test -n "$archiver_list_spec"; then
106833f6d0e1dSmrg	  func_verbose "using command file archive linking..."
106843f6d0e1dSmrg	  for obj in $oldobjs
106853f6d0e1dSmrg	  do
106863f6d0e1dSmrg	    func_to_tool_file "$obj"
106873f6d0e1dSmrg	    $ECHO "$func_to_tool_file_result"
106883f6d0e1dSmrg	  done > $output_objdir/$libname.libcmd
106893f6d0e1dSmrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
106903f6d0e1dSmrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
106913f6d0e1dSmrg	  cmds=$old_archive_cmds
10692c3c9db83Smrg	else
10693c3c9db83Smrg	  # the command line is too long to link in one step, link in parts
10694c3c9db83Smrg	  func_verbose "using piecewise archive linking..."
10695c3c9db83Smrg	  save_RANLIB=$RANLIB
10696c3c9db83Smrg	  RANLIB=:
10697c3c9db83Smrg	  objlist=
10698c3c9db83Smrg	  concat_cmds=
10699c3c9db83Smrg	  save_oldobjs=$oldobjs
10700c3c9db83Smrg	  oldobjs=
10701c3c9db83Smrg	  # Is there a better way of finding the last object in the list?
10702c3c9db83Smrg	  for obj in $save_oldobjs
10703c3c9db83Smrg	  do
10704c3c9db83Smrg	    last_oldobj=$obj
10705c3c9db83Smrg	  done
10706c3c9db83Smrg	  eval test_cmds=\"$old_archive_cmds\"
10707c3c9db83Smrg	  func_len " $test_cmds"
10708c3c9db83Smrg	  len0=$func_len_result
10709c3c9db83Smrg	  len=$len0
10710c3c9db83Smrg	  for obj in $save_oldobjs
10711c3c9db83Smrg	  do
10712c3c9db83Smrg	    func_len " $obj"
10713c3c9db83Smrg	    func_arith $len + $func_len_result
10714c3c9db83Smrg	    len=$func_arith_result
10715c3c9db83Smrg	    func_append objlist " $obj"
10716c3c9db83Smrg	    if test "$len" -lt "$max_cmd_len"; then
10717c3c9db83Smrg	      :
10718c3c9db83Smrg	    else
10719c3c9db83Smrg	      # the above command should be used before it gets too long
10720c3c9db83Smrg	      oldobjs=$objlist
107212f60eb46Smrg	      if test "$obj" = "$last_oldobj"; then
10722c3c9db83Smrg		RANLIB=$save_RANLIB
10723c3c9db83Smrg	      fi
10724c3c9db83Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
107252f60eb46Smrg	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
10726c3c9db83Smrg	      objlist=
10727c3c9db83Smrg	      len=$len0
10728c3c9db83Smrg	    fi
10729c3c9db83Smrg	  done
10730c3c9db83Smrg	  RANLIB=$save_RANLIB
10731c3c9db83Smrg	  oldobjs=$objlist
107322f60eb46Smrg	  if test -z "$oldobjs"; then
10733c3c9db83Smrg	    eval cmds=\"\$concat_cmds\"
10734c3c9db83Smrg	  else
10735c3c9db83Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
10736c3c9db83Smrg	  fi
10737c3c9db83Smrg	fi
10738c3c9db83Smrg      fi
10739c3c9db83Smrg      func_execute_cmds "$cmds" 'exit $?'
10740692f60a7Smrg    done
10741692f60a7Smrg
10742c3c9db83Smrg    test -n "$generated" && \
10743c3c9db83Smrg      func_show_eval "${RM}r$generated"
10744692f60a7Smrg
10745c3c9db83Smrg    # Now create the libtool archive.
10746c3c9db83Smrg    case $output in
10747c3c9db83Smrg    *.la)
10748c3c9db83Smrg      old_library=
107492f60eb46Smrg      test yes = "$build_old_libs" && old_library=$libname.$libext
10750c3c9db83Smrg      func_verbose "creating $output"
1075185ee4c00Smrg
10752c3c9db83Smrg      # Preserve any variables that may affect compiler behavior
10753c3c9db83Smrg      for var in $variables_saved_for_relink; do
10754c3c9db83Smrg	if eval test -z \"\${$var+set}\"; then
10755c3c9db83Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10756c3c9db83Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
10757c3c9db83Smrg	  relink_command="$var=; export $var; $relink_command"
107582e71ea71Smrg	else
10759c3c9db83Smrg	  func_quote_for_eval "$var_value"
10760c3c9db83Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
107612e71ea71Smrg	fi
10762c3c9db83Smrg      done
10763c3c9db83Smrg      # Quote the link command for shipping.
107642f60eb46Smrg      relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
107653f6d0e1dSmrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
107662f60eb46Smrg      if test yes = "$hardcode_automatic"; then
10767c3c9db83Smrg	relink_command=
10768c3c9db83Smrg      fi
10769692f60a7Smrg
10770c3c9db83Smrg      # Only create the output if not a dry run.
10771c3c9db83Smrg      $opt_dry_run || {
10772c3c9db83Smrg	for installed in no yes; do
107732f60eb46Smrg	  if test yes = "$installed"; then
10774c3c9db83Smrg	    if test -z "$install_libdir"; then
10775c3c9db83Smrg	      break
10776c3c9db83Smrg	    fi
107772f60eb46Smrg	    output=$output_objdir/${outputname}i
10778c3c9db83Smrg	    # Replace all uninstalled libtool libraries with the installed ones
10779c3c9db83Smrg	    newdependency_libs=
10780c3c9db83Smrg	    for deplib in $dependency_libs; do
10781c3c9db83Smrg	      case $deplib in
10782c3c9db83Smrg	      *.la)
10783c3c9db83Smrg		func_basename "$deplib"
107842f60eb46Smrg		name=$func_basename_result
1078595903e71Smrg		func_resolve_sysroot "$deplib"
107862f60eb46Smrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
10787c3c9db83Smrg		test -z "$libdir" && \
107882f60eb46Smrg		  func_fatal_error "'$deplib' is not a valid libtool archive"
107893f6d0e1dSmrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
107903f6d0e1dSmrg		;;
107913f6d0e1dSmrg	      -L*)
107923f6d0e1dSmrg		func_stripname -L '' "$deplib"
107933f6d0e1dSmrg		func_replace_sysroot "$func_stripname_result"
107943f6d0e1dSmrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
10795c3c9db83Smrg		;;
107963f6d0e1dSmrg	      -R*)
107973f6d0e1dSmrg		func_stripname -R '' "$deplib"
107983f6d0e1dSmrg		func_replace_sysroot "$func_stripname_result"
107993f6d0e1dSmrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
108003f6d0e1dSmrg		;;
108013f6d0e1dSmrg	      *) func_append newdependency_libs " $deplib" ;;
10802c3c9db83Smrg	      esac
10803c3c9db83Smrg	    done
108042f60eb46Smrg	    dependency_libs=$newdependency_libs
10805c3c9db83Smrg	    newdlfiles=
10806c3c9db83Smrg
10807c3c9db83Smrg	    for lib in $dlfiles; do
10808c3c9db83Smrg	      case $lib in
10809c3c9db83Smrg	      *.la)
10810c3c9db83Smrg	        func_basename "$lib"
108112f60eb46Smrg		name=$func_basename_result
108122f60eb46Smrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10813c3c9db83Smrg		test -z "$libdir" && \
108142f60eb46Smrg		  func_fatal_error "'$lib' is not a valid libtool archive"
108153f6d0e1dSmrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
10816c3c9db83Smrg		;;
108173f6d0e1dSmrg	      *) func_append newdlfiles " $lib" ;;
10818c3c9db83Smrg	      esac
10819c3c9db83Smrg	    done
108202f60eb46Smrg	    dlfiles=$newdlfiles
10821c3c9db83Smrg	    newdlprefiles=
10822c3c9db83Smrg	    for lib in $dlprefiles; do
10823c3c9db83Smrg	      case $lib in
10824c3c9db83Smrg	      *.la)
10825c3c9db83Smrg		# Only pass preopened files to the pseudo-archive (for
10826c3c9db83Smrg		# eventual linking with the app. that links it) if we
10827c3c9db83Smrg		# didn't already link the preopened objects directly into
10828c3c9db83Smrg		# the library:
10829c3c9db83Smrg		func_basename "$lib"
108302f60eb46Smrg		name=$func_basename_result
108312f60eb46Smrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10832c3c9db83Smrg		test -z "$libdir" && \
108332f60eb46Smrg		  func_fatal_error "'$lib' is not a valid libtool archive"
108343f6d0e1dSmrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
10835c3c9db83Smrg		;;
10836c3c9db83Smrg	      esac
10837c3c9db83Smrg	    done
108382f60eb46Smrg	    dlprefiles=$newdlprefiles
10839c3c9db83Smrg	  else
10840c3c9db83Smrg	    newdlfiles=
10841c3c9db83Smrg	    for lib in $dlfiles; do
10842c3c9db83Smrg	      case $lib in
108432f60eb46Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10844c3c9db83Smrg		*) abs=`pwd`"/$lib" ;;
10845c3c9db83Smrg	      esac
108463f6d0e1dSmrg	      func_append newdlfiles " $abs"
10847c3c9db83Smrg	    done
108482f60eb46Smrg	    dlfiles=$newdlfiles
10849c3c9db83Smrg	    newdlprefiles=
10850c3c9db83Smrg	    for lib in $dlprefiles; do
10851c3c9db83Smrg	      case $lib in
108522f60eb46Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10853c3c9db83Smrg		*) abs=`pwd`"/$lib" ;;
10854c3c9db83Smrg	      esac
108553f6d0e1dSmrg	      func_append newdlprefiles " $abs"
10856c3c9db83Smrg	    done
108572f60eb46Smrg	    dlprefiles=$newdlprefiles
10858c3c9db83Smrg	  fi
10859c3c9db83Smrg	  $RM $output
10860c3c9db83Smrg	  # place dlname in correct position for cygwin
108613f6d0e1dSmrg	  # In fact, it would be nice if we could use this code for all target
108623f6d0e1dSmrg	  # systems that can't hard-code library paths into their executables
108633f6d0e1dSmrg	  # and that have no shared library path variable independent of PATH,
108643f6d0e1dSmrg	  # but it turns out we can't easily determine that from inspecting
108653f6d0e1dSmrg	  # libtool variables, so we have to hard-code the OSs to which it
108663f6d0e1dSmrg	  # applies here; at the moment, that means platforms that use the PE
108673f6d0e1dSmrg	  # object format with DLL files.  See the long comment at the top of
108683f6d0e1dSmrg	  # tests/bindir.at for full details.
10869c3c9db83Smrg	  tdlname=$dlname
10870c3c9db83Smrg	  case $host,$output,$installed,$module,$dlname in
108713f6d0e1dSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
108723f6d0e1dSmrg	      # If a -bindir argument was supplied, place the dll there.
108732f60eb46Smrg	      if test -n "$bindir"; then
108743f6d0e1dSmrg		func_relative_path "$install_libdir" "$bindir"
108752f60eb46Smrg		tdlname=$func_relative_path_result/$dlname
108763f6d0e1dSmrg	      else
108773f6d0e1dSmrg		# Otherwise fall back on heuristic.
108783f6d0e1dSmrg		tdlname=../bin/$dlname
108793f6d0e1dSmrg	      fi
108803f6d0e1dSmrg	      ;;
10881c3c9db83Smrg	  esac
10882c3c9db83Smrg	  $ECHO > $output "\
10883c3c9db83Smrg# $outputname - a libtool library file
108842f60eb46Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
10885c3c9db83Smrg#
10886c3c9db83Smrg# Please DO NOT delete this file!
10887c3c9db83Smrg# It is necessary for linking the library.
10888692f60a7Smrg
10889c3c9db83Smrg# The name that we can dlopen(3).
10890c3c9db83Smrgdlname='$tdlname'
10891692f60a7Smrg
10892c3c9db83Smrg# Names of this library.
10893c3c9db83Smrglibrary_names='$library_names'
10894692f60a7Smrg
10895c3c9db83Smrg# The name of the static archive.
10896c3c9db83Smrgold_library='$old_library'
10897692f60a7Smrg
108982f60eb46Smrg# Linker flags that cannot go in dependency_libs.
10899c3c9db83Smrginherited_linker_flags='$new_inherited_linker_flags'
10900692f60a7Smrg
10901c3c9db83Smrg# Libraries that this one depends upon.
10902c3c9db83Smrgdependency_libs='$dependency_libs'
10903692f60a7Smrg
10904c3c9db83Smrg# Names of additional weak libraries provided by this library
10905c3c9db83Smrgweak_library_names='$weak_libs'
10906692f60a7Smrg
10907c3c9db83Smrg# Version information for $libname.
10908c3c9db83Smrgcurrent=$current
10909c3c9db83Smrgage=$age
10910c3c9db83Smrgrevision=$revision
10911692f60a7Smrg
10912c3c9db83Smrg# Is this an already installed library?
10913c3c9db83Smrginstalled=$installed
10914692f60a7Smrg
10915c3c9db83Smrg# Should we warn about portability when linking against -modules?
10916c3c9db83Smrgshouldnotlink=$module
10917692f60a7Smrg
10918c3c9db83Smrg# Files to dlopen/dlpreopen
10919c3c9db83Smrgdlopen='$dlfiles'
10920c3c9db83Smrgdlpreopen='$dlprefiles'
10921692f60a7Smrg
10922c3c9db83Smrg# Directory that this library needs to be installed in:
10923c3c9db83Smrglibdir='$install_libdir'"
109242f60eb46Smrg	  if test no,yes = "$installed,$need_relink"; then
10925c3c9db83Smrg	    $ECHO >> $output "\
10926c3c9db83Smrgrelink_command=\"$relink_command\""
10927c3c9db83Smrg	  fi
10928c3c9db83Smrg	done
10929c3c9db83Smrg      }
10930692f60a7Smrg
10931c3c9db83Smrg      # Do a symbolic link so that the libtool archive can be found in
10932c3c9db83Smrg      # LD_LIBRARY_PATH before the program is installed.
10933c3c9db83Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
10934c3c9db83Smrg      ;;
10935c3c9db83Smrg    esac
10936c3c9db83Smrg    exit $EXIT_SUCCESS
10937c3c9db83Smrg}
109382e71ea71Smrg
109392f60eb46Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then
109402f60eb46Smrg  func_mode_link ${1+"$@"}
109412f60eb46Smrgfi
10942692f60a7Smrg
10943692f60a7Smrg
10944c3c9db83Smrg# func_mode_uninstall arg...
10945c3c9db83Smrgfunc_mode_uninstall ()
10946c3c9db83Smrg{
109472f60eb46Smrg    $debug_cmd
109482f60eb46Smrg
109492f60eb46Smrg    RM=$nonopt
10950692f60a7Smrg    files=
109512f60eb46Smrg    rmforce=false
10952692f60a7Smrg    exit_status=0
10953692f60a7Smrg
10954692f60a7Smrg    # This variable tells wrapper scripts just to set variables rather
10955692f60a7Smrg    # than running their programs.
109562f60eb46Smrg    libtool_install_magic=$magic
10957692f60a7Smrg
10958692f60a7Smrg    for arg
10959692f60a7Smrg    do
10960692f60a7Smrg      case $arg in
109612f60eb46Smrg      -f) func_append RM " $arg"; rmforce=: ;;
109623f6d0e1dSmrg      -*) func_append RM " $arg" ;;
109633f6d0e1dSmrg      *) func_append files " $arg" ;;
10964692f60a7Smrg      esac
10965692f60a7Smrg    done
10966692f60a7Smrg
10967c3c9db83Smrg    test -z "$RM" && \
10968c3c9db83Smrg      func_fatal_help "you must specify an RM program"
10969692f60a7Smrg
10970692f60a7Smrg    rmdirs=
10971692f60a7Smrg
10972692f60a7Smrg    for file in $files; do
10973c3c9db83Smrg      func_dirname "$file" "" "."
109742f60eb46Smrg      dir=$func_dirname_result
109752f60eb46Smrg      if test . = "$dir"; then
109762f60eb46Smrg	odir=$objdir
10977692f60a7Smrg      else
109782f60eb46Smrg	odir=$dir/$objdir
10979692f60a7Smrg      fi
10980c3c9db83Smrg      func_basename "$file"
109812f60eb46Smrg      name=$func_basename_result
109822f60eb46Smrg      test uninstall = "$opt_mode" && odir=$dir
10983692f60a7Smrg
109843f6d0e1dSmrg      # Remember odir for removal later, being careful to avoid duplicates
109852f60eb46Smrg      if test clean = "$opt_mode"; then
10986692f60a7Smrg	case " $rmdirs " in
109873f6d0e1dSmrg	  *" $odir "*) ;;
109883f6d0e1dSmrg	  *) func_append rmdirs " $odir" ;;
10989692f60a7Smrg	esac
10990692f60a7Smrg      fi
10991692f60a7Smrg
10992692f60a7Smrg      # Don't error if the file doesn't exist and rm -f was used.
10993c3c9db83Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
10994c3c9db83Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
10995c3c9db83Smrg	 test -f "$file"; then
10996692f60a7Smrg	:
10997692f60a7Smrg      elif test -d "$file"; then
10998692f60a7Smrg	exit_status=1
10999692f60a7Smrg	continue
110002f60eb46Smrg      elif $rmforce; then
11001692f60a7Smrg	continue
11002692f60a7Smrg      fi
11003692f60a7Smrg
110042f60eb46Smrg      rmfiles=$file
11005692f60a7Smrg
11006692f60a7Smrg      case $name in
11007692f60a7Smrg      *.la)
11008692f60a7Smrg	# Possibly a libtool archive, so verify it.
11009c3c9db83Smrg	if func_lalib_p "$file"; then
11010c3c9db83Smrg	  func_source $dir/$name
11011692f60a7Smrg
11012692f60a7Smrg	  # Delete the libtool libraries and symlinks.
11013692f60a7Smrg	  for n in $library_names; do
110143f6d0e1dSmrg	    func_append rmfiles " $odir/$n"
11015692f60a7Smrg	  done
110163f6d0e1dSmrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
11017692f60a7Smrg
110182f60eb46Smrg	  case $opt_mode in
11019692f60a7Smrg	  clean)
110203f6d0e1dSmrg	    case " $library_names " in
11021692f60a7Smrg	    *" $dlname "*) ;;
110223f6d0e1dSmrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
11023692f60a7Smrg	    esac
110243f6d0e1dSmrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
11025692f60a7Smrg	    ;;
11026692f60a7Smrg	  uninstall)
11027692f60a7Smrg	    if test -n "$library_names"; then
11028692f60a7Smrg	      # Do each command in the postuninstall commands.
110292f60eb46Smrg	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
11030692f60a7Smrg	    fi
11031692f60a7Smrg
11032692f60a7Smrg	    if test -n "$old_library"; then
11033692f60a7Smrg	      # Do each command in the old_postuninstall commands.
110342f60eb46Smrg	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
11035692f60a7Smrg	    fi
11036692f60a7Smrg	    # FIXME: should reinstall the best remaining shared library.
11037692f60a7Smrg	    ;;
11038692f60a7Smrg	  esac
11039692f60a7Smrg	fi
11040692f60a7Smrg	;;
11041692f60a7Smrg
11042692f60a7Smrg      *.lo)
11043692f60a7Smrg	# Possibly a libtool object, so verify it.
11044c3c9db83Smrg	if func_lalib_p "$file"; then
11045692f60a7Smrg
11046692f60a7Smrg	  # Read the .lo file
11047c3c9db83Smrg	  func_source $dir/$name
11048692f60a7Smrg
11049692f60a7Smrg	  # Add PIC object to the list of files to remove.
110502f60eb46Smrg	  if test -n "$pic_object" && test none != "$pic_object"; then
110513f6d0e1dSmrg	    func_append rmfiles " $dir/$pic_object"
11052692f60a7Smrg	  fi
11053692f60a7Smrg
11054692f60a7Smrg	  # Add non-PIC object to the list of files to remove.
110552f60eb46Smrg	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
110563f6d0e1dSmrg	    func_append rmfiles " $dir/$non_pic_object"
11057692f60a7Smrg	  fi
11058692f60a7Smrg	fi
11059692f60a7Smrg	;;
11060692f60a7Smrg
11061692f60a7Smrg      *)
110622f60eb46Smrg	if test clean = "$opt_mode"; then
11063692f60a7Smrg	  noexename=$name
11064692f60a7Smrg	  case $file in
11065692f60a7Smrg	  *.exe)
11066c3c9db83Smrg	    func_stripname '' '.exe' "$file"
11067c3c9db83Smrg	    file=$func_stripname_result
11068c3c9db83Smrg	    func_stripname '' '.exe' "$name"
11069c3c9db83Smrg	    noexename=$func_stripname_result
11070692f60a7Smrg	    # $file with .exe has already been added to rmfiles,
11071692f60a7Smrg	    # add $file without .exe
110723f6d0e1dSmrg	    func_append rmfiles " $file"
11073692f60a7Smrg	    ;;
11074692f60a7Smrg	  esac
11075692f60a7Smrg	  # Do a test to see if this is a libtool program.
11076c3c9db83Smrg	  if func_ltwrapper_p "$file"; then
11077c3c9db83Smrg	    if func_ltwrapper_executable_p "$file"; then
11078c3c9db83Smrg	      func_ltwrapper_scriptname "$file"
11079c3c9db83Smrg	      relink_command=
11080c3c9db83Smrg	      func_source $func_ltwrapper_scriptname_result
110813f6d0e1dSmrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
11082c3c9db83Smrg	    else
11083c3c9db83Smrg	      relink_command=
11084c3c9db83Smrg	      func_source $dir/$noexename
11085c3c9db83Smrg	    fi
11086692f60a7Smrg
11087692f60a7Smrg	    # note $name still contains .exe if it was in $file originally
11088692f60a7Smrg	    # as does the version of $file that was added into $rmfiles
110892f60eb46Smrg	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
110902f60eb46Smrg	    if test yes = "$fast_install" && test -n "$relink_command"; then
110913f6d0e1dSmrg	      func_append rmfiles " $odir/lt-$name"
11092692f60a7Smrg	    fi
110932f60eb46Smrg	    if test "X$noexename" != "X$name"; then
110942f60eb46Smrg	      func_append rmfiles " $odir/lt-$noexename.c"
11095692f60a7Smrg	    fi
11096692f60a7Smrg	  fi
11097692f60a7Smrg	fi
11098692f60a7Smrg	;;
11099692f60a7Smrg      esac
11100c3c9db83Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
11101692f60a7Smrg    done
11102692f60a7Smrg
111032f60eb46Smrg    # Try to remove the $objdir's in the directories where we deleted files
11104692f60a7Smrg    for dir in $rmdirs; do
11105692f60a7Smrg      if test -d "$dir"; then
11106c3c9db83Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
11107692f60a7Smrg      fi
11108692f60a7Smrg    done
11109692f60a7Smrg
11110692f60a7Smrg    exit $exit_status
11111c3c9db83Smrg}
11112692f60a7Smrg
111132f60eb46Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
111142f60eb46Smrg  func_mode_uninstall ${1+"$@"}
111152f60eb46Smrgfi
1111685ee4c00Smrg
111173f6d0e1dSmrgtest -z "$opt_mode" && {
111182f60eb46Smrg  help=$generic_help
11119c3c9db83Smrg  func_fatal_help "you must specify a MODE"
11120c3c9db83Smrg}
11121c3c9db83Smrg
11122c3c9db83Smrgtest -z "$exec_cmd" && \
111232f60eb46Smrg  func_fatal_help "invalid operation mode '$opt_mode'"
11124692f60a7Smrg
11125692f60a7Smrgif test -n "$exec_cmd"; then
11126c3c9db83Smrg  eval exec "$exec_cmd"
11127692f60a7Smrg  exit $EXIT_FAILURE
11128692f60a7Smrgfi
11129692f60a7Smrg
11130c3c9db83Smrgexit $exit_status
11131692f60a7Smrg
11132692f60a7Smrg
11133692f60a7Smrg# The TAGs below are defined such that we never get into a situation
111342f60eb46Smrg# where we disable both kinds of libraries.  Given conflicting
11135692f60a7Smrg# choices, we go for a static library, that is the most portable,
11136692f60a7Smrg# since we can't tell whether shared libraries were disabled because
11137692f60a7Smrg# the user asked for that or because the platform doesn't support
11138692f60a7Smrg# them.  This is particularly important on AIX, because we don't
11139692f60a7Smrg# support having both static and shared libraries enabled at the same
11140692f60a7Smrg# time on that platform, so we default to a shared-only configuration.
11141692f60a7Smrg# If a disable-shared tag is given, we'll fallback to a static-only
11142692f60a7Smrg# configuration.  But we'll never go from static-only to shared-only.
11143692f60a7Smrg
11144692f60a7Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
11145c3c9db83Smrgbuild_libtool_libs=no
11146c3c9db83Smrgbuild_old_libs=yes
11147692f60a7Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
11148692f60a7Smrg
11149692f60a7Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
11150c3c9db83Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
11151692f60a7Smrg# ### END LIBTOOL TAG CONFIG: disable-static
11152692f60a7Smrg
11153692f60a7Smrg# Local Variables:
11154692f60a7Smrg# mode:shell-script
11155692f60a7Smrg# sh-indentation:2
11156692f60a7Smrg# End:
11157