18ce07328Smrg#! /usr/bin/env sh 2e3d74329Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 38ce07328Smrg## by inline-source v2019-02-19.15 442a55b46Smrg 58ce07328Smrg# libtool (GNU libtool) 2.4.7 6e3d74329Smrg# Provide generalized library-building support services. 742a55b46Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 842a55b46Smrg 98ce07328Smrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 1042a55b46Smrg# This is free software; see the source for copying conditions. There is NO 1142a55b46Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1242a55b46Smrg 1342a55b46Smrg# GNU Libtool is free software; you can redistribute it and/or modify 14c582b7e3Smrg# it under the terms of the GNU General Public License as published by 15c582b7e3Smrg# the Free Software Foundation; either version 2 of the License, or 16c582b7e3Smrg# (at your option) any later version. 17c582b7e3Smrg# 1842a55b46Smrg# As a special exception to the GNU General Public License, 1942a55b46Smrg# if you distribute this file as part of a program or library that 2042a55b46Smrg# is built using GNU Libtool, you may include this file under the 2142a55b46Smrg# same distribution terms that you use for the rest of that program. 2242a55b46Smrg# 2342a55b46Smrg# GNU Libtool is distributed in the hope that it will be useful, but 24c582b7e3Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25c582b7e3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26c582b7e3Smrg# General Public License for more details. 27c582b7e3Smrg# 28c582b7e3Smrg# You should have received a copy of the GNU General Public License 29e3d74329Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30c582b7e3Smrg 31c582b7e3Smrg 3242a55b46SmrgPROGRAM=libtool 33c582b7e3SmrgPACKAGE=libtool 348ce07328SmrgVERSION=2.4.7 358ce07328Smrgpackage_revision=2.4.7 36c582b7e3Smrg 37e3d74329Smrg 38e3d74329Smrg## ------ ## 39e3d74329Smrg## Usage. ## 40e3d74329Smrg## ------ ## 41e3d74329Smrg 42e3d74329Smrg# Run './libtool --help' for help with using this script from the 43e3d74329Smrg# command line. 44e3d74329Smrg 45e3d74329Smrg 46e3d74329Smrg## ------------------------------- ## 47e3d74329Smrg## User overridable command paths. ## 48e3d74329Smrg## ------------------------------- ## 49e3d74329Smrg 50e3d74329Smrg# After configure completes, it has a better idea of some of the 51e3d74329Smrg# shell tools we need than the defaults used by the functions shared 52e3d74329Smrg# with bootstrap, so set those here where they can still be over- 53e3d74329Smrg# ridden by the user, but otherwise take precedence. 54e3d74329Smrg 55e3d74329Smrg: ${AUTOCONF="autoconf"} 56e3d74329Smrg: ${AUTOMAKE="automake"} 57e3d74329Smrg 58e3d74329Smrg 59e3d74329Smrg## -------------------------- ## 60e3d74329Smrg## Source external libraries. ## 61e3d74329Smrg## -------------------------- ## 62e3d74329Smrg 63e3d74329Smrg# Much of our low-level functionality needs to be sourced from external 64e3d74329Smrg# libraries, which are installed to $pkgauxdir. 65e3d74329Smrg 66e3d74329Smrg# Set a version string for this script. 678ce07328Smrgscriptversion=2019-02-19.15; # UTC 68e3d74329Smrg 69e3d74329Smrg# General shell script boiler plate, and helper functions. 70e3d74329Smrg# Written by Gary V. Vaughan, 2004 71e3d74329Smrg 728ce07328Smrg# This is free software. There is NO warranty; not even for 738ce07328Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 748ce07328Smrg# 758ce07328Smrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 768ce07328Smrg# 778ce07328Smrg# This file is dual licensed under the terms of the MIT license 788ce07328Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 798ce07328Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 808ce07328Smrg# these licenses when using or redistributing this software or any of 818ce07328Smrg# the files within it. See the URLs above, or the file `LICENSE` 828ce07328Smrg# included in the Bootstrap distribution for the full license texts. 83e3d74329Smrg 848ce07328Smrg# Please report bugs or propose patches to: 858ce07328Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 86e3d74329Smrg 87e3d74329Smrg 88e3d74329Smrg## ------ ## 89e3d74329Smrg## Usage. ## 90e3d74329Smrg## ------ ## 91e3d74329Smrg 92e3d74329Smrg# Evaluate this file near the top of your script to gain access to 93e3d74329Smrg# the functions and variables defined here: 94e3d74329Smrg# 95e3d74329Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 96e3d74329Smrg# 97e3d74329Smrg# If you need to override any of the default environment variable 98e3d74329Smrg# settings, do that before evaluating this file. 99e3d74329Smrg 100e3d74329Smrg 101e3d74329Smrg## -------------------- ## 102e3d74329Smrg## Shell normalisation. ## 103e3d74329Smrg## -------------------- ## 104e3d74329Smrg 105e3d74329Smrg# Some shells need a little help to be as Bourne compatible as possible. 106e3d74329Smrg# Before doing anything else, make sure all that help has been provided! 107e3d74329Smrg 108e3d74329SmrgDUALCASE=1; export DUALCASE # for MKS sh 109e3d74329Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 110c582b7e3Smrg emulate sh 111c582b7e3Smrg NULLCMD=: 112e3d74329Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 113c582b7e3Smrg # is contrary to our usage. Disable this feature. 114c582b7e3Smrg alias -g '${1+"$@"}'='"$@"' 115c582b7e3Smrg setopt NO_GLOB_SUBST 116c582b7e3Smrgelse 117e3d74329Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 118c582b7e3Smrgfi 119c582b7e3Smrg 120e3d74329Smrg# NLS nuisances: We save the old values in case they are required later. 121e3d74329Smrg_G_user_locale= 122e3d74329Smrg_G_safe_locale= 123e3d74329Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 124c582b7e3Smrgdo 125e3d74329Smrg eval "if test set = \"\${$_G_var+set}\"; then 126e3d74329Smrg save_$_G_var=\$$_G_var 127e3d74329Smrg $_G_var=C 128e3d74329Smrg export $_G_var 129e3d74329Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 130e3d74329Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 131c582b7e3Smrg fi" 132c582b7e3Smrgdone 1338ce07328Smrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 1348ce07328Smrg# in case the environment reset is needed later and the $save_* variant is not 1358ce07328Smrg# defined (see the code above). 1368ce07328SmrgLC_ALL=C 1378ce07328SmrgLANGUAGE=C 1388ce07328Smrgexport LANGUAGE LC_ALL 139c582b7e3Smrg 140e3d74329Smrg# Make sure IFS has a sensible default 141e3d74329Smrgsp=' ' 142e3d74329Smrgnl=' 143e3d74329Smrg' 144e3d74329SmrgIFS="$sp $nl" 145e3d74329Smrg 146e3d74329Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 147e3d74329Smrgif test "${PATH_SEPARATOR+set}" != set; then 148e3d74329Smrg PATH_SEPARATOR=: 149e3d74329Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 150e3d74329Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 151e3d74329Smrg PATH_SEPARATOR=';' 152e3d74329Smrg } 153e3d74329Smrgfi 15442a55b46Smrg 15542a55b46Smrg 1568ce07328Smrg# func_unset VAR 1578ce07328Smrg# -------------- 1588ce07328Smrg# Portably unset VAR. 1598ce07328Smrg# In some shells, an 'unset VAR' statement leaves a non-zero return 1608ce07328Smrg# status if VAR is already unset, which might be problematic if the 1618ce07328Smrg# statement is used at the end of a function (thus poisoning its return 1628ce07328Smrg# value) or when 'set -e' is active (causing even a spurious abort of 1638ce07328Smrg# the script in this case). 1648ce07328Smrgfunc_unset () 1658ce07328Smrg{ 1668ce07328Smrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 1678ce07328Smrg} 1688ce07328Smrg 1698ce07328Smrg 1708ce07328Smrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 1718ce07328Smrgfunc_unset CDPATH 1728ce07328Smrg 1738ce07328Smrg# Make sure ${,E,F}GREP behave sanely. 1748ce07328Smrgfunc_unset GREP_OPTIONS 1758ce07328Smrg 17642a55b46Smrg 177e3d74329Smrg## ------------------------- ## 178e3d74329Smrg## Locate command utilities. ## 179e3d74329Smrg## ------------------------- ## 180e3d74329Smrg 181e3d74329Smrg 182e3d74329Smrg# func_executable_p FILE 183e3d74329Smrg# ---------------------- 184e3d74329Smrg# Check that FILE is an executable regular file. 185e3d74329Smrgfunc_executable_p () 186e3d74329Smrg{ 187e3d74329Smrg test -f "$1" && test -x "$1" 188e3d74329Smrg} 189e3d74329Smrg 190e3d74329Smrg 191e3d74329Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 192e3d74329Smrg# -------------------------------------------- 193e3d74329Smrg# Search for either a program that responds to --version with output 194e3d74329Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 195e3d74329Smrg# trying all the directories in PATH with each of the elements of 196e3d74329Smrg# PROGS_LIST. 197e3d74329Smrg# 198e3d74329Smrg# CHECK_FUNC should accept the path to a candidate program, and 199e3d74329Smrg# set $func_check_prog_result if it truncates its output less than 200e3d74329Smrg# $_G_path_prog_max characters. 201e3d74329Smrgfunc_path_progs () 202e3d74329Smrg{ 203e3d74329Smrg _G_progs_list=$1 204e3d74329Smrg _G_check_func=$2 205e3d74329Smrg _G_PATH=${3-"$PATH"} 206e3d74329Smrg 207e3d74329Smrg _G_path_prog_max=0 208e3d74329Smrg _G_path_prog_found=false 209e3d74329Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 210e3d74329Smrg for _G_dir in $_G_PATH; do 211e3d74329Smrg IFS=$_G_save_IFS 212e3d74329Smrg test -z "$_G_dir" && _G_dir=. 213e3d74329Smrg for _G_prog_name in $_G_progs_list; do 214e3d74329Smrg for _exeext in '' .EXE; do 215e3d74329Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 216e3d74329Smrg func_executable_p "$_G_path_prog" || continue 217e3d74329Smrg case `"$_G_path_prog" --version 2>&1` in 218e3d74329Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 219e3d74329Smrg *) $_G_check_func $_G_path_prog 220e3d74329Smrg func_path_progs_result=$func_check_prog_result 221e3d74329Smrg ;; 222e3d74329Smrg esac 223e3d74329Smrg $_G_path_prog_found && break 3 224e3d74329Smrg done 225e3d74329Smrg done 226e3d74329Smrg done 227e3d74329Smrg IFS=$_G_save_IFS 228e3d74329Smrg test -z "$func_path_progs_result" && { 229e3d74329Smrg echo "no acceptable sed could be found in \$PATH" >&2 230e3d74329Smrg exit 1 231e3d74329Smrg } 232e3d74329Smrg} 233e3d74329Smrg 234e3d74329Smrg 235e3d74329Smrg# We want to be able to use the functions in this file before configure 236e3d74329Smrg# has figured out where the best binaries are kept, which means we have 237e3d74329Smrg# to search for them ourselves - except when the results are already set 238e3d74329Smrg# where we skip the searches. 239e3d74329Smrg 240e3d74329Smrg# Unless the user overrides by setting SED, search the path for either GNU 241e3d74329Smrg# sed, or the sed that truncates its output the least. 242e3d74329Smrgtest -z "$SED" && { 243e3d74329Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 244e3d74329Smrg for _G_i in 1 2 3 4 5 6 7; do 245e3d74329Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 246e3d74329Smrg done 247e3d74329Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 248e3d74329Smrg _G_sed_script= 249e3d74329Smrg 250e3d74329Smrg func_check_prog_sed () 251e3d74329Smrg { 252e3d74329Smrg _G_path_prog=$1 253e3d74329Smrg 254e3d74329Smrg _G_count=0 255e3d74329Smrg printf 0123456789 >conftest.in 256e3d74329Smrg while : 257e3d74329Smrg do 258e3d74329Smrg cat conftest.in conftest.in >conftest.tmp 259e3d74329Smrg mv conftest.tmp conftest.in 260e3d74329Smrg cp conftest.in conftest.nl 261e3d74329Smrg echo '' >> conftest.nl 262e3d74329Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 263e3d74329Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 264e3d74329Smrg _G_count=`expr $_G_count + 1` 265e3d74329Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 266e3d74329Smrg # Best one so far, save it but keep looking for a better one 267e3d74329Smrg func_check_prog_result=$_G_path_prog 268e3d74329Smrg _G_path_prog_max=$_G_count 269e3d74329Smrg fi 270e3d74329Smrg # 10*(2^10) chars as input seems more than enough 271e3d74329Smrg test 10 -lt "$_G_count" && break 272e3d74329Smrg done 273e3d74329Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 274e3d74329Smrg } 275e3d74329Smrg 2768ce07328Smrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 277e3d74329Smrg rm -f conftest.sed 278e3d74329Smrg SED=$func_path_progs_result 279e3d74329Smrg} 280e3d74329Smrg 281e3d74329Smrg 282e3d74329Smrg# Unless the user overrides by setting GREP, search the path for either GNU 283e3d74329Smrg# grep, or the grep that truncates its output the least. 284e3d74329Smrgtest -z "$GREP" && { 285e3d74329Smrg func_check_prog_grep () 286e3d74329Smrg { 287e3d74329Smrg _G_path_prog=$1 288e3d74329Smrg 289e3d74329Smrg _G_count=0 290e3d74329Smrg _G_path_prog_max=0 291e3d74329Smrg printf 0123456789 >conftest.in 292e3d74329Smrg while : 293e3d74329Smrg do 294e3d74329Smrg cat conftest.in conftest.in >conftest.tmp 295e3d74329Smrg mv conftest.tmp conftest.in 296e3d74329Smrg cp conftest.in conftest.nl 297e3d74329Smrg echo 'GREP' >> conftest.nl 298e3d74329Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 299e3d74329Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 300e3d74329Smrg _G_count=`expr $_G_count + 1` 301e3d74329Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 302e3d74329Smrg # Best one so far, save it but keep looking for a better one 303e3d74329Smrg func_check_prog_result=$_G_path_prog 304e3d74329Smrg _G_path_prog_max=$_G_count 305e3d74329Smrg fi 306e3d74329Smrg # 10*(2^10) chars as input seems more than enough 307e3d74329Smrg test 10 -lt "$_G_count" && break 308e3d74329Smrg done 309e3d74329Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 310e3d74329Smrg } 311e3d74329Smrg 3128ce07328Smrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 313e3d74329Smrg GREP=$func_path_progs_result 314e3d74329Smrg} 315e3d74329Smrg 316e3d74329Smrg 317e3d74329Smrg## ------------------------------- ## 318e3d74329Smrg## User overridable command paths. ## 319e3d74329Smrg## ------------------------------- ## 320e3d74329Smrg 321e3d74329Smrg# All uppercase variable names are used for environment variables. These 322e3d74329Smrg# variables can be overridden by the user before calling a script that 323e3d74329Smrg# uses them if a suitable command of that name is not already available 324e3d74329Smrg# in the command search PATH. 32542a55b46Smrg 32642a55b46Smrg: ${CP="cp -f"} 327e3d74329Smrg: ${ECHO="printf %s\n"} 328e3d74329Smrg: ${EGREP="$GREP -E"} 329e3d74329Smrg: ${FGREP="$GREP -F"} 330e3d74329Smrg: ${LN_S="ln -s"} 33142a55b46Smrg: ${MAKE="make"} 33242a55b46Smrg: ${MKDIR="mkdir"} 33342a55b46Smrg: ${MV="mv -f"} 33442a55b46Smrg: ${RM="rm -f"} 33542a55b46Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 336c582b7e3Smrg 337c582b7e3Smrg 338e3d74329Smrg## -------------------- ## 339e3d74329Smrg## Useful sed snippets. ## 340e3d74329Smrg## -------------------- ## 34142a55b46Smrg 342e3d74329Smrgsed_dirname='s|/[^/]*$||' 343e3d74329Smrgsed_basename='s|^.*/||' 34442a55b46Smrg 345e3d74329Smrg# Sed substitution that helps us do robust quoting. It backslashifies 346e3d74329Smrg# metacharacters that are still active within double-quoted strings. 347e3d74329Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 34842a55b46Smrg 349e3d74329Smrg# Same as above, but do not quote variable references. 350e3d74329Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 35142a55b46Smrg 352e3d74329Smrg# Sed substitution that turns a string into a regex matching for the 353e3d74329Smrg# string literally. 354e3d74329Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 35542a55b46Smrg 356e3d74329Smrg# Sed substitution that converts a w32 file name or path 357e3d74329Smrg# that contains forward slashes, into one that contains 358e3d74329Smrg# (escaped) backslashes. A very naive implementation. 359e3d74329Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 360e3d74329Smrg 361e3d74329Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 362e3d74329Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 363e3d74329Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 364e3d74329Smrg# expansion. Since each input '\' is now two '\'s, look for any number 365e3d74329Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 366e3d74329Smrg_G_bs='\\' 367e3d74329Smrg_G_bs2='\\\\' 368e3d74329Smrg_G_bs4='\\\\\\\\' 369e3d74329Smrg_G_dollar='\$' 370e3d74329Smrgsed_double_backslash="\ 371e3d74329Smrg s/$_G_bs4/&\\ 372e3d74329Smrg/g 373e3d74329Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 374e3d74329Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 375e3d74329Smrg s/\n//g" 37642a55b46Smrg 3778ce07328Smrg# require_check_ifs_backslash 3788ce07328Smrg# --------------------------- 3798ce07328Smrg# Check if we can use backslash as IFS='\' separator, and set 3808ce07328Smrg# $check_ifs_backshlash_broken to ':' or 'false'. 3818ce07328Smrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 3828ce07328Smrgfunc_require_check_ifs_backslash () 3838ce07328Smrg{ 3848ce07328Smrg _G_save_IFS=$IFS 3858ce07328Smrg IFS='\' 3868ce07328Smrg _G_check_ifs_backshlash='a\\b' 3878ce07328Smrg for _G_i in $_G_check_ifs_backshlash 3888ce07328Smrg do 3898ce07328Smrg case $_G_i in 3908ce07328Smrg a) 3918ce07328Smrg check_ifs_backshlash_broken=false 3928ce07328Smrg ;; 3938ce07328Smrg '') 3948ce07328Smrg break 3958ce07328Smrg ;; 3968ce07328Smrg *) 3978ce07328Smrg check_ifs_backshlash_broken=: 3988ce07328Smrg break 3998ce07328Smrg ;; 4008ce07328Smrg esac 4018ce07328Smrg done 4028ce07328Smrg IFS=$_G_save_IFS 4038ce07328Smrg require_check_ifs_backslash=: 4048ce07328Smrg} 4058ce07328Smrg 40642a55b46Smrg 407e3d74329Smrg## ----------------- ## 408e3d74329Smrg## Global variables. ## 409e3d74329Smrg## ----------------- ## 41042a55b46Smrg 411e3d74329Smrg# Except for the global variables explicitly listed below, the following 412e3d74329Smrg# functions in the '^func_' namespace, and the '^require_' namespace 413e3d74329Smrg# variables initialised in the 'Resource management' section, sourcing 414e3d74329Smrg# this file will not pollute your global namespace with anything 415e3d74329Smrg# else. There's no portable way to scope variables in Bourne shell 416e3d74329Smrg# though, so actually running these functions will sometimes place 417e3d74329Smrg# results into a variable named after the function, and often use 418e3d74329Smrg# temporary variables in the '^_G_' namespace. If you are careful to 419e3d74329Smrg# avoid using those namespaces casually in your sourcing script, things 420e3d74329Smrg# should continue to work as you expect. And, of course, you can freely 421e3d74329Smrg# overwrite any of the functions or variables defined here before 422e3d74329Smrg# calling anything to customize them. 42342a55b46Smrg 424e3d74329SmrgEXIT_SUCCESS=0 425e3d74329SmrgEXIT_FAILURE=1 426e3d74329SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 427e3d74329SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 42842a55b46Smrg 429e3d74329Smrg# Allow overriding, eg assuming that you follow the convention of 430e3d74329Smrg# putting '$debug_cmd' at the start of all your functions, you can get 431e3d74329Smrg# bash to show function call trace with: 432e3d74329Smrg# 433e3d74329Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 434e3d74329Smrgdebug_cmd=${debug_cmd-":"} 435e3d74329Smrgexit_cmd=: 43642a55b46Smrg 437e3d74329Smrg# By convention, finish your script with: 438e3d74329Smrg# 439e3d74329Smrg# exit $exit_status 440e3d74329Smrg# 441e3d74329Smrg# so that you can set exit_status to non-zero if you want to indicate 442e3d74329Smrg# something went wrong during execution without actually bailing out at 443e3d74329Smrg# the point of failure. 444e3d74329Smrgexit_status=$EXIT_SUCCESS 44542a55b46Smrg 446e3d74329Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 447e3d74329Smrg# is ksh but when the shell is invoked as "sh" and the current value of 448e3d74329Smrg# the _XPG environment variable is not equal to 1 (one), the special 449e3d74329Smrg# positional parameter $0, within a function call, is the name of the 450e3d74329Smrg# function. 451e3d74329Smrgprogpath=$0 45242a55b46Smrg 453e3d74329Smrg# The name of this program. 454e3d74329Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 45542a55b46Smrg 456e3d74329Smrg# Make sure we have an absolute progpath for reexecution: 45742a55b46Smrgcase $progpath in 45842a55b46Smrg [\\/]*|[A-Za-z]:\\*) ;; 45942a55b46Smrg *[\\/]*) 460e3d74329Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 46142a55b46Smrg progdir=`cd "$progdir" && pwd` 462e3d74329Smrg progpath=$progdir/$progname 46342a55b46Smrg ;; 46442a55b46Smrg *) 465e3d74329Smrg _G_IFS=$IFS 46642a55b46Smrg IFS=${PATH_SEPARATOR-:} 46742a55b46Smrg for progdir in $PATH; do 468e3d74329Smrg IFS=$_G_IFS 46942a55b46Smrg test -x "$progdir/$progname" && break 47042a55b46Smrg done 471e3d74329Smrg IFS=$_G_IFS 47242a55b46Smrg test -n "$progdir" || progdir=`pwd` 473e3d74329Smrg progpath=$progdir/$progname 47442a55b46Smrg ;; 47542a55b46Smrgesac 47642a55b46Smrg 47742a55b46Smrg 478e3d74329Smrg## ----------------- ## 479e3d74329Smrg## Standard options. ## 480e3d74329Smrg## ----------------- ## 48142a55b46Smrg 482e3d74329Smrg# The following options affect the operation of the functions defined 483e3d74329Smrg# below, and should be set appropriately depending on run-time para- 484e3d74329Smrg# meters passed on the command line. 48542a55b46Smrg 48642a55b46Smrgopt_dry_run=false 48742a55b46Smrgopt_quiet=false 48842a55b46Smrgopt_verbose=false 48942a55b46Smrg 490e3d74329Smrg# Categories 'all' and 'none' are always available. Append any others 491e3d74329Smrg# you will pass as the first argument to func_warning from your own 492e3d74329Smrg# code. 493e3d74329Smrgwarning_categories= 49442a55b46Smrg 495e3d74329Smrg# By default, display warnings according to 'opt_warning_types'. Set 496e3d74329Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 497e3d74329Smrg# treat the next displayed warning as a fatal error. 498e3d74329Smrgwarning_func=func_warn_and_continue 49942a55b46Smrg 500e3d74329Smrg# Set to 'all' to display all warnings, 'none' to suppress all 501e3d74329Smrg# warnings, or a space delimited list of some subset of 502e3d74329Smrg# 'warning_categories' to display only the listed warnings. 503e3d74329Smrgopt_warning_types=all 50442a55b46Smrg 50542a55b46Smrg 506e3d74329Smrg## -------------------- ## 507e3d74329Smrg## Resource management. ## 508e3d74329Smrg## -------------------- ## 50942a55b46Smrg 510e3d74329Smrg# This section contains definitions for functions that each ensure a 511e3d74329Smrg# particular resource (a file, or a non-empty configuration variable for 512e3d74329Smrg# example) is available, and if appropriate to extract default values 513e3d74329Smrg# from pertinent package files. Call them using their associated 514e3d74329Smrg# 'require_*' variable to ensure that they are executed, at most, once. 515e3d74329Smrg# 516e3d74329Smrg# It's entirely deliberate that calling these functions can set 517e3d74329Smrg# variables that don't obey the namespace limitations obeyed by the rest 518e3d74329Smrg# of this file, in order that that they be as useful as possible to 519e3d74329Smrg# callers. 52042a55b46Smrg 52142a55b46Smrg 522e3d74329Smrg# require_term_colors 523e3d74329Smrg# ------------------- 524e3d74329Smrg# Allow display of bold text on terminals that support it. 525e3d74329Smrgrequire_term_colors=func_require_term_colors 526e3d74329Smrgfunc_require_term_colors () 52742a55b46Smrg{ 528e3d74329Smrg $debug_cmd 529e3d74329Smrg 530e3d74329Smrg test -t 1 && { 531e3d74329Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 532e3d74329Smrg # precedence, because most terminfo databases neglect to describe 533e3d74329Smrg # whether color sequences are supported. 534e3d74329Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 535e3d74329Smrg 536e3d74329Smrg if test 1 = "$USE_ANSI_COLORS"; then 537e3d74329Smrg # Standard ANSI escape sequences 538e3d74329Smrg tc_reset='[0m' 539e3d74329Smrg tc_bold='[1m'; tc_standout='[7m' 540e3d74329Smrg tc_red='[31m'; tc_green='[32m' 541e3d74329Smrg tc_blue='[34m'; tc_cyan='[36m' 542e3d74329Smrg else 543e3d74329Smrg # Otherwise trust the terminfo database after all. 544e3d74329Smrg test -n "`tput sgr0 2>/dev/null`" && { 545e3d74329Smrg tc_reset=`tput sgr0` 546e3d74329Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 547e3d74329Smrg tc_standout=$tc_bold 548e3d74329Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 549e3d74329Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 550e3d74329Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 551e3d74329Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 552e3d74329Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 553e3d74329Smrg } 554e3d74329Smrg fi 555e3d74329Smrg } 55642a55b46Smrg 557e3d74329Smrg require_term_colors=: 55842a55b46Smrg} 55942a55b46Smrg 56042a55b46Smrg 561e3d74329Smrg## ----------------- ## 562e3d74329Smrg## Function library. ## 563e3d74329Smrg## ----------------- ## 564e3d74329Smrg 565e3d74329Smrg# This section contains a variety of useful functions to call in your 566e3d74329Smrg# scripts. Take note of the portable wrappers for features provided by 567e3d74329Smrg# some modern shells, which will fall back to slower equivalents on 568e3d74329Smrg# less featureful shells. 569e3d74329Smrg 570e3d74329Smrg 571e3d74329Smrg# func_append VAR VALUE 572e3d74329Smrg# --------------------- 573e3d74329Smrg# Append VALUE onto the existing contents of VAR. 574e3d74329Smrg 575e3d74329Smrg # We should try to minimise forks, especially on Windows where they are 576e3d74329Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 577e3d74329Smrg # being used: 578e3d74329Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 579e3d74329Smrg : ${_G_HAVE_ARITH_OP="yes"} 580e3d74329Smrg : ${_G_HAVE_XSI_OPS="yes"} 581e3d74329Smrg # The += operator was introduced in bash 3.1 582e3d74329Smrg case $BASH_VERSION in 583e3d74329Smrg [12].* | 3.0 | 3.0*) ;; 584e3d74329Smrg *) 585e3d74329Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 586e3d74329Smrg ;; 587e3d74329Smrg esac 588e3d74329Smrg fi 589e3d74329Smrg 590e3d74329Smrg # _G_HAVE_PLUSEQ_OP 591e3d74329Smrg # Can be empty, in which case the shell is probed, "yes" if += is 592e3d74329Smrg # useable or anything else if it does not work. 593e3d74329Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 594e3d74329Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 595e3d74329Smrg && _G_HAVE_PLUSEQ_OP=yes 596e3d74329Smrg 597e3d74329Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 598e3d74329Smrgthen 599e3d74329Smrg # This is an XSI compatible shell, allowing a faster implementation... 600e3d74329Smrg eval 'func_append () 601e3d74329Smrg { 602e3d74329Smrg $debug_cmd 603e3d74329Smrg 604e3d74329Smrg eval "$1+=\$2" 605e3d74329Smrg }' 606e3d74329Smrgelse 607e3d74329Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 608e3d74329Smrg func_append () 609e3d74329Smrg { 610e3d74329Smrg $debug_cmd 611e3d74329Smrg 612e3d74329Smrg eval "$1=\$$1\$2" 613e3d74329Smrg } 614e3d74329Smrgfi 615e3d74329Smrg 616e3d74329Smrg 617e3d74329Smrg# func_append_quoted VAR VALUE 618e3d74329Smrg# ---------------------------- 619e3d74329Smrg# Quote VALUE and append to the end of shell variable VAR, separated 620e3d74329Smrg# by a space. 621e3d74329Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 622e3d74329Smrg eval 'func_append_quoted () 623e3d74329Smrg { 624e3d74329Smrg $debug_cmd 625e3d74329Smrg 6268ce07328Smrg func_quote_arg pretty "$2" 6278ce07328Smrg eval "$1+=\\ \$func_quote_arg_result" 628e3d74329Smrg }' 629e3d74329Smrgelse 630e3d74329Smrg func_append_quoted () 631e3d74329Smrg { 632e3d74329Smrg $debug_cmd 633e3d74329Smrg 6348ce07328Smrg func_quote_arg pretty "$2" 6358ce07328Smrg eval "$1=\$$1\\ \$func_quote_arg_result" 636e3d74329Smrg } 637e3d74329Smrgfi 638e3d74329Smrg 639e3d74329Smrg 640e3d74329Smrg# func_append_uniq VAR VALUE 641e3d74329Smrg# -------------------------- 642e3d74329Smrg# Append unique VALUE onto the existing contents of VAR, assuming 643e3d74329Smrg# entries are delimited by the first character of VALUE. For example: 644e3d74329Smrg# 645e3d74329Smrg# func_append_uniq options " --another-option option-argument" 646e3d74329Smrg# 647e3d74329Smrg# will only append to $options if " --another-option option-argument " 648e3d74329Smrg# is not already present somewhere in $options already (note spaces at 649e3d74329Smrg# each end implied by leading space in second argument). 650e3d74329Smrgfunc_append_uniq () 651e3d74329Smrg{ 652e3d74329Smrg $debug_cmd 653e3d74329Smrg 654e3d74329Smrg eval _G_current_value='`$ECHO $'$1'`' 655e3d74329Smrg _G_delim=`expr "$2" : '\(.\)'` 656e3d74329Smrg 657e3d74329Smrg case $_G_delim$_G_current_value$_G_delim in 658e3d74329Smrg *"$2$_G_delim"*) ;; 659e3d74329Smrg *) func_append "$@" ;; 660e3d74329Smrg esac 661e3d74329Smrg} 662e3d74329Smrg 663e3d74329Smrg 664e3d74329Smrg# func_arith TERM... 665e3d74329Smrg# ------------------ 666e3d74329Smrg# Set func_arith_result to the result of evaluating TERMs. 667e3d74329Smrg test -z "$_G_HAVE_ARITH_OP" \ 668e3d74329Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 669e3d74329Smrg && _G_HAVE_ARITH_OP=yes 670e3d74329Smrg 671e3d74329Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 672e3d74329Smrg eval 'func_arith () 673e3d74329Smrg { 674e3d74329Smrg $debug_cmd 675e3d74329Smrg 676e3d74329Smrg func_arith_result=$(( $* )) 677e3d74329Smrg }' 678e3d74329Smrgelse 679e3d74329Smrg func_arith () 680e3d74329Smrg { 681e3d74329Smrg $debug_cmd 682e3d74329Smrg 683e3d74329Smrg func_arith_result=`expr "$@"` 684e3d74329Smrg } 685e3d74329Smrgfi 686e3d74329Smrg 687e3d74329Smrg 688e3d74329Smrg# func_basename FILE 689e3d74329Smrg# ------------------ 690e3d74329Smrg# Set func_basename_result to FILE with everything up to and including 691e3d74329Smrg# the last / stripped. 692e3d74329Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 693e3d74329Smrg # If this shell supports suffix pattern removal, then use it to avoid 694e3d74329Smrg # forking. Hide the definitions single quotes in case the shell chokes 695e3d74329Smrg # on unsupported syntax... 696e3d74329Smrg _b='func_basename_result=${1##*/}' 697e3d74329Smrg _d='case $1 in 698e3d74329Smrg */*) func_dirname_result=${1%/*}$2 ;; 699e3d74329Smrg * ) func_dirname_result=$3 ;; 700e3d74329Smrg esac' 701e3d74329Smrg 702e3d74329Smrgelse 703e3d74329Smrg # ...otherwise fall back to using sed. 704e3d74329Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 705e3d74329Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 706e3d74329Smrg if test "X$func_dirname_result" = "X$1"; then 707e3d74329Smrg func_dirname_result=$3 708e3d74329Smrg else 709e3d74329Smrg func_append func_dirname_result "$2" 710e3d74329Smrg fi' 711e3d74329Smrgfi 712e3d74329Smrg 713e3d74329Smrgeval 'func_basename () 714e3d74329Smrg{ 715e3d74329Smrg $debug_cmd 716e3d74329Smrg 717e3d74329Smrg '"$_b"' 718e3d74329Smrg}' 719e3d74329Smrg 720e3d74329Smrg 721e3d74329Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 722e3d74329Smrg# ------------------------------------------- 723e3d74329Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 724e3d74329Smrg# otherwise set result to NONDIR_REPLACEMENT. 725e3d74329Smrgeval 'func_dirname () 726e3d74329Smrg{ 727e3d74329Smrg $debug_cmd 728e3d74329Smrg 729e3d74329Smrg '"$_d"' 730e3d74329Smrg}' 731e3d74329Smrg 732e3d74329Smrg 733e3d74329Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 734e3d74329Smrg# -------------------------------------------------------- 735e3d74329Smrg# Perform func_basename and func_dirname in a single function 736e3d74329Smrg# call: 737e3d74329Smrg# dirname: Compute the dirname of FILE. If nonempty, 738e3d74329Smrg# add APPEND to the result, otherwise set result 739e3d74329Smrg# to NONDIR_REPLACEMENT. 740e3d74329Smrg# value returned in "$func_dirname_result" 741e3d74329Smrg# basename: Compute filename of FILE. 742e3d74329Smrg# value retuned in "$func_basename_result" 743e3d74329Smrg# For efficiency, we do not delegate to the functions above but instead 744e3d74329Smrg# duplicate the functionality here. 745e3d74329Smrgeval 'func_dirname_and_basename () 746e3d74329Smrg{ 747e3d74329Smrg $debug_cmd 748e3d74329Smrg 749e3d74329Smrg '"$_b"' 750e3d74329Smrg '"$_d"' 751e3d74329Smrg}' 752e3d74329Smrg 753e3d74329Smrg 754e3d74329Smrg# func_echo ARG... 755e3d74329Smrg# ---------------- 756e3d74329Smrg# Echo program name prefixed message. 757e3d74329Smrgfunc_echo () 758e3d74329Smrg{ 759e3d74329Smrg $debug_cmd 760e3d74329Smrg 761e3d74329Smrg _G_message=$* 762e3d74329Smrg 763e3d74329Smrg func_echo_IFS=$IFS 764e3d74329Smrg IFS=$nl 765e3d74329Smrg for _G_line in $_G_message; do 766e3d74329Smrg IFS=$func_echo_IFS 767e3d74329Smrg $ECHO "$progname: $_G_line" 768e3d74329Smrg done 769e3d74329Smrg IFS=$func_echo_IFS 770e3d74329Smrg} 771e3d74329Smrg 772e3d74329Smrg 773e3d74329Smrg# func_echo_all ARG... 774e3d74329Smrg# -------------------- 775e3d74329Smrg# Invoke $ECHO with all args, space-separated. 776e3d74329Smrgfunc_echo_all () 777e3d74329Smrg{ 778e3d74329Smrg $ECHO "$*" 779e3d74329Smrg} 780e3d74329Smrg 781e3d74329Smrg 782e3d74329Smrg# func_echo_infix_1 INFIX ARG... 783e3d74329Smrg# ------------------------------ 784e3d74329Smrg# Echo program name, followed by INFIX on the first line, with any 785e3d74329Smrg# additional lines not showing INFIX. 786e3d74329Smrgfunc_echo_infix_1 () 787e3d74329Smrg{ 788e3d74329Smrg $debug_cmd 789e3d74329Smrg 790e3d74329Smrg $require_term_colors 791e3d74329Smrg 792e3d74329Smrg _G_infix=$1; shift 793e3d74329Smrg _G_indent=$_G_infix 794e3d74329Smrg _G_prefix="$progname: $_G_infix: " 795e3d74329Smrg _G_message=$* 796e3d74329Smrg 797e3d74329Smrg # Strip color escape sequences before counting printable length 798e3d74329Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 799e3d74329Smrg do 800e3d74329Smrg test -n "$_G_tc" && { 801e3d74329Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 802e3d74329Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 803e3d74329Smrg } 804e3d74329Smrg done 805e3d74329Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 806e3d74329Smrg 807e3d74329Smrg func_echo_infix_1_IFS=$IFS 808e3d74329Smrg IFS=$nl 809e3d74329Smrg for _G_line in $_G_message; do 810e3d74329Smrg IFS=$func_echo_infix_1_IFS 811e3d74329Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 812e3d74329Smrg _G_prefix=$_G_indent 813e3d74329Smrg done 814e3d74329Smrg IFS=$func_echo_infix_1_IFS 815e3d74329Smrg} 816e3d74329Smrg 817e3d74329Smrg 818e3d74329Smrg# func_error ARG... 819e3d74329Smrg# ----------------- 820e3d74329Smrg# Echo program name prefixed message to standard error. 821e3d74329Smrgfunc_error () 822e3d74329Smrg{ 823e3d74329Smrg $debug_cmd 824e3d74329Smrg 825e3d74329Smrg $require_term_colors 826e3d74329Smrg 827e3d74329Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 828e3d74329Smrg} 829e3d74329Smrg 830e3d74329Smrg 831e3d74329Smrg# func_fatal_error ARG... 832e3d74329Smrg# ----------------------- 833e3d74329Smrg# Echo program name prefixed message to standard error, and exit. 834e3d74329Smrgfunc_fatal_error () 835e3d74329Smrg{ 836e3d74329Smrg $debug_cmd 837e3d74329Smrg 838e3d74329Smrg func_error "$*" 839e3d74329Smrg exit $EXIT_FAILURE 840e3d74329Smrg} 841e3d74329Smrg 842e3d74329Smrg 843e3d74329Smrg# func_grep EXPRESSION FILENAME 844e3d74329Smrg# ----------------------------- 84542a55b46Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 84642a55b46Smrgfunc_grep () 84742a55b46Smrg{ 848e3d74329Smrg $debug_cmd 849e3d74329Smrg 85042a55b46Smrg $GREP "$1" "$2" >/dev/null 2>&1 85142a55b46Smrg} 85242a55b46Smrg 85342a55b46Smrg 854e3d74329Smrg# func_len STRING 855e3d74329Smrg# --------------- 856e3d74329Smrg# Set func_len_result to the length of STRING. STRING may not 857e3d74329Smrg# start with a hyphen. 858e3d74329Smrg test -z "$_G_HAVE_XSI_OPS" \ 859e3d74329Smrg && (eval 'x=a/b/c; 860e3d74329Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 861e3d74329Smrg && _G_HAVE_XSI_OPS=yes 862e3d74329Smrg 863e3d74329Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 864e3d74329Smrg eval 'func_len () 865e3d74329Smrg { 866e3d74329Smrg $debug_cmd 867e3d74329Smrg 868e3d74329Smrg func_len_result=${#1} 869e3d74329Smrg }' 870e3d74329Smrgelse 871e3d74329Smrg func_len () 872e3d74329Smrg { 873e3d74329Smrg $debug_cmd 874e3d74329Smrg 875e3d74329Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 876e3d74329Smrg } 877e3d74329Smrgfi 878e3d74329Smrg 879e3d74329Smrg 880e3d74329Smrg# func_mkdir_p DIRECTORY-PATH 881e3d74329Smrg# --------------------------- 88242a55b46Smrg# Make sure the entire path to DIRECTORY-PATH is available. 88342a55b46Smrgfunc_mkdir_p () 88442a55b46Smrg{ 885e3d74329Smrg $debug_cmd 886e3d74329Smrg 887e3d74329Smrg _G_directory_path=$1 888e3d74329Smrg _G_dir_list= 88942a55b46Smrg 890e3d74329Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 89142a55b46Smrg 892e3d74329Smrg # Protect directory names starting with '-' 893e3d74329Smrg case $_G_directory_path in 894e3d74329Smrg -*) _G_directory_path=./$_G_directory_path ;; 89542a55b46Smrg esac 89642a55b46Smrg 89742a55b46Smrg # While some portion of DIR does not yet exist... 898e3d74329Smrg while test ! -d "$_G_directory_path"; do 89942a55b46Smrg # ...make a list in topmost first order. Use a colon delimited 90042a55b46Smrg # list incase some portion of path contains whitespace. 901e3d74329Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 90242a55b46Smrg 90342a55b46Smrg # If the last portion added has no slash in it, the list is done 904e3d74329Smrg case $_G_directory_path in */*) ;; *) break ;; esac 90542a55b46Smrg 90642a55b46Smrg # ...otherwise throw away the child directory and loop 907e3d74329Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 90842a55b46Smrg done 909e3d74329Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 91042a55b46Smrg 911e3d74329Smrg func_mkdir_p_IFS=$IFS; IFS=: 912e3d74329Smrg for _G_dir in $_G_dir_list; do 913e3d74329Smrg IFS=$func_mkdir_p_IFS 914e3d74329Smrg # mkdir can fail with a 'File exist' error if two processes 91542a55b46Smrg # try to create one of the directories concurrently. Don't 91642a55b46Smrg # stop in that case! 917e3d74329Smrg $MKDIR "$_G_dir" 2>/dev/null || : 91842a55b46Smrg done 919e3d74329Smrg IFS=$func_mkdir_p_IFS 92042a55b46Smrg 92142a55b46Smrg # Bail out if we (or some other process) failed to create a directory. 922e3d74329Smrg test -d "$_G_directory_path" || \ 923e3d74329Smrg func_fatal_error "Failed to create '$1'" 92442a55b46Smrg fi 92542a55b46Smrg} 926c582b7e3Smrg 927c582b7e3Smrg 928e3d74329Smrg# func_mktempdir [BASENAME] 929e3d74329Smrg# ------------------------- 930c582b7e3Smrg# Make a temporary directory that won't clash with other running 931c582b7e3Smrg# libtool processes, and avoids race conditions if possible. If 932e3d74329Smrg# given, BASENAME is the basename for that directory. 933c582b7e3Smrgfunc_mktempdir () 934c582b7e3Smrg{ 935e3d74329Smrg $debug_cmd 936e3d74329Smrg 937e3d74329Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 938c582b7e3Smrg 939e3d74329Smrg if test : = "$opt_dry_run"; then 940c582b7e3Smrg # Return a directory name, but don't create it in dry-run mode 941e3d74329Smrg _G_tmpdir=$_G_template-$$ 942c582b7e3Smrg else 943c582b7e3Smrg 944c582b7e3Smrg # If mktemp works, use that first and foremost 945e3d74329Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 946c582b7e3Smrg 947e3d74329Smrg if test ! -d "$_G_tmpdir"; then 94842a55b46Smrg # Failing that, at least try and use $RANDOM to avoid a race 949e3d74329Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 950c582b7e3Smrg 951e3d74329Smrg func_mktempdir_umask=`umask` 95242a55b46Smrg umask 0077 953e3d74329Smrg $MKDIR "$_G_tmpdir" 954e3d74329Smrg umask $func_mktempdir_umask 955c582b7e3Smrg fi 956c582b7e3Smrg 957c582b7e3Smrg # If we're not in dry-run mode, bomb out on failure 958e3d74329Smrg test -d "$_G_tmpdir" || \ 959e3d74329Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 960c582b7e3Smrg fi 961c582b7e3Smrg 962e3d74329Smrg $ECHO "$_G_tmpdir" 963c582b7e3Smrg} 964c582b7e3Smrg 965c582b7e3Smrg 966e3d74329Smrg# func_normal_abspath PATH 967e3d74329Smrg# ------------------------ 968e3d74329Smrg# Remove doubled-up and trailing slashes, "." path components, 969e3d74329Smrg# and cancel out any ".." path components in PATH after making 970e3d74329Smrg# it an absolute path. 971e3d74329Smrgfunc_normal_abspath () 972c582b7e3Smrg{ 973e3d74329Smrg $debug_cmd 97442a55b46Smrg 975e3d74329Smrg # These SED scripts presuppose an absolute path with a trailing slash. 976e3d74329Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 977e3d74329Smrg _G_pathcdr='s|^/[^/]*||' 978e3d74329Smrg _G_removedotparts=':dotsl 979e3d74329Smrg s|/\./|/|g 980e3d74329Smrg t dotsl 981e3d74329Smrg s|/\.$|/|' 982e3d74329Smrg _G_collapseslashes='s|/\{1,\}|/|g' 983e3d74329Smrg _G_finalslash='s|/*$|/|' 984e3d74329Smrg 985e3d74329Smrg # Start from root dir and reassemble the path. 986e3d74329Smrg func_normal_abspath_result= 987e3d74329Smrg func_normal_abspath_tpath=$1 988e3d74329Smrg func_normal_abspath_altnamespace= 989e3d74329Smrg case $func_normal_abspath_tpath in 990e3d74329Smrg "") 991e3d74329Smrg # Empty path, that just means $cwd. 992e3d74329Smrg func_stripname '' '/' "`pwd`" 993e3d74329Smrg func_normal_abspath_result=$func_stripname_result 994e3d74329Smrg return 995e3d74329Smrg ;; 996e3d74329Smrg # The next three entries are used to spot a run of precisely 997e3d74329Smrg # two leading slashes without using negated character classes; 998e3d74329Smrg # we take advantage of case's first-match behaviour. 999e3d74329Smrg ///*) 1000e3d74329Smrg # Unusual form of absolute path, do nothing. 1001e3d74329Smrg ;; 1002e3d74329Smrg //*) 1003e3d74329Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 1004e3d74329Smrg # and for example Cygwin uses it to access remote file shares 1005e3d74329Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 1006e3d74329Smrg func_normal_abspath_altnamespace=/ 1007e3d74329Smrg ;; 1008e3d74329Smrg /*) 1009e3d74329Smrg # Absolute path, do nothing. 101042a55b46Smrg ;; 101142a55b46Smrg *) 1012e3d74329Smrg # Relative path, prepend $cwd. 1013e3d74329Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 1014e3d74329Smrg ;; 101542a55b46Smrg esac 1016e3d74329Smrg 1017e3d74329Smrg # Cancel out all the simple stuff to save iterations. We also want 1018e3d74329Smrg # the path to end with a slash for ease of parsing, so make sure 1019e3d74329Smrg # there is one (and only one) here. 1020e3d74329Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1021e3d74329Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 1022e3d74329Smrg while :; do 1023e3d74329Smrg # Processed it all yet? 1024e3d74329Smrg if test / = "$func_normal_abspath_tpath"; then 1025e3d74329Smrg # If we ascended to the root using ".." the result may be empty now. 1026e3d74329Smrg if test -z "$func_normal_abspath_result"; then 1027e3d74329Smrg func_normal_abspath_result=/ 1028e3d74329Smrg fi 1029e3d74329Smrg break 1030e3d74329Smrg fi 1031e3d74329Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1032e3d74329Smrg -e "$_G_pathcar"` 1033e3d74329Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1034e3d74329Smrg -e "$_G_pathcdr"` 1035e3d74329Smrg # Figure out what to do with it 1036e3d74329Smrg case $func_normal_abspath_tcomponent in 1037e3d74329Smrg "") 1038e3d74329Smrg # Trailing empty path component, ignore it. 1039e3d74329Smrg ;; 1040e3d74329Smrg ..) 1041e3d74329Smrg # Parent dir; strip last assembled component from result. 1042e3d74329Smrg func_dirname "$func_normal_abspath_result" 1043e3d74329Smrg func_normal_abspath_result=$func_dirname_result 1044e3d74329Smrg ;; 1045e3d74329Smrg *) 1046e3d74329Smrg # Actual path component, append it. 1047e3d74329Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1048e3d74329Smrg ;; 1049e3d74329Smrg esac 1050e3d74329Smrg done 1051e3d74329Smrg # Restore leading double-slash if one was found on entry. 1052e3d74329Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1053e3d74329Smrg} 1054e3d74329Smrg 1055e3d74329Smrg 1056e3d74329Smrg# func_notquiet ARG... 1057e3d74329Smrg# -------------------- 1058e3d74329Smrg# Echo program name prefixed message only when not in quiet mode. 1059e3d74329Smrgfunc_notquiet () 1060e3d74329Smrg{ 1061e3d74329Smrg $debug_cmd 1062e3d74329Smrg 1063e3d74329Smrg $opt_quiet || func_echo ${1+"$@"} 1064e3d74329Smrg 1065e3d74329Smrg # A bug in bash halts the script if the last line of a function 1066e3d74329Smrg # fails when set -e is in force, so we need another command to 1067e3d74329Smrg # work around that: 1068e3d74329Smrg : 1069e3d74329Smrg} 1070e3d74329Smrg 1071e3d74329Smrg 1072e3d74329Smrg# func_relative_path SRCDIR DSTDIR 1073e3d74329Smrg# -------------------------------- 1074e3d74329Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1075e3d74329Smrgfunc_relative_path () 1076e3d74329Smrg{ 1077e3d74329Smrg $debug_cmd 1078e3d74329Smrg 1079e3d74329Smrg func_relative_path_result= 1080e3d74329Smrg func_normal_abspath "$1" 1081e3d74329Smrg func_relative_path_tlibdir=$func_normal_abspath_result 1082e3d74329Smrg func_normal_abspath "$2" 1083e3d74329Smrg func_relative_path_tbindir=$func_normal_abspath_result 1084e3d74329Smrg 1085e3d74329Smrg # Ascend the tree starting from libdir 1086e3d74329Smrg while :; do 1087e3d74329Smrg # check if we have found a prefix of bindir 1088e3d74329Smrg case $func_relative_path_tbindir in 1089e3d74329Smrg $func_relative_path_tlibdir) 1090e3d74329Smrg # found an exact match 1091e3d74329Smrg func_relative_path_tcancelled= 1092e3d74329Smrg break 1093e3d74329Smrg ;; 1094e3d74329Smrg $func_relative_path_tlibdir*) 1095e3d74329Smrg # found a matching prefix 1096e3d74329Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1097e3d74329Smrg func_relative_path_tcancelled=$func_stripname_result 1098e3d74329Smrg if test -z "$func_relative_path_result"; then 1099e3d74329Smrg func_relative_path_result=. 1100e3d74329Smrg fi 1101e3d74329Smrg break 1102e3d74329Smrg ;; 1103e3d74329Smrg *) 1104e3d74329Smrg func_dirname $func_relative_path_tlibdir 1105e3d74329Smrg func_relative_path_tlibdir=$func_dirname_result 1106e3d74329Smrg if test -z "$func_relative_path_tlibdir"; then 1107e3d74329Smrg # Have to descend all the way to the root! 1108e3d74329Smrg func_relative_path_result=../$func_relative_path_result 1109e3d74329Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 1110e3d74329Smrg break 1111e3d74329Smrg fi 1112e3d74329Smrg func_relative_path_result=../$func_relative_path_result 1113e3d74329Smrg ;; 1114e3d74329Smrg esac 1115e3d74329Smrg done 1116e3d74329Smrg 1117e3d74329Smrg # Now calculate path; take care to avoid doubling-up slashes. 1118e3d74329Smrg func_stripname '' '/' "$func_relative_path_result" 1119e3d74329Smrg func_relative_path_result=$func_stripname_result 1120e3d74329Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 1121e3d74329Smrg if test -n "$func_stripname_result"; then 1122e3d74329Smrg func_append func_relative_path_result "/$func_stripname_result" 1123e3d74329Smrg fi 1124e3d74329Smrg 1125e3d74329Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 1126e3d74329Smrg if test -n "$func_relative_path_result"; then 1127e3d74329Smrg func_stripname './' '' "$func_relative_path_result" 1128e3d74329Smrg func_relative_path_result=$func_stripname_result 1129e3d74329Smrg fi 1130e3d74329Smrg 1131e3d74329Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 1132e3d74329Smrg 1133e3d74329Smrg : 113442a55b46Smrg} 113542a55b46Smrg 113642a55b46Smrg 11378ce07328Smrg# func_quote_portable EVAL ARG 11388ce07328Smrg# ---------------------------- 11398ce07328Smrg# Internal function to portably implement func_quote_arg. Note that we still 11408ce07328Smrg# keep attention to performance here so we as much as possible try to avoid 11418ce07328Smrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 11428ce07328Smrgfunc_quote_portable () 1143e3d74329Smrg{ 1144e3d74329Smrg $debug_cmd 1145e3d74329Smrg 11468ce07328Smrg $require_check_ifs_backslash 11478ce07328Smrg 11488ce07328Smrg func_quote_portable_result=$2 11498ce07328Smrg 11508ce07328Smrg # one-time-loop (easy break) 11518ce07328Smrg while true 11528ce07328Smrg do 11538ce07328Smrg if $1; then 11548ce07328Smrg func_quote_portable_result=`$ECHO "$2" | $SED \ 11558ce07328Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 11568ce07328Smrg break 1157e3d74329Smrg fi 1158e3d74329Smrg 11598ce07328Smrg # Quote for eval. 11608ce07328Smrg case $func_quote_portable_result in 11618ce07328Smrg *[\\\`\"\$]*) 11628ce07328Smrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 11638ce07328Smrg # contains the shell wildcard characters. 11648ce07328Smrg case $check_ifs_backshlash_broken$func_quote_portable_result in 11658ce07328Smrg :*|*[\[\*\?]*) 11668ce07328Smrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 11678ce07328Smrg | $SED "$sed_quote_subst"` 11688ce07328Smrg break 11698ce07328Smrg ;; 11708ce07328Smrg esac 11718ce07328Smrg 11728ce07328Smrg func_quote_portable_old_IFS=$IFS 11738ce07328Smrg for _G_char in '\' '`' '"' '$' 11748ce07328Smrg do 11758ce07328Smrg # STATE($1) PREV($2) SEPARATOR($3) 11768ce07328Smrg set start "" "" 11778ce07328Smrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 11788ce07328Smrg IFS=$_G_char 11798ce07328Smrg for _G_part in $func_quote_portable_result 11808ce07328Smrg do 11818ce07328Smrg case $1 in 11828ce07328Smrg quote) 11838ce07328Smrg func_append func_quote_portable_result "$3$2" 11848ce07328Smrg set quote "$_G_part" "\\$_G_char" 11858ce07328Smrg ;; 11868ce07328Smrg start) 11878ce07328Smrg set first "" "" 11888ce07328Smrg func_quote_portable_result= 11898ce07328Smrg ;; 11908ce07328Smrg first) 11918ce07328Smrg set quote "$_G_part" "" 11928ce07328Smrg ;; 11938ce07328Smrg esac 11948ce07328Smrg done 11958ce07328Smrg done 11968ce07328Smrg IFS=$func_quote_portable_old_IFS 1197e3d74329Smrg ;; 11988ce07328Smrg *) ;; 1199e3d74329Smrg esac 12008ce07328Smrg break 1201e3d74329Smrg done 12028ce07328Smrg 12038ce07328Smrg func_quote_portable_unquoted_result=$func_quote_portable_result 12048ce07328Smrg case $func_quote_portable_result in 12058ce07328Smrg # double-quote args containing shell metacharacters to delay 12068ce07328Smrg # word splitting, command substitution and variable expansion 12078ce07328Smrg # for a subsequent eval. 12088ce07328Smrg # many bourne shells cannot handle close brackets correctly 12098ce07328Smrg # in scan sets, so we specify it separately. 12108ce07328Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 12118ce07328Smrg func_quote_portable_result=\"$func_quote_portable_result\" 12128ce07328Smrg ;; 12138ce07328Smrg esac 1214e3d74329Smrg} 1215e3d74329Smrg 1216e3d74329Smrg 12178ce07328Smrg# func_quotefast_eval ARG 12188ce07328Smrg# ----------------------- 12198ce07328Smrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 12208ce07328Smrg# but optimized for speed. Result is stored in $func_quotefast_eval. 12218ce07328Smrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 12228ce07328Smrg printf -v _GL_test_printf_tilde %q '~' 12238ce07328Smrg if test '\~' = "$_GL_test_printf_tilde"; then 12248ce07328Smrg func_quotefast_eval () 12258ce07328Smrg { 12268ce07328Smrg printf -v func_quotefast_eval_result %q "$1" 12278ce07328Smrg } 12288ce07328Smrg else 12298ce07328Smrg # Broken older Bash implementations. Make those faster too if possible. 12308ce07328Smrg func_quotefast_eval () 12318ce07328Smrg { 12328ce07328Smrg case $1 in 12338ce07328Smrg '~'*) 12348ce07328Smrg func_quote_portable false "$1" 12358ce07328Smrg func_quotefast_eval_result=$func_quote_portable_result 12368ce07328Smrg ;; 12378ce07328Smrg *) 12388ce07328Smrg printf -v func_quotefast_eval_result %q "$1" 12398ce07328Smrg ;; 12408ce07328Smrg esac 12418ce07328Smrg } 12428ce07328Smrg fi 12438ce07328Smrgelse 12448ce07328Smrg func_quotefast_eval () 12458ce07328Smrg { 12468ce07328Smrg func_quote_portable false "$1" 12478ce07328Smrg func_quotefast_eval_result=$func_quote_portable_result 12488ce07328Smrg } 12498ce07328Smrgfi 1250e3d74329Smrg 12518ce07328Smrg 12528ce07328Smrg# func_quote_arg MODEs ARG 12538ce07328Smrg# ------------------------ 12548ce07328Smrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 12558ce07328Smrg# specifiers listed below separated by ',' character. This function returns two 12568ce07328Smrg# values: 12578ce07328Smrg# i) func_quote_arg_result 12588ce07328Smrg# double-quoted (when needed), suitable for a subsequent eval 12598ce07328Smrg# ii) func_quote_arg_unquoted_result 12608ce07328Smrg# has all characters that are still active within double 12618ce07328Smrg# quotes backslashified. Available only if 'unquoted' is specified. 12628ce07328Smrg# 12638ce07328Smrg# Available modes: 12648ce07328Smrg# ---------------- 12658ce07328Smrg# 'eval' (default) 12668ce07328Smrg# - escape shell special characters 12678ce07328Smrg# 'expand' 12688ce07328Smrg# - the same as 'eval'; but do not quote variable references 12698ce07328Smrg# 'pretty' 12708ce07328Smrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 12718ce07328Smrg# be used later in func_quote to get output like: 'echo "a b"' instead 12728ce07328Smrg# of 'echo a\ b'. This is slower than default on some shells. 12738ce07328Smrg# 'unquoted' 12748ce07328Smrg# - produce also $func_quote_arg_unquoted_result which does not contain 12758ce07328Smrg# wrapping double-quotes. 12768ce07328Smrg# 12778ce07328Smrg# Examples for 'func_quote_arg pretty,unquoted string': 12788ce07328Smrg# 12798ce07328Smrg# string | *_result | *_unquoted_result 12808ce07328Smrg# ------------+-----------------------+------------------- 12818ce07328Smrg# " | \" | \" 12828ce07328Smrg# a b | "a b" | a b 12838ce07328Smrg# "a b" | "\"a b\"" | \"a b\" 12848ce07328Smrg# * | "*" | * 12858ce07328Smrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 12868ce07328Smrg# 12878ce07328Smrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 12888ce07328Smrg# 12898ce07328Smrg# string | *_result | *_unquoted_result 12908ce07328Smrg# --------------+---------------------+-------------------- 12918ce07328Smrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 12928ce07328Smrgfunc_quote_arg () 12938ce07328Smrg{ 12948ce07328Smrg _G_quote_expand=false 12958ce07328Smrg case ,$1, in 12968ce07328Smrg *,expand,*) 12978ce07328Smrg _G_quote_expand=: 12988ce07328Smrg ;; 129942a55b46Smrg esac 130042a55b46Smrg 13018ce07328Smrg case ,$1, in 13028ce07328Smrg *,pretty,*|*,expand,*|*,unquoted,*) 13038ce07328Smrg func_quote_portable $_G_quote_expand "$2" 13048ce07328Smrg func_quote_arg_result=$func_quote_portable_result 13058ce07328Smrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 13068ce07328Smrg ;; 13078ce07328Smrg *) 13088ce07328Smrg # Faster quote-for-eval for some shells. 13098ce07328Smrg func_quotefast_eval "$2" 13108ce07328Smrg func_quote_arg_result=$func_quotefast_eval_result 131142a55b46Smrg ;; 131242a55b46Smrg esac 13138ce07328Smrg} 13148ce07328Smrg 131542a55b46Smrg 13168ce07328Smrg# func_quote MODEs ARGs... 13178ce07328Smrg# ------------------------ 13188ce07328Smrg# Quote all ARGs to be evaled later and join them into single command. See 13198ce07328Smrg# func_quote_arg's description for more info. 13208ce07328Smrgfunc_quote () 13218ce07328Smrg{ 13228ce07328Smrg $debug_cmd 13238ce07328Smrg _G_func_quote_mode=$1 ; shift 13248ce07328Smrg func_quote_result= 13258ce07328Smrg while test 0 -lt $#; do 13268ce07328Smrg func_quote_arg "$_G_func_quote_mode" "$1" 13278ce07328Smrg if test -n "$func_quote_result"; then 13288ce07328Smrg func_append func_quote_result " $func_quote_arg_result" 13298ce07328Smrg else 13308ce07328Smrg func_append func_quote_result "$func_quote_arg_result" 13318ce07328Smrg fi 13328ce07328Smrg shift 13338ce07328Smrg done 1334e3d74329Smrg} 1335e3d74329Smrg 1336e3d74329Smrg 1337e3d74329Smrg# func_stripname PREFIX SUFFIX NAME 1338e3d74329Smrg# --------------------------------- 1339e3d74329Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1340e3d74329Smrg# PREFIX and SUFFIX must not contain globbing or regex special 1341e3d74329Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 1342e3d74329Smrg# dot (in which case that matches only a dot). 1343e3d74329Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 1344e3d74329Smrg eval 'func_stripname () 1345e3d74329Smrg { 1346e3d74329Smrg $debug_cmd 1347e3d74329Smrg 1348e3d74329Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1349e3d74329Smrg # positional parameters, so assign one to ordinary variable first. 1350e3d74329Smrg func_stripname_result=$3 1351e3d74329Smrg func_stripname_result=${func_stripname_result#"$1"} 1352e3d74329Smrg func_stripname_result=${func_stripname_result%"$2"} 1353e3d74329Smrg }' 1354e3d74329Smrgelse 1355e3d74329Smrg func_stripname () 1356e3d74329Smrg { 1357e3d74329Smrg $debug_cmd 1358e3d74329Smrg 1359e3d74329Smrg case $2 in 1360e3d74329Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1361e3d74329Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1362e3d74329Smrg esac 1363e3d74329Smrg } 1364e3d74329Smrgfi 1365e3d74329Smrg 1366e3d74329Smrg 1367e3d74329Smrg# func_show_eval CMD [FAIL_EXP] 1368e3d74329Smrg# ----------------------------- 1369e3d74329Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1370e3d74329Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1371e3d74329Smrg# is given, then evaluate it. 1372e3d74329Smrgfunc_show_eval () 1373e3d74329Smrg{ 1374e3d74329Smrg $debug_cmd 1375e3d74329Smrg 1376e3d74329Smrg _G_cmd=$1 1377e3d74329Smrg _G_fail_exp=${2-':'} 1378e3d74329Smrg 13798ce07328Smrg func_quote_arg pretty,expand "$_G_cmd" 13808ce07328Smrg eval "func_notquiet $func_quote_arg_result" 1381e3d74329Smrg 1382e3d74329Smrg $opt_dry_run || { 1383e3d74329Smrg eval "$_G_cmd" 1384e3d74329Smrg _G_status=$? 1385e3d74329Smrg if test 0 -ne "$_G_status"; then 1386e3d74329Smrg eval "(exit $_G_status); $_G_fail_exp" 1387e3d74329Smrg fi 1388e3d74329Smrg } 1389e3d74329Smrg} 1390e3d74329Smrg 1391e3d74329Smrg 1392e3d74329Smrg# func_show_eval_locale CMD [FAIL_EXP] 1393e3d74329Smrg# ------------------------------------ 1394e3d74329Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1395e3d74329Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1396e3d74329Smrg# is given, then evaluate it. Use the saved locale for evaluation. 1397e3d74329Smrgfunc_show_eval_locale () 1398e3d74329Smrg{ 1399e3d74329Smrg $debug_cmd 1400e3d74329Smrg 1401e3d74329Smrg _G_cmd=$1 1402e3d74329Smrg _G_fail_exp=${2-':'} 1403e3d74329Smrg 1404e3d74329Smrg $opt_quiet || { 14058ce07328Smrg func_quote_arg expand,pretty "$_G_cmd" 14068ce07328Smrg eval "func_echo $func_quote_arg_result" 1407e3d74329Smrg } 1408e3d74329Smrg 1409e3d74329Smrg $opt_dry_run || { 1410e3d74329Smrg eval "$_G_user_locale 1411e3d74329Smrg $_G_cmd" 1412e3d74329Smrg _G_status=$? 1413e3d74329Smrg eval "$_G_safe_locale" 1414e3d74329Smrg if test 0 -ne "$_G_status"; then 1415e3d74329Smrg eval "(exit $_G_status); $_G_fail_exp" 1416e3d74329Smrg fi 1417e3d74329Smrg } 1418e3d74329Smrg} 1419e3d74329Smrg 1420e3d74329Smrg 1421e3d74329Smrg# func_tr_sh 1422e3d74329Smrg# ---------- 1423e3d74329Smrg# Turn $1 into a string suitable for a shell variable name. 1424e3d74329Smrg# Result is stored in $func_tr_sh_result. All characters 1425e3d74329Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1426e3d74329Smrg# if $1 begins with a digit, a '_' is prepended as well. 1427e3d74329Smrgfunc_tr_sh () 1428e3d74329Smrg{ 1429e3d74329Smrg $debug_cmd 1430e3d74329Smrg 1431e3d74329Smrg case $1 in 1432e3d74329Smrg [0-9]* | *[!a-zA-Z0-9_]*) 1433e3d74329Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1434e3d74329Smrg ;; 1435e3d74329Smrg * ) 1436e3d74329Smrg func_tr_sh_result=$1 1437e3d74329Smrg ;; 1438e3d74329Smrg esac 1439e3d74329Smrg} 1440e3d74329Smrg 1441e3d74329Smrg 1442e3d74329Smrg# func_verbose ARG... 1443e3d74329Smrg# ------------------- 1444e3d74329Smrg# Echo program name prefixed message in verbose mode only. 1445e3d74329Smrgfunc_verbose () 1446e3d74329Smrg{ 1447e3d74329Smrg $debug_cmd 1448e3d74329Smrg 1449e3d74329Smrg $opt_verbose && func_echo "$*" 1450e3d74329Smrg 1451e3d74329Smrg : 1452e3d74329Smrg} 1453e3d74329Smrg 1454e3d74329Smrg 1455e3d74329Smrg# func_warn_and_continue ARG... 1456e3d74329Smrg# ----------------------------- 1457e3d74329Smrg# Echo program name prefixed warning message to standard error. 1458e3d74329Smrgfunc_warn_and_continue () 1459e3d74329Smrg{ 1460e3d74329Smrg $debug_cmd 1461e3d74329Smrg 1462e3d74329Smrg $require_term_colors 1463e3d74329Smrg 1464e3d74329Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1465e3d74329Smrg} 1466e3d74329Smrg 1467e3d74329Smrg 1468e3d74329Smrg# func_warning CATEGORY ARG... 1469e3d74329Smrg# ---------------------------- 1470e3d74329Smrg# Echo program name prefixed warning message to standard error. Warning 1471e3d74329Smrg# messages can be filtered according to CATEGORY, where this function 1472e3d74329Smrg# elides messages where CATEGORY is not listed in the global variable 1473e3d74329Smrg# 'opt_warning_types'. 1474e3d74329Smrgfunc_warning () 1475e3d74329Smrg{ 1476e3d74329Smrg $debug_cmd 1477e3d74329Smrg 1478e3d74329Smrg # CATEGORY must be in the warning_categories list! 1479e3d74329Smrg case " $warning_categories " in 1480e3d74329Smrg *" $1 "*) ;; 1481e3d74329Smrg *) func_internal_error "invalid warning category '$1'" ;; 1482e3d74329Smrg esac 1483e3d74329Smrg 1484e3d74329Smrg _G_category=$1 1485e3d74329Smrg shift 1486e3d74329Smrg 1487e3d74329Smrg case " $opt_warning_types " in 1488e3d74329Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 1489e3d74329Smrg esac 149042a55b46Smrg} 149142a55b46Smrg 149242a55b46Smrg 1493e3d74329Smrg# func_sort_ver VER1 VER2 1494e3d74329Smrg# ----------------------- 1495e3d74329Smrg# 'sort -V' is not generally available. 1496e3d74329Smrg# Note this deviates from the version comparison in automake 1497e3d74329Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1498e3d74329Smrg# but this should suffice as we won't be specifying old 1499e3d74329Smrg# version formats or redundant trailing .0 in bootstrap.conf. 1500e3d74329Smrg# If we did want full compatibility then we should probably 1501e3d74329Smrg# use m4_version_compare from autoconf. 1502e3d74329Smrgfunc_sort_ver () 1503e3d74329Smrg{ 1504e3d74329Smrg $debug_cmd 1505e3d74329Smrg 1506e3d74329Smrg printf '%s\n%s\n' "$1" "$2" \ 1507e3d74329Smrg | 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 1508e3d74329Smrg} 1509e3d74329Smrg 1510e3d74329Smrg# func_lt_ver PREV CURR 1511e3d74329Smrg# --------------------- 1512e3d74329Smrg# Return true if PREV and CURR are in the correct order according to 1513e3d74329Smrg# func_sort_ver, otherwise false. Use it like this: 1514e3d74329Smrg# 1515e3d74329Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1516e3d74329Smrgfunc_lt_ver () 1517e3d74329Smrg{ 1518e3d74329Smrg $debug_cmd 1519e3d74329Smrg 1520e3d74329Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1521e3d74329Smrg} 1522e3d74329Smrg 1523e3d74329Smrg 1524e3d74329Smrg# Local variables: 1525e3d74329Smrg# mode: shell-script 1526e3d74329Smrg# sh-indentation: 2 1527e3d74329Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 1528e3d74329Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1529e3d74329Smrg# time-stamp-time-zone: "UTC" 1530e3d74329Smrg# End: 1531e3d74329Smrg#! /bin/sh 1532e3d74329Smrg 1533e3d74329Smrg# A portable, pluggable option parser for Bourne shell. 1534e3d74329Smrg# Written by Gary V. Vaughan, 2010 1535e3d74329Smrg 15368ce07328Smrg# This is free software. There is NO warranty; not even for 15378ce07328Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15388ce07328Smrg# 15398ce07328Smrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 15408ce07328Smrg# 15418ce07328Smrg# This file is dual licensed under the terms of the MIT license 15428ce07328Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 15438ce07328Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 15448ce07328Smrg# these licenses when using or redistributing this software or any of 15458ce07328Smrg# the files within it. See the URLs above, or the file `LICENSE` 15468ce07328Smrg# included in the Bootstrap distribution for the full license texts. 1547e3d74329Smrg 15488ce07328Smrg# Please report bugs or propose patches to: 15498ce07328Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 1550e3d74329Smrg 15518ce07328Smrg# Set a version string for this script. 15528ce07328Smrgscriptversion=2019-02-19.15; # UTC 1553e3d74329Smrg 1554e3d74329Smrg 1555e3d74329Smrg## ------ ## 1556e3d74329Smrg## Usage. ## 1557e3d74329Smrg## ------ ## 1558e3d74329Smrg 1559e3d74329Smrg# This file is a library for parsing options in your shell scripts along 1560e3d74329Smrg# with assorted other useful supporting features that you can make use 1561e3d74329Smrg# of too. 1562e3d74329Smrg# 1563e3d74329Smrg# For the simplest scripts you might need only: 1564e3d74329Smrg# 1565e3d74329Smrg# #!/bin/sh 1566e3d74329Smrg# . relative/path/to/funclib.sh 1567e3d74329Smrg# . relative/path/to/options-parser 1568e3d74329Smrg# scriptversion=1.0 1569e3d74329Smrg# func_options ${1+"$@"} 1570e3d74329Smrg# eval set dummy "$func_options_result"; shift 1571e3d74329Smrg# ...rest of your script... 1572e3d74329Smrg# 1573e3d74329Smrg# In order for the '--version' option to work, you will need to have a 1574e3d74329Smrg# suitably formatted comment like the one at the top of this file 15758ce07328Smrg# starting with '# Written by ' and ending with '# Copyright'. 1576e3d74329Smrg# 1577e3d74329Smrg# For '-h' and '--help' to work, you will also need a one line 1578e3d74329Smrg# description of your script's purpose in a comment directly above the 1579e3d74329Smrg# '# Written by ' line, like the one at the top of this file. 1580e3d74329Smrg# 1581e3d74329Smrg# The default options also support '--debug', which will turn on shell 1582e3d74329Smrg# execution tracing (see the comment above debug_cmd below for another 1583e3d74329Smrg# use), and '--verbose' and the func_verbose function to allow your script 1584e3d74329Smrg# to display verbose messages only when your user has specified 1585e3d74329Smrg# '--verbose'. 1586e3d74329Smrg# 15878ce07328Smrg# After sourcing this file, you can plug in processing for additional 1588e3d74329Smrg# options by amending the variables from the 'Configuration' section 1589e3d74329Smrg# below, and following the instructions in the 'Option parsing' 1590e3d74329Smrg# section further down. 1591e3d74329Smrg 1592e3d74329Smrg## -------------- ## 1593e3d74329Smrg## Configuration. ## 1594e3d74329Smrg## -------------- ## 1595e3d74329Smrg 1596e3d74329Smrg# You should override these variables in your script after sourcing this 1597e3d74329Smrg# file so that they reflect the customisations you have added to the 1598e3d74329Smrg# option parser. 1599e3d74329Smrg 1600e3d74329Smrg# The usage line for option parsing errors and the start of '-h' and 1601e3d74329Smrg# '--help' output messages. You can embed shell variables for delayed 1602e3d74329Smrg# expansion at the time the message is displayed, but you will need to 1603e3d74329Smrg# quote other shell meta-characters carefully to prevent them being 1604e3d74329Smrg# expanded when the contents are evaled. 1605e3d74329Smrgusage='$progpath [OPTION]...' 1606e3d74329Smrg 1607e3d74329Smrg# Short help message in response to '-h' and '--help'. Add to this or 1608e3d74329Smrg# override it after sourcing this library to reflect the full set of 1609e3d74329Smrg# options your script accepts. 1610e3d74329Smrgusage_message="\ 1611e3d74329Smrg --debug enable verbose shell tracing 1612e3d74329Smrg -W, --warnings=CATEGORY 1613e3d74329Smrg report the warnings falling in CATEGORY [all] 1614e3d74329Smrg -v, --verbose verbosely report processing 1615e3d74329Smrg --version print version information and exit 1616e3d74329Smrg -h, --help print short or long help message and exit 1617e3d74329Smrg" 1618e3d74329Smrg 1619e3d74329Smrg# Additional text appended to 'usage_message' in response to '--help'. 1620e3d74329Smrglong_help_message=" 1621e3d74329SmrgWarning categories include: 1622e3d74329Smrg 'all' show all warnings 1623e3d74329Smrg 'none' turn off all the warnings 1624e3d74329Smrg 'error' warnings are treated as fatal errors" 1625e3d74329Smrg 1626e3d74329Smrg# Help message printed before fatal option parsing errors. 1627e3d74329Smrgfatal_help="Try '\$progname --help' for more information." 1628e3d74329Smrg 1629e3d74329Smrg 1630e3d74329Smrg 1631e3d74329Smrg## ------------------------- ## 1632e3d74329Smrg## Hook function management. ## 1633e3d74329Smrg## ------------------------- ## 1634e3d74329Smrg 1635e3d74329Smrg# This section contains functions for adding, removing, and running hooks 16368ce07328Smrg# in the main code. A hook is just a list of function names that can be 16378ce07328Smrg# run in order later on. 1638e3d74329Smrg 1639e3d74329Smrg# func_hookable FUNC_NAME 1640e3d74329Smrg# ----------------------- 1641e3d74329Smrg# Declare that FUNC_NAME will run hooks added with 1642e3d74329Smrg# 'func_add_hook FUNC_NAME ...'. 1643e3d74329Smrgfunc_hookable () 1644e3d74329Smrg{ 1645e3d74329Smrg $debug_cmd 1646e3d74329Smrg 1647e3d74329Smrg func_append hookable_fns " $1" 1648e3d74329Smrg} 1649e3d74329Smrg 1650e3d74329Smrg 1651e3d74329Smrg# func_add_hook FUNC_NAME HOOK_FUNC 1652e3d74329Smrg# --------------------------------- 1653e3d74329Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1654e3d74329Smrg# first have been declared "hookable" by a call to 'func_hookable'. 1655e3d74329Smrgfunc_add_hook () 1656e3d74329Smrg{ 1657e3d74329Smrg $debug_cmd 1658e3d74329Smrg 1659e3d74329Smrg case " $hookable_fns " in 1660e3d74329Smrg *" $1 "*) ;; 1661e3d74329Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 1662e3d74329Smrg esac 1663e3d74329Smrg 1664e3d74329Smrg eval func_append ${1}_hooks '" $2"' 1665e3d74329Smrg} 1666e3d74329Smrg 1667e3d74329Smrg 1668e3d74329Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 1669e3d74329Smrg# ------------------------------------ 16708ce07328Smrg# Remove HOOK_FUNC from the list of hook functions to be called by 16718ce07328Smrg# FUNC_NAME. 1672e3d74329Smrgfunc_remove_hook () 1673e3d74329Smrg{ 1674e3d74329Smrg $debug_cmd 1675e3d74329Smrg 1676e3d74329Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1677e3d74329Smrg} 1678e3d74329Smrg 1679e3d74329Smrg 16808ce07328Smrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 16818ce07328Smrg# --------------------------------------------- 16828ce07328Smrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 16838ce07328Smrg# *_result variable of FUNC_NAME_B. 16848ce07328Smrgfunc_propagate_result () 16858ce07328Smrg{ 16868ce07328Smrg $debug_cmd 16878ce07328Smrg 16888ce07328Smrg func_propagate_result_result=: 16898ce07328Smrg if eval "test \"\${${1}_result+set}\" = set" 16908ce07328Smrg then 16918ce07328Smrg eval "${2}_result=\$${1}_result" 16928ce07328Smrg else 16938ce07328Smrg func_propagate_result_result=false 16948ce07328Smrg fi 16958ce07328Smrg} 16968ce07328Smrg 16978ce07328Smrg 1698e3d74329Smrg# func_run_hooks FUNC_NAME [ARG]... 1699e3d74329Smrg# --------------------------------- 1700e3d74329Smrg# Run all hook functions registered to FUNC_NAME. 17018ce07328Smrg# It's assumed that the list of hook functions contains nothing more 1702e3d74329Smrg# than a whitespace-delimited list of legal shell function names, and 1703e3d74329Smrg# no effort is wasted trying to catch shell meta-characters or preserve 1704e3d74329Smrg# whitespace. 1705e3d74329Smrgfunc_run_hooks () 1706e3d74329Smrg{ 1707e3d74329Smrg $debug_cmd 1708e3d74329Smrg 1709e3d74329Smrg case " $hookable_fns " in 1710e3d74329Smrg *" $1 "*) ;; 17118ce07328Smrg *) func_fatal_error "'$1' does not support hook functions." ;; 1712e3d74329Smrg esac 1713e3d74329Smrg 1714e3d74329Smrg eval _G_hook_fns=\$$1_hooks; shift 1715e3d74329Smrg 1716e3d74329Smrg for _G_hook in $_G_hook_fns; do 17178ce07328Smrg func_unset "${_G_hook}_result" 17188ce07328Smrg eval $_G_hook '${1+"$@"}' 17198ce07328Smrg func_propagate_result $_G_hook func_run_hooks 17208ce07328Smrg if $func_propagate_result_result; then 17218ce07328Smrg eval set dummy "$func_run_hooks_result"; shift 17228ce07328Smrg fi 1723e3d74329Smrg done 1724e3d74329Smrg} 1725e3d74329Smrg 1726e3d74329Smrg 1727e3d74329Smrg 1728e3d74329Smrg## --------------- ## 1729e3d74329Smrg## Option parsing. ## 1730e3d74329Smrg## --------------- ## 1731e3d74329Smrg 1732e3d74329Smrg# In order to add your own option parsing hooks, you must accept the 17338ce07328Smrg# full positional parameter list from your hook function. You may remove 17348ce07328Smrg# or edit any options that you action, and then pass back the remaining 17358ce07328Smrg# unprocessed options in '<hooked_function_name>_result', escaped 17368ce07328Smrg# suitably for 'eval'. 17378ce07328Smrg# 17388ce07328Smrg# The '<hooked_function_name>_result' variable is automatically unset 17398ce07328Smrg# before your hook gets called; for best performance, only set the 17408ce07328Smrg# *_result variable when necessary (i.e. don't call the 'func_quote' 17418ce07328Smrg# function unnecessarily because it can be an expensive operation on some 17428ce07328Smrg# machines). 17438ce07328Smrg# 17448ce07328Smrg# Like this: 1745e3d74329Smrg# 1746e3d74329Smrg# my_options_prep () 1747e3d74329Smrg# { 1748e3d74329Smrg# $debug_cmd 1749e3d74329Smrg# 1750e3d74329Smrg# # Extend the existing usage message. 1751e3d74329Smrg# usage_message=$usage_message' 1752e3d74329Smrg# -s, --silent don'\''t print informational messages 1753e3d74329Smrg# ' 17548ce07328Smrg# # No change in '$@' (ignored completely by this hook). Leave 17558ce07328Smrg# # my_options_prep_result variable intact. 1756e3d74329Smrg# } 1757e3d74329Smrg# func_add_hook func_options_prep my_options_prep 1758e3d74329Smrg# 1759e3d74329Smrg# 1760e3d74329Smrg# my_silent_option () 1761e3d74329Smrg# { 1762e3d74329Smrg# $debug_cmd 1763e3d74329Smrg# 17648ce07328Smrg# args_changed=false 17658ce07328Smrg# 17668ce07328Smrg# # Note that, for efficiency, we parse as many options as we can 1767e3d74329Smrg# # recognise in a loop before passing the remainder back to the 1768e3d74329Smrg# # caller on the first unrecognised argument we encounter. 1769e3d74329Smrg# while test $# -gt 0; do 1770e3d74329Smrg# opt=$1; shift 1771e3d74329Smrg# case $opt in 17728ce07328Smrg# --silent|-s) opt_silent=: 17738ce07328Smrg# args_changed=: 17748ce07328Smrg# ;; 1775e3d74329Smrg# # Separate non-argument short options: 1776e3d74329Smrg# -s*) func_split_short_opt "$_G_opt" 1777e3d74329Smrg# set dummy "$func_split_short_opt_name" \ 1778e3d74329Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 1779e3d74329Smrg# shift 17808ce07328Smrg# args_changed=: 1781e3d74329Smrg# ;; 17828ce07328Smrg# *) # Make sure the first unrecognised option "$_G_opt" 17838ce07328Smrg# # is added back to "$@" in case we need it later, 17848ce07328Smrg# # if $args_changed was set to 'true'. 17858ce07328Smrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1786e3d74329Smrg# esac 1787e3d74329Smrg# done 1788e3d74329Smrg# 17898ce07328Smrg# # Only call 'func_quote' here if we processed at least one argument. 17908ce07328Smrg# if $args_changed; then 17918ce07328Smrg# func_quote eval ${1+"$@"} 17928ce07328Smrg# my_silent_option_result=$func_quote_result 17938ce07328Smrg# fi 1794e3d74329Smrg# } 1795e3d74329Smrg# func_add_hook func_parse_options my_silent_option 1796e3d74329Smrg# 1797e3d74329Smrg# 1798e3d74329Smrg# my_option_validation () 1799e3d74329Smrg# { 1800e3d74329Smrg# $debug_cmd 1801e3d74329Smrg# 1802e3d74329Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 1803e3d74329Smrg# '--silent' and '--verbose' options are mutually exclusive." 1804e3d74329Smrg# } 1805e3d74329Smrg# func_add_hook func_validate_options my_option_validation 1806e3d74329Smrg# 18078ce07328Smrg# You'll also need to manually amend $usage_message to reflect the extra 1808e3d74329Smrg# options you parse. It's preferable to append if you can, so that 1809e3d74329Smrg# multiple option parsing hooks can be added safely. 1810e3d74329Smrg 1811e3d74329Smrg 18128ce07328Smrg# func_options_finish [ARG]... 18138ce07328Smrg# ---------------------------- 18148ce07328Smrg# Finishing the option parse loop (call 'func_options' hooks ATM). 18158ce07328Smrgfunc_options_finish () 18168ce07328Smrg{ 18178ce07328Smrg $debug_cmd 18188ce07328Smrg 18198ce07328Smrg func_run_hooks func_options ${1+"$@"} 18208ce07328Smrg func_propagate_result func_run_hooks func_options_finish 18218ce07328Smrg} 18228ce07328Smrg 18238ce07328Smrg 1824e3d74329Smrg# func_options [ARG]... 1825e3d74329Smrg# --------------------- 1826e3d74329Smrg# All the functions called inside func_options are hookable. See the 1827e3d74329Smrg# individual implementations for details. 1828e3d74329Smrgfunc_hookable func_options 1829e3d74329Smrgfunc_options () 183042a55b46Smrg{ 1831e3d74329Smrg $debug_cmd 183242a55b46Smrg 18338ce07328Smrg _G_options_quoted=false 183442a55b46Smrg 18358ce07328Smrg for my_func in options_prep parse_options validate_options options_finish 18368ce07328Smrg do 18378ce07328Smrg func_unset func_${my_func}_result 18388ce07328Smrg func_unset func_run_hooks_result 18398ce07328Smrg eval func_$my_func '${1+"$@"}' 18408ce07328Smrg func_propagate_result func_$my_func func_options 18418ce07328Smrg if $func_propagate_result_result; then 18428ce07328Smrg eval set dummy "$func_options_result"; shift 18438ce07328Smrg _G_options_quoted=: 18448ce07328Smrg fi 18458ce07328Smrg done 1846e3d74329Smrg 18478ce07328Smrg $_G_options_quoted || { 18488ce07328Smrg # As we (func_options) are top-level options-parser function and 18498ce07328Smrg # nobody quoted "$@" for us yet, we need to do it explicitly for 18508ce07328Smrg # caller. 18518ce07328Smrg func_quote eval ${1+"$@"} 18528ce07328Smrg func_options_result=$func_quote_result 18538ce07328Smrg } 185442a55b46Smrg} 185542a55b46Smrg 185642a55b46Smrg 1857e3d74329Smrg# func_options_prep [ARG]... 1858e3d74329Smrg# -------------------------- 1859e3d74329Smrg# All initialisations required before starting the option parse loop. 1860e3d74329Smrg# Note that when calling hook functions, we pass through the list of 1861e3d74329Smrg# positional parameters. If a hook function modifies that list, and 18628ce07328Smrg# needs to propagate that back to rest of this script, then the complete 18638ce07328Smrg# modified list must be put in 'func_run_hooks_result' before returning. 1864e3d74329Smrgfunc_hookable func_options_prep 1865e3d74329Smrgfunc_options_prep () 186642a55b46Smrg{ 1867e3d74329Smrg $debug_cmd 186842a55b46Smrg 1869e3d74329Smrg # Option defaults: 1870e3d74329Smrg opt_verbose=false 1871e3d74329Smrg opt_warning_types= 187242a55b46Smrg 1873e3d74329Smrg func_run_hooks func_options_prep ${1+"$@"} 18748ce07328Smrg func_propagate_result func_run_hooks func_options_prep 187542a55b46Smrg} 187642a55b46Smrg 1877e3d74329Smrg 1878e3d74329Smrg# func_parse_options [ARG]... 1879e3d74329Smrg# --------------------------- 1880e3d74329Smrg# The main option parsing loop. 1881e3d74329Smrgfunc_hookable func_parse_options 1882e3d74329Smrgfunc_parse_options () 188342a55b46Smrg{ 1884e3d74329Smrg $debug_cmd 1885e3d74329Smrg 18868ce07328Smrg _G_parse_options_requote=false 1887e3d74329Smrg # this just eases exit handling 1888e3d74329Smrg while test $# -gt 0; do 1889e3d74329Smrg # Defer to hook functions for initial option parsing, so they 1890e3d74329Smrg # get priority in the event of reusing an option name. 1891e3d74329Smrg func_run_hooks func_parse_options ${1+"$@"} 18928ce07328Smrg func_propagate_result func_run_hooks func_parse_options 18938ce07328Smrg if $func_propagate_result_result; then 18948ce07328Smrg eval set dummy "$func_parse_options_result"; shift 18958ce07328Smrg # Even though we may have changed "$@", we passed the "$@" array 18968ce07328Smrg # down into the hook and it quoted it for us (because we are in 18978ce07328Smrg # this if-branch). No need to quote it again. 18988ce07328Smrg _G_parse_options_requote=false 18998ce07328Smrg fi 1900e3d74329Smrg 1901e3d74329Smrg # Break out of the loop if we already parsed every option. 1902e3d74329Smrg test $# -gt 0 || break 1903e3d74329Smrg 19048ce07328Smrg # We expect that one of the options parsed in this function matches 19058ce07328Smrg # and thus we remove _G_opt from "$@" and need to re-quote. 19068ce07328Smrg _G_match_parse_options=: 1907e3d74329Smrg _G_opt=$1 1908e3d74329Smrg shift 1909e3d74329Smrg case $_G_opt in 1910e3d74329Smrg --debug|-x) debug_cmd='set -x' 19118ce07328Smrg func_echo "enabling shell trace mode" >&2 1912e3d74329Smrg $debug_cmd 1913e3d74329Smrg ;; 1914e3d74329Smrg 1915e3d74329Smrg --no-warnings|--no-warning|--no-warn) 1916e3d74329Smrg set dummy --warnings none ${1+"$@"} 1917e3d74329Smrg shift 1918e3d74329Smrg ;; 1919e3d74329Smrg 1920e3d74329Smrg --warnings|--warning|-W) 19218ce07328Smrg if test $# = 0 && func_missing_arg $_G_opt; then 19228ce07328Smrg _G_parse_options_requote=: 19238ce07328Smrg break 19248ce07328Smrg fi 1925e3d74329Smrg case " $warning_categories $1" in 1926e3d74329Smrg *" $1 "*) 1927e3d74329Smrg # trailing space prevents matching last $1 above 1928e3d74329Smrg func_append_uniq opt_warning_types " $1" 1929e3d74329Smrg ;; 1930e3d74329Smrg *all) 1931e3d74329Smrg opt_warning_types=$warning_categories 1932e3d74329Smrg ;; 1933e3d74329Smrg *none) 1934e3d74329Smrg opt_warning_types=none 1935e3d74329Smrg warning_func=: 1936e3d74329Smrg ;; 1937e3d74329Smrg *error) 1938e3d74329Smrg opt_warning_types=$warning_categories 1939e3d74329Smrg warning_func=func_fatal_error 1940e3d74329Smrg ;; 1941e3d74329Smrg *) 1942e3d74329Smrg func_fatal_error \ 1943e3d74329Smrg "unsupported warning category: '$1'" 1944e3d74329Smrg ;; 1945e3d74329Smrg esac 1946e3d74329Smrg shift 1947e3d74329Smrg ;; 1948e3d74329Smrg 1949e3d74329Smrg --verbose|-v) opt_verbose=: ;; 1950e3d74329Smrg --version) func_version ;; 1951e3d74329Smrg -\?|-h) func_usage ;; 1952e3d74329Smrg --help) func_help ;; 1953e3d74329Smrg 1954e3d74329Smrg # Separate optargs to long options (plugins may need this): 1955e3d74329Smrg --*=*) func_split_equals "$_G_opt" 1956e3d74329Smrg set dummy "$func_split_equals_lhs" \ 1957e3d74329Smrg "$func_split_equals_rhs" ${1+"$@"} 1958e3d74329Smrg shift 1959e3d74329Smrg ;; 1960e3d74329Smrg 1961e3d74329Smrg # Separate optargs to short options: 1962e3d74329Smrg -W*) 1963e3d74329Smrg func_split_short_opt "$_G_opt" 1964e3d74329Smrg set dummy "$func_split_short_opt_name" \ 1965e3d74329Smrg "$func_split_short_opt_arg" ${1+"$@"} 1966e3d74329Smrg shift 1967e3d74329Smrg ;; 1968e3d74329Smrg 1969e3d74329Smrg # Separate non-argument short options: 1970e3d74329Smrg -\?*|-h*|-v*|-x*) 1971e3d74329Smrg func_split_short_opt "$_G_opt" 1972e3d74329Smrg set dummy "$func_split_short_opt_name" \ 1973e3d74329Smrg "-$func_split_short_opt_arg" ${1+"$@"} 1974e3d74329Smrg shift 1975e3d74329Smrg ;; 1976e3d74329Smrg 19778ce07328Smrg --) _G_parse_options_requote=: ; break ;; 1978e3d74329Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 19798ce07328Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift 19808ce07328Smrg _G_match_parse_options=false 19818ce07328Smrg break 19828ce07328Smrg ;; 1983e3d74329Smrg esac 19848ce07328Smrg 19858ce07328Smrg if $_G_match_parse_options; then 19868ce07328Smrg _G_parse_options_requote=: 19878ce07328Smrg fi 1988e3d74329Smrg done 1989e3d74329Smrg 19908ce07328Smrg if $_G_parse_options_requote; then 19918ce07328Smrg # save modified positional parameters for caller 19928ce07328Smrg func_quote eval ${1+"$@"} 19938ce07328Smrg func_parse_options_result=$func_quote_result 19948ce07328Smrg fi 1995c582b7e3Smrg} 1996c582b7e3Smrg 1997c582b7e3Smrg 1998e3d74329Smrg# func_validate_options [ARG]... 1999e3d74329Smrg# ------------------------------ 2000e3d74329Smrg# Perform any sanity checks on option settings and/or unconsumed 2001e3d74329Smrg# arguments. 2002e3d74329Smrgfunc_hookable func_validate_options 2003e3d74329Smrgfunc_validate_options () 2004c582b7e3Smrg{ 2005e3d74329Smrg $debug_cmd 200642a55b46Smrg 2007e3d74329Smrg # Display all warnings if -W was not given. 2008e3d74329Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 2009e3d74329Smrg 2010e3d74329Smrg func_run_hooks func_validate_options ${1+"$@"} 20118ce07328Smrg func_propagate_result func_run_hooks func_validate_options 2012e3d74329Smrg 2013e3d74329Smrg # Bail if the options were screwed! 2014e3d74329Smrg $exit_cmd $EXIT_FAILURE 2015c582b7e3Smrg} 2016c582b7e3Smrg 2017e3d74329Smrg 2018e3d74329Smrg 2019e3d74329Smrg## ----------------- ## 2020e3d74329Smrg## Helper functions. ## 2021e3d74329Smrg## ----------------- ## 2022e3d74329Smrg 2023e3d74329Smrg# This section contains the helper functions used by the rest of the 2024e3d74329Smrg# hookable option parser framework in ascii-betical order. 2025e3d74329Smrg 2026e3d74329Smrg 2027e3d74329Smrg# func_fatal_help ARG... 2028e3d74329Smrg# ---------------------- 2029e3d74329Smrg# Echo program name prefixed message to standard error, followed by 2030e3d74329Smrg# a help hint, and exit. 2031e3d74329Smrgfunc_fatal_help () 2032c582b7e3Smrg{ 2033e3d74329Smrg $debug_cmd 203442a55b46Smrg 2035e3d74329Smrg eval \$ECHO \""Usage: $usage"\" 2036e3d74329Smrg eval \$ECHO \""$fatal_help"\" 2037e3d74329Smrg func_error ${1+"$@"} 2038e3d74329Smrg exit $EXIT_FAILURE 2039c582b7e3Smrg} 2040c582b7e3Smrg 2041e3d74329Smrg 2042e3d74329Smrg# func_help 2043e3d74329Smrg# --------- 2044e3d74329Smrg# Echo long help message to standard output and exit. 204542a55b46Smrgfunc_help () 2046c582b7e3Smrg{ 2047e3d74329Smrg $debug_cmd 2048e3d74329Smrg 2049e3d74329Smrg func_usage_message 2050e3d74329Smrg $ECHO "$long_help_message" 2051e3d74329Smrg exit 0 205242a55b46Smrg} 2053c582b7e3Smrg 2054e3d74329Smrg 2055e3d74329Smrg# func_missing_arg ARGNAME 2056e3d74329Smrg# ------------------------ 205742a55b46Smrg# Echo program name prefixed message to standard error and set global 205842a55b46Smrg# exit_cmd. 205942a55b46Smrgfunc_missing_arg () 206042a55b46Smrg{ 2061e3d74329Smrg $debug_cmd 2062c582b7e3Smrg 2063e3d74329Smrg func_error "Missing argument for '$1'." 206442a55b46Smrg exit_cmd=exit 2065c582b7e3Smrg} 2066c582b7e3Smrg 2067c582b7e3Smrg 2068e3d74329Smrg# func_split_equals STRING 2069e3d74329Smrg# ------------------------ 20708ce07328Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 20718ce07328Smrg# after splitting STRING at the '=' sign. 2072e3d74329Smrgtest -z "$_G_HAVE_XSI_OPS" \ 2073e3d74329Smrg && (eval 'x=a/b/c; 2074e3d74329Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 2075e3d74329Smrg && _G_HAVE_XSI_OPS=yes 2076e3d74329Smrg 2077e3d74329Smrgif test yes = "$_G_HAVE_XSI_OPS" 2078e3d74329Smrgthen 2079e3d74329Smrg # This is an XSI compatible shell, allowing a faster implementation... 2080e3d74329Smrg eval 'func_split_equals () 2081e3d74329Smrg { 2082e3d74329Smrg $debug_cmd 2083e3d74329Smrg 2084e3d74329Smrg func_split_equals_lhs=${1%%=*} 2085e3d74329Smrg func_split_equals_rhs=${1#*=} 20868ce07328Smrg if test "x$func_split_equals_lhs" = "x$1"; then 20878ce07328Smrg func_split_equals_rhs= 20888ce07328Smrg fi 2089e3d74329Smrg }' 2090e3d74329Smrgelse 2091e3d74329Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 2092e3d74329Smrg func_split_equals () 2093e3d74329Smrg { 2094e3d74329Smrg $debug_cmd 2095e3d74329Smrg 2096e3d74329Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 2097e3d74329Smrg func_split_equals_rhs= 20988ce07328Smrg test "x$func_split_equals_lhs=" = "x$1" \ 2099e3d74329Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 2100e3d74329Smrg } 2101e3d74329Smrgfi #func_split_equals 2102e3d74329Smrg 2103e3d74329Smrg 2104e3d74329Smrg# func_split_short_opt SHORTOPT 2105e3d74329Smrg# ----------------------------- 210642a55b46Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 210742a55b46Smrg# variables after splitting SHORTOPT after the 2nd character. 2108e3d74329Smrgif test yes = "$_G_HAVE_XSI_OPS" 2109e3d74329Smrgthen 2110e3d74329Smrg # This is an XSI compatible shell, allowing a faster implementation... 2111e3d74329Smrg eval 'func_split_short_opt () 2112e3d74329Smrg { 2113e3d74329Smrg $debug_cmd 2114e3d74329Smrg 2115e3d74329Smrg func_split_short_opt_arg=${1#??} 2116e3d74329Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 2117e3d74329Smrg }' 2118e3d74329Smrgelse 2119e3d74329Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 2120e3d74329Smrg func_split_short_opt () 2121e3d74329Smrg { 2122e3d74329Smrg $debug_cmd 2123e3d74329Smrg 21248ce07328Smrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 2125e3d74329Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 2126e3d74329Smrg } 2127e3d74329Smrgfi #func_split_short_opt 2128e3d74329Smrg 2129e3d74329Smrg 2130e3d74329Smrg# func_usage 2131e3d74329Smrg# ---------- 2132e3d74329Smrg# Echo short help message to standard output and exit. 2133e3d74329Smrgfunc_usage () 213442a55b46Smrg{ 2135e3d74329Smrg $debug_cmd 213642a55b46Smrg 2137e3d74329Smrg func_usage_message 2138e3d74329Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 2139e3d74329Smrg exit 0 2140e3d74329Smrg} 2141c582b7e3Smrg 2142c582b7e3Smrg 2143e3d74329Smrg# func_usage_message 2144e3d74329Smrg# ------------------ 2145e3d74329Smrg# Echo short help message to standard output. 2146e3d74329Smrgfunc_usage_message () 214742a55b46Smrg{ 2148e3d74329Smrg $debug_cmd 2149c582b7e3Smrg 2150e3d74329Smrg eval \$ECHO \""Usage: $usage"\" 2151e3d74329Smrg echo 2152e3d74329Smrg $SED -n 's|^# || 2153e3d74329Smrg /^Written by/{ 2154e3d74329Smrg x;p;x 2155e3d74329Smrg } 2156e3d74329Smrg h 2157e3d74329Smrg /^Written by/q' < "$progpath" 2158e3d74329Smrg echo 2159e3d74329Smrg eval \$ECHO \""$usage_message"\" 2160e3d74329Smrg} 2161c582b7e3Smrg 2162c582b7e3Smrg 2163e3d74329Smrg# func_version 2164e3d74329Smrg# ------------ 2165e3d74329Smrg# Echo version message to standard output and exit. 21668ce07328Smrg# The version message is extracted from the calling file's header 21678ce07328Smrg# comments, with leading '# ' stripped: 21688ce07328Smrg# 1. First display the progname and version 21698ce07328Smrg# 2. Followed by the header comment line matching /^# Written by / 21708ce07328Smrg# 3. Then a blank line followed by the first following line matching 21718ce07328Smrg# /^# Copyright / 21728ce07328Smrg# 4. Immediately followed by any lines between the previous matches, 21738ce07328Smrg# except lines preceding the intervening completely blank line. 21748ce07328Smrg# For example, see the header comments of this file. 2175e3d74329Smrgfunc_version () 2176e3d74329Smrg{ 2177e3d74329Smrg $debug_cmd 2178c582b7e3Smrg 2179e3d74329Smrg printf '%s\n' "$progname $scriptversion" 2180e3d74329Smrg $SED -n ' 21818ce07328Smrg /^# Written by /!b 21828ce07328Smrg s|^# ||; p; n 21838ce07328Smrg 21848ce07328Smrg :fwd2blnk 21858ce07328Smrg /./ { 21868ce07328Smrg n 21878ce07328Smrg b fwd2blnk 2188e3d74329Smrg } 21898ce07328Smrg p; n 21908ce07328Smrg 21918ce07328Smrg :holdwrnt 21928ce07328Smrg s|^# || 21938ce07328Smrg s|^# *$|| 21948ce07328Smrg /^Copyright /!{ 21958ce07328Smrg /./H 21968ce07328Smrg n 21978ce07328Smrg b holdwrnt 2198e3d74329Smrg } 21998ce07328Smrg 22008ce07328Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 22018ce07328Smrg G 22028ce07328Smrg s|\(\n\)\n*|\1|g 22038ce07328Smrg p; q' < "$progpath" 2204c582b7e3Smrg 2205e3d74329Smrg exit $? 2206e3d74329Smrg} 2207c582b7e3Smrg 2208c582b7e3Smrg 2209e3d74329Smrg# Local variables: 2210e3d74329Smrg# mode: shell-script 2211e3d74329Smrg# sh-indentation: 2 2212e3d74329Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 22138ce07328Smrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 2214e3d74329Smrg# time-stamp-time-zone: "UTC" 2215e3d74329Smrg# End: 221642a55b46Smrg 2217e3d74329Smrg# Set a version string. 22188ce07328Smrgscriptversion='(GNU libtool) 2.4.7' 221942a55b46Smrg 222042a55b46Smrg 2221e3d74329Smrg# func_echo ARG... 2222e3d74329Smrg# ---------------- 2223e3d74329Smrg# Libtool also displays the current mode in messages, so override 2224e3d74329Smrg# funclib.sh func_echo with this custom definition. 2225e3d74329Smrgfunc_echo () 222642a55b46Smrg{ 2227e3d74329Smrg $debug_cmd 222842a55b46Smrg 2229e3d74329Smrg _G_message=$* 2230e3d74329Smrg 2231e3d74329Smrg func_echo_IFS=$IFS 2232e3d74329Smrg IFS=$nl 2233e3d74329Smrg for _G_line in $_G_message; do 2234e3d74329Smrg IFS=$func_echo_IFS 2235e3d74329Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 2236e3d74329Smrg done 2237e3d74329Smrg IFS=$func_echo_IFS 2238e3d74329Smrg} 223942a55b46Smrg 224042a55b46Smrg 2241e3d74329Smrg# func_warning ARG... 2242e3d74329Smrg# ------------------- 2243e3d74329Smrg# Libtool warnings are not categorized, so override funclib.sh 2244e3d74329Smrg# func_warning with this simpler definition. 2245e3d74329Smrgfunc_warning () 224642a55b46Smrg{ 2247e3d74329Smrg $debug_cmd 2248e3d74329Smrg 2249e3d74329Smrg $warning_func ${1+"$@"} 2250e3d74329Smrg} 2251e3d74329Smrg 225242a55b46Smrg 2253e3d74329Smrg## ---------------- ## 2254e3d74329Smrg## Options parsing. ## 2255e3d74329Smrg## ---------------- ## 2256e3d74329Smrg 2257e3d74329Smrg# Hook in the functions to make sure our own options are parsed during 2258e3d74329Smrg# the option parsing loop. 2259e3d74329Smrg 2260e3d74329Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 2261e3d74329Smrg 2262e3d74329Smrg# Short help message in response to '-h'. 2263e3d74329Smrgusage_message="Options: 2264e3d74329Smrg --config show all configuration variables 2265e3d74329Smrg --debug enable verbose shell tracing 2266e3d74329Smrg -n, --dry-run display commands without modifying any files 2267e3d74329Smrg --features display basic configuration information and exit 2268e3d74329Smrg --mode=MODE use operation mode MODE 2269e3d74329Smrg --no-warnings equivalent to '-Wnone' 2270e3d74329Smrg --preserve-dup-deps don't remove duplicate dependency libraries 2271e3d74329Smrg --quiet, --silent don't print informational messages 2272e3d74329Smrg --tag=TAG use configuration variables from tag TAG 2273e3d74329Smrg -v, --verbose print more informational messages than default 2274e3d74329Smrg --version print version information 2275e3d74329Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2276e3d74329Smrg -h, --help, --help-all print short, long, or detailed help message 2277e3d74329Smrg" 227842a55b46Smrg 2279e3d74329Smrg# Additional text appended to 'usage_message' in response to '--help'. 2280e3d74329Smrgfunc_help () 228142a55b46Smrg{ 2282e3d74329Smrg $debug_cmd 2283e3d74329Smrg 2284e3d74329Smrg func_usage_message 2285e3d74329Smrg $ECHO "$long_help_message 2286e3d74329Smrg 2287e3d74329SmrgMODE must be one of the following: 2288e3d74329Smrg 2289e3d74329Smrg clean remove files from the build directory 2290e3d74329Smrg compile compile a source file into a libtool object 2291e3d74329Smrg execute automatically set library path, then run a program 2292e3d74329Smrg finish complete the installation of libtool libraries 2293e3d74329Smrg install install libraries or executables 2294e3d74329Smrg link create a library or an executable 2295e3d74329Smrg uninstall remove libraries from an installed directory 2296e3d74329Smrg 2297e3d74329SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 2298e3d74329Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2299e3d74329SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2300e3d74329Smrg 2301e3d74329SmrgWhen reporting a bug, please describe a test case to reproduce it and 2302e3d74329Smrginclude the following information: 2303e3d74329Smrg 2304e3d74329Smrg host-triplet: $host 2305e3d74329Smrg shell: $SHELL 2306e3d74329Smrg compiler: $LTCC 2307e3d74329Smrg compiler flags: $LTCFLAGS 2308e3d74329Smrg linker: $LD (gnu? $with_gnu_ld) 23098ce07328Smrg version: $progname (GNU libtool) 2.4.7 2310e3d74329Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2311e3d74329Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2312e3d74329Smrg 2313e3d74329SmrgReport bugs to <bug-libtool@gnu.org>. 23148ce07328SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 2315e3d74329SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2316e3d74329Smrg exit 0 2317e3d74329Smrg} 231842a55b46Smrg 231942a55b46Smrg 2320e3d74329Smrg# func_lo2o OBJECT-NAME 2321e3d74329Smrg# --------------------- 2322e3d74329Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2323e3d74329Smrg# object suffix. 232442a55b46Smrg 2325e3d74329Smrglo2o=s/\\.lo\$/.$objext/ 2326e3d74329Smrgo2lo=s/\\.$objext\$/.lo/ 232742a55b46Smrg 2328e3d74329Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 2329e3d74329Smrg eval 'func_lo2o () 2330e3d74329Smrg { 2331e3d74329Smrg case $1 in 2332e3d74329Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2333e3d74329Smrg * ) func_lo2o_result=$1 ;; 2334e3d74329Smrg esac 2335e3d74329Smrg }' 2336e3d74329Smrg 2337e3d74329Smrg # func_xform LIBOBJ-OR-SOURCE 2338e3d74329Smrg # --------------------------- 2339e3d74329Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2340e3d74329Smrg # suffix to a '.lo' libtool-object suffix. 2341e3d74329Smrg eval 'func_xform () 2342e3d74329Smrg { 2343e3d74329Smrg func_xform_result=${1%.*}.lo 2344e3d74329Smrg }' 2345e3d74329Smrgelse 2346e3d74329Smrg # ...otherwise fall back to using sed. 2347e3d74329Smrg func_lo2o () 2348e3d74329Smrg { 2349e3d74329Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2350e3d74329Smrg } 2351e3d74329Smrg 2352e3d74329Smrg func_xform () 2353e3d74329Smrg { 2354e3d74329Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2355e3d74329Smrg } 2356e3d74329Smrgfi 235742a55b46Smrg 235842a55b46Smrg 2359e3d74329Smrg# func_fatal_configuration ARG... 2360e3d74329Smrg# ------------------------------- 236142a55b46Smrg# Echo program name prefixed message to standard error, followed by 236242a55b46Smrg# a configuration failure hint, and exit. 236342a55b46Smrgfunc_fatal_configuration () 236442a55b46Smrg{ 23658ce07328Smrg func_fatal_error ${1+"$@"} \ 2366e3d74329Smrg "See the $PACKAGE documentation for more information." \ 2367e3d74329Smrg "Fatal configuration error." 236842a55b46Smrg} 236942a55b46Smrg 237042a55b46Smrg 237142a55b46Smrg# func_config 2372e3d74329Smrg# ----------- 237342a55b46Smrg# Display the configuration for all the tags in this script. 237442a55b46Smrgfunc_config () 237542a55b46Smrg{ 237642a55b46Smrg re_begincf='^# ### BEGIN LIBTOOL' 237742a55b46Smrg re_endcf='^# ### END LIBTOOL' 237842a55b46Smrg 237942a55b46Smrg # Default configuration. 238042a55b46Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 238142a55b46Smrg 2382c582b7e3Smrg # Now print the configurations for the tags. 2383c582b7e3Smrg for tagname in $taglist; do 238442a55b46Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2385c582b7e3Smrg done 2386c582b7e3Smrg 238742a55b46Smrg exit $? 238842a55b46Smrg} 2389c582b7e3Smrg 2390e3d74329Smrg 239142a55b46Smrg# func_features 2392e3d74329Smrg# ------------- 239342a55b46Smrg# Display the features supported by this script. 239442a55b46Smrgfunc_features () 239542a55b46Smrg{ 239642a55b46Smrg echo "host: $host" 2397e3d74329Smrg if test yes = "$build_libtool_libs"; then 239842a55b46Smrg echo "enable shared libraries" 2399c582b7e3Smrg else 240042a55b46Smrg echo "disable shared libraries" 2401c582b7e3Smrg fi 2402e3d74329Smrg if test yes = "$build_old_libs"; then 240342a55b46Smrg echo "enable static libraries" 2404c582b7e3Smrg else 240542a55b46Smrg echo "disable static libraries" 2406c582b7e3Smrg fi 2407c582b7e3Smrg 240842a55b46Smrg exit $? 240942a55b46Smrg} 2410c582b7e3Smrg 2411e3d74329Smrg 2412e3d74329Smrg# func_enable_tag TAGNAME 2413e3d74329Smrg# ----------------------- 241442a55b46Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 241542a55b46Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 241642a55b46Smrg# variable here. 241742a55b46Smrgfunc_enable_tag () 241842a55b46Smrg{ 2419e3d74329Smrg # Global variable: 2420e3d74329Smrg tagname=$1 2421c582b7e3Smrg 2422e3d74329Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2423e3d74329Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2424e3d74329Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2425c582b7e3Smrg 2426e3d74329Smrg # Validate tagname. 2427e3d74329Smrg case $tagname in 2428e3d74329Smrg *[!-_A-Za-z0-9,/]*) 2429e3d74329Smrg func_fatal_error "invalid tag name: $tagname" 2430e3d74329Smrg ;; 2431e3d74329Smrg esac 2432c582b7e3Smrg 2433e3d74329Smrg # Don't test for the "default" C tag, as we know it's 2434e3d74329Smrg # there but not specially marked. 2435e3d74329Smrg case $tagname in 2436e3d74329Smrg CC) ;; 243742a55b46Smrg *) 2438e3d74329Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2439e3d74329Smrg taglist="$taglist $tagname" 2440e3d74329Smrg 2441e3d74329Smrg # Evaluate the configuration. Be careful to quote the path 2442e3d74329Smrg # and the sed script, to avoid splitting on whitespace, but 2443e3d74329Smrg # also don't use non-portable quotes within backquotes within 2444e3d74329Smrg # quotes we have to do it in 2 steps: 2445e3d74329Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2446e3d74329Smrg eval "$extractedcf" 2447e3d74329Smrg else 2448e3d74329Smrg func_error "ignoring unknown tag $tagname" 2449e3d74329Smrg fi 2450e3d74329Smrg ;; 2451e3d74329Smrg esac 245242a55b46Smrg} 2453c582b7e3Smrg 2454e3d74329Smrg 245542a55b46Smrg# func_check_version_match 2456e3d74329Smrg# ------------------------ 245742a55b46Smrg# Ensure that we are using m4 macros, and libtool script from the same 245842a55b46Smrg# release of libtool. 245942a55b46Smrgfunc_check_version_match () 246042a55b46Smrg{ 2461e3d74329Smrg if test "$package_revision" != "$macro_revision"; then 2462e3d74329Smrg if test "$VERSION" != "$macro_version"; then 2463e3d74329Smrg if test -z "$macro_version"; then 2464e3d74329Smrg cat >&2 <<_LT_EOF 246542a55b46Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 246642a55b46Smrg$progname: definition of this LT_INIT comes from an older release. 246742a55b46Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 246842a55b46Smrg$progname: and run autoconf again. 246942a55b46Smrg_LT_EOF 2470e3d74329Smrg else 2471e3d74329Smrg cat >&2 <<_LT_EOF 247242a55b46Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 247342a55b46Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 247442a55b46Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 247542a55b46Smrg$progname: and run autoconf again. 247642a55b46Smrg_LT_EOF 2477e3d74329Smrg fi 2478e3d74329Smrg else 2479e3d74329Smrg cat >&2 <<_LT_EOF 248042a55b46Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 248142a55b46Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 248242a55b46Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 248342a55b46Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 248442a55b46Smrg_LT_EOF 2485e3d74329Smrg fi 2486c582b7e3Smrg 2487e3d74329Smrg exit $EXIT_MISMATCH 2488e3d74329Smrg fi 248942a55b46Smrg} 2490c582b7e3Smrg 2491c582b7e3Smrg 2492e3d74329Smrg# libtool_options_prep [ARG]... 2493e3d74329Smrg# ----------------------------- 2494e3d74329Smrg# Preparation for options parsed by libtool. 2495e3d74329Smrglibtool_options_prep () 2496e3d74329Smrg{ 2497e3d74329Smrg $debug_mode 2498c582b7e3Smrg 2499e3d74329Smrg # Option defaults: 2500e3d74329Smrg opt_config=false 2501e3d74329Smrg opt_dlopen= 2502e3d74329Smrg opt_dry_run=false 2503e3d74329Smrg opt_help=false 2504e3d74329Smrg opt_mode= 2505e3d74329Smrg opt_preserve_dup_deps=false 2506e3d74329Smrg opt_quiet=false 2507c582b7e3Smrg 2508e3d74329Smrg nonopt= 2509e3d74329Smrg preserve_args= 2510c582b7e3Smrg 25118ce07328Smrg _G_rc_lt_options_prep=: 25128ce07328Smrg 2513e3d74329Smrg # Shorthand for --mode=foo, only valid as the first argument 2514e3d74329Smrg case $1 in 2515e3d74329Smrg clean|clea|cle|cl) 2516e3d74329Smrg shift; set dummy --mode clean ${1+"$@"}; shift 2517e3d74329Smrg ;; 2518e3d74329Smrg compile|compil|compi|comp|com|co|c) 2519e3d74329Smrg shift; set dummy --mode compile ${1+"$@"}; shift 2520e3d74329Smrg ;; 2521e3d74329Smrg execute|execut|execu|exec|exe|ex|e) 2522e3d74329Smrg shift; set dummy --mode execute ${1+"$@"}; shift 2523e3d74329Smrg ;; 2524e3d74329Smrg finish|finis|fini|fin|fi|f) 2525e3d74329Smrg shift; set dummy --mode finish ${1+"$@"}; shift 2526e3d74329Smrg ;; 2527e3d74329Smrg install|instal|insta|inst|ins|in|i) 2528e3d74329Smrg shift; set dummy --mode install ${1+"$@"}; shift 2529e3d74329Smrg ;; 2530e3d74329Smrg link|lin|li|l) 2531e3d74329Smrg shift; set dummy --mode link ${1+"$@"}; shift 2532e3d74329Smrg ;; 2533e3d74329Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2534e3d74329Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 2535e3d74329Smrg ;; 25368ce07328Smrg *) 25378ce07328Smrg _G_rc_lt_options_prep=false 25388ce07328Smrg ;; 2539e3d74329Smrg esac 2540e3d74329Smrg 25418ce07328Smrg if $_G_rc_lt_options_prep; then 25428ce07328Smrg # Pass back the list of options. 25438ce07328Smrg func_quote eval ${1+"$@"} 25448ce07328Smrg libtool_options_prep_result=$func_quote_result 25458ce07328Smrg fi 2546e3d74329Smrg} 2547e3d74329Smrgfunc_add_hook func_options_prep libtool_options_prep 2548c582b7e3Smrg 254942a55b46Smrg 2550e3d74329Smrg# libtool_parse_options [ARG]... 2551e3d74329Smrg# --------------------------------- 2552e3d74329Smrg# Provide handling for libtool specific options. 2553e3d74329Smrglibtool_parse_options () 255442a55b46Smrg{ 2555e3d74329Smrg $debug_cmd 2556c582b7e3Smrg 25578ce07328Smrg _G_rc_lt_parse_options=false 25588ce07328Smrg 2559e3d74329Smrg # Perform our own loop to consume as many options as possible in 2560e3d74329Smrg # each iteration. 2561e3d74329Smrg while test $# -gt 0; do 25628ce07328Smrg _G_match_lt_parse_options=: 2563e3d74329Smrg _G_opt=$1 2564e3d74329Smrg shift 2565e3d74329Smrg case $_G_opt in 2566e3d74329Smrg --dry-run|--dryrun|-n) 2567e3d74329Smrg opt_dry_run=: 2568e3d74329Smrg ;; 2569e3d74329Smrg 2570e3d74329Smrg --config) func_config ;; 2571e3d74329Smrg 2572e3d74329Smrg --dlopen|-dlopen) 2573e3d74329Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 2574e3d74329Smrg}$1" 2575e3d74329Smrg shift 2576e3d74329Smrg ;; 2577e3d74329Smrg 2578e3d74329Smrg --preserve-dup-deps) 2579e3d74329Smrg opt_preserve_dup_deps=: ;; 2580e3d74329Smrg 2581e3d74329Smrg --features) func_features ;; 2582e3d74329Smrg 2583e3d74329Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2584e3d74329Smrg 2585e3d74329Smrg --help) opt_help=: ;; 2586e3d74329Smrg 2587e3d74329Smrg --help-all) opt_help=': help-all' ;; 2588e3d74329Smrg 2589e3d74329Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 2590e3d74329Smrg opt_mode=$1 2591e3d74329Smrg case $1 in 2592e3d74329Smrg # Valid mode arguments: 2593e3d74329Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 2594e3d74329Smrg 2595e3d74329Smrg # Catch anything else as an error 2596e3d74329Smrg *) func_error "invalid argument for $_G_opt" 2597e3d74329Smrg exit_cmd=exit 2598e3d74329Smrg break 2599e3d74329Smrg ;; 2600e3d74329Smrg esac 2601e3d74329Smrg shift 2602e3d74329Smrg ;; 2603e3d74329Smrg 2604e3d74329Smrg --no-silent|--no-quiet) 2605e3d74329Smrg opt_quiet=false 2606e3d74329Smrg func_append preserve_args " $_G_opt" 2607e3d74329Smrg ;; 2608e3d74329Smrg 2609e3d74329Smrg --no-warnings|--no-warning|--no-warn) 2610e3d74329Smrg opt_warning=false 2611e3d74329Smrg func_append preserve_args " $_G_opt" 2612e3d74329Smrg ;; 2613e3d74329Smrg 2614e3d74329Smrg --no-verbose) 2615e3d74329Smrg opt_verbose=false 2616e3d74329Smrg func_append preserve_args " $_G_opt" 2617e3d74329Smrg ;; 2618e3d74329Smrg 2619e3d74329Smrg --silent|--quiet) 2620e3d74329Smrg opt_quiet=: 2621e3d74329Smrg opt_verbose=false 2622e3d74329Smrg func_append preserve_args " $_G_opt" 2623e3d74329Smrg ;; 2624e3d74329Smrg 2625e3d74329Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 2626e3d74329Smrg opt_tag=$1 2627e3d74329Smrg func_append preserve_args " $_G_opt $1" 2628e3d74329Smrg func_enable_tag "$1" 2629e3d74329Smrg shift 2630e3d74329Smrg ;; 2631e3d74329Smrg 2632e3d74329Smrg --verbose|-v) opt_quiet=false 2633e3d74329Smrg opt_verbose=: 2634e3d74329Smrg func_append preserve_args " $_G_opt" 2635e3d74329Smrg ;; 2636e3d74329Smrg 26378ce07328Smrg # An option not handled by this hook function: 26388ce07328Smrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 26398ce07328Smrg _G_match_lt_parse_options=false 26408ce07328Smrg break 26418ce07328Smrg ;; 2642e3d74329Smrg esac 26438ce07328Smrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 2644e3d74329Smrg done 264542a55b46Smrg 26468ce07328Smrg if $_G_rc_lt_parse_options; then 26478ce07328Smrg # save modified positional parameters for caller 26488ce07328Smrg func_quote eval ${1+"$@"} 26498ce07328Smrg libtool_parse_options_result=$func_quote_result 26508ce07328Smrg fi 2651e3d74329Smrg} 2652e3d74329Smrgfunc_add_hook func_parse_options libtool_parse_options 2653c582b7e3Smrg 2654c582b7e3Smrg 2655c582b7e3Smrg 2656e3d74329Smrg# libtool_validate_options [ARG]... 2657e3d74329Smrg# --------------------------------- 2658e3d74329Smrg# Perform any sanity checks on option settings and/or unconsumed 2659e3d74329Smrg# arguments. 2660e3d74329Smrglibtool_validate_options () 2661e3d74329Smrg{ 2662e3d74329Smrg # save first non-option argument 2663e3d74329Smrg if test 0 -lt $#; then 2664e3d74329Smrg nonopt=$1 2665e3d74329Smrg shift 266642a55b46Smrg fi 2667c582b7e3Smrg 2668e3d74329Smrg # preserve --debug 2669e3d74329Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2670c582b7e3Smrg 2671e3d74329Smrg case $host in 2672e3d74329Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2673e3d74329Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2674e3d74329Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2675e3d74329Smrg # don't eliminate duplications in $postdeps and $predeps 2676e3d74329Smrg opt_duplicate_compiler_generated_deps=: 2677e3d74329Smrg ;; 2678e3d74329Smrg *) 2679e3d74329Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2680e3d74329Smrg ;; 2681e3d74329Smrg esac 2682c582b7e3Smrg 2683e3d74329Smrg $opt_help || { 2684e3d74329Smrg # Sanity checks first: 2685e3d74329Smrg func_check_version_match 2686c582b7e3Smrg 2687e3d74329Smrg test yes != "$build_libtool_libs" \ 2688e3d74329Smrg && test yes != "$build_old_libs" \ 2689e3d74329Smrg && func_fatal_configuration "not configured to build any kind of library" 2690c582b7e3Smrg 2691e3d74329Smrg # Darwin sucks 2692e3d74329Smrg eval std_shrext=\"$shrext_cmds\" 2693e3d74329Smrg 2694e3d74329Smrg # Only execute mode is allowed to have -dlopen flags. 2695e3d74329Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2696e3d74329Smrg func_error "unrecognized option '-dlopen'" 2697e3d74329Smrg $ECHO "$help" 1>&2 2698e3d74329Smrg exit $EXIT_FAILURE 2699e3d74329Smrg fi 2700e3d74329Smrg 2701e3d74329Smrg # Change the help message to a mode-specific one. 2702e3d74329Smrg generic_help=$help 2703e3d74329Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 2704e3d74329Smrg } 2705e3d74329Smrg 2706e3d74329Smrg # Pass back the unparsed argument list 27078ce07328Smrg func_quote eval ${1+"$@"} 27088ce07328Smrg libtool_validate_options_result=$func_quote_result 270942a55b46Smrg} 2710e3d74329Smrgfunc_add_hook func_validate_options libtool_validate_options 2711e3d74329Smrg 2712c582b7e3Smrg 2713e3d74329Smrg# Process options as early as possible so that --help and --version 2714e3d74329Smrg# can return quickly. 2715e3d74329Smrgfunc_options ${1+"$@"} 2716e3d74329Smrgeval set dummy "$func_options_result"; shift 2717c582b7e3Smrg 2718c582b7e3Smrg 2719c582b7e3Smrg 272042a55b46Smrg## ----------- ## 272142a55b46Smrg## Main. ## 272242a55b46Smrg## ----------- ## 2723c582b7e3Smrg 2724e3d74329Smrgmagic='%%%MAGIC variable%%%' 2725e3d74329Smrgmagic_exe='%%%MAGIC EXE variable%%%' 2726e3d74329Smrg 2727e3d74329Smrg# Global variables. 2728e3d74329Smrgextracted_archives= 2729e3d74329Smrgextracted_serial=0 2730e3d74329Smrg 2731e3d74329Smrg# If this variable is set in any of the actions, the command in it 2732e3d74329Smrg# will be execed at the end. This prevents here-documents from being 2733e3d74329Smrg# left over by shells. 2734e3d74329Smrgexec_cmd= 2735e3d74329Smrg 2736e3d74329Smrg 2737e3d74329Smrg# A function that is used when there is no print builtin or printf. 2738e3d74329Smrgfunc_fallback_echo () 2739e3d74329Smrg{ 2740e3d74329Smrg eval 'cat <<_LTECHO_EOF 2741e3d74329Smrg$1 2742e3d74329Smrg_LTECHO_EOF' 2743e3d74329Smrg} 2744e3d74329Smrg 2745e3d74329Smrg# func_generated_by_libtool 2746e3d74329Smrg# True iff stdin has been generated by Libtool. This function is only 2747e3d74329Smrg# a basic sanity check; it will hardly flush out determined imposters. 2748e3d74329Smrgfunc_generated_by_libtool_p () 2749e3d74329Smrg{ 2750e3d74329Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2751e3d74329Smrg} 2752e3d74329Smrg 275342a55b46Smrg# func_lalib_p file 2754e3d74329Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 275542a55b46Smrg# This function is only a basic sanity check; it will hardly flush out 275642a55b46Smrg# determined imposters. 275742a55b46Smrgfunc_lalib_p () 275842a55b46Smrg{ 275942a55b46Smrg test -f "$1" && 2760e3d74329Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 276142a55b46Smrg} 2762c582b7e3Smrg 276342a55b46Smrg# func_lalib_unsafe_p file 2764e3d74329Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 276542a55b46Smrg# This function implements the same check as func_lalib_p without 276642a55b46Smrg# resorting to external programs. To this end, it redirects stdin and 276742a55b46Smrg# closes it afterwards, without saving the original file descriptor. 276842a55b46Smrg# As a safety measure, use it only where a negative result would be 2769e3d74329Smrg# fatal anyway. Works if 'file' does not exist. 277042a55b46Smrgfunc_lalib_unsafe_p () 277142a55b46Smrg{ 277242a55b46Smrg lalib_p=no 277342a55b46Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 277442a55b46Smrg for lalib_p_l in 1 2 3 4 277542a55b46Smrg do 277642a55b46Smrg read lalib_p_line 2777e3d74329Smrg case $lalib_p_line in 277842a55b46Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 277942a55b46Smrg esac 278042a55b46Smrg done 278142a55b46Smrg exec 0<&5 5<&- 278242a55b46Smrg fi 2783e3d74329Smrg test yes = "$lalib_p" 278442a55b46Smrg} 2785c582b7e3Smrg 278642a55b46Smrg# func_ltwrapper_script_p file 278742a55b46Smrg# True iff FILE is a libtool wrapper script 278842a55b46Smrg# This function is only a basic sanity check; it will hardly flush out 278942a55b46Smrg# determined imposters. 279042a55b46Smrgfunc_ltwrapper_script_p () 279142a55b46Smrg{ 2792e3d74329Smrg test -f "$1" && 2793e3d74329Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 279442a55b46Smrg} 2795c582b7e3Smrg 279642a55b46Smrg# func_ltwrapper_executable_p file 279742a55b46Smrg# True iff FILE is a libtool wrapper executable 279842a55b46Smrg# This function is only a basic sanity check; it will hardly flush out 279942a55b46Smrg# determined imposters. 280042a55b46Smrgfunc_ltwrapper_executable_p () 280142a55b46Smrg{ 280242a55b46Smrg func_ltwrapper_exec_suffix= 280342a55b46Smrg case $1 in 280442a55b46Smrg *.exe) ;; 280542a55b46Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2806c582b7e3Smrg esac 280742a55b46Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 280842a55b46Smrg} 2809c582b7e3Smrg 281042a55b46Smrg# func_ltwrapper_scriptname file 281142a55b46Smrg# Assumes file is an ltwrapper_executable 281242a55b46Smrg# uses $file to determine the appropriate filename for a 281342a55b46Smrg# temporary ltwrapper_script. 281442a55b46Smrgfunc_ltwrapper_scriptname () 281542a55b46Smrg{ 281642a55b46Smrg func_dirname_and_basename "$1" "" "." 281742a55b46Smrg func_stripname '' '.exe' "$func_basename_result" 2818e3d74329Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 281942a55b46Smrg} 2820c582b7e3Smrg 282142a55b46Smrg# func_ltwrapper_p file 282242a55b46Smrg# True iff FILE is a libtool wrapper script or wrapper executable 282342a55b46Smrg# This function is only a basic sanity check; it will hardly flush out 282442a55b46Smrg# determined imposters. 282542a55b46Smrgfunc_ltwrapper_p () 282642a55b46Smrg{ 282742a55b46Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 282842a55b46Smrg} 2829c582b7e3Smrg 2830c582b7e3Smrg 283142a55b46Smrg# func_execute_cmds commands fail_cmd 283242a55b46Smrg# Execute tilde-delimited COMMANDS. 283342a55b46Smrg# If FAIL_CMD is given, eval that upon failure. 283442a55b46Smrg# FAIL_CMD may read-access the current command in variable CMD! 283542a55b46Smrgfunc_execute_cmds () 283642a55b46Smrg{ 2837e3d74329Smrg $debug_cmd 2838e3d74329Smrg 283942a55b46Smrg save_ifs=$IFS; IFS='~' 284042a55b46Smrg for cmd in $1; do 2841e3d74329Smrg IFS=$sp$nl 284242a55b46Smrg eval cmd=\"$cmd\" 2843e3d74329Smrg IFS=$save_ifs 284442a55b46Smrg func_show_eval "$cmd" "${2-:}" 2845c582b7e3Smrg done 284642a55b46Smrg IFS=$save_ifs 284742a55b46Smrg} 2848c582b7e3Smrg 2849c582b7e3Smrg 285042a55b46Smrg# func_source file 285142a55b46Smrg# Source FILE, adding directory component if necessary. 285242a55b46Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 285342a55b46Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 285442a55b46Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 2855e3d74329Smrg# 'FILE.' does not work on cygwin managed mounts. 285642a55b46Smrgfunc_source () 285742a55b46Smrg{ 2858e3d74329Smrg $debug_cmd 2859e3d74329Smrg 286042a55b46Smrg case $1 in 286142a55b46Smrg */* | *\\*) . "$1" ;; 286242a55b46Smrg *) . "./$1" ;; 286342a55b46Smrg esac 286442a55b46Smrg} 2865c582b7e3Smrg 2866c582b7e3Smrg 286742a55b46Smrg# func_resolve_sysroot PATH 286842a55b46Smrg# Replace a leading = in PATH with a sysroot. Store the result into 286942a55b46Smrg# func_resolve_sysroot_result 287042a55b46Smrgfunc_resolve_sysroot () 287142a55b46Smrg{ 287242a55b46Smrg func_resolve_sysroot_result=$1 287342a55b46Smrg case $func_resolve_sysroot_result in 287442a55b46Smrg =*) 287542a55b46Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 287642a55b46Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 287742a55b46Smrg ;; 287842a55b46Smrg esac 287942a55b46Smrg} 2880c582b7e3Smrg 288142a55b46Smrg# func_replace_sysroot PATH 288242a55b46Smrg# If PATH begins with the sysroot, replace it with = and 288342a55b46Smrg# store the result into func_replace_sysroot_result. 288442a55b46Smrgfunc_replace_sysroot () 288542a55b46Smrg{ 2886e3d74329Smrg case $lt_sysroot:$1 in 288742a55b46Smrg ?*:"$lt_sysroot"*) 288842a55b46Smrg func_stripname "$lt_sysroot" '' "$1" 2889e3d74329Smrg func_replace_sysroot_result='='$func_stripname_result 289042a55b46Smrg ;; 289142a55b46Smrg *) 289242a55b46Smrg # Including no sysroot. 289342a55b46Smrg func_replace_sysroot_result=$1 289442a55b46Smrg ;; 289542a55b46Smrg esac 289642a55b46Smrg} 2897c582b7e3Smrg 289842a55b46Smrg# func_infer_tag arg 289942a55b46Smrg# Infer tagged configuration to use if any are available and 290042a55b46Smrg# if one wasn't chosen via the "--tag" command line option. 290142a55b46Smrg# Only attempt this if the compiler in the base compile 290242a55b46Smrg# command doesn't match the default compiler. 290342a55b46Smrg# arg is usually of the form 'gcc ...' 290442a55b46Smrgfunc_infer_tag () 290542a55b46Smrg{ 2906e3d74329Smrg $debug_cmd 2907e3d74329Smrg 290842a55b46Smrg if test -n "$available_tags" && test -z "$tagname"; then 290942a55b46Smrg CC_quoted= 291042a55b46Smrg for arg in $CC; do 291142a55b46Smrg func_append_quoted CC_quoted "$arg" 291242a55b46Smrg done 291342a55b46Smrg CC_expanded=`func_echo_all $CC` 291442a55b46Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 291542a55b46Smrg case $@ in 291642a55b46Smrg # Blanks in the command may have been stripped by the calling shell, 291742a55b46Smrg # but not from the CC environment variable when configure was run. 291842a55b46Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 291942a55b46Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 292042a55b46Smrg # Blanks at the start of $base_compile will cause this to fail 292142a55b46Smrg # if we don't check for them as well. 292242a55b46Smrg *) 292342a55b46Smrg for z in $available_tags; do 292442a55b46Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 292542a55b46Smrg # Evaluate the configuration. 2926e3d74329Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 292742a55b46Smrg CC_quoted= 292842a55b46Smrg for arg in $CC; do 292942a55b46Smrg # Double-quote args containing other shell metacharacters. 293042a55b46Smrg func_append_quoted CC_quoted "$arg" 293142a55b46Smrg done 293242a55b46Smrg CC_expanded=`func_echo_all $CC` 293342a55b46Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 293442a55b46Smrg case "$@ " in 293542a55b46Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 293642a55b46Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 293742a55b46Smrg # The compiler in the base compile command matches 293842a55b46Smrg # the one in the tagged configuration. 293942a55b46Smrg # Assume this is the tagged configuration we want. 294042a55b46Smrg tagname=$z 294142a55b46Smrg break 294242a55b46Smrg ;; 294342a55b46Smrg esac 294442a55b46Smrg fi 294542a55b46Smrg done 294642a55b46Smrg # If $tagname still isn't set, then no tagged configuration 294742a55b46Smrg # was found and let the user know that the "--tag" command 294842a55b46Smrg # line option must be used. 294942a55b46Smrg if test -z "$tagname"; then 295042a55b46Smrg func_echo "unable to infer tagged configuration" 2951e3d74329Smrg func_fatal_error "specify a tag with '--tag'" 295242a55b46Smrg# else 295342a55b46Smrg# func_verbose "using $tagname tagged configuration" 295442a55b46Smrg fi 295542a55b46Smrg ;; 295642a55b46Smrg esac 2957c582b7e3Smrg fi 295842a55b46Smrg} 2959c582b7e3Smrg 2960c582b7e3Smrg 2961c582b7e3Smrg 296242a55b46Smrg# func_write_libtool_object output_name pic_name nonpic_name 296342a55b46Smrg# Create a libtool object file (analogous to a ".la" file), 296442a55b46Smrg# but don't create it if we're doing a dry run. 296542a55b46Smrgfunc_write_libtool_object () 296642a55b46Smrg{ 2967e3d74329Smrg write_libobj=$1 2968e3d74329Smrg if test yes = "$build_libtool_libs"; then 2969e3d74329Smrg write_lobj=\'$2\' 297042a55b46Smrg else 297142a55b46Smrg write_lobj=none 2972c582b7e3Smrg fi 2973c582b7e3Smrg 2974e3d74329Smrg if test yes = "$build_old_libs"; then 2975e3d74329Smrg write_oldobj=\'$3\' 297642a55b46Smrg else 297742a55b46Smrg write_oldobj=none 2978c582b7e3Smrg fi 2979c582b7e3Smrg 298042a55b46Smrg $opt_dry_run || { 298142a55b46Smrg cat >${write_libobj}T <<EOF 298242a55b46Smrg# $write_libobj - a libtool object file 2983e3d74329Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2984c582b7e3Smrg# 2985c582b7e3Smrg# Please DO NOT delete this file! 2986c582b7e3Smrg# It is necessary for linking the library. 2987c582b7e3Smrg 2988c582b7e3Smrg# Name of the PIC object. 298942a55b46Smrgpic_object=$write_lobj 2990c582b7e3Smrg 299142a55b46Smrg# Name of the non-PIC object 299242a55b46Smrgnon_pic_object=$write_oldobj 2993c582b7e3Smrg 299442a55b46SmrgEOF 2995e3d74329Smrg $MV "${write_libobj}T" "$write_libobj" 299642a55b46Smrg } 299742a55b46Smrg} 2998c582b7e3Smrg 2999c582b7e3Smrg 300042a55b46Smrg################################################## 300142a55b46Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 300242a55b46Smrg################################################## 3003c582b7e3Smrg 300442a55b46Smrg# func_convert_core_file_wine_to_w32 ARG 300542a55b46Smrg# Helper function used by file name conversion functions when $build is *nix, 300642a55b46Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 300742a55b46Smrg# correctly configured wine environment available, with the winepath program 300842a55b46Smrg# in $build's $PATH. 300942a55b46Smrg# 301042a55b46Smrg# ARG is the $build file name to be converted to w32 format. 301142a55b46Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 301242a55b46Smrg# be empty on error (or when ARG is empty) 301342a55b46Smrgfunc_convert_core_file_wine_to_w32 () 301442a55b46Smrg{ 3015e3d74329Smrg $debug_cmd 3016e3d74329Smrg 3017e3d74329Smrg func_convert_core_file_wine_to_w32_result=$1 301842a55b46Smrg if test -n "$1"; then 301942a55b46Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 302042a55b46Smrg # are forced to check the contents of stdout. On the other hand, if the 302142a55b46Smrg # command is not found, the shell will set an exit code of 127 and print 302242a55b46Smrg # *an error message* to stdout. So we must check for both error code of 302342a55b46Smrg # zero AND non-empty stdout, which explains the odd construction: 302442a55b46Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 3025e3d74329Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 302642a55b46Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 3027e3d74329Smrg $SED -e "$sed_naive_backslashify"` 302842a55b46Smrg else 302942a55b46Smrg func_convert_core_file_wine_to_w32_result= 303042a55b46Smrg fi 303142a55b46Smrg fi 303242a55b46Smrg} 303342a55b46Smrg# end: func_convert_core_file_wine_to_w32 3034c582b7e3Smrg 303542a55b46Smrg 303642a55b46Smrg# func_convert_core_path_wine_to_w32 ARG 303742a55b46Smrg# Helper function used by path conversion functions when $build is *nix, and 303842a55b46Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 303942a55b46Smrg# configured wine environment available, with the winepath program in $build's 304042a55b46Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 304142a55b46Smrg# 304242a55b46Smrg# ARG is path to be converted from $build format to win32. 304342a55b46Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 304442a55b46Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 304542a55b46Smrg# are convertible, then the result may be empty. 304642a55b46Smrgfunc_convert_core_path_wine_to_w32 () 304742a55b46Smrg{ 3048e3d74329Smrg $debug_cmd 3049e3d74329Smrg 305042a55b46Smrg # unfortunately, winepath doesn't convert paths, only file names 3051e3d74329Smrg func_convert_core_path_wine_to_w32_result= 305242a55b46Smrg if test -n "$1"; then 305342a55b46Smrg oldIFS=$IFS 305442a55b46Smrg IFS=: 305542a55b46Smrg for func_convert_core_path_wine_to_w32_f in $1; do 305642a55b46Smrg IFS=$oldIFS 305742a55b46Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 3058e3d74329Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 305942a55b46Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 3060e3d74329Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 306142a55b46Smrg else 306242a55b46Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 306342a55b46Smrg fi 3064c582b7e3Smrg fi 306542a55b46Smrg done 306642a55b46Smrg IFS=$oldIFS 306742a55b46Smrg fi 306842a55b46Smrg} 306942a55b46Smrg# end: func_convert_core_path_wine_to_w32 307042a55b46Smrg 307142a55b46Smrg 307242a55b46Smrg# func_cygpath ARGS... 307342a55b46Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 307442a55b46Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 307542a55b46Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 307642a55b46Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 307742a55b46Smrg# file name or path is assumed to be in w32 format, as previously converted 307842a55b46Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 307942a55b46Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 308042a55b46Smrg# Cygwin format). Returns an empty string on error. 308142a55b46Smrg# 308242a55b46Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 308342a55b46Smrg# be converted. 308442a55b46Smrg# 308542a55b46Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 308642a55b46Smrg# environment variable; do not put it in $PATH. 308742a55b46Smrgfunc_cygpath () 308842a55b46Smrg{ 3089e3d74329Smrg $debug_cmd 3090e3d74329Smrg 309142a55b46Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 309242a55b46Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 309342a55b46Smrg if test "$?" -ne 0; then 309442a55b46Smrg # on failure, ensure result is empty 309542a55b46Smrg func_cygpath_result= 309642a55b46Smrg fi 309742a55b46Smrg else 309842a55b46Smrg func_cygpath_result= 3099e3d74329Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 310042a55b46Smrg fi 310142a55b46Smrg} 310242a55b46Smrg#end: func_cygpath 3103c582b7e3Smrg 3104c582b7e3Smrg 310542a55b46Smrg# func_convert_core_msys_to_w32 ARG 310642a55b46Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 310742a55b46Smrg# result in func_convert_core_msys_to_w32_result. 310842a55b46Smrgfunc_convert_core_msys_to_w32 () 310942a55b46Smrg{ 3110e3d74329Smrg $debug_cmd 3111e3d74329Smrg 311242a55b46Smrg # awkward: cmd appends spaces to result 311342a55b46Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 3114e3d74329Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 311542a55b46Smrg} 311642a55b46Smrg#end: func_convert_core_msys_to_w32 3117c582b7e3Smrg 3118c582b7e3Smrg 311942a55b46Smrg# func_convert_file_check ARG1 ARG2 312042a55b46Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 312142a55b46Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 312242a55b46Smrg# func_to_host_file_result to ARG1). 312342a55b46Smrgfunc_convert_file_check () 312442a55b46Smrg{ 3125e3d74329Smrg $debug_cmd 3126e3d74329Smrg 3127e3d74329Smrg if test -z "$2" && test -n "$1"; then 312842a55b46Smrg func_error "Could not determine host file name corresponding to" 3129e3d74329Smrg func_error " '$1'" 313042a55b46Smrg func_error "Continuing, but uninstalled executables may not work." 313142a55b46Smrg # Fallback: 3132e3d74329Smrg func_to_host_file_result=$1 313342a55b46Smrg fi 313442a55b46Smrg} 313542a55b46Smrg# end func_convert_file_check 3136c582b7e3Smrg 3137c582b7e3Smrg 313842a55b46Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 313942a55b46Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 314042a55b46Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 314142a55b46Smrg# func_to_host_file_result to a simplistic fallback value (see below). 314242a55b46Smrgfunc_convert_path_check () 314342a55b46Smrg{ 3144e3d74329Smrg $debug_cmd 3145e3d74329Smrg 314642a55b46Smrg if test -z "$4" && test -n "$3"; then 314742a55b46Smrg func_error "Could not determine the host path corresponding to" 3148e3d74329Smrg func_error " '$3'" 314942a55b46Smrg func_error "Continuing, but uninstalled executables may not work." 315042a55b46Smrg # Fallback. This is a deliberately simplistic "conversion" and 315142a55b46Smrg # should not be "improved". See libtool.info. 315242a55b46Smrg if test "x$1" != "x$2"; then 315342a55b46Smrg lt_replace_pathsep_chars="s|$1|$2|g" 315442a55b46Smrg func_to_host_path_result=`echo "$3" | 315542a55b46Smrg $SED -e "$lt_replace_pathsep_chars"` 315642a55b46Smrg else 3157e3d74329Smrg func_to_host_path_result=$3 315842a55b46Smrg fi 315942a55b46Smrg fi 316042a55b46Smrg} 316142a55b46Smrg# end func_convert_path_check 3162c582b7e3Smrg 3163c582b7e3Smrg 316442a55b46Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 316542a55b46Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 316642a55b46Smrg# and appending REPL if ORIG matches BACKPAT. 316742a55b46Smrgfunc_convert_path_front_back_pathsep () 316842a55b46Smrg{ 3169e3d74329Smrg $debug_cmd 3170e3d74329Smrg 317142a55b46Smrg case $4 in 3172e3d74329Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 317342a55b46Smrg ;; 317442a55b46Smrg esac 317542a55b46Smrg case $4 in 317642a55b46Smrg $2 ) func_append func_to_host_path_result "$3" 317742a55b46Smrg ;; 317842a55b46Smrg esac 317942a55b46Smrg} 318042a55b46Smrg# end func_convert_path_front_back_pathsep 3181c582b7e3Smrg 3182c582b7e3Smrg 318342a55b46Smrg################################################## 318442a55b46Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 318542a55b46Smrg################################################## 3186e3d74329Smrg# invoked via '$to_host_file_cmd ARG' 318742a55b46Smrg# 318842a55b46Smrg# In each case, ARG is the path to be converted from $build to $host format. 318942a55b46Smrg# Result will be available in $func_to_host_file_result. 3190c582b7e3Smrg 3191c582b7e3Smrg 319242a55b46Smrg# func_to_host_file ARG 319342a55b46Smrg# Converts the file name ARG from $build format to $host format. Return result 319442a55b46Smrg# in func_to_host_file_result. 319542a55b46Smrgfunc_to_host_file () 319642a55b46Smrg{ 3197e3d74329Smrg $debug_cmd 3198e3d74329Smrg 319942a55b46Smrg $to_host_file_cmd "$1" 320042a55b46Smrg} 320142a55b46Smrg# end func_to_host_file 3202c582b7e3Smrg 3203c582b7e3Smrg 320442a55b46Smrg# func_to_tool_file ARG LAZY 320542a55b46Smrg# converts the file name ARG from $build format to toolchain format. Return 320642a55b46Smrg# result in func_to_tool_file_result. If the conversion in use is listed 320742a55b46Smrg# in (the comma separated) LAZY, no conversion takes place. 320842a55b46Smrgfunc_to_tool_file () 320942a55b46Smrg{ 3210e3d74329Smrg $debug_cmd 3211e3d74329Smrg 321242a55b46Smrg case ,$2, in 321342a55b46Smrg *,"$to_tool_file_cmd",*) 321442a55b46Smrg func_to_tool_file_result=$1 321542a55b46Smrg ;; 321642a55b46Smrg *) 321742a55b46Smrg $to_tool_file_cmd "$1" 321842a55b46Smrg func_to_tool_file_result=$func_to_host_file_result 321942a55b46Smrg ;; 322042a55b46Smrg esac 322142a55b46Smrg} 322242a55b46Smrg# end func_to_tool_file 3223c582b7e3Smrg 3224c582b7e3Smrg 322542a55b46Smrg# func_convert_file_noop ARG 322642a55b46Smrg# Copy ARG to func_to_host_file_result. 322742a55b46Smrgfunc_convert_file_noop () 322842a55b46Smrg{ 3229e3d74329Smrg func_to_host_file_result=$1 323042a55b46Smrg} 323142a55b46Smrg# end func_convert_file_noop 3232c582b7e3Smrg 3233c582b7e3Smrg 323442a55b46Smrg# func_convert_file_msys_to_w32 ARG 323542a55b46Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 323642a55b46Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 323742a55b46Smrg# func_to_host_file_result. 323842a55b46Smrgfunc_convert_file_msys_to_w32 () 323942a55b46Smrg{ 3240e3d74329Smrg $debug_cmd 3241e3d74329Smrg 3242e3d74329Smrg func_to_host_file_result=$1 324342a55b46Smrg if test -n "$1"; then 324442a55b46Smrg func_convert_core_msys_to_w32 "$1" 3245e3d74329Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 324642a55b46Smrg fi 324742a55b46Smrg func_convert_file_check "$1" "$func_to_host_file_result" 324842a55b46Smrg} 324942a55b46Smrg# end func_convert_file_msys_to_w32 3250c582b7e3Smrg 3251c582b7e3Smrg 325242a55b46Smrg# func_convert_file_cygwin_to_w32 ARG 325342a55b46Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 325442a55b46Smrg# func_to_host_file_result. 325542a55b46Smrgfunc_convert_file_cygwin_to_w32 () 325642a55b46Smrg{ 3257e3d74329Smrg $debug_cmd 3258e3d74329Smrg 3259e3d74329Smrg func_to_host_file_result=$1 326042a55b46Smrg if test -n "$1"; then 326142a55b46Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 326242a55b46Smrg # LT_CYGPATH in this case. 326342a55b46Smrg func_to_host_file_result=`cygpath -m "$1"` 326442a55b46Smrg fi 326542a55b46Smrg func_convert_file_check "$1" "$func_to_host_file_result" 326642a55b46Smrg} 326742a55b46Smrg# end func_convert_file_cygwin_to_w32 3268c582b7e3Smrg 3269c582b7e3Smrg 327042a55b46Smrg# func_convert_file_nix_to_w32 ARG 327142a55b46Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 327242a55b46Smrg# and a working winepath. Returns result in func_to_host_file_result. 327342a55b46Smrgfunc_convert_file_nix_to_w32 () 327442a55b46Smrg{ 3275e3d74329Smrg $debug_cmd 3276e3d74329Smrg 3277e3d74329Smrg func_to_host_file_result=$1 327842a55b46Smrg if test -n "$1"; then 327942a55b46Smrg func_convert_core_file_wine_to_w32 "$1" 3280e3d74329Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 328142a55b46Smrg fi 328242a55b46Smrg func_convert_file_check "$1" "$func_to_host_file_result" 328342a55b46Smrg} 328442a55b46Smrg# end func_convert_file_nix_to_w32 3285c582b7e3Smrg 3286c582b7e3Smrg 328742a55b46Smrg# func_convert_file_msys_to_cygwin ARG 328842a55b46Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 328942a55b46Smrg# Returns result in func_to_host_file_result. 329042a55b46Smrgfunc_convert_file_msys_to_cygwin () 329142a55b46Smrg{ 3292e3d74329Smrg $debug_cmd 3293e3d74329Smrg 3294e3d74329Smrg func_to_host_file_result=$1 329542a55b46Smrg if test -n "$1"; then 329642a55b46Smrg func_convert_core_msys_to_w32 "$1" 329742a55b46Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 3298e3d74329Smrg func_to_host_file_result=$func_cygpath_result 329942a55b46Smrg fi 330042a55b46Smrg func_convert_file_check "$1" "$func_to_host_file_result" 330142a55b46Smrg} 330242a55b46Smrg# end func_convert_file_msys_to_cygwin 3303c582b7e3Smrg 3304c582b7e3Smrg 330542a55b46Smrg# func_convert_file_nix_to_cygwin ARG 330642a55b46Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 330742a55b46Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 330842a55b46Smrg# in func_to_host_file_result. 330942a55b46Smrgfunc_convert_file_nix_to_cygwin () 331042a55b46Smrg{ 3311e3d74329Smrg $debug_cmd 3312e3d74329Smrg 3313e3d74329Smrg func_to_host_file_result=$1 331442a55b46Smrg if test -n "$1"; then 331542a55b46Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 331642a55b46Smrg func_convert_core_file_wine_to_w32 "$1" 331742a55b46Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3318e3d74329Smrg func_to_host_file_result=$func_cygpath_result 331942a55b46Smrg fi 332042a55b46Smrg func_convert_file_check "$1" "$func_to_host_file_result" 332142a55b46Smrg} 332242a55b46Smrg# end func_convert_file_nix_to_cygwin 3323c582b7e3Smrg 3324c582b7e3Smrg 332542a55b46Smrg############################################# 332642a55b46Smrg# $build to $host PATH CONVERSION FUNCTIONS # 332742a55b46Smrg############################################# 3328e3d74329Smrg# invoked via '$to_host_path_cmd ARG' 332942a55b46Smrg# 333042a55b46Smrg# In each case, ARG is the path to be converted from $build to $host format. 333142a55b46Smrg# The result will be available in $func_to_host_path_result. 333242a55b46Smrg# 333342a55b46Smrg# Path separators are also converted from $build format to $host format. If 333442a55b46Smrg# ARG begins or ends with a path separator character, it is preserved (but 333542a55b46Smrg# converted to $host format) on output. 333642a55b46Smrg# 333742a55b46Smrg# All path conversion functions are named using the following convention: 333842a55b46Smrg# file name conversion function : func_convert_file_X_to_Y () 333942a55b46Smrg# path conversion function : func_convert_path_X_to_Y () 334042a55b46Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 334142a55b46Smrg# same. If conversion functions are added for new $build/$host combinations, 334242a55b46Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 334342a55b46Smrg# will break. 334442a55b46Smrg 334542a55b46Smrg 334642a55b46Smrg# func_init_to_host_path_cmd 334742a55b46Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 334842a55b46Smrg# appropriate value, based on the value of $to_host_file_cmd. 334942a55b46Smrgto_host_path_cmd= 335042a55b46Smrgfunc_init_to_host_path_cmd () 335142a55b46Smrg{ 3352e3d74329Smrg $debug_cmd 3353e3d74329Smrg 335442a55b46Smrg if test -z "$to_host_path_cmd"; then 335542a55b46Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3356e3d74329Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 335742a55b46Smrg fi 335842a55b46Smrg} 3359c582b7e3Smrg 3360c582b7e3Smrg 336142a55b46Smrg# func_to_host_path ARG 336242a55b46Smrg# Converts the path ARG from $build format to $host format. Return result 336342a55b46Smrg# in func_to_host_path_result. 336442a55b46Smrgfunc_to_host_path () 336542a55b46Smrg{ 3366e3d74329Smrg $debug_cmd 3367e3d74329Smrg 336842a55b46Smrg func_init_to_host_path_cmd 336942a55b46Smrg $to_host_path_cmd "$1" 337042a55b46Smrg} 337142a55b46Smrg# end func_to_host_path 3372c582b7e3Smrg 3373c582b7e3Smrg 337442a55b46Smrg# func_convert_path_noop ARG 337542a55b46Smrg# Copy ARG to func_to_host_path_result. 337642a55b46Smrgfunc_convert_path_noop () 337742a55b46Smrg{ 3378e3d74329Smrg func_to_host_path_result=$1 337942a55b46Smrg} 338042a55b46Smrg# end func_convert_path_noop 3381c582b7e3Smrg 3382c582b7e3Smrg 338342a55b46Smrg# func_convert_path_msys_to_w32 ARG 338442a55b46Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 338542a55b46Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 338642a55b46Smrg# func_to_host_path_result. 338742a55b46Smrgfunc_convert_path_msys_to_w32 () 338842a55b46Smrg{ 3389e3d74329Smrg $debug_cmd 3390e3d74329Smrg 3391e3d74329Smrg func_to_host_path_result=$1 339242a55b46Smrg if test -n "$1"; then 339342a55b46Smrg # Remove leading and trailing path separator characters from ARG. MSYS 339442a55b46Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 339542a55b46Smrg # and winepath ignores them completely. 339642a55b46Smrg func_stripname : : "$1" 339742a55b46Smrg func_to_host_path_tmp1=$func_stripname_result 339842a55b46Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3399e3d74329Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 340042a55b46Smrg func_convert_path_check : ";" \ 340142a55b46Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 340242a55b46Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 340342a55b46Smrg fi 340442a55b46Smrg} 340542a55b46Smrg# end func_convert_path_msys_to_w32 3406c582b7e3Smrg 3407c582b7e3Smrg 340842a55b46Smrg# func_convert_path_cygwin_to_w32 ARG 340942a55b46Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 341042a55b46Smrg# func_to_host_file_result. 341142a55b46Smrgfunc_convert_path_cygwin_to_w32 () 341242a55b46Smrg{ 3413e3d74329Smrg $debug_cmd 3414e3d74329Smrg 3415e3d74329Smrg func_to_host_path_result=$1 341642a55b46Smrg if test -n "$1"; then 341742a55b46Smrg # See func_convert_path_msys_to_w32: 341842a55b46Smrg func_stripname : : "$1" 341942a55b46Smrg func_to_host_path_tmp1=$func_stripname_result 342042a55b46Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 342142a55b46Smrg func_convert_path_check : ";" \ 342242a55b46Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 342342a55b46Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 342442a55b46Smrg fi 342542a55b46Smrg} 342642a55b46Smrg# end func_convert_path_cygwin_to_w32 3427c582b7e3Smrg 3428c582b7e3Smrg 342942a55b46Smrg# func_convert_path_nix_to_w32 ARG 343042a55b46Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 343142a55b46Smrg# a working winepath. Returns result in func_to_host_file_result. 343242a55b46Smrgfunc_convert_path_nix_to_w32 () 343342a55b46Smrg{ 3434e3d74329Smrg $debug_cmd 3435e3d74329Smrg 3436e3d74329Smrg func_to_host_path_result=$1 343742a55b46Smrg if test -n "$1"; then 343842a55b46Smrg # See func_convert_path_msys_to_w32: 343942a55b46Smrg func_stripname : : "$1" 344042a55b46Smrg func_to_host_path_tmp1=$func_stripname_result 344142a55b46Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3442e3d74329Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 344342a55b46Smrg func_convert_path_check : ";" \ 344442a55b46Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 344542a55b46Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 344642a55b46Smrg fi 344742a55b46Smrg} 344842a55b46Smrg# end func_convert_path_nix_to_w32 3449c582b7e3Smrg 3450c582b7e3Smrg 345142a55b46Smrg# func_convert_path_msys_to_cygwin ARG 345242a55b46Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 345342a55b46Smrg# Returns result in func_to_host_file_result. 345442a55b46Smrgfunc_convert_path_msys_to_cygwin () 345542a55b46Smrg{ 3456e3d74329Smrg $debug_cmd 3457e3d74329Smrg 3458e3d74329Smrg func_to_host_path_result=$1 345942a55b46Smrg if test -n "$1"; then 346042a55b46Smrg # See func_convert_path_msys_to_w32: 346142a55b46Smrg func_stripname : : "$1" 346242a55b46Smrg func_to_host_path_tmp1=$func_stripname_result 346342a55b46Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 346442a55b46Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3465e3d74329Smrg func_to_host_path_result=$func_cygpath_result 346642a55b46Smrg func_convert_path_check : : \ 346742a55b46Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 346842a55b46Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 346942a55b46Smrg fi 347042a55b46Smrg} 347142a55b46Smrg# end func_convert_path_msys_to_cygwin 3472c582b7e3Smrg 3473c582b7e3Smrg 347442a55b46Smrg# func_convert_path_nix_to_cygwin ARG 347542a55b46Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 347642a55b46Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 347742a55b46Smrg# func_to_host_file_result. 347842a55b46Smrgfunc_convert_path_nix_to_cygwin () 347942a55b46Smrg{ 3480e3d74329Smrg $debug_cmd 3481e3d74329Smrg 3482e3d74329Smrg func_to_host_path_result=$1 348342a55b46Smrg if test -n "$1"; then 348442a55b46Smrg # Remove leading and trailing path separator characters from 348542a55b46Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 348642a55b46Smrg # into '.;' and ';.', and winepath ignores them completely. 348742a55b46Smrg func_stripname : : "$1" 348842a55b46Smrg func_to_host_path_tmp1=$func_stripname_result 348942a55b46Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 349042a55b46Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3491e3d74329Smrg func_to_host_path_result=$func_cygpath_result 349242a55b46Smrg func_convert_path_check : : \ 349342a55b46Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 349442a55b46Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 349542a55b46Smrg fi 349642a55b46Smrg} 349742a55b46Smrg# end func_convert_path_nix_to_cygwin 3498c582b7e3Smrg 3499c582b7e3Smrg 3500e3d74329Smrg# func_dll_def_p FILE 3501e3d74329Smrg# True iff FILE is a Windows DLL '.def' file. 3502e3d74329Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3503e3d74329Smrgfunc_dll_def_p () 3504e3d74329Smrg{ 3505e3d74329Smrg $debug_cmd 3506e3d74329Smrg 3507e3d74329Smrg func_dll_def_p_tmp=`$SED -n \ 3508e3d74329Smrg -e 's/^[ ]*//' \ 3509e3d74329Smrg -e '/^\(;.*\)*$/d' \ 3510e3d74329Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3511e3d74329Smrg -e q \ 3512e3d74329Smrg "$1"` 3513e3d74329Smrg test DEF = "$func_dll_def_p_tmp" 3514e3d74329Smrg} 3515e3d74329Smrg 3516e3d74329Smrg 351742a55b46Smrg# func_mode_compile arg... 351842a55b46Smrgfunc_mode_compile () 351942a55b46Smrg{ 3520e3d74329Smrg $debug_cmd 3521e3d74329Smrg 352242a55b46Smrg # Get the compilation command and the source file. 352342a55b46Smrg base_compile= 3524e3d74329Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 352542a55b46Smrg suppress_opt=yes 352642a55b46Smrg suppress_output= 352742a55b46Smrg arg_mode=normal 352842a55b46Smrg libobj= 352942a55b46Smrg later= 353042a55b46Smrg pie_flag= 353142a55b46Smrg 353242a55b46Smrg for arg 353342a55b46Smrg do 353442a55b46Smrg case $arg_mode in 353542a55b46Smrg arg ) 353642a55b46Smrg # do not "continue". Instead, add this to base_compile 3537e3d74329Smrg lastarg=$arg 353842a55b46Smrg arg_mode=normal 353942a55b46Smrg ;; 354042a55b46Smrg 354142a55b46Smrg target ) 3542e3d74329Smrg libobj=$arg 354342a55b46Smrg arg_mode=normal 354442a55b46Smrg continue 354542a55b46Smrg ;; 354642a55b46Smrg 354742a55b46Smrg normal ) 354842a55b46Smrg # Accept any command-line options. 354942a55b46Smrg case $arg in 355042a55b46Smrg -o) 355142a55b46Smrg test -n "$libobj" && \ 3552e3d74329Smrg func_fatal_error "you cannot specify '-o' more than once" 355342a55b46Smrg arg_mode=target 3554c582b7e3Smrg continue 3555c582b7e3Smrg ;; 355642a55b46Smrg 355742a55b46Smrg -pie | -fpie | -fPIE) 355842a55b46Smrg func_append pie_flag " $arg" 3559c582b7e3Smrg continue 3560c582b7e3Smrg ;; 356142a55b46Smrg 356242a55b46Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 356342a55b46Smrg func_append later " $arg" 3564c582b7e3Smrg continue 3565c582b7e3Smrg ;; 356642a55b46Smrg 356742a55b46Smrg -no-suppress) 356842a55b46Smrg suppress_opt=no 3569c582b7e3Smrg continue 3570c582b7e3Smrg ;; 3571c582b7e3Smrg 357242a55b46Smrg -Xcompiler) 357342a55b46Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 357442a55b46Smrg continue # The current "srcfile" will either be retained or 357542a55b46Smrg ;; # replaced later. I would guess that would be a bug. 3576c582b7e3Smrg 357742a55b46Smrg -Wc,*) 357842a55b46Smrg func_stripname '-Wc,' '' "$arg" 357942a55b46Smrg args=$func_stripname_result 358042a55b46Smrg lastarg= 3581e3d74329Smrg save_ifs=$IFS; IFS=, 358242a55b46Smrg for arg in $args; do 3583e3d74329Smrg IFS=$save_ifs 358442a55b46Smrg func_append_quoted lastarg "$arg" 358542a55b46Smrg done 3586e3d74329Smrg IFS=$save_ifs 358742a55b46Smrg func_stripname ' ' '' "$lastarg" 358842a55b46Smrg lastarg=$func_stripname_result 3589c582b7e3Smrg 359042a55b46Smrg # Add the arguments to base_compile. 359142a55b46Smrg func_append base_compile " $lastarg" 359242a55b46Smrg continue 359342a55b46Smrg ;; 3594c582b7e3Smrg 359542a55b46Smrg *) 359642a55b46Smrg # Accept the current argument as the source file. 359742a55b46Smrg # The previous "srcfile" becomes the current argument. 359842a55b46Smrg # 3599e3d74329Smrg lastarg=$srcfile 3600e3d74329Smrg srcfile=$arg 360142a55b46Smrg ;; 360242a55b46Smrg esac # case $arg 3603c582b7e3Smrg ;; 360442a55b46Smrg esac # case $arg_mode 3605c582b7e3Smrg 360642a55b46Smrg # Aesthetically quote the previous argument. 360742a55b46Smrg func_append_quoted base_compile "$lastarg" 360842a55b46Smrg done # for arg 3609c582b7e3Smrg 361042a55b46Smrg case $arg_mode in 361142a55b46Smrg arg) 361242a55b46Smrg func_fatal_error "you must specify an argument for -Xcompile" 361342a55b46Smrg ;; 361442a55b46Smrg target) 3615e3d74329Smrg func_fatal_error "you must specify a target with '-o'" 361642a55b46Smrg ;; 361742a55b46Smrg *) 361842a55b46Smrg # Get the name of the library object. 361942a55b46Smrg test -z "$libobj" && { 362042a55b46Smrg func_basename "$srcfile" 3621e3d74329Smrg libobj=$func_basename_result 362242a55b46Smrg } 362342a55b46Smrg ;; 362442a55b46Smrg esac 3625c582b7e3Smrg 362642a55b46Smrg # Recognize several different file suffixes. 362742a55b46Smrg # If the user specifies -o file.o, it is replaced with file.lo 362842a55b46Smrg case $libobj in 362942a55b46Smrg *.[cCFSifmso] | \ 363042a55b46Smrg *.ada | *.adb | *.ads | *.asm | \ 363142a55b46Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 363242a55b46Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 363342a55b46Smrg func_xform "$libobj" 363442a55b46Smrg libobj=$func_xform_result 363542a55b46Smrg ;; 363642a55b46Smrg esac 3637c582b7e3Smrg 363842a55b46Smrg case $libobj in 363942a55b46Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 364042a55b46Smrg *) 3641e3d74329Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 364242a55b46Smrg ;; 364342a55b46Smrg esac 3644c582b7e3Smrg 364542a55b46Smrg func_infer_tag $base_compile 3646c582b7e3Smrg 364742a55b46Smrg for arg in $later; do 364842a55b46Smrg case $arg in 364942a55b46Smrg -shared) 3650e3d74329Smrg test yes = "$build_libtool_libs" \ 3651e3d74329Smrg || func_fatal_configuration "cannot build a shared library" 365242a55b46Smrg build_old_libs=no 3653c582b7e3Smrg continue 3654c582b7e3Smrg ;; 3655c582b7e3Smrg 365642a55b46Smrg -static) 365742a55b46Smrg build_libtool_libs=no 365842a55b46Smrg build_old_libs=yes 3659c582b7e3Smrg continue 3660c582b7e3Smrg ;; 3661c582b7e3Smrg 366242a55b46Smrg -prefer-pic) 366342a55b46Smrg pic_mode=yes 3664c582b7e3Smrg continue 3665c582b7e3Smrg ;; 3666c582b7e3Smrg 366742a55b46Smrg -prefer-non-pic) 366842a55b46Smrg pic_mode=no 3669c582b7e3Smrg continue 3670c582b7e3Smrg ;; 367142a55b46Smrg esac 367242a55b46Smrg done 3673c582b7e3Smrg 36748ce07328Smrg func_quote_arg pretty "$libobj" 36758ce07328Smrg test "X$libobj" != "X$func_quote_arg_result" \ 367642a55b46Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3677e3d74329Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 367842a55b46Smrg func_dirname_and_basename "$obj" "/" "" 3679e3d74329Smrg objname=$func_basename_result 3680e3d74329Smrg xdir=$func_dirname_result 3681e3d74329Smrg lobj=$xdir$objdir/$objname 3682c582b7e3Smrg 368342a55b46Smrg test -z "$base_compile" && \ 368442a55b46Smrg func_fatal_help "you must specify a compilation command" 368519019ffeSmrg 368642a55b46Smrg # Delete any leftover library objects. 3687e3d74329Smrg if test yes = "$build_old_libs"; then 368842a55b46Smrg removelist="$obj $lobj $libobj ${libobj}T" 368942a55b46Smrg else 369042a55b46Smrg removelist="$lobj $libobj ${libobj}T" 369142a55b46Smrg fi 3692c582b7e3Smrg 369342a55b46Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 369442a55b46Smrg case $host_os in 369542a55b46Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 369642a55b46Smrg pic_mode=default 369742a55b46Smrg ;; 369842a55b46Smrg esac 3699e3d74329Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 370042a55b46Smrg # non-PIC code in shared libraries is not supported 370142a55b46Smrg pic_mode=default 370242a55b46Smrg fi 3703c582b7e3Smrg 370442a55b46Smrg # Calculate the filename of the output object if compiler does 370542a55b46Smrg # not support -o with -c 3706e3d74329Smrg if test no = "$compiler_c_o"; then 3707e3d74329Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3708e3d74329Smrg lockfile=$output_obj.lock 370942a55b46Smrg else 371042a55b46Smrg output_obj= 371142a55b46Smrg need_locks=no 371242a55b46Smrg lockfile= 371342a55b46Smrg fi 3714c582b7e3Smrg 371542a55b46Smrg # Lock this critical section if it is needed 371642a55b46Smrg # We use this script file to make the link, it avoids creating a new file 3717e3d74329Smrg if test yes = "$need_locks"; then 371842a55b46Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 371942a55b46Smrg func_echo "Waiting for $lockfile to be removed" 372042a55b46Smrg sleep 2 372142a55b46Smrg done 3722e3d74329Smrg elif test warn = "$need_locks"; then 372342a55b46Smrg if test -f "$lockfile"; then 372442a55b46Smrg $ECHO "\ 372542a55b46Smrg*** ERROR, $lockfile exists and contains: 372642a55b46Smrg`cat $lockfile 2>/dev/null` 3727c582b7e3Smrg 372842a55b46SmrgThis indicates that another process is trying to use the same 372942a55b46Smrgtemporary object file, and libtool could not work around it because 3730e3d74329Smrgyour compiler does not support '-c' and '-o' together. If you 373142a55b46Smrgrepeat this compilation, it may succeed, by chance, but you had better 373242a55b46Smrgavoid parallel builds (make -j) in this platform, or get a better 373342a55b46Smrgcompiler." 3734c582b7e3Smrg 373542a55b46Smrg $opt_dry_run || $RM $removelist 373642a55b46Smrg exit $EXIT_FAILURE 373742a55b46Smrg fi 373842a55b46Smrg func_append removelist " $output_obj" 373942a55b46Smrg $ECHO "$srcfile" > "$lockfile" 374042a55b46Smrg fi 3741c582b7e3Smrg 374242a55b46Smrg $opt_dry_run || $RM $removelist 374342a55b46Smrg func_append removelist " $lockfile" 374442a55b46Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3745c582b7e3Smrg 374642a55b46Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 374742a55b46Smrg srcfile=$func_to_tool_file_result 37488ce07328Smrg func_quote_arg pretty "$srcfile" 37498ce07328Smrg qsrcfile=$func_quote_arg_result 3750c582b7e3Smrg 375142a55b46Smrg # Only build a PIC object if we are building libtool libraries. 3752e3d74329Smrg if test yes = "$build_libtool_libs"; then 375342a55b46Smrg # Without this assignment, base_compile gets emptied. 375442a55b46Smrg fbsd_hideous_sh_bug=$base_compile 3755c582b7e3Smrg 3756e3d74329Smrg if test no != "$pic_mode"; then 375742a55b46Smrg command="$base_compile $qsrcfile $pic_flag" 375842a55b46Smrg else 375942a55b46Smrg # Don't build PIC code 376042a55b46Smrg command="$base_compile $qsrcfile" 376142a55b46Smrg fi 3762c582b7e3Smrg 376342a55b46Smrg func_mkdir_p "$xdir$objdir" 3764c582b7e3Smrg 376542a55b46Smrg if test -z "$output_obj"; then 376642a55b46Smrg # Place PIC objects in $objdir 376742a55b46Smrg func_append command " -o $lobj" 376842a55b46Smrg fi 3769c582b7e3Smrg 377042a55b46Smrg func_show_eval_locale "$command" \ 377142a55b46Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3772c582b7e3Smrg 3773e3d74329Smrg if test warn = "$need_locks" && 377442a55b46Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 377542a55b46Smrg $ECHO "\ 377642a55b46Smrg*** ERROR, $lockfile contains: 377742a55b46Smrg`cat $lockfile 2>/dev/null` 3778c582b7e3Smrg 377942a55b46Smrgbut it should contain: 378042a55b46Smrg$srcfile 3781c582b7e3Smrg 378242a55b46SmrgThis indicates that another process is trying to use the same 378342a55b46Smrgtemporary object file, and libtool could not work around it because 3784e3d74329Smrgyour compiler does not support '-c' and '-o' together. If you 378542a55b46Smrgrepeat this compilation, it may succeed, by chance, but you had better 378642a55b46Smrgavoid parallel builds (make -j) in this platform, or get a better 378742a55b46Smrgcompiler." 3788c582b7e3Smrg 378942a55b46Smrg $opt_dry_run || $RM $removelist 379042a55b46Smrg exit $EXIT_FAILURE 379142a55b46Smrg fi 3792c582b7e3Smrg 379342a55b46Smrg # Just move the object if needed, then go on to compile the next one 379442a55b46Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 379542a55b46Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 379642a55b46Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 379742a55b46Smrg fi 3798c582b7e3Smrg 379942a55b46Smrg # Allow error messages only from the first compilation. 3800e3d74329Smrg if test yes = "$suppress_opt"; then 380142a55b46Smrg suppress_output=' >/dev/null 2>&1' 380242a55b46Smrg fi 380342a55b46Smrg fi 3804c582b7e3Smrg 380542a55b46Smrg # Only build a position-dependent object if we build old libraries. 3806e3d74329Smrg if test yes = "$build_old_libs"; then 3807e3d74329Smrg if test yes != "$pic_mode"; then 380842a55b46Smrg # Don't build PIC code 380942a55b46Smrg command="$base_compile $qsrcfile$pie_flag" 381042a55b46Smrg else 381142a55b46Smrg command="$base_compile $qsrcfile $pic_flag" 381242a55b46Smrg fi 3813e3d74329Smrg if test yes = "$compiler_c_o"; then 381442a55b46Smrg func_append command " -o $obj" 381542a55b46Smrg fi 3816c582b7e3Smrg 381742a55b46Smrg # Suppress compiler output if we already did a PIC compilation. 381842a55b46Smrg func_append command "$suppress_output" 381942a55b46Smrg func_show_eval_locale "$command" \ 382042a55b46Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3821c582b7e3Smrg 3822e3d74329Smrg if test warn = "$need_locks" && 382342a55b46Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 382442a55b46Smrg $ECHO "\ 382542a55b46Smrg*** ERROR, $lockfile contains: 382642a55b46Smrg`cat $lockfile 2>/dev/null` 3827c582b7e3Smrg 382842a55b46Smrgbut it should contain: 382942a55b46Smrg$srcfile 3830c582b7e3Smrg 383142a55b46SmrgThis indicates that another process is trying to use the same 383242a55b46Smrgtemporary object file, and libtool could not work around it because 3833e3d74329Smrgyour compiler does not support '-c' and '-o' together. If you 383442a55b46Smrgrepeat this compilation, it may succeed, by chance, but you had better 383542a55b46Smrgavoid parallel builds (make -j) in this platform, or get a better 383642a55b46Smrgcompiler." 3837c582b7e3Smrg 383842a55b46Smrg $opt_dry_run || $RM $removelist 383942a55b46Smrg exit $EXIT_FAILURE 384042a55b46Smrg fi 3841c582b7e3Smrg 384242a55b46Smrg # Just move the object if needed 384342a55b46Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 384442a55b46Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 384542a55b46Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 384642a55b46Smrg fi 384742a55b46Smrg fi 3848c582b7e3Smrg 384942a55b46Smrg $opt_dry_run || { 385042a55b46Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3851c582b7e3Smrg 385242a55b46Smrg # Unlock the critical section if it was locked 3853e3d74329Smrg if test no != "$need_locks"; then 385442a55b46Smrg removelist=$lockfile 385542a55b46Smrg $RM "$lockfile" 385642a55b46Smrg fi 385742a55b46Smrg } 3858c582b7e3Smrg 385942a55b46Smrg exit $EXIT_SUCCESS 386042a55b46Smrg} 3861c582b7e3Smrg 386242a55b46Smrg$opt_help || { 3863e3d74329Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 386442a55b46Smrg} 3865c582b7e3Smrg 386642a55b46Smrgfunc_mode_help () 386742a55b46Smrg{ 386842a55b46Smrg # We need to display help for each of the modes. 386942a55b46Smrg case $opt_mode in 387042a55b46Smrg "") 387142a55b46Smrg # Generic help is extracted from the usage comments 387242a55b46Smrg # at the start of this file. 387342a55b46Smrg func_help 387442a55b46Smrg ;; 3875c582b7e3Smrg 387642a55b46Smrg clean) 387742a55b46Smrg $ECHO \ 387842a55b46Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3879c582b7e3Smrg 388042a55b46SmrgRemove files from the build directory. 3881c582b7e3Smrg 388242a55b46SmrgRM is the name of the program to use to delete files associated with each FILE 3883e3d74329Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 388442a55b46Smrgto RM. 3885c582b7e3Smrg 388642a55b46SmrgIf FILE is a libtool library, object or program, all the files associated 388742a55b46Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 388842a55b46Smrg ;; 3889c582b7e3Smrg 389042a55b46Smrg compile) 389142a55b46Smrg $ECHO \ 389242a55b46Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3893c582b7e3Smrg 389442a55b46SmrgCompile a source file into a libtool library object. 3895c582b7e3Smrg 389642a55b46SmrgThis mode accepts the following additional options: 3897c582b7e3Smrg 389842a55b46Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 389942a55b46Smrg -no-suppress do not suppress compiler output for multiple passes 390042a55b46Smrg -prefer-pic try to build PIC objects only 390142a55b46Smrg -prefer-non-pic try to build non-PIC objects only 3902e3d74329Smrg -shared do not build a '.o' file suitable for static linking 3903e3d74329Smrg -static only build a '.o' file suitable for static linking 39048ce07328Smrg -Wc,FLAG 39058ce07328Smrg -Xcompiler FLAG pass FLAG directly to the compiler 3906c582b7e3Smrg 3907e3d74329SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 390842a55b46Smrgfrom the given SOURCEFILE. 3909c582b7e3Smrg 391042a55b46SmrgThe output file name is determined by removing the directory component from 3911e3d74329SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 3912e3d74329Smrglibrary object suffix, '.lo'." 391342a55b46Smrg ;; 3914c582b7e3Smrg 391542a55b46Smrg execute) 391642a55b46Smrg $ECHO \ 391742a55b46Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3918c582b7e3Smrg 391942a55b46SmrgAutomatically set library path, then run a program. 3920c582b7e3Smrg 392142a55b46SmrgThis mode accepts the following additional options: 3922c582b7e3Smrg 392342a55b46Smrg -dlopen FILE add the directory containing FILE to the library path 3924c582b7e3Smrg 3925e3d74329SmrgThis mode sets the library path environment variable according to '-dlopen' 392642a55b46Smrgflags. 3927c582b7e3Smrg 392842a55b46SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 392942a55b46Smrginto their corresponding uninstalled binary, and any of their required library 393042a55b46Smrgdirectories are added to the library path. 3931c582b7e3Smrg 393242a55b46SmrgThen, COMMAND is executed, with ARGS as arguments." 393342a55b46Smrg ;; 393442a55b46Smrg 393542a55b46Smrg finish) 393642a55b46Smrg $ECHO \ 393742a55b46Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 393842a55b46Smrg 393942a55b46SmrgComplete the installation of libtool libraries. 394042a55b46Smrg 394142a55b46SmrgEach LIBDIR is a directory that contains libtool libraries. 394242a55b46Smrg 394342a55b46SmrgThe commands that this mode executes may require superuser privileges. Use 3944e3d74329Smrgthe '--dry-run' option if you just want to see what would be executed." 394542a55b46Smrg ;; 394642a55b46Smrg 394742a55b46Smrg install) 394842a55b46Smrg $ECHO \ 394942a55b46Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 395042a55b46Smrg 395142a55b46SmrgInstall executables or libraries. 395242a55b46Smrg 395342a55b46SmrgINSTALL-COMMAND is the installation command. The first component should be 3954e3d74329Smrgeither the 'install' or 'cp' program. 395542a55b46Smrg 395642a55b46SmrgThe following components of INSTALL-COMMAND are treated specially: 395742a55b46Smrg 395842a55b46Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 395942a55b46Smrg 396042a55b46SmrgThe rest of the components are interpreted as arguments to that command (only 396142a55b46SmrgBSD-compatible install options are recognized)." 396242a55b46Smrg ;; 396342a55b46Smrg 396442a55b46Smrg link) 396542a55b46Smrg $ECHO \ 396642a55b46Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 396742a55b46Smrg 396842a55b46SmrgLink object files or libraries together to form another library, or to 396942a55b46Smrgcreate an executable program. 397042a55b46Smrg 397142a55b46SmrgLINK-COMMAND is a command using the C compiler that you would use to create 397242a55b46Smrga program from several object files. 397342a55b46Smrg 397442a55b46SmrgThe following components of LINK-COMMAND are treated specially: 397542a55b46Smrg 397642a55b46Smrg -all-static do not do any dynamic linking at all 397742a55b46Smrg -avoid-version do not add a version suffix if possible 397842a55b46Smrg -bindir BINDIR specify path to binaries directory (for systems where 397942a55b46Smrg libraries must be found in the PATH setting at runtime) 3980e3d74329Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 398142a55b46Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 398242a55b46Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 398342a55b46Smrg -export-symbols SYMFILE 398442a55b46Smrg try to export only the symbols listed in SYMFILE 398542a55b46Smrg -export-symbols-regex REGEX 398642a55b46Smrg try to export only the symbols matching REGEX 398742a55b46Smrg -LLIBDIR search LIBDIR for required installed libraries 398842a55b46Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 398942a55b46Smrg -module build a library that can dlopened 399042a55b46Smrg -no-fast-install disable the fast-install mode 399142a55b46Smrg -no-install link a not-installable executable 399242a55b46Smrg -no-undefined declare that a library does not refer to external symbols 399342a55b46Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3994e3d74329Smrg -objectlist FILE use a list of object files found in FILE to specify objects 3995e3d74329Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 399642a55b46Smrg -precious-files-regex REGEX 399742a55b46Smrg don't remove output files matching REGEX 399842a55b46Smrg -release RELEASE specify package release information 399942a55b46Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 400042a55b46Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 400142a55b46Smrg -shared only do dynamic linking of libtool libraries 400242a55b46Smrg -shrext SUFFIX override the standard shared library file extension 400342a55b46Smrg -static do not do any dynamic linking of uninstalled libtool libraries 400442a55b46Smrg -static-libtool-libs 400542a55b46Smrg do not do any dynamic linking of libtool libraries 400642a55b46Smrg -version-info CURRENT[:REVISION[:AGE]] 400742a55b46Smrg specify library version info [each variable defaults to 0] 400842a55b46Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 400942a55b46Smrg -Wc,FLAG 401042a55b46Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 40118ce07328Smrg -Wa,FLAG 40128ce07328Smrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 401342a55b46Smrg -Wl,FLAG 401442a55b46Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 401542a55b46Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 401642a55b46Smrg 4017e3d74329SmrgAll other options (arguments beginning with '-') are ignored. 401842a55b46Smrg 4019e3d74329SmrgEvery other argument is treated as a filename. Files ending in '.la' are 402042a55b46Smrgtreated as uninstalled libtool libraries, other files are standard or library 402142a55b46Smrgobject files. 402242a55b46Smrg 4023e3d74329SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 4024e3d74329Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 402542a55b46Smrgrequired, except when creating a convenience library. 402642a55b46Smrg 4027e3d74329SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 4028e3d74329Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 402942a55b46Smrg 4030e3d74329SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 403142a55b46Smrgis created, otherwise an executable program is created." 403242a55b46Smrg ;; 403342a55b46Smrg 403442a55b46Smrg uninstall) 403542a55b46Smrg $ECHO \ 403642a55b46Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 403742a55b46Smrg 403842a55b46SmrgRemove libraries from an installation directory. 403942a55b46Smrg 404042a55b46SmrgRM is the name of the program to use to delete files associated with each FILE 4041e3d74329Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 404242a55b46Smrgto RM. 404342a55b46Smrg 404442a55b46SmrgIf FILE is a libtool library, all the files associated with it are deleted. 404542a55b46SmrgOtherwise, only FILE itself is deleted using RM." 404642a55b46Smrg ;; 404742a55b46Smrg 404842a55b46Smrg *) 4049e3d74329Smrg func_fatal_help "invalid operation mode '$opt_mode'" 405042a55b46Smrg ;; 4051c582b7e3Smrg esac 4052c582b7e3Smrg 405342a55b46Smrg echo 4054e3d74329Smrg $ECHO "Try '$progname --help' for more information about other modes." 405542a55b46Smrg} 4056c582b7e3Smrg 405742a55b46Smrg# Now that we've collected a possible --mode arg, show help if necessary 405842a55b46Smrgif $opt_help; then 4059e3d74329Smrg if test : = "$opt_help"; then 406042a55b46Smrg func_mode_help 406142a55b46Smrg else 406242a55b46Smrg { 406342a55b46Smrg func_help noexit 406442a55b46Smrg for opt_mode in compile link execute install finish uninstall clean; do 406542a55b46Smrg func_mode_help 406642a55b46Smrg done 4067e3d74329Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 406842a55b46Smrg { 406942a55b46Smrg func_help noexit 407042a55b46Smrg for opt_mode in compile link execute install finish uninstall clean; do 407142a55b46Smrg echo 407242a55b46Smrg func_mode_help 407342a55b46Smrg done 407442a55b46Smrg } | 4075e3d74329Smrg $SED '1d 407642a55b46Smrg /^When reporting/,/^Report/{ 407742a55b46Smrg H 407842a55b46Smrg d 407942a55b46Smrg } 408042a55b46Smrg $x 408142a55b46Smrg /information about other modes/d 408242a55b46Smrg /more detailed .*MODE/d 408342a55b46Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 408442a55b46Smrg fi 408542a55b46Smrg exit $? 408642a55b46Smrgfi 4087c582b7e3Smrg 4088c582b7e3Smrg 408942a55b46Smrg# func_mode_execute arg... 409042a55b46Smrgfunc_mode_execute () 409142a55b46Smrg{ 4092e3d74329Smrg $debug_cmd 4093e3d74329Smrg 409442a55b46Smrg # The first argument is the command name. 4095e3d74329Smrg cmd=$nonopt 409642a55b46Smrg test -z "$cmd" && \ 409742a55b46Smrg func_fatal_help "you must specify a COMMAND" 409842a55b46Smrg 409942a55b46Smrg # Handle -dlopen flags immediately. 410042a55b46Smrg for file in $opt_dlopen; do 410142a55b46Smrg test -f "$file" \ 4102e3d74329Smrg || func_fatal_help "'$file' is not a file" 410342a55b46Smrg 410442a55b46Smrg dir= 410542a55b46Smrg case $file in 410642a55b46Smrg *.la) 410742a55b46Smrg func_resolve_sysroot "$file" 410842a55b46Smrg file=$func_resolve_sysroot_result 410942a55b46Smrg 411042a55b46Smrg # Check to see that this really is a libtool archive. 411142a55b46Smrg func_lalib_unsafe_p "$file" \ 4112e3d74329Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 411342a55b46Smrg 411442a55b46Smrg # Read the libtool library. 411542a55b46Smrg dlname= 411642a55b46Smrg library_names= 411742a55b46Smrg func_source "$file" 411842a55b46Smrg 411942a55b46Smrg # Skip this library if it cannot be dlopened. 412042a55b46Smrg if test -z "$dlname"; then 412142a55b46Smrg # Warn if it was a shared library. 412242a55b46Smrg test -n "$library_names" && \ 4123e3d74329Smrg func_warning "'$file' was not linked with '-export-dynamic'" 412442a55b46Smrg continue 412542a55b46Smrg fi 412642a55b46Smrg 412742a55b46Smrg func_dirname "$file" "" "." 4128e3d74329Smrg dir=$func_dirname_result 412942a55b46Smrg 413042a55b46Smrg if test -f "$dir/$objdir/$dlname"; then 413142a55b46Smrg func_append dir "/$objdir" 413242a55b46Smrg else 413342a55b46Smrg if test ! -f "$dir/$dlname"; then 4134e3d74329Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 413542a55b46Smrg fi 413642a55b46Smrg fi 4137c582b7e3Smrg ;; 413842a55b46Smrg 413942a55b46Smrg *.lo) 414042a55b46Smrg # Just add the directory containing the .lo file. 414142a55b46Smrg func_dirname "$file" "" "." 4142e3d74329Smrg dir=$func_dirname_result 4143c582b7e3Smrg ;; 414442a55b46Smrg 414542a55b46Smrg *) 4146e3d74329Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 414742a55b46Smrg continue 4148c582b7e3Smrg ;; 414942a55b46Smrg esac 415042a55b46Smrg 415142a55b46Smrg # Get the absolute pathname. 415242a55b46Smrg absdir=`cd "$dir" && pwd` 4153e3d74329Smrg test -n "$absdir" && dir=$absdir 415442a55b46Smrg 415542a55b46Smrg # Now add the directory to shlibpath_var. 415642a55b46Smrg if eval "test -z \"\$$shlibpath_var\""; then 415742a55b46Smrg eval "$shlibpath_var=\"\$dir\"" 415842a55b46Smrg else 415942a55b46Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 4160c582b7e3Smrg fi 416142a55b46Smrg done 416242a55b46Smrg 416342a55b46Smrg # This variable tells wrapper scripts just to set shlibpath_var 416442a55b46Smrg # rather than running their programs. 4165e3d74329Smrg libtool_execute_magic=$magic 416642a55b46Smrg 416742a55b46Smrg # Check if any of the arguments is a wrapper script. 416842a55b46Smrg args= 416942a55b46Smrg for file 417042a55b46Smrg do 417142a55b46Smrg case $file in 417242a55b46Smrg -* | *.la | *.lo ) ;; 417342a55b46Smrg *) 417442a55b46Smrg # Do a test to see if this is really a libtool program. 417542a55b46Smrg if func_ltwrapper_script_p "$file"; then 417642a55b46Smrg func_source "$file" 417742a55b46Smrg # Transform arg to wrapped name. 4178e3d74329Smrg file=$progdir/$program 417942a55b46Smrg elif func_ltwrapper_executable_p "$file"; then 418042a55b46Smrg func_ltwrapper_scriptname "$file" 418142a55b46Smrg func_source "$func_ltwrapper_scriptname_result" 418242a55b46Smrg # Transform arg to wrapped name. 4183e3d74329Smrg file=$progdir/$program 418442a55b46Smrg fi 418542a55b46Smrg ;; 418642a55b46Smrg esac 418742a55b46Smrg # Quote arguments (to preserve shell metacharacters). 418842a55b46Smrg func_append_quoted args "$file" 418942a55b46Smrg done 419042a55b46Smrg 4191e3d74329Smrg if $opt_dry_run; then 4192e3d74329Smrg # Display what would be done. 4193e3d74329Smrg if test -n "$shlibpath_var"; then 4194e3d74329Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 4195e3d74329Smrg echo "export $shlibpath_var" 4196e3d74329Smrg fi 4197e3d74329Smrg $ECHO "$cmd$args" 4198e3d74329Smrg exit $EXIT_SUCCESS 4199e3d74329Smrg else 420042a55b46Smrg if test -n "$shlibpath_var"; then 420142a55b46Smrg # Export the shlibpath_var. 420242a55b46Smrg eval "export $shlibpath_var" 4203c582b7e3Smrg fi 420442a55b46Smrg 420542a55b46Smrg # Restore saved environment variables 420642a55b46Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 420742a55b46Smrg do 420842a55b46Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 420942a55b46Smrg $lt_var=\$save_$lt_var; export $lt_var 421042a55b46Smrg else 421142a55b46Smrg $lt_unset $lt_var 421242a55b46Smrg fi" 421342a55b46Smrg done 421442a55b46Smrg 421542a55b46Smrg # Now prepare to actually exec the command. 4216e3d74329Smrg exec_cmd=\$cmd$args 421742a55b46Smrg fi 421842a55b46Smrg} 4219c582b7e3Smrg 4220e3d74329Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 4221c582b7e3Smrg 4222c582b7e3Smrg 422342a55b46Smrg# func_mode_finish arg... 422442a55b46Smrgfunc_mode_finish () 422542a55b46Smrg{ 4226e3d74329Smrg $debug_cmd 4227e3d74329Smrg 422842a55b46Smrg libs= 422942a55b46Smrg libdirs= 423042a55b46Smrg admincmds= 4231c582b7e3Smrg 423242a55b46Smrg for opt in "$nonopt" ${1+"$@"} 423342a55b46Smrg do 423442a55b46Smrg if test -d "$opt"; then 423542a55b46Smrg func_append libdirs " $opt" 4236c582b7e3Smrg 423742a55b46Smrg elif test -f "$opt"; then 423842a55b46Smrg if func_lalib_unsafe_p "$opt"; then 423942a55b46Smrg func_append libs " $opt" 424042a55b46Smrg else 4241e3d74329Smrg func_warning "'$opt' is not a valid libtool archive" 4242c582b7e3Smrg fi 4243c582b7e3Smrg 424442a55b46Smrg else 4245e3d74329Smrg func_fatal_error "invalid argument '$opt'" 424642a55b46Smrg fi 424742a55b46Smrg done 4248c582b7e3Smrg 424942a55b46Smrg if test -n "$libs"; then 425042a55b46Smrg if test -n "$lt_sysroot"; then 425142a55b46Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 425242a55b46Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 425342a55b46Smrg else 425442a55b46Smrg sysroot_cmd= 425542a55b46Smrg fi 4256c582b7e3Smrg 425742a55b46Smrg # Remove sysroot references 425842a55b46Smrg if $opt_dry_run; then 425942a55b46Smrg for lib in $libs; do 4260e3d74329Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 426142a55b46Smrg done 426242a55b46Smrg else 426342a55b46Smrg tmpdir=`func_mktempdir` 426442a55b46Smrg for lib in $libs; do 4265e3d74329Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 426642a55b46Smrg > $tmpdir/tmp-la 426742a55b46Smrg mv -f $tmpdir/tmp-la $lib 4268c582b7e3Smrg done 426942a55b46Smrg ${RM}r "$tmpdir" 427042a55b46Smrg fi 427142a55b46Smrg fi 427242a55b46Smrg 427342a55b46Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 427442a55b46Smrg for libdir in $libdirs; do 427542a55b46Smrg if test -n "$finish_cmds"; then 427642a55b46Smrg # Do each command in the finish commands. 427742a55b46Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 427842a55b46Smrg'"$cmd"'"' 427942a55b46Smrg fi 428042a55b46Smrg if test -n "$finish_eval"; then 428142a55b46Smrg # Do the single finish_eval. 428242a55b46Smrg eval cmds=\"$finish_eval\" 428342a55b46Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 428442a55b46Smrg $cmds" 4285c582b7e3Smrg fi 428642a55b46Smrg done 428742a55b46Smrg fi 4288c582b7e3Smrg 428942a55b46Smrg # Exit here if they wanted silent mode. 4290e3d74329Smrg $opt_quiet && exit $EXIT_SUCCESS 4291c582b7e3Smrg 429242a55b46Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 429342a55b46Smrg echo "----------------------------------------------------------------------" 429442a55b46Smrg echo "Libraries have been installed in:" 429542a55b46Smrg for libdir in $libdirs; do 429642a55b46Smrg $ECHO " $libdir" 429742a55b46Smrg done 429842a55b46Smrg echo 429942a55b46Smrg echo "If you ever happen to want to link against installed libraries" 430042a55b46Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 4301e3d74329Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 430242a55b46Smrg echo "flag during linking and do at least one of the following:" 430342a55b46Smrg if test -n "$shlibpath_var"; then 4304e3d74329Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 430542a55b46Smrg echo " during execution" 430642a55b46Smrg fi 430742a55b46Smrg if test -n "$runpath_var"; then 4308e3d74329Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 430942a55b46Smrg echo " during linking" 431042a55b46Smrg fi 431142a55b46Smrg if test -n "$hardcode_libdir_flag_spec"; then 431242a55b46Smrg libdir=LIBDIR 431342a55b46Smrg eval flag=\"$hardcode_libdir_flag_spec\" 431442a55b46Smrg 4315e3d74329Smrg $ECHO " - use the '$flag' linker flag" 431642a55b46Smrg fi 431742a55b46Smrg if test -n "$admincmds"; then 431842a55b46Smrg $ECHO " - have your system administrator run these commands:$admincmds" 431942a55b46Smrg fi 432042a55b46Smrg if test -f /etc/ld.so.conf; then 4321e3d74329Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 432242a55b46Smrg fi 432342a55b46Smrg echo 432442a55b46Smrg 432542a55b46Smrg echo "See any operating system documentation about shared libraries for" 432642a55b46Smrg case $host in 432742a55b46Smrg solaris2.[6789]|solaris2.1[0-9]) 432842a55b46Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 432942a55b46Smrg echo "pages." 433042a55b46Smrg ;; 4331c582b7e3Smrg *) 433242a55b46Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4333c582b7e3Smrg ;; 433442a55b46Smrg esac 433542a55b46Smrg echo "----------------------------------------------------------------------" 433642a55b46Smrg fi 433742a55b46Smrg exit $EXIT_SUCCESS 433842a55b46Smrg} 4339c582b7e3Smrg 4340e3d74329Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4341c582b7e3Smrg 4342c582b7e3Smrg 434342a55b46Smrg# func_mode_install arg... 434442a55b46Smrgfunc_mode_install () 434542a55b46Smrg{ 4346e3d74329Smrg $debug_cmd 4347e3d74329Smrg 434842a55b46Smrg # There may be an optional sh(1) argument at the beginning of 434942a55b46Smrg # install_prog (especially on Windows NT). 4350e3d74329Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 435142a55b46Smrg # Allow the use of GNU shtool's install command. 4352e3d74329Smrg case $nonopt in *shtool*) :;; *) false;; esac 4353e3d74329Smrg then 435442a55b46Smrg # Aesthetically quote it. 43558ce07328Smrg func_quote_arg pretty "$nonopt" 43568ce07328Smrg install_prog="$func_quote_arg_result " 435742a55b46Smrg arg=$1 435842a55b46Smrg shift 435942a55b46Smrg else 436042a55b46Smrg install_prog= 436142a55b46Smrg arg=$nonopt 436242a55b46Smrg fi 436342a55b46Smrg 436442a55b46Smrg # The real first argument should be the name of the installation program. 436542a55b46Smrg # Aesthetically quote it. 43668ce07328Smrg func_quote_arg pretty "$arg" 43678ce07328Smrg func_append install_prog "$func_quote_arg_result" 436842a55b46Smrg install_shared_prog=$install_prog 436942a55b46Smrg case " $install_prog " in 437042a55b46Smrg *[\\\ /]cp\ *) install_cp=: ;; 437142a55b46Smrg *) install_cp=false ;; 437242a55b46Smrg esac 437342a55b46Smrg 437442a55b46Smrg # We need to accept at least all the BSD install flags. 437542a55b46Smrg dest= 437642a55b46Smrg files= 437742a55b46Smrg opts= 437842a55b46Smrg prev= 437942a55b46Smrg install_type= 4380e3d74329Smrg isdir=false 438142a55b46Smrg stripme= 438242a55b46Smrg no_mode=: 438342a55b46Smrg for arg 438442a55b46Smrg do 438542a55b46Smrg arg2= 438642a55b46Smrg if test -n "$dest"; then 438742a55b46Smrg func_append files " $dest" 438842a55b46Smrg dest=$arg 438942a55b46Smrg continue 439042a55b46Smrg fi 439142a55b46Smrg 439242a55b46Smrg case $arg in 4393e3d74329Smrg -d) isdir=: ;; 439442a55b46Smrg -f) 439542a55b46Smrg if $install_cp; then :; else 439642a55b46Smrg prev=$arg 439742a55b46Smrg fi 439842a55b46Smrg ;; 439942a55b46Smrg -g | -m | -o) 440042a55b46Smrg prev=$arg 440142a55b46Smrg ;; 440242a55b46Smrg -s) 440342a55b46Smrg stripme=" -s" 440442a55b46Smrg continue 440542a55b46Smrg ;; 440642a55b46Smrg -*) 440742a55b46Smrg ;; 440842a55b46Smrg *) 440942a55b46Smrg # If the previous option needed an argument, then skip it. 441042a55b46Smrg if test -n "$prev"; then 4411e3d74329Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 441242a55b46Smrg arg2=$install_override_mode 441342a55b46Smrg no_mode=false 4414c582b7e3Smrg fi 441542a55b46Smrg prev= 441642a55b46Smrg else 441742a55b46Smrg dest=$arg 4418c582b7e3Smrg continue 4419c582b7e3Smrg fi 442042a55b46Smrg ;; 442142a55b46Smrg esac 4422c582b7e3Smrg 442342a55b46Smrg # Aesthetically quote the argument. 44248ce07328Smrg func_quote_arg pretty "$arg" 44258ce07328Smrg func_append install_prog " $func_quote_arg_result" 442642a55b46Smrg if test -n "$arg2"; then 44278ce07328Smrg func_quote_arg pretty "$arg2" 442842a55b46Smrg fi 44298ce07328Smrg func_append install_shared_prog " $func_quote_arg_result" 443042a55b46Smrg done 4431c582b7e3Smrg 443242a55b46Smrg test -z "$install_prog" && \ 443342a55b46Smrg func_fatal_help "you must specify an install program" 4434c582b7e3Smrg 443542a55b46Smrg test -n "$prev" && \ 4436e3d74329Smrg func_fatal_help "the '$prev' option requires an argument" 4437c582b7e3Smrg 443842a55b46Smrg if test -n "$install_override_mode" && $no_mode; then 443942a55b46Smrg if $install_cp; then :; else 44408ce07328Smrg func_quote_arg pretty "$install_override_mode" 44418ce07328Smrg func_append install_shared_prog " -m $func_quote_arg_result" 444242a55b46Smrg fi 444342a55b46Smrg fi 4444c582b7e3Smrg 444542a55b46Smrg if test -z "$files"; then 444642a55b46Smrg if test -z "$dest"; then 444742a55b46Smrg func_fatal_help "no file or destination specified" 444842a55b46Smrg else 444942a55b46Smrg func_fatal_help "you must specify a destination" 445042a55b46Smrg fi 445142a55b46Smrg fi 4452c582b7e3Smrg 445342a55b46Smrg # Strip any trailing slash from the destination. 445442a55b46Smrg func_stripname '' '/' "$dest" 445542a55b46Smrg dest=$func_stripname_result 4456c582b7e3Smrg 445742a55b46Smrg # Check to see that the destination is a directory. 4458e3d74329Smrg test -d "$dest" && isdir=: 4459e3d74329Smrg if $isdir; then 4460e3d74329Smrg destdir=$dest 446142a55b46Smrg destname= 446242a55b46Smrg else 446342a55b46Smrg func_dirname_and_basename "$dest" "" "." 4464e3d74329Smrg destdir=$func_dirname_result 4465e3d74329Smrg destname=$func_basename_result 4466c582b7e3Smrg 446742a55b46Smrg # Not a directory, so check to see that there is only one file specified. 446842a55b46Smrg set dummy $files; shift 446942a55b46Smrg test "$#" -gt 1 && \ 4470e3d74329Smrg func_fatal_help "'$dest' is not a directory" 447142a55b46Smrg fi 447242a55b46Smrg case $destdir in 447342a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 447442a55b46Smrg *) 447542a55b46Smrg for file in $files; do 447642a55b46Smrg case $file in 447742a55b46Smrg *.lo) ;; 447842a55b46Smrg *) 4479e3d74329Smrg func_fatal_help "'$destdir' must be an absolute directory name" 448042a55b46Smrg ;; 448142a55b46Smrg esac 448242a55b46Smrg done 448342a55b46Smrg ;; 448442a55b46Smrg esac 4485c582b7e3Smrg 448642a55b46Smrg # This variable tells wrapper scripts just to set variables rather 448742a55b46Smrg # than running their programs. 4488e3d74329Smrg libtool_install_magic=$magic 4489c582b7e3Smrg 449042a55b46Smrg staticlibs= 449142a55b46Smrg future_libdirs= 449242a55b46Smrg current_libdirs= 449342a55b46Smrg for file in $files; do 4494c582b7e3Smrg 449542a55b46Smrg # Do each installation. 449642a55b46Smrg case $file in 449742a55b46Smrg *.$libext) 449842a55b46Smrg # Do the static libraries later. 449942a55b46Smrg func_append staticlibs " $file" 450042a55b46Smrg ;; 4501c582b7e3Smrg 450242a55b46Smrg *.la) 450342a55b46Smrg func_resolve_sysroot "$file" 450442a55b46Smrg file=$func_resolve_sysroot_result 4505c582b7e3Smrg 450642a55b46Smrg # Check to see that this really is a libtool archive. 450742a55b46Smrg func_lalib_unsafe_p "$file" \ 4508e3d74329Smrg || func_fatal_help "'$file' is not a valid libtool archive" 4509c582b7e3Smrg 451042a55b46Smrg library_names= 451142a55b46Smrg old_library= 451242a55b46Smrg relink_command= 451342a55b46Smrg func_source "$file" 4514c582b7e3Smrg 451542a55b46Smrg # Add the libdir to current_libdirs if it is the destination. 451642a55b46Smrg if test "X$destdir" = "X$libdir"; then 451742a55b46Smrg case "$current_libdirs " in 451842a55b46Smrg *" $libdir "*) ;; 451942a55b46Smrg *) func_append current_libdirs " $libdir" ;; 452042a55b46Smrg esac 452142a55b46Smrg else 452242a55b46Smrg # Note the libdir as a future libdir. 452342a55b46Smrg case "$future_libdirs " in 452442a55b46Smrg *" $libdir "*) ;; 452542a55b46Smrg *) func_append future_libdirs " $libdir" ;; 452642a55b46Smrg esac 452742a55b46Smrg fi 4528c582b7e3Smrg 452942a55b46Smrg func_dirname "$file" "/" "" 4530e3d74329Smrg dir=$func_dirname_result 453142a55b46Smrg func_append dir "$objdir" 4532c582b7e3Smrg 453342a55b46Smrg if test -n "$relink_command"; then 453442a55b46Smrg # Determine the prefix the user has applied to our future dir. 453542a55b46Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4536c582b7e3Smrg 453742a55b46Smrg # Don't allow the user to place us outside of our expected 453842a55b46Smrg # location b/c this prevents finding dependent libraries that 453942a55b46Smrg # are installed to the same prefix. 454042a55b46Smrg # At present, this check doesn't affect windows .dll's that 454142a55b46Smrg # are installed into $libdir/../bin (currently, that works fine) 454242a55b46Smrg # but it's something to keep an eye on. 454342a55b46Smrg test "$inst_prefix_dir" = "$destdir" && \ 4544e3d74329Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 454542a55b46Smrg 454642a55b46Smrg if test -n "$inst_prefix_dir"; then 454742a55b46Smrg # Stick the inst_prefix_dir data into the link command. 454842a55b46Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4549c582b7e3Smrg else 455042a55b46Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4551c582b7e3Smrg fi 4552c582b7e3Smrg 4553e3d74329Smrg func_warning "relinking '$file'" 455442a55b46Smrg func_show_eval "$relink_command" \ 4555e3d74329Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 455642a55b46Smrg fi 455742a55b46Smrg 455842a55b46Smrg # See the names of the shared library. 455942a55b46Smrg set dummy $library_names; shift 456042a55b46Smrg if test -n "$1"; then 4561e3d74329Smrg realname=$1 456242a55b46Smrg shift 456342a55b46Smrg 4564e3d74329Smrg srcname=$realname 4565e3d74329Smrg test -n "$relink_command" && srcname=${realname}T 456642a55b46Smrg 456742a55b46Smrg # Install the shared library and build the symlinks. 456842a55b46Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 456942a55b46Smrg 'exit $?' 4570e3d74329Smrg tstripme=$stripme 457142a55b46Smrg case $host_os in 457242a55b46Smrg cygwin* | mingw* | pw32* | cegcc*) 457342a55b46Smrg case $realname in 457442a55b46Smrg *.dll.a) 4575e3d74329Smrg tstripme= 4576e3d74329Smrg ;; 4577e3d74329Smrg esac 4578e3d74329Smrg ;; 4579e3d74329Smrg os2*) 4580e3d74329Smrg case $realname in 4581e3d74329Smrg *_dll.a) 4582e3d74329Smrg tstripme= 458342a55b46Smrg ;; 458442a55b46Smrg esac 458542a55b46Smrg ;; 458642a55b46Smrg esac 458742a55b46Smrg if test -n "$tstripme" && test -n "$striplib"; then 458842a55b46Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4589c582b7e3Smrg fi 4590c582b7e3Smrg 459142a55b46Smrg if test "$#" -gt 0; then 459242a55b46Smrg # Delete the old symlinks, and create new ones. 4593e3d74329Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 459442a55b46Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 459542a55b46Smrg # so we also need to try rm && ln -s. 459642a55b46Smrg for linkname 459742a55b46Smrg do 459842a55b46Smrg test "$linkname" != "$realname" \ 459942a55b46Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4600c582b7e3Smrg done 4601c582b7e3Smrg fi 4602c582b7e3Smrg 460342a55b46Smrg # Do each command in the postinstall commands. 4604e3d74329Smrg lib=$destdir/$realname 460542a55b46Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 460642a55b46Smrg fi 4607c582b7e3Smrg 460842a55b46Smrg # Install the pseudo-library for information purposes. 460942a55b46Smrg func_basename "$file" 4610e3d74329Smrg name=$func_basename_result 4611e3d74329Smrg instname=$dir/${name}i 461242a55b46Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4613c582b7e3Smrg 461442a55b46Smrg # Maybe install the static library, too. 461542a55b46Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 461642a55b46Smrg ;; 461742a55b46Smrg 461842a55b46Smrg *.lo) 461942a55b46Smrg # Install (i.e. copy) a libtool object. 462042a55b46Smrg 462142a55b46Smrg # Figure out destination file name, if it wasn't already specified. 462242a55b46Smrg if test -n "$destname"; then 4623e3d74329Smrg destfile=$destdir/$destname 4624c582b7e3Smrg else 462542a55b46Smrg func_basename "$file" 4626e3d74329Smrg destfile=$func_basename_result 4627e3d74329Smrg destfile=$destdir/$destfile 4628c582b7e3Smrg fi 462942a55b46Smrg 463042a55b46Smrg # Deduce the name of the destination old-style object file. 463142a55b46Smrg case $destfile in 463242a55b46Smrg *.lo) 463342a55b46Smrg func_lo2o "$destfile" 463442a55b46Smrg staticdest=$func_lo2o_result 463542a55b46Smrg ;; 463642a55b46Smrg *.$objext) 4637e3d74329Smrg staticdest=$destfile 463842a55b46Smrg destfile= 463942a55b46Smrg ;; 464042a55b46Smrg *) 4641e3d74329Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4642c582b7e3Smrg ;; 4643c582b7e3Smrg esac 4644c582b7e3Smrg 464542a55b46Smrg # Install the libtool object if requested. 464642a55b46Smrg test -n "$destfile" && \ 464742a55b46Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4648c582b7e3Smrg 464942a55b46Smrg # Install the old object if enabled. 4650e3d74329Smrg if test yes = "$build_old_libs"; then 465142a55b46Smrg # Deduce the name of the old-style object file. 465242a55b46Smrg func_lo2o "$file" 465342a55b46Smrg staticobj=$func_lo2o_result 465442a55b46Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 465542a55b46Smrg fi 465642a55b46Smrg exit $EXIT_SUCCESS 465742a55b46Smrg ;; 4658c582b7e3Smrg 465942a55b46Smrg *) 466042a55b46Smrg # Figure out destination file name, if it wasn't already specified. 466142a55b46Smrg if test -n "$destname"; then 4662e3d74329Smrg destfile=$destdir/$destname 466342a55b46Smrg else 466442a55b46Smrg func_basename "$file" 4665e3d74329Smrg destfile=$func_basename_result 4666e3d74329Smrg destfile=$destdir/$destfile 466742a55b46Smrg fi 4668c582b7e3Smrg 466942a55b46Smrg # If the file is missing, and there is a .exe on the end, strip it 467042a55b46Smrg # because it is most likely a libtool script we actually want to 467142a55b46Smrg # install 4672e3d74329Smrg stripped_ext= 467342a55b46Smrg case $file in 467442a55b46Smrg *.exe) 467542a55b46Smrg if test ! -f "$file"; then 467642a55b46Smrg func_stripname '' '.exe' "$file" 467742a55b46Smrg file=$func_stripname_result 4678e3d74329Smrg stripped_ext=.exe 467942a55b46Smrg fi 468042a55b46Smrg ;; 468142a55b46Smrg esac 4682c582b7e3Smrg 468342a55b46Smrg # Do a test to see if this is really a libtool program. 468442a55b46Smrg case $host in 468542a55b46Smrg *cygwin* | *mingw*) 468642a55b46Smrg if func_ltwrapper_executable_p "$file"; then 468742a55b46Smrg func_ltwrapper_scriptname "$file" 468842a55b46Smrg wrapper=$func_ltwrapper_scriptname_result 468942a55b46Smrg else 469042a55b46Smrg func_stripname '' '.exe' "$file" 469142a55b46Smrg wrapper=$func_stripname_result 469242a55b46Smrg fi 469342a55b46Smrg ;; 469442a55b46Smrg *) 469542a55b46Smrg wrapper=$file 469642a55b46Smrg ;; 469742a55b46Smrg esac 469842a55b46Smrg if func_ltwrapper_script_p "$wrapper"; then 469942a55b46Smrg notinst_deplibs= 470042a55b46Smrg relink_command= 4701c582b7e3Smrg 470242a55b46Smrg func_source "$wrapper" 4703c582b7e3Smrg 470442a55b46Smrg # Check the variables that should have been set. 470542a55b46Smrg test -z "$generated_by_libtool_version" && \ 4706e3d74329Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4707c582b7e3Smrg 4708e3d74329Smrg finalize=: 470942a55b46Smrg for lib in $notinst_deplibs; do 471042a55b46Smrg # Check to see that each library is installed. 471142a55b46Smrg libdir= 471242a55b46Smrg if test -f "$lib"; then 471342a55b46Smrg func_source "$lib" 471442a55b46Smrg fi 4715e3d74329Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 471642a55b46Smrg if test -n "$libdir" && test ! -f "$libfile"; then 4717e3d74329Smrg func_warning "'$lib' has not been installed in '$libdir'" 4718e3d74329Smrg finalize=false 471942a55b46Smrg fi 472042a55b46Smrg done 4721c582b7e3Smrg 472242a55b46Smrg relink_command= 472342a55b46Smrg func_source "$wrapper" 472442a55b46Smrg 472542a55b46Smrg outputname= 4726e3d74329Smrg if test no = "$fast_install" && test -n "$relink_command"; then 472742a55b46Smrg $opt_dry_run || { 4728e3d74329Smrg if $finalize; then 472942a55b46Smrg tmpdir=`func_mktempdir` 473042a55b46Smrg func_basename "$file$stripped_ext" 4731e3d74329Smrg file=$func_basename_result 4732e3d74329Smrg outputname=$tmpdir/$file 473342a55b46Smrg # Replace the output file specification. 473442a55b46Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 473542a55b46Smrg 4736e3d74329Smrg $opt_quiet || { 47378ce07328Smrg func_quote_arg expand,pretty "$relink_command" 47388ce07328Smrg eval "func_echo $func_quote_arg_result" 473942a55b46Smrg } 474042a55b46Smrg if eval "$relink_command"; then : 474142a55b46Smrg else 4742e3d74329Smrg func_error "error: relink '$file' with the above command before installing it" 474342a55b46Smrg $opt_dry_run || ${RM}r "$tmpdir" 474442a55b46Smrg continue 474542a55b46Smrg fi 4746e3d74329Smrg file=$outputname 474742a55b46Smrg else 4748e3d74329Smrg func_warning "cannot relink '$file'" 474942a55b46Smrg fi 475042a55b46Smrg } 475142a55b46Smrg else 475242a55b46Smrg # Install the binary that we compiled earlier. 475342a55b46Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 475442a55b46Smrg fi 4755c582b7e3Smrg fi 475642a55b46Smrg 475742a55b46Smrg # remove .exe since cygwin /usr/bin/install will append another 475842a55b46Smrg # one anyway 475942a55b46Smrg case $install_prog,$host in 476042a55b46Smrg */usr/bin/install*,*cygwin*) 476142a55b46Smrg case $file:$destfile in 476242a55b46Smrg *.exe:*.exe) 476342a55b46Smrg # this is ok 476442a55b46Smrg ;; 476542a55b46Smrg *.exe:*) 476642a55b46Smrg destfile=$destfile.exe 476742a55b46Smrg ;; 476842a55b46Smrg *:*.exe) 476942a55b46Smrg func_stripname '' '.exe' "$destfile" 477042a55b46Smrg destfile=$func_stripname_result 477142a55b46Smrg ;; 477242a55b46Smrg esac 477342a55b46Smrg ;; 477442a55b46Smrg esac 477542a55b46Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 477642a55b46Smrg $opt_dry_run || if test -n "$outputname"; then 477742a55b46Smrg ${RM}r "$tmpdir" 4778c582b7e3Smrg fi 4779c582b7e3Smrg ;; 4780c582b7e3Smrg esac 478142a55b46Smrg done 4782c582b7e3Smrg 478342a55b46Smrg for file in $staticlibs; do 478442a55b46Smrg func_basename "$file" 4785e3d74329Smrg name=$func_basename_result 4786c582b7e3Smrg 478742a55b46Smrg # Set up the ranlib parameters. 4788e3d74329Smrg oldlib=$destdir/$name 478942a55b46Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 479042a55b46Smrg tool_oldlib=$func_to_tool_file_result 4791c582b7e3Smrg 479242a55b46Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 479342a55b46Smrg 479442a55b46Smrg if test -n "$stripme" && test -n "$old_striplib"; then 479542a55b46Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4796c582b7e3Smrg fi 4797c582b7e3Smrg 479842a55b46Smrg # Do each command in the postinstall commands. 479942a55b46Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 480042a55b46Smrg done 4801c582b7e3Smrg 480242a55b46Smrg test -n "$future_libdirs" && \ 4803e3d74329Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 4804c582b7e3Smrg 480542a55b46Smrg if test -n "$current_libdirs"; then 480642a55b46Smrg # Maybe just do a dry run. 480742a55b46Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 4808e3d74329Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 480942a55b46Smrg else 481042a55b46Smrg exit $EXIT_SUCCESS 481142a55b46Smrg fi 481242a55b46Smrg} 4813c582b7e3Smrg 4814e3d74329Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4815c582b7e3Smrg 4816c582b7e3Smrg 481742a55b46Smrg# func_generate_dlsyms outputname originator pic_p 481842a55b46Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 481942a55b46Smrg# a dlpreopen symbol table. 482042a55b46Smrgfunc_generate_dlsyms () 482142a55b46Smrg{ 4822e3d74329Smrg $debug_cmd 4823e3d74329Smrg 4824e3d74329Smrg my_outputname=$1 4825e3d74329Smrg my_originator=$2 4826e3d74329Smrg my_pic_p=${3-false} 4827e3d74329Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 482842a55b46Smrg my_dlsyms= 482942a55b46Smrg 4830e3d74329Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 483142a55b46Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4832e3d74329Smrg my_dlsyms=${my_outputname}S.c 483342a55b46Smrg else 483442a55b46Smrg func_error "not configured to extract global symbols from dlpreopened files" 483542a55b46Smrg fi 483642a55b46Smrg fi 4837c582b7e3Smrg 483842a55b46Smrg if test -n "$my_dlsyms"; then 483942a55b46Smrg case $my_dlsyms in 484042a55b46Smrg "") ;; 484142a55b46Smrg *.c) 484242a55b46Smrg # Discover the nlist of each of the dlfiles. 4843e3d74329Smrg nlist=$output_objdir/$my_outputname.nm 4844c582b7e3Smrg 484542a55b46Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4846c582b7e3Smrg 484742a55b46Smrg # Parse the name list into a source file. 484842a55b46Smrg func_verbose "creating $output_objdir/$my_dlsyms" 4849c582b7e3Smrg 485042a55b46Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4851e3d74329Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4852e3d74329Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4853c582b7e3Smrg 485442a55b46Smrg#ifdef __cplusplus 485542a55b46Smrgextern \"C\" { 485642a55b46Smrg#endif 4857c582b7e3Smrg 4858e3d74329Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 485942a55b46Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 486042a55b46Smrg#endif 4861c582b7e3Smrg 486242a55b46Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4863e3d74329Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4864e3d74329Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 486542a55b46Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 486642a55b46Smrg# define LT_DLSYM_CONST 4867e3d74329Smrg#elif defined __osf__ 486842a55b46Smrg/* This system does not cope well with relocations in const data. */ 486942a55b46Smrg# define LT_DLSYM_CONST 487042a55b46Smrg#else 487142a55b46Smrg# define LT_DLSYM_CONST const 487242a55b46Smrg#endif 4873c582b7e3Smrg 4874e3d74329Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4875e3d74329Smrg 487642a55b46Smrg/* External symbol declarations for the compiler. */\ 487742a55b46Smrg" 4878c582b7e3Smrg 4879e3d74329Smrg if test yes = "$dlself"; then 4880e3d74329Smrg func_verbose "generating symbol list for '$output'" 4881c582b7e3Smrg 488242a55b46Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4883c582b7e3Smrg 488442a55b46Smrg # Add our own program objects to the symbol list. 488542a55b46Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 488642a55b46Smrg for progfile in $progfiles; do 488742a55b46Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4888e3d74329Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 488942a55b46Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4890c582b7e3Smrg done 4891c582b7e3Smrg 489242a55b46Smrg if test -n "$exclude_expsyms"; then 489342a55b46Smrg $opt_dry_run || { 489442a55b46Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 489542a55b46Smrg eval '$MV "$nlist"T "$nlist"' 489642a55b46Smrg } 489742a55b46Smrg fi 4898c582b7e3Smrg 489942a55b46Smrg if test -n "$export_symbols_regex"; then 490042a55b46Smrg $opt_dry_run || { 490142a55b46Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 490242a55b46Smrg eval '$MV "$nlist"T "$nlist"' 490342a55b46Smrg } 490442a55b46Smrg fi 4905c582b7e3Smrg 490642a55b46Smrg # Prepare the list of exported symbols 490742a55b46Smrg if test -z "$export_symbols"; then 4908e3d74329Smrg export_symbols=$output_objdir/$outputname.exp 490942a55b46Smrg $opt_dry_run || { 491042a55b46Smrg $RM $export_symbols 4911e3d74329Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 491242a55b46Smrg case $host in 491342a55b46Smrg *cygwin* | *mingw* | *cegcc* ) 491442a55b46Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 491542a55b46Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 491642a55b46Smrg ;; 491742a55b46Smrg esac 491842a55b46Smrg } 491942a55b46Smrg else 492042a55b46Smrg $opt_dry_run || { 4921e3d74329Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 492242a55b46Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 492342a55b46Smrg eval '$MV "$nlist"T "$nlist"' 492442a55b46Smrg case $host in 492542a55b46Smrg *cygwin* | *mingw* | *cegcc* ) 492642a55b46Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 492742a55b46Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 492842a55b46Smrg ;; 492942a55b46Smrg esac 493042a55b46Smrg } 493142a55b46Smrg fi 493242a55b46Smrg fi 4933c582b7e3Smrg 493442a55b46Smrg for dlprefile in $dlprefiles; do 4935e3d74329Smrg func_verbose "extracting global C symbols from '$dlprefile'" 493642a55b46Smrg func_basename "$dlprefile" 4937e3d74329Smrg name=$func_basename_result 493842a55b46Smrg case $host in 493942a55b46Smrg *cygwin* | *mingw* | *cegcc* ) 494042a55b46Smrg # if an import library, we need to obtain dlname 494142a55b46Smrg if func_win32_import_lib_p "$dlprefile"; then 494242a55b46Smrg func_tr_sh "$dlprefile" 494342a55b46Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 4944e3d74329Smrg dlprefile_dlbasename= 494542a55b46Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 494642a55b46Smrg # Use subshell, to avoid clobbering current variable values 494742a55b46Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4948e3d74329Smrg if test -n "$dlprefile_dlname"; then 494942a55b46Smrg func_basename "$dlprefile_dlname" 4950e3d74329Smrg dlprefile_dlbasename=$func_basename_result 495142a55b46Smrg else 495242a55b46Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 495342a55b46Smrg $sharedlib_from_linklib_cmd "$dlprefile" 495442a55b46Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 495542a55b46Smrg fi 495642a55b46Smrg fi 495742a55b46Smrg $opt_dry_run || { 4958e3d74329Smrg if test -n "$dlprefile_dlbasename"; then 495942a55b46Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 496042a55b46Smrg else 496142a55b46Smrg func_warning "Could not compute DLL name from $name" 496242a55b46Smrg eval '$ECHO ": $name " >> "$nlist"' 496342a55b46Smrg fi 496442a55b46Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 496542a55b46Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 496642a55b46Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 496742a55b46Smrg } 496842a55b46Smrg else # not an import lib 496942a55b46Smrg $opt_dry_run || { 497042a55b46Smrg eval '$ECHO ": $name " >> "$nlist"' 497142a55b46Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 497242a55b46Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 497342a55b46Smrg } 497442a55b46Smrg fi 497542a55b46Smrg ;; 497642a55b46Smrg *) 497742a55b46Smrg $opt_dry_run || { 497842a55b46Smrg eval '$ECHO ": $name " >> "$nlist"' 497942a55b46Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 498042a55b46Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 498142a55b46Smrg } 498242a55b46Smrg ;; 498342a55b46Smrg esac 498442a55b46Smrg done 4985c582b7e3Smrg 498642a55b46Smrg $opt_dry_run || { 498742a55b46Smrg # Make sure we have at least an empty file. 498842a55b46Smrg test -f "$nlist" || : > "$nlist" 4989c582b7e3Smrg 499042a55b46Smrg if test -n "$exclude_expsyms"; then 499142a55b46Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 499242a55b46Smrg $MV "$nlist"T "$nlist" 499342a55b46Smrg fi 4994c582b7e3Smrg 499542a55b46Smrg # Try sorting and uniquifying the output. 499642a55b46Smrg if $GREP -v "^: " < "$nlist" | 499742a55b46Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 499842a55b46Smrg sort -k 3 499942a55b46Smrg else 500042a55b46Smrg sort +2 500142a55b46Smrg fi | 500242a55b46Smrg uniq > "$nlist"S; then 500342a55b46Smrg : 500442a55b46Smrg else 500542a55b46Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 500642a55b46Smrg fi 5007c582b7e3Smrg 500842a55b46Smrg if test -f "$nlist"S; then 500942a55b46Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 501042a55b46Smrg else 501142a55b46Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 501242a55b46Smrg fi 5013c582b7e3Smrg 5014e3d74329Smrg func_show_eval '$RM "${nlist}I"' 5015e3d74329Smrg if test -n "$global_symbol_to_import"; then 5016e3d74329Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 5017e3d74329Smrg fi 5018e3d74329Smrg 501942a55b46Smrg echo >> "$output_objdir/$my_dlsyms" "\ 502042a55b46Smrg 502142a55b46Smrg/* The mapping between symbol names and symbols. */ 502242a55b46Smrgtypedef struct { 502342a55b46Smrg const char *name; 502442a55b46Smrg void *address; 502542a55b46Smrg} lt_dlsymlist; 502642a55b46Smrgextern LT_DLSYM_CONST lt_dlsymlist 5027e3d74329Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 5028e3d74329Smrg" 5029e3d74329Smrg 5030e3d74329Smrg if test -s "$nlist"I; then 5031e3d74329Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5032e3d74329Smrgstatic void lt_syminit(void) 5033e3d74329Smrg{ 5034e3d74329Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 5035e3d74329Smrg for (; symbol->name; ++symbol) 5036e3d74329Smrg {" 5037e3d74329Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 5038e3d74329Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5039e3d74329Smrg } 5040e3d74329Smrg}" 5041e3d74329Smrg fi 5042e3d74329Smrg echo >> "$output_objdir/$my_dlsyms" "\ 504342a55b46SmrgLT_DLSYM_CONST lt_dlsymlist 504442a55b46Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 5045e3d74329Smrg{ {\"$my_originator\", (void *) 0}," 5046e3d74329Smrg 5047e3d74329Smrg if test -s "$nlist"I; then 5048e3d74329Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5049e3d74329Smrg {\"@INIT@\", (void *) <_syminit}," 5050e3d74329Smrg fi 505142a55b46Smrg 505242a55b46Smrg case $need_lib_prefix in 505342a55b46Smrg no) 505442a55b46Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 5055c582b7e3Smrg ;; 5056c582b7e3Smrg *) 505742a55b46Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 5058c582b7e3Smrg ;; 5059c582b7e3Smrg esac 506042a55b46Smrg echo >> "$output_objdir/$my_dlsyms" "\ 506142a55b46Smrg {0, (void *) 0} 506242a55b46Smrg}; 5063c582b7e3Smrg 506442a55b46Smrg/* This works around a problem in FreeBSD linker */ 506542a55b46Smrg#ifdef FREEBSD_WORKAROUND 506642a55b46Smrgstatic const void *lt_preloaded_setup() { 506742a55b46Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 506842a55b46Smrg} 506942a55b46Smrg#endif 5070c582b7e3Smrg 507142a55b46Smrg#ifdef __cplusplus 507242a55b46Smrg} 507342a55b46Smrg#endif\ 507442a55b46Smrg" 507542a55b46Smrg } # !$opt_dry_run 5076c582b7e3Smrg 507742a55b46Smrg pic_flag_for_symtable= 507842a55b46Smrg case "$compile_command " in 507942a55b46Smrg *" -static "*) ;; 508042a55b46Smrg *) 508142a55b46Smrg case $host in 508242a55b46Smrg # compiling the symbol table file with pic_flag works around 508342a55b46Smrg # a FreeBSD bug that causes programs to crash when -lm is 508442a55b46Smrg # linked before any other PIC object. But we must not use 508542a55b46Smrg # pic_flag when linking with -static. The problem exists in 508642a55b46Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 508742a55b46Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 508842a55b46Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 508942a55b46Smrg *-*-hpux*) 509042a55b46Smrg pic_flag_for_symtable=" $pic_flag" ;; 509142a55b46Smrg *) 5092e3d74329Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 509342a55b46Smrg ;; 509442a55b46Smrg esac 509542a55b46Smrg ;; 509642a55b46Smrg esac 509742a55b46Smrg symtab_cflags= 509842a55b46Smrg for arg in $LTCFLAGS; do 509942a55b46Smrg case $arg in 510042a55b46Smrg -pie | -fpie | -fPIE) ;; 510142a55b46Smrg *) func_append symtab_cflags " $arg" ;; 5102c582b7e3Smrg esac 5103c582b7e3Smrg done 5104c582b7e3Smrg 510542a55b46Smrg # Now compile the dynamic symbol file. 510642a55b46Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 5107c582b7e3Smrg 510842a55b46Smrg # Clean up the generated files. 5109e3d74329Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 5110c582b7e3Smrg 511142a55b46Smrg # Transform the symbol file into the correct name. 5112e3d74329Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 511342a55b46Smrg case $host in 511442a55b46Smrg *cygwin* | *mingw* | *cegcc* ) 511542a55b46Smrg if test -f "$output_objdir/$my_outputname.def"; then 511642a55b46Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 511742a55b46Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 511842a55b46Smrg else 511942a55b46Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512042a55b46Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512142a55b46Smrg fi 512242a55b46Smrg ;; 512342a55b46Smrg *) 512442a55b46Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512542a55b46Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512642a55b46Smrg ;; 512742a55b46Smrg esac 512842a55b46Smrg ;; 512942a55b46Smrg *) 5130e3d74329Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 513142a55b46Smrg ;; 513242a55b46Smrg esac 513342a55b46Smrg else 513442a55b46Smrg # We keep going just in case the user didn't refer to 513542a55b46Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 513642a55b46Smrg # really was required. 5137c582b7e3Smrg 513842a55b46Smrg # Nullify the symbol file. 513942a55b46Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 514042a55b46Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 514142a55b46Smrg fi 514242a55b46Smrg} 5143c582b7e3Smrg 5144e3d74329Smrg# func_cygming_gnu_implib_p ARG 5145e3d74329Smrg# This predicate returns with zero status (TRUE) if 5146e3d74329Smrg# ARG is a GNU/binutils-style import library. Returns 5147e3d74329Smrg# with nonzero status (FALSE) otherwise. 5148e3d74329Smrgfunc_cygming_gnu_implib_p () 5149e3d74329Smrg{ 5150e3d74329Smrg $debug_cmd 5151e3d74329Smrg 5152e3d74329Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5153e3d74329Smrg 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)$'` 5154e3d74329Smrg test -n "$func_cygming_gnu_implib_tmp" 5155e3d74329Smrg} 5156e3d74329Smrg 5157e3d74329Smrg# func_cygming_ms_implib_p ARG 5158e3d74329Smrg# This predicate returns with zero status (TRUE) if 5159e3d74329Smrg# ARG is an MS-style import library. Returns 5160e3d74329Smrg# with nonzero status (FALSE) otherwise. 5161e3d74329Smrgfunc_cygming_ms_implib_p () 5162e3d74329Smrg{ 5163e3d74329Smrg $debug_cmd 5164e3d74329Smrg 5165e3d74329Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5166e3d74329Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 5167e3d74329Smrg test -n "$func_cygming_ms_implib_tmp" 5168e3d74329Smrg} 5169e3d74329Smrg 517042a55b46Smrg# func_win32_libid arg 517142a55b46Smrg# return the library type of file 'arg' 517242a55b46Smrg# 517342a55b46Smrg# Need a lot of goo to handle *both* DLLs and import libs 517442a55b46Smrg# Has to be a shell function in order to 'eat' the argument 517542a55b46Smrg# that is supplied when $file_magic_command is called. 517642a55b46Smrg# Despite the name, also deal with 64 bit binaries. 517742a55b46Smrgfunc_win32_libid () 517842a55b46Smrg{ 5179e3d74329Smrg $debug_cmd 5180e3d74329Smrg 5181e3d74329Smrg win32_libid_type=unknown 518242a55b46Smrg win32_fileres=`file -L $1 2>/dev/null` 518342a55b46Smrg case $win32_fileres in 518442a55b46Smrg *ar\ archive\ import\ library*) # definitely import 518542a55b46Smrg win32_libid_type="x86 archive import" 518642a55b46Smrg ;; 518742a55b46Smrg *ar\ archive*) # could be an import, or static 518842a55b46Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 518942a55b46Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 519042a55b46Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 5191e3d74329Smrg case $nm_interface in 5192e3d74329Smrg "MS dumpbin") 5193e3d74329Smrg if func_cygming_ms_implib_p "$1" || 5194e3d74329Smrg func_cygming_gnu_implib_p "$1" 5195e3d74329Smrg then 5196e3d74329Smrg win32_nmres=import 5197e3d74329Smrg else 5198e3d74329Smrg win32_nmres= 5199e3d74329Smrg fi 5200e3d74329Smrg ;; 5201e3d74329Smrg *) 5202e3d74329Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5203e3d74329Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 5204e3d74329Smrg $SED -n -e ' 520542a55b46Smrg 1,100{ 520642a55b46Smrg / I /{ 5207e3d74329Smrg s|.*|import| 520842a55b46Smrg p 520942a55b46Smrg q 521042a55b46Smrg } 521142a55b46Smrg }'` 5212e3d74329Smrg ;; 5213e3d74329Smrg esac 521442a55b46Smrg case $win32_nmres in 521542a55b46Smrg import*) win32_libid_type="x86 archive import";; 521642a55b46Smrg *) win32_libid_type="x86 archive static";; 521742a55b46Smrg esac 521842a55b46Smrg fi 521942a55b46Smrg ;; 522042a55b46Smrg *DLL*) 522142a55b46Smrg win32_libid_type="x86 DLL" 522242a55b46Smrg ;; 522342a55b46Smrg *executable*) # but shell scripts are "executable" too... 522442a55b46Smrg case $win32_fileres in 522542a55b46Smrg *MS\ Windows\ PE\ Intel*) 522642a55b46Smrg win32_libid_type="x86 DLL" 522742a55b46Smrg ;; 522842a55b46Smrg esac 522942a55b46Smrg ;; 523042a55b46Smrg esac 523142a55b46Smrg $ECHO "$win32_libid_type" 523242a55b46Smrg} 523342a55b46Smrg 523442a55b46Smrg# func_cygming_dll_for_implib ARG 523542a55b46Smrg# 523642a55b46Smrg# Platform-specific function to extract the 523742a55b46Smrg# name of the DLL associated with the specified 523842a55b46Smrg# import library ARG. 523942a55b46Smrg# Invoked by eval'ing the libtool variable 524042a55b46Smrg# $sharedlib_from_linklib_cmd 524142a55b46Smrg# Result is available in the variable 524242a55b46Smrg# $sharedlib_from_linklib_result 524342a55b46Smrgfunc_cygming_dll_for_implib () 524442a55b46Smrg{ 5245e3d74329Smrg $debug_cmd 5246e3d74329Smrg 524742a55b46Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 524842a55b46Smrg} 524942a55b46Smrg 525042a55b46Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 525142a55b46Smrg# 525242a55b46Smrg# The is the core of a fallback implementation of a 525342a55b46Smrg# platform-specific function to extract the name of the 525442a55b46Smrg# DLL associated with the specified import library LIBNAME. 525542a55b46Smrg# 525642a55b46Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 525742a55b46Smrg# on the platform and compiler that created the implib. 525842a55b46Smrg# 525942a55b46Smrg# Echos the name of the DLL associated with the 526042a55b46Smrg# specified import library. 526142a55b46Smrgfunc_cygming_dll_for_implib_fallback_core () 526242a55b46Smrg{ 5263e3d74329Smrg $debug_cmd 5264e3d74329Smrg 526542a55b46Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 526642a55b46Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 526742a55b46Smrg $SED '/^Contents of section '"$match_literal"':/{ 526842a55b46Smrg # Place marker at beginning of archive member dllname section 526942a55b46Smrg s/.*/====MARK====/ 527042a55b46Smrg p 527142a55b46Smrg d 527242a55b46Smrg } 527342a55b46Smrg # These lines can sometimes be longer than 43 characters, but 527442a55b46Smrg # are always uninteresting 527542a55b46Smrg /:[ ]*file format pe[i]\{,1\}-/d 527642a55b46Smrg /^In archive [^:]*:/d 527742a55b46Smrg # Ensure marker is printed 527842a55b46Smrg /^====MARK====/p 527942a55b46Smrg # Remove all lines with less than 43 characters 528042a55b46Smrg /^.\{43\}/!d 528142a55b46Smrg # From remaining lines, remove first 43 characters 528242a55b46Smrg s/^.\{43\}//' | 528342a55b46Smrg $SED -n ' 528442a55b46Smrg # Join marker and all lines until next marker into a single line 528542a55b46Smrg /^====MARK====/ b para 528642a55b46Smrg H 528742a55b46Smrg $ b para 528842a55b46Smrg b 528942a55b46Smrg :para 529042a55b46Smrg x 529142a55b46Smrg s/\n//g 529242a55b46Smrg # Remove the marker 529342a55b46Smrg s/^====MARK====// 529442a55b46Smrg # Remove trailing dots and whitespace 529542a55b46Smrg s/[\. \t]*$// 529642a55b46Smrg # Print 529742a55b46Smrg /./p' | 529842a55b46Smrg # we now have a list, one entry per line, of the stringified 529942a55b46Smrg # contents of the appropriate section of all members of the 5300e3d74329Smrg # archive that possess that section. Heuristic: eliminate 5301e3d74329Smrg # all those that have a first or second character that is 530242a55b46Smrg # a '.' (that is, objdump's representation of an unprintable 530342a55b46Smrg # character.) This should work for all archives with less than 530442a55b46Smrg # 0x302f exports -- but will fail for DLLs whose name actually 530542a55b46Smrg # begins with a literal '.' or a single character followed by 530642a55b46Smrg # a '.'. 530742a55b46Smrg # 530842a55b46Smrg # Of those that remain, print the first one. 530942a55b46Smrg $SED -e '/^\./d;/^.\./d;q' 531042a55b46Smrg} 531142a55b46Smrg 531242a55b46Smrg# func_cygming_dll_for_implib_fallback ARG 531342a55b46Smrg# Platform-specific function to extract the 531442a55b46Smrg# name of the DLL associated with the specified 531542a55b46Smrg# import library ARG. 531642a55b46Smrg# 531742a55b46Smrg# This fallback implementation is for use when $DLLTOOL 531842a55b46Smrg# does not support the --identify-strict option. 531942a55b46Smrg# Invoked by eval'ing the libtool variable 532042a55b46Smrg# $sharedlib_from_linklib_cmd 532142a55b46Smrg# Result is available in the variable 532242a55b46Smrg# $sharedlib_from_linklib_result 532342a55b46Smrgfunc_cygming_dll_for_implib_fallback () 532442a55b46Smrg{ 5325e3d74329Smrg $debug_cmd 5326e3d74329Smrg 5327e3d74329Smrg if func_cygming_gnu_implib_p "$1"; then 532842a55b46Smrg # binutils import library 532942a55b46Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5330e3d74329Smrg elif func_cygming_ms_implib_p "$1"; then 533142a55b46Smrg # ms-generated import library 533242a55b46Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 533342a55b46Smrg else 533442a55b46Smrg # unknown 5335e3d74329Smrg sharedlib_from_linklib_result= 533642a55b46Smrg fi 533742a55b46Smrg} 533842a55b46Smrg 533942a55b46Smrg 534042a55b46Smrg# func_extract_an_archive dir oldlib 534142a55b46Smrgfunc_extract_an_archive () 534242a55b46Smrg{ 5343e3d74329Smrg $debug_cmd 5344e3d74329Smrg 5345e3d74329Smrg f_ex_an_ar_dir=$1; shift 5346e3d74329Smrg f_ex_an_ar_oldlib=$1 5347e3d74329Smrg if test yes = "$lock_old_archive_extraction"; then 534842a55b46Smrg lockfile=$f_ex_an_ar_oldlib.lock 534942a55b46Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 535042a55b46Smrg func_echo "Waiting for $lockfile to be removed" 535142a55b46Smrg sleep 2 5352c582b7e3Smrg done 535342a55b46Smrg fi 535442a55b46Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 535542a55b46Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 5356e3d74329Smrg if test yes = "$lock_old_archive_extraction"; then 535742a55b46Smrg $opt_dry_run || rm -f "$lockfile" 535842a55b46Smrg fi 535942a55b46Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 536042a55b46Smrg : 536142a55b46Smrg else 536242a55b46Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 536342a55b46Smrg fi 536442a55b46Smrg} 5365c582b7e3Smrg 536642a55b46Smrg 536742a55b46Smrg# func_extract_archives gentop oldlib ... 536842a55b46Smrgfunc_extract_archives () 536942a55b46Smrg{ 5370e3d74329Smrg $debug_cmd 5371e3d74329Smrg 5372e3d74329Smrg my_gentop=$1; shift 537342a55b46Smrg my_oldlibs=${1+"$@"} 5374e3d74329Smrg my_oldobjs= 5375e3d74329Smrg my_xlib= 5376e3d74329Smrg my_xabs= 5377e3d74329Smrg my_xdir= 537842a55b46Smrg 537942a55b46Smrg for my_xlib in $my_oldlibs; do 538042a55b46Smrg # Extract the objects. 538142a55b46Smrg case $my_xlib in 5382e3d74329Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 538342a55b46Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 538442a55b46Smrg esac 538542a55b46Smrg func_basename "$my_xlib" 5386e3d74329Smrg my_xlib=$func_basename_result 538742a55b46Smrg my_xlib_u=$my_xlib 538842a55b46Smrg while :; do 538942a55b46Smrg case " $extracted_archives " in 539042a55b46Smrg *" $my_xlib_u "*) 539142a55b46Smrg func_arith $extracted_serial + 1 539242a55b46Smrg extracted_serial=$func_arith_result 539342a55b46Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 539442a55b46Smrg *) break ;; 5395c582b7e3Smrg esac 5396c582b7e3Smrg done 539742a55b46Smrg extracted_archives="$extracted_archives $my_xlib_u" 5398e3d74329Smrg my_xdir=$my_gentop/$my_xlib_u 5399c582b7e3Smrg 540042a55b46Smrg func_mkdir_p "$my_xdir" 5401c582b7e3Smrg 540242a55b46Smrg case $host in 540342a55b46Smrg *-darwin*) 540442a55b46Smrg func_verbose "Extracting $my_xabs" 540542a55b46Smrg # Do not bother doing anything if just a dry run 540642a55b46Smrg $opt_dry_run || { 540742a55b46Smrg darwin_orig_dir=`pwd` 540842a55b46Smrg cd $my_xdir || exit $? 540942a55b46Smrg darwin_archive=$my_xabs 541042a55b46Smrg darwin_curdir=`pwd` 5411e3d74329Smrg func_basename "$darwin_archive" 5412e3d74329Smrg darwin_base_archive=$func_basename_result 541342a55b46Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 541442a55b46Smrg if test -n "$darwin_arches"; then 541542a55b46Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 541642a55b46Smrg darwin_arch= 541742a55b46Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5418e3d74329Smrg for darwin_arch in $darwin_arches; do 5419e3d74329Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5420e3d74329Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5421e3d74329Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5422e3d74329Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 542342a55b46Smrg cd "$darwin_curdir" 5424e3d74329Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 542542a55b46Smrg done # $darwin_arches 542642a55b46Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5427e3d74329Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 542842a55b46Smrg darwin_file= 542942a55b46Smrg darwin_files= 543042a55b46Smrg for darwin_file in $darwin_filelist; do 543142a55b46Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 543242a55b46Smrg $LIPO -create -output "$darwin_file" $darwin_files 543342a55b46Smrg done # $darwin_filelist 543442a55b46Smrg $RM -rf unfat-$$ 543542a55b46Smrg cd "$darwin_orig_dir" 5436c582b7e3Smrg else 543742a55b46Smrg cd $darwin_orig_dir 543842a55b46Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 543942a55b46Smrg fi # $darwin_arches 544042a55b46Smrg } # !$opt_dry_run 544142a55b46Smrg ;; 544242a55b46Smrg *) 544342a55b46Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 544442a55b46Smrg ;; 544542a55b46Smrg esac 544642a55b46Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 544742a55b46Smrg done 5448c582b7e3Smrg 5449e3d74329Smrg func_extract_archives_result=$my_oldobjs 545042a55b46Smrg} 5451c582b7e3Smrg 5452c582b7e3Smrg 545342a55b46Smrg# func_emit_wrapper [arg=no] 545442a55b46Smrg# 545542a55b46Smrg# Emit a libtool wrapper script on stdout. 545642a55b46Smrg# Don't directly open a file because we may want to 545742a55b46Smrg# incorporate the script contents within a cygwin/mingw 545842a55b46Smrg# wrapper executable. Must ONLY be called from within 545942a55b46Smrg# func_mode_link because it depends on a number of variables 546042a55b46Smrg# set therein. 546142a55b46Smrg# 546242a55b46Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 546342a55b46Smrg# variable will take. If 'yes', then the emitted script 5464e3d74329Smrg# will assume that the directory where it is stored is 546542a55b46Smrg# the $objdir directory. This is a cygwin/mingw-specific 546642a55b46Smrg# behavior. 546742a55b46Smrgfunc_emit_wrapper () 546842a55b46Smrg{ 546942a55b46Smrg func_emit_wrapper_arg1=${1-no} 5470c582b7e3Smrg 547142a55b46Smrg $ECHO "\ 547242a55b46Smrg#! $SHELL 5473c582b7e3Smrg 547442a55b46Smrg# $output - temporary wrapper script for $objdir/$outputname 5475e3d74329Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 547642a55b46Smrg# 547742a55b46Smrg# The $output program cannot be directly executed until all the libtool 547842a55b46Smrg# libraries that it depends on are installed. 547942a55b46Smrg# 548042a55b46Smrg# This wrapper script should never be moved out of the build directory. 548142a55b46Smrg# If it is, it will not operate correctly. 5482c582b7e3Smrg 548342a55b46Smrg# Sed substitution that helps us do robust quoting. It backslashifies 548442a55b46Smrg# metacharacters that are still active within double-quoted strings. 548542a55b46Smrgsed_quote_subst='$sed_quote_subst' 5486c582b7e3Smrg 548742a55b46Smrg# Be Bourne compatible 548842a55b46Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 548942a55b46Smrg emulate sh 549042a55b46Smrg NULLCMD=: 549142a55b46Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 549242a55b46Smrg # is contrary to our usage. Disable this feature. 549342a55b46Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 549442a55b46Smrg setopt NO_GLOB_SUBST 549542a55b46Smrgelse 549642a55b46Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 549742a55b46Smrgfi 549842a55b46SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 549942a55b46SmrgDUALCASE=1; export DUALCASE # for MKS sh 5500c582b7e3Smrg 550142a55b46Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 550242a55b46Smrg# if CDPATH is set. 550342a55b46Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5504c582b7e3Smrg 550542a55b46Smrgrelink_command=\"$relink_command\" 5506c582b7e3Smrg 550742a55b46Smrg# This environment variable determines our operation mode. 550842a55b46Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 550942a55b46Smrg # install mode needs the following variables: 551042a55b46Smrg generated_by_libtool_version='$macro_version' 551142a55b46Smrg notinst_deplibs='$notinst_deplibs' 551242a55b46Smrgelse 551342a55b46Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 551442a55b46Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 551542a55b46Smrg file=\"\$0\"" 5516c582b7e3Smrg 55178ce07328Smrg func_quote_arg pretty "$ECHO" 55188ce07328Smrg qECHO=$func_quote_arg_result 551942a55b46Smrg $ECHO "\ 5520c582b7e3Smrg 552142a55b46Smrg# A function that is used when there is no print builtin or printf. 552242a55b46Smrgfunc_fallback_echo () 552342a55b46Smrg{ 552442a55b46Smrg eval 'cat <<_LTECHO_EOF 552542a55b46Smrg\$1 552642a55b46Smrg_LTECHO_EOF' 552742a55b46Smrg} 55288ce07328Smrg ECHO=$qECHO 552942a55b46Smrg fi 5530c582b7e3Smrg 553142a55b46Smrg# Very basic option parsing. These options are (a) specific to 553242a55b46Smrg# the libtool wrapper, (b) are identical between the wrapper 5533e3d74329Smrg# /script/ and the wrapper /executable/ that is used only on 553442a55b46Smrg# windows platforms, and (c) all begin with the string "--lt-" 5535e3d74329Smrg# (application programs are unlikely to have options that match 553642a55b46Smrg# this pattern). 553742a55b46Smrg# 553842a55b46Smrg# There are only two supported options: --lt-debug and 553942a55b46Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 554042a55b46Smrg# 554142a55b46Smrg# The first argument to this parsing function should be the 554242a55b46Smrg# script's $0 value, followed by "$@". 554342a55b46Smrglt_option_debug= 554442a55b46Smrgfunc_parse_lt_options () 554542a55b46Smrg{ 554642a55b46Smrg lt_script_arg0=\$0 554742a55b46Smrg shift 554842a55b46Smrg for lt_opt 554942a55b46Smrg do 555042a55b46Smrg case \"\$lt_opt\" in 555142a55b46Smrg --lt-debug) lt_option_debug=1 ;; 555242a55b46Smrg --lt-dump-script) 555342a55b46Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 555442a55b46Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 555542a55b46Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 555642a55b46Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 555742a55b46Smrg exit 0 555842a55b46Smrg ;; 555942a55b46Smrg --lt-*) 556042a55b46Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 556142a55b46Smrg exit 1 556242a55b46Smrg ;; 556342a55b46Smrg esac 556442a55b46Smrg done 5565c582b7e3Smrg 556642a55b46Smrg # Print the debug banner immediately: 556742a55b46Smrg if test -n \"\$lt_option_debug\"; then 5568e3d74329Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 556942a55b46Smrg fi 557042a55b46Smrg} 5571c582b7e3Smrg 557242a55b46Smrg# Used when --lt-debug. Prints its arguments to stdout 557342a55b46Smrg# (redirection is the responsibility of the caller) 557442a55b46Smrgfunc_lt_dump_args () 557542a55b46Smrg{ 557642a55b46Smrg lt_dump_args_N=1; 557742a55b46Smrg for lt_arg 557842a55b46Smrg do 5579e3d74329Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 558042a55b46Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 558142a55b46Smrg done 558242a55b46Smrg} 5583c582b7e3Smrg 558442a55b46Smrg# Core function for launching the target application 558542a55b46Smrgfunc_exec_program_core () 558642a55b46Smrg{ 558742a55b46Smrg" 558842a55b46Smrg case $host in 558942a55b46Smrg # Backslashes separate directories on plain windows 559042a55b46Smrg *-*-mingw | *-*-os2* | *-cegcc*) 559142a55b46Smrg $ECHO "\ 559242a55b46Smrg if test -n \"\$lt_option_debug\"; then 5593e3d74329Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 559442a55b46Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 559542a55b46Smrg fi 559642a55b46Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 559742a55b46Smrg" 559842a55b46Smrg ;; 5599c582b7e3Smrg 560042a55b46Smrg *) 560142a55b46Smrg $ECHO "\ 560242a55b46Smrg if test -n \"\$lt_option_debug\"; then 5603e3d74329Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 560442a55b46Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 560542a55b46Smrg fi 560642a55b46Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 560742a55b46Smrg" 560842a55b46Smrg ;; 560942a55b46Smrg esac 561042a55b46Smrg $ECHO "\ 561142a55b46Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 561242a55b46Smrg exit 1 561342a55b46Smrg} 5614c582b7e3Smrg 561542a55b46Smrg# A function to encapsulate launching the target application 561642a55b46Smrg# Strips options in the --lt-* namespace from \$@ and 561742a55b46Smrg# launches target application with the remaining arguments. 561842a55b46Smrgfunc_exec_program () 561942a55b46Smrg{ 562042a55b46Smrg case \" \$* \" in 562142a55b46Smrg *\\ --lt-*) 562242a55b46Smrg for lt_wr_arg 562342a55b46Smrg do 562442a55b46Smrg case \$lt_wr_arg in 562542a55b46Smrg --lt-*) ;; 562642a55b46Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 562742a55b46Smrg esac 562842a55b46Smrg shift 562942a55b46Smrg done ;; 563042a55b46Smrg esac 563142a55b46Smrg func_exec_program_core \${1+\"\$@\"} 563242a55b46Smrg} 5633c582b7e3Smrg 563442a55b46Smrg # Parse options 563542a55b46Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5636c582b7e3Smrg 563742a55b46Smrg # Find the directory that this script lives in. 563842a55b46Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 563942a55b46Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5640c582b7e3Smrg 564142a55b46Smrg # Follow symbolic links until we get to the real thisdir. 564242a55b46Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 564342a55b46Smrg while test -n \"\$file\"; do 564442a55b46Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5645c582b7e3Smrg 564642a55b46Smrg # If there was a directory component, then change thisdir. 564742a55b46Smrg if test \"x\$destdir\" != \"x\$file\"; then 564842a55b46Smrg case \"\$destdir\" in 564942a55b46Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 565042a55b46Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 565142a55b46Smrg esac 565242a55b46Smrg fi 5653c582b7e3Smrg 565442a55b46Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 565542a55b46Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 565642a55b46Smrg done 5657c582b7e3Smrg 565842a55b46Smrg # Usually 'no', except on cygwin/mingw when embedded into 565942a55b46Smrg # the cwrapper. 566042a55b46Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 566142a55b46Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 566242a55b46Smrg # special case for '.' 566342a55b46Smrg if test \"\$thisdir\" = \".\"; then 566442a55b46Smrg thisdir=\`pwd\` 566542a55b46Smrg fi 566642a55b46Smrg # remove .libs from thisdir 566742a55b46Smrg case \"\$thisdir\" in 566842a55b46Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 566942a55b46Smrg $objdir ) thisdir=. ;; 567042a55b46Smrg esac 567142a55b46Smrg fi 5672c582b7e3Smrg 567342a55b46Smrg # Try to get the absolute directory name. 567442a55b46Smrg absdir=\`cd \"\$thisdir\" && pwd\` 567542a55b46Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 567642a55b46Smrg" 5677c582b7e3Smrg 5678e3d74329Smrg if test yes = "$fast_install"; then 567942a55b46Smrg $ECHO "\ 568042a55b46Smrg program=lt-'$outputname'$exeext 568142a55b46Smrg progdir=\"\$thisdir/$objdir\" 5682c582b7e3Smrg 568342a55b46Smrg if test ! -f \"\$progdir/\$program\" || 5684e3d74329Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 568542a55b46Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5686c582b7e3Smrg 568742a55b46Smrg file=\"\$\$-\$program\" 5688c582b7e3Smrg 568942a55b46Smrg if test ! -d \"\$progdir\"; then 569042a55b46Smrg $MKDIR \"\$progdir\" 569142a55b46Smrg else 569242a55b46Smrg $RM \"\$progdir/\$file\" 569342a55b46Smrg fi" 5694c582b7e3Smrg 569542a55b46Smrg $ECHO "\ 5696c582b7e3Smrg 569742a55b46Smrg # relink executable if necessary 569842a55b46Smrg if test -n \"\$relink_command\"; then 569942a55b46Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 570042a55b46Smrg else 5701e3d74329Smrg \$ECHO \"\$relink_command_output\" >&2 570242a55b46Smrg $RM \"\$progdir/\$file\" 570342a55b46Smrg exit 1 570442a55b46Smrg fi 570542a55b46Smrg fi 5706c582b7e3Smrg 570742a55b46Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 570842a55b46Smrg { $RM \"\$progdir/\$program\"; 570942a55b46Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 571042a55b46Smrg $RM \"\$progdir/\$file\" 571142a55b46Smrg fi" 571242a55b46Smrg else 571342a55b46Smrg $ECHO "\ 571442a55b46Smrg program='$outputname' 571542a55b46Smrg progdir=\"\$thisdir/$objdir\" 571642a55b46Smrg" 571742a55b46Smrg fi 5718c582b7e3Smrg 571942a55b46Smrg $ECHO "\ 5720c582b7e3Smrg 572142a55b46Smrg if test -f \"\$progdir/\$program\"; then" 572242a55b46Smrg 572342a55b46Smrg # fixup the dll searchpath if we need to. 572442a55b46Smrg # 572542a55b46Smrg # Fix the DLL searchpath if we need to. Do this before prepending 572642a55b46Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 572742a55b46Smrg # libraries must come first. 572842a55b46Smrg if test -n "$dllsearchpath"; then 572942a55b46Smrg $ECHO "\ 573042a55b46Smrg # Add the dll search path components to the executable PATH 573142a55b46Smrg PATH=$dllsearchpath:\$PATH 573242a55b46Smrg" 5733c582b7e3Smrg fi 5734c582b7e3Smrg 573542a55b46Smrg # Export our shlibpath_var if we have one. 5736e3d74329Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 573742a55b46Smrg $ECHO "\ 573842a55b46Smrg # Add our own library path to $shlibpath_var 573942a55b46Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5740c582b7e3Smrg 574142a55b46Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 574242a55b46Smrg # The second colon is a workaround for a bug in BeOS R4 sed 574342a55b46Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 574442a55b46Smrg 574542a55b46Smrg export $shlibpath_var 574642a55b46Smrg" 5747c582b7e3Smrg fi 5748c582b7e3Smrg 574942a55b46Smrg $ECHO "\ 575042a55b46Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 575142a55b46Smrg # Run the actual program with our arguments. 575242a55b46Smrg func_exec_program \${1+\"\$@\"} 575342a55b46Smrg fi 575442a55b46Smrg else 575542a55b46Smrg # The program doesn't exist. 5756e3d74329Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 575742a55b46Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 575842a55b46Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 575942a55b46Smrg exit 1 576042a55b46Smrg fi 576142a55b46Smrgfi\ 576242a55b46Smrg" 576342a55b46Smrg} 5764c582b7e3Smrg 5765c582b7e3Smrg 576642a55b46Smrg# func_emit_cwrapperexe_src 576742a55b46Smrg# emit the source code for a wrapper executable on stdout 576842a55b46Smrg# Must ONLY be called from within func_mode_link because 576942a55b46Smrg# it depends on a number of variable set therein. 577042a55b46Smrgfunc_emit_cwrapperexe_src () 577142a55b46Smrg{ 577242a55b46Smrg cat <<EOF 5773c582b7e3Smrg 577442a55b46Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5775e3d74329Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5776c582b7e3Smrg 577742a55b46Smrg The $output program cannot be directly executed until all the libtool 577842a55b46Smrg libraries that it depends on are installed. 5779c582b7e3Smrg 578042a55b46Smrg This wrapper executable should never be moved out of the build directory. 578142a55b46Smrg If it is, it will not operate correctly. 578242a55b46Smrg*/ 578342a55b46SmrgEOF 578442a55b46Smrg cat <<"EOF" 578542a55b46Smrg#ifdef _MSC_VER 578642a55b46Smrg# define _CRT_SECURE_NO_DEPRECATE 1 578742a55b46Smrg#endif 578842a55b46Smrg#include <stdio.h> 578942a55b46Smrg#include <stdlib.h> 579042a55b46Smrg#ifdef _MSC_VER 579142a55b46Smrg# include <direct.h> 579242a55b46Smrg# include <process.h> 579342a55b46Smrg# include <io.h> 579442a55b46Smrg#else 579542a55b46Smrg# include <unistd.h> 579642a55b46Smrg# include <stdint.h> 579742a55b46Smrg# ifdef __CYGWIN__ 579842a55b46Smrg# include <io.h> 579942a55b46Smrg# endif 580042a55b46Smrg#endif 580142a55b46Smrg#include <malloc.h> 580242a55b46Smrg#include <stdarg.h> 580342a55b46Smrg#include <assert.h> 580442a55b46Smrg#include <string.h> 580542a55b46Smrg#include <ctype.h> 580642a55b46Smrg#include <errno.h> 580742a55b46Smrg#include <fcntl.h> 580842a55b46Smrg#include <sys/stat.h> 5809c582b7e3Smrg 5810e3d74329Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5811e3d74329Smrg 581242a55b46Smrg/* declarations of non-ANSI functions */ 5813e3d74329Smrg#if defined __MINGW32__ 581442a55b46Smrg# ifdef __STRICT_ANSI__ 581542a55b46Smrgint _putenv (const char *); 581642a55b46Smrg# endif 5817e3d74329Smrg#elif defined __CYGWIN__ 581842a55b46Smrg# ifdef __STRICT_ANSI__ 581942a55b46Smrgchar *realpath (const char *, char *); 582042a55b46Smrgint putenv (char *); 582142a55b46Smrgint setenv (const char *, const char *, int); 582242a55b46Smrg# endif 5823e3d74329Smrg/* #elif defined other_platform || defined ... */ 582442a55b46Smrg#endif 5825c582b7e3Smrg 582642a55b46Smrg/* portability defines, excluding path handling macros */ 5827e3d74329Smrg#if defined _MSC_VER 582842a55b46Smrg# define setmode _setmode 582942a55b46Smrg# define stat _stat 583042a55b46Smrg# define chmod _chmod 583142a55b46Smrg# define getcwd _getcwd 583242a55b46Smrg# define putenv _putenv 583342a55b46Smrg# define S_IXUSR _S_IEXEC 5834e3d74329Smrg#elif defined __MINGW32__ 583542a55b46Smrg# define setmode _setmode 583642a55b46Smrg# define stat _stat 583742a55b46Smrg# define chmod _chmod 583842a55b46Smrg# define getcwd _getcwd 583942a55b46Smrg# define putenv _putenv 5840e3d74329Smrg#elif defined __CYGWIN__ 584142a55b46Smrg# define HAVE_SETENV 584242a55b46Smrg# define FOPEN_WB "wb" 5843e3d74329Smrg/* #elif defined other platforms ... */ 584442a55b46Smrg#endif 5845c582b7e3Smrg 5846e3d74329Smrg#if defined PATH_MAX 584742a55b46Smrg# define LT_PATHMAX PATH_MAX 5848e3d74329Smrg#elif defined MAXPATHLEN 584942a55b46Smrg# define LT_PATHMAX MAXPATHLEN 585042a55b46Smrg#else 585142a55b46Smrg# define LT_PATHMAX 1024 585242a55b46Smrg#endif 5853c582b7e3Smrg 585442a55b46Smrg#ifndef S_IXOTH 585542a55b46Smrg# define S_IXOTH 0 585642a55b46Smrg#endif 585742a55b46Smrg#ifndef S_IXGRP 585842a55b46Smrg# define S_IXGRP 0 585942a55b46Smrg#endif 5860c582b7e3Smrg 586142a55b46Smrg/* path handling portability macros */ 586242a55b46Smrg#ifndef DIR_SEPARATOR 586342a55b46Smrg# define DIR_SEPARATOR '/' 586442a55b46Smrg# define PATH_SEPARATOR ':' 586542a55b46Smrg#endif 5866c582b7e3Smrg 5867e3d74329Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5868e3d74329Smrg defined __OS2__ 586942a55b46Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 587042a55b46Smrg# define FOPEN_WB "wb" 587142a55b46Smrg# ifndef DIR_SEPARATOR_2 587242a55b46Smrg# define DIR_SEPARATOR_2 '\\' 587342a55b46Smrg# endif 587442a55b46Smrg# ifndef PATH_SEPARATOR_2 587542a55b46Smrg# define PATH_SEPARATOR_2 ';' 587642a55b46Smrg# endif 587742a55b46Smrg#endif 5878c582b7e3Smrg 587942a55b46Smrg#ifndef DIR_SEPARATOR_2 588042a55b46Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 588142a55b46Smrg#else /* DIR_SEPARATOR_2 */ 588242a55b46Smrg# define IS_DIR_SEPARATOR(ch) \ 588342a55b46Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 588442a55b46Smrg#endif /* DIR_SEPARATOR_2 */ 5885c582b7e3Smrg 588642a55b46Smrg#ifndef PATH_SEPARATOR_2 588742a55b46Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 588842a55b46Smrg#else /* PATH_SEPARATOR_2 */ 588942a55b46Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 589042a55b46Smrg#endif /* PATH_SEPARATOR_2 */ 5891c582b7e3Smrg 589242a55b46Smrg#ifndef FOPEN_WB 589342a55b46Smrg# define FOPEN_WB "w" 589442a55b46Smrg#endif 589542a55b46Smrg#ifndef _O_BINARY 589642a55b46Smrg# define _O_BINARY 0 589742a55b46Smrg#endif 5898c582b7e3Smrg 589942a55b46Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 590042a55b46Smrg#define XFREE(stale) do { \ 5901e3d74329Smrg if (stale) { free (stale); stale = 0; } \ 590242a55b46Smrg} while (0) 5903c582b7e3Smrg 5904e3d74329Smrg#if defined LT_DEBUGWRAPPER 590542a55b46Smrgstatic int lt_debug = 1; 590642a55b46Smrg#else 590742a55b46Smrgstatic int lt_debug = 0; 590842a55b46Smrg#endif 5909c582b7e3Smrg 591042a55b46Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 591142a55b46Smrg 591242a55b46Smrgvoid *xmalloc (size_t num); 591342a55b46Smrgchar *xstrdup (const char *string); 591442a55b46Smrgconst char *base_name (const char *name); 591542a55b46Smrgchar *find_executable (const char *wrapper); 591642a55b46Smrgchar *chase_symlinks (const char *pathspec); 591742a55b46Smrgint make_executable (const char *path); 591842a55b46Smrgint check_executable (const char *path); 591942a55b46Smrgchar *strendzap (char *str, const char *pat); 592042a55b46Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 592142a55b46Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 592242a55b46Smrgstatic const char *nonnull (const char *s); 592342a55b46Smrgstatic const char *nonempty (const char *s); 592442a55b46Smrgvoid lt_setenv (const char *name, const char *value); 592542a55b46Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 592642a55b46Smrgvoid lt_update_exe_path (const char *name, const char *value); 592742a55b46Smrgvoid lt_update_lib_path (const char *name, const char *value); 592842a55b46Smrgchar **prepare_spawn (char **argv); 592942a55b46Smrgvoid lt_dump_script (FILE *f); 593042a55b46SmrgEOF 5931c582b7e3Smrg 593242a55b46Smrg cat <<EOF 5933e3d74329Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5934e3d74329Smrg# define externally_visible volatile 5935e3d74329Smrg#else 5936e3d74329Smrg# define externally_visible __attribute__((externally_visible)) volatile 5937e3d74329Smrg#endif 5938e3d74329Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 593942a55b46Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 594042a55b46SmrgEOF 5941c582b7e3Smrg 5942e3d74329Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 594342a55b46Smrg func_to_host_path "$temp_rpath" 594442a55b46Smrg cat <<EOF 594542a55b46Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 594642a55b46SmrgEOF 594742a55b46Smrg else 594842a55b46Smrg cat <<"EOF" 594942a55b46Smrgconst char * LIB_PATH_VALUE = ""; 595042a55b46SmrgEOF 595142a55b46Smrg fi 5952c582b7e3Smrg 595342a55b46Smrg if test -n "$dllsearchpath"; then 595442a55b46Smrg func_to_host_path "$dllsearchpath:" 595542a55b46Smrg cat <<EOF 595642a55b46Smrgconst char * EXE_PATH_VARNAME = "PATH"; 595742a55b46Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 595842a55b46SmrgEOF 595942a55b46Smrg else 596042a55b46Smrg cat <<"EOF" 596142a55b46Smrgconst char * EXE_PATH_VARNAME = ""; 596242a55b46Smrgconst char * EXE_PATH_VALUE = ""; 596342a55b46SmrgEOF 596442a55b46Smrg fi 5965c582b7e3Smrg 5966e3d74329Smrg if test yes = "$fast_install"; then 596742a55b46Smrg cat <<EOF 596842a55b46Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 596942a55b46SmrgEOF 597042a55b46Smrg else 597142a55b46Smrg cat <<EOF 597242a55b46Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 597342a55b46SmrgEOF 597442a55b46Smrg fi 5975c582b7e3Smrg 5976c582b7e3Smrg 597742a55b46Smrg cat <<"EOF" 5978c582b7e3Smrg 597942a55b46Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5980c582b7e3Smrg 598142a55b46Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 598242a55b46Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 598342a55b46Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5984c582b7e3Smrg 598542a55b46Smrgint 598642a55b46Smrgmain (int argc, char *argv[]) 598742a55b46Smrg{ 598842a55b46Smrg char **newargz; 598942a55b46Smrg int newargc; 599042a55b46Smrg char *tmp_pathspec; 599142a55b46Smrg char *actual_cwrapper_path; 599242a55b46Smrg char *actual_cwrapper_name; 599342a55b46Smrg char *target_name; 599442a55b46Smrg char *lt_argv_zero; 5995e3d74329Smrg int rval = 127; 599642a55b46Smrg 599742a55b46Smrg int i; 5998c582b7e3Smrg 599942a55b46Smrg program_name = (char *) xstrdup (base_name (argv[0])); 6000e3d74329Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 6001c582b7e3Smrg 600242a55b46Smrg /* very simple arg parsing; don't want to rely on getopt 600342a55b46Smrg * also, copy all non cwrapper options to newargz, except 600442a55b46Smrg * argz[0], which is handled differently 600542a55b46Smrg */ 600642a55b46Smrg newargc=0; 600742a55b46Smrg for (i = 1; i < argc; i++) 600842a55b46Smrg { 6009e3d74329Smrg if (STREQ (argv[i], dumpscript_opt)) 601042a55b46Smrg { 601142a55b46SmrgEOF 6012e3d74329Smrg case $host in 601342a55b46Smrg *mingw* | *cygwin* ) 601442a55b46Smrg # make stdout use "unix" line endings 601542a55b46Smrg echo " setmode(1,_O_BINARY);" 601642a55b46Smrg ;; 601742a55b46Smrg esac 6018c582b7e3Smrg 601942a55b46Smrg cat <<"EOF" 602042a55b46Smrg lt_dump_script (stdout); 602142a55b46Smrg return 0; 602242a55b46Smrg } 6023e3d74329Smrg if (STREQ (argv[i], debug_opt)) 602442a55b46Smrg { 602542a55b46Smrg lt_debug = 1; 602642a55b46Smrg continue; 602742a55b46Smrg } 6028e3d74329Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 602942a55b46Smrg { 603042a55b46Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 603142a55b46Smrg namespace, but it is not one of the ones we know about and 603242a55b46Smrg have already dealt with, above (inluding dump-script), then 603342a55b46Smrg report an error. Otherwise, targets might begin to believe 603442a55b46Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 603542a55b46Smrg namespace. The first time any user complains about this, we'll 603642a55b46Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 603742a55b46Smrg or a configure.ac-settable value. 603842a55b46Smrg */ 603942a55b46Smrg lt_fatal (__FILE__, __LINE__, 604042a55b46Smrg "unrecognized %s option: '%s'", 604142a55b46Smrg ltwrapper_option_prefix, argv[i]); 604242a55b46Smrg } 604342a55b46Smrg /* otherwise ... */ 604442a55b46Smrg newargz[++newargc] = xstrdup (argv[i]); 604542a55b46Smrg } 604642a55b46Smrg newargz[++newargc] = NULL; 6047c582b7e3Smrg 604842a55b46SmrgEOF 604942a55b46Smrg cat <<EOF 605042a55b46Smrg /* The GNU banner must be the first non-error debug message */ 6051e3d74329Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 605242a55b46SmrgEOF 605342a55b46Smrg cat <<"EOF" 605442a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 605542a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 605642a55b46Smrg 605742a55b46Smrg tmp_pathspec = find_executable (argv[0]); 605842a55b46Smrg if (tmp_pathspec == NULL) 605942a55b46Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 606042a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 606142a55b46Smrg "(main) found exe (before symlink chase) at: %s\n", 606242a55b46Smrg tmp_pathspec); 606342a55b46Smrg 606442a55b46Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 606542a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 606642a55b46Smrg "(main) found exe (after symlink chase) at: %s\n", 606742a55b46Smrg actual_cwrapper_path); 606842a55b46Smrg XFREE (tmp_pathspec); 606942a55b46Smrg 607042a55b46Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 607142a55b46Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 607242a55b46Smrg 607342a55b46Smrg /* wrapper name transforms */ 607442a55b46Smrg strendzap (actual_cwrapper_name, ".exe"); 607542a55b46Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 607642a55b46Smrg XFREE (actual_cwrapper_name); 607742a55b46Smrg actual_cwrapper_name = tmp_pathspec; 607842a55b46Smrg tmp_pathspec = 0; 607942a55b46Smrg 608042a55b46Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 608142a55b46Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 608242a55b46Smrg strendzap (target_name, ".exe"); 608342a55b46Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 608442a55b46Smrg XFREE (target_name); 608542a55b46Smrg target_name = tmp_pathspec; 608642a55b46Smrg tmp_pathspec = 0; 608742a55b46Smrg 608842a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 608942a55b46Smrg "(main) libtool target name: %s\n", 609042a55b46Smrg target_name); 609142a55b46SmrgEOF 609242a55b46Smrg 609342a55b46Smrg cat <<EOF 609442a55b46Smrg newargz[0] = 609542a55b46Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 609642a55b46Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 609742a55b46Smrg strcpy (newargz[0], actual_cwrapper_path); 609842a55b46Smrg strcat (newargz[0], "$objdir"); 609942a55b46Smrg strcat (newargz[0], "/"); 610042a55b46SmrgEOF 610142a55b46Smrg 610242a55b46Smrg cat <<"EOF" 610342a55b46Smrg /* stop here, and copy so we don't have to do this twice */ 610442a55b46Smrg tmp_pathspec = xstrdup (newargz[0]); 610542a55b46Smrg 610642a55b46Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 610742a55b46Smrg strcat (newargz[0], actual_cwrapper_name); 610842a55b46Smrg 610942a55b46Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 611042a55b46Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 611142a55b46Smrg XFREE (tmp_pathspec); 611242a55b46Smrg tmp_pathspec = NULL; 611342a55b46SmrgEOF 611442a55b46Smrg 611542a55b46Smrg case $host_os in 611642a55b46Smrg mingw*) 611742a55b46Smrg cat <<"EOF" 611842a55b46Smrg { 611942a55b46Smrg char* p; 612042a55b46Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 612142a55b46Smrg { 612242a55b46Smrg *p = '/'; 612342a55b46Smrg } 612442a55b46Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 612542a55b46Smrg { 612642a55b46Smrg *p = '/'; 612742a55b46Smrg } 612842a55b46Smrg } 612942a55b46SmrgEOF 613042a55b46Smrg ;; 613142a55b46Smrg esac 613242a55b46Smrg 613342a55b46Smrg cat <<"EOF" 613442a55b46Smrg XFREE (target_name); 613542a55b46Smrg XFREE (actual_cwrapper_path); 613642a55b46Smrg XFREE (actual_cwrapper_name); 613742a55b46Smrg 613842a55b46Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 613942a55b46Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 614042a55b46Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 614142a55b46Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 614242a55b46Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 614342a55b46Smrg libraries must come first. */ 614442a55b46Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 614542a55b46Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 614642a55b46Smrg 614742a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 614842a55b46Smrg nonnull (lt_argv_zero)); 614942a55b46Smrg for (i = 0; i < newargc; i++) 615042a55b46Smrg { 615142a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 615242a55b46Smrg i, nonnull (newargz[i])); 615342a55b46Smrg } 615442a55b46Smrg 615542a55b46SmrgEOF 615642a55b46Smrg 615742a55b46Smrg case $host_os in 615842a55b46Smrg mingw*) 615942a55b46Smrg cat <<"EOF" 616042a55b46Smrg /* execv doesn't actually work on mingw as expected on unix */ 616142a55b46Smrg newargz = prepare_spawn (newargz); 6162e3d74329Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 616342a55b46Smrg if (rval == -1) 616442a55b46Smrg { 616542a55b46Smrg /* failed to start process */ 616642a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 616742a55b46Smrg "(main) failed to launch target \"%s\": %s\n", 616842a55b46Smrg lt_argv_zero, nonnull (strerror (errno))); 616942a55b46Smrg return 127; 617042a55b46Smrg } 617142a55b46Smrg return rval; 617242a55b46SmrgEOF 6173c582b7e3Smrg ;; 6174c582b7e3Smrg *) 617542a55b46Smrg cat <<"EOF" 617642a55b46Smrg execv (lt_argv_zero, newargz); 617742a55b46Smrg return rval; /* =127, but avoids unused variable warning */ 617842a55b46SmrgEOF 6179c582b7e3Smrg ;; 618042a55b46Smrg esac 6181c582b7e3Smrg 618242a55b46Smrg cat <<"EOF" 618342a55b46Smrg} 6184c582b7e3Smrg 618542a55b46Smrgvoid * 618642a55b46Smrgxmalloc (size_t num) 618742a55b46Smrg{ 618842a55b46Smrg void *p = (void *) malloc (num); 618942a55b46Smrg if (!p) 619042a55b46Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 6191c582b7e3Smrg 619242a55b46Smrg return p; 619342a55b46Smrg} 6194c582b7e3Smrg 619542a55b46Smrgchar * 619642a55b46Smrgxstrdup (const char *string) 619742a55b46Smrg{ 619842a55b46Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 619942a55b46Smrg string) : NULL; 620042a55b46Smrg} 6201c582b7e3Smrg 620242a55b46Smrgconst char * 620342a55b46Smrgbase_name (const char *name) 620442a55b46Smrg{ 620542a55b46Smrg const char *base; 6206c582b7e3Smrg 6207e3d74329Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 620842a55b46Smrg /* Skip over the disk name in MSDOS pathnames. */ 620942a55b46Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 621042a55b46Smrg name += 2; 6211c582b7e3Smrg#endif 6212c582b7e3Smrg 621342a55b46Smrg for (base = name; *name; name++) 621442a55b46Smrg if (IS_DIR_SEPARATOR (*name)) 621542a55b46Smrg base = name + 1; 621642a55b46Smrg return base; 621742a55b46Smrg} 6218c582b7e3Smrg 621942a55b46Smrgint 622042a55b46Smrgcheck_executable (const char *path) 622142a55b46Smrg{ 622242a55b46Smrg struct stat st; 6223c582b7e3Smrg 622442a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 622542a55b46Smrg nonempty (path)); 622642a55b46Smrg if ((!path) || (!*path)) 622742a55b46Smrg return 0; 6228c582b7e3Smrg 622942a55b46Smrg if ((stat (path, &st) >= 0) 623042a55b46Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 623142a55b46Smrg return 1; 623242a55b46Smrg else 623342a55b46Smrg return 0; 623442a55b46Smrg} 6235c582b7e3Smrg 623642a55b46Smrgint 623742a55b46Smrgmake_executable (const char *path) 623842a55b46Smrg{ 623942a55b46Smrg int rval = 0; 624042a55b46Smrg struct stat st; 6241c582b7e3Smrg 624242a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 624342a55b46Smrg nonempty (path)); 624442a55b46Smrg if ((!path) || (!*path)) 624542a55b46Smrg return 0; 6246c582b7e3Smrg 624742a55b46Smrg if (stat (path, &st) >= 0) 624842a55b46Smrg { 624942a55b46Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 625042a55b46Smrg } 625142a55b46Smrg return rval; 625242a55b46Smrg} 6253c582b7e3Smrg 625442a55b46Smrg/* Searches for the full path of the wrapper. Returns 625542a55b46Smrg newly allocated full path name if found, NULL otherwise 625642a55b46Smrg Does not chase symlinks, even on platforms that support them. 625742a55b46Smrg*/ 625842a55b46Smrgchar * 625942a55b46Smrgfind_executable (const char *wrapper) 626042a55b46Smrg{ 626142a55b46Smrg int has_slash = 0; 626242a55b46Smrg const char *p; 626342a55b46Smrg const char *p_next; 626442a55b46Smrg /* static buffer for getcwd */ 626542a55b46Smrg char tmp[LT_PATHMAX + 1]; 6266e3d74329Smrg size_t tmp_len; 626742a55b46Smrg char *concat_name; 6268c582b7e3Smrg 626942a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 627042a55b46Smrg nonempty (wrapper)); 6271c582b7e3Smrg 627242a55b46Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 627342a55b46Smrg return NULL; 6274c582b7e3Smrg 627542a55b46Smrg /* Absolute path? */ 6276e3d74329Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 627742a55b46Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 627842a55b46Smrg { 627942a55b46Smrg concat_name = xstrdup (wrapper); 628042a55b46Smrg if (check_executable (concat_name)) 628142a55b46Smrg return concat_name; 628242a55b46Smrg XFREE (concat_name); 628342a55b46Smrg } 628442a55b46Smrg else 628542a55b46Smrg { 628642a55b46Smrg#endif 628742a55b46Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 628842a55b46Smrg { 628942a55b46Smrg concat_name = xstrdup (wrapper); 629042a55b46Smrg if (check_executable (concat_name)) 629142a55b46Smrg return concat_name; 629242a55b46Smrg XFREE (concat_name); 629342a55b46Smrg } 6294e3d74329Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 629542a55b46Smrg } 629642a55b46Smrg#endif 6297c582b7e3Smrg 629842a55b46Smrg for (p = wrapper; *p; p++) 629942a55b46Smrg if (*p == '/') 630042a55b46Smrg { 630142a55b46Smrg has_slash = 1; 630242a55b46Smrg break; 630342a55b46Smrg } 630442a55b46Smrg if (!has_slash) 630542a55b46Smrg { 630642a55b46Smrg /* no slashes; search PATH */ 630742a55b46Smrg const char *path = getenv ("PATH"); 630842a55b46Smrg if (path != NULL) 630942a55b46Smrg { 631042a55b46Smrg for (p = path; *p; p = p_next) 631142a55b46Smrg { 631242a55b46Smrg const char *q; 631342a55b46Smrg size_t p_len; 631442a55b46Smrg for (q = p; *q; q++) 631542a55b46Smrg if (IS_PATH_SEPARATOR (*q)) 631642a55b46Smrg break; 6317e3d74329Smrg p_len = (size_t) (q - p); 631842a55b46Smrg p_next = (*q == '\0' ? q : q + 1); 631942a55b46Smrg if (p_len == 0) 632042a55b46Smrg { 632142a55b46Smrg /* empty path: current directory */ 632242a55b46Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 632342a55b46Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 632442a55b46Smrg nonnull (strerror (errno))); 632542a55b46Smrg tmp_len = strlen (tmp); 632642a55b46Smrg concat_name = 632742a55b46Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 632842a55b46Smrg memcpy (concat_name, tmp, tmp_len); 632942a55b46Smrg concat_name[tmp_len] = '/'; 633042a55b46Smrg strcpy (concat_name + tmp_len + 1, wrapper); 633142a55b46Smrg } 633242a55b46Smrg else 633342a55b46Smrg { 633442a55b46Smrg concat_name = 633542a55b46Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 633642a55b46Smrg memcpy (concat_name, p, p_len); 633742a55b46Smrg concat_name[p_len] = '/'; 633842a55b46Smrg strcpy (concat_name + p_len + 1, wrapper); 633942a55b46Smrg } 634042a55b46Smrg if (check_executable (concat_name)) 634142a55b46Smrg return concat_name; 634242a55b46Smrg XFREE (concat_name); 634342a55b46Smrg } 634442a55b46Smrg } 634542a55b46Smrg /* not found in PATH; assume curdir */ 634642a55b46Smrg } 634742a55b46Smrg /* Relative path | not found in path: prepend cwd */ 634842a55b46Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 634942a55b46Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 635042a55b46Smrg nonnull (strerror (errno))); 635142a55b46Smrg tmp_len = strlen (tmp); 635242a55b46Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 635342a55b46Smrg memcpy (concat_name, tmp, tmp_len); 635442a55b46Smrg concat_name[tmp_len] = '/'; 635542a55b46Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6356c582b7e3Smrg 635742a55b46Smrg if (check_executable (concat_name)) 635842a55b46Smrg return concat_name; 635942a55b46Smrg XFREE (concat_name); 636042a55b46Smrg return NULL; 636142a55b46Smrg} 6362c582b7e3Smrg 636342a55b46Smrgchar * 636442a55b46Smrgchase_symlinks (const char *pathspec) 636542a55b46Smrg{ 636642a55b46Smrg#ifndef S_ISLNK 636742a55b46Smrg return xstrdup (pathspec); 636842a55b46Smrg#else 636942a55b46Smrg char buf[LT_PATHMAX]; 637042a55b46Smrg struct stat s; 637142a55b46Smrg char *tmp_pathspec = xstrdup (pathspec); 637242a55b46Smrg char *p; 637342a55b46Smrg int has_symlinks = 0; 637442a55b46Smrg while (strlen (tmp_pathspec) && !has_symlinks) 637542a55b46Smrg { 637642a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 637742a55b46Smrg "checking path component for symlinks: %s\n", 637842a55b46Smrg tmp_pathspec); 637942a55b46Smrg if (lstat (tmp_pathspec, &s) == 0) 638042a55b46Smrg { 638142a55b46Smrg if (S_ISLNK (s.st_mode) != 0) 638242a55b46Smrg { 638342a55b46Smrg has_symlinks = 1; 638442a55b46Smrg break; 638542a55b46Smrg } 638642a55b46Smrg 638742a55b46Smrg /* search backwards for last DIR_SEPARATOR */ 638842a55b46Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 638942a55b46Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 639042a55b46Smrg p--; 639142a55b46Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 639242a55b46Smrg { 639342a55b46Smrg /* no more DIR_SEPARATORS left */ 639442a55b46Smrg break; 639542a55b46Smrg } 639642a55b46Smrg *p = '\0'; 639742a55b46Smrg } 639842a55b46Smrg else 639942a55b46Smrg { 640042a55b46Smrg lt_fatal (__FILE__, __LINE__, 640142a55b46Smrg "error accessing file \"%s\": %s", 640242a55b46Smrg tmp_pathspec, nonnull (strerror (errno))); 640342a55b46Smrg } 640442a55b46Smrg } 640542a55b46Smrg XFREE (tmp_pathspec); 6406c582b7e3Smrg 640742a55b46Smrg if (!has_symlinks) 640842a55b46Smrg { 640942a55b46Smrg return xstrdup (pathspec); 641042a55b46Smrg } 6411c582b7e3Smrg 641242a55b46Smrg tmp_pathspec = realpath (pathspec, buf); 641342a55b46Smrg if (tmp_pathspec == 0) 641442a55b46Smrg { 641542a55b46Smrg lt_fatal (__FILE__, __LINE__, 641642a55b46Smrg "could not follow symlinks for %s", pathspec); 641742a55b46Smrg } 641842a55b46Smrg return xstrdup (tmp_pathspec); 6419c582b7e3Smrg#endif 642042a55b46Smrg} 6421c582b7e3Smrg 642242a55b46Smrgchar * 642342a55b46Smrgstrendzap (char *str, const char *pat) 642442a55b46Smrg{ 642542a55b46Smrg size_t len, patlen; 6426c582b7e3Smrg 642742a55b46Smrg assert (str != NULL); 642842a55b46Smrg assert (pat != NULL); 6429c582b7e3Smrg 643042a55b46Smrg len = strlen (str); 643142a55b46Smrg patlen = strlen (pat); 6432c582b7e3Smrg 643342a55b46Smrg if (patlen <= len) 643442a55b46Smrg { 643542a55b46Smrg str += len - patlen; 6436e3d74329Smrg if (STREQ (str, pat)) 643742a55b46Smrg *str = '\0'; 643842a55b46Smrg } 643942a55b46Smrg return str; 6440c582b7e3Smrg} 6441c582b7e3Smrg 644242a55b46Smrgvoid 644342a55b46Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 644442a55b46Smrg{ 644542a55b46Smrg va_list args; 644642a55b46Smrg if (lt_debug) 644742a55b46Smrg { 644842a55b46Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 644942a55b46Smrg va_start (args, fmt); 645042a55b46Smrg (void) vfprintf (stderr, fmt, args); 645142a55b46Smrg va_end (args); 645242a55b46Smrg } 645342a55b46Smrg} 6454c582b7e3Smrg 645542a55b46Smrgstatic void 645642a55b46Smrglt_error_core (int exit_status, const char *file, 645742a55b46Smrg int line, const char *mode, 645842a55b46Smrg const char *message, va_list ap) 645942a55b46Smrg{ 646042a55b46Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 646142a55b46Smrg vfprintf (stderr, message, ap); 646242a55b46Smrg fprintf (stderr, ".\n"); 6463c582b7e3Smrg 646442a55b46Smrg if (exit_status >= 0) 646542a55b46Smrg exit (exit_status); 6466c582b7e3Smrg} 6467c582b7e3Smrg 646842a55b46Smrgvoid 646942a55b46Smrglt_fatal (const char *file, int line, const char *message, ...) 647042a55b46Smrg{ 647142a55b46Smrg va_list ap; 647242a55b46Smrg va_start (ap, message); 647342a55b46Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 647442a55b46Smrg va_end (ap); 6475c582b7e3Smrg} 6476c582b7e3Smrg 647742a55b46Smrgstatic const char * 647842a55b46Smrgnonnull (const char *s) 647942a55b46Smrg{ 648042a55b46Smrg return s ? s : "(null)"; 648142a55b46Smrg} 6482c582b7e3Smrg 648342a55b46Smrgstatic const char * 648442a55b46Smrgnonempty (const char *s) 648542a55b46Smrg{ 648642a55b46Smrg return (s && !*s) ? "(empty)" : nonnull (s); 648742a55b46Smrg} 6488c582b7e3Smrg 648942a55b46Smrgvoid 649042a55b46Smrglt_setenv (const char *name, const char *value) 649142a55b46Smrg{ 649242a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 649342a55b46Smrg "(lt_setenv) setting '%s' to '%s'\n", 649442a55b46Smrg nonnull (name), nonnull (value)); 649542a55b46Smrg { 649642a55b46Smrg#ifdef HAVE_SETENV 649742a55b46Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 649842a55b46Smrg char *str = xstrdup (value); 649942a55b46Smrg setenv (name, str, 1); 650042a55b46Smrg#else 6501e3d74329Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 650242a55b46Smrg char *str = XMALLOC (char, len); 650342a55b46Smrg sprintf (str, "%s=%s", name, value); 650442a55b46Smrg if (putenv (str) != EXIT_SUCCESS) 650542a55b46Smrg { 650642a55b46Smrg XFREE (str); 650742a55b46Smrg } 650842a55b46Smrg#endif 650942a55b46Smrg } 651042a55b46Smrg} 6511c582b7e3Smrg 651242a55b46Smrgchar * 651342a55b46Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 651442a55b46Smrg{ 651542a55b46Smrg char *new_value; 651642a55b46Smrg if (orig_value && *orig_value) 651742a55b46Smrg { 6518e3d74329Smrg size_t orig_value_len = strlen (orig_value); 6519e3d74329Smrg size_t add_len = strlen (add); 652042a55b46Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 652142a55b46Smrg if (to_end) 652242a55b46Smrg { 652342a55b46Smrg strcpy (new_value, orig_value); 652442a55b46Smrg strcpy (new_value + orig_value_len, add); 652542a55b46Smrg } 6526c582b7e3Smrg else 652742a55b46Smrg { 652842a55b46Smrg strcpy (new_value, add); 652942a55b46Smrg strcpy (new_value + add_len, orig_value); 653042a55b46Smrg } 653142a55b46Smrg } 653242a55b46Smrg else 653342a55b46Smrg { 653442a55b46Smrg new_value = xstrdup (add); 653542a55b46Smrg } 653642a55b46Smrg return new_value; 653742a55b46Smrg} 6538c582b7e3Smrg 653942a55b46Smrgvoid 654042a55b46Smrglt_update_exe_path (const char *name, const char *value) 654142a55b46Smrg{ 654242a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 654342a55b46Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 654442a55b46Smrg nonnull (name), nonnull (value)); 6545c582b7e3Smrg 654642a55b46Smrg if (name && *name && value && *value) 654742a55b46Smrg { 654842a55b46Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 654942a55b46Smrg /* some systems can't cope with a ':'-terminated path #' */ 6550e3d74329Smrg size_t len = strlen (new_value); 6551e3d74329Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 655242a55b46Smrg { 6553e3d74329Smrg new_value[--len] = '\0'; 655442a55b46Smrg } 655542a55b46Smrg lt_setenv (name, new_value); 655642a55b46Smrg XFREE (new_value); 655742a55b46Smrg } 655842a55b46Smrg} 6559c582b7e3Smrg 656042a55b46Smrgvoid 656142a55b46Smrglt_update_lib_path (const char *name, const char *value) 656242a55b46Smrg{ 656342a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 656442a55b46Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 656542a55b46Smrg nonnull (name), nonnull (value)); 6566c582b7e3Smrg 656742a55b46Smrg if (name && *name && value && *value) 656842a55b46Smrg { 656942a55b46Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 657042a55b46Smrg lt_setenv (name, new_value); 657142a55b46Smrg XFREE (new_value); 657242a55b46Smrg } 657342a55b46Smrg} 6574c582b7e3Smrg 6575c582b7e3SmrgEOF 657642a55b46Smrg case $host_os in 657742a55b46Smrg mingw*) 657842a55b46Smrg cat <<"EOF" 657942a55b46Smrg 658042a55b46Smrg/* Prepares an argument vector before calling spawn(). 658142a55b46Smrg Note that spawn() does not by itself call the command interpreter 658242a55b46Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 658342a55b46Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 658442a55b46Smrg GetVersionEx(&v); 658542a55b46Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 658642a55b46Smrg }) ? "cmd.exe" : "command.com"). 658742a55b46Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 658842a55b46Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 658942a55b46Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 659042a55b46Smrg special way: 659142a55b46Smrg - Space and tab are interpreted as delimiters. They are not treated as 659242a55b46Smrg delimiters if they are surrounded by double quotes: "...". 659342a55b46Smrg - Unescaped double quotes are removed from the input. Their only effect is 659442a55b46Smrg that within double quotes, space and tab are treated like normal 659542a55b46Smrg characters. 659642a55b46Smrg - Backslashes not followed by double quotes are not special. 659742a55b46Smrg - But 2*n+1 backslashes followed by a double quote become 659842a55b46Smrg n backslashes followed by a double quote (n >= 0): 659942a55b46Smrg \" -> " 660042a55b46Smrg \\\" -> \" 660142a55b46Smrg \\\\\" -> \\" 660242a55b46Smrg */ 660342a55b46Smrg#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" 660442a55b46Smrg#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" 660542a55b46Smrgchar ** 660642a55b46Smrgprepare_spawn (char **argv) 6607c582b7e3Smrg{ 660842a55b46Smrg size_t argc; 660942a55b46Smrg char **new_argv; 661042a55b46Smrg size_t i; 6611c582b7e3Smrg 661242a55b46Smrg /* Count number of arguments. */ 661342a55b46Smrg for (argc = 0; argv[argc] != NULL; argc++) 661442a55b46Smrg ; 6615c582b7e3Smrg 661642a55b46Smrg /* Allocate new argument vector. */ 661742a55b46Smrg new_argv = XMALLOC (char *, argc + 1); 6618c582b7e3Smrg 661942a55b46Smrg /* Put quoted arguments into the new argument vector. */ 662042a55b46Smrg for (i = 0; i < argc; i++) 662142a55b46Smrg { 662242a55b46Smrg const char *string = argv[i]; 662342a55b46Smrg 662442a55b46Smrg if (string[0] == '\0') 662542a55b46Smrg new_argv[i] = xstrdup ("\"\""); 662642a55b46Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 662742a55b46Smrg { 662842a55b46Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 662942a55b46Smrg size_t length; 663042a55b46Smrg unsigned int backslashes; 663142a55b46Smrg const char *s; 663242a55b46Smrg char *quoted_string; 663342a55b46Smrg char *p; 663442a55b46Smrg 663542a55b46Smrg length = 0; 663642a55b46Smrg backslashes = 0; 663742a55b46Smrg if (quote_around) 663842a55b46Smrg length++; 663942a55b46Smrg for (s = string; *s != '\0'; s++) 664042a55b46Smrg { 664142a55b46Smrg char c = *s; 664242a55b46Smrg if (c == '"') 664342a55b46Smrg length += backslashes + 1; 664442a55b46Smrg length++; 664542a55b46Smrg if (c == '\\') 664642a55b46Smrg backslashes++; 664742a55b46Smrg else 664842a55b46Smrg backslashes = 0; 664942a55b46Smrg } 665042a55b46Smrg if (quote_around) 665142a55b46Smrg length += backslashes + 1; 665242a55b46Smrg 665342a55b46Smrg quoted_string = XMALLOC (char, length + 1); 665442a55b46Smrg 665542a55b46Smrg p = quoted_string; 665642a55b46Smrg backslashes = 0; 665742a55b46Smrg if (quote_around) 665842a55b46Smrg *p++ = '"'; 665942a55b46Smrg for (s = string; *s != '\0'; s++) 666042a55b46Smrg { 666142a55b46Smrg char c = *s; 666242a55b46Smrg if (c == '"') 666342a55b46Smrg { 666442a55b46Smrg unsigned int j; 666542a55b46Smrg for (j = backslashes + 1; j > 0; j--) 666642a55b46Smrg *p++ = '\\'; 666742a55b46Smrg } 666842a55b46Smrg *p++ = c; 666942a55b46Smrg if (c == '\\') 667042a55b46Smrg backslashes++; 667142a55b46Smrg else 667242a55b46Smrg backslashes = 0; 667342a55b46Smrg } 667442a55b46Smrg if (quote_around) 667542a55b46Smrg { 667642a55b46Smrg unsigned int j; 667742a55b46Smrg for (j = backslashes; j > 0; j--) 667842a55b46Smrg *p++ = '\\'; 667942a55b46Smrg *p++ = '"'; 668042a55b46Smrg } 668142a55b46Smrg *p = '\0'; 6682c582b7e3Smrg 668342a55b46Smrg new_argv[i] = quoted_string; 668442a55b46Smrg } 668542a55b46Smrg else 668642a55b46Smrg new_argv[i] = (char *) string; 668742a55b46Smrg } 668842a55b46Smrg new_argv[argc] = NULL; 6689c582b7e3Smrg 669042a55b46Smrg return new_argv; 669142a55b46Smrg} 6692c582b7e3SmrgEOF 669342a55b46Smrg ;; 669442a55b46Smrg esac 6695c582b7e3Smrg 669642a55b46Smrg cat <<"EOF" 669742a55b46Smrgvoid lt_dump_script (FILE* f) 669842a55b46Smrg{ 6699c582b7e3SmrgEOF 670042a55b46Smrg func_emit_wrapper yes | 670142a55b46Smrg $SED -n -e ' 670242a55b46Smrgs/^\(.\{79\}\)\(..*\)/\1\ 670342a55b46Smrg\2/ 670442a55b46Smrgh 670542a55b46Smrgs/\([\\"]\)/\\\1/g 670642a55b46Smrgs/$/\\n/ 670742a55b46Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 670842a55b46Smrgg 670942a55b46SmrgD' 671042a55b46Smrg cat <<"EOF" 6711c582b7e3Smrg} 671242a55b46SmrgEOF 6713c582b7e3Smrg} 671442a55b46Smrg# end: func_emit_cwrapperexe_src 6715c582b7e3Smrg 671642a55b46Smrg# func_win32_import_lib_p ARG 671742a55b46Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 671842a55b46Smrgfunc_win32_import_lib_p () 6719c582b7e3Smrg{ 6720e3d74329Smrg $debug_cmd 6721e3d74329Smrg 672242a55b46Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 672342a55b46Smrg *import*) : ;; 672442a55b46Smrg *) false ;; 672542a55b46Smrg esac 6726c582b7e3Smrg} 6727c582b7e3Smrg 6728e3d74329Smrg# func_suncc_cstd_abi 6729e3d74329Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6730e3d74329Smrg# Several compiler flags select an ABI that is incompatible with the 6731e3d74329Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6732e3d74329Smrgfunc_suncc_cstd_abi () 6733e3d74329Smrg{ 6734e3d74329Smrg $debug_cmd 6735e3d74329Smrg 6736e3d74329Smrg case " $compile_command " in 6737e3d74329Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6738e3d74329Smrg suncc_use_cstd_abi=no 6739e3d74329Smrg ;; 6740e3d74329Smrg *) 6741e3d74329Smrg suncc_use_cstd_abi=yes 6742e3d74329Smrg ;; 6743e3d74329Smrg esac 6744e3d74329Smrg} 6745e3d74329Smrg 674642a55b46Smrg# func_mode_link arg... 674742a55b46Smrgfunc_mode_link () 6748c582b7e3Smrg{ 6749e3d74329Smrg $debug_cmd 6750e3d74329Smrg 675142a55b46Smrg case $host in 675242a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 675342a55b46Smrg # It is impossible to link a dll without this setting, and 675442a55b46Smrg # we shouldn't force the makefile maintainer to figure out 6755e3d74329Smrg # what system we are compiling for in order to pass an extra 675642a55b46Smrg # flag for every libtool invocation. 675742a55b46Smrg # allow_undefined=no 6758c582b7e3Smrg 675942a55b46Smrg # FIXME: Unfortunately, there are problems with the above when trying 6760e3d74329Smrg # to make a dll that has undefined symbols, in which case not 676142a55b46Smrg # even a static library is built. For now, we need to specify 676242a55b46Smrg # -no-undefined on the libtool link line when we can be certain 676342a55b46Smrg # that all symbols are satisfied, otherwise we get a static library. 676442a55b46Smrg allow_undefined=yes 676542a55b46Smrg ;; 676642a55b46Smrg *) 676742a55b46Smrg allow_undefined=yes 676842a55b46Smrg ;; 676942a55b46Smrg esac 677042a55b46Smrg libtool_args=$nonopt 677142a55b46Smrg base_compile="$nonopt $@" 677242a55b46Smrg compile_command=$nonopt 677342a55b46Smrg finalize_command=$nonopt 6774c582b7e3Smrg 677542a55b46Smrg compile_rpath= 677642a55b46Smrg finalize_rpath= 677742a55b46Smrg compile_shlibpath= 677842a55b46Smrg finalize_shlibpath= 677942a55b46Smrg convenience= 678042a55b46Smrg old_convenience= 678142a55b46Smrg deplibs= 678242a55b46Smrg old_deplibs= 678342a55b46Smrg compiler_flags= 678442a55b46Smrg linker_flags= 678542a55b46Smrg dllsearchpath= 678642a55b46Smrg lib_search_path=`pwd` 678742a55b46Smrg inst_prefix_dir= 678842a55b46Smrg new_inherited_linker_flags= 6789c582b7e3Smrg 679042a55b46Smrg avoid_version=no 679142a55b46Smrg bindir= 679242a55b46Smrg dlfiles= 679342a55b46Smrg dlprefiles= 679442a55b46Smrg dlself=no 679542a55b46Smrg export_dynamic=no 679642a55b46Smrg export_symbols= 679742a55b46Smrg export_symbols_regex= 679842a55b46Smrg generated= 679942a55b46Smrg libobjs= 680042a55b46Smrg ltlibs= 680142a55b46Smrg module=no 680242a55b46Smrg no_install=no 680342a55b46Smrg objs= 6804e3d74329Smrg os2dllname= 680542a55b46Smrg non_pic_objects= 680642a55b46Smrg precious_files_regex= 680742a55b46Smrg prefer_static_libs=no 6808e3d74329Smrg preload=false 680942a55b46Smrg prev= 681042a55b46Smrg prevarg= 681142a55b46Smrg release= 681242a55b46Smrg rpath= 681342a55b46Smrg xrpath= 681442a55b46Smrg perm_rpath= 681542a55b46Smrg temp_rpath= 681642a55b46Smrg thread_safe=no 681742a55b46Smrg vinfo= 681842a55b46Smrg vinfo_number=no 681942a55b46Smrg weak_libs= 6820e3d74329Smrg single_module=$wl-single_module 682142a55b46Smrg func_infer_tag $base_compile 6822c582b7e3Smrg 682342a55b46Smrg # We need to know -static, to get the right output filenames. 682442a55b46Smrg for arg 682542a55b46Smrg do 682642a55b46Smrg case $arg in 682742a55b46Smrg -shared) 6828e3d74329Smrg test yes != "$build_libtool_libs" \ 6829e3d74329Smrg && func_fatal_configuration "cannot build a shared library" 683042a55b46Smrg build_old_libs=no 683142a55b46Smrg break 683242a55b46Smrg ;; 683342a55b46Smrg -all-static | -static | -static-libtool-libs) 683442a55b46Smrg case $arg in 683542a55b46Smrg -all-static) 6836e3d74329Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 683742a55b46Smrg func_warning "complete static linking is impossible in this configuration" 683842a55b46Smrg fi 683942a55b46Smrg if test -n "$link_static_flag"; then 684042a55b46Smrg dlopen_self=$dlopen_self_static 684142a55b46Smrg fi 684242a55b46Smrg prefer_static_libs=yes 684342a55b46Smrg ;; 684442a55b46Smrg -static) 684542a55b46Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 684642a55b46Smrg dlopen_self=$dlopen_self_static 684742a55b46Smrg fi 684842a55b46Smrg prefer_static_libs=built 684942a55b46Smrg ;; 685042a55b46Smrg -static-libtool-libs) 685142a55b46Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 685242a55b46Smrg dlopen_self=$dlopen_self_static 685342a55b46Smrg fi 685442a55b46Smrg prefer_static_libs=yes 685542a55b46Smrg ;; 685642a55b46Smrg esac 685742a55b46Smrg build_libtool_libs=no 685842a55b46Smrg build_old_libs=yes 685942a55b46Smrg break 686042a55b46Smrg ;; 686142a55b46Smrg esac 686242a55b46Smrg done 6863c582b7e3Smrg 686442a55b46Smrg # See if our shared archives depend on static archives. 686542a55b46Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6866c582b7e3Smrg 686742a55b46Smrg # Go through the arguments, transforming them on the way. 686842a55b46Smrg while test "$#" -gt 0; do 6869e3d74329Smrg arg=$1 687042a55b46Smrg shift 68718ce07328Smrg func_quote_arg pretty,unquoted "$arg" 68728ce07328Smrg qarg=$func_quote_arg_unquoted_result 68738ce07328Smrg func_append libtool_args " $func_quote_arg_result" 6874c582b7e3Smrg 687542a55b46Smrg # If the previous option needs an argument, assign it. 687642a55b46Smrg if test -n "$prev"; then 687742a55b46Smrg case $prev in 687842a55b46Smrg output) 687942a55b46Smrg func_append compile_command " @OUTPUT@" 688042a55b46Smrg func_append finalize_command " @OUTPUT@" 688142a55b46Smrg ;; 688242a55b46Smrg esac 6883c582b7e3Smrg 688442a55b46Smrg case $prev in 688542a55b46Smrg bindir) 6886e3d74329Smrg bindir=$arg 688742a55b46Smrg prev= 688842a55b46Smrg continue 688942a55b46Smrg ;; 689042a55b46Smrg dlfiles|dlprefiles) 6891e3d74329Smrg $preload || { 689242a55b46Smrg # Add the symbol object into the linking commands. 689342a55b46Smrg func_append compile_command " @SYMFILE@" 689442a55b46Smrg func_append finalize_command " @SYMFILE@" 6895e3d74329Smrg preload=: 6896e3d74329Smrg } 689742a55b46Smrg case $arg in 689842a55b46Smrg *.la | *.lo) ;; # We handle these cases below. 689942a55b46Smrg force) 6900e3d74329Smrg if test no = "$dlself"; then 690142a55b46Smrg dlself=needless 690242a55b46Smrg export_dynamic=yes 690342a55b46Smrg fi 690442a55b46Smrg prev= 690542a55b46Smrg continue 690642a55b46Smrg ;; 690742a55b46Smrg self) 6908e3d74329Smrg if test dlprefiles = "$prev"; then 690942a55b46Smrg dlself=yes 6910e3d74329Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 691142a55b46Smrg dlself=yes 691242a55b46Smrg else 691342a55b46Smrg dlself=needless 691442a55b46Smrg export_dynamic=yes 691542a55b46Smrg fi 691642a55b46Smrg prev= 691742a55b46Smrg continue 691842a55b46Smrg ;; 691942a55b46Smrg *) 6920e3d74329Smrg if test dlfiles = "$prev"; then 692142a55b46Smrg func_append dlfiles " $arg" 692242a55b46Smrg else 692342a55b46Smrg func_append dlprefiles " $arg" 692442a55b46Smrg fi 692542a55b46Smrg prev= 692642a55b46Smrg continue 692742a55b46Smrg ;; 692842a55b46Smrg esac 692942a55b46Smrg ;; 693042a55b46Smrg expsyms) 6931e3d74329Smrg export_symbols=$arg 693242a55b46Smrg test -f "$arg" \ 6933e3d74329Smrg || func_fatal_error "symbol file '$arg' does not exist" 693442a55b46Smrg prev= 693542a55b46Smrg continue 693642a55b46Smrg ;; 693742a55b46Smrg expsyms_regex) 6938e3d74329Smrg export_symbols_regex=$arg 693942a55b46Smrg prev= 694042a55b46Smrg continue 694142a55b46Smrg ;; 694242a55b46Smrg framework) 694342a55b46Smrg case $host in 694442a55b46Smrg *-*-darwin*) 694542a55b46Smrg case "$deplibs " in 694642a55b46Smrg *" $qarg.ltframework "*) ;; 694742a55b46Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 694842a55b46Smrg ;; 694942a55b46Smrg esac 695042a55b46Smrg ;; 695142a55b46Smrg esac 695242a55b46Smrg prev= 695342a55b46Smrg continue 695442a55b46Smrg ;; 695542a55b46Smrg inst_prefix) 6956e3d74329Smrg inst_prefix_dir=$arg 6957e3d74329Smrg prev= 6958e3d74329Smrg continue 6959e3d74329Smrg ;; 6960e3d74329Smrg mllvm) 6961e3d74329Smrg # Clang does not use LLVM to link, so we can simply discard any 6962e3d74329Smrg # '-mllvm $arg' options when doing the link step. 696342a55b46Smrg prev= 696442a55b46Smrg continue 696542a55b46Smrg ;; 696642a55b46Smrg objectlist) 696742a55b46Smrg if test -f "$arg"; then 696842a55b46Smrg save_arg=$arg 696942a55b46Smrg moreargs= 697042a55b46Smrg for fil in `cat "$save_arg"` 697142a55b46Smrg do 697242a55b46Smrg# func_append moreargs " $fil" 697342a55b46Smrg arg=$fil 697442a55b46Smrg # A libtool-controlled object. 6975c582b7e3Smrg 697642a55b46Smrg # Check to see that this really is a libtool object. 697742a55b46Smrg if func_lalib_unsafe_p "$arg"; then 697842a55b46Smrg pic_object= 697942a55b46Smrg non_pic_object= 6980c582b7e3Smrg 698142a55b46Smrg # Read the .lo file 698242a55b46Smrg func_source "$arg" 6983c582b7e3Smrg 698442a55b46Smrg if test -z "$pic_object" || 698542a55b46Smrg test -z "$non_pic_object" || 6986e3d74329Smrg test none = "$pic_object" && 6987e3d74329Smrg test none = "$non_pic_object"; then 6988e3d74329Smrg func_fatal_error "cannot find name of object for '$arg'" 698942a55b46Smrg fi 6990c582b7e3Smrg 699142a55b46Smrg # Extract subdirectory from the argument. 699242a55b46Smrg func_dirname "$arg" "/" "" 6993e3d74329Smrg xdir=$func_dirname_result 6994c582b7e3Smrg 6995e3d74329Smrg if test none != "$pic_object"; then 699642a55b46Smrg # Prepend the subdirectory the object is found in. 6997e3d74329Smrg pic_object=$xdir$pic_object 6998c582b7e3Smrg 6999e3d74329Smrg if test dlfiles = "$prev"; then 7000e3d74329Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 700142a55b46Smrg func_append dlfiles " $pic_object" 700242a55b46Smrg prev= 700342a55b46Smrg continue 700442a55b46Smrg else 700542a55b46Smrg # If libtool objects are unsupported, then we need to preload. 700642a55b46Smrg prev=dlprefiles 700742a55b46Smrg fi 700842a55b46Smrg fi 7009c582b7e3Smrg 701042a55b46Smrg # CHECK ME: I think I busted this. -Ossama 7011e3d74329Smrg if test dlprefiles = "$prev"; then 701242a55b46Smrg # Preload the old-style object. 701342a55b46Smrg func_append dlprefiles " $pic_object" 701442a55b46Smrg prev= 701542a55b46Smrg fi 7016c582b7e3Smrg 701742a55b46Smrg # A PIC object. 701842a55b46Smrg func_append libobjs " $pic_object" 7019e3d74329Smrg arg=$pic_object 702042a55b46Smrg fi 7021c582b7e3Smrg 702242a55b46Smrg # Non-PIC object. 7023e3d74329Smrg if test none != "$non_pic_object"; then 702442a55b46Smrg # Prepend the subdirectory the object is found in. 7025e3d74329Smrg non_pic_object=$xdir$non_pic_object 7026c582b7e3Smrg 702742a55b46Smrg # A standard non-PIC object 702842a55b46Smrg func_append non_pic_objects " $non_pic_object" 7029e3d74329Smrg if test -z "$pic_object" || test none = "$pic_object"; then 7030e3d74329Smrg arg=$non_pic_object 703142a55b46Smrg fi 703242a55b46Smrg else 703342a55b46Smrg # If the PIC object exists, use it instead. 703442a55b46Smrg # $xdir was prepended to $pic_object above. 7035e3d74329Smrg non_pic_object=$pic_object 703642a55b46Smrg func_append non_pic_objects " $non_pic_object" 703742a55b46Smrg fi 703842a55b46Smrg else 703942a55b46Smrg # Only an error if not doing a dry-run. 704042a55b46Smrg if $opt_dry_run; then 704142a55b46Smrg # Extract subdirectory from the argument. 704242a55b46Smrg func_dirname "$arg" "/" "" 7043e3d74329Smrg xdir=$func_dirname_result 704442a55b46Smrg 704542a55b46Smrg func_lo2o "$arg" 704642a55b46Smrg pic_object=$xdir$objdir/$func_lo2o_result 704742a55b46Smrg non_pic_object=$xdir$func_lo2o_result 704842a55b46Smrg func_append libobjs " $pic_object" 704942a55b46Smrg func_append non_pic_objects " $non_pic_object" 705042a55b46Smrg else 7051e3d74329Smrg func_fatal_error "'$arg' is not a valid libtool object" 705242a55b46Smrg fi 705342a55b46Smrg fi 705442a55b46Smrg done 705542a55b46Smrg else 7056e3d74329Smrg func_fatal_error "link input file '$arg' does not exist" 705742a55b46Smrg fi 705842a55b46Smrg arg=$save_arg 705942a55b46Smrg prev= 706042a55b46Smrg continue 706142a55b46Smrg ;; 7062e3d74329Smrg os2dllname) 7063e3d74329Smrg os2dllname=$arg 7064e3d74329Smrg prev= 7065e3d74329Smrg continue 7066e3d74329Smrg ;; 706742a55b46Smrg precious_regex) 7068e3d74329Smrg precious_files_regex=$arg 706942a55b46Smrg prev= 707042a55b46Smrg continue 707142a55b46Smrg ;; 707242a55b46Smrg release) 7073e3d74329Smrg release=-$arg 707442a55b46Smrg prev= 707542a55b46Smrg continue 707642a55b46Smrg ;; 707742a55b46Smrg rpath | xrpath) 707842a55b46Smrg # We need an absolute path. 707942a55b46Smrg case $arg in 708042a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 708142a55b46Smrg *) 708242a55b46Smrg func_fatal_error "only absolute run-paths are allowed" 708342a55b46Smrg ;; 708442a55b46Smrg esac 7085e3d74329Smrg if test rpath = "$prev"; then 708642a55b46Smrg case "$rpath " in 708742a55b46Smrg *" $arg "*) ;; 708842a55b46Smrg *) func_append rpath " $arg" ;; 708942a55b46Smrg esac 709042a55b46Smrg else 709142a55b46Smrg case "$xrpath " in 709242a55b46Smrg *" $arg "*) ;; 709342a55b46Smrg *) func_append xrpath " $arg" ;; 709442a55b46Smrg esac 709542a55b46Smrg fi 709642a55b46Smrg prev= 709742a55b46Smrg continue 709842a55b46Smrg ;; 709942a55b46Smrg shrext) 7100e3d74329Smrg shrext_cmds=$arg 710142a55b46Smrg prev= 710242a55b46Smrg continue 710342a55b46Smrg ;; 710442a55b46Smrg weak) 710542a55b46Smrg func_append weak_libs " $arg" 710642a55b46Smrg prev= 710742a55b46Smrg continue 710842a55b46Smrg ;; 71098ce07328Smrg xassembler) 71108ce07328Smrg func_append compiler_flags " -Xassembler $qarg" 71118ce07328Smrg prev= 71128ce07328Smrg func_append compile_command " -Xassembler $qarg" 71138ce07328Smrg func_append finalize_command " -Xassembler $qarg" 71148ce07328Smrg continue 71158ce07328Smrg ;; 711642a55b46Smrg xcclinker) 711742a55b46Smrg func_append linker_flags " $qarg" 711842a55b46Smrg func_append compiler_flags " $qarg" 711942a55b46Smrg prev= 712042a55b46Smrg func_append compile_command " $qarg" 712142a55b46Smrg func_append finalize_command " $qarg" 712242a55b46Smrg continue 712342a55b46Smrg ;; 712442a55b46Smrg xcompiler) 712542a55b46Smrg func_append compiler_flags " $qarg" 712642a55b46Smrg prev= 712742a55b46Smrg func_append compile_command " $qarg" 712842a55b46Smrg func_append finalize_command " $qarg" 712942a55b46Smrg continue 713042a55b46Smrg ;; 713142a55b46Smrg xlinker) 713242a55b46Smrg func_append linker_flags " $qarg" 713342a55b46Smrg func_append compiler_flags " $wl$qarg" 713442a55b46Smrg prev= 713542a55b46Smrg func_append compile_command " $wl$qarg" 713642a55b46Smrg func_append finalize_command " $wl$qarg" 713742a55b46Smrg continue 713842a55b46Smrg ;; 713942a55b46Smrg *) 714042a55b46Smrg eval "$prev=\"\$arg\"" 714142a55b46Smrg prev= 714242a55b46Smrg continue 714342a55b46Smrg ;; 714442a55b46Smrg esac 714542a55b46Smrg fi # test -n "$prev" 7146c582b7e3Smrg 7147e3d74329Smrg prevarg=$arg 7148c582b7e3Smrg 714942a55b46Smrg case $arg in 715042a55b46Smrg -all-static) 715142a55b46Smrg if test -n "$link_static_flag"; then 715242a55b46Smrg # See comment for -static flag below, for more details. 715342a55b46Smrg func_append compile_command " $link_static_flag" 715442a55b46Smrg func_append finalize_command " $link_static_flag" 715542a55b46Smrg fi 715642a55b46Smrg continue 715742a55b46Smrg ;; 7158c582b7e3Smrg 715942a55b46Smrg -allow-undefined) 716042a55b46Smrg # FIXME: remove this flag sometime in the future. 7161e3d74329Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 716242a55b46Smrg ;; 7163c582b7e3Smrg 716442a55b46Smrg -avoid-version) 716542a55b46Smrg avoid_version=yes 716642a55b46Smrg continue 716742a55b46Smrg ;; 7168c582b7e3Smrg 716942a55b46Smrg -bindir) 717042a55b46Smrg prev=bindir 717142a55b46Smrg continue 717242a55b46Smrg ;; 7173c582b7e3Smrg 717442a55b46Smrg -dlopen) 717542a55b46Smrg prev=dlfiles 717642a55b46Smrg continue 717742a55b46Smrg ;; 7178c582b7e3Smrg 717942a55b46Smrg -dlpreopen) 718042a55b46Smrg prev=dlprefiles 718142a55b46Smrg continue 718242a55b46Smrg ;; 7183c582b7e3Smrg 718442a55b46Smrg -export-dynamic) 718542a55b46Smrg export_dynamic=yes 718642a55b46Smrg continue 718742a55b46Smrg ;; 7188c582b7e3Smrg 718942a55b46Smrg -export-symbols | -export-symbols-regex) 719042a55b46Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 719142a55b46Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 719242a55b46Smrg fi 7193e3d74329Smrg if test X-export-symbols = "X$arg"; then 719442a55b46Smrg prev=expsyms 719542a55b46Smrg else 719642a55b46Smrg prev=expsyms_regex 719742a55b46Smrg fi 719842a55b46Smrg continue 719942a55b46Smrg ;; 7200c582b7e3Smrg 720142a55b46Smrg -framework) 720242a55b46Smrg prev=framework 720342a55b46Smrg continue 720442a55b46Smrg ;; 7205c582b7e3Smrg 720642a55b46Smrg -inst-prefix-dir) 720742a55b46Smrg prev=inst_prefix 720842a55b46Smrg continue 720942a55b46Smrg ;; 7210c582b7e3Smrg 721142a55b46Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 721242a55b46Smrg # so, if we see these flags be careful not to treat them like -L 721342a55b46Smrg -L[A-Z][A-Z]*:*) 721442a55b46Smrg case $with_gcc/$host in 721542a55b46Smrg no/*-*-irix* | /*-*-irix*) 721642a55b46Smrg func_append compile_command " $arg" 721742a55b46Smrg func_append finalize_command " $arg" 721842a55b46Smrg ;; 721942a55b46Smrg esac 722042a55b46Smrg continue 722142a55b46Smrg ;; 7222c582b7e3Smrg 722342a55b46Smrg -L*) 722442a55b46Smrg func_stripname "-L" '' "$arg" 722542a55b46Smrg if test -z "$func_stripname_result"; then 722642a55b46Smrg if test "$#" -gt 0; then 7227e3d74329Smrg func_fatal_error "require no space between '-L' and '$1'" 722842a55b46Smrg else 7229e3d74329Smrg func_fatal_error "need path for '-L' option" 723042a55b46Smrg fi 723142a55b46Smrg fi 723242a55b46Smrg func_resolve_sysroot "$func_stripname_result" 723342a55b46Smrg dir=$func_resolve_sysroot_result 723442a55b46Smrg # We need an absolute path. 723542a55b46Smrg case $dir in 723642a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 723742a55b46Smrg *) 723842a55b46Smrg absdir=`cd "$dir" && pwd` 723942a55b46Smrg test -z "$absdir" && \ 7240e3d74329Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 7241e3d74329Smrg dir=$absdir 724242a55b46Smrg ;; 724342a55b46Smrg esac 724442a55b46Smrg case "$deplibs " in 724542a55b46Smrg *" -L$dir "* | *" $arg "*) 724642a55b46Smrg # Will only happen for absolute or sysroot arguments 724742a55b46Smrg ;; 724842a55b46Smrg *) 724942a55b46Smrg # Preserve sysroot, but never include relative directories 725042a55b46Smrg case $dir in 725142a55b46Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 725242a55b46Smrg *) func_append deplibs " -L$dir" ;; 725342a55b46Smrg esac 725442a55b46Smrg func_append lib_search_path " $dir" 725542a55b46Smrg ;; 725642a55b46Smrg esac 725742a55b46Smrg case $host in 725842a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 725942a55b46Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 726042a55b46Smrg case :$dllsearchpath: in 726142a55b46Smrg *":$dir:"*) ;; 726242a55b46Smrg ::) dllsearchpath=$dir;; 726342a55b46Smrg *) func_append dllsearchpath ":$dir";; 726442a55b46Smrg esac 726542a55b46Smrg case :$dllsearchpath: in 726642a55b46Smrg *":$testbindir:"*) ;; 726742a55b46Smrg ::) dllsearchpath=$testbindir;; 726842a55b46Smrg *) func_append dllsearchpath ":$testbindir";; 726942a55b46Smrg esac 727042a55b46Smrg ;; 727142a55b46Smrg esac 727242a55b46Smrg continue 727342a55b46Smrg ;; 7274c582b7e3Smrg 727542a55b46Smrg -l*) 7276e3d74329Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 727742a55b46Smrg case $host in 727842a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 727942a55b46Smrg # These systems don't actually have a C or math library (as such) 728042a55b46Smrg continue 728142a55b46Smrg ;; 728242a55b46Smrg *-*-os2*) 728342a55b46Smrg # These systems don't actually have a C library (as such) 7284e3d74329Smrg test X-lc = "X$arg" && continue 728542a55b46Smrg ;; 72868ce07328Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 728742a55b46Smrg # Do not include libc due to us having libc/libc_r. 7288e3d74329Smrg test X-lc = "X$arg" && continue 728942a55b46Smrg ;; 729042a55b46Smrg *-*-rhapsody* | *-*-darwin1.[012]) 729142a55b46Smrg # Rhapsody C and math libraries are in the System framework 729242a55b46Smrg func_append deplibs " System.ltframework" 729342a55b46Smrg continue 729442a55b46Smrg ;; 729542a55b46Smrg *-*-sco3.2v5* | *-*-sco5v6*) 729642a55b46Smrg # Causes problems with __ctype 7297e3d74329Smrg test X-lc = "X$arg" && continue 729842a55b46Smrg ;; 729942a55b46Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 730042a55b46Smrg # Compiler inserts libc in the correct place for threads to work 7301e3d74329Smrg test X-lc = "X$arg" && continue 730242a55b46Smrg ;; 730342a55b46Smrg esac 7304e3d74329Smrg elif test X-lc_r = "X$arg"; then 730542a55b46Smrg case $host in 73068ce07328Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 730742a55b46Smrg # Do not include libc_r directly, use -pthread flag. 730842a55b46Smrg continue 730942a55b46Smrg ;; 731042a55b46Smrg esac 731142a55b46Smrg fi 731242a55b46Smrg func_append deplibs " $arg" 731342a55b46Smrg continue 731442a55b46Smrg ;; 731542a55b46Smrg 7316e3d74329Smrg -mllvm) 7317e3d74329Smrg prev=mllvm 7318e3d74329Smrg continue 7319e3d74329Smrg ;; 7320e3d74329Smrg 732142a55b46Smrg -module) 732242a55b46Smrg module=yes 732342a55b46Smrg continue 732442a55b46Smrg ;; 732542a55b46Smrg 732642a55b46Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 732742a55b46Smrg # classes, name mangling, and exception handling. 732842a55b46Smrg # Darwin uses the -arch flag to determine output architecture. 732942a55b46Smrg -model|-arch|-isysroot|--sysroot) 733042a55b46Smrg func_append compiler_flags " $arg" 733142a55b46Smrg func_append compile_command " $arg" 733242a55b46Smrg func_append finalize_command " $arg" 733342a55b46Smrg prev=xcompiler 733442a55b46Smrg continue 733542a55b46Smrg ;; 73368ce07328Smrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 73378ce07328Smrg -pthread) 73388ce07328Smrg case $host in 73398ce07328Smrg *solaris2*) ;; 73408ce07328Smrg *) 73418ce07328Smrg case "$new_inherited_linker_flags " in 73428ce07328Smrg *" $arg "*) ;; 73438ce07328Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 73448ce07328Smrg esac 73458ce07328Smrg ;; 73468ce07328Smrg esac 73478ce07328Smrg continue 73488ce07328Smrg ;; 73498ce07328Smrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 735042a55b46Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 735142a55b46Smrg func_append compiler_flags " $arg" 735242a55b46Smrg func_append compile_command " $arg" 735342a55b46Smrg func_append finalize_command " $arg" 735442a55b46Smrg case "$new_inherited_linker_flags " in 735542a55b46Smrg *" $arg "*) ;; 735642a55b46Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 735742a55b46Smrg esac 735842a55b46Smrg continue 735942a55b46Smrg ;; 736042a55b46Smrg 736142a55b46Smrg -multi_module) 7362e3d74329Smrg single_module=$wl-multi_module 736342a55b46Smrg continue 736442a55b46Smrg ;; 736542a55b46Smrg 736642a55b46Smrg -no-fast-install) 736742a55b46Smrg fast_install=no 736842a55b46Smrg continue 736942a55b46Smrg ;; 737042a55b46Smrg 737142a55b46Smrg -no-install) 737242a55b46Smrg case $host in 737342a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 737442a55b46Smrg # The PATH hackery in wrapper scripts is required on Windows 737542a55b46Smrg # and Darwin in order for the loader to find any dlls it needs. 7376e3d74329Smrg func_warning "'-no-install' is ignored for $host" 7377e3d74329Smrg func_warning "assuming '-no-fast-install' instead" 737842a55b46Smrg fast_install=no 737942a55b46Smrg ;; 738042a55b46Smrg *) no_install=yes ;; 738142a55b46Smrg esac 738242a55b46Smrg continue 738342a55b46Smrg ;; 738442a55b46Smrg 738542a55b46Smrg -no-undefined) 738642a55b46Smrg allow_undefined=no 738742a55b46Smrg continue 738842a55b46Smrg ;; 738942a55b46Smrg 739042a55b46Smrg -objectlist) 739142a55b46Smrg prev=objectlist 739242a55b46Smrg continue 739342a55b46Smrg ;; 739442a55b46Smrg 7395e3d74329Smrg -os2dllname) 7396e3d74329Smrg prev=os2dllname 7397e3d74329Smrg continue 7398e3d74329Smrg ;; 7399e3d74329Smrg 740042a55b46Smrg -o) prev=output ;; 740142a55b46Smrg 740242a55b46Smrg -precious-files-regex) 740342a55b46Smrg prev=precious_regex 740442a55b46Smrg continue 740542a55b46Smrg ;; 740642a55b46Smrg 740742a55b46Smrg -release) 740842a55b46Smrg prev=release 740942a55b46Smrg continue 741042a55b46Smrg ;; 741142a55b46Smrg 741242a55b46Smrg -rpath) 741342a55b46Smrg prev=rpath 741442a55b46Smrg continue 741542a55b46Smrg ;; 741642a55b46Smrg 741742a55b46Smrg -R) 741842a55b46Smrg prev=xrpath 741942a55b46Smrg continue 742042a55b46Smrg ;; 742142a55b46Smrg 742242a55b46Smrg -R*) 742342a55b46Smrg func_stripname '-R' '' "$arg" 742442a55b46Smrg dir=$func_stripname_result 742542a55b46Smrg # We need an absolute path. 742642a55b46Smrg case $dir in 742742a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 742842a55b46Smrg =*) 742942a55b46Smrg func_stripname '=' '' "$dir" 743042a55b46Smrg dir=$lt_sysroot$func_stripname_result 743142a55b46Smrg ;; 743242a55b46Smrg *) 743342a55b46Smrg func_fatal_error "only absolute run-paths are allowed" 743442a55b46Smrg ;; 743542a55b46Smrg esac 743642a55b46Smrg case "$xrpath " in 743742a55b46Smrg *" $dir "*) ;; 743842a55b46Smrg *) func_append xrpath " $dir" ;; 743942a55b46Smrg esac 744042a55b46Smrg continue 744142a55b46Smrg ;; 744242a55b46Smrg 744342a55b46Smrg -shared) 744442a55b46Smrg # The effects of -shared are defined in a previous loop. 744542a55b46Smrg continue 744642a55b46Smrg ;; 744742a55b46Smrg 744842a55b46Smrg -shrext) 744942a55b46Smrg prev=shrext 745042a55b46Smrg continue 745142a55b46Smrg ;; 745242a55b46Smrg 745342a55b46Smrg -static | -static-libtool-libs) 745442a55b46Smrg # The effects of -static are defined in a previous loop. 745542a55b46Smrg # We used to do the same as -all-static on platforms that 745642a55b46Smrg # didn't have a PIC flag, but the assumption that the effects 745742a55b46Smrg # would be equivalent was wrong. It would break on at least 745842a55b46Smrg # Digital Unix and AIX. 745942a55b46Smrg continue 746042a55b46Smrg ;; 746142a55b46Smrg 746242a55b46Smrg -thread-safe) 746342a55b46Smrg thread_safe=yes 746442a55b46Smrg continue 746542a55b46Smrg ;; 746642a55b46Smrg 746742a55b46Smrg -version-info) 746842a55b46Smrg prev=vinfo 746942a55b46Smrg continue 747042a55b46Smrg ;; 747142a55b46Smrg 747242a55b46Smrg -version-number) 747342a55b46Smrg prev=vinfo 747442a55b46Smrg vinfo_number=yes 747542a55b46Smrg continue 747642a55b46Smrg ;; 747742a55b46Smrg 747842a55b46Smrg -weak) 747942a55b46Smrg prev=weak 748042a55b46Smrg continue 748142a55b46Smrg ;; 748242a55b46Smrg 748342a55b46Smrg -Wc,*) 748442a55b46Smrg func_stripname '-Wc,' '' "$arg" 748542a55b46Smrg args=$func_stripname_result 748642a55b46Smrg arg= 7487e3d74329Smrg save_ifs=$IFS; IFS=, 748842a55b46Smrg for flag in $args; do 7489e3d74329Smrg IFS=$save_ifs 74908ce07328Smrg func_quote_arg pretty "$flag" 74918ce07328Smrg func_append arg " $func_quote_arg_result" 74928ce07328Smrg func_append compiler_flags " $func_quote_arg_result" 749342a55b46Smrg done 7494e3d74329Smrg IFS=$save_ifs 749542a55b46Smrg func_stripname ' ' '' "$arg" 749642a55b46Smrg arg=$func_stripname_result 749742a55b46Smrg ;; 749842a55b46Smrg 749942a55b46Smrg -Wl,*) 750042a55b46Smrg func_stripname '-Wl,' '' "$arg" 750142a55b46Smrg args=$func_stripname_result 750242a55b46Smrg arg= 7503e3d74329Smrg save_ifs=$IFS; IFS=, 750442a55b46Smrg for flag in $args; do 7505e3d74329Smrg IFS=$save_ifs 75068ce07328Smrg func_quote_arg pretty "$flag" 75078ce07328Smrg func_append arg " $wl$func_quote_arg_result" 75088ce07328Smrg func_append compiler_flags " $wl$func_quote_arg_result" 75098ce07328Smrg func_append linker_flags " $func_quote_arg_result" 751042a55b46Smrg done 7511e3d74329Smrg IFS=$save_ifs 751242a55b46Smrg func_stripname ' ' '' "$arg" 751342a55b46Smrg arg=$func_stripname_result 751442a55b46Smrg ;; 751542a55b46Smrg 75168ce07328Smrg -Xassembler) 75178ce07328Smrg prev=xassembler 75188ce07328Smrg continue 75198ce07328Smrg ;; 75208ce07328Smrg 752142a55b46Smrg -Xcompiler) 752242a55b46Smrg prev=xcompiler 752342a55b46Smrg continue 752442a55b46Smrg ;; 752542a55b46Smrg 752642a55b46Smrg -Xlinker) 752742a55b46Smrg prev=xlinker 752842a55b46Smrg continue 752942a55b46Smrg ;; 753042a55b46Smrg 753142a55b46Smrg -XCClinker) 753242a55b46Smrg prev=xcclinker 753342a55b46Smrg continue 753442a55b46Smrg ;; 753542a55b46Smrg 753642a55b46Smrg # -msg_* for osf cc 753742a55b46Smrg -msg_*) 75388ce07328Smrg func_quote_arg pretty "$arg" 75398ce07328Smrg arg=$func_quote_arg_result 754042a55b46Smrg ;; 754142a55b46Smrg 754242a55b46Smrg # Flags to be passed through unchanged, with rationale: 754342a55b46Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 754442a55b46Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 754542a55b46Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 754642a55b46Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 754742a55b46Smrg # -q* compiler args for the IBM compiler 754842a55b46Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 754942a55b46Smrg # -F/path path to uninstalled frameworks, gcc on darwin 755042a55b46Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7551e3d74329Smrg # -fstack-protector* stack protector flags for GCC 755242a55b46Smrg # @file GCC response files 755342a55b46Smrg # -tp=* Portland pgcc target processor selection 755442a55b46Smrg # --sysroot=* for sysroot support 7555e3d74329Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7556cd241713Smrg # -specs=* GCC specs files 7557e3d74329Smrg # -stdlib=* select c++ std lib with clang 7558cd241713Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 75598ce07328Smrg # -fuse-ld=* Linker select flags for GCC 75608ce07328Smrg # -Wa,* Pass flags directly to the assembler 756142a55b46Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 756242a55b46Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7563cd241713Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 75648ce07328Smrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 75658ce07328Smrg func_quote_arg pretty "$arg" 75668ce07328Smrg arg=$func_quote_arg_result 756742a55b46Smrg func_append compile_command " $arg" 756842a55b46Smrg func_append finalize_command " $arg" 756942a55b46Smrg func_append compiler_flags " $arg" 757042a55b46Smrg continue 757142a55b46Smrg ;; 757242a55b46Smrg 7573e3d74329Smrg -Z*) 7574e3d74329Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 7575e3d74329Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 7576e3d74329Smrg compiler_flags="$compiler_flags $arg" 7577e3d74329Smrg func_append compile_command " $arg" 7578e3d74329Smrg func_append finalize_command " $arg" 7579e3d74329Smrg case $arg in 7580e3d74329Smrg -Zlinker | -Zstack) 7581e3d74329Smrg prev=xcompiler 7582e3d74329Smrg ;; 7583e3d74329Smrg esac 7584e3d74329Smrg continue 7585e3d74329Smrg else 7586e3d74329Smrg # Otherwise treat like 'Some other compiler flag' below 75878ce07328Smrg func_quote_arg pretty "$arg" 75888ce07328Smrg arg=$func_quote_arg_result 7589e3d74329Smrg fi 7590e3d74329Smrg ;; 7591e3d74329Smrg 759242a55b46Smrg # Some other compiler flag. 759342a55b46Smrg -* | +*) 75948ce07328Smrg func_quote_arg pretty "$arg" 75958ce07328Smrg arg=$func_quote_arg_result 759642a55b46Smrg ;; 759742a55b46Smrg 759842a55b46Smrg *.$objext) 759942a55b46Smrg # A standard object. 760042a55b46Smrg func_append objs " $arg" 760142a55b46Smrg ;; 760242a55b46Smrg 760342a55b46Smrg *.lo) 760442a55b46Smrg # A libtool-controlled object. 760542a55b46Smrg 760642a55b46Smrg # Check to see that this really is a libtool object. 760742a55b46Smrg if func_lalib_unsafe_p "$arg"; then 760842a55b46Smrg pic_object= 760942a55b46Smrg non_pic_object= 761042a55b46Smrg 761142a55b46Smrg # Read the .lo file 761242a55b46Smrg func_source "$arg" 761342a55b46Smrg 761442a55b46Smrg if test -z "$pic_object" || 761542a55b46Smrg test -z "$non_pic_object" || 7616e3d74329Smrg test none = "$pic_object" && 7617e3d74329Smrg test none = "$non_pic_object"; then 7618e3d74329Smrg func_fatal_error "cannot find name of object for '$arg'" 761942a55b46Smrg fi 762042a55b46Smrg 762142a55b46Smrg # Extract subdirectory from the argument. 762242a55b46Smrg func_dirname "$arg" "/" "" 7623e3d74329Smrg xdir=$func_dirname_result 762442a55b46Smrg 7625e3d74329Smrg test none = "$pic_object" || { 762642a55b46Smrg # Prepend the subdirectory the object is found in. 7627e3d74329Smrg pic_object=$xdir$pic_object 762842a55b46Smrg 7629e3d74329Smrg if test dlfiles = "$prev"; then 7630e3d74329Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 763142a55b46Smrg func_append dlfiles " $pic_object" 763242a55b46Smrg prev= 763342a55b46Smrg continue 763442a55b46Smrg else 763542a55b46Smrg # If libtool objects are unsupported, then we need to preload. 763642a55b46Smrg prev=dlprefiles 763742a55b46Smrg fi 763842a55b46Smrg fi 763942a55b46Smrg 764042a55b46Smrg # CHECK ME: I think I busted this. -Ossama 7641e3d74329Smrg if test dlprefiles = "$prev"; then 764242a55b46Smrg # Preload the old-style object. 764342a55b46Smrg func_append dlprefiles " $pic_object" 764442a55b46Smrg prev= 764542a55b46Smrg fi 764642a55b46Smrg 764742a55b46Smrg # A PIC object. 764842a55b46Smrg func_append libobjs " $pic_object" 7649e3d74329Smrg arg=$pic_object 7650e3d74329Smrg } 765142a55b46Smrg 765242a55b46Smrg # Non-PIC object. 7653e3d74329Smrg if test none != "$non_pic_object"; then 765442a55b46Smrg # Prepend the subdirectory the object is found in. 7655e3d74329Smrg non_pic_object=$xdir$non_pic_object 765642a55b46Smrg 765742a55b46Smrg # A standard non-PIC object 765842a55b46Smrg func_append non_pic_objects " $non_pic_object" 7659e3d74329Smrg if test -z "$pic_object" || test none = "$pic_object"; then 7660e3d74329Smrg arg=$non_pic_object 766142a55b46Smrg fi 766242a55b46Smrg else 766342a55b46Smrg # If the PIC object exists, use it instead. 766442a55b46Smrg # $xdir was prepended to $pic_object above. 7665e3d74329Smrg non_pic_object=$pic_object 766642a55b46Smrg func_append non_pic_objects " $non_pic_object" 766742a55b46Smrg fi 766842a55b46Smrg else 766942a55b46Smrg # Only an error if not doing a dry-run. 767042a55b46Smrg if $opt_dry_run; then 767142a55b46Smrg # Extract subdirectory from the argument. 767242a55b46Smrg func_dirname "$arg" "/" "" 7673e3d74329Smrg xdir=$func_dirname_result 767442a55b46Smrg 767542a55b46Smrg func_lo2o "$arg" 767642a55b46Smrg pic_object=$xdir$objdir/$func_lo2o_result 767742a55b46Smrg non_pic_object=$xdir$func_lo2o_result 767842a55b46Smrg func_append libobjs " $pic_object" 767942a55b46Smrg func_append non_pic_objects " $non_pic_object" 768042a55b46Smrg else 7681e3d74329Smrg func_fatal_error "'$arg' is not a valid libtool object" 768242a55b46Smrg fi 768342a55b46Smrg fi 768442a55b46Smrg ;; 768542a55b46Smrg 768642a55b46Smrg *.$libext) 768742a55b46Smrg # An archive. 768842a55b46Smrg func_append deplibs " $arg" 768942a55b46Smrg func_append old_deplibs " $arg" 769042a55b46Smrg continue 769142a55b46Smrg ;; 769242a55b46Smrg 769342a55b46Smrg *.la) 769442a55b46Smrg # A libtool-controlled library. 769542a55b46Smrg 769642a55b46Smrg func_resolve_sysroot "$arg" 7697e3d74329Smrg if test dlfiles = "$prev"; then 769842a55b46Smrg # This library was specified with -dlopen. 769942a55b46Smrg func_append dlfiles " $func_resolve_sysroot_result" 770042a55b46Smrg prev= 7701e3d74329Smrg elif test dlprefiles = "$prev"; then 770242a55b46Smrg # The library was specified with -dlpreopen. 770342a55b46Smrg func_append dlprefiles " $func_resolve_sysroot_result" 770442a55b46Smrg prev= 770542a55b46Smrg else 770642a55b46Smrg func_append deplibs " $func_resolve_sysroot_result" 770742a55b46Smrg fi 770842a55b46Smrg continue 770942a55b46Smrg ;; 771042a55b46Smrg 771142a55b46Smrg # Some other compiler argument. 771242a55b46Smrg *) 771342a55b46Smrg # Unknown arguments in both finalize_command and compile_command need 771442a55b46Smrg # to be aesthetically quoted because they are evaled later. 77158ce07328Smrg func_quote_arg pretty "$arg" 77168ce07328Smrg arg=$func_quote_arg_result 771742a55b46Smrg ;; 771842a55b46Smrg esac # arg 771942a55b46Smrg 772042a55b46Smrg # Now actually substitute the argument into the commands. 772142a55b46Smrg if test -n "$arg"; then 772242a55b46Smrg func_append compile_command " $arg" 772342a55b46Smrg func_append finalize_command " $arg" 772442a55b46Smrg fi 772542a55b46Smrg done # argument parsing loop 772642a55b46Smrg 772742a55b46Smrg test -n "$prev" && \ 7728e3d74329Smrg func_fatal_help "the '$prevarg' option requires an argument" 772942a55b46Smrg 7730e3d74329Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 773142a55b46Smrg eval arg=\"$export_dynamic_flag_spec\" 773242a55b46Smrg func_append compile_command " $arg" 773342a55b46Smrg func_append finalize_command " $arg" 773442a55b46Smrg fi 773542a55b46Smrg 773642a55b46Smrg oldlibs= 773742a55b46Smrg # calculate the name of the file, without its directory 773842a55b46Smrg func_basename "$output" 7739e3d74329Smrg outputname=$func_basename_result 7740e3d74329Smrg libobjs_save=$libobjs 774142a55b46Smrg 774242a55b46Smrg if test -n "$shlibpath_var"; then 774342a55b46Smrg # get the directories listed in $shlibpath_var 7744e3d74329Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 774542a55b46Smrg else 774642a55b46Smrg shlib_search_path= 774742a55b46Smrg fi 774842a55b46Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 774942a55b46Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 775042a55b46Smrg 7751e3d74329Smrg # Definition is injected by LT_CONFIG during libtool generation. 7752e3d74329Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7753e3d74329Smrg 775442a55b46Smrg func_dirname "$output" "/" "" 7755e3d74329Smrg output_objdir=$func_dirname_result$objdir 775642a55b46Smrg func_to_tool_file "$output_objdir/" 775742a55b46Smrg tool_output_objdir=$func_to_tool_file_result 775842a55b46Smrg # Create the object directory. 775942a55b46Smrg func_mkdir_p "$output_objdir" 776042a55b46Smrg 776142a55b46Smrg # Determine the type of output 776242a55b46Smrg case $output in 776342a55b46Smrg "") 776442a55b46Smrg func_fatal_help "you must specify an output file" 776542a55b46Smrg ;; 776642a55b46Smrg *.$libext) linkmode=oldlib ;; 776742a55b46Smrg *.lo | *.$objext) linkmode=obj ;; 776842a55b46Smrg *.la) linkmode=lib ;; 776942a55b46Smrg *) linkmode=prog ;; # Anything else should be a program. 777042a55b46Smrg esac 777142a55b46Smrg 777242a55b46Smrg specialdeplibs= 777342a55b46Smrg 777442a55b46Smrg libs= 777542a55b46Smrg # Find all interdependent deplibs by searching for libraries 777642a55b46Smrg # that are linked more than once (e.g. -la -lb -la) 777742a55b46Smrg for deplib in $deplibs; do 7778e3d74329Smrg if $opt_preserve_dup_deps; then 777942a55b46Smrg case "$libs " in 778042a55b46Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 778142a55b46Smrg esac 778242a55b46Smrg fi 778342a55b46Smrg func_append libs " $deplib" 778442a55b46Smrg done 778542a55b46Smrg 7786e3d74329Smrg if test lib = "$linkmode"; then 778742a55b46Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 778842a55b46Smrg 778942a55b46Smrg # Compute libraries that are listed more than once in $predeps 779042a55b46Smrg # $postdeps and mark them as special (i.e., whose duplicates are 779142a55b46Smrg # not to be eliminated). 779242a55b46Smrg pre_post_deps= 779342a55b46Smrg if $opt_duplicate_compiler_generated_deps; then 779442a55b46Smrg for pre_post_dep in $predeps $postdeps; do 779542a55b46Smrg case "$pre_post_deps " in 779642a55b46Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 779742a55b46Smrg esac 779842a55b46Smrg func_append pre_post_deps " $pre_post_dep" 779942a55b46Smrg done 780042a55b46Smrg fi 780142a55b46Smrg pre_post_deps= 780242a55b46Smrg fi 780342a55b46Smrg 780442a55b46Smrg deplibs= 780542a55b46Smrg newdependency_libs= 780642a55b46Smrg newlib_search_path= 780742a55b46Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 780842a55b46Smrg notinst_deplibs= # not-installed libtool libraries 780942a55b46Smrg notinst_path= # paths that contain not-installed libtool libraries 781042a55b46Smrg 781142a55b46Smrg case $linkmode in 781242a55b46Smrg lib) 781342a55b46Smrg passes="conv dlpreopen link" 781442a55b46Smrg for file in $dlfiles $dlprefiles; do 781542a55b46Smrg case $file in 781642a55b46Smrg *.la) ;; 781742a55b46Smrg *) 7818e3d74329Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 781942a55b46Smrg ;; 782042a55b46Smrg esac 782142a55b46Smrg done 782242a55b46Smrg ;; 782342a55b46Smrg prog) 782442a55b46Smrg compile_deplibs= 782542a55b46Smrg finalize_deplibs= 7826e3d74329Smrg alldeplibs=false 782742a55b46Smrg newdlfiles= 782842a55b46Smrg newdlprefiles= 782942a55b46Smrg passes="conv scan dlopen dlpreopen link" 783042a55b46Smrg ;; 783142a55b46Smrg *) passes="conv" 783242a55b46Smrg ;; 783342a55b46Smrg esac 783442a55b46Smrg 783542a55b46Smrg for pass in $passes; do 783642a55b46Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 783742a55b46Smrg # so that -L comes before libs that need it for instance... 7838e3d74329Smrg if test lib,link = "$linkmode,$pass"; then 783942a55b46Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 784042a55b46Smrg ## order, and fix it there properly 784142a55b46Smrg tmp_deplibs= 784242a55b46Smrg for deplib in $deplibs; do 784342a55b46Smrg tmp_deplibs="$deplib $tmp_deplibs" 784442a55b46Smrg done 7845e3d74329Smrg deplibs=$tmp_deplibs 784642a55b46Smrg fi 784742a55b46Smrg 7848e3d74329Smrg if test lib,link = "$linkmode,$pass" || 7849e3d74329Smrg test prog,scan = "$linkmode,$pass"; then 7850e3d74329Smrg libs=$deplibs 785142a55b46Smrg deplibs= 785242a55b46Smrg fi 7853e3d74329Smrg if test prog = "$linkmode"; then 785442a55b46Smrg case $pass in 7855e3d74329Smrg dlopen) libs=$dlfiles ;; 7856e3d74329Smrg dlpreopen) libs=$dlprefiles ;; 78578ce07328Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 785842a55b46Smrg esac 785942a55b46Smrg fi 7860e3d74329Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 786142a55b46Smrg # Collect and forward deplibs of preopened libtool libs 786242a55b46Smrg for lib in $dlprefiles; do 786342a55b46Smrg # Ignore non-libtool-libs 786442a55b46Smrg dependency_libs= 786542a55b46Smrg func_resolve_sysroot "$lib" 786642a55b46Smrg case $lib in 786742a55b46Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 786842a55b46Smrg esac 786942a55b46Smrg 787042a55b46Smrg # Collect preopened libtool deplibs, except any this library 787142a55b46Smrg # has declared as weak libs 787242a55b46Smrg for deplib in $dependency_libs; do 787342a55b46Smrg func_basename "$deplib" 787442a55b46Smrg deplib_base=$func_basename_result 787542a55b46Smrg case " $weak_libs " in 787642a55b46Smrg *" $deplib_base "*) ;; 787742a55b46Smrg *) func_append deplibs " $deplib" ;; 787842a55b46Smrg esac 787942a55b46Smrg done 788042a55b46Smrg done 7881e3d74329Smrg libs=$dlprefiles 788242a55b46Smrg fi 7883e3d74329Smrg if test dlopen = "$pass"; then 788442a55b46Smrg # Collect dlpreopened libraries 7885e3d74329Smrg save_deplibs=$deplibs 788642a55b46Smrg deplibs= 788742a55b46Smrg fi 788842a55b46Smrg 788942a55b46Smrg for deplib in $libs; do 789042a55b46Smrg lib= 7891e3d74329Smrg found=false 789242a55b46Smrg case $deplib in 789342a55b46Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 789442a55b46Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7895e3d74329Smrg if test prog,link = "$linkmode,$pass"; then 789642a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 789742a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 789842a55b46Smrg else 789942a55b46Smrg func_append compiler_flags " $deplib" 7900e3d74329Smrg if test lib = "$linkmode"; then 790142a55b46Smrg case "$new_inherited_linker_flags " in 790242a55b46Smrg *" $deplib "*) ;; 790342a55b46Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 790442a55b46Smrg esac 790542a55b46Smrg fi 790642a55b46Smrg fi 790742a55b46Smrg continue 790842a55b46Smrg ;; 790942a55b46Smrg -l*) 7910e3d74329Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 7911e3d74329Smrg func_warning "'-l' is ignored for archives/objects" 791242a55b46Smrg continue 791342a55b46Smrg fi 791442a55b46Smrg func_stripname '-l' '' "$deplib" 791542a55b46Smrg name=$func_stripname_result 7916e3d74329Smrg if test lib = "$linkmode"; then 791742a55b46Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 791842a55b46Smrg else 791942a55b46Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 792042a55b46Smrg fi 792142a55b46Smrg for searchdir in $searchdirs; do 792242a55b46Smrg for search_ext in .la $std_shrext .so .a; do 792342a55b46Smrg # Search the libtool library 7924e3d74329Smrg lib=$searchdir/lib$name$search_ext 792542a55b46Smrg if test -f "$lib"; then 7926e3d74329Smrg if test .la = "$search_ext"; then 7927e3d74329Smrg found=: 792842a55b46Smrg else 7929e3d74329Smrg found=false 793042a55b46Smrg fi 793142a55b46Smrg break 2 793242a55b46Smrg fi 793342a55b46Smrg done 793442a55b46Smrg done 7935e3d74329Smrg if $found; then 7936e3d74329Smrg # deplib is a libtool library 793742a55b46Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 793842a55b46Smrg # We need to do some special things here, and not later. 7939e3d74329Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 794042a55b46Smrg case " $predeps $postdeps " in 794142a55b46Smrg *" $deplib "*) 794242a55b46Smrg if func_lalib_p "$lib"; then 794342a55b46Smrg library_names= 794442a55b46Smrg old_library= 794542a55b46Smrg func_source "$lib" 794642a55b46Smrg for l in $old_library $library_names; do 7947e3d74329Smrg ll=$l 794842a55b46Smrg done 7949e3d74329Smrg if test "X$ll" = "X$old_library"; then # only static version available 7950e3d74329Smrg found=false 795142a55b46Smrg func_dirname "$lib" "" "." 7952e3d74329Smrg ladir=$func_dirname_result 795342a55b46Smrg lib=$ladir/$old_library 7954e3d74329Smrg if test prog,link = "$linkmode,$pass"; then 795542a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 795642a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 795742a55b46Smrg else 795842a55b46Smrg deplibs="$deplib $deplibs" 7959e3d74329Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 796042a55b46Smrg fi 796142a55b46Smrg continue 796242a55b46Smrg fi 796342a55b46Smrg fi 796442a55b46Smrg ;; 796542a55b46Smrg *) ;; 796642a55b46Smrg esac 796742a55b46Smrg fi 7968e3d74329Smrg else 7969e3d74329Smrg # deplib doesn't seem to be a libtool library 7970e3d74329Smrg if test prog,link = "$linkmode,$pass"; then 7971e3d74329Smrg compile_deplibs="$deplib $compile_deplibs" 7972e3d74329Smrg finalize_deplibs="$deplib $finalize_deplibs" 7973e3d74329Smrg else 7974e3d74329Smrg deplibs="$deplib $deplibs" 7975e3d74329Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7976e3d74329Smrg fi 7977e3d74329Smrg continue 797842a55b46Smrg fi 797942a55b46Smrg ;; # -l 798042a55b46Smrg *.ltframework) 7981e3d74329Smrg if test prog,link = "$linkmode,$pass"; then 798242a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 798342a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 798442a55b46Smrg else 798542a55b46Smrg deplibs="$deplib $deplibs" 7986e3d74329Smrg if test lib = "$linkmode"; then 798742a55b46Smrg case "$new_inherited_linker_flags " in 798842a55b46Smrg *" $deplib "*) ;; 798942a55b46Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 799042a55b46Smrg esac 799142a55b46Smrg fi 799242a55b46Smrg fi 799342a55b46Smrg continue 799442a55b46Smrg ;; 799542a55b46Smrg -L*) 799642a55b46Smrg case $linkmode in 799742a55b46Smrg lib) 799842a55b46Smrg deplibs="$deplib $deplibs" 7999e3d74329Smrg test conv = "$pass" && continue 800042a55b46Smrg newdependency_libs="$deplib $newdependency_libs" 800142a55b46Smrg func_stripname '-L' '' "$deplib" 800242a55b46Smrg func_resolve_sysroot "$func_stripname_result" 800342a55b46Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 800442a55b46Smrg ;; 800542a55b46Smrg prog) 8006e3d74329Smrg if test conv = "$pass"; then 800742a55b46Smrg deplibs="$deplib $deplibs" 800842a55b46Smrg continue 800942a55b46Smrg fi 8010e3d74329Smrg if test scan = "$pass"; then 801142a55b46Smrg deplibs="$deplib $deplibs" 801242a55b46Smrg else 801342a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 801442a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 801542a55b46Smrg fi 801642a55b46Smrg func_stripname '-L' '' "$deplib" 801742a55b46Smrg func_resolve_sysroot "$func_stripname_result" 801842a55b46Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 801942a55b46Smrg ;; 802042a55b46Smrg *) 8021e3d74329Smrg func_warning "'-L' is ignored for archives/objects" 802242a55b46Smrg ;; 802342a55b46Smrg esac # linkmode 802442a55b46Smrg continue 802542a55b46Smrg ;; # -L 802642a55b46Smrg -R*) 8027e3d74329Smrg if test link = "$pass"; then 802842a55b46Smrg func_stripname '-R' '' "$deplib" 802942a55b46Smrg func_resolve_sysroot "$func_stripname_result" 803042a55b46Smrg dir=$func_resolve_sysroot_result 803142a55b46Smrg # Make sure the xrpath contains only unique directories. 803242a55b46Smrg case "$xrpath " in 803342a55b46Smrg *" $dir "*) ;; 803442a55b46Smrg *) func_append xrpath " $dir" ;; 803542a55b46Smrg esac 803642a55b46Smrg fi 803742a55b46Smrg deplibs="$deplib $deplibs" 803842a55b46Smrg continue 803942a55b46Smrg ;; 804042a55b46Smrg *.la) 804142a55b46Smrg func_resolve_sysroot "$deplib" 804242a55b46Smrg lib=$func_resolve_sysroot_result 804342a55b46Smrg ;; 804442a55b46Smrg *.$libext) 8045e3d74329Smrg if test conv = "$pass"; then 804642a55b46Smrg deplibs="$deplib $deplibs" 804742a55b46Smrg continue 804842a55b46Smrg fi 804942a55b46Smrg case $linkmode in 805042a55b46Smrg lib) 805142a55b46Smrg # Linking convenience modules into shared libraries is allowed, 805242a55b46Smrg # but linking other static libraries is non-portable. 805342a55b46Smrg case " $dlpreconveniencelibs " in 805442a55b46Smrg *" $deplib "*) ;; 805542a55b46Smrg *) 8056e3d74329Smrg valid_a_lib=false 805742a55b46Smrg case $deplibs_check_method in 805842a55b46Smrg match_pattern*) 805942a55b46Smrg set dummy $deplibs_check_method; shift 806042a55b46Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 806142a55b46Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 806242a55b46Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 8063e3d74329Smrg valid_a_lib=: 806442a55b46Smrg fi 806542a55b46Smrg ;; 806642a55b46Smrg pass_all) 8067e3d74329Smrg valid_a_lib=: 806842a55b46Smrg ;; 806942a55b46Smrg esac 8070e3d74329Smrg if $valid_a_lib; then 8071e3d74329Smrg echo 8072e3d74329Smrg $ECHO "*** Warning: Linking the shared library $output against the" 8073e3d74329Smrg $ECHO "*** static library $deplib is not portable!" 8074e3d74329Smrg deplibs="$deplib $deplibs" 8075e3d74329Smrg else 807642a55b46Smrg echo 807742a55b46Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 807842a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 807942a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 808042a55b46Smrg echo "*** shared version of the library, which you do not appear to have" 808142a55b46Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 808242a55b46Smrg echo "*** that it is just a static archive that I should not use here." 808342a55b46Smrg fi 808442a55b46Smrg ;; 808542a55b46Smrg esac 808642a55b46Smrg continue 808742a55b46Smrg ;; 808842a55b46Smrg prog) 8089e3d74329Smrg if test link != "$pass"; then 809042a55b46Smrg deplibs="$deplib $deplibs" 809142a55b46Smrg else 809242a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 809342a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 809442a55b46Smrg fi 809542a55b46Smrg continue 809642a55b46Smrg ;; 809742a55b46Smrg esac # linkmode 809842a55b46Smrg ;; # *.$libext 809942a55b46Smrg *.lo | *.$objext) 8100e3d74329Smrg if test conv = "$pass"; then 810142a55b46Smrg deplibs="$deplib $deplibs" 8102e3d74329Smrg elif test prog = "$linkmode"; then 8103e3d74329Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 810442a55b46Smrg # If there is no dlopen support or we're linking statically, 810542a55b46Smrg # we need to preload. 810642a55b46Smrg func_append newdlprefiles " $deplib" 810742a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 810842a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 810942a55b46Smrg else 811042a55b46Smrg func_append newdlfiles " $deplib" 811142a55b46Smrg fi 811242a55b46Smrg fi 811342a55b46Smrg continue 811442a55b46Smrg ;; 811542a55b46Smrg %DEPLIBS%) 8116e3d74329Smrg alldeplibs=: 811742a55b46Smrg continue 811842a55b46Smrg ;; 811942a55b46Smrg esac # case $deplib 812042a55b46Smrg 8121e3d74329Smrg $found || test -f "$lib" \ 8122e3d74329Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 812342a55b46Smrg 812442a55b46Smrg # Check to see that this really is a libtool archive. 812542a55b46Smrg func_lalib_unsafe_p "$lib" \ 8126e3d74329Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 812742a55b46Smrg 812842a55b46Smrg func_dirname "$lib" "" "." 8129e3d74329Smrg ladir=$func_dirname_result 813042a55b46Smrg 813142a55b46Smrg dlname= 813242a55b46Smrg dlopen= 813342a55b46Smrg dlpreopen= 813442a55b46Smrg libdir= 813542a55b46Smrg library_names= 813642a55b46Smrg old_library= 813742a55b46Smrg inherited_linker_flags= 813842a55b46Smrg # If the library was installed with an old release of libtool, 813942a55b46Smrg # it will not redefine variables installed, or shouldnotlink 814042a55b46Smrg installed=yes 814142a55b46Smrg shouldnotlink=no 814242a55b46Smrg avoidtemprpath= 814342a55b46Smrg 814442a55b46Smrg 814542a55b46Smrg # Read the .la file 814642a55b46Smrg func_source "$lib" 814742a55b46Smrg 814842a55b46Smrg # Convert "-framework foo" to "foo.ltframework" 814942a55b46Smrg if test -n "$inherited_linker_flags"; then 815042a55b46Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 815142a55b46Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 815242a55b46Smrg case " $new_inherited_linker_flags " in 815342a55b46Smrg *" $tmp_inherited_linker_flag "*) ;; 815442a55b46Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 815542a55b46Smrg esac 815642a55b46Smrg done 815742a55b46Smrg fi 815842a55b46Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8159e3d74329Smrg if test lib,link = "$linkmode,$pass" || 8160e3d74329Smrg test prog,scan = "$linkmode,$pass" || 8161e3d74329Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 816242a55b46Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 816342a55b46Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 816442a55b46Smrg fi 816542a55b46Smrg 8166e3d74329Smrg if test conv = "$pass"; then 816742a55b46Smrg # Only check for convenience libraries 816842a55b46Smrg deplibs="$lib $deplibs" 816942a55b46Smrg if test -z "$libdir"; then 817042a55b46Smrg if test -z "$old_library"; then 8171e3d74329Smrg func_fatal_error "cannot find name of link library for '$lib'" 817242a55b46Smrg fi 817342a55b46Smrg # It is a libtool convenience library, so add in its objects. 817442a55b46Smrg func_append convenience " $ladir/$objdir/$old_library" 817542a55b46Smrg func_append old_convenience " $ladir/$objdir/$old_library" 8176e3d74329Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 8177e3d74329Smrg func_fatal_error "'$lib' is not a convenience library" 817842a55b46Smrg fi 81798ce07328Smrg tmp_libs= 81808ce07328Smrg for deplib in $dependency_libs; do 81818ce07328Smrg deplibs="$deplib $deplibs" 81828ce07328Smrg if $opt_preserve_dup_deps; then 81838ce07328Smrg case "$tmp_libs " in 81848ce07328Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 81858ce07328Smrg esac 81868ce07328Smrg fi 81878ce07328Smrg func_append tmp_libs " $deplib" 81888ce07328Smrg done 818942a55b46Smrg continue 819042a55b46Smrg fi # $pass = conv 819142a55b46Smrg 819242a55b46Smrg 819342a55b46Smrg # Get the name of the library we link against. 819442a55b46Smrg linklib= 819542a55b46Smrg if test -n "$old_library" && 8196e3d74329Smrg { test yes = "$prefer_static_libs" || 8197e3d74329Smrg test built,no = "$prefer_static_libs,$installed"; }; then 819842a55b46Smrg linklib=$old_library 819942a55b46Smrg else 820042a55b46Smrg for l in $old_library $library_names; do 8201e3d74329Smrg linklib=$l 820242a55b46Smrg done 820342a55b46Smrg fi 820442a55b46Smrg if test -z "$linklib"; then 8205e3d74329Smrg func_fatal_error "cannot find name of link library for '$lib'" 820642a55b46Smrg fi 820742a55b46Smrg 820842a55b46Smrg # This library was specified with -dlopen. 8209e3d74329Smrg if test dlopen = "$pass"; then 8210e3d74329Smrg test -z "$libdir" \ 8211e3d74329Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 821242a55b46Smrg if test -z "$dlname" || 8213e3d74329Smrg test yes != "$dlopen_support" || 8214e3d74329Smrg test no = "$build_libtool_libs" 8215e3d74329Smrg then 821642a55b46Smrg # If there is no dlname, no dlopen support or we're linking 821742a55b46Smrg # statically, we need to preload. We also need to preload any 821842a55b46Smrg # dependent libraries so libltdl's deplib preloader doesn't 821942a55b46Smrg # bomb out in the load deplibs phase. 822042a55b46Smrg func_append dlprefiles " $lib $dependency_libs" 822142a55b46Smrg else 822242a55b46Smrg func_append newdlfiles " $lib" 822342a55b46Smrg fi 822442a55b46Smrg continue 822542a55b46Smrg fi # $pass = dlopen 822642a55b46Smrg 822742a55b46Smrg # We need an absolute path. 822842a55b46Smrg case $ladir in 8229e3d74329Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 823042a55b46Smrg *) 823142a55b46Smrg abs_ladir=`cd "$ladir" && pwd` 823242a55b46Smrg if test -z "$abs_ladir"; then 8233e3d74329Smrg func_warning "cannot determine absolute directory name of '$ladir'" 823442a55b46Smrg func_warning "passing it literally to the linker, although it might fail" 8235e3d74329Smrg abs_ladir=$ladir 823642a55b46Smrg fi 823742a55b46Smrg ;; 823842a55b46Smrg esac 823942a55b46Smrg func_basename "$lib" 8240e3d74329Smrg laname=$func_basename_result 824142a55b46Smrg 824242a55b46Smrg # Find the relevant object directory and library name. 8243e3d74329Smrg if test yes = "$installed"; then 824442a55b46Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8245e3d74329Smrg func_warning "library '$lib' was moved." 8246e3d74329Smrg dir=$ladir 8247e3d74329Smrg absdir=$abs_ladir 8248e3d74329Smrg libdir=$abs_ladir 824942a55b46Smrg else 8250e3d74329Smrg dir=$lt_sysroot$libdir 8251e3d74329Smrg absdir=$lt_sysroot$libdir 825242a55b46Smrg fi 8253e3d74329Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 825442a55b46Smrg else 825542a55b46Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8256e3d74329Smrg dir=$ladir 8257e3d74329Smrg absdir=$abs_ladir 825842a55b46Smrg # Remove this search path later 825942a55b46Smrg func_append notinst_path " $abs_ladir" 826042a55b46Smrg else 8261e3d74329Smrg dir=$ladir/$objdir 8262e3d74329Smrg absdir=$abs_ladir/$objdir 826342a55b46Smrg # Remove this search path later 826442a55b46Smrg func_append notinst_path " $abs_ladir" 826542a55b46Smrg fi 826642a55b46Smrg fi # $installed = yes 826742a55b46Smrg func_stripname 'lib' '.la' "$laname" 826842a55b46Smrg name=$func_stripname_result 826942a55b46Smrg 827042a55b46Smrg # This library was specified with -dlpreopen. 8271e3d74329Smrg if test dlpreopen = "$pass"; then 8272e3d74329Smrg if test -z "$libdir" && test prog = "$linkmode"; then 8273e3d74329Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 827442a55b46Smrg fi 8275e3d74329Smrg case $host in 827642a55b46Smrg # special handling for platforms with PE-DLLs. 827742a55b46Smrg *cygwin* | *mingw* | *cegcc* ) 827842a55b46Smrg # Linker will automatically link against shared library if both 827942a55b46Smrg # static and shared are present. Therefore, ensure we extract 828042a55b46Smrg # symbols from the import library if a shared library is present 828142a55b46Smrg # (otherwise, the dlopen module name will be incorrect). We do 828242a55b46Smrg # this by putting the import library name into $newdlprefiles. 828342a55b46Smrg # We recover the dlopen module name by 'saving' the la file 828442a55b46Smrg # name in a special purpose variable, and (later) extracting the 828542a55b46Smrg # dlname from the la file. 828642a55b46Smrg if test -n "$dlname"; then 828742a55b46Smrg func_tr_sh "$dir/$linklib" 828842a55b46Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 828942a55b46Smrg func_append newdlprefiles " $dir/$linklib" 829042a55b46Smrg else 829142a55b46Smrg func_append newdlprefiles " $dir/$old_library" 829242a55b46Smrg # Keep a list of preopened convenience libraries to check 829342a55b46Smrg # that they are being used correctly in the link pass. 829442a55b46Smrg test -z "$libdir" && \ 829542a55b46Smrg func_append dlpreconveniencelibs " $dir/$old_library" 829642a55b46Smrg fi 829742a55b46Smrg ;; 829842a55b46Smrg * ) 829942a55b46Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 830042a55b46Smrg # are required to link). 830142a55b46Smrg if test -n "$old_library"; then 830242a55b46Smrg func_append newdlprefiles " $dir/$old_library" 830342a55b46Smrg # Keep a list of preopened convenience libraries to check 830442a55b46Smrg # that they are being used correctly in the link pass. 830542a55b46Smrg test -z "$libdir" && \ 830642a55b46Smrg func_append dlpreconveniencelibs " $dir/$old_library" 830742a55b46Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 830842a55b46Smrg elif test -n "$dlname"; then 830942a55b46Smrg func_append newdlprefiles " $dir/$dlname" 831042a55b46Smrg else 831142a55b46Smrg func_append newdlprefiles " $dir/$linklib" 831242a55b46Smrg fi 831342a55b46Smrg ;; 831442a55b46Smrg esac 831542a55b46Smrg fi # $pass = dlpreopen 831642a55b46Smrg 831742a55b46Smrg if test -z "$libdir"; then 831842a55b46Smrg # Link the convenience library 8319e3d74329Smrg if test lib = "$linkmode"; then 832042a55b46Smrg deplibs="$dir/$old_library $deplibs" 8321e3d74329Smrg elif test prog,link = "$linkmode,$pass"; then 832242a55b46Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 832342a55b46Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 832442a55b46Smrg else 832542a55b46Smrg deplibs="$lib $deplibs" # used for prog,scan pass 832642a55b46Smrg fi 832742a55b46Smrg continue 832842a55b46Smrg fi 832942a55b46Smrg 833042a55b46Smrg 8331e3d74329Smrg if test prog = "$linkmode" && test link != "$pass"; then 833242a55b46Smrg func_append newlib_search_path " $ladir" 833342a55b46Smrg deplibs="$lib $deplibs" 833442a55b46Smrg 8335e3d74329Smrg linkalldeplibs=false 8336e3d74329Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 8337e3d74329Smrg test no = "$build_libtool_libs"; then 8338e3d74329Smrg linkalldeplibs=: 833942a55b46Smrg fi 834042a55b46Smrg 834142a55b46Smrg tmp_libs= 834242a55b46Smrg for deplib in $dependency_libs; do 834342a55b46Smrg case $deplib in 834442a55b46Smrg -L*) func_stripname '-L' '' "$deplib" 834542a55b46Smrg func_resolve_sysroot "$func_stripname_result" 834642a55b46Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 834742a55b46Smrg ;; 834842a55b46Smrg esac 834942a55b46Smrg # Need to link against all dependency_libs? 8350e3d74329Smrg if $linkalldeplibs; then 835142a55b46Smrg deplibs="$deplib $deplibs" 835242a55b46Smrg else 835342a55b46Smrg # Need to hardcode shared library paths 835442a55b46Smrg # or/and link against static libraries 835542a55b46Smrg newdependency_libs="$deplib $newdependency_libs" 835642a55b46Smrg fi 8357e3d74329Smrg if $opt_preserve_dup_deps; then 835842a55b46Smrg case "$tmp_libs " in 835942a55b46Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 836042a55b46Smrg esac 836142a55b46Smrg fi 836242a55b46Smrg func_append tmp_libs " $deplib" 836342a55b46Smrg done # for deplib 836442a55b46Smrg continue 836542a55b46Smrg fi # $linkmode = prog... 836642a55b46Smrg 8367e3d74329Smrg if test prog,link = "$linkmode,$pass"; then 836842a55b46Smrg if test -n "$library_names" && 8369e3d74329Smrg { { test no = "$prefer_static_libs" || 8370e3d74329Smrg test built,yes = "$prefer_static_libs,$installed"; } || 837142a55b46Smrg test -z "$old_library"; }; then 837242a55b46Smrg # We need to hardcode the library path 8373e3d74329Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 837442a55b46Smrg # Make sure the rpath contains only unique directories. 8375e3d74329Smrg case $temp_rpath: in 837642a55b46Smrg *"$absdir:"*) ;; 837742a55b46Smrg *) func_append temp_rpath "$absdir:" ;; 837842a55b46Smrg esac 837942a55b46Smrg fi 838042a55b46Smrg 838142a55b46Smrg # Hardcode the library path. 838242a55b46Smrg # Skip directories that are in the system default run-time 838342a55b46Smrg # search path. 838442a55b46Smrg case " $sys_lib_dlsearch_path " in 838542a55b46Smrg *" $absdir "*) ;; 838642a55b46Smrg *) 838742a55b46Smrg case "$compile_rpath " in 838842a55b46Smrg *" $absdir "*) ;; 838942a55b46Smrg *) func_append compile_rpath " $absdir" ;; 839042a55b46Smrg esac 839142a55b46Smrg ;; 839242a55b46Smrg esac 839342a55b46Smrg case " $sys_lib_dlsearch_path " in 839442a55b46Smrg *" $libdir "*) ;; 839542a55b46Smrg *) 839642a55b46Smrg case "$finalize_rpath " in 839742a55b46Smrg *" $libdir "*) ;; 839842a55b46Smrg *) func_append finalize_rpath " $libdir" ;; 839942a55b46Smrg esac 840042a55b46Smrg ;; 840142a55b46Smrg esac 840242a55b46Smrg fi # $linkmode,$pass = prog,link... 840342a55b46Smrg 8404e3d74329Smrg if $alldeplibs && 8405e3d74329Smrg { test pass_all = "$deplibs_check_method" || 8406e3d74329Smrg { test yes = "$build_libtool_libs" && 840742a55b46Smrg test -n "$library_names"; }; }; then 840842a55b46Smrg # We only need to search for static libraries 840942a55b46Smrg continue 841042a55b46Smrg fi 841142a55b46Smrg fi 841242a55b46Smrg 841342a55b46Smrg link_static=no # Whether the deplib will be linked statically 841442a55b46Smrg use_static_libs=$prefer_static_libs 8415e3d74329Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 841642a55b46Smrg use_static_libs=no 841742a55b46Smrg fi 841842a55b46Smrg if test -n "$library_names" && 8419e3d74329Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 842042a55b46Smrg case $host in 8421e3d74329Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 842242a55b46Smrg # No point in relinking DLLs because paths are not encoded 842342a55b46Smrg func_append notinst_deplibs " $lib" 842442a55b46Smrg need_relink=no 842542a55b46Smrg ;; 842642a55b46Smrg *) 8427e3d74329Smrg if test no = "$installed"; then 842842a55b46Smrg func_append notinst_deplibs " $lib" 842942a55b46Smrg need_relink=yes 843042a55b46Smrg fi 843142a55b46Smrg ;; 843242a55b46Smrg esac 843342a55b46Smrg # This is a shared library 843442a55b46Smrg 843542a55b46Smrg # Warn about portability, can't link against -module's on some 843642a55b46Smrg # systems (darwin). Don't bleat about dlopened modules though! 8437e3d74329Smrg dlopenmodule= 843842a55b46Smrg for dlpremoduletest in $dlprefiles; do 843942a55b46Smrg if test "X$dlpremoduletest" = "X$lib"; then 8440e3d74329Smrg dlopenmodule=$dlpremoduletest 844142a55b46Smrg break 844242a55b46Smrg fi 844342a55b46Smrg done 8444e3d74329Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 844542a55b46Smrg echo 8446e3d74329Smrg if test prog = "$linkmode"; then 844742a55b46Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 844842a55b46Smrg else 844942a55b46Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 845042a55b46Smrg fi 845142a55b46Smrg $ECHO "*** $linklib is not portable!" 845242a55b46Smrg fi 8453e3d74329Smrg if test lib = "$linkmode" && 8454e3d74329Smrg test yes = "$hardcode_into_libs"; then 845542a55b46Smrg # Hardcode the library path. 845642a55b46Smrg # Skip directories that are in the system default run-time 845742a55b46Smrg # search path. 845842a55b46Smrg case " $sys_lib_dlsearch_path " in 845942a55b46Smrg *" $absdir "*) ;; 846042a55b46Smrg *) 846142a55b46Smrg case "$compile_rpath " in 846242a55b46Smrg *" $absdir "*) ;; 846342a55b46Smrg *) func_append compile_rpath " $absdir" ;; 846442a55b46Smrg esac 846542a55b46Smrg ;; 846642a55b46Smrg esac 846742a55b46Smrg case " $sys_lib_dlsearch_path " in 846842a55b46Smrg *" $libdir "*) ;; 846942a55b46Smrg *) 847042a55b46Smrg case "$finalize_rpath " in 847142a55b46Smrg *" $libdir "*) ;; 847242a55b46Smrg *) func_append finalize_rpath " $libdir" ;; 847342a55b46Smrg esac 847442a55b46Smrg ;; 847542a55b46Smrg esac 847642a55b46Smrg fi 847742a55b46Smrg 847842a55b46Smrg if test -n "$old_archive_from_expsyms_cmds"; then 847942a55b46Smrg # figure out the soname 848042a55b46Smrg set dummy $library_names 848142a55b46Smrg shift 8482e3d74329Smrg realname=$1 848342a55b46Smrg shift 848442a55b46Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 848542a55b46Smrg # use dlname if we got it. it's perfectly good, no? 848642a55b46Smrg if test -n "$dlname"; then 8487e3d74329Smrg soname=$dlname 848842a55b46Smrg elif test -n "$soname_spec"; then 848942a55b46Smrg # bleh windows 849042a55b46Smrg case $host in 8491e3d74329Smrg *cygwin* | mingw* | *cegcc* | *os2*) 849242a55b46Smrg func_arith $current - $age 849342a55b46Smrg major=$func_arith_result 8494e3d74329Smrg versuffix=-$major 849542a55b46Smrg ;; 849642a55b46Smrg esac 849742a55b46Smrg eval soname=\"$soname_spec\" 849842a55b46Smrg else 8499e3d74329Smrg soname=$realname 850042a55b46Smrg fi 850142a55b46Smrg 850242a55b46Smrg # Make a new name for the extract_expsyms_cmds to use 8503e3d74329Smrg soroot=$soname 850442a55b46Smrg func_basename "$soroot" 8505e3d74329Smrg soname=$func_basename_result 850642a55b46Smrg func_stripname 'lib' '.dll' "$soname" 850742a55b46Smrg newlib=libimp-$func_stripname_result.a 850842a55b46Smrg 850942a55b46Smrg # If the library has no export list, then create one now 851042a55b46Smrg if test -f "$output_objdir/$soname-def"; then : 851142a55b46Smrg else 8512e3d74329Smrg func_verbose "extracting exported symbol list from '$soname'" 851342a55b46Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 851442a55b46Smrg fi 851542a55b46Smrg 851642a55b46Smrg # Create $newlib 851742a55b46Smrg if test -f "$output_objdir/$newlib"; then :; else 8518e3d74329Smrg func_verbose "generating import library for '$soname'" 851942a55b46Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 852042a55b46Smrg fi 852142a55b46Smrg # make sure the library variables are pointing to the new library 852242a55b46Smrg dir=$output_objdir 852342a55b46Smrg linklib=$newlib 852442a55b46Smrg fi # test -n "$old_archive_from_expsyms_cmds" 852542a55b46Smrg 8526e3d74329Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 852742a55b46Smrg add_shlibpath= 852842a55b46Smrg add_dir= 852942a55b46Smrg add= 853042a55b46Smrg lib_linked=yes 853142a55b46Smrg case $hardcode_action in 853242a55b46Smrg immediate | unsupported) 8533e3d74329Smrg if test no = "$hardcode_direct"; then 8534e3d74329Smrg add=$dir/$linklib 853542a55b46Smrg case $host in 8536e3d74329Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8537e3d74329Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 853842a55b46Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8539e3d74329Smrg *-*-unixware7*) add_dir=-L$dir ;; 854042a55b46Smrg *-*-darwin* ) 8541e3d74329Smrg # if the lib is a (non-dlopened) module then we cannot 854242a55b46Smrg # link against it, someone is ignoring the earlier warnings 854342a55b46Smrg if /usr/bin/file -L $add 2> /dev/null | 8544e3d74329Smrg $GREP ": [^:]* bundle" >/dev/null; then 854542a55b46Smrg if test "X$dlopenmodule" != "X$lib"; then 854642a55b46Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8547e3d74329Smrg if test -z "$old_library"; then 854842a55b46Smrg echo 854942a55b46Smrg echo "*** And there doesn't seem to be a static archive available" 855042a55b46Smrg echo "*** The link will probably fail, sorry" 855142a55b46Smrg else 8552e3d74329Smrg add=$dir/$old_library 855342a55b46Smrg fi 855442a55b46Smrg elif test -n "$old_library"; then 8555e3d74329Smrg add=$dir/$old_library 855642a55b46Smrg fi 855742a55b46Smrg fi 855842a55b46Smrg esac 8559e3d74329Smrg elif test no = "$hardcode_minus_L"; then 856042a55b46Smrg case $host in 8561e3d74329Smrg *-*-sunos*) add_shlibpath=$dir ;; 856242a55b46Smrg esac 8563e3d74329Smrg add_dir=-L$dir 8564e3d74329Smrg add=-l$name 8565e3d74329Smrg elif test no = "$hardcode_shlibpath_var"; then 8566e3d74329Smrg add_shlibpath=$dir 8567e3d74329Smrg add=-l$name 856842a55b46Smrg else 856942a55b46Smrg lib_linked=no 857042a55b46Smrg fi 857142a55b46Smrg ;; 857242a55b46Smrg relink) 8573e3d74329Smrg if test yes = "$hardcode_direct" && 8574e3d74329Smrg test no = "$hardcode_direct_absolute"; then 8575e3d74329Smrg add=$dir/$linklib 8576e3d74329Smrg elif test yes = "$hardcode_minus_L"; then 8577e3d74329Smrg add_dir=-L$absdir 857842a55b46Smrg # Try looking first in the location we're being installed to. 857942a55b46Smrg if test -n "$inst_prefix_dir"; then 858042a55b46Smrg case $libdir in 858142a55b46Smrg [\\/]*) 858242a55b46Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 858342a55b46Smrg ;; 858442a55b46Smrg esac 858542a55b46Smrg fi 8586e3d74329Smrg add=-l$name 8587e3d74329Smrg elif test yes = "$hardcode_shlibpath_var"; then 8588e3d74329Smrg add_shlibpath=$dir 8589e3d74329Smrg add=-l$name 859042a55b46Smrg else 859142a55b46Smrg lib_linked=no 859242a55b46Smrg fi 859342a55b46Smrg ;; 859442a55b46Smrg *) lib_linked=no ;; 859542a55b46Smrg esac 859642a55b46Smrg 8597e3d74329Smrg if test yes != "$lib_linked"; then 859842a55b46Smrg func_fatal_configuration "unsupported hardcode properties" 859942a55b46Smrg fi 860042a55b46Smrg 860142a55b46Smrg if test -n "$add_shlibpath"; then 860242a55b46Smrg case :$compile_shlibpath: in 860342a55b46Smrg *":$add_shlibpath:"*) ;; 860442a55b46Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 860542a55b46Smrg esac 860642a55b46Smrg fi 8607e3d74329Smrg if test prog = "$linkmode"; then 860842a55b46Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 860942a55b46Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 861042a55b46Smrg else 861142a55b46Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 861242a55b46Smrg test -n "$add" && deplibs="$add $deplibs" 8613e3d74329Smrg if test yes != "$hardcode_direct" && 8614e3d74329Smrg test yes != "$hardcode_minus_L" && 8615e3d74329Smrg test yes = "$hardcode_shlibpath_var"; then 861642a55b46Smrg case :$finalize_shlibpath: in 861742a55b46Smrg *":$libdir:"*) ;; 861842a55b46Smrg *) func_append finalize_shlibpath "$libdir:" ;; 861942a55b46Smrg esac 862042a55b46Smrg fi 862142a55b46Smrg fi 862242a55b46Smrg fi 862342a55b46Smrg 8624e3d74329Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 862542a55b46Smrg add_shlibpath= 862642a55b46Smrg add_dir= 862742a55b46Smrg add= 862842a55b46Smrg # Finalize command for both is simple: just hardcode it. 8629e3d74329Smrg if test yes = "$hardcode_direct" && 8630e3d74329Smrg test no = "$hardcode_direct_absolute"; then 8631e3d74329Smrg add=$libdir/$linklib 8632e3d74329Smrg elif test yes = "$hardcode_minus_L"; then 8633e3d74329Smrg add_dir=-L$libdir 8634e3d74329Smrg add=-l$name 8635e3d74329Smrg elif test yes = "$hardcode_shlibpath_var"; then 863642a55b46Smrg case :$finalize_shlibpath: in 863742a55b46Smrg *":$libdir:"*) ;; 863842a55b46Smrg *) func_append finalize_shlibpath "$libdir:" ;; 863942a55b46Smrg esac 8640e3d74329Smrg add=-l$name 8641e3d74329Smrg elif test yes = "$hardcode_automatic"; then 864242a55b46Smrg if test -n "$inst_prefix_dir" && 8643e3d74329Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 8644e3d74329Smrg add=$inst_prefix_dir$libdir/$linklib 864542a55b46Smrg else 8646e3d74329Smrg add=$libdir/$linklib 864742a55b46Smrg fi 864842a55b46Smrg else 864942a55b46Smrg # We cannot seem to hardcode it, guess we'll fake it. 8650e3d74329Smrg add_dir=-L$libdir 865142a55b46Smrg # Try looking first in the location we're being installed to. 865242a55b46Smrg if test -n "$inst_prefix_dir"; then 865342a55b46Smrg case $libdir in 865442a55b46Smrg [\\/]*) 865542a55b46Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 865642a55b46Smrg ;; 865742a55b46Smrg esac 865842a55b46Smrg fi 8659e3d74329Smrg add=-l$name 866042a55b46Smrg fi 866142a55b46Smrg 8662e3d74329Smrg if test prog = "$linkmode"; then 866342a55b46Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 866442a55b46Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 866542a55b46Smrg else 866642a55b46Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 866742a55b46Smrg test -n "$add" && deplibs="$add $deplibs" 866842a55b46Smrg fi 866942a55b46Smrg fi 8670e3d74329Smrg elif test prog = "$linkmode"; then 867142a55b46Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 867242a55b46Smrg # is not unsupported. This is valid on all known static and 867342a55b46Smrg # shared platforms. 8674e3d74329Smrg if test unsupported != "$hardcode_direct"; then 8675e3d74329Smrg test -n "$old_library" && linklib=$old_library 867642a55b46Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 867742a55b46Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 867842a55b46Smrg else 867942a55b46Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 868042a55b46Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 868142a55b46Smrg fi 8682e3d74329Smrg elif test yes = "$build_libtool_libs"; then 868342a55b46Smrg # Not a shared library 8684e3d74329Smrg if test pass_all != "$deplibs_check_method"; then 868542a55b46Smrg # We're trying link a shared library against a static one 868642a55b46Smrg # but the system doesn't support it. 868742a55b46Smrg 868842a55b46Smrg # Just print a warning and add the library to dependency_libs so 868942a55b46Smrg # that the program can be linked against the static library. 869042a55b46Smrg echo 8691e3d74329Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 869242a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 869342a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 869442a55b46Smrg echo "*** shared version of the library, which you do not appear to have." 8695e3d74329Smrg if test yes = "$module"; then 869642a55b46Smrg echo "*** But as you try to build a module library, libtool will still create " 869742a55b46Smrg echo "*** a static module, that should work as long as the dlopening application" 869842a55b46Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 869942a55b46Smrg if test -z "$global_symbol_pipe"; then 870042a55b46Smrg echo 870142a55b46Smrg echo "*** However, this would only work if libtool was able to extract symbol" 8702e3d74329Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 870342a55b46Smrg echo "*** not find such a program. So, this module is probably useless." 8704e3d74329Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 870542a55b46Smrg fi 8706e3d74329Smrg if test no = "$build_old_libs"; then 870742a55b46Smrg build_libtool_libs=module 870842a55b46Smrg build_old_libs=yes 870942a55b46Smrg else 871042a55b46Smrg build_libtool_libs=no 871142a55b46Smrg fi 871242a55b46Smrg fi 871342a55b46Smrg else 871442a55b46Smrg deplibs="$dir/$old_library $deplibs" 871542a55b46Smrg link_static=yes 871642a55b46Smrg fi 871742a55b46Smrg fi # link shared/static library? 871842a55b46Smrg 8719e3d74329Smrg if test lib = "$linkmode"; then 872042a55b46Smrg if test -n "$dependency_libs" && 8721e3d74329Smrg { test yes != "$hardcode_into_libs" || 8722e3d74329Smrg test yes = "$build_old_libs" || 8723e3d74329Smrg test yes = "$link_static"; }; then 872442a55b46Smrg # Extract -R from dependency_libs 872542a55b46Smrg temp_deplibs= 872642a55b46Smrg for libdir in $dependency_libs; do 872742a55b46Smrg case $libdir in 872842a55b46Smrg -R*) func_stripname '-R' '' "$libdir" 872942a55b46Smrg temp_xrpath=$func_stripname_result 873042a55b46Smrg case " $xrpath " in 873142a55b46Smrg *" $temp_xrpath "*) ;; 873242a55b46Smrg *) func_append xrpath " $temp_xrpath";; 873342a55b46Smrg esac;; 873442a55b46Smrg *) func_append temp_deplibs " $libdir";; 873542a55b46Smrg esac 873642a55b46Smrg done 8737e3d74329Smrg dependency_libs=$temp_deplibs 873842a55b46Smrg fi 873942a55b46Smrg 874042a55b46Smrg func_append newlib_search_path " $absdir" 874142a55b46Smrg # Link against this library 8742e3d74329Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 874342a55b46Smrg # ... and its dependency_libs 874442a55b46Smrg tmp_libs= 874542a55b46Smrg for deplib in $dependency_libs; do 874642a55b46Smrg newdependency_libs="$deplib $newdependency_libs" 874742a55b46Smrg case $deplib in 874842a55b46Smrg -L*) func_stripname '-L' '' "$deplib" 874942a55b46Smrg func_resolve_sysroot "$func_stripname_result";; 875042a55b46Smrg *) func_resolve_sysroot "$deplib" ;; 875142a55b46Smrg esac 8752e3d74329Smrg if $opt_preserve_dup_deps; then 875342a55b46Smrg case "$tmp_libs " in 875442a55b46Smrg *" $func_resolve_sysroot_result "*) 875542a55b46Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 875642a55b46Smrg esac 875742a55b46Smrg fi 875842a55b46Smrg func_append tmp_libs " $func_resolve_sysroot_result" 875942a55b46Smrg done 876042a55b46Smrg 8761e3d74329Smrg if test no != "$link_all_deplibs"; then 876242a55b46Smrg # Add the search paths of all dependency libraries 876342a55b46Smrg for deplib in $dependency_libs; do 876442a55b46Smrg path= 876542a55b46Smrg case $deplib in 8766e3d74329Smrg -L*) path=$deplib ;; 876742a55b46Smrg *.la) 876842a55b46Smrg func_resolve_sysroot "$deplib" 876942a55b46Smrg deplib=$func_resolve_sysroot_result 877042a55b46Smrg func_dirname "$deplib" "" "." 877142a55b46Smrg dir=$func_dirname_result 877242a55b46Smrg # We need an absolute path. 877342a55b46Smrg case $dir in 8774e3d74329Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 877542a55b46Smrg *) 877642a55b46Smrg absdir=`cd "$dir" && pwd` 877742a55b46Smrg if test -z "$absdir"; then 8778e3d74329Smrg func_warning "cannot determine absolute directory name of '$dir'" 8779e3d74329Smrg absdir=$dir 878042a55b46Smrg fi 878142a55b46Smrg ;; 878242a55b46Smrg esac 878342a55b46Smrg if $GREP "^installed=no" $deplib > /dev/null; then 878442a55b46Smrg case $host in 878542a55b46Smrg *-*-darwin*) 878642a55b46Smrg depdepl= 8787e3d74329Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8788e3d74329Smrg if test -n "$deplibrary_names"; then 8789e3d74329Smrg for tmp in $deplibrary_names; do 879042a55b46Smrg depdepl=$tmp 879142a55b46Smrg done 8792e3d74329Smrg if test -f "$absdir/$objdir/$depdepl"; then 8793e3d74329Smrg depdepl=$absdir/$objdir/$depdepl 8794e3d74329Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 879542a55b46Smrg if test -z "$darwin_install_name"; then 8796e3d74329Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 879742a55b46Smrg fi 8798e3d74329Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8799e3d74329Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 880042a55b46Smrg path= 880142a55b46Smrg fi 880242a55b46Smrg fi 880342a55b46Smrg ;; 880442a55b46Smrg *) 8805e3d74329Smrg path=-L$absdir/$objdir 880642a55b46Smrg ;; 880742a55b46Smrg esac 880842a55b46Smrg else 8809e3d74329Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 881042a55b46Smrg test -z "$libdir" && \ 8811e3d74329Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 881242a55b46Smrg test "$absdir" != "$libdir" && \ 8813e3d74329Smrg func_warning "'$deplib' seems to be moved" 881442a55b46Smrg 8815e3d74329Smrg path=-L$absdir 881642a55b46Smrg fi 881742a55b46Smrg ;; 881842a55b46Smrg esac 881942a55b46Smrg case " $deplibs " in 882042a55b46Smrg *" $path "*) ;; 882142a55b46Smrg *) deplibs="$path $deplibs" ;; 882242a55b46Smrg esac 882342a55b46Smrg done 882442a55b46Smrg fi # link_all_deplibs != no 882542a55b46Smrg fi # linkmode = lib 882642a55b46Smrg done # for deplib in $libs 8827e3d74329Smrg if test link = "$pass"; then 8828e3d74329Smrg if test prog = "$linkmode"; then 882942a55b46Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 883042a55b46Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 883142a55b46Smrg else 883242a55b46Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 883342a55b46Smrg fi 883442a55b46Smrg fi 8835e3d74329Smrg dependency_libs=$newdependency_libs 8836e3d74329Smrg if test dlpreopen = "$pass"; then 883742a55b46Smrg # Link the dlpreopened libraries before other libraries 883842a55b46Smrg for deplib in $save_deplibs; do 883942a55b46Smrg deplibs="$deplib $deplibs" 884042a55b46Smrg done 884142a55b46Smrg fi 8842e3d74329Smrg if test dlopen != "$pass"; then 8843e3d74329Smrg test conv = "$pass" || { 884442a55b46Smrg # Make sure lib_search_path contains only unique directories. 884542a55b46Smrg lib_search_path= 884642a55b46Smrg for dir in $newlib_search_path; do 884742a55b46Smrg case "$lib_search_path " in 884842a55b46Smrg *" $dir "*) ;; 884942a55b46Smrg *) func_append lib_search_path " $dir" ;; 885042a55b46Smrg esac 885142a55b46Smrg done 885242a55b46Smrg newlib_search_path= 8853e3d74329Smrg } 885442a55b46Smrg 8855e3d74329Smrg if test prog,link = "$linkmode,$pass"; then 885642a55b46Smrg vars="compile_deplibs finalize_deplibs" 8857e3d74329Smrg else 8858e3d74329Smrg vars=deplibs 885942a55b46Smrg fi 886042a55b46Smrg for var in $vars dependency_libs; do 886142a55b46Smrg # Add libraries to $var in reverse order 886242a55b46Smrg eval tmp_libs=\"\$$var\" 886342a55b46Smrg new_libs= 886442a55b46Smrg for deplib in $tmp_libs; do 886542a55b46Smrg # FIXME: Pedantically, this is the right thing to do, so 886642a55b46Smrg # that some nasty dependency loop isn't accidentally 886742a55b46Smrg # broken: 886842a55b46Smrg #new_libs="$deplib $new_libs" 886942a55b46Smrg # Pragmatically, this seems to cause very few problems in 887042a55b46Smrg # practice: 887142a55b46Smrg case $deplib in 887242a55b46Smrg -L*) new_libs="$deplib $new_libs" ;; 887342a55b46Smrg -R*) ;; 887442a55b46Smrg *) 887542a55b46Smrg # And here is the reason: when a library appears more 887642a55b46Smrg # than once as an explicit dependence of a library, or 887742a55b46Smrg # is implicitly linked in more than once by the 887842a55b46Smrg # compiler, it is considered special, and multiple 887942a55b46Smrg # occurrences thereof are not removed. Compare this 888042a55b46Smrg # with having the same library being listed as a 888142a55b46Smrg # dependency of multiple other libraries: in this case, 888242a55b46Smrg # we know (pedantically, we assume) the library does not 888342a55b46Smrg # need to be listed more than once, so we keep only the 888442a55b46Smrg # last copy. This is not always right, but it is rare 888542a55b46Smrg # enough that we require users that really mean to play 888642a55b46Smrg # such unportable linking tricks to link the library 888742a55b46Smrg # using -Wl,-lname, so that libtool does not consider it 888842a55b46Smrg # for duplicate removal. 888942a55b46Smrg case " $specialdeplibs " in 889042a55b46Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 889142a55b46Smrg *) 889242a55b46Smrg case " $new_libs " in 889342a55b46Smrg *" $deplib "*) ;; 889442a55b46Smrg *) new_libs="$deplib $new_libs" ;; 889542a55b46Smrg esac 889642a55b46Smrg ;; 889742a55b46Smrg esac 889842a55b46Smrg ;; 889942a55b46Smrg esac 890042a55b46Smrg done 890142a55b46Smrg tmp_libs= 890242a55b46Smrg for deplib in $new_libs; do 890342a55b46Smrg case $deplib in 890442a55b46Smrg -L*) 890542a55b46Smrg case " $tmp_libs " in 890642a55b46Smrg *" $deplib "*) ;; 890742a55b46Smrg *) func_append tmp_libs " $deplib" ;; 890842a55b46Smrg esac 890942a55b46Smrg ;; 891042a55b46Smrg *) func_append tmp_libs " $deplib" ;; 891142a55b46Smrg esac 891242a55b46Smrg done 891342a55b46Smrg eval $var=\"$tmp_libs\" 891442a55b46Smrg done # for var 891542a55b46Smrg fi 8916e3d74329Smrg 8917e3d74329Smrg # Add Sun CC postdeps if required: 8918e3d74329Smrg test CXX = "$tagname" && { 8919e3d74329Smrg case $host_os in 8920e3d74329Smrg linux*) 89218ce07328Smrg case `$CC -V 2>&1 | $SED 5q` in 8922e3d74329Smrg *Sun\ C*) # Sun C++ 5.9 8923e3d74329Smrg func_suncc_cstd_abi 8924e3d74329Smrg 8925e3d74329Smrg if test no != "$suncc_use_cstd_abi"; then 8926e3d74329Smrg func_append postdeps ' -library=Cstd -library=Crun' 8927e3d74329Smrg fi 8928e3d74329Smrg ;; 8929e3d74329Smrg esac 8930e3d74329Smrg ;; 8931e3d74329Smrg 8932e3d74329Smrg solaris*) 8933e3d74329Smrg func_cc_basename "$CC" 8934e3d74329Smrg case $func_cc_basename_result in 8935e3d74329Smrg CC* | sunCC*) 8936e3d74329Smrg func_suncc_cstd_abi 8937e3d74329Smrg 8938e3d74329Smrg if test no != "$suncc_use_cstd_abi"; then 8939e3d74329Smrg func_append postdeps ' -library=Cstd -library=Crun' 8940e3d74329Smrg fi 8941e3d74329Smrg ;; 8942e3d74329Smrg esac 8943e3d74329Smrg ;; 8944e3d74329Smrg esac 8945e3d74329Smrg } 8946e3d74329Smrg 894742a55b46Smrg # Last step: remove runtime libs from dependency_libs 894842a55b46Smrg # (they stay in deplibs) 894942a55b46Smrg tmp_libs= 8950e3d74329Smrg for i in $dependency_libs; do 895142a55b46Smrg case " $predeps $postdeps $compiler_lib_search_path " in 895242a55b46Smrg *" $i "*) 8953e3d74329Smrg i= 895442a55b46Smrg ;; 895542a55b46Smrg esac 8956e3d74329Smrg if test -n "$i"; then 895742a55b46Smrg func_append tmp_libs " $i" 895842a55b46Smrg fi 895942a55b46Smrg done 896042a55b46Smrg dependency_libs=$tmp_libs 896142a55b46Smrg done # for pass 8962e3d74329Smrg if test prog = "$linkmode"; then 8963e3d74329Smrg dlfiles=$newdlfiles 896442a55b46Smrg fi 8965e3d74329Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 8966e3d74329Smrg dlprefiles=$newdlprefiles 896742a55b46Smrg fi 896842a55b46Smrg 896942a55b46Smrg case $linkmode in 897042a55b46Smrg oldlib) 8971e3d74329Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8972e3d74329Smrg func_warning "'-dlopen' is ignored for archives" 897342a55b46Smrg fi 897442a55b46Smrg 897542a55b46Smrg case " $deplibs" in 897642a55b46Smrg *\ -l* | *\ -L*) 8977e3d74329Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 897842a55b46Smrg esac 897942a55b46Smrg 898042a55b46Smrg test -n "$rpath" && \ 8981e3d74329Smrg func_warning "'-rpath' is ignored for archives" 898242a55b46Smrg 898342a55b46Smrg test -n "$xrpath" && \ 8984e3d74329Smrg func_warning "'-R' is ignored for archives" 898542a55b46Smrg 898642a55b46Smrg test -n "$vinfo" && \ 8987e3d74329Smrg func_warning "'-version-info/-version-number' is ignored for archives" 898842a55b46Smrg 898942a55b46Smrg test -n "$release" && \ 8990e3d74329Smrg func_warning "'-release' is ignored for archives" 899142a55b46Smrg 899242a55b46Smrg test -n "$export_symbols$export_symbols_regex" && \ 8993e3d74329Smrg func_warning "'-export-symbols' is ignored for archives" 899442a55b46Smrg 899542a55b46Smrg # Now set the variables for building old libraries. 899642a55b46Smrg build_libtool_libs=no 8997e3d74329Smrg oldlibs=$output 899842a55b46Smrg func_append objs "$old_deplibs" 899942a55b46Smrg ;; 900042a55b46Smrg 900142a55b46Smrg lib) 9002e3d74329Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 900342a55b46Smrg case $outputname in 900442a55b46Smrg lib*) 900542a55b46Smrg func_stripname 'lib' '.la' "$outputname" 900642a55b46Smrg name=$func_stripname_result 900742a55b46Smrg eval shared_ext=\"$shrext_cmds\" 900842a55b46Smrg eval libname=\"$libname_spec\" 900942a55b46Smrg ;; 901042a55b46Smrg *) 9011e3d74329Smrg test no = "$module" \ 9012e3d74329Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 901342a55b46Smrg 9014e3d74329Smrg if test no != "$need_lib_prefix"; then 901542a55b46Smrg # Add the "lib" prefix for modules if required 901642a55b46Smrg func_stripname '' '.la' "$outputname" 901742a55b46Smrg name=$func_stripname_result 901842a55b46Smrg eval shared_ext=\"$shrext_cmds\" 901942a55b46Smrg eval libname=\"$libname_spec\" 902042a55b46Smrg else 902142a55b46Smrg func_stripname '' '.la' "$outputname" 902242a55b46Smrg libname=$func_stripname_result 902342a55b46Smrg fi 902442a55b46Smrg ;; 902542a55b46Smrg esac 902642a55b46Smrg 902742a55b46Smrg if test -n "$objs"; then 9028e3d74329Smrg if test pass_all != "$deplibs_check_method"; then 9029e3d74329Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 903042a55b46Smrg else 903142a55b46Smrg echo 903242a55b46Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 903342a55b46Smrg $ECHO "*** objects $objs is not portable!" 903442a55b46Smrg func_append libobjs " $objs" 903542a55b46Smrg fi 903642a55b46Smrg fi 903742a55b46Smrg 9038e3d74329Smrg test no = "$dlself" \ 9039e3d74329Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 904042a55b46Smrg 904142a55b46Smrg set dummy $rpath 904242a55b46Smrg shift 9043e3d74329Smrg test 1 -lt "$#" \ 9044e3d74329Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 904542a55b46Smrg 9046e3d74329Smrg install_libdir=$1 904742a55b46Smrg 904842a55b46Smrg oldlibs= 904942a55b46Smrg if test -z "$rpath"; then 9050e3d74329Smrg if test yes = "$build_libtool_libs"; then 905142a55b46Smrg # Building a libtool convenience library. 9052e3d74329Smrg # Some compilers have problems with a '.al' extension so 905342a55b46Smrg # convenience libraries should have the same extension an 905442a55b46Smrg # archive normally would. 905542a55b46Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 905642a55b46Smrg build_libtool_libs=convenience 905742a55b46Smrg build_old_libs=yes 905842a55b46Smrg fi 905942a55b46Smrg 906042a55b46Smrg test -n "$vinfo" && \ 9061e3d74329Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 906242a55b46Smrg 906342a55b46Smrg test -n "$release" && \ 9064e3d74329Smrg func_warning "'-release' is ignored for convenience libraries" 906542a55b46Smrg else 906642a55b46Smrg 906742a55b46Smrg # Parse the version information argument. 9068e3d74329Smrg save_ifs=$IFS; IFS=: 906942a55b46Smrg set dummy $vinfo 0 0 0 907042a55b46Smrg shift 9071e3d74329Smrg IFS=$save_ifs 907242a55b46Smrg 907342a55b46Smrg test -n "$7" && \ 9074e3d74329Smrg func_fatal_help "too many parameters to '-version-info'" 907542a55b46Smrg 907642a55b46Smrg # convert absolute version numbers to libtool ages 907742a55b46Smrg # this retains compatibility with .la files and attempts 907842a55b46Smrg # to make the code below a bit more comprehensible 907942a55b46Smrg 908042a55b46Smrg case $vinfo_number in 908142a55b46Smrg yes) 9082e3d74329Smrg number_major=$1 9083e3d74329Smrg number_minor=$2 9084e3d74329Smrg number_revision=$3 908542a55b46Smrg # 908642a55b46Smrg # There are really only two kinds -- those that 908742a55b46Smrg # use the current revision as the major version 908842a55b46Smrg # and those that subtract age and use age as 908942a55b46Smrg # a minor version. But, then there is irix 9090e3d74329Smrg # that has an extra 1 added just for fun 909142a55b46Smrg # 909242a55b46Smrg case $version_type in 909342a55b46Smrg # correct linux to gnu/linux during the next big refactor 90948ce07328Smrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 909542a55b46Smrg func_arith $number_major + $number_minor 909642a55b46Smrg current=$func_arith_result 9097e3d74329Smrg age=$number_minor 9098e3d74329Smrg revision=$number_revision 909942a55b46Smrg ;; 9100e3d74329Smrg freebsd-aout|qnx|sunos) 9101e3d74329Smrg current=$number_major 9102e3d74329Smrg revision=$number_minor 9103e3d74329Smrg age=0 910442a55b46Smrg ;; 910542a55b46Smrg irix|nonstopux) 910642a55b46Smrg func_arith $number_major + $number_minor 910742a55b46Smrg current=$func_arith_result 9108e3d74329Smrg age=$number_minor 9109e3d74329Smrg revision=$number_minor 911042a55b46Smrg lt_irix_increment=no 911142a55b46Smrg ;; 911242a55b46Smrg esac 911342a55b46Smrg ;; 911442a55b46Smrg no) 9115e3d74329Smrg current=$1 9116e3d74329Smrg revision=$2 9117e3d74329Smrg age=$3 911842a55b46Smrg ;; 911942a55b46Smrg esac 912042a55b46Smrg 912142a55b46Smrg # Check that each of the things are valid numbers. 912242a55b46Smrg case $current in 912342a55b46Smrg 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]) ;; 912442a55b46Smrg *) 9125e3d74329Smrg func_error "CURRENT '$current' must be a nonnegative integer" 9126e3d74329Smrg func_fatal_error "'$vinfo' is not valid version information" 912742a55b46Smrg ;; 912842a55b46Smrg esac 912942a55b46Smrg 913042a55b46Smrg case $revision in 913142a55b46Smrg 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]) ;; 913242a55b46Smrg *) 9133e3d74329Smrg func_error "REVISION '$revision' must be a nonnegative integer" 9134e3d74329Smrg func_fatal_error "'$vinfo' is not valid version information" 913542a55b46Smrg ;; 913642a55b46Smrg esac 913742a55b46Smrg 913842a55b46Smrg case $age in 913942a55b46Smrg 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]) ;; 914042a55b46Smrg *) 9141e3d74329Smrg func_error "AGE '$age' must be a nonnegative integer" 9142e3d74329Smrg func_fatal_error "'$vinfo' is not valid version information" 914342a55b46Smrg ;; 914442a55b46Smrg esac 914542a55b46Smrg 914642a55b46Smrg if test "$age" -gt "$current"; then 9147e3d74329Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 9148e3d74329Smrg func_fatal_error "'$vinfo' is not valid version information" 914942a55b46Smrg fi 915042a55b46Smrg 915142a55b46Smrg # Calculate the version variables. 915242a55b46Smrg major= 915342a55b46Smrg versuffix= 915442a55b46Smrg verstring= 915542a55b46Smrg case $version_type in 915642a55b46Smrg none) ;; 915742a55b46Smrg 915842a55b46Smrg darwin) 915942a55b46Smrg # Like Linux, but with the current version available in 916042a55b46Smrg # verstring for coding it into the library header 916142a55b46Smrg func_arith $current - $age 916242a55b46Smrg major=.$func_arith_result 9163e3d74329Smrg versuffix=$major.$age.$revision 916442a55b46Smrg # Darwin ld doesn't like 0 for these options... 916542a55b46Smrg func_arith $current + 1 916642a55b46Smrg minor_current=$func_arith_result 9167e3d74329Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 916842a55b46Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9169e3d74329Smrg # On Darwin other compilers 9170e3d74329Smrg case $CC in 9171e3d74329Smrg nagfor*) 9172e3d74329Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9173e3d74329Smrg ;; 9174e3d74329Smrg *) 9175e3d74329Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9176e3d74329Smrg ;; 9177e3d74329Smrg esac 917842a55b46Smrg ;; 917942a55b46Smrg 918042a55b46Smrg freebsd-aout) 9181e3d74329Smrg major=.$current 9182e3d74329Smrg versuffix=.$current.$revision 918342a55b46Smrg ;; 918442a55b46Smrg 91858ce07328Smrg freebsd-elf | midnightbsd-elf) 9186e3d74329Smrg func_arith $current - $age 9187e3d74329Smrg major=.$func_arith_result 9188e3d74329Smrg versuffix=$major.$age.$revision 918942a55b46Smrg ;; 919042a55b46Smrg 919142a55b46Smrg irix | nonstopux) 9192e3d74329Smrg if test no = "$lt_irix_increment"; then 919342a55b46Smrg func_arith $current - $age 919442a55b46Smrg else 919542a55b46Smrg func_arith $current - $age + 1 919642a55b46Smrg fi 919742a55b46Smrg major=$func_arith_result 919842a55b46Smrg 919942a55b46Smrg case $version_type in 920042a55b46Smrg nonstopux) verstring_prefix=nonstopux ;; 920142a55b46Smrg *) verstring_prefix=sgi ;; 920242a55b46Smrg esac 9203e3d74329Smrg verstring=$verstring_prefix$major.$revision 920442a55b46Smrg 920542a55b46Smrg # Add in all the interfaces that we are compatible with. 920642a55b46Smrg loop=$revision 9207e3d74329Smrg while test 0 -ne "$loop"; do 920842a55b46Smrg func_arith $revision - $loop 920942a55b46Smrg iface=$func_arith_result 921042a55b46Smrg func_arith $loop - 1 921142a55b46Smrg loop=$func_arith_result 9212e3d74329Smrg verstring=$verstring_prefix$major.$iface:$verstring 921342a55b46Smrg done 921442a55b46Smrg 9215e3d74329Smrg # Before this point, $major must not contain '.'. 921642a55b46Smrg major=.$major 9217e3d74329Smrg versuffix=$major.$revision 921842a55b46Smrg ;; 921942a55b46Smrg 922042a55b46Smrg linux) # correct to gnu/linux during the next big refactor 922142a55b46Smrg func_arith $current - $age 922242a55b46Smrg major=.$func_arith_result 9223e3d74329Smrg versuffix=$major.$age.$revision 922442a55b46Smrg ;; 922542a55b46Smrg 922642a55b46Smrg osf) 922742a55b46Smrg func_arith $current - $age 922842a55b46Smrg major=.$func_arith_result 9229e3d74329Smrg versuffix=.$current.$age.$revision 9230e3d74329Smrg verstring=$current.$age.$revision 923142a55b46Smrg 923242a55b46Smrg # Add in all the interfaces that we are compatible with. 923342a55b46Smrg loop=$age 9234e3d74329Smrg while test 0 -ne "$loop"; do 923542a55b46Smrg func_arith $current - $loop 923642a55b46Smrg iface=$func_arith_result 923742a55b46Smrg func_arith $loop - 1 923842a55b46Smrg loop=$func_arith_result 9239e3d74329Smrg verstring=$verstring:$iface.0 924042a55b46Smrg done 924142a55b46Smrg 924242a55b46Smrg # Make executables depend on our current version. 9243e3d74329Smrg func_append verstring ":$current.0" 924442a55b46Smrg ;; 924542a55b46Smrg 924642a55b46Smrg qnx) 9247e3d74329Smrg major=.$current 9248e3d74329Smrg versuffix=.$current 9249e3d74329Smrg ;; 9250e3d74329Smrg 9251e3d74329Smrg sco) 9252e3d74329Smrg major=.$current 9253e3d74329Smrg versuffix=.$current 925442a55b46Smrg ;; 925542a55b46Smrg 925642a55b46Smrg sunos) 9257e3d74329Smrg major=.$current 9258e3d74329Smrg versuffix=.$current.$revision 925942a55b46Smrg ;; 926042a55b46Smrg 926142a55b46Smrg windows) 926242a55b46Smrg # Use '-' rather than '.', since we only want one 9263e3d74329Smrg # extension on DOS 8.3 file systems. 926442a55b46Smrg func_arith $current - $age 926542a55b46Smrg major=$func_arith_result 9266e3d74329Smrg versuffix=-$major 926742a55b46Smrg ;; 926842a55b46Smrg 926942a55b46Smrg *) 9270e3d74329Smrg func_fatal_configuration "unknown library version type '$version_type'" 927142a55b46Smrg ;; 927242a55b46Smrg esac 927342a55b46Smrg 927442a55b46Smrg # Clear the version info if we defaulted, and they specified a release. 927542a55b46Smrg if test -z "$vinfo" && test -n "$release"; then 927642a55b46Smrg major= 927742a55b46Smrg case $version_type in 927842a55b46Smrg darwin) 927942a55b46Smrg # we can't check for "0.0" in archive_cmds due to quoting 928042a55b46Smrg # problems, so we reset it completely 928142a55b46Smrg verstring= 928242a55b46Smrg ;; 928342a55b46Smrg *) 9284e3d74329Smrg verstring=0.0 928542a55b46Smrg ;; 928642a55b46Smrg esac 9287e3d74329Smrg if test no = "$need_version"; then 928842a55b46Smrg versuffix= 928942a55b46Smrg else 9290e3d74329Smrg versuffix=.0.0 929142a55b46Smrg fi 929242a55b46Smrg fi 929342a55b46Smrg 929442a55b46Smrg # Remove version info from name if versioning should be avoided 9295e3d74329Smrg if test yes,no = "$avoid_version,$need_version"; then 929642a55b46Smrg major= 929742a55b46Smrg versuffix= 9298e3d74329Smrg verstring= 929942a55b46Smrg fi 930042a55b46Smrg 930142a55b46Smrg # Check to see if the archive will have undefined symbols. 9302e3d74329Smrg if test yes = "$allow_undefined"; then 9303e3d74329Smrg if test unsupported = "$allow_undefined_flag"; then 9304e3d74329Smrg if test yes = "$build_old_libs"; then 9305e3d74329Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9306e3d74329Smrg build_libtool_libs=no 9307e3d74329Smrg else 9308e3d74329Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9309e3d74329Smrg fi 931042a55b46Smrg fi 931142a55b46Smrg else 931242a55b46Smrg # Don't allow undefined symbols. 9313e3d74329Smrg allow_undefined_flag=$no_undefined_flag 931442a55b46Smrg fi 931542a55b46Smrg 931642a55b46Smrg fi 931742a55b46Smrg 9318e3d74329Smrg func_generate_dlsyms "$libname" "$libname" : 931942a55b46Smrg func_append libobjs " $symfileobj" 9320e3d74329Smrg test " " = "$libobjs" && libobjs= 932142a55b46Smrg 9322e3d74329Smrg if test relink != "$opt_mode"; then 932342a55b46Smrg # Remove our outputs, but don't remove object files since they 932442a55b46Smrg # may have been created when compiling PIC objects. 932542a55b46Smrg removelist= 932642a55b46Smrg tempremovelist=`$ECHO "$output_objdir/*"` 932742a55b46Smrg for p in $tempremovelist; do 932842a55b46Smrg case $p in 932942a55b46Smrg *.$objext | *.gcno) 933042a55b46Smrg ;; 9331e3d74329Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9332e3d74329Smrg if test -n "$precious_files_regex"; then 933342a55b46Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 933442a55b46Smrg then 933542a55b46Smrg continue 933642a55b46Smrg fi 933742a55b46Smrg fi 933842a55b46Smrg func_append removelist " $p" 933942a55b46Smrg ;; 934042a55b46Smrg *) ;; 934142a55b46Smrg esac 934242a55b46Smrg done 934342a55b46Smrg test -n "$removelist" && \ 934442a55b46Smrg func_show_eval "${RM}r \$removelist" 934542a55b46Smrg fi 934642a55b46Smrg 934742a55b46Smrg # Now set the variables for building old libraries. 9348e3d74329Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 934942a55b46Smrg func_append oldlibs " $output_objdir/$libname.$libext" 935042a55b46Smrg 935142a55b46Smrg # Transform .lo files to .o files. 9352e3d74329Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 935342a55b46Smrg fi 935442a55b46Smrg 935542a55b46Smrg # Eliminate all temporary directories. 935642a55b46Smrg #for path in $notinst_path; do 935742a55b46Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 935842a55b46Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 935942a55b46Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 936042a55b46Smrg #done 936142a55b46Smrg 936242a55b46Smrg if test -n "$xrpath"; then 936342a55b46Smrg # If the user specified any rpath flags, then add them. 936442a55b46Smrg temp_xrpath= 936542a55b46Smrg for libdir in $xrpath; do 936642a55b46Smrg func_replace_sysroot "$libdir" 936742a55b46Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 936842a55b46Smrg case "$finalize_rpath " in 936942a55b46Smrg *" $libdir "*) ;; 937042a55b46Smrg *) func_append finalize_rpath " $libdir" ;; 937142a55b46Smrg esac 937242a55b46Smrg done 9373e3d74329Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 937442a55b46Smrg dependency_libs="$temp_xrpath $dependency_libs" 937542a55b46Smrg fi 937642a55b46Smrg fi 937742a55b46Smrg 937842a55b46Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 9379e3d74329Smrg old_dlfiles=$dlfiles 938042a55b46Smrg dlfiles= 938142a55b46Smrg for lib in $old_dlfiles; do 938242a55b46Smrg case " $dlprefiles $dlfiles " in 938342a55b46Smrg *" $lib "*) ;; 938442a55b46Smrg *) func_append dlfiles " $lib" ;; 938542a55b46Smrg esac 938642a55b46Smrg done 938742a55b46Smrg 938842a55b46Smrg # Make sure dlprefiles contains only unique files 9389e3d74329Smrg old_dlprefiles=$dlprefiles 939042a55b46Smrg dlprefiles= 939142a55b46Smrg for lib in $old_dlprefiles; do 939242a55b46Smrg case "$dlprefiles " in 939342a55b46Smrg *" $lib "*) ;; 939442a55b46Smrg *) func_append dlprefiles " $lib" ;; 939542a55b46Smrg esac 939642a55b46Smrg done 939742a55b46Smrg 9398e3d74329Smrg if test yes = "$build_libtool_libs"; then 939942a55b46Smrg if test -n "$rpath"; then 940042a55b46Smrg case $host in 940142a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 940242a55b46Smrg # these systems don't actually have a c library (as such)! 940342a55b46Smrg ;; 940442a55b46Smrg *-*-rhapsody* | *-*-darwin1.[012]) 940542a55b46Smrg # Rhapsody C library is in the System framework 940642a55b46Smrg func_append deplibs " System.ltframework" 940742a55b46Smrg ;; 940842a55b46Smrg *-*-netbsd*) 940942a55b46Smrg # Don't link with libc until the a.out ld.so is fixed. 941042a55b46Smrg ;; 94118ce07328Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 941242a55b46Smrg # Do not include libc due to us having libc/libc_r. 941342a55b46Smrg ;; 941442a55b46Smrg *-*-sco3.2v5* | *-*-sco5v6*) 941542a55b46Smrg # Causes problems with __ctype 941642a55b46Smrg ;; 941742a55b46Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 941842a55b46Smrg # Compiler inserts libc in the correct place for threads to work 941942a55b46Smrg ;; 942042a55b46Smrg *) 942142a55b46Smrg # Add libc to deplibs on all other systems if necessary. 9422e3d74329Smrg if test yes = "$build_libtool_need_lc"; then 942342a55b46Smrg func_append deplibs " -lc" 942442a55b46Smrg fi 942542a55b46Smrg ;; 942642a55b46Smrg esac 942742a55b46Smrg fi 942842a55b46Smrg 942942a55b46Smrg # Transform deplibs into only deplibs that can be linked in shared. 943042a55b46Smrg name_save=$name 943142a55b46Smrg libname_save=$libname 943242a55b46Smrg release_save=$release 943342a55b46Smrg versuffix_save=$versuffix 943442a55b46Smrg major_save=$major 943542a55b46Smrg # I'm not sure if I'm treating the release correctly. I think 943642a55b46Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 943742a55b46Smrg # add it in twice. Is that correct? 9438e3d74329Smrg release= 9439e3d74329Smrg versuffix= 9440e3d74329Smrg major= 944142a55b46Smrg newdeplibs= 944242a55b46Smrg droppeddeps=no 944342a55b46Smrg case $deplibs_check_method in 944442a55b46Smrg pass_all) 944542a55b46Smrg # Don't check for shared/static. Everything works. 944642a55b46Smrg # This might be a little naive. We might want to check 944742a55b46Smrg # whether the library exists or not. But this is on 944842a55b46Smrg # osf3 & osf4 and I'm not really sure... Just 944942a55b46Smrg # implementing what was already the behavior. 945042a55b46Smrg newdeplibs=$deplibs 945142a55b46Smrg ;; 945242a55b46Smrg test_compile) 945342a55b46Smrg # This code stresses the "libraries are programs" paradigm to its 945442a55b46Smrg # limits. Maybe even breaks it. We compile a program, linking it 945542a55b46Smrg # against the deplibs as a proxy for the library. Then we can check 945642a55b46Smrg # whether they linked in statically or dynamically with ldd. 945742a55b46Smrg $opt_dry_run || $RM conftest.c 945842a55b46Smrg cat > conftest.c <<EOF 945942a55b46Smrg int main() { return 0; } 946042a55b46SmrgEOF 946142a55b46Smrg $opt_dry_run || $RM conftest 946242a55b46Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 946342a55b46Smrg ldd_output=`ldd conftest` 946442a55b46Smrg for i in $deplibs; do 946542a55b46Smrg case $i in 946642a55b46Smrg -l*) 946742a55b46Smrg func_stripname -l '' "$i" 946842a55b46Smrg name=$func_stripname_result 9469e3d74329Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 947042a55b46Smrg case " $predeps $postdeps " in 947142a55b46Smrg *" $i "*) 947242a55b46Smrg func_append newdeplibs " $i" 9473e3d74329Smrg i= 947442a55b46Smrg ;; 947542a55b46Smrg esac 947642a55b46Smrg fi 9477e3d74329Smrg if test -n "$i"; then 947842a55b46Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 947942a55b46Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 948042a55b46Smrg set dummy $deplib_matches; shift 948142a55b46Smrg deplib_match=$1 9482e3d74329Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 948342a55b46Smrg func_append newdeplibs " $i" 948442a55b46Smrg else 948542a55b46Smrg droppeddeps=yes 948642a55b46Smrg echo 948742a55b46Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 948842a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 948942a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 949042a55b46Smrg echo "*** shared version of the library, which I believe you do not have" 949142a55b46Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 949242a55b46Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 949342a55b46Smrg fi 949442a55b46Smrg fi 949542a55b46Smrg ;; 949642a55b46Smrg *) 949742a55b46Smrg func_append newdeplibs " $i" 949842a55b46Smrg ;; 949942a55b46Smrg esac 950042a55b46Smrg done 950142a55b46Smrg else 950242a55b46Smrg # Error occurred in the first compile. Let's try to salvage 950342a55b46Smrg # the situation: Compile a separate program for each library. 950442a55b46Smrg for i in $deplibs; do 950542a55b46Smrg case $i in 950642a55b46Smrg -l*) 950742a55b46Smrg func_stripname -l '' "$i" 950842a55b46Smrg name=$func_stripname_result 950942a55b46Smrg $opt_dry_run || $RM conftest 951042a55b46Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 951142a55b46Smrg ldd_output=`ldd conftest` 9512e3d74329Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 951342a55b46Smrg case " $predeps $postdeps " in 951442a55b46Smrg *" $i "*) 951542a55b46Smrg func_append newdeplibs " $i" 9516e3d74329Smrg i= 951742a55b46Smrg ;; 951842a55b46Smrg esac 951942a55b46Smrg fi 9520e3d74329Smrg if test -n "$i"; then 952142a55b46Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 952242a55b46Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 952342a55b46Smrg set dummy $deplib_matches; shift 952442a55b46Smrg deplib_match=$1 9525e3d74329Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 952642a55b46Smrg func_append newdeplibs " $i" 952742a55b46Smrg else 952842a55b46Smrg droppeddeps=yes 952942a55b46Smrg echo 953042a55b46Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 953142a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 953242a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 953342a55b46Smrg echo "*** shared version of the library, which you do not appear to have" 953442a55b46Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 953542a55b46Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 953642a55b46Smrg fi 953742a55b46Smrg fi 953842a55b46Smrg else 953942a55b46Smrg droppeddeps=yes 954042a55b46Smrg echo 954142a55b46Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 954242a55b46Smrg echo "*** make it link in! You will probably need to install it or some" 954342a55b46Smrg echo "*** library that it depends on before this library will be fully" 954442a55b46Smrg echo "*** functional. Installing it before continuing would be even better." 954542a55b46Smrg fi 954642a55b46Smrg ;; 954742a55b46Smrg *) 954842a55b46Smrg func_append newdeplibs " $i" 954942a55b46Smrg ;; 955042a55b46Smrg esac 955142a55b46Smrg done 955242a55b46Smrg fi 955342a55b46Smrg ;; 955442a55b46Smrg file_magic*) 955542a55b46Smrg set dummy $deplibs_check_method; shift 955642a55b46Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 955742a55b46Smrg for a_deplib in $deplibs; do 955842a55b46Smrg case $a_deplib in 955942a55b46Smrg -l*) 956042a55b46Smrg func_stripname -l '' "$a_deplib" 956142a55b46Smrg name=$func_stripname_result 9562e3d74329Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 956342a55b46Smrg case " $predeps $postdeps " in 956442a55b46Smrg *" $a_deplib "*) 956542a55b46Smrg func_append newdeplibs " $a_deplib" 9566e3d74329Smrg a_deplib= 956742a55b46Smrg ;; 956842a55b46Smrg esac 956942a55b46Smrg fi 9570e3d74329Smrg if test -n "$a_deplib"; then 957142a55b46Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 957242a55b46Smrg if test -n "$file_magic_glob"; then 957342a55b46Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 957442a55b46Smrg else 957542a55b46Smrg libnameglob=$libname 957642a55b46Smrg fi 9577e3d74329Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 957842a55b46Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9579e3d74329Smrg if test yes = "$want_nocaseglob"; then 958042a55b46Smrg shopt -s nocaseglob 958142a55b46Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 958242a55b46Smrg $nocaseglob 958342a55b46Smrg else 958442a55b46Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 958542a55b46Smrg fi 958642a55b46Smrg for potent_lib in $potential_libs; do 958742a55b46Smrg # Follow soft links. 958842a55b46Smrg if ls -lLd "$potent_lib" 2>/dev/null | 958942a55b46Smrg $GREP " -> " >/dev/null; then 959042a55b46Smrg continue 959142a55b46Smrg fi 959242a55b46Smrg # The statement above tries to avoid entering an 959342a55b46Smrg # endless loop below, in case of cyclic links. 959442a55b46Smrg # We might still enter an endless loop, since a link 959542a55b46Smrg # loop can be closed while we follow links, 959642a55b46Smrg # but so what? 9597e3d74329Smrg potlib=$potent_lib 959842a55b46Smrg while test -h "$potlib" 2>/dev/null; do 9599e3d74329Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 960042a55b46Smrg case $potliblink in 9601e3d74329Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9602e3d74329Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 960342a55b46Smrg esac 960442a55b46Smrg done 960542a55b46Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 960642a55b46Smrg $SED -e 10q | 960742a55b46Smrg $EGREP "$file_magic_regex" > /dev/null; then 960842a55b46Smrg func_append newdeplibs " $a_deplib" 9609e3d74329Smrg a_deplib= 961042a55b46Smrg break 2 961142a55b46Smrg fi 961242a55b46Smrg done 961342a55b46Smrg done 961442a55b46Smrg fi 9615e3d74329Smrg if test -n "$a_deplib"; then 961642a55b46Smrg droppeddeps=yes 961742a55b46Smrg echo 961842a55b46Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 961942a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 962042a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 962142a55b46Smrg echo "*** shared version of the library, which you do not appear to have" 962242a55b46Smrg echo "*** because I did check the linker path looking for a file starting" 9623e3d74329Smrg if test -z "$potlib"; then 962442a55b46Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 962542a55b46Smrg else 962642a55b46Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 962742a55b46Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 962842a55b46Smrg fi 962942a55b46Smrg fi 963042a55b46Smrg ;; 963142a55b46Smrg *) 963242a55b46Smrg # Add a -L argument. 963342a55b46Smrg func_append newdeplibs " $a_deplib" 963442a55b46Smrg ;; 963542a55b46Smrg esac 963642a55b46Smrg done # Gone through all deplibs. 963742a55b46Smrg ;; 963842a55b46Smrg match_pattern*) 963942a55b46Smrg set dummy $deplibs_check_method; shift 964042a55b46Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 964142a55b46Smrg for a_deplib in $deplibs; do 964242a55b46Smrg case $a_deplib in 964342a55b46Smrg -l*) 964442a55b46Smrg func_stripname -l '' "$a_deplib" 964542a55b46Smrg name=$func_stripname_result 9646e3d74329Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 964742a55b46Smrg case " $predeps $postdeps " in 964842a55b46Smrg *" $a_deplib "*) 964942a55b46Smrg func_append newdeplibs " $a_deplib" 9650e3d74329Smrg a_deplib= 965142a55b46Smrg ;; 965242a55b46Smrg esac 965342a55b46Smrg fi 9654e3d74329Smrg if test -n "$a_deplib"; then 965542a55b46Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 965642a55b46Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 965742a55b46Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 965842a55b46Smrg for potent_lib in $potential_libs; do 9659e3d74329Smrg potlib=$potent_lib # see symlink-check above in file_magic test 966042a55b46Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 966142a55b46Smrg $EGREP "$match_pattern_regex" > /dev/null; then 966242a55b46Smrg func_append newdeplibs " $a_deplib" 9663e3d74329Smrg a_deplib= 966442a55b46Smrg break 2 966542a55b46Smrg fi 966642a55b46Smrg done 966742a55b46Smrg done 966842a55b46Smrg fi 9669e3d74329Smrg if test -n "$a_deplib"; then 967042a55b46Smrg droppeddeps=yes 967142a55b46Smrg echo 967242a55b46Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 967342a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 967442a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 967542a55b46Smrg echo "*** shared version of the library, which you do not appear to have" 967642a55b46Smrg echo "*** because I did check the linker path looking for a file starting" 9677e3d74329Smrg if test -z "$potlib"; then 967842a55b46Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 967942a55b46Smrg else 968042a55b46Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 968142a55b46Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 968242a55b46Smrg fi 968342a55b46Smrg fi 968442a55b46Smrg ;; 968542a55b46Smrg *) 968642a55b46Smrg # Add a -L argument. 968742a55b46Smrg func_append newdeplibs " $a_deplib" 968842a55b46Smrg ;; 968942a55b46Smrg esac 969042a55b46Smrg done # Gone through all deplibs. 969142a55b46Smrg ;; 969242a55b46Smrg none | unknown | *) 9693e3d74329Smrg newdeplibs= 969442a55b46Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9695e3d74329Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9696e3d74329Smrg for i in $predeps $postdeps; do 969742a55b46Smrg # can't use Xsed below, because $i might contain '/' 9698e3d74329Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 969942a55b46Smrg done 970042a55b46Smrg fi 970142a55b46Smrg case $tmp_deplibs in 970242a55b46Smrg *[!\ \ ]*) 970342a55b46Smrg echo 9704e3d74329Smrg if test none = "$deplibs_check_method"; then 970542a55b46Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 970642a55b46Smrg else 970742a55b46Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 970842a55b46Smrg fi 970942a55b46Smrg echo "*** All declared inter-library dependencies are being dropped." 971042a55b46Smrg droppeddeps=yes 971142a55b46Smrg ;; 971242a55b46Smrg esac 971342a55b46Smrg ;; 971442a55b46Smrg esac 971542a55b46Smrg versuffix=$versuffix_save 971642a55b46Smrg major=$major_save 971742a55b46Smrg release=$release_save 971842a55b46Smrg libname=$libname_save 971942a55b46Smrg name=$name_save 9720c582b7e3Smrg 972142a55b46Smrg case $host in 972242a55b46Smrg *-*-rhapsody* | *-*-darwin1.[012]) 972342a55b46Smrg # On Rhapsody replace the C library with the System framework 972442a55b46Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 972542a55b46Smrg ;; 972642a55b46Smrg esac 9727c582b7e3Smrg 9728e3d74329Smrg if test yes = "$droppeddeps"; then 9729e3d74329Smrg if test yes = "$module"; then 973042a55b46Smrg echo 973142a55b46Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 973242a55b46Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 973342a55b46Smrg echo "*** a static module, that should work as long as the dlopening" 973442a55b46Smrg echo "*** application is linked with the -dlopen flag." 973542a55b46Smrg if test -z "$global_symbol_pipe"; then 973642a55b46Smrg echo 973742a55b46Smrg echo "*** However, this would only work if libtool was able to extract symbol" 9738e3d74329Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 973942a55b46Smrg echo "*** not find such a program. So, this module is probably useless." 9740e3d74329Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 974142a55b46Smrg fi 9742e3d74329Smrg if test no = "$build_old_libs"; then 9743e3d74329Smrg oldlibs=$output_objdir/$libname.$libext 974442a55b46Smrg build_libtool_libs=module 974542a55b46Smrg build_old_libs=yes 974642a55b46Smrg else 974742a55b46Smrg build_libtool_libs=no 974842a55b46Smrg fi 974942a55b46Smrg else 975042a55b46Smrg echo "*** The inter-library dependencies that have been dropped here will be" 975142a55b46Smrg echo "*** automatically added whenever a program is linked with this library" 975242a55b46Smrg echo "*** or is declared to -dlopen it." 9753c582b7e3Smrg 9754e3d74329Smrg if test no = "$allow_undefined"; then 975542a55b46Smrg echo 975642a55b46Smrg echo "*** Since this library must not contain undefined symbols," 975742a55b46Smrg echo "*** because either the platform does not support them or" 975842a55b46Smrg echo "*** it was explicitly requested with -no-undefined," 975942a55b46Smrg echo "*** libtool will only create a static version of it." 9760e3d74329Smrg if test no = "$build_old_libs"; then 9761e3d74329Smrg oldlibs=$output_objdir/$libname.$libext 976242a55b46Smrg build_libtool_libs=module 976342a55b46Smrg build_old_libs=yes 976442a55b46Smrg else 976542a55b46Smrg build_libtool_libs=no 976642a55b46Smrg fi 976742a55b46Smrg fi 976842a55b46Smrg fi 9769c582b7e3Smrg fi 977042a55b46Smrg # Done checking deplibs! 977142a55b46Smrg deplibs=$newdeplibs 977242a55b46Smrg fi 977342a55b46Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 977442a55b46Smrg case $host in 977542a55b46Smrg *-*-darwin*) 977642a55b46Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 977742a55b46Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 977842a55b46Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 977942a55b46Smrg ;; 978042a55b46Smrg esac 9781c582b7e3Smrg 978242a55b46Smrg # move library search paths that coincide with paths to not yet 978342a55b46Smrg # installed libraries to the beginning of the library search list 978442a55b46Smrg new_libs= 978542a55b46Smrg for path in $notinst_path; do 978642a55b46Smrg case " $new_libs " in 978742a55b46Smrg *" -L$path/$objdir "*) ;; 978842a55b46Smrg *) 978942a55b46Smrg case " $deplibs " in 979042a55b46Smrg *" -L$path/$objdir "*) 979142a55b46Smrg func_append new_libs " -L$path/$objdir" ;; 979242a55b46Smrg esac 979342a55b46Smrg ;; 979442a55b46Smrg esac 979542a55b46Smrg done 979642a55b46Smrg for deplib in $deplibs; do 979742a55b46Smrg case $deplib in 979842a55b46Smrg -L*) 979942a55b46Smrg case " $new_libs " in 980042a55b46Smrg *" $deplib "*) ;; 980142a55b46Smrg *) func_append new_libs " $deplib" ;; 980242a55b46Smrg esac 980342a55b46Smrg ;; 980442a55b46Smrg *) func_append new_libs " $deplib" ;; 980542a55b46Smrg esac 980642a55b46Smrg done 9807e3d74329Smrg deplibs=$new_libs 9808c582b7e3Smrg 980942a55b46Smrg # All the library-specific variables (install_libdir is set above). 981042a55b46Smrg library_names= 981142a55b46Smrg old_library= 981242a55b46Smrg dlname= 9813c582b7e3Smrg 981442a55b46Smrg # Test again, we may have decided not to build it any more 9815e3d74329Smrg if test yes = "$build_libtool_libs"; then 9816e3d74329Smrg # Remove $wl instances when linking with ld. 981742a55b46Smrg # FIXME: should test the right _cmds variable. 981842a55b46Smrg case $archive_cmds in 981942a55b46Smrg *\$LD\ *) wl= ;; 982042a55b46Smrg esac 9821e3d74329Smrg if test yes = "$hardcode_into_libs"; then 982242a55b46Smrg # Hardcode the library paths 982342a55b46Smrg hardcode_libdirs= 982442a55b46Smrg dep_rpath= 9825e3d74329Smrg rpath=$finalize_rpath 9826e3d74329Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 982742a55b46Smrg for libdir in $rpath; do 982842a55b46Smrg if test -n "$hardcode_libdir_flag_spec"; then 982942a55b46Smrg if test -n "$hardcode_libdir_separator"; then 983042a55b46Smrg func_replace_sysroot "$libdir" 983142a55b46Smrg libdir=$func_replace_sysroot_result 983242a55b46Smrg if test -z "$hardcode_libdirs"; then 9833e3d74329Smrg hardcode_libdirs=$libdir 983442a55b46Smrg else 983542a55b46Smrg # Just accumulate the unique libdirs. 983642a55b46Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 983742a55b46Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 983842a55b46Smrg ;; 983942a55b46Smrg *) 984042a55b46Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 984142a55b46Smrg ;; 984242a55b46Smrg esac 984342a55b46Smrg fi 984442a55b46Smrg else 984542a55b46Smrg eval flag=\"$hardcode_libdir_flag_spec\" 984642a55b46Smrg func_append dep_rpath " $flag" 984742a55b46Smrg fi 984842a55b46Smrg elif test -n "$runpath_var"; then 984942a55b46Smrg case "$perm_rpath " in 985042a55b46Smrg *" $libdir "*) ;; 985142a55b46Smrg *) func_append perm_rpath " $libdir" ;; 985242a55b46Smrg esac 985342a55b46Smrg fi 985442a55b46Smrg done 985542a55b46Smrg # Substitute the hardcoded libdirs into the rpath. 985642a55b46Smrg if test -n "$hardcode_libdir_separator" && 985742a55b46Smrg test -n "$hardcode_libdirs"; then 9858e3d74329Smrg libdir=$hardcode_libdirs 985942a55b46Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 986042a55b46Smrg fi 986142a55b46Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 986242a55b46Smrg # We should set the runpath_var. 986342a55b46Smrg rpath= 986442a55b46Smrg for dir in $perm_rpath; do 986542a55b46Smrg func_append rpath "$dir:" 986642a55b46Smrg done 986742a55b46Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 986842a55b46Smrg fi 986942a55b46Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9870c582b7e3Smrg fi 9871c582b7e3Smrg 9872e3d74329Smrg shlibpath=$finalize_shlibpath 9873e3d74329Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 987442a55b46Smrg if test -n "$shlibpath"; then 987542a55b46Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9876c582b7e3Smrg fi 9877c582b7e3Smrg 987842a55b46Smrg # Get the real and link names of the library. 987942a55b46Smrg eval shared_ext=\"$shrext_cmds\" 988042a55b46Smrg eval library_names=\"$library_names_spec\" 988142a55b46Smrg set dummy $library_names 988242a55b46Smrg shift 9883e3d74329Smrg realname=$1 988442a55b46Smrg shift 9885c582b7e3Smrg 988642a55b46Smrg if test -n "$soname_spec"; then 988742a55b46Smrg eval soname=\"$soname_spec\" 9888c582b7e3Smrg else 9889e3d74329Smrg soname=$realname 989042a55b46Smrg fi 989142a55b46Smrg if test -z "$dlname"; then 989242a55b46Smrg dlname=$soname 9893c582b7e3Smrg fi 9894c582b7e3Smrg 9895e3d74329Smrg lib=$output_objdir/$realname 989642a55b46Smrg linknames= 989742a55b46Smrg for link 989842a55b46Smrg do 989942a55b46Smrg func_append linknames " $link" 990042a55b46Smrg done 9901c582b7e3Smrg 990242a55b46Smrg # Use standard objects if they are pic 990342a55b46Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 990442a55b46Smrg test "X$libobjs" = "X " && libobjs= 9905c582b7e3Smrg 990642a55b46Smrg delfiles= 990742a55b46Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 990842a55b46Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9909e3d74329Smrg export_symbols=$output_objdir/$libname.uexp 991042a55b46Smrg func_append delfiles " $export_symbols" 991142a55b46Smrg fi 9912c582b7e3Smrg 991342a55b46Smrg orig_export_symbols= 991442a55b46Smrg case $host_os in 991542a55b46Smrg cygwin* | mingw* | cegcc*) 991642a55b46Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 991742a55b46Smrg # exporting using user supplied symfile 9918e3d74329Smrg func_dll_def_p "$export_symbols" || { 991942a55b46Smrg # and it's NOT already a .def file. Must figure out 992042a55b46Smrg # which of the given symbols are data symbols and tag 992142a55b46Smrg # them as such. So, trigger use of export_symbols_cmds. 992242a55b46Smrg # export_symbols gets reassigned inside the "prepare 992342a55b46Smrg # the list of exported symbols" if statement, so the 992442a55b46Smrg # include_expsyms logic still works. 9925e3d74329Smrg orig_export_symbols=$export_symbols 992642a55b46Smrg export_symbols= 992742a55b46Smrg always_export_symbols=yes 9928e3d74329Smrg } 9929c582b7e3Smrg fi 993042a55b46Smrg ;; 993142a55b46Smrg esac 9932c582b7e3Smrg 993342a55b46Smrg # Prepare the list of exported symbols 993442a55b46Smrg if test -z "$export_symbols"; then 9935e3d74329Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9936e3d74329Smrg func_verbose "generating symbol list for '$libname.la'" 9937e3d74329Smrg export_symbols=$output_objdir/$libname.exp 993842a55b46Smrg $opt_dry_run || $RM $export_symbols 993942a55b46Smrg cmds=$export_symbols_cmds 9940e3d74329Smrg save_ifs=$IFS; IFS='~' 994142a55b46Smrg for cmd1 in $cmds; do 9942e3d74329Smrg IFS=$save_ifs 994342a55b46Smrg # Take the normal branch if the nm_file_list_spec branch 994442a55b46Smrg # doesn't work or if tool conversion is not needed. 994542a55b46Smrg case $nm_file_list_spec~$to_tool_file_cmd in 994642a55b46Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 994742a55b46Smrg try_normal_branch=yes 994842a55b46Smrg eval cmd=\"$cmd1\" 994942a55b46Smrg func_len " $cmd" 995042a55b46Smrg len=$func_len_result 995142a55b46Smrg ;; 995242a55b46Smrg *) 995342a55b46Smrg try_normal_branch=no 995442a55b46Smrg ;; 995542a55b46Smrg esac 9956e3d74329Smrg if test yes = "$try_normal_branch" \ 995742a55b46Smrg && { test "$len" -lt "$max_cmd_len" \ 995842a55b46Smrg || test "$max_cmd_len" -le -1; } 995942a55b46Smrg then 996042a55b46Smrg func_show_eval "$cmd" 'exit $?' 996142a55b46Smrg skipped_export=false 996242a55b46Smrg elif test -n "$nm_file_list_spec"; then 996342a55b46Smrg func_basename "$output" 996442a55b46Smrg output_la=$func_basename_result 996542a55b46Smrg save_libobjs=$libobjs 996642a55b46Smrg save_output=$output 9967e3d74329Smrg output=$output_objdir/$output_la.nm 996842a55b46Smrg func_to_tool_file "$output" 996942a55b46Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 997042a55b46Smrg func_append delfiles " $output" 997142a55b46Smrg func_verbose "creating $NM input file list: $output" 997242a55b46Smrg for obj in $save_libobjs; do 997342a55b46Smrg func_to_tool_file "$obj" 997442a55b46Smrg $ECHO "$func_to_tool_file_result" 997542a55b46Smrg done > "$output" 997642a55b46Smrg eval cmd=\"$cmd1\" 997742a55b46Smrg func_show_eval "$cmd" 'exit $?' 997842a55b46Smrg output=$save_output 997942a55b46Smrg libobjs=$save_libobjs 998042a55b46Smrg skipped_export=false 998142a55b46Smrg else 998242a55b46Smrg # The command line is too long to execute in one step. 998342a55b46Smrg func_verbose "using reloadable object file for export list..." 998442a55b46Smrg skipped_export=: 998542a55b46Smrg # Break out early, otherwise skipped_export may be 998642a55b46Smrg # set to false by a later but shorter cmd. 998742a55b46Smrg break 998842a55b46Smrg fi 998942a55b46Smrg done 9990e3d74329Smrg IFS=$save_ifs 9991e3d74329Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 999242a55b46Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 999342a55b46Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 999442a55b46Smrg fi 999542a55b46Smrg fi 999642a55b46Smrg fi 999742a55b46Smrg 999842a55b46Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9999e3d74329Smrg tmp_export_symbols=$export_symbols 10000e3d74329Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 1000142a55b46Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10002c582b7e3Smrg fi 10003c582b7e3Smrg 10004e3d74329Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 1000542a55b46Smrg # The given exports_symbols file has to be filtered, so filter it. 10006e3d74329Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 1000742a55b46Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 10008e3d74329Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 1000942a55b46Smrg # though. Also, the filter scales superlinearly with the number of 1001042a55b46Smrg # global variables. join(1) would be nice here, but unfortunately 1001142a55b46Smrg # isn't a blessed tool. 1001242a55b46Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 1001342a55b46Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 1001442a55b46Smrg export_symbols=$output_objdir/$libname.def 1001542a55b46Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 1001642a55b46Smrg fi 10017c582b7e3Smrg 1001842a55b46Smrg tmp_deplibs= 1001942a55b46Smrg for test_deplib in $deplibs; do 1002042a55b46Smrg case " $convenience " in 1002142a55b46Smrg *" $test_deplib "*) ;; 1002242a55b46Smrg *) 1002342a55b46Smrg func_append tmp_deplibs " $test_deplib" 1002442a55b46Smrg ;; 1002542a55b46Smrg esac 1002642a55b46Smrg done 10027e3d74329Smrg deplibs=$tmp_deplibs 10028c582b7e3Smrg 1002942a55b46Smrg if test -n "$convenience"; then 1003042a55b46Smrg if test -n "$whole_archive_flag_spec" && 10031e3d74329Smrg test yes = "$compiler_needs_object" && 1003242a55b46Smrg test -z "$libobjs"; then 1003342a55b46Smrg # extract the archives, so we have objects to list. 1003442a55b46Smrg # TODO: could optimize this to just extract one archive. 1003542a55b46Smrg whole_archive_flag_spec= 1003642a55b46Smrg fi 1003742a55b46Smrg if test -n "$whole_archive_flag_spec"; then 1003842a55b46Smrg save_libobjs=$libobjs 1003942a55b46Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 1004042a55b46Smrg test "X$libobjs" = "X " && libobjs= 10041c582b7e3Smrg else 10042e3d74329Smrg gentop=$output_objdir/${outputname}x 1004342a55b46Smrg func_append generated " $gentop" 1004442a55b46Smrg 1004542a55b46Smrg func_extract_archives $gentop $convenience 1004642a55b46Smrg func_append libobjs " $func_extract_archives_result" 1004742a55b46Smrg test "X$libobjs" = "X " && libobjs= 10048c582b7e3Smrg fi 10049c582b7e3Smrg fi 10050c582b7e3Smrg 10051e3d74329Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 1005242a55b46Smrg eval flag=\"$thread_safe_flag_spec\" 1005342a55b46Smrg func_append linker_flags " $flag" 1005442a55b46Smrg fi 10055c582b7e3Smrg 1005642a55b46Smrg # Make a backup of the uninstalled library when relinking 10057e3d74329Smrg if test relink = "$opt_mode"; then 1005842a55b46Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 1005942a55b46Smrg fi 10060c582b7e3Smrg 1006142a55b46Smrg # Do each of the archive commands. 10062e3d74329Smrg if test yes = "$module" && test -n "$module_cmds"; then 1006342a55b46Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 1006442a55b46Smrg eval test_cmds=\"$module_expsym_cmds\" 1006542a55b46Smrg cmds=$module_expsym_cmds 1006642a55b46Smrg else 1006742a55b46Smrg eval test_cmds=\"$module_cmds\" 1006842a55b46Smrg cmds=$module_cmds 1006942a55b46Smrg fi 10070c582b7e3Smrg else 1007142a55b46Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 1007242a55b46Smrg eval test_cmds=\"$archive_expsym_cmds\" 1007342a55b46Smrg cmds=$archive_expsym_cmds 1007442a55b46Smrg else 1007542a55b46Smrg eval test_cmds=\"$archive_cmds\" 1007642a55b46Smrg cmds=$archive_cmds 1007742a55b46Smrg fi 10078c582b7e3Smrg fi 10079c582b7e3Smrg 10080e3d74329Smrg if test : != "$skipped_export" && 1008142a55b46Smrg func_len " $test_cmds" && 1008242a55b46Smrg len=$func_len_result && 1008342a55b46Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 1008442a55b46Smrg : 1008542a55b46Smrg else 1008642a55b46Smrg # The command line is too long to link in one step, link piecewise 1008742a55b46Smrg # or, if using GNU ld and skipped_export is not :, use a linker 1008842a55b46Smrg # script. 10089c582b7e3Smrg 1009042a55b46Smrg # Save the value of $output and $libobjs because we want to 1009142a55b46Smrg # use them later. If we have whole_archive_flag_spec, we 1009242a55b46Smrg # want to use save_libobjs as it was before 1009342a55b46Smrg # whole_archive_flag_spec was expanded, because we can't 1009442a55b46Smrg # assume the linker understands whole_archive_flag_spec. 1009542a55b46Smrg # This may have to be revisited, in case too many 1009642a55b46Smrg # convenience libraries get linked in and end up exceeding 1009742a55b46Smrg # the spec. 1009842a55b46Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 1009942a55b46Smrg save_libobjs=$libobjs 1010042a55b46Smrg fi 1010142a55b46Smrg save_output=$output 1010242a55b46Smrg func_basename "$output" 1010342a55b46Smrg output_la=$func_basename_result 1010442a55b46Smrg 1010542a55b46Smrg # Clear the reloadable object creation command queue and 1010642a55b46Smrg # initialize k to one. 1010742a55b46Smrg test_cmds= 1010842a55b46Smrg concat_cmds= 1010942a55b46Smrg objlist= 1011042a55b46Smrg last_robj= 1011142a55b46Smrg k=1 1011242a55b46Smrg 10113e3d74329Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 10114e3d74329Smrg output=$output_objdir/$output_la.lnkscript 1011542a55b46Smrg func_verbose "creating GNU ld script: $output" 1011642a55b46Smrg echo 'INPUT (' > $output 1011742a55b46Smrg for obj in $save_libobjs 1011842a55b46Smrg do 1011942a55b46Smrg func_to_tool_file "$obj" 1012042a55b46Smrg $ECHO "$func_to_tool_file_result" >> $output 1012142a55b46Smrg done 1012242a55b46Smrg echo ')' >> $output 1012342a55b46Smrg func_append delfiles " $output" 1012442a55b46Smrg func_to_tool_file "$output" 1012542a55b46Smrg output=$func_to_tool_file_result 10126e3d74329Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 10127e3d74329Smrg output=$output_objdir/$output_la.lnk 1012842a55b46Smrg func_verbose "creating linker input file list: $output" 1012942a55b46Smrg : > $output 1013042a55b46Smrg set x $save_libobjs 1013142a55b46Smrg shift 1013242a55b46Smrg firstobj= 10133e3d74329Smrg if test yes = "$compiler_needs_object"; then 1013442a55b46Smrg firstobj="$1 " 1013542a55b46Smrg shift 10136c582b7e3Smrg fi 1013742a55b46Smrg for obj 1013842a55b46Smrg do 1013942a55b46Smrg func_to_tool_file "$obj" 1014042a55b46Smrg $ECHO "$func_to_tool_file_result" >> $output 10141c582b7e3Smrg done 1014242a55b46Smrg func_append delfiles " $output" 1014342a55b46Smrg func_to_tool_file "$output" 1014442a55b46Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 1014542a55b46Smrg else 1014642a55b46Smrg if test -n "$save_libobjs"; then 1014742a55b46Smrg func_verbose "creating reloadable object files..." 10148e3d74329Smrg output=$output_objdir/$output_la-$k.$objext 1014942a55b46Smrg eval test_cmds=\"$reload_cmds\" 1015042a55b46Smrg func_len " $test_cmds" 1015142a55b46Smrg len0=$func_len_result 1015242a55b46Smrg len=$len0 1015342a55b46Smrg 1015442a55b46Smrg # Loop over the list of objects to be linked. 1015542a55b46Smrg for obj in $save_libobjs 1015642a55b46Smrg do 1015742a55b46Smrg func_len " $obj" 1015842a55b46Smrg func_arith $len + $func_len_result 1015942a55b46Smrg len=$func_arith_result 10160e3d74329Smrg if test -z "$objlist" || 1016142a55b46Smrg test "$len" -lt "$max_cmd_len"; then 1016242a55b46Smrg func_append objlist " $obj" 1016342a55b46Smrg else 1016442a55b46Smrg # The command $test_cmds is almost too long, add a 1016542a55b46Smrg # command to the queue. 10166e3d74329Smrg if test 1 -eq "$k"; then 1016742a55b46Smrg # The first file doesn't have a previous command to add. 1016842a55b46Smrg reload_objs=$objlist 1016942a55b46Smrg eval concat_cmds=\"$reload_cmds\" 1017042a55b46Smrg else 1017142a55b46Smrg # All subsequent reloadable object files will link in 1017242a55b46Smrg # the last one created. 1017342a55b46Smrg reload_objs="$objlist $last_robj" 1017442a55b46Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 1017542a55b46Smrg fi 10176e3d74329Smrg last_robj=$output_objdir/$output_la-$k.$objext 1017742a55b46Smrg func_arith $k + 1 1017842a55b46Smrg k=$func_arith_result 10179e3d74329Smrg output=$output_objdir/$output_la-$k.$objext 1018042a55b46Smrg objlist=" $obj" 1018142a55b46Smrg func_len " $last_robj" 1018242a55b46Smrg func_arith $len0 + $func_len_result 1018342a55b46Smrg len=$func_arith_result 1018442a55b46Smrg fi 1018542a55b46Smrg done 1018642a55b46Smrg # Handle the remaining objects by creating one last 1018742a55b46Smrg # reloadable object file. All subsequent reloadable object 1018842a55b46Smrg # files will link in the last one created. 1018942a55b46Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1019042a55b46Smrg reload_objs="$objlist $last_robj" 10191e3d74329Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 1019242a55b46Smrg if test -n "$last_robj"; then 10193e3d74329Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10194c582b7e3Smrg fi 1019542a55b46Smrg func_append delfiles " $output" 1019642a55b46Smrg 1019742a55b46Smrg else 1019842a55b46Smrg output= 1019942a55b46Smrg fi 1020042a55b46Smrg 10201e3d74329Smrg ${skipped_export-false} && { 10202e3d74329Smrg func_verbose "generating symbol list for '$libname.la'" 10203e3d74329Smrg export_symbols=$output_objdir/$libname.exp 1020442a55b46Smrg $opt_dry_run || $RM $export_symbols 1020542a55b46Smrg libobjs=$output 1020642a55b46Smrg # Append the command to create the export file. 1020742a55b46Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1020842a55b46Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 1020942a55b46Smrg if test -n "$last_robj"; then 1021042a55b46Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10211c582b7e3Smrg fi 10212e3d74329Smrg } 1021342a55b46Smrg 1021442a55b46Smrg test -n "$save_libobjs" && 1021542a55b46Smrg func_verbose "creating a temporary reloadable object file: $output" 1021642a55b46Smrg 1021742a55b46Smrg # Loop through the commands generated above and execute them. 10218e3d74329Smrg save_ifs=$IFS; IFS='~' 1021942a55b46Smrg for cmd in $concat_cmds; do 10220e3d74329Smrg IFS=$save_ifs 10221e3d74329Smrg $opt_quiet || { 102228ce07328Smrg func_quote_arg expand,pretty "$cmd" 102238ce07328Smrg eval "func_echo $func_quote_arg_result" 1022442a55b46Smrg } 1022542a55b46Smrg $opt_dry_run || eval "$cmd" || { 1022642a55b46Smrg lt_exit=$? 1022742a55b46Smrg 1022842a55b46Smrg # Restore the uninstalled library and exit 10229e3d74329Smrg if test relink = "$opt_mode"; then 1023042a55b46Smrg ( cd "$output_objdir" && \ 1023142a55b46Smrg $RM "${realname}T" && \ 1023242a55b46Smrg $MV "${realname}U" "$realname" ) 1023342a55b46Smrg fi 1023442a55b46Smrg 1023542a55b46Smrg exit $lt_exit 1023642a55b46Smrg } 10237c582b7e3Smrg done 10238e3d74329Smrg IFS=$save_ifs 1023942a55b46Smrg 1024042a55b46Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 1024142a55b46Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 1024242a55b46Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 1024342a55b46Smrg fi 1024442a55b46Smrg fi 1024542a55b46Smrg 10246e3d74329Smrg ${skipped_export-false} && { 1024742a55b46Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 10248e3d74329Smrg tmp_export_symbols=$export_symbols 10249e3d74329Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 1025042a55b46Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 1025142a55b46Smrg fi 1025242a55b46Smrg 1025342a55b46Smrg if test -n "$orig_export_symbols"; then 1025442a55b46Smrg # The given exports_symbols file has to be filtered, so filter it. 10255e3d74329Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 1025642a55b46Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 10257e3d74329Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 1025842a55b46Smrg # though. Also, the filter scales superlinearly with the number of 1025942a55b46Smrg # global variables. join(1) would be nice here, but unfortunately 1026042a55b46Smrg # isn't a blessed tool. 1026142a55b46Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 1026242a55b46Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 1026342a55b46Smrg export_symbols=$output_objdir/$libname.def 1026442a55b46Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 1026542a55b46Smrg fi 10266e3d74329Smrg } 1026742a55b46Smrg 1026842a55b46Smrg libobjs=$output 1026942a55b46Smrg # Restore the value of output. 1027042a55b46Smrg output=$save_output 1027142a55b46Smrg 1027242a55b46Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 1027342a55b46Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 1027442a55b46Smrg test "X$libobjs" = "X " && libobjs= 1027542a55b46Smrg fi 1027642a55b46Smrg # Expand the library linking commands again to reset the 1027742a55b46Smrg # value of $libobjs for piecewise linking. 1027842a55b46Smrg 1027942a55b46Smrg # Do each of the archive commands. 10280e3d74329Smrg if test yes = "$module" && test -n "$module_cmds"; then 1028142a55b46Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 1028242a55b46Smrg cmds=$module_expsym_cmds 1028342a55b46Smrg else 1028442a55b46Smrg cmds=$module_cmds 1028542a55b46Smrg fi 10286c582b7e3Smrg else 1028742a55b46Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 1028842a55b46Smrg cmds=$archive_expsym_cmds 1028942a55b46Smrg else 1029042a55b46Smrg cmds=$archive_cmds 1029142a55b46Smrg fi 10292c582b7e3Smrg fi 1029342a55b46Smrg fi 10294c582b7e3Smrg 1029542a55b46Smrg if test -n "$delfiles"; then 1029642a55b46Smrg # Append the command to remove temporary files to $cmds. 1029742a55b46Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 1029842a55b46Smrg fi 10299c582b7e3Smrg 1030042a55b46Smrg # Add any objects from preloaded convenience libraries 1030142a55b46Smrg if test -n "$dlprefiles"; then 10302e3d74329Smrg gentop=$output_objdir/${outputname}x 1030342a55b46Smrg func_append generated " $gentop" 10304c582b7e3Smrg 1030542a55b46Smrg func_extract_archives $gentop $dlprefiles 1030642a55b46Smrg func_append libobjs " $func_extract_archives_result" 1030742a55b46Smrg test "X$libobjs" = "X " && libobjs= 1030842a55b46Smrg fi 10309c582b7e3Smrg 10310e3d74329Smrg save_ifs=$IFS; IFS='~' 1031142a55b46Smrg for cmd in $cmds; do 10312e3d74329Smrg IFS=$sp$nl 1031342a55b46Smrg eval cmd=\"$cmd\" 10314e3d74329Smrg IFS=$save_ifs 10315e3d74329Smrg $opt_quiet || { 103168ce07328Smrg func_quote_arg expand,pretty "$cmd" 103178ce07328Smrg eval "func_echo $func_quote_arg_result" 1031842a55b46Smrg } 1031942a55b46Smrg $opt_dry_run || eval "$cmd" || { 1032042a55b46Smrg lt_exit=$? 10321c582b7e3Smrg 1032242a55b46Smrg # Restore the uninstalled library and exit 10323e3d74329Smrg if test relink = "$opt_mode"; then 1032442a55b46Smrg ( cd "$output_objdir" && \ 1032542a55b46Smrg $RM "${realname}T" && \ 1032642a55b46Smrg $MV "${realname}U" "$realname" ) 1032742a55b46Smrg fi 10328c582b7e3Smrg 1032942a55b46Smrg exit $lt_exit 1033042a55b46Smrg } 1033142a55b46Smrg done 10332e3d74329Smrg IFS=$save_ifs 10333c582b7e3Smrg 1033442a55b46Smrg # Restore the uninstalled library and exit 10335e3d74329Smrg if test relink = "$opt_mode"; then 1033642a55b46Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10337c582b7e3Smrg 1033842a55b46Smrg if test -n "$convenience"; then 1033942a55b46Smrg if test -z "$whole_archive_flag_spec"; then 1034042a55b46Smrg func_show_eval '${RM}r "$gentop"' 1034142a55b46Smrg fi 1034242a55b46Smrg fi 10343c582b7e3Smrg 1034442a55b46Smrg exit $EXIT_SUCCESS 1034542a55b46Smrg fi 1034642a55b46Smrg 1034742a55b46Smrg # Create links to the real library. 1034842a55b46Smrg for linkname in $linknames; do 1034942a55b46Smrg if test "$realname" != "$linkname"; then 1035042a55b46Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10351c582b7e3Smrg fi 10352c582b7e3Smrg done 10353c582b7e3Smrg 1035442a55b46Smrg # If -module or -export-dynamic was specified, set the dlname. 10355e3d74329Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 1035642a55b46Smrg # On all known operating systems, these are identical. 10357e3d74329Smrg dlname=$soname 1035842a55b46Smrg fi 1035942a55b46Smrg fi 10360c582b7e3Smrg ;; 10361c582b7e3Smrg 1036242a55b46Smrg obj) 10363e3d74329Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10364e3d74329Smrg func_warning "'-dlopen' is ignored for objects" 1036542a55b46Smrg fi 10366c582b7e3Smrg 1036742a55b46Smrg case " $deplibs" in 1036842a55b46Smrg *\ -l* | *\ -L*) 10369e3d74329Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 10370c582b7e3Smrg esac 10371c582b7e3Smrg 1037242a55b46Smrg test -n "$rpath" && \ 10373e3d74329Smrg func_warning "'-rpath' is ignored for objects" 10374c582b7e3Smrg 1037542a55b46Smrg test -n "$xrpath" && \ 10376e3d74329Smrg func_warning "'-R' is ignored for objects" 10377c582b7e3Smrg 1037842a55b46Smrg test -n "$vinfo" && \ 10379e3d74329Smrg func_warning "'-version-info' is ignored for objects" 1038042a55b46Smrg 1038142a55b46Smrg test -n "$release" && \ 10382e3d74329Smrg func_warning "'-release' is ignored for objects" 1038342a55b46Smrg 1038442a55b46Smrg case $output in 1038542a55b46Smrg *.lo) 1038642a55b46Smrg test -n "$objs$old_deplibs" && \ 10387e3d74329Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 1038842a55b46Smrg 1038942a55b46Smrg libobj=$output 1039042a55b46Smrg func_lo2o "$libobj" 1039142a55b46Smrg obj=$func_lo2o_result 10392c582b7e3Smrg ;; 10393c582b7e3Smrg *) 1039442a55b46Smrg libobj= 10395e3d74329Smrg obj=$output 10396c582b7e3Smrg ;; 10397c582b7e3Smrg esac 10398c582b7e3Smrg 1039942a55b46Smrg # Delete the old objects. 1040042a55b46Smrg $opt_dry_run || $RM $obj $libobj 10401c582b7e3Smrg 1040242a55b46Smrg # Objects from convenience libraries. This assumes 1040342a55b46Smrg # single-version convenience libraries. Whenever we create 1040442a55b46Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 1040542a55b46Smrg # the extraction. 1040642a55b46Smrg reload_conv_objs= 1040742a55b46Smrg gentop= 10408e3d74329Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 10409e3d74329Smrg # whole_archive_flag_spec and hope we can get by with turning comma 10410e3d74329Smrg # into space. 10411e3d74329Smrg case $reload_cmds in 10412e3d74329Smrg *\$LD[\ \$]*) wl= ;; 10413e3d74329Smrg esac 1041442a55b46Smrg if test -n "$convenience"; then 1041542a55b46Smrg if test -n "$whole_archive_flag_spec"; then 1041642a55b46Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10417e3d74329Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10418e3d74329Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 1041942a55b46Smrg else 10420e3d74329Smrg gentop=$output_objdir/${obj}x 1042142a55b46Smrg func_append generated " $gentop" 10422c582b7e3Smrg 1042342a55b46Smrg func_extract_archives $gentop $convenience 1042442a55b46Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 1042542a55b46Smrg fi 10426c582b7e3Smrg fi 10427c582b7e3Smrg 1042842a55b46Smrg # If we're not building shared, we need to use non_pic_objs 10429e3d74329Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10430c582b7e3Smrg 1043142a55b46Smrg # Create the old-style object. 10432e3d74329Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10433c582b7e3Smrg 10434e3d74329Smrg output=$obj 1043542a55b46Smrg func_execute_cmds "$reload_cmds" 'exit $?' 1043642a55b46Smrg 1043742a55b46Smrg # Exit if we aren't doing a library object file. 1043842a55b46Smrg if test -z "$libobj"; then 1043942a55b46Smrg if test -n "$gentop"; then 1044042a55b46Smrg func_show_eval '${RM}r "$gentop"' 1044142a55b46Smrg fi 1044242a55b46Smrg 1044342a55b46Smrg exit $EXIT_SUCCESS 10444c582b7e3Smrg fi 1044542a55b46Smrg 10446e3d74329Smrg test yes = "$build_libtool_libs" || { 1044742a55b46Smrg if test -n "$gentop"; then 1044842a55b46Smrg func_show_eval '${RM}r "$gentop"' 1044942a55b46Smrg fi 1045042a55b46Smrg 1045142a55b46Smrg # Create an invalid libtool object if no PIC, so that we don't 1045242a55b46Smrg # accidentally link it into a program. 1045342a55b46Smrg # $show "echo timestamp > $libobj" 1045442a55b46Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 1045542a55b46Smrg exit $EXIT_SUCCESS 10456e3d74329Smrg } 1045742a55b46Smrg 10458e3d74329Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 1045942a55b46Smrg # Only do commands if we really have different PIC objects. 1046042a55b46Smrg reload_objs="$libobjs $reload_conv_objs" 10461e3d74329Smrg output=$libobj 1046242a55b46Smrg func_execute_cmds "$reload_cmds" 'exit $?' 1046342a55b46Smrg fi 1046442a55b46Smrg 1046542a55b46Smrg if test -n "$gentop"; then 1046642a55b46Smrg func_show_eval '${RM}r "$gentop"' 1046742a55b46Smrg fi 1046842a55b46Smrg 1046942a55b46Smrg exit $EXIT_SUCCESS 10470c582b7e3Smrg ;; 10471c582b7e3Smrg 1047242a55b46Smrg prog) 1047342a55b46Smrg case $host in 1047442a55b46Smrg *cygwin*) func_stripname '' '.exe' "$output" 1047542a55b46Smrg output=$func_stripname_result.exe;; 1047642a55b46Smrg esac 1047742a55b46Smrg test -n "$vinfo" && \ 10478e3d74329Smrg func_warning "'-version-info' is ignored for programs" 10479c582b7e3Smrg 1048042a55b46Smrg test -n "$release" && \ 10481e3d74329Smrg func_warning "'-release' is ignored for programs" 10482c582b7e3Smrg 10483e3d74329Smrg $preload \ 10484e3d74329Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10485e3d74329Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 1048642a55b46Smrg 1048742a55b46Smrg case $host in 1048842a55b46Smrg *-*-rhapsody* | *-*-darwin1.[012]) 1048942a55b46Smrg # On Rhapsody replace the C library is the System framework 1049042a55b46Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 1049142a55b46Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10492c582b7e3Smrg ;; 1049342a55b46Smrg esac 10494c582b7e3Smrg 1049542a55b46Smrg case $host in 1049642a55b46Smrg *-*-darwin*) 1049742a55b46Smrg # Don't allow lazy linking, it breaks C++ global constructors 1049842a55b46Smrg # But is supposedly fixed on 10.4 or later (yay!). 10499e3d74329Smrg if test CXX = "$tagname"; then 1050042a55b46Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 1050142a55b46Smrg 10.[0123]) 10502e3d74329Smrg func_append compile_command " $wl-bind_at_load" 10503e3d74329Smrg func_append finalize_command " $wl-bind_at_load" 1050442a55b46Smrg ;; 1050542a55b46Smrg esac 10506c582b7e3Smrg fi 1050742a55b46Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 1050842a55b46Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1050942a55b46Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1051042a55b46Smrg ;; 1051142a55b46Smrg esac 10512c582b7e3Smrg 10513c582b7e3Smrg 1051442a55b46Smrg # move library search paths that coincide with paths to not yet 1051542a55b46Smrg # installed libraries to the beginning of the library search list 1051642a55b46Smrg new_libs= 1051742a55b46Smrg for path in $notinst_path; do 1051842a55b46Smrg case " $new_libs " in 1051942a55b46Smrg *" -L$path/$objdir "*) ;; 1052042a55b46Smrg *) 1052142a55b46Smrg case " $compile_deplibs " in 1052242a55b46Smrg *" -L$path/$objdir "*) 1052342a55b46Smrg func_append new_libs " -L$path/$objdir" ;; 10524c582b7e3Smrg esac 1052542a55b46Smrg ;; 1052642a55b46Smrg esac 1052742a55b46Smrg done 1052842a55b46Smrg for deplib in $compile_deplibs; do 1052942a55b46Smrg case $deplib in 1053042a55b46Smrg -L*) 1053142a55b46Smrg case " $new_libs " in 1053242a55b46Smrg *" $deplib "*) ;; 1053342a55b46Smrg *) func_append new_libs " $deplib" ;; 10534c582b7e3Smrg esac 1053542a55b46Smrg ;; 1053642a55b46Smrg *) func_append new_libs " $deplib" ;; 1053742a55b46Smrg esac 1053842a55b46Smrg done 10539e3d74329Smrg compile_deplibs=$new_libs 10540c582b7e3Smrg 10541c582b7e3Smrg 1054242a55b46Smrg func_append compile_command " $compile_deplibs" 1054342a55b46Smrg func_append finalize_command " $finalize_deplibs" 10544c582b7e3Smrg 1054542a55b46Smrg if test -n "$rpath$xrpath"; then 1054642a55b46Smrg # If the user specified any rpath flags, then add them. 1054742a55b46Smrg for libdir in $rpath $xrpath; do 1054842a55b46Smrg # This is the magic to use -rpath. 1054942a55b46Smrg case "$finalize_rpath " in 1055042a55b46Smrg *" $libdir "*) ;; 1055142a55b46Smrg *) func_append finalize_rpath " $libdir" ;; 1055242a55b46Smrg esac 1055342a55b46Smrg done 1055442a55b46Smrg fi 10555c582b7e3Smrg 1055642a55b46Smrg # Now hardcode the library paths 1055742a55b46Smrg rpath= 1055842a55b46Smrg hardcode_libdirs= 1055942a55b46Smrg for libdir in $compile_rpath $finalize_rpath; do 1056042a55b46Smrg if test -n "$hardcode_libdir_flag_spec"; then 1056142a55b46Smrg if test -n "$hardcode_libdir_separator"; then 1056242a55b46Smrg if test -z "$hardcode_libdirs"; then 10563e3d74329Smrg hardcode_libdirs=$libdir 1056442a55b46Smrg else 1056542a55b46Smrg # Just accumulate the unique libdirs. 1056642a55b46Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1056742a55b46Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1056842a55b46Smrg ;; 1056942a55b46Smrg *) 1057042a55b46Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1057142a55b46Smrg ;; 1057242a55b46Smrg esac 1057342a55b46Smrg fi 10574c582b7e3Smrg else 1057542a55b46Smrg eval flag=\"$hardcode_libdir_flag_spec\" 1057642a55b46Smrg func_append rpath " $flag" 10577c582b7e3Smrg fi 1057842a55b46Smrg elif test -n "$runpath_var"; then 1057942a55b46Smrg case "$perm_rpath " in 1058042a55b46Smrg *" $libdir "*) ;; 1058142a55b46Smrg *) func_append perm_rpath " $libdir" ;; 1058242a55b46Smrg esac 1058342a55b46Smrg fi 1058442a55b46Smrg case $host in 1058542a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10586e3d74329Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 1058742a55b46Smrg case :$dllsearchpath: in 1058842a55b46Smrg *":$libdir:"*) ;; 1058942a55b46Smrg ::) dllsearchpath=$libdir;; 1059042a55b46Smrg *) func_append dllsearchpath ":$libdir";; 1059142a55b46Smrg esac 1059242a55b46Smrg case :$dllsearchpath: in 1059342a55b46Smrg *":$testbindir:"*) ;; 1059442a55b46Smrg ::) dllsearchpath=$testbindir;; 1059542a55b46Smrg *) func_append dllsearchpath ":$testbindir";; 1059642a55b46Smrg esac 1059742a55b46Smrg ;; 1059842a55b46Smrg esac 1059942a55b46Smrg done 1060042a55b46Smrg # Substitute the hardcoded libdirs into the rpath. 1060142a55b46Smrg if test -n "$hardcode_libdir_separator" && 1060242a55b46Smrg test -n "$hardcode_libdirs"; then 10603e3d74329Smrg libdir=$hardcode_libdirs 1060442a55b46Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 1060542a55b46Smrg fi 10606e3d74329Smrg compile_rpath=$rpath 10607c582b7e3Smrg 1060842a55b46Smrg rpath= 1060942a55b46Smrg hardcode_libdirs= 1061042a55b46Smrg for libdir in $finalize_rpath; do 1061142a55b46Smrg if test -n "$hardcode_libdir_flag_spec"; then 1061242a55b46Smrg if test -n "$hardcode_libdir_separator"; then 1061342a55b46Smrg if test -z "$hardcode_libdirs"; then 10614e3d74329Smrg hardcode_libdirs=$libdir 1061542a55b46Smrg else 1061642a55b46Smrg # Just accumulate the unique libdirs. 1061742a55b46Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1061842a55b46Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1061942a55b46Smrg ;; 1062042a55b46Smrg *) 1062142a55b46Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1062242a55b46Smrg ;; 1062342a55b46Smrg esac 1062442a55b46Smrg fi 10625c582b7e3Smrg else 1062642a55b46Smrg eval flag=\"$hardcode_libdir_flag_spec\" 1062742a55b46Smrg func_append rpath " $flag" 10628c582b7e3Smrg fi 1062942a55b46Smrg elif test -n "$runpath_var"; then 1063042a55b46Smrg case "$finalize_perm_rpath " in 1063142a55b46Smrg *" $libdir "*) ;; 1063242a55b46Smrg *) func_append finalize_perm_rpath " $libdir" ;; 1063342a55b46Smrg esac 10634c582b7e3Smrg fi 1063542a55b46Smrg done 1063642a55b46Smrg # Substitute the hardcoded libdirs into the rpath. 1063742a55b46Smrg if test -n "$hardcode_libdir_separator" && 1063842a55b46Smrg test -n "$hardcode_libdirs"; then 10639e3d74329Smrg libdir=$hardcode_libdirs 1064042a55b46Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 1064142a55b46Smrg fi 10642e3d74329Smrg finalize_rpath=$rpath 10643c582b7e3Smrg 10644e3d74329Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 1064542a55b46Smrg # Transform all the library objects into standard objects. 1064642a55b46Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1064742a55b46Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1064842a55b46Smrg fi 10649c582b7e3Smrg 10650e3d74329Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10651c582b7e3Smrg 1065242a55b46Smrg # template prelinking step 1065342a55b46Smrg if test -n "$prelink_cmds"; then 1065442a55b46Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 1065542a55b46Smrg fi 10656c582b7e3Smrg 10657e3d74329Smrg wrappers_required=: 1065842a55b46Smrg case $host in 1065942a55b46Smrg *cegcc* | *mingw32ce*) 1066042a55b46Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10661e3d74329Smrg wrappers_required=false 1066242a55b46Smrg ;; 1066342a55b46Smrg *cygwin* | *mingw* ) 10664e3d74329Smrg test yes = "$build_libtool_libs" || wrappers_required=false 1066542a55b46Smrg ;; 1066642a55b46Smrg *) 10667e3d74329Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10668e3d74329Smrg wrappers_required=false 1066942a55b46Smrg fi 1067042a55b46Smrg ;; 1067142a55b46Smrg esac 10672e3d74329Smrg $wrappers_required || { 1067342a55b46Smrg # Replace the output file specification. 1067442a55b46Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10675e3d74329Smrg link_command=$compile_command$compile_rpath 10676c582b7e3Smrg 1067742a55b46Smrg # We have no uninstalled library dependencies, so finalize right now. 1067842a55b46Smrg exit_status=0 1067942a55b46Smrg func_show_eval "$link_command" 'exit_status=$?' 10680c582b7e3Smrg 1068142a55b46Smrg if test -n "$postlink_cmds"; then 1068242a55b46Smrg func_to_tool_file "$output" 1068342a55b46Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1068442a55b46Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10685c582b7e3Smrg fi 10686c582b7e3Smrg 1068742a55b46Smrg # Delete the generated files. 10688e3d74329Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 10689e3d74329Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 1069042a55b46Smrg fi 10691c582b7e3Smrg 1069242a55b46Smrg exit $exit_status 10693e3d74329Smrg } 10694c582b7e3Smrg 1069542a55b46Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 1069642a55b46Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 1069742a55b46Smrg fi 1069842a55b46Smrg if test -n "$finalize_shlibpath"; then 1069942a55b46Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 1070042a55b46Smrg fi 10701c582b7e3Smrg 1070242a55b46Smrg compile_var= 1070342a55b46Smrg finalize_var= 1070442a55b46Smrg if test -n "$runpath_var"; then 1070542a55b46Smrg if test -n "$perm_rpath"; then 1070642a55b46Smrg # We should set the runpath_var. 1070742a55b46Smrg rpath= 1070842a55b46Smrg for dir in $perm_rpath; do 1070942a55b46Smrg func_append rpath "$dir:" 1071042a55b46Smrg done 1071142a55b46Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10712c582b7e3Smrg fi 1071342a55b46Smrg if test -n "$finalize_perm_rpath"; then 1071442a55b46Smrg # We should set the runpath_var. 1071542a55b46Smrg rpath= 1071642a55b46Smrg for dir in $finalize_perm_rpath; do 1071742a55b46Smrg func_append rpath "$dir:" 1071842a55b46Smrg done 1071942a55b46Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10720c582b7e3Smrg fi 1072142a55b46Smrg fi 10722c582b7e3Smrg 10723e3d74329Smrg if test yes = "$no_install"; then 1072442a55b46Smrg # We don't need to create a wrapper script. 10725e3d74329Smrg link_command=$compile_var$compile_command$compile_rpath 1072642a55b46Smrg # Replace the output file specification. 1072742a55b46Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1072842a55b46Smrg # Delete the old output file. 1072942a55b46Smrg $opt_dry_run || $RM $output 1073042a55b46Smrg # Link the executable and exit 1073142a55b46Smrg func_show_eval "$link_command" 'exit $?' 10732c582b7e3Smrg 1073342a55b46Smrg if test -n "$postlink_cmds"; then 1073442a55b46Smrg func_to_tool_file "$output" 1073542a55b46Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1073642a55b46Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10737c582b7e3Smrg fi 1073842a55b46Smrg 10739c582b7e3Smrg exit $EXIT_SUCCESS 1074042a55b46Smrg fi 10741c582b7e3Smrg 10742e3d74329Smrg case $hardcode_action,$fast_install in 10743e3d74329Smrg relink,*) 10744e3d74329Smrg # Fast installation is not supported 10745e3d74329Smrg link_command=$compile_var$compile_command$compile_rpath 10746e3d74329Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 1074742a55b46Smrg 10748e3d74329Smrg func_warning "this platform does not like uninstalled shared libraries" 10749e3d74329Smrg func_warning "'$output' will be relinked during installation" 10750e3d74329Smrg ;; 10751e3d74329Smrg *,yes) 10752e3d74329Smrg link_command=$finalize_var$compile_command$finalize_rpath 10753e3d74329Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10754e3d74329Smrg ;; 10755e3d74329Smrg *,no) 10756e3d74329Smrg link_command=$compile_var$compile_command$compile_rpath 10757e3d74329Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10758e3d74329Smrg ;; 10759e3d74329Smrg *,needless) 10760e3d74329Smrg link_command=$finalize_var$compile_command$finalize_rpath 10761e3d74329Smrg relink_command= 10762e3d74329Smrg ;; 10763e3d74329Smrg esac 10764c582b7e3Smrg 1076542a55b46Smrg # Replace the output file specification. 1076642a55b46Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10767c582b7e3Smrg 1076842a55b46Smrg # Delete the old output files. 1076942a55b46Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10770c582b7e3Smrg 1077142a55b46Smrg func_show_eval "$link_command" 'exit $?' 10772c582b7e3Smrg 1077342a55b46Smrg if test -n "$postlink_cmds"; then 1077442a55b46Smrg func_to_tool_file "$output_objdir/$outputname" 1077542a55b46Smrg 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'` 1077642a55b46Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1077742a55b46Smrg fi 10778c582b7e3Smrg 1077942a55b46Smrg # Now create the wrapper script. 1078042a55b46Smrg func_verbose "creating $output" 10781c582b7e3Smrg 1078242a55b46Smrg # Quote the relink command for shipping. 1078342a55b46Smrg if test -n "$relink_command"; then 1078442a55b46Smrg # Preserve any variables that may affect compiler behavior 1078542a55b46Smrg for var in $variables_saved_for_relink; do 1078642a55b46Smrg if eval test -z \"\${$var+set}\"; then 1078742a55b46Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1078842a55b46Smrg elif eval var_value=\$$var; test -z "$var_value"; then 1078942a55b46Smrg relink_command="$var=; export $var; $relink_command" 10790c582b7e3Smrg else 107918ce07328Smrg func_quote_arg pretty "$var_value" 107928ce07328Smrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 10793c582b7e3Smrg fi 1079442a55b46Smrg done 107958ce07328Smrg func_quote eval cd "`pwd`" 107968ce07328Smrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 107978ce07328Smrg relink_command=$func_quote_arg_unquoted_result 1079842a55b46Smrg fi 1079942a55b46Smrg 1080042a55b46Smrg # Only actually do things if not in dry run mode. 1080142a55b46Smrg $opt_dry_run || { 1080242a55b46Smrg # win32 will think the script is a binary if it has 1080342a55b46Smrg # a .exe suffix, so we strip it off here. 1080442a55b46Smrg case $output in 1080542a55b46Smrg *.exe) func_stripname '' '.exe' "$output" 1080642a55b46Smrg output=$func_stripname_result ;; 10807c582b7e3Smrg esac 1080842a55b46Smrg # test for cygwin because mv fails w/o .exe extensions 1080942a55b46Smrg case $host in 1081042a55b46Smrg *cygwin*) 1081142a55b46Smrg exeext=.exe 1081242a55b46Smrg func_stripname '' '.exe' "$outputname" 1081342a55b46Smrg outputname=$func_stripname_result ;; 1081442a55b46Smrg *) exeext= ;; 1081542a55b46Smrg esac 1081642a55b46Smrg case $host in 1081742a55b46Smrg *cygwin* | *mingw* ) 1081842a55b46Smrg func_dirname_and_basename "$output" "" "." 1081942a55b46Smrg output_name=$func_basename_result 1082042a55b46Smrg output_path=$func_dirname_result 10821e3d74329Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 10822e3d74329Smrg cwrapper=$output_path/$output_name.exe 1082342a55b46Smrg $RM $cwrappersource $cwrapper 1082442a55b46Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 1082542a55b46Smrg 1082642a55b46Smrg func_emit_cwrapperexe_src > $cwrappersource 1082742a55b46Smrg 1082842a55b46Smrg # The wrapper executable is built using the $host compiler, 1082942a55b46Smrg # because it contains $host paths and files. If cross- 1083042a55b46Smrg # compiling, it, like the target executable, must be 1083142a55b46Smrg # executed on the $host or under an emulation environment. 1083242a55b46Smrg $opt_dry_run || { 1083342a55b46Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 1083442a55b46Smrg $STRIP $cwrapper 1083542a55b46Smrg } 10836c582b7e3Smrg 1083742a55b46Smrg # Now, create the wrapper script for func_source use: 1083842a55b46Smrg func_ltwrapper_scriptname $cwrapper 1083942a55b46Smrg $RM $func_ltwrapper_scriptname_result 1084042a55b46Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 1084142a55b46Smrg $opt_dry_run || { 1084242a55b46Smrg # note: this script will not be executed, so do not chmod. 10843e3d74329Smrg if test "x$build" = "x$host"; then 1084442a55b46Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 1084542a55b46Smrg else 1084642a55b46Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 1084742a55b46Smrg fi 1084842a55b46Smrg } 1084942a55b46Smrg ;; 1085042a55b46Smrg * ) 1085142a55b46Smrg $RM $output 1085242a55b46Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10853c582b7e3Smrg 1085442a55b46Smrg func_emit_wrapper no > $output 1085542a55b46Smrg chmod +x $output 1085642a55b46Smrg ;; 1085742a55b46Smrg esac 1085842a55b46Smrg } 1085942a55b46Smrg exit $EXIT_SUCCESS 1086042a55b46Smrg ;; 1086142a55b46Smrg esac 10862c582b7e3Smrg 1086342a55b46Smrg # See if we need to build an old-fashioned archive. 1086442a55b46Smrg for oldlib in $oldlibs; do 10865c582b7e3Smrg 10866e3d74329Smrg case $build_libtool_libs in 10867e3d74329Smrg convenience) 10868e3d74329Smrg oldobjs="$libobjs_save $symfileobj" 10869e3d74329Smrg addlibs=$convenience 1087042a55b46Smrg build_libtool_libs=no 10871e3d74329Smrg ;; 10872e3d74329Smrg module) 10873e3d74329Smrg oldobjs=$libobjs_save 10874e3d74329Smrg addlibs=$old_convenience 10875e3d74329Smrg build_libtool_libs=no 10876e3d74329Smrg ;; 10877e3d74329Smrg *) 1087842a55b46Smrg oldobjs="$old_deplibs $non_pic_objects" 10879e3d74329Smrg $preload && test -f "$symfileobj" \ 10880e3d74329Smrg && func_append oldobjs " $symfileobj" 10881e3d74329Smrg addlibs=$old_convenience 10882e3d74329Smrg ;; 10883e3d74329Smrg esac 10884c582b7e3Smrg 1088542a55b46Smrg if test -n "$addlibs"; then 10886e3d74329Smrg gentop=$output_objdir/${outputname}x 1088742a55b46Smrg func_append generated " $gentop" 10888c582b7e3Smrg 1088942a55b46Smrg func_extract_archives $gentop $addlibs 1089042a55b46Smrg func_append oldobjs " $func_extract_archives_result" 1089142a55b46Smrg fi 10892c582b7e3Smrg 1089342a55b46Smrg # Do each command in the archive commands. 10894e3d74329Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 1089542a55b46Smrg cmds=$old_archive_from_new_cmds 1089642a55b46Smrg else 10897c582b7e3Smrg 1089842a55b46Smrg # Add any objects from preloaded convenience libraries 1089942a55b46Smrg if test -n "$dlprefiles"; then 10900e3d74329Smrg gentop=$output_objdir/${outputname}x 1090142a55b46Smrg func_append generated " $gentop" 10902c582b7e3Smrg 1090342a55b46Smrg func_extract_archives $gentop $dlprefiles 1090442a55b46Smrg func_append oldobjs " $func_extract_archives_result" 1090542a55b46Smrg fi 10906c582b7e3Smrg 1090742a55b46Smrg # POSIX demands no paths to be encoded in archives. We have 1090842a55b46Smrg # to avoid creating archives with duplicate basenames if we 1090942a55b46Smrg # might have to extract them afterwards, e.g., when creating a 1091042a55b46Smrg # static archive out of a convenience library, or when linking 1091142a55b46Smrg # the entirety of a libtool archive into another (currently 1091242a55b46Smrg # not supported by libtool). 1091342a55b46Smrg if (for obj in $oldobjs 1091442a55b46Smrg do 1091542a55b46Smrg func_basename "$obj" 1091642a55b46Smrg $ECHO "$func_basename_result" 1091742a55b46Smrg done | sort | sort -uc >/dev/null 2>&1); then 1091842a55b46Smrg : 1091942a55b46Smrg else 1092042a55b46Smrg echo "copying selected object files to avoid basename conflicts..." 10921e3d74329Smrg gentop=$output_objdir/${outputname}x 1092242a55b46Smrg func_append generated " $gentop" 1092342a55b46Smrg func_mkdir_p "$gentop" 1092442a55b46Smrg save_oldobjs=$oldobjs 1092542a55b46Smrg oldobjs= 1092642a55b46Smrg counter=1 1092742a55b46Smrg for obj in $save_oldobjs 1092842a55b46Smrg do 1092942a55b46Smrg func_basename "$obj" 10930e3d74329Smrg objbase=$func_basename_result 1093142a55b46Smrg case " $oldobjs " in 1093242a55b46Smrg " ") oldobjs=$obj ;; 1093342a55b46Smrg *[\ /]"$objbase "*) 1093442a55b46Smrg while :; do 1093542a55b46Smrg # Make sure we don't pick an alternate name that also 1093642a55b46Smrg # overlaps. 1093742a55b46Smrg newobj=lt$counter-$objbase 1093842a55b46Smrg func_arith $counter + 1 1093942a55b46Smrg counter=$func_arith_result 1094042a55b46Smrg case " $oldobjs " in 1094142a55b46Smrg *[\ /]"$newobj "*) ;; 1094242a55b46Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 1094342a55b46Smrg esac 1094442a55b46Smrg done 1094542a55b46Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 1094642a55b46Smrg func_append oldobjs " $gentop/$newobj" 1094742a55b46Smrg ;; 1094842a55b46Smrg *) func_append oldobjs " $obj" ;; 1094942a55b46Smrg esac 10950c582b7e3Smrg done 10951c582b7e3Smrg fi 1095242a55b46Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 1095342a55b46Smrg tool_oldlib=$func_to_tool_file_result 1095442a55b46Smrg eval cmds=\"$old_archive_cmds\" 10955c582b7e3Smrg 1095642a55b46Smrg func_len " $cmds" 1095742a55b46Smrg len=$func_len_result 1095842a55b46Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 1095942a55b46Smrg cmds=$old_archive_cmds 1096042a55b46Smrg elif test -n "$archiver_list_spec"; then 1096142a55b46Smrg func_verbose "using command file archive linking..." 1096242a55b46Smrg for obj in $oldobjs 1096342a55b46Smrg do 1096442a55b46Smrg func_to_tool_file "$obj" 1096542a55b46Smrg $ECHO "$func_to_tool_file_result" 1096642a55b46Smrg done > $output_objdir/$libname.libcmd 1096742a55b46Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 1096842a55b46Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 1096942a55b46Smrg cmds=$old_archive_cmds 1097042a55b46Smrg else 1097142a55b46Smrg # the command line is too long to link in one step, link in parts 1097242a55b46Smrg func_verbose "using piecewise archive linking..." 1097342a55b46Smrg save_RANLIB=$RANLIB 1097442a55b46Smrg RANLIB=: 1097542a55b46Smrg objlist= 1097642a55b46Smrg concat_cmds= 1097742a55b46Smrg save_oldobjs=$oldobjs 1097842a55b46Smrg oldobjs= 1097942a55b46Smrg # Is there a better way of finding the last object in the list? 1098042a55b46Smrg for obj in $save_oldobjs 1098142a55b46Smrg do 1098242a55b46Smrg last_oldobj=$obj 1098342a55b46Smrg done 1098442a55b46Smrg eval test_cmds=\"$old_archive_cmds\" 1098542a55b46Smrg func_len " $test_cmds" 1098642a55b46Smrg len0=$func_len_result 1098742a55b46Smrg len=$len0 1098842a55b46Smrg for obj in $save_oldobjs 1098942a55b46Smrg do 1099042a55b46Smrg func_len " $obj" 1099142a55b46Smrg func_arith $len + $func_len_result 1099242a55b46Smrg len=$func_arith_result 1099342a55b46Smrg func_append objlist " $obj" 1099442a55b46Smrg if test "$len" -lt "$max_cmd_len"; then 1099542a55b46Smrg : 1099642a55b46Smrg else 1099742a55b46Smrg # the above command should be used before it gets too long 1099842a55b46Smrg oldobjs=$objlist 10999e3d74329Smrg if test "$obj" = "$last_oldobj"; then 1100042a55b46Smrg RANLIB=$save_RANLIB 1100142a55b46Smrg fi 1100242a55b46Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 11003e3d74329Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 1100442a55b46Smrg objlist= 1100542a55b46Smrg len=$len0 1100642a55b46Smrg fi 1100742a55b46Smrg done 1100842a55b46Smrg RANLIB=$save_RANLIB 1100942a55b46Smrg oldobjs=$objlist 11010e3d74329Smrg if test -z "$oldobjs"; then 1101142a55b46Smrg eval cmds=\"\$concat_cmds\" 1101242a55b46Smrg else 1101342a55b46Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 1101442a55b46Smrg fi 1101542a55b46Smrg fi 1101642a55b46Smrg fi 1101742a55b46Smrg func_execute_cmds "$cmds" 'exit $?' 11018c582b7e3Smrg done 11019c582b7e3Smrg 1102042a55b46Smrg test -n "$generated" && \ 1102142a55b46Smrg func_show_eval "${RM}r$generated" 11022c582b7e3Smrg 1102342a55b46Smrg # Now create the libtool archive. 1102442a55b46Smrg case $output in 1102542a55b46Smrg *.la) 1102642a55b46Smrg old_library= 11027e3d74329Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 1102842a55b46Smrg func_verbose "creating $output" 11029c582b7e3Smrg 1103042a55b46Smrg # Preserve any variables that may affect compiler behavior 1103142a55b46Smrg for var in $variables_saved_for_relink; do 1103242a55b46Smrg if eval test -z \"\${$var+set}\"; then 1103342a55b46Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1103442a55b46Smrg elif eval var_value=\$$var; test -z "$var_value"; then 1103542a55b46Smrg relink_command="$var=; export $var; $relink_command" 11036c582b7e3Smrg else 110378ce07328Smrg func_quote_arg pretty,unquoted "$var_value" 110388ce07328Smrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 11039c582b7e3Smrg fi 1104042a55b46Smrg done 1104142a55b46Smrg # Quote the link command for shipping. 110428ce07328Smrg func_quote eval cd "`pwd`" 110438ce07328Smrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 110448ce07328Smrg func_quote_arg pretty,unquoted "$relink_command" 110458ce07328Smrg relink_command=$func_quote_arg_unquoted_result 11046e3d74329Smrg if test yes = "$hardcode_automatic"; then 1104742a55b46Smrg relink_command= 1104842a55b46Smrg fi 11049c582b7e3Smrg 1105042a55b46Smrg # Only create the output if not a dry run. 1105142a55b46Smrg $opt_dry_run || { 1105242a55b46Smrg for installed in no yes; do 11053e3d74329Smrg if test yes = "$installed"; then 1105442a55b46Smrg if test -z "$install_libdir"; then 1105542a55b46Smrg break 1105642a55b46Smrg fi 11057e3d74329Smrg output=$output_objdir/${outputname}i 1105842a55b46Smrg # Replace all uninstalled libtool libraries with the installed ones 1105942a55b46Smrg newdependency_libs= 1106042a55b46Smrg for deplib in $dependency_libs; do 1106142a55b46Smrg case $deplib in 1106242a55b46Smrg *.la) 1106342a55b46Smrg func_basename "$deplib" 11064e3d74329Smrg name=$func_basename_result 1106542a55b46Smrg func_resolve_sysroot "$deplib" 11066e3d74329Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 1106742a55b46Smrg test -z "$libdir" && \ 11068e3d74329Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 1106942a55b46Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 1107042a55b46Smrg ;; 1107142a55b46Smrg -L*) 1107242a55b46Smrg func_stripname -L '' "$deplib" 1107342a55b46Smrg func_replace_sysroot "$func_stripname_result" 1107442a55b46Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 1107542a55b46Smrg ;; 1107642a55b46Smrg -R*) 1107742a55b46Smrg func_stripname -R '' "$deplib" 1107842a55b46Smrg func_replace_sysroot "$func_stripname_result" 1107942a55b46Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 1108042a55b46Smrg ;; 1108142a55b46Smrg *) func_append newdependency_libs " $deplib" ;; 1108242a55b46Smrg esac 1108342a55b46Smrg done 11084e3d74329Smrg dependency_libs=$newdependency_libs 1108542a55b46Smrg newdlfiles= 1108642a55b46Smrg 1108742a55b46Smrg for lib in $dlfiles; do 1108842a55b46Smrg case $lib in 1108942a55b46Smrg *.la) 1109042a55b46Smrg func_basename "$lib" 11091e3d74329Smrg name=$func_basename_result 11092e3d74329Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1109342a55b46Smrg test -z "$libdir" && \ 11094e3d74329Smrg func_fatal_error "'$lib' is not a valid libtool archive" 1109542a55b46Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 1109642a55b46Smrg ;; 1109742a55b46Smrg *) func_append newdlfiles " $lib" ;; 1109842a55b46Smrg esac 1109942a55b46Smrg done 11100e3d74329Smrg dlfiles=$newdlfiles 1110142a55b46Smrg newdlprefiles= 1110242a55b46Smrg for lib in $dlprefiles; do 1110342a55b46Smrg case $lib in 1110442a55b46Smrg *.la) 1110542a55b46Smrg # Only pass preopened files to the pseudo-archive (for 1110642a55b46Smrg # eventual linking with the app. that links it) if we 1110742a55b46Smrg # didn't already link the preopened objects directly into 1110842a55b46Smrg # the library: 1110942a55b46Smrg func_basename "$lib" 11110e3d74329Smrg name=$func_basename_result 11111e3d74329Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1111242a55b46Smrg test -z "$libdir" && \ 11113e3d74329Smrg func_fatal_error "'$lib' is not a valid libtool archive" 1111442a55b46Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 1111542a55b46Smrg ;; 1111642a55b46Smrg esac 1111742a55b46Smrg done 11118e3d74329Smrg dlprefiles=$newdlprefiles 1111942a55b46Smrg else 1112042a55b46Smrg newdlfiles= 1112142a55b46Smrg for lib in $dlfiles; do 1112242a55b46Smrg case $lib in 11123e3d74329Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1112442a55b46Smrg *) abs=`pwd`"/$lib" ;; 1112542a55b46Smrg esac 1112642a55b46Smrg func_append newdlfiles " $abs" 1112742a55b46Smrg done 11128e3d74329Smrg dlfiles=$newdlfiles 1112942a55b46Smrg newdlprefiles= 1113042a55b46Smrg for lib in $dlprefiles; do 1113142a55b46Smrg case $lib in 11132e3d74329Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1113342a55b46Smrg *) abs=`pwd`"/$lib" ;; 1113442a55b46Smrg esac 1113542a55b46Smrg func_append newdlprefiles " $abs" 1113642a55b46Smrg done 11137e3d74329Smrg dlprefiles=$newdlprefiles 1113842a55b46Smrg fi 1113942a55b46Smrg $RM $output 1114042a55b46Smrg # place dlname in correct position for cygwin 1114142a55b46Smrg # In fact, it would be nice if we could use this code for all target 1114242a55b46Smrg # systems that can't hard-code library paths into their executables 1114342a55b46Smrg # and that have no shared library path variable independent of PATH, 1114442a55b46Smrg # but it turns out we can't easily determine that from inspecting 1114542a55b46Smrg # libtool variables, so we have to hard-code the OSs to which it 1114642a55b46Smrg # applies here; at the moment, that means platforms that use the PE 1114742a55b46Smrg # object format with DLL files. See the long comment at the top of 1114842a55b46Smrg # tests/bindir.at for full details. 1114942a55b46Smrg tdlname=$dlname 1115042a55b46Smrg case $host,$output,$installed,$module,$dlname in 1115142a55b46Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 1115242a55b46Smrg # If a -bindir argument was supplied, place the dll there. 11153e3d74329Smrg if test -n "$bindir"; then 1115442a55b46Smrg func_relative_path "$install_libdir" "$bindir" 11155e3d74329Smrg tdlname=$func_relative_path_result/$dlname 1115642a55b46Smrg else 1115742a55b46Smrg # Otherwise fall back on heuristic. 1115842a55b46Smrg tdlname=../bin/$dlname 1115942a55b46Smrg fi 1116042a55b46Smrg ;; 1116142a55b46Smrg esac 1116242a55b46Smrg $ECHO > $output "\ 1116342a55b46Smrg# $outputname - a libtool library file 11164e3d74329Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 1116542a55b46Smrg# 1116642a55b46Smrg# Please DO NOT delete this file! 1116742a55b46Smrg# It is necessary for linking the library. 11168c582b7e3Smrg 1116942a55b46Smrg# The name that we can dlopen(3). 1117042a55b46Smrgdlname='$tdlname' 11171c582b7e3Smrg 1117242a55b46Smrg# Names of this library. 1117342a55b46Smrglibrary_names='$library_names' 11174c582b7e3Smrg 1117542a55b46Smrg# The name of the static archive. 1117642a55b46Smrgold_library='$old_library' 11177c582b7e3Smrg 11178e3d74329Smrg# Linker flags that cannot go in dependency_libs. 1117942a55b46Smrginherited_linker_flags='$new_inherited_linker_flags' 11180c582b7e3Smrg 1118142a55b46Smrg# Libraries that this one depends upon. 1118242a55b46Smrgdependency_libs='$dependency_libs' 11183c582b7e3Smrg 1118442a55b46Smrg# Names of additional weak libraries provided by this library 1118542a55b46Smrgweak_library_names='$weak_libs' 11186c582b7e3Smrg 1118742a55b46Smrg# Version information for $libname. 1118842a55b46Smrgcurrent=$current 1118942a55b46Smrgage=$age 1119042a55b46Smrgrevision=$revision 11191c582b7e3Smrg 1119242a55b46Smrg# Is this an already installed library? 1119342a55b46Smrginstalled=$installed 11194c582b7e3Smrg 1119542a55b46Smrg# Should we warn about portability when linking against -modules? 1119642a55b46Smrgshouldnotlink=$module 11197c582b7e3Smrg 1119842a55b46Smrg# Files to dlopen/dlpreopen 1119942a55b46Smrgdlopen='$dlfiles' 1120042a55b46Smrgdlpreopen='$dlprefiles' 11201c582b7e3Smrg 1120242a55b46Smrg# Directory that this library needs to be installed in: 1120342a55b46Smrglibdir='$install_libdir'" 11204e3d74329Smrg if test no,yes = "$installed,$need_relink"; then 1120542a55b46Smrg $ECHO >> $output "\ 1120642a55b46Smrgrelink_command=\"$relink_command\"" 1120742a55b46Smrg fi 1120842a55b46Smrg done 1120942a55b46Smrg } 11210c582b7e3Smrg 1121142a55b46Smrg # Do a symbolic link so that the libtool archive can be found in 1121242a55b46Smrg # LD_LIBRARY_PATH before the program is installed. 1121342a55b46Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 1121442a55b46Smrg ;; 1121542a55b46Smrg esac 1121642a55b46Smrg exit $EXIT_SUCCESS 1121742a55b46Smrg} 11218c582b7e3Smrg 11219e3d74329Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 11220e3d74329Smrg func_mode_link ${1+"$@"} 11221e3d74329Smrgfi 11222c582b7e3Smrg 11223c582b7e3Smrg 1122442a55b46Smrg# func_mode_uninstall arg... 1122542a55b46Smrgfunc_mode_uninstall () 1122642a55b46Smrg{ 11227e3d74329Smrg $debug_cmd 11228e3d74329Smrg 11229e3d74329Smrg RM=$nonopt 11230c582b7e3Smrg files= 11231e3d74329Smrg rmforce=false 11232c582b7e3Smrg exit_status=0 11233c582b7e3Smrg 11234c582b7e3Smrg # This variable tells wrapper scripts just to set variables rather 11235c582b7e3Smrg # than running their programs. 11236e3d74329Smrg libtool_install_magic=$magic 11237c582b7e3Smrg 11238c582b7e3Smrg for arg 11239c582b7e3Smrg do 11240c582b7e3Smrg case $arg in 11241e3d74329Smrg -f) func_append RM " $arg"; rmforce=: ;; 1124242a55b46Smrg -*) func_append RM " $arg" ;; 1124342a55b46Smrg *) func_append files " $arg" ;; 11244c582b7e3Smrg esac 11245c582b7e3Smrg done 11246c582b7e3Smrg 1124742a55b46Smrg test -z "$RM" && \ 1124842a55b46Smrg func_fatal_help "you must specify an RM program" 11249c582b7e3Smrg 11250c582b7e3Smrg rmdirs= 11251c582b7e3Smrg 11252c582b7e3Smrg for file in $files; do 1125342a55b46Smrg func_dirname "$file" "" "." 11254e3d74329Smrg dir=$func_dirname_result 11255e3d74329Smrg if test . = "$dir"; then 11256e3d74329Smrg odir=$objdir 11257c582b7e3Smrg else 11258e3d74329Smrg odir=$dir/$objdir 11259c582b7e3Smrg fi 1126042a55b46Smrg func_basename "$file" 11261e3d74329Smrg name=$func_basename_result 11262e3d74329Smrg test uninstall = "$opt_mode" && odir=$dir 11263c582b7e3Smrg 1126442a55b46Smrg # Remember odir for removal later, being careful to avoid duplicates 11265e3d74329Smrg if test clean = "$opt_mode"; then 11266c582b7e3Smrg case " $rmdirs " in 1126742a55b46Smrg *" $odir "*) ;; 1126842a55b46Smrg *) func_append rmdirs " $odir" ;; 11269c582b7e3Smrg esac 11270c582b7e3Smrg fi 11271c582b7e3Smrg 11272c582b7e3Smrg # Don't error if the file doesn't exist and rm -f was used. 1127342a55b46Smrg if { test -L "$file"; } >/dev/null 2>&1 || 1127442a55b46Smrg { test -h "$file"; } >/dev/null 2>&1 || 1127542a55b46Smrg test -f "$file"; then 11276c582b7e3Smrg : 11277c582b7e3Smrg elif test -d "$file"; then 11278c582b7e3Smrg exit_status=1 11279c582b7e3Smrg continue 11280e3d74329Smrg elif $rmforce; then 11281c582b7e3Smrg continue 11282c582b7e3Smrg fi 11283c582b7e3Smrg 11284e3d74329Smrg rmfiles=$file 11285c582b7e3Smrg 11286c582b7e3Smrg case $name in 11287c582b7e3Smrg *.la) 11288c582b7e3Smrg # Possibly a libtool archive, so verify it. 1128942a55b46Smrg if func_lalib_p "$file"; then 1129042a55b46Smrg func_source $dir/$name 11291c582b7e3Smrg 11292c582b7e3Smrg # Delete the libtool libraries and symlinks. 11293c582b7e3Smrg for n in $library_names; do 1129442a55b46Smrg func_append rmfiles " $odir/$n" 11295c582b7e3Smrg done 1129642a55b46Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11297c582b7e3Smrg 11298e3d74329Smrg case $opt_mode in 11299c582b7e3Smrg clean) 1130042a55b46Smrg case " $library_names " in 11301c582b7e3Smrg *" $dlname "*) ;; 1130242a55b46Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11303c582b7e3Smrg esac 1130442a55b46Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11305c582b7e3Smrg ;; 11306c582b7e3Smrg uninstall) 11307c582b7e3Smrg if test -n "$library_names"; then 11308c582b7e3Smrg # Do each command in the postuninstall commands. 11309e3d74329Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11310c582b7e3Smrg fi 11311c582b7e3Smrg 11312c582b7e3Smrg if test -n "$old_library"; then 11313c582b7e3Smrg # Do each command in the old_postuninstall commands. 11314e3d74329Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11315c582b7e3Smrg fi 11316c582b7e3Smrg # FIXME: should reinstall the best remaining shared library. 11317c582b7e3Smrg ;; 11318c582b7e3Smrg esac 11319c582b7e3Smrg fi 11320c582b7e3Smrg ;; 11321c582b7e3Smrg 11322c582b7e3Smrg *.lo) 11323c582b7e3Smrg # Possibly a libtool object, so verify it. 1132442a55b46Smrg if func_lalib_p "$file"; then 11325c582b7e3Smrg 11326c582b7e3Smrg # Read the .lo file 1132742a55b46Smrg func_source $dir/$name 11328c582b7e3Smrg 11329c582b7e3Smrg # Add PIC object to the list of files to remove. 11330e3d74329Smrg if test -n "$pic_object" && test none != "$pic_object"; then 1133142a55b46Smrg func_append rmfiles " $dir/$pic_object" 11332c582b7e3Smrg fi 11333c582b7e3Smrg 11334c582b7e3Smrg # Add non-PIC object to the list of files to remove. 11335e3d74329Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 1133642a55b46Smrg func_append rmfiles " $dir/$non_pic_object" 11337c582b7e3Smrg fi 11338c582b7e3Smrg fi 11339c582b7e3Smrg ;; 11340c582b7e3Smrg 11341c582b7e3Smrg *) 11342e3d74329Smrg if test clean = "$opt_mode"; then 11343c582b7e3Smrg noexename=$name 11344c582b7e3Smrg case $file in 11345c582b7e3Smrg *.exe) 1134642a55b46Smrg func_stripname '' '.exe' "$file" 1134742a55b46Smrg file=$func_stripname_result 1134842a55b46Smrg func_stripname '' '.exe' "$name" 1134942a55b46Smrg noexename=$func_stripname_result 11350c582b7e3Smrg # $file with .exe has already been added to rmfiles, 11351c582b7e3Smrg # add $file without .exe 1135242a55b46Smrg func_append rmfiles " $file" 11353c582b7e3Smrg ;; 11354c582b7e3Smrg esac 11355c582b7e3Smrg # Do a test to see if this is a libtool program. 1135642a55b46Smrg if func_ltwrapper_p "$file"; then 1135742a55b46Smrg if func_ltwrapper_executable_p "$file"; then 1135842a55b46Smrg func_ltwrapper_scriptname "$file" 1135942a55b46Smrg relink_command= 1136042a55b46Smrg func_source $func_ltwrapper_scriptname_result 1136142a55b46Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 1136242a55b46Smrg else 1136342a55b46Smrg relink_command= 1136442a55b46Smrg func_source $dir/$noexename 1136542a55b46Smrg fi 11366c582b7e3Smrg 11367c582b7e3Smrg # note $name still contains .exe if it was in $file originally 11368c582b7e3Smrg # as does the version of $file that was added into $rmfiles 11369e3d74329Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11370e3d74329Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 1137142a55b46Smrg func_append rmfiles " $odir/lt-$name" 11372c582b7e3Smrg fi 11373e3d74329Smrg if test "X$noexename" != "X$name"; then 11374e3d74329Smrg func_append rmfiles " $odir/lt-$noexename.c" 11375c582b7e3Smrg fi 11376c582b7e3Smrg fi 11377c582b7e3Smrg fi 11378c582b7e3Smrg ;; 11379c582b7e3Smrg esac 1138042a55b46Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11381c582b7e3Smrg done 11382c582b7e3Smrg 11383e3d74329Smrg # Try to remove the $objdir's in the directories where we deleted files 11384c582b7e3Smrg for dir in $rmdirs; do 11385c582b7e3Smrg if test -d "$dir"; then 1138642a55b46Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11387c582b7e3Smrg fi 11388c582b7e3Smrg done 11389c582b7e3Smrg 11390c582b7e3Smrg exit $exit_status 1139142a55b46Smrg} 11392c582b7e3Smrg 11393e3d74329Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11394e3d74329Smrg func_mode_uninstall ${1+"$@"} 11395e3d74329Smrgfi 11396c582b7e3Smrg 1139742a55b46Smrgtest -z "$opt_mode" && { 11398e3d74329Smrg help=$generic_help 1139942a55b46Smrg func_fatal_help "you must specify a MODE" 1140042a55b46Smrg} 1140142a55b46Smrg 1140242a55b46Smrgtest -z "$exec_cmd" && \ 11403e3d74329Smrg func_fatal_help "invalid operation mode '$opt_mode'" 11404c582b7e3Smrg 11405c582b7e3Smrgif test -n "$exec_cmd"; then 1140642a55b46Smrg eval exec "$exec_cmd" 11407c582b7e3Smrg exit $EXIT_FAILURE 11408c582b7e3Smrgfi 11409c582b7e3Smrg 1141042a55b46Smrgexit $exit_status 11411c582b7e3Smrg 11412c582b7e3Smrg 11413c582b7e3Smrg# The TAGs below are defined such that we never get into a situation 11414e3d74329Smrg# where we disable both kinds of libraries. Given conflicting 11415c582b7e3Smrg# choices, we go for a static library, that is the most portable, 11416c582b7e3Smrg# since we can't tell whether shared libraries were disabled because 11417c582b7e3Smrg# the user asked for that or because the platform doesn't support 11418c582b7e3Smrg# them. This is particularly important on AIX, because we don't 11419c582b7e3Smrg# support having both static and shared libraries enabled at the same 11420c582b7e3Smrg# time on that platform, so we default to a shared-only configuration. 11421c582b7e3Smrg# If a disable-shared tag is given, we'll fallback to a static-only 11422c582b7e3Smrg# configuration. But we'll never go from static-only to shared-only. 11423c582b7e3Smrg 11424c582b7e3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 1142542a55b46Smrgbuild_libtool_libs=no 1142642a55b46Smrgbuild_old_libs=yes 11427c582b7e3Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 11428c582b7e3Smrg 11429c582b7e3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 1143042a55b46Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11431c582b7e3Smrg# ### END LIBTOOL TAG CONFIG: disable-static 11432c582b7e3Smrg 11433c582b7e3Smrg# Local Variables: 11434c582b7e3Smrg# mode:shell-script 11435c582b7e3Smrg# sh-indentation:2 11436c582b7e3Smrg# End: 11437