1370b807fSmrg#! /usr/bin/env sh 2e4da38afSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3370b807fSmrg## by inline-source v2019-02-19.15 4fc27e79cSmrg 5370b807fSmrg# libtool (GNU libtool) 2.4.7 6e4da38afSmrg# Provide generalized library-building support services. 7fc27e79cSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8fc27e79cSmrg 9370b807fSmrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 10fc27e79cSmrg# This is free software; see the source for copying conditions. There is NO 11fc27e79cSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12fc27e79cSmrg 13fc27e79cSmrg# GNU Libtool is free software; you can redistribute it and/or modify 14659607e0Smrg# it under the terms of the GNU General Public License as published by 15659607e0Smrg# the Free Software Foundation; either version 2 of the License, or 16659607e0Smrg# (at your option) any later version. 17659607e0Smrg# 18fc27e79cSmrg# As a special exception to the GNU General Public License, 19fc27e79cSmrg# if you distribute this file as part of a program or library that 20fc27e79cSmrg# is built using GNU Libtool, you may include this file under the 21fc27e79cSmrg# same distribution terms that you use for the rest of that program. 22fc27e79cSmrg# 23fc27e79cSmrg# GNU Libtool is distributed in the hope that it will be useful, but 24659607e0Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25659607e0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26659607e0Smrg# General Public License for more details. 27659607e0Smrg# 28659607e0Smrg# You should have received a copy of the GNU General Public License 29e4da38afSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30fc27e79cSmrg 31fc27e79cSmrg 32bd3a1963SmrgPROGRAM=libtool 33fc27e79cSmrgPACKAGE=libtool 34370b807fSmrgVERSION=2.4.7 35370b807fSmrgpackage_revision=2.4.7 36fc27e79cSmrg 37e4da38afSmrg 38e4da38afSmrg## ------ ## 39e4da38afSmrg## Usage. ## 40e4da38afSmrg## ------ ## 41e4da38afSmrg 42e4da38afSmrg# Run './libtool --help' for help with using this script from the 43e4da38afSmrg# command line. 44e4da38afSmrg 45e4da38afSmrg 46e4da38afSmrg## ------------------------------- ## 47e4da38afSmrg## User overridable command paths. ## 48e4da38afSmrg## ------------------------------- ## 49e4da38afSmrg 50e4da38afSmrg# After configure completes, it has a better idea of some of the 51e4da38afSmrg# shell tools we need than the defaults used by the functions shared 52e4da38afSmrg# with bootstrap, so set those here where they can still be over- 53e4da38afSmrg# ridden by the user, but otherwise take precedence. 54e4da38afSmrg 55e4da38afSmrg: ${AUTOCONF="autoconf"} 56e4da38afSmrg: ${AUTOMAKE="automake"} 57e4da38afSmrg 58e4da38afSmrg 59e4da38afSmrg## -------------------------- ## 60e4da38afSmrg## Source external libraries. ## 61e4da38afSmrg## -------------------------- ## 62e4da38afSmrg 63e4da38afSmrg# Much of our low-level functionality needs to be sourced from external 64e4da38afSmrg# libraries, which are installed to $pkgauxdir. 65e4da38afSmrg 66e4da38afSmrg# Set a version string for this script. 67370b807fSmrgscriptversion=2019-02-19.15; # UTC 68e4da38afSmrg 69e4da38afSmrg# General shell script boiler plate, and helper functions. 70e4da38afSmrg# Written by Gary V. Vaughan, 2004 71e4da38afSmrg 72370b807fSmrg# This is free software. There is NO warranty; not even for 73370b807fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 74370b807fSmrg# 75370b807fSmrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 76370b807fSmrg# 77370b807fSmrg# This file is dual licensed under the terms of the MIT license 78370b807fSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 79370b807fSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 80370b807fSmrg# these licenses when using or redistributing this software or any of 81370b807fSmrg# the files within it. See the URLs above, or the file `LICENSE` 82370b807fSmrg# included in the Bootstrap distribution for the full license texts. 83e4da38afSmrg 84370b807fSmrg# Please report bugs or propose patches to: 85370b807fSmrg# <https://github.com/gnulib-modules/bootstrap/issues> 86e4da38afSmrg 87e4da38afSmrg 88e4da38afSmrg## ------ ## 89e4da38afSmrg## Usage. ## 90e4da38afSmrg## ------ ## 91e4da38afSmrg 92e4da38afSmrg# Evaluate this file near the top of your script to gain access to 93e4da38afSmrg# the functions and variables defined here: 94e4da38afSmrg# 95e4da38afSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 96e4da38afSmrg# 97e4da38afSmrg# If you need to override any of the default environment variable 98e4da38afSmrg# settings, do that before evaluating this file. 99e4da38afSmrg 100e4da38afSmrg 101e4da38afSmrg## -------------------- ## 102e4da38afSmrg## Shell normalisation. ## 103e4da38afSmrg## -------------------- ## 104e4da38afSmrg 105e4da38afSmrg# Some shells need a little help to be as Bourne compatible as possible. 106e4da38afSmrg# Before doing anything else, make sure all that help has been provided! 107e4da38afSmrg 108e4da38afSmrgDUALCASE=1; export DUALCASE # for MKS sh 109e4da38afSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 110fc27e79cSmrg emulate sh 111fc27e79cSmrg NULLCMD=: 112e4da38afSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 113fc27e79cSmrg # is contrary to our usage. Disable this feature. 114fc27e79cSmrg alias -g '${1+"$@"}'='"$@"' 115fc27e79cSmrg setopt NO_GLOB_SUBST 116fc27e79cSmrgelse 117e4da38afSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 118fc27e79cSmrgfi 119bd3a1963Smrg 120e4da38afSmrg# NLS nuisances: We save the old values in case they are required later. 121e4da38afSmrg_G_user_locale= 122e4da38afSmrg_G_safe_locale= 123e4da38afSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 124fc27e79cSmrgdo 125e4da38afSmrg eval "if test set = \"\${$_G_var+set}\"; then 126e4da38afSmrg save_$_G_var=\$$_G_var 127e4da38afSmrg $_G_var=C 128e4da38afSmrg export $_G_var 129e4da38afSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 130e4da38afSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 131fc27e79cSmrg fi" 132fc27e79cSmrgdone 133370b807fSmrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 134370b807fSmrg# in case the environment reset is needed later and the $save_* variant is not 135370b807fSmrg# defined (see the code above). 136370b807fSmrgLC_ALL=C 137370b807fSmrgLANGUAGE=C 138370b807fSmrgexport LANGUAGE LC_ALL 139fc27e79cSmrg 140e4da38afSmrg# Make sure IFS has a sensible default 141e4da38afSmrgsp=' ' 142e4da38afSmrgnl=' 143e4da38afSmrg' 144e4da38afSmrgIFS="$sp $nl" 145e4da38afSmrg 146e4da38afSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 147e4da38afSmrgif test "${PATH_SEPARATOR+set}" != set; then 148e4da38afSmrg PATH_SEPARATOR=: 149e4da38afSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 150e4da38afSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 151e4da38afSmrg PATH_SEPARATOR=';' 152e4da38afSmrg } 153e4da38afSmrgfi 154fc27e79cSmrg 155fc27e79cSmrg 156370b807fSmrg# func_unset VAR 157370b807fSmrg# -------------- 158370b807fSmrg# Portably unset VAR. 159370b807fSmrg# In some shells, an 'unset VAR' statement leaves a non-zero return 160370b807fSmrg# status if VAR is already unset, which might be problematic if the 161370b807fSmrg# statement is used at the end of a function (thus poisoning its return 162370b807fSmrg# value) or when 'set -e' is active (causing even a spurious abort of 163370b807fSmrg# the script in this case). 164370b807fSmrgfunc_unset () 165370b807fSmrg{ 166370b807fSmrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 167370b807fSmrg} 168370b807fSmrg 169370b807fSmrg 170370b807fSmrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 171370b807fSmrgfunc_unset CDPATH 172370b807fSmrg 173370b807fSmrg# Make sure ${,E,F}GREP behave sanely. 174370b807fSmrgfunc_unset GREP_OPTIONS 175370b807fSmrg 176fc27e79cSmrg 177e4da38afSmrg## ------------------------- ## 178e4da38afSmrg## Locate command utilities. ## 179e4da38afSmrg## ------------------------- ## 180e4da38afSmrg 181e4da38afSmrg 182e4da38afSmrg# func_executable_p FILE 183e4da38afSmrg# ---------------------- 184e4da38afSmrg# Check that FILE is an executable regular file. 185e4da38afSmrgfunc_executable_p () 186e4da38afSmrg{ 187e4da38afSmrg test -f "$1" && test -x "$1" 188e4da38afSmrg} 189e4da38afSmrg 190e4da38afSmrg 191e4da38afSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 192e4da38afSmrg# -------------------------------------------- 193e4da38afSmrg# Search for either a program that responds to --version with output 194e4da38afSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 195e4da38afSmrg# trying all the directories in PATH with each of the elements of 196e4da38afSmrg# PROGS_LIST. 197e4da38afSmrg# 198e4da38afSmrg# CHECK_FUNC should accept the path to a candidate program, and 199e4da38afSmrg# set $func_check_prog_result if it truncates its output less than 200e4da38afSmrg# $_G_path_prog_max characters. 201e4da38afSmrgfunc_path_progs () 202e4da38afSmrg{ 203e4da38afSmrg _G_progs_list=$1 204e4da38afSmrg _G_check_func=$2 205e4da38afSmrg _G_PATH=${3-"$PATH"} 206e4da38afSmrg 207e4da38afSmrg _G_path_prog_max=0 208e4da38afSmrg _G_path_prog_found=false 209e4da38afSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 210e4da38afSmrg for _G_dir in $_G_PATH; do 211e4da38afSmrg IFS=$_G_save_IFS 212e4da38afSmrg test -z "$_G_dir" && _G_dir=. 213e4da38afSmrg for _G_prog_name in $_G_progs_list; do 214e4da38afSmrg for _exeext in '' .EXE; do 215e4da38afSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 216e4da38afSmrg func_executable_p "$_G_path_prog" || continue 217e4da38afSmrg case `"$_G_path_prog" --version 2>&1` in 218e4da38afSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 219e4da38afSmrg *) $_G_check_func $_G_path_prog 220e4da38afSmrg func_path_progs_result=$func_check_prog_result 221e4da38afSmrg ;; 222e4da38afSmrg esac 223e4da38afSmrg $_G_path_prog_found && break 3 224e4da38afSmrg done 225e4da38afSmrg done 226e4da38afSmrg done 227e4da38afSmrg IFS=$_G_save_IFS 228e4da38afSmrg test -z "$func_path_progs_result" && { 229e4da38afSmrg echo "no acceptable sed could be found in \$PATH" >&2 230e4da38afSmrg exit 1 231e4da38afSmrg } 232e4da38afSmrg} 233e4da38afSmrg 234e4da38afSmrg 235e4da38afSmrg# We want to be able to use the functions in this file before configure 236e4da38afSmrg# has figured out where the best binaries are kept, which means we have 237e4da38afSmrg# to search for them ourselves - except when the results are already set 238e4da38afSmrg# where we skip the searches. 239e4da38afSmrg 240e4da38afSmrg# Unless the user overrides by setting SED, search the path for either GNU 241e4da38afSmrg# sed, or the sed that truncates its output the least. 242e4da38afSmrgtest -z "$SED" && { 243e4da38afSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 244e4da38afSmrg for _G_i in 1 2 3 4 5 6 7; do 245e4da38afSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 246e4da38afSmrg done 247e4da38afSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 248e4da38afSmrg _G_sed_script= 249e4da38afSmrg 250e4da38afSmrg func_check_prog_sed () 251e4da38afSmrg { 252e4da38afSmrg _G_path_prog=$1 253e4da38afSmrg 254e4da38afSmrg _G_count=0 255e4da38afSmrg printf 0123456789 >conftest.in 256e4da38afSmrg while : 257e4da38afSmrg do 258e4da38afSmrg cat conftest.in conftest.in >conftest.tmp 259e4da38afSmrg mv conftest.tmp conftest.in 260e4da38afSmrg cp conftest.in conftest.nl 261e4da38afSmrg echo '' >> conftest.nl 262e4da38afSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 263e4da38afSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 264e4da38afSmrg _G_count=`expr $_G_count + 1` 265e4da38afSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 266e4da38afSmrg # Best one so far, save it but keep looking for a better one 267e4da38afSmrg func_check_prog_result=$_G_path_prog 268e4da38afSmrg _G_path_prog_max=$_G_count 269e4da38afSmrg fi 270e4da38afSmrg # 10*(2^10) chars as input seems more than enough 271e4da38afSmrg test 10 -lt "$_G_count" && break 272e4da38afSmrg done 273e4da38afSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 274e4da38afSmrg } 275e4da38afSmrg 276370b807fSmrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 277e4da38afSmrg rm -f conftest.sed 278e4da38afSmrg SED=$func_path_progs_result 279e4da38afSmrg} 280e4da38afSmrg 281e4da38afSmrg 282e4da38afSmrg# Unless the user overrides by setting GREP, search the path for either GNU 283e4da38afSmrg# grep, or the grep that truncates its output the least. 284e4da38afSmrgtest -z "$GREP" && { 285e4da38afSmrg func_check_prog_grep () 286e4da38afSmrg { 287e4da38afSmrg _G_path_prog=$1 288e4da38afSmrg 289e4da38afSmrg _G_count=0 290e4da38afSmrg _G_path_prog_max=0 291e4da38afSmrg printf 0123456789 >conftest.in 292e4da38afSmrg while : 293e4da38afSmrg do 294e4da38afSmrg cat conftest.in conftest.in >conftest.tmp 295e4da38afSmrg mv conftest.tmp conftest.in 296e4da38afSmrg cp conftest.in conftest.nl 297e4da38afSmrg echo 'GREP' >> conftest.nl 298e4da38afSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 299e4da38afSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 300e4da38afSmrg _G_count=`expr $_G_count + 1` 301e4da38afSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 302e4da38afSmrg # Best one so far, save it but keep looking for a better one 303e4da38afSmrg func_check_prog_result=$_G_path_prog 304e4da38afSmrg _G_path_prog_max=$_G_count 305e4da38afSmrg fi 306e4da38afSmrg # 10*(2^10) chars as input seems more than enough 307e4da38afSmrg test 10 -lt "$_G_count" && break 308e4da38afSmrg done 309e4da38afSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 310e4da38afSmrg } 311e4da38afSmrg 312370b807fSmrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 313e4da38afSmrg GREP=$func_path_progs_result 314e4da38afSmrg} 315e4da38afSmrg 316e4da38afSmrg 317e4da38afSmrg## ------------------------------- ## 318e4da38afSmrg## User overridable command paths. ## 319e4da38afSmrg## ------------------------------- ## 320e4da38afSmrg 321e4da38afSmrg# All uppercase variable names are used for environment variables. These 322e4da38afSmrg# variables can be overridden by the user before calling a script that 323e4da38afSmrg# uses them if a suitable command of that name is not already available 324e4da38afSmrg# in the command search PATH. 325fc27e79cSmrg 326fc27e79cSmrg: ${CP="cp -f"} 327e4da38afSmrg: ${ECHO="printf %s\n"} 328e4da38afSmrg: ${EGREP="$GREP -E"} 329e4da38afSmrg: ${FGREP="$GREP -F"} 330e4da38afSmrg: ${LN_S="ln -s"} 331fc27e79cSmrg: ${MAKE="make"} 332fc27e79cSmrg: ${MKDIR="mkdir"} 333fc27e79cSmrg: ${MV="mv -f"} 334fc27e79cSmrg: ${RM="rm -f"} 335fc27e79cSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 336fc27e79cSmrg 337fc27e79cSmrg 338e4da38afSmrg## -------------------- ## 339e4da38afSmrg## Useful sed snippets. ## 340e4da38afSmrg## -------------------- ## 341bd3a1963Smrg 342e4da38afSmrgsed_dirname='s|/[^/]*$||' 343e4da38afSmrgsed_basename='s|^.*/||' 344bd3a1963Smrg 345e4da38afSmrg# Sed substitution that helps us do robust quoting. It backslashifies 346e4da38afSmrg# metacharacters that are still active within double-quoted strings. 347e4da38afSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 348bd3a1963Smrg 349e4da38afSmrg# Same as above, but do not quote variable references. 350e4da38afSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 351bd3a1963Smrg 352e4da38afSmrg# Sed substitution that turns a string into a regex matching for the 353e4da38afSmrg# string literally. 354e4da38afSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 355bd3a1963Smrg 356e4da38afSmrg# Sed substitution that converts a w32 file name or path 357e4da38afSmrg# that contains forward slashes, into one that contains 358e4da38afSmrg# (escaped) backslashes. A very naive implementation. 359e4da38afSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 360e4da38afSmrg 361e4da38afSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 362e4da38afSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 363e4da38afSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 364e4da38afSmrg# expansion. Since each input '\' is now two '\'s, look for any number 365e4da38afSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 366e4da38afSmrg_G_bs='\\' 367e4da38afSmrg_G_bs2='\\\\' 368e4da38afSmrg_G_bs4='\\\\\\\\' 369e4da38afSmrg_G_dollar='\$' 370e4da38afSmrgsed_double_backslash="\ 371e4da38afSmrg s/$_G_bs4/&\\ 372e4da38afSmrg/g 373e4da38afSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 374e4da38afSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 375e4da38afSmrg s/\n//g" 376bd3a1963Smrg 377370b807fSmrg# require_check_ifs_backslash 378370b807fSmrg# --------------------------- 379370b807fSmrg# Check if we can use backslash as IFS='\' separator, and set 380370b807fSmrg# $check_ifs_backshlash_broken to ':' or 'false'. 381370b807fSmrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 382370b807fSmrgfunc_require_check_ifs_backslash () 383370b807fSmrg{ 384370b807fSmrg _G_save_IFS=$IFS 385370b807fSmrg IFS='\' 386370b807fSmrg _G_check_ifs_backshlash='a\\b' 387370b807fSmrg for _G_i in $_G_check_ifs_backshlash 388370b807fSmrg do 389370b807fSmrg case $_G_i in 390370b807fSmrg a) 391370b807fSmrg check_ifs_backshlash_broken=false 392370b807fSmrg ;; 393370b807fSmrg '') 394370b807fSmrg break 395370b807fSmrg ;; 396370b807fSmrg *) 397370b807fSmrg check_ifs_backshlash_broken=: 398370b807fSmrg break 399370b807fSmrg ;; 400370b807fSmrg esac 401370b807fSmrg done 402370b807fSmrg IFS=$_G_save_IFS 403370b807fSmrg require_check_ifs_backslash=: 404370b807fSmrg} 405370b807fSmrg 406bd3a1963Smrg 407e4da38afSmrg## ----------------- ## 408e4da38afSmrg## Global variables. ## 409e4da38afSmrg## ----------------- ## 410bd3a1963Smrg 411e4da38afSmrg# Except for the global variables explicitly listed below, the following 412e4da38afSmrg# functions in the '^func_' namespace, and the '^require_' namespace 413e4da38afSmrg# variables initialised in the 'Resource management' section, sourcing 414e4da38afSmrg# this file will not pollute your global namespace with anything 415e4da38afSmrg# else. There's no portable way to scope variables in Bourne shell 416e4da38afSmrg# though, so actually running these functions will sometimes place 417e4da38afSmrg# results into a variable named after the function, and often use 418e4da38afSmrg# temporary variables in the '^_G_' namespace. If you are careful to 419e4da38afSmrg# avoid using those namespaces casually in your sourcing script, things 420e4da38afSmrg# should continue to work as you expect. And, of course, you can freely 421e4da38afSmrg# overwrite any of the functions or variables defined here before 422e4da38afSmrg# calling anything to customize them. 423bd3a1963Smrg 424e4da38afSmrgEXIT_SUCCESS=0 425e4da38afSmrgEXIT_FAILURE=1 426e4da38afSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 427e4da38afSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 428fc27e79cSmrg 429e4da38afSmrg# Allow overriding, eg assuming that you follow the convention of 430e4da38afSmrg# putting '$debug_cmd' at the start of all your functions, you can get 431e4da38afSmrg# bash to show function call trace with: 432e4da38afSmrg# 433e4da38afSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 434e4da38afSmrgdebug_cmd=${debug_cmd-":"} 435e4da38afSmrgexit_cmd=: 436659607e0Smrg 437e4da38afSmrg# By convention, finish your script with: 438e4da38afSmrg# 439e4da38afSmrg# exit $exit_status 440e4da38afSmrg# 441e4da38afSmrg# so that you can set exit_status to non-zero if you want to indicate 442e4da38afSmrg# something went wrong during execution without actually bailing out at 443e4da38afSmrg# the point of failure. 444e4da38afSmrgexit_status=$EXIT_SUCCESS 445bd3a1963Smrg 446e4da38afSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 447e4da38afSmrg# is ksh but when the shell is invoked as "sh" and the current value of 448e4da38afSmrg# the _XPG environment variable is not equal to 1 (one), the special 449e4da38afSmrg# positional parameter $0, within a function call, is the name of the 450e4da38afSmrg# function. 451e4da38afSmrgprogpath=$0 452659607e0Smrg 453e4da38afSmrg# The name of this program. 454e4da38afSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 455659607e0Smrg 456e4da38afSmrg# Make sure we have an absolute progpath for reexecution: 457fc27e79cSmrgcase $progpath in 458fc27e79cSmrg [\\/]*|[A-Za-z]:\\*) ;; 459fc27e79cSmrg *[\\/]*) 460e4da38afSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 461fc27e79cSmrg progdir=`cd "$progdir" && pwd` 462e4da38afSmrg progpath=$progdir/$progname 463fc27e79cSmrg ;; 464fc27e79cSmrg *) 465e4da38afSmrg _G_IFS=$IFS 466a73597f9Smrg IFS=${PATH_SEPARATOR-:} 467fc27e79cSmrg for progdir in $PATH; do 468e4da38afSmrg IFS=$_G_IFS 469fc27e79cSmrg test -x "$progdir/$progname" && break 470fc27e79cSmrg done 471e4da38afSmrg IFS=$_G_IFS 472fc27e79cSmrg test -n "$progdir" || progdir=`pwd` 473e4da38afSmrg progpath=$progdir/$progname 474fc27e79cSmrg ;; 475fc27e79cSmrgesac 476659607e0Smrg 477fc27e79cSmrg 478e4da38afSmrg## ----------------- ## 479e4da38afSmrg## Standard options. ## 480e4da38afSmrg## ----------------- ## 481bd3a1963Smrg 482e4da38afSmrg# The following options affect the operation of the functions defined 483e4da38afSmrg# below, and should be set appropriately depending on run-time para- 484e4da38afSmrg# meters passed on the command line. 485fc27e79cSmrg 486fc27e79cSmrgopt_dry_run=false 487fc27e79cSmrgopt_quiet=false 488fc27e79cSmrgopt_verbose=false 489fc27e79cSmrg 490e4da38afSmrg# Categories 'all' and 'none' are always available. Append any others 491e4da38afSmrg# you will pass as the first argument to func_warning from your own 492e4da38afSmrg# code. 493e4da38afSmrgwarning_categories= 4946aab59a7Smrg 495e4da38afSmrg# By default, display warnings according to 'opt_warning_types'. Set 496e4da38afSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 497e4da38afSmrg# treat the next displayed warning as a fatal error. 498e4da38afSmrgwarning_func=func_warn_and_continue 499659607e0Smrg 500e4da38afSmrg# Set to 'all' to display all warnings, 'none' to suppress all 501e4da38afSmrg# warnings, or a space delimited list of some subset of 502e4da38afSmrg# 'warning_categories' to display only the listed warnings. 503e4da38afSmrgopt_warning_types=all 504659607e0Smrg 505bd3a1963Smrg 506e4da38afSmrg## -------------------- ## 507e4da38afSmrg## Resource management. ## 508e4da38afSmrg## -------------------- ## 509659607e0Smrg 510e4da38afSmrg# This section contains definitions for functions that each ensure a 511e4da38afSmrg# particular resource (a file, or a non-empty configuration variable for 512e4da38afSmrg# example) is available, and if appropriate to extract default values 513e4da38afSmrg# from pertinent package files. Call them using their associated 514e4da38afSmrg# 'require_*' variable to ensure that they are executed, at most, once. 515e4da38afSmrg# 516e4da38afSmrg# It's entirely deliberate that calling these functions can set 517e4da38afSmrg# variables that don't obey the namespace limitations obeyed by the rest 518e4da38afSmrg# of this file, in order that that they be as useful as possible to 519e4da38afSmrg# callers. 520659607e0Smrg 521659607e0Smrg 522e4da38afSmrg# require_term_colors 523e4da38afSmrg# ------------------- 524e4da38afSmrg# Allow display of bold text on terminals that support it. 525e4da38afSmrgrequire_term_colors=func_require_term_colors 526e4da38afSmrgfunc_require_term_colors () 527fc27e79cSmrg{ 528e4da38afSmrg $debug_cmd 529e4da38afSmrg 530e4da38afSmrg test -t 1 && { 531e4da38afSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 532e4da38afSmrg # precedence, because most terminfo databases neglect to describe 533e4da38afSmrg # whether color sequences are supported. 534e4da38afSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 535e4da38afSmrg 536e4da38afSmrg if test 1 = "$USE_ANSI_COLORS"; then 537e4da38afSmrg # Standard ANSI escape sequences 538e4da38afSmrg tc_reset='[0m' 539e4da38afSmrg tc_bold='[1m'; tc_standout='[7m' 540e4da38afSmrg tc_red='[31m'; tc_green='[32m' 541e4da38afSmrg tc_blue='[34m'; tc_cyan='[36m' 542e4da38afSmrg else 543e4da38afSmrg # Otherwise trust the terminfo database after all. 544e4da38afSmrg test -n "`tput sgr0 2>/dev/null`" && { 545e4da38afSmrg tc_reset=`tput sgr0` 546e4da38afSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 547e4da38afSmrg tc_standout=$tc_bold 548e4da38afSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 549e4da38afSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 550e4da38afSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 551e4da38afSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 552e4da38afSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 553e4da38afSmrg } 554e4da38afSmrg fi 555e4da38afSmrg } 556659607e0Smrg 557e4da38afSmrg require_term_colors=: 558fc27e79cSmrg} 559659607e0Smrg 560659607e0Smrg 561e4da38afSmrg## ----------------- ## 562e4da38afSmrg## Function library. ## 563e4da38afSmrg## ----------------- ## 564e4da38afSmrg 565e4da38afSmrg# This section contains a variety of useful functions to call in your 566e4da38afSmrg# scripts. Take note of the portable wrappers for features provided by 567e4da38afSmrg# some modern shells, which will fall back to slower equivalents on 568e4da38afSmrg# less featureful shells. 569e4da38afSmrg 570e4da38afSmrg 571e4da38afSmrg# func_append VAR VALUE 572e4da38afSmrg# --------------------- 573e4da38afSmrg# Append VALUE onto the existing contents of VAR. 574e4da38afSmrg 575e4da38afSmrg # We should try to minimise forks, especially on Windows where they are 576e4da38afSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 577e4da38afSmrg # being used: 578e4da38afSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 579e4da38afSmrg : ${_G_HAVE_ARITH_OP="yes"} 580e4da38afSmrg : ${_G_HAVE_XSI_OPS="yes"} 581e4da38afSmrg # The += operator was introduced in bash 3.1 582e4da38afSmrg case $BASH_VERSION in 583e4da38afSmrg [12].* | 3.0 | 3.0*) ;; 584e4da38afSmrg *) 585e4da38afSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 586e4da38afSmrg ;; 587e4da38afSmrg esac 588e4da38afSmrg fi 589e4da38afSmrg 590e4da38afSmrg # _G_HAVE_PLUSEQ_OP 591e4da38afSmrg # Can be empty, in which case the shell is probed, "yes" if += is 592e4da38afSmrg # useable or anything else if it does not work. 593e4da38afSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 594e4da38afSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 595e4da38afSmrg && _G_HAVE_PLUSEQ_OP=yes 596e4da38afSmrg 597e4da38afSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 598e4da38afSmrgthen 599e4da38afSmrg # This is an XSI compatible shell, allowing a faster implementation... 600e4da38afSmrg eval 'func_append () 601e4da38afSmrg { 602e4da38afSmrg $debug_cmd 603e4da38afSmrg 604e4da38afSmrg eval "$1+=\$2" 605e4da38afSmrg }' 606e4da38afSmrgelse 607e4da38afSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 608e4da38afSmrg func_append () 609e4da38afSmrg { 610e4da38afSmrg $debug_cmd 611e4da38afSmrg 612e4da38afSmrg eval "$1=\$$1\$2" 613e4da38afSmrg } 614e4da38afSmrgfi 615e4da38afSmrg 616e4da38afSmrg 617e4da38afSmrg# func_append_quoted VAR VALUE 618e4da38afSmrg# ---------------------------- 619e4da38afSmrg# Quote VALUE and append to the end of shell variable VAR, separated 620e4da38afSmrg# by a space. 621e4da38afSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 622e4da38afSmrg eval 'func_append_quoted () 623e4da38afSmrg { 624e4da38afSmrg $debug_cmd 625e4da38afSmrg 626370b807fSmrg func_quote_arg pretty "$2" 627370b807fSmrg eval "$1+=\\ \$func_quote_arg_result" 628e4da38afSmrg }' 629e4da38afSmrgelse 630e4da38afSmrg func_append_quoted () 631e4da38afSmrg { 632e4da38afSmrg $debug_cmd 633e4da38afSmrg 634370b807fSmrg func_quote_arg pretty "$2" 635370b807fSmrg eval "$1=\$$1\\ \$func_quote_arg_result" 636e4da38afSmrg } 637e4da38afSmrgfi 638e4da38afSmrg 639e4da38afSmrg 640e4da38afSmrg# func_append_uniq VAR VALUE 641e4da38afSmrg# -------------------------- 642e4da38afSmrg# Append unique VALUE onto the existing contents of VAR, assuming 643e4da38afSmrg# entries are delimited by the first character of VALUE. For example: 644e4da38afSmrg# 645e4da38afSmrg# func_append_uniq options " --another-option option-argument" 646e4da38afSmrg# 647e4da38afSmrg# will only append to $options if " --another-option option-argument " 648e4da38afSmrg# is not already present somewhere in $options already (note spaces at 649e4da38afSmrg# each end implied by leading space in second argument). 650e4da38afSmrgfunc_append_uniq () 651e4da38afSmrg{ 652e4da38afSmrg $debug_cmd 653e4da38afSmrg 654e4da38afSmrg eval _G_current_value='`$ECHO $'$1'`' 655e4da38afSmrg _G_delim=`expr "$2" : '\(.\)'` 656e4da38afSmrg 657e4da38afSmrg case $_G_delim$_G_current_value$_G_delim in 658e4da38afSmrg *"$2$_G_delim"*) ;; 659e4da38afSmrg *) func_append "$@" ;; 660e4da38afSmrg esac 661e4da38afSmrg} 662e4da38afSmrg 663e4da38afSmrg 664e4da38afSmrg# func_arith TERM... 665e4da38afSmrg# ------------------ 666e4da38afSmrg# Set func_arith_result to the result of evaluating TERMs. 667e4da38afSmrg test -z "$_G_HAVE_ARITH_OP" \ 668e4da38afSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 669e4da38afSmrg && _G_HAVE_ARITH_OP=yes 670e4da38afSmrg 671e4da38afSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 672e4da38afSmrg eval 'func_arith () 673e4da38afSmrg { 674e4da38afSmrg $debug_cmd 675e4da38afSmrg 676e4da38afSmrg func_arith_result=$(( $* )) 677e4da38afSmrg }' 678e4da38afSmrgelse 679e4da38afSmrg func_arith () 680e4da38afSmrg { 681e4da38afSmrg $debug_cmd 682e4da38afSmrg 683e4da38afSmrg func_arith_result=`expr "$@"` 684e4da38afSmrg } 685e4da38afSmrgfi 686e4da38afSmrg 687e4da38afSmrg 688e4da38afSmrg# func_basename FILE 689e4da38afSmrg# ------------------ 690e4da38afSmrg# Set func_basename_result to FILE with everything up to and including 691e4da38afSmrg# the last / stripped. 692e4da38afSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 693e4da38afSmrg # If this shell supports suffix pattern removal, then use it to avoid 694e4da38afSmrg # forking. Hide the definitions single quotes in case the shell chokes 695e4da38afSmrg # on unsupported syntax... 696e4da38afSmrg _b='func_basename_result=${1##*/}' 697e4da38afSmrg _d='case $1 in 698e4da38afSmrg */*) func_dirname_result=${1%/*}$2 ;; 699e4da38afSmrg * ) func_dirname_result=$3 ;; 700e4da38afSmrg esac' 701e4da38afSmrg 702e4da38afSmrgelse 703e4da38afSmrg # ...otherwise fall back to using sed. 704e4da38afSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 705e4da38afSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 706e4da38afSmrg if test "X$func_dirname_result" = "X$1"; then 707e4da38afSmrg func_dirname_result=$3 708e4da38afSmrg else 709e4da38afSmrg func_append func_dirname_result "$2" 710e4da38afSmrg fi' 711e4da38afSmrgfi 712e4da38afSmrg 713e4da38afSmrgeval 'func_basename () 714e4da38afSmrg{ 715e4da38afSmrg $debug_cmd 716e4da38afSmrg 717e4da38afSmrg '"$_b"' 718e4da38afSmrg}' 719e4da38afSmrg 720e4da38afSmrg 721e4da38afSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 722e4da38afSmrg# ------------------------------------------- 723e4da38afSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 724e4da38afSmrg# otherwise set result to NONDIR_REPLACEMENT. 725e4da38afSmrgeval 'func_dirname () 726e4da38afSmrg{ 727e4da38afSmrg $debug_cmd 728e4da38afSmrg 729e4da38afSmrg '"$_d"' 730e4da38afSmrg}' 731e4da38afSmrg 732e4da38afSmrg 733e4da38afSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 734e4da38afSmrg# -------------------------------------------------------- 735e4da38afSmrg# Perform func_basename and func_dirname in a single function 736e4da38afSmrg# call: 737e4da38afSmrg# dirname: Compute the dirname of FILE. If nonempty, 738e4da38afSmrg# add APPEND to the result, otherwise set result 739e4da38afSmrg# to NONDIR_REPLACEMENT. 740e4da38afSmrg# value returned in "$func_dirname_result" 741e4da38afSmrg# basename: Compute filename of FILE. 742e4da38afSmrg# value retuned in "$func_basename_result" 743e4da38afSmrg# For efficiency, we do not delegate to the functions above but instead 744e4da38afSmrg# duplicate the functionality here. 745e4da38afSmrgeval 'func_dirname_and_basename () 746e4da38afSmrg{ 747e4da38afSmrg $debug_cmd 748e4da38afSmrg 749e4da38afSmrg '"$_b"' 750e4da38afSmrg '"$_d"' 751e4da38afSmrg}' 752e4da38afSmrg 753e4da38afSmrg 754e4da38afSmrg# func_echo ARG... 755e4da38afSmrg# ---------------- 756e4da38afSmrg# Echo program name prefixed message. 757e4da38afSmrgfunc_echo () 758e4da38afSmrg{ 759e4da38afSmrg $debug_cmd 760e4da38afSmrg 761e4da38afSmrg _G_message=$* 762e4da38afSmrg 763e4da38afSmrg func_echo_IFS=$IFS 764e4da38afSmrg IFS=$nl 765e4da38afSmrg for _G_line in $_G_message; do 766e4da38afSmrg IFS=$func_echo_IFS 767e4da38afSmrg $ECHO "$progname: $_G_line" 768e4da38afSmrg done 769e4da38afSmrg IFS=$func_echo_IFS 770e4da38afSmrg} 771e4da38afSmrg 772e4da38afSmrg 773e4da38afSmrg# func_echo_all ARG... 774e4da38afSmrg# -------------------- 775e4da38afSmrg# Invoke $ECHO with all args, space-separated. 776e4da38afSmrgfunc_echo_all () 777e4da38afSmrg{ 778e4da38afSmrg $ECHO "$*" 779e4da38afSmrg} 780e4da38afSmrg 781e4da38afSmrg 782e4da38afSmrg# func_echo_infix_1 INFIX ARG... 783e4da38afSmrg# ------------------------------ 784e4da38afSmrg# Echo program name, followed by INFIX on the first line, with any 785e4da38afSmrg# additional lines not showing INFIX. 786e4da38afSmrgfunc_echo_infix_1 () 787e4da38afSmrg{ 788e4da38afSmrg $debug_cmd 789e4da38afSmrg 790e4da38afSmrg $require_term_colors 791e4da38afSmrg 792e4da38afSmrg _G_infix=$1; shift 793e4da38afSmrg _G_indent=$_G_infix 794e4da38afSmrg _G_prefix="$progname: $_G_infix: " 795e4da38afSmrg _G_message=$* 796e4da38afSmrg 797e4da38afSmrg # Strip color escape sequences before counting printable length 798e4da38afSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 799e4da38afSmrg do 800e4da38afSmrg test -n "$_G_tc" && { 801e4da38afSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 802e4da38afSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 803e4da38afSmrg } 804e4da38afSmrg done 805e4da38afSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 806e4da38afSmrg 807e4da38afSmrg func_echo_infix_1_IFS=$IFS 808e4da38afSmrg IFS=$nl 809e4da38afSmrg for _G_line in $_G_message; do 810e4da38afSmrg IFS=$func_echo_infix_1_IFS 811e4da38afSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 812e4da38afSmrg _G_prefix=$_G_indent 813e4da38afSmrg done 814e4da38afSmrg IFS=$func_echo_infix_1_IFS 815e4da38afSmrg} 816e4da38afSmrg 817e4da38afSmrg 818e4da38afSmrg# func_error ARG... 819e4da38afSmrg# ----------------- 820e4da38afSmrg# Echo program name prefixed message to standard error. 821e4da38afSmrgfunc_error () 822e4da38afSmrg{ 823e4da38afSmrg $debug_cmd 824e4da38afSmrg 825e4da38afSmrg $require_term_colors 826e4da38afSmrg 827e4da38afSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 828e4da38afSmrg} 829e4da38afSmrg 830e4da38afSmrg 831e4da38afSmrg# func_fatal_error ARG... 832e4da38afSmrg# ----------------------- 833e4da38afSmrg# Echo program name prefixed message to standard error, and exit. 834e4da38afSmrgfunc_fatal_error () 835e4da38afSmrg{ 836e4da38afSmrg $debug_cmd 837e4da38afSmrg 838e4da38afSmrg func_error "$*" 839e4da38afSmrg exit $EXIT_FAILURE 840e4da38afSmrg} 841e4da38afSmrg 842e4da38afSmrg 843e4da38afSmrg# func_grep EXPRESSION FILENAME 844e4da38afSmrg# ----------------------------- 845fc27e79cSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 846fc27e79cSmrgfunc_grep () 847fc27e79cSmrg{ 848e4da38afSmrg $debug_cmd 849e4da38afSmrg 850fc27e79cSmrg $GREP "$1" "$2" >/dev/null 2>&1 851fc27e79cSmrg} 852fc27e79cSmrg 853fc27e79cSmrg 854e4da38afSmrg# func_len STRING 855e4da38afSmrg# --------------- 856e4da38afSmrg# Set func_len_result to the length of STRING. STRING may not 857e4da38afSmrg# start with a hyphen. 858e4da38afSmrg test -z "$_G_HAVE_XSI_OPS" \ 859e4da38afSmrg && (eval 'x=a/b/c; 860e4da38afSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 861e4da38afSmrg && _G_HAVE_XSI_OPS=yes 862e4da38afSmrg 863e4da38afSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 864e4da38afSmrg eval 'func_len () 865e4da38afSmrg { 866e4da38afSmrg $debug_cmd 867e4da38afSmrg 868e4da38afSmrg func_len_result=${#1} 869e4da38afSmrg }' 870e4da38afSmrgelse 871e4da38afSmrg func_len () 872e4da38afSmrg { 873e4da38afSmrg $debug_cmd 874e4da38afSmrg 875e4da38afSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 876e4da38afSmrg } 877e4da38afSmrgfi 878e4da38afSmrg 879e4da38afSmrg 880e4da38afSmrg# func_mkdir_p DIRECTORY-PATH 881e4da38afSmrg# --------------------------- 882fc27e79cSmrg# Make sure the entire path to DIRECTORY-PATH is available. 883fc27e79cSmrgfunc_mkdir_p () 884fc27e79cSmrg{ 885e4da38afSmrg $debug_cmd 886fc27e79cSmrg 887e4da38afSmrg _G_directory_path=$1 888e4da38afSmrg _G_dir_list= 889fc27e79cSmrg 890e4da38afSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 891e4da38afSmrg 892e4da38afSmrg # Protect directory names starting with '-' 893e4da38afSmrg case $_G_directory_path in 894e4da38afSmrg -*) _G_directory_path=./$_G_directory_path ;; 895fc27e79cSmrg esac 896fc27e79cSmrg 897fc27e79cSmrg # While some portion of DIR does not yet exist... 898e4da38afSmrg while test ! -d "$_G_directory_path"; do 899fc27e79cSmrg # ...make a list in topmost first order. Use a colon delimited 900fc27e79cSmrg # list incase some portion of path contains whitespace. 901e4da38afSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 902fc27e79cSmrg 903fc27e79cSmrg # If the last portion added has no slash in it, the list is done 904e4da38afSmrg case $_G_directory_path in */*) ;; *) break ;; esac 905fc27e79cSmrg 906fc27e79cSmrg # ...otherwise throw away the child directory and loop 907e4da38afSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 908fc27e79cSmrg done 909e4da38afSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 910fc27e79cSmrg 911e4da38afSmrg func_mkdir_p_IFS=$IFS; IFS=: 912e4da38afSmrg for _G_dir in $_G_dir_list; do 913e4da38afSmrg IFS=$func_mkdir_p_IFS 914e4da38afSmrg # mkdir can fail with a 'File exist' error if two processes 915fc27e79cSmrg # try to create one of the directories concurrently. Don't 916fc27e79cSmrg # stop in that case! 917e4da38afSmrg $MKDIR "$_G_dir" 2>/dev/null || : 918fc27e79cSmrg done 919e4da38afSmrg IFS=$func_mkdir_p_IFS 920fc27e79cSmrg 921fc27e79cSmrg # Bail out if we (or some other process) failed to create a directory. 922e4da38afSmrg test -d "$_G_directory_path" || \ 923e4da38afSmrg func_fatal_error "Failed to create '$1'" 924fc27e79cSmrg fi 925fc27e79cSmrg} 926659607e0Smrg 927659607e0Smrg 928e4da38afSmrg# func_mktempdir [BASENAME] 929e4da38afSmrg# ------------------------- 930659607e0Smrg# Make a temporary directory that won't clash with other running 931659607e0Smrg# libtool processes, and avoids race conditions if possible. If 932e4da38afSmrg# given, BASENAME is the basename for that directory. 933659607e0Smrgfunc_mktempdir () 934659607e0Smrg{ 935e4da38afSmrg $debug_cmd 936e4da38afSmrg 937e4da38afSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 938659607e0Smrg 939e4da38afSmrg if test : = "$opt_dry_run"; then 940659607e0Smrg # Return a directory name, but don't create it in dry-run mode 941e4da38afSmrg _G_tmpdir=$_G_template-$$ 942659607e0Smrg else 943659607e0Smrg 944659607e0Smrg # If mktemp works, use that first and foremost 945e4da38afSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 946659607e0Smrg 947e4da38afSmrg if test ! -d "$_G_tmpdir"; then 948fc27e79cSmrg # Failing that, at least try and use $RANDOM to avoid a race 949e4da38afSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 950659607e0Smrg 951e4da38afSmrg func_mktempdir_umask=`umask` 952fc27e79cSmrg umask 0077 953e4da38afSmrg $MKDIR "$_G_tmpdir" 954e4da38afSmrg umask $func_mktempdir_umask 955659607e0Smrg fi 956659607e0Smrg 957659607e0Smrg # If we're not in dry-run mode, bomb out on failure 958e4da38afSmrg test -d "$_G_tmpdir" || \ 959e4da38afSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 960e4da38afSmrg fi 961e4da38afSmrg 962e4da38afSmrg $ECHO "$_G_tmpdir" 963e4da38afSmrg} 964e4da38afSmrg 965e4da38afSmrg 966e4da38afSmrg# func_normal_abspath PATH 967e4da38afSmrg# ------------------------ 968e4da38afSmrg# Remove doubled-up and trailing slashes, "." path components, 969e4da38afSmrg# and cancel out any ".." path components in PATH after making 970e4da38afSmrg# it an absolute path. 971e4da38afSmrgfunc_normal_abspath () 972e4da38afSmrg{ 973e4da38afSmrg $debug_cmd 974e4da38afSmrg 975e4da38afSmrg # These SED scripts presuppose an absolute path with a trailing slash. 976e4da38afSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 977e4da38afSmrg _G_pathcdr='s|^/[^/]*||' 978e4da38afSmrg _G_removedotparts=':dotsl 979e4da38afSmrg s|/\./|/|g 980e4da38afSmrg t dotsl 981e4da38afSmrg s|/\.$|/|' 982e4da38afSmrg _G_collapseslashes='s|/\{1,\}|/|g' 983e4da38afSmrg _G_finalslash='s|/*$|/|' 984e4da38afSmrg 985e4da38afSmrg # Start from root dir and reassemble the path. 986e4da38afSmrg func_normal_abspath_result= 987e4da38afSmrg func_normal_abspath_tpath=$1 988e4da38afSmrg func_normal_abspath_altnamespace= 989e4da38afSmrg case $func_normal_abspath_tpath in 990e4da38afSmrg "") 991e4da38afSmrg # Empty path, that just means $cwd. 992e4da38afSmrg func_stripname '' '/' "`pwd`" 993e4da38afSmrg func_normal_abspath_result=$func_stripname_result 994e4da38afSmrg return 995e4da38afSmrg ;; 996e4da38afSmrg # The next three entries are used to spot a run of precisely 997e4da38afSmrg # two leading slashes without using negated character classes; 998e4da38afSmrg # we take advantage of case's first-match behaviour. 999e4da38afSmrg ///*) 1000e4da38afSmrg # Unusual form of absolute path, do nothing. 1001e4da38afSmrg ;; 1002e4da38afSmrg //*) 1003e4da38afSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 1004e4da38afSmrg # and for example Cygwin uses it to access remote file shares 1005e4da38afSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 1006e4da38afSmrg func_normal_abspath_altnamespace=/ 1007e4da38afSmrg ;; 1008e4da38afSmrg /*) 1009e4da38afSmrg # Absolute path, do nothing. 1010e4da38afSmrg ;; 1011e4da38afSmrg *) 1012e4da38afSmrg # Relative path, prepend $cwd. 1013e4da38afSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 1014e4da38afSmrg ;; 1015e4da38afSmrg esac 1016e4da38afSmrg 1017e4da38afSmrg # Cancel out all the simple stuff to save iterations. We also want 1018e4da38afSmrg # the path to end with a slash for ease of parsing, so make sure 1019e4da38afSmrg # there is one (and only one) here. 1020e4da38afSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1021e4da38afSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 1022e4da38afSmrg while :; do 1023e4da38afSmrg # Processed it all yet? 1024e4da38afSmrg if test / = "$func_normal_abspath_tpath"; then 1025e4da38afSmrg # If we ascended to the root using ".." the result may be empty now. 1026e4da38afSmrg if test -z "$func_normal_abspath_result"; then 1027e4da38afSmrg func_normal_abspath_result=/ 1028e4da38afSmrg fi 1029e4da38afSmrg break 1030e4da38afSmrg fi 1031e4da38afSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1032e4da38afSmrg -e "$_G_pathcar"` 1033e4da38afSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1034e4da38afSmrg -e "$_G_pathcdr"` 1035e4da38afSmrg # Figure out what to do with it 1036e4da38afSmrg case $func_normal_abspath_tcomponent in 1037e4da38afSmrg "") 1038e4da38afSmrg # Trailing empty path component, ignore it. 1039e4da38afSmrg ;; 1040e4da38afSmrg ..) 1041e4da38afSmrg # Parent dir; strip last assembled component from result. 1042e4da38afSmrg func_dirname "$func_normal_abspath_result" 1043e4da38afSmrg func_normal_abspath_result=$func_dirname_result 1044e4da38afSmrg ;; 1045e4da38afSmrg *) 1046e4da38afSmrg # Actual path component, append it. 1047e4da38afSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1048e4da38afSmrg ;; 1049e4da38afSmrg esac 1050e4da38afSmrg done 1051e4da38afSmrg # Restore leading double-slash if one was found on entry. 1052e4da38afSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1053e4da38afSmrg} 1054e4da38afSmrg 1055e4da38afSmrg 1056e4da38afSmrg# func_notquiet ARG... 1057e4da38afSmrg# -------------------- 1058e4da38afSmrg# Echo program name prefixed message only when not in quiet mode. 1059e4da38afSmrgfunc_notquiet () 1060e4da38afSmrg{ 1061e4da38afSmrg $debug_cmd 1062e4da38afSmrg 1063e4da38afSmrg $opt_quiet || func_echo ${1+"$@"} 1064e4da38afSmrg 1065e4da38afSmrg # A bug in bash halts the script if the last line of a function 1066e4da38afSmrg # fails when set -e is in force, so we need another command to 1067e4da38afSmrg # work around that: 1068e4da38afSmrg : 1069e4da38afSmrg} 1070e4da38afSmrg 1071e4da38afSmrg 1072e4da38afSmrg# func_relative_path SRCDIR DSTDIR 1073e4da38afSmrg# -------------------------------- 1074e4da38afSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1075e4da38afSmrgfunc_relative_path () 1076e4da38afSmrg{ 1077e4da38afSmrg $debug_cmd 1078e4da38afSmrg 1079e4da38afSmrg func_relative_path_result= 1080e4da38afSmrg func_normal_abspath "$1" 1081e4da38afSmrg func_relative_path_tlibdir=$func_normal_abspath_result 1082e4da38afSmrg func_normal_abspath "$2" 1083e4da38afSmrg func_relative_path_tbindir=$func_normal_abspath_result 1084e4da38afSmrg 1085e4da38afSmrg # Ascend the tree starting from libdir 1086e4da38afSmrg while :; do 1087e4da38afSmrg # check if we have found a prefix of bindir 1088e4da38afSmrg case $func_relative_path_tbindir in 1089e4da38afSmrg $func_relative_path_tlibdir) 1090e4da38afSmrg # found an exact match 1091e4da38afSmrg func_relative_path_tcancelled= 1092e4da38afSmrg break 1093e4da38afSmrg ;; 1094e4da38afSmrg $func_relative_path_tlibdir*) 1095e4da38afSmrg # found a matching prefix 1096e4da38afSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1097e4da38afSmrg func_relative_path_tcancelled=$func_stripname_result 1098e4da38afSmrg if test -z "$func_relative_path_result"; then 1099e4da38afSmrg func_relative_path_result=. 1100e4da38afSmrg fi 1101e4da38afSmrg break 1102e4da38afSmrg ;; 1103e4da38afSmrg *) 1104e4da38afSmrg func_dirname $func_relative_path_tlibdir 1105e4da38afSmrg func_relative_path_tlibdir=$func_dirname_result 1106e4da38afSmrg if test -z "$func_relative_path_tlibdir"; then 1107e4da38afSmrg # Have to descend all the way to the root! 1108e4da38afSmrg func_relative_path_result=../$func_relative_path_result 1109e4da38afSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 1110e4da38afSmrg break 1111e4da38afSmrg fi 1112e4da38afSmrg func_relative_path_result=../$func_relative_path_result 1113e4da38afSmrg ;; 1114e4da38afSmrg esac 1115e4da38afSmrg done 1116e4da38afSmrg 1117e4da38afSmrg # Now calculate path; take care to avoid doubling-up slashes. 1118e4da38afSmrg func_stripname '' '/' "$func_relative_path_result" 1119e4da38afSmrg func_relative_path_result=$func_stripname_result 1120e4da38afSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 1121e4da38afSmrg if test -n "$func_stripname_result"; then 1122e4da38afSmrg func_append func_relative_path_result "/$func_stripname_result" 1123e4da38afSmrg fi 1124e4da38afSmrg 1125e4da38afSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 1126e4da38afSmrg if test -n "$func_relative_path_result"; then 1127e4da38afSmrg func_stripname './' '' "$func_relative_path_result" 1128e4da38afSmrg func_relative_path_result=$func_stripname_result 1129659607e0Smrg fi 1130659607e0Smrg 1131e4da38afSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 1132e4da38afSmrg 1133e4da38afSmrg : 1134e4da38afSmrg} 1135e4da38afSmrg 1136e4da38afSmrg 1137370b807fSmrg# func_quote_portable EVAL ARG 1138370b807fSmrg# ---------------------------- 1139370b807fSmrg# Internal function to portably implement func_quote_arg. Note that we still 1140370b807fSmrg# keep attention to performance here so we as much as possible try to avoid 1141370b807fSmrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 1142370b807fSmrgfunc_quote_portable () 1143e4da38afSmrg{ 1144e4da38afSmrg $debug_cmd 1145e4da38afSmrg 1146370b807fSmrg $require_check_ifs_backslash 1147370b807fSmrg 1148370b807fSmrg func_quote_portable_result=$2 1149370b807fSmrg 1150370b807fSmrg # one-time-loop (easy break) 1151370b807fSmrg while true 1152370b807fSmrg do 1153370b807fSmrg if $1; then 1154370b807fSmrg func_quote_portable_result=`$ECHO "$2" | $SED \ 1155370b807fSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 1156370b807fSmrg break 1157e4da38afSmrg fi 1158e4da38afSmrg 1159370b807fSmrg # Quote for eval. 1160370b807fSmrg case $func_quote_portable_result in 1161370b807fSmrg *[\\\`\"\$]*) 1162370b807fSmrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 1163370b807fSmrg # contains the shell wildcard characters. 1164370b807fSmrg case $check_ifs_backshlash_broken$func_quote_portable_result in 1165370b807fSmrg :*|*[\[\*\?]*) 1166370b807fSmrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 1167370b807fSmrg | $SED "$sed_quote_subst"` 1168370b807fSmrg break 1169370b807fSmrg ;; 1170370b807fSmrg esac 1171370b807fSmrg 1172370b807fSmrg func_quote_portable_old_IFS=$IFS 1173370b807fSmrg for _G_char in '\' '`' '"' '$' 1174370b807fSmrg do 1175370b807fSmrg # STATE($1) PREV($2) SEPARATOR($3) 1176370b807fSmrg set start "" "" 1177370b807fSmrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 1178370b807fSmrg IFS=$_G_char 1179370b807fSmrg for _G_part in $func_quote_portable_result 1180370b807fSmrg do 1181370b807fSmrg case $1 in 1182370b807fSmrg quote) 1183370b807fSmrg func_append func_quote_portable_result "$3$2" 1184370b807fSmrg set quote "$_G_part" "\\$_G_char" 1185370b807fSmrg ;; 1186370b807fSmrg start) 1187370b807fSmrg set first "" "" 1188370b807fSmrg func_quote_portable_result= 1189370b807fSmrg ;; 1190370b807fSmrg first) 1191370b807fSmrg set quote "$_G_part" "" 1192370b807fSmrg ;; 1193370b807fSmrg esac 1194370b807fSmrg done 1195370b807fSmrg done 1196370b807fSmrg IFS=$func_quote_portable_old_IFS 1197e4da38afSmrg ;; 1198370b807fSmrg *) ;; 1199e4da38afSmrg esac 1200370b807fSmrg break 1201e4da38afSmrg done 1202370b807fSmrg 1203370b807fSmrg func_quote_portable_unquoted_result=$func_quote_portable_result 1204370b807fSmrg case $func_quote_portable_result in 1205370b807fSmrg # double-quote args containing shell metacharacters to delay 1206370b807fSmrg # word splitting, command substitution and variable expansion 1207370b807fSmrg # for a subsequent eval. 1208370b807fSmrg # many bourne shells cannot handle close brackets correctly 1209370b807fSmrg # in scan sets, so we specify it separately. 1210370b807fSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1211370b807fSmrg func_quote_portable_result=\"$func_quote_portable_result\" 1212370b807fSmrg ;; 1213370b807fSmrg esac 1214e4da38afSmrg} 1215e4da38afSmrg 1216e4da38afSmrg 1217370b807fSmrg# func_quotefast_eval ARG 1218370b807fSmrg# ----------------------- 1219370b807fSmrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 1220370b807fSmrg# but optimized for speed. Result is stored in $func_quotefast_eval. 1221370b807fSmrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 1222370b807fSmrg printf -v _GL_test_printf_tilde %q '~' 1223370b807fSmrg if test '\~' = "$_GL_test_printf_tilde"; then 1224370b807fSmrg func_quotefast_eval () 1225370b807fSmrg { 1226370b807fSmrg printf -v func_quotefast_eval_result %q "$1" 1227370b807fSmrg } 1228370b807fSmrg else 1229370b807fSmrg # Broken older Bash implementations. Make those faster too if possible. 1230370b807fSmrg func_quotefast_eval () 1231370b807fSmrg { 1232370b807fSmrg case $1 in 1233370b807fSmrg '~'*) 1234370b807fSmrg func_quote_portable false "$1" 1235370b807fSmrg func_quotefast_eval_result=$func_quote_portable_result 1236370b807fSmrg ;; 1237370b807fSmrg *) 1238370b807fSmrg printf -v func_quotefast_eval_result %q "$1" 1239370b807fSmrg ;; 1240370b807fSmrg esac 1241370b807fSmrg } 1242370b807fSmrg fi 1243370b807fSmrgelse 1244370b807fSmrg func_quotefast_eval () 1245370b807fSmrg { 1246370b807fSmrg func_quote_portable false "$1" 1247370b807fSmrg func_quotefast_eval_result=$func_quote_portable_result 1248370b807fSmrg } 1249370b807fSmrgfi 1250e4da38afSmrg 1251370b807fSmrg 1252370b807fSmrg# func_quote_arg MODEs ARG 1253370b807fSmrg# ------------------------ 1254370b807fSmrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 1255370b807fSmrg# specifiers listed below separated by ',' character. This function returns two 1256370b807fSmrg# values: 1257370b807fSmrg# i) func_quote_arg_result 1258370b807fSmrg# double-quoted (when needed), suitable for a subsequent eval 1259370b807fSmrg# ii) func_quote_arg_unquoted_result 1260370b807fSmrg# has all characters that are still active within double 1261370b807fSmrg# quotes backslashified. Available only if 'unquoted' is specified. 1262370b807fSmrg# 1263370b807fSmrg# Available modes: 1264370b807fSmrg# ---------------- 1265370b807fSmrg# 'eval' (default) 1266370b807fSmrg# - escape shell special characters 1267370b807fSmrg# 'expand' 1268370b807fSmrg# - the same as 'eval'; but do not quote variable references 1269370b807fSmrg# 'pretty' 1270370b807fSmrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 1271370b807fSmrg# be used later in func_quote to get output like: 'echo "a b"' instead 1272370b807fSmrg# of 'echo a\ b'. This is slower than default on some shells. 1273370b807fSmrg# 'unquoted' 1274370b807fSmrg# - produce also $func_quote_arg_unquoted_result which does not contain 1275370b807fSmrg# wrapping double-quotes. 1276370b807fSmrg# 1277370b807fSmrg# Examples for 'func_quote_arg pretty,unquoted string': 1278370b807fSmrg# 1279370b807fSmrg# string | *_result | *_unquoted_result 1280370b807fSmrg# ------------+-----------------------+------------------- 1281370b807fSmrg# " | \" | \" 1282370b807fSmrg# a b | "a b" | a b 1283370b807fSmrg# "a b" | "\"a b\"" | \"a b\" 1284370b807fSmrg# * | "*" | * 1285370b807fSmrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 1286370b807fSmrg# 1287370b807fSmrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 1288370b807fSmrg# 1289370b807fSmrg# string | *_result | *_unquoted_result 1290370b807fSmrg# --------------+---------------------+-------------------- 1291370b807fSmrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 1292370b807fSmrgfunc_quote_arg () 1293370b807fSmrg{ 1294370b807fSmrg _G_quote_expand=false 1295370b807fSmrg case ,$1, in 1296370b807fSmrg *,expand,*) 1297370b807fSmrg _G_quote_expand=: 1298370b807fSmrg ;; 1299e4da38afSmrg esac 1300e4da38afSmrg 1301370b807fSmrg case ,$1, in 1302370b807fSmrg *,pretty,*|*,expand,*|*,unquoted,*) 1303370b807fSmrg func_quote_portable $_G_quote_expand "$2" 1304370b807fSmrg func_quote_arg_result=$func_quote_portable_result 1305370b807fSmrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 1306370b807fSmrg ;; 1307370b807fSmrg *) 1308370b807fSmrg # Faster quote-for-eval for some shells. 1309370b807fSmrg func_quotefast_eval "$2" 1310370b807fSmrg func_quote_arg_result=$func_quotefast_eval_result 1311e4da38afSmrg ;; 1312e4da38afSmrg esac 1313370b807fSmrg} 1314370b807fSmrg 1315e4da38afSmrg 1316370b807fSmrg# func_quote MODEs ARGs... 1317370b807fSmrg# ------------------------ 1318370b807fSmrg# Quote all ARGs to be evaled later and join them into single command. See 1319370b807fSmrg# func_quote_arg's description for more info. 1320370b807fSmrgfunc_quote () 1321370b807fSmrg{ 1322370b807fSmrg $debug_cmd 1323370b807fSmrg _G_func_quote_mode=$1 ; shift 1324370b807fSmrg func_quote_result= 1325370b807fSmrg while test 0 -lt $#; do 1326370b807fSmrg func_quote_arg "$_G_func_quote_mode" "$1" 1327370b807fSmrg if test -n "$func_quote_result"; then 1328370b807fSmrg func_append func_quote_result " $func_quote_arg_result" 1329370b807fSmrg else 1330370b807fSmrg func_append func_quote_result "$func_quote_arg_result" 1331370b807fSmrg fi 1332370b807fSmrg shift 1333370b807fSmrg done 1334e4da38afSmrg} 1335e4da38afSmrg 1336e4da38afSmrg 1337e4da38afSmrg# func_stripname PREFIX SUFFIX NAME 1338e4da38afSmrg# --------------------------------- 1339e4da38afSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1340e4da38afSmrg# PREFIX and SUFFIX must not contain globbing or regex special 1341e4da38afSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 1342e4da38afSmrg# dot (in which case that matches only a dot). 1343e4da38afSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 1344e4da38afSmrg eval 'func_stripname () 1345e4da38afSmrg { 1346e4da38afSmrg $debug_cmd 1347e4da38afSmrg 1348e4da38afSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1349e4da38afSmrg # positional parameters, so assign one to ordinary variable first. 1350e4da38afSmrg func_stripname_result=$3 1351e4da38afSmrg func_stripname_result=${func_stripname_result#"$1"} 1352e4da38afSmrg func_stripname_result=${func_stripname_result%"$2"} 1353e4da38afSmrg }' 1354e4da38afSmrgelse 1355e4da38afSmrg func_stripname () 1356e4da38afSmrg { 1357e4da38afSmrg $debug_cmd 1358e4da38afSmrg 1359e4da38afSmrg case $2 in 1360e4da38afSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1361e4da38afSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1362e4da38afSmrg esac 1363e4da38afSmrg } 1364e4da38afSmrgfi 1365e4da38afSmrg 1366e4da38afSmrg 1367e4da38afSmrg# func_show_eval CMD [FAIL_EXP] 1368e4da38afSmrg# ----------------------------- 1369e4da38afSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1370e4da38afSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1371e4da38afSmrg# is given, then evaluate it. 1372e4da38afSmrgfunc_show_eval () 1373e4da38afSmrg{ 1374e4da38afSmrg $debug_cmd 1375e4da38afSmrg 1376e4da38afSmrg _G_cmd=$1 1377e4da38afSmrg _G_fail_exp=${2-':'} 1378e4da38afSmrg 1379370b807fSmrg func_quote_arg pretty,expand "$_G_cmd" 1380370b807fSmrg eval "func_notquiet $func_quote_arg_result" 1381e4da38afSmrg 1382e4da38afSmrg $opt_dry_run || { 1383e4da38afSmrg eval "$_G_cmd" 1384e4da38afSmrg _G_status=$? 1385e4da38afSmrg if test 0 -ne "$_G_status"; then 1386e4da38afSmrg eval "(exit $_G_status); $_G_fail_exp" 1387e4da38afSmrg fi 1388e4da38afSmrg } 1389e4da38afSmrg} 1390e4da38afSmrg 1391e4da38afSmrg 1392e4da38afSmrg# func_show_eval_locale CMD [FAIL_EXP] 1393e4da38afSmrg# ------------------------------------ 1394e4da38afSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1395e4da38afSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1396e4da38afSmrg# is given, then evaluate it. Use the saved locale for evaluation. 1397e4da38afSmrgfunc_show_eval_locale () 1398e4da38afSmrg{ 1399e4da38afSmrg $debug_cmd 1400e4da38afSmrg 1401e4da38afSmrg _G_cmd=$1 1402e4da38afSmrg _G_fail_exp=${2-':'} 1403e4da38afSmrg 1404e4da38afSmrg $opt_quiet || { 1405370b807fSmrg func_quote_arg expand,pretty "$_G_cmd" 1406370b807fSmrg eval "func_echo $func_quote_arg_result" 1407e4da38afSmrg } 1408e4da38afSmrg 1409e4da38afSmrg $opt_dry_run || { 1410e4da38afSmrg eval "$_G_user_locale 1411e4da38afSmrg $_G_cmd" 1412e4da38afSmrg _G_status=$? 1413e4da38afSmrg eval "$_G_safe_locale" 1414e4da38afSmrg if test 0 -ne "$_G_status"; then 1415e4da38afSmrg eval "(exit $_G_status); $_G_fail_exp" 1416e4da38afSmrg fi 1417e4da38afSmrg } 1418e4da38afSmrg} 1419e4da38afSmrg 1420e4da38afSmrg 1421e4da38afSmrg# func_tr_sh 1422e4da38afSmrg# ---------- 1423e4da38afSmrg# Turn $1 into a string suitable for a shell variable name. 1424e4da38afSmrg# Result is stored in $func_tr_sh_result. All characters 1425e4da38afSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1426e4da38afSmrg# if $1 begins with a digit, a '_' is prepended as well. 1427e4da38afSmrgfunc_tr_sh () 1428e4da38afSmrg{ 1429e4da38afSmrg $debug_cmd 1430e4da38afSmrg 1431e4da38afSmrg case $1 in 1432e4da38afSmrg [0-9]* | *[!a-zA-Z0-9_]*) 1433e4da38afSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1434e4da38afSmrg ;; 1435e4da38afSmrg * ) 1436e4da38afSmrg func_tr_sh_result=$1 1437e4da38afSmrg ;; 1438e4da38afSmrg esac 1439e4da38afSmrg} 1440e4da38afSmrg 1441e4da38afSmrg 1442e4da38afSmrg# func_verbose ARG... 1443e4da38afSmrg# ------------------- 1444e4da38afSmrg# Echo program name prefixed message in verbose mode only. 1445e4da38afSmrgfunc_verbose () 1446e4da38afSmrg{ 1447e4da38afSmrg $debug_cmd 1448e4da38afSmrg 1449e4da38afSmrg $opt_verbose && func_echo "$*" 1450e4da38afSmrg 1451e4da38afSmrg : 1452e4da38afSmrg} 1453e4da38afSmrg 1454e4da38afSmrg 1455e4da38afSmrg# func_warn_and_continue ARG... 1456e4da38afSmrg# ----------------------------- 1457e4da38afSmrg# Echo program name prefixed warning message to standard error. 1458e4da38afSmrgfunc_warn_and_continue () 1459e4da38afSmrg{ 1460e4da38afSmrg $debug_cmd 1461e4da38afSmrg 1462e4da38afSmrg $require_term_colors 1463e4da38afSmrg 1464e4da38afSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1465e4da38afSmrg} 1466e4da38afSmrg 1467e4da38afSmrg 1468e4da38afSmrg# func_warning CATEGORY ARG... 1469e4da38afSmrg# ---------------------------- 1470e4da38afSmrg# Echo program name prefixed warning message to standard error. Warning 1471e4da38afSmrg# messages can be filtered according to CATEGORY, where this function 1472e4da38afSmrg# elides messages where CATEGORY is not listed in the global variable 1473e4da38afSmrg# 'opt_warning_types'. 1474e4da38afSmrgfunc_warning () 1475e4da38afSmrg{ 1476e4da38afSmrg $debug_cmd 1477e4da38afSmrg 1478e4da38afSmrg # CATEGORY must be in the warning_categories list! 1479e4da38afSmrg case " $warning_categories " in 1480e4da38afSmrg *" $1 "*) ;; 1481e4da38afSmrg *) func_internal_error "invalid warning category '$1'" ;; 1482e4da38afSmrg esac 1483e4da38afSmrg 1484e4da38afSmrg _G_category=$1 1485e4da38afSmrg shift 1486e4da38afSmrg 1487e4da38afSmrg case " $opt_warning_types " in 1488e4da38afSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 1489e4da38afSmrg esac 1490e4da38afSmrg} 1491e4da38afSmrg 1492e4da38afSmrg 1493e4da38afSmrg# func_sort_ver VER1 VER2 1494e4da38afSmrg# ----------------------- 1495e4da38afSmrg# 'sort -V' is not generally available. 1496e4da38afSmrg# Note this deviates from the version comparison in automake 1497e4da38afSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1498e4da38afSmrg# but this should suffice as we won't be specifying old 1499e4da38afSmrg# version formats or redundant trailing .0 in bootstrap.conf. 1500e4da38afSmrg# If we did want full compatibility then we should probably 1501e4da38afSmrg# use m4_version_compare from autoconf. 1502e4da38afSmrgfunc_sort_ver () 1503e4da38afSmrg{ 1504e4da38afSmrg $debug_cmd 1505e4da38afSmrg 1506e4da38afSmrg printf '%s\n%s\n' "$1" "$2" \ 1507e4da38afSmrg | 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 1508e4da38afSmrg} 1509e4da38afSmrg 1510e4da38afSmrg# func_lt_ver PREV CURR 1511e4da38afSmrg# --------------------- 1512e4da38afSmrg# Return true if PREV and CURR are in the correct order according to 1513e4da38afSmrg# func_sort_ver, otherwise false. Use it like this: 1514e4da38afSmrg# 1515e4da38afSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1516e4da38afSmrgfunc_lt_ver () 1517e4da38afSmrg{ 1518e4da38afSmrg $debug_cmd 1519e4da38afSmrg 1520e4da38afSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1521e4da38afSmrg} 1522e4da38afSmrg 1523e4da38afSmrg 1524e4da38afSmrg# Local variables: 1525e4da38afSmrg# mode: shell-script 1526e4da38afSmrg# sh-indentation: 2 1527e4da38afSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 1528e4da38afSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1529e4da38afSmrg# time-stamp-time-zone: "UTC" 1530e4da38afSmrg# End: 1531e4da38afSmrg#! /bin/sh 1532e4da38afSmrg 1533e4da38afSmrg# A portable, pluggable option parser for Bourne shell. 1534e4da38afSmrg# Written by Gary V. Vaughan, 2010 1535e4da38afSmrg 1536370b807fSmrg# This is free software. There is NO warranty; not even for 1537370b807fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1538370b807fSmrg# 1539370b807fSmrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 1540370b807fSmrg# 1541370b807fSmrg# This file is dual licensed under the terms of the MIT license 1542370b807fSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 1543370b807fSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 1544370b807fSmrg# these licenses when using or redistributing this software or any of 1545370b807fSmrg# the files within it. See the URLs above, or the file `LICENSE` 1546370b807fSmrg# included in the Bootstrap distribution for the full license texts. 1547e4da38afSmrg 1548370b807fSmrg# Please report bugs or propose patches to: 1549370b807fSmrg# <https://github.com/gnulib-modules/bootstrap/issues> 1550e4da38afSmrg 1551370b807fSmrg# Set a version string for this script. 1552370b807fSmrgscriptversion=2019-02-19.15; # UTC 1553e4da38afSmrg 1554e4da38afSmrg 1555e4da38afSmrg## ------ ## 1556e4da38afSmrg## Usage. ## 1557e4da38afSmrg## ------ ## 1558e4da38afSmrg 1559e4da38afSmrg# This file is a library for parsing options in your shell scripts along 1560e4da38afSmrg# with assorted other useful supporting features that you can make use 1561e4da38afSmrg# of too. 1562e4da38afSmrg# 1563e4da38afSmrg# For the simplest scripts you might need only: 1564e4da38afSmrg# 1565e4da38afSmrg# #!/bin/sh 1566e4da38afSmrg# . relative/path/to/funclib.sh 1567e4da38afSmrg# . relative/path/to/options-parser 1568e4da38afSmrg# scriptversion=1.0 1569e4da38afSmrg# func_options ${1+"$@"} 1570e4da38afSmrg# eval set dummy "$func_options_result"; shift 1571e4da38afSmrg# ...rest of your script... 1572e4da38afSmrg# 1573e4da38afSmrg# In order for the '--version' option to work, you will need to have a 1574e4da38afSmrg# suitably formatted comment like the one at the top of this file 1575370b807fSmrg# starting with '# Written by ' and ending with '# Copyright'. 1576e4da38afSmrg# 1577e4da38afSmrg# For '-h' and '--help' to work, you will also need a one line 1578e4da38afSmrg# description of your script's purpose in a comment directly above the 1579e4da38afSmrg# '# Written by ' line, like the one at the top of this file. 1580e4da38afSmrg# 1581e4da38afSmrg# The default options also support '--debug', which will turn on shell 1582e4da38afSmrg# execution tracing (see the comment above debug_cmd below for another 1583e4da38afSmrg# use), and '--verbose' and the func_verbose function to allow your script 1584e4da38afSmrg# to display verbose messages only when your user has specified 1585e4da38afSmrg# '--verbose'. 1586e4da38afSmrg# 1587370b807fSmrg# After sourcing this file, you can plug in processing for additional 1588e4da38afSmrg# options by amending the variables from the 'Configuration' section 1589e4da38afSmrg# below, and following the instructions in the 'Option parsing' 1590e4da38afSmrg# section further down. 1591e4da38afSmrg 1592e4da38afSmrg## -------------- ## 1593e4da38afSmrg## Configuration. ## 1594e4da38afSmrg## -------------- ## 1595e4da38afSmrg 1596e4da38afSmrg# You should override these variables in your script after sourcing this 1597e4da38afSmrg# file so that they reflect the customisations you have added to the 1598e4da38afSmrg# option parser. 1599e4da38afSmrg 1600e4da38afSmrg# The usage line for option parsing errors and the start of '-h' and 1601e4da38afSmrg# '--help' output messages. You can embed shell variables for delayed 1602e4da38afSmrg# expansion at the time the message is displayed, but you will need to 1603e4da38afSmrg# quote other shell meta-characters carefully to prevent them being 1604e4da38afSmrg# expanded when the contents are evaled. 1605e4da38afSmrgusage='$progpath [OPTION]...' 1606e4da38afSmrg 1607e4da38afSmrg# Short help message in response to '-h' and '--help'. Add to this or 1608e4da38afSmrg# override it after sourcing this library to reflect the full set of 1609e4da38afSmrg# options your script accepts. 1610e4da38afSmrgusage_message="\ 1611e4da38afSmrg --debug enable verbose shell tracing 1612e4da38afSmrg -W, --warnings=CATEGORY 1613e4da38afSmrg report the warnings falling in CATEGORY [all] 1614e4da38afSmrg -v, --verbose verbosely report processing 1615e4da38afSmrg --version print version information and exit 1616e4da38afSmrg -h, --help print short or long help message and exit 1617e4da38afSmrg" 1618e4da38afSmrg 1619e4da38afSmrg# Additional text appended to 'usage_message' in response to '--help'. 1620e4da38afSmrglong_help_message=" 1621e4da38afSmrgWarning categories include: 1622e4da38afSmrg 'all' show all warnings 1623e4da38afSmrg 'none' turn off all the warnings 1624e4da38afSmrg 'error' warnings are treated as fatal errors" 1625e4da38afSmrg 1626e4da38afSmrg# Help message printed before fatal option parsing errors. 1627e4da38afSmrgfatal_help="Try '\$progname --help' for more information." 1628e4da38afSmrg 1629e4da38afSmrg 1630e4da38afSmrg 1631e4da38afSmrg## ------------------------- ## 1632e4da38afSmrg## Hook function management. ## 1633e4da38afSmrg## ------------------------- ## 1634e4da38afSmrg 1635e4da38afSmrg# This section contains functions for adding, removing, and running hooks 1636370b807fSmrg# in the main code. A hook is just a list of function names that can be 1637370b807fSmrg# run in order later on. 1638e4da38afSmrg 1639e4da38afSmrg# func_hookable FUNC_NAME 1640e4da38afSmrg# ----------------------- 1641e4da38afSmrg# Declare that FUNC_NAME will run hooks added with 1642e4da38afSmrg# 'func_add_hook FUNC_NAME ...'. 1643e4da38afSmrgfunc_hookable () 1644e4da38afSmrg{ 1645e4da38afSmrg $debug_cmd 1646e4da38afSmrg 1647e4da38afSmrg func_append hookable_fns " $1" 1648e4da38afSmrg} 1649e4da38afSmrg 1650e4da38afSmrg 1651e4da38afSmrg# func_add_hook FUNC_NAME HOOK_FUNC 1652e4da38afSmrg# --------------------------------- 1653e4da38afSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1654e4da38afSmrg# first have been declared "hookable" by a call to 'func_hookable'. 1655e4da38afSmrgfunc_add_hook () 1656e4da38afSmrg{ 1657e4da38afSmrg $debug_cmd 1658e4da38afSmrg 1659e4da38afSmrg case " $hookable_fns " in 1660e4da38afSmrg *" $1 "*) ;; 1661e4da38afSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 1662e4da38afSmrg esac 1663e4da38afSmrg 1664e4da38afSmrg eval func_append ${1}_hooks '" $2"' 1665e4da38afSmrg} 1666e4da38afSmrg 1667e4da38afSmrg 1668e4da38afSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 1669e4da38afSmrg# ------------------------------------ 1670370b807fSmrg# Remove HOOK_FUNC from the list of hook functions to be called by 1671370b807fSmrg# FUNC_NAME. 1672e4da38afSmrgfunc_remove_hook () 1673e4da38afSmrg{ 1674e4da38afSmrg $debug_cmd 1675e4da38afSmrg 1676e4da38afSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1677e4da38afSmrg} 1678e4da38afSmrg 1679e4da38afSmrg 1680370b807fSmrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 1681370b807fSmrg# --------------------------------------------- 1682370b807fSmrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 1683370b807fSmrg# *_result variable of FUNC_NAME_B. 1684370b807fSmrgfunc_propagate_result () 1685370b807fSmrg{ 1686370b807fSmrg $debug_cmd 1687370b807fSmrg 1688370b807fSmrg func_propagate_result_result=: 1689370b807fSmrg if eval "test \"\${${1}_result+set}\" = set" 1690370b807fSmrg then 1691370b807fSmrg eval "${2}_result=\$${1}_result" 1692370b807fSmrg else 1693370b807fSmrg func_propagate_result_result=false 1694370b807fSmrg fi 1695370b807fSmrg} 1696370b807fSmrg 1697370b807fSmrg 1698e4da38afSmrg# func_run_hooks FUNC_NAME [ARG]... 1699e4da38afSmrg# --------------------------------- 1700e4da38afSmrg# Run all hook functions registered to FUNC_NAME. 1701370b807fSmrg# It's assumed that the list of hook functions contains nothing more 1702e4da38afSmrg# than a whitespace-delimited list of legal shell function names, and 1703e4da38afSmrg# no effort is wasted trying to catch shell meta-characters or preserve 1704e4da38afSmrg# whitespace. 1705e4da38afSmrgfunc_run_hooks () 1706e4da38afSmrg{ 1707e4da38afSmrg $debug_cmd 1708e4da38afSmrg 1709e4da38afSmrg case " $hookable_fns " in 1710e4da38afSmrg *" $1 "*) ;; 1711370b807fSmrg *) func_fatal_error "'$1' does not support hook functions." ;; 1712e4da38afSmrg esac 1713e4da38afSmrg 1714e4da38afSmrg eval _G_hook_fns=\$$1_hooks; shift 1715e4da38afSmrg 1716e4da38afSmrg for _G_hook in $_G_hook_fns; do 1717370b807fSmrg func_unset "${_G_hook}_result" 1718370b807fSmrg eval $_G_hook '${1+"$@"}' 1719370b807fSmrg func_propagate_result $_G_hook func_run_hooks 1720370b807fSmrg if $func_propagate_result_result; then 1721370b807fSmrg eval set dummy "$func_run_hooks_result"; shift 1722370b807fSmrg fi 1723e4da38afSmrg done 1724e4da38afSmrg} 1725e4da38afSmrg 1726e4da38afSmrg 1727e4da38afSmrg 1728e4da38afSmrg## --------------- ## 1729e4da38afSmrg## Option parsing. ## 1730e4da38afSmrg## --------------- ## 1731e4da38afSmrg 1732e4da38afSmrg# In order to add your own option parsing hooks, you must accept the 1733370b807fSmrg# full positional parameter list from your hook function. You may remove 1734370b807fSmrg# or edit any options that you action, and then pass back the remaining 1735370b807fSmrg# unprocessed options in '<hooked_function_name>_result', escaped 1736370b807fSmrg# suitably for 'eval'. 1737370b807fSmrg# 1738370b807fSmrg# The '<hooked_function_name>_result' variable is automatically unset 1739370b807fSmrg# before your hook gets called; for best performance, only set the 1740370b807fSmrg# *_result variable when necessary (i.e. don't call the 'func_quote' 1741370b807fSmrg# function unnecessarily because it can be an expensive operation on some 1742370b807fSmrg# machines). 1743370b807fSmrg# 1744370b807fSmrg# Like this: 1745e4da38afSmrg# 1746e4da38afSmrg# my_options_prep () 1747e4da38afSmrg# { 1748e4da38afSmrg# $debug_cmd 1749e4da38afSmrg# 1750e4da38afSmrg# # Extend the existing usage message. 1751e4da38afSmrg# usage_message=$usage_message' 1752e4da38afSmrg# -s, --silent don'\''t print informational messages 1753e4da38afSmrg# ' 1754370b807fSmrg# # No change in '$@' (ignored completely by this hook). Leave 1755370b807fSmrg# # my_options_prep_result variable intact. 1756e4da38afSmrg# } 1757e4da38afSmrg# func_add_hook func_options_prep my_options_prep 1758e4da38afSmrg# 1759e4da38afSmrg# 1760e4da38afSmrg# my_silent_option () 1761e4da38afSmrg# { 1762e4da38afSmrg# $debug_cmd 1763e4da38afSmrg# 1764370b807fSmrg# args_changed=false 1765370b807fSmrg# 1766370b807fSmrg# # Note that, for efficiency, we parse as many options as we can 1767e4da38afSmrg# # recognise in a loop before passing the remainder back to the 1768e4da38afSmrg# # caller on the first unrecognised argument we encounter. 1769e4da38afSmrg# while test $# -gt 0; do 1770e4da38afSmrg# opt=$1; shift 1771e4da38afSmrg# case $opt in 1772370b807fSmrg# --silent|-s) opt_silent=: 1773370b807fSmrg# args_changed=: 1774370b807fSmrg# ;; 1775e4da38afSmrg# # Separate non-argument short options: 1776e4da38afSmrg# -s*) func_split_short_opt "$_G_opt" 1777e4da38afSmrg# set dummy "$func_split_short_opt_name" \ 1778e4da38afSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 1779e4da38afSmrg# shift 1780370b807fSmrg# args_changed=: 1781e4da38afSmrg# ;; 1782370b807fSmrg# *) # Make sure the first unrecognised option "$_G_opt" 1783370b807fSmrg# # is added back to "$@" in case we need it later, 1784370b807fSmrg# # if $args_changed was set to 'true'. 1785370b807fSmrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1786e4da38afSmrg# esac 1787e4da38afSmrg# done 1788e4da38afSmrg# 1789370b807fSmrg# # Only call 'func_quote' here if we processed at least one argument. 1790370b807fSmrg# if $args_changed; then 1791370b807fSmrg# func_quote eval ${1+"$@"} 1792370b807fSmrg# my_silent_option_result=$func_quote_result 1793370b807fSmrg# fi 1794e4da38afSmrg# } 1795e4da38afSmrg# func_add_hook func_parse_options my_silent_option 1796e4da38afSmrg# 1797e4da38afSmrg# 1798e4da38afSmrg# my_option_validation () 1799e4da38afSmrg# { 1800e4da38afSmrg# $debug_cmd 1801e4da38afSmrg# 1802e4da38afSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 1803e4da38afSmrg# '--silent' and '--verbose' options are mutually exclusive." 1804e4da38afSmrg# } 1805e4da38afSmrg# func_add_hook func_validate_options my_option_validation 1806e4da38afSmrg# 1807370b807fSmrg# You'll also need to manually amend $usage_message to reflect the extra 1808e4da38afSmrg# options you parse. It's preferable to append if you can, so that 1809e4da38afSmrg# multiple option parsing hooks can be added safely. 1810e4da38afSmrg 1811e4da38afSmrg 1812370b807fSmrg# func_options_finish [ARG]... 1813370b807fSmrg# ---------------------------- 1814370b807fSmrg# Finishing the option parse loop (call 'func_options' hooks ATM). 1815370b807fSmrgfunc_options_finish () 1816370b807fSmrg{ 1817370b807fSmrg $debug_cmd 1818370b807fSmrg 1819370b807fSmrg func_run_hooks func_options ${1+"$@"} 1820370b807fSmrg func_propagate_result func_run_hooks func_options_finish 1821370b807fSmrg} 1822370b807fSmrg 1823370b807fSmrg 1824e4da38afSmrg# func_options [ARG]... 1825e4da38afSmrg# --------------------- 1826e4da38afSmrg# All the functions called inside func_options are hookable. See the 1827e4da38afSmrg# individual implementations for details. 1828e4da38afSmrgfunc_hookable func_options 1829e4da38afSmrgfunc_options () 1830e4da38afSmrg{ 1831e4da38afSmrg $debug_cmd 1832e4da38afSmrg 1833370b807fSmrg _G_options_quoted=false 1834e4da38afSmrg 1835370b807fSmrg for my_func in options_prep parse_options validate_options options_finish 1836370b807fSmrg do 1837370b807fSmrg func_unset func_${my_func}_result 1838370b807fSmrg func_unset func_run_hooks_result 1839370b807fSmrg eval func_$my_func '${1+"$@"}' 1840370b807fSmrg func_propagate_result func_$my_func func_options 1841370b807fSmrg if $func_propagate_result_result; then 1842370b807fSmrg eval set dummy "$func_options_result"; shift 1843370b807fSmrg _G_options_quoted=: 1844370b807fSmrg fi 1845370b807fSmrg done 1846e4da38afSmrg 1847370b807fSmrg $_G_options_quoted || { 1848370b807fSmrg # As we (func_options) are top-level options-parser function and 1849370b807fSmrg # nobody quoted "$@" for us yet, we need to do it explicitly for 1850370b807fSmrg # caller. 1851370b807fSmrg func_quote eval ${1+"$@"} 1852370b807fSmrg func_options_result=$func_quote_result 1853370b807fSmrg } 1854659607e0Smrg} 1855659607e0Smrg 1856659607e0Smrg 1857e4da38afSmrg# func_options_prep [ARG]... 1858e4da38afSmrg# -------------------------- 1859e4da38afSmrg# All initialisations required before starting the option parse loop. 1860e4da38afSmrg# Note that when calling hook functions, we pass through the list of 1861e4da38afSmrg# positional parameters. If a hook function modifies that list, and 1862370b807fSmrg# needs to propagate that back to rest of this script, then the complete 1863370b807fSmrg# modified list must be put in 'func_run_hooks_result' before returning. 1864e4da38afSmrgfunc_hookable func_options_prep 1865e4da38afSmrgfunc_options_prep () 1866659607e0Smrg{ 1867e4da38afSmrg $debug_cmd 1868fc27e79cSmrg 1869e4da38afSmrg # Option defaults: 1870e4da38afSmrg opt_verbose=false 1871e4da38afSmrg opt_warning_types= 1872e4da38afSmrg 1873e4da38afSmrg func_run_hooks func_options_prep ${1+"$@"} 1874370b807fSmrg func_propagate_result func_run_hooks func_options_prep 1875659607e0Smrg} 1876659607e0Smrg 1877659607e0Smrg 1878e4da38afSmrg# func_parse_options [ARG]... 1879e4da38afSmrg# --------------------------- 1880e4da38afSmrg# The main option parsing loop. 1881e4da38afSmrgfunc_hookable func_parse_options 1882e4da38afSmrgfunc_parse_options () 1883659607e0Smrg{ 1884e4da38afSmrg $debug_cmd 1885fc27e79cSmrg 1886370b807fSmrg _G_parse_options_requote=false 1887e4da38afSmrg # this just eases exit handling 1888e4da38afSmrg while test $# -gt 0; do 1889e4da38afSmrg # Defer to hook functions for initial option parsing, so they 1890e4da38afSmrg # get priority in the event of reusing an option name. 1891e4da38afSmrg func_run_hooks func_parse_options ${1+"$@"} 1892370b807fSmrg func_propagate_result func_run_hooks func_parse_options 1893370b807fSmrg if $func_propagate_result_result; then 1894370b807fSmrg eval set dummy "$func_parse_options_result"; shift 1895370b807fSmrg # Even though we may have changed "$@", we passed the "$@" array 1896370b807fSmrg # down into the hook and it quoted it for us (because we are in 1897370b807fSmrg # this if-branch). No need to quote it again. 1898370b807fSmrg _G_parse_options_requote=false 1899370b807fSmrg fi 1900659607e0Smrg 1901e4da38afSmrg # Break out of the loop if we already parsed every option. 1902e4da38afSmrg test $# -gt 0 || break 1903659607e0Smrg 1904370b807fSmrg # We expect that one of the options parsed in this function matches 1905370b807fSmrg # and thus we remove _G_opt from "$@" and need to re-quote. 1906370b807fSmrg _G_match_parse_options=: 1907e4da38afSmrg _G_opt=$1 1908e4da38afSmrg shift 1909e4da38afSmrg case $_G_opt in 1910e4da38afSmrg --debug|-x) debug_cmd='set -x' 1911370b807fSmrg func_echo "enabling shell trace mode" >&2 1912e4da38afSmrg $debug_cmd 1913e4da38afSmrg ;; 1914e4da38afSmrg 1915e4da38afSmrg --no-warnings|--no-warning|--no-warn) 1916e4da38afSmrg set dummy --warnings none ${1+"$@"} 1917e4da38afSmrg shift 1918e4da38afSmrg ;; 1919fc27e79cSmrg 1920e4da38afSmrg --warnings|--warning|-W) 1921370b807fSmrg if test $# = 0 && func_missing_arg $_G_opt; then 1922370b807fSmrg _G_parse_options_requote=: 1923370b807fSmrg break 1924370b807fSmrg fi 1925e4da38afSmrg case " $warning_categories $1" in 1926e4da38afSmrg *" $1 "*) 1927e4da38afSmrg # trailing space prevents matching last $1 above 1928e4da38afSmrg func_append_uniq opt_warning_types " $1" 1929e4da38afSmrg ;; 1930e4da38afSmrg *all) 1931e4da38afSmrg opt_warning_types=$warning_categories 1932e4da38afSmrg ;; 1933e4da38afSmrg *none) 1934e4da38afSmrg opt_warning_types=none 1935e4da38afSmrg warning_func=: 1936e4da38afSmrg ;; 1937e4da38afSmrg *error) 1938e4da38afSmrg opt_warning_types=$warning_categories 1939e4da38afSmrg warning_func=func_fatal_error 1940e4da38afSmrg ;; 1941e4da38afSmrg *) 1942e4da38afSmrg func_fatal_error \ 1943e4da38afSmrg "unsupported warning category: '$1'" 1944e4da38afSmrg ;; 1945e4da38afSmrg esac 1946e4da38afSmrg shift 1947e4da38afSmrg ;; 1948e4da38afSmrg 1949e4da38afSmrg --verbose|-v) opt_verbose=: ;; 1950e4da38afSmrg --version) func_version ;; 1951e4da38afSmrg -\?|-h) func_usage ;; 1952e4da38afSmrg --help) func_help ;; 1953e4da38afSmrg 1954e4da38afSmrg # Separate optargs to long options (plugins may need this): 1955e4da38afSmrg --*=*) func_split_equals "$_G_opt" 1956e4da38afSmrg set dummy "$func_split_equals_lhs" \ 1957e4da38afSmrg "$func_split_equals_rhs" ${1+"$@"} 1958e4da38afSmrg shift 1959e4da38afSmrg ;; 1960e4da38afSmrg 1961e4da38afSmrg # Separate optargs to short options: 1962e4da38afSmrg -W*) 1963e4da38afSmrg func_split_short_opt "$_G_opt" 1964e4da38afSmrg set dummy "$func_split_short_opt_name" \ 1965e4da38afSmrg "$func_split_short_opt_arg" ${1+"$@"} 1966e4da38afSmrg shift 1967e4da38afSmrg ;; 1968e4da38afSmrg 1969e4da38afSmrg # Separate non-argument short options: 1970e4da38afSmrg -\?*|-h*|-v*|-x*) 1971e4da38afSmrg func_split_short_opt "$_G_opt" 1972e4da38afSmrg set dummy "$func_split_short_opt_name" \ 1973e4da38afSmrg "-$func_split_short_opt_arg" ${1+"$@"} 1974e4da38afSmrg shift 1975e4da38afSmrg ;; 1976e4da38afSmrg 1977370b807fSmrg --) _G_parse_options_requote=: ; break ;; 1978e4da38afSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1979370b807fSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift 1980370b807fSmrg _G_match_parse_options=false 1981370b807fSmrg break 1982370b807fSmrg ;; 1983e4da38afSmrg esac 1984370b807fSmrg 1985370b807fSmrg if $_G_match_parse_options; then 1986370b807fSmrg _G_parse_options_requote=: 1987370b807fSmrg fi 1988e4da38afSmrg done 1989e4da38afSmrg 1990370b807fSmrg if $_G_parse_options_requote; then 1991370b807fSmrg # save modified positional parameters for caller 1992370b807fSmrg func_quote eval ${1+"$@"} 1993370b807fSmrg func_parse_options_result=$func_quote_result 1994370b807fSmrg fi 1995659607e0Smrg} 1996659607e0Smrg 1997fc27e79cSmrg 1998e4da38afSmrg# func_validate_options [ARG]... 1999e4da38afSmrg# ------------------------------ 2000e4da38afSmrg# Perform any sanity checks on option settings and/or unconsumed 2001e4da38afSmrg# arguments. 2002e4da38afSmrgfunc_hookable func_validate_options 2003e4da38afSmrgfunc_validate_options () 2004659607e0Smrg{ 2005e4da38afSmrg $debug_cmd 2006659607e0Smrg 2007e4da38afSmrg # Display all warnings if -W was not given. 2008e4da38afSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 2009fc27e79cSmrg 2010e4da38afSmrg func_run_hooks func_validate_options ${1+"$@"} 2011370b807fSmrg func_propagate_result func_run_hooks func_validate_options 2012659607e0Smrg 2013e4da38afSmrg # Bail if the options were screwed! 2014e4da38afSmrg $exit_cmd $EXIT_FAILURE 2015bd3a1963Smrg} 2016fc27e79cSmrg 2017fc27e79cSmrg 2018bd3a1963Smrg 2019e4da38afSmrg## ----------------- ## 2020e4da38afSmrg## Helper functions. ## 2021e4da38afSmrg## ----------------- ## 2022fc27e79cSmrg 2023e4da38afSmrg# This section contains the helper functions used by the rest of the 2024e4da38afSmrg# hookable option parser framework in ascii-betical order. 2025e4da38afSmrg 2026e4da38afSmrg 2027e4da38afSmrg# func_fatal_help ARG... 2028e4da38afSmrg# ---------------------- 2029e4da38afSmrg# Echo program name prefixed message to standard error, followed by 2030e4da38afSmrg# a help hint, and exit. 2031e4da38afSmrgfunc_fatal_help () 2032fc27e79cSmrg{ 2033e4da38afSmrg $debug_cmd 2034bd3a1963Smrg 2035e4da38afSmrg eval \$ECHO \""Usage: $usage"\" 2036e4da38afSmrg eval \$ECHO \""$fatal_help"\" 2037e4da38afSmrg func_error ${1+"$@"} 2038e4da38afSmrg exit $EXIT_FAILURE 2039fc27e79cSmrg} 2040fc27e79cSmrg 2041e4da38afSmrg 2042e4da38afSmrg# func_help 2043e4da38afSmrg# --------- 2044e4da38afSmrg# Echo long help message to standard output and exit. 2045fc27e79cSmrgfunc_help () 2046fc27e79cSmrg{ 2047e4da38afSmrg $debug_cmd 2048e4da38afSmrg 2049e4da38afSmrg func_usage_message 2050e4da38afSmrg $ECHO "$long_help_message" 2051e4da38afSmrg exit 0 2052fc27e79cSmrg} 2053fc27e79cSmrg 2054e4da38afSmrg 2055e4da38afSmrg# func_missing_arg ARGNAME 2056e4da38afSmrg# ------------------------ 2057fc27e79cSmrg# Echo program name prefixed message to standard error and set global 2058fc27e79cSmrg# exit_cmd. 2059fc27e79cSmrgfunc_missing_arg () 2060fc27e79cSmrg{ 2061e4da38afSmrg $debug_cmd 2062bd3a1963Smrg 2063e4da38afSmrg func_error "Missing argument for '$1'." 2064fc27e79cSmrg exit_cmd=exit 2065fc27e79cSmrg} 2066fc27e79cSmrg 2067fc27e79cSmrg 2068e4da38afSmrg# func_split_equals STRING 2069e4da38afSmrg# ------------------------ 2070370b807fSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 2071370b807fSmrg# after splitting STRING at the '=' sign. 2072e4da38afSmrgtest -z "$_G_HAVE_XSI_OPS" \ 2073e4da38afSmrg && (eval 'x=a/b/c; 2074e4da38afSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 2075e4da38afSmrg && _G_HAVE_XSI_OPS=yes 2076e4da38afSmrg 2077e4da38afSmrgif test yes = "$_G_HAVE_XSI_OPS" 2078e4da38afSmrgthen 2079e4da38afSmrg # This is an XSI compatible shell, allowing a faster implementation... 2080e4da38afSmrg eval 'func_split_equals () 2081e4da38afSmrg { 2082e4da38afSmrg $debug_cmd 2083e4da38afSmrg 2084e4da38afSmrg func_split_equals_lhs=${1%%=*} 2085e4da38afSmrg func_split_equals_rhs=${1#*=} 2086370b807fSmrg if test "x$func_split_equals_lhs" = "x$1"; then 2087370b807fSmrg func_split_equals_rhs= 2088370b807fSmrg fi 2089e4da38afSmrg }' 2090e4da38afSmrgelse 2091e4da38afSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 2092e4da38afSmrg func_split_equals () 2093e4da38afSmrg { 2094e4da38afSmrg $debug_cmd 2095e4da38afSmrg 2096e4da38afSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 2097e4da38afSmrg func_split_equals_rhs= 2098370b807fSmrg test "x$func_split_equals_lhs=" = "x$1" \ 2099e4da38afSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 2100e4da38afSmrg } 2101e4da38afSmrgfi #func_split_equals 2102e4da38afSmrg 2103e4da38afSmrg 2104e4da38afSmrg# func_split_short_opt SHORTOPT 2105e4da38afSmrg# ----------------------------- 2106bd3a1963Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 2107bd3a1963Smrg# variables after splitting SHORTOPT after the 2nd character. 2108e4da38afSmrgif test yes = "$_G_HAVE_XSI_OPS" 2109e4da38afSmrgthen 2110e4da38afSmrg # This is an XSI compatible shell, allowing a faster implementation... 2111e4da38afSmrg eval 'func_split_short_opt () 2112e4da38afSmrg { 2113e4da38afSmrg $debug_cmd 2114e4da38afSmrg 2115e4da38afSmrg func_split_short_opt_arg=${1#??} 2116e4da38afSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 2117e4da38afSmrg }' 2118e4da38afSmrgelse 2119e4da38afSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 2120e4da38afSmrg func_split_short_opt () 2121e4da38afSmrg { 2122e4da38afSmrg $debug_cmd 2123e4da38afSmrg 2124370b807fSmrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 2125e4da38afSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 2126e4da38afSmrg } 2127e4da38afSmrgfi #func_split_short_opt 2128e4da38afSmrg 2129e4da38afSmrg 2130e4da38afSmrg# func_usage 2131e4da38afSmrg# ---------- 2132e4da38afSmrg# Echo short help message to standard output and exit. 2133e4da38afSmrgfunc_usage () 2134bd3a1963Smrg{ 2135e4da38afSmrg $debug_cmd 2136fc27e79cSmrg 2137e4da38afSmrg func_usage_message 2138e4da38afSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 2139e4da38afSmrg exit 0 2140e4da38afSmrg} 2141bd3a1963Smrg 2142bd3a1963Smrg 2143e4da38afSmrg# func_usage_message 2144e4da38afSmrg# ------------------ 2145e4da38afSmrg# Echo short help message to standard output. 2146e4da38afSmrgfunc_usage_message () 2147bd3a1963Smrg{ 2148e4da38afSmrg $debug_cmd 2149bd3a1963Smrg 2150e4da38afSmrg eval \$ECHO \""Usage: $usage"\" 2151e4da38afSmrg echo 2152e4da38afSmrg $SED -n 's|^# || 2153e4da38afSmrg /^Written by/{ 2154e4da38afSmrg x;p;x 2155e4da38afSmrg } 2156e4da38afSmrg h 2157e4da38afSmrg /^Written by/q' < "$progpath" 2158e4da38afSmrg echo 2159e4da38afSmrg eval \$ECHO \""$usage_message"\" 2160e4da38afSmrg} 2161bd3a1963Smrg 2162fc27e79cSmrg 2163e4da38afSmrg# func_version 2164e4da38afSmrg# ------------ 2165e4da38afSmrg# Echo version message to standard output and exit. 2166370b807fSmrg# The version message is extracted from the calling file's header 2167370b807fSmrg# comments, with leading '# ' stripped: 2168370b807fSmrg# 1. First display the progname and version 2169370b807fSmrg# 2. Followed by the header comment line matching /^# Written by / 2170370b807fSmrg# 3. Then a blank line followed by the first following line matching 2171370b807fSmrg# /^# Copyright / 2172370b807fSmrg# 4. Immediately followed by any lines between the previous matches, 2173370b807fSmrg# except lines preceding the intervening completely blank line. 2174370b807fSmrg# For example, see the header comments of this file. 2175e4da38afSmrgfunc_version () 2176e4da38afSmrg{ 2177e4da38afSmrg $debug_cmd 2178fc27e79cSmrg 2179e4da38afSmrg printf '%s\n' "$progname $scriptversion" 2180e4da38afSmrg $SED -n ' 2181370b807fSmrg /^# Written by /!b 2182370b807fSmrg s|^# ||; p; n 2183370b807fSmrg 2184370b807fSmrg :fwd2blnk 2185370b807fSmrg /./ { 2186370b807fSmrg n 2187370b807fSmrg b fwd2blnk 2188e4da38afSmrg } 2189370b807fSmrg p; n 2190370b807fSmrg 2191370b807fSmrg :holdwrnt 2192370b807fSmrg s|^# || 2193370b807fSmrg s|^# *$|| 2194370b807fSmrg /^Copyright /!{ 2195370b807fSmrg /./H 2196370b807fSmrg n 2197370b807fSmrg b holdwrnt 2198e4da38afSmrg } 2199370b807fSmrg 2200370b807fSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 2201370b807fSmrg G 2202370b807fSmrg s|\(\n\)\n*|\1|g 2203370b807fSmrg p; q' < "$progpath" 2204fc27e79cSmrg 2205e4da38afSmrg exit $? 2206e4da38afSmrg} 2207659607e0Smrg 2208659607e0Smrg 2209e4da38afSmrg# Local variables: 2210e4da38afSmrg# mode: shell-script 2211e4da38afSmrg# sh-indentation: 2 2212e4da38afSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 2213370b807fSmrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 2214e4da38afSmrg# time-stamp-time-zone: "UTC" 2215e4da38afSmrg# End: 2216659607e0Smrg 2217e4da38afSmrg# Set a version string. 2218370b807fSmrgscriptversion='(GNU libtool) 2.4.7' 2219659607e0Smrg 2220659607e0Smrg 2221e4da38afSmrg# func_echo ARG... 2222e4da38afSmrg# ---------------- 2223e4da38afSmrg# Libtool also displays the current mode in messages, so override 2224e4da38afSmrg# funclib.sh func_echo with this custom definition. 2225e4da38afSmrgfunc_echo () 2226bd3a1963Smrg{ 2227e4da38afSmrg $debug_cmd 2228bd3a1963Smrg 2229e4da38afSmrg _G_message=$* 2230bd3a1963Smrg 2231e4da38afSmrg func_echo_IFS=$IFS 2232e4da38afSmrg IFS=$nl 2233e4da38afSmrg for _G_line in $_G_message; do 2234e4da38afSmrg IFS=$func_echo_IFS 2235e4da38afSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 2236e4da38afSmrg done 2237e4da38afSmrg IFS=$func_echo_IFS 2238e4da38afSmrg} 2239bd3a1963Smrg 2240e4da38afSmrg 2241e4da38afSmrg# func_warning ARG... 2242e4da38afSmrg# ------------------- 2243e4da38afSmrg# Libtool warnings are not categorized, so override funclib.sh 2244e4da38afSmrg# func_warning with this simpler definition. 2245e4da38afSmrgfunc_warning () 2246bd3a1963Smrg{ 2247e4da38afSmrg $debug_cmd 2248bd3a1963Smrg 2249e4da38afSmrg $warning_func ${1+"$@"} 2250e4da38afSmrg} 2251bd3a1963Smrg 2252bd3a1963Smrg 2253e4da38afSmrg## ---------------- ## 2254e4da38afSmrg## Options parsing. ## 2255e4da38afSmrg## ---------------- ## 2256e4da38afSmrg 2257e4da38afSmrg# Hook in the functions to make sure our own options are parsed during 2258e4da38afSmrg# the option parsing loop. 2259e4da38afSmrg 2260e4da38afSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 2261e4da38afSmrg 2262e4da38afSmrg# Short help message in response to '-h'. 2263e4da38afSmrgusage_message="Options: 2264e4da38afSmrg --config show all configuration variables 2265e4da38afSmrg --debug enable verbose shell tracing 2266e4da38afSmrg -n, --dry-run display commands without modifying any files 2267e4da38afSmrg --features display basic configuration information and exit 2268e4da38afSmrg --mode=MODE use operation mode MODE 2269e4da38afSmrg --no-warnings equivalent to '-Wnone' 2270e4da38afSmrg --preserve-dup-deps don't remove duplicate dependency libraries 2271e4da38afSmrg --quiet, --silent don't print informational messages 2272e4da38afSmrg --tag=TAG use configuration variables from tag TAG 2273e4da38afSmrg -v, --verbose print more informational messages than default 2274e4da38afSmrg --version print version information 2275e4da38afSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2276e4da38afSmrg -h, --help, --help-all print short, long, or detailed help message 2277e4da38afSmrg" 2278bd3a1963Smrg 2279e4da38afSmrg# Additional text appended to 'usage_message' in response to '--help'. 2280e4da38afSmrgfunc_help () 2281bd3a1963Smrg{ 2282e4da38afSmrg $debug_cmd 2283e4da38afSmrg 2284e4da38afSmrg func_usage_message 2285e4da38afSmrg $ECHO "$long_help_message 2286e4da38afSmrg 2287e4da38afSmrgMODE must be one of the following: 2288e4da38afSmrg 2289e4da38afSmrg clean remove files from the build directory 2290e4da38afSmrg compile compile a source file into a libtool object 2291e4da38afSmrg execute automatically set library path, then run a program 2292e4da38afSmrg finish complete the installation of libtool libraries 2293e4da38afSmrg install install libraries or executables 2294e4da38afSmrg link create a library or an executable 2295e4da38afSmrg uninstall remove libraries from an installed directory 2296e4da38afSmrg 2297e4da38afSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 2298e4da38afSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2299e4da38afSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2300e4da38afSmrg 2301e4da38afSmrgWhen reporting a bug, please describe a test case to reproduce it and 2302e4da38afSmrginclude the following information: 2303e4da38afSmrg 2304e4da38afSmrg host-triplet: $host 2305e4da38afSmrg shell: $SHELL 2306e4da38afSmrg compiler: $LTCC 2307e4da38afSmrg compiler flags: $LTCFLAGS 2308e4da38afSmrg linker: $LD (gnu? $with_gnu_ld) 2309370b807fSmrg version: $progname (GNU libtool) 2.4.7 2310e4da38afSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2311e4da38afSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2312e4da38afSmrg 2313e4da38afSmrgReport bugs to <bug-libtool@gnu.org>. 2314e4da38afSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 2315e4da38afSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2316e4da38afSmrg exit 0 2317e4da38afSmrg} 2318bd3a1963Smrg 2319bd3a1963Smrg 2320e4da38afSmrg# func_lo2o OBJECT-NAME 2321e4da38afSmrg# --------------------- 2322e4da38afSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2323e4da38afSmrg# object suffix. 2324e4da38afSmrg 2325e4da38afSmrglo2o=s/\\.lo\$/.$objext/ 2326e4da38afSmrgo2lo=s/\\.$objext\$/.lo/ 2327e4da38afSmrg 2328e4da38afSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 2329e4da38afSmrg eval 'func_lo2o () 2330e4da38afSmrg { 2331e4da38afSmrg case $1 in 2332e4da38afSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2333e4da38afSmrg * ) func_lo2o_result=$1 ;; 2334e4da38afSmrg esac 2335e4da38afSmrg }' 2336e4da38afSmrg 2337e4da38afSmrg # func_xform LIBOBJ-OR-SOURCE 2338e4da38afSmrg # --------------------------- 2339e4da38afSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2340e4da38afSmrg # suffix to a '.lo' libtool-object suffix. 2341e4da38afSmrg eval 'func_xform () 2342e4da38afSmrg { 2343e4da38afSmrg func_xform_result=${1%.*}.lo 2344e4da38afSmrg }' 2345e4da38afSmrgelse 2346e4da38afSmrg # ...otherwise fall back to using sed. 2347e4da38afSmrg func_lo2o () 2348e4da38afSmrg { 2349e4da38afSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2350e4da38afSmrg } 2351e4da38afSmrg 2352e4da38afSmrg func_xform () 2353e4da38afSmrg { 2354e4da38afSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2355e4da38afSmrg } 2356e4da38afSmrgfi 2357bd3a1963Smrg 2358bd3a1963Smrg 2359e4da38afSmrg# func_fatal_configuration ARG... 2360e4da38afSmrg# ------------------------------- 2361fc27e79cSmrg# Echo program name prefixed message to standard error, followed by 2362fc27e79cSmrg# a configuration failure hint, and exit. 2363fc27e79cSmrgfunc_fatal_configuration () 2364fc27e79cSmrg{ 2365370b807fSmrg func_fatal_error ${1+"$@"} \ 2366e4da38afSmrg "See the $PACKAGE documentation for more information." \ 2367e4da38afSmrg "Fatal configuration error." 2368fc27e79cSmrg} 2369fc27e79cSmrg 2370fc27e79cSmrg 2371fc27e79cSmrg# func_config 2372e4da38afSmrg# ----------- 2373fc27e79cSmrg# Display the configuration for all the tags in this script. 2374fc27e79cSmrgfunc_config () 2375fc27e79cSmrg{ 2376fc27e79cSmrg re_begincf='^# ### BEGIN LIBTOOL' 2377fc27e79cSmrg re_endcf='^# ### END LIBTOOL' 2378fc27e79cSmrg 2379fc27e79cSmrg # Default configuration. 2380fc27e79cSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2381659607e0Smrg 2382659607e0Smrg # Now print the configurations for the tags. 2383659607e0Smrg for tagname in $taglist; do 2384fc27e79cSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2385659607e0Smrg done 2386659607e0Smrg 2387fc27e79cSmrg exit $? 2388fc27e79cSmrg} 2389659607e0Smrg 2390e4da38afSmrg 2391fc27e79cSmrg# func_features 2392e4da38afSmrg# ------------- 2393fc27e79cSmrg# Display the features supported by this script. 2394fc27e79cSmrgfunc_features () 2395fc27e79cSmrg{ 2396bd3a1963Smrg echo "host: $host" 2397e4da38afSmrg if test yes = "$build_libtool_libs"; then 2398bd3a1963Smrg echo "enable shared libraries" 2399659607e0Smrg else 2400bd3a1963Smrg echo "disable shared libraries" 2401659607e0Smrg fi 2402e4da38afSmrg if test yes = "$build_old_libs"; then 2403bd3a1963Smrg echo "enable static libraries" 2404659607e0Smrg else 2405bd3a1963Smrg echo "disable static libraries" 2406659607e0Smrg fi 2407fc27e79cSmrg 2408659607e0Smrg exit $? 2409fc27e79cSmrg} 2410fc27e79cSmrg 2411e4da38afSmrg 2412e4da38afSmrg# func_enable_tag TAGNAME 2413e4da38afSmrg# ----------------------- 2414fc27e79cSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2415fc27e79cSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2416fc27e79cSmrg# variable here. 2417fc27e79cSmrgfunc_enable_tag () 2418fc27e79cSmrg{ 2419e4da38afSmrg # Global variable: 2420e4da38afSmrg tagname=$1 2421659607e0Smrg 2422e4da38afSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2423e4da38afSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2424e4da38afSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2425659607e0Smrg 2426e4da38afSmrg # Validate tagname. 2427e4da38afSmrg case $tagname in 2428e4da38afSmrg *[!-_A-Za-z0-9,/]*) 2429e4da38afSmrg func_fatal_error "invalid tag name: $tagname" 2430e4da38afSmrg ;; 2431e4da38afSmrg esac 2432659607e0Smrg 2433e4da38afSmrg # Don't test for the "default" C tag, as we know it's 2434e4da38afSmrg # there but not specially marked. 2435e4da38afSmrg case $tagname in 2436e4da38afSmrg CC) ;; 2437fc27e79cSmrg *) 2438e4da38afSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2439e4da38afSmrg taglist="$taglist $tagname" 2440e4da38afSmrg 2441e4da38afSmrg # Evaluate the configuration. Be careful to quote the path 2442e4da38afSmrg # and the sed script, to avoid splitting on whitespace, but 2443e4da38afSmrg # also don't use non-portable quotes within backquotes within 2444e4da38afSmrg # quotes we have to do it in 2 steps: 2445e4da38afSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2446e4da38afSmrg eval "$extractedcf" 2447e4da38afSmrg else 2448e4da38afSmrg func_error "ignoring unknown tag $tagname" 2449e4da38afSmrg fi 2450e4da38afSmrg ;; 2451e4da38afSmrg esac 2452fc27e79cSmrg} 2453659607e0Smrg 2454e4da38afSmrg 2455bd3a1963Smrg# func_check_version_match 2456e4da38afSmrg# ------------------------ 2457bd3a1963Smrg# Ensure that we are using m4 macros, and libtool script from the same 2458bd3a1963Smrg# release of libtool. 2459bd3a1963Smrgfunc_check_version_match () 2460fc27e79cSmrg{ 2461e4da38afSmrg if test "$package_revision" != "$macro_revision"; then 2462e4da38afSmrg if test "$VERSION" != "$macro_version"; then 2463e4da38afSmrg if test -z "$macro_version"; then 2464e4da38afSmrg cat >&2 <<_LT_EOF 2465bd3a1963Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2466bd3a1963Smrg$progname: definition of this LT_INIT comes from an older release. 2467bd3a1963Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2468bd3a1963Smrg$progname: and run autoconf again. 2469bd3a1963Smrg_LT_EOF 2470e4da38afSmrg else 2471e4da38afSmrg cat >&2 <<_LT_EOF 2472bd3a1963Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2473bd3a1963Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2474bd3a1963Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2475bd3a1963Smrg$progname: and run autoconf again. 2476bd3a1963Smrg_LT_EOF 2477e4da38afSmrg fi 2478e4da38afSmrg else 2479e4da38afSmrg cat >&2 <<_LT_EOF 2480bd3a1963Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2481bd3a1963Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2482bd3a1963Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2483bd3a1963Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 2484bd3a1963Smrg_LT_EOF 2485e4da38afSmrg fi 2486659607e0Smrg 2487e4da38afSmrg exit $EXIT_MISMATCH 2488e4da38afSmrg fi 2489bd3a1963Smrg} 2490bd3a1963Smrg 2491bd3a1963Smrg 2492e4da38afSmrg# libtool_options_prep [ARG]... 2493e4da38afSmrg# ----------------------------- 2494e4da38afSmrg# Preparation for options parsed by libtool. 2495e4da38afSmrglibtool_options_prep () 2496e4da38afSmrg{ 2497e4da38afSmrg $debug_mode 2498bd3a1963Smrg 2499e4da38afSmrg # Option defaults: 2500e4da38afSmrg opt_config=false 2501e4da38afSmrg opt_dlopen= 2502e4da38afSmrg opt_dry_run=false 2503e4da38afSmrg opt_help=false 2504e4da38afSmrg opt_mode= 2505e4da38afSmrg opt_preserve_dup_deps=false 2506e4da38afSmrg opt_quiet=false 2507bd3a1963Smrg 2508e4da38afSmrg nonopt= 2509e4da38afSmrg preserve_args= 2510bd3a1963Smrg 2511370b807fSmrg _G_rc_lt_options_prep=: 2512370b807fSmrg 2513e4da38afSmrg # Shorthand for --mode=foo, only valid as the first argument 2514e4da38afSmrg case $1 in 2515e4da38afSmrg clean|clea|cle|cl) 2516e4da38afSmrg shift; set dummy --mode clean ${1+"$@"}; shift 2517e4da38afSmrg ;; 2518e4da38afSmrg compile|compil|compi|comp|com|co|c) 2519e4da38afSmrg shift; set dummy --mode compile ${1+"$@"}; shift 2520e4da38afSmrg ;; 2521e4da38afSmrg execute|execut|execu|exec|exe|ex|e) 2522e4da38afSmrg shift; set dummy --mode execute ${1+"$@"}; shift 2523e4da38afSmrg ;; 2524e4da38afSmrg finish|finis|fini|fin|fi|f) 2525e4da38afSmrg shift; set dummy --mode finish ${1+"$@"}; shift 2526e4da38afSmrg ;; 2527e4da38afSmrg install|instal|insta|inst|ins|in|i) 2528e4da38afSmrg shift; set dummy --mode install ${1+"$@"}; shift 2529e4da38afSmrg ;; 2530e4da38afSmrg link|lin|li|l) 2531e4da38afSmrg shift; set dummy --mode link ${1+"$@"}; shift 2532e4da38afSmrg ;; 2533e4da38afSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2534e4da38afSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 2535e4da38afSmrg ;; 2536370b807fSmrg *) 2537370b807fSmrg _G_rc_lt_options_prep=false 2538370b807fSmrg ;; 2539e4da38afSmrg esac 2540e4da38afSmrg 2541370b807fSmrg if $_G_rc_lt_options_prep; then 2542370b807fSmrg # Pass back the list of options. 2543370b807fSmrg func_quote eval ${1+"$@"} 2544370b807fSmrg libtool_options_prep_result=$func_quote_result 2545370b807fSmrg fi 2546e4da38afSmrg} 2547e4da38afSmrgfunc_add_hook func_options_prep libtool_options_prep 2548659607e0Smrg 2549bd3a1963Smrg 2550e4da38afSmrg# libtool_parse_options [ARG]... 2551e4da38afSmrg# --------------------------------- 2552e4da38afSmrg# Provide handling for libtool specific options. 2553e4da38afSmrglibtool_parse_options () 2554bd3a1963Smrg{ 2555e4da38afSmrg $debug_cmd 2556fc27e79cSmrg 2557370b807fSmrg _G_rc_lt_parse_options=false 2558370b807fSmrg 2559e4da38afSmrg # Perform our own loop to consume as many options as possible in 2560e4da38afSmrg # each iteration. 2561e4da38afSmrg while test $# -gt 0; do 2562370b807fSmrg _G_match_lt_parse_options=: 2563e4da38afSmrg _G_opt=$1 2564e4da38afSmrg shift 2565e4da38afSmrg case $_G_opt in 2566e4da38afSmrg --dry-run|--dryrun|-n) 2567e4da38afSmrg opt_dry_run=: 2568e4da38afSmrg ;; 2569e4da38afSmrg 2570e4da38afSmrg --config) func_config ;; 2571e4da38afSmrg 2572e4da38afSmrg --dlopen|-dlopen) 2573e4da38afSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 2574e4da38afSmrg}$1" 2575e4da38afSmrg shift 2576e4da38afSmrg ;; 2577e4da38afSmrg 2578e4da38afSmrg --preserve-dup-deps) 2579e4da38afSmrg opt_preserve_dup_deps=: ;; 2580e4da38afSmrg 2581e4da38afSmrg --features) func_features ;; 2582e4da38afSmrg 2583e4da38afSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2584e4da38afSmrg 2585e4da38afSmrg --help) opt_help=: ;; 2586e4da38afSmrg 2587e4da38afSmrg --help-all) opt_help=': help-all' ;; 2588e4da38afSmrg 2589e4da38afSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 2590e4da38afSmrg opt_mode=$1 2591e4da38afSmrg case $1 in 2592e4da38afSmrg # Valid mode arguments: 2593e4da38afSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 2594e4da38afSmrg 2595e4da38afSmrg # Catch anything else as an error 2596e4da38afSmrg *) func_error "invalid argument for $_G_opt" 2597e4da38afSmrg exit_cmd=exit 2598e4da38afSmrg break 2599e4da38afSmrg ;; 2600e4da38afSmrg esac 2601e4da38afSmrg shift 2602e4da38afSmrg ;; 2603e4da38afSmrg 2604e4da38afSmrg --no-silent|--no-quiet) 2605e4da38afSmrg opt_quiet=false 2606e4da38afSmrg func_append preserve_args " $_G_opt" 2607e4da38afSmrg ;; 2608e4da38afSmrg 2609e4da38afSmrg --no-warnings|--no-warning|--no-warn) 2610e4da38afSmrg opt_warning=false 2611e4da38afSmrg func_append preserve_args " $_G_opt" 2612e4da38afSmrg ;; 2613e4da38afSmrg 2614e4da38afSmrg --no-verbose) 2615e4da38afSmrg opt_verbose=false 2616e4da38afSmrg func_append preserve_args " $_G_opt" 2617e4da38afSmrg ;; 2618e4da38afSmrg 2619e4da38afSmrg --silent|--quiet) 2620e4da38afSmrg opt_quiet=: 2621e4da38afSmrg opt_verbose=false 2622e4da38afSmrg func_append preserve_args " $_G_opt" 2623e4da38afSmrg ;; 2624e4da38afSmrg 2625e4da38afSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 2626e4da38afSmrg opt_tag=$1 2627e4da38afSmrg func_append preserve_args " $_G_opt $1" 2628e4da38afSmrg func_enable_tag "$1" 2629e4da38afSmrg shift 2630e4da38afSmrg ;; 2631e4da38afSmrg 2632e4da38afSmrg --verbose|-v) opt_quiet=false 2633e4da38afSmrg opt_verbose=: 2634e4da38afSmrg func_append preserve_args " $_G_opt" 2635e4da38afSmrg ;; 2636e4da38afSmrg 2637370b807fSmrg # An option not handled by this hook function: 2638370b807fSmrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 2639370b807fSmrg _G_match_lt_parse_options=false 2640370b807fSmrg break 2641370b807fSmrg ;; 2642e4da38afSmrg esac 2643370b807fSmrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 2644e4da38afSmrg done 2645bd3a1963Smrg 2646370b807fSmrg if $_G_rc_lt_parse_options; then 2647370b807fSmrg # save modified positional parameters for caller 2648370b807fSmrg func_quote eval ${1+"$@"} 2649370b807fSmrg libtool_parse_options_result=$func_quote_result 2650370b807fSmrg fi 2651e4da38afSmrg} 2652e4da38afSmrgfunc_add_hook func_parse_options libtool_parse_options 2653fc27e79cSmrg 2654659607e0Smrg 2655fc27e79cSmrg 2656e4da38afSmrg# libtool_validate_options [ARG]... 2657e4da38afSmrg# --------------------------------- 2658e4da38afSmrg# Perform any sanity checks on option settings and/or unconsumed 2659e4da38afSmrg# arguments. 2660e4da38afSmrglibtool_validate_options () 2661e4da38afSmrg{ 2662e4da38afSmrg # save first non-option argument 2663e4da38afSmrg if test 0 -lt $#; then 2664e4da38afSmrg nonopt=$1 2665e4da38afSmrg shift 2666fc27e79cSmrg fi 2667fc27e79cSmrg 2668e4da38afSmrg # preserve --debug 2669e4da38afSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2670fc27e79cSmrg 2671e4da38afSmrg case $host in 2672e4da38afSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2673e4da38afSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2674e4da38afSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2675e4da38afSmrg # don't eliminate duplications in $postdeps and $predeps 2676e4da38afSmrg opt_duplicate_compiler_generated_deps=: 2677e4da38afSmrg ;; 2678e4da38afSmrg *) 2679e4da38afSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2680e4da38afSmrg ;; 2681e4da38afSmrg esac 2682659607e0Smrg 2683e4da38afSmrg $opt_help || { 2684e4da38afSmrg # Sanity checks first: 2685e4da38afSmrg func_check_version_match 2686e4da38afSmrg 2687e4da38afSmrg test yes != "$build_libtool_libs" \ 2688e4da38afSmrg && test yes != "$build_old_libs" \ 2689e4da38afSmrg && func_fatal_configuration "not configured to build any kind of library" 2690e4da38afSmrg 2691e4da38afSmrg # Darwin sucks 2692e4da38afSmrg eval std_shrext=\"$shrext_cmds\" 2693e4da38afSmrg 2694e4da38afSmrg # Only execute mode is allowed to have -dlopen flags. 2695e4da38afSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2696e4da38afSmrg func_error "unrecognized option '-dlopen'" 2697e4da38afSmrg $ECHO "$help" 1>&2 2698e4da38afSmrg exit $EXIT_FAILURE 2699e4da38afSmrg fi 2700fc27e79cSmrg 2701e4da38afSmrg # Change the help message to a mode-specific one. 2702e4da38afSmrg generic_help=$help 2703e4da38afSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 2704e4da38afSmrg } 2705fc27e79cSmrg 2706e4da38afSmrg # Pass back the unparsed argument list 2707370b807fSmrg func_quote eval ${1+"$@"} 2708370b807fSmrg libtool_validate_options_result=$func_quote_result 2709bd3a1963Smrg} 2710e4da38afSmrgfunc_add_hook func_validate_options libtool_validate_options 2711fc27e79cSmrg 2712fc27e79cSmrg 2713e4da38afSmrg# Process options as early as possible so that --help and --version 2714e4da38afSmrg# can return quickly. 2715e4da38afSmrgfunc_options ${1+"$@"} 2716e4da38afSmrgeval set dummy "$func_options_result"; shift 2717e4da38afSmrg 2718659607e0Smrg 2719659607e0Smrg 2720bd3a1963Smrg## ----------- ## 2721bd3a1963Smrg## Main. ## 2722bd3a1963Smrg## ----------- ## 2723659607e0Smrg 2724e4da38afSmrgmagic='%%%MAGIC variable%%%' 2725e4da38afSmrgmagic_exe='%%%MAGIC EXE variable%%%' 2726e4da38afSmrg 2727e4da38afSmrg# Global variables. 2728e4da38afSmrgextracted_archives= 2729e4da38afSmrgextracted_serial=0 2730e4da38afSmrg 2731e4da38afSmrg# If this variable is set in any of the actions, the command in it 2732e4da38afSmrg# will be execed at the end. This prevents here-documents from being 2733e4da38afSmrg# left over by shells. 2734e4da38afSmrgexec_cmd= 2735e4da38afSmrg 2736e4da38afSmrg 2737e4da38afSmrg# A function that is used when there is no print builtin or printf. 2738e4da38afSmrgfunc_fallback_echo () 2739e4da38afSmrg{ 2740e4da38afSmrg eval 'cat <<_LTECHO_EOF 2741e4da38afSmrg$1 2742e4da38afSmrg_LTECHO_EOF' 2743e4da38afSmrg} 2744e4da38afSmrg 2745e4da38afSmrg# func_generated_by_libtool 2746e4da38afSmrg# True iff stdin has been generated by Libtool. This function is only 2747e4da38afSmrg# a basic sanity check; it will hardly flush out determined imposters. 2748e4da38afSmrgfunc_generated_by_libtool_p () 2749e4da38afSmrg{ 2750e4da38afSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2751e4da38afSmrg} 2752e4da38afSmrg 2753fc27e79cSmrg# func_lalib_p file 2754e4da38afSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2755fc27e79cSmrg# This function is only a basic sanity check; it will hardly flush out 2756fc27e79cSmrg# determined imposters. 2757fc27e79cSmrgfunc_lalib_p () 2758fc27e79cSmrg{ 2759fc27e79cSmrg test -f "$1" && 2760e4da38afSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2761fc27e79cSmrg} 2762659607e0Smrg 2763fc27e79cSmrg# func_lalib_unsafe_p file 2764e4da38afSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2765fc27e79cSmrg# This function implements the same check as func_lalib_p without 2766fc27e79cSmrg# resorting to external programs. To this end, it redirects stdin and 2767fc27e79cSmrg# closes it afterwards, without saving the original file descriptor. 2768fc27e79cSmrg# As a safety measure, use it only where a negative result would be 2769e4da38afSmrg# fatal anyway. Works if 'file' does not exist. 2770fc27e79cSmrgfunc_lalib_unsafe_p () 2771fc27e79cSmrg{ 2772fc27e79cSmrg lalib_p=no 2773fc27e79cSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2774fc27e79cSmrg for lalib_p_l in 1 2 3 4 2775fc27e79cSmrg do 2776fc27e79cSmrg read lalib_p_line 2777e4da38afSmrg case $lalib_p_line in 2778fc27e79cSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2779fc27e79cSmrg esac 2780fc27e79cSmrg done 2781fc27e79cSmrg exec 0<&5 5<&- 2782fc27e79cSmrg fi 2783e4da38afSmrg test yes = "$lalib_p" 2784fc27e79cSmrg} 2785659607e0Smrg 2786fc27e79cSmrg# func_ltwrapper_script_p file 2787fc27e79cSmrg# True iff FILE is a libtool wrapper script 2788fc27e79cSmrg# This function is only a basic sanity check; it will hardly flush out 2789fc27e79cSmrg# determined imposters. 2790fc27e79cSmrgfunc_ltwrapper_script_p () 2791fc27e79cSmrg{ 2792e4da38afSmrg test -f "$1" && 2793e4da38afSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2794fc27e79cSmrg} 2795659607e0Smrg 2796fc27e79cSmrg# func_ltwrapper_executable_p file 2797fc27e79cSmrg# True iff FILE is a libtool wrapper executable 2798fc27e79cSmrg# This function is only a basic sanity check; it will hardly flush out 2799fc27e79cSmrg# determined imposters. 2800fc27e79cSmrgfunc_ltwrapper_executable_p () 2801fc27e79cSmrg{ 2802fc27e79cSmrg func_ltwrapper_exec_suffix= 2803fc27e79cSmrg case $1 in 2804fc27e79cSmrg *.exe) ;; 2805fc27e79cSmrg *) func_ltwrapper_exec_suffix=.exe ;; 2806fc27e79cSmrg esac 2807fc27e79cSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2808fc27e79cSmrg} 2809659607e0Smrg 2810fc27e79cSmrg# func_ltwrapper_scriptname file 2811fc27e79cSmrg# Assumes file is an ltwrapper_executable 2812fc27e79cSmrg# uses $file to determine the appropriate filename for a 2813fc27e79cSmrg# temporary ltwrapper_script. 2814fc27e79cSmrgfunc_ltwrapper_scriptname () 2815fc27e79cSmrg{ 2816bd3a1963Smrg func_dirname_and_basename "$1" "" "." 2817bd3a1963Smrg func_stripname '' '.exe' "$func_basename_result" 2818e4da38afSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2819fc27e79cSmrg} 2820659607e0Smrg 2821fc27e79cSmrg# func_ltwrapper_p file 2822fc27e79cSmrg# True iff FILE is a libtool wrapper script or wrapper executable 2823fc27e79cSmrg# This function is only a basic sanity check; it will hardly flush out 2824fc27e79cSmrg# determined imposters. 2825fc27e79cSmrgfunc_ltwrapper_p () 2826fc27e79cSmrg{ 2827fc27e79cSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2828fc27e79cSmrg} 2829659607e0Smrg 2830659607e0Smrg 2831fc27e79cSmrg# func_execute_cmds commands fail_cmd 2832fc27e79cSmrg# Execute tilde-delimited COMMANDS. 2833fc27e79cSmrg# If FAIL_CMD is given, eval that upon failure. 2834fc27e79cSmrg# FAIL_CMD may read-access the current command in variable CMD! 2835fc27e79cSmrgfunc_execute_cmds () 2836fc27e79cSmrg{ 2837e4da38afSmrg $debug_cmd 2838e4da38afSmrg 2839fc27e79cSmrg save_ifs=$IFS; IFS='~' 2840fc27e79cSmrg for cmd in $1; do 2841e4da38afSmrg IFS=$sp$nl 2842fc27e79cSmrg eval cmd=\"$cmd\" 2843e4da38afSmrg IFS=$save_ifs 2844fc27e79cSmrg func_show_eval "$cmd" "${2-:}" 2845fc27e79cSmrg done 2846fc27e79cSmrg IFS=$save_ifs 2847fc27e79cSmrg} 2848fc27e79cSmrg 2849fc27e79cSmrg 2850fc27e79cSmrg# func_source file 2851fc27e79cSmrg# Source FILE, adding directory component if necessary. 2852fc27e79cSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 2853fc27e79cSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2854fc27e79cSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 2855e4da38afSmrg# 'FILE.' does not work on cygwin managed mounts. 2856fc27e79cSmrgfunc_source () 2857fc27e79cSmrg{ 2858e4da38afSmrg $debug_cmd 2859e4da38afSmrg 2860fc27e79cSmrg case $1 in 2861fc27e79cSmrg */* | *\\*) . "$1" ;; 2862fc27e79cSmrg *) . "./$1" ;; 2863fc27e79cSmrg esac 2864fc27e79cSmrg} 2865fc27e79cSmrg 2866fc27e79cSmrg 2867bd3a1963Smrg# func_resolve_sysroot PATH 2868bd3a1963Smrg# Replace a leading = in PATH with a sysroot. Store the result into 2869bd3a1963Smrg# func_resolve_sysroot_result 2870bd3a1963Smrgfunc_resolve_sysroot () 2871bd3a1963Smrg{ 2872bd3a1963Smrg func_resolve_sysroot_result=$1 2873bd3a1963Smrg case $func_resolve_sysroot_result in 2874bd3a1963Smrg =*) 2875bd3a1963Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 2876bd3a1963Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2877bd3a1963Smrg ;; 2878bd3a1963Smrg esac 2879bd3a1963Smrg} 2880bd3a1963Smrg 2881bd3a1963Smrg# func_replace_sysroot PATH 2882bd3a1963Smrg# If PATH begins with the sysroot, replace it with = and 2883bd3a1963Smrg# store the result into func_replace_sysroot_result. 2884bd3a1963Smrgfunc_replace_sysroot () 2885bd3a1963Smrg{ 2886e4da38afSmrg case $lt_sysroot:$1 in 2887bd3a1963Smrg ?*:"$lt_sysroot"*) 2888bd3a1963Smrg func_stripname "$lt_sysroot" '' "$1" 2889e4da38afSmrg func_replace_sysroot_result='='$func_stripname_result 2890bd3a1963Smrg ;; 2891bd3a1963Smrg *) 2892bd3a1963Smrg # Including no sysroot. 2893bd3a1963Smrg func_replace_sysroot_result=$1 2894bd3a1963Smrg ;; 2895bd3a1963Smrg esac 2896bd3a1963Smrg} 2897bd3a1963Smrg 2898fc27e79cSmrg# func_infer_tag arg 2899fc27e79cSmrg# Infer tagged configuration to use if any are available and 2900fc27e79cSmrg# if one wasn't chosen via the "--tag" command line option. 2901fc27e79cSmrg# Only attempt this if the compiler in the base compile 2902fc27e79cSmrg# command doesn't match the default compiler. 2903fc27e79cSmrg# arg is usually of the form 'gcc ...' 2904fc27e79cSmrgfunc_infer_tag () 2905fc27e79cSmrg{ 2906e4da38afSmrg $debug_cmd 2907e4da38afSmrg 2908fc27e79cSmrg if test -n "$available_tags" && test -z "$tagname"; then 2909fc27e79cSmrg CC_quoted= 2910fc27e79cSmrg for arg in $CC; do 2911bd3a1963Smrg func_append_quoted CC_quoted "$arg" 2912fc27e79cSmrg done 2913bd3a1963Smrg CC_expanded=`func_echo_all $CC` 2914bd3a1963Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2915fc27e79cSmrg case $@ in 2916fc27e79cSmrg # Blanks in the command may have been stripped by the calling shell, 2917fc27e79cSmrg # but not from the CC environment variable when configure was run. 2918bd3a1963Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2919bd3a1963Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2920fc27e79cSmrg # Blanks at the start of $base_compile will cause this to fail 2921fc27e79cSmrg # if we don't check for them as well. 2922fc27e79cSmrg *) 2923fc27e79cSmrg for z in $available_tags; do 2924fc27e79cSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2925fc27e79cSmrg # Evaluate the configuration. 2926e4da38afSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2927fc27e79cSmrg CC_quoted= 2928fc27e79cSmrg for arg in $CC; do 2929fc27e79cSmrg # Double-quote args containing other shell metacharacters. 2930bd3a1963Smrg func_append_quoted CC_quoted "$arg" 2931fc27e79cSmrg done 2932bd3a1963Smrg CC_expanded=`func_echo_all $CC` 2933bd3a1963Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2934fc27e79cSmrg case "$@ " in 2935bd3a1963Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2936bd3a1963Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2937fc27e79cSmrg # The compiler in the base compile command matches 2938fc27e79cSmrg # the one in the tagged configuration. 2939fc27e79cSmrg # Assume this is the tagged configuration we want. 2940fc27e79cSmrg tagname=$z 2941fc27e79cSmrg break 2942fc27e79cSmrg ;; 2943659607e0Smrg esac 2944fc27e79cSmrg fi 2945fc27e79cSmrg done 2946fc27e79cSmrg # If $tagname still isn't set, then no tagged configuration 2947fc27e79cSmrg # was found and let the user know that the "--tag" command 2948fc27e79cSmrg # line option must be used. 2949fc27e79cSmrg if test -z "$tagname"; then 2950fc27e79cSmrg func_echo "unable to infer tagged configuration" 2951e4da38afSmrg func_fatal_error "specify a tag with '--tag'" 2952fc27e79cSmrg# else 2953fc27e79cSmrg# func_verbose "using $tagname tagged configuration" 2954fc27e79cSmrg fi 2955fc27e79cSmrg ;; 2956fc27e79cSmrg esac 2957fc27e79cSmrg fi 2958fc27e79cSmrg} 2959fc27e79cSmrg 2960fc27e79cSmrg 2961fc27e79cSmrg 2962fc27e79cSmrg# func_write_libtool_object output_name pic_name nonpic_name 2963fc27e79cSmrg# Create a libtool object file (analogous to a ".la" file), 2964fc27e79cSmrg# but don't create it if we're doing a dry run. 2965fc27e79cSmrgfunc_write_libtool_object () 2966fc27e79cSmrg{ 2967e4da38afSmrg write_libobj=$1 2968e4da38afSmrg if test yes = "$build_libtool_libs"; then 2969e4da38afSmrg write_lobj=\'$2\' 2970fc27e79cSmrg else 2971fc27e79cSmrg write_lobj=none 2972fc27e79cSmrg fi 2973fc27e79cSmrg 2974e4da38afSmrg if test yes = "$build_old_libs"; then 2975e4da38afSmrg write_oldobj=\'$3\' 2976fc27e79cSmrg else 2977fc27e79cSmrg write_oldobj=none 2978fc27e79cSmrg fi 2979fc27e79cSmrg 2980fc27e79cSmrg $opt_dry_run || { 2981fc27e79cSmrg cat >${write_libobj}T <<EOF 2982fc27e79cSmrg# $write_libobj - a libtool object file 2983e4da38afSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2984fc27e79cSmrg# 2985fc27e79cSmrg# Please DO NOT delete this file! 2986fc27e79cSmrg# It is necessary for linking the library. 2987fc27e79cSmrg 2988fc27e79cSmrg# Name of the PIC object. 2989fc27e79cSmrgpic_object=$write_lobj 2990fc27e79cSmrg 2991fc27e79cSmrg# Name of the non-PIC object 2992fc27e79cSmrgnon_pic_object=$write_oldobj 2993fc27e79cSmrg 2994fc27e79cSmrgEOF 2995e4da38afSmrg $MV "${write_libobj}T" "$write_libobj" 2996fc27e79cSmrg } 2997fc27e79cSmrg} 2998fc27e79cSmrg 2999bd3a1963Smrg 3000bd3a1963Smrg################################################## 3001bd3a1963Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 3002bd3a1963Smrg################################################## 3003bd3a1963Smrg 3004bd3a1963Smrg# func_convert_core_file_wine_to_w32 ARG 3005bd3a1963Smrg# Helper function used by file name conversion functions when $build is *nix, 3006bd3a1963Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 3007bd3a1963Smrg# correctly configured wine environment available, with the winepath program 3008bd3a1963Smrg# in $build's $PATH. 3009bd3a1963Smrg# 3010bd3a1963Smrg# ARG is the $build file name to be converted to w32 format. 3011bd3a1963Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 3012bd3a1963Smrg# be empty on error (or when ARG is empty) 3013bd3a1963Smrgfunc_convert_core_file_wine_to_w32 () 3014bd3a1963Smrg{ 3015e4da38afSmrg $debug_cmd 3016e4da38afSmrg 3017e4da38afSmrg func_convert_core_file_wine_to_w32_result=$1 3018bd3a1963Smrg if test -n "$1"; then 3019bd3a1963Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 3020bd3a1963Smrg # are forced to check the contents of stdout. On the other hand, if the 3021bd3a1963Smrg # command is not found, the shell will set an exit code of 127 and print 3022bd3a1963Smrg # *an error message* to stdout. So we must check for both error code of 3023bd3a1963Smrg # zero AND non-empty stdout, which explains the odd construction: 3024bd3a1963Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 3025e4da38afSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 3026bd3a1963Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 3027e4da38afSmrg $SED -e "$sed_naive_backslashify"` 3028bd3a1963Smrg else 3029bd3a1963Smrg func_convert_core_file_wine_to_w32_result= 3030bd3a1963Smrg fi 3031bd3a1963Smrg fi 3032bd3a1963Smrg} 3033bd3a1963Smrg# end: func_convert_core_file_wine_to_w32 3034bd3a1963Smrg 3035bd3a1963Smrg 3036bd3a1963Smrg# func_convert_core_path_wine_to_w32 ARG 3037bd3a1963Smrg# Helper function used by path conversion functions when $build is *nix, and 3038bd3a1963Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 3039bd3a1963Smrg# configured wine environment available, with the winepath program in $build's 3040bd3a1963Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 3041bd3a1963Smrg# 3042bd3a1963Smrg# ARG is path to be converted from $build format to win32. 3043bd3a1963Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 3044bd3a1963Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 3045bd3a1963Smrg# are convertible, then the result may be empty. 3046bd3a1963Smrgfunc_convert_core_path_wine_to_w32 () 3047bd3a1963Smrg{ 3048e4da38afSmrg $debug_cmd 3049e4da38afSmrg 3050bd3a1963Smrg # unfortunately, winepath doesn't convert paths, only file names 3051e4da38afSmrg func_convert_core_path_wine_to_w32_result= 3052bd3a1963Smrg if test -n "$1"; then 3053bd3a1963Smrg oldIFS=$IFS 3054bd3a1963Smrg IFS=: 3055bd3a1963Smrg for func_convert_core_path_wine_to_w32_f in $1; do 3056bd3a1963Smrg IFS=$oldIFS 3057bd3a1963Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 3058e4da38afSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 3059bd3a1963Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 3060e4da38afSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 3061bd3a1963Smrg else 3062bd3a1963Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 3063bd3a1963Smrg fi 3064bd3a1963Smrg fi 3065bd3a1963Smrg done 3066bd3a1963Smrg IFS=$oldIFS 3067bd3a1963Smrg fi 3068bd3a1963Smrg} 3069bd3a1963Smrg# end: func_convert_core_path_wine_to_w32 3070bd3a1963Smrg 3071bd3a1963Smrg 3072bd3a1963Smrg# func_cygpath ARGS... 3073bd3a1963Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 3074bd3a1963Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 3075bd3a1963Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 3076bd3a1963Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 3077bd3a1963Smrg# file name or path is assumed to be in w32 format, as previously converted 3078bd3a1963Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 3079bd3a1963Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 3080bd3a1963Smrg# Cygwin format). Returns an empty string on error. 3081bd3a1963Smrg# 3082bd3a1963Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 3083bd3a1963Smrg# be converted. 3084bd3a1963Smrg# 3085bd3a1963Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 3086bd3a1963Smrg# environment variable; do not put it in $PATH. 3087bd3a1963Smrgfunc_cygpath () 3088bd3a1963Smrg{ 3089e4da38afSmrg $debug_cmd 3090e4da38afSmrg 3091bd3a1963Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 3092bd3a1963Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 3093bd3a1963Smrg if test "$?" -ne 0; then 3094bd3a1963Smrg # on failure, ensure result is empty 3095bd3a1963Smrg func_cygpath_result= 3096bd3a1963Smrg fi 3097bd3a1963Smrg else 3098bd3a1963Smrg func_cygpath_result= 3099e4da38afSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 3100bd3a1963Smrg fi 3101bd3a1963Smrg} 3102bd3a1963Smrg#end: func_cygpath 3103bd3a1963Smrg 3104bd3a1963Smrg 3105bd3a1963Smrg# func_convert_core_msys_to_w32 ARG 3106bd3a1963Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 3107bd3a1963Smrg# result in func_convert_core_msys_to_w32_result. 3108bd3a1963Smrgfunc_convert_core_msys_to_w32 () 3109bd3a1963Smrg{ 3110e4da38afSmrg $debug_cmd 3111e4da38afSmrg 3112bd3a1963Smrg # awkward: cmd appends spaces to result 3113bd3a1963Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 3114e4da38afSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 3115bd3a1963Smrg} 3116bd3a1963Smrg#end: func_convert_core_msys_to_w32 3117bd3a1963Smrg 3118bd3a1963Smrg 3119bd3a1963Smrg# func_convert_file_check ARG1 ARG2 3120bd3a1963Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 3121bd3a1963Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 3122bd3a1963Smrg# func_to_host_file_result to ARG1). 3123bd3a1963Smrgfunc_convert_file_check () 3124bd3a1963Smrg{ 3125e4da38afSmrg $debug_cmd 3126e4da38afSmrg 3127e4da38afSmrg if test -z "$2" && test -n "$1"; then 3128bd3a1963Smrg func_error "Could not determine host file name corresponding to" 3129e4da38afSmrg func_error " '$1'" 3130bd3a1963Smrg func_error "Continuing, but uninstalled executables may not work." 3131bd3a1963Smrg # Fallback: 3132e4da38afSmrg func_to_host_file_result=$1 3133bd3a1963Smrg fi 3134bd3a1963Smrg} 3135bd3a1963Smrg# end func_convert_file_check 3136bd3a1963Smrg 3137bd3a1963Smrg 3138bd3a1963Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 3139bd3a1963Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 3140bd3a1963Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 3141bd3a1963Smrg# func_to_host_file_result to a simplistic fallback value (see below). 3142bd3a1963Smrgfunc_convert_path_check () 3143bd3a1963Smrg{ 3144e4da38afSmrg $debug_cmd 3145e4da38afSmrg 3146bd3a1963Smrg if test -z "$4" && test -n "$3"; then 3147bd3a1963Smrg func_error "Could not determine the host path corresponding to" 3148e4da38afSmrg func_error " '$3'" 3149bd3a1963Smrg func_error "Continuing, but uninstalled executables may not work." 3150bd3a1963Smrg # Fallback. This is a deliberately simplistic "conversion" and 3151bd3a1963Smrg # should not be "improved". See libtool.info. 3152bd3a1963Smrg if test "x$1" != "x$2"; then 3153bd3a1963Smrg lt_replace_pathsep_chars="s|$1|$2|g" 3154bd3a1963Smrg func_to_host_path_result=`echo "$3" | 3155bd3a1963Smrg $SED -e "$lt_replace_pathsep_chars"` 3156bd3a1963Smrg else 3157e4da38afSmrg func_to_host_path_result=$3 3158bd3a1963Smrg fi 3159bd3a1963Smrg fi 3160bd3a1963Smrg} 3161bd3a1963Smrg# end func_convert_path_check 3162bd3a1963Smrg 3163bd3a1963Smrg 3164bd3a1963Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 3165bd3a1963Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 3166bd3a1963Smrg# and appending REPL if ORIG matches BACKPAT. 3167bd3a1963Smrgfunc_convert_path_front_back_pathsep () 3168bd3a1963Smrg{ 3169e4da38afSmrg $debug_cmd 3170e4da38afSmrg 3171bd3a1963Smrg case $4 in 3172e4da38afSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 3173bd3a1963Smrg ;; 3174bd3a1963Smrg esac 3175bd3a1963Smrg case $4 in 3176bd3a1963Smrg $2 ) func_append func_to_host_path_result "$3" 3177bd3a1963Smrg ;; 3178bd3a1963Smrg esac 3179bd3a1963Smrg} 3180bd3a1963Smrg# end func_convert_path_front_back_pathsep 3181bd3a1963Smrg 3182bd3a1963Smrg 3183bd3a1963Smrg################################################## 3184bd3a1963Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 3185bd3a1963Smrg################################################## 3186e4da38afSmrg# invoked via '$to_host_file_cmd ARG' 3187bd3a1963Smrg# 3188bd3a1963Smrg# In each case, ARG is the path to be converted from $build to $host format. 3189bd3a1963Smrg# Result will be available in $func_to_host_file_result. 3190bd3a1963Smrg 3191bd3a1963Smrg 3192bd3a1963Smrg# func_to_host_file ARG 3193bd3a1963Smrg# Converts the file name ARG from $build format to $host format. Return result 3194bd3a1963Smrg# in func_to_host_file_result. 3195bd3a1963Smrgfunc_to_host_file () 3196bd3a1963Smrg{ 3197e4da38afSmrg $debug_cmd 3198e4da38afSmrg 3199bd3a1963Smrg $to_host_file_cmd "$1" 3200bd3a1963Smrg} 3201bd3a1963Smrg# end func_to_host_file 3202bd3a1963Smrg 3203bd3a1963Smrg 3204bd3a1963Smrg# func_to_tool_file ARG LAZY 3205bd3a1963Smrg# converts the file name ARG from $build format to toolchain format. Return 3206bd3a1963Smrg# result in func_to_tool_file_result. If the conversion in use is listed 3207bd3a1963Smrg# in (the comma separated) LAZY, no conversion takes place. 3208bd3a1963Smrgfunc_to_tool_file () 3209bd3a1963Smrg{ 3210e4da38afSmrg $debug_cmd 3211e4da38afSmrg 3212bd3a1963Smrg case ,$2, in 3213bd3a1963Smrg *,"$to_tool_file_cmd",*) 3214bd3a1963Smrg func_to_tool_file_result=$1 3215bd3a1963Smrg ;; 3216bd3a1963Smrg *) 3217bd3a1963Smrg $to_tool_file_cmd "$1" 3218bd3a1963Smrg func_to_tool_file_result=$func_to_host_file_result 3219bd3a1963Smrg ;; 3220bd3a1963Smrg esac 3221bd3a1963Smrg} 3222bd3a1963Smrg# end func_to_tool_file 3223bd3a1963Smrg 3224bd3a1963Smrg 3225bd3a1963Smrg# func_convert_file_noop ARG 3226bd3a1963Smrg# Copy ARG to func_to_host_file_result. 3227bd3a1963Smrgfunc_convert_file_noop () 3228bd3a1963Smrg{ 3229e4da38afSmrg func_to_host_file_result=$1 3230bd3a1963Smrg} 3231bd3a1963Smrg# end func_convert_file_noop 3232bd3a1963Smrg 3233bd3a1963Smrg 3234bd3a1963Smrg# func_convert_file_msys_to_w32 ARG 3235bd3a1963Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 3236bd3a1963Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 3237bd3a1963Smrg# func_to_host_file_result. 3238bd3a1963Smrgfunc_convert_file_msys_to_w32 () 3239bd3a1963Smrg{ 3240e4da38afSmrg $debug_cmd 3241e4da38afSmrg 3242e4da38afSmrg func_to_host_file_result=$1 3243bd3a1963Smrg if test -n "$1"; then 3244bd3a1963Smrg func_convert_core_msys_to_w32 "$1" 3245e4da38afSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 3246bd3a1963Smrg fi 3247bd3a1963Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3248bd3a1963Smrg} 3249bd3a1963Smrg# end func_convert_file_msys_to_w32 3250bd3a1963Smrg 3251bd3a1963Smrg 3252bd3a1963Smrg# func_convert_file_cygwin_to_w32 ARG 3253bd3a1963Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3254bd3a1963Smrg# func_to_host_file_result. 3255bd3a1963Smrgfunc_convert_file_cygwin_to_w32 () 3256bd3a1963Smrg{ 3257e4da38afSmrg $debug_cmd 3258e4da38afSmrg 3259e4da38afSmrg func_to_host_file_result=$1 3260bd3a1963Smrg if test -n "$1"; then 3261bd3a1963Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3262bd3a1963Smrg # LT_CYGPATH in this case. 3263bd3a1963Smrg func_to_host_file_result=`cygpath -m "$1"` 3264bd3a1963Smrg fi 3265bd3a1963Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3266bd3a1963Smrg} 3267bd3a1963Smrg# end func_convert_file_cygwin_to_w32 3268bd3a1963Smrg 3269bd3a1963Smrg 3270bd3a1963Smrg# func_convert_file_nix_to_w32 ARG 3271bd3a1963Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3272bd3a1963Smrg# and a working winepath. Returns result in func_to_host_file_result. 3273bd3a1963Smrgfunc_convert_file_nix_to_w32 () 3274bd3a1963Smrg{ 3275e4da38afSmrg $debug_cmd 3276e4da38afSmrg 3277e4da38afSmrg func_to_host_file_result=$1 3278bd3a1963Smrg if test -n "$1"; then 3279bd3a1963Smrg func_convert_core_file_wine_to_w32 "$1" 3280e4da38afSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3281bd3a1963Smrg fi 3282bd3a1963Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3283bd3a1963Smrg} 3284bd3a1963Smrg# end func_convert_file_nix_to_w32 3285bd3a1963Smrg 3286bd3a1963Smrg 3287bd3a1963Smrg# func_convert_file_msys_to_cygwin ARG 3288bd3a1963Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3289bd3a1963Smrg# Returns result in func_to_host_file_result. 3290bd3a1963Smrgfunc_convert_file_msys_to_cygwin () 3291bd3a1963Smrg{ 3292e4da38afSmrg $debug_cmd 3293e4da38afSmrg 3294e4da38afSmrg func_to_host_file_result=$1 3295bd3a1963Smrg if test -n "$1"; then 3296bd3a1963Smrg func_convert_core_msys_to_w32 "$1" 3297bd3a1963Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 3298e4da38afSmrg func_to_host_file_result=$func_cygpath_result 3299bd3a1963Smrg fi 3300bd3a1963Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3301bd3a1963Smrg} 3302bd3a1963Smrg# end func_convert_file_msys_to_cygwin 3303bd3a1963Smrg 3304bd3a1963Smrg 3305bd3a1963Smrg# func_convert_file_nix_to_cygwin ARG 3306bd3a1963Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3307bd3a1963Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3308bd3a1963Smrg# in func_to_host_file_result. 3309bd3a1963Smrgfunc_convert_file_nix_to_cygwin () 3310bd3a1963Smrg{ 3311e4da38afSmrg $debug_cmd 3312e4da38afSmrg 3313e4da38afSmrg func_to_host_file_result=$1 3314bd3a1963Smrg if test -n "$1"; then 3315bd3a1963Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3316bd3a1963Smrg func_convert_core_file_wine_to_w32 "$1" 3317bd3a1963Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3318e4da38afSmrg func_to_host_file_result=$func_cygpath_result 3319bd3a1963Smrg fi 3320bd3a1963Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3321bd3a1963Smrg} 3322bd3a1963Smrg# end func_convert_file_nix_to_cygwin 3323bd3a1963Smrg 3324bd3a1963Smrg 3325bd3a1963Smrg############################################# 3326bd3a1963Smrg# $build to $host PATH CONVERSION FUNCTIONS # 3327bd3a1963Smrg############################################# 3328e4da38afSmrg# invoked via '$to_host_path_cmd ARG' 3329bd3a1963Smrg# 3330bd3a1963Smrg# In each case, ARG is the path to be converted from $build to $host format. 3331bd3a1963Smrg# The result will be available in $func_to_host_path_result. 3332bd3a1963Smrg# 3333bd3a1963Smrg# Path separators are also converted from $build format to $host format. If 3334bd3a1963Smrg# ARG begins or ends with a path separator character, it is preserved (but 3335bd3a1963Smrg# converted to $host format) on output. 3336bd3a1963Smrg# 3337bd3a1963Smrg# All path conversion functions are named using the following convention: 3338bd3a1963Smrg# file name conversion function : func_convert_file_X_to_Y () 3339bd3a1963Smrg# path conversion function : func_convert_path_X_to_Y () 3340bd3a1963Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3341bd3a1963Smrg# same. If conversion functions are added for new $build/$host combinations, 3342bd3a1963Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3343bd3a1963Smrg# will break. 3344bd3a1963Smrg 3345bd3a1963Smrg 3346bd3a1963Smrg# func_init_to_host_path_cmd 3347bd3a1963Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3348bd3a1963Smrg# appropriate value, based on the value of $to_host_file_cmd. 3349bd3a1963Smrgto_host_path_cmd= 3350bd3a1963Smrgfunc_init_to_host_path_cmd () 3351bd3a1963Smrg{ 3352e4da38afSmrg $debug_cmd 3353e4da38afSmrg 3354bd3a1963Smrg if test -z "$to_host_path_cmd"; then 3355bd3a1963Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3356e4da38afSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 3357bd3a1963Smrg fi 3358bd3a1963Smrg} 3359bd3a1963Smrg 3360bd3a1963Smrg 3361bd3a1963Smrg# func_to_host_path ARG 3362bd3a1963Smrg# Converts the path ARG from $build format to $host format. Return result 3363bd3a1963Smrg# in func_to_host_path_result. 3364bd3a1963Smrgfunc_to_host_path () 3365bd3a1963Smrg{ 3366e4da38afSmrg $debug_cmd 3367e4da38afSmrg 3368bd3a1963Smrg func_init_to_host_path_cmd 3369bd3a1963Smrg $to_host_path_cmd "$1" 3370bd3a1963Smrg} 3371bd3a1963Smrg# end func_to_host_path 3372bd3a1963Smrg 3373bd3a1963Smrg 3374bd3a1963Smrg# func_convert_path_noop ARG 3375bd3a1963Smrg# Copy ARG to func_to_host_path_result. 3376bd3a1963Smrgfunc_convert_path_noop () 3377bd3a1963Smrg{ 3378e4da38afSmrg func_to_host_path_result=$1 3379bd3a1963Smrg} 3380bd3a1963Smrg# end func_convert_path_noop 3381bd3a1963Smrg 3382bd3a1963Smrg 3383bd3a1963Smrg# func_convert_path_msys_to_w32 ARG 3384bd3a1963Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3385bd3a1963Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 3386bd3a1963Smrg# func_to_host_path_result. 3387bd3a1963Smrgfunc_convert_path_msys_to_w32 () 3388bd3a1963Smrg{ 3389e4da38afSmrg $debug_cmd 3390e4da38afSmrg 3391e4da38afSmrg func_to_host_path_result=$1 3392bd3a1963Smrg if test -n "$1"; then 3393bd3a1963Smrg # Remove leading and trailing path separator characters from ARG. MSYS 3394bd3a1963Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3395bd3a1963Smrg # and winepath ignores them completely. 3396bd3a1963Smrg func_stripname : : "$1" 3397bd3a1963Smrg func_to_host_path_tmp1=$func_stripname_result 3398bd3a1963Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3399e4da38afSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3400bd3a1963Smrg func_convert_path_check : ";" \ 3401bd3a1963Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3402bd3a1963Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3403bd3a1963Smrg fi 3404bd3a1963Smrg} 3405bd3a1963Smrg# end func_convert_path_msys_to_w32 3406bd3a1963Smrg 3407bd3a1963Smrg 3408bd3a1963Smrg# func_convert_path_cygwin_to_w32 ARG 3409bd3a1963Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 3410bd3a1963Smrg# func_to_host_file_result. 3411bd3a1963Smrgfunc_convert_path_cygwin_to_w32 () 3412bd3a1963Smrg{ 3413e4da38afSmrg $debug_cmd 3414e4da38afSmrg 3415e4da38afSmrg func_to_host_path_result=$1 3416bd3a1963Smrg if test -n "$1"; then 3417bd3a1963Smrg # See func_convert_path_msys_to_w32: 3418bd3a1963Smrg func_stripname : : "$1" 3419bd3a1963Smrg func_to_host_path_tmp1=$func_stripname_result 3420bd3a1963Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3421bd3a1963Smrg func_convert_path_check : ";" \ 3422bd3a1963Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3423bd3a1963Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3424bd3a1963Smrg fi 3425bd3a1963Smrg} 3426bd3a1963Smrg# end func_convert_path_cygwin_to_w32 3427bd3a1963Smrg 3428bd3a1963Smrg 3429bd3a1963Smrg# func_convert_path_nix_to_w32 ARG 3430bd3a1963Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3431bd3a1963Smrg# a working winepath. Returns result in func_to_host_file_result. 3432bd3a1963Smrgfunc_convert_path_nix_to_w32 () 3433bd3a1963Smrg{ 3434e4da38afSmrg $debug_cmd 3435e4da38afSmrg 3436e4da38afSmrg func_to_host_path_result=$1 3437bd3a1963Smrg if test -n "$1"; then 3438bd3a1963Smrg # See func_convert_path_msys_to_w32: 3439bd3a1963Smrg func_stripname : : "$1" 3440bd3a1963Smrg func_to_host_path_tmp1=$func_stripname_result 3441bd3a1963Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3442e4da38afSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3443bd3a1963Smrg func_convert_path_check : ";" \ 3444bd3a1963Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3445bd3a1963Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3446bd3a1963Smrg fi 3447bd3a1963Smrg} 3448bd3a1963Smrg# end func_convert_path_nix_to_w32 3449bd3a1963Smrg 3450bd3a1963Smrg 3451bd3a1963Smrg# func_convert_path_msys_to_cygwin ARG 3452bd3a1963Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3453bd3a1963Smrg# Returns result in func_to_host_file_result. 3454bd3a1963Smrgfunc_convert_path_msys_to_cygwin () 3455bd3a1963Smrg{ 3456e4da38afSmrg $debug_cmd 3457e4da38afSmrg 3458e4da38afSmrg func_to_host_path_result=$1 3459bd3a1963Smrg if test -n "$1"; then 3460bd3a1963Smrg # See func_convert_path_msys_to_w32: 3461bd3a1963Smrg func_stripname : : "$1" 3462bd3a1963Smrg func_to_host_path_tmp1=$func_stripname_result 3463bd3a1963Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3464bd3a1963Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3465e4da38afSmrg func_to_host_path_result=$func_cygpath_result 3466bd3a1963Smrg func_convert_path_check : : \ 3467bd3a1963Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3468bd3a1963Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3469bd3a1963Smrg fi 3470bd3a1963Smrg} 3471bd3a1963Smrg# end func_convert_path_msys_to_cygwin 3472bd3a1963Smrg 3473bd3a1963Smrg 3474bd3a1963Smrg# func_convert_path_nix_to_cygwin ARG 3475bd3a1963Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3476bd3a1963Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3477bd3a1963Smrg# func_to_host_file_result. 3478bd3a1963Smrgfunc_convert_path_nix_to_cygwin () 3479bd3a1963Smrg{ 3480e4da38afSmrg $debug_cmd 3481e4da38afSmrg 3482e4da38afSmrg func_to_host_path_result=$1 3483bd3a1963Smrg if test -n "$1"; then 3484bd3a1963Smrg # Remove leading and trailing path separator characters from 3485bd3a1963Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 3486bd3a1963Smrg # into '.;' and ';.', and winepath ignores them completely. 3487bd3a1963Smrg func_stripname : : "$1" 3488bd3a1963Smrg func_to_host_path_tmp1=$func_stripname_result 3489bd3a1963Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3490bd3a1963Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3491e4da38afSmrg func_to_host_path_result=$func_cygpath_result 3492bd3a1963Smrg func_convert_path_check : : \ 3493bd3a1963Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3494bd3a1963Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3495bd3a1963Smrg fi 3496bd3a1963Smrg} 3497bd3a1963Smrg# end func_convert_path_nix_to_cygwin 3498bd3a1963Smrg 3499bd3a1963Smrg 3500e4da38afSmrg# func_dll_def_p FILE 3501e4da38afSmrg# True iff FILE is a Windows DLL '.def' file. 3502e4da38afSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3503e4da38afSmrgfunc_dll_def_p () 3504e4da38afSmrg{ 3505e4da38afSmrg $debug_cmd 3506e4da38afSmrg 3507e4da38afSmrg func_dll_def_p_tmp=`$SED -n \ 3508e4da38afSmrg -e 's/^[ ]*//' \ 3509e4da38afSmrg -e '/^\(;.*\)*$/d' \ 3510e4da38afSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3511e4da38afSmrg -e q \ 3512e4da38afSmrg "$1"` 3513e4da38afSmrg test DEF = "$func_dll_def_p_tmp" 3514e4da38afSmrg} 3515e4da38afSmrg 3516e4da38afSmrg 3517fc27e79cSmrg# func_mode_compile arg... 3518fc27e79cSmrgfunc_mode_compile () 3519fc27e79cSmrg{ 3520e4da38afSmrg $debug_cmd 3521e4da38afSmrg 3522fc27e79cSmrg # Get the compilation command and the source file. 3523fc27e79cSmrg base_compile= 3524e4da38afSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3525fc27e79cSmrg suppress_opt=yes 3526fc27e79cSmrg suppress_output= 3527fc27e79cSmrg arg_mode=normal 3528fc27e79cSmrg libobj= 3529fc27e79cSmrg later= 3530fc27e79cSmrg pie_flag= 3531fc27e79cSmrg 3532fc27e79cSmrg for arg 3533fc27e79cSmrg do 3534fc27e79cSmrg case $arg_mode in 3535fc27e79cSmrg arg ) 3536fc27e79cSmrg # do not "continue". Instead, add this to base_compile 3537e4da38afSmrg lastarg=$arg 3538fc27e79cSmrg arg_mode=normal 3539fc27e79cSmrg ;; 3540fc27e79cSmrg 3541fc27e79cSmrg target ) 3542e4da38afSmrg libobj=$arg 3543fc27e79cSmrg arg_mode=normal 3544fc27e79cSmrg continue 3545fc27e79cSmrg ;; 3546fc27e79cSmrg 3547fc27e79cSmrg normal ) 3548fc27e79cSmrg # Accept any command-line options. 3549fc27e79cSmrg case $arg in 3550fc27e79cSmrg -o) 3551fc27e79cSmrg test -n "$libobj" && \ 3552e4da38afSmrg func_fatal_error "you cannot specify '-o' more than once" 3553fc27e79cSmrg arg_mode=target 3554fc27e79cSmrg continue 3555fc27e79cSmrg ;; 3556fc27e79cSmrg 3557fc27e79cSmrg -pie | -fpie | -fPIE) 3558bd3a1963Smrg func_append pie_flag " $arg" 3559fc27e79cSmrg continue 3560fc27e79cSmrg ;; 3561fc27e79cSmrg 3562fc27e79cSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 3563bd3a1963Smrg func_append later " $arg" 3564fc27e79cSmrg continue 3565fc27e79cSmrg ;; 3566fc27e79cSmrg 3567fc27e79cSmrg -no-suppress) 3568fc27e79cSmrg suppress_opt=no 3569fc27e79cSmrg continue 3570fc27e79cSmrg ;; 3571fc27e79cSmrg 3572fc27e79cSmrg -Xcompiler) 3573fc27e79cSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 3574fc27e79cSmrg continue # The current "srcfile" will either be retained or 3575fc27e79cSmrg ;; # replaced later. I would guess that would be a bug. 3576fc27e79cSmrg 3577fc27e79cSmrg -Wc,*) 3578fc27e79cSmrg func_stripname '-Wc,' '' "$arg" 3579fc27e79cSmrg args=$func_stripname_result 3580fc27e79cSmrg lastarg= 3581e4da38afSmrg save_ifs=$IFS; IFS=, 3582fc27e79cSmrg for arg in $args; do 3583e4da38afSmrg IFS=$save_ifs 3584bd3a1963Smrg func_append_quoted lastarg "$arg" 3585659607e0Smrg done 3586e4da38afSmrg IFS=$save_ifs 3587fc27e79cSmrg func_stripname ' ' '' "$lastarg" 3588fc27e79cSmrg lastarg=$func_stripname_result 3589659607e0Smrg 3590659607e0Smrg # Add the arguments to base_compile. 3591bd3a1963Smrg func_append base_compile " $lastarg" 3592659607e0Smrg continue 3593659607e0Smrg ;; 3594659607e0Smrg 3595fc27e79cSmrg *) 3596659607e0Smrg # Accept the current argument as the source file. 3597659607e0Smrg # The previous "srcfile" becomes the current argument. 3598659607e0Smrg # 3599e4da38afSmrg lastarg=$srcfile 3600e4da38afSmrg srcfile=$arg 3601659607e0Smrg ;; 3602659607e0Smrg esac # case $arg 3603659607e0Smrg ;; 3604659607e0Smrg esac # case $arg_mode 3605659607e0Smrg 3606659607e0Smrg # Aesthetically quote the previous argument. 3607bd3a1963Smrg func_append_quoted base_compile "$lastarg" 3608659607e0Smrg done # for arg 3609659607e0Smrg 3610659607e0Smrg case $arg_mode in 3611659607e0Smrg arg) 3612fc27e79cSmrg func_fatal_error "you must specify an argument for -Xcompile" 3613659607e0Smrg ;; 3614659607e0Smrg target) 3615e4da38afSmrg func_fatal_error "you must specify a target with '-o'" 3616659607e0Smrg ;; 3617659607e0Smrg *) 3618659607e0Smrg # Get the name of the library object. 3619fc27e79cSmrg test -z "$libobj" && { 3620fc27e79cSmrg func_basename "$srcfile" 3621e4da38afSmrg libobj=$func_basename_result 3622fc27e79cSmrg } 3623659607e0Smrg ;; 3624659607e0Smrg esac 3625659607e0Smrg 3626659607e0Smrg # Recognize several different file suffixes. 3627659607e0Smrg # If the user specifies -o file.o, it is replaced with file.lo 3628659607e0Smrg case $libobj in 3629fc27e79cSmrg *.[cCFSifmso] | \ 3630fc27e79cSmrg *.ada | *.adb | *.ads | *.asm | \ 3631fc27e79cSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3632a73597f9Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3633fc27e79cSmrg func_xform "$libobj" 3634fc27e79cSmrg libobj=$func_xform_result 3635fc27e79cSmrg ;; 3636659607e0Smrg esac 3637659607e0Smrg 3638659607e0Smrg case $libobj in 3639fc27e79cSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3640659607e0Smrg *) 3641e4da38afSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 3642659607e0Smrg ;; 3643659607e0Smrg esac 3644659607e0Smrg 3645659607e0Smrg func_infer_tag $base_compile 3646659607e0Smrg 3647659607e0Smrg for arg in $later; do 3648659607e0Smrg case $arg in 3649fc27e79cSmrg -shared) 3650e4da38afSmrg test yes = "$build_libtool_libs" \ 3651e4da38afSmrg || func_fatal_configuration "cannot build a shared library" 3652fc27e79cSmrg build_old_libs=no 3653fc27e79cSmrg continue 3654fc27e79cSmrg ;; 3655fc27e79cSmrg 3656659607e0Smrg -static) 3657fc27e79cSmrg build_libtool_libs=no 3658659607e0Smrg build_old_libs=yes 3659659607e0Smrg continue 3660659607e0Smrg ;; 3661659607e0Smrg 3662659607e0Smrg -prefer-pic) 3663659607e0Smrg pic_mode=yes 3664659607e0Smrg continue 3665659607e0Smrg ;; 3666659607e0Smrg 3667659607e0Smrg -prefer-non-pic) 3668659607e0Smrg pic_mode=no 3669659607e0Smrg continue 3670659607e0Smrg ;; 3671659607e0Smrg esac 3672659607e0Smrg done 3673659607e0Smrg 3674370b807fSmrg func_quote_arg pretty "$libobj" 3675370b807fSmrg test "X$libobj" != "X$func_quote_arg_result" \ 3676fc27e79cSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3677e4da38afSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3678fc27e79cSmrg func_dirname_and_basename "$obj" "/" "" 3679e4da38afSmrg objname=$func_basename_result 3680e4da38afSmrg xdir=$func_dirname_result 3681e4da38afSmrg lobj=$xdir$objdir/$objname 3682659607e0Smrg 3683fc27e79cSmrg test -z "$base_compile" && \ 3684fc27e79cSmrg func_fatal_help "you must specify a compilation command" 3685659607e0Smrg 3686659607e0Smrg # Delete any leftover library objects. 3687e4da38afSmrg if test yes = "$build_old_libs"; then 3688659607e0Smrg removelist="$obj $lobj $libobj ${libobj}T" 3689659607e0Smrg else 3690659607e0Smrg removelist="$lobj $libobj ${libobj}T" 3691659607e0Smrg fi 3692659607e0Smrg 3693659607e0Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 3694659607e0Smrg case $host_os in 3695fc27e79cSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3696659607e0Smrg pic_mode=default 3697659607e0Smrg ;; 3698659607e0Smrg esac 3699e4da38afSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3700659607e0Smrg # non-PIC code in shared libraries is not supported 3701659607e0Smrg pic_mode=default 3702659607e0Smrg fi 3703659607e0Smrg 3704659607e0Smrg # Calculate the filename of the output object if compiler does 3705659607e0Smrg # not support -o with -c 3706e4da38afSmrg if test no = "$compiler_c_o"; then 3707e4da38afSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3708e4da38afSmrg lockfile=$output_obj.lock 3709659607e0Smrg else 3710659607e0Smrg output_obj= 3711659607e0Smrg need_locks=no 3712659607e0Smrg lockfile= 3713659607e0Smrg fi 3714659607e0Smrg 3715659607e0Smrg # Lock this critical section if it is needed 3716659607e0Smrg # We use this script file to make the link, it avoids creating a new file 3717e4da38afSmrg if test yes = "$need_locks"; then 3718fc27e79cSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3719fc27e79cSmrg func_echo "Waiting for $lockfile to be removed" 3720659607e0Smrg sleep 2 3721659607e0Smrg done 3722e4da38afSmrg elif test warn = "$need_locks"; then 3723659607e0Smrg if test -f "$lockfile"; then 3724fc27e79cSmrg $ECHO "\ 3725659607e0Smrg*** ERROR, $lockfile exists and contains: 3726659607e0Smrg`cat $lockfile 2>/dev/null` 3727659607e0Smrg 3728659607e0SmrgThis indicates that another process is trying to use the same 3729659607e0Smrgtemporary object file, and libtool could not work around it because 3730e4da38afSmrgyour compiler does not support '-c' and '-o' together. If you 3731659607e0Smrgrepeat this compilation, it may succeed, by chance, but you had better 3732659607e0Smrgavoid parallel builds (make -j) in this platform, or get a better 3733659607e0Smrgcompiler." 3734659607e0Smrg 3735fc27e79cSmrg $opt_dry_run || $RM $removelist 3736659607e0Smrg exit $EXIT_FAILURE 3737659607e0Smrg fi 3738bd3a1963Smrg func_append removelist " $output_obj" 3739fc27e79cSmrg $ECHO "$srcfile" > "$lockfile" 3740659607e0Smrg fi 3741659607e0Smrg 3742fc27e79cSmrg $opt_dry_run || $RM $removelist 3743bd3a1963Smrg func_append removelist " $lockfile" 3744fc27e79cSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3745fc27e79cSmrg 3746bd3a1963Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3747bd3a1963Smrg srcfile=$func_to_tool_file_result 3748370b807fSmrg func_quote_arg pretty "$srcfile" 3749370b807fSmrg qsrcfile=$func_quote_arg_result 3750659607e0Smrg 3751659607e0Smrg # Only build a PIC object if we are building libtool libraries. 3752e4da38afSmrg if test yes = "$build_libtool_libs"; then 3753659607e0Smrg # Without this assignment, base_compile gets emptied. 3754659607e0Smrg fbsd_hideous_sh_bug=$base_compile 3755659607e0Smrg 3756e4da38afSmrg if test no != "$pic_mode"; then 3757659607e0Smrg command="$base_compile $qsrcfile $pic_flag" 3758659607e0Smrg else 3759659607e0Smrg # Don't build PIC code 3760659607e0Smrg command="$base_compile $qsrcfile" 3761659607e0Smrg fi 3762659607e0Smrg 3763fc27e79cSmrg func_mkdir_p "$xdir$objdir" 3764659607e0Smrg 3765659607e0Smrg if test -z "$output_obj"; then 3766659607e0Smrg # Place PIC objects in $objdir 3767bd3a1963Smrg func_append command " -o $lobj" 3768659607e0Smrg fi 3769659607e0Smrg 3770fc27e79cSmrg func_show_eval_locale "$command" \ 3771fc27e79cSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3772659607e0Smrg 3773e4da38afSmrg if test warn = "$need_locks" && 3774659607e0Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3775fc27e79cSmrg $ECHO "\ 3776659607e0Smrg*** ERROR, $lockfile contains: 3777659607e0Smrg`cat $lockfile 2>/dev/null` 3778659607e0Smrg 3779659607e0Smrgbut it should contain: 3780659607e0Smrg$srcfile 3781659607e0Smrg 3782659607e0SmrgThis indicates that another process is trying to use the same 3783659607e0Smrgtemporary object file, and libtool could not work around it because 3784e4da38afSmrgyour compiler does not support '-c' and '-o' together. If you 3785659607e0Smrgrepeat this compilation, it may succeed, by chance, but you had better 3786659607e0Smrgavoid parallel builds (make -j) in this platform, or get a better 3787659607e0Smrgcompiler." 3788659607e0Smrg 3789fc27e79cSmrg $opt_dry_run || $RM $removelist 3790659607e0Smrg exit $EXIT_FAILURE 3791659607e0Smrg fi 3792659607e0Smrg 3793659607e0Smrg # Just move the object if needed, then go on to compile the next one 3794659607e0Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3795fc27e79cSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3796fc27e79cSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3797659607e0Smrg fi 3798659607e0Smrg 3799659607e0Smrg # Allow error messages only from the first compilation. 3800e4da38afSmrg if test yes = "$suppress_opt"; then 3801fc27e79cSmrg suppress_output=' >/dev/null 2>&1' 3802659607e0Smrg fi 3803659607e0Smrg fi 3804659607e0Smrg 3805659607e0Smrg # Only build a position-dependent object if we build old libraries. 3806e4da38afSmrg if test yes = "$build_old_libs"; then 3807e4da38afSmrg if test yes != "$pic_mode"; then 3808659607e0Smrg # Don't build PIC code 3809fc27e79cSmrg command="$base_compile $qsrcfile$pie_flag" 3810659607e0Smrg else 3811659607e0Smrg command="$base_compile $qsrcfile $pic_flag" 3812659607e0Smrg fi 3813e4da38afSmrg if test yes = "$compiler_c_o"; then 3814bd3a1963Smrg func_append command " -o $obj" 3815659607e0Smrg fi 3816659607e0Smrg 3817659607e0Smrg # Suppress compiler output if we already did a PIC compilation. 3818bd3a1963Smrg func_append command "$suppress_output" 3819fc27e79cSmrg func_show_eval_locale "$command" \ 3820fc27e79cSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3821659607e0Smrg 3822e4da38afSmrg if test warn = "$need_locks" && 3823659607e0Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3824fc27e79cSmrg $ECHO "\ 3825659607e0Smrg*** ERROR, $lockfile contains: 3826659607e0Smrg`cat $lockfile 2>/dev/null` 3827659607e0Smrg 3828659607e0Smrgbut it should contain: 3829659607e0Smrg$srcfile 3830659607e0Smrg 3831659607e0SmrgThis indicates that another process is trying to use the same 3832659607e0Smrgtemporary object file, and libtool could not work around it because 3833e4da38afSmrgyour compiler does not support '-c' and '-o' together. If you 3834659607e0Smrgrepeat this compilation, it may succeed, by chance, but you had better 3835659607e0Smrgavoid parallel builds (make -j) in this platform, or get a better 3836659607e0Smrgcompiler." 3837659607e0Smrg 3838fc27e79cSmrg $opt_dry_run || $RM $removelist 3839659607e0Smrg exit $EXIT_FAILURE 3840659607e0Smrg fi 3841659607e0Smrg 3842659607e0Smrg # Just move the object if needed 3843659607e0Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3844fc27e79cSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 3845fc27e79cSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3846659607e0Smrg fi 3847659607e0Smrg fi 3848659607e0Smrg 3849fc27e79cSmrg $opt_dry_run || { 3850fc27e79cSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3851659607e0Smrg 3852fc27e79cSmrg # Unlock the critical section if it was locked 3853e4da38afSmrg if test no != "$need_locks"; then 3854fc27e79cSmrg removelist=$lockfile 3855fc27e79cSmrg $RM "$lockfile" 3856fc27e79cSmrg fi 3857fc27e79cSmrg } 3858659607e0Smrg 3859659607e0Smrg exit $EXIT_SUCCESS 3860fc27e79cSmrg} 3861659607e0Smrg 3862fc27e79cSmrg$opt_help || { 3863e4da38afSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3864fc27e79cSmrg} 3865659607e0Smrg 3866fc27e79cSmrgfunc_mode_help () 3867fc27e79cSmrg{ 3868fc27e79cSmrg # We need to display help for each of the modes. 3869bd3a1963Smrg case $opt_mode in 3870fc27e79cSmrg "") 3871fc27e79cSmrg # Generic help is extracted from the usage comments 3872fc27e79cSmrg # at the start of this file. 3873fc27e79cSmrg func_help 3874fc27e79cSmrg ;; 3875659607e0Smrg 3876fc27e79cSmrg clean) 3877fc27e79cSmrg $ECHO \ 3878fc27e79cSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3879659607e0Smrg 3880fc27e79cSmrgRemove files from the build directory. 3881659607e0Smrg 3882fc27e79cSmrgRM is the name of the program to use to delete files associated with each FILE 3883e4da38afSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3884fc27e79cSmrgto RM. 3885659607e0Smrg 3886fc27e79cSmrgIf FILE is a libtool library, object or program, all the files associated 3887fc27e79cSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3888fc27e79cSmrg ;; 3889659607e0Smrg 3890fc27e79cSmrg compile) 3891fc27e79cSmrg $ECHO \ 3892fc27e79cSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3893659607e0Smrg 3894fc27e79cSmrgCompile a source file into a libtool library object. 3895659607e0Smrg 3896fc27e79cSmrgThis mode accepts the following additional options: 3897659607e0Smrg 3898fc27e79cSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3899fc27e79cSmrg -no-suppress do not suppress compiler output for multiple passes 3900bd3a1963Smrg -prefer-pic try to build PIC objects only 3901bd3a1963Smrg -prefer-non-pic try to build non-PIC objects only 3902e4da38afSmrg -shared do not build a '.o' file suitable for static linking 3903e4da38afSmrg -static only build a '.o' file suitable for static linking 3904370b807fSmrg -Wc,FLAG 3905370b807fSmrg -Xcompiler FLAG pass FLAG directly to the compiler 3906659607e0Smrg 3907e4da38afSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3908fc27e79cSmrgfrom the given SOURCEFILE. 3909659607e0Smrg 3910fc27e79cSmrgThe output file name is determined by removing the directory component from 3911e4da38afSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 3912e4da38afSmrglibrary object suffix, '.lo'." 3913fc27e79cSmrg ;; 3914659607e0Smrg 3915fc27e79cSmrg execute) 3916fc27e79cSmrg $ECHO \ 3917fc27e79cSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3918659607e0Smrg 3919fc27e79cSmrgAutomatically set library path, then run a program. 3920659607e0Smrg 3921fc27e79cSmrgThis mode accepts the following additional options: 3922659607e0Smrg 3923fc27e79cSmrg -dlopen FILE add the directory containing FILE to the library path 3924659607e0Smrg 3925e4da38afSmrgThis mode sets the library path environment variable according to '-dlopen' 3926fc27e79cSmrgflags. 3927659607e0Smrg 3928fc27e79cSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3929fc27e79cSmrginto their corresponding uninstalled binary, and any of their required library 3930fc27e79cSmrgdirectories are added to the library path. 3931659607e0Smrg 3932fc27e79cSmrgThen, COMMAND is executed, with ARGS as arguments." 3933fc27e79cSmrg ;; 3934659607e0Smrg 3935fc27e79cSmrg finish) 3936fc27e79cSmrg $ECHO \ 3937fc27e79cSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3938659607e0Smrg 3939fc27e79cSmrgComplete the installation of libtool libraries. 3940659607e0Smrg 3941fc27e79cSmrgEach LIBDIR is a directory that contains libtool libraries. 3942659607e0Smrg 3943fc27e79cSmrgThe commands that this mode executes may require superuser privileges. Use 3944e4da38afSmrgthe '--dry-run' option if you just want to see what would be executed." 3945fc27e79cSmrg ;; 3946659607e0Smrg 3947fc27e79cSmrg install) 3948fc27e79cSmrg $ECHO \ 3949fc27e79cSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3950659607e0Smrg 3951fc27e79cSmrgInstall executables or libraries. 3952659607e0Smrg 3953fc27e79cSmrgINSTALL-COMMAND is the installation command. The first component should be 3954e4da38afSmrgeither the 'install' or 'cp' program. 3955659607e0Smrg 3956fc27e79cSmrgThe following components of INSTALL-COMMAND are treated specially: 3957659607e0Smrg 3958bd3a1963Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3959659607e0Smrg 3960fc27e79cSmrgThe rest of the components are interpreted as arguments to that command (only 3961fc27e79cSmrgBSD-compatible install options are recognized)." 3962fc27e79cSmrg ;; 3963659607e0Smrg 3964fc27e79cSmrg link) 3965fc27e79cSmrg $ECHO \ 3966fc27e79cSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3967659607e0Smrg 3968fc27e79cSmrgLink object files or libraries together to form another library, or to 3969fc27e79cSmrgcreate an executable program. 3970659607e0Smrg 3971fc27e79cSmrgLINK-COMMAND is a command using the C compiler that you would use to create 3972fc27e79cSmrga program from several object files. 3973659607e0Smrg 3974fc27e79cSmrgThe following components of LINK-COMMAND are treated specially: 3975659607e0Smrg 3976fc27e79cSmrg -all-static do not do any dynamic linking at all 3977fc27e79cSmrg -avoid-version do not add a version suffix if possible 3978bd3a1963Smrg -bindir BINDIR specify path to binaries directory (for systems where 3979bd3a1963Smrg libraries must be found in the PATH setting at runtime) 3980e4da38afSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3981fc27e79cSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3982fc27e79cSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3983fc27e79cSmrg -export-symbols SYMFILE 3984fc27e79cSmrg try to export only the symbols listed in SYMFILE 3985fc27e79cSmrg -export-symbols-regex REGEX 3986fc27e79cSmrg try to export only the symbols matching REGEX 3987fc27e79cSmrg -LLIBDIR search LIBDIR for required installed libraries 3988fc27e79cSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 3989fc27e79cSmrg -module build a library that can dlopened 3990fc27e79cSmrg -no-fast-install disable the fast-install mode 3991fc27e79cSmrg -no-install link a not-installable executable 3992fc27e79cSmrg -no-undefined declare that a library does not refer to external symbols 3993fc27e79cSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3994e4da38afSmrg -objectlist FILE use a list of object files found in FILE to specify objects 3995e4da38afSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3996fc27e79cSmrg -precious-files-regex REGEX 3997fc27e79cSmrg don't remove output files matching REGEX 3998fc27e79cSmrg -release RELEASE specify package release information 3999fc27e79cSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 4000fc27e79cSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 4001fc27e79cSmrg -shared only do dynamic linking of libtool libraries 4002fc27e79cSmrg -shrext SUFFIX override the standard shared library file extension 4003fc27e79cSmrg -static do not do any dynamic linking of uninstalled libtool libraries 4004fc27e79cSmrg -static-libtool-libs 4005fc27e79cSmrg do not do any dynamic linking of libtool libraries 4006fc27e79cSmrg -version-info CURRENT[:REVISION[:AGE]] 4007fc27e79cSmrg specify library version info [each variable defaults to 0] 4008fc27e79cSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 4009bd3a1963Smrg -Wc,FLAG 4010bd3a1963Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 4011370b807fSmrg -Wa,FLAG 4012370b807fSmrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 4013bd3a1963Smrg -Wl,FLAG 4014bd3a1963Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 4015bd3a1963Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 4016659607e0Smrg 4017e4da38afSmrgAll other options (arguments beginning with '-') are ignored. 4018659607e0Smrg 4019e4da38afSmrgEvery other argument is treated as a filename. Files ending in '.la' are 4020fc27e79cSmrgtreated as uninstalled libtool libraries, other files are standard or library 4021fc27e79cSmrgobject files. 4022659607e0Smrg 4023e4da38afSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 4024e4da38afSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 4025fc27e79cSmrgrequired, except when creating a convenience library. 4026659607e0Smrg 4027e4da38afSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 4028e4da38afSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 4029659607e0Smrg 4030e4da38afSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 4031fc27e79cSmrgis created, otherwise an executable program is created." 4032659607e0Smrg ;; 4033659607e0Smrg 4034fc27e79cSmrg uninstall) 4035fc27e79cSmrg $ECHO \ 4036fc27e79cSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 4037659607e0Smrg 4038fc27e79cSmrgRemove libraries from an installation directory. 4039659607e0Smrg 4040fc27e79cSmrgRM is the name of the program to use to delete files associated with each FILE 4041e4da38afSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 4042fc27e79cSmrgto RM. 4043659607e0Smrg 4044fc27e79cSmrgIf FILE is a libtool library, all the files associated with it are deleted. 4045fc27e79cSmrgOtherwise, only FILE itself is deleted using RM." 4046fc27e79cSmrg ;; 4047659607e0Smrg 4048fc27e79cSmrg *) 4049e4da38afSmrg func_fatal_help "invalid operation mode '$opt_mode'" 4050fc27e79cSmrg ;; 4051fc27e79cSmrg esac 4052659607e0Smrg 4053bd3a1963Smrg echo 4054e4da38afSmrg $ECHO "Try '$progname --help' for more information about other modes." 4055fc27e79cSmrg} 4056659607e0Smrg 4057bd3a1963Smrg# Now that we've collected a possible --mode arg, show help if necessary 4058bd3a1963Smrgif $opt_help; then 4059e4da38afSmrg if test : = "$opt_help"; then 4060bd3a1963Smrg func_mode_help 4061bd3a1963Smrg else 4062bd3a1963Smrg { 4063bd3a1963Smrg func_help noexit 4064bd3a1963Smrg for opt_mode in compile link execute install finish uninstall clean; do 4065bd3a1963Smrg func_mode_help 4066bd3a1963Smrg done 4067e4da38afSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 4068bd3a1963Smrg { 4069bd3a1963Smrg func_help noexit 4070bd3a1963Smrg for opt_mode in compile link execute install finish uninstall clean; do 4071bd3a1963Smrg echo 4072bd3a1963Smrg func_mode_help 4073bd3a1963Smrg done 4074bd3a1963Smrg } | 4075e4da38afSmrg $SED '1d 4076bd3a1963Smrg /^When reporting/,/^Report/{ 4077bd3a1963Smrg H 4078bd3a1963Smrg d 4079bd3a1963Smrg } 4080bd3a1963Smrg $x 4081bd3a1963Smrg /information about other modes/d 4082bd3a1963Smrg /more detailed .*MODE/d 4083bd3a1963Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 4084bd3a1963Smrg fi 4085bd3a1963Smrg exit $? 4086bd3a1963Smrgfi 4087659607e0Smrg 4088659607e0Smrg 4089fc27e79cSmrg# func_mode_execute arg... 4090fc27e79cSmrgfunc_mode_execute () 4091fc27e79cSmrg{ 4092e4da38afSmrg $debug_cmd 4093e4da38afSmrg 4094fc27e79cSmrg # The first argument is the command name. 4095e4da38afSmrg cmd=$nonopt 4096fc27e79cSmrg test -z "$cmd" && \ 4097fc27e79cSmrg func_fatal_help "you must specify a COMMAND" 4098659607e0Smrg 4099fc27e79cSmrg # Handle -dlopen flags immediately. 4100bd3a1963Smrg for file in $opt_dlopen; do 4101fc27e79cSmrg test -f "$file" \ 4102e4da38afSmrg || func_fatal_help "'$file' is not a file" 4103659607e0Smrg 4104fc27e79cSmrg dir= 4105fc27e79cSmrg case $file in 4106fc27e79cSmrg *.la) 4107bd3a1963Smrg func_resolve_sysroot "$file" 4108bd3a1963Smrg file=$func_resolve_sysroot_result 4109bd3a1963Smrg 4110fc27e79cSmrg # Check to see that this really is a libtool archive. 4111fc27e79cSmrg func_lalib_unsafe_p "$file" \ 4112e4da38afSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 4113659607e0Smrg 4114fc27e79cSmrg # Read the libtool library. 4115fc27e79cSmrg dlname= 4116fc27e79cSmrg library_names= 4117fc27e79cSmrg func_source "$file" 4118659607e0Smrg 4119fc27e79cSmrg # Skip this library if it cannot be dlopened. 4120fc27e79cSmrg if test -z "$dlname"; then 4121fc27e79cSmrg # Warn if it was a shared library. 4122fc27e79cSmrg test -n "$library_names" && \ 4123e4da38afSmrg func_warning "'$file' was not linked with '-export-dynamic'" 4124fc27e79cSmrg continue 4125fc27e79cSmrg fi 4126659607e0Smrg 4127fc27e79cSmrg func_dirname "$file" "" "." 4128e4da38afSmrg dir=$func_dirname_result 4129659607e0Smrg 4130fc27e79cSmrg if test -f "$dir/$objdir/$dlname"; then 4131bd3a1963Smrg func_append dir "/$objdir" 4132fc27e79cSmrg else 4133fc27e79cSmrg if test ! -f "$dir/$dlname"; then 4134e4da38afSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 4135fc27e79cSmrg fi 4136fc27e79cSmrg fi 4137659607e0Smrg ;; 4138659607e0Smrg 4139fc27e79cSmrg *.lo) 4140fc27e79cSmrg # Just add the directory containing the .lo file. 4141fc27e79cSmrg func_dirname "$file" "" "." 4142e4da38afSmrg dir=$func_dirname_result 4143659607e0Smrg ;; 4144659607e0Smrg 4145fc27e79cSmrg *) 4146e4da38afSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 4147659607e0Smrg continue 4148659607e0Smrg ;; 4149fc27e79cSmrg esac 4150659607e0Smrg 4151fc27e79cSmrg # Get the absolute pathname. 4152fc27e79cSmrg absdir=`cd "$dir" && pwd` 4153e4da38afSmrg test -n "$absdir" && dir=$absdir 4154659607e0Smrg 4155fc27e79cSmrg # Now add the directory to shlibpath_var. 4156fc27e79cSmrg if eval "test -z \"\$$shlibpath_var\""; then 4157fc27e79cSmrg eval "$shlibpath_var=\"\$dir\"" 4158fc27e79cSmrg else 4159fc27e79cSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 4160fc27e79cSmrg fi 4161fc27e79cSmrg done 4162659607e0Smrg 4163fc27e79cSmrg # This variable tells wrapper scripts just to set shlibpath_var 4164fc27e79cSmrg # rather than running their programs. 4165e4da38afSmrg libtool_execute_magic=$magic 4166659607e0Smrg 4167fc27e79cSmrg # Check if any of the arguments is a wrapper script. 4168fc27e79cSmrg args= 4169fc27e79cSmrg for file 4170fc27e79cSmrg do 4171fc27e79cSmrg case $file in 4172bd3a1963Smrg -* | *.la | *.lo ) ;; 4173fc27e79cSmrg *) 4174fc27e79cSmrg # Do a test to see if this is really a libtool program. 4175fc27e79cSmrg if func_ltwrapper_script_p "$file"; then 4176fc27e79cSmrg func_source "$file" 4177fc27e79cSmrg # Transform arg to wrapped name. 4178e4da38afSmrg file=$progdir/$program 4179fc27e79cSmrg elif func_ltwrapper_executable_p "$file"; then 4180fc27e79cSmrg func_ltwrapper_scriptname "$file" 4181fc27e79cSmrg func_source "$func_ltwrapper_scriptname_result" 4182fc27e79cSmrg # Transform arg to wrapped name. 4183e4da38afSmrg file=$progdir/$program 4184fc27e79cSmrg fi 4185fc27e79cSmrg ;; 4186fc27e79cSmrg esac 4187fc27e79cSmrg # Quote arguments (to preserve shell metacharacters). 4188bd3a1963Smrg func_append_quoted args "$file" 4189fc27e79cSmrg done 4190659607e0Smrg 4191e4da38afSmrg if $opt_dry_run; then 4192e4da38afSmrg # Display what would be done. 4193e4da38afSmrg if test -n "$shlibpath_var"; then 4194e4da38afSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 4195e4da38afSmrg echo "export $shlibpath_var" 4196e4da38afSmrg fi 4197e4da38afSmrg $ECHO "$cmd$args" 4198e4da38afSmrg exit $EXIT_SUCCESS 4199e4da38afSmrg else 4200fc27e79cSmrg if test -n "$shlibpath_var"; then 4201fc27e79cSmrg # Export the shlibpath_var. 4202fc27e79cSmrg eval "export $shlibpath_var" 4203fc27e79cSmrg fi 4204659607e0Smrg 4205fc27e79cSmrg # Restore saved environment variables 4206fc27e79cSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 4207fc27e79cSmrg do 4208fc27e79cSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 4209fc27e79cSmrg $lt_var=\$save_$lt_var; export $lt_var 4210fc27e79cSmrg else 4211fc27e79cSmrg $lt_unset $lt_var 4212fc27e79cSmrg fi" 4213fc27e79cSmrg done 4214659607e0Smrg 4215fc27e79cSmrg # Now prepare to actually exec the command. 4216e4da38afSmrg exec_cmd=\$cmd$args 4217fc27e79cSmrg fi 4218fc27e79cSmrg} 4219659607e0Smrg 4220e4da38afSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 4221bd3a1963Smrg 4222bd3a1963Smrg 4223bd3a1963Smrg# func_mode_finish arg... 4224bd3a1963Smrgfunc_mode_finish () 4225bd3a1963Smrg{ 4226e4da38afSmrg $debug_cmd 4227e4da38afSmrg 4228bd3a1963Smrg libs= 4229bd3a1963Smrg libdirs= 4230bd3a1963Smrg admincmds= 4231bd3a1963Smrg 4232bd3a1963Smrg for opt in "$nonopt" ${1+"$@"} 4233bd3a1963Smrg do 4234bd3a1963Smrg if test -d "$opt"; then 4235bd3a1963Smrg func_append libdirs " $opt" 4236bd3a1963Smrg 4237bd3a1963Smrg elif test -f "$opt"; then 4238bd3a1963Smrg if func_lalib_unsafe_p "$opt"; then 4239bd3a1963Smrg func_append libs " $opt" 4240bd3a1963Smrg else 4241e4da38afSmrg func_warning "'$opt' is not a valid libtool archive" 4242bd3a1963Smrg fi 4243bd3a1963Smrg 4244bd3a1963Smrg else 4245e4da38afSmrg func_fatal_error "invalid argument '$opt'" 4246bd3a1963Smrg fi 4247bd3a1963Smrg done 4248659607e0Smrg 4249bd3a1963Smrg if test -n "$libs"; then 4250bd3a1963Smrg if test -n "$lt_sysroot"; then 4251bd3a1963Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 4252bd3a1963Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 4253bd3a1963Smrg else 4254bd3a1963Smrg sysroot_cmd= 4255bd3a1963Smrg fi 4256659607e0Smrg 4257bd3a1963Smrg # Remove sysroot references 4258bd3a1963Smrg if $opt_dry_run; then 4259bd3a1963Smrg for lib in $libs; do 4260e4da38afSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4261bd3a1963Smrg done 4262bd3a1963Smrg else 4263bd3a1963Smrg tmpdir=`func_mktempdir` 4264bd3a1963Smrg for lib in $libs; do 4265e4da38afSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4266bd3a1963Smrg > $tmpdir/tmp-la 4267bd3a1963Smrg mv -f $tmpdir/tmp-la $lib 4268bd3a1963Smrg done 4269bd3a1963Smrg ${RM}r "$tmpdir" 4270bd3a1963Smrg fi 4271bd3a1963Smrg fi 4272659607e0Smrg 4273fc27e79cSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4274fc27e79cSmrg for libdir in $libdirs; do 4275fc27e79cSmrg if test -n "$finish_cmds"; then 4276fc27e79cSmrg # Do each command in the finish commands. 4277fc27e79cSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4278fc27e79cSmrg'"$cmd"'"' 4279fc27e79cSmrg fi 4280fc27e79cSmrg if test -n "$finish_eval"; then 4281fc27e79cSmrg # Do the single finish_eval. 4282fc27e79cSmrg eval cmds=\"$finish_eval\" 4283bd3a1963Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4284fc27e79cSmrg $cmds" 4285fc27e79cSmrg fi 4286fc27e79cSmrg done 4287fc27e79cSmrg fi 4288659607e0Smrg 4289fc27e79cSmrg # Exit here if they wanted silent mode. 4290e4da38afSmrg $opt_quiet && exit $EXIT_SUCCESS 4291659607e0Smrg 4292bd3a1963Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4293bd3a1963Smrg echo "----------------------------------------------------------------------" 4294bd3a1963Smrg echo "Libraries have been installed in:" 4295bd3a1963Smrg for libdir in $libdirs; do 4296bd3a1963Smrg $ECHO " $libdir" 4297bd3a1963Smrg done 4298bd3a1963Smrg echo 4299bd3a1963Smrg echo "If you ever happen to want to link against installed libraries" 4300bd3a1963Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 4301e4da38afSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4302bd3a1963Smrg echo "flag during linking and do at least one of the following:" 4303bd3a1963Smrg if test -n "$shlibpath_var"; then 4304e4da38afSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4305bd3a1963Smrg echo " during execution" 4306bd3a1963Smrg fi 4307bd3a1963Smrg if test -n "$runpath_var"; then 4308e4da38afSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4309bd3a1963Smrg echo " during linking" 4310bd3a1963Smrg fi 4311bd3a1963Smrg if test -n "$hardcode_libdir_flag_spec"; then 4312bd3a1963Smrg libdir=LIBDIR 4313bd3a1963Smrg eval flag=\"$hardcode_libdir_flag_spec\" 4314659607e0Smrg 4315e4da38afSmrg $ECHO " - use the '$flag' linker flag" 4316bd3a1963Smrg fi 4317bd3a1963Smrg if test -n "$admincmds"; then 4318bd3a1963Smrg $ECHO " - have your system administrator run these commands:$admincmds" 4319bd3a1963Smrg fi 4320bd3a1963Smrg if test -f /etc/ld.so.conf; then 4321e4da38afSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4322bd3a1963Smrg fi 4323bd3a1963Smrg echo 4324659607e0Smrg 4325bd3a1963Smrg echo "See any operating system documentation about shared libraries for" 4326bd3a1963Smrg case $host in 4327bd3a1963Smrg solaris2.[6789]|solaris2.1[0-9]) 4328bd3a1963Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4329bd3a1963Smrg echo "pages." 4330bd3a1963Smrg ;; 4331bd3a1963Smrg *) 4332bd3a1963Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4333bd3a1963Smrg ;; 4334bd3a1963Smrg esac 4335bd3a1963Smrg echo "----------------------------------------------------------------------" 4336bd3a1963Smrg fi 4337fc27e79cSmrg exit $EXIT_SUCCESS 4338fc27e79cSmrg} 4339659607e0Smrg 4340e4da38afSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4341659607e0Smrg 4342659607e0Smrg 4343fc27e79cSmrg# func_mode_install arg... 4344fc27e79cSmrgfunc_mode_install () 4345fc27e79cSmrg{ 4346e4da38afSmrg $debug_cmd 4347e4da38afSmrg 4348fc27e79cSmrg # There may be an optional sh(1) argument at the beginning of 4349fc27e79cSmrg # install_prog (especially on Windows NT). 4350e4da38afSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4351fc27e79cSmrg # Allow the use of GNU shtool's install command. 4352e4da38afSmrg case $nonopt in *shtool*) :;; *) false;; esac 4353e4da38afSmrg then 4354fc27e79cSmrg # Aesthetically quote it. 4355370b807fSmrg func_quote_arg pretty "$nonopt" 4356370b807fSmrg install_prog="$func_quote_arg_result " 4357fc27e79cSmrg arg=$1 4358fc27e79cSmrg shift 4359fc27e79cSmrg else 4360fc27e79cSmrg install_prog= 4361fc27e79cSmrg arg=$nonopt 4362fc27e79cSmrg fi 4363659607e0Smrg 4364fc27e79cSmrg # The real first argument should be the name of the installation program. 4365fc27e79cSmrg # Aesthetically quote it. 4366370b807fSmrg func_quote_arg pretty "$arg" 4367370b807fSmrg func_append install_prog "$func_quote_arg_result" 4368bd3a1963Smrg install_shared_prog=$install_prog 4369bd3a1963Smrg case " $install_prog " in 4370bd3a1963Smrg *[\\\ /]cp\ *) install_cp=: ;; 4371bd3a1963Smrg *) install_cp=false ;; 4372bd3a1963Smrg esac 4373fc27e79cSmrg 4374fc27e79cSmrg # We need to accept at least all the BSD install flags. 4375fc27e79cSmrg dest= 4376fc27e79cSmrg files= 4377fc27e79cSmrg opts= 4378fc27e79cSmrg prev= 4379fc27e79cSmrg install_type= 4380e4da38afSmrg isdir=false 4381fc27e79cSmrg stripme= 4382bd3a1963Smrg no_mode=: 4383fc27e79cSmrg for arg 4384fc27e79cSmrg do 4385bd3a1963Smrg arg2= 4386fc27e79cSmrg if test -n "$dest"; then 4387bd3a1963Smrg func_append files " $dest" 4388fc27e79cSmrg dest=$arg 4389fc27e79cSmrg continue 4390659607e0Smrg fi 4391659607e0Smrg 4392fc27e79cSmrg case $arg in 4393e4da38afSmrg -d) isdir=: ;; 4394fc27e79cSmrg -f) 4395bd3a1963Smrg if $install_cp; then :; else 4396bd3a1963Smrg prev=$arg 4397bd3a1963Smrg fi 4398fc27e79cSmrg ;; 4399fc27e79cSmrg -g | -m | -o) 4400fc27e79cSmrg prev=$arg 4401fc27e79cSmrg ;; 4402fc27e79cSmrg -s) 4403fc27e79cSmrg stripme=" -s" 4404fc27e79cSmrg continue 4405fc27e79cSmrg ;; 4406fc27e79cSmrg -*) 4407fc27e79cSmrg ;; 4408fc27e79cSmrg *) 4409fc27e79cSmrg # If the previous option needed an argument, then skip it. 4410fc27e79cSmrg if test -n "$prev"; then 4411e4da38afSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4412bd3a1963Smrg arg2=$install_override_mode 4413bd3a1963Smrg no_mode=false 4414bd3a1963Smrg fi 4415fc27e79cSmrg prev= 4416fc27e79cSmrg else 4417fc27e79cSmrg dest=$arg 4418fc27e79cSmrg continue 4419fc27e79cSmrg fi 4420fc27e79cSmrg ;; 4421fc27e79cSmrg esac 4422659607e0Smrg 4423fc27e79cSmrg # Aesthetically quote the argument. 4424370b807fSmrg func_quote_arg pretty "$arg" 4425370b807fSmrg func_append install_prog " $func_quote_arg_result" 4426bd3a1963Smrg if test -n "$arg2"; then 4427370b807fSmrg func_quote_arg pretty "$arg2" 4428bd3a1963Smrg fi 4429370b807fSmrg func_append install_shared_prog " $func_quote_arg_result" 4430fc27e79cSmrg done 4431659607e0Smrg 4432fc27e79cSmrg test -z "$install_prog" && \ 4433fc27e79cSmrg func_fatal_help "you must specify an install program" 4434659607e0Smrg 4435fc27e79cSmrg test -n "$prev" && \ 4436e4da38afSmrg func_fatal_help "the '$prev' option requires an argument" 4437659607e0Smrg 4438bd3a1963Smrg if test -n "$install_override_mode" && $no_mode; then 4439bd3a1963Smrg if $install_cp; then :; else 4440370b807fSmrg func_quote_arg pretty "$install_override_mode" 4441370b807fSmrg func_append install_shared_prog " -m $func_quote_arg_result" 4442bd3a1963Smrg fi 4443bd3a1963Smrg fi 4444bd3a1963Smrg 4445fc27e79cSmrg if test -z "$files"; then 4446fc27e79cSmrg if test -z "$dest"; then 4447fc27e79cSmrg func_fatal_help "no file or destination specified" 4448fc27e79cSmrg else 4449fc27e79cSmrg func_fatal_help "you must specify a destination" 4450659607e0Smrg fi 4451659607e0Smrg fi 4452659607e0Smrg 4453fc27e79cSmrg # Strip any trailing slash from the destination. 4454fc27e79cSmrg func_stripname '' '/' "$dest" 4455fc27e79cSmrg dest=$func_stripname_result 4456659607e0Smrg 4457fc27e79cSmrg # Check to see that the destination is a directory. 4458e4da38afSmrg test -d "$dest" && isdir=: 4459e4da38afSmrg if $isdir; then 4460e4da38afSmrg destdir=$dest 4461fc27e79cSmrg destname= 4462fc27e79cSmrg else 4463fc27e79cSmrg func_dirname_and_basename "$dest" "" "." 4464e4da38afSmrg destdir=$func_dirname_result 4465e4da38afSmrg destname=$func_basename_result 4466fc27e79cSmrg 4467fc27e79cSmrg # Not a directory, so check to see that there is only one file specified. 4468fc27e79cSmrg set dummy $files; shift 4469fc27e79cSmrg test "$#" -gt 1 && \ 4470e4da38afSmrg func_fatal_help "'$dest' is not a directory" 4471fc27e79cSmrg fi 4472fc27e79cSmrg case $destdir in 4473fc27e79cSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4474659607e0Smrg *) 4475fc27e79cSmrg for file in $files; do 4476fc27e79cSmrg case $file in 4477fc27e79cSmrg *.lo) ;; 4478fc27e79cSmrg *) 4479e4da38afSmrg func_fatal_help "'$destdir' must be an absolute directory name" 4480fc27e79cSmrg ;; 4481fc27e79cSmrg esac 4482fc27e79cSmrg done 4483659607e0Smrg ;; 4484659607e0Smrg esac 4485659607e0Smrg 4486fc27e79cSmrg # This variable tells wrapper scripts just to set variables rather 4487fc27e79cSmrg # than running their programs. 4488e4da38afSmrg libtool_install_magic=$magic 4489659607e0Smrg 4490fc27e79cSmrg staticlibs= 4491fc27e79cSmrg future_libdirs= 4492fc27e79cSmrg current_libdirs= 4493fc27e79cSmrg for file in $files; do 4494659607e0Smrg 4495fc27e79cSmrg # Do each installation. 4496fc27e79cSmrg case $file in 4497fc27e79cSmrg *.$libext) 4498fc27e79cSmrg # Do the static libraries later. 4499bd3a1963Smrg func_append staticlibs " $file" 4500fc27e79cSmrg ;; 4501fc27e79cSmrg 4502fc27e79cSmrg *.la) 4503bd3a1963Smrg func_resolve_sysroot "$file" 4504bd3a1963Smrg file=$func_resolve_sysroot_result 4505bd3a1963Smrg 4506fc27e79cSmrg # Check to see that this really is a libtool archive. 4507fc27e79cSmrg func_lalib_unsafe_p "$file" \ 4508e4da38afSmrg || func_fatal_help "'$file' is not a valid libtool archive" 4509fc27e79cSmrg 4510fc27e79cSmrg library_names= 4511fc27e79cSmrg old_library= 4512fc27e79cSmrg relink_command= 4513fc27e79cSmrg func_source "$file" 4514fc27e79cSmrg 4515fc27e79cSmrg # Add the libdir to current_libdirs if it is the destination. 4516fc27e79cSmrg if test "X$destdir" = "X$libdir"; then 4517fc27e79cSmrg case "$current_libdirs " in 4518fc27e79cSmrg *" $libdir "*) ;; 4519bd3a1963Smrg *) func_append current_libdirs " $libdir" ;; 4520659607e0Smrg esac 4521fc27e79cSmrg else 4522fc27e79cSmrg # Note the libdir as a future libdir. 4523fc27e79cSmrg case "$future_libdirs " in 4524fc27e79cSmrg *" $libdir "*) ;; 4525bd3a1963Smrg *) func_append future_libdirs " $libdir" ;; 4526fc27e79cSmrg esac 4527fc27e79cSmrg fi 4528659607e0Smrg 4529fc27e79cSmrg func_dirname "$file" "/" "" 4530e4da38afSmrg dir=$func_dirname_result 4531bd3a1963Smrg func_append dir "$objdir" 4532fc27e79cSmrg 4533fc27e79cSmrg if test -n "$relink_command"; then 4534fc27e79cSmrg # Determine the prefix the user has applied to our future dir. 4535bd3a1963Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4536fc27e79cSmrg 4537fc27e79cSmrg # Don't allow the user to place us outside of our expected 4538fc27e79cSmrg # location b/c this prevents finding dependent libraries that 4539fc27e79cSmrg # are installed to the same prefix. 4540fc27e79cSmrg # At present, this check doesn't affect windows .dll's that 4541fc27e79cSmrg # are installed into $libdir/../bin (currently, that works fine) 4542fc27e79cSmrg # but it's something to keep an eye on. 4543fc27e79cSmrg test "$inst_prefix_dir" = "$destdir" && \ 4544e4da38afSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4545fc27e79cSmrg 4546fc27e79cSmrg if test -n "$inst_prefix_dir"; then 4547fc27e79cSmrg # Stick the inst_prefix_dir data into the link command. 4548bd3a1963Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4549fc27e79cSmrg else 4550bd3a1963Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4551fc27e79cSmrg fi 4552fc27e79cSmrg 4553e4da38afSmrg func_warning "relinking '$file'" 4554fc27e79cSmrg func_show_eval "$relink_command" \ 4555e4da38afSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4556fc27e79cSmrg fi 4557fc27e79cSmrg 4558fc27e79cSmrg # See the names of the shared library. 4559fc27e79cSmrg set dummy $library_names; shift 4560fc27e79cSmrg if test -n "$1"; then 4561e4da38afSmrg realname=$1 4562fc27e79cSmrg shift 4563fc27e79cSmrg 4564e4da38afSmrg srcname=$realname 4565e4da38afSmrg test -n "$relink_command" && srcname=${realname}T 4566fc27e79cSmrg 4567fc27e79cSmrg # Install the shared library and build the symlinks. 4568bd3a1963Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4569fc27e79cSmrg 'exit $?' 4570e4da38afSmrg tstripme=$stripme 4571fc27e79cSmrg case $host_os in 4572fc27e79cSmrg cygwin* | mingw* | pw32* | cegcc*) 4573fc27e79cSmrg case $realname in 4574fc27e79cSmrg *.dll.a) 4575e4da38afSmrg tstripme= 4576e4da38afSmrg ;; 4577e4da38afSmrg esac 4578e4da38afSmrg ;; 4579e4da38afSmrg os2*) 4580e4da38afSmrg case $realname in 4581e4da38afSmrg *_dll.a) 4582e4da38afSmrg tstripme= 4583fc27e79cSmrg ;; 4584fc27e79cSmrg esac 4585659607e0Smrg ;; 4586659607e0Smrg esac 4587fc27e79cSmrg if test -n "$tstripme" && test -n "$striplib"; then 4588fc27e79cSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4589659607e0Smrg fi 4590fc27e79cSmrg 4591fc27e79cSmrg if test "$#" -gt 0; then 4592fc27e79cSmrg # Delete the old symlinks, and create new ones. 4593e4da38afSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4594fc27e79cSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4595fc27e79cSmrg # so we also need to try rm && ln -s. 4596fc27e79cSmrg for linkname 4597fc27e79cSmrg do 4598fc27e79cSmrg test "$linkname" != "$realname" \ 4599fc27e79cSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4600659607e0Smrg done 4601659607e0Smrg fi 4602659607e0Smrg 4603fc27e79cSmrg # Do each command in the postinstall commands. 4604e4da38afSmrg lib=$destdir/$realname 4605fc27e79cSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4606659607e0Smrg fi 4607659607e0Smrg 4608fc27e79cSmrg # Install the pseudo-library for information purposes. 4609fc27e79cSmrg func_basename "$file" 4610e4da38afSmrg name=$func_basename_result 4611e4da38afSmrg instname=$dir/${name}i 4612fc27e79cSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4613659607e0Smrg 4614fc27e79cSmrg # Maybe install the static library, too. 4615bd3a1963Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4616fc27e79cSmrg ;; 4617659607e0Smrg 4618fc27e79cSmrg *.lo) 4619fc27e79cSmrg # Install (i.e. copy) a libtool object. 4620659607e0Smrg 4621fc27e79cSmrg # Figure out destination file name, if it wasn't already specified. 4622fc27e79cSmrg if test -n "$destname"; then 4623e4da38afSmrg destfile=$destdir/$destname 4624fc27e79cSmrg else 4625fc27e79cSmrg func_basename "$file" 4626e4da38afSmrg destfile=$func_basename_result 4627e4da38afSmrg destfile=$destdir/$destfile 4628fc27e79cSmrg fi 4629fc27e79cSmrg 4630fc27e79cSmrg # Deduce the name of the destination old-style object file. 4631fc27e79cSmrg case $destfile in 4632fc27e79cSmrg *.lo) 4633fc27e79cSmrg func_lo2o "$destfile" 4634fc27e79cSmrg staticdest=$func_lo2o_result 4635fc27e79cSmrg ;; 4636fc27e79cSmrg *.$objext) 4637e4da38afSmrg staticdest=$destfile 4638fc27e79cSmrg destfile= 4639fc27e79cSmrg ;; 4640fc27e79cSmrg *) 4641e4da38afSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4642fc27e79cSmrg ;; 4643659607e0Smrg esac 4644659607e0Smrg 4645fc27e79cSmrg # Install the libtool object if requested. 4646fc27e79cSmrg test -n "$destfile" && \ 4647fc27e79cSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4648fc27e79cSmrg 4649fc27e79cSmrg # Install the old object if enabled. 4650e4da38afSmrg if test yes = "$build_old_libs"; then 4651fc27e79cSmrg # Deduce the name of the old-style object file. 4652fc27e79cSmrg func_lo2o "$file" 4653fc27e79cSmrg staticobj=$func_lo2o_result 4654fc27e79cSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4655659607e0Smrg fi 4656fc27e79cSmrg exit $EXIT_SUCCESS 4657fc27e79cSmrg ;; 4658659607e0Smrg 4659fc27e79cSmrg *) 4660fc27e79cSmrg # Figure out destination file name, if it wasn't already specified. 4661fc27e79cSmrg if test -n "$destname"; then 4662e4da38afSmrg destfile=$destdir/$destname 4663fc27e79cSmrg else 4664fc27e79cSmrg func_basename "$file" 4665e4da38afSmrg destfile=$func_basename_result 4666e4da38afSmrg destfile=$destdir/$destfile 4667fc27e79cSmrg fi 4668fc27e79cSmrg 4669fc27e79cSmrg # If the file is missing, and there is a .exe on the end, strip it 4670fc27e79cSmrg # because it is most likely a libtool script we actually want to 4671fc27e79cSmrg # install 4672e4da38afSmrg stripped_ext= 4673fc27e79cSmrg case $file in 4674fc27e79cSmrg *.exe) 4675fc27e79cSmrg if test ! -f "$file"; then 4676fc27e79cSmrg func_stripname '' '.exe' "$file" 4677fc27e79cSmrg file=$func_stripname_result 4678e4da38afSmrg stripped_ext=.exe 4679659607e0Smrg fi 4680fc27e79cSmrg ;; 4681fc27e79cSmrg esac 4682659607e0Smrg 4683fc27e79cSmrg # Do a test to see if this is really a libtool program. 4684fc27e79cSmrg case $host in 4685fc27e79cSmrg *cygwin* | *mingw*) 4686fc27e79cSmrg if func_ltwrapper_executable_p "$file"; then 4687fc27e79cSmrg func_ltwrapper_scriptname "$file" 4688fc27e79cSmrg wrapper=$func_ltwrapper_scriptname_result 4689fc27e79cSmrg else 4690fc27e79cSmrg func_stripname '' '.exe' "$file" 4691fc27e79cSmrg wrapper=$func_stripname_result 4692fc27e79cSmrg fi 4693fc27e79cSmrg ;; 4694fc27e79cSmrg *) 4695fc27e79cSmrg wrapper=$file 4696fc27e79cSmrg ;; 4697fc27e79cSmrg esac 4698fc27e79cSmrg if func_ltwrapper_script_p "$wrapper"; then 4699fc27e79cSmrg notinst_deplibs= 4700fc27e79cSmrg relink_command= 4701659607e0Smrg 4702fc27e79cSmrg func_source "$wrapper" 4703659607e0Smrg 4704fc27e79cSmrg # Check the variables that should have been set. 4705fc27e79cSmrg test -z "$generated_by_libtool_version" && \ 4706e4da38afSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4707fc27e79cSmrg 4708e4da38afSmrg finalize=: 4709fc27e79cSmrg for lib in $notinst_deplibs; do 4710fc27e79cSmrg # Check to see that each library is installed. 4711fc27e79cSmrg libdir= 4712fc27e79cSmrg if test -f "$lib"; then 4713fc27e79cSmrg func_source "$lib" 4714fc27e79cSmrg fi 4715e4da38afSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4716fc27e79cSmrg if test -n "$libdir" && test ! -f "$libfile"; then 4717e4da38afSmrg func_warning "'$lib' has not been installed in '$libdir'" 4718e4da38afSmrg finalize=false 4719fc27e79cSmrg fi 4720fc27e79cSmrg done 4721fc27e79cSmrg 4722fc27e79cSmrg relink_command= 4723fc27e79cSmrg func_source "$wrapper" 4724fc27e79cSmrg 4725fc27e79cSmrg outputname= 4726e4da38afSmrg if test no = "$fast_install" && test -n "$relink_command"; then 4727fc27e79cSmrg $opt_dry_run || { 4728e4da38afSmrg if $finalize; then 4729fc27e79cSmrg tmpdir=`func_mktempdir` 4730fc27e79cSmrg func_basename "$file$stripped_ext" 4731e4da38afSmrg file=$func_basename_result 4732e4da38afSmrg outputname=$tmpdir/$file 4733fc27e79cSmrg # Replace the output file specification. 4734bd3a1963Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4735fc27e79cSmrg 4736e4da38afSmrg $opt_quiet || { 4737370b807fSmrg func_quote_arg expand,pretty "$relink_command" 4738370b807fSmrg eval "func_echo $func_quote_arg_result" 4739fc27e79cSmrg } 4740fc27e79cSmrg if eval "$relink_command"; then : 4741fc27e79cSmrg else 4742e4da38afSmrg func_error "error: relink '$file' with the above command before installing it" 4743fc27e79cSmrg $opt_dry_run || ${RM}r "$tmpdir" 4744fc27e79cSmrg continue 4745fc27e79cSmrg fi 4746e4da38afSmrg file=$outputname 4747fc27e79cSmrg else 4748e4da38afSmrg func_warning "cannot relink '$file'" 4749fc27e79cSmrg fi 4750fc27e79cSmrg } 4751659607e0Smrg else 4752fc27e79cSmrg # Install the binary that we compiled earlier. 4753bd3a1963Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4754659607e0Smrg fi 4755fc27e79cSmrg fi 4756659607e0Smrg 4757fc27e79cSmrg # remove .exe since cygwin /usr/bin/install will append another 4758fc27e79cSmrg # one anyway 4759fc27e79cSmrg case $install_prog,$host in 4760fc27e79cSmrg */usr/bin/install*,*cygwin*) 4761fc27e79cSmrg case $file:$destfile in 4762fc27e79cSmrg *.exe:*.exe) 4763fc27e79cSmrg # this is ok 4764fc27e79cSmrg ;; 4765fc27e79cSmrg *.exe:*) 4766fc27e79cSmrg destfile=$destfile.exe 4767fc27e79cSmrg ;; 4768fc27e79cSmrg *:*.exe) 4769fc27e79cSmrg func_stripname '' '.exe' "$destfile" 4770fc27e79cSmrg destfile=$func_stripname_result 4771fc27e79cSmrg ;; 4772fc27e79cSmrg esac 4773659607e0Smrg ;; 4774659607e0Smrg esac 4775fc27e79cSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4776fc27e79cSmrg $opt_dry_run || if test -n "$outputname"; then 4777fc27e79cSmrg ${RM}r "$tmpdir" 4778fc27e79cSmrg fi 4779fc27e79cSmrg ;; 4780fc27e79cSmrg esac 4781fc27e79cSmrg done 4782659607e0Smrg 4783fc27e79cSmrg for file in $staticlibs; do 4784fc27e79cSmrg func_basename "$file" 4785e4da38afSmrg name=$func_basename_result 4786659607e0Smrg 4787fc27e79cSmrg # Set up the ranlib parameters. 4788e4da38afSmrg oldlib=$destdir/$name 4789a73597f9Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4790a73597f9Smrg tool_oldlib=$func_to_tool_file_result 4791659607e0Smrg 4792fc27e79cSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4793659607e0Smrg 4794fc27e79cSmrg if test -n "$stripme" && test -n "$old_striplib"; then 4795a73597f9Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4796fc27e79cSmrg fi 4797659607e0Smrg 4798fc27e79cSmrg # Do each command in the postinstall commands. 4799fc27e79cSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4800fc27e79cSmrg done 4801659607e0Smrg 4802fc27e79cSmrg test -n "$future_libdirs" && \ 4803e4da38afSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 4804659607e0Smrg 4805fc27e79cSmrg if test -n "$current_libdirs"; then 4806fc27e79cSmrg # Maybe just do a dry run. 4807fc27e79cSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 4808e4da38afSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4809fc27e79cSmrg else 4810fc27e79cSmrg exit $EXIT_SUCCESS 4811fc27e79cSmrg fi 4812fc27e79cSmrg} 4813659607e0Smrg 4814e4da38afSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4815659607e0Smrg 4816659607e0Smrg 4817fc27e79cSmrg# func_generate_dlsyms outputname originator pic_p 4818fc27e79cSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4819fc27e79cSmrg# a dlpreopen symbol table. 4820fc27e79cSmrgfunc_generate_dlsyms () 4821fc27e79cSmrg{ 4822e4da38afSmrg $debug_cmd 4823e4da38afSmrg 4824e4da38afSmrg my_outputname=$1 4825e4da38afSmrg my_originator=$2 4826e4da38afSmrg my_pic_p=${3-false} 4827e4da38afSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4828fc27e79cSmrg my_dlsyms= 4829fc27e79cSmrg 4830e4da38afSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4831fc27e79cSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4832e4da38afSmrg my_dlsyms=${my_outputname}S.c 4833fc27e79cSmrg else 4834fc27e79cSmrg func_error "not configured to extract global symbols from dlpreopened files" 4835fc27e79cSmrg fi 4836fc27e79cSmrg fi 4837659607e0Smrg 4838fc27e79cSmrg if test -n "$my_dlsyms"; then 4839fc27e79cSmrg case $my_dlsyms in 4840fc27e79cSmrg "") ;; 4841fc27e79cSmrg *.c) 4842fc27e79cSmrg # Discover the nlist of each of the dlfiles. 4843e4da38afSmrg nlist=$output_objdir/$my_outputname.nm 4844fc27e79cSmrg 4845fc27e79cSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4846fc27e79cSmrg 4847fc27e79cSmrg # Parse the name list into a source file. 4848fc27e79cSmrg func_verbose "creating $output_objdir/$my_dlsyms" 4849fc27e79cSmrg 4850fc27e79cSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4851e4da38afSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4852e4da38afSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4853fc27e79cSmrg 4854fc27e79cSmrg#ifdef __cplusplus 4855fc27e79cSmrgextern \"C\" { 4856fc27e79cSmrg#endif 4857fc27e79cSmrg 4858e4da38afSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4859bd3a1963Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4860bd3a1963Smrg#endif 4861bd3a1963Smrg 4862bd3a1963Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4863e4da38afSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4864e4da38afSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4865bd3a1963Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4866bd3a1963Smrg# define LT_DLSYM_CONST 4867e4da38afSmrg#elif defined __osf__ 4868bd3a1963Smrg/* This system does not cope well with relocations in const data. */ 4869bd3a1963Smrg# define LT_DLSYM_CONST 4870bd3a1963Smrg#else 4871bd3a1963Smrg# define LT_DLSYM_CONST const 4872bd3a1963Smrg#endif 4873bd3a1963Smrg 4874e4da38afSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4875e4da38afSmrg 4876fc27e79cSmrg/* External symbol declarations for the compiler. */\ 4877fc27e79cSmrg" 4878fc27e79cSmrg 4879e4da38afSmrg if test yes = "$dlself"; then 4880e4da38afSmrg func_verbose "generating symbol list for '$output'" 4881fc27e79cSmrg 4882fc27e79cSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4883fc27e79cSmrg 4884fc27e79cSmrg # Add our own program objects to the symbol list. 4885bd3a1963Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4886fc27e79cSmrg for progfile in $progfiles; do 4887bd3a1963Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4888e4da38afSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4889bd3a1963Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4890fc27e79cSmrg done 4891fc27e79cSmrg 4892fc27e79cSmrg if test -n "$exclude_expsyms"; then 4893fc27e79cSmrg $opt_dry_run || { 4894fc27e79cSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4895fc27e79cSmrg eval '$MV "$nlist"T "$nlist"' 4896fc27e79cSmrg } 4897659607e0Smrg fi 4898659607e0Smrg 4899fc27e79cSmrg if test -n "$export_symbols_regex"; then 4900fc27e79cSmrg $opt_dry_run || { 4901fc27e79cSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4902fc27e79cSmrg eval '$MV "$nlist"T "$nlist"' 4903fc27e79cSmrg } 4904659607e0Smrg fi 4905fc27e79cSmrg 4906fc27e79cSmrg # Prepare the list of exported symbols 4907fc27e79cSmrg if test -z "$export_symbols"; then 4908e4da38afSmrg export_symbols=$output_objdir/$outputname.exp 4909fc27e79cSmrg $opt_dry_run || { 4910fc27e79cSmrg $RM $export_symbols 4911e4da38afSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4912fc27e79cSmrg case $host in 4913fc27e79cSmrg *cygwin* | *mingw* | *cegcc* ) 4914fc27e79cSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4915fc27e79cSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4916fc27e79cSmrg ;; 4917659607e0Smrg esac 4918fc27e79cSmrg } 4919fc27e79cSmrg else 4920fc27e79cSmrg $opt_dry_run || { 4921e4da38afSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4922fc27e79cSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4923fc27e79cSmrg eval '$MV "$nlist"T "$nlist"' 4924fc27e79cSmrg case $host in 4925bd3a1963Smrg *cygwin* | *mingw* | *cegcc* ) 4926fc27e79cSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4927fc27e79cSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4928fc27e79cSmrg ;; 4929659607e0Smrg esac 4930fc27e79cSmrg } 4931659607e0Smrg fi 4932fc27e79cSmrg fi 4933659607e0Smrg 4934fc27e79cSmrg for dlprefile in $dlprefiles; do 4935e4da38afSmrg func_verbose "extracting global C symbols from '$dlprefile'" 4936fc27e79cSmrg func_basename "$dlprefile" 4937e4da38afSmrg name=$func_basename_result 4938bd3a1963Smrg case $host in 4939bd3a1963Smrg *cygwin* | *mingw* | *cegcc* ) 4940bd3a1963Smrg # if an import library, we need to obtain dlname 4941bd3a1963Smrg if func_win32_import_lib_p "$dlprefile"; then 4942bd3a1963Smrg func_tr_sh "$dlprefile" 4943bd3a1963Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 4944e4da38afSmrg dlprefile_dlbasename= 4945bd3a1963Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4946bd3a1963Smrg # Use subshell, to avoid clobbering current variable values 4947bd3a1963Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4948e4da38afSmrg if test -n "$dlprefile_dlname"; then 4949bd3a1963Smrg func_basename "$dlprefile_dlname" 4950e4da38afSmrg dlprefile_dlbasename=$func_basename_result 4951bd3a1963Smrg else 4952bd3a1963Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 4953bd3a1963Smrg $sharedlib_from_linklib_cmd "$dlprefile" 4954bd3a1963Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4955bd3a1963Smrg fi 4956bd3a1963Smrg fi 4957bd3a1963Smrg $opt_dry_run || { 4958e4da38afSmrg if test -n "$dlprefile_dlbasename"; then 4959bd3a1963Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4960bd3a1963Smrg else 4961bd3a1963Smrg func_warning "Could not compute DLL name from $name" 4962bd3a1963Smrg eval '$ECHO ": $name " >> "$nlist"' 4963bd3a1963Smrg fi 4964bd3a1963Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4965bd3a1963Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4966bd3a1963Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4967bd3a1963Smrg } 4968bd3a1963Smrg else # not an import lib 4969bd3a1963Smrg $opt_dry_run || { 4970bd3a1963Smrg eval '$ECHO ": $name " >> "$nlist"' 4971bd3a1963Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4972bd3a1963Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4973bd3a1963Smrg } 4974bd3a1963Smrg fi 4975bd3a1963Smrg ;; 4976bd3a1963Smrg *) 4977bd3a1963Smrg $opt_dry_run || { 4978bd3a1963Smrg eval '$ECHO ": $name " >> "$nlist"' 4979bd3a1963Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4980bd3a1963Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4981bd3a1963Smrg } 4982bd3a1963Smrg ;; 4983bd3a1963Smrg esac 4984fc27e79cSmrg done 4985659607e0Smrg 4986fc27e79cSmrg $opt_dry_run || { 4987fc27e79cSmrg # Make sure we have at least an empty file. 4988fc27e79cSmrg test -f "$nlist" || : > "$nlist" 4989659607e0Smrg 4990fc27e79cSmrg if test -n "$exclude_expsyms"; then 4991fc27e79cSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4992fc27e79cSmrg $MV "$nlist"T "$nlist" 4993659607e0Smrg fi 4994659607e0Smrg 4995fc27e79cSmrg # Try sorting and uniquifying the output. 4996fc27e79cSmrg if $GREP -v "^: " < "$nlist" | 4997fc27e79cSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4998fc27e79cSmrg sort -k 3 4999659607e0Smrg else 5000fc27e79cSmrg sort +2 5001fc27e79cSmrg fi | 5002fc27e79cSmrg uniq > "$nlist"S; then 5003fc27e79cSmrg : 5004659607e0Smrg else 5005fc27e79cSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 5006659607e0Smrg fi 5007659607e0Smrg 5008fc27e79cSmrg if test -f "$nlist"S; then 5009fc27e79cSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 5010659607e0Smrg else 5011bd3a1963Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 5012659607e0Smrg fi 5013659607e0Smrg 5014e4da38afSmrg func_show_eval '$RM "${nlist}I"' 5015e4da38afSmrg if test -n "$global_symbol_to_import"; then 5016e4da38afSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 5017e4da38afSmrg fi 5018e4da38afSmrg 5019bd3a1963Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5020659607e0Smrg 5021fc27e79cSmrg/* The mapping between symbol names and symbols. */ 5022fc27e79cSmrgtypedef struct { 5023fc27e79cSmrg const char *name; 5024fc27e79cSmrg void *address; 5025fc27e79cSmrg} lt_dlsymlist; 5026bd3a1963Smrgextern LT_DLSYM_CONST lt_dlsymlist 5027e4da38afSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 5028e4da38afSmrg" 5029e4da38afSmrg 5030e4da38afSmrg if test -s "$nlist"I; then 5031e4da38afSmrg echo >> "$output_objdir/$my_dlsyms" "\ 5032e4da38afSmrgstatic void lt_syminit(void) 5033e4da38afSmrg{ 5034e4da38afSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 5035e4da38afSmrg for (; symbol->name; ++symbol) 5036e4da38afSmrg {" 5037e4da38afSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 5038e4da38afSmrg echo >> "$output_objdir/$my_dlsyms" "\ 5039e4da38afSmrg } 5040e4da38afSmrg}" 5041e4da38afSmrg fi 5042e4da38afSmrg echo >> "$output_objdir/$my_dlsyms" "\ 5043bd3a1963SmrgLT_DLSYM_CONST lt_dlsymlist 5044fc27e79cSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 5045e4da38afSmrg{ {\"$my_originator\", (void *) 0}," 5046e4da38afSmrg 5047e4da38afSmrg if test -s "$nlist"I; then 5048e4da38afSmrg echo >> "$output_objdir/$my_dlsyms" "\ 5049e4da38afSmrg {\"@INIT@\", (void *) <_syminit}," 5050e4da38afSmrg fi 5051fc27e79cSmrg 5052fc27e79cSmrg case $need_lib_prefix in 5053fc27e79cSmrg no) 5054fc27e79cSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 5055fc27e79cSmrg ;; 5056fc27e79cSmrg *) 5057fc27e79cSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 5058fc27e79cSmrg ;; 5059fc27e79cSmrg esac 5060bd3a1963Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5061fc27e79cSmrg {0, (void *) 0} 5062fc27e79cSmrg}; 5063fc27e79cSmrg 5064fc27e79cSmrg/* This works around a problem in FreeBSD linker */ 5065fc27e79cSmrg#ifdef FREEBSD_WORKAROUND 5066fc27e79cSmrgstatic const void *lt_preloaded_setup() { 5067fc27e79cSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 5068fc27e79cSmrg} 5069fc27e79cSmrg#endif 5070fc27e79cSmrg 5071fc27e79cSmrg#ifdef __cplusplus 5072fc27e79cSmrg} 5073fc27e79cSmrg#endif\ 5074fc27e79cSmrg" 5075fc27e79cSmrg } # !$opt_dry_run 5076fc27e79cSmrg 5077fc27e79cSmrg pic_flag_for_symtable= 5078fc27e79cSmrg case "$compile_command " in 5079fc27e79cSmrg *" -static "*) ;; 5080fc27e79cSmrg *) 5081fc27e79cSmrg case $host in 5082fc27e79cSmrg # compiling the symbol table file with pic_flag works around 5083fc27e79cSmrg # a FreeBSD bug that causes programs to crash when -lm is 5084fc27e79cSmrg # linked before any other PIC object. But we must not use 5085fc27e79cSmrg # pic_flag when linking with -static. The problem exists in 5086fc27e79cSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 5087a73597f9Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 5088fc27e79cSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 5089fc27e79cSmrg *-*-hpux*) 5090fc27e79cSmrg pic_flag_for_symtable=" $pic_flag" ;; 5091fc27e79cSmrg *) 5092e4da38afSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 5093fc27e79cSmrg ;; 5094fc27e79cSmrg esac 5095fc27e79cSmrg ;; 5096fc27e79cSmrg esac 5097fc27e79cSmrg symtab_cflags= 5098fc27e79cSmrg for arg in $LTCFLAGS; do 5099fc27e79cSmrg case $arg in 5100fc27e79cSmrg -pie | -fpie | -fPIE) ;; 5101bd3a1963Smrg *) func_append symtab_cflags " $arg" ;; 5102fc27e79cSmrg esac 5103fc27e79cSmrg done 5104659607e0Smrg 5105fc27e79cSmrg # Now compile the dynamic symbol file. 5106fc27e79cSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 5107659607e0Smrg 5108fc27e79cSmrg # Clean up the generated files. 5109e4da38afSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 5110fc27e79cSmrg 5111fc27e79cSmrg # Transform the symbol file into the correct name. 5112e4da38afSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 5113fc27e79cSmrg case $host in 5114fc27e79cSmrg *cygwin* | *mingw* | *cegcc* ) 5115fc27e79cSmrg if test -f "$output_objdir/$my_outputname.def"; then 5116bd3a1963Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5117bd3a1963Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5118fc27e79cSmrg else 5119bd3a1963Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5120bd3a1963Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5121fc27e79cSmrg fi 5122fc27e79cSmrg ;; 5123fc27e79cSmrg *) 5124bd3a1963Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5125bd3a1963Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5126659607e0Smrg ;; 5127659607e0Smrg esac 5128fc27e79cSmrg ;; 5129fc27e79cSmrg *) 5130e4da38afSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 5131fc27e79cSmrg ;; 5132fc27e79cSmrg esac 5133fc27e79cSmrg else 5134fc27e79cSmrg # We keep going just in case the user didn't refer to 5135fc27e79cSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 5136fc27e79cSmrg # really was required. 5137fc27e79cSmrg 5138fc27e79cSmrg # Nullify the symbol file. 5139bd3a1963Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 5140bd3a1963Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 5141659607e0Smrg fi 5142fc27e79cSmrg} 5143659607e0Smrg 5144e4da38afSmrg# func_cygming_gnu_implib_p ARG 5145e4da38afSmrg# This predicate returns with zero status (TRUE) if 5146e4da38afSmrg# ARG is a GNU/binutils-style import library. Returns 5147e4da38afSmrg# with nonzero status (FALSE) otherwise. 5148e4da38afSmrgfunc_cygming_gnu_implib_p () 5149e4da38afSmrg{ 5150e4da38afSmrg $debug_cmd 5151e4da38afSmrg 5152e4da38afSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5153e4da38afSmrg 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)$'` 5154e4da38afSmrg test -n "$func_cygming_gnu_implib_tmp" 5155e4da38afSmrg} 5156e4da38afSmrg 5157e4da38afSmrg# func_cygming_ms_implib_p ARG 5158e4da38afSmrg# This predicate returns with zero status (TRUE) if 5159e4da38afSmrg# ARG is an MS-style import library. Returns 5160e4da38afSmrg# with nonzero status (FALSE) otherwise. 5161e4da38afSmrgfunc_cygming_ms_implib_p () 5162e4da38afSmrg{ 5163e4da38afSmrg $debug_cmd 5164e4da38afSmrg 5165e4da38afSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5166e4da38afSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 5167e4da38afSmrg test -n "$func_cygming_ms_implib_tmp" 5168e4da38afSmrg} 5169e4da38afSmrg 5170fc27e79cSmrg# func_win32_libid arg 5171fc27e79cSmrg# return the library type of file 'arg' 5172fc27e79cSmrg# 5173fc27e79cSmrg# Need a lot of goo to handle *both* DLLs and import libs 5174fc27e79cSmrg# Has to be a shell function in order to 'eat' the argument 5175fc27e79cSmrg# that is supplied when $file_magic_command is called. 5176bd3a1963Smrg# Despite the name, also deal with 64 bit binaries. 5177fc27e79cSmrgfunc_win32_libid () 5178fc27e79cSmrg{ 5179e4da38afSmrg $debug_cmd 5180e4da38afSmrg 5181e4da38afSmrg win32_libid_type=unknown 5182fc27e79cSmrg win32_fileres=`file -L $1 2>/dev/null` 5183fc27e79cSmrg case $win32_fileres in 5184fc27e79cSmrg *ar\ archive\ import\ library*) # definitely import 5185fc27e79cSmrg win32_libid_type="x86 archive import" 5186fc27e79cSmrg ;; 5187fc27e79cSmrg *ar\ archive*) # could be an import, or static 5188bd3a1963Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 5189fc27e79cSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 5190bd3a1963Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 5191e4da38afSmrg case $nm_interface in 5192e4da38afSmrg "MS dumpbin") 5193e4da38afSmrg if func_cygming_ms_implib_p "$1" || 5194e4da38afSmrg func_cygming_gnu_implib_p "$1" 5195e4da38afSmrg then 5196e4da38afSmrg win32_nmres=import 5197e4da38afSmrg else 5198e4da38afSmrg win32_nmres= 5199e4da38afSmrg fi 5200e4da38afSmrg ;; 5201e4da38afSmrg *) 5202e4da38afSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5203e4da38afSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 5204e4da38afSmrg $SED -n -e ' 5205fc27e79cSmrg 1,100{ 5206fc27e79cSmrg / I /{ 5207e4da38afSmrg s|.*|import| 5208fc27e79cSmrg p 5209fc27e79cSmrg q 5210fc27e79cSmrg } 5211fc27e79cSmrg }'` 5212e4da38afSmrg ;; 5213e4da38afSmrg esac 5214fc27e79cSmrg case $win32_nmres in 5215fc27e79cSmrg import*) win32_libid_type="x86 archive import";; 5216fc27e79cSmrg *) win32_libid_type="x86 archive static";; 5217fc27e79cSmrg esac 5218fc27e79cSmrg fi 5219fc27e79cSmrg ;; 5220fc27e79cSmrg *DLL*) 5221fc27e79cSmrg win32_libid_type="x86 DLL" 5222fc27e79cSmrg ;; 5223fc27e79cSmrg *executable*) # but shell scripts are "executable" too... 5224fc27e79cSmrg case $win32_fileres in 5225fc27e79cSmrg *MS\ Windows\ PE\ Intel*) 5226fc27e79cSmrg win32_libid_type="x86 DLL" 5227fc27e79cSmrg ;; 5228fc27e79cSmrg esac 5229fc27e79cSmrg ;; 5230fc27e79cSmrg esac 5231fc27e79cSmrg $ECHO "$win32_libid_type" 5232fc27e79cSmrg} 5233659607e0Smrg 5234bd3a1963Smrg# func_cygming_dll_for_implib ARG 5235bd3a1963Smrg# 5236bd3a1963Smrg# Platform-specific function to extract the 5237bd3a1963Smrg# name of the DLL associated with the specified 5238bd3a1963Smrg# import library ARG. 5239bd3a1963Smrg# Invoked by eval'ing the libtool variable 5240bd3a1963Smrg# $sharedlib_from_linklib_cmd 5241bd3a1963Smrg# Result is available in the variable 5242bd3a1963Smrg# $sharedlib_from_linklib_result 5243bd3a1963Smrgfunc_cygming_dll_for_implib () 5244bd3a1963Smrg{ 5245e4da38afSmrg $debug_cmd 5246e4da38afSmrg 5247bd3a1963Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 5248bd3a1963Smrg} 5249bd3a1963Smrg 5250bd3a1963Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 5251bd3a1963Smrg# 5252bd3a1963Smrg# The is the core of a fallback implementation of a 5253bd3a1963Smrg# platform-specific function to extract the name of the 5254bd3a1963Smrg# DLL associated with the specified import library LIBNAME. 5255bd3a1963Smrg# 5256bd3a1963Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5257bd3a1963Smrg# on the platform and compiler that created the implib. 5258bd3a1963Smrg# 5259bd3a1963Smrg# Echos the name of the DLL associated with the 5260bd3a1963Smrg# specified import library. 5261bd3a1963Smrgfunc_cygming_dll_for_implib_fallback_core () 5262bd3a1963Smrg{ 5263e4da38afSmrg $debug_cmd 5264e4da38afSmrg 5265bd3a1963Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5266bd3a1963Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5267bd3a1963Smrg $SED '/^Contents of section '"$match_literal"':/{ 5268bd3a1963Smrg # Place marker at beginning of archive member dllname section 5269bd3a1963Smrg s/.*/====MARK====/ 5270bd3a1963Smrg p 5271bd3a1963Smrg d 5272bd3a1963Smrg } 5273bd3a1963Smrg # These lines can sometimes be longer than 43 characters, but 5274bd3a1963Smrg # are always uninteresting 5275bd3a1963Smrg /:[ ]*file format pe[i]\{,1\}-/d 5276bd3a1963Smrg /^In archive [^:]*:/d 5277bd3a1963Smrg # Ensure marker is printed 5278bd3a1963Smrg /^====MARK====/p 5279bd3a1963Smrg # Remove all lines with less than 43 characters 5280bd3a1963Smrg /^.\{43\}/!d 5281bd3a1963Smrg # From remaining lines, remove first 43 characters 5282bd3a1963Smrg s/^.\{43\}//' | 5283bd3a1963Smrg $SED -n ' 5284bd3a1963Smrg # Join marker and all lines until next marker into a single line 5285bd3a1963Smrg /^====MARK====/ b para 5286bd3a1963Smrg H 5287bd3a1963Smrg $ b para 5288bd3a1963Smrg b 5289bd3a1963Smrg :para 5290bd3a1963Smrg x 5291bd3a1963Smrg s/\n//g 5292bd3a1963Smrg # Remove the marker 5293bd3a1963Smrg s/^====MARK====// 5294bd3a1963Smrg # Remove trailing dots and whitespace 5295bd3a1963Smrg s/[\. \t]*$// 5296bd3a1963Smrg # Print 5297bd3a1963Smrg /./p' | 5298bd3a1963Smrg # we now have a list, one entry per line, of the stringified 5299bd3a1963Smrg # contents of the appropriate section of all members of the 5300e4da38afSmrg # archive that possess that section. Heuristic: eliminate 5301e4da38afSmrg # all those that have a first or second character that is 5302bd3a1963Smrg # a '.' (that is, objdump's representation of an unprintable 5303bd3a1963Smrg # character.) This should work for all archives with less than 5304bd3a1963Smrg # 0x302f exports -- but will fail for DLLs whose name actually 5305bd3a1963Smrg # begins with a literal '.' or a single character followed by 5306bd3a1963Smrg # a '.'. 5307bd3a1963Smrg # 5308bd3a1963Smrg # Of those that remain, print the first one. 5309bd3a1963Smrg $SED -e '/^\./d;/^.\./d;q' 5310bd3a1963Smrg} 5311bd3a1963Smrg 5312bd3a1963Smrg# func_cygming_dll_for_implib_fallback ARG 5313bd3a1963Smrg# Platform-specific function to extract the 5314bd3a1963Smrg# name of the DLL associated with the specified 5315bd3a1963Smrg# import library ARG. 5316bd3a1963Smrg# 5317bd3a1963Smrg# This fallback implementation is for use when $DLLTOOL 5318bd3a1963Smrg# does not support the --identify-strict option. 5319bd3a1963Smrg# Invoked by eval'ing the libtool variable 5320bd3a1963Smrg# $sharedlib_from_linklib_cmd 5321bd3a1963Smrg# Result is available in the variable 5322bd3a1963Smrg# $sharedlib_from_linklib_result 5323bd3a1963Smrgfunc_cygming_dll_for_implib_fallback () 5324bd3a1963Smrg{ 5325e4da38afSmrg $debug_cmd 5326e4da38afSmrg 5327e4da38afSmrg if func_cygming_gnu_implib_p "$1"; then 5328bd3a1963Smrg # binutils import library 5329bd3a1963Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5330e4da38afSmrg elif func_cygming_ms_implib_p "$1"; then 5331bd3a1963Smrg # ms-generated import library 5332bd3a1963Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5333bd3a1963Smrg else 5334bd3a1963Smrg # unknown 5335e4da38afSmrg sharedlib_from_linklib_result= 5336bd3a1963Smrg fi 5337bd3a1963Smrg} 5338659607e0Smrg 5339659607e0Smrg 5340fc27e79cSmrg# func_extract_an_archive dir oldlib 5341fc27e79cSmrgfunc_extract_an_archive () 5342fc27e79cSmrg{ 5343e4da38afSmrg $debug_cmd 5344e4da38afSmrg 5345e4da38afSmrg f_ex_an_ar_dir=$1; shift 5346e4da38afSmrg f_ex_an_ar_oldlib=$1 5347e4da38afSmrg if test yes = "$lock_old_archive_extraction"; then 5348bd3a1963Smrg lockfile=$f_ex_an_ar_oldlib.lock 5349bd3a1963Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5350bd3a1963Smrg func_echo "Waiting for $lockfile to be removed" 5351bd3a1963Smrg sleep 2 5352bd3a1963Smrg done 5353bd3a1963Smrg fi 5354bd3a1963Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5355bd3a1963Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 5356e4da38afSmrg if test yes = "$lock_old_archive_extraction"; then 5357bd3a1963Smrg $opt_dry_run || rm -f "$lockfile" 5358bd3a1963Smrg fi 5359fc27e79cSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5360fc27e79cSmrg : 5361fc27e79cSmrg else 5362fc27e79cSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5363fc27e79cSmrg fi 5364fc27e79cSmrg} 5365659607e0Smrg 5366659607e0Smrg 5367fc27e79cSmrg# func_extract_archives gentop oldlib ... 5368fc27e79cSmrgfunc_extract_archives () 5369fc27e79cSmrg{ 5370e4da38afSmrg $debug_cmd 5371e4da38afSmrg 5372e4da38afSmrg my_gentop=$1; shift 5373fc27e79cSmrg my_oldlibs=${1+"$@"} 5374e4da38afSmrg my_oldobjs= 5375e4da38afSmrg my_xlib= 5376e4da38afSmrg my_xabs= 5377e4da38afSmrg my_xdir= 5378659607e0Smrg 5379fc27e79cSmrg for my_xlib in $my_oldlibs; do 5380fc27e79cSmrg # Extract the objects. 5381fc27e79cSmrg case $my_xlib in 5382e4da38afSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5383fc27e79cSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 5384fc27e79cSmrg esac 5385fc27e79cSmrg func_basename "$my_xlib" 5386e4da38afSmrg my_xlib=$func_basename_result 5387fc27e79cSmrg my_xlib_u=$my_xlib 5388fc27e79cSmrg while :; do 5389fc27e79cSmrg case " $extracted_archives " in 5390fc27e79cSmrg *" $my_xlib_u "*) 5391fc27e79cSmrg func_arith $extracted_serial + 1 5392fc27e79cSmrg extracted_serial=$func_arith_result 5393fc27e79cSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5394fc27e79cSmrg *) break ;; 5395fc27e79cSmrg esac 5396fc27e79cSmrg done 5397fc27e79cSmrg extracted_archives="$extracted_archives $my_xlib_u" 5398e4da38afSmrg my_xdir=$my_gentop/$my_xlib_u 5399659607e0Smrg 5400fc27e79cSmrg func_mkdir_p "$my_xdir" 5401659607e0Smrg 5402fc27e79cSmrg case $host in 5403fc27e79cSmrg *-darwin*) 5404fc27e79cSmrg func_verbose "Extracting $my_xabs" 5405fc27e79cSmrg # Do not bother doing anything if just a dry run 5406fc27e79cSmrg $opt_dry_run || { 5407fc27e79cSmrg darwin_orig_dir=`pwd` 5408fc27e79cSmrg cd $my_xdir || exit $? 5409fc27e79cSmrg darwin_archive=$my_xabs 5410fc27e79cSmrg darwin_curdir=`pwd` 5411e4da38afSmrg func_basename "$darwin_archive" 5412e4da38afSmrg darwin_base_archive=$func_basename_result 5413fc27e79cSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5414fc27e79cSmrg if test -n "$darwin_arches"; then 5415fc27e79cSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5416fc27e79cSmrg darwin_arch= 5417fc27e79cSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5418e4da38afSmrg for darwin_arch in $darwin_arches; do 5419e4da38afSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5420e4da38afSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5421e4da38afSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5422e4da38afSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5423fc27e79cSmrg cd "$darwin_curdir" 5424e4da38afSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5425fc27e79cSmrg done # $darwin_arches 5426fc27e79cSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5427e4da38afSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5428fc27e79cSmrg darwin_file= 5429fc27e79cSmrg darwin_files= 5430fc27e79cSmrg for darwin_file in $darwin_filelist; do 5431bd3a1963Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5432fc27e79cSmrg $LIPO -create -output "$darwin_file" $darwin_files 5433fc27e79cSmrg done # $darwin_filelist 5434fc27e79cSmrg $RM -rf unfat-$$ 5435fc27e79cSmrg cd "$darwin_orig_dir" 5436fc27e79cSmrg else 5437fc27e79cSmrg cd $darwin_orig_dir 5438fc27e79cSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 5439fc27e79cSmrg fi # $darwin_arches 5440fc27e79cSmrg } # !$opt_dry_run 5441fc27e79cSmrg ;; 5442fc27e79cSmrg *) 5443fc27e79cSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 5444fc27e79cSmrg ;; 5445659607e0Smrg esac 5446bd3a1963Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5447fc27e79cSmrg done 5448659607e0Smrg 5449e4da38afSmrg func_extract_archives_result=$my_oldobjs 5450fc27e79cSmrg} 5451659607e0Smrg 5452659607e0Smrg 5453bd3a1963Smrg# func_emit_wrapper [arg=no] 5454bd3a1963Smrg# 5455bd3a1963Smrg# Emit a libtool wrapper script on stdout. 5456bd3a1963Smrg# Don't directly open a file because we may want to 5457bd3a1963Smrg# incorporate the script contents within a cygwin/mingw 5458bd3a1963Smrg# wrapper executable. Must ONLY be called from within 5459bd3a1963Smrg# func_mode_link because it depends on a number of variables 5460bd3a1963Smrg# set therein. 5461fc27e79cSmrg# 5462bd3a1963Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5463bd3a1963Smrg# variable will take. If 'yes', then the emitted script 5464e4da38afSmrg# will assume that the directory where it is stored is 5465bd3a1963Smrg# the $objdir directory. This is a cygwin/mingw-specific 5466bd3a1963Smrg# behavior. 5467bd3a1963Smrgfunc_emit_wrapper () 5468fc27e79cSmrg{ 5469bd3a1963Smrg func_emit_wrapper_arg1=${1-no} 5470659607e0Smrg 5471fc27e79cSmrg $ECHO "\ 5472fc27e79cSmrg#! $SHELL 5473659607e0Smrg 5474fc27e79cSmrg# $output - temporary wrapper script for $objdir/$outputname 5475e4da38afSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5476fc27e79cSmrg# 5477fc27e79cSmrg# The $output program cannot be directly executed until all the libtool 5478fc27e79cSmrg# libraries that it depends on are installed. 5479fc27e79cSmrg# 5480fc27e79cSmrg# This wrapper script should never be moved out of the build directory. 5481fc27e79cSmrg# If it is, it will not operate correctly. 5482659607e0Smrg 5483fc27e79cSmrg# Sed substitution that helps us do robust quoting. It backslashifies 5484fc27e79cSmrg# metacharacters that are still active within double-quoted strings. 5485fc27e79cSmrgsed_quote_subst='$sed_quote_subst' 5486659607e0Smrg 5487fc27e79cSmrg# Be Bourne compatible 5488fc27e79cSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5489fc27e79cSmrg emulate sh 5490fc27e79cSmrg NULLCMD=: 5491fc27e79cSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5492fc27e79cSmrg # is contrary to our usage. Disable this feature. 5493fc27e79cSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5494fc27e79cSmrg setopt NO_GLOB_SUBST 5495fc27e79cSmrgelse 5496fc27e79cSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5497fc27e79cSmrgfi 5498fc27e79cSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5499fc27e79cSmrgDUALCASE=1; export DUALCASE # for MKS sh 5500659607e0Smrg 5501fc27e79cSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5502fc27e79cSmrg# if CDPATH is set. 5503fc27e79cSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5504659607e0Smrg 5505fc27e79cSmrgrelink_command=\"$relink_command\" 5506659607e0Smrg 5507fc27e79cSmrg# This environment variable determines our operation mode. 5508fc27e79cSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5509fc27e79cSmrg # install mode needs the following variables: 5510fc27e79cSmrg generated_by_libtool_version='$macro_version' 5511fc27e79cSmrg notinst_deplibs='$notinst_deplibs' 5512fc27e79cSmrgelse 5513fc27e79cSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5514fc27e79cSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5515bd3a1963Smrg file=\"\$0\"" 5516bd3a1963Smrg 5517370b807fSmrg func_quote_arg pretty "$ECHO" 5518370b807fSmrg qECHO=$func_quote_arg_result 5519bd3a1963Smrg $ECHO "\ 5520bd3a1963Smrg 5521bd3a1963Smrg# A function that is used when there is no print builtin or printf. 5522bd3a1963Smrgfunc_fallback_echo () 5523bd3a1963Smrg{ 5524bd3a1963Smrg eval 'cat <<_LTECHO_EOF 5525bd3a1963Smrg\$1 5526bd3a1963Smrg_LTECHO_EOF' 5527bd3a1963Smrg} 5528370b807fSmrg ECHO=$qECHO 5529bd3a1963Smrg fi 5530bd3a1963Smrg 5531bd3a1963Smrg# Very basic option parsing. These options are (a) specific to 5532bd3a1963Smrg# the libtool wrapper, (b) are identical between the wrapper 5533e4da38afSmrg# /script/ and the wrapper /executable/ that is used only on 5534bd3a1963Smrg# windows platforms, and (c) all begin with the string "--lt-" 5535e4da38afSmrg# (application programs are unlikely to have options that match 5536bd3a1963Smrg# this pattern). 5537bd3a1963Smrg# 5538bd3a1963Smrg# There are only two supported options: --lt-debug and 5539bd3a1963Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 5540bd3a1963Smrg# 5541bd3a1963Smrg# The first argument to this parsing function should be the 5542bd3a1963Smrg# script's $0 value, followed by "$@". 5543bd3a1963Smrglt_option_debug= 5544bd3a1963Smrgfunc_parse_lt_options () 5545bd3a1963Smrg{ 5546bd3a1963Smrg lt_script_arg0=\$0 5547bd3a1963Smrg shift 5548bd3a1963Smrg for lt_opt 5549bd3a1963Smrg do 5550bd3a1963Smrg case \"\$lt_opt\" in 5551bd3a1963Smrg --lt-debug) lt_option_debug=1 ;; 5552bd3a1963Smrg --lt-dump-script) 5553bd3a1963Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5554bd3a1963Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5555bd3a1963Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5556bd3a1963Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 5557bd3a1963Smrg exit 0 5558bd3a1963Smrg ;; 5559bd3a1963Smrg --lt-*) 5560bd3a1963Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5561bd3a1963Smrg exit 1 5562bd3a1963Smrg ;; 5563bd3a1963Smrg esac 5564bd3a1963Smrg done 5565bd3a1963Smrg 5566bd3a1963Smrg # Print the debug banner immediately: 5567bd3a1963Smrg if test -n \"\$lt_option_debug\"; then 5568e4da38afSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5569bd3a1963Smrg fi 5570bd3a1963Smrg} 5571bd3a1963Smrg 5572bd3a1963Smrg# Used when --lt-debug. Prints its arguments to stdout 5573bd3a1963Smrg# (redirection is the responsibility of the caller) 5574bd3a1963Smrgfunc_lt_dump_args () 5575bd3a1963Smrg{ 5576bd3a1963Smrg lt_dump_args_N=1; 5577bd3a1963Smrg for lt_arg 5578bd3a1963Smrg do 5579e4da38afSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5580bd3a1963Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5581bd3a1963Smrg done 5582bd3a1963Smrg} 5583bd3a1963Smrg 5584bd3a1963Smrg# Core function for launching the target application 5585bd3a1963Smrgfunc_exec_program_core () 5586bd3a1963Smrg{ 5587fc27e79cSmrg" 5588bd3a1963Smrg case $host in 5589bd3a1963Smrg # Backslashes separate directories on plain windows 5590bd3a1963Smrg *-*-mingw | *-*-os2* | *-cegcc*) 5591bd3a1963Smrg $ECHO "\ 5592bd3a1963Smrg if test -n \"\$lt_option_debug\"; then 5593e4da38afSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5594bd3a1963Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5595bd3a1963Smrg fi 5596bd3a1963Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5597bd3a1963Smrg" 5598bd3a1963Smrg ;; 5599bd3a1963Smrg 5600bd3a1963Smrg *) 5601bd3a1963Smrg $ECHO "\ 5602bd3a1963Smrg if test -n \"\$lt_option_debug\"; then 5603e4da38afSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5604bd3a1963Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5605bd3a1963Smrg fi 5606bd3a1963Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5607bd3a1963Smrg" 5608bd3a1963Smrg ;; 5609bd3a1963Smrg esac 5610bd3a1963Smrg $ECHO "\ 5611bd3a1963Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5612bd3a1963Smrg exit 1 5613bd3a1963Smrg} 5614bd3a1963Smrg 5615bd3a1963Smrg# A function to encapsulate launching the target application 5616bd3a1963Smrg# Strips options in the --lt-* namespace from \$@ and 5617bd3a1963Smrg# launches target application with the remaining arguments. 5618bd3a1963Smrgfunc_exec_program () 5619bd3a1963Smrg{ 5620a73597f9Smrg case \" \$* \" in 5621a73597f9Smrg *\\ --lt-*) 5622a73597f9Smrg for lt_wr_arg 5623a73597f9Smrg do 5624a73597f9Smrg case \$lt_wr_arg in 5625a73597f9Smrg --lt-*) ;; 5626a73597f9Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5627a73597f9Smrg esac 5628a73597f9Smrg shift 5629a73597f9Smrg done ;; 5630a73597f9Smrg esac 5631bd3a1963Smrg func_exec_program_core \${1+\"\$@\"} 5632bd3a1963Smrg} 5633bd3a1963Smrg 5634bd3a1963Smrg # Parse options 5635bd3a1963Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5636659607e0Smrg 5637fc27e79cSmrg # Find the directory that this script lives in. 5638bd3a1963Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5639fc27e79cSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5640659607e0Smrg 5641fc27e79cSmrg # Follow symbolic links until we get to the real thisdir. 5642bd3a1963Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5643fc27e79cSmrg while test -n \"\$file\"; do 5644bd3a1963Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5645659607e0Smrg 5646fc27e79cSmrg # If there was a directory component, then change thisdir. 5647fc27e79cSmrg if test \"x\$destdir\" != \"x\$file\"; then 5648fc27e79cSmrg case \"\$destdir\" in 5649fc27e79cSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5650fc27e79cSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5651fc27e79cSmrg esac 5652fc27e79cSmrg fi 5653659607e0Smrg 5654bd3a1963Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5655bd3a1963Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5656fc27e79cSmrg done 5657659607e0Smrg 5658fc27e79cSmrg # Usually 'no', except on cygwin/mingw when embedded into 5659fc27e79cSmrg # the cwrapper. 5660bd3a1963Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5661fc27e79cSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5662fc27e79cSmrg # special case for '.' 5663fc27e79cSmrg if test \"\$thisdir\" = \".\"; then 5664fc27e79cSmrg thisdir=\`pwd\` 5665fc27e79cSmrg fi 5666fc27e79cSmrg # remove .libs from thisdir 5667fc27e79cSmrg case \"\$thisdir\" in 5668bd3a1963Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5669fc27e79cSmrg $objdir ) thisdir=. ;; 5670fc27e79cSmrg esac 5671fc27e79cSmrg fi 5672659607e0Smrg 5673fc27e79cSmrg # Try to get the absolute directory name. 5674fc27e79cSmrg absdir=\`cd \"\$thisdir\" && pwd\` 5675fc27e79cSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5676fc27e79cSmrg" 56776aab59a7Smrg 5678e4da38afSmrg if test yes = "$fast_install"; then 5679fc27e79cSmrg $ECHO "\ 5680fc27e79cSmrg program=lt-'$outputname'$exeext 5681fc27e79cSmrg progdir=\"\$thisdir/$objdir\" 5682659607e0Smrg 5683fc27e79cSmrg if test ! -f \"\$progdir/\$program\" || 5684e4da38afSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5685fc27e79cSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5686659607e0Smrg 5687fc27e79cSmrg file=\"\$\$-\$program\" 5688659607e0Smrg 5689fc27e79cSmrg if test ! -d \"\$progdir\"; then 5690fc27e79cSmrg $MKDIR \"\$progdir\" 5691fc27e79cSmrg else 5692fc27e79cSmrg $RM \"\$progdir/\$file\" 5693fc27e79cSmrg fi" 5694659607e0Smrg 5695fc27e79cSmrg $ECHO "\ 5696659607e0Smrg 5697fc27e79cSmrg # relink executable if necessary 5698fc27e79cSmrg if test -n \"\$relink_command\"; then 5699fc27e79cSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5700fc27e79cSmrg else 5701e4da38afSmrg \$ECHO \"\$relink_command_output\" >&2 5702fc27e79cSmrg $RM \"\$progdir/\$file\" 5703fc27e79cSmrg exit 1 5704fc27e79cSmrg fi 5705fc27e79cSmrg fi 5706659607e0Smrg 5707fc27e79cSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5708fc27e79cSmrg { $RM \"\$progdir/\$program\"; 5709fc27e79cSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5710fc27e79cSmrg $RM \"\$progdir/\$file\" 5711fc27e79cSmrg fi" 5712fc27e79cSmrg else 5713fc27e79cSmrg $ECHO "\ 5714fc27e79cSmrg program='$outputname' 5715fc27e79cSmrg progdir=\"\$thisdir/$objdir\" 5716fc27e79cSmrg" 5717fc27e79cSmrg fi 5718659607e0Smrg 5719fc27e79cSmrg $ECHO "\ 5720659607e0Smrg 5721fc27e79cSmrg if test -f \"\$progdir/\$program\"; then" 5722659607e0Smrg 5723bd3a1963Smrg # fixup the dll searchpath if we need to. 5724bd3a1963Smrg # 5725bd3a1963Smrg # Fix the DLL searchpath if we need to. Do this before prepending 5726bd3a1963Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 5727bd3a1963Smrg # libraries must come first. 5728bd3a1963Smrg if test -n "$dllsearchpath"; then 5729bd3a1963Smrg $ECHO "\ 5730bd3a1963Smrg # Add the dll search path components to the executable PATH 5731bd3a1963Smrg PATH=$dllsearchpath:\$PATH 5732bd3a1963Smrg" 5733bd3a1963Smrg fi 5734bd3a1963Smrg 5735fc27e79cSmrg # Export our shlibpath_var if we have one. 5736e4da38afSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5737fc27e79cSmrg $ECHO "\ 5738fc27e79cSmrg # Add our own library path to $shlibpath_var 5739fc27e79cSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5740659607e0Smrg 5741fc27e79cSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 5742fc27e79cSmrg # The second colon is a workaround for a bug in BeOS R4 sed 5743bd3a1963Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5744659607e0Smrg 5745fc27e79cSmrg export $shlibpath_var 5746fc27e79cSmrg" 5747659607e0Smrg fi 5748659607e0Smrg 5749fc27e79cSmrg $ECHO "\ 5750fc27e79cSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5751fc27e79cSmrg # Run the actual program with our arguments. 5752bd3a1963Smrg func_exec_program \${1+\"\$@\"} 5753fc27e79cSmrg fi 5754fc27e79cSmrg else 5755fc27e79cSmrg # The program doesn't exist. 5756e4da38afSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5757fc27e79cSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5758bd3a1963Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5759fc27e79cSmrg exit 1 5760fc27e79cSmrg fi 5761fc27e79cSmrgfi\ 5762fc27e79cSmrg" 5763fc27e79cSmrg} 5764659607e0Smrg 5765659607e0Smrg 5766fc27e79cSmrg# func_emit_cwrapperexe_src 5767fc27e79cSmrg# emit the source code for a wrapper executable on stdout 5768fc27e79cSmrg# Must ONLY be called from within func_mode_link because 5769fc27e79cSmrg# it depends on a number of variable set therein. 5770fc27e79cSmrgfunc_emit_cwrapperexe_src () 5771fc27e79cSmrg{ 5772fc27e79cSmrg cat <<EOF 5773659607e0Smrg 5774fc27e79cSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5775e4da38afSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5776659607e0Smrg 5777fc27e79cSmrg The $output program cannot be directly executed until all the libtool 5778fc27e79cSmrg libraries that it depends on are installed. 5779659607e0Smrg 5780fc27e79cSmrg This wrapper executable should never be moved out of the build directory. 5781fc27e79cSmrg If it is, it will not operate correctly. 5782fc27e79cSmrg*/ 5783fc27e79cSmrgEOF 5784fc27e79cSmrg cat <<"EOF" 5785bd3a1963Smrg#ifdef _MSC_VER 5786bd3a1963Smrg# define _CRT_SECURE_NO_DEPRECATE 1 5787bd3a1963Smrg#endif 5788fc27e79cSmrg#include <stdio.h> 5789fc27e79cSmrg#include <stdlib.h> 5790fc27e79cSmrg#ifdef _MSC_VER 5791fc27e79cSmrg# include <direct.h> 5792fc27e79cSmrg# include <process.h> 5793fc27e79cSmrg# include <io.h> 5794fc27e79cSmrg#else 5795fc27e79cSmrg# include <unistd.h> 5796fc27e79cSmrg# include <stdint.h> 5797fc27e79cSmrg# ifdef __CYGWIN__ 5798fc27e79cSmrg# include <io.h> 5799fc27e79cSmrg# endif 5800fc27e79cSmrg#endif 5801fc27e79cSmrg#include <malloc.h> 5802fc27e79cSmrg#include <stdarg.h> 5803fc27e79cSmrg#include <assert.h> 5804fc27e79cSmrg#include <string.h> 5805fc27e79cSmrg#include <ctype.h> 5806fc27e79cSmrg#include <errno.h> 5807fc27e79cSmrg#include <fcntl.h> 5808fc27e79cSmrg#include <sys/stat.h> 5809fc27e79cSmrg 5810e4da38afSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5811e4da38afSmrg 5812bd3a1963Smrg/* declarations of non-ANSI functions */ 5813e4da38afSmrg#if defined __MINGW32__ 5814bd3a1963Smrg# ifdef __STRICT_ANSI__ 5815bd3a1963Smrgint _putenv (const char *); 5816bd3a1963Smrg# endif 5817e4da38afSmrg#elif defined __CYGWIN__ 5818bd3a1963Smrg# ifdef __STRICT_ANSI__ 5819bd3a1963Smrgchar *realpath (const char *, char *); 5820bd3a1963Smrgint putenv (char *); 5821bd3a1963Smrgint setenv (const char *, const char *, int); 5822bd3a1963Smrg# endif 5823e4da38afSmrg/* #elif defined other_platform || defined ... */ 5824bd3a1963Smrg#endif 5825bd3a1963Smrg 5826bd3a1963Smrg/* portability defines, excluding path handling macros */ 5827e4da38afSmrg#if defined _MSC_VER 5828bd3a1963Smrg# define setmode _setmode 5829bd3a1963Smrg# define stat _stat 5830bd3a1963Smrg# define chmod _chmod 5831bd3a1963Smrg# define getcwd _getcwd 5832bd3a1963Smrg# define putenv _putenv 5833bd3a1963Smrg# define S_IXUSR _S_IEXEC 5834e4da38afSmrg#elif defined __MINGW32__ 5835bd3a1963Smrg# define setmode _setmode 5836bd3a1963Smrg# define stat _stat 5837bd3a1963Smrg# define chmod _chmod 5838bd3a1963Smrg# define getcwd _getcwd 5839bd3a1963Smrg# define putenv _putenv 5840e4da38afSmrg#elif defined __CYGWIN__ 5841bd3a1963Smrg# define HAVE_SETENV 5842bd3a1963Smrg# define FOPEN_WB "wb" 5843e4da38afSmrg/* #elif defined other platforms ... */ 5844bd3a1963Smrg#endif 5845bd3a1963Smrg 5846e4da38afSmrg#if defined PATH_MAX 5847fc27e79cSmrg# define LT_PATHMAX PATH_MAX 5848e4da38afSmrg#elif defined MAXPATHLEN 5849fc27e79cSmrg# define LT_PATHMAX MAXPATHLEN 5850fc27e79cSmrg#else 5851fc27e79cSmrg# define LT_PATHMAX 1024 5852fc27e79cSmrg#endif 5853fc27e79cSmrg 5854fc27e79cSmrg#ifndef S_IXOTH 5855fc27e79cSmrg# define S_IXOTH 0 5856fc27e79cSmrg#endif 5857fc27e79cSmrg#ifndef S_IXGRP 5858fc27e79cSmrg# define S_IXGRP 0 5859fc27e79cSmrg#endif 5860fc27e79cSmrg 5861bd3a1963Smrg/* path handling portability macros */ 5862fc27e79cSmrg#ifndef DIR_SEPARATOR 5863fc27e79cSmrg# define DIR_SEPARATOR '/' 5864fc27e79cSmrg# define PATH_SEPARATOR ':' 5865fc27e79cSmrg#endif 5866fc27e79cSmrg 5867e4da38afSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5868e4da38afSmrg defined __OS2__ 5869fc27e79cSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 5870fc27e79cSmrg# define FOPEN_WB "wb" 5871fc27e79cSmrg# ifndef DIR_SEPARATOR_2 5872fc27e79cSmrg# define DIR_SEPARATOR_2 '\\' 5873fc27e79cSmrg# endif 5874fc27e79cSmrg# ifndef PATH_SEPARATOR_2 5875fc27e79cSmrg# define PATH_SEPARATOR_2 ';' 5876fc27e79cSmrg# endif 5877fc27e79cSmrg#endif 5878fc27e79cSmrg 5879fc27e79cSmrg#ifndef DIR_SEPARATOR_2 5880fc27e79cSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5881fc27e79cSmrg#else /* DIR_SEPARATOR_2 */ 5882fc27e79cSmrg# define IS_DIR_SEPARATOR(ch) \ 5883fc27e79cSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5884fc27e79cSmrg#endif /* DIR_SEPARATOR_2 */ 5885fc27e79cSmrg 5886fc27e79cSmrg#ifndef PATH_SEPARATOR_2 5887fc27e79cSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5888fc27e79cSmrg#else /* PATH_SEPARATOR_2 */ 5889fc27e79cSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5890fc27e79cSmrg#endif /* PATH_SEPARATOR_2 */ 5891fc27e79cSmrg 5892fc27e79cSmrg#ifndef FOPEN_WB 5893fc27e79cSmrg# define FOPEN_WB "w" 5894fc27e79cSmrg#endif 5895fc27e79cSmrg#ifndef _O_BINARY 5896fc27e79cSmrg# define _O_BINARY 0 5897fc27e79cSmrg#endif 5898fc27e79cSmrg 5899fc27e79cSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5900fc27e79cSmrg#define XFREE(stale) do { \ 5901e4da38afSmrg if (stale) { free (stale); stale = 0; } \ 5902fc27e79cSmrg} while (0) 5903fc27e79cSmrg 5904e4da38afSmrg#if defined LT_DEBUGWRAPPER 5905bd3a1963Smrgstatic int lt_debug = 1; 5906fc27e79cSmrg#else 5907bd3a1963Smrgstatic int lt_debug = 0; 5908fc27e79cSmrg#endif 5909fc27e79cSmrg 5910bd3a1963Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5911fc27e79cSmrg 5912fc27e79cSmrgvoid *xmalloc (size_t num); 5913fc27e79cSmrgchar *xstrdup (const char *string); 5914fc27e79cSmrgconst char *base_name (const char *name); 5915fc27e79cSmrgchar *find_executable (const char *wrapper); 5916fc27e79cSmrgchar *chase_symlinks (const char *pathspec); 5917fc27e79cSmrgint make_executable (const char *path); 5918fc27e79cSmrgint check_executable (const char *path); 5919fc27e79cSmrgchar *strendzap (char *str, const char *pat); 5920bd3a1963Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5921bd3a1963Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5922bd3a1963Smrgstatic const char *nonnull (const char *s); 5923bd3a1963Smrgstatic const char *nonempty (const char *s); 5924fc27e79cSmrgvoid lt_setenv (const char *name, const char *value); 5925fc27e79cSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5926fc27e79cSmrgvoid lt_update_exe_path (const char *name, const char *value); 5927fc27e79cSmrgvoid lt_update_lib_path (const char *name, const char *value); 5928bd3a1963Smrgchar **prepare_spawn (char **argv); 5929bd3a1963Smrgvoid lt_dump_script (FILE *f); 5930fc27e79cSmrgEOF 5931fc27e79cSmrg 5932fc27e79cSmrg cat <<EOF 5933e4da38afSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5934e4da38afSmrg# define externally_visible volatile 5935e4da38afSmrg#else 5936e4da38afSmrg# define externally_visible __attribute__((externally_visible)) volatile 5937e4da38afSmrg#endif 5938e4da38afSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5939fc27e79cSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5940fc27e79cSmrgEOF 5941fc27e79cSmrg 5942e4da38afSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5943bd3a1963Smrg func_to_host_path "$temp_rpath" 5944fc27e79cSmrg cat <<EOF 5945bd3a1963Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5946659607e0SmrgEOF 5947659607e0Smrg else 5948fc27e79cSmrg cat <<"EOF" 5949fc27e79cSmrgconst char * LIB_PATH_VALUE = ""; 5950fc27e79cSmrgEOF 5951659607e0Smrg fi 5952fc27e79cSmrg 5953fc27e79cSmrg if test -n "$dllsearchpath"; then 5954bd3a1963Smrg func_to_host_path "$dllsearchpath:" 5955fc27e79cSmrg cat <<EOF 5956fc27e79cSmrgconst char * EXE_PATH_VARNAME = "PATH"; 5957bd3a1963Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5958fc27e79cSmrgEOF 5959659607e0Smrg else 5960fc27e79cSmrg cat <<"EOF" 5961fc27e79cSmrgconst char * EXE_PATH_VARNAME = ""; 5962fc27e79cSmrgconst char * EXE_PATH_VALUE = ""; 5963fc27e79cSmrgEOF 5964659607e0Smrg fi 5965fc27e79cSmrg 5966e4da38afSmrg if test yes = "$fast_install"; then 5967fc27e79cSmrg cat <<EOF 5968fc27e79cSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5969fc27e79cSmrgEOF 5970659607e0Smrg else 5971fc27e79cSmrg cat <<EOF 5972fc27e79cSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5973fc27e79cSmrgEOF 5974659607e0Smrg fi 5975659607e0Smrg 5976659607e0Smrg 5977fc27e79cSmrg cat <<"EOF" 5978659607e0Smrg 5979fc27e79cSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5980659607e0Smrg 5981fc27e79cSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5982fc27e79cSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5983bd3a1963Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5984659607e0Smrg 5985fc27e79cSmrgint 5986fc27e79cSmrgmain (int argc, char *argv[]) 5987fc27e79cSmrg{ 5988fc27e79cSmrg char **newargz; 5989fc27e79cSmrg int newargc; 5990fc27e79cSmrg char *tmp_pathspec; 5991fc27e79cSmrg char *actual_cwrapper_path; 5992fc27e79cSmrg char *actual_cwrapper_name; 5993fc27e79cSmrg char *target_name; 5994fc27e79cSmrg char *lt_argv_zero; 5995e4da38afSmrg int rval = 127; 5996659607e0Smrg 5997fc27e79cSmrg int i; 5998659607e0Smrg 5999fc27e79cSmrg program_name = (char *) xstrdup (base_name (argv[0])); 6000e4da38afSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 6001659607e0Smrg 6002bd3a1963Smrg /* very simple arg parsing; don't want to rely on getopt 6003bd3a1963Smrg * also, copy all non cwrapper options to newargz, except 6004bd3a1963Smrg * argz[0], which is handled differently 6005bd3a1963Smrg */ 6006bd3a1963Smrg newargc=0; 6007fc27e79cSmrg for (i = 1; i < argc; i++) 6008fc27e79cSmrg { 6009e4da38afSmrg if (STREQ (argv[i], dumpscript_opt)) 6010fc27e79cSmrg { 6011fc27e79cSmrgEOF 6012e4da38afSmrg case $host in 6013fc27e79cSmrg *mingw* | *cygwin* ) 6014fc27e79cSmrg # make stdout use "unix" line endings 6015fc27e79cSmrg echo " setmode(1,_O_BINARY);" 6016fc27e79cSmrg ;; 6017fc27e79cSmrg esac 6018659607e0Smrg 6019fc27e79cSmrg cat <<"EOF" 6020bd3a1963Smrg lt_dump_script (stdout); 6021fc27e79cSmrg return 0; 6022fc27e79cSmrg } 6023e4da38afSmrg if (STREQ (argv[i], debug_opt)) 6024bd3a1963Smrg { 6025bd3a1963Smrg lt_debug = 1; 6026bd3a1963Smrg continue; 6027bd3a1963Smrg } 6028e4da38afSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 6029bd3a1963Smrg { 6030bd3a1963Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 6031bd3a1963Smrg namespace, but it is not one of the ones we know about and 6032bd3a1963Smrg have already dealt with, above (inluding dump-script), then 6033bd3a1963Smrg report an error. Otherwise, targets might begin to believe 6034bd3a1963Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 6035bd3a1963Smrg namespace. The first time any user complains about this, we'll 6036bd3a1963Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 6037bd3a1963Smrg or a configure.ac-settable value. 6038bd3a1963Smrg */ 6039bd3a1963Smrg lt_fatal (__FILE__, __LINE__, 6040bd3a1963Smrg "unrecognized %s option: '%s'", 6041bd3a1963Smrg ltwrapper_option_prefix, argv[i]); 6042bd3a1963Smrg } 6043bd3a1963Smrg /* otherwise ... */ 6044bd3a1963Smrg newargz[++newargc] = xstrdup (argv[i]); 6045fc27e79cSmrg } 6046bd3a1963Smrg newargz[++newargc] = NULL; 6047bd3a1963Smrg 6048bd3a1963SmrgEOF 6049bd3a1963Smrg cat <<EOF 6050bd3a1963Smrg /* The GNU banner must be the first non-error debug message */ 6051e4da38afSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 6052bd3a1963SmrgEOF 6053bd3a1963Smrg cat <<"EOF" 6054bd3a1963Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 6055bd3a1963Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 6056659607e0Smrg 6057fc27e79cSmrg tmp_pathspec = find_executable (argv[0]); 6058fc27e79cSmrg if (tmp_pathspec == NULL) 6059bd3a1963Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 6060bd3a1963Smrg lt_debugprintf (__FILE__, __LINE__, 6061bd3a1963Smrg "(main) found exe (before symlink chase) at: %s\n", 6062bd3a1963Smrg tmp_pathspec); 6063fc27e79cSmrg 6064fc27e79cSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 6065bd3a1963Smrg lt_debugprintf (__FILE__, __LINE__, 6066bd3a1963Smrg "(main) found exe (after symlink chase) at: %s\n", 6067bd3a1963Smrg actual_cwrapper_path); 6068fc27e79cSmrg XFREE (tmp_pathspec); 6069fc27e79cSmrg 6070bd3a1963Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 6071fc27e79cSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 6072fc27e79cSmrg 6073fc27e79cSmrg /* wrapper name transforms */ 6074fc27e79cSmrg strendzap (actual_cwrapper_name, ".exe"); 6075fc27e79cSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 6076fc27e79cSmrg XFREE (actual_cwrapper_name); 6077fc27e79cSmrg actual_cwrapper_name = tmp_pathspec; 6078fc27e79cSmrg tmp_pathspec = 0; 6079fc27e79cSmrg 6080fc27e79cSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 6081fc27e79cSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 6082fc27e79cSmrg strendzap (target_name, ".exe"); 6083fc27e79cSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 6084fc27e79cSmrg XFREE (target_name); 6085fc27e79cSmrg target_name = tmp_pathspec; 6086fc27e79cSmrg tmp_pathspec = 0; 6087fc27e79cSmrg 6088bd3a1963Smrg lt_debugprintf (__FILE__, __LINE__, 6089bd3a1963Smrg "(main) libtool target name: %s\n", 6090bd3a1963Smrg target_name); 6091fc27e79cSmrgEOF 6092659607e0Smrg 6093fc27e79cSmrg cat <<EOF 6094fc27e79cSmrg newargz[0] = 6095fc27e79cSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 6096fc27e79cSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 6097fc27e79cSmrg strcpy (newargz[0], actual_cwrapper_path); 6098fc27e79cSmrg strcat (newargz[0], "$objdir"); 6099fc27e79cSmrg strcat (newargz[0], "/"); 6100fc27e79cSmrgEOF 6101659607e0Smrg 6102fc27e79cSmrg cat <<"EOF" 6103fc27e79cSmrg /* stop here, and copy so we don't have to do this twice */ 6104fc27e79cSmrg tmp_pathspec = xstrdup (newargz[0]); 6105659607e0Smrg 6106fc27e79cSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 6107fc27e79cSmrg strcat (newargz[0], actual_cwrapper_name); 6108659607e0Smrg 6109fc27e79cSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 6110fc27e79cSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 6111fc27e79cSmrg XFREE (tmp_pathspec); 6112fc27e79cSmrg tmp_pathspec = NULL; 6113fc27e79cSmrgEOF 6114659607e0Smrg 6115fc27e79cSmrg case $host_os in 6116fc27e79cSmrg mingw*) 6117fc27e79cSmrg cat <<"EOF" 6118fc27e79cSmrg { 6119fc27e79cSmrg char* p; 6120fc27e79cSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 6121fc27e79cSmrg { 6122fc27e79cSmrg *p = '/'; 6123fc27e79cSmrg } 6124fc27e79cSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 6125fc27e79cSmrg { 6126fc27e79cSmrg *p = '/'; 6127fc27e79cSmrg } 6128fc27e79cSmrg } 6129fc27e79cSmrgEOF 6130fc27e79cSmrg ;; 6131fc27e79cSmrg esac 6132659607e0Smrg 6133fc27e79cSmrg cat <<"EOF" 6134fc27e79cSmrg XFREE (target_name); 6135fc27e79cSmrg XFREE (actual_cwrapper_path); 6136fc27e79cSmrg XFREE (actual_cwrapper_name); 6137659607e0Smrg 6138fc27e79cSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 6139fc27e79cSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 6140bd3a1963Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 6141bd3a1963Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 6142bd3a1963Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 6143bd3a1963Smrg libraries must come first. */ 6144fc27e79cSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 6145bd3a1963Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 6146659607e0Smrg 6147bd3a1963Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 6148bd3a1963Smrg nonnull (lt_argv_zero)); 6149fc27e79cSmrg for (i = 0; i < newargc; i++) 6150fc27e79cSmrg { 6151bd3a1963Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 6152bd3a1963Smrg i, nonnull (newargz[i])); 6153fc27e79cSmrg } 6154659607e0Smrg 6155fc27e79cSmrgEOF 6156659607e0Smrg 6157fc27e79cSmrg case $host_os in 6158fc27e79cSmrg mingw*) 6159fc27e79cSmrg cat <<"EOF" 6160fc27e79cSmrg /* execv doesn't actually work on mingw as expected on unix */ 6161bd3a1963Smrg newargz = prepare_spawn (newargz); 6162e4da38afSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 6163fc27e79cSmrg if (rval == -1) 6164fc27e79cSmrg { 6165fc27e79cSmrg /* failed to start process */ 6166bd3a1963Smrg lt_debugprintf (__FILE__, __LINE__, 6167bd3a1963Smrg "(main) failed to launch target \"%s\": %s\n", 6168bd3a1963Smrg lt_argv_zero, nonnull (strerror (errno))); 6169fc27e79cSmrg return 127; 6170fc27e79cSmrg } 6171fc27e79cSmrg return rval; 6172fc27e79cSmrgEOF 6173fc27e79cSmrg ;; 6174fc27e79cSmrg *) 6175fc27e79cSmrg cat <<"EOF" 6176fc27e79cSmrg execv (lt_argv_zero, newargz); 6177fc27e79cSmrg return rval; /* =127, but avoids unused variable warning */ 6178fc27e79cSmrgEOF 6179fc27e79cSmrg ;; 6180fc27e79cSmrg esac 6181659607e0Smrg 6182fc27e79cSmrg cat <<"EOF" 6183fc27e79cSmrg} 6184659607e0Smrg 6185fc27e79cSmrgvoid * 6186fc27e79cSmrgxmalloc (size_t num) 6187fc27e79cSmrg{ 6188fc27e79cSmrg void *p = (void *) malloc (num); 6189fc27e79cSmrg if (!p) 6190bd3a1963Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 6191659607e0Smrg 6192fc27e79cSmrg return p; 6193fc27e79cSmrg} 6194659607e0Smrg 6195fc27e79cSmrgchar * 6196fc27e79cSmrgxstrdup (const char *string) 6197fc27e79cSmrg{ 6198fc27e79cSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 6199fc27e79cSmrg string) : NULL; 6200fc27e79cSmrg} 6201659607e0Smrg 6202fc27e79cSmrgconst char * 6203fc27e79cSmrgbase_name (const char *name) 6204fc27e79cSmrg{ 6205fc27e79cSmrg const char *base; 6206659607e0Smrg 6207e4da38afSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6208fc27e79cSmrg /* Skip over the disk name in MSDOS pathnames. */ 6209fc27e79cSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 6210fc27e79cSmrg name += 2; 6211fc27e79cSmrg#endif 6212659607e0Smrg 6213fc27e79cSmrg for (base = name; *name; name++) 6214fc27e79cSmrg if (IS_DIR_SEPARATOR (*name)) 6215fc27e79cSmrg base = name + 1; 6216fc27e79cSmrg return base; 6217fc27e79cSmrg} 6218659607e0Smrg 6219fc27e79cSmrgint 6220fc27e79cSmrgcheck_executable (const char *path) 6221fc27e79cSmrg{ 6222fc27e79cSmrg struct stat st; 6223659607e0Smrg 6224bd3a1963Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 6225bd3a1963Smrg nonempty (path)); 6226fc27e79cSmrg if ((!path) || (!*path)) 6227fc27e79cSmrg return 0; 6228659607e0Smrg 6229fc27e79cSmrg if ((stat (path, &st) >= 0) 6230fc27e79cSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 6231fc27e79cSmrg return 1; 6232fc27e79cSmrg else 6233fc27e79cSmrg return 0; 6234fc27e79cSmrg} 6235659607e0Smrg 6236fc27e79cSmrgint 6237fc27e79cSmrgmake_executable (const char *path) 6238fc27e79cSmrg{ 6239fc27e79cSmrg int rval = 0; 6240fc27e79cSmrg struct stat st; 6241659607e0Smrg 6242bd3a1963Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 6243bd3a1963Smrg nonempty (path)); 6244fc27e79cSmrg if ((!path) || (!*path)) 6245fc27e79cSmrg return 0; 6246659607e0Smrg 6247fc27e79cSmrg if (stat (path, &st) >= 0) 6248fc27e79cSmrg { 6249fc27e79cSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 6250fc27e79cSmrg } 6251fc27e79cSmrg return rval; 6252fc27e79cSmrg} 6253659607e0Smrg 6254fc27e79cSmrg/* Searches for the full path of the wrapper. Returns 6255fc27e79cSmrg newly allocated full path name if found, NULL otherwise 6256fc27e79cSmrg Does not chase symlinks, even on platforms that support them. 6257fc27e79cSmrg*/ 6258fc27e79cSmrgchar * 6259fc27e79cSmrgfind_executable (const char *wrapper) 6260fc27e79cSmrg{ 6261fc27e79cSmrg int has_slash = 0; 6262fc27e79cSmrg const char *p; 6263fc27e79cSmrg const char *p_next; 6264fc27e79cSmrg /* static buffer for getcwd */ 6265fc27e79cSmrg char tmp[LT_PATHMAX + 1]; 6266e4da38afSmrg size_t tmp_len; 6267fc27e79cSmrg char *concat_name; 6268659607e0Smrg 6269bd3a1963Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6270bd3a1963Smrg nonempty (wrapper)); 6271659607e0Smrg 6272fc27e79cSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 6273fc27e79cSmrg return NULL; 6274659607e0Smrg 6275fc27e79cSmrg /* Absolute path? */ 6276e4da38afSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6277fc27e79cSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6278fc27e79cSmrg { 6279fc27e79cSmrg concat_name = xstrdup (wrapper); 6280fc27e79cSmrg if (check_executable (concat_name)) 6281fc27e79cSmrg return concat_name; 6282fc27e79cSmrg XFREE (concat_name); 6283fc27e79cSmrg } 6284fc27e79cSmrg else 6285fc27e79cSmrg { 6286fc27e79cSmrg#endif 6287fc27e79cSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 6288fc27e79cSmrg { 6289fc27e79cSmrg concat_name = xstrdup (wrapper); 6290fc27e79cSmrg if (check_executable (concat_name)) 6291fc27e79cSmrg return concat_name; 6292fc27e79cSmrg XFREE (concat_name); 6293fc27e79cSmrg } 6294e4da38afSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6295fc27e79cSmrg } 6296fc27e79cSmrg#endif 6297659607e0Smrg 6298fc27e79cSmrg for (p = wrapper; *p; p++) 6299fc27e79cSmrg if (*p == '/') 6300fc27e79cSmrg { 6301fc27e79cSmrg has_slash = 1; 6302fc27e79cSmrg break; 6303fc27e79cSmrg } 6304fc27e79cSmrg if (!has_slash) 6305fc27e79cSmrg { 6306fc27e79cSmrg /* no slashes; search PATH */ 6307fc27e79cSmrg const char *path = getenv ("PATH"); 6308fc27e79cSmrg if (path != NULL) 6309fc27e79cSmrg { 6310fc27e79cSmrg for (p = path; *p; p = p_next) 6311fc27e79cSmrg { 6312fc27e79cSmrg const char *q; 6313fc27e79cSmrg size_t p_len; 6314fc27e79cSmrg for (q = p; *q; q++) 6315fc27e79cSmrg if (IS_PATH_SEPARATOR (*q)) 6316fc27e79cSmrg break; 6317e4da38afSmrg p_len = (size_t) (q - p); 6318fc27e79cSmrg p_next = (*q == '\0' ? q : q + 1); 6319fc27e79cSmrg if (p_len == 0) 6320fc27e79cSmrg { 6321fc27e79cSmrg /* empty path: current directory */ 6322fc27e79cSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6323bd3a1963Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6324bd3a1963Smrg nonnull (strerror (errno))); 6325fc27e79cSmrg tmp_len = strlen (tmp); 6326fc27e79cSmrg concat_name = 6327fc27e79cSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6328fc27e79cSmrg memcpy (concat_name, tmp, tmp_len); 6329fc27e79cSmrg concat_name[tmp_len] = '/'; 6330fc27e79cSmrg strcpy (concat_name + tmp_len + 1, wrapper); 6331fc27e79cSmrg } 6332fc27e79cSmrg else 6333fc27e79cSmrg { 6334fc27e79cSmrg concat_name = 6335fc27e79cSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6336fc27e79cSmrg memcpy (concat_name, p, p_len); 6337fc27e79cSmrg concat_name[p_len] = '/'; 6338fc27e79cSmrg strcpy (concat_name + p_len + 1, wrapper); 6339fc27e79cSmrg } 6340fc27e79cSmrg if (check_executable (concat_name)) 6341fc27e79cSmrg return concat_name; 6342fc27e79cSmrg XFREE (concat_name); 6343fc27e79cSmrg } 6344fc27e79cSmrg } 6345fc27e79cSmrg /* not found in PATH; assume curdir */ 6346fc27e79cSmrg } 6347fc27e79cSmrg /* Relative path | not found in path: prepend cwd */ 6348fc27e79cSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6349bd3a1963Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6350bd3a1963Smrg nonnull (strerror (errno))); 6351fc27e79cSmrg tmp_len = strlen (tmp); 6352fc27e79cSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6353fc27e79cSmrg memcpy (concat_name, tmp, tmp_len); 6354fc27e79cSmrg concat_name[tmp_len] = '/'; 6355fc27e79cSmrg strcpy (concat_name + tmp_len + 1, wrapper); 6356659607e0Smrg 6357fc27e79cSmrg if (check_executable (concat_name)) 6358fc27e79cSmrg return concat_name; 6359fc27e79cSmrg XFREE (concat_name); 6360fc27e79cSmrg return NULL; 6361fc27e79cSmrg} 6362659607e0Smrg 6363fc27e79cSmrgchar * 6364fc27e79cSmrgchase_symlinks (const char *pathspec) 6365fc27e79cSmrg{ 6366fc27e79cSmrg#ifndef S_ISLNK 6367fc27e79cSmrg return xstrdup (pathspec); 6368fc27e79cSmrg#else 6369fc27e79cSmrg char buf[LT_PATHMAX]; 6370fc27e79cSmrg struct stat s; 6371fc27e79cSmrg char *tmp_pathspec = xstrdup (pathspec); 6372fc27e79cSmrg char *p; 6373fc27e79cSmrg int has_symlinks = 0; 6374fc27e79cSmrg while (strlen (tmp_pathspec) && !has_symlinks) 6375fc27e79cSmrg { 6376bd3a1963Smrg lt_debugprintf (__FILE__, __LINE__, 6377bd3a1963Smrg "checking path component for symlinks: %s\n", 6378bd3a1963Smrg tmp_pathspec); 6379fc27e79cSmrg if (lstat (tmp_pathspec, &s) == 0) 6380fc27e79cSmrg { 6381fc27e79cSmrg if (S_ISLNK (s.st_mode) != 0) 6382fc27e79cSmrg { 6383fc27e79cSmrg has_symlinks = 1; 6384fc27e79cSmrg break; 6385fc27e79cSmrg } 6386659607e0Smrg 6387fc27e79cSmrg /* search backwards for last DIR_SEPARATOR */ 6388fc27e79cSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6389fc27e79cSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6390fc27e79cSmrg p--; 6391fc27e79cSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6392fc27e79cSmrg { 6393fc27e79cSmrg /* no more DIR_SEPARATORS left */ 6394fc27e79cSmrg break; 6395fc27e79cSmrg } 6396fc27e79cSmrg *p = '\0'; 6397fc27e79cSmrg } 6398fc27e79cSmrg else 6399fc27e79cSmrg { 6400bd3a1963Smrg lt_fatal (__FILE__, __LINE__, 6401bd3a1963Smrg "error accessing file \"%s\": %s", 6402bd3a1963Smrg tmp_pathspec, nonnull (strerror (errno))); 6403fc27e79cSmrg } 6404fc27e79cSmrg } 6405fc27e79cSmrg XFREE (tmp_pathspec); 6406659607e0Smrg 6407fc27e79cSmrg if (!has_symlinks) 6408fc27e79cSmrg { 6409fc27e79cSmrg return xstrdup (pathspec); 6410fc27e79cSmrg } 6411659607e0Smrg 6412fc27e79cSmrg tmp_pathspec = realpath (pathspec, buf); 6413fc27e79cSmrg if (tmp_pathspec == 0) 6414fc27e79cSmrg { 6415bd3a1963Smrg lt_fatal (__FILE__, __LINE__, 6416bd3a1963Smrg "could not follow symlinks for %s", pathspec); 6417fc27e79cSmrg } 6418fc27e79cSmrg return xstrdup (tmp_pathspec); 6419fc27e79cSmrg#endif 6420fc27e79cSmrg} 6421659607e0Smrg 6422fc27e79cSmrgchar * 6423fc27e79cSmrgstrendzap (char *str, const char *pat) 6424fc27e79cSmrg{ 6425fc27e79cSmrg size_t len, patlen; 6426659607e0Smrg 6427fc27e79cSmrg assert (str != NULL); 6428fc27e79cSmrg assert (pat != NULL); 6429659607e0Smrg 6430fc27e79cSmrg len = strlen (str); 6431fc27e79cSmrg patlen = strlen (pat); 6432659607e0Smrg 6433fc27e79cSmrg if (patlen <= len) 6434fc27e79cSmrg { 6435fc27e79cSmrg str += len - patlen; 6436e4da38afSmrg if (STREQ (str, pat)) 6437fc27e79cSmrg *str = '\0'; 6438fc27e79cSmrg } 6439fc27e79cSmrg return str; 6440fc27e79cSmrg} 6441659607e0Smrg 6442bd3a1963Smrgvoid 6443bd3a1963Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6444bd3a1963Smrg{ 6445bd3a1963Smrg va_list args; 6446bd3a1963Smrg if (lt_debug) 6447bd3a1963Smrg { 6448bd3a1963Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6449bd3a1963Smrg va_start (args, fmt); 6450bd3a1963Smrg (void) vfprintf (stderr, fmt, args); 6451bd3a1963Smrg va_end (args); 6452bd3a1963Smrg } 6453bd3a1963Smrg} 6454bd3a1963Smrg 6455fc27e79cSmrgstatic void 6456bd3a1963Smrglt_error_core (int exit_status, const char *file, 6457bd3a1963Smrg int line, const char *mode, 6458fc27e79cSmrg const char *message, va_list ap) 6459fc27e79cSmrg{ 6460bd3a1963Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6461fc27e79cSmrg vfprintf (stderr, message, ap); 6462fc27e79cSmrg fprintf (stderr, ".\n"); 6463659607e0Smrg 6464fc27e79cSmrg if (exit_status >= 0) 6465fc27e79cSmrg exit (exit_status); 6466fc27e79cSmrg} 6467659607e0Smrg 6468fc27e79cSmrgvoid 6469bd3a1963Smrglt_fatal (const char *file, int line, const char *message, ...) 6470fc27e79cSmrg{ 6471fc27e79cSmrg va_list ap; 6472fc27e79cSmrg va_start (ap, message); 6473bd3a1963Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6474fc27e79cSmrg va_end (ap); 6475fc27e79cSmrg} 6476659607e0Smrg 6477bd3a1963Smrgstatic const char * 6478bd3a1963Smrgnonnull (const char *s) 6479bd3a1963Smrg{ 6480bd3a1963Smrg return s ? s : "(null)"; 6481bd3a1963Smrg} 6482bd3a1963Smrg 6483bd3a1963Smrgstatic const char * 6484bd3a1963Smrgnonempty (const char *s) 6485bd3a1963Smrg{ 6486bd3a1963Smrg return (s && !*s) ? "(empty)" : nonnull (s); 6487bd3a1963Smrg} 6488bd3a1963Smrg 6489fc27e79cSmrgvoid 6490fc27e79cSmrglt_setenv (const char *name, const char *value) 6491fc27e79cSmrg{ 6492bd3a1963Smrg lt_debugprintf (__FILE__, __LINE__, 6493bd3a1963Smrg "(lt_setenv) setting '%s' to '%s'\n", 6494bd3a1963Smrg nonnull (name), nonnull (value)); 6495fc27e79cSmrg { 6496fc27e79cSmrg#ifdef HAVE_SETENV 6497fc27e79cSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 6498fc27e79cSmrg char *str = xstrdup (value); 6499fc27e79cSmrg setenv (name, str, 1); 6500fc27e79cSmrg#else 6501e4da38afSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6502fc27e79cSmrg char *str = XMALLOC (char, len); 6503fc27e79cSmrg sprintf (str, "%s=%s", name, value); 6504fc27e79cSmrg if (putenv (str) != EXIT_SUCCESS) 6505fc27e79cSmrg { 6506fc27e79cSmrg XFREE (str); 6507fc27e79cSmrg } 6508fc27e79cSmrg#endif 6509fc27e79cSmrg } 6510fc27e79cSmrg} 6511659607e0Smrg 6512fc27e79cSmrgchar * 6513fc27e79cSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 6514fc27e79cSmrg{ 6515fc27e79cSmrg char *new_value; 6516fc27e79cSmrg if (orig_value && *orig_value) 6517fc27e79cSmrg { 6518e4da38afSmrg size_t orig_value_len = strlen (orig_value); 6519e4da38afSmrg size_t add_len = strlen (add); 6520fc27e79cSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6521fc27e79cSmrg if (to_end) 6522fc27e79cSmrg { 6523fc27e79cSmrg strcpy (new_value, orig_value); 6524fc27e79cSmrg strcpy (new_value + orig_value_len, add); 6525fc27e79cSmrg } 6526fc27e79cSmrg else 6527fc27e79cSmrg { 6528fc27e79cSmrg strcpy (new_value, add); 6529fc27e79cSmrg strcpy (new_value + add_len, orig_value); 6530fc27e79cSmrg } 6531fc27e79cSmrg } 6532fc27e79cSmrg else 6533fc27e79cSmrg { 6534fc27e79cSmrg new_value = xstrdup (add); 6535fc27e79cSmrg } 6536fc27e79cSmrg return new_value; 6537fc27e79cSmrg} 6538659607e0Smrg 6539fc27e79cSmrgvoid 6540fc27e79cSmrglt_update_exe_path (const char *name, const char *value) 6541fc27e79cSmrg{ 6542bd3a1963Smrg lt_debugprintf (__FILE__, __LINE__, 6543bd3a1963Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6544bd3a1963Smrg nonnull (name), nonnull (value)); 6545659607e0Smrg 6546fc27e79cSmrg if (name && *name && value && *value) 6547fc27e79cSmrg { 6548fc27e79cSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 6549fc27e79cSmrg /* some systems can't cope with a ':'-terminated path #' */ 6550e4da38afSmrg size_t len = strlen (new_value); 6551e4da38afSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6552fc27e79cSmrg { 6553e4da38afSmrg new_value[--len] = '\0'; 6554fc27e79cSmrg } 6555fc27e79cSmrg lt_setenv (name, new_value); 6556fc27e79cSmrg XFREE (new_value); 6557fc27e79cSmrg } 6558fc27e79cSmrg} 6559659607e0Smrg 6560fc27e79cSmrgvoid 6561fc27e79cSmrglt_update_lib_path (const char *name, const char *value) 6562fc27e79cSmrg{ 6563bd3a1963Smrg lt_debugprintf (__FILE__, __LINE__, 6564bd3a1963Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6565bd3a1963Smrg nonnull (name), nonnull (value)); 6566659607e0Smrg 6567fc27e79cSmrg if (name && *name && value && *value) 6568fc27e79cSmrg { 6569fc27e79cSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 6570fc27e79cSmrg lt_setenv (name, new_value); 6571fc27e79cSmrg XFREE (new_value); 6572fc27e79cSmrg } 6573fc27e79cSmrg} 6574659607e0Smrg 6575bd3a1963SmrgEOF 6576bd3a1963Smrg case $host_os in 6577bd3a1963Smrg mingw*) 6578bd3a1963Smrg cat <<"EOF" 6579bd3a1963Smrg 6580bd3a1963Smrg/* Prepares an argument vector before calling spawn(). 6581bd3a1963Smrg Note that spawn() does not by itself call the command interpreter 6582bd3a1963Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6583bd3a1963Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6584bd3a1963Smrg GetVersionEx(&v); 6585bd3a1963Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6586bd3a1963Smrg }) ? "cmd.exe" : "command.com"). 6587bd3a1963Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 6588bd3a1963Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6589bd3a1963Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6590bd3a1963Smrg special way: 6591bd3a1963Smrg - Space and tab are interpreted as delimiters. They are not treated as 6592bd3a1963Smrg delimiters if they are surrounded by double quotes: "...". 6593bd3a1963Smrg - Unescaped double quotes are removed from the input. Their only effect is 6594bd3a1963Smrg that within double quotes, space and tab are treated like normal 6595bd3a1963Smrg characters. 6596bd3a1963Smrg - Backslashes not followed by double quotes are not special. 6597bd3a1963Smrg - But 2*n+1 backslashes followed by a double quote become 6598bd3a1963Smrg n backslashes followed by a double quote (n >= 0): 6599bd3a1963Smrg \" -> " 6600bd3a1963Smrg \\\" -> \" 6601bd3a1963Smrg \\\\\" -> \\" 6602bd3a1963Smrg */ 6603bd3a1963Smrg#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" 6604bd3a1963Smrg#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" 6605bd3a1963Smrgchar ** 6606bd3a1963Smrgprepare_spawn (char **argv) 6607bd3a1963Smrg{ 6608bd3a1963Smrg size_t argc; 6609bd3a1963Smrg char **new_argv; 6610bd3a1963Smrg size_t i; 6611bd3a1963Smrg 6612bd3a1963Smrg /* Count number of arguments. */ 6613bd3a1963Smrg for (argc = 0; argv[argc] != NULL; argc++) 6614bd3a1963Smrg ; 6615bd3a1963Smrg 6616bd3a1963Smrg /* Allocate new argument vector. */ 6617bd3a1963Smrg new_argv = XMALLOC (char *, argc + 1); 6618bd3a1963Smrg 6619bd3a1963Smrg /* Put quoted arguments into the new argument vector. */ 6620bd3a1963Smrg for (i = 0; i < argc; i++) 6621bd3a1963Smrg { 6622bd3a1963Smrg const char *string = argv[i]; 6623bd3a1963Smrg 6624bd3a1963Smrg if (string[0] == '\0') 6625bd3a1963Smrg new_argv[i] = xstrdup ("\"\""); 6626bd3a1963Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6627bd3a1963Smrg { 6628bd3a1963Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6629bd3a1963Smrg size_t length; 6630bd3a1963Smrg unsigned int backslashes; 6631bd3a1963Smrg const char *s; 6632bd3a1963Smrg char *quoted_string; 6633bd3a1963Smrg char *p; 6634bd3a1963Smrg 6635bd3a1963Smrg length = 0; 6636bd3a1963Smrg backslashes = 0; 6637bd3a1963Smrg if (quote_around) 6638bd3a1963Smrg length++; 6639bd3a1963Smrg for (s = string; *s != '\0'; s++) 6640bd3a1963Smrg { 6641bd3a1963Smrg char c = *s; 6642bd3a1963Smrg if (c == '"') 6643bd3a1963Smrg length += backslashes + 1; 6644bd3a1963Smrg length++; 6645bd3a1963Smrg if (c == '\\') 6646bd3a1963Smrg backslashes++; 6647bd3a1963Smrg else 6648bd3a1963Smrg backslashes = 0; 6649bd3a1963Smrg } 6650bd3a1963Smrg if (quote_around) 6651bd3a1963Smrg length += backslashes + 1; 6652bd3a1963Smrg 6653bd3a1963Smrg quoted_string = XMALLOC (char, length + 1); 6654bd3a1963Smrg 6655bd3a1963Smrg p = quoted_string; 6656bd3a1963Smrg backslashes = 0; 6657bd3a1963Smrg if (quote_around) 6658bd3a1963Smrg *p++ = '"'; 6659bd3a1963Smrg for (s = string; *s != '\0'; s++) 6660bd3a1963Smrg { 6661bd3a1963Smrg char c = *s; 6662bd3a1963Smrg if (c == '"') 6663bd3a1963Smrg { 6664bd3a1963Smrg unsigned int j; 6665bd3a1963Smrg for (j = backslashes + 1; j > 0; j--) 6666bd3a1963Smrg *p++ = '\\'; 6667bd3a1963Smrg } 6668bd3a1963Smrg *p++ = c; 6669bd3a1963Smrg if (c == '\\') 6670bd3a1963Smrg backslashes++; 6671bd3a1963Smrg else 6672bd3a1963Smrg backslashes = 0; 6673bd3a1963Smrg } 6674bd3a1963Smrg if (quote_around) 6675bd3a1963Smrg { 6676bd3a1963Smrg unsigned int j; 6677bd3a1963Smrg for (j = backslashes; j > 0; j--) 6678bd3a1963Smrg *p++ = '\\'; 6679bd3a1963Smrg *p++ = '"'; 6680bd3a1963Smrg } 6681bd3a1963Smrg *p = '\0'; 6682bd3a1963Smrg 6683bd3a1963Smrg new_argv[i] = quoted_string; 6684bd3a1963Smrg } 6685bd3a1963Smrg else 6686bd3a1963Smrg new_argv[i] = (char *) string; 6687bd3a1963Smrg } 6688bd3a1963Smrg new_argv[argc] = NULL; 6689bd3a1963Smrg 6690bd3a1963Smrg return new_argv; 6691bd3a1963Smrg} 6692bd3a1963SmrgEOF 6693bd3a1963Smrg ;; 6694bd3a1963Smrg esac 6695bd3a1963Smrg 6696bd3a1963Smrg cat <<"EOF" 6697bd3a1963Smrgvoid lt_dump_script (FILE* f) 6698bd3a1963Smrg{ 6699bd3a1963SmrgEOF 6700bd3a1963Smrg func_emit_wrapper yes | 6701a73597f9Smrg $SED -n -e ' 6702a73597f9Smrgs/^\(.\{79\}\)\(..*\)/\1\ 6703a73597f9Smrg\2/ 6704a73597f9Smrgh 6705a73597f9Smrgs/\([\\"]\)/\\\1/g 6706a73597f9Smrgs/$/\\n/ 6707a73597f9Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6708a73597f9Smrgg 6709a73597f9SmrgD' 6710bd3a1963Smrg cat <<"EOF" 6711bd3a1963Smrg} 6712fc27e79cSmrgEOF 6713fc27e79cSmrg} 6714fc27e79cSmrg# end: func_emit_cwrapperexe_src 6715659607e0Smrg 6716bd3a1963Smrg# func_win32_import_lib_p ARG 6717bd3a1963Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6718bd3a1963Smrgfunc_win32_import_lib_p () 6719bd3a1963Smrg{ 6720e4da38afSmrg $debug_cmd 6721e4da38afSmrg 6722bd3a1963Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6723bd3a1963Smrg *import*) : ;; 6724bd3a1963Smrg *) false ;; 6725bd3a1963Smrg esac 6726bd3a1963Smrg} 6727bd3a1963Smrg 6728e4da38afSmrg# func_suncc_cstd_abi 6729e4da38afSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6730e4da38afSmrg# Several compiler flags select an ABI that is incompatible with the 6731e4da38afSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6732e4da38afSmrgfunc_suncc_cstd_abi () 6733e4da38afSmrg{ 6734e4da38afSmrg $debug_cmd 6735e4da38afSmrg 6736e4da38afSmrg case " $compile_command " in 6737e4da38afSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6738e4da38afSmrg suncc_use_cstd_abi=no 6739e4da38afSmrg ;; 6740e4da38afSmrg *) 6741e4da38afSmrg suncc_use_cstd_abi=yes 6742e4da38afSmrg ;; 6743e4da38afSmrg esac 6744e4da38afSmrg} 6745e4da38afSmrg 6746fc27e79cSmrg# func_mode_link arg... 6747fc27e79cSmrgfunc_mode_link () 6748fc27e79cSmrg{ 6749e4da38afSmrg $debug_cmd 6750e4da38afSmrg 6751fc27e79cSmrg case $host in 6752fc27e79cSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6753fc27e79cSmrg # It is impossible to link a dll without this setting, and 6754fc27e79cSmrg # we shouldn't force the makefile maintainer to figure out 6755e4da38afSmrg # what system we are compiling for in order to pass an extra 6756fc27e79cSmrg # flag for every libtool invocation. 6757fc27e79cSmrg # allow_undefined=no 6758659607e0Smrg 6759fc27e79cSmrg # FIXME: Unfortunately, there are problems with the above when trying 6760e4da38afSmrg # to make a dll that has undefined symbols, in which case not 6761fc27e79cSmrg # even a static library is built. For now, we need to specify 6762fc27e79cSmrg # -no-undefined on the libtool link line when we can be certain 6763fc27e79cSmrg # that all symbols are satisfied, otherwise we get a static library. 6764fc27e79cSmrg allow_undefined=yes 6765fc27e79cSmrg ;; 6766fc27e79cSmrg *) 6767fc27e79cSmrg allow_undefined=yes 6768fc27e79cSmrg ;; 6769fc27e79cSmrg esac 6770fc27e79cSmrg libtool_args=$nonopt 6771fc27e79cSmrg base_compile="$nonopt $@" 6772fc27e79cSmrg compile_command=$nonopt 6773fc27e79cSmrg finalize_command=$nonopt 6774659607e0Smrg 6775fc27e79cSmrg compile_rpath= 6776fc27e79cSmrg finalize_rpath= 6777fc27e79cSmrg compile_shlibpath= 6778fc27e79cSmrg finalize_shlibpath= 6779fc27e79cSmrg convenience= 6780fc27e79cSmrg old_convenience= 6781fc27e79cSmrg deplibs= 6782fc27e79cSmrg old_deplibs= 6783fc27e79cSmrg compiler_flags= 6784fc27e79cSmrg linker_flags= 6785fc27e79cSmrg dllsearchpath= 6786fc27e79cSmrg lib_search_path=`pwd` 6787fc27e79cSmrg inst_prefix_dir= 6788fc27e79cSmrg new_inherited_linker_flags= 6789659607e0Smrg 6790fc27e79cSmrg avoid_version=no 6791bd3a1963Smrg bindir= 6792fc27e79cSmrg dlfiles= 6793fc27e79cSmrg dlprefiles= 6794fc27e79cSmrg dlself=no 6795fc27e79cSmrg export_dynamic=no 6796fc27e79cSmrg export_symbols= 6797fc27e79cSmrg export_symbols_regex= 6798fc27e79cSmrg generated= 6799fc27e79cSmrg libobjs= 6800fc27e79cSmrg ltlibs= 6801fc27e79cSmrg module=no 6802fc27e79cSmrg no_install=no 6803fc27e79cSmrg objs= 6804e4da38afSmrg os2dllname= 6805fc27e79cSmrg non_pic_objects= 6806fc27e79cSmrg precious_files_regex= 6807fc27e79cSmrg prefer_static_libs=no 6808e4da38afSmrg preload=false 6809fc27e79cSmrg prev= 6810fc27e79cSmrg prevarg= 6811fc27e79cSmrg release= 6812fc27e79cSmrg rpath= 6813fc27e79cSmrg xrpath= 6814fc27e79cSmrg perm_rpath= 6815fc27e79cSmrg temp_rpath= 6816fc27e79cSmrg thread_safe=no 6817fc27e79cSmrg vinfo= 6818fc27e79cSmrg vinfo_number=no 6819fc27e79cSmrg weak_libs= 6820e4da38afSmrg single_module=$wl-single_module 6821fc27e79cSmrg func_infer_tag $base_compile 6822659607e0Smrg 6823fc27e79cSmrg # We need to know -static, to get the right output filenames. 6824fc27e79cSmrg for arg 6825fc27e79cSmrg do 6826fc27e79cSmrg case $arg in 6827fc27e79cSmrg -shared) 6828e4da38afSmrg test yes != "$build_libtool_libs" \ 6829e4da38afSmrg && func_fatal_configuration "cannot build a shared library" 6830fc27e79cSmrg build_old_libs=no 6831fc27e79cSmrg break 6832fc27e79cSmrg ;; 6833fc27e79cSmrg -all-static | -static | -static-libtool-libs) 6834fc27e79cSmrg case $arg in 6835fc27e79cSmrg -all-static) 6836e4da38afSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6837fc27e79cSmrg func_warning "complete static linking is impossible in this configuration" 6838659607e0Smrg fi 6839fc27e79cSmrg if test -n "$link_static_flag"; then 6840fc27e79cSmrg dlopen_self=$dlopen_self_static 6841659607e0Smrg fi 6842fc27e79cSmrg prefer_static_libs=yes 6843659607e0Smrg ;; 6844fc27e79cSmrg -static) 6845fc27e79cSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6846fc27e79cSmrg dlopen_self=$dlopen_self_static 6847fc27e79cSmrg fi 6848fc27e79cSmrg prefer_static_libs=built 6849fc27e79cSmrg ;; 6850fc27e79cSmrg -static-libtool-libs) 6851fc27e79cSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6852fc27e79cSmrg dlopen_self=$dlopen_self_static 6853fc27e79cSmrg fi 6854fc27e79cSmrg prefer_static_libs=yes 6855659607e0Smrg ;; 6856659607e0Smrg esac 6857fc27e79cSmrg build_libtool_libs=no 6858fc27e79cSmrg build_old_libs=yes 6859fc27e79cSmrg break 6860fc27e79cSmrg ;; 6861fc27e79cSmrg esac 6862fc27e79cSmrg done 6863659607e0Smrg 6864fc27e79cSmrg # See if our shared archives depend on static archives. 6865fc27e79cSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6866659607e0Smrg 6867fc27e79cSmrg # Go through the arguments, transforming them on the way. 6868fc27e79cSmrg while test "$#" -gt 0; do 6869e4da38afSmrg arg=$1 6870fc27e79cSmrg shift 6871370b807fSmrg func_quote_arg pretty,unquoted "$arg" 6872370b807fSmrg qarg=$func_quote_arg_unquoted_result 6873370b807fSmrg func_append libtool_args " $func_quote_arg_result" 6874659607e0Smrg 6875fc27e79cSmrg # If the previous option needs an argument, assign it. 6876fc27e79cSmrg if test -n "$prev"; then 6877fc27e79cSmrg case $prev in 6878fc27e79cSmrg output) 6879fc27e79cSmrg func_append compile_command " @OUTPUT@" 6880fc27e79cSmrg func_append finalize_command " @OUTPUT@" 6881fc27e79cSmrg ;; 6882fc27e79cSmrg esac 6883659607e0Smrg 6884fc27e79cSmrg case $prev in 6885bd3a1963Smrg bindir) 6886e4da38afSmrg bindir=$arg 6887bd3a1963Smrg prev= 6888bd3a1963Smrg continue 6889bd3a1963Smrg ;; 6890fc27e79cSmrg dlfiles|dlprefiles) 6891e4da38afSmrg $preload || { 6892fc27e79cSmrg # Add the symbol object into the linking commands. 6893fc27e79cSmrg func_append compile_command " @SYMFILE@" 6894fc27e79cSmrg func_append finalize_command " @SYMFILE@" 6895e4da38afSmrg preload=: 6896e4da38afSmrg } 6897fc27e79cSmrg case $arg in 6898fc27e79cSmrg *.la | *.lo) ;; # We handle these cases below. 6899fc27e79cSmrg force) 6900e4da38afSmrg if test no = "$dlself"; then 6901fc27e79cSmrg dlself=needless 6902fc27e79cSmrg export_dynamic=yes 6903fc27e79cSmrg fi 6904fc27e79cSmrg prev= 6905fc27e79cSmrg continue 6906fc27e79cSmrg ;; 6907fc27e79cSmrg self) 6908e4da38afSmrg if test dlprefiles = "$prev"; then 6909fc27e79cSmrg dlself=yes 6910e4da38afSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6911fc27e79cSmrg dlself=yes 6912fc27e79cSmrg else 6913fc27e79cSmrg dlself=needless 6914fc27e79cSmrg export_dynamic=yes 6915fc27e79cSmrg fi 6916fc27e79cSmrg prev= 6917fc27e79cSmrg continue 6918659607e0Smrg ;; 6919659607e0Smrg *) 6920e4da38afSmrg if test dlfiles = "$prev"; then 6921bd3a1963Smrg func_append dlfiles " $arg" 6922fc27e79cSmrg else 6923bd3a1963Smrg func_append dlprefiles " $arg" 6924fc27e79cSmrg fi 6925fc27e79cSmrg prev= 6926fc27e79cSmrg continue 6927659607e0Smrg ;; 6928659607e0Smrg esac 6929fc27e79cSmrg ;; 6930fc27e79cSmrg expsyms) 6931e4da38afSmrg export_symbols=$arg 6932fc27e79cSmrg test -f "$arg" \ 6933e4da38afSmrg || func_fatal_error "symbol file '$arg' does not exist" 6934fc27e79cSmrg prev= 6935fc27e79cSmrg continue 6936fc27e79cSmrg ;; 6937fc27e79cSmrg expsyms_regex) 6938e4da38afSmrg export_symbols_regex=$arg 6939fc27e79cSmrg prev= 6940fc27e79cSmrg continue 6941fc27e79cSmrg ;; 6942fc27e79cSmrg framework) 6943fc27e79cSmrg case $host in 6944fc27e79cSmrg *-*-darwin*) 6945fc27e79cSmrg case "$deplibs " in 6946fc27e79cSmrg *" $qarg.ltframework "*) ;; 6947bd3a1963Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6948fc27e79cSmrg ;; 6949fc27e79cSmrg esac 6950fc27e79cSmrg ;; 6951fc27e79cSmrg esac 6952fc27e79cSmrg prev= 6953fc27e79cSmrg continue 6954fc27e79cSmrg ;; 6955fc27e79cSmrg inst_prefix) 6956e4da38afSmrg inst_prefix_dir=$arg 6957e4da38afSmrg prev= 6958e4da38afSmrg continue 6959e4da38afSmrg ;; 6960e4da38afSmrg mllvm) 6961e4da38afSmrg # Clang does not use LLVM to link, so we can simply discard any 6962e4da38afSmrg # '-mllvm $arg' options when doing the link step. 6963fc27e79cSmrg prev= 6964fc27e79cSmrg continue 6965fc27e79cSmrg ;; 6966fc27e79cSmrg objectlist) 6967fc27e79cSmrg if test -f "$arg"; then 6968fc27e79cSmrg save_arg=$arg 6969fc27e79cSmrg moreargs= 6970fc27e79cSmrg for fil in `cat "$save_arg"` 6971fc27e79cSmrg do 6972bd3a1963Smrg# func_append moreargs " $fil" 6973fc27e79cSmrg arg=$fil 6974fc27e79cSmrg # A libtool-controlled object. 6975659607e0Smrg 6976fc27e79cSmrg # Check to see that this really is a libtool object. 6977fc27e79cSmrg if func_lalib_unsafe_p "$arg"; then 6978fc27e79cSmrg pic_object= 6979fc27e79cSmrg non_pic_object= 6980659607e0Smrg 6981fc27e79cSmrg # Read the .lo file 6982fc27e79cSmrg func_source "$arg" 6983659607e0Smrg 6984fc27e79cSmrg if test -z "$pic_object" || 6985fc27e79cSmrg test -z "$non_pic_object" || 6986e4da38afSmrg test none = "$pic_object" && 6987e4da38afSmrg test none = "$non_pic_object"; then 6988e4da38afSmrg func_fatal_error "cannot find name of object for '$arg'" 6989fc27e79cSmrg fi 6990659607e0Smrg 6991fc27e79cSmrg # Extract subdirectory from the argument. 6992fc27e79cSmrg func_dirname "$arg" "/" "" 6993e4da38afSmrg xdir=$func_dirname_result 6994659607e0Smrg 6995e4da38afSmrg if test none != "$pic_object"; then 6996fc27e79cSmrg # Prepend the subdirectory the object is found in. 6997e4da38afSmrg pic_object=$xdir$pic_object 6998659607e0Smrg 6999e4da38afSmrg if test dlfiles = "$prev"; then 7000e4da38afSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7001bd3a1963Smrg func_append dlfiles " $pic_object" 7002fc27e79cSmrg prev= 7003fc27e79cSmrg continue 7004fc27e79cSmrg else 7005fc27e79cSmrg # If libtool objects are unsupported, then we need to preload. 7006fc27e79cSmrg prev=dlprefiles 7007fc27e79cSmrg fi 7008fc27e79cSmrg fi 7009659607e0Smrg 7010fc27e79cSmrg # CHECK ME: I think I busted this. -Ossama 7011e4da38afSmrg if test dlprefiles = "$prev"; then 7012fc27e79cSmrg # Preload the old-style object. 7013bd3a1963Smrg func_append dlprefiles " $pic_object" 7014fc27e79cSmrg prev= 7015fc27e79cSmrg fi 7016659607e0Smrg 7017fc27e79cSmrg # A PIC object. 7018fc27e79cSmrg func_append libobjs " $pic_object" 7019e4da38afSmrg arg=$pic_object 7020fc27e79cSmrg fi 7021659607e0Smrg 7022fc27e79cSmrg # Non-PIC object. 7023e4da38afSmrg if test none != "$non_pic_object"; then 7024fc27e79cSmrg # Prepend the subdirectory the object is found in. 7025e4da38afSmrg non_pic_object=$xdir$non_pic_object 7026659607e0Smrg 7027fc27e79cSmrg # A standard non-PIC object 7028fc27e79cSmrg func_append non_pic_objects " $non_pic_object" 7029e4da38afSmrg if test -z "$pic_object" || test none = "$pic_object"; then 7030e4da38afSmrg arg=$non_pic_object 7031fc27e79cSmrg fi 7032fc27e79cSmrg else 7033fc27e79cSmrg # If the PIC object exists, use it instead. 7034fc27e79cSmrg # $xdir was prepended to $pic_object above. 7035e4da38afSmrg non_pic_object=$pic_object 7036fc27e79cSmrg func_append non_pic_objects " $non_pic_object" 7037fc27e79cSmrg fi 7038fc27e79cSmrg else 7039fc27e79cSmrg # Only an error if not doing a dry-run. 7040fc27e79cSmrg if $opt_dry_run; then 7041fc27e79cSmrg # Extract subdirectory from the argument. 7042fc27e79cSmrg func_dirname "$arg" "/" "" 7043e4da38afSmrg xdir=$func_dirname_result 7044fc27e79cSmrg 7045fc27e79cSmrg func_lo2o "$arg" 7046fc27e79cSmrg pic_object=$xdir$objdir/$func_lo2o_result 7047fc27e79cSmrg non_pic_object=$xdir$func_lo2o_result 7048fc27e79cSmrg func_append libobjs " $pic_object" 7049fc27e79cSmrg func_append non_pic_objects " $non_pic_object" 7050fc27e79cSmrg else 7051e4da38afSmrg func_fatal_error "'$arg' is not a valid libtool object" 7052fc27e79cSmrg fi 7053fc27e79cSmrg fi 7054fc27e79cSmrg done 7055fc27e79cSmrg else 7056e4da38afSmrg func_fatal_error "link input file '$arg' does not exist" 7057fc27e79cSmrg fi 7058fc27e79cSmrg arg=$save_arg 7059fc27e79cSmrg prev= 7060fc27e79cSmrg continue 7061fc27e79cSmrg ;; 7062e4da38afSmrg os2dllname) 7063e4da38afSmrg os2dllname=$arg 7064e4da38afSmrg prev= 7065e4da38afSmrg continue 7066e4da38afSmrg ;; 7067fc27e79cSmrg precious_regex) 7068e4da38afSmrg precious_files_regex=$arg 7069fc27e79cSmrg prev= 7070fc27e79cSmrg continue 7071fc27e79cSmrg ;; 7072fc27e79cSmrg release) 7073e4da38afSmrg release=-$arg 7074fc27e79cSmrg prev= 7075fc27e79cSmrg continue 7076fc27e79cSmrg ;; 7077fc27e79cSmrg rpath | xrpath) 7078fc27e79cSmrg # We need an absolute path. 7079fc27e79cSmrg case $arg in 7080fc27e79cSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7081fc27e79cSmrg *) 7082fc27e79cSmrg func_fatal_error "only absolute run-paths are allowed" 7083fc27e79cSmrg ;; 7084fc27e79cSmrg esac 7085e4da38afSmrg if test rpath = "$prev"; then 7086fc27e79cSmrg case "$rpath " in 7087fc27e79cSmrg *" $arg "*) ;; 7088bd3a1963Smrg *) func_append rpath " $arg" ;; 7089fc27e79cSmrg esac 7090fc27e79cSmrg else 7091fc27e79cSmrg case "$xrpath " in 7092fc27e79cSmrg *" $arg "*) ;; 7093bd3a1963Smrg *) func_append xrpath " $arg" ;; 7094fc27e79cSmrg esac 7095fc27e79cSmrg fi 7096fc27e79cSmrg prev= 7097fc27e79cSmrg continue 7098fc27e79cSmrg ;; 7099fc27e79cSmrg shrext) 7100e4da38afSmrg shrext_cmds=$arg 7101fc27e79cSmrg prev= 7102fc27e79cSmrg continue 7103fc27e79cSmrg ;; 7104fc27e79cSmrg weak) 7105bd3a1963Smrg func_append weak_libs " $arg" 7106fc27e79cSmrg prev= 7107fc27e79cSmrg continue 7108fc27e79cSmrg ;; 7109370b807fSmrg xassembler) 7110370b807fSmrg func_append compiler_flags " -Xassembler $qarg" 7111370b807fSmrg prev= 7112370b807fSmrg func_append compile_command " -Xassembler $qarg" 7113370b807fSmrg func_append finalize_command " -Xassembler $qarg" 7114370b807fSmrg continue 7115370b807fSmrg ;; 7116fc27e79cSmrg xcclinker) 7117bd3a1963Smrg func_append linker_flags " $qarg" 7118bd3a1963Smrg func_append compiler_flags " $qarg" 7119fc27e79cSmrg prev= 7120fc27e79cSmrg func_append compile_command " $qarg" 7121fc27e79cSmrg func_append finalize_command " $qarg" 7122fc27e79cSmrg continue 7123fc27e79cSmrg ;; 7124fc27e79cSmrg xcompiler) 7125bd3a1963Smrg func_append compiler_flags " $qarg" 7126fc27e79cSmrg prev= 7127fc27e79cSmrg func_append compile_command " $qarg" 7128fc27e79cSmrg func_append finalize_command " $qarg" 7129fc27e79cSmrg continue 7130fc27e79cSmrg ;; 7131fc27e79cSmrg xlinker) 7132bd3a1963Smrg func_append linker_flags " $qarg" 7133bd3a1963Smrg func_append compiler_flags " $wl$qarg" 7134fc27e79cSmrg prev= 7135fc27e79cSmrg func_append compile_command " $wl$qarg" 7136fc27e79cSmrg func_append finalize_command " $wl$qarg" 7137fc27e79cSmrg continue 7138fc27e79cSmrg ;; 7139fc27e79cSmrg *) 7140fc27e79cSmrg eval "$prev=\"\$arg\"" 7141fc27e79cSmrg prev= 7142fc27e79cSmrg continue 7143fc27e79cSmrg ;; 7144659607e0Smrg esac 7145fc27e79cSmrg fi # test -n "$prev" 7146659607e0Smrg 7147e4da38afSmrg prevarg=$arg 7148659607e0Smrg 7149fc27e79cSmrg case $arg in 7150fc27e79cSmrg -all-static) 7151fc27e79cSmrg if test -n "$link_static_flag"; then 7152fc27e79cSmrg # See comment for -static flag below, for more details. 7153fc27e79cSmrg func_append compile_command " $link_static_flag" 7154fc27e79cSmrg func_append finalize_command " $link_static_flag" 7155fc27e79cSmrg fi 7156fc27e79cSmrg continue 7157fc27e79cSmrg ;; 7158659607e0Smrg 7159fc27e79cSmrg -allow-undefined) 7160fc27e79cSmrg # FIXME: remove this flag sometime in the future. 7161e4da38afSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 7162fc27e79cSmrg ;; 7163659607e0Smrg 7164fc27e79cSmrg -avoid-version) 7165fc27e79cSmrg avoid_version=yes 7166fc27e79cSmrg continue 7167fc27e79cSmrg ;; 7168659607e0Smrg 7169bd3a1963Smrg -bindir) 7170bd3a1963Smrg prev=bindir 7171bd3a1963Smrg continue 7172bd3a1963Smrg ;; 7173bd3a1963Smrg 7174fc27e79cSmrg -dlopen) 7175fc27e79cSmrg prev=dlfiles 7176fc27e79cSmrg continue 7177fc27e79cSmrg ;; 7178659607e0Smrg 7179fc27e79cSmrg -dlpreopen) 7180fc27e79cSmrg prev=dlprefiles 7181fc27e79cSmrg continue 7182fc27e79cSmrg ;; 7183659607e0Smrg 7184fc27e79cSmrg -export-dynamic) 7185fc27e79cSmrg export_dynamic=yes 7186fc27e79cSmrg continue 7187fc27e79cSmrg ;; 7188659607e0Smrg 7189fc27e79cSmrg -export-symbols | -export-symbols-regex) 7190fc27e79cSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 7191fc27e79cSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 7192fc27e79cSmrg fi 7193e4da38afSmrg if test X-export-symbols = "X$arg"; then 7194fc27e79cSmrg prev=expsyms 7195fc27e79cSmrg else 7196fc27e79cSmrg prev=expsyms_regex 7197fc27e79cSmrg fi 7198fc27e79cSmrg continue 7199fc27e79cSmrg ;; 7200659607e0Smrg 7201fc27e79cSmrg -framework) 7202fc27e79cSmrg prev=framework 7203fc27e79cSmrg continue 7204fc27e79cSmrg ;; 7205659607e0Smrg 7206fc27e79cSmrg -inst-prefix-dir) 7207fc27e79cSmrg prev=inst_prefix 7208fc27e79cSmrg continue 7209fc27e79cSmrg ;; 7210659607e0Smrg 7211fc27e79cSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 7212fc27e79cSmrg # so, if we see these flags be careful not to treat them like -L 7213fc27e79cSmrg -L[A-Z][A-Z]*:*) 7214fc27e79cSmrg case $with_gcc/$host in 7215fc27e79cSmrg no/*-*-irix* | /*-*-irix*) 7216fc27e79cSmrg func_append compile_command " $arg" 7217fc27e79cSmrg func_append finalize_command " $arg" 7218fc27e79cSmrg ;; 7219fc27e79cSmrg esac 7220fc27e79cSmrg continue 7221fc27e79cSmrg ;; 7222659607e0Smrg 7223fc27e79cSmrg -L*) 7224bd3a1963Smrg func_stripname "-L" '' "$arg" 7225bd3a1963Smrg if test -z "$func_stripname_result"; then 7226fc27e79cSmrg if test "$#" -gt 0; then 7227e4da38afSmrg func_fatal_error "require no space between '-L' and '$1'" 7228fc27e79cSmrg else 7229e4da38afSmrg func_fatal_error "need path for '-L' option" 7230fc27e79cSmrg fi 7231fc27e79cSmrg fi 7232bd3a1963Smrg func_resolve_sysroot "$func_stripname_result" 7233bd3a1963Smrg dir=$func_resolve_sysroot_result 7234fc27e79cSmrg # We need an absolute path. 7235fc27e79cSmrg case $dir in 7236fc27e79cSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7237fc27e79cSmrg *) 7238fc27e79cSmrg absdir=`cd "$dir" && pwd` 7239fc27e79cSmrg test -z "$absdir" && \ 7240e4da38afSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 7241e4da38afSmrg dir=$absdir 7242fc27e79cSmrg ;; 7243fc27e79cSmrg esac 7244fc27e79cSmrg case "$deplibs " in 7245bd3a1963Smrg *" -L$dir "* | *" $arg "*) 7246bd3a1963Smrg # Will only happen for absolute or sysroot arguments 7247bd3a1963Smrg ;; 7248fc27e79cSmrg *) 7249bd3a1963Smrg # Preserve sysroot, but never include relative directories 7250bd3a1963Smrg case $dir in 7251bd3a1963Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 7252bd3a1963Smrg *) func_append deplibs " -L$dir" ;; 7253bd3a1963Smrg esac 7254bd3a1963Smrg func_append lib_search_path " $dir" 7255fc27e79cSmrg ;; 7256fc27e79cSmrg esac 7257fc27e79cSmrg case $host in 7258fc27e79cSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 7259bd3a1963Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 7260fc27e79cSmrg case :$dllsearchpath: in 7261fc27e79cSmrg *":$dir:"*) ;; 7262fc27e79cSmrg ::) dllsearchpath=$dir;; 7263bd3a1963Smrg *) func_append dllsearchpath ":$dir";; 7264fc27e79cSmrg esac 7265fc27e79cSmrg case :$dllsearchpath: in 7266fc27e79cSmrg *":$testbindir:"*) ;; 7267fc27e79cSmrg ::) dllsearchpath=$testbindir;; 7268bd3a1963Smrg *) func_append dllsearchpath ":$testbindir";; 7269fc27e79cSmrg esac 7270fc27e79cSmrg ;; 7271fc27e79cSmrg esac 7272fc27e79cSmrg continue 7273fc27e79cSmrg ;; 7274659607e0Smrg 7275fc27e79cSmrg -l*) 7276e4da38afSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7277fc27e79cSmrg case $host in 7278bd3a1963Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7279fc27e79cSmrg # These systems don't actually have a C or math library (as such) 7280fc27e79cSmrg continue 7281fc27e79cSmrg ;; 7282fc27e79cSmrg *-*-os2*) 7283fc27e79cSmrg # These systems don't actually have a C library (as such) 7284e4da38afSmrg test X-lc = "X$arg" && continue 7285fc27e79cSmrg ;; 7286370b807fSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7287fc27e79cSmrg # Do not include libc due to us having libc/libc_r. 7288e4da38afSmrg test X-lc = "X$arg" && continue 7289fc27e79cSmrg ;; 7290fc27e79cSmrg *-*-rhapsody* | *-*-darwin1.[012]) 7291fc27e79cSmrg # Rhapsody C and math libraries are in the System framework 7292bd3a1963Smrg func_append deplibs " System.ltframework" 7293fc27e79cSmrg continue 7294fc27e79cSmrg ;; 7295fc27e79cSmrg *-*-sco3.2v5* | *-*-sco5v6*) 7296fc27e79cSmrg # Causes problems with __ctype 7297e4da38afSmrg test X-lc = "X$arg" && continue 7298fc27e79cSmrg ;; 7299fc27e79cSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7300fc27e79cSmrg # Compiler inserts libc in the correct place for threads to work 7301e4da38afSmrg test X-lc = "X$arg" && continue 7302fc27e79cSmrg ;; 7303fc27e79cSmrg esac 7304e4da38afSmrg elif test X-lc_r = "X$arg"; then 7305fc27e79cSmrg case $host in 7306370b807fSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7307fc27e79cSmrg # Do not include libc_r directly, use -pthread flag. 7308fc27e79cSmrg continue 7309fc27e79cSmrg ;; 7310fc27e79cSmrg esac 7311fc27e79cSmrg fi 7312bd3a1963Smrg func_append deplibs " $arg" 7313fc27e79cSmrg continue 7314fc27e79cSmrg ;; 7315659607e0Smrg 7316e4da38afSmrg -mllvm) 7317e4da38afSmrg prev=mllvm 7318e4da38afSmrg continue 7319e4da38afSmrg ;; 7320e4da38afSmrg 7321fc27e79cSmrg -module) 7322fc27e79cSmrg module=yes 7323fc27e79cSmrg continue 7324fc27e79cSmrg ;; 7325659607e0Smrg 7326fc27e79cSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7327fc27e79cSmrg # classes, name mangling, and exception handling. 7328fc27e79cSmrg # Darwin uses the -arch flag to determine output architecture. 7329bd3a1963Smrg -model|-arch|-isysroot|--sysroot) 7330bd3a1963Smrg func_append compiler_flags " $arg" 7331fc27e79cSmrg func_append compile_command " $arg" 7332fc27e79cSmrg func_append finalize_command " $arg" 7333fc27e79cSmrg prev=xcompiler 7334fc27e79cSmrg continue 7335fc27e79cSmrg ;; 7336370b807fSmrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 7337370b807fSmrg -pthread) 7338370b807fSmrg case $host in 7339370b807fSmrg *solaris2*) ;; 7340370b807fSmrg *) 7341370b807fSmrg case "$new_inherited_linker_flags " in 7342370b807fSmrg *" $arg "*) ;; 7343370b807fSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 7344370b807fSmrg esac 7345370b807fSmrg ;; 7346370b807fSmrg esac 7347370b807fSmrg continue 7348370b807fSmrg ;; 7349370b807fSmrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 7350a73597f9Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7351bd3a1963Smrg func_append compiler_flags " $arg" 7352fc27e79cSmrg func_append compile_command " $arg" 7353fc27e79cSmrg func_append finalize_command " $arg" 7354fc27e79cSmrg case "$new_inherited_linker_flags " in 7355fc27e79cSmrg *" $arg "*) ;; 7356bd3a1963Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7357fc27e79cSmrg esac 7358fc27e79cSmrg continue 7359fc27e79cSmrg ;; 7360659607e0Smrg 7361fc27e79cSmrg -multi_module) 7362e4da38afSmrg single_module=$wl-multi_module 7363fc27e79cSmrg continue 7364fc27e79cSmrg ;; 7365659607e0Smrg 7366fc27e79cSmrg -no-fast-install) 7367fc27e79cSmrg fast_install=no 7368fc27e79cSmrg continue 7369fc27e79cSmrg ;; 7370659607e0Smrg 7371fc27e79cSmrg -no-install) 7372fc27e79cSmrg case $host in 7373fc27e79cSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7374fc27e79cSmrg # The PATH hackery in wrapper scripts is required on Windows 7375fc27e79cSmrg # and Darwin in order for the loader to find any dlls it needs. 7376e4da38afSmrg func_warning "'-no-install' is ignored for $host" 7377e4da38afSmrg func_warning "assuming '-no-fast-install' instead" 7378fc27e79cSmrg fast_install=no 7379fc27e79cSmrg ;; 7380fc27e79cSmrg *) no_install=yes ;; 7381fc27e79cSmrg esac 7382fc27e79cSmrg continue 7383fc27e79cSmrg ;; 7384659607e0Smrg 7385fc27e79cSmrg -no-undefined) 7386fc27e79cSmrg allow_undefined=no 7387fc27e79cSmrg continue 7388fc27e79cSmrg ;; 7389659607e0Smrg 7390fc27e79cSmrg -objectlist) 7391fc27e79cSmrg prev=objectlist 7392fc27e79cSmrg continue 7393fc27e79cSmrg ;; 7394659607e0Smrg 7395e4da38afSmrg -os2dllname) 7396e4da38afSmrg prev=os2dllname 7397e4da38afSmrg continue 7398e4da38afSmrg ;; 7399e4da38afSmrg 7400fc27e79cSmrg -o) prev=output ;; 7401659607e0Smrg 7402fc27e79cSmrg -precious-files-regex) 7403fc27e79cSmrg prev=precious_regex 7404fc27e79cSmrg continue 7405fc27e79cSmrg ;; 7406659607e0Smrg 7407fc27e79cSmrg -release) 7408fc27e79cSmrg prev=release 7409fc27e79cSmrg continue 7410fc27e79cSmrg ;; 7411659607e0Smrg 7412fc27e79cSmrg -rpath) 7413fc27e79cSmrg prev=rpath 7414fc27e79cSmrg continue 7415fc27e79cSmrg ;; 7416659607e0Smrg 7417fc27e79cSmrg -R) 7418fc27e79cSmrg prev=xrpath 7419fc27e79cSmrg continue 7420fc27e79cSmrg ;; 7421659607e0Smrg 7422fc27e79cSmrg -R*) 7423fc27e79cSmrg func_stripname '-R' '' "$arg" 7424fc27e79cSmrg dir=$func_stripname_result 7425fc27e79cSmrg # We need an absolute path. 7426fc27e79cSmrg case $dir in 7427fc27e79cSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7428bd3a1963Smrg =*) 7429bd3a1963Smrg func_stripname '=' '' "$dir" 7430bd3a1963Smrg dir=$lt_sysroot$func_stripname_result 7431bd3a1963Smrg ;; 7432fc27e79cSmrg *) 7433fc27e79cSmrg func_fatal_error "only absolute run-paths are allowed" 7434fc27e79cSmrg ;; 7435fc27e79cSmrg esac 7436fc27e79cSmrg case "$xrpath " in 7437fc27e79cSmrg *" $dir "*) ;; 7438bd3a1963Smrg *) func_append xrpath " $dir" ;; 7439fc27e79cSmrg esac 7440fc27e79cSmrg continue 7441fc27e79cSmrg ;; 7442659607e0Smrg 7443fc27e79cSmrg -shared) 7444fc27e79cSmrg # The effects of -shared are defined in a previous loop. 7445fc27e79cSmrg continue 7446fc27e79cSmrg ;; 7447659607e0Smrg 7448fc27e79cSmrg -shrext) 7449fc27e79cSmrg prev=shrext 7450fc27e79cSmrg continue 7451fc27e79cSmrg ;; 7452659607e0Smrg 7453fc27e79cSmrg -static | -static-libtool-libs) 7454fc27e79cSmrg # The effects of -static are defined in a previous loop. 7455fc27e79cSmrg # We used to do the same as -all-static on platforms that 7456fc27e79cSmrg # didn't have a PIC flag, but the assumption that the effects 7457fc27e79cSmrg # would be equivalent was wrong. It would break on at least 7458fc27e79cSmrg # Digital Unix and AIX. 7459fc27e79cSmrg continue 7460fc27e79cSmrg ;; 7461659607e0Smrg 7462fc27e79cSmrg -thread-safe) 7463fc27e79cSmrg thread_safe=yes 7464fc27e79cSmrg continue 7465fc27e79cSmrg ;; 7466659607e0Smrg 7467fc27e79cSmrg -version-info) 7468fc27e79cSmrg prev=vinfo 7469fc27e79cSmrg continue 7470fc27e79cSmrg ;; 7471659607e0Smrg 7472fc27e79cSmrg -version-number) 7473fc27e79cSmrg prev=vinfo 7474fc27e79cSmrg vinfo_number=yes 7475fc27e79cSmrg continue 7476fc27e79cSmrg ;; 7477659607e0Smrg 7478fc27e79cSmrg -weak) 7479fc27e79cSmrg prev=weak 7480fc27e79cSmrg continue 7481fc27e79cSmrg ;; 7482659607e0Smrg 7483fc27e79cSmrg -Wc,*) 7484fc27e79cSmrg func_stripname '-Wc,' '' "$arg" 7485fc27e79cSmrg args=$func_stripname_result 7486fc27e79cSmrg arg= 7487e4da38afSmrg save_ifs=$IFS; IFS=, 7488fc27e79cSmrg for flag in $args; do 7489e4da38afSmrg IFS=$save_ifs 7490370b807fSmrg func_quote_arg pretty "$flag" 7491370b807fSmrg func_append arg " $func_quote_arg_result" 7492370b807fSmrg func_append compiler_flags " $func_quote_arg_result" 7493fc27e79cSmrg done 7494e4da38afSmrg IFS=$save_ifs 7495fc27e79cSmrg func_stripname ' ' '' "$arg" 7496fc27e79cSmrg arg=$func_stripname_result 7497fc27e79cSmrg ;; 7498659607e0Smrg 7499fc27e79cSmrg -Wl,*) 7500fc27e79cSmrg func_stripname '-Wl,' '' "$arg" 7501fc27e79cSmrg args=$func_stripname_result 7502fc27e79cSmrg arg= 7503e4da38afSmrg save_ifs=$IFS; IFS=, 7504fc27e79cSmrg for flag in $args; do 7505e4da38afSmrg IFS=$save_ifs 7506370b807fSmrg func_quote_arg pretty "$flag" 7507370b807fSmrg func_append arg " $wl$func_quote_arg_result" 7508370b807fSmrg func_append compiler_flags " $wl$func_quote_arg_result" 7509370b807fSmrg func_append linker_flags " $func_quote_arg_result" 7510fc27e79cSmrg done 7511e4da38afSmrg IFS=$save_ifs 7512fc27e79cSmrg func_stripname ' ' '' "$arg" 7513fc27e79cSmrg arg=$func_stripname_result 7514fc27e79cSmrg ;; 7515659607e0Smrg 7516370b807fSmrg -Xassembler) 7517370b807fSmrg prev=xassembler 7518370b807fSmrg continue 7519370b807fSmrg ;; 7520370b807fSmrg 7521fc27e79cSmrg -Xcompiler) 7522fc27e79cSmrg prev=xcompiler 7523fc27e79cSmrg continue 7524fc27e79cSmrg ;; 7525659607e0Smrg 7526fc27e79cSmrg -Xlinker) 7527fc27e79cSmrg prev=xlinker 7528fc27e79cSmrg continue 7529fc27e79cSmrg ;; 7530659607e0Smrg 7531fc27e79cSmrg -XCClinker) 7532fc27e79cSmrg prev=xcclinker 7533fc27e79cSmrg continue 7534fc27e79cSmrg ;; 7535659607e0Smrg 7536fc27e79cSmrg # -msg_* for osf cc 7537fc27e79cSmrg -msg_*) 7538370b807fSmrg func_quote_arg pretty "$arg" 7539370b807fSmrg arg=$func_quote_arg_result 7540fc27e79cSmrg ;; 7541659607e0Smrg 7542bd3a1963Smrg # Flags to be passed through unchanged, with rationale: 7543bd3a1963Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7544bd3a1963Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 7545bd3a1963Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7546bd3a1963Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7547bd3a1963Smrg # -q* compiler args for the IBM compiler 7548bd3a1963Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7549bd3a1963Smrg # -F/path path to uninstalled frameworks, gcc on darwin 7550bd3a1963Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7551e4da38afSmrg # -fstack-protector* stack protector flags for GCC 7552bd3a1963Smrg # @file GCC response files 7553bd3a1963Smrg # -tp=* Portland pgcc target processor selection 7554bd3a1963Smrg # --sysroot=* for sysroot support 7555e4da38afSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7556370b807fSmrg # -specs=* GCC specs files 7557e4da38afSmrg # -stdlib=* select c++ std lib with clang 7558370b807fSmrg # -fsanitize=* Clang/GCC memory and address sanitizer 7559370b807fSmrg # -fuse-ld=* Linker select flags for GCC 7560370b807fSmrg # -Wa,* Pass flags directly to the assembler 7561fc27e79cSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7562bd3a1963Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7563370b807fSmrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 7564370b807fSmrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 7565370b807fSmrg func_quote_arg pretty "$arg" 7566370b807fSmrg arg=$func_quote_arg_result 7567fc27e79cSmrg func_append compile_command " $arg" 7568fc27e79cSmrg func_append finalize_command " $arg" 7569bd3a1963Smrg func_append compiler_flags " $arg" 7570fc27e79cSmrg continue 7571fc27e79cSmrg ;; 7572659607e0Smrg 7573e4da38afSmrg -Z*) 7574e4da38afSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 7575e4da38afSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 7576e4da38afSmrg compiler_flags="$compiler_flags $arg" 7577e4da38afSmrg func_append compile_command " $arg" 7578e4da38afSmrg func_append finalize_command " $arg" 7579e4da38afSmrg case $arg in 7580e4da38afSmrg -Zlinker | -Zstack) 7581e4da38afSmrg prev=xcompiler 7582e4da38afSmrg ;; 7583e4da38afSmrg esac 7584e4da38afSmrg continue 7585e4da38afSmrg else 7586e4da38afSmrg # Otherwise treat like 'Some other compiler flag' below 7587370b807fSmrg func_quote_arg pretty "$arg" 7588370b807fSmrg arg=$func_quote_arg_result 7589e4da38afSmrg fi 7590e4da38afSmrg ;; 7591e4da38afSmrg 7592fc27e79cSmrg # Some other compiler flag. 7593fc27e79cSmrg -* | +*) 7594370b807fSmrg func_quote_arg pretty "$arg" 7595370b807fSmrg arg=$func_quote_arg_result 7596fc27e79cSmrg ;; 7597659607e0Smrg 7598fc27e79cSmrg *.$objext) 7599fc27e79cSmrg # A standard object. 7600bd3a1963Smrg func_append objs " $arg" 7601fc27e79cSmrg ;; 7602fc27e79cSmrg 7603fc27e79cSmrg *.lo) 7604fc27e79cSmrg # A libtool-controlled object. 7605fc27e79cSmrg 7606fc27e79cSmrg # Check to see that this really is a libtool object. 7607fc27e79cSmrg if func_lalib_unsafe_p "$arg"; then 7608fc27e79cSmrg pic_object= 7609fc27e79cSmrg non_pic_object= 7610fc27e79cSmrg 7611fc27e79cSmrg # Read the .lo file 7612fc27e79cSmrg func_source "$arg" 7613fc27e79cSmrg 7614fc27e79cSmrg if test -z "$pic_object" || 7615fc27e79cSmrg test -z "$non_pic_object" || 7616e4da38afSmrg test none = "$pic_object" && 7617e4da38afSmrg test none = "$non_pic_object"; then 7618e4da38afSmrg func_fatal_error "cannot find name of object for '$arg'" 7619fc27e79cSmrg fi 7620fc27e79cSmrg 7621fc27e79cSmrg # Extract subdirectory from the argument. 7622fc27e79cSmrg func_dirname "$arg" "/" "" 7623e4da38afSmrg xdir=$func_dirname_result 7624fc27e79cSmrg 7625e4da38afSmrg test none = "$pic_object" || { 7626fc27e79cSmrg # Prepend the subdirectory the object is found in. 7627e4da38afSmrg pic_object=$xdir$pic_object 7628fc27e79cSmrg 7629e4da38afSmrg if test dlfiles = "$prev"; then 7630e4da38afSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7631bd3a1963Smrg func_append dlfiles " $pic_object" 7632fc27e79cSmrg prev= 7633fc27e79cSmrg continue 7634fc27e79cSmrg else 7635fc27e79cSmrg # If libtool objects are unsupported, then we need to preload. 7636fc27e79cSmrg prev=dlprefiles 7637fc27e79cSmrg fi 7638fc27e79cSmrg fi 7639fc27e79cSmrg 7640fc27e79cSmrg # CHECK ME: I think I busted this. -Ossama 7641e4da38afSmrg if test dlprefiles = "$prev"; then 7642fc27e79cSmrg # Preload the old-style object. 7643bd3a1963Smrg func_append dlprefiles " $pic_object" 7644fc27e79cSmrg prev= 7645fc27e79cSmrg fi 7646fc27e79cSmrg 7647fc27e79cSmrg # A PIC object. 7648fc27e79cSmrg func_append libobjs " $pic_object" 7649e4da38afSmrg arg=$pic_object 7650e4da38afSmrg } 7651fc27e79cSmrg 7652fc27e79cSmrg # Non-PIC object. 7653e4da38afSmrg if test none != "$non_pic_object"; then 7654fc27e79cSmrg # Prepend the subdirectory the object is found in. 7655e4da38afSmrg non_pic_object=$xdir$non_pic_object 7656fc27e79cSmrg 7657fc27e79cSmrg # A standard non-PIC object 7658fc27e79cSmrg func_append non_pic_objects " $non_pic_object" 7659e4da38afSmrg if test -z "$pic_object" || test none = "$pic_object"; then 7660e4da38afSmrg arg=$non_pic_object 7661fc27e79cSmrg fi 7662fc27e79cSmrg else 7663fc27e79cSmrg # If the PIC object exists, use it instead. 7664fc27e79cSmrg # $xdir was prepended to $pic_object above. 7665e4da38afSmrg non_pic_object=$pic_object 7666fc27e79cSmrg func_append non_pic_objects " $non_pic_object" 7667fc27e79cSmrg fi 7668fc27e79cSmrg else 7669fc27e79cSmrg # Only an error if not doing a dry-run. 7670fc27e79cSmrg if $opt_dry_run; then 7671fc27e79cSmrg # Extract subdirectory from the argument. 7672fc27e79cSmrg func_dirname "$arg" "/" "" 7673e4da38afSmrg xdir=$func_dirname_result 7674fc27e79cSmrg 7675fc27e79cSmrg func_lo2o "$arg" 7676fc27e79cSmrg pic_object=$xdir$objdir/$func_lo2o_result 7677fc27e79cSmrg non_pic_object=$xdir$func_lo2o_result 7678fc27e79cSmrg func_append libobjs " $pic_object" 7679fc27e79cSmrg func_append non_pic_objects " $non_pic_object" 7680fc27e79cSmrg else 7681e4da38afSmrg func_fatal_error "'$arg' is not a valid libtool object" 7682fc27e79cSmrg fi 7683fc27e79cSmrg fi 7684fc27e79cSmrg ;; 7685fc27e79cSmrg 7686fc27e79cSmrg *.$libext) 7687fc27e79cSmrg # An archive. 7688bd3a1963Smrg func_append deplibs " $arg" 7689bd3a1963Smrg func_append old_deplibs " $arg" 7690fc27e79cSmrg continue 7691fc27e79cSmrg ;; 7692fc27e79cSmrg 7693fc27e79cSmrg *.la) 7694fc27e79cSmrg # A libtool-controlled library. 7695fc27e79cSmrg 7696bd3a1963Smrg func_resolve_sysroot "$arg" 7697e4da38afSmrg if test dlfiles = "$prev"; then 7698fc27e79cSmrg # This library was specified with -dlopen. 7699bd3a1963Smrg func_append dlfiles " $func_resolve_sysroot_result" 7700fc27e79cSmrg prev= 7701e4da38afSmrg elif test dlprefiles = "$prev"; then 7702fc27e79cSmrg # The library was specified with -dlpreopen. 7703bd3a1963Smrg func_append dlprefiles " $func_resolve_sysroot_result" 7704fc27e79cSmrg prev= 7705fc27e79cSmrg else 7706bd3a1963Smrg func_append deplibs " $func_resolve_sysroot_result" 7707fc27e79cSmrg fi 7708fc27e79cSmrg continue 7709fc27e79cSmrg ;; 7710fc27e79cSmrg 7711fc27e79cSmrg # Some other compiler argument. 7712fc27e79cSmrg *) 7713fc27e79cSmrg # Unknown arguments in both finalize_command and compile_command need 7714fc27e79cSmrg # to be aesthetically quoted because they are evaled later. 7715370b807fSmrg func_quote_arg pretty "$arg" 7716370b807fSmrg arg=$func_quote_arg_result 7717fc27e79cSmrg ;; 7718fc27e79cSmrg esac # arg 7719fc27e79cSmrg 7720fc27e79cSmrg # Now actually substitute the argument into the commands. 7721fc27e79cSmrg if test -n "$arg"; then 7722fc27e79cSmrg func_append compile_command " $arg" 7723fc27e79cSmrg func_append finalize_command " $arg" 7724fc27e79cSmrg fi 7725fc27e79cSmrg done # argument parsing loop 7726fc27e79cSmrg 7727fc27e79cSmrg test -n "$prev" && \ 7728e4da38afSmrg func_fatal_help "the '$prevarg' option requires an argument" 7729fc27e79cSmrg 7730e4da38afSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7731fc27e79cSmrg eval arg=\"$export_dynamic_flag_spec\" 7732fc27e79cSmrg func_append compile_command " $arg" 7733fc27e79cSmrg func_append finalize_command " $arg" 7734fc27e79cSmrg fi 7735fc27e79cSmrg 7736fc27e79cSmrg oldlibs= 7737fc27e79cSmrg # calculate the name of the file, without its directory 7738fc27e79cSmrg func_basename "$output" 7739e4da38afSmrg outputname=$func_basename_result 7740e4da38afSmrg libobjs_save=$libobjs 7741fc27e79cSmrg 7742fc27e79cSmrg if test -n "$shlibpath_var"; then 7743fc27e79cSmrg # get the directories listed in $shlibpath_var 7744e4da38afSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7745659607e0Smrg else 7746fc27e79cSmrg shlib_search_path= 7747659607e0Smrg fi 7748fc27e79cSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7749fc27e79cSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7750659607e0Smrg 7751e4da38afSmrg # Definition is injected by LT_CONFIG during libtool generation. 7752e4da38afSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7753e4da38afSmrg 7754fc27e79cSmrg func_dirname "$output" "/" "" 7755e4da38afSmrg output_objdir=$func_dirname_result$objdir 7756bd3a1963Smrg func_to_tool_file "$output_objdir/" 7757bd3a1963Smrg tool_output_objdir=$func_to_tool_file_result 7758fc27e79cSmrg # Create the object directory. 7759fc27e79cSmrg func_mkdir_p "$output_objdir" 7760659607e0Smrg 7761fc27e79cSmrg # Determine the type of output 7762fc27e79cSmrg case $output in 7763fc27e79cSmrg "") 7764fc27e79cSmrg func_fatal_help "you must specify an output file" 7765fc27e79cSmrg ;; 7766fc27e79cSmrg *.$libext) linkmode=oldlib ;; 7767fc27e79cSmrg *.lo | *.$objext) linkmode=obj ;; 7768fc27e79cSmrg *.la) linkmode=lib ;; 7769fc27e79cSmrg *) linkmode=prog ;; # Anything else should be a program. 7770fc27e79cSmrg esac 7771fc27e79cSmrg 7772fc27e79cSmrg specialdeplibs= 7773fc27e79cSmrg 7774fc27e79cSmrg libs= 7775fc27e79cSmrg # Find all interdependent deplibs by searching for libraries 7776fc27e79cSmrg # that are linked more than once (e.g. -la -lb -la) 7777fc27e79cSmrg for deplib in $deplibs; do 7778e4da38afSmrg if $opt_preserve_dup_deps; then 7779fc27e79cSmrg case "$libs " in 7780bd3a1963Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7781fc27e79cSmrg esac 7782fc27e79cSmrg fi 7783bd3a1963Smrg func_append libs " $deplib" 7784fc27e79cSmrg done 7785fc27e79cSmrg 7786e4da38afSmrg if test lib = "$linkmode"; then 7787fc27e79cSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7788fc27e79cSmrg 7789fc27e79cSmrg # Compute libraries that are listed more than once in $predeps 7790fc27e79cSmrg # $postdeps and mark them as special (i.e., whose duplicates are 7791fc27e79cSmrg # not to be eliminated). 7792fc27e79cSmrg pre_post_deps= 7793fc27e79cSmrg if $opt_duplicate_compiler_generated_deps; then 7794fc27e79cSmrg for pre_post_dep in $predeps $postdeps; do 7795fc27e79cSmrg case "$pre_post_deps " in 7796bd3a1963Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7797fc27e79cSmrg esac 7798bd3a1963Smrg func_append pre_post_deps " $pre_post_dep" 7799fc27e79cSmrg done 7800fc27e79cSmrg fi 7801fc27e79cSmrg pre_post_deps= 7802fc27e79cSmrg fi 7803fc27e79cSmrg 7804fc27e79cSmrg deplibs= 7805fc27e79cSmrg newdependency_libs= 7806fc27e79cSmrg newlib_search_path= 7807fc27e79cSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 7808fc27e79cSmrg notinst_deplibs= # not-installed libtool libraries 7809fc27e79cSmrg notinst_path= # paths that contain not-installed libtool libraries 7810fc27e79cSmrg 7811fc27e79cSmrg case $linkmode in 7812fc27e79cSmrg lib) 7813fc27e79cSmrg passes="conv dlpreopen link" 7814fc27e79cSmrg for file in $dlfiles $dlprefiles; do 7815fc27e79cSmrg case $file in 7816fc27e79cSmrg *.la) ;; 7817fc27e79cSmrg *) 7818e4da38afSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7819fc27e79cSmrg ;; 7820fc27e79cSmrg esac 7821fc27e79cSmrg done 7822fc27e79cSmrg ;; 7823fc27e79cSmrg prog) 7824fc27e79cSmrg compile_deplibs= 7825fc27e79cSmrg finalize_deplibs= 7826e4da38afSmrg alldeplibs=false 7827fc27e79cSmrg newdlfiles= 7828fc27e79cSmrg newdlprefiles= 7829fc27e79cSmrg passes="conv scan dlopen dlpreopen link" 7830fc27e79cSmrg ;; 7831fc27e79cSmrg *) passes="conv" 7832fc27e79cSmrg ;; 7833fc27e79cSmrg esac 7834fc27e79cSmrg 7835fc27e79cSmrg for pass in $passes; do 7836fc27e79cSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 7837fc27e79cSmrg # so that -L comes before libs that need it for instance... 7838e4da38afSmrg if test lib,link = "$linkmode,$pass"; then 7839fc27e79cSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 7840fc27e79cSmrg ## order, and fix it there properly 7841fc27e79cSmrg tmp_deplibs= 7842fc27e79cSmrg for deplib in $deplibs; do 7843fc27e79cSmrg tmp_deplibs="$deplib $tmp_deplibs" 7844fc27e79cSmrg done 7845e4da38afSmrg deplibs=$tmp_deplibs 7846fc27e79cSmrg fi 7847fc27e79cSmrg 7848e4da38afSmrg if test lib,link = "$linkmode,$pass" || 7849e4da38afSmrg test prog,scan = "$linkmode,$pass"; then 7850e4da38afSmrg libs=$deplibs 7851fc27e79cSmrg deplibs= 7852fc27e79cSmrg fi 7853e4da38afSmrg if test prog = "$linkmode"; then 7854fc27e79cSmrg case $pass in 7855e4da38afSmrg dlopen) libs=$dlfiles ;; 7856e4da38afSmrg dlpreopen) libs=$dlprefiles ;; 7857fc27e79cSmrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7858fc27e79cSmrg esac 7859fc27e79cSmrg fi 7860e4da38afSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 7861fc27e79cSmrg # Collect and forward deplibs of preopened libtool libs 7862fc27e79cSmrg for lib in $dlprefiles; do 7863fc27e79cSmrg # Ignore non-libtool-libs 7864fc27e79cSmrg dependency_libs= 7865bd3a1963Smrg func_resolve_sysroot "$lib" 7866fc27e79cSmrg case $lib in 7867bd3a1963Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 7868fc27e79cSmrg esac 7869fc27e79cSmrg 7870fc27e79cSmrg # Collect preopened libtool deplibs, except any this library 7871fc27e79cSmrg # has declared as weak libs 7872fc27e79cSmrg for deplib in $dependency_libs; do 7873bd3a1963Smrg func_basename "$deplib" 7874bd3a1963Smrg deplib_base=$func_basename_result 7875fc27e79cSmrg case " $weak_libs " in 7876fc27e79cSmrg *" $deplib_base "*) ;; 7877bd3a1963Smrg *) func_append deplibs " $deplib" ;; 7878fc27e79cSmrg esac 7879fc27e79cSmrg done 7880fc27e79cSmrg done 7881e4da38afSmrg libs=$dlprefiles 7882fc27e79cSmrg fi 7883e4da38afSmrg if test dlopen = "$pass"; then 7884fc27e79cSmrg # Collect dlpreopened libraries 7885e4da38afSmrg save_deplibs=$deplibs 7886fc27e79cSmrg deplibs= 7887fc27e79cSmrg fi 7888fc27e79cSmrg 7889fc27e79cSmrg for deplib in $libs; do 7890fc27e79cSmrg lib= 7891e4da38afSmrg found=false 7892fc27e79cSmrg case $deplib in 7893a73597f9Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7894a73597f9Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7895e4da38afSmrg if test prog,link = "$linkmode,$pass"; then 7896fc27e79cSmrg compile_deplibs="$deplib $compile_deplibs" 7897fc27e79cSmrg finalize_deplibs="$deplib $finalize_deplibs" 7898fc27e79cSmrg else 7899bd3a1963Smrg func_append compiler_flags " $deplib" 7900e4da38afSmrg if test lib = "$linkmode"; then 7901fc27e79cSmrg case "$new_inherited_linker_flags " in 7902fc27e79cSmrg *" $deplib "*) ;; 7903bd3a1963Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7904fc27e79cSmrg esac 7905fc27e79cSmrg fi 7906fc27e79cSmrg fi 7907fc27e79cSmrg continue 7908fc27e79cSmrg ;; 7909fc27e79cSmrg -l*) 7910e4da38afSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 7911e4da38afSmrg func_warning "'-l' is ignored for archives/objects" 7912fc27e79cSmrg continue 7913fc27e79cSmrg fi 7914fc27e79cSmrg func_stripname '-l' '' "$deplib" 7915fc27e79cSmrg name=$func_stripname_result 7916e4da38afSmrg if test lib = "$linkmode"; then 7917fc27e79cSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7918fc27e79cSmrg else 7919fc27e79cSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7920fc27e79cSmrg fi 7921fc27e79cSmrg for searchdir in $searchdirs; do 7922fc27e79cSmrg for search_ext in .la $std_shrext .so .a; do 7923fc27e79cSmrg # Search the libtool library 7924e4da38afSmrg lib=$searchdir/lib$name$search_ext 7925fc27e79cSmrg if test -f "$lib"; then 7926e4da38afSmrg if test .la = "$search_ext"; then 7927e4da38afSmrg found=: 7928fc27e79cSmrg else 7929e4da38afSmrg found=false 7930fc27e79cSmrg fi 7931fc27e79cSmrg break 2 7932fc27e79cSmrg fi 7933fc27e79cSmrg done 7934fc27e79cSmrg done 7935e4da38afSmrg if $found; then 7936e4da38afSmrg # deplib is a libtool library 7937fc27e79cSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7938fc27e79cSmrg # We need to do some special things here, and not later. 7939e4da38afSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7940fc27e79cSmrg case " $predeps $postdeps " in 7941fc27e79cSmrg *" $deplib "*) 7942fc27e79cSmrg if func_lalib_p "$lib"; then 7943fc27e79cSmrg library_names= 7944fc27e79cSmrg old_library= 7945fc27e79cSmrg func_source "$lib" 7946fc27e79cSmrg for l in $old_library $library_names; do 7947e4da38afSmrg ll=$l 7948fc27e79cSmrg done 7949e4da38afSmrg if test "X$ll" = "X$old_library"; then # only static version available 7950e4da38afSmrg found=false 7951fc27e79cSmrg func_dirname "$lib" "" "." 7952e4da38afSmrg ladir=$func_dirname_result 7953fc27e79cSmrg lib=$ladir/$old_library 7954e4da38afSmrg if test prog,link = "$linkmode,$pass"; then 7955fc27e79cSmrg compile_deplibs="$deplib $compile_deplibs" 7956fc27e79cSmrg finalize_deplibs="$deplib $finalize_deplibs" 7957fc27e79cSmrg else 7958fc27e79cSmrg deplibs="$deplib $deplibs" 7959e4da38afSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7960fc27e79cSmrg fi 7961fc27e79cSmrg continue 7962fc27e79cSmrg fi 7963fc27e79cSmrg fi 7964fc27e79cSmrg ;; 7965fc27e79cSmrg *) ;; 7966fc27e79cSmrg esac 7967fc27e79cSmrg fi 7968e4da38afSmrg else 7969e4da38afSmrg # deplib doesn't seem to be a libtool library 7970e4da38afSmrg if test prog,link = "$linkmode,$pass"; then 7971e4da38afSmrg compile_deplibs="$deplib $compile_deplibs" 7972e4da38afSmrg finalize_deplibs="$deplib $finalize_deplibs" 7973e4da38afSmrg else 7974e4da38afSmrg deplibs="$deplib $deplibs" 7975e4da38afSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7976e4da38afSmrg fi 7977e4da38afSmrg continue 7978fc27e79cSmrg fi 7979fc27e79cSmrg ;; # -l 7980fc27e79cSmrg *.ltframework) 7981e4da38afSmrg if test prog,link = "$linkmode,$pass"; then 7982fc27e79cSmrg compile_deplibs="$deplib $compile_deplibs" 7983fc27e79cSmrg finalize_deplibs="$deplib $finalize_deplibs" 7984fc27e79cSmrg else 7985fc27e79cSmrg deplibs="$deplib $deplibs" 7986e4da38afSmrg if test lib = "$linkmode"; then 7987fc27e79cSmrg case "$new_inherited_linker_flags " in 7988fc27e79cSmrg *" $deplib "*) ;; 7989bd3a1963Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7990fc27e79cSmrg esac 7991fc27e79cSmrg fi 7992fc27e79cSmrg fi 7993fc27e79cSmrg continue 7994fc27e79cSmrg ;; 7995fc27e79cSmrg -L*) 7996fc27e79cSmrg case $linkmode in 7997fc27e79cSmrg lib) 7998fc27e79cSmrg deplibs="$deplib $deplibs" 7999e4da38afSmrg test conv = "$pass" && continue 8000fc27e79cSmrg newdependency_libs="$deplib $newdependency_libs" 8001fc27e79cSmrg func_stripname '-L' '' "$deplib" 8002bd3a1963Smrg func_resolve_sysroot "$func_stripname_result" 8003bd3a1963Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8004fc27e79cSmrg ;; 8005fc27e79cSmrg prog) 8006e4da38afSmrg if test conv = "$pass"; then 8007fc27e79cSmrg deplibs="$deplib $deplibs" 8008fc27e79cSmrg continue 8009fc27e79cSmrg fi 8010e4da38afSmrg if test scan = "$pass"; then 8011fc27e79cSmrg deplibs="$deplib $deplibs" 8012fc27e79cSmrg else 8013fc27e79cSmrg compile_deplibs="$deplib $compile_deplibs" 8014fc27e79cSmrg finalize_deplibs="$deplib $finalize_deplibs" 8015fc27e79cSmrg fi 8016fc27e79cSmrg func_stripname '-L' '' "$deplib" 8017bd3a1963Smrg func_resolve_sysroot "$func_stripname_result" 8018bd3a1963Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8019fc27e79cSmrg ;; 8020fc27e79cSmrg *) 8021e4da38afSmrg func_warning "'-L' is ignored for archives/objects" 8022fc27e79cSmrg ;; 8023fc27e79cSmrg esac # linkmode 8024fc27e79cSmrg continue 8025fc27e79cSmrg ;; # -L 8026fc27e79cSmrg -R*) 8027e4da38afSmrg if test link = "$pass"; then 8028fc27e79cSmrg func_stripname '-R' '' "$deplib" 8029bd3a1963Smrg func_resolve_sysroot "$func_stripname_result" 8030bd3a1963Smrg dir=$func_resolve_sysroot_result 8031fc27e79cSmrg # Make sure the xrpath contains only unique directories. 8032fc27e79cSmrg case "$xrpath " in 8033fc27e79cSmrg *" $dir "*) ;; 8034bd3a1963Smrg *) func_append xrpath " $dir" ;; 8035fc27e79cSmrg esac 8036fc27e79cSmrg fi 8037fc27e79cSmrg deplibs="$deplib $deplibs" 8038fc27e79cSmrg continue 8039fc27e79cSmrg ;; 8040bd3a1963Smrg *.la) 8041bd3a1963Smrg func_resolve_sysroot "$deplib" 8042bd3a1963Smrg lib=$func_resolve_sysroot_result 8043bd3a1963Smrg ;; 8044fc27e79cSmrg *.$libext) 8045e4da38afSmrg if test conv = "$pass"; then 8046fc27e79cSmrg deplibs="$deplib $deplibs" 8047fc27e79cSmrg continue 8048fc27e79cSmrg fi 8049fc27e79cSmrg case $linkmode in 8050fc27e79cSmrg lib) 8051fc27e79cSmrg # Linking convenience modules into shared libraries is allowed, 8052fc27e79cSmrg # but linking other static libraries is non-portable. 8053fc27e79cSmrg case " $dlpreconveniencelibs " in 8054fc27e79cSmrg *" $deplib "*) ;; 8055fc27e79cSmrg *) 8056e4da38afSmrg valid_a_lib=false 8057fc27e79cSmrg case $deplibs_check_method in 8058fc27e79cSmrg match_pattern*) 8059fc27e79cSmrg set dummy $deplibs_check_method; shift 8060fc27e79cSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 8061bd3a1963Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 8062fc27e79cSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 8063e4da38afSmrg valid_a_lib=: 8064fc27e79cSmrg fi 8065fc27e79cSmrg ;; 8066fc27e79cSmrg pass_all) 8067e4da38afSmrg valid_a_lib=: 8068fc27e79cSmrg ;; 8069fc27e79cSmrg esac 8070e4da38afSmrg if $valid_a_lib; then 8071e4da38afSmrg echo 8072e4da38afSmrg $ECHO "*** Warning: Linking the shared library $output against the" 8073e4da38afSmrg $ECHO "*** static library $deplib is not portable!" 8074e4da38afSmrg deplibs="$deplib $deplibs" 8075e4da38afSmrg else 8076bd3a1963Smrg echo 8077fc27e79cSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 8078bd3a1963Smrg echo "*** I have the capability to make that library automatically link in when" 8079bd3a1963Smrg echo "*** you link to this library. But I can only do this if you have a" 8080bd3a1963Smrg echo "*** shared version of the library, which you do not appear to have" 8081bd3a1963Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 8082bd3a1963Smrg echo "*** that it is just a static archive that I should not use here." 8083fc27e79cSmrg fi 8084fc27e79cSmrg ;; 8085fc27e79cSmrg esac 8086fc27e79cSmrg continue 8087fc27e79cSmrg ;; 8088fc27e79cSmrg prog) 8089e4da38afSmrg if test link != "$pass"; then 8090fc27e79cSmrg deplibs="$deplib $deplibs" 8091fc27e79cSmrg else 8092fc27e79cSmrg compile_deplibs="$deplib $compile_deplibs" 8093fc27e79cSmrg finalize_deplibs="$deplib $finalize_deplibs" 8094fc27e79cSmrg fi 8095fc27e79cSmrg continue 8096fc27e79cSmrg ;; 8097fc27e79cSmrg esac # linkmode 8098fc27e79cSmrg ;; # *.$libext 8099fc27e79cSmrg *.lo | *.$objext) 8100e4da38afSmrg if test conv = "$pass"; then 8101fc27e79cSmrg deplibs="$deplib $deplibs" 8102e4da38afSmrg elif test prog = "$linkmode"; then 8103e4da38afSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 8104fc27e79cSmrg # If there is no dlopen support or we're linking statically, 8105fc27e79cSmrg # we need to preload. 8106bd3a1963Smrg func_append newdlprefiles " $deplib" 8107fc27e79cSmrg compile_deplibs="$deplib $compile_deplibs" 8108fc27e79cSmrg finalize_deplibs="$deplib $finalize_deplibs" 8109fc27e79cSmrg else 8110bd3a1963Smrg func_append newdlfiles " $deplib" 8111fc27e79cSmrg fi 8112fc27e79cSmrg fi 8113fc27e79cSmrg continue 8114fc27e79cSmrg ;; 8115fc27e79cSmrg %DEPLIBS%) 8116e4da38afSmrg alldeplibs=: 8117fc27e79cSmrg continue 8118fc27e79cSmrg ;; 8119fc27e79cSmrg esac # case $deplib 8120fc27e79cSmrg 8121e4da38afSmrg $found || test -f "$lib" \ 8122e4da38afSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 8123fc27e79cSmrg 8124fc27e79cSmrg # Check to see that this really is a libtool archive. 8125fc27e79cSmrg func_lalib_unsafe_p "$lib" \ 8126e4da38afSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 8127fc27e79cSmrg 8128fc27e79cSmrg func_dirname "$lib" "" "." 8129e4da38afSmrg ladir=$func_dirname_result 8130fc27e79cSmrg 8131fc27e79cSmrg dlname= 8132fc27e79cSmrg dlopen= 8133fc27e79cSmrg dlpreopen= 8134fc27e79cSmrg libdir= 8135fc27e79cSmrg library_names= 8136fc27e79cSmrg old_library= 8137fc27e79cSmrg inherited_linker_flags= 8138fc27e79cSmrg # If the library was installed with an old release of libtool, 8139fc27e79cSmrg # it will not redefine variables installed, or shouldnotlink 8140fc27e79cSmrg installed=yes 8141fc27e79cSmrg shouldnotlink=no 8142fc27e79cSmrg avoidtemprpath= 8143fc27e79cSmrg 8144fc27e79cSmrg 8145fc27e79cSmrg # Read the .la file 8146fc27e79cSmrg func_source "$lib" 8147fc27e79cSmrg 8148fc27e79cSmrg # Convert "-framework foo" to "foo.ltframework" 8149fc27e79cSmrg if test -n "$inherited_linker_flags"; then 8150bd3a1963Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 8151fc27e79cSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 8152fc27e79cSmrg case " $new_inherited_linker_flags " in 8153fc27e79cSmrg *" $tmp_inherited_linker_flag "*) ;; 8154bd3a1963Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 8155fc27e79cSmrg esac 8156fc27e79cSmrg done 8157fc27e79cSmrg fi 8158bd3a1963Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8159e4da38afSmrg if test lib,link = "$linkmode,$pass" || 8160e4da38afSmrg test prog,scan = "$linkmode,$pass" || 8161e4da38afSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 8162bd3a1963Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 8163bd3a1963Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 8164fc27e79cSmrg fi 8165fc27e79cSmrg 8166e4da38afSmrg if test conv = "$pass"; then 8167fc27e79cSmrg # Only check for convenience libraries 8168fc27e79cSmrg deplibs="$lib $deplibs" 8169fc27e79cSmrg if test -z "$libdir"; then 8170fc27e79cSmrg if test -z "$old_library"; then 8171e4da38afSmrg func_fatal_error "cannot find name of link library for '$lib'" 8172fc27e79cSmrg fi 8173fc27e79cSmrg # It is a libtool convenience library, so add in its objects. 8174bd3a1963Smrg func_append convenience " $ladir/$objdir/$old_library" 8175bd3a1963Smrg func_append old_convenience " $ladir/$objdir/$old_library" 8176e4da38afSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 8177e4da38afSmrg func_fatal_error "'$lib' is not a convenience library" 8178fc27e79cSmrg fi 8179fc27e79cSmrg tmp_libs= 8180fc27e79cSmrg for deplib in $dependency_libs; do 8181fc27e79cSmrg deplibs="$deplib $deplibs" 8182e4da38afSmrg if $opt_preserve_dup_deps; then 8183fc27e79cSmrg case "$tmp_libs " in 8184bd3a1963Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8185fc27e79cSmrg esac 8186fc27e79cSmrg fi 8187bd3a1963Smrg func_append tmp_libs " $deplib" 8188fc27e79cSmrg done 8189fc27e79cSmrg continue 8190fc27e79cSmrg fi # $pass = conv 8191fc27e79cSmrg 8192fc27e79cSmrg 8193fc27e79cSmrg # Get the name of the library we link against. 8194fc27e79cSmrg linklib= 8195bd3a1963Smrg if test -n "$old_library" && 8196e4da38afSmrg { test yes = "$prefer_static_libs" || 8197e4da38afSmrg test built,no = "$prefer_static_libs,$installed"; }; then 8198bd3a1963Smrg linklib=$old_library 8199bd3a1963Smrg else 8200bd3a1963Smrg for l in $old_library $library_names; do 8201e4da38afSmrg linklib=$l 8202bd3a1963Smrg done 8203bd3a1963Smrg fi 8204fc27e79cSmrg if test -z "$linklib"; then 8205e4da38afSmrg func_fatal_error "cannot find name of link library for '$lib'" 8206fc27e79cSmrg fi 8207fc27e79cSmrg 8208fc27e79cSmrg # This library was specified with -dlopen. 8209e4da38afSmrg if test dlopen = "$pass"; then 8210e4da38afSmrg test -z "$libdir" \ 8211e4da38afSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 8212fc27e79cSmrg if test -z "$dlname" || 8213e4da38afSmrg test yes != "$dlopen_support" || 8214e4da38afSmrg test no = "$build_libtool_libs" 8215e4da38afSmrg then 8216fc27e79cSmrg # If there is no dlname, no dlopen support or we're linking 8217fc27e79cSmrg # statically, we need to preload. We also need to preload any 8218fc27e79cSmrg # dependent libraries so libltdl's deplib preloader doesn't 8219fc27e79cSmrg # bomb out in the load deplibs phase. 8220bd3a1963Smrg func_append dlprefiles " $lib $dependency_libs" 8221fc27e79cSmrg else 8222bd3a1963Smrg func_append newdlfiles " $lib" 8223fc27e79cSmrg fi 8224fc27e79cSmrg continue 8225fc27e79cSmrg fi # $pass = dlopen 8226fc27e79cSmrg 8227fc27e79cSmrg # We need an absolute path. 8228fc27e79cSmrg case $ladir in 8229e4da38afSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 8230fc27e79cSmrg *) 8231fc27e79cSmrg abs_ladir=`cd "$ladir" && pwd` 8232fc27e79cSmrg if test -z "$abs_ladir"; then 8233e4da38afSmrg func_warning "cannot determine absolute directory name of '$ladir'" 8234fc27e79cSmrg func_warning "passing it literally to the linker, although it might fail" 8235e4da38afSmrg abs_ladir=$ladir 8236fc27e79cSmrg fi 8237fc27e79cSmrg ;; 8238fc27e79cSmrg esac 8239fc27e79cSmrg func_basename "$lib" 8240e4da38afSmrg laname=$func_basename_result 8241fc27e79cSmrg 8242fc27e79cSmrg # Find the relevant object directory and library name. 8243e4da38afSmrg if test yes = "$installed"; then 8244bd3a1963Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8245e4da38afSmrg func_warning "library '$lib' was moved." 8246e4da38afSmrg dir=$ladir 8247e4da38afSmrg absdir=$abs_ladir 8248e4da38afSmrg libdir=$abs_ladir 8249fc27e79cSmrg else 8250e4da38afSmrg dir=$lt_sysroot$libdir 8251e4da38afSmrg absdir=$lt_sysroot$libdir 8252fc27e79cSmrg fi 8253e4da38afSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 8254fc27e79cSmrg else 8255fc27e79cSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8256e4da38afSmrg dir=$ladir 8257e4da38afSmrg absdir=$abs_ladir 8258fc27e79cSmrg # Remove this search path later 8259bd3a1963Smrg func_append notinst_path " $abs_ladir" 8260fc27e79cSmrg else 8261e4da38afSmrg dir=$ladir/$objdir 8262e4da38afSmrg absdir=$abs_ladir/$objdir 8263fc27e79cSmrg # Remove this search path later 8264bd3a1963Smrg func_append notinst_path " $abs_ladir" 8265fc27e79cSmrg fi 8266fc27e79cSmrg fi # $installed = yes 8267fc27e79cSmrg func_stripname 'lib' '.la' "$laname" 8268fc27e79cSmrg name=$func_stripname_result 8269fc27e79cSmrg 8270fc27e79cSmrg # This library was specified with -dlpreopen. 8271e4da38afSmrg if test dlpreopen = "$pass"; then 8272e4da38afSmrg if test -z "$libdir" && test prog = "$linkmode"; then 8273e4da38afSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 8274fc27e79cSmrg fi 8275e4da38afSmrg case $host in 8276bd3a1963Smrg # special handling for platforms with PE-DLLs. 8277bd3a1963Smrg *cygwin* | *mingw* | *cegcc* ) 8278bd3a1963Smrg # Linker will automatically link against shared library if both 8279bd3a1963Smrg # static and shared are present. Therefore, ensure we extract 8280bd3a1963Smrg # symbols from the import library if a shared library is present 8281bd3a1963Smrg # (otherwise, the dlopen module name will be incorrect). We do 8282bd3a1963Smrg # this by putting the import library name into $newdlprefiles. 8283bd3a1963Smrg # We recover the dlopen module name by 'saving' the la file 8284bd3a1963Smrg # name in a special purpose variable, and (later) extracting the 8285bd3a1963Smrg # dlname from the la file. 8286bd3a1963Smrg if test -n "$dlname"; then 8287bd3a1963Smrg func_tr_sh "$dir/$linklib" 8288bd3a1963Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8289bd3a1963Smrg func_append newdlprefiles " $dir/$linklib" 8290bd3a1963Smrg else 8291bd3a1963Smrg func_append newdlprefiles " $dir/$old_library" 8292bd3a1963Smrg # Keep a list of preopened convenience libraries to check 8293bd3a1963Smrg # that they are being used correctly in the link pass. 8294bd3a1963Smrg test -z "$libdir" && \ 8295bd3a1963Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8296bd3a1963Smrg fi 8297bd3a1963Smrg ;; 8298bd3a1963Smrg * ) 8299bd3a1963Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8300bd3a1963Smrg # are required to link). 8301bd3a1963Smrg if test -n "$old_library"; then 8302bd3a1963Smrg func_append newdlprefiles " $dir/$old_library" 8303bd3a1963Smrg # Keep a list of preopened convenience libraries to check 8304bd3a1963Smrg # that they are being used correctly in the link pass. 8305bd3a1963Smrg test -z "$libdir" && \ 8306bd3a1963Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8307bd3a1963Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8308bd3a1963Smrg elif test -n "$dlname"; then 8309bd3a1963Smrg func_append newdlprefiles " $dir/$dlname" 8310bd3a1963Smrg else 8311bd3a1963Smrg func_append newdlprefiles " $dir/$linklib" 8312bd3a1963Smrg fi 8313bd3a1963Smrg ;; 8314bd3a1963Smrg esac 8315fc27e79cSmrg fi # $pass = dlpreopen 8316fc27e79cSmrg 8317fc27e79cSmrg if test -z "$libdir"; then 8318fc27e79cSmrg # Link the convenience library 8319e4da38afSmrg if test lib = "$linkmode"; then 8320fc27e79cSmrg deplibs="$dir/$old_library $deplibs" 8321e4da38afSmrg elif test prog,link = "$linkmode,$pass"; then 8322fc27e79cSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 8323fc27e79cSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8324fc27e79cSmrg else 8325fc27e79cSmrg deplibs="$lib $deplibs" # used for prog,scan pass 8326fc27e79cSmrg fi 8327fc27e79cSmrg continue 8328fc27e79cSmrg fi 8329fc27e79cSmrg 8330fc27e79cSmrg 8331e4da38afSmrg if test prog = "$linkmode" && test link != "$pass"; then 8332bd3a1963Smrg func_append newlib_search_path " $ladir" 8333fc27e79cSmrg deplibs="$lib $deplibs" 8334fc27e79cSmrg 8335e4da38afSmrg linkalldeplibs=false 8336e4da38afSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 8337e4da38afSmrg test no = "$build_libtool_libs"; then 8338e4da38afSmrg linkalldeplibs=: 8339fc27e79cSmrg fi 8340fc27e79cSmrg 8341fc27e79cSmrg tmp_libs= 8342fc27e79cSmrg for deplib in $dependency_libs; do 8343fc27e79cSmrg case $deplib in 8344fc27e79cSmrg -L*) func_stripname '-L' '' "$deplib" 8345bd3a1963Smrg func_resolve_sysroot "$func_stripname_result" 8346bd3a1963Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8347fc27e79cSmrg ;; 8348fc27e79cSmrg esac 8349fc27e79cSmrg # Need to link against all dependency_libs? 8350e4da38afSmrg if $linkalldeplibs; then 8351fc27e79cSmrg deplibs="$deplib $deplibs" 8352fc27e79cSmrg else 8353fc27e79cSmrg # Need to hardcode shared library paths 8354fc27e79cSmrg # or/and link against static libraries 8355fc27e79cSmrg newdependency_libs="$deplib $newdependency_libs" 8356fc27e79cSmrg fi 8357e4da38afSmrg if $opt_preserve_dup_deps; then 8358fc27e79cSmrg case "$tmp_libs " in 8359bd3a1963Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8360fc27e79cSmrg esac 8361fc27e79cSmrg fi 8362bd3a1963Smrg func_append tmp_libs " $deplib" 8363fc27e79cSmrg done # for deplib 8364fc27e79cSmrg continue 8365fc27e79cSmrg fi # $linkmode = prog... 8366fc27e79cSmrg 8367e4da38afSmrg if test prog,link = "$linkmode,$pass"; then 8368fc27e79cSmrg if test -n "$library_names" && 8369e4da38afSmrg { { test no = "$prefer_static_libs" || 8370e4da38afSmrg test built,yes = "$prefer_static_libs,$installed"; } || 8371fc27e79cSmrg test -z "$old_library"; }; then 8372fc27e79cSmrg # We need to hardcode the library path 8373e4da38afSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8374fc27e79cSmrg # Make sure the rpath contains only unique directories. 8375e4da38afSmrg case $temp_rpath: in 8376fc27e79cSmrg *"$absdir:"*) ;; 8377bd3a1963Smrg *) func_append temp_rpath "$absdir:" ;; 8378fc27e79cSmrg esac 8379fc27e79cSmrg fi 8380fc27e79cSmrg 8381fc27e79cSmrg # Hardcode the library path. 8382fc27e79cSmrg # Skip directories that are in the system default run-time 8383fc27e79cSmrg # search path. 8384fc27e79cSmrg case " $sys_lib_dlsearch_path " in 8385fc27e79cSmrg *" $absdir "*) ;; 8386fc27e79cSmrg *) 8387fc27e79cSmrg case "$compile_rpath " in 8388fc27e79cSmrg *" $absdir "*) ;; 8389bd3a1963Smrg *) func_append compile_rpath " $absdir" ;; 8390fc27e79cSmrg esac 8391fc27e79cSmrg ;; 8392fc27e79cSmrg esac 8393fc27e79cSmrg case " $sys_lib_dlsearch_path " in 8394fc27e79cSmrg *" $libdir "*) ;; 8395fc27e79cSmrg *) 8396fc27e79cSmrg case "$finalize_rpath " in 8397fc27e79cSmrg *" $libdir "*) ;; 8398bd3a1963Smrg *) func_append finalize_rpath " $libdir" ;; 8399fc27e79cSmrg esac 8400fc27e79cSmrg ;; 8401fc27e79cSmrg esac 8402fc27e79cSmrg fi # $linkmode,$pass = prog,link... 8403fc27e79cSmrg 8404e4da38afSmrg if $alldeplibs && 8405e4da38afSmrg { test pass_all = "$deplibs_check_method" || 8406e4da38afSmrg { test yes = "$build_libtool_libs" && 8407fc27e79cSmrg test -n "$library_names"; }; }; then 8408fc27e79cSmrg # We only need to search for static libraries 8409fc27e79cSmrg continue 8410fc27e79cSmrg fi 8411fc27e79cSmrg fi 8412fc27e79cSmrg 8413fc27e79cSmrg link_static=no # Whether the deplib will be linked statically 8414fc27e79cSmrg use_static_libs=$prefer_static_libs 8415e4da38afSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 8416fc27e79cSmrg use_static_libs=no 8417fc27e79cSmrg fi 8418fc27e79cSmrg if test -n "$library_names" && 8419e4da38afSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8420fc27e79cSmrg case $host in 8421e4da38afSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 8422fc27e79cSmrg # No point in relinking DLLs because paths are not encoded 8423bd3a1963Smrg func_append notinst_deplibs " $lib" 8424fc27e79cSmrg need_relink=no 8425fc27e79cSmrg ;; 8426fc27e79cSmrg *) 8427e4da38afSmrg if test no = "$installed"; then 8428bd3a1963Smrg func_append notinst_deplibs " $lib" 8429fc27e79cSmrg need_relink=yes 8430fc27e79cSmrg fi 8431fc27e79cSmrg ;; 8432fc27e79cSmrg esac 8433fc27e79cSmrg # This is a shared library 8434fc27e79cSmrg 8435fc27e79cSmrg # Warn about portability, can't link against -module's on some 8436fc27e79cSmrg # systems (darwin). Don't bleat about dlopened modules though! 8437e4da38afSmrg dlopenmodule= 8438fc27e79cSmrg for dlpremoduletest in $dlprefiles; do 8439fc27e79cSmrg if test "X$dlpremoduletest" = "X$lib"; then 8440e4da38afSmrg dlopenmodule=$dlpremoduletest 8441fc27e79cSmrg break 8442fc27e79cSmrg fi 8443fc27e79cSmrg done 8444e4da38afSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8445bd3a1963Smrg echo 8446e4da38afSmrg if test prog = "$linkmode"; then 8447fc27e79cSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8448fc27e79cSmrg else 8449fc27e79cSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8450fc27e79cSmrg fi 8451fc27e79cSmrg $ECHO "*** $linklib is not portable!" 8452fc27e79cSmrg fi 8453e4da38afSmrg if test lib = "$linkmode" && 8454e4da38afSmrg test yes = "$hardcode_into_libs"; then 8455fc27e79cSmrg # Hardcode the library path. 8456fc27e79cSmrg # Skip directories that are in the system default run-time 8457fc27e79cSmrg # search path. 8458fc27e79cSmrg case " $sys_lib_dlsearch_path " in 8459fc27e79cSmrg *" $absdir "*) ;; 8460fc27e79cSmrg *) 8461fc27e79cSmrg case "$compile_rpath " in 8462fc27e79cSmrg *" $absdir "*) ;; 8463bd3a1963Smrg *) func_append compile_rpath " $absdir" ;; 8464fc27e79cSmrg esac 8465fc27e79cSmrg ;; 8466fc27e79cSmrg esac 8467fc27e79cSmrg case " $sys_lib_dlsearch_path " in 8468fc27e79cSmrg *" $libdir "*) ;; 8469fc27e79cSmrg *) 8470fc27e79cSmrg case "$finalize_rpath " in 8471fc27e79cSmrg *" $libdir "*) ;; 8472bd3a1963Smrg *) func_append finalize_rpath " $libdir" ;; 8473fc27e79cSmrg esac 8474fc27e79cSmrg ;; 8475fc27e79cSmrg esac 8476fc27e79cSmrg fi 8477fc27e79cSmrg 8478fc27e79cSmrg if test -n "$old_archive_from_expsyms_cmds"; then 8479fc27e79cSmrg # figure out the soname 8480fc27e79cSmrg set dummy $library_names 8481fc27e79cSmrg shift 8482e4da38afSmrg realname=$1 8483fc27e79cSmrg shift 8484fc27e79cSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 8485fc27e79cSmrg # use dlname if we got it. it's perfectly good, no? 8486fc27e79cSmrg if test -n "$dlname"; then 8487e4da38afSmrg soname=$dlname 8488fc27e79cSmrg elif test -n "$soname_spec"; then 8489fc27e79cSmrg # bleh windows 8490fc27e79cSmrg case $host in 8491e4da38afSmrg *cygwin* | mingw* | *cegcc* | *os2*) 8492fc27e79cSmrg func_arith $current - $age 8493fc27e79cSmrg major=$func_arith_result 8494e4da38afSmrg versuffix=-$major 8495fc27e79cSmrg ;; 8496fc27e79cSmrg esac 8497fc27e79cSmrg eval soname=\"$soname_spec\" 8498fc27e79cSmrg else 8499e4da38afSmrg soname=$realname 8500fc27e79cSmrg fi 8501fc27e79cSmrg 8502fc27e79cSmrg # Make a new name for the extract_expsyms_cmds to use 8503e4da38afSmrg soroot=$soname 8504fc27e79cSmrg func_basename "$soroot" 8505e4da38afSmrg soname=$func_basename_result 8506fc27e79cSmrg func_stripname 'lib' '.dll' "$soname" 8507fc27e79cSmrg newlib=libimp-$func_stripname_result.a 8508fc27e79cSmrg 8509fc27e79cSmrg # If the library has no export list, then create one now 8510fc27e79cSmrg if test -f "$output_objdir/$soname-def"; then : 8511fc27e79cSmrg else 8512e4da38afSmrg func_verbose "extracting exported symbol list from '$soname'" 8513fc27e79cSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8514fc27e79cSmrg fi 8515fc27e79cSmrg 8516fc27e79cSmrg # Create $newlib 8517fc27e79cSmrg if test -f "$output_objdir/$newlib"; then :; else 8518e4da38afSmrg func_verbose "generating import library for '$soname'" 8519fc27e79cSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8520fc27e79cSmrg fi 8521fc27e79cSmrg # make sure the library variables are pointing to the new library 8522fc27e79cSmrg dir=$output_objdir 8523fc27e79cSmrg linklib=$newlib 8524fc27e79cSmrg fi # test -n "$old_archive_from_expsyms_cmds" 8525fc27e79cSmrg 8526e4da38afSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8527fc27e79cSmrg add_shlibpath= 8528fc27e79cSmrg add_dir= 8529fc27e79cSmrg add= 8530fc27e79cSmrg lib_linked=yes 8531fc27e79cSmrg case $hardcode_action in 8532fc27e79cSmrg immediate | unsupported) 8533e4da38afSmrg if test no = "$hardcode_direct"; then 8534e4da38afSmrg add=$dir/$linklib 8535fc27e79cSmrg case $host in 8536e4da38afSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8537e4da38afSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8538fc27e79cSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8539e4da38afSmrg *-*-unixware7*) add_dir=-L$dir ;; 8540fc27e79cSmrg *-*-darwin* ) 8541e4da38afSmrg # if the lib is a (non-dlopened) module then we cannot 8542fc27e79cSmrg # link against it, someone is ignoring the earlier warnings 8543fc27e79cSmrg if /usr/bin/file -L $add 2> /dev/null | 8544e4da38afSmrg $GREP ": [^:]* bundle" >/dev/null; then 8545fc27e79cSmrg if test "X$dlopenmodule" != "X$lib"; then 8546fc27e79cSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8547e4da38afSmrg if test -z "$old_library"; then 8548bd3a1963Smrg echo 8549bd3a1963Smrg echo "*** And there doesn't seem to be a static archive available" 8550bd3a1963Smrg echo "*** The link will probably fail, sorry" 8551fc27e79cSmrg else 8552e4da38afSmrg add=$dir/$old_library 8553fc27e79cSmrg fi 8554fc27e79cSmrg elif test -n "$old_library"; then 8555e4da38afSmrg add=$dir/$old_library 8556fc27e79cSmrg fi 8557fc27e79cSmrg fi 8558fc27e79cSmrg esac 8559e4da38afSmrg elif test no = "$hardcode_minus_L"; then 8560fc27e79cSmrg case $host in 8561e4da38afSmrg *-*-sunos*) add_shlibpath=$dir ;; 8562fc27e79cSmrg esac 8563e4da38afSmrg add_dir=-L$dir 8564e4da38afSmrg add=-l$name 8565e4da38afSmrg elif test no = "$hardcode_shlibpath_var"; then 8566e4da38afSmrg add_shlibpath=$dir 8567e4da38afSmrg add=-l$name 8568fc27e79cSmrg else 8569fc27e79cSmrg lib_linked=no 8570fc27e79cSmrg fi 8571fc27e79cSmrg ;; 8572fc27e79cSmrg relink) 8573e4da38afSmrg if test yes = "$hardcode_direct" && 8574e4da38afSmrg test no = "$hardcode_direct_absolute"; then 8575e4da38afSmrg add=$dir/$linklib 8576e4da38afSmrg elif test yes = "$hardcode_minus_L"; then 8577e4da38afSmrg add_dir=-L$absdir 8578fc27e79cSmrg # Try looking first in the location we're being installed to. 8579fc27e79cSmrg if test -n "$inst_prefix_dir"; then 8580fc27e79cSmrg case $libdir in 8581fc27e79cSmrg [\\/]*) 8582bd3a1963Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8583fc27e79cSmrg ;; 8584fc27e79cSmrg esac 8585fc27e79cSmrg fi 8586e4da38afSmrg add=-l$name 8587e4da38afSmrg elif test yes = "$hardcode_shlibpath_var"; then 8588e4da38afSmrg add_shlibpath=$dir 8589e4da38afSmrg add=-l$name 8590fc27e79cSmrg else 8591fc27e79cSmrg lib_linked=no 8592fc27e79cSmrg fi 8593fc27e79cSmrg ;; 8594fc27e79cSmrg *) lib_linked=no ;; 8595fc27e79cSmrg esac 8596fc27e79cSmrg 8597e4da38afSmrg if test yes != "$lib_linked"; then 8598fc27e79cSmrg func_fatal_configuration "unsupported hardcode properties" 8599fc27e79cSmrg fi 8600fc27e79cSmrg 8601fc27e79cSmrg if test -n "$add_shlibpath"; then 8602fc27e79cSmrg case :$compile_shlibpath: in 8603fc27e79cSmrg *":$add_shlibpath:"*) ;; 8604bd3a1963Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8605fc27e79cSmrg esac 8606fc27e79cSmrg fi 8607e4da38afSmrg if test prog = "$linkmode"; then 8608fc27e79cSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8609fc27e79cSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8610fc27e79cSmrg else 8611fc27e79cSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8612fc27e79cSmrg test -n "$add" && deplibs="$add $deplibs" 8613e4da38afSmrg if test yes != "$hardcode_direct" && 8614e4da38afSmrg test yes != "$hardcode_minus_L" && 8615e4da38afSmrg test yes = "$hardcode_shlibpath_var"; then 8616fc27e79cSmrg case :$finalize_shlibpath: in 8617fc27e79cSmrg *":$libdir:"*) ;; 8618bd3a1963Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8619fc27e79cSmrg esac 8620fc27e79cSmrg fi 8621fc27e79cSmrg fi 8622fc27e79cSmrg fi 8623fc27e79cSmrg 8624e4da38afSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8625fc27e79cSmrg add_shlibpath= 8626fc27e79cSmrg add_dir= 8627fc27e79cSmrg add= 8628fc27e79cSmrg # Finalize command for both is simple: just hardcode it. 8629e4da38afSmrg if test yes = "$hardcode_direct" && 8630e4da38afSmrg test no = "$hardcode_direct_absolute"; then 8631e4da38afSmrg add=$libdir/$linklib 8632e4da38afSmrg elif test yes = "$hardcode_minus_L"; then 8633e4da38afSmrg add_dir=-L$libdir 8634e4da38afSmrg add=-l$name 8635e4da38afSmrg elif test yes = "$hardcode_shlibpath_var"; then 8636fc27e79cSmrg case :$finalize_shlibpath: in 8637fc27e79cSmrg *":$libdir:"*) ;; 8638bd3a1963Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8639fc27e79cSmrg esac 8640e4da38afSmrg add=-l$name 8641e4da38afSmrg elif test yes = "$hardcode_automatic"; then 8642fc27e79cSmrg if test -n "$inst_prefix_dir" && 8643e4da38afSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 8644e4da38afSmrg add=$inst_prefix_dir$libdir/$linklib 8645fc27e79cSmrg else 8646e4da38afSmrg add=$libdir/$linklib 8647fc27e79cSmrg fi 8648fc27e79cSmrg else 8649fc27e79cSmrg # We cannot seem to hardcode it, guess we'll fake it. 8650e4da38afSmrg add_dir=-L$libdir 8651fc27e79cSmrg # Try looking first in the location we're being installed to. 8652fc27e79cSmrg if test -n "$inst_prefix_dir"; then 8653fc27e79cSmrg case $libdir in 8654fc27e79cSmrg [\\/]*) 8655bd3a1963Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8656fc27e79cSmrg ;; 8657fc27e79cSmrg esac 8658fc27e79cSmrg fi 8659e4da38afSmrg add=-l$name 8660fc27e79cSmrg fi 8661fc27e79cSmrg 8662e4da38afSmrg if test prog = "$linkmode"; then 8663fc27e79cSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8664fc27e79cSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8665fc27e79cSmrg else 8666fc27e79cSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8667fc27e79cSmrg test -n "$add" && deplibs="$add $deplibs" 8668fc27e79cSmrg fi 8669fc27e79cSmrg fi 8670e4da38afSmrg elif test prog = "$linkmode"; then 8671fc27e79cSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8672fc27e79cSmrg # is not unsupported. This is valid on all known static and 8673fc27e79cSmrg # shared platforms. 8674e4da38afSmrg if test unsupported != "$hardcode_direct"; then 8675e4da38afSmrg test -n "$old_library" && linklib=$old_library 8676fc27e79cSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 8677fc27e79cSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8678fc27e79cSmrg else 8679fc27e79cSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8680fc27e79cSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8681fc27e79cSmrg fi 8682e4da38afSmrg elif test yes = "$build_libtool_libs"; then 8683fc27e79cSmrg # Not a shared library 8684e4da38afSmrg if test pass_all != "$deplibs_check_method"; then 8685fc27e79cSmrg # We're trying link a shared library against a static one 8686fc27e79cSmrg # but the system doesn't support it. 8687fc27e79cSmrg 8688fc27e79cSmrg # Just print a warning and add the library to dependency_libs so 8689fc27e79cSmrg # that the program can be linked against the static library. 8690bd3a1963Smrg echo 8691e4da38afSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8692bd3a1963Smrg echo "*** I have the capability to make that library automatically link in when" 8693bd3a1963Smrg echo "*** you link to this library. But I can only do this if you have a" 8694bd3a1963Smrg echo "*** shared version of the library, which you do not appear to have." 8695e4da38afSmrg if test yes = "$module"; then 8696bd3a1963Smrg echo "*** But as you try to build a module library, libtool will still create " 8697bd3a1963Smrg echo "*** a static module, that should work as long as the dlopening application" 8698bd3a1963Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8699fc27e79cSmrg if test -z "$global_symbol_pipe"; then 8700bd3a1963Smrg echo 8701bd3a1963Smrg echo "*** However, this would only work if libtool was able to extract symbol" 8702e4da38afSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8703bd3a1963Smrg echo "*** not find such a program. So, this module is probably useless." 8704e4da38afSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8705fc27e79cSmrg fi 8706e4da38afSmrg if test no = "$build_old_libs"; then 8707fc27e79cSmrg build_libtool_libs=module 8708fc27e79cSmrg build_old_libs=yes 8709fc27e79cSmrg else 8710fc27e79cSmrg build_libtool_libs=no 8711fc27e79cSmrg fi 8712fc27e79cSmrg fi 8713fc27e79cSmrg else 8714fc27e79cSmrg deplibs="$dir/$old_library $deplibs" 8715fc27e79cSmrg link_static=yes 8716fc27e79cSmrg fi 8717fc27e79cSmrg fi # link shared/static library? 8718fc27e79cSmrg 8719e4da38afSmrg if test lib = "$linkmode"; then 8720fc27e79cSmrg if test -n "$dependency_libs" && 8721e4da38afSmrg { test yes != "$hardcode_into_libs" || 8722e4da38afSmrg test yes = "$build_old_libs" || 8723e4da38afSmrg test yes = "$link_static"; }; then 8724fc27e79cSmrg # Extract -R from dependency_libs 8725fc27e79cSmrg temp_deplibs= 8726fc27e79cSmrg for libdir in $dependency_libs; do 8727fc27e79cSmrg case $libdir in 8728fc27e79cSmrg -R*) func_stripname '-R' '' "$libdir" 8729fc27e79cSmrg temp_xrpath=$func_stripname_result 8730fc27e79cSmrg case " $xrpath " in 8731fc27e79cSmrg *" $temp_xrpath "*) ;; 8732bd3a1963Smrg *) func_append xrpath " $temp_xrpath";; 8733fc27e79cSmrg esac;; 8734bd3a1963Smrg *) func_append temp_deplibs " $libdir";; 8735fc27e79cSmrg esac 8736fc27e79cSmrg done 8737e4da38afSmrg dependency_libs=$temp_deplibs 8738fc27e79cSmrg fi 8739fc27e79cSmrg 8740bd3a1963Smrg func_append newlib_search_path " $absdir" 8741fc27e79cSmrg # Link against this library 8742e4da38afSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8743fc27e79cSmrg # ... and its dependency_libs 8744fc27e79cSmrg tmp_libs= 8745fc27e79cSmrg for deplib in $dependency_libs; do 8746fc27e79cSmrg newdependency_libs="$deplib $newdependency_libs" 8747bd3a1963Smrg case $deplib in 8748bd3a1963Smrg -L*) func_stripname '-L' '' "$deplib" 8749bd3a1963Smrg func_resolve_sysroot "$func_stripname_result";; 8750bd3a1963Smrg *) func_resolve_sysroot "$deplib" ;; 8751bd3a1963Smrg esac 8752e4da38afSmrg if $opt_preserve_dup_deps; then 8753fc27e79cSmrg case "$tmp_libs " in 8754bd3a1963Smrg *" $func_resolve_sysroot_result "*) 8755bd3a1963Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8756fc27e79cSmrg esac 8757fc27e79cSmrg fi 8758bd3a1963Smrg func_append tmp_libs " $func_resolve_sysroot_result" 8759fc27e79cSmrg done 8760fc27e79cSmrg 8761e4da38afSmrg if test no != "$link_all_deplibs"; then 8762fc27e79cSmrg # Add the search paths of all dependency libraries 8763fc27e79cSmrg for deplib in $dependency_libs; do 8764bd3a1963Smrg path= 8765fc27e79cSmrg case $deplib in 8766e4da38afSmrg -L*) path=$deplib ;; 8767fc27e79cSmrg *.la) 8768bd3a1963Smrg func_resolve_sysroot "$deplib" 8769bd3a1963Smrg deplib=$func_resolve_sysroot_result 8770fc27e79cSmrg func_dirname "$deplib" "" "." 8771bd3a1963Smrg dir=$func_dirname_result 8772fc27e79cSmrg # We need an absolute path. 8773fc27e79cSmrg case $dir in 8774e4da38afSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8775fc27e79cSmrg *) 8776fc27e79cSmrg absdir=`cd "$dir" && pwd` 8777fc27e79cSmrg if test -z "$absdir"; then 8778e4da38afSmrg func_warning "cannot determine absolute directory name of '$dir'" 8779e4da38afSmrg absdir=$dir 8780fc27e79cSmrg fi 8781fc27e79cSmrg ;; 8782fc27e79cSmrg esac 8783fc27e79cSmrg if $GREP "^installed=no" $deplib > /dev/null; then 8784fc27e79cSmrg case $host in 8785fc27e79cSmrg *-*-darwin*) 8786fc27e79cSmrg depdepl= 8787e4da38afSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8788e4da38afSmrg if test -n "$deplibrary_names"; then 8789e4da38afSmrg for tmp in $deplibrary_names; do 8790fc27e79cSmrg depdepl=$tmp 8791fc27e79cSmrg done 8792e4da38afSmrg if test -f "$absdir/$objdir/$depdepl"; then 8793e4da38afSmrg depdepl=$absdir/$objdir/$depdepl 8794e4da38afSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8795fc27e79cSmrg if test -z "$darwin_install_name"; then 8796e4da38afSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8797fc27e79cSmrg fi 8798e4da38afSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8799e4da38afSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8800fc27e79cSmrg path= 8801fc27e79cSmrg fi 8802fc27e79cSmrg fi 8803fc27e79cSmrg ;; 8804fc27e79cSmrg *) 8805e4da38afSmrg path=-L$absdir/$objdir 8806fc27e79cSmrg ;; 8807fc27e79cSmrg esac 8808fc27e79cSmrg else 8809e4da38afSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8810fc27e79cSmrg test -z "$libdir" && \ 8811e4da38afSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 8812fc27e79cSmrg test "$absdir" != "$libdir" && \ 8813e4da38afSmrg func_warning "'$deplib' seems to be moved" 8814fc27e79cSmrg 8815e4da38afSmrg path=-L$absdir 8816fc27e79cSmrg fi 8817fc27e79cSmrg ;; 8818fc27e79cSmrg esac 8819fc27e79cSmrg case " $deplibs " in 8820fc27e79cSmrg *" $path "*) ;; 8821fc27e79cSmrg *) deplibs="$path $deplibs" ;; 8822fc27e79cSmrg esac 8823fc27e79cSmrg done 8824fc27e79cSmrg fi # link_all_deplibs != no 8825fc27e79cSmrg fi # linkmode = lib 8826fc27e79cSmrg done # for deplib in $libs 8827e4da38afSmrg if test link = "$pass"; then 8828e4da38afSmrg if test prog = "$linkmode"; then 8829fc27e79cSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8830fc27e79cSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8831fc27e79cSmrg else 8832bd3a1963Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8833fc27e79cSmrg fi 8834fc27e79cSmrg fi 8835e4da38afSmrg dependency_libs=$newdependency_libs 8836e4da38afSmrg if test dlpreopen = "$pass"; then 8837fc27e79cSmrg # Link the dlpreopened libraries before other libraries 8838fc27e79cSmrg for deplib in $save_deplibs; do 8839fc27e79cSmrg deplibs="$deplib $deplibs" 8840fc27e79cSmrg done 8841fc27e79cSmrg fi 8842e4da38afSmrg if test dlopen != "$pass"; then 8843e4da38afSmrg test conv = "$pass" || { 8844fc27e79cSmrg # Make sure lib_search_path contains only unique directories. 8845fc27e79cSmrg lib_search_path= 8846fc27e79cSmrg for dir in $newlib_search_path; do 8847fc27e79cSmrg case "$lib_search_path " in 8848fc27e79cSmrg *" $dir "*) ;; 8849bd3a1963Smrg *) func_append lib_search_path " $dir" ;; 8850fc27e79cSmrg esac 8851fc27e79cSmrg done 8852fc27e79cSmrg newlib_search_path= 8853e4da38afSmrg } 8854fc27e79cSmrg 8855e4da38afSmrg if test prog,link = "$linkmode,$pass"; then 8856fc27e79cSmrg vars="compile_deplibs finalize_deplibs" 8857e4da38afSmrg else 8858e4da38afSmrg vars=deplibs 8859fc27e79cSmrg fi 8860fc27e79cSmrg for var in $vars dependency_libs; do 8861fc27e79cSmrg # Add libraries to $var in reverse order 8862fc27e79cSmrg eval tmp_libs=\"\$$var\" 8863fc27e79cSmrg new_libs= 8864fc27e79cSmrg for deplib in $tmp_libs; do 8865fc27e79cSmrg # FIXME: Pedantically, this is the right thing to do, so 8866fc27e79cSmrg # that some nasty dependency loop isn't accidentally 8867fc27e79cSmrg # broken: 8868fc27e79cSmrg #new_libs="$deplib $new_libs" 8869fc27e79cSmrg # Pragmatically, this seems to cause very few problems in 8870fc27e79cSmrg # practice: 8871fc27e79cSmrg case $deplib in 8872fc27e79cSmrg -L*) new_libs="$deplib $new_libs" ;; 8873fc27e79cSmrg -R*) ;; 8874fc27e79cSmrg *) 8875fc27e79cSmrg # And here is the reason: when a library appears more 8876fc27e79cSmrg # than once as an explicit dependence of a library, or 8877fc27e79cSmrg # is implicitly linked in more than once by the 8878fc27e79cSmrg # compiler, it is considered special, and multiple 8879fc27e79cSmrg # occurrences thereof are not removed. Compare this 8880fc27e79cSmrg # with having the same library being listed as a 8881fc27e79cSmrg # dependency of multiple other libraries: in this case, 8882fc27e79cSmrg # we know (pedantically, we assume) the library does not 8883fc27e79cSmrg # need to be listed more than once, so we keep only the 8884fc27e79cSmrg # last copy. This is not always right, but it is rare 8885fc27e79cSmrg # enough that we require users that really mean to play 8886fc27e79cSmrg # such unportable linking tricks to link the library 8887fc27e79cSmrg # using -Wl,-lname, so that libtool does not consider it 8888fc27e79cSmrg # for duplicate removal. 8889fc27e79cSmrg case " $specialdeplibs " in 8890fc27e79cSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8891fc27e79cSmrg *) 8892fc27e79cSmrg case " $new_libs " in 8893fc27e79cSmrg *" $deplib "*) ;; 8894fc27e79cSmrg *) new_libs="$deplib $new_libs" ;; 8895fc27e79cSmrg esac 8896fc27e79cSmrg ;; 8897fc27e79cSmrg esac 8898fc27e79cSmrg ;; 8899fc27e79cSmrg esac 8900fc27e79cSmrg done 8901fc27e79cSmrg tmp_libs= 8902fc27e79cSmrg for deplib in $new_libs; do 8903fc27e79cSmrg case $deplib in 8904fc27e79cSmrg -L*) 8905fc27e79cSmrg case " $tmp_libs " in 8906fc27e79cSmrg *" $deplib "*) ;; 8907bd3a1963Smrg *) func_append tmp_libs " $deplib" ;; 8908fc27e79cSmrg esac 8909fc27e79cSmrg ;; 8910bd3a1963Smrg *) func_append tmp_libs " $deplib" ;; 8911fc27e79cSmrg esac 8912fc27e79cSmrg done 8913fc27e79cSmrg eval $var=\"$tmp_libs\" 8914fc27e79cSmrg done # for var 8915fc27e79cSmrg fi 8916e4da38afSmrg 8917e4da38afSmrg # Add Sun CC postdeps if required: 8918e4da38afSmrg test CXX = "$tagname" && { 8919e4da38afSmrg case $host_os in 8920e4da38afSmrg linux*) 8921370b807fSmrg case `$CC -V 2>&1 | $SED 5q` in 8922e4da38afSmrg *Sun\ C*) # Sun C++ 5.9 8923e4da38afSmrg func_suncc_cstd_abi 8924e4da38afSmrg 8925e4da38afSmrg if test no != "$suncc_use_cstd_abi"; then 8926e4da38afSmrg func_append postdeps ' -library=Cstd -library=Crun' 8927e4da38afSmrg fi 8928e4da38afSmrg ;; 8929e4da38afSmrg esac 8930e4da38afSmrg ;; 8931e4da38afSmrg 8932e4da38afSmrg solaris*) 8933e4da38afSmrg func_cc_basename "$CC" 8934e4da38afSmrg case $func_cc_basename_result in 8935e4da38afSmrg CC* | sunCC*) 8936e4da38afSmrg func_suncc_cstd_abi 8937e4da38afSmrg 8938e4da38afSmrg if test no != "$suncc_use_cstd_abi"; then 8939e4da38afSmrg func_append postdeps ' -library=Cstd -library=Crun' 8940e4da38afSmrg fi 8941e4da38afSmrg ;; 8942e4da38afSmrg esac 8943e4da38afSmrg ;; 8944e4da38afSmrg esac 8945e4da38afSmrg } 8946e4da38afSmrg 8947fc27e79cSmrg # Last step: remove runtime libs from dependency_libs 8948fc27e79cSmrg # (they stay in deplibs) 8949fc27e79cSmrg tmp_libs= 8950e4da38afSmrg for i in $dependency_libs; do 8951fc27e79cSmrg case " $predeps $postdeps $compiler_lib_search_path " in 8952fc27e79cSmrg *" $i "*) 8953e4da38afSmrg i= 8954fc27e79cSmrg ;; 8955fc27e79cSmrg esac 8956e4da38afSmrg if test -n "$i"; then 8957bd3a1963Smrg func_append tmp_libs " $i" 8958fc27e79cSmrg fi 8959fc27e79cSmrg done 8960fc27e79cSmrg dependency_libs=$tmp_libs 8961fc27e79cSmrg done # for pass 8962e4da38afSmrg if test prog = "$linkmode"; then 8963e4da38afSmrg dlfiles=$newdlfiles 8964fc27e79cSmrg fi 8965e4da38afSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 8966e4da38afSmrg dlprefiles=$newdlprefiles 8967fc27e79cSmrg fi 8968fc27e79cSmrg 8969fc27e79cSmrg case $linkmode in 8970fc27e79cSmrg oldlib) 8971e4da38afSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8972e4da38afSmrg func_warning "'-dlopen' is ignored for archives" 8973fc27e79cSmrg fi 8974fc27e79cSmrg 8975fc27e79cSmrg case " $deplibs" in 8976fc27e79cSmrg *\ -l* | *\ -L*) 8977e4da38afSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 8978fc27e79cSmrg esac 8979fc27e79cSmrg 8980fc27e79cSmrg test -n "$rpath" && \ 8981e4da38afSmrg func_warning "'-rpath' is ignored for archives" 8982fc27e79cSmrg 8983fc27e79cSmrg test -n "$xrpath" && \ 8984e4da38afSmrg func_warning "'-R' is ignored for archives" 8985fc27e79cSmrg 8986fc27e79cSmrg test -n "$vinfo" && \ 8987e4da38afSmrg func_warning "'-version-info/-version-number' is ignored for archives" 8988fc27e79cSmrg 8989fc27e79cSmrg test -n "$release" && \ 8990e4da38afSmrg func_warning "'-release' is ignored for archives" 8991fc27e79cSmrg 8992fc27e79cSmrg test -n "$export_symbols$export_symbols_regex" && \ 8993e4da38afSmrg func_warning "'-export-symbols' is ignored for archives" 8994fc27e79cSmrg 8995fc27e79cSmrg # Now set the variables for building old libraries. 8996fc27e79cSmrg build_libtool_libs=no 8997e4da38afSmrg oldlibs=$output 8998bd3a1963Smrg func_append objs "$old_deplibs" 8999fc27e79cSmrg ;; 9000fc27e79cSmrg 9001fc27e79cSmrg lib) 9002e4da38afSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 9003fc27e79cSmrg case $outputname in 9004fc27e79cSmrg lib*) 9005fc27e79cSmrg func_stripname 'lib' '.la' "$outputname" 9006fc27e79cSmrg name=$func_stripname_result 9007fc27e79cSmrg eval shared_ext=\"$shrext_cmds\" 9008fc27e79cSmrg eval libname=\"$libname_spec\" 9009fc27e79cSmrg ;; 9010fc27e79cSmrg *) 9011e4da38afSmrg test no = "$module" \ 9012e4da38afSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 9013fc27e79cSmrg 9014e4da38afSmrg if test no != "$need_lib_prefix"; then 9015fc27e79cSmrg # Add the "lib" prefix for modules if required 9016fc27e79cSmrg func_stripname '' '.la' "$outputname" 9017fc27e79cSmrg name=$func_stripname_result 9018fc27e79cSmrg eval shared_ext=\"$shrext_cmds\" 9019fc27e79cSmrg eval libname=\"$libname_spec\" 9020fc27e79cSmrg else 9021fc27e79cSmrg func_stripname '' '.la' "$outputname" 9022fc27e79cSmrg libname=$func_stripname_result 9023fc27e79cSmrg fi 9024fc27e79cSmrg ;; 9025fc27e79cSmrg esac 9026fc27e79cSmrg 9027fc27e79cSmrg if test -n "$objs"; then 9028e4da38afSmrg if test pass_all != "$deplibs_check_method"; then 9029e4da38afSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 9030fc27e79cSmrg else 9031bd3a1963Smrg echo 9032fc27e79cSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 9033fc27e79cSmrg $ECHO "*** objects $objs is not portable!" 9034bd3a1963Smrg func_append libobjs " $objs" 9035fc27e79cSmrg fi 9036fc27e79cSmrg fi 9037fc27e79cSmrg 9038e4da38afSmrg test no = "$dlself" \ 9039e4da38afSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 9040fc27e79cSmrg 9041fc27e79cSmrg set dummy $rpath 9042fc27e79cSmrg shift 9043e4da38afSmrg test 1 -lt "$#" \ 9044e4da38afSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 9045fc27e79cSmrg 9046e4da38afSmrg install_libdir=$1 9047fc27e79cSmrg 9048fc27e79cSmrg oldlibs= 9049fc27e79cSmrg if test -z "$rpath"; then 9050e4da38afSmrg if test yes = "$build_libtool_libs"; then 9051fc27e79cSmrg # Building a libtool convenience library. 9052e4da38afSmrg # Some compilers have problems with a '.al' extension so 9053fc27e79cSmrg # convenience libraries should have the same extension an 9054fc27e79cSmrg # archive normally would. 9055fc27e79cSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 9056fc27e79cSmrg build_libtool_libs=convenience 9057fc27e79cSmrg build_old_libs=yes 9058fc27e79cSmrg fi 9059fc27e79cSmrg 9060fc27e79cSmrg test -n "$vinfo" && \ 9061e4da38afSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 9062fc27e79cSmrg 9063fc27e79cSmrg test -n "$release" && \ 9064e4da38afSmrg func_warning "'-release' is ignored for convenience libraries" 9065fc27e79cSmrg else 9066fc27e79cSmrg 9067fc27e79cSmrg # Parse the version information argument. 9068e4da38afSmrg save_ifs=$IFS; IFS=: 9069fc27e79cSmrg set dummy $vinfo 0 0 0 9070fc27e79cSmrg shift 9071e4da38afSmrg IFS=$save_ifs 9072fc27e79cSmrg 9073fc27e79cSmrg test -n "$7" && \ 9074e4da38afSmrg func_fatal_help "too many parameters to '-version-info'" 9075fc27e79cSmrg 9076fc27e79cSmrg # convert absolute version numbers to libtool ages 9077fc27e79cSmrg # this retains compatibility with .la files and attempts 9078fc27e79cSmrg # to make the code below a bit more comprehensible 9079fc27e79cSmrg 9080fc27e79cSmrg case $vinfo_number in 9081fc27e79cSmrg yes) 9082e4da38afSmrg number_major=$1 9083e4da38afSmrg number_minor=$2 9084e4da38afSmrg number_revision=$3 9085fc27e79cSmrg # 9086fc27e79cSmrg # There are really only two kinds -- those that 9087fc27e79cSmrg # use the current revision as the major version 9088fc27e79cSmrg # and those that subtract age and use age as 9089fc27e79cSmrg # a minor version. But, then there is irix 9090e4da38afSmrg # that has an extra 1 added just for fun 9091fc27e79cSmrg # 9092fc27e79cSmrg case $version_type in 9093a73597f9Smrg # correct linux to gnu/linux during the next big refactor 9094370b807fSmrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 9095fc27e79cSmrg func_arith $number_major + $number_minor 9096fc27e79cSmrg current=$func_arith_result 9097e4da38afSmrg age=$number_minor 9098e4da38afSmrg revision=$number_revision 9099fc27e79cSmrg ;; 9100e4da38afSmrg freebsd-aout|qnx|sunos) 9101e4da38afSmrg current=$number_major 9102e4da38afSmrg revision=$number_minor 9103e4da38afSmrg age=0 9104fc27e79cSmrg ;; 9105fc27e79cSmrg irix|nonstopux) 9106fc27e79cSmrg func_arith $number_major + $number_minor 9107fc27e79cSmrg current=$func_arith_result 9108e4da38afSmrg age=$number_minor 9109e4da38afSmrg revision=$number_minor 9110fc27e79cSmrg lt_irix_increment=no 9111fc27e79cSmrg ;; 9112fc27e79cSmrg esac 9113fc27e79cSmrg ;; 9114fc27e79cSmrg no) 9115e4da38afSmrg current=$1 9116e4da38afSmrg revision=$2 9117e4da38afSmrg age=$3 9118fc27e79cSmrg ;; 9119fc27e79cSmrg esac 9120fc27e79cSmrg 9121fc27e79cSmrg # Check that each of the things are valid numbers. 9122fc27e79cSmrg case $current in 9123fc27e79cSmrg 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]) ;; 9124fc27e79cSmrg *) 9125e4da38afSmrg func_error "CURRENT '$current' must be a nonnegative integer" 9126e4da38afSmrg func_fatal_error "'$vinfo' is not valid version information" 9127fc27e79cSmrg ;; 9128fc27e79cSmrg esac 9129fc27e79cSmrg 9130fc27e79cSmrg case $revision in 9131fc27e79cSmrg 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]) ;; 9132fc27e79cSmrg *) 9133e4da38afSmrg func_error "REVISION '$revision' must be a nonnegative integer" 9134e4da38afSmrg func_fatal_error "'$vinfo' is not valid version information" 9135fc27e79cSmrg ;; 9136fc27e79cSmrg esac 9137fc27e79cSmrg 9138fc27e79cSmrg case $age in 9139fc27e79cSmrg 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]) ;; 9140fc27e79cSmrg *) 9141e4da38afSmrg func_error "AGE '$age' must be a nonnegative integer" 9142e4da38afSmrg func_fatal_error "'$vinfo' is not valid version information" 9143fc27e79cSmrg ;; 9144fc27e79cSmrg esac 9145fc27e79cSmrg 9146fc27e79cSmrg if test "$age" -gt "$current"; then 9147e4da38afSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 9148e4da38afSmrg func_fatal_error "'$vinfo' is not valid version information" 9149fc27e79cSmrg fi 9150fc27e79cSmrg 9151fc27e79cSmrg # Calculate the version variables. 9152fc27e79cSmrg major= 9153fc27e79cSmrg versuffix= 9154fc27e79cSmrg verstring= 9155fc27e79cSmrg case $version_type in 9156fc27e79cSmrg none) ;; 9157fc27e79cSmrg 9158fc27e79cSmrg darwin) 9159fc27e79cSmrg # Like Linux, but with the current version available in 9160fc27e79cSmrg # verstring for coding it into the library header 9161fc27e79cSmrg func_arith $current - $age 9162fc27e79cSmrg major=.$func_arith_result 9163e4da38afSmrg versuffix=$major.$age.$revision 9164fc27e79cSmrg # Darwin ld doesn't like 0 for these options... 9165fc27e79cSmrg func_arith $current + 1 9166fc27e79cSmrg minor_current=$func_arith_result 9167e4da38afSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9168fc27e79cSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9169e4da38afSmrg # On Darwin other compilers 9170e4da38afSmrg case $CC in 9171e4da38afSmrg nagfor*) 9172e4da38afSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9173e4da38afSmrg ;; 9174e4da38afSmrg *) 9175e4da38afSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9176e4da38afSmrg ;; 9177e4da38afSmrg esac 9178fc27e79cSmrg ;; 9179fc27e79cSmrg 9180fc27e79cSmrg freebsd-aout) 9181e4da38afSmrg major=.$current 9182e4da38afSmrg versuffix=.$current.$revision 9183fc27e79cSmrg ;; 9184fc27e79cSmrg 9185370b807fSmrg freebsd-elf | midnightbsd-elf) 9186e4da38afSmrg func_arith $current - $age 9187e4da38afSmrg major=.$func_arith_result 9188e4da38afSmrg versuffix=$major.$age.$revision 9189fc27e79cSmrg ;; 9190fc27e79cSmrg 9191fc27e79cSmrg irix | nonstopux) 9192e4da38afSmrg if test no = "$lt_irix_increment"; then 9193fc27e79cSmrg func_arith $current - $age 9194fc27e79cSmrg else 9195fc27e79cSmrg func_arith $current - $age + 1 9196fc27e79cSmrg fi 9197fc27e79cSmrg major=$func_arith_result 9198fc27e79cSmrg 9199fc27e79cSmrg case $version_type in 9200fc27e79cSmrg nonstopux) verstring_prefix=nonstopux ;; 9201fc27e79cSmrg *) verstring_prefix=sgi ;; 9202fc27e79cSmrg esac 9203e4da38afSmrg verstring=$verstring_prefix$major.$revision 9204fc27e79cSmrg 9205fc27e79cSmrg # Add in all the interfaces that we are compatible with. 9206fc27e79cSmrg loop=$revision 9207e4da38afSmrg while test 0 -ne "$loop"; do 9208fc27e79cSmrg func_arith $revision - $loop 9209fc27e79cSmrg iface=$func_arith_result 9210fc27e79cSmrg func_arith $loop - 1 9211fc27e79cSmrg loop=$func_arith_result 9212e4da38afSmrg verstring=$verstring_prefix$major.$iface:$verstring 9213fc27e79cSmrg done 9214fc27e79cSmrg 9215e4da38afSmrg # Before this point, $major must not contain '.'. 9216fc27e79cSmrg major=.$major 9217e4da38afSmrg versuffix=$major.$revision 9218fc27e79cSmrg ;; 9219fc27e79cSmrg 9220a73597f9Smrg linux) # correct to gnu/linux during the next big refactor 9221fc27e79cSmrg func_arith $current - $age 9222fc27e79cSmrg major=.$func_arith_result 9223e4da38afSmrg versuffix=$major.$age.$revision 9224fc27e79cSmrg ;; 9225fc27e79cSmrg 9226fc27e79cSmrg osf) 9227fc27e79cSmrg func_arith $current - $age 9228fc27e79cSmrg major=.$func_arith_result 9229e4da38afSmrg versuffix=.$current.$age.$revision 9230e4da38afSmrg verstring=$current.$age.$revision 9231fc27e79cSmrg 9232fc27e79cSmrg # Add in all the interfaces that we are compatible with. 9233fc27e79cSmrg loop=$age 9234e4da38afSmrg while test 0 -ne "$loop"; do 9235fc27e79cSmrg func_arith $current - $loop 9236fc27e79cSmrg iface=$func_arith_result 9237fc27e79cSmrg func_arith $loop - 1 9238fc27e79cSmrg loop=$func_arith_result 9239e4da38afSmrg verstring=$verstring:$iface.0 9240fc27e79cSmrg done 9241fc27e79cSmrg 9242fc27e79cSmrg # Make executables depend on our current version. 9243e4da38afSmrg func_append verstring ":$current.0" 9244fc27e79cSmrg ;; 9245fc27e79cSmrg 9246fc27e79cSmrg qnx) 9247e4da38afSmrg major=.$current 9248e4da38afSmrg versuffix=.$current 9249e4da38afSmrg ;; 9250e4da38afSmrg 9251e4da38afSmrg sco) 9252e4da38afSmrg major=.$current 9253e4da38afSmrg versuffix=.$current 9254fc27e79cSmrg ;; 9255fc27e79cSmrg 9256fc27e79cSmrg sunos) 9257e4da38afSmrg major=.$current 9258e4da38afSmrg versuffix=.$current.$revision 9259fc27e79cSmrg ;; 9260fc27e79cSmrg 9261fc27e79cSmrg windows) 9262fc27e79cSmrg # Use '-' rather than '.', since we only want one 9263e4da38afSmrg # extension on DOS 8.3 file systems. 9264fc27e79cSmrg func_arith $current - $age 9265fc27e79cSmrg major=$func_arith_result 9266e4da38afSmrg versuffix=-$major 9267fc27e79cSmrg ;; 9268fc27e79cSmrg 9269fc27e79cSmrg *) 9270e4da38afSmrg func_fatal_configuration "unknown library version type '$version_type'" 9271fc27e79cSmrg ;; 9272fc27e79cSmrg esac 9273fc27e79cSmrg 9274fc27e79cSmrg # Clear the version info if we defaulted, and they specified a release. 9275fc27e79cSmrg if test -z "$vinfo" && test -n "$release"; then 9276fc27e79cSmrg major= 9277fc27e79cSmrg case $version_type in 9278fc27e79cSmrg darwin) 9279fc27e79cSmrg # we can't check for "0.0" in archive_cmds due to quoting 9280fc27e79cSmrg # problems, so we reset it completely 9281fc27e79cSmrg verstring= 9282fc27e79cSmrg ;; 9283fc27e79cSmrg *) 9284e4da38afSmrg verstring=0.0 9285fc27e79cSmrg ;; 9286fc27e79cSmrg esac 9287e4da38afSmrg if test no = "$need_version"; then 9288fc27e79cSmrg versuffix= 9289fc27e79cSmrg else 9290e4da38afSmrg versuffix=.0.0 9291fc27e79cSmrg fi 9292fc27e79cSmrg fi 9293fc27e79cSmrg 9294fc27e79cSmrg # Remove version info from name if versioning should be avoided 9295e4da38afSmrg if test yes,no = "$avoid_version,$need_version"; then 9296fc27e79cSmrg major= 9297fc27e79cSmrg versuffix= 9298e4da38afSmrg verstring= 9299fc27e79cSmrg fi 9300fc27e79cSmrg 9301fc27e79cSmrg # Check to see if the archive will have undefined symbols. 9302e4da38afSmrg if test yes = "$allow_undefined"; then 9303e4da38afSmrg if test unsupported = "$allow_undefined_flag"; then 9304e4da38afSmrg if test yes = "$build_old_libs"; then 9305e4da38afSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9306e4da38afSmrg build_libtool_libs=no 9307e4da38afSmrg else 9308e4da38afSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9309e4da38afSmrg fi 9310fc27e79cSmrg fi 9311fc27e79cSmrg else 9312fc27e79cSmrg # Don't allow undefined symbols. 9313e4da38afSmrg allow_undefined_flag=$no_undefined_flag 9314fc27e79cSmrg fi 9315fc27e79cSmrg 9316fc27e79cSmrg fi 9317fc27e79cSmrg 9318e4da38afSmrg func_generate_dlsyms "$libname" "$libname" : 9319bd3a1963Smrg func_append libobjs " $symfileobj" 9320e4da38afSmrg test " " = "$libobjs" && libobjs= 9321fc27e79cSmrg 9322e4da38afSmrg if test relink != "$opt_mode"; then 9323fc27e79cSmrg # Remove our outputs, but don't remove object files since they 9324fc27e79cSmrg # may have been created when compiling PIC objects. 9325fc27e79cSmrg removelist= 9326fc27e79cSmrg tempremovelist=`$ECHO "$output_objdir/*"` 9327fc27e79cSmrg for p in $tempremovelist; do 9328fc27e79cSmrg case $p in 9329fc27e79cSmrg *.$objext | *.gcno) 9330fc27e79cSmrg ;; 9331e4da38afSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9332e4da38afSmrg if test -n "$precious_files_regex"; then 9333fc27e79cSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9334fc27e79cSmrg then 9335fc27e79cSmrg continue 9336fc27e79cSmrg fi 9337fc27e79cSmrg fi 9338bd3a1963Smrg func_append removelist " $p" 9339fc27e79cSmrg ;; 9340fc27e79cSmrg *) ;; 9341fc27e79cSmrg esac 9342fc27e79cSmrg done 9343fc27e79cSmrg test -n "$removelist" && \ 9344fc27e79cSmrg func_show_eval "${RM}r \$removelist" 9345fc27e79cSmrg fi 9346fc27e79cSmrg 9347fc27e79cSmrg # Now set the variables for building old libraries. 9348e4da38afSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9349bd3a1963Smrg func_append oldlibs " $output_objdir/$libname.$libext" 9350fc27e79cSmrg 9351fc27e79cSmrg # Transform .lo files to .o files. 9352e4da38afSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9353fc27e79cSmrg fi 9354fc27e79cSmrg 9355fc27e79cSmrg # Eliminate all temporary directories. 9356fc27e79cSmrg #for path in $notinst_path; do 9357bd3a1963Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9358bd3a1963Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9359bd3a1963Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9360fc27e79cSmrg #done 9361fc27e79cSmrg 9362fc27e79cSmrg if test -n "$xrpath"; then 9363fc27e79cSmrg # If the user specified any rpath flags, then add them. 9364fc27e79cSmrg temp_xrpath= 9365fc27e79cSmrg for libdir in $xrpath; do 9366bd3a1963Smrg func_replace_sysroot "$libdir" 9367bd3a1963Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9368fc27e79cSmrg case "$finalize_rpath " in 9369fc27e79cSmrg *" $libdir "*) ;; 9370bd3a1963Smrg *) func_append finalize_rpath " $libdir" ;; 9371fc27e79cSmrg esac 9372fc27e79cSmrg done 9373e4da38afSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9374fc27e79cSmrg dependency_libs="$temp_xrpath $dependency_libs" 9375fc27e79cSmrg fi 9376fc27e79cSmrg fi 9377fc27e79cSmrg 9378fc27e79cSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 9379e4da38afSmrg old_dlfiles=$dlfiles 9380fc27e79cSmrg dlfiles= 9381fc27e79cSmrg for lib in $old_dlfiles; do 9382fc27e79cSmrg case " $dlprefiles $dlfiles " in 9383fc27e79cSmrg *" $lib "*) ;; 9384bd3a1963Smrg *) func_append dlfiles " $lib" ;; 9385fc27e79cSmrg esac 9386fc27e79cSmrg done 9387fc27e79cSmrg 9388fc27e79cSmrg # Make sure dlprefiles contains only unique files 9389e4da38afSmrg old_dlprefiles=$dlprefiles 9390fc27e79cSmrg dlprefiles= 9391fc27e79cSmrg for lib in $old_dlprefiles; do 9392fc27e79cSmrg case "$dlprefiles " in 9393fc27e79cSmrg *" $lib "*) ;; 9394bd3a1963Smrg *) func_append dlprefiles " $lib" ;; 9395fc27e79cSmrg esac 9396fc27e79cSmrg done 9397fc27e79cSmrg 9398e4da38afSmrg if test yes = "$build_libtool_libs"; then 9399fc27e79cSmrg if test -n "$rpath"; then 9400fc27e79cSmrg case $host in 9401bd3a1963Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9402fc27e79cSmrg # these systems don't actually have a c library (as such)! 9403fc27e79cSmrg ;; 9404fc27e79cSmrg *-*-rhapsody* | *-*-darwin1.[012]) 9405fc27e79cSmrg # Rhapsody C library is in the System framework 9406bd3a1963Smrg func_append deplibs " System.ltframework" 9407fc27e79cSmrg ;; 9408fc27e79cSmrg *-*-netbsd*) 9409fc27e79cSmrg # Don't link with libc until the a.out ld.so is fixed. 9410fc27e79cSmrg ;; 9411370b807fSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 9412fc27e79cSmrg # Do not include libc due to us having libc/libc_r. 9413fc27e79cSmrg ;; 9414fc27e79cSmrg *-*-sco3.2v5* | *-*-sco5v6*) 9415fc27e79cSmrg # Causes problems with __ctype 9416fc27e79cSmrg ;; 9417fc27e79cSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9418fc27e79cSmrg # Compiler inserts libc in the correct place for threads to work 9419fc27e79cSmrg ;; 9420fc27e79cSmrg *) 9421fc27e79cSmrg # Add libc to deplibs on all other systems if necessary. 9422e4da38afSmrg if test yes = "$build_libtool_need_lc"; then 9423bd3a1963Smrg func_append deplibs " -lc" 9424fc27e79cSmrg fi 9425fc27e79cSmrg ;; 9426fc27e79cSmrg esac 9427fc27e79cSmrg fi 9428fc27e79cSmrg 9429fc27e79cSmrg # Transform deplibs into only deplibs that can be linked in shared. 9430fc27e79cSmrg name_save=$name 9431fc27e79cSmrg libname_save=$libname 9432fc27e79cSmrg release_save=$release 9433fc27e79cSmrg versuffix_save=$versuffix 9434fc27e79cSmrg major_save=$major 9435fc27e79cSmrg # I'm not sure if I'm treating the release correctly. I think 9436fc27e79cSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 9437fc27e79cSmrg # add it in twice. Is that correct? 9438e4da38afSmrg release= 9439e4da38afSmrg versuffix= 9440e4da38afSmrg major= 9441fc27e79cSmrg newdeplibs= 9442fc27e79cSmrg droppeddeps=no 9443fc27e79cSmrg case $deplibs_check_method in 9444fc27e79cSmrg pass_all) 9445fc27e79cSmrg # Don't check for shared/static. Everything works. 9446fc27e79cSmrg # This might be a little naive. We might want to check 9447fc27e79cSmrg # whether the library exists or not. But this is on 9448fc27e79cSmrg # osf3 & osf4 and I'm not really sure... Just 9449fc27e79cSmrg # implementing what was already the behavior. 9450fc27e79cSmrg newdeplibs=$deplibs 9451fc27e79cSmrg ;; 9452fc27e79cSmrg test_compile) 9453fc27e79cSmrg # This code stresses the "libraries are programs" paradigm to its 9454fc27e79cSmrg # limits. Maybe even breaks it. We compile a program, linking it 9455fc27e79cSmrg # against the deplibs as a proxy for the library. Then we can check 9456fc27e79cSmrg # whether they linked in statically or dynamically with ldd. 9457fc27e79cSmrg $opt_dry_run || $RM conftest.c 9458fc27e79cSmrg cat > conftest.c <<EOF 9459fc27e79cSmrg int main() { return 0; } 9460fc27e79cSmrgEOF 9461fc27e79cSmrg $opt_dry_run || $RM conftest 9462fc27e79cSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9463fc27e79cSmrg ldd_output=`ldd conftest` 9464fc27e79cSmrg for i in $deplibs; do 9465fc27e79cSmrg case $i in 9466fc27e79cSmrg -l*) 9467fc27e79cSmrg func_stripname -l '' "$i" 9468fc27e79cSmrg name=$func_stripname_result 9469e4da38afSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9470fc27e79cSmrg case " $predeps $postdeps " in 9471fc27e79cSmrg *" $i "*) 9472bd3a1963Smrg func_append newdeplibs " $i" 9473e4da38afSmrg i= 9474fc27e79cSmrg ;; 9475fc27e79cSmrg esac 9476fc27e79cSmrg fi 9477e4da38afSmrg if test -n "$i"; then 9478fc27e79cSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9479fc27e79cSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9480fc27e79cSmrg set dummy $deplib_matches; shift 9481fc27e79cSmrg deplib_match=$1 9482e4da38afSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9483bd3a1963Smrg func_append newdeplibs " $i" 9484fc27e79cSmrg else 9485fc27e79cSmrg droppeddeps=yes 9486bd3a1963Smrg echo 9487fc27e79cSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9488bd3a1963Smrg echo "*** I have the capability to make that library automatically link in when" 9489bd3a1963Smrg echo "*** you link to this library. But I can only do this if you have a" 9490bd3a1963Smrg echo "*** shared version of the library, which I believe you do not have" 9491bd3a1963Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 9492bd3a1963Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9493fc27e79cSmrg fi 9494fc27e79cSmrg fi 9495fc27e79cSmrg ;; 9496fc27e79cSmrg *) 9497bd3a1963Smrg func_append newdeplibs " $i" 9498fc27e79cSmrg ;; 9499fc27e79cSmrg esac 9500fc27e79cSmrg done 9501fc27e79cSmrg else 9502fc27e79cSmrg # Error occurred in the first compile. Let's try to salvage 9503fc27e79cSmrg # the situation: Compile a separate program for each library. 9504fc27e79cSmrg for i in $deplibs; do 9505fc27e79cSmrg case $i in 9506fc27e79cSmrg -l*) 9507fc27e79cSmrg func_stripname -l '' "$i" 9508fc27e79cSmrg name=$func_stripname_result 9509fc27e79cSmrg $opt_dry_run || $RM conftest 9510fc27e79cSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9511fc27e79cSmrg ldd_output=`ldd conftest` 9512e4da38afSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9513fc27e79cSmrg case " $predeps $postdeps " in 9514fc27e79cSmrg *" $i "*) 9515bd3a1963Smrg func_append newdeplibs " $i" 9516e4da38afSmrg i= 9517fc27e79cSmrg ;; 9518fc27e79cSmrg esac 9519fc27e79cSmrg fi 9520e4da38afSmrg if test -n "$i"; then 9521fc27e79cSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9522fc27e79cSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9523fc27e79cSmrg set dummy $deplib_matches; shift 9524fc27e79cSmrg deplib_match=$1 9525e4da38afSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9526bd3a1963Smrg func_append newdeplibs " $i" 9527fc27e79cSmrg else 9528fc27e79cSmrg droppeddeps=yes 9529bd3a1963Smrg echo 9530fc27e79cSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9531bd3a1963Smrg echo "*** I have the capability to make that library automatically link in when" 9532bd3a1963Smrg echo "*** you link to this library. But I can only do this if you have a" 9533bd3a1963Smrg echo "*** shared version of the library, which you do not appear to have" 9534bd3a1963Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 9535bd3a1963Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9536fc27e79cSmrg fi 9537fc27e79cSmrg fi 9538fc27e79cSmrg else 9539fc27e79cSmrg droppeddeps=yes 9540bd3a1963Smrg echo 9541fc27e79cSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9542bd3a1963Smrg echo "*** make it link in! You will probably need to install it or some" 9543bd3a1963Smrg echo "*** library that it depends on before this library will be fully" 9544bd3a1963Smrg echo "*** functional. Installing it before continuing would be even better." 9545fc27e79cSmrg fi 9546fc27e79cSmrg ;; 9547fc27e79cSmrg *) 9548bd3a1963Smrg func_append newdeplibs " $i" 9549fc27e79cSmrg ;; 9550fc27e79cSmrg esac 9551fc27e79cSmrg done 9552fc27e79cSmrg fi 9553fc27e79cSmrg ;; 9554fc27e79cSmrg file_magic*) 9555fc27e79cSmrg set dummy $deplibs_check_method; shift 9556fc27e79cSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9557fc27e79cSmrg for a_deplib in $deplibs; do 9558fc27e79cSmrg case $a_deplib in 9559fc27e79cSmrg -l*) 9560fc27e79cSmrg func_stripname -l '' "$a_deplib" 9561fc27e79cSmrg name=$func_stripname_result 9562e4da38afSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9563fc27e79cSmrg case " $predeps $postdeps " in 9564fc27e79cSmrg *" $a_deplib "*) 9565bd3a1963Smrg func_append newdeplibs " $a_deplib" 9566e4da38afSmrg a_deplib= 9567fc27e79cSmrg ;; 9568fc27e79cSmrg esac 9569fc27e79cSmrg fi 9570e4da38afSmrg if test -n "$a_deplib"; then 9571fc27e79cSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9572bd3a1963Smrg if test -n "$file_magic_glob"; then 9573bd3a1963Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9574bd3a1963Smrg else 9575bd3a1963Smrg libnameglob=$libname 9576bd3a1963Smrg fi 9577e4da38afSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9578fc27e79cSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9579e4da38afSmrg if test yes = "$want_nocaseglob"; then 9580bd3a1963Smrg shopt -s nocaseglob 9581bd3a1963Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9582bd3a1963Smrg $nocaseglob 9583bd3a1963Smrg else 9584bd3a1963Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9585bd3a1963Smrg fi 9586fc27e79cSmrg for potent_lib in $potential_libs; do 9587fc27e79cSmrg # Follow soft links. 9588fc27e79cSmrg if ls -lLd "$potent_lib" 2>/dev/null | 9589fc27e79cSmrg $GREP " -> " >/dev/null; then 9590fc27e79cSmrg continue 9591fc27e79cSmrg fi 9592fc27e79cSmrg # The statement above tries to avoid entering an 9593fc27e79cSmrg # endless loop below, in case of cyclic links. 9594fc27e79cSmrg # We might still enter an endless loop, since a link 9595fc27e79cSmrg # loop can be closed while we follow links, 9596fc27e79cSmrg # but so what? 9597e4da38afSmrg potlib=$potent_lib 9598fc27e79cSmrg while test -h "$potlib" 2>/dev/null; do 9599e4da38afSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9600fc27e79cSmrg case $potliblink in 9601e4da38afSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9602e4da38afSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9603fc27e79cSmrg esac 9604fc27e79cSmrg done 9605fc27e79cSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9606fc27e79cSmrg $SED -e 10q | 9607fc27e79cSmrg $EGREP "$file_magic_regex" > /dev/null; then 9608bd3a1963Smrg func_append newdeplibs " $a_deplib" 9609e4da38afSmrg a_deplib= 9610fc27e79cSmrg break 2 9611fc27e79cSmrg fi 9612fc27e79cSmrg done 9613fc27e79cSmrg done 9614fc27e79cSmrg fi 9615e4da38afSmrg if test -n "$a_deplib"; then 9616fc27e79cSmrg droppeddeps=yes 9617bd3a1963Smrg echo 9618fc27e79cSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9619bd3a1963Smrg echo "*** I have the capability to make that library automatically link in when" 9620bd3a1963Smrg echo "*** you link to this library. But I can only do this if you have a" 9621bd3a1963Smrg echo "*** shared version of the library, which you do not appear to have" 9622bd3a1963Smrg echo "*** because I did check the linker path looking for a file starting" 9623e4da38afSmrg if test -z "$potlib"; then 9624fc27e79cSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9625fc27e79cSmrg else 9626fc27e79cSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9627fc27e79cSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 9628fc27e79cSmrg fi 9629fc27e79cSmrg fi 9630fc27e79cSmrg ;; 9631fc27e79cSmrg *) 9632fc27e79cSmrg # Add a -L argument. 9633bd3a1963Smrg func_append newdeplibs " $a_deplib" 9634fc27e79cSmrg ;; 9635fc27e79cSmrg esac 9636fc27e79cSmrg done # Gone through all deplibs. 9637fc27e79cSmrg ;; 9638fc27e79cSmrg match_pattern*) 9639fc27e79cSmrg set dummy $deplibs_check_method; shift 9640fc27e79cSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9641fc27e79cSmrg for a_deplib in $deplibs; do 9642fc27e79cSmrg case $a_deplib in 9643fc27e79cSmrg -l*) 9644fc27e79cSmrg func_stripname -l '' "$a_deplib" 9645fc27e79cSmrg name=$func_stripname_result 9646e4da38afSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9647fc27e79cSmrg case " $predeps $postdeps " in 9648fc27e79cSmrg *" $a_deplib "*) 9649bd3a1963Smrg func_append newdeplibs " $a_deplib" 9650e4da38afSmrg a_deplib= 9651fc27e79cSmrg ;; 9652fc27e79cSmrg esac 9653fc27e79cSmrg fi 9654e4da38afSmrg if test -n "$a_deplib"; then 9655fc27e79cSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9656fc27e79cSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9657fc27e79cSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9658fc27e79cSmrg for potent_lib in $potential_libs; do 9659e4da38afSmrg potlib=$potent_lib # see symlink-check above in file_magic test 9660bd3a1963Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9661fc27e79cSmrg $EGREP "$match_pattern_regex" > /dev/null; then 9662bd3a1963Smrg func_append newdeplibs " $a_deplib" 9663e4da38afSmrg a_deplib= 9664fc27e79cSmrg break 2 9665fc27e79cSmrg fi 9666fc27e79cSmrg done 9667fc27e79cSmrg done 9668fc27e79cSmrg fi 9669e4da38afSmrg if test -n "$a_deplib"; then 9670fc27e79cSmrg droppeddeps=yes 9671bd3a1963Smrg echo 9672fc27e79cSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9673bd3a1963Smrg echo "*** I have the capability to make that library automatically link in when" 9674bd3a1963Smrg echo "*** you link to this library. But I can only do this if you have a" 9675bd3a1963Smrg echo "*** shared version of the library, which you do not appear to have" 9676bd3a1963Smrg echo "*** because I did check the linker path looking for a file starting" 9677e4da38afSmrg if test -z "$potlib"; then 9678fc27e79cSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9679fc27e79cSmrg else 9680fc27e79cSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9681fc27e79cSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9682fc27e79cSmrg fi 9683fc27e79cSmrg fi 9684fc27e79cSmrg ;; 9685fc27e79cSmrg *) 9686fc27e79cSmrg # Add a -L argument. 9687bd3a1963Smrg func_append newdeplibs " $a_deplib" 9688fc27e79cSmrg ;; 9689fc27e79cSmrg esac 9690fc27e79cSmrg done # Gone through all deplibs. 9691fc27e79cSmrg ;; 9692fc27e79cSmrg none | unknown | *) 9693e4da38afSmrg newdeplibs= 9694bd3a1963Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9695e4da38afSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9696e4da38afSmrg for i in $predeps $postdeps; do 9697fc27e79cSmrg # can't use Xsed below, because $i might contain '/' 9698e4da38afSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9699fc27e79cSmrg done 9700fc27e79cSmrg fi 9701bd3a1963Smrg case $tmp_deplibs in 9702bd3a1963Smrg *[!\ \ ]*) 9703bd3a1963Smrg echo 9704e4da38afSmrg if test none = "$deplibs_check_method"; then 9705bd3a1963Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9706fc27e79cSmrg else 9707bd3a1963Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 9708fc27e79cSmrg fi 9709bd3a1963Smrg echo "*** All declared inter-library dependencies are being dropped." 9710fc27e79cSmrg droppeddeps=yes 9711bd3a1963Smrg ;; 9712bd3a1963Smrg esac 9713fc27e79cSmrg ;; 9714fc27e79cSmrg esac 9715fc27e79cSmrg versuffix=$versuffix_save 9716fc27e79cSmrg major=$major_save 9717fc27e79cSmrg release=$release_save 9718fc27e79cSmrg libname=$libname_save 9719fc27e79cSmrg name=$name_save 9720fc27e79cSmrg 9721fc27e79cSmrg case $host in 9722fc27e79cSmrg *-*-rhapsody* | *-*-darwin1.[012]) 9723fc27e79cSmrg # On Rhapsody replace the C library with the System framework 9724bd3a1963Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9725fc27e79cSmrg ;; 9726fc27e79cSmrg esac 9727fc27e79cSmrg 9728e4da38afSmrg if test yes = "$droppeddeps"; then 9729e4da38afSmrg if test yes = "$module"; then 9730bd3a1963Smrg echo 9731bd3a1963Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9732fc27e79cSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9733bd3a1963Smrg echo "*** a static module, that should work as long as the dlopening" 9734bd3a1963Smrg echo "*** application is linked with the -dlopen flag." 9735fc27e79cSmrg if test -z "$global_symbol_pipe"; then 9736bd3a1963Smrg echo 9737bd3a1963Smrg echo "*** However, this would only work if libtool was able to extract symbol" 9738e4da38afSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9739bd3a1963Smrg echo "*** not find such a program. So, this module is probably useless." 9740e4da38afSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9741fc27e79cSmrg fi 9742e4da38afSmrg if test no = "$build_old_libs"; then 9743e4da38afSmrg oldlibs=$output_objdir/$libname.$libext 9744fc27e79cSmrg build_libtool_libs=module 9745fc27e79cSmrg build_old_libs=yes 9746fc27e79cSmrg else 9747fc27e79cSmrg build_libtool_libs=no 9748fc27e79cSmrg fi 9749fc27e79cSmrg else 9750bd3a1963Smrg echo "*** The inter-library dependencies that have been dropped here will be" 9751bd3a1963Smrg echo "*** automatically added whenever a program is linked with this library" 9752bd3a1963Smrg echo "*** or is declared to -dlopen it." 9753fc27e79cSmrg 9754e4da38afSmrg if test no = "$allow_undefined"; then 9755bd3a1963Smrg echo 9756bd3a1963Smrg echo "*** Since this library must not contain undefined symbols," 9757bd3a1963Smrg echo "*** because either the platform does not support them or" 9758bd3a1963Smrg echo "*** it was explicitly requested with -no-undefined," 9759bd3a1963Smrg echo "*** libtool will only create a static version of it." 9760e4da38afSmrg if test no = "$build_old_libs"; then 9761e4da38afSmrg oldlibs=$output_objdir/$libname.$libext 9762fc27e79cSmrg build_libtool_libs=module 9763fc27e79cSmrg build_old_libs=yes 9764fc27e79cSmrg else 9765fc27e79cSmrg build_libtool_libs=no 9766fc27e79cSmrg fi 9767fc27e79cSmrg fi 9768fc27e79cSmrg fi 9769fc27e79cSmrg fi 9770fc27e79cSmrg # Done checking deplibs! 9771fc27e79cSmrg deplibs=$newdeplibs 9772fc27e79cSmrg fi 9773fc27e79cSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9774fc27e79cSmrg case $host in 9775fc27e79cSmrg *-*-darwin*) 9776bd3a1963Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9777bd3a1963Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9778bd3a1963Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9779fc27e79cSmrg ;; 9780fc27e79cSmrg esac 9781fc27e79cSmrg 9782fc27e79cSmrg # move library search paths that coincide with paths to not yet 9783fc27e79cSmrg # installed libraries to the beginning of the library search list 9784fc27e79cSmrg new_libs= 9785fc27e79cSmrg for path in $notinst_path; do 9786fc27e79cSmrg case " $new_libs " in 9787fc27e79cSmrg *" -L$path/$objdir "*) ;; 9788fc27e79cSmrg *) 9789fc27e79cSmrg case " $deplibs " in 9790fc27e79cSmrg *" -L$path/$objdir "*) 9791bd3a1963Smrg func_append new_libs " -L$path/$objdir" ;; 9792fc27e79cSmrg esac 9793fc27e79cSmrg ;; 9794fc27e79cSmrg esac 9795fc27e79cSmrg done 9796fc27e79cSmrg for deplib in $deplibs; do 9797fc27e79cSmrg case $deplib in 9798fc27e79cSmrg -L*) 9799fc27e79cSmrg case " $new_libs " in 9800fc27e79cSmrg *" $deplib "*) ;; 9801bd3a1963Smrg *) func_append new_libs " $deplib" ;; 9802fc27e79cSmrg esac 9803fc27e79cSmrg ;; 9804bd3a1963Smrg *) func_append new_libs " $deplib" ;; 9805fc27e79cSmrg esac 9806fc27e79cSmrg done 9807e4da38afSmrg deplibs=$new_libs 9808fc27e79cSmrg 9809fc27e79cSmrg # All the library-specific variables (install_libdir is set above). 9810fc27e79cSmrg library_names= 9811fc27e79cSmrg old_library= 9812fc27e79cSmrg dlname= 9813fc27e79cSmrg 9814fc27e79cSmrg # Test again, we may have decided not to build it any more 9815e4da38afSmrg if test yes = "$build_libtool_libs"; then 9816e4da38afSmrg # Remove $wl instances when linking with ld. 9817a73597f9Smrg # FIXME: should test the right _cmds variable. 9818a73597f9Smrg case $archive_cmds in 9819a73597f9Smrg *\$LD\ *) wl= ;; 9820a73597f9Smrg esac 9821e4da38afSmrg if test yes = "$hardcode_into_libs"; then 9822fc27e79cSmrg # Hardcode the library paths 9823fc27e79cSmrg hardcode_libdirs= 9824fc27e79cSmrg dep_rpath= 9825e4da38afSmrg rpath=$finalize_rpath 9826e4da38afSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9827fc27e79cSmrg for libdir in $rpath; do 9828fc27e79cSmrg if test -n "$hardcode_libdir_flag_spec"; then 9829fc27e79cSmrg if test -n "$hardcode_libdir_separator"; then 9830bd3a1963Smrg func_replace_sysroot "$libdir" 9831bd3a1963Smrg libdir=$func_replace_sysroot_result 9832fc27e79cSmrg if test -z "$hardcode_libdirs"; then 9833e4da38afSmrg hardcode_libdirs=$libdir 9834fc27e79cSmrg else 9835fc27e79cSmrg # Just accumulate the unique libdirs. 9836fc27e79cSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9837fc27e79cSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9838fc27e79cSmrg ;; 9839fc27e79cSmrg *) 9840bd3a1963Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9841fc27e79cSmrg ;; 9842fc27e79cSmrg esac 9843fc27e79cSmrg fi 9844fc27e79cSmrg else 9845fc27e79cSmrg eval flag=\"$hardcode_libdir_flag_spec\" 9846bd3a1963Smrg func_append dep_rpath " $flag" 9847fc27e79cSmrg fi 9848fc27e79cSmrg elif test -n "$runpath_var"; then 9849fc27e79cSmrg case "$perm_rpath " in 9850fc27e79cSmrg *" $libdir "*) ;; 9851a73597f9Smrg *) func_append perm_rpath " $libdir" ;; 9852fc27e79cSmrg esac 9853fc27e79cSmrg fi 9854fc27e79cSmrg done 9855fc27e79cSmrg # Substitute the hardcoded libdirs into the rpath. 9856fc27e79cSmrg if test -n "$hardcode_libdir_separator" && 9857fc27e79cSmrg test -n "$hardcode_libdirs"; then 9858e4da38afSmrg libdir=$hardcode_libdirs 9859a73597f9Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9860fc27e79cSmrg fi 9861fc27e79cSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9862fc27e79cSmrg # We should set the runpath_var. 9863fc27e79cSmrg rpath= 9864fc27e79cSmrg for dir in $perm_rpath; do 9865bd3a1963Smrg func_append rpath "$dir:" 9866fc27e79cSmrg done 9867fc27e79cSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9868fc27e79cSmrg fi 9869fc27e79cSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9870fc27e79cSmrg fi 9871659607e0Smrg 9872e4da38afSmrg shlibpath=$finalize_shlibpath 9873e4da38afSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9874fc27e79cSmrg if test -n "$shlibpath"; then 9875fc27e79cSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9876fc27e79cSmrg fi 9877659607e0Smrg 9878fc27e79cSmrg # Get the real and link names of the library. 9879fc27e79cSmrg eval shared_ext=\"$shrext_cmds\" 9880fc27e79cSmrg eval library_names=\"$library_names_spec\" 9881fc27e79cSmrg set dummy $library_names 9882fc27e79cSmrg shift 9883e4da38afSmrg realname=$1 9884fc27e79cSmrg shift 9885659607e0Smrg 9886fc27e79cSmrg if test -n "$soname_spec"; then 9887fc27e79cSmrg eval soname=\"$soname_spec\" 9888fc27e79cSmrg else 9889e4da38afSmrg soname=$realname 9890fc27e79cSmrg fi 9891fc27e79cSmrg if test -z "$dlname"; then 9892fc27e79cSmrg dlname=$soname 9893fc27e79cSmrg fi 9894659607e0Smrg 9895e4da38afSmrg lib=$output_objdir/$realname 9896fc27e79cSmrg linknames= 9897fc27e79cSmrg for link 9898fc27e79cSmrg do 9899bd3a1963Smrg func_append linknames " $link" 9900fc27e79cSmrg done 9901659607e0Smrg 9902fc27e79cSmrg # Use standard objects if they are pic 9903bd3a1963Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9904fc27e79cSmrg test "X$libobjs" = "X " && libobjs= 9905659607e0Smrg 9906fc27e79cSmrg delfiles= 9907fc27e79cSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9908fc27e79cSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9909e4da38afSmrg export_symbols=$output_objdir/$libname.uexp 9910bd3a1963Smrg func_append delfiles " $export_symbols" 9911fc27e79cSmrg fi 9912659607e0Smrg 9913fc27e79cSmrg orig_export_symbols= 9914fc27e79cSmrg case $host_os in 9915fc27e79cSmrg cygwin* | mingw* | cegcc*) 9916fc27e79cSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9917fc27e79cSmrg # exporting using user supplied symfile 9918e4da38afSmrg func_dll_def_p "$export_symbols" || { 9919fc27e79cSmrg # and it's NOT already a .def file. Must figure out 9920fc27e79cSmrg # which of the given symbols are data symbols and tag 9921fc27e79cSmrg # them as such. So, trigger use of export_symbols_cmds. 9922fc27e79cSmrg # export_symbols gets reassigned inside the "prepare 9923fc27e79cSmrg # the list of exported symbols" if statement, so the 9924fc27e79cSmrg # include_expsyms logic still works. 9925e4da38afSmrg orig_export_symbols=$export_symbols 9926fc27e79cSmrg export_symbols= 9927fc27e79cSmrg always_export_symbols=yes 9928e4da38afSmrg } 9929fc27e79cSmrg fi 9930fc27e79cSmrg ;; 9931fc27e79cSmrg esac 9932659607e0Smrg 9933fc27e79cSmrg # Prepare the list of exported symbols 9934fc27e79cSmrg if test -z "$export_symbols"; then 9935e4da38afSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9936e4da38afSmrg func_verbose "generating symbol list for '$libname.la'" 9937e4da38afSmrg export_symbols=$output_objdir/$libname.exp 9938fc27e79cSmrg $opt_dry_run || $RM $export_symbols 9939fc27e79cSmrg cmds=$export_symbols_cmds 9940e4da38afSmrg save_ifs=$IFS; IFS='~' 9941bd3a1963Smrg for cmd1 in $cmds; do 9942e4da38afSmrg IFS=$save_ifs 9943bd3a1963Smrg # Take the normal branch if the nm_file_list_spec branch 9944bd3a1963Smrg # doesn't work or if tool conversion is not needed. 9945bd3a1963Smrg case $nm_file_list_spec~$to_tool_file_cmd in 9946bd3a1963Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9947bd3a1963Smrg try_normal_branch=yes 9948bd3a1963Smrg eval cmd=\"$cmd1\" 9949bd3a1963Smrg func_len " $cmd" 9950bd3a1963Smrg len=$func_len_result 9951bd3a1963Smrg ;; 9952bd3a1963Smrg *) 9953bd3a1963Smrg try_normal_branch=no 9954bd3a1963Smrg ;; 9955bd3a1963Smrg esac 9956e4da38afSmrg if test yes = "$try_normal_branch" \ 9957bd3a1963Smrg && { test "$len" -lt "$max_cmd_len" \ 9958bd3a1963Smrg || test "$max_cmd_len" -le -1; } 9959bd3a1963Smrg then 9960bd3a1963Smrg func_show_eval "$cmd" 'exit $?' 9961bd3a1963Smrg skipped_export=false 9962bd3a1963Smrg elif test -n "$nm_file_list_spec"; then 9963bd3a1963Smrg func_basename "$output" 9964bd3a1963Smrg output_la=$func_basename_result 9965bd3a1963Smrg save_libobjs=$libobjs 9966bd3a1963Smrg save_output=$output 9967e4da38afSmrg output=$output_objdir/$output_la.nm 9968bd3a1963Smrg func_to_tool_file "$output" 9969bd3a1963Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9970bd3a1963Smrg func_append delfiles " $output" 9971bd3a1963Smrg func_verbose "creating $NM input file list: $output" 9972bd3a1963Smrg for obj in $save_libobjs; do 9973bd3a1963Smrg func_to_tool_file "$obj" 9974bd3a1963Smrg $ECHO "$func_to_tool_file_result" 9975bd3a1963Smrg done > "$output" 9976bd3a1963Smrg eval cmd=\"$cmd1\" 9977fc27e79cSmrg func_show_eval "$cmd" 'exit $?' 9978bd3a1963Smrg output=$save_output 9979bd3a1963Smrg libobjs=$save_libobjs 9980fc27e79cSmrg skipped_export=false 9981fc27e79cSmrg else 9982fc27e79cSmrg # The command line is too long to execute in one step. 9983fc27e79cSmrg func_verbose "using reloadable object file for export list..." 9984fc27e79cSmrg skipped_export=: 9985fc27e79cSmrg # Break out early, otherwise skipped_export may be 9986fc27e79cSmrg # set to false by a later but shorter cmd. 9987fc27e79cSmrg break 9988fc27e79cSmrg fi 9989fc27e79cSmrg done 9990e4da38afSmrg IFS=$save_ifs 9991e4da38afSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9992fc27e79cSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9993fc27e79cSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9994fc27e79cSmrg fi 9995fc27e79cSmrg fi 9996fc27e79cSmrg fi 9997659607e0Smrg 9998fc27e79cSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9999e4da38afSmrg tmp_export_symbols=$export_symbols 10000e4da38afSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10001bd3a1963Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10002fc27e79cSmrg fi 10003659607e0Smrg 10004e4da38afSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 10005fc27e79cSmrg # The given exports_symbols file has to be filtered, so filter it. 10006e4da38afSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10007fc27e79cSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 10008e4da38afSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 10009fc27e79cSmrg # though. Also, the filter scales superlinearly with the number of 10010fc27e79cSmrg # global variables. join(1) would be nice here, but unfortunately 10011fc27e79cSmrg # isn't a blessed tool. 10012fc27e79cSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10013bd3a1963Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10014fc27e79cSmrg export_symbols=$output_objdir/$libname.def 10015fc27e79cSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10016659607e0Smrg fi 10017659607e0Smrg 10018fc27e79cSmrg tmp_deplibs= 10019fc27e79cSmrg for test_deplib in $deplibs; do 10020fc27e79cSmrg case " $convenience " in 10021fc27e79cSmrg *" $test_deplib "*) ;; 10022fc27e79cSmrg *) 10023bd3a1963Smrg func_append tmp_deplibs " $test_deplib" 10024fc27e79cSmrg ;; 10025fc27e79cSmrg esac 10026fc27e79cSmrg done 10027e4da38afSmrg deplibs=$tmp_deplibs 10028659607e0Smrg 10029fc27e79cSmrg if test -n "$convenience"; then 10030fc27e79cSmrg if test -n "$whole_archive_flag_spec" && 10031e4da38afSmrg test yes = "$compiler_needs_object" && 10032fc27e79cSmrg test -z "$libobjs"; then 10033fc27e79cSmrg # extract the archives, so we have objects to list. 10034fc27e79cSmrg # TODO: could optimize this to just extract one archive. 10035fc27e79cSmrg whole_archive_flag_spec= 10036fc27e79cSmrg fi 10037fc27e79cSmrg if test -n "$whole_archive_flag_spec"; then 10038fc27e79cSmrg save_libobjs=$libobjs 10039fc27e79cSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10040fc27e79cSmrg test "X$libobjs" = "X " && libobjs= 10041fc27e79cSmrg else 10042e4da38afSmrg gentop=$output_objdir/${outputname}x 10043bd3a1963Smrg func_append generated " $gentop" 10044659607e0Smrg 10045fc27e79cSmrg func_extract_archives $gentop $convenience 10046bd3a1963Smrg func_append libobjs " $func_extract_archives_result" 10047fc27e79cSmrg test "X$libobjs" = "X " && libobjs= 10048fc27e79cSmrg fi 10049fc27e79cSmrg fi 10050659607e0Smrg 10051e4da38afSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 10052fc27e79cSmrg eval flag=\"$thread_safe_flag_spec\" 10053bd3a1963Smrg func_append linker_flags " $flag" 10054fc27e79cSmrg fi 10055659607e0Smrg 10056fc27e79cSmrg # Make a backup of the uninstalled library when relinking 10057e4da38afSmrg if test relink = "$opt_mode"; then 10058fc27e79cSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 10059659607e0Smrg fi 10060659607e0Smrg 10061fc27e79cSmrg # Do each of the archive commands. 10062e4da38afSmrg if test yes = "$module" && test -n "$module_cmds"; then 10063fc27e79cSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10064fc27e79cSmrg eval test_cmds=\"$module_expsym_cmds\" 10065fc27e79cSmrg cmds=$module_expsym_cmds 10066fc27e79cSmrg else 10067fc27e79cSmrg eval test_cmds=\"$module_cmds\" 10068fc27e79cSmrg cmds=$module_cmds 10069fc27e79cSmrg fi 10070fc27e79cSmrg else 10071fc27e79cSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10072fc27e79cSmrg eval test_cmds=\"$archive_expsym_cmds\" 10073fc27e79cSmrg cmds=$archive_expsym_cmds 10074fc27e79cSmrg else 10075fc27e79cSmrg eval test_cmds=\"$archive_cmds\" 10076fc27e79cSmrg cmds=$archive_cmds 10077fc27e79cSmrg fi 10078659607e0Smrg fi 10079659607e0Smrg 10080e4da38afSmrg if test : != "$skipped_export" && 10081fc27e79cSmrg func_len " $test_cmds" && 10082fc27e79cSmrg len=$func_len_result && 10083fc27e79cSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10084fc27e79cSmrg : 10085fc27e79cSmrg else 10086fc27e79cSmrg # The command line is too long to link in one step, link piecewise 10087fc27e79cSmrg # or, if using GNU ld and skipped_export is not :, use a linker 10088fc27e79cSmrg # script. 10089659607e0Smrg 10090fc27e79cSmrg # Save the value of $output and $libobjs because we want to 10091fc27e79cSmrg # use them later. If we have whole_archive_flag_spec, we 10092fc27e79cSmrg # want to use save_libobjs as it was before 10093fc27e79cSmrg # whole_archive_flag_spec was expanded, because we can't 10094fc27e79cSmrg # assume the linker understands whole_archive_flag_spec. 10095fc27e79cSmrg # This may have to be revisited, in case too many 10096fc27e79cSmrg # convenience libraries get linked in and end up exceeding 10097fc27e79cSmrg # the spec. 10098fc27e79cSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 10099fc27e79cSmrg save_libobjs=$libobjs 10100fc27e79cSmrg fi 10101fc27e79cSmrg save_output=$output 10102bd3a1963Smrg func_basename "$output" 10103bd3a1963Smrg output_la=$func_basename_result 10104659607e0Smrg 10105fc27e79cSmrg # Clear the reloadable object creation command queue and 10106fc27e79cSmrg # initialize k to one. 10107fc27e79cSmrg test_cmds= 10108fc27e79cSmrg concat_cmds= 10109fc27e79cSmrg objlist= 10110fc27e79cSmrg last_robj= 10111fc27e79cSmrg k=1 10112659607e0Smrg 10113e4da38afSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 10114e4da38afSmrg output=$output_objdir/$output_la.lnkscript 10115fc27e79cSmrg func_verbose "creating GNU ld script: $output" 10116bd3a1963Smrg echo 'INPUT (' > $output 10117fc27e79cSmrg for obj in $save_libobjs 10118fc27e79cSmrg do 10119bd3a1963Smrg func_to_tool_file "$obj" 10120bd3a1963Smrg $ECHO "$func_to_tool_file_result" >> $output 10121fc27e79cSmrg done 10122bd3a1963Smrg echo ')' >> $output 10123bd3a1963Smrg func_append delfiles " $output" 10124bd3a1963Smrg func_to_tool_file "$output" 10125bd3a1963Smrg output=$func_to_tool_file_result 10126e4da38afSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 10127e4da38afSmrg output=$output_objdir/$output_la.lnk 10128fc27e79cSmrg func_verbose "creating linker input file list: $output" 10129fc27e79cSmrg : > $output 10130fc27e79cSmrg set x $save_libobjs 10131fc27e79cSmrg shift 10132fc27e79cSmrg firstobj= 10133e4da38afSmrg if test yes = "$compiler_needs_object"; then 10134fc27e79cSmrg firstobj="$1 " 10135fc27e79cSmrg shift 10136fc27e79cSmrg fi 10137fc27e79cSmrg for obj 10138fc27e79cSmrg do 10139bd3a1963Smrg func_to_tool_file "$obj" 10140bd3a1963Smrg $ECHO "$func_to_tool_file_result" >> $output 10141fc27e79cSmrg done 10142bd3a1963Smrg func_append delfiles " $output" 10143bd3a1963Smrg func_to_tool_file "$output" 10144bd3a1963Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 10145fc27e79cSmrg else 10146fc27e79cSmrg if test -n "$save_libobjs"; then 10147fc27e79cSmrg func_verbose "creating reloadable object files..." 10148e4da38afSmrg output=$output_objdir/$output_la-$k.$objext 10149fc27e79cSmrg eval test_cmds=\"$reload_cmds\" 10150fc27e79cSmrg func_len " $test_cmds" 10151fc27e79cSmrg len0=$func_len_result 10152fc27e79cSmrg len=$len0 10153fc27e79cSmrg 10154fc27e79cSmrg # Loop over the list of objects to be linked. 10155fc27e79cSmrg for obj in $save_libobjs 10156fc27e79cSmrg do 10157fc27e79cSmrg func_len " $obj" 10158fc27e79cSmrg func_arith $len + $func_len_result 10159fc27e79cSmrg len=$func_arith_result 10160e4da38afSmrg if test -z "$objlist" || 10161fc27e79cSmrg test "$len" -lt "$max_cmd_len"; then 10162fc27e79cSmrg func_append objlist " $obj" 10163fc27e79cSmrg else 10164fc27e79cSmrg # The command $test_cmds is almost too long, add a 10165fc27e79cSmrg # command to the queue. 10166e4da38afSmrg if test 1 -eq "$k"; then 10167fc27e79cSmrg # The first file doesn't have a previous command to add. 10168bd3a1963Smrg reload_objs=$objlist 10169bd3a1963Smrg eval concat_cmds=\"$reload_cmds\" 10170fc27e79cSmrg else 10171fc27e79cSmrg # All subsequent reloadable object files will link in 10172fc27e79cSmrg # the last one created. 10173bd3a1963Smrg reload_objs="$objlist $last_robj" 10174bd3a1963Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 10175fc27e79cSmrg fi 10176e4da38afSmrg last_robj=$output_objdir/$output_la-$k.$objext 10177fc27e79cSmrg func_arith $k + 1 10178fc27e79cSmrg k=$func_arith_result 10179e4da38afSmrg output=$output_objdir/$output_la-$k.$objext 10180bd3a1963Smrg objlist=" $obj" 10181fc27e79cSmrg func_len " $last_robj" 10182fc27e79cSmrg func_arith $len0 + $func_len_result 10183fc27e79cSmrg len=$func_arith_result 10184fc27e79cSmrg fi 10185fc27e79cSmrg done 10186fc27e79cSmrg # Handle the remaining objects by creating one last 10187fc27e79cSmrg # reloadable object file. All subsequent reloadable object 10188fc27e79cSmrg # files will link in the last one created. 10189fc27e79cSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10190bd3a1963Smrg reload_objs="$objlist $last_robj" 10191e4da38afSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 10192fc27e79cSmrg if test -n "$last_robj"; then 10193e4da38afSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10194fc27e79cSmrg fi 10195bd3a1963Smrg func_append delfiles " $output" 10196659607e0Smrg 10197fc27e79cSmrg else 10198fc27e79cSmrg output= 10199fc27e79cSmrg fi 10200659607e0Smrg 10201e4da38afSmrg ${skipped_export-false} && { 10202e4da38afSmrg func_verbose "generating symbol list for '$libname.la'" 10203e4da38afSmrg export_symbols=$output_objdir/$libname.exp 10204fc27e79cSmrg $opt_dry_run || $RM $export_symbols 10205fc27e79cSmrg libobjs=$output 10206fc27e79cSmrg # Append the command to create the export file. 10207fc27e79cSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10208fc27e79cSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 10209fc27e79cSmrg if test -n "$last_robj"; then 10210fc27e79cSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10211fc27e79cSmrg fi 10212e4da38afSmrg } 10213659607e0Smrg 10214fc27e79cSmrg test -n "$save_libobjs" && 10215fc27e79cSmrg func_verbose "creating a temporary reloadable object file: $output" 10216659607e0Smrg 10217fc27e79cSmrg # Loop through the commands generated above and execute them. 10218e4da38afSmrg save_ifs=$IFS; IFS='~' 10219fc27e79cSmrg for cmd in $concat_cmds; do 10220e4da38afSmrg IFS=$save_ifs 10221e4da38afSmrg $opt_quiet || { 10222370b807fSmrg func_quote_arg expand,pretty "$cmd" 10223370b807fSmrg eval "func_echo $func_quote_arg_result" 10224fc27e79cSmrg } 10225fc27e79cSmrg $opt_dry_run || eval "$cmd" || { 10226fc27e79cSmrg lt_exit=$? 10227fc27e79cSmrg 10228fc27e79cSmrg # Restore the uninstalled library and exit 10229e4da38afSmrg if test relink = "$opt_mode"; then 10230fc27e79cSmrg ( cd "$output_objdir" && \ 10231fc27e79cSmrg $RM "${realname}T" && \ 10232fc27e79cSmrg $MV "${realname}U" "$realname" ) 10233fc27e79cSmrg fi 10234659607e0Smrg 10235fc27e79cSmrg exit $lt_exit 10236fc27e79cSmrg } 10237fc27e79cSmrg done 10238e4da38afSmrg IFS=$save_ifs 10239fc27e79cSmrg 10240fc27e79cSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 10241fc27e79cSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 10242fc27e79cSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 10243659607e0Smrg fi 10244659607e0Smrg fi 10245659607e0Smrg 10246e4da38afSmrg ${skipped_export-false} && { 10247fc27e79cSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 10248e4da38afSmrg tmp_export_symbols=$export_symbols 10249e4da38afSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10250bd3a1963Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10251fc27e79cSmrg fi 10252659607e0Smrg 10253fc27e79cSmrg if test -n "$orig_export_symbols"; then 10254fc27e79cSmrg # The given exports_symbols file has to be filtered, so filter it. 10255e4da38afSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10256fc27e79cSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 10257e4da38afSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 10258fc27e79cSmrg # though. Also, the filter scales superlinearly with the number of 10259fc27e79cSmrg # global variables. join(1) would be nice here, but unfortunately 10260fc27e79cSmrg # isn't a blessed tool. 10261fc27e79cSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10262bd3a1963Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10263fc27e79cSmrg export_symbols=$output_objdir/$libname.def 10264fc27e79cSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10265fc27e79cSmrg fi 10266e4da38afSmrg } 10267659607e0Smrg 10268fc27e79cSmrg libobjs=$output 10269fc27e79cSmrg # Restore the value of output. 10270fc27e79cSmrg output=$save_output 10271659607e0Smrg 10272fc27e79cSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 10273fc27e79cSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10274fc27e79cSmrg test "X$libobjs" = "X " && libobjs= 10275fc27e79cSmrg fi 10276fc27e79cSmrg # Expand the library linking commands again to reset the 10277fc27e79cSmrg # value of $libobjs for piecewise linking. 10278fc27e79cSmrg 10279fc27e79cSmrg # Do each of the archive commands. 10280e4da38afSmrg if test yes = "$module" && test -n "$module_cmds"; then 10281fc27e79cSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10282fc27e79cSmrg cmds=$module_expsym_cmds 10283659607e0Smrg else 10284fc27e79cSmrg cmds=$module_cmds 10285659607e0Smrg fi 10286659607e0Smrg else 10287fc27e79cSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10288fc27e79cSmrg cmds=$archive_expsym_cmds 10289fc27e79cSmrg else 10290fc27e79cSmrg cmds=$archive_cmds 10291fc27e79cSmrg fi 10292659607e0Smrg fi 10293659607e0Smrg fi 10294659607e0Smrg 10295fc27e79cSmrg if test -n "$delfiles"; then 10296fc27e79cSmrg # Append the command to remove temporary files to $cmds. 10297fc27e79cSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 10298fc27e79cSmrg fi 10299659607e0Smrg 10300fc27e79cSmrg # Add any objects from preloaded convenience libraries 10301fc27e79cSmrg if test -n "$dlprefiles"; then 10302e4da38afSmrg gentop=$output_objdir/${outputname}x 10303bd3a1963Smrg func_append generated " $gentop" 10304659607e0Smrg 10305fc27e79cSmrg func_extract_archives $gentop $dlprefiles 10306bd3a1963Smrg func_append libobjs " $func_extract_archives_result" 10307fc27e79cSmrg test "X$libobjs" = "X " && libobjs= 10308659607e0Smrg fi 10309659607e0Smrg 10310e4da38afSmrg save_ifs=$IFS; IFS='~' 10311fc27e79cSmrg for cmd in $cmds; do 10312e4da38afSmrg IFS=$sp$nl 10313fc27e79cSmrg eval cmd=\"$cmd\" 10314e4da38afSmrg IFS=$save_ifs 10315e4da38afSmrg $opt_quiet || { 10316370b807fSmrg func_quote_arg expand,pretty "$cmd" 10317370b807fSmrg eval "func_echo $func_quote_arg_result" 10318fc27e79cSmrg } 10319fc27e79cSmrg $opt_dry_run || eval "$cmd" || { 10320fc27e79cSmrg lt_exit=$? 10321659607e0Smrg 10322fc27e79cSmrg # Restore the uninstalled library and exit 10323e4da38afSmrg if test relink = "$opt_mode"; then 10324fc27e79cSmrg ( cd "$output_objdir" && \ 10325fc27e79cSmrg $RM "${realname}T" && \ 10326fc27e79cSmrg $MV "${realname}U" "$realname" ) 10327fc27e79cSmrg fi 10328fc27e79cSmrg 10329fc27e79cSmrg exit $lt_exit 10330fc27e79cSmrg } 10331fc27e79cSmrg done 10332e4da38afSmrg IFS=$save_ifs 10333fc27e79cSmrg 10334fc27e79cSmrg # Restore the uninstalled library and exit 10335e4da38afSmrg if test relink = "$opt_mode"; then 10336fc27e79cSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10337fc27e79cSmrg 10338fc27e79cSmrg if test -n "$convenience"; then 10339fc27e79cSmrg if test -z "$whole_archive_flag_spec"; then 10340fc27e79cSmrg func_show_eval '${RM}r "$gentop"' 10341659607e0Smrg fi 10342659607e0Smrg fi 10343659607e0Smrg 10344fc27e79cSmrg exit $EXIT_SUCCESS 10345fc27e79cSmrg fi 10346659607e0Smrg 10347fc27e79cSmrg # Create links to the real library. 10348fc27e79cSmrg for linkname in $linknames; do 10349fc27e79cSmrg if test "$realname" != "$linkname"; then 10350fc27e79cSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10351fc27e79cSmrg fi 10352fc27e79cSmrg done 10353fc27e79cSmrg 10354fc27e79cSmrg # If -module or -export-dynamic was specified, set the dlname. 10355e4da38afSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 10356fc27e79cSmrg # On all known operating systems, these are identical. 10357e4da38afSmrg dlname=$soname 10358fc27e79cSmrg fi 10359fc27e79cSmrg fi 10360fc27e79cSmrg ;; 10361fc27e79cSmrg 10362fc27e79cSmrg obj) 10363e4da38afSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10364e4da38afSmrg func_warning "'-dlopen' is ignored for objects" 10365fc27e79cSmrg fi 10366fc27e79cSmrg 10367fc27e79cSmrg case " $deplibs" in 10368fc27e79cSmrg *\ -l* | *\ -L*) 10369e4da38afSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 10370fc27e79cSmrg esac 10371fc27e79cSmrg 10372fc27e79cSmrg test -n "$rpath" && \ 10373e4da38afSmrg func_warning "'-rpath' is ignored for objects" 10374fc27e79cSmrg 10375fc27e79cSmrg test -n "$xrpath" && \ 10376e4da38afSmrg func_warning "'-R' is ignored for objects" 10377fc27e79cSmrg 10378fc27e79cSmrg test -n "$vinfo" && \ 10379e4da38afSmrg func_warning "'-version-info' is ignored for objects" 10380fc27e79cSmrg 10381fc27e79cSmrg test -n "$release" && \ 10382e4da38afSmrg func_warning "'-release' is ignored for objects" 10383fc27e79cSmrg 10384fc27e79cSmrg case $output in 10385fc27e79cSmrg *.lo) 10386fc27e79cSmrg test -n "$objs$old_deplibs" && \ 10387e4da38afSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10388fc27e79cSmrg 10389fc27e79cSmrg libobj=$output 10390fc27e79cSmrg func_lo2o "$libobj" 10391fc27e79cSmrg obj=$func_lo2o_result 10392fc27e79cSmrg ;; 10393fc27e79cSmrg *) 10394fc27e79cSmrg libobj= 10395e4da38afSmrg obj=$output 10396fc27e79cSmrg ;; 10397fc27e79cSmrg esac 10398fc27e79cSmrg 10399fc27e79cSmrg # Delete the old objects. 10400fc27e79cSmrg $opt_dry_run || $RM $obj $libobj 10401fc27e79cSmrg 10402fc27e79cSmrg # Objects from convenience libraries. This assumes 10403fc27e79cSmrg # single-version convenience libraries. Whenever we create 10404fc27e79cSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 10405fc27e79cSmrg # the extraction. 10406fc27e79cSmrg reload_conv_objs= 10407fc27e79cSmrg gentop= 10408e4da38afSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 10409e4da38afSmrg # whole_archive_flag_spec and hope we can get by with turning comma 10410e4da38afSmrg # into space. 10411e4da38afSmrg case $reload_cmds in 10412e4da38afSmrg *\$LD[\ \$]*) wl= ;; 10413e4da38afSmrg esac 10414fc27e79cSmrg if test -n "$convenience"; then 10415fc27e79cSmrg if test -n "$whole_archive_flag_spec"; then 10416fc27e79cSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10417e4da38afSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10418e4da38afSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10419fc27e79cSmrg else 10420e4da38afSmrg gentop=$output_objdir/${obj}x 10421bd3a1963Smrg func_append generated " $gentop" 10422fc27e79cSmrg 10423fc27e79cSmrg func_extract_archives $gentop $convenience 10424fc27e79cSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10425fc27e79cSmrg fi 10426fc27e79cSmrg fi 10427659607e0Smrg 10428bd3a1963Smrg # If we're not building shared, we need to use non_pic_objs 10429e4da38afSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10430bd3a1963Smrg 10431fc27e79cSmrg # Create the old-style object. 10432e4da38afSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10433659607e0Smrg 10434e4da38afSmrg output=$obj 10435fc27e79cSmrg func_execute_cmds "$reload_cmds" 'exit $?' 10436659607e0Smrg 10437fc27e79cSmrg # Exit if we aren't doing a library object file. 10438fc27e79cSmrg if test -z "$libobj"; then 10439fc27e79cSmrg if test -n "$gentop"; then 10440fc27e79cSmrg func_show_eval '${RM}r "$gentop"' 10441fc27e79cSmrg fi 10442659607e0Smrg 10443fc27e79cSmrg exit $EXIT_SUCCESS 10444fc27e79cSmrg fi 10445659607e0Smrg 10446e4da38afSmrg test yes = "$build_libtool_libs" || { 10447fc27e79cSmrg if test -n "$gentop"; then 10448fc27e79cSmrg func_show_eval '${RM}r "$gentop"' 10449fc27e79cSmrg fi 10450659607e0Smrg 10451fc27e79cSmrg # Create an invalid libtool object if no PIC, so that we don't 10452fc27e79cSmrg # accidentally link it into a program. 10453fc27e79cSmrg # $show "echo timestamp > $libobj" 10454fc27e79cSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10455fc27e79cSmrg exit $EXIT_SUCCESS 10456e4da38afSmrg } 10457659607e0Smrg 10458e4da38afSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10459fc27e79cSmrg # Only do commands if we really have different PIC objects. 10460fc27e79cSmrg reload_objs="$libobjs $reload_conv_objs" 10461e4da38afSmrg output=$libobj 10462fc27e79cSmrg func_execute_cmds "$reload_cmds" 'exit $?' 10463659607e0Smrg fi 10464659607e0Smrg 10465fc27e79cSmrg if test -n "$gentop"; then 10466fc27e79cSmrg func_show_eval '${RM}r "$gentop"' 10467fc27e79cSmrg fi 10468659607e0Smrg 10469fc27e79cSmrg exit $EXIT_SUCCESS 10470fc27e79cSmrg ;; 10471659607e0Smrg 10472fc27e79cSmrg prog) 10473fc27e79cSmrg case $host in 10474fc27e79cSmrg *cygwin*) func_stripname '' '.exe' "$output" 10475fc27e79cSmrg output=$func_stripname_result.exe;; 10476659607e0Smrg esac 10477fc27e79cSmrg test -n "$vinfo" && \ 10478e4da38afSmrg func_warning "'-version-info' is ignored for programs" 10479659607e0Smrg 10480fc27e79cSmrg test -n "$release" && \ 10481e4da38afSmrg func_warning "'-release' is ignored for programs" 10482659607e0Smrg 10483e4da38afSmrg $preload \ 10484e4da38afSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10485e4da38afSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10486659607e0Smrg 10487fc27e79cSmrg case $host in 10488fc27e79cSmrg *-*-rhapsody* | *-*-darwin1.[012]) 10489fc27e79cSmrg # On Rhapsody replace the C library is the System framework 10490bd3a1963Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10491bd3a1963Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10492659607e0Smrg ;; 10493659607e0Smrg esac 10494659607e0Smrg 10495fc27e79cSmrg case $host in 10496fc27e79cSmrg *-*-darwin*) 10497fc27e79cSmrg # Don't allow lazy linking, it breaks C++ global constructors 10498fc27e79cSmrg # But is supposedly fixed on 10.4 or later (yay!). 10499e4da38afSmrg if test CXX = "$tagname"; then 10500fc27e79cSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10501fc27e79cSmrg 10.[0123]) 10502e4da38afSmrg func_append compile_command " $wl-bind_at_load" 10503e4da38afSmrg func_append finalize_command " $wl-bind_at_load" 10504fc27e79cSmrg ;; 10505fc27e79cSmrg esac 10506fc27e79cSmrg fi 10507fc27e79cSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10508bd3a1963Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10509bd3a1963Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10510659607e0Smrg ;; 10511659607e0Smrg esac 10512659607e0Smrg 10513659607e0Smrg 10514fc27e79cSmrg # move library search paths that coincide with paths to not yet 10515fc27e79cSmrg # installed libraries to the beginning of the library search list 10516fc27e79cSmrg new_libs= 10517fc27e79cSmrg for path in $notinst_path; do 10518fc27e79cSmrg case " $new_libs " in 10519fc27e79cSmrg *" -L$path/$objdir "*) ;; 10520659607e0Smrg *) 10521fc27e79cSmrg case " $compile_deplibs " in 10522fc27e79cSmrg *" -L$path/$objdir "*) 10523bd3a1963Smrg func_append new_libs " -L$path/$objdir" ;; 10524fc27e79cSmrg esac 10525659607e0Smrg ;; 10526659607e0Smrg esac 10527659607e0Smrg done 10528fc27e79cSmrg for deplib in $compile_deplibs; do 10529fc27e79cSmrg case $deplib in 10530fc27e79cSmrg -L*) 10531fc27e79cSmrg case " $new_libs " in 10532fc27e79cSmrg *" $deplib "*) ;; 10533bd3a1963Smrg *) func_append new_libs " $deplib" ;; 10534fc27e79cSmrg esac 10535fc27e79cSmrg ;; 10536bd3a1963Smrg *) func_append new_libs " $deplib" ;; 10537fc27e79cSmrg esac 10538fc27e79cSmrg done 10539e4da38afSmrg compile_deplibs=$new_libs 10540659607e0Smrg 10541659607e0Smrg 10542bd3a1963Smrg func_append compile_command " $compile_deplibs" 10543bd3a1963Smrg func_append finalize_command " $finalize_deplibs" 10544659607e0Smrg 10545fc27e79cSmrg if test -n "$rpath$xrpath"; then 10546fc27e79cSmrg # If the user specified any rpath flags, then add them. 10547fc27e79cSmrg for libdir in $rpath $xrpath; do 10548fc27e79cSmrg # This is the magic to use -rpath. 10549fc27e79cSmrg case "$finalize_rpath " in 10550fc27e79cSmrg *" $libdir "*) ;; 10551bd3a1963Smrg *) func_append finalize_rpath " $libdir" ;; 10552fc27e79cSmrg esac 10553fc27e79cSmrg done 10554fc27e79cSmrg fi 10555659607e0Smrg 10556fc27e79cSmrg # Now hardcode the library paths 10557fc27e79cSmrg rpath= 10558fc27e79cSmrg hardcode_libdirs= 10559fc27e79cSmrg for libdir in $compile_rpath $finalize_rpath; do 10560fc27e79cSmrg if test -n "$hardcode_libdir_flag_spec"; then 10561fc27e79cSmrg if test -n "$hardcode_libdir_separator"; then 10562fc27e79cSmrg if test -z "$hardcode_libdirs"; then 10563e4da38afSmrg hardcode_libdirs=$libdir 10564fc27e79cSmrg else 10565fc27e79cSmrg # Just accumulate the unique libdirs. 10566fc27e79cSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10567fc27e79cSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10568fc27e79cSmrg ;; 10569fc27e79cSmrg *) 10570bd3a1963Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10571fc27e79cSmrg ;; 10572fc27e79cSmrg esac 10573fc27e79cSmrg fi 10574fc27e79cSmrg else 10575fc27e79cSmrg eval flag=\"$hardcode_libdir_flag_spec\" 10576bd3a1963Smrg func_append rpath " $flag" 10577fc27e79cSmrg fi 10578fc27e79cSmrg elif test -n "$runpath_var"; then 10579fc27e79cSmrg case "$perm_rpath " in 10580659607e0Smrg *" $libdir "*) ;; 10581bd3a1963Smrg *) func_append perm_rpath " $libdir" ;; 10582659607e0Smrg esac 10583fc27e79cSmrg fi 10584fc27e79cSmrg case $host in 10585fc27e79cSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10586e4da38afSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10587fc27e79cSmrg case :$dllsearchpath: in 10588fc27e79cSmrg *":$libdir:"*) ;; 10589fc27e79cSmrg ::) dllsearchpath=$libdir;; 10590bd3a1963Smrg *) func_append dllsearchpath ":$libdir";; 10591fc27e79cSmrg esac 10592fc27e79cSmrg case :$dllsearchpath: in 10593fc27e79cSmrg *":$testbindir:"*) ;; 10594fc27e79cSmrg ::) dllsearchpath=$testbindir;; 10595bd3a1963Smrg *) func_append dllsearchpath ":$testbindir";; 10596fc27e79cSmrg esac 10597fc27e79cSmrg ;; 10598fc27e79cSmrg esac 10599fc27e79cSmrg done 10600fc27e79cSmrg # Substitute the hardcoded libdirs into the rpath. 10601fc27e79cSmrg if test -n "$hardcode_libdir_separator" && 10602fc27e79cSmrg test -n "$hardcode_libdirs"; then 10603e4da38afSmrg libdir=$hardcode_libdirs 10604fc27e79cSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 10605fc27e79cSmrg fi 10606e4da38afSmrg compile_rpath=$rpath 10607fc27e79cSmrg 10608fc27e79cSmrg rpath= 10609fc27e79cSmrg hardcode_libdirs= 10610fc27e79cSmrg for libdir in $finalize_rpath; do 10611fc27e79cSmrg if test -n "$hardcode_libdir_flag_spec"; then 10612fc27e79cSmrg if test -n "$hardcode_libdir_separator"; then 10613fc27e79cSmrg if test -z "$hardcode_libdirs"; then 10614e4da38afSmrg hardcode_libdirs=$libdir 10615fc27e79cSmrg else 10616fc27e79cSmrg # Just accumulate the unique libdirs. 10617fc27e79cSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10618fc27e79cSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10619fc27e79cSmrg ;; 10620fc27e79cSmrg *) 10621bd3a1963Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10622fc27e79cSmrg ;; 10623fc27e79cSmrg esac 10624fc27e79cSmrg fi 10625fc27e79cSmrg else 10626fc27e79cSmrg eval flag=\"$hardcode_libdir_flag_spec\" 10627bd3a1963Smrg func_append rpath " $flag" 10628fc27e79cSmrg fi 10629fc27e79cSmrg elif test -n "$runpath_var"; then 10630fc27e79cSmrg case "$finalize_perm_rpath " in 10631659607e0Smrg *" $libdir "*) ;; 10632bd3a1963Smrg *) func_append finalize_perm_rpath " $libdir" ;; 10633659607e0Smrg esac 10634659607e0Smrg fi 10635fc27e79cSmrg done 10636fc27e79cSmrg # Substitute the hardcoded libdirs into the rpath. 10637fc27e79cSmrg if test -n "$hardcode_libdir_separator" && 10638fc27e79cSmrg test -n "$hardcode_libdirs"; then 10639e4da38afSmrg libdir=$hardcode_libdirs 10640fc27e79cSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 10641fc27e79cSmrg fi 10642e4da38afSmrg finalize_rpath=$rpath 10643659607e0Smrg 10644e4da38afSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10645fc27e79cSmrg # Transform all the library objects into standard objects. 10646bd3a1963Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10647bd3a1963Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10648fc27e79cSmrg fi 10649659607e0Smrg 10650e4da38afSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10651659607e0Smrg 10652fc27e79cSmrg # template prelinking step 10653fc27e79cSmrg if test -n "$prelink_cmds"; then 10654fc27e79cSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 10655fc27e79cSmrg fi 10656659607e0Smrg 10657e4da38afSmrg wrappers_required=: 10658fc27e79cSmrg case $host in 10659bd3a1963Smrg *cegcc* | *mingw32ce*) 10660bd3a1963Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10661e4da38afSmrg wrappers_required=false 10662bd3a1963Smrg ;; 10663fc27e79cSmrg *cygwin* | *mingw* ) 10664e4da38afSmrg test yes = "$build_libtool_libs" || wrappers_required=false 10665fc27e79cSmrg ;; 10666fc27e79cSmrg *) 10667e4da38afSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10668e4da38afSmrg wrappers_required=false 10669fc27e79cSmrg fi 10670fc27e79cSmrg ;; 10671fc27e79cSmrg esac 10672e4da38afSmrg $wrappers_required || { 10673fc27e79cSmrg # Replace the output file specification. 10674bd3a1963Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10675e4da38afSmrg link_command=$compile_command$compile_rpath 10676659607e0Smrg 10677fc27e79cSmrg # We have no uninstalled library dependencies, so finalize right now. 10678fc27e79cSmrg exit_status=0 10679fc27e79cSmrg func_show_eval "$link_command" 'exit_status=$?' 10680659607e0Smrg 10681bd3a1963Smrg if test -n "$postlink_cmds"; then 10682bd3a1963Smrg func_to_tool_file "$output" 10683bd3a1963Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10684bd3a1963Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10685bd3a1963Smrg fi 10686bd3a1963Smrg 10687fc27e79cSmrg # Delete the generated files. 10688e4da38afSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 10689e4da38afSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10690fc27e79cSmrg fi 10691659607e0Smrg 10692fc27e79cSmrg exit $exit_status 10693e4da38afSmrg } 10694659607e0Smrg 10695fc27e79cSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10696fc27e79cSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10697fc27e79cSmrg fi 10698fc27e79cSmrg if test -n "$finalize_shlibpath"; then 10699fc27e79cSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10700fc27e79cSmrg fi 10701659607e0Smrg 10702fc27e79cSmrg compile_var= 10703fc27e79cSmrg finalize_var= 10704fc27e79cSmrg if test -n "$runpath_var"; then 10705fc27e79cSmrg if test -n "$perm_rpath"; then 10706fc27e79cSmrg # We should set the runpath_var. 10707fc27e79cSmrg rpath= 10708fc27e79cSmrg for dir in $perm_rpath; do 10709bd3a1963Smrg func_append rpath "$dir:" 10710659607e0Smrg done 10711fc27e79cSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10712659607e0Smrg fi 10713fc27e79cSmrg if test -n "$finalize_perm_rpath"; then 10714fc27e79cSmrg # We should set the runpath_var. 10715fc27e79cSmrg rpath= 10716fc27e79cSmrg for dir in $finalize_perm_rpath; do 10717bd3a1963Smrg func_append rpath "$dir:" 10718fc27e79cSmrg done 10719fc27e79cSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10720fc27e79cSmrg fi 10721fc27e79cSmrg fi 10722659607e0Smrg 10723e4da38afSmrg if test yes = "$no_install"; then 10724fc27e79cSmrg # We don't need to create a wrapper script. 10725e4da38afSmrg link_command=$compile_var$compile_command$compile_rpath 10726fc27e79cSmrg # Replace the output file specification. 10727bd3a1963Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10728fc27e79cSmrg # Delete the old output file. 10729fc27e79cSmrg $opt_dry_run || $RM $output 10730fc27e79cSmrg # Link the executable and exit 10731fc27e79cSmrg func_show_eval "$link_command" 'exit $?' 10732bd3a1963Smrg 10733bd3a1963Smrg if test -n "$postlink_cmds"; then 10734bd3a1963Smrg func_to_tool_file "$output" 10735bd3a1963Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10736bd3a1963Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10737bd3a1963Smrg fi 10738bd3a1963Smrg 10739fc27e79cSmrg exit $EXIT_SUCCESS 10740fc27e79cSmrg fi 10741659607e0Smrg 10742e4da38afSmrg case $hardcode_action,$fast_install in 10743e4da38afSmrg relink,*) 10744e4da38afSmrg # Fast installation is not supported 10745e4da38afSmrg link_command=$compile_var$compile_command$compile_rpath 10746e4da38afSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10747659607e0Smrg 10748e4da38afSmrg func_warning "this platform does not like uninstalled shared libraries" 10749e4da38afSmrg func_warning "'$output' will be relinked during installation" 10750e4da38afSmrg ;; 10751e4da38afSmrg *,yes) 10752e4da38afSmrg link_command=$finalize_var$compile_command$finalize_rpath 10753e4da38afSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10754e4da38afSmrg ;; 10755e4da38afSmrg *,no) 10756e4da38afSmrg link_command=$compile_var$compile_command$compile_rpath 10757e4da38afSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10758e4da38afSmrg ;; 10759e4da38afSmrg *,needless) 10760e4da38afSmrg link_command=$finalize_var$compile_command$finalize_rpath 10761e4da38afSmrg relink_command= 10762e4da38afSmrg ;; 10763e4da38afSmrg esac 10764659607e0Smrg 10765fc27e79cSmrg # Replace the output file specification. 10766bd3a1963Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10767659607e0Smrg 10768fc27e79cSmrg # Delete the old output files. 10769fc27e79cSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10770659607e0Smrg 10771fc27e79cSmrg func_show_eval "$link_command" 'exit $?' 10772659607e0Smrg 10773bd3a1963Smrg if test -n "$postlink_cmds"; then 10774bd3a1963Smrg func_to_tool_file "$output_objdir/$outputname" 10775bd3a1963Smrg 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'` 10776bd3a1963Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10777bd3a1963Smrg fi 10778bd3a1963Smrg 10779fc27e79cSmrg # Now create the wrapper script. 10780fc27e79cSmrg func_verbose "creating $output" 10781659607e0Smrg 10782fc27e79cSmrg # Quote the relink command for shipping. 10783fc27e79cSmrg if test -n "$relink_command"; then 10784fc27e79cSmrg # Preserve any variables that may affect compiler behavior 10785fc27e79cSmrg for var in $variables_saved_for_relink; do 10786fc27e79cSmrg if eval test -z \"\${$var+set}\"; then 10787fc27e79cSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10788fc27e79cSmrg elif eval var_value=\$$var; test -z "$var_value"; then 10789fc27e79cSmrg relink_command="$var=; export $var; $relink_command" 10790fc27e79cSmrg else 10791370b807fSmrg func_quote_arg pretty "$var_value" 10792370b807fSmrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 10793fc27e79cSmrg fi 10794fc27e79cSmrg done 10795370b807fSmrg func_quote eval cd "`pwd`" 10796370b807fSmrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 10797370b807fSmrg relink_command=$func_quote_arg_unquoted_result 10798fc27e79cSmrg fi 10799659607e0Smrg 10800fc27e79cSmrg # Only actually do things if not in dry run mode. 10801fc27e79cSmrg $opt_dry_run || { 10802fc27e79cSmrg # win32 will think the script is a binary if it has 10803fc27e79cSmrg # a .exe suffix, so we strip it off here. 10804fc27e79cSmrg case $output in 10805fc27e79cSmrg *.exe) func_stripname '' '.exe' "$output" 10806fc27e79cSmrg output=$func_stripname_result ;; 10807fc27e79cSmrg esac 10808fc27e79cSmrg # test for cygwin because mv fails w/o .exe extensions 10809659607e0Smrg case $host in 10810fc27e79cSmrg *cygwin*) 10811fc27e79cSmrg exeext=.exe 10812fc27e79cSmrg func_stripname '' '.exe' "$outputname" 10813fc27e79cSmrg outputname=$func_stripname_result ;; 10814fc27e79cSmrg *) exeext= ;; 10815659607e0Smrg esac 10816fc27e79cSmrg case $host in 10817fc27e79cSmrg *cygwin* | *mingw* ) 10818fc27e79cSmrg func_dirname_and_basename "$output" "" "." 10819fc27e79cSmrg output_name=$func_basename_result 10820fc27e79cSmrg output_path=$func_dirname_result 10821e4da38afSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 10822e4da38afSmrg cwrapper=$output_path/$output_name.exe 10823fc27e79cSmrg $RM $cwrappersource $cwrapper 10824fc27e79cSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10825fc27e79cSmrg 10826fc27e79cSmrg func_emit_cwrapperexe_src > $cwrappersource 10827fc27e79cSmrg 10828fc27e79cSmrg # The wrapper executable is built using the $host compiler, 10829fc27e79cSmrg # because it contains $host paths and files. If cross- 10830fc27e79cSmrg # compiling, it, like the target executable, must be 10831fc27e79cSmrg # executed on the $host or under an emulation environment. 10832fc27e79cSmrg $opt_dry_run || { 10833fc27e79cSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10834fc27e79cSmrg $STRIP $cwrapper 10835fc27e79cSmrg } 10836659607e0Smrg 10837fc27e79cSmrg # Now, create the wrapper script for func_source use: 10838fc27e79cSmrg func_ltwrapper_scriptname $cwrapper 10839fc27e79cSmrg $RM $func_ltwrapper_scriptname_result 10840fc27e79cSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10841fc27e79cSmrg $opt_dry_run || { 10842fc27e79cSmrg # note: this script will not be executed, so do not chmod. 10843e4da38afSmrg if test "x$build" = "x$host"; then 10844fc27e79cSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10845659607e0Smrg else 10846fc27e79cSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10847659607e0Smrg fi 10848fc27e79cSmrg } 10849fc27e79cSmrg ;; 10850fc27e79cSmrg * ) 10851fc27e79cSmrg $RM $output 10852fc27e79cSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10853659607e0Smrg 10854fc27e79cSmrg func_emit_wrapper no > $output 10855fc27e79cSmrg chmod +x $output 10856659607e0Smrg ;; 10857659607e0Smrg esac 10858fc27e79cSmrg } 10859fc27e79cSmrg exit $EXIT_SUCCESS 10860fc27e79cSmrg ;; 10861fc27e79cSmrg esac 10862659607e0Smrg 10863fc27e79cSmrg # See if we need to build an old-fashioned archive. 10864fc27e79cSmrg for oldlib in $oldlibs; do 10865659607e0Smrg 10866e4da38afSmrg case $build_libtool_libs in 10867e4da38afSmrg convenience) 10868e4da38afSmrg oldobjs="$libobjs_save $symfileobj" 10869e4da38afSmrg addlibs=$convenience 10870fc27e79cSmrg build_libtool_libs=no 10871e4da38afSmrg ;; 10872e4da38afSmrg module) 10873e4da38afSmrg oldobjs=$libobjs_save 10874e4da38afSmrg addlibs=$old_convenience 10875e4da38afSmrg build_libtool_libs=no 10876e4da38afSmrg ;; 10877e4da38afSmrg *) 10878fc27e79cSmrg oldobjs="$old_deplibs $non_pic_objects" 10879e4da38afSmrg $preload && test -f "$symfileobj" \ 10880e4da38afSmrg && func_append oldobjs " $symfileobj" 10881e4da38afSmrg addlibs=$old_convenience 10882e4da38afSmrg ;; 10883e4da38afSmrg esac 10884659607e0Smrg 10885fc27e79cSmrg if test -n "$addlibs"; then 10886e4da38afSmrg gentop=$output_objdir/${outputname}x 10887bd3a1963Smrg func_append generated " $gentop" 10888659607e0Smrg 10889fc27e79cSmrg func_extract_archives $gentop $addlibs 10890bd3a1963Smrg func_append oldobjs " $func_extract_archives_result" 10891fc27e79cSmrg fi 10892659607e0Smrg 10893fc27e79cSmrg # Do each command in the archive commands. 10894e4da38afSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10895fc27e79cSmrg cmds=$old_archive_from_new_cmds 10896fc27e79cSmrg else 10897659607e0Smrg 10898fc27e79cSmrg # Add any objects from preloaded convenience libraries 10899fc27e79cSmrg if test -n "$dlprefiles"; then 10900e4da38afSmrg gentop=$output_objdir/${outputname}x 10901bd3a1963Smrg func_append generated " $gentop" 10902659607e0Smrg 10903fc27e79cSmrg func_extract_archives $gentop $dlprefiles 10904bd3a1963Smrg func_append oldobjs " $func_extract_archives_result" 10905fc27e79cSmrg fi 10906659607e0Smrg 10907fc27e79cSmrg # POSIX demands no paths to be encoded in archives. We have 10908fc27e79cSmrg # to avoid creating archives with duplicate basenames if we 10909fc27e79cSmrg # might have to extract them afterwards, e.g., when creating a 10910fc27e79cSmrg # static archive out of a convenience library, or when linking 10911fc27e79cSmrg # the entirety of a libtool archive into another (currently 10912fc27e79cSmrg # not supported by libtool). 10913fc27e79cSmrg if (for obj in $oldobjs 10914fc27e79cSmrg do 10915fc27e79cSmrg func_basename "$obj" 10916fc27e79cSmrg $ECHO "$func_basename_result" 10917fc27e79cSmrg done | sort | sort -uc >/dev/null 2>&1); then 10918fc27e79cSmrg : 10919fc27e79cSmrg else 10920bd3a1963Smrg echo "copying selected object files to avoid basename conflicts..." 10921e4da38afSmrg gentop=$output_objdir/${outputname}x 10922bd3a1963Smrg func_append generated " $gentop" 10923fc27e79cSmrg func_mkdir_p "$gentop" 10924fc27e79cSmrg save_oldobjs=$oldobjs 10925fc27e79cSmrg oldobjs= 10926fc27e79cSmrg counter=1 10927fc27e79cSmrg for obj in $save_oldobjs 10928fc27e79cSmrg do 10929fc27e79cSmrg func_basename "$obj" 10930e4da38afSmrg objbase=$func_basename_result 10931fc27e79cSmrg case " $oldobjs " in 10932fc27e79cSmrg " ") oldobjs=$obj ;; 10933fc27e79cSmrg *[\ /]"$objbase "*) 10934fc27e79cSmrg while :; do 10935fc27e79cSmrg # Make sure we don't pick an alternate name that also 10936fc27e79cSmrg # overlaps. 10937fc27e79cSmrg newobj=lt$counter-$objbase 10938fc27e79cSmrg func_arith $counter + 1 10939fc27e79cSmrg counter=$func_arith_result 10940fc27e79cSmrg case " $oldobjs " in 10941fc27e79cSmrg *[\ /]"$newobj "*) ;; 10942fc27e79cSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10943fc27e79cSmrg esac 10944fc27e79cSmrg done 10945fc27e79cSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10946bd3a1963Smrg func_append oldobjs " $gentop/$newobj" 10947fc27e79cSmrg ;; 10948bd3a1963Smrg *) func_append oldobjs " $obj" ;; 10949fc27e79cSmrg esac 10950659607e0Smrg done 10951659607e0Smrg fi 10952a73597f9Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10953a73597f9Smrg tool_oldlib=$func_to_tool_file_result 10954fc27e79cSmrg eval cmds=\"$old_archive_cmds\" 10955659607e0Smrg 10956fc27e79cSmrg func_len " $cmds" 10957fc27e79cSmrg len=$func_len_result 10958fc27e79cSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10959fc27e79cSmrg cmds=$old_archive_cmds 10960bd3a1963Smrg elif test -n "$archiver_list_spec"; then 10961bd3a1963Smrg func_verbose "using command file archive linking..." 10962bd3a1963Smrg for obj in $oldobjs 10963bd3a1963Smrg do 10964bd3a1963Smrg func_to_tool_file "$obj" 10965bd3a1963Smrg $ECHO "$func_to_tool_file_result" 10966bd3a1963Smrg done > $output_objdir/$libname.libcmd 10967bd3a1963Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 10968bd3a1963Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10969bd3a1963Smrg cmds=$old_archive_cmds 10970fc27e79cSmrg else 10971fc27e79cSmrg # the command line is too long to link in one step, link in parts 10972fc27e79cSmrg func_verbose "using piecewise archive linking..." 10973fc27e79cSmrg save_RANLIB=$RANLIB 10974fc27e79cSmrg RANLIB=: 10975fc27e79cSmrg objlist= 10976fc27e79cSmrg concat_cmds= 10977fc27e79cSmrg save_oldobjs=$oldobjs 10978fc27e79cSmrg oldobjs= 10979fc27e79cSmrg # Is there a better way of finding the last object in the list? 10980fc27e79cSmrg for obj in $save_oldobjs 10981fc27e79cSmrg do 10982fc27e79cSmrg last_oldobj=$obj 10983fc27e79cSmrg done 10984fc27e79cSmrg eval test_cmds=\"$old_archive_cmds\" 10985fc27e79cSmrg func_len " $test_cmds" 10986fc27e79cSmrg len0=$func_len_result 10987fc27e79cSmrg len=$len0 10988fc27e79cSmrg for obj in $save_oldobjs 10989fc27e79cSmrg do 10990fc27e79cSmrg func_len " $obj" 10991fc27e79cSmrg func_arith $len + $func_len_result 10992fc27e79cSmrg len=$func_arith_result 10993fc27e79cSmrg func_append objlist " $obj" 10994fc27e79cSmrg if test "$len" -lt "$max_cmd_len"; then 10995fc27e79cSmrg : 10996fc27e79cSmrg else 10997fc27e79cSmrg # the above command should be used before it gets too long 10998fc27e79cSmrg oldobjs=$objlist 10999e4da38afSmrg if test "$obj" = "$last_oldobj"; then 11000fc27e79cSmrg RANLIB=$save_RANLIB 11001fc27e79cSmrg fi 11002fc27e79cSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 11003e4da38afSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 11004fc27e79cSmrg objlist= 11005fc27e79cSmrg len=$len0 11006fc27e79cSmrg fi 11007fc27e79cSmrg done 11008fc27e79cSmrg RANLIB=$save_RANLIB 11009fc27e79cSmrg oldobjs=$objlist 11010e4da38afSmrg if test -z "$oldobjs"; then 11011fc27e79cSmrg eval cmds=\"\$concat_cmds\" 11012fc27e79cSmrg else 11013fc27e79cSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 11014fc27e79cSmrg fi 11015fc27e79cSmrg fi 11016fc27e79cSmrg fi 11017fc27e79cSmrg func_execute_cmds "$cmds" 'exit $?' 11018659607e0Smrg done 11019659607e0Smrg 11020fc27e79cSmrg test -n "$generated" && \ 11021fc27e79cSmrg func_show_eval "${RM}r$generated" 11022659607e0Smrg 11023fc27e79cSmrg # Now create the libtool archive. 11024fc27e79cSmrg case $output in 11025fc27e79cSmrg *.la) 11026fc27e79cSmrg old_library= 11027e4da38afSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 11028fc27e79cSmrg func_verbose "creating $output" 11029659607e0Smrg 11030fc27e79cSmrg # Preserve any variables that may affect compiler behavior 11031fc27e79cSmrg for var in $variables_saved_for_relink; do 11032fc27e79cSmrg if eval test -z \"\${$var+set}\"; then 11033fc27e79cSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 11034fc27e79cSmrg elif eval var_value=\$$var; test -z "$var_value"; then 11035fc27e79cSmrg relink_command="$var=; export $var; $relink_command" 11036659607e0Smrg else 11037370b807fSmrg func_quote_arg pretty,unquoted "$var_value" 11038370b807fSmrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 11039659607e0Smrg fi 11040fc27e79cSmrg done 11041fc27e79cSmrg # Quote the link command for shipping. 11042370b807fSmrg func_quote eval cd "`pwd`" 11043370b807fSmrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 11044370b807fSmrg func_quote_arg pretty,unquoted "$relink_command" 11045370b807fSmrg relink_command=$func_quote_arg_unquoted_result 11046e4da38afSmrg if test yes = "$hardcode_automatic"; then 11047fc27e79cSmrg relink_command= 11048fc27e79cSmrg fi 11049659607e0Smrg 11050fc27e79cSmrg # Only create the output if not a dry run. 11051fc27e79cSmrg $opt_dry_run || { 11052fc27e79cSmrg for installed in no yes; do 11053e4da38afSmrg if test yes = "$installed"; then 11054fc27e79cSmrg if test -z "$install_libdir"; then 11055fc27e79cSmrg break 11056fc27e79cSmrg fi 11057e4da38afSmrg output=$output_objdir/${outputname}i 11058fc27e79cSmrg # Replace all uninstalled libtool libraries with the installed ones 11059fc27e79cSmrg newdependency_libs= 11060fc27e79cSmrg for deplib in $dependency_libs; do 11061fc27e79cSmrg case $deplib in 11062fc27e79cSmrg *.la) 11063fc27e79cSmrg func_basename "$deplib" 11064e4da38afSmrg name=$func_basename_result 11065a73597f9Smrg func_resolve_sysroot "$deplib" 11066e4da38afSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 11067fc27e79cSmrg test -z "$libdir" && \ 11068e4da38afSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 11069bd3a1963Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 11070bd3a1963Smrg ;; 11071bd3a1963Smrg -L*) 11072bd3a1963Smrg func_stripname -L '' "$deplib" 11073bd3a1963Smrg func_replace_sysroot "$func_stripname_result" 11074bd3a1963Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 11075fc27e79cSmrg ;; 11076bd3a1963Smrg -R*) 11077bd3a1963Smrg func_stripname -R '' "$deplib" 11078bd3a1963Smrg func_replace_sysroot "$func_stripname_result" 11079bd3a1963Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 11080bd3a1963Smrg ;; 11081bd3a1963Smrg *) func_append newdependency_libs " $deplib" ;; 11082fc27e79cSmrg esac 11083fc27e79cSmrg done 11084e4da38afSmrg dependency_libs=$newdependency_libs 11085fc27e79cSmrg newdlfiles= 11086fc27e79cSmrg 11087fc27e79cSmrg for lib in $dlfiles; do 11088fc27e79cSmrg case $lib in 11089fc27e79cSmrg *.la) 11090fc27e79cSmrg func_basename "$lib" 11091e4da38afSmrg name=$func_basename_result 11092e4da38afSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11093fc27e79cSmrg test -z "$libdir" && \ 11094e4da38afSmrg func_fatal_error "'$lib' is not a valid libtool archive" 11095bd3a1963Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 11096fc27e79cSmrg ;; 11097bd3a1963Smrg *) func_append newdlfiles " $lib" ;; 11098fc27e79cSmrg esac 11099fc27e79cSmrg done 11100e4da38afSmrg dlfiles=$newdlfiles 11101fc27e79cSmrg newdlprefiles= 11102fc27e79cSmrg for lib in $dlprefiles; do 11103fc27e79cSmrg case $lib in 11104fc27e79cSmrg *.la) 11105fc27e79cSmrg # Only pass preopened files to the pseudo-archive (for 11106fc27e79cSmrg # eventual linking with the app. that links it) if we 11107fc27e79cSmrg # didn't already link the preopened objects directly into 11108fc27e79cSmrg # the library: 11109fc27e79cSmrg func_basename "$lib" 11110e4da38afSmrg name=$func_basename_result 11111e4da38afSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11112fc27e79cSmrg test -z "$libdir" && \ 11113e4da38afSmrg func_fatal_error "'$lib' is not a valid libtool archive" 11114bd3a1963Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 11115fc27e79cSmrg ;; 11116fc27e79cSmrg esac 11117fc27e79cSmrg done 11118e4da38afSmrg dlprefiles=$newdlprefiles 11119fc27e79cSmrg else 11120fc27e79cSmrg newdlfiles= 11121fc27e79cSmrg for lib in $dlfiles; do 11122fc27e79cSmrg case $lib in 11123e4da38afSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11124fc27e79cSmrg *) abs=`pwd`"/$lib" ;; 11125fc27e79cSmrg esac 11126bd3a1963Smrg func_append newdlfiles " $abs" 11127fc27e79cSmrg done 11128e4da38afSmrg dlfiles=$newdlfiles 11129fc27e79cSmrg newdlprefiles= 11130fc27e79cSmrg for lib in $dlprefiles; do 11131fc27e79cSmrg case $lib in 11132e4da38afSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11133fc27e79cSmrg *) abs=`pwd`"/$lib" ;; 11134fc27e79cSmrg esac 11135bd3a1963Smrg func_append newdlprefiles " $abs" 11136fc27e79cSmrg done 11137e4da38afSmrg dlprefiles=$newdlprefiles 11138fc27e79cSmrg fi 11139fc27e79cSmrg $RM $output 11140fc27e79cSmrg # place dlname in correct position for cygwin 11141bd3a1963Smrg # In fact, it would be nice if we could use this code for all target 11142bd3a1963Smrg # systems that can't hard-code library paths into their executables 11143bd3a1963Smrg # and that have no shared library path variable independent of PATH, 11144bd3a1963Smrg # but it turns out we can't easily determine that from inspecting 11145bd3a1963Smrg # libtool variables, so we have to hard-code the OSs to which it 11146bd3a1963Smrg # applies here; at the moment, that means platforms that use the PE 11147bd3a1963Smrg # object format with DLL files. See the long comment at the top of 11148bd3a1963Smrg # tests/bindir.at for full details. 11149fc27e79cSmrg tdlname=$dlname 11150fc27e79cSmrg case $host,$output,$installed,$module,$dlname in 11151bd3a1963Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 11152bd3a1963Smrg # If a -bindir argument was supplied, place the dll there. 11153e4da38afSmrg if test -n "$bindir"; then 11154bd3a1963Smrg func_relative_path "$install_libdir" "$bindir" 11155e4da38afSmrg tdlname=$func_relative_path_result/$dlname 11156bd3a1963Smrg else 11157bd3a1963Smrg # Otherwise fall back on heuristic. 11158bd3a1963Smrg tdlname=../bin/$dlname 11159bd3a1963Smrg fi 11160bd3a1963Smrg ;; 11161fc27e79cSmrg esac 11162fc27e79cSmrg $ECHO > $output "\ 11163fc27e79cSmrg# $outputname - a libtool library file 11164e4da38afSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 11165fc27e79cSmrg# 11166fc27e79cSmrg# Please DO NOT delete this file! 11167fc27e79cSmrg# It is necessary for linking the library. 11168659607e0Smrg 11169fc27e79cSmrg# The name that we can dlopen(3). 11170fc27e79cSmrgdlname='$tdlname' 11171659607e0Smrg 11172fc27e79cSmrg# Names of this library. 11173fc27e79cSmrglibrary_names='$library_names' 11174659607e0Smrg 11175fc27e79cSmrg# The name of the static archive. 11176fc27e79cSmrgold_library='$old_library' 11177659607e0Smrg 11178e4da38afSmrg# Linker flags that cannot go in dependency_libs. 11179fc27e79cSmrginherited_linker_flags='$new_inherited_linker_flags' 11180659607e0Smrg 11181fc27e79cSmrg# Libraries that this one depends upon. 11182fc27e79cSmrgdependency_libs='$dependency_libs' 11183659607e0Smrg 11184fc27e79cSmrg# Names of additional weak libraries provided by this library 11185fc27e79cSmrgweak_library_names='$weak_libs' 11186659607e0Smrg 11187fc27e79cSmrg# Version information for $libname. 11188fc27e79cSmrgcurrent=$current 11189fc27e79cSmrgage=$age 11190fc27e79cSmrgrevision=$revision 11191659607e0Smrg 11192fc27e79cSmrg# Is this an already installed library? 11193fc27e79cSmrginstalled=$installed 11194659607e0Smrg 11195fc27e79cSmrg# Should we warn about portability when linking against -modules? 11196fc27e79cSmrgshouldnotlink=$module 11197659607e0Smrg 11198fc27e79cSmrg# Files to dlopen/dlpreopen 11199fc27e79cSmrgdlopen='$dlfiles' 11200fc27e79cSmrgdlpreopen='$dlprefiles' 11201659607e0Smrg 11202fc27e79cSmrg# Directory that this library needs to be installed in: 11203fc27e79cSmrglibdir='$install_libdir'" 11204e4da38afSmrg if test no,yes = "$installed,$need_relink"; then 11205fc27e79cSmrg $ECHO >> $output "\ 11206fc27e79cSmrgrelink_command=\"$relink_command\"" 11207fc27e79cSmrg fi 11208fc27e79cSmrg done 11209fc27e79cSmrg } 11210659607e0Smrg 11211fc27e79cSmrg # Do a symbolic link so that the libtool archive can be found in 11212fc27e79cSmrg # LD_LIBRARY_PATH before the program is installed. 11213fc27e79cSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 11214fc27e79cSmrg ;; 11215fc27e79cSmrg esac 11216fc27e79cSmrg exit $EXIT_SUCCESS 11217fc27e79cSmrg} 11218659607e0Smrg 11219e4da38afSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 11220e4da38afSmrg func_mode_link ${1+"$@"} 11221e4da38afSmrgfi 11222659607e0Smrg 11223659607e0Smrg 11224fc27e79cSmrg# func_mode_uninstall arg... 11225fc27e79cSmrgfunc_mode_uninstall () 11226fc27e79cSmrg{ 11227e4da38afSmrg $debug_cmd 11228e4da38afSmrg 11229e4da38afSmrg RM=$nonopt 11230659607e0Smrg files= 11231e4da38afSmrg rmforce=false 11232659607e0Smrg exit_status=0 11233659607e0Smrg 11234659607e0Smrg # This variable tells wrapper scripts just to set variables rather 11235659607e0Smrg # than running their programs. 11236e4da38afSmrg libtool_install_magic=$magic 11237659607e0Smrg 11238659607e0Smrg for arg 11239659607e0Smrg do 11240659607e0Smrg case $arg in 11241e4da38afSmrg -f) func_append RM " $arg"; rmforce=: ;; 11242bd3a1963Smrg -*) func_append RM " $arg" ;; 11243bd3a1963Smrg *) func_append files " $arg" ;; 11244659607e0Smrg esac 11245659607e0Smrg done 11246659607e0Smrg 11247fc27e79cSmrg test -z "$RM" && \ 11248fc27e79cSmrg func_fatal_help "you must specify an RM program" 11249659607e0Smrg 11250659607e0Smrg rmdirs= 11251659607e0Smrg 11252659607e0Smrg for file in $files; do 11253fc27e79cSmrg func_dirname "$file" "" "." 11254e4da38afSmrg dir=$func_dirname_result 11255e4da38afSmrg if test . = "$dir"; then 11256e4da38afSmrg odir=$objdir 11257659607e0Smrg else 11258e4da38afSmrg odir=$dir/$objdir 11259659607e0Smrg fi 11260fc27e79cSmrg func_basename "$file" 11261e4da38afSmrg name=$func_basename_result 11262e4da38afSmrg test uninstall = "$opt_mode" && odir=$dir 11263659607e0Smrg 11264bd3a1963Smrg # Remember odir for removal later, being careful to avoid duplicates 11265e4da38afSmrg if test clean = "$opt_mode"; then 11266659607e0Smrg case " $rmdirs " in 11267bd3a1963Smrg *" $odir "*) ;; 11268bd3a1963Smrg *) func_append rmdirs " $odir" ;; 11269659607e0Smrg esac 11270659607e0Smrg fi 11271659607e0Smrg 11272659607e0Smrg # Don't error if the file doesn't exist and rm -f was used. 11273fc27e79cSmrg if { test -L "$file"; } >/dev/null 2>&1 || 11274fc27e79cSmrg { test -h "$file"; } >/dev/null 2>&1 || 11275fc27e79cSmrg test -f "$file"; then 11276659607e0Smrg : 11277659607e0Smrg elif test -d "$file"; then 11278659607e0Smrg exit_status=1 11279659607e0Smrg continue 11280e4da38afSmrg elif $rmforce; then 11281659607e0Smrg continue 11282659607e0Smrg fi 11283659607e0Smrg 11284e4da38afSmrg rmfiles=$file 11285659607e0Smrg 11286659607e0Smrg case $name in 11287659607e0Smrg *.la) 11288659607e0Smrg # Possibly a libtool archive, so verify it. 11289fc27e79cSmrg if func_lalib_p "$file"; then 11290fc27e79cSmrg func_source $dir/$name 11291659607e0Smrg 11292659607e0Smrg # Delete the libtool libraries and symlinks. 11293659607e0Smrg for n in $library_names; do 11294bd3a1963Smrg func_append rmfiles " $odir/$n" 11295659607e0Smrg done 11296bd3a1963Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11297659607e0Smrg 11298e4da38afSmrg case $opt_mode in 11299659607e0Smrg clean) 11300bd3a1963Smrg case " $library_names " in 11301659607e0Smrg *" $dlname "*) ;; 11302bd3a1963Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11303659607e0Smrg esac 11304bd3a1963Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11305659607e0Smrg ;; 11306659607e0Smrg uninstall) 11307659607e0Smrg if test -n "$library_names"; then 11308659607e0Smrg # Do each command in the postuninstall commands. 11309e4da38afSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11310659607e0Smrg fi 11311659607e0Smrg 11312659607e0Smrg if test -n "$old_library"; then 11313659607e0Smrg # Do each command in the old_postuninstall commands. 11314e4da38afSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11315659607e0Smrg fi 11316659607e0Smrg # FIXME: should reinstall the best remaining shared library. 11317659607e0Smrg ;; 11318659607e0Smrg esac 11319659607e0Smrg fi 11320659607e0Smrg ;; 11321659607e0Smrg 11322659607e0Smrg *.lo) 11323659607e0Smrg # Possibly a libtool object, so verify it. 11324fc27e79cSmrg if func_lalib_p "$file"; then 11325659607e0Smrg 11326659607e0Smrg # Read the .lo file 11327fc27e79cSmrg func_source $dir/$name 11328659607e0Smrg 11329659607e0Smrg # Add PIC object to the list of files to remove. 11330e4da38afSmrg if test -n "$pic_object" && test none != "$pic_object"; then 11331bd3a1963Smrg func_append rmfiles " $dir/$pic_object" 11332659607e0Smrg fi 11333659607e0Smrg 11334659607e0Smrg # Add non-PIC object to the list of files to remove. 11335e4da38afSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11336bd3a1963Smrg func_append rmfiles " $dir/$non_pic_object" 11337659607e0Smrg fi 11338659607e0Smrg fi 11339659607e0Smrg ;; 11340659607e0Smrg 11341659607e0Smrg *) 11342e4da38afSmrg if test clean = "$opt_mode"; then 11343659607e0Smrg noexename=$name 11344659607e0Smrg case $file in 11345659607e0Smrg *.exe) 11346fc27e79cSmrg func_stripname '' '.exe' "$file" 11347fc27e79cSmrg file=$func_stripname_result 11348fc27e79cSmrg func_stripname '' '.exe' "$name" 11349fc27e79cSmrg noexename=$func_stripname_result 11350659607e0Smrg # $file with .exe has already been added to rmfiles, 11351659607e0Smrg # add $file without .exe 11352bd3a1963Smrg func_append rmfiles " $file" 11353659607e0Smrg ;; 11354659607e0Smrg esac 11355659607e0Smrg # Do a test to see if this is a libtool program. 11356fc27e79cSmrg if func_ltwrapper_p "$file"; then 11357fc27e79cSmrg if func_ltwrapper_executable_p "$file"; then 11358fc27e79cSmrg func_ltwrapper_scriptname "$file" 11359fc27e79cSmrg relink_command= 11360fc27e79cSmrg func_source $func_ltwrapper_scriptname_result 11361bd3a1963Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11362fc27e79cSmrg else 11363fc27e79cSmrg relink_command= 11364fc27e79cSmrg func_source $dir/$noexename 11365fc27e79cSmrg fi 11366659607e0Smrg 11367659607e0Smrg # note $name still contains .exe if it was in $file originally 11368659607e0Smrg # as does the version of $file that was added into $rmfiles 11369e4da38afSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11370e4da38afSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 11371bd3a1963Smrg func_append rmfiles " $odir/lt-$name" 11372659607e0Smrg fi 11373e4da38afSmrg if test "X$noexename" != "X$name"; then 11374e4da38afSmrg func_append rmfiles " $odir/lt-$noexename.c" 11375659607e0Smrg fi 11376659607e0Smrg fi 11377659607e0Smrg fi 11378659607e0Smrg ;; 11379659607e0Smrg esac 11380fc27e79cSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11381659607e0Smrg done 11382659607e0Smrg 11383e4da38afSmrg # Try to remove the $objdir's in the directories where we deleted files 11384659607e0Smrg for dir in $rmdirs; do 11385659607e0Smrg if test -d "$dir"; then 11386fc27e79cSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11387659607e0Smrg fi 11388659607e0Smrg done 11389659607e0Smrg 11390659607e0Smrg exit $exit_status 11391fc27e79cSmrg} 11392659607e0Smrg 11393e4da38afSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11394e4da38afSmrg func_mode_uninstall ${1+"$@"} 11395e4da38afSmrgfi 11396659607e0Smrg 11397bd3a1963Smrgtest -z "$opt_mode" && { 11398e4da38afSmrg help=$generic_help 11399fc27e79cSmrg func_fatal_help "you must specify a MODE" 11400fc27e79cSmrg} 11401fc27e79cSmrg 11402fc27e79cSmrgtest -z "$exec_cmd" && \ 11403e4da38afSmrg func_fatal_help "invalid operation mode '$opt_mode'" 11404659607e0Smrg 11405659607e0Smrgif test -n "$exec_cmd"; then 11406fc27e79cSmrg eval exec "$exec_cmd" 11407659607e0Smrg exit $EXIT_FAILURE 11408659607e0Smrgfi 11409659607e0Smrg 11410fc27e79cSmrgexit $exit_status 11411659607e0Smrg 11412659607e0Smrg 11413659607e0Smrg# The TAGs below are defined such that we never get into a situation 11414e4da38afSmrg# where we disable both kinds of libraries. Given conflicting 11415659607e0Smrg# choices, we go for a static library, that is the most portable, 11416659607e0Smrg# since we can't tell whether shared libraries were disabled because 11417659607e0Smrg# the user asked for that or because the platform doesn't support 11418659607e0Smrg# them. This is particularly important on AIX, because we don't 11419659607e0Smrg# support having both static and shared libraries enabled at the same 11420659607e0Smrg# time on that platform, so we default to a shared-only configuration. 11421659607e0Smrg# If a disable-shared tag is given, we'll fallback to a static-only 11422659607e0Smrg# configuration. But we'll never go from static-only to shared-only. 11423659607e0Smrg 11424659607e0Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11425fc27e79cSmrgbuild_libtool_libs=no 11426fc27e79cSmrgbuild_old_libs=yes 11427659607e0Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 11428659607e0Smrg 11429659607e0Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11430fc27e79cSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11431659607e0Smrg# ### END LIBTOOL TAG CONFIG: disable-static 11432659607e0Smrg 11433659607e0Smrg# Local Variables: 11434659607e0Smrg# mode:shell-script 11435659607e0Smrg# sh-indentation:2 11436659607e0Smrg# End: 11437