14f00d7e1Smrg#! /bin/sh
24f00d7e1Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
34f00d7e1Smrg##               by inline-source v2014-01-03.01
40b661123Smrg
54f00d7e1Smrg# libtool (GNU libtool) 2.4.6
64f00d7e1Smrg# Provide generalized library-building support services.
70b661123Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
80b661123Smrg
94f00d7e1Smrg# Copyright (C) 1996-2015 Free Software Foundation, Inc.
100b661123Smrg# This is free software; see the source for copying conditions.  There is NO
110b661123Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
120b661123Smrg
130b661123Smrg# GNU Libtool is free software; you can redistribute it and/or modify
14bdcaa8d0Smrg# it under the terms of the GNU General Public License as published by
15bdcaa8d0Smrg# the Free Software Foundation; either version 2 of the License, or
16bdcaa8d0Smrg# (at your option) any later version.
17bdcaa8d0Smrg#
180b661123Smrg# As a special exception to the GNU General Public License,
190b661123Smrg# if you distribute this file as part of a program or library that
200b661123Smrg# is built using GNU Libtool, you may include this file under the
210b661123Smrg# same distribution terms that you use for the rest of that program.
220b661123Smrg#
230b661123Smrg# GNU Libtool is distributed in the hope that it will be useful, but
24bdcaa8d0Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
25bdcaa8d0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26bdcaa8d0Smrg# General Public License for more details.
27bdcaa8d0Smrg#
28bdcaa8d0Smrg# You should have received a copy of the GNU General Public License
294f00d7e1Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
3096ce994aSmrg
3172313efbSmrg
32880c7e28SmrgPROGRAM=libtool
3372313efbSmrgPACKAGE=libtool
344f00d7e1SmrgVERSION=2.4.6
354f00d7e1Smrgpackage_revision=2.4.6
3672313efbSmrg
374f00d7e1Smrg
384f00d7e1Smrg## ------ ##
394f00d7e1Smrg## Usage. ##
404f00d7e1Smrg## ------ ##
414f00d7e1Smrg
424f00d7e1Smrg# Run './libtool --help' for help with using this script from the
434f00d7e1Smrg# command line.
444f00d7e1Smrg
454f00d7e1Smrg
464f00d7e1Smrg## ------------------------------- ##
474f00d7e1Smrg## User overridable command paths. ##
484f00d7e1Smrg## ------------------------------- ##
494f00d7e1Smrg
504f00d7e1Smrg# After configure completes, it has a better idea of some of the
514f00d7e1Smrg# shell tools we need than the defaults used by the functions shared
524f00d7e1Smrg# with bootstrap, so set those here where they can still be over-
534f00d7e1Smrg# ridden by the user, but otherwise take precedence.
544f00d7e1Smrg
554f00d7e1Smrg: ${AUTOCONF="autoconf"}
564f00d7e1Smrg: ${AUTOMAKE="automake"}
574f00d7e1Smrg
584f00d7e1Smrg
594f00d7e1Smrg## -------------------------- ##
604f00d7e1Smrg## Source external libraries. ##
614f00d7e1Smrg## -------------------------- ##
624f00d7e1Smrg
634f00d7e1Smrg# Much of our low-level functionality needs to be sourced from external
644f00d7e1Smrg# libraries, which are installed to $pkgauxdir.
654f00d7e1Smrg
664f00d7e1Smrg# Set a version string for this script.
674f00d7e1Smrgscriptversion=2015-01-20.17; # UTC
684f00d7e1Smrg
694f00d7e1Smrg# General shell script boiler plate, and helper functions.
704f00d7e1Smrg# Written by Gary V. Vaughan, 2004
714f00d7e1Smrg
724f00d7e1Smrg# Copyright (C) 2004-2015 Free Software Foundation, Inc.
734f00d7e1Smrg# This is free software; see the source for copying conditions.  There is NO
744f00d7e1Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
754f00d7e1Smrg
764f00d7e1Smrg# This program is free software; you can redistribute it and/or modify
774f00d7e1Smrg# it under the terms of the GNU General Public License as published by
784f00d7e1Smrg# the Free Software Foundation; either version 3 of the License, or
794f00d7e1Smrg# (at your option) any later version.
804f00d7e1Smrg
814f00d7e1Smrg# As a special exception to the GNU General Public License, if you distribute
824f00d7e1Smrg# this file as part of a program or library that is built using GNU Libtool,
834f00d7e1Smrg# you may include this file under the same distribution terms that you use
844f00d7e1Smrg# for the rest of that program.
854f00d7e1Smrg
864f00d7e1Smrg# This program is distributed in the hope that it will be useful,
874f00d7e1Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
884f00d7e1Smrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
894f00d7e1Smrg# General Public License for more details.
904f00d7e1Smrg
914f00d7e1Smrg# You should have received a copy of the GNU General Public License
924f00d7e1Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>.
934f00d7e1Smrg
944f00d7e1Smrg# Please report bugs or propose patches to gary@gnu.org.
954f00d7e1Smrg
964f00d7e1Smrg
974f00d7e1Smrg## ------ ##
984f00d7e1Smrg## Usage. ##
994f00d7e1Smrg## ------ ##
1004f00d7e1Smrg
1014f00d7e1Smrg# Evaluate this file near the top of your script to gain access to
1024f00d7e1Smrg# the functions and variables defined here:
1034f00d7e1Smrg#
1044f00d7e1Smrg#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
1054f00d7e1Smrg#
1064f00d7e1Smrg# If you need to override any of the default environment variable
1074f00d7e1Smrg# settings, do that before evaluating this file.
1084f00d7e1Smrg
1094f00d7e1Smrg
1104f00d7e1Smrg## -------------------- ##
1114f00d7e1Smrg## Shell normalisation. ##
1124f00d7e1Smrg## -------------------- ##
1134f00d7e1Smrg
1144f00d7e1Smrg# Some shells need a little help to be as Bourne compatible as possible.
1154f00d7e1Smrg# Before doing anything else, make sure all that help has been provided!
1164f00d7e1Smrg
1174f00d7e1SmrgDUALCASE=1; export DUALCASE # for MKS sh
1184f00d7e1Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
11972313efbSmrg  emulate sh
12072313efbSmrg  NULLCMD=:
1214f00d7e1Smrg  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
12272313efbSmrg  # is contrary to our usage.  Disable this feature.
12372313efbSmrg  alias -g '${1+"$@"}'='"$@"'
12472313efbSmrg  setopt NO_GLOB_SUBST
12572313efbSmrgelse
1264f00d7e1Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
12772313efbSmrgfi
128880c7e28Smrg
1294f00d7e1Smrg# NLS nuisances: We save the old values in case they are required later.
1304f00d7e1Smrg_G_user_locale=
1314f00d7e1Smrg_G_safe_locale=
1324f00d7e1Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
13372313efbSmrgdo
1344f00d7e1Smrg  eval "if test set = \"\${$_G_var+set}\"; then
1354f00d7e1Smrg          save_$_G_var=\$$_G_var
1364f00d7e1Smrg          $_G_var=C
1374f00d7e1Smrg	  export $_G_var
1384f00d7e1Smrg	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
1394f00d7e1Smrg	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
14072313efbSmrg	fi"
14172313efbSmrgdone
14272313efbSmrg
1434f00d7e1Smrg# CDPATH.
1444f00d7e1Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1450b661123Smrg
1464f00d7e1Smrg# Make sure IFS has a sensible default
1474f00d7e1Smrgsp=' '
1484f00d7e1Smrgnl='
1494f00d7e1Smrg'
1504f00d7e1SmrgIFS="$sp	$nl"
1514f00d7e1Smrg
1524f00d7e1Smrg# There are apparently some retarded systems that use ';' as a PATH separator!
1534f00d7e1Smrgif test "${PATH_SEPARATOR+set}" != set; then
1544f00d7e1Smrg  PATH_SEPARATOR=:
1554f00d7e1Smrg  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
1564f00d7e1Smrg    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
1574f00d7e1Smrg      PATH_SEPARATOR=';'
1584f00d7e1Smrg  }
1594f00d7e1Smrgfi
1600b661123Smrg
1610b661123Smrg
1620b661123Smrg
1634f00d7e1Smrg## ------------------------- ##
1644f00d7e1Smrg## Locate command utilities. ##
1654f00d7e1Smrg## ------------------------- ##
1664f00d7e1Smrg
1674f00d7e1Smrg
1684f00d7e1Smrg# func_executable_p FILE
1694f00d7e1Smrg# ----------------------
1704f00d7e1Smrg# Check that FILE is an executable regular file.
1714f00d7e1Smrgfunc_executable_p ()
1724f00d7e1Smrg{
1734f00d7e1Smrg    test -f "$1" && test -x "$1"
1744f00d7e1Smrg}
1754f00d7e1Smrg
1764f00d7e1Smrg
1774f00d7e1Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
1784f00d7e1Smrg# --------------------------------------------
1794f00d7e1Smrg# Search for either a program that responds to --version with output
1804f00d7e1Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by
1814f00d7e1Smrg# trying all the directories in PATH with each of the elements of
1824f00d7e1Smrg# PROGS_LIST.
1834f00d7e1Smrg#
1844f00d7e1Smrg# CHECK_FUNC should accept the path to a candidate program, and
1854f00d7e1Smrg# set $func_check_prog_result if it truncates its output less than
1864f00d7e1Smrg# $_G_path_prog_max characters.
1874f00d7e1Smrgfunc_path_progs ()
1884f00d7e1Smrg{
1894f00d7e1Smrg    _G_progs_list=$1
1904f00d7e1Smrg    _G_check_func=$2
1914f00d7e1Smrg    _G_PATH=${3-"$PATH"}
1924f00d7e1Smrg
1934f00d7e1Smrg    _G_path_prog_max=0
1944f00d7e1Smrg    _G_path_prog_found=false
1954f00d7e1Smrg    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
1964f00d7e1Smrg    for _G_dir in $_G_PATH; do
1974f00d7e1Smrg      IFS=$_G_save_IFS
1984f00d7e1Smrg      test -z "$_G_dir" && _G_dir=.
1994f00d7e1Smrg      for _G_prog_name in $_G_progs_list; do
2004f00d7e1Smrg        for _exeext in '' .EXE; do
2014f00d7e1Smrg          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
2024f00d7e1Smrg          func_executable_p "$_G_path_prog" || continue
2034f00d7e1Smrg          case `"$_G_path_prog" --version 2>&1` in
2044f00d7e1Smrg            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
2054f00d7e1Smrg            *)     $_G_check_func $_G_path_prog
2064f00d7e1Smrg		   func_path_progs_result=$func_check_prog_result
2074f00d7e1Smrg		   ;;
2084f00d7e1Smrg          esac
2094f00d7e1Smrg          $_G_path_prog_found && break 3
2104f00d7e1Smrg        done
2114f00d7e1Smrg      done
2124f00d7e1Smrg    done
2134f00d7e1Smrg    IFS=$_G_save_IFS
2144f00d7e1Smrg    test -z "$func_path_progs_result" && {
2154f00d7e1Smrg      echo "no acceptable sed could be found in \$PATH" >&2
2164f00d7e1Smrg      exit 1
2174f00d7e1Smrg    }
2184f00d7e1Smrg}
2194f00d7e1Smrg
2204f00d7e1Smrg
2214f00d7e1Smrg# We want to be able to use the functions in this file before configure
2224f00d7e1Smrg# has figured out where the best binaries are kept, which means we have
2234f00d7e1Smrg# to search for them ourselves - except when the results are already set
2244f00d7e1Smrg# where we skip the searches.
2254f00d7e1Smrg
2264f00d7e1Smrg# Unless the user overrides by setting SED, search the path for either GNU
2274f00d7e1Smrg# sed, or the sed that truncates its output the least.
2284f00d7e1Smrgtest -z "$SED" && {
2294f00d7e1Smrg  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
2304f00d7e1Smrg  for _G_i in 1 2 3 4 5 6 7; do
2314f00d7e1Smrg    _G_sed_script=$_G_sed_script$nl$_G_sed_script
2324f00d7e1Smrg  done
2334f00d7e1Smrg  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
2344f00d7e1Smrg  _G_sed_script=
2354f00d7e1Smrg
2364f00d7e1Smrg  func_check_prog_sed ()
2374f00d7e1Smrg  {
2384f00d7e1Smrg    _G_path_prog=$1
2394f00d7e1Smrg
2404f00d7e1Smrg    _G_count=0
2414f00d7e1Smrg    printf 0123456789 >conftest.in
2424f00d7e1Smrg    while :
2434f00d7e1Smrg    do
2444f00d7e1Smrg      cat conftest.in conftest.in >conftest.tmp
2454f00d7e1Smrg      mv conftest.tmp conftest.in
2464f00d7e1Smrg      cp conftest.in conftest.nl
2474f00d7e1Smrg      echo '' >> conftest.nl
2484f00d7e1Smrg      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
2494f00d7e1Smrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
2504f00d7e1Smrg      _G_count=`expr $_G_count + 1`
2514f00d7e1Smrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
2524f00d7e1Smrg        # Best one so far, save it but keep looking for a better one
2534f00d7e1Smrg        func_check_prog_result=$_G_path_prog
2544f00d7e1Smrg        _G_path_prog_max=$_G_count
2554f00d7e1Smrg      fi
2564f00d7e1Smrg      # 10*(2^10) chars as input seems more than enough
2574f00d7e1Smrg      test 10 -lt "$_G_count" && break
2584f00d7e1Smrg    done
2594f00d7e1Smrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
2604f00d7e1Smrg  }
2614f00d7e1Smrg
2624f00d7e1Smrg  func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
2634f00d7e1Smrg  rm -f conftest.sed
2644f00d7e1Smrg  SED=$func_path_progs_result
2654f00d7e1Smrg}
2664f00d7e1Smrg
2674f00d7e1Smrg
2684f00d7e1Smrg# Unless the user overrides by setting GREP, search the path for either GNU
2694f00d7e1Smrg# grep, or the grep that truncates its output the least.
2704f00d7e1Smrgtest -z "$GREP" && {
2714f00d7e1Smrg  func_check_prog_grep ()
2724f00d7e1Smrg  {
2734f00d7e1Smrg    _G_path_prog=$1
2744f00d7e1Smrg
2754f00d7e1Smrg    _G_count=0
2764f00d7e1Smrg    _G_path_prog_max=0
2774f00d7e1Smrg    printf 0123456789 >conftest.in
2784f00d7e1Smrg    while :
2794f00d7e1Smrg    do
2804f00d7e1Smrg      cat conftest.in conftest.in >conftest.tmp
2814f00d7e1Smrg      mv conftest.tmp conftest.in
2824f00d7e1Smrg      cp conftest.in conftest.nl
2834f00d7e1Smrg      echo 'GREP' >> conftest.nl
2844f00d7e1Smrg      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
2854f00d7e1Smrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
2864f00d7e1Smrg      _G_count=`expr $_G_count + 1`
2874f00d7e1Smrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
2884f00d7e1Smrg        # Best one so far, save it but keep looking for a better one
2894f00d7e1Smrg        func_check_prog_result=$_G_path_prog
2904f00d7e1Smrg        _G_path_prog_max=$_G_count
2914f00d7e1Smrg      fi
2924f00d7e1Smrg      # 10*(2^10) chars as input seems more than enough
2934f00d7e1Smrg      test 10 -lt "$_G_count" && break
2944f00d7e1Smrg    done
2954f00d7e1Smrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
2964f00d7e1Smrg  }
2974f00d7e1Smrg
2984f00d7e1Smrg  func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
2994f00d7e1Smrg  GREP=$func_path_progs_result
3004f00d7e1Smrg}
3014f00d7e1Smrg
3024f00d7e1Smrg
3034f00d7e1Smrg## ------------------------------- ##
3044f00d7e1Smrg## User overridable command paths. ##
3054f00d7e1Smrg## ------------------------------- ##
3064f00d7e1Smrg
3074f00d7e1Smrg# All uppercase variable names are used for environment variables.  These
3084f00d7e1Smrg# variables can be overridden by the user before calling a script that
3094f00d7e1Smrg# uses them if a suitable command of that name is not already available
3104f00d7e1Smrg# in the command search PATH.
3110b661123Smrg
3120b661123Smrg: ${CP="cp -f"}
3134f00d7e1Smrg: ${ECHO="printf %s\n"}
3144f00d7e1Smrg: ${EGREP="$GREP -E"}
3154f00d7e1Smrg: ${FGREP="$GREP -F"}
3164f00d7e1Smrg: ${LN_S="ln -s"}
3170b661123Smrg: ${MAKE="make"}
3180b661123Smrg: ${MKDIR="mkdir"}
3190b661123Smrg: ${MV="mv -f"}
3200b661123Smrg: ${RM="rm -f"}
3210b661123Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
32272313efbSmrg
3230b661123Smrg
3244f00d7e1Smrg## -------------------- ##
3254f00d7e1Smrg## Useful sed snippets. ##
3264f00d7e1Smrg## -------------------- ##
327880c7e28Smrg
3284f00d7e1Smrgsed_dirname='s|/[^/]*$||'
3294f00d7e1Smrgsed_basename='s|^.*/||'
330880c7e28Smrg
3314f00d7e1Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
3324f00d7e1Smrg# metacharacters that are still active within double-quoted strings.
3334f00d7e1Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g'
334880c7e28Smrg
3354f00d7e1Smrg# Same as above, but do not quote variable references.
3364f00d7e1Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
337880c7e28Smrg
3384f00d7e1Smrg# Sed substitution that turns a string into a regex matching for the
3394f00d7e1Smrg# string literally.
3404f00d7e1Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
341880c7e28Smrg
3424f00d7e1Smrg# Sed substitution that converts a w32 file name or path
3434f00d7e1Smrg# that contains forward slashes, into one that contains
3444f00d7e1Smrg# (escaped) backslashes.  A very naive implementation.
3454f00d7e1Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3464f00d7e1Smrg
3474f00d7e1Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that
3484f00d7e1Smrg# were '\'-ed in input to the same.  If an odd number of '\' preceded a
3494f00d7e1Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from
3504f00d7e1Smrg# expansion.  Since each input '\' is now two '\'s, look for any number
3514f00d7e1Smrg# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
3524f00d7e1Smrg_G_bs='\\'
3534f00d7e1Smrg_G_bs2='\\\\'
3544f00d7e1Smrg_G_bs4='\\\\\\\\'
3554f00d7e1Smrg_G_dollar='\$'
3564f00d7e1Smrgsed_double_backslash="\
3574f00d7e1Smrg  s/$_G_bs4/&\\
3584f00d7e1Smrg/g
3594f00d7e1Smrg  s/^$_G_bs2$_G_dollar/$_G_bs&/
3604f00d7e1Smrg  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
3614f00d7e1Smrg  s/\n//g"
362880c7e28Smrg
363880c7e28Smrg
3644f00d7e1Smrg## ----------------- ##
3654f00d7e1Smrg## Global variables. ##
3664f00d7e1Smrg## ----------------- ##
367880c7e28Smrg
3684f00d7e1Smrg# Except for the global variables explicitly listed below, the following
3694f00d7e1Smrg# functions in the '^func_' namespace, and the '^require_' namespace
3704f00d7e1Smrg# variables initialised in the 'Resource management' section, sourcing
3714f00d7e1Smrg# this file will not pollute your global namespace with anything
3724f00d7e1Smrg# else. There's no portable way to scope variables in Bourne shell
3734f00d7e1Smrg# though, so actually running these functions will sometimes place
3744f00d7e1Smrg# results into a variable named after the function, and often use
3754f00d7e1Smrg# temporary variables in the '^_G_' namespace. If you are careful to
3764f00d7e1Smrg# avoid using those namespaces casually in your sourcing script, things
3774f00d7e1Smrg# should continue to work as you expect. And, of course, you can freely
3784f00d7e1Smrg# overwrite any of the functions or variables defined here before
3794f00d7e1Smrg# calling anything to customize them.
380880c7e28Smrg
3814f00d7e1SmrgEXIT_SUCCESS=0
3824f00d7e1SmrgEXIT_FAILURE=1
3834f00d7e1SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
3844f00d7e1SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
38572313efbSmrg
3864f00d7e1Smrg# Allow overriding, eg assuming that you follow the convention of
3874f00d7e1Smrg# putting '$debug_cmd' at the start of all your functions, you can get
3884f00d7e1Smrg# bash to show function call trace with:
3894f00d7e1Smrg#
3904f00d7e1Smrg#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
3914f00d7e1Smrgdebug_cmd=${debug_cmd-":"}
3924f00d7e1Smrgexit_cmd=:
3930b661123Smrg
3944f00d7e1Smrg# By convention, finish your script with:
3954f00d7e1Smrg#
3964f00d7e1Smrg#    exit $exit_status
3974f00d7e1Smrg#
3984f00d7e1Smrg# so that you can set exit_status to non-zero if you want to indicate
3994f00d7e1Smrg# something went wrong during execution without actually bailing out at
4004f00d7e1Smrg# the point of failure.
4014f00d7e1Smrgexit_status=$EXIT_SUCCESS
402880c7e28Smrg
4034f00d7e1Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
4044f00d7e1Smrg# is ksh but when the shell is invoked as "sh" and the current value of
4054f00d7e1Smrg# the _XPG environment variable is not equal to 1 (one), the special
4064f00d7e1Smrg# positional parameter $0, within a function call, is the name of the
4074f00d7e1Smrg# function.
4084f00d7e1Smrgprogpath=$0
4090b661123Smrg
4104f00d7e1Smrg# The name of this program.
4114f00d7e1Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"`
4120b661123Smrg
4134f00d7e1Smrg# Make sure we have an absolute progpath for reexecution:
4140b661123Smrgcase $progpath in
4150b661123Smrg  [\\/]*|[A-Za-z]:\\*) ;;
4160b661123Smrg  *[\\/]*)
4174f00d7e1Smrg     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
4180b661123Smrg     progdir=`cd "$progdir" && pwd`
4194f00d7e1Smrg     progpath=$progdir/$progname
4200b661123Smrg     ;;
4210b661123Smrg  *)
4224f00d7e1Smrg     _G_IFS=$IFS
423880c7e28Smrg     IFS=${PATH_SEPARATOR-:}
4240b661123Smrg     for progdir in $PATH; do
4254f00d7e1Smrg       IFS=$_G_IFS
4260b661123Smrg       test -x "$progdir/$progname" && break
4270b661123Smrg     done
4284f00d7e1Smrg     IFS=$_G_IFS
4290b661123Smrg     test -n "$progdir" || progdir=`pwd`
4304f00d7e1Smrg     progpath=$progdir/$progname
4310b661123Smrg     ;;
4320b661123Smrgesac
4330b661123Smrg
4340b661123Smrg
4354f00d7e1Smrg## ----------------- ##
4364f00d7e1Smrg## Standard options. ##
4374f00d7e1Smrg## ----------------- ##
438880c7e28Smrg
4394f00d7e1Smrg# The following options affect the operation of the functions defined
4404f00d7e1Smrg# below, and should be set appropriately depending on run-time para-
4414f00d7e1Smrg# meters passed on the command line.
4420b661123Smrg
4430b661123Smrgopt_dry_run=false
4440b661123Smrgopt_quiet=false
4450b661123Smrgopt_verbose=false
4460b661123Smrg
4474f00d7e1Smrg# Categories 'all' and 'none' are always available.  Append any others
4484f00d7e1Smrg# you will pass as the first argument to func_warning from your own
4494f00d7e1Smrg# code.
4504f00d7e1Smrgwarning_categories=
4510b661123Smrg
4524f00d7e1Smrg# By default, display warnings according to 'opt_warning_types'.  Set
4534f00d7e1Smrg# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
4544f00d7e1Smrg# treat the next displayed warning as a fatal error.
4554f00d7e1Smrgwarning_func=func_warn_and_continue
4560b661123Smrg
4574f00d7e1Smrg# Set to 'all' to display all warnings, 'none' to suppress all
4584f00d7e1Smrg# warnings, or a space delimited list of some subset of
4594f00d7e1Smrg# 'warning_categories' to display only the listed warnings.
4604f00d7e1Smrgopt_warning_types=all
4610b661123Smrg
462880c7e28Smrg
4634f00d7e1Smrg## -------------------- ##
4644f00d7e1Smrg## Resource management. ##
4654f00d7e1Smrg## -------------------- ##
4660b661123Smrg
4674f00d7e1Smrg# This section contains definitions for functions that each ensure a
4684f00d7e1Smrg# particular resource (a file, or a non-empty configuration variable for
4694f00d7e1Smrg# example) is available, and if appropriate to extract default values
4704f00d7e1Smrg# from pertinent package files. Call them using their associated
4714f00d7e1Smrg# 'require_*' variable to ensure that they are executed, at most, once.
4724f00d7e1Smrg#
4734f00d7e1Smrg# It's entirely deliberate that calling these functions can set
4744f00d7e1Smrg# variables that don't obey the namespace limitations obeyed by the rest
4754f00d7e1Smrg# of this file, in order that that they be as useful as possible to
4764f00d7e1Smrg# callers.
4770b661123Smrg
4780b661123Smrg
4794f00d7e1Smrg# require_term_colors
4804f00d7e1Smrg# -------------------
4814f00d7e1Smrg# Allow display of bold text on terminals that support it.
4824f00d7e1Smrgrequire_term_colors=func_require_term_colors
4834f00d7e1Smrgfunc_require_term_colors ()
4840b661123Smrg{
4854f00d7e1Smrg    $debug_cmd
4864f00d7e1Smrg
4874f00d7e1Smrg    test -t 1 && {
4884f00d7e1Smrg      # COLORTERM and USE_ANSI_COLORS environment variables take
4894f00d7e1Smrg      # precedence, because most terminfo databases neglect to describe
4904f00d7e1Smrg      # whether color sequences are supported.
4914f00d7e1Smrg      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
4924f00d7e1Smrg
4934f00d7e1Smrg      if test 1 = "$USE_ANSI_COLORS"; then
4944f00d7e1Smrg        # Standard ANSI escape sequences
4954f00d7e1Smrg        tc_reset='[0m'
4964f00d7e1Smrg        tc_bold='[1m';   tc_standout='[7m'
4974f00d7e1Smrg        tc_red='[31m';   tc_green='[32m'
4984f00d7e1Smrg        tc_blue='[34m';  tc_cyan='[36m'
4994f00d7e1Smrg      else
5004f00d7e1Smrg        # Otherwise trust the terminfo database after all.
5014f00d7e1Smrg        test -n "`tput sgr0 2>/dev/null`" && {
5024f00d7e1Smrg          tc_reset=`tput sgr0`
5034f00d7e1Smrg          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
5044f00d7e1Smrg          tc_standout=$tc_bold
5054f00d7e1Smrg          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
5064f00d7e1Smrg          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
5074f00d7e1Smrg          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
5084f00d7e1Smrg          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
5094f00d7e1Smrg          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
5104f00d7e1Smrg        }
5114f00d7e1Smrg      fi
5124f00d7e1Smrg    }
5130b661123Smrg
5144f00d7e1Smrg    require_term_colors=:
5150b661123Smrg}
5160b661123Smrg
5170b661123Smrg
5184f00d7e1Smrg## ----------------- ##
5194f00d7e1Smrg## Function library. ##
5204f00d7e1Smrg## ----------------- ##
5214f00d7e1Smrg
5224f00d7e1Smrg# This section contains a variety of useful functions to call in your
5234f00d7e1Smrg# scripts. Take note of the portable wrappers for features provided by
5244f00d7e1Smrg# some modern shells, which will fall back to slower equivalents on
5254f00d7e1Smrg# less featureful shells.
5264f00d7e1Smrg
5274f00d7e1Smrg
5284f00d7e1Smrg# func_append VAR VALUE
5294f00d7e1Smrg# ---------------------
5304f00d7e1Smrg# Append VALUE onto the existing contents of VAR.
5314f00d7e1Smrg
5324f00d7e1Smrg  # We should try to minimise forks, especially on Windows where they are
5334f00d7e1Smrg  # unreasonably slow, so skip the feature probes when bash or zsh are
5344f00d7e1Smrg  # being used:
5354f00d7e1Smrg  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
5364f00d7e1Smrg    : ${_G_HAVE_ARITH_OP="yes"}
5374f00d7e1Smrg    : ${_G_HAVE_XSI_OPS="yes"}
5384f00d7e1Smrg    # The += operator was introduced in bash 3.1
5394f00d7e1Smrg    case $BASH_VERSION in
5404f00d7e1Smrg      [12].* | 3.0 | 3.0*) ;;
5414f00d7e1Smrg      *)
5424f00d7e1Smrg        : ${_G_HAVE_PLUSEQ_OP="yes"}
5434f00d7e1Smrg        ;;
5444f00d7e1Smrg    esac
5454f00d7e1Smrg  fi
5464f00d7e1Smrg
5474f00d7e1Smrg  # _G_HAVE_PLUSEQ_OP
5484f00d7e1Smrg  # Can be empty, in which case the shell is probed, "yes" if += is
5494f00d7e1Smrg  # useable or anything else if it does not work.
5504f00d7e1Smrg  test -z "$_G_HAVE_PLUSEQ_OP" \
5514f00d7e1Smrg    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
5524f00d7e1Smrg    && _G_HAVE_PLUSEQ_OP=yes
5534f00d7e1Smrg
5544f00d7e1Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"
5554f00d7e1Smrgthen
5564f00d7e1Smrg  # This is an XSI compatible shell, allowing a faster implementation...
5574f00d7e1Smrg  eval 'func_append ()
5584f00d7e1Smrg  {
5594f00d7e1Smrg    $debug_cmd
5604f00d7e1Smrg
5614f00d7e1Smrg    eval "$1+=\$2"
5624f00d7e1Smrg  }'
5634f00d7e1Smrgelse
5644f00d7e1Smrg  # ...otherwise fall back to using expr, which is often a shell builtin.
5654f00d7e1Smrg  func_append ()
5664f00d7e1Smrg  {
5674f00d7e1Smrg    $debug_cmd
5684f00d7e1Smrg
5694f00d7e1Smrg    eval "$1=\$$1\$2"
5704f00d7e1Smrg  }
5714f00d7e1Smrgfi
5724f00d7e1Smrg
5734f00d7e1Smrg
5744f00d7e1Smrg# func_append_quoted VAR VALUE
5754f00d7e1Smrg# ----------------------------
5764f00d7e1Smrg# Quote VALUE and append to the end of shell variable VAR, separated
5774f00d7e1Smrg# by a space.
5784f00d7e1Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then
5794f00d7e1Smrg  eval 'func_append_quoted ()
5804f00d7e1Smrg  {
5814f00d7e1Smrg    $debug_cmd
5824f00d7e1Smrg
5834f00d7e1Smrg    func_quote_for_eval "$2"
5844f00d7e1Smrg    eval "$1+=\\ \$func_quote_for_eval_result"
5854f00d7e1Smrg  }'
5864f00d7e1Smrgelse
5874f00d7e1Smrg  func_append_quoted ()
5884f00d7e1Smrg  {
5894f00d7e1Smrg    $debug_cmd
5904f00d7e1Smrg
5914f00d7e1Smrg    func_quote_for_eval "$2"
5924f00d7e1Smrg    eval "$1=\$$1\\ \$func_quote_for_eval_result"
5934f00d7e1Smrg  }
5944f00d7e1Smrgfi
5954f00d7e1Smrg
5964f00d7e1Smrg
5974f00d7e1Smrg# func_append_uniq VAR VALUE
5984f00d7e1Smrg# --------------------------
5994f00d7e1Smrg# Append unique VALUE onto the existing contents of VAR, assuming
6004f00d7e1Smrg# entries are delimited by the first character of VALUE.  For example:
6014f00d7e1Smrg#
6024f00d7e1Smrg#   func_append_uniq options " --another-option option-argument"
6034f00d7e1Smrg#
6044f00d7e1Smrg# will only append to $options if " --another-option option-argument "
6054f00d7e1Smrg# is not already present somewhere in $options already (note spaces at
6064f00d7e1Smrg# each end implied by leading space in second argument).
6074f00d7e1Smrgfunc_append_uniq ()
6084f00d7e1Smrg{
6094f00d7e1Smrg    $debug_cmd
6104f00d7e1Smrg
6114f00d7e1Smrg    eval _G_current_value='`$ECHO $'$1'`'
6124f00d7e1Smrg    _G_delim=`expr "$2" : '\(.\)'`
6134f00d7e1Smrg
6144f00d7e1Smrg    case $_G_delim$_G_current_value$_G_delim in
6154f00d7e1Smrg      *"$2$_G_delim"*) ;;
6164f00d7e1Smrg      *) func_append "$@" ;;
6174f00d7e1Smrg    esac
6184f00d7e1Smrg}
6194f00d7e1Smrg
6204f00d7e1Smrg
6214f00d7e1Smrg# func_arith TERM...
6224f00d7e1Smrg# ------------------
6234f00d7e1Smrg# Set func_arith_result to the result of evaluating TERMs.
6244f00d7e1Smrg  test -z "$_G_HAVE_ARITH_OP" \
6254f00d7e1Smrg    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
6264f00d7e1Smrg    && _G_HAVE_ARITH_OP=yes
6274f00d7e1Smrg
6284f00d7e1Smrgif test yes = "$_G_HAVE_ARITH_OP"; then
6294f00d7e1Smrg  eval 'func_arith ()
6304f00d7e1Smrg  {
6314f00d7e1Smrg    $debug_cmd
6324f00d7e1Smrg
6334f00d7e1Smrg    func_arith_result=$(( $* ))
6344f00d7e1Smrg  }'
6354f00d7e1Smrgelse
6364f00d7e1Smrg  func_arith ()
6374f00d7e1Smrg  {
6384f00d7e1Smrg    $debug_cmd
6394f00d7e1Smrg
6404f00d7e1Smrg    func_arith_result=`expr "$@"`
6414f00d7e1Smrg  }
6424f00d7e1Smrgfi
6434f00d7e1Smrg
6444f00d7e1Smrg
6454f00d7e1Smrg# func_basename FILE
6464f00d7e1Smrg# ------------------
6474f00d7e1Smrg# Set func_basename_result to FILE with everything up to and including
6484f00d7e1Smrg# the last / stripped.
6494f00d7e1Smrgif test yes = "$_G_HAVE_XSI_OPS"; then
6504f00d7e1Smrg  # If this shell supports suffix pattern removal, then use it to avoid
6514f00d7e1Smrg  # forking. Hide the definitions single quotes in case the shell chokes
6524f00d7e1Smrg  # on unsupported syntax...
6534f00d7e1Smrg  _b='func_basename_result=${1##*/}'
6544f00d7e1Smrg  _d='case $1 in
6554f00d7e1Smrg        */*) func_dirname_result=${1%/*}$2 ;;
6564f00d7e1Smrg        *  ) func_dirname_result=$3        ;;
6574f00d7e1Smrg      esac'
6584f00d7e1Smrg
6594f00d7e1Smrgelse
6604f00d7e1Smrg  # ...otherwise fall back to using sed.
6614f00d7e1Smrg  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
6624f00d7e1Smrg  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
6634f00d7e1Smrg      if test "X$func_dirname_result" = "X$1"; then
6644f00d7e1Smrg        func_dirname_result=$3
6654f00d7e1Smrg      else
6664f00d7e1Smrg        func_append func_dirname_result "$2"
6674f00d7e1Smrg      fi'
6684f00d7e1Smrgfi
6694f00d7e1Smrg
6704f00d7e1Smrgeval 'func_basename ()
6714f00d7e1Smrg{
6724f00d7e1Smrg    $debug_cmd
6734f00d7e1Smrg
6744f00d7e1Smrg    '"$_b"'
6754f00d7e1Smrg}'
6764f00d7e1Smrg
6774f00d7e1Smrg
6784f00d7e1Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT
6794f00d7e1Smrg# -------------------------------------------
6804f00d7e1Smrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
6814f00d7e1Smrg# otherwise set result to NONDIR_REPLACEMENT.
6824f00d7e1Smrgeval 'func_dirname ()
6834f00d7e1Smrg{
6844f00d7e1Smrg    $debug_cmd
6854f00d7e1Smrg
6864f00d7e1Smrg    '"$_d"'
6874f00d7e1Smrg}'
6884f00d7e1Smrg
6894f00d7e1Smrg
6904f00d7e1Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
6914f00d7e1Smrg# --------------------------------------------------------
6924f00d7e1Smrg# Perform func_basename and func_dirname in a single function
6934f00d7e1Smrg# call:
6944f00d7e1Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
6954f00d7e1Smrg#             add APPEND to the result, otherwise set result
6964f00d7e1Smrg#             to NONDIR_REPLACEMENT.
6974f00d7e1Smrg#             value returned in "$func_dirname_result"
6984f00d7e1Smrg#   basename: Compute filename of FILE.
6994f00d7e1Smrg#             value retuned in "$func_basename_result"
7004f00d7e1Smrg# For efficiency, we do not delegate to the functions above but instead
7014f00d7e1Smrg# duplicate the functionality here.
7024f00d7e1Smrgeval 'func_dirname_and_basename ()
7034f00d7e1Smrg{
7044f00d7e1Smrg    $debug_cmd
7054f00d7e1Smrg
7064f00d7e1Smrg    '"$_b"'
7074f00d7e1Smrg    '"$_d"'
7084f00d7e1Smrg}'
7094f00d7e1Smrg
7104f00d7e1Smrg
7114f00d7e1Smrg# func_echo ARG...
7124f00d7e1Smrg# ----------------
7134f00d7e1Smrg# Echo program name prefixed message.
7144f00d7e1Smrgfunc_echo ()
7154f00d7e1Smrg{
7164f00d7e1Smrg    $debug_cmd
7174f00d7e1Smrg
7184f00d7e1Smrg    _G_message=$*
7194f00d7e1Smrg
7204f00d7e1Smrg    func_echo_IFS=$IFS
7214f00d7e1Smrg    IFS=$nl
7224f00d7e1Smrg    for _G_line in $_G_message; do
7234f00d7e1Smrg      IFS=$func_echo_IFS
7244f00d7e1Smrg      $ECHO "$progname: $_G_line"
7254f00d7e1Smrg    done
7264f00d7e1Smrg    IFS=$func_echo_IFS
7274f00d7e1Smrg}
7284f00d7e1Smrg
7294f00d7e1Smrg
7304f00d7e1Smrg# func_echo_all ARG...
7314f00d7e1Smrg# --------------------
7324f00d7e1Smrg# Invoke $ECHO with all args, space-separated.
7334f00d7e1Smrgfunc_echo_all ()
7344f00d7e1Smrg{
7354f00d7e1Smrg    $ECHO "$*"
7364f00d7e1Smrg}
7374f00d7e1Smrg
7384f00d7e1Smrg
7394f00d7e1Smrg# func_echo_infix_1 INFIX ARG...
7404f00d7e1Smrg# ------------------------------
7414f00d7e1Smrg# Echo program name, followed by INFIX on the first line, with any
7424f00d7e1Smrg# additional lines not showing INFIX.
7434f00d7e1Smrgfunc_echo_infix_1 ()
7444f00d7e1Smrg{
7454f00d7e1Smrg    $debug_cmd
7464f00d7e1Smrg
7474f00d7e1Smrg    $require_term_colors
7484f00d7e1Smrg
7494f00d7e1Smrg    _G_infix=$1; shift
7504f00d7e1Smrg    _G_indent=$_G_infix
7514f00d7e1Smrg    _G_prefix="$progname: $_G_infix: "
7524f00d7e1Smrg    _G_message=$*
7534f00d7e1Smrg
7544f00d7e1Smrg    # Strip color escape sequences before counting printable length
7554f00d7e1Smrg    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
7564f00d7e1Smrg    do
7574f00d7e1Smrg      test -n "$_G_tc" && {
7584f00d7e1Smrg        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
7594f00d7e1Smrg        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
7604f00d7e1Smrg      }
7614f00d7e1Smrg    done
7624f00d7e1Smrg    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
7634f00d7e1Smrg
7644f00d7e1Smrg    func_echo_infix_1_IFS=$IFS
7654f00d7e1Smrg    IFS=$nl
7664f00d7e1Smrg    for _G_line in $_G_message; do
7674f00d7e1Smrg      IFS=$func_echo_infix_1_IFS
7684f00d7e1Smrg      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
7694f00d7e1Smrg      _G_prefix=$_G_indent
7704f00d7e1Smrg    done
7714f00d7e1Smrg    IFS=$func_echo_infix_1_IFS
7724f00d7e1Smrg}
7734f00d7e1Smrg
7744f00d7e1Smrg
7754f00d7e1Smrg# func_error ARG...
7764f00d7e1Smrg# -----------------
7774f00d7e1Smrg# Echo program name prefixed message to standard error.
7784f00d7e1Smrgfunc_error ()
7794f00d7e1Smrg{
7804f00d7e1Smrg    $debug_cmd
7814f00d7e1Smrg
7824f00d7e1Smrg    $require_term_colors
7834f00d7e1Smrg
7844f00d7e1Smrg    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
7854f00d7e1Smrg}
7864f00d7e1Smrg
7874f00d7e1Smrg
7884f00d7e1Smrg# func_fatal_error ARG...
7894f00d7e1Smrg# -----------------------
7904f00d7e1Smrg# Echo program name prefixed message to standard error, and exit.
7914f00d7e1Smrgfunc_fatal_error ()
7924f00d7e1Smrg{
7934f00d7e1Smrg    $debug_cmd
7944f00d7e1Smrg
7954f00d7e1Smrg    func_error "$*"
7964f00d7e1Smrg    exit $EXIT_FAILURE
7974f00d7e1Smrg}
7984f00d7e1Smrg
7994f00d7e1Smrg
8004f00d7e1Smrg# func_grep EXPRESSION FILENAME
8014f00d7e1Smrg# -----------------------------
8020b661123Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
8030b661123Smrgfunc_grep ()
8040b661123Smrg{
8054f00d7e1Smrg    $debug_cmd
8064f00d7e1Smrg
8070b661123Smrg    $GREP "$1" "$2" >/dev/null 2>&1
8080b661123Smrg}
8090b661123Smrg
8100b661123Smrg
8114f00d7e1Smrg# func_len STRING
8124f00d7e1Smrg# ---------------
8134f00d7e1Smrg# Set func_len_result to the length of STRING. STRING may not
8144f00d7e1Smrg# start with a hyphen.
8154f00d7e1Smrg  test -z "$_G_HAVE_XSI_OPS" \
8164f00d7e1Smrg    && (eval 'x=a/b/c;
8174f00d7e1Smrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
8184f00d7e1Smrg    && _G_HAVE_XSI_OPS=yes
8194f00d7e1Smrg
8204f00d7e1Smrgif test yes = "$_G_HAVE_XSI_OPS"; then
8214f00d7e1Smrg  eval 'func_len ()
8224f00d7e1Smrg  {
8234f00d7e1Smrg    $debug_cmd
8244f00d7e1Smrg
8254f00d7e1Smrg    func_len_result=${#1}
8264f00d7e1Smrg  }'
8274f00d7e1Smrgelse
8284f00d7e1Smrg  func_len ()
8294f00d7e1Smrg  {
8304f00d7e1Smrg    $debug_cmd
8314f00d7e1Smrg
8324f00d7e1Smrg    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
8334f00d7e1Smrg  }
8344f00d7e1Smrgfi
8354f00d7e1Smrg
8364f00d7e1Smrg
8374f00d7e1Smrg# func_mkdir_p DIRECTORY-PATH
8384f00d7e1Smrg# ---------------------------
8390b661123Smrg# Make sure the entire path to DIRECTORY-PATH is available.
8400b661123Smrgfunc_mkdir_p ()
8410b661123Smrg{
8424f00d7e1Smrg    $debug_cmd
8430b661123Smrg
8444f00d7e1Smrg    _G_directory_path=$1
8454f00d7e1Smrg    _G_dir_list=
8460b661123Smrg
8474f00d7e1Smrg    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
8484f00d7e1Smrg
8494f00d7e1Smrg      # Protect directory names starting with '-'
8504f00d7e1Smrg      case $_G_directory_path in
8514f00d7e1Smrg        -*) _G_directory_path=./$_G_directory_path ;;
8520b661123Smrg      esac
8530b661123Smrg
8540b661123Smrg      # While some portion of DIR does not yet exist...
8554f00d7e1Smrg      while test ! -d "$_G_directory_path"; do
8560b661123Smrg        # ...make a list in topmost first order.  Use a colon delimited
8570b661123Smrg	# list incase some portion of path contains whitespace.
8584f00d7e1Smrg        _G_dir_list=$_G_directory_path:$_G_dir_list
8590b661123Smrg
8600b661123Smrg        # If the last portion added has no slash in it, the list is done
8614f00d7e1Smrg        case $_G_directory_path in */*) ;; *) break ;; esac
8620b661123Smrg
8630b661123Smrg        # ...otherwise throw away the child directory and loop
8644f00d7e1Smrg        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
8650b661123Smrg      done
8664f00d7e1Smrg      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
8670b661123Smrg
8684f00d7e1Smrg      func_mkdir_p_IFS=$IFS; IFS=:
8694f00d7e1Smrg      for _G_dir in $_G_dir_list; do
8704f00d7e1Smrg	IFS=$func_mkdir_p_IFS
8714f00d7e1Smrg        # mkdir can fail with a 'File exist' error if two processes
8720b661123Smrg        # try to create one of the directories concurrently.  Don't
8730b661123Smrg        # stop in that case!
8744f00d7e1Smrg        $MKDIR "$_G_dir" 2>/dev/null || :
8750b661123Smrg      done
8764f00d7e1Smrg      IFS=$func_mkdir_p_IFS
8770b661123Smrg
8780b661123Smrg      # Bail out if we (or some other process) failed to create a directory.
8794f00d7e1Smrg      test -d "$_G_directory_path" || \
8804f00d7e1Smrg        func_fatal_error "Failed to create '$1'"
8810b661123Smrg    fi
8820b661123Smrg}
883bdcaa8d0Smrg
884bdcaa8d0Smrg
8854f00d7e1Smrg# func_mktempdir [BASENAME]
8864f00d7e1Smrg# -------------------------
887bdcaa8d0Smrg# Make a temporary directory that won't clash with other running
888bdcaa8d0Smrg# libtool processes, and avoids race conditions if possible.  If
8894f00d7e1Smrg# given, BASENAME is the basename for that directory.
890bdcaa8d0Smrgfunc_mktempdir ()
891bdcaa8d0Smrg{
8924f00d7e1Smrg    $debug_cmd
8934f00d7e1Smrg
8944f00d7e1Smrg    _G_template=${TMPDIR-/tmp}/${1-$progname}
895bdcaa8d0Smrg
8964f00d7e1Smrg    if test : = "$opt_dry_run"; then
897bdcaa8d0Smrg      # Return a directory name, but don't create it in dry-run mode
8984f00d7e1Smrg      _G_tmpdir=$_G_template-$$
899bdcaa8d0Smrg    else
900bdcaa8d0Smrg
901bdcaa8d0Smrg      # If mktemp works, use that first and foremost
9024f00d7e1Smrg      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
903bdcaa8d0Smrg
9044f00d7e1Smrg      if test ! -d "$_G_tmpdir"; then
9050b661123Smrg        # Failing that, at least try and use $RANDOM to avoid a race
9064f00d7e1Smrg        _G_tmpdir=$_G_template-${RANDOM-0}$$
907bdcaa8d0Smrg
9084f00d7e1Smrg        func_mktempdir_umask=`umask`
9090b661123Smrg        umask 0077
9104f00d7e1Smrg        $MKDIR "$_G_tmpdir"
9114f00d7e1Smrg        umask $func_mktempdir_umask
912bdcaa8d0Smrg      fi
913bdcaa8d0Smrg
914bdcaa8d0Smrg      # If we're not in dry-run mode, bomb out on failure
9154f00d7e1Smrg      test -d "$_G_tmpdir" || \
9164f00d7e1Smrg        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
9174f00d7e1Smrg    fi
9184f00d7e1Smrg
9194f00d7e1Smrg    $ECHO "$_G_tmpdir"
9204f00d7e1Smrg}
9214f00d7e1Smrg
9224f00d7e1Smrg
9234f00d7e1Smrg# func_normal_abspath PATH
9244f00d7e1Smrg# ------------------------
9254f00d7e1Smrg# Remove doubled-up and trailing slashes, "." path components,
9264f00d7e1Smrg# and cancel out any ".." path components in PATH after making
9274f00d7e1Smrg# it an absolute path.
9284f00d7e1Smrgfunc_normal_abspath ()
9294f00d7e1Smrg{
9304f00d7e1Smrg    $debug_cmd
9314f00d7e1Smrg
9324f00d7e1Smrg    # These SED scripts presuppose an absolute path with a trailing slash.
9334f00d7e1Smrg    _G_pathcar='s|^/\([^/]*\).*$|\1|'
9344f00d7e1Smrg    _G_pathcdr='s|^/[^/]*||'
9354f00d7e1Smrg    _G_removedotparts=':dotsl
9364f00d7e1Smrg		s|/\./|/|g
9374f00d7e1Smrg		t dotsl
9384f00d7e1Smrg		s|/\.$|/|'
9394f00d7e1Smrg    _G_collapseslashes='s|/\{1,\}|/|g'
9404f00d7e1Smrg    _G_finalslash='s|/*$|/|'
9414f00d7e1Smrg
9424f00d7e1Smrg    # Start from root dir and reassemble the path.
9434f00d7e1Smrg    func_normal_abspath_result=
9444f00d7e1Smrg    func_normal_abspath_tpath=$1
9454f00d7e1Smrg    func_normal_abspath_altnamespace=
9464f00d7e1Smrg    case $func_normal_abspath_tpath in
9474f00d7e1Smrg      "")
9484f00d7e1Smrg        # Empty path, that just means $cwd.
9494f00d7e1Smrg        func_stripname '' '/' "`pwd`"
9504f00d7e1Smrg        func_normal_abspath_result=$func_stripname_result
9514f00d7e1Smrg        return
9524f00d7e1Smrg        ;;
9534f00d7e1Smrg      # The next three entries are used to spot a run of precisely
9544f00d7e1Smrg      # two leading slashes without using negated character classes;
9554f00d7e1Smrg      # we take advantage of case's first-match behaviour.
9564f00d7e1Smrg      ///*)
9574f00d7e1Smrg        # Unusual form of absolute path, do nothing.
9584f00d7e1Smrg        ;;
9594f00d7e1Smrg      //*)
9604f00d7e1Smrg        # Not necessarily an ordinary path; POSIX reserves leading '//'
9614f00d7e1Smrg        # and for example Cygwin uses it to access remote file shares
9624f00d7e1Smrg        # over CIFS/SMB, so we conserve a leading double slash if found.
9634f00d7e1Smrg        func_normal_abspath_altnamespace=/
9644f00d7e1Smrg        ;;
9654f00d7e1Smrg      /*)
9664f00d7e1Smrg        # Absolute path, do nothing.
9674f00d7e1Smrg        ;;
9684f00d7e1Smrg      *)
9694f00d7e1Smrg        # Relative path, prepend $cwd.
9704f00d7e1Smrg        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
9714f00d7e1Smrg        ;;
9724f00d7e1Smrg    esac
9734f00d7e1Smrg
9744f00d7e1Smrg    # Cancel out all the simple stuff to save iterations.  We also want
9754f00d7e1Smrg    # the path to end with a slash for ease of parsing, so make sure
9764f00d7e1Smrg    # there is one (and only one) here.
9774f00d7e1Smrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
9784f00d7e1Smrg          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
9794f00d7e1Smrg    while :; do
9804f00d7e1Smrg      # Processed it all yet?
9814f00d7e1Smrg      if test / = "$func_normal_abspath_tpath"; then
9824f00d7e1Smrg        # If we ascended to the root using ".." the result may be empty now.
9834f00d7e1Smrg        if test -z "$func_normal_abspath_result"; then
9844f00d7e1Smrg          func_normal_abspath_result=/
9854f00d7e1Smrg        fi
9864f00d7e1Smrg        break
9874f00d7e1Smrg      fi
9884f00d7e1Smrg      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
9894f00d7e1Smrg          -e "$_G_pathcar"`
9904f00d7e1Smrg      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
9914f00d7e1Smrg          -e "$_G_pathcdr"`
9924f00d7e1Smrg      # Figure out what to do with it
9934f00d7e1Smrg      case $func_normal_abspath_tcomponent in
9944f00d7e1Smrg        "")
9954f00d7e1Smrg          # Trailing empty path component, ignore it.
9964f00d7e1Smrg          ;;
9974f00d7e1Smrg        ..)
9984f00d7e1Smrg          # Parent dir; strip last assembled component from result.
9994f00d7e1Smrg          func_dirname "$func_normal_abspath_result"
10004f00d7e1Smrg          func_normal_abspath_result=$func_dirname_result
10014f00d7e1Smrg          ;;
10024f00d7e1Smrg        *)
10034f00d7e1Smrg          # Actual path component, append it.
10044f00d7e1Smrg          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
10054f00d7e1Smrg          ;;
10064f00d7e1Smrg      esac
10074f00d7e1Smrg    done
10084f00d7e1Smrg    # Restore leading double-slash if one was found on entry.
10094f00d7e1Smrg    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
10104f00d7e1Smrg}
10114f00d7e1Smrg
10124f00d7e1Smrg
10134f00d7e1Smrg# func_notquiet ARG...
10144f00d7e1Smrg# --------------------
10154f00d7e1Smrg# Echo program name prefixed message only when not in quiet mode.
10164f00d7e1Smrgfunc_notquiet ()
10174f00d7e1Smrg{
10184f00d7e1Smrg    $debug_cmd
10194f00d7e1Smrg
10204f00d7e1Smrg    $opt_quiet || func_echo ${1+"$@"}
10214f00d7e1Smrg
10224f00d7e1Smrg    # A bug in bash halts the script if the last line of a function
10234f00d7e1Smrg    # fails when set -e is in force, so we need another command to
10244f00d7e1Smrg    # work around that:
10254f00d7e1Smrg    :
10264f00d7e1Smrg}
10274f00d7e1Smrg
10284f00d7e1Smrg
10294f00d7e1Smrg# func_relative_path SRCDIR DSTDIR
10304f00d7e1Smrg# --------------------------------
10314f00d7e1Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
10324f00d7e1Smrgfunc_relative_path ()
10334f00d7e1Smrg{
10344f00d7e1Smrg    $debug_cmd
10354f00d7e1Smrg
10364f00d7e1Smrg    func_relative_path_result=
10374f00d7e1Smrg    func_normal_abspath "$1"
10384f00d7e1Smrg    func_relative_path_tlibdir=$func_normal_abspath_result
10394f00d7e1Smrg    func_normal_abspath "$2"
10404f00d7e1Smrg    func_relative_path_tbindir=$func_normal_abspath_result
10414f00d7e1Smrg
10424f00d7e1Smrg    # Ascend the tree starting from libdir
10434f00d7e1Smrg    while :; do
10444f00d7e1Smrg      # check if we have found a prefix of bindir
10454f00d7e1Smrg      case $func_relative_path_tbindir in
10464f00d7e1Smrg        $func_relative_path_tlibdir)
10474f00d7e1Smrg          # found an exact match
10484f00d7e1Smrg          func_relative_path_tcancelled=
10494f00d7e1Smrg          break
10504f00d7e1Smrg          ;;
10514f00d7e1Smrg        $func_relative_path_tlibdir*)
10524f00d7e1Smrg          # found a matching prefix
10534f00d7e1Smrg          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
10544f00d7e1Smrg          func_relative_path_tcancelled=$func_stripname_result
10554f00d7e1Smrg          if test -z "$func_relative_path_result"; then
10564f00d7e1Smrg            func_relative_path_result=.
10574f00d7e1Smrg          fi
10584f00d7e1Smrg          break
10594f00d7e1Smrg          ;;
10604f00d7e1Smrg        *)
10614f00d7e1Smrg          func_dirname $func_relative_path_tlibdir
10624f00d7e1Smrg          func_relative_path_tlibdir=$func_dirname_result
10634f00d7e1Smrg          if test -z "$func_relative_path_tlibdir"; then
10644f00d7e1Smrg            # Have to descend all the way to the root!
10654f00d7e1Smrg            func_relative_path_result=../$func_relative_path_result
10664f00d7e1Smrg            func_relative_path_tcancelled=$func_relative_path_tbindir
10674f00d7e1Smrg            break
10684f00d7e1Smrg          fi
10694f00d7e1Smrg          func_relative_path_result=../$func_relative_path_result
10704f00d7e1Smrg          ;;
10714f00d7e1Smrg      esac
10724f00d7e1Smrg    done
10734f00d7e1Smrg
10744f00d7e1Smrg    # Now calculate path; take care to avoid doubling-up slashes.
10754f00d7e1Smrg    func_stripname '' '/' "$func_relative_path_result"
10764f00d7e1Smrg    func_relative_path_result=$func_stripname_result
10774f00d7e1Smrg    func_stripname '/' '/' "$func_relative_path_tcancelled"
10784f00d7e1Smrg    if test -n "$func_stripname_result"; then
10794f00d7e1Smrg      func_append func_relative_path_result "/$func_stripname_result"
10804f00d7e1Smrg    fi
10814f00d7e1Smrg
10824f00d7e1Smrg    # Normalisation. If bindir is libdir, return '.' else relative path.
10834f00d7e1Smrg    if test -n "$func_relative_path_result"; then
10844f00d7e1Smrg      func_stripname './' '' "$func_relative_path_result"
10854f00d7e1Smrg      func_relative_path_result=$func_stripname_result
1086bdcaa8d0Smrg    fi
1087bdcaa8d0Smrg
10884f00d7e1Smrg    test -n "$func_relative_path_result" || func_relative_path_result=.
10894f00d7e1Smrg
10904f00d7e1Smrg    :
10914f00d7e1Smrg}
10924f00d7e1Smrg
10934f00d7e1Smrg
10944f00d7e1Smrg# func_quote_for_eval ARG...
10954f00d7e1Smrg# --------------------------
10964f00d7e1Smrg# Aesthetically quote ARGs to be evaled later.
10974f00d7e1Smrg# This function returns two values:
10984f00d7e1Smrg#   i) func_quote_for_eval_result
10994f00d7e1Smrg#      double-quoted, suitable for a subsequent eval
11004f00d7e1Smrg#  ii) func_quote_for_eval_unquoted_result
11014f00d7e1Smrg#      has all characters that are still active within double
11024f00d7e1Smrg#      quotes backslashified.
11034f00d7e1Smrgfunc_quote_for_eval ()
11044f00d7e1Smrg{
11054f00d7e1Smrg    $debug_cmd
11064f00d7e1Smrg
11074f00d7e1Smrg    func_quote_for_eval_unquoted_result=
11084f00d7e1Smrg    func_quote_for_eval_result=
11094f00d7e1Smrg    while test 0 -lt $#; do
11104f00d7e1Smrg      case $1 in
11114f00d7e1Smrg        *[\\\`\"\$]*)
11124f00d7e1Smrg	  _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
11134f00d7e1Smrg        *)
11144f00d7e1Smrg          _G_unquoted_arg=$1 ;;
11154f00d7e1Smrg      esac
11164f00d7e1Smrg      if test -n "$func_quote_for_eval_unquoted_result"; then
11174f00d7e1Smrg	func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
11184f00d7e1Smrg      else
11194f00d7e1Smrg        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
11204f00d7e1Smrg      fi
11214f00d7e1Smrg
11224f00d7e1Smrg      case $_G_unquoted_arg in
11234f00d7e1Smrg        # Double-quote args containing shell metacharacters to delay
11244f00d7e1Smrg        # word splitting, command substitution and variable expansion
11254f00d7e1Smrg        # for a subsequent eval.
11264f00d7e1Smrg        # Many Bourne shells cannot handle close brackets correctly
11274f00d7e1Smrg        # in scan sets, so we specify it separately.
11284f00d7e1Smrg        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
11294f00d7e1Smrg          _G_quoted_arg=\"$_G_unquoted_arg\"
11304f00d7e1Smrg          ;;
11314f00d7e1Smrg        *)
11324f00d7e1Smrg          _G_quoted_arg=$_G_unquoted_arg
11334f00d7e1Smrg	  ;;
11344f00d7e1Smrg      esac
11354f00d7e1Smrg
11364f00d7e1Smrg      if test -n "$func_quote_for_eval_result"; then
11374f00d7e1Smrg	func_append func_quote_for_eval_result " $_G_quoted_arg"
11384f00d7e1Smrg      else
11394f00d7e1Smrg        func_append func_quote_for_eval_result "$_G_quoted_arg"
11404f00d7e1Smrg      fi
11414f00d7e1Smrg      shift
11424f00d7e1Smrg    done
11434f00d7e1Smrg}
11444f00d7e1Smrg
11454f00d7e1Smrg
11464f00d7e1Smrg# func_quote_for_expand ARG
11474f00d7e1Smrg# -------------------------
11484f00d7e1Smrg# Aesthetically quote ARG to be evaled later; same as above,
11494f00d7e1Smrg# but do not quote variable references.
11504f00d7e1Smrgfunc_quote_for_expand ()
11514f00d7e1Smrg{
11524f00d7e1Smrg    $debug_cmd
11534f00d7e1Smrg
11544f00d7e1Smrg    case $1 in
11554f00d7e1Smrg      *[\\\`\"]*)
11564f00d7e1Smrg	_G_arg=`$ECHO "$1" | $SED \
11574f00d7e1Smrg	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
11584f00d7e1Smrg      *)
11594f00d7e1Smrg        _G_arg=$1 ;;
11604f00d7e1Smrg    esac
11614f00d7e1Smrg
11624f00d7e1Smrg    case $_G_arg in
11634f00d7e1Smrg      # Double-quote args containing shell metacharacters to delay
11644f00d7e1Smrg      # word splitting and command substitution for a subsequent eval.
11654f00d7e1Smrg      # Many Bourne shells cannot handle close brackets correctly
11664f00d7e1Smrg      # in scan sets, so we specify it separately.
11674f00d7e1Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
11684f00d7e1Smrg        _G_arg=\"$_G_arg\"
11694f00d7e1Smrg        ;;
11704f00d7e1Smrg    esac
11714f00d7e1Smrg
11724f00d7e1Smrg    func_quote_for_expand_result=$_G_arg
11734f00d7e1Smrg}
11744f00d7e1Smrg
11754f00d7e1Smrg
11764f00d7e1Smrg# func_stripname PREFIX SUFFIX NAME
11774f00d7e1Smrg# ---------------------------------
11784f00d7e1Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
11794f00d7e1Smrg# PREFIX and SUFFIX must not contain globbing or regex special
11804f00d7e1Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading
11814f00d7e1Smrg# dot (in which case that matches only a dot).
11824f00d7e1Smrgif test yes = "$_G_HAVE_XSI_OPS"; then
11834f00d7e1Smrg  eval 'func_stripname ()
11844f00d7e1Smrg  {
11854f00d7e1Smrg    $debug_cmd
11864f00d7e1Smrg
11874f00d7e1Smrg    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
11884f00d7e1Smrg    # positional parameters, so assign one to ordinary variable first.
11894f00d7e1Smrg    func_stripname_result=$3
11904f00d7e1Smrg    func_stripname_result=${func_stripname_result#"$1"}
11914f00d7e1Smrg    func_stripname_result=${func_stripname_result%"$2"}
11924f00d7e1Smrg  }'
11934f00d7e1Smrgelse
11944f00d7e1Smrg  func_stripname ()
11954f00d7e1Smrg  {
11964f00d7e1Smrg    $debug_cmd
11974f00d7e1Smrg
11984f00d7e1Smrg    case $2 in
11994f00d7e1Smrg      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
12004f00d7e1Smrg      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
12014f00d7e1Smrg    esac
12024f00d7e1Smrg  }
12034f00d7e1Smrgfi
12044f00d7e1Smrg
12054f00d7e1Smrg
12064f00d7e1Smrg# func_show_eval CMD [FAIL_EXP]
12074f00d7e1Smrg# -----------------------------
12084f00d7e1Smrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
12094f00d7e1Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
12104f00d7e1Smrg# is given, then evaluate it.
12114f00d7e1Smrgfunc_show_eval ()
12124f00d7e1Smrg{
12134f00d7e1Smrg    $debug_cmd
12144f00d7e1Smrg
12154f00d7e1Smrg    _G_cmd=$1
12164f00d7e1Smrg    _G_fail_exp=${2-':'}
12174f00d7e1Smrg
12184f00d7e1Smrg    func_quote_for_expand "$_G_cmd"
12194f00d7e1Smrg    eval "func_notquiet $func_quote_for_expand_result"
12204f00d7e1Smrg
12214f00d7e1Smrg    $opt_dry_run || {
12224f00d7e1Smrg      eval "$_G_cmd"
12234f00d7e1Smrg      _G_status=$?
12244f00d7e1Smrg      if test 0 -ne "$_G_status"; then
12254f00d7e1Smrg	eval "(exit $_G_status); $_G_fail_exp"
12264f00d7e1Smrg      fi
12274f00d7e1Smrg    }
12284f00d7e1Smrg}
12294f00d7e1Smrg
12304f00d7e1Smrg
12314f00d7e1Smrg# func_show_eval_locale CMD [FAIL_EXP]
12324f00d7e1Smrg# ------------------------------------
12334f00d7e1Smrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
12344f00d7e1Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
12354f00d7e1Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
12364f00d7e1Smrgfunc_show_eval_locale ()
12374f00d7e1Smrg{
12384f00d7e1Smrg    $debug_cmd
12394f00d7e1Smrg
12404f00d7e1Smrg    _G_cmd=$1
12414f00d7e1Smrg    _G_fail_exp=${2-':'}
12424f00d7e1Smrg
12434f00d7e1Smrg    $opt_quiet || {
12444f00d7e1Smrg      func_quote_for_expand "$_G_cmd"
12454f00d7e1Smrg      eval "func_echo $func_quote_for_expand_result"
12464f00d7e1Smrg    }
12474f00d7e1Smrg
12484f00d7e1Smrg    $opt_dry_run || {
12494f00d7e1Smrg      eval "$_G_user_locale
12504f00d7e1Smrg	    $_G_cmd"
12514f00d7e1Smrg      _G_status=$?
12524f00d7e1Smrg      eval "$_G_safe_locale"
12534f00d7e1Smrg      if test 0 -ne "$_G_status"; then
12544f00d7e1Smrg	eval "(exit $_G_status); $_G_fail_exp"
12554f00d7e1Smrg      fi
12564f00d7e1Smrg    }
12574f00d7e1Smrg}
12584f00d7e1Smrg
12594f00d7e1Smrg
12604f00d7e1Smrg# func_tr_sh
12614f00d7e1Smrg# ----------
12624f00d7e1Smrg# Turn $1 into a string suitable for a shell variable name.
12634f00d7e1Smrg# Result is stored in $func_tr_sh_result.  All characters
12644f00d7e1Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
12654f00d7e1Smrg# if $1 begins with a digit, a '_' is prepended as well.
12664f00d7e1Smrgfunc_tr_sh ()
12674f00d7e1Smrg{
12684f00d7e1Smrg    $debug_cmd
12694f00d7e1Smrg
12704f00d7e1Smrg    case $1 in
12714f00d7e1Smrg    [0-9]* | *[!a-zA-Z0-9_]*)
12724f00d7e1Smrg      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
12734f00d7e1Smrg      ;;
12744f00d7e1Smrg    * )
12754f00d7e1Smrg      func_tr_sh_result=$1
12764f00d7e1Smrg      ;;
12774f00d7e1Smrg    esac
12784f00d7e1Smrg}
12794f00d7e1Smrg
12804f00d7e1Smrg
12814f00d7e1Smrg# func_verbose ARG...
12824f00d7e1Smrg# -------------------
12834f00d7e1Smrg# Echo program name prefixed message in verbose mode only.
12844f00d7e1Smrgfunc_verbose ()
12854f00d7e1Smrg{
12864f00d7e1Smrg    $debug_cmd
12874f00d7e1Smrg
12884f00d7e1Smrg    $opt_verbose && func_echo "$*"
12894f00d7e1Smrg
12904f00d7e1Smrg    :
12914f00d7e1Smrg}
12924f00d7e1Smrg
12934f00d7e1Smrg
12944f00d7e1Smrg# func_warn_and_continue ARG...
12954f00d7e1Smrg# -----------------------------
12964f00d7e1Smrg# Echo program name prefixed warning message to standard error.
12974f00d7e1Smrgfunc_warn_and_continue ()
12984f00d7e1Smrg{
12994f00d7e1Smrg    $debug_cmd
13004f00d7e1Smrg
13014f00d7e1Smrg    $require_term_colors
13024f00d7e1Smrg
13034f00d7e1Smrg    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
13044f00d7e1Smrg}
13054f00d7e1Smrg
13064f00d7e1Smrg
13074f00d7e1Smrg# func_warning CATEGORY ARG...
13084f00d7e1Smrg# ----------------------------
13094f00d7e1Smrg# Echo program name prefixed warning message to standard error. Warning
13104f00d7e1Smrg# messages can be filtered according to CATEGORY, where this function
13114f00d7e1Smrg# elides messages where CATEGORY is not listed in the global variable
13124f00d7e1Smrg# 'opt_warning_types'.
13134f00d7e1Smrgfunc_warning ()
13144f00d7e1Smrg{
13154f00d7e1Smrg    $debug_cmd
13164f00d7e1Smrg
13174f00d7e1Smrg    # CATEGORY must be in the warning_categories list!
13184f00d7e1Smrg    case " $warning_categories " in
13194f00d7e1Smrg      *" $1 "*) ;;
13204f00d7e1Smrg      *) func_internal_error "invalid warning category '$1'" ;;
13214f00d7e1Smrg    esac
13224f00d7e1Smrg
13234f00d7e1Smrg    _G_category=$1
13244f00d7e1Smrg    shift
13254f00d7e1Smrg
13264f00d7e1Smrg    case " $opt_warning_types " in
13274f00d7e1Smrg      *" $_G_category "*) $warning_func ${1+"$@"} ;;
13284f00d7e1Smrg    esac
13294f00d7e1Smrg}
13304f00d7e1Smrg
13314f00d7e1Smrg
13324f00d7e1Smrg# func_sort_ver VER1 VER2
13334f00d7e1Smrg# -----------------------
13344f00d7e1Smrg# 'sort -V' is not generally available.
13354f00d7e1Smrg# Note this deviates from the version comparison in automake
13364f00d7e1Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
13374f00d7e1Smrg# but this should suffice as we won't be specifying old
13384f00d7e1Smrg# version formats or redundant trailing .0 in bootstrap.conf.
13394f00d7e1Smrg# If we did want full compatibility then we should probably
13404f00d7e1Smrg# use m4_version_compare from autoconf.
13414f00d7e1Smrgfunc_sort_ver ()
13424f00d7e1Smrg{
13434f00d7e1Smrg    $debug_cmd
13444f00d7e1Smrg
13454f00d7e1Smrg    printf '%s\n%s\n' "$1" "$2" \
13464f00d7e1Smrg      | 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
13474f00d7e1Smrg}
13484f00d7e1Smrg
13494f00d7e1Smrg# func_lt_ver PREV CURR
13504f00d7e1Smrg# ---------------------
13514f00d7e1Smrg# Return true if PREV and CURR are in the correct order according to
13524f00d7e1Smrg# func_sort_ver, otherwise false.  Use it like this:
13534f00d7e1Smrg#
13544f00d7e1Smrg#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
13554f00d7e1Smrgfunc_lt_ver ()
13564f00d7e1Smrg{
13574f00d7e1Smrg    $debug_cmd
13584f00d7e1Smrg
13594f00d7e1Smrg    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
13604f00d7e1Smrg}
13614f00d7e1Smrg
13624f00d7e1Smrg
13634f00d7e1Smrg# Local variables:
13644f00d7e1Smrg# mode: shell-script
13654f00d7e1Smrg# sh-indentation: 2
13664f00d7e1Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
13674f00d7e1Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
13684f00d7e1Smrg# time-stamp-time-zone: "UTC"
13694f00d7e1Smrg# End:
13704f00d7e1Smrg#! /bin/sh
13714f00d7e1Smrg
13724f00d7e1Smrg# Set a version string for this script.
13734f00d7e1Smrgscriptversion=2014-01-07.03; # UTC
13744f00d7e1Smrg
13754f00d7e1Smrg# A portable, pluggable option parser for Bourne shell.
13764f00d7e1Smrg# Written by Gary V. Vaughan, 2010
13774f00d7e1Smrg
13784f00d7e1Smrg# Copyright (C) 2010-2015 Free Software Foundation, Inc.
13794f00d7e1Smrg# This is free software; see the source for copying conditions.  There is NO
13804f00d7e1Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13814f00d7e1Smrg
13824f00d7e1Smrg# This program is free software: you can redistribute it and/or modify
13834f00d7e1Smrg# it under the terms of the GNU General Public License as published by
13844f00d7e1Smrg# the Free Software Foundation, either version 3 of the License, or
13854f00d7e1Smrg# (at your option) any later version.
13864f00d7e1Smrg
13874f00d7e1Smrg# This program is distributed in the hope that it will be useful,
13884f00d7e1Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
13894f00d7e1Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13904f00d7e1Smrg# GNU General Public License for more details.
13914f00d7e1Smrg
13924f00d7e1Smrg# You should have received a copy of the GNU General Public License
13934f00d7e1Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
13944f00d7e1Smrg
13954f00d7e1Smrg# Please report bugs or propose patches to gary@gnu.org.
13964f00d7e1Smrg
13974f00d7e1Smrg
13984f00d7e1Smrg## ------ ##
13994f00d7e1Smrg## Usage. ##
14004f00d7e1Smrg## ------ ##
14014f00d7e1Smrg
14024f00d7e1Smrg# This file is a library for parsing options in your shell scripts along
14034f00d7e1Smrg# with assorted other useful supporting features that you can make use
14044f00d7e1Smrg# of too.
14054f00d7e1Smrg#
14064f00d7e1Smrg# For the simplest scripts you might need only:
14074f00d7e1Smrg#
14084f00d7e1Smrg#   #!/bin/sh
14094f00d7e1Smrg#   . relative/path/to/funclib.sh
14104f00d7e1Smrg#   . relative/path/to/options-parser
14114f00d7e1Smrg#   scriptversion=1.0
14124f00d7e1Smrg#   func_options ${1+"$@"}
14134f00d7e1Smrg#   eval set dummy "$func_options_result"; shift
14144f00d7e1Smrg#   ...rest of your script...
14154f00d7e1Smrg#
14164f00d7e1Smrg# In order for the '--version' option to work, you will need to have a
14174f00d7e1Smrg# suitably formatted comment like the one at the top of this file
14184f00d7e1Smrg# starting with '# Written by ' and ending with '# warranty; '.
14194f00d7e1Smrg#
14204f00d7e1Smrg# For '-h' and '--help' to work, you will also need a one line
14214f00d7e1Smrg# description of your script's purpose in a comment directly above the
14224f00d7e1Smrg# '# Written by ' line, like the one at the top of this file.
14234f00d7e1Smrg#
14244f00d7e1Smrg# The default options also support '--debug', which will turn on shell
14254f00d7e1Smrg# execution tracing (see the comment above debug_cmd below for another
14264f00d7e1Smrg# use), and '--verbose' and the func_verbose function to allow your script
14274f00d7e1Smrg# to display verbose messages only when your user has specified
14284f00d7e1Smrg# '--verbose'.
14294f00d7e1Smrg#
14304f00d7e1Smrg# After sourcing this file, you can plug processing for additional
14314f00d7e1Smrg# options by amending the variables from the 'Configuration' section
14324f00d7e1Smrg# below, and following the instructions in the 'Option parsing'
14334f00d7e1Smrg# section further down.
14344f00d7e1Smrg
14354f00d7e1Smrg## -------------- ##
14364f00d7e1Smrg## Configuration. ##
14374f00d7e1Smrg## -------------- ##
14384f00d7e1Smrg
14394f00d7e1Smrg# You should override these variables in your script after sourcing this
14404f00d7e1Smrg# file so that they reflect the customisations you have added to the
14414f00d7e1Smrg# option parser.
14424f00d7e1Smrg
14434f00d7e1Smrg# The usage line for option parsing errors and the start of '-h' and
14444f00d7e1Smrg# '--help' output messages. You can embed shell variables for delayed
14454f00d7e1Smrg# expansion at the time the message is displayed, but you will need to
14464f00d7e1Smrg# quote other shell meta-characters carefully to prevent them being
14474f00d7e1Smrg# expanded when the contents are evaled.
14484f00d7e1Smrgusage='$progpath [OPTION]...'
14494f00d7e1Smrg
14504f00d7e1Smrg# Short help message in response to '-h' and '--help'.  Add to this or
14514f00d7e1Smrg# override it after sourcing this library to reflect the full set of
14524f00d7e1Smrg# options your script accepts.
14534f00d7e1Smrgusage_message="\
14544f00d7e1Smrg       --debug        enable verbose shell tracing
14554f00d7e1Smrg   -W, --warnings=CATEGORY
14564f00d7e1Smrg                      report the warnings falling in CATEGORY [all]
14574f00d7e1Smrg   -v, --verbose      verbosely report processing
14584f00d7e1Smrg       --version      print version information and exit
14594f00d7e1Smrg   -h, --help         print short or long help message and exit
14604f00d7e1Smrg"
14614f00d7e1Smrg
14624f00d7e1Smrg# Additional text appended to 'usage_message' in response to '--help'.
14634f00d7e1Smrglong_help_message="
14644f00d7e1SmrgWarning categories include:
14654f00d7e1Smrg       'all'          show all warnings
14664f00d7e1Smrg       'none'         turn off all the warnings
14674f00d7e1Smrg       'error'        warnings are treated as fatal errors"
14684f00d7e1Smrg
14694f00d7e1Smrg# Help message printed before fatal option parsing errors.
14704f00d7e1Smrgfatal_help="Try '\$progname --help' for more information."
14714f00d7e1Smrg
14724f00d7e1Smrg
14734f00d7e1Smrg
14744f00d7e1Smrg## ------------------------- ##
14754f00d7e1Smrg## Hook function management. ##
14764f00d7e1Smrg## ------------------------- ##
14774f00d7e1Smrg
14784f00d7e1Smrg# This section contains functions for adding, removing, and running hooks
14794f00d7e1Smrg# to the main code.  A hook is just a named list of of function, that can
14804f00d7e1Smrg# be run in order later on.
14814f00d7e1Smrg
14824f00d7e1Smrg# func_hookable FUNC_NAME
14834f00d7e1Smrg# -----------------------
14844f00d7e1Smrg# Declare that FUNC_NAME will run hooks added with
14854f00d7e1Smrg# 'func_add_hook FUNC_NAME ...'.
14864f00d7e1Smrgfunc_hookable ()
14874f00d7e1Smrg{
14884f00d7e1Smrg    $debug_cmd
14894f00d7e1Smrg
14904f00d7e1Smrg    func_append hookable_fns " $1"
14914f00d7e1Smrg}
14924f00d7e1Smrg
14934f00d7e1Smrg
14944f00d7e1Smrg# func_add_hook FUNC_NAME HOOK_FUNC
14954f00d7e1Smrg# ---------------------------------
14964f00d7e1Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
14974f00d7e1Smrg# first have been declared "hookable" by a call to 'func_hookable'.
14984f00d7e1Smrgfunc_add_hook ()
14994f00d7e1Smrg{
15004f00d7e1Smrg    $debug_cmd
15014f00d7e1Smrg
15024f00d7e1Smrg    case " $hookable_fns " in
15034f00d7e1Smrg      *" $1 "*) ;;
15044f00d7e1Smrg      *) func_fatal_error "'$1' does not accept hook functions." ;;
15054f00d7e1Smrg    esac
15064f00d7e1Smrg
15074f00d7e1Smrg    eval func_append ${1}_hooks '" $2"'
15084f00d7e1Smrg}
15094f00d7e1Smrg
15104f00d7e1Smrg
15114f00d7e1Smrg# func_remove_hook FUNC_NAME HOOK_FUNC
15124f00d7e1Smrg# ------------------------------------
15134f00d7e1Smrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
15144f00d7e1Smrgfunc_remove_hook ()
15154f00d7e1Smrg{
15164f00d7e1Smrg    $debug_cmd
15174f00d7e1Smrg
15184f00d7e1Smrg    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
15194f00d7e1Smrg}
15204f00d7e1Smrg
15214f00d7e1Smrg
15224f00d7e1Smrg# func_run_hooks FUNC_NAME [ARG]...
15234f00d7e1Smrg# ---------------------------------
15244f00d7e1Smrg# Run all hook functions registered to FUNC_NAME.
15254f00d7e1Smrg# It is assumed that the list of hook functions contains nothing more
15264f00d7e1Smrg# than a whitespace-delimited list of legal shell function names, and
15274f00d7e1Smrg# no effort is wasted trying to catch shell meta-characters or preserve
15284f00d7e1Smrg# whitespace.
15294f00d7e1Smrgfunc_run_hooks ()
15304f00d7e1Smrg{
15314f00d7e1Smrg    $debug_cmd
15324f00d7e1Smrg
15334f00d7e1Smrg    case " $hookable_fns " in
15344f00d7e1Smrg      *" $1 "*) ;;
15354f00d7e1Smrg      *) func_fatal_error "'$1' does not support hook funcions.n" ;;
15364f00d7e1Smrg    esac
15374f00d7e1Smrg
15384f00d7e1Smrg    eval _G_hook_fns=\$$1_hooks; shift
15394f00d7e1Smrg
15404f00d7e1Smrg    for _G_hook in $_G_hook_fns; do
15414f00d7e1Smrg      eval $_G_hook '"$@"'
15424f00d7e1Smrg
15434f00d7e1Smrg      # store returned options list back into positional
15444f00d7e1Smrg      # parameters for next 'cmd' execution.
15454f00d7e1Smrg      eval _G_hook_result=\$${_G_hook}_result
15464f00d7e1Smrg      eval set dummy "$_G_hook_result"; shift
15474f00d7e1Smrg    done
15484f00d7e1Smrg
15494f00d7e1Smrg    func_quote_for_eval ${1+"$@"}
15504f00d7e1Smrg    func_run_hooks_result=$func_quote_for_eval_result
15514f00d7e1Smrg}
15524f00d7e1Smrg
15534f00d7e1Smrg
15544f00d7e1Smrg
15554f00d7e1Smrg## --------------- ##
15564f00d7e1Smrg## Option parsing. ##
15574f00d7e1Smrg## --------------- ##
15584f00d7e1Smrg
15594f00d7e1Smrg# In order to add your own option parsing hooks, you must accept the
15604f00d7e1Smrg# full positional parameter list in your hook function, remove any
15614f00d7e1Smrg# options that you action, and then pass back the remaining unprocessed
15624f00d7e1Smrg# options in '<hooked_function_name>_result', escaped suitably for
15634f00d7e1Smrg# 'eval'.  Like this:
15644f00d7e1Smrg#
15654f00d7e1Smrg#    my_options_prep ()
15664f00d7e1Smrg#    {
15674f00d7e1Smrg#        $debug_cmd
15684f00d7e1Smrg#
15694f00d7e1Smrg#        # Extend the existing usage message.
15704f00d7e1Smrg#        usage_message=$usage_message'
15714f00d7e1Smrg#      -s, --silent       don'\''t print informational messages
15724f00d7e1Smrg#    '
15734f00d7e1Smrg#
15744f00d7e1Smrg#        func_quote_for_eval ${1+"$@"}
15754f00d7e1Smrg#        my_options_prep_result=$func_quote_for_eval_result
15764f00d7e1Smrg#    }
15774f00d7e1Smrg#    func_add_hook func_options_prep my_options_prep
15784f00d7e1Smrg#
15794f00d7e1Smrg#
15804f00d7e1Smrg#    my_silent_option ()
15814f00d7e1Smrg#    {
15824f00d7e1Smrg#        $debug_cmd
15834f00d7e1Smrg#
15844f00d7e1Smrg#        # Note that for efficiency, we parse as many options as we can
15854f00d7e1Smrg#        # recognise in a loop before passing the remainder back to the
15864f00d7e1Smrg#        # caller on the first unrecognised argument we encounter.
15874f00d7e1Smrg#        while test $# -gt 0; do
15884f00d7e1Smrg#          opt=$1; shift
15894f00d7e1Smrg#          case $opt in
15904f00d7e1Smrg#            --silent|-s) opt_silent=: ;;
15914f00d7e1Smrg#            # Separate non-argument short options:
15924f00d7e1Smrg#            -s*)         func_split_short_opt "$_G_opt"
15934f00d7e1Smrg#                         set dummy "$func_split_short_opt_name" \
15944f00d7e1Smrg#                             "-$func_split_short_opt_arg" ${1+"$@"}
15954f00d7e1Smrg#                         shift
15964f00d7e1Smrg#                         ;;
15974f00d7e1Smrg#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
15984f00d7e1Smrg#          esac
15994f00d7e1Smrg#        done
16004f00d7e1Smrg#
16014f00d7e1Smrg#        func_quote_for_eval ${1+"$@"}
16024f00d7e1Smrg#        my_silent_option_result=$func_quote_for_eval_result
16034f00d7e1Smrg#    }
16044f00d7e1Smrg#    func_add_hook func_parse_options my_silent_option
16054f00d7e1Smrg#
16064f00d7e1Smrg#
16074f00d7e1Smrg#    my_option_validation ()
16084f00d7e1Smrg#    {
16094f00d7e1Smrg#        $debug_cmd
16104f00d7e1Smrg#
16114f00d7e1Smrg#        $opt_silent && $opt_verbose && func_fatal_help "\
16124f00d7e1Smrg#    '--silent' and '--verbose' options are mutually exclusive."
16134f00d7e1Smrg#
16144f00d7e1Smrg#        func_quote_for_eval ${1+"$@"}
16154f00d7e1Smrg#        my_option_validation_result=$func_quote_for_eval_result
16164f00d7e1Smrg#    }
16174f00d7e1Smrg#    func_add_hook func_validate_options my_option_validation
16184f00d7e1Smrg#
16194f00d7e1Smrg# You'll alse need to manually amend $usage_message to reflect the extra
16204f00d7e1Smrg# options you parse.  It's preferable to append if you can, so that
16214f00d7e1Smrg# multiple option parsing hooks can be added safely.
16224f00d7e1Smrg
16234f00d7e1Smrg
16244f00d7e1Smrg# func_options [ARG]...
16254f00d7e1Smrg# ---------------------
16264f00d7e1Smrg# All the functions called inside func_options are hookable. See the
16274f00d7e1Smrg# individual implementations for details.
16284f00d7e1Smrgfunc_hookable func_options
16294f00d7e1Smrgfunc_options ()
16304f00d7e1Smrg{
16314f00d7e1Smrg    $debug_cmd
16324f00d7e1Smrg
16334f00d7e1Smrg    func_options_prep ${1+"$@"}
16344f00d7e1Smrg    eval func_parse_options \
16354f00d7e1Smrg        ${func_options_prep_result+"$func_options_prep_result"}
16364f00d7e1Smrg    eval func_validate_options \
16374f00d7e1Smrg        ${func_parse_options_result+"$func_parse_options_result"}
16384f00d7e1Smrg
16394f00d7e1Smrg    eval func_run_hooks func_options \
16404f00d7e1Smrg        ${func_validate_options_result+"$func_validate_options_result"}
16414f00d7e1Smrg
16424f00d7e1Smrg    # save modified positional parameters for caller
16434f00d7e1Smrg    func_options_result=$func_run_hooks_result
1644bdcaa8d0Smrg}
1645bdcaa8d0Smrg
1646bdcaa8d0Smrg
16474f00d7e1Smrg# func_options_prep [ARG]...
16484f00d7e1Smrg# --------------------------
16494f00d7e1Smrg# All initialisations required before starting the option parse loop.
16504f00d7e1Smrg# Note that when calling hook functions, we pass through the list of
16514f00d7e1Smrg# positional parameters.  If a hook function modifies that list, and
16524f00d7e1Smrg# needs to propogate that back to rest of this script, then the complete
16534f00d7e1Smrg# modified list must be put in 'func_run_hooks_result' before
16544f00d7e1Smrg# returning.
16554f00d7e1Smrgfunc_hookable func_options_prep
16564f00d7e1Smrgfunc_options_prep ()
1657bdcaa8d0Smrg{
16584f00d7e1Smrg    $debug_cmd
16590b661123Smrg
16604f00d7e1Smrg    # Option defaults:
16614f00d7e1Smrg    opt_verbose=false
16624f00d7e1Smrg    opt_warning_types=
16634f00d7e1Smrg
16644f00d7e1Smrg    func_run_hooks func_options_prep ${1+"$@"}
16654f00d7e1Smrg
16664f00d7e1Smrg    # save modified positional parameters for caller
16674f00d7e1Smrg    func_options_prep_result=$func_run_hooks_result
1668bdcaa8d0Smrg}
1669bdcaa8d0Smrg
1670bdcaa8d0Smrg
16714f00d7e1Smrg# func_parse_options [ARG]...
16724f00d7e1Smrg# ---------------------------
16734f00d7e1Smrg# The main option parsing loop.
16744f00d7e1Smrgfunc_hookable func_parse_options
16754f00d7e1Smrgfunc_parse_options ()
1676bdcaa8d0Smrg{
16774f00d7e1Smrg    $debug_cmd
16780b661123Smrg
16794f00d7e1Smrg    func_parse_options_result=
16800b661123Smrg
16814f00d7e1Smrg    # this just eases exit handling
16824f00d7e1Smrg    while test $# -gt 0; do
16834f00d7e1Smrg      # Defer to hook functions for initial option parsing, so they
16844f00d7e1Smrg      # get priority in the event of reusing an option name.
16854f00d7e1Smrg      func_run_hooks func_parse_options ${1+"$@"}
1686bdcaa8d0Smrg
16874f00d7e1Smrg      # Adjust func_parse_options positional parameters to match
16884f00d7e1Smrg      eval set dummy "$func_run_hooks_result"; shift
1689bdcaa8d0Smrg
16904f00d7e1Smrg      # Break out of the loop if we already parsed every option.
16914f00d7e1Smrg      test $# -gt 0 || break
169272313efbSmrg
16934f00d7e1Smrg      _G_opt=$1
16944f00d7e1Smrg      shift
16954f00d7e1Smrg      case $_G_opt in
16964f00d7e1Smrg        --debug|-x)   debug_cmd='set -x'
16974f00d7e1Smrg                      func_echo "enabling shell trace mode"
16984f00d7e1Smrg                      $debug_cmd
16994f00d7e1Smrg                      ;;
17004f00d7e1Smrg
17014f00d7e1Smrg        --no-warnings|--no-warning|--no-warn)
17024f00d7e1Smrg                      set dummy --warnings none ${1+"$@"}
17034f00d7e1Smrg                      shift
17044f00d7e1Smrg		      ;;
17050b661123Smrg
17064f00d7e1Smrg        --warnings|--warning|-W)
17074f00d7e1Smrg                      test $# = 0 && func_missing_arg $_G_opt && break
17084f00d7e1Smrg                      case " $warning_categories $1" in
17094f00d7e1Smrg                        *" $1 "*)
17104f00d7e1Smrg                          # trailing space prevents matching last $1 above
17114f00d7e1Smrg                          func_append_uniq opt_warning_types " $1"
17124f00d7e1Smrg                          ;;
17134f00d7e1Smrg                        *all)
17144f00d7e1Smrg                          opt_warning_types=$warning_categories
17154f00d7e1Smrg                          ;;
17164f00d7e1Smrg                        *none)
17174f00d7e1Smrg                          opt_warning_types=none
17184f00d7e1Smrg                          warning_func=:
17194f00d7e1Smrg                          ;;
17204f00d7e1Smrg                        *error)
17214f00d7e1Smrg                          opt_warning_types=$warning_categories
17224f00d7e1Smrg                          warning_func=func_fatal_error
17234f00d7e1Smrg                          ;;
17244f00d7e1Smrg                        *)
17254f00d7e1Smrg                          func_fatal_error \
17264f00d7e1Smrg                             "unsupported warning category: '$1'"
17274f00d7e1Smrg                          ;;
17284f00d7e1Smrg                      esac
17294f00d7e1Smrg                      shift
17304f00d7e1Smrg                      ;;
17314f00d7e1Smrg
17324f00d7e1Smrg        --verbose|-v) opt_verbose=: ;;
17334f00d7e1Smrg        --version)    func_version ;;
17344f00d7e1Smrg        -\?|-h)       func_usage ;;
17354f00d7e1Smrg        --help)       func_help ;;
17364f00d7e1Smrg
17374f00d7e1Smrg	# Separate optargs to long options (plugins may need this):
17384f00d7e1Smrg	--*=*)        func_split_equals "$_G_opt"
17394f00d7e1Smrg	              set dummy "$func_split_equals_lhs" \
17404f00d7e1Smrg                          "$func_split_equals_rhs" ${1+"$@"}
17414f00d7e1Smrg                      shift
17424f00d7e1Smrg                      ;;
17434f00d7e1Smrg
17444f00d7e1Smrg       # Separate optargs to short options:
17454f00d7e1Smrg        -W*)
17464f00d7e1Smrg                      func_split_short_opt "$_G_opt"
17474f00d7e1Smrg                      set dummy "$func_split_short_opt_name" \
17484f00d7e1Smrg                          "$func_split_short_opt_arg" ${1+"$@"}
17494f00d7e1Smrg                      shift
17504f00d7e1Smrg                      ;;
17514f00d7e1Smrg
17524f00d7e1Smrg        # Separate non-argument short options:
17534f00d7e1Smrg        -\?*|-h*|-v*|-x*)
17544f00d7e1Smrg                      func_split_short_opt "$_G_opt"
17554f00d7e1Smrg                      set dummy "$func_split_short_opt_name" \
17564f00d7e1Smrg                          "-$func_split_short_opt_arg" ${1+"$@"}
17574f00d7e1Smrg                      shift
17584f00d7e1Smrg                      ;;
17594f00d7e1Smrg
17604f00d7e1Smrg        --)           break ;;
17614f00d7e1Smrg        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
17624f00d7e1Smrg        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
17634f00d7e1Smrg      esac
17644f00d7e1Smrg    done
17654f00d7e1Smrg
17664f00d7e1Smrg    # save modified positional parameters for caller
17674f00d7e1Smrg    func_quote_for_eval ${1+"$@"}
17684f00d7e1Smrg    func_parse_options_result=$func_quote_for_eval_result
1769bdcaa8d0Smrg}
1770bdcaa8d0Smrg
17710b661123Smrg
17724f00d7e1Smrg# func_validate_options [ARG]...
17734f00d7e1Smrg# ------------------------------
17744f00d7e1Smrg# Perform any sanity checks on option settings and/or unconsumed
17754f00d7e1Smrg# arguments.
17764f00d7e1Smrgfunc_hookable func_validate_options
17774f00d7e1Smrgfunc_validate_options ()
1778bdcaa8d0Smrg{
17794f00d7e1Smrg    $debug_cmd
17800b661123Smrg
17814f00d7e1Smrg    # Display all warnings if -W was not given.
17824f00d7e1Smrg    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
17830b661123Smrg
17844f00d7e1Smrg    func_run_hooks func_validate_options ${1+"$@"}
1785bdcaa8d0Smrg
17864f00d7e1Smrg    # Bail if the options were screwed!
17874f00d7e1Smrg    $exit_cmd $EXIT_FAILURE
17884f00d7e1Smrg
17894f00d7e1Smrg    # save modified positional parameters for caller
17904f00d7e1Smrg    func_validate_options_result=$func_run_hooks_result
1791880c7e28Smrg}
17920b661123Smrg
17930b661123Smrg
1794880c7e28Smrg
17954f00d7e1Smrg## ----------------- ##
17964f00d7e1Smrg## Helper functions. ##
17974f00d7e1Smrg## ----------------- ##
17980b661123Smrg
17994f00d7e1Smrg# This section contains the helper functions used by the rest of the
18004f00d7e1Smrg# hookable option parser framework in ascii-betical order.
18014f00d7e1Smrg
18024f00d7e1Smrg
18034f00d7e1Smrg# func_fatal_help ARG...
18044f00d7e1Smrg# ----------------------
18054f00d7e1Smrg# Echo program name prefixed message to standard error, followed by
18064f00d7e1Smrg# a help hint, and exit.
18074f00d7e1Smrgfunc_fatal_help ()
18080b661123Smrg{
18094f00d7e1Smrg    $debug_cmd
1810880c7e28Smrg
18114f00d7e1Smrg    eval \$ECHO \""Usage: $usage"\"
18124f00d7e1Smrg    eval \$ECHO \""$fatal_help"\"
18134f00d7e1Smrg    func_error ${1+"$@"}
18144f00d7e1Smrg    exit $EXIT_FAILURE
18150b661123Smrg}
18160b661123Smrg
18174f00d7e1Smrg
18184f00d7e1Smrg# func_help
18194f00d7e1Smrg# ---------
18204f00d7e1Smrg# Echo long help message to standard output and exit.
18210b661123Smrgfunc_help ()
18220b661123Smrg{
18234f00d7e1Smrg    $debug_cmd
18244f00d7e1Smrg
18254f00d7e1Smrg    func_usage_message
18264f00d7e1Smrg    $ECHO "$long_help_message"
18274f00d7e1Smrg    exit 0
18280b661123Smrg}
18290b661123Smrg
18304f00d7e1Smrg
18314f00d7e1Smrg# func_missing_arg ARGNAME
18324f00d7e1Smrg# ------------------------
18330b661123Smrg# Echo program name prefixed message to standard error and set global
18340b661123Smrg# exit_cmd.
18350b661123Smrgfunc_missing_arg ()
18360b661123Smrg{
18374f00d7e1Smrg    $debug_cmd
1838880c7e28Smrg
18394f00d7e1Smrg    func_error "Missing argument for '$1'."
18400b661123Smrg    exit_cmd=exit
184172313efbSmrg}
184272313efbSmrg
184372313efbSmrg
18444f00d7e1Smrg# func_split_equals STRING
18454f00d7e1Smrg# ------------------------
18464f00d7e1Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
18474f00d7e1Smrg# splitting STRING at the '=' sign.
18484f00d7e1Smrgtest -z "$_G_HAVE_XSI_OPS" \
18494f00d7e1Smrg    && (eval 'x=a/b/c;
18504f00d7e1Smrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
18514f00d7e1Smrg    && _G_HAVE_XSI_OPS=yes
18524f00d7e1Smrg
18534f00d7e1Smrgif test yes = "$_G_HAVE_XSI_OPS"
18544f00d7e1Smrgthen
18554f00d7e1Smrg  # This is an XSI compatible shell, allowing a faster implementation...
18564f00d7e1Smrg  eval 'func_split_equals ()
18574f00d7e1Smrg  {
18584f00d7e1Smrg      $debug_cmd
18594f00d7e1Smrg
18604f00d7e1Smrg      func_split_equals_lhs=${1%%=*}
18614f00d7e1Smrg      func_split_equals_rhs=${1#*=}
18624f00d7e1Smrg      test "x$func_split_equals_lhs" = "x$1" \
18634f00d7e1Smrg        && func_split_equals_rhs=
18644f00d7e1Smrg  }'
18654f00d7e1Smrgelse
18664f00d7e1Smrg  # ...otherwise fall back to using expr, which is often a shell builtin.
18674f00d7e1Smrg  func_split_equals ()
18684f00d7e1Smrg  {
18694f00d7e1Smrg      $debug_cmd
18704f00d7e1Smrg
18714f00d7e1Smrg      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
18724f00d7e1Smrg      func_split_equals_rhs=
18734f00d7e1Smrg      test "x$func_split_equals_lhs" = "x$1" \
18744f00d7e1Smrg        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
18754f00d7e1Smrg  }
18764f00d7e1Smrgfi #func_split_equals
18774f00d7e1Smrg
18784f00d7e1Smrg
18794f00d7e1Smrg# func_split_short_opt SHORTOPT
18804f00d7e1Smrg# -----------------------------
1881880c7e28Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
1882880c7e28Smrg# variables after splitting SHORTOPT after the 2nd character.
18834f00d7e1Smrgif test yes = "$_G_HAVE_XSI_OPS"
18844f00d7e1Smrgthen
18854f00d7e1Smrg  # This is an XSI compatible shell, allowing a faster implementation...
18864f00d7e1Smrg  eval 'func_split_short_opt ()
18874f00d7e1Smrg  {
18884f00d7e1Smrg      $debug_cmd
18894f00d7e1Smrg
18904f00d7e1Smrg      func_split_short_opt_arg=${1#??}
18914f00d7e1Smrg      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
18924f00d7e1Smrg  }'
18934f00d7e1Smrgelse
18944f00d7e1Smrg  # ...otherwise fall back to using expr, which is often a shell builtin.
18954f00d7e1Smrg  func_split_short_opt ()
18964f00d7e1Smrg  {
18974f00d7e1Smrg      $debug_cmd
18984f00d7e1Smrg
18994f00d7e1Smrg      func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
19004f00d7e1Smrg      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
19014f00d7e1Smrg  }
19024f00d7e1Smrgfi #func_split_short_opt
19034f00d7e1Smrg
19044f00d7e1Smrg
19054f00d7e1Smrg# func_usage
19064f00d7e1Smrg# ----------
19074f00d7e1Smrg# Echo short help message to standard output and exit.
19084f00d7e1Smrgfunc_usage ()
1909880c7e28Smrg{
19104f00d7e1Smrg    $debug_cmd
191172313efbSmrg
19124f00d7e1Smrg    func_usage_message
19134f00d7e1Smrg    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
19144f00d7e1Smrg    exit 0
19154f00d7e1Smrg}
1916880c7e28Smrg
1917880c7e28Smrg
19184f00d7e1Smrg# func_usage_message
19194f00d7e1Smrg# ------------------
19204f00d7e1Smrg# Echo short help message to standard output.
19214f00d7e1Smrgfunc_usage_message ()
1922880c7e28Smrg{
19234f00d7e1Smrg    $debug_cmd
1924880c7e28Smrg
19254f00d7e1Smrg    eval \$ECHO \""Usage: $usage"\"
19264f00d7e1Smrg    echo
19274f00d7e1Smrg    $SED -n 's|^# ||
19284f00d7e1Smrg        /^Written by/{
19294f00d7e1Smrg          x;p;x
19304f00d7e1Smrg        }
19314f00d7e1Smrg	h
19324f00d7e1Smrg	/^Written by/q' < "$progpath"
19334f00d7e1Smrg    echo
19344f00d7e1Smrg    eval \$ECHO \""$usage_message"\"
19354f00d7e1Smrg}
1936880c7e28Smrg
19370b661123Smrg
19384f00d7e1Smrg# func_version
19394f00d7e1Smrg# ------------
19404f00d7e1Smrg# Echo version message to standard output and exit.
19414f00d7e1Smrgfunc_version ()
19424f00d7e1Smrg{
19434f00d7e1Smrg    $debug_cmd
19440b661123Smrg
19454f00d7e1Smrg    printf '%s\n' "$progname $scriptversion"
19464f00d7e1Smrg    $SED -n '
19474f00d7e1Smrg        /(C)/!b go
19484f00d7e1Smrg        :more
19494f00d7e1Smrg        /\./!{
19504f00d7e1Smrg          N
19514f00d7e1Smrg          s|\n# | |
19524f00d7e1Smrg          b more
19534f00d7e1Smrg        }
19544f00d7e1Smrg        :go
19554f00d7e1Smrg        /^# Written by /,/# warranty; / {
19564f00d7e1Smrg          s|^# ||
19574f00d7e1Smrg          s|^# *$||
19584f00d7e1Smrg          s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
19594f00d7e1Smrg          p
19604f00d7e1Smrg        }
19614f00d7e1Smrg        /^# Written by / {
19624f00d7e1Smrg          s|^# ||
19634f00d7e1Smrg          p
19644f00d7e1Smrg        }
19654f00d7e1Smrg        /^warranty; /q' < "$progpath"
19660b661123Smrg
19674f00d7e1Smrg    exit $?
19684f00d7e1Smrg}
1969bdcaa8d0Smrg
1970bdcaa8d0Smrg
19714f00d7e1Smrg# Local variables:
19724f00d7e1Smrg# mode: shell-script
19734f00d7e1Smrg# sh-indentation: 2
19744f00d7e1Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
19754f00d7e1Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
19764f00d7e1Smrg# time-stamp-time-zone: "UTC"
19774f00d7e1Smrg# End:
1978bdcaa8d0Smrg
19794f00d7e1Smrg# Set a version string.
19804f00d7e1Smrgscriptversion='(GNU libtool) 2.4.6'
1981bdcaa8d0Smrg
19820b661123Smrg
19834f00d7e1Smrg# func_echo ARG...
19844f00d7e1Smrg# ----------------
19854f00d7e1Smrg# Libtool also displays the current mode in messages, so override
19864f00d7e1Smrg# funclib.sh func_echo with this custom definition.
19874f00d7e1Smrgfunc_echo ()
1988880c7e28Smrg{
19894f00d7e1Smrg    $debug_cmd
1990880c7e28Smrg
19914f00d7e1Smrg    _G_message=$*
1992880c7e28Smrg
19934f00d7e1Smrg    func_echo_IFS=$IFS
19944f00d7e1Smrg    IFS=$nl
19954f00d7e1Smrg    for _G_line in $_G_message; do
19964f00d7e1Smrg      IFS=$func_echo_IFS
19974f00d7e1Smrg      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
19984f00d7e1Smrg    done
19994f00d7e1Smrg    IFS=$func_echo_IFS
20004f00d7e1Smrg}
2001880c7e28Smrg
20024f00d7e1Smrg
20034f00d7e1Smrg# func_warning ARG...
20044f00d7e1Smrg# -------------------
20054f00d7e1Smrg# Libtool warnings are not categorized, so override funclib.sh
20064f00d7e1Smrg# func_warning with this simpler definition.
20074f00d7e1Smrgfunc_warning ()
2008880c7e28Smrg{
20094f00d7e1Smrg    $debug_cmd
2010880c7e28Smrg
20114f00d7e1Smrg    $warning_func ${1+"$@"}
20124f00d7e1Smrg}
2013880c7e28Smrg
2014880c7e28Smrg
20154f00d7e1Smrg## ---------------- ##
20164f00d7e1Smrg## Options parsing. ##
20174f00d7e1Smrg## ---------------- ##
20184f00d7e1Smrg
20194f00d7e1Smrg# Hook in the functions to make sure our own options are parsed during
20204f00d7e1Smrg# the option parsing loop.
20214f00d7e1Smrg
20224f00d7e1Smrgusage='$progpath [OPTION]... [MODE-ARG]...'
20234f00d7e1Smrg
20244f00d7e1Smrg# Short help message in response to '-h'.
20254f00d7e1Smrgusage_message="Options:
20264f00d7e1Smrg       --config             show all configuration variables
20274f00d7e1Smrg       --debug              enable verbose shell tracing
20284f00d7e1Smrg   -n, --dry-run            display commands without modifying any files
20294f00d7e1Smrg       --features           display basic configuration information and exit
20304f00d7e1Smrg       --mode=MODE          use operation mode MODE
20314f00d7e1Smrg       --no-warnings        equivalent to '-Wnone'
20324f00d7e1Smrg       --preserve-dup-deps  don't remove duplicate dependency libraries
20334f00d7e1Smrg       --quiet, --silent    don't print informational messages
20344f00d7e1Smrg       --tag=TAG            use configuration variables from tag TAG
20354f00d7e1Smrg   -v, --verbose            print more informational messages than default
20364f00d7e1Smrg       --version            print version information
20374f00d7e1Smrg   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
20384f00d7e1Smrg   -h, --help, --help-all   print short, long, or detailed help message
20394f00d7e1Smrg"
2040880c7e28Smrg
20414f00d7e1Smrg# Additional text appended to 'usage_message' in response to '--help'.
20424f00d7e1Smrgfunc_help ()
2043880c7e28Smrg{
20444f00d7e1Smrg    $debug_cmd
20454f00d7e1Smrg
20464f00d7e1Smrg    func_usage_message
20474f00d7e1Smrg    $ECHO "$long_help_message
20484f00d7e1Smrg
20494f00d7e1SmrgMODE must be one of the following:
20504f00d7e1Smrg
20514f00d7e1Smrg       clean           remove files from the build directory
20524f00d7e1Smrg       compile         compile a source file into a libtool object
20534f00d7e1Smrg       execute         automatically set library path, then run a program
20544f00d7e1Smrg       finish          complete the installation of libtool libraries
20554f00d7e1Smrg       install         install libraries or executables
20564f00d7e1Smrg       link            create a library or an executable
20574f00d7e1Smrg       uninstall       remove libraries from an installed directory
20584f00d7e1Smrg
20594f00d7e1SmrgMODE-ARGS vary depending on the MODE.  When passed as first option,
20604f00d7e1Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
20614f00d7e1SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE.
20624f00d7e1Smrg
20634f00d7e1SmrgWhen reporting a bug, please describe a test case to reproduce it and
20644f00d7e1Smrginclude the following information:
20654f00d7e1Smrg
20664f00d7e1Smrg       host-triplet:   $host
20674f00d7e1Smrg       shell:          $SHELL
20684f00d7e1Smrg       compiler:       $LTCC
20694f00d7e1Smrg       compiler flags: $LTCFLAGS
20704f00d7e1Smrg       linker:         $LD (gnu? $with_gnu_ld)
20714f00d7e1Smrg       version:        $progname (GNU libtool) 2.4.6
20724f00d7e1Smrg       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
20734f00d7e1Smrg       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
20744f00d7e1Smrg
20754f00d7e1SmrgReport bugs to <bug-libtool@gnu.org>.
20764f00d7e1SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>.
20774f00d7e1SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>."
20784f00d7e1Smrg    exit 0
20794f00d7e1Smrg}
2080880c7e28Smrg
2081880c7e28Smrg
20824f00d7e1Smrg# func_lo2o OBJECT-NAME
20834f00d7e1Smrg# ---------------------
20844f00d7e1Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
20854f00d7e1Smrg# object suffix.
20864f00d7e1Smrg
20874f00d7e1Smrglo2o=s/\\.lo\$/.$objext/
20884f00d7e1Smrgo2lo=s/\\.$objext\$/.lo/
20894f00d7e1Smrg
20904f00d7e1Smrgif test yes = "$_G_HAVE_XSI_OPS"; then
20914f00d7e1Smrg  eval 'func_lo2o ()
20924f00d7e1Smrg  {
20934f00d7e1Smrg    case $1 in
20944f00d7e1Smrg      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
20954f00d7e1Smrg      *   ) func_lo2o_result=$1               ;;
20964f00d7e1Smrg    esac
20974f00d7e1Smrg  }'
20984f00d7e1Smrg
20994f00d7e1Smrg  # func_xform LIBOBJ-OR-SOURCE
21004f00d7e1Smrg  # ---------------------------
21014f00d7e1Smrg  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
21024f00d7e1Smrg  # suffix to a '.lo' libtool-object suffix.
21034f00d7e1Smrg  eval 'func_xform ()
21044f00d7e1Smrg  {
21054f00d7e1Smrg    func_xform_result=${1%.*}.lo
21064f00d7e1Smrg  }'
21074f00d7e1Smrgelse
21084f00d7e1Smrg  # ...otherwise fall back to using sed.
21094f00d7e1Smrg  func_lo2o ()
21104f00d7e1Smrg  {
21114f00d7e1Smrg    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
21124f00d7e1Smrg  }
21134f00d7e1Smrg
21144f00d7e1Smrg  func_xform ()
21154f00d7e1Smrg  {
21164f00d7e1Smrg    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
21174f00d7e1Smrg  }
21184f00d7e1Smrgfi
2119880c7e28Smrg
2120880c7e28Smrg
21214f00d7e1Smrg# func_fatal_configuration ARG...
21224f00d7e1Smrg# -------------------------------
21230b661123Smrg# Echo program name prefixed message to standard error, followed by
21240b661123Smrg# a configuration failure hint, and exit.
21250b661123Smrgfunc_fatal_configuration ()
21260b661123Smrg{
21274f00d7e1Smrg    func__fatal_error ${1+"$@"} \
21284f00d7e1Smrg      "See the $PACKAGE documentation for more information." \
21294f00d7e1Smrg      "Fatal configuration error."
21300b661123Smrg}
213172313efbSmrg
213272313efbSmrg
21330b661123Smrg# func_config
21344f00d7e1Smrg# -----------
21350b661123Smrg# Display the configuration for all the tags in this script.
21360b661123Smrgfunc_config ()
21370b661123Smrg{
21380b661123Smrg    re_begincf='^# ### BEGIN LIBTOOL'
21390b661123Smrg    re_endcf='^# ### END LIBTOOL'
21400b661123Smrg
21410b661123Smrg    # Default configuration.
21420b661123Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
2143bdcaa8d0Smrg
2144bdcaa8d0Smrg    # Now print the configurations for the tags.
2145bdcaa8d0Smrg    for tagname in $taglist; do
21460b661123Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
2147bdcaa8d0Smrg    done
214896ce994aSmrg
21490b661123Smrg    exit $?
21500b661123Smrg}
215196ce994aSmrg
21524f00d7e1Smrg
21530b661123Smrg# func_features
21544f00d7e1Smrg# -------------
21550b661123Smrg# Display the features supported by this script.
21560b661123Smrgfunc_features ()
21570b661123Smrg{
2158880c7e28Smrg    echo "host: $host"
21594f00d7e1Smrg    if test yes = "$build_libtool_libs"; then
2160880c7e28Smrg      echo "enable shared libraries"
2161bdcaa8d0Smrg    else
2162880c7e28Smrg      echo "disable shared libraries"
2163bdcaa8d0Smrg    fi
21644f00d7e1Smrg    if test yes = "$build_old_libs"; then
2165880c7e28Smrg      echo "enable static libraries"
2166bdcaa8d0Smrg    else
2167880c7e28Smrg      echo "disable static libraries"
2168bdcaa8d0Smrg    fi
21690b661123Smrg
2170bdcaa8d0Smrg    exit $?
21710b661123Smrg}
2172bdcaa8d0Smrg
21734f00d7e1Smrg
21744f00d7e1Smrg# func_enable_tag TAGNAME
21754f00d7e1Smrg# -----------------------
21760b661123Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
21770b661123Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
21780b661123Smrg# variable here.
21790b661123Smrgfunc_enable_tag ()
21800b661123Smrg{
21814f00d7e1Smrg    # Global variable:
21824f00d7e1Smrg    tagname=$1
2183bdcaa8d0Smrg
21844f00d7e1Smrg    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
21854f00d7e1Smrg    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
21864f00d7e1Smrg    sed_extractcf=/$re_begincf/,/$re_endcf/p
2187bdcaa8d0Smrg
21884f00d7e1Smrg    # Validate tagname.
21894f00d7e1Smrg    case $tagname in
21904f00d7e1Smrg      *[!-_A-Za-z0-9,/]*)
21914f00d7e1Smrg        func_fatal_error "invalid tag name: $tagname"
21924f00d7e1Smrg        ;;
21934f00d7e1Smrg    esac
2194bdcaa8d0Smrg
21954f00d7e1Smrg    # Don't test for the "default" C tag, as we know it's
21964f00d7e1Smrg    # there but not specially marked.
21974f00d7e1Smrg    case $tagname in
21984f00d7e1Smrg        CC) ;;
21990b661123Smrg    *)
22004f00d7e1Smrg        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
22014f00d7e1Smrg	  taglist="$taglist $tagname"
22024f00d7e1Smrg
22034f00d7e1Smrg	  # Evaluate the configuration.  Be careful to quote the path
22044f00d7e1Smrg	  # and the sed script, to avoid splitting on whitespace, but
22054f00d7e1Smrg	  # also don't use non-portable quotes within backquotes within
22064f00d7e1Smrg	  # quotes we have to do it in 2 steps:
22074f00d7e1Smrg	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
22084f00d7e1Smrg	  eval "$extractedcf"
22094f00d7e1Smrg        else
22104f00d7e1Smrg	  func_error "ignoring unknown tag $tagname"
22114f00d7e1Smrg        fi
22124f00d7e1Smrg        ;;
22134f00d7e1Smrg    esac
22140b661123Smrg}
22150b661123Smrg
22164f00d7e1Smrg
2217880c7e28Smrg# func_check_version_match
22184f00d7e1Smrg# ------------------------
2219880c7e28Smrg# Ensure that we are using m4 macros, and libtool script from the same
2220880c7e28Smrg# release of libtool.
2221880c7e28Smrgfunc_check_version_match ()
22220b661123Smrg{
22234f00d7e1Smrg    if test "$package_revision" != "$macro_revision"; then
22244f00d7e1Smrg      if test "$VERSION" != "$macro_version"; then
22254f00d7e1Smrg        if test -z "$macro_version"; then
22264f00d7e1Smrg          cat >&2 <<_LT_EOF
2227880c7e28Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2228880c7e28Smrg$progname: definition of this LT_INIT comes from an older release.
2229880c7e28Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2230880c7e28Smrg$progname: and run autoconf again.
2231880c7e28Smrg_LT_EOF
22324f00d7e1Smrg        else
22334f00d7e1Smrg          cat >&2 <<_LT_EOF
2234880c7e28Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2235880c7e28Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
2236880c7e28Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2237880c7e28Smrg$progname: and run autoconf again.
2238880c7e28Smrg_LT_EOF
22394f00d7e1Smrg        fi
22404f00d7e1Smrg      else
22414f00d7e1Smrg        cat >&2 <<_LT_EOF
2242880c7e28Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
2243880c7e28Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
2244880c7e28Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
2245880c7e28Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
2246880c7e28Smrg_LT_EOF
22474f00d7e1Smrg      fi
2248880c7e28Smrg
22494f00d7e1Smrg      exit $EXIT_MISMATCH
22504f00d7e1Smrg    fi
2251880c7e28Smrg}
2252880c7e28Smrg
2253880c7e28Smrg
22544f00d7e1Smrg# libtool_options_prep [ARG]...
22554f00d7e1Smrg# -----------------------------
22564f00d7e1Smrg# Preparation for options parsed by libtool.
22574f00d7e1Smrglibtool_options_prep ()
22584f00d7e1Smrg{
22594f00d7e1Smrg    $debug_mode
2260880c7e28Smrg
22614f00d7e1Smrg    # Option defaults:
22624f00d7e1Smrg    opt_config=false
22634f00d7e1Smrg    opt_dlopen=
22644f00d7e1Smrg    opt_dry_run=false
22654f00d7e1Smrg    opt_help=false
22664f00d7e1Smrg    opt_mode=
22674f00d7e1Smrg    opt_preserve_dup_deps=false
22684f00d7e1Smrg    opt_quiet=false
2269880c7e28Smrg
22704f00d7e1Smrg    nonopt=
22714f00d7e1Smrg    preserve_args=
2272880c7e28Smrg
22734f00d7e1Smrg    # Shorthand for --mode=foo, only valid as the first argument
22744f00d7e1Smrg    case $1 in
22754f00d7e1Smrg    clean|clea|cle|cl)
22764f00d7e1Smrg      shift; set dummy --mode clean ${1+"$@"}; shift
22774f00d7e1Smrg      ;;
22784f00d7e1Smrg    compile|compil|compi|comp|com|co|c)
22794f00d7e1Smrg      shift; set dummy --mode compile ${1+"$@"}; shift
22804f00d7e1Smrg      ;;
22814f00d7e1Smrg    execute|execut|execu|exec|exe|ex|e)
22824f00d7e1Smrg      shift; set dummy --mode execute ${1+"$@"}; shift
22834f00d7e1Smrg      ;;
22844f00d7e1Smrg    finish|finis|fini|fin|fi|f)
22854f00d7e1Smrg      shift; set dummy --mode finish ${1+"$@"}; shift
22864f00d7e1Smrg      ;;
22874f00d7e1Smrg    install|instal|insta|inst|ins|in|i)
22884f00d7e1Smrg      shift; set dummy --mode install ${1+"$@"}; shift
22894f00d7e1Smrg      ;;
22904f00d7e1Smrg    link|lin|li|l)
22914f00d7e1Smrg      shift; set dummy --mode link ${1+"$@"}; shift
22924f00d7e1Smrg      ;;
22934f00d7e1Smrg    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
22944f00d7e1Smrg      shift; set dummy --mode uninstall ${1+"$@"}; shift
22954f00d7e1Smrg      ;;
22964f00d7e1Smrg    esac
22974f00d7e1Smrg
22984f00d7e1Smrg    # Pass back the list of options.
22994f00d7e1Smrg    func_quote_for_eval ${1+"$@"}
23004f00d7e1Smrg    libtool_options_prep_result=$func_quote_for_eval_result
23014f00d7e1Smrg}
23024f00d7e1Smrgfunc_add_hook func_options_prep libtool_options_prep
230396ce994aSmrg
2304bdcaa8d0Smrg
23054f00d7e1Smrg# libtool_parse_options [ARG]...
23064f00d7e1Smrg# ---------------------------------
23074f00d7e1Smrg# Provide handling for libtool specific options.
23084f00d7e1Smrglibtool_parse_options ()
2309880c7e28Smrg{
23104f00d7e1Smrg    $debug_cmd
23110b661123Smrg
23124f00d7e1Smrg    # Perform our own loop to consume as many options as possible in
23134f00d7e1Smrg    # each iteration.
23144f00d7e1Smrg    while test $# -gt 0; do
23154f00d7e1Smrg      _G_opt=$1
23164f00d7e1Smrg      shift
23174f00d7e1Smrg      case $_G_opt in
23184f00d7e1Smrg        --dry-run|--dryrun|-n)
23194f00d7e1Smrg                        opt_dry_run=:
23204f00d7e1Smrg                        ;;
23214f00d7e1Smrg
23224f00d7e1Smrg        --config)       func_config ;;
23234f00d7e1Smrg
23244f00d7e1Smrg        --dlopen|-dlopen)
23254f00d7e1Smrg                        opt_dlopen="${opt_dlopen+$opt_dlopen
23264f00d7e1Smrg}$1"
23274f00d7e1Smrg                        shift
23284f00d7e1Smrg                        ;;
23294f00d7e1Smrg
23304f00d7e1Smrg        --preserve-dup-deps)
23314f00d7e1Smrg                        opt_preserve_dup_deps=: ;;
23324f00d7e1Smrg
23334f00d7e1Smrg        --features)     func_features ;;
23344f00d7e1Smrg
23354f00d7e1Smrg        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
23364f00d7e1Smrg
23374f00d7e1Smrg        --help)         opt_help=: ;;
23384f00d7e1Smrg
23394f00d7e1Smrg        --help-all)     opt_help=': help-all' ;;
23404f00d7e1Smrg
23414f00d7e1Smrg        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
23424f00d7e1Smrg                        opt_mode=$1
23434f00d7e1Smrg                        case $1 in
23444f00d7e1Smrg                          # Valid mode arguments:
23454f00d7e1Smrg                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
23464f00d7e1Smrg
23474f00d7e1Smrg                          # Catch anything else as an error
23484f00d7e1Smrg                          *) func_error "invalid argument for $_G_opt"
23494f00d7e1Smrg                             exit_cmd=exit
23504f00d7e1Smrg                             break
23514f00d7e1Smrg                             ;;
23524f00d7e1Smrg                        esac
23534f00d7e1Smrg                        shift
23544f00d7e1Smrg                        ;;
23554f00d7e1Smrg
23564f00d7e1Smrg        --no-silent|--no-quiet)
23574f00d7e1Smrg                        opt_quiet=false
23584f00d7e1Smrg                        func_append preserve_args " $_G_opt"
23594f00d7e1Smrg                        ;;
23604f00d7e1Smrg
23614f00d7e1Smrg        --no-warnings|--no-warning|--no-warn)
23624f00d7e1Smrg                        opt_warning=false
23634f00d7e1Smrg                        func_append preserve_args " $_G_opt"
23644f00d7e1Smrg                        ;;
23654f00d7e1Smrg
23664f00d7e1Smrg        --no-verbose)
23674f00d7e1Smrg                        opt_verbose=false
23684f00d7e1Smrg                        func_append preserve_args " $_G_opt"
23694f00d7e1Smrg                        ;;
23704f00d7e1Smrg
23714f00d7e1Smrg        --silent|--quiet)
23724f00d7e1Smrg                        opt_quiet=:
23734f00d7e1Smrg                        opt_verbose=false
23744f00d7e1Smrg                        func_append preserve_args " $_G_opt"
23754f00d7e1Smrg                        ;;
23764f00d7e1Smrg
23774f00d7e1Smrg        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
23784f00d7e1Smrg                        opt_tag=$1
23794f00d7e1Smrg                        func_append preserve_args " $_G_opt $1"
23804f00d7e1Smrg                        func_enable_tag "$1"
23814f00d7e1Smrg                        shift
23824f00d7e1Smrg                        ;;
23834f00d7e1Smrg
23844f00d7e1Smrg        --verbose|-v)   opt_quiet=false
23854f00d7e1Smrg                        opt_verbose=:
23864f00d7e1Smrg                        func_append preserve_args " $_G_opt"
23874f00d7e1Smrg                        ;;
23884f00d7e1Smrg
23894f00d7e1Smrg	# An option not handled by this hook function:
23904f00d7e1Smrg        *)		set dummy "$_G_opt" ${1+"$@"};	shift; break  ;;
23914f00d7e1Smrg      esac
23924f00d7e1Smrg    done
2393880c7e28Smrg
2394880c7e28Smrg
23954f00d7e1Smrg    # save modified positional parameters for caller
23964f00d7e1Smrg    func_quote_for_eval ${1+"$@"}
23974f00d7e1Smrg    libtool_parse_options_result=$func_quote_for_eval_result
23984f00d7e1Smrg}
23994f00d7e1Smrgfunc_add_hook func_parse_options libtool_parse_options
24000b661123Smrg
240172313efbSmrg
24020b661123Smrg
24034f00d7e1Smrg# libtool_validate_options [ARG]...
24044f00d7e1Smrg# ---------------------------------
24054f00d7e1Smrg# Perform any sanity checks on option settings and/or unconsumed
24064f00d7e1Smrg# arguments.
24074f00d7e1Smrglibtool_validate_options ()
24084f00d7e1Smrg{
24094f00d7e1Smrg    # save first non-option argument
24104f00d7e1Smrg    if test 0 -lt $#; then
24114f00d7e1Smrg      nonopt=$1
24124f00d7e1Smrg      shift
24130b661123Smrg    fi
24140b661123Smrg
24154f00d7e1Smrg    # preserve --debug
24164f00d7e1Smrg    test : = "$debug_cmd" || func_append preserve_args " --debug"
24170b661123Smrg
24184f00d7e1Smrg    case $host in
24194f00d7e1Smrg      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
24204f00d7e1Smrg      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
24214f00d7e1Smrg      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
24224f00d7e1Smrg        # don't eliminate duplications in $postdeps and $predeps
24234f00d7e1Smrg        opt_duplicate_compiler_generated_deps=:
24244f00d7e1Smrg        ;;
24254f00d7e1Smrg      *)
24264f00d7e1Smrg        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
24274f00d7e1Smrg        ;;
24284f00d7e1Smrg    esac
2429bdcaa8d0Smrg
24304f00d7e1Smrg    $opt_help || {
24314f00d7e1Smrg      # Sanity checks first:
24324f00d7e1Smrg      func_check_version_match
24334f00d7e1Smrg
24344f00d7e1Smrg      test yes != "$build_libtool_libs" \
24354f00d7e1Smrg        && test yes != "$build_old_libs" \
24364f00d7e1Smrg        && func_fatal_configuration "not configured to build any kind of library"
24374f00d7e1Smrg
24384f00d7e1Smrg      # Darwin sucks
24394f00d7e1Smrg      eval std_shrext=\"$shrext_cmds\"
24404f00d7e1Smrg
24414f00d7e1Smrg      # Only execute mode is allowed to have -dlopen flags.
24424f00d7e1Smrg      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
24434f00d7e1Smrg        func_error "unrecognized option '-dlopen'"
24444f00d7e1Smrg        $ECHO "$help" 1>&2
24454f00d7e1Smrg        exit $EXIT_FAILURE
24464f00d7e1Smrg      fi
24470b661123Smrg
24484f00d7e1Smrg      # Change the help message to a mode-specific one.
24494f00d7e1Smrg      generic_help=$help
24504f00d7e1Smrg      help="Try '$progname --help --mode=$opt_mode' for more information."
24514f00d7e1Smrg    }
24520b661123Smrg
24534f00d7e1Smrg    # Pass back the unparsed argument list
24544f00d7e1Smrg    func_quote_for_eval ${1+"$@"}
24554f00d7e1Smrg    libtool_validate_options_result=$func_quote_for_eval_result
2456880c7e28Smrg}
24574f00d7e1Smrgfunc_add_hook func_validate_options libtool_validate_options
24580b661123Smrg
24590b661123Smrg
24604f00d7e1Smrg# Process options as early as possible so that --help and --version
24614f00d7e1Smrg# can return quickly.
24624f00d7e1Smrgfunc_options ${1+"$@"}
24634f00d7e1Smrgeval set dummy "$func_options_result"; shift
24644f00d7e1Smrg
2465bdcaa8d0Smrg
2466bdcaa8d0Smrg
2467880c7e28Smrg## ----------- ##
2468880c7e28Smrg##    Main.    ##
2469880c7e28Smrg## ----------- ##
2470bdcaa8d0Smrg
24714f00d7e1Smrgmagic='%%%MAGIC variable%%%'
24724f00d7e1Smrgmagic_exe='%%%MAGIC EXE variable%%%'
24734f00d7e1Smrg
24744f00d7e1Smrg# Global variables.
24754f00d7e1Smrgextracted_archives=
24764f00d7e1Smrgextracted_serial=0
24774f00d7e1Smrg
24784f00d7e1Smrg# If this variable is set in any of the actions, the command in it
24794f00d7e1Smrg# will be execed at the end.  This prevents here-documents from being
24804f00d7e1Smrg# left over by shells.
24814f00d7e1Smrgexec_cmd=
24824f00d7e1Smrg
24834f00d7e1Smrg
24844f00d7e1Smrg# A function that is used when there is no print builtin or printf.
24854f00d7e1Smrgfunc_fallback_echo ()
24864f00d7e1Smrg{
24874f00d7e1Smrg  eval 'cat <<_LTECHO_EOF
24884f00d7e1Smrg$1
24894f00d7e1Smrg_LTECHO_EOF'
24904f00d7e1Smrg}
24914f00d7e1Smrg
24924f00d7e1Smrg# func_generated_by_libtool
24934f00d7e1Smrg# True iff stdin has been generated by Libtool. This function is only
24944f00d7e1Smrg# a basic sanity check; it will hardly flush out determined imposters.
24954f00d7e1Smrgfunc_generated_by_libtool_p ()
24964f00d7e1Smrg{
24974f00d7e1Smrg  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
24984f00d7e1Smrg}
24994f00d7e1Smrg
25000b661123Smrg# func_lalib_p file
25014f00d7e1Smrg# True iff FILE is a libtool '.la' library or '.lo' object file.
25020b661123Smrg# This function is only a basic sanity check; it will hardly flush out
25030b661123Smrg# determined imposters.
25040b661123Smrgfunc_lalib_p ()
25050b661123Smrg{
25060b661123Smrg    test -f "$1" &&
25074f00d7e1Smrg      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
25080b661123Smrg}
2509bdcaa8d0Smrg
25100b661123Smrg# func_lalib_unsafe_p file
25114f00d7e1Smrg# True iff FILE is a libtool '.la' library or '.lo' object file.
25120b661123Smrg# This function implements the same check as func_lalib_p without
25130b661123Smrg# resorting to external programs.  To this end, it redirects stdin and
25140b661123Smrg# closes it afterwards, without saving the original file descriptor.
25150b661123Smrg# As a safety measure, use it only where a negative result would be
25164f00d7e1Smrg# fatal anyway.  Works if 'file' does not exist.
25170b661123Smrgfunc_lalib_unsafe_p ()
25180b661123Smrg{
25190b661123Smrg    lalib_p=no
25200b661123Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
25210b661123Smrg	for lalib_p_l in 1 2 3 4
25220b661123Smrg	do
25230b661123Smrg	    read lalib_p_line
25244f00d7e1Smrg	    case $lalib_p_line in
25250b661123Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
25260b661123Smrg	    esac
25270b661123Smrg	done
25280b661123Smrg	exec 0<&5 5<&-
25290b661123Smrg    fi
25304f00d7e1Smrg    test yes = "$lalib_p"
25310b661123Smrg}
2532bdcaa8d0Smrg
25330b661123Smrg# func_ltwrapper_script_p file
25340b661123Smrg# True iff FILE is a libtool wrapper script
25350b661123Smrg# This function is only a basic sanity check; it will hardly flush out
25360b661123Smrg# determined imposters.
25370b661123Smrgfunc_ltwrapper_script_p ()
25380b661123Smrg{
25394f00d7e1Smrg    test -f "$1" &&
25404f00d7e1Smrg      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
25410b661123Smrg}
2542bdcaa8d0Smrg
25430b661123Smrg# func_ltwrapper_executable_p file
25440b661123Smrg# True iff FILE is a libtool wrapper executable
25450b661123Smrg# This function is only a basic sanity check; it will hardly flush out
25460b661123Smrg# determined imposters.
25470b661123Smrgfunc_ltwrapper_executable_p ()
25480b661123Smrg{
25490b661123Smrg    func_ltwrapper_exec_suffix=
25500b661123Smrg    case $1 in
25510b661123Smrg    *.exe) ;;
25520b661123Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
25530b661123Smrg    esac
25540b661123Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
25550b661123Smrg}
255672313efbSmrg
25570b661123Smrg# func_ltwrapper_scriptname file
25580b661123Smrg# Assumes file is an ltwrapper_executable
25590b661123Smrg# uses $file to determine the appropriate filename for a
25600b661123Smrg# temporary ltwrapper_script.
25610b661123Smrgfunc_ltwrapper_scriptname ()
25620b661123Smrg{
2563880c7e28Smrg    func_dirname_and_basename "$1" "" "."
2564880c7e28Smrg    func_stripname '' '.exe' "$func_basename_result"
25654f00d7e1Smrg    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
25660b661123Smrg}
25670b661123Smrg
25680b661123Smrg# func_ltwrapper_p file
25690b661123Smrg# True iff FILE is a libtool wrapper script or wrapper executable
25700b661123Smrg# This function is only a basic sanity check; it will hardly flush out
25710b661123Smrg# determined imposters.
25720b661123Smrgfunc_ltwrapper_p ()
25730b661123Smrg{
25740b661123Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
25750b661123Smrg}
25760b661123Smrg
25770b661123Smrg
25780b661123Smrg# func_execute_cmds commands fail_cmd
25790b661123Smrg# Execute tilde-delimited COMMANDS.
25800b661123Smrg# If FAIL_CMD is given, eval that upon failure.
25810b661123Smrg# FAIL_CMD may read-access the current command in variable CMD!
25820b661123Smrgfunc_execute_cmds ()
25830b661123Smrg{
25844f00d7e1Smrg    $debug_cmd
25854f00d7e1Smrg
25860b661123Smrg    save_ifs=$IFS; IFS='~'
25870b661123Smrg    for cmd in $1; do
25884f00d7e1Smrg      IFS=$sp$nl
25890b661123Smrg      eval cmd=\"$cmd\"
25904f00d7e1Smrg      IFS=$save_ifs
25910b661123Smrg      func_show_eval "$cmd" "${2-:}"
25920b661123Smrg    done
25930b661123Smrg    IFS=$save_ifs
25940b661123Smrg}
25950b661123Smrg
25960b661123Smrg
25970b661123Smrg# func_source file
25980b661123Smrg# Source FILE, adding directory component if necessary.
25990b661123Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
26000b661123Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
26010b661123Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
26024f00d7e1Smrg# 'FILE.' does not work on cygwin managed mounts.
26030b661123Smrgfunc_source ()
26040b661123Smrg{
26054f00d7e1Smrg    $debug_cmd
26064f00d7e1Smrg
26070b661123Smrg    case $1 in
26080b661123Smrg    */* | *\\*)	. "$1" ;;
26090b661123Smrg    *)		. "./$1" ;;
26100b661123Smrg    esac
26110b661123Smrg}
26120b661123Smrg
26130b661123Smrg
2614880c7e28Smrg# func_resolve_sysroot PATH
2615880c7e28Smrg# Replace a leading = in PATH with a sysroot.  Store the result into
2616880c7e28Smrg# func_resolve_sysroot_result
2617880c7e28Smrgfunc_resolve_sysroot ()
2618880c7e28Smrg{
2619880c7e28Smrg  func_resolve_sysroot_result=$1
2620880c7e28Smrg  case $func_resolve_sysroot_result in
2621880c7e28Smrg  =*)
2622880c7e28Smrg    func_stripname '=' '' "$func_resolve_sysroot_result"
2623880c7e28Smrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
2624880c7e28Smrg    ;;
2625880c7e28Smrg  esac
2626880c7e28Smrg}
2627880c7e28Smrg
2628880c7e28Smrg# func_replace_sysroot PATH
2629880c7e28Smrg# If PATH begins with the sysroot, replace it with = and
2630880c7e28Smrg# store the result into func_replace_sysroot_result.
2631880c7e28Smrgfunc_replace_sysroot ()
2632880c7e28Smrg{
26334f00d7e1Smrg  case $lt_sysroot:$1 in
2634880c7e28Smrg  ?*:"$lt_sysroot"*)
2635880c7e28Smrg    func_stripname "$lt_sysroot" '' "$1"
26364f00d7e1Smrg    func_replace_sysroot_result='='$func_stripname_result
2637880c7e28Smrg    ;;
2638880c7e28Smrg  *)
2639880c7e28Smrg    # Including no sysroot.
2640880c7e28Smrg    func_replace_sysroot_result=$1
2641880c7e28Smrg    ;;
2642880c7e28Smrg  esac
2643880c7e28Smrg}
2644880c7e28Smrg
26450b661123Smrg# func_infer_tag arg
26460b661123Smrg# Infer tagged configuration to use if any are available and
26470b661123Smrg# if one wasn't chosen via the "--tag" command line option.
26480b661123Smrg# Only attempt this if the compiler in the base compile
26490b661123Smrg# command doesn't match the default compiler.
26500b661123Smrg# arg is usually of the form 'gcc ...'
26510b661123Smrgfunc_infer_tag ()
26520b661123Smrg{
26534f00d7e1Smrg    $debug_cmd
26544f00d7e1Smrg
26550b661123Smrg    if test -n "$available_tags" && test -z "$tagname"; then
26560b661123Smrg      CC_quoted=
26570b661123Smrg      for arg in $CC; do
2658880c7e28Smrg	func_append_quoted CC_quoted "$arg"
26590b661123Smrg      done
2660880c7e28Smrg      CC_expanded=`func_echo_all $CC`
2661880c7e28Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
26620b661123Smrg      case $@ in
26630b661123Smrg      # Blanks in the command may have been stripped by the calling shell,
26640b661123Smrg      # but not from the CC environment variable when configure was run.
2665880c7e28Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2666880c7e28Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
26670b661123Smrg      # Blanks at the start of $base_compile will cause this to fail
26680b661123Smrg      # if we don't check for them as well.
26690b661123Smrg      *)
26700b661123Smrg	for z in $available_tags; do
26710b661123Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
26720b661123Smrg	    # Evaluate the configuration.
26734f00d7e1Smrg	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
26740b661123Smrg	    CC_quoted=
26750b661123Smrg	    for arg in $CC; do
26760b661123Smrg	      # Double-quote args containing other shell metacharacters.
2677880c7e28Smrg	      func_append_quoted CC_quoted "$arg"
26780b661123Smrg	    done
2679880c7e28Smrg	    CC_expanded=`func_echo_all $CC`
2680880c7e28Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
26810b661123Smrg	    case "$@ " in
2682880c7e28Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2683880c7e28Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
26840b661123Smrg	      # The compiler in the base compile command matches
26850b661123Smrg	      # the one in the tagged configuration.
26860b661123Smrg	      # Assume this is the tagged configuration we want.
26870b661123Smrg	      tagname=$z
26880b661123Smrg	      break
26890b661123Smrg	      ;;
26900b661123Smrg	    esac
26910b661123Smrg	  fi
26920b661123Smrg	done
26930b661123Smrg	# If $tagname still isn't set, then no tagged configuration
26940b661123Smrg	# was found and let the user know that the "--tag" command
26950b661123Smrg	# line option must be used.
26960b661123Smrg	if test -z "$tagname"; then
26970b661123Smrg	  func_echo "unable to infer tagged configuration"
26984f00d7e1Smrg	  func_fatal_error "specify a tag with '--tag'"
26990b661123Smrg#	else
27000b661123Smrg#	  func_verbose "using $tagname tagged configuration"
27010b661123Smrg	fi
27020b661123Smrg	;;
27030b661123Smrg      esac
27040b661123Smrg    fi
27050b661123Smrg}
27060b661123Smrg
27070b661123Smrg
27080b661123Smrg
27090b661123Smrg# func_write_libtool_object output_name pic_name nonpic_name
27100b661123Smrg# Create a libtool object file (analogous to a ".la" file),
27110b661123Smrg# but don't create it if we're doing a dry run.
27120b661123Smrgfunc_write_libtool_object ()
27130b661123Smrg{
27144f00d7e1Smrg    write_libobj=$1
27154f00d7e1Smrg    if test yes = "$build_libtool_libs"; then
27164f00d7e1Smrg      write_lobj=\'$2\'
27170b661123Smrg    else
27180b661123Smrg      write_lobj=none
27190b661123Smrg    fi
27200b661123Smrg
27214f00d7e1Smrg    if test yes = "$build_old_libs"; then
27224f00d7e1Smrg      write_oldobj=\'$3\'
27230b661123Smrg    else
27240b661123Smrg      write_oldobj=none
27250b661123Smrg    fi
27260b661123Smrg
27270b661123Smrg    $opt_dry_run || {
27280b661123Smrg      cat >${write_libobj}T <<EOF
27290b661123Smrg# $write_libobj - a libtool object file
27304f00d7e1Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
27310b661123Smrg#
27320b661123Smrg# Please DO NOT delete this file!
27330b661123Smrg# It is necessary for linking the library.
27340b661123Smrg
27350b661123Smrg# Name of the PIC object.
27360b661123Smrgpic_object=$write_lobj
27370b661123Smrg
27380b661123Smrg# Name of the non-PIC object
27390b661123Smrgnon_pic_object=$write_oldobj
27400b661123Smrg
27410b661123SmrgEOF
27424f00d7e1Smrg      $MV "${write_libobj}T" "$write_libobj"
27430b661123Smrg    }
27440b661123Smrg}
27450b661123Smrg
2746880c7e28Smrg
2747880c7e28Smrg##################################################
2748880c7e28Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
2749880c7e28Smrg##################################################
2750880c7e28Smrg
2751880c7e28Smrg# func_convert_core_file_wine_to_w32 ARG
2752880c7e28Smrg# Helper function used by file name conversion functions when $build is *nix,
2753880c7e28Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
2754880c7e28Smrg# correctly configured wine environment available, with the winepath program
2755880c7e28Smrg# in $build's $PATH.
2756880c7e28Smrg#
2757880c7e28Smrg# ARG is the $build file name to be converted to w32 format.
2758880c7e28Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
2759880c7e28Smrg# be empty on error (or when ARG is empty)
2760880c7e28Smrgfunc_convert_core_file_wine_to_w32 ()
2761880c7e28Smrg{
27624f00d7e1Smrg  $debug_cmd
27634f00d7e1Smrg
27644f00d7e1Smrg  func_convert_core_file_wine_to_w32_result=$1
2765880c7e28Smrg  if test -n "$1"; then
2766880c7e28Smrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
2767880c7e28Smrg    # are forced to check the contents of stdout. On the other hand, if the
2768880c7e28Smrg    # command is not found, the shell will set an exit code of 127 and print
2769880c7e28Smrg    # *an error message* to stdout. So we must check for both error code of
2770880c7e28Smrg    # zero AND non-empty stdout, which explains the odd construction:
2771880c7e28Smrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
27724f00d7e1Smrg    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
2773880c7e28Smrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
27744f00d7e1Smrg        $SED -e "$sed_naive_backslashify"`
2775880c7e28Smrg    else
2776880c7e28Smrg      func_convert_core_file_wine_to_w32_result=
2777880c7e28Smrg    fi
2778880c7e28Smrg  fi
2779880c7e28Smrg}
2780880c7e28Smrg# end: func_convert_core_file_wine_to_w32
2781880c7e28Smrg
2782880c7e28Smrg
2783880c7e28Smrg# func_convert_core_path_wine_to_w32 ARG
2784880c7e28Smrg# Helper function used by path conversion functions when $build is *nix, and
2785880c7e28Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
2786880c7e28Smrg# configured wine environment available, with the winepath program in $build's
2787880c7e28Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
2788880c7e28Smrg#
2789880c7e28Smrg# ARG is path to be converted from $build format to win32.
2790880c7e28Smrg# Result is available in $func_convert_core_path_wine_to_w32_result.
2791880c7e28Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
2792880c7e28Smrg# are convertible, then the result may be empty.
2793880c7e28Smrgfunc_convert_core_path_wine_to_w32 ()
2794880c7e28Smrg{
27954f00d7e1Smrg  $debug_cmd
27964f00d7e1Smrg
2797880c7e28Smrg  # unfortunately, winepath doesn't convert paths, only file names
27984f00d7e1Smrg  func_convert_core_path_wine_to_w32_result=
2799880c7e28Smrg  if test -n "$1"; then
2800880c7e28Smrg    oldIFS=$IFS
2801880c7e28Smrg    IFS=:
2802880c7e28Smrg    for func_convert_core_path_wine_to_w32_f in $1; do
2803880c7e28Smrg      IFS=$oldIFS
2804880c7e28Smrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
28054f00d7e1Smrg      if test -n "$func_convert_core_file_wine_to_w32_result"; then
2806880c7e28Smrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
28074f00d7e1Smrg          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
2808880c7e28Smrg        else
2809880c7e28Smrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
2810880c7e28Smrg        fi
2811880c7e28Smrg      fi
2812880c7e28Smrg    done
2813880c7e28Smrg    IFS=$oldIFS
2814880c7e28Smrg  fi
2815880c7e28Smrg}
2816880c7e28Smrg# end: func_convert_core_path_wine_to_w32
2817880c7e28Smrg
2818880c7e28Smrg
2819880c7e28Smrg# func_cygpath ARGS...
2820880c7e28Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
2821880c7e28Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
2822880c7e28Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
2823880c7e28Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
2824880c7e28Smrg# file name or path is assumed to be in w32 format, as previously converted
2825880c7e28Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
2826880c7e28Smrg# or path in func_cygpath_result (input file name or path is assumed to be in
2827880c7e28Smrg# Cygwin format). Returns an empty string on error.
2828880c7e28Smrg#
2829880c7e28Smrg# ARGS are passed to cygpath, with the last one being the file name or path to
2830880c7e28Smrg# be converted.
2831880c7e28Smrg#
2832880c7e28Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
2833880c7e28Smrg# environment variable; do not put it in $PATH.
2834880c7e28Smrgfunc_cygpath ()
2835880c7e28Smrg{
28364f00d7e1Smrg  $debug_cmd
28374f00d7e1Smrg
2838880c7e28Smrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
2839880c7e28Smrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
2840880c7e28Smrg    if test "$?" -ne 0; then
2841880c7e28Smrg      # on failure, ensure result is empty
2842880c7e28Smrg      func_cygpath_result=
2843880c7e28Smrg    fi
2844880c7e28Smrg  else
2845880c7e28Smrg    func_cygpath_result=
28464f00d7e1Smrg    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
2847880c7e28Smrg  fi
2848880c7e28Smrg}
2849880c7e28Smrg#end: func_cygpath
2850880c7e28Smrg
2851880c7e28Smrg
2852880c7e28Smrg# func_convert_core_msys_to_w32 ARG
2853880c7e28Smrg# Convert file name or path ARG from MSYS format to w32 format.  Return
2854880c7e28Smrg# result in func_convert_core_msys_to_w32_result.
2855880c7e28Smrgfunc_convert_core_msys_to_w32 ()
2856880c7e28Smrg{
28574f00d7e1Smrg  $debug_cmd
28584f00d7e1Smrg
2859880c7e28Smrg  # awkward: cmd appends spaces to result
2860880c7e28Smrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
28614f00d7e1Smrg    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
2862880c7e28Smrg}
2863880c7e28Smrg#end: func_convert_core_msys_to_w32
2864880c7e28Smrg
2865880c7e28Smrg
2866880c7e28Smrg# func_convert_file_check ARG1 ARG2
2867880c7e28Smrg# Verify that ARG1 (a file name in $build format) was converted to $host
2868880c7e28Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
2869880c7e28Smrg# func_to_host_file_result to ARG1).
2870880c7e28Smrgfunc_convert_file_check ()
2871880c7e28Smrg{
28724f00d7e1Smrg  $debug_cmd
28734f00d7e1Smrg
28744f00d7e1Smrg  if test -z "$2" && test -n "$1"; then
2875880c7e28Smrg    func_error "Could not determine host file name corresponding to"
28764f00d7e1Smrg    func_error "  '$1'"
2877880c7e28Smrg    func_error "Continuing, but uninstalled executables may not work."
2878880c7e28Smrg    # Fallback:
28794f00d7e1Smrg    func_to_host_file_result=$1
2880880c7e28Smrg  fi
2881880c7e28Smrg}
2882880c7e28Smrg# end func_convert_file_check
2883880c7e28Smrg
2884880c7e28Smrg
2885880c7e28Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
2886880c7e28Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host
2887880c7e28Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
2888880c7e28Smrg# func_to_host_file_result to a simplistic fallback value (see below).
2889880c7e28Smrgfunc_convert_path_check ()
2890880c7e28Smrg{
28914f00d7e1Smrg  $debug_cmd
28924f00d7e1Smrg
2893880c7e28Smrg  if test -z "$4" && test -n "$3"; then
2894880c7e28Smrg    func_error "Could not determine the host path corresponding to"
28954f00d7e1Smrg    func_error "  '$3'"
2896880c7e28Smrg    func_error "Continuing, but uninstalled executables may not work."
2897880c7e28Smrg    # Fallback.  This is a deliberately simplistic "conversion" and
2898880c7e28Smrg    # should not be "improved".  See libtool.info.
2899880c7e28Smrg    if test "x$1" != "x$2"; then
2900880c7e28Smrg      lt_replace_pathsep_chars="s|$1|$2|g"
2901880c7e28Smrg      func_to_host_path_result=`echo "$3" |
2902880c7e28Smrg        $SED -e "$lt_replace_pathsep_chars"`
2903880c7e28Smrg    else
29044f00d7e1Smrg      func_to_host_path_result=$3
2905880c7e28Smrg    fi
2906880c7e28Smrg  fi
2907880c7e28Smrg}
2908880c7e28Smrg# end func_convert_path_check
2909880c7e28Smrg
2910880c7e28Smrg
2911880c7e28Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
2912880c7e28Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
2913880c7e28Smrg# and appending REPL if ORIG matches BACKPAT.
2914880c7e28Smrgfunc_convert_path_front_back_pathsep ()
2915880c7e28Smrg{
29164f00d7e1Smrg  $debug_cmd
29174f00d7e1Smrg
2918880c7e28Smrg  case $4 in
29194f00d7e1Smrg  $1 ) func_to_host_path_result=$3$func_to_host_path_result
2920880c7e28Smrg    ;;
2921880c7e28Smrg  esac
2922880c7e28Smrg  case $4 in
2923880c7e28Smrg  $2 ) func_append func_to_host_path_result "$3"
2924880c7e28Smrg    ;;
2925880c7e28Smrg  esac
2926880c7e28Smrg}
2927880c7e28Smrg# end func_convert_path_front_back_pathsep
2928880c7e28Smrg
2929880c7e28Smrg
2930880c7e28Smrg##################################################
2931880c7e28Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
2932880c7e28Smrg##################################################
29334f00d7e1Smrg# invoked via '$to_host_file_cmd ARG'
2934880c7e28Smrg#
2935880c7e28Smrg# In each case, ARG is the path to be converted from $build to $host format.
2936880c7e28Smrg# Result will be available in $func_to_host_file_result.
2937880c7e28Smrg
2938880c7e28Smrg
2939880c7e28Smrg# func_to_host_file ARG
2940880c7e28Smrg# Converts the file name ARG from $build format to $host format. Return result
2941880c7e28Smrg# in func_to_host_file_result.
2942880c7e28Smrgfunc_to_host_file ()
2943880c7e28Smrg{
29444f00d7e1Smrg  $debug_cmd
29454f00d7e1Smrg
2946880c7e28Smrg  $to_host_file_cmd "$1"
2947880c7e28Smrg}
2948880c7e28Smrg# end func_to_host_file
2949880c7e28Smrg
2950880c7e28Smrg
2951880c7e28Smrg# func_to_tool_file ARG LAZY
2952880c7e28Smrg# converts the file name ARG from $build format to toolchain format. Return
2953880c7e28Smrg# result in func_to_tool_file_result.  If the conversion in use is listed
2954880c7e28Smrg# in (the comma separated) LAZY, no conversion takes place.
2955880c7e28Smrgfunc_to_tool_file ()
2956880c7e28Smrg{
29574f00d7e1Smrg  $debug_cmd
29584f00d7e1Smrg
2959880c7e28Smrg  case ,$2, in
2960880c7e28Smrg    *,"$to_tool_file_cmd",*)
2961880c7e28Smrg      func_to_tool_file_result=$1
2962880c7e28Smrg      ;;
2963880c7e28Smrg    *)
2964880c7e28Smrg      $to_tool_file_cmd "$1"
2965880c7e28Smrg      func_to_tool_file_result=$func_to_host_file_result
2966880c7e28Smrg      ;;
2967880c7e28Smrg  esac
2968880c7e28Smrg}
2969880c7e28Smrg# end func_to_tool_file
2970880c7e28Smrg
2971880c7e28Smrg
2972880c7e28Smrg# func_convert_file_noop ARG
2973880c7e28Smrg# Copy ARG to func_to_host_file_result.
2974880c7e28Smrgfunc_convert_file_noop ()
2975880c7e28Smrg{
29764f00d7e1Smrg  func_to_host_file_result=$1
2977880c7e28Smrg}
2978880c7e28Smrg# end func_convert_file_noop
2979880c7e28Smrg
2980880c7e28Smrg
2981880c7e28Smrg# func_convert_file_msys_to_w32 ARG
2982880c7e28Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
2983880c7e28Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
2984880c7e28Smrg# func_to_host_file_result.
2985880c7e28Smrgfunc_convert_file_msys_to_w32 ()
2986880c7e28Smrg{
29874f00d7e1Smrg  $debug_cmd
29884f00d7e1Smrg
29894f00d7e1Smrg  func_to_host_file_result=$1
2990880c7e28Smrg  if test -n "$1"; then
2991880c7e28Smrg    func_convert_core_msys_to_w32 "$1"
29924f00d7e1Smrg    func_to_host_file_result=$func_convert_core_msys_to_w32_result
2993880c7e28Smrg  fi
2994880c7e28Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
2995880c7e28Smrg}
2996880c7e28Smrg# end func_convert_file_msys_to_w32
2997880c7e28Smrg
2998880c7e28Smrg
2999880c7e28Smrg# func_convert_file_cygwin_to_w32 ARG
3000880c7e28Smrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
3001880c7e28Smrg# func_to_host_file_result.
3002880c7e28Smrgfunc_convert_file_cygwin_to_w32 ()
3003880c7e28Smrg{
30044f00d7e1Smrg  $debug_cmd
30054f00d7e1Smrg
30064f00d7e1Smrg  func_to_host_file_result=$1
3007880c7e28Smrg  if test -n "$1"; then
3008880c7e28Smrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
3009880c7e28Smrg    # LT_CYGPATH in this case.
3010880c7e28Smrg    func_to_host_file_result=`cygpath -m "$1"`
3011880c7e28Smrg  fi
3012880c7e28Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3013880c7e28Smrg}
3014880c7e28Smrg# end func_convert_file_cygwin_to_w32
3015880c7e28Smrg
3016880c7e28Smrg
3017880c7e28Smrg# func_convert_file_nix_to_w32 ARG
3018880c7e28Smrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
3019880c7e28Smrg# and a working winepath. Returns result in func_to_host_file_result.
3020880c7e28Smrgfunc_convert_file_nix_to_w32 ()
3021880c7e28Smrg{
30224f00d7e1Smrg  $debug_cmd
30234f00d7e1Smrg
30244f00d7e1Smrg  func_to_host_file_result=$1
3025880c7e28Smrg  if test -n "$1"; then
3026880c7e28Smrg    func_convert_core_file_wine_to_w32 "$1"
30274f00d7e1Smrg    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
3028880c7e28Smrg  fi
3029880c7e28Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3030880c7e28Smrg}
3031880c7e28Smrg# end func_convert_file_nix_to_w32
3032880c7e28Smrg
3033880c7e28Smrg
3034880c7e28Smrg# func_convert_file_msys_to_cygwin ARG
3035880c7e28Smrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3036880c7e28Smrg# Returns result in func_to_host_file_result.
3037880c7e28Smrgfunc_convert_file_msys_to_cygwin ()
3038880c7e28Smrg{
30394f00d7e1Smrg  $debug_cmd
30404f00d7e1Smrg
30414f00d7e1Smrg  func_to_host_file_result=$1
3042880c7e28Smrg  if test -n "$1"; then
3043880c7e28Smrg    func_convert_core_msys_to_w32 "$1"
3044880c7e28Smrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
30454f00d7e1Smrg    func_to_host_file_result=$func_cygpath_result
3046880c7e28Smrg  fi
3047880c7e28Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3048880c7e28Smrg}
3049880c7e28Smrg# end func_convert_file_msys_to_cygwin
3050880c7e28Smrg
3051880c7e28Smrg
3052880c7e28Smrg# func_convert_file_nix_to_cygwin ARG
3053880c7e28Smrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
3054880c7e28Smrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
3055880c7e28Smrg# in func_to_host_file_result.
3056880c7e28Smrgfunc_convert_file_nix_to_cygwin ()
3057880c7e28Smrg{
30584f00d7e1Smrg  $debug_cmd
30594f00d7e1Smrg
30604f00d7e1Smrg  func_to_host_file_result=$1
3061880c7e28Smrg  if test -n "$1"; then
3062880c7e28Smrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
3063880c7e28Smrg    func_convert_core_file_wine_to_w32 "$1"
3064880c7e28Smrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
30654f00d7e1Smrg    func_to_host_file_result=$func_cygpath_result
3066880c7e28Smrg  fi
3067880c7e28Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3068880c7e28Smrg}
3069880c7e28Smrg# end func_convert_file_nix_to_cygwin
3070880c7e28Smrg
3071880c7e28Smrg
3072880c7e28Smrg#############################################
3073880c7e28Smrg# $build to $host PATH CONVERSION FUNCTIONS #
3074880c7e28Smrg#############################################
30754f00d7e1Smrg# invoked via '$to_host_path_cmd ARG'
3076880c7e28Smrg#
3077880c7e28Smrg# In each case, ARG is the path to be converted from $build to $host format.
3078880c7e28Smrg# The result will be available in $func_to_host_path_result.
3079880c7e28Smrg#
3080880c7e28Smrg# Path separators are also converted from $build format to $host format.  If
3081880c7e28Smrg# ARG begins or ends with a path separator character, it is preserved (but
3082880c7e28Smrg# converted to $host format) on output.
3083880c7e28Smrg#
3084880c7e28Smrg# All path conversion functions are named using the following convention:
3085880c7e28Smrg#   file name conversion function    : func_convert_file_X_to_Y ()
3086880c7e28Smrg#   path conversion function         : func_convert_path_X_to_Y ()
3087880c7e28Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the
3088880c7e28Smrg# same.  If conversion functions are added for new $build/$host combinations,
3089880c7e28Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
3090880c7e28Smrg# will break.
3091880c7e28Smrg
3092880c7e28Smrg
3093880c7e28Smrg# func_init_to_host_path_cmd
3094880c7e28Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
3095880c7e28Smrg# appropriate value, based on the value of $to_host_file_cmd.
3096880c7e28Smrgto_host_path_cmd=
3097880c7e28Smrgfunc_init_to_host_path_cmd ()
3098880c7e28Smrg{
30994f00d7e1Smrg  $debug_cmd
31004f00d7e1Smrg
3101880c7e28Smrg  if test -z "$to_host_path_cmd"; then
3102880c7e28Smrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
31034f00d7e1Smrg    to_host_path_cmd=func_convert_path_$func_stripname_result
3104880c7e28Smrg  fi
3105880c7e28Smrg}
3106880c7e28Smrg
3107880c7e28Smrg
3108880c7e28Smrg# func_to_host_path ARG
3109880c7e28Smrg# Converts the path ARG from $build format to $host format. Return result
3110880c7e28Smrg# in func_to_host_path_result.
3111880c7e28Smrgfunc_to_host_path ()
3112880c7e28Smrg{
31134f00d7e1Smrg  $debug_cmd
31144f00d7e1Smrg
3115880c7e28Smrg  func_init_to_host_path_cmd
3116880c7e28Smrg  $to_host_path_cmd "$1"
3117880c7e28Smrg}
3118880c7e28Smrg# end func_to_host_path
3119880c7e28Smrg
3120880c7e28Smrg
3121880c7e28Smrg# func_convert_path_noop ARG
3122880c7e28Smrg# Copy ARG to func_to_host_path_result.
3123880c7e28Smrgfunc_convert_path_noop ()
3124880c7e28Smrg{
31254f00d7e1Smrg  func_to_host_path_result=$1
3126880c7e28Smrg}
3127880c7e28Smrg# end func_convert_path_noop
3128880c7e28Smrg
3129880c7e28Smrg
3130880c7e28Smrg# func_convert_path_msys_to_w32 ARG
3131880c7e28Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
3132880c7e28Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
3133880c7e28Smrg# func_to_host_path_result.
3134880c7e28Smrgfunc_convert_path_msys_to_w32 ()
3135880c7e28Smrg{
31364f00d7e1Smrg  $debug_cmd
31374f00d7e1Smrg
31384f00d7e1Smrg  func_to_host_path_result=$1
3139880c7e28Smrg  if test -n "$1"; then
3140880c7e28Smrg    # Remove leading and trailing path separator characters from ARG.  MSYS
3141880c7e28Smrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
3142880c7e28Smrg    # and winepath ignores them completely.
3143880c7e28Smrg    func_stripname : : "$1"
3144880c7e28Smrg    func_to_host_path_tmp1=$func_stripname_result
3145880c7e28Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
31464f00d7e1Smrg    func_to_host_path_result=$func_convert_core_msys_to_w32_result
3147880c7e28Smrg    func_convert_path_check : ";" \
3148880c7e28Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3149880c7e28Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3150880c7e28Smrg  fi
3151880c7e28Smrg}
3152880c7e28Smrg# end func_convert_path_msys_to_w32
3153880c7e28Smrg
3154880c7e28Smrg
3155880c7e28Smrg# func_convert_path_cygwin_to_w32 ARG
3156880c7e28Smrg# Convert path ARG from Cygwin to w32 format.  Returns result in
3157880c7e28Smrg# func_to_host_file_result.
3158880c7e28Smrgfunc_convert_path_cygwin_to_w32 ()
3159880c7e28Smrg{
31604f00d7e1Smrg  $debug_cmd
31614f00d7e1Smrg
31624f00d7e1Smrg  func_to_host_path_result=$1
3163880c7e28Smrg  if test -n "$1"; then
3164880c7e28Smrg    # See func_convert_path_msys_to_w32:
3165880c7e28Smrg    func_stripname : : "$1"
3166880c7e28Smrg    func_to_host_path_tmp1=$func_stripname_result
3167880c7e28Smrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
3168880c7e28Smrg    func_convert_path_check : ";" \
3169880c7e28Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3170880c7e28Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3171880c7e28Smrg  fi
3172880c7e28Smrg}
3173880c7e28Smrg# end func_convert_path_cygwin_to_w32
3174880c7e28Smrg
3175880c7e28Smrg
3176880c7e28Smrg# func_convert_path_nix_to_w32 ARG
3177880c7e28Smrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
3178880c7e28Smrg# a working winepath.  Returns result in func_to_host_file_result.
3179880c7e28Smrgfunc_convert_path_nix_to_w32 ()
3180880c7e28Smrg{
31814f00d7e1Smrg  $debug_cmd
31824f00d7e1Smrg
31834f00d7e1Smrg  func_to_host_path_result=$1
3184880c7e28Smrg  if test -n "$1"; then
3185880c7e28Smrg    # See func_convert_path_msys_to_w32:
3186880c7e28Smrg    func_stripname : : "$1"
3187880c7e28Smrg    func_to_host_path_tmp1=$func_stripname_result
3188880c7e28Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
31894f00d7e1Smrg    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
3190880c7e28Smrg    func_convert_path_check : ";" \
3191880c7e28Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3192880c7e28Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3193880c7e28Smrg  fi
3194880c7e28Smrg}
3195880c7e28Smrg# end func_convert_path_nix_to_w32
3196880c7e28Smrg
3197880c7e28Smrg
3198880c7e28Smrg# func_convert_path_msys_to_cygwin ARG
3199880c7e28Smrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3200880c7e28Smrg# Returns result in func_to_host_file_result.
3201880c7e28Smrgfunc_convert_path_msys_to_cygwin ()
3202880c7e28Smrg{
32034f00d7e1Smrg  $debug_cmd
32044f00d7e1Smrg
32054f00d7e1Smrg  func_to_host_path_result=$1
3206880c7e28Smrg  if test -n "$1"; then
3207880c7e28Smrg    # See func_convert_path_msys_to_w32:
3208880c7e28Smrg    func_stripname : : "$1"
3209880c7e28Smrg    func_to_host_path_tmp1=$func_stripname_result
3210880c7e28Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3211880c7e28Smrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
32124f00d7e1Smrg    func_to_host_path_result=$func_cygpath_result
3213880c7e28Smrg    func_convert_path_check : : \
3214880c7e28Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3215880c7e28Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3216880c7e28Smrg  fi
3217880c7e28Smrg}
3218880c7e28Smrg# end func_convert_path_msys_to_cygwin
3219880c7e28Smrg
3220880c7e28Smrg
3221880c7e28Smrg# func_convert_path_nix_to_cygwin ARG
3222880c7e28Smrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
3223880c7e28Smrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
3224880c7e28Smrg# func_to_host_file_result.
3225880c7e28Smrgfunc_convert_path_nix_to_cygwin ()
3226880c7e28Smrg{
32274f00d7e1Smrg  $debug_cmd
32284f00d7e1Smrg
32294f00d7e1Smrg  func_to_host_path_result=$1
3230880c7e28Smrg  if test -n "$1"; then
3231880c7e28Smrg    # Remove leading and trailing path separator characters from
3232880c7e28Smrg    # ARG. msys behavior is inconsistent here, cygpath turns them
3233880c7e28Smrg    # into '.;' and ';.', and winepath ignores them completely.
3234880c7e28Smrg    func_stripname : : "$1"
3235880c7e28Smrg    func_to_host_path_tmp1=$func_stripname_result
3236880c7e28Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3237880c7e28Smrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
32384f00d7e1Smrg    func_to_host_path_result=$func_cygpath_result
3239880c7e28Smrg    func_convert_path_check : : \
3240880c7e28Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3241880c7e28Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3242880c7e28Smrg  fi
3243880c7e28Smrg}
3244880c7e28Smrg# end func_convert_path_nix_to_cygwin
3245880c7e28Smrg
3246880c7e28Smrg
32474f00d7e1Smrg# func_dll_def_p FILE
32484f00d7e1Smrg# True iff FILE is a Windows DLL '.def' file.
32494f00d7e1Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4
32504f00d7e1Smrgfunc_dll_def_p ()
32514f00d7e1Smrg{
32524f00d7e1Smrg  $debug_cmd
32534f00d7e1Smrg
32544f00d7e1Smrg  func_dll_def_p_tmp=`$SED -n \
32554f00d7e1Smrg    -e 's/^[	 ]*//' \
32564f00d7e1Smrg    -e '/^\(;.*\)*$/d' \
32574f00d7e1Smrg    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
32584f00d7e1Smrg    -e q \
32594f00d7e1Smrg    "$1"`
32604f00d7e1Smrg  test DEF = "$func_dll_def_p_tmp"
32614f00d7e1Smrg}
32624f00d7e1Smrg
32634f00d7e1Smrg
32640b661123Smrg# func_mode_compile arg...
32650b661123Smrgfunc_mode_compile ()
32660b661123Smrg{
32674f00d7e1Smrg    $debug_cmd
32684f00d7e1Smrg
32690b661123Smrg    # Get the compilation command and the source file.
32700b661123Smrg    base_compile=
32714f00d7e1Smrg    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
32720b661123Smrg    suppress_opt=yes
32730b661123Smrg    suppress_output=
32740b661123Smrg    arg_mode=normal
32750b661123Smrg    libobj=
32760b661123Smrg    later=
32770b661123Smrg    pie_flag=
32780b661123Smrg
32790b661123Smrg    for arg
32800b661123Smrg    do
32810b661123Smrg      case $arg_mode in
32820b661123Smrg      arg  )
32830b661123Smrg	# do not "continue".  Instead, add this to base_compile
32844f00d7e1Smrg	lastarg=$arg
32850b661123Smrg	arg_mode=normal
32860b661123Smrg	;;
32870b661123Smrg
32880b661123Smrg      target )
32894f00d7e1Smrg	libobj=$arg
32900b661123Smrg	arg_mode=normal
32910b661123Smrg	continue
32920b661123Smrg	;;
32930b661123Smrg
32940b661123Smrg      normal )
32950b661123Smrg	# Accept any command-line options.
32960b661123Smrg	case $arg in
32970b661123Smrg	-o)
32980b661123Smrg	  test -n "$libobj" && \
32994f00d7e1Smrg	    func_fatal_error "you cannot specify '-o' more than once"
33000b661123Smrg	  arg_mode=target
33010b661123Smrg	  continue
33020b661123Smrg	  ;;
33030b661123Smrg
33040b661123Smrg	-pie | -fpie | -fPIE)
3305880c7e28Smrg          func_append pie_flag " $arg"
33060b661123Smrg	  continue
33070b661123Smrg	  ;;
33080b661123Smrg
33090b661123Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
3310880c7e28Smrg	  func_append later " $arg"
33110b661123Smrg	  continue
33120b661123Smrg	  ;;
33130b661123Smrg
33140b661123Smrg	-no-suppress)
331572313efbSmrg	  suppress_opt=no
331672313efbSmrg	  continue
331772313efbSmrg	  ;;
331872313efbSmrg
331972313efbSmrg	-Xcompiler)
332072313efbSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
332172313efbSmrg	  continue      #  The current "srcfile" will either be retained or
332272313efbSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
332372313efbSmrg
332472313efbSmrg	-Wc,*)
33250b661123Smrg	  func_stripname '-Wc,' '' "$arg"
33260b661123Smrg	  args=$func_stripname_result
332772313efbSmrg	  lastarg=
33284f00d7e1Smrg	  save_ifs=$IFS; IFS=,
33290b661123Smrg	  for arg in $args; do
33304f00d7e1Smrg	    IFS=$save_ifs
3331880c7e28Smrg	    func_append_quoted lastarg "$arg"
3332bdcaa8d0Smrg	  done
33334f00d7e1Smrg	  IFS=$save_ifs
33340b661123Smrg	  func_stripname ' ' '' "$lastarg"
33350b661123Smrg	  lastarg=$func_stripname_result
3336bdcaa8d0Smrg
3337bdcaa8d0Smrg	  # Add the arguments to base_compile.
3338880c7e28Smrg	  func_append base_compile " $lastarg"
3339bdcaa8d0Smrg	  continue
3340bdcaa8d0Smrg	  ;;
3341bdcaa8d0Smrg
33420b661123Smrg	*)
3343bdcaa8d0Smrg	  # Accept the current argument as the source file.
3344bdcaa8d0Smrg	  # The previous "srcfile" becomes the current argument.
3345bdcaa8d0Smrg	  #
33464f00d7e1Smrg	  lastarg=$srcfile
33474f00d7e1Smrg	  srcfile=$arg
3348bdcaa8d0Smrg	  ;;
3349bdcaa8d0Smrg	esac  #  case $arg
3350bdcaa8d0Smrg	;;
3351bdcaa8d0Smrg      esac    #  case $arg_mode
3352bdcaa8d0Smrg
3353bdcaa8d0Smrg      # Aesthetically quote the previous argument.
3354880c7e28Smrg      func_append_quoted base_compile "$lastarg"
3355bdcaa8d0Smrg    done # for arg
3356bdcaa8d0Smrg
3357bdcaa8d0Smrg    case $arg_mode in
3358bdcaa8d0Smrg    arg)
33590b661123Smrg      func_fatal_error "you must specify an argument for -Xcompile"
3360bdcaa8d0Smrg      ;;
3361bdcaa8d0Smrg    target)
33624f00d7e1Smrg      func_fatal_error "you must specify a target with '-o'"
3363bdcaa8d0Smrg      ;;
3364bdcaa8d0Smrg    *)
3365bdcaa8d0Smrg      # Get the name of the library object.
33660b661123Smrg      test -z "$libobj" && {
33670b661123Smrg	func_basename "$srcfile"
33684f00d7e1Smrg	libobj=$func_basename_result
33690b661123Smrg      }
3370bdcaa8d0Smrg      ;;
3371bdcaa8d0Smrg    esac
3372bdcaa8d0Smrg
3373bdcaa8d0Smrg    # Recognize several different file suffixes.
3374bdcaa8d0Smrg    # If the user specifies -o file.o, it is replaced with file.lo
3375bdcaa8d0Smrg    case $libobj in
33760b661123Smrg    *.[cCFSifmso] | \
33770b661123Smrg    *.ada | *.adb | *.ads | *.asm | \
33780b661123Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
3379880c7e28Smrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
33800b661123Smrg      func_xform "$libobj"
33810b661123Smrg      libobj=$func_xform_result
33820b661123Smrg      ;;
3383bdcaa8d0Smrg    esac
3384bdcaa8d0Smrg
3385bdcaa8d0Smrg    case $libobj in
33860b661123Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
3387bdcaa8d0Smrg    *)
33884f00d7e1Smrg      func_fatal_error "cannot determine name of library object from '$libobj'"
3389bdcaa8d0Smrg      ;;
3390bdcaa8d0Smrg    esac
3391bdcaa8d0Smrg
3392bdcaa8d0Smrg    func_infer_tag $base_compile
3393bdcaa8d0Smrg
3394bdcaa8d0Smrg    for arg in $later; do
3395bdcaa8d0Smrg      case $arg in
33960b661123Smrg      -shared)
33974f00d7e1Smrg	test yes = "$build_libtool_libs" \
33984f00d7e1Smrg	  || func_fatal_configuration "cannot build a shared library"
33990b661123Smrg	build_old_libs=no
34000b661123Smrg	continue
34010b661123Smrg	;;
34020b661123Smrg
3403bdcaa8d0Smrg      -static)
34040b661123Smrg	build_libtool_libs=no
3405bdcaa8d0Smrg	build_old_libs=yes
3406bdcaa8d0Smrg	continue
3407bdcaa8d0Smrg	;;
3408bdcaa8d0Smrg
3409bdcaa8d0Smrg      -prefer-pic)
3410bdcaa8d0Smrg	pic_mode=yes
3411bdcaa8d0Smrg	continue
3412bdcaa8d0Smrg	;;
3413bdcaa8d0Smrg
3414bdcaa8d0Smrg      -prefer-non-pic)
3415bdcaa8d0Smrg	pic_mode=no
3416bdcaa8d0Smrg	continue
3417bdcaa8d0Smrg	;;
3418bdcaa8d0Smrg      esac
3419bdcaa8d0Smrg    done
3420bdcaa8d0Smrg
34210b661123Smrg    func_quote_for_eval "$libobj"
34220b661123Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
34230b661123Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
34244f00d7e1Smrg      && func_warning "libobj name '$libobj' may not contain shell special characters."
34250b661123Smrg    func_dirname_and_basename "$obj" "/" ""
34264f00d7e1Smrg    objname=$func_basename_result
34274f00d7e1Smrg    xdir=$func_dirname_result
34284f00d7e1Smrg    lobj=$xdir$objdir/$objname
3429bdcaa8d0Smrg
34300b661123Smrg    test -z "$base_compile" && \
34310b661123Smrg      func_fatal_help "you must specify a compilation command"
3432bdcaa8d0Smrg
3433bdcaa8d0Smrg    # Delete any leftover library objects.
34344f00d7e1Smrg    if test yes = "$build_old_libs"; then
3435bdcaa8d0Smrg      removelist="$obj $lobj $libobj ${libobj}T"
3436bdcaa8d0Smrg    else
3437bdcaa8d0Smrg      removelist="$lobj $libobj ${libobj}T"
3438bdcaa8d0Smrg    fi
3439bdcaa8d0Smrg
3440bdcaa8d0Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
3441bdcaa8d0Smrg    case $host_os in
34420b661123Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
3443bdcaa8d0Smrg      pic_mode=default
3444bdcaa8d0Smrg      ;;
3445bdcaa8d0Smrg    esac
34464f00d7e1Smrg    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
3447bdcaa8d0Smrg      # non-PIC code in shared libraries is not supported
3448bdcaa8d0Smrg      pic_mode=default
3449bdcaa8d0Smrg    fi
3450bdcaa8d0Smrg
3451bdcaa8d0Smrg    # Calculate the filename of the output object if compiler does
3452bdcaa8d0Smrg    # not support -o with -c
34534f00d7e1Smrg    if test no = "$compiler_c_o"; then
34544f00d7e1Smrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
34554f00d7e1Smrg      lockfile=$output_obj.lock
3456bdcaa8d0Smrg    else
3457bdcaa8d0Smrg      output_obj=
3458bdcaa8d0Smrg      need_locks=no
3459bdcaa8d0Smrg      lockfile=
3460bdcaa8d0Smrg    fi
3461bdcaa8d0Smrg
3462bdcaa8d0Smrg    # Lock this critical section if it is needed
3463bdcaa8d0Smrg    # We use this script file to make the link, it avoids creating a new file
34644f00d7e1Smrg    if test yes = "$need_locks"; then
34650b661123Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
34660b661123Smrg	func_echo "Waiting for $lockfile to be removed"
3467bdcaa8d0Smrg	sleep 2
3468bdcaa8d0Smrg      done
34694f00d7e1Smrg    elif test warn = "$need_locks"; then
3470bdcaa8d0Smrg      if test -f "$lockfile"; then
34710b661123Smrg	$ECHO "\
3472bdcaa8d0Smrg*** ERROR, $lockfile exists and contains:
3473bdcaa8d0Smrg`cat $lockfile 2>/dev/null`
3474bdcaa8d0Smrg
3475bdcaa8d0SmrgThis indicates that another process is trying to use the same
3476bdcaa8d0Smrgtemporary object file, and libtool could not work around it because
34774f00d7e1Smrgyour compiler does not support '-c' and '-o' together.  If you
3478bdcaa8d0Smrgrepeat this compilation, it may succeed, by chance, but you had better
3479bdcaa8d0Smrgavoid parallel builds (make -j) in this platform, or get a better
3480bdcaa8d0Smrgcompiler."
3481bdcaa8d0Smrg
34820b661123Smrg	$opt_dry_run || $RM $removelist
3483bdcaa8d0Smrg	exit $EXIT_FAILURE
3484bdcaa8d0Smrg      fi
3485880c7e28Smrg      func_append removelist " $output_obj"
34860b661123Smrg      $ECHO "$srcfile" > "$lockfile"
3487bdcaa8d0Smrg    fi
3488bdcaa8d0Smrg
34890b661123Smrg    $opt_dry_run || $RM $removelist
3490880c7e28Smrg    func_append removelist " $lockfile"
34910b661123Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
34920b661123Smrg
3493880c7e28Smrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
3494880c7e28Smrg    srcfile=$func_to_tool_file_result
34950b661123Smrg    func_quote_for_eval "$srcfile"
34960b661123Smrg    qsrcfile=$func_quote_for_eval_result
3497bdcaa8d0Smrg
3498bdcaa8d0Smrg    # Only build a PIC object if we are building libtool libraries.
34994f00d7e1Smrg    if test yes = "$build_libtool_libs"; then
3500bdcaa8d0Smrg      # Without this assignment, base_compile gets emptied.
3501bdcaa8d0Smrg      fbsd_hideous_sh_bug=$base_compile
3502bdcaa8d0Smrg
35034f00d7e1Smrg      if test no != "$pic_mode"; then
3504bdcaa8d0Smrg	command="$base_compile $qsrcfile $pic_flag"
3505bdcaa8d0Smrg      else
3506bdcaa8d0Smrg	# Don't build PIC code
3507bdcaa8d0Smrg	command="$base_compile $qsrcfile"
3508bdcaa8d0Smrg      fi
3509bdcaa8d0Smrg
35100b661123Smrg      func_mkdir_p "$xdir$objdir"
3511bdcaa8d0Smrg
3512bdcaa8d0Smrg      if test -z "$output_obj"; then
3513bdcaa8d0Smrg	# Place PIC objects in $objdir
3514880c7e28Smrg	func_append command " -o $lobj"
3515bdcaa8d0Smrg      fi
3516bdcaa8d0Smrg
35170b661123Smrg      func_show_eval_locale "$command"	\
35180b661123Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
3519bdcaa8d0Smrg
35204f00d7e1Smrg      if test warn = "$need_locks" &&
3521bdcaa8d0Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
35220b661123Smrg	$ECHO "\
3523bdcaa8d0Smrg*** ERROR, $lockfile contains:
3524bdcaa8d0Smrg`cat $lockfile 2>/dev/null`
3525bdcaa8d0Smrg
3526bdcaa8d0Smrgbut it should contain:
3527bdcaa8d0Smrg$srcfile
3528bdcaa8d0Smrg
3529bdcaa8d0SmrgThis indicates that another process is trying to use the same
3530bdcaa8d0Smrgtemporary object file, and libtool could not work around it because
35314f00d7e1Smrgyour compiler does not support '-c' and '-o' together.  If you
3532bdcaa8d0Smrgrepeat this compilation, it may succeed, by chance, but you had better
3533bdcaa8d0Smrgavoid parallel builds (make -j) in this platform, or get a better
3534bdcaa8d0Smrgcompiler."
3535bdcaa8d0Smrg
35360b661123Smrg	$opt_dry_run || $RM $removelist
3537bdcaa8d0Smrg	exit $EXIT_FAILURE
3538bdcaa8d0Smrg      fi
3539bdcaa8d0Smrg
3540bdcaa8d0Smrg      # Just move the object if needed, then go on to compile the next one
3541bdcaa8d0Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
35420b661123Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
35430b661123Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3544bdcaa8d0Smrg      fi
3545bdcaa8d0Smrg
3546bdcaa8d0Smrg      # Allow error messages only from the first compilation.
35474f00d7e1Smrg      if test yes = "$suppress_opt"; then
35480b661123Smrg	suppress_output=' >/dev/null 2>&1'
3549bdcaa8d0Smrg      fi
3550bdcaa8d0Smrg    fi
3551bdcaa8d0Smrg
3552bdcaa8d0Smrg    # Only build a position-dependent object if we build old libraries.
35534f00d7e1Smrg    if test yes = "$build_old_libs"; then
35544f00d7e1Smrg      if test yes != "$pic_mode"; then
3555bdcaa8d0Smrg	# Don't build PIC code
35560b661123Smrg	command="$base_compile $qsrcfile$pie_flag"
3557bdcaa8d0Smrg      else
3558bdcaa8d0Smrg	command="$base_compile $qsrcfile $pic_flag"
3559bdcaa8d0Smrg      fi
35604f00d7e1Smrg      if test yes = "$compiler_c_o"; then
3561880c7e28Smrg	func_append command " -o $obj"
3562bdcaa8d0Smrg      fi
3563bdcaa8d0Smrg
3564bdcaa8d0Smrg      # Suppress compiler output if we already did a PIC compilation.
3565880c7e28Smrg      func_append command "$suppress_output"
35660b661123Smrg      func_show_eval_locale "$command" \
35670b661123Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
3568bdcaa8d0Smrg
35694f00d7e1Smrg      if test warn = "$need_locks" &&
3570bdcaa8d0Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
35710b661123Smrg	$ECHO "\
3572bdcaa8d0Smrg*** ERROR, $lockfile contains:
3573bdcaa8d0Smrg`cat $lockfile 2>/dev/null`
3574bdcaa8d0Smrg
3575bdcaa8d0Smrgbut it should contain:
3576bdcaa8d0Smrg$srcfile
3577bdcaa8d0Smrg
3578bdcaa8d0SmrgThis indicates that another process is trying to use the same
3579bdcaa8d0Smrgtemporary object file, and libtool could not work around it because
35804f00d7e1Smrgyour compiler does not support '-c' and '-o' together.  If you
3581bdcaa8d0Smrgrepeat this compilation, it may succeed, by chance, but you had better
3582bdcaa8d0Smrgavoid parallel builds (make -j) in this platform, or get a better
3583bdcaa8d0Smrgcompiler."
3584bdcaa8d0Smrg
35850b661123Smrg	$opt_dry_run || $RM $removelist
3586bdcaa8d0Smrg	exit $EXIT_FAILURE
3587bdcaa8d0Smrg      fi
3588bdcaa8d0Smrg
3589bdcaa8d0Smrg      # Just move the object if needed
3590bdcaa8d0Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
35910b661123Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
35920b661123Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3593bdcaa8d0Smrg      fi
3594bdcaa8d0Smrg    fi
3595bdcaa8d0Smrg
35960b661123Smrg    $opt_dry_run || {
35970b661123Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
3598bdcaa8d0Smrg
35990b661123Smrg      # Unlock the critical section if it was locked
36004f00d7e1Smrg      if test no != "$need_locks"; then
36010b661123Smrg	removelist=$lockfile
36020b661123Smrg        $RM "$lockfile"
36030b661123Smrg      fi
36040b661123Smrg    }
3605bdcaa8d0Smrg
3606bdcaa8d0Smrg    exit $EXIT_SUCCESS
36070b661123Smrg}
3608bdcaa8d0Smrg
36090b661123Smrg$opt_help || {
36104f00d7e1Smrg  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
36110b661123Smrg}
3612bdcaa8d0Smrg
36130b661123Smrgfunc_mode_help ()
36140b661123Smrg{
36150b661123Smrg    # We need to display help for each of the modes.
3616880c7e28Smrg    case $opt_mode in
36170b661123Smrg      "")
36180b661123Smrg        # Generic help is extracted from the usage comments
36190b661123Smrg        # at the start of this file.
36200b661123Smrg        func_help
36210b661123Smrg        ;;
3622bdcaa8d0Smrg
36230b661123Smrg      clean)
36240b661123Smrg        $ECHO \
36250b661123Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
3626bdcaa8d0Smrg
36270b661123SmrgRemove files from the build directory.
3628bdcaa8d0Smrg
36290b661123SmrgRM is the name of the program to use to delete files associated with each FILE
36304f00d7e1Smrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
36310b661123Smrgto RM.
3632bdcaa8d0Smrg
36330b661123SmrgIf FILE is a libtool library, object or program, all the files associated
36340b661123Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
36350b661123Smrg        ;;
3636bdcaa8d0Smrg
36370b661123Smrg      compile)
36380b661123Smrg      $ECHO \
36390b661123Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
3640bdcaa8d0Smrg
36410b661123SmrgCompile a source file into a libtool library object.
3642bdcaa8d0Smrg
36430b661123SmrgThis mode accepts the following additional options:
3644bdcaa8d0Smrg
36450b661123Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
36460b661123Smrg  -no-suppress      do not suppress compiler output for multiple passes
3647880c7e28Smrg  -prefer-pic       try to build PIC objects only
3648880c7e28Smrg  -prefer-non-pic   try to build non-PIC objects only
36494f00d7e1Smrg  -shared           do not build a '.o' file suitable for static linking
36504f00d7e1Smrg  -static           only build a '.o' file suitable for static linking
3651880c7e28Smrg  -Wc,FLAG          pass FLAG directly to the compiler
3652bdcaa8d0Smrg
36534f00d7e1SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file
36540b661123Smrgfrom the given SOURCEFILE.
3655bdcaa8d0Smrg
36560b661123SmrgThe output file name is determined by removing the directory component from
36574f00d7e1SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the
36584f00d7e1Smrglibrary object suffix, '.lo'."
36590b661123Smrg        ;;
3660bdcaa8d0Smrg
36610b661123Smrg      execute)
36620b661123Smrg        $ECHO \
36630b661123Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
3664bdcaa8d0Smrg
36650b661123SmrgAutomatically set library path, then run a program.
3666bdcaa8d0Smrg
36670b661123SmrgThis mode accepts the following additional options:
3668bdcaa8d0Smrg
36690b661123Smrg  -dlopen FILE      add the directory containing FILE to the library path
3670bdcaa8d0Smrg
36714f00d7e1SmrgThis mode sets the library path environment variable according to '-dlopen'
36720b661123Smrgflags.
3673bdcaa8d0Smrg
36740b661123SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
36750b661123Smrginto their corresponding uninstalled binary, and any of their required library
36760b661123Smrgdirectories are added to the library path.
3677bdcaa8d0Smrg
36780b661123SmrgThen, COMMAND is executed, with ARGS as arguments."
36790b661123Smrg        ;;
3680bdcaa8d0Smrg
36810b661123Smrg      finish)
36820b661123Smrg        $ECHO \
36830b661123Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
3684bdcaa8d0Smrg
36850b661123SmrgComplete the installation of libtool libraries.
3686bdcaa8d0Smrg
36870b661123SmrgEach LIBDIR is a directory that contains libtool libraries.
3688bdcaa8d0Smrg
36890b661123SmrgThe commands that this mode executes may require superuser privileges.  Use
36904f00d7e1Smrgthe '--dry-run' option if you just want to see what would be executed."
36910b661123Smrg        ;;
3692bdcaa8d0Smrg
36930b661123Smrg      install)
36940b661123Smrg        $ECHO \
36950b661123Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
3696bdcaa8d0Smrg
36970b661123SmrgInstall executables or libraries.
3698bdcaa8d0Smrg
36990b661123SmrgINSTALL-COMMAND is the installation command.  The first component should be
37004f00d7e1Smrgeither the 'install' or 'cp' program.
3701bdcaa8d0Smrg
37020b661123SmrgThe following components of INSTALL-COMMAND are treated specially:
3703bdcaa8d0Smrg
3704880c7e28Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
3705bdcaa8d0Smrg
37060b661123SmrgThe rest of the components are interpreted as arguments to that command (only
37070b661123SmrgBSD-compatible install options are recognized)."
37080b661123Smrg        ;;
3709bdcaa8d0Smrg
37100b661123Smrg      link)
37110b661123Smrg        $ECHO \
37120b661123Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
3713bdcaa8d0Smrg
37140b661123SmrgLink object files or libraries together to form another library, or to
37150b661123Smrgcreate an executable program.
3716bdcaa8d0Smrg
37170b661123SmrgLINK-COMMAND is a command using the C compiler that you would use to create
37180b661123Smrga program from several object files.
3719bdcaa8d0Smrg
37200b661123SmrgThe following components of LINK-COMMAND are treated specially:
3721bdcaa8d0Smrg
37220b661123Smrg  -all-static       do not do any dynamic linking at all
37230b661123Smrg  -avoid-version    do not add a version suffix if possible
3724880c7e28Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
3725880c7e28Smrg                    libraries must be found in the PATH setting at runtime)
37264f00d7e1Smrg  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
37270b661123Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
37280b661123Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
37290b661123Smrg  -export-symbols SYMFILE
37300b661123Smrg                    try to export only the symbols listed in SYMFILE
37310b661123Smrg  -export-symbols-regex REGEX
37320b661123Smrg                    try to export only the symbols matching REGEX
37330b661123Smrg  -LLIBDIR          search LIBDIR for required installed libraries
37340b661123Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
37350b661123Smrg  -module           build a library that can dlopened
37360b661123Smrg  -no-fast-install  disable the fast-install mode
37370b661123Smrg  -no-install       link a not-installable executable
37380b661123Smrg  -no-undefined     declare that a library does not refer to external symbols
37390b661123Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
37404f00d7e1Smrg  -objectlist FILE  use a list of object files found in FILE to specify objects
37414f00d7e1Smrg  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
37420b661123Smrg  -precious-files-regex REGEX
37430b661123Smrg                    don't remove output files matching REGEX
37440b661123Smrg  -release RELEASE  specify package release information
37450b661123Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
37460b661123Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
37470b661123Smrg  -shared           only do dynamic linking of libtool libraries
37480b661123Smrg  -shrext SUFFIX    override the standard shared library file extension
37490b661123Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
37500b661123Smrg  -static-libtool-libs
37510b661123Smrg                    do not do any dynamic linking of libtool libraries
37520b661123Smrg  -version-info CURRENT[:REVISION[:AGE]]
37530b661123Smrg                    specify library version info [each variable defaults to 0]
37540b661123Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
3755880c7e28Smrg  -Wc,FLAG
3756880c7e28Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
3757880c7e28Smrg  -Wl,FLAG
3758880c7e28Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
3759880c7e28Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
3760bdcaa8d0Smrg
37614f00d7e1SmrgAll other options (arguments beginning with '-') are ignored.
3762bdcaa8d0Smrg
37634f00d7e1SmrgEvery other argument is treated as a filename.  Files ending in '.la' are
37640b661123Smrgtreated as uninstalled libtool libraries, other files are standard or library
37650b661123Smrgobject files.
3766bdcaa8d0Smrg
37674f00d7e1SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created,
37684f00d7e1Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is
37690b661123Smrgrequired, except when creating a convenience library.
3770bdcaa8d0Smrg
37714f00d7e1SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
37724f00d7e1Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'.
3773bdcaa8d0Smrg
37744f00d7e1SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
37750b661123Smrgis created, otherwise an executable program is created."
377696ce994aSmrg        ;;
3777bdcaa8d0Smrg
37780b661123Smrg      uninstall)
37790b661123Smrg        $ECHO \
37800b661123Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
3781bdcaa8d0Smrg
37820b661123SmrgRemove libraries from an installation directory.
3783bdcaa8d0Smrg
37840b661123SmrgRM is the name of the program to use to delete files associated with each FILE
37854f00d7e1Smrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
37860b661123Smrgto RM.
3787bdcaa8d0Smrg
37880b661123SmrgIf FILE is a libtool library, all the files associated with it are deleted.
37890b661123SmrgOtherwise, only FILE itself is deleted using RM."
37900b661123Smrg        ;;
3791bdcaa8d0Smrg
37920b661123Smrg      *)
37934f00d7e1Smrg        func_fatal_help "invalid operation mode '$opt_mode'"
37940b661123Smrg        ;;
37950b661123Smrg    esac
3796bdcaa8d0Smrg
3797880c7e28Smrg    echo
37984f00d7e1Smrg    $ECHO "Try '$progname --help' for more information about other modes."
37990b661123Smrg}
3800bdcaa8d0Smrg
3801880c7e28Smrg# Now that we've collected a possible --mode arg, show help if necessary
3802880c7e28Smrgif $opt_help; then
38034f00d7e1Smrg  if test : = "$opt_help"; then
3804880c7e28Smrg    func_mode_help
3805880c7e28Smrg  else
3806880c7e28Smrg    {
3807880c7e28Smrg      func_help noexit
3808880c7e28Smrg      for opt_mode in compile link execute install finish uninstall clean; do
3809880c7e28Smrg	func_mode_help
3810880c7e28Smrg      done
38114f00d7e1Smrg    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
3812880c7e28Smrg    {
3813880c7e28Smrg      func_help noexit
3814880c7e28Smrg      for opt_mode in compile link execute install finish uninstall clean; do
3815880c7e28Smrg	echo
3816880c7e28Smrg	func_mode_help
3817880c7e28Smrg      done
3818880c7e28Smrg    } |
38194f00d7e1Smrg    $SED '1d
3820880c7e28Smrg      /^When reporting/,/^Report/{
3821880c7e28Smrg	H
3822880c7e28Smrg	d
3823880c7e28Smrg      }
3824880c7e28Smrg      $x
3825880c7e28Smrg      /information about other modes/d
3826880c7e28Smrg      /more detailed .*MODE/d
3827880c7e28Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
3828880c7e28Smrg  fi
3829880c7e28Smrg  exit $?
3830880c7e28Smrgfi
383172313efbSmrg
3832bdcaa8d0Smrg
38330b661123Smrg# func_mode_execute arg...
38340b661123Smrgfunc_mode_execute ()
38350b661123Smrg{
38364f00d7e1Smrg    $debug_cmd
38374f00d7e1Smrg
38380b661123Smrg    # The first argument is the command name.
38394f00d7e1Smrg    cmd=$nonopt
38400b661123Smrg    test -z "$cmd" && \
38410b661123Smrg      func_fatal_help "you must specify a COMMAND"
384296ce994aSmrg
38430b661123Smrg    # Handle -dlopen flags immediately.
3844880c7e28Smrg    for file in $opt_dlopen; do
38450b661123Smrg      test -f "$file" \
38464f00d7e1Smrg	|| func_fatal_help "'$file' is not a file"
384796ce994aSmrg
38480b661123Smrg      dir=
38490b661123Smrg      case $file in
38500b661123Smrg      *.la)
3851880c7e28Smrg	func_resolve_sysroot "$file"
3852880c7e28Smrg	file=$func_resolve_sysroot_result
3853880c7e28Smrg
38540b661123Smrg	# Check to see that this really is a libtool archive.
38550b661123Smrg	func_lalib_unsafe_p "$file" \
38564f00d7e1Smrg	  || func_fatal_help "'$lib' is not a valid libtool archive"
385796ce994aSmrg
38580b661123Smrg	# Read the libtool library.
38590b661123Smrg	dlname=
38600b661123Smrg	library_names=
38610b661123Smrg	func_source "$file"
3862bdcaa8d0Smrg
38630b661123Smrg	# Skip this library if it cannot be dlopened.
38640b661123Smrg	if test -z "$dlname"; then
38650b661123Smrg	  # Warn if it was a shared library.
38660b661123Smrg	  test -n "$library_names" && \
38674f00d7e1Smrg	    func_warning "'$file' was not linked with '-export-dynamic'"
38680b661123Smrg	  continue
38690b661123Smrg	fi
3870bdcaa8d0Smrg
38710b661123Smrg	func_dirname "$file" "" "."
38724f00d7e1Smrg	dir=$func_dirname_result
3873bdcaa8d0Smrg
38740b661123Smrg	if test -f "$dir/$objdir/$dlname"; then
3875880c7e28Smrg	  func_append dir "/$objdir"
38760b661123Smrg	else
38770b661123Smrg	  if test ! -f "$dir/$dlname"; then
38784f00d7e1Smrg	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
38790b661123Smrg	  fi
38800b661123Smrg	fi
388196ce994aSmrg	;;
3882bdcaa8d0Smrg
38830b661123Smrg      *.lo)
38840b661123Smrg	# Just add the directory containing the .lo file.
38850b661123Smrg	func_dirname "$file" "" "."
38864f00d7e1Smrg	dir=$func_dirname_result
388796ce994aSmrg	;;
3888bdcaa8d0Smrg
38890b661123Smrg      *)
38904f00d7e1Smrg	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
389196ce994aSmrg	continue
389296ce994aSmrg	;;
38930b661123Smrg      esac
389472313efbSmrg
38950b661123Smrg      # Get the absolute pathname.
38960b661123Smrg      absdir=`cd "$dir" && pwd`
38974f00d7e1Smrg      test -n "$absdir" && dir=$absdir
389872313efbSmrg
38990b661123Smrg      # Now add the directory to shlibpath_var.
39000b661123Smrg      if eval "test -z \"\$$shlibpath_var\""; then
39010b661123Smrg	eval "$shlibpath_var=\"\$dir\""
39020b661123Smrg      else
39030b661123Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
39040b661123Smrg      fi
39050b661123Smrg    done
390672313efbSmrg
39070b661123Smrg    # This variable tells wrapper scripts just to set shlibpath_var
39080b661123Smrg    # rather than running their programs.
39094f00d7e1Smrg    libtool_execute_magic=$magic
391072313efbSmrg
39110b661123Smrg    # Check if any of the arguments is a wrapper script.
39120b661123Smrg    args=
39130b661123Smrg    for file
39140b661123Smrg    do
39150b661123Smrg      case $file in
3916880c7e28Smrg      -* | *.la | *.lo ) ;;
39170b661123Smrg      *)
39180b661123Smrg	# Do a test to see if this is really a libtool program.
39190b661123Smrg	if func_ltwrapper_script_p "$file"; then
39200b661123Smrg	  func_source "$file"
39210b661123Smrg	  # Transform arg to wrapped name.
39224f00d7e1Smrg	  file=$progdir/$program
39230b661123Smrg	elif func_ltwrapper_executable_p "$file"; then
39240b661123Smrg	  func_ltwrapper_scriptname "$file"
39250b661123Smrg	  func_source "$func_ltwrapper_scriptname_result"
39260b661123Smrg	  # Transform arg to wrapped name.
39274f00d7e1Smrg	  file=$progdir/$program
39280b661123Smrg	fi
39290b661123Smrg	;;
39300b661123Smrg      esac
39310b661123Smrg      # Quote arguments (to preserve shell metacharacters).
3932880c7e28Smrg      func_append_quoted args "$file"
39330b661123Smrg    done
393472313efbSmrg
39354f00d7e1Smrg    if $opt_dry_run; then
39364f00d7e1Smrg      # Display what would be done.
39374f00d7e1Smrg      if test -n "$shlibpath_var"; then
39384f00d7e1Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
39394f00d7e1Smrg	echo "export $shlibpath_var"
39404f00d7e1Smrg      fi
39414f00d7e1Smrg      $ECHO "$cmd$args"
39424f00d7e1Smrg      exit $EXIT_SUCCESS
39434f00d7e1Smrg    else
39440b661123Smrg      if test -n "$shlibpath_var"; then
39450b661123Smrg	# Export the shlibpath_var.
39460b661123Smrg	eval "export $shlibpath_var"
39470b661123Smrg      fi
394872313efbSmrg
39490b661123Smrg      # Restore saved environment variables
39500b661123Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
39510b661123Smrg      do
39520b661123Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
39530b661123Smrg                $lt_var=\$save_$lt_var; export $lt_var
395496ce994aSmrg	      else
39550b661123Smrg		$lt_unset $lt_var
39560b661123Smrg	      fi"
39570b661123Smrg      done
395872313efbSmrg
39590b661123Smrg      # Now prepare to actually exec the command.
39604f00d7e1Smrg      exec_cmd=\$cmd$args
39610b661123Smrg    fi
39620b661123Smrg}
396372313efbSmrg
39644f00d7e1Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"}
396572313efbSmrg
396696ce994aSmrg
39670b661123Smrg# func_mode_finish arg...
39680b661123Smrgfunc_mode_finish ()
39690b661123Smrg{
39704f00d7e1Smrg    $debug_cmd
39714f00d7e1Smrg
3972880c7e28Smrg    libs=
3973880c7e28Smrg    libdirs=
39740b661123Smrg    admincmds=
3975bdcaa8d0Smrg
3976880c7e28Smrg    for opt in "$nonopt" ${1+"$@"}
3977880c7e28Smrg    do
3978880c7e28Smrg      if test -d "$opt"; then
3979880c7e28Smrg	func_append libdirs " $opt"
3980880c7e28Smrg
3981880c7e28Smrg      elif test -f "$opt"; then
3982880c7e28Smrg	if func_lalib_unsafe_p "$opt"; then
3983880c7e28Smrg	  func_append libs " $opt"
3984880c7e28Smrg	else
39854f00d7e1Smrg	  func_warning "'$opt' is not a valid libtool archive"
3986880c7e28Smrg	fi
3987880c7e28Smrg
3988880c7e28Smrg      else
39894f00d7e1Smrg	func_fatal_error "invalid argument '$opt'"
3990880c7e28Smrg      fi
3991880c7e28Smrg    done
3992880c7e28Smrg
3993880c7e28Smrg    if test -n "$libs"; then
3994880c7e28Smrg      if test -n "$lt_sysroot"; then
3995880c7e28Smrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
3996880c7e28Smrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
3997880c7e28Smrg      else
3998880c7e28Smrg        sysroot_cmd=
3999880c7e28Smrg      fi
4000880c7e28Smrg
4001880c7e28Smrg      # Remove sysroot references
4002880c7e28Smrg      if $opt_dry_run; then
4003880c7e28Smrg        for lib in $libs; do
40044f00d7e1Smrg          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
4005880c7e28Smrg        done
4006880c7e28Smrg      else
4007880c7e28Smrg        tmpdir=`func_mktempdir`
4008880c7e28Smrg        for lib in $libs; do
40094f00d7e1Smrg	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
4010880c7e28Smrg	    > $tmpdir/tmp-la
4011880c7e28Smrg	  mv -f $tmpdir/tmp-la $lib
4012880c7e28Smrg	done
4013880c7e28Smrg        ${RM}r "$tmpdir"
4014880c7e28Smrg      fi
4015880c7e28Smrg    fi
4016bdcaa8d0Smrg
4017880c7e28Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
40180b661123Smrg      for libdir in $libdirs; do
40190b661123Smrg	if test -n "$finish_cmds"; then
40200b661123Smrg	  # Do each command in the finish commands.
40210b661123Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
40220b661123Smrg'"$cmd"'"'
402396ce994aSmrg	fi
40240b661123Smrg	if test -n "$finish_eval"; then
40250b661123Smrg	  # Do the single finish_eval.
40260b661123Smrg	  eval cmds=\"$finish_eval\"
4027880c7e28Smrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
40280b661123Smrg       $cmds"
40290b661123Smrg	fi
40300b661123Smrg      done
40310b661123Smrg    fi
4032bdcaa8d0Smrg
40330b661123Smrg    # Exit here if they wanted silent mode.
40344f00d7e1Smrg    $opt_quiet && exit $EXIT_SUCCESS
4035bdcaa8d0Smrg
4036880c7e28Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4037880c7e28Smrg      echo "----------------------------------------------------------------------"
4038880c7e28Smrg      echo "Libraries have been installed in:"
4039880c7e28Smrg      for libdir in $libdirs; do
4040880c7e28Smrg	$ECHO "   $libdir"
4041880c7e28Smrg      done
4042880c7e28Smrg      echo
4043880c7e28Smrg      echo "If you ever happen to want to link against installed libraries"
4044880c7e28Smrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
40454f00d7e1Smrg      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
4046880c7e28Smrg      echo "flag during linking and do at least one of the following:"
4047880c7e28Smrg      if test -n "$shlibpath_var"; then
40484f00d7e1Smrg	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
4049880c7e28Smrg	echo "     during execution"
4050880c7e28Smrg      fi
4051880c7e28Smrg      if test -n "$runpath_var"; then
40524f00d7e1Smrg	echo "   - add LIBDIR to the '$runpath_var' environment variable"
4053880c7e28Smrg	echo "     during linking"
4054880c7e28Smrg      fi
4055880c7e28Smrg      if test -n "$hardcode_libdir_flag_spec"; then
4056880c7e28Smrg	libdir=LIBDIR
4057880c7e28Smrg	eval flag=\"$hardcode_libdir_flag_spec\"
40580b661123Smrg
40594f00d7e1Smrg	$ECHO "   - use the '$flag' linker flag"
4060880c7e28Smrg      fi
4061880c7e28Smrg      if test -n "$admincmds"; then
4062880c7e28Smrg	$ECHO "   - have your system administrator run these commands:$admincmds"
4063880c7e28Smrg      fi
4064880c7e28Smrg      if test -f /etc/ld.so.conf; then
40654f00d7e1Smrg	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
4066880c7e28Smrg      fi
4067880c7e28Smrg      echo
40680b661123Smrg
4069880c7e28Smrg      echo "See any operating system documentation about shared libraries for"
4070880c7e28Smrg      case $host in
4071880c7e28Smrg	solaris2.[6789]|solaris2.1[0-9])
4072880c7e28Smrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
4073880c7e28Smrg	  echo "pages."
4074880c7e28Smrg	  ;;
4075880c7e28Smrg	*)
4076880c7e28Smrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
4077880c7e28Smrg	  ;;
4078880c7e28Smrg      esac
4079880c7e28Smrg      echo "----------------------------------------------------------------------"
4080880c7e28Smrg    fi
40810b661123Smrg    exit $EXIT_SUCCESS
40820b661123Smrg}
40830b661123Smrg
40844f00d7e1Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"}
40850b661123Smrg
40860b661123Smrg
40870b661123Smrg# func_mode_install arg...
40880b661123Smrgfunc_mode_install ()
40890b661123Smrg{
40904f00d7e1Smrg    $debug_cmd
40914f00d7e1Smrg
40920b661123Smrg    # There may be an optional sh(1) argument at the beginning of
40930b661123Smrg    # install_prog (especially on Windows NT).
40944f00d7e1Smrg    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
40950b661123Smrg       # Allow the use of GNU shtool's install command.
40964f00d7e1Smrg       case $nonopt in *shtool*) :;; *) false;; esac
40974f00d7e1Smrg    then
40980b661123Smrg      # Aesthetically quote it.
40990b661123Smrg      func_quote_for_eval "$nonopt"
41000b661123Smrg      install_prog="$func_quote_for_eval_result "
41010b661123Smrg      arg=$1
41020b661123Smrg      shift
41030b661123Smrg    else
41040b661123Smrg      install_prog=
41050b661123Smrg      arg=$nonopt
41060b661123Smrg    fi
41070b661123Smrg
41080b661123Smrg    # The real first argument should be the name of the installation program.
41090b661123Smrg    # Aesthetically quote it.
41100b661123Smrg    func_quote_for_eval "$arg"
4111880c7e28Smrg    func_append install_prog "$func_quote_for_eval_result"
4112880c7e28Smrg    install_shared_prog=$install_prog
4113880c7e28Smrg    case " $install_prog " in
4114880c7e28Smrg      *[\\\ /]cp\ *) install_cp=: ;;
4115880c7e28Smrg      *) install_cp=false ;;
4116880c7e28Smrg    esac
41170b661123Smrg
41180b661123Smrg    # We need to accept at least all the BSD install flags.
41190b661123Smrg    dest=
41200b661123Smrg    files=
41210b661123Smrg    opts=
41220b661123Smrg    prev=
41230b661123Smrg    install_type=
41244f00d7e1Smrg    isdir=false
41250b661123Smrg    stripme=
4126880c7e28Smrg    no_mode=:
41270b661123Smrg    for arg
41280b661123Smrg    do
4129880c7e28Smrg      arg2=
41300b661123Smrg      if test -n "$dest"; then
4131880c7e28Smrg	func_append files " $dest"
41320b661123Smrg	dest=$arg
41330b661123Smrg	continue
41340b661123Smrg      fi
41350b661123Smrg
41360b661123Smrg      case $arg in
41374f00d7e1Smrg      -d) isdir=: ;;
41380b661123Smrg      -f)
4139880c7e28Smrg	if $install_cp; then :; else
4140880c7e28Smrg	  prev=$arg
4141880c7e28Smrg	fi
41420b661123Smrg	;;
41430b661123Smrg      -g | -m | -o)
41440b661123Smrg	prev=$arg
41450b661123Smrg	;;
41460b661123Smrg      -s)
41470b661123Smrg	stripme=" -s"
41480b661123Smrg	continue
41490b661123Smrg	;;
41500b661123Smrg      -*)
41510b661123Smrg	;;
41520b661123Smrg      *)
41530b661123Smrg	# If the previous option needed an argument, then skip it.
41540b661123Smrg	if test -n "$prev"; then
41554f00d7e1Smrg	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
4156880c7e28Smrg	    arg2=$install_override_mode
4157880c7e28Smrg	    no_mode=false
4158880c7e28Smrg	  fi
415996ce994aSmrg	  prev=
416072313efbSmrg	else
41610b661123Smrg	  dest=$arg
41620b661123Smrg	  continue
416372313efbSmrg	fi
416496ce994aSmrg	;;
41650b661123Smrg      esac
416672313efbSmrg
41670b661123Smrg      # Aesthetically quote the argument.
41680b661123Smrg      func_quote_for_eval "$arg"
4169880c7e28Smrg      func_append install_prog " $func_quote_for_eval_result"
4170880c7e28Smrg      if test -n "$arg2"; then
4171880c7e28Smrg	func_quote_for_eval "$arg2"
4172880c7e28Smrg      fi
4173880c7e28Smrg      func_append install_shared_prog " $func_quote_for_eval_result"
41740b661123Smrg    done
4175bdcaa8d0Smrg
41760b661123Smrg    test -z "$install_prog" && \
41770b661123Smrg      func_fatal_help "you must specify an install program"
417872313efbSmrg
41790b661123Smrg    test -n "$prev" && \
41804f00d7e1Smrg      func_fatal_help "the '$prev' option requires an argument"
4181bdcaa8d0Smrg
4182880c7e28Smrg    if test -n "$install_override_mode" && $no_mode; then
4183880c7e28Smrg      if $install_cp; then :; else
4184880c7e28Smrg	func_quote_for_eval "$install_override_mode"
4185880c7e28Smrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
4186880c7e28Smrg      fi
4187880c7e28Smrg    fi
4188880c7e28Smrg
41890b661123Smrg    if test -z "$files"; then
41900b661123Smrg      if test -z "$dest"; then
41910b661123Smrg	func_fatal_help "no file or destination specified"
41920b661123Smrg      else
41930b661123Smrg	func_fatal_help "you must specify a destination"
41940b661123Smrg      fi
419596ce994aSmrg    fi
4196bdcaa8d0Smrg
41970b661123Smrg    # Strip any trailing slash from the destination.
41980b661123Smrg    func_stripname '' '/' "$dest"
41990b661123Smrg    dest=$func_stripname_result
4200bdcaa8d0Smrg
42010b661123Smrg    # Check to see that the destination is a directory.
42024f00d7e1Smrg    test -d "$dest" && isdir=:
42034f00d7e1Smrg    if $isdir; then
42044f00d7e1Smrg      destdir=$dest
42050b661123Smrg      destname=
420696ce994aSmrg    else
42070b661123Smrg      func_dirname_and_basename "$dest" "" "."
42084f00d7e1Smrg      destdir=$func_dirname_result
42094f00d7e1Smrg      destname=$func_basename_result
421072313efbSmrg
42110b661123Smrg      # Not a directory, so check to see that there is only one file specified.
42120b661123Smrg      set dummy $files; shift
42130b661123Smrg      test "$#" -gt 1 && \
42144f00d7e1Smrg	func_fatal_help "'$dest' is not a directory"
421572313efbSmrg    fi
42160b661123Smrg    case $destdir in
42170b661123Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
421896ce994aSmrg    *)
42190b661123Smrg      for file in $files; do
42200b661123Smrg	case $file in
42210b661123Smrg	*.lo) ;;
42220b661123Smrg	*)
42234f00d7e1Smrg	  func_fatal_help "'$destdir' must be an absolute directory name"
42240b661123Smrg	  ;;
42250b661123Smrg	esac
42260b661123Smrg      done
422796ce994aSmrg      ;;
422896ce994aSmrg    esac
4229bdcaa8d0Smrg
42300b661123Smrg    # This variable tells wrapper scripts just to set variables rather
42310b661123Smrg    # than running their programs.
42324f00d7e1Smrg    libtool_install_magic=$magic
423372313efbSmrg
42340b661123Smrg    staticlibs=
42350b661123Smrg    future_libdirs=
42360b661123Smrg    current_libdirs=
42370b661123Smrg    for file in $files; do
423872313efbSmrg
42390b661123Smrg      # Do each installation.
42400b661123Smrg      case $file in
42410b661123Smrg      *.$libext)
42420b661123Smrg	# Do the static libraries later.
4243880c7e28Smrg	func_append staticlibs " $file"
42440b661123Smrg	;;
42450b661123Smrg
42460b661123Smrg      *.la)
4247880c7e28Smrg	func_resolve_sysroot "$file"
4248880c7e28Smrg	file=$func_resolve_sysroot_result
4249880c7e28Smrg
42500b661123Smrg	# Check to see that this really is a libtool archive.
42510b661123Smrg	func_lalib_unsafe_p "$file" \
42524f00d7e1Smrg	  || func_fatal_help "'$file' is not a valid libtool archive"
42530b661123Smrg
42540b661123Smrg	library_names=
42550b661123Smrg	old_library=
42560b661123Smrg	relink_command=
42570b661123Smrg	func_source "$file"
42580b661123Smrg
42590b661123Smrg	# Add the libdir to current_libdirs if it is the destination.
42600b661123Smrg	if test "X$destdir" = "X$libdir"; then
42610b661123Smrg	  case "$current_libdirs " in
42620b661123Smrg	  *" $libdir "*) ;;
4263880c7e28Smrg	  *) func_append current_libdirs " $libdir" ;;
426472313efbSmrg	  esac
42650b661123Smrg	else
42660b661123Smrg	  # Note the libdir as a future libdir.
42670b661123Smrg	  case "$future_libdirs " in
42680b661123Smrg	  *" $libdir "*) ;;
4269880c7e28Smrg	  *) func_append future_libdirs " $libdir" ;;
42700b661123Smrg	  esac
42710b661123Smrg	fi
427272313efbSmrg
42730b661123Smrg	func_dirname "$file" "/" ""
42744f00d7e1Smrg	dir=$func_dirname_result
4275880c7e28Smrg	func_append dir "$objdir"
42760b661123Smrg
42770b661123Smrg	if test -n "$relink_command"; then
42780b661123Smrg	  # Determine the prefix the user has applied to our future dir.
4279880c7e28Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
42800b661123Smrg
42810b661123Smrg	  # Don't allow the user to place us outside of our expected
42820b661123Smrg	  # location b/c this prevents finding dependent libraries that
42830b661123Smrg	  # are installed to the same prefix.
42840b661123Smrg	  # At present, this check doesn't affect windows .dll's that
42850b661123Smrg	  # are installed into $libdir/../bin (currently, that works fine)
42860b661123Smrg	  # but it's something to keep an eye on.
42870b661123Smrg	  test "$inst_prefix_dir" = "$destdir" && \
42884f00d7e1Smrg	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
42890b661123Smrg
42900b661123Smrg	  if test -n "$inst_prefix_dir"; then
42910b661123Smrg	    # Stick the inst_prefix_dir data into the link command.
4292880c7e28Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
42930b661123Smrg	  else
4294880c7e28Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
42950b661123Smrg	  fi
42960b661123Smrg
42974f00d7e1Smrg	  func_warning "relinking '$file'"
42980b661123Smrg	  func_show_eval "$relink_command" \
42994f00d7e1Smrg	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
43000b661123Smrg	fi
43010b661123Smrg
43020b661123Smrg	# See the names of the shared library.
43030b661123Smrg	set dummy $library_names; shift
43040b661123Smrg	if test -n "$1"; then
43054f00d7e1Smrg	  realname=$1
43060b661123Smrg	  shift
43070b661123Smrg
43084f00d7e1Smrg	  srcname=$realname
43094f00d7e1Smrg	  test -n "$relink_command" && srcname=${realname}T
43100b661123Smrg
43110b661123Smrg	  # Install the shared library and build the symlinks.
4312880c7e28Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
43130b661123Smrg	      'exit $?'
43144f00d7e1Smrg	  tstripme=$stripme
43150b661123Smrg	  case $host_os in
43160b661123Smrg	  cygwin* | mingw* | pw32* | cegcc*)
43170b661123Smrg	    case $realname in
43180b661123Smrg	    *.dll.a)
43194f00d7e1Smrg	      tstripme=
43204f00d7e1Smrg	      ;;
43214f00d7e1Smrg	    esac
43224f00d7e1Smrg	    ;;
43234f00d7e1Smrg	  os2*)
43244f00d7e1Smrg	    case $realname in
43254f00d7e1Smrg	    *_dll.a)
43264f00d7e1Smrg	      tstripme=
43270b661123Smrg	      ;;
43280b661123Smrg	    esac
432972313efbSmrg	    ;;
433072313efbSmrg	  esac
43310b661123Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
43320b661123Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
433396ce994aSmrg	  fi
43340b661123Smrg
43350b661123Smrg	  if test "$#" -gt 0; then
43360b661123Smrg	    # Delete the old symlinks, and create new ones.
43374f00d7e1Smrg	    # Try 'ln -sf' first, because the 'ln' binary might depend on
43380b661123Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
43390b661123Smrg	    # so we also need to try rm && ln -s.
43400b661123Smrg	    for linkname
43410b661123Smrg	    do
43420b661123Smrg	      test "$linkname" != "$realname" \
43430b661123Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
434496ce994aSmrg	    done
434596ce994aSmrg	  fi
4346bdcaa8d0Smrg
43470b661123Smrg	  # Do each command in the postinstall commands.
43484f00d7e1Smrg	  lib=$destdir/$realname
43490b661123Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
435096ce994aSmrg	fi
4351bdcaa8d0Smrg
43520b661123Smrg	# Install the pseudo-library for information purposes.
43530b661123Smrg	func_basename "$file"
43544f00d7e1Smrg	name=$func_basename_result
43554f00d7e1Smrg	instname=$dir/${name}i
43560b661123Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
4357bdcaa8d0Smrg
43580b661123Smrg	# Maybe install the static library, too.
4359880c7e28Smrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
43600b661123Smrg	;;
4361bdcaa8d0Smrg
43620b661123Smrg      *.lo)
43630b661123Smrg	# Install (i.e. copy) a libtool object.
4364bdcaa8d0Smrg
43650b661123Smrg	# Figure out destination file name, if it wasn't already specified.
43660b661123Smrg	if test -n "$destname"; then
43674f00d7e1Smrg	  destfile=$destdir/$destname
43680b661123Smrg	else
43690b661123Smrg	  func_basename "$file"
43704f00d7e1Smrg	  destfile=$func_basename_result
43714f00d7e1Smrg	  destfile=$destdir/$destfile
437296ce994aSmrg	fi
4373bdcaa8d0Smrg
43740b661123Smrg	# Deduce the name of the destination old-style object file.
43750b661123Smrg	case $destfile in
43760b661123Smrg	*.lo)
43770b661123Smrg	  func_lo2o "$destfile"
43780b661123Smrg	  staticdest=$func_lo2o_result
43790b661123Smrg	  ;;
43800b661123Smrg	*.$objext)
43814f00d7e1Smrg	  staticdest=$destfile
43820b661123Smrg	  destfile=
43830b661123Smrg	  ;;
43840b661123Smrg	*)
43854f00d7e1Smrg	  func_fatal_help "cannot copy a libtool object to '$destfile'"
43860b661123Smrg	  ;;
43870b661123Smrg	esac
4388bdcaa8d0Smrg
43890b661123Smrg	# Install the libtool object if requested.
43900b661123Smrg	test -n "$destfile" && \
43910b661123Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
4392bdcaa8d0Smrg
43930b661123Smrg	# Install the old object if enabled.
43944f00d7e1Smrg	if test yes = "$build_old_libs"; then
43950b661123Smrg	  # Deduce the name of the old-style object file.
43960b661123Smrg	  func_lo2o "$file"
43970b661123Smrg	  staticobj=$func_lo2o_result
43980b661123Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
4399bdcaa8d0Smrg	fi
44000b661123Smrg	exit $EXIT_SUCCESS
44010b661123Smrg	;;
4402bdcaa8d0Smrg
44030b661123Smrg      *)
44040b661123Smrg	# Figure out destination file name, if it wasn't already specified.
44050b661123Smrg	if test -n "$destname"; then
44064f00d7e1Smrg	  destfile=$destdir/$destname
44070b661123Smrg	else
44080b661123Smrg	  func_basename "$file"
44094f00d7e1Smrg	  destfile=$func_basename_result
44104f00d7e1Smrg	  destfile=$destdir/$destfile
44110b661123Smrg	fi
4412bdcaa8d0Smrg
44130b661123Smrg	# If the file is missing, and there is a .exe on the end, strip it
44140b661123Smrg	# because it is most likely a libtool script we actually want to
44150b661123Smrg	# install
44164f00d7e1Smrg	stripped_ext=
44170b661123Smrg	case $file in
44180b661123Smrg	  *.exe)
44190b661123Smrg	    if test ! -f "$file"; then
44200b661123Smrg	      func_stripname '' '.exe' "$file"
44210b661123Smrg	      file=$func_stripname_result
44224f00d7e1Smrg	      stripped_ext=.exe
44230b661123Smrg	    fi
44240b661123Smrg	    ;;
44250b661123Smrg	esac
44260b661123Smrg
44270b661123Smrg	# Do a test to see if this is really a libtool program.
44280b661123Smrg	case $host in
44290b661123Smrg	*cygwin* | *mingw*)
44300b661123Smrg	    if func_ltwrapper_executable_p "$file"; then
44310b661123Smrg	      func_ltwrapper_scriptname "$file"
44320b661123Smrg	      wrapper=$func_ltwrapper_scriptname_result
44330b661123Smrg	    else
44340b661123Smrg	      func_stripname '' '.exe' "$file"
44350b661123Smrg	      wrapper=$func_stripname_result
44360b661123Smrg	    fi
44370b661123Smrg	    ;;
443896ce994aSmrg	*)
44390b661123Smrg	    wrapper=$file
44400b661123Smrg	    ;;
44410b661123Smrg	esac
44420b661123Smrg	if func_ltwrapper_script_p "$wrapper"; then
44430b661123Smrg	  notinst_deplibs=
44440b661123Smrg	  relink_command=
44450b661123Smrg
44460b661123Smrg	  func_source "$wrapper"
44470b661123Smrg
44480b661123Smrg	  # Check the variables that should have been set.
44490b661123Smrg	  test -z "$generated_by_libtool_version" && \
44504f00d7e1Smrg	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
44510b661123Smrg
44524f00d7e1Smrg	  finalize=:
44530b661123Smrg	  for lib in $notinst_deplibs; do
44540b661123Smrg	    # Check to see that each library is installed.
44550b661123Smrg	    libdir=
44560b661123Smrg	    if test -f "$lib"; then
44570b661123Smrg	      func_source "$lib"
44580b661123Smrg	    fi
44594f00d7e1Smrg	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
44600b661123Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
44614f00d7e1Smrg	      func_warning "'$lib' has not been installed in '$libdir'"
44624f00d7e1Smrg	      finalize=false
44630b661123Smrg	    fi
44640b661123Smrg	  done
44650b661123Smrg
44660b661123Smrg	  relink_command=
44670b661123Smrg	  func_source "$wrapper"
44680b661123Smrg
44690b661123Smrg	  outputname=
44704f00d7e1Smrg	  if test no = "$fast_install" && test -n "$relink_command"; then
44710b661123Smrg	    $opt_dry_run || {
44724f00d7e1Smrg	      if $finalize; then
44730b661123Smrg	        tmpdir=`func_mktempdir`
44740b661123Smrg		func_basename "$file$stripped_ext"
44754f00d7e1Smrg		file=$func_basename_result
44764f00d7e1Smrg	        outputname=$tmpdir/$file
44770b661123Smrg	        # Replace the output file specification.
4478880c7e28Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
44790b661123Smrg
44804f00d7e1Smrg	        $opt_quiet || {
44810b661123Smrg	          func_quote_for_expand "$relink_command"
44820b661123Smrg		  eval "func_echo $func_quote_for_expand_result"
44830b661123Smrg	        }
44840b661123Smrg	        if eval "$relink_command"; then :
44850b661123Smrg	          else
44864f00d7e1Smrg		  func_error "error: relink '$file' with the above command before installing it"
44870b661123Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
44880b661123Smrg		  continue
44890b661123Smrg	        fi
44904f00d7e1Smrg	        file=$outputname
44910b661123Smrg	      else
44924f00d7e1Smrg	        func_warning "cannot relink '$file'"
44930b661123Smrg	      fi
44940b661123Smrg	    }
44950b661123Smrg	  else
44960b661123Smrg	    # Install the binary that we compiled earlier.
4497880c7e28Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
449896ce994aSmrg	  fi
44990b661123Smrg	fi
45000b661123Smrg
45010b661123Smrg	# remove .exe since cygwin /usr/bin/install will append another
45020b661123Smrg	# one anyway
45030b661123Smrg	case $install_prog,$host in
45040b661123Smrg	*/usr/bin/install*,*cygwin*)
45050b661123Smrg	  case $file:$destfile in
45060b661123Smrg	  *.exe:*.exe)
45070b661123Smrg	    # this is ok
45080b661123Smrg	    ;;
45090b661123Smrg	  *.exe:*)
45100b661123Smrg	    destfile=$destfile.exe
45110b661123Smrg	    ;;
45120b661123Smrg	  *:*.exe)
45130b661123Smrg	    func_stripname '' '.exe' "$destfile"
45140b661123Smrg	    destfile=$func_stripname_result
45150b661123Smrg	    ;;
45160b661123Smrg	  esac
451796ce994aSmrg	  ;;
451896ce994aSmrg	esac
45190b661123Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
45200b661123Smrg	$opt_dry_run || if test -n "$outputname"; then
45210b661123Smrg	  ${RM}r "$tmpdir"
45220b661123Smrg	fi
45230b661123Smrg	;;
45240b661123Smrg      esac
45250b661123Smrg    done
4526bdcaa8d0Smrg
45270b661123Smrg    for file in $staticlibs; do
45280b661123Smrg      func_basename "$file"
45294f00d7e1Smrg      name=$func_basename_result
45300b661123Smrg
45310b661123Smrg      # Set up the ranlib parameters.
45324f00d7e1Smrg      oldlib=$destdir/$name
4533880c7e28Smrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
4534880c7e28Smrg      tool_oldlib=$func_to_tool_file_result
45350b661123Smrg
45360b661123Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
45370b661123Smrg
45380b661123Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
4539880c7e28Smrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
45400b661123Smrg      fi
45410b661123Smrg
45420b661123Smrg      # Do each command in the postinstall commands.
45430b661123Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
45440b661123Smrg    done
45450b661123Smrg
45460b661123Smrg    test -n "$future_libdirs" && \
45474f00d7e1Smrg      func_warning "remember to run '$progname --finish$future_libdirs'"
45480b661123Smrg
45490b661123Smrg    if test -n "$current_libdirs"; then
45500b661123Smrg      # Maybe just do a dry run.
45510b661123Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
45524f00d7e1Smrg      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
45530b661123Smrg    else
45540b661123Smrg      exit $EXIT_SUCCESS
45550b661123Smrg    fi
45560b661123Smrg}
45570b661123Smrg
45584f00d7e1Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"}
45590b661123Smrg
45600b661123Smrg
45610b661123Smrg# func_generate_dlsyms outputname originator pic_p
45620b661123Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
45630b661123Smrg# a dlpreopen symbol table.
45640b661123Smrgfunc_generate_dlsyms ()
45650b661123Smrg{
45664f00d7e1Smrg    $debug_cmd
45674f00d7e1Smrg
45684f00d7e1Smrg    my_outputname=$1
45694f00d7e1Smrg    my_originator=$2
45704f00d7e1Smrg    my_pic_p=${3-false}
45714f00d7e1Smrg    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
45720b661123Smrg    my_dlsyms=
45730b661123Smrg
45744f00d7e1Smrg    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
45750b661123Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
45764f00d7e1Smrg	my_dlsyms=${my_outputname}S.c
45770b661123Smrg      else
45780b661123Smrg	func_error "not configured to extract global symbols from dlpreopened files"
45790b661123Smrg      fi
45800b661123Smrg    fi
45810b661123Smrg
45820b661123Smrg    if test -n "$my_dlsyms"; then
45830b661123Smrg      case $my_dlsyms in
45840b661123Smrg      "") ;;
45850b661123Smrg      *.c)
45860b661123Smrg	# Discover the nlist of each of the dlfiles.
45874f00d7e1Smrg	nlist=$output_objdir/$my_outputname.nm
45880b661123Smrg
45890b661123Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
45900b661123Smrg
45910b661123Smrg	# Parse the name list into a source file.
45920b661123Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
45930b661123Smrg
45940b661123Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
45954f00d7e1Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
45964f00d7e1Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
45970b661123Smrg
45980b661123Smrg#ifdef __cplusplus
45990b661123Smrgextern \"C\" {
46000b661123Smrg#endif
46010b661123Smrg
46024f00d7e1Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
4603880c7e28Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
4604880c7e28Smrg#endif
4605880c7e28Smrg
4606880c7e28Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
46074f00d7e1Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
46084f00d7e1Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime
4609880c7e28Smrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
4610880c7e28Smrg# define LT_DLSYM_CONST
46114f00d7e1Smrg#elif defined __osf__
4612880c7e28Smrg/* This system does not cope well with relocations in const data.  */
4613880c7e28Smrg# define LT_DLSYM_CONST
4614880c7e28Smrg#else
4615880c7e28Smrg# define LT_DLSYM_CONST const
4616880c7e28Smrg#endif
4617880c7e28Smrg
46184f00d7e1Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
46194f00d7e1Smrg
46200b661123Smrg/* External symbol declarations for the compiler. */\
46210b661123Smrg"
46220b661123Smrg
46234f00d7e1Smrg	if test yes = "$dlself"; then
46244f00d7e1Smrg	  func_verbose "generating symbol list for '$output'"
46250b661123Smrg
46260b661123Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
46270b661123Smrg
46280b661123Smrg	  # Add our own program objects to the symbol list.
4629880c7e28Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
46300b661123Smrg	  for progfile in $progfiles; do
4631880c7e28Smrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
46324f00d7e1Smrg	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
4633880c7e28Smrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
46340b661123Smrg	  done
46350b661123Smrg
46360b661123Smrg	  if test -n "$exclude_expsyms"; then
46370b661123Smrg	    $opt_dry_run || {
46380b661123Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
46390b661123Smrg	      eval '$MV "$nlist"T "$nlist"'
46400b661123Smrg	    }
464196ce994aSmrg	  fi
46420b661123Smrg
46430b661123Smrg	  if test -n "$export_symbols_regex"; then
46440b661123Smrg	    $opt_dry_run || {
46450b661123Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
46460b661123Smrg	      eval '$MV "$nlist"T "$nlist"'
46470b661123Smrg	    }
46480b661123Smrg	  fi
46490b661123Smrg
46500b661123Smrg	  # Prepare the list of exported symbols
46510b661123Smrg	  if test -z "$export_symbols"; then
46524f00d7e1Smrg	    export_symbols=$output_objdir/$outputname.exp
46530b661123Smrg	    $opt_dry_run || {
46540b661123Smrg	      $RM $export_symbols
46554f00d7e1Smrg	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
46560b661123Smrg	      case $host in
46570b661123Smrg	      *cygwin* | *mingw* | *cegcc* )
46580b661123Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
46590b661123Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
46600b661123Smrg	        ;;
46610b661123Smrg	      esac
46620b661123Smrg	    }
466396ce994aSmrg	  else
46640b661123Smrg	    $opt_dry_run || {
46654f00d7e1Smrg	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
46660b661123Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
46670b661123Smrg	      eval '$MV "$nlist"T "$nlist"'
46680b661123Smrg	      case $host in
4669880c7e28Smrg	        *cygwin* | *mingw* | *cegcc* )
46700b661123Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
46710b661123Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
46720b661123Smrg	          ;;
46730b661123Smrg	      esac
46740b661123Smrg	    }
467596ce994aSmrg	  fi
46760b661123Smrg	fi
4677bdcaa8d0Smrg
46780b661123Smrg	for dlprefile in $dlprefiles; do
46794f00d7e1Smrg	  func_verbose "extracting global C symbols from '$dlprefile'"
46800b661123Smrg	  func_basename "$dlprefile"
46814f00d7e1Smrg	  name=$func_basename_result
4682880c7e28Smrg          case $host in
4683880c7e28Smrg	    *cygwin* | *mingw* | *cegcc* )
4684880c7e28Smrg	      # if an import library, we need to obtain dlname
4685880c7e28Smrg	      if func_win32_import_lib_p "$dlprefile"; then
4686880c7e28Smrg	        func_tr_sh "$dlprefile"
4687880c7e28Smrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
46884f00d7e1Smrg	        dlprefile_dlbasename=
4689880c7e28Smrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
4690880c7e28Smrg	          # Use subshell, to avoid clobbering current variable values
4691880c7e28Smrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
46924f00d7e1Smrg	          if test -n "$dlprefile_dlname"; then
4693880c7e28Smrg	            func_basename "$dlprefile_dlname"
46944f00d7e1Smrg	            dlprefile_dlbasename=$func_basename_result
4695880c7e28Smrg	          else
4696880c7e28Smrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
4697880c7e28Smrg	            $sharedlib_from_linklib_cmd "$dlprefile"
4698880c7e28Smrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
4699880c7e28Smrg	          fi
4700880c7e28Smrg	        fi
4701880c7e28Smrg	        $opt_dry_run || {
47024f00d7e1Smrg	          if test -n "$dlprefile_dlbasename"; then
4703880c7e28Smrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
4704880c7e28Smrg	          else
4705880c7e28Smrg	            func_warning "Could not compute DLL name from $name"
4706880c7e28Smrg	            eval '$ECHO ": $name " >> "$nlist"'
4707880c7e28Smrg	          fi
4708880c7e28Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4709880c7e28Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
4710880c7e28Smrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
4711880c7e28Smrg	        }
4712880c7e28Smrg	      else # not an import lib
4713880c7e28Smrg	        $opt_dry_run || {
4714880c7e28Smrg	          eval '$ECHO ": $name " >> "$nlist"'
4715880c7e28Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4716880c7e28Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4717880c7e28Smrg	        }
4718880c7e28Smrg	      fi
4719880c7e28Smrg	    ;;
4720880c7e28Smrg	    *)
4721880c7e28Smrg	      $opt_dry_run || {
4722880c7e28Smrg	        eval '$ECHO ": $name " >> "$nlist"'
4723880c7e28Smrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4724880c7e28Smrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4725880c7e28Smrg	      }
4726880c7e28Smrg	    ;;
4727880c7e28Smrg          esac
47280b661123Smrg	done
47290b661123Smrg
47300b661123Smrg	$opt_dry_run || {
47310b661123Smrg	  # Make sure we have at least an empty file.
47320b661123Smrg	  test -f "$nlist" || : > "$nlist"
47330b661123Smrg
47340b661123Smrg	  if test -n "$exclude_expsyms"; then
47350b661123Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
47360b661123Smrg	    $MV "$nlist"T "$nlist"
473796ce994aSmrg	  fi
47380b661123Smrg
47390b661123Smrg	  # Try sorting and uniquifying the output.
47400b661123Smrg	  if $GREP -v "^: " < "$nlist" |
47410b661123Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
47420b661123Smrg		sort -k 3
47430b661123Smrg	      else
47440b661123Smrg		sort +2
47450b661123Smrg	      fi |
47460b661123Smrg	      uniq > "$nlist"S; then
47470b661123Smrg	    :
474896ce994aSmrg	  else
47490b661123Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
475096ce994aSmrg	  fi
4751bdcaa8d0Smrg
47520b661123Smrg	  if test -f "$nlist"S; then
47530b661123Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
475496ce994aSmrg	  else
4755880c7e28Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
475696ce994aSmrg	  fi
4757bdcaa8d0Smrg
47584f00d7e1Smrg	  func_show_eval '$RM "${nlist}I"'
47594f00d7e1Smrg	  if test -n "$global_symbol_to_import"; then
47604f00d7e1Smrg	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
47614f00d7e1Smrg	  fi
47624f00d7e1Smrg
4763880c7e28Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
4764bdcaa8d0Smrg
47650b661123Smrg/* The mapping between symbol names and symbols.  */
47660b661123Smrgtypedef struct {
47670b661123Smrg  const char *name;
47680b661123Smrg  void *address;
47690b661123Smrg} lt_dlsymlist;
4770880c7e28Smrgextern LT_DLSYM_CONST lt_dlsymlist
47714f00d7e1Smrglt_${my_prefix}_LTX_preloaded_symbols[];\
47724f00d7e1Smrg"
47734f00d7e1Smrg
47744f00d7e1Smrg	  if test -s "$nlist"I; then
47754f00d7e1Smrg	    echo >> "$output_objdir/$my_dlsyms" "\
47764f00d7e1Smrgstatic void lt_syminit(void)
47774f00d7e1Smrg{
47784f00d7e1Smrg  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
47794f00d7e1Smrg  for (; symbol->name; ++symbol)
47804f00d7e1Smrg    {"
47814f00d7e1Smrg	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
47824f00d7e1Smrg	    echo >> "$output_objdir/$my_dlsyms" "\
47834f00d7e1Smrg    }
47844f00d7e1Smrg}"
47854f00d7e1Smrg	  fi
47864f00d7e1Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
4787880c7e28SmrgLT_DLSYM_CONST lt_dlsymlist
47880b661123Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
47894f00d7e1Smrg{ {\"$my_originator\", (void *) 0},"
47904f00d7e1Smrg
47914f00d7e1Smrg	  if test -s "$nlist"I; then
47924f00d7e1Smrg	    echo >> "$output_objdir/$my_dlsyms" "\
47934f00d7e1Smrg  {\"@INIT@\", (void *) &lt_syminit},"
47944f00d7e1Smrg	  fi
4795bdcaa8d0Smrg
47960b661123Smrg	  case $need_lib_prefix in
47970b661123Smrg	  no)
47980b661123Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
47990b661123Smrg	    ;;
48000b661123Smrg	  *)
48010b661123Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
48020b661123Smrg	    ;;
48030b661123Smrg	  esac
4804880c7e28Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
48050b661123Smrg  {0, (void *) 0}
48060b661123Smrg};
4807bdcaa8d0Smrg
48080b661123Smrg/* This works around a problem in FreeBSD linker */
48090b661123Smrg#ifdef FREEBSD_WORKAROUND
48100b661123Smrgstatic const void *lt_preloaded_setup() {
48110b661123Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
48120b661123Smrg}
48130b661123Smrg#endif
48140b661123Smrg
48150b661123Smrg#ifdef __cplusplus
48160b661123Smrg}
48170b661123Smrg#endif\
48180b661123Smrg"
48190b661123Smrg	} # !$opt_dry_run
48200b661123Smrg
48210b661123Smrg	pic_flag_for_symtable=
48220b661123Smrg	case "$compile_command " in
48230b661123Smrg	*" -static "*) ;;
48240b661123Smrg	*)
48250b661123Smrg	  case $host in
48260b661123Smrg	  # compiling the symbol table file with pic_flag works around
48270b661123Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
48280b661123Smrg	  # linked before any other PIC object.  But we must not use
48290b661123Smrg	  # pic_flag when linking with -static.  The problem exists in
48300b661123Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4831880c7e28Smrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
48320b661123Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
48330b661123Smrg	  *-*-hpux*)
48340b661123Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
48350b661123Smrg	  *)
48364f00d7e1Smrg	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
48370b661123Smrg	    ;;
48380b661123Smrg	  esac
48390b661123Smrg	  ;;
48400b661123Smrg	esac
48410b661123Smrg	symtab_cflags=
48420b661123Smrg	for arg in $LTCFLAGS; do
48430b661123Smrg	  case $arg in
48440b661123Smrg	  -pie | -fpie | -fPIE) ;;
4845880c7e28Smrg	  *) func_append symtab_cflags " $arg" ;;
48460b661123Smrg	  esac
48470b661123Smrg	done
4848bdcaa8d0Smrg
48490b661123Smrg	# Now compile the dynamic symbol file.
48500b661123Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
4851bdcaa8d0Smrg
48520b661123Smrg	# Clean up the generated files.
48534f00d7e1Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
4854bdcaa8d0Smrg
48550b661123Smrg	# Transform the symbol file into the correct name.
48564f00d7e1Smrg	symfileobj=$output_objdir/${my_outputname}S.$objext
48570b661123Smrg	case $host in
48580b661123Smrg	*cygwin* | *mingw* | *cegcc* )
48590b661123Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
4860880c7e28Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4861880c7e28Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
48620b661123Smrg	  else
4863880c7e28Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4864880c7e28Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
486596ce994aSmrg	  fi
48660b661123Smrg	  ;;
48670b661123Smrg	*)
4868880c7e28Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4869880c7e28Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
48700b661123Smrg	  ;;
48710b661123Smrg	esac
48720b661123Smrg	;;
48730b661123Smrg      *)
48744f00d7e1Smrg	func_fatal_error "unknown suffix for '$my_dlsyms'"
48750b661123Smrg	;;
48760b661123Smrg      esac
48770b661123Smrg    else
48780b661123Smrg      # We keep going just in case the user didn't refer to
48790b661123Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
48800b661123Smrg      # really was required.
4881bdcaa8d0Smrg
48820b661123Smrg      # Nullify the symbol file.
4883880c7e28Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
4884880c7e28Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
48850b661123Smrg    fi
48860b661123Smrg}
4887bdcaa8d0Smrg
48884f00d7e1Smrg# func_cygming_gnu_implib_p ARG
48894f00d7e1Smrg# This predicate returns with zero status (TRUE) if
48904f00d7e1Smrg# ARG is a GNU/binutils-style import library. Returns
48914f00d7e1Smrg# with nonzero status (FALSE) otherwise.
48924f00d7e1Smrgfunc_cygming_gnu_implib_p ()
48934f00d7e1Smrg{
48944f00d7e1Smrg  $debug_cmd
48954f00d7e1Smrg
48964f00d7e1Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
48974f00d7e1Smrg  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)$'`
48984f00d7e1Smrg  test -n "$func_cygming_gnu_implib_tmp"
48994f00d7e1Smrg}
49004f00d7e1Smrg
49014f00d7e1Smrg# func_cygming_ms_implib_p ARG
49024f00d7e1Smrg# This predicate returns with zero status (TRUE) if
49034f00d7e1Smrg# ARG is an MS-style import library. Returns
49044f00d7e1Smrg# with nonzero status (FALSE) otherwise.
49054f00d7e1Smrgfunc_cygming_ms_implib_p ()
49064f00d7e1Smrg{
49074f00d7e1Smrg  $debug_cmd
49084f00d7e1Smrg
49094f00d7e1Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
49104f00d7e1Smrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
49114f00d7e1Smrg  test -n "$func_cygming_ms_implib_tmp"
49124f00d7e1Smrg}
49134f00d7e1Smrg
49140b661123Smrg# func_win32_libid arg
49150b661123Smrg# return the library type of file 'arg'
49160b661123Smrg#
49170b661123Smrg# Need a lot of goo to handle *both* DLLs and import libs
49180b661123Smrg# Has to be a shell function in order to 'eat' the argument
49190b661123Smrg# that is supplied when $file_magic_command is called.
4920880c7e28Smrg# Despite the name, also deal with 64 bit binaries.
49210b661123Smrgfunc_win32_libid ()
49220b661123Smrg{
49234f00d7e1Smrg  $debug_cmd
49244f00d7e1Smrg
49254f00d7e1Smrg  win32_libid_type=unknown
49260b661123Smrg  win32_fileres=`file -L $1 2>/dev/null`
49270b661123Smrg  case $win32_fileres in
49280b661123Smrg  *ar\ archive\ import\ library*) # definitely import
49290b661123Smrg    win32_libid_type="x86 archive import"
49300b661123Smrg    ;;
49310b661123Smrg  *ar\ archive*) # could be an import, or static
4932880c7e28Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
49330b661123Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
4934880c7e28Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
49354f00d7e1Smrg      case $nm_interface in
49364f00d7e1Smrg      "MS dumpbin")
49374f00d7e1Smrg	if func_cygming_ms_implib_p "$1" ||
49384f00d7e1Smrg	   func_cygming_gnu_implib_p "$1"
49394f00d7e1Smrg	then
49404f00d7e1Smrg	  win32_nmres=import
49414f00d7e1Smrg	else
49424f00d7e1Smrg	  win32_nmres=
49434f00d7e1Smrg	fi
49444f00d7e1Smrg	;;
49454f00d7e1Smrg      *)
49464f00d7e1Smrg	func_to_tool_file "$1" func_convert_file_msys_to_w32
49474f00d7e1Smrg	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
49484f00d7e1Smrg	  $SED -n -e '
49490b661123Smrg	    1,100{
49500b661123Smrg		/ I /{
49514f00d7e1Smrg		    s|.*|import|
49520b661123Smrg		    p
49530b661123Smrg		    q
49540b661123Smrg		}
49550b661123Smrg	    }'`
49564f00d7e1Smrg	;;
49574f00d7e1Smrg      esac
49580b661123Smrg      case $win32_nmres in
49590b661123Smrg      import*)  win32_libid_type="x86 archive import";;
49600b661123Smrg      *)        win32_libid_type="x86 archive static";;
49610b661123Smrg      esac
49620b661123Smrg    fi
49630b661123Smrg    ;;
49640b661123Smrg  *DLL*)
49650b661123Smrg    win32_libid_type="x86 DLL"
49660b661123Smrg    ;;
49670b661123Smrg  *executable*) # but shell scripts are "executable" too...
49680b661123Smrg    case $win32_fileres in
49690b661123Smrg    *MS\ Windows\ PE\ Intel*)
49700b661123Smrg      win32_libid_type="x86 DLL"
49710b661123Smrg      ;;
49720b661123Smrg    esac
49730b661123Smrg    ;;
49740b661123Smrg  esac
49750b661123Smrg  $ECHO "$win32_libid_type"
49760b661123Smrg}
4977bdcaa8d0Smrg
4978880c7e28Smrg# func_cygming_dll_for_implib ARG
4979880c7e28Smrg#
4980880c7e28Smrg# Platform-specific function to extract the
4981880c7e28Smrg# name of the DLL associated with the specified
4982880c7e28Smrg# import library ARG.
4983880c7e28Smrg# Invoked by eval'ing the libtool variable
4984880c7e28Smrg#    $sharedlib_from_linklib_cmd
4985880c7e28Smrg# Result is available in the variable
4986880c7e28Smrg#    $sharedlib_from_linklib_result
4987880c7e28Smrgfunc_cygming_dll_for_implib ()
4988880c7e28Smrg{
49894f00d7e1Smrg  $debug_cmd
49904f00d7e1Smrg
4991880c7e28Smrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
4992880c7e28Smrg}
4993880c7e28Smrg
4994880c7e28Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
4995880c7e28Smrg#
4996880c7e28Smrg# The is the core of a fallback implementation of a
4997880c7e28Smrg# platform-specific function to extract the name of the
4998880c7e28Smrg# DLL associated with the specified import library LIBNAME.
4999880c7e28Smrg#
5000880c7e28Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending
5001880c7e28Smrg# on the platform and compiler that created the implib.
5002880c7e28Smrg#
5003880c7e28Smrg# Echos the name of the DLL associated with the
5004880c7e28Smrg# specified import library.
5005880c7e28Smrgfunc_cygming_dll_for_implib_fallback_core ()
5006880c7e28Smrg{
50074f00d7e1Smrg  $debug_cmd
50084f00d7e1Smrg
5009880c7e28Smrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
5010880c7e28Smrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
5011880c7e28Smrg    $SED '/^Contents of section '"$match_literal"':/{
5012880c7e28Smrg      # Place marker at beginning of archive member dllname section
5013880c7e28Smrg      s/.*/====MARK====/
5014880c7e28Smrg      p
5015880c7e28Smrg      d
5016880c7e28Smrg    }
5017880c7e28Smrg    # These lines can sometimes be longer than 43 characters, but
5018880c7e28Smrg    # are always uninteresting
5019880c7e28Smrg    /:[	 ]*file format pe[i]\{,1\}-/d
5020880c7e28Smrg    /^In archive [^:]*:/d
5021880c7e28Smrg    # Ensure marker is printed
5022880c7e28Smrg    /^====MARK====/p
5023880c7e28Smrg    # Remove all lines with less than 43 characters
5024880c7e28Smrg    /^.\{43\}/!d
5025880c7e28Smrg    # From remaining lines, remove first 43 characters
5026880c7e28Smrg    s/^.\{43\}//' |
5027880c7e28Smrg    $SED -n '
5028880c7e28Smrg      # Join marker and all lines until next marker into a single line
5029880c7e28Smrg      /^====MARK====/ b para
5030880c7e28Smrg      H
5031880c7e28Smrg      $ b para
5032880c7e28Smrg      b
5033880c7e28Smrg      :para
5034880c7e28Smrg      x
5035880c7e28Smrg      s/\n//g
5036880c7e28Smrg      # Remove the marker
5037880c7e28Smrg      s/^====MARK====//
5038880c7e28Smrg      # Remove trailing dots and whitespace
5039880c7e28Smrg      s/[\. \t]*$//
5040880c7e28Smrg      # Print
5041880c7e28Smrg      /./p' |
5042880c7e28Smrg    # we now have a list, one entry per line, of the stringified
5043880c7e28Smrg    # contents of the appropriate section of all members of the
50444f00d7e1Smrg    # archive that possess that section. Heuristic: eliminate
50454f00d7e1Smrg    # all those that have a first or second character that is
5046880c7e28Smrg    # a '.' (that is, objdump's representation of an unprintable
5047880c7e28Smrg    # character.) This should work for all archives with less than
5048880c7e28Smrg    # 0x302f exports -- but will fail for DLLs whose name actually
5049880c7e28Smrg    # begins with a literal '.' or a single character followed by
5050880c7e28Smrg    # a '.'.
5051880c7e28Smrg    #
5052880c7e28Smrg    # Of those that remain, print the first one.
5053880c7e28Smrg    $SED -e '/^\./d;/^.\./d;q'
5054880c7e28Smrg}
5055880c7e28Smrg
5056880c7e28Smrg# func_cygming_dll_for_implib_fallback ARG
5057880c7e28Smrg# Platform-specific function to extract the
5058880c7e28Smrg# name of the DLL associated with the specified
5059880c7e28Smrg# import library ARG.
5060880c7e28Smrg#
5061880c7e28Smrg# This fallback implementation is for use when $DLLTOOL
5062880c7e28Smrg# does not support the --identify-strict option.
5063880c7e28Smrg# Invoked by eval'ing the libtool variable
5064880c7e28Smrg#    $sharedlib_from_linklib_cmd
5065880c7e28Smrg# Result is available in the variable
5066880c7e28Smrg#    $sharedlib_from_linklib_result
5067880c7e28Smrgfunc_cygming_dll_for_implib_fallback ()
5068880c7e28Smrg{
50694f00d7e1Smrg  $debug_cmd
50704f00d7e1Smrg
50714f00d7e1Smrg  if func_cygming_gnu_implib_p "$1"; then
5072880c7e28Smrg    # binutils import library
5073880c7e28Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
50744f00d7e1Smrg  elif func_cygming_ms_implib_p "$1"; then
5075880c7e28Smrg    # ms-generated import library
5076880c7e28Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
5077880c7e28Smrg  else
5078880c7e28Smrg    # unknown
50794f00d7e1Smrg    sharedlib_from_linklib_result=
5080880c7e28Smrg  fi
5081880c7e28Smrg}
5082bdcaa8d0Smrg
5083bdcaa8d0Smrg
50840b661123Smrg# func_extract_an_archive dir oldlib
50850b661123Smrgfunc_extract_an_archive ()
50860b661123Smrg{
50874f00d7e1Smrg    $debug_cmd
50884f00d7e1Smrg
50894f00d7e1Smrg    f_ex_an_ar_dir=$1; shift
50904f00d7e1Smrg    f_ex_an_ar_oldlib=$1
50914f00d7e1Smrg    if test yes = "$lock_old_archive_extraction"; then
5092880c7e28Smrg      lockfile=$f_ex_an_ar_oldlib.lock
5093880c7e28Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
5094880c7e28Smrg	func_echo "Waiting for $lockfile to be removed"
5095880c7e28Smrg	sleep 2
5096880c7e28Smrg      done
5097880c7e28Smrg    fi
5098880c7e28Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
5099880c7e28Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
51004f00d7e1Smrg    if test yes = "$lock_old_archive_extraction"; then
5101880c7e28Smrg      $opt_dry_run || rm -f "$lockfile"
5102880c7e28Smrg    fi
51030b661123Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
51040b661123Smrg     :
51050b661123Smrg    else
51060b661123Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
51070b661123Smrg    fi
51080b661123Smrg}
5109bdcaa8d0Smrg
5110bdcaa8d0Smrg
51110b661123Smrg# func_extract_archives gentop oldlib ...
51120b661123Smrgfunc_extract_archives ()
51130b661123Smrg{
51144f00d7e1Smrg    $debug_cmd
51154f00d7e1Smrg
51164f00d7e1Smrg    my_gentop=$1; shift
51170b661123Smrg    my_oldlibs=${1+"$@"}
51184f00d7e1Smrg    my_oldobjs=
51194f00d7e1Smrg    my_xlib=
51204f00d7e1Smrg    my_xabs=
51214f00d7e1Smrg    my_xdir=
5122bdcaa8d0Smrg
51230b661123Smrg    for my_xlib in $my_oldlibs; do
51240b661123Smrg      # Extract the objects.
51250b661123Smrg      case $my_xlib in
51264f00d7e1Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
51270b661123Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
51280b661123Smrg      esac
51290b661123Smrg      func_basename "$my_xlib"
51304f00d7e1Smrg      my_xlib=$func_basename_result
51310b661123Smrg      my_xlib_u=$my_xlib
51320b661123Smrg      while :; do
51330b661123Smrg        case " $extracted_archives " in
51340b661123Smrg	*" $my_xlib_u "*)
51350b661123Smrg	  func_arith $extracted_serial + 1
51360b661123Smrg	  extracted_serial=$func_arith_result
51370b661123Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
51380b661123Smrg	*) break ;;
51390b661123Smrg	esac
51400b661123Smrg      done
51410b661123Smrg      extracted_archives="$extracted_archives $my_xlib_u"
51424f00d7e1Smrg      my_xdir=$my_gentop/$my_xlib_u
5143bdcaa8d0Smrg
51440b661123Smrg      func_mkdir_p "$my_xdir"
5145bdcaa8d0Smrg
51460b661123Smrg      case $host in
51470b661123Smrg      *-darwin*)
51480b661123Smrg	func_verbose "Extracting $my_xabs"
51490b661123Smrg	# Do not bother doing anything if just a dry run
51500b661123Smrg	$opt_dry_run || {
51510b661123Smrg	  darwin_orig_dir=`pwd`
51520b661123Smrg	  cd $my_xdir || exit $?
51530b661123Smrg	  darwin_archive=$my_xabs
51540b661123Smrg	  darwin_curdir=`pwd`
51554f00d7e1Smrg	  func_basename "$darwin_archive"
51564f00d7e1Smrg	  darwin_base_archive=$func_basename_result
51570b661123Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
51580b661123Smrg	  if test -n "$darwin_arches"; then
51590b661123Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
51600b661123Smrg	    darwin_arch=
51610b661123Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
51624f00d7e1Smrg	    for darwin_arch in  $darwin_arches; do
51634f00d7e1Smrg	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
51644f00d7e1Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
51654f00d7e1Smrg	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
51664f00d7e1Smrg	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
51670b661123Smrg	      cd "$darwin_curdir"
51684f00d7e1Smrg	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
51690b661123Smrg	    done # $darwin_arches
51700b661123Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
51714f00d7e1Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
51720b661123Smrg	    darwin_file=
51730b661123Smrg	    darwin_files=
51740b661123Smrg	    for darwin_file in $darwin_filelist; do
5175880c7e28Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
51760b661123Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
51770b661123Smrg	    done # $darwin_filelist
51780b661123Smrg	    $RM -rf unfat-$$
51790b661123Smrg	    cd "$darwin_orig_dir"
518096ce994aSmrg	  else
51810b661123Smrg	    cd $darwin_orig_dir
51820b661123Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
51830b661123Smrg	  fi # $darwin_arches
51840b661123Smrg	} # !$opt_dry_run
51850b661123Smrg	;;
51860b661123Smrg      *)
51870b661123Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
51880b661123Smrg	;;
51890b661123Smrg      esac
5190880c7e28Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
51910b661123Smrg    done
5192bdcaa8d0Smrg
51934f00d7e1Smrg    func_extract_archives_result=$my_oldobjs
51940b661123Smrg}
5195bdcaa8d0Smrg
5196bdcaa8d0Smrg
5197880c7e28Smrg# func_emit_wrapper [arg=no]
5198880c7e28Smrg#
5199880c7e28Smrg# Emit a libtool wrapper script on stdout.
5200880c7e28Smrg# Don't directly open a file because we may want to
5201880c7e28Smrg# incorporate the script contents within a cygwin/mingw
5202880c7e28Smrg# wrapper executable.  Must ONLY be called from within
5203880c7e28Smrg# func_mode_link because it depends on a number of variables
5204880c7e28Smrg# set therein.
52050b661123Smrg#
5206880c7e28Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
5207880c7e28Smrg# variable will take.  If 'yes', then the emitted script
52084f00d7e1Smrg# will assume that the directory where it is stored is
5209880c7e28Smrg# the $objdir directory.  This is a cygwin/mingw-specific
5210880c7e28Smrg# behavior.
5211880c7e28Smrgfunc_emit_wrapper ()
52120b661123Smrg{
5213880c7e28Smrg	func_emit_wrapper_arg1=${1-no}
521496ce994aSmrg
52150b661123Smrg	$ECHO "\
52160b661123Smrg#! $SHELL
521772313efbSmrg
52180b661123Smrg# $output - temporary wrapper script for $objdir/$outputname
52194f00d7e1Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
52200b661123Smrg#
52210b661123Smrg# The $output program cannot be directly executed until all the libtool
52220b661123Smrg# libraries that it depends on are installed.
52230b661123Smrg#
52240b661123Smrg# This wrapper script should never be moved out of the build directory.
52250b661123Smrg# If it is, it will not operate correctly.
522672313efbSmrg
52270b661123Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
52280b661123Smrg# metacharacters that are still active within double-quoted strings.
52290b661123Smrgsed_quote_subst='$sed_quote_subst'
5230bdcaa8d0Smrg
52310b661123Smrg# Be Bourne compatible
52320b661123Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
52330b661123Smrg  emulate sh
52340b661123Smrg  NULLCMD=:
52350b661123Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
52360b661123Smrg  # is contrary to our usage.  Disable this feature.
52370b661123Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
52380b661123Smrg  setopt NO_GLOB_SUBST
52390b661123Smrgelse
52400b661123Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
52410b661123Smrgfi
52420b661123SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
52430b661123SmrgDUALCASE=1; export DUALCASE # for MKS sh
5244bdcaa8d0Smrg
52450b661123Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
52460b661123Smrg# if CDPATH is set.
52470b661123Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5248bdcaa8d0Smrg
52490b661123Smrgrelink_command=\"$relink_command\"
5250bdcaa8d0Smrg
52510b661123Smrg# This environment variable determines our operation mode.
52520b661123Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
52530b661123Smrg  # install mode needs the following variables:
52540b661123Smrg  generated_by_libtool_version='$macro_version'
52550b661123Smrg  notinst_deplibs='$notinst_deplibs'
52560b661123Smrgelse
52570b661123Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
52580b661123Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
5259880c7e28Smrg    file=\"\$0\""
5260880c7e28Smrg
5261880c7e28Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
5262880c7e28Smrg    $ECHO "\
5263880c7e28Smrg
5264880c7e28Smrg# A function that is used when there is no print builtin or printf.
5265880c7e28Smrgfunc_fallback_echo ()
5266880c7e28Smrg{
5267880c7e28Smrg  eval 'cat <<_LTECHO_EOF
5268880c7e28Smrg\$1
5269880c7e28Smrg_LTECHO_EOF'
5270880c7e28Smrg}
5271880c7e28Smrg    ECHO=\"$qECHO\"
5272880c7e28Smrg  fi
5273880c7e28Smrg
5274880c7e28Smrg# Very basic option parsing. These options are (a) specific to
5275880c7e28Smrg# the libtool wrapper, (b) are identical between the wrapper
52764f00d7e1Smrg# /script/ and the wrapper /executable/ that is used only on
5277880c7e28Smrg# windows platforms, and (c) all begin with the string "--lt-"
52784f00d7e1Smrg# (application programs are unlikely to have options that match
5279880c7e28Smrg# this pattern).
5280880c7e28Smrg#
5281880c7e28Smrg# There are only two supported options: --lt-debug and
5282880c7e28Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
5283880c7e28Smrg#
5284880c7e28Smrg# The first argument to this parsing function should be the
5285880c7e28Smrg# script's $0 value, followed by "$@".
5286880c7e28Smrglt_option_debug=
5287880c7e28Smrgfunc_parse_lt_options ()
5288880c7e28Smrg{
5289880c7e28Smrg  lt_script_arg0=\$0
5290880c7e28Smrg  shift
5291880c7e28Smrg  for lt_opt
5292880c7e28Smrg  do
5293880c7e28Smrg    case \"\$lt_opt\" in
5294880c7e28Smrg    --lt-debug) lt_option_debug=1 ;;
5295880c7e28Smrg    --lt-dump-script)
5296880c7e28Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
5297880c7e28Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
5298880c7e28Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
5299880c7e28Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
5300880c7e28Smrg        exit 0
5301880c7e28Smrg      ;;
5302880c7e28Smrg    --lt-*)
5303880c7e28Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
5304880c7e28Smrg        exit 1
5305880c7e28Smrg      ;;
5306880c7e28Smrg    esac
5307880c7e28Smrg  done
5308880c7e28Smrg
5309880c7e28Smrg  # Print the debug banner immediately:
5310880c7e28Smrg  if test -n \"\$lt_option_debug\"; then
53114f00d7e1Smrg    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
5312880c7e28Smrg  fi
5313880c7e28Smrg}
5314880c7e28Smrg
5315880c7e28Smrg# Used when --lt-debug. Prints its arguments to stdout
5316880c7e28Smrg# (redirection is the responsibility of the caller)
5317880c7e28Smrgfunc_lt_dump_args ()
5318880c7e28Smrg{
5319880c7e28Smrg  lt_dump_args_N=1;
5320880c7e28Smrg  for lt_arg
5321880c7e28Smrg  do
53224f00d7e1Smrg    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
5323880c7e28Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
5324880c7e28Smrg  done
5325880c7e28Smrg}
5326880c7e28Smrg
5327880c7e28Smrg# Core function for launching the target application
5328880c7e28Smrgfunc_exec_program_core ()
5329880c7e28Smrg{
53300b661123Smrg"
5331880c7e28Smrg  case $host in
5332880c7e28Smrg  # Backslashes separate directories on plain windows
5333880c7e28Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
5334880c7e28Smrg    $ECHO "\
5335880c7e28Smrg      if test -n \"\$lt_option_debug\"; then
53364f00d7e1Smrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
5337880c7e28Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5338880c7e28Smrg      fi
5339880c7e28Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5340880c7e28Smrg"
5341880c7e28Smrg    ;;
5342880c7e28Smrg
5343880c7e28Smrg  *)
5344880c7e28Smrg    $ECHO "\
5345880c7e28Smrg      if test -n \"\$lt_option_debug\"; then
53464f00d7e1Smrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
5347880c7e28Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5348880c7e28Smrg      fi
5349880c7e28Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
5350880c7e28Smrg"
5351880c7e28Smrg    ;;
5352880c7e28Smrg  esac
5353880c7e28Smrg  $ECHO "\
5354880c7e28Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
5355880c7e28Smrg      exit 1
5356880c7e28Smrg}
5357880c7e28Smrg
5358880c7e28Smrg# A function to encapsulate launching the target application
5359880c7e28Smrg# Strips options in the --lt-* namespace from \$@ and
5360880c7e28Smrg# launches target application with the remaining arguments.
5361880c7e28Smrgfunc_exec_program ()
5362880c7e28Smrg{
5363880c7e28Smrg  case \" \$* \" in
5364880c7e28Smrg  *\\ --lt-*)
5365880c7e28Smrg    for lt_wr_arg
5366880c7e28Smrg    do
5367880c7e28Smrg      case \$lt_wr_arg in
5368880c7e28Smrg      --lt-*) ;;
5369880c7e28Smrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
5370880c7e28Smrg      esac
5371880c7e28Smrg      shift
5372880c7e28Smrg    done ;;
5373880c7e28Smrg  esac
5374880c7e28Smrg  func_exec_program_core \${1+\"\$@\"}
5375880c7e28Smrg}
5376880c7e28Smrg
5377880c7e28Smrg  # Parse options
5378880c7e28Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
5379bdcaa8d0Smrg
53800b661123Smrg  # Find the directory that this script lives in.
5381880c7e28Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
53820b661123Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
5383bdcaa8d0Smrg
53840b661123Smrg  # Follow symbolic links until we get to the real thisdir.
5385880c7e28Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
53860b661123Smrg  while test -n \"\$file\"; do
5387880c7e28Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
5388bdcaa8d0Smrg
53890b661123Smrg    # If there was a directory component, then change thisdir.
53900b661123Smrg    if test \"x\$destdir\" != \"x\$file\"; then
53910b661123Smrg      case \"\$destdir\" in
53920b661123Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
53930b661123Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
539496ce994aSmrg      esac
53950b661123Smrg    fi
539672313efbSmrg
5397880c7e28Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
5398880c7e28Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
53990b661123Smrg  done
540072313efbSmrg
54010b661123Smrg  # Usually 'no', except on cygwin/mingw when embedded into
54020b661123Smrg  # the cwrapper.
5403880c7e28Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
54040b661123Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
54050b661123Smrg    # special case for '.'
54060b661123Smrg    if test \"\$thisdir\" = \".\"; then
54070b661123Smrg      thisdir=\`pwd\`
54080b661123Smrg    fi
54090b661123Smrg    # remove .libs from thisdir
54100b661123Smrg    case \"\$thisdir\" in
5411880c7e28Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
54120b661123Smrg    $objdir )   thisdir=. ;;
54130b661123Smrg    esac
54140b661123Smrg  fi
54150b661123Smrg
54160b661123Smrg  # Try to get the absolute directory name.
54170b661123Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
54180b661123Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
54190b661123Smrg"
54200b661123Smrg
54214f00d7e1Smrg	if test yes = "$fast_install"; then
54220b661123Smrg	  $ECHO "\
54230b661123Smrg  program=lt-'$outputname'$exeext
54240b661123Smrg  progdir=\"\$thisdir/$objdir\"
54250b661123Smrg
54260b661123Smrg  if test ! -f \"\$progdir/\$program\" ||
54274f00d7e1Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
54280b661123Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
54290b661123Smrg
54300b661123Smrg    file=\"\$\$-\$program\"
54310b661123Smrg
54320b661123Smrg    if test ! -d \"\$progdir\"; then
54330b661123Smrg      $MKDIR \"\$progdir\"
54340b661123Smrg    else
54350b661123Smrg      $RM \"\$progdir/\$file\"
54360b661123Smrg    fi"
54370b661123Smrg
54380b661123Smrg	  $ECHO "\
54390b661123Smrg
54400b661123Smrg    # relink executable if necessary
54410b661123Smrg    if test -n \"\$relink_command\"; then
54420b661123Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
54430b661123Smrg      else
54444f00d7e1Smrg	\$ECHO \"\$relink_command_output\" >&2
54450b661123Smrg	$RM \"\$progdir/\$file\"
54460b661123Smrg	exit 1
544796ce994aSmrg      fi
54480b661123Smrg    fi
544972313efbSmrg
54500b661123Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
54510b661123Smrg    { $RM \"\$progdir/\$program\";
54520b661123Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
54530b661123Smrg    $RM \"\$progdir/\$file\"
54540b661123Smrg  fi"
54550b661123Smrg	else
54560b661123Smrg	  $ECHO "\
54570b661123Smrg  program='$outputname'
54580b661123Smrg  progdir=\"\$thisdir/$objdir\"
54590b661123Smrg"
546096ce994aSmrg	fi
546172313efbSmrg
54620b661123Smrg	$ECHO "\
546372313efbSmrg
54640b661123Smrg  if test -f \"\$progdir/\$program\"; then"
546572313efbSmrg
5466880c7e28Smrg	# fixup the dll searchpath if we need to.
5467880c7e28Smrg	#
5468880c7e28Smrg	# Fix the DLL searchpath if we need to.  Do this before prepending
5469880c7e28Smrg	# to shlibpath, because on Windows, both are PATH and uninstalled
5470880c7e28Smrg	# libraries must come first.
5471880c7e28Smrg	if test -n "$dllsearchpath"; then
5472880c7e28Smrg	  $ECHO "\
5473880c7e28Smrg    # Add the dll search path components to the executable PATH
5474880c7e28Smrg    PATH=$dllsearchpath:\$PATH
5475880c7e28Smrg"
5476880c7e28Smrg	fi
5477880c7e28Smrg
54780b661123Smrg	# Export our shlibpath_var if we have one.
54794f00d7e1Smrg	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
54800b661123Smrg	  $ECHO "\
54810b661123Smrg    # Add our own library path to $shlibpath_var
54820b661123Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
54830b661123Smrg
54840b661123Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
54850b661123Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
5486880c7e28Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
548772313efbSmrg
54880b661123Smrg    export $shlibpath_var
54890b661123Smrg"
549096ce994aSmrg	fi
549172313efbSmrg
54920b661123Smrg	$ECHO "\
54930b661123Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
54940b661123Smrg      # Run the actual program with our arguments.
5495880c7e28Smrg      func_exec_program \${1+\"\$@\"}
54960b661123Smrg    fi
54970b661123Smrg  else
54980b661123Smrg    # The program doesn't exist.
54994f00d7e1Smrg    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
55000b661123Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
5501880c7e28Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
55020b661123Smrg    exit 1
55030b661123Smrg  fi
55040b661123Smrgfi\
55050b661123Smrg"
55060b661123Smrg}
550772313efbSmrg
550872313efbSmrg
55090b661123Smrg# func_emit_cwrapperexe_src
55100b661123Smrg# emit the source code for a wrapper executable on stdout
55110b661123Smrg# Must ONLY be called from within func_mode_link because
55120b661123Smrg# it depends on a number of variable set therein.
55130b661123Smrgfunc_emit_cwrapperexe_src ()
55140b661123Smrg{
55150b661123Smrg	cat <<EOF
5516bdcaa8d0Smrg
55170b661123Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
55184f00d7e1Smrg   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5519bdcaa8d0Smrg
55200b661123Smrg   The $output program cannot be directly executed until all the libtool
55210b661123Smrg   libraries that it depends on are installed.
5522bdcaa8d0Smrg
55230b661123Smrg   This wrapper executable should never be moved out of the build directory.
55240b661123Smrg   If it is, it will not operate correctly.
55250b661123Smrg*/
55260b661123SmrgEOF
55270b661123Smrg	    cat <<"EOF"
5528880c7e28Smrg#ifdef _MSC_VER
5529880c7e28Smrg# define _CRT_SECURE_NO_DEPRECATE 1
5530880c7e28Smrg#endif
55310b661123Smrg#include <stdio.h>
55320b661123Smrg#include <stdlib.h>
55330b661123Smrg#ifdef _MSC_VER
55340b661123Smrg# include <direct.h>
55350b661123Smrg# include <process.h>
55360b661123Smrg# include <io.h>
55370b661123Smrg#else
55380b661123Smrg# include <unistd.h>
55390b661123Smrg# include <stdint.h>
55400b661123Smrg# ifdef __CYGWIN__
55410b661123Smrg#  include <io.h>
55420b661123Smrg# endif
55430b661123Smrg#endif
55440b661123Smrg#include <malloc.h>
55450b661123Smrg#include <stdarg.h>
55460b661123Smrg#include <assert.h>
55470b661123Smrg#include <string.h>
55480b661123Smrg#include <ctype.h>
55490b661123Smrg#include <errno.h>
55500b661123Smrg#include <fcntl.h>
55510b661123Smrg#include <sys/stat.h>
5552bdcaa8d0Smrg
55534f00d7e1Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
55544f00d7e1Smrg
5555880c7e28Smrg/* declarations of non-ANSI functions */
55564f00d7e1Smrg#if defined __MINGW32__
5557880c7e28Smrg# ifdef __STRICT_ANSI__
5558880c7e28Smrgint _putenv (const char *);
5559880c7e28Smrg# endif
55604f00d7e1Smrg#elif defined __CYGWIN__
5561880c7e28Smrg# ifdef __STRICT_ANSI__
5562880c7e28Smrgchar *realpath (const char *, char *);
5563880c7e28Smrgint putenv (char *);
5564880c7e28Smrgint setenv (const char *, const char *, int);
5565880c7e28Smrg# endif
55664f00d7e1Smrg/* #elif defined other_platform || defined ... */
5567880c7e28Smrg#endif
5568880c7e28Smrg
5569880c7e28Smrg/* portability defines, excluding path handling macros */
55704f00d7e1Smrg#if defined _MSC_VER
5571880c7e28Smrg# define setmode _setmode
5572880c7e28Smrg# define stat    _stat
5573880c7e28Smrg# define chmod   _chmod
5574880c7e28Smrg# define getcwd  _getcwd
5575880c7e28Smrg# define putenv  _putenv
5576880c7e28Smrg# define S_IXUSR _S_IEXEC
55774f00d7e1Smrg#elif defined __MINGW32__
5578880c7e28Smrg# define setmode _setmode
5579880c7e28Smrg# define stat    _stat
5580880c7e28Smrg# define chmod   _chmod
5581880c7e28Smrg# define getcwd  _getcwd
5582880c7e28Smrg# define putenv  _putenv
55834f00d7e1Smrg#elif defined __CYGWIN__
5584880c7e28Smrg# define HAVE_SETENV
5585880c7e28Smrg# define FOPEN_WB "wb"
55864f00d7e1Smrg/* #elif defined other platforms ... */
5587880c7e28Smrg#endif
5588880c7e28Smrg
55894f00d7e1Smrg#if defined PATH_MAX
55900b661123Smrg# define LT_PATHMAX PATH_MAX
55914f00d7e1Smrg#elif defined MAXPATHLEN
55920b661123Smrg# define LT_PATHMAX MAXPATHLEN
55930b661123Smrg#else
55940b661123Smrg# define LT_PATHMAX 1024
55950b661123Smrg#endif
5596bdcaa8d0Smrg
55970b661123Smrg#ifndef S_IXOTH
55980b661123Smrg# define S_IXOTH 0
55990b661123Smrg#endif
56000b661123Smrg#ifndef S_IXGRP
56010b661123Smrg# define S_IXGRP 0
56020b661123Smrg#endif
5603bdcaa8d0Smrg
5604880c7e28Smrg/* path handling portability macros */
56050b661123Smrg#ifndef DIR_SEPARATOR
56060b661123Smrg# define DIR_SEPARATOR '/'
56070b661123Smrg# define PATH_SEPARATOR ':'
56080b661123Smrg#endif
5609bdcaa8d0Smrg
56104f00d7e1Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
56114f00d7e1Smrg  defined __OS2__
56120b661123Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
56130b661123Smrg# define FOPEN_WB "wb"
56140b661123Smrg# ifndef DIR_SEPARATOR_2
56150b661123Smrg#  define DIR_SEPARATOR_2 '\\'
56160b661123Smrg# endif
56170b661123Smrg# ifndef PATH_SEPARATOR_2
56180b661123Smrg#  define PATH_SEPARATOR_2 ';'
56190b661123Smrg# endif
56200b661123Smrg#endif
5621bdcaa8d0Smrg
56220b661123Smrg#ifndef DIR_SEPARATOR_2
56230b661123Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
56240b661123Smrg#else /* DIR_SEPARATOR_2 */
56250b661123Smrg# define IS_DIR_SEPARATOR(ch) \
56260b661123Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
56270b661123Smrg#endif /* DIR_SEPARATOR_2 */
5628bdcaa8d0Smrg
56290b661123Smrg#ifndef PATH_SEPARATOR_2
56300b661123Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
56310b661123Smrg#else /* PATH_SEPARATOR_2 */
56320b661123Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
56330b661123Smrg#endif /* PATH_SEPARATOR_2 */
5634bdcaa8d0Smrg
56350b661123Smrg#ifndef FOPEN_WB
56360b661123Smrg# define FOPEN_WB "w"
56370b661123Smrg#endif
56380b661123Smrg#ifndef _O_BINARY
56390b661123Smrg# define _O_BINARY 0
56400b661123Smrg#endif
5641bdcaa8d0Smrg
56420b661123Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
56430b661123Smrg#define XFREE(stale) do { \
56444f00d7e1Smrg  if (stale) { free (stale); stale = 0; } \
56450b661123Smrg} while (0)
5646bdcaa8d0Smrg
56474f00d7e1Smrg#if defined LT_DEBUGWRAPPER
5648880c7e28Smrgstatic int lt_debug = 1;
56490b661123Smrg#else
5650880c7e28Smrgstatic int lt_debug = 0;
56510b661123Smrg#endif
5652bdcaa8d0Smrg
5653880c7e28Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
5654bdcaa8d0Smrg
56550b661123Smrgvoid *xmalloc (size_t num);
56560b661123Smrgchar *xstrdup (const char *string);
56570b661123Smrgconst char *base_name (const char *name);
56580b661123Smrgchar *find_executable (const char *wrapper);
56590b661123Smrgchar *chase_symlinks (const char *pathspec);
56600b661123Smrgint make_executable (const char *path);
56610b661123Smrgint check_executable (const char *path);
56620b661123Smrgchar *strendzap (char *str, const char *pat);
5663880c7e28Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
5664880c7e28Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
5665880c7e28Smrgstatic const char *nonnull (const char *s);
5666880c7e28Smrgstatic const char *nonempty (const char *s);
56670b661123Smrgvoid lt_setenv (const char *name, const char *value);
56680b661123Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
56690b661123Smrgvoid lt_update_exe_path (const char *name, const char *value);
56700b661123Smrgvoid lt_update_lib_path (const char *name, const char *value);
5671880c7e28Smrgchar **prepare_spawn (char **argv);
5672880c7e28Smrgvoid lt_dump_script (FILE *f);
56730b661123SmrgEOF
56740b661123Smrg
56750b661123Smrg	    cat <<EOF
56764f00d7e1Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
56774f00d7e1Smrg# define externally_visible volatile
56784f00d7e1Smrg#else
56794f00d7e1Smrg# define externally_visible __attribute__((externally_visible)) volatile
56804f00d7e1Smrg#endif
56814f00d7e1Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe";
56820b661123Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
56830b661123SmrgEOF
5684bdcaa8d0Smrg
56854f00d7e1Smrg	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5686880c7e28Smrg              func_to_host_path "$temp_rpath"
56870b661123Smrg	      cat <<EOF
5688880c7e28Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
56890b661123SmrgEOF
56900b661123Smrg	    else
56910b661123Smrg	      cat <<"EOF"
56920b661123Smrgconst char * LIB_PATH_VALUE   = "";
56930b661123SmrgEOF
569496ce994aSmrg	    fi
5695bdcaa8d0Smrg
56960b661123Smrg	    if test -n "$dllsearchpath"; then
5697880c7e28Smrg              func_to_host_path "$dllsearchpath:"
56980b661123Smrg	      cat <<EOF
56990b661123Smrgconst char * EXE_PATH_VARNAME = "PATH";
5700880c7e28Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
570196ce994aSmrgEOF
570296ce994aSmrg	    else
57030b661123Smrg	      cat <<"EOF"
57040b661123Smrgconst char * EXE_PATH_VARNAME = "";
57050b661123Smrgconst char * EXE_PATH_VALUE   = "";
57060b661123SmrgEOF
570796ce994aSmrg	    fi
57080b661123Smrg
57094f00d7e1Smrg	    if test yes = "$fast_install"; then
57100b661123Smrg	      cat <<EOF
57110b661123Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
57120b661123SmrgEOF
571396ce994aSmrg	    else
57140b661123Smrg	      cat <<EOF
57150b661123Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
57160b661123SmrgEOF
571796ce994aSmrg	    fi
5718bdcaa8d0Smrg
5719bdcaa8d0Smrg
57200b661123Smrg	    cat <<"EOF"
5721bdcaa8d0Smrg
57220b661123Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
5723bdcaa8d0Smrg
57240b661123Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
57250b661123Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
5726880c7e28Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
5727bdcaa8d0Smrg
57280b661123Smrgint
57290b661123Smrgmain (int argc, char *argv[])
57300b661123Smrg{
57310b661123Smrg  char **newargz;
57320b661123Smrg  int  newargc;
57330b661123Smrg  char *tmp_pathspec;
57340b661123Smrg  char *actual_cwrapper_path;
57350b661123Smrg  char *actual_cwrapper_name;
57360b661123Smrg  char *target_name;
57370b661123Smrg  char *lt_argv_zero;
57384f00d7e1Smrg  int rval = 127;
5739bdcaa8d0Smrg
57400b661123Smrg  int i;
5741bdcaa8d0Smrg
57420b661123Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
57434f00d7e1Smrg  newargz = XMALLOC (char *, (size_t) argc + 1);
5744bdcaa8d0Smrg
5745880c7e28Smrg  /* very simple arg parsing; don't want to rely on getopt
5746880c7e28Smrg   * also, copy all non cwrapper options to newargz, except
5747880c7e28Smrg   * argz[0], which is handled differently
5748880c7e28Smrg   */
5749880c7e28Smrg  newargc=0;
57500b661123Smrg  for (i = 1; i < argc; i++)
57510b661123Smrg    {
57524f00d7e1Smrg      if (STREQ (argv[i], dumpscript_opt))
57530b661123Smrg	{
57540b661123SmrgEOF
57554f00d7e1Smrg	    case $host in
57560b661123Smrg	      *mingw* | *cygwin* )
57570b661123Smrg		# make stdout use "unix" line endings
57580b661123Smrg		echo "          setmode(1,_O_BINARY);"
57590b661123Smrg		;;
57600b661123Smrg	      esac
5761bdcaa8d0Smrg
57620b661123Smrg	    cat <<"EOF"
5763880c7e28Smrg	  lt_dump_script (stdout);
57640b661123Smrg	  return 0;
57650b661123Smrg	}
57664f00d7e1Smrg      if (STREQ (argv[i], debug_opt))
5767880c7e28Smrg	{
5768880c7e28Smrg          lt_debug = 1;
5769880c7e28Smrg          continue;
5770880c7e28Smrg	}
57714f00d7e1Smrg      if (STREQ (argv[i], ltwrapper_option_prefix))
5772880c7e28Smrg        {
5773880c7e28Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
5774880c7e28Smrg             namespace, but it is not one of the ones we know about and
5775880c7e28Smrg             have already dealt with, above (inluding dump-script), then
5776880c7e28Smrg             report an error. Otherwise, targets might begin to believe
5777880c7e28Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
5778880c7e28Smrg             namespace. The first time any user complains about this, we'll
5779880c7e28Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
5780880c7e28Smrg             or a configure.ac-settable value.
5781880c7e28Smrg           */
5782880c7e28Smrg          lt_fatal (__FILE__, __LINE__,
5783880c7e28Smrg		    "unrecognized %s option: '%s'",
5784880c7e28Smrg                    ltwrapper_option_prefix, argv[i]);
5785880c7e28Smrg        }
5786880c7e28Smrg      /* otherwise ... */
5787880c7e28Smrg      newargz[++newargc] = xstrdup (argv[i]);
57880b661123Smrg    }
5789880c7e28Smrg  newargz[++newargc] = NULL;
5790880c7e28Smrg
5791880c7e28SmrgEOF
5792880c7e28Smrg	    cat <<EOF
5793880c7e28Smrg  /* The GNU banner must be the first non-error debug message */
57944f00d7e1Smrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
5795880c7e28SmrgEOF
5796880c7e28Smrg	    cat <<"EOF"
5797880c7e28Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
5798880c7e28Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
5799bdcaa8d0Smrg
58000b661123Smrg  tmp_pathspec = find_executable (argv[0]);
58010b661123Smrg  if (tmp_pathspec == NULL)
5802880c7e28Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
5803880c7e28Smrg  lt_debugprintf (__FILE__, __LINE__,
5804880c7e28Smrg                  "(main) found exe (before symlink chase) at: %s\n",
5805880c7e28Smrg		  tmp_pathspec);
58060b661123Smrg
58070b661123Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
5808880c7e28Smrg  lt_debugprintf (__FILE__, __LINE__,
5809880c7e28Smrg                  "(main) found exe (after symlink chase) at: %s\n",
5810880c7e28Smrg		  actual_cwrapper_path);
58110b661123Smrg  XFREE (tmp_pathspec);
58120b661123Smrg
5813880c7e28Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
58140b661123Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
58150b661123Smrg
58160b661123Smrg  /* wrapper name transforms */
58170b661123Smrg  strendzap (actual_cwrapper_name, ".exe");
58180b661123Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
58190b661123Smrg  XFREE (actual_cwrapper_name);
58200b661123Smrg  actual_cwrapper_name = tmp_pathspec;
58210b661123Smrg  tmp_pathspec = 0;
58220b661123Smrg
58230b661123Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
58240b661123Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
58250b661123Smrg  strendzap (target_name, ".exe");
58260b661123Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
58270b661123Smrg  XFREE (target_name);
58280b661123Smrg  target_name = tmp_pathspec;
58290b661123Smrg  tmp_pathspec = 0;
58300b661123Smrg
5831880c7e28Smrg  lt_debugprintf (__FILE__, __LINE__,
5832880c7e28Smrg		  "(main) libtool target name: %s\n",
5833880c7e28Smrg		  target_name);
58340b661123SmrgEOF
5835bdcaa8d0Smrg
58360b661123Smrg	    cat <<EOF
58370b661123Smrg  newargz[0] =
58380b661123Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
58390b661123Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
58400b661123Smrg  strcpy (newargz[0], actual_cwrapper_path);
58410b661123Smrg  strcat (newargz[0], "$objdir");
58420b661123Smrg  strcat (newargz[0], "/");
58430b661123SmrgEOF
5844bdcaa8d0Smrg
58450b661123Smrg	    cat <<"EOF"
58460b661123Smrg  /* stop here, and copy so we don't have to do this twice */
58470b661123Smrg  tmp_pathspec = xstrdup (newargz[0]);
5848bdcaa8d0Smrg
58490b661123Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
58500b661123Smrg  strcat (newargz[0], actual_cwrapper_name);
5851bdcaa8d0Smrg
58520b661123Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
58530b661123Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
58540b661123Smrg  XFREE (tmp_pathspec);
58550b661123Smrg  tmp_pathspec = NULL;
58560b661123SmrgEOF
5857bdcaa8d0Smrg
58580b661123Smrg	    case $host_os in
58590b661123Smrg	      mingw*)
58600b661123Smrg	    cat <<"EOF"
58610b661123Smrg  {
58620b661123Smrg    char* p;
58630b661123Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
58640b661123Smrg      {
58650b661123Smrg	*p = '/';
58660b661123Smrg      }
58670b661123Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
58680b661123Smrg      {
58690b661123Smrg	*p = '/';
58700b661123Smrg      }
58710b661123Smrg  }
58720b661123SmrgEOF
58730b661123Smrg	    ;;
58740b661123Smrg	    esac
5875bdcaa8d0Smrg
58760b661123Smrg	    cat <<"EOF"
58770b661123Smrg  XFREE (target_name);
58780b661123Smrg  XFREE (actual_cwrapper_path);
58790b661123Smrg  XFREE (actual_cwrapper_name);
5880bdcaa8d0Smrg
58810b661123Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
58820b661123Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
5883880c7e28Smrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
5884880c7e28Smrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
5885880c7e28Smrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
5886880c7e28Smrg     libraries must come first. */
58870b661123Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
5888880c7e28Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
5889bdcaa8d0Smrg
5890880c7e28Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
5891880c7e28Smrg		  nonnull (lt_argv_zero));
58920b661123Smrg  for (i = 0; i < newargc; i++)
58930b661123Smrg    {
5894880c7e28Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
5895880c7e28Smrg		      i, nonnull (newargz[i]));
58960b661123Smrg    }
5897bdcaa8d0Smrg
58980b661123SmrgEOF
5899bdcaa8d0Smrg
59000b661123Smrg	    case $host_os in
59010b661123Smrg	      mingw*)
59020b661123Smrg		cat <<"EOF"
59030b661123Smrg  /* execv doesn't actually work on mingw as expected on unix */
5904880c7e28Smrg  newargz = prepare_spawn (newargz);
59054f00d7e1Smrg  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
59060b661123Smrg  if (rval == -1)
59070b661123Smrg    {
59080b661123Smrg      /* failed to start process */
5909880c7e28Smrg      lt_debugprintf (__FILE__, __LINE__,
5910880c7e28Smrg		      "(main) failed to launch target \"%s\": %s\n",
5911880c7e28Smrg		      lt_argv_zero, nonnull (strerror (errno)));
59120b661123Smrg      return 127;
59130b661123Smrg    }
59140b661123Smrg  return rval;
59150b661123SmrgEOF
59160b661123Smrg		;;
59170b661123Smrg	      *)
59180b661123Smrg		cat <<"EOF"
59190b661123Smrg  execv (lt_argv_zero, newargz);
59200b661123Smrg  return rval; /* =127, but avoids unused variable warning */
59210b661123SmrgEOF
59220b661123Smrg		;;
59230b661123Smrg	    esac
5924bdcaa8d0Smrg
59250b661123Smrg	    cat <<"EOF"
59260b661123Smrg}
5927bdcaa8d0Smrg
59280b661123Smrgvoid *
59290b661123Smrgxmalloc (size_t num)
59300b661123Smrg{
59310b661123Smrg  void *p = (void *) malloc (num);
59320b661123Smrg  if (!p)
5933880c7e28Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
5934bdcaa8d0Smrg
59350b661123Smrg  return p;
59360b661123Smrg}
5937bdcaa8d0Smrg
59380b661123Smrgchar *
59390b661123Smrgxstrdup (const char *string)
59400b661123Smrg{
59410b661123Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
59420b661123Smrg			  string) : NULL;
59430b661123Smrg}
5944bdcaa8d0Smrg
59450b661123Smrgconst char *
59460b661123Smrgbase_name (const char *name)
59470b661123Smrg{
59480b661123Smrg  const char *base;
594996ce994aSmrg
59504f00d7e1Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
59510b661123Smrg  /* Skip over the disk name in MSDOS pathnames. */
59520b661123Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
59530b661123Smrg    name += 2;
59540b661123Smrg#endif
595596ce994aSmrg
59560b661123Smrg  for (base = name; *name; name++)
59570b661123Smrg    if (IS_DIR_SEPARATOR (*name))
59580b661123Smrg      base = name + 1;
59590b661123Smrg  return base;
59600b661123Smrg}
596196ce994aSmrg
59620b661123Smrgint
59630b661123Smrgcheck_executable (const char *path)
59640b661123Smrg{
59650b661123Smrg  struct stat st;
596696ce994aSmrg
5967880c7e28Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
5968880c7e28Smrg                  nonempty (path));
59690b661123Smrg  if ((!path) || (!*path))
59700b661123Smrg    return 0;
597196ce994aSmrg
59720b661123Smrg  if ((stat (path, &st) >= 0)
59730b661123Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
59740b661123Smrg    return 1;
59750b661123Smrg  else
59760b661123Smrg    return 0;
59770b661123Smrg}
5978bdcaa8d0Smrg
59790b661123Smrgint
59800b661123Smrgmake_executable (const char *path)
59810b661123Smrg{
59820b661123Smrg  int rval = 0;
59830b661123Smrg  struct stat st;
5984bdcaa8d0Smrg
5985880c7e28Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
5986880c7e28Smrg                  nonempty (path));
59870b661123Smrg  if ((!path) || (!*path))
59880b661123Smrg    return 0;
5989bdcaa8d0Smrg
59900b661123Smrg  if (stat (path, &st) >= 0)
59910b661123Smrg    {
59920b661123Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
59930b661123Smrg    }
59940b661123Smrg  return rval;
59950b661123Smrg}
599696ce994aSmrg
59970b661123Smrg/* Searches for the full path of the wrapper.  Returns
59980b661123Smrg   newly allocated full path name if found, NULL otherwise
59990b661123Smrg   Does not chase symlinks, even on platforms that support them.
60000b661123Smrg*/
60010b661123Smrgchar *
60020b661123Smrgfind_executable (const char *wrapper)
60030b661123Smrg{
60040b661123Smrg  int has_slash = 0;
60050b661123Smrg  const char *p;
60060b661123Smrg  const char *p_next;
60070b661123Smrg  /* static buffer for getcwd */
60080b661123Smrg  char tmp[LT_PATHMAX + 1];
60094f00d7e1Smrg  size_t tmp_len;
60100b661123Smrg  char *concat_name;
601196ce994aSmrg
6012880c7e28Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
6013880c7e28Smrg                  nonempty (wrapper));
601496ce994aSmrg
60150b661123Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
60160b661123Smrg    return NULL;
601796ce994aSmrg
60180b661123Smrg  /* Absolute path? */
60194f00d7e1Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
60200b661123Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
60210b661123Smrg    {
60220b661123Smrg      concat_name = xstrdup (wrapper);
60230b661123Smrg      if (check_executable (concat_name))
60240b661123Smrg	return concat_name;
60250b661123Smrg      XFREE (concat_name);
60260b661123Smrg    }
60270b661123Smrg  else
60280b661123Smrg    {
60290b661123Smrg#endif
60300b661123Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
60310b661123Smrg	{
60320b661123Smrg	  concat_name = xstrdup (wrapper);
60330b661123Smrg	  if (check_executable (concat_name))
60340b661123Smrg	    return concat_name;
60350b661123Smrg	  XFREE (concat_name);
60360b661123Smrg	}
60374f00d7e1Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
60380b661123Smrg    }
60390b661123Smrg#endif
6040bdcaa8d0Smrg
60410b661123Smrg  for (p = wrapper; *p; p++)
60420b661123Smrg    if (*p == '/')
60430b661123Smrg      {
60440b661123Smrg	has_slash = 1;
60450b661123Smrg	break;
60460b661123Smrg      }
60470b661123Smrg  if (!has_slash)
60480b661123Smrg    {
60490b661123Smrg      /* no slashes; search PATH */
60500b661123Smrg      const char *path = getenv ("PATH");
60510b661123Smrg      if (path != NULL)
60520b661123Smrg	{
60530b661123Smrg	  for (p = path; *p; p = p_next)
60540b661123Smrg	    {
60550b661123Smrg	      const char *q;
60560b661123Smrg	      size_t p_len;
60570b661123Smrg	      for (q = p; *q; q++)
60580b661123Smrg		if (IS_PATH_SEPARATOR (*q))
60590b661123Smrg		  break;
60604f00d7e1Smrg	      p_len = (size_t) (q - p);
60610b661123Smrg	      p_next = (*q == '\0' ? q : q + 1);
60620b661123Smrg	      if (p_len == 0)
60630b661123Smrg		{
60640b661123Smrg		  /* empty path: current directory */
60650b661123Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
6066880c7e28Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6067880c7e28Smrg                              nonnull (strerror (errno)));
60680b661123Smrg		  tmp_len = strlen (tmp);
60690b661123Smrg		  concat_name =
60700b661123Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
60710b661123Smrg		  memcpy (concat_name, tmp, tmp_len);
60720b661123Smrg		  concat_name[tmp_len] = '/';
60730b661123Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
60740b661123Smrg		}
60750b661123Smrg	      else
60760b661123Smrg		{
60770b661123Smrg		  concat_name =
60780b661123Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
60790b661123Smrg		  memcpy (concat_name, p, p_len);
60800b661123Smrg		  concat_name[p_len] = '/';
60810b661123Smrg		  strcpy (concat_name + p_len + 1, wrapper);
60820b661123Smrg		}
60830b661123Smrg	      if (check_executable (concat_name))
60840b661123Smrg		return concat_name;
60850b661123Smrg	      XFREE (concat_name);
60860b661123Smrg	    }
60870b661123Smrg	}
60880b661123Smrg      /* not found in PATH; assume curdir */
60890b661123Smrg    }
60900b661123Smrg  /* Relative path | not found in path: prepend cwd */
60910b661123Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
6092880c7e28Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6093880c7e28Smrg              nonnull (strerror (errno)));
60940b661123Smrg  tmp_len = strlen (tmp);
60950b661123Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
60960b661123Smrg  memcpy (concat_name, tmp, tmp_len);
60970b661123Smrg  concat_name[tmp_len] = '/';
60980b661123Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
6099bdcaa8d0Smrg
61000b661123Smrg  if (check_executable (concat_name))
61010b661123Smrg    return concat_name;
61020b661123Smrg  XFREE (concat_name);
61030b661123Smrg  return NULL;
61040b661123Smrg}
6105bdcaa8d0Smrg
61060b661123Smrgchar *
61070b661123Smrgchase_symlinks (const char *pathspec)
61080b661123Smrg{
61090b661123Smrg#ifndef S_ISLNK
61100b661123Smrg  return xstrdup (pathspec);
61110b661123Smrg#else
61120b661123Smrg  char buf[LT_PATHMAX];
61130b661123Smrg  struct stat s;
61140b661123Smrg  char *tmp_pathspec = xstrdup (pathspec);
61150b661123Smrg  char *p;
61160b661123Smrg  int has_symlinks = 0;
61170b661123Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
61180b661123Smrg    {
6119880c7e28Smrg      lt_debugprintf (__FILE__, __LINE__,
6120880c7e28Smrg		      "checking path component for symlinks: %s\n",
6121880c7e28Smrg		      tmp_pathspec);
61220b661123Smrg      if (lstat (tmp_pathspec, &s) == 0)
61230b661123Smrg	{
61240b661123Smrg	  if (S_ISLNK (s.st_mode) != 0)
61250b661123Smrg	    {
61260b661123Smrg	      has_symlinks = 1;
61270b661123Smrg	      break;
61280b661123Smrg	    }
6129bdcaa8d0Smrg
61300b661123Smrg	  /* search backwards for last DIR_SEPARATOR */
61310b661123Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
61320b661123Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
61330b661123Smrg	    p--;
61340b661123Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
61350b661123Smrg	    {
61360b661123Smrg	      /* no more DIR_SEPARATORS left */
61370b661123Smrg	      break;
61380b661123Smrg	    }
61390b661123Smrg	  *p = '\0';
61400b661123Smrg	}
61410b661123Smrg      else
61420b661123Smrg	{
6143880c7e28Smrg	  lt_fatal (__FILE__, __LINE__,
6144880c7e28Smrg		    "error accessing file \"%s\": %s",
6145880c7e28Smrg		    tmp_pathspec, nonnull (strerror (errno)));
61460b661123Smrg	}
61470b661123Smrg    }
61480b661123Smrg  XFREE (tmp_pathspec);
6149bdcaa8d0Smrg
61500b661123Smrg  if (!has_symlinks)
61510b661123Smrg    {
61520b661123Smrg      return xstrdup (pathspec);
61530b661123Smrg    }
6154bdcaa8d0Smrg
61550b661123Smrg  tmp_pathspec = realpath (pathspec, buf);
61560b661123Smrg  if (tmp_pathspec == 0)
61570b661123Smrg    {
6158880c7e28Smrg      lt_fatal (__FILE__, __LINE__,
6159880c7e28Smrg		"could not follow symlinks for %s", pathspec);
61600b661123Smrg    }
61610b661123Smrg  return xstrdup (tmp_pathspec);
61620b661123Smrg#endif
61630b661123Smrg}
6164bdcaa8d0Smrg
61650b661123Smrgchar *
61660b661123Smrgstrendzap (char *str, const char *pat)
61670b661123Smrg{
61680b661123Smrg  size_t len, patlen;
6169bdcaa8d0Smrg
61700b661123Smrg  assert (str != NULL);
61710b661123Smrg  assert (pat != NULL);
6172bdcaa8d0Smrg
61730b661123Smrg  len = strlen (str);
61740b661123Smrg  patlen = strlen (pat);
6175bdcaa8d0Smrg
61760b661123Smrg  if (patlen <= len)
61770b661123Smrg    {
61780b661123Smrg      str += len - patlen;
61794f00d7e1Smrg      if (STREQ (str, pat))
61800b661123Smrg	*str = '\0';
61810b661123Smrg    }
61820b661123Smrg  return str;
61830b661123Smrg}
6184bdcaa8d0Smrg
6185880c7e28Smrgvoid
6186880c7e28Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
6187880c7e28Smrg{
6188880c7e28Smrg  va_list args;
6189880c7e28Smrg  if (lt_debug)
6190880c7e28Smrg    {
6191880c7e28Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
6192880c7e28Smrg      va_start (args, fmt);
6193880c7e28Smrg      (void) vfprintf (stderr, fmt, args);
6194880c7e28Smrg      va_end (args);
6195880c7e28Smrg    }
6196880c7e28Smrg}
6197880c7e28Smrg
61980b661123Smrgstatic void
6199880c7e28Smrglt_error_core (int exit_status, const char *file,
6200880c7e28Smrg	       int line, const char *mode,
62010b661123Smrg	       const char *message, va_list ap)
62020b661123Smrg{
6203880c7e28Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
62040b661123Smrg  vfprintf (stderr, message, ap);
62050b661123Smrg  fprintf (stderr, ".\n");
6206bdcaa8d0Smrg
62070b661123Smrg  if (exit_status >= 0)
62080b661123Smrg    exit (exit_status);
62090b661123Smrg}
6210bdcaa8d0Smrg
62110b661123Smrgvoid
6212880c7e28Smrglt_fatal (const char *file, int line, const char *message, ...)
62130b661123Smrg{
62140b661123Smrg  va_list ap;
62150b661123Smrg  va_start (ap, message);
6216880c7e28Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
62170b661123Smrg  va_end (ap);
62180b661123Smrg}
6219bdcaa8d0Smrg
6220880c7e28Smrgstatic const char *
6221880c7e28Smrgnonnull (const char *s)
6222880c7e28Smrg{
6223880c7e28Smrg  return s ? s : "(null)";
6224880c7e28Smrg}
6225880c7e28Smrg
6226880c7e28Smrgstatic const char *
6227880c7e28Smrgnonempty (const char *s)
6228880c7e28Smrg{
6229880c7e28Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
6230880c7e28Smrg}
6231880c7e28Smrg
62320b661123Smrgvoid
62330b661123Smrglt_setenv (const char *name, const char *value)
62340b661123Smrg{
6235880c7e28Smrg  lt_debugprintf (__FILE__, __LINE__,
6236880c7e28Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
6237880c7e28Smrg                  nonnull (name), nonnull (value));
62380b661123Smrg  {
62390b661123Smrg#ifdef HAVE_SETENV
62400b661123Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
62410b661123Smrg    char *str = xstrdup (value);
62420b661123Smrg    setenv (name, str, 1);
62430b661123Smrg#else
62444f00d7e1Smrg    size_t len = strlen (name) + 1 + strlen (value) + 1;
62450b661123Smrg    char *str = XMALLOC (char, len);
62460b661123Smrg    sprintf (str, "%s=%s", name, value);
62470b661123Smrg    if (putenv (str) != EXIT_SUCCESS)
62480b661123Smrg      {
62490b661123Smrg        XFREE (str);
62500b661123Smrg      }
62510b661123Smrg#endif
62520b661123Smrg  }
62530b661123Smrg}
6254bdcaa8d0Smrg
62550b661123Smrgchar *
62560b661123Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
62570b661123Smrg{
62580b661123Smrg  char *new_value;
62590b661123Smrg  if (orig_value && *orig_value)
62600b661123Smrg    {
62614f00d7e1Smrg      size_t orig_value_len = strlen (orig_value);
62624f00d7e1Smrg      size_t add_len = strlen (add);
62630b661123Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
62640b661123Smrg      if (to_end)
62650b661123Smrg        {
62660b661123Smrg          strcpy (new_value, orig_value);
62670b661123Smrg          strcpy (new_value + orig_value_len, add);
62680b661123Smrg        }
62690b661123Smrg      else
62700b661123Smrg        {
62710b661123Smrg          strcpy (new_value, add);
62720b661123Smrg          strcpy (new_value + add_len, orig_value);
62730b661123Smrg        }
62740b661123Smrg    }
62750b661123Smrg  else
62760b661123Smrg    {
62770b661123Smrg      new_value = xstrdup (add);
62780b661123Smrg    }
62790b661123Smrg  return new_value;
62800b661123Smrg}
6281bdcaa8d0Smrg
62820b661123Smrgvoid
62830b661123Smrglt_update_exe_path (const char *name, const char *value)
62840b661123Smrg{
6285880c7e28Smrg  lt_debugprintf (__FILE__, __LINE__,
6286880c7e28Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
6287880c7e28Smrg                  nonnull (name), nonnull (value));
6288bdcaa8d0Smrg
62890b661123Smrg  if (name && *name && value && *value)
62900b661123Smrg    {
62910b661123Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
62920b661123Smrg      /* some systems can't cope with a ':'-terminated path #' */
62934f00d7e1Smrg      size_t len = strlen (new_value);
62944f00d7e1Smrg      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
62950b661123Smrg        {
62964f00d7e1Smrg          new_value[--len] = '\0';
62970b661123Smrg        }
62980b661123Smrg      lt_setenv (name, new_value);
62990b661123Smrg      XFREE (new_value);
63000b661123Smrg    }
63010b661123Smrg}
6302bdcaa8d0Smrg
63030b661123Smrgvoid
63040b661123Smrglt_update_lib_path (const char *name, const char *value)
63050b661123Smrg{
6306880c7e28Smrg  lt_debugprintf (__FILE__, __LINE__,
6307880c7e28Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
6308880c7e28Smrg                  nonnull (name), nonnull (value));
6309bdcaa8d0Smrg
63100b661123Smrg  if (name && *name && value && *value)
63110b661123Smrg    {
63120b661123Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
63130b661123Smrg      lt_setenv (name, new_value);
63140b661123Smrg      XFREE (new_value);
63150b661123Smrg    }
63160b661123Smrg}
6317bdcaa8d0Smrg
6318880c7e28SmrgEOF
6319880c7e28Smrg	    case $host_os in
6320880c7e28Smrg	      mingw*)
6321880c7e28Smrg		cat <<"EOF"
6322880c7e28Smrg
6323880c7e28Smrg/* Prepares an argument vector before calling spawn().
6324880c7e28Smrg   Note that spawn() does not by itself call the command interpreter
6325880c7e28Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
6326880c7e28Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
6327880c7e28Smrg         GetVersionEx(&v);
6328880c7e28Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
6329880c7e28Smrg      }) ? "cmd.exe" : "command.com").
6330880c7e28Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
6331880c7e28Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
6332880c7e28Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
6333880c7e28Smrg   special way:
6334880c7e28Smrg   - Space and tab are interpreted as delimiters. They are not treated as
6335880c7e28Smrg     delimiters if they are surrounded by double quotes: "...".
6336880c7e28Smrg   - Unescaped double quotes are removed from the input. Their only effect is
6337880c7e28Smrg     that within double quotes, space and tab are treated like normal
6338880c7e28Smrg     characters.
6339880c7e28Smrg   - Backslashes not followed by double quotes are not special.
6340880c7e28Smrg   - But 2*n+1 backslashes followed by a double quote become
6341880c7e28Smrg     n backslashes followed by a double quote (n >= 0):
6342880c7e28Smrg       \" -> "
6343880c7e28Smrg       \\\" -> \"
6344880c7e28Smrg       \\\\\" -> \\"
6345880c7e28Smrg */
6346880c7e28Smrg#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"
6347880c7e28Smrg#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"
6348880c7e28Smrgchar **
6349880c7e28Smrgprepare_spawn (char **argv)
6350880c7e28Smrg{
6351880c7e28Smrg  size_t argc;
6352880c7e28Smrg  char **new_argv;
6353880c7e28Smrg  size_t i;
6354880c7e28Smrg
6355880c7e28Smrg  /* Count number of arguments.  */
6356880c7e28Smrg  for (argc = 0; argv[argc] != NULL; argc++)
6357880c7e28Smrg    ;
6358880c7e28Smrg
6359880c7e28Smrg  /* Allocate new argument vector.  */
6360880c7e28Smrg  new_argv = XMALLOC (char *, argc + 1);
6361880c7e28Smrg
6362880c7e28Smrg  /* Put quoted arguments into the new argument vector.  */
6363880c7e28Smrg  for (i = 0; i < argc; i++)
6364880c7e28Smrg    {
6365880c7e28Smrg      const char *string = argv[i];
6366880c7e28Smrg
6367880c7e28Smrg      if (string[0] == '\0')
6368880c7e28Smrg	new_argv[i] = xstrdup ("\"\"");
6369880c7e28Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
6370880c7e28Smrg	{
6371880c7e28Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
6372880c7e28Smrg	  size_t length;
6373880c7e28Smrg	  unsigned int backslashes;
6374880c7e28Smrg	  const char *s;
6375880c7e28Smrg	  char *quoted_string;
6376880c7e28Smrg	  char *p;
6377880c7e28Smrg
6378880c7e28Smrg	  length = 0;
6379880c7e28Smrg	  backslashes = 0;
6380880c7e28Smrg	  if (quote_around)
6381880c7e28Smrg	    length++;
6382880c7e28Smrg	  for (s = string; *s != '\0'; s++)
6383880c7e28Smrg	    {
6384880c7e28Smrg	      char c = *s;
6385880c7e28Smrg	      if (c == '"')
6386880c7e28Smrg		length += backslashes + 1;
6387880c7e28Smrg	      length++;
6388880c7e28Smrg	      if (c == '\\')
6389880c7e28Smrg		backslashes++;
6390880c7e28Smrg	      else
6391880c7e28Smrg		backslashes = 0;
6392880c7e28Smrg	    }
6393880c7e28Smrg	  if (quote_around)
6394880c7e28Smrg	    length += backslashes + 1;
6395880c7e28Smrg
6396880c7e28Smrg	  quoted_string = XMALLOC (char, length + 1);
6397880c7e28Smrg
6398880c7e28Smrg	  p = quoted_string;
6399880c7e28Smrg	  backslashes = 0;
6400880c7e28Smrg	  if (quote_around)
6401880c7e28Smrg	    *p++ = '"';
6402880c7e28Smrg	  for (s = string; *s != '\0'; s++)
6403880c7e28Smrg	    {
6404880c7e28Smrg	      char c = *s;
6405880c7e28Smrg	      if (c == '"')
6406880c7e28Smrg		{
6407880c7e28Smrg		  unsigned int j;
6408880c7e28Smrg		  for (j = backslashes + 1; j > 0; j--)
6409880c7e28Smrg		    *p++ = '\\';
6410880c7e28Smrg		}
6411880c7e28Smrg	      *p++ = c;
6412880c7e28Smrg	      if (c == '\\')
6413880c7e28Smrg		backslashes++;
6414880c7e28Smrg	      else
6415880c7e28Smrg		backslashes = 0;
6416880c7e28Smrg	    }
6417880c7e28Smrg	  if (quote_around)
6418880c7e28Smrg	    {
6419880c7e28Smrg	      unsigned int j;
6420880c7e28Smrg	      for (j = backslashes; j > 0; j--)
6421880c7e28Smrg		*p++ = '\\';
6422880c7e28Smrg	      *p++ = '"';
6423880c7e28Smrg	    }
6424880c7e28Smrg	  *p = '\0';
6425880c7e28Smrg
6426880c7e28Smrg	  new_argv[i] = quoted_string;
6427880c7e28Smrg	}
6428880c7e28Smrg      else
6429880c7e28Smrg	new_argv[i] = (char *) string;
6430880c7e28Smrg    }
6431880c7e28Smrg  new_argv[argc] = NULL;
6432880c7e28Smrg
6433880c7e28Smrg  return new_argv;
6434880c7e28Smrg}
6435880c7e28SmrgEOF
6436880c7e28Smrg		;;
6437880c7e28Smrg	    esac
6438bdcaa8d0Smrg
6439880c7e28Smrg            cat <<"EOF"
6440880c7e28Smrgvoid lt_dump_script (FILE* f)
6441880c7e28Smrg{
6442880c7e28SmrgEOF
6443880c7e28Smrg	    func_emit_wrapper yes |
6444880c7e28Smrg	      $SED -n -e '
6445880c7e28Smrgs/^\(.\{79\}\)\(..*\)/\1\
6446880c7e28Smrg\2/
6447880c7e28Smrgh
6448880c7e28Smrgs/\([\\"]\)/\\\1/g
6449880c7e28Smrgs/$/\\n/
6450880c7e28Smrgs/\([^\n]*\).*/  fputs ("\1", f);/p
6451880c7e28Smrgg
6452880c7e28SmrgD'
6453880c7e28Smrg            cat <<"EOF"
6454880c7e28Smrg}
64550b661123SmrgEOF
64560b661123Smrg}
64570b661123Smrg# end: func_emit_cwrapperexe_src
6458bdcaa8d0Smrg
6459880c7e28Smrg# func_win32_import_lib_p ARG
6460880c7e28Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
6461880c7e28Smrgfunc_win32_import_lib_p ()
6462880c7e28Smrg{
64634f00d7e1Smrg    $debug_cmd
64644f00d7e1Smrg
6465880c7e28Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
6466880c7e28Smrg    *import*) : ;;
6467880c7e28Smrg    *) false ;;
6468880c7e28Smrg    esac
6469880c7e28Smrg}
6470880c7e28Smrg
64714f00d7e1Smrg# func_suncc_cstd_abi
64724f00d7e1Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
64734f00d7e1Smrg# Several compiler flags select an ABI that is incompatible with the
64744f00d7e1Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS.
64754f00d7e1Smrgfunc_suncc_cstd_abi ()
64764f00d7e1Smrg{
64774f00d7e1Smrg    $debug_cmd
64784f00d7e1Smrg
64794f00d7e1Smrg    case " $compile_command " in
64804f00d7e1Smrg    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
64814f00d7e1Smrg      suncc_use_cstd_abi=no
64824f00d7e1Smrg      ;;
64834f00d7e1Smrg    *)
64844f00d7e1Smrg      suncc_use_cstd_abi=yes
64854f00d7e1Smrg      ;;
64864f00d7e1Smrg    esac
64874f00d7e1Smrg}
64884f00d7e1Smrg
64890b661123Smrg# func_mode_link arg...
64900b661123Smrgfunc_mode_link ()
64910b661123Smrg{
64924f00d7e1Smrg    $debug_cmd
64934f00d7e1Smrg
64940b661123Smrg    case $host in
64950b661123Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
64960b661123Smrg      # It is impossible to link a dll without this setting, and
64970b661123Smrg      # we shouldn't force the makefile maintainer to figure out
64984f00d7e1Smrg      # what system we are compiling for in order to pass an extra
64990b661123Smrg      # flag for every libtool invocation.
65000b661123Smrg      # allow_undefined=no
6501bdcaa8d0Smrg
65020b661123Smrg      # FIXME: Unfortunately, there are problems with the above when trying
65034f00d7e1Smrg      # to make a dll that has undefined symbols, in which case not
65040b661123Smrg      # even a static library is built.  For now, we need to specify
65050b661123Smrg      # -no-undefined on the libtool link line when we can be certain
65060b661123Smrg      # that all symbols are satisfied, otherwise we get a static library.
65070b661123Smrg      allow_undefined=yes
65080b661123Smrg      ;;
65090b661123Smrg    *)
65100b661123Smrg      allow_undefined=yes
65110b661123Smrg      ;;
65120b661123Smrg    esac
65130b661123Smrg    libtool_args=$nonopt
65140b661123Smrg    base_compile="$nonopt $@"
65150b661123Smrg    compile_command=$nonopt
65160b661123Smrg    finalize_command=$nonopt
6517bdcaa8d0Smrg
65180b661123Smrg    compile_rpath=
65190b661123Smrg    finalize_rpath=
65200b661123Smrg    compile_shlibpath=
65210b661123Smrg    finalize_shlibpath=
65220b661123Smrg    convenience=
65230b661123Smrg    old_convenience=
65240b661123Smrg    deplibs=
65250b661123Smrg    old_deplibs=
65260b661123Smrg    compiler_flags=
65270b661123Smrg    linker_flags=
65280b661123Smrg    dllsearchpath=
65290b661123Smrg    lib_search_path=`pwd`
65300b661123Smrg    inst_prefix_dir=
65310b661123Smrg    new_inherited_linker_flags=
6532bdcaa8d0Smrg
65330b661123Smrg    avoid_version=no
6534880c7e28Smrg    bindir=
65350b661123Smrg    dlfiles=
65360b661123Smrg    dlprefiles=
65370b661123Smrg    dlself=no
65380b661123Smrg    export_dynamic=no
65390b661123Smrg    export_symbols=
65400b661123Smrg    export_symbols_regex=
65410b661123Smrg    generated=
65420b661123Smrg    libobjs=
65430b661123Smrg    ltlibs=
65440b661123Smrg    module=no
65450b661123Smrg    no_install=no
65460b661123Smrg    objs=
65474f00d7e1Smrg    os2dllname=
65480b661123Smrg    non_pic_objects=
65490b661123Smrg    precious_files_regex=
65500b661123Smrg    prefer_static_libs=no
65514f00d7e1Smrg    preload=false
65520b661123Smrg    prev=
65530b661123Smrg    prevarg=
65540b661123Smrg    release=
65550b661123Smrg    rpath=
65560b661123Smrg    xrpath=
65570b661123Smrg    perm_rpath=
65580b661123Smrg    temp_rpath=
65590b661123Smrg    thread_safe=no
65600b661123Smrg    vinfo=
65610b661123Smrg    vinfo_number=no
65620b661123Smrg    weak_libs=
65634f00d7e1Smrg    single_module=$wl-single_module
65640b661123Smrg    func_infer_tag $base_compile
65650b661123Smrg
65660b661123Smrg    # We need to know -static, to get the right output filenames.
65670b661123Smrg    for arg
65680b661123Smrg    do
65690b661123Smrg      case $arg in
65700b661123Smrg      -shared)
65714f00d7e1Smrg	test yes != "$build_libtool_libs" \
65724f00d7e1Smrg	  && func_fatal_configuration "cannot build a shared library"
65730b661123Smrg	build_old_libs=no
65740b661123Smrg	break
65750b661123Smrg	;;
65760b661123Smrg      -all-static | -static | -static-libtool-libs)
65770b661123Smrg	case $arg in
65780b661123Smrg	-all-static)
65794f00d7e1Smrg	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
65800b661123Smrg	    func_warning "complete static linking is impossible in this configuration"
65810b661123Smrg	  fi
65820b661123Smrg	  if test -n "$link_static_flag"; then
65830b661123Smrg	    dlopen_self=$dlopen_self_static
65840b661123Smrg	  fi
65850b661123Smrg	  prefer_static_libs=yes
65860b661123Smrg	  ;;
65870b661123Smrg	-static)
65880b661123Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
65890b661123Smrg	    dlopen_self=$dlopen_self_static
65900b661123Smrg	  fi
65910b661123Smrg	  prefer_static_libs=built
65920b661123Smrg	  ;;
65930b661123Smrg	-static-libtool-libs)
65940b661123Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
65950b661123Smrg	    dlopen_self=$dlopen_self_static
659696ce994aSmrg	  fi
65970b661123Smrg	  prefer_static_libs=yes
65980b661123Smrg	  ;;
65990b661123Smrg	esac
66000b661123Smrg	build_libtool_libs=no
66010b661123Smrg	build_old_libs=yes
66020b661123Smrg	break
66030b661123Smrg	;;
66040b661123Smrg      esac
66050b661123Smrg    done
6606bdcaa8d0Smrg
66070b661123Smrg    # See if our shared archives depend on static archives.
66080b661123Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
6609bdcaa8d0Smrg
66100b661123Smrg    # Go through the arguments, transforming them on the way.
66110b661123Smrg    while test "$#" -gt 0; do
66124f00d7e1Smrg      arg=$1
66130b661123Smrg      shift
66140b661123Smrg      func_quote_for_eval "$arg"
66150b661123Smrg      qarg=$func_quote_for_eval_unquoted_result
66160b661123Smrg      func_append libtool_args " $func_quote_for_eval_result"
6617bdcaa8d0Smrg
66180b661123Smrg      # If the previous option needs an argument, assign it.
66190b661123Smrg      if test -n "$prev"; then
66200b661123Smrg	case $prev in
66210b661123Smrg	output)
66220b661123Smrg	  func_append compile_command " @OUTPUT@"
66230b661123Smrg	  func_append finalize_command " @OUTPUT@"
66240b661123Smrg	  ;;
66250b661123Smrg	esac
6626bdcaa8d0Smrg
66270b661123Smrg	case $prev in
6628880c7e28Smrg	bindir)
66294f00d7e1Smrg	  bindir=$arg
6630880c7e28Smrg	  prev=
6631880c7e28Smrg	  continue
6632880c7e28Smrg	  ;;
66330b661123Smrg	dlfiles|dlprefiles)
66344f00d7e1Smrg	  $preload || {
66350b661123Smrg	    # Add the symbol object into the linking commands.
66360b661123Smrg	    func_append compile_command " @SYMFILE@"
66370b661123Smrg	    func_append finalize_command " @SYMFILE@"
66384f00d7e1Smrg	    preload=:
66394f00d7e1Smrg	  }
66400b661123Smrg	  case $arg in
66410b661123Smrg	  *.la | *.lo) ;;  # We handle these cases below.
66420b661123Smrg	  force)
66434f00d7e1Smrg	    if test no = "$dlself"; then
66440b661123Smrg	      dlself=needless
66450b661123Smrg	      export_dynamic=yes
66460b661123Smrg	    fi
66470b661123Smrg	    prev=
66480b661123Smrg	    continue
66490b661123Smrg	    ;;
66500b661123Smrg	  self)
66514f00d7e1Smrg	    if test dlprefiles = "$prev"; then
66520b661123Smrg	      dlself=yes
66534f00d7e1Smrg	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
66540b661123Smrg	      dlself=yes
665596ce994aSmrg	    else
66560b661123Smrg	      dlself=needless
66570b661123Smrg	      export_dynamic=yes
665896ce994aSmrg	    fi
66590b661123Smrg	    prev=
66600b661123Smrg	    continue
66610b661123Smrg	    ;;
66620b661123Smrg	  *)
66634f00d7e1Smrg	    if test dlfiles = "$prev"; then
6664880c7e28Smrg	      func_append dlfiles " $arg"
666596ce994aSmrg	    else
6666880c7e28Smrg	      func_append dlprefiles " $arg"
666796ce994aSmrg	    fi
66680b661123Smrg	    prev=
66690b661123Smrg	    continue
66700b661123Smrg	    ;;
66710b661123Smrg	  esac
66720b661123Smrg	  ;;
66730b661123Smrg	expsyms)
66744f00d7e1Smrg	  export_symbols=$arg
66750b661123Smrg	  test -f "$arg" \
66764f00d7e1Smrg	    || func_fatal_error "symbol file '$arg' does not exist"
66770b661123Smrg	  prev=
66780b661123Smrg	  continue
66790b661123Smrg	  ;;
66800b661123Smrg	expsyms_regex)
66814f00d7e1Smrg	  export_symbols_regex=$arg
66820b661123Smrg	  prev=
66830b661123Smrg	  continue
66840b661123Smrg	  ;;
66850b661123Smrg	framework)
668696ce994aSmrg	  case $host in
66870b661123Smrg	    *-*-darwin*)
66880b661123Smrg	      case "$deplibs " in
66890b661123Smrg		*" $qarg.ltframework "*) ;;
6690880c7e28Smrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
66910b661123Smrg		   ;;
66920b661123Smrg	      esac
66930b661123Smrg	      ;;
669496ce994aSmrg	  esac
66950b661123Smrg	  prev=
66960b661123Smrg	  continue
669796ce994aSmrg	  ;;
66980b661123Smrg	inst_prefix)
66994f00d7e1Smrg	  inst_prefix_dir=$arg
67004f00d7e1Smrg	  prev=
67014f00d7e1Smrg	  continue
67024f00d7e1Smrg	  ;;
67034f00d7e1Smrg	mllvm)
67044f00d7e1Smrg	  # Clang does not use LLVM to link, so we can simply discard any
67054f00d7e1Smrg	  # '-mllvm $arg' options when doing the link step.
67060b661123Smrg	  prev=
67070b661123Smrg	  continue
670896ce994aSmrg	  ;;
67090b661123Smrg	objectlist)
67100b661123Smrg	  if test -f "$arg"; then
67110b661123Smrg	    save_arg=$arg
67120b661123Smrg	    moreargs=
67130b661123Smrg	    for fil in `cat "$save_arg"`
67140b661123Smrg	    do
6715880c7e28Smrg#	      func_append moreargs " $fil"
67160b661123Smrg	      arg=$fil
67170b661123Smrg	      # A libtool-controlled object.
671872313efbSmrg
67190b661123Smrg	      # Check to see that this really is a libtool object.
67200b661123Smrg	      if func_lalib_unsafe_p "$arg"; then
67210b661123Smrg		pic_object=
67220b661123Smrg		non_pic_object=
672372313efbSmrg
67240b661123Smrg		# Read the .lo file
67250b661123Smrg		func_source "$arg"
672672313efbSmrg
67270b661123Smrg		if test -z "$pic_object" ||
67280b661123Smrg		   test -z "$non_pic_object" ||
67294f00d7e1Smrg		   test none = "$pic_object" &&
67304f00d7e1Smrg		   test none = "$non_pic_object"; then
67314f00d7e1Smrg		  func_fatal_error "cannot find name of object for '$arg'"
67320b661123Smrg		fi
673372313efbSmrg
67340b661123Smrg		# Extract subdirectory from the argument.
67350b661123Smrg		func_dirname "$arg" "/" ""
67364f00d7e1Smrg		xdir=$func_dirname_result
673772313efbSmrg
67384f00d7e1Smrg		if test none != "$pic_object"; then
67390b661123Smrg		  # Prepend the subdirectory the object is found in.
67404f00d7e1Smrg		  pic_object=$xdir$pic_object
674172313efbSmrg
67424f00d7e1Smrg		  if test dlfiles = "$prev"; then
67434f00d7e1Smrg		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
6744880c7e28Smrg		      func_append dlfiles " $pic_object"
67450b661123Smrg		      prev=
67460b661123Smrg		      continue
67470b661123Smrg		    else
67480b661123Smrg		      # If libtool objects are unsupported, then we need to preload.
67490b661123Smrg		      prev=dlprefiles
67500b661123Smrg		    fi
67510b661123Smrg		  fi
675272313efbSmrg
67530b661123Smrg		  # CHECK ME:  I think I busted this.  -Ossama
67544f00d7e1Smrg		  if test dlprefiles = "$prev"; then
67550b661123Smrg		    # Preload the old-style object.
6756880c7e28Smrg		    func_append dlprefiles " $pic_object"
67570b661123Smrg		    prev=
67580b661123Smrg		  fi
675972313efbSmrg
67600b661123Smrg		  # A PIC object.
67610b661123Smrg		  func_append libobjs " $pic_object"
67624f00d7e1Smrg		  arg=$pic_object
67630b661123Smrg		fi
676472313efbSmrg
67650b661123Smrg		# Non-PIC object.
67664f00d7e1Smrg		if test none != "$non_pic_object"; then
67670b661123Smrg		  # Prepend the subdirectory the object is found in.
67684f00d7e1Smrg		  non_pic_object=$xdir$non_pic_object
676972313efbSmrg
67700b661123Smrg		  # A standard non-PIC object
67710b661123Smrg		  func_append non_pic_objects " $non_pic_object"
67724f00d7e1Smrg		  if test -z "$pic_object" || test none = "$pic_object"; then
67734f00d7e1Smrg		    arg=$non_pic_object
67740b661123Smrg		  fi
67750b661123Smrg		else
67760b661123Smrg		  # If the PIC object exists, use it instead.
67770b661123Smrg		  # $xdir was prepended to $pic_object above.
67784f00d7e1Smrg		  non_pic_object=$pic_object
67790b661123Smrg		  func_append non_pic_objects " $non_pic_object"
67800b661123Smrg		fi
67810b661123Smrg	      else
67820b661123Smrg		# Only an error if not doing a dry-run.
67830b661123Smrg		if $opt_dry_run; then
67840b661123Smrg		  # Extract subdirectory from the argument.
67850b661123Smrg		  func_dirname "$arg" "/" ""
67864f00d7e1Smrg		  xdir=$func_dirname_result
67870b661123Smrg
67880b661123Smrg		  func_lo2o "$arg"
67890b661123Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
67900b661123Smrg		  non_pic_object=$xdir$func_lo2o_result
67910b661123Smrg		  func_append libobjs " $pic_object"
67920b661123Smrg		  func_append non_pic_objects " $non_pic_object"
67930b661123Smrg	        else
67944f00d7e1Smrg		  func_fatal_error "'$arg' is not a valid libtool object"
67950b661123Smrg		fi
67960b661123Smrg	      fi
67970b661123Smrg	    done
679896ce994aSmrg	  else
67994f00d7e1Smrg	    func_fatal_error "link input file '$arg' does not exist"
680096ce994aSmrg	  fi
68010b661123Smrg	  arg=$save_arg
68020b661123Smrg	  prev=
68030b661123Smrg	  continue
68040b661123Smrg	  ;;
68054f00d7e1Smrg	os2dllname)
68064f00d7e1Smrg	  os2dllname=$arg
68074f00d7e1Smrg	  prev=
68084f00d7e1Smrg	  continue
68094f00d7e1Smrg	  ;;
68100b661123Smrg	precious_regex)
68114f00d7e1Smrg	  precious_files_regex=$arg
68120b661123Smrg	  prev=
68130b661123Smrg	  continue
68140b661123Smrg	  ;;
68150b661123Smrg	release)
68164f00d7e1Smrg	  release=-$arg
68170b661123Smrg	  prev=
68180b661123Smrg	  continue
68190b661123Smrg	  ;;
68200b661123Smrg	rpath | xrpath)
68210b661123Smrg	  # We need an absolute path.
68220b661123Smrg	  case $arg in
68230b661123Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
68240b661123Smrg	  *)
68250b661123Smrg	    func_fatal_error "only absolute run-paths are allowed"
68260b661123Smrg	    ;;
68270b661123Smrg	  esac
68284f00d7e1Smrg	  if test rpath = "$prev"; then
68290b661123Smrg	    case "$rpath " in
68300b661123Smrg	    *" $arg "*) ;;
6831880c7e28Smrg	    *) func_append rpath " $arg" ;;
68320b661123Smrg	    esac
683396ce994aSmrg	  else
68340b661123Smrg	    case "$xrpath " in
68350b661123Smrg	    *" $arg "*) ;;
6836880c7e28Smrg	    *) func_append xrpath " $arg" ;;
68370b661123Smrg	    esac
683896ce994aSmrg	  fi
68390b661123Smrg	  prev=
68400b661123Smrg	  continue
68410b661123Smrg	  ;;
68420b661123Smrg	shrext)
68434f00d7e1Smrg	  shrext_cmds=$arg
68440b661123Smrg	  prev=
68450b661123Smrg	  continue
68460b661123Smrg	  ;;
68470b661123Smrg	weak)
6848880c7e28Smrg	  func_append weak_libs " $arg"
68490b661123Smrg	  prev=
68500b661123Smrg	  continue
68510b661123Smrg	  ;;
68520b661123Smrg	xcclinker)
6853880c7e28Smrg	  func_append linker_flags " $qarg"
6854880c7e28Smrg	  func_append compiler_flags " $qarg"
68550b661123Smrg	  prev=
68560b661123Smrg	  func_append compile_command " $qarg"
68570b661123Smrg	  func_append finalize_command " $qarg"
68580b661123Smrg	  continue
68590b661123Smrg	  ;;
68600b661123Smrg	xcompiler)
6861880c7e28Smrg	  func_append compiler_flags " $qarg"
68620b661123Smrg	  prev=
68630b661123Smrg	  func_append compile_command " $qarg"
68640b661123Smrg	  func_append finalize_command " $qarg"
68650b661123Smrg	  continue
68660b661123Smrg	  ;;
68670b661123Smrg	xlinker)
6868880c7e28Smrg	  func_append linker_flags " $qarg"
6869880c7e28Smrg	  func_append compiler_flags " $wl$qarg"
68700b661123Smrg	  prev=
68710b661123Smrg	  func_append compile_command " $wl$qarg"
68720b661123Smrg	  func_append finalize_command " $wl$qarg"
68730b661123Smrg	  continue
68740b661123Smrg	  ;;
68750b661123Smrg	*)
68760b661123Smrg	  eval "$prev=\"\$arg\""
68770b661123Smrg	  prev=
68780b661123Smrg	  continue
68790b661123Smrg	  ;;
688072313efbSmrg	esac
68810b661123Smrg      fi # test -n "$prev"
688272313efbSmrg
68834f00d7e1Smrg      prevarg=$arg
688472313efbSmrg
68850b661123Smrg      case $arg in
68860b661123Smrg      -all-static)
68870b661123Smrg	if test -n "$link_static_flag"; then
68880b661123Smrg	  # See comment for -static flag below, for more details.
68890b661123Smrg	  func_append compile_command " $link_static_flag"
68900b661123Smrg	  func_append finalize_command " $link_static_flag"
68910b661123Smrg	fi
68920b661123Smrg	continue
68930b661123Smrg	;;
689472313efbSmrg
68950b661123Smrg      -allow-undefined)
68960b661123Smrg	# FIXME: remove this flag sometime in the future.
68974f00d7e1Smrg	func_fatal_error "'-allow-undefined' must not be used because it is the default"
68980b661123Smrg	;;
689972313efbSmrg
69000b661123Smrg      -avoid-version)
69010b661123Smrg	avoid_version=yes
69020b661123Smrg	continue
69030b661123Smrg	;;
690472313efbSmrg
6905880c7e28Smrg      -bindir)
6906880c7e28Smrg	prev=bindir
6907880c7e28Smrg	continue
6908880c7e28Smrg	;;
6909880c7e28Smrg
69100b661123Smrg      -dlopen)
69110b661123Smrg	prev=dlfiles
69120b661123Smrg	continue
69130b661123Smrg	;;
691472313efbSmrg
69150b661123Smrg      -dlpreopen)
69160b661123Smrg	prev=dlprefiles
69170b661123Smrg	continue
69180b661123Smrg	;;
691972313efbSmrg
69200b661123Smrg      -export-dynamic)
69210b661123Smrg	export_dynamic=yes
69220b661123Smrg	continue
69230b661123Smrg	;;
692472313efbSmrg
69250b661123Smrg      -export-symbols | -export-symbols-regex)
69260b661123Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
69270b661123Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
69280b661123Smrg	fi
69294f00d7e1Smrg	if test X-export-symbols = "X$arg"; then
69300b661123Smrg	  prev=expsyms
69310b661123Smrg	else
69320b661123Smrg	  prev=expsyms_regex
69330b661123Smrg	fi
69340b661123Smrg	continue
69350b661123Smrg	;;
693672313efbSmrg
69370b661123Smrg      -framework)
69380b661123Smrg	prev=framework
69390b661123Smrg	continue
69400b661123Smrg	;;
694172313efbSmrg
69420b661123Smrg      -inst-prefix-dir)
69430b661123Smrg	prev=inst_prefix
69440b661123Smrg	continue
69450b661123Smrg	;;
694672313efbSmrg
69470b661123Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
69480b661123Smrg      # so, if we see these flags be careful not to treat them like -L
69490b661123Smrg      -L[A-Z][A-Z]*:*)
69500b661123Smrg	case $with_gcc/$host in
69510b661123Smrg	no/*-*-irix* | /*-*-irix*)
69520b661123Smrg	  func_append compile_command " $arg"
69530b661123Smrg	  func_append finalize_command " $arg"
69540b661123Smrg	  ;;
69550b661123Smrg	esac
69560b661123Smrg	continue
69570b661123Smrg	;;
695872313efbSmrg
69590b661123Smrg      -L*)
6960880c7e28Smrg	func_stripname "-L" '' "$arg"
6961880c7e28Smrg	if test -z "$func_stripname_result"; then
69620b661123Smrg	  if test "$#" -gt 0; then
69634f00d7e1Smrg	    func_fatal_error "require no space between '-L' and '$1'"
69640b661123Smrg	  else
69654f00d7e1Smrg	    func_fatal_error "need path for '-L' option"
69660b661123Smrg	  fi
69670b661123Smrg	fi
6968880c7e28Smrg	func_resolve_sysroot "$func_stripname_result"
6969880c7e28Smrg	dir=$func_resolve_sysroot_result
69700b661123Smrg	# We need an absolute path.
69710b661123Smrg	case $dir in
69720b661123Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
69730b661123Smrg	*)
69740b661123Smrg	  absdir=`cd "$dir" && pwd`
69750b661123Smrg	  test -z "$absdir" && \
69764f00d7e1Smrg	    func_fatal_error "cannot determine absolute directory name of '$dir'"
69774f00d7e1Smrg	  dir=$absdir
69780b661123Smrg	  ;;
69790b661123Smrg	esac
69800b661123Smrg	case "$deplibs " in
6981880c7e28Smrg	*" -L$dir "* | *" $arg "*)
6982880c7e28Smrg	  # Will only happen for absolute or sysroot arguments
6983880c7e28Smrg	  ;;
69840b661123Smrg	*)
6985880c7e28Smrg	  # Preserve sysroot, but never include relative directories
6986880c7e28Smrg	  case $dir in
6987880c7e28Smrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
6988880c7e28Smrg	    *) func_append deplibs " -L$dir" ;;
6989880c7e28Smrg	  esac
6990880c7e28Smrg	  func_append lib_search_path " $dir"
69910b661123Smrg	  ;;
69920b661123Smrg	esac
69930b661123Smrg	case $host in
69940b661123Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6995880c7e28Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
69960b661123Smrg	  case :$dllsearchpath: in
69970b661123Smrg	  *":$dir:"*) ;;
69980b661123Smrg	  ::) dllsearchpath=$dir;;
6999880c7e28Smrg	  *) func_append dllsearchpath ":$dir";;
70000b661123Smrg	  esac
70010b661123Smrg	  case :$dllsearchpath: in
70020b661123Smrg	  *":$testbindir:"*) ;;
70030b661123Smrg	  ::) dllsearchpath=$testbindir;;
7004880c7e28Smrg	  *) func_append dllsearchpath ":$testbindir";;
70050b661123Smrg	  esac
70060b661123Smrg	  ;;
70070b661123Smrg	esac
70080b661123Smrg	continue
70090b661123Smrg	;;
701072313efbSmrg
70110b661123Smrg      -l*)
70124f00d7e1Smrg	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
70130b661123Smrg	  case $host in
7014880c7e28Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
70150b661123Smrg	    # These systems don't actually have a C or math library (as such)
70160b661123Smrg	    continue
70170b661123Smrg	    ;;
70180b661123Smrg	  *-*-os2*)
70190b661123Smrg	    # These systems don't actually have a C library (as such)
70204f00d7e1Smrg	    test X-lc = "X$arg" && continue
70210b661123Smrg	    ;;
70224f00d7e1Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
70230b661123Smrg	    # Do not include libc due to us having libc/libc_r.
70244f00d7e1Smrg	    test X-lc = "X$arg" && continue
70250b661123Smrg	    ;;
70260b661123Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
70270b661123Smrg	    # Rhapsody C and math libraries are in the System framework
7028880c7e28Smrg	    func_append deplibs " System.ltframework"
70290b661123Smrg	    continue
70300b661123Smrg	    ;;
70310b661123Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
70320b661123Smrg	    # Causes problems with __ctype
70334f00d7e1Smrg	    test X-lc = "X$arg" && continue
70340b661123Smrg	    ;;
70350b661123Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
70360b661123Smrg	    # Compiler inserts libc in the correct place for threads to work
70374f00d7e1Smrg	    test X-lc = "X$arg" && continue
70380b661123Smrg	    ;;
70390b661123Smrg	  esac
70404f00d7e1Smrg	elif test X-lc_r = "X$arg"; then
70410b661123Smrg	 case $host in
70424f00d7e1Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
70430b661123Smrg	   # Do not include libc_r directly, use -pthread flag.
70440b661123Smrg	   continue
70450b661123Smrg	   ;;
70460b661123Smrg	 esac
70470b661123Smrg	fi
7048880c7e28Smrg	func_append deplibs " $arg"
70490b661123Smrg	continue
70500b661123Smrg	;;
705172313efbSmrg
70524f00d7e1Smrg      -mllvm)
70534f00d7e1Smrg	prev=mllvm
70544f00d7e1Smrg	continue
70554f00d7e1Smrg	;;
70564f00d7e1Smrg
70570b661123Smrg      -module)
70580b661123Smrg	module=yes
70590b661123Smrg	continue
70600b661123Smrg	;;
706172313efbSmrg
70620b661123Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
70630b661123Smrg      # classes, name mangling, and exception handling.
70640b661123Smrg      # Darwin uses the -arch flag to determine output architecture.
7065880c7e28Smrg      -model|-arch|-isysroot|--sysroot)
7066880c7e28Smrg	func_append compiler_flags " $arg"
70670b661123Smrg	func_append compile_command " $arg"
70680b661123Smrg	func_append finalize_command " $arg"
70690b661123Smrg	prev=xcompiler
70700b661123Smrg	continue
70710b661123Smrg	;;
707272313efbSmrg
7073880c7e28Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7074880c7e28Smrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7075880c7e28Smrg	func_append compiler_flags " $arg"
70760b661123Smrg	func_append compile_command " $arg"
70770b661123Smrg	func_append finalize_command " $arg"
70780b661123Smrg	case "$new_inherited_linker_flags " in
70790b661123Smrg	    *" $arg "*) ;;
7080880c7e28Smrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
70810b661123Smrg	esac
70820b661123Smrg	continue
70830b661123Smrg	;;
708472313efbSmrg
70850b661123Smrg      -multi_module)
70864f00d7e1Smrg	single_module=$wl-multi_module
70870b661123Smrg	continue
70880b661123Smrg	;;
708972313efbSmrg
70900b661123Smrg      -no-fast-install)
70910b661123Smrg	fast_install=no
70920b661123Smrg	continue
70930b661123Smrg	;;
709472313efbSmrg
70950b661123Smrg      -no-install)
70960b661123Smrg	case $host in
70970b661123Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
70980b661123Smrg	  # The PATH hackery in wrapper scripts is required on Windows
70990b661123Smrg	  # and Darwin in order for the loader to find any dlls it needs.
71004f00d7e1Smrg	  func_warning "'-no-install' is ignored for $host"
71014f00d7e1Smrg	  func_warning "assuming '-no-fast-install' instead"
71020b661123Smrg	  fast_install=no
71030b661123Smrg	  ;;
71040b661123Smrg	*) no_install=yes ;;
71050b661123Smrg	esac
71060b661123Smrg	continue
71070b661123Smrg	;;
710872313efbSmrg
71090b661123Smrg      -no-undefined)
71100b661123Smrg	allow_undefined=no
71110b661123Smrg	continue
71120b661123Smrg	;;
711372313efbSmrg
71140b661123Smrg      -objectlist)
71150b661123Smrg	prev=objectlist
71160b661123Smrg	continue
71170b661123Smrg	;;
711872313efbSmrg
71194f00d7e1Smrg      -os2dllname)
71204f00d7e1Smrg	prev=os2dllname
71214f00d7e1Smrg	continue
71224f00d7e1Smrg	;;
71234f00d7e1Smrg
71240b661123Smrg      -o) prev=output ;;
712572313efbSmrg
71260b661123Smrg      -precious-files-regex)
71270b661123Smrg	prev=precious_regex
71280b661123Smrg	continue
71290b661123Smrg	;;
713072313efbSmrg
71310b661123Smrg      -release)
71320b661123Smrg	prev=release
71330b661123Smrg	continue
71340b661123Smrg	;;
713572313efbSmrg
71360b661123Smrg      -rpath)
71370b661123Smrg	prev=rpath
71380b661123Smrg	continue
71390b661123Smrg	;;
714072313efbSmrg
71410b661123Smrg      -R)
71420b661123Smrg	prev=xrpath
71430b661123Smrg	continue
71440b661123Smrg	;;
714572313efbSmrg
71460b661123Smrg      -R*)
71470b661123Smrg	func_stripname '-R' '' "$arg"
71480b661123Smrg	dir=$func_stripname_result
71490b661123Smrg	# We need an absolute path.
71500b661123Smrg	case $dir in
71510b661123Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
7152880c7e28Smrg	=*)
7153880c7e28Smrg	  func_stripname '=' '' "$dir"
7154880c7e28Smrg	  dir=$lt_sysroot$func_stripname_result
7155880c7e28Smrg	  ;;
71560b661123Smrg	*)
71570b661123Smrg	  func_fatal_error "only absolute run-paths are allowed"
71580b661123Smrg	  ;;
71590b661123Smrg	esac
71600b661123Smrg	case "$xrpath " in
71610b661123Smrg	*" $dir "*) ;;
7162880c7e28Smrg	*) func_append xrpath " $dir" ;;
71630b661123Smrg	esac
71640b661123Smrg	continue
71650b661123Smrg	;;
716672313efbSmrg
71670b661123Smrg      -shared)
71680b661123Smrg	# The effects of -shared are defined in a previous loop.
71690b661123Smrg	continue
71700b661123Smrg	;;
717172313efbSmrg
71720b661123Smrg      -shrext)
71730b661123Smrg	prev=shrext
71740b661123Smrg	continue
71750b661123Smrg	;;
717672313efbSmrg
71770b661123Smrg      -static | -static-libtool-libs)
71780b661123Smrg	# The effects of -static are defined in a previous loop.
71790b661123Smrg	# We used to do the same as -all-static on platforms that
71800b661123Smrg	# didn't have a PIC flag, but the assumption that the effects
71810b661123Smrg	# would be equivalent was wrong.  It would break on at least
71820b661123Smrg	# Digital Unix and AIX.
71830b661123Smrg	continue
71840b661123Smrg	;;
718572313efbSmrg
71860b661123Smrg      -thread-safe)
71870b661123Smrg	thread_safe=yes
71880b661123Smrg	continue
71890b661123Smrg	;;
719072313efbSmrg
71910b661123Smrg      -version-info)
71920b661123Smrg	prev=vinfo
71930b661123Smrg	continue
71940b661123Smrg	;;
719572313efbSmrg
71960b661123Smrg      -version-number)
71970b661123Smrg	prev=vinfo
71980b661123Smrg	vinfo_number=yes
71990b661123Smrg	continue
72000b661123Smrg	;;
720172313efbSmrg
72020b661123Smrg      -weak)
72030b661123Smrg        prev=weak
72040b661123Smrg	continue
72050b661123Smrg	;;
7206bdcaa8d0Smrg
72070b661123Smrg      -Wc,*)
72080b661123Smrg	func_stripname '-Wc,' '' "$arg"
72090b661123Smrg	args=$func_stripname_result
72100b661123Smrg	arg=
72114f00d7e1Smrg	save_ifs=$IFS; IFS=,
72120b661123Smrg	for flag in $args; do
72134f00d7e1Smrg	  IFS=$save_ifs
72140b661123Smrg          func_quote_for_eval "$flag"
7215880c7e28Smrg	  func_append arg " $func_quote_for_eval_result"
7216880c7e28Smrg	  func_append compiler_flags " $func_quote_for_eval_result"
72170b661123Smrg	done
72184f00d7e1Smrg	IFS=$save_ifs
72190b661123Smrg	func_stripname ' ' '' "$arg"
72200b661123Smrg	arg=$func_stripname_result
72210b661123Smrg	;;
722296ce994aSmrg
72230b661123Smrg      -Wl,*)
72240b661123Smrg	func_stripname '-Wl,' '' "$arg"
72250b661123Smrg	args=$func_stripname_result
72260b661123Smrg	arg=
72274f00d7e1Smrg	save_ifs=$IFS; IFS=,
72280b661123Smrg	for flag in $args; do
72294f00d7e1Smrg	  IFS=$save_ifs
72300b661123Smrg          func_quote_for_eval "$flag"
7231880c7e28Smrg	  func_append arg " $wl$func_quote_for_eval_result"
7232880c7e28Smrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
7233880c7e28Smrg	  func_append linker_flags " $func_quote_for_eval_result"
72340b661123Smrg	done
72354f00d7e1Smrg	IFS=$save_ifs
72360b661123Smrg	func_stripname ' ' '' "$arg"
72370b661123Smrg	arg=$func_stripname_result
72380b661123Smrg	;;
723996ce994aSmrg
72400b661123Smrg      -Xcompiler)
72410b661123Smrg	prev=xcompiler
72420b661123Smrg	continue
72430b661123Smrg	;;
724496ce994aSmrg
72450b661123Smrg      -Xlinker)
72460b661123Smrg	prev=xlinker
72470b661123Smrg	continue
72480b661123Smrg	;;
724996ce994aSmrg
72500b661123Smrg      -XCClinker)
72510b661123Smrg	prev=xcclinker
72520b661123Smrg	continue
72530b661123Smrg	;;
725496ce994aSmrg
72550b661123Smrg      # -msg_* for osf cc
72560b661123Smrg      -msg_*)
72570b661123Smrg	func_quote_for_eval "$arg"
72584f00d7e1Smrg	arg=$func_quote_for_eval_result
72590b661123Smrg	;;
726096ce994aSmrg
7261880c7e28Smrg      # Flags to be passed through unchanged, with rationale:
7262880c7e28Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
7263880c7e28Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
7264880c7e28Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
7265880c7e28Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
7266880c7e28Smrg      # -q*                  compiler args for the IBM compiler
7267880c7e28Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
7268880c7e28Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
7269880c7e28Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
72704f00d7e1Smrg      # -fstack-protector*   stack protector flags for GCC
7271880c7e28Smrg      # @file                GCC response files
7272880c7e28Smrg      # -tp=*                Portland pgcc target processor selection
7273880c7e28Smrg      # --sysroot=*          for sysroot support
72744f00d7e1Smrg      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
72754f00d7e1Smrg      # -stdlib=*            select c++ std lib with clang
72760b661123Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
7277880c7e28Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
72784f00d7e1Smrg      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*)
72790b661123Smrg        func_quote_for_eval "$arg"
72804f00d7e1Smrg	arg=$func_quote_for_eval_result
72810b661123Smrg        func_append compile_command " $arg"
72820b661123Smrg        func_append finalize_command " $arg"
7283880c7e28Smrg        func_append compiler_flags " $arg"
72840b661123Smrg        continue
72850b661123Smrg        ;;
728696ce994aSmrg
72874f00d7e1Smrg      -Z*)
72884f00d7e1Smrg        if test os2 = "`expr $host : '.*\(os2\)'`"; then
72894f00d7e1Smrg          # OS/2 uses -Zxxx to specify OS/2-specific options
72904f00d7e1Smrg	  compiler_flags="$compiler_flags $arg"
72914f00d7e1Smrg	  func_append compile_command " $arg"
72924f00d7e1Smrg	  func_append finalize_command " $arg"
72934f00d7e1Smrg	  case $arg in
72944f00d7e1Smrg	  -Zlinker | -Zstack)
72954f00d7e1Smrg	    prev=xcompiler
72964f00d7e1Smrg	    ;;
72974f00d7e1Smrg	  esac
72984f00d7e1Smrg	  continue
72994f00d7e1Smrg        else
73004f00d7e1Smrg	  # Otherwise treat like 'Some other compiler flag' below
73014f00d7e1Smrg	  func_quote_for_eval "$arg"
73024f00d7e1Smrg	  arg=$func_quote_for_eval_result
73034f00d7e1Smrg        fi
73044f00d7e1Smrg	;;
73054f00d7e1Smrg
73060b661123Smrg      # Some other compiler flag.
73070b661123Smrg      -* | +*)
73080b661123Smrg        func_quote_for_eval "$arg"
73094f00d7e1Smrg	arg=$func_quote_for_eval_result
73100b661123Smrg	;;
731196ce994aSmrg
73120b661123Smrg      *.$objext)
73130b661123Smrg	# A standard object.
7314880c7e28Smrg	func_append objs " $arg"
73150b661123Smrg	;;
731696ce994aSmrg
73170b661123Smrg      *.lo)
73180b661123Smrg	# A libtool-controlled object.
731996ce994aSmrg
73200b661123Smrg	# Check to see that this really is a libtool object.
73210b661123Smrg	if func_lalib_unsafe_p "$arg"; then
73220b661123Smrg	  pic_object=
73230b661123Smrg	  non_pic_object=
732496ce994aSmrg
73250b661123Smrg	  # Read the .lo file
73260b661123Smrg	  func_source "$arg"
732796ce994aSmrg
73280b661123Smrg	  if test -z "$pic_object" ||
73290b661123Smrg	     test -z "$non_pic_object" ||
73304f00d7e1Smrg	     test none = "$pic_object" &&
73314f00d7e1Smrg	     test none = "$non_pic_object"; then
73324f00d7e1Smrg	    func_fatal_error "cannot find name of object for '$arg'"
73330b661123Smrg	  fi
733496ce994aSmrg
73350b661123Smrg	  # Extract subdirectory from the argument.
73360b661123Smrg	  func_dirname "$arg" "/" ""
73374f00d7e1Smrg	  xdir=$func_dirname_result
733896ce994aSmrg
73394f00d7e1Smrg	  test none = "$pic_object" || {
73400b661123Smrg	    # Prepend the subdirectory the object is found in.
73414f00d7e1Smrg	    pic_object=$xdir$pic_object
734296ce994aSmrg
73434f00d7e1Smrg	    if test dlfiles = "$prev"; then
73444f00d7e1Smrg	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
7345880c7e28Smrg		func_append dlfiles " $pic_object"
73460b661123Smrg		prev=
73470b661123Smrg		continue
73480b661123Smrg	      else
73490b661123Smrg		# If libtool objects are unsupported, then we need to preload.
73500b661123Smrg		prev=dlprefiles
73510b661123Smrg	      fi
73520b661123Smrg	    fi
735396ce994aSmrg
73540b661123Smrg	    # CHECK ME:  I think I busted this.  -Ossama
73554f00d7e1Smrg	    if test dlprefiles = "$prev"; then
73560b661123Smrg	      # Preload the old-style object.
7357880c7e28Smrg	      func_append dlprefiles " $pic_object"
73580b661123Smrg	      prev=
73590b661123Smrg	    fi
7360bdcaa8d0Smrg
73610b661123Smrg	    # A PIC object.
73620b661123Smrg	    func_append libobjs " $pic_object"
73634f00d7e1Smrg	    arg=$pic_object
73644f00d7e1Smrg	  }
7365bdcaa8d0Smrg
73660b661123Smrg	  # Non-PIC object.
73674f00d7e1Smrg	  if test none != "$non_pic_object"; then
73680b661123Smrg	    # Prepend the subdirectory the object is found in.
73694f00d7e1Smrg	    non_pic_object=$xdir$non_pic_object
7370bdcaa8d0Smrg
73710b661123Smrg	    # A standard non-PIC object
73720b661123Smrg	    func_append non_pic_objects " $non_pic_object"
73734f00d7e1Smrg	    if test -z "$pic_object" || test none = "$pic_object"; then
73744f00d7e1Smrg	      arg=$non_pic_object
73750b661123Smrg	    fi
73760b661123Smrg	  else
73770b661123Smrg	    # If the PIC object exists, use it instead.
73780b661123Smrg	    # $xdir was prepended to $pic_object above.
73794f00d7e1Smrg	    non_pic_object=$pic_object
73800b661123Smrg	    func_append non_pic_objects " $non_pic_object"
73810b661123Smrg	  fi
73820b661123Smrg	else
73830b661123Smrg	  # Only an error if not doing a dry-run.
73840b661123Smrg	  if $opt_dry_run; then
73850b661123Smrg	    # Extract subdirectory from the argument.
73860b661123Smrg	    func_dirname "$arg" "/" ""
73874f00d7e1Smrg	    xdir=$func_dirname_result
73880b661123Smrg
73890b661123Smrg	    func_lo2o "$arg"
73900b661123Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
73910b661123Smrg	    non_pic_object=$xdir$func_lo2o_result
73920b661123Smrg	    func_append libobjs " $pic_object"
73930b661123Smrg	    func_append non_pic_objects " $non_pic_object"
73940b661123Smrg	  else
73954f00d7e1Smrg	    func_fatal_error "'$arg' is not a valid libtool object"
73960b661123Smrg	  fi
73970b661123Smrg	fi
73980b661123Smrg	;;
7399bdcaa8d0Smrg
74000b661123Smrg      *.$libext)
74010b661123Smrg	# An archive.
7402880c7e28Smrg	func_append deplibs " $arg"
7403880c7e28Smrg	func_append old_deplibs " $arg"
74040b661123Smrg	continue
74050b661123Smrg	;;
74060b661123Smrg
74070b661123Smrg      *.la)
74080b661123Smrg	# A libtool-controlled library.
74090b661123Smrg
7410880c7e28Smrg	func_resolve_sysroot "$arg"
74114f00d7e1Smrg	if test dlfiles = "$prev"; then
74120b661123Smrg	  # This library was specified with -dlopen.
7413880c7e28Smrg	  func_append dlfiles " $func_resolve_sysroot_result"
74140b661123Smrg	  prev=
74154f00d7e1Smrg	elif test dlprefiles = "$prev"; then
74160b661123Smrg	  # The library was specified with -dlpreopen.
7417880c7e28Smrg	  func_append dlprefiles " $func_resolve_sysroot_result"
74180b661123Smrg	  prev=
74190b661123Smrg	else
7420880c7e28Smrg	  func_append deplibs " $func_resolve_sysroot_result"
74210b661123Smrg	fi
74220b661123Smrg	continue
74230b661123Smrg	;;
74240b661123Smrg
74250b661123Smrg      # Some other compiler argument.
74260b661123Smrg      *)
74270b661123Smrg	# Unknown arguments in both finalize_command and compile_command need
74280b661123Smrg	# to be aesthetically quoted because they are evaled later.
74290b661123Smrg	func_quote_for_eval "$arg"
74304f00d7e1Smrg	arg=$func_quote_for_eval_result
74310b661123Smrg	;;
74320b661123Smrg      esac # arg
74330b661123Smrg
74340b661123Smrg      # Now actually substitute the argument into the commands.
74350b661123Smrg      if test -n "$arg"; then
74360b661123Smrg	func_append compile_command " $arg"
74370b661123Smrg	func_append finalize_command " $arg"
74380b661123Smrg      fi
74390b661123Smrg    done # argument parsing loop
74400b661123Smrg
74410b661123Smrg    test -n "$prev" && \
74424f00d7e1Smrg      func_fatal_help "the '$prevarg' option requires an argument"
74430b661123Smrg
74444f00d7e1Smrg    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
74450b661123Smrg      eval arg=\"$export_dynamic_flag_spec\"
74460b661123Smrg      func_append compile_command " $arg"
74470b661123Smrg      func_append finalize_command " $arg"
74480b661123Smrg    fi
74490b661123Smrg
74500b661123Smrg    oldlibs=
74510b661123Smrg    # calculate the name of the file, without its directory
74520b661123Smrg    func_basename "$output"
74534f00d7e1Smrg    outputname=$func_basename_result
74544f00d7e1Smrg    libobjs_save=$libobjs
74550b661123Smrg
74560b661123Smrg    if test -n "$shlibpath_var"; then
74570b661123Smrg      # get the directories listed in $shlibpath_var
74584f00d7e1Smrg      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
74590b661123Smrg    else
74600b661123Smrg      shlib_search_path=
74610b661123Smrg    fi
74620b661123Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
74630b661123Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
74640b661123Smrg
74654f00d7e1Smrg    # Definition is injected by LT_CONFIG during libtool generation.
74664f00d7e1Smrg    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
74674f00d7e1Smrg
74680b661123Smrg    func_dirname "$output" "/" ""
74694f00d7e1Smrg    output_objdir=$func_dirname_result$objdir
7470880c7e28Smrg    func_to_tool_file "$output_objdir/"
7471880c7e28Smrg    tool_output_objdir=$func_to_tool_file_result
74720b661123Smrg    # Create the object directory.
74730b661123Smrg    func_mkdir_p "$output_objdir"
74740b661123Smrg
74750b661123Smrg    # Determine the type of output
74760b661123Smrg    case $output in
74770b661123Smrg    "")
74780b661123Smrg      func_fatal_help "you must specify an output file"
74790b661123Smrg      ;;
74800b661123Smrg    *.$libext) linkmode=oldlib ;;
74810b661123Smrg    *.lo | *.$objext) linkmode=obj ;;
74820b661123Smrg    *.la) linkmode=lib ;;
74830b661123Smrg    *) linkmode=prog ;; # Anything else should be a program.
74840b661123Smrg    esac
74850b661123Smrg
74860b661123Smrg    specialdeplibs=
74870b661123Smrg
74880b661123Smrg    libs=
74890b661123Smrg    # Find all interdependent deplibs by searching for libraries
74900b661123Smrg    # that are linked more than once (e.g. -la -lb -la)
74910b661123Smrg    for deplib in $deplibs; do
74924f00d7e1Smrg      if $opt_preserve_dup_deps; then
74930b661123Smrg	case "$libs " in
7494880c7e28Smrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
74950b661123Smrg	esac
74960b661123Smrg      fi
7497880c7e28Smrg      func_append libs " $deplib"
74980b661123Smrg    done
74990b661123Smrg
75004f00d7e1Smrg    if test lib = "$linkmode"; then
75010b661123Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
75020b661123Smrg
75030b661123Smrg      # Compute libraries that are listed more than once in $predeps
75040b661123Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
75050b661123Smrg      # not to be eliminated).
75060b661123Smrg      pre_post_deps=
75070b661123Smrg      if $opt_duplicate_compiler_generated_deps; then
75080b661123Smrg	for pre_post_dep in $predeps $postdeps; do
75090b661123Smrg	  case "$pre_post_deps " in
7510880c7e28Smrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
75110b661123Smrg	  esac
7512880c7e28Smrg	  func_append pre_post_deps " $pre_post_dep"
75130b661123Smrg	done
75140b661123Smrg      fi
75150b661123Smrg      pre_post_deps=
75160b661123Smrg    fi
75170b661123Smrg
75180b661123Smrg    deplibs=
75190b661123Smrg    newdependency_libs=
75200b661123Smrg    newlib_search_path=
75210b661123Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
75220b661123Smrg    notinst_deplibs= # not-installed libtool libraries
75230b661123Smrg    notinst_path= # paths that contain not-installed libtool libraries
75240b661123Smrg
75250b661123Smrg    case $linkmode in
75260b661123Smrg    lib)
75270b661123Smrg	passes="conv dlpreopen link"
75280b661123Smrg	for file in $dlfiles $dlprefiles; do
75290b661123Smrg	  case $file in
75300b661123Smrg	  *.la) ;;
75310b661123Smrg	  *)
75324f00d7e1Smrg	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
75330b661123Smrg	    ;;
75340b661123Smrg	  esac
75350b661123Smrg	done
75360b661123Smrg	;;
75370b661123Smrg    prog)
75380b661123Smrg	compile_deplibs=
75390b661123Smrg	finalize_deplibs=
75404f00d7e1Smrg	alldeplibs=false
75410b661123Smrg	newdlfiles=
75420b661123Smrg	newdlprefiles=
75430b661123Smrg	passes="conv scan dlopen dlpreopen link"
75440b661123Smrg	;;
75450b661123Smrg    *)  passes="conv"
75460b661123Smrg	;;
75470b661123Smrg    esac
75480b661123Smrg
75490b661123Smrg    for pass in $passes; do
75500b661123Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
75510b661123Smrg      # so that -L comes before libs that need it for instance...
75524f00d7e1Smrg      if test lib,link = "$linkmode,$pass"; then
75530b661123Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
75540b661123Smrg	##        order, and fix it there properly
75550b661123Smrg        tmp_deplibs=
75560b661123Smrg	for deplib in $deplibs; do
75570b661123Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
75580b661123Smrg	done
75594f00d7e1Smrg	deplibs=$tmp_deplibs
75600b661123Smrg      fi
75610b661123Smrg
75624f00d7e1Smrg      if test lib,link = "$linkmode,$pass" ||
75634f00d7e1Smrg	 test prog,scan = "$linkmode,$pass"; then
75644f00d7e1Smrg	libs=$deplibs
75650b661123Smrg	deplibs=
75660b661123Smrg      fi
75674f00d7e1Smrg      if test prog = "$linkmode"; then
75680b661123Smrg	case $pass in
75694f00d7e1Smrg	dlopen) libs=$dlfiles ;;
75704f00d7e1Smrg	dlpreopen) libs=$dlprefiles ;;
75710b661123Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
75720b661123Smrg	esac
75730b661123Smrg      fi
75744f00d7e1Smrg      if test lib,dlpreopen = "$linkmode,$pass"; then
75750b661123Smrg	# Collect and forward deplibs of preopened libtool libs
75760b661123Smrg	for lib in $dlprefiles; do
75770b661123Smrg	  # Ignore non-libtool-libs
75780b661123Smrg	  dependency_libs=
7579880c7e28Smrg	  func_resolve_sysroot "$lib"
75800b661123Smrg	  case $lib in
7581880c7e28Smrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
75820b661123Smrg	  esac
75830b661123Smrg
75840b661123Smrg	  # Collect preopened libtool deplibs, except any this library
75850b661123Smrg	  # has declared as weak libs
75860b661123Smrg	  for deplib in $dependency_libs; do
7587880c7e28Smrg	    func_basename "$deplib"
7588880c7e28Smrg            deplib_base=$func_basename_result
75890b661123Smrg	    case " $weak_libs " in
75900b661123Smrg	    *" $deplib_base "*) ;;
7591880c7e28Smrg	    *) func_append deplibs " $deplib" ;;
75920b661123Smrg	    esac
75930b661123Smrg	  done
75940b661123Smrg	done
75954f00d7e1Smrg	libs=$dlprefiles
75960b661123Smrg      fi
75974f00d7e1Smrg      if test dlopen = "$pass"; then
75980b661123Smrg	# Collect dlpreopened libraries
75994f00d7e1Smrg	save_deplibs=$deplibs
76000b661123Smrg	deplibs=
76010b661123Smrg      fi
76020b661123Smrg
76030b661123Smrg      for deplib in $libs; do
76040b661123Smrg	lib=
76054f00d7e1Smrg	found=false
76060b661123Smrg	case $deplib in
7607880c7e28Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7608880c7e28Smrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
76094f00d7e1Smrg	  if test prog,link = "$linkmode,$pass"; then
76100b661123Smrg	    compile_deplibs="$deplib $compile_deplibs"
76110b661123Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
76120b661123Smrg	  else
7613880c7e28Smrg	    func_append compiler_flags " $deplib"
76144f00d7e1Smrg	    if test lib = "$linkmode"; then
76150b661123Smrg		case "$new_inherited_linker_flags " in
76160b661123Smrg		    *" $deplib "*) ;;
7617880c7e28Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
76180b661123Smrg		esac
76190b661123Smrg	    fi
76200b661123Smrg	  fi
76210b661123Smrg	  continue
76220b661123Smrg	  ;;
76230b661123Smrg	-l*)
76244f00d7e1Smrg	  if test lib != "$linkmode" && test prog != "$linkmode"; then
76254f00d7e1Smrg	    func_warning "'-l' is ignored for archives/objects"
76260b661123Smrg	    continue
76270b661123Smrg	  fi
76280b661123Smrg	  func_stripname '-l' '' "$deplib"
76290b661123Smrg	  name=$func_stripname_result
76304f00d7e1Smrg	  if test lib = "$linkmode"; then
76310b661123Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
76320b661123Smrg	  else
76330b661123Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
76340b661123Smrg	  fi
76350b661123Smrg	  for searchdir in $searchdirs; do
76360b661123Smrg	    for search_ext in .la $std_shrext .so .a; do
76370b661123Smrg	      # Search the libtool library
76384f00d7e1Smrg	      lib=$searchdir/lib$name$search_ext
76390b661123Smrg	      if test -f "$lib"; then
76404f00d7e1Smrg		if test .la = "$search_ext"; then
76414f00d7e1Smrg		  found=:
76420b661123Smrg		else
76434f00d7e1Smrg		  found=false
76440b661123Smrg		fi
76450b661123Smrg		break 2
76460b661123Smrg	      fi
76470b661123Smrg	    done
76480b661123Smrg	  done
76494f00d7e1Smrg	  if $found; then
76504f00d7e1Smrg	    # deplib is a libtool library
76510b661123Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
76520b661123Smrg	    # We need to do some special things here, and not later.
76534f00d7e1Smrg	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
76540b661123Smrg	      case " $predeps $postdeps " in
76550b661123Smrg	      *" $deplib "*)
76560b661123Smrg		if func_lalib_p "$lib"; then
76570b661123Smrg		  library_names=
76580b661123Smrg		  old_library=
76590b661123Smrg		  func_source "$lib"
76600b661123Smrg		  for l in $old_library $library_names; do
76614f00d7e1Smrg		    ll=$l
76620b661123Smrg		  done
76634f00d7e1Smrg		  if test "X$ll" = "X$old_library"; then # only static version available
76644f00d7e1Smrg		    found=false
76650b661123Smrg		    func_dirname "$lib" "" "."
76664f00d7e1Smrg		    ladir=$func_dirname_result
76670b661123Smrg		    lib=$ladir/$old_library
76684f00d7e1Smrg		    if test prog,link = "$linkmode,$pass"; then
76690b661123Smrg		      compile_deplibs="$deplib $compile_deplibs"
76700b661123Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
76710b661123Smrg		    else
76720b661123Smrg		      deplibs="$deplib $deplibs"
76734f00d7e1Smrg		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
76740b661123Smrg		    fi
76750b661123Smrg		    continue
76760b661123Smrg		  fi
76770b661123Smrg		fi
76780b661123Smrg		;;
76790b661123Smrg	      *) ;;
76800b661123Smrg	      esac
76810b661123Smrg	    fi
76824f00d7e1Smrg	  else
76834f00d7e1Smrg	    # deplib doesn't seem to be a libtool library
76844f00d7e1Smrg	    if test prog,link = "$linkmode,$pass"; then
76854f00d7e1Smrg	      compile_deplibs="$deplib $compile_deplibs"
76864f00d7e1Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
76874f00d7e1Smrg	    else
76884f00d7e1Smrg	      deplibs="$deplib $deplibs"
76894f00d7e1Smrg	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
76904f00d7e1Smrg	    fi
76914f00d7e1Smrg	    continue
76920b661123Smrg	  fi
76930b661123Smrg	  ;; # -l
76940b661123Smrg	*.ltframework)
76954f00d7e1Smrg	  if test prog,link = "$linkmode,$pass"; then
76960b661123Smrg	    compile_deplibs="$deplib $compile_deplibs"
76970b661123Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
76980b661123Smrg	  else
76990b661123Smrg	    deplibs="$deplib $deplibs"
77004f00d7e1Smrg	    if test lib = "$linkmode"; then
77010b661123Smrg		case "$new_inherited_linker_flags " in
77020b661123Smrg		    *" $deplib "*) ;;
7703880c7e28Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
77040b661123Smrg		esac
77050b661123Smrg	    fi
77060b661123Smrg	  fi
77070b661123Smrg	  continue
77080b661123Smrg	  ;;
77090b661123Smrg	-L*)
77100b661123Smrg	  case $linkmode in
77110b661123Smrg	  lib)
77120b661123Smrg	    deplibs="$deplib $deplibs"
77134f00d7e1Smrg	    test conv = "$pass" && continue
77140b661123Smrg	    newdependency_libs="$deplib $newdependency_libs"
77150b661123Smrg	    func_stripname '-L' '' "$deplib"
7716880c7e28Smrg	    func_resolve_sysroot "$func_stripname_result"
7717880c7e28Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
77180b661123Smrg	    ;;
77190b661123Smrg	  prog)
77204f00d7e1Smrg	    if test conv = "$pass"; then
77210b661123Smrg	      deplibs="$deplib $deplibs"
77220b661123Smrg	      continue
77230b661123Smrg	    fi
77244f00d7e1Smrg	    if test scan = "$pass"; then
77250b661123Smrg	      deplibs="$deplib $deplibs"
77260b661123Smrg	    else
77270b661123Smrg	      compile_deplibs="$deplib $compile_deplibs"
77280b661123Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
77290b661123Smrg	    fi
77300b661123Smrg	    func_stripname '-L' '' "$deplib"
7731880c7e28Smrg	    func_resolve_sysroot "$func_stripname_result"
7732880c7e28Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
77330b661123Smrg	    ;;
77340b661123Smrg	  *)
77354f00d7e1Smrg	    func_warning "'-L' is ignored for archives/objects"
77360b661123Smrg	    ;;
77370b661123Smrg	  esac # linkmode
77380b661123Smrg	  continue
77390b661123Smrg	  ;; # -L
77400b661123Smrg	-R*)
77414f00d7e1Smrg	  if test link = "$pass"; then
77420b661123Smrg	    func_stripname '-R' '' "$deplib"
7743880c7e28Smrg	    func_resolve_sysroot "$func_stripname_result"
7744880c7e28Smrg	    dir=$func_resolve_sysroot_result
77450b661123Smrg	    # Make sure the xrpath contains only unique directories.
77460b661123Smrg	    case "$xrpath " in
77470b661123Smrg	    *" $dir "*) ;;
7748880c7e28Smrg	    *) func_append xrpath " $dir" ;;
77490b661123Smrg	    esac
77500b661123Smrg	  fi
77510b661123Smrg	  deplibs="$deplib $deplibs"
77520b661123Smrg	  continue
77530b661123Smrg	  ;;
7754880c7e28Smrg	*.la)
7755880c7e28Smrg	  func_resolve_sysroot "$deplib"
7756880c7e28Smrg	  lib=$func_resolve_sysroot_result
7757880c7e28Smrg	  ;;
77580b661123Smrg	*.$libext)
77594f00d7e1Smrg	  if test conv = "$pass"; then
77600b661123Smrg	    deplibs="$deplib $deplibs"
77610b661123Smrg	    continue
77620b661123Smrg	  fi
77630b661123Smrg	  case $linkmode in
77640b661123Smrg	  lib)
77650b661123Smrg	    # Linking convenience modules into shared libraries is allowed,
77660b661123Smrg	    # but linking other static libraries is non-portable.
77670b661123Smrg	    case " $dlpreconveniencelibs " in
77680b661123Smrg	    *" $deplib "*) ;;
77690b661123Smrg	    *)
77704f00d7e1Smrg	      valid_a_lib=false
77710b661123Smrg	      case $deplibs_check_method in
77720b661123Smrg		match_pattern*)
77730b661123Smrg		  set dummy $deplibs_check_method; shift
77740b661123Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7775880c7e28Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
77760b661123Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
77774f00d7e1Smrg		    valid_a_lib=:
77780b661123Smrg		  fi
77790b661123Smrg		;;
77800b661123Smrg		pass_all)
77814f00d7e1Smrg		  valid_a_lib=:
77820b661123Smrg		;;
77830b661123Smrg	      esac
77844f00d7e1Smrg	      if $valid_a_lib; then
77854f00d7e1Smrg		echo
77864f00d7e1Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
77874f00d7e1Smrg		$ECHO "*** static library $deplib is not portable!"
77884f00d7e1Smrg		deplibs="$deplib $deplibs"
77894f00d7e1Smrg	      else
7790880c7e28Smrg		echo
77910b661123Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
7792880c7e28Smrg		echo "*** I have the capability to make that library automatically link in when"
7793880c7e28Smrg		echo "*** you link to this library.  But I can only do this if you have a"
7794880c7e28Smrg		echo "*** shared version of the library, which you do not appear to have"
7795880c7e28Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
7796880c7e28Smrg		echo "*** that it is just a static archive that I should not use here."
77970b661123Smrg	      fi
77980b661123Smrg	      ;;
77990b661123Smrg	    esac
78000b661123Smrg	    continue
78010b661123Smrg	    ;;
78020b661123Smrg	  prog)
78034f00d7e1Smrg	    if test link != "$pass"; then
78040b661123Smrg	      deplibs="$deplib $deplibs"
78050b661123Smrg	    else
78060b661123Smrg	      compile_deplibs="$deplib $compile_deplibs"
78070b661123Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
78080b661123Smrg	    fi
78090b661123Smrg	    continue
78100b661123Smrg	    ;;
78110b661123Smrg	  esac # linkmode
78120b661123Smrg	  ;; # *.$libext
78130b661123Smrg	*.lo | *.$objext)
78144f00d7e1Smrg	  if test conv = "$pass"; then
78150b661123Smrg	    deplibs="$deplib $deplibs"
78164f00d7e1Smrg	  elif test prog = "$linkmode"; then
78174f00d7e1Smrg	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
78180b661123Smrg	      # If there is no dlopen support or we're linking statically,
78190b661123Smrg	      # we need to preload.
7820880c7e28Smrg	      func_append newdlprefiles " $deplib"
78210b661123Smrg	      compile_deplibs="$deplib $compile_deplibs"
78220b661123Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
78230b661123Smrg	    else
7824880c7e28Smrg	      func_append newdlfiles " $deplib"
78250b661123Smrg	    fi
78260b661123Smrg	  fi
78270b661123Smrg	  continue
78280b661123Smrg	  ;;
78290b661123Smrg	%DEPLIBS%)
78304f00d7e1Smrg	  alldeplibs=:
78310b661123Smrg	  continue
78320b661123Smrg	  ;;
78330b661123Smrg	esac # case $deplib
78340b661123Smrg
78354f00d7e1Smrg	$found || test -f "$lib" \
78364f00d7e1Smrg	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
78370b661123Smrg
78380b661123Smrg	# Check to see that this really is a libtool archive.
78390b661123Smrg	func_lalib_unsafe_p "$lib" \
78404f00d7e1Smrg	  || func_fatal_error "'$lib' is not a valid libtool archive"
78410b661123Smrg
78420b661123Smrg	func_dirname "$lib" "" "."
78434f00d7e1Smrg	ladir=$func_dirname_result
78440b661123Smrg
78450b661123Smrg	dlname=
78460b661123Smrg	dlopen=
78470b661123Smrg	dlpreopen=
78480b661123Smrg	libdir=
78490b661123Smrg	library_names=
78500b661123Smrg	old_library=
78510b661123Smrg	inherited_linker_flags=
78520b661123Smrg	# If the library was installed with an old release of libtool,
78530b661123Smrg	# it will not redefine variables installed, or shouldnotlink
78540b661123Smrg	installed=yes
78550b661123Smrg	shouldnotlink=no
78560b661123Smrg	avoidtemprpath=
78570b661123Smrg
78580b661123Smrg
78590b661123Smrg	# Read the .la file
78600b661123Smrg	func_source "$lib"
78610b661123Smrg
78620b661123Smrg	# Convert "-framework foo" to "foo.ltframework"
78630b661123Smrg	if test -n "$inherited_linker_flags"; then
7864880c7e28Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
78650b661123Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
78660b661123Smrg	    case " $new_inherited_linker_flags " in
78670b661123Smrg	      *" $tmp_inherited_linker_flag "*) ;;
7868880c7e28Smrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
78690b661123Smrg	    esac
78700b661123Smrg	  done
78710b661123Smrg	fi
7872880c7e28Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
78734f00d7e1Smrg	if test lib,link = "$linkmode,$pass" ||
78744f00d7e1Smrg	   test prog,scan = "$linkmode,$pass" ||
78754f00d7e1Smrg	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
7876880c7e28Smrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
7877880c7e28Smrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
78780b661123Smrg	fi
78790b661123Smrg
78804f00d7e1Smrg	if test conv = "$pass"; then
78810b661123Smrg	  # Only check for convenience libraries
78820b661123Smrg	  deplibs="$lib $deplibs"
78830b661123Smrg	  if test -z "$libdir"; then
78840b661123Smrg	    if test -z "$old_library"; then
78854f00d7e1Smrg	      func_fatal_error "cannot find name of link library for '$lib'"
78860b661123Smrg	    fi
78870b661123Smrg	    # It is a libtool convenience library, so add in its objects.
7888880c7e28Smrg	    func_append convenience " $ladir/$objdir/$old_library"
7889880c7e28Smrg	    func_append old_convenience " $ladir/$objdir/$old_library"
78904f00d7e1Smrg	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
78914f00d7e1Smrg	    func_fatal_error "'$lib' is not a convenience library"
78920b661123Smrg	  fi
78930b661123Smrg	  tmp_libs=
78940b661123Smrg	  for deplib in $dependency_libs; do
78950b661123Smrg	    deplibs="$deplib $deplibs"
78964f00d7e1Smrg	    if $opt_preserve_dup_deps; then
78970b661123Smrg	      case "$tmp_libs " in
7898880c7e28Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
78990b661123Smrg	      esac
79000b661123Smrg	    fi
7901880c7e28Smrg	    func_append tmp_libs " $deplib"
79020b661123Smrg	  done
79030b661123Smrg	  continue
79040b661123Smrg	fi # $pass = conv
79050b661123Smrg
79060b661123Smrg
79070b661123Smrg	# Get the name of the library we link against.
79080b661123Smrg	linklib=
7909880c7e28Smrg	if test -n "$old_library" &&
79104f00d7e1Smrg	   { test yes = "$prefer_static_libs" ||
79114f00d7e1Smrg	     test built,no = "$prefer_static_libs,$installed"; }; then
7912880c7e28Smrg	  linklib=$old_library
7913880c7e28Smrg	else
7914880c7e28Smrg	  for l in $old_library $library_names; do
79154f00d7e1Smrg	    linklib=$l
7916880c7e28Smrg	  done
7917880c7e28Smrg	fi
79180b661123Smrg	if test -z "$linklib"; then
79194f00d7e1Smrg	  func_fatal_error "cannot find name of link library for '$lib'"
79200b661123Smrg	fi
79210b661123Smrg
79220b661123Smrg	# This library was specified with -dlopen.
79234f00d7e1Smrg	if test dlopen = "$pass"; then
79244f00d7e1Smrg	  test -z "$libdir" \
79254f00d7e1Smrg	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
79260b661123Smrg	  if test -z "$dlname" ||
79274f00d7e1Smrg	     test yes != "$dlopen_support" ||
79284f00d7e1Smrg	     test no = "$build_libtool_libs"
79294f00d7e1Smrg	  then
79300b661123Smrg	    # If there is no dlname, no dlopen support or we're linking
79310b661123Smrg	    # statically, we need to preload.  We also need to preload any
79320b661123Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
79330b661123Smrg	    # bomb out in the load deplibs phase.
7934880c7e28Smrg	    func_append dlprefiles " $lib $dependency_libs"
79350b661123Smrg	  else
7936880c7e28Smrg	    func_append newdlfiles " $lib"
79370b661123Smrg	  fi
79380b661123Smrg	  continue
79390b661123Smrg	fi # $pass = dlopen
79400b661123Smrg
79410b661123Smrg	# We need an absolute path.
79420b661123Smrg	case $ladir in
79434f00d7e1Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
79440b661123Smrg	*)
79450b661123Smrg	  abs_ladir=`cd "$ladir" && pwd`
79460b661123Smrg	  if test -z "$abs_ladir"; then
79474f00d7e1Smrg	    func_warning "cannot determine absolute directory name of '$ladir'"
79480b661123Smrg	    func_warning "passing it literally to the linker, although it might fail"
79494f00d7e1Smrg	    abs_ladir=$ladir
79500b661123Smrg	  fi
79510b661123Smrg	  ;;
79520b661123Smrg	esac
79530b661123Smrg	func_basename "$lib"
79544f00d7e1Smrg	laname=$func_basename_result
79550b661123Smrg
79560b661123Smrg	# Find the relevant object directory and library name.
79574f00d7e1Smrg	if test yes = "$installed"; then
7958880c7e28Smrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
79594f00d7e1Smrg	    func_warning "library '$lib' was moved."
79604f00d7e1Smrg	    dir=$ladir
79614f00d7e1Smrg	    absdir=$abs_ladir
79624f00d7e1Smrg	    libdir=$abs_ladir
79630b661123Smrg	  else
79644f00d7e1Smrg	    dir=$lt_sysroot$libdir
79654f00d7e1Smrg	    absdir=$lt_sysroot$libdir
79660b661123Smrg	  fi
79674f00d7e1Smrg	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
79680b661123Smrg	else
79690b661123Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
79704f00d7e1Smrg	    dir=$ladir
79714f00d7e1Smrg	    absdir=$abs_ladir
79720b661123Smrg	    # Remove this search path later
7973880c7e28Smrg	    func_append notinst_path " $abs_ladir"
79740b661123Smrg	  else
79754f00d7e1Smrg	    dir=$ladir/$objdir
79764f00d7e1Smrg	    absdir=$abs_ladir/$objdir
79770b661123Smrg	    # Remove this search path later
7978880c7e28Smrg	    func_append notinst_path " $abs_ladir"
79790b661123Smrg	  fi
79800b661123Smrg	fi # $installed = yes
79810b661123Smrg	func_stripname 'lib' '.la' "$laname"
79820b661123Smrg	name=$func_stripname_result
79830b661123Smrg
79840b661123Smrg	# This library was specified with -dlpreopen.
79854f00d7e1Smrg	if test dlpreopen = "$pass"; then
79864f00d7e1Smrg	  if test -z "$libdir" && test prog = "$linkmode"; then
79874f00d7e1Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
79880b661123Smrg	  fi
79894f00d7e1Smrg	  case $host in
7990880c7e28Smrg	    # special handling for platforms with PE-DLLs.
7991880c7e28Smrg	    *cygwin* | *mingw* | *cegcc* )
7992880c7e28Smrg	      # Linker will automatically link against shared library if both
7993880c7e28Smrg	      # static and shared are present.  Therefore, ensure we extract
7994880c7e28Smrg	      # symbols from the import library if a shared library is present
7995880c7e28Smrg	      # (otherwise, the dlopen module name will be incorrect).  We do
7996880c7e28Smrg	      # this by putting the import library name into $newdlprefiles.
7997880c7e28Smrg	      # We recover the dlopen module name by 'saving' the la file
7998880c7e28Smrg	      # name in a special purpose variable, and (later) extracting the
7999880c7e28Smrg	      # dlname from the la file.
8000880c7e28Smrg	      if test -n "$dlname"; then
8001880c7e28Smrg	        func_tr_sh "$dir/$linklib"
8002880c7e28Smrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
8003880c7e28Smrg	        func_append newdlprefiles " $dir/$linklib"
8004880c7e28Smrg	      else
8005880c7e28Smrg	        func_append newdlprefiles " $dir/$old_library"
8006880c7e28Smrg	        # Keep a list of preopened convenience libraries to check
8007880c7e28Smrg	        # that they are being used correctly in the link pass.
8008880c7e28Smrg	        test -z "$libdir" && \
8009880c7e28Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8010880c7e28Smrg	      fi
8011880c7e28Smrg	    ;;
8012880c7e28Smrg	    * )
8013880c7e28Smrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
8014880c7e28Smrg	      # are required to link).
8015880c7e28Smrg	      if test -n "$old_library"; then
8016880c7e28Smrg	        func_append newdlprefiles " $dir/$old_library"
8017880c7e28Smrg	        # Keep a list of preopened convenience libraries to check
8018880c7e28Smrg	        # that they are being used correctly in the link pass.
8019880c7e28Smrg	        test -z "$libdir" && \
8020880c7e28Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8021880c7e28Smrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
8022880c7e28Smrg	      elif test -n "$dlname"; then
8023880c7e28Smrg	        func_append newdlprefiles " $dir/$dlname"
8024880c7e28Smrg	      else
8025880c7e28Smrg	        func_append newdlprefiles " $dir/$linklib"
8026880c7e28Smrg	      fi
8027880c7e28Smrg	    ;;
8028880c7e28Smrg	  esac
80290b661123Smrg	fi # $pass = dlpreopen
80300b661123Smrg
80310b661123Smrg	if test -z "$libdir"; then
80320b661123Smrg	  # Link the convenience library
80334f00d7e1Smrg	  if test lib = "$linkmode"; then
80340b661123Smrg	    deplibs="$dir/$old_library $deplibs"
80354f00d7e1Smrg	  elif test prog,link = "$linkmode,$pass"; then
80360b661123Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
80370b661123Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
80380b661123Smrg	  else
80390b661123Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
80400b661123Smrg	  fi
80410b661123Smrg	  continue
80420b661123Smrg	fi
80430b661123Smrg
80440b661123Smrg
80454f00d7e1Smrg	if test prog = "$linkmode" && test link != "$pass"; then
8046880c7e28Smrg	  func_append newlib_search_path " $ladir"
80470b661123Smrg	  deplibs="$lib $deplibs"
80480b661123Smrg
80494f00d7e1Smrg	  linkalldeplibs=false
80504f00d7e1Smrg	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
80514f00d7e1Smrg	     test no = "$build_libtool_libs"; then
80524f00d7e1Smrg	    linkalldeplibs=:
80530b661123Smrg	  fi
80540b661123Smrg
80550b661123Smrg	  tmp_libs=
80560b661123Smrg	  for deplib in $dependency_libs; do
80570b661123Smrg	    case $deplib in
80580b661123Smrg	    -L*) func_stripname '-L' '' "$deplib"
8059880c7e28Smrg	         func_resolve_sysroot "$func_stripname_result"
8060880c7e28Smrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
80610b661123Smrg		 ;;
80620b661123Smrg	    esac
80630b661123Smrg	    # Need to link against all dependency_libs?
80644f00d7e1Smrg	    if $linkalldeplibs; then
80650b661123Smrg	      deplibs="$deplib $deplibs"
80660b661123Smrg	    else
80670b661123Smrg	      # Need to hardcode shared library paths
80680b661123Smrg	      # or/and link against static libraries
80690b661123Smrg	      newdependency_libs="$deplib $newdependency_libs"
80700b661123Smrg	    fi
80714f00d7e1Smrg	    if $opt_preserve_dup_deps; then
80720b661123Smrg	      case "$tmp_libs " in
8073880c7e28Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
80740b661123Smrg	      esac
80750b661123Smrg	    fi
8076880c7e28Smrg	    func_append tmp_libs " $deplib"
80770b661123Smrg	  done # for deplib
80780b661123Smrg	  continue
80790b661123Smrg	fi # $linkmode = prog...
80800b661123Smrg
80814f00d7e1Smrg	if test prog,link = "$linkmode,$pass"; then
80820b661123Smrg	  if test -n "$library_names" &&
80834f00d7e1Smrg	     { { test no = "$prefer_static_libs" ||
80844f00d7e1Smrg	         test built,yes = "$prefer_static_libs,$installed"; } ||
80850b661123Smrg	       test -z "$old_library"; }; then
80860b661123Smrg	    # We need to hardcode the library path
80874f00d7e1Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
80880b661123Smrg	      # Make sure the rpath contains only unique directories.
80894f00d7e1Smrg	      case $temp_rpath: in
80900b661123Smrg	      *"$absdir:"*) ;;
8091880c7e28Smrg	      *) func_append temp_rpath "$absdir:" ;;
80920b661123Smrg	      esac
80930b661123Smrg	    fi
80940b661123Smrg
80950b661123Smrg	    # Hardcode the library path.
80960b661123Smrg	    # Skip directories that are in the system default run-time
80970b661123Smrg	    # search path.
80980b661123Smrg	    case " $sys_lib_dlsearch_path " in
80990b661123Smrg	    *" $absdir "*) ;;
81000b661123Smrg	    *)
81010b661123Smrg	      case "$compile_rpath " in
81020b661123Smrg	      *" $absdir "*) ;;
8103880c7e28Smrg	      *) func_append compile_rpath " $absdir" ;;
81040b661123Smrg	      esac
81050b661123Smrg	      ;;
81060b661123Smrg	    esac
81070b661123Smrg	    case " $sys_lib_dlsearch_path " in
81080b661123Smrg	    *" $libdir "*) ;;
81090b661123Smrg	    *)
81100b661123Smrg	      case "$finalize_rpath " in
81110b661123Smrg	      *" $libdir "*) ;;
8112880c7e28Smrg	      *) func_append finalize_rpath " $libdir" ;;
81130b661123Smrg	      esac
81140b661123Smrg	      ;;
81150b661123Smrg	    esac
81160b661123Smrg	  fi # $linkmode,$pass = prog,link...
81170b661123Smrg
81184f00d7e1Smrg	  if $alldeplibs &&
81194f00d7e1Smrg	     { test pass_all = "$deplibs_check_method" ||
81204f00d7e1Smrg	       { test yes = "$build_libtool_libs" &&
81210b661123Smrg		 test -n "$library_names"; }; }; then
81220b661123Smrg	    # We only need to search for static libraries
81230b661123Smrg	    continue
81240b661123Smrg	  fi
81250b661123Smrg	fi
81260b661123Smrg
81270b661123Smrg	link_static=no # Whether the deplib will be linked statically
81280b661123Smrg	use_static_libs=$prefer_static_libs
81294f00d7e1Smrg	if test built = "$use_static_libs" && test yes = "$installed"; then
81300b661123Smrg	  use_static_libs=no
81310b661123Smrg	fi
81320b661123Smrg	if test -n "$library_names" &&
81334f00d7e1Smrg	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
81340b661123Smrg	  case $host in
81354f00d7e1Smrg	  *cygwin* | *mingw* | *cegcc* | *os2*)
81360b661123Smrg	      # No point in relinking DLLs because paths are not encoded
8137880c7e28Smrg	      func_append notinst_deplibs " $lib"
81380b661123Smrg	      need_relink=no
81390b661123Smrg	    ;;
81400b661123Smrg	  *)
81414f00d7e1Smrg	    if test no = "$installed"; then
8142880c7e28Smrg	      func_append notinst_deplibs " $lib"
81430b661123Smrg	      need_relink=yes
81440b661123Smrg	    fi
81450b661123Smrg	    ;;
81460b661123Smrg	  esac
81470b661123Smrg	  # This is a shared library
81480b661123Smrg
81490b661123Smrg	  # Warn about portability, can't link against -module's on some
81500b661123Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
81514f00d7e1Smrg	  dlopenmodule=
81520b661123Smrg	  for dlpremoduletest in $dlprefiles; do
81530b661123Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
81544f00d7e1Smrg	      dlopenmodule=$dlpremoduletest
81550b661123Smrg	      break
81560b661123Smrg	    fi
81570b661123Smrg	  done
81584f00d7e1Smrg	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
8159880c7e28Smrg	    echo
81604f00d7e1Smrg	    if test prog = "$linkmode"; then
81610b661123Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
81620b661123Smrg	    else
81630b661123Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
81640b661123Smrg	    fi
81650b661123Smrg	    $ECHO "*** $linklib is not portable!"
81660b661123Smrg	  fi
81674f00d7e1Smrg	  if test lib = "$linkmode" &&
81684f00d7e1Smrg	     test yes = "$hardcode_into_libs"; then
81690b661123Smrg	    # Hardcode the library path.
81700b661123Smrg	    # Skip directories that are in the system default run-time
81710b661123Smrg	    # search path.
81720b661123Smrg	    case " $sys_lib_dlsearch_path " in
81730b661123Smrg	    *" $absdir "*) ;;
81740b661123Smrg	    *)
81750b661123Smrg	      case "$compile_rpath " in
81760b661123Smrg	      *" $absdir "*) ;;
8177880c7e28Smrg	      *) func_append compile_rpath " $absdir" ;;
81780b661123Smrg	      esac
81790b661123Smrg	      ;;
81800b661123Smrg	    esac
81810b661123Smrg	    case " $sys_lib_dlsearch_path " in
81820b661123Smrg	    *" $libdir "*) ;;
81830b661123Smrg	    *)
81840b661123Smrg	      case "$finalize_rpath " in
81850b661123Smrg	      *" $libdir "*) ;;
8186880c7e28Smrg	      *) func_append finalize_rpath " $libdir" ;;
81870b661123Smrg	      esac
81880b661123Smrg	      ;;
81890b661123Smrg	    esac
81900b661123Smrg	  fi
81910b661123Smrg
81920b661123Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
81930b661123Smrg	    # figure out the soname
81940b661123Smrg	    set dummy $library_names
81950b661123Smrg	    shift
81964f00d7e1Smrg	    realname=$1
81970b661123Smrg	    shift
81980b661123Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
81990b661123Smrg	    # use dlname if we got it. it's perfectly good, no?
82000b661123Smrg	    if test -n "$dlname"; then
82014f00d7e1Smrg	      soname=$dlname
82020b661123Smrg	    elif test -n "$soname_spec"; then
82030b661123Smrg	      # bleh windows
82040b661123Smrg	      case $host in
82054f00d7e1Smrg	      *cygwin* | mingw* | *cegcc* | *os2*)
82060b661123Smrg	        func_arith $current - $age
82070b661123Smrg		major=$func_arith_result
82084f00d7e1Smrg		versuffix=-$major
82090b661123Smrg		;;
82100b661123Smrg	      esac
82110b661123Smrg	      eval soname=\"$soname_spec\"
82120b661123Smrg	    else
82134f00d7e1Smrg	      soname=$realname
82140b661123Smrg	    fi
82150b661123Smrg
82160b661123Smrg	    # Make a new name for the extract_expsyms_cmds to use
82174f00d7e1Smrg	    soroot=$soname
82180b661123Smrg	    func_basename "$soroot"
82194f00d7e1Smrg	    soname=$func_basename_result
82200b661123Smrg	    func_stripname 'lib' '.dll' "$soname"
82210b661123Smrg	    newlib=libimp-$func_stripname_result.a
82220b661123Smrg
82230b661123Smrg	    # If the library has no export list, then create one now
82240b661123Smrg	    if test -f "$output_objdir/$soname-def"; then :
82250b661123Smrg	    else
82264f00d7e1Smrg	      func_verbose "extracting exported symbol list from '$soname'"
82270b661123Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
82280b661123Smrg	    fi
82290b661123Smrg
82300b661123Smrg	    # Create $newlib
82310b661123Smrg	    if test -f "$output_objdir/$newlib"; then :; else
82324f00d7e1Smrg	      func_verbose "generating import library for '$soname'"
82330b661123Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
82340b661123Smrg	    fi
82350b661123Smrg	    # make sure the library variables are pointing to the new library
82360b661123Smrg	    dir=$output_objdir
82370b661123Smrg	    linklib=$newlib
82380b661123Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
82390b661123Smrg
82404f00d7e1Smrg	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
82410b661123Smrg	    add_shlibpath=
82420b661123Smrg	    add_dir=
82430b661123Smrg	    add=
82440b661123Smrg	    lib_linked=yes
82450b661123Smrg	    case $hardcode_action in
82460b661123Smrg	    immediate | unsupported)
82474f00d7e1Smrg	      if test no = "$hardcode_direct"; then
82484f00d7e1Smrg		add=$dir/$linklib
82490b661123Smrg		case $host in
82504f00d7e1Smrg		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
82514f00d7e1Smrg		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
82520b661123Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
82534f00d7e1Smrg		    *-*-unixware7*) add_dir=-L$dir ;;
82540b661123Smrg		  *-*-darwin* )
82554f00d7e1Smrg		    # if the lib is a (non-dlopened) module then we cannot
82560b661123Smrg		    # link against it, someone is ignoring the earlier warnings
82570b661123Smrg		    if /usr/bin/file -L $add 2> /dev/null |
82584f00d7e1Smrg			 $GREP ": [^:]* bundle" >/dev/null; then
82590b661123Smrg		      if test "X$dlopenmodule" != "X$lib"; then
82600b661123Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
82614f00d7e1Smrg			if test -z "$old_library"; then
8262880c7e28Smrg			  echo
8263880c7e28Smrg			  echo "*** And there doesn't seem to be a static archive available"
8264880c7e28Smrg			  echo "*** The link will probably fail, sorry"
82650b661123Smrg			else
82664f00d7e1Smrg			  add=$dir/$old_library
82670b661123Smrg			fi
82680b661123Smrg		      elif test -n "$old_library"; then
82694f00d7e1Smrg			add=$dir/$old_library
82700b661123Smrg		      fi
82710b661123Smrg		    fi
82720b661123Smrg		esac
82734f00d7e1Smrg	      elif test no = "$hardcode_minus_L"; then
82740b661123Smrg		case $host in
82754f00d7e1Smrg		*-*-sunos*) add_shlibpath=$dir ;;
82760b661123Smrg		esac
82774f00d7e1Smrg		add_dir=-L$dir
82784f00d7e1Smrg		add=-l$name
82794f00d7e1Smrg	      elif test no = "$hardcode_shlibpath_var"; then
82804f00d7e1Smrg		add_shlibpath=$dir
82814f00d7e1Smrg		add=-l$name
82820b661123Smrg	      else
82830b661123Smrg		lib_linked=no
82840b661123Smrg	      fi
82850b661123Smrg	      ;;
82860b661123Smrg	    relink)
82874f00d7e1Smrg	      if test yes = "$hardcode_direct" &&
82884f00d7e1Smrg	         test no = "$hardcode_direct_absolute"; then
82894f00d7e1Smrg		add=$dir/$linklib
82904f00d7e1Smrg	      elif test yes = "$hardcode_minus_L"; then
82914f00d7e1Smrg		add_dir=-L$absdir
82920b661123Smrg		# Try looking first in the location we're being installed to.
82930b661123Smrg		if test -n "$inst_prefix_dir"; then
82940b661123Smrg		  case $libdir in
82950b661123Smrg		    [\\/]*)
8296880c7e28Smrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
82970b661123Smrg		      ;;
82980b661123Smrg		  esac
82990b661123Smrg		fi
83004f00d7e1Smrg		add=-l$name
83014f00d7e1Smrg	      elif test yes = "$hardcode_shlibpath_var"; then
83024f00d7e1Smrg		add_shlibpath=$dir
83034f00d7e1Smrg		add=-l$name
83040b661123Smrg	      else
83050b661123Smrg		lib_linked=no
83060b661123Smrg	      fi
83070b661123Smrg	      ;;
83080b661123Smrg	    *) lib_linked=no ;;
83090b661123Smrg	    esac
83100b661123Smrg
83114f00d7e1Smrg	    if test yes != "$lib_linked"; then
83120b661123Smrg	      func_fatal_configuration "unsupported hardcode properties"
83130b661123Smrg	    fi
83140b661123Smrg
83150b661123Smrg	    if test -n "$add_shlibpath"; then
83160b661123Smrg	      case :$compile_shlibpath: in
83170b661123Smrg	      *":$add_shlibpath:"*) ;;
8318880c7e28Smrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
83190b661123Smrg	      esac
83200b661123Smrg	    fi
83214f00d7e1Smrg	    if test prog = "$linkmode"; then
83220b661123Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
83230b661123Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
83240b661123Smrg	    else
83250b661123Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
83260b661123Smrg	      test -n "$add" && deplibs="$add $deplibs"
83274f00d7e1Smrg	      if test yes != "$hardcode_direct" &&
83284f00d7e1Smrg		 test yes != "$hardcode_minus_L" &&
83294f00d7e1Smrg		 test yes = "$hardcode_shlibpath_var"; then
83300b661123Smrg		case :$finalize_shlibpath: in
83310b661123Smrg		*":$libdir:"*) ;;
8332880c7e28Smrg		*) func_append finalize_shlibpath "$libdir:" ;;
83330b661123Smrg		esac
83340b661123Smrg	      fi
83350b661123Smrg	    fi
83360b661123Smrg	  fi
83370b661123Smrg
83384f00d7e1Smrg	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
83390b661123Smrg	    add_shlibpath=
83400b661123Smrg	    add_dir=
83410b661123Smrg	    add=
83420b661123Smrg	    # Finalize command for both is simple: just hardcode it.
83434f00d7e1Smrg	    if test yes = "$hardcode_direct" &&
83444f00d7e1Smrg	       test no = "$hardcode_direct_absolute"; then
83454f00d7e1Smrg	      add=$libdir/$linklib
83464f00d7e1Smrg	    elif test yes = "$hardcode_minus_L"; then
83474f00d7e1Smrg	      add_dir=-L$libdir
83484f00d7e1Smrg	      add=-l$name
83494f00d7e1Smrg	    elif test yes = "$hardcode_shlibpath_var"; then
83500b661123Smrg	      case :$finalize_shlibpath: in
83510b661123Smrg	      *":$libdir:"*) ;;
8352880c7e28Smrg	      *) func_append finalize_shlibpath "$libdir:" ;;
83530b661123Smrg	      esac
83544f00d7e1Smrg	      add=-l$name
83554f00d7e1Smrg	    elif test yes = "$hardcode_automatic"; then
83560b661123Smrg	      if test -n "$inst_prefix_dir" &&
83574f00d7e1Smrg		 test -f "$inst_prefix_dir$libdir/$linklib"; then
83584f00d7e1Smrg		add=$inst_prefix_dir$libdir/$linklib
83590b661123Smrg	      else
83604f00d7e1Smrg		add=$libdir/$linklib
83610b661123Smrg	      fi
83620b661123Smrg	    else
83630b661123Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
83644f00d7e1Smrg	      add_dir=-L$libdir
83650b661123Smrg	      # Try looking first in the location we're being installed to.
83660b661123Smrg	      if test -n "$inst_prefix_dir"; then
83670b661123Smrg		case $libdir in
83680b661123Smrg		  [\\/]*)
8369880c7e28Smrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
83700b661123Smrg		    ;;
83710b661123Smrg		esac
83720b661123Smrg	      fi
83734f00d7e1Smrg	      add=-l$name
83740b661123Smrg	    fi
83750b661123Smrg
83764f00d7e1Smrg	    if test prog = "$linkmode"; then
83770b661123Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
83780b661123Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
83790b661123Smrg	    else
83800b661123Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
83810b661123Smrg	      test -n "$add" && deplibs="$add $deplibs"
83820b661123Smrg	    fi
83830b661123Smrg	  fi
83844f00d7e1Smrg	elif test prog = "$linkmode"; then
83850b661123Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
83860b661123Smrg	  # is not unsupported.  This is valid on all known static and
83870b661123Smrg	  # shared platforms.
83884f00d7e1Smrg	  if test unsupported != "$hardcode_direct"; then
83894f00d7e1Smrg	    test -n "$old_library" && linklib=$old_library
83900b661123Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
83910b661123Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
83920b661123Smrg	  else
83930b661123Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
83940b661123Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
83950b661123Smrg	  fi
83964f00d7e1Smrg	elif test yes = "$build_libtool_libs"; then
83970b661123Smrg	  # Not a shared library
83984f00d7e1Smrg	  if test pass_all != "$deplibs_check_method"; then
83990b661123Smrg	    # We're trying link a shared library against a static one
84000b661123Smrg	    # but the system doesn't support it.
84010b661123Smrg
84020b661123Smrg	    # Just print a warning and add the library to dependency_libs so
84030b661123Smrg	    # that the program can be linked against the static library.
8404880c7e28Smrg	    echo
84054f00d7e1Smrg	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
8406880c7e28Smrg	    echo "*** I have the capability to make that library automatically link in when"
8407880c7e28Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
8408880c7e28Smrg	    echo "*** shared version of the library, which you do not appear to have."
84094f00d7e1Smrg	    if test yes = "$module"; then
8410880c7e28Smrg	      echo "*** But as you try to build a module library, libtool will still create "
8411880c7e28Smrg	      echo "*** a static module, that should work as long as the dlopening application"
8412880c7e28Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
84130b661123Smrg	      if test -z "$global_symbol_pipe"; then
8414880c7e28Smrg		echo
8415880c7e28Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
84164f00d7e1Smrg		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
8417880c7e28Smrg		echo "*** not find such a program.  So, this module is probably useless."
84184f00d7e1Smrg		echo "*** 'nm' from GNU binutils and a full rebuild may help."
84190b661123Smrg	      fi
84204f00d7e1Smrg	      if test no = "$build_old_libs"; then
84210b661123Smrg		build_libtool_libs=module
84220b661123Smrg		build_old_libs=yes
84230b661123Smrg	      else
84240b661123Smrg		build_libtool_libs=no
84250b661123Smrg	      fi
84260b661123Smrg	    fi
84270b661123Smrg	  else
84280b661123Smrg	    deplibs="$dir/$old_library $deplibs"
84290b661123Smrg	    link_static=yes
84300b661123Smrg	  fi
84310b661123Smrg	fi # link shared/static library?
84320b661123Smrg
84334f00d7e1Smrg	if test lib = "$linkmode"; then
84340b661123Smrg	  if test -n "$dependency_libs" &&
84354f00d7e1Smrg	     { test yes != "$hardcode_into_libs" ||
84364f00d7e1Smrg	       test yes = "$build_old_libs" ||
84374f00d7e1Smrg	       test yes = "$link_static"; }; then
84380b661123Smrg	    # Extract -R from dependency_libs
84390b661123Smrg	    temp_deplibs=
84400b661123Smrg	    for libdir in $dependency_libs; do
84410b661123Smrg	      case $libdir in
84420b661123Smrg	      -R*) func_stripname '-R' '' "$libdir"
84430b661123Smrg	           temp_xrpath=$func_stripname_result
84440b661123Smrg		   case " $xrpath " in
84450b661123Smrg		   *" $temp_xrpath "*) ;;
8446880c7e28Smrg		   *) func_append xrpath " $temp_xrpath";;
84470b661123Smrg		   esac;;
8448880c7e28Smrg	      *) func_append temp_deplibs " $libdir";;
84490b661123Smrg	      esac
84500b661123Smrg	    done
84514f00d7e1Smrg	    dependency_libs=$temp_deplibs
84520b661123Smrg	  fi
84530b661123Smrg
8454880c7e28Smrg	  func_append newlib_search_path " $absdir"
84550b661123Smrg	  # Link against this library
84564f00d7e1Smrg	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
84570b661123Smrg	  # ... and its dependency_libs
84580b661123Smrg	  tmp_libs=
84590b661123Smrg	  for deplib in $dependency_libs; do
84600b661123Smrg	    newdependency_libs="$deplib $newdependency_libs"
8461880c7e28Smrg	    case $deplib in
8462880c7e28Smrg              -L*) func_stripname '-L' '' "$deplib"
8463880c7e28Smrg                   func_resolve_sysroot "$func_stripname_result";;
8464880c7e28Smrg              *) func_resolve_sysroot "$deplib" ;;
8465880c7e28Smrg            esac
84664f00d7e1Smrg	    if $opt_preserve_dup_deps; then
84670b661123Smrg	      case "$tmp_libs " in
8468880c7e28Smrg	      *" $func_resolve_sysroot_result "*)
8469880c7e28Smrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
84700b661123Smrg	      esac
84710b661123Smrg	    fi
8472880c7e28Smrg	    func_append tmp_libs " $func_resolve_sysroot_result"
84730b661123Smrg	  done
84740b661123Smrg
84754f00d7e1Smrg	  if test no != "$link_all_deplibs"; then
84760b661123Smrg	    # Add the search paths of all dependency libraries
84770b661123Smrg	    for deplib in $dependency_libs; do
8478880c7e28Smrg	      path=
84790b661123Smrg	      case $deplib in
84804f00d7e1Smrg	      -L*) path=$deplib ;;
84810b661123Smrg	      *.la)
8482880c7e28Smrg	        func_resolve_sysroot "$deplib"
8483880c7e28Smrg	        deplib=$func_resolve_sysroot_result
84840b661123Smrg	        func_dirname "$deplib" "" "."
8485880c7e28Smrg		dir=$func_dirname_result
84860b661123Smrg		# We need an absolute path.
84870b661123Smrg		case $dir in
84884f00d7e1Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
84890b661123Smrg		*)
84900b661123Smrg		  absdir=`cd "$dir" && pwd`
84910b661123Smrg		  if test -z "$absdir"; then
84924f00d7e1Smrg		    func_warning "cannot determine absolute directory name of '$dir'"
84934f00d7e1Smrg		    absdir=$dir
84940b661123Smrg		  fi
84950b661123Smrg		  ;;
84960b661123Smrg		esac
84970b661123Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
84980b661123Smrg		case $host in
84990b661123Smrg		*-*-darwin*)
85000b661123Smrg		  depdepl=
85014f00d7e1Smrg		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
85024f00d7e1Smrg		  if test -n "$deplibrary_names"; then
85034f00d7e1Smrg		    for tmp in $deplibrary_names; do
85040b661123Smrg		      depdepl=$tmp
85050b661123Smrg		    done
85064f00d7e1Smrg		    if test -f "$absdir/$objdir/$depdepl"; then
85074f00d7e1Smrg		      depdepl=$absdir/$objdir/$depdepl
85084f00d7e1Smrg		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
85090b661123Smrg                      if test -z "$darwin_install_name"; then
85104f00d7e1Smrg                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
85110b661123Smrg                      fi
85124f00d7e1Smrg		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
85134f00d7e1Smrg		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
85140b661123Smrg		      path=
85150b661123Smrg		    fi
85160b661123Smrg		  fi
85170b661123Smrg		  ;;
85180b661123Smrg		*)
85194f00d7e1Smrg		  path=-L$absdir/$objdir
85200b661123Smrg		  ;;
85210b661123Smrg		esac
85220b661123Smrg		else
85234f00d7e1Smrg		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
85240b661123Smrg		  test -z "$libdir" && \
85254f00d7e1Smrg		    func_fatal_error "'$deplib' is not a valid libtool archive"
85260b661123Smrg		  test "$absdir" != "$libdir" && \
85274f00d7e1Smrg		    func_warning "'$deplib' seems to be moved"
85280b661123Smrg
85294f00d7e1Smrg		  path=-L$absdir
85300b661123Smrg		fi
85310b661123Smrg		;;
85320b661123Smrg	      esac
85330b661123Smrg	      case " $deplibs " in
85340b661123Smrg	      *" $path "*) ;;
85350b661123Smrg	      *) deplibs="$path $deplibs" ;;
85360b661123Smrg	      esac
85370b661123Smrg	    done
85380b661123Smrg	  fi # link_all_deplibs != no
85390b661123Smrg	fi # linkmode = lib
85400b661123Smrg      done # for deplib in $libs
85414f00d7e1Smrg      if test link = "$pass"; then
85424f00d7e1Smrg	if test prog = "$linkmode"; then
85430b661123Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
85440b661123Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
85450b661123Smrg	else
8546880c7e28Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
85470b661123Smrg	fi
85480b661123Smrg      fi
85494f00d7e1Smrg      dependency_libs=$newdependency_libs
85504f00d7e1Smrg      if test dlpreopen = "$pass"; then
85510b661123Smrg	# Link the dlpreopened libraries before other libraries
85520b661123Smrg	for deplib in $save_deplibs; do
85530b661123Smrg	  deplibs="$deplib $deplibs"
85540b661123Smrg	done
85550b661123Smrg      fi
85564f00d7e1Smrg      if test dlopen != "$pass"; then
85574f00d7e1Smrg	test conv = "$pass" || {
85580b661123Smrg	  # Make sure lib_search_path contains only unique directories.
85590b661123Smrg	  lib_search_path=
85600b661123Smrg	  for dir in $newlib_search_path; do
85610b661123Smrg	    case "$lib_search_path " in
85620b661123Smrg	    *" $dir "*) ;;
8563880c7e28Smrg	    *) func_append lib_search_path " $dir" ;;
85640b661123Smrg	    esac
85650b661123Smrg	  done
85660b661123Smrg	  newlib_search_path=
85674f00d7e1Smrg	}
85680b661123Smrg
85694f00d7e1Smrg	if test prog,link = "$linkmode,$pass"; then
85700b661123Smrg	  vars="compile_deplibs finalize_deplibs"
85714f00d7e1Smrg	else
85724f00d7e1Smrg	  vars=deplibs
85730b661123Smrg	fi
85740b661123Smrg	for var in $vars dependency_libs; do
85750b661123Smrg	  # Add libraries to $var in reverse order
85760b661123Smrg	  eval tmp_libs=\"\$$var\"
85770b661123Smrg	  new_libs=
85780b661123Smrg	  for deplib in $tmp_libs; do
85790b661123Smrg	    # FIXME: Pedantically, this is the right thing to do, so
85800b661123Smrg	    #        that some nasty dependency loop isn't accidentally
85810b661123Smrg	    #        broken:
85820b661123Smrg	    #new_libs="$deplib $new_libs"
85830b661123Smrg	    # Pragmatically, this seems to cause very few problems in
85840b661123Smrg	    # practice:
85850b661123Smrg	    case $deplib in
85860b661123Smrg	    -L*) new_libs="$deplib $new_libs" ;;
85870b661123Smrg	    -R*) ;;
85880b661123Smrg	    *)
85890b661123Smrg	      # And here is the reason: when a library appears more
85900b661123Smrg	      # than once as an explicit dependence of a library, or
85910b661123Smrg	      # is implicitly linked in more than once by the
85920b661123Smrg	      # compiler, it is considered special, and multiple
85930b661123Smrg	      # occurrences thereof are not removed.  Compare this
85940b661123Smrg	      # with having the same library being listed as a
85950b661123Smrg	      # dependency of multiple other libraries: in this case,
85960b661123Smrg	      # we know (pedantically, we assume) the library does not
85970b661123Smrg	      # need to be listed more than once, so we keep only the
85980b661123Smrg	      # last copy.  This is not always right, but it is rare
85990b661123Smrg	      # enough that we require users that really mean to play
86000b661123Smrg	      # such unportable linking tricks to link the library
86010b661123Smrg	      # using -Wl,-lname, so that libtool does not consider it
86020b661123Smrg	      # for duplicate removal.
86030b661123Smrg	      case " $specialdeplibs " in
86040b661123Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
86050b661123Smrg	      *)
86060b661123Smrg		case " $new_libs " in
86070b661123Smrg		*" $deplib "*) ;;
86080b661123Smrg		*) new_libs="$deplib $new_libs" ;;
86090b661123Smrg		esac
86100b661123Smrg		;;
86110b661123Smrg	      esac
86120b661123Smrg	      ;;
86130b661123Smrg	    esac
86140b661123Smrg	  done
86150b661123Smrg	  tmp_libs=
86160b661123Smrg	  for deplib in $new_libs; do
86170b661123Smrg	    case $deplib in
86180b661123Smrg	    -L*)
86190b661123Smrg	      case " $tmp_libs " in
86200b661123Smrg	      *" $deplib "*) ;;
8621880c7e28Smrg	      *) func_append tmp_libs " $deplib" ;;
86220b661123Smrg	      esac
86230b661123Smrg	      ;;
8624880c7e28Smrg	    *) func_append tmp_libs " $deplib" ;;
86250b661123Smrg	    esac
86260b661123Smrg	  done
86270b661123Smrg	  eval $var=\"$tmp_libs\"
86280b661123Smrg	done # for var
86290b661123Smrg      fi
86304f00d7e1Smrg
86314f00d7e1Smrg      # Add Sun CC postdeps if required:
86324f00d7e1Smrg      test CXX = "$tagname" && {
86334f00d7e1Smrg        case $host_os in
86344f00d7e1Smrg        linux*)
86354f00d7e1Smrg          case `$CC -V 2>&1 | sed 5q` in
86364f00d7e1Smrg          *Sun\ C*) # Sun C++ 5.9
86374f00d7e1Smrg            func_suncc_cstd_abi
86384f00d7e1Smrg
86394f00d7e1Smrg            if test no != "$suncc_use_cstd_abi"; then
86404f00d7e1Smrg              func_append postdeps ' -library=Cstd -library=Crun'
86414f00d7e1Smrg            fi
86424f00d7e1Smrg            ;;
86434f00d7e1Smrg          esac
86444f00d7e1Smrg          ;;
86454f00d7e1Smrg
86464f00d7e1Smrg        solaris*)
86474f00d7e1Smrg          func_cc_basename "$CC"
86484f00d7e1Smrg          case $func_cc_basename_result in
86494f00d7e1Smrg          CC* | sunCC*)
86504f00d7e1Smrg            func_suncc_cstd_abi
86514f00d7e1Smrg
86524f00d7e1Smrg            if test no != "$suncc_use_cstd_abi"; then
86534f00d7e1Smrg              func_append postdeps ' -library=Cstd -library=Crun'
86544f00d7e1Smrg            fi
86554f00d7e1Smrg            ;;
86564f00d7e1Smrg          esac
86574f00d7e1Smrg          ;;
86584f00d7e1Smrg        esac
86594f00d7e1Smrg      }
86604f00d7e1Smrg
86610b661123Smrg      # Last step: remove runtime libs from dependency_libs
86620b661123Smrg      # (they stay in deplibs)
86630b661123Smrg      tmp_libs=
86644f00d7e1Smrg      for i in $dependency_libs; do
86650b661123Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
86660b661123Smrg	*" $i "*)
86674f00d7e1Smrg	  i=
86680b661123Smrg	  ;;
86690b661123Smrg	esac
86704f00d7e1Smrg	if test -n "$i"; then
8671880c7e28Smrg	  func_append tmp_libs " $i"
86720b661123Smrg	fi
86730b661123Smrg      done
86740b661123Smrg      dependency_libs=$tmp_libs
86750b661123Smrg    done # for pass
86764f00d7e1Smrg    if test prog = "$linkmode"; then
86774f00d7e1Smrg      dlfiles=$newdlfiles
86780b661123Smrg    fi
86794f00d7e1Smrg    if test prog = "$linkmode" || test lib = "$linkmode"; then
86804f00d7e1Smrg      dlprefiles=$newdlprefiles
86810b661123Smrg    fi
86820b661123Smrg
86830b661123Smrg    case $linkmode in
86840b661123Smrg    oldlib)
86854f00d7e1Smrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
86864f00d7e1Smrg	func_warning "'-dlopen' is ignored for archives"
86870b661123Smrg      fi
86880b661123Smrg
86890b661123Smrg      case " $deplibs" in
86900b661123Smrg      *\ -l* | *\ -L*)
86914f00d7e1Smrg	func_warning "'-l' and '-L' are ignored for archives" ;;
86920b661123Smrg      esac
86930b661123Smrg
86940b661123Smrg      test -n "$rpath" && \
86954f00d7e1Smrg	func_warning "'-rpath' is ignored for archives"
86960b661123Smrg
86970b661123Smrg      test -n "$xrpath" && \
86984f00d7e1Smrg	func_warning "'-R' is ignored for archives"
86990b661123Smrg
87000b661123Smrg      test -n "$vinfo" && \
87014f00d7e1Smrg	func_warning "'-version-info/-version-number' is ignored for archives"
87020b661123Smrg
87030b661123Smrg      test -n "$release" && \
87044f00d7e1Smrg	func_warning "'-release' is ignored for archives"
87050b661123Smrg
87060b661123Smrg      test -n "$export_symbols$export_symbols_regex" && \
87074f00d7e1Smrg	func_warning "'-export-symbols' is ignored for archives"
87080b661123Smrg
87090b661123Smrg      # Now set the variables for building old libraries.
87100b661123Smrg      build_libtool_libs=no
87114f00d7e1Smrg      oldlibs=$output
8712880c7e28Smrg      func_append objs "$old_deplibs"
87130b661123Smrg      ;;
87140b661123Smrg
87150b661123Smrg    lib)
87164f00d7e1Smrg      # Make sure we only generate libraries of the form 'libNAME.la'.
87170b661123Smrg      case $outputname in
87180b661123Smrg      lib*)
87190b661123Smrg	func_stripname 'lib' '.la' "$outputname"
87200b661123Smrg	name=$func_stripname_result
87210b661123Smrg	eval shared_ext=\"$shrext_cmds\"
87220b661123Smrg	eval libname=\"$libname_spec\"
87230b661123Smrg	;;
87240b661123Smrg      *)
87254f00d7e1Smrg	test no = "$module" \
87264f00d7e1Smrg	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
87270b661123Smrg
87284f00d7e1Smrg	if test no != "$need_lib_prefix"; then
87290b661123Smrg	  # Add the "lib" prefix for modules if required
87300b661123Smrg	  func_stripname '' '.la' "$outputname"
87310b661123Smrg	  name=$func_stripname_result
87320b661123Smrg	  eval shared_ext=\"$shrext_cmds\"
87330b661123Smrg	  eval libname=\"$libname_spec\"
87340b661123Smrg	else
87350b661123Smrg	  func_stripname '' '.la' "$outputname"
87360b661123Smrg	  libname=$func_stripname_result
87370b661123Smrg	fi
87380b661123Smrg	;;
87390b661123Smrg      esac
87400b661123Smrg
87410b661123Smrg      if test -n "$objs"; then
87424f00d7e1Smrg	if test pass_all != "$deplibs_check_method"; then
87434f00d7e1Smrg	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
87440b661123Smrg	else
8745880c7e28Smrg	  echo
87460b661123Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
87470b661123Smrg	  $ECHO "*** objects $objs is not portable!"
8748880c7e28Smrg	  func_append libobjs " $objs"
87490b661123Smrg	fi
87500b661123Smrg      fi
87510b661123Smrg
87524f00d7e1Smrg      test no = "$dlself" \
87534f00d7e1Smrg	|| func_warning "'-dlopen self' is ignored for libtool libraries"
87540b661123Smrg
87550b661123Smrg      set dummy $rpath
87560b661123Smrg      shift
87574f00d7e1Smrg      test 1 -lt "$#" \
87584f00d7e1Smrg	&& func_warning "ignoring multiple '-rpath's for a libtool library"
87590b661123Smrg
87604f00d7e1Smrg      install_libdir=$1
87610b661123Smrg
87620b661123Smrg      oldlibs=
87630b661123Smrg      if test -z "$rpath"; then
87644f00d7e1Smrg	if test yes = "$build_libtool_libs"; then
87650b661123Smrg	  # Building a libtool convenience library.
87664f00d7e1Smrg	  # Some compilers have problems with a '.al' extension so
87670b661123Smrg	  # convenience libraries should have the same extension an
87680b661123Smrg	  # archive normally would.
87690b661123Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
87700b661123Smrg	  build_libtool_libs=convenience
87710b661123Smrg	  build_old_libs=yes
87720b661123Smrg	fi
87730b661123Smrg
87740b661123Smrg	test -n "$vinfo" && \
87754f00d7e1Smrg	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
87760b661123Smrg
87770b661123Smrg	test -n "$release" && \
87784f00d7e1Smrg	  func_warning "'-release' is ignored for convenience libraries"
87790b661123Smrg      else
87800b661123Smrg
87810b661123Smrg	# Parse the version information argument.
87824f00d7e1Smrg	save_ifs=$IFS; IFS=:
87830b661123Smrg	set dummy $vinfo 0 0 0
87840b661123Smrg	shift
87854f00d7e1Smrg	IFS=$save_ifs
87860b661123Smrg
87870b661123Smrg	test -n "$7" && \
87884f00d7e1Smrg	  func_fatal_help "too many parameters to '-version-info'"
87890b661123Smrg
87900b661123Smrg	# convert absolute version numbers to libtool ages
87910b661123Smrg	# this retains compatibility with .la files and attempts
87920b661123Smrg	# to make the code below a bit more comprehensible
87930b661123Smrg
87940b661123Smrg	case $vinfo_number in
87950b661123Smrg	yes)
87964f00d7e1Smrg	  number_major=$1
87974f00d7e1Smrg	  number_minor=$2
87984f00d7e1Smrg	  number_revision=$3
87990b661123Smrg	  #
88000b661123Smrg	  # There are really only two kinds -- those that
88010b661123Smrg	  # use the current revision as the major version
88020b661123Smrg	  # and those that subtract age and use age as
88030b661123Smrg	  # a minor version.  But, then there is irix
88044f00d7e1Smrg	  # that has an extra 1 added just for fun
88050b661123Smrg	  #
88060b661123Smrg	  case $version_type in
8807880c7e28Smrg	  # correct linux to gnu/linux during the next big refactor
88084f00d7e1Smrg	  darwin|freebsd-elf|linux|osf|windows|none)
88090b661123Smrg	    func_arith $number_major + $number_minor
88100b661123Smrg	    current=$func_arith_result
88114f00d7e1Smrg	    age=$number_minor
88124f00d7e1Smrg	    revision=$number_revision
88130b661123Smrg	    ;;
88144f00d7e1Smrg	  freebsd-aout|qnx|sunos)
88154f00d7e1Smrg	    current=$number_major
88164f00d7e1Smrg	    revision=$number_minor
88174f00d7e1Smrg	    age=0
88180b661123Smrg	    ;;
88190b661123Smrg	  irix|nonstopux)
88200b661123Smrg	    func_arith $number_major + $number_minor
88210b661123Smrg	    current=$func_arith_result
88224f00d7e1Smrg	    age=$number_minor
88234f00d7e1Smrg	    revision=$number_minor
88240b661123Smrg	    lt_irix_increment=no
88250b661123Smrg	    ;;
88260b661123Smrg	  esac
88270b661123Smrg	  ;;
88280b661123Smrg	no)
88294f00d7e1Smrg	  current=$1
88304f00d7e1Smrg	  revision=$2
88314f00d7e1Smrg	  age=$3
88320b661123Smrg	  ;;
88330b661123Smrg	esac
88340b661123Smrg
88350b661123Smrg	# Check that each of the things are valid numbers.
88360b661123Smrg	case $current in
88370b661123Smrg	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]) ;;
88380b661123Smrg	*)
88394f00d7e1Smrg	  func_error "CURRENT '$current' must be a nonnegative integer"
88404f00d7e1Smrg	  func_fatal_error "'$vinfo' is not valid version information"
88410b661123Smrg	  ;;
88420b661123Smrg	esac
88430b661123Smrg
88440b661123Smrg	case $revision in
88450b661123Smrg	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]) ;;
88460b661123Smrg	*)
88474f00d7e1Smrg	  func_error "REVISION '$revision' must be a nonnegative integer"
88484f00d7e1Smrg	  func_fatal_error "'$vinfo' is not valid version information"
88490b661123Smrg	  ;;
88500b661123Smrg	esac
88510b661123Smrg
88520b661123Smrg	case $age in
88530b661123Smrg	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]) ;;
88540b661123Smrg	*)
88554f00d7e1Smrg	  func_error "AGE '$age' must be a nonnegative integer"
88564f00d7e1Smrg	  func_fatal_error "'$vinfo' is not valid version information"
88570b661123Smrg	  ;;
88580b661123Smrg	esac
88590b661123Smrg
88600b661123Smrg	if test "$age" -gt "$current"; then
88614f00d7e1Smrg	  func_error "AGE '$age' is greater than the current interface number '$current'"
88624f00d7e1Smrg	  func_fatal_error "'$vinfo' is not valid version information"
88630b661123Smrg	fi
88640b661123Smrg
88650b661123Smrg	# Calculate the version variables.
88660b661123Smrg	major=
88670b661123Smrg	versuffix=
88680b661123Smrg	verstring=
88690b661123Smrg	case $version_type in
88700b661123Smrg	none) ;;
88710b661123Smrg
88720b661123Smrg	darwin)
88730b661123Smrg	  # Like Linux, but with the current version available in
88740b661123Smrg	  # verstring for coding it into the library header
88750b661123Smrg	  func_arith $current - $age
88760b661123Smrg	  major=.$func_arith_result
88774f00d7e1Smrg	  versuffix=$major.$age.$revision
88780b661123Smrg	  # Darwin ld doesn't like 0 for these options...
88790b661123Smrg	  func_arith $current + 1
88800b661123Smrg	  minor_current=$func_arith_result
88814f00d7e1Smrg	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
88820b661123Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
88834f00d7e1Smrg          # On Darwin other compilers
88844f00d7e1Smrg          case $CC in
88854f00d7e1Smrg              nagfor*)
88864f00d7e1Smrg                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
88874f00d7e1Smrg                  ;;
88884f00d7e1Smrg              *)
88894f00d7e1Smrg                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
88904f00d7e1Smrg                  ;;
88914f00d7e1Smrg          esac
88920b661123Smrg	  ;;
88930b661123Smrg
88940b661123Smrg	freebsd-aout)
88954f00d7e1Smrg	  major=.$current
88964f00d7e1Smrg	  versuffix=.$current.$revision
88970b661123Smrg	  ;;
88980b661123Smrg
88990b661123Smrg	freebsd-elf)
89004f00d7e1Smrg	  func_arith $current - $age
89014f00d7e1Smrg	  major=.$func_arith_result
89024f00d7e1Smrg	  versuffix=$major.$age.$revision
89030b661123Smrg	  ;;
89040b661123Smrg
89050b661123Smrg	irix | nonstopux)
89064f00d7e1Smrg	  if test no = "$lt_irix_increment"; then
89070b661123Smrg	    func_arith $current - $age
89080b661123Smrg	  else
89090b661123Smrg	    func_arith $current - $age + 1
89100b661123Smrg	  fi
89110b661123Smrg	  major=$func_arith_result
89120b661123Smrg
89130b661123Smrg	  case $version_type in
89140b661123Smrg	    nonstopux) verstring_prefix=nonstopux ;;
89150b661123Smrg	    *)         verstring_prefix=sgi ;;
89160b661123Smrg	  esac
89174f00d7e1Smrg	  verstring=$verstring_prefix$major.$revision
89180b661123Smrg
89190b661123Smrg	  # Add in all the interfaces that we are compatible with.
89200b661123Smrg	  loop=$revision
89214f00d7e1Smrg	  while test 0 -ne "$loop"; do
89220b661123Smrg	    func_arith $revision - $loop
89230b661123Smrg	    iface=$func_arith_result
89240b661123Smrg	    func_arith $loop - 1
89250b661123Smrg	    loop=$func_arith_result
89264f00d7e1Smrg	    verstring=$verstring_prefix$major.$iface:$verstring
89270b661123Smrg	  done
89280b661123Smrg
89294f00d7e1Smrg	  # Before this point, $major must not contain '.'.
89300b661123Smrg	  major=.$major
89314f00d7e1Smrg	  versuffix=$major.$revision
89320b661123Smrg	  ;;
89330b661123Smrg
8934880c7e28Smrg	linux) # correct to gnu/linux during the next big refactor
89350b661123Smrg	  func_arith $current - $age
89360b661123Smrg	  major=.$func_arith_result
89374f00d7e1Smrg	  versuffix=$major.$age.$revision
89380b661123Smrg	  ;;
89390b661123Smrg
89400b661123Smrg	osf)
89410b661123Smrg	  func_arith $current - $age
89420b661123Smrg	  major=.$func_arith_result
89434f00d7e1Smrg	  versuffix=.$current.$age.$revision
89444f00d7e1Smrg	  verstring=$current.$age.$revision
89450b661123Smrg
89460b661123Smrg	  # Add in all the interfaces that we are compatible with.
89470b661123Smrg	  loop=$age
89484f00d7e1Smrg	  while test 0 -ne "$loop"; do
89490b661123Smrg	    func_arith $current - $loop
89500b661123Smrg	    iface=$func_arith_result
89510b661123Smrg	    func_arith $loop - 1
89520b661123Smrg	    loop=$func_arith_result
89534f00d7e1Smrg	    verstring=$verstring:$iface.0
89540b661123Smrg	  done
89550b661123Smrg
89560b661123Smrg	  # Make executables depend on our current version.
89574f00d7e1Smrg	  func_append verstring ":$current.0"
89580b661123Smrg	  ;;
89590b661123Smrg
89600b661123Smrg	qnx)
89614f00d7e1Smrg	  major=.$current
89624f00d7e1Smrg	  versuffix=.$current
89634f00d7e1Smrg	  ;;
89644f00d7e1Smrg
89654f00d7e1Smrg	sco)
89664f00d7e1Smrg	  major=.$current
89674f00d7e1Smrg	  versuffix=.$current
89680b661123Smrg	  ;;
89690b661123Smrg
89700b661123Smrg	sunos)
89714f00d7e1Smrg	  major=.$current
89724f00d7e1Smrg	  versuffix=.$current.$revision
89730b661123Smrg	  ;;
89740b661123Smrg
89750b661123Smrg	windows)
89760b661123Smrg	  # Use '-' rather than '.', since we only want one
89774f00d7e1Smrg	  # extension on DOS 8.3 file systems.
89780b661123Smrg	  func_arith $current - $age
89790b661123Smrg	  major=$func_arith_result
89804f00d7e1Smrg	  versuffix=-$major
89810b661123Smrg	  ;;
89820b661123Smrg
89830b661123Smrg	*)
89844f00d7e1Smrg	  func_fatal_configuration "unknown library version type '$version_type'"
89850b661123Smrg	  ;;
89860b661123Smrg	esac
89870b661123Smrg
89880b661123Smrg	# Clear the version info if we defaulted, and they specified a release.
89890b661123Smrg	if test -z "$vinfo" && test -n "$release"; then
89900b661123Smrg	  major=
89910b661123Smrg	  case $version_type in
89920b661123Smrg	  darwin)
89930b661123Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
89940b661123Smrg	    # problems, so we reset it completely
89950b661123Smrg	    verstring=
89960b661123Smrg	    ;;
89970b661123Smrg	  *)
89984f00d7e1Smrg	    verstring=0.0
89990b661123Smrg	    ;;
90000b661123Smrg	  esac
90014f00d7e1Smrg	  if test no = "$need_version"; then
90020b661123Smrg	    versuffix=
90030b661123Smrg	  else
90044f00d7e1Smrg	    versuffix=.0.0
90050b661123Smrg	  fi
90060b661123Smrg	fi
90070b661123Smrg
90080b661123Smrg	# Remove version info from name if versioning should be avoided
90094f00d7e1Smrg	if test yes,no = "$avoid_version,$need_version"; then
90100b661123Smrg	  major=
90110b661123Smrg	  versuffix=
90124f00d7e1Smrg	  verstring=
90130b661123Smrg	fi
90140b661123Smrg
90150b661123Smrg	# Check to see if the archive will have undefined symbols.
90164f00d7e1Smrg	if test yes = "$allow_undefined"; then
90174f00d7e1Smrg	  if test unsupported = "$allow_undefined_flag"; then
90184f00d7e1Smrg	    if test yes = "$build_old_libs"; then
90194f00d7e1Smrg	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
90204f00d7e1Smrg	      build_libtool_libs=no
90214f00d7e1Smrg	    else
90224f00d7e1Smrg	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
90234f00d7e1Smrg	    fi
90240b661123Smrg	  fi
90250b661123Smrg	else
90260b661123Smrg	  # Don't allow undefined symbols.
90274f00d7e1Smrg	  allow_undefined_flag=$no_undefined_flag
90280b661123Smrg	fi
90290b661123Smrg
90300b661123Smrg      fi
90310b661123Smrg
90324f00d7e1Smrg      func_generate_dlsyms "$libname" "$libname" :
9033880c7e28Smrg      func_append libobjs " $symfileobj"
90344f00d7e1Smrg      test " " = "$libobjs" && libobjs=
90350b661123Smrg
90364f00d7e1Smrg      if test relink != "$opt_mode"; then
90370b661123Smrg	# Remove our outputs, but don't remove object files since they
90380b661123Smrg	# may have been created when compiling PIC objects.
90390b661123Smrg	removelist=
90400b661123Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
90410b661123Smrg	for p in $tempremovelist; do
90420b661123Smrg	  case $p in
90430b661123Smrg	    *.$objext | *.gcno)
90440b661123Smrg	       ;;
90454f00d7e1Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
90464f00d7e1Smrg	       if test -n "$precious_files_regex"; then
90470b661123Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
90480b661123Smrg		 then
90490b661123Smrg		   continue
90500b661123Smrg		 fi
90510b661123Smrg	       fi
9052880c7e28Smrg	       func_append removelist " $p"
90530b661123Smrg	       ;;
90540b661123Smrg	    *) ;;
90550b661123Smrg	  esac
90560b661123Smrg	done
90570b661123Smrg	test -n "$removelist" && \
90580b661123Smrg	  func_show_eval "${RM}r \$removelist"
90590b661123Smrg      fi
90600b661123Smrg
90610b661123Smrg      # Now set the variables for building old libraries.
90624f00d7e1Smrg      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
9063880c7e28Smrg	func_append oldlibs " $output_objdir/$libname.$libext"
90640b661123Smrg
90650b661123Smrg	# Transform .lo files to .o files.
90664f00d7e1Smrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
90670b661123Smrg      fi
90680b661123Smrg
90690b661123Smrg      # Eliminate all temporary directories.
90700b661123Smrg      #for path in $notinst_path; do
9071880c7e28Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
9072880c7e28Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
9073880c7e28Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
90740b661123Smrg      #done
90750b661123Smrg
90760b661123Smrg      if test -n "$xrpath"; then
90770b661123Smrg	# If the user specified any rpath flags, then add them.
90780b661123Smrg	temp_xrpath=
90790b661123Smrg	for libdir in $xrpath; do
9080880c7e28Smrg	  func_replace_sysroot "$libdir"
9081880c7e28Smrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
90820b661123Smrg	  case "$finalize_rpath " in
90830b661123Smrg	  *" $libdir "*) ;;
9084880c7e28Smrg	  *) func_append finalize_rpath " $libdir" ;;
90850b661123Smrg	  esac
90860b661123Smrg	done
90874f00d7e1Smrg	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
90880b661123Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
90890b661123Smrg	fi
90900b661123Smrg      fi
90910b661123Smrg
90920b661123Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
90934f00d7e1Smrg      old_dlfiles=$dlfiles
90940b661123Smrg      dlfiles=
90950b661123Smrg      for lib in $old_dlfiles; do
90960b661123Smrg	case " $dlprefiles $dlfiles " in
90970b661123Smrg	*" $lib "*) ;;
9098880c7e28Smrg	*) func_append dlfiles " $lib" ;;
90990b661123Smrg	esac
91000b661123Smrg      done
91010b661123Smrg
91020b661123Smrg      # Make sure dlprefiles contains only unique files
91034f00d7e1Smrg      old_dlprefiles=$dlprefiles
91040b661123Smrg      dlprefiles=
91050b661123Smrg      for lib in $old_dlprefiles; do
91060b661123Smrg	case "$dlprefiles " in
91070b661123Smrg	*" $lib "*) ;;
9108880c7e28Smrg	*) func_append dlprefiles " $lib" ;;
91090b661123Smrg	esac
91100b661123Smrg      done
91110b661123Smrg
91124f00d7e1Smrg      if test yes = "$build_libtool_libs"; then
91130b661123Smrg	if test -n "$rpath"; then
91140b661123Smrg	  case $host in
9115880c7e28Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
91160b661123Smrg	    # these systems don't actually have a c library (as such)!
91170b661123Smrg	    ;;
91180b661123Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
91190b661123Smrg	    # Rhapsody C library is in the System framework
9120880c7e28Smrg	    func_append deplibs " System.ltframework"
91210b661123Smrg	    ;;
91220b661123Smrg	  *-*-netbsd*)
91230b661123Smrg	    # Don't link with libc until the a.out ld.so is fixed.
91240b661123Smrg	    ;;
91250b661123Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
91260b661123Smrg	    # Do not include libc due to us having libc/libc_r.
91270b661123Smrg	    ;;
91280b661123Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
91290b661123Smrg	    # Causes problems with __ctype
91300b661123Smrg	    ;;
91310b661123Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
91320b661123Smrg	    # Compiler inserts libc in the correct place for threads to work
91330b661123Smrg	    ;;
91340b661123Smrg	  *)
91350b661123Smrg	    # Add libc to deplibs on all other systems if necessary.
91364f00d7e1Smrg	    if test yes = "$build_libtool_need_lc"; then
9137880c7e28Smrg	      func_append deplibs " -lc"
91380b661123Smrg	    fi
91390b661123Smrg	    ;;
91400b661123Smrg	  esac
91410b661123Smrg	fi
91420b661123Smrg
91430b661123Smrg	# Transform deplibs into only deplibs that can be linked in shared.
91440b661123Smrg	name_save=$name
91450b661123Smrg	libname_save=$libname
91460b661123Smrg	release_save=$release
91470b661123Smrg	versuffix_save=$versuffix
91480b661123Smrg	major_save=$major
91490b661123Smrg	# I'm not sure if I'm treating the release correctly.  I think
91500b661123Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
91510b661123Smrg	# add it in twice.  Is that correct?
91524f00d7e1Smrg	release=
91534f00d7e1Smrg	versuffix=
91544f00d7e1Smrg	major=
91550b661123Smrg	newdeplibs=
91560b661123Smrg	droppeddeps=no
91570b661123Smrg	case $deplibs_check_method in
91580b661123Smrg	pass_all)
91590b661123Smrg	  # Don't check for shared/static.  Everything works.
91600b661123Smrg	  # This might be a little naive.  We might want to check
91610b661123Smrg	  # whether the library exists or not.  But this is on
91620b661123Smrg	  # osf3 & osf4 and I'm not really sure... Just
91630b661123Smrg	  # implementing what was already the behavior.
91640b661123Smrg	  newdeplibs=$deplibs
91650b661123Smrg	  ;;
91660b661123Smrg	test_compile)
91670b661123Smrg	  # This code stresses the "libraries are programs" paradigm to its
91680b661123Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
91690b661123Smrg	  # against the deplibs as a proxy for the library.  Then we can check
91700b661123Smrg	  # whether they linked in statically or dynamically with ldd.
91710b661123Smrg	  $opt_dry_run || $RM conftest.c
91720b661123Smrg	  cat > conftest.c <<EOF
91730b661123Smrg	  int main() { return 0; }
91740b661123SmrgEOF
91750b661123Smrg	  $opt_dry_run || $RM conftest
91760b661123Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
91770b661123Smrg	    ldd_output=`ldd conftest`
91780b661123Smrg	    for i in $deplibs; do
91790b661123Smrg	      case $i in
91800b661123Smrg	      -l*)
91810b661123Smrg		func_stripname -l '' "$i"
91820b661123Smrg		name=$func_stripname_result
91834f00d7e1Smrg		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
91840b661123Smrg		  case " $predeps $postdeps " in
91850b661123Smrg		  *" $i "*)
9186880c7e28Smrg		    func_append newdeplibs " $i"
91874f00d7e1Smrg		    i=
91880b661123Smrg		    ;;
91890b661123Smrg		  esac
91900b661123Smrg		fi
91914f00d7e1Smrg		if test -n "$i"; then
91920b661123Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
91930b661123Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
91940b661123Smrg		  set dummy $deplib_matches; shift
91950b661123Smrg		  deplib_match=$1
91964f00d7e1Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9197880c7e28Smrg		    func_append newdeplibs " $i"
91980b661123Smrg		  else
91990b661123Smrg		    droppeddeps=yes
9200880c7e28Smrg		    echo
92010b661123Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9202880c7e28Smrg		    echo "*** I have the capability to make that library automatically link in when"
9203880c7e28Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
9204880c7e28Smrg		    echo "*** shared version of the library, which I believe you do not have"
9205880c7e28Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
9206880c7e28Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
92070b661123Smrg		  fi
92080b661123Smrg		fi
92090b661123Smrg		;;
92100b661123Smrg	      *)
9211880c7e28Smrg		func_append newdeplibs " $i"
92120b661123Smrg		;;
92130b661123Smrg	      esac
92140b661123Smrg	    done
92150b661123Smrg	  else
92160b661123Smrg	    # Error occurred in the first compile.  Let's try to salvage
92170b661123Smrg	    # the situation: Compile a separate program for each library.
92180b661123Smrg	    for i in $deplibs; do
92190b661123Smrg	      case $i in
92200b661123Smrg	      -l*)
92210b661123Smrg		func_stripname -l '' "$i"
92220b661123Smrg		name=$func_stripname_result
92230b661123Smrg		$opt_dry_run || $RM conftest
92240b661123Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
92250b661123Smrg		  ldd_output=`ldd conftest`
92264f00d7e1Smrg		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
92270b661123Smrg		    case " $predeps $postdeps " in
92280b661123Smrg		    *" $i "*)
9229880c7e28Smrg		      func_append newdeplibs " $i"
92304f00d7e1Smrg		      i=
92310b661123Smrg		      ;;
92320b661123Smrg		    esac
92330b661123Smrg		  fi
92344f00d7e1Smrg		  if test -n "$i"; then
92350b661123Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
92360b661123Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
92370b661123Smrg		    set dummy $deplib_matches; shift
92380b661123Smrg		    deplib_match=$1
92394f00d7e1Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9240880c7e28Smrg		      func_append newdeplibs " $i"
92410b661123Smrg		    else
92420b661123Smrg		      droppeddeps=yes
9243880c7e28Smrg		      echo
92440b661123Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9245880c7e28Smrg		      echo "*** I have the capability to make that library automatically link in when"
9246880c7e28Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
9247880c7e28Smrg		      echo "*** shared version of the library, which you do not appear to have"
9248880c7e28Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
9249880c7e28Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
92500b661123Smrg		    fi
92510b661123Smrg		  fi
92520b661123Smrg		else
92530b661123Smrg		  droppeddeps=yes
9254880c7e28Smrg		  echo
92550b661123Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
9256880c7e28Smrg		  echo "*** make it link in!  You will probably need to install it or some"
9257880c7e28Smrg		  echo "*** library that it depends on before this library will be fully"
9258880c7e28Smrg		  echo "*** functional.  Installing it before continuing would be even better."
92590b661123Smrg		fi
92600b661123Smrg		;;
92610b661123Smrg	      *)
9262880c7e28Smrg		func_append newdeplibs " $i"
92630b661123Smrg		;;
92640b661123Smrg	      esac
92650b661123Smrg	    done
92660b661123Smrg	  fi
92670b661123Smrg	  ;;
92680b661123Smrg	file_magic*)
92690b661123Smrg	  set dummy $deplibs_check_method; shift
92700b661123Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
92710b661123Smrg	  for a_deplib in $deplibs; do
92720b661123Smrg	    case $a_deplib in
92730b661123Smrg	    -l*)
92740b661123Smrg	      func_stripname -l '' "$a_deplib"
92750b661123Smrg	      name=$func_stripname_result
92764f00d7e1Smrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
92770b661123Smrg		case " $predeps $postdeps " in
92780b661123Smrg		*" $a_deplib "*)
9279880c7e28Smrg		  func_append newdeplibs " $a_deplib"
92804f00d7e1Smrg		  a_deplib=
92810b661123Smrg		  ;;
92820b661123Smrg		esac
92830b661123Smrg	      fi
92844f00d7e1Smrg	      if test -n "$a_deplib"; then
92850b661123Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
9286880c7e28Smrg		if test -n "$file_magic_glob"; then
9287880c7e28Smrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
9288880c7e28Smrg		else
9289880c7e28Smrg		  libnameglob=$libname
9290880c7e28Smrg		fi
92914f00d7e1Smrg		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
92920b661123Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
92934f00d7e1Smrg		  if test yes = "$want_nocaseglob"; then
9294880c7e28Smrg		    shopt -s nocaseglob
9295880c7e28Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9296880c7e28Smrg		    $nocaseglob
9297880c7e28Smrg		  else
9298880c7e28Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9299880c7e28Smrg		  fi
93000b661123Smrg		  for potent_lib in $potential_libs; do
93010b661123Smrg		      # Follow soft links.
93020b661123Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
93030b661123Smrg			 $GREP " -> " >/dev/null; then
93040b661123Smrg			continue
93050b661123Smrg		      fi
93060b661123Smrg		      # The statement above tries to avoid entering an
93070b661123Smrg		      # endless loop below, in case of cyclic links.
93080b661123Smrg		      # We might still enter an endless loop, since a link
93090b661123Smrg		      # loop can be closed while we follow links,
93100b661123Smrg		      # but so what?
93114f00d7e1Smrg		      potlib=$potent_lib
93120b661123Smrg		      while test -h "$potlib" 2>/dev/null; do
93134f00d7e1Smrg			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
93140b661123Smrg			case $potliblink in
93154f00d7e1Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
93164f00d7e1Smrg			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
93170b661123Smrg			esac
93180b661123Smrg		      done
93190b661123Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
93200b661123Smrg			 $SED -e 10q |
93210b661123Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
9322880c7e28Smrg			func_append newdeplibs " $a_deplib"
93234f00d7e1Smrg			a_deplib=
93240b661123Smrg			break 2
93250b661123Smrg		      fi
93260b661123Smrg		  done
93270b661123Smrg		done
93280b661123Smrg	      fi
93294f00d7e1Smrg	      if test -n "$a_deplib"; then
93300b661123Smrg		droppeddeps=yes
9331880c7e28Smrg		echo
93320b661123Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9333880c7e28Smrg		echo "*** I have the capability to make that library automatically link in when"
9334880c7e28Smrg		echo "*** you link to this library.  But I can only do this if you have a"
9335880c7e28Smrg		echo "*** shared version of the library, which you do not appear to have"
9336880c7e28Smrg		echo "*** because I did check the linker path looking for a file starting"
93374f00d7e1Smrg		if test -z "$potlib"; then
93380b661123Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
93390b661123Smrg		else
93400b661123Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
93410b661123Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
93420b661123Smrg		fi
93430b661123Smrg	      fi
93440b661123Smrg	      ;;
93450b661123Smrg	    *)
93460b661123Smrg	      # Add a -L argument.
9347880c7e28Smrg	      func_append newdeplibs " $a_deplib"
93480b661123Smrg	      ;;
93490b661123Smrg	    esac
93500b661123Smrg	  done # Gone through all deplibs.
93510b661123Smrg	  ;;
93520b661123Smrg	match_pattern*)
93530b661123Smrg	  set dummy $deplibs_check_method; shift
93540b661123Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
93550b661123Smrg	  for a_deplib in $deplibs; do
93560b661123Smrg	    case $a_deplib in
93570b661123Smrg	    -l*)
93580b661123Smrg	      func_stripname -l '' "$a_deplib"
93590b661123Smrg	      name=$func_stripname_result
93604f00d7e1Smrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
93610b661123Smrg		case " $predeps $postdeps " in
93620b661123Smrg		*" $a_deplib "*)
9363880c7e28Smrg		  func_append newdeplibs " $a_deplib"
93644f00d7e1Smrg		  a_deplib=
93650b661123Smrg		  ;;
93660b661123Smrg		esac
93670b661123Smrg	      fi
93684f00d7e1Smrg	      if test -n "$a_deplib"; then
93690b661123Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
93700b661123Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
93710b661123Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
93720b661123Smrg		  for potent_lib in $potential_libs; do
93734f00d7e1Smrg		    potlib=$potent_lib # see symlink-check above in file_magic test
9374880c7e28Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
93750b661123Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
9376880c7e28Smrg		      func_append newdeplibs " $a_deplib"
93774f00d7e1Smrg		      a_deplib=
93780b661123Smrg		      break 2
93790b661123Smrg		    fi
93800b661123Smrg		  done
93810b661123Smrg		done
93820b661123Smrg	      fi
93834f00d7e1Smrg	      if test -n "$a_deplib"; then
93840b661123Smrg		droppeddeps=yes
9385880c7e28Smrg		echo
93860b661123Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9387880c7e28Smrg		echo "*** I have the capability to make that library automatically link in when"
9388880c7e28Smrg		echo "*** you link to this library.  But I can only do this if you have a"
9389880c7e28Smrg		echo "*** shared version of the library, which you do not appear to have"
9390880c7e28Smrg		echo "*** because I did check the linker path looking for a file starting"
93914f00d7e1Smrg		if test -z "$potlib"; then
93920b661123Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
93930b661123Smrg		else
93940b661123Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
93950b661123Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
93960b661123Smrg		fi
93970b661123Smrg	      fi
93980b661123Smrg	      ;;
93990b661123Smrg	    *)
94000b661123Smrg	      # Add a -L argument.
9401880c7e28Smrg	      func_append newdeplibs " $a_deplib"
94020b661123Smrg	      ;;
94030b661123Smrg	    esac
94040b661123Smrg	  done # Gone through all deplibs.
94050b661123Smrg	  ;;
94060b661123Smrg	none | unknown | *)
94074f00d7e1Smrg	  newdeplibs=
9408880c7e28Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
94094f00d7e1Smrg	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
94104f00d7e1Smrg	    for i in $predeps $postdeps; do
94110b661123Smrg	      # can't use Xsed below, because $i might contain '/'
94124f00d7e1Smrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
94130b661123Smrg	    done
94140b661123Smrg	  fi
9415880c7e28Smrg	  case $tmp_deplibs in
9416880c7e28Smrg	  *[!\	\ ]*)
9417880c7e28Smrg	    echo
94184f00d7e1Smrg	    if test none = "$deplibs_check_method"; then
9419880c7e28Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
94200b661123Smrg	    else
9421880c7e28Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
94220b661123Smrg	    fi
9423880c7e28Smrg	    echo "*** All declared inter-library dependencies are being dropped."
94240b661123Smrg	    droppeddeps=yes
9425880c7e28Smrg	    ;;
9426880c7e28Smrg	  esac
94270b661123Smrg	  ;;
94280b661123Smrg	esac
94290b661123Smrg	versuffix=$versuffix_save
94300b661123Smrg	major=$major_save
94310b661123Smrg	release=$release_save
94320b661123Smrg	libname=$libname_save
94330b661123Smrg	name=$name_save
94340b661123Smrg
94350b661123Smrg	case $host in
94360b661123Smrg	*-*-rhapsody* | *-*-darwin1.[012])
94370b661123Smrg	  # On Rhapsody replace the C library with the System framework
9438880c7e28Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
94390b661123Smrg	  ;;
94400b661123Smrg	esac
94410b661123Smrg
94424f00d7e1Smrg	if test yes = "$droppeddeps"; then
94434f00d7e1Smrg	  if test yes = "$module"; then
9444880c7e28Smrg	    echo
9445880c7e28Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
94460b661123Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
9447880c7e28Smrg	    echo "*** a static module, that should work as long as the dlopening"
9448880c7e28Smrg	    echo "*** application is linked with the -dlopen flag."
94490b661123Smrg	    if test -z "$global_symbol_pipe"; then
9450880c7e28Smrg	      echo
9451880c7e28Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
94524f00d7e1Smrg	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
9453880c7e28Smrg	      echo "*** not find such a program.  So, this module is probably useless."
94544f00d7e1Smrg	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
94550b661123Smrg	    fi
94564f00d7e1Smrg	    if test no = "$build_old_libs"; then
94574f00d7e1Smrg	      oldlibs=$output_objdir/$libname.$libext
94580b661123Smrg	      build_libtool_libs=module
94590b661123Smrg	      build_old_libs=yes
94600b661123Smrg	    else
94610b661123Smrg	      build_libtool_libs=no
94620b661123Smrg	    fi
94630b661123Smrg	  else
9464880c7e28Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
9465880c7e28Smrg	    echo "*** automatically added whenever a program is linked with this library"
9466880c7e28Smrg	    echo "*** or is declared to -dlopen it."
94670b661123Smrg
94684f00d7e1Smrg	    if test no = "$allow_undefined"; then
9469880c7e28Smrg	      echo
9470880c7e28Smrg	      echo "*** Since this library must not contain undefined symbols,"
9471880c7e28Smrg	      echo "*** because either the platform does not support them or"
9472880c7e28Smrg	      echo "*** it was explicitly requested with -no-undefined,"
9473880c7e28Smrg	      echo "*** libtool will only create a static version of it."
94744f00d7e1Smrg	      if test no = "$build_old_libs"; then
94754f00d7e1Smrg		oldlibs=$output_objdir/$libname.$libext
94760b661123Smrg		build_libtool_libs=module
94770b661123Smrg		build_old_libs=yes
94780b661123Smrg	      else
94790b661123Smrg		build_libtool_libs=no
94800b661123Smrg	      fi
94810b661123Smrg	    fi
94820b661123Smrg	  fi
94830b661123Smrg	fi
94840b661123Smrg	# Done checking deplibs!
94850b661123Smrg	deplibs=$newdeplibs
94860b661123Smrg      fi
94870b661123Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
94880b661123Smrg      case $host in
94890b661123Smrg	*-*-darwin*)
9490880c7e28Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9491880c7e28Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9492880c7e28Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
94930b661123Smrg	  ;;
94940b661123Smrg      esac
94950b661123Smrg
94960b661123Smrg      # move library search paths that coincide with paths to not yet
94970b661123Smrg      # installed libraries to the beginning of the library search list
94980b661123Smrg      new_libs=
94990b661123Smrg      for path in $notinst_path; do
95000b661123Smrg	case " $new_libs " in
95010b661123Smrg	*" -L$path/$objdir "*) ;;
95020b661123Smrg	*)
95030b661123Smrg	  case " $deplibs " in
95040b661123Smrg	  *" -L$path/$objdir "*)
9505880c7e28Smrg	    func_append new_libs " -L$path/$objdir" ;;
95060b661123Smrg	  esac
95070b661123Smrg	  ;;
95080b661123Smrg	esac
95090b661123Smrg      done
95100b661123Smrg      for deplib in $deplibs; do
95110b661123Smrg	case $deplib in
95120b661123Smrg	-L*)
95130b661123Smrg	  case " $new_libs " in
95140b661123Smrg	  *" $deplib "*) ;;
9515880c7e28Smrg	  *) func_append new_libs " $deplib" ;;
95160b661123Smrg	  esac
95170b661123Smrg	  ;;
9518880c7e28Smrg	*) func_append new_libs " $deplib" ;;
95190b661123Smrg	esac
95200b661123Smrg      done
95214f00d7e1Smrg      deplibs=$new_libs
95220b661123Smrg
95230b661123Smrg      # All the library-specific variables (install_libdir is set above).
95240b661123Smrg      library_names=
95250b661123Smrg      old_library=
95260b661123Smrg      dlname=
95270b661123Smrg
95280b661123Smrg      # Test again, we may have decided not to build it any more
95294f00d7e1Smrg      if test yes = "$build_libtool_libs"; then
95304f00d7e1Smrg	# Remove $wl instances when linking with ld.
9531880c7e28Smrg	# FIXME: should test the right _cmds variable.
9532880c7e28Smrg	case $archive_cmds in
9533880c7e28Smrg	  *\$LD\ *) wl= ;;
9534880c7e28Smrg        esac
95354f00d7e1Smrg	if test yes = "$hardcode_into_libs"; then
95360b661123Smrg	  # Hardcode the library paths
95370b661123Smrg	  hardcode_libdirs=
95380b661123Smrg	  dep_rpath=
95394f00d7e1Smrg	  rpath=$finalize_rpath
95404f00d7e1Smrg	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
95410b661123Smrg	  for libdir in $rpath; do
95420b661123Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
95430b661123Smrg	      if test -n "$hardcode_libdir_separator"; then
9544880c7e28Smrg		func_replace_sysroot "$libdir"
9545880c7e28Smrg		libdir=$func_replace_sysroot_result
95460b661123Smrg		if test -z "$hardcode_libdirs"; then
95474f00d7e1Smrg		  hardcode_libdirs=$libdir
95480b661123Smrg		else
95490b661123Smrg		  # Just accumulate the unique libdirs.
95500b661123Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
95510b661123Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
95520b661123Smrg		    ;;
95530b661123Smrg		  *)
9554880c7e28Smrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
95550b661123Smrg		    ;;
95560b661123Smrg		  esac
95570b661123Smrg		fi
95580b661123Smrg	      else
95590b661123Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
9560880c7e28Smrg		func_append dep_rpath " $flag"
95610b661123Smrg	      fi
95620b661123Smrg	    elif test -n "$runpath_var"; then
95630b661123Smrg	      case "$perm_rpath " in
95640b661123Smrg	      *" $libdir "*) ;;
9565880c7e28Smrg	      *) func_append perm_rpath " $libdir" ;;
95660b661123Smrg	      esac
95670b661123Smrg	    fi
95680b661123Smrg	  done
95690b661123Smrg	  # Substitute the hardcoded libdirs into the rpath.
95700b661123Smrg	  if test -n "$hardcode_libdir_separator" &&
95710b661123Smrg	     test -n "$hardcode_libdirs"; then
95724f00d7e1Smrg	    libdir=$hardcode_libdirs
9573880c7e28Smrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
95740b661123Smrg	  fi
95750b661123Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
95760b661123Smrg	    # We should set the runpath_var.
95770b661123Smrg	    rpath=
95780b661123Smrg	    for dir in $perm_rpath; do
9579880c7e28Smrg	      func_append rpath "$dir:"
95800b661123Smrg	    done
95810b661123Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
95820b661123Smrg	  fi
95830b661123Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
95840b661123Smrg	fi
9585bdcaa8d0Smrg
95864f00d7e1Smrg	shlibpath=$finalize_shlibpath
95874f00d7e1Smrg	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
95880b661123Smrg	if test -n "$shlibpath"; then
95890b661123Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
95900b661123Smrg	fi
9591bdcaa8d0Smrg
95920b661123Smrg	# Get the real and link names of the library.
95930b661123Smrg	eval shared_ext=\"$shrext_cmds\"
95940b661123Smrg	eval library_names=\"$library_names_spec\"
95950b661123Smrg	set dummy $library_names
95960b661123Smrg	shift
95974f00d7e1Smrg	realname=$1
95980b661123Smrg	shift
9599bdcaa8d0Smrg
96000b661123Smrg	if test -n "$soname_spec"; then
96010b661123Smrg	  eval soname=\"$soname_spec\"
96020b661123Smrg	else
96034f00d7e1Smrg	  soname=$realname
96040b661123Smrg	fi
96050b661123Smrg	if test -z "$dlname"; then
96060b661123Smrg	  dlname=$soname
96070b661123Smrg	fi
9608bdcaa8d0Smrg
96094f00d7e1Smrg	lib=$output_objdir/$realname
96100b661123Smrg	linknames=
96110b661123Smrg	for link
96120b661123Smrg	do
9613880c7e28Smrg	  func_append linknames " $link"
96140b661123Smrg	done
9615bdcaa8d0Smrg
96160b661123Smrg	# Use standard objects if they are pic
9617880c7e28Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
96180b661123Smrg	test "X$libobjs" = "X " && libobjs=
9619bdcaa8d0Smrg
96200b661123Smrg	delfiles=
96210b661123Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
96220b661123Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
96234f00d7e1Smrg	  export_symbols=$output_objdir/$libname.uexp
9624880c7e28Smrg	  func_append delfiles " $export_symbols"
96250b661123Smrg	fi
9626bdcaa8d0Smrg
96270b661123Smrg	orig_export_symbols=
96280b661123Smrg	case $host_os in
96290b661123Smrg	cygwin* | mingw* | cegcc*)
96300b661123Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
96310b661123Smrg	    # exporting using user supplied symfile
96324f00d7e1Smrg	    func_dll_def_p "$export_symbols" || {
96330b661123Smrg	      # and it's NOT already a .def file. Must figure out
96340b661123Smrg	      # which of the given symbols are data symbols and tag
96350b661123Smrg	      # them as such. So, trigger use of export_symbols_cmds.
96360b661123Smrg	      # export_symbols gets reassigned inside the "prepare
96370b661123Smrg	      # the list of exported symbols" if statement, so the
96380b661123Smrg	      # include_expsyms logic still works.
96394f00d7e1Smrg	      orig_export_symbols=$export_symbols
96400b661123Smrg	      export_symbols=
96410b661123Smrg	      always_export_symbols=yes
96424f00d7e1Smrg	    }
96430b661123Smrg	  fi
96440b661123Smrg	  ;;
96450b661123Smrg	esac
9646bdcaa8d0Smrg
96470b661123Smrg	# Prepare the list of exported symbols
96480b661123Smrg	if test -z "$export_symbols"; then
96494f00d7e1Smrg	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
96504f00d7e1Smrg	    func_verbose "generating symbol list for '$libname.la'"
96514f00d7e1Smrg	    export_symbols=$output_objdir/$libname.exp
96520b661123Smrg	    $opt_dry_run || $RM $export_symbols
96530b661123Smrg	    cmds=$export_symbols_cmds
96544f00d7e1Smrg	    save_ifs=$IFS; IFS='~'
9655880c7e28Smrg	    for cmd1 in $cmds; do
96564f00d7e1Smrg	      IFS=$save_ifs
9657880c7e28Smrg	      # Take the normal branch if the nm_file_list_spec branch
9658880c7e28Smrg	      # doesn't work or if tool conversion is not needed.
9659880c7e28Smrg	      case $nm_file_list_spec~$to_tool_file_cmd in
9660880c7e28Smrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
9661880c7e28Smrg		  try_normal_branch=yes
9662880c7e28Smrg		  eval cmd=\"$cmd1\"
9663880c7e28Smrg		  func_len " $cmd"
9664880c7e28Smrg		  len=$func_len_result
9665880c7e28Smrg		  ;;
9666880c7e28Smrg		*)
9667880c7e28Smrg		  try_normal_branch=no
9668880c7e28Smrg		  ;;
9669880c7e28Smrg	      esac
96704f00d7e1Smrg	      if test yes = "$try_normal_branch" \
9671880c7e28Smrg		 && { test "$len" -lt "$max_cmd_len" \
9672880c7e28Smrg		      || test "$max_cmd_len" -le -1; }
9673880c7e28Smrg	      then
9674880c7e28Smrg		func_show_eval "$cmd" 'exit $?'
9675880c7e28Smrg		skipped_export=false
9676880c7e28Smrg	      elif test -n "$nm_file_list_spec"; then
9677880c7e28Smrg		func_basename "$output"
9678880c7e28Smrg		output_la=$func_basename_result
9679880c7e28Smrg		save_libobjs=$libobjs
9680880c7e28Smrg		save_output=$output
96814f00d7e1Smrg		output=$output_objdir/$output_la.nm
9682880c7e28Smrg		func_to_tool_file "$output"
9683880c7e28Smrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
9684880c7e28Smrg		func_append delfiles " $output"
9685880c7e28Smrg		func_verbose "creating $NM input file list: $output"
9686880c7e28Smrg		for obj in $save_libobjs; do
9687880c7e28Smrg		  func_to_tool_file "$obj"
9688880c7e28Smrg		  $ECHO "$func_to_tool_file_result"
9689880c7e28Smrg		done > "$output"
9690880c7e28Smrg		eval cmd=\"$cmd1\"
96910b661123Smrg		func_show_eval "$cmd" 'exit $?'
9692880c7e28Smrg		output=$save_output
9693880c7e28Smrg		libobjs=$save_libobjs
96940b661123Smrg		skipped_export=false
96950b661123Smrg	      else
96960b661123Smrg		# The command line is too long to execute in one step.
96970b661123Smrg		func_verbose "using reloadable object file for export list..."
96980b661123Smrg		skipped_export=:
96990b661123Smrg		# Break out early, otherwise skipped_export may be
97000b661123Smrg		# set to false by a later but shorter cmd.
97010b661123Smrg		break
97020b661123Smrg	      fi
97030b661123Smrg	    done
97044f00d7e1Smrg	    IFS=$save_ifs
97054f00d7e1Smrg	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
97060b661123Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
97070b661123Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
97080b661123Smrg	    fi
97090b661123Smrg	  fi
971072313efbSmrg	fi
9711bdcaa8d0Smrg
97120b661123Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
97134f00d7e1Smrg	  tmp_export_symbols=$export_symbols
97144f00d7e1Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9715880c7e28Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
97160b661123Smrg	fi
9717bdcaa8d0Smrg
97184f00d7e1Smrg	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
97190b661123Smrg	  # The given exports_symbols file has to be filtered, so filter it.
97204f00d7e1Smrg	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
97210b661123Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
97224f00d7e1Smrg	  # 's' commands, which not all seds can handle. GNU sed should be fine
97230b661123Smrg	  # though. Also, the filter scales superlinearly with the number of
97240b661123Smrg	  # global variables. join(1) would be nice here, but unfortunately
97250b661123Smrg	  # isn't a blessed tool.
97260b661123Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9727880c7e28Smrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
97280b661123Smrg	  export_symbols=$output_objdir/$libname.def
97290b661123Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
97300b661123Smrg	fi
9731bdcaa8d0Smrg
97320b661123Smrg	tmp_deplibs=
97330b661123Smrg	for test_deplib in $deplibs; do
97340b661123Smrg	  case " $convenience " in
97350b661123Smrg	  *" $test_deplib "*) ;;
97360b661123Smrg	  *)
9737880c7e28Smrg	    func_append tmp_deplibs " $test_deplib"
97380b661123Smrg	    ;;
97390b661123Smrg	  esac
97400b661123Smrg	done
97414f00d7e1Smrg	deplibs=$tmp_deplibs
9742bdcaa8d0Smrg
97430b661123Smrg	if test -n "$convenience"; then
97440b661123Smrg	  if test -n "$whole_archive_flag_spec" &&
97454f00d7e1Smrg	    test yes = "$compiler_needs_object" &&
97460b661123Smrg	    test -z "$libobjs"; then
97470b661123Smrg	    # extract the archives, so we have objects to list.
97480b661123Smrg	    # TODO: could optimize this to just extract one archive.
97490b661123Smrg	    whole_archive_flag_spec=
97500b661123Smrg	  fi
97510b661123Smrg	  if test -n "$whole_archive_flag_spec"; then
97520b661123Smrg	    save_libobjs=$libobjs
97530b661123Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
97540b661123Smrg	    test "X$libobjs" = "X " && libobjs=
97550b661123Smrg	  else
97564f00d7e1Smrg	    gentop=$output_objdir/${outputname}x
9757880c7e28Smrg	    func_append generated " $gentop"
9758bdcaa8d0Smrg
97590b661123Smrg	    func_extract_archives $gentop $convenience
9760880c7e28Smrg	    func_append libobjs " $func_extract_archives_result"
97610b661123Smrg	    test "X$libobjs" = "X " && libobjs=
97620b661123Smrg	  fi
976396ce994aSmrg	fi
9764bdcaa8d0Smrg
97654f00d7e1Smrg	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
97660b661123Smrg	  eval flag=\"$thread_safe_flag_spec\"
9767880c7e28Smrg	  func_append linker_flags " $flag"
976896ce994aSmrg	fi
9769bdcaa8d0Smrg
97700b661123Smrg	# Make a backup of the uninstalled library when relinking
97714f00d7e1Smrg	if test relink = "$opt_mode"; then
97720b661123Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
97730b661123Smrg	fi
9774bdcaa8d0Smrg
97750b661123Smrg	# Do each of the archive commands.
97764f00d7e1Smrg	if test yes = "$module" && test -n "$module_cmds"; then
97770b661123Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
97780b661123Smrg	    eval test_cmds=\"$module_expsym_cmds\"
97790b661123Smrg	    cmds=$module_expsym_cmds
97800b661123Smrg	  else
97810b661123Smrg	    eval test_cmds=\"$module_cmds\"
97820b661123Smrg	    cmds=$module_cmds
97830b661123Smrg	  fi
978496ce994aSmrg	else
97850b661123Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
97860b661123Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
97870b661123Smrg	    cmds=$archive_expsym_cmds
97880b661123Smrg	  else
97890b661123Smrg	    eval test_cmds=\"$archive_cmds\"
97900b661123Smrg	    cmds=$archive_cmds
97910b661123Smrg	  fi
979296ce994aSmrg	fi
9793bdcaa8d0Smrg
97944f00d7e1Smrg	if test : != "$skipped_export" &&
97950b661123Smrg	   func_len " $test_cmds" &&
97960b661123Smrg	   len=$func_len_result &&
97970b661123Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
97980b661123Smrg	  :
97990b661123Smrg	else
98000b661123Smrg	  # The command line is too long to link in one step, link piecewise
98010b661123Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
98020b661123Smrg	  # script.
9803bdcaa8d0Smrg
98040b661123Smrg	  # Save the value of $output and $libobjs because we want to
98050b661123Smrg	  # use them later.  If we have whole_archive_flag_spec, we
98060b661123Smrg	  # want to use save_libobjs as it was before
98070b661123Smrg	  # whole_archive_flag_spec was expanded, because we can't
98080b661123Smrg	  # assume the linker understands whole_archive_flag_spec.
98090b661123Smrg	  # This may have to be revisited, in case too many
98100b661123Smrg	  # convenience libraries get linked in and end up exceeding
98110b661123Smrg	  # the spec.
98120b661123Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
98130b661123Smrg	    save_libobjs=$libobjs
98140b661123Smrg	  fi
98150b661123Smrg	  save_output=$output
9816880c7e28Smrg	  func_basename "$output"
9817880c7e28Smrg	  output_la=$func_basename_result
981872313efbSmrg
98190b661123Smrg	  # Clear the reloadable object creation command queue and
98200b661123Smrg	  # initialize k to one.
98210b661123Smrg	  test_cmds=
98220b661123Smrg	  concat_cmds=
98230b661123Smrg	  objlist=
98240b661123Smrg	  last_robj=
98250b661123Smrg	  k=1
98260b661123Smrg
98274f00d7e1Smrg	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
98284f00d7e1Smrg	    output=$output_objdir/$output_la.lnkscript
98290b661123Smrg	    func_verbose "creating GNU ld script: $output"
9830880c7e28Smrg	    echo 'INPUT (' > $output
98310b661123Smrg	    for obj in $save_libobjs
983296ce994aSmrg	    do
9833880c7e28Smrg	      func_to_tool_file "$obj"
9834880c7e28Smrg	      $ECHO "$func_to_tool_file_result" >> $output
98350b661123Smrg	    done
9836880c7e28Smrg	    echo ')' >> $output
9837880c7e28Smrg	    func_append delfiles " $output"
9838880c7e28Smrg	    func_to_tool_file "$output"
9839880c7e28Smrg	    output=$func_to_tool_file_result
98404f00d7e1Smrg	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
98414f00d7e1Smrg	    output=$output_objdir/$output_la.lnk
98420b661123Smrg	    func_verbose "creating linker input file list: $output"
98430b661123Smrg	    : > $output
98440b661123Smrg	    set x $save_libobjs
98450b661123Smrg	    shift
98460b661123Smrg	    firstobj=
98474f00d7e1Smrg	    if test yes = "$compiler_needs_object"; then
98480b661123Smrg	      firstobj="$1 "
98490b661123Smrg	      shift
98500b661123Smrg	    fi
98510b661123Smrg	    for obj
98520b661123Smrg	    do
9853880c7e28Smrg	      func_to_tool_file "$obj"
9854880c7e28Smrg	      $ECHO "$func_to_tool_file_result" >> $output
98550b661123Smrg	    done
9856880c7e28Smrg	    func_append delfiles " $output"
9857880c7e28Smrg	    func_to_tool_file "$output"
9858880c7e28Smrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
98590b661123Smrg	  else
98600b661123Smrg	    if test -n "$save_libobjs"; then
98610b661123Smrg	      func_verbose "creating reloadable object files..."
98624f00d7e1Smrg	      output=$output_objdir/$output_la-$k.$objext
98630b661123Smrg	      eval test_cmds=\"$reload_cmds\"
98640b661123Smrg	      func_len " $test_cmds"
98650b661123Smrg	      len0=$func_len_result
98660b661123Smrg	      len=$len0
98670b661123Smrg
98680b661123Smrg	      # Loop over the list of objects to be linked.
98690b661123Smrg	      for obj in $save_libobjs
98700b661123Smrg	      do
98710b661123Smrg		func_len " $obj"
98720b661123Smrg		func_arith $len + $func_len_result
98730b661123Smrg		len=$func_arith_result
98744f00d7e1Smrg		if test -z "$objlist" ||
98750b661123Smrg		   test "$len" -lt "$max_cmd_len"; then
98760b661123Smrg		  func_append objlist " $obj"
98770b661123Smrg		else
98780b661123Smrg		  # The command $test_cmds is almost too long, add a
98790b661123Smrg		  # command to the queue.
98804f00d7e1Smrg		  if test 1 -eq "$k"; then
98810b661123Smrg		    # The first file doesn't have a previous command to add.
9882880c7e28Smrg		    reload_objs=$objlist
9883880c7e28Smrg		    eval concat_cmds=\"$reload_cmds\"
98840b661123Smrg		  else
98850b661123Smrg		    # All subsequent reloadable object files will link in
98860b661123Smrg		    # the last one created.
9887880c7e28Smrg		    reload_objs="$objlist $last_robj"
9888880c7e28Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
98890b661123Smrg		  fi
98904f00d7e1Smrg		  last_robj=$output_objdir/$output_la-$k.$objext
98910b661123Smrg		  func_arith $k + 1
98920b661123Smrg		  k=$func_arith_result
98934f00d7e1Smrg		  output=$output_objdir/$output_la-$k.$objext
9894880c7e28Smrg		  objlist=" $obj"
98950b661123Smrg		  func_len " $last_robj"
98960b661123Smrg		  func_arith $len0 + $func_len_result
98970b661123Smrg		  len=$func_arith_result
98980b661123Smrg		fi
98990b661123Smrg	      done
99000b661123Smrg	      # Handle the remaining objects by creating one last
99010b661123Smrg	      # reloadable object file.  All subsequent reloadable object
99020b661123Smrg	      # files will link in the last one created.
99030b661123Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9904880c7e28Smrg	      reload_objs="$objlist $last_robj"
99054f00d7e1Smrg	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
99060b661123Smrg	      if test -n "$last_robj"; then
99074f00d7e1Smrg	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
99080b661123Smrg	      fi
9909880c7e28Smrg	      func_append delfiles " $output"
9910bdcaa8d0Smrg
99110b661123Smrg	    else
99120b661123Smrg	      output=
99130b661123Smrg	    fi
9914bdcaa8d0Smrg
99154f00d7e1Smrg	    ${skipped_export-false} && {
99164f00d7e1Smrg	      func_verbose "generating symbol list for '$libname.la'"
99174f00d7e1Smrg	      export_symbols=$output_objdir/$libname.exp
99180b661123Smrg	      $opt_dry_run || $RM $export_symbols
99190b661123Smrg	      libobjs=$output
99200b661123Smrg	      # Append the command to create the export file.
99210b661123Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
99220b661123Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
99230b661123Smrg	      if test -n "$last_robj"; then
99240b661123Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
99250b661123Smrg	      fi
99264f00d7e1Smrg	    }
9927bdcaa8d0Smrg
99280b661123Smrg	    test -n "$save_libobjs" &&
99290b661123Smrg	      func_verbose "creating a temporary reloadable object file: $output"
9930bdcaa8d0Smrg
99310b661123Smrg	    # Loop through the commands generated above and execute them.
99324f00d7e1Smrg	    save_ifs=$IFS; IFS='~'
99330b661123Smrg	    for cmd in $concat_cmds; do
99344f00d7e1Smrg	      IFS=$save_ifs
99354f00d7e1Smrg	      $opt_quiet || {
99360b661123Smrg		  func_quote_for_expand "$cmd"
99370b661123Smrg		  eval "func_echo $func_quote_for_expand_result"
99380b661123Smrg	      }
99390b661123Smrg	      $opt_dry_run || eval "$cmd" || {
99400b661123Smrg		lt_exit=$?
99410b661123Smrg
99420b661123Smrg		# Restore the uninstalled library and exit
99434f00d7e1Smrg		if test relink = "$opt_mode"; then
99440b661123Smrg		  ( cd "$output_objdir" && \
99450b661123Smrg		    $RM "${realname}T" && \
99460b661123Smrg		    $MV "${realname}U" "$realname" )
99470b661123Smrg		fi
994872313efbSmrg
99490b661123Smrg		exit $lt_exit
99500b661123Smrg	      }
99510b661123Smrg	    done
99524f00d7e1Smrg	    IFS=$save_ifs
995396ce994aSmrg
99540b661123Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
99550b661123Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
99560b661123Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9957bdcaa8d0Smrg	    fi
9958bdcaa8d0Smrg	  fi
995972313efbSmrg
99604f00d7e1Smrg          ${skipped_export-false} && {
99610b661123Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
99624f00d7e1Smrg	      tmp_export_symbols=$export_symbols
99634f00d7e1Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9964880c7e28Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
99650b661123Smrg	    fi
9966bdcaa8d0Smrg
99670b661123Smrg	    if test -n "$orig_export_symbols"; then
99680b661123Smrg	      # The given exports_symbols file has to be filtered, so filter it.
99694f00d7e1Smrg	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
99700b661123Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
99714f00d7e1Smrg	      # 's' commands, which not all seds can handle. GNU sed should be fine
99720b661123Smrg	      # though. Also, the filter scales superlinearly with the number of
99730b661123Smrg	      # global variables. join(1) would be nice here, but unfortunately
99740b661123Smrg	      # isn't a blessed tool.
99750b661123Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9976880c7e28Smrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
99770b661123Smrg	      export_symbols=$output_objdir/$libname.def
99780b661123Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
99790b661123Smrg	    fi
99804f00d7e1Smrg	  }
998172313efbSmrg
99820b661123Smrg	  libobjs=$output
99830b661123Smrg	  # Restore the value of output.
99840b661123Smrg	  output=$save_output
998572313efbSmrg
99860b661123Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
99870b661123Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
99880b661123Smrg	    test "X$libobjs" = "X " && libobjs=
99890b661123Smrg	  fi
99900b661123Smrg	  # Expand the library linking commands again to reset the
99910b661123Smrg	  # value of $libobjs for piecewise linking.
999272313efbSmrg
99930b661123Smrg	  # Do each of the archive commands.
99944f00d7e1Smrg	  if test yes = "$module" && test -n "$module_cmds"; then
99950b661123Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
99960b661123Smrg	      cmds=$module_expsym_cmds
99970b661123Smrg	    else
99980b661123Smrg	      cmds=$module_cmds
999996ce994aSmrg	    fi
1000096ce994aSmrg	  else
100010b661123Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
100020b661123Smrg	      cmds=$archive_expsym_cmds
100030b661123Smrg	    else
100040b661123Smrg	      cmds=$archive_cmds
100050b661123Smrg	    fi
1000696ce994aSmrg	  fi
100070b661123Smrg	fi
1000872313efbSmrg
100090b661123Smrg	if test -n "$delfiles"; then
100100b661123Smrg	  # Append the command to remove temporary files to $cmds.
100110b661123Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
100120b661123Smrg	fi
10013bdcaa8d0Smrg
100140b661123Smrg	# Add any objects from preloaded convenience libraries
100150b661123Smrg	if test -n "$dlprefiles"; then
100164f00d7e1Smrg	  gentop=$output_objdir/${outputname}x
10017880c7e28Smrg	  func_append generated " $gentop"
10018bdcaa8d0Smrg
100190b661123Smrg	  func_extract_archives $gentop $dlprefiles
10020880c7e28Smrg	  func_append libobjs " $func_extract_archives_result"
100210b661123Smrg	  test "X$libobjs" = "X " && libobjs=
100220b661123Smrg	fi
10023bdcaa8d0Smrg
100244f00d7e1Smrg	save_ifs=$IFS; IFS='~'
100250b661123Smrg	for cmd in $cmds; do
100264f00d7e1Smrg	  IFS=$sp$nl
100270b661123Smrg	  eval cmd=\"$cmd\"
100284f00d7e1Smrg	  IFS=$save_ifs
100294f00d7e1Smrg	  $opt_quiet || {
100300b661123Smrg	    func_quote_for_expand "$cmd"
100310b661123Smrg	    eval "func_echo $func_quote_for_expand_result"
100320b661123Smrg	  }
100330b661123Smrg	  $opt_dry_run || eval "$cmd" || {
100340b661123Smrg	    lt_exit=$?
10035bdcaa8d0Smrg
100360b661123Smrg	    # Restore the uninstalled library and exit
100374f00d7e1Smrg	    if test relink = "$opt_mode"; then
100380b661123Smrg	      ( cd "$output_objdir" && \
100390b661123Smrg	        $RM "${realname}T" && \
100400b661123Smrg		$MV "${realname}U" "$realname" )
100410b661123Smrg	    fi
10042bdcaa8d0Smrg
100430b661123Smrg	    exit $lt_exit
100440b661123Smrg	  }
100450b661123Smrg	done
100464f00d7e1Smrg	IFS=$save_ifs
10047bdcaa8d0Smrg
100480b661123Smrg	# Restore the uninstalled library and exit
100494f00d7e1Smrg	if test relink = "$opt_mode"; then
100500b661123Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
10051bdcaa8d0Smrg
100520b661123Smrg	  if test -n "$convenience"; then
100530b661123Smrg	    if test -z "$whole_archive_flag_spec"; then
100540b661123Smrg	      func_show_eval '${RM}r "$gentop"'
100550b661123Smrg	    fi
100560b661123Smrg	  fi
10057bdcaa8d0Smrg
100580b661123Smrg	  exit $EXIT_SUCCESS
100590b661123Smrg	fi
100600b661123Smrg
100610b661123Smrg	# Create links to the real library.
100620b661123Smrg	for linkname in $linknames; do
100630b661123Smrg	  if test "$realname" != "$linkname"; then
100640b661123Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
1006596ce994aSmrg	  fi
1006696ce994aSmrg	done
10067bdcaa8d0Smrg
100680b661123Smrg	# If -module or -export-dynamic was specified, set the dlname.
100694f00d7e1Smrg	if test yes = "$module" || test yes = "$export_dynamic"; then
100700b661123Smrg	  # On all known operating systems, these are identical.
100714f00d7e1Smrg	  dlname=$soname
100720b661123Smrg	fi
100730b661123Smrg      fi
1007472313efbSmrg      ;;
10075bdcaa8d0Smrg
100760b661123Smrg    obj)
100774f00d7e1Smrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
100784f00d7e1Smrg	func_warning "'-dlopen' is ignored for objects"
100790b661123Smrg      fi
1008096ce994aSmrg
100810b661123Smrg      case " $deplibs" in
100820b661123Smrg      *\ -l* | *\ -L*)
100834f00d7e1Smrg	func_warning "'-l' and '-L' are ignored for objects" ;;
10084bdcaa8d0Smrg      esac
10085bdcaa8d0Smrg
100860b661123Smrg      test -n "$rpath" && \
100874f00d7e1Smrg	func_warning "'-rpath' is ignored for objects"
100880b661123Smrg
100890b661123Smrg      test -n "$xrpath" && \
100904f00d7e1Smrg	func_warning "'-R' is ignored for objects"
10091bdcaa8d0Smrg
100920b661123Smrg      test -n "$vinfo" && \
100934f00d7e1Smrg	func_warning "'-version-info' is ignored for objects"
10094bdcaa8d0Smrg
100950b661123Smrg      test -n "$release" && \
100964f00d7e1Smrg	func_warning "'-release' is ignored for objects"
100970b661123Smrg
100980b661123Smrg      case $output in
100990b661123Smrg      *.lo)
101000b661123Smrg	test -n "$objs$old_deplibs" && \
101014f00d7e1Smrg	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
101020b661123Smrg
101030b661123Smrg	libobj=$output
101040b661123Smrg	func_lo2o "$libobj"
101050b661123Smrg	obj=$func_lo2o_result
1010696ce994aSmrg	;;
1010796ce994aSmrg      *)
101080b661123Smrg	libobj=
101094f00d7e1Smrg	obj=$output
10110bdcaa8d0Smrg	;;
10111bdcaa8d0Smrg      esac
10112bdcaa8d0Smrg
101130b661123Smrg      # Delete the old objects.
101140b661123Smrg      $opt_dry_run || $RM $obj $libobj
10115bdcaa8d0Smrg
101160b661123Smrg      # Objects from convenience libraries.  This assumes
101170b661123Smrg      # single-version convenience libraries.  Whenever we create
101180b661123Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
101190b661123Smrg      # the extraction.
101200b661123Smrg      reload_conv_objs=
101210b661123Smrg      gentop=
101224f00d7e1Smrg      # if reload_cmds runs $LD directly, get rid of -Wl from
101234f00d7e1Smrg      # whole_archive_flag_spec and hope we can get by with turning comma
101244f00d7e1Smrg      # into space.
101254f00d7e1Smrg      case $reload_cmds in
101264f00d7e1Smrg        *\$LD[\ \$]*) wl= ;;
101274f00d7e1Smrg      esac
101280b661123Smrg      if test -n "$convenience"; then
101290b661123Smrg	if test -n "$whole_archive_flag_spec"; then
101300b661123Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
101314f00d7e1Smrg	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
101324f00d7e1Smrg	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
101330b661123Smrg	else
101344f00d7e1Smrg	  gentop=$output_objdir/${obj}x
10135880c7e28Smrg	  func_append generated " $gentop"
1013696ce994aSmrg
101370b661123Smrg	  func_extract_archives $gentop $convenience
101380b661123Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
101390b661123Smrg	fi
1014096ce994aSmrg      fi
1014196ce994aSmrg
10142880c7e28Smrg      # If we're not building shared, we need to use non_pic_objs
101434f00d7e1Smrg      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
10144880c7e28Smrg
101450b661123Smrg      # Create the old-style object.
101464f00d7e1Smrg      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
1014796ce994aSmrg
101484f00d7e1Smrg      output=$obj
101490b661123Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
1015096ce994aSmrg
101510b661123Smrg      # Exit if we aren't doing a library object file.
101520b661123Smrg      if test -z "$libobj"; then
101530b661123Smrg	if test -n "$gentop"; then
101540b661123Smrg	  func_show_eval '${RM}r "$gentop"'
101550b661123Smrg	fi
101560b661123Smrg
101570b661123Smrg	exit $EXIT_SUCCESS
1015896ce994aSmrg      fi
101590b661123Smrg
101604f00d7e1Smrg      test yes = "$build_libtool_libs" || {
101610b661123Smrg	if test -n "$gentop"; then
101620b661123Smrg	  func_show_eval '${RM}r "$gentop"'
101630b661123Smrg	fi
101640b661123Smrg
101650b661123Smrg	# Create an invalid libtool object if no PIC, so that we don't
101660b661123Smrg	# accidentally link it into a program.
101670b661123Smrg	# $show "echo timestamp > $libobj"
101680b661123Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
101690b661123Smrg	exit $EXIT_SUCCESS
101704f00d7e1Smrg      }
101710b661123Smrg
101724f00d7e1Smrg      if test -n "$pic_flag" || test default != "$pic_mode"; then
101730b661123Smrg	# Only do commands if we really have different PIC objects.
101740b661123Smrg	reload_objs="$libobjs $reload_conv_objs"
101754f00d7e1Smrg	output=$libobj
101760b661123Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
101770b661123Smrg      fi
101780b661123Smrg
101790b661123Smrg      if test -n "$gentop"; then
101800b661123Smrg	func_show_eval '${RM}r "$gentop"'
101810b661123Smrg      fi
101820b661123Smrg
101830b661123Smrg      exit $EXIT_SUCCESS
1018496ce994aSmrg      ;;
10185bdcaa8d0Smrg
101860b661123Smrg    prog)
101870b661123Smrg      case $host in
101880b661123Smrg	*cygwin*) func_stripname '' '.exe' "$output"
101890b661123Smrg	          output=$func_stripname_result.exe;;
101900b661123Smrg      esac
101910b661123Smrg      test -n "$vinfo" && \
101924f00d7e1Smrg	func_warning "'-version-info' is ignored for programs"
10193bdcaa8d0Smrg
101940b661123Smrg      test -n "$release" && \
101954f00d7e1Smrg	func_warning "'-release' is ignored for programs"
10196bdcaa8d0Smrg
101974f00d7e1Smrg      $preload \
101984f00d7e1Smrg	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
101994f00d7e1Smrg	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
102000b661123Smrg
102010b661123Smrg      case $host in
102020b661123Smrg      *-*-rhapsody* | *-*-darwin1.[012])
102030b661123Smrg	# On Rhapsody replace the C library is the System framework
10204880c7e28Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
10205880c7e28Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
1020696ce994aSmrg	;;
102070b661123Smrg      esac
1020896ce994aSmrg
102090b661123Smrg      case $host in
102100b661123Smrg      *-*-darwin*)
102110b661123Smrg	# Don't allow lazy linking, it breaks C++ global constructors
102120b661123Smrg	# But is supposedly fixed on 10.4 or later (yay!).
102134f00d7e1Smrg	if test CXX = "$tagname"; then
102140b661123Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
102150b661123Smrg	    10.[0123])
102164f00d7e1Smrg	      func_append compile_command " $wl-bind_at_load"
102174f00d7e1Smrg	      func_append finalize_command " $wl-bind_at_load"
102180b661123Smrg	    ;;
102190b661123Smrg	  esac
1022096ce994aSmrg	fi
102210b661123Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
10222880c7e28Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10223880c7e28Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
102240b661123Smrg	;;
102250b661123Smrg      esac
1022696ce994aSmrg
1022796ce994aSmrg
102280b661123Smrg      # move library search paths that coincide with paths to not yet
102290b661123Smrg      # installed libraries to the beginning of the library search list
102300b661123Smrg      new_libs=
102310b661123Smrg      for path in $notinst_path; do
102320b661123Smrg	case " $new_libs " in
102330b661123Smrg	*" -L$path/$objdir "*) ;;
102340b661123Smrg	*)
102350b661123Smrg	  case " $compile_deplibs " in
102360b661123Smrg	  *" -L$path/$objdir "*)
10237880c7e28Smrg	    func_append new_libs " -L$path/$objdir" ;;
1023872313efbSmrg	  esac
102390b661123Smrg	  ;;
102400b661123Smrg	esac
102410b661123Smrg      done
102420b661123Smrg      for deplib in $compile_deplibs; do
102430b661123Smrg	case $deplib in
102440b661123Smrg	-L*)
102450b661123Smrg	  case " $new_libs " in
102460b661123Smrg	  *" $deplib "*) ;;
10247880c7e28Smrg	  *) func_append new_libs " $deplib" ;;
10248bdcaa8d0Smrg	  esac
102490b661123Smrg	  ;;
10250880c7e28Smrg	*) func_append new_libs " $deplib" ;;
102510b661123Smrg	esac
102520b661123Smrg      done
102534f00d7e1Smrg      compile_deplibs=$new_libs
1025472313efbSmrg
1025596ce994aSmrg
10256880c7e28Smrg      func_append compile_command " $compile_deplibs"
10257880c7e28Smrg      func_append finalize_command " $finalize_deplibs"
1025896ce994aSmrg
102590b661123Smrg      if test -n "$rpath$xrpath"; then
102600b661123Smrg	# If the user specified any rpath flags, then add them.
102610b661123Smrg	for libdir in $rpath $xrpath; do
102620b661123Smrg	  # This is the magic to use -rpath.
102630b661123Smrg	  case "$finalize_rpath " in
102640b661123Smrg	  *" $libdir "*) ;;
10265880c7e28Smrg	  *) func_append finalize_rpath " $libdir" ;;
102660b661123Smrg	  esac
102670b661123Smrg	done
102680b661123Smrg      fi
1026996ce994aSmrg
102700b661123Smrg      # Now hardcode the library paths
102710b661123Smrg      rpath=
102720b661123Smrg      hardcode_libdirs=
102730b661123Smrg      for libdir in $compile_rpath $finalize_rpath; do
102740b661123Smrg	if test -n "$hardcode_libdir_flag_spec"; then
102750b661123Smrg	  if test -n "$hardcode_libdir_separator"; then
102760b661123Smrg	    if test -z "$hardcode_libdirs"; then
102774f00d7e1Smrg	      hardcode_libdirs=$libdir
102780b661123Smrg	    else
102790b661123Smrg	      # Just accumulate the unique libdirs.
102800b661123Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
102810b661123Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
102820b661123Smrg		;;
102830b661123Smrg	      *)
10284880c7e28Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
102850b661123Smrg		;;
102860b661123Smrg	      esac
102870b661123Smrg	    fi
1028896ce994aSmrg	  else
102890b661123Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10290880c7e28Smrg	    func_append rpath " $flag"
1029196ce994aSmrg	  fi
102920b661123Smrg	elif test -n "$runpath_var"; then
102930b661123Smrg	  case "$perm_rpath " in
102940b661123Smrg	  *" $libdir "*) ;;
10295880c7e28Smrg	  *) func_append perm_rpath " $libdir" ;;
102960b661123Smrg	  esac
102970b661123Smrg	fi
102980b661123Smrg	case $host in
102990b661123Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
103004f00d7e1Smrg	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
103010b661123Smrg	  case :$dllsearchpath: in
103020b661123Smrg	  *":$libdir:"*) ;;
103030b661123Smrg	  ::) dllsearchpath=$libdir;;
10304880c7e28Smrg	  *) func_append dllsearchpath ":$libdir";;
103050b661123Smrg	  esac
103060b661123Smrg	  case :$dllsearchpath: in
103070b661123Smrg	  *":$testbindir:"*) ;;
103080b661123Smrg	  ::) dllsearchpath=$testbindir;;
10309880c7e28Smrg	  *) func_append dllsearchpath ":$testbindir";;
103100b661123Smrg	  esac
103110b661123Smrg	  ;;
103120b661123Smrg	esac
103130b661123Smrg      done
103140b661123Smrg      # Substitute the hardcoded libdirs into the rpath.
103150b661123Smrg      if test -n "$hardcode_libdir_separator" &&
103160b661123Smrg	 test -n "$hardcode_libdirs"; then
103174f00d7e1Smrg	libdir=$hardcode_libdirs
103180b661123Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
103190b661123Smrg      fi
103204f00d7e1Smrg      compile_rpath=$rpath
1032196ce994aSmrg
103220b661123Smrg      rpath=
103230b661123Smrg      hardcode_libdirs=
103240b661123Smrg      for libdir in $finalize_rpath; do
103250b661123Smrg	if test -n "$hardcode_libdir_flag_spec"; then
103260b661123Smrg	  if test -n "$hardcode_libdir_separator"; then
103270b661123Smrg	    if test -z "$hardcode_libdirs"; then
103284f00d7e1Smrg	      hardcode_libdirs=$libdir
103290b661123Smrg	    else
103300b661123Smrg	      # Just accumulate the unique libdirs.
103310b661123Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
103320b661123Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
103330b661123Smrg		;;
103340b661123Smrg	      *)
10335880c7e28Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
103360b661123Smrg		;;
103370b661123Smrg	      esac
103380b661123Smrg	    fi
1033972313efbSmrg	  else
103400b661123Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10341880c7e28Smrg	    func_append rpath " $flag"
1034272313efbSmrg	  fi
103430b661123Smrg	elif test -n "$runpath_var"; then
103440b661123Smrg	  case "$finalize_perm_rpath " in
103450b661123Smrg	  *" $libdir "*) ;;
10346880c7e28Smrg	  *) func_append finalize_perm_rpath " $libdir" ;;
103470b661123Smrg	  esac
10348bdcaa8d0Smrg	fi
103490b661123Smrg      done
103500b661123Smrg      # Substitute the hardcoded libdirs into the rpath.
103510b661123Smrg      if test -n "$hardcode_libdir_separator" &&
103520b661123Smrg	 test -n "$hardcode_libdirs"; then
103534f00d7e1Smrg	libdir=$hardcode_libdirs
103540b661123Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
103550b661123Smrg      fi
103564f00d7e1Smrg      finalize_rpath=$rpath
10357bdcaa8d0Smrg
103584f00d7e1Smrg      if test -n "$libobjs" && test yes = "$build_old_libs"; then
103590b661123Smrg	# Transform all the library objects into standard objects.
10360880c7e28Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10361880c7e28Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
103620b661123Smrg      fi
10363bdcaa8d0Smrg
103644f00d7e1Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" false
10365bdcaa8d0Smrg
103660b661123Smrg      # template prelinking step
103670b661123Smrg      if test -n "$prelink_cmds"; then
103680b661123Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
103690b661123Smrg      fi
10370bdcaa8d0Smrg
103714f00d7e1Smrg      wrappers_required=:
103720b661123Smrg      case $host in
10373880c7e28Smrg      *cegcc* | *mingw32ce*)
10374880c7e28Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
103754f00d7e1Smrg        wrappers_required=false
10376880c7e28Smrg        ;;
103770b661123Smrg      *cygwin* | *mingw* )
103784f00d7e1Smrg        test yes = "$build_libtool_libs" || wrappers_required=false
103790b661123Smrg        ;;
103800b661123Smrg      *)
103814f00d7e1Smrg        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
103824f00d7e1Smrg          wrappers_required=false
103830b661123Smrg        fi
103840b661123Smrg        ;;
103850b661123Smrg      esac
103864f00d7e1Smrg      $wrappers_required || {
103870b661123Smrg	# Replace the output file specification.
10388880c7e28Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
103894f00d7e1Smrg	link_command=$compile_command$compile_rpath
10390bdcaa8d0Smrg
103910b661123Smrg	# We have no uninstalled library dependencies, so finalize right now.
103920b661123Smrg	exit_status=0
103930b661123Smrg	func_show_eval "$link_command" 'exit_status=$?'
10394bdcaa8d0Smrg
10395880c7e28Smrg	if test -n "$postlink_cmds"; then
10396880c7e28Smrg	  func_to_tool_file "$output"
10397880c7e28Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10398880c7e28Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
10399880c7e28Smrg	fi
10400880c7e28Smrg
104010b661123Smrg	# Delete the generated files.
104024f00d7e1Smrg	if test -f "$output_objdir/${outputname}S.$objext"; then
104034f00d7e1Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
1040472313efbSmrg	fi
10405bdcaa8d0Smrg
104060b661123Smrg	exit $exit_status
104074f00d7e1Smrg      }
10408bdcaa8d0Smrg
104090b661123Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
104100b661123Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
104110b661123Smrg      fi
104120b661123Smrg      if test -n "$finalize_shlibpath"; then
104130b661123Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
104140b661123Smrg      fi
1041596ce994aSmrg
104160b661123Smrg      compile_var=
104170b661123Smrg      finalize_var=
104180b661123Smrg      if test -n "$runpath_var"; then
104190b661123Smrg	if test -n "$perm_rpath"; then
104200b661123Smrg	  # We should set the runpath_var.
104210b661123Smrg	  rpath=
104220b661123Smrg	  for dir in $perm_rpath; do
10423880c7e28Smrg	    func_append rpath "$dir:"
104240b661123Smrg	  done
104250b661123Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
10426bdcaa8d0Smrg	fi
104270b661123Smrg	if test -n "$finalize_perm_rpath"; then
104280b661123Smrg	  # We should set the runpath_var.
104290b661123Smrg	  rpath=
104300b661123Smrg	  for dir in $finalize_perm_rpath; do
10431880c7e28Smrg	    func_append rpath "$dir:"
104320b661123Smrg	  done
104330b661123Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
1043472313efbSmrg	fi
104350b661123Smrg      fi
10436bdcaa8d0Smrg
104374f00d7e1Smrg      if test yes = "$no_install"; then
104380b661123Smrg	# We don't need to create a wrapper script.
104394f00d7e1Smrg	link_command=$compile_var$compile_command$compile_rpath
104400b661123Smrg	# Replace the output file specification.
10441880c7e28Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
104420b661123Smrg	# Delete the old output file.
104430b661123Smrg	$opt_dry_run || $RM $output
104440b661123Smrg	# Link the executable and exit
104450b661123Smrg	func_show_eval "$link_command" 'exit $?'
10446880c7e28Smrg
10447880c7e28Smrg	if test -n "$postlink_cmds"; then
10448880c7e28Smrg	  func_to_tool_file "$output"
10449880c7e28Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10450880c7e28Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
10451880c7e28Smrg	fi
10452880c7e28Smrg
1045396ce994aSmrg	exit $EXIT_SUCCESS
104540b661123Smrg      fi
10455bdcaa8d0Smrg
104564f00d7e1Smrg      case $hardcode_action,$fast_install in
104574f00d7e1Smrg        relink,*)
104584f00d7e1Smrg	  # Fast installation is not supported
104594f00d7e1Smrg	  link_command=$compile_var$compile_command$compile_rpath
104604f00d7e1Smrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
104610b661123Smrg
104624f00d7e1Smrg	  func_warning "this platform does not like uninstalled shared libraries"
104634f00d7e1Smrg	  func_warning "'$output' will be relinked during installation"
104644f00d7e1Smrg	  ;;
104654f00d7e1Smrg        *,yes)
104664f00d7e1Smrg	  link_command=$finalize_var$compile_command$finalize_rpath
104674f00d7e1Smrg	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
104684f00d7e1Smrg          ;;
104694f00d7e1Smrg	*,no)
104704f00d7e1Smrg	  link_command=$compile_var$compile_command$compile_rpath
104714f00d7e1Smrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
104724f00d7e1Smrg          ;;
104734f00d7e1Smrg	*,needless)
104744f00d7e1Smrg	  link_command=$finalize_var$compile_command$finalize_rpath
104754f00d7e1Smrg	  relink_command=
104764f00d7e1Smrg          ;;
104774f00d7e1Smrg      esac
10478bdcaa8d0Smrg
104790b661123Smrg      # Replace the output file specification.
10480880c7e28Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
10481bdcaa8d0Smrg
104820b661123Smrg      # Delete the old output files.
104830b661123Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
10484bdcaa8d0Smrg
104850b661123Smrg      func_show_eval "$link_command" 'exit $?'
1048696ce994aSmrg
10487880c7e28Smrg      if test -n "$postlink_cmds"; then
10488880c7e28Smrg	func_to_tool_file "$output_objdir/$outputname"
10489880c7e28Smrg	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'`
10490880c7e28Smrg	func_execute_cmds "$postlink_cmds" 'exit $?'
10491880c7e28Smrg      fi
10492880c7e28Smrg
104930b661123Smrg      # Now create the wrapper script.
104940b661123Smrg      func_verbose "creating $output"
1049596ce994aSmrg
104960b661123Smrg      # Quote the relink command for shipping.
104970b661123Smrg      if test -n "$relink_command"; then
104980b661123Smrg	# Preserve any variables that may affect compiler behavior
104990b661123Smrg	for var in $variables_saved_for_relink; do
105000b661123Smrg	  if eval test -z \"\${$var+set}\"; then
105010b661123Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
105020b661123Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
105030b661123Smrg	    relink_command="$var=; export $var; $relink_command"
1050472313efbSmrg	  else
105050b661123Smrg	    func_quote_for_eval "$var_value"
105060b661123Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
1050772313efbSmrg	  fi
105080b661123Smrg	done
105090b661123Smrg	relink_command="(cd `pwd`; $relink_command)"
10510880c7e28Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
105110b661123Smrg      fi
105120b661123Smrg
105130b661123Smrg      # Only actually do things if not in dry run mode.
105140b661123Smrg      $opt_dry_run || {
105150b661123Smrg	# win32 will think the script is a binary if it has
105160b661123Smrg	# a .exe suffix, so we strip it off here.
105170b661123Smrg	case $output in
105180b661123Smrg	  *.exe) func_stripname '' '.exe' "$output"
105190b661123Smrg	         output=$func_stripname_result ;;
105200b661123Smrg	esac
105210b661123Smrg	# test for cygwin because mv fails w/o .exe extensions
105220b661123Smrg	case $host in
105230b661123Smrg	  *cygwin*)
105240b661123Smrg	    exeext=.exe
105250b661123Smrg	    func_stripname '' '.exe' "$outputname"
105260b661123Smrg	    outputname=$func_stripname_result ;;
105270b661123Smrg	  *) exeext= ;;
10528bdcaa8d0Smrg	esac
105290b661123Smrg	case $host in
105300b661123Smrg	  *cygwin* | *mingw* )
105310b661123Smrg	    func_dirname_and_basename "$output" "" "."
105320b661123Smrg	    output_name=$func_basename_result
105330b661123Smrg	    output_path=$func_dirname_result
105344f00d7e1Smrg	    cwrappersource=$output_path/$objdir/lt-$output_name.c
105354f00d7e1Smrg	    cwrapper=$output_path/$output_name.exe
105360b661123Smrg	    $RM $cwrappersource $cwrapper
105370b661123Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
105380b661123Smrg
105390b661123Smrg	    func_emit_cwrapperexe_src > $cwrappersource
105400b661123Smrg
105410b661123Smrg	    # The wrapper executable is built using the $host compiler,
105420b661123Smrg	    # because it contains $host paths and files. If cross-
105430b661123Smrg	    # compiling, it, like the target executable, must be
105440b661123Smrg	    # executed on the $host or under an emulation environment.
105450b661123Smrg	    $opt_dry_run || {
105460b661123Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
105470b661123Smrg	      $STRIP $cwrapper
105480b661123Smrg	    }
10549bdcaa8d0Smrg
105500b661123Smrg	    # Now, create the wrapper script for func_source use:
105510b661123Smrg	    func_ltwrapper_scriptname $cwrapper
105520b661123Smrg	    $RM $func_ltwrapper_scriptname_result
105530b661123Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
105540b661123Smrg	    $opt_dry_run || {
105550b661123Smrg	      # note: this script will not be executed, so do not chmod.
105564f00d7e1Smrg	      if test "x$build" = "x$host"; then
105570b661123Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
105580b661123Smrg	      else
105590b661123Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
105600b661123Smrg	      fi
105610b661123Smrg	    }
105620b661123Smrg	  ;;
105630b661123Smrg	  * )
105640b661123Smrg	    $RM $output
105650b661123Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
10566bdcaa8d0Smrg
105670b661123Smrg	    func_emit_wrapper no > $output
105680b661123Smrg	    chmod +x $output
105690b661123Smrg	  ;;
105700b661123Smrg	esac
105710b661123Smrg      }
105720b661123Smrg      exit $EXIT_SUCCESS
105730b661123Smrg      ;;
105740b661123Smrg    esac
10575bdcaa8d0Smrg
105760b661123Smrg    # See if we need to build an old-fashioned archive.
105770b661123Smrg    for oldlib in $oldlibs; do
10578bdcaa8d0Smrg
105794f00d7e1Smrg      case $build_libtool_libs in
105804f00d7e1Smrg        convenience)
105814f00d7e1Smrg	  oldobjs="$libobjs_save $symfileobj"
105824f00d7e1Smrg	  addlibs=$convenience
105830b661123Smrg	  build_libtool_libs=no
105844f00d7e1Smrg	  ;;
105854f00d7e1Smrg	module)
105864f00d7e1Smrg	  oldobjs=$libobjs_save
105874f00d7e1Smrg	  addlibs=$old_convenience
105884f00d7e1Smrg	  build_libtool_libs=no
105894f00d7e1Smrg          ;;
105904f00d7e1Smrg	*)
105910b661123Smrg	  oldobjs="$old_deplibs $non_pic_objects"
105924f00d7e1Smrg	  $preload && test -f "$symfileobj" \
105934f00d7e1Smrg	    && func_append oldobjs " $symfileobj"
105944f00d7e1Smrg	  addlibs=$old_convenience
105954f00d7e1Smrg	  ;;
105964f00d7e1Smrg      esac
10597bdcaa8d0Smrg
105980b661123Smrg      if test -n "$addlibs"; then
105994f00d7e1Smrg	gentop=$output_objdir/${outputname}x
10600880c7e28Smrg	func_append generated " $gentop"
10601bdcaa8d0Smrg
106020b661123Smrg	func_extract_archives $gentop $addlibs
10603880c7e28Smrg	func_append oldobjs " $func_extract_archives_result"
106040b661123Smrg      fi
10605bdcaa8d0Smrg
106060b661123Smrg      # Do each command in the archive commands.
106074f00d7e1Smrg      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
106080b661123Smrg	cmds=$old_archive_from_new_cmds
106090b661123Smrg      else
10610bdcaa8d0Smrg
106110b661123Smrg	# Add any objects from preloaded convenience libraries
106120b661123Smrg	if test -n "$dlprefiles"; then
106134f00d7e1Smrg	  gentop=$output_objdir/${outputname}x
10614880c7e28Smrg	  func_append generated " $gentop"
10615bdcaa8d0Smrg
106160b661123Smrg	  func_extract_archives $gentop $dlprefiles
10617880c7e28Smrg	  func_append oldobjs " $func_extract_archives_result"
106180b661123Smrg	fi
10619bdcaa8d0Smrg
106200b661123Smrg	# POSIX demands no paths to be encoded in archives.  We have
106210b661123Smrg	# to avoid creating archives with duplicate basenames if we
106220b661123Smrg	# might have to extract them afterwards, e.g., when creating a
106230b661123Smrg	# static archive out of a convenience library, or when linking
106240b661123Smrg	# the entirety of a libtool archive into another (currently
106250b661123Smrg	# not supported by libtool).
106260b661123Smrg	if (for obj in $oldobjs
106270b661123Smrg	    do
106280b661123Smrg	      func_basename "$obj"
106290b661123Smrg	      $ECHO "$func_basename_result"
106300b661123Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
106310b661123Smrg	  :
106320b661123Smrg	else
10633880c7e28Smrg	  echo "copying selected object files to avoid basename conflicts..."
106344f00d7e1Smrg	  gentop=$output_objdir/${outputname}x
10635880c7e28Smrg	  func_append generated " $gentop"
106360b661123Smrg	  func_mkdir_p "$gentop"
106370b661123Smrg	  save_oldobjs=$oldobjs
106380b661123Smrg	  oldobjs=
106390b661123Smrg	  counter=1
106400b661123Smrg	  for obj in $save_oldobjs
106410b661123Smrg	  do
106420b661123Smrg	    func_basename "$obj"
106434f00d7e1Smrg	    objbase=$func_basename_result
106440b661123Smrg	    case " $oldobjs " in
106450b661123Smrg	    " ") oldobjs=$obj ;;
106460b661123Smrg	    *[\ /]"$objbase "*)
106470b661123Smrg	      while :; do
106480b661123Smrg		# Make sure we don't pick an alternate name that also
106490b661123Smrg		# overlaps.
106500b661123Smrg		newobj=lt$counter-$objbase
106510b661123Smrg		func_arith $counter + 1
106520b661123Smrg		counter=$func_arith_result
106530b661123Smrg		case " $oldobjs " in
106540b661123Smrg		*[\ /]"$newobj "*) ;;
106550b661123Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
106560b661123Smrg		esac
106570b661123Smrg	      done
106580b661123Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
10659880c7e28Smrg	      func_append oldobjs " $gentop/$newobj"
106600b661123Smrg	      ;;
10661880c7e28Smrg	    *) func_append oldobjs " $obj" ;;
106620b661123Smrg	    esac
10663bdcaa8d0Smrg	  done
1066472313efbSmrg	fi
10665880c7e28Smrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
10666880c7e28Smrg	tool_oldlib=$func_to_tool_file_result
106670b661123Smrg	eval cmds=\"$old_archive_cmds\"
1066896ce994aSmrg
106690b661123Smrg	func_len " $cmds"
106700b661123Smrg	len=$func_len_result
106710b661123Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
106720b661123Smrg	  cmds=$old_archive_cmds
10673880c7e28Smrg	elif test -n "$archiver_list_spec"; then
10674880c7e28Smrg	  func_verbose "using command file archive linking..."
10675880c7e28Smrg	  for obj in $oldobjs
10676880c7e28Smrg	  do
10677880c7e28Smrg	    func_to_tool_file "$obj"
10678880c7e28Smrg	    $ECHO "$func_to_tool_file_result"
10679880c7e28Smrg	  done > $output_objdir/$libname.libcmd
10680880c7e28Smrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
10681880c7e28Smrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
10682880c7e28Smrg	  cmds=$old_archive_cmds
106830b661123Smrg	else
106840b661123Smrg	  # the command line is too long to link in one step, link in parts
106850b661123Smrg	  func_verbose "using piecewise archive linking..."
106860b661123Smrg	  save_RANLIB=$RANLIB
106870b661123Smrg	  RANLIB=:
106880b661123Smrg	  objlist=
106890b661123Smrg	  concat_cmds=
106900b661123Smrg	  save_oldobjs=$oldobjs
106910b661123Smrg	  oldobjs=
106920b661123Smrg	  # Is there a better way of finding the last object in the list?
106930b661123Smrg	  for obj in $save_oldobjs
106940b661123Smrg	  do
106950b661123Smrg	    last_oldobj=$obj
106960b661123Smrg	  done
106970b661123Smrg	  eval test_cmds=\"$old_archive_cmds\"
106980b661123Smrg	  func_len " $test_cmds"
106990b661123Smrg	  len0=$func_len_result
107000b661123Smrg	  len=$len0
107010b661123Smrg	  for obj in $save_oldobjs
107020b661123Smrg	  do
107030b661123Smrg	    func_len " $obj"
107040b661123Smrg	    func_arith $len + $func_len_result
107050b661123Smrg	    len=$func_arith_result
107060b661123Smrg	    func_append objlist " $obj"
107070b661123Smrg	    if test "$len" -lt "$max_cmd_len"; then
107080b661123Smrg	      :
107090b661123Smrg	    else
107100b661123Smrg	      # the above command should be used before it gets too long
107110b661123Smrg	      oldobjs=$objlist
107124f00d7e1Smrg	      if test "$obj" = "$last_oldobj"; then
107130b661123Smrg		RANLIB=$save_RANLIB
107140b661123Smrg	      fi
107150b661123Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
107164f00d7e1Smrg	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
107170b661123Smrg	      objlist=
107180b661123Smrg	      len=$len0
107190b661123Smrg	    fi
107200b661123Smrg	  done
107210b661123Smrg	  RANLIB=$save_RANLIB
107220b661123Smrg	  oldobjs=$objlist
107234f00d7e1Smrg	  if test -z "$oldobjs"; then
107240b661123Smrg	    eval cmds=\"\$concat_cmds\"
107250b661123Smrg	  else
107260b661123Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
107270b661123Smrg	  fi
107280b661123Smrg	fi
107290b661123Smrg      fi
107300b661123Smrg      func_execute_cmds "$cmds" 'exit $?'
10731bdcaa8d0Smrg    done
10732bdcaa8d0Smrg
107330b661123Smrg    test -n "$generated" && \
107340b661123Smrg      func_show_eval "${RM}r$generated"
10735bdcaa8d0Smrg
107360b661123Smrg    # Now create the libtool archive.
107370b661123Smrg    case $output in
107380b661123Smrg    *.la)
107390b661123Smrg      old_library=
107404f00d7e1Smrg      test yes = "$build_old_libs" && old_library=$libname.$libext
107410b661123Smrg      func_verbose "creating $output"
1074272313efbSmrg
107430b661123Smrg      # Preserve any variables that may affect compiler behavior
107440b661123Smrg      for var in $variables_saved_for_relink; do
107450b661123Smrg	if eval test -z \"\${$var+set}\"; then
107460b661123Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
107470b661123Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
107480b661123Smrg	  relink_command="$var=; export $var; $relink_command"
1074996ce994aSmrg	else
107500b661123Smrg	  func_quote_for_eval "$var_value"
107510b661123Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
1075296ce994aSmrg	fi
107530b661123Smrg      done
107540b661123Smrg      # Quote the link command for shipping.
107554f00d7e1Smrg      relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
10756880c7e28Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
107574f00d7e1Smrg      if test yes = "$hardcode_automatic"; then
107580b661123Smrg	relink_command=
107590b661123Smrg      fi
10760bdcaa8d0Smrg
107610b661123Smrg      # Only create the output if not a dry run.
107620b661123Smrg      $opt_dry_run || {
107630b661123Smrg	for installed in no yes; do
107644f00d7e1Smrg	  if test yes = "$installed"; then
107650b661123Smrg	    if test -z "$install_libdir"; then
107660b661123Smrg	      break
107670b661123Smrg	    fi
107684f00d7e1Smrg	    output=$output_objdir/${outputname}i
107690b661123Smrg	    # Replace all uninstalled libtool libraries with the installed ones
107700b661123Smrg	    newdependency_libs=
107710b661123Smrg	    for deplib in $dependency_libs; do
107720b661123Smrg	      case $deplib in
107730b661123Smrg	      *.la)
107740b661123Smrg		func_basename "$deplib"
107754f00d7e1Smrg		name=$func_basename_result
10776880c7e28Smrg		func_resolve_sysroot "$deplib"
107774f00d7e1Smrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
107780b661123Smrg		test -z "$libdir" && \
107794f00d7e1Smrg		  func_fatal_error "'$deplib' is not a valid libtool archive"
10780880c7e28Smrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
10781880c7e28Smrg		;;
10782880c7e28Smrg	      -L*)
10783880c7e28Smrg		func_stripname -L '' "$deplib"
10784880c7e28Smrg		func_replace_sysroot "$func_stripname_result"
10785880c7e28Smrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
107860b661123Smrg		;;
10787880c7e28Smrg	      -R*)
10788880c7e28Smrg		func_stripname -R '' "$deplib"
10789880c7e28Smrg		func_replace_sysroot "$func_stripname_result"
10790880c7e28Smrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
10791880c7e28Smrg		;;
10792880c7e28Smrg	      *) func_append newdependency_libs " $deplib" ;;
107930b661123Smrg	      esac
107940b661123Smrg	    done
107954f00d7e1Smrg	    dependency_libs=$newdependency_libs
107960b661123Smrg	    newdlfiles=
107970b661123Smrg
107980b661123Smrg	    for lib in $dlfiles; do
107990b661123Smrg	      case $lib in
108000b661123Smrg	      *.la)
108010b661123Smrg	        func_basename "$lib"
108024f00d7e1Smrg		name=$func_basename_result
108034f00d7e1Smrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
108040b661123Smrg		test -z "$libdir" && \
108054f00d7e1Smrg		  func_fatal_error "'$lib' is not a valid libtool archive"
10806880c7e28Smrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
108070b661123Smrg		;;
10808880c7e28Smrg	      *) func_append newdlfiles " $lib" ;;
108090b661123Smrg	      esac
108100b661123Smrg	    done
108114f00d7e1Smrg	    dlfiles=$newdlfiles
108120b661123Smrg	    newdlprefiles=
108130b661123Smrg	    for lib in $dlprefiles; do
108140b661123Smrg	      case $lib in
108150b661123Smrg	      *.la)
108160b661123Smrg		# Only pass preopened files to the pseudo-archive (for
108170b661123Smrg		# eventual linking with the app. that links it) if we
108180b661123Smrg		# didn't already link the preopened objects directly into
108190b661123Smrg		# the library:
108200b661123Smrg		func_basename "$lib"
108214f00d7e1Smrg		name=$func_basename_result
108224f00d7e1Smrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
108230b661123Smrg		test -z "$libdir" && \
108244f00d7e1Smrg		  func_fatal_error "'$lib' is not a valid libtool archive"
10825880c7e28Smrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
108260b661123Smrg		;;
108270b661123Smrg	      esac
108280b661123Smrg	    done
108294f00d7e1Smrg	    dlprefiles=$newdlprefiles
108300b661123Smrg	  else
108310b661123Smrg	    newdlfiles=
108320b661123Smrg	    for lib in $dlfiles; do
108330b661123Smrg	      case $lib in
108344f00d7e1Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
108350b661123Smrg		*) abs=`pwd`"/$lib" ;;
108360b661123Smrg	      esac
10837880c7e28Smrg	      func_append newdlfiles " $abs"
108380b661123Smrg	    done
108394f00d7e1Smrg	    dlfiles=$newdlfiles
108400b661123Smrg	    newdlprefiles=
108410b661123Smrg	    for lib in $dlprefiles; do
108420b661123Smrg	      case $lib in
108434f00d7e1Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
108440b661123Smrg		*) abs=`pwd`"/$lib" ;;
108450b661123Smrg	      esac
10846880c7e28Smrg	      func_append newdlprefiles " $abs"
108470b661123Smrg	    done
108484f00d7e1Smrg	    dlprefiles=$newdlprefiles
108490b661123Smrg	  fi
108500b661123Smrg	  $RM $output
108510b661123Smrg	  # place dlname in correct position for cygwin
10852880c7e28Smrg	  # In fact, it would be nice if we could use this code for all target
10853880c7e28Smrg	  # systems that can't hard-code library paths into their executables
10854880c7e28Smrg	  # and that have no shared library path variable independent of PATH,
10855880c7e28Smrg	  # but it turns out we can't easily determine that from inspecting
10856880c7e28Smrg	  # libtool variables, so we have to hard-code the OSs to which it
10857880c7e28Smrg	  # applies here; at the moment, that means platforms that use the PE
10858880c7e28Smrg	  # object format with DLL files.  See the long comment at the top of
10859880c7e28Smrg	  # tests/bindir.at for full details.
108600b661123Smrg	  tdlname=$dlname
108610b661123Smrg	  case $host,$output,$installed,$module,$dlname in
10862880c7e28Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
10863880c7e28Smrg	      # If a -bindir argument was supplied, place the dll there.
108644f00d7e1Smrg	      if test -n "$bindir"; then
10865880c7e28Smrg		func_relative_path "$install_libdir" "$bindir"
108664f00d7e1Smrg		tdlname=$func_relative_path_result/$dlname
10867880c7e28Smrg	      else
10868880c7e28Smrg		# Otherwise fall back on heuristic.
10869880c7e28Smrg		tdlname=../bin/$dlname
10870880c7e28Smrg	      fi
10871880c7e28Smrg	      ;;
108720b661123Smrg	  esac
108730b661123Smrg	  $ECHO > $output "\
108740b661123Smrg# $outputname - a libtool library file
108754f00d7e1Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
108760b661123Smrg#
108770b661123Smrg# Please DO NOT delete this file!
108780b661123Smrg# It is necessary for linking the library.
10879bdcaa8d0Smrg
108800b661123Smrg# The name that we can dlopen(3).
108810b661123Smrgdlname='$tdlname'
10882bdcaa8d0Smrg
108830b661123Smrg# Names of this library.
108840b661123Smrglibrary_names='$library_names'
10885bdcaa8d0Smrg
108860b661123Smrg# The name of the static archive.
108870b661123Smrgold_library='$old_library'
10888bdcaa8d0Smrg
108894f00d7e1Smrg# Linker flags that cannot go in dependency_libs.
108900b661123Smrginherited_linker_flags='$new_inherited_linker_flags'
10891bdcaa8d0Smrg
108920b661123Smrg# Libraries that this one depends upon.
108930b661123Smrgdependency_libs='$dependency_libs'
10894bdcaa8d0Smrg
108950b661123Smrg# Names of additional weak libraries provided by this library
108960b661123Smrgweak_library_names='$weak_libs'
10897bdcaa8d0Smrg
108980b661123Smrg# Version information for $libname.
108990b661123Smrgcurrent=$current
109000b661123Smrgage=$age
109010b661123Smrgrevision=$revision
10902bdcaa8d0Smrg
109030b661123Smrg# Is this an already installed library?
109040b661123Smrginstalled=$installed
10905bdcaa8d0Smrg
109060b661123Smrg# Should we warn about portability when linking against -modules?
109070b661123Smrgshouldnotlink=$module
10908bdcaa8d0Smrg
109090b661123Smrg# Files to dlopen/dlpreopen
109100b661123Smrgdlopen='$dlfiles'
109110b661123Smrgdlpreopen='$dlprefiles'
10912bdcaa8d0Smrg
109130b661123Smrg# Directory that this library needs to be installed in:
109140b661123Smrglibdir='$install_libdir'"
109154f00d7e1Smrg	  if test no,yes = "$installed,$need_relink"; then
109160b661123Smrg	    $ECHO >> $output "\
109170b661123Smrgrelink_command=\"$relink_command\""
109180b661123Smrg	  fi
109190b661123Smrg	done
109200b661123Smrg      }
10921bdcaa8d0Smrg
109220b661123Smrg      # Do a symbolic link so that the libtool archive can be found in
109230b661123Smrg      # LD_LIBRARY_PATH before the program is installed.
109240b661123Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
109250b661123Smrg      ;;
109260b661123Smrg    esac
109270b661123Smrg    exit $EXIT_SUCCESS
109280b661123Smrg}
1092996ce994aSmrg
109304f00d7e1Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then
109314f00d7e1Smrg  func_mode_link ${1+"$@"}
109324f00d7e1Smrgfi
10933bdcaa8d0Smrg
10934bdcaa8d0Smrg
109350b661123Smrg# func_mode_uninstall arg...
109360b661123Smrgfunc_mode_uninstall ()
109370b661123Smrg{
109384f00d7e1Smrg    $debug_cmd
109394f00d7e1Smrg
109404f00d7e1Smrg    RM=$nonopt
10941bdcaa8d0Smrg    files=
109424f00d7e1Smrg    rmforce=false
10943bdcaa8d0Smrg    exit_status=0
10944bdcaa8d0Smrg
10945bdcaa8d0Smrg    # This variable tells wrapper scripts just to set variables rather
10946bdcaa8d0Smrg    # than running their programs.
109474f00d7e1Smrg    libtool_install_magic=$magic
10948bdcaa8d0Smrg
10949bdcaa8d0Smrg    for arg
10950bdcaa8d0Smrg    do
10951bdcaa8d0Smrg      case $arg in
109524f00d7e1Smrg      -f) func_append RM " $arg"; rmforce=: ;;
10953880c7e28Smrg      -*) func_append RM " $arg" ;;
10954880c7e28Smrg      *) func_append files " $arg" ;;
10955bdcaa8d0Smrg      esac
10956bdcaa8d0Smrg    done
10957bdcaa8d0Smrg
109580b661123Smrg    test -z "$RM" && \
109590b661123Smrg      func_fatal_help "you must specify an RM program"
10960bdcaa8d0Smrg
10961bdcaa8d0Smrg    rmdirs=
10962bdcaa8d0Smrg
10963bdcaa8d0Smrg    for file in $files; do
109640b661123Smrg      func_dirname "$file" "" "."
109654f00d7e1Smrg      dir=$func_dirname_result
109664f00d7e1Smrg      if test . = "$dir"; then
109674f00d7e1Smrg	odir=$objdir
10968bdcaa8d0Smrg      else
109694f00d7e1Smrg	odir=$dir/$objdir
10970bdcaa8d0Smrg      fi
109710b661123Smrg      func_basename "$file"
109724f00d7e1Smrg      name=$func_basename_result
109734f00d7e1Smrg      test uninstall = "$opt_mode" && odir=$dir
10974bdcaa8d0Smrg
10975880c7e28Smrg      # Remember odir for removal later, being careful to avoid duplicates
109764f00d7e1Smrg      if test clean = "$opt_mode"; then
10977bdcaa8d0Smrg	case " $rmdirs " in
10978880c7e28Smrg	  *" $odir "*) ;;
10979880c7e28Smrg	  *) func_append rmdirs " $odir" ;;
10980bdcaa8d0Smrg	esac
10981bdcaa8d0Smrg      fi
10982bdcaa8d0Smrg
10983bdcaa8d0Smrg      # Don't error if the file doesn't exist and rm -f was used.
109840b661123Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
109850b661123Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
109860b661123Smrg	 test -f "$file"; then
10987bdcaa8d0Smrg	:
10988bdcaa8d0Smrg      elif test -d "$file"; then
10989bdcaa8d0Smrg	exit_status=1
10990bdcaa8d0Smrg	continue
109914f00d7e1Smrg      elif $rmforce; then
10992bdcaa8d0Smrg	continue
10993bdcaa8d0Smrg      fi
10994bdcaa8d0Smrg
109954f00d7e1Smrg      rmfiles=$file
10996bdcaa8d0Smrg
10997bdcaa8d0Smrg      case $name in
10998bdcaa8d0Smrg      *.la)
10999bdcaa8d0Smrg	# Possibly a libtool archive, so verify it.
110000b661123Smrg	if func_lalib_p "$file"; then
110010b661123Smrg	  func_source $dir/$name
11002bdcaa8d0Smrg
11003bdcaa8d0Smrg	  # Delete the libtool libraries and symlinks.
11004bdcaa8d0Smrg	  for n in $library_names; do
11005880c7e28Smrg	    func_append rmfiles " $odir/$n"
11006bdcaa8d0Smrg	  done
11007880c7e28Smrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
11008bdcaa8d0Smrg
110094f00d7e1Smrg	  case $opt_mode in
11010bdcaa8d0Smrg	  clean)
11011880c7e28Smrg	    case " $library_names " in
11012bdcaa8d0Smrg	    *" $dlname "*) ;;
11013880c7e28Smrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
11014bdcaa8d0Smrg	    esac
11015880c7e28Smrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
11016bdcaa8d0Smrg	    ;;
11017bdcaa8d0Smrg	  uninstall)
11018bdcaa8d0Smrg	    if test -n "$library_names"; then
11019bdcaa8d0Smrg	      # Do each command in the postuninstall commands.
110204f00d7e1Smrg	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
11021bdcaa8d0Smrg	    fi
11022bdcaa8d0Smrg
11023bdcaa8d0Smrg	    if test -n "$old_library"; then
11024bdcaa8d0Smrg	      # Do each command in the old_postuninstall commands.
110254f00d7e1Smrg	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
11026bdcaa8d0Smrg	    fi
11027bdcaa8d0Smrg	    # FIXME: should reinstall the best remaining shared library.
11028bdcaa8d0Smrg	    ;;
11029bdcaa8d0Smrg	  esac
11030bdcaa8d0Smrg	fi
11031bdcaa8d0Smrg	;;
11032bdcaa8d0Smrg
11033bdcaa8d0Smrg      *.lo)
11034bdcaa8d0Smrg	# Possibly a libtool object, so verify it.
110350b661123Smrg	if func_lalib_p "$file"; then
11036bdcaa8d0Smrg
11037bdcaa8d0Smrg	  # Read the .lo file
110380b661123Smrg	  func_source $dir/$name
11039bdcaa8d0Smrg
11040bdcaa8d0Smrg	  # Add PIC object to the list of files to remove.
110414f00d7e1Smrg	  if test -n "$pic_object" && test none != "$pic_object"; then
11042880c7e28Smrg	    func_append rmfiles " $dir/$pic_object"
11043bdcaa8d0Smrg	  fi
11044bdcaa8d0Smrg
11045bdcaa8d0Smrg	  # Add non-PIC object to the list of files to remove.
110464f00d7e1Smrg	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
11047880c7e28Smrg	    func_append rmfiles " $dir/$non_pic_object"
11048bdcaa8d0Smrg	  fi
11049bdcaa8d0Smrg	fi
11050bdcaa8d0Smrg	;;
11051bdcaa8d0Smrg
11052bdcaa8d0Smrg      *)
110534f00d7e1Smrg	if test clean = "$opt_mode"; then
11054bdcaa8d0Smrg	  noexename=$name
11055bdcaa8d0Smrg	  case $file in
11056bdcaa8d0Smrg	  *.exe)
110570b661123Smrg	    func_stripname '' '.exe' "$file"
110580b661123Smrg	    file=$func_stripname_result
110590b661123Smrg	    func_stripname '' '.exe' "$name"
110600b661123Smrg	    noexename=$func_stripname_result
11061bdcaa8d0Smrg	    # $file with .exe has already been added to rmfiles,
11062bdcaa8d0Smrg	    # add $file without .exe
11063880c7e28Smrg	    func_append rmfiles " $file"
11064bdcaa8d0Smrg	    ;;
11065bdcaa8d0Smrg	  esac
11066bdcaa8d0Smrg	  # Do a test to see if this is a libtool program.
110670b661123Smrg	  if func_ltwrapper_p "$file"; then
110680b661123Smrg	    if func_ltwrapper_executable_p "$file"; then
110690b661123Smrg	      func_ltwrapper_scriptname "$file"
110700b661123Smrg	      relink_command=
110710b661123Smrg	      func_source $func_ltwrapper_scriptname_result
11072880c7e28Smrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
110730b661123Smrg	    else
110740b661123Smrg	      relink_command=
110750b661123Smrg	      func_source $dir/$noexename
110760b661123Smrg	    fi
11077bdcaa8d0Smrg
11078bdcaa8d0Smrg	    # note $name still contains .exe if it was in $file originally
11079bdcaa8d0Smrg	    # as does the version of $file that was added into $rmfiles
110804f00d7e1Smrg	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
110814f00d7e1Smrg	    if test yes = "$fast_install" && test -n "$relink_command"; then
11082880c7e28Smrg	      func_append rmfiles " $odir/lt-$name"
11083bdcaa8d0Smrg	    fi
110844f00d7e1Smrg	    if test "X$noexename" != "X$name"; then
110854f00d7e1Smrg	      func_append rmfiles " $odir/lt-$noexename.c"
11086bdcaa8d0Smrg	    fi
11087bdcaa8d0Smrg	  fi
11088bdcaa8d0Smrg	fi
11089bdcaa8d0Smrg	;;
11090bdcaa8d0Smrg      esac
110910b661123Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
11092bdcaa8d0Smrg    done
11093bdcaa8d0Smrg
110944f00d7e1Smrg    # Try to remove the $objdir's in the directories where we deleted files
11095bdcaa8d0Smrg    for dir in $rmdirs; do
11096bdcaa8d0Smrg      if test -d "$dir"; then
110970b661123Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
11098bdcaa8d0Smrg      fi
11099bdcaa8d0Smrg    done
11100bdcaa8d0Smrg
11101bdcaa8d0Smrg    exit $exit_status
111020b661123Smrg}
11103bdcaa8d0Smrg
111044f00d7e1Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
111054f00d7e1Smrg  func_mode_uninstall ${1+"$@"}
111064f00d7e1Smrgfi
1110772313efbSmrg
11108880c7e28Smrgtest -z "$opt_mode" && {
111094f00d7e1Smrg  help=$generic_help
111100b661123Smrg  func_fatal_help "you must specify a MODE"
111110b661123Smrg}
111120b661123Smrg
111130b661123Smrgtest -z "$exec_cmd" && \
111144f00d7e1Smrg  func_fatal_help "invalid operation mode '$opt_mode'"
11115bdcaa8d0Smrg
11116bdcaa8d0Smrgif test -n "$exec_cmd"; then
111170b661123Smrg  eval exec "$exec_cmd"
11118bdcaa8d0Smrg  exit $EXIT_FAILURE
11119bdcaa8d0Smrgfi
11120bdcaa8d0Smrg
111210b661123Smrgexit $exit_status
11122bdcaa8d0Smrg
11123bdcaa8d0Smrg
11124bdcaa8d0Smrg# The TAGs below are defined such that we never get into a situation
111254f00d7e1Smrg# where we disable both kinds of libraries.  Given conflicting
11126bdcaa8d0Smrg# choices, we go for a static library, that is the most portable,
11127bdcaa8d0Smrg# since we can't tell whether shared libraries were disabled because
11128bdcaa8d0Smrg# the user asked for that or because the platform doesn't support
11129bdcaa8d0Smrg# them.  This is particularly important on AIX, because we don't
11130bdcaa8d0Smrg# support having both static and shared libraries enabled at the same
11131bdcaa8d0Smrg# time on that platform, so we default to a shared-only configuration.
11132bdcaa8d0Smrg# If a disable-shared tag is given, we'll fallback to a static-only
11133bdcaa8d0Smrg# configuration.  But we'll never go from static-only to shared-only.
11134bdcaa8d0Smrg
11135bdcaa8d0Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
111360b661123Smrgbuild_libtool_libs=no
111370b661123Smrgbuild_old_libs=yes
11138bdcaa8d0Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
11139bdcaa8d0Smrg
11140bdcaa8d0Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
111410b661123Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
11142bdcaa8d0Smrg# ### END LIBTOOL TAG CONFIG: disable-static
11143bdcaa8d0Smrg
11144bdcaa8d0Smrg# Local Variables:
11145bdcaa8d0Smrg# mode:shell-script
11146bdcaa8d0Smrg# sh-indentation:2
11147bdcaa8d0Smrg# End:
11148