ltmain.sh revision 4a8d91dc
14a8d91dcSmrg#! /bin/sh
24a8d91dcSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
34a8d91dcSmrg##               by inline-source v2014-01-03.01
4b3e38ee4Smrg
54a8d91dcSmrg# libtool (GNU libtool) 2.4.6
64a8d91dcSmrg# Provide generalized library-building support services.
7b3e38ee4Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
8b3e38ee4Smrg
94a8d91dcSmrg# Copyright (C) 1996-2015 Free Software Foundation, Inc.
10b3e38ee4Smrg# This is free software; see the source for copying conditions.  There is NO
11b3e38ee4Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12b3e38ee4Smrg
13b3e38ee4Smrg# GNU Libtool is free software; you can redistribute it and/or modify
1450806d53Smrg# it under the terms of the GNU General Public License as published by
1550806d53Smrg# the Free Software Foundation; either version 2 of the License, or
1650806d53Smrg# (at your option) any later version.
1750806d53Smrg#
18b3e38ee4Smrg# As a special exception to the GNU General Public License,
19b3e38ee4Smrg# if you distribute this file as part of a program or library that
20b3e38ee4Smrg# is built using GNU Libtool, you may include this file under the
21b3e38ee4Smrg# same distribution terms that you use for the rest of that program.
22b3e38ee4Smrg#
23b3e38ee4Smrg# GNU Libtool is distributed in the hope that it will be useful, but
2450806d53Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
2550806d53Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2650806d53Smrg# General Public License for more details.
2750806d53Smrg#
2850806d53Smrg# You should have received a copy of the GNU General Public License
294a8d91dcSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
30a18ebfb2Smrg
3150806d53Smrg
32a73423d7SmrgPROGRAM=libtool
3350806d53SmrgPACKAGE=libtool
344a8d91dcSmrgVERSION="2.4.6 Debian-2.4.6-0.1"
354a8d91dcSmrgpackage_revision=2.4.6
3650806d53Smrg
374a8d91dcSmrg
384a8d91dcSmrg## ------ ##
394a8d91dcSmrg## Usage. ##
404a8d91dcSmrg## ------ ##
414a8d91dcSmrg
424a8d91dcSmrg# Run './libtool --help' for help with using this script from the
434a8d91dcSmrg# command line.
444a8d91dcSmrg
454a8d91dcSmrg
464a8d91dcSmrg## ------------------------------- ##
474a8d91dcSmrg## User overridable command paths. ##
484a8d91dcSmrg## ------------------------------- ##
494a8d91dcSmrg
504a8d91dcSmrg# After configure completes, it has a better idea of some of the
514a8d91dcSmrg# shell tools we need than the defaults used by the functions shared
524a8d91dcSmrg# with bootstrap, so set those here where they can still be over-
534a8d91dcSmrg# ridden by the user, but otherwise take precedence.
544a8d91dcSmrg
554a8d91dcSmrg: ${AUTOCONF="autoconf"}
564a8d91dcSmrg: ${AUTOMAKE="automake"}
574a8d91dcSmrg
584a8d91dcSmrg
594a8d91dcSmrg## -------------------------- ##
604a8d91dcSmrg## Source external libraries. ##
614a8d91dcSmrg## -------------------------- ##
624a8d91dcSmrg
634a8d91dcSmrg# Much of our low-level functionality needs to be sourced from external
644a8d91dcSmrg# libraries, which are installed to $pkgauxdir.
654a8d91dcSmrg
664a8d91dcSmrg# Set a version string for this script.
674a8d91dcSmrgscriptversion=2015-01-20.17; # UTC
684a8d91dcSmrg
694a8d91dcSmrg# General shell script boiler plate, and helper functions.
704a8d91dcSmrg# Written by Gary V. Vaughan, 2004
714a8d91dcSmrg
724a8d91dcSmrg# Copyright (C) 2004-2015 Free Software Foundation, Inc.
734a8d91dcSmrg# This is free software; see the source for copying conditions.  There is NO
744a8d91dcSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
754a8d91dcSmrg
764a8d91dcSmrg# This program is free software; you can redistribute it and/or modify
774a8d91dcSmrg# it under the terms of the GNU General Public License as published by
784a8d91dcSmrg# the Free Software Foundation; either version 3 of the License, or
794a8d91dcSmrg# (at your option) any later version.
804a8d91dcSmrg
814a8d91dcSmrg# As a special exception to the GNU General Public License, if you distribute
824a8d91dcSmrg# this file as part of a program or library that is built using GNU Libtool,
834a8d91dcSmrg# you may include this file under the same distribution terms that you use
844a8d91dcSmrg# for the rest of that program.
854a8d91dcSmrg
864a8d91dcSmrg# This program is distributed in the hope that it will be useful,
874a8d91dcSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
884a8d91dcSmrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
894a8d91dcSmrg# General Public License for more details.
904a8d91dcSmrg
914a8d91dcSmrg# You should have received a copy of the GNU General Public License
924a8d91dcSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>.
934a8d91dcSmrg
944a8d91dcSmrg# Please report bugs or propose patches to gary@gnu.org.
954a8d91dcSmrg
964a8d91dcSmrg
974a8d91dcSmrg## ------ ##
984a8d91dcSmrg## Usage. ##
994a8d91dcSmrg## ------ ##
1004a8d91dcSmrg
1014a8d91dcSmrg# Evaluate this file near the top of your script to gain access to
1024a8d91dcSmrg# the functions and variables defined here:
1034a8d91dcSmrg#
1044a8d91dcSmrg#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
1054a8d91dcSmrg#
1064a8d91dcSmrg# If you need to override any of the default environment variable
1074a8d91dcSmrg# settings, do that before evaluating this file.
1084a8d91dcSmrg
1094a8d91dcSmrg
1104a8d91dcSmrg## -------------------- ##
1114a8d91dcSmrg## Shell normalisation. ##
1124a8d91dcSmrg## -------------------- ##
1134a8d91dcSmrg
1144a8d91dcSmrg# Some shells need a little help to be as Bourne compatible as possible.
1154a8d91dcSmrg# Before doing anything else, make sure all that help has been provided!
1164a8d91dcSmrg
1174a8d91dcSmrgDUALCASE=1; export DUALCASE # for MKS sh
1184a8d91dcSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
11950806d53Smrg  emulate sh
12050806d53Smrg  NULLCMD=:
1214a8d91dcSmrg  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
12250806d53Smrg  # is contrary to our usage.  Disable this feature.
12350806d53Smrg  alias -g '${1+"$@"}'='"$@"'
12450806d53Smrg  setopt NO_GLOB_SUBST
12550806d53Smrgelse
1264a8d91dcSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
12750806d53Smrgfi
128a73423d7Smrg
1294a8d91dcSmrg# NLS nuisances: We save the old values in case they are required later.
1304a8d91dcSmrg_G_user_locale=
1314a8d91dcSmrg_G_safe_locale=
1324a8d91dcSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
13350806d53Smrgdo
1344a8d91dcSmrg  eval "if test set = \"\${$_G_var+set}\"; then
1354a8d91dcSmrg          save_$_G_var=\$$_G_var
1364a8d91dcSmrg          $_G_var=C
1374a8d91dcSmrg	  export $_G_var
1384a8d91dcSmrg	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
1394a8d91dcSmrg	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
1407965d9acSmrg	fi"
14150806d53Smrgdone
14250806d53Smrg
1434a8d91dcSmrg# CDPATH.
1444a8d91dcSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
145b3e38ee4Smrg
1464a8d91dcSmrg# Make sure IFS has a sensible default
1474a8d91dcSmrgsp=' '
1484a8d91dcSmrgnl='
1494a8d91dcSmrg'
1504a8d91dcSmrgIFS="$sp	$nl"
1514a8d91dcSmrg
1524a8d91dcSmrg# There are apparently some retarded systems that use ';' as a PATH separator!
1534a8d91dcSmrgif test "${PATH_SEPARATOR+set}" != set; then
1544a8d91dcSmrg  PATH_SEPARATOR=:
1554a8d91dcSmrg  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
1564a8d91dcSmrg    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
1574a8d91dcSmrg      PATH_SEPARATOR=';'
1584a8d91dcSmrg  }
1594a8d91dcSmrgfi
160b3e38ee4Smrg
161b3e38ee4Smrg
162b3e38ee4Smrg
1634a8d91dcSmrg## ------------------------- ##
1644a8d91dcSmrg## Locate command utilities. ##
1654a8d91dcSmrg## ------------------------- ##
1664a8d91dcSmrg
1674a8d91dcSmrg
1684a8d91dcSmrg# func_executable_p FILE
1694a8d91dcSmrg# ----------------------
1704a8d91dcSmrg# Check that FILE is an executable regular file.
1714a8d91dcSmrgfunc_executable_p ()
1724a8d91dcSmrg{
1734a8d91dcSmrg    test -f "$1" && test -x "$1"
1744a8d91dcSmrg}
1754a8d91dcSmrg
1764a8d91dcSmrg
1774a8d91dcSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
1784a8d91dcSmrg# --------------------------------------------
1794a8d91dcSmrg# Search for either a program that responds to --version with output
1804a8d91dcSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by
1814a8d91dcSmrg# trying all the directories in PATH with each of the elements of
1824a8d91dcSmrg# PROGS_LIST.
1834a8d91dcSmrg#
1844a8d91dcSmrg# CHECK_FUNC should accept the path to a candidate program, and
1854a8d91dcSmrg# set $func_check_prog_result if it truncates its output less than
1864a8d91dcSmrg# $_G_path_prog_max characters.
1874a8d91dcSmrgfunc_path_progs ()
1884a8d91dcSmrg{
1894a8d91dcSmrg    _G_progs_list=$1
1904a8d91dcSmrg    _G_check_func=$2
1914a8d91dcSmrg    _G_PATH=${3-"$PATH"}
1924a8d91dcSmrg
1934a8d91dcSmrg    _G_path_prog_max=0
1944a8d91dcSmrg    _G_path_prog_found=false
1954a8d91dcSmrg    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
1964a8d91dcSmrg    for _G_dir in $_G_PATH; do
1974a8d91dcSmrg      IFS=$_G_save_IFS
1984a8d91dcSmrg      test -z "$_G_dir" && _G_dir=.
1994a8d91dcSmrg      for _G_prog_name in $_G_progs_list; do
2004a8d91dcSmrg        for _exeext in '' .EXE; do
2014a8d91dcSmrg          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
2024a8d91dcSmrg          func_executable_p "$_G_path_prog" || continue
2034a8d91dcSmrg          case `"$_G_path_prog" --version 2>&1` in
2044a8d91dcSmrg            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
2054a8d91dcSmrg            *)     $_G_check_func $_G_path_prog
2064a8d91dcSmrg		   func_path_progs_result=$func_check_prog_result
2074a8d91dcSmrg		   ;;
2084a8d91dcSmrg          esac
2094a8d91dcSmrg          $_G_path_prog_found && break 3
2104a8d91dcSmrg        done
2114a8d91dcSmrg      done
2124a8d91dcSmrg    done
2134a8d91dcSmrg    IFS=$_G_save_IFS
2144a8d91dcSmrg    test -z "$func_path_progs_result" && {
2154a8d91dcSmrg      echo "no acceptable sed could be found in \$PATH" >&2
2164a8d91dcSmrg      exit 1
2174a8d91dcSmrg    }
2184a8d91dcSmrg}
2194a8d91dcSmrg
2204a8d91dcSmrg
2214a8d91dcSmrg# We want to be able to use the functions in this file before configure
2224a8d91dcSmrg# has figured out where the best binaries are kept, which means we have
2234a8d91dcSmrg# to search for them ourselves - except when the results are already set
2244a8d91dcSmrg# where we skip the searches.
2254a8d91dcSmrg
2264a8d91dcSmrg# Unless the user overrides by setting SED, search the path for either GNU
2274a8d91dcSmrg# sed, or the sed that truncates its output the least.
2284a8d91dcSmrgtest -z "$SED" && {
2294a8d91dcSmrg  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
2304a8d91dcSmrg  for _G_i in 1 2 3 4 5 6 7; do
2314a8d91dcSmrg    _G_sed_script=$_G_sed_script$nl$_G_sed_script
2324a8d91dcSmrg  done
2334a8d91dcSmrg  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
2344a8d91dcSmrg  _G_sed_script=
2354a8d91dcSmrg
2364a8d91dcSmrg  func_check_prog_sed ()
2374a8d91dcSmrg  {
2384a8d91dcSmrg    _G_path_prog=$1
2394a8d91dcSmrg
2404a8d91dcSmrg    _G_count=0
2414a8d91dcSmrg    printf 0123456789 >conftest.in
2424a8d91dcSmrg    while :
2434a8d91dcSmrg    do
2444a8d91dcSmrg      cat conftest.in conftest.in >conftest.tmp
2454a8d91dcSmrg      mv conftest.tmp conftest.in
2464a8d91dcSmrg      cp conftest.in conftest.nl
2474a8d91dcSmrg      echo '' >> conftest.nl
2484a8d91dcSmrg      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
2494a8d91dcSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
2504a8d91dcSmrg      _G_count=`expr $_G_count + 1`
2514a8d91dcSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
2524a8d91dcSmrg        # Best one so far, save it but keep looking for a better one
2534a8d91dcSmrg        func_check_prog_result=$_G_path_prog
2544a8d91dcSmrg        _G_path_prog_max=$_G_count
2554a8d91dcSmrg      fi
2564a8d91dcSmrg      # 10*(2^10) chars as input seems more than enough
2574a8d91dcSmrg      test 10 -lt "$_G_count" && break
2584a8d91dcSmrg    done
2594a8d91dcSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
2604a8d91dcSmrg  }
2614a8d91dcSmrg
2624a8d91dcSmrg  func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
2634a8d91dcSmrg  rm -f conftest.sed
2644a8d91dcSmrg  SED=$func_path_progs_result
2654a8d91dcSmrg}
2664a8d91dcSmrg
2674a8d91dcSmrg
2684a8d91dcSmrg# Unless the user overrides by setting GREP, search the path for either GNU
2694a8d91dcSmrg# grep, or the grep that truncates its output the least.
2704a8d91dcSmrgtest -z "$GREP" && {
2714a8d91dcSmrg  func_check_prog_grep ()
2724a8d91dcSmrg  {
2734a8d91dcSmrg    _G_path_prog=$1
2744a8d91dcSmrg
2754a8d91dcSmrg    _G_count=0
2764a8d91dcSmrg    _G_path_prog_max=0
2774a8d91dcSmrg    printf 0123456789 >conftest.in
2784a8d91dcSmrg    while :
2794a8d91dcSmrg    do
2804a8d91dcSmrg      cat conftest.in conftest.in >conftest.tmp
2814a8d91dcSmrg      mv conftest.tmp conftest.in
2824a8d91dcSmrg      cp conftest.in conftest.nl
2834a8d91dcSmrg      echo 'GREP' >> conftest.nl
2844a8d91dcSmrg      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
2854a8d91dcSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
2864a8d91dcSmrg      _G_count=`expr $_G_count + 1`
2874a8d91dcSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
2884a8d91dcSmrg        # Best one so far, save it but keep looking for a better one
2894a8d91dcSmrg        func_check_prog_result=$_G_path_prog
2904a8d91dcSmrg        _G_path_prog_max=$_G_count
2914a8d91dcSmrg      fi
2924a8d91dcSmrg      # 10*(2^10) chars as input seems more than enough
2934a8d91dcSmrg      test 10 -lt "$_G_count" && break
2944a8d91dcSmrg    done
2954a8d91dcSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
2964a8d91dcSmrg  }
2974a8d91dcSmrg
2984a8d91dcSmrg  func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
2994a8d91dcSmrg  GREP=$func_path_progs_result
3004a8d91dcSmrg}
3014a8d91dcSmrg
3024a8d91dcSmrg
3034a8d91dcSmrg## ------------------------------- ##
3044a8d91dcSmrg## User overridable command paths. ##
3054a8d91dcSmrg## ------------------------------- ##
3064a8d91dcSmrg
3074a8d91dcSmrg# All uppercase variable names are used for environment variables.  These
3084a8d91dcSmrg# variables can be overridden by the user before calling a script that
3094a8d91dcSmrg# uses them if a suitable command of that name is not already available
3104a8d91dcSmrg# in the command search PATH.
311b3e38ee4Smrg
312b3e38ee4Smrg: ${CP="cp -f"}
3134a8d91dcSmrg: ${ECHO="printf %s\n"}
3144a8d91dcSmrg: ${EGREP="$GREP -E"}
3154a8d91dcSmrg: ${FGREP="$GREP -F"}
3164a8d91dcSmrg: ${LN_S="ln -s"}
317b3e38ee4Smrg: ${MAKE="make"}
318b3e38ee4Smrg: ${MKDIR="mkdir"}
319b3e38ee4Smrg: ${MV="mv -f"}
320b3e38ee4Smrg: ${RM="rm -f"}
321b3e38ee4Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
32250806d53Smrg
323b3e38ee4Smrg
3244a8d91dcSmrg## -------------------- ##
3254a8d91dcSmrg## Useful sed snippets. ##
3264a8d91dcSmrg## -------------------- ##
327a73423d7Smrg
3284a8d91dcSmrgsed_dirname='s|/[^/]*$||'
3294a8d91dcSmrgsed_basename='s|^.*/||'
330a73423d7Smrg
3314a8d91dcSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
3324a8d91dcSmrg# metacharacters that are still active within double-quoted strings.
3334a8d91dcSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g'
334a73423d7Smrg
3354a8d91dcSmrg# Same as above, but do not quote variable references.
3364a8d91dcSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
337a73423d7Smrg
3384a8d91dcSmrg# Sed substitution that turns a string into a regex matching for the
3394a8d91dcSmrg# string literally.
3404a8d91dcSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
341a73423d7Smrg
3424a8d91dcSmrg# Sed substitution that converts a w32 file name or path
3434a8d91dcSmrg# that contains forward slashes, into one that contains
3444a8d91dcSmrg# (escaped) backslashes.  A very naive implementation.
3454a8d91dcSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3464a8d91dcSmrg
3474a8d91dcSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that
3484a8d91dcSmrg# were '\'-ed in input to the same.  If an odd number of '\' preceded a
3494a8d91dcSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from
3504a8d91dcSmrg# expansion.  Since each input '\' is now two '\'s, look for any number
3514a8d91dcSmrg# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
3524a8d91dcSmrg_G_bs='\\'
3534a8d91dcSmrg_G_bs2='\\\\'
3544a8d91dcSmrg_G_bs4='\\\\\\\\'
3554a8d91dcSmrg_G_dollar='\$'
3564a8d91dcSmrgsed_double_backslash="\
3574a8d91dcSmrg  s/$_G_bs4/&\\
3584a8d91dcSmrg/g
3594a8d91dcSmrg  s/^$_G_bs2$_G_dollar/$_G_bs&/
3604a8d91dcSmrg  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
3614a8d91dcSmrg  s/\n//g"
362a73423d7Smrg
363a73423d7Smrg
3644a8d91dcSmrg## ----------------- ##
3654a8d91dcSmrg## Global variables. ##
3664a8d91dcSmrg## ----------------- ##
367a73423d7Smrg
3684a8d91dcSmrg# Except for the global variables explicitly listed below, the following
3694a8d91dcSmrg# functions in the '^func_' namespace, and the '^require_' namespace
3704a8d91dcSmrg# variables initialised in the 'Resource management' section, sourcing
3714a8d91dcSmrg# this file will not pollute your global namespace with anything
3724a8d91dcSmrg# else. There's no portable way to scope variables in Bourne shell
3734a8d91dcSmrg# though, so actually running these functions will sometimes place
3744a8d91dcSmrg# results into a variable named after the function, and often use
3754a8d91dcSmrg# temporary variables in the '^_G_' namespace. If you are careful to
3764a8d91dcSmrg# avoid using those namespaces casually in your sourcing script, things
3774a8d91dcSmrg# should continue to work as you expect. And, of course, you can freely
3784a8d91dcSmrg# overwrite any of the functions or variables defined here before
3794a8d91dcSmrg# calling anything to customize them.
380a73423d7Smrg
3814a8d91dcSmrgEXIT_SUCCESS=0
3824a8d91dcSmrgEXIT_FAILURE=1
3834a8d91dcSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
3844a8d91dcSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
385af1a9c97Smrg
3864a8d91dcSmrg# Allow overriding, eg assuming that you follow the convention of
3874a8d91dcSmrg# putting '$debug_cmd' at the start of all your functions, you can get
3884a8d91dcSmrg# bash to show function call trace with:
3894a8d91dcSmrg#
3904a8d91dcSmrg#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
3914a8d91dcSmrgdebug_cmd=${debug_cmd-":"}
3924a8d91dcSmrgexit_cmd=:
393b3e38ee4Smrg
3944a8d91dcSmrg# By convention, finish your script with:
3954a8d91dcSmrg#
3964a8d91dcSmrg#    exit $exit_status
3974a8d91dcSmrg#
3984a8d91dcSmrg# so that you can set exit_status to non-zero if you want to indicate
3994a8d91dcSmrg# something went wrong during execution without actually bailing out at
4004a8d91dcSmrg# the point of failure.
4014a8d91dcSmrgexit_status=$EXIT_SUCCESS
402a73423d7Smrg
4034a8d91dcSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
4044a8d91dcSmrg# is ksh but when the shell is invoked as "sh" and the current value of
4054a8d91dcSmrg# the _XPG environment variable is not equal to 1 (one), the special
4064a8d91dcSmrg# positional parameter $0, within a function call, is the name of the
4074a8d91dcSmrg# function.
4084a8d91dcSmrgprogpath=$0
409b3e38ee4Smrg
4104a8d91dcSmrg# The name of this program.
4114a8d91dcSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"`
412b3e38ee4Smrg
4134a8d91dcSmrg# Make sure we have an absolute progpath for reexecution:
414b3e38ee4Smrgcase $progpath in
415b3e38ee4Smrg  [\\/]*|[A-Za-z]:\\*) ;;
416b3e38ee4Smrg  *[\\/]*)
4174a8d91dcSmrg     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
418b3e38ee4Smrg     progdir=`cd "$progdir" && pwd`
4194a8d91dcSmrg     progpath=$progdir/$progname
420b3e38ee4Smrg     ;;
421b3e38ee4Smrg  *)
4224a8d91dcSmrg     _G_IFS=$IFS
423a73423d7Smrg     IFS=${PATH_SEPARATOR-:}
424b3e38ee4Smrg     for progdir in $PATH; do
4254a8d91dcSmrg       IFS=$_G_IFS
426b3e38ee4Smrg       test -x "$progdir/$progname" && break
427b3e38ee4Smrg     done
4284a8d91dcSmrg     IFS=$_G_IFS
429b3e38ee4Smrg     test -n "$progdir" || progdir=`pwd`
4304a8d91dcSmrg     progpath=$progdir/$progname
431b3e38ee4Smrg     ;;
432b3e38ee4Smrgesac
433b3e38ee4Smrg
434b3e38ee4Smrg
4354a8d91dcSmrg## ----------------- ##
4364a8d91dcSmrg## Standard options. ##
4374a8d91dcSmrg## ----------------- ##
438a73423d7Smrg
4394a8d91dcSmrg# The following options affect the operation of the functions defined
4404a8d91dcSmrg# below, and should be set appropriately depending on run-time para-
4414a8d91dcSmrg# meters passed on the command line.
442b3e38ee4Smrg
443b3e38ee4Smrgopt_dry_run=false
444b3e38ee4Smrgopt_quiet=false
445b3e38ee4Smrgopt_verbose=false
446b3e38ee4Smrg
4474a8d91dcSmrg# Categories 'all' and 'none' are always available.  Append any others
4484a8d91dcSmrg# you will pass as the first argument to func_warning from your own
4494a8d91dcSmrg# code.
4504a8d91dcSmrgwarning_categories=
451b3e38ee4Smrg
4524a8d91dcSmrg# By default, display warnings according to 'opt_warning_types'.  Set
4534a8d91dcSmrg# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
4544a8d91dcSmrg# treat the next displayed warning as a fatal error.
4554a8d91dcSmrgwarning_func=func_warn_and_continue
456b3e38ee4Smrg
4574a8d91dcSmrg# Set to 'all' to display all warnings, 'none' to suppress all
4584a8d91dcSmrg# warnings, or a space delimited list of some subset of
4594a8d91dcSmrg# 'warning_categories' to display only the listed warnings.
4604a8d91dcSmrgopt_warning_types=all
461b3e38ee4Smrg
462a73423d7Smrg
4634a8d91dcSmrg## -------------------- ##
4644a8d91dcSmrg## Resource management. ##
4654a8d91dcSmrg## -------------------- ##
466b3e38ee4Smrg
4674a8d91dcSmrg# This section contains definitions for functions that each ensure a
4684a8d91dcSmrg# particular resource (a file, or a non-empty configuration variable for
4694a8d91dcSmrg# example) is available, and if appropriate to extract default values
4704a8d91dcSmrg# from pertinent package files. Call them using their associated
4714a8d91dcSmrg# 'require_*' variable to ensure that they are executed, at most, once.
4724a8d91dcSmrg#
4734a8d91dcSmrg# It's entirely deliberate that calling these functions can set
4744a8d91dcSmrg# variables that don't obey the namespace limitations obeyed by the rest
4754a8d91dcSmrg# of this file, in order that that they be as useful as possible to
4764a8d91dcSmrg# callers.
477b3e38ee4Smrg
478b3e38ee4Smrg
4794a8d91dcSmrg# require_term_colors
4804a8d91dcSmrg# -------------------
4814a8d91dcSmrg# Allow display of bold text on terminals that support it.
4824a8d91dcSmrgrequire_term_colors=func_require_term_colors
4834a8d91dcSmrgfunc_require_term_colors ()
484b3e38ee4Smrg{
4854a8d91dcSmrg    $debug_cmd
4864a8d91dcSmrg
4874a8d91dcSmrg    test -t 1 && {
4884a8d91dcSmrg      # COLORTERM and USE_ANSI_COLORS environment variables take
4894a8d91dcSmrg      # precedence, because most terminfo databases neglect to describe
4904a8d91dcSmrg      # whether color sequences are supported.
4914a8d91dcSmrg      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
4924a8d91dcSmrg
4934a8d91dcSmrg      if test 1 = "$USE_ANSI_COLORS"; then
4944a8d91dcSmrg        # Standard ANSI escape sequences
4954a8d91dcSmrg        tc_reset='[0m'
4964a8d91dcSmrg        tc_bold='[1m';   tc_standout='[7m'
4974a8d91dcSmrg        tc_red='[31m';   tc_green='[32m'
4984a8d91dcSmrg        tc_blue='[34m';  tc_cyan='[36m'
4994a8d91dcSmrg      else
5004a8d91dcSmrg        # Otherwise trust the terminfo database after all.
5014a8d91dcSmrg        test -n "`tput sgr0 2>/dev/null`" && {
5024a8d91dcSmrg          tc_reset=`tput sgr0`
5034a8d91dcSmrg          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
5044a8d91dcSmrg          tc_standout=$tc_bold
5054a8d91dcSmrg          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
5064a8d91dcSmrg          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
5074a8d91dcSmrg          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
5084a8d91dcSmrg          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
5094a8d91dcSmrg          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
5104a8d91dcSmrg        }
5114a8d91dcSmrg      fi
5124a8d91dcSmrg    }
513b3e38ee4Smrg
5144a8d91dcSmrg    require_term_colors=:
515b3e38ee4Smrg}
516b3e38ee4Smrg
517b3e38ee4Smrg
5184a8d91dcSmrg## ----------------- ##
5194a8d91dcSmrg## Function library. ##
5204a8d91dcSmrg## ----------------- ##
5214a8d91dcSmrg
5224a8d91dcSmrg# This section contains a variety of useful functions to call in your
5234a8d91dcSmrg# scripts. Take note of the portable wrappers for features provided by
5244a8d91dcSmrg# some modern shells, which will fall back to slower equivalents on
5254a8d91dcSmrg# less featureful shells.
5264a8d91dcSmrg
5274a8d91dcSmrg
5284a8d91dcSmrg# func_append VAR VALUE
5294a8d91dcSmrg# ---------------------
5304a8d91dcSmrg# Append VALUE onto the existing contents of VAR.
5314a8d91dcSmrg
5324a8d91dcSmrg  # We should try to minimise forks, especially on Windows where they are
5334a8d91dcSmrg  # unreasonably slow, so skip the feature probes when bash or zsh are
5344a8d91dcSmrg  # being used:
5354a8d91dcSmrg  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
5364a8d91dcSmrg    : ${_G_HAVE_ARITH_OP="yes"}
5374a8d91dcSmrg    : ${_G_HAVE_XSI_OPS="yes"}
5384a8d91dcSmrg    # The += operator was introduced in bash 3.1
5394a8d91dcSmrg    case $BASH_VERSION in
5404a8d91dcSmrg      [12].* | 3.0 | 3.0*) ;;
5414a8d91dcSmrg      *)
5424a8d91dcSmrg        : ${_G_HAVE_PLUSEQ_OP="yes"}
5434a8d91dcSmrg        ;;
5444a8d91dcSmrg    esac
5454a8d91dcSmrg  fi
5464a8d91dcSmrg
5474a8d91dcSmrg  # _G_HAVE_PLUSEQ_OP
5484a8d91dcSmrg  # Can be empty, in which case the shell is probed, "yes" if += is
5494a8d91dcSmrg  # useable or anything else if it does not work.
5504a8d91dcSmrg  test -z "$_G_HAVE_PLUSEQ_OP" \
5514a8d91dcSmrg    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
5524a8d91dcSmrg    && _G_HAVE_PLUSEQ_OP=yes
5534a8d91dcSmrg
5544a8d91dcSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"
5554a8d91dcSmrgthen
5564a8d91dcSmrg  # This is an XSI compatible shell, allowing a faster implementation...
5574a8d91dcSmrg  eval 'func_append ()
5584a8d91dcSmrg  {
5594a8d91dcSmrg    $debug_cmd
5604a8d91dcSmrg
5614a8d91dcSmrg    eval "$1+=\$2"
5624a8d91dcSmrg  }'
5634a8d91dcSmrgelse
5644a8d91dcSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
5654a8d91dcSmrg  func_append ()
5664a8d91dcSmrg  {
5674a8d91dcSmrg    $debug_cmd
5684a8d91dcSmrg
5694a8d91dcSmrg    eval "$1=\$$1\$2"
5704a8d91dcSmrg  }
5714a8d91dcSmrgfi
5724a8d91dcSmrg
5734a8d91dcSmrg
5744a8d91dcSmrg# func_append_quoted VAR VALUE
5754a8d91dcSmrg# ----------------------------
5764a8d91dcSmrg# Quote VALUE and append to the end of shell variable VAR, separated
5774a8d91dcSmrg# by a space.
5784a8d91dcSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then
5794a8d91dcSmrg  eval 'func_append_quoted ()
5804a8d91dcSmrg  {
5814a8d91dcSmrg    $debug_cmd
5824a8d91dcSmrg
5834a8d91dcSmrg    func_quote_for_eval "$2"
5844a8d91dcSmrg    eval "$1+=\\ \$func_quote_for_eval_result"
5854a8d91dcSmrg  }'
5864a8d91dcSmrgelse
5874a8d91dcSmrg  func_append_quoted ()
5884a8d91dcSmrg  {
5894a8d91dcSmrg    $debug_cmd
5904a8d91dcSmrg
5914a8d91dcSmrg    func_quote_for_eval "$2"
5924a8d91dcSmrg    eval "$1=\$$1\\ \$func_quote_for_eval_result"
5934a8d91dcSmrg  }
5944a8d91dcSmrgfi
5954a8d91dcSmrg
5964a8d91dcSmrg
5974a8d91dcSmrg# func_append_uniq VAR VALUE
5984a8d91dcSmrg# --------------------------
5994a8d91dcSmrg# Append unique VALUE onto the existing contents of VAR, assuming
6004a8d91dcSmrg# entries are delimited by the first character of VALUE.  For example:
6014a8d91dcSmrg#
6024a8d91dcSmrg#   func_append_uniq options " --another-option option-argument"
6034a8d91dcSmrg#
6044a8d91dcSmrg# will only append to $options if " --another-option option-argument "
6054a8d91dcSmrg# is not already present somewhere in $options already (note spaces at
6064a8d91dcSmrg# each end implied by leading space in second argument).
6074a8d91dcSmrgfunc_append_uniq ()
6084a8d91dcSmrg{
6094a8d91dcSmrg    $debug_cmd
6104a8d91dcSmrg
6114a8d91dcSmrg    eval _G_current_value='`$ECHO $'$1'`'
6124a8d91dcSmrg    _G_delim=`expr "$2" : '\(.\)'`
6134a8d91dcSmrg
6144a8d91dcSmrg    case $_G_delim$_G_current_value$_G_delim in
6154a8d91dcSmrg      *"$2$_G_delim"*) ;;
6164a8d91dcSmrg      *) func_append "$@" ;;
6174a8d91dcSmrg    esac
6184a8d91dcSmrg}
6194a8d91dcSmrg
6204a8d91dcSmrg
6214a8d91dcSmrg# func_arith TERM...
6224a8d91dcSmrg# ------------------
6234a8d91dcSmrg# Set func_arith_result to the result of evaluating TERMs.
6244a8d91dcSmrg  test -z "$_G_HAVE_ARITH_OP" \
6254a8d91dcSmrg    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
6264a8d91dcSmrg    && _G_HAVE_ARITH_OP=yes
6274a8d91dcSmrg
6284a8d91dcSmrgif test yes = "$_G_HAVE_ARITH_OP"; then
6294a8d91dcSmrg  eval 'func_arith ()
6304a8d91dcSmrg  {
6314a8d91dcSmrg    $debug_cmd
6324a8d91dcSmrg
6334a8d91dcSmrg    func_arith_result=$(( $* ))
6344a8d91dcSmrg  }'
6354a8d91dcSmrgelse
6364a8d91dcSmrg  func_arith ()
6374a8d91dcSmrg  {
6384a8d91dcSmrg    $debug_cmd
6394a8d91dcSmrg
6404a8d91dcSmrg    func_arith_result=`expr "$@"`
6414a8d91dcSmrg  }
6424a8d91dcSmrgfi
6434a8d91dcSmrg
6444a8d91dcSmrg
6454a8d91dcSmrg# func_basename FILE
6464a8d91dcSmrg# ------------------
6474a8d91dcSmrg# Set func_basename_result to FILE with everything up to and including
6484a8d91dcSmrg# the last / stripped.
6494a8d91dcSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
6504a8d91dcSmrg  # If this shell supports suffix pattern removal, then use it to avoid
6514a8d91dcSmrg  # forking. Hide the definitions single quotes in case the shell chokes
6524a8d91dcSmrg  # on unsupported syntax...
6534a8d91dcSmrg  _b='func_basename_result=${1##*/}'
6544a8d91dcSmrg  _d='case $1 in
6554a8d91dcSmrg        */*) func_dirname_result=${1%/*}$2 ;;
6564a8d91dcSmrg        *  ) func_dirname_result=$3        ;;
6574a8d91dcSmrg      esac'
6584a8d91dcSmrg
6594a8d91dcSmrgelse
6604a8d91dcSmrg  # ...otherwise fall back to using sed.
6614a8d91dcSmrg  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
6624a8d91dcSmrg  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
6634a8d91dcSmrg      if test "X$func_dirname_result" = "X$1"; then
6644a8d91dcSmrg        func_dirname_result=$3
6654a8d91dcSmrg      else
6664a8d91dcSmrg        func_append func_dirname_result "$2"
6674a8d91dcSmrg      fi'
6684a8d91dcSmrgfi
6694a8d91dcSmrg
6704a8d91dcSmrgeval 'func_basename ()
6714a8d91dcSmrg{
6724a8d91dcSmrg    $debug_cmd
6734a8d91dcSmrg
6744a8d91dcSmrg    '"$_b"'
6754a8d91dcSmrg}'
6764a8d91dcSmrg
6774a8d91dcSmrg
6784a8d91dcSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT
6794a8d91dcSmrg# -------------------------------------------
6804a8d91dcSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
6814a8d91dcSmrg# otherwise set result to NONDIR_REPLACEMENT.
6824a8d91dcSmrgeval 'func_dirname ()
6834a8d91dcSmrg{
6844a8d91dcSmrg    $debug_cmd
6854a8d91dcSmrg
6864a8d91dcSmrg    '"$_d"'
6874a8d91dcSmrg}'
6884a8d91dcSmrg
6894a8d91dcSmrg
6904a8d91dcSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
6914a8d91dcSmrg# --------------------------------------------------------
6924a8d91dcSmrg# Perform func_basename and func_dirname in a single function
6934a8d91dcSmrg# call:
6944a8d91dcSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
6954a8d91dcSmrg#             add APPEND to the result, otherwise set result
6964a8d91dcSmrg#             to NONDIR_REPLACEMENT.
6974a8d91dcSmrg#             value returned in "$func_dirname_result"
6984a8d91dcSmrg#   basename: Compute filename of FILE.
6994a8d91dcSmrg#             value retuned in "$func_basename_result"
7004a8d91dcSmrg# For efficiency, we do not delegate to the functions above but instead
7014a8d91dcSmrg# duplicate the functionality here.
7024a8d91dcSmrgeval 'func_dirname_and_basename ()
7034a8d91dcSmrg{
7044a8d91dcSmrg    $debug_cmd
7054a8d91dcSmrg
7064a8d91dcSmrg    '"$_b"'
7074a8d91dcSmrg    '"$_d"'
7084a8d91dcSmrg}'
7094a8d91dcSmrg
7104a8d91dcSmrg
7114a8d91dcSmrg# func_echo ARG...
7124a8d91dcSmrg# ----------------
7134a8d91dcSmrg# Echo program name prefixed message.
7144a8d91dcSmrgfunc_echo ()
7154a8d91dcSmrg{
7164a8d91dcSmrg    $debug_cmd
7174a8d91dcSmrg
7184a8d91dcSmrg    _G_message=$*
7194a8d91dcSmrg
7204a8d91dcSmrg    func_echo_IFS=$IFS
7214a8d91dcSmrg    IFS=$nl
7224a8d91dcSmrg    for _G_line in $_G_message; do
7234a8d91dcSmrg      IFS=$func_echo_IFS
7244a8d91dcSmrg      $ECHO "$progname: $_G_line"
7254a8d91dcSmrg    done
7264a8d91dcSmrg    IFS=$func_echo_IFS
7274a8d91dcSmrg}
7284a8d91dcSmrg
7294a8d91dcSmrg
7304a8d91dcSmrg# func_echo_all ARG...
7314a8d91dcSmrg# --------------------
7324a8d91dcSmrg# Invoke $ECHO with all args, space-separated.
7334a8d91dcSmrgfunc_echo_all ()
7344a8d91dcSmrg{
7354a8d91dcSmrg    $ECHO "$*"
7364a8d91dcSmrg}
7374a8d91dcSmrg
7384a8d91dcSmrg
7394a8d91dcSmrg# func_echo_infix_1 INFIX ARG...
7404a8d91dcSmrg# ------------------------------
7414a8d91dcSmrg# Echo program name, followed by INFIX on the first line, with any
7424a8d91dcSmrg# additional lines not showing INFIX.
7434a8d91dcSmrgfunc_echo_infix_1 ()
7444a8d91dcSmrg{
7454a8d91dcSmrg    $debug_cmd
7464a8d91dcSmrg
7474a8d91dcSmrg    $require_term_colors
7484a8d91dcSmrg
7494a8d91dcSmrg    _G_infix=$1; shift
7504a8d91dcSmrg    _G_indent=$_G_infix
7514a8d91dcSmrg    _G_prefix="$progname: $_G_infix: "
7524a8d91dcSmrg    _G_message=$*
7534a8d91dcSmrg
7544a8d91dcSmrg    # Strip color escape sequences before counting printable length
7554a8d91dcSmrg    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
7564a8d91dcSmrg    do
7574a8d91dcSmrg      test -n "$_G_tc" && {
7584a8d91dcSmrg        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
7594a8d91dcSmrg        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
7604a8d91dcSmrg      }
7614a8d91dcSmrg    done
7624a8d91dcSmrg    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
7634a8d91dcSmrg
7644a8d91dcSmrg    func_echo_infix_1_IFS=$IFS
7654a8d91dcSmrg    IFS=$nl
7664a8d91dcSmrg    for _G_line in $_G_message; do
7674a8d91dcSmrg      IFS=$func_echo_infix_1_IFS
7684a8d91dcSmrg      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
7694a8d91dcSmrg      _G_prefix=$_G_indent
7704a8d91dcSmrg    done
7714a8d91dcSmrg    IFS=$func_echo_infix_1_IFS
7724a8d91dcSmrg}
7734a8d91dcSmrg
7744a8d91dcSmrg
7754a8d91dcSmrg# func_error ARG...
7764a8d91dcSmrg# -----------------
7774a8d91dcSmrg# Echo program name prefixed message to standard error.
7784a8d91dcSmrgfunc_error ()
7794a8d91dcSmrg{
7804a8d91dcSmrg    $debug_cmd
7814a8d91dcSmrg
7824a8d91dcSmrg    $require_term_colors
7834a8d91dcSmrg
7844a8d91dcSmrg    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
7854a8d91dcSmrg}
7864a8d91dcSmrg
7874a8d91dcSmrg
7884a8d91dcSmrg# func_fatal_error ARG...
7894a8d91dcSmrg# -----------------------
7904a8d91dcSmrg# Echo program name prefixed message to standard error, and exit.
7914a8d91dcSmrgfunc_fatal_error ()
7924a8d91dcSmrg{
7934a8d91dcSmrg    $debug_cmd
7944a8d91dcSmrg
7954a8d91dcSmrg    func_error "$*"
7964a8d91dcSmrg    exit $EXIT_FAILURE
7974a8d91dcSmrg}
7984a8d91dcSmrg
7994a8d91dcSmrg
8004a8d91dcSmrg# func_grep EXPRESSION FILENAME
8014a8d91dcSmrg# -----------------------------
802b3e38ee4Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
803b3e38ee4Smrgfunc_grep ()
804b3e38ee4Smrg{
8054a8d91dcSmrg    $debug_cmd
8064a8d91dcSmrg
807b3e38ee4Smrg    $GREP "$1" "$2" >/dev/null 2>&1
808b3e38ee4Smrg}
809b3e38ee4Smrg
810b3e38ee4Smrg
8114a8d91dcSmrg# func_len STRING
8124a8d91dcSmrg# ---------------
8134a8d91dcSmrg# Set func_len_result to the length of STRING. STRING may not
8144a8d91dcSmrg# start with a hyphen.
8154a8d91dcSmrg  test -z "$_G_HAVE_XSI_OPS" \
8164a8d91dcSmrg    && (eval 'x=a/b/c;
8174a8d91dcSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
8184a8d91dcSmrg    && _G_HAVE_XSI_OPS=yes
8194a8d91dcSmrg
8204a8d91dcSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
8214a8d91dcSmrg  eval 'func_len ()
8224a8d91dcSmrg  {
8234a8d91dcSmrg    $debug_cmd
8244a8d91dcSmrg
8254a8d91dcSmrg    func_len_result=${#1}
8264a8d91dcSmrg  }'
8274a8d91dcSmrgelse
8284a8d91dcSmrg  func_len ()
8294a8d91dcSmrg  {
8304a8d91dcSmrg    $debug_cmd
8314a8d91dcSmrg
8324a8d91dcSmrg    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
8334a8d91dcSmrg  }
8344a8d91dcSmrgfi
8354a8d91dcSmrg
8364a8d91dcSmrg
8374a8d91dcSmrg# func_mkdir_p DIRECTORY-PATH
8384a8d91dcSmrg# ---------------------------
839b3e38ee4Smrg# Make sure the entire path to DIRECTORY-PATH is available.
840b3e38ee4Smrgfunc_mkdir_p ()
841b3e38ee4Smrg{
8424a8d91dcSmrg    $debug_cmd
8434a8d91dcSmrg
8444a8d91dcSmrg    _G_directory_path=$1
8454a8d91dcSmrg    _G_dir_list=
846b3e38ee4Smrg
8474a8d91dcSmrg    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
848b3e38ee4Smrg
8494a8d91dcSmrg      # Protect directory names starting with '-'
8504a8d91dcSmrg      case $_G_directory_path in
8514a8d91dcSmrg        -*) _G_directory_path=./$_G_directory_path ;;
852b3e38ee4Smrg      esac
853b3e38ee4Smrg
854b3e38ee4Smrg      # While some portion of DIR does not yet exist...
8554a8d91dcSmrg      while test ! -d "$_G_directory_path"; do
856b3e38ee4Smrg        # ...make a list in topmost first order.  Use a colon delimited
857b3e38ee4Smrg	# list incase some portion of path contains whitespace.
8584a8d91dcSmrg        _G_dir_list=$_G_directory_path:$_G_dir_list
859b3e38ee4Smrg
860b3e38ee4Smrg        # If the last portion added has no slash in it, the list is done
8614a8d91dcSmrg        case $_G_directory_path in */*) ;; *) break ;; esac
862b3e38ee4Smrg
863b3e38ee4Smrg        # ...otherwise throw away the child directory and loop
8644a8d91dcSmrg        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
865b3e38ee4Smrg      done
8664a8d91dcSmrg      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
867b3e38ee4Smrg
8684a8d91dcSmrg      func_mkdir_p_IFS=$IFS; IFS=:
8694a8d91dcSmrg      for _G_dir in $_G_dir_list; do
8704a8d91dcSmrg	IFS=$func_mkdir_p_IFS
8714a8d91dcSmrg        # mkdir can fail with a 'File exist' error if two processes
872b3e38ee4Smrg        # try to create one of the directories concurrently.  Don't
873b3e38ee4Smrg        # stop in that case!
8744a8d91dcSmrg        $MKDIR "$_G_dir" 2>/dev/null || :
875b3e38ee4Smrg      done
8764a8d91dcSmrg      IFS=$func_mkdir_p_IFS
877b3e38ee4Smrg
878b3e38ee4Smrg      # Bail out if we (or some other process) failed to create a directory.
8794a8d91dcSmrg      test -d "$_G_directory_path" || \
8804a8d91dcSmrg        func_fatal_error "Failed to create '$1'"
881b3e38ee4Smrg    fi
882b3e38ee4Smrg}
88350806d53Smrg
88450806d53Smrg
8854a8d91dcSmrg# func_mktempdir [BASENAME]
8864a8d91dcSmrg# -------------------------
88750806d53Smrg# Make a temporary directory that won't clash with other running
88850806d53Smrg# libtool processes, and avoids race conditions if possible.  If
8894a8d91dcSmrg# given, BASENAME is the basename for that directory.
89050806d53Smrgfunc_mktempdir ()
89150806d53Smrg{
8924a8d91dcSmrg    $debug_cmd
8934a8d91dcSmrg
8944a8d91dcSmrg    _G_template=${TMPDIR-/tmp}/${1-$progname}
89550806d53Smrg
8964a8d91dcSmrg    if test : = "$opt_dry_run"; then
89750806d53Smrg      # Return a directory name, but don't create it in dry-run mode
8984a8d91dcSmrg      _G_tmpdir=$_G_template-$$
89950806d53Smrg    else
90050806d53Smrg
90150806d53Smrg      # If mktemp works, use that first and foremost
9024a8d91dcSmrg      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
90350806d53Smrg
9044a8d91dcSmrg      if test ! -d "$_G_tmpdir"; then
905b3e38ee4Smrg        # Failing that, at least try and use $RANDOM to avoid a race
9064a8d91dcSmrg        _G_tmpdir=$_G_template-${RANDOM-0}$$
90750806d53Smrg
9084a8d91dcSmrg        func_mktempdir_umask=`umask`
909b3e38ee4Smrg        umask 0077
9104a8d91dcSmrg        $MKDIR "$_G_tmpdir"
9114a8d91dcSmrg        umask $func_mktempdir_umask
91250806d53Smrg      fi
91350806d53Smrg
91450806d53Smrg      # If we're not in dry-run mode, bomb out on failure
9154a8d91dcSmrg      test -d "$_G_tmpdir" || \
9164a8d91dcSmrg        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
91750806d53Smrg    fi
91850806d53Smrg
9194a8d91dcSmrg    $ECHO "$_G_tmpdir"
92050806d53Smrg}
92150806d53Smrg
92250806d53Smrg
9234a8d91dcSmrg# func_normal_abspath PATH
9244a8d91dcSmrg# ------------------------
9254a8d91dcSmrg# Remove doubled-up and trailing slashes, "." path components,
9264a8d91dcSmrg# and cancel out any ".." path components in PATH after making
9274a8d91dcSmrg# it an absolute path.
9284a8d91dcSmrgfunc_normal_abspath ()
92950806d53Smrg{
9304a8d91dcSmrg    $debug_cmd
931b3e38ee4Smrg
9324a8d91dcSmrg    # These SED scripts presuppose an absolute path with a trailing slash.
9334a8d91dcSmrg    _G_pathcar='s|^/\([^/]*\).*$|\1|'
9344a8d91dcSmrg    _G_pathcdr='s|^/[^/]*||'
9354a8d91dcSmrg    _G_removedotparts=':dotsl
9364a8d91dcSmrg		s|/\./|/|g
9374a8d91dcSmrg		t dotsl
9384a8d91dcSmrg		s|/\.$|/|'
9394a8d91dcSmrg    _G_collapseslashes='s|/\{1,\}|/|g'
9404a8d91dcSmrg    _G_finalslash='s|/*$|/|'
9414a8d91dcSmrg
9424a8d91dcSmrg    # Start from root dir and reassemble the path.
9434a8d91dcSmrg    func_normal_abspath_result=
9444a8d91dcSmrg    func_normal_abspath_tpath=$1
9454a8d91dcSmrg    func_normal_abspath_altnamespace=
9464a8d91dcSmrg    case $func_normal_abspath_tpath in
9474a8d91dcSmrg      "")
9484a8d91dcSmrg        # Empty path, that just means $cwd.
9494a8d91dcSmrg        func_stripname '' '/' "`pwd`"
9504a8d91dcSmrg        func_normal_abspath_result=$func_stripname_result
9514a8d91dcSmrg        return
9524a8d91dcSmrg        ;;
9534a8d91dcSmrg      # The next three entries are used to spot a run of precisely
9544a8d91dcSmrg      # two leading slashes without using negated character classes;
9554a8d91dcSmrg      # we take advantage of case's first-match behaviour.
9564a8d91dcSmrg      ///*)
9574a8d91dcSmrg        # Unusual form of absolute path, do nothing.
9584a8d91dcSmrg        ;;
9594a8d91dcSmrg      //*)
9604a8d91dcSmrg        # Not necessarily an ordinary path; POSIX reserves leading '//'
9614a8d91dcSmrg        # and for example Cygwin uses it to access remote file shares
9624a8d91dcSmrg        # over CIFS/SMB, so we conserve a leading double slash if found.
9634a8d91dcSmrg        func_normal_abspath_altnamespace=/
9644a8d91dcSmrg        ;;
9654a8d91dcSmrg      /*)
9664a8d91dcSmrg        # Absolute path, do nothing.
967b3e38ee4Smrg        ;;
968b3e38ee4Smrg      *)
9694a8d91dcSmrg        # Relative path, prepend $cwd.
9704a8d91dcSmrg        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
9714a8d91dcSmrg        ;;
97250806d53Smrg    esac
9734a8d91dcSmrg
9744a8d91dcSmrg    # Cancel out all the simple stuff to save iterations.  We also want
9754a8d91dcSmrg    # the path to end with a slash for ease of parsing, so make sure
9764a8d91dcSmrg    # there is one (and only one) here.
9774a8d91dcSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
9784a8d91dcSmrg          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
9794a8d91dcSmrg    while :; do
9804a8d91dcSmrg      # Processed it all yet?
9814a8d91dcSmrg      if test / = "$func_normal_abspath_tpath"; then
9824a8d91dcSmrg        # If we ascended to the root using ".." the result may be empty now.
9834a8d91dcSmrg        if test -z "$func_normal_abspath_result"; then
9844a8d91dcSmrg          func_normal_abspath_result=/
9854a8d91dcSmrg        fi
9864a8d91dcSmrg        break
9874a8d91dcSmrg      fi
9884a8d91dcSmrg      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
9894a8d91dcSmrg          -e "$_G_pathcar"`
9904a8d91dcSmrg      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
9914a8d91dcSmrg          -e "$_G_pathcdr"`
9924a8d91dcSmrg      # Figure out what to do with it
9934a8d91dcSmrg      case $func_normal_abspath_tcomponent in
9944a8d91dcSmrg        "")
9954a8d91dcSmrg          # Trailing empty path component, ignore it.
9964a8d91dcSmrg          ;;
9974a8d91dcSmrg        ..)
9984a8d91dcSmrg          # Parent dir; strip last assembled component from result.
9994a8d91dcSmrg          func_dirname "$func_normal_abspath_result"
10004a8d91dcSmrg          func_normal_abspath_result=$func_dirname_result
10014a8d91dcSmrg          ;;
10024a8d91dcSmrg        *)
10034a8d91dcSmrg          # Actual path component, append it.
10044a8d91dcSmrg          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
10054a8d91dcSmrg          ;;
10064a8d91dcSmrg      esac
10074a8d91dcSmrg    done
10084a8d91dcSmrg    # Restore leading double-slash if one was found on entry.
10094a8d91dcSmrg    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
10104a8d91dcSmrg}
10114a8d91dcSmrg
10124a8d91dcSmrg
10134a8d91dcSmrg# func_notquiet ARG...
10144a8d91dcSmrg# --------------------
10154a8d91dcSmrg# Echo program name prefixed message only when not in quiet mode.
10164a8d91dcSmrgfunc_notquiet ()
10174a8d91dcSmrg{
10184a8d91dcSmrg    $debug_cmd
10194a8d91dcSmrg
10204a8d91dcSmrg    $opt_quiet || func_echo ${1+"$@"}
10214a8d91dcSmrg
10224a8d91dcSmrg    # A bug in bash halts the script if the last line of a function
10234a8d91dcSmrg    # fails when set -e is in force, so we need another command to
10244a8d91dcSmrg    # work around that:
10254a8d91dcSmrg    :
10264a8d91dcSmrg}
10274a8d91dcSmrg
10284a8d91dcSmrg
10294a8d91dcSmrg# func_relative_path SRCDIR DSTDIR
10304a8d91dcSmrg# --------------------------------
10314a8d91dcSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
10324a8d91dcSmrgfunc_relative_path ()
10334a8d91dcSmrg{
10344a8d91dcSmrg    $debug_cmd
10354a8d91dcSmrg
10364a8d91dcSmrg    func_relative_path_result=
10374a8d91dcSmrg    func_normal_abspath "$1"
10384a8d91dcSmrg    func_relative_path_tlibdir=$func_normal_abspath_result
10394a8d91dcSmrg    func_normal_abspath "$2"
10404a8d91dcSmrg    func_relative_path_tbindir=$func_normal_abspath_result
10414a8d91dcSmrg
10424a8d91dcSmrg    # Ascend the tree starting from libdir
10434a8d91dcSmrg    while :; do
10444a8d91dcSmrg      # check if we have found a prefix of bindir
10454a8d91dcSmrg      case $func_relative_path_tbindir in
10464a8d91dcSmrg        $func_relative_path_tlibdir)
10474a8d91dcSmrg          # found an exact match
10484a8d91dcSmrg          func_relative_path_tcancelled=
10494a8d91dcSmrg          break
10504a8d91dcSmrg          ;;
10514a8d91dcSmrg        $func_relative_path_tlibdir*)
10524a8d91dcSmrg          # found a matching prefix
10534a8d91dcSmrg          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
10544a8d91dcSmrg          func_relative_path_tcancelled=$func_stripname_result
10554a8d91dcSmrg          if test -z "$func_relative_path_result"; then
10564a8d91dcSmrg            func_relative_path_result=.
10574a8d91dcSmrg          fi
10584a8d91dcSmrg          break
10594a8d91dcSmrg          ;;
10604a8d91dcSmrg        *)
10614a8d91dcSmrg          func_dirname $func_relative_path_tlibdir
10624a8d91dcSmrg          func_relative_path_tlibdir=$func_dirname_result
10634a8d91dcSmrg          if test -z "$func_relative_path_tlibdir"; then
10644a8d91dcSmrg            # Have to descend all the way to the root!
10654a8d91dcSmrg            func_relative_path_result=../$func_relative_path_result
10664a8d91dcSmrg            func_relative_path_tcancelled=$func_relative_path_tbindir
10674a8d91dcSmrg            break
10684a8d91dcSmrg          fi
10694a8d91dcSmrg          func_relative_path_result=../$func_relative_path_result
10704a8d91dcSmrg          ;;
10714a8d91dcSmrg      esac
10724a8d91dcSmrg    done
10734a8d91dcSmrg
10744a8d91dcSmrg    # Now calculate path; take care to avoid doubling-up slashes.
10754a8d91dcSmrg    func_stripname '' '/' "$func_relative_path_result"
10764a8d91dcSmrg    func_relative_path_result=$func_stripname_result
10774a8d91dcSmrg    func_stripname '/' '/' "$func_relative_path_tcancelled"
10784a8d91dcSmrg    if test -n "$func_stripname_result"; then
10794a8d91dcSmrg      func_append func_relative_path_result "/$func_stripname_result"
10804a8d91dcSmrg    fi
10814a8d91dcSmrg
10824a8d91dcSmrg    # Normalisation. If bindir is libdir, return '.' else relative path.
10834a8d91dcSmrg    if test -n "$func_relative_path_result"; then
10844a8d91dcSmrg      func_stripname './' '' "$func_relative_path_result"
10854a8d91dcSmrg      func_relative_path_result=$func_stripname_result
10864a8d91dcSmrg    fi
10874a8d91dcSmrg
10884a8d91dcSmrg    test -n "$func_relative_path_result" || func_relative_path_result=.
10894a8d91dcSmrg
10904a8d91dcSmrg    :
109150806d53Smrg}
109250806d53Smrg
109350806d53Smrg
10944a8d91dcSmrg# func_quote_for_eval ARG...
10954a8d91dcSmrg# --------------------------
10964a8d91dcSmrg# Aesthetically quote ARGs to be evaled later.
10974a8d91dcSmrg# This function returns two values:
10984a8d91dcSmrg#   i) func_quote_for_eval_result
10994a8d91dcSmrg#      double-quoted, suitable for a subsequent eval
11004a8d91dcSmrg#  ii) func_quote_for_eval_unquoted_result
11014a8d91dcSmrg#      has all characters that are still active within double
11024a8d91dcSmrg#      quotes backslashified.
11034a8d91dcSmrgfunc_quote_for_eval ()
11044a8d91dcSmrg{
11054a8d91dcSmrg    $debug_cmd
11064a8d91dcSmrg
11074a8d91dcSmrg    func_quote_for_eval_unquoted_result=
11084a8d91dcSmrg    func_quote_for_eval_result=
11094a8d91dcSmrg    while test 0 -lt $#; do
11104a8d91dcSmrg      case $1 in
11114a8d91dcSmrg        *[\\\`\"\$]*)
11124a8d91dcSmrg	  _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
11134a8d91dcSmrg        *)
11144a8d91dcSmrg          _G_unquoted_arg=$1 ;;
11154a8d91dcSmrg      esac
11164a8d91dcSmrg      if test -n "$func_quote_for_eval_unquoted_result"; then
11174a8d91dcSmrg	func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
11184a8d91dcSmrg      else
11194a8d91dcSmrg        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
11204a8d91dcSmrg      fi
11214a8d91dcSmrg
11224a8d91dcSmrg      case $_G_unquoted_arg in
11234a8d91dcSmrg        # Double-quote args containing shell metacharacters to delay
11244a8d91dcSmrg        # word splitting, command substitution and variable expansion
11254a8d91dcSmrg        # for a subsequent eval.
11264a8d91dcSmrg        # Many Bourne shells cannot handle close brackets correctly
11274a8d91dcSmrg        # in scan sets, so we specify it separately.
11284a8d91dcSmrg        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
11294a8d91dcSmrg          _G_quoted_arg=\"$_G_unquoted_arg\"
11304a8d91dcSmrg          ;;
11314a8d91dcSmrg        *)
11324a8d91dcSmrg          _G_quoted_arg=$_G_unquoted_arg
11334a8d91dcSmrg	  ;;
11344a8d91dcSmrg      esac
11354a8d91dcSmrg
11364a8d91dcSmrg      if test -n "$func_quote_for_eval_result"; then
11374a8d91dcSmrg	func_append func_quote_for_eval_result " $_G_quoted_arg"
11384a8d91dcSmrg      else
11394a8d91dcSmrg        func_append func_quote_for_eval_result "$_G_quoted_arg"
11404a8d91dcSmrg      fi
11414a8d91dcSmrg      shift
11424a8d91dcSmrg    done
11434a8d91dcSmrg}
11444a8d91dcSmrg
11454a8d91dcSmrg
11464a8d91dcSmrg# func_quote_for_expand ARG
11474a8d91dcSmrg# -------------------------
1148b3e38ee4Smrg# Aesthetically quote ARG to be evaled later; same as above,
1149b3e38ee4Smrg# but do not quote variable references.
1150b3e38ee4Smrgfunc_quote_for_expand ()
115150806d53Smrg{
11524a8d91dcSmrg    $debug_cmd
11534a8d91dcSmrg
1154b3e38ee4Smrg    case $1 in
1155b3e38ee4Smrg      *[\\\`\"]*)
11564a8d91dcSmrg	_G_arg=`$ECHO "$1" | $SED \
11574a8d91dcSmrg	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
115850806d53Smrg      *)
11594a8d91dcSmrg        _G_arg=$1 ;;
1160b3e38ee4Smrg    esac
1161b3e38ee4Smrg
11624a8d91dcSmrg    case $_G_arg in
1163b3e38ee4Smrg      # Double-quote args containing shell metacharacters to delay
1164b3e38ee4Smrg      # word splitting and command substitution for a subsequent eval.
1165b3e38ee4Smrg      # Many Bourne shells cannot handle close brackets correctly
1166b3e38ee4Smrg      # in scan sets, so we specify it separately.
1167b3e38ee4Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
11684a8d91dcSmrg        _G_arg=\"$_G_arg\"
1169b3e38ee4Smrg        ;;
1170b3e38ee4Smrg    esac
1171b3e38ee4Smrg
11724a8d91dcSmrg    func_quote_for_expand_result=$_G_arg
11734a8d91dcSmrg}
11744a8d91dcSmrg
11754a8d91dcSmrg
11764a8d91dcSmrg# func_stripname PREFIX SUFFIX NAME
11774a8d91dcSmrg# ---------------------------------
11784a8d91dcSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
11794a8d91dcSmrg# PREFIX and SUFFIX must not contain globbing or regex special
11804a8d91dcSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
11814a8d91dcSmrg# dot (in which case that matches only a dot).
11824a8d91dcSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
11834a8d91dcSmrg  eval 'func_stripname ()
11844a8d91dcSmrg  {
11854a8d91dcSmrg    $debug_cmd
11864a8d91dcSmrg
11874a8d91dcSmrg    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
11884a8d91dcSmrg    # positional parameters, so assign one to ordinary variable first.
11894a8d91dcSmrg    func_stripname_result=$3
11904a8d91dcSmrg    func_stripname_result=${func_stripname_result#"$1"}
11914a8d91dcSmrg    func_stripname_result=${func_stripname_result%"$2"}
11924a8d91dcSmrg  }'
11934a8d91dcSmrgelse
11944a8d91dcSmrg  func_stripname ()
11954a8d91dcSmrg  {
11964a8d91dcSmrg    $debug_cmd
11974a8d91dcSmrg
11984a8d91dcSmrg    case $2 in
11994a8d91dcSmrg      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
12004a8d91dcSmrg      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
12014a8d91dcSmrg    esac
12024a8d91dcSmrg  }
12034a8d91dcSmrgfi
12044a8d91dcSmrg
12054a8d91dcSmrg
12064a8d91dcSmrg# func_show_eval CMD [FAIL_EXP]
12074a8d91dcSmrg# -----------------------------
12084a8d91dcSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
12094a8d91dcSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
12104a8d91dcSmrg# is given, then evaluate it.
12114a8d91dcSmrgfunc_show_eval ()
12124a8d91dcSmrg{
12134a8d91dcSmrg    $debug_cmd
12144a8d91dcSmrg
12154a8d91dcSmrg    _G_cmd=$1
12164a8d91dcSmrg    _G_fail_exp=${2-':'}
12174a8d91dcSmrg
12184a8d91dcSmrg    func_quote_for_expand "$_G_cmd"
12194a8d91dcSmrg    eval "func_notquiet $func_quote_for_expand_result"
12204a8d91dcSmrg
12214a8d91dcSmrg    $opt_dry_run || {
12224a8d91dcSmrg      eval "$_G_cmd"
12234a8d91dcSmrg      _G_status=$?
12244a8d91dcSmrg      if test 0 -ne "$_G_status"; then
12254a8d91dcSmrg	eval "(exit $_G_status); $_G_fail_exp"
12264a8d91dcSmrg      fi
12274a8d91dcSmrg    }
12284a8d91dcSmrg}
12294a8d91dcSmrg
12304a8d91dcSmrg
12314a8d91dcSmrg# func_show_eval_locale CMD [FAIL_EXP]
12324a8d91dcSmrg# ------------------------------------
12334a8d91dcSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
12344a8d91dcSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
12354a8d91dcSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
12364a8d91dcSmrgfunc_show_eval_locale ()
12374a8d91dcSmrg{
12384a8d91dcSmrg    $debug_cmd
12394a8d91dcSmrg
12404a8d91dcSmrg    _G_cmd=$1
12414a8d91dcSmrg    _G_fail_exp=${2-':'}
12424a8d91dcSmrg
12434a8d91dcSmrg    $opt_quiet || {
12444a8d91dcSmrg      func_quote_for_expand "$_G_cmd"
12454a8d91dcSmrg      eval "func_echo $func_quote_for_expand_result"
12464a8d91dcSmrg    }
12474a8d91dcSmrg
12484a8d91dcSmrg    $opt_dry_run || {
12494a8d91dcSmrg      eval "$_G_user_locale
12504a8d91dcSmrg	    $_G_cmd"
12514a8d91dcSmrg      _G_status=$?
12524a8d91dcSmrg      eval "$_G_safe_locale"
12534a8d91dcSmrg      if test 0 -ne "$_G_status"; then
12544a8d91dcSmrg	eval "(exit $_G_status); $_G_fail_exp"
12554a8d91dcSmrg      fi
12564a8d91dcSmrg    }
12574a8d91dcSmrg}
12584a8d91dcSmrg
12594a8d91dcSmrg
12604a8d91dcSmrg# func_tr_sh
12614a8d91dcSmrg# ----------
12624a8d91dcSmrg# Turn $1 into a string suitable for a shell variable name.
12634a8d91dcSmrg# Result is stored in $func_tr_sh_result.  All characters
12644a8d91dcSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
12654a8d91dcSmrg# if $1 begins with a digit, a '_' is prepended as well.
12664a8d91dcSmrgfunc_tr_sh ()
12674a8d91dcSmrg{
12684a8d91dcSmrg    $debug_cmd
12694a8d91dcSmrg
12704a8d91dcSmrg    case $1 in
12714a8d91dcSmrg    [0-9]* | *[!a-zA-Z0-9_]*)
12724a8d91dcSmrg      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
12734a8d91dcSmrg      ;;
12744a8d91dcSmrg    * )
12754a8d91dcSmrg      func_tr_sh_result=$1
12764a8d91dcSmrg      ;;
12774a8d91dcSmrg    esac
12784a8d91dcSmrg}
12794a8d91dcSmrg
12804a8d91dcSmrg
12814a8d91dcSmrg# func_verbose ARG...
12824a8d91dcSmrg# -------------------
12834a8d91dcSmrg# Echo program name prefixed message in verbose mode only.
12844a8d91dcSmrgfunc_verbose ()
12854a8d91dcSmrg{
12864a8d91dcSmrg    $debug_cmd
12874a8d91dcSmrg
12884a8d91dcSmrg    $opt_verbose && func_echo "$*"
12894a8d91dcSmrg
12904a8d91dcSmrg    :
12914a8d91dcSmrg}
12924a8d91dcSmrg
12934a8d91dcSmrg
12944a8d91dcSmrg# func_warn_and_continue ARG...
12954a8d91dcSmrg# -----------------------------
12964a8d91dcSmrg# Echo program name prefixed warning message to standard error.
12974a8d91dcSmrgfunc_warn_and_continue ()
12984a8d91dcSmrg{
12994a8d91dcSmrg    $debug_cmd
13004a8d91dcSmrg
13014a8d91dcSmrg    $require_term_colors
13024a8d91dcSmrg
13034a8d91dcSmrg    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
13044a8d91dcSmrg}
13054a8d91dcSmrg
13064a8d91dcSmrg
13074a8d91dcSmrg# func_warning CATEGORY ARG...
13084a8d91dcSmrg# ----------------------------
13094a8d91dcSmrg# Echo program name prefixed warning message to standard error. Warning
13104a8d91dcSmrg# messages can be filtered according to CATEGORY, where this function
13114a8d91dcSmrg# elides messages where CATEGORY is not listed in the global variable
13124a8d91dcSmrg# 'opt_warning_types'.
13134a8d91dcSmrgfunc_warning ()
13144a8d91dcSmrg{
13154a8d91dcSmrg    $debug_cmd
13164a8d91dcSmrg
13174a8d91dcSmrg    # CATEGORY must be in the warning_categories list!
13184a8d91dcSmrg    case " $warning_categories " in
13194a8d91dcSmrg      *" $1 "*) ;;
13204a8d91dcSmrg      *) func_internal_error "invalid warning category '$1'" ;;
13214a8d91dcSmrg    esac
13224a8d91dcSmrg
13234a8d91dcSmrg    _G_category=$1
13244a8d91dcSmrg    shift
13254a8d91dcSmrg
13264a8d91dcSmrg    case " $opt_warning_types " in
13274a8d91dcSmrg      *" $_G_category "*) $warning_func ${1+"$@"} ;;
13284a8d91dcSmrg    esac
132950806d53Smrg}
133050806d53Smrg
133150806d53Smrg
13324a8d91dcSmrg# func_sort_ver VER1 VER2
13334a8d91dcSmrg# -----------------------
13344a8d91dcSmrg# 'sort -V' is not generally available.
13354a8d91dcSmrg# Note this deviates from the version comparison in automake
13364a8d91dcSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
13374a8d91dcSmrg# but this should suffice as we won't be specifying old
13384a8d91dcSmrg# version formats or redundant trailing .0 in bootstrap.conf.
13394a8d91dcSmrg# If we did want full compatibility then we should probably
13404a8d91dcSmrg# use m4_version_compare from autoconf.
13414a8d91dcSmrgfunc_sort_ver ()
13424a8d91dcSmrg{
13434a8d91dcSmrg    $debug_cmd
13444a8d91dcSmrg
13454a8d91dcSmrg    printf '%s\n%s\n' "$1" "$2" \
13464a8d91dcSmrg      | 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
13474a8d91dcSmrg}
13484a8d91dcSmrg
13494a8d91dcSmrg# func_lt_ver PREV CURR
13504a8d91dcSmrg# ---------------------
13514a8d91dcSmrg# Return true if PREV and CURR are in the correct order according to
13524a8d91dcSmrg# func_sort_ver, otherwise false.  Use it like this:
13534a8d91dcSmrg#
13544a8d91dcSmrg#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
13554a8d91dcSmrgfunc_lt_ver ()
13564a8d91dcSmrg{
13574a8d91dcSmrg    $debug_cmd
13584a8d91dcSmrg
13594a8d91dcSmrg    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
13604a8d91dcSmrg}
13614a8d91dcSmrg
13624a8d91dcSmrg
13634a8d91dcSmrg# Local variables:
13644a8d91dcSmrg# mode: shell-script
13654a8d91dcSmrg# sh-indentation: 2
13664a8d91dcSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
13674a8d91dcSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
13684a8d91dcSmrg# time-stamp-time-zone: "UTC"
13694a8d91dcSmrg# End:
13704a8d91dcSmrg#! /bin/sh
13714a8d91dcSmrg
13724a8d91dcSmrg# Set a version string for this script.
13734a8d91dcSmrgscriptversion=2014-01-07.03; # UTC
13744a8d91dcSmrg
13754a8d91dcSmrg# A portable, pluggable option parser for Bourne shell.
13764a8d91dcSmrg# Written by Gary V. Vaughan, 2010
13774a8d91dcSmrg
13784a8d91dcSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc.
13794a8d91dcSmrg# This is free software; see the source for copying conditions.  There is NO
13804a8d91dcSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13814a8d91dcSmrg
13824a8d91dcSmrg# This program is free software: you can redistribute it and/or modify
13834a8d91dcSmrg# it under the terms of the GNU General Public License as published by
13844a8d91dcSmrg# the Free Software Foundation, either version 3 of the License, or
13854a8d91dcSmrg# (at your option) any later version.
13864a8d91dcSmrg
13874a8d91dcSmrg# This program is distributed in the hope that it will be useful,
13884a8d91dcSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
13894a8d91dcSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13904a8d91dcSmrg# GNU General Public License for more details.
13914a8d91dcSmrg
13924a8d91dcSmrg# You should have received a copy of the GNU General Public License
13934a8d91dcSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
13944a8d91dcSmrg
13954a8d91dcSmrg# Please report bugs or propose patches to gary@gnu.org.
13964a8d91dcSmrg
13974a8d91dcSmrg
13984a8d91dcSmrg## ------ ##
13994a8d91dcSmrg## Usage. ##
14004a8d91dcSmrg## ------ ##
14014a8d91dcSmrg
14024a8d91dcSmrg# This file is a library for parsing options in your shell scripts along
14034a8d91dcSmrg# with assorted other useful supporting features that you can make use
14044a8d91dcSmrg# of too.
14054a8d91dcSmrg#
14064a8d91dcSmrg# For the simplest scripts you might need only:
14074a8d91dcSmrg#
14084a8d91dcSmrg#   #!/bin/sh
14094a8d91dcSmrg#   . relative/path/to/funclib.sh
14104a8d91dcSmrg#   . relative/path/to/options-parser
14114a8d91dcSmrg#   scriptversion=1.0
14124a8d91dcSmrg#   func_options ${1+"$@"}
14134a8d91dcSmrg#   eval set dummy "$func_options_result"; shift
14144a8d91dcSmrg#   ...rest of your script...
14154a8d91dcSmrg#
14164a8d91dcSmrg# In order for the '--version' option to work, you will need to have a
14174a8d91dcSmrg# suitably formatted comment like the one at the top of this file
14184a8d91dcSmrg# starting with '# Written by ' and ending with '# warranty; '.
14194a8d91dcSmrg#
14204a8d91dcSmrg# For '-h' and '--help' to work, you will also need a one line
14214a8d91dcSmrg# description of your script's purpose in a comment directly above the
14224a8d91dcSmrg# '# Written by ' line, like the one at the top of this file.
14234a8d91dcSmrg#
14244a8d91dcSmrg# The default options also support '--debug', which will turn on shell
14254a8d91dcSmrg# execution tracing (see the comment above debug_cmd below for another
14264a8d91dcSmrg# use), and '--verbose' and the func_verbose function to allow your script
14274a8d91dcSmrg# to display verbose messages only when your user has specified
14284a8d91dcSmrg# '--verbose'.
14294a8d91dcSmrg#
14304a8d91dcSmrg# After sourcing this file, you can plug processing for additional
14314a8d91dcSmrg# options by amending the variables from the 'Configuration' section
14324a8d91dcSmrg# below, and following the instructions in the 'Option parsing'
14334a8d91dcSmrg# section further down.
14344a8d91dcSmrg
14354a8d91dcSmrg## -------------- ##
14364a8d91dcSmrg## Configuration. ##
14374a8d91dcSmrg## -------------- ##
14384a8d91dcSmrg
14394a8d91dcSmrg# You should override these variables in your script after sourcing this
14404a8d91dcSmrg# file so that they reflect the customisations you have added to the
14414a8d91dcSmrg# option parser.
14424a8d91dcSmrg
14434a8d91dcSmrg# The usage line for option parsing errors and the start of '-h' and
14444a8d91dcSmrg# '--help' output messages. You can embed shell variables for delayed
14454a8d91dcSmrg# expansion at the time the message is displayed, but you will need to
14464a8d91dcSmrg# quote other shell meta-characters carefully to prevent them being
14474a8d91dcSmrg# expanded when the contents are evaled.
14484a8d91dcSmrgusage='$progpath [OPTION]...'
14494a8d91dcSmrg
14504a8d91dcSmrg# Short help message in response to '-h' and '--help'.  Add to this or
14514a8d91dcSmrg# override it after sourcing this library to reflect the full set of
14524a8d91dcSmrg# options your script accepts.
14534a8d91dcSmrgusage_message="\
14544a8d91dcSmrg       --debug        enable verbose shell tracing
14554a8d91dcSmrg   -W, --warnings=CATEGORY
14564a8d91dcSmrg                      report the warnings falling in CATEGORY [all]
14574a8d91dcSmrg   -v, --verbose      verbosely report processing
14584a8d91dcSmrg       --version      print version information and exit
14594a8d91dcSmrg   -h, --help         print short or long help message and exit
14604a8d91dcSmrg"
14614a8d91dcSmrg
14624a8d91dcSmrg# Additional text appended to 'usage_message' in response to '--help'.
14634a8d91dcSmrglong_help_message="
14644a8d91dcSmrgWarning categories include:
14654a8d91dcSmrg       'all'          show all warnings
14664a8d91dcSmrg       'none'         turn off all the warnings
14674a8d91dcSmrg       'error'        warnings are treated as fatal errors"
14684a8d91dcSmrg
14694a8d91dcSmrg# Help message printed before fatal option parsing errors.
14704a8d91dcSmrgfatal_help="Try '\$progname --help' for more information."
14714a8d91dcSmrg
14724a8d91dcSmrg
14734a8d91dcSmrg
14744a8d91dcSmrg## ------------------------- ##
14754a8d91dcSmrg## Hook function management. ##
14764a8d91dcSmrg## ------------------------- ##
14774a8d91dcSmrg
14784a8d91dcSmrg# This section contains functions for adding, removing, and running hooks
14794a8d91dcSmrg# to the main code.  A hook is just a named list of of function, that can
14804a8d91dcSmrg# be run in order later on.
14814a8d91dcSmrg
14824a8d91dcSmrg# func_hookable FUNC_NAME
14834a8d91dcSmrg# -----------------------
14844a8d91dcSmrg# Declare that FUNC_NAME will run hooks added with
14854a8d91dcSmrg# 'func_add_hook FUNC_NAME ...'.
14864a8d91dcSmrgfunc_hookable ()
14874a8d91dcSmrg{
14884a8d91dcSmrg    $debug_cmd
14894a8d91dcSmrg
14904a8d91dcSmrg    func_append hookable_fns " $1"
14914a8d91dcSmrg}
14924a8d91dcSmrg
14934a8d91dcSmrg
14944a8d91dcSmrg# func_add_hook FUNC_NAME HOOK_FUNC
14954a8d91dcSmrg# ---------------------------------
14964a8d91dcSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
14974a8d91dcSmrg# first have been declared "hookable" by a call to 'func_hookable'.
14984a8d91dcSmrgfunc_add_hook ()
14994a8d91dcSmrg{
15004a8d91dcSmrg    $debug_cmd
15014a8d91dcSmrg
15024a8d91dcSmrg    case " $hookable_fns " in
15034a8d91dcSmrg      *" $1 "*) ;;
15044a8d91dcSmrg      *) func_fatal_error "'$1' does not accept hook functions." ;;
15054a8d91dcSmrg    esac
15064a8d91dcSmrg
15074a8d91dcSmrg    eval func_append ${1}_hooks '" $2"'
15084a8d91dcSmrg}
15094a8d91dcSmrg
15104a8d91dcSmrg
15114a8d91dcSmrg# func_remove_hook FUNC_NAME HOOK_FUNC
15124a8d91dcSmrg# ------------------------------------
15134a8d91dcSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
15144a8d91dcSmrgfunc_remove_hook ()
15154a8d91dcSmrg{
15164a8d91dcSmrg    $debug_cmd
15174a8d91dcSmrg
15184a8d91dcSmrg    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
15194a8d91dcSmrg}
15204a8d91dcSmrg
15214a8d91dcSmrg
15224a8d91dcSmrg# func_run_hooks FUNC_NAME [ARG]...
15234a8d91dcSmrg# ---------------------------------
15244a8d91dcSmrg# Run all hook functions registered to FUNC_NAME.
15254a8d91dcSmrg# It is assumed that the list of hook functions contains nothing more
15264a8d91dcSmrg# than a whitespace-delimited list of legal shell function names, and
15274a8d91dcSmrg# no effort is wasted trying to catch shell meta-characters or preserve
15284a8d91dcSmrg# whitespace.
15294a8d91dcSmrgfunc_run_hooks ()
15304a8d91dcSmrg{
15314a8d91dcSmrg    $debug_cmd
15324a8d91dcSmrg
15334a8d91dcSmrg    case " $hookable_fns " in
15344a8d91dcSmrg      *" $1 "*) ;;
15354a8d91dcSmrg      *) func_fatal_error "'$1' does not support hook funcions.n" ;;
15364a8d91dcSmrg    esac
15374a8d91dcSmrg
15384a8d91dcSmrg    eval _G_hook_fns=\$$1_hooks; shift
15394a8d91dcSmrg
15404a8d91dcSmrg    for _G_hook in $_G_hook_fns; do
15414a8d91dcSmrg      eval $_G_hook '"$@"'
15424a8d91dcSmrg
15434a8d91dcSmrg      # store returned options list back into positional
15444a8d91dcSmrg      # parameters for next 'cmd' execution.
15454a8d91dcSmrg      eval _G_hook_result=\$${_G_hook}_result
15464a8d91dcSmrg      eval set dummy "$_G_hook_result"; shift
15474a8d91dcSmrg    done
15484a8d91dcSmrg
15494a8d91dcSmrg    func_quote_for_eval ${1+"$@"}
15504a8d91dcSmrg    func_run_hooks_result=$func_quote_for_eval_result
15514a8d91dcSmrg}
15524a8d91dcSmrg
15534a8d91dcSmrg
15544a8d91dcSmrg
15554a8d91dcSmrg## --------------- ##
15564a8d91dcSmrg## Option parsing. ##
15574a8d91dcSmrg## --------------- ##
15584a8d91dcSmrg
15594a8d91dcSmrg# In order to add your own option parsing hooks, you must accept the
15604a8d91dcSmrg# full positional parameter list in your hook function, remove any
15614a8d91dcSmrg# options that you action, and then pass back the remaining unprocessed
15624a8d91dcSmrg# options in '<hooked_function_name>_result', escaped suitably for
15634a8d91dcSmrg# 'eval'.  Like this:
15644a8d91dcSmrg#
15654a8d91dcSmrg#    my_options_prep ()
15664a8d91dcSmrg#    {
15674a8d91dcSmrg#        $debug_cmd
15684a8d91dcSmrg#
15694a8d91dcSmrg#        # Extend the existing usage message.
15704a8d91dcSmrg#        usage_message=$usage_message'
15714a8d91dcSmrg#      -s, --silent       don'\''t print informational messages
15724a8d91dcSmrg#    '
15734a8d91dcSmrg#
15744a8d91dcSmrg#        func_quote_for_eval ${1+"$@"}
15754a8d91dcSmrg#        my_options_prep_result=$func_quote_for_eval_result
15764a8d91dcSmrg#    }
15774a8d91dcSmrg#    func_add_hook func_options_prep my_options_prep
15784a8d91dcSmrg#
15794a8d91dcSmrg#
15804a8d91dcSmrg#    my_silent_option ()
15814a8d91dcSmrg#    {
15824a8d91dcSmrg#        $debug_cmd
15834a8d91dcSmrg#
15844a8d91dcSmrg#        # Note that for efficiency, we parse as many options as we can
15854a8d91dcSmrg#        # recognise in a loop before passing the remainder back to the
15864a8d91dcSmrg#        # caller on the first unrecognised argument we encounter.
15874a8d91dcSmrg#        while test $# -gt 0; do
15884a8d91dcSmrg#          opt=$1; shift
15894a8d91dcSmrg#          case $opt in
15904a8d91dcSmrg#            --silent|-s) opt_silent=: ;;
15914a8d91dcSmrg#            # Separate non-argument short options:
15924a8d91dcSmrg#            -s*)         func_split_short_opt "$_G_opt"
15934a8d91dcSmrg#                         set dummy "$func_split_short_opt_name" \
15944a8d91dcSmrg#                             "-$func_split_short_opt_arg" ${1+"$@"}
15954a8d91dcSmrg#                         shift
15964a8d91dcSmrg#                         ;;
15974a8d91dcSmrg#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
15984a8d91dcSmrg#          esac
15994a8d91dcSmrg#        done
16004a8d91dcSmrg#
16014a8d91dcSmrg#        func_quote_for_eval ${1+"$@"}
16024a8d91dcSmrg#        my_silent_option_result=$func_quote_for_eval_result
16034a8d91dcSmrg#    }
16044a8d91dcSmrg#    func_add_hook func_parse_options my_silent_option
16054a8d91dcSmrg#
16064a8d91dcSmrg#
16074a8d91dcSmrg#    my_option_validation ()
16084a8d91dcSmrg#    {
16094a8d91dcSmrg#        $debug_cmd
16104a8d91dcSmrg#
16114a8d91dcSmrg#        $opt_silent && $opt_verbose && func_fatal_help "\
16124a8d91dcSmrg#    '--silent' and '--verbose' options are mutually exclusive."
16134a8d91dcSmrg#
16144a8d91dcSmrg#        func_quote_for_eval ${1+"$@"}
16154a8d91dcSmrg#        my_option_validation_result=$func_quote_for_eval_result
16164a8d91dcSmrg#    }
16174a8d91dcSmrg#    func_add_hook func_validate_options my_option_validation
16184a8d91dcSmrg#
16194a8d91dcSmrg# You'll alse need to manually amend $usage_message to reflect the extra
16204a8d91dcSmrg# options you parse.  It's preferable to append if you can, so that
16214a8d91dcSmrg# multiple option parsing hooks can be added safely.
16224a8d91dcSmrg
16234a8d91dcSmrg
16244a8d91dcSmrg# func_options [ARG]...
16254a8d91dcSmrg# ---------------------
16264a8d91dcSmrg# All the functions called inside func_options are hookable. See the
16274a8d91dcSmrg# individual implementations for details.
16284a8d91dcSmrgfunc_hookable func_options
16294a8d91dcSmrgfunc_options ()
163050806d53Smrg{
16314a8d91dcSmrg    $debug_cmd
1632af1a9c97Smrg
16334a8d91dcSmrg    func_options_prep ${1+"$@"}
16344a8d91dcSmrg    eval func_parse_options \
16354a8d91dcSmrg        ${func_options_prep_result+"$func_options_prep_result"}
16364a8d91dcSmrg    eval func_validate_options \
16374a8d91dcSmrg        ${func_parse_options_result+"$func_parse_options_result"}
1638b3e38ee4Smrg
16394a8d91dcSmrg    eval func_run_hooks func_options \
16404a8d91dcSmrg        ${func_validate_options_result+"$func_validate_options_result"}
16414a8d91dcSmrg
16424a8d91dcSmrg    # save modified positional parameters for caller
16434a8d91dcSmrg    func_options_result=$func_run_hooks_result
164450806d53Smrg}
164550806d53Smrg
1646b3e38ee4Smrg
16474a8d91dcSmrg# func_options_prep [ARG]...
16484a8d91dcSmrg# --------------------------
16494a8d91dcSmrg# All initialisations required before starting the option parse loop.
16504a8d91dcSmrg# Note that when calling hook functions, we pass through the list of
16514a8d91dcSmrg# positional parameters.  If a hook function modifies that list, and
16524a8d91dcSmrg# needs to propogate that back to rest of this script, then the complete
16534a8d91dcSmrg# modified list must be put in 'func_run_hooks_result' before
16544a8d91dcSmrg# returning.
16554a8d91dcSmrgfunc_hookable func_options_prep
16564a8d91dcSmrgfunc_options_prep ()
165750806d53Smrg{
16584a8d91dcSmrg    $debug_cmd
1659b3e38ee4Smrg
16604a8d91dcSmrg    # Option defaults:
16614a8d91dcSmrg    opt_verbose=false
16624a8d91dcSmrg    opt_warning_types=
1663b3e38ee4Smrg
16644a8d91dcSmrg    func_run_hooks func_options_prep ${1+"$@"}
16654a8d91dcSmrg
16664a8d91dcSmrg    # save modified positional parameters for caller
16674a8d91dcSmrg    func_options_prep_result=$func_run_hooks_result
1668b3e38ee4Smrg}
166950806d53Smrg
16704a8d91dcSmrg
16714a8d91dcSmrg# func_parse_options [ARG]...
16724a8d91dcSmrg# ---------------------------
16734a8d91dcSmrg# The main option parsing loop.
16744a8d91dcSmrgfunc_hookable func_parse_options
16754a8d91dcSmrgfunc_parse_options ()
1676a73423d7Smrg{
16774a8d91dcSmrg    $debug_cmd
16784a8d91dcSmrg
16794a8d91dcSmrg    func_parse_options_result=
16804a8d91dcSmrg
16814a8d91dcSmrg    # this just eases exit handling
16824a8d91dcSmrg    while test $# -gt 0; do
16834a8d91dcSmrg      # Defer to hook functions for initial option parsing, so they
16844a8d91dcSmrg      # get priority in the event of reusing an option name.
16854a8d91dcSmrg      func_run_hooks func_parse_options ${1+"$@"}
16864a8d91dcSmrg
16874a8d91dcSmrg      # Adjust func_parse_options positional parameters to match
16884a8d91dcSmrg      eval set dummy "$func_run_hooks_result"; shift
16894a8d91dcSmrg
16904a8d91dcSmrg      # Break out of the loop if we already parsed every option.
16914a8d91dcSmrg      test $# -gt 0 || break
16924a8d91dcSmrg
16934a8d91dcSmrg      _G_opt=$1
16944a8d91dcSmrg      shift
16954a8d91dcSmrg      case $_G_opt in
16964a8d91dcSmrg        --debug|-x)   debug_cmd='set -x'
16974a8d91dcSmrg                      func_echo "enabling shell trace mode"
16984a8d91dcSmrg                      $debug_cmd
16994a8d91dcSmrg                      ;;
17004a8d91dcSmrg
17014a8d91dcSmrg        --no-warnings|--no-warning|--no-warn)
17024a8d91dcSmrg                      set dummy --warnings none ${1+"$@"}
17034a8d91dcSmrg                      shift
17044a8d91dcSmrg		      ;;
17054a8d91dcSmrg
17064a8d91dcSmrg        --warnings|--warning|-W)
17074a8d91dcSmrg                      test $# = 0 && func_missing_arg $_G_opt && break
17084a8d91dcSmrg                      case " $warning_categories $1" in
17094a8d91dcSmrg                        *" $1 "*)
17104a8d91dcSmrg                          # trailing space prevents matching last $1 above
17114a8d91dcSmrg                          func_append_uniq opt_warning_types " $1"
17124a8d91dcSmrg                          ;;
17134a8d91dcSmrg                        *all)
17144a8d91dcSmrg                          opt_warning_types=$warning_categories
17154a8d91dcSmrg                          ;;
17164a8d91dcSmrg                        *none)
17174a8d91dcSmrg                          opt_warning_types=none
17184a8d91dcSmrg                          warning_func=:
17194a8d91dcSmrg                          ;;
17204a8d91dcSmrg                        *error)
17214a8d91dcSmrg                          opt_warning_types=$warning_categories
17224a8d91dcSmrg                          warning_func=func_fatal_error
17234a8d91dcSmrg                          ;;
17244a8d91dcSmrg                        *)
17254a8d91dcSmrg                          func_fatal_error \
17264a8d91dcSmrg                             "unsupported warning category: '$1'"
17274a8d91dcSmrg                          ;;
17284a8d91dcSmrg                      esac
17294a8d91dcSmrg                      shift
17304a8d91dcSmrg                      ;;
17314a8d91dcSmrg
17324a8d91dcSmrg        --verbose|-v) opt_verbose=: ;;
17334a8d91dcSmrg        --version)    func_version ;;
17344a8d91dcSmrg        -\?|-h)       func_usage ;;
17354a8d91dcSmrg        --help)       func_help ;;
17364a8d91dcSmrg
17374a8d91dcSmrg	# Separate optargs to long options (plugins may need this):
17384a8d91dcSmrg	--*=*)        func_split_equals "$_G_opt"
17394a8d91dcSmrg	              set dummy "$func_split_equals_lhs" \
17404a8d91dcSmrg                          "$func_split_equals_rhs" ${1+"$@"}
17414a8d91dcSmrg                      shift
17424a8d91dcSmrg                      ;;
17434a8d91dcSmrg
17444a8d91dcSmrg       # Separate optargs to short options:
17454a8d91dcSmrg        -W*)
17464a8d91dcSmrg                      func_split_short_opt "$_G_opt"
17474a8d91dcSmrg                      set dummy "$func_split_short_opt_name" \
17484a8d91dcSmrg                          "$func_split_short_opt_arg" ${1+"$@"}
17494a8d91dcSmrg                      shift
17504a8d91dcSmrg                      ;;
17514a8d91dcSmrg
17524a8d91dcSmrg        # Separate non-argument short options:
17534a8d91dcSmrg        -\?*|-h*|-v*|-x*)
17544a8d91dcSmrg                      func_split_short_opt "$_G_opt"
17554a8d91dcSmrg                      set dummy "$func_split_short_opt_name" \
17564a8d91dcSmrg                          "-$func_split_short_opt_arg" ${1+"$@"}
17574a8d91dcSmrg                      shift
17584a8d91dcSmrg                      ;;
17594a8d91dcSmrg
17604a8d91dcSmrg        --)           break ;;
17614a8d91dcSmrg        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
17624a8d91dcSmrg        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
17634a8d91dcSmrg      esac
17644a8d91dcSmrg    done
17654a8d91dcSmrg
17664a8d91dcSmrg    # save modified positional parameters for caller
17674a8d91dcSmrg    func_quote_for_eval ${1+"$@"}
17684a8d91dcSmrg    func_parse_options_result=$func_quote_for_eval_result
1769a73423d7Smrg}
1770b3e38ee4Smrg
1771b3e38ee4Smrg
17724a8d91dcSmrg# func_validate_options [ARG]...
17734a8d91dcSmrg# ------------------------------
17744a8d91dcSmrg# Perform any sanity checks on option settings and/or unconsumed
17754a8d91dcSmrg# arguments.
17764a8d91dcSmrgfunc_hookable func_validate_options
17774a8d91dcSmrgfunc_validate_options ()
1778b3e38ee4Smrg{
17794a8d91dcSmrg    $debug_cmd
1780a73423d7Smrg
17814a8d91dcSmrg    # Display all warnings if -W was not given.
17824a8d91dcSmrg    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
17834a8d91dcSmrg
17844a8d91dcSmrg    func_run_hooks func_validate_options ${1+"$@"}
17854a8d91dcSmrg
17864a8d91dcSmrg    # Bail if the options were screwed!
17874a8d91dcSmrg    $exit_cmd $EXIT_FAILURE
17884a8d91dcSmrg
17894a8d91dcSmrg    # save modified positional parameters for caller
17904a8d91dcSmrg    func_validate_options_result=$func_run_hooks_result
1791b3e38ee4Smrg}
1792b3e38ee4Smrg
17934a8d91dcSmrg
17944a8d91dcSmrg
17954a8d91dcSmrg## ----------------- ##
17964a8d91dcSmrg## Helper functions. ##
17974a8d91dcSmrg## ----------------- ##
17984a8d91dcSmrg
17994a8d91dcSmrg# This section contains the helper functions used by the rest of the
18004a8d91dcSmrg# hookable option parser framework in ascii-betical order.
18014a8d91dcSmrg
18024a8d91dcSmrg
18034a8d91dcSmrg# func_fatal_help ARG...
18044a8d91dcSmrg# ----------------------
18054a8d91dcSmrg# Echo program name prefixed message to standard error, followed by
18064a8d91dcSmrg# a help hint, and exit.
18074a8d91dcSmrgfunc_fatal_help ()
1808b3e38ee4Smrg{
18094a8d91dcSmrg    $debug_cmd
1810a73423d7Smrg
18114a8d91dcSmrg    eval \$ECHO \""Usage: $usage"\"
18124a8d91dcSmrg    eval \$ECHO \""$fatal_help"\"
18134a8d91dcSmrg    func_error ${1+"$@"}
18144a8d91dcSmrg    exit $EXIT_FAILURE
1815b3e38ee4Smrg}
1816b3e38ee4Smrg
18174a8d91dcSmrg
18184a8d91dcSmrg# func_help
18194a8d91dcSmrg# ---------
18204a8d91dcSmrg# Echo long help message to standard output and exit.
1821b3e38ee4Smrgfunc_help ()
1822b3e38ee4Smrg{
18234a8d91dcSmrg    $debug_cmd
18244a8d91dcSmrg
18254a8d91dcSmrg    func_usage_message
18264a8d91dcSmrg    $ECHO "$long_help_message"
18274a8d91dcSmrg    exit 0
1828b3e38ee4Smrg}
1829b3e38ee4Smrg
18304a8d91dcSmrg
18314a8d91dcSmrg# func_missing_arg ARGNAME
18324a8d91dcSmrg# ------------------------
1833b3e38ee4Smrg# Echo program name prefixed message to standard error and set global
1834b3e38ee4Smrg# exit_cmd.
1835b3e38ee4Smrgfunc_missing_arg ()
1836b3e38ee4Smrg{
18374a8d91dcSmrg    $debug_cmd
1838a73423d7Smrg
18394a8d91dcSmrg    func_error "Missing argument for '$1'."
1840b3e38ee4Smrg    exit_cmd=exit
184150806d53Smrg}
184250806d53Smrg
1843af1a9c97Smrg
18444a8d91dcSmrg# func_split_equals STRING
18454a8d91dcSmrg# ------------------------
18464a8d91dcSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
18474a8d91dcSmrg# splitting STRING at the '=' sign.
18484a8d91dcSmrgtest -z "$_G_HAVE_XSI_OPS" \
18494a8d91dcSmrg    && (eval 'x=a/b/c;
18504a8d91dcSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
18514a8d91dcSmrg    && _G_HAVE_XSI_OPS=yes
18524a8d91dcSmrg
18534a8d91dcSmrgif test yes = "$_G_HAVE_XSI_OPS"
18544a8d91dcSmrgthen
18554a8d91dcSmrg  # This is an XSI compatible shell, allowing a faster implementation...
18564a8d91dcSmrg  eval 'func_split_equals ()
18574a8d91dcSmrg  {
18584a8d91dcSmrg      $debug_cmd
18594a8d91dcSmrg
18604a8d91dcSmrg      func_split_equals_lhs=${1%%=*}
18614a8d91dcSmrg      func_split_equals_rhs=${1#*=}
18624a8d91dcSmrg      test "x$func_split_equals_lhs" = "x$1" \
18634a8d91dcSmrg        && func_split_equals_rhs=
18644a8d91dcSmrg  }'
18654a8d91dcSmrgelse
18664a8d91dcSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
18674a8d91dcSmrg  func_split_equals ()
18684a8d91dcSmrg  {
18694a8d91dcSmrg      $debug_cmd
18704a8d91dcSmrg
18714a8d91dcSmrg      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
18724a8d91dcSmrg      func_split_equals_rhs=
18734a8d91dcSmrg      test "x$func_split_equals_lhs" = "x$1" \
18744a8d91dcSmrg        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
18754a8d91dcSmrg  }
18764a8d91dcSmrgfi #func_split_equals
18774a8d91dcSmrg
18784a8d91dcSmrg
18794a8d91dcSmrg# func_split_short_opt SHORTOPT
18804a8d91dcSmrg# -----------------------------
1881a73423d7Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
1882a73423d7Smrg# variables after splitting SHORTOPT after the 2nd character.
18834a8d91dcSmrgif test yes = "$_G_HAVE_XSI_OPS"
18844a8d91dcSmrgthen
18854a8d91dcSmrg  # This is an XSI compatible shell, allowing a faster implementation...
18864a8d91dcSmrg  eval 'func_split_short_opt ()
18874a8d91dcSmrg  {
18884a8d91dcSmrg      $debug_cmd
18894a8d91dcSmrg
18904a8d91dcSmrg      func_split_short_opt_arg=${1#??}
18914a8d91dcSmrg      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
18924a8d91dcSmrg  }'
18934a8d91dcSmrgelse
18944a8d91dcSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
18954a8d91dcSmrg  func_split_short_opt ()
18964a8d91dcSmrg  {
18974a8d91dcSmrg      $debug_cmd
18984a8d91dcSmrg
18994a8d91dcSmrg      func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
19004a8d91dcSmrg      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
19014a8d91dcSmrg  }
19024a8d91dcSmrgfi #func_split_short_opt
19034a8d91dcSmrg
19044a8d91dcSmrg
19054a8d91dcSmrg# func_usage
19064a8d91dcSmrg# ----------
19074a8d91dcSmrg# Echo short help message to standard output and exit.
19084a8d91dcSmrgfunc_usage ()
1909a73423d7Smrg{
19104a8d91dcSmrg    $debug_cmd
1911af1a9c97Smrg
19124a8d91dcSmrg    func_usage_message
19134a8d91dcSmrg    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
19144a8d91dcSmrg    exit 0
19154a8d91dcSmrg}
1916a73423d7Smrg
1917a73423d7Smrg
19184a8d91dcSmrg# func_usage_message
19194a8d91dcSmrg# ------------------
19204a8d91dcSmrg# Echo short help message to standard output.
19214a8d91dcSmrgfunc_usage_message ()
1922a73423d7Smrg{
19234a8d91dcSmrg    $debug_cmd
1924a73423d7Smrg
19254a8d91dcSmrg    eval \$ECHO \""Usage: $usage"\"
19264a8d91dcSmrg    echo
19274a8d91dcSmrg    $SED -n 's|^# ||
19284a8d91dcSmrg        /^Written by/{
19294a8d91dcSmrg          x;p;x
19304a8d91dcSmrg        }
19314a8d91dcSmrg	h
19324a8d91dcSmrg	/^Written by/q' < "$progpath"
19334a8d91dcSmrg    echo
19344a8d91dcSmrg    eval \$ECHO \""$usage_message"\"
19354a8d91dcSmrg}
1936a73423d7Smrg
1937b3e38ee4Smrg
19384a8d91dcSmrg# func_version
19394a8d91dcSmrg# ------------
19404a8d91dcSmrg# Echo version message to standard output and exit.
19414a8d91dcSmrgfunc_version ()
19424a8d91dcSmrg{
19434a8d91dcSmrg    $debug_cmd
1944b3e38ee4Smrg
19454a8d91dcSmrg    printf '%s\n' "$progname $scriptversion"
19464a8d91dcSmrg    $SED -n '
19474a8d91dcSmrg        /(C)/!b go
19484a8d91dcSmrg        :more
19494a8d91dcSmrg        /\./!{
19504a8d91dcSmrg          N
19514a8d91dcSmrg          s|\n# | |
19524a8d91dcSmrg          b more
19534a8d91dcSmrg        }
19544a8d91dcSmrg        :go
19554a8d91dcSmrg        /^# Written by /,/# warranty; / {
19564a8d91dcSmrg          s|^# ||
19574a8d91dcSmrg          s|^# *$||
19584a8d91dcSmrg          s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
19594a8d91dcSmrg          p
19604a8d91dcSmrg        }
19614a8d91dcSmrg        /^# Written by / {
19624a8d91dcSmrg          s|^# ||
19634a8d91dcSmrg          p
19644a8d91dcSmrg        }
19654a8d91dcSmrg        /^warranty; /q' < "$progpath"
1966b3e38ee4Smrg
19674a8d91dcSmrg    exit $?
19684a8d91dcSmrg}
196950806d53Smrg
197050806d53Smrg
19714a8d91dcSmrg# Local variables:
19724a8d91dcSmrg# mode: shell-script
19734a8d91dcSmrg# sh-indentation: 2
19744a8d91dcSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
19754a8d91dcSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
19764a8d91dcSmrg# time-stamp-time-zone: "UTC"
19774a8d91dcSmrg# End:
197850806d53Smrg
19794a8d91dcSmrg# Set a version string.
19804a8d91dcSmrgscriptversion='(GNU libtool) 2.4.6'
1981af1a9c97Smrg
1982b3e38ee4Smrg
19834a8d91dcSmrg# func_echo ARG...
19844a8d91dcSmrg# ----------------
19854a8d91dcSmrg# Libtool also displays the current mode in messages, so override
19864a8d91dcSmrg# funclib.sh func_echo with this custom definition.
19874a8d91dcSmrgfunc_echo ()
1988a73423d7Smrg{
19894a8d91dcSmrg    $debug_cmd
1990a73423d7Smrg
19914a8d91dcSmrg    _G_message=$*
19924a8d91dcSmrg
19934a8d91dcSmrg    func_echo_IFS=$IFS
19944a8d91dcSmrg    IFS=$nl
19954a8d91dcSmrg    for _G_line in $_G_message; do
19964a8d91dcSmrg      IFS=$func_echo_IFS
19974a8d91dcSmrg      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
19984a8d91dcSmrg    done
19994a8d91dcSmrg    IFS=$func_echo_IFS
20004a8d91dcSmrg}
2001a73423d7Smrg
2002a73423d7Smrg
20034a8d91dcSmrg# func_warning ARG...
20044a8d91dcSmrg# -------------------
20054a8d91dcSmrg# Libtool warnings are not categorized, so override funclib.sh
20064a8d91dcSmrg# func_warning with this simpler definition.
20074a8d91dcSmrgfunc_warning ()
2008a73423d7Smrg{
20094a8d91dcSmrg    $debug_cmd
20104a8d91dcSmrg
20114a8d91dcSmrg    $warning_func ${1+"$@"}
20124a8d91dcSmrg}
20134a8d91dcSmrg
2014a73423d7Smrg
20154a8d91dcSmrg## ---------------- ##
20164a8d91dcSmrg## Options parsing. ##
20174a8d91dcSmrg## ---------------- ##
20184a8d91dcSmrg
20194a8d91dcSmrg# Hook in the functions to make sure our own options are parsed during
20204a8d91dcSmrg# the option parsing loop.
20214a8d91dcSmrg
20224a8d91dcSmrgusage='$progpath [OPTION]... [MODE-ARG]...'
20234a8d91dcSmrg
20244a8d91dcSmrg# Short help message in response to '-h'.
20254a8d91dcSmrgusage_message="Options:
20264a8d91dcSmrg       --config             show all configuration variables
20274a8d91dcSmrg       --debug              enable verbose shell tracing
20284a8d91dcSmrg   -n, --dry-run            display commands without modifying any files
20294a8d91dcSmrg       --features           display basic configuration information and exit
20304a8d91dcSmrg       --mode=MODE          use operation mode MODE
20314a8d91dcSmrg       --no-warnings        equivalent to '-Wnone'
20324a8d91dcSmrg       --preserve-dup-deps  don't remove duplicate dependency libraries
20334a8d91dcSmrg       --quiet, --silent    don't print informational messages
20344a8d91dcSmrg       --tag=TAG            use configuration variables from tag TAG
20354a8d91dcSmrg   -v, --verbose            print more informational messages than default
20364a8d91dcSmrg       --version            print version information
20374a8d91dcSmrg   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
20384a8d91dcSmrg   -h, --help, --help-all   print short, long, or detailed help message
20394a8d91dcSmrg"
2040a73423d7Smrg
20414a8d91dcSmrg# Additional text appended to 'usage_message' in response to '--help'.
20424a8d91dcSmrgfunc_help ()
2043a73423d7Smrg{
20444a8d91dcSmrg    $debug_cmd
20454a8d91dcSmrg
20464a8d91dcSmrg    func_usage_message
20474a8d91dcSmrg    $ECHO "$long_help_message
20484a8d91dcSmrg
20494a8d91dcSmrgMODE must be one of the following:
20504a8d91dcSmrg
20514a8d91dcSmrg       clean           remove files from the build directory
20524a8d91dcSmrg       compile         compile a source file into a libtool object
20534a8d91dcSmrg       execute         automatically set library path, then run a program
20544a8d91dcSmrg       finish          complete the installation of libtool libraries
20554a8d91dcSmrg       install         install libraries or executables
20564a8d91dcSmrg       link            create a library or an executable
20574a8d91dcSmrg       uninstall       remove libraries from an installed directory
20584a8d91dcSmrg
20594a8d91dcSmrgMODE-ARGS vary depending on the MODE.  When passed as first option,
20604a8d91dcSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
20614a8d91dcSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE.
20624a8d91dcSmrg
20634a8d91dcSmrgWhen reporting a bug, please describe a test case to reproduce it and
20644a8d91dcSmrginclude the following information:
20654a8d91dcSmrg
20664a8d91dcSmrg       host-triplet:   $host
20674a8d91dcSmrg       shell:          $SHELL
20684a8d91dcSmrg       compiler:       $LTCC
20694a8d91dcSmrg       compiler flags: $LTCFLAGS
20704a8d91dcSmrg       linker:         $LD (gnu? $with_gnu_ld)
20714a8d91dcSmrg       version:        $progname (GNU libtool) 2.4.6
20724a8d91dcSmrg       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
20734a8d91dcSmrg       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
20744a8d91dcSmrg
20754a8d91dcSmrgReport bugs to <bug-libtool@gnu.org>.
20764a8d91dcSmrgGNU libtool home page: <http://www.gnu.org/s/libtool/>.
20774a8d91dcSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>."
20784a8d91dcSmrg    exit 0
20794a8d91dcSmrg}
2080a73423d7Smrg
2081a73423d7Smrg
20824a8d91dcSmrg# func_lo2o OBJECT-NAME
20834a8d91dcSmrg# ---------------------
20844a8d91dcSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
20854a8d91dcSmrg# object suffix.
2086a73423d7Smrg
20874a8d91dcSmrglo2o=s/\\.lo\$/.$objext/
20884a8d91dcSmrgo2lo=s/\\.$objext\$/.lo/
2089a73423d7Smrg
20904a8d91dcSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
20914a8d91dcSmrg  eval 'func_lo2o ()
20924a8d91dcSmrg  {
20934a8d91dcSmrg    case $1 in
20944a8d91dcSmrg      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
20954a8d91dcSmrg      *   ) func_lo2o_result=$1               ;;
20964a8d91dcSmrg    esac
20974a8d91dcSmrg  }'
20984a8d91dcSmrg
20994a8d91dcSmrg  # func_xform LIBOBJ-OR-SOURCE
21004a8d91dcSmrg  # ---------------------------
21014a8d91dcSmrg  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
21024a8d91dcSmrg  # suffix to a '.lo' libtool-object suffix.
21034a8d91dcSmrg  eval 'func_xform ()
21044a8d91dcSmrg  {
21054a8d91dcSmrg    func_xform_result=${1%.*}.lo
21064a8d91dcSmrg  }'
21074a8d91dcSmrgelse
21084a8d91dcSmrg  # ...otherwise fall back to using sed.
21094a8d91dcSmrg  func_lo2o ()
21104a8d91dcSmrg  {
21114a8d91dcSmrg    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
21124a8d91dcSmrg  }
21134a8d91dcSmrg
21144a8d91dcSmrg  func_xform ()
21154a8d91dcSmrg  {
21164a8d91dcSmrg    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
21174a8d91dcSmrg  }
21184a8d91dcSmrgfi
2119a73423d7Smrg
2120a73423d7Smrg
21214a8d91dcSmrg# func_fatal_configuration ARG...
21224a8d91dcSmrg# -------------------------------
2123b3e38ee4Smrg# Echo program name prefixed message to standard error, followed by
2124b3e38ee4Smrg# a configuration failure hint, and exit.
2125b3e38ee4Smrgfunc_fatal_configuration ()
2126b3e38ee4Smrg{
21274a8d91dcSmrg    func__fatal_error ${1+"$@"} \
21284a8d91dcSmrg      "See the $PACKAGE documentation for more information." \
21294a8d91dcSmrg      "Fatal configuration error."
2130b3e38ee4Smrg}
21317965d9acSmrg
2132af1a9c97Smrg
2133b3e38ee4Smrg# func_config
21344a8d91dcSmrg# -----------
2135b3e38ee4Smrg# Display the configuration for all the tags in this script.
2136b3e38ee4Smrgfunc_config ()
2137b3e38ee4Smrg{
2138b3e38ee4Smrg    re_begincf='^# ### BEGIN LIBTOOL'
2139b3e38ee4Smrg    re_endcf='^# ### END LIBTOOL'
2140b3e38ee4Smrg
2141b3e38ee4Smrg    # Default configuration.
2142b3e38ee4Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
214350806d53Smrg
214450806d53Smrg    # Now print the configurations for the tags.
214550806d53Smrg    for tagname in $taglist; do
2146b3e38ee4Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
214750806d53Smrg    done
2148a18ebfb2Smrg
2149b3e38ee4Smrg    exit $?
2150b3e38ee4Smrg}
2151a18ebfb2Smrg
21524a8d91dcSmrg
2153b3e38ee4Smrg# func_features
21544a8d91dcSmrg# -------------
2155b3e38ee4Smrg# Display the features supported by this script.
2156b3e38ee4Smrgfunc_features ()
2157b3e38ee4Smrg{
2158a73423d7Smrg    echo "host: $host"
21594a8d91dcSmrg    if test yes = "$build_libtool_libs"; then
2160a73423d7Smrg      echo "enable shared libraries"
216150806d53Smrg    else
2162a73423d7Smrg      echo "disable shared libraries"
216350806d53Smrg    fi
21644a8d91dcSmrg    if test yes = "$build_old_libs"; then
2165a73423d7Smrg      echo "enable static libraries"
216650806d53Smrg    else
2167a73423d7Smrg      echo "disable static libraries"
216850806d53Smrg    fi
2169b3e38ee4Smrg
217050806d53Smrg    exit $?
2171b3e38ee4Smrg}
217250806d53Smrg
21734a8d91dcSmrg
21744a8d91dcSmrg# func_enable_tag TAGNAME
21754a8d91dcSmrg# -----------------------
2176b3e38ee4Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
2177b3e38ee4Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
2178b3e38ee4Smrg# variable here.
2179b3e38ee4Smrgfunc_enable_tag ()
2180b3e38ee4Smrg{
21814a8d91dcSmrg    # Global variable:
21824a8d91dcSmrg    tagname=$1
218350806d53Smrg
21844a8d91dcSmrg    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
21854a8d91dcSmrg    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
21864a8d91dcSmrg    sed_extractcf=/$re_begincf/,/$re_endcf/p
2187af1a9c97Smrg
21884a8d91dcSmrg    # Validate tagname.
21894a8d91dcSmrg    case $tagname in
21904a8d91dcSmrg      *[!-_A-Za-z0-9,/]*)
21914a8d91dcSmrg        func_fatal_error "invalid tag name: $tagname"
21924a8d91dcSmrg        ;;
21934a8d91dcSmrg    esac
219450806d53Smrg
21954a8d91dcSmrg    # Don't test for the "default" C tag, as we know it's
21964a8d91dcSmrg    # there but not specially marked.
21974a8d91dcSmrg    case $tagname in
21984a8d91dcSmrg        CC) ;;
2199b3e38ee4Smrg    *)
22004a8d91dcSmrg        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
22014a8d91dcSmrg	  taglist="$taglist $tagname"
22024a8d91dcSmrg
22034a8d91dcSmrg	  # Evaluate the configuration.  Be careful to quote the path
22044a8d91dcSmrg	  # and the sed script, to avoid splitting on whitespace, but
22054a8d91dcSmrg	  # also don't use non-portable quotes within backquotes within
22064a8d91dcSmrg	  # quotes we have to do it in 2 steps:
22074a8d91dcSmrg	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
22084a8d91dcSmrg	  eval "$extractedcf"
22094a8d91dcSmrg        else
22104a8d91dcSmrg	  func_error "ignoring unknown tag $tagname"
22114a8d91dcSmrg        fi
22124a8d91dcSmrg        ;;
22134a8d91dcSmrg    esac
2214b3e38ee4Smrg}
2215b3e38ee4Smrg
22164a8d91dcSmrg
2217a73423d7Smrg# func_check_version_match
22184a8d91dcSmrg# ------------------------
2219a73423d7Smrg# Ensure that we are using m4 macros, and libtool script from the same
2220a73423d7Smrg# release of libtool.
2221a73423d7Smrgfunc_check_version_match ()
2222b3e38ee4Smrg{
22234a8d91dcSmrg    if test "$package_revision" != "$macro_revision"; then
22244a8d91dcSmrg      if test "$VERSION" != "$macro_version"; then
22254a8d91dcSmrg        if test -z "$macro_version"; then
22264a8d91dcSmrg          cat >&2 <<_LT_EOF
2227a73423d7Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2228a73423d7Smrg$progname: definition of this LT_INIT comes from an older release.
2229a73423d7Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2230a73423d7Smrg$progname: and run autoconf again.
2231a73423d7Smrg_LT_EOF
22324a8d91dcSmrg        else
22334a8d91dcSmrg          cat >&2 <<_LT_EOF
2234a73423d7Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2235a73423d7Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
2236a73423d7Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2237a73423d7Smrg$progname: and run autoconf again.
2238a73423d7Smrg_LT_EOF
22394a8d91dcSmrg        fi
22404a8d91dcSmrg      else
22414a8d91dcSmrg        cat >&2 <<_LT_EOF
2242a73423d7Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
2243a73423d7Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
2244a73423d7Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
2245a73423d7Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
2246a73423d7Smrg_LT_EOF
22474a8d91dcSmrg      fi
2248a73423d7Smrg
22494a8d91dcSmrg      exit $EXIT_MISMATCH
22504a8d91dcSmrg    fi
2251a73423d7Smrg}
2252a73423d7Smrg
2253a73423d7Smrg
22544a8d91dcSmrg# libtool_options_prep [ARG]...
22554a8d91dcSmrg# -----------------------------
22564a8d91dcSmrg# Preparation for options parsed by libtool.
22574a8d91dcSmrglibtool_options_prep ()
22584a8d91dcSmrg{
22594a8d91dcSmrg    $debug_mode
2260a73423d7Smrg
22614a8d91dcSmrg    # Option defaults:
22624a8d91dcSmrg    opt_config=false
22634a8d91dcSmrg    opt_dlopen=
22644a8d91dcSmrg    opt_dry_run=false
22654a8d91dcSmrg    opt_help=false
22664a8d91dcSmrg    opt_mode=
22674a8d91dcSmrg    opt_preserve_dup_deps=false
22684a8d91dcSmrg    opt_quiet=false
2269a73423d7Smrg
22704a8d91dcSmrg    nonopt=
22714a8d91dcSmrg    preserve_args=
2272a73423d7Smrg
22734a8d91dcSmrg    # Shorthand for --mode=foo, only valid as the first argument
22744a8d91dcSmrg    case $1 in
22754a8d91dcSmrg    clean|clea|cle|cl)
22764a8d91dcSmrg      shift; set dummy --mode clean ${1+"$@"}; shift
22774a8d91dcSmrg      ;;
22784a8d91dcSmrg    compile|compil|compi|comp|com|co|c)
22794a8d91dcSmrg      shift; set dummy --mode compile ${1+"$@"}; shift
22804a8d91dcSmrg      ;;
22814a8d91dcSmrg    execute|execut|execu|exec|exe|ex|e)
22824a8d91dcSmrg      shift; set dummy --mode execute ${1+"$@"}; shift
22834a8d91dcSmrg      ;;
22844a8d91dcSmrg    finish|finis|fini|fin|fi|f)
22854a8d91dcSmrg      shift; set dummy --mode finish ${1+"$@"}; shift
22864a8d91dcSmrg      ;;
22874a8d91dcSmrg    install|instal|insta|inst|ins|in|i)
22884a8d91dcSmrg      shift; set dummy --mode install ${1+"$@"}; shift
22894a8d91dcSmrg      ;;
22904a8d91dcSmrg    link|lin|li|l)
22914a8d91dcSmrg      shift; set dummy --mode link ${1+"$@"}; shift
22924a8d91dcSmrg      ;;
22934a8d91dcSmrg    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
22944a8d91dcSmrg      shift; set dummy --mode uninstall ${1+"$@"}; shift
22954a8d91dcSmrg      ;;
22964a8d91dcSmrg    esac
22974a8d91dcSmrg
22984a8d91dcSmrg    # Pass back the list of options.
22994a8d91dcSmrg    func_quote_for_eval ${1+"$@"}
23004a8d91dcSmrg    libtool_options_prep_result=$func_quote_for_eval_result
23014a8d91dcSmrg}
23024a8d91dcSmrgfunc_add_hook func_options_prep libtool_options_prep
2303a18ebfb2Smrg
230450806d53Smrg
23054a8d91dcSmrg# libtool_parse_options [ARG]...
23064a8d91dcSmrg# ---------------------------------
23074a8d91dcSmrg# Provide handling for libtool specific options.
23084a8d91dcSmrglibtool_parse_options ()
2309a73423d7Smrg{
23104a8d91dcSmrg    $debug_cmd
2311b3e38ee4Smrg
23124a8d91dcSmrg    # Perform our own loop to consume as many options as possible in
23134a8d91dcSmrg    # each iteration.
23144a8d91dcSmrg    while test $# -gt 0; do
23154a8d91dcSmrg      _G_opt=$1
23164a8d91dcSmrg      shift
23174a8d91dcSmrg      case $_G_opt in
23184a8d91dcSmrg        --dry-run|--dryrun|-n)
23194a8d91dcSmrg                        opt_dry_run=:
23204a8d91dcSmrg                        ;;
23214a8d91dcSmrg
23224a8d91dcSmrg        --config)       func_config ;;
23234a8d91dcSmrg
23244a8d91dcSmrg        --dlopen|-dlopen)
23254a8d91dcSmrg                        opt_dlopen="${opt_dlopen+$opt_dlopen
23264a8d91dcSmrg}$1"
23274a8d91dcSmrg                        shift
23284a8d91dcSmrg                        ;;
23294a8d91dcSmrg
23304a8d91dcSmrg        --preserve-dup-deps)
23314a8d91dcSmrg                        opt_preserve_dup_deps=: ;;
23324a8d91dcSmrg
23334a8d91dcSmrg        --features)     func_features ;;
23344a8d91dcSmrg
23354a8d91dcSmrg        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
23364a8d91dcSmrg
23374a8d91dcSmrg        --help)         opt_help=: ;;
23384a8d91dcSmrg
23394a8d91dcSmrg        --help-all)     opt_help=': help-all' ;;
23404a8d91dcSmrg
23414a8d91dcSmrg        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
23424a8d91dcSmrg                        opt_mode=$1
23434a8d91dcSmrg                        case $1 in
23444a8d91dcSmrg                          # Valid mode arguments:
23454a8d91dcSmrg                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
23464a8d91dcSmrg
23474a8d91dcSmrg                          # Catch anything else as an error
23484a8d91dcSmrg                          *) func_error "invalid argument for $_G_opt"
23494a8d91dcSmrg                             exit_cmd=exit
23504a8d91dcSmrg                             break
23514a8d91dcSmrg                             ;;
23524a8d91dcSmrg                        esac
23534a8d91dcSmrg                        shift
23544a8d91dcSmrg                        ;;
23554a8d91dcSmrg
23564a8d91dcSmrg        --no-silent|--no-quiet)
23574a8d91dcSmrg                        opt_quiet=false
23584a8d91dcSmrg                        func_append preserve_args " $_G_opt"
23594a8d91dcSmrg                        ;;
23604a8d91dcSmrg
23614a8d91dcSmrg        --no-warnings|--no-warning|--no-warn)
23624a8d91dcSmrg                        opt_warning=false
23634a8d91dcSmrg                        func_append preserve_args " $_G_opt"
23644a8d91dcSmrg                        ;;
23654a8d91dcSmrg
23664a8d91dcSmrg        --no-verbose)
23674a8d91dcSmrg                        opt_verbose=false
23684a8d91dcSmrg                        func_append preserve_args " $_G_opt"
23694a8d91dcSmrg                        ;;
23704a8d91dcSmrg
23714a8d91dcSmrg        --silent|--quiet)
23724a8d91dcSmrg                        opt_quiet=:
23734a8d91dcSmrg                        opt_verbose=false
23744a8d91dcSmrg                        func_append preserve_args " $_G_opt"
23754a8d91dcSmrg                        ;;
23764a8d91dcSmrg
23774a8d91dcSmrg        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
23784a8d91dcSmrg                        opt_tag=$1
23794a8d91dcSmrg                        func_append preserve_args " $_G_opt $1"
23804a8d91dcSmrg                        func_enable_tag "$1"
23814a8d91dcSmrg                        shift
23824a8d91dcSmrg                        ;;
23834a8d91dcSmrg
23844a8d91dcSmrg        --verbose|-v)   opt_quiet=false
23854a8d91dcSmrg                        opt_verbose=:
23864a8d91dcSmrg                        func_append preserve_args " $_G_opt"
23874a8d91dcSmrg                        ;;
23884a8d91dcSmrg
23894a8d91dcSmrg	# An option not handled by this hook function:
23904a8d91dcSmrg        *)		set dummy "$_G_opt" ${1+"$@"};	shift; break  ;;
23914a8d91dcSmrg      esac
23924a8d91dcSmrg    done
2393a73423d7Smrg
2394a73423d7Smrg
23954a8d91dcSmrg    # save modified positional parameters for caller
23964a8d91dcSmrg    func_quote_for_eval ${1+"$@"}
23974a8d91dcSmrg    libtool_parse_options_result=$func_quote_for_eval_result
23984a8d91dcSmrg}
23994a8d91dcSmrgfunc_add_hook func_parse_options libtool_parse_options
2400b3e38ee4Smrg
2401af1a9c97Smrg
2402b3e38ee4Smrg
24034a8d91dcSmrg# libtool_validate_options [ARG]...
24044a8d91dcSmrg# ---------------------------------
24054a8d91dcSmrg# Perform any sanity checks on option settings and/or unconsumed
24064a8d91dcSmrg# arguments.
24074a8d91dcSmrglibtool_validate_options ()
24084a8d91dcSmrg{
24094a8d91dcSmrg    # save first non-option argument
24104a8d91dcSmrg    if test 0 -lt $#; then
24114a8d91dcSmrg      nonopt=$1
24124a8d91dcSmrg      shift
2413b3e38ee4Smrg    fi
2414b3e38ee4Smrg
24154a8d91dcSmrg    # preserve --debug
24164a8d91dcSmrg    test : = "$debug_cmd" || func_append preserve_args " --debug"
2417b3e38ee4Smrg
24184a8d91dcSmrg    case $host in
24194a8d91dcSmrg      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
24204a8d91dcSmrg      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
24214a8d91dcSmrg      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
24224a8d91dcSmrg        # don't eliminate duplications in $postdeps and $predeps
24234a8d91dcSmrg        opt_duplicate_compiler_generated_deps=:
24244a8d91dcSmrg        ;;
24254a8d91dcSmrg      *)
24264a8d91dcSmrg        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
24274a8d91dcSmrg        ;;
24284a8d91dcSmrg    esac
242950806d53Smrg
24304a8d91dcSmrg    $opt_help || {
24314a8d91dcSmrg      # Sanity checks first:
24324a8d91dcSmrg      func_check_version_match
2433b3e38ee4Smrg
24344a8d91dcSmrg      test yes != "$build_libtool_libs" \
24354a8d91dcSmrg        && test yes != "$build_old_libs" \
24364a8d91dcSmrg        && func_fatal_configuration "not configured to build any kind of library"
2437b3e38ee4Smrg
24384a8d91dcSmrg      # Darwin sucks
24394a8d91dcSmrg      eval std_shrext=\"$shrext_cmds\"
24404a8d91dcSmrg
24414a8d91dcSmrg      # Only execute mode is allowed to have -dlopen flags.
24424a8d91dcSmrg      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
24434a8d91dcSmrg        func_error "unrecognized option '-dlopen'"
24444a8d91dcSmrg        $ECHO "$help" 1>&2
24454a8d91dcSmrg        exit $EXIT_FAILURE
24464a8d91dcSmrg      fi
24474a8d91dcSmrg
24484a8d91dcSmrg      # Change the help message to a mode-specific one.
24494a8d91dcSmrg      generic_help=$help
24504a8d91dcSmrg      help="Try '$progname --help --mode=$opt_mode' for more information."
24514a8d91dcSmrg    }
24524a8d91dcSmrg
24534a8d91dcSmrg    # Pass back the unparsed argument list
24544a8d91dcSmrg    func_quote_for_eval ${1+"$@"}
24554a8d91dcSmrg    libtool_validate_options_result=$func_quote_for_eval_result
2456a73423d7Smrg}
24574a8d91dcSmrgfunc_add_hook func_validate_options libtool_validate_options
24584a8d91dcSmrg
2459b3e38ee4Smrg
24604a8d91dcSmrg# Process options as early as possible so that --help and --version
24614a8d91dcSmrg# can return quickly.
24624a8d91dcSmrgfunc_options ${1+"$@"}
24634a8d91dcSmrgeval set dummy "$func_options_result"; shift
2464b3e38ee4Smrg
246550806d53Smrg
246650806d53Smrg
2467a73423d7Smrg## ----------- ##
2468a73423d7Smrg##    Main.    ##
2469a73423d7Smrg## ----------- ##
247050806d53Smrg
24714a8d91dcSmrgmagic='%%%MAGIC variable%%%'
24724a8d91dcSmrgmagic_exe='%%%MAGIC EXE variable%%%'
24734a8d91dcSmrg
24744a8d91dcSmrg# Global variables.
24754a8d91dcSmrgextracted_archives=
24764a8d91dcSmrgextracted_serial=0
24774a8d91dcSmrg
24784a8d91dcSmrg# If this variable is set in any of the actions, the command in it
24794a8d91dcSmrg# will be execed at the end.  This prevents here-documents from being
24804a8d91dcSmrg# left over by shells.
24814a8d91dcSmrgexec_cmd=
24824a8d91dcSmrg
24834a8d91dcSmrg
24844a8d91dcSmrg# A function that is used when there is no print builtin or printf.
24854a8d91dcSmrgfunc_fallback_echo ()
24864a8d91dcSmrg{
24874a8d91dcSmrg  eval 'cat <<_LTECHO_EOF
24884a8d91dcSmrg$1
24894a8d91dcSmrg_LTECHO_EOF'
24904a8d91dcSmrg}
24914a8d91dcSmrg
24924a8d91dcSmrg# func_generated_by_libtool
24934a8d91dcSmrg# True iff stdin has been generated by Libtool. This function is only
24944a8d91dcSmrg# a basic sanity check; it will hardly flush out determined imposters.
24954a8d91dcSmrgfunc_generated_by_libtool_p ()
24964a8d91dcSmrg{
24974a8d91dcSmrg  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
24984a8d91dcSmrg}
24994a8d91dcSmrg
2500b3e38ee4Smrg# func_lalib_p file
25014a8d91dcSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
2502b3e38ee4Smrg# This function is only a basic sanity check; it will hardly flush out
2503b3e38ee4Smrg# determined imposters.
2504b3e38ee4Smrgfunc_lalib_p ()
2505b3e38ee4Smrg{
2506b3e38ee4Smrg    test -f "$1" &&
25074a8d91dcSmrg      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
2508b3e38ee4Smrg}
250950806d53Smrg
2510b3e38ee4Smrg# func_lalib_unsafe_p file
25114a8d91dcSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
2512b3e38ee4Smrg# This function implements the same check as func_lalib_p without
2513b3e38ee4Smrg# resorting to external programs.  To this end, it redirects stdin and
2514b3e38ee4Smrg# closes it afterwards, without saving the original file descriptor.
2515b3e38ee4Smrg# As a safety measure, use it only where a negative result would be
25164a8d91dcSmrg# fatal anyway.  Works if 'file' does not exist.
2517b3e38ee4Smrgfunc_lalib_unsafe_p ()
2518b3e38ee4Smrg{
2519b3e38ee4Smrg    lalib_p=no
2520b3e38ee4Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
2521b3e38ee4Smrg	for lalib_p_l in 1 2 3 4
2522b3e38ee4Smrg	do
2523b3e38ee4Smrg	    read lalib_p_line
25244a8d91dcSmrg	    case $lalib_p_line in
2525b3e38ee4Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
2526b3e38ee4Smrg	    esac
2527b3e38ee4Smrg	done
2528b3e38ee4Smrg	exec 0<&5 5<&-
2529b3e38ee4Smrg    fi
25304a8d91dcSmrg    test yes = "$lalib_p"
2531b3e38ee4Smrg}
253250806d53Smrg
2533b3e38ee4Smrg# func_ltwrapper_script_p file
2534b3e38ee4Smrg# True iff FILE is a libtool wrapper script
2535b3e38ee4Smrg# This function is only a basic sanity check; it will hardly flush out
2536b3e38ee4Smrg# determined imposters.
2537b3e38ee4Smrgfunc_ltwrapper_script_p ()
2538b3e38ee4Smrg{
25394a8d91dcSmrg    test -f "$1" &&
25404a8d91dcSmrg      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
2541b3e38ee4Smrg}
254250806d53Smrg
2543b3e38ee4Smrg# func_ltwrapper_executable_p file
2544b3e38ee4Smrg# True iff FILE is a libtool wrapper executable
2545b3e38ee4Smrg# This function is only a basic sanity check; it will hardly flush out
2546b3e38ee4Smrg# determined imposters.
2547b3e38ee4Smrgfunc_ltwrapper_executable_p ()
2548b3e38ee4Smrg{
2549b3e38ee4Smrg    func_ltwrapper_exec_suffix=
2550b3e38ee4Smrg    case $1 in
2551b3e38ee4Smrg    *.exe) ;;
2552b3e38ee4Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
2553b3e38ee4Smrg    esac
2554b3e38ee4Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
2555b3e38ee4Smrg}
2556af1a9c97Smrg
2557b3e38ee4Smrg# func_ltwrapper_scriptname file
2558b3e38ee4Smrg# Assumes file is an ltwrapper_executable
2559b3e38ee4Smrg# uses $file to determine the appropriate filename for a
2560b3e38ee4Smrg# temporary ltwrapper_script.
2561b3e38ee4Smrgfunc_ltwrapper_scriptname ()
2562b3e38ee4Smrg{
2563a73423d7Smrg    func_dirname_and_basename "$1" "" "."
2564a73423d7Smrg    func_stripname '' '.exe' "$func_basename_result"
25654a8d91dcSmrg    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
2566b3e38ee4Smrg}
2567b3e38ee4Smrg
2568b3e38ee4Smrg# func_ltwrapper_p file
2569b3e38ee4Smrg# True iff FILE is a libtool wrapper script or wrapper executable
2570b3e38ee4Smrg# This function is only a basic sanity check; it will hardly flush out
2571b3e38ee4Smrg# determined imposters.
2572b3e38ee4Smrgfunc_ltwrapper_p ()
2573b3e38ee4Smrg{
2574b3e38ee4Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
2575b3e38ee4Smrg}
2576b3e38ee4Smrg
2577b3e38ee4Smrg
2578b3e38ee4Smrg# func_execute_cmds commands fail_cmd
2579b3e38ee4Smrg# Execute tilde-delimited COMMANDS.
2580b3e38ee4Smrg# If FAIL_CMD is given, eval that upon failure.
2581b3e38ee4Smrg# FAIL_CMD may read-access the current command in variable CMD!
2582b3e38ee4Smrgfunc_execute_cmds ()
2583b3e38ee4Smrg{
25844a8d91dcSmrg    $debug_cmd
25854a8d91dcSmrg
2586b3e38ee4Smrg    save_ifs=$IFS; IFS='~'
2587b3e38ee4Smrg    for cmd in $1; do
25884a8d91dcSmrg      IFS=$sp$nl
2589b3e38ee4Smrg      eval cmd=\"$cmd\"
25904a8d91dcSmrg      IFS=$save_ifs
2591b3e38ee4Smrg      func_show_eval "$cmd" "${2-:}"
2592b3e38ee4Smrg    done
2593b3e38ee4Smrg    IFS=$save_ifs
2594b3e38ee4Smrg}
2595b3e38ee4Smrg
2596b3e38ee4Smrg
2597b3e38ee4Smrg# func_source file
2598b3e38ee4Smrg# Source FILE, adding directory component if necessary.
2599b3e38ee4Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
2600b3e38ee4Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
2601b3e38ee4Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
26024a8d91dcSmrg# 'FILE.' does not work on cygwin managed mounts.
2603b3e38ee4Smrgfunc_source ()
2604b3e38ee4Smrg{
26054a8d91dcSmrg    $debug_cmd
26064a8d91dcSmrg
2607b3e38ee4Smrg    case $1 in
2608b3e38ee4Smrg    */* | *\\*)	. "$1" ;;
2609b3e38ee4Smrg    *)		. "./$1" ;;
2610b3e38ee4Smrg    esac
2611b3e38ee4Smrg}
2612b3e38ee4Smrg
2613b3e38ee4Smrg
2614a73423d7Smrg# func_resolve_sysroot PATH
2615a73423d7Smrg# Replace a leading = in PATH with a sysroot.  Store the result into
2616a73423d7Smrg# func_resolve_sysroot_result
2617a73423d7Smrgfunc_resolve_sysroot ()
2618a73423d7Smrg{
2619a73423d7Smrg  func_resolve_sysroot_result=$1
2620a73423d7Smrg  case $func_resolve_sysroot_result in
2621a73423d7Smrg  =*)
2622a73423d7Smrg    func_stripname '=' '' "$func_resolve_sysroot_result"
2623a73423d7Smrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
2624a73423d7Smrg    ;;
2625a73423d7Smrg  esac
2626a73423d7Smrg}
2627a73423d7Smrg
2628a73423d7Smrg# func_replace_sysroot PATH
2629a73423d7Smrg# If PATH begins with the sysroot, replace it with = and
2630a73423d7Smrg# store the result into func_replace_sysroot_result.
2631a73423d7Smrgfunc_replace_sysroot ()
2632a73423d7Smrg{
26334a8d91dcSmrg  case $lt_sysroot:$1 in
2634a73423d7Smrg  ?*:"$lt_sysroot"*)
2635a73423d7Smrg    func_stripname "$lt_sysroot" '' "$1"
26364a8d91dcSmrg    func_replace_sysroot_result='='$func_stripname_result
2637a73423d7Smrg    ;;
2638a73423d7Smrg  *)
2639a73423d7Smrg    # Including no sysroot.
2640a73423d7Smrg    func_replace_sysroot_result=$1
2641a73423d7Smrg    ;;
2642a73423d7Smrg  esac
2643a73423d7Smrg}
2644a73423d7Smrg
2645b3e38ee4Smrg# func_infer_tag arg
2646b3e38ee4Smrg# Infer tagged configuration to use if any are available and
2647b3e38ee4Smrg# if one wasn't chosen via the "--tag" command line option.
2648b3e38ee4Smrg# Only attempt this if the compiler in the base compile
2649b3e38ee4Smrg# command doesn't match the default compiler.
2650b3e38ee4Smrg# arg is usually of the form 'gcc ...'
2651b3e38ee4Smrgfunc_infer_tag ()
2652b3e38ee4Smrg{
26534a8d91dcSmrg    $debug_cmd
26544a8d91dcSmrg
2655b3e38ee4Smrg    if test -n "$available_tags" && test -z "$tagname"; then
2656b3e38ee4Smrg      CC_quoted=
2657b3e38ee4Smrg      for arg in $CC; do
2658a73423d7Smrg	func_append_quoted CC_quoted "$arg"
2659b3e38ee4Smrg      done
2660a73423d7Smrg      CC_expanded=`func_echo_all $CC`
2661a73423d7Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
2662b3e38ee4Smrg      case $@ in
2663b3e38ee4Smrg      # Blanks in the command may have been stripped by the calling shell,
2664b3e38ee4Smrg      # but not from the CC environment variable when configure was run.
2665a73423d7Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2666a73423d7Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
2667b3e38ee4Smrg      # Blanks at the start of $base_compile will cause this to fail
2668b3e38ee4Smrg      # if we don't check for them as well.
2669b3e38ee4Smrg      *)
2670b3e38ee4Smrg	for z in $available_tags; do
2671b3e38ee4Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
2672b3e38ee4Smrg	    # Evaluate the configuration.
26734a8d91dcSmrg	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
2674b3e38ee4Smrg	    CC_quoted=
2675b3e38ee4Smrg	    for arg in $CC; do
2676b3e38ee4Smrg	      # Double-quote args containing other shell metacharacters.
2677a73423d7Smrg	      func_append_quoted CC_quoted "$arg"
2678b3e38ee4Smrg	    done
2679a73423d7Smrg	    CC_expanded=`func_echo_all $CC`
2680a73423d7Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
2681b3e38ee4Smrg	    case "$@ " in
2682a73423d7Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2683a73423d7Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
2684b3e38ee4Smrg	      # The compiler in the base compile command matches
2685b3e38ee4Smrg	      # the one in the tagged configuration.
2686b3e38ee4Smrg	      # Assume this is the tagged configuration we want.
2687b3e38ee4Smrg	      tagname=$z
2688b3e38ee4Smrg	      break
2689b3e38ee4Smrg	      ;;
2690b3e38ee4Smrg	    esac
2691b3e38ee4Smrg	  fi
2692b3e38ee4Smrg	done
2693b3e38ee4Smrg	# If $tagname still isn't set, then no tagged configuration
2694b3e38ee4Smrg	# was found and let the user know that the "--tag" command
2695b3e38ee4Smrg	# line option must be used.
2696b3e38ee4Smrg	if test -z "$tagname"; then
2697b3e38ee4Smrg	  func_echo "unable to infer tagged configuration"
26984a8d91dcSmrg	  func_fatal_error "specify a tag with '--tag'"
2699b3e38ee4Smrg#	else
2700b3e38ee4Smrg#	  func_verbose "using $tagname tagged configuration"
2701b3e38ee4Smrg	fi
2702b3e38ee4Smrg	;;
2703b3e38ee4Smrg      esac
2704b3e38ee4Smrg    fi
2705b3e38ee4Smrg}
2706b3e38ee4Smrg
2707b3e38ee4Smrg
2708b3e38ee4Smrg
2709b3e38ee4Smrg# func_write_libtool_object output_name pic_name nonpic_name
2710b3e38ee4Smrg# Create a libtool object file (analogous to a ".la" file),
2711b3e38ee4Smrg# but don't create it if we're doing a dry run.
2712b3e38ee4Smrgfunc_write_libtool_object ()
2713b3e38ee4Smrg{
27144a8d91dcSmrg    write_libobj=$1
27154a8d91dcSmrg    if test yes = "$build_libtool_libs"; then
27164a8d91dcSmrg      write_lobj=\'$2\'
2717b3e38ee4Smrg    else
2718b3e38ee4Smrg      write_lobj=none
2719b3e38ee4Smrg    fi
2720b3e38ee4Smrg
27214a8d91dcSmrg    if test yes = "$build_old_libs"; then
27224a8d91dcSmrg      write_oldobj=\'$3\'
2723b3e38ee4Smrg    else
2724b3e38ee4Smrg      write_oldobj=none
2725b3e38ee4Smrg    fi
2726b3e38ee4Smrg
2727b3e38ee4Smrg    $opt_dry_run || {
2728b3e38ee4Smrg      cat >${write_libobj}T <<EOF
2729b3e38ee4Smrg# $write_libobj - a libtool object file
27304a8d91dcSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
2731b3e38ee4Smrg#
2732b3e38ee4Smrg# Please DO NOT delete this file!
2733b3e38ee4Smrg# It is necessary for linking the library.
2734b3e38ee4Smrg
2735b3e38ee4Smrg# Name of the PIC object.
2736b3e38ee4Smrgpic_object=$write_lobj
2737b3e38ee4Smrg
2738b3e38ee4Smrg# Name of the non-PIC object
2739b3e38ee4Smrgnon_pic_object=$write_oldobj
2740b3e38ee4Smrg
2741b3e38ee4SmrgEOF
27424a8d91dcSmrg      $MV "${write_libobj}T" "$write_libobj"
2743b3e38ee4Smrg    }
2744b3e38ee4Smrg}
2745b3e38ee4Smrg
2746a73423d7Smrg
2747a73423d7Smrg##################################################
2748a73423d7Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
2749a73423d7Smrg##################################################
2750a73423d7Smrg
2751a73423d7Smrg# func_convert_core_file_wine_to_w32 ARG
2752a73423d7Smrg# Helper function used by file name conversion functions when $build is *nix,
2753a73423d7Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
2754a73423d7Smrg# correctly configured wine environment available, with the winepath program
2755a73423d7Smrg# in $build's $PATH.
2756a73423d7Smrg#
2757a73423d7Smrg# ARG is the $build file name to be converted to w32 format.
2758a73423d7Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
2759a73423d7Smrg# be empty on error (or when ARG is empty)
2760a73423d7Smrgfunc_convert_core_file_wine_to_w32 ()
2761a73423d7Smrg{
27624a8d91dcSmrg  $debug_cmd
27634a8d91dcSmrg
27644a8d91dcSmrg  func_convert_core_file_wine_to_w32_result=$1
2765a73423d7Smrg  if test -n "$1"; then
2766a73423d7Smrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
2767a73423d7Smrg    # are forced to check the contents of stdout. On the other hand, if the
2768a73423d7Smrg    # command is not found, the shell will set an exit code of 127 and print
2769a73423d7Smrg    # *an error message* to stdout. So we must check for both error code of
2770a73423d7Smrg    # zero AND non-empty stdout, which explains the odd construction:
2771a73423d7Smrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
27724a8d91dcSmrg    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
2773a73423d7Smrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
27744a8d91dcSmrg        $SED -e "$sed_naive_backslashify"`
2775a73423d7Smrg    else
2776a73423d7Smrg      func_convert_core_file_wine_to_w32_result=
2777a73423d7Smrg    fi
2778a73423d7Smrg  fi
2779a73423d7Smrg}
2780a73423d7Smrg# end: func_convert_core_file_wine_to_w32
2781a73423d7Smrg
2782a73423d7Smrg
2783a73423d7Smrg# func_convert_core_path_wine_to_w32 ARG
2784a73423d7Smrg# Helper function used by path conversion functions when $build is *nix, and
2785a73423d7Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
2786a73423d7Smrg# configured wine environment available, with the winepath program in $build's
2787a73423d7Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
2788a73423d7Smrg#
2789a73423d7Smrg# ARG is path to be converted from $build format to win32.
2790a73423d7Smrg# Result is available in $func_convert_core_path_wine_to_w32_result.
2791a73423d7Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
2792a73423d7Smrg# are convertible, then the result may be empty.
2793a73423d7Smrgfunc_convert_core_path_wine_to_w32 ()
2794a73423d7Smrg{
27954a8d91dcSmrg  $debug_cmd
27964a8d91dcSmrg
2797a73423d7Smrg  # unfortunately, winepath doesn't convert paths, only file names
27984a8d91dcSmrg  func_convert_core_path_wine_to_w32_result=
2799a73423d7Smrg  if test -n "$1"; then
2800a73423d7Smrg    oldIFS=$IFS
2801a73423d7Smrg    IFS=:
2802a73423d7Smrg    for func_convert_core_path_wine_to_w32_f in $1; do
2803a73423d7Smrg      IFS=$oldIFS
2804a73423d7Smrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
28054a8d91dcSmrg      if test -n "$func_convert_core_file_wine_to_w32_result"; then
2806a73423d7Smrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
28074a8d91dcSmrg          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
2808a73423d7Smrg        else
2809a73423d7Smrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
2810a73423d7Smrg        fi
2811a73423d7Smrg      fi
2812a73423d7Smrg    done
2813a73423d7Smrg    IFS=$oldIFS
2814a73423d7Smrg  fi
2815a73423d7Smrg}
2816a73423d7Smrg# end: func_convert_core_path_wine_to_w32
2817a73423d7Smrg
2818a73423d7Smrg
2819a73423d7Smrg# func_cygpath ARGS...
2820a73423d7Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
2821a73423d7Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
2822a73423d7Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
2823a73423d7Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
2824a73423d7Smrg# file name or path is assumed to be in w32 format, as previously converted
2825a73423d7Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
2826a73423d7Smrg# or path in func_cygpath_result (input file name or path is assumed to be in
2827a73423d7Smrg# Cygwin format). Returns an empty string on error.
2828a73423d7Smrg#
2829a73423d7Smrg# ARGS are passed to cygpath, with the last one being the file name or path to
2830a73423d7Smrg# be converted.
2831a73423d7Smrg#
2832a73423d7Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
2833a73423d7Smrg# environment variable; do not put it in $PATH.
2834a73423d7Smrgfunc_cygpath ()
2835a73423d7Smrg{
28364a8d91dcSmrg  $debug_cmd
28374a8d91dcSmrg
2838a73423d7Smrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
2839a73423d7Smrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
2840a73423d7Smrg    if test "$?" -ne 0; then
2841a73423d7Smrg      # on failure, ensure result is empty
2842a73423d7Smrg      func_cygpath_result=
2843a73423d7Smrg    fi
2844a73423d7Smrg  else
2845a73423d7Smrg    func_cygpath_result=
28464a8d91dcSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
2847a73423d7Smrg  fi
2848a73423d7Smrg}
2849a73423d7Smrg#end: func_cygpath
2850a73423d7Smrg
2851a73423d7Smrg
2852a73423d7Smrg# func_convert_core_msys_to_w32 ARG
2853a73423d7Smrg# Convert file name or path ARG from MSYS format to w32 format.  Return
2854a73423d7Smrg# result in func_convert_core_msys_to_w32_result.
2855a73423d7Smrgfunc_convert_core_msys_to_w32 ()
2856a73423d7Smrg{
28574a8d91dcSmrg  $debug_cmd
28584a8d91dcSmrg
2859a73423d7Smrg  # awkward: cmd appends spaces to result
2860a73423d7Smrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
28614a8d91dcSmrg    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
2862a73423d7Smrg}
2863a73423d7Smrg#end: func_convert_core_msys_to_w32
2864a73423d7Smrg
2865a73423d7Smrg
2866a73423d7Smrg# func_convert_file_check ARG1 ARG2
2867a73423d7Smrg# Verify that ARG1 (a file name in $build format) was converted to $host
2868a73423d7Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
2869a73423d7Smrg# func_to_host_file_result to ARG1).
2870a73423d7Smrgfunc_convert_file_check ()
2871a73423d7Smrg{
28724a8d91dcSmrg  $debug_cmd
28734a8d91dcSmrg
28744a8d91dcSmrg  if test -z "$2" && test -n "$1"; then
2875a73423d7Smrg    func_error "Could not determine host file name corresponding to"
28764a8d91dcSmrg    func_error "  '$1'"
2877a73423d7Smrg    func_error "Continuing, but uninstalled executables may not work."
2878a73423d7Smrg    # Fallback:
28794a8d91dcSmrg    func_to_host_file_result=$1
2880a73423d7Smrg  fi
2881a73423d7Smrg}
2882a73423d7Smrg# end func_convert_file_check
2883a73423d7Smrg
2884a73423d7Smrg
2885a73423d7Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
2886a73423d7Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host
2887a73423d7Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
2888a73423d7Smrg# func_to_host_file_result to a simplistic fallback value (see below).
2889a73423d7Smrgfunc_convert_path_check ()
2890a73423d7Smrg{
28914a8d91dcSmrg  $debug_cmd
28924a8d91dcSmrg
2893a73423d7Smrg  if test -z "$4" && test -n "$3"; then
2894a73423d7Smrg    func_error "Could not determine the host path corresponding to"
28954a8d91dcSmrg    func_error "  '$3'"
2896a73423d7Smrg    func_error "Continuing, but uninstalled executables may not work."
2897a73423d7Smrg    # Fallback.  This is a deliberately simplistic "conversion" and
2898a73423d7Smrg    # should not be "improved".  See libtool.info.
2899a73423d7Smrg    if test "x$1" != "x$2"; then
2900a73423d7Smrg      lt_replace_pathsep_chars="s|$1|$2|g"
2901a73423d7Smrg      func_to_host_path_result=`echo "$3" |
2902a73423d7Smrg        $SED -e "$lt_replace_pathsep_chars"`
2903a73423d7Smrg    else
29044a8d91dcSmrg      func_to_host_path_result=$3
2905a73423d7Smrg    fi
2906a73423d7Smrg  fi
2907a73423d7Smrg}
2908a73423d7Smrg# end func_convert_path_check
2909a73423d7Smrg
2910a73423d7Smrg
2911a73423d7Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
2912a73423d7Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
2913a73423d7Smrg# and appending REPL if ORIG matches BACKPAT.
2914a73423d7Smrgfunc_convert_path_front_back_pathsep ()
2915a73423d7Smrg{
29164a8d91dcSmrg  $debug_cmd
29174a8d91dcSmrg
2918a73423d7Smrg  case $4 in
29194a8d91dcSmrg  $1 ) func_to_host_path_result=$3$func_to_host_path_result
2920a73423d7Smrg    ;;
2921a73423d7Smrg  esac
2922a73423d7Smrg  case $4 in
2923a73423d7Smrg  $2 ) func_append func_to_host_path_result "$3"
2924a73423d7Smrg    ;;
2925a73423d7Smrg  esac
2926a73423d7Smrg}
2927a73423d7Smrg# end func_convert_path_front_back_pathsep
2928a73423d7Smrg
2929a73423d7Smrg
2930a73423d7Smrg##################################################
2931a73423d7Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
2932a73423d7Smrg##################################################
29334a8d91dcSmrg# invoked via '$to_host_file_cmd ARG'
2934a73423d7Smrg#
2935a73423d7Smrg# In each case, ARG is the path to be converted from $build to $host format.
2936a73423d7Smrg# Result will be available in $func_to_host_file_result.
2937a73423d7Smrg
2938a73423d7Smrg
2939a73423d7Smrg# func_to_host_file ARG
2940a73423d7Smrg# Converts the file name ARG from $build format to $host format. Return result
2941a73423d7Smrg# in func_to_host_file_result.
2942a73423d7Smrgfunc_to_host_file ()
2943a73423d7Smrg{
29444a8d91dcSmrg  $debug_cmd
29454a8d91dcSmrg
2946a73423d7Smrg  $to_host_file_cmd "$1"
2947a73423d7Smrg}
2948a73423d7Smrg# end func_to_host_file
2949a73423d7Smrg
2950a73423d7Smrg
2951a73423d7Smrg# func_to_tool_file ARG LAZY
2952a73423d7Smrg# converts the file name ARG from $build format to toolchain format. Return
2953a73423d7Smrg# result in func_to_tool_file_result.  If the conversion in use is listed
2954a73423d7Smrg# in (the comma separated) LAZY, no conversion takes place.
2955a73423d7Smrgfunc_to_tool_file ()
2956a73423d7Smrg{
29574a8d91dcSmrg  $debug_cmd
29584a8d91dcSmrg
2959a73423d7Smrg  case ,$2, in
2960a73423d7Smrg    *,"$to_tool_file_cmd",*)
2961a73423d7Smrg      func_to_tool_file_result=$1
2962a73423d7Smrg      ;;
2963a73423d7Smrg    *)
2964a73423d7Smrg      $to_tool_file_cmd "$1"
2965a73423d7Smrg      func_to_tool_file_result=$func_to_host_file_result
2966a73423d7Smrg      ;;
2967a73423d7Smrg  esac
2968a73423d7Smrg}
2969a73423d7Smrg# end func_to_tool_file
2970a73423d7Smrg
2971a73423d7Smrg
2972a73423d7Smrg# func_convert_file_noop ARG
2973a73423d7Smrg# Copy ARG to func_to_host_file_result.
2974a73423d7Smrgfunc_convert_file_noop ()
2975a73423d7Smrg{
29764a8d91dcSmrg  func_to_host_file_result=$1
2977a73423d7Smrg}
2978a73423d7Smrg# end func_convert_file_noop
2979a73423d7Smrg
2980a73423d7Smrg
2981a73423d7Smrg# func_convert_file_msys_to_w32 ARG
2982a73423d7Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
2983a73423d7Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
2984a73423d7Smrg# func_to_host_file_result.
2985a73423d7Smrgfunc_convert_file_msys_to_w32 ()
2986a73423d7Smrg{
29874a8d91dcSmrg  $debug_cmd
29884a8d91dcSmrg
29894a8d91dcSmrg  func_to_host_file_result=$1
2990a73423d7Smrg  if test -n "$1"; then
2991a73423d7Smrg    func_convert_core_msys_to_w32 "$1"
29924a8d91dcSmrg    func_to_host_file_result=$func_convert_core_msys_to_w32_result
2993a73423d7Smrg  fi
2994a73423d7Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
2995a73423d7Smrg}
2996a73423d7Smrg# end func_convert_file_msys_to_w32
2997a73423d7Smrg
2998a73423d7Smrg
2999a73423d7Smrg# func_convert_file_cygwin_to_w32 ARG
3000a73423d7Smrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
3001a73423d7Smrg# func_to_host_file_result.
3002a73423d7Smrgfunc_convert_file_cygwin_to_w32 ()
3003a73423d7Smrg{
30044a8d91dcSmrg  $debug_cmd
30054a8d91dcSmrg
30064a8d91dcSmrg  func_to_host_file_result=$1
3007a73423d7Smrg  if test -n "$1"; then
3008a73423d7Smrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
3009a73423d7Smrg    # LT_CYGPATH in this case.
3010a73423d7Smrg    func_to_host_file_result=`cygpath -m "$1"`
3011a73423d7Smrg  fi
3012a73423d7Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3013a73423d7Smrg}
3014a73423d7Smrg# end func_convert_file_cygwin_to_w32
3015a73423d7Smrg
3016a73423d7Smrg
3017a73423d7Smrg# func_convert_file_nix_to_w32 ARG
3018a73423d7Smrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
3019a73423d7Smrg# and a working winepath. Returns result in func_to_host_file_result.
3020a73423d7Smrgfunc_convert_file_nix_to_w32 ()
3021a73423d7Smrg{
30224a8d91dcSmrg  $debug_cmd
30234a8d91dcSmrg
30244a8d91dcSmrg  func_to_host_file_result=$1
3025a73423d7Smrg  if test -n "$1"; then
3026a73423d7Smrg    func_convert_core_file_wine_to_w32 "$1"
30274a8d91dcSmrg    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
3028a73423d7Smrg  fi
3029a73423d7Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3030a73423d7Smrg}
3031a73423d7Smrg# end func_convert_file_nix_to_w32
3032a73423d7Smrg
3033a73423d7Smrg
3034a73423d7Smrg# func_convert_file_msys_to_cygwin ARG
3035a73423d7Smrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3036a73423d7Smrg# Returns result in func_to_host_file_result.
3037a73423d7Smrgfunc_convert_file_msys_to_cygwin ()
3038a73423d7Smrg{
30394a8d91dcSmrg  $debug_cmd
30404a8d91dcSmrg
30414a8d91dcSmrg  func_to_host_file_result=$1
3042a73423d7Smrg  if test -n "$1"; then
3043a73423d7Smrg    func_convert_core_msys_to_w32 "$1"
3044a73423d7Smrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
30454a8d91dcSmrg    func_to_host_file_result=$func_cygpath_result
3046a73423d7Smrg  fi
3047a73423d7Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3048a73423d7Smrg}
3049a73423d7Smrg# end func_convert_file_msys_to_cygwin
3050a73423d7Smrg
3051a73423d7Smrg
3052a73423d7Smrg# func_convert_file_nix_to_cygwin ARG
3053a73423d7Smrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
3054a73423d7Smrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
3055a73423d7Smrg# in func_to_host_file_result.
3056a73423d7Smrgfunc_convert_file_nix_to_cygwin ()
3057a73423d7Smrg{
30584a8d91dcSmrg  $debug_cmd
30594a8d91dcSmrg
30604a8d91dcSmrg  func_to_host_file_result=$1
3061a73423d7Smrg  if test -n "$1"; then
3062a73423d7Smrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
3063a73423d7Smrg    func_convert_core_file_wine_to_w32 "$1"
3064a73423d7Smrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
30654a8d91dcSmrg    func_to_host_file_result=$func_cygpath_result
3066a73423d7Smrg  fi
3067a73423d7Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3068a73423d7Smrg}
3069a73423d7Smrg# end func_convert_file_nix_to_cygwin
3070a73423d7Smrg
3071a73423d7Smrg
3072a73423d7Smrg#############################################
3073a73423d7Smrg# $build to $host PATH CONVERSION FUNCTIONS #
3074a73423d7Smrg#############################################
30754a8d91dcSmrg# invoked via '$to_host_path_cmd ARG'
3076a73423d7Smrg#
3077a73423d7Smrg# In each case, ARG is the path to be converted from $build to $host format.
3078a73423d7Smrg# The result will be available in $func_to_host_path_result.
3079a73423d7Smrg#
3080a73423d7Smrg# Path separators are also converted from $build format to $host format.  If
3081a73423d7Smrg# ARG begins or ends with a path separator character, it is preserved (but
3082a73423d7Smrg# converted to $host format) on output.
3083a73423d7Smrg#
3084a73423d7Smrg# All path conversion functions are named using the following convention:
3085a73423d7Smrg#   file name conversion function    : func_convert_file_X_to_Y ()
3086a73423d7Smrg#   path conversion function         : func_convert_path_X_to_Y ()
3087a73423d7Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the
3088a73423d7Smrg# same.  If conversion functions are added for new $build/$host combinations,
3089a73423d7Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
3090a73423d7Smrg# will break.
3091a73423d7Smrg
3092a73423d7Smrg
3093a73423d7Smrg# func_init_to_host_path_cmd
3094a73423d7Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
3095a73423d7Smrg# appropriate value, based on the value of $to_host_file_cmd.
3096a73423d7Smrgto_host_path_cmd=
3097a73423d7Smrgfunc_init_to_host_path_cmd ()
3098a73423d7Smrg{
30994a8d91dcSmrg  $debug_cmd
31004a8d91dcSmrg
3101a73423d7Smrg  if test -z "$to_host_path_cmd"; then
3102a73423d7Smrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
31034a8d91dcSmrg    to_host_path_cmd=func_convert_path_$func_stripname_result
3104a73423d7Smrg  fi
3105a73423d7Smrg}
3106a73423d7Smrg
3107a73423d7Smrg
3108a73423d7Smrg# func_to_host_path ARG
3109a73423d7Smrg# Converts the path ARG from $build format to $host format. Return result
3110a73423d7Smrg# in func_to_host_path_result.
3111a73423d7Smrgfunc_to_host_path ()
3112a73423d7Smrg{
31134a8d91dcSmrg  $debug_cmd
31144a8d91dcSmrg
3115a73423d7Smrg  func_init_to_host_path_cmd
3116a73423d7Smrg  $to_host_path_cmd "$1"
3117a73423d7Smrg}
3118a73423d7Smrg# end func_to_host_path
3119a73423d7Smrg
3120a73423d7Smrg
3121a73423d7Smrg# func_convert_path_noop ARG
3122a73423d7Smrg# Copy ARG to func_to_host_path_result.
3123a73423d7Smrgfunc_convert_path_noop ()
3124a73423d7Smrg{
31254a8d91dcSmrg  func_to_host_path_result=$1
3126a73423d7Smrg}
3127a73423d7Smrg# end func_convert_path_noop
3128a73423d7Smrg
3129a73423d7Smrg
3130a73423d7Smrg# func_convert_path_msys_to_w32 ARG
3131a73423d7Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
3132a73423d7Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
3133a73423d7Smrg# func_to_host_path_result.
3134a73423d7Smrgfunc_convert_path_msys_to_w32 ()
3135a73423d7Smrg{
31364a8d91dcSmrg  $debug_cmd
31374a8d91dcSmrg
31384a8d91dcSmrg  func_to_host_path_result=$1
3139a73423d7Smrg  if test -n "$1"; then
3140a73423d7Smrg    # Remove leading and trailing path separator characters from ARG.  MSYS
3141a73423d7Smrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
3142a73423d7Smrg    # and winepath ignores them completely.
3143a73423d7Smrg    func_stripname : : "$1"
3144a73423d7Smrg    func_to_host_path_tmp1=$func_stripname_result
3145a73423d7Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
31464a8d91dcSmrg    func_to_host_path_result=$func_convert_core_msys_to_w32_result
3147a73423d7Smrg    func_convert_path_check : ";" \
3148a73423d7Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3149a73423d7Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3150a73423d7Smrg  fi
3151a73423d7Smrg}
3152a73423d7Smrg# end func_convert_path_msys_to_w32
3153a73423d7Smrg
3154a73423d7Smrg
3155a73423d7Smrg# func_convert_path_cygwin_to_w32 ARG
3156a73423d7Smrg# Convert path ARG from Cygwin to w32 format.  Returns result in
3157a73423d7Smrg# func_to_host_file_result.
3158a73423d7Smrgfunc_convert_path_cygwin_to_w32 ()
3159a73423d7Smrg{
31604a8d91dcSmrg  $debug_cmd
31614a8d91dcSmrg
31624a8d91dcSmrg  func_to_host_path_result=$1
3163a73423d7Smrg  if test -n "$1"; then
3164a73423d7Smrg    # See func_convert_path_msys_to_w32:
3165a73423d7Smrg    func_stripname : : "$1"
3166a73423d7Smrg    func_to_host_path_tmp1=$func_stripname_result
3167a73423d7Smrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
3168a73423d7Smrg    func_convert_path_check : ";" \
3169a73423d7Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3170a73423d7Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3171a73423d7Smrg  fi
3172a73423d7Smrg}
3173a73423d7Smrg# end func_convert_path_cygwin_to_w32
3174a73423d7Smrg
3175a73423d7Smrg
3176a73423d7Smrg# func_convert_path_nix_to_w32 ARG
3177a73423d7Smrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
3178a73423d7Smrg# a working winepath.  Returns result in func_to_host_file_result.
3179a73423d7Smrgfunc_convert_path_nix_to_w32 ()
3180a73423d7Smrg{
31814a8d91dcSmrg  $debug_cmd
31824a8d91dcSmrg
31834a8d91dcSmrg  func_to_host_path_result=$1
3184a73423d7Smrg  if test -n "$1"; then
3185a73423d7Smrg    # See func_convert_path_msys_to_w32:
3186a73423d7Smrg    func_stripname : : "$1"
3187a73423d7Smrg    func_to_host_path_tmp1=$func_stripname_result
3188a73423d7Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
31894a8d91dcSmrg    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
3190a73423d7Smrg    func_convert_path_check : ";" \
3191a73423d7Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3192a73423d7Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3193a73423d7Smrg  fi
3194a73423d7Smrg}
3195a73423d7Smrg# end func_convert_path_nix_to_w32
3196a73423d7Smrg
3197a73423d7Smrg
3198a73423d7Smrg# func_convert_path_msys_to_cygwin ARG
3199a73423d7Smrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3200a73423d7Smrg# Returns result in func_to_host_file_result.
3201a73423d7Smrgfunc_convert_path_msys_to_cygwin ()
3202a73423d7Smrg{
32034a8d91dcSmrg  $debug_cmd
32044a8d91dcSmrg
32054a8d91dcSmrg  func_to_host_path_result=$1
3206a73423d7Smrg  if test -n "$1"; then
3207a73423d7Smrg    # See func_convert_path_msys_to_w32:
3208a73423d7Smrg    func_stripname : : "$1"
3209a73423d7Smrg    func_to_host_path_tmp1=$func_stripname_result
3210a73423d7Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3211a73423d7Smrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
32124a8d91dcSmrg    func_to_host_path_result=$func_cygpath_result
3213a73423d7Smrg    func_convert_path_check : : \
3214a73423d7Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3215a73423d7Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3216a73423d7Smrg  fi
3217a73423d7Smrg}
3218a73423d7Smrg# end func_convert_path_msys_to_cygwin
3219a73423d7Smrg
3220a73423d7Smrg
3221a73423d7Smrg# func_convert_path_nix_to_cygwin ARG
3222a73423d7Smrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
3223a73423d7Smrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
3224a73423d7Smrg# func_to_host_file_result.
3225a73423d7Smrgfunc_convert_path_nix_to_cygwin ()
3226a73423d7Smrg{
32274a8d91dcSmrg  $debug_cmd
32284a8d91dcSmrg
32294a8d91dcSmrg  func_to_host_path_result=$1
3230a73423d7Smrg  if test -n "$1"; then
3231a73423d7Smrg    # Remove leading and trailing path separator characters from
3232a73423d7Smrg    # ARG. msys behavior is inconsistent here, cygpath turns them
3233a73423d7Smrg    # into '.;' and ';.', and winepath ignores them completely.
3234a73423d7Smrg    func_stripname : : "$1"
3235a73423d7Smrg    func_to_host_path_tmp1=$func_stripname_result
3236a73423d7Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3237a73423d7Smrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
32384a8d91dcSmrg    func_to_host_path_result=$func_cygpath_result
3239a73423d7Smrg    func_convert_path_check : : \
3240a73423d7Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3241a73423d7Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3242a73423d7Smrg  fi
3243a73423d7Smrg}
3244a73423d7Smrg# end func_convert_path_nix_to_cygwin
3245a73423d7Smrg
3246a73423d7Smrg
32474a8d91dcSmrg# func_dll_def_p FILE
32484a8d91dcSmrg# True iff FILE is a Windows DLL '.def' file.
32494a8d91dcSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4
32504a8d91dcSmrgfunc_dll_def_p ()
32514a8d91dcSmrg{
32524a8d91dcSmrg  $debug_cmd
32534a8d91dcSmrg
32544a8d91dcSmrg  func_dll_def_p_tmp=`$SED -n \
32554a8d91dcSmrg    -e 's/^[	 ]*//' \
32564a8d91dcSmrg    -e '/^\(;.*\)*$/d' \
32574a8d91dcSmrg    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
32584a8d91dcSmrg    -e q \
32594a8d91dcSmrg    "$1"`
32604a8d91dcSmrg  test DEF = "$func_dll_def_p_tmp"
32614a8d91dcSmrg}
32624a8d91dcSmrg
32634a8d91dcSmrg
3264b3e38ee4Smrg# func_mode_compile arg...
3265b3e38ee4Smrgfunc_mode_compile ()
3266b3e38ee4Smrg{
32674a8d91dcSmrg    $debug_cmd
32684a8d91dcSmrg
3269b3e38ee4Smrg    # Get the compilation command and the source file.
3270b3e38ee4Smrg    base_compile=
32714a8d91dcSmrg    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
3272b3e38ee4Smrg    suppress_opt=yes
3273b3e38ee4Smrg    suppress_output=
3274b3e38ee4Smrg    arg_mode=normal
3275b3e38ee4Smrg    libobj=
3276b3e38ee4Smrg    later=
3277b3e38ee4Smrg    pie_flag=
3278b3e38ee4Smrg
3279b3e38ee4Smrg    for arg
3280b3e38ee4Smrg    do
3281b3e38ee4Smrg      case $arg_mode in
3282b3e38ee4Smrg      arg  )
3283b3e38ee4Smrg	# do not "continue".  Instead, add this to base_compile
32844a8d91dcSmrg	lastarg=$arg
3285b3e38ee4Smrg	arg_mode=normal
3286b3e38ee4Smrg	;;
3287b3e38ee4Smrg
3288b3e38ee4Smrg      target )
32894a8d91dcSmrg	libobj=$arg
3290b3e38ee4Smrg	arg_mode=normal
3291b3e38ee4Smrg	continue
3292b3e38ee4Smrg	;;
3293b3e38ee4Smrg
3294b3e38ee4Smrg      normal )
3295b3e38ee4Smrg	# Accept any command-line options.
3296b3e38ee4Smrg	case $arg in
3297b3e38ee4Smrg	-o)
3298b3e38ee4Smrg	  test -n "$libobj" && \
32994a8d91dcSmrg	    func_fatal_error "you cannot specify '-o' more than once"
3300b3e38ee4Smrg	  arg_mode=target
3301b3e38ee4Smrg	  continue
3302b3e38ee4Smrg	  ;;
3303b3e38ee4Smrg
3304b3e38ee4Smrg	-pie | -fpie | -fPIE)
3305a73423d7Smrg          func_append pie_flag " $arg"
3306b3e38ee4Smrg	  continue
3307b3e38ee4Smrg	  ;;
3308b3e38ee4Smrg
3309b3e38ee4Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
3310a73423d7Smrg	  func_append later " $arg"
3311b3e38ee4Smrg	  continue
3312b3e38ee4Smrg	  ;;
3313b3e38ee4Smrg
3314b3e38ee4Smrg	-no-suppress)
331550806d53Smrg	  suppress_opt=no
331650806d53Smrg	  continue
331750806d53Smrg	  ;;
331850806d53Smrg
331950806d53Smrg	-Xcompiler)
332050806d53Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
332150806d53Smrg	  continue      #  The current "srcfile" will either be retained or
332250806d53Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
332350806d53Smrg
332450806d53Smrg	-Wc,*)
3325b3e38ee4Smrg	  func_stripname '-Wc,' '' "$arg"
3326b3e38ee4Smrg	  args=$func_stripname_result
332750806d53Smrg	  lastarg=
33284a8d91dcSmrg	  save_ifs=$IFS; IFS=,
3329b3e38ee4Smrg	  for arg in $args; do
33304a8d91dcSmrg	    IFS=$save_ifs
3331a73423d7Smrg	    func_append_quoted lastarg "$arg"
333250806d53Smrg	  done
33334a8d91dcSmrg	  IFS=$save_ifs
3334b3e38ee4Smrg	  func_stripname ' ' '' "$lastarg"
3335b3e38ee4Smrg	  lastarg=$func_stripname_result
333650806d53Smrg
333750806d53Smrg	  # Add the arguments to base_compile.
3338a73423d7Smrg	  func_append base_compile " $lastarg"
333950806d53Smrg	  continue
334050806d53Smrg	  ;;
334150806d53Smrg
3342b3e38ee4Smrg	*)
334350806d53Smrg	  # Accept the current argument as the source file.
334450806d53Smrg	  # The previous "srcfile" becomes the current argument.
334550806d53Smrg	  #
33464a8d91dcSmrg	  lastarg=$srcfile
33474a8d91dcSmrg	  srcfile=$arg
334850806d53Smrg	  ;;
334950806d53Smrg	esac  #  case $arg
335050806d53Smrg	;;
335150806d53Smrg      esac    #  case $arg_mode
335250806d53Smrg
335350806d53Smrg      # Aesthetically quote the previous argument.
3354a73423d7Smrg      func_append_quoted base_compile "$lastarg"
335550806d53Smrg    done # for arg
335650806d53Smrg
335750806d53Smrg    case $arg_mode in
335850806d53Smrg    arg)
3359b3e38ee4Smrg      func_fatal_error "you must specify an argument for -Xcompile"
336050806d53Smrg      ;;
336150806d53Smrg    target)
33624a8d91dcSmrg      func_fatal_error "you must specify a target with '-o'"
336350806d53Smrg      ;;
336450806d53Smrg    *)
336550806d53Smrg      # Get the name of the library object.
3366b3e38ee4Smrg      test -z "$libobj" && {
3367b3e38ee4Smrg	func_basename "$srcfile"
33684a8d91dcSmrg	libobj=$func_basename_result
3369b3e38ee4Smrg      }
337050806d53Smrg      ;;
337150806d53Smrg    esac
337250806d53Smrg
337350806d53Smrg    # Recognize several different file suffixes.
337450806d53Smrg    # If the user specifies -o file.o, it is replaced with file.lo
337550806d53Smrg    case $libobj in
3376b3e38ee4Smrg    *.[cCFSifmso] | \
3377b3e38ee4Smrg    *.ada | *.adb | *.ads | *.asm | \
3378b3e38ee4Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
3379a73423d7Smrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
3380b3e38ee4Smrg      func_xform "$libobj"
3381b3e38ee4Smrg      libobj=$func_xform_result
3382b3e38ee4Smrg      ;;
338350806d53Smrg    esac
338450806d53Smrg
338550806d53Smrg    case $libobj in
3386b3e38ee4Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
338750806d53Smrg    *)
33884a8d91dcSmrg      func_fatal_error "cannot determine name of library object from '$libobj'"
338950806d53Smrg      ;;
339050806d53Smrg    esac
339150806d53Smrg
339250806d53Smrg    func_infer_tag $base_compile
339350806d53Smrg
339450806d53Smrg    for arg in $later; do
339550806d53Smrg      case $arg in
3396b3e38ee4Smrg      -shared)
33974a8d91dcSmrg	test yes = "$build_libtool_libs" \
33984a8d91dcSmrg	  || func_fatal_configuration "cannot build a shared library"
3399b3e38ee4Smrg	build_old_libs=no
3400b3e38ee4Smrg	continue
3401b3e38ee4Smrg	;;
3402b3e38ee4Smrg
340350806d53Smrg      -static)
3404b3e38ee4Smrg	build_libtool_libs=no
340550806d53Smrg	build_old_libs=yes
340650806d53Smrg	continue
340750806d53Smrg	;;
340850806d53Smrg
340950806d53Smrg      -prefer-pic)
341050806d53Smrg	pic_mode=yes
341150806d53Smrg	continue
341250806d53Smrg	;;
341350806d53Smrg
341450806d53Smrg      -prefer-non-pic)
341550806d53Smrg	pic_mode=no
341650806d53Smrg	continue
341750806d53Smrg	;;
341850806d53Smrg      esac
341950806d53Smrg    done
342050806d53Smrg
3421b3e38ee4Smrg    func_quote_for_eval "$libobj"
3422b3e38ee4Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
3423b3e38ee4Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
34244a8d91dcSmrg      && func_warning "libobj name '$libobj' may not contain shell special characters."
3425b3e38ee4Smrg    func_dirname_and_basename "$obj" "/" ""
34264a8d91dcSmrg    objname=$func_basename_result
34274a8d91dcSmrg    xdir=$func_dirname_result
34284a8d91dcSmrg    lobj=$xdir$objdir/$objname
342950806d53Smrg
3430b3e38ee4Smrg    test -z "$base_compile" && \
3431b3e38ee4Smrg      func_fatal_help "you must specify a compilation command"
343250806d53Smrg
343350806d53Smrg    # Delete any leftover library objects.
34344a8d91dcSmrg    if test yes = "$build_old_libs"; then
343550806d53Smrg      removelist="$obj $lobj $libobj ${libobj}T"
343650806d53Smrg    else
343750806d53Smrg      removelist="$lobj $libobj ${libobj}T"
343850806d53Smrg    fi
343950806d53Smrg
344050806d53Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
344150806d53Smrg    case $host_os in
3442b3e38ee4Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
344350806d53Smrg      pic_mode=default
344450806d53Smrg      ;;
344550806d53Smrg    esac
34464a8d91dcSmrg    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
344750806d53Smrg      # non-PIC code in shared libraries is not supported
344850806d53Smrg      pic_mode=default
344950806d53Smrg    fi
345050806d53Smrg
345150806d53Smrg    # Calculate the filename of the output object if compiler does
345250806d53Smrg    # not support -o with -c
34534a8d91dcSmrg    if test no = "$compiler_c_o"; then
34544a8d91dcSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
34554a8d91dcSmrg      lockfile=$output_obj.lock
345650806d53Smrg    else
345750806d53Smrg      output_obj=
345850806d53Smrg      need_locks=no
345950806d53Smrg      lockfile=
346050806d53Smrg    fi
346150806d53Smrg
346250806d53Smrg    # Lock this critical section if it is needed
346350806d53Smrg    # We use this script file to make the link, it avoids creating a new file
34644a8d91dcSmrg    if test yes = "$need_locks"; then
3465b3e38ee4Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3466b3e38ee4Smrg	func_echo "Waiting for $lockfile to be removed"
346750806d53Smrg	sleep 2
346850806d53Smrg      done
34694a8d91dcSmrg    elif test warn = "$need_locks"; then
347050806d53Smrg      if test -f "$lockfile"; then
3471b3e38ee4Smrg	$ECHO "\
347250806d53Smrg*** ERROR, $lockfile exists and contains:
347350806d53Smrg`cat $lockfile 2>/dev/null`
347450806d53Smrg
347550806d53SmrgThis indicates that another process is trying to use the same
347650806d53Smrgtemporary object file, and libtool could not work around it because
34774a8d91dcSmrgyour compiler does not support '-c' and '-o' together.  If you
347850806d53Smrgrepeat this compilation, it may succeed, by chance, but you had better
347950806d53Smrgavoid parallel builds (make -j) in this platform, or get a better
348050806d53Smrgcompiler."
348150806d53Smrg
3482b3e38ee4Smrg	$opt_dry_run || $RM $removelist
348350806d53Smrg	exit $EXIT_FAILURE
348450806d53Smrg      fi
3485a73423d7Smrg      func_append removelist " $output_obj"
3486b3e38ee4Smrg      $ECHO "$srcfile" > "$lockfile"
348750806d53Smrg    fi
348850806d53Smrg
3489b3e38ee4Smrg    $opt_dry_run || $RM $removelist
3490a73423d7Smrg    func_append removelist " $lockfile"
3491b3e38ee4Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
3492b3e38ee4Smrg
3493a73423d7Smrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
3494a73423d7Smrg    srcfile=$func_to_tool_file_result
3495b3e38ee4Smrg    func_quote_for_eval "$srcfile"
3496b3e38ee4Smrg    qsrcfile=$func_quote_for_eval_result
349750806d53Smrg
349850806d53Smrg    # Only build a PIC object if we are building libtool libraries.
34994a8d91dcSmrg    if test yes = "$build_libtool_libs"; then
350050806d53Smrg      # Without this assignment, base_compile gets emptied.
350150806d53Smrg      fbsd_hideous_sh_bug=$base_compile
350250806d53Smrg
35034a8d91dcSmrg      if test no != "$pic_mode"; then
350450806d53Smrg	command="$base_compile $qsrcfile $pic_flag"
350550806d53Smrg      else
350650806d53Smrg	# Don't build PIC code
350750806d53Smrg	command="$base_compile $qsrcfile"
350850806d53Smrg      fi
350950806d53Smrg
3510b3e38ee4Smrg      func_mkdir_p "$xdir$objdir"
351150806d53Smrg
351250806d53Smrg      if test -z "$output_obj"; then
351350806d53Smrg	# Place PIC objects in $objdir
3514a73423d7Smrg	func_append command " -o $lobj"
351550806d53Smrg      fi
351650806d53Smrg
3517b3e38ee4Smrg      func_show_eval_locale "$command"	\
3518b3e38ee4Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
351950806d53Smrg
35204a8d91dcSmrg      if test warn = "$need_locks" &&
352150806d53Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3522b3e38ee4Smrg	$ECHO "\
352350806d53Smrg*** ERROR, $lockfile contains:
352450806d53Smrg`cat $lockfile 2>/dev/null`
352550806d53Smrg
352650806d53Smrgbut it should contain:
352750806d53Smrg$srcfile
352850806d53Smrg
352950806d53SmrgThis indicates that another process is trying to use the same
353050806d53Smrgtemporary object file, and libtool could not work around it because
35314a8d91dcSmrgyour compiler does not support '-c' and '-o' together.  If you
353250806d53Smrgrepeat this compilation, it may succeed, by chance, but you had better
353350806d53Smrgavoid parallel builds (make -j) in this platform, or get a better
353450806d53Smrgcompiler."
353550806d53Smrg
3536b3e38ee4Smrg	$opt_dry_run || $RM $removelist
353750806d53Smrg	exit $EXIT_FAILURE
353850806d53Smrg      fi
353950806d53Smrg
354050806d53Smrg      # Just move the object if needed, then go on to compile the next one
354150806d53Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
3542b3e38ee4Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
3543b3e38ee4Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
354450806d53Smrg      fi
354550806d53Smrg
354650806d53Smrg      # Allow error messages only from the first compilation.
35474a8d91dcSmrg      if test yes = "$suppress_opt"; then
3548b3e38ee4Smrg	suppress_output=' >/dev/null 2>&1'
354950806d53Smrg      fi
355050806d53Smrg    fi
355150806d53Smrg
355250806d53Smrg    # Only build a position-dependent object if we build old libraries.
35534a8d91dcSmrg    if test yes = "$build_old_libs"; then
35544a8d91dcSmrg      if test yes != "$pic_mode"; then
355550806d53Smrg	# Don't build PIC code
3556b3e38ee4Smrg	command="$base_compile $qsrcfile$pie_flag"
355750806d53Smrg      else
355850806d53Smrg	command="$base_compile $qsrcfile $pic_flag"
355950806d53Smrg      fi
35604a8d91dcSmrg      if test yes = "$compiler_c_o"; then
3561a73423d7Smrg	func_append command " -o $obj"
356250806d53Smrg      fi
356350806d53Smrg
356450806d53Smrg      # Suppress compiler output if we already did a PIC compilation.
3565a73423d7Smrg      func_append command "$suppress_output"
3566b3e38ee4Smrg      func_show_eval_locale "$command" \
3567b3e38ee4Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
356850806d53Smrg
35694a8d91dcSmrg      if test warn = "$need_locks" &&
357050806d53Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3571b3e38ee4Smrg	$ECHO "\
357250806d53Smrg*** ERROR, $lockfile contains:
357350806d53Smrg`cat $lockfile 2>/dev/null`
357450806d53Smrg
357550806d53Smrgbut it should contain:
357650806d53Smrg$srcfile
357750806d53Smrg
357850806d53SmrgThis indicates that another process is trying to use the same
357950806d53Smrgtemporary object file, and libtool could not work around it because
35804a8d91dcSmrgyour compiler does not support '-c' and '-o' together.  If you
358150806d53Smrgrepeat this compilation, it may succeed, by chance, but you had better
358250806d53Smrgavoid parallel builds (make -j) in this platform, or get a better
358350806d53Smrgcompiler."
358450806d53Smrg
3585b3e38ee4Smrg	$opt_dry_run || $RM $removelist
358650806d53Smrg	exit $EXIT_FAILURE
358750806d53Smrg      fi
358850806d53Smrg
358950806d53Smrg      # Just move the object if needed
359050806d53Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
3591b3e38ee4Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
3592b3e38ee4Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
359350806d53Smrg      fi
359450806d53Smrg    fi
359550806d53Smrg
3596b3e38ee4Smrg    $opt_dry_run || {
3597b3e38ee4Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
359850806d53Smrg
3599b3e38ee4Smrg      # Unlock the critical section if it was locked
36004a8d91dcSmrg      if test no != "$need_locks"; then
3601b3e38ee4Smrg	removelist=$lockfile
3602b3e38ee4Smrg        $RM "$lockfile"
3603b3e38ee4Smrg      fi
3604b3e38ee4Smrg    }
360550806d53Smrg
360650806d53Smrg    exit $EXIT_SUCCESS
3607b3e38ee4Smrg}
360850806d53Smrg
3609b3e38ee4Smrg$opt_help || {
36104a8d91dcSmrg  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
3611b3e38ee4Smrg}
361250806d53Smrg
3613b3e38ee4Smrgfunc_mode_help ()
3614b3e38ee4Smrg{
3615b3e38ee4Smrg    # We need to display help for each of the modes.
3616a73423d7Smrg    case $opt_mode in
3617b3e38ee4Smrg      "")
3618b3e38ee4Smrg        # Generic help is extracted from the usage comments
3619b3e38ee4Smrg        # at the start of this file.
3620b3e38ee4Smrg        func_help
3621b3e38ee4Smrg        ;;
362250806d53Smrg
3623b3e38ee4Smrg      clean)
3624b3e38ee4Smrg        $ECHO \
3625b3e38ee4Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
362650806d53Smrg
3627b3e38ee4SmrgRemove files from the build directory.
362850806d53Smrg
3629b3e38ee4SmrgRM is the name of the program to use to delete files associated with each FILE
36304a8d91dcSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
3631b3e38ee4Smrgto RM.
363250806d53Smrg
3633b3e38ee4SmrgIf FILE is a libtool library, object or program, all the files associated
3634b3e38ee4Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
3635b3e38ee4Smrg        ;;
363650806d53Smrg
3637b3e38ee4Smrg      compile)
3638b3e38ee4Smrg      $ECHO \
3639b3e38ee4Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
364050806d53Smrg
3641b3e38ee4SmrgCompile a source file into a libtool library object.
364250806d53Smrg
3643b3e38ee4SmrgThis mode accepts the following additional options:
364450806d53Smrg
3645b3e38ee4Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
3646b3e38ee4Smrg  -no-suppress      do not suppress compiler output for multiple passes
3647a73423d7Smrg  -prefer-pic       try to build PIC objects only
3648a73423d7Smrg  -prefer-non-pic   try to build non-PIC objects only
36494a8d91dcSmrg  -shared           do not build a '.o' file suitable for static linking
36504a8d91dcSmrg  -static           only build a '.o' file suitable for static linking
3651a73423d7Smrg  -Wc,FLAG          pass FLAG directly to the compiler
365250806d53Smrg
36534a8d91dcSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file
3654b3e38ee4Smrgfrom the given SOURCEFILE.
365550806d53Smrg
3656b3e38ee4SmrgThe output file name is determined by removing the directory component from
36574a8d91dcSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the
36584a8d91dcSmrglibrary object suffix, '.lo'."
3659b3e38ee4Smrg        ;;
366050806d53Smrg
3661b3e38ee4Smrg      execute)
3662b3e38ee4Smrg        $ECHO \
3663b3e38ee4Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
366450806d53Smrg
3665b3e38ee4SmrgAutomatically set library path, then run a program.
366650806d53Smrg
3667b3e38ee4SmrgThis mode accepts the following additional options:
366850806d53Smrg
3669b3e38ee4Smrg  -dlopen FILE      add the directory containing FILE to the library path
367050806d53Smrg
36714a8d91dcSmrgThis mode sets the library path environment variable according to '-dlopen'
3672b3e38ee4Smrgflags.
367350806d53Smrg
3674b3e38ee4SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
3675b3e38ee4Smrginto their corresponding uninstalled binary, and any of their required library
3676b3e38ee4Smrgdirectories are added to the library path.
367750806d53Smrg
3678b3e38ee4SmrgThen, COMMAND is executed, with ARGS as arguments."
3679b3e38ee4Smrg        ;;
368050806d53Smrg
3681b3e38ee4Smrg      finish)
3682b3e38ee4Smrg        $ECHO \
3683b3e38ee4Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
368450806d53Smrg
3685b3e38ee4SmrgComplete the installation of libtool libraries.
368650806d53Smrg
3687b3e38ee4SmrgEach LIBDIR is a directory that contains libtool libraries.
368850806d53Smrg
3689b3e38ee4SmrgThe commands that this mode executes may require superuser privileges.  Use
36904a8d91dcSmrgthe '--dry-run' option if you just want to see what would be executed."
3691b3e38ee4Smrg        ;;
369250806d53Smrg
3693b3e38ee4Smrg      install)
3694b3e38ee4Smrg        $ECHO \
3695b3e38ee4Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
369650806d53Smrg
3697b3e38ee4SmrgInstall executables or libraries.
369850806d53Smrg
3699b3e38ee4SmrgINSTALL-COMMAND is the installation command.  The first component should be
37004a8d91dcSmrgeither the 'install' or 'cp' program.
370150806d53Smrg
3702b3e38ee4SmrgThe following components of INSTALL-COMMAND are treated specially:
370350806d53Smrg
3704a73423d7Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
370550806d53Smrg
3706b3e38ee4SmrgThe rest of the components are interpreted as arguments to that command (only
3707b3e38ee4SmrgBSD-compatible install options are recognized)."
3708b3e38ee4Smrg        ;;
370950806d53Smrg
3710b3e38ee4Smrg      link)
3711b3e38ee4Smrg        $ECHO \
3712b3e38ee4Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
371350806d53Smrg
3714b3e38ee4SmrgLink object files or libraries together to form another library, or to
3715b3e38ee4Smrgcreate an executable program.
371650806d53Smrg
3717b3e38ee4SmrgLINK-COMMAND is a command using the C compiler that you would use to create
3718b3e38ee4Smrga program from several object files.
371950806d53Smrg
3720b3e38ee4SmrgThe following components of LINK-COMMAND are treated specially:
372150806d53Smrg
3722b3e38ee4Smrg  -all-static       do not do any dynamic linking at all
3723b3e38ee4Smrg  -avoid-version    do not add a version suffix if possible
3724a73423d7Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
3725a73423d7Smrg                    libraries must be found in the PATH setting at runtime)
37264a8d91dcSmrg  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
3727b3e38ee4Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
3728b3e38ee4Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
3729b3e38ee4Smrg  -export-symbols SYMFILE
3730b3e38ee4Smrg                    try to export only the symbols listed in SYMFILE
3731b3e38ee4Smrg  -export-symbols-regex REGEX
3732b3e38ee4Smrg                    try to export only the symbols matching REGEX
3733b3e38ee4Smrg  -LLIBDIR          search LIBDIR for required installed libraries
3734b3e38ee4Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
3735b3e38ee4Smrg  -module           build a library that can dlopened
3736b3e38ee4Smrg  -no-fast-install  disable the fast-install mode
3737b3e38ee4Smrg  -no-install       link a not-installable executable
3738b3e38ee4Smrg  -no-undefined     declare that a library does not refer to external symbols
3739b3e38ee4Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
37404a8d91dcSmrg  -objectlist FILE  use a list of object files found in FILE to specify objects
37414a8d91dcSmrg  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
3742b3e38ee4Smrg  -precious-files-regex REGEX
3743b3e38ee4Smrg                    don't remove output files matching REGEX
3744b3e38ee4Smrg  -release RELEASE  specify package release information
3745b3e38ee4Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
3746b3e38ee4Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
3747b3e38ee4Smrg  -shared           only do dynamic linking of libtool libraries
3748b3e38ee4Smrg  -shrext SUFFIX    override the standard shared library file extension
3749b3e38ee4Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
3750b3e38ee4Smrg  -static-libtool-libs
3751b3e38ee4Smrg                    do not do any dynamic linking of libtool libraries
3752b3e38ee4Smrg  -version-info CURRENT[:REVISION[:AGE]]
3753b3e38ee4Smrg                    specify library version info [each variable defaults to 0]
3754b3e38ee4Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
3755a73423d7Smrg  -Wc,FLAG
3756a73423d7Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
3757a73423d7Smrg  -Wl,FLAG
3758a73423d7Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
3759a73423d7Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
376050806d53Smrg
37614a8d91dcSmrgAll other options (arguments beginning with '-') are ignored.
376250806d53Smrg
37634a8d91dcSmrgEvery other argument is treated as a filename.  Files ending in '.la' are
3764b3e38ee4Smrgtreated as uninstalled libtool libraries, other files are standard or library
3765b3e38ee4Smrgobject files.
376650806d53Smrg
37674a8d91dcSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created,
37684a8d91dcSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is
3769b3e38ee4Smrgrequired, except when creating a convenience library.
377050806d53Smrg
37714a8d91dcSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
37724a8d91dcSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'.
377350806d53Smrg
37744a8d91dcSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
3775b3e38ee4Smrgis created, otherwise an executable program is created."
3776a18ebfb2Smrg        ;;
377750806d53Smrg
3778b3e38ee4Smrg      uninstall)
3779b3e38ee4Smrg        $ECHO \
3780b3e38ee4Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
378150806d53Smrg
3782b3e38ee4SmrgRemove libraries from an installation directory.
378350806d53Smrg
3784b3e38ee4SmrgRM is the name of the program to use to delete files associated with each FILE
37854a8d91dcSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
3786b3e38ee4Smrgto RM.
3787af1a9c97Smrg
3788b3e38ee4SmrgIf FILE is a libtool library, all the files associated with it are deleted.
3789b3e38ee4SmrgOtherwise, only FILE itself is deleted using RM."
3790b3e38ee4Smrg        ;;
3791af1a9c97Smrg
3792b3e38ee4Smrg      *)
37934a8d91dcSmrg        func_fatal_help "invalid operation mode '$opt_mode'"
3794b3e38ee4Smrg        ;;
3795b3e38ee4Smrg    esac
3796af1a9c97Smrg
3797a73423d7Smrg    echo
37984a8d91dcSmrg    $ECHO "Try '$progname --help' for more information about other modes."
3799b3e38ee4Smrg}
3800af1a9c97Smrg
3801a73423d7Smrg# Now that we've collected a possible --mode arg, show help if necessary
3802a73423d7Smrgif $opt_help; then
38034a8d91dcSmrg  if test : = "$opt_help"; then
3804a73423d7Smrg    func_mode_help
3805a73423d7Smrg  else
3806a73423d7Smrg    {
3807a73423d7Smrg      func_help noexit
3808a73423d7Smrg      for opt_mode in compile link execute install finish uninstall clean; do
3809a73423d7Smrg	func_mode_help
3810a73423d7Smrg      done
38114a8d91dcSmrg    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
3812a73423d7Smrg    {
3813a73423d7Smrg      func_help noexit
3814a73423d7Smrg      for opt_mode in compile link execute install finish uninstall clean; do
3815a73423d7Smrg	echo
3816a73423d7Smrg	func_mode_help
3817a73423d7Smrg      done
3818a73423d7Smrg    } |
38194a8d91dcSmrg    $SED '1d
3820a73423d7Smrg      /^When reporting/,/^Report/{
3821a73423d7Smrg	H
3822a73423d7Smrg	d
3823a73423d7Smrg      }
3824a73423d7Smrg      $x
3825a73423d7Smrg      /information about other modes/d
3826a73423d7Smrg      /more detailed .*MODE/d
3827a73423d7Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
3828a73423d7Smrg  fi
3829a73423d7Smrg  exit $?
3830a73423d7Smrgfi
3831af1a9c97Smrg
3832af1a9c97Smrg
3833b3e38ee4Smrg# func_mode_execute arg...
3834b3e38ee4Smrgfunc_mode_execute ()
3835b3e38ee4Smrg{
38364a8d91dcSmrg    $debug_cmd
38374a8d91dcSmrg
3838b3e38ee4Smrg    # The first argument is the command name.
38394a8d91dcSmrg    cmd=$nonopt
3840b3e38ee4Smrg    test -z "$cmd" && \
3841b3e38ee4Smrg      func_fatal_help "you must specify a COMMAND"
3842a18ebfb2Smrg
3843b3e38ee4Smrg    # Handle -dlopen flags immediately.
3844a73423d7Smrg    for file in $opt_dlopen; do
3845b3e38ee4Smrg      test -f "$file" \
38464a8d91dcSmrg	|| func_fatal_help "'$file' is not a file"
3847a18ebfb2Smrg
3848b3e38ee4Smrg      dir=
3849b3e38ee4Smrg      case $file in
3850b3e38ee4Smrg      *.la)
3851a73423d7Smrg	func_resolve_sysroot "$file"
3852a73423d7Smrg	file=$func_resolve_sysroot_result
3853a73423d7Smrg
3854b3e38ee4Smrg	# Check to see that this really is a libtool archive.
3855b3e38ee4Smrg	func_lalib_unsafe_p "$file" \
38564a8d91dcSmrg	  || func_fatal_help "'$lib' is not a valid libtool archive"
3857a18ebfb2Smrg
3858b3e38ee4Smrg	# Read the libtool library.
3859b3e38ee4Smrg	dlname=
3860b3e38ee4Smrg	library_names=
3861b3e38ee4Smrg	func_source "$file"
386250806d53Smrg
3863b3e38ee4Smrg	# Skip this library if it cannot be dlopened.
3864b3e38ee4Smrg	if test -z "$dlname"; then
3865b3e38ee4Smrg	  # Warn if it was a shared library.
3866b3e38ee4Smrg	  test -n "$library_names" && \
38674a8d91dcSmrg	    func_warning "'$file' was not linked with '-export-dynamic'"
3868b3e38ee4Smrg	  continue
3869b3e38ee4Smrg	fi
387050806d53Smrg
3871b3e38ee4Smrg	func_dirname "$file" "" "."
38724a8d91dcSmrg	dir=$func_dirname_result
387350806d53Smrg
3874b3e38ee4Smrg	if test -f "$dir/$objdir/$dlname"; then
3875a73423d7Smrg	  func_append dir "/$objdir"
3876b3e38ee4Smrg	else
3877b3e38ee4Smrg	  if test ! -f "$dir/$dlname"; then
38784a8d91dcSmrg	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
3879b3e38ee4Smrg	  fi
3880b3e38ee4Smrg	fi
3881a18ebfb2Smrg	;;
388250806d53Smrg
3883b3e38ee4Smrg      *.lo)
3884b3e38ee4Smrg	# Just add the directory containing the .lo file.
3885b3e38ee4Smrg	func_dirname "$file" "" "."
38864a8d91dcSmrg	dir=$func_dirname_result
3887a18ebfb2Smrg	;;
388850806d53Smrg
3889b3e38ee4Smrg      *)
38904a8d91dcSmrg	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
3891a18ebfb2Smrg	continue
3892a18ebfb2Smrg	;;
3893b3e38ee4Smrg      esac
389450806d53Smrg
3895b3e38ee4Smrg      # Get the absolute pathname.
3896b3e38ee4Smrg      absdir=`cd "$dir" && pwd`
38974a8d91dcSmrg      test -n "$absdir" && dir=$absdir
3898af1a9c97Smrg
3899b3e38ee4Smrg      # Now add the directory to shlibpath_var.
3900b3e38ee4Smrg      if eval "test -z \"\$$shlibpath_var\""; then
3901b3e38ee4Smrg	eval "$shlibpath_var=\"\$dir\""
3902b3e38ee4Smrg      else
3903b3e38ee4Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
3904b3e38ee4Smrg      fi
3905b3e38ee4Smrg    done
3906af1a9c97Smrg
3907b3e38ee4Smrg    # This variable tells wrapper scripts just to set shlibpath_var
3908b3e38ee4Smrg    # rather than running their programs.
39094a8d91dcSmrg    libtool_execute_magic=$magic
3910af1a9c97Smrg
3911b3e38ee4Smrg    # Check if any of the arguments is a wrapper script.
3912b3e38ee4Smrg    args=
3913b3e38ee4Smrg    for file
3914b3e38ee4Smrg    do
3915b3e38ee4Smrg      case $file in
3916a73423d7Smrg      -* | *.la | *.lo ) ;;
3917b3e38ee4Smrg      *)
3918b3e38ee4Smrg	# Do a test to see if this is really a libtool program.
3919b3e38ee4Smrg	if func_ltwrapper_script_p "$file"; then
3920b3e38ee4Smrg	  func_source "$file"
3921b3e38ee4Smrg	  # Transform arg to wrapped name.
39224a8d91dcSmrg	  file=$progdir/$program
3923b3e38ee4Smrg	elif func_ltwrapper_executable_p "$file"; then
3924b3e38ee4Smrg	  func_ltwrapper_scriptname "$file"
3925b3e38ee4Smrg	  func_source "$func_ltwrapper_scriptname_result"
3926b3e38ee4Smrg	  # Transform arg to wrapped name.
39274a8d91dcSmrg	  file=$progdir/$program
3928b3e38ee4Smrg	fi
3929b3e38ee4Smrg	;;
3930b3e38ee4Smrg      esac
3931b3e38ee4Smrg      # Quote arguments (to preserve shell metacharacters).
3932a73423d7Smrg      func_append_quoted args "$file"
3933b3e38ee4Smrg    done
3934af1a9c97Smrg
39354a8d91dcSmrg    if $opt_dry_run; then
39364a8d91dcSmrg      # Display what would be done.
39374a8d91dcSmrg      if test -n "$shlibpath_var"; then
39384a8d91dcSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
39394a8d91dcSmrg	echo "export $shlibpath_var"
39404a8d91dcSmrg      fi
39414a8d91dcSmrg      $ECHO "$cmd$args"
39424a8d91dcSmrg      exit $EXIT_SUCCESS
39434a8d91dcSmrg    else
3944b3e38ee4Smrg      if test -n "$shlibpath_var"; then
3945b3e38ee4Smrg	# Export the shlibpath_var.
3946b3e38ee4Smrg	eval "export $shlibpath_var"
3947b3e38ee4Smrg      fi
3948af1a9c97Smrg
3949b3e38ee4Smrg      # Restore saved environment variables
3950b3e38ee4Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
3951b3e38ee4Smrg      do
3952b3e38ee4Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
3953b3e38ee4Smrg                $lt_var=\$save_$lt_var; export $lt_var
3954a18ebfb2Smrg	      else
3955b3e38ee4Smrg		$lt_unset $lt_var
3956b3e38ee4Smrg	      fi"
3957b3e38ee4Smrg      done
3958af1a9c97Smrg
3959b3e38ee4Smrg      # Now prepare to actually exec the command.
39604a8d91dcSmrg      exec_cmd=\$cmd$args
3961b3e38ee4Smrg    fi
3962b3e38ee4Smrg}
3963af1a9c97Smrg
39644a8d91dcSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"}
3965af1a9c97Smrg
3966a18ebfb2Smrg
3967b3e38ee4Smrg# func_mode_finish arg...
3968b3e38ee4Smrgfunc_mode_finish ()
3969b3e38ee4Smrg{
39704a8d91dcSmrg    $debug_cmd
39714a8d91dcSmrg
3972a73423d7Smrg    libs=
3973a73423d7Smrg    libdirs=
3974b3e38ee4Smrg    admincmds=
397550806d53Smrg
3976a73423d7Smrg    for opt in "$nonopt" ${1+"$@"}
3977a73423d7Smrg    do
3978a73423d7Smrg      if test -d "$opt"; then
3979a73423d7Smrg	func_append libdirs " $opt"
3980a73423d7Smrg
3981a73423d7Smrg      elif test -f "$opt"; then
3982a73423d7Smrg	if func_lalib_unsafe_p "$opt"; then
3983a73423d7Smrg	  func_append libs " $opt"
3984a73423d7Smrg	else
39854a8d91dcSmrg	  func_warning "'$opt' is not a valid libtool archive"
3986a73423d7Smrg	fi
3987a73423d7Smrg
3988a73423d7Smrg      else
39894a8d91dcSmrg	func_fatal_error "invalid argument '$opt'"
3990a73423d7Smrg      fi
3991a73423d7Smrg    done
3992a73423d7Smrg
3993a73423d7Smrg    if test -n "$libs"; then
3994a73423d7Smrg      if test -n "$lt_sysroot"; then
3995a73423d7Smrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
3996a73423d7Smrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
3997a73423d7Smrg      else
3998a73423d7Smrg        sysroot_cmd=
3999a73423d7Smrg      fi
4000a73423d7Smrg
4001a73423d7Smrg      # Remove sysroot references
4002a73423d7Smrg      if $opt_dry_run; then
4003a73423d7Smrg        for lib in $libs; do
40044a8d91dcSmrg          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
4005a73423d7Smrg        done
4006a73423d7Smrg      else
4007a73423d7Smrg        tmpdir=`func_mktempdir`
4008a73423d7Smrg        for lib in $libs; do
40094a8d91dcSmrg	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
4010a73423d7Smrg	    > $tmpdir/tmp-la
4011a73423d7Smrg	  mv -f $tmpdir/tmp-la $lib
4012a73423d7Smrg	done
4013a73423d7Smrg        ${RM}r "$tmpdir"
4014a73423d7Smrg      fi
4015a73423d7Smrg    fi
401650806d53Smrg
4017a73423d7Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4018b3e38ee4Smrg      for libdir in $libdirs; do
4019b3e38ee4Smrg	if test -n "$finish_cmds"; then
4020b3e38ee4Smrg	  # Do each command in the finish commands.
4021b3e38ee4Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
4022b3e38ee4Smrg'"$cmd"'"'
4023a18ebfb2Smrg	fi
4024b3e38ee4Smrg	if test -n "$finish_eval"; then
4025b3e38ee4Smrg	  # Do the single finish_eval.
4026b3e38ee4Smrg	  eval cmds=\"$finish_eval\"
4027a73423d7Smrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
4028b3e38ee4Smrg       $cmds"
4029b3e38ee4Smrg	fi
4030b3e38ee4Smrg      done
4031b3e38ee4Smrg    fi
403250806d53Smrg
4033b3e38ee4Smrg    # Exit here if they wanted silent mode.
40344a8d91dcSmrg    $opt_quiet && exit $EXIT_SUCCESS
403550806d53Smrg
4036a73423d7Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4037a73423d7Smrg      echo "----------------------------------------------------------------------"
4038a73423d7Smrg      echo "Libraries have been installed in:"
4039a73423d7Smrg      for libdir in $libdirs; do
4040a73423d7Smrg	$ECHO "   $libdir"
4041a73423d7Smrg      done
4042a73423d7Smrg      echo
4043a73423d7Smrg      echo "If you ever happen to want to link against installed libraries"
4044a73423d7Smrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
40454a8d91dcSmrg      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
4046a73423d7Smrg      echo "flag during linking and do at least one of the following:"
4047a73423d7Smrg      if test -n "$shlibpath_var"; then
40484a8d91dcSmrg	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
4049a73423d7Smrg	echo "     during execution"
4050a73423d7Smrg      fi
4051a73423d7Smrg      if test -n "$runpath_var"; then
40524a8d91dcSmrg	echo "   - add LIBDIR to the '$runpath_var' environment variable"
4053a73423d7Smrg	echo "     during linking"
4054a73423d7Smrg      fi
4055a73423d7Smrg      if test -n "$hardcode_libdir_flag_spec"; then
4056a73423d7Smrg	libdir=LIBDIR
4057a73423d7Smrg	eval flag=\"$hardcode_libdir_flag_spec\"
4058b3e38ee4Smrg
40594a8d91dcSmrg	$ECHO "   - use the '$flag' linker flag"
4060a73423d7Smrg      fi
4061a73423d7Smrg      if test -n "$admincmds"; then
4062a73423d7Smrg	$ECHO "   - have your system administrator run these commands:$admincmds"
4063a73423d7Smrg      fi
4064a73423d7Smrg      if test -f /etc/ld.so.conf; then
40654a8d91dcSmrg	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
4066a73423d7Smrg      fi
4067a73423d7Smrg      echo
4068b3e38ee4Smrg
4069a73423d7Smrg      echo "See any operating system documentation about shared libraries for"
4070a73423d7Smrg      case $host in
4071a73423d7Smrg	solaris2.[6789]|solaris2.1[0-9])
4072a73423d7Smrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
4073a73423d7Smrg	  echo "pages."
4074a73423d7Smrg	  ;;
4075a73423d7Smrg	*)
4076a73423d7Smrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
4077a73423d7Smrg	  ;;
4078a73423d7Smrg      esac
4079a73423d7Smrg      echo "----------------------------------------------------------------------"
4080a73423d7Smrg    fi
4081b3e38ee4Smrg    exit $EXIT_SUCCESS
4082b3e38ee4Smrg}
4083b3e38ee4Smrg
40844a8d91dcSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"}
4085b3e38ee4Smrg
4086b3e38ee4Smrg
4087b3e38ee4Smrg# func_mode_install arg...
4088b3e38ee4Smrgfunc_mode_install ()
4089b3e38ee4Smrg{
40904a8d91dcSmrg    $debug_cmd
40914a8d91dcSmrg
4092b3e38ee4Smrg    # There may be an optional sh(1) argument at the beginning of
4093b3e38ee4Smrg    # install_prog (especially on Windows NT).
40944a8d91dcSmrg    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
4095b3e38ee4Smrg       # Allow the use of GNU shtool's install command.
40964a8d91dcSmrg       case $nonopt in *shtool*) :;; *) false;; esac
40974a8d91dcSmrg    then
4098b3e38ee4Smrg      # Aesthetically quote it.
4099b3e38ee4Smrg      func_quote_for_eval "$nonopt"
4100b3e38ee4Smrg      install_prog="$func_quote_for_eval_result "
4101b3e38ee4Smrg      arg=$1
4102b3e38ee4Smrg      shift
4103b3e38ee4Smrg    else
4104b3e38ee4Smrg      install_prog=
4105b3e38ee4Smrg      arg=$nonopt
4106b3e38ee4Smrg    fi
4107b3e38ee4Smrg
4108b3e38ee4Smrg    # The real first argument should be the name of the installation program.
4109b3e38ee4Smrg    # Aesthetically quote it.
4110b3e38ee4Smrg    func_quote_for_eval "$arg"
4111a73423d7Smrg    func_append install_prog "$func_quote_for_eval_result"
4112a73423d7Smrg    install_shared_prog=$install_prog
4113a73423d7Smrg    case " $install_prog " in
4114a73423d7Smrg      *[\\\ /]cp\ *) install_cp=: ;;
4115a73423d7Smrg      *) install_cp=false ;;
4116a73423d7Smrg    esac
4117b3e38ee4Smrg
4118b3e38ee4Smrg    # We need to accept at least all the BSD install flags.
4119b3e38ee4Smrg    dest=
4120b3e38ee4Smrg    files=
4121b3e38ee4Smrg    opts=
4122b3e38ee4Smrg    prev=
4123b3e38ee4Smrg    install_type=
41244a8d91dcSmrg    isdir=false
4125b3e38ee4Smrg    stripme=
4126a73423d7Smrg    no_mode=:
4127b3e38ee4Smrg    for arg
4128b3e38ee4Smrg    do
4129a73423d7Smrg      arg2=
4130b3e38ee4Smrg      if test -n "$dest"; then
4131a73423d7Smrg	func_append files " $dest"
4132b3e38ee4Smrg	dest=$arg
4133b3e38ee4Smrg	continue
4134b3e38ee4Smrg      fi
4135b3e38ee4Smrg
4136b3e38ee4Smrg      case $arg in
41374a8d91dcSmrg      -d) isdir=: ;;
4138b3e38ee4Smrg      -f)
4139a73423d7Smrg	if $install_cp; then :; else
4140a73423d7Smrg	  prev=$arg
4141a73423d7Smrg	fi
4142b3e38ee4Smrg	;;
4143b3e38ee4Smrg      -g | -m | -o)
4144b3e38ee4Smrg	prev=$arg
4145b3e38ee4Smrg	;;
4146b3e38ee4Smrg      -s)
4147b3e38ee4Smrg	stripme=" -s"
4148b3e38ee4Smrg	continue
4149b3e38ee4Smrg	;;
4150b3e38ee4Smrg      -*)
4151b3e38ee4Smrg	;;
4152b3e38ee4Smrg      *)
4153b3e38ee4Smrg	# If the previous option needed an argument, then skip it.
4154b3e38ee4Smrg	if test -n "$prev"; then
41554a8d91dcSmrg	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
4156a73423d7Smrg	    arg2=$install_override_mode
4157a73423d7Smrg	    no_mode=false
4158a73423d7Smrg	  fi
4159a18ebfb2Smrg	  prev=
4160af1a9c97Smrg	else
4161b3e38ee4Smrg	  dest=$arg
4162b3e38ee4Smrg	  continue
416350806d53Smrg	fi
4164a18ebfb2Smrg	;;
4165b3e38ee4Smrg      esac
416650806d53Smrg
4167b3e38ee4Smrg      # Aesthetically quote the argument.
4168b3e38ee4Smrg      func_quote_for_eval "$arg"
4169a73423d7Smrg      func_append install_prog " $func_quote_for_eval_result"
4170a73423d7Smrg      if test -n "$arg2"; then
4171a73423d7Smrg	func_quote_for_eval "$arg2"
4172a73423d7Smrg      fi
4173a73423d7Smrg      func_append install_shared_prog " $func_quote_for_eval_result"
4174b3e38ee4Smrg    done
417550806d53Smrg
4176b3e38ee4Smrg    test -z "$install_prog" && \
4177b3e38ee4Smrg      func_fatal_help "you must specify an install program"
417850806d53Smrg
4179b3e38ee4Smrg    test -n "$prev" && \
41804a8d91dcSmrg      func_fatal_help "the '$prev' option requires an argument"
4181af1a9c97Smrg
4182a73423d7Smrg    if test -n "$install_override_mode" && $no_mode; then
4183a73423d7Smrg      if $install_cp; then :; else
4184a73423d7Smrg	func_quote_for_eval "$install_override_mode"
4185a73423d7Smrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
4186a73423d7Smrg      fi
4187a73423d7Smrg    fi
4188a73423d7Smrg
4189b3e38ee4Smrg    if test -z "$files"; then
4190b3e38ee4Smrg      if test -z "$dest"; then
4191b3e38ee4Smrg	func_fatal_help "no file or destination specified"
4192b3e38ee4Smrg      else
4193b3e38ee4Smrg	func_fatal_help "you must specify a destination"
4194b3e38ee4Smrg      fi
4195a18ebfb2Smrg    fi
4196af1a9c97Smrg
4197b3e38ee4Smrg    # Strip any trailing slash from the destination.
4198b3e38ee4Smrg    func_stripname '' '/' "$dest"
4199b3e38ee4Smrg    dest=$func_stripname_result
4200af1a9c97Smrg
4201b3e38ee4Smrg    # Check to see that the destination is a directory.
42024a8d91dcSmrg    test -d "$dest" && isdir=:
42034a8d91dcSmrg    if $isdir; then
42044a8d91dcSmrg      destdir=$dest
4205b3e38ee4Smrg      destname=
4206a18ebfb2Smrg    else
4207b3e38ee4Smrg      func_dirname_and_basename "$dest" "" "."
42084a8d91dcSmrg      destdir=$func_dirname_result
42094a8d91dcSmrg      destname=$func_basename_result
4210af1a9c97Smrg
4211b3e38ee4Smrg      # Not a directory, so check to see that there is only one file specified.
4212b3e38ee4Smrg      set dummy $files; shift
4213b3e38ee4Smrg      test "$#" -gt 1 && \
42144a8d91dcSmrg	func_fatal_help "'$dest' is not a directory"
4215af1a9c97Smrg    fi
4216b3e38ee4Smrg    case $destdir in
4217b3e38ee4Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
4218a18ebfb2Smrg    *)
4219b3e38ee4Smrg      for file in $files; do
4220b3e38ee4Smrg	case $file in
4221b3e38ee4Smrg	*.lo) ;;
4222b3e38ee4Smrg	*)
42234a8d91dcSmrg	  func_fatal_help "'$destdir' must be an absolute directory name"
4224b3e38ee4Smrg	  ;;
4225b3e38ee4Smrg	esac
4226b3e38ee4Smrg      done
4227a18ebfb2Smrg      ;;
4228a18ebfb2Smrg    esac
422950806d53Smrg
4230b3e38ee4Smrg    # This variable tells wrapper scripts just to set variables rather
4231b3e38ee4Smrg    # than running their programs.
42324a8d91dcSmrg    libtool_install_magic=$magic
423350806d53Smrg
4234b3e38ee4Smrg    staticlibs=
4235b3e38ee4Smrg    future_libdirs=
4236b3e38ee4Smrg    current_libdirs=
4237b3e38ee4Smrg    for file in $files; do
423850806d53Smrg
4239b3e38ee4Smrg      # Do each installation.
4240b3e38ee4Smrg      case $file in
4241b3e38ee4Smrg      *.$libext)
4242b3e38ee4Smrg	# Do the static libraries later.
4243a73423d7Smrg	func_append staticlibs " $file"
4244b3e38ee4Smrg	;;
4245b3e38ee4Smrg
4246b3e38ee4Smrg      *.la)
4247a73423d7Smrg	func_resolve_sysroot "$file"
4248a73423d7Smrg	file=$func_resolve_sysroot_result
4249a73423d7Smrg
4250b3e38ee4Smrg	# Check to see that this really is a libtool archive.
4251b3e38ee4Smrg	func_lalib_unsafe_p "$file" \
42524a8d91dcSmrg	  || func_fatal_help "'$file' is not a valid libtool archive"
4253b3e38ee4Smrg
4254b3e38ee4Smrg	library_names=
4255b3e38ee4Smrg	old_library=
4256b3e38ee4Smrg	relink_command=
4257b3e38ee4Smrg	func_source "$file"
4258b3e38ee4Smrg
4259b3e38ee4Smrg	# Add the libdir to current_libdirs if it is the destination.
4260b3e38ee4Smrg	if test "X$destdir" = "X$libdir"; then
4261b3e38ee4Smrg	  case "$current_libdirs " in
4262b3e38ee4Smrg	  *" $libdir "*) ;;
4263a73423d7Smrg	  *) func_append current_libdirs " $libdir" ;;
4264af1a9c97Smrg	  esac
4265b3e38ee4Smrg	else
4266b3e38ee4Smrg	  # Note the libdir as a future libdir.
4267b3e38ee4Smrg	  case "$future_libdirs " in
4268b3e38ee4Smrg	  *" $libdir "*) ;;
4269a73423d7Smrg	  *) func_append future_libdirs " $libdir" ;;
4270b3e38ee4Smrg	  esac
4271b3e38ee4Smrg	fi
4272af1a9c97Smrg
4273b3e38ee4Smrg	func_dirname "$file" "/" ""
42744a8d91dcSmrg	dir=$func_dirname_result
4275a73423d7Smrg	func_append dir "$objdir"
4276b3e38ee4Smrg
4277b3e38ee4Smrg	if test -n "$relink_command"; then
4278b3e38ee4Smrg	  # Determine the prefix the user has applied to our future dir.
4279a73423d7Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
4280b3e38ee4Smrg
4281b3e38ee4Smrg	  # Don't allow the user to place us outside of our expected
4282b3e38ee4Smrg	  # location b/c this prevents finding dependent libraries that
4283b3e38ee4Smrg	  # are installed to the same prefix.
4284b3e38ee4Smrg	  # At present, this check doesn't affect windows .dll's that
4285b3e38ee4Smrg	  # are installed into $libdir/../bin (currently, that works fine)
4286b3e38ee4Smrg	  # but it's something to keep an eye on.
4287b3e38ee4Smrg	  test "$inst_prefix_dir" = "$destdir" && \
42884a8d91dcSmrg	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
4289b3e38ee4Smrg
4290b3e38ee4Smrg	  if test -n "$inst_prefix_dir"; then
4291b3e38ee4Smrg	    # Stick the inst_prefix_dir data into the link command.
4292a73423d7Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
4293b3e38ee4Smrg	  else
4294a73423d7Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
4295b3e38ee4Smrg	  fi
4296b3e38ee4Smrg
42974a8d91dcSmrg	  func_warning "relinking '$file'"
4298b3e38ee4Smrg	  func_show_eval "$relink_command" \
42994a8d91dcSmrg	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
4300b3e38ee4Smrg	fi
4301b3e38ee4Smrg
4302b3e38ee4Smrg	# See the names of the shared library.
4303b3e38ee4Smrg	set dummy $library_names; shift
4304b3e38ee4Smrg	if test -n "$1"; then
43054a8d91dcSmrg	  realname=$1
4306b3e38ee4Smrg	  shift
4307b3e38ee4Smrg
43084a8d91dcSmrg	  srcname=$realname
43094a8d91dcSmrg	  test -n "$relink_command" && srcname=${realname}T
4310b3e38ee4Smrg
4311b3e38ee4Smrg	  # Install the shared library and build the symlinks.
4312a73423d7Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
4313b3e38ee4Smrg	      'exit $?'
43144a8d91dcSmrg	  tstripme=$stripme
4315b3e38ee4Smrg	  case $host_os in
4316b3e38ee4Smrg	  cygwin* | mingw* | pw32* | cegcc*)
4317b3e38ee4Smrg	    case $realname in
4318b3e38ee4Smrg	    *.dll.a)
43194a8d91dcSmrg	      tstripme=
43204a8d91dcSmrg	      ;;
43214a8d91dcSmrg	    esac
43224a8d91dcSmrg	    ;;
43234a8d91dcSmrg	  os2*)
43244a8d91dcSmrg	    case $realname in
43254a8d91dcSmrg	    *_dll.a)
43264a8d91dcSmrg	      tstripme=
4327b3e38ee4Smrg	      ;;
4328b3e38ee4Smrg	    esac
4329af1a9c97Smrg	    ;;
4330af1a9c97Smrg	  esac
4331b3e38ee4Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
4332b3e38ee4Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
4333a18ebfb2Smrg	  fi
4334b3e38ee4Smrg
4335b3e38ee4Smrg	  if test "$#" -gt 0; then
4336b3e38ee4Smrg	    # Delete the old symlinks, and create new ones.
43374a8d91dcSmrg	    # Try 'ln -sf' first, because the 'ln' binary might depend on
4338b3e38ee4Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
4339b3e38ee4Smrg	    # so we also need to try rm && ln -s.
4340b3e38ee4Smrg	    for linkname
4341b3e38ee4Smrg	    do
4342b3e38ee4Smrg	      test "$linkname" != "$realname" \
4343b3e38ee4Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
4344a18ebfb2Smrg	    done
4345a18ebfb2Smrg	  fi
434650806d53Smrg
4347b3e38ee4Smrg	  # Do each command in the postinstall commands.
43484a8d91dcSmrg	  lib=$destdir/$realname
4349b3e38ee4Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
4350a18ebfb2Smrg	fi
435150806d53Smrg
4352b3e38ee4Smrg	# Install the pseudo-library for information purposes.
4353b3e38ee4Smrg	func_basename "$file"
43544a8d91dcSmrg	name=$func_basename_result
43554a8d91dcSmrg	instname=$dir/${name}i
4356b3e38ee4Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
435750806d53Smrg
4358b3e38ee4Smrg	# Maybe install the static library, too.
4359a73423d7Smrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
4360b3e38ee4Smrg	;;
436150806d53Smrg
4362b3e38ee4Smrg      *.lo)
4363b3e38ee4Smrg	# Install (i.e. copy) a libtool object.
436450806d53Smrg
4365b3e38ee4Smrg	# Figure out destination file name, if it wasn't already specified.
4366b3e38ee4Smrg	if test -n "$destname"; then
43674a8d91dcSmrg	  destfile=$destdir/$destname
4368b3e38ee4Smrg	else
4369b3e38ee4Smrg	  func_basename "$file"
43704a8d91dcSmrg	  destfile=$func_basename_result
43714a8d91dcSmrg	  destfile=$destdir/$destfile
4372a18ebfb2Smrg	fi
437350806d53Smrg
4374b3e38ee4Smrg	# Deduce the name of the destination old-style object file.
4375b3e38ee4Smrg	case $destfile in
4376b3e38ee4Smrg	*.lo)
4377b3e38ee4Smrg	  func_lo2o "$destfile"
4378b3e38ee4Smrg	  staticdest=$func_lo2o_result
4379b3e38ee4Smrg	  ;;
4380b3e38ee4Smrg	*.$objext)
43814a8d91dcSmrg	  staticdest=$destfile
4382b3e38ee4Smrg	  destfile=
4383b3e38ee4Smrg	  ;;
4384b3e38ee4Smrg	*)
43854a8d91dcSmrg	  func_fatal_help "cannot copy a libtool object to '$destfile'"
4386b3e38ee4Smrg	  ;;
4387b3e38ee4Smrg	esac
438850806d53Smrg
4389b3e38ee4Smrg	# Install the libtool object if requested.
4390b3e38ee4Smrg	test -n "$destfile" && \
4391b3e38ee4Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
439250806d53Smrg
4393b3e38ee4Smrg	# Install the old object if enabled.
43944a8d91dcSmrg	if test yes = "$build_old_libs"; then
4395b3e38ee4Smrg	  # Deduce the name of the old-style object file.
4396b3e38ee4Smrg	  func_lo2o "$file"
4397b3e38ee4Smrg	  staticobj=$func_lo2o_result
4398b3e38ee4Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
439950806d53Smrg	fi
4400b3e38ee4Smrg	exit $EXIT_SUCCESS
4401b3e38ee4Smrg	;;
440250806d53Smrg
4403b3e38ee4Smrg      *)
4404b3e38ee4Smrg	# Figure out destination file name, if it wasn't already specified.
4405b3e38ee4Smrg	if test -n "$destname"; then
44064a8d91dcSmrg	  destfile=$destdir/$destname
4407b3e38ee4Smrg	else
4408b3e38ee4Smrg	  func_basename "$file"
44094a8d91dcSmrg	  destfile=$func_basename_result
44104a8d91dcSmrg	  destfile=$destdir/$destfile
4411b3e38ee4Smrg	fi
441250806d53Smrg
4413b3e38ee4Smrg	# If the file is missing, and there is a .exe on the end, strip it
4414b3e38ee4Smrg	# because it is most likely a libtool script we actually want to
4415b3e38ee4Smrg	# install
44164a8d91dcSmrg	stripped_ext=
4417b3e38ee4Smrg	case $file in
4418b3e38ee4Smrg	  *.exe)
4419b3e38ee4Smrg	    if test ! -f "$file"; then
4420b3e38ee4Smrg	      func_stripname '' '.exe' "$file"
4421b3e38ee4Smrg	      file=$func_stripname_result
44224a8d91dcSmrg	      stripped_ext=.exe
4423b3e38ee4Smrg	    fi
4424b3e38ee4Smrg	    ;;
4425b3e38ee4Smrg	esac
4426b3e38ee4Smrg
4427b3e38ee4Smrg	# Do a test to see if this is really a libtool program.
4428b3e38ee4Smrg	case $host in
4429b3e38ee4Smrg	*cygwin* | *mingw*)
4430b3e38ee4Smrg	    if func_ltwrapper_executable_p "$file"; then
4431b3e38ee4Smrg	      func_ltwrapper_scriptname "$file"
4432b3e38ee4Smrg	      wrapper=$func_ltwrapper_scriptname_result
4433b3e38ee4Smrg	    else
4434b3e38ee4Smrg	      func_stripname '' '.exe' "$file"
4435b3e38ee4Smrg	      wrapper=$func_stripname_result
4436b3e38ee4Smrg	    fi
4437b3e38ee4Smrg	    ;;
4438a18ebfb2Smrg	*)
4439b3e38ee4Smrg	    wrapper=$file
4440b3e38ee4Smrg	    ;;
4441b3e38ee4Smrg	esac
4442b3e38ee4Smrg	if func_ltwrapper_script_p "$wrapper"; then
4443b3e38ee4Smrg	  notinst_deplibs=
4444b3e38ee4Smrg	  relink_command=
4445b3e38ee4Smrg
4446b3e38ee4Smrg	  func_source "$wrapper"
4447b3e38ee4Smrg
4448b3e38ee4Smrg	  # Check the variables that should have been set.
4449b3e38ee4Smrg	  test -z "$generated_by_libtool_version" && \
44504a8d91dcSmrg	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
4451b3e38ee4Smrg
44524a8d91dcSmrg	  finalize=:
4453b3e38ee4Smrg	  for lib in $notinst_deplibs; do
4454b3e38ee4Smrg	    # Check to see that each library is installed.
4455b3e38ee4Smrg	    libdir=
4456b3e38ee4Smrg	    if test -f "$lib"; then
4457b3e38ee4Smrg	      func_source "$lib"
4458b3e38ee4Smrg	    fi
44594a8d91dcSmrg	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
4460b3e38ee4Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
44614a8d91dcSmrg	      func_warning "'$lib' has not been installed in '$libdir'"
44624a8d91dcSmrg	      finalize=false
4463b3e38ee4Smrg	    fi
4464b3e38ee4Smrg	  done
4465b3e38ee4Smrg
4466b3e38ee4Smrg	  relink_command=
4467b3e38ee4Smrg	  func_source "$wrapper"
4468b3e38ee4Smrg
4469b3e38ee4Smrg	  outputname=
44704a8d91dcSmrg	  if test no = "$fast_install" && test -n "$relink_command"; then
4471b3e38ee4Smrg	    $opt_dry_run || {
44724a8d91dcSmrg	      if $finalize; then
4473b3e38ee4Smrg	        tmpdir=`func_mktempdir`
4474b3e38ee4Smrg		func_basename "$file$stripped_ext"
44754a8d91dcSmrg		file=$func_basename_result
44764a8d91dcSmrg	        outputname=$tmpdir/$file
4477b3e38ee4Smrg	        # Replace the output file specification.
4478a73423d7Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
4479b3e38ee4Smrg
44804a8d91dcSmrg	        $opt_quiet || {
4481b3e38ee4Smrg	          func_quote_for_expand "$relink_command"
4482b3e38ee4Smrg		  eval "func_echo $func_quote_for_expand_result"
4483b3e38ee4Smrg	        }
4484b3e38ee4Smrg	        if eval "$relink_command"; then :
4485b3e38ee4Smrg	          else
44864a8d91dcSmrg		  func_error "error: relink '$file' with the above command before installing it"
4487b3e38ee4Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
4488b3e38ee4Smrg		  continue
4489b3e38ee4Smrg	        fi
44904a8d91dcSmrg	        file=$outputname
4491b3e38ee4Smrg	      else
44924a8d91dcSmrg	        func_warning "cannot relink '$file'"
4493b3e38ee4Smrg	      fi
4494b3e38ee4Smrg	    }
4495b3e38ee4Smrg	  else
4496b3e38ee4Smrg	    # Install the binary that we compiled earlier.
4497a73423d7Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
4498a18ebfb2Smrg	  fi
4499b3e38ee4Smrg	fi
4500b3e38ee4Smrg
4501b3e38ee4Smrg	# remove .exe since cygwin /usr/bin/install will append another
4502b3e38ee4Smrg	# one anyway
4503b3e38ee4Smrg	case $install_prog,$host in
4504b3e38ee4Smrg	*/usr/bin/install*,*cygwin*)
4505b3e38ee4Smrg	  case $file:$destfile in
4506b3e38ee4Smrg	  *.exe:*.exe)
4507b3e38ee4Smrg	    # this is ok
4508b3e38ee4Smrg	    ;;
4509b3e38ee4Smrg	  *.exe:*)
4510b3e38ee4Smrg	    destfile=$destfile.exe
4511b3e38ee4Smrg	    ;;
4512b3e38ee4Smrg	  *:*.exe)
4513b3e38ee4Smrg	    func_stripname '' '.exe' "$destfile"
4514b3e38ee4Smrg	    destfile=$func_stripname_result
4515b3e38ee4Smrg	    ;;
4516b3e38ee4Smrg	  esac
4517a18ebfb2Smrg	  ;;
4518a18ebfb2Smrg	esac
4519b3e38ee4Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
4520b3e38ee4Smrg	$opt_dry_run || if test -n "$outputname"; then
4521b3e38ee4Smrg	  ${RM}r "$tmpdir"
4522b3e38ee4Smrg	fi
4523b3e38ee4Smrg	;;
4524b3e38ee4Smrg      esac
4525b3e38ee4Smrg    done
452650806d53Smrg
4527b3e38ee4Smrg    for file in $staticlibs; do
4528b3e38ee4Smrg      func_basename "$file"
45294a8d91dcSmrg      name=$func_basename_result
4530b3e38ee4Smrg
4531b3e38ee4Smrg      # Set up the ranlib parameters.
45324a8d91dcSmrg      oldlib=$destdir/$name
4533a73423d7Smrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
4534a73423d7Smrg      tool_oldlib=$func_to_tool_file_result
4535b3e38ee4Smrg
4536b3e38ee4Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
4537b3e38ee4Smrg
4538b3e38ee4Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
4539a73423d7Smrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
4540b3e38ee4Smrg      fi
4541b3e38ee4Smrg
4542b3e38ee4Smrg      # Do each command in the postinstall commands.
4543b3e38ee4Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
4544b3e38ee4Smrg    done
4545b3e38ee4Smrg
4546b3e38ee4Smrg    test -n "$future_libdirs" && \
45474a8d91dcSmrg      func_warning "remember to run '$progname --finish$future_libdirs'"
4548b3e38ee4Smrg
4549b3e38ee4Smrg    if test -n "$current_libdirs"; then
4550b3e38ee4Smrg      # Maybe just do a dry run.
4551b3e38ee4Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
45524a8d91dcSmrg      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
4553b3e38ee4Smrg    else
4554b3e38ee4Smrg      exit $EXIT_SUCCESS
4555b3e38ee4Smrg    fi
4556b3e38ee4Smrg}
4557b3e38ee4Smrg
45584a8d91dcSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"}
4559b3e38ee4Smrg
4560b3e38ee4Smrg
4561b3e38ee4Smrg# func_generate_dlsyms outputname originator pic_p
4562b3e38ee4Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
4563b3e38ee4Smrg# a dlpreopen symbol table.
4564b3e38ee4Smrgfunc_generate_dlsyms ()
4565b3e38ee4Smrg{
45664a8d91dcSmrg    $debug_cmd
45674a8d91dcSmrg
45684a8d91dcSmrg    my_outputname=$1
45694a8d91dcSmrg    my_originator=$2
45704a8d91dcSmrg    my_pic_p=${3-false}
45714a8d91dcSmrg    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
4572b3e38ee4Smrg    my_dlsyms=
4573b3e38ee4Smrg
45744a8d91dcSmrg    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
4575b3e38ee4Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
45764a8d91dcSmrg	my_dlsyms=${my_outputname}S.c
4577b3e38ee4Smrg      else
4578b3e38ee4Smrg	func_error "not configured to extract global symbols from dlpreopened files"
4579b3e38ee4Smrg      fi
4580b3e38ee4Smrg    fi
4581b3e38ee4Smrg
4582b3e38ee4Smrg    if test -n "$my_dlsyms"; then
4583b3e38ee4Smrg      case $my_dlsyms in
4584b3e38ee4Smrg      "") ;;
4585b3e38ee4Smrg      *.c)
4586b3e38ee4Smrg	# Discover the nlist of each of the dlfiles.
45874a8d91dcSmrg	nlist=$output_objdir/$my_outputname.nm
4588b3e38ee4Smrg
4589b3e38ee4Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
4590b3e38ee4Smrg
4591b3e38ee4Smrg	# Parse the name list into a source file.
4592b3e38ee4Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
4593b3e38ee4Smrg
4594b3e38ee4Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
45954a8d91dcSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
45964a8d91dcSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
4597b3e38ee4Smrg
4598b3e38ee4Smrg#ifdef __cplusplus
4599b3e38ee4Smrgextern \"C\" {
4600b3e38ee4Smrg#endif
4601b3e38ee4Smrg
46024a8d91dcSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
4603a73423d7Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
4604a73423d7Smrg#endif
4605a73423d7Smrg
4606a73423d7Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
46074a8d91dcSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
46084a8d91dcSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime
4609a73423d7Smrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
4610a73423d7Smrg# define LT_DLSYM_CONST
46114a8d91dcSmrg#elif defined __osf__
4612a73423d7Smrg/* This system does not cope well with relocations in const data.  */
4613a73423d7Smrg# define LT_DLSYM_CONST
4614a73423d7Smrg#else
4615a73423d7Smrg# define LT_DLSYM_CONST const
4616a73423d7Smrg#endif
4617a73423d7Smrg
46184a8d91dcSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
46194a8d91dcSmrg
4620b3e38ee4Smrg/* External symbol declarations for the compiler. */\
4621b3e38ee4Smrg"
4622b3e38ee4Smrg
46234a8d91dcSmrg	if test yes = "$dlself"; then
46244a8d91dcSmrg	  func_verbose "generating symbol list for '$output'"
4625b3e38ee4Smrg
4626b3e38ee4Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
4627b3e38ee4Smrg
4628b3e38ee4Smrg	  # Add our own program objects to the symbol list.
4629a73423d7Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
4630b3e38ee4Smrg	  for progfile in $progfiles; do
4631a73423d7Smrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
46324a8d91dcSmrg	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
4633a73423d7Smrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
4634b3e38ee4Smrg	  done
4635b3e38ee4Smrg
4636b3e38ee4Smrg	  if test -n "$exclude_expsyms"; then
4637b3e38ee4Smrg	    $opt_dry_run || {
4638b3e38ee4Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4639b3e38ee4Smrg	      eval '$MV "$nlist"T "$nlist"'
4640b3e38ee4Smrg	    }
4641a18ebfb2Smrg	  fi
4642b3e38ee4Smrg
4643b3e38ee4Smrg	  if test -n "$export_symbols_regex"; then
4644b3e38ee4Smrg	    $opt_dry_run || {
4645b3e38ee4Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4646b3e38ee4Smrg	      eval '$MV "$nlist"T "$nlist"'
4647b3e38ee4Smrg	    }
4648b3e38ee4Smrg	  fi
4649b3e38ee4Smrg
4650b3e38ee4Smrg	  # Prepare the list of exported symbols
4651b3e38ee4Smrg	  if test -z "$export_symbols"; then
46524a8d91dcSmrg	    export_symbols=$output_objdir/$outputname.exp
4653b3e38ee4Smrg	    $opt_dry_run || {
4654b3e38ee4Smrg	      $RM $export_symbols
46554a8d91dcSmrg	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4656b3e38ee4Smrg	      case $host in
4657b3e38ee4Smrg	      *cygwin* | *mingw* | *cegcc* )
4658b3e38ee4Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4659b3e38ee4Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4660b3e38ee4Smrg	        ;;
4661b3e38ee4Smrg	      esac
4662b3e38ee4Smrg	    }
4663a18ebfb2Smrg	  else
4664b3e38ee4Smrg	    $opt_dry_run || {
46654a8d91dcSmrg	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4666b3e38ee4Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4667b3e38ee4Smrg	      eval '$MV "$nlist"T "$nlist"'
4668b3e38ee4Smrg	      case $host in
4669a73423d7Smrg	        *cygwin* | *mingw* | *cegcc* )
4670b3e38ee4Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4671b3e38ee4Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4672b3e38ee4Smrg	          ;;
4673b3e38ee4Smrg	      esac
4674b3e38ee4Smrg	    }
4675a18ebfb2Smrg	  fi
4676b3e38ee4Smrg	fi
467750806d53Smrg
4678b3e38ee4Smrg	for dlprefile in $dlprefiles; do
46794a8d91dcSmrg	  func_verbose "extracting global C symbols from '$dlprefile'"
4680b3e38ee4Smrg	  func_basename "$dlprefile"
46814a8d91dcSmrg	  name=$func_basename_result
4682a73423d7Smrg          case $host in
4683a73423d7Smrg	    *cygwin* | *mingw* | *cegcc* )
4684a73423d7Smrg	      # if an import library, we need to obtain dlname
4685a73423d7Smrg	      if func_win32_import_lib_p "$dlprefile"; then
4686a73423d7Smrg	        func_tr_sh "$dlprefile"
4687a73423d7Smrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
46884a8d91dcSmrg	        dlprefile_dlbasename=
4689a73423d7Smrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
4690a73423d7Smrg	          # Use subshell, to avoid clobbering current variable values
4691a73423d7Smrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
46924a8d91dcSmrg	          if test -n "$dlprefile_dlname"; then
4693a73423d7Smrg	            func_basename "$dlprefile_dlname"
46944a8d91dcSmrg	            dlprefile_dlbasename=$func_basename_result
4695a73423d7Smrg	          else
4696a73423d7Smrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
4697a73423d7Smrg	            $sharedlib_from_linklib_cmd "$dlprefile"
4698a73423d7Smrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
4699a73423d7Smrg	          fi
4700a73423d7Smrg	        fi
4701a73423d7Smrg	        $opt_dry_run || {
47024a8d91dcSmrg	          if test -n "$dlprefile_dlbasename"; then
4703a73423d7Smrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
4704a73423d7Smrg	          else
4705a73423d7Smrg	            func_warning "Could not compute DLL name from $name"
4706a73423d7Smrg	            eval '$ECHO ": $name " >> "$nlist"'
4707a73423d7Smrg	          fi
4708a73423d7Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4709a73423d7Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
4710a73423d7Smrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
4711a73423d7Smrg	        }
4712a73423d7Smrg	      else # not an import lib
4713a73423d7Smrg	        $opt_dry_run || {
4714a73423d7Smrg	          eval '$ECHO ": $name " >> "$nlist"'
4715a73423d7Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4716a73423d7Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4717a73423d7Smrg	        }
4718a73423d7Smrg	      fi
4719a73423d7Smrg	    ;;
4720a73423d7Smrg	    *)
4721a73423d7Smrg	      $opt_dry_run || {
4722a73423d7Smrg	        eval '$ECHO ": $name " >> "$nlist"'
4723a73423d7Smrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4724a73423d7Smrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4725a73423d7Smrg	      }
4726a73423d7Smrg	    ;;
4727a73423d7Smrg          esac
4728b3e38ee4Smrg	done
4729b3e38ee4Smrg
4730b3e38ee4Smrg	$opt_dry_run || {
4731b3e38ee4Smrg	  # Make sure we have at least an empty file.
4732b3e38ee4Smrg	  test -f "$nlist" || : > "$nlist"
4733b3e38ee4Smrg
4734b3e38ee4Smrg	  if test -n "$exclude_expsyms"; then
4735b3e38ee4Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4736b3e38ee4Smrg	    $MV "$nlist"T "$nlist"
4737a18ebfb2Smrg	  fi
4738b3e38ee4Smrg
4739b3e38ee4Smrg	  # Try sorting and uniquifying the output.
4740b3e38ee4Smrg	  if $GREP -v "^: " < "$nlist" |
4741b3e38ee4Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
4742b3e38ee4Smrg		sort -k 3
4743b3e38ee4Smrg	      else
4744b3e38ee4Smrg		sort +2
4745b3e38ee4Smrg	      fi |
4746b3e38ee4Smrg	      uniq > "$nlist"S; then
4747b3e38ee4Smrg	    :
4748a18ebfb2Smrg	  else
4749b3e38ee4Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
4750a18ebfb2Smrg	  fi
475150806d53Smrg
4752b3e38ee4Smrg	  if test -f "$nlist"S; then
4753b3e38ee4Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
4754a18ebfb2Smrg	  else
4755a73423d7Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
4756a18ebfb2Smrg	  fi
475750806d53Smrg
47584a8d91dcSmrg	  func_show_eval '$RM "${nlist}I"'
47594a8d91dcSmrg	  if test -n "$global_symbol_to_import"; then
47604a8d91dcSmrg	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
47614a8d91dcSmrg	  fi
47624a8d91dcSmrg
4763a73423d7Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
476450806d53Smrg
4765b3e38ee4Smrg/* The mapping between symbol names and symbols.  */
4766b3e38ee4Smrgtypedef struct {
4767b3e38ee4Smrg  const char *name;
4768b3e38ee4Smrg  void *address;
4769b3e38ee4Smrg} lt_dlsymlist;
4770a73423d7Smrgextern LT_DLSYM_CONST lt_dlsymlist
47714a8d91dcSmrglt_${my_prefix}_LTX_preloaded_symbols[];\
47724a8d91dcSmrg"
47734a8d91dcSmrg
47744a8d91dcSmrg	  if test -s "$nlist"I; then
47754a8d91dcSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
47764a8d91dcSmrgstatic void lt_syminit(void)
47774a8d91dcSmrg{
47784a8d91dcSmrg  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
47794a8d91dcSmrg  for (; symbol->name; ++symbol)
47804a8d91dcSmrg    {"
47814a8d91dcSmrg	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
47824a8d91dcSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
47834a8d91dcSmrg    }
47844a8d91dcSmrg}"
47854a8d91dcSmrg	  fi
47864a8d91dcSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
4787a73423d7SmrgLT_DLSYM_CONST lt_dlsymlist
4788b3e38ee4Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
47894a8d91dcSmrg{ {\"$my_originator\", (void *) 0},"
47904a8d91dcSmrg
47914a8d91dcSmrg	  if test -s "$nlist"I; then
47924a8d91dcSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
47934a8d91dcSmrg  {\"@INIT@\", (void *) &lt_syminit},"
47944a8d91dcSmrg	  fi
479550806d53Smrg
4796b3e38ee4Smrg	  case $need_lib_prefix in
4797b3e38ee4Smrg	  no)
4798b3e38ee4Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
4799b3e38ee4Smrg	    ;;
4800b3e38ee4Smrg	  *)
4801b3e38ee4Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
4802b3e38ee4Smrg	    ;;
4803b3e38ee4Smrg	  esac
4804a73423d7Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
4805b3e38ee4Smrg  {0, (void *) 0}
4806b3e38ee4Smrg};
480750806d53Smrg
4808b3e38ee4Smrg/* This works around a problem in FreeBSD linker */
4809b3e38ee4Smrg#ifdef FREEBSD_WORKAROUND
4810b3e38ee4Smrgstatic const void *lt_preloaded_setup() {
4811b3e38ee4Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
4812b3e38ee4Smrg}
4813b3e38ee4Smrg#endif
4814b3e38ee4Smrg
4815b3e38ee4Smrg#ifdef __cplusplus
4816b3e38ee4Smrg}
4817b3e38ee4Smrg#endif\
4818b3e38ee4Smrg"
4819b3e38ee4Smrg	} # !$opt_dry_run
4820b3e38ee4Smrg
4821b3e38ee4Smrg	pic_flag_for_symtable=
4822b3e38ee4Smrg	case "$compile_command " in
4823b3e38ee4Smrg	*" -static "*) ;;
4824b3e38ee4Smrg	*)
4825b3e38ee4Smrg	  case $host in
4826b3e38ee4Smrg	  # compiling the symbol table file with pic_flag works around
4827b3e38ee4Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
4828b3e38ee4Smrg	  # linked before any other PIC object.  But we must not use
4829b3e38ee4Smrg	  # pic_flag when linking with -static.  The problem exists in
4830b3e38ee4Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4831a73423d7Smrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4832b3e38ee4Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
4833b3e38ee4Smrg	  *-*-hpux*)
4834b3e38ee4Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
4835b3e38ee4Smrg	  *)
48364a8d91dcSmrg	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
4837b3e38ee4Smrg	    ;;
4838b3e38ee4Smrg	  esac
4839b3e38ee4Smrg	  ;;
4840b3e38ee4Smrg	esac
4841b3e38ee4Smrg	symtab_cflags=
4842b3e38ee4Smrg	for arg in $LTCFLAGS; do
4843b3e38ee4Smrg	  case $arg in
4844b3e38ee4Smrg	  -pie | -fpie | -fPIE) ;;
4845a73423d7Smrg	  *) func_append symtab_cflags " $arg" ;;
4846b3e38ee4Smrg	  esac
4847b3e38ee4Smrg	done
484850806d53Smrg
4849b3e38ee4Smrg	# Now compile the dynamic symbol file.
4850b3e38ee4Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
4851af1a9c97Smrg
4852b3e38ee4Smrg	# Clean up the generated files.
48534a8d91dcSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
485450806d53Smrg
4855b3e38ee4Smrg	# Transform the symbol file into the correct name.
48564a8d91dcSmrg	symfileobj=$output_objdir/${my_outputname}S.$objext
4857b3e38ee4Smrg	case $host in
4858b3e38ee4Smrg	*cygwin* | *mingw* | *cegcc* )
4859b3e38ee4Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
4860a73423d7Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4861a73423d7Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4862b3e38ee4Smrg	  else
4863a73423d7Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4864a73423d7Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4865a18ebfb2Smrg	  fi
4866b3e38ee4Smrg	  ;;
4867b3e38ee4Smrg	*)
4868a73423d7Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4869a73423d7Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4870b3e38ee4Smrg	  ;;
4871b3e38ee4Smrg	esac
4872b3e38ee4Smrg	;;
4873b3e38ee4Smrg      *)
48744a8d91dcSmrg	func_fatal_error "unknown suffix for '$my_dlsyms'"
4875b3e38ee4Smrg	;;
4876b3e38ee4Smrg      esac
4877b3e38ee4Smrg    else
4878b3e38ee4Smrg      # We keep going just in case the user didn't refer to
4879b3e38ee4Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
4880b3e38ee4Smrg      # really was required.
488150806d53Smrg
4882b3e38ee4Smrg      # Nullify the symbol file.
4883a73423d7Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
4884a73423d7Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
4885b3e38ee4Smrg    fi
4886b3e38ee4Smrg}
4887af1a9c97Smrg
48884a8d91dcSmrg# func_cygming_gnu_implib_p ARG
48894a8d91dcSmrg# This predicate returns with zero status (TRUE) if
48904a8d91dcSmrg# ARG is a GNU/binutils-style import library. Returns
48914a8d91dcSmrg# with nonzero status (FALSE) otherwise.
48924a8d91dcSmrgfunc_cygming_gnu_implib_p ()
48934a8d91dcSmrg{
48944a8d91dcSmrg  $debug_cmd
48954a8d91dcSmrg
48964a8d91dcSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
48974a8d91dcSmrg  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)$'`
48984a8d91dcSmrg  test -n "$func_cygming_gnu_implib_tmp"
48994a8d91dcSmrg}
49004a8d91dcSmrg
49014a8d91dcSmrg# func_cygming_ms_implib_p ARG
49024a8d91dcSmrg# This predicate returns with zero status (TRUE) if
49034a8d91dcSmrg# ARG is an MS-style import library. Returns
49044a8d91dcSmrg# with nonzero status (FALSE) otherwise.
49054a8d91dcSmrgfunc_cygming_ms_implib_p ()
49064a8d91dcSmrg{
49074a8d91dcSmrg  $debug_cmd
49084a8d91dcSmrg
49094a8d91dcSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
49104a8d91dcSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
49114a8d91dcSmrg  test -n "$func_cygming_ms_implib_tmp"
49124a8d91dcSmrg}
49134a8d91dcSmrg
4914b3e38ee4Smrg# func_win32_libid arg
4915b3e38ee4Smrg# return the library type of file 'arg'
4916b3e38ee4Smrg#
4917b3e38ee4Smrg# Need a lot of goo to handle *both* DLLs and import libs
4918b3e38ee4Smrg# Has to be a shell function in order to 'eat' the argument
4919b3e38ee4Smrg# that is supplied when $file_magic_command is called.
4920a73423d7Smrg# Despite the name, also deal with 64 bit binaries.
4921b3e38ee4Smrgfunc_win32_libid ()
4922b3e38ee4Smrg{
49234a8d91dcSmrg  $debug_cmd
49244a8d91dcSmrg
49254a8d91dcSmrg  win32_libid_type=unknown
4926b3e38ee4Smrg  win32_fileres=`file -L $1 2>/dev/null`
4927b3e38ee4Smrg  case $win32_fileres in
4928b3e38ee4Smrg  *ar\ archive\ import\ library*) # definitely import
4929b3e38ee4Smrg    win32_libid_type="x86 archive import"
4930b3e38ee4Smrg    ;;
4931b3e38ee4Smrg  *ar\ archive*) # could be an import, or static
4932a73423d7Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
4933b3e38ee4Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
4934a73423d7Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
49354a8d91dcSmrg      case $nm_interface in
49364a8d91dcSmrg      "MS dumpbin")
49374a8d91dcSmrg	if func_cygming_ms_implib_p "$1" ||
49384a8d91dcSmrg	   func_cygming_gnu_implib_p "$1"
49394a8d91dcSmrg	then
49404a8d91dcSmrg	  win32_nmres=import
49414a8d91dcSmrg	else
49424a8d91dcSmrg	  win32_nmres=
49434a8d91dcSmrg	fi
49444a8d91dcSmrg	;;
49454a8d91dcSmrg      *)
49464a8d91dcSmrg	func_to_tool_file "$1" func_convert_file_msys_to_w32
49474a8d91dcSmrg	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
49484a8d91dcSmrg	  $SED -n -e '
4949b3e38ee4Smrg	    1,100{
4950b3e38ee4Smrg		/ I /{
49514a8d91dcSmrg		    s|.*|import|
4952b3e38ee4Smrg		    p
4953b3e38ee4Smrg		    q
4954b3e38ee4Smrg		}
4955b3e38ee4Smrg	    }'`
49564a8d91dcSmrg	;;
49574a8d91dcSmrg      esac
4958b3e38ee4Smrg      case $win32_nmres in
4959b3e38ee4Smrg      import*)  win32_libid_type="x86 archive import";;
4960b3e38ee4Smrg      *)        win32_libid_type="x86 archive static";;
4961b3e38ee4Smrg      esac
4962b3e38ee4Smrg    fi
4963b3e38ee4Smrg    ;;
4964b3e38ee4Smrg  *DLL*)
4965b3e38ee4Smrg    win32_libid_type="x86 DLL"
4966b3e38ee4Smrg    ;;
4967b3e38ee4Smrg  *executable*) # but shell scripts are "executable" too...
4968b3e38ee4Smrg    case $win32_fileres in
4969b3e38ee4Smrg    *MS\ Windows\ PE\ Intel*)
4970b3e38ee4Smrg      win32_libid_type="x86 DLL"
4971b3e38ee4Smrg      ;;
4972b3e38ee4Smrg    esac
4973b3e38ee4Smrg    ;;
4974b3e38ee4Smrg  esac
4975b3e38ee4Smrg  $ECHO "$win32_libid_type"
4976b3e38ee4Smrg}
4977af1a9c97Smrg
4978a73423d7Smrg# func_cygming_dll_for_implib ARG
4979a73423d7Smrg#
4980a73423d7Smrg# Platform-specific function to extract the
4981a73423d7Smrg# name of the DLL associated with the specified
4982a73423d7Smrg# import library ARG.
4983a73423d7Smrg# Invoked by eval'ing the libtool variable
4984a73423d7Smrg#    $sharedlib_from_linklib_cmd
4985a73423d7Smrg# Result is available in the variable
4986a73423d7Smrg#    $sharedlib_from_linklib_result
4987a73423d7Smrgfunc_cygming_dll_for_implib ()
4988a73423d7Smrg{
49894a8d91dcSmrg  $debug_cmd
49904a8d91dcSmrg
4991a73423d7Smrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
4992a73423d7Smrg}
4993a73423d7Smrg
4994a73423d7Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
4995a73423d7Smrg#
4996a73423d7Smrg# The is the core of a fallback implementation of a
4997a73423d7Smrg# platform-specific function to extract the name of the
4998a73423d7Smrg# DLL associated with the specified import library LIBNAME.
4999a73423d7Smrg#
5000a73423d7Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending
5001a73423d7Smrg# on the platform and compiler that created the implib.
5002a73423d7Smrg#
5003a73423d7Smrg# Echos the name of the DLL associated with the
5004a73423d7Smrg# specified import library.
5005a73423d7Smrgfunc_cygming_dll_for_implib_fallback_core ()
5006a73423d7Smrg{
50074a8d91dcSmrg  $debug_cmd
50084a8d91dcSmrg
5009a73423d7Smrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
5010a73423d7Smrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
5011a73423d7Smrg    $SED '/^Contents of section '"$match_literal"':/{
5012a73423d7Smrg      # Place marker at beginning of archive member dllname section
5013a73423d7Smrg      s/.*/====MARK====/
5014a73423d7Smrg      p
5015a73423d7Smrg      d
5016a73423d7Smrg    }
5017a73423d7Smrg    # These lines can sometimes be longer than 43 characters, but
5018a73423d7Smrg    # are always uninteresting
5019a73423d7Smrg    /:[	 ]*file format pe[i]\{,1\}-/d
5020a73423d7Smrg    /^In archive [^:]*:/d
5021a73423d7Smrg    # Ensure marker is printed
5022a73423d7Smrg    /^====MARK====/p
5023a73423d7Smrg    # Remove all lines with less than 43 characters
5024a73423d7Smrg    /^.\{43\}/!d
5025a73423d7Smrg    # From remaining lines, remove first 43 characters
5026a73423d7Smrg    s/^.\{43\}//' |
5027a73423d7Smrg    $SED -n '
5028a73423d7Smrg      # Join marker and all lines until next marker into a single line
5029a73423d7Smrg      /^====MARK====/ b para
5030a73423d7Smrg      H
5031a73423d7Smrg      $ b para
5032a73423d7Smrg      b
5033a73423d7Smrg      :para
5034a73423d7Smrg      x
5035a73423d7Smrg      s/\n//g
5036a73423d7Smrg      # Remove the marker
5037a73423d7Smrg      s/^====MARK====//
5038a73423d7Smrg      # Remove trailing dots and whitespace
5039a73423d7Smrg      s/[\. \t]*$//
5040a73423d7Smrg      # Print
5041a73423d7Smrg      /./p' |
5042a73423d7Smrg    # we now have a list, one entry per line, of the stringified
5043a73423d7Smrg    # contents of the appropriate section of all members of the
50444a8d91dcSmrg    # archive that possess that section. Heuristic: eliminate
50454a8d91dcSmrg    # all those that have a first or second character that is
5046a73423d7Smrg    # a '.' (that is, objdump's representation of an unprintable
5047a73423d7Smrg    # character.) This should work for all archives with less than
5048a73423d7Smrg    # 0x302f exports -- but will fail for DLLs whose name actually
5049a73423d7Smrg    # begins with a literal '.' or a single character followed by
5050a73423d7Smrg    # a '.'.
5051a73423d7Smrg    #
5052a73423d7Smrg    # Of those that remain, print the first one.
5053a73423d7Smrg    $SED -e '/^\./d;/^.\./d;q'
5054a73423d7Smrg}
5055a73423d7Smrg
5056a73423d7Smrg# func_cygming_dll_for_implib_fallback ARG
5057a73423d7Smrg# Platform-specific function to extract the
5058a73423d7Smrg# name of the DLL associated with the specified
5059a73423d7Smrg# import library ARG.
5060a73423d7Smrg#
5061a73423d7Smrg# This fallback implementation is for use when $DLLTOOL
5062a73423d7Smrg# does not support the --identify-strict option.
5063a73423d7Smrg# Invoked by eval'ing the libtool variable
5064a73423d7Smrg#    $sharedlib_from_linklib_cmd
5065a73423d7Smrg# Result is available in the variable
5066a73423d7Smrg#    $sharedlib_from_linklib_result
5067a73423d7Smrgfunc_cygming_dll_for_implib_fallback ()
5068a73423d7Smrg{
50694a8d91dcSmrg  $debug_cmd
50704a8d91dcSmrg
50714a8d91dcSmrg  if func_cygming_gnu_implib_p "$1"; then
5072a73423d7Smrg    # binutils import library
5073a73423d7Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
50744a8d91dcSmrg  elif func_cygming_ms_implib_p "$1"; then
5075a73423d7Smrg    # ms-generated import library
5076a73423d7Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
5077a73423d7Smrg  else
5078a73423d7Smrg    # unknown
50794a8d91dcSmrg    sharedlib_from_linklib_result=
5080a73423d7Smrg  fi
5081a73423d7Smrg}
5082af1a9c97Smrg
5083af1a9c97Smrg
5084b3e38ee4Smrg# func_extract_an_archive dir oldlib
5085b3e38ee4Smrgfunc_extract_an_archive ()
5086b3e38ee4Smrg{
50874a8d91dcSmrg    $debug_cmd
50884a8d91dcSmrg
50894a8d91dcSmrg    f_ex_an_ar_dir=$1; shift
50904a8d91dcSmrg    f_ex_an_ar_oldlib=$1
50914a8d91dcSmrg    if test yes = "$lock_old_archive_extraction"; then
5092a73423d7Smrg      lockfile=$f_ex_an_ar_oldlib.lock
5093a73423d7Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
5094a73423d7Smrg	func_echo "Waiting for $lockfile to be removed"
5095a73423d7Smrg	sleep 2
5096a73423d7Smrg      done
5097a73423d7Smrg    fi
5098a73423d7Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
5099a73423d7Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
51004a8d91dcSmrg    if test yes = "$lock_old_archive_extraction"; then
5101a73423d7Smrg      $opt_dry_run || rm -f "$lockfile"
5102a73423d7Smrg    fi
5103b3e38ee4Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
5104b3e38ee4Smrg     :
5105b3e38ee4Smrg    else
5106b3e38ee4Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
5107b3e38ee4Smrg    fi
5108b3e38ee4Smrg}
510950806d53Smrg
511050806d53Smrg
5111b3e38ee4Smrg# func_extract_archives gentop oldlib ...
5112b3e38ee4Smrgfunc_extract_archives ()
5113b3e38ee4Smrg{
51144a8d91dcSmrg    $debug_cmd
51154a8d91dcSmrg
51164a8d91dcSmrg    my_gentop=$1; shift
5117b3e38ee4Smrg    my_oldlibs=${1+"$@"}
51184a8d91dcSmrg    my_oldobjs=
51194a8d91dcSmrg    my_xlib=
51204a8d91dcSmrg    my_xabs=
51214a8d91dcSmrg    my_xdir=
512250806d53Smrg
5123b3e38ee4Smrg    for my_xlib in $my_oldlibs; do
5124b3e38ee4Smrg      # Extract the objects.
5125b3e38ee4Smrg      case $my_xlib in
51264a8d91dcSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
5127b3e38ee4Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
5128b3e38ee4Smrg      esac
5129b3e38ee4Smrg      func_basename "$my_xlib"
51304a8d91dcSmrg      my_xlib=$func_basename_result
5131b3e38ee4Smrg      my_xlib_u=$my_xlib
5132b3e38ee4Smrg      while :; do
5133b3e38ee4Smrg        case " $extracted_archives " in
5134b3e38ee4Smrg	*" $my_xlib_u "*)
5135b3e38ee4Smrg	  func_arith $extracted_serial + 1
5136b3e38ee4Smrg	  extracted_serial=$func_arith_result
5137b3e38ee4Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
5138b3e38ee4Smrg	*) break ;;
5139b3e38ee4Smrg	esac
5140b3e38ee4Smrg      done
5141b3e38ee4Smrg      extracted_archives="$extracted_archives $my_xlib_u"
51424a8d91dcSmrg      my_xdir=$my_gentop/$my_xlib_u
514350806d53Smrg
5144b3e38ee4Smrg      func_mkdir_p "$my_xdir"
5145af1a9c97Smrg
5146b3e38ee4Smrg      case $host in
5147b3e38ee4Smrg      *-darwin*)
5148b3e38ee4Smrg	func_verbose "Extracting $my_xabs"
5149b3e38ee4Smrg	# Do not bother doing anything if just a dry run
5150b3e38ee4Smrg	$opt_dry_run || {
5151b3e38ee4Smrg	  darwin_orig_dir=`pwd`
5152b3e38ee4Smrg	  cd $my_xdir || exit $?
5153b3e38ee4Smrg	  darwin_archive=$my_xabs
5154b3e38ee4Smrg	  darwin_curdir=`pwd`
51554a8d91dcSmrg	  func_basename "$darwin_archive"
51564a8d91dcSmrg	  darwin_base_archive=$func_basename_result
5157b3e38ee4Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
5158b3e38ee4Smrg	  if test -n "$darwin_arches"; then
5159b3e38ee4Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
5160b3e38ee4Smrg	    darwin_arch=
5161b3e38ee4Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
51624a8d91dcSmrg	    for darwin_arch in  $darwin_arches; do
51634a8d91dcSmrg	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
51644a8d91dcSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
51654a8d91dcSmrg	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
51664a8d91dcSmrg	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
5167b3e38ee4Smrg	      cd "$darwin_curdir"
51684a8d91dcSmrg	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
5169b3e38ee4Smrg	    done # $darwin_arches
5170b3e38ee4Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
51714a8d91dcSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
5172b3e38ee4Smrg	    darwin_file=
5173b3e38ee4Smrg	    darwin_files=
5174b3e38ee4Smrg	    for darwin_file in $darwin_filelist; do
5175a73423d7Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
5176b3e38ee4Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
5177b3e38ee4Smrg	    done # $darwin_filelist
5178b3e38ee4Smrg	    $RM -rf unfat-$$
5179b3e38ee4Smrg	    cd "$darwin_orig_dir"
5180a18ebfb2Smrg	  else
5181b3e38ee4Smrg	    cd $darwin_orig_dir
5182b3e38ee4Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
5183b3e38ee4Smrg	  fi # $darwin_arches
5184b3e38ee4Smrg	} # !$opt_dry_run
5185b3e38ee4Smrg	;;
5186b3e38ee4Smrg      *)
5187b3e38ee4Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
5188b3e38ee4Smrg	;;
5189b3e38ee4Smrg      esac
5190a73423d7Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
5191b3e38ee4Smrg    done
519250806d53Smrg
51934a8d91dcSmrg    func_extract_archives_result=$my_oldobjs
5194b3e38ee4Smrg}
519550806d53Smrg
519650806d53Smrg
5197a73423d7Smrg# func_emit_wrapper [arg=no]
5198a73423d7Smrg#
5199a73423d7Smrg# Emit a libtool wrapper script on stdout.
5200a73423d7Smrg# Don't directly open a file because we may want to
5201a73423d7Smrg# incorporate the script contents within a cygwin/mingw
5202a73423d7Smrg# wrapper executable.  Must ONLY be called from within
5203a73423d7Smrg# func_mode_link because it depends on a number of variables
5204a73423d7Smrg# set therein.
5205b3e38ee4Smrg#
5206a73423d7Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
5207a73423d7Smrg# variable will take.  If 'yes', then the emitted script
52084a8d91dcSmrg# will assume that the directory where it is stored is
5209a73423d7Smrg# the $objdir directory.  This is a cygwin/mingw-specific
5210a73423d7Smrg# behavior.
5211a73423d7Smrgfunc_emit_wrapper ()
5212b3e38ee4Smrg{
5213a73423d7Smrg	func_emit_wrapper_arg1=${1-no}
5214a18ebfb2Smrg
5215b3e38ee4Smrg	$ECHO "\
5216b3e38ee4Smrg#! $SHELL
521750806d53Smrg
5218b3e38ee4Smrg# $output - temporary wrapper script for $objdir/$outputname
52194a8d91dcSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5220b3e38ee4Smrg#
5221b3e38ee4Smrg# The $output program cannot be directly executed until all the libtool
5222b3e38ee4Smrg# libraries that it depends on are installed.
5223b3e38ee4Smrg#
5224b3e38ee4Smrg# This wrapper script should never be moved out of the build directory.
5225b3e38ee4Smrg# If it is, it will not operate correctly.
522650806d53Smrg
5227b3e38ee4Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
5228b3e38ee4Smrg# metacharacters that are still active within double-quoted strings.
5229b3e38ee4Smrgsed_quote_subst='$sed_quote_subst'
523050806d53Smrg
5231b3e38ee4Smrg# Be Bourne compatible
5232b3e38ee4Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5233b3e38ee4Smrg  emulate sh
5234b3e38ee4Smrg  NULLCMD=:
5235b3e38ee4Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5236b3e38ee4Smrg  # is contrary to our usage.  Disable this feature.
5237b3e38ee4Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
5238b3e38ee4Smrg  setopt NO_GLOB_SUBST
5239b3e38ee4Smrgelse
5240b3e38ee4Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5241b3e38ee4Smrgfi
5242b3e38ee4SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
5243b3e38ee4SmrgDUALCASE=1; export DUALCASE # for MKS sh
524450806d53Smrg
5245b3e38ee4Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
5246b3e38ee4Smrg# if CDPATH is set.
5247b3e38ee4Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
524850806d53Smrg
5249b3e38ee4Smrgrelink_command=\"$relink_command\"
525050806d53Smrg
5251b3e38ee4Smrg# This environment variable determines our operation mode.
5252b3e38ee4Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
5253b3e38ee4Smrg  # install mode needs the following variables:
5254b3e38ee4Smrg  generated_by_libtool_version='$macro_version'
5255b3e38ee4Smrg  notinst_deplibs='$notinst_deplibs'
5256b3e38ee4Smrgelse
5257b3e38ee4Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
5258b3e38ee4Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
5259a73423d7Smrg    file=\"\$0\""
5260a73423d7Smrg
5261a73423d7Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
5262a73423d7Smrg    $ECHO "\
5263a73423d7Smrg
5264a73423d7Smrg# A function that is used when there is no print builtin or printf.
5265a73423d7Smrgfunc_fallback_echo ()
5266a73423d7Smrg{
5267a73423d7Smrg  eval 'cat <<_LTECHO_EOF
5268a73423d7Smrg\$1
5269a73423d7Smrg_LTECHO_EOF'
5270a73423d7Smrg}
5271a73423d7Smrg    ECHO=\"$qECHO\"
5272a73423d7Smrg  fi
5273a73423d7Smrg
5274a73423d7Smrg# Very basic option parsing. These options are (a) specific to
5275a73423d7Smrg# the libtool wrapper, (b) are identical between the wrapper
52764a8d91dcSmrg# /script/ and the wrapper /executable/ that is used only on
5277a73423d7Smrg# windows platforms, and (c) all begin with the string "--lt-"
52784a8d91dcSmrg# (application programs are unlikely to have options that match
5279a73423d7Smrg# this pattern).
5280a73423d7Smrg#
5281a73423d7Smrg# There are only two supported options: --lt-debug and
5282a73423d7Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
5283a73423d7Smrg#
5284a73423d7Smrg# The first argument to this parsing function should be the
5285a73423d7Smrg# script's $0 value, followed by "$@".
5286a73423d7Smrglt_option_debug=
5287a73423d7Smrgfunc_parse_lt_options ()
5288a73423d7Smrg{
5289a73423d7Smrg  lt_script_arg0=\$0
5290a73423d7Smrg  shift
5291a73423d7Smrg  for lt_opt
5292a73423d7Smrg  do
5293a73423d7Smrg    case \"\$lt_opt\" in
5294a73423d7Smrg    --lt-debug) lt_option_debug=1 ;;
5295a73423d7Smrg    --lt-dump-script)
5296a73423d7Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
5297a73423d7Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
5298a73423d7Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
5299a73423d7Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
5300a73423d7Smrg        exit 0
5301a73423d7Smrg      ;;
5302a73423d7Smrg    --lt-*)
5303a73423d7Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
5304a73423d7Smrg        exit 1
5305a73423d7Smrg      ;;
5306a73423d7Smrg    esac
5307a73423d7Smrg  done
5308a73423d7Smrg
5309a73423d7Smrg  # Print the debug banner immediately:
5310a73423d7Smrg  if test -n \"\$lt_option_debug\"; then
53114a8d91dcSmrg    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
5312a73423d7Smrg  fi
5313a73423d7Smrg}
5314a73423d7Smrg
5315a73423d7Smrg# Used when --lt-debug. Prints its arguments to stdout
5316a73423d7Smrg# (redirection is the responsibility of the caller)
5317a73423d7Smrgfunc_lt_dump_args ()
5318a73423d7Smrg{
5319a73423d7Smrg  lt_dump_args_N=1;
5320a73423d7Smrg  for lt_arg
5321a73423d7Smrg  do
53224a8d91dcSmrg    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
5323a73423d7Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
5324a73423d7Smrg  done
5325a73423d7Smrg}
5326a73423d7Smrg
5327a73423d7Smrg# Core function for launching the target application
5328a73423d7Smrgfunc_exec_program_core ()
5329a73423d7Smrg{
5330b3e38ee4Smrg"
5331a73423d7Smrg  case $host in
5332a73423d7Smrg  # Backslashes separate directories on plain windows
5333a73423d7Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
5334a73423d7Smrg    $ECHO "\
5335a73423d7Smrg      if test -n \"\$lt_option_debug\"; then
53364a8d91dcSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
5337a73423d7Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5338a73423d7Smrg      fi
5339a73423d7Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5340a73423d7Smrg"
5341a73423d7Smrg    ;;
5342a73423d7Smrg
5343a73423d7Smrg  *)
5344a73423d7Smrg    $ECHO "\
5345a73423d7Smrg      if test -n \"\$lt_option_debug\"; then
53464a8d91dcSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
5347a73423d7Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5348a73423d7Smrg      fi
5349a73423d7Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
5350a73423d7Smrg"
5351a73423d7Smrg    ;;
5352a73423d7Smrg  esac
5353a73423d7Smrg  $ECHO "\
5354a73423d7Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
5355a73423d7Smrg      exit 1
5356a73423d7Smrg}
5357a73423d7Smrg
5358a73423d7Smrg# A function to encapsulate launching the target application
5359a73423d7Smrg# Strips options in the --lt-* namespace from \$@ and
5360a73423d7Smrg# launches target application with the remaining arguments.
5361a73423d7Smrgfunc_exec_program ()
5362a73423d7Smrg{
5363a73423d7Smrg  case \" \$* \" in
5364a73423d7Smrg  *\\ --lt-*)
5365a73423d7Smrg    for lt_wr_arg
5366a73423d7Smrg    do
5367a73423d7Smrg      case \$lt_wr_arg in
5368a73423d7Smrg      --lt-*) ;;
5369a73423d7Smrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
5370a73423d7Smrg      esac
5371a73423d7Smrg      shift
5372a73423d7Smrg    done ;;
5373a73423d7Smrg  esac
5374a73423d7Smrg  func_exec_program_core \${1+\"\$@\"}
5375a73423d7Smrg}
5376a73423d7Smrg
5377a73423d7Smrg  # Parse options
5378a73423d7Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
537950806d53Smrg
5380b3e38ee4Smrg  # Find the directory that this script lives in.
5381a73423d7Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
5382b3e38ee4Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
538350806d53Smrg
5384b3e38ee4Smrg  # Follow symbolic links until we get to the real thisdir.
5385a73423d7Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
5386b3e38ee4Smrg  while test -n \"\$file\"; do
5387a73423d7Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
538850806d53Smrg
5389b3e38ee4Smrg    # If there was a directory component, then change thisdir.
5390b3e38ee4Smrg    if test \"x\$destdir\" != \"x\$file\"; then
5391b3e38ee4Smrg      case \"\$destdir\" in
5392b3e38ee4Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5393b3e38ee4Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
5394a18ebfb2Smrg      esac
5395b3e38ee4Smrg    fi
539650806d53Smrg
5397a73423d7Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
5398a73423d7Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
5399b3e38ee4Smrg  done
540050806d53Smrg
5401b3e38ee4Smrg  # Usually 'no', except on cygwin/mingw when embedded into
5402b3e38ee4Smrg  # the cwrapper.
5403a73423d7Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
5404b3e38ee4Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
5405b3e38ee4Smrg    # special case for '.'
5406b3e38ee4Smrg    if test \"\$thisdir\" = \".\"; then
5407b3e38ee4Smrg      thisdir=\`pwd\`
5408b3e38ee4Smrg    fi
5409b3e38ee4Smrg    # remove .libs from thisdir
5410b3e38ee4Smrg    case \"\$thisdir\" in
5411a73423d7Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
5412b3e38ee4Smrg    $objdir )   thisdir=. ;;
5413b3e38ee4Smrg    esac
5414b3e38ee4Smrg  fi
5415b3e38ee4Smrg
5416b3e38ee4Smrg  # Try to get the absolute directory name.
5417b3e38ee4Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
5418b3e38ee4Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
5419b3e38ee4Smrg"
5420b3e38ee4Smrg
54214a8d91dcSmrg	if test yes = "$fast_install"; then
5422b3e38ee4Smrg	  $ECHO "\
5423b3e38ee4Smrg  program=lt-'$outputname'$exeext
5424b3e38ee4Smrg  progdir=\"\$thisdir/$objdir\"
5425b3e38ee4Smrg
5426b3e38ee4Smrg  if test ! -f \"\$progdir/\$program\" ||
54274a8d91dcSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
5428b3e38ee4Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
5429b3e38ee4Smrg
5430b3e38ee4Smrg    file=\"\$\$-\$program\"
5431b3e38ee4Smrg
5432b3e38ee4Smrg    if test ! -d \"\$progdir\"; then
5433b3e38ee4Smrg      $MKDIR \"\$progdir\"
5434b3e38ee4Smrg    else
5435b3e38ee4Smrg      $RM \"\$progdir/\$file\"
5436b3e38ee4Smrg    fi"
5437b3e38ee4Smrg
5438b3e38ee4Smrg	  $ECHO "\
5439b3e38ee4Smrg
5440b3e38ee4Smrg    # relink executable if necessary
5441b3e38ee4Smrg    if test -n \"\$relink_command\"; then
5442b3e38ee4Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5443b3e38ee4Smrg      else
54444a8d91dcSmrg	\$ECHO \"\$relink_command_output\" >&2
5445b3e38ee4Smrg	$RM \"\$progdir/\$file\"
5446b3e38ee4Smrg	exit 1
5447a18ebfb2Smrg      fi
5448b3e38ee4Smrg    fi
544950806d53Smrg
5450b3e38ee4Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5451b3e38ee4Smrg    { $RM \"\$progdir/\$program\";
5452b3e38ee4Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5453b3e38ee4Smrg    $RM \"\$progdir/\$file\"
5454b3e38ee4Smrg  fi"
5455b3e38ee4Smrg	else
5456b3e38ee4Smrg	  $ECHO "\
5457b3e38ee4Smrg  program='$outputname'
5458b3e38ee4Smrg  progdir=\"\$thisdir/$objdir\"
5459b3e38ee4Smrg"
5460a18ebfb2Smrg	fi
546150806d53Smrg
5462b3e38ee4Smrg	$ECHO "\
546350806d53Smrg
5464b3e38ee4Smrg  if test -f \"\$progdir/\$program\"; then"
546550806d53Smrg
5466a73423d7Smrg	# fixup the dll searchpath if we need to.
5467a73423d7Smrg	#
5468a73423d7Smrg	# Fix the DLL searchpath if we need to.  Do this before prepending
5469a73423d7Smrg	# to shlibpath, because on Windows, both are PATH and uninstalled
5470a73423d7Smrg	# libraries must come first.
5471a73423d7Smrg	if test -n "$dllsearchpath"; then
5472a73423d7Smrg	  $ECHO "\
5473a73423d7Smrg    # Add the dll search path components to the executable PATH
5474a73423d7Smrg    PATH=$dllsearchpath:\$PATH
5475a73423d7Smrg"
5476a73423d7Smrg	fi
5477a73423d7Smrg
5478b3e38ee4Smrg	# Export our shlibpath_var if we have one.
54794a8d91dcSmrg	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5480b3e38ee4Smrg	  $ECHO "\
5481b3e38ee4Smrg    # Add our own library path to $shlibpath_var
5482b3e38ee4Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
5483b3e38ee4Smrg
5484b3e38ee4Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
5485b3e38ee4Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
5486a73423d7Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
548750806d53Smrg
5488b3e38ee4Smrg    export $shlibpath_var
5489b3e38ee4Smrg"
5490a18ebfb2Smrg	fi
549150806d53Smrg
5492b3e38ee4Smrg	$ECHO "\
5493b3e38ee4Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
5494b3e38ee4Smrg      # Run the actual program with our arguments.
5495a73423d7Smrg      func_exec_program \${1+\"\$@\"}
5496b3e38ee4Smrg    fi
5497b3e38ee4Smrg  else
5498b3e38ee4Smrg    # The program doesn't exist.
54994a8d91dcSmrg    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
5500b3e38ee4Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
5501a73423d7Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
5502b3e38ee4Smrg    exit 1
5503b3e38ee4Smrg  fi
5504b3e38ee4Smrgfi\
5505b3e38ee4Smrg"
5506b3e38ee4Smrg}
550750806d53Smrg
5508af1a9c97Smrg
5509b3e38ee4Smrg# func_emit_cwrapperexe_src
5510b3e38ee4Smrg# emit the source code for a wrapper executable on stdout
5511b3e38ee4Smrg# Must ONLY be called from within func_mode_link because
5512b3e38ee4Smrg# it depends on a number of variable set therein.
5513b3e38ee4Smrgfunc_emit_cwrapperexe_src ()
5514b3e38ee4Smrg{
5515b3e38ee4Smrg	cat <<EOF
551650806d53Smrg
5517b3e38ee4Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
55184a8d91dcSmrg   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
551950806d53Smrg
5520b3e38ee4Smrg   The $output program cannot be directly executed until all the libtool
5521b3e38ee4Smrg   libraries that it depends on are installed.
552250806d53Smrg
5523b3e38ee4Smrg   This wrapper executable should never be moved out of the build directory.
5524b3e38ee4Smrg   If it is, it will not operate correctly.
5525b3e38ee4Smrg*/
5526b3e38ee4SmrgEOF
5527b3e38ee4Smrg	    cat <<"EOF"
5528a73423d7Smrg#ifdef _MSC_VER
5529a73423d7Smrg# define _CRT_SECURE_NO_DEPRECATE 1
5530a73423d7Smrg#endif
5531b3e38ee4Smrg#include <stdio.h>
5532b3e38ee4Smrg#include <stdlib.h>
5533b3e38ee4Smrg#ifdef _MSC_VER
5534b3e38ee4Smrg# include <direct.h>
5535b3e38ee4Smrg# include <process.h>
5536b3e38ee4Smrg# include <io.h>
5537b3e38ee4Smrg#else
5538b3e38ee4Smrg# include <unistd.h>
5539b3e38ee4Smrg# include <stdint.h>
5540b3e38ee4Smrg# ifdef __CYGWIN__
5541b3e38ee4Smrg#  include <io.h>
5542b3e38ee4Smrg# endif
5543b3e38ee4Smrg#endif
5544b3e38ee4Smrg#include <malloc.h>
5545b3e38ee4Smrg#include <stdarg.h>
5546b3e38ee4Smrg#include <assert.h>
5547b3e38ee4Smrg#include <string.h>
5548b3e38ee4Smrg#include <ctype.h>
5549b3e38ee4Smrg#include <errno.h>
5550b3e38ee4Smrg#include <fcntl.h>
5551b3e38ee4Smrg#include <sys/stat.h>
555250806d53Smrg
55534a8d91dcSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
55544a8d91dcSmrg
5555a73423d7Smrg/* declarations of non-ANSI functions */
55564a8d91dcSmrg#if defined __MINGW32__
5557a73423d7Smrg# ifdef __STRICT_ANSI__
5558a73423d7Smrgint _putenv (const char *);
5559a73423d7Smrg# endif
55604a8d91dcSmrg#elif defined __CYGWIN__
5561a73423d7Smrg# ifdef __STRICT_ANSI__
5562a73423d7Smrgchar *realpath (const char *, char *);
5563a73423d7Smrgint putenv (char *);
5564a73423d7Smrgint setenv (const char *, const char *, int);
5565a73423d7Smrg# endif
55664a8d91dcSmrg/* #elif defined other_platform || defined ... */
5567a73423d7Smrg#endif
5568a73423d7Smrg
5569a73423d7Smrg/* portability defines, excluding path handling macros */
55704a8d91dcSmrg#if defined _MSC_VER
5571a73423d7Smrg# define setmode _setmode
5572a73423d7Smrg# define stat    _stat
5573a73423d7Smrg# define chmod   _chmod
5574a73423d7Smrg# define getcwd  _getcwd
5575a73423d7Smrg# define putenv  _putenv
5576a73423d7Smrg# define S_IXUSR _S_IEXEC
55774a8d91dcSmrg#elif defined __MINGW32__
5578a73423d7Smrg# define setmode _setmode
5579a73423d7Smrg# define stat    _stat
5580a73423d7Smrg# define chmod   _chmod
5581a73423d7Smrg# define getcwd  _getcwd
5582a73423d7Smrg# define putenv  _putenv
55834a8d91dcSmrg#elif defined __CYGWIN__
5584a73423d7Smrg# define HAVE_SETENV
5585a73423d7Smrg# define FOPEN_WB "wb"
55864a8d91dcSmrg/* #elif defined other platforms ... */
5587a73423d7Smrg#endif
5588a73423d7Smrg
55894a8d91dcSmrg#if defined PATH_MAX
5590b3e38ee4Smrg# define LT_PATHMAX PATH_MAX
55914a8d91dcSmrg#elif defined MAXPATHLEN
5592b3e38ee4Smrg# define LT_PATHMAX MAXPATHLEN
5593b3e38ee4Smrg#else
5594b3e38ee4Smrg# define LT_PATHMAX 1024
5595b3e38ee4Smrg#endif
559650806d53Smrg
5597b3e38ee4Smrg#ifndef S_IXOTH
5598b3e38ee4Smrg# define S_IXOTH 0
5599b3e38ee4Smrg#endif
5600b3e38ee4Smrg#ifndef S_IXGRP
5601b3e38ee4Smrg# define S_IXGRP 0
5602b3e38ee4Smrg#endif
560350806d53Smrg
5604a73423d7Smrg/* path handling portability macros */
5605b3e38ee4Smrg#ifndef DIR_SEPARATOR
5606b3e38ee4Smrg# define DIR_SEPARATOR '/'
5607b3e38ee4Smrg# define PATH_SEPARATOR ':'
5608b3e38ee4Smrg#endif
560950806d53Smrg
56104a8d91dcSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
56114a8d91dcSmrg  defined __OS2__
5612b3e38ee4Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
5613b3e38ee4Smrg# define FOPEN_WB "wb"
5614b3e38ee4Smrg# ifndef DIR_SEPARATOR_2
5615b3e38ee4Smrg#  define DIR_SEPARATOR_2 '\\'
5616b3e38ee4Smrg# endif
5617b3e38ee4Smrg# ifndef PATH_SEPARATOR_2
5618b3e38ee4Smrg#  define PATH_SEPARATOR_2 ';'
5619b3e38ee4Smrg# endif
5620b3e38ee4Smrg#endif
562150806d53Smrg
5622b3e38ee4Smrg#ifndef DIR_SEPARATOR_2
5623b3e38ee4Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
5624b3e38ee4Smrg#else /* DIR_SEPARATOR_2 */
5625b3e38ee4Smrg# define IS_DIR_SEPARATOR(ch) \
5626b3e38ee4Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
5627b3e38ee4Smrg#endif /* DIR_SEPARATOR_2 */
562850806d53Smrg
5629b3e38ee4Smrg#ifndef PATH_SEPARATOR_2
5630b3e38ee4Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5631b3e38ee4Smrg#else /* PATH_SEPARATOR_2 */
5632b3e38ee4Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5633b3e38ee4Smrg#endif /* PATH_SEPARATOR_2 */
563450806d53Smrg
5635b3e38ee4Smrg#ifndef FOPEN_WB
5636b3e38ee4Smrg# define FOPEN_WB "w"
5637b3e38ee4Smrg#endif
5638b3e38ee4Smrg#ifndef _O_BINARY
5639b3e38ee4Smrg# define _O_BINARY 0
5640b3e38ee4Smrg#endif
564150806d53Smrg
5642b3e38ee4Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
5643b3e38ee4Smrg#define XFREE(stale) do { \
56444a8d91dcSmrg  if (stale) { free (stale); stale = 0; } \
5645b3e38ee4Smrg} while (0)
564650806d53Smrg
56474a8d91dcSmrg#if defined LT_DEBUGWRAPPER
5648a73423d7Smrgstatic int lt_debug = 1;
5649b3e38ee4Smrg#else
5650a73423d7Smrgstatic int lt_debug = 0;
5651b3e38ee4Smrg#endif
565250806d53Smrg
5653a73423d7Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
565450806d53Smrg
5655b3e38ee4Smrgvoid *xmalloc (size_t num);
5656b3e38ee4Smrgchar *xstrdup (const char *string);
5657b3e38ee4Smrgconst char *base_name (const char *name);
5658b3e38ee4Smrgchar *find_executable (const char *wrapper);
5659b3e38ee4Smrgchar *chase_symlinks (const char *pathspec);
5660b3e38ee4Smrgint make_executable (const char *path);
5661b3e38ee4Smrgint check_executable (const char *path);
5662b3e38ee4Smrgchar *strendzap (char *str, const char *pat);
5663a73423d7Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
5664a73423d7Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
5665a73423d7Smrgstatic const char *nonnull (const char *s);
5666a73423d7Smrgstatic const char *nonempty (const char *s);
5667b3e38ee4Smrgvoid lt_setenv (const char *name, const char *value);
5668b3e38ee4Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
5669b3e38ee4Smrgvoid lt_update_exe_path (const char *name, const char *value);
5670b3e38ee4Smrgvoid lt_update_lib_path (const char *name, const char *value);
5671a73423d7Smrgchar **prepare_spawn (char **argv);
5672a73423d7Smrgvoid lt_dump_script (FILE *f);
5673b3e38ee4SmrgEOF
5674b3e38ee4Smrg
5675b3e38ee4Smrg	    cat <<EOF
56764a8d91dcSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
56774a8d91dcSmrg# define externally_visible volatile
56784a8d91dcSmrg#else
56794a8d91dcSmrg# define externally_visible __attribute__((externally_visible)) volatile
56804a8d91dcSmrg#endif
56814a8d91dcSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe";
5682b3e38ee4Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
5683b3e38ee4SmrgEOF
568450806d53Smrg
56854a8d91dcSmrg	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5686a73423d7Smrg              func_to_host_path "$temp_rpath"
5687b3e38ee4Smrg	      cat <<EOF
5688a73423d7Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
5689b3e38ee4SmrgEOF
5690b3e38ee4Smrg	    else
5691b3e38ee4Smrg	      cat <<"EOF"
5692b3e38ee4Smrgconst char * LIB_PATH_VALUE   = "";
5693b3e38ee4SmrgEOF
5694a18ebfb2Smrg	    fi
569550806d53Smrg
5696b3e38ee4Smrg	    if test -n "$dllsearchpath"; then
5697a73423d7Smrg              func_to_host_path "$dllsearchpath:"
5698b3e38ee4Smrg	      cat <<EOF
5699b3e38ee4Smrgconst char * EXE_PATH_VARNAME = "PATH";
5700a73423d7Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
5701a18ebfb2SmrgEOF
5702a18ebfb2Smrg	    else
5703b3e38ee4Smrg	      cat <<"EOF"
5704b3e38ee4Smrgconst char * EXE_PATH_VARNAME = "";
5705b3e38ee4Smrgconst char * EXE_PATH_VALUE   = "";
5706b3e38ee4SmrgEOF
5707a18ebfb2Smrg	    fi
5708b3e38ee4Smrg
57094a8d91dcSmrg	    if test yes = "$fast_install"; then
5710b3e38ee4Smrg	      cat <<EOF
5711b3e38ee4Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
5712b3e38ee4SmrgEOF
5713a18ebfb2Smrg	    else
5714b3e38ee4Smrg	      cat <<EOF
5715b3e38ee4Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
5716b3e38ee4SmrgEOF
5717a18ebfb2Smrg	    fi
571850806d53Smrg
571950806d53Smrg
5720b3e38ee4Smrg	    cat <<"EOF"
572150806d53Smrg
5722b3e38ee4Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
572350806d53Smrg
5724b3e38ee4Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
5725b3e38ee4Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
5726a73423d7Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
572750806d53Smrg
5728b3e38ee4Smrgint
5729b3e38ee4Smrgmain (int argc, char *argv[])
5730b3e38ee4Smrg{
5731b3e38ee4Smrg  char **newargz;
5732b3e38ee4Smrg  int  newargc;
5733b3e38ee4Smrg  char *tmp_pathspec;
5734b3e38ee4Smrg  char *actual_cwrapper_path;
5735b3e38ee4Smrg  char *actual_cwrapper_name;
5736b3e38ee4Smrg  char *target_name;
5737b3e38ee4Smrg  char *lt_argv_zero;
57384a8d91dcSmrg  int rval = 127;
573950806d53Smrg
5740b3e38ee4Smrg  int i;
574150806d53Smrg
5742b3e38ee4Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
57434a8d91dcSmrg  newargz = XMALLOC (char *, (size_t) argc + 1);
574450806d53Smrg
5745a73423d7Smrg  /* very simple arg parsing; don't want to rely on getopt
5746a73423d7Smrg   * also, copy all non cwrapper options to newargz, except
5747a73423d7Smrg   * argz[0], which is handled differently
5748a73423d7Smrg   */
5749a73423d7Smrg  newargc=0;
5750b3e38ee4Smrg  for (i = 1; i < argc; i++)
5751b3e38ee4Smrg    {
57524a8d91dcSmrg      if (STREQ (argv[i], dumpscript_opt))
5753b3e38ee4Smrg	{
5754b3e38ee4SmrgEOF
57554a8d91dcSmrg	    case $host in
5756b3e38ee4Smrg	      *mingw* | *cygwin* )
5757b3e38ee4Smrg		# make stdout use "unix" line endings
5758b3e38ee4Smrg		echo "          setmode(1,_O_BINARY);"
5759b3e38ee4Smrg		;;
5760b3e38ee4Smrg	      esac
576150806d53Smrg
5762b3e38ee4Smrg	    cat <<"EOF"
5763a73423d7Smrg	  lt_dump_script (stdout);
5764b3e38ee4Smrg	  return 0;
5765b3e38ee4Smrg	}
57664a8d91dcSmrg      if (STREQ (argv[i], debug_opt))
5767a73423d7Smrg	{
5768a73423d7Smrg          lt_debug = 1;
5769a73423d7Smrg          continue;
5770a73423d7Smrg	}
57714a8d91dcSmrg      if (STREQ (argv[i], ltwrapper_option_prefix))
5772a73423d7Smrg        {
5773a73423d7Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
5774a73423d7Smrg             namespace, but it is not one of the ones we know about and
5775a73423d7Smrg             have already dealt with, above (inluding dump-script), then
5776a73423d7Smrg             report an error. Otherwise, targets might begin to believe
5777a73423d7Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
5778a73423d7Smrg             namespace. The first time any user complains about this, we'll
5779a73423d7Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
5780a73423d7Smrg             or a configure.ac-settable value.
5781a73423d7Smrg           */
5782a73423d7Smrg          lt_fatal (__FILE__, __LINE__,
5783a73423d7Smrg		    "unrecognized %s option: '%s'",
5784a73423d7Smrg                    ltwrapper_option_prefix, argv[i]);
5785a73423d7Smrg        }
5786a73423d7Smrg      /* otherwise ... */
5787a73423d7Smrg      newargz[++newargc] = xstrdup (argv[i]);
5788b3e38ee4Smrg    }
5789a73423d7Smrg  newargz[++newargc] = NULL;
5790a73423d7Smrg
5791a73423d7SmrgEOF
5792a73423d7Smrg	    cat <<EOF
5793a73423d7Smrg  /* The GNU banner must be the first non-error debug message */
57944a8d91dcSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
5795a73423d7SmrgEOF
5796a73423d7Smrg	    cat <<"EOF"
5797a73423d7Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
5798a73423d7Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
579950806d53Smrg
5800b3e38ee4Smrg  tmp_pathspec = find_executable (argv[0]);
5801b3e38ee4Smrg  if (tmp_pathspec == NULL)
5802a73423d7Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
5803a73423d7Smrg  lt_debugprintf (__FILE__, __LINE__,
5804a73423d7Smrg                  "(main) found exe (before symlink chase) at: %s\n",
5805a73423d7Smrg		  tmp_pathspec);
5806b3e38ee4Smrg
5807b3e38ee4Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
5808a73423d7Smrg  lt_debugprintf (__FILE__, __LINE__,
5809a73423d7Smrg                  "(main) found exe (after symlink chase) at: %s\n",
5810a73423d7Smrg		  actual_cwrapper_path);
5811b3e38ee4Smrg  XFREE (tmp_pathspec);
5812b3e38ee4Smrg
5813a73423d7Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
5814b3e38ee4Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
5815b3e38ee4Smrg
5816b3e38ee4Smrg  /* wrapper name transforms */
5817b3e38ee4Smrg  strendzap (actual_cwrapper_name, ".exe");
5818b3e38ee4Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
5819b3e38ee4Smrg  XFREE (actual_cwrapper_name);
5820b3e38ee4Smrg  actual_cwrapper_name = tmp_pathspec;
5821b3e38ee4Smrg  tmp_pathspec = 0;
5822b3e38ee4Smrg
5823b3e38ee4Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
5824b3e38ee4Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
5825b3e38ee4Smrg  strendzap (target_name, ".exe");
5826b3e38ee4Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
5827b3e38ee4Smrg  XFREE (target_name);
5828b3e38ee4Smrg  target_name = tmp_pathspec;
5829b3e38ee4Smrg  tmp_pathspec = 0;
5830b3e38ee4Smrg
5831a73423d7Smrg  lt_debugprintf (__FILE__, __LINE__,
5832a73423d7Smrg		  "(main) libtool target name: %s\n",
5833a73423d7Smrg		  target_name);
5834b3e38ee4SmrgEOF
583550806d53Smrg
5836b3e38ee4Smrg	    cat <<EOF
5837b3e38ee4Smrg  newargz[0] =
5838b3e38ee4Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
5839b3e38ee4Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
5840b3e38ee4Smrg  strcpy (newargz[0], actual_cwrapper_path);
5841b3e38ee4Smrg  strcat (newargz[0], "$objdir");
5842b3e38ee4Smrg  strcat (newargz[0], "/");
5843b3e38ee4SmrgEOF
584450806d53Smrg
5845b3e38ee4Smrg	    cat <<"EOF"
5846b3e38ee4Smrg  /* stop here, and copy so we don't have to do this twice */
5847b3e38ee4Smrg  tmp_pathspec = xstrdup (newargz[0]);
584850806d53Smrg
5849b3e38ee4Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
5850b3e38ee4Smrg  strcat (newargz[0], actual_cwrapper_name);
585150806d53Smrg
5852b3e38ee4Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
5853b3e38ee4Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
5854b3e38ee4Smrg  XFREE (tmp_pathspec);
5855b3e38ee4Smrg  tmp_pathspec = NULL;
5856b3e38ee4SmrgEOF
585750806d53Smrg
5858b3e38ee4Smrg	    case $host_os in
5859b3e38ee4Smrg	      mingw*)
5860b3e38ee4Smrg	    cat <<"EOF"
5861b3e38ee4Smrg  {
5862b3e38ee4Smrg    char* p;
5863b3e38ee4Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
5864b3e38ee4Smrg      {
5865b3e38ee4Smrg	*p = '/';
5866b3e38ee4Smrg      }
5867b3e38ee4Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
5868b3e38ee4Smrg      {
5869b3e38ee4Smrg	*p = '/';
5870b3e38ee4Smrg      }
5871b3e38ee4Smrg  }
5872b3e38ee4SmrgEOF
5873b3e38ee4Smrg	    ;;
5874b3e38ee4Smrg	    esac
587550806d53Smrg
5876b3e38ee4Smrg	    cat <<"EOF"
5877b3e38ee4Smrg  XFREE (target_name);
5878b3e38ee4Smrg  XFREE (actual_cwrapper_path);
5879b3e38ee4Smrg  XFREE (actual_cwrapper_name);
588050806d53Smrg
5881b3e38ee4Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
5882b3e38ee4Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
5883a73423d7Smrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
5884a73423d7Smrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
5885a73423d7Smrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
5886a73423d7Smrg     libraries must come first. */
5887b3e38ee4Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
5888a73423d7Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
588950806d53Smrg
5890a73423d7Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
5891a73423d7Smrg		  nonnull (lt_argv_zero));
5892b3e38ee4Smrg  for (i = 0; i < newargc; i++)
5893b3e38ee4Smrg    {
5894a73423d7Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
5895a73423d7Smrg		      i, nonnull (newargz[i]));
5896b3e38ee4Smrg    }
589750806d53Smrg
5898b3e38ee4SmrgEOF
589950806d53Smrg
5900b3e38ee4Smrg	    case $host_os in
5901b3e38ee4Smrg	      mingw*)
5902b3e38ee4Smrg		cat <<"EOF"
5903b3e38ee4Smrg  /* execv doesn't actually work on mingw as expected on unix */
5904a73423d7Smrg  newargz = prepare_spawn (newargz);
59054a8d91dcSmrg  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
5906b3e38ee4Smrg  if (rval == -1)
5907b3e38ee4Smrg    {
5908b3e38ee4Smrg      /* failed to start process */
5909a73423d7Smrg      lt_debugprintf (__FILE__, __LINE__,
5910a73423d7Smrg		      "(main) failed to launch target \"%s\": %s\n",
5911a73423d7Smrg		      lt_argv_zero, nonnull (strerror (errno)));
5912b3e38ee4Smrg      return 127;
5913b3e38ee4Smrg    }
5914b3e38ee4Smrg  return rval;
5915b3e38ee4SmrgEOF
5916b3e38ee4Smrg		;;
5917b3e38ee4Smrg	      *)
5918b3e38ee4Smrg		cat <<"EOF"
5919b3e38ee4Smrg  execv (lt_argv_zero, newargz);
5920b3e38ee4Smrg  return rval; /* =127, but avoids unused variable warning */
5921b3e38ee4SmrgEOF
5922b3e38ee4Smrg		;;
5923b3e38ee4Smrg	    esac
592450806d53Smrg
5925b3e38ee4Smrg	    cat <<"EOF"
5926b3e38ee4Smrg}
592750806d53Smrg
5928b3e38ee4Smrgvoid *
5929b3e38ee4Smrgxmalloc (size_t num)
5930b3e38ee4Smrg{
5931b3e38ee4Smrg  void *p = (void *) malloc (num);
5932b3e38ee4Smrg  if (!p)
5933a73423d7Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
593450806d53Smrg
5935b3e38ee4Smrg  return p;
5936b3e38ee4Smrg}
593750806d53Smrg
5938b3e38ee4Smrgchar *
5939b3e38ee4Smrgxstrdup (const char *string)
5940b3e38ee4Smrg{
5941b3e38ee4Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
5942b3e38ee4Smrg			  string) : NULL;
5943b3e38ee4Smrg}
594450806d53Smrg
5945b3e38ee4Smrgconst char *
5946b3e38ee4Smrgbase_name (const char *name)
5947b3e38ee4Smrg{
5948b3e38ee4Smrg  const char *base;
5949a18ebfb2Smrg
59504a8d91dcSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
5951b3e38ee4Smrg  /* Skip over the disk name in MSDOS pathnames. */
5952b3e38ee4Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
5953b3e38ee4Smrg    name += 2;
5954b3e38ee4Smrg#endif
5955a18ebfb2Smrg
5956b3e38ee4Smrg  for (base = name; *name; name++)
5957b3e38ee4Smrg    if (IS_DIR_SEPARATOR (*name))
5958b3e38ee4Smrg      base = name + 1;
5959b3e38ee4Smrg  return base;
5960b3e38ee4Smrg}
5961a18ebfb2Smrg
5962b3e38ee4Smrgint
5963b3e38ee4Smrgcheck_executable (const char *path)
5964b3e38ee4Smrg{
5965b3e38ee4Smrg  struct stat st;
5966a18ebfb2Smrg
5967a73423d7Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
5968a73423d7Smrg                  nonempty (path));
5969b3e38ee4Smrg  if ((!path) || (!*path))
5970b3e38ee4Smrg    return 0;
5971a18ebfb2Smrg
5972b3e38ee4Smrg  if ((stat (path, &st) >= 0)
5973b3e38ee4Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
5974b3e38ee4Smrg    return 1;
5975b3e38ee4Smrg  else
5976b3e38ee4Smrg    return 0;
5977b3e38ee4Smrg}
597850806d53Smrg
5979b3e38ee4Smrgint
5980b3e38ee4Smrgmake_executable (const char *path)
5981b3e38ee4Smrg{
5982b3e38ee4Smrg  int rval = 0;
5983b3e38ee4Smrg  struct stat st;
598450806d53Smrg
5985a73423d7Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
5986a73423d7Smrg                  nonempty (path));
5987b3e38ee4Smrg  if ((!path) || (!*path))
5988b3e38ee4Smrg    return 0;
598950806d53Smrg
5990b3e38ee4Smrg  if (stat (path, &st) >= 0)
5991b3e38ee4Smrg    {
5992b3e38ee4Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
5993b3e38ee4Smrg    }
5994b3e38ee4Smrg  return rval;
5995b3e38ee4Smrg}
5996a18ebfb2Smrg
5997b3e38ee4Smrg/* Searches for the full path of the wrapper.  Returns
5998b3e38ee4Smrg   newly allocated full path name if found, NULL otherwise
5999b3e38ee4Smrg   Does not chase symlinks, even on platforms that support them.
6000b3e38ee4Smrg*/
6001b3e38ee4Smrgchar *
6002b3e38ee4Smrgfind_executable (const char *wrapper)
6003b3e38ee4Smrg{
6004b3e38ee4Smrg  int has_slash = 0;
6005b3e38ee4Smrg  const char *p;
6006b3e38ee4Smrg  const char *p_next;
6007b3e38ee4Smrg  /* static buffer for getcwd */
6008b3e38ee4Smrg  char tmp[LT_PATHMAX + 1];
60094a8d91dcSmrg  size_t tmp_len;
6010b3e38ee4Smrg  char *concat_name;
6011a18ebfb2Smrg
6012a73423d7Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
6013a73423d7Smrg                  nonempty (wrapper));
6014a18ebfb2Smrg
6015b3e38ee4Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
6016b3e38ee4Smrg    return NULL;
6017a18ebfb2Smrg
6018b3e38ee4Smrg  /* Absolute path? */
60194a8d91dcSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
6020b3e38ee4Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
6021b3e38ee4Smrg    {
6022b3e38ee4Smrg      concat_name = xstrdup (wrapper);
6023b3e38ee4Smrg      if (check_executable (concat_name))
6024b3e38ee4Smrg	return concat_name;
6025b3e38ee4Smrg      XFREE (concat_name);
6026b3e38ee4Smrg    }
6027b3e38ee4Smrg  else
6028b3e38ee4Smrg    {
6029b3e38ee4Smrg#endif
6030b3e38ee4Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
6031b3e38ee4Smrg	{
6032b3e38ee4Smrg	  concat_name = xstrdup (wrapper);
6033b3e38ee4Smrg	  if (check_executable (concat_name))
6034b3e38ee4Smrg	    return concat_name;
6035b3e38ee4Smrg	  XFREE (concat_name);
6036b3e38ee4Smrg	}
60374a8d91dcSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
6038b3e38ee4Smrg    }
6039b3e38ee4Smrg#endif
604050806d53Smrg
6041b3e38ee4Smrg  for (p = wrapper; *p; p++)
6042b3e38ee4Smrg    if (*p == '/')
6043b3e38ee4Smrg      {
6044b3e38ee4Smrg	has_slash = 1;
6045b3e38ee4Smrg	break;
6046b3e38ee4Smrg      }
6047b3e38ee4Smrg  if (!has_slash)
6048b3e38ee4Smrg    {
6049b3e38ee4Smrg      /* no slashes; search PATH */
6050b3e38ee4Smrg      const char *path = getenv ("PATH");
6051b3e38ee4Smrg      if (path != NULL)
6052b3e38ee4Smrg	{
6053b3e38ee4Smrg	  for (p = path; *p; p = p_next)
6054b3e38ee4Smrg	    {
6055b3e38ee4Smrg	      const char *q;
6056b3e38ee4Smrg	      size_t p_len;
6057b3e38ee4Smrg	      for (q = p; *q; q++)
6058b3e38ee4Smrg		if (IS_PATH_SEPARATOR (*q))
6059b3e38ee4Smrg		  break;
60604a8d91dcSmrg	      p_len = (size_t) (q - p);
6061b3e38ee4Smrg	      p_next = (*q == '\0' ? q : q + 1);
6062b3e38ee4Smrg	      if (p_len == 0)
6063b3e38ee4Smrg		{
6064b3e38ee4Smrg		  /* empty path: current directory */
6065b3e38ee4Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
6066a73423d7Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6067a73423d7Smrg                              nonnull (strerror (errno)));
6068b3e38ee4Smrg		  tmp_len = strlen (tmp);
6069b3e38ee4Smrg		  concat_name =
6070b3e38ee4Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6071b3e38ee4Smrg		  memcpy (concat_name, tmp, tmp_len);
6072b3e38ee4Smrg		  concat_name[tmp_len] = '/';
6073b3e38ee4Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
6074b3e38ee4Smrg		}
6075b3e38ee4Smrg	      else
6076b3e38ee4Smrg		{
6077b3e38ee4Smrg		  concat_name =
6078b3e38ee4Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
6079b3e38ee4Smrg		  memcpy (concat_name, p, p_len);
6080b3e38ee4Smrg		  concat_name[p_len] = '/';
6081b3e38ee4Smrg		  strcpy (concat_name + p_len + 1, wrapper);
6082b3e38ee4Smrg		}
6083b3e38ee4Smrg	      if (check_executable (concat_name))
6084b3e38ee4Smrg		return concat_name;
6085b3e38ee4Smrg	      XFREE (concat_name);
6086b3e38ee4Smrg	    }
6087b3e38ee4Smrg	}
6088b3e38ee4Smrg      /* not found in PATH; assume curdir */
6089b3e38ee4Smrg    }
6090b3e38ee4Smrg  /* Relative path | not found in path: prepend cwd */
6091b3e38ee4Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
6092a73423d7Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6093a73423d7Smrg              nonnull (strerror (errno)));
6094b3e38ee4Smrg  tmp_len = strlen (tmp);
6095b3e38ee4Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6096b3e38ee4Smrg  memcpy (concat_name, tmp, tmp_len);
6097b3e38ee4Smrg  concat_name[tmp_len] = '/';
6098b3e38ee4Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
609950806d53Smrg
6100b3e38ee4Smrg  if (check_executable (concat_name))
6101b3e38ee4Smrg    return concat_name;
6102b3e38ee4Smrg  XFREE (concat_name);
6103b3e38ee4Smrg  return NULL;
6104b3e38ee4Smrg}
610550806d53Smrg
6106b3e38ee4Smrgchar *
6107b3e38ee4Smrgchase_symlinks (const char *pathspec)
6108b3e38ee4Smrg{
6109b3e38ee4Smrg#ifndef S_ISLNK
6110b3e38ee4Smrg  return xstrdup (pathspec);
6111b3e38ee4Smrg#else
6112b3e38ee4Smrg  char buf[LT_PATHMAX];
6113b3e38ee4Smrg  struct stat s;
6114b3e38ee4Smrg  char *tmp_pathspec = xstrdup (pathspec);
6115b3e38ee4Smrg  char *p;
6116b3e38ee4Smrg  int has_symlinks = 0;
6117b3e38ee4Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
6118b3e38ee4Smrg    {
6119a73423d7Smrg      lt_debugprintf (__FILE__, __LINE__,
6120a73423d7Smrg		      "checking path component for symlinks: %s\n",
6121a73423d7Smrg		      tmp_pathspec);
6122b3e38ee4Smrg      if (lstat (tmp_pathspec, &s) == 0)
6123b3e38ee4Smrg	{
6124b3e38ee4Smrg	  if (S_ISLNK (s.st_mode) != 0)
6125b3e38ee4Smrg	    {
6126b3e38ee4Smrg	      has_symlinks = 1;
6127b3e38ee4Smrg	      break;
6128b3e38ee4Smrg	    }
612950806d53Smrg
6130b3e38ee4Smrg	  /* search backwards for last DIR_SEPARATOR */
6131b3e38ee4Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
6132b3e38ee4Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6133b3e38ee4Smrg	    p--;
6134b3e38ee4Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6135b3e38ee4Smrg	    {
6136b3e38ee4Smrg	      /* no more DIR_SEPARATORS left */
6137b3e38ee4Smrg	      break;
6138b3e38ee4Smrg	    }
6139b3e38ee4Smrg	  *p = '\0';
6140b3e38ee4Smrg	}
6141b3e38ee4Smrg      else
6142b3e38ee4Smrg	{
6143a73423d7Smrg	  lt_fatal (__FILE__, __LINE__,
6144a73423d7Smrg		    "error accessing file \"%s\": %s",
6145a73423d7Smrg		    tmp_pathspec, nonnull (strerror (errno)));
6146b3e38ee4Smrg	}
6147b3e38ee4Smrg    }
6148b3e38ee4Smrg  XFREE (tmp_pathspec);
614950806d53Smrg
6150b3e38ee4Smrg  if (!has_symlinks)
6151b3e38ee4Smrg    {
6152b3e38ee4Smrg      return xstrdup (pathspec);
6153b3e38ee4Smrg    }
615450806d53Smrg
6155b3e38ee4Smrg  tmp_pathspec = realpath (pathspec, buf);
6156b3e38ee4Smrg  if (tmp_pathspec == 0)
6157b3e38ee4Smrg    {
6158a73423d7Smrg      lt_fatal (__FILE__, __LINE__,
6159a73423d7Smrg		"could not follow symlinks for %s", pathspec);
6160b3e38ee4Smrg    }
6161b3e38ee4Smrg  return xstrdup (tmp_pathspec);
6162b3e38ee4Smrg#endif
6163b3e38ee4Smrg}
616450806d53Smrg
6165b3e38ee4Smrgchar *
6166b3e38ee4Smrgstrendzap (char *str, const char *pat)
6167b3e38ee4Smrg{
6168b3e38ee4Smrg  size_t len, patlen;
616950806d53Smrg
6170b3e38ee4Smrg  assert (str != NULL);
6171b3e38ee4Smrg  assert (pat != NULL);
617250806d53Smrg
6173b3e38ee4Smrg  len = strlen (str);
6174b3e38ee4Smrg  patlen = strlen (pat);
617550806d53Smrg
6176b3e38ee4Smrg  if (patlen <= len)
6177b3e38ee4Smrg    {
6178b3e38ee4Smrg      str += len - patlen;
61794a8d91dcSmrg      if (STREQ (str, pat))
6180b3e38ee4Smrg	*str = '\0';
6181b3e38ee4Smrg    }
6182b3e38ee4Smrg  return str;
6183b3e38ee4Smrg}
618450806d53Smrg
6185a73423d7Smrgvoid
6186a73423d7Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
6187a73423d7Smrg{
6188a73423d7Smrg  va_list args;
6189a73423d7Smrg  if (lt_debug)
6190a73423d7Smrg    {
6191a73423d7Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
6192a73423d7Smrg      va_start (args, fmt);
6193a73423d7Smrg      (void) vfprintf (stderr, fmt, args);
6194a73423d7Smrg      va_end (args);
6195a73423d7Smrg    }
6196a73423d7Smrg}
6197a73423d7Smrg
6198b3e38ee4Smrgstatic void
6199a73423d7Smrglt_error_core (int exit_status, const char *file,
6200a73423d7Smrg	       int line, const char *mode,
6201b3e38ee4Smrg	       const char *message, va_list ap)
6202b3e38ee4Smrg{
6203a73423d7Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
6204b3e38ee4Smrg  vfprintf (stderr, message, ap);
6205b3e38ee4Smrg  fprintf (stderr, ".\n");
620650806d53Smrg
6207b3e38ee4Smrg  if (exit_status >= 0)
6208b3e38ee4Smrg    exit (exit_status);
6209b3e38ee4Smrg}
621050806d53Smrg
6211b3e38ee4Smrgvoid
6212a73423d7Smrglt_fatal (const char *file, int line, const char *message, ...)
6213b3e38ee4Smrg{
6214b3e38ee4Smrg  va_list ap;
6215b3e38ee4Smrg  va_start (ap, message);
6216a73423d7Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
6217b3e38ee4Smrg  va_end (ap);
6218b3e38ee4Smrg}
6219af1a9c97Smrg
6220a73423d7Smrgstatic const char *
6221a73423d7Smrgnonnull (const char *s)
6222a73423d7Smrg{
6223a73423d7Smrg  return s ? s : "(null)";
6224a73423d7Smrg}
6225a73423d7Smrg
6226a73423d7Smrgstatic const char *
6227a73423d7Smrgnonempty (const char *s)
6228a73423d7Smrg{
6229a73423d7Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
6230a73423d7Smrg}
6231a73423d7Smrg
6232b3e38ee4Smrgvoid
6233b3e38ee4Smrglt_setenv (const char *name, const char *value)
6234b3e38ee4Smrg{
6235a73423d7Smrg  lt_debugprintf (__FILE__, __LINE__,
6236a73423d7Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
6237a73423d7Smrg                  nonnull (name), nonnull (value));
6238b3e38ee4Smrg  {
6239b3e38ee4Smrg#ifdef HAVE_SETENV
6240b3e38ee4Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
6241b3e38ee4Smrg    char *str = xstrdup (value);
6242b3e38ee4Smrg    setenv (name, str, 1);
6243b3e38ee4Smrg#else
62444a8d91dcSmrg    size_t len = strlen (name) + 1 + strlen (value) + 1;
6245b3e38ee4Smrg    char *str = XMALLOC (char, len);
6246b3e38ee4Smrg    sprintf (str, "%s=%s", name, value);
6247b3e38ee4Smrg    if (putenv (str) != EXIT_SUCCESS)
6248b3e38ee4Smrg      {
6249b3e38ee4Smrg        XFREE (str);
6250b3e38ee4Smrg      }
6251b3e38ee4Smrg#endif
6252b3e38ee4Smrg  }
6253b3e38ee4Smrg}
625450806d53Smrg
6255b3e38ee4Smrgchar *
6256b3e38ee4Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
6257b3e38ee4Smrg{
6258b3e38ee4Smrg  char *new_value;
6259b3e38ee4Smrg  if (orig_value && *orig_value)
6260b3e38ee4Smrg    {
62614a8d91dcSmrg      size_t orig_value_len = strlen (orig_value);
62624a8d91dcSmrg      size_t add_len = strlen (add);
6263b3e38ee4Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
6264b3e38ee4Smrg      if (to_end)
6265b3e38ee4Smrg        {
6266b3e38ee4Smrg          strcpy (new_value, orig_value);
6267b3e38ee4Smrg          strcpy (new_value + orig_value_len, add);
6268b3e38ee4Smrg        }
6269b3e38ee4Smrg      else
6270b3e38ee4Smrg        {
6271b3e38ee4Smrg          strcpy (new_value, add);
6272b3e38ee4Smrg          strcpy (new_value + add_len, orig_value);
6273b3e38ee4Smrg        }
6274b3e38ee4Smrg    }
6275b3e38ee4Smrg  else
6276b3e38ee4Smrg    {
6277b3e38ee4Smrg      new_value = xstrdup (add);
6278b3e38ee4Smrg    }
6279b3e38ee4Smrg  return new_value;
6280b3e38ee4Smrg}
628150806d53Smrg
6282b3e38ee4Smrgvoid
6283b3e38ee4Smrglt_update_exe_path (const char *name, const char *value)
6284b3e38ee4Smrg{
6285a73423d7Smrg  lt_debugprintf (__FILE__, __LINE__,
6286a73423d7Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
6287a73423d7Smrg                  nonnull (name), nonnull (value));
628850806d53Smrg
6289b3e38ee4Smrg  if (name && *name && value && *value)
6290b3e38ee4Smrg    {
6291b3e38ee4Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
6292b3e38ee4Smrg      /* some systems can't cope with a ':'-terminated path #' */
62934a8d91dcSmrg      size_t len = strlen (new_value);
62944a8d91dcSmrg      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
6295b3e38ee4Smrg        {
62964a8d91dcSmrg          new_value[--len] = '\0';
6297b3e38ee4Smrg        }
6298b3e38ee4Smrg      lt_setenv (name, new_value);
6299b3e38ee4Smrg      XFREE (new_value);
6300b3e38ee4Smrg    }
6301b3e38ee4Smrg}
630250806d53Smrg
6303b3e38ee4Smrgvoid
6304b3e38ee4Smrglt_update_lib_path (const char *name, const char *value)
6305b3e38ee4Smrg{
6306a73423d7Smrg  lt_debugprintf (__FILE__, __LINE__,
6307a73423d7Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
6308a73423d7Smrg                  nonnull (name), nonnull (value));
630950806d53Smrg
6310b3e38ee4Smrg  if (name && *name && value && *value)
6311b3e38ee4Smrg    {
6312b3e38ee4Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
6313b3e38ee4Smrg      lt_setenv (name, new_value);
6314b3e38ee4Smrg      XFREE (new_value);
6315b3e38ee4Smrg    }
6316b3e38ee4Smrg}
631750806d53Smrg
6318a73423d7SmrgEOF
6319a73423d7Smrg	    case $host_os in
6320a73423d7Smrg	      mingw*)
6321a73423d7Smrg		cat <<"EOF"
6322a73423d7Smrg
6323a73423d7Smrg/* Prepares an argument vector before calling spawn().
6324a73423d7Smrg   Note that spawn() does not by itself call the command interpreter
6325a73423d7Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
6326a73423d7Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
6327a73423d7Smrg         GetVersionEx(&v);
6328a73423d7Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
6329a73423d7Smrg      }) ? "cmd.exe" : "command.com").
6330a73423d7Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
6331a73423d7Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
6332a73423d7Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
6333a73423d7Smrg   special way:
6334a73423d7Smrg   - Space and tab are interpreted as delimiters. They are not treated as
6335a73423d7Smrg     delimiters if they are surrounded by double quotes: "...".
6336a73423d7Smrg   - Unescaped double quotes are removed from the input. Their only effect is
6337a73423d7Smrg     that within double quotes, space and tab are treated like normal
6338a73423d7Smrg     characters.
6339a73423d7Smrg   - Backslashes not followed by double quotes are not special.
6340a73423d7Smrg   - But 2*n+1 backslashes followed by a double quote become
6341a73423d7Smrg     n backslashes followed by a double quote (n >= 0):
6342a73423d7Smrg       \" -> "
6343a73423d7Smrg       \\\" -> \"
6344a73423d7Smrg       \\\\\" -> \\"
6345a73423d7Smrg */
6346a73423d7Smrg#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"
6347a73423d7Smrg#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"
6348a73423d7Smrgchar **
6349a73423d7Smrgprepare_spawn (char **argv)
6350a73423d7Smrg{
6351a73423d7Smrg  size_t argc;
6352a73423d7Smrg  char **new_argv;
6353a73423d7Smrg  size_t i;
6354a73423d7Smrg
6355a73423d7Smrg  /* Count number of arguments.  */
6356a73423d7Smrg  for (argc = 0; argv[argc] != NULL; argc++)
6357a73423d7Smrg    ;
6358a73423d7Smrg
6359a73423d7Smrg  /* Allocate new argument vector.  */
6360a73423d7Smrg  new_argv = XMALLOC (char *, argc + 1);
6361a73423d7Smrg
6362a73423d7Smrg  /* Put quoted arguments into the new argument vector.  */
6363a73423d7Smrg  for (i = 0; i < argc; i++)
6364a73423d7Smrg    {
6365a73423d7Smrg      const char *string = argv[i];
6366a73423d7Smrg
6367a73423d7Smrg      if (string[0] == '\0')
6368a73423d7Smrg	new_argv[i] = xstrdup ("\"\"");
6369a73423d7Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
6370a73423d7Smrg	{
6371a73423d7Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
6372a73423d7Smrg	  size_t length;
6373a73423d7Smrg	  unsigned int backslashes;
6374a73423d7Smrg	  const char *s;
6375a73423d7Smrg	  char *quoted_string;
6376a73423d7Smrg	  char *p;
6377a73423d7Smrg
6378a73423d7Smrg	  length = 0;
6379a73423d7Smrg	  backslashes = 0;
6380a73423d7Smrg	  if (quote_around)
6381a73423d7Smrg	    length++;
6382a73423d7Smrg	  for (s = string; *s != '\0'; s++)
6383a73423d7Smrg	    {
6384a73423d7Smrg	      char c = *s;
6385a73423d7Smrg	      if (c == '"')
6386a73423d7Smrg		length += backslashes + 1;
6387a73423d7Smrg	      length++;
6388a73423d7Smrg	      if (c == '\\')
6389a73423d7Smrg		backslashes++;
6390a73423d7Smrg	      else
6391a73423d7Smrg		backslashes = 0;
6392a73423d7Smrg	    }
6393a73423d7Smrg	  if (quote_around)
6394a73423d7Smrg	    length += backslashes + 1;
6395a73423d7Smrg
6396a73423d7Smrg	  quoted_string = XMALLOC (char, length + 1);
6397a73423d7Smrg
6398a73423d7Smrg	  p = quoted_string;
6399a73423d7Smrg	  backslashes = 0;
6400a73423d7Smrg	  if (quote_around)
6401a73423d7Smrg	    *p++ = '"';
6402a73423d7Smrg	  for (s = string; *s != '\0'; s++)
6403a73423d7Smrg	    {
6404a73423d7Smrg	      char c = *s;
6405a73423d7Smrg	      if (c == '"')
6406a73423d7Smrg		{
6407a73423d7Smrg		  unsigned int j;
6408a73423d7Smrg		  for (j = backslashes + 1; j > 0; j--)
6409a73423d7Smrg		    *p++ = '\\';
6410a73423d7Smrg		}
6411a73423d7Smrg	      *p++ = c;
6412a73423d7Smrg	      if (c == '\\')
6413a73423d7Smrg		backslashes++;
6414a73423d7Smrg	      else
6415a73423d7Smrg		backslashes = 0;
6416a73423d7Smrg	    }
6417a73423d7Smrg	  if (quote_around)
6418a73423d7Smrg	    {
6419a73423d7Smrg	      unsigned int j;
6420a73423d7Smrg	      for (j = backslashes; j > 0; j--)
6421a73423d7Smrg		*p++ = '\\';
6422a73423d7Smrg	      *p++ = '"';
6423a73423d7Smrg	    }
6424a73423d7Smrg	  *p = '\0';
6425a73423d7Smrg
6426a73423d7Smrg	  new_argv[i] = quoted_string;
6427a73423d7Smrg	}
6428a73423d7Smrg      else
6429a73423d7Smrg	new_argv[i] = (char *) string;
6430a73423d7Smrg    }
6431a73423d7Smrg  new_argv[argc] = NULL;
6432a73423d7Smrg
6433a73423d7Smrg  return new_argv;
6434a73423d7Smrg}
6435a73423d7SmrgEOF
6436a73423d7Smrg		;;
6437a73423d7Smrg	    esac
643850806d53Smrg
6439a73423d7Smrg            cat <<"EOF"
6440a73423d7Smrgvoid lt_dump_script (FILE* f)
6441a73423d7Smrg{
6442a73423d7SmrgEOF
6443a73423d7Smrg	    func_emit_wrapper yes |
6444a73423d7Smrg	      $SED -n -e '
6445a73423d7Smrgs/^\(.\{79\}\)\(..*\)/\1\
6446a73423d7Smrg\2/
6447a73423d7Smrgh
6448a73423d7Smrgs/\([\\"]\)/\\\1/g
6449a73423d7Smrgs/$/\\n/
6450a73423d7Smrgs/\([^\n]*\).*/  fputs ("\1", f);/p
6451a73423d7Smrgg
6452a73423d7SmrgD'
6453a73423d7Smrg            cat <<"EOF"
6454a73423d7Smrg}
6455b3e38ee4SmrgEOF
6456b3e38ee4Smrg}
6457b3e38ee4Smrg# end: func_emit_cwrapperexe_src
645850806d53Smrg
6459a73423d7Smrg# func_win32_import_lib_p ARG
6460a73423d7Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
6461a73423d7Smrgfunc_win32_import_lib_p ()
6462a73423d7Smrg{
64634a8d91dcSmrg    $debug_cmd
64644a8d91dcSmrg
6465a73423d7Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
6466a73423d7Smrg    *import*) : ;;
6467a73423d7Smrg    *) false ;;
6468a73423d7Smrg    esac
6469a73423d7Smrg}
6470a73423d7Smrg
64714a8d91dcSmrg# func_suncc_cstd_abi
64724a8d91dcSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
64734a8d91dcSmrg# Several compiler flags select an ABI that is incompatible with the
64744a8d91dcSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS.
64754a8d91dcSmrgfunc_suncc_cstd_abi ()
64764a8d91dcSmrg{
64774a8d91dcSmrg    $debug_cmd
64784a8d91dcSmrg
64794a8d91dcSmrg    case " $compile_command " in
64804a8d91dcSmrg    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
64814a8d91dcSmrg      suncc_use_cstd_abi=no
64824a8d91dcSmrg      ;;
64834a8d91dcSmrg    *)
64844a8d91dcSmrg      suncc_use_cstd_abi=yes
64854a8d91dcSmrg      ;;
64864a8d91dcSmrg    esac
64874a8d91dcSmrg}
64884a8d91dcSmrg
6489b3e38ee4Smrg# func_mode_link arg...
6490b3e38ee4Smrgfunc_mode_link ()
6491b3e38ee4Smrg{
64924a8d91dcSmrg    $debug_cmd
64934a8d91dcSmrg
6494b3e38ee4Smrg    case $host in
6495b3e38ee4Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6496b3e38ee4Smrg      # It is impossible to link a dll without this setting, and
6497b3e38ee4Smrg      # we shouldn't force the makefile maintainer to figure out
64984a8d91dcSmrg      # what system we are compiling for in order to pass an extra
6499b3e38ee4Smrg      # flag for every libtool invocation.
6500b3e38ee4Smrg      # allow_undefined=no
650150806d53Smrg
6502b3e38ee4Smrg      # FIXME: Unfortunately, there are problems with the above when trying
65034a8d91dcSmrg      # to make a dll that has undefined symbols, in which case not
6504b3e38ee4Smrg      # even a static library is built.  For now, we need to specify
6505b3e38ee4Smrg      # -no-undefined on the libtool link line when we can be certain
6506b3e38ee4Smrg      # that all symbols are satisfied, otherwise we get a static library.
6507b3e38ee4Smrg      allow_undefined=yes
6508b3e38ee4Smrg      ;;
6509b3e38ee4Smrg    *)
6510b3e38ee4Smrg      allow_undefined=yes
6511b3e38ee4Smrg      ;;
6512b3e38ee4Smrg    esac
6513b3e38ee4Smrg    libtool_args=$nonopt
6514b3e38ee4Smrg    base_compile="$nonopt $@"
6515b3e38ee4Smrg    compile_command=$nonopt
6516b3e38ee4Smrg    finalize_command=$nonopt
651750806d53Smrg
6518b3e38ee4Smrg    compile_rpath=
6519b3e38ee4Smrg    finalize_rpath=
6520b3e38ee4Smrg    compile_shlibpath=
6521b3e38ee4Smrg    finalize_shlibpath=
6522b3e38ee4Smrg    convenience=
6523b3e38ee4Smrg    old_convenience=
6524b3e38ee4Smrg    deplibs=
6525b3e38ee4Smrg    old_deplibs=
6526b3e38ee4Smrg    compiler_flags=
6527b3e38ee4Smrg    linker_flags=
6528b3e38ee4Smrg    dllsearchpath=
6529b3e38ee4Smrg    lib_search_path=`pwd`
6530b3e38ee4Smrg    inst_prefix_dir=
6531b3e38ee4Smrg    new_inherited_linker_flags=
653250806d53Smrg
6533b3e38ee4Smrg    avoid_version=no
6534a73423d7Smrg    bindir=
6535b3e38ee4Smrg    dlfiles=
6536b3e38ee4Smrg    dlprefiles=
6537b3e38ee4Smrg    dlself=no
6538b3e38ee4Smrg    export_dynamic=no
6539b3e38ee4Smrg    export_symbols=
6540b3e38ee4Smrg    export_symbols_regex=
6541b3e38ee4Smrg    generated=
6542b3e38ee4Smrg    libobjs=
6543b3e38ee4Smrg    ltlibs=
6544b3e38ee4Smrg    module=no
6545b3e38ee4Smrg    no_install=no
6546b3e38ee4Smrg    objs=
65474a8d91dcSmrg    os2dllname=
6548b3e38ee4Smrg    non_pic_objects=
6549b3e38ee4Smrg    precious_files_regex=
6550b3e38ee4Smrg    prefer_static_libs=no
65514a8d91dcSmrg    preload=false
6552b3e38ee4Smrg    prev=
6553b3e38ee4Smrg    prevarg=
6554b3e38ee4Smrg    release=
6555b3e38ee4Smrg    rpath=
6556b3e38ee4Smrg    xrpath=
6557b3e38ee4Smrg    perm_rpath=
6558b3e38ee4Smrg    temp_rpath=
6559b3e38ee4Smrg    thread_safe=no
6560b3e38ee4Smrg    vinfo=
6561b3e38ee4Smrg    vinfo_number=no
6562b3e38ee4Smrg    weak_libs=
65634a8d91dcSmrg    single_module=$wl-single_module
6564b3e38ee4Smrg    func_infer_tag $base_compile
6565b3e38ee4Smrg
6566b3e38ee4Smrg    # We need to know -static, to get the right output filenames.
6567b3e38ee4Smrg    for arg
6568b3e38ee4Smrg    do
6569b3e38ee4Smrg      case $arg in
6570b3e38ee4Smrg      -shared)
65714a8d91dcSmrg	test yes != "$build_libtool_libs" \
65724a8d91dcSmrg	  && func_fatal_configuration "cannot build a shared library"
6573b3e38ee4Smrg	build_old_libs=no
6574b3e38ee4Smrg	break
6575b3e38ee4Smrg	;;
6576b3e38ee4Smrg      -all-static | -static | -static-libtool-libs)
6577b3e38ee4Smrg	case $arg in
6578b3e38ee4Smrg	-all-static)
65794a8d91dcSmrg	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
6580b3e38ee4Smrg	    func_warning "complete static linking is impossible in this configuration"
6581b3e38ee4Smrg	  fi
6582b3e38ee4Smrg	  if test -n "$link_static_flag"; then
6583b3e38ee4Smrg	    dlopen_self=$dlopen_self_static
6584b3e38ee4Smrg	  fi
6585b3e38ee4Smrg	  prefer_static_libs=yes
6586b3e38ee4Smrg	  ;;
6587b3e38ee4Smrg	-static)
6588b3e38ee4Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
6589b3e38ee4Smrg	    dlopen_self=$dlopen_self_static
6590b3e38ee4Smrg	  fi
6591b3e38ee4Smrg	  prefer_static_libs=built
6592b3e38ee4Smrg	  ;;
6593b3e38ee4Smrg	-static-libtool-libs)
6594b3e38ee4Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
6595b3e38ee4Smrg	    dlopen_self=$dlopen_self_static
6596a18ebfb2Smrg	  fi
6597b3e38ee4Smrg	  prefer_static_libs=yes
6598b3e38ee4Smrg	  ;;
6599b3e38ee4Smrg	esac
6600b3e38ee4Smrg	build_libtool_libs=no
6601b3e38ee4Smrg	build_old_libs=yes
6602b3e38ee4Smrg	break
6603b3e38ee4Smrg	;;
6604b3e38ee4Smrg      esac
6605b3e38ee4Smrg    done
660650806d53Smrg
6607b3e38ee4Smrg    # See if our shared archives depend on static archives.
6608b3e38ee4Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
660950806d53Smrg
6610b3e38ee4Smrg    # Go through the arguments, transforming them on the way.
6611b3e38ee4Smrg    while test "$#" -gt 0; do
66124a8d91dcSmrg      arg=$1
6613b3e38ee4Smrg      shift
6614b3e38ee4Smrg      func_quote_for_eval "$arg"
6615b3e38ee4Smrg      qarg=$func_quote_for_eval_unquoted_result
6616b3e38ee4Smrg      func_append libtool_args " $func_quote_for_eval_result"
661750806d53Smrg
6618b3e38ee4Smrg      # If the previous option needs an argument, assign it.
6619b3e38ee4Smrg      if test -n "$prev"; then
6620b3e38ee4Smrg	case $prev in
6621b3e38ee4Smrg	output)
6622b3e38ee4Smrg	  func_append compile_command " @OUTPUT@"
6623b3e38ee4Smrg	  func_append finalize_command " @OUTPUT@"
6624b3e38ee4Smrg	  ;;
6625b3e38ee4Smrg	esac
662650806d53Smrg
6627b3e38ee4Smrg	case $prev in
6628a73423d7Smrg	bindir)
66294a8d91dcSmrg	  bindir=$arg
6630a73423d7Smrg	  prev=
6631a73423d7Smrg	  continue
6632a73423d7Smrg	  ;;
6633b3e38ee4Smrg	dlfiles|dlprefiles)
66344a8d91dcSmrg	  $preload || {
6635b3e38ee4Smrg	    # Add the symbol object into the linking commands.
6636b3e38ee4Smrg	    func_append compile_command " @SYMFILE@"
6637b3e38ee4Smrg	    func_append finalize_command " @SYMFILE@"
66384a8d91dcSmrg	    preload=:
66394a8d91dcSmrg	  }
6640b3e38ee4Smrg	  case $arg in
6641b3e38ee4Smrg	  *.la | *.lo) ;;  # We handle these cases below.
6642b3e38ee4Smrg	  force)
66434a8d91dcSmrg	    if test no = "$dlself"; then
6644b3e38ee4Smrg	      dlself=needless
6645b3e38ee4Smrg	      export_dynamic=yes
6646b3e38ee4Smrg	    fi
6647b3e38ee4Smrg	    prev=
6648b3e38ee4Smrg	    continue
6649b3e38ee4Smrg	    ;;
6650b3e38ee4Smrg	  self)
66514a8d91dcSmrg	    if test dlprefiles = "$prev"; then
6652b3e38ee4Smrg	      dlself=yes
66534a8d91dcSmrg	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
6654b3e38ee4Smrg	      dlself=yes
6655a18ebfb2Smrg	    else
6656b3e38ee4Smrg	      dlself=needless
6657b3e38ee4Smrg	      export_dynamic=yes
6658a18ebfb2Smrg	    fi
6659b3e38ee4Smrg	    prev=
6660b3e38ee4Smrg	    continue
6661b3e38ee4Smrg	    ;;
6662b3e38ee4Smrg	  *)
66634a8d91dcSmrg	    if test dlfiles = "$prev"; then
6664a73423d7Smrg	      func_append dlfiles " $arg"
6665a18ebfb2Smrg	    else
6666a73423d7Smrg	      func_append dlprefiles " $arg"
6667a18ebfb2Smrg	    fi
6668b3e38ee4Smrg	    prev=
6669b3e38ee4Smrg	    continue
6670b3e38ee4Smrg	    ;;
6671b3e38ee4Smrg	  esac
6672b3e38ee4Smrg	  ;;
6673b3e38ee4Smrg	expsyms)
66744a8d91dcSmrg	  export_symbols=$arg
6675b3e38ee4Smrg	  test -f "$arg" \
66764a8d91dcSmrg	    || func_fatal_error "symbol file '$arg' does not exist"
6677b3e38ee4Smrg	  prev=
6678b3e38ee4Smrg	  continue
6679b3e38ee4Smrg	  ;;
6680b3e38ee4Smrg	expsyms_regex)
66814a8d91dcSmrg	  export_symbols_regex=$arg
6682b3e38ee4Smrg	  prev=
6683b3e38ee4Smrg	  continue
6684b3e38ee4Smrg	  ;;
6685b3e38ee4Smrg	framework)
6686a18ebfb2Smrg	  case $host in
6687b3e38ee4Smrg	    *-*-darwin*)
6688b3e38ee4Smrg	      case "$deplibs " in
6689b3e38ee4Smrg		*" $qarg.ltframework "*) ;;
6690a73423d7Smrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
6691b3e38ee4Smrg		   ;;
6692b3e38ee4Smrg	      esac
6693b3e38ee4Smrg	      ;;
6694a18ebfb2Smrg	  esac
6695b3e38ee4Smrg	  prev=
6696b3e38ee4Smrg	  continue
6697a18ebfb2Smrg	  ;;
6698b3e38ee4Smrg	inst_prefix)
66994a8d91dcSmrg	  inst_prefix_dir=$arg
67004a8d91dcSmrg	  prev=
67014a8d91dcSmrg	  continue
67024a8d91dcSmrg	  ;;
67034a8d91dcSmrg	mllvm)
67044a8d91dcSmrg	  # Clang does not use LLVM to link, so we can simply discard any
67054a8d91dcSmrg	  # '-mllvm $arg' options when doing the link step.
6706b3e38ee4Smrg	  prev=
6707b3e38ee4Smrg	  continue
6708a18ebfb2Smrg	  ;;
6709b3e38ee4Smrg	objectlist)
6710b3e38ee4Smrg	  if test -f "$arg"; then
6711b3e38ee4Smrg	    save_arg=$arg
6712b3e38ee4Smrg	    moreargs=
6713b3e38ee4Smrg	    for fil in `cat "$save_arg"`
6714b3e38ee4Smrg	    do
6715a73423d7Smrg#	      func_append moreargs " $fil"
6716b3e38ee4Smrg	      arg=$fil
6717b3e38ee4Smrg	      # A libtool-controlled object.
6718af1a9c97Smrg
6719b3e38ee4Smrg	      # Check to see that this really is a libtool object.
6720b3e38ee4Smrg	      if func_lalib_unsafe_p "$arg"; then
6721b3e38ee4Smrg		pic_object=
6722b3e38ee4Smrg		non_pic_object=
6723af1a9c97Smrg
6724b3e38ee4Smrg		# Read the .lo file
6725b3e38ee4Smrg		func_source "$arg"
6726af1a9c97Smrg
6727b3e38ee4Smrg		if test -z "$pic_object" ||
6728b3e38ee4Smrg		   test -z "$non_pic_object" ||
67294a8d91dcSmrg		   test none = "$pic_object" &&
67304a8d91dcSmrg		   test none = "$non_pic_object"; then
67314a8d91dcSmrg		  func_fatal_error "cannot find name of object for '$arg'"
6732b3e38ee4Smrg		fi
6733af1a9c97Smrg
6734b3e38ee4Smrg		# Extract subdirectory from the argument.
6735b3e38ee4Smrg		func_dirname "$arg" "/" ""
67364a8d91dcSmrg		xdir=$func_dirname_result
6737af1a9c97Smrg
67384a8d91dcSmrg		if test none != "$pic_object"; then
6739b3e38ee4Smrg		  # Prepend the subdirectory the object is found in.
67404a8d91dcSmrg		  pic_object=$xdir$pic_object
6741af1a9c97Smrg
67424a8d91dcSmrg		  if test dlfiles = "$prev"; then
67434a8d91dcSmrg		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
6744a73423d7Smrg		      func_append dlfiles " $pic_object"
6745b3e38ee4Smrg		      prev=
6746b3e38ee4Smrg		      continue
6747b3e38ee4Smrg		    else
6748b3e38ee4Smrg		      # If libtool objects are unsupported, then we need to preload.
6749b3e38ee4Smrg		      prev=dlprefiles
6750b3e38ee4Smrg		    fi
6751b3e38ee4Smrg		  fi
6752af1a9c97Smrg
6753b3e38ee4Smrg		  # CHECK ME:  I think I busted this.  -Ossama
67544a8d91dcSmrg		  if test dlprefiles = "$prev"; then
6755b3e38ee4Smrg		    # Preload the old-style object.
6756a73423d7Smrg		    func_append dlprefiles " $pic_object"
6757b3e38ee4Smrg		    prev=
6758b3e38ee4Smrg		  fi
6759af1a9c97Smrg
6760b3e38ee4Smrg		  # A PIC object.
6761b3e38ee4Smrg		  func_append libobjs " $pic_object"
67624a8d91dcSmrg		  arg=$pic_object
6763b3e38ee4Smrg		fi
6764af1a9c97Smrg
6765b3e38ee4Smrg		# Non-PIC object.
67664a8d91dcSmrg		if test none != "$non_pic_object"; then
6767b3e38ee4Smrg		  # Prepend the subdirectory the object is found in.
67684a8d91dcSmrg		  non_pic_object=$xdir$non_pic_object
6769af1a9c97Smrg
6770b3e38ee4Smrg		  # A standard non-PIC object
6771b3e38ee4Smrg		  func_append non_pic_objects " $non_pic_object"
67724a8d91dcSmrg		  if test -z "$pic_object" || test none = "$pic_object"; then
67734a8d91dcSmrg		    arg=$non_pic_object
6774b3e38ee4Smrg		  fi
6775b3e38ee4Smrg		else
6776b3e38ee4Smrg		  # If the PIC object exists, use it instead.
6777b3e38ee4Smrg		  # $xdir was prepended to $pic_object above.
67784a8d91dcSmrg		  non_pic_object=$pic_object
6779b3e38ee4Smrg		  func_append non_pic_objects " $non_pic_object"
6780b3e38ee4Smrg		fi
6781b3e38ee4Smrg	      else
6782b3e38ee4Smrg		# Only an error if not doing a dry-run.
6783b3e38ee4Smrg		if $opt_dry_run; then
6784b3e38ee4Smrg		  # Extract subdirectory from the argument.
6785b3e38ee4Smrg		  func_dirname "$arg" "/" ""
67864a8d91dcSmrg		  xdir=$func_dirname_result
6787b3e38ee4Smrg
6788b3e38ee4Smrg		  func_lo2o "$arg"
6789b3e38ee4Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
6790b3e38ee4Smrg		  non_pic_object=$xdir$func_lo2o_result
6791b3e38ee4Smrg		  func_append libobjs " $pic_object"
6792b3e38ee4Smrg		  func_append non_pic_objects " $non_pic_object"
6793b3e38ee4Smrg	        else
67944a8d91dcSmrg		  func_fatal_error "'$arg' is not a valid libtool object"
6795b3e38ee4Smrg		fi
6796b3e38ee4Smrg	      fi
6797b3e38ee4Smrg	    done
6798a18ebfb2Smrg	  else
67994a8d91dcSmrg	    func_fatal_error "link input file '$arg' does not exist"
6800a18ebfb2Smrg	  fi
6801b3e38ee4Smrg	  arg=$save_arg
6802b3e38ee4Smrg	  prev=
6803b3e38ee4Smrg	  continue
6804b3e38ee4Smrg	  ;;
68054a8d91dcSmrg	os2dllname)
68064a8d91dcSmrg	  os2dllname=$arg
68074a8d91dcSmrg	  prev=
68084a8d91dcSmrg	  continue
68094a8d91dcSmrg	  ;;
6810b3e38ee4Smrg	precious_regex)
68114a8d91dcSmrg	  precious_files_regex=$arg
6812b3e38ee4Smrg	  prev=
6813b3e38ee4Smrg	  continue
6814b3e38ee4Smrg	  ;;
6815b3e38ee4Smrg	release)
68164a8d91dcSmrg	  release=-$arg
6817b3e38ee4Smrg	  prev=
6818b3e38ee4Smrg	  continue
6819b3e38ee4Smrg	  ;;
6820b3e38ee4Smrg	rpath | xrpath)
6821b3e38ee4Smrg	  # We need an absolute path.
6822b3e38ee4Smrg	  case $arg in
6823b3e38ee4Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
6824b3e38ee4Smrg	  *)
6825b3e38ee4Smrg	    func_fatal_error "only absolute run-paths are allowed"
6826b3e38ee4Smrg	    ;;
6827b3e38ee4Smrg	  esac
68284a8d91dcSmrg	  if test rpath = "$prev"; then
6829b3e38ee4Smrg	    case "$rpath " in
6830b3e38ee4Smrg	    *" $arg "*) ;;
6831a73423d7Smrg	    *) func_append rpath " $arg" ;;
6832b3e38ee4Smrg	    esac
6833a18ebfb2Smrg	  else
6834b3e38ee4Smrg	    case "$xrpath " in
6835b3e38ee4Smrg	    *" $arg "*) ;;
6836a73423d7Smrg	    *) func_append xrpath " $arg" ;;
6837b3e38ee4Smrg	    esac
6838a18ebfb2Smrg	  fi
6839b3e38ee4Smrg	  prev=
6840b3e38ee4Smrg	  continue
6841b3e38ee4Smrg	  ;;
6842b3e38ee4Smrg	shrext)
68434a8d91dcSmrg	  shrext_cmds=$arg
6844b3e38ee4Smrg	  prev=
6845b3e38ee4Smrg	  continue
6846b3e38ee4Smrg	  ;;
6847b3e38ee4Smrg	weak)
6848a73423d7Smrg	  func_append weak_libs " $arg"
6849b3e38ee4Smrg	  prev=
6850b3e38ee4Smrg	  continue
6851b3e38ee4Smrg	  ;;
6852b3e38ee4Smrg	xcclinker)
6853a73423d7Smrg	  func_append linker_flags " $qarg"
6854a73423d7Smrg	  func_append compiler_flags " $qarg"
6855b3e38ee4Smrg	  prev=
6856b3e38ee4Smrg	  func_append compile_command " $qarg"
6857b3e38ee4Smrg	  func_append finalize_command " $qarg"
6858b3e38ee4Smrg	  continue
6859b3e38ee4Smrg	  ;;
6860b3e38ee4Smrg	xcompiler)
6861a73423d7Smrg	  func_append compiler_flags " $qarg"
6862b3e38ee4Smrg	  prev=
6863b3e38ee4Smrg	  func_append compile_command " $qarg"
6864b3e38ee4Smrg	  func_append finalize_command " $qarg"
6865b3e38ee4Smrg	  continue
6866b3e38ee4Smrg	  ;;
6867b3e38ee4Smrg	xlinker)
6868a73423d7Smrg	  func_append linker_flags " $qarg"
6869a73423d7Smrg	  func_append compiler_flags " $wl$qarg"
6870b3e38ee4Smrg	  prev=
6871b3e38ee4Smrg	  func_append compile_command " $wl$qarg"
6872b3e38ee4Smrg	  func_append finalize_command " $wl$qarg"
6873b3e38ee4Smrg	  continue
6874b3e38ee4Smrg	  ;;
6875b3e38ee4Smrg	*)
6876b3e38ee4Smrg	  eval "$prev=\"\$arg\""
6877b3e38ee4Smrg	  prev=
6878b3e38ee4Smrg	  continue
6879b3e38ee4Smrg	  ;;
6880af1a9c97Smrg	esac
6881b3e38ee4Smrg      fi # test -n "$prev"
6882af1a9c97Smrg
68834a8d91dcSmrg      prevarg=$arg
6884af1a9c97Smrg
6885b3e38ee4Smrg      case $arg in
6886b3e38ee4Smrg      -all-static)
6887b3e38ee4Smrg	if test -n "$link_static_flag"; then
6888b3e38ee4Smrg	  # See comment for -static flag below, for more details.
6889b3e38ee4Smrg	  func_append compile_command " $link_static_flag"
6890b3e38ee4Smrg	  func_append finalize_command " $link_static_flag"
6891b3e38ee4Smrg	fi
6892b3e38ee4Smrg	continue
6893b3e38ee4Smrg	;;
6894af1a9c97Smrg
6895b3e38ee4Smrg      -allow-undefined)
6896b3e38ee4Smrg	# FIXME: remove this flag sometime in the future.
68974a8d91dcSmrg	func_fatal_error "'-allow-undefined' must not be used because it is the default"
6898b3e38ee4Smrg	;;
6899af1a9c97Smrg
6900b3e38ee4Smrg      -avoid-version)
6901b3e38ee4Smrg	avoid_version=yes
6902b3e38ee4Smrg	continue
6903b3e38ee4Smrg	;;
6904af1a9c97Smrg
6905a73423d7Smrg      -bindir)
6906a73423d7Smrg	prev=bindir
6907a73423d7Smrg	continue
6908a73423d7Smrg	;;
6909a73423d7Smrg
6910b3e38ee4Smrg      -dlopen)
6911b3e38ee4Smrg	prev=dlfiles
6912b3e38ee4Smrg	continue
6913b3e38ee4Smrg	;;
6914af1a9c97Smrg
6915b3e38ee4Smrg      -dlpreopen)
6916b3e38ee4Smrg	prev=dlprefiles
6917b3e38ee4Smrg	continue
6918b3e38ee4Smrg	;;
6919af1a9c97Smrg
6920b3e38ee4Smrg      -export-dynamic)
6921b3e38ee4Smrg	export_dynamic=yes
6922b3e38ee4Smrg	continue
6923b3e38ee4Smrg	;;
6924af1a9c97Smrg
6925b3e38ee4Smrg      -export-symbols | -export-symbols-regex)
6926b3e38ee4Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
6927b3e38ee4Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
6928b3e38ee4Smrg	fi
69294a8d91dcSmrg	if test X-export-symbols = "X$arg"; then
6930b3e38ee4Smrg	  prev=expsyms
6931b3e38ee4Smrg	else
6932b3e38ee4Smrg	  prev=expsyms_regex
6933b3e38ee4Smrg	fi
6934b3e38ee4Smrg	continue
6935b3e38ee4Smrg	;;
6936af1a9c97Smrg
6937b3e38ee4Smrg      -framework)
6938b3e38ee4Smrg	prev=framework
6939b3e38ee4Smrg	continue
6940b3e38ee4Smrg	;;
6941af1a9c97Smrg
6942b3e38ee4Smrg      -inst-prefix-dir)
6943b3e38ee4Smrg	prev=inst_prefix
6944b3e38ee4Smrg	continue
6945b3e38ee4Smrg	;;
6946af1a9c97Smrg
6947b3e38ee4Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
6948b3e38ee4Smrg      # so, if we see these flags be careful not to treat them like -L
6949b3e38ee4Smrg      -L[A-Z][A-Z]*:*)
6950b3e38ee4Smrg	case $with_gcc/$host in
6951b3e38ee4Smrg	no/*-*-irix* | /*-*-irix*)
6952b3e38ee4Smrg	  func_append compile_command " $arg"
6953b3e38ee4Smrg	  func_append finalize_command " $arg"
6954b3e38ee4Smrg	  ;;
6955b3e38ee4Smrg	esac
6956b3e38ee4Smrg	continue
6957b3e38ee4Smrg	;;
6958af1a9c97Smrg
6959b3e38ee4Smrg      -L*)
6960a73423d7Smrg	func_stripname "-L" '' "$arg"
6961a73423d7Smrg	if test -z "$func_stripname_result"; then
6962b3e38ee4Smrg	  if test "$#" -gt 0; then
69634a8d91dcSmrg	    func_fatal_error "require no space between '-L' and '$1'"
6964b3e38ee4Smrg	  else
69654a8d91dcSmrg	    func_fatal_error "need path for '-L' option"
6966b3e38ee4Smrg	  fi
6967b3e38ee4Smrg	fi
6968a73423d7Smrg	func_resolve_sysroot "$func_stripname_result"
6969a73423d7Smrg	dir=$func_resolve_sysroot_result
6970b3e38ee4Smrg	# We need an absolute path.
6971b3e38ee4Smrg	case $dir in
6972b3e38ee4Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
6973b3e38ee4Smrg	*)
6974b3e38ee4Smrg	  absdir=`cd "$dir" && pwd`
6975b3e38ee4Smrg	  test -z "$absdir" && \
69764a8d91dcSmrg	    func_fatal_error "cannot determine absolute directory name of '$dir'"
69774a8d91dcSmrg	  dir=$absdir
6978b3e38ee4Smrg	  ;;
6979b3e38ee4Smrg	esac
6980b3e38ee4Smrg	case "$deplibs " in
6981a73423d7Smrg	*" -L$dir "* | *" $arg "*)
6982a73423d7Smrg	  # Will only happen for absolute or sysroot arguments
6983a73423d7Smrg	  ;;
6984b3e38ee4Smrg	*)
6985a73423d7Smrg	  # Preserve sysroot, but never include relative directories
6986a73423d7Smrg	  case $dir in
6987a73423d7Smrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
6988a73423d7Smrg	    *) func_append deplibs " -L$dir" ;;
6989a73423d7Smrg	  esac
6990a73423d7Smrg	  func_append lib_search_path " $dir"
6991b3e38ee4Smrg	  ;;
6992b3e38ee4Smrg	esac
6993b3e38ee4Smrg	case $host in
6994b3e38ee4Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6995a73423d7Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
6996b3e38ee4Smrg	  case :$dllsearchpath: in
6997b3e38ee4Smrg	  *":$dir:"*) ;;
6998b3e38ee4Smrg	  ::) dllsearchpath=$dir;;
6999a73423d7Smrg	  *) func_append dllsearchpath ":$dir";;
7000b3e38ee4Smrg	  esac
7001b3e38ee4Smrg	  case :$dllsearchpath: in
7002b3e38ee4Smrg	  *":$testbindir:"*) ;;
7003b3e38ee4Smrg	  ::) dllsearchpath=$testbindir;;
7004a73423d7Smrg	  *) func_append dllsearchpath ":$testbindir";;
7005b3e38ee4Smrg	  esac
7006b3e38ee4Smrg	  ;;
7007b3e38ee4Smrg	esac
7008b3e38ee4Smrg	continue
7009b3e38ee4Smrg	;;
7010af1a9c97Smrg
7011b3e38ee4Smrg      -l*)
70124a8d91dcSmrg	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
7013b3e38ee4Smrg	  case $host in
7014a73423d7Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
7015b3e38ee4Smrg	    # These systems don't actually have a C or math library (as such)
7016b3e38ee4Smrg	    continue
7017b3e38ee4Smrg	    ;;
7018b3e38ee4Smrg	  *-*-os2*)
7019b3e38ee4Smrg	    # These systems don't actually have a C library (as such)
70204a8d91dcSmrg	    test X-lc = "X$arg" && continue
7021b3e38ee4Smrg	    ;;
70224a8d91dcSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
7023b3e38ee4Smrg	    # Do not include libc due to us having libc/libc_r.
70244a8d91dcSmrg	    test X-lc = "X$arg" && continue
7025b3e38ee4Smrg	    ;;
7026b3e38ee4Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
7027b3e38ee4Smrg	    # Rhapsody C and math libraries are in the System framework
7028a73423d7Smrg	    func_append deplibs " System.ltframework"
7029b3e38ee4Smrg	    continue
7030b3e38ee4Smrg	    ;;
7031b3e38ee4Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
7032b3e38ee4Smrg	    # Causes problems with __ctype
70334a8d91dcSmrg	    test X-lc = "X$arg" && continue
7034b3e38ee4Smrg	    ;;
7035b3e38ee4Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7036b3e38ee4Smrg	    # Compiler inserts libc in the correct place for threads to work
70374a8d91dcSmrg	    test X-lc = "X$arg" && continue
7038b3e38ee4Smrg	    ;;
7039b3e38ee4Smrg	  esac
70404a8d91dcSmrg	elif test X-lc_r = "X$arg"; then
7041b3e38ee4Smrg	 case $host in
70424a8d91dcSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
7043b3e38ee4Smrg	   # Do not include libc_r directly, use -pthread flag.
7044b3e38ee4Smrg	   continue
7045b3e38ee4Smrg	   ;;
7046b3e38ee4Smrg	 esac
7047b3e38ee4Smrg	fi
7048a73423d7Smrg	func_append deplibs " $arg"
7049b3e38ee4Smrg	continue
7050b3e38ee4Smrg	;;
7051af1a9c97Smrg
70524a8d91dcSmrg      -mllvm)
70534a8d91dcSmrg	prev=mllvm
70544a8d91dcSmrg	continue
70554a8d91dcSmrg	;;
70564a8d91dcSmrg
7057b3e38ee4Smrg      -module)
7058b3e38ee4Smrg	module=yes
7059b3e38ee4Smrg	continue
7060b3e38ee4Smrg	;;
7061af1a9c97Smrg
7062b3e38ee4Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
7063b3e38ee4Smrg      # classes, name mangling, and exception handling.
7064b3e38ee4Smrg      # Darwin uses the -arch flag to determine output architecture.
7065a73423d7Smrg      -model|-arch|-isysroot|--sysroot)
7066a73423d7Smrg	func_append compiler_flags " $arg"
7067b3e38ee4Smrg	func_append compile_command " $arg"
7068b3e38ee4Smrg	func_append finalize_command " $arg"
7069b3e38ee4Smrg	prev=xcompiler
7070b3e38ee4Smrg	continue
7071b3e38ee4Smrg	;;
7072af1a9c97Smrg
7073a73423d7Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7074a73423d7Smrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7075a73423d7Smrg	func_append compiler_flags " $arg"
7076b3e38ee4Smrg	func_append compile_command " $arg"
7077b3e38ee4Smrg	func_append finalize_command " $arg"
7078b3e38ee4Smrg	case "$new_inherited_linker_flags " in
7079b3e38ee4Smrg	    *" $arg "*) ;;
7080a73423d7Smrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
7081b3e38ee4Smrg	esac
7082b3e38ee4Smrg	continue
7083b3e38ee4Smrg	;;
7084af1a9c97Smrg
7085b3e38ee4Smrg      -multi_module)
70864a8d91dcSmrg	single_module=$wl-multi_module
7087b3e38ee4Smrg	continue
7088b3e38ee4Smrg	;;
7089af1a9c97Smrg
7090b3e38ee4Smrg      -no-fast-install)
7091b3e38ee4Smrg	fast_install=no
7092b3e38ee4Smrg	continue
7093b3e38ee4Smrg	;;
7094af1a9c97Smrg
7095b3e38ee4Smrg      -no-install)
7096b3e38ee4Smrg	case $host in
7097b3e38ee4Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
7098b3e38ee4Smrg	  # The PATH hackery in wrapper scripts is required on Windows
7099b3e38ee4Smrg	  # and Darwin in order for the loader to find any dlls it needs.
71004a8d91dcSmrg	  func_warning "'-no-install' is ignored for $host"
71014a8d91dcSmrg	  func_warning "assuming '-no-fast-install' instead"
7102b3e38ee4Smrg	  fast_install=no
7103b3e38ee4Smrg	  ;;
7104b3e38ee4Smrg	*) no_install=yes ;;
7105b3e38ee4Smrg	esac
7106b3e38ee4Smrg	continue
7107b3e38ee4Smrg	;;
7108af1a9c97Smrg
7109b3e38ee4Smrg      -no-undefined)
7110b3e38ee4Smrg	allow_undefined=no
7111b3e38ee4Smrg	continue
7112b3e38ee4Smrg	;;
7113af1a9c97Smrg
7114b3e38ee4Smrg      -objectlist)
7115b3e38ee4Smrg	prev=objectlist
7116b3e38ee4Smrg	continue
7117b3e38ee4Smrg	;;
7118af1a9c97Smrg
71194a8d91dcSmrg      -os2dllname)
71204a8d91dcSmrg	prev=os2dllname
71214a8d91dcSmrg	continue
71224a8d91dcSmrg	;;
71234a8d91dcSmrg
7124b3e38ee4Smrg      -o) prev=output ;;
7125af1a9c97Smrg
7126b3e38ee4Smrg      -precious-files-regex)
7127b3e38ee4Smrg	prev=precious_regex
7128b3e38ee4Smrg	continue
7129b3e38ee4Smrg	;;
7130af1a9c97Smrg
7131b3e38ee4Smrg      -release)
7132b3e38ee4Smrg	prev=release
7133b3e38ee4Smrg	continue
7134b3e38ee4Smrg	;;
7135af1a9c97Smrg
7136b3e38ee4Smrg      -rpath)
7137b3e38ee4Smrg	prev=rpath
7138b3e38ee4Smrg	continue
7139b3e38ee4Smrg	;;
7140af1a9c97Smrg
7141b3e38ee4Smrg      -R)
7142b3e38ee4Smrg	prev=xrpath
7143b3e38ee4Smrg	continue
7144b3e38ee4Smrg	;;
7145af1a9c97Smrg
7146b3e38ee4Smrg      -R*)
7147b3e38ee4Smrg	func_stripname '-R' '' "$arg"
7148b3e38ee4Smrg	dir=$func_stripname_result
7149b3e38ee4Smrg	# We need an absolute path.
7150b3e38ee4Smrg	case $dir in
7151b3e38ee4Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
7152a73423d7Smrg	=*)
7153a73423d7Smrg	  func_stripname '=' '' "$dir"
7154a73423d7Smrg	  dir=$lt_sysroot$func_stripname_result
7155a73423d7Smrg	  ;;
7156b3e38ee4Smrg	*)
7157b3e38ee4Smrg	  func_fatal_error "only absolute run-paths are allowed"
7158b3e38ee4Smrg	  ;;
7159b3e38ee4Smrg	esac
7160b3e38ee4Smrg	case "$xrpath " in
7161b3e38ee4Smrg	*" $dir "*) ;;
7162a73423d7Smrg	*) func_append xrpath " $dir" ;;
7163b3e38ee4Smrg	esac
7164b3e38ee4Smrg	continue
7165b3e38ee4Smrg	;;
7166af1a9c97Smrg
7167b3e38ee4Smrg      -shared)
7168b3e38ee4Smrg	# The effects of -shared are defined in a previous loop.
7169b3e38ee4Smrg	continue
7170b3e38ee4Smrg	;;
7171af1a9c97Smrg
7172b3e38ee4Smrg      -shrext)
7173b3e38ee4Smrg	prev=shrext
7174b3e38ee4Smrg	continue
7175b3e38ee4Smrg	;;
7176af1a9c97Smrg
7177b3e38ee4Smrg      -static | -static-libtool-libs)
7178b3e38ee4Smrg	# The effects of -static are defined in a previous loop.
7179b3e38ee4Smrg	# We used to do the same as -all-static on platforms that
7180b3e38ee4Smrg	# didn't have a PIC flag, but the assumption that the effects
7181b3e38ee4Smrg	# would be equivalent was wrong.  It would break on at least
7182b3e38ee4Smrg	# Digital Unix and AIX.
7183b3e38ee4Smrg	continue
7184b3e38ee4Smrg	;;
7185af1a9c97Smrg
7186b3e38ee4Smrg      -thread-safe)
7187b3e38ee4Smrg	thread_safe=yes
7188b3e38ee4Smrg	continue
7189b3e38ee4Smrg	;;
7190af1a9c97Smrg
7191b3e38ee4Smrg      -version-info)
7192b3e38ee4Smrg	prev=vinfo
7193b3e38ee4Smrg	continue
7194b3e38ee4Smrg	;;
7195af1a9c97Smrg
7196b3e38ee4Smrg      -version-number)
7197b3e38ee4Smrg	prev=vinfo
7198b3e38ee4Smrg	vinfo_number=yes
7199b3e38ee4Smrg	continue
7200b3e38ee4Smrg	;;
7201af1a9c97Smrg
7202b3e38ee4Smrg      -weak)
7203b3e38ee4Smrg        prev=weak
7204b3e38ee4Smrg	continue
7205b3e38ee4Smrg	;;
720650806d53Smrg
7207b3e38ee4Smrg      -Wc,*)
7208b3e38ee4Smrg	func_stripname '-Wc,' '' "$arg"
7209b3e38ee4Smrg	args=$func_stripname_result
7210b3e38ee4Smrg	arg=
72114a8d91dcSmrg	save_ifs=$IFS; IFS=,
7212b3e38ee4Smrg	for flag in $args; do
72134a8d91dcSmrg	  IFS=$save_ifs
7214b3e38ee4Smrg          func_quote_for_eval "$flag"
7215a73423d7Smrg	  func_append arg " $func_quote_for_eval_result"
7216a73423d7Smrg	  func_append compiler_flags " $func_quote_for_eval_result"
7217b3e38ee4Smrg	done
72184a8d91dcSmrg	IFS=$save_ifs
7219b3e38ee4Smrg	func_stripname ' ' '' "$arg"
7220b3e38ee4Smrg	arg=$func_stripname_result
7221b3e38ee4Smrg	;;
7222a18ebfb2Smrg
7223b3e38ee4Smrg      -Wl,*)
7224b3e38ee4Smrg	func_stripname '-Wl,' '' "$arg"
7225b3e38ee4Smrg	args=$func_stripname_result
7226b3e38ee4Smrg	arg=
72274a8d91dcSmrg	save_ifs=$IFS; IFS=,
7228b3e38ee4Smrg	for flag in $args; do
72294a8d91dcSmrg	  IFS=$save_ifs
7230b3e38ee4Smrg          func_quote_for_eval "$flag"
7231a73423d7Smrg	  func_append arg " $wl$func_quote_for_eval_result"
7232a73423d7Smrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
7233a73423d7Smrg	  func_append linker_flags " $func_quote_for_eval_result"
7234b3e38ee4Smrg	done
72354a8d91dcSmrg	IFS=$save_ifs
7236b3e38ee4Smrg	func_stripname ' ' '' "$arg"
7237b3e38ee4Smrg	arg=$func_stripname_result
7238b3e38ee4Smrg	;;
7239a18ebfb2Smrg
7240b3e38ee4Smrg      -Xcompiler)
7241b3e38ee4Smrg	prev=xcompiler
7242b3e38ee4Smrg	continue
7243b3e38ee4Smrg	;;
7244a18ebfb2Smrg
7245b3e38ee4Smrg      -Xlinker)
7246b3e38ee4Smrg	prev=xlinker
7247b3e38ee4Smrg	continue
7248b3e38ee4Smrg	;;
7249a18ebfb2Smrg
7250b3e38ee4Smrg      -XCClinker)
7251b3e38ee4Smrg	prev=xcclinker
7252b3e38ee4Smrg	continue
7253b3e38ee4Smrg	;;
7254a18ebfb2Smrg
7255b3e38ee4Smrg      # -msg_* for osf cc
7256b3e38ee4Smrg      -msg_*)
7257b3e38ee4Smrg	func_quote_for_eval "$arg"
72584a8d91dcSmrg	arg=$func_quote_for_eval_result
7259b3e38ee4Smrg	;;
7260a18ebfb2Smrg
7261a73423d7Smrg      # Flags to be passed through unchanged, with rationale:
7262a73423d7Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
7263a73423d7Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
7264a73423d7Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
7265a73423d7Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
7266a73423d7Smrg      # -q*                  compiler args for the IBM compiler
7267a73423d7Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
7268a73423d7Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
7269a73423d7Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
72704a8d91dcSmrg      # -fstack-protector*   stack protector flags for GCC
7271a73423d7Smrg      # @file                GCC response files
7272a73423d7Smrg      # -tp=*                Portland pgcc target processor selection
7273a73423d7Smrg      # --sysroot=*          for sysroot support
72744a8d91dcSmrg      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
72754a8d91dcSmrg      # -specs=*             GCC specs files
72764a8d91dcSmrg      # -stdlib=*            select c++ std lib with clang
72774a8d91dcSmrg      # -fsanitize=*         Clang/GCC memory and address sanitizer
7278b3e38ee4Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
7279a73423d7Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
72804a8d91dcSmrg      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
72814a8d91dcSmrg      -specs=*|-fsanitize=*)
7282b3e38ee4Smrg        func_quote_for_eval "$arg"
72834a8d91dcSmrg	arg=$func_quote_for_eval_result
7284b3e38ee4Smrg        func_append compile_command " $arg"
7285b3e38ee4Smrg        func_append finalize_command " $arg"
7286a73423d7Smrg        func_append compiler_flags " $arg"
7287b3e38ee4Smrg        continue
7288b3e38ee4Smrg        ;;
7289a18ebfb2Smrg
72904a8d91dcSmrg      -Z*)
72914a8d91dcSmrg        if test os2 = "`expr $host : '.*\(os2\)'`"; then
72924a8d91dcSmrg          # OS/2 uses -Zxxx to specify OS/2-specific options
72934a8d91dcSmrg	  compiler_flags="$compiler_flags $arg"
72944a8d91dcSmrg	  func_append compile_command " $arg"
72954a8d91dcSmrg	  func_append finalize_command " $arg"
72964a8d91dcSmrg	  case $arg in
72974a8d91dcSmrg	  -Zlinker | -Zstack)
72984a8d91dcSmrg	    prev=xcompiler
72994a8d91dcSmrg	    ;;
73004a8d91dcSmrg	  esac
73014a8d91dcSmrg	  continue
73024a8d91dcSmrg        else
73034a8d91dcSmrg	  # Otherwise treat like 'Some other compiler flag' below
73044a8d91dcSmrg	  func_quote_for_eval "$arg"
73054a8d91dcSmrg	  arg=$func_quote_for_eval_result
73064a8d91dcSmrg        fi
73074a8d91dcSmrg	;;
73084a8d91dcSmrg
7309b3e38ee4Smrg      # Some other compiler flag.
7310b3e38ee4Smrg      -* | +*)
7311b3e38ee4Smrg        func_quote_for_eval "$arg"
73124a8d91dcSmrg	arg=$func_quote_for_eval_result
7313b3e38ee4Smrg	;;
7314a18ebfb2Smrg
7315b3e38ee4Smrg      *.$objext)
7316b3e38ee4Smrg	# A standard object.
7317a73423d7Smrg	func_append objs " $arg"
7318b3e38ee4Smrg	;;
7319a18ebfb2Smrg
7320b3e38ee4Smrg      *.lo)
7321b3e38ee4Smrg	# A libtool-controlled object.
7322a18ebfb2Smrg
7323b3e38ee4Smrg	# Check to see that this really is a libtool object.
7324b3e38ee4Smrg	if func_lalib_unsafe_p "$arg"; then
7325b3e38ee4Smrg	  pic_object=
7326b3e38ee4Smrg	  non_pic_object=
7327a18ebfb2Smrg
7328b3e38ee4Smrg	  # Read the .lo file
7329b3e38ee4Smrg	  func_source "$arg"
7330a18ebfb2Smrg
7331b3e38ee4Smrg	  if test -z "$pic_object" ||
7332b3e38ee4Smrg	     test -z "$non_pic_object" ||
73334a8d91dcSmrg	     test none = "$pic_object" &&
73344a8d91dcSmrg	     test none = "$non_pic_object"; then
73354a8d91dcSmrg	    func_fatal_error "cannot find name of object for '$arg'"
7336b3e38ee4Smrg	  fi
7337a18ebfb2Smrg
7338b3e38ee4Smrg	  # Extract subdirectory from the argument.
7339b3e38ee4Smrg	  func_dirname "$arg" "/" ""
73404a8d91dcSmrg	  xdir=$func_dirname_result
7341a18ebfb2Smrg
73424a8d91dcSmrg	  test none = "$pic_object" || {
7343b3e38ee4Smrg	    # Prepend the subdirectory the object is found in.
73444a8d91dcSmrg	    pic_object=$xdir$pic_object
7345a18ebfb2Smrg
73464a8d91dcSmrg	    if test dlfiles = "$prev"; then
73474a8d91dcSmrg	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
7348a73423d7Smrg		func_append dlfiles " $pic_object"
7349b3e38ee4Smrg		prev=
7350b3e38ee4Smrg		continue
7351b3e38ee4Smrg	      else
7352b3e38ee4Smrg		# If libtool objects are unsupported, then we need to preload.
7353b3e38ee4Smrg		prev=dlprefiles
7354b3e38ee4Smrg	      fi
7355b3e38ee4Smrg	    fi
7356a18ebfb2Smrg
7357b3e38ee4Smrg	    # CHECK ME:  I think I busted this.  -Ossama
73584a8d91dcSmrg	    if test dlprefiles = "$prev"; then
7359b3e38ee4Smrg	      # Preload the old-style object.
7360a73423d7Smrg	      func_append dlprefiles " $pic_object"
7361b3e38ee4Smrg	      prev=
7362b3e38ee4Smrg	    fi
736350806d53Smrg
7364b3e38ee4Smrg	    # A PIC object.
7365b3e38ee4Smrg	    func_append libobjs " $pic_object"
73664a8d91dcSmrg	    arg=$pic_object
73674a8d91dcSmrg	  }
736850806d53Smrg
7369b3e38ee4Smrg	  # Non-PIC object.
73704a8d91dcSmrg	  if test none != "$non_pic_object"; then
7371b3e38ee4Smrg	    # Prepend the subdirectory the object is found in.
73724a8d91dcSmrg	    non_pic_object=$xdir$non_pic_object
737350806d53Smrg
7374b3e38ee4Smrg	    # A standard non-PIC object
7375b3e38ee4Smrg	    func_append non_pic_objects " $non_pic_object"
73764a8d91dcSmrg	    if test -z "$pic_object" || test none = "$pic_object"; then
73774a8d91dcSmrg	      arg=$non_pic_object
7378b3e38ee4Smrg	    fi
7379b3e38ee4Smrg	  else
7380b3e38ee4Smrg	    # If the PIC object exists, use it instead.
7381b3e38ee4Smrg	    # $xdir was prepended to $pic_object above.
73824a8d91dcSmrg	    non_pic_object=$pic_object
7383b3e38ee4Smrg	    func_append non_pic_objects " $non_pic_object"
7384b3e38ee4Smrg	  fi
7385b3e38ee4Smrg	else
7386b3e38ee4Smrg	  # Only an error if not doing a dry-run.
7387b3e38ee4Smrg	  if $opt_dry_run; then
7388b3e38ee4Smrg	    # Extract subdirectory from the argument.
7389b3e38ee4Smrg	    func_dirname "$arg" "/" ""
73904a8d91dcSmrg	    xdir=$func_dirname_result
7391b3e38ee4Smrg
7392b3e38ee4Smrg	    func_lo2o "$arg"
7393b3e38ee4Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
7394b3e38ee4Smrg	    non_pic_object=$xdir$func_lo2o_result
7395b3e38ee4Smrg	    func_append libobjs " $pic_object"
7396b3e38ee4Smrg	    func_append non_pic_objects " $non_pic_object"
7397b3e38ee4Smrg	  else
73984a8d91dcSmrg	    func_fatal_error "'$arg' is not a valid libtool object"
7399b3e38ee4Smrg	  fi
7400b3e38ee4Smrg	fi
7401b3e38ee4Smrg	;;
740250806d53Smrg
7403b3e38ee4Smrg      *.$libext)
7404b3e38ee4Smrg	# An archive.
7405a73423d7Smrg	func_append deplibs " $arg"
7406a73423d7Smrg	func_append old_deplibs " $arg"
7407b3e38ee4Smrg	continue
7408b3e38ee4Smrg	;;
7409b3e38ee4Smrg
7410b3e38ee4Smrg      *.la)
7411b3e38ee4Smrg	# A libtool-controlled library.
7412b3e38ee4Smrg
7413a73423d7Smrg	func_resolve_sysroot "$arg"
74144a8d91dcSmrg	if test dlfiles = "$prev"; then
7415b3e38ee4Smrg	  # This library was specified with -dlopen.
7416a73423d7Smrg	  func_append dlfiles " $func_resolve_sysroot_result"
7417b3e38ee4Smrg	  prev=
74184a8d91dcSmrg	elif test dlprefiles = "$prev"; then
7419b3e38ee4Smrg	  # The library was specified with -dlpreopen.
7420a73423d7Smrg	  func_append dlprefiles " $func_resolve_sysroot_result"
7421b3e38ee4Smrg	  prev=
7422b3e38ee4Smrg	else
7423a73423d7Smrg	  func_append deplibs " $func_resolve_sysroot_result"
7424b3e38ee4Smrg	fi
7425b3e38ee4Smrg	continue
7426b3e38ee4Smrg	;;
7427b3e38ee4Smrg
7428b3e38ee4Smrg      # Some other compiler argument.
7429b3e38ee4Smrg      *)
7430b3e38ee4Smrg	# Unknown arguments in both finalize_command and compile_command need
7431b3e38ee4Smrg	# to be aesthetically quoted because they are evaled later.
7432b3e38ee4Smrg	func_quote_for_eval "$arg"
74334a8d91dcSmrg	arg=$func_quote_for_eval_result
7434b3e38ee4Smrg	;;
7435b3e38ee4Smrg      esac # arg
7436b3e38ee4Smrg
7437b3e38ee4Smrg      # Now actually substitute the argument into the commands.
7438b3e38ee4Smrg      if test -n "$arg"; then
7439b3e38ee4Smrg	func_append compile_command " $arg"
7440b3e38ee4Smrg	func_append finalize_command " $arg"
7441b3e38ee4Smrg      fi
7442b3e38ee4Smrg    done # argument parsing loop
7443b3e38ee4Smrg
7444b3e38ee4Smrg    test -n "$prev" && \
74454a8d91dcSmrg      func_fatal_help "the '$prevarg' option requires an argument"
7446b3e38ee4Smrg
74474a8d91dcSmrg    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
7448b3e38ee4Smrg      eval arg=\"$export_dynamic_flag_spec\"
7449b3e38ee4Smrg      func_append compile_command " $arg"
7450b3e38ee4Smrg      func_append finalize_command " $arg"
7451b3e38ee4Smrg    fi
7452b3e38ee4Smrg
7453b3e38ee4Smrg    oldlibs=
7454b3e38ee4Smrg    # calculate the name of the file, without its directory
7455b3e38ee4Smrg    func_basename "$output"
74564a8d91dcSmrg    outputname=$func_basename_result
74574a8d91dcSmrg    libobjs_save=$libobjs
7458b3e38ee4Smrg
7459b3e38ee4Smrg    if test -n "$shlibpath_var"; then
7460b3e38ee4Smrg      # get the directories listed in $shlibpath_var
74614a8d91dcSmrg      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
7462b3e38ee4Smrg    else
7463b3e38ee4Smrg      shlib_search_path=
7464b3e38ee4Smrg    fi
7465b3e38ee4Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
7466b3e38ee4Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
7467b3e38ee4Smrg
74684a8d91dcSmrg    # Definition is injected by LT_CONFIG during libtool generation.
74694a8d91dcSmrg    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
74704a8d91dcSmrg
7471b3e38ee4Smrg    func_dirname "$output" "/" ""
74724a8d91dcSmrg    output_objdir=$func_dirname_result$objdir
7473a73423d7Smrg    func_to_tool_file "$output_objdir/"
7474a73423d7Smrg    tool_output_objdir=$func_to_tool_file_result
7475b3e38ee4Smrg    # Create the object directory.
7476b3e38ee4Smrg    func_mkdir_p "$output_objdir"
7477b3e38ee4Smrg
7478b3e38ee4Smrg    # Determine the type of output
7479b3e38ee4Smrg    case $output in
7480b3e38ee4Smrg    "")
7481b3e38ee4Smrg      func_fatal_help "you must specify an output file"
7482b3e38ee4Smrg      ;;
7483b3e38ee4Smrg    *.$libext) linkmode=oldlib ;;
7484b3e38ee4Smrg    *.lo | *.$objext) linkmode=obj ;;
7485b3e38ee4Smrg    *.la) linkmode=lib ;;
7486b3e38ee4Smrg    *) linkmode=prog ;; # Anything else should be a program.
7487b3e38ee4Smrg    esac
7488b3e38ee4Smrg
7489b3e38ee4Smrg    specialdeplibs=
7490b3e38ee4Smrg
7491b3e38ee4Smrg    libs=
7492b3e38ee4Smrg    # Find all interdependent deplibs by searching for libraries
7493b3e38ee4Smrg    # that are linked more than once (e.g. -la -lb -la)
7494b3e38ee4Smrg    for deplib in $deplibs; do
74954a8d91dcSmrg      if $opt_preserve_dup_deps; then
7496b3e38ee4Smrg	case "$libs " in
7497a73423d7Smrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
7498b3e38ee4Smrg	esac
7499b3e38ee4Smrg      fi
7500a73423d7Smrg      func_append libs " $deplib"
7501b3e38ee4Smrg    done
7502b3e38ee4Smrg
75034a8d91dcSmrg    if test lib = "$linkmode"; then
7504b3e38ee4Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
7505b3e38ee4Smrg
7506b3e38ee4Smrg      # Compute libraries that are listed more than once in $predeps
7507b3e38ee4Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
7508b3e38ee4Smrg      # not to be eliminated).
7509b3e38ee4Smrg      pre_post_deps=
7510b3e38ee4Smrg      if $opt_duplicate_compiler_generated_deps; then
7511b3e38ee4Smrg	for pre_post_dep in $predeps $postdeps; do
7512b3e38ee4Smrg	  case "$pre_post_deps " in
7513a73423d7Smrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
7514b3e38ee4Smrg	  esac
7515a73423d7Smrg	  func_append pre_post_deps " $pre_post_dep"
7516b3e38ee4Smrg	done
7517b3e38ee4Smrg      fi
7518b3e38ee4Smrg      pre_post_deps=
7519b3e38ee4Smrg    fi
7520b3e38ee4Smrg
7521b3e38ee4Smrg    deplibs=
7522b3e38ee4Smrg    newdependency_libs=
7523b3e38ee4Smrg    newlib_search_path=
7524b3e38ee4Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
7525b3e38ee4Smrg    notinst_deplibs= # not-installed libtool libraries
7526b3e38ee4Smrg    notinst_path= # paths that contain not-installed libtool libraries
7527b3e38ee4Smrg
7528b3e38ee4Smrg    case $linkmode in
7529b3e38ee4Smrg    lib)
7530b3e38ee4Smrg	passes="conv dlpreopen link"
7531b3e38ee4Smrg	for file in $dlfiles $dlprefiles; do
7532b3e38ee4Smrg	  case $file in
7533b3e38ee4Smrg	  *.la) ;;
7534b3e38ee4Smrg	  *)
75354a8d91dcSmrg	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
7536b3e38ee4Smrg	    ;;
7537b3e38ee4Smrg	  esac
7538b3e38ee4Smrg	done
7539b3e38ee4Smrg	;;
7540b3e38ee4Smrg    prog)
7541b3e38ee4Smrg	compile_deplibs=
7542b3e38ee4Smrg	finalize_deplibs=
75434a8d91dcSmrg	alldeplibs=false
7544b3e38ee4Smrg	newdlfiles=
7545b3e38ee4Smrg	newdlprefiles=
7546b3e38ee4Smrg	passes="conv scan dlopen dlpreopen link"
7547b3e38ee4Smrg	;;
7548b3e38ee4Smrg    *)  passes="conv"
7549b3e38ee4Smrg	;;
7550b3e38ee4Smrg    esac
7551b3e38ee4Smrg
7552b3e38ee4Smrg    for pass in $passes; do
7553b3e38ee4Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
7554b3e38ee4Smrg      # so that -L comes before libs that need it for instance...
75554a8d91dcSmrg      if test lib,link = "$linkmode,$pass"; then
7556b3e38ee4Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
7557b3e38ee4Smrg	##        order, and fix it there properly
7558b3e38ee4Smrg        tmp_deplibs=
7559b3e38ee4Smrg	for deplib in $deplibs; do
7560b3e38ee4Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
7561b3e38ee4Smrg	done
75624a8d91dcSmrg	deplibs=$tmp_deplibs
7563b3e38ee4Smrg      fi
7564b3e38ee4Smrg
75654a8d91dcSmrg      if test lib,link = "$linkmode,$pass" ||
75664a8d91dcSmrg	 test prog,scan = "$linkmode,$pass"; then
75674a8d91dcSmrg	libs=$deplibs
7568b3e38ee4Smrg	deplibs=
7569b3e38ee4Smrg      fi
75704a8d91dcSmrg      if test prog = "$linkmode"; then
7571b3e38ee4Smrg	case $pass in
75724a8d91dcSmrg	dlopen) libs=$dlfiles ;;
75734a8d91dcSmrg	dlpreopen) libs=$dlprefiles ;;
75744a8d91dcSmrg	link)
75754a8d91dcSmrg	  libs="$deplibs %DEPLIBS%"
75764a8d91dcSmrg	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
75774a8d91dcSmrg	  ;;
7578b3e38ee4Smrg	esac
7579b3e38ee4Smrg      fi
75804a8d91dcSmrg      if test lib,dlpreopen = "$linkmode,$pass"; then
7581b3e38ee4Smrg	# Collect and forward deplibs of preopened libtool libs
7582b3e38ee4Smrg	for lib in $dlprefiles; do
7583b3e38ee4Smrg	  # Ignore non-libtool-libs
7584b3e38ee4Smrg	  dependency_libs=
7585a73423d7Smrg	  func_resolve_sysroot "$lib"
7586b3e38ee4Smrg	  case $lib in
7587a73423d7Smrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
7588b3e38ee4Smrg	  esac
7589b3e38ee4Smrg
7590b3e38ee4Smrg	  # Collect preopened libtool deplibs, except any this library
7591b3e38ee4Smrg	  # has declared as weak libs
7592b3e38ee4Smrg	  for deplib in $dependency_libs; do
7593a73423d7Smrg	    func_basename "$deplib"
7594a73423d7Smrg            deplib_base=$func_basename_result
7595b3e38ee4Smrg	    case " $weak_libs " in
7596b3e38ee4Smrg	    *" $deplib_base "*) ;;
7597a73423d7Smrg	    *) func_append deplibs " $deplib" ;;
7598b3e38ee4Smrg	    esac
7599b3e38ee4Smrg	  done
7600b3e38ee4Smrg	done
76014a8d91dcSmrg	libs=$dlprefiles
7602b3e38ee4Smrg      fi
76034a8d91dcSmrg      if test dlopen = "$pass"; then
7604b3e38ee4Smrg	# Collect dlpreopened libraries
76054a8d91dcSmrg	save_deplibs=$deplibs
7606b3e38ee4Smrg	deplibs=
7607b3e38ee4Smrg      fi
7608b3e38ee4Smrg
7609b3e38ee4Smrg      for deplib in $libs; do
7610b3e38ee4Smrg	lib=
76114a8d91dcSmrg	found=false
7612b3e38ee4Smrg	case $deplib in
7613a73423d7Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7614a73423d7Smrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
76154a8d91dcSmrg	  if test prog,link = "$linkmode,$pass"; then
7616b3e38ee4Smrg	    compile_deplibs="$deplib $compile_deplibs"
7617b3e38ee4Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
7618b3e38ee4Smrg	  else
7619a73423d7Smrg	    func_append compiler_flags " $deplib"
76204a8d91dcSmrg	    if test lib = "$linkmode"; then
7621b3e38ee4Smrg		case "$new_inherited_linker_flags " in
7622b3e38ee4Smrg		    *" $deplib "*) ;;
7623a73423d7Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
7624b3e38ee4Smrg		esac
7625b3e38ee4Smrg	    fi
7626b3e38ee4Smrg	  fi
7627b3e38ee4Smrg	  continue
7628b3e38ee4Smrg	  ;;
7629b3e38ee4Smrg	-l*)
76304a8d91dcSmrg	  if test lib != "$linkmode" && test prog != "$linkmode"; then
76314a8d91dcSmrg	    func_warning "'-l' is ignored for archives/objects"
7632b3e38ee4Smrg	    continue
7633b3e38ee4Smrg	  fi
7634b3e38ee4Smrg	  func_stripname '-l' '' "$deplib"
7635b3e38ee4Smrg	  name=$func_stripname_result
76364a8d91dcSmrg	  if test lib = "$linkmode"; then
7637b3e38ee4Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
7638b3e38ee4Smrg	  else
7639b3e38ee4Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
7640b3e38ee4Smrg	  fi
7641b3e38ee4Smrg	  for searchdir in $searchdirs; do
7642b3e38ee4Smrg	    for search_ext in .la $std_shrext .so .a; do
7643b3e38ee4Smrg	      # Search the libtool library
76444a8d91dcSmrg	      lib=$searchdir/lib$name$search_ext
7645b3e38ee4Smrg	      if test -f "$lib"; then
76464a8d91dcSmrg		if test .la = "$search_ext"; then
76474a8d91dcSmrg		  found=:
7648b3e38ee4Smrg		else
76494a8d91dcSmrg		  found=false
7650b3e38ee4Smrg		fi
7651b3e38ee4Smrg		break 2
7652b3e38ee4Smrg	      fi
7653b3e38ee4Smrg	    done
7654b3e38ee4Smrg	  done
76554a8d91dcSmrg	  if $found; then
76564a8d91dcSmrg	    # deplib is a libtool library
7657b3e38ee4Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
7658b3e38ee4Smrg	    # We need to do some special things here, and not later.
76594a8d91dcSmrg	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
7660b3e38ee4Smrg	      case " $predeps $postdeps " in
7661b3e38ee4Smrg	      *" $deplib "*)
7662b3e38ee4Smrg		if func_lalib_p "$lib"; then
7663b3e38ee4Smrg		  library_names=
7664b3e38ee4Smrg		  old_library=
7665b3e38ee4Smrg		  func_source "$lib"
7666b3e38ee4Smrg		  for l in $old_library $library_names; do
76674a8d91dcSmrg		    ll=$l
7668b3e38ee4Smrg		  done
76694a8d91dcSmrg		  if test "X$ll" = "X$old_library"; then # only static version available
76704a8d91dcSmrg		    found=false
7671b3e38ee4Smrg		    func_dirname "$lib" "" "."
76724a8d91dcSmrg		    ladir=$func_dirname_result
7673b3e38ee4Smrg		    lib=$ladir/$old_library
76744a8d91dcSmrg		    if test prog,link = "$linkmode,$pass"; then
7675b3e38ee4Smrg		      compile_deplibs="$deplib $compile_deplibs"
7676b3e38ee4Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
7677b3e38ee4Smrg		    else
7678b3e38ee4Smrg		      deplibs="$deplib $deplibs"
76794a8d91dcSmrg		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7680b3e38ee4Smrg		    fi
7681b3e38ee4Smrg		    continue
7682b3e38ee4Smrg		  fi
7683b3e38ee4Smrg		fi
7684b3e38ee4Smrg		;;
7685b3e38ee4Smrg	      *) ;;
7686b3e38ee4Smrg	      esac
7687b3e38ee4Smrg	    fi
76884a8d91dcSmrg	  else
76894a8d91dcSmrg	    # deplib doesn't seem to be a libtool library
76904a8d91dcSmrg	    if test prog,link = "$linkmode,$pass"; then
76914a8d91dcSmrg	      compile_deplibs="$deplib $compile_deplibs"
76924a8d91dcSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
76934a8d91dcSmrg	    else
76944a8d91dcSmrg	      deplibs="$deplib $deplibs"
76954a8d91dcSmrg	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
76964a8d91dcSmrg	    fi
76974a8d91dcSmrg	    continue
7698b3e38ee4Smrg	  fi
7699b3e38ee4Smrg	  ;; # -l
7700b3e38ee4Smrg	*.ltframework)
77014a8d91dcSmrg	  if test prog,link = "$linkmode,$pass"; then
7702b3e38ee4Smrg	    compile_deplibs="$deplib $compile_deplibs"
7703b3e38ee4Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
7704b3e38ee4Smrg	  else
7705b3e38ee4Smrg	    deplibs="$deplib $deplibs"
77064a8d91dcSmrg	    if test lib = "$linkmode"; then
7707b3e38ee4Smrg		case "$new_inherited_linker_flags " in
7708b3e38ee4Smrg		    *" $deplib "*) ;;
7709a73423d7Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
7710b3e38ee4Smrg		esac
7711b3e38ee4Smrg	    fi
7712b3e38ee4Smrg	  fi
7713b3e38ee4Smrg	  continue
7714b3e38ee4Smrg	  ;;
7715b3e38ee4Smrg	-L*)
7716b3e38ee4Smrg	  case $linkmode in
7717b3e38ee4Smrg	  lib)
7718b3e38ee4Smrg	    deplibs="$deplib $deplibs"
77194a8d91dcSmrg	    test conv = "$pass" && continue
7720b3e38ee4Smrg	    newdependency_libs="$deplib $newdependency_libs"
7721b3e38ee4Smrg	    func_stripname '-L' '' "$deplib"
7722a73423d7Smrg	    func_resolve_sysroot "$func_stripname_result"
7723a73423d7Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
7724b3e38ee4Smrg	    ;;
7725b3e38ee4Smrg	  prog)
77264a8d91dcSmrg	    if test conv = "$pass"; then
7727b3e38ee4Smrg	      deplibs="$deplib $deplibs"
7728b3e38ee4Smrg	      continue
7729b3e38ee4Smrg	    fi
77304a8d91dcSmrg	    if test scan = "$pass"; then
7731b3e38ee4Smrg	      deplibs="$deplib $deplibs"
7732b3e38ee4Smrg	    else
7733b3e38ee4Smrg	      compile_deplibs="$deplib $compile_deplibs"
7734b3e38ee4Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
7735b3e38ee4Smrg	    fi
7736b3e38ee4Smrg	    func_stripname '-L' '' "$deplib"
7737a73423d7Smrg	    func_resolve_sysroot "$func_stripname_result"
7738a73423d7Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
7739b3e38ee4Smrg	    ;;
7740b3e38ee4Smrg	  *)
77414a8d91dcSmrg	    func_warning "'-L' is ignored for archives/objects"
7742b3e38ee4Smrg	    ;;
7743b3e38ee4Smrg	  esac # linkmode
7744b3e38ee4Smrg	  continue
7745b3e38ee4Smrg	  ;; # -L
7746b3e38ee4Smrg	-R*)
77474a8d91dcSmrg	  if test link = "$pass"; then
7748b3e38ee4Smrg	    func_stripname '-R' '' "$deplib"
7749a73423d7Smrg	    func_resolve_sysroot "$func_stripname_result"
7750a73423d7Smrg	    dir=$func_resolve_sysroot_result
7751b3e38ee4Smrg	    # Make sure the xrpath contains only unique directories.
7752b3e38ee4Smrg	    case "$xrpath " in
7753b3e38ee4Smrg	    *" $dir "*) ;;
7754a73423d7Smrg	    *) func_append xrpath " $dir" ;;
7755b3e38ee4Smrg	    esac
7756b3e38ee4Smrg	  fi
7757b3e38ee4Smrg	  deplibs="$deplib $deplibs"
7758b3e38ee4Smrg	  continue
7759b3e38ee4Smrg	  ;;
7760a73423d7Smrg	*.la)
7761a73423d7Smrg	  func_resolve_sysroot "$deplib"
7762a73423d7Smrg	  lib=$func_resolve_sysroot_result
7763a73423d7Smrg	  ;;
7764b3e38ee4Smrg	*.$libext)
77654a8d91dcSmrg	  if test conv = "$pass"; then
7766b3e38ee4Smrg	    deplibs="$deplib $deplibs"
7767b3e38ee4Smrg	    continue
7768b3e38ee4Smrg	  fi
7769b3e38ee4Smrg	  case $linkmode in
7770b3e38ee4Smrg	  lib)
7771b3e38ee4Smrg	    # Linking convenience modules into shared libraries is allowed,
7772b3e38ee4Smrg	    # but linking other static libraries is non-portable.
7773b3e38ee4Smrg	    case " $dlpreconveniencelibs " in
7774b3e38ee4Smrg	    *" $deplib "*) ;;
7775b3e38ee4Smrg	    *)
77764a8d91dcSmrg	      valid_a_lib=false
7777b3e38ee4Smrg	      case $deplibs_check_method in
7778b3e38ee4Smrg		match_pattern*)
7779b3e38ee4Smrg		  set dummy $deplibs_check_method; shift
7780b3e38ee4Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7781a73423d7Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
7782b3e38ee4Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
77834a8d91dcSmrg		    valid_a_lib=:
7784b3e38ee4Smrg		  fi
7785b3e38ee4Smrg		;;
7786b3e38ee4Smrg		pass_all)
77874a8d91dcSmrg		  valid_a_lib=:
7788b3e38ee4Smrg		;;
7789b3e38ee4Smrg	      esac
77904a8d91dcSmrg	      if $valid_a_lib; then
77914a8d91dcSmrg		echo
77924a8d91dcSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
77934a8d91dcSmrg		$ECHO "*** static library $deplib is not portable!"
77944a8d91dcSmrg		deplibs="$deplib $deplibs"
77954a8d91dcSmrg	      else
7796a73423d7Smrg		echo
7797b3e38ee4Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
7798a73423d7Smrg		echo "*** I have the capability to make that library automatically link in when"
7799a73423d7Smrg		echo "*** you link to this library.  But I can only do this if you have a"
7800a73423d7Smrg		echo "*** shared version of the library, which you do not appear to have"
7801a73423d7Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
7802a73423d7Smrg		echo "*** that it is just a static archive that I should not use here."
7803b3e38ee4Smrg	      fi
7804b3e38ee4Smrg	      ;;
7805b3e38ee4Smrg	    esac
7806b3e38ee4Smrg	    continue
7807b3e38ee4Smrg	    ;;
7808b3e38ee4Smrg	  prog)
78094a8d91dcSmrg	    if test link != "$pass"; then
7810b3e38ee4Smrg	      deplibs="$deplib $deplibs"
7811b3e38ee4Smrg	    else
7812b3e38ee4Smrg	      compile_deplibs="$deplib $compile_deplibs"
7813b3e38ee4Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
7814b3e38ee4Smrg	    fi
7815b3e38ee4Smrg	    continue
7816b3e38ee4Smrg	    ;;
7817b3e38ee4Smrg	  esac # linkmode
7818b3e38ee4Smrg	  ;; # *.$libext
7819b3e38ee4Smrg	*.lo | *.$objext)
78204a8d91dcSmrg	  if test conv = "$pass"; then
7821b3e38ee4Smrg	    deplibs="$deplib $deplibs"
78224a8d91dcSmrg	  elif test prog = "$linkmode"; then
78234a8d91dcSmrg	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
7824b3e38ee4Smrg	      # If there is no dlopen support or we're linking statically,
7825b3e38ee4Smrg	      # we need to preload.
7826a73423d7Smrg	      func_append newdlprefiles " $deplib"
7827b3e38ee4Smrg	      compile_deplibs="$deplib $compile_deplibs"
7828b3e38ee4Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
7829b3e38ee4Smrg	    else
7830a73423d7Smrg	      func_append newdlfiles " $deplib"
7831b3e38ee4Smrg	    fi
7832b3e38ee4Smrg	  fi
7833b3e38ee4Smrg	  continue
7834b3e38ee4Smrg	  ;;
7835b3e38ee4Smrg	%DEPLIBS%)
78364a8d91dcSmrg	  alldeplibs=:
7837b3e38ee4Smrg	  continue
7838b3e38ee4Smrg	  ;;
7839b3e38ee4Smrg	esac # case $deplib
7840b3e38ee4Smrg
78414a8d91dcSmrg	$found || test -f "$lib" \
78424a8d91dcSmrg	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
7843b3e38ee4Smrg
7844b3e38ee4Smrg	# Check to see that this really is a libtool archive.
7845b3e38ee4Smrg	func_lalib_unsafe_p "$lib" \
78464a8d91dcSmrg	  || func_fatal_error "'$lib' is not a valid libtool archive"
7847b3e38ee4Smrg
7848b3e38ee4Smrg	func_dirname "$lib" "" "."
78494a8d91dcSmrg	ladir=$func_dirname_result
7850b3e38ee4Smrg
7851b3e38ee4Smrg	dlname=
7852b3e38ee4Smrg	dlopen=
7853b3e38ee4Smrg	dlpreopen=
7854b3e38ee4Smrg	libdir=
7855b3e38ee4Smrg	library_names=
7856b3e38ee4Smrg	old_library=
7857b3e38ee4Smrg	inherited_linker_flags=
7858b3e38ee4Smrg	# If the library was installed with an old release of libtool,
7859b3e38ee4Smrg	# it will not redefine variables installed, or shouldnotlink
7860b3e38ee4Smrg	installed=yes
7861b3e38ee4Smrg	shouldnotlink=no
7862b3e38ee4Smrg	avoidtemprpath=
7863b3e38ee4Smrg
7864b3e38ee4Smrg
7865b3e38ee4Smrg	# Read the .la file
7866b3e38ee4Smrg	func_source "$lib"
7867b3e38ee4Smrg
7868b3e38ee4Smrg	# Convert "-framework foo" to "foo.ltframework"
7869b3e38ee4Smrg	if test -n "$inherited_linker_flags"; then
7870a73423d7Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
7871b3e38ee4Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
7872b3e38ee4Smrg	    case " $new_inherited_linker_flags " in
7873b3e38ee4Smrg	      *" $tmp_inherited_linker_flag "*) ;;
7874a73423d7Smrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
7875b3e38ee4Smrg	    esac
7876b3e38ee4Smrg	  done
7877b3e38ee4Smrg	fi
7878a73423d7Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
78794a8d91dcSmrg	if test lib,link = "$linkmode,$pass" ||
78804a8d91dcSmrg	   test prog,scan = "$linkmode,$pass" ||
78814a8d91dcSmrg	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
7882a73423d7Smrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
7883a73423d7Smrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
7884b3e38ee4Smrg	fi
7885b3e38ee4Smrg
78864a8d91dcSmrg	if test conv = "$pass"; then
7887b3e38ee4Smrg	  # Only check for convenience libraries
7888b3e38ee4Smrg	  deplibs="$lib $deplibs"
7889b3e38ee4Smrg	  if test -z "$libdir"; then
7890b3e38ee4Smrg	    if test -z "$old_library"; then
78914a8d91dcSmrg	      func_fatal_error "cannot find name of link library for '$lib'"
7892b3e38ee4Smrg	    fi
7893b3e38ee4Smrg	    # It is a libtool convenience library, so add in its objects.
7894a73423d7Smrg	    func_append convenience " $ladir/$objdir/$old_library"
7895a73423d7Smrg	    func_append old_convenience " $ladir/$objdir/$old_library"
78964a8d91dcSmrg	    tmp_libs=
78974a8d91dcSmrg	    for deplib in $dependency_libs; do
78984a8d91dcSmrg	      deplibs="$deplib $deplibs"
78994a8d91dcSmrg	      if $opt_preserve_dup_deps; then
79004a8d91dcSmrg		case "$tmp_libs " in
79014a8d91dcSmrg		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
79024a8d91dcSmrg		esac
79034a8d91dcSmrg	      fi
79044a8d91dcSmrg	      func_append tmp_libs " $deplib"
79054a8d91dcSmrg	    done
79064a8d91dcSmrg	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
79074a8d91dcSmrg	    func_fatal_error "'$lib' is not a convenience library"
7908b3e38ee4Smrg	  fi
7909b3e38ee4Smrg	  continue
7910b3e38ee4Smrg	fi # $pass = conv
7911b3e38ee4Smrg
7912b3e38ee4Smrg
7913b3e38ee4Smrg	# Get the name of the library we link against.
7914b3e38ee4Smrg	linklib=
7915a73423d7Smrg	if test -n "$old_library" &&
79164a8d91dcSmrg	   { test yes = "$prefer_static_libs" ||
79174a8d91dcSmrg	     test built,no = "$prefer_static_libs,$installed"; }; then
7918a73423d7Smrg	  linklib=$old_library
7919a73423d7Smrg	else
7920a73423d7Smrg	  for l in $old_library $library_names; do
79214a8d91dcSmrg	    linklib=$l
7922a73423d7Smrg	  done
7923a73423d7Smrg	fi
7924b3e38ee4Smrg	if test -z "$linklib"; then
79254a8d91dcSmrg	  func_fatal_error "cannot find name of link library for '$lib'"
7926b3e38ee4Smrg	fi
7927b3e38ee4Smrg
7928b3e38ee4Smrg	# This library was specified with -dlopen.
79294a8d91dcSmrg	if test dlopen = "$pass"; then
79304a8d91dcSmrg	  test -z "$libdir" \
79314a8d91dcSmrg	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
7932b3e38ee4Smrg	  if test -z "$dlname" ||
79334a8d91dcSmrg	     test yes != "$dlopen_support" ||
79344a8d91dcSmrg	     test no = "$build_libtool_libs"
79354a8d91dcSmrg	  then
7936b3e38ee4Smrg	    # If there is no dlname, no dlopen support or we're linking
7937b3e38ee4Smrg	    # statically, we need to preload.  We also need to preload any
7938b3e38ee4Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
7939b3e38ee4Smrg	    # bomb out in the load deplibs phase.
7940a73423d7Smrg	    func_append dlprefiles " $lib $dependency_libs"
7941b3e38ee4Smrg	  else
7942a73423d7Smrg	    func_append newdlfiles " $lib"
7943b3e38ee4Smrg	  fi
7944b3e38ee4Smrg	  continue
7945b3e38ee4Smrg	fi # $pass = dlopen
7946b3e38ee4Smrg
7947b3e38ee4Smrg	# We need an absolute path.
7948b3e38ee4Smrg	case $ladir in
79494a8d91dcSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
7950b3e38ee4Smrg	*)
7951b3e38ee4Smrg	  abs_ladir=`cd "$ladir" && pwd`
7952b3e38ee4Smrg	  if test -z "$abs_ladir"; then
79534a8d91dcSmrg	    func_warning "cannot determine absolute directory name of '$ladir'"
7954b3e38ee4Smrg	    func_warning "passing it literally to the linker, although it might fail"
79554a8d91dcSmrg	    abs_ladir=$ladir
7956b3e38ee4Smrg	  fi
7957b3e38ee4Smrg	  ;;
7958b3e38ee4Smrg	esac
7959b3e38ee4Smrg	func_basename "$lib"
79604a8d91dcSmrg	laname=$func_basename_result
7961b3e38ee4Smrg
7962b3e38ee4Smrg	# Find the relevant object directory and library name.
79634a8d91dcSmrg	if test yes = "$installed"; then
7964a73423d7Smrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
79654a8d91dcSmrg	    func_warning "library '$lib' was moved."
79664a8d91dcSmrg	    dir=$ladir
79674a8d91dcSmrg	    absdir=$abs_ladir
79684a8d91dcSmrg	    libdir=$abs_ladir
7969b3e38ee4Smrg	  else
79704a8d91dcSmrg	    dir=$lt_sysroot$libdir
79714a8d91dcSmrg	    absdir=$lt_sysroot$libdir
7972b3e38ee4Smrg	  fi
79734a8d91dcSmrg	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
7974b3e38ee4Smrg	else
7975b3e38ee4Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
79764a8d91dcSmrg	    dir=$ladir
79774a8d91dcSmrg	    absdir=$abs_ladir
7978b3e38ee4Smrg	    # Remove this search path later
7979a73423d7Smrg	    func_append notinst_path " $abs_ladir"
7980b3e38ee4Smrg	  else
79814a8d91dcSmrg	    dir=$ladir/$objdir
79824a8d91dcSmrg	    absdir=$abs_ladir/$objdir
7983b3e38ee4Smrg	    # Remove this search path later
7984a73423d7Smrg	    func_append notinst_path " $abs_ladir"
7985b3e38ee4Smrg	  fi
7986b3e38ee4Smrg	fi # $installed = yes
7987b3e38ee4Smrg	func_stripname 'lib' '.la' "$laname"
7988b3e38ee4Smrg	name=$func_stripname_result
7989b3e38ee4Smrg
7990b3e38ee4Smrg	# This library was specified with -dlpreopen.
79914a8d91dcSmrg	if test dlpreopen = "$pass"; then
79924a8d91dcSmrg	  if test -z "$libdir" && test prog = "$linkmode"; then
79934a8d91dcSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
7994b3e38ee4Smrg	  fi
79954a8d91dcSmrg	  case $host in
7996a73423d7Smrg	    # special handling for platforms with PE-DLLs.
7997a73423d7Smrg	    *cygwin* | *mingw* | *cegcc* )
7998a73423d7Smrg	      # Linker will automatically link against shared library if both
7999a73423d7Smrg	      # static and shared are present.  Therefore, ensure we extract
8000a73423d7Smrg	      # symbols from the import library if a shared library is present
8001a73423d7Smrg	      # (otherwise, the dlopen module name will be incorrect).  We do
8002a73423d7Smrg	      # this by putting the import library name into $newdlprefiles.
8003a73423d7Smrg	      # We recover the dlopen module name by 'saving' the la file
8004a73423d7Smrg	      # name in a special purpose variable, and (later) extracting the
8005a73423d7Smrg	      # dlname from the la file.
8006a73423d7Smrg	      if test -n "$dlname"; then
8007a73423d7Smrg	        func_tr_sh "$dir/$linklib"
8008a73423d7Smrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
8009a73423d7Smrg	        func_append newdlprefiles " $dir/$linklib"
8010a73423d7Smrg	      else
8011a73423d7Smrg	        func_append newdlprefiles " $dir/$old_library"
8012a73423d7Smrg	        # Keep a list of preopened convenience libraries to check
8013a73423d7Smrg	        # that they are being used correctly in the link pass.
8014a73423d7Smrg	        test -z "$libdir" && \
8015a73423d7Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8016a73423d7Smrg	      fi
8017a73423d7Smrg	    ;;
8018a73423d7Smrg	    * )
8019a73423d7Smrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
8020a73423d7Smrg	      # are required to link).
8021a73423d7Smrg	      if test -n "$old_library"; then
8022a73423d7Smrg	        func_append newdlprefiles " $dir/$old_library"
8023a73423d7Smrg	        # Keep a list of preopened convenience libraries to check
8024a73423d7Smrg	        # that they are being used correctly in the link pass.
8025a73423d7Smrg	        test -z "$libdir" && \
8026a73423d7Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8027a73423d7Smrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
8028a73423d7Smrg	      elif test -n "$dlname"; then
8029a73423d7Smrg	        func_append newdlprefiles " $dir/$dlname"
8030a73423d7Smrg	      else
8031a73423d7Smrg	        func_append newdlprefiles " $dir/$linklib"
8032a73423d7Smrg	      fi
8033a73423d7Smrg	    ;;
8034a73423d7Smrg	  esac
8035b3e38ee4Smrg	fi # $pass = dlpreopen
8036b3e38ee4Smrg
8037b3e38ee4Smrg	if test -z "$libdir"; then
8038b3e38ee4Smrg	  # Link the convenience library
80394a8d91dcSmrg	  if test lib = "$linkmode"; then
8040b3e38ee4Smrg	    deplibs="$dir/$old_library $deplibs"
80414a8d91dcSmrg	  elif test prog,link = "$linkmode,$pass"; then
8042b3e38ee4Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
8043b3e38ee4Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
8044b3e38ee4Smrg	  else
8045b3e38ee4Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
8046b3e38ee4Smrg	  fi
8047b3e38ee4Smrg	  continue
8048b3e38ee4Smrg	fi
8049b3e38ee4Smrg
8050b3e38ee4Smrg
80514a8d91dcSmrg	if test prog = "$linkmode" && test link != "$pass"; then
8052a73423d7Smrg	  func_append newlib_search_path " $ladir"
8053b3e38ee4Smrg	  deplibs="$lib $deplibs"
8054b3e38ee4Smrg
80554a8d91dcSmrg	  linkalldeplibs=false
80564a8d91dcSmrg	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
80574a8d91dcSmrg	     test no = "$build_libtool_libs"; then
80584a8d91dcSmrg	    linkalldeplibs=:
8059b3e38ee4Smrg	  fi
8060b3e38ee4Smrg
8061b3e38ee4Smrg	  tmp_libs=
8062b3e38ee4Smrg	  for deplib in $dependency_libs; do
8063b3e38ee4Smrg	    case $deplib in
8064b3e38ee4Smrg	    -L*) func_stripname '-L' '' "$deplib"
8065a73423d7Smrg	         func_resolve_sysroot "$func_stripname_result"
8066a73423d7Smrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
8067b3e38ee4Smrg		 ;;
8068b3e38ee4Smrg	    esac
8069b3e38ee4Smrg	    # Need to link against all dependency_libs?
80704a8d91dcSmrg	    if $linkalldeplibs; then
8071b3e38ee4Smrg	      deplibs="$deplib $deplibs"
8072b3e38ee4Smrg	    else
8073b3e38ee4Smrg	      # Need to hardcode shared library paths
8074b3e38ee4Smrg	      # or/and link against static libraries
8075b3e38ee4Smrg	      newdependency_libs="$deplib $newdependency_libs"
8076b3e38ee4Smrg	    fi
80774a8d91dcSmrg	    if $opt_preserve_dup_deps; then
8078b3e38ee4Smrg	      case "$tmp_libs " in
8079a73423d7Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
8080b3e38ee4Smrg	      esac
8081b3e38ee4Smrg	    fi
8082a73423d7Smrg	    func_append tmp_libs " $deplib"
8083b3e38ee4Smrg	  done # for deplib
8084b3e38ee4Smrg	  continue
8085b3e38ee4Smrg	fi # $linkmode = prog...
8086b3e38ee4Smrg
80874a8d91dcSmrg	if test prog,link = "$linkmode,$pass"; then
8088b3e38ee4Smrg	  if test -n "$library_names" &&
80894a8d91dcSmrg	     { { test no = "$prefer_static_libs" ||
80904a8d91dcSmrg	         test built,yes = "$prefer_static_libs,$installed"; } ||
8091b3e38ee4Smrg	       test -z "$old_library"; }; then
8092b3e38ee4Smrg	    # We need to hardcode the library path
80934a8d91dcSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
8094b3e38ee4Smrg	      # Make sure the rpath contains only unique directories.
80954a8d91dcSmrg	      case $temp_rpath: in
8096b3e38ee4Smrg	      *"$absdir:"*) ;;
8097a73423d7Smrg	      *) func_append temp_rpath "$absdir:" ;;
8098b3e38ee4Smrg	      esac
8099b3e38ee4Smrg	    fi
8100b3e38ee4Smrg
8101b3e38ee4Smrg	    # Hardcode the library path.
8102b3e38ee4Smrg	    # Skip directories that are in the system default run-time
8103b3e38ee4Smrg	    # search path.
8104b3e38ee4Smrg	    case " $sys_lib_dlsearch_path " in
8105b3e38ee4Smrg	    *" $absdir "*) ;;
8106b3e38ee4Smrg	    *)
8107b3e38ee4Smrg	      case "$compile_rpath " in
8108b3e38ee4Smrg	      *" $absdir "*) ;;
8109a73423d7Smrg	      *) func_append compile_rpath " $absdir" ;;
8110b3e38ee4Smrg	      esac
8111b3e38ee4Smrg	      ;;
8112b3e38ee4Smrg	    esac
8113b3e38ee4Smrg	    case " $sys_lib_dlsearch_path " in
8114b3e38ee4Smrg	    *" $libdir "*) ;;
8115b3e38ee4Smrg	    *)
8116b3e38ee4Smrg	      case "$finalize_rpath " in
8117b3e38ee4Smrg	      *" $libdir "*) ;;
8118a73423d7Smrg	      *) func_append finalize_rpath " $libdir" ;;
8119b3e38ee4Smrg	      esac
8120b3e38ee4Smrg	      ;;
8121b3e38ee4Smrg	    esac
8122b3e38ee4Smrg	  fi # $linkmode,$pass = prog,link...
8123b3e38ee4Smrg
81244a8d91dcSmrg	  if $alldeplibs &&
81254a8d91dcSmrg	     { test pass_all = "$deplibs_check_method" ||
81264a8d91dcSmrg	       { test yes = "$build_libtool_libs" &&
8127b3e38ee4Smrg		 test -n "$library_names"; }; }; then
8128b3e38ee4Smrg	    # We only need to search for static libraries
8129b3e38ee4Smrg	    continue
8130b3e38ee4Smrg	  fi
8131b3e38ee4Smrg	fi
8132b3e38ee4Smrg
8133b3e38ee4Smrg	link_static=no # Whether the deplib will be linked statically
8134b3e38ee4Smrg	use_static_libs=$prefer_static_libs
81354a8d91dcSmrg	if test built = "$use_static_libs" && test yes = "$installed"; then
8136b3e38ee4Smrg	  use_static_libs=no
8137b3e38ee4Smrg	fi
8138b3e38ee4Smrg	if test -n "$library_names" &&
81394a8d91dcSmrg	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
8140b3e38ee4Smrg	  case $host in
81414a8d91dcSmrg	  *cygwin* | *mingw* | *cegcc* | *os2*)
8142b3e38ee4Smrg	      # No point in relinking DLLs because paths are not encoded
8143a73423d7Smrg	      func_append notinst_deplibs " $lib"
8144b3e38ee4Smrg	      need_relink=no
8145b3e38ee4Smrg	    ;;
8146b3e38ee4Smrg	  *)
81474a8d91dcSmrg	    if test no = "$installed"; then
8148a73423d7Smrg	      func_append notinst_deplibs " $lib"
8149b3e38ee4Smrg	      need_relink=yes
8150b3e38ee4Smrg	    fi
8151b3e38ee4Smrg	    ;;
8152b3e38ee4Smrg	  esac
8153b3e38ee4Smrg	  # This is a shared library
8154b3e38ee4Smrg
8155b3e38ee4Smrg	  # Warn about portability, can't link against -module's on some
8156b3e38ee4Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
81574a8d91dcSmrg	  dlopenmodule=
8158b3e38ee4Smrg	  for dlpremoduletest in $dlprefiles; do
8159b3e38ee4Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
81604a8d91dcSmrg	      dlopenmodule=$dlpremoduletest
8161b3e38ee4Smrg	      break
8162b3e38ee4Smrg	    fi
8163b3e38ee4Smrg	  done
81644a8d91dcSmrg	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
8165a73423d7Smrg	    echo
81664a8d91dcSmrg	    if test prog = "$linkmode"; then
8167b3e38ee4Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
8168b3e38ee4Smrg	    else
8169b3e38ee4Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
8170b3e38ee4Smrg	    fi
8171b3e38ee4Smrg	    $ECHO "*** $linklib is not portable!"
8172b3e38ee4Smrg	  fi
81734a8d91dcSmrg	  if test lib = "$linkmode" &&
81744a8d91dcSmrg	     test yes = "$hardcode_into_libs"; then
8175b3e38ee4Smrg	    # Hardcode the library path.
8176b3e38ee4Smrg	    # Skip directories that are in the system default run-time
8177b3e38ee4Smrg	    # search path.
8178b3e38ee4Smrg	    case " $sys_lib_dlsearch_path " in
8179b3e38ee4Smrg	    *" $absdir "*) ;;
8180b3e38ee4Smrg	    *)
8181b3e38ee4Smrg	      case "$compile_rpath " in
8182b3e38ee4Smrg	      *" $absdir "*) ;;
8183a73423d7Smrg	      *) func_append compile_rpath " $absdir" ;;
8184b3e38ee4Smrg	      esac
8185b3e38ee4Smrg	      ;;
8186b3e38ee4Smrg	    esac
8187b3e38ee4Smrg	    case " $sys_lib_dlsearch_path " in
8188b3e38ee4Smrg	    *" $libdir "*) ;;
8189b3e38ee4Smrg	    *)
8190b3e38ee4Smrg	      case "$finalize_rpath " in
8191b3e38ee4Smrg	      *" $libdir "*) ;;
8192a73423d7Smrg	      *) func_append finalize_rpath " $libdir" ;;
8193b3e38ee4Smrg	      esac
8194b3e38ee4Smrg	      ;;
8195b3e38ee4Smrg	    esac
8196b3e38ee4Smrg	  fi
8197b3e38ee4Smrg
8198b3e38ee4Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
8199b3e38ee4Smrg	    # figure out the soname
8200b3e38ee4Smrg	    set dummy $library_names
8201b3e38ee4Smrg	    shift
82024a8d91dcSmrg	    realname=$1
8203b3e38ee4Smrg	    shift
8204b3e38ee4Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
8205b3e38ee4Smrg	    # use dlname if we got it. it's perfectly good, no?
8206b3e38ee4Smrg	    if test -n "$dlname"; then
82074a8d91dcSmrg	      soname=$dlname
8208b3e38ee4Smrg	    elif test -n "$soname_spec"; then
8209b3e38ee4Smrg	      # bleh windows
8210b3e38ee4Smrg	      case $host in
82114a8d91dcSmrg	      *cygwin* | mingw* | *cegcc* | *os2*)
8212b3e38ee4Smrg	        func_arith $current - $age
8213b3e38ee4Smrg		major=$func_arith_result
82144a8d91dcSmrg		versuffix=-$major
8215b3e38ee4Smrg		;;
8216b3e38ee4Smrg	      esac
8217b3e38ee4Smrg	      eval soname=\"$soname_spec\"
8218b3e38ee4Smrg	    else
82194a8d91dcSmrg	      soname=$realname
8220b3e38ee4Smrg	    fi
8221b3e38ee4Smrg
8222b3e38ee4Smrg	    # Make a new name for the extract_expsyms_cmds to use
82234a8d91dcSmrg	    soroot=$soname
8224b3e38ee4Smrg	    func_basename "$soroot"
82254a8d91dcSmrg	    soname=$func_basename_result
8226b3e38ee4Smrg	    func_stripname 'lib' '.dll' "$soname"
8227b3e38ee4Smrg	    newlib=libimp-$func_stripname_result.a
8228b3e38ee4Smrg
8229b3e38ee4Smrg	    # If the library has no export list, then create one now
8230b3e38ee4Smrg	    if test -f "$output_objdir/$soname-def"; then :
8231b3e38ee4Smrg	    else
82324a8d91dcSmrg	      func_verbose "extracting exported symbol list from '$soname'"
8233b3e38ee4Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
8234b3e38ee4Smrg	    fi
8235b3e38ee4Smrg
8236b3e38ee4Smrg	    # Create $newlib
8237b3e38ee4Smrg	    if test -f "$output_objdir/$newlib"; then :; else
82384a8d91dcSmrg	      func_verbose "generating import library for '$soname'"
8239b3e38ee4Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
8240b3e38ee4Smrg	    fi
8241b3e38ee4Smrg	    # make sure the library variables are pointing to the new library
8242b3e38ee4Smrg	    dir=$output_objdir
8243b3e38ee4Smrg	    linklib=$newlib
8244b3e38ee4Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
8245b3e38ee4Smrg
82464a8d91dcSmrg	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
8247b3e38ee4Smrg	    add_shlibpath=
8248b3e38ee4Smrg	    add_dir=
8249b3e38ee4Smrg	    add=
8250b3e38ee4Smrg	    lib_linked=yes
8251b3e38ee4Smrg	    case $hardcode_action in
8252b3e38ee4Smrg	    immediate | unsupported)
82534a8d91dcSmrg	      if test no = "$hardcode_direct"; then
82544a8d91dcSmrg		add=$dir/$linklib
8255b3e38ee4Smrg		case $host in
82564a8d91dcSmrg		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
82574a8d91dcSmrg		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
8258b3e38ee4Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
82594a8d91dcSmrg		    *-*-unixware7*) add_dir=-L$dir ;;
8260b3e38ee4Smrg		  *-*-darwin* )
82614a8d91dcSmrg		    # if the lib is a (non-dlopened) module then we cannot
8262b3e38ee4Smrg		    # link against it, someone is ignoring the earlier warnings
8263b3e38ee4Smrg		    if /usr/bin/file -L $add 2> /dev/null |
82644a8d91dcSmrg			 $GREP ": [^:]* bundle" >/dev/null; then
8265b3e38ee4Smrg		      if test "X$dlopenmodule" != "X$lib"; then
8266b3e38ee4Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
82674a8d91dcSmrg			if test -z "$old_library"; then
8268a73423d7Smrg			  echo
8269a73423d7Smrg			  echo "*** And there doesn't seem to be a static archive available"
8270a73423d7Smrg			  echo "*** The link will probably fail, sorry"
8271b3e38ee4Smrg			else
82724a8d91dcSmrg			  add=$dir/$old_library
8273b3e38ee4Smrg			fi
8274b3e38ee4Smrg		      elif test -n "$old_library"; then
82754a8d91dcSmrg			add=$dir/$old_library
8276b3e38ee4Smrg		      fi
8277b3e38ee4Smrg		    fi
8278b3e38ee4Smrg		esac
82794a8d91dcSmrg	      elif test no = "$hardcode_minus_L"; then
8280b3e38ee4Smrg		case $host in
82814a8d91dcSmrg		*-*-sunos*) add_shlibpath=$dir ;;
8282b3e38ee4Smrg		esac
82834a8d91dcSmrg		add_dir=-L$dir
82844a8d91dcSmrg		add=-l$name
82854a8d91dcSmrg	      elif test no = "$hardcode_shlibpath_var"; then
82864a8d91dcSmrg		add_shlibpath=$dir
82874a8d91dcSmrg		add=-l$name
8288b3e38ee4Smrg	      else
8289b3e38ee4Smrg		lib_linked=no
8290b3e38ee4Smrg	      fi
8291b3e38ee4Smrg	      ;;
8292b3e38ee4Smrg	    relink)
82934a8d91dcSmrg	      if test yes = "$hardcode_direct" &&
82944a8d91dcSmrg	         test no = "$hardcode_direct_absolute"; then
82954a8d91dcSmrg		add=$dir/$linklib
82964a8d91dcSmrg	      elif test yes = "$hardcode_minus_L"; then
82974a8d91dcSmrg		add_dir=-L$absdir
8298b3e38ee4Smrg		# Try looking first in the location we're being installed to.
8299b3e38ee4Smrg		if test -n "$inst_prefix_dir"; then
8300b3e38ee4Smrg		  case $libdir in
8301b3e38ee4Smrg		    [\\/]*)
8302a73423d7Smrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
8303b3e38ee4Smrg		      ;;
8304b3e38ee4Smrg		  esac
8305b3e38ee4Smrg		fi
83064a8d91dcSmrg		add=-l$name
83074a8d91dcSmrg	      elif test yes = "$hardcode_shlibpath_var"; then
83084a8d91dcSmrg		add_shlibpath=$dir
83094a8d91dcSmrg		add=-l$name
8310b3e38ee4Smrg	      else
8311b3e38ee4Smrg		lib_linked=no
8312b3e38ee4Smrg	      fi
8313b3e38ee4Smrg	      ;;
8314b3e38ee4Smrg	    *) lib_linked=no ;;
8315b3e38ee4Smrg	    esac
8316b3e38ee4Smrg
83174a8d91dcSmrg	    if test yes != "$lib_linked"; then
8318b3e38ee4Smrg	      func_fatal_configuration "unsupported hardcode properties"
8319b3e38ee4Smrg	    fi
8320b3e38ee4Smrg
8321b3e38ee4Smrg	    if test -n "$add_shlibpath"; then
8322b3e38ee4Smrg	      case :$compile_shlibpath: in
8323b3e38ee4Smrg	      *":$add_shlibpath:"*) ;;
8324a73423d7Smrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
8325b3e38ee4Smrg	      esac
8326b3e38ee4Smrg	    fi
83274a8d91dcSmrg	    if test prog = "$linkmode"; then
8328b3e38ee4Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
8329b3e38ee4Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
8330b3e38ee4Smrg	    else
8331b3e38ee4Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
8332b3e38ee4Smrg	      test -n "$add" && deplibs="$add $deplibs"
83334a8d91dcSmrg	      if test yes != "$hardcode_direct" &&
83344a8d91dcSmrg		 test yes != "$hardcode_minus_L" &&
83354a8d91dcSmrg		 test yes = "$hardcode_shlibpath_var"; then
8336b3e38ee4Smrg		case :$finalize_shlibpath: in
8337b3e38ee4Smrg		*":$libdir:"*) ;;
8338a73423d7Smrg		*) func_append finalize_shlibpath "$libdir:" ;;
8339b3e38ee4Smrg		esac
8340b3e38ee4Smrg	      fi
8341b3e38ee4Smrg	    fi
8342b3e38ee4Smrg	  fi
8343b3e38ee4Smrg
83444a8d91dcSmrg	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
8345b3e38ee4Smrg	    add_shlibpath=
8346b3e38ee4Smrg	    add_dir=
8347b3e38ee4Smrg	    add=
8348b3e38ee4Smrg	    # Finalize command for both is simple: just hardcode it.
83494a8d91dcSmrg	    if test yes = "$hardcode_direct" &&
83504a8d91dcSmrg	       test no = "$hardcode_direct_absolute"; then
83514a8d91dcSmrg	      add=$libdir/$linklib
83524a8d91dcSmrg	    elif test yes = "$hardcode_minus_L"; then
83534a8d91dcSmrg	      add_dir=-L$libdir
83544a8d91dcSmrg	      add=-l$name
83554a8d91dcSmrg	    elif test yes = "$hardcode_shlibpath_var"; then
8356b3e38ee4Smrg	      case :$finalize_shlibpath: in
8357b3e38ee4Smrg	      *":$libdir:"*) ;;
8358a73423d7Smrg	      *) func_append finalize_shlibpath "$libdir:" ;;
8359b3e38ee4Smrg	      esac
83604a8d91dcSmrg	      add=-l$name
83614a8d91dcSmrg	    elif test yes = "$hardcode_automatic"; then
8362b3e38ee4Smrg	      if test -n "$inst_prefix_dir" &&
83634a8d91dcSmrg		 test -f "$inst_prefix_dir$libdir/$linklib"; then
83644a8d91dcSmrg		add=$inst_prefix_dir$libdir/$linklib
8365b3e38ee4Smrg	      else
83664a8d91dcSmrg		add=$libdir/$linklib
8367b3e38ee4Smrg	      fi
8368b3e38ee4Smrg	    else
8369b3e38ee4Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
83704a8d91dcSmrg	      add_dir=-L$libdir
8371b3e38ee4Smrg	      # Try looking first in the location we're being installed to.
8372b3e38ee4Smrg	      if test -n "$inst_prefix_dir"; then
8373b3e38ee4Smrg		case $libdir in
8374b3e38ee4Smrg		  [\\/]*)
8375a73423d7Smrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
8376b3e38ee4Smrg		    ;;
8377b3e38ee4Smrg		esac
8378b3e38ee4Smrg	      fi
83794a8d91dcSmrg	      add=-l$name
8380b3e38ee4Smrg	    fi
8381b3e38ee4Smrg
83824a8d91dcSmrg	    if test prog = "$linkmode"; then
8383b3e38ee4Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
8384b3e38ee4Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
8385b3e38ee4Smrg	    else
8386b3e38ee4Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
8387b3e38ee4Smrg	      test -n "$add" && deplibs="$add $deplibs"
8388b3e38ee4Smrg	    fi
8389b3e38ee4Smrg	  fi
83904a8d91dcSmrg	elif test prog = "$linkmode"; then
8391b3e38ee4Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
8392b3e38ee4Smrg	  # is not unsupported.  This is valid on all known static and
8393b3e38ee4Smrg	  # shared platforms.
83944a8d91dcSmrg	  if test unsupported != "$hardcode_direct"; then
83954a8d91dcSmrg	    test -n "$old_library" && linklib=$old_library
8396b3e38ee4Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
8397b3e38ee4Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
8398b3e38ee4Smrg	  else
8399b3e38ee4Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
8400b3e38ee4Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
8401b3e38ee4Smrg	  fi
84024a8d91dcSmrg	elif test yes = "$build_libtool_libs"; then
8403b3e38ee4Smrg	  # Not a shared library
84044a8d91dcSmrg	  if test pass_all != "$deplibs_check_method"; then
8405b3e38ee4Smrg	    # We're trying link a shared library against a static one
8406b3e38ee4Smrg	    # but the system doesn't support it.
8407b3e38ee4Smrg
8408b3e38ee4Smrg	    # Just print a warning and add the library to dependency_libs so
8409b3e38ee4Smrg	    # that the program can be linked against the static library.
8410a73423d7Smrg	    echo
84114a8d91dcSmrg	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
8412a73423d7Smrg	    echo "*** I have the capability to make that library automatically link in when"
8413a73423d7Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
8414a73423d7Smrg	    echo "*** shared version of the library, which you do not appear to have."
84154a8d91dcSmrg	    if test yes = "$module"; then
8416a73423d7Smrg	      echo "*** But as you try to build a module library, libtool will still create "
8417a73423d7Smrg	      echo "*** a static module, that should work as long as the dlopening application"
8418a73423d7Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
8419b3e38ee4Smrg	      if test -z "$global_symbol_pipe"; then
8420a73423d7Smrg		echo
8421a73423d7Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
84224a8d91dcSmrg		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
8423a73423d7Smrg		echo "*** not find such a program.  So, this module is probably useless."
84244a8d91dcSmrg		echo "*** 'nm' from GNU binutils and a full rebuild may help."
8425b3e38ee4Smrg	      fi
84264a8d91dcSmrg	      if test no = "$build_old_libs"; then
8427b3e38ee4Smrg		build_libtool_libs=module
8428b3e38ee4Smrg		build_old_libs=yes
8429b3e38ee4Smrg	      else
8430b3e38ee4Smrg		build_libtool_libs=no
8431b3e38ee4Smrg	      fi
8432b3e38ee4Smrg	    fi
8433b3e38ee4Smrg	  else
8434b3e38ee4Smrg	    deplibs="$dir/$old_library $deplibs"
8435b3e38ee4Smrg	    link_static=yes
8436b3e38ee4Smrg	  fi
8437b3e38ee4Smrg	fi # link shared/static library?
8438b3e38ee4Smrg
84394a8d91dcSmrg	if test lib = "$linkmode"; then
8440b3e38ee4Smrg	  if test -n "$dependency_libs" &&
84414a8d91dcSmrg	     { test yes != "$hardcode_into_libs" ||
84424a8d91dcSmrg	       test yes = "$build_old_libs" ||
84434a8d91dcSmrg	       test yes = "$link_static"; }; then
8444b3e38ee4Smrg	    # Extract -R from dependency_libs
8445b3e38ee4Smrg	    temp_deplibs=
8446b3e38ee4Smrg	    for libdir in $dependency_libs; do
8447b3e38ee4Smrg	      case $libdir in
8448b3e38ee4Smrg	      -R*) func_stripname '-R' '' "$libdir"
8449b3e38ee4Smrg	           temp_xrpath=$func_stripname_result
8450b3e38ee4Smrg		   case " $xrpath " in
8451b3e38ee4Smrg		   *" $temp_xrpath "*) ;;
8452a73423d7Smrg		   *) func_append xrpath " $temp_xrpath";;
8453b3e38ee4Smrg		   esac;;
8454a73423d7Smrg	      *) func_append temp_deplibs " $libdir";;
8455b3e38ee4Smrg	      esac
8456b3e38ee4Smrg	    done
84574a8d91dcSmrg	    dependency_libs=$temp_deplibs
8458b3e38ee4Smrg	  fi
8459b3e38ee4Smrg
8460a73423d7Smrg	  func_append newlib_search_path " $absdir"
8461b3e38ee4Smrg	  # Link against this library
84624a8d91dcSmrg	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
8463b3e38ee4Smrg	  # ... and its dependency_libs
8464b3e38ee4Smrg	  tmp_libs=
8465b3e38ee4Smrg	  for deplib in $dependency_libs; do
8466b3e38ee4Smrg	    newdependency_libs="$deplib $newdependency_libs"
8467a73423d7Smrg	    case $deplib in
8468a73423d7Smrg              -L*) func_stripname '-L' '' "$deplib"
8469a73423d7Smrg                   func_resolve_sysroot "$func_stripname_result";;
8470a73423d7Smrg              *) func_resolve_sysroot "$deplib" ;;
8471a73423d7Smrg            esac
84724a8d91dcSmrg	    if $opt_preserve_dup_deps; then
8473b3e38ee4Smrg	      case "$tmp_libs " in
8474a73423d7Smrg	      *" $func_resolve_sysroot_result "*)
8475a73423d7Smrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
8476b3e38ee4Smrg	      esac
8477b3e38ee4Smrg	    fi
8478a73423d7Smrg	    func_append tmp_libs " $func_resolve_sysroot_result"
8479b3e38ee4Smrg	  done
8480b3e38ee4Smrg
84814a8d91dcSmrg	  if test no != "$link_all_deplibs"; then
8482b3e38ee4Smrg	    # Add the search paths of all dependency libraries
8483b3e38ee4Smrg	    for deplib in $dependency_libs; do
8484a73423d7Smrg	      path=
8485b3e38ee4Smrg	      case $deplib in
84864a8d91dcSmrg	      -L*) path=$deplib ;;
8487b3e38ee4Smrg	      *.la)
8488a73423d7Smrg	        func_resolve_sysroot "$deplib"
8489a73423d7Smrg	        deplib=$func_resolve_sysroot_result
8490b3e38ee4Smrg	        func_dirname "$deplib" "" "."
8491a73423d7Smrg		dir=$func_dirname_result
8492b3e38ee4Smrg		# We need an absolute path.
8493b3e38ee4Smrg		case $dir in
84944a8d91dcSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
8495b3e38ee4Smrg		*)
8496b3e38ee4Smrg		  absdir=`cd "$dir" && pwd`
8497b3e38ee4Smrg		  if test -z "$absdir"; then
84984a8d91dcSmrg		    func_warning "cannot determine absolute directory name of '$dir'"
84994a8d91dcSmrg		    absdir=$dir
8500b3e38ee4Smrg		  fi
8501b3e38ee4Smrg		  ;;
8502b3e38ee4Smrg		esac
8503b3e38ee4Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
8504b3e38ee4Smrg		case $host in
8505b3e38ee4Smrg		*-*-darwin*)
8506b3e38ee4Smrg		  depdepl=
85074a8d91dcSmrg		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
85084a8d91dcSmrg		  if test -n "$deplibrary_names"; then
85094a8d91dcSmrg		    for tmp in $deplibrary_names; do
8510b3e38ee4Smrg		      depdepl=$tmp
8511b3e38ee4Smrg		    done
85124a8d91dcSmrg		    if test -f "$absdir/$objdir/$depdepl"; then
85134a8d91dcSmrg		      depdepl=$absdir/$objdir/$depdepl
85144a8d91dcSmrg		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
8515b3e38ee4Smrg                      if test -z "$darwin_install_name"; then
85164a8d91dcSmrg                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
8517b3e38ee4Smrg                      fi
85184a8d91dcSmrg		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
85194a8d91dcSmrg		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
8520b3e38ee4Smrg		      path=
8521b3e38ee4Smrg		    fi
8522b3e38ee4Smrg		  fi
8523b3e38ee4Smrg		  ;;
8524b3e38ee4Smrg		*)
85254a8d91dcSmrg		  path=-L$absdir/$objdir
8526b3e38ee4Smrg		  ;;
8527b3e38ee4Smrg		esac
8528b3e38ee4Smrg		else
85294a8d91dcSmrg		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8530b3e38ee4Smrg		  test -z "$libdir" && \
85314a8d91dcSmrg		    func_fatal_error "'$deplib' is not a valid libtool archive"
8532b3e38ee4Smrg		  test "$absdir" != "$libdir" && \
85334a8d91dcSmrg		    func_warning "'$deplib' seems to be moved"
8534b3e38ee4Smrg
85354a8d91dcSmrg		  path=-L$absdir
8536b3e38ee4Smrg		fi
8537b3e38ee4Smrg		;;
8538b3e38ee4Smrg	      esac
8539b3e38ee4Smrg	      case " $deplibs " in
8540b3e38ee4Smrg	      *" $path "*) ;;
8541b3e38ee4Smrg	      *) deplibs="$path $deplibs" ;;
8542b3e38ee4Smrg	      esac
8543b3e38ee4Smrg	    done
8544b3e38ee4Smrg	  fi # link_all_deplibs != no
8545b3e38ee4Smrg	fi # linkmode = lib
8546b3e38ee4Smrg      done # for deplib in $libs
85474a8d91dcSmrg      if test link = "$pass"; then
85484a8d91dcSmrg	if test prog = "$linkmode"; then
8549b3e38ee4Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
8550b3e38ee4Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
8551b3e38ee4Smrg	else
8552a73423d7Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8553b3e38ee4Smrg	fi
8554b3e38ee4Smrg      fi
85554a8d91dcSmrg      dependency_libs=$newdependency_libs
85564a8d91dcSmrg      if test dlpreopen = "$pass"; then
8557b3e38ee4Smrg	# Link the dlpreopened libraries before other libraries
8558b3e38ee4Smrg	for deplib in $save_deplibs; do
8559b3e38ee4Smrg	  deplibs="$deplib $deplibs"
8560b3e38ee4Smrg	done
8561b3e38ee4Smrg      fi
85624a8d91dcSmrg      if test dlopen != "$pass"; then
85634a8d91dcSmrg	test conv = "$pass" || {
8564b3e38ee4Smrg	  # Make sure lib_search_path contains only unique directories.
8565b3e38ee4Smrg	  lib_search_path=
8566b3e38ee4Smrg	  for dir in $newlib_search_path; do
8567b3e38ee4Smrg	    case "$lib_search_path " in
8568b3e38ee4Smrg	    *" $dir "*) ;;
8569a73423d7Smrg	    *) func_append lib_search_path " $dir" ;;
8570b3e38ee4Smrg	    esac
8571b3e38ee4Smrg	  done
8572b3e38ee4Smrg	  newlib_search_path=
85734a8d91dcSmrg	}
8574b3e38ee4Smrg
85754a8d91dcSmrg	if test prog,link = "$linkmode,$pass"; then
8576b3e38ee4Smrg	  vars="compile_deplibs finalize_deplibs"
85774a8d91dcSmrg	else
85784a8d91dcSmrg	  vars=deplibs
8579b3e38ee4Smrg	fi
8580b3e38ee4Smrg	for var in $vars dependency_libs; do
8581b3e38ee4Smrg	  # Add libraries to $var in reverse order
8582b3e38ee4Smrg	  eval tmp_libs=\"\$$var\"
8583b3e38ee4Smrg	  new_libs=
8584b3e38ee4Smrg	  for deplib in $tmp_libs; do
8585b3e38ee4Smrg	    # FIXME: Pedantically, this is the right thing to do, so
8586b3e38ee4Smrg	    #        that some nasty dependency loop isn't accidentally
8587b3e38ee4Smrg	    #        broken:
8588b3e38ee4Smrg	    #new_libs="$deplib $new_libs"
8589b3e38ee4Smrg	    # Pragmatically, this seems to cause very few problems in
8590b3e38ee4Smrg	    # practice:
8591b3e38ee4Smrg	    case $deplib in
8592b3e38ee4Smrg	    -L*) new_libs="$deplib $new_libs" ;;
8593b3e38ee4Smrg	    -R*) ;;
8594b3e38ee4Smrg	    *)
8595b3e38ee4Smrg	      # And here is the reason: when a library appears more
8596b3e38ee4Smrg	      # than once as an explicit dependence of a library, or
8597b3e38ee4Smrg	      # is implicitly linked in more than once by the
8598b3e38ee4Smrg	      # compiler, it is considered special, and multiple
8599b3e38ee4Smrg	      # occurrences thereof are not removed.  Compare this
8600b3e38ee4Smrg	      # with having the same library being listed as a
8601b3e38ee4Smrg	      # dependency of multiple other libraries: in this case,
8602b3e38ee4Smrg	      # we know (pedantically, we assume) the library does not
8603b3e38ee4Smrg	      # need to be listed more than once, so we keep only the
8604b3e38ee4Smrg	      # last copy.  This is not always right, but it is rare
8605b3e38ee4Smrg	      # enough that we require users that really mean to play
8606b3e38ee4Smrg	      # such unportable linking tricks to link the library
8607b3e38ee4Smrg	      # using -Wl,-lname, so that libtool does not consider it
8608b3e38ee4Smrg	      # for duplicate removal.
8609b3e38ee4Smrg	      case " $specialdeplibs " in
8610b3e38ee4Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
8611b3e38ee4Smrg	      *)
8612b3e38ee4Smrg		case " $new_libs " in
8613b3e38ee4Smrg		*" $deplib "*) ;;
8614b3e38ee4Smrg		*) new_libs="$deplib $new_libs" ;;
8615b3e38ee4Smrg		esac
8616b3e38ee4Smrg		;;
8617b3e38ee4Smrg	      esac
8618b3e38ee4Smrg	      ;;
8619b3e38ee4Smrg	    esac
8620b3e38ee4Smrg	  done
8621b3e38ee4Smrg	  tmp_libs=
8622b3e38ee4Smrg	  for deplib in $new_libs; do
8623b3e38ee4Smrg	    case $deplib in
8624b3e38ee4Smrg	    -L*)
8625b3e38ee4Smrg	      case " $tmp_libs " in
8626b3e38ee4Smrg	      *" $deplib "*) ;;
8627a73423d7Smrg	      *) func_append tmp_libs " $deplib" ;;
8628b3e38ee4Smrg	      esac
8629b3e38ee4Smrg	      ;;
8630a73423d7Smrg	    *) func_append tmp_libs " $deplib" ;;
8631b3e38ee4Smrg	    esac
8632b3e38ee4Smrg	  done
8633b3e38ee4Smrg	  eval $var=\"$tmp_libs\"
8634b3e38ee4Smrg	done # for var
8635b3e38ee4Smrg      fi
86364a8d91dcSmrg
86374a8d91dcSmrg      # Add Sun CC postdeps if required:
86384a8d91dcSmrg      test CXX = "$tagname" && {
86394a8d91dcSmrg        case $host_os in
86404a8d91dcSmrg        linux*)
86414a8d91dcSmrg          case `$CC -V 2>&1 | sed 5q` in
86424a8d91dcSmrg          *Sun\ C*) # Sun C++ 5.9
86434a8d91dcSmrg            func_suncc_cstd_abi
86444a8d91dcSmrg
86454a8d91dcSmrg            if test no != "$suncc_use_cstd_abi"; then
86464a8d91dcSmrg              func_append postdeps ' -library=Cstd -library=Crun'
86474a8d91dcSmrg            fi
86484a8d91dcSmrg            ;;
86494a8d91dcSmrg          esac
86504a8d91dcSmrg          ;;
86514a8d91dcSmrg
86524a8d91dcSmrg        solaris*)
86534a8d91dcSmrg          func_cc_basename "$CC"
86544a8d91dcSmrg          case $func_cc_basename_result in
86554a8d91dcSmrg          CC* | sunCC*)
86564a8d91dcSmrg            func_suncc_cstd_abi
86574a8d91dcSmrg
86584a8d91dcSmrg            if test no != "$suncc_use_cstd_abi"; then
86594a8d91dcSmrg              func_append postdeps ' -library=Cstd -library=Crun'
86604a8d91dcSmrg            fi
86614a8d91dcSmrg            ;;
86624a8d91dcSmrg          esac
86634a8d91dcSmrg          ;;
86644a8d91dcSmrg        esac
86654a8d91dcSmrg      }
86664a8d91dcSmrg
8667b3e38ee4Smrg      # Last step: remove runtime libs from dependency_libs
8668b3e38ee4Smrg      # (they stay in deplibs)
8669b3e38ee4Smrg      tmp_libs=
86704a8d91dcSmrg      for i in $dependency_libs; do
8671b3e38ee4Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
8672b3e38ee4Smrg	*" $i "*)
86734a8d91dcSmrg	  i=
8674b3e38ee4Smrg	  ;;
8675b3e38ee4Smrg	esac
86764a8d91dcSmrg	if test -n "$i"; then
8677a73423d7Smrg	  func_append tmp_libs " $i"
8678b3e38ee4Smrg	fi
8679b3e38ee4Smrg      done
8680b3e38ee4Smrg      dependency_libs=$tmp_libs
8681b3e38ee4Smrg    done # for pass
86824a8d91dcSmrg    if test prog = "$linkmode"; then
86834a8d91dcSmrg      dlfiles=$newdlfiles
8684b3e38ee4Smrg    fi
86854a8d91dcSmrg    if test prog = "$linkmode" || test lib = "$linkmode"; then
86864a8d91dcSmrg      dlprefiles=$newdlprefiles
8687b3e38ee4Smrg    fi
8688b3e38ee4Smrg
8689b3e38ee4Smrg    case $linkmode in
8690b3e38ee4Smrg    oldlib)
86914a8d91dcSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
86924a8d91dcSmrg	func_warning "'-dlopen' is ignored for archives"
8693b3e38ee4Smrg      fi
8694b3e38ee4Smrg
8695b3e38ee4Smrg      case " $deplibs" in
8696b3e38ee4Smrg      *\ -l* | *\ -L*)
86974a8d91dcSmrg	func_warning "'-l' and '-L' are ignored for archives" ;;
8698b3e38ee4Smrg      esac
8699b3e38ee4Smrg
8700b3e38ee4Smrg      test -n "$rpath" && \
87014a8d91dcSmrg	func_warning "'-rpath' is ignored for archives"
8702b3e38ee4Smrg
8703b3e38ee4Smrg      test -n "$xrpath" && \
87044a8d91dcSmrg	func_warning "'-R' is ignored for archives"
8705b3e38ee4Smrg
8706b3e38ee4Smrg      test -n "$vinfo" && \
87074a8d91dcSmrg	func_warning "'-version-info/-version-number' is ignored for archives"
8708b3e38ee4Smrg
8709b3e38ee4Smrg      test -n "$release" && \
87104a8d91dcSmrg	func_warning "'-release' is ignored for archives"
8711b3e38ee4Smrg
8712b3e38ee4Smrg      test -n "$export_symbols$export_symbols_regex" && \
87134a8d91dcSmrg	func_warning "'-export-symbols' is ignored for archives"
8714b3e38ee4Smrg
8715b3e38ee4Smrg      # Now set the variables for building old libraries.
8716b3e38ee4Smrg      build_libtool_libs=no
87174a8d91dcSmrg      oldlibs=$output
8718a73423d7Smrg      func_append objs "$old_deplibs"
8719b3e38ee4Smrg      ;;
8720b3e38ee4Smrg
8721b3e38ee4Smrg    lib)
87224a8d91dcSmrg      # Make sure we only generate libraries of the form 'libNAME.la'.
8723b3e38ee4Smrg      case $outputname in
8724b3e38ee4Smrg      lib*)
8725b3e38ee4Smrg	func_stripname 'lib' '.la' "$outputname"
8726b3e38ee4Smrg	name=$func_stripname_result
8727b3e38ee4Smrg	eval shared_ext=\"$shrext_cmds\"
8728b3e38ee4Smrg	eval libname=\"$libname_spec\"
8729b3e38ee4Smrg	;;
8730b3e38ee4Smrg      *)
87314a8d91dcSmrg	test no = "$module" \
87324a8d91dcSmrg	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
8733b3e38ee4Smrg
87344a8d91dcSmrg	if test no != "$need_lib_prefix"; then
8735b3e38ee4Smrg	  # Add the "lib" prefix for modules if required
8736b3e38ee4Smrg	  func_stripname '' '.la' "$outputname"
8737b3e38ee4Smrg	  name=$func_stripname_result
8738b3e38ee4Smrg	  eval shared_ext=\"$shrext_cmds\"
8739b3e38ee4Smrg	  eval libname=\"$libname_spec\"
8740b3e38ee4Smrg	else
8741b3e38ee4Smrg	  func_stripname '' '.la' "$outputname"
8742b3e38ee4Smrg	  libname=$func_stripname_result
8743b3e38ee4Smrg	fi
8744b3e38ee4Smrg	;;
8745b3e38ee4Smrg      esac
8746b3e38ee4Smrg
8747b3e38ee4Smrg      if test -n "$objs"; then
87484a8d91dcSmrg	if test pass_all != "$deplibs_check_method"; then
87494a8d91dcSmrg	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
8750b3e38ee4Smrg	else
8751a73423d7Smrg	  echo
8752b3e38ee4Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
8753b3e38ee4Smrg	  $ECHO "*** objects $objs is not portable!"
8754a73423d7Smrg	  func_append libobjs " $objs"
8755b3e38ee4Smrg	fi
8756b3e38ee4Smrg      fi
8757b3e38ee4Smrg
87584a8d91dcSmrg      test no = "$dlself" \
87594a8d91dcSmrg	|| func_warning "'-dlopen self' is ignored for libtool libraries"
8760b3e38ee4Smrg
8761b3e38ee4Smrg      set dummy $rpath
8762b3e38ee4Smrg      shift
87634a8d91dcSmrg      test 1 -lt "$#" \
87644a8d91dcSmrg	&& func_warning "ignoring multiple '-rpath's for a libtool library"
8765b3e38ee4Smrg
87664a8d91dcSmrg      install_libdir=$1
8767b3e38ee4Smrg
8768b3e38ee4Smrg      oldlibs=
8769b3e38ee4Smrg      if test -z "$rpath"; then
87704a8d91dcSmrg	if test yes = "$build_libtool_libs"; then
8771b3e38ee4Smrg	  # Building a libtool convenience library.
87724a8d91dcSmrg	  # Some compilers have problems with a '.al' extension so
8773b3e38ee4Smrg	  # convenience libraries should have the same extension an
8774b3e38ee4Smrg	  # archive normally would.
8775b3e38ee4Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
8776b3e38ee4Smrg	  build_libtool_libs=convenience
8777b3e38ee4Smrg	  build_old_libs=yes
8778b3e38ee4Smrg	fi
8779b3e38ee4Smrg
8780b3e38ee4Smrg	test -n "$vinfo" && \
87814a8d91dcSmrg	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
8782b3e38ee4Smrg
8783b3e38ee4Smrg	test -n "$release" && \
87844a8d91dcSmrg	  func_warning "'-release' is ignored for convenience libraries"
8785b3e38ee4Smrg      else
8786b3e38ee4Smrg
8787b3e38ee4Smrg	# Parse the version information argument.
87884a8d91dcSmrg	save_ifs=$IFS; IFS=:
8789b3e38ee4Smrg	set dummy $vinfo 0 0 0
8790b3e38ee4Smrg	shift
87914a8d91dcSmrg	IFS=$save_ifs
8792b3e38ee4Smrg
8793b3e38ee4Smrg	test -n "$7" && \
87944a8d91dcSmrg	  func_fatal_help "too many parameters to '-version-info'"
8795b3e38ee4Smrg
8796b3e38ee4Smrg	# convert absolute version numbers to libtool ages
8797b3e38ee4Smrg	# this retains compatibility with .la files and attempts
8798b3e38ee4Smrg	# to make the code below a bit more comprehensible
8799b3e38ee4Smrg
8800b3e38ee4Smrg	case $vinfo_number in
8801b3e38ee4Smrg	yes)
88024a8d91dcSmrg	  number_major=$1
88034a8d91dcSmrg	  number_minor=$2
88044a8d91dcSmrg	  number_revision=$3
8805b3e38ee4Smrg	  #
8806b3e38ee4Smrg	  # There are really only two kinds -- those that
8807b3e38ee4Smrg	  # use the current revision as the major version
8808b3e38ee4Smrg	  # and those that subtract age and use age as
8809b3e38ee4Smrg	  # a minor version.  But, then there is irix
88104a8d91dcSmrg	  # that has an extra 1 added just for fun
8811b3e38ee4Smrg	  #
8812b3e38ee4Smrg	  case $version_type in
8813a73423d7Smrg	  # correct linux to gnu/linux during the next big refactor
88144a8d91dcSmrg	  darwin|freebsd-elf|linux|osf|windows|none)
8815b3e38ee4Smrg	    func_arith $number_major + $number_minor
8816b3e38ee4Smrg	    current=$func_arith_result
88174a8d91dcSmrg	    age=$number_minor
88184a8d91dcSmrg	    revision=$number_revision
8819b3e38ee4Smrg	    ;;
88204a8d91dcSmrg	  freebsd-aout|qnx|sunos)
88214a8d91dcSmrg	    current=$number_major
88224a8d91dcSmrg	    revision=$number_minor
88234a8d91dcSmrg	    age=0
8824b3e38ee4Smrg	    ;;
8825b3e38ee4Smrg	  irix|nonstopux)
8826b3e38ee4Smrg	    func_arith $number_major + $number_minor
8827b3e38ee4Smrg	    current=$func_arith_result
88284a8d91dcSmrg	    age=$number_minor
88294a8d91dcSmrg	    revision=$number_minor
8830b3e38ee4Smrg	    lt_irix_increment=no
8831b3e38ee4Smrg	    ;;
88324a8d91dcSmrg	  *)
88334a8d91dcSmrg	    func_fatal_configuration "$modename: unknown library version type '$version_type'"
88344a8d91dcSmrg	    ;;
8835b3e38ee4Smrg	  esac
8836b3e38ee4Smrg	  ;;
8837b3e38ee4Smrg	no)
88384a8d91dcSmrg	  current=$1
88394a8d91dcSmrg	  revision=$2
88404a8d91dcSmrg	  age=$3
8841b3e38ee4Smrg	  ;;
8842b3e38ee4Smrg	esac
8843b3e38ee4Smrg
8844b3e38ee4Smrg	# Check that each of the things are valid numbers.
8845b3e38ee4Smrg	case $current in
8846b3e38ee4Smrg	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]) ;;
8847b3e38ee4Smrg	*)
88484a8d91dcSmrg	  func_error "CURRENT '$current' must be a nonnegative integer"
88494a8d91dcSmrg	  func_fatal_error "'$vinfo' is not valid version information"
8850b3e38ee4Smrg	  ;;
8851b3e38ee4Smrg	esac
8852b3e38ee4Smrg
8853b3e38ee4Smrg	case $revision in
8854b3e38ee4Smrg	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]) ;;
8855b3e38ee4Smrg	*)
88564a8d91dcSmrg	  func_error "REVISION '$revision' must be a nonnegative integer"
88574a8d91dcSmrg	  func_fatal_error "'$vinfo' is not valid version information"
8858b3e38ee4Smrg	  ;;
8859b3e38ee4Smrg	esac
8860b3e38ee4Smrg
8861b3e38ee4Smrg	case $age in
8862b3e38ee4Smrg	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]) ;;
8863b3e38ee4Smrg	*)
88644a8d91dcSmrg	  func_error "AGE '$age' must be a nonnegative integer"
88654a8d91dcSmrg	  func_fatal_error "'$vinfo' is not valid version information"
8866b3e38ee4Smrg	  ;;
8867b3e38ee4Smrg	esac
8868b3e38ee4Smrg
8869b3e38ee4Smrg	if test "$age" -gt "$current"; then
88704a8d91dcSmrg	  func_error "AGE '$age' is greater than the current interface number '$current'"
88714a8d91dcSmrg	  func_fatal_error "'$vinfo' is not valid version information"
8872b3e38ee4Smrg	fi
8873b3e38ee4Smrg
8874b3e38ee4Smrg	# Calculate the version variables.
8875b3e38ee4Smrg	major=
8876b3e38ee4Smrg	versuffix=
8877b3e38ee4Smrg	verstring=
8878b3e38ee4Smrg	case $version_type in
8879b3e38ee4Smrg	none) ;;
8880b3e38ee4Smrg
8881b3e38ee4Smrg	darwin)
8882b3e38ee4Smrg	  # Like Linux, but with the current version available in
8883b3e38ee4Smrg	  # verstring for coding it into the library header
8884b3e38ee4Smrg	  func_arith $current - $age
8885b3e38ee4Smrg	  major=.$func_arith_result
88864a8d91dcSmrg	  versuffix=$major.$age.$revision
8887b3e38ee4Smrg	  # Darwin ld doesn't like 0 for these options...
8888b3e38ee4Smrg	  func_arith $current + 1
8889b3e38ee4Smrg	  minor_current=$func_arith_result
88904a8d91dcSmrg	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8891b3e38ee4Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
88924a8d91dcSmrg          # On Darwin other compilers
88934a8d91dcSmrg          case $CC in
88944a8d91dcSmrg              nagfor*)
88954a8d91dcSmrg                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
88964a8d91dcSmrg                  ;;
88974a8d91dcSmrg              *)
88984a8d91dcSmrg                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
88994a8d91dcSmrg                  ;;
89004a8d91dcSmrg          esac
8901b3e38ee4Smrg	  ;;
8902b3e38ee4Smrg
8903b3e38ee4Smrg	freebsd-aout)
89044a8d91dcSmrg	  major=.$current
89054a8d91dcSmrg	  versuffix=.$current.$revision
8906b3e38ee4Smrg	  ;;
8907b3e38ee4Smrg
8908b3e38ee4Smrg	freebsd-elf)
89094a8d91dcSmrg	  func_arith $current - $age
89104a8d91dcSmrg	  major=.$func_arith_result
89114a8d91dcSmrg	  versuffix=$major.$age.$revision
8912b3e38ee4Smrg	  ;;
8913b3e38ee4Smrg
8914b3e38ee4Smrg	irix | nonstopux)
89154a8d91dcSmrg	  if test no = "$lt_irix_increment"; then
8916b3e38ee4Smrg	    func_arith $current - $age
8917b3e38ee4Smrg	  else
8918b3e38ee4Smrg	    func_arith $current - $age + 1
8919b3e38ee4Smrg	  fi
8920b3e38ee4Smrg	  major=$func_arith_result
8921b3e38ee4Smrg
8922b3e38ee4Smrg	  case $version_type in
8923b3e38ee4Smrg	    nonstopux) verstring_prefix=nonstopux ;;
8924b3e38ee4Smrg	    *)         verstring_prefix=sgi ;;
8925b3e38ee4Smrg	  esac
89264a8d91dcSmrg	  verstring=$verstring_prefix$major.$revision
8927b3e38ee4Smrg
8928b3e38ee4Smrg	  # Add in all the interfaces that we are compatible with.
8929b3e38ee4Smrg	  loop=$revision
89304a8d91dcSmrg	  while test 0 -ne "$loop"; do
8931b3e38ee4Smrg	    func_arith $revision - $loop
8932b3e38ee4Smrg	    iface=$func_arith_result
8933b3e38ee4Smrg	    func_arith $loop - 1
8934b3e38ee4Smrg	    loop=$func_arith_result
89354a8d91dcSmrg	    verstring=$verstring_prefix$major.$iface:$verstring
8936b3e38ee4Smrg	  done
8937b3e38ee4Smrg
89384a8d91dcSmrg	  # Before this point, $major must not contain '.'.
8939b3e38ee4Smrg	  major=.$major
89404a8d91dcSmrg	  versuffix=$major.$revision
8941b3e38ee4Smrg	  ;;
8942b3e38ee4Smrg
8943a73423d7Smrg	linux) # correct to gnu/linux during the next big refactor
8944b3e38ee4Smrg	  func_arith $current - $age
8945b3e38ee4Smrg	  major=.$func_arith_result
89464a8d91dcSmrg	  versuffix=$major.$age.$revision
8947b3e38ee4Smrg	  ;;
8948b3e38ee4Smrg
8949b3e38ee4Smrg	osf)
8950b3e38ee4Smrg	  func_arith $current - $age
8951b3e38ee4Smrg	  major=.$func_arith_result
89524a8d91dcSmrg	  versuffix=.$current.$age.$revision
89534a8d91dcSmrg	  verstring=$current.$age.$revision
8954b3e38ee4Smrg
8955b3e38ee4Smrg	  # Add in all the interfaces that we are compatible with.
8956b3e38ee4Smrg	  loop=$age
89574a8d91dcSmrg	  while test 0 -ne "$loop"; do
8958b3e38ee4Smrg	    func_arith $current - $loop
8959b3e38ee4Smrg	    iface=$func_arith_result
8960b3e38ee4Smrg	    func_arith $loop - 1
8961b3e38ee4Smrg	    loop=$func_arith_result
89624a8d91dcSmrg	    verstring=$verstring:$iface.0
8963b3e38ee4Smrg	  done
8964b3e38ee4Smrg
8965b3e38ee4Smrg	  # Make executables depend on our current version.
89664a8d91dcSmrg	  func_append verstring ":$current.0"
8967b3e38ee4Smrg	  ;;
8968b3e38ee4Smrg
8969b3e38ee4Smrg	qnx)
89704a8d91dcSmrg	  major=.$current
89714a8d91dcSmrg	  versuffix=.$current
89724a8d91dcSmrg	  ;;
89734a8d91dcSmrg
89744a8d91dcSmrg	sco)
89754a8d91dcSmrg	  major=.$current
89764a8d91dcSmrg	  versuffix=.$current
8977b3e38ee4Smrg	  ;;
8978b3e38ee4Smrg
8979b3e38ee4Smrg	sunos)
89804a8d91dcSmrg	  major=.$current
89814a8d91dcSmrg	  versuffix=.$current.$revision
8982b3e38ee4Smrg	  ;;
8983b3e38ee4Smrg
8984b3e38ee4Smrg	windows)
8985b3e38ee4Smrg	  # Use '-' rather than '.', since we only want one
89864a8d91dcSmrg	  # extension on DOS 8.3 file systems.
8987b3e38ee4Smrg	  func_arith $current - $age
8988b3e38ee4Smrg	  major=$func_arith_result
89894a8d91dcSmrg	  versuffix=-$major
8990b3e38ee4Smrg	  ;;
8991b3e38ee4Smrg
8992b3e38ee4Smrg	*)
89934a8d91dcSmrg	  func_fatal_configuration "unknown library version type '$version_type'"
8994b3e38ee4Smrg	  ;;
8995b3e38ee4Smrg	esac
8996b3e38ee4Smrg
8997b3e38ee4Smrg	# Clear the version info if we defaulted, and they specified a release.
8998b3e38ee4Smrg	if test -z "$vinfo" && test -n "$release"; then
8999b3e38ee4Smrg	  major=
9000b3e38ee4Smrg	  case $version_type in
9001b3e38ee4Smrg	  darwin)
9002b3e38ee4Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
9003b3e38ee4Smrg	    # problems, so we reset it completely
9004b3e38ee4Smrg	    verstring=
9005b3e38ee4Smrg	    ;;
9006b3e38ee4Smrg	  *)
90074a8d91dcSmrg	    verstring=0.0
9008b3e38ee4Smrg	    ;;
9009b3e38ee4Smrg	  esac
90104a8d91dcSmrg	  if test no = "$need_version"; then
9011b3e38ee4Smrg	    versuffix=
9012b3e38ee4Smrg	  else
90134a8d91dcSmrg	    versuffix=.0.0
9014b3e38ee4Smrg	  fi
9015b3e38ee4Smrg	fi
9016b3e38ee4Smrg
9017b3e38ee4Smrg	# Remove version info from name if versioning should be avoided
90184a8d91dcSmrg	if test yes,no = "$avoid_version,$need_version"; then
9019b3e38ee4Smrg	  major=
9020b3e38ee4Smrg	  versuffix=
90214a8d91dcSmrg	  verstring=
9022b3e38ee4Smrg	fi
9023b3e38ee4Smrg
9024b3e38ee4Smrg	# Check to see if the archive will have undefined symbols.
90254a8d91dcSmrg	if test yes = "$allow_undefined"; then
90264a8d91dcSmrg	  if test unsupported = "$allow_undefined_flag"; then
90274a8d91dcSmrg	    if test yes = "$build_old_libs"; then
90284a8d91dcSmrg	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
90294a8d91dcSmrg	      build_libtool_libs=no
90304a8d91dcSmrg	    else
90314a8d91dcSmrg	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
90324a8d91dcSmrg	    fi
9033b3e38ee4Smrg	  fi
9034b3e38ee4Smrg	else
9035b3e38ee4Smrg	  # Don't allow undefined symbols.
90364a8d91dcSmrg	  allow_undefined_flag=$no_undefined_flag
9037b3e38ee4Smrg	fi
9038b3e38ee4Smrg
9039b3e38ee4Smrg      fi
9040b3e38ee4Smrg
90414a8d91dcSmrg      func_generate_dlsyms "$libname" "$libname" :
9042a73423d7Smrg      func_append libobjs " $symfileobj"
90434a8d91dcSmrg      test " " = "$libobjs" && libobjs=
9044b3e38ee4Smrg
90454a8d91dcSmrg      if test relink != "$opt_mode"; then
9046b3e38ee4Smrg	# Remove our outputs, but don't remove object files since they
9047b3e38ee4Smrg	# may have been created when compiling PIC objects.
9048b3e38ee4Smrg	removelist=
9049b3e38ee4Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
9050b3e38ee4Smrg	for p in $tempremovelist; do
9051b3e38ee4Smrg	  case $p in
9052b3e38ee4Smrg	    *.$objext | *.gcno)
9053b3e38ee4Smrg	       ;;
90544a8d91dcSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
90554a8d91dcSmrg	       if test -n "$precious_files_regex"; then
9056b3e38ee4Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
9057b3e38ee4Smrg		 then
9058b3e38ee4Smrg		   continue
9059b3e38ee4Smrg		 fi
9060b3e38ee4Smrg	       fi
9061a73423d7Smrg	       func_append removelist " $p"
9062b3e38ee4Smrg	       ;;
9063b3e38ee4Smrg	    *) ;;
9064b3e38ee4Smrg	  esac
9065b3e38ee4Smrg	done
9066b3e38ee4Smrg	test -n "$removelist" && \
9067b3e38ee4Smrg	  func_show_eval "${RM}r \$removelist"
9068b3e38ee4Smrg      fi
9069b3e38ee4Smrg
9070b3e38ee4Smrg      # Now set the variables for building old libraries.
90714a8d91dcSmrg      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
9072a73423d7Smrg	func_append oldlibs " $output_objdir/$libname.$libext"
9073b3e38ee4Smrg
9074b3e38ee4Smrg	# Transform .lo files to .o files.
90754a8d91dcSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
9076b3e38ee4Smrg      fi
9077b3e38ee4Smrg
9078b3e38ee4Smrg      # Eliminate all temporary directories.
9079b3e38ee4Smrg      #for path in $notinst_path; do
9080a73423d7Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
9081a73423d7Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
9082a73423d7Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
9083b3e38ee4Smrg      #done
9084b3e38ee4Smrg
9085b3e38ee4Smrg      if test -n "$xrpath"; then
9086b3e38ee4Smrg	# If the user specified any rpath flags, then add them.
9087b3e38ee4Smrg	temp_xrpath=
9088b3e38ee4Smrg	for libdir in $xrpath; do
9089a73423d7Smrg	  func_replace_sysroot "$libdir"
9090a73423d7Smrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
9091b3e38ee4Smrg	  case "$finalize_rpath " in
9092b3e38ee4Smrg	  *" $libdir "*) ;;
9093a73423d7Smrg	  *) func_append finalize_rpath " $libdir" ;;
9094b3e38ee4Smrg	  esac
9095b3e38ee4Smrg	done
90964a8d91dcSmrg	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
9097b3e38ee4Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
9098b3e38ee4Smrg	fi
9099b3e38ee4Smrg      fi
9100b3e38ee4Smrg
9101b3e38ee4Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
91024a8d91dcSmrg      old_dlfiles=$dlfiles
9103b3e38ee4Smrg      dlfiles=
9104b3e38ee4Smrg      for lib in $old_dlfiles; do
9105b3e38ee4Smrg	case " $dlprefiles $dlfiles " in
9106b3e38ee4Smrg	*" $lib "*) ;;
9107a73423d7Smrg	*) func_append dlfiles " $lib" ;;
9108b3e38ee4Smrg	esac
9109b3e38ee4Smrg      done
9110b3e38ee4Smrg
9111b3e38ee4Smrg      # Make sure dlprefiles contains only unique files
91124a8d91dcSmrg      old_dlprefiles=$dlprefiles
9113b3e38ee4Smrg      dlprefiles=
9114b3e38ee4Smrg      for lib in $old_dlprefiles; do
9115b3e38ee4Smrg	case "$dlprefiles " in
9116b3e38ee4Smrg	*" $lib "*) ;;
9117a73423d7Smrg	*) func_append dlprefiles " $lib" ;;
9118b3e38ee4Smrg	esac
9119b3e38ee4Smrg      done
9120b3e38ee4Smrg
91214a8d91dcSmrg      if test yes = "$build_libtool_libs"; then
9122b3e38ee4Smrg	if test -n "$rpath"; then
9123b3e38ee4Smrg	  case $host in
9124a73423d7Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
9125b3e38ee4Smrg	    # these systems don't actually have a c library (as such)!
9126b3e38ee4Smrg	    ;;
9127b3e38ee4Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
9128b3e38ee4Smrg	    # Rhapsody C library is in the System framework
9129a73423d7Smrg	    func_append deplibs " System.ltframework"
9130b3e38ee4Smrg	    ;;
9131b3e38ee4Smrg	  *-*-netbsd*)
9132b3e38ee4Smrg	    # Don't link with libc until the a.out ld.so is fixed.
9133b3e38ee4Smrg	    ;;
9134b3e38ee4Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
9135b3e38ee4Smrg	    # Do not include libc due to us having libc/libc_r.
9136b3e38ee4Smrg	    ;;
9137b3e38ee4Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
9138b3e38ee4Smrg	    # Causes problems with __ctype
9139b3e38ee4Smrg	    ;;
9140b3e38ee4Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
9141b3e38ee4Smrg	    # Compiler inserts libc in the correct place for threads to work
9142b3e38ee4Smrg	    ;;
9143b3e38ee4Smrg	  *)
9144b3e38ee4Smrg	    # Add libc to deplibs on all other systems if necessary.
91454a8d91dcSmrg	    if test yes = "$build_libtool_need_lc"; then
9146a73423d7Smrg	      func_append deplibs " -lc"
9147b3e38ee4Smrg	    fi
9148b3e38ee4Smrg	    ;;
9149b3e38ee4Smrg	  esac
9150b3e38ee4Smrg	fi
9151b3e38ee4Smrg
9152b3e38ee4Smrg	# Transform deplibs into only deplibs that can be linked in shared.
9153b3e38ee4Smrg	name_save=$name
9154b3e38ee4Smrg	libname_save=$libname
9155b3e38ee4Smrg	release_save=$release
9156b3e38ee4Smrg	versuffix_save=$versuffix
9157b3e38ee4Smrg	major_save=$major
9158b3e38ee4Smrg	# I'm not sure if I'm treating the release correctly.  I think
9159b3e38ee4Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
9160b3e38ee4Smrg	# add it in twice.  Is that correct?
91614a8d91dcSmrg	release=
91624a8d91dcSmrg	versuffix=
91634a8d91dcSmrg	major=
9164b3e38ee4Smrg	newdeplibs=
9165b3e38ee4Smrg	droppeddeps=no
9166b3e38ee4Smrg	case $deplibs_check_method in
9167b3e38ee4Smrg	pass_all)
9168b3e38ee4Smrg	  # Don't check for shared/static.  Everything works.
9169b3e38ee4Smrg	  # This might be a little naive.  We might want to check
9170b3e38ee4Smrg	  # whether the library exists or not.  But this is on
9171b3e38ee4Smrg	  # osf3 & osf4 and I'm not really sure... Just
9172b3e38ee4Smrg	  # implementing what was already the behavior.
9173b3e38ee4Smrg	  newdeplibs=$deplibs
9174b3e38ee4Smrg	  ;;
9175b3e38ee4Smrg	test_compile)
9176b3e38ee4Smrg	  # This code stresses the "libraries are programs" paradigm to its
9177b3e38ee4Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
9178b3e38ee4Smrg	  # against the deplibs as a proxy for the library.  Then we can check
9179b3e38ee4Smrg	  # whether they linked in statically or dynamically with ldd.
9180b3e38ee4Smrg	  $opt_dry_run || $RM conftest.c
9181b3e38ee4Smrg	  cat > conftest.c <<EOF
9182b3e38ee4Smrg	  int main() { return 0; }
9183b3e38ee4SmrgEOF
9184b3e38ee4Smrg	  $opt_dry_run || $RM conftest
9185b3e38ee4Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
9186b3e38ee4Smrg	    ldd_output=`ldd conftest`
9187b3e38ee4Smrg	    for i in $deplibs; do
9188b3e38ee4Smrg	      case $i in
9189b3e38ee4Smrg	      -l*)
9190b3e38ee4Smrg		func_stripname -l '' "$i"
9191b3e38ee4Smrg		name=$func_stripname_result
91924a8d91dcSmrg		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9193b3e38ee4Smrg		  case " $predeps $postdeps " in
9194b3e38ee4Smrg		  *" $i "*)
9195a73423d7Smrg		    func_append newdeplibs " $i"
91964a8d91dcSmrg		    i=
9197b3e38ee4Smrg		    ;;
9198b3e38ee4Smrg		  esac
9199b3e38ee4Smrg		fi
92004a8d91dcSmrg		if test -n "$i"; then
9201b3e38ee4Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
9202b3e38ee4Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9203b3e38ee4Smrg		  set dummy $deplib_matches; shift
9204b3e38ee4Smrg		  deplib_match=$1
92054a8d91dcSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9206a73423d7Smrg		    func_append newdeplibs " $i"
9207b3e38ee4Smrg		  else
9208b3e38ee4Smrg		    droppeddeps=yes
9209a73423d7Smrg		    echo
9210b3e38ee4Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9211a73423d7Smrg		    echo "*** I have the capability to make that library automatically link in when"
9212a73423d7Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
9213a73423d7Smrg		    echo "*** shared version of the library, which I believe you do not have"
9214a73423d7Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
9215a73423d7Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
9216b3e38ee4Smrg		  fi
9217b3e38ee4Smrg		fi
9218b3e38ee4Smrg		;;
9219b3e38ee4Smrg	      *)
9220a73423d7Smrg		func_append newdeplibs " $i"
9221b3e38ee4Smrg		;;
9222b3e38ee4Smrg	      esac
9223b3e38ee4Smrg	    done
9224b3e38ee4Smrg	  else
9225b3e38ee4Smrg	    # Error occurred in the first compile.  Let's try to salvage
9226b3e38ee4Smrg	    # the situation: Compile a separate program for each library.
9227b3e38ee4Smrg	    for i in $deplibs; do
9228b3e38ee4Smrg	      case $i in
9229b3e38ee4Smrg	      -l*)
9230b3e38ee4Smrg		func_stripname -l '' "$i"
9231b3e38ee4Smrg		name=$func_stripname_result
9232b3e38ee4Smrg		$opt_dry_run || $RM conftest
9233b3e38ee4Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
9234b3e38ee4Smrg		  ldd_output=`ldd conftest`
92354a8d91dcSmrg		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9236b3e38ee4Smrg		    case " $predeps $postdeps " in
9237b3e38ee4Smrg		    *" $i "*)
9238a73423d7Smrg		      func_append newdeplibs " $i"
92394a8d91dcSmrg		      i=
9240b3e38ee4Smrg		      ;;
9241b3e38ee4Smrg		    esac
9242b3e38ee4Smrg		  fi
92434a8d91dcSmrg		  if test -n "$i"; then
9244b3e38ee4Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
9245b3e38ee4Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9246b3e38ee4Smrg		    set dummy $deplib_matches; shift
9247b3e38ee4Smrg		    deplib_match=$1
92484a8d91dcSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9249a73423d7Smrg		      func_append newdeplibs " $i"
9250b3e38ee4Smrg		    else
9251b3e38ee4Smrg		      droppeddeps=yes
9252a73423d7Smrg		      echo
9253b3e38ee4Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9254a73423d7Smrg		      echo "*** I have the capability to make that library automatically link in when"
9255a73423d7Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
9256a73423d7Smrg		      echo "*** shared version of the library, which you do not appear to have"
9257a73423d7Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
9258a73423d7Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
9259b3e38ee4Smrg		    fi
9260b3e38ee4Smrg		  fi
9261b3e38ee4Smrg		else
9262b3e38ee4Smrg		  droppeddeps=yes
9263a73423d7Smrg		  echo
9264b3e38ee4Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
9265a73423d7Smrg		  echo "*** make it link in!  You will probably need to install it or some"
9266a73423d7Smrg		  echo "*** library that it depends on before this library will be fully"
9267a73423d7Smrg		  echo "*** functional.  Installing it before continuing would be even better."
9268b3e38ee4Smrg		fi
9269b3e38ee4Smrg		;;
9270b3e38ee4Smrg	      *)
9271a73423d7Smrg		func_append newdeplibs " $i"
9272b3e38ee4Smrg		;;
9273b3e38ee4Smrg	      esac
9274b3e38ee4Smrg	    done
9275b3e38ee4Smrg	  fi
9276b3e38ee4Smrg	  ;;
9277b3e38ee4Smrg	file_magic*)
9278b3e38ee4Smrg	  set dummy $deplibs_check_method; shift
9279b3e38ee4Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9280b3e38ee4Smrg	  for a_deplib in $deplibs; do
9281b3e38ee4Smrg	    case $a_deplib in
9282b3e38ee4Smrg	    -l*)
9283b3e38ee4Smrg	      func_stripname -l '' "$a_deplib"
9284b3e38ee4Smrg	      name=$func_stripname_result
92854a8d91dcSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9286b3e38ee4Smrg		case " $predeps $postdeps " in
9287b3e38ee4Smrg		*" $a_deplib "*)
9288a73423d7Smrg		  func_append newdeplibs " $a_deplib"
92894a8d91dcSmrg		  a_deplib=
9290b3e38ee4Smrg		  ;;
9291b3e38ee4Smrg		esac
9292b3e38ee4Smrg	      fi
92934a8d91dcSmrg	      if test -n "$a_deplib"; then
9294b3e38ee4Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
9295a73423d7Smrg		if test -n "$file_magic_glob"; then
9296a73423d7Smrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
9297a73423d7Smrg		else
9298a73423d7Smrg		  libnameglob=$libname
9299a73423d7Smrg		fi
93004a8d91dcSmrg		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
9301b3e38ee4Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
93024a8d91dcSmrg		  if test yes = "$want_nocaseglob"; then
9303a73423d7Smrg		    shopt -s nocaseglob
9304a73423d7Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9305a73423d7Smrg		    $nocaseglob
9306a73423d7Smrg		  else
9307a73423d7Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9308a73423d7Smrg		  fi
9309b3e38ee4Smrg		  for potent_lib in $potential_libs; do
9310b3e38ee4Smrg		      # Follow soft links.
9311b3e38ee4Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
9312b3e38ee4Smrg			 $GREP " -> " >/dev/null; then
9313b3e38ee4Smrg			continue
9314b3e38ee4Smrg		      fi
9315b3e38ee4Smrg		      # The statement above tries to avoid entering an
9316b3e38ee4Smrg		      # endless loop below, in case of cyclic links.
9317b3e38ee4Smrg		      # We might still enter an endless loop, since a link
9318b3e38ee4Smrg		      # loop can be closed while we follow links,
9319b3e38ee4Smrg		      # but so what?
93204a8d91dcSmrg		      potlib=$potent_lib
9321b3e38ee4Smrg		      while test -h "$potlib" 2>/dev/null; do
93224a8d91dcSmrg			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
9323b3e38ee4Smrg			case $potliblink in
93244a8d91dcSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
93254a8d91dcSmrg			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
9326b3e38ee4Smrg			esac
9327b3e38ee4Smrg		      done
9328b3e38ee4Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
9329b3e38ee4Smrg			 $SED -e 10q |
9330b3e38ee4Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
9331a73423d7Smrg			func_append newdeplibs " $a_deplib"
93324a8d91dcSmrg			a_deplib=
9333b3e38ee4Smrg			break 2
9334b3e38ee4Smrg		      fi
9335b3e38ee4Smrg		  done
9336b3e38ee4Smrg		done
9337b3e38ee4Smrg	      fi
93384a8d91dcSmrg	      if test -n "$a_deplib"; then
9339b3e38ee4Smrg		droppeddeps=yes
9340a73423d7Smrg		echo
9341b3e38ee4Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9342a73423d7Smrg		echo "*** I have the capability to make that library automatically link in when"
9343a73423d7Smrg		echo "*** you link to this library.  But I can only do this if you have a"
9344a73423d7Smrg		echo "*** shared version of the library, which you do not appear to have"
9345a73423d7Smrg		echo "*** because I did check the linker path looking for a file starting"
93464a8d91dcSmrg		if test -z "$potlib"; then
9347b3e38ee4Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
9348b3e38ee4Smrg		else
9349b3e38ee4Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
9350b3e38ee4Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
9351b3e38ee4Smrg		fi
9352b3e38ee4Smrg	      fi
9353b3e38ee4Smrg	      ;;
9354b3e38ee4Smrg	    *)
9355b3e38ee4Smrg	      # Add a -L argument.
9356a73423d7Smrg	      func_append newdeplibs " $a_deplib"
9357b3e38ee4Smrg	      ;;
9358b3e38ee4Smrg	    esac
9359b3e38ee4Smrg	  done # Gone through all deplibs.
9360b3e38ee4Smrg	  ;;
9361b3e38ee4Smrg	match_pattern*)
9362b3e38ee4Smrg	  set dummy $deplibs_check_method; shift
9363b3e38ee4Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9364b3e38ee4Smrg	  for a_deplib in $deplibs; do
9365b3e38ee4Smrg	    case $a_deplib in
9366b3e38ee4Smrg	    -l*)
9367b3e38ee4Smrg	      func_stripname -l '' "$a_deplib"
9368b3e38ee4Smrg	      name=$func_stripname_result
93694a8d91dcSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9370b3e38ee4Smrg		case " $predeps $postdeps " in
9371b3e38ee4Smrg		*" $a_deplib "*)
9372a73423d7Smrg		  func_append newdeplibs " $a_deplib"
93734a8d91dcSmrg		  a_deplib=
9374b3e38ee4Smrg		  ;;
9375b3e38ee4Smrg		esac
9376b3e38ee4Smrg	      fi
93774a8d91dcSmrg	      if test -n "$a_deplib"; then
9378b3e38ee4Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
9379b3e38ee4Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9380b3e38ee4Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
9381b3e38ee4Smrg		  for potent_lib in $potential_libs; do
93824a8d91dcSmrg		    potlib=$potent_lib # see symlink-check above in file_magic test
9383a73423d7Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
9384b3e38ee4Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
9385a73423d7Smrg		      func_append newdeplibs " $a_deplib"
93864a8d91dcSmrg		      a_deplib=
9387b3e38ee4Smrg		      break 2
9388b3e38ee4Smrg		    fi
9389b3e38ee4Smrg		  done
9390b3e38ee4Smrg		done
9391b3e38ee4Smrg	      fi
93924a8d91dcSmrg	      if test -n "$a_deplib"; then
9393b3e38ee4Smrg		droppeddeps=yes
9394a73423d7Smrg		echo
9395b3e38ee4Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9396a73423d7Smrg		echo "*** I have the capability to make that library automatically link in when"
9397a73423d7Smrg		echo "*** you link to this library.  But I can only do this if you have a"
9398a73423d7Smrg		echo "*** shared version of the library, which you do not appear to have"
9399a73423d7Smrg		echo "*** because I did check the linker path looking for a file starting"
94004a8d91dcSmrg		if test -z "$potlib"; then
9401b3e38ee4Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
9402b3e38ee4Smrg		else
9403b3e38ee4Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
9404b3e38ee4Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
9405b3e38ee4Smrg		fi
9406b3e38ee4Smrg	      fi
9407b3e38ee4Smrg	      ;;
9408b3e38ee4Smrg	    *)
9409b3e38ee4Smrg	      # Add a -L argument.
9410a73423d7Smrg	      func_append newdeplibs " $a_deplib"
9411b3e38ee4Smrg	      ;;
9412b3e38ee4Smrg	    esac
9413b3e38ee4Smrg	  done # Gone through all deplibs.
9414b3e38ee4Smrg	  ;;
9415b3e38ee4Smrg	none | unknown | *)
94164a8d91dcSmrg	  newdeplibs=
9417a73423d7Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
94184a8d91dcSmrg	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
94194a8d91dcSmrg	    for i in $predeps $postdeps; do
9420b3e38ee4Smrg	      # can't use Xsed below, because $i might contain '/'
94214a8d91dcSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
9422b3e38ee4Smrg	    done
9423b3e38ee4Smrg	  fi
9424a73423d7Smrg	  case $tmp_deplibs in
9425a73423d7Smrg	  *[!\	\ ]*)
9426a73423d7Smrg	    echo
94274a8d91dcSmrg	    if test none = "$deplibs_check_method"; then
9428a73423d7Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
9429b3e38ee4Smrg	    else
9430a73423d7Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
9431b3e38ee4Smrg	    fi
9432a73423d7Smrg	    echo "*** All declared inter-library dependencies are being dropped."
9433b3e38ee4Smrg	    droppeddeps=yes
9434a73423d7Smrg	    ;;
9435a73423d7Smrg	  esac
9436b3e38ee4Smrg	  ;;
9437b3e38ee4Smrg	esac
9438b3e38ee4Smrg	versuffix=$versuffix_save
9439b3e38ee4Smrg	major=$major_save
9440b3e38ee4Smrg	release=$release_save
9441b3e38ee4Smrg	libname=$libname_save
9442b3e38ee4Smrg	name=$name_save
9443b3e38ee4Smrg
9444b3e38ee4Smrg	case $host in
9445b3e38ee4Smrg	*-*-rhapsody* | *-*-darwin1.[012])
9446b3e38ee4Smrg	  # On Rhapsody replace the C library with the System framework
9447a73423d7Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
9448b3e38ee4Smrg	  ;;
9449b3e38ee4Smrg	esac
9450b3e38ee4Smrg
94514a8d91dcSmrg	if test yes = "$droppeddeps"; then
94524a8d91dcSmrg	  if test yes = "$module"; then
9453a73423d7Smrg	    echo
9454a73423d7Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
9455b3e38ee4Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
9456a73423d7Smrg	    echo "*** a static module, that should work as long as the dlopening"
9457a73423d7Smrg	    echo "*** application is linked with the -dlopen flag."
9458b3e38ee4Smrg	    if test -z "$global_symbol_pipe"; then
9459a73423d7Smrg	      echo
9460a73423d7Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
94614a8d91dcSmrg	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
9462a73423d7Smrg	      echo "*** not find such a program.  So, this module is probably useless."
94634a8d91dcSmrg	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
9464b3e38ee4Smrg	    fi
94654a8d91dcSmrg	    if test no = "$build_old_libs"; then
94664a8d91dcSmrg	      oldlibs=$output_objdir/$libname.$libext
9467b3e38ee4Smrg	      build_libtool_libs=module
9468b3e38ee4Smrg	      build_old_libs=yes
9469b3e38ee4Smrg	    else
9470b3e38ee4Smrg	      build_libtool_libs=no
9471b3e38ee4Smrg	    fi
9472b3e38ee4Smrg	  else
9473a73423d7Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
9474a73423d7Smrg	    echo "*** automatically added whenever a program is linked with this library"
9475a73423d7Smrg	    echo "*** or is declared to -dlopen it."
9476b3e38ee4Smrg
94774a8d91dcSmrg	    if test no = "$allow_undefined"; then
9478a73423d7Smrg	      echo
9479a73423d7Smrg	      echo "*** Since this library must not contain undefined symbols,"
9480a73423d7Smrg	      echo "*** because either the platform does not support them or"
9481a73423d7Smrg	      echo "*** it was explicitly requested with -no-undefined,"
9482a73423d7Smrg	      echo "*** libtool will only create a static version of it."
94834a8d91dcSmrg	      if test no = "$build_old_libs"; then
94844a8d91dcSmrg		oldlibs=$output_objdir/$libname.$libext
9485b3e38ee4Smrg		build_libtool_libs=module
9486b3e38ee4Smrg		build_old_libs=yes
9487b3e38ee4Smrg	      else
9488b3e38ee4Smrg		build_libtool_libs=no
9489b3e38ee4Smrg	      fi
9490b3e38ee4Smrg	    fi
9491b3e38ee4Smrg	  fi
9492b3e38ee4Smrg	fi
9493b3e38ee4Smrg	# Done checking deplibs!
9494b3e38ee4Smrg	deplibs=$newdeplibs
9495b3e38ee4Smrg      fi
9496b3e38ee4Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
9497b3e38ee4Smrg      case $host in
9498b3e38ee4Smrg	*-*-darwin*)
9499a73423d7Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9500a73423d7Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9501a73423d7Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9502b3e38ee4Smrg	  ;;
9503b3e38ee4Smrg      esac
9504b3e38ee4Smrg
9505b3e38ee4Smrg      # move library search paths that coincide with paths to not yet
9506b3e38ee4Smrg      # installed libraries to the beginning of the library search list
9507b3e38ee4Smrg      new_libs=
9508b3e38ee4Smrg      for path in $notinst_path; do
9509b3e38ee4Smrg	case " $new_libs " in
9510b3e38ee4Smrg	*" -L$path/$objdir "*) ;;
9511b3e38ee4Smrg	*)
9512b3e38ee4Smrg	  case " $deplibs " in
9513b3e38ee4Smrg	  *" -L$path/$objdir "*)
9514a73423d7Smrg	    func_append new_libs " -L$path/$objdir" ;;
9515b3e38ee4Smrg	  esac
9516b3e38ee4Smrg	  ;;
9517b3e38ee4Smrg	esac
9518b3e38ee4Smrg      done
9519b3e38ee4Smrg      for deplib in $deplibs; do
9520b3e38ee4Smrg	case $deplib in
9521b3e38ee4Smrg	-L*)
9522b3e38ee4Smrg	  case " $new_libs " in
9523b3e38ee4Smrg	  *" $deplib "*) ;;
9524a73423d7Smrg	  *) func_append new_libs " $deplib" ;;
9525b3e38ee4Smrg	  esac
9526b3e38ee4Smrg	  ;;
9527a73423d7Smrg	*) func_append new_libs " $deplib" ;;
9528b3e38ee4Smrg	esac
9529b3e38ee4Smrg      done
95304a8d91dcSmrg      deplibs=$new_libs
9531b3e38ee4Smrg
9532b3e38ee4Smrg      # All the library-specific variables (install_libdir is set above).
9533b3e38ee4Smrg      library_names=
9534b3e38ee4Smrg      old_library=
9535b3e38ee4Smrg      dlname=
9536b3e38ee4Smrg
9537b3e38ee4Smrg      # Test again, we may have decided not to build it any more
95384a8d91dcSmrg      if test yes = "$build_libtool_libs"; then
95394a8d91dcSmrg	# Remove $wl instances when linking with ld.
9540a73423d7Smrg	# FIXME: should test the right _cmds variable.
9541a73423d7Smrg	case $archive_cmds in
9542a73423d7Smrg	  *\$LD\ *) wl= ;;
9543a73423d7Smrg        esac
95444a8d91dcSmrg	if test yes = "$hardcode_into_libs"; then
9545b3e38ee4Smrg	  # Hardcode the library paths
9546b3e38ee4Smrg	  hardcode_libdirs=
9547b3e38ee4Smrg	  dep_rpath=
95484a8d91dcSmrg	  rpath=$finalize_rpath
95494a8d91dcSmrg	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
9550b3e38ee4Smrg	  for libdir in $rpath; do
9551b3e38ee4Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
9552b3e38ee4Smrg	      if test -n "$hardcode_libdir_separator"; then
9553a73423d7Smrg		func_replace_sysroot "$libdir"
9554a73423d7Smrg		libdir=$func_replace_sysroot_result
9555b3e38ee4Smrg		if test -z "$hardcode_libdirs"; then
95564a8d91dcSmrg		  hardcode_libdirs=$libdir
9557b3e38ee4Smrg		else
9558b3e38ee4Smrg		  # Just accumulate the unique libdirs.
9559b3e38ee4Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
9560b3e38ee4Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
9561b3e38ee4Smrg		    ;;
9562b3e38ee4Smrg		  *)
9563a73423d7Smrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
9564b3e38ee4Smrg		    ;;
9565b3e38ee4Smrg		  esac
9566b3e38ee4Smrg		fi
9567b3e38ee4Smrg	      else
9568b3e38ee4Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
9569a73423d7Smrg		func_append dep_rpath " $flag"
9570b3e38ee4Smrg	      fi
9571b3e38ee4Smrg	    elif test -n "$runpath_var"; then
9572b3e38ee4Smrg	      case "$perm_rpath " in
9573b3e38ee4Smrg	      *" $libdir "*) ;;
9574a73423d7Smrg	      *) func_append perm_rpath " $libdir" ;;
9575b3e38ee4Smrg	      esac
9576b3e38ee4Smrg	    fi
9577b3e38ee4Smrg	  done
9578b3e38ee4Smrg	  # Substitute the hardcoded libdirs into the rpath.
9579b3e38ee4Smrg	  if test -n "$hardcode_libdir_separator" &&
9580b3e38ee4Smrg	     test -n "$hardcode_libdirs"; then
95814a8d91dcSmrg	    libdir=$hardcode_libdirs
9582a73423d7Smrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
9583b3e38ee4Smrg	  fi
9584b3e38ee4Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
9585b3e38ee4Smrg	    # We should set the runpath_var.
9586b3e38ee4Smrg	    rpath=
9587b3e38ee4Smrg	    for dir in $perm_rpath; do
9588a73423d7Smrg	      func_append rpath "$dir:"
9589b3e38ee4Smrg	    done
9590b3e38ee4Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
9591b3e38ee4Smrg	  fi
9592b3e38ee4Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
9593b3e38ee4Smrg	fi
959450806d53Smrg
95954a8d91dcSmrg	shlibpath=$finalize_shlibpath
95964a8d91dcSmrg	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
9597b3e38ee4Smrg	if test -n "$shlibpath"; then
9598b3e38ee4Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
9599b3e38ee4Smrg	fi
960050806d53Smrg
9601b3e38ee4Smrg	# Get the real and link names of the library.
9602b3e38ee4Smrg	eval shared_ext=\"$shrext_cmds\"
9603b3e38ee4Smrg	eval library_names=\"$library_names_spec\"
9604b3e38ee4Smrg	set dummy $library_names
9605b3e38ee4Smrg	shift
96064a8d91dcSmrg	realname=$1
9607b3e38ee4Smrg	shift
960850806d53Smrg
9609b3e38ee4Smrg	if test -n "$soname_spec"; then
9610b3e38ee4Smrg	  eval soname=\"$soname_spec\"
9611b3e38ee4Smrg	else
96124a8d91dcSmrg	  soname=$realname
9613b3e38ee4Smrg	fi
9614b3e38ee4Smrg	if test -z "$dlname"; then
9615b3e38ee4Smrg	  dlname=$soname
9616b3e38ee4Smrg	fi
961750806d53Smrg
96184a8d91dcSmrg	lib=$output_objdir/$realname
9619b3e38ee4Smrg	linknames=
9620b3e38ee4Smrg	for link
9621b3e38ee4Smrg	do
9622a73423d7Smrg	  func_append linknames " $link"
9623b3e38ee4Smrg	done
962450806d53Smrg
9625b3e38ee4Smrg	# Use standard objects if they are pic
9626a73423d7Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
9627b3e38ee4Smrg	test "X$libobjs" = "X " && libobjs=
962850806d53Smrg
9629b3e38ee4Smrg	delfiles=
9630b3e38ee4Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
9631b3e38ee4Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
96324a8d91dcSmrg	  export_symbols=$output_objdir/$libname.uexp
9633a73423d7Smrg	  func_append delfiles " $export_symbols"
9634b3e38ee4Smrg	fi
963550806d53Smrg
9636b3e38ee4Smrg	orig_export_symbols=
9637b3e38ee4Smrg	case $host_os in
9638b3e38ee4Smrg	cygwin* | mingw* | cegcc*)
9639b3e38ee4Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
9640b3e38ee4Smrg	    # exporting using user supplied symfile
96414a8d91dcSmrg	    func_dll_def_p "$export_symbols" || {
9642b3e38ee4Smrg	      # and it's NOT already a .def file. Must figure out
9643b3e38ee4Smrg	      # which of the given symbols are data symbols and tag
9644b3e38ee4Smrg	      # them as such. So, trigger use of export_symbols_cmds.
9645b3e38ee4Smrg	      # export_symbols gets reassigned inside the "prepare
9646b3e38ee4Smrg	      # the list of exported symbols" if statement, so the
9647b3e38ee4Smrg	      # include_expsyms logic still works.
96484a8d91dcSmrg	      orig_export_symbols=$export_symbols
9649b3e38ee4Smrg	      export_symbols=
9650b3e38ee4Smrg	      always_export_symbols=yes
96514a8d91dcSmrg	    }
9652b3e38ee4Smrg	  fi
9653b3e38ee4Smrg	  ;;
9654b3e38ee4Smrg	esac
965550806d53Smrg
9656b3e38ee4Smrg	# Prepare the list of exported symbols
9657b3e38ee4Smrg	if test -z "$export_symbols"; then
96584a8d91dcSmrg	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
96594a8d91dcSmrg	    func_verbose "generating symbol list for '$libname.la'"
96604a8d91dcSmrg	    export_symbols=$output_objdir/$libname.exp
9661b3e38ee4Smrg	    $opt_dry_run || $RM $export_symbols
9662b3e38ee4Smrg	    cmds=$export_symbols_cmds
96634a8d91dcSmrg	    save_ifs=$IFS; IFS='~'
9664a73423d7Smrg	    for cmd1 in $cmds; do
96654a8d91dcSmrg	      IFS=$save_ifs
9666a73423d7Smrg	      # Take the normal branch if the nm_file_list_spec branch
9667a73423d7Smrg	      # doesn't work or if tool conversion is not needed.
9668a73423d7Smrg	      case $nm_file_list_spec~$to_tool_file_cmd in
9669a73423d7Smrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
9670a73423d7Smrg		  try_normal_branch=yes
9671a73423d7Smrg		  eval cmd=\"$cmd1\"
9672a73423d7Smrg		  func_len " $cmd"
9673a73423d7Smrg		  len=$func_len_result
9674a73423d7Smrg		  ;;
9675a73423d7Smrg		*)
9676a73423d7Smrg		  try_normal_branch=no
9677a73423d7Smrg		  ;;
9678a73423d7Smrg	      esac
96794a8d91dcSmrg	      if test yes = "$try_normal_branch" \
9680a73423d7Smrg		 && { test "$len" -lt "$max_cmd_len" \
9681a73423d7Smrg		      || test "$max_cmd_len" -le -1; }
9682a73423d7Smrg	      then
9683a73423d7Smrg		func_show_eval "$cmd" 'exit $?'
9684a73423d7Smrg		skipped_export=false
9685a73423d7Smrg	      elif test -n "$nm_file_list_spec"; then
9686a73423d7Smrg		func_basename "$output"
9687a73423d7Smrg		output_la=$func_basename_result
9688a73423d7Smrg		save_libobjs=$libobjs
9689a73423d7Smrg		save_output=$output
96904a8d91dcSmrg		output=$output_objdir/$output_la.nm
9691a73423d7Smrg		func_to_tool_file "$output"
9692a73423d7Smrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
9693a73423d7Smrg		func_append delfiles " $output"
9694a73423d7Smrg		func_verbose "creating $NM input file list: $output"
9695a73423d7Smrg		for obj in $save_libobjs; do
9696a73423d7Smrg		  func_to_tool_file "$obj"
9697a73423d7Smrg		  $ECHO "$func_to_tool_file_result"
9698a73423d7Smrg		done > "$output"
9699a73423d7Smrg		eval cmd=\"$cmd1\"
9700b3e38ee4Smrg		func_show_eval "$cmd" 'exit $?'
9701a73423d7Smrg		output=$save_output
9702a73423d7Smrg		libobjs=$save_libobjs
9703b3e38ee4Smrg		skipped_export=false
9704b3e38ee4Smrg	      else
9705b3e38ee4Smrg		# The command line is too long to execute in one step.
9706b3e38ee4Smrg		func_verbose "using reloadable object file for export list..."
9707b3e38ee4Smrg		skipped_export=:
9708b3e38ee4Smrg		# Break out early, otherwise skipped_export may be
9709b3e38ee4Smrg		# set to false by a later but shorter cmd.
9710b3e38ee4Smrg		break
9711b3e38ee4Smrg	      fi
9712b3e38ee4Smrg	    done
97134a8d91dcSmrg	    IFS=$save_ifs
97144a8d91dcSmrg	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
9715b3e38ee4Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9716b3e38ee4Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9717b3e38ee4Smrg	    fi
9718b3e38ee4Smrg	  fi
971950806d53Smrg	fi
972050806d53Smrg
9721b3e38ee4Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
97224a8d91dcSmrg	  tmp_export_symbols=$export_symbols
97234a8d91dcSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9724a73423d7Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9725b3e38ee4Smrg	fi
972650806d53Smrg
97274a8d91dcSmrg	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
9728b3e38ee4Smrg	  # The given exports_symbols file has to be filtered, so filter it.
97294a8d91dcSmrg	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9730b3e38ee4Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
97314a8d91dcSmrg	  # 's' commands, which not all seds can handle. GNU sed should be fine
9732b3e38ee4Smrg	  # though. Also, the filter scales superlinearly with the number of
9733b3e38ee4Smrg	  # global variables. join(1) would be nice here, but unfortunately
9734b3e38ee4Smrg	  # isn't a blessed tool.
9735b3e38ee4Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9736a73423d7Smrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9737b3e38ee4Smrg	  export_symbols=$output_objdir/$libname.def
9738b3e38ee4Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9739b3e38ee4Smrg	fi
974050806d53Smrg
9741b3e38ee4Smrg	tmp_deplibs=
9742b3e38ee4Smrg	for test_deplib in $deplibs; do
9743b3e38ee4Smrg	  case " $convenience " in
9744b3e38ee4Smrg	  *" $test_deplib "*) ;;
9745b3e38ee4Smrg	  *)
9746a73423d7Smrg	    func_append tmp_deplibs " $test_deplib"
9747b3e38ee4Smrg	    ;;
9748b3e38ee4Smrg	  esac
9749b3e38ee4Smrg	done
97504a8d91dcSmrg	deplibs=$tmp_deplibs
975150806d53Smrg
9752b3e38ee4Smrg	if test -n "$convenience"; then
9753b3e38ee4Smrg	  if test -n "$whole_archive_flag_spec" &&
97544a8d91dcSmrg	    test yes = "$compiler_needs_object" &&
9755b3e38ee4Smrg	    test -z "$libobjs"; then
9756b3e38ee4Smrg	    # extract the archives, so we have objects to list.
9757b3e38ee4Smrg	    # TODO: could optimize this to just extract one archive.
9758b3e38ee4Smrg	    whole_archive_flag_spec=
9759b3e38ee4Smrg	  fi
9760b3e38ee4Smrg	  if test -n "$whole_archive_flag_spec"; then
9761b3e38ee4Smrg	    save_libobjs=$libobjs
9762b3e38ee4Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9763b3e38ee4Smrg	    test "X$libobjs" = "X " && libobjs=
9764b3e38ee4Smrg	  else
97654a8d91dcSmrg	    gentop=$output_objdir/${outputname}x
9766a73423d7Smrg	    func_append generated " $gentop"
976750806d53Smrg
9768b3e38ee4Smrg	    func_extract_archives $gentop $convenience
9769a73423d7Smrg	    func_append libobjs " $func_extract_archives_result"
9770b3e38ee4Smrg	    test "X$libobjs" = "X " && libobjs=
9771b3e38ee4Smrg	  fi
9772a18ebfb2Smrg	fi
977350806d53Smrg
97744a8d91dcSmrg	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
9775b3e38ee4Smrg	  eval flag=\"$thread_safe_flag_spec\"
9776a73423d7Smrg	  func_append linker_flags " $flag"
9777a18ebfb2Smrg	fi
9778af1a9c97Smrg
9779b3e38ee4Smrg	# Make a backup of the uninstalled library when relinking
97804a8d91dcSmrg	if test relink = "$opt_mode"; then
9781b3e38ee4Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
9782b3e38ee4Smrg	fi
978350806d53Smrg
9784b3e38ee4Smrg	# Do each of the archive commands.
97854a8d91dcSmrg	if test yes = "$module" && test -n "$module_cmds"; then
9786b3e38ee4Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
9787b3e38ee4Smrg	    eval test_cmds=\"$module_expsym_cmds\"
9788b3e38ee4Smrg	    cmds=$module_expsym_cmds
9789b3e38ee4Smrg	  else
9790b3e38ee4Smrg	    eval test_cmds=\"$module_cmds\"
9791b3e38ee4Smrg	    cmds=$module_cmds
9792b3e38ee4Smrg	  fi
9793a18ebfb2Smrg	else
9794b3e38ee4Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
9795b3e38ee4Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
9796b3e38ee4Smrg	    cmds=$archive_expsym_cmds
9797b3e38ee4Smrg	  else
9798b3e38ee4Smrg	    eval test_cmds=\"$archive_cmds\"
9799b3e38ee4Smrg	    cmds=$archive_cmds
9800b3e38ee4Smrg	  fi
9801a18ebfb2Smrg	fi
980250806d53Smrg
98034a8d91dcSmrg	if test : != "$skipped_export" &&
9804b3e38ee4Smrg	   func_len " $test_cmds" &&
9805b3e38ee4Smrg	   len=$func_len_result &&
9806b3e38ee4Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9807b3e38ee4Smrg	  :
9808b3e38ee4Smrg	else
9809b3e38ee4Smrg	  # The command line is too long to link in one step, link piecewise
9810b3e38ee4Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
9811b3e38ee4Smrg	  # script.
981250806d53Smrg
9813b3e38ee4Smrg	  # Save the value of $output and $libobjs because we want to
9814b3e38ee4Smrg	  # use them later.  If we have whole_archive_flag_spec, we
9815b3e38ee4Smrg	  # want to use save_libobjs as it was before
9816b3e38ee4Smrg	  # whole_archive_flag_spec was expanded, because we can't
9817b3e38ee4Smrg	  # assume the linker understands whole_archive_flag_spec.
9818b3e38ee4Smrg	  # This may have to be revisited, in case too many
9819b3e38ee4Smrg	  # convenience libraries get linked in and end up exceeding
9820b3e38ee4Smrg	  # the spec.
9821b3e38ee4Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
9822b3e38ee4Smrg	    save_libobjs=$libobjs
9823b3e38ee4Smrg	  fi
9824b3e38ee4Smrg	  save_output=$output
9825a73423d7Smrg	  func_basename "$output"
9826a73423d7Smrg	  output_la=$func_basename_result
982750806d53Smrg
9828b3e38ee4Smrg	  # Clear the reloadable object creation command queue and
9829b3e38ee4Smrg	  # initialize k to one.
9830b3e38ee4Smrg	  test_cmds=
9831b3e38ee4Smrg	  concat_cmds=
9832b3e38ee4Smrg	  objlist=
9833b3e38ee4Smrg	  last_robj=
9834b3e38ee4Smrg	  k=1
9835b3e38ee4Smrg
98364a8d91dcSmrg	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
98374a8d91dcSmrg	    output=$output_objdir/$output_la.lnkscript
9838b3e38ee4Smrg	    func_verbose "creating GNU ld script: $output"
9839a73423d7Smrg	    echo 'INPUT (' > $output
9840b3e38ee4Smrg	    for obj in $save_libobjs
9841a18ebfb2Smrg	    do
9842a73423d7Smrg	      func_to_tool_file "$obj"
9843a73423d7Smrg	      $ECHO "$func_to_tool_file_result" >> $output
9844b3e38ee4Smrg	    done
9845a73423d7Smrg	    echo ')' >> $output
9846a73423d7Smrg	    func_append delfiles " $output"
9847a73423d7Smrg	    func_to_tool_file "$output"
9848a73423d7Smrg	    output=$func_to_tool_file_result
98494a8d91dcSmrg	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
98504a8d91dcSmrg	    output=$output_objdir/$output_la.lnk
9851b3e38ee4Smrg	    func_verbose "creating linker input file list: $output"
9852b3e38ee4Smrg	    : > $output
9853b3e38ee4Smrg	    set x $save_libobjs
9854b3e38ee4Smrg	    shift
9855b3e38ee4Smrg	    firstobj=
98564a8d91dcSmrg	    if test yes = "$compiler_needs_object"; then
9857b3e38ee4Smrg	      firstobj="$1 "
9858b3e38ee4Smrg	      shift
9859b3e38ee4Smrg	    fi
9860b3e38ee4Smrg	    for obj
9861b3e38ee4Smrg	    do
9862a73423d7Smrg	      func_to_tool_file "$obj"
9863a73423d7Smrg	      $ECHO "$func_to_tool_file_result" >> $output
9864b3e38ee4Smrg	    done
9865a73423d7Smrg	    func_append delfiles " $output"
9866a73423d7Smrg	    func_to_tool_file "$output"
9867a73423d7Smrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
9868b3e38ee4Smrg	  else
9869b3e38ee4Smrg	    if test -n "$save_libobjs"; then
9870b3e38ee4Smrg	      func_verbose "creating reloadable object files..."
98714a8d91dcSmrg	      output=$output_objdir/$output_la-$k.$objext
9872b3e38ee4Smrg	      eval test_cmds=\"$reload_cmds\"
9873b3e38ee4Smrg	      func_len " $test_cmds"
9874b3e38ee4Smrg	      len0=$func_len_result
9875b3e38ee4Smrg	      len=$len0
9876b3e38ee4Smrg
9877b3e38ee4Smrg	      # Loop over the list of objects to be linked.
9878b3e38ee4Smrg	      for obj in $save_libobjs
9879b3e38ee4Smrg	      do
9880b3e38ee4Smrg		func_len " $obj"
9881b3e38ee4Smrg		func_arith $len + $func_len_result
9882b3e38ee4Smrg		len=$func_arith_result
98834a8d91dcSmrg		if test -z "$objlist" ||
9884b3e38ee4Smrg		   test "$len" -lt "$max_cmd_len"; then
9885b3e38ee4Smrg		  func_append objlist " $obj"
9886b3e38ee4Smrg		else
9887b3e38ee4Smrg		  # The command $test_cmds is almost too long, add a
9888b3e38ee4Smrg		  # command to the queue.
98894a8d91dcSmrg		  if test 1 -eq "$k"; then
9890b3e38ee4Smrg		    # The first file doesn't have a previous command to add.
9891a73423d7Smrg		    reload_objs=$objlist
9892a73423d7Smrg		    eval concat_cmds=\"$reload_cmds\"
9893b3e38ee4Smrg		  else
9894b3e38ee4Smrg		    # All subsequent reloadable object files will link in
9895b3e38ee4Smrg		    # the last one created.
9896a73423d7Smrg		    reload_objs="$objlist $last_robj"
9897a73423d7Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
9898b3e38ee4Smrg		  fi
98994a8d91dcSmrg		  last_robj=$output_objdir/$output_la-$k.$objext
9900b3e38ee4Smrg		  func_arith $k + 1
9901b3e38ee4Smrg		  k=$func_arith_result
99024a8d91dcSmrg		  output=$output_objdir/$output_la-$k.$objext
9903a73423d7Smrg		  objlist=" $obj"
9904b3e38ee4Smrg		  func_len " $last_robj"
9905b3e38ee4Smrg		  func_arith $len0 + $func_len_result
9906b3e38ee4Smrg		  len=$func_arith_result
9907b3e38ee4Smrg		fi
9908b3e38ee4Smrg	      done
9909b3e38ee4Smrg	      # Handle the remaining objects by creating one last
9910b3e38ee4Smrg	      # reloadable object file.  All subsequent reloadable object
9911b3e38ee4Smrg	      # files will link in the last one created.
9912b3e38ee4Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9913a73423d7Smrg	      reload_objs="$objlist $last_robj"
99144a8d91dcSmrg	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
9915b3e38ee4Smrg	      if test -n "$last_robj"; then
99164a8d91dcSmrg	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9917b3e38ee4Smrg	      fi
9918a73423d7Smrg	      func_append delfiles " $output"
991950806d53Smrg
9920b3e38ee4Smrg	    else
9921b3e38ee4Smrg	      output=
9922b3e38ee4Smrg	    fi
992350806d53Smrg
99244a8d91dcSmrg	    ${skipped_export-false} && {
99254a8d91dcSmrg	      func_verbose "generating symbol list for '$libname.la'"
99264a8d91dcSmrg	      export_symbols=$output_objdir/$libname.exp
9927b3e38ee4Smrg	      $opt_dry_run || $RM $export_symbols
9928b3e38ee4Smrg	      libobjs=$output
9929b3e38ee4Smrg	      # Append the command to create the export file.
9930b3e38ee4Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9931b3e38ee4Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
9932b3e38ee4Smrg	      if test -n "$last_robj"; then
9933b3e38ee4Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9934b3e38ee4Smrg	      fi
99354a8d91dcSmrg	    }
993650806d53Smrg
9937b3e38ee4Smrg	    test -n "$save_libobjs" &&
9938b3e38ee4Smrg	      func_verbose "creating a temporary reloadable object file: $output"
993950806d53Smrg
9940b3e38ee4Smrg	    # Loop through the commands generated above and execute them.
99414a8d91dcSmrg	    save_ifs=$IFS; IFS='~'
9942b3e38ee4Smrg	    for cmd in $concat_cmds; do
99434a8d91dcSmrg	      IFS=$save_ifs
99444a8d91dcSmrg	      $opt_quiet || {
9945b3e38ee4Smrg		  func_quote_for_expand "$cmd"
9946b3e38ee4Smrg		  eval "func_echo $func_quote_for_expand_result"
9947b3e38ee4Smrg	      }
9948b3e38ee4Smrg	      $opt_dry_run || eval "$cmd" || {
9949b3e38ee4Smrg		lt_exit=$?
9950b3e38ee4Smrg
9951b3e38ee4Smrg		# Restore the uninstalled library and exit
99524a8d91dcSmrg		if test relink = "$opt_mode"; then
9953b3e38ee4Smrg		  ( cd "$output_objdir" && \
9954b3e38ee4Smrg		    $RM "${realname}T" && \
9955b3e38ee4Smrg		    $MV "${realname}U" "$realname" )
9956b3e38ee4Smrg		fi
995750806d53Smrg
9958b3e38ee4Smrg		exit $lt_exit
9959b3e38ee4Smrg	      }
9960b3e38ee4Smrg	    done
99614a8d91dcSmrg	    IFS=$save_ifs
9962a18ebfb2Smrg
9963b3e38ee4Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
9964b3e38ee4Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9965b3e38ee4Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
996650806d53Smrg	    fi
996750806d53Smrg	  fi
996850806d53Smrg
99694a8d91dcSmrg          ${skipped_export-false} && {
9970b3e38ee4Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
99714a8d91dcSmrg	      tmp_export_symbols=$export_symbols
99724a8d91dcSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9973a73423d7Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9974b3e38ee4Smrg	    fi
9975af1a9c97Smrg
9976b3e38ee4Smrg	    if test -n "$orig_export_symbols"; then
9977b3e38ee4Smrg	      # The given exports_symbols file has to be filtered, so filter it.
99784a8d91dcSmrg	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9979b3e38ee4Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
99804a8d91dcSmrg	      # 's' commands, which not all seds can handle. GNU sed should be fine
9981b3e38ee4Smrg	      # though. Also, the filter scales superlinearly with the number of
9982b3e38ee4Smrg	      # global variables. join(1) would be nice here, but unfortunately
9983b3e38ee4Smrg	      # isn't a blessed tool.
9984b3e38ee4Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9985a73423d7Smrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9986b3e38ee4Smrg	      export_symbols=$output_objdir/$libname.def
9987b3e38ee4Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9988b3e38ee4Smrg	    fi
99894a8d91dcSmrg	  }
999050806d53Smrg
9991b3e38ee4Smrg	  libobjs=$output
9992b3e38ee4Smrg	  # Restore the value of output.
9993b3e38ee4Smrg	  output=$save_output
999450806d53Smrg
9995b3e38ee4Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
9996b3e38ee4Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9997b3e38ee4Smrg	    test "X$libobjs" = "X " && libobjs=
9998b3e38ee4Smrg	  fi
9999b3e38ee4Smrg	  # Expand the library linking commands again to reset the
10000b3e38ee4Smrg	  # value of $libobjs for piecewise linking.
1000150806d53Smrg
10002b3e38ee4Smrg	  # Do each of the archive commands.
100034a8d91dcSmrg	  if test yes = "$module" && test -n "$module_cmds"; then
10004b3e38ee4Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
10005b3e38ee4Smrg	      cmds=$module_expsym_cmds
10006b3e38ee4Smrg	    else
10007b3e38ee4Smrg	      cmds=$module_cmds
10008a18ebfb2Smrg	    fi
10009a18ebfb2Smrg	  else
10010b3e38ee4Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
10011b3e38ee4Smrg	      cmds=$archive_expsym_cmds
10012b3e38ee4Smrg	    else
10013b3e38ee4Smrg	      cmds=$archive_cmds
10014b3e38ee4Smrg	    fi
10015a18ebfb2Smrg	  fi
10016b3e38ee4Smrg	fi
1001750806d53Smrg
10018b3e38ee4Smrg	if test -n "$delfiles"; then
10019b3e38ee4Smrg	  # Append the command to remove temporary files to $cmds.
10020b3e38ee4Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
10021b3e38ee4Smrg	fi
1002250806d53Smrg
10023b3e38ee4Smrg	# Add any objects from preloaded convenience libraries
10024b3e38ee4Smrg	if test -n "$dlprefiles"; then
100254a8d91dcSmrg	  gentop=$output_objdir/${outputname}x
10026a73423d7Smrg	  func_append generated " $gentop"
1002750806d53Smrg
10028b3e38ee4Smrg	  func_extract_archives $gentop $dlprefiles
10029a73423d7Smrg	  func_append libobjs " $func_extract_archives_result"
10030b3e38ee4Smrg	  test "X$libobjs" = "X " && libobjs=
10031b3e38ee4Smrg	fi
1003250806d53Smrg
100334a8d91dcSmrg	save_ifs=$IFS; IFS='~'
10034b3e38ee4Smrg	for cmd in $cmds; do
100354a8d91dcSmrg	  IFS=$sp$nl
10036b3e38ee4Smrg	  eval cmd=\"$cmd\"
100374a8d91dcSmrg	  IFS=$save_ifs
100384a8d91dcSmrg	  $opt_quiet || {
10039b3e38ee4Smrg	    func_quote_for_expand "$cmd"
10040b3e38ee4Smrg	    eval "func_echo $func_quote_for_expand_result"
10041b3e38ee4Smrg	  }
10042b3e38ee4Smrg	  $opt_dry_run || eval "$cmd" || {
10043b3e38ee4Smrg	    lt_exit=$?
10044af1a9c97Smrg
10045b3e38ee4Smrg	    # Restore the uninstalled library and exit
100464a8d91dcSmrg	    if test relink = "$opt_mode"; then
10047b3e38ee4Smrg	      ( cd "$output_objdir" && \
10048b3e38ee4Smrg	        $RM "${realname}T" && \
10049b3e38ee4Smrg		$MV "${realname}U" "$realname" )
10050b3e38ee4Smrg	    fi
10051af1a9c97Smrg
10052b3e38ee4Smrg	    exit $lt_exit
10053b3e38ee4Smrg	  }
10054b3e38ee4Smrg	done
100554a8d91dcSmrg	IFS=$save_ifs
10056af1a9c97Smrg
10057b3e38ee4Smrg	# Restore the uninstalled library and exit
100584a8d91dcSmrg	if test relink = "$opt_mode"; then
10059b3e38ee4Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
10060af1a9c97Smrg
10061b3e38ee4Smrg	  if test -n "$convenience"; then
10062b3e38ee4Smrg	    if test -z "$whole_archive_flag_spec"; then
10063b3e38ee4Smrg	      func_show_eval '${RM}r "$gentop"'
10064b3e38ee4Smrg	    fi
10065b3e38ee4Smrg	  fi
10066af1a9c97Smrg
10067b3e38ee4Smrg	  exit $EXIT_SUCCESS
10068b3e38ee4Smrg	fi
10069b3e38ee4Smrg
10070b3e38ee4Smrg	# Create links to the real library.
10071b3e38ee4Smrg	for linkname in $linknames; do
10072b3e38ee4Smrg	  if test "$realname" != "$linkname"; then
10073b3e38ee4Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
10074a18ebfb2Smrg	  fi
10075a18ebfb2Smrg	done
10076af1a9c97Smrg
10077b3e38ee4Smrg	# If -module or -export-dynamic was specified, set the dlname.
100784a8d91dcSmrg	if test yes = "$module" || test yes = "$export_dynamic"; then
10079b3e38ee4Smrg	  # On all known operating systems, these are identical.
100804a8d91dcSmrg	  dlname=$soname
10081b3e38ee4Smrg	fi
10082b3e38ee4Smrg      fi
1008350806d53Smrg      ;;
1008450806d53Smrg
10085b3e38ee4Smrg    obj)
100864a8d91dcSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
100874a8d91dcSmrg	func_warning "'-dlopen' is ignored for objects"
10088b3e38ee4Smrg      fi
10089a18ebfb2Smrg
10090b3e38ee4Smrg      case " $deplibs" in
10091b3e38ee4Smrg      *\ -l* | *\ -L*)
100924a8d91dcSmrg	func_warning "'-l' and '-L' are ignored for objects" ;;
10093af1a9c97Smrg      esac
1009450806d53Smrg
10095b3e38ee4Smrg      test -n "$rpath" && \
100964a8d91dcSmrg	func_warning "'-rpath' is ignored for objects"
10097b3e38ee4Smrg
10098b3e38ee4Smrg      test -n "$xrpath" && \
100994a8d91dcSmrg	func_warning "'-R' is ignored for objects"
1010050806d53Smrg
10101b3e38ee4Smrg      test -n "$vinfo" && \
101024a8d91dcSmrg	func_warning "'-version-info' is ignored for objects"
10103af1a9c97Smrg
10104b3e38ee4Smrg      test -n "$release" && \
101054a8d91dcSmrg	func_warning "'-release' is ignored for objects"
10106b3e38ee4Smrg
10107b3e38ee4Smrg      case $output in
10108b3e38ee4Smrg      *.lo)
10109b3e38ee4Smrg	test -n "$objs$old_deplibs" && \
101104a8d91dcSmrg	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
10111b3e38ee4Smrg
10112b3e38ee4Smrg	libobj=$output
10113b3e38ee4Smrg	func_lo2o "$libobj"
10114b3e38ee4Smrg	obj=$func_lo2o_result
10115a18ebfb2Smrg	;;
10116a18ebfb2Smrg      *)
10117b3e38ee4Smrg	libobj=
101184a8d91dcSmrg	obj=$output
1011950806d53Smrg	;;
10120af1a9c97Smrg      esac
1012150806d53Smrg
10122b3e38ee4Smrg      # Delete the old objects.
10123b3e38ee4Smrg      $opt_dry_run || $RM $obj $libobj
1012450806d53Smrg
10125b3e38ee4Smrg      # Objects from convenience libraries.  This assumes
10126b3e38ee4Smrg      # single-version convenience libraries.  Whenever we create
10127b3e38ee4Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
10128b3e38ee4Smrg      # the extraction.
10129b3e38ee4Smrg      reload_conv_objs=
10130b3e38ee4Smrg      gentop=
101314a8d91dcSmrg      # if reload_cmds runs $LD directly, get rid of -Wl from
101324a8d91dcSmrg      # whole_archive_flag_spec and hope we can get by with turning comma
101334a8d91dcSmrg      # into space.
101344a8d91dcSmrg      case $reload_cmds in
101354a8d91dcSmrg        *\$LD[\ \$]*) wl= ;;
101364a8d91dcSmrg      esac
10137b3e38ee4Smrg      if test -n "$convenience"; then
10138b3e38ee4Smrg	if test -n "$whole_archive_flag_spec"; then
10139b3e38ee4Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
101404a8d91dcSmrg	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
101414a8d91dcSmrg	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
10142b3e38ee4Smrg	else
101434a8d91dcSmrg	  gentop=$output_objdir/${obj}x
10144a73423d7Smrg	  func_append generated " $gentop"
10145a18ebfb2Smrg
10146b3e38ee4Smrg	  func_extract_archives $gentop $convenience
10147b3e38ee4Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
10148b3e38ee4Smrg	fi
10149a18ebfb2Smrg      fi
10150a18ebfb2Smrg
10151a73423d7Smrg      # If we're not building shared, we need to use non_pic_objs
101524a8d91dcSmrg      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
10153a73423d7Smrg
10154b3e38ee4Smrg      # Create the old-style object.
101554a8d91dcSmrg      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
10156a18ebfb2Smrg
101574a8d91dcSmrg      output=$obj
10158b3e38ee4Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
10159a18ebfb2Smrg
10160b3e38ee4Smrg      # Exit if we aren't doing a library object file.
10161b3e38ee4Smrg      if test -z "$libobj"; then
10162b3e38ee4Smrg	if test -n "$gentop"; then
10163b3e38ee4Smrg	  func_show_eval '${RM}r "$gentop"'
10164b3e38ee4Smrg	fi
10165b3e38ee4Smrg
10166b3e38ee4Smrg	exit $EXIT_SUCCESS
10167a18ebfb2Smrg      fi
10168b3e38ee4Smrg
101694a8d91dcSmrg      test yes = "$build_libtool_libs" || {
10170b3e38ee4Smrg	if test -n "$gentop"; then
10171b3e38ee4Smrg	  func_show_eval '${RM}r "$gentop"'
10172b3e38ee4Smrg	fi
10173b3e38ee4Smrg
10174b3e38ee4Smrg	# Create an invalid libtool object if no PIC, so that we don't
10175b3e38ee4Smrg	# accidentally link it into a program.
10176b3e38ee4Smrg	# $show "echo timestamp > $libobj"
10177b3e38ee4Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
10178b3e38ee4Smrg	exit $EXIT_SUCCESS
101794a8d91dcSmrg      }
10180b3e38ee4Smrg
101814a8d91dcSmrg      if test -n "$pic_flag" || test default != "$pic_mode"; then
10182b3e38ee4Smrg	# Only do commands if we really have different PIC objects.
10183b3e38ee4Smrg	reload_objs="$libobjs $reload_conv_objs"
101844a8d91dcSmrg	output=$libobj
10185b3e38ee4Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
10186b3e38ee4Smrg      fi
10187b3e38ee4Smrg
10188b3e38ee4Smrg      if test -n "$gentop"; then
10189b3e38ee4Smrg	func_show_eval '${RM}r "$gentop"'
10190b3e38ee4Smrg      fi
10191b3e38ee4Smrg
10192b3e38ee4Smrg      exit $EXIT_SUCCESS
10193a18ebfb2Smrg      ;;
1019450806d53Smrg
10195b3e38ee4Smrg    prog)
10196b3e38ee4Smrg      case $host in
10197b3e38ee4Smrg	*cygwin*) func_stripname '' '.exe' "$output"
10198b3e38ee4Smrg	          output=$func_stripname_result.exe;;
10199b3e38ee4Smrg      esac
10200b3e38ee4Smrg      test -n "$vinfo" && \
102014a8d91dcSmrg	func_warning "'-version-info' is ignored for programs"
1020250806d53Smrg
10203b3e38ee4Smrg      test -n "$release" && \
102044a8d91dcSmrg	func_warning "'-release' is ignored for programs"
1020550806d53Smrg
102064a8d91dcSmrg      $preload \
102074a8d91dcSmrg	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
102084a8d91dcSmrg	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
10209b3e38ee4Smrg
10210b3e38ee4Smrg      case $host in
10211b3e38ee4Smrg      *-*-rhapsody* | *-*-darwin1.[012])
10212b3e38ee4Smrg	# On Rhapsody replace the C library is the System framework
10213a73423d7Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
10214a73423d7Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
10215a18ebfb2Smrg	;;
10216b3e38ee4Smrg      esac
10217a18ebfb2Smrg
10218b3e38ee4Smrg      case $host in
10219b3e38ee4Smrg      *-*-darwin*)
10220b3e38ee4Smrg	# Don't allow lazy linking, it breaks C++ global constructors
10221b3e38ee4Smrg	# But is supposedly fixed on 10.4 or later (yay!).
102224a8d91dcSmrg	if test CXX = "$tagname"; then
10223b3e38ee4Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
10224b3e38ee4Smrg	    10.[0123])
102254a8d91dcSmrg	      func_append compile_command " $wl-bind_at_load"
102264a8d91dcSmrg	      func_append finalize_command " $wl-bind_at_load"
10227b3e38ee4Smrg	    ;;
10228b3e38ee4Smrg	  esac
10229a18ebfb2Smrg	fi
10230b3e38ee4Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
10231a73423d7Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10232a73423d7Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10233b3e38ee4Smrg	;;
10234b3e38ee4Smrg      esac
10235a18ebfb2Smrg
10236a18ebfb2Smrg
10237b3e38ee4Smrg      # move library search paths that coincide with paths to not yet
10238b3e38ee4Smrg      # installed libraries to the beginning of the library search list
10239b3e38ee4Smrg      new_libs=
10240b3e38ee4Smrg      for path in $notinst_path; do
10241b3e38ee4Smrg	case " $new_libs " in
10242b3e38ee4Smrg	*" -L$path/$objdir "*) ;;
10243b3e38ee4Smrg	*)
10244b3e38ee4Smrg	  case " $compile_deplibs " in
10245b3e38ee4Smrg	  *" -L$path/$objdir "*)
10246a73423d7Smrg	    func_append new_libs " -L$path/$objdir" ;;
10247af1a9c97Smrg	  esac
10248b3e38ee4Smrg	  ;;
10249b3e38ee4Smrg	esac
10250b3e38ee4Smrg      done
10251b3e38ee4Smrg      for deplib in $compile_deplibs; do
10252b3e38ee4Smrg	case $deplib in
10253b3e38ee4Smrg	-L*)
10254b3e38ee4Smrg	  case " $new_libs " in
10255b3e38ee4Smrg	  *" $deplib "*) ;;
10256a73423d7Smrg	  *) func_append new_libs " $deplib" ;;
10257af1a9c97Smrg	  esac
10258b3e38ee4Smrg	  ;;
10259a73423d7Smrg	*) func_append new_libs " $deplib" ;;
10260b3e38ee4Smrg	esac
10261b3e38ee4Smrg      done
102624a8d91dcSmrg      compile_deplibs=$new_libs
1026350806d53Smrg
10264a18ebfb2Smrg
10265a73423d7Smrg      func_append compile_command " $compile_deplibs"
10266a73423d7Smrg      func_append finalize_command " $finalize_deplibs"
10267a18ebfb2Smrg
10268b3e38ee4Smrg      if test -n "$rpath$xrpath"; then
10269b3e38ee4Smrg	# If the user specified any rpath flags, then add them.
10270b3e38ee4Smrg	for libdir in $rpath $xrpath; do
10271b3e38ee4Smrg	  # This is the magic to use -rpath.
10272b3e38ee4Smrg	  case "$finalize_rpath " in
10273b3e38ee4Smrg	  *" $libdir "*) ;;
10274a73423d7Smrg	  *) func_append finalize_rpath " $libdir" ;;
10275b3e38ee4Smrg	  esac
10276b3e38ee4Smrg	done
10277b3e38ee4Smrg      fi
10278a18ebfb2Smrg
10279b3e38ee4Smrg      # Now hardcode the library paths
10280b3e38ee4Smrg      rpath=
10281b3e38ee4Smrg      hardcode_libdirs=
10282b3e38ee4Smrg      for libdir in $compile_rpath $finalize_rpath; do
10283b3e38ee4Smrg	if test -n "$hardcode_libdir_flag_spec"; then
10284b3e38ee4Smrg	  if test -n "$hardcode_libdir_separator"; then
10285b3e38ee4Smrg	    if test -z "$hardcode_libdirs"; then
102864a8d91dcSmrg	      hardcode_libdirs=$libdir
10287b3e38ee4Smrg	    else
10288b3e38ee4Smrg	      # Just accumulate the unique libdirs.
10289b3e38ee4Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10290b3e38ee4Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10291b3e38ee4Smrg		;;
10292b3e38ee4Smrg	      *)
10293a73423d7Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10294b3e38ee4Smrg		;;
10295b3e38ee4Smrg	      esac
10296b3e38ee4Smrg	    fi
10297a18ebfb2Smrg	  else
10298b3e38ee4Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10299a73423d7Smrg	    func_append rpath " $flag"
10300a18ebfb2Smrg	  fi
10301b3e38ee4Smrg	elif test -n "$runpath_var"; then
10302b3e38ee4Smrg	  case "$perm_rpath " in
10303b3e38ee4Smrg	  *" $libdir "*) ;;
10304a73423d7Smrg	  *) func_append perm_rpath " $libdir" ;;
10305b3e38ee4Smrg	  esac
10306b3e38ee4Smrg	fi
10307b3e38ee4Smrg	case $host in
10308b3e38ee4Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
103094a8d91dcSmrg	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
10310b3e38ee4Smrg	  case :$dllsearchpath: in
10311b3e38ee4Smrg	  *":$libdir:"*) ;;
10312b3e38ee4Smrg	  ::) dllsearchpath=$libdir;;
10313a73423d7Smrg	  *) func_append dllsearchpath ":$libdir";;
10314b3e38ee4Smrg	  esac
10315b3e38ee4Smrg	  case :$dllsearchpath: in
10316b3e38ee4Smrg	  *":$testbindir:"*) ;;
10317b3e38ee4Smrg	  ::) dllsearchpath=$testbindir;;
10318a73423d7Smrg	  *) func_append dllsearchpath ":$testbindir";;
10319b3e38ee4Smrg	  esac
10320b3e38ee4Smrg	  ;;
10321b3e38ee4Smrg	esac
10322b3e38ee4Smrg      done
10323b3e38ee4Smrg      # Substitute the hardcoded libdirs into the rpath.
10324b3e38ee4Smrg      if test -n "$hardcode_libdir_separator" &&
10325b3e38ee4Smrg	 test -n "$hardcode_libdirs"; then
103264a8d91dcSmrg	libdir=$hardcode_libdirs
10327b3e38ee4Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
10328b3e38ee4Smrg      fi
103294a8d91dcSmrg      compile_rpath=$rpath
10330a18ebfb2Smrg
10331b3e38ee4Smrg      rpath=
10332b3e38ee4Smrg      hardcode_libdirs=
10333b3e38ee4Smrg      for libdir in $finalize_rpath; do
10334b3e38ee4Smrg	if test -n "$hardcode_libdir_flag_spec"; then
10335b3e38ee4Smrg	  if test -n "$hardcode_libdir_separator"; then
10336b3e38ee4Smrg	    if test -z "$hardcode_libdirs"; then
103374a8d91dcSmrg	      hardcode_libdirs=$libdir
10338b3e38ee4Smrg	    else
10339b3e38ee4Smrg	      # Just accumulate the unique libdirs.
10340b3e38ee4Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10341b3e38ee4Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10342b3e38ee4Smrg		;;
10343b3e38ee4Smrg	      *)
10344a73423d7Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10345b3e38ee4Smrg		;;
10346b3e38ee4Smrg	      esac
10347b3e38ee4Smrg	    fi
1034850806d53Smrg	  else
10349b3e38ee4Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10350a73423d7Smrg	    func_append rpath " $flag"
1035150806d53Smrg	  fi
10352b3e38ee4Smrg	elif test -n "$runpath_var"; then
10353b3e38ee4Smrg	  case "$finalize_perm_rpath " in
10354b3e38ee4Smrg	  *" $libdir "*) ;;
10355a73423d7Smrg	  *) func_append finalize_perm_rpath " $libdir" ;;
10356b3e38ee4Smrg	  esac
1035750806d53Smrg	fi
10358b3e38ee4Smrg      done
10359b3e38ee4Smrg      # Substitute the hardcoded libdirs into the rpath.
10360b3e38ee4Smrg      if test -n "$hardcode_libdir_separator" &&
10361b3e38ee4Smrg	 test -n "$hardcode_libdirs"; then
103624a8d91dcSmrg	libdir=$hardcode_libdirs
10363b3e38ee4Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
10364b3e38ee4Smrg      fi
103654a8d91dcSmrg      finalize_rpath=$rpath
1036650806d53Smrg
103674a8d91dcSmrg      if test -n "$libobjs" && test yes = "$build_old_libs"; then
10368b3e38ee4Smrg	# Transform all the library objects into standard objects.
10369a73423d7Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10370a73423d7Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10371b3e38ee4Smrg      fi
1037250806d53Smrg
103734a8d91dcSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" false
1037450806d53Smrg
10375b3e38ee4Smrg      # template prelinking step
10376b3e38ee4Smrg      if test -n "$prelink_cmds"; then
10377b3e38ee4Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
10378b3e38ee4Smrg      fi
1037950806d53Smrg
103804a8d91dcSmrg      wrappers_required=:
10381b3e38ee4Smrg      case $host in
10382a73423d7Smrg      *cegcc* | *mingw32ce*)
10383a73423d7Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
103844a8d91dcSmrg        wrappers_required=false
10385a73423d7Smrg        ;;
10386b3e38ee4Smrg      *cygwin* | *mingw* )
103874a8d91dcSmrg        test yes = "$build_libtool_libs" || wrappers_required=false
10388b3e38ee4Smrg        ;;
10389b3e38ee4Smrg      *)
103904a8d91dcSmrg        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
103914a8d91dcSmrg          wrappers_required=false
10392b3e38ee4Smrg        fi
10393b3e38ee4Smrg        ;;
10394b3e38ee4Smrg      esac
103954a8d91dcSmrg      $wrappers_required || {
10396b3e38ee4Smrg	# Replace the output file specification.
10397a73423d7Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
103984a8d91dcSmrg	link_command=$compile_command$compile_rpath
1039950806d53Smrg
10400b3e38ee4Smrg	# We have no uninstalled library dependencies, so finalize right now.
10401b3e38ee4Smrg	exit_status=0
10402b3e38ee4Smrg	func_show_eval "$link_command" 'exit_status=$?'
1040350806d53Smrg
10404a73423d7Smrg	if test -n "$postlink_cmds"; then
10405a73423d7Smrg	  func_to_tool_file "$output"
10406a73423d7Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10407a73423d7Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
10408a73423d7Smrg	fi
10409a73423d7Smrg
10410b3e38ee4Smrg	# Delete the generated files.
104114a8d91dcSmrg	if test -f "$output_objdir/${outputname}S.$objext"; then
104124a8d91dcSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
1041350806d53Smrg	fi
1041450806d53Smrg
10415b3e38ee4Smrg	exit $exit_status
104164a8d91dcSmrg      }
1041750806d53Smrg
10418b3e38ee4Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
10419b3e38ee4Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
10420b3e38ee4Smrg      fi
10421b3e38ee4Smrg      if test -n "$finalize_shlibpath"; then
10422b3e38ee4Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
10423b3e38ee4Smrg      fi
10424a18ebfb2Smrg
10425b3e38ee4Smrg      compile_var=
10426b3e38ee4Smrg      finalize_var=
10427b3e38ee4Smrg      if test -n "$runpath_var"; then
10428b3e38ee4Smrg	if test -n "$perm_rpath"; then
10429b3e38ee4Smrg	  # We should set the runpath_var.
10430b3e38ee4Smrg	  rpath=
10431b3e38ee4Smrg	  for dir in $perm_rpath; do
10432a73423d7Smrg	    func_append rpath "$dir:"
10433b3e38ee4Smrg	  done
10434b3e38ee4Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
1043550806d53Smrg	fi
10436b3e38ee4Smrg	if test -n "$finalize_perm_rpath"; then
10437b3e38ee4Smrg	  # We should set the runpath_var.
10438b3e38ee4Smrg	  rpath=
10439b3e38ee4Smrg	  for dir in $finalize_perm_rpath; do
10440a73423d7Smrg	    func_append rpath "$dir:"
10441b3e38ee4Smrg	  done
10442b3e38ee4Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
1044350806d53Smrg	fi
10444b3e38ee4Smrg      fi
1044550806d53Smrg
104464a8d91dcSmrg      if test yes = "$no_install"; then
10447b3e38ee4Smrg	# We don't need to create a wrapper script.
104484a8d91dcSmrg	link_command=$compile_var$compile_command$compile_rpath
10449b3e38ee4Smrg	# Replace the output file specification.
10450a73423d7Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10451b3e38ee4Smrg	# Delete the old output file.
10452b3e38ee4Smrg	$opt_dry_run || $RM $output
10453b3e38ee4Smrg	# Link the executable and exit
10454b3e38ee4Smrg	func_show_eval "$link_command" 'exit $?'
10455a73423d7Smrg
10456a73423d7Smrg	if test -n "$postlink_cmds"; then
10457a73423d7Smrg	  func_to_tool_file "$output"
10458a73423d7Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10459a73423d7Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
10460a73423d7Smrg	fi
10461a73423d7Smrg
10462a18ebfb2Smrg	exit $EXIT_SUCCESS
10463b3e38ee4Smrg      fi
10464af1a9c97Smrg
104654a8d91dcSmrg      case $hardcode_action,$fast_install in
104664a8d91dcSmrg        relink,*)
104674a8d91dcSmrg	  # Fast installation is not supported
104684a8d91dcSmrg	  link_command=$compile_var$compile_command$compile_rpath
104694a8d91dcSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
10470b3e38ee4Smrg
104714a8d91dcSmrg	  func_warning "this platform does not like uninstalled shared libraries"
104724a8d91dcSmrg	  func_warning "'$output' will be relinked during installation"
104734a8d91dcSmrg	  ;;
104744a8d91dcSmrg        *,yes)
104754a8d91dcSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
104764a8d91dcSmrg	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
104774a8d91dcSmrg          ;;
104784a8d91dcSmrg	*,no)
104794a8d91dcSmrg	  link_command=$compile_var$compile_command$compile_rpath
104804a8d91dcSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
104814a8d91dcSmrg          ;;
104824a8d91dcSmrg	*,needless)
104834a8d91dcSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
104844a8d91dcSmrg	  relink_command=
104854a8d91dcSmrg          ;;
104864a8d91dcSmrg      esac
1048750806d53Smrg
10488b3e38ee4Smrg      # Replace the output file specification.
10489a73423d7Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
1049050806d53Smrg
10491b3e38ee4Smrg      # Delete the old output files.
10492b3e38ee4Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
1049350806d53Smrg
10494b3e38ee4Smrg      func_show_eval "$link_command" 'exit $?'
10495a18ebfb2Smrg
10496a73423d7Smrg      if test -n "$postlink_cmds"; then
10497a73423d7Smrg	func_to_tool_file "$output_objdir/$outputname"
10498a73423d7Smrg	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'`
10499a73423d7Smrg	func_execute_cmds "$postlink_cmds" 'exit $?'
10500a73423d7Smrg      fi
10501a73423d7Smrg
10502b3e38ee4Smrg      # Now create the wrapper script.
10503b3e38ee4Smrg      func_verbose "creating $output"
10504a18ebfb2Smrg
10505b3e38ee4Smrg      # Quote the relink command for shipping.
10506b3e38ee4Smrg      if test -n "$relink_command"; then
10507b3e38ee4Smrg	# Preserve any variables that may affect compiler behavior
10508b3e38ee4Smrg	for var in $variables_saved_for_relink; do
10509b3e38ee4Smrg	  if eval test -z \"\${$var+set}\"; then
10510b3e38ee4Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10511b3e38ee4Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
10512b3e38ee4Smrg	    relink_command="$var=; export $var; $relink_command"
1051350806d53Smrg	  else
10514b3e38ee4Smrg	    func_quote_for_eval "$var_value"
10515b3e38ee4Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
1051650806d53Smrg	  fi
10517b3e38ee4Smrg	done
10518b3e38ee4Smrg	relink_command="(cd `pwd`; $relink_command)"
10519a73423d7Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10520b3e38ee4Smrg      fi
10521b3e38ee4Smrg
10522b3e38ee4Smrg      # Only actually do things if not in dry run mode.
10523b3e38ee4Smrg      $opt_dry_run || {
10524b3e38ee4Smrg	# win32 will think the script is a binary if it has
10525b3e38ee4Smrg	# a .exe suffix, so we strip it off here.
10526b3e38ee4Smrg	case $output in
10527b3e38ee4Smrg	  *.exe) func_stripname '' '.exe' "$output"
10528b3e38ee4Smrg	         output=$func_stripname_result ;;
10529b3e38ee4Smrg	esac
10530b3e38ee4Smrg	# test for cygwin because mv fails w/o .exe extensions
10531b3e38ee4Smrg	case $host in
10532b3e38ee4Smrg	  *cygwin*)
10533b3e38ee4Smrg	    exeext=.exe
10534b3e38ee4Smrg	    func_stripname '' '.exe' "$outputname"
10535b3e38ee4Smrg	    outputname=$func_stripname_result ;;
10536b3e38ee4Smrg	  *) exeext= ;;
1053750806d53Smrg	esac
10538b3e38ee4Smrg	case $host in
10539b3e38ee4Smrg	  *cygwin* | *mingw* )
10540b3e38ee4Smrg	    func_dirname_and_basename "$output" "" "."
10541b3e38ee4Smrg	    output_name=$func_basename_result
10542b3e38ee4Smrg	    output_path=$func_dirname_result
105434a8d91dcSmrg	    cwrappersource=$output_path/$objdir/lt-$output_name.c
105444a8d91dcSmrg	    cwrapper=$output_path/$output_name.exe
10545b3e38ee4Smrg	    $RM $cwrappersource $cwrapper
10546b3e38ee4Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
10547b3e38ee4Smrg
10548b3e38ee4Smrg	    func_emit_cwrapperexe_src > $cwrappersource
10549b3e38ee4Smrg
10550b3e38ee4Smrg	    # The wrapper executable is built using the $host compiler,
10551b3e38ee4Smrg	    # because it contains $host paths and files. If cross-
10552b3e38ee4Smrg	    # compiling, it, like the target executable, must be
10553b3e38ee4Smrg	    # executed on the $host or under an emulation environment.
10554b3e38ee4Smrg	    $opt_dry_run || {
10555b3e38ee4Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
10556b3e38ee4Smrg	      $STRIP $cwrapper
10557b3e38ee4Smrg	    }
1055850806d53Smrg
10559b3e38ee4Smrg	    # Now, create the wrapper script for func_source use:
10560b3e38ee4Smrg	    func_ltwrapper_scriptname $cwrapper
10561b3e38ee4Smrg	    $RM $func_ltwrapper_scriptname_result
10562b3e38ee4Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
10563b3e38ee4Smrg	    $opt_dry_run || {
10564b3e38ee4Smrg	      # note: this script will not be executed, so do not chmod.
105654a8d91dcSmrg	      if test "x$build" = "x$host"; then
10566b3e38ee4Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
10567b3e38ee4Smrg	      else
10568b3e38ee4Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
10569b3e38ee4Smrg	      fi
10570b3e38ee4Smrg	    }
10571b3e38ee4Smrg	  ;;
10572b3e38ee4Smrg	  * )
10573b3e38ee4Smrg	    $RM $output
10574b3e38ee4Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
1057550806d53Smrg
10576b3e38ee4Smrg	    func_emit_wrapper no > $output
10577b3e38ee4Smrg	    chmod +x $output
10578b3e38ee4Smrg	  ;;
10579b3e38ee4Smrg	esac
10580b3e38ee4Smrg      }
10581b3e38ee4Smrg      exit $EXIT_SUCCESS
10582b3e38ee4Smrg      ;;
10583b3e38ee4Smrg    esac
1058450806d53Smrg
10585b3e38ee4Smrg    # See if we need to build an old-fashioned archive.
10586b3e38ee4Smrg    for oldlib in $oldlibs; do
1058750806d53Smrg
105884a8d91dcSmrg      case $build_libtool_libs in
105894a8d91dcSmrg        convenience)
105904a8d91dcSmrg	  oldobjs="$libobjs_save $symfileobj"
105914a8d91dcSmrg	  addlibs=$convenience
10592b3e38ee4Smrg	  build_libtool_libs=no
105934a8d91dcSmrg	  ;;
105944a8d91dcSmrg	module)
105954a8d91dcSmrg	  oldobjs=$libobjs_save
105964a8d91dcSmrg	  addlibs=$old_convenience
105974a8d91dcSmrg	  build_libtool_libs=no
105984a8d91dcSmrg          ;;
105994a8d91dcSmrg	*)
10600b3e38ee4Smrg	  oldobjs="$old_deplibs $non_pic_objects"
106014a8d91dcSmrg	  $preload && test -f "$symfileobj" \
106024a8d91dcSmrg	    && func_append oldobjs " $symfileobj"
106034a8d91dcSmrg	  addlibs=$old_convenience
106044a8d91dcSmrg	  ;;
106054a8d91dcSmrg      esac
1060650806d53Smrg
10607b3e38ee4Smrg      if test -n "$addlibs"; then
106084a8d91dcSmrg	gentop=$output_objdir/${outputname}x
10609a73423d7Smrg	func_append generated " $gentop"
1061050806d53Smrg
10611b3e38ee4Smrg	func_extract_archives $gentop $addlibs
10612a73423d7Smrg	func_append oldobjs " $func_extract_archives_result"
10613b3e38ee4Smrg      fi
1061450806d53Smrg
10615b3e38ee4Smrg      # Do each command in the archive commands.
106164a8d91dcSmrg      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
10617b3e38ee4Smrg	cmds=$old_archive_from_new_cmds
10618b3e38ee4Smrg      else
1061950806d53Smrg
10620b3e38ee4Smrg	# Add any objects from preloaded convenience libraries
10621b3e38ee4Smrg	if test -n "$dlprefiles"; then
106224a8d91dcSmrg	  gentop=$output_objdir/${outputname}x
10623a73423d7Smrg	  func_append generated " $gentop"
1062450806d53Smrg
10625b3e38ee4Smrg	  func_extract_archives $gentop $dlprefiles
10626a73423d7Smrg	  func_append oldobjs " $func_extract_archives_result"
10627b3e38ee4Smrg	fi
1062850806d53Smrg
10629b3e38ee4Smrg	# POSIX demands no paths to be encoded in archives.  We have
10630b3e38ee4Smrg	# to avoid creating archives with duplicate basenames if we
10631b3e38ee4Smrg	# might have to extract them afterwards, e.g., when creating a
10632b3e38ee4Smrg	# static archive out of a convenience library, or when linking
10633b3e38ee4Smrg	# the entirety of a libtool archive into another (currently
10634b3e38ee4Smrg	# not supported by libtool).
10635b3e38ee4Smrg	if (for obj in $oldobjs
10636b3e38ee4Smrg	    do
10637b3e38ee4Smrg	      func_basename "$obj"
10638b3e38ee4Smrg	      $ECHO "$func_basename_result"
10639b3e38ee4Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
10640b3e38ee4Smrg	  :
10641b3e38ee4Smrg	else
10642a73423d7Smrg	  echo "copying selected object files to avoid basename conflicts..."
106434a8d91dcSmrg	  gentop=$output_objdir/${outputname}x
10644a73423d7Smrg	  func_append generated " $gentop"
10645b3e38ee4Smrg	  func_mkdir_p "$gentop"
10646b3e38ee4Smrg	  save_oldobjs=$oldobjs
10647b3e38ee4Smrg	  oldobjs=
10648b3e38ee4Smrg	  counter=1
10649b3e38ee4Smrg	  for obj in $save_oldobjs
10650b3e38ee4Smrg	  do
10651b3e38ee4Smrg	    func_basename "$obj"
106524a8d91dcSmrg	    objbase=$func_basename_result
10653b3e38ee4Smrg	    case " $oldobjs " in
10654b3e38ee4Smrg	    " ") oldobjs=$obj ;;
10655b3e38ee4Smrg	    *[\ /]"$objbase "*)
10656b3e38ee4Smrg	      while :; do
10657b3e38ee4Smrg		# Make sure we don't pick an alternate name that also
10658b3e38ee4Smrg		# overlaps.
10659b3e38ee4Smrg		newobj=lt$counter-$objbase
10660b3e38ee4Smrg		func_arith $counter + 1
10661b3e38ee4Smrg		counter=$func_arith_result
10662b3e38ee4Smrg		case " $oldobjs " in
10663b3e38ee4Smrg		*[\ /]"$newobj "*) ;;
10664b3e38ee4Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
10665b3e38ee4Smrg		esac
10666b3e38ee4Smrg	      done
10667b3e38ee4Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
10668a73423d7Smrg	      func_append oldobjs " $gentop/$newobj"
10669b3e38ee4Smrg	      ;;
10670a73423d7Smrg	    *) func_append oldobjs " $obj" ;;
10671b3e38ee4Smrg	    esac
1067250806d53Smrg	  done
10673af1a9c97Smrg	fi
10674a73423d7Smrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
10675a73423d7Smrg	tool_oldlib=$func_to_tool_file_result
10676b3e38ee4Smrg	eval cmds=\"$old_archive_cmds\"
10677a18ebfb2Smrg
10678b3e38ee4Smrg	func_len " $cmds"
10679b3e38ee4Smrg	len=$func_len_result
10680b3e38ee4Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
10681b3e38ee4Smrg	  cmds=$old_archive_cmds
10682a73423d7Smrg	elif test -n "$archiver_list_spec"; then
10683a73423d7Smrg	  func_verbose "using command file archive linking..."
10684a73423d7Smrg	  for obj in $oldobjs
10685a73423d7Smrg	  do
10686a73423d7Smrg	    func_to_tool_file "$obj"
10687a73423d7Smrg	    $ECHO "$func_to_tool_file_result"
10688a73423d7Smrg	  done > $output_objdir/$libname.libcmd
10689a73423d7Smrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
10690a73423d7Smrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
10691a73423d7Smrg	  cmds=$old_archive_cmds
10692b3e38ee4Smrg	else
10693b3e38ee4Smrg	  # the command line is too long to link in one step, link in parts
10694b3e38ee4Smrg	  func_verbose "using piecewise archive linking..."
10695b3e38ee4Smrg	  save_RANLIB=$RANLIB
10696b3e38ee4Smrg	  RANLIB=:
10697b3e38ee4Smrg	  objlist=
10698b3e38ee4Smrg	  concat_cmds=
10699b3e38ee4Smrg	  save_oldobjs=$oldobjs
10700b3e38ee4Smrg	  oldobjs=
10701b3e38ee4Smrg	  # Is there a better way of finding the last object in the list?
10702b3e38ee4Smrg	  for obj in $save_oldobjs
10703b3e38ee4Smrg	  do
10704b3e38ee4Smrg	    last_oldobj=$obj
10705b3e38ee4Smrg	  done
10706b3e38ee4Smrg	  eval test_cmds=\"$old_archive_cmds\"
10707b3e38ee4Smrg	  func_len " $test_cmds"
10708b3e38ee4Smrg	  len0=$func_len_result
10709b3e38ee4Smrg	  len=$len0
10710b3e38ee4Smrg	  for obj in $save_oldobjs
10711b3e38ee4Smrg	  do
10712b3e38ee4Smrg	    func_len " $obj"
10713b3e38ee4Smrg	    func_arith $len + $func_len_result
10714b3e38ee4Smrg	    len=$func_arith_result
10715b3e38ee4Smrg	    func_append objlist " $obj"
10716b3e38ee4Smrg	    if test "$len" -lt "$max_cmd_len"; then
10717b3e38ee4Smrg	      :
10718b3e38ee4Smrg	    else
10719b3e38ee4Smrg	      # the above command should be used before it gets too long
10720b3e38ee4Smrg	      oldobjs=$objlist
107214a8d91dcSmrg	      if test "$obj" = "$last_oldobj"; then
10722b3e38ee4Smrg		RANLIB=$save_RANLIB
10723b3e38ee4Smrg	      fi
10724b3e38ee4Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
107254a8d91dcSmrg	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
10726b3e38ee4Smrg	      objlist=
10727b3e38ee4Smrg	      len=$len0
10728b3e38ee4Smrg	    fi
10729b3e38ee4Smrg	  done
10730b3e38ee4Smrg	  RANLIB=$save_RANLIB
10731b3e38ee4Smrg	  oldobjs=$objlist
107324a8d91dcSmrg	  if test -z "$oldobjs"; then
10733b3e38ee4Smrg	    eval cmds=\"\$concat_cmds\"
10734b3e38ee4Smrg	  else
10735b3e38ee4Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
10736b3e38ee4Smrg	  fi
10737b3e38ee4Smrg	fi
10738b3e38ee4Smrg      fi
10739b3e38ee4Smrg      func_execute_cmds "$cmds" 'exit $?'
1074050806d53Smrg    done
1074150806d53Smrg
10742b3e38ee4Smrg    test -n "$generated" && \
10743b3e38ee4Smrg      func_show_eval "${RM}r$generated"
1074450806d53Smrg
10745b3e38ee4Smrg    # Now create the libtool archive.
10746b3e38ee4Smrg    case $output in
10747b3e38ee4Smrg    *.la)
10748b3e38ee4Smrg      old_library=
107494a8d91dcSmrg      test yes = "$build_old_libs" && old_library=$libname.$libext
10750b3e38ee4Smrg      func_verbose "creating $output"
10751af1a9c97Smrg
10752b3e38ee4Smrg      # Preserve any variables that may affect compiler behavior
10753b3e38ee4Smrg      for var in $variables_saved_for_relink; do
10754b3e38ee4Smrg	if eval test -z \"\${$var+set}\"; then
10755b3e38ee4Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10756b3e38ee4Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
10757b3e38ee4Smrg	  relink_command="$var=; export $var; $relink_command"
10758a18ebfb2Smrg	else
10759b3e38ee4Smrg	  func_quote_for_eval "$var_value"
10760b3e38ee4Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10761a18ebfb2Smrg	fi
10762b3e38ee4Smrg      done
10763b3e38ee4Smrg      # Quote the link command for shipping.
107644a8d91dcSmrg      relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
10765a73423d7Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
107664a8d91dcSmrg      if test yes = "$hardcode_automatic"; then
10767b3e38ee4Smrg	relink_command=
10768b3e38ee4Smrg      fi
1076950806d53Smrg
10770b3e38ee4Smrg      # Only create the output if not a dry run.
10771b3e38ee4Smrg      $opt_dry_run || {
10772b3e38ee4Smrg	for installed in no yes; do
107734a8d91dcSmrg	  if test yes = "$installed"; then
10774b3e38ee4Smrg	    if test -z "$install_libdir"; then
10775b3e38ee4Smrg	      break
10776b3e38ee4Smrg	    fi
107774a8d91dcSmrg	    output=$output_objdir/${outputname}i
10778b3e38ee4Smrg	    # Replace all uninstalled libtool libraries with the installed ones
10779b3e38ee4Smrg	    newdependency_libs=
10780b3e38ee4Smrg	    for deplib in $dependency_libs; do
10781b3e38ee4Smrg	      case $deplib in
10782b3e38ee4Smrg	      *.la)
10783b3e38ee4Smrg		func_basename "$deplib"
107844a8d91dcSmrg		name=$func_basename_result
10785a73423d7Smrg		func_resolve_sysroot "$deplib"
107864a8d91dcSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
10787b3e38ee4Smrg		test -z "$libdir" && \
107884a8d91dcSmrg		  func_fatal_error "'$deplib' is not a valid libtool archive"
10789a73423d7Smrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
10790a73423d7Smrg		;;
10791a73423d7Smrg	      -L*)
10792a73423d7Smrg		func_stripname -L '' "$deplib"
10793a73423d7Smrg		func_replace_sysroot "$func_stripname_result"
10794a73423d7Smrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
10795b3e38ee4Smrg		;;
10796a73423d7Smrg	      -R*)
10797a73423d7Smrg		func_stripname -R '' "$deplib"
10798a73423d7Smrg		func_replace_sysroot "$func_stripname_result"
10799a73423d7Smrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
10800a73423d7Smrg		;;
10801a73423d7Smrg	      *) func_append newdependency_libs " $deplib" ;;
10802b3e38ee4Smrg	      esac
10803b3e38ee4Smrg	    done
108044a8d91dcSmrg	    dependency_libs=$newdependency_libs
10805b3e38ee4Smrg	    newdlfiles=
10806b3e38ee4Smrg
10807b3e38ee4Smrg	    for lib in $dlfiles; do
10808b3e38ee4Smrg	      case $lib in
10809b3e38ee4Smrg	      *.la)
10810b3e38ee4Smrg	        func_basename "$lib"
108114a8d91dcSmrg		name=$func_basename_result
108124a8d91dcSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10813b3e38ee4Smrg		test -z "$libdir" && \
108144a8d91dcSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
10815a73423d7Smrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
10816b3e38ee4Smrg		;;
10817a73423d7Smrg	      *) func_append newdlfiles " $lib" ;;
10818b3e38ee4Smrg	      esac
10819b3e38ee4Smrg	    done
108204a8d91dcSmrg	    dlfiles=$newdlfiles
10821b3e38ee4Smrg	    newdlprefiles=
10822b3e38ee4Smrg	    for lib in $dlprefiles; do
10823b3e38ee4Smrg	      case $lib in
10824b3e38ee4Smrg	      *.la)
10825b3e38ee4Smrg		# Only pass preopened files to the pseudo-archive (for
10826b3e38ee4Smrg		# eventual linking with the app. that links it) if we
10827b3e38ee4Smrg		# didn't already link the preopened objects directly into
10828b3e38ee4Smrg		# the library:
10829b3e38ee4Smrg		func_basename "$lib"
108304a8d91dcSmrg		name=$func_basename_result
108314a8d91dcSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10832b3e38ee4Smrg		test -z "$libdir" && \
108334a8d91dcSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
10834a73423d7Smrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
10835b3e38ee4Smrg		;;
10836b3e38ee4Smrg	      esac
10837b3e38ee4Smrg	    done
108384a8d91dcSmrg	    dlprefiles=$newdlprefiles
10839b3e38ee4Smrg	  else
10840b3e38ee4Smrg	    newdlfiles=
10841b3e38ee4Smrg	    for lib in $dlfiles; do
10842b3e38ee4Smrg	      case $lib in
108434a8d91dcSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10844b3e38ee4Smrg		*) abs=`pwd`"/$lib" ;;
10845b3e38ee4Smrg	      esac
10846a73423d7Smrg	      func_append newdlfiles " $abs"
10847b3e38ee4Smrg	    done
108484a8d91dcSmrg	    dlfiles=$newdlfiles
10849b3e38ee4Smrg	    newdlprefiles=
10850b3e38ee4Smrg	    for lib in $dlprefiles; do
10851b3e38ee4Smrg	      case $lib in
108524a8d91dcSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10853b3e38ee4Smrg		*) abs=`pwd`"/$lib" ;;
10854b3e38ee4Smrg	      esac
10855a73423d7Smrg	      func_append newdlprefiles " $abs"
10856b3e38ee4Smrg	    done
108574a8d91dcSmrg	    dlprefiles=$newdlprefiles
10858b3e38ee4Smrg	  fi
10859b3e38ee4Smrg	  $RM $output
10860b3e38ee4Smrg	  # place dlname in correct position for cygwin
10861a73423d7Smrg	  # In fact, it would be nice if we could use this code for all target
10862a73423d7Smrg	  # systems that can't hard-code library paths into their executables
10863a73423d7Smrg	  # and that have no shared library path variable independent of PATH,
10864a73423d7Smrg	  # but it turns out we can't easily determine that from inspecting
10865a73423d7Smrg	  # libtool variables, so we have to hard-code the OSs to which it
10866a73423d7Smrg	  # applies here; at the moment, that means platforms that use the PE
10867a73423d7Smrg	  # object format with DLL files.  See the long comment at the top of
10868a73423d7Smrg	  # tests/bindir.at for full details.
10869b3e38ee4Smrg	  tdlname=$dlname
10870b3e38ee4Smrg	  case $host,$output,$installed,$module,$dlname in
10871a73423d7Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
10872a73423d7Smrg	      # If a -bindir argument was supplied, place the dll there.
108734a8d91dcSmrg	      if test -n "$bindir"; then
10874a73423d7Smrg		func_relative_path "$install_libdir" "$bindir"
108754a8d91dcSmrg		tdlname=$func_relative_path_result/$dlname
10876a73423d7Smrg	      else
10877a73423d7Smrg		# Otherwise fall back on heuristic.
10878a73423d7Smrg		tdlname=../bin/$dlname
10879a73423d7Smrg	      fi
10880a73423d7Smrg	      ;;
10881b3e38ee4Smrg	  esac
10882b3e38ee4Smrg	  $ECHO > $output "\
10883b3e38ee4Smrg# $outputname - a libtool library file
108844a8d91dcSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
10885b3e38ee4Smrg#
10886b3e38ee4Smrg# Please DO NOT delete this file!
10887b3e38ee4Smrg# It is necessary for linking the library.
1088850806d53Smrg
10889b3e38ee4Smrg# The name that we can dlopen(3).
10890b3e38ee4Smrgdlname='$tdlname'
1089150806d53Smrg
10892b3e38ee4Smrg# Names of this library.
10893b3e38ee4Smrglibrary_names='$library_names'
1089450806d53Smrg
10895b3e38ee4Smrg# The name of the static archive.
10896b3e38ee4Smrgold_library='$old_library'
1089750806d53Smrg
108984a8d91dcSmrg# Linker flags that cannot go in dependency_libs.
10899b3e38ee4Smrginherited_linker_flags='$new_inherited_linker_flags'
1090050806d53Smrg
10901b3e38ee4Smrg# Libraries that this one depends upon.
10902b3e38ee4Smrgdependency_libs='$dependency_libs'
1090350806d53Smrg
10904b3e38ee4Smrg# Names of additional weak libraries provided by this library
10905b3e38ee4Smrgweak_library_names='$weak_libs'
1090650806d53Smrg
10907b3e38ee4Smrg# Version information for $libname.
10908b3e38ee4Smrgcurrent=$current
10909b3e38ee4Smrgage=$age
10910b3e38ee4Smrgrevision=$revision
1091150806d53Smrg
10912b3e38ee4Smrg# Is this an already installed library?
10913b3e38ee4Smrginstalled=$installed
1091450806d53Smrg
10915b3e38ee4Smrg# Should we warn about portability when linking against -modules?
10916b3e38ee4Smrgshouldnotlink=$module
1091750806d53Smrg
10918b3e38ee4Smrg# Files to dlopen/dlpreopen
10919b3e38ee4Smrgdlopen='$dlfiles'
10920b3e38ee4Smrgdlpreopen='$dlprefiles'
1092150806d53Smrg
10922b3e38ee4Smrg# Directory that this library needs to be installed in:
10923b3e38ee4Smrglibdir='$install_libdir'"
109244a8d91dcSmrg	  if test no,yes = "$installed,$need_relink"; then
10925b3e38ee4Smrg	    $ECHO >> $output "\
10926b3e38ee4Smrgrelink_command=\"$relink_command\""
10927b3e38ee4Smrg	  fi
10928b3e38ee4Smrg	done
10929b3e38ee4Smrg      }
1093050806d53Smrg
10931b3e38ee4Smrg      # Do a symbolic link so that the libtool archive can be found in
10932b3e38ee4Smrg      # LD_LIBRARY_PATH before the program is installed.
10933b3e38ee4Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
10934b3e38ee4Smrg      ;;
10935b3e38ee4Smrg    esac
10936b3e38ee4Smrg    exit $EXIT_SUCCESS
10937b3e38ee4Smrg}
10938a18ebfb2Smrg
109394a8d91dcSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then
109404a8d91dcSmrg  func_mode_link ${1+"$@"}
109414a8d91dcSmrgfi
1094250806d53Smrg
1094350806d53Smrg
10944b3e38ee4Smrg# func_mode_uninstall arg...
10945b3e38ee4Smrgfunc_mode_uninstall ()
10946b3e38ee4Smrg{
109474a8d91dcSmrg    $debug_cmd
109484a8d91dcSmrg
109494a8d91dcSmrg    RM=$nonopt
1095050806d53Smrg    files=
109514a8d91dcSmrg    rmforce=false
1095250806d53Smrg    exit_status=0
1095350806d53Smrg
1095450806d53Smrg    # This variable tells wrapper scripts just to set variables rather
1095550806d53Smrg    # than running their programs.
109564a8d91dcSmrg    libtool_install_magic=$magic
1095750806d53Smrg
1095850806d53Smrg    for arg
1095950806d53Smrg    do
1096050806d53Smrg      case $arg in
109614a8d91dcSmrg      -f) func_append RM " $arg"; rmforce=: ;;
10962a73423d7Smrg      -*) func_append RM " $arg" ;;
10963a73423d7Smrg      *) func_append files " $arg" ;;
1096450806d53Smrg      esac
1096550806d53Smrg    done
1096650806d53Smrg
10967b3e38ee4Smrg    test -z "$RM" && \
10968b3e38ee4Smrg      func_fatal_help "you must specify an RM program"
1096950806d53Smrg
1097050806d53Smrg    rmdirs=
1097150806d53Smrg
1097250806d53Smrg    for file in $files; do
10973b3e38ee4Smrg      func_dirname "$file" "" "."
109744a8d91dcSmrg      dir=$func_dirname_result
109754a8d91dcSmrg      if test . = "$dir"; then
109764a8d91dcSmrg	odir=$objdir
1097750806d53Smrg      else
109784a8d91dcSmrg	odir=$dir/$objdir
1097950806d53Smrg      fi
10980b3e38ee4Smrg      func_basename "$file"
109814a8d91dcSmrg      name=$func_basename_result
109824a8d91dcSmrg      test uninstall = "$opt_mode" && odir=$dir
1098350806d53Smrg
10984a73423d7Smrg      # Remember odir for removal later, being careful to avoid duplicates
109854a8d91dcSmrg      if test clean = "$opt_mode"; then
1098650806d53Smrg	case " $rmdirs " in
10987a73423d7Smrg	  *" $odir "*) ;;
10988a73423d7Smrg	  *) func_append rmdirs " $odir" ;;
1098950806d53Smrg	esac
1099050806d53Smrg      fi
1099150806d53Smrg
1099250806d53Smrg      # Don't error if the file doesn't exist and rm -f was used.
10993b3e38ee4Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
10994b3e38ee4Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
10995b3e38ee4Smrg	 test -f "$file"; then
1099650806d53Smrg	:
1099750806d53Smrg      elif test -d "$file"; then
1099850806d53Smrg	exit_status=1
1099950806d53Smrg	continue
110004a8d91dcSmrg      elif $rmforce; then
1100150806d53Smrg	continue
1100250806d53Smrg      fi
1100350806d53Smrg
110044a8d91dcSmrg      rmfiles=$file
1100550806d53Smrg
1100650806d53Smrg      case $name in
1100750806d53Smrg      *.la)
1100850806d53Smrg	# Possibly a libtool archive, so verify it.
11009b3e38ee4Smrg	if func_lalib_p "$file"; then
11010b3e38ee4Smrg	  func_source $dir/$name
1101150806d53Smrg
1101250806d53Smrg	  # Delete the libtool libraries and symlinks.
1101350806d53Smrg	  for n in $library_names; do
11014a73423d7Smrg	    func_append rmfiles " $odir/$n"
1101550806d53Smrg	  done
11016a73423d7Smrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
1101750806d53Smrg
110184a8d91dcSmrg	  case $opt_mode in
1101950806d53Smrg	  clean)
11020a73423d7Smrg	    case " $library_names " in
1102150806d53Smrg	    *" $dlname "*) ;;
11022a73423d7Smrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
1102350806d53Smrg	    esac
11024a73423d7Smrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
1102550806d53Smrg	    ;;
1102650806d53Smrg	  uninstall)
1102750806d53Smrg	    if test -n "$library_names"; then
1102850806d53Smrg	      # Do each command in the postuninstall commands.
110294a8d91dcSmrg	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
1103050806d53Smrg	    fi
1103150806d53Smrg
1103250806d53Smrg	    if test -n "$old_library"; then
1103350806d53Smrg	      # Do each command in the old_postuninstall commands.
110344a8d91dcSmrg	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
1103550806d53Smrg	    fi
1103650806d53Smrg	    # FIXME: should reinstall the best remaining shared library.
1103750806d53Smrg	    ;;
1103850806d53Smrg	  esac
1103950806d53Smrg	fi
1104050806d53Smrg	;;
1104150806d53Smrg
1104250806d53Smrg      *.lo)
1104350806d53Smrg	# Possibly a libtool object, so verify it.
11044b3e38ee4Smrg	if func_lalib_p "$file"; then
1104550806d53Smrg
1104650806d53Smrg	  # Read the .lo file
11047b3e38ee4Smrg	  func_source $dir/$name
1104850806d53Smrg
1104950806d53Smrg	  # Add PIC object to the list of files to remove.
110504a8d91dcSmrg	  if test -n "$pic_object" && test none != "$pic_object"; then
11051a73423d7Smrg	    func_append rmfiles " $dir/$pic_object"
1105250806d53Smrg	  fi
1105350806d53Smrg
1105450806d53Smrg	  # Add non-PIC object to the list of files to remove.
110554a8d91dcSmrg	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
11056a73423d7Smrg	    func_append rmfiles " $dir/$non_pic_object"
1105750806d53Smrg	  fi
1105850806d53Smrg	fi
1105950806d53Smrg	;;
1106050806d53Smrg
1106150806d53Smrg      *)
110624a8d91dcSmrg	if test clean = "$opt_mode"; then
1106350806d53Smrg	  noexename=$name
1106450806d53Smrg	  case $file in
1106550806d53Smrg	  *.exe)
11066b3e38ee4Smrg	    func_stripname '' '.exe' "$file"
11067b3e38ee4Smrg	    file=$func_stripname_result
11068b3e38ee4Smrg	    func_stripname '' '.exe' "$name"
11069b3e38ee4Smrg	    noexename=$func_stripname_result
1107050806d53Smrg	    # $file with .exe has already been added to rmfiles,
1107150806d53Smrg	    # add $file without .exe
11072a73423d7Smrg	    func_append rmfiles " $file"
1107350806d53Smrg	    ;;
1107450806d53Smrg	  esac
1107550806d53Smrg	  # Do a test to see if this is a libtool program.
11076b3e38ee4Smrg	  if func_ltwrapper_p "$file"; then
11077b3e38ee4Smrg	    if func_ltwrapper_executable_p "$file"; then
11078b3e38ee4Smrg	      func_ltwrapper_scriptname "$file"
11079b3e38ee4Smrg	      relink_command=
11080b3e38ee4Smrg	      func_source $func_ltwrapper_scriptname_result
11081a73423d7Smrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
11082b3e38ee4Smrg	    else
11083b3e38ee4Smrg	      relink_command=
11084b3e38ee4Smrg	      func_source $dir/$noexename
11085b3e38ee4Smrg	    fi
1108650806d53Smrg
1108750806d53Smrg	    # note $name still contains .exe if it was in $file originally
1108850806d53Smrg	    # as does the version of $file that was added into $rmfiles
110894a8d91dcSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
110904a8d91dcSmrg	    if test yes = "$fast_install" && test -n "$relink_command"; then
11091a73423d7Smrg	      func_append rmfiles " $odir/lt-$name"
1109250806d53Smrg	    fi
110934a8d91dcSmrg	    if test "X$noexename" != "X$name"; then
110944a8d91dcSmrg	      func_append rmfiles " $odir/lt-$noexename.c"
1109550806d53Smrg	    fi
1109650806d53Smrg	  fi
1109750806d53Smrg	fi
1109850806d53Smrg	;;
1109950806d53Smrg      esac
11100b3e38ee4Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
1110150806d53Smrg    done
1110250806d53Smrg
111034a8d91dcSmrg    # Try to remove the $objdir's in the directories where we deleted files
1110450806d53Smrg    for dir in $rmdirs; do
1110550806d53Smrg      if test -d "$dir"; then
11106b3e38ee4Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
1110750806d53Smrg      fi
1110850806d53Smrg    done
1110950806d53Smrg
1111050806d53Smrg    exit $exit_status
11111b3e38ee4Smrg}
1111250806d53Smrg
111134a8d91dcSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
111144a8d91dcSmrg  func_mode_uninstall ${1+"$@"}
111154a8d91dcSmrgfi
11116af1a9c97Smrg
11117a73423d7Smrgtest -z "$opt_mode" && {
111184a8d91dcSmrg  help=$generic_help
11119b3e38ee4Smrg  func_fatal_help "you must specify a MODE"
11120b3e38ee4Smrg}
11121b3e38ee4Smrg
11122b3e38ee4Smrgtest -z "$exec_cmd" && \
111234a8d91dcSmrg  func_fatal_help "invalid operation mode '$opt_mode'"
1112450806d53Smrg
1112550806d53Smrgif test -n "$exec_cmd"; then
11126b3e38ee4Smrg  eval exec "$exec_cmd"
1112750806d53Smrg  exit $EXIT_FAILURE
1112850806d53Smrgfi
1112950806d53Smrg
11130b3e38ee4Smrgexit $exit_status
1113150806d53Smrg
1113250806d53Smrg
1113350806d53Smrg# The TAGs below are defined such that we never get into a situation
111344a8d91dcSmrg# where we disable both kinds of libraries.  Given conflicting
1113550806d53Smrg# choices, we go for a static library, that is the most portable,
1113650806d53Smrg# since we can't tell whether shared libraries were disabled because
1113750806d53Smrg# the user asked for that or because the platform doesn't support
1113850806d53Smrg# them.  This is particularly important on AIX, because we don't
1113950806d53Smrg# support having both static and shared libraries enabled at the same
1114050806d53Smrg# time on that platform, so we default to a shared-only configuration.
1114150806d53Smrg# If a disable-shared tag is given, we'll fallback to a static-only
1114250806d53Smrg# configuration.  But we'll never go from static-only to shared-only.
1114350806d53Smrg
1114450806d53Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
11145b3e38ee4Smrgbuild_libtool_libs=no
11146b3e38ee4Smrgbuild_old_libs=yes
1114750806d53Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
1114850806d53Smrg
1114950806d53Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
11150b3e38ee4Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
1115150806d53Smrg# ### END LIBTOOL TAG CONFIG: disable-static
1115250806d53Smrg
1115350806d53Smrg# Local Variables:
1115450806d53Smrg# mode:shell-script
1115550806d53Smrg# sh-indentation:2
1115650806d53Smrg# End:
11157