113498266Sopenharmony_ci#! /usr/bin/env sh
213498266Sopenharmony_ci## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
313498266Sopenharmony_ci##               by inline-source v2019-02-19.15
413498266Sopenharmony_ci
513498266Sopenharmony_ci# libtool (GNU libtool) 2.4.7
613498266Sopenharmony_ci# Provide generalized library-building support services.
713498266Sopenharmony_ci# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
813498266Sopenharmony_ci
913498266Sopenharmony_ci# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc.
1013498266Sopenharmony_ci# This is free software; see the source for copying conditions.  There is NO
1113498266Sopenharmony_ci# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1213498266Sopenharmony_ci
1313498266Sopenharmony_ci# GNU Libtool is free software; you can redistribute it and/or modify
1413498266Sopenharmony_ci# it under the terms of the GNU General Public License as published by
1513498266Sopenharmony_ci# the Free Software Foundation; either version 2 of the License, or
1613498266Sopenharmony_ci# (at your option) any later version.
1713498266Sopenharmony_ci#
1813498266Sopenharmony_ci# As a special exception to the GNU General Public License,
1913498266Sopenharmony_ci# if you distribute this file as part of a program or library that
2013498266Sopenharmony_ci# is built using GNU Libtool, you may include this file under the
2113498266Sopenharmony_ci# same distribution terms that you use for the rest of that program.
2213498266Sopenharmony_ci#
2313498266Sopenharmony_ci# GNU Libtool is distributed in the hope that it will be useful, but
2413498266Sopenharmony_ci# WITHOUT ANY WARRANTY; without even the implied warranty of
2513498266Sopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2613498266Sopenharmony_ci# General Public License for more details.
2713498266Sopenharmony_ci#
2813498266Sopenharmony_ci# You should have received a copy of the GNU General Public License
2913498266Sopenharmony_ci# along with this program.  If not, see <http://www.gnu.org/licenses/>.
3013498266Sopenharmony_ci
3113498266Sopenharmony_ci
3213498266Sopenharmony_ciPROGRAM=libtool
3313498266Sopenharmony_ciPACKAGE=libtool
3413498266Sopenharmony_ciVERSION="2.4.7 Debian-2.4.7-7"
3513498266Sopenharmony_cipackage_revision=2.4.7
3613498266Sopenharmony_ci
3713498266Sopenharmony_ci
3813498266Sopenharmony_ci## ------ ##
3913498266Sopenharmony_ci## Usage. ##
4013498266Sopenharmony_ci## ------ ##
4113498266Sopenharmony_ci
4213498266Sopenharmony_ci# Run './libtool --help' for help with using this script from the
4313498266Sopenharmony_ci# command line.
4413498266Sopenharmony_ci
4513498266Sopenharmony_ci
4613498266Sopenharmony_ci## ------------------------------- ##
4713498266Sopenharmony_ci## User overridable command paths. ##
4813498266Sopenharmony_ci## ------------------------------- ##
4913498266Sopenharmony_ci
5013498266Sopenharmony_ci# After configure completes, it has a better idea of some of the
5113498266Sopenharmony_ci# shell tools we need than the defaults used by the functions shared
5213498266Sopenharmony_ci# with bootstrap, so set those here where they can still be over-
5313498266Sopenharmony_ci# ridden by the user, but otherwise take precedence.
5413498266Sopenharmony_ci
5513498266Sopenharmony_ci: ${AUTOCONF="autoconf"}
5613498266Sopenharmony_ci: ${AUTOMAKE="automake"}
5713498266Sopenharmony_ci
5813498266Sopenharmony_ci
5913498266Sopenharmony_ci## -------------------------- ##
6013498266Sopenharmony_ci## Source external libraries. ##
6113498266Sopenharmony_ci## -------------------------- ##
6213498266Sopenharmony_ci
6313498266Sopenharmony_ci# Much of our low-level functionality needs to be sourced from external
6413498266Sopenharmony_ci# libraries, which are installed to $pkgauxdir.
6513498266Sopenharmony_ci
6613498266Sopenharmony_ci# Set a version string for this script.
6713498266Sopenharmony_ciscriptversion=2019-02-19.15; # UTC
6813498266Sopenharmony_ci
6913498266Sopenharmony_ci# General shell script boiler plate, and helper functions.
7013498266Sopenharmony_ci# Written by Gary V. Vaughan, 2004
7113498266Sopenharmony_ci
7213498266Sopenharmony_ci# This is free software.  There is NO warranty; not even for
7313498266Sopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7413498266Sopenharmony_ci#
7513498266Sopenharmony_ci# Copyright (C) 2004-2019, 2021 Bootstrap Authors
7613498266Sopenharmony_ci#
7713498266Sopenharmony_ci# This file is dual licensed under the terms of the MIT license
7813498266Sopenharmony_ci# <https://opensource.org/license/MIT>, and GPL version 2 or later
7913498266Sopenharmony_ci# <http://www.gnu.org/licenses/gpl-2.0.html>.  You must apply one of
8013498266Sopenharmony_ci# these licenses when using or redistributing this software or any of
8113498266Sopenharmony_ci# the files within it.  See the URLs above, or the file `LICENSE`
8213498266Sopenharmony_ci# included in the Bootstrap distribution for the full license texts.
8313498266Sopenharmony_ci
8413498266Sopenharmony_ci# Please report bugs or propose patches to:
8513498266Sopenharmony_ci# <https://github.com/gnulib-modules/bootstrap/issues>
8613498266Sopenharmony_ci
8713498266Sopenharmony_ci
8813498266Sopenharmony_ci## ------ ##
8913498266Sopenharmony_ci## Usage. ##
9013498266Sopenharmony_ci## ------ ##
9113498266Sopenharmony_ci
9213498266Sopenharmony_ci# Evaluate this file near the top of your script to gain access to
9313498266Sopenharmony_ci# the functions and variables defined here:
9413498266Sopenharmony_ci#
9513498266Sopenharmony_ci#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
9613498266Sopenharmony_ci#
9713498266Sopenharmony_ci# If you need to override any of the default environment variable
9813498266Sopenharmony_ci# settings, do that before evaluating this file.
9913498266Sopenharmony_ci
10013498266Sopenharmony_ci
10113498266Sopenharmony_ci## -------------------- ##
10213498266Sopenharmony_ci## Shell normalisation. ##
10313498266Sopenharmony_ci## -------------------- ##
10413498266Sopenharmony_ci
10513498266Sopenharmony_ci# Some shells need a little help to be as Bourne compatible as possible.
10613498266Sopenharmony_ci# Before doing anything else, make sure all that help has been provided!
10713498266Sopenharmony_ci
10813498266Sopenharmony_ciDUALCASE=1; export DUALCASE # for MKS sh
10913498266Sopenharmony_ciif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
11013498266Sopenharmony_ci  emulate sh
11113498266Sopenharmony_ci  NULLCMD=:
11213498266Sopenharmony_ci  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
11313498266Sopenharmony_ci  # is contrary to our usage.  Disable this feature.
11413498266Sopenharmony_ci  alias -g '${1+"$@"}'='"$@"'
11513498266Sopenharmony_ci  setopt NO_GLOB_SUBST
11613498266Sopenharmony_cielse
11713498266Sopenharmony_ci  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
11813498266Sopenharmony_cifi
11913498266Sopenharmony_ci
12013498266Sopenharmony_ci# NLS nuisances: We save the old values in case they are required later.
12113498266Sopenharmony_ci_G_user_locale=
12213498266Sopenharmony_ci_G_safe_locale=
12313498266Sopenharmony_cifor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
12413498266Sopenharmony_cido
12513498266Sopenharmony_ci  eval "if test set = \"\${$_G_var+set}\"; then
12613498266Sopenharmony_ci          save_$_G_var=\$$_G_var
12713498266Sopenharmony_ci          $_G_var=C
12813498266Sopenharmony_ci	  export $_G_var
12913498266Sopenharmony_ci	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
13013498266Sopenharmony_ci	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
13113498266Sopenharmony_ci	fi"
13213498266Sopenharmony_cidone
13313498266Sopenharmony_ci# These NLS vars are set unconditionally (bootstrap issue #24).  Unset those
13413498266Sopenharmony_ci# in case the environment reset is needed later and the $save_* variant is not
13513498266Sopenharmony_ci# defined (see the code above).
13613498266Sopenharmony_ciLC_ALL=C
13713498266Sopenharmony_ciLANGUAGE=C
13813498266Sopenharmony_ciexport LANGUAGE LC_ALL
13913498266Sopenharmony_ci
14013498266Sopenharmony_ci# Make sure IFS has a sensible default
14113498266Sopenharmony_cisp=' '
14213498266Sopenharmony_cinl='
14313498266Sopenharmony_ci'
14413498266Sopenharmony_ciIFS="$sp	$nl"
14513498266Sopenharmony_ci
14613498266Sopenharmony_ci# There are apparently some retarded systems that use ';' as a PATH separator!
14713498266Sopenharmony_ciif test "${PATH_SEPARATOR+set}" != set; then
14813498266Sopenharmony_ci  PATH_SEPARATOR=:
14913498266Sopenharmony_ci  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
15013498266Sopenharmony_ci    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
15113498266Sopenharmony_ci      PATH_SEPARATOR=';'
15213498266Sopenharmony_ci  }
15313498266Sopenharmony_cifi
15413498266Sopenharmony_ci
15513498266Sopenharmony_ci
15613498266Sopenharmony_ci# func_unset VAR
15713498266Sopenharmony_ci# --------------
15813498266Sopenharmony_ci# Portably unset VAR.
15913498266Sopenharmony_ci# In some shells, an 'unset VAR' statement leaves a non-zero return
16013498266Sopenharmony_ci# status if VAR is already unset, which might be problematic if the
16113498266Sopenharmony_ci# statement is used at the end of a function (thus poisoning its return
16213498266Sopenharmony_ci# value) or when 'set -e' is active (causing even a spurious abort of
16313498266Sopenharmony_ci# the script in this case).
16413498266Sopenharmony_cifunc_unset ()
16513498266Sopenharmony_ci{
16613498266Sopenharmony_ci    { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; }
16713498266Sopenharmony_ci}
16813498266Sopenharmony_ci
16913498266Sopenharmony_ci
17013498266Sopenharmony_ci# Make sure CDPATH doesn't cause `cd` commands to output the target dir.
17113498266Sopenharmony_cifunc_unset CDPATH
17213498266Sopenharmony_ci
17313498266Sopenharmony_ci# Make sure ${,E,F}GREP behave sanely.
17413498266Sopenharmony_cifunc_unset GREP_OPTIONS
17513498266Sopenharmony_ci
17613498266Sopenharmony_ci
17713498266Sopenharmony_ci## ------------------------- ##
17813498266Sopenharmony_ci## Locate command utilities. ##
17913498266Sopenharmony_ci## ------------------------- ##
18013498266Sopenharmony_ci
18113498266Sopenharmony_ci
18213498266Sopenharmony_ci# func_executable_p FILE
18313498266Sopenharmony_ci# ----------------------
18413498266Sopenharmony_ci# Check that FILE is an executable regular file.
18513498266Sopenharmony_cifunc_executable_p ()
18613498266Sopenharmony_ci{
18713498266Sopenharmony_ci    test -f "$1" && test -x "$1"
18813498266Sopenharmony_ci}
18913498266Sopenharmony_ci
19013498266Sopenharmony_ci
19113498266Sopenharmony_ci# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
19213498266Sopenharmony_ci# --------------------------------------------
19313498266Sopenharmony_ci# Search for either a program that responds to --version with output
19413498266Sopenharmony_ci# containing "GNU", or else returned by CHECK_FUNC otherwise, by
19513498266Sopenharmony_ci# trying all the directories in PATH with each of the elements of
19613498266Sopenharmony_ci# PROGS_LIST.
19713498266Sopenharmony_ci#
19813498266Sopenharmony_ci# CHECK_FUNC should accept the path to a candidate program, and
19913498266Sopenharmony_ci# set $func_check_prog_result if it truncates its output less than
20013498266Sopenharmony_ci# $_G_path_prog_max characters.
20113498266Sopenharmony_cifunc_path_progs ()
20213498266Sopenharmony_ci{
20313498266Sopenharmony_ci    _G_progs_list=$1
20413498266Sopenharmony_ci    _G_check_func=$2
20513498266Sopenharmony_ci    _G_PATH=${3-"$PATH"}
20613498266Sopenharmony_ci
20713498266Sopenharmony_ci    _G_path_prog_max=0
20813498266Sopenharmony_ci    _G_path_prog_found=false
20913498266Sopenharmony_ci    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
21013498266Sopenharmony_ci    for _G_dir in $_G_PATH; do
21113498266Sopenharmony_ci      IFS=$_G_save_IFS
21213498266Sopenharmony_ci      test -z "$_G_dir" && _G_dir=.
21313498266Sopenharmony_ci      for _G_prog_name in $_G_progs_list; do
21413498266Sopenharmony_ci        for _exeext in '' .EXE; do
21513498266Sopenharmony_ci          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
21613498266Sopenharmony_ci          func_executable_p "$_G_path_prog" || continue
21713498266Sopenharmony_ci          case `"$_G_path_prog" --version 2>&1` in
21813498266Sopenharmony_ci            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
21913498266Sopenharmony_ci            *)     $_G_check_func $_G_path_prog
22013498266Sopenharmony_ci		   func_path_progs_result=$func_check_prog_result
22113498266Sopenharmony_ci		   ;;
22213498266Sopenharmony_ci          esac
22313498266Sopenharmony_ci          $_G_path_prog_found && break 3
22413498266Sopenharmony_ci        done
22513498266Sopenharmony_ci      done
22613498266Sopenharmony_ci    done
22713498266Sopenharmony_ci    IFS=$_G_save_IFS
22813498266Sopenharmony_ci    test -z "$func_path_progs_result" && {
22913498266Sopenharmony_ci      echo "no acceptable sed could be found in \$PATH" >&2
23013498266Sopenharmony_ci      exit 1
23113498266Sopenharmony_ci    }
23213498266Sopenharmony_ci}
23313498266Sopenharmony_ci
23413498266Sopenharmony_ci
23513498266Sopenharmony_ci# We want to be able to use the functions in this file before configure
23613498266Sopenharmony_ci# has figured out where the best binaries are kept, which means we have
23713498266Sopenharmony_ci# to search for them ourselves - except when the results are already set
23813498266Sopenharmony_ci# where we skip the searches.
23913498266Sopenharmony_ci
24013498266Sopenharmony_ci# Unless the user overrides by setting SED, search the path for either GNU
24113498266Sopenharmony_ci# sed, or the sed that truncates its output the least.
24213498266Sopenharmony_citest -z "$SED" && {
24313498266Sopenharmony_ci  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
24413498266Sopenharmony_ci  for _G_i in 1 2 3 4 5 6 7; do
24513498266Sopenharmony_ci    _G_sed_script=$_G_sed_script$nl$_G_sed_script
24613498266Sopenharmony_ci  done
24713498266Sopenharmony_ci  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
24813498266Sopenharmony_ci  _G_sed_script=
24913498266Sopenharmony_ci
25013498266Sopenharmony_ci  func_check_prog_sed ()
25113498266Sopenharmony_ci  {
25213498266Sopenharmony_ci    _G_path_prog=$1
25313498266Sopenharmony_ci
25413498266Sopenharmony_ci    _G_count=0
25513498266Sopenharmony_ci    printf 0123456789 >conftest.in
25613498266Sopenharmony_ci    while :
25713498266Sopenharmony_ci    do
25813498266Sopenharmony_ci      cat conftest.in conftest.in >conftest.tmp
25913498266Sopenharmony_ci      mv conftest.tmp conftest.in
26013498266Sopenharmony_ci      cp conftest.in conftest.nl
26113498266Sopenharmony_ci      echo '' >> conftest.nl
26213498266Sopenharmony_ci      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
26313498266Sopenharmony_ci      diff conftest.out conftest.nl >/dev/null 2>&1 || break
26413498266Sopenharmony_ci      _G_count=`expr $_G_count + 1`
26513498266Sopenharmony_ci      if test "$_G_count" -gt "$_G_path_prog_max"; then
26613498266Sopenharmony_ci        # Best one so far, save it but keep looking for a better one
26713498266Sopenharmony_ci        func_check_prog_result=$_G_path_prog
26813498266Sopenharmony_ci        _G_path_prog_max=$_G_count
26913498266Sopenharmony_ci      fi
27013498266Sopenharmony_ci      # 10*(2^10) chars as input seems more than enough
27113498266Sopenharmony_ci      test 10 -lt "$_G_count" && break
27213498266Sopenharmony_ci    done
27313498266Sopenharmony_ci    rm -f conftest.in conftest.tmp conftest.nl conftest.out
27413498266Sopenharmony_ci  }
27513498266Sopenharmony_ci
27613498266Sopenharmony_ci  func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin"
27713498266Sopenharmony_ci  rm -f conftest.sed
27813498266Sopenharmony_ci  SED=$func_path_progs_result
27913498266Sopenharmony_ci}
28013498266Sopenharmony_ci
28113498266Sopenharmony_ci
28213498266Sopenharmony_ci# Unless the user overrides by setting GREP, search the path for either GNU
28313498266Sopenharmony_ci# grep, or the grep that truncates its output the least.
28413498266Sopenharmony_citest -z "$GREP" && {
28513498266Sopenharmony_ci  func_check_prog_grep ()
28613498266Sopenharmony_ci  {
28713498266Sopenharmony_ci    _G_path_prog=$1
28813498266Sopenharmony_ci
28913498266Sopenharmony_ci    _G_count=0
29013498266Sopenharmony_ci    _G_path_prog_max=0
29113498266Sopenharmony_ci    printf 0123456789 >conftest.in
29213498266Sopenharmony_ci    while :
29313498266Sopenharmony_ci    do
29413498266Sopenharmony_ci      cat conftest.in conftest.in >conftest.tmp
29513498266Sopenharmony_ci      mv conftest.tmp conftest.in
29613498266Sopenharmony_ci      cp conftest.in conftest.nl
29713498266Sopenharmony_ci      echo 'GREP' >> conftest.nl
29813498266Sopenharmony_ci      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
29913498266Sopenharmony_ci      diff conftest.out conftest.nl >/dev/null 2>&1 || break
30013498266Sopenharmony_ci      _G_count=`expr $_G_count + 1`
30113498266Sopenharmony_ci      if test "$_G_count" -gt "$_G_path_prog_max"; then
30213498266Sopenharmony_ci        # Best one so far, save it but keep looking for a better one
30313498266Sopenharmony_ci        func_check_prog_result=$_G_path_prog
30413498266Sopenharmony_ci        _G_path_prog_max=$_G_count
30513498266Sopenharmony_ci      fi
30613498266Sopenharmony_ci      # 10*(2^10) chars as input seems more than enough
30713498266Sopenharmony_ci      test 10 -lt "$_G_count" && break
30813498266Sopenharmony_ci    done
30913498266Sopenharmony_ci    rm -f conftest.in conftest.tmp conftest.nl conftest.out
31013498266Sopenharmony_ci  }
31113498266Sopenharmony_ci
31213498266Sopenharmony_ci  func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin"
31313498266Sopenharmony_ci  GREP=$func_path_progs_result
31413498266Sopenharmony_ci}
31513498266Sopenharmony_ci
31613498266Sopenharmony_ci
31713498266Sopenharmony_ci## ------------------------------- ##
31813498266Sopenharmony_ci## User overridable command paths. ##
31913498266Sopenharmony_ci## ------------------------------- ##
32013498266Sopenharmony_ci
32113498266Sopenharmony_ci# All uppercase variable names are used for environment variables.  These
32213498266Sopenharmony_ci# variables can be overridden by the user before calling a script that
32313498266Sopenharmony_ci# uses them if a suitable command of that name is not already available
32413498266Sopenharmony_ci# in the command search PATH.
32513498266Sopenharmony_ci
32613498266Sopenharmony_ci: ${CP="cp -f"}
32713498266Sopenharmony_ci: ${ECHO="printf %s\n"}
32813498266Sopenharmony_ci: ${EGREP="$GREP -E"}
32913498266Sopenharmony_ci: ${FGREP="$GREP -F"}
33013498266Sopenharmony_ci: ${LN_S="ln -s"}
33113498266Sopenharmony_ci: ${MAKE="make"}
33213498266Sopenharmony_ci: ${MKDIR="mkdir"}
33313498266Sopenharmony_ci: ${MV="mv -f"}
33413498266Sopenharmony_ci: ${RM="rm -f"}
33513498266Sopenharmony_ci: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
33613498266Sopenharmony_ci
33713498266Sopenharmony_ci
33813498266Sopenharmony_ci## -------------------- ##
33913498266Sopenharmony_ci## Useful sed snippets. ##
34013498266Sopenharmony_ci## -------------------- ##
34113498266Sopenharmony_ci
34213498266Sopenharmony_cised_dirname='s|/[^/]*$||'
34313498266Sopenharmony_cised_basename='s|^.*/||'
34413498266Sopenharmony_ci
34513498266Sopenharmony_ci# Sed substitution that helps us do robust quoting.  It backslashifies
34613498266Sopenharmony_ci# metacharacters that are still active within double-quoted strings.
34713498266Sopenharmony_cised_quote_subst='s|\([`"$\\]\)|\\\1|g'
34813498266Sopenharmony_ci
34913498266Sopenharmony_ci# Same as above, but do not quote variable references.
35013498266Sopenharmony_cised_double_quote_subst='s/\(["`\\]\)/\\\1/g'
35113498266Sopenharmony_ci
35213498266Sopenharmony_ci# Sed substitution that turns a string into a regex matching for the
35313498266Sopenharmony_ci# string literally.
35413498266Sopenharmony_cised_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
35513498266Sopenharmony_ci
35613498266Sopenharmony_ci# Sed substitution that converts a w32 file name or path
35713498266Sopenharmony_ci# that contains forward slashes, into one that contains
35813498266Sopenharmony_ci# (escaped) backslashes.  A very naive implementation.
35913498266Sopenharmony_cised_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
36013498266Sopenharmony_ci
36113498266Sopenharmony_ci# Re-'\' parameter expansions in output of sed_double_quote_subst that
36213498266Sopenharmony_ci# were '\'-ed in input to the same.  If an odd number of '\' preceded a
36313498266Sopenharmony_ci# '$' in input to sed_double_quote_subst, that '$' was protected from
36413498266Sopenharmony_ci# expansion.  Since each input '\' is now two '\'s, look for any number
36513498266Sopenharmony_ci# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
36613498266Sopenharmony_ci_G_bs='\\'
36713498266Sopenharmony_ci_G_bs2='\\\\'
36813498266Sopenharmony_ci_G_bs4='\\\\\\\\'
36913498266Sopenharmony_ci_G_dollar='\$'
37013498266Sopenharmony_cised_double_backslash="\
37113498266Sopenharmony_ci  s/$_G_bs4/&\\
37213498266Sopenharmony_ci/g
37313498266Sopenharmony_ci  s/^$_G_bs2$_G_dollar/$_G_bs&/
37413498266Sopenharmony_ci  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
37513498266Sopenharmony_ci  s/\n//g"
37613498266Sopenharmony_ci
37713498266Sopenharmony_ci# require_check_ifs_backslash
37813498266Sopenharmony_ci# ---------------------------
37913498266Sopenharmony_ci# Check if we can use backslash as IFS='\' separator, and set
38013498266Sopenharmony_ci# $check_ifs_backshlash_broken to ':' or 'false'.
38113498266Sopenharmony_cirequire_check_ifs_backslash=func_require_check_ifs_backslash
38213498266Sopenharmony_cifunc_require_check_ifs_backslash ()
38313498266Sopenharmony_ci{
38413498266Sopenharmony_ci  _G_save_IFS=$IFS
38513498266Sopenharmony_ci  IFS='\'
38613498266Sopenharmony_ci  _G_check_ifs_backshlash='a\\b'
38713498266Sopenharmony_ci  for _G_i in $_G_check_ifs_backshlash
38813498266Sopenharmony_ci  do
38913498266Sopenharmony_ci  case $_G_i in
39013498266Sopenharmony_ci  a)
39113498266Sopenharmony_ci    check_ifs_backshlash_broken=false
39213498266Sopenharmony_ci    ;;
39313498266Sopenharmony_ci  '')
39413498266Sopenharmony_ci    break
39513498266Sopenharmony_ci    ;;
39613498266Sopenharmony_ci  *)
39713498266Sopenharmony_ci    check_ifs_backshlash_broken=:
39813498266Sopenharmony_ci    break
39913498266Sopenharmony_ci    ;;
40013498266Sopenharmony_ci  esac
40113498266Sopenharmony_ci  done
40213498266Sopenharmony_ci  IFS=$_G_save_IFS
40313498266Sopenharmony_ci  require_check_ifs_backslash=:
40413498266Sopenharmony_ci}
40513498266Sopenharmony_ci
40613498266Sopenharmony_ci
40713498266Sopenharmony_ci## ----------------- ##
40813498266Sopenharmony_ci## Global variables. ##
40913498266Sopenharmony_ci## ----------------- ##
41013498266Sopenharmony_ci
41113498266Sopenharmony_ci# Except for the global variables explicitly listed below, the following
41213498266Sopenharmony_ci# functions in the '^func_' namespace, and the '^require_' namespace
41313498266Sopenharmony_ci# variables initialised in the 'Resource management' section, sourcing
41413498266Sopenharmony_ci# this file will not pollute your global namespace with anything
41513498266Sopenharmony_ci# else. There's no portable way to scope variables in Bourne shell
41613498266Sopenharmony_ci# though, so actually running these functions will sometimes place
41713498266Sopenharmony_ci# results into a variable named after the function, and often use
41813498266Sopenharmony_ci# temporary variables in the '^_G_' namespace. If you are careful to
41913498266Sopenharmony_ci# avoid using those namespaces casually in your sourcing script, things
42013498266Sopenharmony_ci# should continue to work as you expect. And, of course, you can freely
42113498266Sopenharmony_ci# overwrite any of the functions or variables defined here before
42213498266Sopenharmony_ci# calling anything to customize them.
42313498266Sopenharmony_ci
42413498266Sopenharmony_ciEXIT_SUCCESS=0
42513498266Sopenharmony_ciEXIT_FAILURE=1
42613498266Sopenharmony_ciEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
42713498266Sopenharmony_ciEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
42813498266Sopenharmony_ci
42913498266Sopenharmony_ci# Allow overriding, eg assuming that you follow the convention of
43013498266Sopenharmony_ci# putting '$debug_cmd' at the start of all your functions, you can get
43113498266Sopenharmony_ci# bash to show function call trace with:
43213498266Sopenharmony_ci#
43313498266Sopenharmony_ci#    debug_cmd='echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
43413498266Sopenharmony_cidebug_cmd=${debug_cmd-":"}
43513498266Sopenharmony_ciexit_cmd=:
43613498266Sopenharmony_ci
43713498266Sopenharmony_ci# By convention, finish your script with:
43813498266Sopenharmony_ci#
43913498266Sopenharmony_ci#    exit $exit_status
44013498266Sopenharmony_ci#
44113498266Sopenharmony_ci# so that you can set exit_status to non-zero if you want to indicate
44213498266Sopenharmony_ci# something went wrong during execution without actually bailing out at
44313498266Sopenharmony_ci# the point of failure.
44413498266Sopenharmony_ciexit_status=$EXIT_SUCCESS
44513498266Sopenharmony_ci
44613498266Sopenharmony_ci# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
44713498266Sopenharmony_ci# is ksh but when the shell is invoked as "sh" and the current value of
44813498266Sopenharmony_ci# the _XPG environment variable is not equal to 1 (one), the special
44913498266Sopenharmony_ci# positional parameter $0, within a function call, is the name of the
45013498266Sopenharmony_ci# function.
45113498266Sopenharmony_ciprogpath=$0
45213498266Sopenharmony_ci
45313498266Sopenharmony_ci# The name of this program.
45413498266Sopenharmony_ciprogname=`$ECHO "$progpath" |$SED "$sed_basename"`
45513498266Sopenharmony_ci
45613498266Sopenharmony_ci# Make sure we have an absolute progpath for reexecution:
45713498266Sopenharmony_cicase $progpath in
45813498266Sopenharmony_ci  [\\/]*|[A-Za-z]:\\*) ;;
45913498266Sopenharmony_ci  *[\\/]*)
46013498266Sopenharmony_ci     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
46113498266Sopenharmony_ci     progdir=`cd "$progdir" && pwd`
46213498266Sopenharmony_ci     progpath=$progdir/$progname
46313498266Sopenharmony_ci     ;;
46413498266Sopenharmony_ci  *)
46513498266Sopenharmony_ci     _G_IFS=$IFS
46613498266Sopenharmony_ci     IFS=${PATH_SEPARATOR-:}
46713498266Sopenharmony_ci     for progdir in $PATH; do
46813498266Sopenharmony_ci       IFS=$_G_IFS
46913498266Sopenharmony_ci       test -x "$progdir/$progname" && break
47013498266Sopenharmony_ci     done
47113498266Sopenharmony_ci     IFS=$_G_IFS
47213498266Sopenharmony_ci     test -n "$progdir" || progdir=`pwd`
47313498266Sopenharmony_ci     progpath=$progdir/$progname
47413498266Sopenharmony_ci     ;;
47513498266Sopenharmony_ciesac
47613498266Sopenharmony_ci
47713498266Sopenharmony_ci
47813498266Sopenharmony_ci## ----------------- ##
47913498266Sopenharmony_ci## Standard options. ##
48013498266Sopenharmony_ci## ----------------- ##
48113498266Sopenharmony_ci
48213498266Sopenharmony_ci# The following options affect the operation of the functions defined
48313498266Sopenharmony_ci# below, and should be set appropriately depending on run-time para-
48413498266Sopenharmony_ci# meters passed on the command line.
48513498266Sopenharmony_ci
48613498266Sopenharmony_ciopt_dry_run=false
48713498266Sopenharmony_ciopt_quiet=false
48813498266Sopenharmony_ciopt_verbose=false
48913498266Sopenharmony_ci
49013498266Sopenharmony_ci# Categories 'all' and 'none' are always available.  Append any others
49113498266Sopenharmony_ci# you will pass as the first argument to func_warning from your own
49213498266Sopenharmony_ci# code.
49313498266Sopenharmony_ciwarning_categories=
49413498266Sopenharmony_ci
49513498266Sopenharmony_ci# By default, display warnings according to 'opt_warning_types'.  Set
49613498266Sopenharmony_ci# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
49713498266Sopenharmony_ci# treat the next displayed warning as a fatal error.
49813498266Sopenharmony_ciwarning_func=func_warn_and_continue
49913498266Sopenharmony_ci
50013498266Sopenharmony_ci# Set to 'all' to display all warnings, 'none' to suppress all
50113498266Sopenharmony_ci# warnings, or a space delimited list of some subset of
50213498266Sopenharmony_ci# 'warning_categories' to display only the listed warnings.
50313498266Sopenharmony_ciopt_warning_types=all
50413498266Sopenharmony_ci
50513498266Sopenharmony_ci
50613498266Sopenharmony_ci## -------------------- ##
50713498266Sopenharmony_ci## Resource management. ##
50813498266Sopenharmony_ci## -------------------- ##
50913498266Sopenharmony_ci
51013498266Sopenharmony_ci# This section contains definitions for functions that each ensure a
51113498266Sopenharmony_ci# particular resource (a file, or a non-empty configuration variable for
51213498266Sopenharmony_ci# example) is available, and if appropriate to extract default values
51313498266Sopenharmony_ci# from pertinent package files. Call them using their associated
51413498266Sopenharmony_ci# 'require_*' variable to ensure that they are executed, at most, once.
51513498266Sopenharmony_ci#
51613498266Sopenharmony_ci# It's entirely deliberate that calling these functions can set
51713498266Sopenharmony_ci# variables that don't obey the namespace limitations obeyed by the rest
51813498266Sopenharmony_ci# of this file, in order that that they be as useful as possible to
51913498266Sopenharmony_ci# callers.
52013498266Sopenharmony_ci
52113498266Sopenharmony_ci
52213498266Sopenharmony_ci# require_term_colors
52313498266Sopenharmony_ci# -------------------
52413498266Sopenharmony_ci# Allow display of bold text on terminals that support it.
52513498266Sopenharmony_cirequire_term_colors=func_require_term_colors
52613498266Sopenharmony_cifunc_require_term_colors ()
52713498266Sopenharmony_ci{
52813498266Sopenharmony_ci    $debug_cmd
52913498266Sopenharmony_ci
53013498266Sopenharmony_ci    test -t 1 && {
53113498266Sopenharmony_ci      # COLORTERM and USE_ANSI_COLORS environment variables take
53213498266Sopenharmony_ci      # precedence, because most terminfo databases neglect to describe
53313498266Sopenharmony_ci      # whether color sequences are supported.
53413498266Sopenharmony_ci      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
53513498266Sopenharmony_ci
53613498266Sopenharmony_ci      if test 1 = "$USE_ANSI_COLORS"; then
53713498266Sopenharmony_ci        # Standard ANSI escape sequences
53813498266Sopenharmony_ci        tc_reset='[0m'
53913498266Sopenharmony_ci        tc_bold='[1m';   tc_standout='[7m'
54013498266Sopenharmony_ci        tc_red='[31m';   tc_green='[32m'
54113498266Sopenharmony_ci        tc_blue='[34m';  tc_cyan='[36m'
54213498266Sopenharmony_ci      else
54313498266Sopenharmony_ci        # Otherwise trust the terminfo database after all.
54413498266Sopenharmony_ci        test -n "`tput sgr0 2>/dev/null`" && {
54513498266Sopenharmony_ci          tc_reset=`tput sgr0`
54613498266Sopenharmony_ci          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
54713498266Sopenharmony_ci          tc_standout=$tc_bold
54813498266Sopenharmony_ci          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
54913498266Sopenharmony_ci          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
55013498266Sopenharmony_ci          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
55113498266Sopenharmony_ci          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
55213498266Sopenharmony_ci          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
55313498266Sopenharmony_ci        }
55413498266Sopenharmony_ci      fi
55513498266Sopenharmony_ci    }
55613498266Sopenharmony_ci
55713498266Sopenharmony_ci    require_term_colors=:
55813498266Sopenharmony_ci}
55913498266Sopenharmony_ci
56013498266Sopenharmony_ci
56113498266Sopenharmony_ci## ----------------- ##
56213498266Sopenharmony_ci## Function library. ##
56313498266Sopenharmony_ci## ----------------- ##
56413498266Sopenharmony_ci
56513498266Sopenharmony_ci# This section contains a variety of useful functions to call in your
56613498266Sopenharmony_ci# scripts. Take note of the portable wrappers for features provided by
56713498266Sopenharmony_ci# some modern shells, which will fall back to slower equivalents on
56813498266Sopenharmony_ci# less featureful shells.
56913498266Sopenharmony_ci
57013498266Sopenharmony_ci
57113498266Sopenharmony_ci# func_append VAR VALUE
57213498266Sopenharmony_ci# ---------------------
57313498266Sopenharmony_ci# Append VALUE onto the existing contents of VAR.
57413498266Sopenharmony_ci
57513498266Sopenharmony_ci  # _G_HAVE_PLUSEQ_OP
57613498266Sopenharmony_ci  # Can be empty, in which case the shell is probed, "yes" if += is
57713498266Sopenharmony_ci  # useable or anything else if it does not work.
57813498266Sopenharmony_ci  if test -z "$_G_HAVE_PLUSEQ_OP" &&  \
57913498266Sopenharmony_ci      __PLUSEQ_TEST="a" &&  \
58013498266Sopenharmony_ci      __PLUSEQ_TEST+=" b" 2>/dev/null &&  \
58113498266Sopenharmony_ci      test "a b" = "$__PLUSEQ_TEST"; then
58213498266Sopenharmony_ci    _G_HAVE_PLUSEQ_OP=yes
58313498266Sopenharmony_ci  fi
58413498266Sopenharmony_ci
58513498266Sopenharmony_ciif test yes = "$_G_HAVE_PLUSEQ_OP"
58613498266Sopenharmony_cithen
58713498266Sopenharmony_ci  # This is an XSI compatible shell, allowing a faster implementation...
58813498266Sopenharmony_ci  eval 'func_append ()
58913498266Sopenharmony_ci  {
59013498266Sopenharmony_ci    $debug_cmd
59113498266Sopenharmony_ci
59213498266Sopenharmony_ci    eval "$1+=\$2"
59313498266Sopenharmony_ci  }'
59413498266Sopenharmony_cielse
59513498266Sopenharmony_ci  # ...otherwise fall back to using expr, which is often a shell builtin.
59613498266Sopenharmony_ci  func_append ()
59713498266Sopenharmony_ci  {
59813498266Sopenharmony_ci    $debug_cmd
59913498266Sopenharmony_ci
60013498266Sopenharmony_ci    eval "$1=\$$1\$2"
60113498266Sopenharmony_ci  }
60213498266Sopenharmony_cifi
60313498266Sopenharmony_ci
60413498266Sopenharmony_ci
60513498266Sopenharmony_ci# func_append_quoted VAR VALUE
60613498266Sopenharmony_ci# ----------------------------
60713498266Sopenharmony_ci# Quote VALUE and append to the end of shell variable VAR, separated
60813498266Sopenharmony_ci# by a space.
60913498266Sopenharmony_ciif test yes = "$_G_HAVE_PLUSEQ_OP"; then
61013498266Sopenharmony_ci  eval 'func_append_quoted ()
61113498266Sopenharmony_ci  {
61213498266Sopenharmony_ci    $debug_cmd
61313498266Sopenharmony_ci
61413498266Sopenharmony_ci    func_quote_arg pretty "$2"
61513498266Sopenharmony_ci    eval "$1+=\\ \$func_quote_arg_result"
61613498266Sopenharmony_ci  }'
61713498266Sopenharmony_cielse
61813498266Sopenharmony_ci  func_append_quoted ()
61913498266Sopenharmony_ci  {
62013498266Sopenharmony_ci    $debug_cmd
62113498266Sopenharmony_ci
62213498266Sopenharmony_ci    func_quote_arg pretty "$2"
62313498266Sopenharmony_ci    eval "$1=\$$1\\ \$func_quote_arg_result"
62413498266Sopenharmony_ci  }
62513498266Sopenharmony_cifi
62613498266Sopenharmony_ci
62713498266Sopenharmony_ci
62813498266Sopenharmony_ci# func_append_uniq VAR VALUE
62913498266Sopenharmony_ci# --------------------------
63013498266Sopenharmony_ci# Append unique VALUE onto the existing contents of VAR, assuming
63113498266Sopenharmony_ci# entries are delimited by the first character of VALUE.  For example:
63213498266Sopenharmony_ci#
63313498266Sopenharmony_ci#   func_append_uniq options " --another-option option-argument"
63413498266Sopenharmony_ci#
63513498266Sopenharmony_ci# will only append to $options if " --another-option option-argument "
63613498266Sopenharmony_ci# is not already present somewhere in $options already (note spaces at
63713498266Sopenharmony_ci# each end implied by leading space in second argument).
63813498266Sopenharmony_cifunc_append_uniq ()
63913498266Sopenharmony_ci{
64013498266Sopenharmony_ci    $debug_cmd
64113498266Sopenharmony_ci
64213498266Sopenharmony_ci    eval _G_current_value='`$ECHO $'$1'`'
64313498266Sopenharmony_ci    _G_delim=`expr "$2" : '\(.\)'`
64413498266Sopenharmony_ci
64513498266Sopenharmony_ci    case $_G_delim$_G_current_value$_G_delim in
64613498266Sopenharmony_ci      *"$2$_G_delim"*) ;;
64713498266Sopenharmony_ci      *) func_append "$@" ;;
64813498266Sopenharmony_ci    esac
64913498266Sopenharmony_ci}
65013498266Sopenharmony_ci
65113498266Sopenharmony_ci
65213498266Sopenharmony_ci# func_arith TERM...
65313498266Sopenharmony_ci# ------------------
65413498266Sopenharmony_ci# Set func_arith_result to the result of evaluating TERMs.
65513498266Sopenharmony_ci  test -z "$_G_HAVE_ARITH_OP" \
65613498266Sopenharmony_ci    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
65713498266Sopenharmony_ci    && _G_HAVE_ARITH_OP=yes
65813498266Sopenharmony_ci
65913498266Sopenharmony_ciif test yes = "$_G_HAVE_ARITH_OP"; then
66013498266Sopenharmony_ci  eval 'func_arith ()
66113498266Sopenharmony_ci  {
66213498266Sopenharmony_ci    $debug_cmd
66313498266Sopenharmony_ci
66413498266Sopenharmony_ci    func_arith_result=$(( $* ))
66513498266Sopenharmony_ci  }'
66613498266Sopenharmony_cielse
66713498266Sopenharmony_ci  func_arith ()
66813498266Sopenharmony_ci  {
66913498266Sopenharmony_ci    $debug_cmd
67013498266Sopenharmony_ci
67113498266Sopenharmony_ci    func_arith_result=`expr "$@"`
67213498266Sopenharmony_ci  }
67313498266Sopenharmony_cifi
67413498266Sopenharmony_ci
67513498266Sopenharmony_ci
67613498266Sopenharmony_ci# func_basename FILE
67713498266Sopenharmony_ci# ------------------
67813498266Sopenharmony_ci# Set func_basename_result to FILE with everything up to and including
67913498266Sopenharmony_ci# the last / stripped.
68013498266Sopenharmony_ciif test yes = "$_G_HAVE_XSI_OPS"; then
68113498266Sopenharmony_ci  # If this shell supports suffix pattern removal, then use it to avoid
68213498266Sopenharmony_ci  # forking. Hide the definitions single quotes in case the shell chokes
68313498266Sopenharmony_ci  # on unsupported syntax...
68413498266Sopenharmony_ci  _b='func_basename_result=${1##*/}'
68513498266Sopenharmony_ci  _d='case $1 in
68613498266Sopenharmony_ci        */*) func_dirname_result=${1%/*}$2 ;;
68713498266Sopenharmony_ci        *  ) func_dirname_result=$3        ;;
68813498266Sopenharmony_ci      esac'
68913498266Sopenharmony_ci
69013498266Sopenharmony_cielse
69113498266Sopenharmony_ci  # ...otherwise fall back to using sed.
69213498266Sopenharmony_ci  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
69313498266Sopenharmony_ci  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
69413498266Sopenharmony_ci      if test "X$func_dirname_result" = "X$1"; then
69513498266Sopenharmony_ci        func_dirname_result=$3
69613498266Sopenharmony_ci      else
69713498266Sopenharmony_ci        func_append func_dirname_result "$2"
69813498266Sopenharmony_ci      fi'
69913498266Sopenharmony_cifi
70013498266Sopenharmony_ci
70113498266Sopenharmony_cieval 'func_basename ()
70213498266Sopenharmony_ci{
70313498266Sopenharmony_ci    $debug_cmd
70413498266Sopenharmony_ci
70513498266Sopenharmony_ci    '"$_b"'
70613498266Sopenharmony_ci}'
70713498266Sopenharmony_ci
70813498266Sopenharmony_ci
70913498266Sopenharmony_ci# func_dirname FILE APPEND NONDIR_REPLACEMENT
71013498266Sopenharmony_ci# -------------------------------------------
71113498266Sopenharmony_ci# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
71213498266Sopenharmony_ci# otherwise set result to NONDIR_REPLACEMENT.
71313498266Sopenharmony_cieval 'func_dirname ()
71413498266Sopenharmony_ci{
71513498266Sopenharmony_ci    $debug_cmd
71613498266Sopenharmony_ci
71713498266Sopenharmony_ci    '"$_d"'
71813498266Sopenharmony_ci}'
71913498266Sopenharmony_ci
72013498266Sopenharmony_ci
72113498266Sopenharmony_ci# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
72213498266Sopenharmony_ci# --------------------------------------------------------
72313498266Sopenharmony_ci# Perform func_basename and func_dirname in a single function
72413498266Sopenharmony_ci# call:
72513498266Sopenharmony_ci#   dirname:  Compute the dirname of FILE.  If nonempty,
72613498266Sopenharmony_ci#             add APPEND to the result, otherwise set result
72713498266Sopenharmony_ci#             to NONDIR_REPLACEMENT.
72813498266Sopenharmony_ci#             value returned in "$func_dirname_result"
72913498266Sopenharmony_ci#   basename: Compute filename of FILE.
73013498266Sopenharmony_ci#             value retuned in "$func_basename_result"
73113498266Sopenharmony_ci# For efficiency, we do not delegate to the functions above but instead
73213498266Sopenharmony_ci# duplicate the functionality here.
73313498266Sopenharmony_cieval 'func_dirname_and_basename ()
73413498266Sopenharmony_ci{
73513498266Sopenharmony_ci    $debug_cmd
73613498266Sopenharmony_ci
73713498266Sopenharmony_ci    '"$_b"'
73813498266Sopenharmony_ci    '"$_d"'
73913498266Sopenharmony_ci}'
74013498266Sopenharmony_ci
74113498266Sopenharmony_ci
74213498266Sopenharmony_ci# func_echo ARG...
74313498266Sopenharmony_ci# ----------------
74413498266Sopenharmony_ci# Echo program name prefixed message.
74513498266Sopenharmony_cifunc_echo ()
74613498266Sopenharmony_ci{
74713498266Sopenharmony_ci    $debug_cmd
74813498266Sopenharmony_ci
74913498266Sopenharmony_ci    _G_message=$*
75013498266Sopenharmony_ci
75113498266Sopenharmony_ci    func_echo_IFS=$IFS
75213498266Sopenharmony_ci    IFS=$nl
75313498266Sopenharmony_ci    for _G_line in $_G_message; do
75413498266Sopenharmony_ci      IFS=$func_echo_IFS
75513498266Sopenharmony_ci      $ECHO "$progname: $_G_line"
75613498266Sopenharmony_ci    done
75713498266Sopenharmony_ci    IFS=$func_echo_IFS
75813498266Sopenharmony_ci}
75913498266Sopenharmony_ci
76013498266Sopenharmony_ci
76113498266Sopenharmony_ci# func_echo_all ARG...
76213498266Sopenharmony_ci# --------------------
76313498266Sopenharmony_ci# Invoke $ECHO with all args, space-separated.
76413498266Sopenharmony_cifunc_echo_all ()
76513498266Sopenharmony_ci{
76613498266Sopenharmony_ci    $ECHO "$*"
76713498266Sopenharmony_ci}
76813498266Sopenharmony_ci
76913498266Sopenharmony_ci
77013498266Sopenharmony_ci# func_echo_infix_1 INFIX ARG...
77113498266Sopenharmony_ci# ------------------------------
77213498266Sopenharmony_ci# Echo program name, followed by INFIX on the first line, with any
77313498266Sopenharmony_ci# additional lines not showing INFIX.
77413498266Sopenharmony_cifunc_echo_infix_1 ()
77513498266Sopenharmony_ci{
77613498266Sopenharmony_ci    $debug_cmd
77713498266Sopenharmony_ci
77813498266Sopenharmony_ci    $require_term_colors
77913498266Sopenharmony_ci
78013498266Sopenharmony_ci    _G_infix=$1; shift
78113498266Sopenharmony_ci    _G_indent=$_G_infix
78213498266Sopenharmony_ci    _G_prefix="$progname: $_G_infix: "
78313498266Sopenharmony_ci    _G_message=$*
78413498266Sopenharmony_ci
78513498266Sopenharmony_ci    # Strip color escape sequences before counting printable length
78613498266Sopenharmony_ci    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
78713498266Sopenharmony_ci    do
78813498266Sopenharmony_ci      test -n "$_G_tc" && {
78913498266Sopenharmony_ci        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
79013498266Sopenharmony_ci        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
79113498266Sopenharmony_ci      }
79213498266Sopenharmony_ci    done
79313498266Sopenharmony_ci    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
79413498266Sopenharmony_ci
79513498266Sopenharmony_ci    func_echo_infix_1_IFS=$IFS
79613498266Sopenharmony_ci    IFS=$nl
79713498266Sopenharmony_ci    for _G_line in $_G_message; do
79813498266Sopenharmony_ci      IFS=$func_echo_infix_1_IFS
79913498266Sopenharmony_ci      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
80013498266Sopenharmony_ci      _G_prefix=$_G_indent
80113498266Sopenharmony_ci    done
80213498266Sopenharmony_ci    IFS=$func_echo_infix_1_IFS
80313498266Sopenharmony_ci}
80413498266Sopenharmony_ci
80513498266Sopenharmony_ci
80613498266Sopenharmony_ci# func_error ARG...
80713498266Sopenharmony_ci# -----------------
80813498266Sopenharmony_ci# Echo program name prefixed message to standard error.
80913498266Sopenharmony_cifunc_error ()
81013498266Sopenharmony_ci{
81113498266Sopenharmony_ci    $debug_cmd
81213498266Sopenharmony_ci
81313498266Sopenharmony_ci    $require_term_colors
81413498266Sopenharmony_ci
81513498266Sopenharmony_ci    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
81613498266Sopenharmony_ci}
81713498266Sopenharmony_ci
81813498266Sopenharmony_ci
81913498266Sopenharmony_ci# func_fatal_error ARG...
82013498266Sopenharmony_ci# -----------------------
82113498266Sopenharmony_ci# Echo program name prefixed message to standard error, and exit.
82213498266Sopenharmony_cifunc_fatal_error ()
82313498266Sopenharmony_ci{
82413498266Sopenharmony_ci    $debug_cmd
82513498266Sopenharmony_ci
82613498266Sopenharmony_ci    func_error "$*"
82713498266Sopenharmony_ci    exit $EXIT_FAILURE
82813498266Sopenharmony_ci}
82913498266Sopenharmony_ci
83013498266Sopenharmony_ci
83113498266Sopenharmony_ci# func_grep EXPRESSION FILENAME
83213498266Sopenharmony_ci# -----------------------------
83313498266Sopenharmony_ci# Check whether EXPRESSION matches any line of FILENAME, without output.
83413498266Sopenharmony_cifunc_grep ()
83513498266Sopenharmony_ci{
83613498266Sopenharmony_ci    $debug_cmd
83713498266Sopenharmony_ci
83813498266Sopenharmony_ci    $GREP "$1" "$2" >/dev/null 2>&1
83913498266Sopenharmony_ci}
84013498266Sopenharmony_ci
84113498266Sopenharmony_ci
84213498266Sopenharmony_ci# func_len STRING
84313498266Sopenharmony_ci# ---------------
84413498266Sopenharmony_ci# Set func_len_result to the length of STRING. STRING may not
84513498266Sopenharmony_ci# start with a hyphen.
84613498266Sopenharmony_ci  test -z "$_G_HAVE_XSI_OPS" \
84713498266Sopenharmony_ci    && (eval 'x=a/b/c;
84813498266Sopenharmony_ci      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
84913498266Sopenharmony_ci    && _G_HAVE_XSI_OPS=yes
85013498266Sopenharmony_ci
85113498266Sopenharmony_ciif test yes = "$_G_HAVE_XSI_OPS"; then
85213498266Sopenharmony_ci  eval 'func_len ()
85313498266Sopenharmony_ci  {
85413498266Sopenharmony_ci    $debug_cmd
85513498266Sopenharmony_ci
85613498266Sopenharmony_ci    func_len_result=${#1}
85713498266Sopenharmony_ci  }'
85813498266Sopenharmony_cielse
85913498266Sopenharmony_ci  func_len ()
86013498266Sopenharmony_ci  {
86113498266Sopenharmony_ci    $debug_cmd
86213498266Sopenharmony_ci
86313498266Sopenharmony_ci    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
86413498266Sopenharmony_ci  }
86513498266Sopenharmony_cifi
86613498266Sopenharmony_ci
86713498266Sopenharmony_ci
86813498266Sopenharmony_ci# func_mkdir_p DIRECTORY-PATH
86913498266Sopenharmony_ci# ---------------------------
87013498266Sopenharmony_ci# Make sure the entire path to DIRECTORY-PATH is available.
87113498266Sopenharmony_cifunc_mkdir_p ()
87213498266Sopenharmony_ci{
87313498266Sopenharmony_ci    $debug_cmd
87413498266Sopenharmony_ci
87513498266Sopenharmony_ci    _G_directory_path=$1
87613498266Sopenharmony_ci    _G_dir_list=
87713498266Sopenharmony_ci
87813498266Sopenharmony_ci    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
87913498266Sopenharmony_ci
88013498266Sopenharmony_ci      # Protect directory names starting with '-'
88113498266Sopenharmony_ci      case $_G_directory_path in
88213498266Sopenharmony_ci        -*) _G_directory_path=./$_G_directory_path ;;
88313498266Sopenharmony_ci      esac
88413498266Sopenharmony_ci
88513498266Sopenharmony_ci      # While some portion of DIR does not yet exist...
88613498266Sopenharmony_ci      while test ! -d "$_G_directory_path"; do
88713498266Sopenharmony_ci        # ...make a list in topmost first order.  Use a colon delimited
88813498266Sopenharmony_ci	# list incase some portion of path contains whitespace.
88913498266Sopenharmony_ci        _G_dir_list=$_G_directory_path:$_G_dir_list
89013498266Sopenharmony_ci
89113498266Sopenharmony_ci        # If the last portion added has no slash in it, the list is done
89213498266Sopenharmony_ci        case $_G_directory_path in */*) ;; *) break ;; esac
89313498266Sopenharmony_ci
89413498266Sopenharmony_ci        # ...otherwise throw away the child directory and loop
89513498266Sopenharmony_ci        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
89613498266Sopenharmony_ci      done
89713498266Sopenharmony_ci      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
89813498266Sopenharmony_ci
89913498266Sopenharmony_ci      func_mkdir_p_IFS=$IFS; IFS=:
90013498266Sopenharmony_ci      for _G_dir in $_G_dir_list; do
90113498266Sopenharmony_ci	IFS=$func_mkdir_p_IFS
90213498266Sopenharmony_ci        # mkdir can fail with a 'File exist' error if two processes
90313498266Sopenharmony_ci        # try to create one of the directories concurrently.  Don't
90413498266Sopenharmony_ci        # stop in that case!
90513498266Sopenharmony_ci        $MKDIR "$_G_dir" 2>/dev/null || :
90613498266Sopenharmony_ci      done
90713498266Sopenharmony_ci      IFS=$func_mkdir_p_IFS
90813498266Sopenharmony_ci
90913498266Sopenharmony_ci      # Bail out if we (or some other process) failed to create a directory.
91013498266Sopenharmony_ci      test -d "$_G_directory_path" || \
91113498266Sopenharmony_ci        func_fatal_error "Failed to create '$1'"
91213498266Sopenharmony_ci    fi
91313498266Sopenharmony_ci}
91413498266Sopenharmony_ci
91513498266Sopenharmony_ci
91613498266Sopenharmony_ci# func_mktempdir [BASENAME]
91713498266Sopenharmony_ci# -------------------------
91813498266Sopenharmony_ci# Make a temporary directory that won't clash with other running
91913498266Sopenharmony_ci# libtool processes, and avoids race conditions if possible.  If
92013498266Sopenharmony_ci# given, BASENAME is the basename for that directory.
92113498266Sopenharmony_cifunc_mktempdir ()
92213498266Sopenharmony_ci{
92313498266Sopenharmony_ci    $debug_cmd
92413498266Sopenharmony_ci
92513498266Sopenharmony_ci    _G_template=${TMPDIR-/tmp}/${1-$progname}
92613498266Sopenharmony_ci
92713498266Sopenharmony_ci    if test : = "$opt_dry_run"; then
92813498266Sopenharmony_ci      # Return a directory name, but don't create it in dry-run mode
92913498266Sopenharmony_ci      _G_tmpdir=$_G_template-$$
93013498266Sopenharmony_ci    else
93113498266Sopenharmony_ci
93213498266Sopenharmony_ci      # If mktemp works, use that first and foremost
93313498266Sopenharmony_ci      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
93413498266Sopenharmony_ci
93513498266Sopenharmony_ci      if test ! -d "$_G_tmpdir"; then
93613498266Sopenharmony_ci        # Failing that, at least try and use $RANDOM to avoid a race
93713498266Sopenharmony_ci        _G_tmpdir=$_G_template-${RANDOM-0}$$
93813498266Sopenharmony_ci
93913498266Sopenharmony_ci        func_mktempdir_umask=`umask`
94013498266Sopenharmony_ci        umask 0077
94113498266Sopenharmony_ci        $MKDIR "$_G_tmpdir"
94213498266Sopenharmony_ci        umask $func_mktempdir_umask
94313498266Sopenharmony_ci      fi
94413498266Sopenharmony_ci
94513498266Sopenharmony_ci      # If we're not in dry-run mode, bomb out on failure
94613498266Sopenharmony_ci      test -d "$_G_tmpdir" || \
94713498266Sopenharmony_ci        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
94813498266Sopenharmony_ci    fi
94913498266Sopenharmony_ci
95013498266Sopenharmony_ci    $ECHO "$_G_tmpdir"
95113498266Sopenharmony_ci}
95213498266Sopenharmony_ci
95313498266Sopenharmony_ci
95413498266Sopenharmony_ci# func_normal_abspath PATH
95513498266Sopenharmony_ci# ------------------------
95613498266Sopenharmony_ci# Remove doubled-up and trailing slashes, "." path components,
95713498266Sopenharmony_ci# and cancel out any ".." path components in PATH after making
95813498266Sopenharmony_ci# it an absolute path.
95913498266Sopenharmony_cifunc_normal_abspath ()
96013498266Sopenharmony_ci{
96113498266Sopenharmony_ci    $debug_cmd
96213498266Sopenharmony_ci
96313498266Sopenharmony_ci    # These SED scripts presuppose an absolute path with a trailing slash.
96413498266Sopenharmony_ci    _G_pathcar='s|^/\([^/]*\).*$|\1|'
96513498266Sopenharmony_ci    _G_pathcdr='s|^/[^/]*||'
96613498266Sopenharmony_ci    _G_removedotparts=':dotsl
96713498266Sopenharmony_ci		s|/\./|/|g
96813498266Sopenharmony_ci		t dotsl
96913498266Sopenharmony_ci		s|/\.$|/|'
97013498266Sopenharmony_ci    _G_collapseslashes='s|/\{1,\}|/|g'
97113498266Sopenharmony_ci    _G_finalslash='s|/*$|/|'
97213498266Sopenharmony_ci
97313498266Sopenharmony_ci    # Start from root dir and reassemble the path.
97413498266Sopenharmony_ci    func_normal_abspath_result=
97513498266Sopenharmony_ci    func_normal_abspath_tpath=$1
97613498266Sopenharmony_ci    func_normal_abspath_altnamespace=
97713498266Sopenharmony_ci    case $func_normal_abspath_tpath in
97813498266Sopenharmony_ci      "")
97913498266Sopenharmony_ci        # Empty path, that just means $cwd.
98013498266Sopenharmony_ci        func_stripname '' '/' "`pwd`"
98113498266Sopenharmony_ci        func_normal_abspath_result=$func_stripname_result
98213498266Sopenharmony_ci        return
98313498266Sopenharmony_ci        ;;
98413498266Sopenharmony_ci      # The next three entries are used to spot a run of precisely
98513498266Sopenharmony_ci      # two leading slashes without using negated character classes;
98613498266Sopenharmony_ci      # we take advantage of case's first-match behaviour.
98713498266Sopenharmony_ci      ///*)
98813498266Sopenharmony_ci        # Unusual form of absolute path, do nothing.
98913498266Sopenharmony_ci        ;;
99013498266Sopenharmony_ci      //*)
99113498266Sopenharmony_ci        # Not necessarily an ordinary path; POSIX reserves leading '//'
99213498266Sopenharmony_ci        # and for example Cygwin uses it to access remote file shares
99313498266Sopenharmony_ci        # over CIFS/SMB, so we conserve a leading double slash if found.
99413498266Sopenharmony_ci        func_normal_abspath_altnamespace=/
99513498266Sopenharmony_ci        ;;
99613498266Sopenharmony_ci      /*)
99713498266Sopenharmony_ci        # Absolute path, do nothing.
99813498266Sopenharmony_ci        ;;
99913498266Sopenharmony_ci      *)
100013498266Sopenharmony_ci        # Relative path, prepend $cwd.
100113498266Sopenharmony_ci        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
100213498266Sopenharmony_ci        ;;
100313498266Sopenharmony_ci    esac
100413498266Sopenharmony_ci
100513498266Sopenharmony_ci    # Cancel out all the simple stuff to save iterations.  We also want
100613498266Sopenharmony_ci    # the path to end with a slash for ease of parsing, so make sure
100713498266Sopenharmony_ci    # there is one (and only one) here.
100813498266Sopenharmony_ci    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
100913498266Sopenharmony_ci          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
101013498266Sopenharmony_ci    while :; do
101113498266Sopenharmony_ci      # Processed it all yet?
101213498266Sopenharmony_ci      if test / = "$func_normal_abspath_tpath"; then
101313498266Sopenharmony_ci        # If we ascended to the root using ".." the result may be empty now.
101413498266Sopenharmony_ci        if test -z "$func_normal_abspath_result"; then
101513498266Sopenharmony_ci          func_normal_abspath_result=/
101613498266Sopenharmony_ci        fi
101713498266Sopenharmony_ci        break
101813498266Sopenharmony_ci      fi
101913498266Sopenharmony_ci      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
102013498266Sopenharmony_ci          -e "$_G_pathcar"`
102113498266Sopenharmony_ci      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
102213498266Sopenharmony_ci          -e "$_G_pathcdr"`
102313498266Sopenharmony_ci      # Figure out what to do with it
102413498266Sopenharmony_ci      case $func_normal_abspath_tcomponent in
102513498266Sopenharmony_ci        "")
102613498266Sopenharmony_ci          # Trailing empty path component, ignore it.
102713498266Sopenharmony_ci          ;;
102813498266Sopenharmony_ci        ..)
102913498266Sopenharmony_ci          # Parent dir; strip last assembled component from result.
103013498266Sopenharmony_ci          func_dirname "$func_normal_abspath_result"
103113498266Sopenharmony_ci          func_normal_abspath_result=$func_dirname_result
103213498266Sopenharmony_ci          ;;
103313498266Sopenharmony_ci        *)
103413498266Sopenharmony_ci          # Actual path component, append it.
103513498266Sopenharmony_ci          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
103613498266Sopenharmony_ci          ;;
103713498266Sopenharmony_ci      esac
103813498266Sopenharmony_ci    done
103913498266Sopenharmony_ci    # Restore leading double-slash if one was found on entry.
104013498266Sopenharmony_ci    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
104113498266Sopenharmony_ci}
104213498266Sopenharmony_ci
104313498266Sopenharmony_ci
104413498266Sopenharmony_ci# func_notquiet ARG...
104513498266Sopenharmony_ci# --------------------
104613498266Sopenharmony_ci# Echo program name prefixed message only when not in quiet mode.
104713498266Sopenharmony_cifunc_notquiet ()
104813498266Sopenharmony_ci{
104913498266Sopenharmony_ci    $debug_cmd
105013498266Sopenharmony_ci
105113498266Sopenharmony_ci    $opt_quiet || func_echo ${1+"$@"}
105213498266Sopenharmony_ci
105313498266Sopenharmony_ci    # A bug in bash halts the script if the last line of a function
105413498266Sopenharmony_ci    # fails when set -e is in force, so we need another command to
105513498266Sopenharmony_ci    # work around that:
105613498266Sopenharmony_ci    :
105713498266Sopenharmony_ci}
105813498266Sopenharmony_ci
105913498266Sopenharmony_ci
106013498266Sopenharmony_ci# func_relative_path SRCDIR DSTDIR
106113498266Sopenharmony_ci# --------------------------------
106213498266Sopenharmony_ci# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
106313498266Sopenharmony_cifunc_relative_path ()
106413498266Sopenharmony_ci{
106513498266Sopenharmony_ci    $debug_cmd
106613498266Sopenharmony_ci
106713498266Sopenharmony_ci    func_relative_path_result=
106813498266Sopenharmony_ci    func_normal_abspath "$1"
106913498266Sopenharmony_ci    func_relative_path_tlibdir=$func_normal_abspath_result
107013498266Sopenharmony_ci    func_normal_abspath "$2"
107113498266Sopenharmony_ci    func_relative_path_tbindir=$func_normal_abspath_result
107213498266Sopenharmony_ci
107313498266Sopenharmony_ci    # Ascend the tree starting from libdir
107413498266Sopenharmony_ci    while :; do
107513498266Sopenharmony_ci      # check if we have found a prefix of bindir
107613498266Sopenharmony_ci      case $func_relative_path_tbindir in
107713498266Sopenharmony_ci        $func_relative_path_tlibdir)
107813498266Sopenharmony_ci          # found an exact match
107913498266Sopenharmony_ci          func_relative_path_tcancelled=
108013498266Sopenharmony_ci          break
108113498266Sopenharmony_ci          ;;
108213498266Sopenharmony_ci        $func_relative_path_tlibdir*)
108313498266Sopenharmony_ci          # found a matching prefix
108413498266Sopenharmony_ci          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
108513498266Sopenharmony_ci          func_relative_path_tcancelled=$func_stripname_result
108613498266Sopenharmony_ci          if test -z "$func_relative_path_result"; then
108713498266Sopenharmony_ci            func_relative_path_result=.
108813498266Sopenharmony_ci          fi
108913498266Sopenharmony_ci          break
109013498266Sopenharmony_ci          ;;
109113498266Sopenharmony_ci        *)
109213498266Sopenharmony_ci          func_dirname $func_relative_path_tlibdir
109313498266Sopenharmony_ci          func_relative_path_tlibdir=$func_dirname_result
109413498266Sopenharmony_ci          if test -z "$func_relative_path_tlibdir"; then
109513498266Sopenharmony_ci            # Have to descend all the way to the root!
109613498266Sopenharmony_ci            func_relative_path_result=../$func_relative_path_result
109713498266Sopenharmony_ci            func_relative_path_tcancelled=$func_relative_path_tbindir
109813498266Sopenharmony_ci            break
109913498266Sopenharmony_ci          fi
110013498266Sopenharmony_ci          func_relative_path_result=../$func_relative_path_result
110113498266Sopenharmony_ci          ;;
110213498266Sopenharmony_ci      esac
110313498266Sopenharmony_ci    done
110413498266Sopenharmony_ci
110513498266Sopenharmony_ci    # Now calculate path; take care to avoid doubling-up slashes.
110613498266Sopenharmony_ci    func_stripname '' '/' "$func_relative_path_result"
110713498266Sopenharmony_ci    func_relative_path_result=$func_stripname_result
110813498266Sopenharmony_ci    func_stripname '/' '/' "$func_relative_path_tcancelled"
110913498266Sopenharmony_ci    if test -n "$func_stripname_result"; then
111013498266Sopenharmony_ci      func_append func_relative_path_result "/$func_stripname_result"
111113498266Sopenharmony_ci    fi
111213498266Sopenharmony_ci
111313498266Sopenharmony_ci    # Normalisation. If bindir is libdir, return '.' else relative path.
111413498266Sopenharmony_ci    if test -n "$func_relative_path_result"; then
111513498266Sopenharmony_ci      func_stripname './' '' "$func_relative_path_result"
111613498266Sopenharmony_ci      func_relative_path_result=$func_stripname_result
111713498266Sopenharmony_ci    fi
111813498266Sopenharmony_ci
111913498266Sopenharmony_ci    test -n "$func_relative_path_result" || func_relative_path_result=.
112013498266Sopenharmony_ci
112113498266Sopenharmony_ci    :
112213498266Sopenharmony_ci}
112313498266Sopenharmony_ci
112413498266Sopenharmony_ci
112513498266Sopenharmony_ci# func_quote_portable EVAL ARG
112613498266Sopenharmony_ci# ----------------------------
112713498266Sopenharmony_ci# Internal function to portably implement func_quote_arg.  Note that we still
112813498266Sopenharmony_ci# keep attention to performance here so we as much as possible try to avoid
112913498266Sopenharmony_ci# calling sed binary (so far O(N) complexity as long as func_append is O(1)).
113013498266Sopenharmony_cifunc_quote_portable ()
113113498266Sopenharmony_ci{
113213498266Sopenharmony_ci    $debug_cmd
113313498266Sopenharmony_ci
113413498266Sopenharmony_ci    $require_check_ifs_backslash
113513498266Sopenharmony_ci
113613498266Sopenharmony_ci    func_quote_portable_result=$2
113713498266Sopenharmony_ci
113813498266Sopenharmony_ci    # one-time-loop (easy break)
113913498266Sopenharmony_ci    while true
114013498266Sopenharmony_ci    do
114113498266Sopenharmony_ci      if $1; then
114213498266Sopenharmony_ci        func_quote_portable_result=`$ECHO "$2" | $SED \
114313498266Sopenharmony_ci          -e "$sed_double_quote_subst" -e "$sed_double_backslash"`
114413498266Sopenharmony_ci        break
114513498266Sopenharmony_ci      fi
114613498266Sopenharmony_ci
114713498266Sopenharmony_ci      # Quote for eval.
114813498266Sopenharmony_ci      case $func_quote_portable_result in
114913498266Sopenharmony_ci        *[\\\`\"\$]*)
115013498266Sopenharmony_ci          # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string
115113498266Sopenharmony_ci          # contains the shell wildcard characters.
115213498266Sopenharmony_ci          case $check_ifs_backshlash_broken$func_quote_portable_result in
115313498266Sopenharmony_ci            :*|*[\[\*\?]*)
115413498266Sopenharmony_ci              func_quote_portable_result=`$ECHO "$func_quote_portable_result" \
115513498266Sopenharmony_ci                  | $SED "$sed_quote_subst"`
115613498266Sopenharmony_ci              break
115713498266Sopenharmony_ci              ;;
115813498266Sopenharmony_ci          esac
115913498266Sopenharmony_ci
116013498266Sopenharmony_ci          func_quote_portable_old_IFS=$IFS
116113498266Sopenharmony_ci          for _G_char in '\' '`' '"' '$'
116213498266Sopenharmony_ci          do
116313498266Sopenharmony_ci            # STATE($1) PREV($2) SEPARATOR($3)
116413498266Sopenharmony_ci            set start "" ""
116513498266Sopenharmony_ci            func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy
116613498266Sopenharmony_ci            IFS=$_G_char
116713498266Sopenharmony_ci            for _G_part in $func_quote_portable_result
116813498266Sopenharmony_ci            do
116913498266Sopenharmony_ci              case $1 in
117013498266Sopenharmony_ci              quote)
117113498266Sopenharmony_ci                func_append func_quote_portable_result "$3$2"
117213498266Sopenharmony_ci                set quote "$_G_part" "\\$_G_char"
117313498266Sopenharmony_ci                ;;
117413498266Sopenharmony_ci              start)
117513498266Sopenharmony_ci                set first "" ""
117613498266Sopenharmony_ci                func_quote_portable_result=
117713498266Sopenharmony_ci                ;;
117813498266Sopenharmony_ci              first)
117913498266Sopenharmony_ci                set quote "$_G_part" ""
118013498266Sopenharmony_ci                ;;
118113498266Sopenharmony_ci              esac
118213498266Sopenharmony_ci            done
118313498266Sopenharmony_ci          done
118413498266Sopenharmony_ci          IFS=$func_quote_portable_old_IFS
118513498266Sopenharmony_ci          ;;
118613498266Sopenharmony_ci        *) ;;
118713498266Sopenharmony_ci      esac
118813498266Sopenharmony_ci      break
118913498266Sopenharmony_ci    done
119013498266Sopenharmony_ci
119113498266Sopenharmony_ci    func_quote_portable_unquoted_result=$func_quote_portable_result
119213498266Sopenharmony_ci    case $func_quote_portable_result in
119313498266Sopenharmony_ci      # double-quote args containing shell metacharacters to delay
119413498266Sopenharmony_ci      # word splitting, command substitution and variable expansion
119513498266Sopenharmony_ci      # for a subsequent eval.
119613498266Sopenharmony_ci      # many bourne shells cannot handle close brackets correctly
119713498266Sopenharmony_ci      # in scan sets, so we specify it separately.
119813498266Sopenharmony_ci      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
119913498266Sopenharmony_ci        func_quote_portable_result=\"$func_quote_portable_result\"
120013498266Sopenharmony_ci        ;;
120113498266Sopenharmony_ci    esac
120213498266Sopenharmony_ci}
120313498266Sopenharmony_ci
120413498266Sopenharmony_ci
120513498266Sopenharmony_ci# func_quotefast_eval ARG
120613498266Sopenharmony_ci# -----------------------
120713498266Sopenharmony_ci# Quote one ARG (internal).  This is equivalent to 'func_quote_arg eval ARG',
120813498266Sopenharmony_ci# but optimized for speed.  Result is stored in $func_quotefast_eval.
120913498266Sopenharmony_ciif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then
121013498266Sopenharmony_ci  printf -v _GL_test_printf_tilde %q '~'
121113498266Sopenharmony_ci  if test '\~' = "$_GL_test_printf_tilde"; then
121213498266Sopenharmony_ci    func_quotefast_eval ()
121313498266Sopenharmony_ci    {
121413498266Sopenharmony_ci      printf -v func_quotefast_eval_result %q "$1"
121513498266Sopenharmony_ci    }
121613498266Sopenharmony_ci  else
121713498266Sopenharmony_ci    # Broken older Bash implementations.  Make those faster too if possible.
121813498266Sopenharmony_ci    func_quotefast_eval ()
121913498266Sopenharmony_ci    {
122013498266Sopenharmony_ci      case $1 in
122113498266Sopenharmony_ci        '~'*)
122213498266Sopenharmony_ci          func_quote_portable false "$1"
122313498266Sopenharmony_ci          func_quotefast_eval_result=$func_quote_portable_result
122413498266Sopenharmony_ci          ;;
122513498266Sopenharmony_ci        *)
122613498266Sopenharmony_ci          printf -v func_quotefast_eval_result %q "$1"
122713498266Sopenharmony_ci          ;;
122813498266Sopenharmony_ci      esac
122913498266Sopenharmony_ci    }
123013498266Sopenharmony_ci  fi
123113498266Sopenharmony_cielse
123213498266Sopenharmony_ci  func_quotefast_eval ()
123313498266Sopenharmony_ci  {
123413498266Sopenharmony_ci    func_quote_portable false "$1"
123513498266Sopenharmony_ci    func_quotefast_eval_result=$func_quote_portable_result
123613498266Sopenharmony_ci  }
123713498266Sopenharmony_cifi
123813498266Sopenharmony_ci
123913498266Sopenharmony_ci
124013498266Sopenharmony_ci# func_quote_arg MODEs ARG
124113498266Sopenharmony_ci# ------------------------
124213498266Sopenharmony_ci# Quote one ARG to be evaled later.  MODEs argument may contain zero or more
124313498266Sopenharmony_ci# specifiers listed below separated by ',' character.  This function returns two
124413498266Sopenharmony_ci# values:
124513498266Sopenharmony_ci#   i) func_quote_arg_result
124613498266Sopenharmony_ci#      double-quoted (when needed), suitable for a subsequent eval
124713498266Sopenharmony_ci#  ii) func_quote_arg_unquoted_result
124813498266Sopenharmony_ci#      has all characters that are still active within double
124913498266Sopenharmony_ci#      quotes backslashified.  Available only if 'unquoted' is specified.
125013498266Sopenharmony_ci#
125113498266Sopenharmony_ci# Available modes:
125213498266Sopenharmony_ci# ----------------
125313498266Sopenharmony_ci# 'eval' (default)
125413498266Sopenharmony_ci#       - escape shell special characters
125513498266Sopenharmony_ci# 'expand'
125613498266Sopenharmony_ci#       - the same as 'eval';  but do not quote variable references
125713498266Sopenharmony_ci# 'pretty'
125813498266Sopenharmony_ci#       - request aesthetic output, i.e. '"a b"' instead of 'a\ b'.  This might
125913498266Sopenharmony_ci#         be used later in func_quote to get output like: 'echo "a b"' instead
126013498266Sopenharmony_ci#         of 'echo a\ b'.  This is slower than default on some shells.
126113498266Sopenharmony_ci# 'unquoted'
126213498266Sopenharmony_ci#       - produce also $func_quote_arg_unquoted_result which does not contain
126313498266Sopenharmony_ci#         wrapping double-quotes.
126413498266Sopenharmony_ci#
126513498266Sopenharmony_ci# Examples for 'func_quote_arg pretty,unquoted string':
126613498266Sopenharmony_ci#
126713498266Sopenharmony_ci#   string      | *_result              | *_unquoted_result
126813498266Sopenharmony_ci#   ------------+-----------------------+-------------------
126913498266Sopenharmony_ci#   "           | \"                    | \"
127013498266Sopenharmony_ci#   a b         | "a b"                 | a b
127113498266Sopenharmony_ci#   "a b"       | "\"a b\""             | \"a b\"
127213498266Sopenharmony_ci#   *           | "*"                   | *
127313498266Sopenharmony_ci#   z="${x-$y}" | "z=\"\${x-\$y}\""     | z=\"\${x-\$y}\"
127413498266Sopenharmony_ci#
127513498266Sopenharmony_ci# Examples for 'func_quote_arg pretty,unquoted,expand string':
127613498266Sopenharmony_ci#
127713498266Sopenharmony_ci#   string        |   *_result          |  *_unquoted_result
127813498266Sopenharmony_ci#   --------------+---------------------+--------------------
127913498266Sopenharmony_ci#   z="${x-$y}"   | "z=\"${x-$y}\""     | z=\"${x-$y}\"
128013498266Sopenharmony_cifunc_quote_arg ()
128113498266Sopenharmony_ci{
128213498266Sopenharmony_ci    _G_quote_expand=false
128313498266Sopenharmony_ci    case ,$1, in
128413498266Sopenharmony_ci      *,expand,*)
128513498266Sopenharmony_ci        _G_quote_expand=:
128613498266Sopenharmony_ci        ;;
128713498266Sopenharmony_ci    esac
128813498266Sopenharmony_ci
128913498266Sopenharmony_ci    case ,$1, in
129013498266Sopenharmony_ci      *,pretty,*|*,expand,*|*,unquoted,*)
129113498266Sopenharmony_ci        func_quote_portable $_G_quote_expand "$2"
129213498266Sopenharmony_ci        func_quote_arg_result=$func_quote_portable_result
129313498266Sopenharmony_ci        func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result
129413498266Sopenharmony_ci        ;;
129513498266Sopenharmony_ci      *)
129613498266Sopenharmony_ci        # Faster quote-for-eval for some shells.
129713498266Sopenharmony_ci        func_quotefast_eval "$2"
129813498266Sopenharmony_ci        func_quote_arg_result=$func_quotefast_eval_result
129913498266Sopenharmony_ci        ;;
130013498266Sopenharmony_ci    esac
130113498266Sopenharmony_ci}
130213498266Sopenharmony_ci
130313498266Sopenharmony_ci
130413498266Sopenharmony_ci# func_quote MODEs ARGs...
130513498266Sopenharmony_ci# ------------------------
130613498266Sopenharmony_ci# Quote all ARGs to be evaled later and join them into single command.  See
130713498266Sopenharmony_ci# func_quote_arg's description for more info.
130813498266Sopenharmony_cifunc_quote ()
130913498266Sopenharmony_ci{
131013498266Sopenharmony_ci    $debug_cmd
131113498266Sopenharmony_ci    _G_func_quote_mode=$1 ; shift
131213498266Sopenharmony_ci    func_quote_result=
131313498266Sopenharmony_ci    while test 0 -lt $#; do
131413498266Sopenharmony_ci      func_quote_arg "$_G_func_quote_mode" "$1"
131513498266Sopenharmony_ci      if test -n "$func_quote_result"; then
131613498266Sopenharmony_ci        func_append func_quote_result " $func_quote_arg_result"
131713498266Sopenharmony_ci      else
131813498266Sopenharmony_ci        func_append func_quote_result "$func_quote_arg_result"
131913498266Sopenharmony_ci      fi
132013498266Sopenharmony_ci      shift
132113498266Sopenharmony_ci    done
132213498266Sopenharmony_ci}
132313498266Sopenharmony_ci
132413498266Sopenharmony_ci
132513498266Sopenharmony_ci# func_stripname PREFIX SUFFIX NAME
132613498266Sopenharmony_ci# ---------------------------------
132713498266Sopenharmony_ci# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
132813498266Sopenharmony_ci# PREFIX and SUFFIX must not contain globbing or regex special
132913498266Sopenharmony_ci# characters, hashes, percent signs, but SUFFIX may contain a leading
133013498266Sopenharmony_ci# dot (in which case that matches only a dot).
133113498266Sopenharmony_ciif test yes = "$_G_HAVE_XSI_OPS"; then
133213498266Sopenharmony_ci  eval 'func_stripname ()
133313498266Sopenharmony_ci  {
133413498266Sopenharmony_ci    $debug_cmd
133513498266Sopenharmony_ci
133613498266Sopenharmony_ci    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
133713498266Sopenharmony_ci    # positional parameters, so assign one to ordinary variable first.
133813498266Sopenharmony_ci    func_stripname_result=$3
133913498266Sopenharmony_ci    func_stripname_result=${func_stripname_result#"$1"}
134013498266Sopenharmony_ci    func_stripname_result=${func_stripname_result%"$2"}
134113498266Sopenharmony_ci  }'
134213498266Sopenharmony_cielse
134313498266Sopenharmony_ci  func_stripname ()
134413498266Sopenharmony_ci  {
134513498266Sopenharmony_ci    $debug_cmd
134613498266Sopenharmony_ci
134713498266Sopenharmony_ci    case $2 in
134813498266Sopenharmony_ci      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
134913498266Sopenharmony_ci      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
135013498266Sopenharmony_ci    esac
135113498266Sopenharmony_ci  }
135213498266Sopenharmony_cifi
135313498266Sopenharmony_ci
135413498266Sopenharmony_ci
135513498266Sopenharmony_ci# func_show_eval CMD [FAIL_EXP]
135613498266Sopenharmony_ci# -----------------------------
135713498266Sopenharmony_ci# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
135813498266Sopenharmony_ci# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
135913498266Sopenharmony_ci# is given, then evaluate it.
136013498266Sopenharmony_cifunc_show_eval ()
136113498266Sopenharmony_ci{
136213498266Sopenharmony_ci    $debug_cmd
136313498266Sopenharmony_ci
136413498266Sopenharmony_ci    _G_cmd=$1
136513498266Sopenharmony_ci    _G_fail_exp=${2-':'}
136613498266Sopenharmony_ci
136713498266Sopenharmony_ci    func_quote_arg pretty,expand "$_G_cmd"
136813498266Sopenharmony_ci    eval "func_notquiet $func_quote_arg_result"
136913498266Sopenharmony_ci
137013498266Sopenharmony_ci    $opt_dry_run || {
137113498266Sopenharmony_ci      eval "$_G_cmd"
137213498266Sopenharmony_ci      _G_status=$?
137313498266Sopenharmony_ci      if test 0 -ne "$_G_status"; then
137413498266Sopenharmony_ci	eval "(exit $_G_status); $_G_fail_exp"
137513498266Sopenharmony_ci      fi
137613498266Sopenharmony_ci    }
137713498266Sopenharmony_ci}
137813498266Sopenharmony_ci
137913498266Sopenharmony_ci
138013498266Sopenharmony_ci# func_show_eval_locale CMD [FAIL_EXP]
138113498266Sopenharmony_ci# ------------------------------------
138213498266Sopenharmony_ci# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
138313498266Sopenharmony_ci# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
138413498266Sopenharmony_ci# is given, then evaluate it.  Use the saved locale for evaluation.
138513498266Sopenharmony_cifunc_show_eval_locale ()
138613498266Sopenharmony_ci{
138713498266Sopenharmony_ci    $debug_cmd
138813498266Sopenharmony_ci
138913498266Sopenharmony_ci    _G_cmd=$1
139013498266Sopenharmony_ci    _G_fail_exp=${2-':'}
139113498266Sopenharmony_ci
139213498266Sopenharmony_ci    $opt_quiet || {
139313498266Sopenharmony_ci      func_quote_arg expand,pretty "$_G_cmd"
139413498266Sopenharmony_ci      eval "func_echo $func_quote_arg_result"
139513498266Sopenharmony_ci    }
139613498266Sopenharmony_ci
139713498266Sopenharmony_ci    $opt_dry_run || {
139813498266Sopenharmony_ci      eval "$_G_user_locale
139913498266Sopenharmony_ci	    $_G_cmd"
140013498266Sopenharmony_ci      _G_status=$?
140113498266Sopenharmony_ci      eval "$_G_safe_locale"
140213498266Sopenharmony_ci      if test 0 -ne "$_G_status"; then
140313498266Sopenharmony_ci	eval "(exit $_G_status); $_G_fail_exp"
140413498266Sopenharmony_ci      fi
140513498266Sopenharmony_ci    }
140613498266Sopenharmony_ci}
140713498266Sopenharmony_ci
140813498266Sopenharmony_ci
140913498266Sopenharmony_ci# func_tr_sh
141013498266Sopenharmony_ci# ----------
141113498266Sopenharmony_ci# Turn $1 into a string suitable for a shell variable name.
141213498266Sopenharmony_ci# Result is stored in $func_tr_sh_result.  All characters
141313498266Sopenharmony_ci# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
141413498266Sopenharmony_ci# if $1 begins with a digit, a '_' is prepended as well.
141513498266Sopenharmony_cifunc_tr_sh ()
141613498266Sopenharmony_ci{
141713498266Sopenharmony_ci    $debug_cmd
141813498266Sopenharmony_ci
141913498266Sopenharmony_ci    case $1 in
142013498266Sopenharmony_ci    [0-9]* | *[!a-zA-Z0-9_]*)
142113498266Sopenharmony_ci      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
142213498266Sopenharmony_ci      ;;
142313498266Sopenharmony_ci    * )
142413498266Sopenharmony_ci      func_tr_sh_result=$1
142513498266Sopenharmony_ci      ;;
142613498266Sopenharmony_ci    esac
142713498266Sopenharmony_ci}
142813498266Sopenharmony_ci
142913498266Sopenharmony_ci
143013498266Sopenharmony_ci# func_verbose ARG...
143113498266Sopenharmony_ci# -------------------
143213498266Sopenharmony_ci# Echo program name prefixed message in verbose mode only.
143313498266Sopenharmony_cifunc_verbose ()
143413498266Sopenharmony_ci{
143513498266Sopenharmony_ci    $debug_cmd
143613498266Sopenharmony_ci
143713498266Sopenharmony_ci    $opt_verbose && func_echo "$*"
143813498266Sopenharmony_ci
143913498266Sopenharmony_ci    :
144013498266Sopenharmony_ci}
144113498266Sopenharmony_ci
144213498266Sopenharmony_ci
144313498266Sopenharmony_ci# func_warn_and_continue ARG...
144413498266Sopenharmony_ci# -----------------------------
144513498266Sopenharmony_ci# Echo program name prefixed warning message to standard error.
144613498266Sopenharmony_cifunc_warn_and_continue ()
144713498266Sopenharmony_ci{
144813498266Sopenharmony_ci    $debug_cmd
144913498266Sopenharmony_ci
145013498266Sopenharmony_ci    $require_term_colors
145113498266Sopenharmony_ci
145213498266Sopenharmony_ci    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
145313498266Sopenharmony_ci}
145413498266Sopenharmony_ci
145513498266Sopenharmony_ci
145613498266Sopenharmony_ci# func_warning CATEGORY ARG...
145713498266Sopenharmony_ci# ----------------------------
145813498266Sopenharmony_ci# Echo program name prefixed warning message to standard error. Warning
145913498266Sopenharmony_ci# messages can be filtered according to CATEGORY, where this function
146013498266Sopenharmony_ci# elides messages where CATEGORY is not listed in the global variable
146113498266Sopenharmony_ci# 'opt_warning_types'.
146213498266Sopenharmony_cifunc_warning ()
146313498266Sopenharmony_ci{
146413498266Sopenharmony_ci    $debug_cmd
146513498266Sopenharmony_ci
146613498266Sopenharmony_ci    # CATEGORY must be in the warning_categories list!
146713498266Sopenharmony_ci    case " $warning_categories " in
146813498266Sopenharmony_ci      *" $1 "*) ;;
146913498266Sopenharmony_ci      *) func_internal_error "invalid warning category '$1'" ;;
147013498266Sopenharmony_ci    esac
147113498266Sopenharmony_ci
147213498266Sopenharmony_ci    _G_category=$1
147313498266Sopenharmony_ci    shift
147413498266Sopenharmony_ci
147513498266Sopenharmony_ci    case " $opt_warning_types " in
147613498266Sopenharmony_ci      *" $_G_category "*) $warning_func ${1+"$@"} ;;
147713498266Sopenharmony_ci    esac
147813498266Sopenharmony_ci}
147913498266Sopenharmony_ci
148013498266Sopenharmony_ci
148113498266Sopenharmony_ci# func_sort_ver VER1 VER2
148213498266Sopenharmony_ci# -----------------------
148313498266Sopenharmony_ci# 'sort -V' is not generally available.
148413498266Sopenharmony_ci# Note this deviates from the version comparison in automake
148513498266Sopenharmony_ci# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
148613498266Sopenharmony_ci# but this should suffice as we won't be specifying old
148713498266Sopenharmony_ci# version formats or redundant trailing .0 in bootstrap.conf.
148813498266Sopenharmony_ci# If we did want full compatibility then we should probably
148913498266Sopenharmony_ci# use m4_version_compare from autoconf.
149013498266Sopenharmony_cifunc_sort_ver ()
149113498266Sopenharmony_ci{
149213498266Sopenharmony_ci    $debug_cmd
149313498266Sopenharmony_ci
149413498266Sopenharmony_ci    printf '%s\n%s\n' "$1" "$2" \
149513498266Sopenharmony_ci      | 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
149613498266Sopenharmony_ci}
149713498266Sopenharmony_ci
149813498266Sopenharmony_ci# func_lt_ver PREV CURR
149913498266Sopenharmony_ci# ---------------------
150013498266Sopenharmony_ci# Return true if PREV and CURR are in the correct order according to
150113498266Sopenharmony_ci# func_sort_ver, otherwise false.  Use it like this:
150213498266Sopenharmony_ci#
150313498266Sopenharmony_ci#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
150413498266Sopenharmony_cifunc_lt_ver ()
150513498266Sopenharmony_ci{
150613498266Sopenharmony_ci    $debug_cmd
150713498266Sopenharmony_ci
150813498266Sopenharmony_ci    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
150913498266Sopenharmony_ci}
151013498266Sopenharmony_ci
151113498266Sopenharmony_ci
151213498266Sopenharmony_ci# Local variables:
151313498266Sopenharmony_ci# mode: shell-script
151413498266Sopenharmony_ci# sh-indentation: 2
151513498266Sopenharmony_ci# eval: (add-hook 'before-save-hook 'time-stamp)
151613498266Sopenharmony_ci# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
151713498266Sopenharmony_ci# time-stamp-time-zone: "UTC"
151813498266Sopenharmony_ci# End:
151913498266Sopenharmony_ci#! /bin/sh
152013498266Sopenharmony_ci
152113498266Sopenharmony_ci# A portable, pluggable option parser for Bourne shell.
152213498266Sopenharmony_ci# Written by Gary V. Vaughan, 2010
152313498266Sopenharmony_ci
152413498266Sopenharmony_ci# This is free software.  There is NO warranty; not even for
152513498266Sopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
152613498266Sopenharmony_ci#
152713498266Sopenharmony_ci# Copyright (C) 2010-2019, 2021 Bootstrap Authors
152813498266Sopenharmony_ci#
152913498266Sopenharmony_ci# This file is dual licensed under the terms of the MIT license
153013498266Sopenharmony_ci# <https://opensource.org/license/MIT>, and GPL version 2 or later
153113498266Sopenharmony_ci# <http://www.gnu.org/licenses/gpl-2.0.html>.  You must apply one of
153213498266Sopenharmony_ci# these licenses when using or redistributing this software or any of
153313498266Sopenharmony_ci# the files within it.  See the URLs above, or the file `LICENSE`
153413498266Sopenharmony_ci# included in the Bootstrap distribution for the full license texts.
153513498266Sopenharmony_ci
153613498266Sopenharmony_ci# Please report bugs or propose patches to:
153713498266Sopenharmony_ci# <https://github.com/gnulib-modules/bootstrap/issues>
153813498266Sopenharmony_ci
153913498266Sopenharmony_ci# Set a version string for this script.
154013498266Sopenharmony_ciscriptversion=2019-02-19.15; # UTC
154113498266Sopenharmony_ci
154213498266Sopenharmony_ci
154313498266Sopenharmony_ci## ------ ##
154413498266Sopenharmony_ci## Usage. ##
154513498266Sopenharmony_ci## ------ ##
154613498266Sopenharmony_ci
154713498266Sopenharmony_ci# This file is a library for parsing options in your shell scripts along
154813498266Sopenharmony_ci# with assorted other useful supporting features that you can make use
154913498266Sopenharmony_ci# of too.
155013498266Sopenharmony_ci#
155113498266Sopenharmony_ci# For the simplest scripts you might need only:
155213498266Sopenharmony_ci#
155313498266Sopenharmony_ci#   #!/bin/sh
155413498266Sopenharmony_ci#   . relative/path/to/funclib.sh
155513498266Sopenharmony_ci#   . relative/path/to/options-parser
155613498266Sopenharmony_ci#   scriptversion=1.0
155713498266Sopenharmony_ci#   func_options ${1+"$@"}
155813498266Sopenharmony_ci#   eval set dummy "$func_options_result"; shift
155913498266Sopenharmony_ci#   ...rest of your script...
156013498266Sopenharmony_ci#
156113498266Sopenharmony_ci# In order for the '--version' option to work, you will need to have a
156213498266Sopenharmony_ci# suitably formatted comment like the one at the top of this file
156313498266Sopenharmony_ci# starting with '# Written by ' and ending with '# Copyright'.
156413498266Sopenharmony_ci#
156513498266Sopenharmony_ci# For '-h' and '--help' to work, you will also need a one line
156613498266Sopenharmony_ci# description of your script's purpose in a comment directly above the
156713498266Sopenharmony_ci# '# Written by ' line, like the one at the top of this file.
156813498266Sopenharmony_ci#
156913498266Sopenharmony_ci# The default options also support '--debug', which will turn on shell
157013498266Sopenharmony_ci# execution tracing (see the comment above debug_cmd below for another
157113498266Sopenharmony_ci# use), and '--verbose' and the func_verbose function to allow your script
157213498266Sopenharmony_ci# to display verbose messages only when your user has specified
157313498266Sopenharmony_ci# '--verbose'.
157413498266Sopenharmony_ci#
157513498266Sopenharmony_ci# After sourcing this file, you can plug in processing for additional
157613498266Sopenharmony_ci# options by amending the variables from the 'Configuration' section
157713498266Sopenharmony_ci# below, and following the instructions in the 'Option parsing'
157813498266Sopenharmony_ci# section further down.
157913498266Sopenharmony_ci
158013498266Sopenharmony_ci## -------------- ##
158113498266Sopenharmony_ci## Configuration. ##
158213498266Sopenharmony_ci## -------------- ##
158313498266Sopenharmony_ci
158413498266Sopenharmony_ci# You should override these variables in your script after sourcing this
158513498266Sopenharmony_ci# file so that they reflect the customisations you have added to the
158613498266Sopenharmony_ci# option parser.
158713498266Sopenharmony_ci
158813498266Sopenharmony_ci# The usage line for option parsing errors and the start of '-h' and
158913498266Sopenharmony_ci# '--help' output messages. You can embed shell variables for delayed
159013498266Sopenharmony_ci# expansion at the time the message is displayed, but you will need to
159113498266Sopenharmony_ci# quote other shell meta-characters carefully to prevent them being
159213498266Sopenharmony_ci# expanded when the contents are evaled.
159313498266Sopenharmony_ciusage='$progpath [OPTION]...'
159413498266Sopenharmony_ci
159513498266Sopenharmony_ci# Short help message in response to '-h' and '--help'.  Add to this or
159613498266Sopenharmony_ci# override it after sourcing this library to reflect the full set of
159713498266Sopenharmony_ci# options your script accepts.
159813498266Sopenharmony_ciusage_message="\
159913498266Sopenharmony_ci       --debug        enable verbose shell tracing
160013498266Sopenharmony_ci   -W, --warnings=CATEGORY
160113498266Sopenharmony_ci                      report the warnings falling in CATEGORY [all]
160213498266Sopenharmony_ci   -v, --verbose      verbosely report processing
160313498266Sopenharmony_ci       --version      print version information and exit
160413498266Sopenharmony_ci   -h, --help         print short or long help message and exit
160513498266Sopenharmony_ci"
160613498266Sopenharmony_ci
160713498266Sopenharmony_ci# Additional text appended to 'usage_message' in response to '--help'.
160813498266Sopenharmony_cilong_help_message="
160913498266Sopenharmony_ciWarning categories include:
161013498266Sopenharmony_ci       'all'          show all warnings
161113498266Sopenharmony_ci       'none'         turn off all the warnings
161213498266Sopenharmony_ci       'error'        warnings are treated as fatal errors"
161313498266Sopenharmony_ci
161413498266Sopenharmony_ci# Help message printed before fatal option parsing errors.
161513498266Sopenharmony_cifatal_help="Try '\$progname --help' for more information."
161613498266Sopenharmony_ci
161713498266Sopenharmony_ci
161813498266Sopenharmony_ci
161913498266Sopenharmony_ci## ------------------------- ##
162013498266Sopenharmony_ci## Hook function management. ##
162113498266Sopenharmony_ci## ------------------------- ##
162213498266Sopenharmony_ci
162313498266Sopenharmony_ci# This section contains functions for adding, removing, and running hooks
162413498266Sopenharmony_ci# in the main code.  A hook is just a list of function names that can be
162513498266Sopenharmony_ci# run in order later on.
162613498266Sopenharmony_ci
162713498266Sopenharmony_ci# func_hookable FUNC_NAME
162813498266Sopenharmony_ci# -----------------------
162913498266Sopenharmony_ci# Declare that FUNC_NAME will run hooks added with
163013498266Sopenharmony_ci# 'func_add_hook FUNC_NAME ...'.
163113498266Sopenharmony_cifunc_hookable ()
163213498266Sopenharmony_ci{
163313498266Sopenharmony_ci    $debug_cmd
163413498266Sopenharmony_ci
163513498266Sopenharmony_ci    func_append hookable_fns " $1"
163613498266Sopenharmony_ci}
163713498266Sopenharmony_ci
163813498266Sopenharmony_ci
163913498266Sopenharmony_ci# func_add_hook FUNC_NAME HOOK_FUNC
164013498266Sopenharmony_ci# ---------------------------------
164113498266Sopenharmony_ci# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
164213498266Sopenharmony_ci# first have been declared "hookable" by a call to 'func_hookable'.
164313498266Sopenharmony_cifunc_add_hook ()
164413498266Sopenharmony_ci{
164513498266Sopenharmony_ci    $debug_cmd
164613498266Sopenharmony_ci
164713498266Sopenharmony_ci    case " $hookable_fns " in
164813498266Sopenharmony_ci      *" $1 "*) ;;
164913498266Sopenharmony_ci      *) func_fatal_error "'$1' does not accept hook functions." ;;
165013498266Sopenharmony_ci    esac
165113498266Sopenharmony_ci
165213498266Sopenharmony_ci    eval func_append ${1}_hooks '" $2"'
165313498266Sopenharmony_ci}
165413498266Sopenharmony_ci
165513498266Sopenharmony_ci
165613498266Sopenharmony_ci# func_remove_hook FUNC_NAME HOOK_FUNC
165713498266Sopenharmony_ci# ------------------------------------
165813498266Sopenharmony_ci# Remove HOOK_FUNC from the list of hook functions to be called by
165913498266Sopenharmony_ci# FUNC_NAME.
166013498266Sopenharmony_cifunc_remove_hook ()
166113498266Sopenharmony_ci{
166213498266Sopenharmony_ci    $debug_cmd
166313498266Sopenharmony_ci
166413498266Sopenharmony_ci    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
166513498266Sopenharmony_ci}
166613498266Sopenharmony_ci
166713498266Sopenharmony_ci
166813498266Sopenharmony_ci# func_propagate_result FUNC_NAME_A FUNC_NAME_B
166913498266Sopenharmony_ci# ---------------------------------------------
167013498266Sopenharmony_ci# If the *_result variable of FUNC_NAME_A _is set_, assign its value to
167113498266Sopenharmony_ci# *_result variable of FUNC_NAME_B.
167213498266Sopenharmony_cifunc_propagate_result ()
167313498266Sopenharmony_ci{
167413498266Sopenharmony_ci    $debug_cmd
167513498266Sopenharmony_ci
167613498266Sopenharmony_ci    func_propagate_result_result=:
167713498266Sopenharmony_ci    if eval "test \"\${${1}_result+set}\" = set"
167813498266Sopenharmony_ci    then
167913498266Sopenharmony_ci      eval "${2}_result=\$${1}_result"
168013498266Sopenharmony_ci    else
168113498266Sopenharmony_ci      func_propagate_result_result=false
168213498266Sopenharmony_ci    fi
168313498266Sopenharmony_ci}
168413498266Sopenharmony_ci
168513498266Sopenharmony_ci
168613498266Sopenharmony_ci# func_run_hooks FUNC_NAME [ARG]...
168713498266Sopenharmony_ci# ---------------------------------
168813498266Sopenharmony_ci# Run all hook functions registered to FUNC_NAME.
168913498266Sopenharmony_ci# It's assumed that the list of hook functions contains nothing more
169013498266Sopenharmony_ci# than a whitespace-delimited list of legal shell function names, and
169113498266Sopenharmony_ci# no effort is wasted trying to catch shell meta-characters or preserve
169213498266Sopenharmony_ci# whitespace.
169313498266Sopenharmony_cifunc_run_hooks ()
169413498266Sopenharmony_ci{
169513498266Sopenharmony_ci    $debug_cmd
169613498266Sopenharmony_ci
169713498266Sopenharmony_ci    _G_rc_run_hooks=false
169813498266Sopenharmony_ci
169913498266Sopenharmony_ci    case " $hookable_fns " in
170013498266Sopenharmony_ci      *" $1 "*) ;;
170113498266Sopenharmony_ci      *) func_fatal_error "'$1' does not support hook functions." ;;
170213498266Sopenharmony_ci    esac
170313498266Sopenharmony_ci
170413498266Sopenharmony_ci    eval _G_hook_fns=\$$1_hooks; shift
170513498266Sopenharmony_ci
170613498266Sopenharmony_ci    for _G_hook in $_G_hook_fns; do
170713498266Sopenharmony_ci      func_unset "${_G_hook}_result"
170813498266Sopenharmony_ci      eval $_G_hook '${1+"$@"}'
170913498266Sopenharmony_ci      func_propagate_result $_G_hook func_run_hooks
171013498266Sopenharmony_ci      if $func_propagate_result_result; then
171113498266Sopenharmony_ci        eval set dummy "$func_run_hooks_result"; shift
171213498266Sopenharmony_ci      fi
171313498266Sopenharmony_ci    done
171413498266Sopenharmony_ci}
171513498266Sopenharmony_ci
171613498266Sopenharmony_ci
171713498266Sopenharmony_ci
171813498266Sopenharmony_ci## --------------- ##
171913498266Sopenharmony_ci## Option parsing. ##
172013498266Sopenharmony_ci## --------------- ##
172113498266Sopenharmony_ci
172213498266Sopenharmony_ci# In order to add your own option parsing hooks, you must accept the
172313498266Sopenharmony_ci# full positional parameter list from your hook function.  You may remove
172413498266Sopenharmony_ci# or edit any options that you action, and then pass back the remaining
172513498266Sopenharmony_ci# unprocessed options in '<hooked_function_name>_result', escaped
172613498266Sopenharmony_ci# suitably for 'eval'.
172713498266Sopenharmony_ci#
172813498266Sopenharmony_ci# The '<hooked_function_name>_result' variable is automatically unset
172913498266Sopenharmony_ci# before your hook gets called; for best performance, only set the
173013498266Sopenharmony_ci# *_result variable when necessary (i.e. don't call the 'func_quote'
173113498266Sopenharmony_ci# function unnecessarily because it can be an expensive operation on some
173213498266Sopenharmony_ci# machines).
173313498266Sopenharmony_ci#
173413498266Sopenharmony_ci# Like this:
173513498266Sopenharmony_ci#
173613498266Sopenharmony_ci#    my_options_prep ()
173713498266Sopenharmony_ci#    {
173813498266Sopenharmony_ci#        $debug_cmd
173913498266Sopenharmony_ci#
174013498266Sopenharmony_ci#        # Extend the existing usage message.
174113498266Sopenharmony_ci#        usage_message=$usage_message'
174213498266Sopenharmony_ci#      -s, --silent       don'\''t print informational messages
174313498266Sopenharmony_ci#    '
174413498266Sopenharmony_ci#        # No change in '$@' (ignored completely by this hook).  Leave
174513498266Sopenharmony_ci#        # my_options_prep_result variable intact.
174613498266Sopenharmony_ci#    }
174713498266Sopenharmony_ci#    func_add_hook func_options_prep my_options_prep
174813498266Sopenharmony_ci#
174913498266Sopenharmony_ci#
175013498266Sopenharmony_ci#    my_silent_option ()
175113498266Sopenharmony_ci#    {
175213498266Sopenharmony_ci#        $debug_cmd
175313498266Sopenharmony_ci#
175413498266Sopenharmony_ci#        args_changed=false
175513498266Sopenharmony_ci#
175613498266Sopenharmony_ci#        # Note that, for efficiency, we parse as many options as we can
175713498266Sopenharmony_ci#        # recognise in a loop before passing the remainder back to the
175813498266Sopenharmony_ci#        # caller on the first unrecognised argument we encounter.
175913498266Sopenharmony_ci#        while test $# -gt 0; do
176013498266Sopenharmony_ci#          opt=$1; shift
176113498266Sopenharmony_ci#          case $opt in
176213498266Sopenharmony_ci#            --silent|-s) opt_silent=:
176313498266Sopenharmony_ci#                         args_changed=:
176413498266Sopenharmony_ci#                         ;;
176513498266Sopenharmony_ci#            # Separate non-argument short options:
176613498266Sopenharmony_ci#            -s*)         func_split_short_opt "$_G_opt"
176713498266Sopenharmony_ci#                         set dummy "$func_split_short_opt_name" \
176813498266Sopenharmony_ci#                             "-$func_split_short_opt_arg" ${1+"$@"}
176913498266Sopenharmony_ci#                         shift
177013498266Sopenharmony_ci#                         args_changed=:
177113498266Sopenharmony_ci#                         ;;
177213498266Sopenharmony_ci#            *)           # Make sure the first unrecognised option "$_G_opt"
177313498266Sopenharmony_ci#                         # is added back to "$@" in case we need it later,
177413498266Sopenharmony_ci#                         # if $args_changed was set to 'true'.
177513498266Sopenharmony_ci#                         set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
177613498266Sopenharmony_ci#          esac
177713498266Sopenharmony_ci#        done
177813498266Sopenharmony_ci#
177913498266Sopenharmony_ci#        # Only call 'func_quote' here if we processed at least one argument.
178013498266Sopenharmony_ci#        if $args_changed; then
178113498266Sopenharmony_ci#          func_quote eval ${1+"$@"}
178213498266Sopenharmony_ci#          my_silent_option_result=$func_quote_result
178313498266Sopenharmony_ci#        fi
178413498266Sopenharmony_ci#    }
178513498266Sopenharmony_ci#    func_add_hook func_parse_options my_silent_option
178613498266Sopenharmony_ci#
178713498266Sopenharmony_ci#
178813498266Sopenharmony_ci#    my_option_validation ()
178913498266Sopenharmony_ci#    {
179013498266Sopenharmony_ci#        $debug_cmd
179113498266Sopenharmony_ci#
179213498266Sopenharmony_ci#        $opt_silent && $opt_verbose && func_fatal_help "\
179313498266Sopenharmony_ci#    '--silent' and '--verbose' options are mutually exclusive."
179413498266Sopenharmony_ci#    }
179513498266Sopenharmony_ci#    func_add_hook func_validate_options my_option_validation
179613498266Sopenharmony_ci#
179713498266Sopenharmony_ci# You'll also need to manually amend $usage_message to reflect the extra
179813498266Sopenharmony_ci# options you parse.  It's preferable to append if you can, so that
179913498266Sopenharmony_ci# multiple option parsing hooks can be added safely.
180013498266Sopenharmony_ci
180113498266Sopenharmony_ci
180213498266Sopenharmony_ci# func_options_finish [ARG]...
180313498266Sopenharmony_ci# ----------------------------
180413498266Sopenharmony_ci# Finishing the option parse loop (call 'func_options' hooks ATM).
180513498266Sopenharmony_cifunc_options_finish ()
180613498266Sopenharmony_ci{
180713498266Sopenharmony_ci    $debug_cmd
180813498266Sopenharmony_ci
180913498266Sopenharmony_ci    func_run_hooks func_options ${1+"$@"}
181013498266Sopenharmony_ci    func_propagate_result func_run_hooks func_options_finish
181113498266Sopenharmony_ci}
181213498266Sopenharmony_ci
181313498266Sopenharmony_ci
181413498266Sopenharmony_ci# func_options [ARG]...
181513498266Sopenharmony_ci# ---------------------
181613498266Sopenharmony_ci# All the functions called inside func_options are hookable. See the
181713498266Sopenharmony_ci# individual implementations for details.
181813498266Sopenharmony_cifunc_hookable func_options
181913498266Sopenharmony_cifunc_options ()
182013498266Sopenharmony_ci{
182113498266Sopenharmony_ci    $debug_cmd
182213498266Sopenharmony_ci
182313498266Sopenharmony_ci    _G_options_quoted=false
182413498266Sopenharmony_ci
182513498266Sopenharmony_ci    for my_func in options_prep parse_options validate_options options_finish
182613498266Sopenharmony_ci    do
182713498266Sopenharmony_ci      func_unset func_${my_func}_result
182813498266Sopenharmony_ci      func_unset func_run_hooks_result
182913498266Sopenharmony_ci      eval func_$my_func '${1+"$@"}'
183013498266Sopenharmony_ci      func_propagate_result func_$my_func func_options
183113498266Sopenharmony_ci      if $func_propagate_result_result; then
183213498266Sopenharmony_ci        eval set dummy "$func_options_result"; shift
183313498266Sopenharmony_ci        _G_options_quoted=:
183413498266Sopenharmony_ci      fi
183513498266Sopenharmony_ci    done
183613498266Sopenharmony_ci
183713498266Sopenharmony_ci    $_G_options_quoted || {
183813498266Sopenharmony_ci      # As we (func_options) are top-level options-parser function and
183913498266Sopenharmony_ci      # nobody quoted "$@" for us yet, we need to do it explicitly for
184013498266Sopenharmony_ci      # caller.
184113498266Sopenharmony_ci      func_quote eval ${1+"$@"}
184213498266Sopenharmony_ci      func_options_result=$func_quote_result
184313498266Sopenharmony_ci    }
184413498266Sopenharmony_ci}
184513498266Sopenharmony_ci
184613498266Sopenharmony_ci
184713498266Sopenharmony_ci# func_options_prep [ARG]...
184813498266Sopenharmony_ci# --------------------------
184913498266Sopenharmony_ci# All initialisations required before starting the option parse loop.
185013498266Sopenharmony_ci# Note that when calling hook functions, we pass through the list of
185113498266Sopenharmony_ci# positional parameters.  If a hook function modifies that list, and
185213498266Sopenharmony_ci# needs to propagate that back to rest of this script, then the complete
185313498266Sopenharmony_ci# modified list must be put in 'func_run_hooks_result' before returning.
185413498266Sopenharmony_cifunc_hookable func_options_prep
185513498266Sopenharmony_cifunc_options_prep ()
185613498266Sopenharmony_ci{
185713498266Sopenharmony_ci    $debug_cmd
185813498266Sopenharmony_ci
185913498266Sopenharmony_ci    # Option defaults:
186013498266Sopenharmony_ci    opt_verbose=false
186113498266Sopenharmony_ci    opt_warning_types=
186213498266Sopenharmony_ci
186313498266Sopenharmony_ci    func_run_hooks func_options_prep ${1+"$@"}
186413498266Sopenharmony_ci    func_propagate_result func_run_hooks func_options_prep
186513498266Sopenharmony_ci}
186613498266Sopenharmony_ci
186713498266Sopenharmony_ci
186813498266Sopenharmony_ci# func_parse_options [ARG]...
186913498266Sopenharmony_ci# ---------------------------
187013498266Sopenharmony_ci# The main option parsing loop.
187113498266Sopenharmony_cifunc_hookable func_parse_options
187213498266Sopenharmony_cifunc_parse_options ()
187313498266Sopenharmony_ci{
187413498266Sopenharmony_ci    $debug_cmd
187513498266Sopenharmony_ci
187613498266Sopenharmony_ci    _G_parse_options_requote=false
187713498266Sopenharmony_ci    # this just eases exit handling
187813498266Sopenharmony_ci    while test $# -gt 0; do
187913498266Sopenharmony_ci      # Defer to hook functions for initial option parsing, so they
188013498266Sopenharmony_ci      # get priority in the event of reusing an option name.
188113498266Sopenharmony_ci      func_run_hooks func_parse_options ${1+"$@"}
188213498266Sopenharmony_ci      func_propagate_result func_run_hooks func_parse_options
188313498266Sopenharmony_ci      if $func_propagate_result_result; then
188413498266Sopenharmony_ci        eval set dummy "$func_parse_options_result"; shift
188513498266Sopenharmony_ci        # Even though we may have changed "$@", we passed the "$@" array
188613498266Sopenharmony_ci        # down into the hook and it quoted it for us (because we are in
188713498266Sopenharmony_ci        # this if-branch).  No need to quote it again.
188813498266Sopenharmony_ci        _G_parse_options_requote=false
188913498266Sopenharmony_ci      fi
189013498266Sopenharmony_ci
189113498266Sopenharmony_ci      # Break out of the loop if we already parsed every option.
189213498266Sopenharmony_ci      test $# -gt 0 || break
189313498266Sopenharmony_ci
189413498266Sopenharmony_ci      # We expect that one of the options parsed in this function matches
189513498266Sopenharmony_ci      # and thus we remove _G_opt from "$@" and need to re-quote.
189613498266Sopenharmony_ci      _G_match_parse_options=:
189713498266Sopenharmony_ci      _G_opt=$1
189813498266Sopenharmony_ci      shift
189913498266Sopenharmony_ci      case $_G_opt in
190013498266Sopenharmony_ci        --debug|-x)   debug_cmd='set -x'
190113498266Sopenharmony_ci                      func_echo "enabling shell trace mode" >&2
190213498266Sopenharmony_ci                      $debug_cmd
190313498266Sopenharmony_ci                      ;;
190413498266Sopenharmony_ci
190513498266Sopenharmony_ci        --no-warnings|--no-warning|--no-warn)
190613498266Sopenharmony_ci                      set dummy --warnings none ${1+"$@"}
190713498266Sopenharmony_ci                      shift
190813498266Sopenharmony_ci		      ;;
190913498266Sopenharmony_ci
191013498266Sopenharmony_ci        --warnings|--warning|-W)
191113498266Sopenharmony_ci                      if test $# = 0 && func_missing_arg $_G_opt; then
191213498266Sopenharmony_ci                        _G_parse_options_requote=:
191313498266Sopenharmony_ci                        break
191413498266Sopenharmony_ci                      fi
191513498266Sopenharmony_ci                      case " $warning_categories $1" in
191613498266Sopenharmony_ci                        *" $1 "*)
191713498266Sopenharmony_ci                          # trailing space prevents matching last $1 above
191813498266Sopenharmony_ci                          func_append_uniq opt_warning_types " $1"
191913498266Sopenharmony_ci                          ;;
192013498266Sopenharmony_ci                        *all)
192113498266Sopenharmony_ci                          opt_warning_types=$warning_categories
192213498266Sopenharmony_ci                          ;;
192313498266Sopenharmony_ci                        *none)
192413498266Sopenharmony_ci                          opt_warning_types=none
192513498266Sopenharmony_ci                          warning_func=:
192613498266Sopenharmony_ci                          ;;
192713498266Sopenharmony_ci                        *error)
192813498266Sopenharmony_ci                          opt_warning_types=$warning_categories
192913498266Sopenharmony_ci                          warning_func=func_fatal_error
193013498266Sopenharmony_ci                          ;;
193113498266Sopenharmony_ci                        *)
193213498266Sopenharmony_ci                          func_fatal_error \
193313498266Sopenharmony_ci                             "unsupported warning category: '$1'"
193413498266Sopenharmony_ci                          ;;
193513498266Sopenharmony_ci                      esac
193613498266Sopenharmony_ci                      shift
193713498266Sopenharmony_ci                      ;;
193813498266Sopenharmony_ci
193913498266Sopenharmony_ci        --verbose|-v) opt_verbose=: ;;
194013498266Sopenharmony_ci        --version)    func_version ;;
194113498266Sopenharmony_ci        -\?|-h)       func_usage ;;
194213498266Sopenharmony_ci        --help)       func_help ;;
194313498266Sopenharmony_ci
194413498266Sopenharmony_ci	# Separate optargs to long options (plugins may need this):
194513498266Sopenharmony_ci	--*=*)        func_split_equals "$_G_opt"
194613498266Sopenharmony_ci	              set dummy "$func_split_equals_lhs" \
194713498266Sopenharmony_ci                          "$func_split_equals_rhs" ${1+"$@"}
194813498266Sopenharmony_ci                      shift
194913498266Sopenharmony_ci                      ;;
195013498266Sopenharmony_ci
195113498266Sopenharmony_ci       # Separate optargs to short options:
195213498266Sopenharmony_ci        -W*)
195313498266Sopenharmony_ci                      func_split_short_opt "$_G_opt"
195413498266Sopenharmony_ci                      set dummy "$func_split_short_opt_name" \
195513498266Sopenharmony_ci                          "$func_split_short_opt_arg" ${1+"$@"}
195613498266Sopenharmony_ci                      shift
195713498266Sopenharmony_ci                      ;;
195813498266Sopenharmony_ci
195913498266Sopenharmony_ci        # Separate non-argument short options:
196013498266Sopenharmony_ci        -\?*|-h*|-v*|-x*)
196113498266Sopenharmony_ci                      func_split_short_opt "$_G_opt"
196213498266Sopenharmony_ci                      set dummy "$func_split_short_opt_name" \
196313498266Sopenharmony_ci                          "-$func_split_short_opt_arg" ${1+"$@"}
196413498266Sopenharmony_ci                      shift
196513498266Sopenharmony_ci                      ;;
196613498266Sopenharmony_ci
196713498266Sopenharmony_ci        --)           _G_parse_options_requote=: ; break ;;
196813498266Sopenharmony_ci        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
196913498266Sopenharmony_ci        *)            set dummy "$_G_opt" ${1+"$@"}; shift
197013498266Sopenharmony_ci                      _G_match_parse_options=false
197113498266Sopenharmony_ci                      break
197213498266Sopenharmony_ci                      ;;
197313498266Sopenharmony_ci      esac
197413498266Sopenharmony_ci
197513498266Sopenharmony_ci      if $_G_match_parse_options; then
197613498266Sopenharmony_ci        _G_parse_options_requote=:
197713498266Sopenharmony_ci      fi
197813498266Sopenharmony_ci    done
197913498266Sopenharmony_ci
198013498266Sopenharmony_ci    if $_G_parse_options_requote; then
198113498266Sopenharmony_ci      # save modified positional parameters for caller
198213498266Sopenharmony_ci      func_quote eval ${1+"$@"}
198313498266Sopenharmony_ci      func_parse_options_result=$func_quote_result
198413498266Sopenharmony_ci    fi
198513498266Sopenharmony_ci}
198613498266Sopenharmony_ci
198713498266Sopenharmony_ci
198813498266Sopenharmony_ci# func_validate_options [ARG]...
198913498266Sopenharmony_ci# ------------------------------
199013498266Sopenharmony_ci# Perform any sanity checks on option settings and/or unconsumed
199113498266Sopenharmony_ci# arguments.
199213498266Sopenharmony_cifunc_hookable func_validate_options
199313498266Sopenharmony_cifunc_validate_options ()
199413498266Sopenharmony_ci{
199513498266Sopenharmony_ci    $debug_cmd
199613498266Sopenharmony_ci
199713498266Sopenharmony_ci    # Display all warnings if -W was not given.
199813498266Sopenharmony_ci    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
199913498266Sopenharmony_ci
200013498266Sopenharmony_ci    func_run_hooks func_validate_options ${1+"$@"}
200113498266Sopenharmony_ci    func_propagate_result func_run_hooks func_validate_options
200213498266Sopenharmony_ci
200313498266Sopenharmony_ci    # Bail if the options were screwed!
200413498266Sopenharmony_ci    $exit_cmd $EXIT_FAILURE
200513498266Sopenharmony_ci}
200613498266Sopenharmony_ci
200713498266Sopenharmony_ci
200813498266Sopenharmony_ci
200913498266Sopenharmony_ci## ----------------- ##
201013498266Sopenharmony_ci## Helper functions. ##
201113498266Sopenharmony_ci## ----------------- ##
201213498266Sopenharmony_ci
201313498266Sopenharmony_ci# This section contains the helper functions used by the rest of the
201413498266Sopenharmony_ci# hookable option parser framework in ascii-betical order.
201513498266Sopenharmony_ci
201613498266Sopenharmony_ci
201713498266Sopenharmony_ci# func_fatal_help ARG...
201813498266Sopenharmony_ci# ----------------------
201913498266Sopenharmony_ci# Echo program name prefixed message to standard error, followed by
202013498266Sopenharmony_ci# a help hint, and exit.
202113498266Sopenharmony_cifunc_fatal_help ()
202213498266Sopenharmony_ci{
202313498266Sopenharmony_ci    $debug_cmd
202413498266Sopenharmony_ci
202513498266Sopenharmony_ci    eval \$ECHO \""Usage: $usage"\"
202613498266Sopenharmony_ci    eval \$ECHO \""$fatal_help"\"
202713498266Sopenharmony_ci    func_error ${1+"$@"}
202813498266Sopenharmony_ci    exit $EXIT_FAILURE
202913498266Sopenharmony_ci}
203013498266Sopenharmony_ci
203113498266Sopenharmony_ci
203213498266Sopenharmony_ci# func_help
203313498266Sopenharmony_ci# ---------
203413498266Sopenharmony_ci# Echo long help message to standard output and exit.
203513498266Sopenharmony_cifunc_help ()
203613498266Sopenharmony_ci{
203713498266Sopenharmony_ci    $debug_cmd
203813498266Sopenharmony_ci
203913498266Sopenharmony_ci    func_usage_message
204013498266Sopenharmony_ci    $ECHO "$long_help_message"
204113498266Sopenharmony_ci    exit 0
204213498266Sopenharmony_ci}
204313498266Sopenharmony_ci
204413498266Sopenharmony_ci
204513498266Sopenharmony_ci# func_missing_arg ARGNAME
204613498266Sopenharmony_ci# ------------------------
204713498266Sopenharmony_ci# Echo program name prefixed message to standard error and set global
204813498266Sopenharmony_ci# exit_cmd.
204913498266Sopenharmony_cifunc_missing_arg ()
205013498266Sopenharmony_ci{
205113498266Sopenharmony_ci    $debug_cmd
205213498266Sopenharmony_ci
205313498266Sopenharmony_ci    func_error "Missing argument for '$1'."
205413498266Sopenharmony_ci    exit_cmd=exit
205513498266Sopenharmony_ci}
205613498266Sopenharmony_ci
205713498266Sopenharmony_ci
205813498266Sopenharmony_ci# func_split_equals STRING
205913498266Sopenharmony_ci# ------------------------
206013498266Sopenharmony_ci# Set func_split_equals_lhs and func_split_equals_rhs shell variables
206113498266Sopenharmony_ci# after splitting STRING at the '=' sign.
206213498266Sopenharmony_citest -z "$_G_HAVE_XSI_OPS" \
206313498266Sopenharmony_ci    && (eval 'x=a/b/c;
206413498266Sopenharmony_ci      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
206513498266Sopenharmony_ci    && _G_HAVE_XSI_OPS=yes
206613498266Sopenharmony_ci
206713498266Sopenharmony_ciif test yes = "$_G_HAVE_XSI_OPS"
206813498266Sopenharmony_cithen
206913498266Sopenharmony_ci  # This is an XSI compatible shell, allowing a faster implementation...
207013498266Sopenharmony_ci  eval 'func_split_equals ()
207113498266Sopenharmony_ci  {
207213498266Sopenharmony_ci      $debug_cmd
207313498266Sopenharmony_ci
207413498266Sopenharmony_ci      func_split_equals_lhs=${1%%=*}
207513498266Sopenharmony_ci      func_split_equals_rhs=${1#*=}
207613498266Sopenharmony_ci      if test "x$func_split_equals_lhs" = "x$1"; then
207713498266Sopenharmony_ci        func_split_equals_rhs=
207813498266Sopenharmony_ci      fi
207913498266Sopenharmony_ci  }'
208013498266Sopenharmony_cielse
208113498266Sopenharmony_ci  # ...otherwise fall back to using expr, which is often a shell builtin.
208213498266Sopenharmony_ci  func_split_equals ()
208313498266Sopenharmony_ci  {
208413498266Sopenharmony_ci      $debug_cmd
208513498266Sopenharmony_ci
208613498266Sopenharmony_ci      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
208713498266Sopenharmony_ci      func_split_equals_rhs=
208813498266Sopenharmony_ci      test "x$func_split_equals_lhs=" = "x$1" \
208913498266Sopenharmony_ci        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
209013498266Sopenharmony_ci  }
209113498266Sopenharmony_cifi #func_split_equals
209213498266Sopenharmony_ci
209313498266Sopenharmony_ci
209413498266Sopenharmony_ci# func_split_short_opt SHORTOPT
209513498266Sopenharmony_ci# -----------------------------
209613498266Sopenharmony_ci# Set func_split_short_opt_name and func_split_short_opt_arg shell
209713498266Sopenharmony_ci# variables after splitting SHORTOPT after the 2nd character.
209813498266Sopenharmony_ciif test yes = "$_G_HAVE_XSI_OPS"
209913498266Sopenharmony_cithen
210013498266Sopenharmony_ci  # This is an XSI compatible shell, allowing a faster implementation...
210113498266Sopenharmony_ci  eval 'func_split_short_opt ()
210213498266Sopenharmony_ci  {
210313498266Sopenharmony_ci      $debug_cmd
210413498266Sopenharmony_ci
210513498266Sopenharmony_ci      func_split_short_opt_arg=${1#??}
210613498266Sopenharmony_ci      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
210713498266Sopenharmony_ci  }'
210813498266Sopenharmony_cielse
210913498266Sopenharmony_ci  # ...otherwise fall back to using expr, which is often a shell builtin.
211013498266Sopenharmony_ci  func_split_short_opt ()
211113498266Sopenharmony_ci  {
211213498266Sopenharmony_ci      $debug_cmd
211313498266Sopenharmony_ci
211413498266Sopenharmony_ci      func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'`
211513498266Sopenharmony_ci      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
211613498266Sopenharmony_ci  }
211713498266Sopenharmony_cifi #func_split_short_opt
211813498266Sopenharmony_ci
211913498266Sopenharmony_ci
212013498266Sopenharmony_ci# func_usage
212113498266Sopenharmony_ci# ----------
212213498266Sopenharmony_ci# Echo short help message to standard output and exit.
212313498266Sopenharmony_cifunc_usage ()
212413498266Sopenharmony_ci{
212513498266Sopenharmony_ci    $debug_cmd
212613498266Sopenharmony_ci
212713498266Sopenharmony_ci    func_usage_message
212813498266Sopenharmony_ci    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
212913498266Sopenharmony_ci    exit 0
213013498266Sopenharmony_ci}
213113498266Sopenharmony_ci
213213498266Sopenharmony_ci
213313498266Sopenharmony_ci# func_usage_message
213413498266Sopenharmony_ci# ------------------
213513498266Sopenharmony_ci# Echo short help message to standard output.
213613498266Sopenharmony_cifunc_usage_message ()
213713498266Sopenharmony_ci{
213813498266Sopenharmony_ci    $debug_cmd
213913498266Sopenharmony_ci
214013498266Sopenharmony_ci    eval \$ECHO \""Usage: $usage"\"
214113498266Sopenharmony_ci    echo
214213498266Sopenharmony_ci    $SED -n 's|^# ||
214313498266Sopenharmony_ci        /^Written by/{
214413498266Sopenharmony_ci          x;p;x
214513498266Sopenharmony_ci        }
214613498266Sopenharmony_ci	h
214713498266Sopenharmony_ci	/^Written by/q' < "$progpath"
214813498266Sopenharmony_ci    echo
214913498266Sopenharmony_ci    eval \$ECHO \""$usage_message"\"
215013498266Sopenharmony_ci}
215113498266Sopenharmony_ci
215213498266Sopenharmony_ci
215313498266Sopenharmony_ci# func_version
215413498266Sopenharmony_ci# ------------
215513498266Sopenharmony_ci# Echo version message to standard output and exit.
215613498266Sopenharmony_ci# The version message is extracted from the calling file's header
215713498266Sopenharmony_ci# comments, with leading '# ' stripped:
215813498266Sopenharmony_ci#   1. First display the progname and version
215913498266Sopenharmony_ci#   2. Followed by the header comment line matching  /^# Written by /
216013498266Sopenharmony_ci#   3. Then a blank line followed by the first following line matching
216113498266Sopenharmony_ci#      /^# Copyright /
216213498266Sopenharmony_ci#   4. Immediately followed by any lines between the previous matches,
216313498266Sopenharmony_ci#      except lines preceding the intervening completely blank line.
216413498266Sopenharmony_ci# For example, see the header comments of this file.
216513498266Sopenharmony_cifunc_version ()
216613498266Sopenharmony_ci{
216713498266Sopenharmony_ci    $debug_cmd
216813498266Sopenharmony_ci
216913498266Sopenharmony_ci    printf '%s\n' "$progname $scriptversion"
217013498266Sopenharmony_ci    $SED -n '
217113498266Sopenharmony_ci        /^# Written by /!b
217213498266Sopenharmony_ci        s|^# ||; p; n
217313498266Sopenharmony_ci
217413498266Sopenharmony_ci        :fwd2blnk
217513498266Sopenharmony_ci        /./ {
217613498266Sopenharmony_ci          n
217713498266Sopenharmony_ci          b fwd2blnk
217813498266Sopenharmony_ci        }
217913498266Sopenharmony_ci        p; n
218013498266Sopenharmony_ci
218113498266Sopenharmony_ci        :holdwrnt
218213498266Sopenharmony_ci        s|^# ||
218313498266Sopenharmony_ci        s|^# *$||
218413498266Sopenharmony_ci        /^Copyright /!{
218513498266Sopenharmony_ci          /./H
218613498266Sopenharmony_ci          n
218713498266Sopenharmony_ci          b holdwrnt
218813498266Sopenharmony_ci        }
218913498266Sopenharmony_ci
219013498266Sopenharmony_ci        s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
219113498266Sopenharmony_ci        G
219213498266Sopenharmony_ci        s|\(\n\)\n*|\1|g
219313498266Sopenharmony_ci        p; q' < "$progpath"
219413498266Sopenharmony_ci
219513498266Sopenharmony_ci    exit $?
219613498266Sopenharmony_ci}
219713498266Sopenharmony_ci
219813498266Sopenharmony_ci
219913498266Sopenharmony_ci# Local variables:
220013498266Sopenharmony_ci# mode: shell-script
220113498266Sopenharmony_ci# sh-indentation: 2
220213498266Sopenharmony_ci# eval: (add-hook 'before-save-hook 'time-stamp)
220313498266Sopenharmony_ci# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC"
220413498266Sopenharmony_ci# time-stamp-time-zone: "UTC"
220513498266Sopenharmony_ci# End:
220613498266Sopenharmony_ci
220713498266Sopenharmony_ci# Set a version string.
220813498266Sopenharmony_ciscriptversion='(GNU libtool) 2.4.7'
220913498266Sopenharmony_ci
221013498266Sopenharmony_ci
221113498266Sopenharmony_ci# func_echo ARG...
221213498266Sopenharmony_ci# ----------------
221313498266Sopenharmony_ci# Libtool also displays the current mode in messages, so override
221413498266Sopenharmony_ci# funclib.sh func_echo with this custom definition.
221513498266Sopenharmony_cifunc_echo ()
221613498266Sopenharmony_ci{
221713498266Sopenharmony_ci    $debug_cmd
221813498266Sopenharmony_ci
221913498266Sopenharmony_ci    _G_message=$*
222013498266Sopenharmony_ci
222113498266Sopenharmony_ci    func_echo_IFS=$IFS
222213498266Sopenharmony_ci    IFS=$nl
222313498266Sopenharmony_ci    for _G_line in $_G_message; do
222413498266Sopenharmony_ci      IFS=$func_echo_IFS
222513498266Sopenharmony_ci      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
222613498266Sopenharmony_ci    done
222713498266Sopenharmony_ci    IFS=$func_echo_IFS
222813498266Sopenharmony_ci}
222913498266Sopenharmony_ci
223013498266Sopenharmony_ci
223113498266Sopenharmony_ci# func_warning ARG...
223213498266Sopenharmony_ci# -------------------
223313498266Sopenharmony_ci# Libtool warnings are not categorized, so override funclib.sh
223413498266Sopenharmony_ci# func_warning with this simpler definition.
223513498266Sopenharmony_cifunc_warning ()
223613498266Sopenharmony_ci{
223713498266Sopenharmony_ci    $debug_cmd
223813498266Sopenharmony_ci
223913498266Sopenharmony_ci    $warning_func ${1+"$@"}
224013498266Sopenharmony_ci}
224113498266Sopenharmony_ci
224213498266Sopenharmony_ci
224313498266Sopenharmony_ci## ---------------- ##
224413498266Sopenharmony_ci## Options parsing. ##
224513498266Sopenharmony_ci## ---------------- ##
224613498266Sopenharmony_ci
224713498266Sopenharmony_ci# Hook in the functions to make sure our own options are parsed during
224813498266Sopenharmony_ci# the option parsing loop.
224913498266Sopenharmony_ci
225013498266Sopenharmony_ciusage='$progpath [OPTION]... [MODE-ARG]...'
225113498266Sopenharmony_ci
225213498266Sopenharmony_ci# Short help message in response to '-h'.
225313498266Sopenharmony_ciusage_message="Options:
225413498266Sopenharmony_ci       --config             show all configuration variables
225513498266Sopenharmony_ci       --debug              enable verbose shell tracing
225613498266Sopenharmony_ci   -n, --dry-run            display commands without modifying any files
225713498266Sopenharmony_ci       --features           display basic configuration information and exit
225813498266Sopenharmony_ci       --mode=MODE          use operation mode MODE
225913498266Sopenharmony_ci       --no-warnings        equivalent to '-Wnone'
226013498266Sopenharmony_ci       --preserve-dup-deps  don't remove duplicate dependency libraries
226113498266Sopenharmony_ci       --quiet, --silent    don't print informational messages
226213498266Sopenharmony_ci       --tag=TAG            use configuration variables from tag TAG
226313498266Sopenharmony_ci   -v, --verbose            print more informational messages than default
226413498266Sopenharmony_ci       --version            print version information
226513498266Sopenharmony_ci   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
226613498266Sopenharmony_ci   -h, --help, --help-all   print short, long, or detailed help message
226713498266Sopenharmony_ci"
226813498266Sopenharmony_ci
226913498266Sopenharmony_ci# Additional text appended to 'usage_message' in response to '--help'.
227013498266Sopenharmony_cifunc_help ()
227113498266Sopenharmony_ci{
227213498266Sopenharmony_ci    $debug_cmd
227313498266Sopenharmony_ci
227413498266Sopenharmony_ci    func_usage_message
227513498266Sopenharmony_ci    $ECHO "$long_help_message
227613498266Sopenharmony_ci
227713498266Sopenharmony_ciMODE must be one of the following:
227813498266Sopenharmony_ci
227913498266Sopenharmony_ci       clean           remove files from the build directory
228013498266Sopenharmony_ci       compile         compile a source file into a libtool object
228113498266Sopenharmony_ci       execute         automatically set library path, then run a program
228213498266Sopenharmony_ci       finish          complete the installation of libtool libraries
228313498266Sopenharmony_ci       install         install libraries or executables
228413498266Sopenharmony_ci       link            create a library or an executable
228513498266Sopenharmony_ci       uninstall       remove libraries from an installed directory
228613498266Sopenharmony_ci
228713498266Sopenharmony_ciMODE-ARGS vary depending on the MODE.  When passed as first option,
228813498266Sopenharmony_ci'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
228913498266Sopenharmony_ciTry '$progname --help --mode=MODE' for a more detailed description of MODE.
229013498266Sopenharmony_ci
229113498266Sopenharmony_ciWhen reporting a bug, please describe a test case to reproduce it and
229213498266Sopenharmony_ciinclude the following information:
229313498266Sopenharmony_ci
229413498266Sopenharmony_ci       host-triplet:   $host
229513498266Sopenharmony_ci       shell:          $SHELL
229613498266Sopenharmony_ci       compiler:       $LTCC
229713498266Sopenharmony_ci       compiler flags: $LTCFLAGS
229813498266Sopenharmony_ci       linker:         $LD (gnu? $with_gnu_ld)
229913498266Sopenharmony_ci       version:        $progname $scriptversion Debian-2.4.7-7
230013498266Sopenharmony_ci       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
230113498266Sopenharmony_ci       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
230213498266Sopenharmony_ci
230313498266Sopenharmony_ciReport bugs to <bug-libtool@gnu.org>.
230413498266Sopenharmony_ciGNU libtool home page: <http://www.gnu.org/s/libtool/>.
230513498266Sopenharmony_ciGeneral help using GNU software: <http://www.gnu.org/gethelp/>."
230613498266Sopenharmony_ci    exit 0
230713498266Sopenharmony_ci}
230813498266Sopenharmony_ci
230913498266Sopenharmony_ci
231013498266Sopenharmony_ci# func_lo2o OBJECT-NAME
231113498266Sopenharmony_ci# ---------------------
231213498266Sopenharmony_ci# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
231313498266Sopenharmony_ci# object suffix.
231413498266Sopenharmony_ci
231513498266Sopenharmony_cilo2o=s/\\.lo\$/.$objext/
231613498266Sopenharmony_cio2lo=s/\\.$objext\$/.lo/
231713498266Sopenharmony_ci
231813498266Sopenharmony_ciif test yes = "$_G_HAVE_XSI_OPS"; then
231913498266Sopenharmony_ci  eval 'func_lo2o ()
232013498266Sopenharmony_ci  {
232113498266Sopenharmony_ci    case $1 in
232213498266Sopenharmony_ci      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
232313498266Sopenharmony_ci      *   ) func_lo2o_result=$1               ;;
232413498266Sopenharmony_ci    esac
232513498266Sopenharmony_ci  }'
232613498266Sopenharmony_ci
232713498266Sopenharmony_ci  # func_xform LIBOBJ-OR-SOURCE
232813498266Sopenharmony_ci  # ---------------------------
232913498266Sopenharmony_ci  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
233013498266Sopenharmony_ci  # suffix to a '.lo' libtool-object suffix.
233113498266Sopenharmony_ci  eval 'func_xform ()
233213498266Sopenharmony_ci  {
233313498266Sopenharmony_ci    func_xform_result=${1%.*}.lo
233413498266Sopenharmony_ci  }'
233513498266Sopenharmony_cielse
233613498266Sopenharmony_ci  # ...otherwise fall back to using sed.
233713498266Sopenharmony_ci  func_lo2o ()
233813498266Sopenharmony_ci  {
233913498266Sopenharmony_ci    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
234013498266Sopenharmony_ci  }
234113498266Sopenharmony_ci
234213498266Sopenharmony_ci  func_xform ()
234313498266Sopenharmony_ci  {
234413498266Sopenharmony_ci    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
234513498266Sopenharmony_ci  }
234613498266Sopenharmony_cifi
234713498266Sopenharmony_ci
234813498266Sopenharmony_ci
234913498266Sopenharmony_ci# func_fatal_configuration ARG...
235013498266Sopenharmony_ci# -------------------------------
235113498266Sopenharmony_ci# Echo program name prefixed message to standard error, followed by
235213498266Sopenharmony_ci# a configuration failure hint, and exit.
235313498266Sopenharmony_cifunc_fatal_configuration ()
235413498266Sopenharmony_ci{
235513498266Sopenharmony_ci    func_fatal_error ${1+"$@"} \
235613498266Sopenharmony_ci      "See the $PACKAGE documentation for more information." \
235713498266Sopenharmony_ci      "Fatal configuration error."
235813498266Sopenharmony_ci}
235913498266Sopenharmony_ci
236013498266Sopenharmony_ci
236113498266Sopenharmony_ci# func_config
236213498266Sopenharmony_ci# -----------
236313498266Sopenharmony_ci# Display the configuration for all the tags in this script.
236413498266Sopenharmony_cifunc_config ()
236513498266Sopenharmony_ci{
236613498266Sopenharmony_ci    re_begincf='^# ### BEGIN LIBTOOL'
236713498266Sopenharmony_ci    re_endcf='^# ### END LIBTOOL'
236813498266Sopenharmony_ci
236913498266Sopenharmony_ci    # Default configuration.
237013498266Sopenharmony_ci    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
237113498266Sopenharmony_ci
237213498266Sopenharmony_ci    # Now print the configurations for the tags.
237313498266Sopenharmony_ci    for tagname in $taglist; do
237413498266Sopenharmony_ci      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
237513498266Sopenharmony_ci    done
237613498266Sopenharmony_ci
237713498266Sopenharmony_ci    exit $?
237813498266Sopenharmony_ci}
237913498266Sopenharmony_ci
238013498266Sopenharmony_ci
238113498266Sopenharmony_ci# func_features
238213498266Sopenharmony_ci# -------------
238313498266Sopenharmony_ci# Display the features supported by this script.
238413498266Sopenharmony_cifunc_features ()
238513498266Sopenharmony_ci{
238613498266Sopenharmony_ci    echo "host: $host"
238713498266Sopenharmony_ci    if test yes = "$build_libtool_libs"; then
238813498266Sopenharmony_ci      echo "enable shared libraries"
238913498266Sopenharmony_ci    else
239013498266Sopenharmony_ci      echo "disable shared libraries"
239113498266Sopenharmony_ci    fi
239213498266Sopenharmony_ci    if test yes = "$build_old_libs"; then
239313498266Sopenharmony_ci      echo "enable static libraries"
239413498266Sopenharmony_ci    else
239513498266Sopenharmony_ci      echo "disable static libraries"
239613498266Sopenharmony_ci    fi
239713498266Sopenharmony_ci
239813498266Sopenharmony_ci    exit $?
239913498266Sopenharmony_ci}
240013498266Sopenharmony_ci
240113498266Sopenharmony_ci
240213498266Sopenharmony_ci# func_enable_tag TAGNAME
240313498266Sopenharmony_ci# -----------------------
240413498266Sopenharmony_ci# Verify that TAGNAME is valid, and either flag an error and exit, or
240513498266Sopenharmony_ci# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
240613498266Sopenharmony_ci# variable here.
240713498266Sopenharmony_cifunc_enable_tag ()
240813498266Sopenharmony_ci{
240913498266Sopenharmony_ci    # Global variable:
241013498266Sopenharmony_ci    tagname=$1
241113498266Sopenharmony_ci
241213498266Sopenharmony_ci    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
241313498266Sopenharmony_ci    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
241413498266Sopenharmony_ci    sed_extractcf=/$re_begincf/,/$re_endcf/p
241513498266Sopenharmony_ci
241613498266Sopenharmony_ci    # Validate tagname.
241713498266Sopenharmony_ci    case $tagname in
241813498266Sopenharmony_ci      *[!-_A-Za-z0-9,/]*)
241913498266Sopenharmony_ci        func_fatal_error "invalid tag name: $tagname"
242013498266Sopenharmony_ci        ;;
242113498266Sopenharmony_ci    esac
242213498266Sopenharmony_ci
242313498266Sopenharmony_ci    # Don't test for the "default" C tag, as we know it's
242413498266Sopenharmony_ci    # there but not specially marked.
242513498266Sopenharmony_ci    case $tagname in
242613498266Sopenharmony_ci        CC) ;;
242713498266Sopenharmony_ci    *)
242813498266Sopenharmony_ci        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
242913498266Sopenharmony_ci	  taglist="$taglist $tagname"
243013498266Sopenharmony_ci
243113498266Sopenharmony_ci	  # Evaluate the configuration.  Be careful to quote the path
243213498266Sopenharmony_ci	  # and the sed script, to avoid splitting on whitespace, but
243313498266Sopenharmony_ci	  # also don't use non-portable quotes within backquotes within
243413498266Sopenharmony_ci	  # quotes we have to do it in 2 steps:
243513498266Sopenharmony_ci	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
243613498266Sopenharmony_ci	  eval "$extractedcf"
243713498266Sopenharmony_ci        else
243813498266Sopenharmony_ci	  func_error "ignoring unknown tag $tagname"
243913498266Sopenharmony_ci        fi
244013498266Sopenharmony_ci        ;;
244113498266Sopenharmony_ci    esac
244213498266Sopenharmony_ci}
244313498266Sopenharmony_ci
244413498266Sopenharmony_ci
244513498266Sopenharmony_ci# func_check_version_match
244613498266Sopenharmony_ci# ------------------------
244713498266Sopenharmony_ci# Ensure that we are using m4 macros, and libtool script from the same
244813498266Sopenharmony_ci# release of libtool.
244913498266Sopenharmony_cifunc_check_version_match ()
245013498266Sopenharmony_ci{
245113498266Sopenharmony_ci    if test "$package_revision" != "$macro_revision"; then
245213498266Sopenharmony_ci      if test "$VERSION" != "$macro_version"; then
245313498266Sopenharmony_ci        if test -z "$macro_version"; then
245413498266Sopenharmony_ci          cat >&2 <<_LT_EOF
245513498266Sopenharmony_ci$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
245613498266Sopenharmony_ci$progname: definition of this LT_INIT comes from an older release.
245713498266Sopenharmony_ci$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
245813498266Sopenharmony_ci$progname: and run autoconf again.
245913498266Sopenharmony_ci_LT_EOF
246013498266Sopenharmony_ci        else
246113498266Sopenharmony_ci          cat >&2 <<_LT_EOF
246213498266Sopenharmony_ci$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
246313498266Sopenharmony_ci$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
246413498266Sopenharmony_ci$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
246513498266Sopenharmony_ci$progname: and run autoconf again.
246613498266Sopenharmony_ci_LT_EOF
246713498266Sopenharmony_ci        fi
246813498266Sopenharmony_ci      else
246913498266Sopenharmony_ci        cat >&2 <<_LT_EOF
247013498266Sopenharmony_ci$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
247113498266Sopenharmony_ci$progname: but the definition of this LT_INIT comes from revision $macro_revision.
247213498266Sopenharmony_ci$progname: You should recreate aclocal.m4 with macros from revision $package_revision
247313498266Sopenharmony_ci$progname: of $PACKAGE $VERSION and run autoconf again.
247413498266Sopenharmony_ci_LT_EOF
247513498266Sopenharmony_ci      fi
247613498266Sopenharmony_ci
247713498266Sopenharmony_ci      exit $EXIT_MISMATCH
247813498266Sopenharmony_ci    fi
247913498266Sopenharmony_ci}
248013498266Sopenharmony_ci
248113498266Sopenharmony_ci
248213498266Sopenharmony_ci# libtool_options_prep [ARG]...
248313498266Sopenharmony_ci# -----------------------------
248413498266Sopenharmony_ci# Preparation for options parsed by libtool.
248513498266Sopenharmony_cilibtool_options_prep ()
248613498266Sopenharmony_ci{
248713498266Sopenharmony_ci    $debug_mode
248813498266Sopenharmony_ci
248913498266Sopenharmony_ci    # Option defaults:
249013498266Sopenharmony_ci    opt_config=false
249113498266Sopenharmony_ci    opt_dlopen=
249213498266Sopenharmony_ci    opt_dry_run=false
249313498266Sopenharmony_ci    opt_help=false
249413498266Sopenharmony_ci    opt_mode=
249513498266Sopenharmony_ci    opt_preserve_dup_deps=false
249613498266Sopenharmony_ci    opt_quiet=false
249713498266Sopenharmony_ci
249813498266Sopenharmony_ci    nonopt=
249913498266Sopenharmony_ci    preserve_args=
250013498266Sopenharmony_ci
250113498266Sopenharmony_ci    _G_rc_lt_options_prep=:
250213498266Sopenharmony_ci
250313498266Sopenharmony_ci    _G_rc_lt_options_prep=:
250413498266Sopenharmony_ci
250513498266Sopenharmony_ci    # Shorthand for --mode=foo, only valid as the first argument
250613498266Sopenharmony_ci    case $1 in
250713498266Sopenharmony_ci    clean|clea|cle|cl)
250813498266Sopenharmony_ci      shift; set dummy --mode clean ${1+"$@"}; shift
250913498266Sopenharmony_ci      ;;
251013498266Sopenharmony_ci    compile|compil|compi|comp|com|co|c)
251113498266Sopenharmony_ci      shift; set dummy --mode compile ${1+"$@"}; shift
251213498266Sopenharmony_ci      ;;
251313498266Sopenharmony_ci    execute|execut|execu|exec|exe|ex|e)
251413498266Sopenharmony_ci      shift; set dummy --mode execute ${1+"$@"}; shift
251513498266Sopenharmony_ci      ;;
251613498266Sopenharmony_ci    finish|finis|fini|fin|fi|f)
251713498266Sopenharmony_ci      shift; set dummy --mode finish ${1+"$@"}; shift
251813498266Sopenharmony_ci      ;;
251913498266Sopenharmony_ci    install|instal|insta|inst|ins|in|i)
252013498266Sopenharmony_ci      shift; set dummy --mode install ${1+"$@"}; shift
252113498266Sopenharmony_ci      ;;
252213498266Sopenharmony_ci    link|lin|li|l)
252313498266Sopenharmony_ci      shift; set dummy --mode link ${1+"$@"}; shift
252413498266Sopenharmony_ci      ;;
252513498266Sopenharmony_ci    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
252613498266Sopenharmony_ci      shift; set dummy --mode uninstall ${1+"$@"}; shift
252713498266Sopenharmony_ci      ;;
252813498266Sopenharmony_ci    *)
252913498266Sopenharmony_ci      _G_rc_lt_options_prep=false
253013498266Sopenharmony_ci      ;;
253113498266Sopenharmony_ci    esac
253213498266Sopenharmony_ci
253313498266Sopenharmony_ci    if $_G_rc_lt_options_prep; then
253413498266Sopenharmony_ci      # Pass back the list of options.
253513498266Sopenharmony_ci      func_quote eval ${1+"$@"}
253613498266Sopenharmony_ci      libtool_options_prep_result=$func_quote_result
253713498266Sopenharmony_ci    fi
253813498266Sopenharmony_ci}
253913498266Sopenharmony_cifunc_add_hook func_options_prep libtool_options_prep
254013498266Sopenharmony_ci
254113498266Sopenharmony_ci
254213498266Sopenharmony_ci# libtool_parse_options [ARG]...
254313498266Sopenharmony_ci# ---------------------------------
254413498266Sopenharmony_ci# Provide handling for libtool specific options.
254513498266Sopenharmony_cilibtool_parse_options ()
254613498266Sopenharmony_ci{
254713498266Sopenharmony_ci    $debug_cmd
254813498266Sopenharmony_ci
254913498266Sopenharmony_ci    _G_rc_lt_parse_options=false
255013498266Sopenharmony_ci
255113498266Sopenharmony_ci    # Perform our own loop to consume as many options as possible in
255213498266Sopenharmony_ci    # each iteration.
255313498266Sopenharmony_ci    while test $# -gt 0; do
255413498266Sopenharmony_ci      _G_match_lt_parse_options=:
255513498266Sopenharmony_ci      _G_opt=$1
255613498266Sopenharmony_ci      shift
255713498266Sopenharmony_ci      case $_G_opt in
255813498266Sopenharmony_ci        --dry-run|--dryrun|-n)
255913498266Sopenharmony_ci                        opt_dry_run=:
256013498266Sopenharmony_ci                        ;;
256113498266Sopenharmony_ci
256213498266Sopenharmony_ci        --config)       func_config ;;
256313498266Sopenharmony_ci
256413498266Sopenharmony_ci        --dlopen|-dlopen)
256513498266Sopenharmony_ci                        opt_dlopen="${opt_dlopen+$opt_dlopen
256613498266Sopenharmony_ci}$1"
256713498266Sopenharmony_ci                        shift
256813498266Sopenharmony_ci                        ;;
256913498266Sopenharmony_ci
257013498266Sopenharmony_ci        --preserve-dup-deps)
257113498266Sopenharmony_ci                        opt_preserve_dup_deps=: ;;
257213498266Sopenharmony_ci
257313498266Sopenharmony_ci        --features)     func_features ;;
257413498266Sopenharmony_ci
257513498266Sopenharmony_ci        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
257613498266Sopenharmony_ci
257713498266Sopenharmony_ci        --help)         opt_help=: ;;
257813498266Sopenharmony_ci
257913498266Sopenharmony_ci        --help-all)     opt_help=': help-all' ;;
258013498266Sopenharmony_ci
258113498266Sopenharmony_ci        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
258213498266Sopenharmony_ci                        opt_mode=$1
258313498266Sopenharmony_ci                        case $1 in
258413498266Sopenharmony_ci                          # Valid mode arguments:
258513498266Sopenharmony_ci                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
258613498266Sopenharmony_ci
258713498266Sopenharmony_ci                          # Catch anything else as an error
258813498266Sopenharmony_ci                          *) func_error "invalid argument for $_G_opt"
258913498266Sopenharmony_ci                             exit_cmd=exit
259013498266Sopenharmony_ci                             break
259113498266Sopenharmony_ci                             ;;
259213498266Sopenharmony_ci                        esac
259313498266Sopenharmony_ci                        shift
259413498266Sopenharmony_ci                        ;;
259513498266Sopenharmony_ci
259613498266Sopenharmony_ci        --no-silent|--no-quiet)
259713498266Sopenharmony_ci                        opt_quiet=false
259813498266Sopenharmony_ci                        func_append preserve_args " $_G_opt"
259913498266Sopenharmony_ci                        ;;
260013498266Sopenharmony_ci
260113498266Sopenharmony_ci        --no-warnings|--no-warning|--no-warn)
260213498266Sopenharmony_ci                        opt_warning=false
260313498266Sopenharmony_ci                        func_append preserve_args " $_G_opt"
260413498266Sopenharmony_ci                        ;;
260513498266Sopenharmony_ci
260613498266Sopenharmony_ci        --no-verbose)
260713498266Sopenharmony_ci                        opt_verbose=false
260813498266Sopenharmony_ci                        func_append preserve_args " $_G_opt"
260913498266Sopenharmony_ci                        ;;
261013498266Sopenharmony_ci
261113498266Sopenharmony_ci        --silent|--quiet)
261213498266Sopenharmony_ci                        opt_quiet=:
261313498266Sopenharmony_ci                        opt_verbose=false
261413498266Sopenharmony_ci                        func_append preserve_args " $_G_opt"
261513498266Sopenharmony_ci                        ;;
261613498266Sopenharmony_ci
261713498266Sopenharmony_ci        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
261813498266Sopenharmony_ci                        opt_tag=$1
261913498266Sopenharmony_ci                        func_append preserve_args " $_G_opt $1"
262013498266Sopenharmony_ci                        func_enable_tag "$1"
262113498266Sopenharmony_ci                        shift
262213498266Sopenharmony_ci                        ;;
262313498266Sopenharmony_ci
262413498266Sopenharmony_ci        --verbose|-v)   opt_quiet=false
262513498266Sopenharmony_ci                        opt_verbose=:
262613498266Sopenharmony_ci                        func_append preserve_args " $_G_opt"
262713498266Sopenharmony_ci                        ;;
262813498266Sopenharmony_ci
262913498266Sopenharmony_ci        # An option not handled by this hook function:
263013498266Sopenharmony_ci        *)              set dummy "$_G_opt" ${1+"$@"} ; shift
263113498266Sopenharmony_ci                        _G_match_lt_parse_options=false
263213498266Sopenharmony_ci                        break
263313498266Sopenharmony_ci                        ;;
263413498266Sopenharmony_ci      esac
263513498266Sopenharmony_ci      $_G_match_lt_parse_options && _G_rc_lt_parse_options=:
263613498266Sopenharmony_ci    done
263713498266Sopenharmony_ci
263813498266Sopenharmony_ci    if $_G_rc_lt_parse_options; then
263913498266Sopenharmony_ci      # save modified positional parameters for caller
264013498266Sopenharmony_ci      func_quote eval ${1+"$@"}
264113498266Sopenharmony_ci      libtool_parse_options_result=$func_quote_result
264213498266Sopenharmony_ci    fi
264313498266Sopenharmony_ci}
264413498266Sopenharmony_cifunc_add_hook func_parse_options libtool_parse_options
264513498266Sopenharmony_ci
264613498266Sopenharmony_ci
264713498266Sopenharmony_ci
264813498266Sopenharmony_ci# libtool_validate_options [ARG]...
264913498266Sopenharmony_ci# ---------------------------------
265013498266Sopenharmony_ci# Perform any sanity checks on option settings and/or unconsumed
265113498266Sopenharmony_ci# arguments.
265213498266Sopenharmony_cilibtool_validate_options ()
265313498266Sopenharmony_ci{
265413498266Sopenharmony_ci    # save first non-option argument
265513498266Sopenharmony_ci    if test 0 -lt $#; then
265613498266Sopenharmony_ci      nonopt=$1
265713498266Sopenharmony_ci      shift
265813498266Sopenharmony_ci    fi
265913498266Sopenharmony_ci
266013498266Sopenharmony_ci    # preserve --debug
266113498266Sopenharmony_ci    test : = "$debug_cmd" || func_append preserve_args " --debug"
266213498266Sopenharmony_ci
266313498266Sopenharmony_ci    case $host in
266413498266Sopenharmony_ci      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
266513498266Sopenharmony_ci      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
266613498266Sopenharmony_ci      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
266713498266Sopenharmony_ci        # don't eliminate duplications in $postdeps and $predeps
266813498266Sopenharmony_ci        opt_duplicate_compiler_generated_deps=:
266913498266Sopenharmony_ci        ;;
267013498266Sopenharmony_ci      *)
267113498266Sopenharmony_ci        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
267213498266Sopenharmony_ci        ;;
267313498266Sopenharmony_ci    esac
267413498266Sopenharmony_ci
267513498266Sopenharmony_ci    $opt_help || {
267613498266Sopenharmony_ci      # Sanity checks first:
267713498266Sopenharmony_ci      func_check_version_match
267813498266Sopenharmony_ci
267913498266Sopenharmony_ci      test yes != "$build_libtool_libs" \
268013498266Sopenharmony_ci        && test yes != "$build_old_libs" \
268113498266Sopenharmony_ci        && func_fatal_configuration "not configured to build any kind of library"
268213498266Sopenharmony_ci
268313498266Sopenharmony_ci      # Darwin sucks
268413498266Sopenharmony_ci      eval std_shrext=\"$shrext_cmds\"
268513498266Sopenharmony_ci
268613498266Sopenharmony_ci      # Only execute mode is allowed to have -dlopen flags.
268713498266Sopenharmony_ci      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
268813498266Sopenharmony_ci        func_error "unrecognized option '-dlopen'"
268913498266Sopenharmony_ci        $ECHO "$help" 1>&2
269013498266Sopenharmony_ci        exit $EXIT_FAILURE
269113498266Sopenharmony_ci      fi
269213498266Sopenharmony_ci
269313498266Sopenharmony_ci      # Change the help message to a mode-specific one.
269413498266Sopenharmony_ci      generic_help=$help
269513498266Sopenharmony_ci      help="Try '$progname --help --mode=$opt_mode' for more information."
269613498266Sopenharmony_ci    }
269713498266Sopenharmony_ci
269813498266Sopenharmony_ci    # Pass back the unparsed argument list
269913498266Sopenharmony_ci    func_quote eval ${1+"$@"}
270013498266Sopenharmony_ci    libtool_validate_options_result=$func_quote_result
270113498266Sopenharmony_ci}
270213498266Sopenharmony_cifunc_add_hook func_validate_options libtool_validate_options
270313498266Sopenharmony_ci
270413498266Sopenharmony_ci
270513498266Sopenharmony_ci# Process options as early as possible so that --help and --version
270613498266Sopenharmony_ci# can return quickly.
270713498266Sopenharmony_cifunc_options ${1+"$@"}
270813498266Sopenharmony_cieval set dummy "$func_options_result"; shift
270913498266Sopenharmony_ci
271013498266Sopenharmony_ci
271113498266Sopenharmony_ci
271213498266Sopenharmony_ci## ----------- ##
271313498266Sopenharmony_ci##    Main.    ##
271413498266Sopenharmony_ci## ----------- ##
271513498266Sopenharmony_ci
271613498266Sopenharmony_cimagic='%%%MAGIC variable%%%'
271713498266Sopenharmony_cimagic_exe='%%%MAGIC EXE variable%%%'
271813498266Sopenharmony_ci
271913498266Sopenharmony_ci# Global variables.
272013498266Sopenharmony_ciextracted_archives=
272113498266Sopenharmony_ciextracted_serial=0
272213498266Sopenharmony_ci
272313498266Sopenharmony_ci# If this variable is set in any of the actions, the command in it
272413498266Sopenharmony_ci# will be execed at the end.  This prevents here-documents from being
272513498266Sopenharmony_ci# left over by shells.
272613498266Sopenharmony_ciexec_cmd=
272713498266Sopenharmony_ci
272813498266Sopenharmony_ci
272913498266Sopenharmony_ci# A function that is used when there is no print builtin or printf.
273013498266Sopenharmony_cifunc_fallback_echo ()
273113498266Sopenharmony_ci{
273213498266Sopenharmony_ci  eval 'cat <<_LTECHO_EOF
273313498266Sopenharmony_ci$1
273413498266Sopenharmony_ci_LTECHO_EOF'
273513498266Sopenharmony_ci}
273613498266Sopenharmony_ci
273713498266Sopenharmony_ci# func_generated_by_libtool
273813498266Sopenharmony_ci# True iff stdin has been generated by Libtool. This function is only
273913498266Sopenharmony_ci# a basic sanity check; it will hardly flush out determined imposters.
274013498266Sopenharmony_cifunc_generated_by_libtool_p ()
274113498266Sopenharmony_ci{
274213498266Sopenharmony_ci  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
274313498266Sopenharmony_ci}
274413498266Sopenharmony_ci
274513498266Sopenharmony_ci# func_lalib_p file
274613498266Sopenharmony_ci# True iff FILE is a libtool '.la' library or '.lo' object file.
274713498266Sopenharmony_ci# This function is only a basic sanity check; it will hardly flush out
274813498266Sopenharmony_ci# determined imposters.
274913498266Sopenharmony_cifunc_lalib_p ()
275013498266Sopenharmony_ci{
275113498266Sopenharmony_ci    test -f "$1" &&
275213498266Sopenharmony_ci      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
275313498266Sopenharmony_ci}
275413498266Sopenharmony_ci
275513498266Sopenharmony_ci# func_lalib_unsafe_p file
275613498266Sopenharmony_ci# True iff FILE is a libtool '.la' library or '.lo' object file.
275713498266Sopenharmony_ci# This function implements the same check as func_lalib_p without
275813498266Sopenharmony_ci# resorting to external programs.  To this end, it redirects stdin and
275913498266Sopenharmony_ci# closes it afterwards, without saving the original file descriptor.
276013498266Sopenharmony_ci# As a safety measure, use it only where a negative result would be
276113498266Sopenharmony_ci# fatal anyway.  Works if 'file' does not exist.
276213498266Sopenharmony_cifunc_lalib_unsafe_p ()
276313498266Sopenharmony_ci{
276413498266Sopenharmony_ci    lalib_p=no
276513498266Sopenharmony_ci    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
276613498266Sopenharmony_ci	for lalib_p_l in 1 2 3 4
276713498266Sopenharmony_ci	do
276813498266Sopenharmony_ci	    read lalib_p_line
276913498266Sopenharmony_ci	    case $lalib_p_line in
277013498266Sopenharmony_ci		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
277113498266Sopenharmony_ci	    esac
277213498266Sopenharmony_ci	done
277313498266Sopenharmony_ci	exec 0<&5 5<&-
277413498266Sopenharmony_ci    fi
277513498266Sopenharmony_ci    test yes = "$lalib_p"
277613498266Sopenharmony_ci}
277713498266Sopenharmony_ci
277813498266Sopenharmony_ci# func_ltwrapper_script_p file
277913498266Sopenharmony_ci# True iff FILE is a libtool wrapper script
278013498266Sopenharmony_ci# This function is only a basic sanity check; it will hardly flush out
278113498266Sopenharmony_ci# determined imposters.
278213498266Sopenharmony_cifunc_ltwrapper_script_p ()
278313498266Sopenharmony_ci{
278413498266Sopenharmony_ci    test -f "$1" &&
278513498266Sopenharmony_ci      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
278613498266Sopenharmony_ci}
278713498266Sopenharmony_ci
278813498266Sopenharmony_ci# func_ltwrapper_executable_p file
278913498266Sopenharmony_ci# True iff FILE is a libtool wrapper executable
279013498266Sopenharmony_ci# This function is only a basic sanity check; it will hardly flush out
279113498266Sopenharmony_ci# determined imposters.
279213498266Sopenharmony_cifunc_ltwrapper_executable_p ()
279313498266Sopenharmony_ci{
279413498266Sopenharmony_ci    func_ltwrapper_exec_suffix=
279513498266Sopenharmony_ci    case $1 in
279613498266Sopenharmony_ci    *.exe) ;;
279713498266Sopenharmony_ci    *) func_ltwrapper_exec_suffix=.exe ;;
279813498266Sopenharmony_ci    esac
279913498266Sopenharmony_ci    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
280013498266Sopenharmony_ci}
280113498266Sopenharmony_ci
280213498266Sopenharmony_ci# func_ltwrapper_scriptname file
280313498266Sopenharmony_ci# Assumes file is an ltwrapper_executable
280413498266Sopenharmony_ci# uses $file to determine the appropriate filename for a
280513498266Sopenharmony_ci# temporary ltwrapper_script.
280613498266Sopenharmony_cifunc_ltwrapper_scriptname ()
280713498266Sopenharmony_ci{
280813498266Sopenharmony_ci    func_dirname_and_basename "$1" "" "."
280913498266Sopenharmony_ci    func_stripname '' '.exe' "$func_basename_result"
281013498266Sopenharmony_ci    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
281113498266Sopenharmony_ci}
281213498266Sopenharmony_ci
281313498266Sopenharmony_ci# func_ltwrapper_p file
281413498266Sopenharmony_ci# True iff FILE is a libtool wrapper script or wrapper executable
281513498266Sopenharmony_ci# This function is only a basic sanity check; it will hardly flush out
281613498266Sopenharmony_ci# determined imposters.
281713498266Sopenharmony_cifunc_ltwrapper_p ()
281813498266Sopenharmony_ci{
281913498266Sopenharmony_ci    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
282013498266Sopenharmony_ci}
282113498266Sopenharmony_ci
282213498266Sopenharmony_ci
282313498266Sopenharmony_ci# func_execute_cmds commands fail_cmd
282413498266Sopenharmony_ci# Execute tilde-delimited COMMANDS.
282513498266Sopenharmony_ci# If FAIL_CMD is given, eval that upon failure.
282613498266Sopenharmony_ci# FAIL_CMD may read-access the current command in variable CMD!
282713498266Sopenharmony_cifunc_execute_cmds ()
282813498266Sopenharmony_ci{
282913498266Sopenharmony_ci    $debug_cmd
283013498266Sopenharmony_ci
283113498266Sopenharmony_ci    save_ifs=$IFS; IFS='~'
283213498266Sopenharmony_ci    for cmd in $1; do
283313498266Sopenharmony_ci      IFS=$sp$nl
283413498266Sopenharmony_ci      eval cmd=\"$cmd\"
283513498266Sopenharmony_ci      IFS=$save_ifs
283613498266Sopenharmony_ci      func_show_eval "$cmd" "${2-:}"
283713498266Sopenharmony_ci    done
283813498266Sopenharmony_ci    IFS=$save_ifs
283913498266Sopenharmony_ci}
284013498266Sopenharmony_ci
284113498266Sopenharmony_ci
284213498266Sopenharmony_ci# func_source file
284313498266Sopenharmony_ci# Source FILE, adding directory component if necessary.
284413498266Sopenharmony_ci# Note that it is not necessary on cygwin/mingw to append a dot to
284513498266Sopenharmony_ci# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
284613498266Sopenharmony_ci# behavior happens only for exec(3), not for open(2)!  Also, sourcing
284713498266Sopenharmony_ci# 'FILE.' does not work on cygwin managed mounts.
284813498266Sopenharmony_cifunc_source ()
284913498266Sopenharmony_ci{
285013498266Sopenharmony_ci    $debug_cmd
285113498266Sopenharmony_ci
285213498266Sopenharmony_ci    case $1 in
285313498266Sopenharmony_ci    */* | *\\*)	. "$1" ;;
285413498266Sopenharmony_ci    *)		. "./$1" ;;
285513498266Sopenharmony_ci    esac
285613498266Sopenharmony_ci}
285713498266Sopenharmony_ci
285813498266Sopenharmony_ci
285913498266Sopenharmony_ci# func_resolve_sysroot PATH
286013498266Sopenharmony_ci# Replace a leading = in PATH with a sysroot.  Store the result into
286113498266Sopenharmony_ci# func_resolve_sysroot_result
286213498266Sopenharmony_cifunc_resolve_sysroot ()
286313498266Sopenharmony_ci{
286413498266Sopenharmony_ci  func_resolve_sysroot_result=$1
286513498266Sopenharmony_ci  case $func_resolve_sysroot_result in
286613498266Sopenharmony_ci  =*)
286713498266Sopenharmony_ci    func_stripname '=' '' "$func_resolve_sysroot_result"
286813498266Sopenharmony_ci    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
286913498266Sopenharmony_ci    ;;
287013498266Sopenharmony_ci  esac
287113498266Sopenharmony_ci}
287213498266Sopenharmony_ci
287313498266Sopenharmony_ci# func_replace_sysroot PATH
287413498266Sopenharmony_ci# If PATH begins with the sysroot, replace it with = and
287513498266Sopenharmony_ci# store the result into func_replace_sysroot_result.
287613498266Sopenharmony_cifunc_replace_sysroot ()
287713498266Sopenharmony_ci{
287813498266Sopenharmony_ci  case $lt_sysroot:$1 in
287913498266Sopenharmony_ci  ?*:"$lt_sysroot"*)
288013498266Sopenharmony_ci    func_stripname "$lt_sysroot" '' "$1"
288113498266Sopenharmony_ci    func_replace_sysroot_result='='$func_stripname_result
288213498266Sopenharmony_ci    ;;
288313498266Sopenharmony_ci  *)
288413498266Sopenharmony_ci    # Including no sysroot.
288513498266Sopenharmony_ci    func_replace_sysroot_result=$1
288613498266Sopenharmony_ci    ;;
288713498266Sopenharmony_ci  esac
288813498266Sopenharmony_ci}
288913498266Sopenharmony_ci
289013498266Sopenharmony_ci# func_infer_tag arg
289113498266Sopenharmony_ci# Infer tagged configuration to use if any are available and
289213498266Sopenharmony_ci# if one wasn't chosen via the "--tag" command line option.
289313498266Sopenharmony_ci# Only attempt this if the compiler in the base compile
289413498266Sopenharmony_ci# command doesn't match the default compiler.
289513498266Sopenharmony_ci# arg is usually of the form 'gcc ...'
289613498266Sopenharmony_cifunc_infer_tag ()
289713498266Sopenharmony_ci{
289813498266Sopenharmony_ci    $debug_cmd
289913498266Sopenharmony_ci
290013498266Sopenharmony_ci    if test -n "$available_tags" && test -z "$tagname"; then
290113498266Sopenharmony_ci      CC_quoted=
290213498266Sopenharmony_ci      for arg in $CC; do
290313498266Sopenharmony_ci	func_append_quoted CC_quoted "$arg"
290413498266Sopenharmony_ci      done
290513498266Sopenharmony_ci      CC_expanded=`func_echo_all $CC`
290613498266Sopenharmony_ci      CC_quoted_expanded=`func_echo_all $CC_quoted`
290713498266Sopenharmony_ci      case $@ in
290813498266Sopenharmony_ci      # Blanks in the command may have been stripped by the calling shell,
290913498266Sopenharmony_ci      # but not from the CC environment variable when configure was run.
291013498266Sopenharmony_ci      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
291113498266Sopenharmony_ci      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
291213498266Sopenharmony_ci      # Blanks at the start of $base_compile will cause this to fail
291313498266Sopenharmony_ci      # if we don't check for them as well.
291413498266Sopenharmony_ci      *)
291513498266Sopenharmony_ci	for z in $available_tags; do
291613498266Sopenharmony_ci	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
291713498266Sopenharmony_ci	    # Evaluate the configuration.
291813498266Sopenharmony_ci	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
291913498266Sopenharmony_ci	    CC_quoted=
292013498266Sopenharmony_ci	    for arg in $CC; do
292113498266Sopenharmony_ci	      # Double-quote args containing other shell metacharacters.
292213498266Sopenharmony_ci	      func_append_quoted CC_quoted "$arg"
292313498266Sopenharmony_ci	    done
292413498266Sopenharmony_ci	    CC_expanded=`func_echo_all $CC`
292513498266Sopenharmony_ci	    CC_quoted_expanded=`func_echo_all $CC_quoted`
292613498266Sopenharmony_ci	    case "$@ " in
292713498266Sopenharmony_ci	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
292813498266Sopenharmony_ci	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
292913498266Sopenharmony_ci	      # The compiler in the base compile command matches
293013498266Sopenharmony_ci	      # the one in the tagged configuration.
293113498266Sopenharmony_ci	      # Assume this is the tagged configuration we want.
293213498266Sopenharmony_ci	      tagname=$z
293313498266Sopenharmony_ci	      break
293413498266Sopenharmony_ci	      ;;
293513498266Sopenharmony_ci	    esac
293613498266Sopenharmony_ci	  fi
293713498266Sopenharmony_ci	done
293813498266Sopenharmony_ci	# If $tagname still isn't set, then no tagged configuration
293913498266Sopenharmony_ci	# was found and let the user know that the "--tag" command
294013498266Sopenharmony_ci	# line option must be used.
294113498266Sopenharmony_ci	if test -z "$tagname"; then
294213498266Sopenharmony_ci	  func_echo "unable to infer tagged configuration"
294313498266Sopenharmony_ci	  func_fatal_error "specify a tag with '--tag'"
294413498266Sopenharmony_ci#	else
294513498266Sopenharmony_ci#	  func_verbose "using $tagname tagged configuration"
294613498266Sopenharmony_ci	fi
294713498266Sopenharmony_ci	;;
294813498266Sopenharmony_ci      esac
294913498266Sopenharmony_ci    fi
295013498266Sopenharmony_ci}
295113498266Sopenharmony_ci
295213498266Sopenharmony_ci
295313498266Sopenharmony_ci
295413498266Sopenharmony_ci# func_write_libtool_object output_name pic_name nonpic_name
295513498266Sopenharmony_ci# Create a libtool object file (analogous to a ".la" file),
295613498266Sopenharmony_ci# but don't create it if we're doing a dry run.
295713498266Sopenharmony_cifunc_write_libtool_object ()
295813498266Sopenharmony_ci{
295913498266Sopenharmony_ci    write_libobj=$1
296013498266Sopenharmony_ci    if test yes = "$build_libtool_libs"; then
296113498266Sopenharmony_ci      write_lobj=\'$2\'
296213498266Sopenharmony_ci    else
296313498266Sopenharmony_ci      write_lobj=none
296413498266Sopenharmony_ci    fi
296513498266Sopenharmony_ci
296613498266Sopenharmony_ci    if test yes = "$build_old_libs"; then
296713498266Sopenharmony_ci      write_oldobj=\'$3\'
296813498266Sopenharmony_ci    else
296913498266Sopenharmony_ci      write_oldobj=none
297013498266Sopenharmony_ci    fi
297113498266Sopenharmony_ci
297213498266Sopenharmony_ci    $opt_dry_run || {
297313498266Sopenharmony_ci      cat >${write_libobj}T <<EOF
297413498266Sopenharmony_ci# $write_libobj - a libtool object file
297513498266Sopenharmony_ci# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
297613498266Sopenharmony_ci#
297713498266Sopenharmony_ci# Please DO NOT delete this file!
297813498266Sopenharmony_ci# It is necessary for linking the library.
297913498266Sopenharmony_ci
298013498266Sopenharmony_ci# Name of the PIC object.
298113498266Sopenharmony_cipic_object=$write_lobj
298213498266Sopenharmony_ci
298313498266Sopenharmony_ci# Name of the non-PIC object
298413498266Sopenharmony_cinon_pic_object=$write_oldobj
298513498266Sopenharmony_ci
298613498266Sopenharmony_ciEOF
298713498266Sopenharmony_ci      $MV "${write_libobj}T" "$write_libobj"
298813498266Sopenharmony_ci    }
298913498266Sopenharmony_ci}
299013498266Sopenharmony_ci
299113498266Sopenharmony_ci
299213498266Sopenharmony_ci##################################################
299313498266Sopenharmony_ci# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
299413498266Sopenharmony_ci##################################################
299513498266Sopenharmony_ci
299613498266Sopenharmony_ci# func_convert_core_file_wine_to_w32 ARG
299713498266Sopenharmony_ci# Helper function used by file name conversion functions when $build is *nix,
299813498266Sopenharmony_ci# and $host is mingw, cygwin, or some other w32 environment. Relies on a
299913498266Sopenharmony_ci# correctly configured wine environment available, with the winepath program
300013498266Sopenharmony_ci# in $build's $PATH.
300113498266Sopenharmony_ci#
300213498266Sopenharmony_ci# ARG is the $build file name to be converted to w32 format.
300313498266Sopenharmony_ci# Result is available in $func_convert_core_file_wine_to_w32_result, and will
300413498266Sopenharmony_ci# be empty on error (or when ARG is empty)
300513498266Sopenharmony_cifunc_convert_core_file_wine_to_w32 ()
300613498266Sopenharmony_ci{
300713498266Sopenharmony_ci  $debug_cmd
300813498266Sopenharmony_ci
300913498266Sopenharmony_ci  func_convert_core_file_wine_to_w32_result=$1
301013498266Sopenharmony_ci  if test -n "$1"; then
301113498266Sopenharmony_ci    # Unfortunately, winepath does not exit with a non-zero error code, so we
301213498266Sopenharmony_ci    # are forced to check the contents of stdout. On the other hand, if the
301313498266Sopenharmony_ci    # command is not found, the shell will set an exit code of 127 and print
301413498266Sopenharmony_ci    # *an error message* to stdout. So we must check for both error code of
301513498266Sopenharmony_ci    # zero AND non-empty stdout, which explains the odd construction:
301613498266Sopenharmony_ci    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
301713498266Sopenharmony_ci    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
301813498266Sopenharmony_ci      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
301913498266Sopenharmony_ci        $SED -e "$sed_naive_backslashify"`
302013498266Sopenharmony_ci    else
302113498266Sopenharmony_ci      func_convert_core_file_wine_to_w32_result=
302213498266Sopenharmony_ci    fi
302313498266Sopenharmony_ci  fi
302413498266Sopenharmony_ci}
302513498266Sopenharmony_ci# end: func_convert_core_file_wine_to_w32
302613498266Sopenharmony_ci
302713498266Sopenharmony_ci
302813498266Sopenharmony_ci# func_convert_core_path_wine_to_w32 ARG
302913498266Sopenharmony_ci# Helper function used by path conversion functions when $build is *nix, and
303013498266Sopenharmony_ci# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
303113498266Sopenharmony_ci# configured wine environment available, with the winepath program in $build's
303213498266Sopenharmony_ci# $PATH. Assumes ARG has no leading or trailing path separator characters.
303313498266Sopenharmony_ci#
303413498266Sopenharmony_ci# ARG is path to be converted from $build format to win32.
303513498266Sopenharmony_ci# Result is available in $func_convert_core_path_wine_to_w32_result.
303613498266Sopenharmony_ci# Unconvertible file (directory) names in ARG are skipped; if no directory names
303713498266Sopenharmony_ci# are convertible, then the result may be empty.
303813498266Sopenharmony_cifunc_convert_core_path_wine_to_w32 ()
303913498266Sopenharmony_ci{
304013498266Sopenharmony_ci  $debug_cmd
304113498266Sopenharmony_ci
304213498266Sopenharmony_ci  # unfortunately, winepath doesn't convert paths, only file names
304313498266Sopenharmony_ci  func_convert_core_path_wine_to_w32_result=
304413498266Sopenharmony_ci  if test -n "$1"; then
304513498266Sopenharmony_ci    oldIFS=$IFS
304613498266Sopenharmony_ci    IFS=:
304713498266Sopenharmony_ci    for func_convert_core_path_wine_to_w32_f in $1; do
304813498266Sopenharmony_ci      IFS=$oldIFS
304913498266Sopenharmony_ci      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
305013498266Sopenharmony_ci      if test -n "$func_convert_core_file_wine_to_w32_result"; then
305113498266Sopenharmony_ci        if test -z "$func_convert_core_path_wine_to_w32_result"; then
305213498266Sopenharmony_ci          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
305313498266Sopenharmony_ci        else
305413498266Sopenharmony_ci          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
305513498266Sopenharmony_ci        fi
305613498266Sopenharmony_ci      fi
305713498266Sopenharmony_ci    done
305813498266Sopenharmony_ci    IFS=$oldIFS
305913498266Sopenharmony_ci  fi
306013498266Sopenharmony_ci}
306113498266Sopenharmony_ci# end: func_convert_core_path_wine_to_w32
306213498266Sopenharmony_ci
306313498266Sopenharmony_ci
306413498266Sopenharmony_ci# func_cygpath ARGS...
306513498266Sopenharmony_ci# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
306613498266Sopenharmony_ci# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
306713498266Sopenharmony_ci# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
306813498266Sopenharmony_ci# (2), returns the Cygwin file name or path in func_cygpath_result (input
306913498266Sopenharmony_ci# file name or path is assumed to be in w32 format, as previously converted
307013498266Sopenharmony_ci# from $build's *nix or MSYS format). In case (3), returns the w32 file name
307113498266Sopenharmony_ci# or path in func_cygpath_result (input file name or path is assumed to be in
307213498266Sopenharmony_ci# Cygwin format). Returns an empty string on error.
307313498266Sopenharmony_ci#
307413498266Sopenharmony_ci# ARGS are passed to cygpath, with the last one being the file name or path to
307513498266Sopenharmony_ci# be converted.
307613498266Sopenharmony_ci#
307713498266Sopenharmony_ci# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
307813498266Sopenharmony_ci# environment variable; do not put it in $PATH.
307913498266Sopenharmony_cifunc_cygpath ()
308013498266Sopenharmony_ci{
308113498266Sopenharmony_ci  $debug_cmd
308213498266Sopenharmony_ci
308313498266Sopenharmony_ci  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
308413498266Sopenharmony_ci    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
308513498266Sopenharmony_ci    if test "$?" -ne 0; then
308613498266Sopenharmony_ci      # on failure, ensure result is empty
308713498266Sopenharmony_ci      func_cygpath_result=
308813498266Sopenharmony_ci    fi
308913498266Sopenharmony_ci  else
309013498266Sopenharmony_ci    func_cygpath_result=
309113498266Sopenharmony_ci    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
309213498266Sopenharmony_ci  fi
309313498266Sopenharmony_ci}
309413498266Sopenharmony_ci#end: func_cygpath
309513498266Sopenharmony_ci
309613498266Sopenharmony_ci
309713498266Sopenharmony_ci# func_convert_core_msys_to_w32 ARG
309813498266Sopenharmony_ci# Convert file name or path ARG from MSYS format to w32 format.  Return
309913498266Sopenharmony_ci# result in func_convert_core_msys_to_w32_result.
310013498266Sopenharmony_cifunc_convert_core_msys_to_w32 ()
310113498266Sopenharmony_ci{
310213498266Sopenharmony_ci  $debug_cmd
310313498266Sopenharmony_ci
310413498266Sopenharmony_ci  # awkward: cmd appends spaces to result
310513498266Sopenharmony_ci  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
310613498266Sopenharmony_ci    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
310713498266Sopenharmony_ci}
310813498266Sopenharmony_ci#end: func_convert_core_msys_to_w32
310913498266Sopenharmony_ci
311013498266Sopenharmony_ci
311113498266Sopenharmony_ci# func_convert_file_check ARG1 ARG2
311213498266Sopenharmony_ci# Verify that ARG1 (a file name in $build format) was converted to $host
311313498266Sopenharmony_ci# format in ARG2. Otherwise, emit an error message, but continue (resetting
311413498266Sopenharmony_ci# func_to_host_file_result to ARG1).
311513498266Sopenharmony_cifunc_convert_file_check ()
311613498266Sopenharmony_ci{
311713498266Sopenharmony_ci  $debug_cmd
311813498266Sopenharmony_ci
311913498266Sopenharmony_ci  if test -z "$2" && test -n "$1"; then
312013498266Sopenharmony_ci    func_error "Could not determine host file name corresponding to"
312113498266Sopenharmony_ci    func_error "  '$1'"
312213498266Sopenharmony_ci    func_error "Continuing, but uninstalled executables may not work."
312313498266Sopenharmony_ci    # Fallback:
312413498266Sopenharmony_ci    func_to_host_file_result=$1
312513498266Sopenharmony_ci  fi
312613498266Sopenharmony_ci}
312713498266Sopenharmony_ci# end func_convert_file_check
312813498266Sopenharmony_ci
312913498266Sopenharmony_ci
313013498266Sopenharmony_ci# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
313113498266Sopenharmony_ci# Verify that FROM_PATH (a path in $build format) was converted to $host
313213498266Sopenharmony_ci# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
313313498266Sopenharmony_ci# func_to_host_file_result to a simplistic fallback value (see below).
313413498266Sopenharmony_cifunc_convert_path_check ()
313513498266Sopenharmony_ci{
313613498266Sopenharmony_ci  $debug_cmd
313713498266Sopenharmony_ci
313813498266Sopenharmony_ci  if test -z "$4" && test -n "$3"; then
313913498266Sopenharmony_ci    func_error "Could not determine the host path corresponding to"
314013498266Sopenharmony_ci    func_error "  '$3'"
314113498266Sopenharmony_ci    func_error "Continuing, but uninstalled executables may not work."
314213498266Sopenharmony_ci    # Fallback.  This is a deliberately simplistic "conversion" and
314313498266Sopenharmony_ci    # should not be "improved".  See libtool.info.
314413498266Sopenharmony_ci    if test "x$1" != "x$2"; then
314513498266Sopenharmony_ci      lt_replace_pathsep_chars="s|$1|$2|g"
314613498266Sopenharmony_ci      func_to_host_path_result=`echo "$3" |
314713498266Sopenharmony_ci        $SED -e "$lt_replace_pathsep_chars"`
314813498266Sopenharmony_ci    else
314913498266Sopenharmony_ci      func_to_host_path_result=$3
315013498266Sopenharmony_ci    fi
315113498266Sopenharmony_ci  fi
315213498266Sopenharmony_ci}
315313498266Sopenharmony_ci# end func_convert_path_check
315413498266Sopenharmony_ci
315513498266Sopenharmony_ci
315613498266Sopenharmony_ci# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
315713498266Sopenharmony_ci# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
315813498266Sopenharmony_ci# and appending REPL if ORIG matches BACKPAT.
315913498266Sopenharmony_cifunc_convert_path_front_back_pathsep ()
316013498266Sopenharmony_ci{
316113498266Sopenharmony_ci  $debug_cmd
316213498266Sopenharmony_ci
316313498266Sopenharmony_ci  case $4 in
316413498266Sopenharmony_ci  $1 ) func_to_host_path_result=$3$func_to_host_path_result
316513498266Sopenharmony_ci    ;;
316613498266Sopenharmony_ci  esac
316713498266Sopenharmony_ci  case $4 in
316813498266Sopenharmony_ci  $2 ) func_append func_to_host_path_result "$3"
316913498266Sopenharmony_ci    ;;
317013498266Sopenharmony_ci  esac
317113498266Sopenharmony_ci}
317213498266Sopenharmony_ci# end func_convert_path_front_back_pathsep
317313498266Sopenharmony_ci
317413498266Sopenharmony_ci
317513498266Sopenharmony_ci##################################################
317613498266Sopenharmony_ci# $build to $host FILE NAME CONVERSION FUNCTIONS #
317713498266Sopenharmony_ci##################################################
317813498266Sopenharmony_ci# invoked via '$to_host_file_cmd ARG'
317913498266Sopenharmony_ci#
318013498266Sopenharmony_ci# In each case, ARG is the path to be converted from $build to $host format.
318113498266Sopenharmony_ci# Result will be available in $func_to_host_file_result.
318213498266Sopenharmony_ci
318313498266Sopenharmony_ci
318413498266Sopenharmony_ci# func_to_host_file ARG
318513498266Sopenharmony_ci# Converts the file name ARG from $build format to $host format. Return result
318613498266Sopenharmony_ci# in func_to_host_file_result.
318713498266Sopenharmony_cifunc_to_host_file ()
318813498266Sopenharmony_ci{
318913498266Sopenharmony_ci  $debug_cmd
319013498266Sopenharmony_ci
319113498266Sopenharmony_ci  $to_host_file_cmd "$1"
319213498266Sopenharmony_ci}
319313498266Sopenharmony_ci# end func_to_host_file
319413498266Sopenharmony_ci
319513498266Sopenharmony_ci
319613498266Sopenharmony_ci# func_to_tool_file ARG LAZY
319713498266Sopenharmony_ci# converts the file name ARG from $build format to toolchain format. Return
319813498266Sopenharmony_ci# result in func_to_tool_file_result.  If the conversion in use is listed
319913498266Sopenharmony_ci# in (the comma separated) LAZY, no conversion takes place.
320013498266Sopenharmony_cifunc_to_tool_file ()
320113498266Sopenharmony_ci{
320213498266Sopenharmony_ci  $debug_cmd
320313498266Sopenharmony_ci
320413498266Sopenharmony_ci  case ,$2, in
320513498266Sopenharmony_ci    *,"$to_tool_file_cmd",*)
320613498266Sopenharmony_ci      func_to_tool_file_result=$1
320713498266Sopenharmony_ci      ;;
320813498266Sopenharmony_ci    *)
320913498266Sopenharmony_ci      $to_tool_file_cmd "$1"
321013498266Sopenharmony_ci      func_to_tool_file_result=$func_to_host_file_result
321113498266Sopenharmony_ci      ;;
321213498266Sopenharmony_ci  esac
321313498266Sopenharmony_ci}
321413498266Sopenharmony_ci# end func_to_tool_file
321513498266Sopenharmony_ci
321613498266Sopenharmony_ci
321713498266Sopenharmony_ci# func_convert_file_noop ARG
321813498266Sopenharmony_ci# Copy ARG to func_to_host_file_result.
321913498266Sopenharmony_cifunc_convert_file_noop ()
322013498266Sopenharmony_ci{
322113498266Sopenharmony_ci  func_to_host_file_result=$1
322213498266Sopenharmony_ci}
322313498266Sopenharmony_ci# end func_convert_file_noop
322413498266Sopenharmony_ci
322513498266Sopenharmony_ci
322613498266Sopenharmony_ci# func_convert_file_msys_to_w32 ARG
322713498266Sopenharmony_ci# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
322813498266Sopenharmony_ci# conversion to w32 is not available inside the cwrapper.  Returns result in
322913498266Sopenharmony_ci# func_to_host_file_result.
323013498266Sopenharmony_cifunc_convert_file_msys_to_w32 ()
323113498266Sopenharmony_ci{
323213498266Sopenharmony_ci  $debug_cmd
323313498266Sopenharmony_ci
323413498266Sopenharmony_ci  func_to_host_file_result=$1
323513498266Sopenharmony_ci  if test -n "$1"; then
323613498266Sopenharmony_ci    func_convert_core_msys_to_w32 "$1"
323713498266Sopenharmony_ci    func_to_host_file_result=$func_convert_core_msys_to_w32_result
323813498266Sopenharmony_ci  fi
323913498266Sopenharmony_ci  func_convert_file_check "$1" "$func_to_host_file_result"
324013498266Sopenharmony_ci}
324113498266Sopenharmony_ci# end func_convert_file_msys_to_w32
324213498266Sopenharmony_ci
324313498266Sopenharmony_ci
324413498266Sopenharmony_ci# func_convert_file_cygwin_to_w32 ARG
324513498266Sopenharmony_ci# Convert file name ARG from Cygwin to w32 format.  Returns result in
324613498266Sopenharmony_ci# func_to_host_file_result.
324713498266Sopenharmony_cifunc_convert_file_cygwin_to_w32 ()
324813498266Sopenharmony_ci{
324913498266Sopenharmony_ci  $debug_cmd
325013498266Sopenharmony_ci
325113498266Sopenharmony_ci  func_to_host_file_result=$1
325213498266Sopenharmony_ci  if test -n "$1"; then
325313498266Sopenharmony_ci    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
325413498266Sopenharmony_ci    # LT_CYGPATH in this case.
325513498266Sopenharmony_ci    func_to_host_file_result=`cygpath -m "$1"`
325613498266Sopenharmony_ci  fi
325713498266Sopenharmony_ci  func_convert_file_check "$1" "$func_to_host_file_result"
325813498266Sopenharmony_ci}
325913498266Sopenharmony_ci# end func_convert_file_cygwin_to_w32
326013498266Sopenharmony_ci
326113498266Sopenharmony_ci
326213498266Sopenharmony_ci# func_convert_file_nix_to_w32 ARG
326313498266Sopenharmony_ci# Convert file name ARG from *nix to w32 format.  Requires a wine environment
326413498266Sopenharmony_ci# and a working winepath. Returns result in func_to_host_file_result.
326513498266Sopenharmony_cifunc_convert_file_nix_to_w32 ()
326613498266Sopenharmony_ci{
326713498266Sopenharmony_ci  $debug_cmd
326813498266Sopenharmony_ci
326913498266Sopenharmony_ci  func_to_host_file_result=$1
327013498266Sopenharmony_ci  if test -n "$1"; then
327113498266Sopenharmony_ci    func_convert_core_file_wine_to_w32 "$1"
327213498266Sopenharmony_ci    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
327313498266Sopenharmony_ci  fi
327413498266Sopenharmony_ci  func_convert_file_check "$1" "$func_to_host_file_result"
327513498266Sopenharmony_ci}
327613498266Sopenharmony_ci# end func_convert_file_nix_to_w32
327713498266Sopenharmony_ci
327813498266Sopenharmony_ci
327913498266Sopenharmony_ci# func_convert_file_msys_to_cygwin ARG
328013498266Sopenharmony_ci# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
328113498266Sopenharmony_ci# Returns result in func_to_host_file_result.
328213498266Sopenharmony_cifunc_convert_file_msys_to_cygwin ()
328313498266Sopenharmony_ci{
328413498266Sopenharmony_ci  $debug_cmd
328513498266Sopenharmony_ci
328613498266Sopenharmony_ci  func_to_host_file_result=$1
328713498266Sopenharmony_ci  if test -n "$1"; then
328813498266Sopenharmony_ci    func_convert_core_msys_to_w32 "$1"
328913498266Sopenharmony_ci    func_cygpath -u "$func_convert_core_msys_to_w32_result"
329013498266Sopenharmony_ci    func_to_host_file_result=$func_cygpath_result
329113498266Sopenharmony_ci  fi
329213498266Sopenharmony_ci  func_convert_file_check "$1" "$func_to_host_file_result"
329313498266Sopenharmony_ci}
329413498266Sopenharmony_ci# end func_convert_file_msys_to_cygwin
329513498266Sopenharmony_ci
329613498266Sopenharmony_ci
329713498266Sopenharmony_ci# func_convert_file_nix_to_cygwin ARG
329813498266Sopenharmony_ci# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
329913498266Sopenharmony_ci# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
330013498266Sopenharmony_ci# in func_to_host_file_result.
330113498266Sopenharmony_cifunc_convert_file_nix_to_cygwin ()
330213498266Sopenharmony_ci{
330313498266Sopenharmony_ci  $debug_cmd
330413498266Sopenharmony_ci
330513498266Sopenharmony_ci  func_to_host_file_result=$1
330613498266Sopenharmony_ci  if test -n "$1"; then
330713498266Sopenharmony_ci    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
330813498266Sopenharmony_ci    func_convert_core_file_wine_to_w32 "$1"
330913498266Sopenharmony_ci    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
331013498266Sopenharmony_ci    func_to_host_file_result=$func_cygpath_result
331113498266Sopenharmony_ci  fi
331213498266Sopenharmony_ci  func_convert_file_check "$1" "$func_to_host_file_result"
331313498266Sopenharmony_ci}
331413498266Sopenharmony_ci# end func_convert_file_nix_to_cygwin
331513498266Sopenharmony_ci
331613498266Sopenharmony_ci
331713498266Sopenharmony_ci#############################################
331813498266Sopenharmony_ci# $build to $host PATH CONVERSION FUNCTIONS #
331913498266Sopenharmony_ci#############################################
332013498266Sopenharmony_ci# invoked via '$to_host_path_cmd ARG'
332113498266Sopenharmony_ci#
332213498266Sopenharmony_ci# In each case, ARG is the path to be converted from $build to $host format.
332313498266Sopenharmony_ci# The result will be available in $func_to_host_path_result.
332413498266Sopenharmony_ci#
332513498266Sopenharmony_ci# Path separators are also converted from $build format to $host format.  If
332613498266Sopenharmony_ci# ARG begins or ends with a path separator character, it is preserved (but
332713498266Sopenharmony_ci# converted to $host format) on output.
332813498266Sopenharmony_ci#
332913498266Sopenharmony_ci# All path conversion functions are named using the following convention:
333013498266Sopenharmony_ci#   file name conversion function    : func_convert_file_X_to_Y ()
333113498266Sopenharmony_ci#   path conversion function         : func_convert_path_X_to_Y ()
333213498266Sopenharmony_ci# where, for any given $build/$host combination the 'X_to_Y' value is the
333313498266Sopenharmony_ci# same.  If conversion functions are added for new $build/$host combinations,
333413498266Sopenharmony_ci# the two new functions must follow this pattern, or func_init_to_host_path_cmd
333513498266Sopenharmony_ci# will break.
333613498266Sopenharmony_ci
333713498266Sopenharmony_ci
333813498266Sopenharmony_ci# func_init_to_host_path_cmd
333913498266Sopenharmony_ci# Ensures that function "pointer" variable $to_host_path_cmd is set to the
334013498266Sopenharmony_ci# appropriate value, based on the value of $to_host_file_cmd.
334113498266Sopenharmony_cito_host_path_cmd=
334213498266Sopenharmony_cifunc_init_to_host_path_cmd ()
334313498266Sopenharmony_ci{
334413498266Sopenharmony_ci  $debug_cmd
334513498266Sopenharmony_ci
334613498266Sopenharmony_ci  if test -z "$to_host_path_cmd"; then
334713498266Sopenharmony_ci    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
334813498266Sopenharmony_ci    to_host_path_cmd=func_convert_path_$func_stripname_result
334913498266Sopenharmony_ci  fi
335013498266Sopenharmony_ci}
335113498266Sopenharmony_ci
335213498266Sopenharmony_ci
335313498266Sopenharmony_ci# func_to_host_path ARG
335413498266Sopenharmony_ci# Converts the path ARG from $build format to $host format. Return result
335513498266Sopenharmony_ci# in func_to_host_path_result.
335613498266Sopenharmony_cifunc_to_host_path ()
335713498266Sopenharmony_ci{
335813498266Sopenharmony_ci  $debug_cmd
335913498266Sopenharmony_ci
336013498266Sopenharmony_ci  func_init_to_host_path_cmd
336113498266Sopenharmony_ci  $to_host_path_cmd "$1"
336213498266Sopenharmony_ci}
336313498266Sopenharmony_ci# end func_to_host_path
336413498266Sopenharmony_ci
336513498266Sopenharmony_ci
336613498266Sopenharmony_ci# func_convert_path_noop ARG
336713498266Sopenharmony_ci# Copy ARG to func_to_host_path_result.
336813498266Sopenharmony_cifunc_convert_path_noop ()
336913498266Sopenharmony_ci{
337013498266Sopenharmony_ci  func_to_host_path_result=$1
337113498266Sopenharmony_ci}
337213498266Sopenharmony_ci# end func_convert_path_noop
337313498266Sopenharmony_ci
337413498266Sopenharmony_ci
337513498266Sopenharmony_ci# func_convert_path_msys_to_w32 ARG
337613498266Sopenharmony_ci# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
337713498266Sopenharmony_ci# conversion to w32 is not available inside the cwrapper.  Returns result in
337813498266Sopenharmony_ci# func_to_host_path_result.
337913498266Sopenharmony_cifunc_convert_path_msys_to_w32 ()
338013498266Sopenharmony_ci{
338113498266Sopenharmony_ci  $debug_cmd
338213498266Sopenharmony_ci
338313498266Sopenharmony_ci  func_to_host_path_result=$1
338413498266Sopenharmony_ci  if test -n "$1"; then
338513498266Sopenharmony_ci    # Remove leading and trailing path separator characters from ARG.  MSYS
338613498266Sopenharmony_ci    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
338713498266Sopenharmony_ci    # and winepath ignores them completely.
338813498266Sopenharmony_ci    func_stripname : : "$1"
338913498266Sopenharmony_ci    func_to_host_path_tmp1=$func_stripname_result
339013498266Sopenharmony_ci    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
339113498266Sopenharmony_ci    func_to_host_path_result=$func_convert_core_msys_to_w32_result
339213498266Sopenharmony_ci    func_convert_path_check : ";" \
339313498266Sopenharmony_ci      "$func_to_host_path_tmp1" "$func_to_host_path_result"
339413498266Sopenharmony_ci    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
339513498266Sopenharmony_ci  fi
339613498266Sopenharmony_ci}
339713498266Sopenharmony_ci# end func_convert_path_msys_to_w32
339813498266Sopenharmony_ci
339913498266Sopenharmony_ci
340013498266Sopenharmony_ci# func_convert_path_cygwin_to_w32 ARG
340113498266Sopenharmony_ci# Convert path ARG from Cygwin to w32 format.  Returns result in
340213498266Sopenharmony_ci# func_to_host_file_result.
340313498266Sopenharmony_cifunc_convert_path_cygwin_to_w32 ()
340413498266Sopenharmony_ci{
340513498266Sopenharmony_ci  $debug_cmd
340613498266Sopenharmony_ci
340713498266Sopenharmony_ci  func_to_host_path_result=$1
340813498266Sopenharmony_ci  if test -n "$1"; then
340913498266Sopenharmony_ci    # See func_convert_path_msys_to_w32:
341013498266Sopenharmony_ci    func_stripname : : "$1"
341113498266Sopenharmony_ci    func_to_host_path_tmp1=$func_stripname_result
341213498266Sopenharmony_ci    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
341313498266Sopenharmony_ci    func_convert_path_check : ";" \
341413498266Sopenharmony_ci      "$func_to_host_path_tmp1" "$func_to_host_path_result"
341513498266Sopenharmony_ci    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
341613498266Sopenharmony_ci  fi
341713498266Sopenharmony_ci}
341813498266Sopenharmony_ci# end func_convert_path_cygwin_to_w32
341913498266Sopenharmony_ci
342013498266Sopenharmony_ci
342113498266Sopenharmony_ci# func_convert_path_nix_to_w32 ARG
342213498266Sopenharmony_ci# Convert path ARG from *nix to w32 format.  Requires a wine environment and
342313498266Sopenharmony_ci# a working winepath.  Returns result in func_to_host_file_result.
342413498266Sopenharmony_cifunc_convert_path_nix_to_w32 ()
342513498266Sopenharmony_ci{
342613498266Sopenharmony_ci  $debug_cmd
342713498266Sopenharmony_ci
342813498266Sopenharmony_ci  func_to_host_path_result=$1
342913498266Sopenharmony_ci  if test -n "$1"; then
343013498266Sopenharmony_ci    # See func_convert_path_msys_to_w32:
343113498266Sopenharmony_ci    func_stripname : : "$1"
343213498266Sopenharmony_ci    func_to_host_path_tmp1=$func_stripname_result
343313498266Sopenharmony_ci    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
343413498266Sopenharmony_ci    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
343513498266Sopenharmony_ci    func_convert_path_check : ";" \
343613498266Sopenharmony_ci      "$func_to_host_path_tmp1" "$func_to_host_path_result"
343713498266Sopenharmony_ci    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
343813498266Sopenharmony_ci  fi
343913498266Sopenharmony_ci}
344013498266Sopenharmony_ci# end func_convert_path_nix_to_w32
344113498266Sopenharmony_ci
344213498266Sopenharmony_ci
344313498266Sopenharmony_ci# func_convert_path_msys_to_cygwin ARG
344413498266Sopenharmony_ci# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
344513498266Sopenharmony_ci# Returns result in func_to_host_file_result.
344613498266Sopenharmony_cifunc_convert_path_msys_to_cygwin ()
344713498266Sopenharmony_ci{
344813498266Sopenharmony_ci  $debug_cmd
344913498266Sopenharmony_ci
345013498266Sopenharmony_ci  func_to_host_path_result=$1
345113498266Sopenharmony_ci  if test -n "$1"; then
345213498266Sopenharmony_ci    # See func_convert_path_msys_to_w32:
345313498266Sopenharmony_ci    func_stripname : : "$1"
345413498266Sopenharmony_ci    func_to_host_path_tmp1=$func_stripname_result
345513498266Sopenharmony_ci    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
345613498266Sopenharmony_ci    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
345713498266Sopenharmony_ci    func_to_host_path_result=$func_cygpath_result
345813498266Sopenharmony_ci    func_convert_path_check : : \
345913498266Sopenharmony_ci      "$func_to_host_path_tmp1" "$func_to_host_path_result"
346013498266Sopenharmony_ci    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
346113498266Sopenharmony_ci  fi
346213498266Sopenharmony_ci}
346313498266Sopenharmony_ci# end func_convert_path_msys_to_cygwin
346413498266Sopenharmony_ci
346513498266Sopenharmony_ci
346613498266Sopenharmony_ci# func_convert_path_nix_to_cygwin ARG
346713498266Sopenharmony_ci# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
346813498266Sopenharmony_ci# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
346913498266Sopenharmony_ci# func_to_host_file_result.
347013498266Sopenharmony_cifunc_convert_path_nix_to_cygwin ()
347113498266Sopenharmony_ci{
347213498266Sopenharmony_ci  $debug_cmd
347313498266Sopenharmony_ci
347413498266Sopenharmony_ci  func_to_host_path_result=$1
347513498266Sopenharmony_ci  if test -n "$1"; then
347613498266Sopenharmony_ci    # Remove leading and trailing path separator characters from
347713498266Sopenharmony_ci    # ARG. msys behavior is inconsistent here, cygpath turns them
347813498266Sopenharmony_ci    # into '.;' and ';.', and winepath ignores them completely.
347913498266Sopenharmony_ci    func_stripname : : "$1"
348013498266Sopenharmony_ci    func_to_host_path_tmp1=$func_stripname_result
348113498266Sopenharmony_ci    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
348213498266Sopenharmony_ci    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
348313498266Sopenharmony_ci    func_to_host_path_result=$func_cygpath_result
348413498266Sopenharmony_ci    func_convert_path_check : : \
348513498266Sopenharmony_ci      "$func_to_host_path_tmp1" "$func_to_host_path_result"
348613498266Sopenharmony_ci    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
348713498266Sopenharmony_ci  fi
348813498266Sopenharmony_ci}
348913498266Sopenharmony_ci# end func_convert_path_nix_to_cygwin
349013498266Sopenharmony_ci
349113498266Sopenharmony_ci
349213498266Sopenharmony_ci# func_dll_def_p FILE
349313498266Sopenharmony_ci# True iff FILE is a Windows DLL '.def' file.
349413498266Sopenharmony_ci# Keep in sync with _LT_DLL_DEF_P in libtool.m4
349513498266Sopenharmony_cifunc_dll_def_p ()
349613498266Sopenharmony_ci{
349713498266Sopenharmony_ci  $debug_cmd
349813498266Sopenharmony_ci
349913498266Sopenharmony_ci  func_dll_def_p_tmp=`$SED -n \
350013498266Sopenharmony_ci    -e 's/^[	 ]*//' \
350113498266Sopenharmony_ci    -e '/^\(;.*\)*$/d' \
350213498266Sopenharmony_ci    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
350313498266Sopenharmony_ci    -e q \
350413498266Sopenharmony_ci    "$1"`
350513498266Sopenharmony_ci  test DEF = "$func_dll_def_p_tmp"
350613498266Sopenharmony_ci}
350713498266Sopenharmony_ci
350813498266Sopenharmony_ci
350913498266Sopenharmony_ci# func_mode_compile arg...
351013498266Sopenharmony_cifunc_mode_compile ()
351113498266Sopenharmony_ci{
351213498266Sopenharmony_ci    $debug_cmd
351313498266Sopenharmony_ci
351413498266Sopenharmony_ci    # Get the compilation command and the source file.
351513498266Sopenharmony_ci    base_compile=
351613498266Sopenharmony_ci    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
351713498266Sopenharmony_ci    suppress_opt=yes
351813498266Sopenharmony_ci    suppress_output=
351913498266Sopenharmony_ci    arg_mode=normal
352013498266Sopenharmony_ci    libobj=
352113498266Sopenharmony_ci    later=
352213498266Sopenharmony_ci    pie_flag=
352313498266Sopenharmony_ci
352413498266Sopenharmony_ci    for arg
352513498266Sopenharmony_ci    do
352613498266Sopenharmony_ci      case $arg_mode in
352713498266Sopenharmony_ci      arg  )
352813498266Sopenharmony_ci	# do not "continue".  Instead, add this to base_compile
352913498266Sopenharmony_ci	lastarg=$arg
353013498266Sopenharmony_ci	arg_mode=normal
353113498266Sopenharmony_ci	;;
353213498266Sopenharmony_ci
353313498266Sopenharmony_ci      target )
353413498266Sopenharmony_ci	libobj=$arg
353513498266Sopenharmony_ci	arg_mode=normal
353613498266Sopenharmony_ci	continue
353713498266Sopenharmony_ci	;;
353813498266Sopenharmony_ci
353913498266Sopenharmony_ci      normal )
354013498266Sopenharmony_ci	# Accept any command-line options.
354113498266Sopenharmony_ci	case $arg in
354213498266Sopenharmony_ci	-o)
354313498266Sopenharmony_ci	  test -n "$libobj" && \
354413498266Sopenharmony_ci	    func_fatal_error "you cannot specify '-o' more than once"
354513498266Sopenharmony_ci	  arg_mode=target
354613498266Sopenharmony_ci	  continue
354713498266Sopenharmony_ci	  ;;
354813498266Sopenharmony_ci
354913498266Sopenharmony_ci	-pie | -fpie | -fPIE)
355013498266Sopenharmony_ci          func_append pie_flag " $arg"
355113498266Sopenharmony_ci	  continue
355213498266Sopenharmony_ci	  ;;
355313498266Sopenharmony_ci
355413498266Sopenharmony_ci	-shared | -static | -prefer-pic | -prefer-non-pic)
355513498266Sopenharmony_ci	  func_append later " $arg"
355613498266Sopenharmony_ci	  continue
355713498266Sopenharmony_ci	  ;;
355813498266Sopenharmony_ci
355913498266Sopenharmony_ci	-no-suppress)
356013498266Sopenharmony_ci	  suppress_opt=no
356113498266Sopenharmony_ci	  continue
356213498266Sopenharmony_ci	  ;;
356313498266Sopenharmony_ci
356413498266Sopenharmony_ci	-Xcompiler)
356513498266Sopenharmony_ci	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
356613498266Sopenharmony_ci	  continue      #  The current "srcfile" will either be retained or
356713498266Sopenharmony_ci	  ;;            #  replaced later.  I would guess that would be a bug.
356813498266Sopenharmony_ci
356913498266Sopenharmony_ci	-Wc,*)
357013498266Sopenharmony_ci	  func_stripname '-Wc,' '' "$arg"
357113498266Sopenharmony_ci	  args=$func_stripname_result
357213498266Sopenharmony_ci	  lastarg=
357313498266Sopenharmony_ci	  save_ifs=$IFS; IFS=,
357413498266Sopenharmony_ci	  for arg in $args; do
357513498266Sopenharmony_ci	    IFS=$save_ifs
357613498266Sopenharmony_ci	    func_append_quoted lastarg "$arg"
357713498266Sopenharmony_ci	  done
357813498266Sopenharmony_ci	  IFS=$save_ifs
357913498266Sopenharmony_ci	  func_stripname ' ' '' "$lastarg"
358013498266Sopenharmony_ci	  lastarg=$func_stripname_result
358113498266Sopenharmony_ci
358213498266Sopenharmony_ci	  # Add the arguments to base_compile.
358313498266Sopenharmony_ci	  func_append base_compile " $lastarg"
358413498266Sopenharmony_ci	  continue
358513498266Sopenharmony_ci	  ;;
358613498266Sopenharmony_ci
358713498266Sopenharmony_ci	*)
358813498266Sopenharmony_ci	  # Accept the current argument as the source file.
358913498266Sopenharmony_ci	  # The previous "srcfile" becomes the current argument.
359013498266Sopenharmony_ci	  #
359113498266Sopenharmony_ci	  lastarg=$srcfile
359213498266Sopenharmony_ci	  srcfile=$arg
359313498266Sopenharmony_ci	  ;;
359413498266Sopenharmony_ci	esac  #  case $arg
359513498266Sopenharmony_ci	;;
359613498266Sopenharmony_ci      esac    #  case $arg_mode
359713498266Sopenharmony_ci
359813498266Sopenharmony_ci      # Aesthetically quote the previous argument.
359913498266Sopenharmony_ci      func_append_quoted base_compile "$lastarg"
360013498266Sopenharmony_ci    done # for arg
360113498266Sopenharmony_ci
360213498266Sopenharmony_ci    case $arg_mode in
360313498266Sopenharmony_ci    arg)
360413498266Sopenharmony_ci      func_fatal_error "you must specify an argument for -Xcompile"
360513498266Sopenharmony_ci      ;;
360613498266Sopenharmony_ci    target)
360713498266Sopenharmony_ci      func_fatal_error "you must specify a target with '-o'"
360813498266Sopenharmony_ci      ;;
360913498266Sopenharmony_ci    *)
361013498266Sopenharmony_ci      # Get the name of the library object.
361113498266Sopenharmony_ci      test -z "$libobj" && {
361213498266Sopenharmony_ci	func_basename "$srcfile"
361313498266Sopenharmony_ci	libobj=$func_basename_result
361413498266Sopenharmony_ci      }
361513498266Sopenharmony_ci      ;;
361613498266Sopenharmony_ci    esac
361713498266Sopenharmony_ci
361813498266Sopenharmony_ci    # Recognize several different file suffixes.
361913498266Sopenharmony_ci    # If the user specifies -o file.o, it is replaced with file.lo
362013498266Sopenharmony_ci    case $libobj in
362113498266Sopenharmony_ci    *.[cCFSifmso] | \
362213498266Sopenharmony_ci    *.ada | *.adb | *.ads | *.asm | \
362313498266Sopenharmony_ci    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
362413498266Sopenharmony_ci    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
362513498266Sopenharmony_ci      func_xform "$libobj"
362613498266Sopenharmony_ci      libobj=$func_xform_result
362713498266Sopenharmony_ci      ;;
362813498266Sopenharmony_ci    esac
362913498266Sopenharmony_ci
363013498266Sopenharmony_ci    case $libobj in
363113498266Sopenharmony_ci    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
363213498266Sopenharmony_ci    *)
363313498266Sopenharmony_ci      func_fatal_error "cannot determine name of library object from '$libobj'"
363413498266Sopenharmony_ci      ;;
363513498266Sopenharmony_ci    esac
363613498266Sopenharmony_ci
363713498266Sopenharmony_ci    func_infer_tag $base_compile
363813498266Sopenharmony_ci
363913498266Sopenharmony_ci    for arg in $later; do
364013498266Sopenharmony_ci      case $arg in
364113498266Sopenharmony_ci      -shared)
364213498266Sopenharmony_ci	test yes = "$build_libtool_libs" \
364313498266Sopenharmony_ci	  || func_fatal_configuration "cannot build a shared library"
364413498266Sopenharmony_ci	build_old_libs=no
364513498266Sopenharmony_ci	continue
364613498266Sopenharmony_ci	;;
364713498266Sopenharmony_ci
364813498266Sopenharmony_ci      -static)
364913498266Sopenharmony_ci	build_libtool_libs=no
365013498266Sopenharmony_ci	build_old_libs=yes
365113498266Sopenharmony_ci	continue
365213498266Sopenharmony_ci	;;
365313498266Sopenharmony_ci
365413498266Sopenharmony_ci      -prefer-pic)
365513498266Sopenharmony_ci	pic_mode=yes
365613498266Sopenharmony_ci	continue
365713498266Sopenharmony_ci	;;
365813498266Sopenharmony_ci
365913498266Sopenharmony_ci      -prefer-non-pic)
366013498266Sopenharmony_ci	pic_mode=no
366113498266Sopenharmony_ci	continue
366213498266Sopenharmony_ci	;;
366313498266Sopenharmony_ci      esac
366413498266Sopenharmony_ci    done
366513498266Sopenharmony_ci
366613498266Sopenharmony_ci    func_quote_arg pretty "$libobj"
366713498266Sopenharmony_ci    test "X$libobj" != "X$func_quote_arg_result" \
366813498266Sopenharmony_ci      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
366913498266Sopenharmony_ci      && func_warning "libobj name '$libobj' may not contain shell special characters."
367013498266Sopenharmony_ci    func_dirname_and_basename "$obj" "/" ""
367113498266Sopenharmony_ci    objname=$func_basename_result
367213498266Sopenharmony_ci    xdir=$func_dirname_result
367313498266Sopenharmony_ci    lobj=$xdir$objdir/$objname
367413498266Sopenharmony_ci
367513498266Sopenharmony_ci    test -z "$base_compile" && \
367613498266Sopenharmony_ci      func_fatal_help "you must specify a compilation command"
367713498266Sopenharmony_ci
367813498266Sopenharmony_ci    # Delete any leftover library objects.
367913498266Sopenharmony_ci    if test yes = "$build_old_libs"; then
368013498266Sopenharmony_ci      removelist="$obj $lobj $libobj ${libobj}T"
368113498266Sopenharmony_ci    else
368213498266Sopenharmony_ci      removelist="$lobj $libobj ${libobj}T"
368313498266Sopenharmony_ci    fi
368413498266Sopenharmony_ci
368513498266Sopenharmony_ci    # On Cygwin there's no "real" PIC flag so we must build both object types
368613498266Sopenharmony_ci    case $host_os in
368713498266Sopenharmony_ci    cygwin* | mingw* | pw32* | os2* | cegcc*)
368813498266Sopenharmony_ci      pic_mode=default
368913498266Sopenharmony_ci      ;;
369013498266Sopenharmony_ci    esac
369113498266Sopenharmony_ci    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
369213498266Sopenharmony_ci      # non-PIC code in shared libraries is not supported
369313498266Sopenharmony_ci      pic_mode=default
369413498266Sopenharmony_ci    fi
369513498266Sopenharmony_ci
369613498266Sopenharmony_ci    # Calculate the filename of the output object if compiler does
369713498266Sopenharmony_ci    # not support -o with -c
369813498266Sopenharmony_ci    if test no = "$compiler_c_o"; then
369913498266Sopenharmony_ci      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
370013498266Sopenharmony_ci      lockfile=$output_obj.lock
370113498266Sopenharmony_ci    else
370213498266Sopenharmony_ci      output_obj=
370313498266Sopenharmony_ci      need_locks=no
370413498266Sopenharmony_ci      lockfile=
370513498266Sopenharmony_ci    fi
370613498266Sopenharmony_ci
370713498266Sopenharmony_ci    # Lock this critical section if it is needed
370813498266Sopenharmony_ci    # We use this script file to make the link, it avoids creating a new file
370913498266Sopenharmony_ci    if test yes = "$need_locks"; then
371013498266Sopenharmony_ci      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
371113498266Sopenharmony_ci	func_echo "Waiting for $lockfile to be removed"
371213498266Sopenharmony_ci	sleep 2
371313498266Sopenharmony_ci      done
371413498266Sopenharmony_ci    elif test warn = "$need_locks"; then
371513498266Sopenharmony_ci      if test -f "$lockfile"; then
371613498266Sopenharmony_ci	$ECHO "\
371713498266Sopenharmony_ci*** ERROR, $lockfile exists and contains:
371813498266Sopenharmony_ci`cat $lockfile 2>/dev/null`
371913498266Sopenharmony_ci
372013498266Sopenharmony_ciThis indicates that another process is trying to use the same
372113498266Sopenharmony_citemporary object file, and libtool could not work around it because
372213498266Sopenharmony_ciyour compiler does not support '-c' and '-o' together.  If you
372313498266Sopenharmony_cirepeat this compilation, it may succeed, by chance, but you had better
372413498266Sopenharmony_ciavoid parallel builds (make -j) in this platform, or get a better
372513498266Sopenharmony_cicompiler."
372613498266Sopenharmony_ci
372713498266Sopenharmony_ci	$opt_dry_run || $RM $removelist
372813498266Sopenharmony_ci	exit $EXIT_FAILURE
372913498266Sopenharmony_ci      fi
373013498266Sopenharmony_ci      func_append removelist " $output_obj"
373113498266Sopenharmony_ci      $ECHO "$srcfile" > "$lockfile"
373213498266Sopenharmony_ci    fi
373313498266Sopenharmony_ci
373413498266Sopenharmony_ci    $opt_dry_run || $RM $removelist
373513498266Sopenharmony_ci    func_append removelist " $lockfile"
373613498266Sopenharmony_ci    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
373713498266Sopenharmony_ci
373813498266Sopenharmony_ci    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
373913498266Sopenharmony_ci    srcfile=$func_to_tool_file_result
374013498266Sopenharmony_ci    func_quote_arg pretty "$srcfile"
374113498266Sopenharmony_ci    qsrcfile=$func_quote_arg_result
374213498266Sopenharmony_ci
374313498266Sopenharmony_ci    # Only build a PIC object if we are building libtool libraries.
374413498266Sopenharmony_ci    if test yes = "$build_libtool_libs"; then
374513498266Sopenharmony_ci      # Without this assignment, base_compile gets emptied.
374613498266Sopenharmony_ci      fbsd_hideous_sh_bug=$base_compile
374713498266Sopenharmony_ci
374813498266Sopenharmony_ci      if test no != "$pic_mode"; then
374913498266Sopenharmony_ci	command="$base_compile $qsrcfile $pic_flag"
375013498266Sopenharmony_ci      else
375113498266Sopenharmony_ci	# Don't build PIC code
375213498266Sopenharmony_ci	command="$base_compile $qsrcfile"
375313498266Sopenharmony_ci      fi
375413498266Sopenharmony_ci
375513498266Sopenharmony_ci      func_mkdir_p "$xdir$objdir"
375613498266Sopenharmony_ci
375713498266Sopenharmony_ci      if test -z "$output_obj"; then
375813498266Sopenharmony_ci	# Place PIC objects in $objdir
375913498266Sopenharmony_ci	func_append command " -o $lobj"
376013498266Sopenharmony_ci      fi
376113498266Sopenharmony_ci
376213498266Sopenharmony_ci      func_show_eval_locale "$command"	\
376313498266Sopenharmony_ci          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
376413498266Sopenharmony_ci
376513498266Sopenharmony_ci      if test warn = "$need_locks" &&
376613498266Sopenharmony_ci	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
376713498266Sopenharmony_ci	$ECHO "\
376813498266Sopenharmony_ci*** ERROR, $lockfile contains:
376913498266Sopenharmony_ci`cat $lockfile 2>/dev/null`
377013498266Sopenharmony_ci
377113498266Sopenharmony_cibut it should contain:
377213498266Sopenharmony_ci$srcfile
377313498266Sopenharmony_ci
377413498266Sopenharmony_ciThis indicates that another process is trying to use the same
377513498266Sopenharmony_citemporary object file, and libtool could not work around it because
377613498266Sopenharmony_ciyour compiler does not support '-c' and '-o' together.  If you
377713498266Sopenharmony_cirepeat this compilation, it may succeed, by chance, but you had better
377813498266Sopenharmony_ciavoid parallel builds (make -j) in this platform, or get a better
377913498266Sopenharmony_cicompiler."
378013498266Sopenharmony_ci
378113498266Sopenharmony_ci	$opt_dry_run || $RM $removelist
378213498266Sopenharmony_ci	exit $EXIT_FAILURE
378313498266Sopenharmony_ci      fi
378413498266Sopenharmony_ci
378513498266Sopenharmony_ci      # Just move the object if needed, then go on to compile the next one
378613498266Sopenharmony_ci      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
378713498266Sopenharmony_ci	func_show_eval '$MV "$output_obj" "$lobj"' \
378813498266Sopenharmony_ci	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
378913498266Sopenharmony_ci      fi
379013498266Sopenharmony_ci
379113498266Sopenharmony_ci      # Allow error messages only from the first compilation.
379213498266Sopenharmony_ci      if test yes = "$suppress_opt"; then
379313498266Sopenharmony_ci	suppress_output=' >/dev/null 2>&1'
379413498266Sopenharmony_ci      fi
379513498266Sopenharmony_ci    fi
379613498266Sopenharmony_ci
379713498266Sopenharmony_ci    # Only build a position-dependent object if we build old libraries.
379813498266Sopenharmony_ci    if test yes = "$build_old_libs"; then
379913498266Sopenharmony_ci      if test yes != "$pic_mode"; then
380013498266Sopenharmony_ci	# Don't build PIC code
380113498266Sopenharmony_ci	command="$base_compile $qsrcfile$pie_flag"
380213498266Sopenharmony_ci      else
380313498266Sopenharmony_ci	command="$base_compile $qsrcfile $pic_flag"
380413498266Sopenharmony_ci      fi
380513498266Sopenharmony_ci      if test yes = "$compiler_c_o"; then
380613498266Sopenharmony_ci	func_append command " -o $obj"
380713498266Sopenharmony_ci      fi
380813498266Sopenharmony_ci
380913498266Sopenharmony_ci      # Suppress compiler output if we already did a PIC compilation.
381013498266Sopenharmony_ci      func_append command "$suppress_output"
381113498266Sopenharmony_ci      func_show_eval_locale "$command" \
381213498266Sopenharmony_ci        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
381313498266Sopenharmony_ci
381413498266Sopenharmony_ci      if test warn = "$need_locks" &&
381513498266Sopenharmony_ci	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
381613498266Sopenharmony_ci	$ECHO "\
381713498266Sopenharmony_ci*** ERROR, $lockfile contains:
381813498266Sopenharmony_ci`cat $lockfile 2>/dev/null`
381913498266Sopenharmony_ci
382013498266Sopenharmony_cibut it should contain:
382113498266Sopenharmony_ci$srcfile
382213498266Sopenharmony_ci
382313498266Sopenharmony_ciThis indicates that another process is trying to use the same
382413498266Sopenharmony_citemporary object file, and libtool could not work around it because
382513498266Sopenharmony_ciyour compiler does not support '-c' and '-o' together.  If you
382613498266Sopenharmony_cirepeat this compilation, it may succeed, by chance, but you had better
382713498266Sopenharmony_ciavoid parallel builds (make -j) in this platform, or get a better
382813498266Sopenharmony_cicompiler."
382913498266Sopenharmony_ci
383013498266Sopenharmony_ci	$opt_dry_run || $RM $removelist
383113498266Sopenharmony_ci	exit $EXIT_FAILURE
383213498266Sopenharmony_ci      fi
383313498266Sopenharmony_ci
383413498266Sopenharmony_ci      # Just move the object if needed
383513498266Sopenharmony_ci      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
383613498266Sopenharmony_ci	func_show_eval '$MV "$output_obj" "$obj"' \
383713498266Sopenharmony_ci	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
383813498266Sopenharmony_ci      fi
383913498266Sopenharmony_ci    fi
384013498266Sopenharmony_ci
384113498266Sopenharmony_ci    $opt_dry_run || {
384213498266Sopenharmony_ci      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
384313498266Sopenharmony_ci
384413498266Sopenharmony_ci      # Unlock the critical section if it was locked
384513498266Sopenharmony_ci      if test no != "$need_locks"; then
384613498266Sopenharmony_ci	removelist=$lockfile
384713498266Sopenharmony_ci        $RM "$lockfile"
384813498266Sopenharmony_ci      fi
384913498266Sopenharmony_ci    }
385013498266Sopenharmony_ci
385113498266Sopenharmony_ci    exit $EXIT_SUCCESS
385213498266Sopenharmony_ci}
385313498266Sopenharmony_ci
385413498266Sopenharmony_ci$opt_help || {
385513498266Sopenharmony_ci  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
385613498266Sopenharmony_ci}
385713498266Sopenharmony_ci
385813498266Sopenharmony_cifunc_mode_help ()
385913498266Sopenharmony_ci{
386013498266Sopenharmony_ci    # We need to display help for each of the modes.
386113498266Sopenharmony_ci    case $opt_mode in
386213498266Sopenharmony_ci      "")
386313498266Sopenharmony_ci        # Generic help is extracted from the usage comments
386413498266Sopenharmony_ci        # at the start of this file.
386513498266Sopenharmony_ci        func_help
386613498266Sopenharmony_ci        ;;
386713498266Sopenharmony_ci
386813498266Sopenharmony_ci      clean)
386913498266Sopenharmony_ci        $ECHO \
387013498266Sopenharmony_ci"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
387113498266Sopenharmony_ci
387213498266Sopenharmony_ciRemove files from the build directory.
387313498266Sopenharmony_ci
387413498266Sopenharmony_ciRM is the name of the program to use to delete files associated with each FILE
387513498266Sopenharmony_ci(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
387613498266Sopenharmony_cito RM.
387713498266Sopenharmony_ci
387813498266Sopenharmony_ciIf FILE is a libtool library, object or program, all the files associated
387913498266Sopenharmony_ciwith it are deleted. Otherwise, only FILE itself is deleted using RM."
388013498266Sopenharmony_ci        ;;
388113498266Sopenharmony_ci
388213498266Sopenharmony_ci      compile)
388313498266Sopenharmony_ci      $ECHO \
388413498266Sopenharmony_ci"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
388513498266Sopenharmony_ci
388613498266Sopenharmony_ciCompile a source file into a libtool library object.
388713498266Sopenharmony_ci
388813498266Sopenharmony_ciThis mode accepts the following additional options:
388913498266Sopenharmony_ci
389013498266Sopenharmony_ci  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
389113498266Sopenharmony_ci  -no-suppress      do not suppress compiler output for multiple passes
389213498266Sopenharmony_ci  -prefer-pic       try to build PIC objects only
389313498266Sopenharmony_ci  -prefer-non-pic   try to build non-PIC objects only
389413498266Sopenharmony_ci  -shared           do not build a '.o' file suitable for static linking
389513498266Sopenharmony_ci  -static           only build a '.o' file suitable for static linking
389613498266Sopenharmony_ci  -Wc,FLAG
389713498266Sopenharmony_ci  -Xcompiler FLAG   pass FLAG directly to the compiler
389813498266Sopenharmony_ci
389913498266Sopenharmony_ciCOMPILE-COMMAND is a command to be used in creating a 'standard' object file
390013498266Sopenharmony_cifrom the given SOURCEFILE.
390113498266Sopenharmony_ci
390213498266Sopenharmony_ciThe output file name is determined by removing the directory component from
390313498266Sopenharmony_ciSOURCEFILE, then substituting the C source code suffix '.c' with the
390413498266Sopenharmony_cilibrary object suffix, '.lo'."
390513498266Sopenharmony_ci        ;;
390613498266Sopenharmony_ci
390713498266Sopenharmony_ci      execute)
390813498266Sopenharmony_ci        $ECHO \
390913498266Sopenharmony_ci"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
391013498266Sopenharmony_ci
391113498266Sopenharmony_ciAutomatically set library path, then run a program.
391213498266Sopenharmony_ci
391313498266Sopenharmony_ciThis mode accepts the following additional options:
391413498266Sopenharmony_ci
391513498266Sopenharmony_ci  -dlopen FILE      add the directory containing FILE to the library path
391613498266Sopenharmony_ci
391713498266Sopenharmony_ciThis mode sets the library path environment variable according to '-dlopen'
391813498266Sopenharmony_ciflags.
391913498266Sopenharmony_ci
392013498266Sopenharmony_ciIf any of the ARGS are libtool executable wrappers, then they are translated
392113498266Sopenharmony_ciinto their corresponding uninstalled binary, and any of their required library
392213498266Sopenharmony_cidirectories are added to the library path.
392313498266Sopenharmony_ci
392413498266Sopenharmony_ciThen, COMMAND is executed, with ARGS as arguments."
392513498266Sopenharmony_ci        ;;
392613498266Sopenharmony_ci
392713498266Sopenharmony_ci      finish)
392813498266Sopenharmony_ci        $ECHO \
392913498266Sopenharmony_ci"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
393013498266Sopenharmony_ci
393113498266Sopenharmony_ciComplete the installation of libtool libraries.
393213498266Sopenharmony_ci
393313498266Sopenharmony_ciEach LIBDIR is a directory that contains libtool libraries.
393413498266Sopenharmony_ci
393513498266Sopenharmony_ciThe commands that this mode executes may require superuser privileges.  Use
393613498266Sopenharmony_cithe '--dry-run' option if you just want to see what would be executed."
393713498266Sopenharmony_ci        ;;
393813498266Sopenharmony_ci
393913498266Sopenharmony_ci      install)
394013498266Sopenharmony_ci        $ECHO \
394113498266Sopenharmony_ci"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
394213498266Sopenharmony_ci
394313498266Sopenharmony_ciInstall executables or libraries.
394413498266Sopenharmony_ci
394513498266Sopenharmony_ciINSTALL-COMMAND is the installation command.  The first component should be
394613498266Sopenharmony_cieither the 'install' or 'cp' program.
394713498266Sopenharmony_ci
394813498266Sopenharmony_ciThe following components of INSTALL-COMMAND are treated specially:
394913498266Sopenharmony_ci
395013498266Sopenharmony_ci  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
395113498266Sopenharmony_ci
395213498266Sopenharmony_ciThe rest of the components are interpreted as arguments to that command (only
395313498266Sopenharmony_ciBSD-compatible install options are recognized)."
395413498266Sopenharmony_ci        ;;
395513498266Sopenharmony_ci
395613498266Sopenharmony_ci      link)
395713498266Sopenharmony_ci        $ECHO \
395813498266Sopenharmony_ci"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
395913498266Sopenharmony_ci
396013498266Sopenharmony_ciLink object files or libraries together to form another library, or to
396113498266Sopenharmony_cicreate an executable program.
396213498266Sopenharmony_ci
396313498266Sopenharmony_ciLINK-COMMAND is a command using the C compiler that you would use to create
396413498266Sopenharmony_cia program from several object files.
396513498266Sopenharmony_ci
396613498266Sopenharmony_ciThe following components of LINK-COMMAND are treated specially:
396713498266Sopenharmony_ci
396813498266Sopenharmony_ci  -all-static       do not do any dynamic linking at all
396913498266Sopenharmony_ci  -avoid-version    do not add a version suffix if possible
397013498266Sopenharmony_ci  -bindir BINDIR    specify path to binaries directory (for systems where
397113498266Sopenharmony_ci                    libraries must be found in the PATH setting at runtime)
397213498266Sopenharmony_ci  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
397313498266Sopenharmony_ci  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
397413498266Sopenharmony_ci  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
397513498266Sopenharmony_ci  -export-symbols SYMFILE
397613498266Sopenharmony_ci                    try to export only the symbols listed in SYMFILE
397713498266Sopenharmony_ci  -export-symbols-regex REGEX
397813498266Sopenharmony_ci                    try to export only the symbols matching REGEX
397913498266Sopenharmony_ci  -LLIBDIR          search LIBDIR for required installed libraries
398013498266Sopenharmony_ci  -lNAME            OUTPUT-FILE requires the installed library libNAME
398113498266Sopenharmony_ci  -module           build a library that can dlopened
398213498266Sopenharmony_ci  -no-fast-install  disable the fast-install mode
398313498266Sopenharmony_ci  -no-install       link a not-installable executable
398413498266Sopenharmony_ci  -no-undefined     declare that a library does not refer to external symbols
398513498266Sopenharmony_ci  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
398613498266Sopenharmony_ci  -objectlist FILE  use a list of object files found in FILE to specify objects
398713498266Sopenharmony_ci  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
398813498266Sopenharmony_ci  -precious-files-regex REGEX
398913498266Sopenharmony_ci                    don't remove output files matching REGEX
399013498266Sopenharmony_ci  -release RELEASE  specify package release information
399113498266Sopenharmony_ci  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
399213498266Sopenharmony_ci  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
399313498266Sopenharmony_ci  -shared           only do dynamic linking of libtool libraries
399413498266Sopenharmony_ci  -shrext SUFFIX    override the standard shared library file extension
399513498266Sopenharmony_ci  -static           do not do any dynamic linking of uninstalled libtool libraries
399613498266Sopenharmony_ci  -static-libtool-libs
399713498266Sopenharmony_ci                    do not do any dynamic linking of libtool libraries
399813498266Sopenharmony_ci  -version-info CURRENT[:REVISION[:AGE]]
399913498266Sopenharmony_ci                    specify library version info [each variable defaults to 0]
400013498266Sopenharmony_ci  -weak LIBNAME     declare that the target provides the LIBNAME interface
400113498266Sopenharmony_ci  -Wc,FLAG
400213498266Sopenharmony_ci  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
400313498266Sopenharmony_ci  -Wa,FLAG
400413498266Sopenharmony_ci  -Xassembler FLAG  pass linker-specific FLAG directly to the assembler
400513498266Sopenharmony_ci  -Wl,FLAG
400613498266Sopenharmony_ci  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
400713498266Sopenharmony_ci  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
400813498266Sopenharmony_ci
400913498266Sopenharmony_ciAll other options (arguments beginning with '-') are ignored.
401013498266Sopenharmony_ci
401113498266Sopenharmony_ciEvery other argument is treated as a filename.  Files ending in '.la' are
401213498266Sopenharmony_citreated as uninstalled libtool libraries, other files are standard or library
401313498266Sopenharmony_ciobject files.
401413498266Sopenharmony_ci
401513498266Sopenharmony_ciIf the OUTPUT-FILE ends in '.la', then a libtool library is created,
401613498266Sopenharmony_cionly library objects ('.lo' files) may be specified, and '-rpath' is
401713498266Sopenharmony_cirequired, except when creating a convenience library.
401813498266Sopenharmony_ci
401913498266Sopenharmony_ciIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
402013498266Sopenharmony_ciusing 'ar' and 'ranlib', or on Windows using 'lib'.
402113498266Sopenharmony_ci
402213498266Sopenharmony_ciIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
402313498266Sopenharmony_ciis created, otherwise an executable program is created."
402413498266Sopenharmony_ci        ;;
402513498266Sopenharmony_ci
402613498266Sopenharmony_ci      uninstall)
402713498266Sopenharmony_ci        $ECHO \
402813498266Sopenharmony_ci"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
402913498266Sopenharmony_ci
403013498266Sopenharmony_ciRemove libraries from an installation directory.
403113498266Sopenharmony_ci
403213498266Sopenharmony_ciRM is the name of the program to use to delete files associated with each FILE
403313498266Sopenharmony_ci(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
403413498266Sopenharmony_cito RM.
403513498266Sopenharmony_ci
403613498266Sopenharmony_ciIf FILE is a libtool library, all the files associated with it are deleted.
403713498266Sopenharmony_ciOtherwise, only FILE itself is deleted using RM."
403813498266Sopenharmony_ci        ;;
403913498266Sopenharmony_ci
404013498266Sopenharmony_ci      *)
404113498266Sopenharmony_ci        func_fatal_help "invalid operation mode '$opt_mode'"
404213498266Sopenharmony_ci        ;;
404313498266Sopenharmony_ci    esac
404413498266Sopenharmony_ci
404513498266Sopenharmony_ci    echo
404613498266Sopenharmony_ci    $ECHO "Try '$progname --help' for more information about other modes."
404713498266Sopenharmony_ci}
404813498266Sopenharmony_ci
404913498266Sopenharmony_ci# Now that we've collected a possible --mode arg, show help if necessary
405013498266Sopenharmony_ciif $opt_help; then
405113498266Sopenharmony_ci  if test : = "$opt_help"; then
405213498266Sopenharmony_ci    func_mode_help
405313498266Sopenharmony_ci  else
405413498266Sopenharmony_ci    {
405513498266Sopenharmony_ci      func_help noexit
405613498266Sopenharmony_ci      for opt_mode in compile link execute install finish uninstall clean; do
405713498266Sopenharmony_ci	func_mode_help
405813498266Sopenharmony_ci      done
405913498266Sopenharmony_ci    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
406013498266Sopenharmony_ci    {
406113498266Sopenharmony_ci      func_help noexit
406213498266Sopenharmony_ci      for opt_mode in compile link execute install finish uninstall clean; do
406313498266Sopenharmony_ci	echo
406413498266Sopenharmony_ci	func_mode_help
406513498266Sopenharmony_ci      done
406613498266Sopenharmony_ci    } |
406713498266Sopenharmony_ci    $SED '1d
406813498266Sopenharmony_ci      /^When reporting/,/^Report/{
406913498266Sopenharmony_ci	H
407013498266Sopenharmony_ci	d
407113498266Sopenharmony_ci      }
407213498266Sopenharmony_ci      $x
407313498266Sopenharmony_ci      /information about other modes/d
407413498266Sopenharmony_ci      /more detailed .*MODE/d
407513498266Sopenharmony_ci      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
407613498266Sopenharmony_ci  fi
407713498266Sopenharmony_ci  exit $?
407813498266Sopenharmony_cifi
407913498266Sopenharmony_ci
408013498266Sopenharmony_ci
408113498266Sopenharmony_ci# func_mode_execute arg...
408213498266Sopenharmony_cifunc_mode_execute ()
408313498266Sopenharmony_ci{
408413498266Sopenharmony_ci    $debug_cmd
408513498266Sopenharmony_ci
408613498266Sopenharmony_ci    # The first argument is the command name.
408713498266Sopenharmony_ci    cmd=$nonopt
408813498266Sopenharmony_ci    test -z "$cmd" && \
408913498266Sopenharmony_ci      func_fatal_help "you must specify a COMMAND"
409013498266Sopenharmony_ci
409113498266Sopenharmony_ci    # Handle -dlopen flags immediately.
409213498266Sopenharmony_ci    for file in $opt_dlopen; do
409313498266Sopenharmony_ci      test -f "$file" \
409413498266Sopenharmony_ci	|| func_fatal_help "'$file' is not a file"
409513498266Sopenharmony_ci
409613498266Sopenharmony_ci      dir=
409713498266Sopenharmony_ci      case $file in
409813498266Sopenharmony_ci      *.la)
409913498266Sopenharmony_ci	func_resolve_sysroot "$file"
410013498266Sopenharmony_ci	file=$func_resolve_sysroot_result
410113498266Sopenharmony_ci
410213498266Sopenharmony_ci	# Check to see that this really is a libtool archive.
410313498266Sopenharmony_ci	func_lalib_unsafe_p "$file" \
410413498266Sopenharmony_ci	  || func_fatal_help "'$lib' is not a valid libtool archive"
410513498266Sopenharmony_ci
410613498266Sopenharmony_ci	# Read the libtool library.
410713498266Sopenharmony_ci	dlname=
410813498266Sopenharmony_ci	library_names=
410913498266Sopenharmony_ci	func_source "$file"
411013498266Sopenharmony_ci
411113498266Sopenharmony_ci	# Skip this library if it cannot be dlopened.
411213498266Sopenharmony_ci	if test -z "$dlname"; then
411313498266Sopenharmony_ci	  # Warn if it was a shared library.
411413498266Sopenharmony_ci	  test -n "$library_names" && \
411513498266Sopenharmony_ci	    func_warning "'$file' was not linked with '-export-dynamic'"
411613498266Sopenharmony_ci	  continue
411713498266Sopenharmony_ci	fi
411813498266Sopenharmony_ci
411913498266Sopenharmony_ci	func_dirname "$file" "" "."
412013498266Sopenharmony_ci	dir=$func_dirname_result
412113498266Sopenharmony_ci
412213498266Sopenharmony_ci	if test -f "$dir/$objdir/$dlname"; then
412313498266Sopenharmony_ci	  func_append dir "/$objdir"
412413498266Sopenharmony_ci	else
412513498266Sopenharmony_ci	  if test ! -f "$dir/$dlname"; then
412613498266Sopenharmony_ci	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
412713498266Sopenharmony_ci	  fi
412813498266Sopenharmony_ci	fi
412913498266Sopenharmony_ci	;;
413013498266Sopenharmony_ci
413113498266Sopenharmony_ci      *.lo)
413213498266Sopenharmony_ci	# Just add the directory containing the .lo file.
413313498266Sopenharmony_ci	func_dirname "$file" "" "."
413413498266Sopenharmony_ci	dir=$func_dirname_result
413513498266Sopenharmony_ci	;;
413613498266Sopenharmony_ci
413713498266Sopenharmony_ci      *)
413813498266Sopenharmony_ci	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
413913498266Sopenharmony_ci	continue
414013498266Sopenharmony_ci	;;
414113498266Sopenharmony_ci      esac
414213498266Sopenharmony_ci
414313498266Sopenharmony_ci      # Get the absolute pathname.
414413498266Sopenharmony_ci      absdir=`cd "$dir" && pwd`
414513498266Sopenharmony_ci      test -n "$absdir" && dir=$absdir
414613498266Sopenharmony_ci
414713498266Sopenharmony_ci      # Now add the directory to shlibpath_var.
414813498266Sopenharmony_ci      if eval "test -z \"\$$shlibpath_var\""; then
414913498266Sopenharmony_ci	eval "$shlibpath_var=\"\$dir\""
415013498266Sopenharmony_ci      else
415113498266Sopenharmony_ci	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
415213498266Sopenharmony_ci      fi
415313498266Sopenharmony_ci    done
415413498266Sopenharmony_ci
415513498266Sopenharmony_ci    # This variable tells wrapper scripts just to set shlibpath_var
415613498266Sopenharmony_ci    # rather than running their programs.
415713498266Sopenharmony_ci    libtool_execute_magic=$magic
415813498266Sopenharmony_ci
415913498266Sopenharmony_ci    # Check if any of the arguments is a wrapper script.
416013498266Sopenharmony_ci    args=
416113498266Sopenharmony_ci    for file
416213498266Sopenharmony_ci    do
416313498266Sopenharmony_ci      case $file in
416413498266Sopenharmony_ci      -* | *.la | *.lo ) ;;
416513498266Sopenharmony_ci      *)
416613498266Sopenharmony_ci	# Do a test to see if this is really a libtool program.
416713498266Sopenharmony_ci	if func_ltwrapper_script_p "$file"; then
416813498266Sopenharmony_ci	  func_source "$file"
416913498266Sopenharmony_ci	  # Transform arg to wrapped name.
417013498266Sopenharmony_ci	  file=$progdir/$program
417113498266Sopenharmony_ci	elif func_ltwrapper_executable_p "$file"; then
417213498266Sopenharmony_ci	  func_ltwrapper_scriptname "$file"
417313498266Sopenharmony_ci	  func_source "$func_ltwrapper_scriptname_result"
417413498266Sopenharmony_ci	  # Transform arg to wrapped name.
417513498266Sopenharmony_ci	  file=$progdir/$program
417613498266Sopenharmony_ci	fi
417713498266Sopenharmony_ci	;;
417813498266Sopenharmony_ci      esac
417913498266Sopenharmony_ci      # Quote arguments (to preserve shell metacharacters).
418013498266Sopenharmony_ci      func_append_quoted args "$file"
418113498266Sopenharmony_ci    done
418213498266Sopenharmony_ci
418313498266Sopenharmony_ci    if $opt_dry_run; then
418413498266Sopenharmony_ci      # Display what would be done.
418513498266Sopenharmony_ci      if test -n "$shlibpath_var"; then
418613498266Sopenharmony_ci	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
418713498266Sopenharmony_ci	echo "export $shlibpath_var"
418813498266Sopenharmony_ci      fi
418913498266Sopenharmony_ci      $ECHO "$cmd$args"
419013498266Sopenharmony_ci      exit $EXIT_SUCCESS
419113498266Sopenharmony_ci    else
419213498266Sopenharmony_ci      if test -n "$shlibpath_var"; then
419313498266Sopenharmony_ci	# Export the shlibpath_var.
419413498266Sopenharmony_ci	eval "export $shlibpath_var"
419513498266Sopenharmony_ci      fi
419613498266Sopenharmony_ci
419713498266Sopenharmony_ci      # Restore saved environment variables
419813498266Sopenharmony_ci      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
419913498266Sopenharmony_ci      do
420013498266Sopenharmony_ci	eval "if test \"\${save_$lt_var+set}\" = set; then
420113498266Sopenharmony_ci                $lt_var=\$save_$lt_var; export $lt_var
420213498266Sopenharmony_ci	      else
420313498266Sopenharmony_ci		$lt_unset $lt_var
420413498266Sopenharmony_ci	      fi"
420513498266Sopenharmony_ci      done
420613498266Sopenharmony_ci
420713498266Sopenharmony_ci      # Now prepare to actually exec the command.
420813498266Sopenharmony_ci      exec_cmd=\$cmd$args
420913498266Sopenharmony_ci    fi
421013498266Sopenharmony_ci}
421113498266Sopenharmony_ci
421213498266Sopenharmony_citest execute = "$opt_mode" && func_mode_execute ${1+"$@"}
421313498266Sopenharmony_ci
421413498266Sopenharmony_ci
421513498266Sopenharmony_ci# func_mode_finish arg...
421613498266Sopenharmony_cifunc_mode_finish ()
421713498266Sopenharmony_ci{
421813498266Sopenharmony_ci    $debug_cmd
421913498266Sopenharmony_ci
422013498266Sopenharmony_ci    libs=
422113498266Sopenharmony_ci    libdirs=
422213498266Sopenharmony_ci    admincmds=
422313498266Sopenharmony_ci
422413498266Sopenharmony_ci    for opt in "$nonopt" ${1+"$@"}
422513498266Sopenharmony_ci    do
422613498266Sopenharmony_ci      if test -d "$opt"; then
422713498266Sopenharmony_ci	func_append libdirs " $opt"
422813498266Sopenharmony_ci
422913498266Sopenharmony_ci      elif test -f "$opt"; then
423013498266Sopenharmony_ci	if func_lalib_unsafe_p "$opt"; then
423113498266Sopenharmony_ci	  func_append libs " $opt"
423213498266Sopenharmony_ci	else
423313498266Sopenharmony_ci	  func_warning "'$opt' is not a valid libtool archive"
423413498266Sopenharmony_ci	fi
423513498266Sopenharmony_ci
423613498266Sopenharmony_ci      else
423713498266Sopenharmony_ci	func_fatal_error "invalid argument '$opt'"
423813498266Sopenharmony_ci      fi
423913498266Sopenharmony_ci    done
424013498266Sopenharmony_ci
424113498266Sopenharmony_ci    if test -n "$libs"; then
424213498266Sopenharmony_ci      if test -n "$lt_sysroot"; then
424313498266Sopenharmony_ci        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
424413498266Sopenharmony_ci        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
424513498266Sopenharmony_ci      else
424613498266Sopenharmony_ci        sysroot_cmd=
424713498266Sopenharmony_ci      fi
424813498266Sopenharmony_ci
424913498266Sopenharmony_ci      # Remove sysroot references
425013498266Sopenharmony_ci      if $opt_dry_run; then
425113498266Sopenharmony_ci        for lib in $libs; do
425213498266Sopenharmony_ci          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
425313498266Sopenharmony_ci        done
425413498266Sopenharmony_ci      else
425513498266Sopenharmony_ci        tmpdir=`func_mktempdir`
425613498266Sopenharmony_ci        for lib in $libs; do
425713498266Sopenharmony_ci	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
425813498266Sopenharmony_ci	    > $tmpdir/tmp-la
425913498266Sopenharmony_ci	  mv -f $tmpdir/tmp-la $lib
426013498266Sopenharmony_ci	done
426113498266Sopenharmony_ci        ${RM}r "$tmpdir"
426213498266Sopenharmony_ci      fi
426313498266Sopenharmony_ci    fi
426413498266Sopenharmony_ci
426513498266Sopenharmony_ci    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
426613498266Sopenharmony_ci      for libdir in $libdirs; do
426713498266Sopenharmony_ci	if test -n "$finish_cmds"; then
426813498266Sopenharmony_ci	  # Do each command in the finish commands.
426913498266Sopenharmony_ci	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
427013498266Sopenharmony_ci'"$cmd"'"'
427113498266Sopenharmony_ci	fi
427213498266Sopenharmony_ci	if test -n "$finish_eval"; then
427313498266Sopenharmony_ci	  # Do the single finish_eval.
427413498266Sopenharmony_ci	  eval cmds=\"$finish_eval\"
427513498266Sopenharmony_ci	  $opt_dry_run || eval "$cmds" || func_append admincmds "
427613498266Sopenharmony_ci       $cmds"
427713498266Sopenharmony_ci	fi
427813498266Sopenharmony_ci      done
427913498266Sopenharmony_ci    fi
428013498266Sopenharmony_ci
428113498266Sopenharmony_ci    # Exit here if they wanted silent mode.
428213498266Sopenharmony_ci    $opt_quiet && exit $EXIT_SUCCESS
428313498266Sopenharmony_ci
428413498266Sopenharmony_ci    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
428513498266Sopenharmony_ci      echo "----------------------------------------------------------------------"
428613498266Sopenharmony_ci      echo "Libraries have been installed in:"
428713498266Sopenharmony_ci      for libdir in $libdirs; do
428813498266Sopenharmony_ci	$ECHO "   $libdir"
428913498266Sopenharmony_ci      done
429013498266Sopenharmony_ci      echo
429113498266Sopenharmony_ci      echo "If you ever happen to want to link against installed libraries"
429213498266Sopenharmony_ci      echo "in a given directory, LIBDIR, you must either use libtool, and"
429313498266Sopenharmony_ci      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
429413498266Sopenharmony_ci      echo "flag during linking and do at least one of the following:"
429513498266Sopenharmony_ci      if test -n "$shlibpath_var"; then
429613498266Sopenharmony_ci	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
429713498266Sopenharmony_ci	echo "     during execution"
429813498266Sopenharmony_ci      fi
429913498266Sopenharmony_ci      if test -n "$runpath_var"; then
430013498266Sopenharmony_ci	echo "   - add LIBDIR to the '$runpath_var' environment variable"
430113498266Sopenharmony_ci	echo "     during linking"
430213498266Sopenharmony_ci      fi
430313498266Sopenharmony_ci      if test -n "$hardcode_libdir_flag_spec"; then
430413498266Sopenharmony_ci	libdir=LIBDIR
430513498266Sopenharmony_ci	eval flag=\"$hardcode_libdir_flag_spec\"
430613498266Sopenharmony_ci
430713498266Sopenharmony_ci	$ECHO "   - use the '$flag' linker flag"
430813498266Sopenharmony_ci      fi
430913498266Sopenharmony_ci      if test -n "$admincmds"; then
431013498266Sopenharmony_ci	$ECHO "   - have your system administrator run these commands:$admincmds"
431113498266Sopenharmony_ci      fi
431213498266Sopenharmony_ci      if test -f /etc/ld.so.conf; then
431313498266Sopenharmony_ci	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
431413498266Sopenharmony_ci      fi
431513498266Sopenharmony_ci      echo
431613498266Sopenharmony_ci
431713498266Sopenharmony_ci      echo "See any operating system documentation about shared libraries for"
431813498266Sopenharmony_ci      case $host in
431913498266Sopenharmony_ci	solaris2.[6789]|solaris2.1[0-9])
432013498266Sopenharmony_ci	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
432113498266Sopenharmony_ci	  echo "pages."
432213498266Sopenharmony_ci	  ;;
432313498266Sopenharmony_ci	*)
432413498266Sopenharmony_ci	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
432513498266Sopenharmony_ci	  ;;
432613498266Sopenharmony_ci      esac
432713498266Sopenharmony_ci      echo "----------------------------------------------------------------------"
432813498266Sopenharmony_ci    fi
432913498266Sopenharmony_ci    exit $EXIT_SUCCESS
433013498266Sopenharmony_ci}
433113498266Sopenharmony_ci
433213498266Sopenharmony_citest finish = "$opt_mode" && func_mode_finish ${1+"$@"}
433313498266Sopenharmony_ci
433413498266Sopenharmony_ci
433513498266Sopenharmony_ci# func_mode_install arg...
433613498266Sopenharmony_cifunc_mode_install ()
433713498266Sopenharmony_ci{
433813498266Sopenharmony_ci    $debug_cmd
433913498266Sopenharmony_ci
434013498266Sopenharmony_ci    # There may be an optional sh(1) argument at the beginning of
434113498266Sopenharmony_ci    # install_prog (especially on Windows NT).
434213498266Sopenharmony_ci    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
434313498266Sopenharmony_ci       # Allow the use of GNU shtool's install command.
434413498266Sopenharmony_ci       case $nonopt in *shtool*) :;; *) false;; esac
434513498266Sopenharmony_ci    then
434613498266Sopenharmony_ci      # Aesthetically quote it.
434713498266Sopenharmony_ci      func_quote_arg pretty "$nonopt"
434813498266Sopenharmony_ci      install_prog="$func_quote_arg_result "
434913498266Sopenharmony_ci      arg=$1
435013498266Sopenharmony_ci      shift
435113498266Sopenharmony_ci    else
435213498266Sopenharmony_ci      install_prog=
435313498266Sopenharmony_ci      arg=$nonopt
435413498266Sopenharmony_ci    fi
435513498266Sopenharmony_ci
435613498266Sopenharmony_ci    # The real first argument should be the name of the installation program.
435713498266Sopenharmony_ci    # Aesthetically quote it.
435813498266Sopenharmony_ci    func_quote_arg pretty "$arg"
435913498266Sopenharmony_ci    func_append install_prog "$func_quote_arg_result"
436013498266Sopenharmony_ci    install_shared_prog=$install_prog
436113498266Sopenharmony_ci    case " $install_prog " in
436213498266Sopenharmony_ci      *[\\\ /]cp\ *) install_cp=: ;;
436313498266Sopenharmony_ci      *) install_cp=false ;;
436413498266Sopenharmony_ci    esac
436513498266Sopenharmony_ci
436613498266Sopenharmony_ci    # We need to accept at least all the BSD install flags.
436713498266Sopenharmony_ci    dest=
436813498266Sopenharmony_ci    files=
436913498266Sopenharmony_ci    opts=
437013498266Sopenharmony_ci    prev=
437113498266Sopenharmony_ci    install_type=
437213498266Sopenharmony_ci    isdir=false
437313498266Sopenharmony_ci    stripme=
437413498266Sopenharmony_ci    no_mode=:
437513498266Sopenharmony_ci    for arg
437613498266Sopenharmony_ci    do
437713498266Sopenharmony_ci      arg2=
437813498266Sopenharmony_ci      if test -n "$dest"; then
437913498266Sopenharmony_ci	func_append files " $dest"
438013498266Sopenharmony_ci	dest=$arg
438113498266Sopenharmony_ci	continue
438213498266Sopenharmony_ci      fi
438313498266Sopenharmony_ci
438413498266Sopenharmony_ci      case $arg in
438513498266Sopenharmony_ci      -d) isdir=: ;;
438613498266Sopenharmony_ci      -f)
438713498266Sopenharmony_ci	if $install_cp; then :; else
438813498266Sopenharmony_ci	  prev=$arg
438913498266Sopenharmony_ci	fi
439013498266Sopenharmony_ci	;;
439113498266Sopenharmony_ci      -g | -m | -o)
439213498266Sopenharmony_ci	prev=$arg
439313498266Sopenharmony_ci	;;
439413498266Sopenharmony_ci      -s)
439513498266Sopenharmony_ci	stripme=" -s"
439613498266Sopenharmony_ci	continue
439713498266Sopenharmony_ci	;;
439813498266Sopenharmony_ci      -*)
439913498266Sopenharmony_ci	;;
440013498266Sopenharmony_ci      *)
440113498266Sopenharmony_ci	# If the previous option needed an argument, then skip it.
440213498266Sopenharmony_ci	if test -n "$prev"; then
440313498266Sopenharmony_ci	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
440413498266Sopenharmony_ci	    arg2=$install_override_mode
440513498266Sopenharmony_ci	    no_mode=false
440613498266Sopenharmony_ci	  fi
440713498266Sopenharmony_ci	  prev=
440813498266Sopenharmony_ci	else
440913498266Sopenharmony_ci	  dest=$arg
441013498266Sopenharmony_ci	  continue
441113498266Sopenharmony_ci	fi
441213498266Sopenharmony_ci	;;
441313498266Sopenharmony_ci      esac
441413498266Sopenharmony_ci
441513498266Sopenharmony_ci      # Aesthetically quote the argument.
441613498266Sopenharmony_ci      func_quote_arg pretty "$arg"
441713498266Sopenharmony_ci      func_append install_prog " $func_quote_arg_result"
441813498266Sopenharmony_ci      if test -n "$arg2"; then
441913498266Sopenharmony_ci	func_quote_arg pretty "$arg2"
442013498266Sopenharmony_ci      fi
442113498266Sopenharmony_ci      func_append install_shared_prog " $func_quote_arg_result"
442213498266Sopenharmony_ci    done
442313498266Sopenharmony_ci
442413498266Sopenharmony_ci    test -z "$install_prog" && \
442513498266Sopenharmony_ci      func_fatal_help "you must specify an install program"
442613498266Sopenharmony_ci
442713498266Sopenharmony_ci    test -n "$prev" && \
442813498266Sopenharmony_ci      func_fatal_help "the '$prev' option requires an argument"
442913498266Sopenharmony_ci
443013498266Sopenharmony_ci    if test -n "$install_override_mode" && $no_mode; then
443113498266Sopenharmony_ci      if $install_cp; then :; else
443213498266Sopenharmony_ci	func_quote_arg pretty "$install_override_mode"
443313498266Sopenharmony_ci	func_append install_shared_prog " -m $func_quote_arg_result"
443413498266Sopenharmony_ci      fi
443513498266Sopenharmony_ci    fi
443613498266Sopenharmony_ci
443713498266Sopenharmony_ci    if test -z "$files"; then
443813498266Sopenharmony_ci      if test -z "$dest"; then
443913498266Sopenharmony_ci	func_fatal_help "no file or destination specified"
444013498266Sopenharmony_ci      else
444113498266Sopenharmony_ci	func_fatal_help "you must specify a destination"
444213498266Sopenharmony_ci      fi
444313498266Sopenharmony_ci    fi
444413498266Sopenharmony_ci
444513498266Sopenharmony_ci    # Strip any trailing slash from the destination.
444613498266Sopenharmony_ci    func_stripname '' '/' "$dest"
444713498266Sopenharmony_ci    dest=$func_stripname_result
444813498266Sopenharmony_ci
444913498266Sopenharmony_ci    # Check to see that the destination is a directory.
445013498266Sopenharmony_ci    test -d "$dest" && isdir=:
445113498266Sopenharmony_ci    if $isdir; then
445213498266Sopenharmony_ci      destdir=$dest
445313498266Sopenharmony_ci      destname=
445413498266Sopenharmony_ci    else
445513498266Sopenharmony_ci      func_dirname_and_basename "$dest" "" "."
445613498266Sopenharmony_ci      destdir=$func_dirname_result
445713498266Sopenharmony_ci      destname=$func_basename_result
445813498266Sopenharmony_ci
445913498266Sopenharmony_ci      # Not a directory, so check to see that there is only one file specified.
446013498266Sopenharmony_ci      set dummy $files; shift
446113498266Sopenharmony_ci      test "$#" -gt 1 && \
446213498266Sopenharmony_ci	func_fatal_help "'$dest' is not a directory"
446313498266Sopenharmony_ci    fi
446413498266Sopenharmony_ci    case $destdir in
446513498266Sopenharmony_ci    [\\/]* | [A-Za-z]:[\\/]*) ;;
446613498266Sopenharmony_ci    *)
446713498266Sopenharmony_ci      for file in $files; do
446813498266Sopenharmony_ci	case $file in
446913498266Sopenharmony_ci	*.lo) ;;
447013498266Sopenharmony_ci	*)
447113498266Sopenharmony_ci	  func_fatal_help "'$destdir' must be an absolute directory name"
447213498266Sopenharmony_ci	  ;;
447313498266Sopenharmony_ci	esac
447413498266Sopenharmony_ci      done
447513498266Sopenharmony_ci      ;;
447613498266Sopenharmony_ci    esac
447713498266Sopenharmony_ci
447813498266Sopenharmony_ci    # This variable tells wrapper scripts just to set variables rather
447913498266Sopenharmony_ci    # than running their programs.
448013498266Sopenharmony_ci    libtool_install_magic=$magic
448113498266Sopenharmony_ci
448213498266Sopenharmony_ci    staticlibs=
448313498266Sopenharmony_ci    future_libdirs=
448413498266Sopenharmony_ci    current_libdirs=
448513498266Sopenharmony_ci    for file in $files; do
448613498266Sopenharmony_ci
448713498266Sopenharmony_ci      # Do each installation.
448813498266Sopenharmony_ci      case $file in
448913498266Sopenharmony_ci      *.$libext)
449013498266Sopenharmony_ci	# Do the static libraries later.
449113498266Sopenharmony_ci	func_append staticlibs " $file"
449213498266Sopenharmony_ci	;;
449313498266Sopenharmony_ci
449413498266Sopenharmony_ci      *.la)
449513498266Sopenharmony_ci	func_resolve_sysroot "$file"
449613498266Sopenharmony_ci	file=$func_resolve_sysroot_result
449713498266Sopenharmony_ci
449813498266Sopenharmony_ci	# Check to see that this really is a libtool archive.
449913498266Sopenharmony_ci	func_lalib_unsafe_p "$file" \
450013498266Sopenharmony_ci	  || func_fatal_help "'$file' is not a valid libtool archive"
450113498266Sopenharmony_ci
450213498266Sopenharmony_ci	library_names=
450313498266Sopenharmony_ci	old_library=
450413498266Sopenharmony_ci	relink_command=
450513498266Sopenharmony_ci	func_source "$file"
450613498266Sopenharmony_ci
450713498266Sopenharmony_ci	# Add the libdir to current_libdirs if it is the destination.
450813498266Sopenharmony_ci	if test "X$destdir" = "X$libdir"; then
450913498266Sopenharmony_ci	  case "$current_libdirs " in
451013498266Sopenharmony_ci	  *" $libdir "*) ;;
451113498266Sopenharmony_ci	  *) func_append current_libdirs " $libdir" ;;
451213498266Sopenharmony_ci	  esac
451313498266Sopenharmony_ci	else
451413498266Sopenharmony_ci	  # Note the libdir as a future libdir.
451513498266Sopenharmony_ci	  case "$future_libdirs " in
451613498266Sopenharmony_ci	  *" $libdir "*) ;;
451713498266Sopenharmony_ci	  *) func_append future_libdirs " $libdir" ;;
451813498266Sopenharmony_ci	  esac
451913498266Sopenharmony_ci	fi
452013498266Sopenharmony_ci
452113498266Sopenharmony_ci	func_dirname "$file" "/" ""
452213498266Sopenharmony_ci	dir=$func_dirname_result
452313498266Sopenharmony_ci	func_append dir "$objdir"
452413498266Sopenharmony_ci
452513498266Sopenharmony_ci	if test -n "$relink_command"; then
452613498266Sopenharmony_ci	  # Determine the prefix the user has applied to our future dir.
452713498266Sopenharmony_ci	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
452813498266Sopenharmony_ci
452913498266Sopenharmony_ci	  # Don't allow the user to place us outside of our expected
453013498266Sopenharmony_ci	  # location b/c this prevents finding dependent libraries that
453113498266Sopenharmony_ci	  # are installed to the same prefix.
453213498266Sopenharmony_ci	  # At present, this check doesn't affect windows .dll's that
453313498266Sopenharmony_ci	  # are installed into $libdir/../bin (currently, that works fine)
453413498266Sopenharmony_ci	  # but it's something to keep an eye on.
453513498266Sopenharmony_ci	  test "$inst_prefix_dir" = "$destdir" && \
453613498266Sopenharmony_ci	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
453713498266Sopenharmony_ci
453813498266Sopenharmony_ci	  if test -n "$inst_prefix_dir"; then
453913498266Sopenharmony_ci	    # Stick the inst_prefix_dir data into the link command.
454013498266Sopenharmony_ci	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
454113498266Sopenharmony_ci	  else
454213498266Sopenharmony_ci	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
454313498266Sopenharmony_ci	  fi
454413498266Sopenharmony_ci
454513498266Sopenharmony_ci	  func_warning "relinking '$file'"
454613498266Sopenharmony_ci	  func_show_eval "$relink_command" \
454713498266Sopenharmony_ci	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
454813498266Sopenharmony_ci	fi
454913498266Sopenharmony_ci
455013498266Sopenharmony_ci	# See the names of the shared library.
455113498266Sopenharmony_ci	set dummy $library_names; shift
455213498266Sopenharmony_ci	if test -n "$1"; then
455313498266Sopenharmony_ci	  realname=$1
455413498266Sopenharmony_ci	  shift
455513498266Sopenharmony_ci
455613498266Sopenharmony_ci	  srcname=$realname
455713498266Sopenharmony_ci	  test -n "$relink_command" && srcname=${realname}T
455813498266Sopenharmony_ci
455913498266Sopenharmony_ci	  # Install the shared library and build the symlinks.
456013498266Sopenharmony_ci	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
456113498266Sopenharmony_ci	      'exit $?'
456213498266Sopenharmony_ci	  tstripme=$stripme
456313498266Sopenharmony_ci	  case $host_os in
456413498266Sopenharmony_ci	  cygwin* | mingw* | pw32* | cegcc*)
456513498266Sopenharmony_ci	    case $realname in
456613498266Sopenharmony_ci	    *.dll.a)
456713498266Sopenharmony_ci	      tstripme=
456813498266Sopenharmony_ci	      ;;
456913498266Sopenharmony_ci	    esac
457013498266Sopenharmony_ci	    ;;
457113498266Sopenharmony_ci	  os2*)
457213498266Sopenharmony_ci	    case $realname in
457313498266Sopenharmony_ci	    *_dll.a)
457413498266Sopenharmony_ci	      tstripme=
457513498266Sopenharmony_ci	      ;;
457613498266Sopenharmony_ci	    esac
457713498266Sopenharmony_ci	    ;;
457813498266Sopenharmony_ci	  esac
457913498266Sopenharmony_ci	  if test -n "$tstripme" && test -n "$striplib"; then
458013498266Sopenharmony_ci	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
458113498266Sopenharmony_ci	  fi
458213498266Sopenharmony_ci
458313498266Sopenharmony_ci	  if test "$#" -gt 0; then
458413498266Sopenharmony_ci	    # Delete the old symlinks, and create new ones.
458513498266Sopenharmony_ci	    # Try 'ln -sf' first, because the 'ln' binary might depend on
458613498266Sopenharmony_ci	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
458713498266Sopenharmony_ci	    # so we also need to try rm && ln -s.
458813498266Sopenharmony_ci	    for linkname
458913498266Sopenharmony_ci	    do
459013498266Sopenharmony_ci	      test "$linkname" != "$realname" \
459113498266Sopenharmony_ci		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
459213498266Sopenharmony_ci	    done
459313498266Sopenharmony_ci	  fi
459413498266Sopenharmony_ci
459513498266Sopenharmony_ci	  # Do each command in the postinstall commands.
459613498266Sopenharmony_ci	  lib=$destdir/$realname
459713498266Sopenharmony_ci	  func_execute_cmds "$postinstall_cmds" 'exit $?'
459813498266Sopenharmony_ci	fi
459913498266Sopenharmony_ci
460013498266Sopenharmony_ci	# Install the pseudo-library for information purposes.
460113498266Sopenharmony_ci	func_basename "$file"
460213498266Sopenharmony_ci	name=$func_basename_result
460313498266Sopenharmony_ci	instname=$dir/${name}i
460413498266Sopenharmony_ci	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
460513498266Sopenharmony_ci
460613498266Sopenharmony_ci	# Maybe install the static library, too.
460713498266Sopenharmony_ci	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
460813498266Sopenharmony_ci	;;
460913498266Sopenharmony_ci
461013498266Sopenharmony_ci      *.lo)
461113498266Sopenharmony_ci	# Install (i.e. copy) a libtool object.
461213498266Sopenharmony_ci
461313498266Sopenharmony_ci	# Figure out destination file name, if it wasn't already specified.
461413498266Sopenharmony_ci	if test -n "$destname"; then
461513498266Sopenharmony_ci	  destfile=$destdir/$destname
461613498266Sopenharmony_ci	else
461713498266Sopenharmony_ci	  func_basename "$file"
461813498266Sopenharmony_ci	  destfile=$func_basename_result
461913498266Sopenharmony_ci	  destfile=$destdir/$destfile
462013498266Sopenharmony_ci	fi
462113498266Sopenharmony_ci
462213498266Sopenharmony_ci	# Deduce the name of the destination old-style object file.
462313498266Sopenharmony_ci	case $destfile in
462413498266Sopenharmony_ci	*.lo)
462513498266Sopenharmony_ci	  func_lo2o "$destfile"
462613498266Sopenharmony_ci	  staticdest=$func_lo2o_result
462713498266Sopenharmony_ci	  ;;
462813498266Sopenharmony_ci	*.$objext)
462913498266Sopenharmony_ci	  staticdest=$destfile
463013498266Sopenharmony_ci	  destfile=
463113498266Sopenharmony_ci	  ;;
463213498266Sopenharmony_ci	*)
463313498266Sopenharmony_ci	  func_fatal_help "cannot copy a libtool object to '$destfile'"
463413498266Sopenharmony_ci	  ;;
463513498266Sopenharmony_ci	esac
463613498266Sopenharmony_ci
463713498266Sopenharmony_ci	# Install the libtool object if requested.
463813498266Sopenharmony_ci	test -n "$destfile" && \
463913498266Sopenharmony_ci	  func_show_eval "$install_prog $file $destfile" 'exit $?'
464013498266Sopenharmony_ci
464113498266Sopenharmony_ci	# Install the old object if enabled.
464213498266Sopenharmony_ci	if test yes = "$build_old_libs"; then
464313498266Sopenharmony_ci	  # Deduce the name of the old-style object file.
464413498266Sopenharmony_ci	  func_lo2o "$file"
464513498266Sopenharmony_ci	  staticobj=$func_lo2o_result
464613498266Sopenharmony_ci	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
464713498266Sopenharmony_ci	fi
464813498266Sopenharmony_ci	exit $EXIT_SUCCESS
464913498266Sopenharmony_ci	;;
465013498266Sopenharmony_ci
465113498266Sopenharmony_ci      *)
465213498266Sopenharmony_ci	# Figure out destination file name, if it wasn't already specified.
465313498266Sopenharmony_ci	if test -n "$destname"; then
465413498266Sopenharmony_ci	  destfile=$destdir/$destname
465513498266Sopenharmony_ci	else
465613498266Sopenharmony_ci	  func_basename "$file"
465713498266Sopenharmony_ci	  destfile=$func_basename_result
465813498266Sopenharmony_ci	  destfile=$destdir/$destfile
465913498266Sopenharmony_ci	fi
466013498266Sopenharmony_ci
466113498266Sopenharmony_ci	# If the file is missing, and there is a .exe on the end, strip it
466213498266Sopenharmony_ci	# because it is most likely a libtool script we actually want to
466313498266Sopenharmony_ci	# install
466413498266Sopenharmony_ci	stripped_ext=
466513498266Sopenharmony_ci	case $file in
466613498266Sopenharmony_ci	  *.exe)
466713498266Sopenharmony_ci	    if test ! -f "$file"; then
466813498266Sopenharmony_ci	      func_stripname '' '.exe' "$file"
466913498266Sopenharmony_ci	      file=$func_stripname_result
467013498266Sopenharmony_ci	      stripped_ext=.exe
467113498266Sopenharmony_ci	    fi
467213498266Sopenharmony_ci	    ;;
467313498266Sopenharmony_ci	esac
467413498266Sopenharmony_ci
467513498266Sopenharmony_ci	# Do a test to see if this is really a libtool program.
467613498266Sopenharmony_ci	case $host in
467713498266Sopenharmony_ci	*cygwin* | *mingw*)
467813498266Sopenharmony_ci	    if func_ltwrapper_executable_p "$file"; then
467913498266Sopenharmony_ci	      func_ltwrapper_scriptname "$file"
468013498266Sopenharmony_ci	      wrapper=$func_ltwrapper_scriptname_result
468113498266Sopenharmony_ci	    else
468213498266Sopenharmony_ci	      func_stripname '' '.exe' "$file"
468313498266Sopenharmony_ci	      wrapper=$func_stripname_result
468413498266Sopenharmony_ci	    fi
468513498266Sopenharmony_ci	    ;;
468613498266Sopenharmony_ci	*)
468713498266Sopenharmony_ci	    wrapper=$file
468813498266Sopenharmony_ci	    ;;
468913498266Sopenharmony_ci	esac
469013498266Sopenharmony_ci	if func_ltwrapper_script_p "$wrapper"; then
469113498266Sopenharmony_ci	  notinst_deplibs=
469213498266Sopenharmony_ci	  relink_command=
469313498266Sopenharmony_ci
469413498266Sopenharmony_ci	  func_source "$wrapper"
469513498266Sopenharmony_ci
469613498266Sopenharmony_ci	  # Check the variables that should have been set.
469713498266Sopenharmony_ci	  test -z "$generated_by_libtool_version" && \
469813498266Sopenharmony_ci	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
469913498266Sopenharmony_ci
470013498266Sopenharmony_ci	  finalize=:
470113498266Sopenharmony_ci	  for lib in $notinst_deplibs; do
470213498266Sopenharmony_ci	    # Check to see that each library is installed.
470313498266Sopenharmony_ci	    libdir=
470413498266Sopenharmony_ci	    if test -f "$lib"; then
470513498266Sopenharmony_ci	      func_source "$lib"
470613498266Sopenharmony_ci	    fi
470713498266Sopenharmony_ci	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
470813498266Sopenharmony_ci	    if test -n "$libdir" && test ! -f "$libfile"; then
470913498266Sopenharmony_ci	      func_warning "'$lib' has not been installed in '$libdir'"
471013498266Sopenharmony_ci	      finalize=false
471113498266Sopenharmony_ci	    fi
471213498266Sopenharmony_ci	  done
471313498266Sopenharmony_ci
471413498266Sopenharmony_ci	  relink_command=
471513498266Sopenharmony_ci	  func_source "$wrapper"
471613498266Sopenharmony_ci
471713498266Sopenharmony_ci	  outputname=
471813498266Sopenharmony_ci	  if test no = "$fast_install" && test -n "$relink_command"; then
471913498266Sopenharmony_ci	    $opt_dry_run || {
472013498266Sopenharmony_ci	      if $finalize; then
472113498266Sopenharmony_ci	        tmpdir=`func_mktempdir`
472213498266Sopenharmony_ci		func_basename "$file$stripped_ext"
472313498266Sopenharmony_ci		file=$func_basename_result
472413498266Sopenharmony_ci	        outputname=$tmpdir/$file
472513498266Sopenharmony_ci	        # Replace the output file specification.
472613498266Sopenharmony_ci	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
472713498266Sopenharmony_ci
472813498266Sopenharmony_ci	        $opt_quiet || {
472913498266Sopenharmony_ci	          func_quote_arg expand,pretty "$relink_command"
473013498266Sopenharmony_ci		  eval "func_echo $func_quote_arg_result"
473113498266Sopenharmony_ci	        }
473213498266Sopenharmony_ci	        if eval "$relink_command"; then :
473313498266Sopenharmony_ci	          else
473413498266Sopenharmony_ci		  func_error "error: relink '$file' with the above command before installing it"
473513498266Sopenharmony_ci		  $opt_dry_run || ${RM}r "$tmpdir"
473613498266Sopenharmony_ci		  continue
473713498266Sopenharmony_ci	        fi
473813498266Sopenharmony_ci	        file=$outputname
473913498266Sopenharmony_ci	      else
474013498266Sopenharmony_ci	        func_warning "cannot relink '$file'"
474113498266Sopenharmony_ci	      fi
474213498266Sopenharmony_ci	    }
474313498266Sopenharmony_ci	  else
474413498266Sopenharmony_ci	    # Install the binary that we compiled earlier.
474513498266Sopenharmony_ci	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
474613498266Sopenharmony_ci	  fi
474713498266Sopenharmony_ci	fi
474813498266Sopenharmony_ci
474913498266Sopenharmony_ci	# remove .exe since cygwin /usr/bin/install will append another
475013498266Sopenharmony_ci	# one anyway
475113498266Sopenharmony_ci	case $install_prog,$host in
475213498266Sopenharmony_ci	*/usr/bin/install*,*cygwin*)
475313498266Sopenharmony_ci	  case $file:$destfile in
475413498266Sopenharmony_ci	  *.exe:*.exe)
475513498266Sopenharmony_ci	    # this is ok
475613498266Sopenharmony_ci	    ;;
475713498266Sopenharmony_ci	  *.exe:*)
475813498266Sopenharmony_ci	    destfile=$destfile.exe
475913498266Sopenharmony_ci	    ;;
476013498266Sopenharmony_ci	  *:*.exe)
476113498266Sopenharmony_ci	    func_stripname '' '.exe' "$destfile"
476213498266Sopenharmony_ci	    destfile=$func_stripname_result
476313498266Sopenharmony_ci	    ;;
476413498266Sopenharmony_ci	  esac
476513498266Sopenharmony_ci	  ;;
476613498266Sopenharmony_ci	esac
476713498266Sopenharmony_ci	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
476813498266Sopenharmony_ci	$opt_dry_run || if test -n "$outputname"; then
476913498266Sopenharmony_ci	  ${RM}r "$tmpdir"
477013498266Sopenharmony_ci	fi
477113498266Sopenharmony_ci	;;
477213498266Sopenharmony_ci      esac
477313498266Sopenharmony_ci    done
477413498266Sopenharmony_ci
477513498266Sopenharmony_ci    for file in $staticlibs; do
477613498266Sopenharmony_ci      func_basename "$file"
477713498266Sopenharmony_ci      name=$func_basename_result
477813498266Sopenharmony_ci
477913498266Sopenharmony_ci      # Set up the ranlib parameters.
478013498266Sopenharmony_ci      oldlib=$destdir/$name
478113498266Sopenharmony_ci      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
478213498266Sopenharmony_ci      tool_oldlib=$func_to_tool_file_result
478313498266Sopenharmony_ci
478413498266Sopenharmony_ci      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
478513498266Sopenharmony_ci
478613498266Sopenharmony_ci      if test -n "$stripme" && test -n "$old_striplib"; then
478713498266Sopenharmony_ci	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
478813498266Sopenharmony_ci      fi
478913498266Sopenharmony_ci
479013498266Sopenharmony_ci      # Do each command in the postinstall commands.
479113498266Sopenharmony_ci      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
479213498266Sopenharmony_ci    done
479313498266Sopenharmony_ci
479413498266Sopenharmony_ci    test -n "$future_libdirs" && \
479513498266Sopenharmony_ci      func_warning "remember to run '$progname --finish$future_libdirs'"
479613498266Sopenharmony_ci
479713498266Sopenharmony_ci    if test -n "$current_libdirs"; then
479813498266Sopenharmony_ci      # Maybe just do a dry run.
479913498266Sopenharmony_ci      $opt_dry_run && current_libdirs=" -n$current_libdirs"
480013498266Sopenharmony_ci      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
480113498266Sopenharmony_ci    else
480213498266Sopenharmony_ci      exit $EXIT_SUCCESS
480313498266Sopenharmony_ci    fi
480413498266Sopenharmony_ci}
480513498266Sopenharmony_ci
480613498266Sopenharmony_citest install = "$opt_mode" && func_mode_install ${1+"$@"}
480713498266Sopenharmony_ci
480813498266Sopenharmony_ci
480913498266Sopenharmony_ci# func_generate_dlsyms outputname originator pic_p
481013498266Sopenharmony_ci# Extract symbols from dlprefiles and create ${outputname}S.o with
481113498266Sopenharmony_ci# a dlpreopen symbol table.
481213498266Sopenharmony_cifunc_generate_dlsyms ()
481313498266Sopenharmony_ci{
481413498266Sopenharmony_ci    $debug_cmd
481513498266Sopenharmony_ci
481613498266Sopenharmony_ci    my_outputname=$1
481713498266Sopenharmony_ci    my_originator=$2
481813498266Sopenharmony_ci    my_pic_p=${3-false}
481913498266Sopenharmony_ci    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
482013498266Sopenharmony_ci    my_dlsyms=
482113498266Sopenharmony_ci
482213498266Sopenharmony_ci    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
482313498266Sopenharmony_ci      if test -n "$NM" && test -n "$global_symbol_pipe"; then
482413498266Sopenharmony_ci	my_dlsyms=${my_outputname}S.c
482513498266Sopenharmony_ci      else
482613498266Sopenharmony_ci	func_error "not configured to extract global symbols from dlpreopened files"
482713498266Sopenharmony_ci      fi
482813498266Sopenharmony_ci    fi
482913498266Sopenharmony_ci
483013498266Sopenharmony_ci    if test -n "$my_dlsyms"; then
483113498266Sopenharmony_ci      case $my_dlsyms in
483213498266Sopenharmony_ci      "") ;;
483313498266Sopenharmony_ci      *.c)
483413498266Sopenharmony_ci	# Discover the nlist of each of the dlfiles.
483513498266Sopenharmony_ci	nlist=$output_objdir/$my_outputname.nm
483613498266Sopenharmony_ci
483713498266Sopenharmony_ci	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
483813498266Sopenharmony_ci
483913498266Sopenharmony_ci	# Parse the name list into a source file.
484013498266Sopenharmony_ci	func_verbose "creating $output_objdir/$my_dlsyms"
484113498266Sopenharmony_ci
484213498266Sopenharmony_ci	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
484313498266Sopenharmony_ci/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
484413498266Sopenharmony_ci/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
484513498266Sopenharmony_ci
484613498266Sopenharmony_ci#ifdef __cplusplus
484713498266Sopenharmony_ciextern \"C\" {
484813498266Sopenharmony_ci#endif
484913498266Sopenharmony_ci
485013498266Sopenharmony_ci#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
485113498266Sopenharmony_ci#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
485213498266Sopenharmony_ci#endif
485313498266Sopenharmony_ci
485413498266Sopenharmony_ci/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
485513498266Sopenharmony_ci#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
485613498266Sopenharmony_ci/* DATA imports from DLLs on WIN32 can't be const, because runtime
485713498266Sopenharmony_ci   relocations are performed -- see ld's documentation on pseudo-relocs.  */
485813498266Sopenharmony_ci# define LT_DLSYM_CONST
485913498266Sopenharmony_ci#elif defined __osf__
486013498266Sopenharmony_ci/* This system does not cope well with relocations in const data.  */
486113498266Sopenharmony_ci# define LT_DLSYM_CONST
486213498266Sopenharmony_ci#else
486313498266Sopenharmony_ci# define LT_DLSYM_CONST const
486413498266Sopenharmony_ci#endif
486513498266Sopenharmony_ci
486613498266Sopenharmony_ci#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
486713498266Sopenharmony_ci
486813498266Sopenharmony_ci/* External symbol declarations for the compiler. */\
486913498266Sopenharmony_ci"
487013498266Sopenharmony_ci
487113498266Sopenharmony_ci	if test yes = "$dlself"; then
487213498266Sopenharmony_ci	  func_verbose "generating symbol list for '$output'"
487313498266Sopenharmony_ci
487413498266Sopenharmony_ci	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
487513498266Sopenharmony_ci
487613498266Sopenharmony_ci	  # Add our own program objects to the symbol list.
487713498266Sopenharmony_ci	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
487813498266Sopenharmony_ci	  for progfile in $progfiles; do
487913498266Sopenharmony_ci	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
488013498266Sopenharmony_ci	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
488113498266Sopenharmony_ci	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
488213498266Sopenharmony_ci	  done
488313498266Sopenharmony_ci
488413498266Sopenharmony_ci	  if test -n "$exclude_expsyms"; then
488513498266Sopenharmony_ci	    $opt_dry_run || {
488613498266Sopenharmony_ci	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
488713498266Sopenharmony_ci	      eval '$MV "$nlist"T "$nlist"'
488813498266Sopenharmony_ci	    }
488913498266Sopenharmony_ci	  fi
489013498266Sopenharmony_ci
489113498266Sopenharmony_ci	  if test -n "$export_symbols_regex"; then
489213498266Sopenharmony_ci	    $opt_dry_run || {
489313498266Sopenharmony_ci	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
489413498266Sopenharmony_ci	      eval '$MV "$nlist"T "$nlist"'
489513498266Sopenharmony_ci	    }
489613498266Sopenharmony_ci	  fi
489713498266Sopenharmony_ci
489813498266Sopenharmony_ci	  # Prepare the list of exported symbols
489913498266Sopenharmony_ci	  if test -z "$export_symbols"; then
490013498266Sopenharmony_ci	    export_symbols=$output_objdir/$outputname.exp
490113498266Sopenharmony_ci	    $opt_dry_run || {
490213498266Sopenharmony_ci	      $RM $export_symbols
490313498266Sopenharmony_ci	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
490413498266Sopenharmony_ci	      case $host in
490513498266Sopenharmony_ci	      *cygwin* | *mingw* | *cegcc* )
490613498266Sopenharmony_ci                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
490713498266Sopenharmony_ci                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
490813498266Sopenharmony_ci	        ;;
490913498266Sopenharmony_ci	      esac
491013498266Sopenharmony_ci	    }
491113498266Sopenharmony_ci	  else
491213498266Sopenharmony_ci	    $opt_dry_run || {
491313498266Sopenharmony_ci	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
491413498266Sopenharmony_ci	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
491513498266Sopenharmony_ci	      eval '$MV "$nlist"T "$nlist"'
491613498266Sopenharmony_ci	      case $host in
491713498266Sopenharmony_ci	        *cygwin* | *mingw* | *cegcc* )
491813498266Sopenharmony_ci	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
491913498266Sopenharmony_ci	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
492013498266Sopenharmony_ci	          ;;
492113498266Sopenharmony_ci	      esac
492213498266Sopenharmony_ci	    }
492313498266Sopenharmony_ci	  fi
492413498266Sopenharmony_ci	fi
492513498266Sopenharmony_ci
492613498266Sopenharmony_ci	for dlprefile in $dlprefiles; do
492713498266Sopenharmony_ci	  func_verbose "extracting global C symbols from '$dlprefile'"
492813498266Sopenharmony_ci	  func_basename "$dlprefile"
492913498266Sopenharmony_ci	  name=$func_basename_result
493013498266Sopenharmony_ci          case $host in
493113498266Sopenharmony_ci	    *cygwin* | *mingw* | *cegcc* )
493213498266Sopenharmony_ci	      # if an import library, we need to obtain dlname
493313498266Sopenharmony_ci	      if func_win32_import_lib_p "$dlprefile"; then
493413498266Sopenharmony_ci	        func_tr_sh "$dlprefile"
493513498266Sopenharmony_ci	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
493613498266Sopenharmony_ci	        dlprefile_dlbasename=
493713498266Sopenharmony_ci	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
493813498266Sopenharmony_ci	          # Use subshell, to avoid clobbering current variable values
493913498266Sopenharmony_ci	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
494013498266Sopenharmony_ci	          if test -n "$dlprefile_dlname"; then
494113498266Sopenharmony_ci	            func_basename "$dlprefile_dlname"
494213498266Sopenharmony_ci	            dlprefile_dlbasename=$func_basename_result
494313498266Sopenharmony_ci	          else
494413498266Sopenharmony_ci	            # no lafile. user explicitly requested -dlpreopen <import library>.
494513498266Sopenharmony_ci	            $sharedlib_from_linklib_cmd "$dlprefile"
494613498266Sopenharmony_ci	            dlprefile_dlbasename=$sharedlib_from_linklib_result
494713498266Sopenharmony_ci	          fi
494813498266Sopenharmony_ci	        fi
494913498266Sopenharmony_ci	        $opt_dry_run || {
495013498266Sopenharmony_ci	          if test -n "$dlprefile_dlbasename"; then
495113498266Sopenharmony_ci	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
495213498266Sopenharmony_ci	          else
495313498266Sopenharmony_ci	            func_warning "Could not compute DLL name from $name"
495413498266Sopenharmony_ci	            eval '$ECHO ": $name " >> "$nlist"'
495513498266Sopenharmony_ci	          fi
495613498266Sopenharmony_ci	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
495713498266Sopenharmony_ci	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
495813498266Sopenharmony_ci	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
495913498266Sopenharmony_ci	        }
496013498266Sopenharmony_ci	      else # not an import lib
496113498266Sopenharmony_ci	        $opt_dry_run || {
496213498266Sopenharmony_ci	          eval '$ECHO ": $name " >> "$nlist"'
496313498266Sopenharmony_ci	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
496413498266Sopenharmony_ci	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
496513498266Sopenharmony_ci	        }
496613498266Sopenharmony_ci	      fi
496713498266Sopenharmony_ci	    ;;
496813498266Sopenharmony_ci	    *)
496913498266Sopenharmony_ci	      $opt_dry_run || {
497013498266Sopenharmony_ci	        eval '$ECHO ": $name " >> "$nlist"'
497113498266Sopenharmony_ci	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
497213498266Sopenharmony_ci	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
497313498266Sopenharmony_ci	      }
497413498266Sopenharmony_ci	    ;;
497513498266Sopenharmony_ci          esac
497613498266Sopenharmony_ci	done
497713498266Sopenharmony_ci
497813498266Sopenharmony_ci	$opt_dry_run || {
497913498266Sopenharmony_ci	  # Make sure we have at least an empty file.
498013498266Sopenharmony_ci	  test -f "$nlist" || : > "$nlist"
498113498266Sopenharmony_ci
498213498266Sopenharmony_ci	  if test -n "$exclude_expsyms"; then
498313498266Sopenharmony_ci	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
498413498266Sopenharmony_ci	    $MV "$nlist"T "$nlist"
498513498266Sopenharmony_ci	  fi
498613498266Sopenharmony_ci
498713498266Sopenharmony_ci	  # Try sorting and uniquifying the output.
498813498266Sopenharmony_ci	  if $GREP -v "^: " < "$nlist" |
498913498266Sopenharmony_ci	      if sort -k 3 </dev/null >/dev/null 2>&1; then
499013498266Sopenharmony_ci		sort -k 3
499113498266Sopenharmony_ci	      else
499213498266Sopenharmony_ci		sort +2
499313498266Sopenharmony_ci	      fi |
499413498266Sopenharmony_ci	      uniq > "$nlist"S; then
499513498266Sopenharmony_ci	    :
499613498266Sopenharmony_ci	  else
499713498266Sopenharmony_ci	    $GREP -v "^: " < "$nlist" > "$nlist"S
499813498266Sopenharmony_ci	  fi
499913498266Sopenharmony_ci
500013498266Sopenharmony_ci	  if test -f "$nlist"S; then
500113498266Sopenharmony_ci	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
500213498266Sopenharmony_ci	  else
500313498266Sopenharmony_ci	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
500413498266Sopenharmony_ci	  fi
500513498266Sopenharmony_ci
500613498266Sopenharmony_ci	  func_show_eval '$RM "${nlist}I"'
500713498266Sopenharmony_ci	  if test -n "$global_symbol_to_import"; then
500813498266Sopenharmony_ci	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
500913498266Sopenharmony_ci	  fi
501013498266Sopenharmony_ci
501113498266Sopenharmony_ci	  echo >> "$output_objdir/$my_dlsyms" "\
501213498266Sopenharmony_ci
501313498266Sopenharmony_ci/* The mapping between symbol names and symbols.  */
501413498266Sopenharmony_citypedef struct {
501513498266Sopenharmony_ci  const char *name;
501613498266Sopenharmony_ci  void *address;
501713498266Sopenharmony_ci} lt_dlsymlist;
501813498266Sopenharmony_ciextern LT_DLSYM_CONST lt_dlsymlist
501913498266Sopenharmony_cilt_${my_prefix}_LTX_preloaded_symbols[];\
502013498266Sopenharmony_ci"
502113498266Sopenharmony_ci
502213498266Sopenharmony_ci	  if test -s "$nlist"I; then
502313498266Sopenharmony_ci	    echo >> "$output_objdir/$my_dlsyms" "\
502413498266Sopenharmony_cistatic void lt_syminit(void)
502513498266Sopenharmony_ci{
502613498266Sopenharmony_ci  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
502713498266Sopenharmony_ci  for (; symbol->name; ++symbol)
502813498266Sopenharmony_ci    {"
502913498266Sopenharmony_ci	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
503013498266Sopenharmony_ci	    echo >> "$output_objdir/$my_dlsyms" "\
503113498266Sopenharmony_ci    }
503213498266Sopenharmony_ci}"
503313498266Sopenharmony_ci	  fi
503413498266Sopenharmony_ci	  echo >> "$output_objdir/$my_dlsyms" "\
503513498266Sopenharmony_ciLT_DLSYM_CONST lt_dlsymlist
503613498266Sopenharmony_cilt_${my_prefix}_LTX_preloaded_symbols[] =
503713498266Sopenharmony_ci{ {\"$my_originator\", (void *) 0},"
503813498266Sopenharmony_ci
503913498266Sopenharmony_ci	  if test -s "$nlist"I; then
504013498266Sopenharmony_ci	    echo >> "$output_objdir/$my_dlsyms" "\
504113498266Sopenharmony_ci  {\"@INIT@\", (void *) &lt_syminit},"
504213498266Sopenharmony_ci	  fi
504313498266Sopenharmony_ci
504413498266Sopenharmony_ci	  case $need_lib_prefix in
504513498266Sopenharmony_ci	  no)
504613498266Sopenharmony_ci	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
504713498266Sopenharmony_ci	    ;;
504813498266Sopenharmony_ci	  *)
504913498266Sopenharmony_ci	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
505013498266Sopenharmony_ci	    ;;
505113498266Sopenharmony_ci	  esac
505213498266Sopenharmony_ci	  echo >> "$output_objdir/$my_dlsyms" "\
505313498266Sopenharmony_ci  {0, (void *) 0}
505413498266Sopenharmony_ci};
505513498266Sopenharmony_ci
505613498266Sopenharmony_ci/* This works around a problem in FreeBSD linker */
505713498266Sopenharmony_ci#ifdef FREEBSD_WORKAROUND
505813498266Sopenharmony_cistatic const void *lt_preloaded_setup() {
505913498266Sopenharmony_ci  return lt_${my_prefix}_LTX_preloaded_symbols;
506013498266Sopenharmony_ci}
506113498266Sopenharmony_ci#endif
506213498266Sopenharmony_ci
506313498266Sopenharmony_ci#ifdef __cplusplus
506413498266Sopenharmony_ci}
506513498266Sopenharmony_ci#endif\
506613498266Sopenharmony_ci"
506713498266Sopenharmony_ci	} # !$opt_dry_run
506813498266Sopenharmony_ci
506913498266Sopenharmony_ci	pic_flag_for_symtable=
507013498266Sopenharmony_ci	case "$compile_command " in
507113498266Sopenharmony_ci	*" -static "*) ;;
507213498266Sopenharmony_ci	*)
507313498266Sopenharmony_ci	  case $host in
507413498266Sopenharmony_ci	  # compiling the symbol table file with pic_flag works around
507513498266Sopenharmony_ci	  # a FreeBSD bug that causes programs to crash when -lm is
507613498266Sopenharmony_ci	  # linked before any other PIC object.  But we must not use
507713498266Sopenharmony_ci	  # pic_flag when linking with -static.  The problem exists in
507813498266Sopenharmony_ci	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
507913498266Sopenharmony_ci	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
508013498266Sopenharmony_ci	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
508113498266Sopenharmony_ci	  *-*-hpux*)
508213498266Sopenharmony_ci	    pic_flag_for_symtable=" $pic_flag"  ;;
508313498266Sopenharmony_ci	  *)
508413498266Sopenharmony_ci	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
508513498266Sopenharmony_ci	    ;;
508613498266Sopenharmony_ci	  esac
508713498266Sopenharmony_ci	  ;;
508813498266Sopenharmony_ci	esac
508913498266Sopenharmony_ci	symtab_cflags=
509013498266Sopenharmony_ci	for arg in $LTCFLAGS; do
509113498266Sopenharmony_ci	  case $arg in
509213498266Sopenharmony_ci	  -pie | -fpie | -fPIE) ;;
509313498266Sopenharmony_ci	  *) func_append symtab_cflags " $arg" ;;
509413498266Sopenharmony_ci	  esac
509513498266Sopenharmony_ci	done
509613498266Sopenharmony_ci
509713498266Sopenharmony_ci	# Now compile the dynamic symbol file.
509813498266Sopenharmony_ci	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
509913498266Sopenharmony_ci
510013498266Sopenharmony_ci	# Clean up the generated files.
510113498266Sopenharmony_ci	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
510213498266Sopenharmony_ci
510313498266Sopenharmony_ci	# Transform the symbol file into the correct name.
510413498266Sopenharmony_ci	symfileobj=$output_objdir/${my_outputname}S.$objext
510513498266Sopenharmony_ci	case $host in
510613498266Sopenharmony_ci	*cygwin* | *mingw* | *cegcc* )
510713498266Sopenharmony_ci	  if test -f "$output_objdir/$my_outputname.def"; then
510813498266Sopenharmony_ci	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
510913498266Sopenharmony_ci	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
511013498266Sopenharmony_ci	  else
511113498266Sopenharmony_ci	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
511213498266Sopenharmony_ci	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
511313498266Sopenharmony_ci	  fi
511413498266Sopenharmony_ci	  ;;
511513498266Sopenharmony_ci	*)
511613498266Sopenharmony_ci	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
511713498266Sopenharmony_ci	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
511813498266Sopenharmony_ci	  ;;
511913498266Sopenharmony_ci	esac
512013498266Sopenharmony_ci	;;
512113498266Sopenharmony_ci      *)
512213498266Sopenharmony_ci	func_fatal_error "unknown suffix for '$my_dlsyms'"
512313498266Sopenharmony_ci	;;
512413498266Sopenharmony_ci      esac
512513498266Sopenharmony_ci    else
512613498266Sopenharmony_ci      # We keep going just in case the user didn't refer to
512713498266Sopenharmony_ci      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
512813498266Sopenharmony_ci      # really was required.
512913498266Sopenharmony_ci
513013498266Sopenharmony_ci      # Nullify the symbol file.
513113498266Sopenharmony_ci      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
513213498266Sopenharmony_ci      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
513313498266Sopenharmony_ci    fi
513413498266Sopenharmony_ci}
513513498266Sopenharmony_ci
513613498266Sopenharmony_ci# func_cygming_gnu_implib_p ARG
513713498266Sopenharmony_ci# This predicate returns with zero status (TRUE) if
513813498266Sopenharmony_ci# ARG is a GNU/binutils-style import library. Returns
513913498266Sopenharmony_ci# with nonzero status (FALSE) otherwise.
514013498266Sopenharmony_cifunc_cygming_gnu_implib_p ()
514113498266Sopenharmony_ci{
514213498266Sopenharmony_ci  $debug_cmd
514313498266Sopenharmony_ci
514413498266Sopenharmony_ci  func_to_tool_file "$1" func_convert_file_msys_to_w32
514513498266Sopenharmony_ci  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)$'`
514613498266Sopenharmony_ci  test -n "$func_cygming_gnu_implib_tmp"
514713498266Sopenharmony_ci}
514813498266Sopenharmony_ci
514913498266Sopenharmony_ci# func_cygming_ms_implib_p ARG
515013498266Sopenharmony_ci# This predicate returns with zero status (TRUE) if
515113498266Sopenharmony_ci# ARG is an MS-style import library. Returns
515213498266Sopenharmony_ci# with nonzero status (FALSE) otherwise.
515313498266Sopenharmony_cifunc_cygming_ms_implib_p ()
515413498266Sopenharmony_ci{
515513498266Sopenharmony_ci  $debug_cmd
515613498266Sopenharmony_ci
515713498266Sopenharmony_ci  func_to_tool_file "$1" func_convert_file_msys_to_w32
515813498266Sopenharmony_ci  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
515913498266Sopenharmony_ci  test -n "$func_cygming_ms_implib_tmp"
516013498266Sopenharmony_ci}
516113498266Sopenharmony_ci
516213498266Sopenharmony_ci# func_win32_libid arg
516313498266Sopenharmony_ci# return the library type of file 'arg'
516413498266Sopenharmony_ci#
516513498266Sopenharmony_ci# Need a lot of goo to handle *both* DLLs and import libs
516613498266Sopenharmony_ci# Has to be a shell function in order to 'eat' the argument
516713498266Sopenharmony_ci# that is supplied when $file_magic_command is called.
516813498266Sopenharmony_ci# Despite the name, also deal with 64 bit binaries.
516913498266Sopenharmony_cifunc_win32_libid ()
517013498266Sopenharmony_ci{
517113498266Sopenharmony_ci  $debug_cmd
517213498266Sopenharmony_ci
517313498266Sopenharmony_ci  win32_libid_type=unknown
517413498266Sopenharmony_ci  win32_fileres=`file -L $1 2>/dev/null`
517513498266Sopenharmony_ci  case $win32_fileres in
517613498266Sopenharmony_ci  *ar\ archive\ import\ library*) # definitely import
517713498266Sopenharmony_ci    win32_libid_type="x86 archive import"
517813498266Sopenharmony_ci    ;;
517913498266Sopenharmony_ci  *ar\ archive*) # could be an import, or static
518013498266Sopenharmony_ci    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
518113498266Sopenharmony_ci    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
518213498266Sopenharmony_ci       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
518313498266Sopenharmony_ci      case $nm_interface in
518413498266Sopenharmony_ci      "MS dumpbin")
518513498266Sopenharmony_ci	if func_cygming_ms_implib_p "$1" ||
518613498266Sopenharmony_ci	   func_cygming_gnu_implib_p "$1"
518713498266Sopenharmony_ci	then
518813498266Sopenharmony_ci	  win32_nmres=import
518913498266Sopenharmony_ci	else
519013498266Sopenharmony_ci	  win32_nmres=
519113498266Sopenharmony_ci	fi
519213498266Sopenharmony_ci	;;
519313498266Sopenharmony_ci      *)
519413498266Sopenharmony_ci	func_to_tool_file "$1" func_convert_file_msys_to_w32
519513498266Sopenharmony_ci	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
519613498266Sopenharmony_ci	  $SED -n -e '
519713498266Sopenharmony_ci	    1,100{
519813498266Sopenharmony_ci		/ I /{
519913498266Sopenharmony_ci		    s|.*|import|
520013498266Sopenharmony_ci		    p
520113498266Sopenharmony_ci		    q
520213498266Sopenharmony_ci		}
520313498266Sopenharmony_ci	    }'`
520413498266Sopenharmony_ci	;;
520513498266Sopenharmony_ci      esac
520613498266Sopenharmony_ci      case $win32_nmres in
520713498266Sopenharmony_ci      import*)  win32_libid_type="x86 archive import";;
520813498266Sopenharmony_ci      *)        win32_libid_type="x86 archive static";;
520913498266Sopenharmony_ci      esac
521013498266Sopenharmony_ci    fi
521113498266Sopenharmony_ci    ;;
521213498266Sopenharmony_ci  *DLL*)
521313498266Sopenharmony_ci    win32_libid_type="x86 DLL"
521413498266Sopenharmony_ci    ;;
521513498266Sopenharmony_ci  *executable*) # but shell scripts are "executable" too...
521613498266Sopenharmony_ci    case $win32_fileres in
521713498266Sopenharmony_ci    *MS\ Windows\ PE\ Intel*)
521813498266Sopenharmony_ci      win32_libid_type="x86 DLL"
521913498266Sopenharmony_ci      ;;
522013498266Sopenharmony_ci    esac
522113498266Sopenharmony_ci    ;;
522213498266Sopenharmony_ci  esac
522313498266Sopenharmony_ci  $ECHO "$win32_libid_type"
522413498266Sopenharmony_ci}
522513498266Sopenharmony_ci
522613498266Sopenharmony_ci# func_cygming_dll_for_implib ARG
522713498266Sopenharmony_ci#
522813498266Sopenharmony_ci# Platform-specific function to extract the
522913498266Sopenharmony_ci# name of the DLL associated with the specified
523013498266Sopenharmony_ci# import library ARG.
523113498266Sopenharmony_ci# Invoked by eval'ing the libtool variable
523213498266Sopenharmony_ci#    $sharedlib_from_linklib_cmd
523313498266Sopenharmony_ci# Result is available in the variable
523413498266Sopenharmony_ci#    $sharedlib_from_linklib_result
523513498266Sopenharmony_cifunc_cygming_dll_for_implib ()
523613498266Sopenharmony_ci{
523713498266Sopenharmony_ci  $debug_cmd
523813498266Sopenharmony_ci
523913498266Sopenharmony_ci  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
524013498266Sopenharmony_ci}
524113498266Sopenharmony_ci
524213498266Sopenharmony_ci# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
524313498266Sopenharmony_ci#
524413498266Sopenharmony_ci# The is the core of a fallback implementation of a
524513498266Sopenharmony_ci# platform-specific function to extract the name of the
524613498266Sopenharmony_ci# DLL associated with the specified import library LIBNAME.
524713498266Sopenharmony_ci#
524813498266Sopenharmony_ci# SECTION_NAME is either .idata$6 or .idata$7, depending
524913498266Sopenharmony_ci# on the platform and compiler that created the implib.
525013498266Sopenharmony_ci#
525113498266Sopenharmony_ci# Echos the name of the DLL associated with the
525213498266Sopenharmony_ci# specified import library.
525313498266Sopenharmony_cifunc_cygming_dll_for_implib_fallback_core ()
525413498266Sopenharmony_ci{
525513498266Sopenharmony_ci  $debug_cmd
525613498266Sopenharmony_ci
525713498266Sopenharmony_ci  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
525813498266Sopenharmony_ci  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
525913498266Sopenharmony_ci    $SED '/^Contents of section '"$match_literal"':/{
526013498266Sopenharmony_ci      # Place marker at beginning of archive member dllname section
526113498266Sopenharmony_ci      s/.*/====MARK====/
526213498266Sopenharmony_ci      p
526313498266Sopenharmony_ci      d
526413498266Sopenharmony_ci    }
526513498266Sopenharmony_ci    # These lines can sometimes be longer than 43 characters, but
526613498266Sopenharmony_ci    # are always uninteresting
526713498266Sopenharmony_ci    /:[	 ]*file format pe[i]\{,1\}-/d
526813498266Sopenharmony_ci    /^In archive [^:]*:/d
526913498266Sopenharmony_ci    # Ensure marker is printed
527013498266Sopenharmony_ci    /^====MARK====/p
527113498266Sopenharmony_ci    # Remove all lines with less than 43 characters
527213498266Sopenharmony_ci    /^.\{43\}/!d
527313498266Sopenharmony_ci    # From remaining lines, remove first 43 characters
527413498266Sopenharmony_ci    s/^.\{43\}//' |
527513498266Sopenharmony_ci    $SED -n '
527613498266Sopenharmony_ci      # Join marker and all lines until next marker into a single line
527713498266Sopenharmony_ci      /^====MARK====/ b para
527813498266Sopenharmony_ci      H
527913498266Sopenharmony_ci      $ b para
528013498266Sopenharmony_ci      b
528113498266Sopenharmony_ci      :para
528213498266Sopenharmony_ci      x
528313498266Sopenharmony_ci      s/\n//g
528413498266Sopenharmony_ci      # Remove the marker
528513498266Sopenharmony_ci      s/^====MARK====//
528613498266Sopenharmony_ci      # Remove trailing dots and whitespace
528713498266Sopenharmony_ci      s/[\. \t]*$//
528813498266Sopenharmony_ci      # Print
528913498266Sopenharmony_ci      /./p' |
529013498266Sopenharmony_ci    # we now have a list, one entry per line, of the stringified
529113498266Sopenharmony_ci    # contents of the appropriate section of all members of the
529213498266Sopenharmony_ci    # archive that possess that section. Heuristic: eliminate
529313498266Sopenharmony_ci    # all those that have a first or second character that is
529413498266Sopenharmony_ci    # a '.' (that is, objdump's representation of an unprintable
529513498266Sopenharmony_ci    # character.) This should work for all archives with less than
529613498266Sopenharmony_ci    # 0x302f exports -- but will fail for DLLs whose name actually
529713498266Sopenharmony_ci    # begins with a literal '.' or a single character followed by
529813498266Sopenharmony_ci    # a '.'.
529913498266Sopenharmony_ci    #
530013498266Sopenharmony_ci    # Of those that remain, print the first one.
530113498266Sopenharmony_ci    $SED -e '/^\./d;/^.\./d;q'
530213498266Sopenharmony_ci}
530313498266Sopenharmony_ci
530413498266Sopenharmony_ci# func_cygming_dll_for_implib_fallback ARG
530513498266Sopenharmony_ci# Platform-specific function to extract the
530613498266Sopenharmony_ci# name of the DLL associated with the specified
530713498266Sopenharmony_ci# import library ARG.
530813498266Sopenharmony_ci#
530913498266Sopenharmony_ci# This fallback implementation is for use when $DLLTOOL
531013498266Sopenharmony_ci# does not support the --identify-strict option.
531113498266Sopenharmony_ci# Invoked by eval'ing the libtool variable
531213498266Sopenharmony_ci#    $sharedlib_from_linklib_cmd
531313498266Sopenharmony_ci# Result is available in the variable
531413498266Sopenharmony_ci#    $sharedlib_from_linklib_result
531513498266Sopenharmony_cifunc_cygming_dll_for_implib_fallback ()
531613498266Sopenharmony_ci{
531713498266Sopenharmony_ci  $debug_cmd
531813498266Sopenharmony_ci
531913498266Sopenharmony_ci  if func_cygming_gnu_implib_p "$1"; then
532013498266Sopenharmony_ci    # binutils import library
532113498266Sopenharmony_ci    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
532213498266Sopenharmony_ci  elif func_cygming_ms_implib_p "$1"; then
532313498266Sopenharmony_ci    # ms-generated import library
532413498266Sopenharmony_ci    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
532513498266Sopenharmony_ci  else
532613498266Sopenharmony_ci    # unknown
532713498266Sopenharmony_ci    sharedlib_from_linklib_result=
532813498266Sopenharmony_ci  fi
532913498266Sopenharmony_ci}
533013498266Sopenharmony_ci
533113498266Sopenharmony_ci
533213498266Sopenharmony_ci# func_extract_an_archive dir oldlib
533313498266Sopenharmony_cifunc_extract_an_archive ()
533413498266Sopenharmony_ci{
533513498266Sopenharmony_ci    $debug_cmd
533613498266Sopenharmony_ci
533713498266Sopenharmony_ci    f_ex_an_ar_dir=$1; shift
533813498266Sopenharmony_ci    f_ex_an_ar_oldlib=$1
533913498266Sopenharmony_ci    if test yes = "$lock_old_archive_extraction"; then
534013498266Sopenharmony_ci      lockfile=$f_ex_an_ar_oldlib.lock
534113498266Sopenharmony_ci      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
534213498266Sopenharmony_ci	func_echo "Waiting for $lockfile to be removed"
534313498266Sopenharmony_ci	sleep 2
534413498266Sopenharmony_ci      done
534513498266Sopenharmony_ci    fi
534613498266Sopenharmony_ci    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
534713498266Sopenharmony_ci		   'stat=$?; rm -f "$lockfile"; exit $stat'
534813498266Sopenharmony_ci    if test yes = "$lock_old_archive_extraction"; then
534913498266Sopenharmony_ci      $opt_dry_run || rm -f "$lockfile"
535013498266Sopenharmony_ci    fi
535113498266Sopenharmony_ci    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
535213498266Sopenharmony_ci     :
535313498266Sopenharmony_ci    else
535413498266Sopenharmony_ci      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
535513498266Sopenharmony_ci    fi
535613498266Sopenharmony_ci}
535713498266Sopenharmony_ci
535813498266Sopenharmony_ci
535913498266Sopenharmony_ci# func_extract_archives gentop oldlib ...
536013498266Sopenharmony_cifunc_extract_archives ()
536113498266Sopenharmony_ci{
536213498266Sopenharmony_ci    $debug_cmd
536313498266Sopenharmony_ci
536413498266Sopenharmony_ci    my_gentop=$1; shift
536513498266Sopenharmony_ci    my_oldlibs=${1+"$@"}
536613498266Sopenharmony_ci    my_oldobjs=
536713498266Sopenharmony_ci    my_xlib=
536813498266Sopenharmony_ci    my_xabs=
536913498266Sopenharmony_ci    my_xdir=
537013498266Sopenharmony_ci
537113498266Sopenharmony_ci    for my_xlib in $my_oldlibs; do
537213498266Sopenharmony_ci      # Extract the objects.
537313498266Sopenharmony_ci      case $my_xlib in
537413498266Sopenharmony_ci	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
537513498266Sopenharmony_ci	*) my_xabs=`pwd`"/$my_xlib" ;;
537613498266Sopenharmony_ci      esac
537713498266Sopenharmony_ci      func_basename "$my_xlib"
537813498266Sopenharmony_ci      my_xlib=$func_basename_result
537913498266Sopenharmony_ci      my_xlib_u=$my_xlib
538013498266Sopenharmony_ci      while :; do
538113498266Sopenharmony_ci        case " $extracted_archives " in
538213498266Sopenharmony_ci	*" $my_xlib_u "*)
538313498266Sopenharmony_ci	  func_arith $extracted_serial + 1
538413498266Sopenharmony_ci	  extracted_serial=$func_arith_result
538513498266Sopenharmony_ci	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
538613498266Sopenharmony_ci	*) break ;;
538713498266Sopenharmony_ci	esac
538813498266Sopenharmony_ci      done
538913498266Sopenharmony_ci      extracted_archives="$extracted_archives $my_xlib_u"
539013498266Sopenharmony_ci      my_xdir=$my_gentop/$my_xlib_u
539113498266Sopenharmony_ci
539213498266Sopenharmony_ci      func_mkdir_p "$my_xdir"
539313498266Sopenharmony_ci
539413498266Sopenharmony_ci      case $host in
539513498266Sopenharmony_ci      *-darwin*)
539613498266Sopenharmony_ci	func_verbose "Extracting $my_xabs"
539713498266Sopenharmony_ci	# Do not bother doing anything if just a dry run
539813498266Sopenharmony_ci	$opt_dry_run || {
539913498266Sopenharmony_ci	  darwin_orig_dir=`pwd`
540013498266Sopenharmony_ci	  cd $my_xdir || exit $?
540113498266Sopenharmony_ci	  darwin_archive=$my_xabs
540213498266Sopenharmony_ci	  darwin_curdir=`pwd`
540313498266Sopenharmony_ci	  func_basename "$darwin_archive"
540413498266Sopenharmony_ci	  darwin_base_archive=$func_basename_result
540513498266Sopenharmony_ci	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
540613498266Sopenharmony_ci	  if test -n "$darwin_arches"; then
540713498266Sopenharmony_ci	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
540813498266Sopenharmony_ci	    darwin_arch=
540913498266Sopenharmony_ci	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
541013498266Sopenharmony_ci	    for darwin_arch in  $darwin_arches; do
541113498266Sopenharmony_ci	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
541213498266Sopenharmony_ci	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
541313498266Sopenharmony_ci	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
541413498266Sopenharmony_ci	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
541513498266Sopenharmony_ci	      cd "$darwin_curdir"
541613498266Sopenharmony_ci	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
541713498266Sopenharmony_ci	    done # $darwin_arches
541813498266Sopenharmony_ci            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
541913498266Sopenharmony_ci	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
542013498266Sopenharmony_ci	    darwin_file=
542113498266Sopenharmony_ci	    darwin_files=
542213498266Sopenharmony_ci	    for darwin_file in $darwin_filelist; do
542313498266Sopenharmony_ci	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
542413498266Sopenharmony_ci	      $LIPO -create -output "$darwin_file" $darwin_files
542513498266Sopenharmony_ci	    done # $darwin_filelist
542613498266Sopenharmony_ci	    $RM -rf unfat-$$
542713498266Sopenharmony_ci	    cd "$darwin_orig_dir"
542813498266Sopenharmony_ci	  else
542913498266Sopenharmony_ci	    cd $darwin_orig_dir
543013498266Sopenharmony_ci	    func_extract_an_archive "$my_xdir" "$my_xabs"
543113498266Sopenharmony_ci	  fi # $darwin_arches
543213498266Sopenharmony_ci	} # !$opt_dry_run
543313498266Sopenharmony_ci	;;
543413498266Sopenharmony_ci      *)
543513498266Sopenharmony_ci        func_extract_an_archive "$my_xdir" "$my_xabs"
543613498266Sopenharmony_ci	;;
543713498266Sopenharmony_ci      esac
543813498266Sopenharmony_ci      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
543913498266Sopenharmony_ci    done
544013498266Sopenharmony_ci
544113498266Sopenharmony_ci    func_extract_archives_result=$my_oldobjs
544213498266Sopenharmony_ci}
544313498266Sopenharmony_ci
544413498266Sopenharmony_ci
544513498266Sopenharmony_ci# func_emit_wrapper [arg=no]
544613498266Sopenharmony_ci#
544713498266Sopenharmony_ci# Emit a libtool wrapper script on stdout.
544813498266Sopenharmony_ci# Don't directly open a file because we may want to
544913498266Sopenharmony_ci# incorporate the script contents within a cygwin/mingw
545013498266Sopenharmony_ci# wrapper executable.  Must ONLY be called from within
545113498266Sopenharmony_ci# func_mode_link because it depends on a number of variables
545213498266Sopenharmony_ci# set therein.
545313498266Sopenharmony_ci#
545413498266Sopenharmony_ci# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
545513498266Sopenharmony_ci# variable will take.  If 'yes', then the emitted script
545613498266Sopenharmony_ci# will assume that the directory where it is stored is
545713498266Sopenharmony_ci# the $objdir directory.  This is a cygwin/mingw-specific
545813498266Sopenharmony_ci# behavior.
545913498266Sopenharmony_cifunc_emit_wrapper ()
546013498266Sopenharmony_ci{
546113498266Sopenharmony_ci	func_emit_wrapper_arg1=${1-no}
546213498266Sopenharmony_ci
546313498266Sopenharmony_ci	$ECHO "\
546413498266Sopenharmony_ci#! $SHELL
546513498266Sopenharmony_ci
546613498266Sopenharmony_ci# $output - temporary wrapper script for $objdir/$outputname
546713498266Sopenharmony_ci# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
546813498266Sopenharmony_ci#
546913498266Sopenharmony_ci# The $output program cannot be directly executed until all the libtool
547013498266Sopenharmony_ci# libraries that it depends on are installed.
547113498266Sopenharmony_ci#
547213498266Sopenharmony_ci# This wrapper script should never be moved out of the build directory.
547313498266Sopenharmony_ci# If it is, it will not operate correctly.
547413498266Sopenharmony_ci
547513498266Sopenharmony_ci# Sed substitution that helps us do robust quoting.  It backslashifies
547613498266Sopenharmony_ci# metacharacters that are still active within double-quoted strings.
547713498266Sopenharmony_cised_quote_subst='$sed_quote_subst'
547813498266Sopenharmony_ci
547913498266Sopenharmony_ci# Be Bourne compatible
548013498266Sopenharmony_ciif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
548113498266Sopenharmony_ci  emulate sh
548213498266Sopenharmony_ci  NULLCMD=:
548313498266Sopenharmony_ci  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
548413498266Sopenharmony_ci  # is contrary to our usage.  Disable this feature.
548513498266Sopenharmony_ci  alias -g '\${1+\"\$@\"}'='\"\$@\"'
548613498266Sopenharmony_ci  setopt NO_GLOB_SUBST
548713498266Sopenharmony_cielse
548813498266Sopenharmony_ci  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
548913498266Sopenharmony_cifi
549013498266Sopenharmony_ciBIN_SH=xpg4; export BIN_SH # for Tru64
549113498266Sopenharmony_ciDUALCASE=1; export DUALCASE # for MKS sh
549213498266Sopenharmony_ci
549313498266Sopenharmony_ci# The HP-UX ksh and POSIX shell print the target directory to stdout
549413498266Sopenharmony_ci# if CDPATH is set.
549513498266Sopenharmony_ci(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
549613498266Sopenharmony_ci
549713498266Sopenharmony_cirelink_command=\"$relink_command\"
549813498266Sopenharmony_ci
549913498266Sopenharmony_ci# This environment variable determines our operation mode.
550013498266Sopenharmony_ciif test \"\$libtool_install_magic\" = \"$magic\"; then
550113498266Sopenharmony_ci  # install mode needs the following variables:
550213498266Sopenharmony_ci  generated_by_libtool_version='$macro_version'
550313498266Sopenharmony_ci  notinst_deplibs='$notinst_deplibs'
550413498266Sopenharmony_cielse
550513498266Sopenharmony_ci  # When we are sourced in execute mode, \$file and \$ECHO are already set.
550613498266Sopenharmony_ci  if test \"\$libtool_execute_magic\" != \"$magic\"; then
550713498266Sopenharmony_ci    file=\"\$0\""
550813498266Sopenharmony_ci
550913498266Sopenharmony_ci    func_quote_arg pretty "$ECHO"
551013498266Sopenharmony_ci    qECHO=$func_quote_arg_result
551113498266Sopenharmony_ci    $ECHO "\
551213498266Sopenharmony_ci
551313498266Sopenharmony_ci# A function that is used when there is no print builtin or printf.
551413498266Sopenharmony_cifunc_fallback_echo ()
551513498266Sopenharmony_ci{
551613498266Sopenharmony_ci  eval 'cat <<_LTECHO_EOF
551713498266Sopenharmony_ci\$1
551813498266Sopenharmony_ci_LTECHO_EOF'
551913498266Sopenharmony_ci}
552013498266Sopenharmony_ci    ECHO=$qECHO
552113498266Sopenharmony_ci  fi
552213498266Sopenharmony_ci
552313498266Sopenharmony_ci# Very basic option parsing. These options are (a) specific to
552413498266Sopenharmony_ci# the libtool wrapper, (b) are identical between the wrapper
552513498266Sopenharmony_ci# /script/ and the wrapper /executable/ that is used only on
552613498266Sopenharmony_ci# windows platforms, and (c) all begin with the string "--lt-"
552713498266Sopenharmony_ci# (application programs are unlikely to have options that match
552813498266Sopenharmony_ci# this pattern).
552913498266Sopenharmony_ci#
553013498266Sopenharmony_ci# There are only two supported options: --lt-debug and
553113498266Sopenharmony_ci# --lt-dump-script. There is, deliberately, no --lt-help.
553213498266Sopenharmony_ci#
553313498266Sopenharmony_ci# The first argument to this parsing function should be the
553413498266Sopenharmony_ci# script's $0 value, followed by "$@".
553513498266Sopenharmony_cilt_option_debug=
553613498266Sopenharmony_cifunc_parse_lt_options ()
553713498266Sopenharmony_ci{
553813498266Sopenharmony_ci  lt_script_arg0=\$0
553913498266Sopenharmony_ci  shift
554013498266Sopenharmony_ci  for lt_opt
554113498266Sopenharmony_ci  do
554213498266Sopenharmony_ci    case \"\$lt_opt\" in
554313498266Sopenharmony_ci    --lt-debug) lt_option_debug=1 ;;
554413498266Sopenharmony_ci    --lt-dump-script)
554513498266Sopenharmony_ci        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
554613498266Sopenharmony_ci        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
554713498266Sopenharmony_ci        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
554813498266Sopenharmony_ci        cat \"\$lt_dump_D/\$lt_dump_F\"
554913498266Sopenharmony_ci        exit 0
555013498266Sopenharmony_ci      ;;
555113498266Sopenharmony_ci    --lt-*)
555213498266Sopenharmony_ci        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
555313498266Sopenharmony_ci        exit 1
555413498266Sopenharmony_ci      ;;
555513498266Sopenharmony_ci    esac
555613498266Sopenharmony_ci  done
555713498266Sopenharmony_ci
555813498266Sopenharmony_ci  # Print the debug banner immediately:
555913498266Sopenharmony_ci  if test -n \"\$lt_option_debug\"; then
556013498266Sopenharmony_ci    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
556113498266Sopenharmony_ci  fi
556213498266Sopenharmony_ci}
556313498266Sopenharmony_ci
556413498266Sopenharmony_ci# Used when --lt-debug. Prints its arguments to stdout
556513498266Sopenharmony_ci# (redirection is the responsibility of the caller)
556613498266Sopenharmony_cifunc_lt_dump_args ()
556713498266Sopenharmony_ci{
556813498266Sopenharmony_ci  lt_dump_args_N=1;
556913498266Sopenharmony_ci  for lt_arg
557013498266Sopenharmony_ci  do
557113498266Sopenharmony_ci    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
557213498266Sopenharmony_ci    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
557313498266Sopenharmony_ci  done
557413498266Sopenharmony_ci}
557513498266Sopenharmony_ci
557613498266Sopenharmony_ci# Core function for launching the target application
557713498266Sopenharmony_cifunc_exec_program_core ()
557813498266Sopenharmony_ci{
557913498266Sopenharmony_ci"
558013498266Sopenharmony_ci  case $host in
558113498266Sopenharmony_ci  # Backslashes separate directories on plain windows
558213498266Sopenharmony_ci  *-*-mingw | *-*-os2* | *-cegcc*)
558313498266Sopenharmony_ci    $ECHO "\
558413498266Sopenharmony_ci      if test -n \"\$lt_option_debug\"; then
558513498266Sopenharmony_ci        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
558613498266Sopenharmony_ci        func_lt_dump_args \${1+\"\$@\"} 1>&2
558713498266Sopenharmony_ci      fi
558813498266Sopenharmony_ci      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
558913498266Sopenharmony_ci"
559013498266Sopenharmony_ci    ;;
559113498266Sopenharmony_ci
559213498266Sopenharmony_ci  *)
559313498266Sopenharmony_ci    $ECHO "\
559413498266Sopenharmony_ci      if test -n \"\$lt_option_debug\"; then
559513498266Sopenharmony_ci        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
559613498266Sopenharmony_ci        func_lt_dump_args \${1+\"\$@\"} 1>&2
559713498266Sopenharmony_ci      fi
559813498266Sopenharmony_ci      exec \"\$progdir/\$program\" \${1+\"\$@\"}
559913498266Sopenharmony_ci"
560013498266Sopenharmony_ci    ;;
560113498266Sopenharmony_ci  esac
560213498266Sopenharmony_ci  $ECHO "\
560313498266Sopenharmony_ci      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
560413498266Sopenharmony_ci      exit 1
560513498266Sopenharmony_ci}
560613498266Sopenharmony_ci
560713498266Sopenharmony_ci# A function to encapsulate launching the target application
560813498266Sopenharmony_ci# Strips options in the --lt-* namespace from \$@ and
560913498266Sopenharmony_ci# launches target application with the remaining arguments.
561013498266Sopenharmony_cifunc_exec_program ()
561113498266Sopenharmony_ci{
561213498266Sopenharmony_ci  case \" \$* \" in
561313498266Sopenharmony_ci  *\\ --lt-*)
561413498266Sopenharmony_ci    for lt_wr_arg
561513498266Sopenharmony_ci    do
561613498266Sopenharmony_ci      case \$lt_wr_arg in
561713498266Sopenharmony_ci      --lt-*) ;;
561813498266Sopenharmony_ci      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
561913498266Sopenharmony_ci      esac
562013498266Sopenharmony_ci      shift
562113498266Sopenharmony_ci    done ;;
562213498266Sopenharmony_ci  esac
562313498266Sopenharmony_ci  func_exec_program_core \${1+\"\$@\"}
562413498266Sopenharmony_ci}
562513498266Sopenharmony_ci
562613498266Sopenharmony_ci  # Parse options
562713498266Sopenharmony_ci  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
562813498266Sopenharmony_ci
562913498266Sopenharmony_ci  # Find the directory that this script lives in.
563013498266Sopenharmony_ci  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
563113498266Sopenharmony_ci  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
563213498266Sopenharmony_ci
563313498266Sopenharmony_ci  # Follow symbolic links until we get to the real thisdir.
563413498266Sopenharmony_ci  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
563513498266Sopenharmony_ci  while test -n \"\$file\"; do
563613498266Sopenharmony_ci    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
563713498266Sopenharmony_ci
563813498266Sopenharmony_ci    # If there was a directory component, then change thisdir.
563913498266Sopenharmony_ci    if test \"x\$destdir\" != \"x\$file\"; then
564013498266Sopenharmony_ci      case \"\$destdir\" in
564113498266Sopenharmony_ci      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
564213498266Sopenharmony_ci      *) thisdir=\"\$thisdir/\$destdir\" ;;
564313498266Sopenharmony_ci      esac
564413498266Sopenharmony_ci    fi
564513498266Sopenharmony_ci
564613498266Sopenharmony_ci    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
564713498266Sopenharmony_ci    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
564813498266Sopenharmony_ci  done
564913498266Sopenharmony_ci
565013498266Sopenharmony_ci  # Usually 'no', except on cygwin/mingw when embedded into
565113498266Sopenharmony_ci  # the cwrapper.
565213498266Sopenharmony_ci  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
565313498266Sopenharmony_ci  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
565413498266Sopenharmony_ci    # special case for '.'
565513498266Sopenharmony_ci    if test \"\$thisdir\" = \".\"; then
565613498266Sopenharmony_ci      thisdir=\`pwd\`
565713498266Sopenharmony_ci    fi
565813498266Sopenharmony_ci    # remove .libs from thisdir
565913498266Sopenharmony_ci    case \"\$thisdir\" in
566013498266Sopenharmony_ci    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
566113498266Sopenharmony_ci    $objdir )   thisdir=. ;;
566213498266Sopenharmony_ci    esac
566313498266Sopenharmony_ci  fi
566413498266Sopenharmony_ci
566513498266Sopenharmony_ci  # Try to get the absolute directory name.
566613498266Sopenharmony_ci  absdir=\`cd \"\$thisdir\" && pwd\`
566713498266Sopenharmony_ci  test -n \"\$absdir\" && thisdir=\"\$absdir\"
566813498266Sopenharmony_ci"
566913498266Sopenharmony_ci
567013498266Sopenharmony_ci	if test yes = "$fast_install"; then
567113498266Sopenharmony_ci	  $ECHO "\
567213498266Sopenharmony_ci  program=lt-'$outputname'$exeext
567313498266Sopenharmony_ci  progdir=\"\$thisdir/$objdir\"
567413498266Sopenharmony_ci
567513498266Sopenharmony_ci  if test ! -f \"\$progdir/\$program\" ||
567613498266Sopenharmony_ci     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
567713498266Sopenharmony_ci       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
567813498266Sopenharmony_ci
567913498266Sopenharmony_ci    file=\"\$\$-\$program\"
568013498266Sopenharmony_ci
568113498266Sopenharmony_ci    if test ! -d \"\$progdir\"; then
568213498266Sopenharmony_ci      $MKDIR \"\$progdir\"
568313498266Sopenharmony_ci    else
568413498266Sopenharmony_ci      $RM \"\$progdir/\$file\"
568513498266Sopenharmony_ci    fi"
568613498266Sopenharmony_ci
568713498266Sopenharmony_ci	  $ECHO "\
568813498266Sopenharmony_ci
568913498266Sopenharmony_ci    # relink executable if necessary
569013498266Sopenharmony_ci    if test -n \"\$relink_command\"; then
569113498266Sopenharmony_ci      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
569213498266Sopenharmony_ci      else
569313498266Sopenharmony_ci	\$ECHO \"\$relink_command_output\" >&2
569413498266Sopenharmony_ci	$RM \"\$progdir/\$file\"
569513498266Sopenharmony_ci	exit 1
569613498266Sopenharmony_ci      fi
569713498266Sopenharmony_ci    fi
569813498266Sopenharmony_ci
569913498266Sopenharmony_ci    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
570013498266Sopenharmony_ci    { $RM \"\$progdir/\$program\";
570113498266Sopenharmony_ci      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
570213498266Sopenharmony_ci    $RM \"\$progdir/\$file\"
570313498266Sopenharmony_ci  fi"
570413498266Sopenharmony_ci	else
570513498266Sopenharmony_ci	  $ECHO "\
570613498266Sopenharmony_ci  program='$outputname'
570713498266Sopenharmony_ci  progdir=\"\$thisdir/$objdir\"
570813498266Sopenharmony_ci"
570913498266Sopenharmony_ci	fi
571013498266Sopenharmony_ci
571113498266Sopenharmony_ci	$ECHO "\
571213498266Sopenharmony_ci
571313498266Sopenharmony_ci  if test -f \"\$progdir/\$program\"; then"
571413498266Sopenharmony_ci
571513498266Sopenharmony_ci	# fixup the dll searchpath if we need to.
571613498266Sopenharmony_ci	#
571713498266Sopenharmony_ci	# Fix the DLL searchpath if we need to.  Do this before prepending
571813498266Sopenharmony_ci	# to shlibpath, because on Windows, both are PATH and uninstalled
571913498266Sopenharmony_ci	# libraries must come first.
572013498266Sopenharmony_ci	if test -n "$dllsearchpath"; then
572113498266Sopenharmony_ci	  $ECHO "\
572213498266Sopenharmony_ci    # Add the dll search path components to the executable PATH
572313498266Sopenharmony_ci    PATH=$dllsearchpath:\$PATH
572413498266Sopenharmony_ci"
572513498266Sopenharmony_ci	fi
572613498266Sopenharmony_ci
572713498266Sopenharmony_ci	# Export our shlibpath_var if we have one.
572813498266Sopenharmony_ci	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
572913498266Sopenharmony_ci	  $ECHO "\
573013498266Sopenharmony_ci    # Add our own library path to $shlibpath_var
573113498266Sopenharmony_ci    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
573213498266Sopenharmony_ci
573313498266Sopenharmony_ci    # Some systems cannot cope with colon-terminated $shlibpath_var
573413498266Sopenharmony_ci    # The second colon is a workaround for a bug in BeOS R4 sed
573513498266Sopenharmony_ci    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
573613498266Sopenharmony_ci
573713498266Sopenharmony_ci    export $shlibpath_var
573813498266Sopenharmony_ci"
573913498266Sopenharmony_ci	fi
574013498266Sopenharmony_ci
574113498266Sopenharmony_ci	$ECHO "\
574213498266Sopenharmony_ci    if test \"\$libtool_execute_magic\" != \"$magic\"; then
574313498266Sopenharmony_ci      # Run the actual program with our arguments.
574413498266Sopenharmony_ci      func_exec_program \${1+\"\$@\"}
574513498266Sopenharmony_ci    fi
574613498266Sopenharmony_ci  else
574713498266Sopenharmony_ci    # The program doesn't exist.
574813498266Sopenharmony_ci    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
574913498266Sopenharmony_ci    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
575013498266Sopenharmony_ci    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
575113498266Sopenharmony_ci    exit 1
575213498266Sopenharmony_ci  fi
575313498266Sopenharmony_cifi\
575413498266Sopenharmony_ci"
575513498266Sopenharmony_ci}
575613498266Sopenharmony_ci
575713498266Sopenharmony_ci
575813498266Sopenharmony_ci# func_emit_cwrapperexe_src
575913498266Sopenharmony_ci# emit the source code for a wrapper executable on stdout
576013498266Sopenharmony_ci# Must ONLY be called from within func_mode_link because
576113498266Sopenharmony_ci# it depends on a number of variable set therein.
576213498266Sopenharmony_cifunc_emit_cwrapperexe_src ()
576313498266Sopenharmony_ci{
576413498266Sopenharmony_ci	cat <<EOF
576513498266Sopenharmony_ci
576613498266Sopenharmony_ci/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
576713498266Sopenharmony_ci   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
576813498266Sopenharmony_ci
576913498266Sopenharmony_ci   The $output program cannot be directly executed until all the libtool
577013498266Sopenharmony_ci   libraries that it depends on are installed.
577113498266Sopenharmony_ci
577213498266Sopenharmony_ci   This wrapper executable should never be moved out of the build directory.
577313498266Sopenharmony_ci   If it is, it will not operate correctly.
577413498266Sopenharmony_ci*/
577513498266Sopenharmony_ciEOF
577613498266Sopenharmony_ci	    cat <<"EOF"
577713498266Sopenharmony_ci#ifdef _MSC_VER
577813498266Sopenharmony_ci# define _CRT_SECURE_NO_DEPRECATE 1
577913498266Sopenharmony_ci#endif
578013498266Sopenharmony_ci#include <stdio.h>
578113498266Sopenharmony_ci#include <stdlib.h>
578213498266Sopenharmony_ci#ifdef _MSC_VER
578313498266Sopenharmony_ci# include <direct.h>
578413498266Sopenharmony_ci# include <process.h>
578513498266Sopenharmony_ci# include <io.h>
578613498266Sopenharmony_ci#else
578713498266Sopenharmony_ci# include <unistd.h>
578813498266Sopenharmony_ci# include <stdint.h>
578913498266Sopenharmony_ci# ifdef __CYGWIN__
579013498266Sopenharmony_ci#  include <io.h>
579113498266Sopenharmony_ci# endif
579213498266Sopenharmony_ci#endif
579313498266Sopenharmony_ci#include <malloc.h>
579413498266Sopenharmony_ci#include <stdarg.h>
579513498266Sopenharmony_ci#include <assert.h>
579613498266Sopenharmony_ci#include <string.h>
579713498266Sopenharmony_ci#include <ctype.h>
579813498266Sopenharmony_ci#include <errno.h>
579913498266Sopenharmony_ci#include <fcntl.h>
580013498266Sopenharmony_ci#include <sys/stat.h>
580113498266Sopenharmony_ci
580213498266Sopenharmony_ci#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
580313498266Sopenharmony_ci
580413498266Sopenharmony_ci/* declarations of non-ANSI functions */
580513498266Sopenharmony_ci#if defined __MINGW32__
580613498266Sopenharmony_ci# ifdef __STRICT_ANSI__
580713498266Sopenharmony_ciint _putenv (const char *);
580813498266Sopenharmony_ci# endif
580913498266Sopenharmony_ci#elif defined __CYGWIN__
581013498266Sopenharmony_ci# ifdef __STRICT_ANSI__
581113498266Sopenharmony_cichar *realpath (const char *, char *);
581213498266Sopenharmony_ciint putenv (char *);
581313498266Sopenharmony_ciint setenv (const char *, const char *, int);
581413498266Sopenharmony_ci# endif
581513498266Sopenharmony_ci/* #elif defined other_platform || defined ... */
581613498266Sopenharmony_ci#endif
581713498266Sopenharmony_ci
581813498266Sopenharmony_ci/* portability defines, excluding path handling macros */
581913498266Sopenharmony_ci#if defined _MSC_VER
582013498266Sopenharmony_ci# define setmode _setmode
582113498266Sopenharmony_ci# define stat    _stat
582213498266Sopenharmony_ci# define chmod   _chmod
582313498266Sopenharmony_ci# define getcwd  _getcwd
582413498266Sopenharmony_ci# define putenv  _putenv
582513498266Sopenharmony_ci# define S_IXUSR _S_IEXEC
582613498266Sopenharmony_ci#elif defined __MINGW32__
582713498266Sopenharmony_ci# define setmode _setmode
582813498266Sopenharmony_ci# define stat    _stat
582913498266Sopenharmony_ci# define chmod   _chmod
583013498266Sopenharmony_ci# define getcwd  _getcwd
583113498266Sopenharmony_ci# define putenv  _putenv
583213498266Sopenharmony_ci#elif defined __CYGWIN__
583313498266Sopenharmony_ci# define HAVE_SETENV
583413498266Sopenharmony_ci# define FOPEN_WB "wb"
583513498266Sopenharmony_ci/* #elif defined other platforms ... */
583613498266Sopenharmony_ci#endif
583713498266Sopenharmony_ci
583813498266Sopenharmony_ci#if defined PATH_MAX
583913498266Sopenharmony_ci# define LT_PATHMAX PATH_MAX
584013498266Sopenharmony_ci#elif defined MAXPATHLEN
584113498266Sopenharmony_ci# define LT_PATHMAX MAXPATHLEN
584213498266Sopenharmony_ci#else
584313498266Sopenharmony_ci# define LT_PATHMAX 1024
584413498266Sopenharmony_ci#endif
584513498266Sopenharmony_ci
584613498266Sopenharmony_ci#ifndef S_IXOTH
584713498266Sopenharmony_ci# define S_IXOTH 0
584813498266Sopenharmony_ci#endif
584913498266Sopenharmony_ci#ifndef S_IXGRP
585013498266Sopenharmony_ci# define S_IXGRP 0
585113498266Sopenharmony_ci#endif
585213498266Sopenharmony_ci
585313498266Sopenharmony_ci/* path handling portability macros */
585413498266Sopenharmony_ci#ifndef DIR_SEPARATOR
585513498266Sopenharmony_ci# define DIR_SEPARATOR '/'
585613498266Sopenharmony_ci# define PATH_SEPARATOR ':'
585713498266Sopenharmony_ci#endif
585813498266Sopenharmony_ci
585913498266Sopenharmony_ci#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
586013498266Sopenharmony_ci  defined __OS2__
586113498266Sopenharmony_ci# define HAVE_DOS_BASED_FILE_SYSTEM
586213498266Sopenharmony_ci# define FOPEN_WB "wb"
586313498266Sopenharmony_ci# ifndef DIR_SEPARATOR_2
586413498266Sopenharmony_ci#  define DIR_SEPARATOR_2 '\\'
586513498266Sopenharmony_ci# endif
586613498266Sopenharmony_ci# ifndef PATH_SEPARATOR_2
586713498266Sopenharmony_ci#  define PATH_SEPARATOR_2 ';'
586813498266Sopenharmony_ci# endif
586913498266Sopenharmony_ci#endif
587013498266Sopenharmony_ci
587113498266Sopenharmony_ci#ifndef DIR_SEPARATOR_2
587213498266Sopenharmony_ci# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
587313498266Sopenharmony_ci#else /* DIR_SEPARATOR_2 */
587413498266Sopenharmony_ci# define IS_DIR_SEPARATOR(ch) \
587513498266Sopenharmony_ci	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
587613498266Sopenharmony_ci#endif /* DIR_SEPARATOR_2 */
587713498266Sopenharmony_ci
587813498266Sopenharmony_ci#ifndef PATH_SEPARATOR_2
587913498266Sopenharmony_ci# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
588013498266Sopenharmony_ci#else /* PATH_SEPARATOR_2 */
588113498266Sopenharmony_ci# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
588213498266Sopenharmony_ci#endif /* PATH_SEPARATOR_2 */
588313498266Sopenharmony_ci
588413498266Sopenharmony_ci#ifndef FOPEN_WB
588513498266Sopenharmony_ci# define FOPEN_WB "w"
588613498266Sopenharmony_ci#endif
588713498266Sopenharmony_ci#ifndef _O_BINARY
588813498266Sopenharmony_ci# define _O_BINARY 0
588913498266Sopenharmony_ci#endif
589013498266Sopenharmony_ci
589113498266Sopenharmony_ci#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
589213498266Sopenharmony_ci#define XFREE(stale) do { \
589313498266Sopenharmony_ci  if (stale) { free (stale); stale = 0; } \
589413498266Sopenharmony_ci} while (0)
589513498266Sopenharmony_ci
589613498266Sopenharmony_ci#if defined LT_DEBUGWRAPPER
589713498266Sopenharmony_cistatic int lt_debug = 1;
589813498266Sopenharmony_ci#else
589913498266Sopenharmony_cistatic int lt_debug = 0;
590013498266Sopenharmony_ci#endif
590113498266Sopenharmony_ci
590213498266Sopenharmony_ciconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
590313498266Sopenharmony_ci
590413498266Sopenharmony_civoid *xmalloc (size_t num);
590513498266Sopenharmony_cichar *xstrdup (const char *string);
590613498266Sopenharmony_ciconst char *base_name (const char *name);
590713498266Sopenharmony_cichar *find_executable (const char *wrapper);
590813498266Sopenharmony_cichar *chase_symlinks (const char *pathspec);
590913498266Sopenharmony_ciint make_executable (const char *path);
591013498266Sopenharmony_ciint check_executable (const char *path);
591113498266Sopenharmony_cichar *strendzap (char *str, const char *pat);
591213498266Sopenharmony_civoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
591313498266Sopenharmony_civoid lt_fatal (const char *file, int line, const char *message, ...);
591413498266Sopenharmony_cistatic const char *nonnull (const char *s);
591513498266Sopenharmony_cistatic const char *nonempty (const char *s);
591613498266Sopenharmony_civoid lt_setenv (const char *name, const char *value);
591713498266Sopenharmony_cichar *lt_extend_str (const char *orig_value, const char *add, int to_end);
591813498266Sopenharmony_civoid lt_update_exe_path (const char *name, const char *value);
591913498266Sopenharmony_civoid lt_update_lib_path (const char *name, const char *value);
592013498266Sopenharmony_cichar **prepare_spawn (char **argv);
592113498266Sopenharmony_civoid lt_dump_script (FILE *f);
592213498266Sopenharmony_ciEOF
592313498266Sopenharmony_ci
592413498266Sopenharmony_ci	    cat <<EOF
592513498266Sopenharmony_ci#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
592613498266Sopenharmony_ci# define externally_visible volatile
592713498266Sopenharmony_ci#else
592813498266Sopenharmony_ci# define externally_visible __attribute__((externally_visible)) volatile
592913498266Sopenharmony_ci#endif
593013498266Sopenharmony_ciexternally_visible const char * MAGIC_EXE = "$magic_exe";
593113498266Sopenharmony_ciconst char * LIB_PATH_VARNAME = "$shlibpath_var";
593213498266Sopenharmony_ciEOF
593313498266Sopenharmony_ci
593413498266Sopenharmony_ci	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
593513498266Sopenharmony_ci              func_to_host_path "$temp_rpath"
593613498266Sopenharmony_ci	      cat <<EOF
593713498266Sopenharmony_ciconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
593813498266Sopenharmony_ciEOF
593913498266Sopenharmony_ci	    else
594013498266Sopenharmony_ci	      cat <<"EOF"
594113498266Sopenharmony_ciconst char * LIB_PATH_VALUE   = "";
594213498266Sopenharmony_ciEOF
594313498266Sopenharmony_ci	    fi
594413498266Sopenharmony_ci
594513498266Sopenharmony_ci	    if test -n "$dllsearchpath"; then
594613498266Sopenharmony_ci              func_to_host_path "$dllsearchpath:"
594713498266Sopenharmony_ci	      cat <<EOF
594813498266Sopenharmony_ciconst char * EXE_PATH_VARNAME = "PATH";
594913498266Sopenharmony_ciconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
595013498266Sopenharmony_ciEOF
595113498266Sopenharmony_ci	    else
595213498266Sopenharmony_ci	      cat <<"EOF"
595313498266Sopenharmony_ciconst char * EXE_PATH_VARNAME = "";
595413498266Sopenharmony_ciconst char * EXE_PATH_VALUE   = "";
595513498266Sopenharmony_ciEOF
595613498266Sopenharmony_ci	    fi
595713498266Sopenharmony_ci
595813498266Sopenharmony_ci	    if test yes = "$fast_install"; then
595913498266Sopenharmony_ci	      cat <<EOF
596013498266Sopenharmony_ciconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
596113498266Sopenharmony_ciEOF
596213498266Sopenharmony_ci	    else
596313498266Sopenharmony_ci	      cat <<EOF
596413498266Sopenharmony_ciconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
596513498266Sopenharmony_ciEOF
596613498266Sopenharmony_ci	    fi
596713498266Sopenharmony_ci
596813498266Sopenharmony_ci
596913498266Sopenharmony_ci	    cat <<"EOF"
597013498266Sopenharmony_ci
597113498266Sopenharmony_ci#define LTWRAPPER_OPTION_PREFIX         "--lt-"
597213498266Sopenharmony_ci
597313498266Sopenharmony_cistatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
597413498266Sopenharmony_cistatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
597513498266Sopenharmony_cistatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
597613498266Sopenharmony_ci
597713498266Sopenharmony_ciint
597813498266Sopenharmony_cimain (int argc, char *argv[])
597913498266Sopenharmony_ci{
598013498266Sopenharmony_ci  char **newargz;
598113498266Sopenharmony_ci  int  newargc;
598213498266Sopenharmony_ci  char *tmp_pathspec;
598313498266Sopenharmony_ci  char *actual_cwrapper_path;
598413498266Sopenharmony_ci  char *actual_cwrapper_name;
598513498266Sopenharmony_ci  char *target_name;
598613498266Sopenharmony_ci  char *lt_argv_zero;
598713498266Sopenharmony_ci  int rval = 127;
598813498266Sopenharmony_ci
598913498266Sopenharmony_ci  int i;
599013498266Sopenharmony_ci
599113498266Sopenharmony_ci  program_name = (char *) xstrdup (base_name (argv[0]));
599213498266Sopenharmony_ci  newargz = XMALLOC (char *, (size_t) argc + 1);
599313498266Sopenharmony_ci
599413498266Sopenharmony_ci  /* very simple arg parsing; don't want to rely on getopt
599513498266Sopenharmony_ci   * also, copy all non cwrapper options to newargz, except
599613498266Sopenharmony_ci   * argz[0], which is handled differently
599713498266Sopenharmony_ci   */
599813498266Sopenharmony_ci  newargc=0;
599913498266Sopenharmony_ci  for (i = 1; i < argc; i++)
600013498266Sopenharmony_ci    {
600113498266Sopenharmony_ci      if (STREQ (argv[i], dumpscript_opt))
600213498266Sopenharmony_ci	{
600313498266Sopenharmony_ciEOF
600413498266Sopenharmony_ci	    case $host in
600513498266Sopenharmony_ci	      *mingw* | *cygwin* )
600613498266Sopenharmony_ci		# make stdout use "unix" line endings
600713498266Sopenharmony_ci		echo "          setmode(1,_O_BINARY);"
600813498266Sopenharmony_ci		;;
600913498266Sopenharmony_ci	      esac
601013498266Sopenharmony_ci
601113498266Sopenharmony_ci	    cat <<"EOF"
601213498266Sopenharmony_ci	  lt_dump_script (stdout);
601313498266Sopenharmony_ci	  return 0;
601413498266Sopenharmony_ci	}
601513498266Sopenharmony_ci      if (STREQ (argv[i], debug_opt))
601613498266Sopenharmony_ci	{
601713498266Sopenharmony_ci          lt_debug = 1;
601813498266Sopenharmony_ci          continue;
601913498266Sopenharmony_ci	}
602013498266Sopenharmony_ci      if (STREQ (argv[i], ltwrapper_option_prefix))
602113498266Sopenharmony_ci        {
602213498266Sopenharmony_ci          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
602313498266Sopenharmony_ci             namespace, but it is not one of the ones we know about and
602413498266Sopenharmony_ci             have already dealt with, above (inluding dump-script), then
602513498266Sopenharmony_ci             report an error. Otherwise, targets might begin to believe
602613498266Sopenharmony_ci             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
602713498266Sopenharmony_ci             namespace. The first time any user complains about this, we'll
602813498266Sopenharmony_ci             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
602913498266Sopenharmony_ci             or a configure.ac-settable value.
603013498266Sopenharmony_ci           */
603113498266Sopenharmony_ci          lt_fatal (__FILE__, __LINE__,
603213498266Sopenharmony_ci		    "unrecognized %s option: '%s'",
603313498266Sopenharmony_ci                    ltwrapper_option_prefix, argv[i]);
603413498266Sopenharmony_ci        }
603513498266Sopenharmony_ci      /* otherwise ... */
603613498266Sopenharmony_ci      newargz[++newargc] = xstrdup (argv[i]);
603713498266Sopenharmony_ci    }
603813498266Sopenharmony_ci  newargz[++newargc] = NULL;
603913498266Sopenharmony_ci
604013498266Sopenharmony_ciEOF
604113498266Sopenharmony_ci	    cat <<EOF
604213498266Sopenharmony_ci  /* The GNU banner must be the first non-error debug message */
604313498266Sopenharmony_ci  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
604413498266Sopenharmony_ciEOF
604513498266Sopenharmony_ci	    cat <<"EOF"
604613498266Sopenharmony_ci  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
604713498266Sopenharmony_ci  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
604813498266Sopenharmony_ci
604913498266Sopenharmony_ci  tmp_pathspec = find_executable (argv[0]);
605013498266Sopenharmony_ci  if (tmp_pathspec == NULL)
605113498266Sopenharmony_ci    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
605213498266Sopenharmony_ci  lt_debugprintf (__FILE__, __LINE__,
605313498266Sopenharmony_ci                  "(main) found exe (before symlink chase) at: %s\n",
605413498266Sopenharmony_ci		  tmp_pathspec);
605513498266Sopenharmony_ci
605613498266Sopenharmony_ci  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
605713498266Sopenharmony_ci  lt_debugprintf (__FILE__, __LINE__,
605813498266Sopenharmony_ci                  "(main) found exe (after symlink chase) at: %s\n",
605913498266Sopenharmony_ci		  actual_cwrapper_path);
606013498266Sopenharmony_ci  XFREE (tmp_pathspec);
606113498266Sopenharmony_ci
606213498266Sopenharmony_ci  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
606313498266Sopenharmony_ci  strendzap (actual_cwrapper_path, actual_cwrapper_name);
606413498266Sopenharmony_ci
606513498266Sopenharmony_ci  /* wrapper name transforms */
606613498266Sopenharmony_ci  strendzap (actual_cwrapper_name, ".exe");
606713498266Sopenharmony_ci  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
606813498266Sopenharmony_ci  XFREE (actual_cwrapper_name);
606913498266Sopenharmony_ci  actual_cwrapper_name = tmp_pathspec;
607013498266Sopenharmony_ci  tmp_pathspec = 0;
607113498266Sopenharmony_ci
607213498266Sopenharmony_ci  /* target_name transforms -- use actual target program name; might have lt- prefix */
607313498266Sopenharmony_ci  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
607413498266Sopenharmony_ci  strendzap (target_name, ".exe");
607513498266Sopenharmony_ci  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
607613498266Sopenharmony_ci  XFREE (target_name);
607713498266Sopenharmony_ci  target_name = tmp_pathspec;
607813498266Sopenharmony_ci  tmp_pathspec = 0;
607913498266Sopenharmony_ci
608013498266Sopenharmony_ci  lt_debugprintf (__FILE__, __LINE__,
608113498266Sopenharmony_ci		  "(main) libtool target name: %s\n",
608213498266Sopenharmony_ci		  target_name);
608313498266Sopenharmony_ciEOF
608413498266Sopenharmony_ci
608513498266Sopenharmony_ci	    cat <<EOF
608613498266Sopenharmony_ci  newargz[0] =
608713498266Sopenharmony_ci    XMALLOC (char, (strlen (actual_cwrapper_path) +
608813498266Sopenharmony_ci		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
608913498266Sopenharmony_ci  strcpy (newargz[0], actual_cwrapper_path);
609013498266Sopenharmony_ci  strcat (newargz[0], "$objdir");
609113498266Sopenharmony_ci  strcat (newargz[0], "/");
609213498266Sopenharmony_ciEOF
609313498266Sopenharmony_ci
609413498266Sopenharmony_ci	    cat <<"EOF"
609513498266Sopenharmony_ci  /* stop here, and copy so we don't have to do this twice */
609613498266Sopenharmony_ci  tmp_pathspec = xstrdup (newargz[0]);
609713498266Sopenharmony_ci
609813498266Sopenharmony_ci  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
609913498266Sopenharmony_ci  strcat (newargz[0], actual_cwrapper_name);
610013498266Sopenharmony_ci
610113498266Sopenharmony_ci  /* DO want the lt- prefix here if it exists, so use target_name */
610213498266Sopenharmony_ci  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
610313498266Sopenharmony_ci  XFREE (tmp_pathspec);
610413498266Sopenharmony_ci  tmp_pathspec = NULL;
610513498266Sopenharmony_ciEOF
610613498266Sopenharmony_ci
610713498266Sopenharmony_ci	    case $host_os in
610813498266Sopenharmony_ci	      mingw*)
610913498266Sopenharmony_ci	    cat <<"EOF"
611013498266Sopenharmony_ci  {
611113498266Sopenharmony_ci    char* p;
611213498266Sopenharmony_ci    while ((p = strchr (newargz[0], '\\')) != NULL)
611313498266Sopenharmony_ci      {
611413498266Sopenharmony_ci	*p = '/';
611513498266Sopenharmony_ci      }
611613498266Sopenharmony_ci    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
611713498266Sopenharmony_ci      {
611813498266Sopenharmony_ci	*p = '/';
611913498266Sopenharmony_ci      }
612013498266Sopenharmony_ci  }
612113498266Sopenharmony_ciEOF
612213498266Sopenharmony_ci	    ;;
612313498266Sopenharmony_ci	    esac
612413498266Sopenharmony_ci
612513498266Sopenharmony_ci	    cat <<"EOF"
612613498266Sopenharmony_ci  XFREE (target_name);
612713498266Sopenharmony_ci  XFREE (actual_cwrapper_path);
612813498266Sopenharmony_ci  XFREE (actual_cwrapper_name);
612913498266Sopenharmony_ci
613013498266Sopenharmony_ci  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
613113498266Sopenharmony_ci  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
613213498266Sopenharmony_ci  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
613313498266Sopenharmony_ci     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
613413498266Sopenharmony_ci     because on Windows, both *_VARNAMEs are PATH but uninstalled
613513498266Sopenharmony_ci     libraries must come first. */
613613498266Sopenharmony_ci  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
613713498266Sopenharmony_ci  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
613813498266Sopenharmony_ci
613913498266Sopenharmony_ci  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
614013498266Sopenharmony_ci		  nonnull (lt_argv_zero));
614113498266Sopenharmony_ci  for (i = 0; i < newargc; i++)
614213498266Sopenharmony_ci    {
614313498266Sopenharmony_ci      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
614413498266Sopenharmony_ci		      i, nonnull (newargz[i]));
614513498266Sopenharmony_ci    }
614613498266Sopenharmony_ci
614713498266Sopenharmony_ciEOF
614813498266Sopenharmony_ci
614913498266Sopenharmony_ci	    case $host_os in
615013498266Sopenharmony_ci	      mingw*)
615113498266Sopenharmony_ci		cat <<"EOF"
615213498266Sopenharmony_ci  /* execv doesn't actually work on mingw as expected on unix */
615313498266Sopenharmony_ci  newargz = prepare_spawn (newargz);
615413498266Sopenharmony_ci  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
615513498266Sopenharmony_ci  if (rval == -1)
615613498266Sopenharmony_ci    {
615713498266Sopenharmony_ci      /* failed to start process */
615813498266Sopenharmony_ci      lt_debugprintf (__FILE__, __LINE__,
615913498266Sopenharmony_ci		      "(main) failed to launch target \"%s\": %s\n",
616013498266Sopenharmony_ci		      lt_argv_zero, nonnull (strerror (errno)));
616113498266Sopenharmony_ci      return 127;
616213498266Sopenharmony_ci    }
616313498266Sopenharmony_ci  return rval;
616413498266Sopenharmony_ciEOF
616513498266Sopenharmony_ci		;;
616613498266Sopenharmony_ci	      *)
616713498266Sopenharmony_ci		cat <<"EOF"
616813498266Sopenharmony_ci  execv (lt_argv_zero, newargz);
616913498266Sopenharmony_ci  return rval; /* =127, but avoids unused variable warning */
617013498266Sopenharmony_ciEOF
617113498266Sopenharmony_ci		;;
617213498266Sopenharmony_ci	    esac
617313498266Sopenharmony_ci
617413498266Sopenharmony_ci	    cat <<"EOF"
617513498266Sopenharmony_ci}
617613498266Sopenharmony_ci
617713498266Sopenharmony_civoid *
617813498266Sopenharmony_cixmalloc (size_t num)
617913498266Sopenharmony_ci{
618013498266Sopenharmony_ci  void *p = (void *) malloc (num);
618113498266Sopenharmony_ci  if (!p)
618213498266Sopenharmony_ci    lt_fatal (__FILE__, __LINE__, "memory exhausted");
618313498266Sopenharmony_ci
618413498266Sopenharmony_ci  return p;
618513498266Sopenharmony_ci}
618613498266Sopenharmony_ci
618713498266Sopenharmony_cichar *
618813498266Sopenharmony_cixstrdup (const char *string)
618913498266Sopenharmony_ci{
619013498266Sopenharmony_ci  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
619113498266Sopenharmony_ci			  string) : NULL;
619213498266Sopenharmony_ci}
619313498266Sopenharmony_ci
619413498266Sopenharmony_ciconst char *
619513498266Sopenharmony_cibase_name (const char *name)
619613498266Sopenharmony_ci{
619713498266Sopenharmony_ci  const char *base;
619813498266Sopenharmony_ci
619913498266Sopenharmony_ci#if defined HAVE_DOS_BASED_FILE_SYSTEM
620013498266Sopenharmony_ci  /* Skip over the disk name in MSDOS pathnames. */
620113498266Sopenharmony_ci  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
620213498266Sopenharmony_ci    name += 2;
620313498266Sopenharmony_ci#endif
620413498266Sopenharmony_ci
620513498266Sopenharmony_ci  for (base = name; *name; name++)
620613498266Sopenharmony_ci    if (IS_DIR_SEPARATOR (*name))
620713498266Sopenharmony_ci      base = name + 1;
620813498266Sopenharmony_ci  return base;
620913498266Sopenharmony_ci}
621013498266Sopenharmony_ci
621113498266Sopenharmony_ciint
621213498266Sopenharmony_cicheck_executable (const char *path)
621313498266Sopenharmony_ci{
621413498266Sopenharmony_ci  struct stat st;
621513498266Sopenharmony_ci
621613498266Sopenharmony_ci  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
621713498266Sopenharmony_ci                  nonempty (path));
621813498266Sopenharmony_ci  if ((!path) || (!*path))
621913498266Sopenharmony_ci    return 0;
622013498266Sopenharmony_ci
622113498266Sopenharmony_ci  if ((stat (path, &st) >= 0)
622213498266Sopenharmony_ci      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
622313498266Sopenharmony_ci    return 1;
622413498266Sopenharmony_ci  else
622513498266Sopenharmony_ci    return 0;
622613498266Sopenharmony_ci}
622713498266Sopenharmony_ci
622813498266Sopenharmony_ciint
622913498266Sopenharmony_cimake_executable (const char *path)
623013498266Sopenharmony_ci{
623113498266Sopenharmony_ci  int rval = 0;
623213498266Sopenharmony_ci  struct stat st;
623313498266Sopenharmony_ci
623413498266Sopenharmony_ci  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
623513498266Sopenharmony_ci                  nonempty (path));
623613498266Sopenharmony_ci  if ((!path) || (!*path))
623713498266Sopenharmony_ci    return 0;
623813498266Sopenharmony_ci
623913498266Sopenharmony_ci  if (stat (path, &st) >= 0)
624013498266Sopenharmony_ci    {
624113498266Sopenharmony_ci      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
624213498266Sopenharmony_ci    }
624313498266Sopenharmony_ci  return rval;
624413498266Sopenharmony_ci}
624513498266Sopenharmony_ci
624613498266Sopenharmony_ci/* Searches for the full path of the wrapper.  Returns
624713498266Sopenharmony_ci   newly allocated full path name if found, NULL otherwise
624813498266Sopenharmony_ci   Does not chase symlinks, even on platforms that support them.
624913498266Sopenharmony_ci*/
625013498266Sopenharmony_cichar *
625113498266Sopenharmony_cifind_executable (const char *wrapper)
625213498266Sopenharmony_ci{
625313498266Sopenharmony_ci  int has_slash = 0;
625413498266Sopenharmony_ci  const char *p;
625513498266Sopenharmony_ci  const char *p_next;
625613498266Sopenharmony_ci  /* static buffer for getcwd */
625713498266Sopenharmony_ci  char tmp[LT_PATHMAX + 1];
625813498266Sopenharmony_ci  size_t tmp_len;
625913498266Sopenharmony_ci  char *concat_name;
626013498266Sopenharmony_ci
626113498266Sopenharmony_ci  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
626213498266Sopenharmony_ci                  nonempty (wrapper));
626313498266Sopenharmony_ci
626413498266Sopenharmony_ci  if ((wrapper == NULL) || (*wrapper == '\0'))
626513498266Sopenharmony_ci    return NULL;
626613498266Sopenharmony_ci
626713498266Sopenharmony_ci  /* Absolute path? */
626813498266Sopenharmony_ci#if defined HAVE_DOS_BASED_FILE_SYSTEM
626913498266Sopenharmony_ci  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
627013498266Sopenharmony_ci    {
627113498266Sopenharmony_ci      concat_name = xstrdup (wrapper);
627213498266Sopenharmony_ci      if (check_executable (concat_name))
627313498266Sopenharmony_ci	return concat_name;
627413498266Sopenharmony_ci      XFREE (concat_name);
627513498266Sopenharmony_ci    }
627613498266Sopenharmony_ci  else
627713498266Sopenharmony_ci    {
627813498266Sopenharmony_ci#endif
627913498266Sopenharmony_ci      if (IS_DIR_SEPARATOR (wrapper[0]))
628013498266Sopenharmony_ci	{
628113498266Sopenharmony_ci	  concat_name = xstrdup (wrapper);
628213498266Sopenharmony_ci	  if (check_executable (concat_name))
628313498266Sopenharmony_ci	    return concat_name;
628413498266Sopenharmony_ci	  XFREE (concat_name);
628513498266Sopenharmony_ci	}
628613498266Sopenharmony_ci#if defined HAVE_DOS_BASED_FILE_SYSTEM
628713498266Sopenharmony_ci    }
628813498266Sopenharmony_ci#endif
628913498266Sopenharmony_ci
629013498266Sopenharmony_ci  for (p = wrapper; *p; p++)
629113498266Sopenharmony_ci    if (*p == '/')
629213498266Sopenharmony_ci      {
629313498266Sopenharmony_ci	has_slash = 1;
629413498266Sopenharmony_ci	break;
629513498266Sopenharmony_ci      }
629613498266Sopenharmony_ci  if (!has_slash)
629713498266Sopenharmony_ci    {
629813498266Sopenharmony_ci      /* no slashes; search PATH */
629913498266Sopenharmony_ci      const char *path = getenv ("PATH");
630013498266Sopenharmony_ci      if (path != NULL)
630113498266Sopenharmony_ci	{
630213498266Sopenharmony_ci	  for (p = path; *p; p = p_next)
630313498266Sopenharmony_ci	    {
630413498266Sopenharmony_ci	      const char *q;
630513498266Sopenharmony_ci	      size_t p_len;
630613498266Sopenharmony_ci	      for (q = p; *q; q++)
630713498266Sopenharmony_ci		if (IS_PATH_SEPARATOR (*q))
630813498266Sopenharmony_ci		  break;
630913498266Sopenharmony_ci	      p_len = (size_t) (q - p);
631013498266Sopenharmony_ci	      p_next = (*q == '\0' ? q : q + 1);
631113498266Sopenharmony_ci	      if (p_len == 0)
631213498266Sopenharmony_ci		{
631313498266Sopenharmony_ci		  /* empty path: current directory */
631413498266Sopenharmony_ci		  if (getcwd (tmp, LT_PATHMAX) == NULL)
631513498266Sopenharmony_ci		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
631613498266Sopenharmony_ci                              nonnull (strerror (errno)));
631713498266Sopenharmony_ci		  tmp_len = strlen (tmp);
631813498266Sopenharmony_ci		  concat_name =
631913498266Sopenharmony_ci		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
632013498266Sopenharmony_ci		  memcpy (concat_name, tmp, tmp_len);
632113498266Sopenharmony_ci		  concat_name[tmp_len] = '/';
632213498266Sopenharmony_ci		  strcpy (concat_name + tmp_len + 1, wrapper);
632313498266Sopenharmony_ci		}
632413498266Sopenharmony_ci	      else
632513498266Sopenharmony_ci		{
632613498266Sopenharmony_ci		  concat_name =
632713498266Sopenharmony_ci		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
632813498266Sopenharmony_ci		  memcpy (concat_name, p, p_len);
632913498266Sopenharmony_ci		  concat_name[p_len] = '/';
633013498266Sopenharmony_ci		  strcpy (concat_name + p_len + 1, wrapper);
633113498266Sopenharmony_ci		}
633213498266Sopenharmony_ci	      if (check_executable (concat_name))
633313498266Sopenharmony_ci		return concat_name;
633413498266Sopenharmony_ci	      XFREE (concat_name);
633513498266Sopenharmony_ci	    }
633613498266Sopenharmony_ci	}
633713498266Sopenharmony_ci      /* not found in PATH; assume curdir */
633813498266Sopenharmony_ci    }
633913498266Sopenharmony_ci  /* Relative path | not found in path: prepend cwd */
634013498266Sopenharmony_ci  if (getcwd (tmp, LT_PATHMAX) == NULL)
634113498266Sopenharmony_ci    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
634213498266Sopenharmony_ci              nonnull (strerror (errno)));
634313498266Sopenharmony_ci  tmp_len = strlen (tmp);
634413498266Sopenharmony_ci  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
634513498266Sopenharmony_ci  memcpy (concat_name, tmp, tmp_len);
634613498266Sopenharmony_ci  concat_name[tmp_len] = '/';
634713498266Sopenharmony_ci  strcpy (concat_name + tmp_len + 1, wrapper);
634813498266Sopenharmony_ci
634913498266Sopenharmony_ci  if (check_executable (concat_name))
635013498266Sopenharmony_ci    return concat_name;
635113498266Sopenharmony_ci  XFREE (concat_name);
635213498266Sopenharmony_ci  return NULL;
635313498266Sopenharmony_ci}
635413498266Sopenharmony_ci
635513498266Sopenharmony_cichar *
635613498266Sopenharmony_cichase_symlinks (const char *pathspec)
635713498266Sopenharmony_ci{
635813498266Sopenharmony_ci#ifndef S_ISLNK
635913498266Sopenharmony_ci  return xstrdup (pathspec);
636013498266Sopenharmony_ci#else
636113498266Sopenharmony_ci  char buf[LT_PATHMAX];
636213498266Sopenharmony_ci  struct stat s;
636313498266Sopenharmony_ci  char *tmp_pathspec = xstrdup (pathspec);
636413498266Sopenharmony_ci  char *p;
636513498266Sopenharmony_ci  int has_symlinks = 0;
636613498266Sopenharmony_ci  while (strlen (tmp_pathspec) && !has_symlinks)
636713498266Sopenharmony_ci    {
636813498266Sopenharmony_ci      lt_debugprintf (__FILE__, __LINE__,
636913498266Sopenharmony_ci		      "checking path component for symlinks: %s\n",
637013498266Sopenharmony_ci		      tmp_pathspec);
637113498266Sopenharmony_ci      if (lstat (tmp_pathspec, &s) == 0)
637213498266Sopenharmony_ci	{
637313498266Sopenharmony_ci	  if (S_ISLNK (s.st_mode) != 0)
637413498266Sopenharmony_ci	    {
637513498266Sopenharmony_ci	      has_symlinks = 1;
637613498266Sopenharmony_ci	      break;
637713498266Sopenharmony_ci	    }
637813498266Sopenharmony_ci
637913498266Sopenharmony_ci	  /* search backwards for last DIR_SEPARATOR */
638013498266Sopenharmony_ci	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
638113498266Sopenharmony_ci	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
638213498266Sopenharmony_ci	    p--;
638313498266Sopenharmony_ci	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
638413498266Sopenharmony_ci	    {
638513498266Sopenharmony_ci	      /* no more DIR_SEPARATORS left */
638613498266Sopenharmony_ci	      break;
638713498266Sopenharmony_ci	    }
638813498266Sopenharmony_ci	  *p = '\0';
638913498266Sopenharmony_ci	}
639013498266Sopenharmony_ci      else
639113498266Sopenharmony_ci	{
639213498266Sopenharmony_ci	  lt_fatal (__FILE__, __LINE__,
639313498266Sopenharmony_ci		    "error accessing file \"%s\": %s",
639413498266Sopenharmony_ci		    tmp_pathspec, nonnull (strerror (errno)));
639513498266Sopenharmony_ci	}
639613498266Sopenharmony_ci    }
639713498266Sopenharmony_ci  XFREE (tmp_pathspec);
639813498266Sopenharmony_ci
639913498266Sopenharmony_ci  if (!has_symlinks)
640013498266Sopenharmony_ci    {
640113498266Sopenharmony_ci      return xstrdup (pathspec);
640213498266Sopenharmony_ci    }
640313498266Sopenharmony_ci
640413498266Sopenharmony_ci  tmp_pathspec = realpath (pathspec, buf);
640513498266Sopenharmony_ci  if (tmp_pathspec == 0)
640613498266Sopenharmony_ci    {
640713498266Sopenharmony_ci      lt_fatal (__FILE__, __LINE__,
640813498266Sopenharmony_ci		"could not follow symlinks for %s", pathspec);
640913498266Sopenharmony_ci    }
641013498266Sopenharmony_ci  return xstrdup (tmp_pathspec);
641113498266Sopenharmony_ci#endif
641213498266Sopenharmony_ci}
641313498266Sopenharmony_ci
641413498266Sopenharmony_cichar *
641513498266Sopenharmony_cistrendzap (char *str, const char *pat)
641613498266Sopenharmony_ci{
641713498266Sopenharmony_ci  size_t len, patlen;
641813498266Sopenharmony_ci
641913498266Sopenharmony_ci  assert (str != NULL);
642013498266Sopenharmony_ci  assert (pat != NULL);
642113498266Sopenharmony_ci
642213498266Sopenharmony_ci  len = strlen (str);
642313498266Sopenharmony_ci  patlen = strlen (pat);
642413498266Sopenharmony_ci
642513498266Sopenharmony_ci  if (patlen <= len)
642613498266Sopenharmony_ci    {
642713498266Sopenharmony_ci      str += len - patlen;
642813498266Sopenharmony_ci      if (STREQ (str, pat))
642913498266Sopenharmony_ci	*str = '\0';
643013498266Sopenharmony_ci    }
643113498266Sopenharmony_ci  return str;
643213498266Sopenharmony_ci}
643313498266Sopenharmony_ci
643413498266Sopenharmony_civoid
643513498266Sopenharmony_cilt_debugprintf (const char *file, int line, const char *fmt, ...)
643613498266Sopenharmony_ci{
643713498266Sopenharmony_ci  va_list args;
643813498266Sopenharmony_ci  if (lt_debug)
643913498266Sopenharmony_ci    {
644013498266Sopenharmony_ci      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
644113498266Sopenharmony_ci      va_start (args, fmt);
644213498266Sopenharmony_ci      (void) vfprintf (stderr, fmt, args);
644313498266Sopenharmony_ci      va_end (args);
644413498266Sopenharmony_ci    }
644513498266Sopenharmony_ci}
644613498266Sopenharmony_ci
644713498266Sopenharmony_cistatic void
644813498266Sopenharmony_cilt_error_core (int exit_status, const char *file,
644913498266Sopenharmony_ci	       int line, const char *mode,
645013498266Sopenharmony_ci	       const char *message, va_list ap)
645113498266Sopenharmony_ci{
645213498266Sopenharmony_ci  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
645313498266Sopenharmony_ci  vfprintf (stderr, message, ap);
645413498266Sopenharmony_ci  fprintf (stderr, ".\n");
645513498266Sopenharmony_ci
645613498266Sopenharmony_ci  if (exit_status >= 0)
645713498266Sopenharmony_ci    exit (exit_status);
645813498266Sopenharmony_ci}
645913498266Sopenharmony_ci
646013498266Sopenharmony_civoid
646113498266Sopenharmony_cilt_fatal (const char *file, int line, const char *message, ...)
646213498266Sopenharmony_ci{
646313498266Sopenharmony_ci  va_list ap;
646413498266Sopenharmony_ci  va_start (ap, message);
646513498266Sopenharmony_ci  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
646613498266Sopenharmony_ci  va_end (ap);
646713498266Sopenharmony_ci}
646813498266Sopenharmony_ci
646913498266Sopenharmony_cistatic const char *
647013498266Sopenharmony_cinonnull (const char *s)
647113498266Sopenharmony_ci{
647213498266Sopenharmony_ci  return s ? s : "(null)";
647313498266Sopenharmony_ci}
647413498266Sopenharmony_ci
647513498266Sopenharmony_cistatic const char *
647613498266Sopenharmony_cinonempty (const char *s)
647713498266Sopenharmony_ci{
647813498266Sopenharmony_ci  return (s && !*s) ? "(empty)" : nonnull (s);
647913498266Sopenharmony_ci}
648013498266Sopenharmony_ci
648113498266Sopenharmony_civoid
648213498266Sopenharmony_cilt_setenv (const char *name, const char *value)
648313498266Sopenharmony_ci{
648413498266Sopenharmony_ci  lt_debugprintf (__FILE__, __LINE__,
648513498266Sopenharmony_ci		  "(lt_setenv) setting '%s' to '%s'\n",
648613498266Sopenharmony_ci                  nonnull (name), nonnull (value));
648713498266Sopenharmony_ci  {
648813498266Sopenharmony_ci#ifdef HAVE_SETENV
648913498266Sopenharmony_ci    /* always make a copy, for consistency with !HAVE_SETENV */
649013498266Sopenharmony_ci    char *str = xstrdup (value);
649113498266Sopenharmony_ci    setenv (name, str, 1);
649213498266Sopenharmony_ci#else
649313498266Sopenharmony_ci    size_t len = strlen (name) + 1 + strlen (value) + 1;
649413498266Sopenharmony_ci    char *str = XMALLOC (char, len);
649513498266Sopenharmony_ci    sprintf (str, "%s=%s", name, value);
649613498266Sopenharmony_ci    if (putenv (str) != EXIT_SUCCESS)
649713498266Sopenharmony_ci      {
649813498266Sopenharmony_ci        XFREE (str);
649913498266Sopenharmony_ci      }
650013498266Sopenharmony_ci#endif
650113498266Sopenharmony_ci  }
650213498266Sopenharmony_ci}
650313498266Sopenharmony_ci
650413498266Sopenharmony_cichar *
650513498266Sopenharmony_cilt_extend_str (const char *orig_value, const char *add, int to_end)
650613498266Sopenharmony_ci{
650713498266Sopenharmony_ci  char *new_value;
650813498266Sopenharmony_ci  if (orig_value && *orig_value)
650913498266Sopenharmony_ci    {
651013498266Sopenharmony_ci      size_t orig_value_len = strlen (orig_value);
651113498266Sopenharmony_ci      size_t add_len = strlen (add);
651213498266Sopenharmony_ci      new_value = XMALLOC (char, add_len + orig_value_len + 1);
651313498266Sopenharmony_ci      if (to_end)
651413498266Sopenharmony_ci        {
651513498266Sopenharmony_ci          strcpy (new_value, orig_value);
651613498266Sopenharmony_ci          strcpy (new_value + orig_value_len, add);
651713498266Sopenharmony_ci        }
651813498266Sopenharmony_ci      else
651913498266Sopenharmony_ci        {
652013498266Sopenharmony_ci          strcpy (new_value, add);
652113498266Sopenharmony_ci          strcpy (new_value + add_len, orig_value);
652213498266Sopenharmony_ci        }
652313498266Sopenharmony_ci    }
652413498266Sopenharmony_ci  else
652513498266Sopenharmony_ci    {
652613498266Sopenharmony_ci      new_value = xstrdup (add);
652713498266Sopenharmony_ci    }
652813498266Sopenharmony_ci  return new_value;
652913498266Sopenharmony_ci}
653013498266Sopenharmony_ci
653113498266Sopenharmony_civoid
653213498266Sopenharmony_cilt_update_exe_path (const char *name, const char *value)
653313498266Sopenharmony_ci{
653413498266Sopenharmony_ci  lt_debugprintf (__FILE__, __LINE__,
653513498266Sopenharmony_ci		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
653613498266Sopenharmony_ci                  nonnull (name), nonnull (value));
653713498266Sopenharmony_ci
653813498266Sopenharmony_ci  if (name && *name && value && *value)
653913498266Sopenharmony_ci    {
654013498266Sopenharmony_ci      char *new_value = lt_extend_str (getenv (name), value, 0);
654113498266Sopenharmony_ci      /* some systems can't cope with a ':'-terminated path #' */
654213498266Sopenharmony_ci      size_t len = strlen (new_value);
654313498266Sopenharmony_ci      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
654413498266Sopenharmony_ci        {
654513498266Sopenharmony_ci          new_value[--len] = '\0';
654613498266Sopenharmony_ci        }
654713498266Sopenharmony_ci      lt_setenv (name, new_value);
654813498266Sopenharmony_ci      XFREE (new_value);
654913498266Sopenharmony_ci    }
655013498266Sopenharmony_ci}
655113498266Sopenharmony_ci
655213498266Sopenharmony_civoid
655313498266Sopenharmony_cilt_update_lib_path (const char *name, const char *value)
655413498266Sopenharmony_ci{
655513498266Sopenharmony_ci  lt_debugprintf (__FILE__, __LINE__,
655613498266Sopenharmony_ci		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
655713498266Sopenharmony_ci                  nonnull (name), nonnull (value));
655813498266Sopenharmony_ci
655913498266Sopenharmony_ci  if (name && *name && value && *value)
656013498266Sopenharmony_ci    {
656113498266Sopenharmony_ci      char *new_value = lt_extend_str (getenv (name), value, 0);
656213498266Sopenharmony_ci      lt_setenv (name, new_value);
656313498266Sopenharmony_ci      XFREE (new_value);
656413498266Sopenharmony_ci    }
656513498266Sopenharmony_ci}
656613498266Sopenharmony_ci
656713498266Sopenharmony_ciEOF
656813498266Sopenharmony_ci	    case $host_os in
656913498266Sopenharmony_ci	      mingw*)
657013498266Sopenharmony_ci		cat <<"EOF"
657113498266Sopenharmony_ci
657213498266Sopenharmony_ci/* Prepares an argument vector before calling spawn().
657313498266Sopenharmony_ci   Note that spawn() does not by itself call the command interpreter
657413498266Sopenharmony_ci     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
657513498266Sopenharmony_ci      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
657613498266Sopenharmony_ci         GetVersionEx(&v);
657713498266Sopenharmony_ci         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
657813498266Sopenharmony_ci      }) ? "cmd.exe" : "command.com").
657913498266Sopenharmony_ci   Instead it simply concatenates the arguments, separated by ' ', and calls
658013498266Sopenharmony_ci   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
658113498266Sopenharmony_ci   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
658213498266Sopenharmony_ci   special way:
658313498266Sopenharmony_ci   - Space and tab are interpreted as delimiters. They are not treated as
658413498266Sopenharmony_ci     delimiters if they are surrounded by double quotes: "...".
658513498266Sopenharmony_ci   - Unescaped double quotes are removed from the input. Their only effect is
658613498266Sopenharmony_ci     that within double quotes, space and tab are treated like normal
658713498266Sopenharmony_ci     characters.
658813498266Sopenharmony_ci   - Backslashes not followed by double quotes are not special.
658913498266Sopenharmony_ci   - But 2*n+1 backslashes followed by a double quote become
659013498266Sopenharmony_ci     n backslashes followed by a double quote (n >= 0):
659113498266Sopenharmony_ci       \" -> "
659213498266Sopenharmony_ci       \\\" -> \"
659313498266Sopenharmony_ci       \\\\\" -> \\"
659413498266Sopenharmony_ci */
659513498266Sopenharmony_ci#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"
659613498266Sopenharmony_ci#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"
659713498266Sopenharmony_cichar **
659813498266Sopenharmony_ciprepare_spawn (char **argv)
659913498266Sopenharmony_ci{
660013498266Sopenharmony_ci  size_t argc;
660113498266Sopenharmony_ci  char **new_argv;
660213498266Sopenharmony_ci  size_t i;
660313498266Sopenharmony_ci
660413498266Sopenharmony_ci  /* Count number of arguments.  */
660513498266Sopenharmony_ci  for (argc = 0; argv[argc] != NULL; argc++)
660613498266Sopenharmony_ci    ;
660713498266Sopenharmony_ci
660813498266Sopenharmony_ci  /* Allocate new argument vector.  */
660913498266Sopenharmony_ci  new_argv = XMALLOC (char *, argc + 1);
661013498266Sopenharmony_ci
661113498266Sopenharmony_ci  /* Put quoted arguments into the new argument vector.  */
661213498266Sopenharmony_ci  for (i = 0; i < argc; i++)
661313498266Sopenharmony_ci    {
661413498266Sopenharmony_ci      const char *string = argv[i];
661513498266Sopenharmony_ci
661613498266Sopenharmony_ci      if (string[0] == '\0')
661713498266Sopenharmony_ci	new_argv[i] = xstrdup ("\"\"");
661813498266Sopenharmony_ci      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
661913498266Sopenharmony_ci	{
662013498266Sopenharmony_ci	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
662113498266Sopenharmony_ci	  size_t length;
662213498266Sopenharmony_ci	  unsigned int backslashes;
662313498266Sopenharmony_ci	  const char *s;
662413498266Sopenharmony_ci	  char *quoted_string;
662513498266Sopenharmony_ci	  char *p;
662613498266Sopenharmony_ci
662713498266Sopenharmony_ci	  length = 0;
662813498266Sopenharmony_ci	  backslashes = 0;
662913498266Sopenharmony_ci	  if (quote_around)
663013498266Sopenharmony_ci	    length++;
663113498266Sopenharmony_ci	  for (s = string; *s != '\0'; s++)
663213498266Sopenharmony_ci	    {
663313498266Sopenharmony_ci	      char c = *s;
663413498266Sopenharmony_ci	      if (c == '"')
663513498266Sopenharmony_ci		length += backslashes + 1;
663613498266Sopenharmony_ci	      length++;
663713498266Sopenharmony_ci	      if (c == '\\')
663813498266Sopenharmony_ci		backslashes++;
663913498266Sopenharmony_ci	      else
664013498266Sopenharmony_ci		backslashes = 0;
664113498266Sopenharmony_ci	    }
664213498266Sopenharmony_ci	  if (quote_around)
664313498266Sopenharmony_ci	    length += backslashes + 1;
664413498266Sopenharmony_ci
664513498266Sopenharmony_ci	  quoted_string = XMALLOC (char, length + 1);
664613498266Sopenharmony_ci
664713498266Sopenharmony_ci	  p = quoted_string;
664813498266Sopenharmony_ci	  backslashes = 0;
664913498266Sopenharmony_ci	  if (quote_around)
665013498266Sopenharmony_ci	    *p++ = '"';
665113498266Sopenharmony_ci	  for (s = string; *s != '\0'; s++)
665213498266Sopenharmony_ci	    {
665313498266Sopenharmony_ci	      char c = *s;
665413498266Sopenharmony_ci	      if (c == '"')
665513498266Sopenharmony_ci		{
665613498266Sopenharmony_ci		  unsigned int j;
665713498266Sopenharmony_ci		  for (j = backslashes + 1; j > 0; j--)
665813498266Sopenharmony_ci		    *p++ = '\\';
665913498266Sopenharmony_ci		}
666013498266Sopenharmony_ci	      *p++ = c;
666113498266Sopenharmony_ci	      if (c == '\\')
666213498266Sopenharmony_ci		backslashes++;
666313498266Sopenharmony_ci	      else
666413498266Sopenharmony_ci		backslashes = 0;
666513498266Sopenharmony_ci	    }
666613498266Sopenharmony_ci	  if (quote_around)
666713498266Sopenharmony_ci	    {
666813498266Sopenharmony_ci	      unsigned int j;
666913498266Sopenharmony_ci	      for (j = backslashes; j > 0; j--)
667013498266Sopenharmony_ci		*p++ = '\\';
667113498266Sopenharmony_ci	      *p++ = '"';
667213498266Sopenharmony_ci	    }
667313498266Sopenharmony_ci	  *p = '\0';
667413498266Sopenharmony_ci
667513498266Sopenharmony_ci	  new_argv[i] = quoted_string;
667613498266Sopenharmony_ci	}
667713498266Sopenharmony_ci      else
667813498266Sopenharmony_ci	new_argv[i] = (char *) string;
667913498266Sopenharmony_ci    }
668013498266Sopenharmony_ci  new_argv[argc] = NULL;
668113498266Sopenharmony_ci
668213498266Sopenharmony_ci  return new_argv;
668313498266Sopenharmony_ci}
668413498266Sopenharmony_ciEOF
668513498266Sopenharmony_ci		;;
668613498266Sopenharmony_ci	    esac
668713498266Sopenharmony_ci
668813498266Sopenharmony_ci            cat <<"EOF"
668913498266Sopenharmony_civoid lt_dump_script (FILE* f)
669013498266Sopenharmony_ci{
669113498266Sopenharmony_ciEOF
669213498266Sopenharmony_ci	    func_emit_wrapper yes |
669313498266Sopenharmony_ci	      $SED -n -e '
669413498266Sopenharmony_cis/^\(.\{79\}\)\(..*\)/\1\
669513498266Sopenharmony_ci\2/
669613498266Sopenharmony_cih
669713498266Sopenharmony_cis/\([\\"]\)/\\\1/g
669813498266Sopenharmony_cis/$/\\n/
669913498266Sopenharmony_cis/\([^\n]*\).*/  fputs ("\1", f);/p
670013498266Sopenharmony_cig
670113498266Sopenharmony_ciD'
670213498266Sopenharmony_ci            cat <<"EOF"
670313498266Sopenharmony_ci}
670413498266Sopenharmony_ciEOF
670513498266Sopenharmony_ci}
670613498266Sopenharmony_ci# end: func_emit_cwrapperexe_src
670713498266Sopenharmony_ci
670813498266Sopenharmony_ci# func_win32_import_lib_p ARG
670913498266Sopenharmony_ci# True if ARG is an import lib, as indicated by $file_magic_cmd
671013498266Sopenharmony_cifunc_win32_import_lib_p ()
671113498266Sopenharmony_ci{
671213498266Sopenharmony_ci    $debug_cmd
671313498266Sopenharmony_ci
671413498266Sopenharmony_ci    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
671513498266Sopenharmony_ci    *import*) : ;;
671613498266Sopenharmony_ci    *) false ;;
671713498266Sopenharmony_ci    esac
671813498266Sopenharmony_ci}
671913498266Sopenharmony_ci
672013498266Sopenharmony_ci# func_suncc_cstd_abi
672113498266Sopenharmony_ci# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
672213498266Sopenharmony_ci# Several compiler flags select an ABI that is incompatible with the
672313498266Sopenharmony_ci# Cstd library. Avoid specifying it if any are in CXXFLAGS.
672413498266Sopenharmony_cifunc_suncc_cstd_abi ()
672513498266Sopenharmony_ci{
672613498266Sopenharmony_ci    $debug_cmd
672713498266Sopenharmony_ci
672813498266Sopenharmony_ci    case " $compile_command " in
672913498266Sopenharmony_ci    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
673013498266Sopenharmony_ci      suncc_use_cstd_abi=no
673113498266Sopenharmony_ci      ;;
673213498266Sopenharmony_ci    *)
673313498266Sopenharmony_ci      suncc_use_cstd_abi=yes
673413498266Sopenharmony_ci      ;;
673513498266Sopenharmony_ci    esac
673613498266Sopenharmony_ci}
673713498266Sopenharmony_ci
673813498266Sopenharmony_ci# func_mode_link arg...
673913498266Sopenharmony_cifunc_mode_link ()
674013498266Sopenharmony_ci{
674113498266Sopenharmony_ci    $debug_cmd
674213498266Sopenharmony_ci
674313498266Sopenharmony_ci    case $host in
674413498266Sopenharmony_ci    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
674513498266Sopenharmony_ci      # It is impossible to link a dll without this setting, and
674613498266Sopenharmony_ci      # we shouldn't force the makefile maintainer to figure out
674713498266Sopenharmony_ci      # what system we are compiling for in order to pass an extra
674813498266Sopenharmony_ci      # flag for every libtool invocation.
674913498266Sopenharmony_ci      # allow_undefined=no
675013498266Sopenharmony_ci
675113498266Sopenharmony_ci      # FIXME: Unfortunately, there are problems with the above when trying
675213498266Sopenharmony_ci      # to make a dll that has undefined symbols, in which case not
675313498266Sopenharmony_ci      # even a static library is built.  For now, we need to specify
675413498266Sopenharmony_ci      # -no-undefined on the libtool link line when we can be certain
675513498266Sopenharmony_ci      # that all symbols are satisfied, otherwise we get a static library.
675613498266Sopenharmony_ci      allow_undefined=yes
675713498266Sopenharmony_ci      ;;
675813498266Sopenharmony_ci    *)
675913498266Sopenharmony_ci      allow_undefined=yes
676013498266Sopenharmony_ci      ;;
676113498266Sopenharmony_ci    esac
676213498266Sopenharmony_ci    libtool_args=$nonopt
676313498266Sopenharmony_ci    base_compile="$nonopt $@"
676413498266Sopenharmony_ci    compile_command=$nonopt
676513498266Sopenharmony_ci    finalize_command=$nonopt
676613498266Sopenharmony_ci
676713498266Sopenharmony_ci    compile_rpath=
676813498266Sopenharmony_ci    finalize_rpath=
676913498266Sopenharmony_ci    compile_shlibpath=
677013498266Sopenharmony_ci    finalize_shlibpath=
677113498266Sopenharmony_ci    convenience=
677213498266Sopenharmony_ci    old_convenience=
677313498266Sopenharmony_ci    deplibs=
677413498266Sopenharmony_ci    old_deplibs=
677513498266Sopenharmony_ci    compiler_flags=
677613498266Sopenharmony_ci    linker_flags=
677713498266Sopenharmony_ci    dllsearchpath=
677813498266Sopenharmony_ci    lib_search_path=`pwd`
677913498266Sopenharmony_ci    inst_prefix_dir=
678013498266Sopenharmony_ci    new_inherited_linker_flags=
678113498266Sopenharmony_ci
678213498266Sopenharmony_ci    avoid_version=no
678313498266Sopenharmony_ci    bindir=
678413498266Sopenharmony_ci    dlfiles=
678513498266Sopenharmony_ci    dlprefiles=
678613498266Sopenharmony_ci    dlself=no
678713498266Sopenharmony_ci    export_dynamic=no
678813498266Sopenharmony_ci    export_symbols=
678913498266Sopenharmony_ci    export_symbols_regex=
679013498266Sopenharmony_ci    generated=
679113498266Sopenharmony_ci    libobjs=
679213498266Sopenharmony_ci    ltlibs=
679313498266Sopenharmony_ci    module=no
679413498266Sopenharmony_ci    no_install=no
679513498266Sopenharmony_ci    objs=
679613498266Sopenharmony_ci    os2dllname=
679713498266Sopenharmony_ci    non_pic_objects=
679813498266Sopenharmony_ci    precious_files_regex=
679913498266Sopenharmony_ci    prefer_static_libs=no
680013498266Sopenharmony_ci    preload=false
680113498266Sopenharmony_ci    prev=
680213498266Sopenharmony_ci    prevarg=
680313498266Sopenharmony_ci    release=
680413498266Sopenharmony_ci    rpath=
680513498266Sopenharmony_ci    xrpath=
680613498266Sopenharmony_ci    perm_rpath=
680713498266Sopenharmony_ci    temp_rpath=
680813498266Sopenharmony_ci    thread_safe=no
680913498266Sopenharmony_ci    vinfo=
681013498266Sopenharmony_ci    vinfo_number=no
681113498266Sopenharmony_ci    weak_libs=
681213498266Sopenharmony_ci    single_module=$wl-single_module
681313498266Sopenharmony_ci    func_infer_tag $base_compile
681413498266Sopenharmony_ci
681513498266Sopenharmony_ci    # We need to know -static, to get the right output filenames.
681613498266Sopenharmony_ci    for arg
681713498266Sopenharmony_ci    do
681813498266Sopenharmony_ci      case $arg in
681913498266Sopenharmony_ci      -shared)
682013498266Sopenharmony_ci	test yes != "$build_libtool_libs" \
682113498266Sopenharmony_ci	  && func_fatal_configuration "cannot build a shared library"
682213498266Sopenharmony_ci	build_old_libs=no
682313498266Sopenharmony_ci	break
682413498266Sopenharmony_ci	;;
682513498266Sopenharmony_ci      -all-static | -static | -static-libtool-libs)
682613498266Sopenharmony_ci	case $arg in
682713498266Sopenharmony_ci	-all-static)
682813498266Sopenharmony_ci	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
682913498266Sopenharmony_ci	    func_warning "complete static linking is impossible in this configuration"
683013498266Sopenharmony_ci	  fi
683113498266Sopenharmony_ci	  if test -n "$link_static_flag"; then
683213498266Sopenharmony_ci	    dlopen_self=$dlopen_self_static
683313498266Sopenharmony_ci	  fi
683413498266Sopenharmony_ci	  prefer_static_libs=yes
683513498266Sopenharmony_ci	  ;;
683613498266Sopenharmony_ci	-static)
683713498266Sopenharmony_ci	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
683813498266Sopenharmony_ci	    dlopen_self=$dlopen_self_static
683913498266Sopenharmony_ci	  fi
684013498266Sopenharmony_ci	  prefer_static_libs=built
684113498266Sopenharmony_ci	  ;;
684213498266Sopenharmony_ci	-static-libtool-libs)
684313498266Sopenharmony_ci	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
684413498266Sopenharmony_ci	    dlopen_self=$dlopen_self_static
684513498266Sopenharmony_ci	  fi
684613498266Sopenharmony_ci	  prefer_static_libs=yes
684713498266Sopenharmony_ci	  ;;
684813498266Sopenharmony_ci	esac
684913498266Sopenharmony_ci	build_libtool_libs=no
685013498266Sopenharmony_ci	build_old_libs=yes
685113498266Sopenharmony_ci	break
685213498266Sopenharmony_ci	;;
685313498266Sopenharmony_ci      esac
685413498266Sopenharmony_ci    done
685513498266Sopenharmony_ci
685613498266Sopenharmony_ci    # See if our shared archives depend on static archives.
685713498266Sopenharmony_ci    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
685813498266Sopenharmony_ci
685913498266Sopenharmony_ci    # Go through the arguments, transforming them on the way.
686013498266Sopenharmony_ci    while test "$#" -gt 0; do
686113498266Sopenharmony_ci      arg=$1
686213498266Sopenharmony_ci      shift
686313498266Sopenharmony_ci      func_quote_arg pretty,unquoted "$arg"
686413498266Sopenharmony_ci      qarg=$func_quote_arg_unquoted_result
686513498266Sopenharmony_ci      func_append libtool_args " $func_quote_arg_result"
686613498266Sopenharmony_ci
686713498266Sopenharmony_ci      # If the previous option needs an argument, assign it.
686813498266Sopenharmony_ci      if test -n "$prev"; then
686913498266Sopenharmony_ci	case $prev in
687013498266Sopenharmony_ci	output)
687113498266Sopenharmony_ci	  func_append compile_command " @OUTPUT@"
687213498266Sopenharmony_ci	  func_append finalize_command " @OUTPUT@"
687313498266Sopenharmony_ci	  ;;
687413498266Sopenharmony_ci	esac
687513498266Sopenharmony_ci
687613498266Sopenharmony_ci	case $prev in
687713498266Sopenharmony_ci	bindir)
687813498266Sopenharmony_ci	  bindir=$arg
687913498266Sopenharmony_ci	  prev=
688013498266Sopenharmony_ci	  continue
688113498266Sopenharmony_ci	  ;;
688213498266Sopenharmony_ci	dlfiles|dlprefiles)
688313498266Sopenharmony_ci	  $preload || {
688413498266Sopenharmony_ci	    # Add the symbol object into the linking commands.
688513498266Sopenharmony_ci	    func_append compile_command " @SYMFILE@"
688613498266Sopenharmony_ci	    func_append finalize_command " @SYMFILE@"
688713498266Sopenharmony_ci	    preload=:
688813498266Sopenharmony_ci	  }
688913498266Sopenharmony_ci	  case $arg in
689013498266Sopenharmony_ci	  *.la | *.lo) ;;  # We handle these cases below.
689113498266Sopenharmony_ci	  force)
689213498266Sopenharmony_ci	    if test no = "$dlself"; then
689313498266Sopenharmony_ci	      dlself=needless
689413498266Sopenharmony_ci	      export_dynamic=yes
689513498266Sopenharmony_ci	    fi
689613498266Sopenharmony_ci	    prev=
689713498266Sopenharmony_ci	    continue
689813498266Sopenharmony_ci	    ;;
689913498266Sopenharmony_ci	  self)
690013498266Sopenharmony_ci	    if test dlprefiles = "$prev"; then
690113498266Sopenharmony_ci	      dlself=yes
690213498266Sopenharmony_ci	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
690313498266Sopenharmony_ci	      dlself=yes
690413498266Sopenharmony_ci	    else
690513498266Sopenharmony_ci	      dlself=needless
690613498266Sopenharmony_ci	      export_dynamic=yes
690713498266Sopenharmony_ci	    fi
690813498266Sopenharmony_ci	    prev=
690913498266Sopenharmony_ci	    continue
691013498266Sopenharmony_ci	    ;;
691113498266Sopenharmony_ci	  *)
691213498266Sopenharmony_ci	    if test dlfiles = "$prev"; then
691313498266Sopenharmony_ci	      func_append dlfiles " $arg"
691413498266Sopenharmony_ci	    else
691513498266Sopenharmony_ci	      func_append dlprefiles " $arg"
691613498266Sopenharmony_ci	    fi
691713498266Sopenharmony_ci	    prev=
691813498266Sopenharmony_ci	    continue
691913498266Sopenharmony_ci	    ;;
692013498266Sopenharmony_ci	  esac
692113498266Sopenharmony_ci	  ;;
692213498266Sopenharmony_ci	expsyms)
692313498266Sopenharmony_ci	  export_symbols=$arg
692413498266Sopenharmony_ci	  test -f "$arg" \
692513498266Sopenharmony_ci	    || func_fatal_error "symbol file '$arg' does not exist"
692613498266Sopenharmony_ci	  prev=
692713498266Sopenharmony_ci	  continue
692813498266Sopenharmony_ci	  ;;
692913498266Sopenharmony_ci	expsyms_regex)
693013498266Sopenharmony_ci	  export_symbols_regex=$arg
693113498266Sopenharmony_ci	  prev=
693213498266Sopenharmony_ci	  continue
693313498266Sopenharmony_ci	  ;;
693413498266Sopenharmony_ci	framework)
693513498266Sopenharmony_ci	  case $host in
693613498266Sopenharmony_ci	    *-*-darwin*)
693713498266Sopenharmony_ci	      case "$deplibs " in
693813498266Sopenharmony_ci		*" $qarg.ltframework "*) ;;
693913498266Sopenharmony_ci		*) func_append deplibs " $qarg.ltframework" # this is fixed later
694013498266Sopenharmony_ci		   ;;
694113498266Sopenharmony_ci	      esac
694213498266Sopenharmony_ci	      ;;
694313498266Sopenharmony_ci	  esac
694413498266Sopenharmony_ci	  prev=
694513498266Sopenharmony_ci	  continue
694613498266Sopenharmony_ci	  ;;
694713498266Sopenharmony_ci	inst_prefix)
694813498266Sopenharmony_ci	  inst_prefix_dir=$arg
694913498266Sopenharmony_ci	  prev=
695013498266Sopenharmony_ci	  continue
695113498266Sopenharmony_ci	  ;;
695213498266Sopenharmony_ci	mllvm)
695313498266Sopenharmony_ci	  # Clang does not use LLVM to link, so we can simply discard any
695413498266Sopenharmony_ci	  # '-mllvm $arg' options when doing the link step.
695513498266Sopenharmony_ci	  prev=
695613498266Sopenharmony_ci	  continue
695713498266Sopenharmony_ci	  ;;
695813498266Sopenharmony_ci	objectlist)
695913498266Sopenharmony_ci	  if test -f "$arg"; then
696013498266Sopenharmony_ci	    save_arg=$arg
696113498266Sopenharmony_ci	    moreargs=
696213498266Sopenharmony_ci	    for fil in `cat "$save_arg"`
696313498266Sopenharmony_ci	    do
696413498266Sopenharmony_ci#	      func_append moreargs " $fil"
696513498266Sopenharmony_ci	      arg=$fil
696613498266Sopenharmony_ci	      # A libtool-controlled object.
696713498266Sopenharmony_ci
696813498266Sopenharmony_ci	      # Check to see that this really is a libtool object.
696913498266Sopenharmony_ci	      if func_lalib_unsafe_p "$arg"; then
697013498266Sopenharmony_ci		pic_object=
697113498266Sopenharmony_ci		non_pic_object=
697213498266Sopenharmony_ci
697313498266Sopenharmony_ci		# Read the .lo file
697413498266Sopenharmony_ci		func_source "$arg"
697513498266Sopenharmony_ci
697613498266Sopenharmony_ci		if test -z "$pic_object" ||
697713498266Sopenharmony_ci		   test -z "$non_pic_object" ||
697813498266Sopenharmony_ci		   test none = "$pic_object" &&
697913498266Sopenharmony_ci		   test none = "$non_pic_object"; then
698013498266Sopenharmony_ci		  func_fatal_error "cannot find name of object for '$arg'"
698113498266Sopenharmony_ci		fi
698213498266Sopenharmony_ci
698313498266Sopenharmony_ci		# Extract subdirectory from the argument.
698413498266Sopenharmony_ci		func_dirname "$arg" "/" ""
698513498266Sopenharmony_ci		xdir=$func_dirname_result
698613498266Sopenharmony_ci
698713498266Sopenharmony_ci		if test none != "$pic_object"; then
698813498266Sopenharmony_ci		  # Prepend the subdirectory the object is found in.
698913498266Sopenharmony_ci		  pic_object=$xdir$pic_object
699013498266Sopenharmony_ci
699113498266Sopenharmony_ci		  if test dlfiles = "$prev"; then
699213498266Sopenharmony_ci		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
699313498266Sopenharmony_ci		      func_append dlfiles " $pic_object"
699413498266Sopenharmony_ci		      prev=
699513498266Sopenharmony_ci		      continue
699613498266Sopenharmony_ci		    else
699713498266Sopenharmony_ci		      # If libtool objects are unsupported, then we need to preload.
699813498266Sopenharmony_ci		      prev=dlprefiles
699913498266Sopenharmony_ci		    fi
700013498266Sopenharmony_ci		  fi
700113498266Sopenharmony_ci
700213498266Sopenharmony_ci		  # CHECK ME:  I think I busted this.  -Ossama
700313498266Sopenharmony_ci		  if test dlprefiles = "$prev"; then
700413498266Sopenharmony_ci		    # Preload the old-style object.
700513498266Sopenharmony_ci		    func_append dlprefiles " $pic_object"
700613498266Sopenharmony_ci		    prev=
700713498266Sopenharmony_ci		  fi
700813498266Sopenharmony_ci
700913498266Sopenharmony_ci		  # A PIC object.
701013498266Sopenharmony_ci		  func_append libobjs " $pic_object"
701113498266Sopenharmony_ci		  arg=$pic_object
701213498266Sopenharmony_ci		fi
701313498266Sopenharmony_ci
701413498266Sopenharmony_ci		# Non-PIC object.
701513498266Sopenharmony_ci		if test none != "$non_pic_object"; then
701613498266Sopenharmony_ci		  # Prepend the subdirectory the object is found in.
701713498266Sopenharmony_ci		  non_pic_object=$xdir$non_pic_object
701813498266Sopenharmony_ci
701913498266Sopenharmony_ci		  # A standard non-PIC object
702013498266Sopenharmony_ci		  func_append non_pic_objects " $non_pic_object"
702113498266Sopenharmony_ci		  if test -z "$pic_object" || test none = "$pic_object"; then
702213498266Sopenharmony_ci		    arg=$non_pic_object
702313498266Sopenharmony_ci		  fi
702413498266Sopenharmony_ci		else
702513498266Sopenharmony_ci		  # If the PIC object exists, use it instead.
702613498266Sopenharmony_ci		  # $xdir was prepended to $pic_object above.
702713498266Sopenharmony_ci		  non_pic_object=$pic_object
702813498266Sopenharmony_ci		  func_append non_pic_objects " $non_pic_object"
702913498266Sopenharmony_ci		fi
703013498266Sopenharmony_ci	      else
703113498266Sopenharmony_ci		# Only an error if not doing a dry-run.
703213498266Sopenharmony_ci		if $opt_dry_run; then
703313498266Sopenharmony_ci		  # Extract subdirectory from the argument.
703413498266Sopenharmony_ci		  func_dirname "$arg" "/" ""
703513498266Sopenharmony_ci		  xdir=$func_dirname_result
703613498266Sopenharmony_ci
703713498266Sopenharmony_ci		  func_lo2o "$arg"
703813498266Sopenharmony_ci		  pic_object=$xdir$objdir/$func_lo2o_result
703913498266Sopenharmony_ci		  non_pic_object=$xdir$func_lo2o_result
704013498266Sopenharmony_ci		  func_append libobjs " $pic_object"
704113498266Sopenharmony_ci		  func_append non_pic_objects " $non_pic_object"
704213498266Sopenharmony_ci	        else
704313498266Sopenharmony_ci		  func_fatal_error "'$arg' is not a valid libtool object"
704413498266Sopenharmony_ci		fi
704513498266Sopenharmony_ci	      fi
704613498266Sopenharmony_ci	    done
704713498266Sopenharmony_ci	  else
704813498266Sopenharmony_ci	    func_fatal_error "link input file '$arg' does not exist"
704913498266Sopenharmony_ci	  fi
705013498266Sopenharmony_ci	  arg=$save_arg
705113498266Sopenharmony_ci	  prev=
705213498266Sopenharmony_ci	  continue
705313498266Sopenharmony_ci	  ;;
705413498266Sopenharmony_ci	os2dllname)
705513498266Sopenharmony_ci	  os2dllname=$arg
705613498266Sopenharmony_ci	  prev=
705713498266Sopenharmony_ci	  continue
705813498266Sopenharmony_ci	  ;;
705913498266Sopenharmony_ci	precious_regex)
706013498266Sopenharmony_ci	  precious_files_regex=$arg
706113498266Sopenharmony_ci	  prev=
706213498266Sopenharmony_ci	  continue
706313498266Sopenharmony_ci	  ;;
706413498266Sopenharmony_ci	release)
706513498266Sopenharmony_ci	  release=-$arg
706613498266Sopenharmony_ci	  prev=
706713498266Sopenharmony_ci	  continue
706813498266Sopenharmony_ci	  ;;
706913498266Sopenharmony_ci	rpath | xrpath)
707013498266Sopenharmony_ci	  # We need an absolute path.
707113498266Sopenharmony_ci	  case $arg in
707213498266Sopenharmony_ci	  [\\/]* | [A-Za-z]:[\\/]*) ;;
707313498266Sopenharmony_ci	  *)
707413498266Sopenharmony_ci	    func_fatal_error "only absolute run-paths are allowed"
707513498266Sopenharmony_ci	    ;;
707613498266Sopenharmony_ci	  esac
707713498266Sopenharmony_ci	  if test rpath = "$prev"; then
707813498266Sopenharmony_ci	    case "$rpath " in
707913498266Sopenharmony_ci	    *" $arg "*) ;;
708013498266Sopenharmony_ci	    *) func_append rpath " $arg" ;;
708113498266Sopenharmony_ci	    esac
708213498266Sopenharmony_ci	  else
708313498266Sopenharmony_ci	    case "$xrpath " in
708413498266Sopenharmony_ci	    *" $arg "*) ;;
708513498266Sopenharmony_ci	    *) func_append xrpath " $arg" ;;
708613498266Sopenharmony_ci	    esac
708713498266Sopenharmony_ci	  fi
708813498266Sopenharmony_ci	  prev=
708913498266Sopenharmony_ci	  continue
709013498266Sopenharmony_ci	  ;;
709113498266Sopenharmony_ci	shrext)
709213498266Sopenharmony_ci	  shrext_cmds=$arg
709313498266Sopenharmony_ci	  prev=
709413498266Sopenharmony_ci	  continue
709513498266Sopenharmony_ci	  ;;
709613498266Sopenharmony_ci	weak)
709713498266Sopenharmony_ci	  func_append weak_libs " $arg"
709813498266Sopenharmony_ci	  prev=
709913498266Sopenharmony_ci	  continue
710013498266Sopenharmony_ci	  ;;
710113498266Sopenharmony_ci	xassembler)
710213498266Sopenharmony_ci	  func_append compiler_flags " -Xassembler $qarg"
710313498266Sopenharmony_ci	  prev=
710413498266Sopenharmony_ci	  func_append compile_command " -Xassembler $qarg"
710513498266Sopenharmony_ci	  func_append finalize_command " -Xassembler $qarg"
710613498266Sopenharmony_ci	  continue
710713498266Sopenharmony_ci	  ;;
710813498266Sopenharmony_ci	xcclinker)
710913498266Sopenharmony_ci	  func_append linker_flags " $qarg"
711013498266Sopenharmony_ci	  func_append compiler_flags " $qarg"
711113498266Sopenharmony_ci	  prev=
711213498266Sopenharmony_ci	  func_append compile_command " $qarg"
711313498266Sopenharmony_ci	  func_append finalize_command " $qarg"
711413498266Sopenharmony_ci	  continue
711513498266Sopenharmony_ci	  ;;
711613498266Sopenharmony_ci	xcompiler)
711713498266Sopenharmony_ci	  func_append compiler_flags " $qarg"
711813498266Sopenharmony_ci	  prev=
711913498266Sopenharmony_ci	  func_append compile_command " $qarg"
712013498266Sopenharmony_ci	  func_append finalize_command " $qarg"
712113498266Sopenharmony_ci	  continue
712213498266Sopenharmony_ci	  ;;
712313498266Sopenharmony_ci	xlinker)
712413498266Sopenharmony_ci	  func_append linker_flags " $qarg"
712513498266Sopenharmony_ci	  func_append compiler_flags " $wl$qarg"
712613498266Sopenharmony_ci	  prev=
712713498266Sopenharmony_ci	  func_append compile_command " $wl$qarg"
712813498266Sopenharmony_ci	  func_append finalize_command " $wl$qarg"
712913498266Sopenharmony_ci	  continue
713013498266Sopenharmony_ci	  ;;
713113498266Sopenharmony_ci	*)
713213498266Sopenharmony_ci	  eval "$prev=\"\$arg\""
713313498266Sopenharmony_ci	  prev=
713413498266Sopenharmony_ci	  continue
713513498266Sopenharmony_ci	  ;;
713613498266Sopenharmony_ci	esac
713713498266Sopenharmony_ci      fi # test -n "$prev"
713813498266Sopenharmony_ci
713913498266Sopenharmony_ci      prevarg=$arg
714013498266Sopenharmony_ci
714113498266Sopenharmony_ci      case $arg in
714213498266Sopenharmony_ci      -all-static)
714313498266Sopenharmony_ci	if test -n "$link_static_flag"; then
714413498266Sopenharmony_ci	  # See comment for -static flag below, for more details.
714513498266Sopenharmony_ci	  func_append compile_command " $link_static_flag"
714613498266Sopenharmony_ci	  func_append finalize_command " $link_static_flag"
714713498266Sopenharmony_ci	fi
714813498266Sopenharmony_ci	continue
714913498266Sopenharmony_ci	;;
715013498266Sopenharmony_ci
715113498266Sopenharmony_ci      -allow-undefined)
715213498266Sopenharmony_ci	# FIXME: remove this flag sometime in the future.
715313498266Sopenharmony_ci	func_fatal_error "'-allow-undefined' must not be used because it is the default"
715413498266Sopenharmony_ci	;;
715513498266Sopenharmony_ci
715613498266Sopenharmony_ci      -avoid-version)
715713498266Sopenharmony_ci	avoid_version=yes
715813498266Sopenharmony_ci	continue
715913498266Sopenharmony_ci	;;
716013498266Sopenharmony_ci
716113498266Sopenharmony_ci      -bindir)
716213498266Sopenharmony_ci	prev=bindir
716313498266Sopenharmony_ci	continue
716413498266Sopenharmony_ci	;;
716513498266Sopenharmony_ci
716613498266Sopenharmony_ci      -dlopen)
716713498266Sopenharmony_ci	prev=dlfiles
716813498266Sopenharmony_ci	continue
716913498266Sopenharmony_ci	;;
717013498266Sopenharmony_ci
717113498266Sopenharmony_ci      -dlpreopen)
717213498266Sopenharmony_ci	prev=dlprefiles
717313498266Sopenharmony_ci	continue
717413498266Sopenharmony_ci	;;
717513498266Sopenharmony_ci
717613498266Sopenharmony_ci      -export-dynamic)
717713498266Sopenharmony_ci	export_dynamic=yes
717813498266Sopenharmony_ci	continue
717913498266Sopenharmony_ci	;;
718013498266Sopenharmony_ci
718113498266Sopenharmony_ci      -export-symbols | -export-symbols-regex)
718213498266Sopenharmony_ci	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
718313498266Sopenharmony_ci	  func_fatal_error "more than one -exported-symbols argument is not allowed"
718413498266Sopenharmony_ci	fi
718513498266Sopenharmony_ci	if test X-export-symbols = "X$arg"; then
718613498266Sopenharmony_ci	  prev=expsyms
718713498266Sopenharmony_ci	else
718813498266Sopenharmony_ci	  prev=expsyms_regex
718913498266Sopenharmony_ci	fi
719013498266Sopenharmony_ci	continue
719113498266Sopenharmony_ci	;;
719213498266Sopenharmony_ci
719313498266Sopenharmony_ci      -framework)
719413498266Sopenharmony_ci	prev=framework
719513498266Sopenharmony_ci	continue
719613498266Sopenharmony_ci	;;
719713498266Sopenharmony_ci
719813498266Sopenharmony_ci      -inst-prefix-dir)
719913498266Sopenharmony_ci	prev=inst_prefix
720013498266Sopenharmony_ci	continue
720113498266Sopenharmony_ci	;;
720213498266Sopenharmony_ci
720313498266Sopenharmony_ci      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
720413498266Sopenharmony_ci      # so, if we see these flags be careful not to treat them like -L
720513498266Sopenharmony_ci      -L[A-Z][A-Z]*:*)
720613498266Sopenharmony_ci	case $with_gcc/$host in
720713498266Sopenharmony_ci	no/*-*-irix* | /*-*-irix*)
720813498266Sopenharmony_ci	  func_append compile_command " $arg"
720913498266Sopenharmony_ci	  func_append finalize_command " $arg"
721013498266Sopenharmony_ci	  ;;
721113498266Sopenharmony_ci	esac
721213498266Sopenharmony_ci	continue
721313498266Sopenharmony_ci	;;
721413498266Sopenharmony_ci
721513498266Sopenharmony_ci      -L*)
721613498266Sopenharmony_ci	func_stripname "-L" '' "$arg"
721713498266Sopenharmony_ci	if test -z "$func_stripname_result"; then
721813498266Sopenharmony_ci	  if test "$#" -gt 0; then
721913498266Sopenharmony_ci	    func_fatal_error "require no space between '-L' and '$1'"
722013498266Sopenharmony_ci	  else
722113498266Sopenharmony_ci	    func_fatal_error "need path for '-L' option"
722213498266Sopenharmony_ci	  fi
722313498266Sopenharmony_ci	fi
722413498266Sopenharmony_ci	func_resolve_sysroot "$func_stripname_result"
722513498266Sopenharmony_ci	dir=$func_resolve_sysroot_result
722613498266Sopenharmony_ci	# We need an absolute path.
722713498266Sopenharmony_ci	case $dir in
722813498266Sopenharmony_ci	[\\/]* | [A-Za-z]:[\\/]*) ;;
722913498266Sopenharmony_ci	*)
723013498266Sopenharmony_ci	  absdir=`cd "$dir" && pwd`
723113498266Sopenharmony_ci	  test -z "$absdir" && \
723213498266Sopenharmony_ci	    func_fatal_error "cannot determine absolute directory name of '$dir'"
723313498266Sopenharmony_ci	  dir=$absdir
723413498266Sopenharmony_ci	  ;;
723513498266Sopenharmony_ci	esac
723613498266Sopenharmony_ci	case "$deplibs " in
723713498266Sopenharmony_ci	*" -L$dir "* | *" $arg "*)
723813498266Sopenharmony_ci	  # Will only happen for absolute or sysroot arguments
723913498266Sopenharmony_ci	  ;;
724013498266Sopenharmony_ci	*)
724113498266Sopenharmony_ci	  # Preserve sysroot, but never include relative directories
724213498266Sopenharmony_ci	  case $dir in
724313498266Sopenharmony_ci	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
724413498266Sopenharmony_ci	    *) func_append deplibs " -L$dir" ;;
724513498266Sopenharmony_ci	  esac
724613498266Sopenharmony_ci	  func_append lib_search_path " $dir"
724713498266Sopenharmony_ci	  ;;
724813498266Sopenharmony_ci	esac
724913498266Sopenharmony_ci	case $host in
725013498266Sopenharmony_ci	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
725113498266Sopenharmony_ci	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
725213498266Sopenharmony_ci	  case :$dllsearchpath: in
725313498266Sopenharmony_ci	  *":$dir:"*) ;;
725413498266Sopenharmony_ci	  ::) dllsearchpath=$dir;;
725513498266Sopenharmony_ci	  *) func_append dllsearchpath ":$dir";;
725613498266Sopenharmony_ci	  esac
725713498266Sopenharmony_ci	  case :$dllsearchpath: in
725813498266Sopenharmony_ci	  *":$testbindir:"*) ;;
725913498266Sopenharmony_ci	  ::) dllsearchpath=$testbindir;;
726013498266Sopenharmony_ci	  *) func_append dllsearchpath ":$testbindir";;
726113498266Sopenharmony_ci	  esac
726213498266Sopenharmony_ci	  ;;
726313498266Sopenharmony_ci	esac
726413498266Sopenharmony_ci	continue
726513498266Sopenharmony_ci	;;
726613498266Sopenharmony_ci
726713498266Sopenharmony_ci      -l*)
726813498266Sopenharmony_ci	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
726913498266Sopenharmony_ci	  case $host in
727013498266Sopenharmony_ci	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
727113498266Sopenharmony_ci	    # These systems don't actually have a C or math library (as such)
727213498266Sopenharmony_ci	    continue
727313498266Sopenharmony_ci	    ;;
727413498266Sopenharmony_ci	  *-*-os2*)
727513498266Sopenharmony_ci	    # These systems don't actually have a C library (as such)
727613498266Sopenharmony_ci	    test X-lc = "X$arg" && continue
727713498266Sopenharmony_ci	    ;;
727813498266Sopenharmony_ci	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*)
727913498266Sopenharmony_ci	    # Do not include libc due to us having libc/libc_r.
728013498266Sopenharmony_ci	    test X-lc = "X$arg" && continue
728113498266Sopenharmony_ci	    ;;
728213498266Sopenharmony_ci	  *-*-rhapsody* | *-*-darwin1.[012])
728313498266Sopenharmony_ci	    # Rhapsody C and math libraries are in the System framework
728413498266Sopenharmony_ci	    func_append deplibs " System.ltframework"
728513498266Sopenharmony_ci	    continue
728613498266Sopenharmony_ci	    ;;
728713498266Sopenharmony_ci	  *-*-sco3.2v5* | *-*-sco5v6*)
728813498266Sopenharmony_ci	    # Causes problems with __ctype
728913498266Sopenharmony_ci	    test X-lc = "X$arg" && continue
729013498266Sopenharmony_ci	    ;;
729113498266Sopenharmony_ci	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
729213498266Sopenharmony_ci	    # Compiler inserts libc in the correct place for threads to work
729313498266Sopenharmony_ci	    test X-lc = "X$arg" && continue
729413498266Sopenharmony_ci	    ;;
729513498266Sopenharmony_ci	  esac
729613498266Sopenharmony_ci	elif test X-lc_r = "X$arg"; then
729713498266Sopenharmony_ci	 case $host in
729813498266Sopenharmony_ci	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*)
729913498266Sopenharmony_ci	   # Do not include libc_r directly, use -pthread flag.
730013498266Sopenharmony_ci	   continue
730113498266Sopenharmony_ci	   ;;
730213498266Sopenharmony_ci	 esac
730313498266Sopenharmony_ci	fi
730413498266Sopenharmony_ci	func_append deplibs " $arg"
730513498266Sopenharmony_ci	continue
730613498266Sopenharmony_ci	;;
730713498266Sopenharmony_ci
730813498266Sopenharmony_ci      -mllvm)
730913498266Sopenharmony_ci	prev=mllvm
731013498266Sopenharmony_ci	continue
731113498266Sopenharmony_ci	;;
731213498266Sopenharmony_ci
731313498266Sopenharmony_ci      -module)
731413498266Sopenharmony_ci	module=yes
731513498266Sopenharmony_ci	continue
731613498266Sopenharmony_ci	;;
731713498266Sopenharmony_ci
731813498266Sopenharmony_ci      # Tru64 UNIX uses -model [arg] to determine the layout of C++
731913498266Sopenharmony_ci      # classes, name mangling, and exception handling.
732013498266Sopenharmony_ci      # Darwin uses the -arch flag to determine output architecture.
732113498266Sopenharmony_ci      -model|-arch|-isysroot|--sysroot)
732213498266Sopenharmony_ci	func_append compiler_flags " $arg"
732313498266Sopenharmony_ci	func_append compile_command " $arg"
732413498266Sopenharmony_ci	func_append finalize_command " $arg"
732513498266Sopenharmony_ci	prev=xcompiler
732613498266Sopenharmony_ci	continue
732713498266Sopenharmony_ci	;;
732813498266Sopenharmony_ci     # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199.
732913498266Sopenharmony_ci     -pthread)
733013498266Sopenharmony_ci	case $host in
733113498266Sopenharmony_ci	  *solaris2*) ;;
733213498266Sopenharmony_ci	  *)
733313498266Sopenharmony_ci	    case "$new_inherited_linker_flags " in
733413498266Sopenharmony_ci	        *" $arg "*) ;;
733513498266Sopenharmony_ci	        * ) func_append new_inherited_linker_flags " $arg" ;;
733613498266Sopenharmony_ci	    esac
733713498266Sopenharmony_ci	  ;;
733813498266Sopenharmony_ci	esac
733913498266Sopenharmony_ci	continue
734013498266Sopenharmony_ci	;;
734113498266Sopenharmony_ci      -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \
734213498266Sopenharmony_ci      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
734313498266Sopenharmony_ci	func_append compiler_flags " $arg"
734413498266Sopenharmony_ci	func_append compile_command " $arg"
734513498266Sopenharmony_ci	func_append finalize_command " $arg"
734613498266Sopenharmony_ci	case "$new_inherited_linker_flags " in
734713498266Sopenharmony_ci	    *" $arg "*) ;;
734813498266Sopenharmony_ci	    * ) func_append new_inherited_linker_flags " $arg" ;;
734913498266Sopenharmony_ci	esac
735013498266Sopenharmony_ci	continue
735113498266Sopenharmony_ci	;;
735213498266Sopenharmony_ci
735313498266Sopenharmony_ci      -multi_module)
735413498266Sopenharmony_ci	single_module=$wl-multi_module
735513498266Sopenharmony_ci	continue
735613498266Sopenharmony_ci	;;
735713498266Sopenharmony_ci
735813498266Sopenharmony_ci      -no-fast-install)
735913498266Sopenharmony_ci	fast_install=no
736013498266Sopenharmony_ci	continue
736113498266Sopenharmony_ci	;;
736213498266Sopenharmony_ci
736313498266Sopenharmony_ci      -no-install)
736413498266Sopenharmony_ci	case $host in
736513498266Sopenharmony_ci	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
736613498266Sopenharmony_ci	  # The PATH hackery in wrapper scripts is required on Windows
736713498266Sopenharmony_ci	  # and Darwin in order for the loader to find any dlls it needs.
736813498266Sopenharmony_ci	  func_warning "'-no-install' is ignored for $host"
736913498266Sopenharmony_ci	  func_warning "assuming '-no-fast-install' instead"
737013498266Sopenharmony_ci	  fast_install=no
737113498266Sopenharmony_ci	  ;;
737213498266Sopenharmony_ci	*) no_install=yes ;;
737313498266Sopenharmony_ci	esac
737413498266Sopenharmony_ci	continue
737513498266Sopenharmony_ci	;;
737613498266Sopenharmony_ci
737713498266Sopenharmony_ci      -no-undefined)
737813498266Sopenharmony_ci	allow_undefined=no
737913498266Sopenharmony_ci	continue
738013498266Sopenharmony_ci	;;
738113498266Sopenharmony_ci
738213498266Sopenharmony_ci      -objectlist)
738313498266Sopenharmony_ci	prev=objectlist
738413498266Sopenharmony_ci	continue
738513498266Sopenharmony_ci	;;
738613498266Sopenharmony_ci
738713498266Sopenharmony_ci      -os2dllname)
738813498266Sopenharmony_ci	prev=os2dllname
738913498266Sopenharmony_ci	continue
739013498266Sopenharmony_ci	;;
739113498266Sopenharmony_ci
739213498266Sopenharmony_ci      -o) prev=output ;;
739313498266Sopenharmony_ci
739413498266Sopenharmony_ci      -precious-files-regex)
739513498266Sopenharmony_ci	prev=precious_regex
739613498266Sopenharmony_ci	continue
739713498266Sopenharmony_ci	;;
739813498266Sopenharmony_ci
739913498266Sopenharmony_ci      -release)
740013498266Sopenharmony_ci	prev=release
740113498266Sopenharmony_ci	continue
740213498266Sopenharmony_ci	;;
740313498266Sopenharmony_ci
740413498266Sopenharmony_ci      -rpath)
740513498266Sopenharmony_ci	prev=rpath
740613498266Sopenharmony_ci	continue
740713498266Sopenharmony_ci	;;
740813498266Sopenharmony_ci
740913498266Sopenharmony_ci      -R)
741013498266Sopenharmony_ci	prev=xrpath
741113498266Sopenharmony_ci	continue
741213498266Sopenharmony_ci	;;
741313498266Sopenharmony_ci
741413498266Sopenharmony_ci      -R*)
741513498266Sopenharmony_ci	func_stripname '-R' '' "$arg"
741613498266Sopenharmony_ci	dir=$func_stripname_result
741713498266Sopenharmony_ci	# We need an absolute path.
741813498266Sopenharmony_ci	case $dir in
741913498266Sopenharmony_ci	[\\/]* | [A-Za-z]:[\\/]*) ;;
742013498266Sopenharmony_ci	=*)
742113498266Sopenharmony_ci	  func_stripname '=' '' "$dir"
742213498266Sopenharmony_ci	  dir=$lt_sysroot$func_stripname_result
742313498266Sopenharmony_ci	  ;;
742413498266Sopenharmony_ci	*)
742513498266Sopenharmony_ci	  func_fatal_error "only absolute run-paths are allowed"
742613498266Sopenharmony_ci	  ;;
742713498266Sopenharmony_ci	esac
742813498266Sopenharmony_ci	case "$xrpath " in
742913498266Sopenharmony_ci	*" $dir "*) ;;
743013498266Sopenharmony_ci	*) func_append xrpath " $dir" ;;
743113498266Sopenharmony_ci	esac
743213498266Sopenharmony_ci	continue
743313498266Sopenharmony_ci	;;
743413498266Sopenharmony_ci
743513498266Sopenharmony_ci      -shared)
743613498266Sopenharmony_ci	# The effects of -shared are defined in a previous loop.
743713498266Sopenharmony_ci	continue
743813498266Sopenharmony_ci	;;
743913498266Sopenharmony_ci
744013498266Sopenharmony_ci      -shrext)
744113498266Sopenharmony_ci	prev=shrext
744213498266Sopenharmony_ci	continue
744313498266Sopenharmony_ci	;;
744413498266Sopenharmony_ci
744513498266Sopenharmony_ci      -static | -static-libtool-libs)
744613498266Sopenharmony_ci	# The effects of -static are defined in a previous loop.
744713498266Sopenharmony_ci	# We used to do the same as -all-static on platforms that
744813498266Sopenharmony_ci	# didn't have a PIC flag, but the assumption that the effects
744913498266Sopenharmony_ci	# would be equivalent was wrong.  It would break on at least
745013498266Sopenharmony_ci	# Digital Unix and AIX.
745113498266Sopenharmony_ci	continue
745213498266Sopenharmony_ci	;;
745313498266Sopenharmony_ci
745413498266Sopenharmony_ci      -thread-safe)
745513498266Sopenharmony_ci	thread_safe=yes
745613498266Sopenharmony_ci	continue
745713498266Sopenharmony_ci	;;
745813498266Sopenharmony_ci
745913498266Sopenharmony_ci      -version-info)
746013498266Sopenharmony_ci	prev=vinfo
746113498266Sopenharmony_ci	continue
746213498266Sopenharmony_ci	;;
746313498266Sopenharmony_ci
746413498266Sopenharmony_ci      -version-number)
746513498266Sopenharmony_ci	prev=vinfo
746613498266Sopenharmony_ci	vinfo_number=yes
746713498266Sopenharmony_ci	continue
746813498266Sopenharmony_ci	;;
746913498266Sopenharmony_ci
747013498266Sopenharmony_ci      -weak)
747113498266Sopenharmony_ci        prev=weak
747213498266Sopenharmony_ci	continue
747313498266Sopenharmony_ci	;;
747413498266Sopenharmony_ci
747513498266Sopenharmony_ci      -Wc,*)
747613498266Sopenharmony_ci	func_stripname '-Wc,' '' "$arg"
747713498266Sopenharmony_ci	args=$func_stripname_result
747813498266Sopenharmony_ci	arg=
747913498266Sopenharmony_ci	save_ifs=$IFS; IFS=,
748013498266Sopenharmony_ci	for flag in $args; do
748113498266Sopenharmony_ci	  IFS=$save_ifs
748213498266Sopenharmony_ci          func_quote_arg pretty "$flag"
748313498266Sopenharmony_ci	  func_append arg " $func_quote_arg_result"
748413498266Sopenharmony_ci	  func_append compiler_flags " $func_quote_arg_result"
748513498266Sopenharmony_ci	done
748613498266Sopenharmony_ci	IFS=$save_ifs
748713498266Sopenharmony_ci	func_stripname ' ' '' "$arg"
748813498266Sopenharmony_ci	arg=$func_stripname_result
748913498266Sopenharmony_ci	;;
749013498266Sopenharmony_ci
749113498266Sopenharmony_ci      -Wl,*)
749213498266Sopenharmony_ci	func_stripname '-Wl,' '' "$arg"
749313498266Sopenharmony_ci	args=$func_stripname_result
749413498266Sopenharmony_ci	arg=
749513498266Sopenharmony_ci	save_ifs=$IFS; IFS=,
749613498266Sopenharmony_ci	for flag in $args; do
749713498266Sopenharmony_ci	  IFS=$save_ifs
749813498266Sopenharmony_ci          func_quote_arg pretty "$flag"
749913498266Sopenharmony_ci	  func_append arg " $wl$func_quote_arg_result"
750013498266Sopenharmony_ci	  func_append compiler_flags " $wl$func_quote_arg_result"
750113498266Sopenharmony_ci	  func_append linker_flags " $func_quote_arg_result"
750213498266Sopenharmony_ci	done
750313498266Sopenharmony_ci	IFS=$save_ifs
750413498266Sopenharmony_ci	func_stripname ' ' '' "$arg"
750513498266Sopenharmony_ci	arg=$func_stripname_result
750613498266Sopenharmony_ci	;;
750713498266Sopenharmony_ci
750813498266Sopenharmony_ci      -Xassembler)
750913498266Sopenharmony_ci        prev=xassembler
751013498266Sopenharmony_ci        continue
751113498266Sopenharmony_ci        ;;
751213498266Sopenharmony_ci
751313498266Sopenharmony_ci      -Xcompiler)
751413498266Sopenharmony_ci	prev=xcompiler
751513498266Sopenharmony_ci	continue
751613498266Sopenharmony_ci	;;
751713498266Sopenharmony_ci
751813498266Sopenharmony_ci      -Xlinker)
751913498266Sopenharmony_ci	prev=xlinker
752013498266Sopenharmony_ci	continue
752113498266Sopenharmony_ci	;;
752213498266Sopenharmony_ci
752313498266Sopenharmony_ci      -XCClinker)
752413498266Sopenharmony_ci	prev=xcclinker
752513498266Sopenharmony_ci	continue
752613498266Sopenharmony_ci	;;
752713498266Sopenharmony_ci
752813498266Sopenharmony_ci      # -msg_* for osf cc
752913498266Sopenharmony_ci      -msg_*)
753013498266Sopenharmony_ci	func_quote_arg pretty "$arg"
753113498266Sopenharmony_ci	arg=$func_quote_arg_result
753213498266Sopenharmony_ci	;;
753313498266Sopenharmony_ci
753413498266Sopenharmony_ci      # Flags to be passed through unchanged, with rationale:
753513498266Sopenharmony_ci      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
753613498266Sopenharmony_ci      # -r[0-9][0-9]*        specify processor for the SGI compiler
753713498266Sopenharmony_ci      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
753813498266Sopenharmony_ci      # +DA*, +DD*           enable 64-bit mode for the HP compiler
753913498266Sopenharmony_ci      # -q*                  compiler args for the IBM compiler
754013498266Sopenharmony_ci      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
754113498266Sopenharmony_ci      # -F/path              path to uninstalled frameworks, gcc on darwin
754213498266Sopenharmony_ci      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
754313498266Sopenharmony_ci      # -fstack-protector*   stack protector flags for GCC
754413498266Sopenharmony_ci      # @file                GCC response files
754513498266Sopenharmony_ci      # -tp=*                Portland pgcc target processor selection
754613498266Sopenharmony_ci      # --sysroot=*          for sysroot support
754713498266Sopenharmony_ci      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
754813498266Sopenharmony_ci      # -specs=*             GCC specs files
754913498266Sopenharmony_ci      # -stdlib=*            select c++ std lib with clang
755013498266Sopenharmony_ci      # -fsanitize=*         Clang/GCC memory and address sanitizer
755113498266Sopenharmony_ci      # -fuse-ld=*           Linker select flags for GCC
755213498266Sopenharmony_ci      # -static-*            direct GCC to link specific libraries statically
755313498266Sopenharmony_ci      # -fcilkplus           Cilk Plus language extension features for C/C++
755413498266Sopenharmony_ci      # -Wa,*                Pass flags directly to the assembler
755513498266Sopenharmony_ci      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
755613498266Sopenharmony_ci      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
755713498266Sopenharmony_ci      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
755813498266Sopenharmony_ci      -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus|-Wa,*)
755913498266Sopenharmony_ci        func_quote_arg pretty "$arg"
756013498266Sopenharmony_ci	arg=$func_quote_arg_result
756113498266Sopenharmony_ci        func_append compile_command " $arg"
756213498266Sopenharmony_ci        func_append finalize_command " $arg"
756313498266Sopenharmony_ci        func_append compiler_flags " $arg"
756413498266Sopenharmony_ci        continue
756513498266Sopenharmony_ci        ;;
756613498266Sopenharmony_ci
756713498266Sopenharmony_ci      -Z*)
756813498266Sopenharmony_ci        if test os2 = "`expr $host : '.*\(os2\)'`"; then
756913498266Sopenharmony_ci          # OS/2 uses -Zxxx to specify OS/2-specific options
757013498266Sopenharmony_ci	  compiler_flags="$compiler_flags $arg"
757113498266Sopenharmony_ci	  func_append compile_command " $arg"
757213498266Sopenharmony_ci	  func_append finalize_command " $arg"
757313498266Sopenharmony_ci	  case $arg in
757413498266Sopenharmony_ci	  -Zlinker | -Zstack)
757513498266Sopenharmony_ci	    prev=xcompiler
757613498266Sopenharmony_ci	    ;;
757713498266Sopenharmony_ci	  esac
757813498266Sopenharmony_ci	  continue
757913498266Sopenharmony_ci        else
758013498266Sopenharmony_ci	  # Otherwise treat like 'Some other compiler flag' below
758113498266Sopenharmony_ci	  func_quote_arg pretty "$arg"
758213498266Sopenharmony_ci	  arg=$func_quote_arg_result
758313498266Sopenharmony_ci        fi
758413498266Sopenharmony_ci	;;
758513498266Sopenharmony_ci
758613498266Sopenharmony_ci      # Some other compiler flag.
758713498266Sopenharmony_ci      -* | +*)
758813498266Sopenharmony_ci        func_quote_arg pretty "$arg"
758913498266Sopenharmony_ci	arg=$func_quote_arg_result
759013498266Sopenharmony_ci	;;
759113498266Sopenharmony_ci
759213498266Sopenharmony_ci      *.$objext)
759313498266Sopenharmony_ci	# A standard object.
759413498266Sopenharmony_ci	func_append objs " $arg"
759513498266Sopenharmony_ci	;;
759613498266Sopenharmony_ci
759713498266Sopenharmony_ci      *.lo)
759813498266Sopenharmony_ci	# A libtool-controlled object.
759913498266Sopenharmony_ci
760013498266Sopenharmony_ci	# Check to see that this really is a libtool object.
760113498266Sopenharmony_ci	if func_lalib_unsafe_p "$arg"; then
760213498266Sopenharmony_ci	  pic_object=
760313498266Sopenharmony_ci	  non_pic_object=
760413498266Sopenharmony_ci
760513498266Sopenharmony_ci	  # Read the .lo file
760613498266Sopenharmony_ci	  func_source "$arg"
760713498266Sopenharmony_ci
760813498266Sopenharmony_ci	  if test -z "$pic_object" ||
760913498266Sopenharmony_ci	     test -z "$non_pic_object" ||
761013498266Sopenharmony_ci	     test none = "$pic_object" &&
761113498266Sopenharmony_ci	     test none = "$non_pic_object"; then
761213498266Sopenharmony_ci	    func_fatal_error "cannot find name of object for '$arg'"
761313498266Sopenharmony_ci	  fi
761413498266Sopenharmony_ci
761513498266Sopenharmony_ci	  # Extract subdirectory from the argument.
761613498266Sopenharmony_ci	  func_dirname "$arg" "/" ""
761713498266Sopenharmony_ci	  xdir=$func_dirname_result
761813498266Sopenharmony_ci
761913498266Sopenharmony_ci	  test none = "$pic_object" || {
762013498266Sopenharmony_ci	    # Prepend the subdirectory the object is found in.
762113498266Sopenharmony_ci	    pic_object=$xdir$pic_object
762213498266Sopenharmony_ci
762313498266Sopenharmony_ci	    if test dlfiles = "$prev"; then
762413498266Sopenharmony_ci	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
762513498266Sopenharmony_ci		func_append dlfiles " $pic_object"
762613498266Sopenharmony_ci		prev=
762713498266Sopenharmony_ci		continue
762813498266Sopenharmony_ci	      else
762913498266Sopenharmony_ci		# If libtool objects are unsupported, then we need to preload.
763013498266Sopenharmony_ci		prev=dlprefiles
763113498266Sopenharmony_ci	      fi
763213498266Sopenharmony_ci	    fi
763313498266Sopenharmony_ci
763413498266Sopenharmony_ci	    # CHECK ME:  I think I busted this.  -Ossama
763513498266Sopenharmony_ci	    if test dlprefiles = "$prev"; then
763613498266Sopenharmony_ci	      # Preload the old-style object.
763713498266Sopenharmony_ci	      func_append dlprefiles " $pic_object"
763813498266Sopenharmony_ci	      prev=
763913498266Sopenharmony_ci	    fi
764013498266Sopenharmony_ci
764113498266Sopenharmony_ci	    # A PIC object.
764213498266Sopenharmony_ci	    func_append libobjs " $pic_object"
764313498266Sopenharmony_ci	    arg=$pic_object
764413498266Sopenharmony_ci	  }
764513498266Sopenharmony_ci
764613498266Sopenharmony_ci	  # Non-PIC object.
764713498266Sopenharmony_ci	  if test none != "$non_pic_object"; then
764813498266Sopenharmony_ci	    # Prepend the subdirectory the object is found in.
764913498266Sopenharmony_ci	    non_pic_object=$xdir$non_pic_object
765013498266Sopenharmony_ci
765113498266Sopenharmony_ci	    # A standard non-PIC object
765213498266Sopenharmony_ci	    func_append non_pic_objects " $non_pic_object"
765313498266Sopenharmony_ci	    if test -z "$pic_object" || test none = "$pic_object"; then
765413498266Sopenharmony_ci	      arg=$non_pic_object
765513498266Sopenharmony_ci	    fi
765613498266Sopenharmony_ci	  else
765713498266Sopenharmony_ci	    # If the PIC object exists, use it instead.
765813498266Sopenharmony_ci	    # $xdir was prepended to $pic_object above.
765913498266Sopenharmony_ci	    non_pic_object=$pic_object
766013498266Sopenharmony_ci	    func_append non_pic_objects " $non_pic_object"
766113498266Sopenharmony_ci	  fi
766213498266Sopenharmony_ci	else
766313498266Sopenharmony_ci	  # Only an error if not doing a dry-run.
766413498266Sopenharmony_ci	  if $opt_dry_run; then
766513498266Sopenharmony_ci	    # Extract subdirectory from the argument.
766613498266Sopenharmony_ci	    func_dirname "$arg" "/" ""
766713498266Sopenharmony_ci	    xdir=$func_dirname_result
766813498266Sopenharmony_ci
766913498266Sopenharmony_ci	    func_lo2o "$arg"
767013498266Sopenharmony_ci	    pic_object=$xdir$objdir/$func_lo2o_result
767113498266Sopenharmony_ci	    non_pic_object=$xdir$func_lo2o_result
767213498266Sopenharmony_ci	    func_append libobjs " $pic_object"
767313498266Sopenharmony_ci	    func_append non_pic_objects " $non_pic_object"
767413498266Sopenharmony_ci	  else
767513498266Sopenharmony_ci	    func_fatal_error "'$arg' is not a valid libtool object"
767613498266Sopenharmony_ci	  fi
767713498266Sopenharmony_ci	fi
767813498266Sopenharmony_ci	;;
767913498266Sopenharmony_ci
768013498266Sopenharmony_ci      *.$libext)
768113498266Sopenharmony_ci	# An archive.
768213498266Sopenharmony_ci	func_append deplibs " $arg"
768313498266Sopenharmony_ci	func_append old_deplibs " $arg"
768413498266Sopenharmony_ci	continue
768513498266Sopenharmony_ci	;;
768613498266Sopenharmony_ci
768713498266Sopenharmony_ci      *.la)
768813498266Sopenharmony_ci	# A libtool-controlled library.
768913498266Sopenharmony_ci
769013498266Sopenharmony_ci	func_resolve_sysroot "$arg"
769113498266Sopenharmony_ci	if test dlfiles = "$prev"; then
769213498266Sopenharmony_ci	  # This library was specified with -dlopen.
769313498266Sopenharmony_ci	  func_append dlfiles " $func_resolve_sysroot_result"
769413498266Sopenharmony_ci	  prev=
769513498266Sopenharmony_ci	elif test dlprefiles = "$prev"; then
769613498266Sopenharmony_ci	  # The library was specified with -dlpreopen.
769713498266Sopenharmony_ci	  func_append dlprefiles " $func_resolve_sysroot_result"
769813498266Sopenharmony_ci	  prev=
769913498266Sopenharmony_ci	else
770013498266Sopenharmony_ci	  func_append deplibs " $func_resolve_sysroot_result"
770113498266Sopenharmony_ci	fi
770213498266Sopenharmony_ci	continue
770313498266Sopenharmony_ci	;;
770413498266Sopenharmony_ci
770513498266Sopenharmony_ci      # Some other compiler argument.
770613498266Sopenharmony_ci      *)
770713498266Sopenharmony_ci	# Unknown arguments in both finalize_command and compile_command need
770813498266Sopenharmony_ci	# to be aesthetically quoted because they are evaled later.
770913498266Sopenharmony_ci	func_quote_arg pretty "$arg"
771013498266Sopenharmony_ci	arg=$func_quote_arg_result
771113498266Sopenharmony_ci	;;
771213498266Sopenharmony_ci      esac # arg
771313498266Sopenharmony_ci
771413498266Sopenharmony_ci      # Now actually substitute the argument into the commands.
771513498266Sopenharmony_ci      if test -n "$arg"; then
771613498266Sopenharmony_ci	func_append compile_command " $arg"
771713498266Sopenharmony_ci	func_append finalize_command " $arg"
771813498266Sopenharmony_ci      fi
771913498266Sopenharmony_ci    done # argument parsing loop
772013498266Sopenharmony_ci
772113498266Sopenharmony_ci    test -n "$prev" && \
772213498266Sopenharmony_ci      func_fatal_help "the '$prevarg' option requires an argument"
772313498266Sopenharmony_ci
772413498266Sopenharmony_ci    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
772513498266Sopenharmony_ci      eval arg=\"$export_dynamic_flag_spec\"
772613498266Sopenharmony_ci      func_append compile_command " $arg"
772713498266Sopenharmony_ci      func_append finalize_command " $arg"
772813498266Sopenharmony_ci    fi
772913498266Sopenharmony_ci
773013498266Sopenharmony_ci    oldlibs=
773113498266Sopenharmony_ci    # calculate the name of the file, without its directory
773213498266Sopenharmony_ci    func_basename "$output"
773313498266Sopenharmony_ci    outputname=$func_basename_result
773413498266Sopenharmony_ci    libobjs_save=$libobjs
773513498266Sopenharmony_ci
773613498266Sopenharmony_ci    if test -n "$shlibpath_var"; then
773713498266Sopenharmony_ci      # get the directories listed in $shlibpath_var
773813498266Sopenharmony_ci      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
773913498266Sopenharmony_ci    else
774013498266Sopenharmony_ci      shlib_search_path=
774113498266Sopenharmony_ci    fi
774213498266Sopenharmony_ci    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
774313498266Sopenharmony_ci    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
774413498266Sopenharmony_ci
774513498266Sopenharmony_ci    # Definition is injected by LT_CONFIG during libtool generation.
774613498266Sopenharmony_ci    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
774713498266Sopenharmony_ci
774813498266Sopenharmony_ci    func_dirname "$output" "/" ""
774913498266Sopenharmony_ci    output_objdir=$func_dirname_result$objdir
775013498266Sopenharmony_ci    func_to_tool_file "$output_objdir/"
775113498266Sopenharmony_ci    tool_output_objdir=$func_to_tool_file_result
775213498266Sopenharmony_ci    # Create the object directory.
775313498266Sopenharmony_ci    func_mkdir_p "$output_objdir"
775413498266Sopenharmony_ci
775513498266Sopenharmony_ci    # Determine the type of output
775613498266Sopenharmony_ci    case $output in
775713498266Sopenharmony_ci    "")
775813498266Sopenharmony_ci      func_fatal_help "you must specify an output file"
775913498266Sopenharmony_ci      ;;
776013498266Sopenharmony_ci    *.$libext) linkmode=oldlib ;;
776113498266Sopenharmony_ci    *.lo | *.$objext) linkmode=obj ;;
776213498266Sopenharmony_ci    *.la) linkmode=lib ;;
776313498266Sopenharmony_ci    *) linkmode=prog ;; # Anything else should be a program.
776413498266Sopenharmony_ci    esac
776513498266Sopenharmony_ci
776613498266Sopenharmony_ci    specialdeplibs=
776713498266Sopenharmony_ci
776813498266Sopenharmony_ci    libs=
776913498266Sopenharmony_ci    # Find all interdependent deplibs by searching for libraries
777013498266Sopenharmony_ci    # that are linked more than once (e.g. -la -lb -la)
777113498266Sopenharmony_ci    for deplib in $deplibs; do
777213498266Sopenharmony_ci      if $opt_preserve_dup_deps; then
777313498266Sopenharmony_ci	case "$libs " in
777413498266Sopenharmony_ci	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
777513498266Sopenharmony_ci	esac
777613498266Sopenharmony_ci      fi
777713498266Sopenharmony_ci      func_append libs " $deplib"
777813498266Sopenharmony_ci    done
777913498266Sopenharmony_ci
778013498266Sopenharmony_ci    if test lib = "$linkmode"; then
778113498266Sopenharmony_ci      libs="$predeps $libs $compiler_lib_search_path $postdeps"
778213498266Sopenharmony_ci
778313498266Sopenharmony_ci      # Compute libraries that are listed more than once in $predeps
778413498266Sopenharmony_ci      # $postdeps and mark them as special (i.e., whose duplicates are
778513498266Sopenharmony_ci      # not to be eliminated).
778613498266Sopenharmony_ci      pre_post_deps=
778713498266Sopenharmony_ci      if $opt_duplicate_compiler_generated_deps; then
778813498266Sopenharmony_ci	for pre_post_dep in $predeps $postdeps; do
778913498266Sopenharmony_ci	  case "$pre_post_deps " in
779013498266Sopenharmony_ci	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
779113498266Sopenharmony_ci	  esac
779213498266Sopenharmony_ci	  func_append pre_post_deps " $pre_post_dep"
779313498266Sopenharmony_ci	done
779413498266Sopenharmony_ci      fi
779513498266Sopenharmony_ci      pre_post_deps=
779613498266Sopenharmony_ci    fi
779713498266Sopenharmony_ci
779813498266Sopenharmony_ci    deplibs=
779913498266Sopenharmony_ci    newdependency_libs=
780013498266Sopenharmony_ci    newlib_search_path=
780113498266Sopenharmony_ci    need_relink=no # whether we're linking any uninstalled libtool libraries
780213498266Sopenharmony_ci    notinst_deplibs= # not-installed libtool libraries
780313498266Sopenharmony_ci    notinst_path= # paths that contain not-installed libtool libraries
780413498266Sopenharmony_ci
780513498266Sopenharmony_ci    case $linkmode in
780613498266Sopenharmony_ci    lib)
780713498266Sopenharmony_ci	passes="conv dlpreopen link"
780813498266Sopenharmony_ci	for file in $dlfiles $dlprefiles; do
780913498266Sopenharmony_ci	  case $file in
781013498266Sopenharmony_ci	  *.la) ;;
781113498266Sopenharmony_ci	  *)
781213498266Sopenharmony_ci	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
781313498266Sopenharmony_ci	    ;;
781413498266Sopenharmony_ci	  esac
781513498266Sopenharmony_ci	done
781613498266Sopenharmony_ci	;;
781713498266Sopenharmony_ci    prog)
781813498266Sopenharmony_ci	compile_deplibs=
781913498266Sopenharmony_ci	finalize_deplibs=
782013498266Sopenharmony_ci	alldeplibs=false
782113498266Sopenharmony_ci	newdlfiles=
782213498266Sopenharmony_ci	newdlprefiles=
782313498266Sopenharmony_ci	passes="conv scan dlopen dlpreopen link"
782413498266Sopenharmony_ci	;;
782513498266Sopenharmony_ci    *)  passes="conv"
782613498266Sopenharmony_ci	;;
782713498266Sopenharmony_ci    esac
782813498266Sopenharmony_ci
782913498266Sopenharmony_ci    for pass in $passes; do
783013498266Sopenharmony_ci      # The preopen pass in lib mode reverses $deplibs; put it back here
783113498266Sopenharmony_ci      # so that -L comes before libs that need it for instance...
783213498266Sopenharmony_ci      if test lib,link = "$linkmode,$pass"; then
783313498266Sopenharmony_ci	## FIXME: Find the place where the list is rebuilt in the wrong
783413498266Sopenharmony_ci	##        order, and fix it there properly
783513498266Sopenharmony_ci        tmp_deplibs=
783613498266Sopenharmony_ci	for deplib in $deplibs; do
783713498266Sopenharmony_ci	  tmp_deplibs="$deplib $tmp_deplibs"
783813498266Sopenharmony_ci	done
783913498266Sopenharmony_ci	deplibs=$tmp_deplibs
784013498266Sopenharmony_ci      fi
784113498266Sopenharmony_ci
784213498266Sopenharmony_ci      if test lib,link = "$linkmode,$pass" ||
784313498266Sopenharmony_ci	 test prog,scan = "$linkmode,$pass"; then
784413498266Sopenharmony_ci	libs=$deplibs
784513498266Sopenharmony_ci	deplibs=
784613498266Sopenharmony_ci      fi
784713498266Sopenharmony_ci      if test prog = "$linkmode"; then
784813498266Sopenharmony_ci	case $pass in
784913498266Sopenharmony_ci	dlopen) libs=$dlfiles ;;
785013498266Sopenharmony_ci	dlpreopen) libs=$dlprefiles ;;
785113498266Sopenharmony_ci	link)
785213498266Sopenharmony_ci	  libs="$deplibs %DEPLIBS%"
785313498266Sopenharmony_ci	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
785413498266Sopenharmony_ci	  ;;
785513498266Sopenharmony_ci	esac
785613498266Sopenharmony_ci      fi
785713498266Sopenharmony_ci      if test lib,dlpreopen = "$linkmode,$pass"; then
785813498266Sopenharmony_ci	# Collect and forward deplibs of preopened libtool libs
785913498266Sopenharmony_ci	for lib in $dlprefiles; do
786013498266Sopenharmony_ci	  # Ignore non-libtool-libs
786113498266Sopenharmony_ci	  dependency_libs=
786213498266Sopenharmony_ci	  func_resolve_sysroot "$lib"
786313498266Sopenharmony_ci	  case $lib in
786413498266Sopenharmony_ci	  *.la)	func_source "$func_resolve_sysroot_result" ;;
786513498266Sopenharmony_ci	  esac
786613498266Sopenharmony_ci
786713498266Sopenharmony_ci	  # Collect preopened libtool deplibs, except any this library
786813498266Sopenharmony_ci	  # has declared as weak libs
786913498266Sopenharmony_ci	  for deplib in $dependency_libs; do
787013498266Sopenharmony_ci	    func_basename "$deplib"
787113498266Sopenharmony_ci            deplib_base=$func_basename_result
787213498266Sopenharmony_ci	    case " $weak_libs " in
787313498266Sopenharmony_ci	    *" $deplib_base "*) ;;
787413498266Sopenharmony_ci	    *) func_append deplibs " $deplib" ;;
787513498266Sopenharmony_ci	    esac
787613498266Sopenharmony_ci	  done
787713498266Sopenharmony_ci	done
787813498266Sopenharmony_ci	libs=$dlprefiles
787913498266Sopenharmony_ci      fi
788013498266Sopenharmony_ci      if test dlopen = "$pass"; then
788113498266Sopenharmony_ci	# Collect dlpreopened libraries
788213498266Sopenharmony_ci	save_deplibs=$deplibs
788313498266Sopenharmony_ci	deplibs=
788413498266Sopenharmony_ci      fi
788513498266Sopenharmony_ci
788613498266Sopenharmony_ci      for deplib in $libs; do
788713498266Sopenharmony_ci	lib=
788813498266Sopenharmony_ci	found=false
788913498266Sopenharmony_ci	case $deplib in
789013498266Sopenharmony_ci	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
789113498266Sopenharmony_ci        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
789213498266Sopenharmony_ci	  if test prog,link = "$linkmode,$pass"; then
789313498266Sopenharmony_ci	    compile_deplibs="$deplib $compile_deplibs"
789413498266Sopenharmony_ci	    finalize_deplibs="$deplib $finalize_deplibs"
789513498266Sopenharmony_ci	  else
789613498266Sopenharmony_ci	    func_append compiler_flags " $deplib"
789713498266Sopenharmony_ci	    if test lib = "$linkmode"; then
789813498266Sopenharmony_ci		case "$new_inherited_linker_flags " in
789913498266Sopenharmony_ci		    *" $deplib "*) ;;
790013498266Sopenharmony_ci		    * ) func_append new_inherited_linker_flags " $deplib" ;;
790113498266Sopenharmony_ci		esac
790213498266Sopenharmony_ci	    fi
790313498266Sopenharmony_ci	  fi
790413498266Sopenharmony_ci	  continue
790513498266Sopenharmony_ci	  ;;
790613498266Sopenharmony_ci	-l*)
790713498266Sopenharmony_ci	  if test lib != "$linkmode" && test prog != "$linkmode"; then
790813498266Sopenharmony_ci	    func_warning "'-l' is ignored for archives/objects"
790913498266Sopenharmony_ci	    continue
791013498266Sopenharmony_ci	  fi
791113498266Sopenharmony_ci	  func_stripname '-l' '' "$deplib"
791213498266Sopenharmony_ci	  name=$func_stripname_result
791313498266Sopenharmony_ci	  if test lib = "$linkmode"; then
791413498266Sopenharmony_ci	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
791513498266Sopenharmony_ci	  else
791613498266Sopenharmony_ci	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
791713498266Sopenharmony_ci	  fi
791813498266Sopenharmony_ci	  for searchdir in $searchdirs; do
791913498266Sopenharmony_ci	    for search_ext in .la $std_shrext .so .a; do
792013498266Sopenharmony_ci	      # Search the libtool library
792113498266Sopenharmony_ci	      lib=$searchdir/lib$name$search_ext
792213498266Sopenharmony_ci	      if test -f "$lib"; then
792313498266Sopenharmony_ci		if test .la = "$search_ext"; then
792413498266Sopenharmony_ci		  found=:
792513498266Sopenharmony_ci		else
792613498266Sopenharmony_ci		  found=false
792713498266Sopenharmony_ci		fi
792813498266Sopenharmony_ci		break 2
792913498266Sopenharmony_ci	      fi
793013498266Sopenharmony_ci	    done
793113498266Sopenharmony_ci	  done
793213498266Sopenharmony_ci	  if $found; then
793313498266Sopenharmony_ci	    # deplib is a libtool library
793413498266Sopenharmony_ci	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
793513498266Sopenharmony_ci	    # We need to do some special things here, and not later.
793613498266Sopenharmony_ci	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
793713498266Sopenharmony_ci	      case " $predeps $postdeps " in
793813498266Sopenharmony_ci	      *" $deplib "*)
793913498266Sopenharmony_ci		if func_lalib_p "$lib"; then
794013498266Sopenharmony_ci		  library_names=
794113498266Sopenharmony_ci		  old_library=
794213498266Sopenharmony_ci		  func_source "$lib"
794313498266Sopenharmony_ci		  for l in $old_library $library_names; do
794413498266Sopenharmony_ci		    ll=$l
794513498266Sopenharmony_ci		  done
794613498266Sopenharmony_ci		  if test "X$ll" = "X$old_library"; then # only static version available
794713498266Sopenharmony_ci		    found=false
794813498266Sopenharmony_ci		    func_dirname "$lib" "" "."
794913498266Sopenharmony_ci		    ladir=$func_dirname_result
795013498266Sopenharmony_ci		    lib=$ladir/$old_library
795113498266Sopenharmony_ci		    if test prog,link = "$linkmode,$pass"; then
795213498266Sopenharmony_ci		      compile_deplibs="$deplib $compile_deplibs"
795313498266Sopenharmony_ci		      finalize_deplibs="$deplib $finalize_deplibs"
795413498266Sopenharmony_ci		    else
795513498266Sopenharmony_ci		      deplibs="$deplib $deplibs"
795613498266Sopenharmony_ci		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
795713498266Sopenharmony_ci		    fi
795813498266Sopenharmony_ci		    continue
795913498266Sopenharmony_ci		  fi
796013498266Sopenharmony_ci		fi
796113498266Sopenharmony_ci		;;
796213498266Sopenharmony_ci	      *) ;;
796313498266Sopenharmony_ci	      esac
796413498266Sopenharmony_ci	    fi
796513498266Sopenharmony_ci	  else
796613498266Sopenharmony_ci	    # deplib doesn't seem to be a libtool library
796713498266Sopenharmony_ci	    if test prog,link = "$linkmode,$pass"; then
796813498266Sopenharmony_ci	      compile_deplibs="$deplib $compile_deplibs"
796913498266Sopenharmony_ci	      finalize_deplibs="$deplib $finalize_deplibs"
797013498266Sopenharmony_ci	    else
797113498266Sopenharmony_ci	      deplibs="$deplib $deplibs"
797213498266Sopenharmony_ci	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
797313498266Sopenharmony_ci	    fi
797413498266Sopenharmony_ci	    continue
797513498266Sopenharmony_ci	  fi
797613498266Sopenharmony_ci	  ;; # -l
797713498266Sopenharmony_ci	*.ltframework)
797813498266Sopenharmony_ci	  if test prog,link = "$linkmode,$pass"; then
797913498266Sopenharmony_ci	    compile_deplibs="$deplib $compile_deplibs"
798013498266Sopenharmony_ci	    finalize_deplibs="$deplib $finalize_deplibs"
798113498266Sopenharmony_ci	  else
798213498266Sopenharmony_ci	    deplibs="$deplib $deplibs"
798313498266Sopenharmony_ci	    if test lib = "$linkmode"; then
798413498266Sopenharmony_ci		case "$new_inherited_linker_flags " in
798513498266Sopenharmony_ci		    *" $deplib "*) ;;
798613498266Sopenharmony_ci		    * ) func_append new_inherited_linker_flags " $deplib" ;;
798713498266Sopenharmony_ci		esac
798813498266Sopenharmony_ci	    fi
798913498266Sopenharmony_ci	  fi
799013498266Sopenharmony_ci	  continue
799113498266Sopenharmony_ci	  ;;
799213498266Sopenharmony_ci	-L*)
799313498266Sopenharmony_ci	  case $linkmode in
799413498266Sopenharmony_ci	  lib)
799513498266Sopenharmony_ci	    deplibs="$deplib $deplibs"
799613498266Sopenharmony_ci	    test conv = "$pass" && continue
799713498266Sopenharmony_ci	    newdependency_libs="$deplib $newdependency_libs"
799813498266Sopenharmony_ci	    func_stripname '-L' '' "$deplib"
799913498266Sopenharmony_ci	    func_resolve_sysroot "$func_stripname_result"
800013498266Sopenharmony_ci	    func_append newlib_search_path " $func_resolve_sysroot_result"
800113498266Sopenharmony_ci	    ;;
800213498266Sopenharmony_ci	  prog)
800313498266Sopenharmony_ci	    if test conv = "$pass"; then
800413498266Sopenharmony_ci	      deplibs="$deplib $deplibs"
800513498266Sopenharmony_ci	      continue
800613498266Sopenharmony_ci	    fi
800713498266Sopenharmony_ci	    if test scan = "$pass"; then
800813498266Sopenharmony_ci	      deplibs="$deplib $deplibs"
800913498266Sopenharmony_ci	    else
801013498266Sopenharmony_ci	      compile_deplibs="$deplib $compile_deplibs"
801113498266Sopenharmony_ci	      finalize_deplibs="$deplib $finalize_deplibs"
801213498266Sopenharmony_ci	    fi
801313498266Sopenharmony_ci	    func_stripname '-L' '' "$deplib"
801413498266Sopenharmony_ci	    func_resolve_sysroot "$func_stripname_result"
801513498266Sopenharmony_ci	    func_append newlib_search_path " $func_resolve_sysroot_result"
801613498266Sopenharmony_ci	    ;;
801713498266Sopenharmony_ci	  *)
801813498266Sopenharmony_ci	    func_warning "'-L' is ignored for archives/objects"
801913498266Sopenharmony_ci	    ;;
802013498266Sopenharmony_ci	  esac # linkmode
802113498266Sopenharmony_ci	  continue
802213498266Sopenharmony_ci	  ;; # -L
802313498266Sopenharmony_ci	-R*)
802413498266Sopenharmony_ci	  if test link = "$pass"; then
802513498266Sopenharmony_ci	    func_stripname '-R' '' "$deplib"
802613498266Sopenharmony_ci	    func_resolve_sysroot "$func_stripname_result"
802713498266Sopenharmony_ci	    dir=$func_resolve_sysroot_result
802813498266Sopenharmony_ci	    # Make sure the xrpath contains only unique directories.
802913498266Sopenharmony_ci	    case "$xrpath " in
803013498266Sopenharmony_ci	    *" $dir "*) ;;
803113498266Sopenharmony_ci	    *) func_append xrpath " $dir" ;;
803213498266Sopenharmony_ci	    esac
803313498266Sopenharmony_ci	  fi
803413498266Sopenharmony_ci	  deplibs="$deplib $deplibs"
803513498266Sopenharmony_ci	  continue
803613498266Sopenharmony_ci	  ;;
803713498266Sopenharmony_ci	*.la)
803813498266Sopenharmony_ci	  func_resolve_sysroot "$deplib"
803913498266Sopenharmony_ci	  lib=$func_resolve_sysroot_result
804013498266Sopenharmony_ci	  ;;
804113498266Sopenharmony_ci	*.$libext)
804213498266Sopenharmony_ci	  if test conv = "$pass"; then
804313498266Sopenharmony_ci	    deplibs="$deplib $deplibs"
804413498266Sopenharmony_ci	    continue
804513498266Sopenharmony_ci	  fi
804613498266Sopenharmony_ci	  case $linkmode in
804713498266Sopenharmony_ci	  lib)
804813498266Sopenharmony_ci	    # Linking convenience modules into shared libraries is allowed,
804913498266Sopenharmony_ci	    # but linking other static libraries is non-portable.
805013498266Sopenharmony_ci	    case " $dlpreconveniencelibs " in
805113498266Sopenharmony_ci	    *" $deplib "*) ;;
805213498266Sopenharmony_ci	    *)
805313498266Sopenharmony_ci	      valid_a_lib=false
805413498266Sopenharmony_ci	      case $deplibs_check_method in
805513498266Sopenharmony_ci		match_pattern*)
805613498266Sopenharmony_ci		  set dummy $deplibs_check_method; shift
805713498266Sopenharmony_ci		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
805813498266Sopenharmony_ci		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
805913498266Sopenharmony_ci		    | $EGREP "$match_pattern_regex" > /dev/null; then
806013498266Sopenharmony_ci		    valid_a_lib=:
806113498266Sopenharmony_ci		  fi
806213498266Sopenharmony_ci		;;
806313498266Sopenharmony_ci		pass_all)
806413498266Sopenharmony_ci		  valid_a_lib=:
806513498266Sopenharmony_ci		;;
806613498266Sopenharmony_ci	      esac
806713498266Sopenharmony_ci	      if $valid_a_lib; then
806813498266Sopenharmony_ci		echo
806913498266Sopenharmony_ci		$ECHO "*** Warning: Linking the shared library $output against the"
807013498266Sopenharmony_ci		$ECHO "*** static library $deplib is not portable!"
807113498266Sopenharmony_ci		deplibs="$deplib $deplibs"
807213498266Sopenharmony_ci	      else
807313498266Sopenharmony_ci		echo
807413498266Sopenharmony_ci		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
807513498266Sopenharmony_ci		echo "*** I have the capability to make that library automatically link in when"
807613498266Sopenharmony_ci		echo "*** you link to this library.  But I can only do this if you have a"
807713498266Sopenharmony_ci		echo "*** shared version of the library, which you do not appear to have"
807813498266Sopenharmony_ci		echo "*** because the file extensions .$libext of this argument makes me believe"
807913498266Sopenharmony_ci		echo "*** that it is just a static archive that I should not use here."
808013498266Sopenharmony_ci	      fi
808113498266Sopenharmony_ci	      ;;
808213498266Sopenharmony_ci	    esac
808313498266Sopenharmony_ci	    continue
808413498266Sopenharmony_ci	    ;;
808513498266Sopenharmony_ci	  prog)
808613498266Sopenharmony_ci	    if test link != "$pass"; then
808713498266Sopenharmony_ci	      deplibs="$deplib $deplibs"
808813498266Sopenharmony_ci	    else
808913498266Sopenharmony_ci	      compile_deplibs="$deplib $compile_deplibs"
809013498266Sopenharmony_ci	      finalize_deplibs="$deplib $finalize_deplibs"
809113498266Sopenharmony_ci	    fi
809213498266Sopenharmony_ci	    continue
809313498266Sopenharmony_ci	    ;;
809413498266Sopenharmony_ci	  esac # linkmode
809513498266Sopenharmony_ci	  ;; # *.$libext
809613498266Sopenharmony_ci	*.lo | *.$objext)
809713498266Sopenharmony_ci	  if test conv = "$pass"; then
809813498266Sopenharmony_ci	    deplibs="$deplib $deplibs"
809913498266Sopenharmony_ci	  elif test prog = "$linkmode"; then
810013498266Sopenharmony_ci	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
810113498266Sopenharmony_ci	      # If there is no dlopen support or we're linking statically,
810213498266Sopenharmony_ci	      # we need to preload.
810313498266Sopenharmony_ci	      func_append newdlprefiles " $deplib"
810413498266Sopenharmony_ci	      compile_deplibs="$deplib $compile_deplibs"
810513498266Sopenharmony_ci	      finalize_deplibs="$deplib $finalize_deplibs"
810613498266Sopenharmony_ci	    else
810713498266Sopenharmony_ci	      func_append newdlfiles " $deplib"
810813498266Sopenharmony_ci	    fi
810913498266Sopenharmony_ci	  fi
811013498266Sopenharmony_ci	  continue
811113498266Sopenharmony_ci	  ;;
811213498266Sopenharmony_ci	%DEPLIBS%)
811313498266Sopenharmony_ci	  alldeplibs=:
811413498266Sopenharmony_ci	  continue
811513498266Sopenharmony_ci	  ;;
811613498266Sopenharmony_ci	esac # case $deplib
811713498266Sopenharmony_ci
811813498266Sopenharmony_ci	$found || test -f "$lib" \
811913498266Sopenharmony_ci	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
812013498266Sopenharmony_ci
812113498266Sopenharmony_ci	# Check to see that this really is a libtool archive.
812213498266Sopenharmony_ci	func_lalib_unsafe_p "$lib" \
812313498266Sopenharmony_ci	  || func_fatal_error "'$lib' is not a valid libtool archive"
812413498266Sopenharmony_ci
812513498266Sopenharmony_ci	func_dirname "$lib" "" "."
812613498266Sopenharmony_ci	ladir=$func_dirname_result
812713498266Sopenharmony_ci
812813498266Sopenharmony_ci	dlname=
812913498266Sopenharmony_ci	dlopen=
813013498266Sopenharmony_ci	dlpreopen=
813113498266Sopenharmony_ci	libdir=
813213498266Sopenharmony_ci	library_names=
813313498266Sopenharmony_ci	old_library=
813413498266Sopenharmony_ci	inherited_linker_flags=
813513498266Sopenharmony_ci	# If the library was installed with an old release of libtool,
813613498266Sopenharmony_ci	# it will not redefine variables installed, or shouldnotlink
813713498266Sopenharmony_ci	installed=yes
813813498266Sopenharmony_ci	shouldnotlink=no
813913498266Sopenharmony_ci	avoidtemprpath=
814013498266Sopenharmony_ci
814113498266Sopenharmony_ci
814213498266Sopenharmony_ci	# Read the .la file
814313498266Sopenharmony_ci	func_source "$lib"
814413498266Sopenharmony_ci
814513498266Sopenharmony_ci	# Convert "-framework foo" to "foo.ltframework"
814613498266Sopenharmony_ci	if test -n "$inherited_linker_flags"; then
814713498266Sopenharmony_ci	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
814813498266Sopenharmony_ci	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
814913498266Sopenharmony_ci	    case " $new_inherited_linker_flags " in
815013498266Sopenharmony_ci	      *" $tmp_inherited_linker_flag "*) ;;
815113498266Sopenharmony_ci	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
815213498266Sopenharmony_ci	    esac
815313498266Sopenharmony_ci	  done
815413498266Sopenharmony_ci	fi
815513498266Sopenharmony_ci	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
815613498266Sopenharmony_ci	if test lib,link = "$linkmode,$pass" ||
815713498266Sopenharmony_ci	   test prog,scan = "$linkmode,$pass" ||
815813498266Sopenharmony_ci	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
815913498266Sopenharmony_ci	  test -n "$dlopen" && func_append dlfiles " $dlopen"
816013498266Sopenharmony_ci	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
816113498266Sopenharmony_ci	fi
816213498266Sopenharmony_ci
816313498266Sopenharmony_ci	if test conv = "$pass"; then
816413498266Sopenharmony_ci	  # Only check for convenience libraries
816513498266Sopenharmony_ci	  deplibs="$lib $deplibs"
816613498266Sopenharmony_ci	  if test -z "$libdir"; then
816713498266Sopenharmony_ci	    if test -z "$old_library"; then
816813498266Sopenharmony_ci	      func_fatal_error "cannot find name of link library for '$lib'"
816913498266Sopenharmony_ci	    fi
817013498266Sopenharmony_ci	    # It is a libtool convenience library, so add in its objects.
817113498266Sopenharmony_ci	    func_append convenience " $ladir/$objdir/$old_library"
817213498266Sopenharmony_ci	    func_append old_convenience " $ladir/$objdir/$old_library"
817313498266Sopenharmony_ci	    tmp_libs=
817413498266Sopenharmony_ci	    for deplib in $dependency_libs; do
817513498266Sopenharmony_ci	      deplibs="$deplib $deplibs"
817613498266Sopenharmony_ci	      if $opt_preserve_dup_deps; then
817713498266Sopenharmony_ci		case "$tmp_libs " in
817813498266Sopenharmony_ci		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
817913498266Sopenharmony_ci		esac
818013498266Sopenharmony_ci	      fi
818113498266Sopenharmony_ci	      func_append tmp_libs " $deplib"
818213498266Sopenharmony_ci	    done
818313498266Sopenharmony_ci	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
818413498266Sopenharmony_ci	    func_fatal_error "'$lib' is not a convenience library"
818513498266Sopenharmony_ci	  fi
818613498266Sopenharmony_ci	  continue
818713498266Sopenharmony_ci	fi # $pass = conv
818813498266Sopenharmony_ci
818913498266Sopenharmony_ci
819013498266Sopenharmony_ci	# Get the name of the library we link against.
819113498266Sopenharmony_ci	linklib=
819213498266Sopenharmony_ci	if test -n "$old_library" &&
819313498266Sopenharmony_ci	   { test yes = "$prefer_static_libs" ||
819413498266Sopenharmony_ci	     test built,no = "$prefer_static_libs,$installed"; }; then
819513498266Sopenharmony_ci	  linklib=$old_library
819613498266Sopenharmony_ci	else
819713498266Sopenharmony_ci	  for l in $old_library $library_names; do
819813498266Sopenharmony_ci	    linklib=$l
819913498266Sopenharmony_ci	  done
820013498266Sopenharmony_ci	fi
820113498266Sopenharmony_ci	if test -z "$linklib"; then
820213498266Sopenharmony_ci	  func_fatal_error "cannot find name of link library for '$lib'"
820313498266Sopenharmony_ci	fi
820413498266Sopenharmony_ci
820513498266Sopenharmony_ci	# This library was specified with -dlopen.
820613498266Sopenharmony_ci	if test dlopen = "$pass"; then
820713498266Sopenharmony_ci	  test -z "$libdir" \
820813498266Sopenharmony_ci	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
820913498266Sopenharmony_ci	  if test -z "$dlname" ||
821013498266Sopenharmony_ci	     test yes != "$dlopen_support" ||
821113498266Sopenharmony_ci	     test no = "$build_libtool_libs"
821213498266Sopenharmony_ci	  then
821313498266Sopenharmony_ci	    # If there is no dlname, no dlopen support or we're linking
821413498266Sopenharmony_ci	    # statically, we need to preload.  We also need to preload any
821513498266Sopenharmony_ci	    # dependent libraries so libltdl's deplib preloader doesn't
821613498266Sopenharmony_ci	    # bomb out in the load deplibs phase.
821713498266Sopenharmony_ci	    func_append dlprefiles " $lib $dependency_libs"
821813498266Sopenharmony_ci	  else
821913498266Sopenharmony_ci	    func_append newdlfiles " $lib"
822013498266Sopenharmony_ci	  fi
822113498266Sopenharmony_ci	  continue
822213498266Sopenharmony_ci	fi # $pass = dlopen
822313498266Sopenharmony_ci
822413498266Sopenharmony_ci	# We need an absolute path.
822513498266Sopenharmony_ci	case $ladir in
822613498266Sopenharmony_ci	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
822713498266Sopenharmony_ci	*)
822813498266Sopenharmony_ci	  abs_ladir=`cd "$ladir" && pwd`
822913498266Sopenharmony_ci	  if test -z "$abs_ladir"; then
823013498266Sopenharmony_ci	    func_warning "cannot determine absolute directory name of '$ladir'"
823113498266Sopenharmony_ci	    func_warning "passing it literally to the linker, although it might fail"
823213498266Sopenharmony_ci	    abs_ladir=$ladir
823313498266Sopenharmony_ci	  fi
823413498266Sopenharmony_ci	  ;;
823513498266Sopenharmony_ci	esac
823613498266Sopenharmony_ci	func_basename "$lib"
823713498266Sopenharmony_ci	laname=$func_basename_result
823813498266Sopenharmony_ci
823913498266Sopenharmony_ci	# Find the relevant object directory and library name.
824013498266Sopenharmony_ci	if test yes = "$installed"; then
824113498266Sopenharmony_ci	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
824213498266Sopenharmony_ci	    func_warning "library '$lib' was moved."
824313498266Sopenharmony_ci	    dir=$ladir
824413498266Sopenharmony_ci	    absdir=$abs_ladir
824513498266Sopenharmony_ci	    libdir=$abs_ladir
824613498266Sopenharmony_ci	  else
824713498266Sopenharmony_ci	    dir=$lt_sysroot$libdir
824813498266Sopenharmony_ci	    absdir=$lt_sysroot$libdir
824913498266Sopenharmony_ci	  fi
825013498266Sopenharmony_ci	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
825113498266Sopenharmony_ci	else
825213498266Sopenharmony_ci	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
825313498266Sopenharmony_ci	    dir=$ladir
825413498266Sopenharmony_ci	    absdir=$abs_ladir
825513498266Sopenharmony_ci	    # Remove this search path later
825613498266Sopenharmony_ci	    func_append notinst_path " $abs_ladir"
825713498266Sopenharmony_ci	  else
825813498266Sopenharmony_ci	    dir=$ladir/$objdir
825913498266Sopenharmony_ci	    absdir=$abs_ladir/$objdir
826013498266Sopenharmony_ci	    # Remove this search path later
826113498266Sopenharmony_ci	    func_append notinst_path " $abs_ladir"
826213498266Sopenharmony_ci	  fi
826313498266Sopenharmony_ci	fi # $installed = yes
826413498266Sopenharmony_ci	func_stripname 'lib' '.la' "$laname"
826513498266Sopenharmony_ci	name=$func_stripname_result
826613498266Sopenharmony_ci
826713498266Sopenharmony_ci	# This library was specified with -dlpreopen.
826813498266Sopenharmony_ci	if test dlpreopen = "$pass"; then
826913498266Sopenharmony_ci	  if test -z "$libdir" && test prog = "$linkmode"; then
827013498266Sopenharmony_ci	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
827113498266Sopenharmony_ci	  fi
827213498266Sopenharmony_ci	  case $host in
827313498266Sopenharmony_ci	    # special handling for platforms with PE-DLLs.
827413498266Sopenharmony_ci	    *cygwin* | *mingw* | *cegcc* )
827513498266Sopenharmony_ci	      # Linker will automatically link against shared library if both
827613498266Sopenharmony_ci	      # static and shared are present.  Therefore, ensure we extract
827713498266Sopenharmony_ci	      # symbols from the import library if a shared library is present
827813498266Sopenharmony_ci	      # (otherwise, the dlopen module name will be incorrect).  We do
827913498266Sopenharmony_ci	      # this by putting the import library name into $newdlprefiles.
828013498266Sopenharmony_ci	      # We recover the dlopen module name by 'saving' the la file
828113498266Sopenharmony_ci	      # name in a special purpose variable, and (later) extracting the
828213498266Sopenharmony_ci	      # dlname from the la file.
828313498266Sopenharmony_ci	      if test -n "$dlname"; then
828413498266Sopenharmony_ci	        func_tr_sh "$dir/$linklib"
828513498266Sopenharmony_ci	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
828613498266Sopenharmony_ci	        func_append newdlprefiles " $dir/$linklib"
828713498266Sopenharmony_ci	      else
828813498266Sopenharmony_ci	        func_append newdlprefiles " $dir/$old_library"
828913498266Sopenharmony_ci	        # Keep a list of preopened convenience libraries to check
829013498266Sopenharmony_ci	        # that they are being used correctly in the link pass.
829113498266Sopenharmony_ci	        test -z "$libdir" && \
829213498266Sopenharmony_ci	          func_append dlpreconveniencelibs " $dir/$old_library"
829313498266Sopenharmony_ci	      fi
829413498266Sopenharmony_ci	    ;;
829513498266Sopenharmony_ci	    * )
829613498266Sopenharmony_ci	      # Prefer using a static library (so that no silly _DYNAMIC symbols
829713498266Sopenharmony_ci	      # are required to link).
829813498266Sopenharmony_ci	      if test -n "$old_library"; then
829913498266Sopenharmony_ci	        func_append newdlprefiles " $dir/$old_library"
830013498266Sopenharmony_ci	        # Keep a list of preopened convenience libraries to check
830113498266Sopenharmony_ci	        # that they are being used correctly in the link pass.
830213498266Sopenharmony_ci	        test -z "$libdir" && \
830313498266Sopenharmony_ci	          func_append dlpreconveniencelibs " $dir/$old_library"
830413498266Sopenharmony_ci	      # Otherwise, use the dlname, so that lt_dlopen finds it.
830513498266Sopenharmony_ci	      elif test -n "$dlname"; then
830613498266Sopenharmony_ci	        func_append newdlprefiles " $dir/$dlname"
830713498266Sopenharmony_ci	      else
830813498266Sopenharmony_ci	        func_append newdlprefiles " $dir/$linklib"
830913498266Sopenharmony_ci	      fi
831013498266Sopenharmony_ci	    ;;
831113498266Sopenharmony_ci	  esac
831213498266Sopenharmony_ci	fi # $pass = dlpreopen
831313498266Sopenharmony_ci
831413498266Sopenharmony_ci	if test -z "$libdir"; then
831513498266Sopenharmony_ci	  # Link the convenience library
831613498266Sopenharmony_ci	  if test lib = "$linkmode"; then
831713498266Sopenharmony_ci	    deplibs="$dir/$old_library $deplibs"
831813498266Sopenharmony_ci	  elif test prog,link = "$linkmode,$pass"; then
831913498266Sopenharmony_ci	    compile_deplibs="$dir/$old_library $compile_deplibs"
832013498266Sopenharmony_ci	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
832113498266Sopenharmony_ci	  else
832213498266Sopenharmony_ci	    deplibs="$lib $deplibs" # used for prog,scan pass
832313498266Sopenharmony_ci	  fi
832413498266Sopenharmony_ci	  continue
832513498266Sopenharmony_ci	fi
832613498266Sopenharmony_ci
832713498266Sopenharmony_ci
832813498266Sopenharmony_ci	if test prog = "$linkmode" && test link != "$pass"; then
832913498266Sopenharmony_ci	  func_append newlib_search_path " $ladir"
833013498266Sopenharmony_ci	  deplibs="$lib $deplibs"
833113498266Sopenharmony_ci
833213498266Sopenharmony_ci	  linkalldeplibs=false
833313498266Sopenharmony_ci	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
833413498266Sopenharmony_ci	     test no = "$build_libtool_libs"; then
833513498266Sopenharmony_ci	    linkalldeplibs=:
833613498266Sopenharmony_ci	  fi
833713498266Sopenharmony_ci
833813498266Sopenharmony_ci	  tmp_libs=
833913498266Sopenharmony_ci	  for deplib in $dependency_libs; do
834013498266Sopenharmony_ci	    case $deplib in
834113498266Sopenharmony_ci	    -L*) func_stripname '-L' '' "$deplib"
834213498266Sopenharmony_ci	         func_resolve_sysroot "$func_stripname_result"
834313498266Sopenharmony_ci	         func_append newlib_search_path " $func_resolve_sysroot_result"
834413498266Sopenharmony_ci		 ;;
834513498266Sopenharmony_ci	    esac
834613498266Sopenharmony_ci	    # Need to link against all dependency_libs?
834713498266Sopenharmony_ci	    if $linkalldeplibs; then
834813498266Sopenharmony_ci	      deplibs="$deplib $deplibs"
834913498266Sopenharmony_ci	    else
835013498266Sopenharmony_ci	      # Need to hardcode shared library paths
835113498266Sopenharmony_ci	      # or/and link against static libraries
835213498266Sopenharmony_ci	      newdependency_libs="$deplib $newdependency_libs"
835313498266Sopenharmony_ci	    fi
835413498266Sopenharmony_ci	    if $opt_preserve_dup_deps; then
835513498266Sopenharmony_ci	      case "$tmp_libs " in
835613498266Sopenharmony_ci	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
835713498266Sopenharmony_ci	      esac
835813498266Sopenharmony_ci	    fi
835913498266Sopenharmony_ci	    func_append tmp_libs " $deplib"
836013498266Sopenharmony_ci	  done # for deplib
836113498266Sopenharmony_ci	  continue
836213498266Sopenharmony_ci	fi # $linkmode = prog...
836313498266Sopenharmony_ci
836413498266Sopenharmony_ci	if test prog,link = "$linkmode,$pass"; then
836513498266Sopenharmony_ci	  if test -n "$library_names" &&
836613498266Sopenharmony_ci	     { { test no = "$prefer_static_libs" ||
836713498266Sopenharmony_ci	         test built,yes = "$prefer_static_libs,$installed"; } ||
836813498266Sopenharmony_ci	       test -z "$old_library"; }; then
836913498266Sopenharmony_ci	    # We need to hardcode the library path
837013498266Sopenharmony_ci	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
837113498266Sopenharmony_ci	      # Make sure the rpath contains only unique directories.
837213498266Sopenharmony_ci	      case $temp_rpath: in
837313498266Sopenharmony_ci	      *"$absdir:"*) ;;
837413498266Sopenharmony_ci	      *) func_append temp_rpath "$absdir:" ;;
837513498266Sopenharmony_ci	      esac
837613498266Sopenharmony_ci	    fi
837713498266Sopenharmony_ci
837813498266Sopenharmony_ci	    # Hardcode the library path.
837913498266Sopenharmony_ci	    # Skip directories that are in the system default run-time
838013498266Sopenharmony_ci	    # search path.
838113498266Sopenharmony_ci	    case " $sys_lib_dlsearch_path " in
838213498266Sopenharmony_ci	    *" $absdir "*) ;;
838313498266Sopenharmony_ci	    *)
838413498266Sopenharmony_ci	      case "$compile_rpath " in
838513498266Sopenharmony_ci	      *" $absdir "*) ;;
838613498266Sopenharmony_ci	      *) func_append compile_rpath " $absdir" ;;
838713498266Sopenharmony_ci	      esac
838813498266Sopenharmony_ci	      ;;
838913498266Sopenharmony_ci	    esac
839013498266Sopenharmony_ci	    case " $sys_lib_dlsearch_path " in
839113498266Sopenharmony_ci	    *" $libdir "*) ;;
839213498266Sopenharmony_ci	    *)
839313498266Sopenharmony_ci	      case "$finalize_rpath " in
839413498266Sopenharmony_ci	      *" $libdir "*) ;;
839513498266Sopenharmony_ci	      *) func_append finalize_rpath " $libdir" ;;
839613498266Sopenharmony_ci	      esac
839713498266Sopenharmony_ci	      ;;
839813498266Sopenharmony_ci	    esac
839913498266Sopenharmony_ci	  fi # $linkmode,$pass = prog,link...
840013498266Sopenharmony_ci
840113498266Sopenharmony_ci	  if $alldeplibs &&
840213498266Sopenharmony_ci	     { test pass_all = "$deplibs_check_method" ||
840313498266Sopenharmony_ci	       { test yes = "$build_libtool_libs" &&
840413498266Sopenharmony_ci		 test -n "$library_names"; }; }; then
840513498266Sopenharmony_ci	    # We only need to search for static libraries
840613498266Sopenharmony_ci	    continue
840713498266Sopenharmony_ci	  fi
840813498266Sopenharmony_ci	fi
840913498266Sopenharmony_ci
841013498266Sopenharmony_ci	link_static=no # Whether the deplib will be linked statically
841113498266Sopenharmony_ci	use_static_libs=$prefer_static_libs
841213498266Sopenharmony_ci	if test built = "$use_static_libs" && test yes = "$installed"; then
841313498266Sopenharmony_ci	  use_static_libs=no
841413498266Sopenharmony_ci	fi
841513498266Sopenharmony_ci	if test -n "$library_names" &&
841613498266Sopenharmony_ci	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
841713498266Sopenharmony_ci	  case $host in
841813498266Sopenharmony_ci	  *cygwin* | *mingw* | *cegcc* | *os2*)
841913498266Sopenharmony_ci	      # No point in relinking DLLs because paths are not encoded
842013498266Sopenharmony_ci	      func_append notinst_deplibs " $lib"
842113498266Sopenharmony_ci	      need_relink=no
842213498266Sopenharmony_ci	    ;;
842313498266Sopenharmony_ci	  *)
842413498266Sopenharmony_ci	    if test no = "$installed"; then
842513498266Sopenharmony_ci	      func_append notinst_deplibs " $lib"
842613498266Sopenharmony_ci	      need_relink=yes
842713498266Sopenharmony_ci	    fi
842813498266Sopenharmony_ci	    ;;
842913498266Sopenharmony_ci	  esac
843013498266Sopenharmony_ci	  # This is a shared library
843113498266Sopenharmony_ci
843213498266Sopenharmony_ci	  # Warn about portability, can't link against -module's on some
843313498266Sopenharmony_ci	  # systems (darwin).  Don't bleat about dlopened modules though!
843413498266Sopenharmony_ci	  dlopenmodule=
843513498266Sopenharmony_ci	  for dlpremoduletest in $dlprefiles; do
843613498266Sopenharmony_ci	    if test "X$dlpremoduletest" = "X$lib"; then
843713498266Sopenharmony_ci	      dlopenmodule=$dlpremoduletest
843813498266Sopenharmony_ci	      break
843913498266Sopenharmony_ci	    fi
844013498266Sopenharmony_ci	  done
844113498266Sopenharmony_ci	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
844213498266Sopenharmony_ci	    echo
844313498266Sopenharmony_ci	    if test prog = "$linkmode"; then
844413498266Sopenharmony_ci	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
844513498266Sopenharmony_ci	    else
844613498266Sopenharmony_ci	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
844713498266Sopenharmony_ci	    fi
844813498266Sopenharmony_ci	    $ECHO "*** $linklib is not portable!"
844913498266Sopenharmony_ci	  fi
845013498266Sopenharmony_ci	  if test lib = "$linkmode" &&
845113498266Sopenharmony_ci	     test yes = "$hardcode_into_libs"; then
845213498266Sopenharmony_ci	    # Hardcode the library path.
845313498266Sopenharmony_ci	    # Skip directories that are in the system default run-time
845413498266Sopenharmony_ci	    # search path.
845513498266Sopenharmony_ci	    case " $sys_lib_dlsearch_path " in
845613498266Sopenharmony_ci	    *" $absdir "*) ;;
845713498266Sopenharmony_ci	    *)
845813498266Sopenharmony_ci	      case "$compile_rpath " in
845913498266Sopenharmony_ci	      *" $absdir "*) ;;
846013498266Sopenharmony_ci	      *) func_append compile_rpath " $absdir" ;;
846113498266Sopenharmony_ci	      esac
846213498266Sopenharmony_ci	      ;;
846313498266Sopenharmony_ci	    esac
846413498266Sopenharmony_ci	    case " $sys_lib_dlsearch_path " in
846513498266Sopenharmony_ci	    *" $libdir "*) ;;
846613498266Sopenharmony_ci	    *)
846713498266Sopenharmony_ci	      case "$finalize_rpath " in
846813498266Sopenharmony_ci	      *" $libdir "*) ;;
846913498266Sopenharmony_ci	      *) func_append finalize_rpath " $libdir" ;;
847013498266Sopenharmony_ci	      esac
847113498266Sopenharmony_ci	      ;;
847213498266Sopenharmony_ci	    esac
847313498266Sopenharmony_ci	  fi
847413498266Sopenharmony_ci
847513498266Sopenharmony_ci	  if test -n "$old_archive_from_expsyms_cmds"; then
847613498266Sopenharmony_ci	    # figure out the soname
847713498266Sopenharmony_ci	    set dummy $library_names
847813498266Sopenharmony_ci	    shift
847913498266Sopenharmony_ci	    realname=$1
848013498266Sopenharmony_ci	    shift
848113498266Sopenharmony_ci	    libname=`eval "\\$ECHO \"$libname_spec\""`
848213498266Sopenharmony_ci	    # use dlname if we got it. it's perfectly good, no?
848313498266Sopenharmony_ci	    if test -n "$dlname"; then
848413498266Sopenharmony_ci	      soname=$dlname
848513498266Sopenharmony_ci	    elif test -n "$soname_spec"; then
848613498266Sopenharmony_ci	      # bleh windows
848713498266Sopenharmony_ci	      case $host in
848813498266Sopenharmony_ci	      *cygwin* | mingw* | *cegcc* | *os2*)
848913498266Sopenharmony_ci	        func_arith $current - $age
849013498266Sopenharmony_ci		major=$func_arith_result
849113498266Sopenharmony_ci		versuffix=-$major
849213498266Sopenharmony_ci		;;
849313498266Sopenharmony_ci	      esac
849413498266Sopenharmony_ci	      eval soname=\"$soname_spec\"
849513498266Sopenharmony_ci	    else
849613498266Sopenharmony_ci	      soname=$realname
849713498266Sopenharmony_ci	    fi
849813498266Sopenharmony_ci
849913498266Sopenharmony_ci	    # Make a new name for the extract_expsyms_cmds to use
850013498266Sopenharmony_ci	    soroot=$soname
850113498266Sopenharmony_ci	    func_basename "$soroot"
850213498266Sopenharmony_ci	    soname=$func_basename_result
850313498266Sopenharmony_ci	    func_stripname 'lib' '.dll' "$soname"
850413498266Sopenharmony_ci	    newlib=libimp-$func_stripname_result.a
850513498266Sopenharmony_ci
850613498266Sopenharmony_ci	    # If the library has no export list, then create one now
850713498266Sopenharmony_ci	    if test -f "$output_objdir/$soname-def"; then :
850813498266Sopenharmony_ci	    else
850913498266Sopenharmony_ci	      func_verbose "extracting exported symbol list from '$soname'"
851013498266Sopenharmony_ci	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
851113498266Sopenharmony_ci	    fi
851213498266Sopenharmony_ci
851313498266Sopenharmony_ci	    # Create $newlib
851413498266Sopenharmony_ci	    if test -f "$output_objdir/$newlib"; then :; else
851513498266Sopenharmony_ci	      func_verbose "generating import library for '$soname'"
851613498266Sopenharmony_ci	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
851713498266Sopenharmony_ci	    fi
851813498266Sopenharmony_ci	    # make sure the library variables are pointing to the new library
851913498266Sopenharmony_ci	    dir=$output_objdir
852013498266Sopenharmony_ci	    linklib=$newlib
852113498266Sopenharmony_ci	  fi # test -n "$old_archive_from_expsyms_cmds"
852213498266Sopenharmony_ci
852313498266Sopenharmony_ci	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
852413498266Sopenharmony_ci	    add_shlibpath=
852513498266Sopenharmony_ci	    add_dir=
852613498266Sopenharmony_ci	    add=
852713498266Sopenharmony_ci	    lib_linked=yes
852813498266Sopenharmony_ci	    case $hardcode_action in
852913498266Sopenharmony_ci	    immediate | unsupported)
853013498266Sopenharmony_ci	      if test no = "$hardcode_direct"; then
853113498266Sopenharmony_ci		add=$dir/$linklib
853213498266Sopenharmony_ci		case $host in
853313498266Sopenharmony_ci		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
853413498266Sopenharmony_ci		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
853513498266Sopenharmony_ci		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
853613498266Sopenharmony_ci		    *-*-unixware7*) add_dir=-L$dir ;;
853713498266Sopenharmony_ci		  *-*-darwin* )
853813498266Sopenharmony_ci		    # if the lib is a (non-dlopened) module then we cannot
853913498266Sopenharmony_ci		    # link against it, someone is ignoring the earlier warnings
854013498266Sopenharmony_ci		    if /usr/bin/file -L $add 2> /dev/null |
854113498266Sopenharmony_ci			 $GREP ": [^:]* bundle" >/dev/null; then
854213498266Sopenharmony_ci		      if test "X$dlopenmodule" != "X$lib"; then
854313498266Sopenharmony_ci			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
854413498266Sopenharmony_ci			if test -z "$old_library"; then
854513498266Sopenharmony_ci			  echo
854613498266Sopenharmony_ci			  echo "*** And there doesn't seem to be a static archive available"
854713498266Sopenharmony_ci			  echo "*** The link will probably fail, sorry"
854813498266Sopenharmony_ci			else
854913498266Sopenharmony_ci			  add=$dir/$old_library
855013498266Sopenharmony_ci			fi
855113498266Sopenharmony_ci		      elif test -n "$old_library"; then
855213498266Sopenharmony_ci			add=$dir/$old_library
855313498266Sopenharmony_ci		      fi
855413498266Sopenharmony_ci		    fi
855513498266Sopenharmony_ci		esac
855613498266Sopenharmony_ci	      elif test no = "$hardcode_minus_L"; then
855713498266Sopenharmony_ci		case $host in
855813498266Sopenharmony_ci		*-*-sunos*) add_shlibpath=$dir ;;
855913498266Sopenharmony_ci		esac
856013498266Sopenharmony_ci		add_dir=-L$dir
856113498266Sopenharmony_ci		add=-l$name
856213498266Sopenharmony_ci	      elif test no = "$hardcode_shlibpath_var"; then
856313498266Sopenharmony_ci		add_shlibpath=$dir
856413498266Sopenharmony_ci		add=-l$name
856513498266Sopenharmony_ci	      else
856613498266Sopenharmony_ci		lib_linked=no
856713498266Sopenharmony_ci	      fi
856813498266Sopenharmony_ci	      ;;
856913498266Sopenharmony_ci	    relink)
857013498266Sopenharmony_ci	      if test yes = "$hardcode_direct" &&
857113498266Sopenharmony_ci	         test no = "$hardcode_direct_absolute"; then
857213498266Sopenharmony_ci		add=$dir/$linklib
857313498266Sopenharmony_ci	      elif test yes = "$hardcode_minus_L"; then
857413498266Sopenharmony_ci		add_dir=-L$absdir
857513498266Sopenharmony_ci		# Try looking first in the location we're being installed to.
857613498266Sopenharmony_ci		if test -n "$inst_prefix_dir"; then
857713498266Sopenharmony_ci		  case $libdir in
857813498266Sopenharmony_ci		    [\\/]*)
857913498266Sopenharmony_ci		      func_append add_dir " -L$inst_prefix_dir$libdir"
858013498266Sopenharmony_ci		      ;;
858113498266Sopenharmony_ci		  esac
858213498266Sopenharmony_ci		fi
858313498266Sopenharmony_ci		add=-l$name
858413498266Sopenharmony_ci	      elif test yes = "$hardcode_shlibpath_var"; then
858513498266Sopenharmony_ci		add_shlibpath=$dir
858613498266Sopenharmony_ci		add=-l$name
858713498266Sopenharmony_ci	      else
858813498266Sopenharmony_ci		lib_linked=no
858913498266Sopenharmony_ci	      fi
859013498266Sopenharmony_ci	      ;;
859113498266Sopenharmony_ci	    *) lib_linked=no ;;
859213498266Sopenharmony_ci	    esac
859313498266Sopenharmony_ci
859413498266Sopenharmony_ci	    if test yes != "$lib_linked"; then
859513498266Sopenharmony_ci	      func_fatal_configuration "unsupported hardcode properties"
859613498266Sopenharmony_ci	    fi
859713498266Sopenharmony_ci
859813498266Sopenharmony_ci	    if test -n "$add_shlibpath"; then
859913498266Sopenharmony_ci	      case :$compile_shlibpath: in
860013498266Sopenharmony_ci	      *":$add_shlibpath:"*) ;;
860113498266Sopenharmony_ci	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
860213498266Sopenharmony_ci	      esac
860313498266Sopenharmony_ci	    fi
860413498266Sopenharmony_ci	    if test prog = "$linkmode"; then
860513498266Sopenharmony_ci	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
860613498266Sopenharmony_ci	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
860713498266Sopenharmony_ci	    else
860813498266Sopenharmony_ci	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
860913498266Sopenharmony_ci	      test -n "$add" && deplibs="$add $deplibs"
861013498266Sopenharmony_ci	      if test yes != "$hardcode_direct" &&
861113498266Sopenharmony_ci		 test yes != "$hardcode_minus_L" &&
861213498266Sopenharmony_ci		 test yes = "$hardcode_shlibpath_var"; then
861313498266Sopenharmony_ci		case :$finalize_shlibpath: in
861413498266Sopenharmony_ci		*":$libdir:"*) ;;
861513498266Sopenharmony_ci		*) func_append finalize_shlibpath "$libdir:" ;;
861613498266Sopenharmony_ci		esac
861713498266Sopenharmony_ci	      fi
861813498266Sopenharmony_ci	    fi
861913498266Sopenharmony_ci	  fi
862013498266Sopenharmony_ci
862113498266Sopenharmony_ci	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
862213498266Sopenharmony_ci	    add_shlibpath=
862313498266Sopenharmony_ci	    add_dir=
862413498266Sopenharmony_ci	    add=
862513498266Sopenharmony_ci	    # Finalize command for both is simple: just hardcode it.
862613498266Sopenharmony_ci	    if test yes = "$hardcode_direct" &&
862713498266Sopenharmony_ci	       test no = "$hardcode_direct_absolute"; then
862813498266Sopenharmony_ci	      add=$libdir/$linklib
862913498266Sopenharmony_ci	    elif test yes = "$hardcode_minus_L"; then
863013498266Sopenharmony_ci	      add_dir=-L$libdir
863113498266Sopenharmony_ci	      add=-l$name
863213498266Sopenharmony_ci	    elif test yes = "$hardcode_shlibpath_var"; then
863313498266Sopenharmony_ci	      case :$finalize_shlibpath: in
863413498266Sopenharmony_ci	      *":$libdir:"*) ;;
863513498266Sopenharmony_ci	      *) func_append finalize_shlibpath "$libdir:" ;;
863613498266Sopenharmony_ci	      esac
863713498266Sopenharmony_ci	      add=-l$name
863813498266Sopenharmony_ci	    elif test yes = "$hardcode_automatic"; then
863913498266Sopenharmony_ci	      if test -n "$inst_prefix_dir" &&
864013498266Sopenharmony_ci		 test -f "$inst_prefix_dir$libdir/$linklib"; then
864113498266Sopenharmony_ci		add=$inst_prefix_dir$libdir/$linklib
864213498266Sopenharmony_ci	      else
864313498266Sopenharmony_ci		add=$libdir/$linklib
864413498266Sopenharmony_ci	      fi
864513498266Sopenharmony_ci	    else
864613498266Sopenharmony_ci	      # We cannot seem to hardcode it, guess we'll fake it.
864713498266Sopenharmony_ci	      add_dir=-L$libdir
864813498266Sopenharmony_ci	      # Try looking first in the location we're being installed to.
864913498266Sopenharmony_ci	      if test -n "$inst_prefix_dir"; then
865013498266Sopenharmony_ci		case $libdir in
865113498266Sopenharmony_ci		  [\\/]*)
865213498266Sopenharmony_ci		    func_append add_dir " -L$inst_prefix_dir$libdir"
865313498266Sopenharmony_ci		    ;;
865413498266Sopenharmony_ci		esac
865513498266Sopenharmony_ci	      fi
865613498266Sopenharmony_ci	      add=-l$name
865713498266Sopenharmony_ci	    fi
865813498266Sopenharmony_ci
865913498266Sopenharmony_ci	    if test prog = "$linkmode"; then
866013498266Sopenharmony_ci	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
866113498266Sopenharmony_ci	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
866213498266Sopenharmony_ci	    else
866313498266Sopenharmony_ci	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
866413498266Sopenharmony_ci	      test -n "$add" && deplibs="$add $deplibs"
866513498266Sopenharmony_ci	    fi
866613498266Sopenharmony_ci	  fi
866713498266Sopenharmony_ci	elif test prog = "$linkmode"; then
866813498266Sopenharmony_ci	  # Here we assume that one of hardcode_direct or hardcode_minus_L
866913498266Sopenharmony_ci	  # is not unsupported.  This is valid on all known static and
867013498266Sopenharmony_ci	  # shared platforms.
867113498266Sopenharmony_ci	  if test unsupported != "$hardcode_direct"; then
867213498266Sopenharmony_ci	    test -n "$old_library" && linklib=$old_library
867313498266Sopenharmony_ci	    compile_deplibs="$dir/$linklib $compile_deplibs"
867413498266Sopenharmony_ci	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
867513498266Sopenharmony_ci	  else
867613498266Sopenharmony_ci	    compile_deplibs="-l$name -L$dir $compile_deplibs"
867713498266Sopenharmony_ci	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
867813498266Sopenharmony_ci	  fi
867913498266Sopenharmony_ci	elif test yes = "$build_libtool_libs"; then
868013498266Sopenharmony_ci	  # Not a shared library
868113498266Sopenharmony_ci	  if test pass_all != "$deplibs_check_method"; then
868213498266Sopenharmony_ci	    # We're trying link a shared library against a static one
868313498266Sopenharmony_ci	    # but the system doesn't support it.
868413498266Sopenharmony_ci
868513498266Sopenharmony_ci	    # Just print a warning and add the library to dependency_libs so
868613498266Sopenharmony_ci	    # that the program can be linked against the static library.
868713498266Sopenharmony_ci	    echo
868813498266Sopenharmony_ci	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
868913498266Sopenharmony_ci	    echo "*** I have the capability to make that library automatically link in when"
869013498266Sopenharmony_ci	    echo "*** you link to this library.  But I can only do this if you have a"
869113498266Sopenharmony_ci	    echo "*** shared version of the library, which you do not appear to have."
869213498266Sopenharmony_ci	    if test yes = "$module"; then
869313498266Sopenharmony_ci	      echo "*** But as you try to build a module library, libtool will still create "
869413498266Sopenharmony_ci	      echo "*** a static module, that should work as long as the dlopening application"
869513498266Sopenharmony_ci	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
869613498266Sopenharmony_ci	      if test -z "$global_symbol_pipe"; then
869713498266Sopenharmony_ci		echo
869813498266Sopenharmony_ci		echo "*** However, this would only work if libtool was able to extract symbol"
869913498266Sopenharmony_ci		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
870013498266Sopenharmony_ci		echo "*** not find such a program.  So, this module is probably useless."
870113498266Sopenharmony_ci		echo "*** 'nm' from GNU binutils and a full rebuild may help."
870213498266Sopenharmony_ci	      fi
870313498266Sopenharmony_ci	      if test no = "$build_old_libs"; then
870413498266Sopenharmony_ci		build_libtool_libs=module
870513498266Sopenharmony_ci		build_old_libs=yes
870613498266Sopenharmony_ci	      else
870713498266Sopenharmony_ci		build_libtool_libs=no
870813498266Sopenharmony_ci	      fi
870913498266Sopenharmony_ci	    fi
871013498266Sopenharmony_ci	  else
871113498266Sopenharmony_ci	    deplibs="$dir/$old_library $deplibs"
871213498266Sopenharmony_ci	    link_static=yes
871313498266Sopenharmony_ci	  fi
871413498266Sopenharmony_ci	fi # link shared/static library?
871513498266Sopenharmony_ci
871613498266Sopenharmony_ci	if test lib = "$linkmode"; then
871713498266Sopenharmony_ci	  if test -n "$dependency_libs" &&
871813498266Sopenharmony_ci	     { test yes != "$hardcode_into_libs" ||
871913498266Sopenharmony_ci	       test yes = "$build_old_libs" ||
872013498266Sopenharmony_ci	       test yes = "$link_static"; }; then
872113498266Sopenharmony_ci	    # Extract -R from dependency_libs
872213498266Sopenharmony_ci	    temp_deplibs=
872313498266Sopenharmony_ci	    for libdir in $dependency_libs; do
872413498266Sopenharmony_ci	      case $libdir in
872513498266Sopenharmony_ci	      -R*) func_stripname '-R' '' "$libdir"
872613498266Sopenharmony_ci	           temp_xrpath=$func_stripname_result
872713498266Sopenharmony_ci		   case " $xrpath " in
872813498266Sopenharmony_ci		   *" $temp_xrpath "*) ;;
872913498266Sopenharmony_ci		   *) func_append xrpath " $temp_xrpath";;
873013498266Sopenharmony_ci		   esac;;
873113498266Sopenharmony_ci	      *) func_append temp_deplibs " $libdir";;
873213498266Sopenharmony_ci	      esac
873313498266Sopenharmony_ci	    done
873413498266Sopenharmony_ci	    dependency_libs=$temp_deplibs
873513498266Sopenharmony_ci	  fi
873613498266Sopenharmony_ci
873713498266Sopenharmony_ci	  func_append newlib_search_path " $absdir"
873813498266Sopenharmony_ci	  # Link against this library
873913498266Sopenharmony_ci	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
874013498266Sopenharmony_ci	  # ... and its dependency_libs
874113498266Sopenharmony_ci	  tmp_libs=
874213498266Sopenharmony_ci	  for deplib in $dependency_libs; do
874313498266Sopenharmony_ci	    newdependency_libs="$deplib $newdependency_libs"
874413498266Sopenharmony_ci	    case $deplib in
874513498266Sopenharmony_ci              -L*) func_stripname '-L' '' "$deplib"
874613498266Sopenharmony_ci                   func_resolve_sysroot "$func_stripname_result";;
874713498266Sopenharmony_ci              *) func_resolve_sysroot "$deplib" ;;
874813498266Sopenharmony_ci            esac
874913498266Sopenharmony_ci	    if $opt_preserve_dup_deps; then
875013498266Sopenharmony_ci	      case "$tmp_libs " in
875113498266Sopenharmony_ci	      *" $func_resolve_sysroot_result "*)
875213498266Sopenharmony_ci                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
875313498266Sopenharmony_ci	      esac
875413498266Sopenharmony_ci	    fi
875513498266Sopenharmony_ci	    func_append tmp_libs " $func_resolve_sysroot_result"
875613498266Sopenharmony_ci	  done
875713498266Sopenharmony_ci
875813498266Sopenharmony_ci	  if test no != "$link_all_deplibs"; then
875913498266Sopenharmony_ci	    # Add the search paths of all dependency libraries
876013498266Sopenharmony_ci	    for deplib in $dependency_libs; do
876113498266Sopenharmony_ci	      path=
876213498266Sopenharmony_ci	      case $deplib in
876313498266Sopenharmony_ci	      -L*) path=$deplib ;;
876413498266Sopenharmony_ci	      *.la)
876513498266Sopenharmony_ci	        func_resolve_sysroot "$deplib"
876613498266Sopenharmony_ci	        deplib=$func_resolve_sysroot_result
876713498266Sopenharmony_ci	        func_dirname "$deplib" "" "."
876813498266Sopenharmony_ci		dir=$func_dirname_result
876913498266Sopenharmony_ci		# We need an absolute path.
877013498266Sopenharmony_ci		case $dir in
877113498266Sopenharmony_ci		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
877213498266Sopenharmony_ci		*)
877313498266Sopenharmony_ci		  absdir=`cd "$dir" && pwd`
877413498266Sopenharmony_ci		  if test -z "$absdir"; then
877513498266Sopenharmony_ci		    func_warning "cannot determine absolute directory name of '$dir'"
877613498266Sopenharmony_ci		    absdir=$dir
877713498266Sopenharmony_ci		  fi
877813498266Sopenharmony_ci		  ;;
877913498266Sopenharmony_ci		esac
878013498266Sopenharmony_ci		if $GREP "^installed=no" $deplib > /dev/null; then
878113498266Sopenharmony_ci		case $host in
878213498266Sopenharmony_ci		*-*-darwin*)
878313498266Sopenharmony_ci		  depdepl=
878413498266Sopenharmony_ci		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
878513498266Sopenharmony_ci		  if test -n "$deplibrary_names"; then
878613498266Sopenharmony_ci		    for tmp in $deplibrary_names; do
878713498266Sopenharmony_ci		      depdepl=$tmp
878813498266Sopenharmony_ci		    done
878913498266Sopenharmony_ci		    if test -f "$absdir/$objdir/$depdepl"; then
879013498266Sopenharmony_ci		      depdepl=$absdir/$objdir/$depdepl
879113498266Sopenharmony_ci		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
879213498266Sopenharmony_ci                      if test -z "$darwin_install_name"; then
879313498266Sopenharmony_ci                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
879413498266Sopenharmony_ci                      fi
879513498266Sopenharmony_ci		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
879613498266Sopenharmony_ci		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
879713498266Sopenharmony_ci		      path=
879813498266Sopenharmony_ci		    fi
879913498266Sopenharmony_ci		  fi
880013498266Sopenharmony_ci		  ;;
880113498266Sopenharmony_ci		*)
880213498266Sopenharmony_ci		  path=-L$absdir/$objdir
880313498266Sopenharmony_ci		  ;;
880413498266Sopenharmony_ci		esac
880513498266Sopenharmony_ci		else
880613498266Sopenharmony_ci		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
880713498266Sopenharmony_ci		  test -z "$libdir" && \
880813498266Sopenharmony_ci		    func_fatal_error "'$deplib' is not a valid libtool archive"
880913498266Sopenharmony_ci		  test "$absdir" != "$libdir" && \
881013498266Sopenharmony_ci		    func_warning "'$deplib' seems to be moved"
881113498266Sopenharmony_ci
881213498266Sopenharmony_ci		  path=-L$absdir
881313498266Sopenharmony_ci		fi
881413498266Sopenharmony_ci		;;
881513498266Sopenharmony_ci	      esac
881613498266Sopenharmony_ci	      case " $deplibs " in
881713498266Sopenharmony_ci	      *" $path "*) ;;
881813498266Sopenharmony_ci	      *) deplibs="$path $deplibs" ;;
881913498266Sopenharmony_ci	      esac
882013498266Sopenharmony_ci	    done
882113498266Sopenharmony_ci	  fi # link_all_deplibs != no
882213498266Sopenharmony_ci	fi # linkmode = lib
882313498266Sopenharmony_ci      done # for deplib in $libs
882413498266Sopenharmony_ci      if test link = "$pass"; then
882513498266Sopenharmony_ci	if test prog = "$linkmode"; then
882613498266Sopenharmony_ci	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
882713498266Sopenharmony_ci	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
882813498266Sopenharmony_ci	else
882913498266Sopenharmony_ci	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
883013498266Sopenharmony_ci	fi
883113498266Sopenharmony_ci      fi
883213498266Sopenharmony_ci      dependency_libs=$newdependency_libs
883313498266Sopenharmony_ci      if test dlpreopen = "$pass"; then
883413498266Sopenharmony_ci	# Link the dlpreopened libraries before other libraries
883513498266Sopenharmony_ci	for deplib in $save_deplibs; do
883613498266Sopenharmony_ci	  deplibs="$deplib $deplibs"
883713498266Sopenharmony_ci	done
883813498266Sopenharmony_ci      fi
883913498266Sopenharmony_ci      if test dlopen != "$pass"; then
884013498266Sopenharmony_ci	test conv = "$pass" || {
884113498266Sopenharmony_ci	  # Make sure lib_search_path contains only unique directories.
884213498266Sopenharmony_ci	  lib_search_path=
884313498266Sopenharmony_ci	  for dir in $newlib_search_path; do
884413498266Sopenharmony_ci	    case "$lib_search_path " in
884513498266Sopenharmony_ci	    *" $dir "*) ;;
884613498266Sopenharmony_ci	    *) func_append lib_search_path " $dir" ;;
884713498266Sopenharmony_ci	    esac
884813498266Sopenharmony_ci	  done
884913498266Sopenharmony_ci	  newlib_search_path=
885013498266Sopenharmony_ci	}
885113498266Sopenharmony_ci
885213498266Sopenharmony_ci	if test prog,link = "$linkmode,$pass"; then
885313498266Sopenharmony_ci	  vars="compile_deplibs finalize_deplibs"
885413498266Sopenharmony_ci	else
885513498266Sopenharmony_ci	  vars=deplibs
885613498266Sopenharmony_ci	fi
885713498266Sopenharmony_ci	for var in $vars dependency_libs; do
885813498266Sopenharmony_ci	  # Add libraries to $var in reverse order
885913498266Sopenharmony_ci	  eval tmp_libs=\"\$$var\"
886013498266Sopenharmony_ci	  new_libs=
886113498266Sopenharmony_ci	  for deplib in $tmp_libs; do
886213498266Sopenharmony_ci	    # FIXME: Pedantically, this is the right thing to do, so
886313498266Sopenharmony_ci	    #        that some nasty dependency loop isn't accidentally
886413498266Sopenharmony_ci	    #        broken:
886513498266Sopenharmony_ci	    #new_libs="$deplib $new_libs"
886613498266Sopenharmony_ci	    # Pragmatically, this seems to cause very few problems in
886713498266Sopenharmony_ci	    # practice:
886813498266Sopenharmony_ci	    case $deplib in
886913498266Sopenharmony_ci	    -L*) new_libs="$deplib $new_libs" ;;
887013498266Sopenharmony_ci	    -R*) ;;
887113498266Sopenharmony_ci	    *)
887213498266Sopenharmony_ci	      # And here is the reason: when a library appears more
887313498266Sopenharmony_ci	      # than once as an explicit dependence of a library, or
887413498266Sopenharmony_ci	      # is implicitly linked in more than once by the
887513498266Sopenharmony_ci	      # compiler, it is considered special, and multiple
887613498266Sopenharmony_ci	      # occurrences thereof are not removed.  Compare this
887713498266Sopenharmony_ci	      # with having the same library being listed as a
887813498266Sopenharmony_ci	      # dependency of multiple other libraries: in this case,
887913498266Sopenharmony_ci	      # we know (pedantically, we assume) the library does not
888013498266Sopenharmony_ci	      # need to be listed more than once, so we keep only the
888113498266Sopenharmony_ci	      # last copy.  This is not always right, but it is rare
888213498266Sopenharmony_ci	      # enough that we require users that really mean to play
888313498266Sopenharmony_ci	      # such unportable linking tricks to link the library
888413498266Sopenharmony_ci	      # using -Wl,-lname, so that libtool does not consider it
888513498266Sopenharmony_ci	      # for duplicate removal.
888613498266Sopenharmony_ci	      case " $specialdeplibs " in
888713498266Sopenharmony_ci	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
888813498266Sopenharmony_ci	      *)
888913498266Sopenharmony_ci		case " $new_libs " in
889013498266Sopenharmony_ci		*" $deplib "*) ;;
889113498266Sopenharmony_ci		*) new_libs="$deplib $new_libs" ;;
889213498266Sopenharmony_ci		esac
889313498266Sopenharmony_ci		;;
889413498266Sopenharmony_ci	      esac
889513498266Sopenharmony_ci	      ;;
889613498266Sopenharmony_ci	    esac
889713498266Sopenharmony_ci	  done
889813498266Sopenharmony_ci	  tmp_libs=
889913498266Sopenharmony_ci	  for deplib in $new_libs; do
890013498266Sopenharmony_ci	    case $deplib in
890113498266Sopenharmony_ci	    -L*)
890213498266Sopenharmony_ci	      case " $tmp_libs " in
890313498266Sopenharmony_ci	      *" $deplib "*) ;;
890413498266Sopenharmony_ci	      *) func_append tmp_libs " $deplib" ;;
890513498266Sopenharmony_ci	      esac
890613498266Sopenharmony_ci	      ;;
890713498266Sopenharmony_ci	    *) func_append tmp_libs " $deplib" ;;
890813498266Sopenharmony_ci	    esac
890913498266Sopenharmony_ci	  done
891013498266Sopenharmony_ci	  eval $var=\"$tmp_libs\"
891113498266Sopenharmony_ci	done # for var
891213498266Sopenharmony_ci      fi
891313498266Sopenharmony_ci
891413498266Sopenharmony_ci      # Add Sun CC postdeps if required:
891513498266Sopenharmony_ci      test CXX = "$tagname" && {
891613498266Sopenharmony_ci        case $host_os in
891713498266Sopenharmony_ci        linux*)
891813498266Sopenharmony_ci          case `$CC -V 2>&1 | $SED 5q` in
891913498266Sopenharmony_ci          *Sun\ C*) # Sun C++ 5.9
892013498266Sopenharmony_ci            func_suncc_cstd_abi
892113498266Sopenharmony_ci
892213498266Sopenharmony_ci            if test no != "$suncc_use_cstd_abi"; then
892313498266Sopenharmony_ci              func_append postdeps ' -library=Cstd -library=Crun'
892413498266Sopenharmony_ci            fi
892513498266Sopenharmony_ci            ;;
892613498266Sopenharmony_ci          esac
892713498266Sopenharmony_ci          ;;
892813498266Sopenharmony_ci
892913498266Sopenharmony_ci        solaris*)
893013498266Sopenharmony_ci          func_cc_basename "$CC"
893113498266Sopenharmony_ci          case $func_cc_basename_result in
893213498266Sopenharmony_ci          CC* | sunCC*)
893313498266Sopenharmony_ci            func_suncc_cstd_abi
893413498266Sopenharmony_ci
893513498266Sopenharmony_ci            if test no != "$suncc_use_cstd_abi"; then
893613498266Sopenharmony_ci              func_append postdeps ' -library=Cstd -library=Crun'
893713498266Sopenharmony_ci            fi
893813498266Sopenharmony_ci            ;;
893913498266Sopenharmony_ci          esac
894013498266Sopenharmony_ci          ;;
894113498266Sopenharmony_ci        esac
894213498266Sopenharmony_ci      }
894313498266Sopenharmony_ci
894413498266Sopenharmony_ci      # Last step: remove runtime libs from dependency_libs
894513498266Sopenharmony_ci      # (they stay in deplibs)
894613498266Sopenharmony_ci      tmp_libs=
894713498266Sopenharmony_ci      for i in $dependency_libs; do
894813498266Sopenharmony_ci	case " $predeps $postdeps $compiler_lib_search_path " in
894913498266Sopenharmony_ci	*" $i "*)
895013498266Sopenharmony_ci	  i=
895113498266Sopenharmony_ci	  ;;
895213498266Sopenharmony_ci	esac
895313498266Sopenharmony_ci	if test -n "$i"; then
895413498266Sopenharmony_ci	  func_append tmp_libs " $i"
895513498266Sopenharmony_ci	fi
895613498266Sopenharmony_ci      done
895713498266Sopenharmony_ci      dependency_libs=$tmp_libs
895813498266Sopenharmony_ci    done # for pass
895913498266Sopenharmony_ci    if test prog = "$linkmode"; then
896013498266Sopenharmony_ci      dlfiles=$newdlfiles
896113498266Sopenharmony_ci    fi
896213498266Sopenharmony_ci    if test prog = "$linkmode" || test lib = "$linkmode"; then
896313498266Sopenharmony_ci      dlprefiles=$newdlprefiles
896413498266Sopenharmony_ci    fi
896513498266Sopenharmony_ci
896613498266Sopenharmony_ci    case $linkmode in
896713498266Sopenharmony_ci    oldlib)
896813498266Sopenharmony_ci      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
896913498266Sopenharmony_ci	func_warning "'-dlopen' is ignored for archives"
897013498266Sopenharmony_ci      fi
897113498266Sopenharmony_ci
897213498266Sopenharmony_ci      case " $deplibs" in
897313498266Sopenharmony_ci      *\ -l* | *\ -L*)
897413498266Sopenharmony_ci	func_warning "'-l' and '-L' are ignored for archives" ;;
897513498266Sopenharmony_ci      esac
897613498266Sopenharmony_ci
897713498266Sopenharmony_ci      test -n "$rpath" && \
897813498266Sopenharmony_ci	func_warning "'-rpath' is ignored for archives"
897913498266Sopenharmony_ci
898013498266Sopenharmony_ci      test -n "$xrpath" && \
898113498266Sopenharmony_ci	func_warning "'-R' is ignored for archives"
898213498266Sopenharmony_ci
898313498266Sopenharmony_ci      test -n "$vinfo" && \
898413498266Sopenharmony_ci	func_warning "'-version-info/-version-number' is ignored for archives"
898513498266Sopenharmony_ci
898613498266Sopenharmony_ci      test -n "$release" && \
898713498266Sopenharmony_ci	func_warning "'-release' is ignored for archives"
898813498266Sopenharmony_ci
898913498266Sopenharmony_ci      test -n "$export_symbols$export_symbols_regex" && \
899013498266Sopenharmony_ci	func_warning "'-export-symbols' is ignored for archives"
899113498266Sopenharmony_ci
899213498266Sopenharmony_ci      # Now set the variables for building old libraries.
899313498266Sopenharmony_ci      build_libtool_libs=no
899413498266Sopenharmony_ci      oldlibs=$output
899513498266Sopenharmony_ci      func_append objs "$old_deplibs"
899613498266Sopenharmony_ci      ;;
899713498266Sopenharmony_ci
899813498266Sopenharmony_ci    lib)
899913498266Sopenharmony_ci      # Make sure we only generate libraries of the form 'libNAME.la'.
900013498266Sopenharmony_ci      case $outputname in
900113498266Sopenharmony_ci      lib*)
900213498266Sopenharmony_ci	func_stripname 'lib' '.la' "$outputname"
900313498266Sopenharmony_ci	name=$func_stripname_result
900413498266Sopenharmony_ci	eval shared_ext=\"$shrext_cmds\"
900513498266Sopenharmony_ci	eval libname=\"$libname_spec\"
900613498266Sopenharmony_ci	;;
900713498266Sopenharmony_ci      *)
900813498266Sopenharmony_ci	test no = "$module" \
900913498266Sopenharmony_ci	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
901013498266Sopenharmony_ci
901113498266Sopenharmony_ci	if test no != "$need_lib_prefix"; then
901213498266Sopenharmony_ci	  # Add the "lib" prefix for modules if required
901313498266Sopenharmony_ci	  func_stripname '' '.la' "$outputname"
901413498266Sopenharmony_ci	  name=$func_stripname_result
901513498266Sopenharmony_ci	  eval shared_ext=\"$shrext_cmds\"
901613498266Sopenharmony_ci	  eval libname=\"$libname_spec\"
901713498266Sopenharmony_ci	else
901813498266Sopenharmony_ci	  func_stripname '' '.la' "$outputname"
901913498266Sopenharmony_ci	  libname=$func_stripname_result
902013498266Sopenharmony_ci	fi
902113498266Sopenharmony_ci	;;
902213498266Sopenharmony_ci      esac
902313498266Sopenharmony_ci
902413498266Sopenharmony_ci      if test -n "$objs"; then
902513498266Sopenharmony_ci	if test pass_all != "$deplibs_check_method"; then
902613498266Sopenharmony_ci	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
902713498266Sopenharmony_ci	else
902813498266Sopenharmony_ci	  echo
902913498266Sopenharmony_ci	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
903013498266Sopenharmony_ci	  $ECHO "*** objects $objs is not portable!"
903113498266Sopenharmony_ci	  func_append libobjs " $objs"
903213498266Sopenharmony_ci	fi
903313498266Sopenharmony_ci      fi
903413498266Sopenharmony_ci
903513498266Sopenharmony_ci      test no = "$dlself" \
903613498266Sopenharmony_ci	|| func_warning "'-dlopen self' is ignored for libtool libraries"
903713498266Sopenharmony_ci
903813498266Sopenharmony_ci      set dummy $rpath
903913498266Sopenharmony_ci      shift
904013498266Sopenharmony_ci      test 1 -lt "$#" \
904113498266Sopenharmony_ci	&& func_warning "ignoring multiple '-rpath's for a libtool library"
904213498266Sopenharmony_ci
904313498266Sopenharmony_ci      install_libdir=$1
904413498266Sopenharmony_ci
904513498266Sopenharmony_ci      oldlibs=
904613498266Sopenharmony_ci      if test -z "$rpath"; then
904713498266Sopenharmony_ci	if test yes = "$build_libtool_libs"; then
904813498266Sopenharmony_ci	  # Building a libtool convenience library.
904913498266Sopenharmony_ci	  # Some compilers have problems with a '.al' extension so
905013498266Sopenharmony_ci	  # convenience libraries should have the same extension an
905113498266Sopenharmony_ci	  # archive normally would.
905213498266Sopenharmony_ci	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
905313498266Sopenharmony_ci	  build_libtool_libs=convenience
905413498266Sopenharmony_ci	  build_old_libs=yes
905513498266Sopenharmony_ci	fi
905613498266Sopenharmony_ci
905713498266Sopenharmony_ci	test -n "$vinfo" && \
905813498266Sopenharmony_ci	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
905913498266Sopenharmony_ci
906013498266Sopenharmony_ci	test -n "$release" && \
906113498266Sopenharmony_ci	  func_warning "'-release' is ignored for convenience libraries"
906213498266Sopenharmony_ci      else
906313498266Sopenharmony_ci
906413498266Sopenharmony_ci	# Parse the version information argument.
906513498266Sopenharmony_ci	save_ifs=$IFS; IFS=:
906613498266Sopenharmony_ci	set dummy $vinfo 0 0 0
906713498266Sopenharmony_ci	shift
906813498266Sopenharmony_ci	IFS=$save_ifs
906913498266Sopenharmony_ci
907013498266Sopenharmony_ci	test -n "$7" && \
907113498266Sopenharmony_ci	  func_fatal_help "too many parameters to '-version-info'"
907213498266Sopenharmony_ci
907313498266Sopenharmony_ci	# convert absolute version numbers to libtool ages
907413498266Sopenharmony_ci	# this retains compatibility with .la files and attempts
907513498266Sopenharmony_ci	# to make the code below a bit more comprehensible
907613498266Sopenharmony_ci
907713498266Sopenharmony_ci	case $vinfo_number in
907813498266Sopenharmony_ci	yes)
907913498266Sopenharmony_ci	  number_major=$1
908013498266Sopenharmony_ci	  number_minor=$2
908113498266Sopenharmony_ci	  number_revision=$3
908213498266Sopenharmony_ci	  #
908313498266Sopenharmony_ci	  # There are really only two kinds -- those that
908413498266Sopenharmony_ci	  # use the current revision as the major version
908513498266Sopenharmony_ci	  # and those that subtract age and use age as
908613498266Sopenharmony_ci	  # a minor version.  But, then there is irix
908713498266Sopenharmony_ci	  # that has an extra 1 added just for fun
908813498266Sopenharmony_ci	  #
908913498266Sopenharmony_ci	  case $version_type in
909013498266Sopenharmony_ci	  # correct linux to gnu/linux during the next big refactor
909113498266Sopenharmony_ci	  darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none)
909213498266Sopenharmony_ci	    func_arith $number_major + $number_minor
909313498266Sopenharmony_ci	    current=$func_arith_result
909413498266Sopenharmony_ci	    age=$number_minor
909513498266Sopenharmony_ci	    revision=$number_revision
909613498266Sopenharmony_ci	    ;;
909713498266Sopenharmony_ci	  freebsd-aout|qnx|sunos)
909813498266Sopenharmony_ci	    current=$number_major
909913498266Sopenharmony_ci	    revision=$number_minor
910013498266Sopenharmony_ci	    age=0
910113498266Sopenharmony_ci	    ;;
910213498266Sopenharmony_ci	  irix|nonstopux)
910313498266Sopenharmony_ci	    func_arith $number_major + $number_minor
910413498266Sopenharmony_ci	    current=$func_arith_result
910513498266Sopenharmony_ci	    age=$number_minor
910613498266Sopenharmony_ci	    revision=$number_minor
910713498266Sopenharmony_ci	    lt_irix_increment=no
910813498266Sopenharmony_ci	    ;;
910913498266Sopenharmony_ci	  *)
911013498266Sopenharmony_ci	    func_fatal_configuration "$modename: unknown library version type '$version_type'"
911113498266Sopenharmony_ci	    ;;
911213498266Sopenharmony_ci	  esac
911313498266Sopenharmony_ci	  ;;
911413498266Sopenharmony_ci	no)
911513498266Sopenharmony_ci	  current=$1
911613498266Sopenharmony_ci	  revision=$2
911713498266Sopenharmony_ci	  age=$3
911813498266Sopenharmony_ci	  ;;
911913498266Sopenharmony_ci	esac
912013498266Sopenharmony_ci
912113498266Sopenharmony_ci	# Check that each of the things are valid numbers.
912213498266Sopenharmony_ci	case $current in
912313498266Sopenharmony_ci	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]) ;;
912413498266Sopenharmony_ci	*)
912513498266Sopenharmony_ci	  func_error "CURRENT '$current' must be a nonnegative integer"
912613498266Sopenharmony_ci	  func_fatal_error "'$vinfo' is not valid version information"
912713498266Sopenharmony_ci	  ;;
912813498266Sopenharmony_ci	esac
912913498266Sopenharmony_ci
913013498266Sopenharmony_ci	case $revision in
913113498266Sopenharmony_ci	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]) ;;
913213498266Sopenharmony_ci	*)
913313498266Sopenharmony_ci	  func_error "REVISION '$revision' must be a nonnegative integer"
913413498266Sopenharmony_ci	  func_fatal_error "'$vinfo' is not valid version information"
913513498266Sopenharmony_ci	  ;;
913613498266Sopenharmony_ci	esac
913713498266Sopenharmony_ci
913813498266Sopenharmony_ci	case $age in
913913498266Sopenharmony_ci	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]) ;;
914013498266Sopenharmony_ci	*)
914113498266Sopenharmony_ci	  func_error "AGE '$age' must be a nonnegative integer"
914213498266Sopenharmony_ci	  func_fatal_error "'$vinfo' is not valid version information"
914313498266Sopenharmony_ci	  ;;
914413498266Sopenharmony_ci	esac
914513498266Sopenharmony_ci
914613498266Sopenharmony_ci	if test "$age" -gt "$current"; then
914713498266Sopenharmony_ci	  func_error "AGE '$age' is greater than the current interface number '$current'"
914813498266Sopenharmony_ci	  func_fatal_error "'$vinfo' is not valid version information"
914913498266Sopenharmony_ci	fi
915013498266Sopenharmony_ci
915113498266Sopenharmony_ci	# Calculate the version variables.
915213498266Sopenharmony_ci	major=
915313498266Sopenharmony_ci	versuffix=
915413498266Sopenharmony_ci	verstring=
915513498266Sopenharmony_ci	case $version_type in
915613498266Sopenharmony_ci	none) ;;
915713498266Sopenharmony_ci
915813498266Sopenharmony_ci	darwin)
915913498266Sopenharmony_ci	  # Like Linux, but with the current version available in
916013498266Sopenharmony_ci	  # verstring for coding it into the library header
916113498266Sopenharmony_ci	  func_arith $current - $age
916213498266Sopenharmony_ci	  major=.$func_arith_result
916313498266Sopenharmony_ci	  versuffix=$major.$age.$revision
916413498266Sopenharmony_ci	  # Darwin ld doesn't like 0 for these options...
916513498266Sopenharmony_ci	  func_arith $current + 1
916613498266Sopenharmony_ci	  minor_current=$func_arith_result
916713498266Sopenharmony_ci	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
916813498266Sopenharmony_ci	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
916913498266Sopenharmony_ci          # On Darwin other compilers
917013498266Sopenharmony_ci          case $CC in
917113498266Sopenharmony_ci              nagfor*)
917213498266Sopenharmony_ci                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
917313498266Sopenharmony_ci                  ;;
917413498266Sopenharmony_ci              *)
917513498266Sopenharmony_ci                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
917613498266Sopenharmony_ci                  ;;
917713498266Sopenharmony_ci          esac
917813498266Sopenharmony_ci	  ;;
917913498266Sopenharmony_ci
918013498266Sopenharmony_ci	freebsd-aout)
918113498266Sopenharmony_ci	  major=.$current
918213498266Sopenharmony_ci	  versuffix=.$current.$revision
918313498266Sopenharmony_ci	  ;;
918413498266Sopenharmony_ci
918513498266Sopenharmony_ci	freebsd-elf | midnightbsd-elf)
918613498266Sopenharmony_ci	  func_arith $current - $age
918713498266Sopenharmony_ci	  major=.$func_arith_result
918813498266Sopenharmony_ci	  versuffix=$major.$age.$revision
918913498266Sopenharmony_ci	  ;;
919013498266Sopenharmony_ci
919113498266Sopenharmony_ci	irix | nonstopux)
919213498266Sopenharmony_ci	  if test no = "$lt_irix_increment"; then
919313498266Sopenharmony_ci	    func_arith $current - $age
919413498266Sopenharmony_ci	  else
919513498266Sopenharmony_ci	    func_arith $current - $age + 1
919613498266Sopenharmony_ci	  fi
919713498266Sopenharmony_ci	  major=$func_arith_result
919813498266Sopenharmony_ci
919913498266Sopenharmony_ci	  case $version_type in
920013498266Sopenharmony_ci	    nonstopux) verstring_prefix=nonstopux ;;
920113498266Sopenharmony_ci	    *)         verstring_prefix=sgi ;;
920213498266Sopenharmony_ci	  esac
920313498266Sopenharmony_ci	  verstring=$verstring_prefix$major.$revision
920413498266Sopenharmony_ci
920513498266Sopenharmony_ci	  # Add in all the interfaces that we are compatible with.
920613498266Sopenharmony_ci	  loop=$revision
920713498266Sopenharmony_ci	  while test 0 -ne "$loop"; do
920813498266Sopenharmony_ci	    func_arith $revision - $loop
920913498266Sopenharmony_ci	    iface=$func_arith_result
921013498266Sopenharmony_ci	    func_arith $loop - 1
921113498266Sopenharmony_ci	    loop=$func_arith_result
921213498266Sopenharmony_ci	    verstring=$verstring_prefix$major.$iface:$verstring
921313498266Sopenharmony_ci	  done
921413498266Sopenharmony_ci
921513498266Sopenharmony_ci	  # Before this point, $major must not contain '.'.
921613498266Sopenharmony_ci	  major=.$major
921713498266Sopenharmony_ci	  versuffix=$major.$revision
921813498266Sopenharmony_ci	  ;;
921913498266Sopenharmony_ci
922013498266Sopenharmony_ci	linux) # correct to gnu/linux during the next big refactor
922113498266Sopenharmony_ci	  func_arith $current - $age
922213498266Sopenharmony_ci	  major=.$func_arith_result
922313498266Sopenharmony_ci	  versuffix=$major.$age.$revision
922413498266Sopenharmony_ci	  ;;
922513498266Sopenharmony_ci
922613498266Sopenharmony_ci	osf)
922713498266Sopenharmony_ci	  func_arith $current - $age
922813498266Sopenharmony_ci	  major=.$func_arith_result
922913498266Sopenharmony_ci	  versuffix=.$current.$age.$revision
923013498266Sopenharmony_ci	  verstring=$current.$age.$revision
923113498266Sopenharmony_ci
923213498266Sopenharmony_ci	  # Add in all the interfaces that we are compatible with.
923313498266Sopenharmony_ci	  loop=$age
923413498266Sopenharmony_ci	  while test 0 -ne "$loop"; do
923513498266Sopenharmony_ci	    func_arith $current - $loop
923613498266Sopenharmony_ci	    iface=$func_arith_result
923713498266Sopenharmony_ci	    func_arith $loop - 1
923813498266Sopenharmony_ci	    loop=$func_arith_result
923913498266Sopenharmony_ci	    verstring=$verstring:$iface.0
924013498266Sopenharmony_ci	  done
924113498266Sopenharmony_ci
924213498266Sopenharmony_ci	  # Make executables depend on our current version.
924313498266Sopenharmony_ci	  func_append verstring ":$current.0"
924413498266Sopenharmony_ci	  ;;
924513498266Sopenharmony_ci
924613498266Sopenharmony_ci	qnx)
924713498266Sopenharmony_ci	  major=.$current
924813498266Sopenharmony_ci	  versuffix=.$current
924913498266Sopenharmony_ci	  ;;
925013498266Sopenharmony_ci
925113498266Sopenharmony_ci	sco)
925213498266Sopenharmony_ci	  major=.$current
925313498266Sopenharmony_ci	  versuffix=.$current
925413498266Sopenharmony_ci	  ;;
925513498266Sopenharmony_ci
925613498266Sopenharmony_ci	sunos)
925713498266Sopenharmony_ci	  major=.$current
925813498266Sopenharmony_ci	  versuffix=.$current.$revision
925913498266Sopenharmony_ci	  ;;
926013498266Sopenharmony_ci
926113498266Sopenharmony_ci	windows)
926213498266Sopenharmony_ci	  # Use '-' rather than '.', since we only want one
926313498266Sopenharmony_ci	  # extension on DOS 8.3 file systems.
926413498266Sopenharmony_ci	  func_arith $current - $age
926513498266Sopenharmony_ci	  major=$func_arith_result
926613498266Sopenharmony_ci	  versuffix=-$major
926713498266Sopenharmony_ci	  ;;
926813498266Sopenharmony_ci
926913498266Sopenharmony_ci	*)
927013498266Sopenharmony_ci	  func_fatal_configuration "unknown library version type '$version_type'"
927113498266Sopenharmony_ci	  ;;
927213498266Sopenharmony_ci	esac
927313498266Sopenharmony_ci
927413498266Sopenharmony_ci	# Clear the version info if we defaulted, and they specified a release.
927513498266Sopenharmony_ci	if test -z "$vinfo" && test -n "$release"; then
927613498266Sopenharmony_ci	  major=
927713498266Sopenharmony_ci	  case $version_type in
927813498266Sopenharmony_ci	  darwin)
927913498266Sopenharmony_ci	    # we can't check for "0.0" in archive_cmds due to quoting
928013498266Sopenharmony_ci	    # problems, so we reset it completely
928113498266Sopenharmony_ci	    verstring=
928213498266Sopenharmony_ci	    ;;
928313498266Sopenharmony_ci	  *)
928413498266Sopenharmony_ci	    verstring=0.0
928513498266Sopenharmony_ci	    ;;
928613498266Sopenharmony_ci	  esac
928713498266Sopenharmony_ci	  if test no = "$need_version"; then
928813498266Sopenharmony_ci	    versuffix=
928913498266Sopenharmony_ci	  else
929013498266Sopenharmony_ci	    versuffix=.0.0
929113498266Sopenharmony_ci	  fi
929213498266Sopenharmony_ci	fi
929313498266Sopenharmony_ci
929413498266Sopenharmony_ci	# Remove version info from name if versioning should be avoided
929513498266Sopenharmony_ci	if test yes,no = "$avoid_version,$need_version"; then
929613498266Sopenharmony_ci	  major=
929713498266Sopenharmony_ci	  versuffix=
929813498266Sopenharmony_ci	  verstring=
929913498266Sopenharmony_ci	fi
930013498266Sopenharmony_ci
930113498266Sopenharmony_ci	# Check to see if the archive will have undefined symbols.
930213498266Sopenharmony_ci	if test yes = "$allow_undefined"; then
930313498266Sopenharmony_ci	  if test unsupported = "$allow_undefined_flag"; then
930413498266Sopenharmony_ci	    if test yes = "$build_old_libs"; then
930513498266Sopenharmony_ci	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
930613498266Sopenharmony_ci	      build_libtool_libs=no
930713498266Sopenharmony_ci	    else
930813498266Sopenharmony_ci	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
930913498266Sopenharmony_ci	    fi
931013498266Sopenharmony_ci	  fi
931113498266Sopenharmony_ci	else
931213498266Sopenharmony_ci	  # Don't allow undefined symbols.
931313498266Sopenharmony_ci	  allow_undefined_flag=$no_undefined_flag
931413498266Sopenharmony_ci	fi
931513498266Sopenharmony_ci
931613498266Sopenharmony_ci      fi
931713498266Sopenharmony_ci
931813498266Sopenharmony_ci      func_generate_dlsyms "$libname" "$libname" :
931913498266Sopenharmony_ci      func_append libobjs " $symfileobj"
932013498266Sopenharmony_ci      test " " = "$libobjs" && libobjs=
932113498266Sopenharmony_ci
932213498266Sopenharmony_ci      if test relink != "$opt_mode"; then
932313498266Sopenharmony_ci	# Remove our outputs, but don't remove object files since they
932413498266Sopenharmony_ci	# may have been created when compiling PIC objects.
932513498266Sopenharmony_ci	removelist=
932613498266Sopenharmony_ci	tempremovelist=`$ECHO "$output_objdir/*"`
932713498266Sopenharmony_ci	for p in $tempremovelist; do
932813498266Sopenharmony_ci	  case $p in
932913498266Sopenharmony_ci	    *.$objext | *.gcno)
933013498266Sopenharmony_ci	       ;;
933113498266Sopenharmony_ci	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
933213498266Sopenharmony_ci	       if test -n "$precious_files_regex"; then
933313498266Sopenharmony_ci		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
933413498266Sopenharmony_ci		 then
933513498266Sopenharmony_ci		   continue
933613498266Sopenharmony_ci		 fi
933713498266Sopenharmony_ci	       fi
933813498266Sopenharmony_ci	       func_append removelist " $p"
933913498266Sopenharmony_ci	       ;;
934013498266Sopenharmony_ci	    *) ;;
934113498266Sopenharmony_ci	  esac
934213498266Sopenharmony_ci	done
934313498266Sopenharmony_ci	test -n "$removelist" && \
934413498266Sopenharmony_ci	  func_show_eval "${RM}r \$removelist"
934513498266Sopenharmony_ci      fi
934613498266Sopenharmony_ci
934713498266Sopenharmony_ci      # Now set the variables for building old libraries.
934813498266Sopenharmony_ci      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
934913498266Sopenharmony_ci	func_append oldlibs " $output_objdir/$libname.$libext"
935013498266Sopenharmony_ci
935113498266Sopenharmony_ci	# Transform .lo files to .o files.
935213498266Sopenharmony_ci	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
935313498266Sopenharmony_ci      fi
935413498266Sopenharmony_ci
935513498266Sopenharmony_ci      # Eliminate all temporary directories.
935613498266Sopenharmony_ci      #for path in $notinst_path; do
935713498266Sopenharmony_ci      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
935813498266Sopenharmony_ci      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
935913498266Sopenharmony_ci      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
936013498266Sopenharmony_ci      #done
936113498266Sopenharmony_ci
936213498266Sopenharmony_ci      if test -n "$xrpath"; then
936313498266Sopenharmony_ci	# If the user specified any rpath flags, then add them.
936413498266Sopenharmony_ci	temp_xrpath=
936513498266Sopenharmony_ci	for libdir in $xrpath; do
936613498266Sopenharmony_ci	  func_replace_sysroot "$libdir"
936713498266Sopenharmony_ci	  func_append temp_xrpath " -R$func_replace_sysroot_result"
936813498266Sopenharmony_ci	  case "$finalize_rpath " in
936913498266Sopenharmony_ci	  *" $libdir "*) ;;
937013498266Sopenharmony_ci	  *) func_append finalize_rpath " $libdir" ;;
937113498266Sopenharmony_ci	  esac
937213498266Sopenharmony_ci	done
937313498266Sopenharmony_ci	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
937413498266Sopenharmony_ci	  dependency_libs="$temp_xrpath $dependency_libs"
937513498266Sopenharmony_ci	fi
937613498266Sopenharmony_ci      fi
937713498266Sopenharmony_ci
937813498266Sopenharmony_ci      # Make sure dlfiles contains only unique files that won't be dlpreopened
937913498266Sopenharmony_ci      old_dlfiles=$dlfiles
938013498266Sopenharmony_ci      dlfiles=
938113498266Sopenharmony_ci      for lib in $old_dlfiles; do
938213498266Sopenharmony_ci	case " $dlprefiles $dlfiles " in
938313498266Sopenharmony_ci	*" $lib "*) ;;
938413498266Sopenharmony_ci	*) func_append dlfiles " $lib" ;;
938513498266Sopenharmony_ci	esac
938613498266Sopenharmony_ci      done
938713498266Sopenharmony_ci
938813498266Sopenharmony_ci      # Make sure dlprefiles contains only unique files
938913498266Sopenharmony_ci      old_dlprefiles=$dlprefiles
939013498266Sopenharmony_ci      dlprefiles=
939113498266Sopenharmony_ci      for lib in $old_dlprefiles; do
939213498266Sopenharmony_ci	case "$dlprefiles " in
939313498266Sopenharmony_ci	*" $lib "*) ;;
939413498266Sopenharmony_ci	*) func_append dlprefiles " $lib" ;;
939513498266Sopenharmony_ci	esac
939613498266Sopenharmony_ci      done
939713498266Sopenharmony_ci
939813498266Sopenharmony_ci      if test yes = "$build_libtool_libs"; then
939913498266Sopenharmony_ci	if test -n "$rpath"; then
940013498266Sopenharmony_ci	  case $host in
940113498266Sopenharmony_ci	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
940213498266Sopenharmony_ci	    # these systems don't actually have a c library (as such)!
940313498266Sopenharmony_ci	    ;;
940413498266Sopenharmony_ci	  *-*-rhapsody* | *-*-darwin1.[012])
940513498266Sopenharmony_ci	    # Rhapsody C library is in the System framework
940613498266Sopenharmony_ci	    func_append deplibs " System.ltframework"
940713498266Sopenharmony_ci	    ;;
940813498266Sopenharmony_ci	  *-*-netbsd*)
940913498266Sopenharmony_ci	    # Don't link with libc until the a.out ld.so is fixed.
941013498266Sopenharmony_ci	    ;;
941113498266Sopenharmony_ci	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*)
941213498266Sopenharmony_ci	    # Do not include libc due to us having libc/libc_r.
941313498266Sopenharmony_ci	    ;;
941413498266Sopenharmony_ci	  *-*-sco3.2v5* | *-*-sco5v6*)
941513498266Sopenharmony_ci	    # Causes problems with __ctype
941613498266Sopenharmony_ci	    ;;
941713498266Sopenharmony_ci	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
941813498266Sopenharmony_ci	    # Compiler inserts libc in the correct place for threads to work
941913498266Sopenharmony_ci	    ;;
942013498266Sopenharmony_ci	  *)
942113498266Sopenharmony_ci	    # Add libc to deplibs on all other systems if necessary.
942213498266Sopenharmony_ci	    if test yes = "$build_libtool_need_lc"; then
942313498266Sopenharmony_ci	      func_append deplibs " -lc"
942413498266Sopenharmony_ci	    fi
942513498266Sopenharmony_ci	    ;;
942613498266Sopenharmony_ci	  esac
942713498266Sopenharmony_ci	fi
942813498266Sopenharmony_ci
942913498266Sopenharmony_ci	# Transform deplibs into only deplibs that can be linked in shared.
943013498266Sopenharmony_ci	name_save=$name
943113498266Sopenharmony_ci	libname_save=$libname
943213498266Sopenharmony_ci	release_save=$release
943313498266Sopenharmony_ci	versuffix_save=$versuffix
943413498266Sopenharmony_ci	major_save=$major
943513498266Sopenharmony_ci	# I'm not sure if I'm treating the release correctly.  I think
943613498266Sopenharmony_ci	# release should show up in the -l (ie -lgmp5) so we don't want to
943713498266Sopenharmony_ci	# add it in twice.  Is that correct?
943813498266Sopenharmony_ci	release=
943913498266Sopenharmony_ci	versuffix=
944013498266Sopenharmony_ci	major=
944113498266Sopenharmony_ci	newdeplibs=
944213498266Sopenharmony_ci	droppeddeps=no
944313498266Sopenharmony_ci	case $deplibs_check_method in
944413498266Sopenharmony_ci	pass_all)
944513498266Sopenharmony_ci	  # Don't check for shared/static.  Everything works.
944613498266Sopenharmony_ci	  # This might be a little naive.  We might want to check
944713498266Sopenharmony_ci	  # whether the library exists or not.  But this is on
944813498266Sopenharmony_ci	  # osf3 & osf4 and I'm not really sure... Just
944913498266Sopenharmony_ci	  # implementing what was already the behavior.
945013498266Sopenharmony_ci	  newdeplibs=$deplibs
945113498266Sopenharmony_ci	  ;;
945213498266Sopenharmony_ci	test_compile)
945313498266Sopenharmony_ci	  # This code stresses the "libraries are programs" paradigm to its
945413498266Sopenharmony_ci	  # limits. Maybe even breaks it.  We compile a program, linking it
945513498266Sopenharmony_ci	  # against the deplibs as a proxy for the library.  Then we can check
945613498266Sopenharmony_ci	  # whether they linked in statically or dynamically with ldd.
945713498266Sopenharmony_ci	  $opt_dry_run || $RM conftest.c
945813498266Sopenharmony_ci	  cat > conftest.c <<EOF
945913498266Sopenharmony_ci	  int main() { return 0; }
946013498266Sopenharmony_ciEOF
946113498266Sopenharmony_ci	  $opt_dry_run || $RM conftest
946213498266Sopenharmony_ci	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
946313498266Sopenharmony_ci	    ldd_output=`ldd conftest`
946413498266Sopenharmony_ci	    for i in $deplibs; do
946513498266Sopenharmony_ci	      case $i in
946613498266Sopenharmony_ci	      -l*)
946713498266Sopenharmony_ci		func_stripname -l '' "$i"
946813498266Sopenharmony_ci		name=$func_stripname_result
946913498266Sopenharmony_ci		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
947013498266Sopenharmony_ci		  case " $predeps $postdeps " in
947113498266Sopenharmony_ci		  *" $i "*)
947213498266Sopenharmony_ci		    func_append newdeplibs " $i"
947313498266Sopenharmony_ci		    i=
947413498266Sopenharmony_ci		    ;;
947513498266Sopenharmony_ci		  esac
947613498266Sopenharmony_ci		fi
947713498266Sopenharmony_ci		if test -n "$i"; then
947813498266Sopenharmony_ci		  libname=`eval "\\$ECHO \"$libname_spec\""`
947913498266Sopenharmony_ci		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
948013498266Sopenharmony_ci		  set dummy $deplib_matches; shift
948113498266Sopenharmony_ci		  deplib_match=$1
948213498266Sopenharmony_ci		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
948313498266Sopenharmony_ci		    func_append newdeplibs " $i"
948413498266Sopenharmony_ci		  else
948513498266Sopenharmony_ci		    droppeddeps=yes
948613498266Sopenharmony_ci		    echo
948713498266Sopenharmony_ci		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
948813498266Sopenharmony_ci		    echo "*** I have the capability to make that library automatically link in when"
948913498266Sopenharmony_ci		    echo "*** you link to this library.  But I can only do this if you have a"
949013498266Sopenharmony_ci		    echo "*** shared version of the library, which I believe you do not have"
949113498266Sopenharmony_ci		    echo "*** because a test_compile did reveal that the linker did not use it for"
949213498266Sopenharmony_ci		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
949313498266Sopenharmony_ci		  fi
949413498266Sopenharmony_ci		fi
949513498266Sopenharmony_ci		;;
949613498266Sopenharmony_ci	      *)
949713498266Sopenharmony_ci		func_append newdeplibs " $i"
949813498266Sopenharmony_ci		;;
949913498266Sopenharmony_ci	      esac
950013498266Sopenharmony_ci	    done
950113498266Sopenharmony_ci	  else
950213498266Sopenharmony_ci	    # Error occurred in the first compile.  Let's try to salvage
950313498266Sopenharmony_ci	    # the situation: Compile a separate program for each library.
950413498266Sopenharmony_ci	    for i in $deplibs; do
950513498266Sopenharmony_ci	      case $i in
950613498266Sopenharmony_ci	      -l*)
950713498266Sopenharmony_ci		func_stripname -l '' "$i"
950813498266Sopenharmony_ci		name=$func_stripname_result
950913498266Sopenharmony_ci		$opt_dry_run || $RM conftest
951013498266Sopenharmony_ci		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
951113498266Sopenharmony_ci		  ldd_output=`ldd conftest`
951213498266Sopenharmony_ci		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
951313498266Sopenharmony_ci		    case " $predeps $postdeps " in
951413498266Sopenharmony_ci		    *" $i "*)
951513498266Sopenharmony_ci		      func_append newdeplibs " $i"
951613498266Sopenharmony_ci		      i=
951713498266Sopenharmony_ci		      ;;
951813498266Sopenharmony_ci		    esac
951913498266Sopenharmony_ci		  fi
952013498266Sopenharmony_ci		  if test -n "$i"; then
952113498266Sopenharmony_ci		    libname=`eval "\\$ECHO \"$libname_spec\""`
952213498266Sopenharmony_ci		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
952313498266Sopenharmony_ci		    set dummy $deplib_matches; shift
952413498266Sopenharmony_ci		    deplib_match=$1
952513498266Sopenharmony_ci		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
952613498266Sopenharmony_ci		      func_append newdeplibs " $i"
952713498266Sopenharmony_ci		    else
952813498266Sopenharmony_ci		      droppeddeps=yes
952913498266Sopenharmony_ci		      echo
953013498266Sopenharmony_ci		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
953113498266Sopenharmony_ci		      echo "*** I have the capability to make that library automatically link in when"
953213498266Sopenharmony_ci		      echo "*** you link to this library.  But I can only do this if you have a"
953313498266Sopenharmony_ci		      echo "*** shared version of the library, which you do not appear to have"
953413498266Sopenharmony_ci		      echo "*** because a test_compile did reveal that the linker did not use this one"
953513498266Sopenharmony_ci		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
953613498266Sopenharmony_ci		    fi
953713498266Sopenharmony_ci		  fi
953813498266Sopenharmony_ci		else
953913498266Sopenharmony_ci		  droppeddeps=yes
954013498266Sopenharmony_ci		  echo
954113498266Sopenharmony_ci		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
954213498266Sopenharmony_ci		  echo "*** make it link in!  You will probably need to install it or some"
954313498266Sopenharmony_ci		  echo "*** library that it depends on before this library will be fully"
954413498266Sopenharmony_ci		  echo "*** functional.  Installing it before continuing would be even better."
954513498266Sopenharmony_ci		fi
954613498266Sopenharmony_ci		;;
954713498266Sopenharmony_ci	      *)
954813498266Sopenharmony_ci		func_append newdeplibs " $i"
954913498266Sopenharmony_ci		;;
955013498266Sopenharmony_ci	      esac
955113498266Sopenharmony_ci	    done
955213498266Sopenharmony_ci	  fi
955313498266Sopenharmony_ci	  ;;
955413498266Sopenharmony_ci	file_magic*)
955513498266Sopenharmony_ci	  set dummy $deplibs_check_method; shift
955613498266Sopenharmony_ci	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
955713498266Sopenharmony_ci	  for a_deplib in $deplibs; do
955813498266Sopenharmony_ci	    case $a_deplib in
955913498266Sopenharmony_ci	    -l*)
956013498266Sopenharmony_ci	      func_stripname -l '' "$a_deplib"
956113498266Sopenharmony_ci	      name=$func_stripname_result
956213498266Sopenharmony_ci	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
956313498266Sopenharmony_ci		case " $predeps $postdeps " in
956413498266Sopenharmony_ci		*" $a_deplib "*)
956513498266Sopenharmony_ci		  func_append newdeplibs " $a_deplib"
956613498266Sopenharmony_ci		  a_deplib=
956713498266Sopenharmony_ci		  ;;
956813498266Sopenharmony_ci		esac
956913498266Sopenharmony_ci	      fi
957013498266Sopenharmony_ci	      if test -n "$a_deplib"; then
957113498266Sopenharmony_ci		libname=`eval "\\$ECHO \"$libname_spec\""`
957213498266Sopenharmony_ci		if test -n "$file_magic_glob"; then
957313498266Sopenharmony_ci		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
957413498266Sopenharmony_ci		else
957513498266Sopenharmony_ci		  libnameglob=$libname
957613498266Sopenharmony_ci		fi
957713498266Sopenharmony_ci		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
957813498266Sopenharmony_ci		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
957913498266Sopenharmony_ci		  if test yes = "$want_nocaseglob"; then
958013498266Sopenharmony_ci		    shopt -s nocaseglob
958113498266Sopenharmony_ci		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
958213498266Sopenharmony_ci		    $nocaseglob
958313498266Sopenharmony_ci		  else
958413498266Sopenharmony_ci		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
958513498266Sopenharmony_ci		  fi
958613498266Sopenharmony_ci		  for potent_lib in $potential_libs; do
958713498266Sopenharmony_ci		      # Follow soft links.
958813498266Sopenharmony_ci		      if ls -lLd "$potent_lib" 2>/dev/null |
958913498266Sopenharmony_ci			 $GREP " -> " >/dev/null; then
959013498266Sopenharmony_ci			continue
959113498266Sopenharmony_ci		      fi
959213498266Sopenharmony_ci		      # The statement above tries to avoid entering an
959313498266Sopenharmony_ci		      # endless loop below, in case of cyclic links.
959413498266Sopenharmony_ci		      # We might still enter an endless loop, since a link
959513498266Sopenharmony_ci		      # loop can be closed while we follow links,
959613498266Sopenharmony_ci		      # but so what?
959713498266Sopenharmony_ci		      potlib=$potent_lib
959813498266Sopenharmony_ci		      while test -h "$potlib" 2>/dev/null; do
959913498266Sopenharmony_ci			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
960013498266Sopenharmony_ci			case $potliblink in
960113498266Sopenharmony_ci			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
960213498266Sopenharmony_ci			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
960313498266Sopenharmony_ci			esac
960413498266Sopenharmony_ci		      done
960513498266Sopenharmony_ci		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
960613498266Sopenharmony_ci			 $SED -e 10q |
960713498266Sopenharmony_ci			 $EGREP "$file_magic_regex" > /dev/null; then
960813498266Sopenharmony_ci			func_append newdeplibs " $a_deplib"
960913498266Sopenharmony_ci			a_deplib=
961013498266Sopenharmony_ci			break 2
961113498266Sopenharmony_ci		      fi
961213498266Sopenharmony_ci		  done
961313498266Sopenharmony_ci		done
961413498266Sopenharmony_ci	      fi
961513498266Sopenharmony_ci	      if test -n "$a_deplib"; then
961613498266Sopenharmony_ci		droppeddeps=yes
961713498266Sopenharmony_ci		echo
961813498266Sopenharmony_ci		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
961913498266Sopenharmony_ci		echo "*** I have the capability to make that library automatically link in when"
962013498266Sopenharmony_ci		echo "*** you link to this library.  But I can only do this if you have a"
962113498266Sopenharmony_ci		echo "*** shared version of the library, which you do not appear to have"
962213498266Sopenharmony_ci		echo "*** because I did check the linker path looking for a file starting"
962313498266Sopenharmony_ci		if test -z "$potlib"; then
962413498266Sopenharmony_ci		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
962513498266Sopenharmony_ci		else
962613498266Sopenharmony_ci		  $ECHO "*** with $libname and none of the candidates passed a file format test"
962713498266Sopenharmony_ci		  $ECHO "*** using a file magic. Last file checked: $potlib"
962813498266Sopenharmony_ci		fi
962913498266Sopenharmony_ci	      fi
963013498266Sopenharmony_ci	      ;;
963113498266Sopenharmony_ci	    *)
963213498266Sopenharmony_ci	      # Add a -L argument.
963313498266Sopenharmony_ci	      func_append newdeplibs " $a_deplib"
963413498266Sopenharmony_ci	      ;;
963513498266Sopenharmony_ci	    esac
963613498266Sopenharmony_ci	  done # Gone through all deplibs.
963713498266Sopenharmony_ci	  ;;
963813498266Sopenharmony_ci	match_pattern*)
963913498266Sopenharmony_ci	  set dummy $deplibs_check_method; shift
964013498266Sopenharmony_ci	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
964113498266Sopenharmony_ci	  for a_deplib in $deplibs; do
964213498266Sopenharmony_ci	    case $a_deplib in
964313498266Sopenharmony_ci	    -l*)
964413498266Sopenharmony_ci	      func_stripname -l '' "$a_deplib"
964513498266Sopenharmony_ci	      name=$func_stripname_result
964613498266Sopenharmony_ci	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
964713498266Sopenharmony_ci		case " $predeps $postdeps " in
964813498266Sopenharmony_ci		*" $a_deplib "*)
964913498266Sopenharmony_ci		  func_append newdeplibs " $a_deplib"
965013498266Sopenharmony_ci		  a_deplib=
965113498266Sopenharmony_ci		  ;;
965213498266Sopenharmony_ci		esac
965313498266Sopenharmony_ci	      fi
965413498266Sopenharmony_ci	      if test -n "$a_deplib"; then
965513498266Sopenharmony_ci		libname=`eval "\\$ECHO \"$libname_spec\""`
965613498266Sopenharmony_ci		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
965713498266Sopenharmony_ci		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
965813498266Sopenharmony_ci		  for potent_lib in $potential_libs; do
965913498266Sopenharmony_ci		    potlib=$potent_lib # see symlink-check above in file_magic test
966013498266Sopenharmony_ci		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
966113498266Sopenharmony_ci		       $EGREP "$match_pattern_regex" > /dev/null; then
966213498266Sopenharmony_ci		      func_append newdeplibs " $a_deplib"
966313498266Sopenharmony_ci		      a_deplib=
966413498266Sopenharmony_ci		      break 2
966513498266Sopenharmony_ci		    fi
966613498266Sopenharmony_ci		  done
966713498266Sopenharmony_ci		done
966813498266Sopenharmony_ci	      fi
966913498266Sopenharmony_ci	      if test -n "$a_deplib"; then
967013498266Sopenharmony_ci		droppeddeps=yes
967113498266Sopenharmony_ci		echo
967213498266Sopenharmony_ci		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
967313498266Sopenharmony_ci		echo "*** I have the capability to make that library automatically link in when"
967413498266Sopenharmony_ci		echo "*** you link to this library.  But I can only do this if you have a"
967513498266Sopenharmony_ci		echo "*** shared version of the library, which you do not appear to have"
967613498266Sopenharmony_ci		echo "*** because I did check the linker path looking for a file starting"
967713498266Sopenharmony_ci		if test -z "$potlib"; then
967813498266Sopenharmony_ci		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
967913498266Sopenharmony_ci		else
968013498266Sopenharmony_ci		  $ECHO "*** with $libname and none of the candidates passed a file format test"
968113498266Sopenharmony_ci		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
968213498266Sopenharmony_ci		fi
968313498266Sopenharmony_ci	      fi
968413498266Sopenharmony_ci	      ;;
968513498266Sopenharmony_ci	    *)
968613498266Sopenharmony_ci	      # Add a -L argument.
968713498266Sopenharmony_ci	      func_append newdeplibs " $a_deplib"
968813498266Sopenharmony_ci	      ;;
968913498266Sopenharmony_ci	    esac
969013498266Sopenharmony_ci	  done # Gone through all deplibs.
969113498266Sopenharmony_ci	  ;;
969213498266Sopenharmony_ci	none | unknown | *)
969313498266Sopenharmony_ci	  newdeplibs=
969413498266Sopenharmony_ci	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
969513498266Sopenharmony_ci	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
969613498266Sopenharmony_ci	    for i in $predeps $postdeps; do
969713498266Sopenharmony_ci	      # can't use Xsed below, because $i might contain '/'
969813498266Sopenharmony_ci	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
969913498266Sopenharmony_ci	    done
970013498266Sopenharmony_ci	  fi
970113498266Sopenharmony_ci	  case $tmp_deplibs in
970213498266Sopenharmony_ci	  *[!\	\ ]*)
970313498266Sopenharmony_ci	    echo
970413498266Sopenharmony_ci	    if test none = "$deplibs_check_method"; then
970513498266Sopenharmony_ci	      echo "*** Warning: inter-library dependencies are not supported in this platform."
970613498266Sopenharmony_ci	    else
970713498266Sopenharmony_ci	      echo "*** Warning: inter-library dependencies are not known to be supported."
970813498266Sopenharmony_ci	    fi
970913498266Sopenharmony_ci	    echo "*** All declared inter-library dependencies are being dropped."
971013498266Sopenharmony_ci	    droppeddeps=yes
971113498266Sopenharmony_ci	    ;;
971213498266Sopenharmony_ci	  esac
971313498266Sopenharmony_ci	  ;;
971413498266Sopenharmony_ci	esac
971513498266Sopenharmony_ci	versuffix=$versuffix_save
971613498266Sopenharmony_ci	major=$major_save
971713498266Sopenharmony_ci	release=$release_save
971813498266Sopenharmony_ci	libname=$libname_save
971913498266Sopenharmony_ci	name=$name_save
972013498266Sopenharmony_ci
972113498266Sopenharmony_ci	case $host in
972213498266Sopenharmony_ci	*-*-rhapsody* | *-*-darwin1.[012])
972313498266Sopenharmony_ci	  # On Rhapsody replace the C library with the System framework
972413498266Sopenharmony_ci	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
972513498266Sopenharmony_ci	  ;;
972613498266Sopenharmony_ci	esac
972713498266Sopenharmony_ci
972813498266Sopenharmony_ci	if test yes = "$droppeddeps"; then
972913498266Sopenharmony_ci	  if test yes = "$module"; then
973013498266Sopenharmony_ci	    echo
973113498266Sopenharmony_ci	    echo "*** Warning: libtool could not satisfy all declared inter-library"
973213498266Sopenharmony_ci	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
973313498266Sopenharmony_ci	    echo "*** a static module, that should work as long as the dlopening"
973413498266Sopenharmony_ci	    echo "*** application is linked with the -dlopen flag."
973513498266Sopenharmony_ci	    if test -z "$global_symbol_pipe"; then
973613498266Sopenharmony_ci	      echo
973713498266Sopenharmony_ci	      echo "*** However, this would only work if libtool was able to extract symbol"
973813498266Sopenharmony_ci	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
973913498266Sopenharmony_ci	      echo "*** not find such a program.  So, this module is probably useless."
974013498266Sopenharmony_ci	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
974113498266Sopenharmony_ci	    fi
974213498266Sopenharmony_ci	    if test no = "$build_old_libs"; then
974313498266Sopenharmony_ci	      oldlibs=$output_objdir/$libname.$libext
974413498266Sopenharmony_ci	      build_libtool_libs=module
974513498266Sopenharmony_ci	      build_old_libs=yes
974613498266Sopenharmony_ci	    else
974713498266Sopenharmony_ci	      build_libtool_libs=no
974813498266Sopenharmony_ci	    fi
974913498266Sopenharmony_ci	  else
975013498266Sopenharmony_ci	    echo "*** The inter-library dependencies that have been dropped here will be"
975113498266Sopenharmony_ci	    echo "*** automatically added whenever a program is linked with this library"
975213498266Sopenharmony_ci	    echo "*** or is declared to -dlopen it."
975313498266Sopenharmony_ci
975413498266Sopenharmony_ci	    if test no = "$allow_undefined"; then
975513498266Sopenharmony_ci	      echo
975613498266Sopenharmony_ci	      echo "*** Since this library must not contain undefined symbols,"
975713498266Sopenharmony_ci	      echo "*** because either the platform does not support them or"
975813498266Sopenharmony_ci	      echo "*** it was explicitly requested with -no-undefined,"
975913498266Sopenharmony_ci	      echo "*** libtool will only create a static version of it."
976013498266Sopenharmony_ci	      if test no = "$build_old_libs"; then
976113498266Sopenharmony_ci		oldlibs=$output_objdir/$libname.$libext
976213498266Sopenharmony_ci		build_libtool_libs=module
976313498266Sopenharmony_ci		build_old_libs=yes
976413498266Sopenharmony_ci	      else
976513498266Sopenharmony_ci		build_libtool_libs=no
976613498266Sopenharmony_ci	      fi
976713498266Sopenharmony_ci	    fi
976813498266Sopenharmony_ci	  fi
976913498266Sopenharmony_ci	fi
977013498266Sopenharmony_ci	# Done checking deplibs!
977113498266Sopenharmony_ci	deplibs=$newdeplibs
977213498266Sopenharmony_ci      fi
977313498266Sopenharmony_ci      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
977413498266Sopenharmony_ci      case $host in
977513498266Sopenharmony_ci	*-*-darwin*)
977613498266Sopenharmony_ci	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
977713498266Sopenharmony_ci	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
977813498266Sopenharmony_ci	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
977913498266Sopenharmony_ci	  ;;
978013498266Sopenharmony_ci      esac
978113498266Sopenharmony_ci
978213498266Sopenharmony_ci      # move library search paths that coincide with paths to not yet
978313498266Sopenharmony_ci      # installed libraries to the beginning of the library search list
978413498266Sopenharmony_ci      new_libs=
978513498266Sopenharmony_ci      for path in $notinst_path; do
978613498266Sopenharmony_ci	case " $new_libs " in
978713498266Sopenharmony_ci	*" -L$path/$objdir "*) ;;
978813498266Sopenharmony_ci	*)
978913498266Sopenharmony_ci	  case " $deplibs " in
979013498266Sopenharmony_ci	  *" -L$path/$objdir "*)
979113498266Sopenharmony_ci	    func_append new_libs " -L$path/$objdir" ;;
979213498266Sopenharmony_ci	  esac
979313498266Sopenharmony_ci	  ;;
979413498266Sopenharmony_ci	esac
979513498266Sopenharmony_ci      done
979613498266Sopenharmony_ci      for deplib in $deplibs; do
979713498266Sopenharmony_ci	case $deplib in
979813498266Sopenharmony_ci	-L*)
979913498266Sopenharmony_ci	  case " $new_libs " in
980013498266Sopenharmony_ci	  *" $deplib "*) ;;
980113498266Sopenharmony_ci	  *) func_append new_libs " $deplib" ;;
980213498266Sopenharmony_ci	  esac
980313498266Sopenharmony_ci	  ;;
980413498266Sopenharmony_ci	*) func_append new_libs " $deplib" ;;
980513498266Sopenharmony_ci	esac
980613498266Sopenharmony_ci      done
980713498266Sopenharmony_ci      deplibs=$new_libs
980813498266Sopenharmony_ci
980913498266Sopenharmony_ci      # All the library-specific variables (install_libdir is set above).
981013498266Sopenharmony_ci      library_names=
981113498266Sopenharmony_ci      old_library=
981213498266Sopenharmony_ci      dlname=
981313498266Sopenharmony_ci
981413498266Sopenharmony_ci      # Test again, we may have decided not to build it any more
981513498266Sopenharmony_ci      if test yes = "$build_libtool_libs"; then
981613498266Sopenharmony_ci	# Remove $wl instances when linking with ld.
981713498266Sopenharmony_ci	# FIXME: should test the right _cmds variable.
981813498266Sopenharmony_ci	case $archive_cmds in
981913498266Sopenharmony_ci	  *\$LD\ *) wl= ;;
982013498266Sopenharmony_ci        esac
982113498266Sopenharmony_ci	if test yes = "$hardcode_into_libs"; then
982213498266Sopenharmony_ci	  # Hardcode the library paths
982313498266Sopenharmony_ci	  hardcode_libdirs=
982413498266Sopenharmony_ci	  dep_rpath=
982513498266Sopenharmony_ci	  rpath=$finalize_rpath
982613498266Sopenharmony_ci	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
982713498266Sopenharmony_ci	  for libdir in $rpath; do
982813498266Sopenharmony_ci	    if test -n "$hardcode_libdir_flag_spec"; then
982913498266Sopenharmony_ci	      if test -n "$hardcode_libdir_separator"; then
983013498266Sopenharmony_ci		func_replace_sysroot "$libdir"
983113498266Sopenharmony_ci		libdir=$func_replace_sysroot_result
983213498266Sopenharmony_ci		if test -z "$hardcode_libdirs"; then
983313498266Sopenharmony_ci		  hardcode_libdirs=$libdir
983413498266Sopenharmony_ci		else
983513498266Sopenharmony_ci		  # Just accumulate the unique libdirs.
983613498266Sopenharmony_ci		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
983713498266Sopenharmony_ci		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
983813498266Sopenharmony_ci		    ;;
983913498266Sopenharmony_ci		  *)
984013498266Sopenharmony_ci		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
984113498266Sopenharmony_ci		    ;;
984213498266Sopenharmony_ci		  esac
984313498266Sopenharmony_ci		fi
984413498266Sopenharmony_ci	      else
984513498266Sopenharmony_ci		eval flag=\"$hardcode_libdir_flag_spec\"
984613498266Sopenharmony_ci		func_append dep_rpath " $flag"
984713498266Sopenharmony_ci	      fi
984813498266Sopenharmony_ci	    elif test -n "$runpath_var"; then
984913498266Sopenharmony_ci	      case "$perm_rpath " in
985013498266Sopenharmony_ci	      *" $libdir "*) ;;
985113498266Sopenharmony_ci	      *) func_append perm_rpath " $libdir" ;;
985213498266Sopenharmony_ci	      esac
985313498266Sopenharmony_ci	    fi
985413498266Sopenharmony_ci	  done
985513498266Sopenharmony_ci	  # Substitute the hardcoded libdirs into the rpath.
985613498266Sopenharmony_ci	  if test -n "$hardcode_libdir_separator" &&
985713498266Sopenharmony_ci	     test -n "$hardcode_libdirs"; then
985813498266Sopenharmony_ci	    libdir=$hardcode_libdirs
985913498266Sopenharmony_ci	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
986013498266Sopenharmony_ci	  fi
986113498266Sopenharmony_ci	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
986213498266Sopenharmony_ci	    # We should set the runpath_var.
986313498266Sopenharmony_ci	    rpath=
986413498266Sopenharmony_ci	    for dir in $perm_rpath; do
986513498266Sopenharmony_ci	      func_append rpath "$dir:"
986613498266Sopenharmony_ci	    done
986713498266Sopenharmony_ci	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
986813498266Sopenharmony_ci	  fi
986913498266Sopenharmony_ci	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
987013498266Sopenharmony_ci	fi
987113498266Sopenharmony_ci
987213498266Sopenharmony_ci	shlibpath=$finalize_shlibpath
987313498266Sopenharmony_ci	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
987413498266Sopenharmony_ci	if test -n "$shlibpath"; then
987513498266Sopenharmony_ci	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
987613498266Sopenharmony_ci	fi
987713498266Sopenharmony_ci
987813498266Sopenharmony_ci	# Get the real and link names of the library.
987913498266Sopenharmony_ci	eval shared_ext=\"$shrext_cmds\"
988013498266Sopenharmony_ci	eval library_names=\"$library_names_spec\"
988113498266Sopenharmony_ci	set dummy $library_names
988213498266Sopenharmony_ci	shift
988313498266Sopenharmony_ci	realname=$1
988413498266Sopenharmony_ci	shift
988513498266Sopenharmony_ci
988613498266Sopenharmony_ci	if test -n "$soname_spec"; then
988713498266Sopenharmony_ci	  eval soname=\"$soname_spec\"
988813498266Sopenharmony_ci	else
988913498266Sopenharmony_ci	  soname=$realname
989013498266Sopenharmony_ci	fi
989113498266Sopenharmony_ci	if test -z "$dlname"; then
989213498266Sopenharmony_ci	  dlname=$soname
989313498266Sopenharmony_ci	fi
989413498266Sopenharmony_ci
989513498266Sopenharmony_ci	lib=$output_objdir/$realname
989613498266Sopenharmony_ci	linknames=
989713498266Sopenharmony_ci	for link
989813498266Sopenharmony_ci	do
989913498266Sopenharmony_ci	  func_append linknames " $link"
990013498266Sopenharmony_ci	done
990113498266Sopenharmony_ci
990213498266Sopenharmony_ci	# Use standard objects if they are pic
990313498266Sopenharmony_ci	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
990413498266Sopenharmony_ci	test "X$libobjs" = "X " && libobjs=
990513498266Sopenharmony_ci
990613498266Sopenharmony_ci	delfiles=
990713498266Sopenharmony_ci	if test -n "$export_symbols" && test -n "$include_expsyms"; then
990813498266Sopenharmony_ci	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
990913498266Sopenharmony_ci	  export_symbols=$output_objdir/$libname.uexp
991013498266Sopenharmony_ci	  func_append delfiles " $export_symbols"
991113498266Sopenharmony_ci	fi
991213498266Sopenharmony_ci
991313498266Sopenharmony_ci	orig_export_symbols=
991413498266Sopenharmony_ci	case $host_os in
991513498266Sopenharmony_ci	cygwin* | mingw* | cegcc*)
991613498266Sopenharmony_ci	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
991713498266Sopenharmony_ci	    # exporting using user supplied symfile
991813498266Sopenharmony_ci	    func_dll_def_p "$export_symbols" || {
991913498266Sopenharmony_ci	      # and it's NOT already a .def file. Must figure out
992013498266Sopenharmony_ci	      # which of the given symbols are data symbols and tag
992113498266Sopenharmony_ci	      # them as such. So, trigger use of export_symbols_cmds.
992213498266Sopenharmony_ci	      # export_symbols gets reassigned inside the "prepare
992313498266Sopenharmony_ci	      # the list of exported symbols" if statement, so the
992413498266Sopenharmony_ci	      # include_expsyms logic still works.
992513498266Sopenharmony_ci	      orig_export_symbols=$export_symbols
992613498266Sopenharmony_ci	      export_symbols=
992713498266Sopenharmony_ci	      always_export_symbols=yes
992813498266Sopenharmony_ci	    }
992913498266Sopenharmony_ci	  fi
993013498266Sopenharmony_ci	  ;;
993113498266Sopenharmony_ci	esac
993213498266Sopenharmony_ci
993313498266Sopenharmony_ci	# Prepare the list of exported symbols
993413498266Sopenharmony_ci	if test -z "$export_symbols"; then
993513498266Sopenharmony_ci	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
993613498266Sopenharmony_ci	    func_verbose "generating symbol list for '$libname.la'"
993713498266Sopenharmony_ci	    export_symbols=$output_objdir/$libname.exp
993813498266Sopenharmony_ci	    $opt_dry_run || $RM $export_symbols
993913498266Sopenharmony_ci	    cmds=$export_symbols_cmds
994013498266Sopenharmony_ci	    save_ifs=$IFS; IFS='~'
994113498266Sopenharmony_ci	    for cmd1 in $cmds; do
994213498266Sopenharmony_ci	      IFS=$save_ifs
994313498266Sopenharmony_ci	      # Take the normal branch if the nm_file_list_spec branch
994413498266Sopenharmony_ci	      # doesn't work or if tool conversion is not needed.
994513498266Sopenharmony_ci	      case $nm_file_list_spec~$to_tool_file_cmd in
994613498266Sopenharmony_ci		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
994713498266Sopenharmony_ci		  try_normal_branch=yes
994813498266Sopenharmony_ci		  eval cmd=\"$cmd1\"
994913498266Sopenharmony_ci		  func_len " $cmd"
995013498266Sopenharmony_ci		  len=$func_len_result
995113498266Sopenharmony_ci		  ;;
995213498266Sopenharmony_ci		*)
995313498266Sopenharmony_ci		  try_normal_branch=no
995413498266Sopenharmony_ci		  ;;
995513498266Sopenharmony_ci	      esac
995613498266Sopenharmony_ci	      if test yes = "$try_normal_branch" \
995713498266Sopenharmony_ci		 && { test "$len" -lt "$max_cmd_len" \
995813498266Sopenharmony_ci		      || test "$max_cmd_len" -le -1; }
995913498266Sopenharmony_ci	      then
996013498266Sopenharmony_ci		func_show_eval "$cmd" 'exit $?'
996113498266Sopenharmony_ci		skipped_export=false
996213498266Sopenharmony_ci	      elif test -n "$nm_file_list_spec"; then
996313498266Sopenharmony_ci		func_basename "$output"
996413498266Sopenharmony_ci		output_la=$func_basename_result
996513498266Sopenharmony_ci		save_libobjs=$libobjs
996613498266Sopenharmony_ci		save_output=$output
996713498266Sopenharmony_ci		output=$output_objdir/$output_la.nm
996813498266Sopenharmony_ci		func_to_tool_file "$output"
996913498266Sopenharmony_ci		libobjs=$nm_file_list_spec$func_to_tool_file_result
997013498266Sopenharmony_ci		func_append delfiles " $output"
997113498266Sopenharmony_ci		func_verbose "creating $NM input file list: $output"
997213498266Sopenharmony_ci		for obj in $save_libobjs; do
997313498266Sopenharmony_ci		  func_to_tool_file "$obj"
997413498266Sopenharmony_ci		  $ECHO "$func_to_tool_file_result"
997513498266Sopenharmony_ci		done > "$output"
997613498266Sopenharmony_ci		eval cmd=\"$cmd1\"
997713498266Sopenharmony_ci		func_show_eval "$cmd" 'exit $?'
997813498266Sopenharmony_ci		output=$save_output
997913498266Sopenharmony_ci		libobjs=$save_libobjs
998013498266Sopenharmony_ci		skipped_export=false
998113498266Sopenharmony_ci	      else
998213498266Sopenharmony_ci		# The command line is too long to execute in one step.
998313498266Sopenharmony_ci		func_verbose "using reloadable object file for export list..."
998413498266Sopenharmony_ci		skipped_export=:
998513498266Sopenharmony_ci		# Break out early, otherwise skipped_export may be
998613498266Sopenharmony_ci		# set to false by a later but shorter cmd.
998713498266Sopenharmony_ci		break
998813498266Sopenharmony_ci	      fi
998913498266Sopenharmony_ci	    done
999013498266Sopenharmony_ci	    IFS=$save_ifs
999113498266Sopenharmony_ci	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
999213498266Sopenharmony_ci	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
999313498266Sopenharmony_ci	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
999413498266Sopenharmony_ci	    fi
999513498266Sopenharmony_ci	  fi
999613498266Sopenharmony_ci	fi
999713498266Sopenharmony_ci
999813498266Sopenharmony_ci	if test -n "$export_symbols" && test -n "$include_expsyms"; then
999913498266Sopenharmony_ci	  tmp_export_symbols=$export_symbols
1000013498266Sopenharmony_ci	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
1000113498266Sopenharmony_ci	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
1000213498266Sopenharmony_ci	fi
1000313498266Sopenharmony_ci
1000413498266Sopenharmony_ci	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
1000513498266Sopenharmony_ci	  # The given exports_symbols file has to be filtered, so filter it.
1000613498266Sopenharmony_ci	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
1000713498266Sopenharmony_ci	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
1000813498266Sopenharmony_ci	  # 's' commands, which not all seds can handle. GNU sed should be fine
1000913498266Sopenharmony_ci	  # though. Also, the filter scales superlinearly with the number of
1001013498266Sopenharmony_ci	  # global variables. join(1) would be nice here, but unfortunately
1001113498266Sopenharmony_ci	  # isn't a blessed tool.
1001213498266Sopenharmony_ci	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
1001313498266Sopenharmony_ci	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
1001413498266Sopenharmony_ci	  export_symbols=$output_objdir/$libname.def
1001513498266Sopenharmony_ci	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
1001613498266Sopenharmony_ci	fi
1001713498266Sopenharmony_ci
1001813498266Sopenharmony_ci	tmp_deplibs=
1001913498266Sopenharmony_ci	for test_deplib in $deplibs; do
1002013498266Sopenharmony_ci	  case " $convenience " in
1002113498266Sopenharmony_ci	  *" $test_deplib "*) ;;
1002213498266Sopenharmony_ci	  *)
1002313498266Sopenharmony_ci	    func_append tmp_deplibs " $test_deplib"
1002413498266Sopenharmony_ci	    ;;
1002513498266Sopenharmony_ci	  esac
1002613498266Sopenharmony_ci	done
1002713498266Sopenharmony_ci	deplibs=$tmp_deplibs
1002813498266Sopenharmony_ci
1002913498266Sopenharmony_ci	if test -n "$convenience"; then
1003013498266Sopenharmony_ci	  if test -n "$whole_archive_flag_spec" &&
1003113498266Sopenharmony_ci	    test yes = "$compiler_needs_object" &&
1003213498266Sopenharmony_ci	    test -z "$libobjs"; then
1003313498266Sopenharmony_ci	    # extract the archives, so we have objects to list.
1003413498266Sopenharmony_ci	    # TODO: could optimize this to just extract one archive.
1003513498266Sopenharmony_ci	    whole_archive_flag_spec=
1003613498266Sopenharmony_ci	  fi
1003713498266Sopenharmony_ci	  if test -n "$whole_archive_flag_spec"; then
1003813498266Sopenharmony_ci	    save_libobjs=$libobjs
1003913498266Sopenharmony_ci	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
1004013498266Sopenharmony_ci	    test "X$libobjs" = "X " && libobjs=
1004113498266Sopenharmony_ci	  else
1004213498266Sopenharmony_ci	    gentop=$output_objdir/${outputname}x
1004313498266Sopenharmony_ci	    func_append generated " $gentop"
1004413498266Sopenharmony_ci
1004513498266Sopenharmony_ci	    func_extract_archives $gentop $convenience
1004613498266Sopenharmony_ci	    func_append libobjs " $func_extract_archives_result"
1004713498266Sopenharmony_ci	    test "X$libobjs" = "X " && libobjs=
1004813498266Sopenharmony_ci	  fi
1004913498266Sopenharmony_ci	fi
1005013498266Sopenharmony_ci
1005113498266Sopenharmony_ci	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
1005213498266Sopenharmony_ci	  eval flag=\"$thread_safe_flag_spec\"
1005313498266Sopenharmony_ci	  func_append linker_flags " $flag"
1005413498266Sopenharmony_ci	fi
1005513498266Sopenharmony_ci
1005613498266Sopenharmony_ci	# Make a backup of the uninstalled library when relinking
1005713498266Sopenharmony_ci	if test relink = "$opt_mode"; then
1005813498266Sopenharmony_ci	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
1005913498266Sopenharmony_ci	fi
1006013498266Sopenharmony_ci
1006113498266Sopenharmony_ci	# Do each of the archive commands.
1006213498266Sopenharmony_ci	if test yes = "$module" && test -n "$module_cmds"; then
1006313498266Sopenharmony_ci	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
1006413498266Sopenharmony_ci	    eval test_cmds=\"$module_expsym_cmds\"
1006513498266Sopenharmony_ci	    cmds=$module_expsym_cmds
1006613498266Sopenharmony_ci	  else
1006713498266Sopenharmony_ci	    eval test_cmds=\"$module_cmds\"
1006813498266Sopenharmony_ci	    cmds=$module_cmds
1006913498266Sopenharmony_ci	  fi
1007013498266Sopenharmony_ci	else
1007113498266Sopenharmony_ci	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
1007213498266Sopenharmony_ci	    eval test_cmds=\"$archive_expsym_cmds\"
1007313498266Sopenharmony_ci	    cmds=$archive_expsym_cmds
1007413498266Sopenharmony_ci	  else
1007513498266Sopenharmony_ci	    eval test_cmds=\"$archive_cmds\"
1007613498266Sopenharmony_ci	    cmds=$archive_cmds
1007713498266Sopenharmony_ci	  fi
1007813498266Sopenharmony_ci	fi
1007913498266Sopenharmony_ci
1008013498266Sopenharmony_ci	if test : != "$skipped_export" &&
1008113498266Sopenharmony_ci	   func_len " $test_cmds" &&
1008213498266Sopenharmony_ci	   len=$func_len_result &&
1008313498266Sopenharmony_ci	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
1008413498266Sopenharmony_ci	  :
1008513498266Sopenharmony_ci	else
1008613498266Sopenharmony_ci	  # The command line is too long to link in one step, link piecewise
1008713498266Sopenharmony_ci	  # or, if using GNU ld and skipped_export is not :, use a linker
1008813498266Sopenharmony_ci	  # script.
1008913498266Sopenharmony_ci
1009013498266Sopenharmony_ci	  # Save the value of $output and $libobjs because we want to
1009113498266Sopenharmony_ci	  # use them later.  If we have whole_archive_flag_spec, we
1009213498266Sopenharmony_ci	  # want to use save_libobjs as it was before
1009313498266Sopenharmony_ci	  # whole_archive_flag_spec was expanded, because we can't
1009413498266Sopenharmony_ci	  # assume the linker understands whole_archive_flag_spec.
1009513498266Sopenharmony_ci	  # This may have to be revisited, in case too many
1009613498266Sopenharmony_ci	  # convenience libraries get linked in and end up exceeding
1009713498266Sopenharmony_ci	  # the spec.
1009813498266Sopenharmony_ci	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
1009913498266Sopenharmony_ci	    save_libobjs=$libobjs
1010013498266Sopenharmony_ci	  fi
1010113498266Sopenharmony_ci	  save_output=$output
1010213498266Sopenharmony_ci	  func_basename "$output"
1010313498266Sopenharmony_ci	  output_la=$func_basename_result
1010413498266Sopenharmony_ci
1010513498266Sopenharmony_ci	  # Clear the reloadable object creation command queue and
1010613498266Sopenharmony_ci	  # initialize k to one.
1010713498266Sopenharmony_ci	  test_cmds=
1010813498266Sopenharmony_ci	  concat_cmds=
1010913498266Sopenharmony_ci	  objlist=
1011013498266Sopenharmony_ci	  last_robj=
1011113498266Sopenharmony_ci	  k=1
1011213498266Sopenharmony_ci
1011313498266Sopenharmony_ci	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
1011413498266Sopenharmony_ci	    output=$output_objdir/$output_la.lnkscript
1011513498266Sopenharmony_ci	    func_verbose "creating GNU ld script: $output"
1011613498266Sopenharmony_ci	    echo 'INPUT (' > $output
1011713498266Sopenharmony_ci	    for obj in $save_libobjs
1011813498266Sopenharmony_ci	    do
1011913498266Sopenharmony_ci	      func_to_tool_file "$obj"
1012013498266Sopenharmony_ci	      $ECHO "$func_to_tool_file_result" >> $output
1012113498266Sopenharmony_ci	    done
1012213498266Sopenharmony_ci	    echo ')' >> $output
1012313498266Sopenharmony_ci	    func_append delfiles " $output"
1012413498266Sopenharmony_ci	    func_to_tool_file "$output"
1012513498266Sopenharmony_ci	    output=$func_to_tool_file_result
1012613498266Sopenharmony_ci	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
1012713498266Sopenharmony_ci	    output=$output_objdir/$output_la.lnk
1012813498266Sopenharmony_ci	    func_verbose "creating linker input file list: $output"
1012913498266Sopenharmony_ci	    : > $output
1013013498266Sopenharmony_ci	    set x $save_libobjs
1013113498266Sopenharmony_ci	    shift
1013213498266Sopenharmony_ci	    firstobj=
1013313498266Sopenharmony_ci	    if test yes = "$compiler_needs_object"; then
1013413498266Sopenharmony_ci	      firstobj="$1 "
1013513498266Sopenharmony_ci	      shift
1013613498266Sopenharmony_ci	    fi
1013713498266Sopenharmony_ci	    for obj
1013813498266Sopenharmony_ci	    do
1013913498266Sopenharmony_ci	      func_to_tool_file "$obj"
1014013498266Sopenharmony_ci	      $ECHO "$func_to_tool_file_result" >> $output
1014113498266Sopenharmony_ci	    done
1014213498266Sopenharmony_ci	    func_append delfiles " $output"
1014313498266Sopenharmony_ci	    func_to_tool_file "$output"
1014413498266Sopenharmony_ci	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
1014513498266Sopenharmony_ci	  else
1014613498266Sopenharmony_ci	    if test -n "$save_libobjs"; then
1014713498266Sopenharmony_ci	      func_verbose "creating reloadable object files..."
1014813498266Sopenharmony_ci	      output=$output_objdir/$output_la-$k.$objext
1014913498266Sopenharmony_ci	      eval test_cmds=\"$reload_cmds\"
1015013498266Sopenharmony_ci	      func_len " $test_cmds"
1015113498266Sopenharmony_ci	      len0=$func_len_result
1015213498266Sopenharmony_ci	      len=$len0
1015313498266Sopenharmony_ci
1015413498266Sopenharmony_ci	      # Loop over the list of objects to be linked.
1015513498266Sopenharmony_ci	      for obj in $save_libobjs
1015613498266Sopenharmony_ci	      do
1015713498266Sopenharmony_ci		func_len " $obj"
1015813498266Sopenharmony_ci		func_arith $len + $func_len_result
1015913498266Sopenharmony_ci		len=$func_arith_result
1016013498266Sopenharmony_ci		if test -z "$objlist" ||
1016113498266Sopenharmony_ci		   test "$len" -lt "$max_cmd_len"; then
1016213498266Sopenharmony_ci		  func_append objlist " $obj"
1016313498266Sopenharmony_ci		else
1016413498266Sopenharmony_ci		  # The command $test_cmds is almost too long, add a
1016513498266Sopenharmony_ci		  # command to the queue.
1016613498266Sopenharmony_ci		  if test 1 -eq "$k"; then
1016713498266Sopenharmony_ci		    # The first file doesn't have a previous command to add.
1016813498266Sopenharmony_ci		    reload_objs=$objlist
1016913498266Sopenharmony_ci		    eval concat_cmds=\"$reload_cmds\"
1017013498266Sopenharmony_ci		  else
1017113498266Sopenharmony_ci		    # All subsequent reloadable object files will link in
1017213498266Sopenharmony_ci		    # the last one created.
1017313498266Sopenharmony_ci		    reload_objs="$objlist $last_robj"
1017413498266Sopenharmony_ci		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
1017513498266Sopenharmony_ci		  fi
1017613498266Sopenharmony_ci		  last_robj=$output_objdir/$output_la-$k.$objext
1017713498266Sopenharmony_ci		  func_arith $k + 1
1017813498266Sopenharmony_ci		  k=$func_arith_result
1017913498266Sopenharmony_ci		  output=$output_objdir/$output_la-$k.$objext
1018013498266Sopenharmony_ci		  objlist=" $obj"
1018113498266Sopenharmony_ci		  func_len " $last_robj"
1018213498266Sopenharmony_ci		  func_arith $len0 + $func_len_result
1018313498266Sopenharmony_ci		  len=$func_arith_result
1018413498266Sopenharmony_ci		fi
1018513498266Sopenharmony_ci	      done
1018613498266Sopenharmony_ci	      # Handle the remaining objects by creating one last
1018713498266Sopenharmony_ci	      # reloadable object file.  All subsequent reloadable object
1018813498266Sopenharmony_ci	      # files will link in the last one created.
1018913498266Sopenharmony_ci	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
1019013498266Sopenharmony_ci	      reload_objs="$objlist $last_robj"
1019113498266Sopenharmony_ci	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
1019213498266Sopenharmony_ci	      if test -n "$last_robj"; then
1019313498266Sopenharmony_ci	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
1019413498266Sopenharmony_ci	      fi
1019513498266Sopenharmony_ci	      func_append delfiles " $output"
1019613498266Sopenharmony_ci
1019713498266Sopenharmony_ci	    else
1019813498266Sopenharmony_ci	      output=
1019913498266Sopenharmony_ci	    fi
1020013498266Sopenharmony_ci
1020113498266Sopenharmony_ci	    ${skipped_export-false} && {
1020213498266Sopenharmony_ci	      func_verbose "generating symbol list for '$libname.la'"
1020313498266Sopenharmony_ci	      export_symbols=$output_objdir/$libname.exp
1020413498266Sopenharmony_ci	      $opt_dry_run || $RM $export_symbols
1020513498266Sopenharmony_ci	      libobjs=$output
1020613498266Sopenharmony_ci	      # Append the command to create the export file.
1020713498266Sopenharmony_ci	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
1020813498266Sopenharmony_ci	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
1020913498266Sopenharmony_ci	      if test -n "$last_robj"; then
1021013498266Sopenharmony_ci		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
1021113498266Sopenharmony_ci	      fi
1021213498266Sopenharmony_ci	    }
1021313498266Sopenharmony_ci
1021413498266Sopenharmony_ci	    test -n "$save_libobjs" &&
1021513498266Sopenharmony_ci	      func_verbose "creating a temporary reloadable object file: $output"
1021613498266Sopenharmony_ci
1021713498266Sopenharmony_ci	    # Loop through the commands generated above and execute them.
1021813498266Sopenharmony_ci	    save_ifs=$IFS; IFS='~'
1021913498266Sopenharmony_ci	    for cmd in $concat_cmds; do
1022013498266Sopenharmony_ci	      IFS=$save_ifs
1022113498266Sopenharmony_ci	      $opt_quiet || {
1022213498266Sopenharmony_ci		  func_quote_arg expand,pretty "$cmd"
1022313498266Sopenharmony_ci		  eval "func_echo $func_quote_arg_result"
1022413498266Sopenharmony_ci	      }
1022513498266Sopenharmony_ci	      $opt_dry_run || eval "$cmd" || {
1022613498266Sopenharmony_ci		lt_exit=$?
1022713498266Sopenharmony_ci
1022813498266Sopenharmony_ci		# Restore the uninstalled library and exit
1022913498266Sopenharmony_ci		if test relink = "$opt_mode"; then
1023013498266Sopenharmony_ci		  ( cd "$output_objdir" && \
1023113498266Sopenharmony_ci		    $RM "${realname}T" && \
1023213498266Sopenharmony_ci		    $MV "${realname}U" "$realname" )
1023313498266Sopenharmony_ci		fi
1023413498266Sopenharmony_ci
1023513498266Sopenharmony_ci		exit $lt_exit
1023613498266Sopenharmony_ci	      }
1023713498266Sopenharmony_ci	    done
1023813498266Sopenharmony_ci	    IFS=$save_ifs
1023913498266Sopenharmony_ci
1024013498266Sopenharmony_ci	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
1024113498266Sopenharmony_ci	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
1024213498266Sopenharmony_ci	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
1024313498266Sopenharmony_ci	    fi
1024413498266Sopenharmony_ci	  fi
1024513498266Sopenharmony_ci
1024613498266Sopenharmony_ci          ${skipped_export-false} && {
1024713498266Sopenharmony_ci	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
1024813498266Sopenharmony_ci	      tmp_export_symbols=$export_symbols
1024913498266Sopenharmony_ci	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
1025013498266Sopenharmony_ci	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
1025113498266Sopenharmony_ci	    fi
1025213498266Sopenharmony_ci
1025313498266Sopenharmony_ci	    if test -n "$orig_export_symbols"; then
1025413498266Sopenharmony_ci	      # The given exports_symbols file has to be filtered, so filter it.
1025513498266Sopenharmony_ci	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
1025613498266Sopenharmony_ci	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
1025713498266Sopenharmony_ci	      # 's' commands, which not all seds can handle. GNU sed should be fine
1025813498266Sopenharmony_ci	      # though. Also, the filter scales superlinearly with the number of
1025913498266Sopenharmony_ci	      # global variables. join(1) would be nice here, but unfortunately
1026013498266Sopenharmony_ci	      # isn't a blessed tool.
1026113498266Sopenharmony_ci	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
1026213498266Sopenharmony_ci	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
1026313498266Sopenharmony_ci	      export_symbols=$output_objdir/$libname.def
1026413498266Sopenharmony_ci	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
1026513498266Sopenharmony_ci	    fi
1026613498266Sopenharmony_ci	  }
1026713498266Sopenharmony_ci
1026813498266Sopenharmony_ci	  libobjs=$output
1026913498266Sopenharmony_ci	  # Restore the value of output.
1027013498266Sopenharmony_ci	  output=$save_output
1027113498266Sopenharmony_ci
1027213498266Sopenharmony_ci	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
1027313498266Sopenharmony_ci	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
1027413498266Sopenharmony_ci	    test "X$libobjs" = "X " && libobjs=
1027513498266Sopenharmony_ci	  fi
1027613498266Sopenharmony_ci	  # Expand the library linking commands again to reset the
1027713498266Sopenharmony_ci	  # value of $libobjs for piecewise linking.
1027813498266Sopenharmony_ci
1027913498266Sopenharmony_ci	  # Do each of the archive commands.
1028013498266Sopenharmony_ci	  if test yes = "$module" && test -n "$module_cmds"; then
1028113498266Sopenharmony_ci	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
1028213498266Sopenharmony_ci	      cmds=$module_expsym_cmds
1028313498266Sopenharmony_ci	    else
1028413498266Sopenharmony_ci	      cmds=$module_cmds
1028513498266Sopenharmony_ci	    fi
1028613498266Sopenharmony_ci	  else
1028713498266Sopenharmony_ci	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
1028813498266Sopenharmony_ci	      cmds=$archive_expsym_cmds
1028913498266Sopenharmony_ci	    else
1029013498266Sopenharmony_ci	      cmds=$archive_cmds
1029113498266Sopenharmony_ci	    fi
1029213498266Sopenharmony_ci	  fi
1029313498266Sopenharmony_ci	fi
1029413498266Sopenharmony_ci
1029513498266Sopenharmony_ci	if test -n "$delfiles"; then
1029613498266Sopenharmony_ci	  # Append the command to remove temporary files to $cmds.
1029713498266Sopenharmony_ci	  eval cmds=\"\$cmds~\$RM $delfiles\"
1029813498266Sopenharmony_ci	fi
1029913498266Sopenharmony_ci
1030013498266Sopenharmony_ci	# Add any objects from preloaded convenience libraries
1030113498266Sopenharmony_ci	if test -n "$dlprefiles"; then
1030213498266Sopenharmony_ci	  gentop=$output_objdir/${outputname}x
1030313498266Sopenharmony_ci	  func_append generated " $gentop"
1030413498266Sopenharmony_ci
1030513498266Sopenharmony_ci	  func_extract_archives $gentop $dlprefiles
1030613498266Sopenharmony_ci	  func_append libobjs " $func_extract_archives_result"
1030713498266Sopenharmony_ci	  test "X$libobjs" = "X " && libobjs=
1030813498266Sopenharmony_ci	fi
1030913498266Sopenharmony_ci
1031013498266Sopenharmony_ci	save_ifs=$IFS; IFS='~'
1031113498266Sopenharmony_ci	for cmd in $cmds; do
1031213498266Sopenharmony_ci	  IFS=$sp$nl
1031313498266Sopenharmony_ci	  eval cmd=\"$cmd\"
1031413498266Sopenharmony_ci	  IFS=$save_ifs
1031513498266Sopenharmony_ci	  $opt_quiet || {
1031613498266Sopenharmony_ci	    func_quote_arg expand,pretty "$cmd"
1031713498266Sopenharmony_ci	    eval "func_echo $func_quote_arg_result"
1031813498266Sopenharmony_ci	  }
1031913498266Sopenharmony_ci	  $opt_dry_run || eval "$cmd" || {
1032013498266Sopenharmony_ci	    lt_exit=$?
1032113498266Sopenharmony_ci
1032213498266Sopenharmony_ci	    # Restore the uninstalled library and exit
1032313498266Sopenharmony_ci	    if test relink = "$opt_mode"; then
1032413498266Sopenharmony_ci	      ( cd "$output_objdir" && \
1032513498266Sopenharmony_ci	        $RM "${realname}T" && \
1032613498266Sopenharmony_ci		$MV "${realname}U" "$realname" )
1032713498266Sopenharmony_ci	    fi
1032813498266Sopenharmony_ci
1032913498266Sopenharmony_ci	    exit $lt_exit
1033013498266Sopenharmony_ci	  }
1033113498266Sopenharmony_ci	done
1033213498266Sopenharmony_ci	IFS=$save_ifs
1033313498266Sopenharmony_ci
1033413498266Sopenharmony_ci	# Restore the uninstalled library and exit
1033513498266Sopenharmony_ci	if test relink = "$opt_mode"; then
1033613498266Sopenharmony_ci	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
1033713498266Sopenharmony_ci
1033813498266Sopenharmony_ci	  if test -n "$convenience"; then
1033913498266Sopenharmony_ci	    if test -z "$whole_archive_flag_spec"; then
1034013498266Sopenharmony_ci	      func_show_eval '${RM}r "$gentop"'
1034113498266Sopenharmony_ci	    fi
1034213498266Sopenharmony_ci	  fi
1034313498266Sopenharmony_ci
1034413498266Sopenharmony_ci	  exit $EXIT_SUCCESS
1034513498266Sopenharmony_ci	fi
1034613498266Sopenharmony_ci
1034713498266Sopenharmony_ci	# Create links to the real library.
1034813498266Sopenharmony_ci	for linkname in $linknames; do
1034913498266Sopenharmony_ci	  if test "$realname" != "$linkname"; then
1035013498266Sopenharmony_ci	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
1035113498266Sopenharmony_ci	  fi
1035213498266Sopenharmony_ci	done
1035313498266Sopenharmony_ci
1035413498266Sopenharmony_ci	# If -module or -export-dynamic was specified, set the dlname.
1035513498266Sopenharmony_ci	if test yes = "$module" || test yes = "$export_dynamic"; then
1035613498266Sopenharmony_ci	  # On all known operating systems, these are identical.
1035713498266Sopenharmony_ci	  dlname=$soname
1035813498266Sopenharmony_ci	fi
1035913498266Sopenharmony_ci      fi
1036013498266Sopenharmony_ci      ;;
1036113498266Sopenharmony_ci
1036213498266Sopenharmony_ci    obj)
1036313498266Sopenharmony_ci      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
1036413498266Sopenharmony_ci	func_warning "'-dlopen' is ignored for objects"
1036513498266Sopenharmony_ci      fi
1036613498266Sopenharmony_ci
1036713498266Sopenharmony_ci      case " $deplibs" in
1036813498266Sopenharmony_ci      *\ -l* | *\ -L*)
1036913498266Sopenharmony_ci	func_warning "'-l' and '-L' are ignored for objects" ;;
1037013498266Sopenharmony_ci      esac
1037113498266Sopenharmony_ci
1037213498266Sopenharmony_ci      test -n "$rpath" && \
1037313498266Sopenharmony_ci	func_warning "'-rpath' is ignored for objects"
1037413498266Sopenharmony_ci
1037513498266Sopenharmony_ci      test -n "$xrpath" && \
1037613498266Sopenharmony_ci	func_warning "'-R' is ignored for objects"
1037713498266Sopenharmony_ci
1037813498266Sopenharmony_ci      test -n "$vinfo" && \
1037913498266Sopenharmony_ci	func_warning "'-version-info' is ignored for objects"
1038013498266Sopenharmony_ci
1038113498266Sopenharmony_ci      test -n "$release" && \
1038213498266Sopenharmony_ci	func_warning "'-release' is ignored for objects"
1038313498266Sopenharmony_ci
1038413498266Sopenharmony_ci      case $output in
1038513498266Sopenharmony_ci      *.lo)
1038613498266Sopenharmony_ci	test -n "$objs$old_deplibs" && \
1038713498266Sopenharmony_ci	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
1038813498266Sopenharmony_ci
1038913498266Sopenharmony_ci	libobj=$output
1039013498266Sopenharmony_ci	func_lo2o "$libobj"
1039113498266Sopenharmony_ci	obj=$func_lo2o_result
1039213498266Sopenharmony_ci	;;
1039313498266Sopenharmony_ci      *)
1039413498266Sopenharmony_ci	libobj=
1039513498266Sopenharmony_ci	obj=$output
1039613498266Sopenharmony_ci	;;
1039713498266Sopenharmony_ci      esac
1039813498266Sopenharmony_ci
1039913498266Sopenharmony_ci      # Delete the old objects.
1040013498266Sopenharmony_ci      $opt_dry_run || $RM $obj $libobj
1040113498266Sopenharmony_ci
1040213498266Sopenharmony_ci      # Objects from convenience libraries.  This assumes
1040313498266Sopenharmony_ci      # single-version convenience libraries.  Whenever we create
1040413498266Sopenharmony_ci      # different ones for PIC/non-PIC, this we'll have to duplicate
1040513498266Sopenharmony_ci      # the extraction.
1040613498266Sopenharmony_ci      reload_conv_objs=
1040713498266Sopenharmony_ci      gentop=
1040813498266Sopenharmony_ci      # if reload_cmds runs $LD directly, get rid of -Wl from
1040913498266Sopenharmony_ci      # whole_archive_flag_spec and hope we can get by with turning comma
1041013498266Sopenharmony_ci      # into space.
1041113498266Sopenharmony_ci      case $reload_cmds in
1041213498266Sopenharmony_ci        *\$LD[\ \$]*) wl= ;;
1041313498266Sopenharmony_ci      esac
1041413498266Sopenharmony_ci      if test -n "$convenience"; then
1041513498266Sopenharmony_ci	if test -n "$whole_archive_flag_spec"; then
1041613498266Sopenharmony_ci	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
1041713498266Sopenharmony_ci	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
1041813498266Sopenharmony_ci	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
1041913498266Sopenharmony_ci	else
1042013498266Sopenharmony_ci	  gentop=$output_objdir/${obj}x
1042113498266Sopenharmony_ci	  func_append generated " $gentop"
1042213498266Sopenharmony_ci
1042313498266Sopenharmony_ci	  func_extract_archives $gentop $convenience
1042413498266Sopenharmony_ci	  reload_conv_objs="$reload_objs $func_extract_archives_result"
1042513498266Sopenharmony_ci	fi
1042613498266Sopenharmony_ci      fi
1042713498266Sopenharmony_ci
1042813498266Sopenharmony_ci      # If we're not building shared, we need to use non_pic_objs
1042913498266Sopenharmony_ci      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
1043013498266Sopenharmony_ci
1043113498266Sopenharmony_ci      # Create the old-style object.
1043213498266Sopenharmony_ci      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
1043313498266Sopenharmony_ci
1043413498266Sopenharmony_ci      output=$obj
1043513498266Sopenharmony_ci      func_execute_cmds "$reload_cmds" 'exit $?'
1043613498266Sopenharmony_ci
1043713498266Sopenharmony_ci      # Exit if we aren't doing a library object file.
1043813498266Sopenharmony_ci      if test -z "$libobj"; then
1043913498266Sopenharmony_ci	if test -n "$gentop"; then
1044013498266Sopenharmony_ci	  func_show_eval '${RM}r "$gentop"'
1044113498266Sopenharmony_ci	fi
1044213498266Sopenharmony_ci
1044313498266Sopenharmony_ci	exit $EXIT_SUCCESS
1044413498266Sopenharmony_ci      fi
1044513498266Sopenharmony_ci
1044613498266Sopenharmony_ci      test yes = "$build_libtool_libs" || {
1044713498266Sopenharmony_ci	if test -n "$gentop"; then
1044813498266Sopenharmony_ci	  func_show_eval '${RM}r "$gentop"'
1044913498266Sopenharmony_ci	fi
1045013498266Sopenharmony_ci
1045113498266Sopenharmony_ci	# Create an invalid libtool object if no PIC, so that we don't
1045213498266Sopenharmony_ci	# accidentally link it into a program.
1045313498266Sopenharmony_ci	# $show "echo timestamp > $libobj"
1045413498266Sopenharmony_ci	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
1045513498266Sopenharmony_ci	exit $EXIT_SUCCESS
1045613498266Sopenharmony_ci      }
1045713498266Sopenharmony_ci
1045813498266Sopenharmony_ci      if test -n "$pic_flag" || test default != "$pic_mode"; then
1045913498266Sopenharmony_ci	# Only do commands if we really have different PIC objects.
1046013498266Sopenharmony_ci	reload_objs="$libobjs $reload_conv_objs"
1046113498266Sopenharmony_ci	output=$libobj
1046213498266Sopenharmony_ci	func_execute_cmds "$reload_cmds" 'exit $?'
1046313498266Sopenharmony_ci      fi
1046413498266Sopenharmony_ci
1046513498266Sopenharmony_ci      if test -n "$gentop"; then
1046613498266Sopenharmony_ci	func_show_eval '${RM}r "$gentop"'
1046713498266Sopenharmony_ci      fi
1046813498266Sopenharmony_ci
1046913498266Sopenharmony_ci      exit $EXIT_SUCCESS
1047013498266Sopenharmony_ci      ;;
1047113498266Sopenharmony_ci
1047213498266Sopenharmony_ci    prog)
1047313498266Sopenharmony_ci      case $host in
1047413498266Sopenharmony_ci	*cygwin*) func_stripname '' '.exe' "$output"
1047513498266Sopenharmony_ci	          output=$func_stripname_result.exe;;
1047613498266Sopenharmony_ci      esac
1047713498266Sopenharmony_ci      test -n "$vinfo" && \
1047813498266Sopenharmony_ci	func_warning "'-version-info' is ignored for programs"
1047913498266Sopenharmony_ci
1048013498266Sopenharmony_ci      test -n "$release" && \
1048113498266Sopenharmony_ci	func_warning "'-release' is ignored for programs"
1048213498266Sopenharmony_ci
1048313498266Sopenharmony_ci      $preload \
1048413498266Sopenharmony_ci	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
1048513498266Sopenharmony_ci	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
1048613498266Sopenharmony_ci
1048713498266Sopenharmony_ci      case $host in
1048813498266Sopenharmony_ci      *-*-rhapsody* | *-*-darwin1.[012])
1048913498266Sopenharmony_ci	# On Rhapsody replace the C library is the System framework
1049013498266Sopenharmony_ci	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
1049113498266Sopenharmony_ci	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
1049213498266Sopenharmony_ci	;;
1049313498266Sopenharmony_ci      esac
1049413498266Sopenharmony_ci
1049513498266Sopenharmony_ci      case $host in
1049613498266Sopenharmony_ci      *-*-darwin*)
1049713498266Sopenharmony_ci	# Don't allow lazy linking, it breaks C++ global constructors
1049813498266Sopenharmony_ci	# But is supposedly fixed on 10.4 or later (yay!).
1049913498266Sopenharmony_ci	if test CXX = "$tagname"; then
1050013498266Sopenharmony_ci	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
1050113498266Sopenharmony_ci	    10.[0123])
1050213498266Sopenharmony_ci	      func_append compile_command " $wl-bind_at_load"
1050313498266Sopenharmony_ci	      func_append finalize_command " $wl-bind_at_load"
1050413498266Sopenharmony_ci	    ;;
1050513498266Sopenharmony_ci	  esac
1050613498266Sopenharmony_ci	fi
1050713498266Sopenharmony_ci	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
1050813498266Sopenharmony_ci	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
1050913498266Sopenharmony_ci	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
1051013498266Sopenharmony_ci	;;
1051113498266Sopenharmony_ci      esac
1051213498266Sopenharmony_ci
1051313498266Sopenharmony_ci
1051413498266Sopenharmony_ci      # move library search paths that coincide with paths to not yet
1051513498266Sopenharmony_ci      # installed libraries to the beginning of the library search list
1051613498266Sopenharmony_ci      new_libs=
1051713498266Sopenharmony_ci      for path in $notinst_path; do
1051813498266Sopenharmony_ci	case " $new_libs " in
1051913498266Sopenharmony_ci	*" -L$path/$objdir "*) ;;
1052013498266Sopenharmony_ci	*)
1052113498266Sopenharmony_ci	  case " $compile_deplibs " in
1052213498266Sopenharmony_ci	  *" -L$path/$objdir "*)
1052313498266Sopenharmony_ci	    func_append new_libs " -L$path/$objdir" ;;
1052413498266Sopenharmony_ci	  esac
1052513498266Sopenharmony_ci	  ;;
1052613498266Sopenharmony_ci	esac
1052713498266Sopenharmony_ci      done
1052813498266Sopenharmony_ci      for deplib in $compile_deplibs; do
1052913498266Sopenharmony_ci	case $deplib in
1053013498266Sopenharmony_ci	-L*)
1053113498266Sopenharmony_ci	  case " $new_libs " in
1053213498266Sopenharmony_ci	  *" $deplib "*) ;;
1053313498266Sopenharmony_ci	  *) func_append new_libs " $deplib" ;;
1053413498266Sopenharmony_ci	  esac
1053513498266Sopenharmony_ci	  ;;
1053613498266Sopenharmony_ci	*) func_append new_libs " $deplib" ;;
1053713498266Sopenharmony_ci	esac
1053813498266Sopenharmony_ci      done
1053913498266Sopenharmony_ci      compile_deplibs=$new_libs
1054013498266Sopenharmony_ci
1054113498266Sopenharmony_ci
1054213498266Sopenharmony_ci      func_append compile_command " $compile_deplibs"
1054313498266Sopenharmony_ci      func_append finalize_command " $finalize_deplibs"
1054413498266Sopenharmony_ci
1054513498266Sopenharmony_ci      if test -n "$rpath$xrpath"; then
1054613498266Sopenharmony_ci	# If the user specified any rpath flags, then add them.
1054713498266Sopenharmony_ci	for libdir in $rpath $xrpath; do
1054813498266Sopenharmony_ci	  # This is the magic to use -rpath.
1054913498266Sopenharmony_ci	  case "$finalize_rpath " in
1055013498266Sopenharmony_ci	  *" $libdir "*) ;;
1055113498266Sopenharmony_ci	  *) func_append finalize_rpath " $libdir" ;;
1055213498266Sopenharmony_ci	  esac
1055313498266Sopenharmony_ci	done
1055413498266Sopenharmony_ci      fi
1055513498266Sopenharmony_ci
1055613498266Sopenharmony_ci      # Now hardcode the library paths
1055713498266Sopenharmony_ci      rpath=
1055813498266Sopenharmony_ci      hardcode_libdirs=
1055913498266Sopenharmony_ci      for libdir in $compile_rpath $finalize_rpath; do
1056013498266Sopenharmony_ci	if test -n "$hardcode_libdir_flag_spec"; then
1056113498266Sopenharmony_ci	  if test -n "$hardcode_libdir_separator"; then
1056213498266Sopenharmony_ci	    if test -z "$hardcode_libdirs"; then
1056313498266Sopenharmony_ci	      hardcode_libdirs=$libdir
1056413498266Sopenharmony_ci	    else
1056513498266Sopenharmony_ci	      # Just accumulate the unique libdirs.
1056613498266Sopenharmony_ci	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
1056713498266Sopenharmony_ci	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
1056813498266Sopenharmony_ci		;;
1056913498266Sopenharmony_ci	      *)
1057013498266Sopenharmony_ci		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
1057113498266Sopenharmony_ci		;;
1057213498266Sopenharmony_ci	      esac
1057313498266Sopenharmony_ci	    fi
1057413498266Sopenharmony_ci	  else
1057513498266Sopenharmony_ci	    eval flag=\"$hardcode_libdir_flag_spec\"
1057613498266Sopenharmony_ci	    func_append rpath " $flag"
1057713498266Sopenharmony_ci	  fi
1057813498266Sopenharmony_ci	elif test -n "$runpath_var"; then
1057913498266Sopenharmony_ci	  case "$perm_rpath " in
1058013498266Sopenharmony_ci	  *" $libdir "*) ;;
1058113498266Sopenharmony_ci	  *) func_append perm_rpath " $libdir" ;;
1058213498266Sopenharmony_ci	  esac
1058313498266Sopenharmony_ci	fi
1058413498266Sopenharmony_ci	case $host in
1058513498266Sopenharmony_ci	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
1058613498266Sopenharmony_ci	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
1058713498266Sopenharmony_ci	  case :$dllsearchpath: in
1058813498266Sopenharmony_ci	  *":$libdir:"*) ;;
1058913498266Sopenharmony_ci	  ::) dllsearchpath=$libdir;;
1059013498266Sopenharmony_ci	  *) func_append dllsearchpath ":$libdir";;
1059113498266Sopenharmony_ci	  esac
1059213498266Sopenharmony_ci	  case :$dllsearchpath: in
1059313498266Sopenharmony_ci	  *":$testbindir:"*) ;;
1059413498266Sopenharmony_ci	  ::) dllsearchpath=$testbindir;;
1059513498266Sopenharmony_ci	  *) func_append dllsearchpath ":$testbindir";;
1059613498266Sopenharmony_ci	  esac
1059713498266Sopenharmony_ci	  ;;
1059813498266Sopenharmony_ci	esac
1059913498266Sopenharmony_ci      done
1060013498266Sopenharmony_ci      # Substitute the hardcoded libdirs into the rpath.
1060113498266Sopenharmony_ci      if test -n "$hardcode_libdir_separator" &&
1060213498266Sopenharmony_ci	 test -n "$hardcode_libdirs"; then
1060313498266Sopenharmony_ci	libdir=$hardcode_libdirs
1060413498266Sopenharmony_ci	eval rpath=\" $hardcode_libdir_flag_spec\"
1060513498266Sopenharmony_ci      fi
1060613498266Sopenharmony_ci      compile_rpath=$rpath
1060713498266Sopenharmony_ci
1060813498266Sopenharmony_ci      rpath=
1060913498266Sopenharmony_ci      hardcode_libdirs=
1061013498266Sopenharmony_ci      for libdir in $finalize_rpath; do
1061113498266Sopenharmony_ci	if test -n "$hardcode_libdir_flag_spec"; then
1061213498266Sopenharmony_ci	  if test -n "$hardcode_libdir_separator"; then
1061313498266Sopenharmony_ci	    if test -z "$hardcode_libdirs"; then
1061413498266Sopenharmony_ci	      hardcode_libdirs=$libdir
1061513498266Sopenharmony_ci	    else
1061613498266Sopenharmony_ci	      # Just accumulate the unique libdirs.
1061713498266Sopenharmony_ci	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
1061813498266Sopenharmony_ci	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
1061913498266Sopenharmony_ci		;;
1062013498266Sopenharmony_ci	      *)
1062113498266Sopenharmony_ci		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
1062213498266Sopenharmony_ci		;;
1062313498266Sopenharmony_ci	      esac
1062413498266Sopenharmony_ci	    fi
1062513498266Sopenharmony_ci	  else
1062613498266Sopenharmony_ci	    eval flag=\"$hardcode_libdir_flag_spec\"
1062713498266Sopenharmony_ci	    func_append rpath " $flag"
1062813498266Sopenharmony_ci	  fi
1062913498266Sopenharmony_ci	elif test -n "$runpath_var"; then
1063013498266Sopenharmony_ci	  case "$finalize_perm_rpath " in
1063113498266Sopenharmony_ci	  *" $libdir "*) ;;
1063213498266Sopenharmony_ci	  *) func_append finalize_perm_rpath " $libdir" ;;
1063313498266Sopenharmony_ci	  esac
1063413498266Sopenharmony_ci	fi
1063513498266Sopenharmony_ci      done
1063613498266Sopenharmony_ci      # Substitute the hardcoded libdirs into the rpath.
1063713498266Sopenharmony_ci      if test -n "$hardcode_libdir_separator" &&
1063813498266Sopenharmony_ci	 test -n "$hardcode_libdirs"; then
1063913498266Sopenharmony_ci	libdir=$hardcode_libdirs
1064013498266Sopenharmony_ci	eval rpath=\" $hardcode_libdir_flag_spec\"
1064113498266Sopenharmony_ci      fi
1064213498266Sopenharmony_ci      finalize_rpath=$rpath
1064313498266Sopenharmony_ci
1064413498266Sopenharmony_ci      if test -n "$libobjs" && test yes = "$build_old_libs"; then
1064513498266Sopenharmony_ci	# Transform all the library objects into standard objects.
1064613498266Sopenharmony_ci	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
1064713498266Sopenharmony_ci	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
1064813498266Sopenharmony_ci      fi
1064913498266Sopenharmony_ci
1065013498266Sopenharmony_ci      func_generate_dlsyms "$outputname" "@PROGRAM@" false
1065113498266Sopenharmony_ci
1065213498266Sopenharmony_ci      # template prelinking step
1065313498266Sopenharmony_ci      if test -n "$prelink_cmds"; then
1065413498266Sopenharmony_ci	func_execute_cmds "$prelink_cmds" 'exit $?'
1065513498266Sopenharmony_ci      fi
1065613498266Sopenharmony_ci
1065713498266Sopenharmony_ci      wrappers_required=:
1065813498266Sopenharmony_ci      case $host in
1065913498266Sopenharmony_ci      *cegcc* | *mingw32ce*)
1066013498266Sopenharmony_ci        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
1066113498266Sopenharmony_ci        wrappers_required=false
1066213498266Sopenharmony_ci        ;;
1066313498266Sopenharmony_ci      *cygwin* | *mingw* )
1066413498266Sopenharmony_ci        test yes = "$build_libtool_libs" || wrappers_required=false
1066513498266Sopenharmony_ci        ;;
1066613498266Sopenharmony_ci      *)
1066713498266Sopenharmony_ci        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
1066813498266Sopenharmony_ci          wrappers_required=false
1066913498266Sopenharmony_ci        fi
1067013498266Sopenharmony_ci        ;;
1067113498266Sopenharmony_ci      esac
1067213498266Sopenharmony_ci      $wrappers_required || {
1067313498266Sopenharmony_ci	# Replace the output file specification.
1067413498266Sopenharmony_ci	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
1067513498266Sopenharmony_ci	link_command=$compile_command$compile_rpath
1067613498266Sopenharmony_ci
1067713498266Sopenharmony_ci	# We have no uninstalled library dependencies, so finalize right now.
1067813498266Sopenharmony_ci	exit_status=0
1067913498266Sopenharmony_ci	func_show_eval "$link_command" 'exit_status=$?'
1068013498266Sopenharmony_ci
1068113498266Sopenharmony_ci	if test -n "$postlink_cmds"; then
1068213498266Sopenharmony_ci	  func_to_tool_file "$output"
1068313498266Sopenharmony_ci	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
1068413498266Sopenharmony_ci	  func_execute_cmds "$postlink_cmds" 'exit $?'
1068513498266Sopenharmony_ci	fi
1068613498266Sopenharmony_ci
1068713498266Sopenharmony_ci	# Delete the generated files.
1068813498266Sopenharmony_ci	if test -f "$output_objdir/${outputname}S.$objext"; then
1068913498266Sopenharmony_ci	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
1069013498266Sopenharmony_ci	fi
1069113498266Sopenharmony_ci
1069213498266Sopenharmony_ci	exit $exit_status
1069313498266Sopenharmony_ci      }
1069413498266Sopenharmony_ci
1069513498266Sopenharmony_ci      if test -n "$compile_shlibpath$finalize_shlibpath"; then
1069613498266Sopenharmony_ci	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
1069713498266Sopenharmony_ci      fi
1069813498266Sopenharmony_ci      if test -n "$finalize_shlibpath"; then
1069913498266Sopenharmony_ci	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
1070013498266Sopenharmony_ci      fi
1070113498266Sopenharmony_ci
1070213498266Sopenharmony_ci      compile_var=
1070313498266Sopenharmony_ci      finalize_var=
1070413498266Sopenharmony_ci      if test -n "$runpath_var"; then
1070513498266Sopenharmony_ci	if test -n "$perm_rpath"; then
1070613498266Sopenharmony_ci	  # We should set the runpath_var.
1070713498266Sopenharmony_ci	  rpath=
1070813498266Sopenharmony_ci	  for dir in $perm_rpath; do
1070913498266Sopenharmony_ci	    func_append rpath "$dir:"
1071013498266Sopenharmony_ci	  done
1071113498266Sopenharmony_ci	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
1071213498266Sopenharmony_ci	fi
1071313498266Sopenharmony_ci	if test -n "$finalize_perm_rpath"; then
1071413498266Sopenharmony_ci	  # We should set the runpath_var.
1071513498266Sopenharmony_ci	  rpath=
1071613498266Sopenharmony_ci	  for dir in $finalize_perm_rpath; do
1071713498266Sopenharmony_ci	    func_append rpath "$dir:"
1071813498266Sopenharmony_ci	  done
1071913498266Sopenharmony_ci	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
1072013498266Sopenharmony_ci	fi
1072113498266Sopenharmony_ci      fi
1072213498266Sopenharmony_ci
1072313498266Sopenharmony_ci      if test yes = "$no_install"; then
1072413498266Sopenharmony_ci	# We don't need to create a wrapper script.
1072513498266Sopenharmony_ci	link_command=$compile_var$compile_command$compile_rpath
1072613498266Sopenharmony_ci	# Replace the output file specification.
1072713498266Sopenharmony_ci	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
1072813498266Sopenharmony_ci	# Delete the old output file.
1072913498266Sopenharmony_ci	$opt_dry_run || $RM $output
1073013498266Sopenharmony_ci	# Link the executable and exit
1073113498266Sopenharmony_ci	func_show_eval "$link_command" 'exit $?'
1073213498266Sopenharmony_ci
1073313498266Sopenharmony_ci	if test -n "$postlink_cmds"; then
1073413498266Sopenharmony_ci	  func_to_tool_file "$output"
1073513498266Sopenharmony_ci	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
1073613498266Sopenharmony_ci	  func_execute_cmds "$postlink_cmds" 'exit $?'
1073713498266Sopenharmony_ci	fi
1073813498266Sopenharmony_ci
1073913498266Sopenharmony_ci	exit $EXIT_SUCCESS
1074013498266Sopenharmony_ci      fi
1074113498266Sopenharmony_ci
1074213498266Sopenharmony_ci      case $hardcode_action,$fast_install in
1074313498266Sopenharmony_ci        relink,*)
1074413498266Sopenharmony_ci	  # Fast installation is not supported
1074513498266Sopenharmony_ci	  link_command=$compile_var$compile_command$compile_rpath
1074613498266Sopenharmony_ci	  relink_command=$finalize_var$finalize_command$finalize_rpath
1074713498266Sopenharmony_ci
1074813498266Sopenharmony_ci	  func_warning "this platform does not like uninstalled shared libraries"
1074913498266Sopenharmony_ci	  func_warning "'$output' will be relinked during installation"
1075013498266Sopenharmony_ci	  ;;
1075113498266Sopenharmony_ci        *,yes)
1075213498266Sopenharmony_ci	  link_command=$finalize_var$compile_command$finalize_rpath
1075313498266Sopenharmony_ci	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
1075413498266Sopenharmony_ci          ;;
1075513498266Sopenharmony_ci	*,no)
1075613498266Sopenharmony_ci	  link_command=$compile_var$compile_command$compile_rpath
1075713498266Sopenharmony_ci	  relink_command=$finalize_var$finalize_command$finalize_rpath
1075813498266Sopenharmony_ci          ;;
1075913498266Sopenharmony_ci	*,needless)
1076013498266Sopenharmony_ci	  link_command=$finalize_var$compile_command$finalize_rpath
1076113498266Sopenharmony_ci	  relink_command=
1076213498266Sopenharmony_ci          ;;
1076313498266Sopenharmony_ci      esac
1076413498266Sopenharmony_ci
1076513498266Sopenharmony_ci      # Replace the output file specification.
1076613498266Sopenharmony_ci      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
1076713498266Sopenharmony_ci
1076813498266Sopenharmony_ci      # Delete the old output files.
1076913498266Sopenharmony_ci      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
1077013498266Sopenharmony_ci
1077113498266Sopenharmony_ci      func_show_eval "$link_command" 'exit $?'
1077213498266Sopenharmony_ci
1077313498266Sopenharmony_ci      if test -n "$postlink_cmds"; then
1077413498266Sopenharmony_ci	func_to_tool_file "$output_objdir/$outputname"
1077513498266Sopenharmony_ci	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'`
1077613498266Sopenharmony_ci	func_execute_cmds "$postlink_cmds" 'exit $?'
1077713498266Sopenharmony_ci      fi
1077813498266Sopenharmony_ci
1077913498266Sopenharmony_ci      # Now create the wrapper script.
1078013498266Sopenharmony_ci      func_verbose "creating $output"
1078113498266Sopenharmony_ci
1078213498266Sopenharmony_ci      # Quote the relink command for shipping.
1078313498266Sopenharmony_ci      if test -n "$relink_command"; then
1078413498266Sopenharmony_ci	# Preserve any variables that may affect compiler behavior
1078513498266Sopenharmony_ci	for var in $variables_saved_for_relink; do
1078613498266Sopenharmony_ci	  if eval test -z \"\${$var+set}\"; then
1078713498266Sopenharmony_ci	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
1078813498266Sopenharmony_ci	  elif eval var_value=\$$var; test -z "$var_value"; then
1078913498266Sopenharmony_ci	    relink_command="$var=; export $var; $relink_command"
1079013498266Sopenharmony_ci	  else
1079113498266Sopenharmony_ci	    func_quote_arg pretty "$var_value"
1079213498266Sopenharmony_ci	    relink_command="$var=$func_quote_arg_result; export $var; $relink_command"
1079313498266Sopenharmony_ci	  fi
1079413498266Sopenharmony_ci	done
1079513498266Sopenharmony_ci	func_quote eval cd "`pwd`"
1079613498266Sopenharmony_ci	func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)"
1079713498266Sopenharmony_ci	relink_command=$func_quote_arg_unquoted_result
1079813498266Sopenharmony_ci      fi
1079913498266Sopenharmony_ci
1080013498266Sopenharmony_ci      # Only actually do things if not in dry run mode.
1080113498266Sopenharmony_ci      $opt_dry_run || {
1080213498266Sopenharmony_ci	# win32 will think the script is a binary if it has
1080313498266Sopenharmony_ci	# a .exe suffix, so we strip it off here.
1080413498266Sopenharmony_ci	case $output in
1080513498266Sopenharmony_ci	  *.exe) func_stripname '' '.exe' "$output"
1080613498266Sopenharmony_ci	         output=$func_stripname_result ;;
1080713498266Sopenharmony_ci	esac
1080813498266Sopenharmony_ci	# test for cygwin because mv fails w/o .exe extensions
1080913498266Sopenharmony_ci	case $host in
1081013498266Sopenharmony_ci	  *cygwin*)
1081113498266Sopenharmony_ci	    exeext=.exe
1081213498266Sopenharmony_ci	    func_stripname '' '.exe' "$outputname"
1081313498266Sopenharmony_ci	    outputname=$func_stripname_result ;;
1081413498266Sopenharmony_ci	  *) exeext= ;;
1081513498266Sopenharmony_ci	esac
1081613498266Sopenharmony_ci	case $host in
1081713498266Sopenharmony_ci	  *cygwin* | *mingw* )
1081813498266Sopenharmony_ci	    func_dirname_and_basename "$output" "" "."
1081913498266Sopenharmony_ci	    output_name=$func_basename_result
1082013498266Sopenharmony_ci	    output_path=$func_dirname_result
1082113498266Sopenharmony_ci	    cwrappersource=$output_path/$objdir/lt-$output_name.c
1082213498266Sopenharmony_ci	    cwrapper=$output_path/$output_name.exe
1082313498266Sopenharmony_ci	    $RM $cwrappersource $cwrapper
1082413498266Sopenharmony_ci	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
1082513498266Sopenharmony_ci
1082613498266Sopenharmony_ci	    func_emit_cwrapperexe_src > $cwrappersource
1082713498266Sopenharmony_ci
1082813498266Sopenharmony_ci	    # The wrapper executable is built using the $host compiler,
1082913498266Sopenharmony_ci	    # because it contains $host paths and files. If cross-
1083013498266Sopenharmony_ci	    # compiling, it, like the target executable, must be
1083113498266Sopenharmony_ci	    # executed on the $host or under an emulation environment.
1083213498266Sopenharmony_ci	    $opt_dry_run || {
1083313498266Sopenharmony_ci	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
1083413498266Sopenharmony_ci	      $STRIP $cwrapper
1083513498266Sopenharmony_ci	    }
1083613498266Sopenharmony_ci
1083713498266Sopenharmony_ci	    # Now, create the wrapper script for func_source use:
1083813498266Sopenharmony_ci	    func_ltwrapper_scriptname $cwrapper
1083913498266Sopenharmony_ci	    $RM $func_ltwrapper_scriptname_result
1084013498266Sopenharmony_ci	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
1084113498266Sopenharmony_ci	    $opt_dry_run || {
1084213498266Sopenharmony_ci	      # note: this script will not be executed, so do not chmod.
1084313498266Sopenharmony_ci	      if test "x$build" = "x$host"; then
1084413498266Sopenharmony_ci		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
1084513498266Sopenharmony_ci	      else
1084613498266Sopenharmony_ci		func_emit_wrapper no > $func_ltwrapper_scriptname_result
1084713498266Sopenharmony_ci	      fi
1084813498266Sopenharmony_ci	    }
1084913498266Sopenharmony_ci	  ;;
1085013498266Sopenharmony_ci	  * )
1085113498266Sopenharmony_ci	    $RM $output
1085213498266Sopenharmony_ci	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
1085313498266Sopenharmony_ci
1085413498266Sopenharmony_ci	    func_emit_wrapper no > $output
1085513498266Sopenharmony_ci	    chmod +x $output
1085613498266Sopenharmony_ci	  ;;
1085713498266Sopenharmony_ci	esac
1085813498266Sopenharmony_ci      }
1085913498266Sopenharmony_ci      exit $EXIT_SUCCESS
1086013498266Sopenharmony_ci      ;;
1086113498266Sopenharmony_ci    esac
1086213498266Sopenharmony_ci
1086313498266Sopenharmony_ci    # See if we need to build an old-fashioned archive.
1086413498266Sopenharmony_ci    for oldlib in $oldlibs; do
1086513498266Sopenharmony_ci
1086613498266Sopenharmony_ci      case $build_libtool_libs in
1086713498266Sopenharmony_ci        convenience)
1086813498266Sopenharmony_ci	  oldobjs="$libobjs_save $symfileobj"
1086913498266Sopenharmony_ci	  addlibs=$convenience
1087013498266Sopenharmony_ci	  build_libtool_libs=no
1087113498266Sopenharmony_ci	  ;;
1087213498266Sopenharmony_ci	module)
1087313498266Sopenharmony_ci	  oldobjs=$libobjs_save
1087413498266Sopenharmony_ci	  addlibs=$old_convenience
1087513498266Sopenharmony_ci	  build_libtool_libs=no
1087613498266Sopenharmony_ci          ;;
1087713498266Sopenharmony_ci	*)
1087813498266Sopenharmony_ci	  oldobjs="$old_deplibs $non_pic_objects"
1087913498266Sopenharmony_ci	  $preload && test -f "$symfileobj" \
1088013498266Sopenharmony_ci	    && func_append oldobjs " $symfileobj"
1088113498266Sopenharmony_ci	  addlibs=$old_convenience
1088213498266Sopenharmony_ci	  ;;
1088313498266Sopenharmony_ci      esac
1088413498266Sopenharmony_ci
1088513498266Sopenharmony_ci      if test -n "$addlibs"; then
1088613498266Sopenharmony_ci	gentop=$output_objdir/${outputname}x
1088713498266Sopenharmony_ci	func_append generated " $gentop"
1088813498266Sopenharmony_ci
1088913498266Sopenharmony_ci	func_extract_archives $gentop $addlibs
1089013498266Sopenharmony_ci	func_append oldobjs " $func_extract_archives_result"
1089113498266Sopenharmony_ci      fi
1089213498266Sopenharmony_ci
1089313498266Sopenharmony_ci      # Do each command in the archive commands.
1089413498266Sopenharmony_ci      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
1089513498266Sopenharmony_ci	cmds=$old_archive_from_new_cmds
1089613498266Sopenharmony_ci      else
1089713498266Sopenharmony_ci
1089813498266Sopenharmony_ci	# Add any objects from preloaded convenience libraries
1089913498266Sopenharmony_ci	if test -n "$dlprefiles"; then
1090013498266Sopenharmony_ci	  gentop=$output_objdir/${outputname}x
1090113498266Sopenharmony_ci	  func_append generated " $gentop"
1090213498266Sopenharmony_ci
1090313498266Sopenharmony_ci	  func_extract_archives $gentop $dlprefiles
1090413498266Sopenharmony_ci	  func_append oldobjs " $func_extract_archives_result"
1090513498266Sopenharmony_ci	fi
1090613498266Sopenharmony_ci
1090713498266Sopenharmony_ci	# POSIX demands no paths to be encoded in archives.  We have
1090813498266Sopenharmony_ci	# to avoid creating archives with duplicate basenames if we
1090913498266Sopenharmony_ci	# might have to extract them afterwards, e.g., when creating a
1091013498266Sopenharmony_ci	# static archive out of a convenience library, or when linking
1091113498266Sopenharmony_ci	# the entirety of a libtool archive into another (currently
1091213498266Sopenharmony_ci	# not supported by libtool).
1091313498266Sopenharmony_ci	if (for obj in $oldobjs
1091413498266Sopenharmony_ci	    do
1091513498266Sopenharmony_ci	      func_basename "$obj"
1091613498266Sopenharmony_ci	      $ECHO "$func_basename_result"
1091713498266Sopenharmony_ci	    done | sort | sort -uc >/dev/null 2>&1); then
1091813498266Sopenharmony_ci	  :
1091913498266Sopenharmony_ci	else
1092013498266Sopenharmony_ci	  echo "copying selected object files to avoid basename conflicts..."
1092113498266Sopenharmony_ci	  gentop=$output_objdir/${outputname}x
1092213498266Sopenharmony_ci	  func_append generated " $gentop"
1092313498266Sopenharmony_ci	  func_mkdir_p "$gentop"
1092413498266Sopenharmony_ci	  save_oldobjs=$oldobjs
1092513498266Sopenharmony_ci	  oldobjs=
1092613498266Sopenharmony_ci	  counter=1
1092713498266Sopenharmony_ci	  for obj in $save_oldobjs
1092813498266Sopenharmony_ci	  do
1092913498266Sopenharmony_ci	    func_basename "$obj"
1093013498266Sopenharmony_ci	    objbase=$func_basename_result
1093113498266Sopenharmony_ci	    case " $oldobjs " in
1093213498266Sopenharmony_ci	    " ") oldobjs=$obj ;;
1093313498266Sopenharmony_ci	    *[\ /]"$objbase "*)
1093413498266Sopenharmony_ci	      while :; do
1093513498266Sopenharmony_ci		# Make sure we don't pick an alternate name that also
1093613498266Sopenharmony_ci		# overlaps.
1093713498266Sopenharmony_ci		newobj=lt$counter-$objbase
1093813498266Sopenharmony_ci		func_arith $counter + 1
1093913498266Sopenharmony_ci		counter=$func_arith_result
1094013498266Sopenharmony_ci		case " $oldobjs " in
1094113498266Sopenharmony_ci		*[\ /]"$newobj "*) ;;
1094213498266Sopenharmony_ci		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
1094313498266Sopenharmony_ci		esac
1094413498266Sopenharmony_ci	      done
1094513498266Sopenharmony_ci	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
1094613498266Sopenharmony_ci	      func_append oldobjs " $gentop/$newobj"
1094713498266Sopenharmony_ci	      ;;
1094813498266Sopenharmony_ci	    *) func_append oldobjs " $obj" ;;
1094913498266Sopenharmony_ci	    esac
1095013498266Sopenharmony_ci	  done
1095113498266Sopenharmony_ci	fi
1095213498266Sopenharmony_ci	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
1095313498266Sopenharmony_ci	tool_oldlib=$func_to_tool_file_result
1095413498266Sopenharmony_ci	eval cmds=\"$old_archive_cmds\"
1095513498266Sopenharmony_ci
1095613498266Sopenharmony_ci	func_len " $cmds"
1095713498266Sopenharmony_ci	len=$func_len_result
1095813498266Sopenharmony_ci	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
1095913498266Sopenharmony_ci	  cmds=$old_archive_cmds
1096013498266Sopenharmony_ci	elif test -n "$archiver_list_spec"; then
1096113498266Sopenharmony_ci	  func_verbose "using command file archive linking..."
1096213498266Sopenharmony_ci	  for obj in $oldobjs
1096313498266Sopenharmony_ci	  do
1096413498266Sopenharmony_ci	    func_to_tool_file "$obj"
1096513498266Sopenharmony_ci	    $ECHO "$func_to_tool_file_result"
1096613498266Sopenharmony_ci	  done > $output_objdir/$libname.libcmd
1096713498266Sopenharmony_ci	  func_to_tool_file "$output_objdir/$libname.libcmd"
1096813498266Sopenharmony_ci	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
1096913498266Sopenharmony_ci	  cmds=$old_archive_cmds
1097013498266Sopenharmony_ci	else
1097113498266Sopenharmony_ci	  # the command line is too long to link in one step, link in parts
1097213498266Sopenharmony_ci	  func_verbose "using piecewise archive linking..."
1097313498266Sopenharmony_ci	  save_RANLIB=$RANLIB
1097413498266Sopenharmony_ci	  RANLIB=:
1097513498266Sopenharmony_ci	  objlist=
1097613498266Sopenharmony_ci	  concat_cmds=
1097713498266Sopenharmony_ci	  save_oldobjs=$oldobjs
1097813498266Sopenharmony_ci	  oldobjs=
1097913498266Sopenharmony_ci	  # Is there a better way of finding the last object in the list?
1098013498266Sopenharmony_ci	  for obj in $save_oldobjs
1098113498266Sopenharmony_ci	  do
1098213498266Sopenharmony_ci	    last_oldobj=$obj
1098313498266Sopenharmony_ci	  done
1098413498266Sopenharmony_ci	  eval test_cmds=\"$old_archive_cmds\"
1098513498266Sopenharmony_ci	  func_len " $test_cmds"
1098613498266Sopenharmony_ci	  len0=$func_len_result
1098713498266Sopenharmony_ci	  len=$len0
1098813498266Sopenharmony_ci	  for obj in $save_oldobjs
1098913498266Sopenharmony_ci	  do
1099013498266Sopenharmony_ci	    func_len " $obj"
1099113498266Sopenharmony_ci	    func_arith $len + $func_len_result
1099213498266Sopenharmony_ci	    len=$func_arith_result
1099313498266Sopenharmony_ci	    func_append objlist " $obj"
1099413498266Sopenharmony_ci	    if test "$len" -lt "$max_cmd_len"; then
1099513498266Sopenharmony_ci	      :
1099613498266Sopenharmony_ci	    else
1099713498266Sopenharmony_ci	      # the above command should be used before it gets too long
1099813498266Sopenharmony_ci	      oldobjs=$objlist
1099913498266Sopenharmony_ci	      if test "$obj" = "$last_oldobj"; then
1100013498266Sopenharmony_ci		RANLIB=$save_RANLIB
1100113498266Sopenharmony_ci	      fi
1100213498266Sopenharmony_ci	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
1100313498266Sopenharmony_ci	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
1100413498266Sopenharmony_ci	      objlist=
1100513498266Sopenharmony_ci	      len=$len0
1100613498266Sopenharmony_ci	    fi
1100713498266Sopenharmony_ci	  done
1100813498266Sopenharmony_ci	  RANLIB=$save_RANLIB
1100913498266Sopenharmony_ci	  oldobjs=$objlist
1101013498266Sopenharmony_ci	  if test -z "$oldobjs"; then
1101113498266Sopenharmony_ci	    eval cmds=\"\$concat_cmds\"
1101213498266Sopenharmony_ci	  else
1101313498266Sopenharmony_ci	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
1101413498266Sopenharmony_ci	  fi
1101513498266Sopenharmony_ci	fi
1101613498266Sopenharmony_ci      fi
1101713498266Sopenharmony_ci      func_execute_cmds "$cmds" 'exit $?'
1101813498266Sopenharmony_ci    done
1101913498266Sopenharmony_ci
1102013498266Sopenharmony_ci    test -n "$generated" && \
1102113498266Sopenharmony_ci      func_show_eval "${RM}r$generated"
1102213498266Sopenharmony_ci
1102313498266Sopenharmony_ci    # Now create the libtool archive.
1102413498266Sopenharmony_ci    case $output in
1102513498266Sopenharmony_ci    *.la)
1102613498266Sopenharmony_ci      old_library=
1102713498266Sopenharmony_ci      test yes = "$build_old_libs" && old_library=$libname.$libext
1102813498266Sopenharmony_ci      func_verbose "creating $output"
1102913498266Sopenharmony_ci
1103013498266Sopenharmony_ci      # Preserve any variables that may affect compiler behavior
1103113498266Sopenharmony_ci      for var in $variables_saved_for_relink; do
1103213498266Sopenharmony_ci	if eval test -z \"\${$var+set}\"; then
1103313498266Sopenharmony_ci	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
1103413498266Sopenharmony_ci	elif eval var_value=\$$var; test -z "$var_value"; then
1103513498266Sopenharmony_ci	  relink_command="$var=; export $var; $relink_command"
1103613498266Sopenharmony_ci	else
1103713498266Sopenharmony_ci	  func_quote_arg pretty,unquoted "$var_value"
1103813498266Sopenharmony_ci	  relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command"
1103913498266Sopenharmony_ci	fi
1104013498266Sopenharmony_ci      done
1104113498266Sopenharmony_ci      # Quote the link command for shipping.
1104213498266Sopenharmony_ci      func_quote eval cd "`pwd`"
1104313498266Sopenharmony_ci      relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
1104413498266Sopenharmony_ci      func_quote_arg pretty,unquoted "$relink_command"
1104513498266Sopenharmony_ci      relink_command=$func_quote_arg_unquoted_result
1104613498266Sopenharmony_ci      if test yes = "$hardcode_automatic"; then
1104713498266Sopenharmony_ci	relink_command=
1104813498266Sopenharmony_ci      fi
1104913498266Sopenharmony_ci
1105013498266Sopenharmony_ci      # Only create the output if not a dry run.
1105113498266Sopenharmony_ci      $opt_dry_run || {
1105213498266Sopenharmony_ci	for installed in no yes; do
1105313498266Sopenharmony_ci	  if test yes = "$installed"; then
1105413498266Sopenharmony_ci	    if test -z "$install_libdir"; then
1105513498266Sopenharmony_ci	      break
1105613498266Sopenharmony_ci	    fi
1105713498266Sopenharmony_ci	    output=$output_objdir/${outputname}i
1105813498266Sopenharmony_ci	    # Replace all uninstalled libtool libraries with the installed ones
1105913498266Sopenharmony_ci	    newdependency_libs=
1106013498266Sopenharmony_ci	    for deplib in $dependency_libs; do
1106113498266Sopenharmony_ci	      case $deplib in
1106213498266Sopenharmony_ci	      *.la)
1106313498266Sopenharmony_ci		func_basename "$deplib"
1106413498266Sopenharmony_ci		name=$func_basename_result
1106513498266Sopenharmony_ci		func_resolve_sysroot "$deplib"
1106613498266Sopenharmony_ci		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
1106713498266Sopenharmony_ci		test -z "$libdir" && \
1106813498266Sopenharmony_ci		  func_fatal_error "'$deplib' is not a valid libtool archive"
1106913498266Sopenharmony_ci		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
1107013498266Sopenharmony_ci		;;
1107113498266Sopenharmony_ci	      -L*)
1107213498266Sopenharmony_ci		func_stripname -L '' "$deplib"
1107313498266Sopenharmony_ci		func_replace_sysroot "$func_stripname_result"
1107413498266Sopenharmony_ci		func_append newdependency_libs " -L$func_replace_sysroot_result"
1107513498266Sopenharmony_ci		;;
1107613498266Sopenharmony_ci	      -R*)
1107713498266Sopenharmony_ci		func_stripname -R '' "$deplib"
1107813498266Sopenharmony_ci		func_replace_sysroot "$func_stripname_result"
1107913498266Sopenharmony_ci		func_append newdependency_libs " -R$func_replace_sysroot_result"
1108013498266Sopenharmony_ci		;;
1108113498266Sopenharmony_ci	      *) func_append newdependency_libs " $deplib" ;;
1108213498266Sopenharmony_ci	      esac
1108313498266Sopenharmony_ci	    done
1108413498266Sopenharmony_ci	    dependency_libs=$newdependency_libs
1108513498266Sopenharmony_ci	    newdlfiles=
1108613498266Sopenharmony_ci
1108713498266Sopenharmony_ci	    for lib in $dlfiles; do
1108813498266Sopenharmony_ci	      case $lib in
1108913498266Sopenharmony_ci	      *.la)
1109013498266Sopenharmony_ci	        func_basename "$lib"
1109113498266Sopenharmony_ci		name=$func_basename_result
1109213498266Sopenharmony_ci		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
1109313498266Sopenharmony_ci		test -z "$libdir" && \
1109413498266Sopenharmony_ci		  func_fatal_error "'$lib' is not a valid libtool archive"
1109513498266Sopenharmony_ci		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
1109613498266Sopenharmony_ci		;;
1109713498266Sopenharmony_ci	      *) func_append newdlfiles " $lib" ;;
1109813498266Sopenharmony_ci	      esac
1109913498266Sopenharmony_ci	    done
1110013498266Sopenharmony_ci	    dlfiles=$newdlfiles
1110113498266Sopenharmony_ci	    newdlprefiles=
1110213498266Sopenharmony_ci	    for lib in $dlprefiles; do
1110313498266Sopenharmony_ci	      case $lib in
1110413498266Sopenharmony_ci	      *.la)
1110513498266Sopenharmony_ci		# Only pass preopened files to the pseudo-archive (for
1110613498266Sopenharmony_ci		# eventual linking with the app. that links it) if we
1110713498266Sopenharmony_ci		# didn't already link the preopened objects directly into
1110813498266Sopenharmony_ci		# the library:
1110913498266Sopenharmony_ci		func_basename "$lib"
1111013498266Sopenharmony_ci		name=$func_basename_result
1111113498266Sopenharmony_ci		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
1111213498266Sopenharmony_ci		test -z "$libdir" && \
1111313498266Sopenharmony_ci		  func_fatal_error "'$lib' is not a valid libtool archive"
1111413498266Sopenharmony_ci		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
1111513498266Sopenharmony_ci		;;
1111613498266Sopenharmony_ci	      esac
1111713498266Sopenharmony_ci	    done
1111813498266Sopenharmony_ci	    dlprefiles=$newdlprefiles
1111913498266Sopenharmony_ci	  else
1112013498266Sopenharmony_ci	    newdlfiles=
1112113498266Sopenharmony_ci	    for lib in $dlfiles; do
1112213498266Sopenharmony_ci	      case $lib in
1112313498266Sopenharmony_ci		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
1112413498266Sopenharmony_ci		*) abs=`pwd`"/$lib" ;;
1112513498266Sopenharmony_ci	      esac
1112613498266Sopenharmony_ci	      func_append newdlfiles " $abs"
1112713498266Sopenharmony_ci	    done
1112813498266Sopenharmony_ci	    dlfiles=$newdlfiles
1112913498266Sopenharmony_ci	    newdlprefiles=
1113013498266Sopenharmony_ci	    for lib in $dlprefiles; do
1113113498266Sopenharmony_ci	      case $lib in
1113213498266Sopenharmony_ci		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
1113313498266Sopenharmony_ci		*) abs=`pwd`"/$lib" ;;
1113413498266Sopenharmony_ci	      esac
1113513498266Sopenharmony_ci	      func_append newdlprefiles " $abs"
1113613498266Sopenharmony_ci	    done
1113713498266Sopenharmony_ci	    dlprefiles=$newdlprefiles
1113813498266Sopenharmony_ci	  fi
1113913498266Sopenharmony_ci	  $RM $output
1114013498266Sopenharmony_ci	  # place dlname in correct position for cygwin
1114113498266Sopenharmony_ci	  # In fact, it would be nice if we could use this code for all target
1114213498266Sopenharmony_ci	  # systems that can't hard-code library paths into their executables
1114313498266Sopenharmony_ci	  # and that have no shared library path variable independent of PATH,
1114413498266Sopenharmony_ci	  # but it turns out we can't easily determine that from inspecting
1114513498266Sopenharmony_ci	  # libtool variables, so we have to hard-code the OSs to which it
1114613498266Sopenharmony_ci	  # applies here; at the moment, that means platforms that use the PE
1114713498266Sopenharmony_ci	  # object format with DLL files.  See the long comment at the top of
1114813498266Sopenharmony_ci	  # tests/bindir.at for full details.
1114913498266Sopenharmony_ci	  tdlname=$dlname
1115013498266Sopenharmony_ci	  case $host,$output,$installed,$module,$dlname in
1115113498266Sopenharmony_ci	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
1115213498266Sopenharmony_ci	      # If a -bindir argument was supplied, place the dll there.
1115313498266Sopenharmony_ci	      if test -n "$bindir"; then
1115413498266Sopenharmony_ci		func_relative_path "$install_libdir" "$bindir"
1115513498266Sopenharmony_ci		tdlname=$func_relative_path_result/$dlname
1115613498266Sopenharmony_ci	      else
1115713498266Sopenharmony_ci		# Otherwise fall back on heuristic.
1115813498266Sopenharmony_ci		tdlname=../bin/$dlname
1115913498266Sopenharmony_ci	      fi
1116013498266Sopenharmony_ci	      ;;
1116113498266Sopenharmony_ci	  esac
1116213498266Sopenharmony_ci	  $ECHO > $output "\
1116313498266Sopenharmony_ci# $outputname - a libtool library file
1116413498266Sopenharmony_ci# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
1116513498266Sopenharmony_ci#
1116613498266Sopenharmony_ci# Please DO NOT delete this file!
1116713498266Sopenharmony_ci# It is necessary for linking the library.
1116813498266Sopenharmony_ci
1116913498266Sopenharmony_ci# The name that we can dlopen(3).
1117013498266Sopenharmony_cidlname='$tdlname'
1117113498266Sopenharmony_ci
1117213498266Sopenharmony_ci# Names of this library.
1117313498266Sopenharmony_cilibrary_names='$library_names'
1117413498266Sopenharmony_ci
1117513498266Sopenharmony_ci# The name of the static archive.
1117613498266Sopenharmony_ciold_library='$old_library'
1117713498266Sopenharmony_ci
1117813498266Sopenharmony_ci# Linker flags that cannot go in dependency_libs.
1117913498266Sopenharmony_ciinherited_linker_flags='$new_inherited_linker_flags'
1118013498266Sopenharmony_ci
1118113498266Sopenharmony_ci# Libraries that this one depends upon.
1118213498266Sopenharmony_cidependency_libs='$dependency_libs'
1118313498266Sopenharmony_ci
1118413498266Sopenharmony_ci# Names of additional weak libraries provided by this library
1118513498266Sopenharmony_ciweak_library_names='$weak_libs'
1118613498266Sopenharmony_ci
1118713498266Sopenharmony_ci# Version information for $libname.
1118813498266Sopenharmony_cicurrent=$current
1118913498266Sopenharmony_ciage=$age
1119013498266Sopenharmony_cirevision=$revision
1119113498266Sopenharmony_ci
1119213498266Sopenharmony_ci# Is this an already installed library?
1119313498266Sopenharmony_ciinstalled=$installed
1119413498266Sopenharmony_ci
1119513498266Sopenharmony_ci# Should we warn about portability when linking against -modules?
1119613498266Sopenharmony_cishouldnotlink=$module
1119713498266Sopenharmony_ci
1119813498266Sopenharmony_ci# Files to dlopen/dlpreopen
1119913498266Sopenharmony_cidlopen='$dlfiles'
1120013498266Sopenharmony_cidlpreopen='$dlprefiles'
1120113498266Sopenharmony_ci
1120213498266Sopenharmony_ci# Directory that this library needs to be installed in:
1120313498266Sopenharmony_cilibdir='$install_libdir'"
1120413498266Sopenharmony_ci	  if test no,yes = "$installed,$need_relink"; then
1120513498266Sopenharmony_ci	    $ECHO >> $output "\
1120613498266Sopenharmony_cirelink_command=\"$relink_command\""
1120713498266Sopenharmony_ci	  fi
1120813498266Sopenharmony_ci	done
1120913498266Sopenharmony_ci      }
1121013498266Sopenharmony_ci
1121113498266Sopenharmony_ci      # Do a symbolic link so that the libtool archive can be found in
1121213498266Sopenharmony_ci      # LD_LIBRARY_PATH before the program is installed.
1121313498266Sopenharmony_ci      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
1121413498266Sopenharmony_ci      ;;
1121513498266Sopenharmony_ci    esac
1121613498266Sopenharmony_ci    exit $EXIT_SUCCESS
1121713498266Sopenharmony_ci}
1121813498266Sopenharmony_ci
1121913498266Sopenharmony_ciif test link = "$opt_mode" || test relink = "$opt_mode"; then
1122013498266Sopenharmony_ci  func_mode_link ${1+"$@"}
1122113498266Sopenharmony_cifi
1122213498266Sopenharmony_ci
1122313498266Sopenharmony_ci
1122413498266Sopenharmony_ci# func_mode_uninstall arg...
1122513498266Sopenharmony_cifunc_mode_uninstall ()
1122613498266Sopenharmony_ci{
1122713498266Sopenharmony_ci    $debug_cmd
1122813498266Sopenharmony_ci
1122913498266Sopenharmony_ci    RM=$nonopt
1123013498266Sopenharmony_ci    files=
1123113498266Sopenharmony_ci    rmforce=false
1123213498266Sopenharmony_ci    exit_status=0
1123313498266Sopenharmony_ci
1123413498266Sopenharmony_ci    # This variable tells wrapper scripts just to set variables rather
1123513498266Sopenharmony_ci    # than running their programs.
1123613498266Sopenharmony_ci    libtool_install_magic=$magic
1123713498266Sopenharmony_ci
1123813498266Sopenharmony_ci    for arg
1123913498266Sopenharmony_ci    do
1124013498266Sopenharmony_ci      case $arg in
1124113498266Sopenharmony_ci      -f) func_append RM " $arg"; rmforce=: ;;
1124213498266Sopenharmony_ci      -*) func_append RM " $arg" ;;
1124313498266Sopenharmony_ci      *) func_append files " $arg" ;;
1124413498266Sopenharmony_ci      esac
1124513498266Sopenharmony_ci    done
1124613498266Sopenharmony_ci
1124713498266Sopenharmony_ci    test -z "$RM" && \
1124813498266Sopenharmony_ci      func_fatal_help "you must specify an RM program"
1124913498266Sopenharmony_ci
1125013498266Sopenharmony_ci    rmdirs=
1125113498266Sopenharmony_ci
1125213498266Sopenharmony_ci    for file in $files; do
1125313498266Sopenharmony_ci      func_dirname "$file" "" "."
1125413498266Sopenharmony_ci      dir=$func_dirname_result
1125513498266Sopenharmony_ci      if test . = "$dir"; then
1125613498266Sopenharmony_ci	odir=$objdir
1125713498266Sopenharmony_ci      else
1125813498266Sopenharmony_ci	odir=$dir/$objdir
1125913498266Sopenharmony_ci      fi
1126013498266Sopenharmony_ci      func_basename "$file"
1126113498266Sopenharmony_ci      name=$func_basename_result
1126213498266Sopenharmony_ci      test uninstall = "$opt_mode" && odir=$dir
1126313498266Sopenharmony_ci
1126413498266Sopenharmony_ci      # Remember odir for removal later, being careful to avoid duplicates
1126513498266Sopenharmony_ci      if test clean = "$opt_mode"; then
1126613498266Sopenharmony_ci	case " $rmdirs " in
1126713498266Sopenharmony_ci	  *" $odir "*) ;;
1126813498266Sopenharmony_ci	  *) func_append rmdirs " $odir" ;;
1126913498266Sopenharmony_ci	esac
1127013498266Sopenharmony_ci      fi
1127113498266Sopenharmony_ci
1127213498266Sopenharmony_ci      # Don't error if the file doesn't exist and rm -f was used.
1127313498266Sopenharmony_ci      if { test -L "$file"; } >/dev/null 2>&1 ||
1127413498266Sopenharmony_ci	 { test -h "$file"; } >/dev/null 2>&1 ||
1127513498266Sopenharmony_ci	 test -f "$file"; then
1127613498266Sopenharmony_ci	:
1127713498266Sopenharmony_ci      elif test -d "$file"; then
1127813498266Sopenharmony_ci	exit_status=1
1127913498266Sopenharmony_ci	continue
1128013498266Sopenharmony_ci      elif $rmforce; then
1128113498266Sopenharmony_ci	continue
1128213498266Sopenharmony_ci      fi
1128313498266Sopenharmony_ci
1128413498266Sopenharmony_ci      rmfiles=$file
1128513498266Sopenharmony_ci
1128613498266Sopenharmony_ci      case $name in
1128713498266Sopenharmony_ci      *.la)
1128813498266Sopenharmony_ci	# Possibly a libtool archive, so verify it.
1128913498266Sopenharmony_ci	if func_lalib_p "$file"; then
1129013498266Sopenharmony_ci	  func_source $dir/$name
1129113498266Sopenharmony_ci
1129213498266Sopenharmony_ci	  # Delete the libtool libraries and symlinks.
1129313498266Sopenharmony_ci	  for n in $library_names; do
1129413498266Sopenharmony_ci	    func_append rmfiles " $odir/$n"
1129513498266Sopenharmony_ci	  done
1129613498266Sopenharmony_ci	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
1129713498266Sopenharmony_ci
1129813498266Sopenharmony_ci	  case $opt_mode in
1129913498266Sopenharmony_ci	  clean)
1130013498266Sopenharmony_ci	    case " $library_names " in
1130113498266Sopenharmony_ci	    *" $dlname "*) ;;
1130213498266Sopenharmony_ci	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
1130313498266Sopenharmony_ci	    esac
1130413498266Sopenharmony_ci	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
1130513498266Sopenharmony_ci	    ;;
1130613498266Sopenharmony_ci	  uninstall)
1130713498266Sopenharmony_ci	    if test -n "$library_names"; then
1130813498266Sopenharmony_ci	      # Do each command in the postuninstall commands.
1130913498266Sopenharmony_ci	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
1131013498266Sopenharmony_ci	    fi
1131113498266Sopenharmony_ci
1131213498266Sopenharmony_ci	    if test -n "$old_library"; then
1131313498266Sopenharmony_ci	      # Do each command in the old_postuninstall commands.
1131413498266Sopenharmony_ci	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
1131513498266Sopenharmony_ci	    fi
1131613498266Sopenharmony_ci	    # FIXME: should reinstall the best remaining shared library.
1131713498266Sopenharmony_ci	    ;;
1131813498266Sopenharmony_ci	  esac
1131913498266Sopenharmony_ci	fi
1132013498266Sopenharmony_ci	;;
1132113498266Sopenharmony_ci
1132213498266Sopenharmony_ci      *.lo)
1132313498266Sopenharmony_ci	# Possibly a libtool object, so verify it.
1132413498266Sopenharmony_ci	if func_lalib_p "$file"; then
1132513498266Sopenharmony_ci
1132613498266Sopenharmony_ci	  # Read the .lo file
1132713498266Sopenharmony_ci	  func_source $dir/$name
1132813498266Sopenharmony_ci
1132913498266Sopenharmony_ci	  # Add PIC object to the list of files to remove.
1133013498266Sopenharmony_ci	  if test -n "$pic_object" && test none != "$pic_object"; then
1133113498266Sopenharmony_ci	    func_append rmfiles " $dir/$pic_object"
1133213498266Sopenharmony_ci	  fi
1133313498266Sopenharmony_ci
1133413498266Sopenharmony_ci	  # Add non-PIC object to the list of files to remove.
1133513498266Sopenharmony_ci	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
1133613498266Sopenharmony_ci	    func_append rmfiles " $dir/$non_pic_object"
1133713498266Sopenharmony_ci	  fi
1133813498266Sopenharmony_ci	fi
1133913498266Sopenharmony_ci	;;
1134013498266Sopenharmony_ci
1134113498266Sopenharmony_ci      *)
1134213498266Sopenharmony_ci	if test clean = "$opt_mode"; then
1134313498266Sopenharmony_ci	  noexename=$name
1134413498266Sopenharmony_ci	  case $file in
1134513498266Sopenharmony_ci	  *.exe)
1134613498266Sopenharmony_ci	    func_stripname '' '.exe' "$file"
1134713498266Sopenharmony_ci	    file=$func_stripname_result
1134813498266Sopenharmony_ci	    func_stripname '' '.exe' "$name"
1134913498266Sopenharmony_ci	    noexename=$func_stripname_result
1135013498266Sopenharmony_ci	    # $file with .exe has already been added to rmfiles,
1135113498266Sopenharmony_ci	    # add $file without .exe
1135213498266Sopenharmony_ci	    func_append rmfiles " $file"
1135313498266Sopenharmony_ci	    ;;
1135413498266Sopenharmony_ci	  esac
1135513498266Sopenharmony_ci	  # Do a test to see if this is a libtool program.
1135613498266Sopenharmony_ci	  if func_ltwrapper_p "$file"; then
1135713498266Sopenharmony_ci	    if func_ltwrapper_executable_p "$file"; then
1135813498266Sopenharmony_ci	      func_ltwrapper_scriptname "$file"
1135913498266Sopenharmony_ci	      relink_command=
1136013498266Sopenharmony_ci	      func_source $func_ltwrapper_scriptname_result
1136113498266Sopenharmony_ci	      func_append rmfiles " $func_ltwrapper_scriptname_result"
1136213498266Sopenharmony_ci	    else
1136313498266Sopenharmony_ci	      relink_command=
1136413498266Sopenharmony_ci	      func_source $dir/$noexename
1136513498266Sopenharmony_ci	    fi
1136613498266Sopenharmony_ci
1136713498266Sopenharmony_ci	    # note $name still contains .exe if it was in $file originally
1136813498266Sopenharmony_ci	    # as does the version of $file that was added into $rmfiles
1136913498266Sopenharmony_ci	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
1137013498266Sopenharmony_ci	    if test yes = "$fast_install" && test -n "$relink_command"; then
1137113498266Sopenharmony_ci	      func_append rmfiles " $odir/lt-$name"
1137213498266Sopenharmony_ci	    fi
1137313498266Sopenharmony_ci	    if test "X$noexename" != "X$name"; then
1137413498266Sopenharmony_ci	      func_append rmfiles " $odir/lt-$noexename.c"
1137513498266Sopenharmony_ci	    fi
1137613498266Sopenharmony_ci	  fi
1137713498266Sopenharmony_ci	fi
1137813498266Sopenharmony_ci	;;
1137913498266Sopenharmony_ci      esac
1138013498266Sopenharmony_ci      func_show_eval "$RM $rmfiles" 'exit_status=1'
1138113498266Sopenharmony_ci    done
1138213498266Sopenharmony_ci
1138313498266Sopenharmony_ci    # Try to remove the $objdir's in the directories where we deleted files
1138413498266Sopenharmony_ci    for dir in $rmdirs; do
1138513498266Sopenharmony_ci      if test -d "$dir"; then
1138613498266Sopenharmony_ci	func_show_eval "rmdir $dir >/dev/null 2>&1"
1138713498266Sopenharmony_ci      fi
1138813498266Sopenharmony_ci    done
1138913498266Sopenharmony_ci
1139013498266Sopenharmony_ci    exit $exit_status
1139113498266Sopenharmony_ci}
1139213498266Sopenharmony_ci
1139313498266Sopenharmony_ciif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
1139413498266Sopenharmony_ci  func_mode_uninstall ${1+"$@"}
1139513498266Sopenharmony_cifi
1139613498266Sopenharmony_ci
1139713498266Sopenharmony_citest -z "$opt_mode" && {
1139813498266Sopenharmony_ci  help=$generic_help
1139913498266Sopenharmony_ci  func_fatal_help "you must specify a MODE"
1140013498266Sopenharmony_ci}
1140113498266Sopenharmony_ci
1140213498266Sopenharmony_citest -z "$exec_cmd" && \
1140313498266Sopenharmony_ci  func_fatal_help "invalid operation mode '$opt_mode'"
1140413498266Sopenharmony_ci
1140513498266Sopenharmony_ciif test -n "$exec_cmd"; then
1140613498266Sopenharmony_ci  eval exec "$exec_cmd"
1140713498266Sopenharmony_ci  exit $EXIT_FAILURE
1140813498266Sopenharmony_cifi
1140913498266Sopenharmony_ci
1141013498266Sopenharmony_ciexit $exit_status
1141113498266Sopenharmony_ci
1141213498266Sopenharmony_ci
1141313498266Sopenharmony_ci# The TAGs below are defined such that we never get into a situation
1141413498266Sopenharmony_ci# where we disable both kinds of libraries.  Given conflicting
1141513498266Sopenharmony_ci# choices, we go for a static library, that is the most portable,
1141613498266Sopenharmony_ci# since we can't tell whether shared libraries were disabled because
1141713498266Sopenharmony_ci# the user asked for that or because the platform doesn't support
1141813498266Sopenharmony_ci# them.  This is particularly important on AIX, because we don't
1141913498266Sopenharmony_ci# support having both static and shared libraries enabled at the same
1142013498266Sopenharmony_ci# time on that platform, so we default to a shared-only configuration.
1142113498266Sopenharmony_ci# If a disable-shared tag is given, we'll fallback to a static-only
1142213498266Sopenharmony_ci# configuration.  But we'll never go from static-only to shared-only.
1142313498266Sopenharmony_ci
1142413498266Sopenharmony_ci# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
1142513498266Sopenharmony_cibuild_libtool_libs=no
1142613498266Sopenharmony_cibuild_old_libs=yes
1142713498266Sopenharmony_ci# ### END LIBTOOL TAG CONFIG: disable-shared
1142813498266Sopenharmony_ci
1142913498266Sopenharmony_ci# ### BEGIN LIBTOOL TAG CONFIG: disable-static
1143013498266Sopenharmony_cibuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
1143113498266Sopenharmony_ci# ### END LIBTOOL TAG CONFIG: disable-static
1143213498266Sopenharmony_ci
1143313498266Sopenharmony_ci# Local Variables:
1143413498266Sopenharmony_ci# mode:shell-script
1143513498266Sopenharmony_ci# sh-indentation:2
1143613498266Sopenharmony_ci# End:
11437