1d5637ae9Smrg#! /usr/bin/env sh 2b312a94cSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3d5637ae9Smrg## by inline-source v2019-02-19.15 465eef222Smrg 5d5637ae9Smrg# libtool (GNU libtool) 2.4.7 6b312a94cSmrg# Provide generalized library-building support services. 765eef222Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 865eef222Smrg 9d5637ae9Smrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 1065eef222Smrg# This is free software; see the source for copying conditions. There is NO 1165eef222Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1265eef222Smrg 1365eef222Smrg# GNU Libtool is free software; you can redistribute it and/or modify 14ef981d24Smrg# it under the terms of the GNU General Public License as published by 15ef981d24Smrg# the Free Software Foundation; either version 2 of the License, or 16ef981d24Smrg# (at your option) any later version. 17ef981d24Smrg# 1865eef222Smrg# As a special exception to the GNU General Public License, 1965eef222Smrg# if you distribute this file as part of a program or library that 2065eef222Smrg# is built using GNU Libtool, you may include this file under the 2165eef222Smrg# same distribution terms that you use for the rest of that program. 2265eef222Smrg# 2365eef222Smrg# GNU Libtool is distributed in the hope that it will be useful, but 24ef981d24Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25ef981d24Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26ef981d24Smrg# General Public License for more details. 27ef981d24Smrg# 28ef981d24Smrg# You should have received a copy of the GNU General Public License 29b312a94cSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 3065eef222Smrg 3165eef222Smrg 3256957a04SmrgPROGRAM=libtool 3365eef222SmrgPACKAGE=libtool 34d5637ae9SmrgVERSION=2.4.7 35d5637ae9Smrgpackage_revision=2.4.7 3665eef222Smrg 37b312a94cSmrg 38b312a94cSmrg## ------ ## 39b312a94cSmrg## Usage. ## 40b312a94cSmrg## ------ ## 41b312a94cSmrg 42b312a94cSmrg# Run './libtool --help' for help with using this script from the 43b312a94cSmrg# command line. 44b312a94cSmrg 45b312a94cSmrg 46b312a94cSmrg## ------------------------------- ## 47b312a94cSmrg## User overridable command paths. ## 48b312a94cSmrg## ------------------------------- ## 49b312a94cSmrg 50b312a94cSmrg# After configure completes, it has a better idea of some of the 51b312a94cSmrg# shell tools we need than the defaults used by the functions shared 52b312a94cSmrg# with bootstrap, so set those here where they can still be over- 53b312a94cSmrg# ridden by the user, but otherwise take precedence. 54b312a94cSmrg 55b312a94cSmrg: ${AUTOCONF="autoconf"} 56b312a94cSmrg: ${AUTOMAKE="automake"} 57b312a94cSmrg 58b312a94cSmrg 59b312a94cSmrg## -------------------------- ## 60b312a94cSmrg## Source external libraries. ## 61b312a94cSmrg## -------------------------- ## 62b312a94cSmrg 63b312a94cSmrg# Much of our low-level functionality needs to be sourced from external 64b312a94cSmrg# libraries, which are installed to $pkgauxdir. 65b312a94cSmrg 66b312a94cSmrg# Set a version string for this script. 67d5637ae9Smrgscriptversion=2019-02-19.15; # UTC 68b312a94cSmrg 69b312a94cSmrg# General shell script boiler plate, and helper functions. 70b312a94cSmrg# Written by Gary V. Vaughan, 2004 71b312a94cSmrg 72d5637ae9Smrg# This is free software. There is NO warranty; not even for 73d5637ae9Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 74d5637ae9Smrg# 75d5637ae9Smrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 76d5637ae9Smrg# 77d5637ae9Smrg# This file is dual licensed under the terms of the MIT license 78d5637ae9Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 79d5637ae9Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 80d5637ae9Smrg# these licenses when using or redistributing this software or any of 81d5637ae9Smrg# the files within it. See the URLs above, or the file `LICENSE` 82d5637ae9Smrg# included in the Bootstrap distribution for the full license texts. 83b312a94cSmrg 84d5637ae9Smrg# Please report bugs or propose patches to: 85d5637ae9Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 86b312a94cSmrg 87b312a94cSmrg 88b312a94cSmrg## ------ ## 89b312a94cSmrg## Usage. ## 90b312a94cSmrg## ------ ## 91b312a94cSmrg 92b312a94cSmrg# Evaluate this file near the top of your script to gain access to 93b312a94cSmrg# the functions and variables defined here: 94b312a94cSmrg# 95b312a94cSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 96b312a94cSmrg# 97b312a94cSmrg# If you need to override any of the default environment variable 98b312a94cSmrg# settings, do that before evaluating this file. 99b312a94cSmrg 100b312a94cSmrg 101b312a94cSmrg## -------------------- ## 102b312a94cSmrg## Shell normalisation. ## 103b312a94cSmrg## -------------------- ## 104b312a94cSmrg 105b312a94cSmrg# Some shells need a little help to be as Bourne compatible as possible. 106b312a94cSmrg# Before doing anything else, make sure all that help has been provided! 107b312a94cSmrg 108b312a94cSmrgDUALCASE=1; export DUALCASE # for MKS sh 109b312a94cSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 11065eef222Smrg emulate sh 11165eef222Smrg NULLCMD=: 112b312a94cSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 11365eef222Smrg # is contrary to our usage. Disable this feature. 11465eef222Smrg alias -g '${1+"$@"}'='"$@"' 11565eef222Smrg setopt NO_GLOB_SUBST 11665eef222Smrgelse 117b312a94cSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 11865eef222Smrgfi 11956957a04Smrg 120b312a94cSmrg# NLS nuisances: We save the old values in case they are required later. 121b312a94cSmrg_G_user_locale= 122b312a94cSmrg_G_safe_locale= 123b312a94cSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 12465eef222Smrgdo 125b312a94cSmrg eval "if test set = \"\${$_G_var+set}\"; then 126b312a94cSmrg save_$_G_var=\$$_G_var 127b312a94cSmrg $_G_var=C 128b312a94cSmrg export $_G_var 129b312a94cSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 130b312a94cSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 13165eef222Smrg fi" 13265eef222Smrgdone 133d5637ae9Smrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 134d5637ae9Smrg# in case the environment reset is needed later and the $save_* variant is not 135d5637ae9Smrg# defined (see the code above). 136d5637ae9SmrgLC_ALL=C 137d5637ae9SmrgLANGUAGE=C 138d5637ae9Smrgexport LANGUAGE LC_ALL 13965eef222Smrg 140b312a94cSmrg# Make sure IFS has a sensible default 141b312a94cSmrgsp=' ' 142b312a94cSmrgnl=' 143b312a94cSmrg' 144b312a94cSmrgIFS="$sp $nl" 145b312a94cSmrg 146b312a94cSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 147b312a94cSmrgif test "${PATH_SEPARATOR+set}" != set; then 148b312a94cSmrg PATH_SEPARATOR=: 149b312a94cSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 150b312a94cSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 151b312a94cSmrg PATH_SEPARATOR=';' 152b312a94cSmrg } 153b312a94cSmrgfi 15465eef222Smrg 15565eef222Smrg 156d5637ae9Smrg# func_unset VAR 157d5637ae9Smrg# -------------- 158d5637ae9Smrg# Portably unset VAR. 159d5637ae9Smrg# In some shells, an 'unset VAR' statement leaves a non-zero return 160d5637ae9Smrg# status if VAR is already unset, which might be problematic if the 161d5637ae9Smrg# statement is used at the end of a function (thus poisoning its return 162d5637ae9Smrg# value) or when 'set -e' is active (causing even a spurious abort of 163d5637ae9Smrg# the script in this case). 164d5637ae9Smrgfunc_unset () 165d5637ae9Smrg{ 166d5637ae9Smrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 167d5637ae9Smrg} 168d5637ae9Smrg 169d5637ae9Smrg 170d5637ae9Smrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 171d5637ae9Smrgfunc_unset CDPATH 172d5637ae9Smrg 173d5637ae9Smrg# Make sure ${,E,F}GREP behave sanely. 174d5637ae9Smrgfunc_unset GREP_OPTIONS 175d5637ae9Smrg 17665eef222Smrg 177b312a94cSmrg## ------------------------- ## 178b312a94cSmrg## Locate command utilities. ## 179b312a94cSmrg## ------------------------- ## 180b312a94cSmrg 181b312a94cSmrg 182b312a94cSmrg# func_executable_p FILE 183b312a94cSmrg# ---------------------- 184b312a94cSmrg# Check that FILE is an executable regular file. 185b312a94cSmrgfunc_executable_p () 186b312a94cSmrg{ 187b312a94cSmrg test -f "$1" && test -x "$1" 188b312a94cSmrg} 189b312a94cSmrg 190b312a94cSmrg 191b312a94cSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 192b312a94cSmrg# -------------------------------------------- 193b312a94cSmrg# Search for either a program that responds to --version with output 194b312a94cSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 195b312a94cSmrg# trying all the directories in PATH with each of the elements of 196b312a94cSmrg# PROGS_LIST. 197b312a94cSmrg# 198b312a94cSmrg# CHECK_FUNC should accept the path to a candidate program, and 199b312a94cSmrg# set $func_check_prog_result if it truncates its output less than 200b312a94cSmrg# $_G_path_prog_max characters. 201b312a94cSmrgfunc_path_progs () 202b312a94cSmrg{ 203b312a94cSmrg _G_progs_list=$1 204b312a94cSmrg _G_check_func=$2 205b312a94cSmrg _G_PATH=${3-"$PATH"} 206b312a94cSmrg 207b312a94cSmrg _G_path_prog_max=0 208b312a94cSmrg _G_path_prog_found=false 209b312a94cSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 210b312a94cSmrg for _G_dir in $_G_PATH; do 211b312a94cSmrg IFS=$_G_save_IFS 212b312a94cSmrg test -z "$_G_dir" && _G_dir=. 213b312a94cSmrg for _G_prog_name in $_G_progs_list; do 214b312a94cSmrg for _exeext in '' .EXE; do 215b312a94cSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 216b312a94cSmrg func_executable_p "$_G_path_prog" || continue 217b312a94cSmrg case `"$_G_path_prog" --version 2>&1` in 218b312a94cSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 219b312a94cSmrg *) $_G_check_func $_G_path_prog 220b312a94cSmrg func_path_progs_result=$func_check_prog_result 221b312a94cSmrg ;; 222b312a94cSmrg esac 223b312a94cSmrg $_G_path_prog_found && break 3 224b312a94cSmrg done 225b312a94cSmrg done 226b312a94cSmrg done 227b312a94cSmrg IFS=$_G_save_IFS 228b312a94cSmrg test -z "$func_path_progs_result" && { 229b312a94cSmrg echo "no acceptable sed could be found in \$PATH" >&2 230b312a94cSmrg exit 1 231b312a94cSmrg } 232b312a94cSmrg} 233b312a94cSmrg 234b312a94cSmrg 235b312a94cSmrg# We want to be able to use the functions in this file before configure 236b312a94cSmrg# has figured out where the best binaries are kept, which means we have 237b312a94cSmrg# to search for them ourselves - except when the results are already set 238b312a94cSmrg# where we skip the searches. 239b312a94cSmrg 240b312a94cSmrg# Unless the user overrides by setting SED, search the path for either GNU 241b312a94cSmrg# sed, or the sed that truncates its output the least. 242b312a94cSmrgtest -z "$SED" && { 243b312a94cSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 244b312a94cSmrg for _G_i in 1 2 3 4 5 6 7; do 245b312a94cSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 246b312a94cSmrg done 247b312a94cSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 248b312a94cSmrg _G_sed_script= 249b312a94cSmrg 250b312a94cSmrg func_check_prog_sed () 251b312a94cSmrg { 252b312a94cSmrg _G_path_prog=$1 253b312a94cSmrg 254b312a94cSmrg _G_count=0 255b312a94cSmrg printf 0123456789 >conftest.in 256b312a94cSmrg while : 257b312a94cSmrg do 258b312a94cSmrg cat conftest.in conftest.in >conftest.tmp 259b312a94cSmrg mv conftest.tmp conftest.in 260b312a94cSmrg cp conftest.in conftest.nl 261b312a94cSmrg echo '' >> conftest.nl 262b312a94cSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 263b312a94cSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 264b312a94cSmrg _G_count=`expr $_G_count + 1` 265b312a94cSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 266b312a94cSmrg # Best one so far, save it but keep looking for a better one 267b312a94cSmrg func_check_prog_result=$_G_path_prog 268b312a94cSmrg _G_path_prog_max=$_G_count 269b312a94cSmrg fi 270b312a94cSmrg # 10*(2^10) chars as input seems more than enough 271b312a94cSmrg test 10 -lt "$_G_count" && break 272b312a94cSmrg done 273b312a94cSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 274b312a94cSmrg } 275b312a94cSmrg 276d5637ae9Smrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 277b312a94cSmrg rm -f conftest.sed 278b312a94cSmrg SED=$func_path_progs_result 279b312a94cSmrg} 280b312a94cSmrg 281b312a94cSmrg 282b312a94cSmrg# Unless the user overrides by setting GREP, search the path for either GNU 283b312a94cSmrg# grep, or the grep that truncates its output the least. 284b312a94cSmrgtest -z "$GREP" && { 285b312a94cSmrg func_check_prog_grep () 286b312a94cSmrg { 287b312a94cSmrg _G_path_prog=$1 288b312a94cSmrg 289b312a94cSmrg _G_count=0 290b312a94cSmrg _G_path_prog_max=0 291b312a94cSmrg printf 0123456789 >conftest.in 292b312a94cSmrg while : 293b312a94cSmrg do 294b312a94cSmrg cat conftest.in conftest.in >conftest.tmp 295b312a94cSmrg mv conftest.tmp conftest.in 296b312a94cSmrg cp conftest.in conftest.nl 297b312a94cSmrg echo 'GREP' >> conftest.nl 298b312a94cSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 299b312a94cSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 300b312a94cSmrg _G_count=`expr $_G_count + 1` 301b312a94cSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 302b312a94cSmrg # Best one so far, save it but keep looking for a better one 303b312a94cSmrg func_check_prog_result=$_G_path_prog 304b312a94cSmrg _G_path_prog_max=$_G_count 305b312a94cSmrg fi 306b312a94cSmrg # 10*(2^10) chars as input seems more than enough 307b312a94cSmrg test 10 -lt "$_G_count" && break 308b312a94cSmrg done 309b312a94cSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 310b312a94cSmrg } 311b312a94cSmrg 312d5637ae9Smrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 313b312a94cSmrg GREP=$func_path_progs_result 314b312a94cSmrg} 315b312a94cSmrg 316b312a94cSmrg 317b312a94cSmrg## ------------------------------- ## 318b312a94cSmrg## User overridable command paths. ## 319b312a94cSmrg## ------------------------------- ## 320b312a94cSmrg 321b312a94cSmrg# All uppercase variable names are used for environment variables. These 322b312a94cSmrg# variables can be overridden by the user before calling a script that 323b312a94cSmrg# uses them if a suitable command of that name is not already available 324b312a94cSmrg# in the command search PATH. 32565eef222Smrg 32665eef222Smrg: ${CP="cp -f"} 327b312a94cSmrg: ${ECHO="printf %s\n"} 328b312a94cSmrg: ${EGREP="$GREP -E"} 329b312a94cSmrg: ${FGREP="$GREP -F"} 33065eef222Smrg: ${LN_S="ln -s"} 33165eef222Smrg: ${MAKE="make"} 33265eef222Smrg: ${MKDIR="mkdir"} 33365eef222Smrg: ${MV="mv -f"} 33465eef222Smrg: ${RM="rm -f"} 33565eef222Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 33665eef222Smrg 33765eef222Smrg 338b312a94cSmrg## -------------------- ## 339b312a94cSmrg## Useful sed snippets. ## 340b312a94cSmrg## -------------------- ## 341200d7199Smrg 342b312a94cSmrgsed_dirname='s|/[^/]*$||' 343b312a94cSmrgsed_basename='s|^.*/||' 344200d7199Smrg 345b312a94cSmrg# Sed substitution that helps us do robust quoting. It backslashifies 346b312a94cSmrg# metacharacters that are still active within double-quoted strings. 347b312a94cSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 348200d7199Smrg 349b312a94cSmrg# Same as above, but do not quote variable references. 350b312a94cSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 351200d7199Smrg 352b312a94cSmrg# Sed substitution that turns a string into a regex matching for the 353b312a94cSmrg# string literally. 354b312a94cSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 355200d7199Smrg 356b312a94cSmrg# Sed substitution that converts a w32 file name or path 357b312a94cSmrg# that contains forward slashes, into one that contains 358b312a94cSmrg# (escaped) backslashes. A very naive implementation. 359b312a94cSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 360b312a94cSmrg 361b312a94cSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 362b312a94cSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 363b312a94cSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 364b312a94cSmrg# expansion. Since each input '\' is now two '\'s, look for any number 365b312a94cSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 366b312a94cSmrg_G_bs='\\' 367b312a94cSmrg_G_bs2='\\\\' 368b312a94cSmrg_G_bs4='\\\\\\\\' 369b312a94cSmrg_G_dollar='\$' 370b312a94cSmrgsed_double_backslash="\ 371b312a94cSmrg s/$_G_bs4/&\\ 372b312a94cSmrg/g 373b312a94cSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 374b312a94cSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 375b312a94cSmrg s/\n//g" 376200d7199Smrg 377d5637ae9Smrg# require_check_ifs_backslash 378d5637ae9Smrg# --------------------------- 379d5637ae9Smrg# Check if we can use backslash as IFS='\' separator, and set 380d5637ae9Smrg# $check_ifs_backshlash_broken to ':' or 'false'. 381d5637ae9Smrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 382d5637ae9Smrgfunc_require_check_ifs_backslash () 383d5637ae9Smrg{ 384d5637ae9Smrg _G_save_IFS=$IFS 385d5637ae9Smrg IFS='\' 386d5637ae9Smrg _G_check_ifs_backshlash='a\\b' 387d5637ae9Smrg for _G_i in $_G_check_ifs_backshlash 388d5637ae9Smrg do 389d5637ae9Smrg case $_G_i in 390d5637ae9Smrg a) 391d5637ae9Smrg check_ifs_backshlash_broken=false 392d5637ae9Smrg ;; 393d5637ae9Smrg '') 394d5637ae9Smrg break 395d5637ae9Smrg ;; 396d5637ae9Smrg *) 397d5637ae9Smrg check_ifs_backshlash_broken=: 398d5637ae9Smrg break 399d5637ae9Smrg ;; 400d5637ae9Smrg esac 401d5637ae9Smrg done 402d5637ae9Smrg IFS=$_G_save_IFS 403d5637ae9Smrg require_check_ifs_backslash=: 404d5637ae9Smrg} 405d5637ae9Smrg 40665eef222Smrg 407b312a94cSmrg## ----------------- ## 408b312a94cSmrg## Global variables. ## 409b312a94cSmrg## ----------------- ## 410ef981d24Smrg 411b312a94cSmrg# Except for the global variables explicitly listed below, the following 412b312a94cSmrg# functions in the '^func_' namespace, and the '^require_' namespace 413b312a94cSmrg# variables initialised in the 'Resource management' section, sourcing 414b312a94cSmrg# this file will not pollute your global namespace with anything 415b312a94cSmrg# else. There's no portable way to scope variables in Bourne shell 416b312a94cSmrg# though, so actually running these functions will sometimes place 417b312a94cSmrg# results into a variable named after the function, and often use 418b312a94cSmrg# temporary variables in the '^_G_' namespace. If you are careful to 419b312a94cSmrg# avoid using those namespaces casually in your sourcing script, things 420b312a94cSmrg# should continue to work as you expect. And, of course, you can freely 421b312a94cSmrg# overwrite any of the functions or variables defined here before 422b312a94cSmrg# calling anything to customize them. 42356957a04Smrg 424b312a94cSmrgEXIT_SUCCESS=0 425b312a94cSmrgEXIT_FAILURE=1 426b312a94cSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 427b312a94cSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 42856957a04Smrg 429b312a94cSmrg# Allow overriding, eg assuming that you follow the convention of 430b312a94cSmrg# putting '$debug_cmd' at the start of all your functions, you can get 431b312a94cSmrg# bash to show function call trace with: 432b312a94cSmrg# 433b312a94cSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 434b312a94cSmrgdebug_cmd=${debug_cmd-":"} 435b312a94cSmrgexit_cmd=: 43656957a04Smrg 437b312a94cSmrg# By convention, finish your script with: 438b312a94cSmrg# 439b312a94cSmrg# exit $exit_status 440b312a94cSmrg# 441b312a94cSmrg# so that you can set exit_status to non-zero if you want to indicate 442b312a94cSmrg# something went wrong during execution without actually bailing out at 443b312a94cSmrg# the point of failure. 444b312a94cSmrgexit_status=$EXIT_SUCCESS 44556957a04Smrg 446b312a94cSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 447b312a94cSmrg# is ksh but when the shell is invoked as "sh" and the current value of 448b312a94cSmrg# the _XPG environment variable is not equal to 1 (one), the special 449b312a94cSmrg# positional parameter $0, within a function call, is the name of the 450b312a94cSmrg# function. 451b312a94cSmrgprogpath=$0 452ef981d24Smrg 453b312a94cSmrg# The name of this program. 454b312a94cSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 455ef981d24Smrg 456b312a94cSmrg# Make sure we have an absolute progpath for reexecution: 45765eef222Smrgcase $progpath in 45865eef222Smrg [\\/]*|[A-Za-z]:\\*) ;; 45965eef222Smrg *[\\/]*) 460b312a94cSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 46165eef222Smrg progdir=`cd "$progdir" && pwd` 462b312a94cSmrg progpath=$progdir/$progname 46365eef222Smrg ;; 46465eef222Smrg *) 465b312a94cSmrg _G_IFS=$IFS 466b312a94cSmrg IFS=${PATH_SEPARATOR-:} 46765eef222Smrg for progdir in $PATH; do 468b312a94cSmrg IFS=$_G_IFS 46965eef222Smrg test -x "$progdir/$progname" && break 47065eef222Smrg done 471b312a94cSmrg IFS=$_G_IFS 47265eef222Smrg test -n "$progdir" || progdir=`pwd` 473b312a94cSmrg progpath=$progdir/$progname 47465eef222Smrg ;; 47565eef222Smrgesac 476ef981d24Smrg 47765eef222Smrg 478b312a94cSmrg## ----------------- ## 479b312a94cSmrg## Standard options. ## 480b312a94cSmrg## ----------------- ## 481200d7199Smrg 482b312a94cSmrg# The following options affect the operation of the functions defined 483b312a94cSmrg# below, and should be set appropriately depending on run-time para- 484b312a94cSmrg# meters passed on the command line. 48565eef222Smrg 48665eef222Smrgopt_dry_run=false 48765eef222Smrgopt_quiet=false 48865eef222Smrgopt_verbose=false 48965eef222Smrg 490b312a94cSmrg# Categories 'all' and 'none' are always available. Append any others 491b312a94cSmrg# you will pass as the first argument to func_warning from your own 492b312a94cSmrg# code. 493b312a94cSmrgwarning_categories= 494ef981d24Smrg 495b312a94cSmrg# By default, display warnings according to 'opt_warning_types'. Set 496b312a94cSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 497b312a94cSmrg# treat the next displayed warning as a fatal error. 498b312a94cSmrgwarning_func=func_warn_and_continue 499ef981d24Smrg 500b312a94cSmrg# Set to 'all' to display all warnings, 'none' to suppress all 501b312a94cSmrg# warnings, or a space delimited list of some subset of 502b312a94cSmrg# 'warning_categories' to display only the listed warnings. 503b312a94cSmrgopt_warning_types=all 504ef981d24Smrg 50556957a04Smrg 506b312a94cSmrg## -------------------- ## 507b312a94cSmrg## Resource management. ## 508b312a94cSmrg## -------------------- ## 509ef981d24Smrg 510b312a94cSmrg# This section contains definitions for functions that each ensure a 511b312a94cSmrg# particular resource (a file, or a non-empty configuration variable for 512b312a94cSmrg# example) is available, and if appropriate to extract default values 513b312a94cSmrg# from pertinent package files. Call them using their associated 514b312a94cSmrg# 'require_*' variable to ensure that they are executed, at most, once. 515b312a94cSmrg# 516b312a94cSmrg# It's entirely deliberate that calling these functions can set 517b312a94cSmrg# variables that don't obey the namespace limitations obeyed by the rest 518b312a94cSmrg# of this file, in order that that they be as useful as possible to 519b312a94cSmrg# callers. 520ef981d24Smrg 521ef981d24Smrg 522b312a94cSmrg# require_term_colors 523b312a94cSmrg# ------------------- 524b312a94cSmrg# Allow display of bold text on terminals that support it. 525b312a94cSmrgrequire_term_colors=func_require_term_colors 526b312a94cSmrgfunc_require_term_colors () 52765eef222Smrg{ 528b312a94cSmrg $debug_cmd 529b312a94cSmrg 530b312a94cSmrg test -t 1 && { 531b312a94cSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 532b312a94cSmrg # precedence, because most terminfo databases neglect to describe 533b312a94cSmrg # whether color sequences are supported. 534b312a94cSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 535b312a94cSmrg 536b312a94cSmrg if test 1 = "$USE_ANSI_COLORS"; then 537b312a94cSmrg # Standard ANSI escape sequences 538b312a94cSmrg tc_reset='[0m' 539b312a94cSmrg tc_bold='[1m'; tc_standout='[7m' 540b312a94cSmrg tc_red='[31m'; tc_green='[32m' 541b312a94cSmrg tc_blue='[34m'; tc_cyan='[36m' 542b312a94cSmrg else 543b312a94cSmrg # Otherwise trust the terminfo database after all. 544b312a94cSmrg test -n "`tput sgr0 2>/dev/null`" && { 545b312a94cSmrg tc_reset=`tput sgr0` 546b312a94cSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 547b312a94cSmrg tc_standout=$tc_bold 548b312a94cSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 549b312a94cSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 550b312a94cSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 551b312a94cSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 552b312a94cSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 553b312a94cSmrg } 554b312a94cSmrg fi 555b312a94cSmrg } 556ef981d24Smrg 557b312a94cSmrg require_term_colors=: 55865eef222Smrg} 559ef981d24Smrg 560ef981d24Smrg 561b312a94cSmrg## ----------------- ## 562b312a94cSmrg## Function library. ## 563b312a94cSmrg## ----------------- ## 564b312a94cSmrg 565b312a94cSmrg# This section contains a variety of useful functions to call in your 566b312a94cSmrg# scripts. Take note of the portable wrappers for features provided by 567b312a94cSmrg# some modern shells, which will fall back to slower equivalents on 568b312a94cSmrg# less featureful shells. 569b312a94cSmrg 570b312a94cSmrg 571b312a94cSmrg# func_append VAR VALUE 572b312a94cSmrg# --------------------- 573b312a94cSmrg# Append VALUE onto the existing contents of VAR. 574b312a94cSmrg 575b312a94cSmrg # We should try to minimise forks, especially on Windows where they are 576b312a94cSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 577b312a94cSmrg # being used: 578b312a94cSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 579b312a94cSmrg : ${_G_HAVE_ARITH_OP="yes"} 580b312a94cSmrg : ${_G_HAVE_XSI_OPS="yes"} 581b312a94cSmrg # The += operator was introduced in bash 3.1 582b312a94cSmrg case $BASH_VERSION in 583b312a94cSmrg [12].* | 3.0 | 3.0*) ;; 584b312a94cSmrg *) 585b312a94cSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 586b312a94cSmrg ;; 587b312a94cSmrg esac 588b312a94cSmrg fi 589b312a94cSmrg 590b312a94cSmrg # _G_HAVE_PLUSEQ_OP 591b312a94cSmrg # Can be empty, in which case the shell is probed, "yes" if += is 592b312a94cSmrg # useable or anything else if it does not work. 593b312a94cSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 594b312a94cSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 595b312a94cSmrg && _G_HAVE_PLUSEQ_OP=yes 596b312a94cSmrg 597b312a94cSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 598b312a94cSmrgthen 599b312a94cSmrg # This is an XSI compatible shell, allowing a faster implementation... 600b312a94cSmrg eval 'func_append () 601b312a94cSmrg { 602b312a94cSmrg $debug_cmd 603b312a94cSmrg 604b312a94cSmrg eval "$1+=\$2" 605b312a94cSmrg }' 606b312a94cSmrgelse 607b312a94cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 608b312a94cSmrg func_append () 609b312a94cSmrg { 610b312a94cSmrg $debug_cmd 611b312a94cSmrg 612b312a94cSmrg eval "$1=\$$1\$2" 613b312a94cSmrg } 614b312a94cSmrgfi 615b312a94cSmrg 616b312a94cSmrg 617b312a94cSmrg# func_append_quoted VAR VALUE 618b312a94cSmrg# ---------------------------- 619b312a94cSmrg# Quote VALUE and append to the end of shell variable VAR, separated 620b312a94cSmrg# by a space. 621b312a94cSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 622b312a94cSmrg eval 'func_append_quoted () 623b312a94cSmrg { 624b312a94cSmrg $debug_cmd 625b312a94cSmrg 626d5637ae9Smrg func_quote_arg pretty "$2" 627d5637ae9Smrg eval "$1+=\\ \$func_quote_arg_result" 628b312a94cSmrg }' 629b312a94cSmrgelse 630b312a94cSmrg func_append_quoted () 631b312a94cSmrg { 632b312a94cSmrg $debug_cmd 633b312a94cSmrg 634d5637ae9Smrg func_quote_arg pretty "$2" 635d5637ae9Smrg eval "$1=\$$1\\ \$func_quote_arg_result" 636b312a94cSmrg } 637b312a94cSmrgfi 638b312a94cSmrg 639b312a94cSmrg 640b312a94cSmrg# func_append_uniq VAR VALUE 641b312a94cSmrg# -------------------------- 642b312a94cSmrg# Append unique VALUE onto the existing contents of VAR, assuming 643b312a94cSmrg# entries are delimited by the first character of VALUE. For example: 644b312a94cSmrg# 645b312a94cSmrg# func_append_uniq options " --another-option option-argument" 646b312a94cSmrg# 647b312a94cSmrg# will only append to $options if " --another-option option-argument " 648b312a94cSmrg# is not already present somewhere in $options already (note spaces at 649b312a94cSmrg# each end implied by leading space in second argument). 650b312a94cSmrgfunc_append_uniq () 651b312a94cSmrg{ 652b312a94cSmrg $debug_cmd 653b312a94cSmrg 654b312a94cSmrg eval _G_current_value='`$ECHO $'$1'`' 655b312a94cSmrg _G_delim=`expr "$2" : '\(.\)'` 656b312a94cSmrg 657b312a94cSmrg case $_G_delim$_G_current_value$_G_delim in 658b312a94cSmrg *"$2$_G_delim"*) ;; 659b312a94cSmrg *) func_append "$@" ;; 660b312a94cSmrg esac 661b312a94cSmrg} 662b312a94cSmrg 663b312a94cSmrg 664b312a94cSmrg# func_arith TERM... 665b312a94cSmrg# ------------------ 666b312a94cSmrg# Set func_arith_result to the result of evaluating TERMs. 667b312a94cSmrg test -z "$_G_HAVE_ARITH_OP" \ 668b312a94cSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 669b312a94cSmrg && _G_HAVE_ARITH_OP=yes 670b312a94cSmrg 671b312a94cSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 672b312a94cSmrg eval 'func_arith () 673b312a94cSmrg { 674b312a94cSmrg $debug_cmd 675b312a94cSmrg 676b312a94cSmrg func_arith_result=$(( $* )) 677b312a94cSmrg }' 678b312a94cSmrgelse 679b312a94cSmrg func_arith () 680b312a94cSmrg { 681b312a94cSmrg $debug_cmd 682b312a94cSmrg 683b312a94cSmrg func_arith_result=`expr "$@"` 684b312a94cSmrg } 685b312a94cSmrgfi 686b312a94cSmrg 687b312a94cSmrg 688b312a94cSmrg# func_basename FILE 689b312a94cSmrg# ------------------ 690b312a94cSmrg# Set func_basename_result to FILE with everything up to and including 691b312a94cSmrg# the last / stripped. 692b312a94cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 693b312a94cSmrg # If this shell supports suffix pattern removal, then use it to avoid 694b312a94cSmrg # forking. Hide the definitions single quotes in case the shell chokes 695b312a94cSmrg # on unsupported syntax... 696b312a94cSmrg _b='func_basename_result=${1##*/}' 697b312a94cSmrg _d='case $1 in 698b312a94cSmrg */*) func_dirname_result=${1%/*}$2 ;; 699b312a94cSmrg * ) func_dirname_result=$3 ;; 700b312a94cSmrg esac' 701b312a94cSmrg 702b312a94cSmrgelse 703b312a94cSmrg # ...otherwise fall back to using sed. 704b312a94cSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 705b312a94cSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 706b312a94cSmrg if test "X$func_dirname_result" = "X$1"; then 707b312a94cSmrg func_dirname_result=$3 708b312a94cSmrg else 709b312a94cSmrg func_append func_dirname_result "$2" 710b312a94cSmrg fi' 711b312a94cSmrgfi 712b312a94cSmrg 713b312a94cSmrgeval 'func_basename () 714b312a94cSmrg{ 715b312a94cSmrg $debug_cmd 716b312a94cSmrg 717b312a94cSmrg '"$_b"' 718b312a94cSmrg}' 719b312a94cSmrg 720b312a94cSmrg 721b312a94cSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 722b312a94cSmrg# ------------------------------------------- 723b312a94cSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 724b312a94cSmrg# otherwise set result to NONDIR_REPLACEMENT. 725b312a94cSmrgeval 'func_dirname () 726b312a94cSmrg{ 727b312a94cSmrg $debug_cmd 728b312a94cSmrg 729b312a94cSmrg '"$_d"' 730b312a94cSmrg}' 731b312a94cSmrg 732b312a94cSmrg 733b312a94cSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 734b312a94cSmrg# -------------------------------------------------------- 735b312a94cSmrg# Perform func_basename and func_dirname in a single function 736b312a94cSmrg# call: 737b312a94cSmrg# dirname: Compute the dirname of FILE. If nonempty, 738b312a94cSmrg# add APPEND to the result, otherwise set result 739b312a94cSmrg# to NONDIR_REPLACEMENT. 740b312a94cSmrg# value returned in "$func_dirname_result" 741b312a94cSmrg# basename: Compute filename of FILE. 742b312a94cSmrg# value retuned in "$func_basename_result" 743b312a94cSmrg# For efficiency, we do not delegate to the functions above but instead 744b312a94cSmrg# duplicate the functionality here. 745b312a94cSmrgeval 'func_dirname_and_basename () 746b312a94cSmrg{ 747b312a94cSmrg $debug_cmd 748b312a94cSmrg 749b312a94cSmrg '"$_b"' 750b312a94cSmrg '"$_d"' 751b312a94cSmrg}' 752b312a94cSmrg 753b312a94cSmrg 754b312a94cSmrg# func_echo ARG... 755b312a94cSmrg# ---------------- 756b312a94cSmrg# Echo program name prefixed message. 757b312a94cSmrgfunc_echo () 758b312a94cSmrg{ 759b312a94cSmrg $debug_cmd 760b312a94cSmrg 761b312a94cSmrg _G_message=$* 762b312a94cSmrg 763b312a94cSmrg func_echo_IFS=$IFS 764b312a94cSmrg IFS=$nl 765b312a94cSmrg for _G_line in $_G_message; do 766b312a94cSmrg IFS=$func_echo_IFS 767b312a94cSmrg $ECHO "$progname: $_G_line" 768b312a94cSmrg done 769b312a94cSmrg IFS=$func_echo_IFS 770b312a94cSmrg} 771b312a94cSmrg 772b312a94cSmrg 773b312a94cSmrg# func_echo_all ARG... 774b312a94cSmrg# -------------------- 775b312a94cSmrg# Invoke $ECHO with all args, space-separated. 776b312a94cSmrgfunc_echo_all () 777b312a94cSmrg{ 778b312a94cSmrg $ECHO "$*" 779b312a94cSmrg} 780b312a94cSmrg 781b312a94cSmrg 782b312a94cSmrg# func_echo_infix_1 INFIX ARG... 783b312a94cSmrg# ------------------------------ 784b312a94cSmrg# Echo program name, followed by INFIX on the first line, with any 785b312a94cSmrg# additional lines not showing INFIX. 786b312a94cSmrgfunc_echo_infix_1 () 787b312a94cSmrg{ 788b312a94cSmrg $debug_cmd 789b312a94cSmrg 790b312a94cSmrg $require_term_colors 791b312a94cSmrg 792b312a94cSmrg _G_infix=$1; shift 793b312a94cSmrg _G_indent=$_G_infix 794b312a94cSmrg _G_prefix="$progname: $_G_infix: " 795b312a94cSmrg _G_message=$* 796b312a94cSmrg 797b312a94cSmrg # Strip color escape sequences before counting printable length 798b312a94cSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 799b312a94cSmrg do 800b312a94cSmrg test -n "$_G_tc" && { 801b312a94cSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 802b312a94cSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 803b312a94cSmrg } 804b312a94cSmrg done 805b312a94cSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 806b312a94cSmrg 807b312a94cSmrg func_echo_infix_1_IFS=$IFS 808b312a94cSmrg IFS=$nl 809b312a94cSmrg for _G_line in $_G_message; do 810b312a94cSmrg IFS=$func_echo_infix_1_IFS 811b312a94cSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 812b312a94cSmrg _G_prefix=$_G_indent 813b312a94cSmrg done 814b312a94cSmrg IFS=$func_echo_infix_1_IFS 815b312a94cSmrg} 816b312a94cSmrg 817b312a94cSmrg 818b312a94cSmrg# func_error ARG... 819b312a94cSmrg# ----------------- 820b312a94cSmrg# Echo program name prefixed message to standard error. 821b312a94cSmrgfunc_error () 822b312a94cSmrg{ 823b312a94cSmrg $debug_cmd 824b312a94cSmrg 825b312a94cSmrg $require_term_colors 826b312a94cSmrg 827b312a94cSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 828b312a94cSmrg} 829b312a94cSmrg 830b312a94cSmrg 831b312a94cSmrg# func_fatal_error ARG... 832b312a94cSmrg# ----------------------- 833b312a94cSmrg# Echo program name prefixed message to standard error, and exit. 834b312a94cSmrgfunc_fatal_error () 835b312a94cSmrg{ 836b312a94cSmrg $debug_cmd 837b312a94cSmrg 838b312a94cSmrg func_error "$*" 839b312a94cSmrg exit $EXIT_FAILURE 840b312a94cSmrg} 841b312a94cSmrg 842b312a94cSmrg 843b312a94cSmrg# func_grep EXPRESSION FILENAME 844b312a94cSmrg# ----------------------------- 84565eef222Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 84665eef222Smrgfunc_grep () 84765eef222Smrg{ 848b312a94cSmrg $debug_cmd 849b312a94cSmrg 85065eef222Smrg $GREP "$1" "$2" >/dev/null 2>&1 85165eef222Smrg} 85265eef222Smrg 85365eef222Smrg 854b312a94cSmrg# func_len STRING 855b312a94cSmrg# --------------- 856b312a94cSmrg# Set func_len_result to the length of STRING. STRING may not 857b312a94cSmrg# start with a hyphen. 858b312a94cSmrg test -z "$_G_HAVE_XSI_OPS" \ 859b312a94cSmrg && (eval 'x=a/b/c; 860b312a94cSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 861b312a94cSmrg && _G_HAVE_XSI_OPS=yes 862b312a94cSmrg 863b312a94cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 864b312a94cSmrg eval 'func_len () 865b312a94cSmrg { 866b312a94cSmrg $debug_cmd 867b312a94cSmrg 868b312a94cSmrg func_len_result=${#1} 869b312a94cSmrg }' 870b312a94cSmrgelse 871b312a94cSmrg func_len () 872b312a94cSmrg { 873b312a94cSmrg $debug_cmd 874b312a94cSmrg 875b312a94cSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 876b312a94cSmrg } 877b312a94cSmrgfi 878b312a94cSmrg 879b312a94cSmrg 880b312a94cSmrg# func_mkdir_p DIRECTORY-PATH 881b312a94cSmrg# --------------------------- 88265eef222Smrg# Make sure the entire path to DIRECTORY-PATH is available. 88365eef222Smrgfunc_mkdir_p () 88465eef222Smrg{ 885b312a94cSmrg $debug_cmd 886b312a94cSmrg 887b312a94cSmrg _G_directory_path=$1 888b312a94cSmrg _G_dir_list= 88965eef222Smrg 890b312a94cSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 89165eef222Smrg 892b312a94cSmrg # Protect directory names starting with '-' 893b312a94cSmrg case $_G_directory_path in 894b312a94cSmrg -*) _G_directory_path=./$_G_directory_path ;; 89565eef222Smrg esac 89665eef222Smrg 89765eef222Smrg # While some portion of DIR does not yet exist... 898b312a94cSmrg while test ! -d "$_G_directory_path"; do 89965eef222Smrg # ...make a list in topmost first order. Use a colon delimited 90065eef222Smrg # list incase some portion of path contains whitespace. 901b312a94cSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 90265eef222Smrg 90365eef222Smrg # If the last portion added has no slash in it, the list is done 904b312a94cSmrg case $_G_directory_path in */*) ;; *) break ;; esac 90565eef222Smrg 90665eef222Smrg # ...otherwise throw away the child directory and loop 907b312a94cSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 90865eef222Smrg done 909b312a94cSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 91065eef222Smrg 911b312a94cSmrg func_mkdir_p_IFS=$IFS; IFS=: 912b312a94cSmrg for _G_dir in $_G_dir_list; do 913b312a94cSmrg IFS=$func_mkdir_p_IFS 914b312a94cSmrg # mkdir can fail with a 'File exist' error if two processes 91565eef222Smrg # try to create one of the directories concurrently. Don't 91665eef222Smrg # stop in that case! 917b312a94cSmrg $MKDIR "$_G_dir" 2>/dev/null || : 91865eef222Smrg done 919b312a94cSmrg IFS=$func_mkdir_p_IFS 92065eef222Smrg 92165eef222Smrg # Bail out if we (or some other process) failed to create a directory. 922b312a94cSmrg test -d "$_G_directory_path" || \ 923b312a94cSmrg func_fatal_error "Failed to create '$1'" 92465eef222Smrg fi 92565eef222Smrg} 926ef981d24Smrg 927ef981d24Smrg 928b312a94cSmrg# func_mktempdir [BASENAME] 929b312a94cSmrg# ------------------------- 930ef981d24Smrg# Make a temporary directory that won't clash with other running 931ef981d24Smrg# libtool processes, and avoids race conditions if possible. If 932b312a94cSmrg# given, BASENAME is the basename for that directory. 933ef981d24Smrgfunc_mktempdir () 934ef981d24Smrg{ 935b312a94cSmrg $debug_cmd 936ef981d24Smrg 937b312a94cSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 938b312a94cSmrg 939b312a94cSmrg if test : = "$opt_dry_run"; then 940ef981d24Smrg # Return a directory name, but don't create it in dry-run mode 941b312a94cSmrg _G_tmpdir=$_G_template-$$ 942ef981d24Smrg else 943ef981d24Smrg 944ef981d24Smrg # If mktemp works, use that first and foremost 945b312a94cSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 946ef981d24Smrg 947b312a94cSmrg if test ! -d "$_G_tmpdir"; then 94865eef222Smrg # Failing that, at least try and use $RANDOM to avoid a race 949b312a94cSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 950ef981d24Smrg 951b312a94cSmrg func_mktempdir_umask=`umask` 95265eef222Smrg umask 0077 953b312a94cSmrg $MKDIR "$_G_tmpdir" 954b312a94cSmrg umask $func_mktempdir_umask 955ef981d24Smrg fi 956ef981d24Smrg 957ef981d24Smrg # If we're not in dry-run mode, bomb out on failure 958b312a94cSmrg test -d "$_G_tmpdir" || \ 959b312a94cSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 960ef981d24Smrg fi 961ef981d24Smrg 962b312a94cSmrg $ECHO "$_G_tmpdir" 963ef981d24Smrg} 964ef981d24Smrg 965ef981d24Smrg 966b312a94cSmrg# func_normal_abspath PATH 967b312a94cSmrg# ------------------------ 968b312a94cSmrg# Remove doubled-up and trailing slashes, "." path components, 969b312a94cSmrg# and cancel out any ".." path components in PATH after making 970b312a94cSmrg# it an absolute path. 971b312a94cSmrgfunc_normal_abspath () 972b312a94cSmrg{ 973b312a94cSmrg $debug_cmd 974b312a94cSmrg 975b312a94cSmrg # These SED scripts presuppose an absolute path with a trailing slash. 976b312a94cSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 977b312a94cSmrg _G_pathcdr='s|^/[^/]*||' 978b312a94cSmrg _G_removedotparts=':dotsl 979b312a94cSmrg s|/\./|/|g 980b312a94cSmrg t dotsl 981b312a94cSmrg s|/\.$|/|' 982b312a94cSmrg _G_collapseslashes='s|/\{1,\}|/|g' 983b312a94cSmrg _G_finalslash='s|/*$|/|' 984b312a94cSmrg 985b312a94cSmrg # Start from root dir and reassemble the path. 986b312a94cSmrg func_normal_abspath_result= 987b312a94cSmrg func_normal_abspath_tpath=$1 988b312a94cSmrg func_normal_abspath_altnamespace= 989b312a94cSmrg case $func_normal_abspath_tpath in 990b312a94cSmrg "") 991b312a94cSmrg # Empty path, that just means $cwd. 992b312a94cSmrg func_stripname '' '/' "`pwd`" 993b312a94cSmrg func_normal_abspath_result=$func_stripname_result 994b312a94cSmrg return 995b312a94cSmrg ;; 996b312a94cSmrg # The next three entries are used to spot a run of precisely 997b312a94cSmrg # two leading slashes without using negated character classes; 998b312a94cSmrg # we take advantage of case's first-match behaviour. 999b312a94cSmrg ///*) 1000b312a94cSmrg # Unusual form of absolute path, do nothing. 1001b312a94cSmrg ;; 1002b312a94cSmrg //*) 1003b312a94cSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 1004b312a94cSmrg # and for example Cygwin uses it to access remote file shares 1005b312a94cSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 1006b312a94cSmrg func_normal_abspath_altnamespace=/ 1007b312a94cSmrg ;; 1008b312a94cSmrg /*) 1009b312a94cSmrg # Absolute path, do nothing. 1010b312a94cSmrg ;; 1011b312a94cSmrg *) 1012b312a94cSmrg # Relative path, prepend $cwd. 1013b312a94cSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 1014b312a94cSmrg ;; 1015b312a94cSmrg esac 1016b312a94cSmrg 1017b312a94cSmrg # Cancel out all the simple stuff to save iterations. We also want 1018b312a94cSmrg # the path to end with a slash for ease of parsing, so make sure 1019b312a94cSmrg # there is one (and only one) here. 1020b312a94cSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1021b312a94cSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 1022b312a94cSmrg while :; do 1023b312a94cSmrg # Processed it all yet? 1024b312a94cSmrg if test / = "$func_normal_abspath_tpath"; then 1025b312a94cSmrg # If we ascended to the root using ".." the result may be empty now. 1026b312a94cSmrg if test -z "$func_normal_abspath_result"; then 1027b312a94cSmrg func_normal_abspath_result=/ 1028b312a94cSmrg fi 1029b312a94cSmrg break 1030b312a94cSmrg fi 1031b312a94cSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1032b312a94cSmrg -e "$_G_pathcar"` 1033b312a94cSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1034b312a94cSmrg -e "$_G_pathcdr"` 1035b312a94cSmrg # Figure out what to do with it 1036b312a94cSmrg case $func_normal_abspath_tcomponent in 1037b312a94cSmrg "") 1038b312a94cSmrg # Trailing empty path component, ignore it. 1039b312a94cSmrg ;; 1040b312a94cSmrg ..) 1041b312a94cSmrg # Parent dir; strip last assembled component from result. 1042b312a94cSmrg func_dirname "$func_normal_abspath_result" 1043b312a94cSmrg func_normal_abspath_result=$func_dirname_result 1044b312a94cSmrg ;; 1045b312a94cSmrg *) 1046b312a94cSmrg # Actual path component, append it. 1047b312a94cSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1048b312a94cSmrg ;; 1049b312a94cSmrg esac 1050b312a94cSmrg done 1051b312a94cSmrg # Restore leading double-slash if one was found on entry. 1052b312a94cSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1053b312a94cSmrg} 1054b312a94cSmrg 1055b312a94cSmrg 1056b312a94cSmrg# func_notquiet ARG... 1057b312a94cSmrg# -------------------- 1058b312a94cSmrg# Echo program name prefixed message only when not in quiet mode. 1059b312a94cSmrgfunc_notquiet () 1060b312a94cSmrg{ 1061b312a94cSmrg $debug_cmd 1062b312a94cSmrg 1063b312a94cSmrg $opt_quiet || func_echo ${1+"$@"} 1064b312a94cSmrg 1065b312a94cSmrg # A bug in bash halts the script if the last line of a function 1066b312a94cSmrg # fails when set -e is in force, so we need another command to 1067b312a94cSmrg # work around that: 1068b312a94cSmrg : 1069b312a94cSmrg} 1070b312a94cSmrg 1071b312a94cSmrg 1072b312a94cSmrg# func_relative_path SRCDIR DSTDIR 1073b312a94cSmrg# -------------------------------- 1074b312a94cSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1075b312a94cSmrgfunc_relative_path () 1076b312a94cSmrg{ 1077b312a94cSmrg $debug_cmd 1078b312a94cSmrg 1079b312a94cSmrg func_relative_path_result= 1080b312a94cSmrg func_normal_abspath "$1" 1081b312a94cSmrg func_relative_path_tlibdir=$func_normal_abspath_result 1082b312a94cSmrg func_normal_abspath "$2" 1083b312a94cSmrg func_relative_path_tbindir=$func_normal_abspath_result 1084b312a94cSmrg 1085b312a94cSmrg # Ascend the tree starting from libdir 1086b312a94cSmrg while :; do 1087b312a94cSmrg # check if we have found a prefix of bindir 1088b312a94cSmrg case $func_relative_path_tbindir in 1089b312a94cSmrg $func_relative_path_tlibdir) 1090b312a94cSmrg # found an exact match 1091b312a94cSmrg func_relative_path_tcancelled= 1092b312a94cSmrg break 1093b312a94cSmrg ;; 1094b312a94cSmrg $func_relative_path_tlibdir*) 1095b312a94cSmrg # found a matching prefix 1096b312a94cSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1097b312a94cSmrg func_relative_path_tcancelled=$func_stripname_result 1098b312a94cSmrg if test -z "$func_relative_path_result"; then 1099b312a94cSmrg func_relative_path_result=. 1100b312a94cSmrg fi 1101b312a94cSmrg break 1102b312a94cSmrg ;; 1103b312a94cSmrg *) 1104b312a94cSmrg func_dirname $func_relative_path_tlibdir 1105b312a94cSmrg func_relative_path_tlibdir=$func_dirname_result 1106b312a94cSmrg if test -z "$func_relative_path_tlibdir"; then 1107b312a94cSmrg # Have to descend all the way to the root! 1108b312a94cSmrg func_relative_path_result=../$func_relative_path_result 1109b312a94cSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 1110b312a94cSmrg break 1111b312a94cSmrg fi 1112b312a94cSmrg func_relative_path_result=../$func_relative_path_result 1113b312a94cSmrg ;; 1114b312a94cSmrg esac 1115b312a94cSmrg done 1116b312a94cSmrg 1117b312a94cSmrg # Now calculate path; take care to avoid doubling-up slashes. 1118b312a94cSmrg func_stripname '' '/' "$func_relative_path_result" 1119b312a94cSmrg func_relative_path_result=$func_stripname_result 1120b312a94cSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 1121b312a94cSmrg if test -n "$func_stripname_result"; then 1122b312a94cSmrg func_append func_relative_path_result "/$func_stripname_result" 1123b312a94cSmrg fi 1124b312a94cSmrg 1125b312a94cSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 1126b312a94cSmrg if test -n "$func_relative_path_result"; then 1127b312a94cSmrg func_stripname './' '' "$func_relative_path_result" 1128b312a94cSmrg func_relative_path_result=$func_stripname_result 1129b312a94cSmrg fi 1130b312a94cSmrg 1131b312a94cSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 1132b312a94cSmrg 1133b312a94cSmrg : 1134b312a94cSmrg} 1135b312a94cSmrg 1136b312a94cSmrg 1137d5637ae9Smrg# func_quote_portable EVAL ARG 1138d5637ae9Smrg# ---------------------------- 1139d5637ae9Smrg# Internal function to portably implement func_quote_arg. Note that we still 1140d5637ae9Smrg# keep attention to performance here so we as much as possible try to avoid 1141d5637ae9Smrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 1142d5637ae9Smrgfunc_quote_portable () 1143ef981d24Smrg{ 1144b312a94cSmrg $debug_cmd 1145b312a94cSmrg 1146d5637ae9Smrg $require_check_ifs_backslash 1147d5637ae9Smrg 1148d5637ae9Smrg func_quote_portable_result=$2 1149d5637ae9Smrg 1150d5637ae9Smrg # one-time-loop (easy break) 1151d5637ae9Smrg while true 1152d5637ae9Smrg do 1153d5637ae9Smrg if $1; then 1154d5637ae9Smrg func_quote_portable_result=`$ECHO "$2" | $SED \ 1155d5637ae9Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 1156d5637ae9Smrg break 1157b312a94cSmrg fi 1158b312a94cSmrg 1159d5637ae9Smrg # Quote for eval. 1160d5637ae9Smrg case $func_quote_portable_result in 1161d5637ae9Smrg *[\\\`\"\$]*) 1162d5637ae9Smrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 1163d5637ae9Smrg # contains the shell wildcard characters. 1164d5637ae9Smrg case $check_ifs_backshlash_broken$func_quote_portable_result in 1165d5637ae9Smrg :*|*[\[\*\?]*) 1166d5637ae9Smrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 1167d5637ae9Smrg | $SED "$sed_quote_subst"` 1168d5637ae9Smrg break 1169d5637ae9Smrg ;; 1170d5637ae9Smrg esac 1171d5637ae9Smrg 1172d5637ae9Smrg func_quote_portable_old_IFS=$IFS 1173d5637ae9Smrg for _G_char in '\' '`' '"' '$' 1174d5637ae9Smrg do 1175d5637ae9Smrg # STATE($1) PREV($2) SEPARATOR($3) 1176d5637ae9Smrg set start "" "" 1177d5637ae9Smrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 1178d5637ae9Smrg IFS=$_G_char 1179d5637ae9Smrg for _G_part in $func_quote_portable_result 1180d5637ae9Smrg do 1181d5637ae9Smrg case $1 in 1182d5637ae9Smrg quote) 1183d5637ae9Smrg func_append func_quote_portable_result "$3$2" 1184d5637ae9Smrg set quote "$_G_part" "\\$_G_char" 1185d5637ae9Smrg ;; 1186d5637ae9Smrg start) 1187d5637ae9Smrg set first "" "" 1188d5637ae9Smrg func_quote_portable_result= 1189d5637ae9Smrg ;; 1190d5637ae9Smrg first) 1191d5637ae9Smrg set quote "$_G_part" "" 1192d5637ae9Smrg ;; 1193d5637ae9Smrg esac 1194d5637ae9Smrg done 1195d5637ae9Smrg done 1196d5637ae9Smrg IFS=$func_quote_portable_old_IFS 1197b312a94cSmrg ;; 1198d5637ae9Smrg *) ;; 1199b312a94cSmrg esac 1200d5637ae9Smrg break 1201b312a94cSmrg done 1202d5637ae9Smrg 1203d5637ae9Smrg func_quote_portable_unquoted_result=$func_quote_portable_result 1204d5637ae9Smrg case $func_quote_portable_result in 1205d5637ae9Smrg # double-quote args containing shell metacharacters to delay 1206d5637ae9Smrg # word splitting, command substitution and variable expansion 1207d5637ae9Smrg # for a subsequent eval. 1208d5637ae9Smrg # many bourne shells cannot handle close brackets correctly 1209d5637ae9Smrg # in scan sets, so we specify it separately. 1210d5637ae9Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1211d5637ae9Smrg func_quote_portable_result=\"$func_quote_portable_result\" 1212d5637ae9Smrg ;; 1213d5637ae9Smrg esac 1214b312a94cSmrg} 1215b312a94cSmrg 1216b312a94cSmrg 1217d5637ae9Smrg# func_quotefast_eval ARG 1218d5637ae9Smrg# ----------------------- 1219d5637ae9Smrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 1220d5637ae9Smrg# but optimized for speed. Result is stored in $func_quotefast_eval. 1221d5637ae9Smrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 1222d5637ae9Smrg printf -v _GL_test_printf_tilde %q '~' 1223d5637ae9Smrg if test '\~' = "$_GL_test_printf_tilde"; then 1224d5637ae9Smrg func_quotefast_eval () 1225d5637ae9Smrg { 1226d5637ae9Smrg printf -v func_quotefast_eval_result %q "$1" 1227d5637ae9Smrg } 1228d5637ae9Smrg else 1229d5637ae9Smrg # Broken older Bash implementations. Make those faster too if possible. 1230d5637ae9Smrg func_quotefast_eval () 1231d5637ae9Smrg { 1232d5637ae9Smrg case $1 in 1233d5637ae9Smrg '~'*) 1234d5637ae9Smrg func_quote_portable false "$1" 1235d5637ae9Smrg func_quotefast_eval_result=$func_quote_portable_result 1236d5637ae9Smrg ;; 1237d5637ae9Smrg *) 1238d5637ae9Smrg printf -v func_quotefast_eval_result %q "$1" 1239d5637ae9Smrg ;; 1240d5637ae9Smrg esac 1241d5637ae9Smrg } 1242d5637ae9Smrg fi 1243d5637ae9Smrgelse 1244d5637ae9Smrg func_quotefast_eval () 1245d5637ae9Smrg { 1246d5637ae9Smrg func_quote_portable false "$1" 1247d5637ae9Smrg func_quotefast_eval_result=$func_quote_portable_result 1248d5637ae9Smrg } 1249d5637ae9Smrgfi 1250b312a94cSmrg 1251d5637ae9Smrg 1252d5637ae9Smrg# func_quote_arg MODEs ARG 1253d5637ae9Smrg# ------------------------ 1254d5637ae9Smrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 1255d5637ae9Smrg# specifiers listed below separated by ',' character. This function returns two 1256d5637ae9Smrg# values: 1257d5637ae9Smrg# i) func_quote_arg_result 1258d5637ae9Smrg# double-quoted (when needed), suitable for a subsequent eval 1259d5637ae9Smrg# ii) func_quote_arg_unquoted_result 1260d5637ae9Smrg# has all characters that are still active within double 1261d5637ae9Smrg# quotes backslashified. Available only if 'unquoted' is specified. 1262d5637ae9Smrg# 1263d5637ae9Smrg# Available modes: 1264d5637ae9Smrg# ---------------- 1265d5637ae9Smrg# 'eval' (default) 1266d5637ae9Smrg# - escape shell special characters 1267d5637ae9Smrg# 'expand' 1268d5637ae9Smrg# - the same as 'eval'; but do not quote variable references 1269d5637ae9Smrg# 'pretty' 1270d5637ae9Smrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 1271d5637ae9Smrg# be used later in func_quote to get output like: 'echo "a b"' instead 1272d5637ae9Smrg# of 'echo a\ b'. This is slower than default on some shells. 1273d5637ae9Smrg# 'unquoted' 1274d5637ae9Smrg# - produce also $func_quote_arg_unquoted_result which does not contain 1275d5637ae9Smrg# wrapping double-quotes. 1276d5637ae9Smrg# 1277d5637ae9Smrg# Examples for 'func_quote_arg pretty,unquoted string': 1278d5637ae9Smrg# 1279d5637ae9Smrg# string | *_result | *_unquoted_result 1280d5637ae9Smrg# ------------+-----------------------+------------------- 1281d5637ae9Smrg# " | \" | \" 1282d5637ae9Smrg# a b | "a b" | a b 1283d5637ae9Smrg# "a b" | "\"a b\"" | \"a b\" 1284d5637ae9Smrg# * | "*" | * 1285d5637ae9Smrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 1286d5637ae9Smrg# 1287d5637ae9Smrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 1288d5637ae9Smrg# 1289d5637ae9Smrg# string | *_result | *_unquoted_result 1290d5637ae9Smrg# --------------+---------------------+-------------------- 1291d5637ae9Smrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 1292d5637ae9Smrgfunc_quote_arg () 1293d5637ae9Smrg{ 1294d5637ae9Smrg _G_quote_expand=false 1295d5637ae9Smrg case ,$1, in 1296d5637ae9Smrg *,expand,*) 1297d5637ae9Smrg _G_quote_expand=: 1298d5637ae9Smrg ;; 129965eef222Smrg esac 130065eef222Smrg 1301d5637ae9Smrg case ,$1, in 1302d5637ae9Smrg *,pretty,*|*,expand,*|*,unquoted,*) 1303d5637ae9Smrg func_quote_portable $_G_quote_expand "$2" 1304d5637ae9Smrg func_quote_arg_result=$func_quote_portable_result 1305d5637ae9Smrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 1306d5637ae9Smrg ;; 1307d5637ae9Smrg *) 1308d5637ae9Smrg # Faster quote-for-eval for some shells. 1309d5637ae9Smrg func_quotefast_eval "$2" 1310d5637ae9Smrg func_quote_arg_result=$func_quotefast_eval_result 131165eef222Smrg ;; 1312ef981d24Smrg esac 1313d5637ae9Smrg} 1314d5637ae9Smrg 1315b312a94cSmrg 1316d5637ae9Smrg# func_quote MODEs ARGs... 1317d5637ae9Smrg# ------------------------ 1318d5637ae9Smrg# Quote all ARGs to be evaled later and join them into single command. See 1319d5637ae9Smrg# func_quote_arg's description for more info. 1320d5637ae9Smrgfunc_quote () 1321d5637ae9Smrg{ 1322d5637ae9Smrg $debug_cmd 1323d5637ae9Smrg _G_func_quote_mode=$1 ; shift 1324d5637ae9Smrg func_quote_result= 1325d5637ae9Smrg while test 0 -lt $#; do 1326d5637ae9Smrg func_quote_arg "$_G_func_quote_mode" "$1" 1327d5637ae9Smrg if test -n "$func_quote_result"; then 1328d5637ae9Smrg func_append func_quote_result " $func_quote_arg_result" 1329d5637ae9Smrg else 1330d5637ae9Smrg func_append func_quote_result "$func_quote_arg_result" 1331d5637ae9Smrg fi 1332d5637ae9Smrg shift 1333d5637ae9Smrg done 1334b312a94cSmrg} 1335b312a94cSmrg 1336b312a94cSmrg 1337b312a94cSmrg# func_stripname PREFIX SUFFIX NAME 1338b312a94cSmrg# --------------------------------- 1339b312a94cSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1340b312a94cSmrg# PREFIX and SUFFIX must not contain globbing or regex special 1341b312a94cSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 1342b312a94cSmrg# dot (in which case that matches only a dot). 1343b312a94cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 1344b312a94cSmrg eval 'func_stripname () 1345b312a94cSmrg { 1346b312a94cSmrg $debug_cmd 1347b312a94cSmrg 1348b312a94cSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1349b312a94cSmrg # positional parameters, so assign one to ordinary variable first. 1350b312a94cSmrg func_stripname_result=$3 1351b312a94cSmrg func_stripname_result=${func_stripname_result#"$1"} 1352b312a94cSmrg func_stripname_result=${func_stripname_result%"$2"} 1353b312a94cSmrg }' 1354b312a94cSmrgelse 1355b312a94cSmrg func_stripname () 1356b312a94cSmrg { 1357b312a94cSmrg $debug_cmd 1358b312a94cSmrg 1359b312a94cSmrg case $2 in 1360b312a94cSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1361b312a94cSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1362b312a94cSmrg esac 1363b312a94cSmrg } 1364b312a94cSmrgfi 1365b312a94cSmrg 1366b312a94cSmrg 1367b312a94cSmrg# func_show_eval CMD [FAIL_EXP] 1368b312a94cSmrg# ----------------------------- 1369b312a94cSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1370b312a94cSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1371b312a94cSmrg# is given, then evaluate it. 1372b312a94cSmrgfunc_show_eval () 1373b312a94cSmrg{ 1374b312a94cSmrg $debug_cmd 1375b312a94cSmrg 1376b312a94cSmrg _G_cmd=$1 1377b312a94cSmrg _G_fail_exp=${2-':'} 1378b312a94cSmrg 1379d5637ae9Smrg func_quote_arg pretty,expand "$_G_cmd" 1380d5637ae9Smrg eval "func_notquiet $func_quote_arg_result" 1381b312a94cSmrg 1382b312a94cSmrg $opt_dry_run || { 1383b312a94cSmrg eval "$_G_cmd" 1384b312a94cSmrg _G_status=$? 1385b312a94cSmrg if test 0 -ne "$_G_status"; then 1386b312a94cSmrg eval "(exit $_G_status); $_G_fail_exp" 1387b312a94cSmrg fi 1388b312a94cSmrg } 1389b312a94cSmrg} 1390b312a94cSmrg 1391b312a94cSmrg 1392b312a94cSmrg# func_show_eval_locale CMD [FAIL_EXP] 1393b312a94cSmrg# ------------------------------------ 1394b312a94cSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1395b312a94cSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1396b312a94cSmrg# is given, then evaluate it. Use the saved locale for evaluation. 1397b312a94cSmrgfunc_show_eval_locale () 1398b312a94cSmrg{ 1399b312a94cSmrg $debug_cmd 1400b312a94cSmrg 1401b312a94cSmrg _G_cmd=$1 1402b312a94cSmrg _G_fail_exp=${2-':'} 1403b312a94cSmrg 1404b312a94cSmrg $opt_quiet || { 1405d5637ae9Smrg func_quote_arg expand,pretty "$_G_cmd" 1406d5637ae9Smrg eval "func_echo $func_quote_arg_result" 1407b312a94cSmrg } 1408b312a94cSmrg 1409b312a94cSmrg $opt_dry_run || { 1410b312a94cSmrg eval "$_G_user_locale 1411b312a94cSmrg $_G_cmd" 1412b312a94cSmrg _G_status=$? 1413b312a94cSmrg eval "$_G_safe_locale" 1414b312a94cSmrg if test 0 -ne "$_G_status"; then 1415b312a94cSmrg eval "(exit $_G_status); $_G_fail_exp" 1416b312a94cSmrg fi 1417b312a94cSmrg } 1418b312a94cSmrg} 1419b312a94cSmrg 1420b312a94cSmrg 1421b312a94cSmrg# func_tr_sh 1422b312a94cSmrg# ---------- 1423b312a94cSmrg# Turn $1 into a string suitable for a shell variable name. 1424b312a94cSmrg# Result is stored in $func_tr_sh_result. All characters 1425b312a94cSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1426b312a94cSmrg# if $1 begins with a digit, a '_' is prepended as well. 1427b312a94cSmrgfunc_tr_sh () 1428b312a94cSmrg{ 1429b312a94cSmrg $debug_cmd 1430b312a94cSmrg 1431b312a94cSmrg case $1 in 1432b312a94cSmrg [0-9]* | *[!a-zA-Z0-9_]*) 1433b312a94cSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1434b312a94cSmrg ;; 1435b312a94cSmrg * ) 1436b312a94cSmrg func_tr_sh_result=$1 1437b312a94cSmrg ;; 1438b312a94cSmrg esac 1439b312a94cSmrg} 1440b312a94cSmrg 1441b312a94cSmrg 1442b312a94cSmrg# func_verbose ARG... 1443b312a94cSmrg# ------------------- 1444b312a94cSmrg# Echo program name prefixed message in verbose mode only. 1445b312a94cSmrgfunc_verbose () 1446b312a94cSmrg{ 1447b312a94cSmrg $debug_cmd 1448b312a94cSmrg 1449b312a94cSmrg $opt_verbose && func_echo "$*" 1450b312a94cSmrg 1451b312a94cSmrg : 1452b312a94cSmrg} 1453b312a94cSmrg 1454b312a94cSmrg 1455b312a94cSmrg# func_warn_and_continue ARG... 1456b312a94cSmrg# ----------------------------- 1457b312a94cSmrg# Echo program name prefixed warning message to standard error. 1458b312a94cSmrgfunc_warn_and_continue () 1459b312a94cSmrg{ 1460b312a94cSmrg $debug_cmd 1461b312a94cSmrg 1462b312a94cSmrg $require_term_colors 1463b312a94cSmrg 1464b312a94cSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1465b312a94cSmrg} 1466b312a94cSmrg 1467b312a94cSmrg 1468b312a94cSmrg# func_warning CATEGORY ARG... 1469b312a94cSmrg# ---------------------------- 1470b312a94cSmrg# Echo program name prefixed warning message to standard error. Warning 1471b312a94cSmrg# messages can be filtered according to CATEGORY, where this function 1472b312a94cSmrg# elides messages where CATEGORY is not listed in the global variable 1473b312a94cSmrg# 'opt_warning_types'. 1474b312a94cSmrgfunc_warning () 1475b312a94cSmrg{ 1476b312a94cSmrg $debug_cmd 1477b312a94cSmrg 1478b312a94cSmrg # CATEGORY must be in the warning_categories list! 1479b312a94cSmrg case " $warning_categories " in 1480b312a94cSmrg *" $1 "*) ;; 1481b312a94cSmrg *) func_internal_error "invalid warning category '$1'" ;; 1482b312a94cSmrg esac 1483b312a94cSmrg 1484b312a94cSmrg _G_category=$1 1485b312a94cSmrg shift 1486b312a94cSmrg 1487b312a94cSmrg case " $opt_warning_types " in 1488b312a94cSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 1489b312a94cSmrg esac 1490b312a94cSmrg} 1491b312a94cSmrg 1492b312a94cSmrg 1493b312a94cSmrg# func_sort_ver VER1 VER2 1494b312a94cSmrg# ----------------------- 1495b312a94cSmrg# 'sort -V' is not generally available. 1496b312a94cSmrg# Note this deviates from the version comparison in automake 1497b312a94cSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1498b312a94cSmrg# but this should suffice as we won't be specifying old 1499b312a94cSmrg# version formats or redundant trailing .0 in bootstrap.conf. 1500b312a94cSmrg# If we did want full compatibility then we should probably 1501b312a94cSmrg# use m4_version_compare from autoconf. 1502b312a94cSmrgfunc_sort_ver () 1503b312a94cSmrg{ 1504b312a94cSmrg $debug_cmd 1505b312a94cSmrg 1506b312a94cSmrg printf '%s\n%s\n' "$1" "$2" \ 1507b312a94cSmrg | 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 1508b312a94cSmrg} 1509b312a94cSmrg 1510b312a94cSmrg# func_lt_ver PREV CURR 1511b312a94cSmrg# --------------------- 1512b312a94cSmrg# Return true if PREV and CURR are in the correct order according to 1513b312a94cSmrg# func_sort_ver, otherwise false. Use it like this: 1514b312a94cSmrg# 1515b312a94cSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1516b312a94cSmrgfunc_lt_ver () 1517b312a94cSmrg{ 1518b312a94cSmrg $debug_cmd 1519b312a94cSmrg 1520b312a94cSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1521b312a94cSmrg} 1522b312a94cSmrg 1523b312a94cSmrg 1524b312a94cSmrg# Local variables: 1525b312a94cSmrg# mode: shell-script 1526b312a94cSmrg# sh-indentation: 2 1527b312a94cSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 1528b312a94cSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1529b312a94cSmrg# time-stamp-time-zone: "UTC" 1530b312a94cSmrg# End: 1531b312a94cSmrg#! /bin/sh 1532b312a94cSmrg 1533b312a94cSmrg# A portable, pluggable option parser for Bourne shell. 1534b312a94cSmrg# Written by Gary V. Vaughan, 2010 1535b312a94cSmrg 1536d5637ae9Smrg# This is free software. There is NO warranty; not even for 1537d5637ae9Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1538d5637ae9Smrg# 1539d5637ae9Smrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 1540d5637ae9Smrg# 1541d5637ae9Smrg# This file is dual licensed under the terms of the MIT license 1542d5637ae9Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 1543d5637ae9Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 1544d5637ae9Smrg# these licenses when using or redistributing this software or any of 1545d5637ae9Smrg# the files within it. See the URLs above, or the file `LICENSE` 1546d5637ae9Smrg# included in the Bootstrap distribution for the full license texts. 1547b312a94cSmrg 1548d5637ae9Smrg# Please report bugs or propose patches to: 1549d5637ae9Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 1550b312a94cSmrg 1551d5637ae9Smrg# Set a version string for this script. 1552d5637ae9Smrgscriptversion=2019-02-19.15; # UTC 1553b312a94cSmrg 1554b312a94cSmrg 1555b312a94cSmrg## ------ ## 1556b312a94cSmrg## Usage. ## 1557b312a94cSmrg## ------ ## 1558b312a94cSmrg 1559b312a94cSmrg# This file is a library for parsing options in your shell scripts along 1560b312a94cSmrg# with assorted other useful supporting features that you can make use 1561b312a94cSmrg# of too. 1562b312a94cSmrg# 1563b312a94cSmrg# For the simplest scripts you might need only: 1564b312a94cSmrg# 1565b312a94cSmrg# #!/bin/sh 1566b312a94cSmrg# . relative/path/to/funclib.sh 1567b312a94cSmrg# . relative/path/to/options-parser 1568b312a94cSmrg# scriptversion=1.0 1569b312a94cSmrg# func_options ${1+"$@"} 1570b312a94cSmrg# eval set dummy "$func_options_result"; shift 1571b312a94cSmrg# ...rest of your script... 1572b312a94cSmrg# 1573b312a94cSmrg# In order for the '--version' option to work, you will need to have a 1574b312a94cSmrg# suitably formatted comment like the one at the top of this file 1575d5637ae9Smrg# starting with '# Written by ' and ending with '# Copyright'. 1576b312a94cSmrg# 1577b312a94cSmrg# For '-h' and '--help' to work, you will also need a one line 1578b312a94cSmrg# description of your script's purpose in a comment directly above the 1579b312a94cSmrg# '# Written by ' line, like the one at the top of this file. 1580b312a94cSmrg# 1581b312a94cSmrg# The default options also support '--debug', which will turn on shell 1582b312a94cSmrg# execution tracing (see the comment above debug_cmd below for another 1583b312a94cSmrg# use), and '--verbose' and the func_verbose function to allow your script 1584b312a94cSmrg# to display verbose messages only when your user has specified 1585b312a94cSmrg# '--verbose'. 1586b312a94cSmrg# 1587d5637ae9Smrg# After sourcing this file, you can plug in processing for additional 1588b312a94cSmrg# options by amending the variables from the 'Configuration' section 1589b312a94cSmrg# below, and following the instructions in the 'Option parsing' 1590b312a94cSmrg# section further down. 1591b312a94cSmrg 1592b312a94cSmrg## -------------- ## 1593b312a94cSmrg## Configuration. ## 1594b312a94cSmrg## -------------- ## 1595b312a94cSmrg 1596b312a94cSmrg# You should override these variables in your script after sourcing this 1597b312a94cSmrg# file so that they reflect the customisations you have added to the 1598b312a94cSmrg# option parser. 1599b312a94cSmrg 1600b312a94cSmrg# The usage line for option parsing errors and the start of '-h' and 1601b312a94cSmrg# '--help' output messages. You can embed shell variables for delayed 1602b312a94cSmrg# expansion at the time the message is displayed, but you will need to 1603b312a94cSmrg# quote other shell meta-characters carefully to prevent them being 1604b312a94cSmrg# expanded when the contents are evaled. 1605b312a94cSmrgusage='$progpath [OPTION]...' 1606b312a94cSmrg 1607b312a94cSmrg# Short help message in response to '-h' and '--help'. Add to this or 1608b312a94cSmrg# override it after sourcing this library to reflect the full set of 1609b312a94cSmrg# options your script accepts. 1610b312a94cSmrgusage_message="\ 1611b312a94cSmrg --debug enable verbose shell tracing 1612b312a94cSmrg -W, --warnings=CATEGORY 1613b312a94cSmrg report the warnings falling in CATEGORY [all] 1614b312a94cSmrg -v, --verbose verbosely report processing 1615b312a94cSmrg --version print version information and exit 1616b312a94cSmrg -h, --help print short or long help message and exit 1617b312a94cSmrg" 1618b312a94cSmrg 1619b312a94cSmrg# Additional text appended to 'usage_message' in response to '--help'. 1620b312a94cSmrglong_help_message=" 1621b312a94cSmrgWarning categories include: 1622b312a94cSmrg 'all' show all warnings 1623b312a94cSmrg 'none' turn off all the warnings 1624b312a94cSmrg 'error' warnings are treated as fatal errors" 1625b312a94cSmrg 1626b312a94cSmrg# Help message printed before fatal option parsing errors. 1627b312a94cSmrgfatal_help="Try '\$progname --help' for more information." 1628b312a94cSmrg 1629b312a94cSmrg 1630b312a94cSmrg 1631b312a94cSmrg## ------------------------- ## 1632b312a94cSmrg## Hook function management. ## 1633b312a94cSmrg## ------------------------- ## 1634b312a94cSmrg 1635b312a94cSmrg# This section contains functions for adding, removing, and running hooks 1636d5637ae9Smrg# in the main code. A hook is just a list of function names that can be 1637d5637ae9Smrg# run in order later on. 1638b312a94cSmrg 1639b312a94cSmrg# func_hookable FUNC_NAME 1640b312a94cSmrg# ----------------------- 1641b312a94cSmrg# Declare that FUNC_NAME will run hooks added with 1642b312a94cSmrg# 'func_add_hook FUNC_NAME ...'. 1643b312a94cSmrgfunc_hookable () 1644b312a94cSmrg{ 1645b312a94cSmrg $debug_cmd 1646b312a94cSmrg 1647b312a94cSmrg func_append hookable_fns " $1" 1648b312a94cSmrg} 1649b312a94cSmrg 1650b312a94cSmrg 1651b312a94cSmrg# func_add_hook FUNC_NAME HOOK_FUNC 1652b312a94cSmrg# --------------------------------- 1653b312a94cSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1654b312a94cSmrg# first have been declared "hookable" by a call to 'func_hookable'. 1655b312a94cSmrgfunc_add_hook () 1656b312a94cSmrg{ 1657b312a94cSmrg $debug_cmd 1658b312a94cSmrg 1659b312a94cSmrg case " $hookable_fns " in 1660b312a94cSmrg *" $1 "*) ;; 1661b312a94cSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 1662b312a94cSmrg esac 1663b312a94cSmrg 1664b312a94cSmrg eval func_append ${1}_hooks '" $2"' 1665b312a94cSmrg} 1666b312a94cSmrg 1667b312a94cSmrg 1668b312a94cSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 1669b312a94cSmrg# ------------------------------------ 1670d5637ae9Smrg# Remove HOOK_FUNC from the list of hook functions to be called by 1671d5637ae9Smrg# FUNC_NAME. 1672b312a94cSmrgfunc_remove_hook () 1673b312a94cSmrg{ 1674b312a94cSmrg $debug_cmd 1675b312a94cSmrg 1676b312a94cSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1677b312a94cSmrg} 1678b312a94cSmrg 1679b312a94cSmrg 1680d5637ae9Smrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 1681d5637ae9Smrg# --------------------------------------------- 1682d5637ae9Smrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 1683d5637ae9Smrg# *_result variable of FUNC_NAME_B. 1684d5637ae9Smrgfunc_propagate_result () 1685d5637ae9Smrg{ 1686d5637ae9Smrg $debug_cmd 1687d5637ae9Smrg 1688d5637ae9Smrg func_propagate_result_result=: 1689d5637ae9Smrg if eval "test \"\${${1}_result+set}\" = set" 1690d5637ae9Smrg then 1691d5637ae9Smrg eval "${2}_result=\$${1}_result" 1692d5637ae9Smrg else 1693d5637ae9Smrg func_propagate_result_result=false 1694d5637ae9Smrg fi 1695d5637ae9Smrg} 1696d5637ae9Smrg 1697d5637ae9Smrg 1698b312a94cSmrg# func_run_hooks FUNC_NAME [ARG]... 1699b312a94cSmrg# --------------------------------- 1700b312a94cSmrg# Run all hook functions registered to FUNC_NAME. 1701d5637ae9Smrg# It's assumed that the list of hook functions contains nothing more 1702b312a94cSmrg# than a whitespace-delimited list of legal shell function names, and 1703b312a94cSmrg# no effort is wasted trying to catch shell meta-characters or preserve 1704b312a94cSmrg# whitespace. 1705b312a94cSmrgfunc_run_hooks () 1706b312a94cSmrg{ 1707b312a94cSmrg $debug_cmd 1708b312a94cSmrg 1709b312a94cSmrg case " $hookable_fns " in 1710b312a94cSmrg *" $1 "*) ;; 1711d5637ae9Smrg *) func_fatal_error "'$1' does not support hook functions." ;; 1712b312a94cSmrg esac 1713b312a94cSmrg 1714b312a94cSmrg eval _G_hook_fns=\$$1_hooks; shift 1715b312a94cSmrg 1716b312a94cSmrg for _G_hook in $_G_hook_fns; do 1717d5637ae9Smrg func_unset "${_G_hook}_result" 1718d5637ae9Smrg eval $_G_hook '${1+"$@"}' 1719d5637ae9Smrg func_propagate_result $_G_hook func_run_hooks 1720d5637ae9Smrg if $func_propagate_result_result; then 1721d5637ae9Smrg eval set dummy "$func_run_hooks_result"; shift 1722d5637ae9Smrg fi 1723b312a94cSmrg done 1724b312a94cSmrg} 1725b312a94cSmrg 1726b312a94cSmrg 1727b312a94cSmrg 1728b312a94cSmrg## --------------- ## 1729b312a94cSmrg## Option parsing. ## 1730b312a94cSmrg## --------------- ## 1731b312a94cSmrg 1732b312a94cSmrg# In order to add your own option parsing hooks, you must accept the 1733d5637ae9Smrg# full positional parameter list from your hook function. You may remove 1734d5637ae9Smrg# or edit any options that you action, and then pass back the remaining 1735d5637ae9Smrg# unprocessed options in '<hooked_function_name>_result', escaped 1736d5637ae9Smrg# suitably for 'eval'. 1737d5637ae9Smrg# 1738d5637ae9Smrg# The '<hooked_function_name>_result' variable is automatically unset 1739d5637ae9Smrg# before your hook gets called; for best performance, only set the 1740d5637ae9Smrg# *_result variable when necessary (i.e. don't call the 'func_quote' 1741d5637ae9Smrg# function unnecessarily because it can be an expensive operation on some 1742d5637ae9Smrg# machines). 1743d5637ae9Smrg# 1744d5637ae9Smrg# Like this: 1745b312a94cSmrg# 1746b312a94cSmrg# my_options_prep () 1747b312a94cSmrg# { 1748b312a94cSmrg# $debug_cmd 1749b312a94cSmrg# 1750b312a94cSmrg# # Extend the existing usage message. 1751b312a94cSmrg# usage_message=$usage_message' 1752b312a94cSmrg# -s, --silent don'\''t print informational messages 1753b312a94cSmrg# ' 1754d5637ae9Smrg# # No change in '$@' (ignored completely by this hook). Leave 1755d5637ae9Smrg# # my_options_prep_result variable intact. 1756b312a94cSmrg# } 1757b312a94cSmrg# func_add_hook func_options_prep my_options_prep 1758b312a94cSmrg# 1759b312a94cSmrg# 1760b312a94cSmrg# my_silent_option () 1761b312a94cSmrg# { 1762b312a94cSmrg# $debug_cmd 1763b312a94cSmrg# 1764d5637ae9Smrg# args_changed=false 1765d5637ae9Smrg# 1766d5637ae9Smrg# # Note that, for efficiency, we parse as many options as we can 1767b312a94cSmrg# # recognise in a loop before passing the remainder back to the 1768b312a94cSmrg# # caller on the first unrecognised argument we encounter. 1769b312a94cSmrg# while test $# -gt 0; do 1770b312a94cSmrg# opt=$1; shift 1771b312a94cSmrg# case $opt in 1772d5637ae9Smrg# --silent|-s) opt_silent=: 1773d5637ae9Smrg# args_changed=: 1774d5637ae9Smrg# ;; 1775b312a94cSmrg# # Separate non-argument short options: 1776b312a94cSmrg# -s*) func_split_short_opt "$_G_opt" 1777b312a94cSmrg# set dummy "$func_split_short_opt_name" \ 1778b312a94cSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 1779b312a94cSmrg# shift 1780d5637ae9Smrg# args_changed=: 1781b312a94cSmrg# ;; 1782d5637ae9Smrg# *) # Make sure the first unrecognised option "$_G_opt" 1783d5637ae9Smrg# # is added back to "$@" in case we need it later, 1784d5637ae9Smrg# # if $args_changed was set to 'true'. 1785d5637ae9Smrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1786b312a94cSmrg# esac 1787b312a94cSmrg# done 1788b312a94cSmrg# 1789d5637ae9Smrg# # Only call 'func_quote' here if we processed at least one argument. 1790d5637ae9Smrg# if $args_changed; then 1791d5637ae9Smrg# func_quote eval ${1+"$@"} 1792d5637ae9Smrg# my_silent_option_result=$func_quote_result 1793d5637ae9Smrg# fi 1794b312a94cSmrg# } 1795b312a94cSmrg# func_add_hook func_parse_options my_silent_option 1796b312a94cSmrg# 1797b312a94cSmrg# 1798b312a94cSmrg# my_option_validation () 1799b312a94cSmrg# { 1800b312a94cSmrg# $debug_cmd 1801b312a94cSmrg# 1802b312a94cSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 1803b312a94cSmrg# '--silent' and '--verbose' options are mutually exclusive." 1804b312a94cSmrg# } 1805b312a94cSmrg# func_add_hook func_validate_options my_option_validation 1806b312a94cSmrg# 1807d5637ae9Smrg# You'll also need to manually amend $usage_message to reflect the extra 1808b312a94cSmrg# options you parse. It's preferable to append if you can, so that 1809b312a94cSmrg# multiple option parsing hooks can be added safely. 1810b312a94cSmrg 1811b312a94cSmrg 1812d5637ae9Smrg# func_options_finish [ARG]... 1813d5637ae9Smrg# ---------------------------- 1814d5637ae9Smrg# Finishing the option parse loop (call 'func_options' hooks ATM). 1815d5637ae9Smrgfunc_options_finish () 1816d5637ae9Smrg{ 1817d5637ae9Smrg $debug_cmd 1818d5637ae9Smrg 1819d5637ae9Smrg func_run_hooks func_options ${1+"$@"} 1820d5637ae9Smrg func_propagate_result func_run_hooks func_options_finish 1821d5637ae9Smrg} 1822d5637ae9Smrg 1823d5637ae9Smrg 1824b312a94cSmrg# func_options [ARG]... 1825b312a94cSmrg# --------------------- 1826b312a94cSmrg# All the functions called inside func_options are hookable. See the 1827b312a94cSmrg# individual implementations for details. 1828b312a94cSmrgfunc_hookable func_options 1829b312a94cSmrgfunc_options () 1830b312a94cSmrg{ 1831b312a94cSmrg $debug_cmd 1832b312a94cSmrg 1833d5637ae9Smrg _G_options_quoted=false 1834b312a94cSmrg 1835d5637ae9Smrg for my_func in options_prep parse_options validate_options options_finish 1836d5637ae9Smrg do 1837d5637ae9Smrg func_unset func_${my_func}_result 1838d5637ae9Smrg func_unset func_run_hooks_result 1839d5637ae9Smrg eval func_$my_func '${1+"$@"}' 1840d5637ae9Smrg func_propagate_result func_$my_func func_options 1841d5637ae9Smrg if $func_propagate_result_result; then 1842d5637ae9Smrg eval set dummy "$func_options_result"; shift 1843d5637ae9Smrg _G_options_quoted=: 1844d5637ae9Smrg fi 1845d5637ae9Smrg done 1846b312a94cSmrg 1847d5637ae9Smrg $_G_options_quoted || { 1848d5637ae9Smrg # As we (func_options) are top-level options-parser function and 1849d5637ae9Smrg # nobody quoted "$@" for us yet, we need to do it explicitly for 1850d5637ae9Smrg # caller. 1851d5637ae9Smrg func_quote eval ${1+"$@"} 1852d5637ae9Smrg func_options_result=$func_quote_result 1853d5637ae9Smrg } 1854ef981d24Smrg} 1855ef981d24Smrg 1856ef981d24Smrg 1857b312a94cSmrg# func_options_prep [ARG]... 1858b312a94cSmrg# -------------------------- 1859b312a94cSmrg# All initialisations required before starting the option parse loop. 1860b312a94cSmrg# Note that when calling hook functions, we pass through the list of 1861b312a94cSmrg# positional parameters. If a hook function modifies that list, and 1862d5637ae9Smrg# needs to propagate that back to rest of this script, then the complete 1863d5637ae9Smrg# modified list must be put in 'func_run_hooks_result' before returning. 1864b312a94cSmrgfunc_hookable func_options_prep 1865b312a94cSmrgfunc_options_prep () 1866ef981d24Smrg{ 1867b312a94cSmrg $debug_cmd 186865eef222Smrg 1869b312a94cSmrg # Option defaults: 1870b312a94cSmrg opt_verbose=false 1871b312a94cSmrg opt_warning_types= 1872b312a94cSmrg 1873b312a94cSmrg func_run_hooks func_options_prep ${1+"$@"} 1874d5637ae9Smrg func_propagate_result func_run_hooks func_options_prep 1875ef981d24Smrg} 1876ef981d24Smrg 1877ef981d24Smrg 1878b312a94cSmrg# func_parse_options [ARG]... 1879b312a94cSmrg# --------------------------- 1880b312a94cSmrg# The main option parsing loop. 1881b312a94cSmrgfunc_hookable func_parse_options 1882b312a94cSmrgfunc_parse_options () 1883ef981d24Smrg{ 1884b312a94cSmrg $debug_cmd 1885ef981d24Smrg 1886d5637ae9Smrg _G_parse_options_requote=false 1887b312a94cSmrg # this just eases exit handling 1888b312a94cSmrg while test $# -gt 0; do 1889b312a94cSmrg # Defer to hook functions for initial option parsing, so they 1890b312a94cSmrg # get priority in the event of reusing an option name. 1891b312a94cSmrg func_run_hooks func_parse_options ${1+"$@"} 1892d5637ae9Smrg func_propagate_result func_run_hooks func_parse_options 1893d5637ae9Smrg if $func_propagate_result_result; then 1894d5637ae9Smrg eval set dummy "$func_parse_options_result"; shift 1895d5637ae9Smrg # Even though we may have changed "$@", we passed the "$@" array 1896d5637ae9Smrg # down into the hook and it quoted it for us (because we are in 1897d5637ae9Smrg # this if-branch). No need to quote it again. 1898d5637ae9Smrg _G_parse_options_requote=false 1899d5637ae9Smrg fi 190065eef222Smrg 1901b312a94cSmrg # Break out of the loop if we already parsed every option. 1902b312a94cSmrg test $# -gt 0 || break 1903ef981d24Smrg 1904d5637ae9Smrg # We expect that one of the options parsed in this function matches 1905d5637ae9Smrg # and thus we remove _G_opt from "$@" and need to re-quote. 1906d5637ae9Smrg _G_match_parse_options=: 1907b312a94cSmrg _G_opt=$1 1908b312a94cSmrg shift 1909b312a94cSmrg case $_G_opt in 1910b312a94cSmrg --debug|-x) debug_cmd='set -x' 1911d5637ae9Smrg func_echo "enabling shell trace mode" >&2 1912b312a94cSmrg $debug_cmd 1913b312a94cSmrg ;; 1914b312a94cSmrg 1915b312a94cSmrg --no-warnings|--no-warning|--no-warn) 1916b312a94cSmrg set dummy --warnings none ${1+"$@"} 1917b312a94cSmrg shift 1918b312a94cSmrg ;; 191965eef222Smrg 1920b312a94cSmrg --warnings|--warning|-W) 1921d5637ae9Smrg if test $# = 0 && func_missing_arg $_G_opt; then 1922d5637ae9Smrg _G_parse_options_requote=: 1923d5637ae9Smrg break 1924d5637ae9Smrg fi 1925b312a94cSmrg case " $warning_categories $1" in 1926b312a94cSmrg *" $1 "*) 1927b312a94cSmrg # trailing space prevents matching last $1 above 1928b312a94cSmrg func_append_uniq opt_warning_types " $1" 1929b312a94cSmrg ;; 1930b312a94cSmrg *all) 1931b312a94cSmrg opt_warning_types=$warning_categories 1932b312a94cSmrg ;; 1933b312a94cSmrg *none) 1934b312a94cSmrg opt_warning_types=none 1935b312a94cSmrg warning_func=: 1936b312a94cSmrg ;; 1937b312a94cSmrg *error) 1938b312a94cSmrg opt_warning_types=$warning_categories 1939b312a94cSmrg warning_func=func_fatal_error 1940b312a94cSmrg ;; 1941b312a94cSmrg *) 1942b312a94cSmrg func_fatal_error \ 1943b312a94cSmrg "unsupported warning category: '$1'" 1944b312a94cSmrg ;; 1945b312a94cSmrg esac 1946b312a94cSmrg shift 1947b312a94cSmrg ;; 1948b312a94cSmrg 1949b312a94cSmrg --verbose|-v) opt_verbose=: ;; 1950b312a94cSmrg --version) func_version ;; 1951b312a94cSmrg -\?|-h) func_usage ;; 1952b312a94cSmrg --help) func_help ;; 1953b312a94cSmrg 1954b312a94cSmrg # Separate optargs to long options (plugins may need this): 1955b312a94cSmrg --*=*) func_split_equals "$_G_opt" 1956b312a94cSmrg set dummy "$func_split_equals_lhs" \ 1957b312a94cSmrg "$func_split_equals_rhs" ${1+"$@"} 1958b312a94cSmrg shift 1959b312a94cSmrg ;; 1960b312a94cSmrg 1961b312a94cSmrg # Separate optargs to short options: 1962b312a94cSmrg -W*) 1963b312a94cSmrg func_split_short_opt "$_G_opt" 1964b312a94cSmrg set dummy "$func_split_short_opt_name" \ 1965b312a94cSmrg "$func_split_short_opt_arg" ${1+"$@"} 1966b312a94cSmrg shift 1967b312a94cSmrg ;; 1968b312a94cSmrg 1969b312a94cSmrg # Separate non-argument short options: 1970b312a94cSmrg -\?*|-h*|-v*|-x*) 1971b312a94cSmrg func_split_short_opt "$_G_opt" 1972b312a94cSmrg set dummy "$func_split_short_opt_name" \ 1973b312a94cSmrg "-$func_split_short_opt_arg" ${1+"$@"} 1974b312a94cSmrg shift 1975b312a94cSmrg ;; 1976b312a94cSmrg 1977d5637ae9Smrg --) _G_parse_options_requote=: ; break ;; 1978b312a94cSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1979d5637ae9Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift 1980d5637ae9Smrg _G_match_parse_options=false 1981d5637ae9Smrg break 1982d5637ae9Smrg ;; 1983b312a94cSmrg esac 1984d5637ae9Smrg 1985d5637ae9Smrg if $_G_match_parse_options; then 1986d5637ae9Smrg _G_parse_options_requote=: 1987d5637ae9Smrg fi 1988b312a94cSmrg done 1989ef981d24Smrg 1990d5637ae9Smrg if $_G_parse_options_requote; then 1991d5637ae9Smrg # save modified positional parameters for caller 1992d5637ae9Smrg func_quote eval ${1+"$@"} 1993d5637ae9Smrg func_parse_options_result=$func_quote_result 1994d5637ae9Smrg fi 1995200d7199Smrg} 1996200d7199Smrg 1997ef981d24Smrg 1998b312a94cSmrg# func_validate_options [ARG]... 1999b312a94cSmrg# ------------------------------ 2000b312a94cSmrg# Perform any sanity checks on option settings and/or unconsumed 2001b312a94cSmrg# arguments. 2002b312a94cSmrgfunc_hookable func_validate_options 2003b312a94cSmrgfunc_validate_options () 200465eef222Smrg{ 2005b312a94cSmrg $debug_cmd 2006200d7199Smrg 2007b312a94cSmrg # Display all warnings if -W was not given. 2008b312a94cSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 2009b312a94cSmrg 2010b312a94cSmrg func_run_hooks func_validate_options ${1+"$@"} 2011d5637ae9Smrg func_propagate_result func_run_hooks func_validate_options 2012b312a94cSmrg 2013b312a94cSmrg # Bail if the options were screwed! 2014b312a94cSmrg $exit_cmd $EXIT_FAILURE 201565eef222Smrg} 201665eef222Smrg 2017b312a94cSmrg 2018b312a94cSmrg 2019b312a94cSmrg## ----------------- ## 2020b312a94cSmrg## Helper functions. ## 2021b312a94cSmrg## ----------------- ## 2022b312a94cSmrg 2023b312a94cSmrg# This section contains the helper functions used by the rest of the 2024b312a94cSmrg# hookable option parser framework in ascii-betical order. 2025b312a94cSmrg 2026b312a94cSmrg 2027b312a94cSmrg# func_fatal_help ARG... 2028b312a94cSmrg# ---------------------- 2029b312a94cSmrg# Echo program name prefixed message to standard error, followed by 2030b312a94cSmrg# a help hint, and exit. 2031b312a94cSmrgfunc_fatal_help () 203265eef222Smrg{ 2033b312a94cSmrg $debug_cmd 2034200d7199Smrg 2035b312a94cSmrg eval \$ECHO \""Usage: $usage"\" 2036b312a94cSmrg eval \$ECHO \""$fatal_help"\" 2037b312a94cSmrg func_error ${1+"$@"} 2038b312a94cSmrg exit $EXIT_FAILURE 203965eef222Smrg} 204065eef222Smrg 2041b312a94cSmrg 2042b312a94cSmrg# func_help 2043b312a94cSmrg# --------- 2044b312a94cSmrg# Echo long help message to standard output and exit. 204565eef222Smrgfunc_help () 204665eef222Smrg{ 2047b312a94cSmrg $debug_cmd 2048b312a94cSmrg 2049b312a94cSmrg func_usage_message 2050b312a94cSmrg $ECHO "$long_help_message" 2051b312a94cSmrg exit 0 205265eef222Smrg} 205365eef222Smrg 2054b312a94cSmrg 2055b312a94cSmrg# func_missing_arg ARGNAME 2056b312a94cSmrg# ------------------------ 205765eef222Smrg# Echo program name prefixed message to standard error and set global 205865eef222Smrg# exit_cmd. 205965eef222Smrgfunc_missing_arg () 206065eef222Smrg{ 2061b312a94cSmrg $debug_cmd 2062200d7199Smrg 2063b312a94cSmrg func_error "Missing argument for '$1'." 206465eef222Smrg exit_cmd=exit 206565eef222Smrg} 206665eef222Smrg 206765eef222Smrg 2068b312a94cSmrg# func_split_equals STRING 2069b312a94cSmrg# ------------------------ 2070d5637ae9Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 2071d5637ae9Smrg# after splitting STRING at the '=' sign. 2072b312a94cSmrgtest -z "$_G_HAVE_XSI_OPS" \ 2073b312a94cSmrg && (eval 'x=a/b/c; 2074b312a94cSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 2075b312a94cSmrg && _G_HAVE_XSI_OPS=yes 2076b312a94cSmrg 2077b312a94cSmrgif test yes = "$_G_HAVE_XSI_OPS" 2078b312a94cSmrgthen 2079b312a94cSmrg # This is an XSI compatible shell, allowing a faster implementation... 2080b312a94cSmrg eval 'func_split_equals () 2081b312a94cSmrg { 2082b312a94cSmrg $debug_cmd 2083b312a94cSmrg 2084b312a94cSmrg func_split_equals_lhs=${1%%=*} 2085b312a94cSmrg func_split_equals_rhs=${1#*=} 2086d5637ae9Smrg if test "x$func_split_equals_lhs" = "x$1"; then 2087d5637ae9Smrg func_split_equals_rhs= 2088d5637ae9Smrg fi 2089b312a94cSmrg }' 2090b312a94cSmrgelse 2091b312a94cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 2092b312a94cSmrg func_split_equals () 2093b312a94cSmrg { 2094b312a94cSmrg $debug_cmd 2095b312a94cSmrg 2096b312a94cSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 2097b312a94cSmrg func_split_equals_rhs= 2098d5637ae9Smrg test "x$func_split_equals_lhs=" = "x$1" \ 2099b312a94cSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 2100b312a94cSmrg } 2101b312a94cSmrgfi #func_split_equals 2102b312a94cSmrg 2103b312a94cSmrg 2104b312a94cSmrg# func_split_short_opt SHORTOPT 2105b312a94cSmrg# ----------------------------- 2106200d7199Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 2107200d7199Smrg# variables after splitting SHORTOPT after the 2nd character. 2108b312a94cSmrgif test yes = "$_G_HAVE_XSI_OPS" 2109b312a94cSmrgthen 2110b312a94cSmrg # This is an XSI compatible shell, allowing a faster implementation... 2111b312a94cSmrg eval 'func_split_short_opt () 2112b312a94cSmrg { 2113b312a94cSmrg $debug_cmd 2114b312a94cSmrg 2115b312a94cSmrg func_split_short_opt_arg=${1#??} 2116b312a94cSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 2117b312a94cSmrg }' 2118b312a94cSmrgelse 2119b312a94cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 2120b312a94cSmrg func_split_short_opt () 2121b312a94cSmrg { 2122b312a94cSmrg $debug_cmd 2123b312a94cSmrg 2124d5637ae9Smrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 2125b312a94cSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 2126b312a94cSmrg } 2127b312a94cSmrgfi #func_split_short_opt 2128b312a94cSmrg 2129b312a94cSmrg 2130b312a94cSmrg# func_usage 2131b312a94cSmrg# ---------- 2132b312a94cSmrg# Echo short help message to standard output and exit. 2133b312a94cSmrgfunc_usage () 2134200d7199Smrg{ 2135b312a94cSmrg $debug_cmd 2136200d7199Smrg 2137b312a94cSmrg func_usage_message 2138b312a94cSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 2139b312a94cSmrg exit 0 2140b312a94cSmrg} 2141200d7199Smrg 2142200d7199Smrg 2143b312a94cSmrg# func_usage_message 2144b312a94cSmrg# ------------------ 2145b312a94cSmrg# Echo short help message to standard output. 2146b312a94cSmrgfunc_usage_message () 2147200d7199Smrg{ 2148b312a94cSmrg $debug_cmd 2149200d7199Smrg 2150b312a94cSmrg eval \$ECHO \""Usage: $usage"\" 2151b312a94cSmrg echo 2152b312a94cSmrg $SED -n 's|^# || 2153b312a94cSmrg /^Written by/{ 2154b312a94cSmrg x;p;x 2155b312a94cSmrg } 2156b312a94cSmrg h 2157b312a94cSmrg /^Written by/q' < "$progpath" 2158b312a94cSmrg echo 2159b312a94cSmrg eval \$ECHO \""$usage_message"\" 2160b312a94cSmrg} 2161200d7199Smrg 216265eef222Smrg 2163b312a94cSmrg# func_version 2164b312a94cSmrg# ------------ 2165b312a94cSmrg# Echo version message to standard output and exit. 2166d5637ae9Smrg# The version message is extracted from the calling file's header 2167d5637ae9Smrg# comments, with leading '# ' stripped: 2168d5637ae9Smrg# 1. First display the progname and version 2169d5637ae9Smrg# 2. Followed by the header comment line matching /^# Written by / 2170d5637ae9Smrg# 3. Then a blank line followed by the first following line matching 2171d5637ae9Smrg# /^# Copyright / 2172d5637ae9Smrg# 4. Immediately followed by any lines between the previous matches, 2173d5637ae9Smrg# except lines preceding the intervening completely blank line. 2174d5637ae9Smrg# For example, see the header comments of this file. 2175b312a94cSmrgfunc_version () 2176b312a94cSmrg{ 2177b312a94cSmrg $debug_cmd 217865eef222Smrg 2179b312a94cSmrg printf '%s\n' "$progname $scriptversion" 2180b312a94cSmrg $SED -n ' 2181d5637ae9Smrg /^# Written by /!b 2182d5637ae9Smrg s|^# ||; p; n 2183d5637ae9Smrg 2184d5637ae9Smrg :fwd2blnk 2185d5637ae9Smrg /./ { 2186d5637ae9Smrg n 2187d5637ae9Smrg b fwd2blnk 2188b312a94cSmrg } 2189d5637ae9Smrg p; n 2190d5637ae9Smrg 2191d5637ae9Smrg :holdwrnt 2192d5637ae9Smrg s|^# || 2193d5637ae9Smrg s|^# *$|| 2194d5637ae9Smrg /^Copyright /!{ 2195d5637ae9Smrg /./H 2196d5637ae9Smrg n 2197d5637ae9Smrg b holdwrnt 2198b312a94cSmrg } 2199d5637ae9Smrg 2200d5637ae9Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 2201d5637ae9Smrg G 2202d5637ae9Smrg s|\(\n\)\n*|\1|g 2203d5637ae9Smrg p; q' < "$progpath" 220465eef222Smrg 2205b312a94cSmrg exit $? 2206b312a94cSmrg} 220765eef222Smrg 2208ef981d24Smrg 2209b312a94cSmrg# Local variables: 2210b312a94cSmrg# mode: shell-script 2211b312a94cSmrg# sh-indentation: 2 2212b312a94cSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 2213d5637ae9Smrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 2214b312a94cSmrg# time-stamp-time-zone: "UTC" 2215b312a94cSmrg# End: 2216ef981d24Smrg 2217b312a94cSmrg# Set a version string. 2218d5637ae9Smrgscriptversion='(GNU libtool) 2.4.7' 2219ef981d24Smrg 2220ef981d24Smrg 2221b312a94cSmrg# func_echo ARG... 2222b312a94cSmrg# ---------------- 2223b312a94cSmrg# Libtool also displays the current mode in messages, so override 2224b312a94cSmrg# funclib.sh func_echo with this custom definition. 2225b312a94cSmrgfunc_echo () 2226200d7199Smrg{ 2227b312a94cSmrg $debug_cmd 2228200d7199Smrg 2229b312a94cSmrg _G_message=$* 2230b312a94cSmrg 2231b312a94cSmrg func_echo_IFS=$IFS 2232b312a94cSmrg IFS=$nl 2233b312a94cSmrg for _G_line in $_G_message; do 2234b312a94cSmrg IFS=$func_echo_IFS 2235b312a94cSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 2236b312a94cSmrg done 2237b312a94cSmrg IFS=$func_echo_IFS 2238b312a94cSmrg} 2239200d7199Smrg 2240200d7199Smrg 2241b312a94cSmrg# func_warning ARG... 2242b312a94cSmrg# ------------------- 2243b312a94cSmrg# Libtool warnings are not categorized, so override funclib.sh 2244b312a94cSmrg# func_warning with this simpler definition. 2245b312a94cSmrgfunc_warning () 2246200d7199Smrg{ 2247b312a94cSmrg $debug_cmd 2248200d7199Smrg 2249b312a94cSmrg $warning_func ${1+"$@"} 2250b312a94cSmrg} 2251200d7199Smrg 2252200d7199Smrg 2253b312a94cSmrg## ---------------- ## 2254b312a94cSmrg## Options parsing. ## 2255b312a94cSmrg## ---------------- ## 2256b312a94cSmrg 2257b312a94cSmrg# Hook in the functions to make sure our own options are parsed during 2258b312a94cSmrg# the option parsing loop. 2259b312a94cSmrg 2260b312a94cSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 2261b312a94cSmrg 2262b312a94cSmrg# Short help message in response to '-h'. 2263b312a94cSmrgusage_message="Options: 2264b312a94cSmrg --config show all configuration variables 2265b312a94cSmrg --debug enable verbose shell tracing 2266b312a94cSmrg -n, --dry-run display commands without modifying any files 2267b312a94cSmrg --features display basic configuration information and exit 2268b312a94cSmrg --mode=MODE use operation mode MODE 2269b312a94cSmrg --no-warnings equivalent to '-Wnone' 2270b312a94cSmrg --preserve-dup-deps don't remove duplicate dependency libraries 2271b312a94cSmrg --quiet, --silent don't print informational messages 2272b312a94cSmrg --tag=TAG use configuration variables from tag TAG 2273b312a94cSmrg -v, --verbose print more informational messages than default 2274b312a94cSmrg --version print version information 2275b312a94cSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2276b312a94cSmrg -h, --help, --help-all print short, long, or detailed help message 2277b312a94cSmrg" 2278200d7199Smrg 2279b312a94cSmrg# Additional text appended to 'usage_message' in response to '--help'. 2280b312a94cSmrgfunc_help () 2281200d7199Smrg{ 2282b312a94cSmrg $debug_cmd 2283b312a94cSmrg 2284b312a94cSmrg func_usage_message 2285b312a94cSmrg $ECHO "$long_help_message 2286b312a94cSmrg 2287b312a94cSmrgMODE must be one of the following: 2288b312a94cSmrg 2289b312a94cSmrg clean remove files from the build directory 2290b312a94cSmrg compile compile a source file into a libtool object 2291b312a94cSmrg execute automatically set library path, then run a program 2292b312a94cSmrg finish complete the installation of libtool libraries 2293b312a94cSmrg install install libraries or executables 2294b312a94cSmrg link create a library or an executable 2295b312a94cSmrg uninstall remove libraries from an installed directory 2296b312a94cSmrg 2297b312a94cSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 2298b312a94cSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2299b312a94cSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2300b312a94cSmrg 2301b312a94cSmrgWhen reporting a bug, please describe a test case to reproduce it and 2302b312a94cSmrginclude the following information: 2303b312a94cSmrg 2304b312a94cSmrg host-triplet: $host 2305b312a94cSmrg shell: $SHELL 2306b312a94cSmrg compiler: $LTCC 2307b312a94cSmrg compiler flags: $LTCFLAGS 2308b312a94cSmrg linker: $LD (gnu? $with_gnu_ld) 2309d5637ae9Smrg version: $progname (GNU libtool) 2.4.7 2310b312a94cSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2311b312a94cSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2312b312a94cSmrg 2313b312a94cSmrgReport bugs to <bug-libtool@gnu.org>. 2314b312a94cSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 2315b312a94cSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2316b312a94cSmrg exit 0 2317b312a94cSmrg} 2318200d7199Smrg 2319200d7199Smrg 2320b312a94cSmrg# func_lo2o OBJECT-NAME 2321b312a94cSmrg# --------------------- 2322b312a94cSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2323b312a94cSmrg# object suffix. 2324b312a94cSmrg 2325b312a94cSmrglo2o=s/\\.lo\$/.$objext/ 2326b312a94cSmrgo2lo=s/\\.$objext\$/.lo/ 2327b312a94cSmrg 2328b312a94cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 2329b312a94cSmrg eval 'func_lo2o () 2330b312a94cSmrg { 2331b312a94cSmrg case $1 in 2332b312a94cSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2333b312a94cSmrg * ) func_lo2o_result=$1 ;; 2334b312a94cSmrg esac 2335b312a94cSmrg }' 2336b312a94cSmrg 2337b312a94cSmrg # func_xform LIBOBJ-OR-SOURCE 2338b312a94cSmrg # --------------------------- 2339b312a94cSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2340b312a94cSmrg # suffix to a '.lo' libtool-object suffix. 2341b312a94cSmrg eval 'func_xform () 2342b312a94cSmrg { 2343b312a94cSmrg func_xform_result=${1%.*}.lo 2344b312a94cSmrg }' 2345b312a94cSmrgelse 2346b312a94cSmrg # ...otherwise fall back to using sed. 2347b312a94cSmrg func_lo2o () 2348b312a94cSmrg { 2349b312a94cSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2350b312a94cSmrg } 2351b312a94cSmrg 2352b312a94cSmrg func_xform () 2353b312a94cSmrg { 2354b312a94cSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2355b312a94cSmrg } 2356b312a94cSmrgfi 2357200d7199Smrg 2358200d7199Smrg 2359b312a94cSmrg# func_fatal_configuration ARG... 2360b312a94cSmrg# ------------------------------- 236165eef222Smrg# Echo program name prefixed message to standard error, followed by 236265eef222Smrg# a configuration failure hint, and exit. 236365eef222Smrgfunc_fatal_configuration () 236465eef222Smrg{ 2365d5637ae9Smrg func_fatal_error ${1+"$@"} \ 2366b312a94cSmrg "See the $PACKAGE documentation for more information." \ 2367b312a94cSmrg "Fatal configuration error." 236865eef222Smrg} 236965eef222Smrg 237065eef222Smrg 237165eef222Smrg# func_config 2372b312a94cSmrg# ----------- 237365eef222Smrg# Display the configuration for all the tags in this script. 237465eef222Smrgfunc_config () 237565eef222Smrg{ 237665eef222Smrg re_begincf='^# ### BEGIN LIBTOOL' 237765eef222Smrg re_endcf='^# ### END LIBTOOL' 237865eef222Smrg 237965eef222Smrg # Default configuration. 238065eef222Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2381ef981d24Smrg 2382ef981d24Smrg # Now print the configurations for the tags. 2383ef981d24Smrg for tagname in $taglist; do 238465eef222Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2385ef981d24Smrg done 2386ef981d24Smrg 238765eef222Smrg exit $? 238865eef222Smrg} 2389ef981d24Smrg 2390b312a94cSmrg 239165eef222Smrg# func_features 2392b312a94cSmrg# ------------- 239365eef222Smrg# Display the features supported by this script. 239465eef222Smrgfunc_features () 239565eef222Smrg{ 239656957a04Smrg echo "host: $host" 2397b312a94cSmrg if test yes = "$build_libtool_libs"; then 239856957a04Smrg echo "enable shared libraries" 2399ef981d24Smrg else 240056957a04Smrg echo "disable shared libraries" 2401ef981d24Smrg fi 2402b312a94cSmrg if test yes = "$build_old_libs"; then 240356957a04Smrg echo "enable static libraries" 2404ef981d24Smrg else 240556957a04Smrg echo "disable static libraries" 2406ef981d24Smrg fi 240765eef222Smrg 2408ef981d24Smrg exit $? 240965eef222Smrg} 241065eef222Smrg 2411b312a94cSmrg 2412b312a94cSmrg# func_enable_tag TAGNAME 2413b312a94cSmrg# ----------------------- 241465eef222Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 241565eef222Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 241665eef222Smrg# variable here. 241765eef222Smrgfunc_enable_tag () 241865eef222Smrg{ 2419b312a94cSmrg # Global variable: 2420b312a94cSmrg tagname=$1 2421ef981d24Smrg 2422b312a94cSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2423b312a94cSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2424b312a94cSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2425ef981d24Smrg 2426b312a94cSmrg # Validate tagname. 2427b312a94cSmrg case $tagname in 2428b312a94cSmrg *[!-_A-Za-z0-9,/]*) 2429b312a94cSmrg func_fatal_error "invalid tag name: $tagname" 2430b312a94cSmrg ;; 2431b312a94cSmrg esac 2432ef981d24Smrg 2433b312a94cSmrg # Don't test for the "default" C tag, as we know it's 2434b312a94cSmrg # there but not specially marked. 2435b312a94cSmrg case $tagname in 2436b312a94cSmrg CC) ;; 243765eef222Smrg *) 2438b312a94cSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2439b312a94cSmrg taglist="$taglist $tagname" 2440b312a94cSmrg 2441b312a94cSmrg # Evaluate the configuration. Be careful to quote the path 2442b312a94cSmrg # and the sed script, to avoid splitting on whitespace, but 2443b312a94cSmrg # also don't use non-portable quotes within backquotes within 2444b312a94cSmrg # quotes we have to do it in 2 steps: 2445b312a94cSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2446b312a94cSmrg eval "$extractedcf" 2447b312a94cSmrg else 2448b312a94cSmrg func_error "ignoring unknown tag $tagname" 2449b312a94cSmrg fi 2450b312a94cSmrg ;; 2451b312a94cSmrg esac 245265eef222Smrg} 2453ef981d24Smrg 2454b312a94cSmrg 2455200d7199Smrg# func_check_version_match 2456b312a94cSmrg# ------------------------ 2457200d7199Smrg# Ensure that we are using m4 macros, and libtool script from the same 2458200d7199Smrg# release of libtool. 2459200d7199Smrgfunc_check_version_match () 246065eef222Smrg{ 2461b312a94cSmrg if test "$package_revision" != "$macro_revision"; then 2462b312a94cSmrg if test "$VERSION" != "$macro_version"; then 2463b312a94cSmrg if test -z "$macro_version"; then 2464b312a94cSmrg cat >&2 <<_LT_EOF 2465200d7199Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2466200d7199Smrg$progname: definition of this LT_INIT comes from an older release. 2467200d7199Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2468200d7199Smrg$progname: and run autoconf again. 2469200d7199Smrg_LT_EOF 2470b312a94cSmrg else 2471b312a94cSmrg cat >&2 <<_LT_EOF 2472200d7199Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2473200d7199Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2474200d7199Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2475200d7199Smrg$progname: and run autoconf again. 2476200d7199Smrg_LT_EOF 2477b312a94cSmrg fi 2478b312a94cSmrg else 2479b312a94cSmrg cat >&2 <<_LT_EOF 2480200d7199Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2481200d7199Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2482200d7199Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2483200d7199Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 2484200d7199Smrg_LT_EOF 2485b312a94cSmrg fi 2486ef981d24Smrg 2487b312a94cSmrg exit $EXIT_MISMATCH 2488b312a94cSmrg fi 2489200d7199Smrg} 2490200d7199Smrg 2491200d7199Smrg 2492b312a94cSmrg# libtool_options_prep [ARG]... 2493b312a94cSmrg# ----------------------------- 2494b312a94cSmrg# Preparation for options parsed by libtool. 2495b312a94cSmrglibtool_options_prep () 2496b312a94cSmrg{ 2497b312a94cSmrg $debug_mode 2498ef981d24Smrg 2499b312a94cSmrg # Option defaults: 2500b312a94cSmrg opt_config=false 2501b312a94cSmrg opt_dlopen= 2502b312a94cSmrg opt_dry_run=false 2503b312a94cSmrg opt_help=false 2504b312a94cSmrg opt_mode= 2505b312a94cSmrg opt_preserve_dup_deps=false 2506b312a94cSmrg opt_quiet=false 2507200d7199Smrg 2508b312a94cSmrg nonopt= 2509b312a94cSmrg preserve_args= 2510200d7199Smrg 2511d5637ae9Smrg _G_rc_lt_options_prep=: 2512d5637ae9Smrg 2513b312a94cSmrg # Shorthand for --mode=foo, only valid as the first argument 2514b312a94cSmrg case $1 in 2515b312a94cSmrg clean|clea|cle|cl) 2516b312a94cSmrg shift; set dummy --mode clean ${1+"$@"}; shift 2517b312a94cSmrg ;; 2518b312a94cSmrg compile|compil|compi|comp|com|co|c) 2519b312a94cSmrg shift; set dummy --mode compile ${1+"$@"}; shift 2520b312a94cSmrg ;; 2521b312a94cSmrg execute|execut|execu|exec|exe|ex|e) 2522b312a94cSmrg shift; set dummy --mode execute ${1+"$@"}; shift 2523b312a94cSmrg ;; 2524b312a94cSmrg finish|finis|fini|fin|fi|f) 2525b312a94cSmrg shift; set dummy --mode finish ${1+"$@"}; shift 2526b312a94cSmrg ;; 2527b312a94cSmrg install|instal|insta|inst|ins|in|i) 2528b312a94cSmrg shift; set dummy --mode install ${1+"$@"}; shift 2529b312a94cSmrg ;; 2530b312a94cSmrg link|lin|li|l) 2531b312a94cSmrg shift; set dummy --mode link ${1+"$@"}; shift 2532b312a94cSmrg ;; 2533b312a94cSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2534b312a94cSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 2535b312a94cSmrg ;; 2536d5637ae9Smrg *) 2537d5637ae9Smrg _G_rc_lt_options_prep=false 2538d5637ae9Smrg ;; 2539b312a94cSmrg esac 2540b312a94cSmrg 2541d5637ae9Smrg if $_G_rc_lt_options_prep; then 2542d5637ae9Smrg # Pass back the list of options. 2543d5637ae9Smrg func_quote eval ${1+"$@"} 2544d5637ae9Smrg libtool_options_prep_result=$func_quote_result 2545d5637ae9Smrg fi 2546b312a94cSmrg} 2547b312a94cSmrgfunc_add_hook func_options_prep libtool_options_prep 2548200d7199Smrg 2549200d7199Smrg 2550b312a94cSmrg# libtool_parse_options [ARG]... 2551b312a94cSmrg# --------------------------------- 2552b312a94cSmrg# Provide handling for libtool specific options. 2553b312a94cSmrglibtool_parse_options () 2554200d7199Smrg{ 2555b312a94cSmrg $debug_cmd 255665eef222Smrg 2557d5637ae9Smrg _G_rc_lt_parse_options=false 2558d5637ae9Smrg 2559b312a94cSmrg # Perform our own loop to consume as many options as possible in 2560b312a94cSmrg # each iteration. 2561b312a94cSmrg while test $# -gt 0; do 2562d5637ae9Smrg _G_match_lt_parse_options=: 2563b312a94cSmrg _G_opt=$1 2564b312a94cSmrg shift 2565b312a94cSmrg case $_G_opt in 2566b312a94cSmrg --dry-run|--dryrun|-n) 2567b312a94cSmrg opt_dry_run=: 2568b312a94cSmrg ;; 2569b312a94cSmrg 2570b312a94cSmrg --config) func_config ;; 2571b312a94cSmrg 2572b312a94cSmrg --dlopen|-dlopen) 2573b312a94cSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 2574b312a94cSmrg}$1" 2575b312a94cSmrg shift 2576b312a94cSmrg ;; 2577b312a94cSmrg 2578b312a94cSmrg --preserve-dup-deps) 2579b312a94cSmrg opt_preserve_dup_deps=: ;; 2580b312a94cSmrg 2581b312a94cSmrg --features) func_features ;; 2582b312a94cSmrg 2583b312a94cSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2584b312a94cSmrg 2585b312a94cSmrg --help) opt_help=: ;; 2586b312a94cSmrg 2587b312a94cSmrg --help-all) opt_help=': help-all' ;; 2588b312a94cSmrg 2589b312a94cSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 2590b312a94cSmrg opt_mode=$1 2591b312a94cSmrg case $1 in 2592b312a94cSmrg # Valid mode arguments: 2593b312a94cSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 2594b312a94cSmrg 2595b312a94cSmrg # Catch anything else as an error 2596b312a94cSmrg *) func_error "invalid argument for $_G_opt" 2597b312a94cSmrg exit_cmd=exit 2598b312a94cSmrg break 2599b312a94cSmrg ;; 2600b312a94cSmrg esac 2601b312a94cSmrg shift 2602b312a94cSmrg ;; 2603b312a94cSmrg 2604b312a94cSmrg --no-silent|--no-quiet) 2605b312a94cSmrg opt_quiet=false 2606b312a94cSmrg func_append preserve_args " $_G_opt" 2607b312a94cSmrg ;; 2608b312a94cSmrg 2609b312a94cSmrg --no-warnings|--no-warning|--no-warn) 2610b312a94cSmrg opt_warning=false 2611b312a94cSmrg func_append preserve_args " $_G_opt" 2612b312a94cSmrg ;; 2613b312a94cSmrg 2614b312a94cSmrg --no-verbose) 2615b312a94cSmrg opt_verbose=false 2616b312a94cSmrg func_append preserve_args " $_G_opt" 2617b312a94cSmrg ;; 2618b312a94cSmrg 2619b312a94cSmrg --silent|--quiet) 2620b312a94cSmrg opt_quiet=: 2621b312a94cSmrg opt_verbose=false 2622b312a94cSmrg func_append preserve_args " $_G_opt" 2623b312a94cSmrg ;; 2624b312a94cSmrg 2625b312a94cSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 2626b312a94cSmrg opt_tag=$1 2627b312a94cSmrg func_append preserve_args " $_G_opt $1" 2628b312a94cSmrg func_enable_tag "$1" 2629b312a94cSmrg shift 2630b312a94cSmrg ;; 2631b312a94cSmrg 2632b312a94cSmrg --verbose|-v) opt_quiet=false 2633b312a94cSmrg opt_verbose=: 2634b312a94cSmrg func_append preserve_args " $_G_opt" 2635b312a94cSmrg ;; 2636b312a94cSmrg 2637d5637ae9Smrg # An option not handled by this hook function: 2638d5637ae9Smrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 2639d5637ae9Smrg _G_match_lt_parse_options=false 2640d5637ae9Smrg break 2641d5637ae9Smrg ;; 2642b312a94cSmrg esac 2643d5637ae9Smrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 2644b312a94cSmrg done 2645200d7199Smrg 2646d5637ae9Smrg if $_G_rc_lt_parse_options; then 2647d5637ae9Smrg # save modified positional parameters for caller 2648d5637ae9Smrg func_quote eval ${1+"$@"} 2649d5637ae9Smrg libtool_parse_options_result=$func_quote_result 2650d5637ae9Smrg fi 2651b312a94cSmrg} 2652b312a94cSmrgfunc_add_hook func_parse_options libtool_parse_options 265365eef222Smrg 2654ef981d24Smrg 265565eef222Smrg 2656b312a94cSmrg# libtool_validate_options [ARG]... 2657b312a94cSmrg# --------------------------------- 2658b312a94cSmrg# Perform any sanity checks on option settings and/or unconsumed 2659b312a94cSmrg# arguments. 2660b312a94cSmrglibtool_validate_options () 2661b312a94cSmrg{ 2662b312a94cSmrg # save first non-option argument 2663b312a94cSmrg if test 0 -lt $#; then 2664b312a94cSmrg nonopt=$1 2665b312a94cSmrg shift 266665eef222Smrg fi 266765eef222Smrg 2668b312a94cSmrg # preserve --debug 2669b312a94cSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 267065eef222Smrg 2671b312a94cSmrg case $host in 2672b312a94cSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2673b312a94cSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2674b312a94cSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2675b312a94cSmrg # don't eliminate duplications in $postdeps and $predeps 2676b312a94cSmrg opt_duplicate_compiler_generated_deps=: 2677b312a94cSmrg ;; 2678b312a94cSmrg *) 2679b312a94cSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2680b312a94cSmrg ;; 2681b312a94cSmrg esac 268265eef222Smrg 2683b312a94cSmrg $opt_help || { 2684b312a94cSmrg # Sanity checks first: 2685b312a94cSmrg func_check_version_match 2686b312a94cSmrg 2687b312a94cSmrg test yes != "$build_libtool_libs" \ 2688b312a94cSmrg && test yes != "$build_old_libs" \ 2689b312a94cSmrg && func_fatal_configuration "not configured to build any kind of library" 269065eef222Smrg 2691b312a94cSmrg # Darwin sucks 2692b312a94cSmrg eval std_shrext=\"$shrext_cmds\" 269365eef222Smrg 2694b312a94cSmrg # Only execute mode is allowed to have -dlopen flags. 2695b312a94cSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2696b312a94cSmrg func_error "unrecognized option '-dlopen'" 2697b312a94cSmrg $ECHO "$help" 1>&2 2698b312a94cSmrg exit $EXIT_FAILURE 2699b312a94cSmrg fi 2700b312a94cSmrg 2701b312a94cSmrg # Change the help message to a mode-specific one. 2702b312a94cSmrg generic_help=$help 2703b312a94cSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 2704b312a94cSmrg } 2705b312a94cSmrg 2706b312a94cSmrg # Pass back the unparsed argument list 2707d5637ae9Smrg func_quote eval ${1+"$@"} 2708d5637ae9Smrg libtool_validate_options_result=$func_quote_result 2709200d7199Smrg} 2710b312a94cSmrgfunc_add_hook func_validate_options libtool_validate_options 271165eef222Smrg 271265eef222Smrg 2713b312a94cSmrg# Process options as early as possible so that --help and --version 2714b312a94cSmrg# can return quickly. 2715b312a94cSmrgfunc_options ${1+"$@"} 2716b312a94cSmrgeval set dummy "$func_options_result"; shift 2717b312a94cSmrg 2718ef981d24Smrg 2719ef981d24Smrg 2720200d7199Smrg## ----------- ## 2721200d7199Smrg## Main. ## 2722200d7199Smrg## ----------- ## 2723ef981d24Smrg 2724b312a94cSmrgmagic='%%%MAGIC variable%%%' 2725b312a94cSmrgmagic_exe='%%%MAGIC EXE variable%%%' 2726b312a94cSmrg 2727b312a94cSmrg# Global variables. 2728b312a94cSmrgextracted_archives= 2729b312a94cSmrgextracted_serial=0 2730b312a94cSmrg 2731b312a94cSmrg# If this variable is set in any of the actions, the command in it 2732b312a94cSmrg# will be execed at the end. This prevents here-documents from being 2733b312a94cSmrg# left over by shells. 2734b312a94cSmrgexec_cmd= 2735b312a94cSmrg 2736b312a94cSmrg 2737b312a94cSmrg# A function that is used when there is no print builtin or printf. 2738b312a94cSmrgfunc_fallback_echo () 2739b312a94cSmrg{ 2740b312a94cSmrg eval 'cat <<_LTECHO_EOF 2741b312a94cSmrg$1 2742b312a94cSmrg_LTECHO_EOF' 2743b312a94cSmrg} 2744b312a94cSmrg 2745b312a94cSmrg# func_generated_by_libtool 2746b312a94cSmrg# True iff stdin has been generated by Libtool. This function is only 2747b312a94cSmrg# a basic sanity check; it will hardly flush out determined imposters. 2748b312a94cSmrgfunc_generated_by_libtool_p () 2749b312a94cSmrg{ 2750b312a94cSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2751b312a94cSmrg} 2752b312a94cSmrg 275365eef222Smrg# func_lalib_p file 2754b312a94cSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 275565eef222Smrg# This function is only a basic sanity check; it will hardly flush out 275665eef222Smrg# determined imposters. 275765eef222Smrgfunc_lalib_p () 275865eef222Smrg{ 275965eef222Smrg test -f "$1" && 2760b312a94cSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 276165eef222Smrg} 2762ef981d24Smrg 276365eef222Smrg# func_lalib_unsafe_p file 2764b312a94cSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 276565eef222Smrg# This function implements the same check as func_lalib_p without 276665eef222Smrg# resorting to external programs. To this end, it redirects stdin and 276765eef222Smrg# closes it afterwards, without saving the original file descriptor. 276865eef222Smrg# As a safety measure, use it only where a negative result would be 2769b312a94cSmrg# fatal anyway. Works if 'file' does not exist. 277065eef222Smrgfunc_lalib_unsafe_p () 277165eef222Smrg{ 277265eef222Smrg lalib_p=no 277365eef222Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 277465eef222Smrg for lalib_p_l in 1 2 3 4 277565eef222Smrg do 277665eef222Smrg read lalib_p_line 2777b312a94cSmrg case $lalib_p_line in 277865eef222Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 277965eef222Smrg esac 278065eef222Smrg done 278165eef222Smrg exec 0<&5 5<&- 278265eef222Smrg fi 2783b312a94cSmrg test yes = "$lalib_p" 278465eef222Smrg} 2785ef981d24Smrg 278665eef222Smrg# func_ltwrapper_script_p file 278765eef222Smrg# True iff FILE is a libtool wrapper script 278865eef222Smrg# This function is only a basic sanity check; it will hardly flush out 278965eef222Smrg# determined imposters. 279065eef222Smrgfunc_ltwrapper_script_p () 279165eef222Smrg{ 2792b312a94cSmrg test -f "$1" && 2793b312a94cSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 279465eef222Smrg} 2795ef981d24Smrg 279665eef222Smrg# func_ltwrapper_executable_p file 279765eef222Smrg# True iff FILE is a libtool wrapper executable 279865eef222Smrg# This function is only a basic sanity check; it will hardly flush out 279965eef222Smrg# determined imposters. 280065eef222Smrgfunc_ltwrapper_executable_p () 280165eef222Smrg{ 280265eef222Smrg func_ltwrapper_exec_suffix= 280365eef222Smrg case $1 in 280465eef222Smrg *.exe) ;; 280565eef222Smrg *) func_ltwrapper_exec_suffix=.exe ;; 280665eef222Smrg esac 280765eef222Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 280865eef222Smrg} 2809ef981d24Smrg 281065eef222Smrg# func_ltwrapper_scriptname file 281165eef222Smrg# Assumes file is an ltwrapper_executable 281265eef222Smrg# uses $file to determine the appropriate filename for a 281365eef222Smrg# temporary ltwrapper_script. 281465eef222Smrgfunc_ltwrapper_scriptname () 281565eef222Smrg{ 2816200d7199Smrg func_dirname_and_basename "$1" "" "." 2817200d7199Smrg func_stripname '' '.exe' "$func_basename_result" 2818b312a94cSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 281965eef222Smrg} 2820ef981d24Smrg 282165eef222Smrg# func_ltwrapper_p file 282265eef222Smrg# True iff FILE is a libtool wrapper script or wrapper executable 282365eef222Smrg# This function is only a basic sanity check; it will hardly flush out 282465eef222Smrg# determined imposters. 282565eef222Smrgfunc_ltwrapper_p () 282665eef222Smrg{ 282765eef222Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 282865eef222Smrg} 2829ef981d24Smrg 2830ef981d24Smrg 283165eef222Smrg# func_execute_cmds commands fail_cmd 283265eef222Smrg# Execute tilde-delimited COMMANDS. 283365eef222Smrg# If FAIL_CMD is given, eval that upon failure. 283465eef222Smrg# FAIL_CMD may read-access the current command in variable CMD! 283565eef222Smrgfunc_execute_cmds () 283665eef222Smrg{ 2837b312a94cSmrg $debug_cmd 2838b312a94cSmrg 283965eef222Smrg save_ifs=$IFS; IFS='~' 284065eef222Smrg for cmd in $1; do 2841b312a94cSmrg IFS=$sp$nl 284265eef222Smrg eval cmd=\"$cmd\" 2843b312a94cSmrg IFS=$save_ifs 284465eef222Smrg func_show_eval "$cmd" "${2-:}" 284565eef222Smrg done 284665eef222Smrg IFS=$save_ifs 284765eef222Smrg} 284865eef222Smrg 284965eef222Smrg 285065eef222Smrg# func_source file 285165eef222Smrg# Source FILE, adding directory component if necessary. 285265eef222Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 285365eef222Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 285465eef222Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 2855b312a94cSmrg# 'FILE.' does not work on cygwin managed mounts. 285665eef222Smrgfunc_source () 285765eef222Smrg{ 2858b312a94cSmrg $debug_cmd 2859b312a94cSmrg 286065eef222Smrg case $1 in 286165eef222Smrg */* | *\\*) . "$1" ;; 286265eef222Smrg *) . "./$1" ;; 286365eef222Smrg esac 286465eef222Smrg} 286565eef222Smrg 286665eef222Smrg 2867200d7199Smrg# func_resolve_sysroot PATH 2868200d7199Smrg# Replace a leading = in PATH with a sysroot. Store the result into 2869200d7199Smrg# func_resolve_sysroot_result 2870200d7199Smrgfunc_resolve_sysroot () 2871200d7199Smrg{ 2872200d7199Smrg func_resolve_sysroot_result=$1 2873200d7199Smrg case $func_resolve_sysroot_result in 2874200d7199Smrg =*) 2875200d7199Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 2876200d7199Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2877200d7199Smrg ;; 2878200d7199Smrg esac 2879200d7199Smrg} 2880200d7199Smrg 2881200d7199Smrg# func_replace_sysroot PATH 2882200d7199Smrg# If PATH begins with the sysroot, replace it with = and 2883200d7199Smrg# store the result into func_replace_sysroot_result. 2884200d7199Smrgfunc_replace_sysroot () 2885200d7199Smrg{ 2886b312a94cSmrg case $lt_sysroot:$1 in 2887200d7199Smrg ?*:"$lt_sysroot"*) 2888200d7199Smrg func_stripname "$lt_sysroot" '' "$1" 2889b312a94cSmrg func_replace_sysroot_result='='$func_stripname_result 2890200d7199Smrg ;; 2891200d7199Smrg *) 2892200d7199Smrg # Including no sysroot. 2893200d7199Smrg func_replace_sysroot_result=$1 2894200d7199Smrg ;; 2895200d7199Smrg esac 2896200d7199Smrg} 2897200d7199Smrg 289865eef222Smrg# func_infer_tag arg 289965eef222Smrg# Infer tagged configuration to use if any are available and 290065eef222Smrg# if one wasn't chosen via the "--tag" command line option. 290165eef222Smrg# Only attempt this if the compiler in the base compile 290265eef222Smrg# command doesn't match the default compiler. 290365eef222Smrg# arg is usually of the form 'gcc ...' 290465eef222Smrgfunc_infer_tag () 290565eef222Smrg{ 2906b312a94cSmrg $debug_cmd 2907b312a94cSmrg 290865eef222Smrg if test -n "$available_tags" && test -z "$tagname"; then 290965eef222Smrg CC_quoted= 291065eef222Smrg for arg in $CC; do 2911200d7199Smrg func_append_quoted CC_quoted "$arg" 291265eef222Smrg done 291356957a04Smrg CC_expanded=`func_echo_all $CC` 291456957a04Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 291565eef222Smrg case $@ in 291665eef222Smrg # Blanks in the command may have been stripped by the calling shell, 291765eef222Smrg # but not from the CC environment variable when configure was run. 291856957a04Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 291956957a04Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 292065eef222Smrg # Blanks at the start of $base_compile will cause this to fail 292165eef222Smrg # if we don't check for them as well. 292265eef222Smrg *) 292365eef222Smrg for z in $available_tags; do 292465eef222Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 292565eef222Smrg # Evaluate the configuration. 2926b312a94cSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 292765eef222Smrg CC_quoted= 292865eef222Smrg for arg in $CC; do 292965eef222Smrg # Double-quote args containing other shell metacharacters. 2930200d7199Smrg func_append_quoted CC_quoted "$arg" 293165eef222Smrg done 293256957a04Smrg CC_expanded=`func_echo_all $CC` 293356957a04Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 293465eef222Smrg case "$@ " in 293556957a04Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 293656957a04Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 293765eef222Smrg # The compiler in the base compile command matches 293865eef222Smrg # the one in the tagged configuration. 293965eef222Smrg # Assume this is the tagged configuration we want. 294065eef222Smrg tagname=$z 294165eef222Smrg break 294265eef222Smrg ;; 2943ef981d24Smrg esac 294465eef222Smrg fi 294565eef222Smrg done 294665eef222Smrg # If $tagname still isn't set, then no tagged configuration 294765eef222Smrg # was found and let the user know that the "--tag" command 294865eef222Smrg # line option must be used. 294965eef222Smrg if test -z "$tagname"; then 295065eef222Smrg func_echo "unable to infer tagged configuration" 2951b312a94cSmrg func_fatal_error "specify a tag with '--tag'" 295265eef222Smrg# else 295365eef222Smrg# func_verbose "using $tagname tagged configuration" 295465eef222Smrg fi 295565eef222Smrg ;; 295665eef222Smrg esac 295765eef222Smrg fi 295865eef222Smrg} 295965eef222Smrg 296065eef222Smrg 296165eef222Smrg 2962200d7199Smrg# func_write_libtool_object output_name pic_name nonpic_name 2963200d7199Smrg# Create a libtool object file (analogous to a ".la" file), 2964200d7199Smrg# but don't create it if we're doing a dry run. 2965200d7199Smrgfunc_write_libtool_object () 2966200d7199Smrg{ 2967b312a94cSmrg write_libobj=$1 2968b312a94cSmrg if test yes = "$build_libtool_libs"; then 2969b312a94cSmrg write_lobj=\'$2\' 2970200d7199Smrg else 2971200d7199Smrg write_lobj=none 2972200d7199Smrg fi 2973200d7199Smrg 2974b312a94cSmrg if test yes = "$build_old_libs"; then 2975b312a94cSmrg write_oldobj=\'$3\' 2976200d7199Smrg else 2977200d7199Smrg write_oldobj=none 2978200d7199Smrg fi 2979200d7199Smrg 2980200d7199Smrg $opt_dry_run || { 2981200d7199Smrg cat >${write_libobj}T <<EOF 2982200d7199Smrg# $write_libobj - a libtool object file 2983b312a94cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2984200d7199Smrg# 2985200d7199Smrg# Please DO NOT delete this file! 2986200d7199Smrg# It is necessary for linking the library. 2987200d7199Smrg 2988200d7199Smrg# Name of the PIC object. 2989200d7199Smrgpic_object=$write_lobj 2990200d7199Smrg 2991200d7199Smrg# Name of the non-PIC object 2992200d7199Smrgnon_pic_object=$write_oldobj 2993200d7199Smrg 2994200d7199SmrgEOF 2995b312a94cSmrg $MV "${write_libobj}T" "$write_libobj" 2996200d7199Smrg } 2997200d7199Smrg} 2998200d7199Smrg 2999200d7199Smrg 3000200d7199Smrg################################################## 3001200d7199Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 3002200d7199Smrg################################################## 3003200d7199Smrg 3004200d7199Smrg# func_convert_core_file_wine_to_w32 ARG 3005200d7199Smrg# Helper function used by file name conversion functions when $build is *nix, 3006200d7199Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 3007200d7199Smrg# correctly configured wine environment available, with the winepath program 3008200d7199Smrg# in $build's $PATH. 3009200d7199Smrg# 3010200d7199Smrg# ARG is the $build file name to be converted to w32 format. 3011200d7199Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 3012200d7199Smrg# be empty on error (or when ARG is empty) 3013200d7199Smrgfunc_convert_core_file_wine_to_w32 () 3014200d7199Smrg{ 3015b312a94cSmrg $debug_cmd 3016b312a94cSmrg 3017b312a94cSmrg func_convert_core_file_wine_to_w32_result=$1 3018200d7199Smrg if test -n "$1"; then 3019200d7199Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 3020200d7199Smrg # are forced to check the contents of stdout. On the other hand, if the 3021200d7199Smrg # command is not found, the shell will set an exit code of 127 and print 3022200d7199Smrg # *an error message* to stdout. So we must check for both error code of 3023200d7199Smrg # zero AND non-empty stdout, which explains the odd construction: 3024200d7199Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 3025b312a94cSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 3026200d7199Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 3027b312a94cSmrg $SED -e "$sed_naive_backslashify"` 3028200d7199Smrg else 3029200d7199Smrg func_convert_core_file_wine_to_w32_result= 3030200d7199Smrg fi 3031200d7199Smrg fi 3032200d7199Smrg} 3033200d7199Smrg# end: func_convert_core_file_wine_to_w32 3034200d7199Smrg 3035200d7199Smrg 3036200d7199Smrg# func_convert_core_path_wine_to_w32 ARG 3037200d7199Smrg# Helper function used by path conversion functions when $build is *nix, and 3038200d7199Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 3039200d7199Smrg# configured wine environment available, with the winepath program in $build's 3040200d7199Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 3041200d7199Smrg# 3042200d7199Smrg# ARG is path to be converted from $build format to win32. 3043200d7199Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 3044200d7199Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 3045200d7199Smrg# are convertible, then the result may be empty. 3046200d7199Smrgfunc_convert_core_path_wine_to_w32 () 3047200d7199Smrg{ 3048b312a94cSmrg $debug_cmd 3049b312a94cSmrg 3050200d7199Smrg # unfortunately, winepath doesn't convert paths, only file names 3051b312a94cSmrg func_convert_core_path_wine_to_w32_result= 3052200d7199Smrg if test -n "$1"; then 3053200d7199Smrg oldIFS=$IFS 3054200d7199Smrg IFS=: 3055200d7199Smrg for func_convert_core_path_wine_to_w32_f in $1; do 3056200d7199Smrg IFS=$oldIFS 3057200d7199Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 3058b312a94cSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 3059200d7199Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 3060b312a94cSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 3061200d7199Smrg else 3062200d7199Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 3063200d7199Smrg fi 3064200d7199Smrg fi 3065200d7199Smrg done 3066200d7199Smrg IFS=$oldIFS 3067200d7199Smrg fi 3068200d7199Smrg} 3069200d7199Smrg# end: func_convert_core_path_wine_to_w32 3070200d7199Smrg 3071200d7199Smrg 3072200d7199Smrg# func_cygpath ARGS... 3073200d7199Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 3074200d7199Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 3075200d7199Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 3076200d7199Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 3077200d7199Smrg# file name or path is assumed to be in w32 format, as previously converted 3078200d7199Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 3079200d7199Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 3080200d7199Smrg# Cygwin format). Returns an empty string on error. 3081200d7199Smrg# 3082200d7199Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 3083200d7199Smrg# be converted. 3084200d7199Smrg# 3085200d7199Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 3086200d7199Smrg# environment variable; do not put it in $PATH. 3087200d7199Smrgfunc_cygpath () 3088200d7199Smrg{ 3089b312a94cSmrg $debug_cmd 3090b312a94cSmrg 3091200d7199Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 3092200d7199Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 3093200d7199Smrg if test "$?" -ne 0; then 3094200d7199Smrg # on failure, ensure result is empty 3095200d7199Smrg func_cygpath_result= 3096200d7199Smrg fi 3097200d7199Smrg else 3098200d7199Smrg func_cygpath_result= 3099b312a94cSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 3100200d7199Smrg fi 3101200d7199Smrg} 3102200d7199Smrg#end: func_cygpath 3103200d7199Smrg 3104200d7199Smrg 3105200d7199Smrg# func_convert_core_msys_to_w32 ARG 3106200d7199Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 3107200d7199Smrg# result in func_convert_core_msys_to_w32_result. 3108200d7199Smrgfunc_convert_core_msys_to_w32 () 3109200d7199Smrg{ 3110b312a94cSmrg $debug_cmd 3111b312a94cSmrg 3112200d7199Smrg # awkward: cmd appends spaces to result 3113200d7199Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 3114b312a94cSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 3115200d7199Smrg} 3116200d7199Smrg#end: func_convert_core_msys_to_w32 3117200d7199Smrg 3118200d7199Smrg 3119200d7199Smrg# func_convert_file_check ARG1 ARG2 3120200d7199Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 3121200d7199Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 3122200d7199Smrg# func_to_host_file_result to ARG1). 3123200d7199Smrgfunc_convert_file_check () 3124200d7199Smrg{ 3125b312a94cSmrg $debug_cmd 3126b312a94cSmrg 3127b312a94cSmrg if test -z "$2" && test -n "$1"; then 3128200d7199Smrg func_error "Could not determine host file name corresponding to" 3129b312a94cSmrg func_error " '$1'" 3130200d7199Smrg func_error "Continuing, but uninstalled executables may not work." 3131200d7199Smrg # Fallback: 3132b312a94cSmrg func_to_host_file_result=$1 3133200d7199Smrg fi 3134200d7199Smrg} 3135200d7199Smrg# end func_convert_file_check 3136200d7199Smrg 3137200d7199Smrg 3138200d7199Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 3139200d7199Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 3140200d7199Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 3141200d7199Smrg# func_to_host_file_result to a simplistic fallback value (see below). 3142200d7199Smrgfunc_convert_path_check () 3143200d7199Smrg{ 3144b312a94cSmrg $debug_cmd 3145b312a94cSmrg 3146200d7199Smrg if test -z "$4" && test -n "$3"; then 3147200d7199Smrg func_error "Could not determine the host path corresponding to" 3148b312a94cSmrg func_error " '$3'" 3149200d7199Smrg func_error "Continuing, but uninstalled executables may not work." 3150200d7199Smrg # Fallback. This is a deliberately simplistic "conversion" and 3151200d7199Smrg # should not be "improved". See libtool.info. 3152200d7199Smrg if test "x$1" != "x$2"; then 3153200d7199Smrg lt_replace_pathsep_chars="s|$1|$2|g" 3154200d7199Smrg func_to_host_path_result=`echo "$3" | 3155200d7199Smrg $SED -e "$lt_replace_pathsep_chars"` 3156200d7199Smrg else 3157b312a94cSmrg func_to_host_path_result=$3 3158200d7199Smrg fi 3159200d7199Smrg fi 3160200d7199Smrg} 3161200d7199Smrg# end func_convert_path_check 3162200d7199Smrg 3163200d7199Smrg 3164200d7199Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 3165200d7199Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 3166200d7199Smrg# and appending REPL if ORIG matches BACKPAT. 3167200d7199Smrgfunc_convert_path_front_back_pathsep () 3168200d7199Smrg{ 3169b312a94cSmrg $debug_cmd 3170b312a94cSmrg 3171200d7199Smrg case $4 in 3172b312a94cSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 3173200d7199Smrg ;; 3174200d7199Smrg esac 3175200d7199Smrg case $4 in 3176200d7199Smrg $2 ) func_append func_to_host_path_result "$3" 3177200d7199Smrg ;; 3178200d7199Smrg esac 3179200d7199Smrg} 3180200d7199Smrg# end func_convert_path_front_back_pathsep 3181200d7199Smrg 3182200d7199Smrg 3183200d7199Smrg################################################## 3184200d7199Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 3185200d7199Smrg################################################## 3186b312a94cSmrg# invoked via '$to_host_file_cmd ARG' 3187200d7199Smrg# 3188200d7199Smrg# In each case, ARG is the path to be converted from $build to $host format. 3189200d7199Smrg# Result will be available in $func_to_host_file_result. 3190200d7199Smrg 3191200d7199Smrg 3192200d7199Smrg# func_to_host_file ARG 3193200d7199Smrg# Converts the file name ARG from $build format to $host format. Return result 3194200d7199Smrg# in func_to_host_file_result. 3195200d7199Smrgfunc_to_host_file () 3196200d7199Smrg{ 3197b312a94cSmrg $debug_cmd 3198b312a94cSmrg 3199200d7199Smrg $to_host_file_cmd "$1" 3200200d7199Smrg} 3201200d7199Smrg# end func_to_host_file 3202200d7199Smrg 3203200d7199Smrg 3204200d7199Smrg# func_to_tool_file ARG LAZY 3205200d7199Smrg# converts the file name ARG from $build format to toolchain format. Return 3206200d7199Smrg# result in func_to_tool_file_result. If the conversion in use is listed 3207200d7199Smrg# in (the comma separated) LAZY, no conversion takes place. 3208200d7199Smrgfunc_to_tool_file () 3209200d7199Smrg{ 3210b312a94cSmrg $debug_cmd 3211b312a94cSmrg 3212200d7199Smrg case ,$2, in 3213200d7199Smrg *,"$to_tool_file_cmd",*) 3214200d7199Smrg func_to_tool_file_result=$1 3215200d7199Smrg ;; 3216200d7199Smrg *) 3217200d7199Smrg $to_tool_file_cmd "$1" 3218200d7199Smrg func_to_tool_file_result=$func_to_host_file_result 3219200d7199Smrg ;; 3220200d7199Smrg esac 3221200d7199Smrg} 3222200d7199Smrg# end func_to_tool_file 3223200d7199Smrg 3224200d7199Smrg 3225200d7199Smrg# func_convert_file_noop ARG 3226200d7199Smrg# Copy ARG to func_to_host_file_result. 3227200d7199Smrgfunc_convert_file_noop () 3228200d7199Smrg{ 3229b312a94cSmrg func_to_host_file_result=$1 3230200d7199Smrg} 3231200d7199Smrg# end func_convert_file_noop 3232200d7199Smrg 3233200d7199Smrg 3234200d7199Smrg# func_convert_file_msys_to_w32 ARG 3235200d7199Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 3236200d7199Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 3237200d7199Smrg# func_to_host_file_result. 3238200d7199Smrgfunc_convert_file_msys_to_w32 () 3239200d7199Smrg{ 3240b312a94cSmrg $debug_cmd 3241b312a94cSmrg 3242b312a94cSmrg func_to_host_file_result=$1 3243200d7199Smrg if test -n "$1"; then 3244200d7199Smrg func_convert_core_msys_to_w32 "$1" 3245b312a94cSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 3246200d7199Smrg fi 3247200d7199Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3248200d7199Smrg} 3249200d7199Smrg# end func_convert_file_msys_to_w32 3250200d7199Smrg 3251200d7199Smrg 3252200d7199Smrg# func_convert_file_cygwin_to_w32 ARG 3253200d7199Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3254200d7199Smrg# func_to_host_file_result. 3255200d7199Smrgfunc_convert_file_cygwin_to_w32 () 3256200d7199Smrg{ 3257b312a94cSmrg $debug_cmd 3258b312a94cSmrg 3259b312a94cSmrg func_to_host_file_result=$1 3260200d7199Smrg if test -n "$1"; then 3261200d7199Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3262200d7199Smrg # LT_CYGPATH in this case. 3263200d7199Smrg func_to_host_file_result=`cygpath -m "$1"` 3264200d7199Smrg fi 3265200d7199Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3266200d7199Smrg} 3267200d7199Smrg# end func_convert_file_cygwin_to_w32 3268200d7199Smrg 3269200d7199Smrg 3270200d7199Smrg# func_convert_file_nix_to_w32 ARG 3271200d7199Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3272200d7199Smrg# and a working winepath. Returns result in func_to_host_file_result. 3273200d7199Smrgfunc_convert_file_nix_to_w32 () 3274200d7199Smrg{ 3275b312a94cSmrg $debug_cmd 3276b312a94cSmrg 3277b312a94cSmrg func_to_host_file_result=$1 3278200d7199Smrg if test -n "$1"; then 3279200d7199Smrg func_convert_core_file_wine_to_w32 "$1" 3280b312a94cSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3281200d7199Smrg fi 3282200d7199Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3283200d7199Smrg} 3284200d7199Smrg# end func_convert_file_nix_to_w32 3285200d7199Smrg 3286200d7199Smrg 3287200d7199Smrg# func_convert_file_msys_to_cygwin ARG 3288200d7199Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3289200d7199Smrg# Returns result in func_to_host_file_result. 3290200d7199Smrgfunc_convert_file_msys_to_cygwin () 3291200d7199Smrg{ 3292b312a94cSmrg $debug_cmd 3293b312a94cSmrg 3294b312a94cSmrg func_to_host_file_result=$1 3295200d7199Smrg if test -n "$1"; then 3296200d7199Smrg func_convert_core_msys_to_w32 "$1" 3297200d7199Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 3298b312a94cSmrg func_to_host_file_result=$func_cygpath_result 3299200d7199Smrg fi 3300200d7199Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3301200d7199Smrg} 3302200d7199Smrg# end func_convert_file_msys_to_cygwin 3303200d7199Smrg 3304200d7199Smrg 3305200d7199Smrg# func_convert_file_nix_to_cygwin ARG 3306200d7199Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3307200d7199Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3308200d7199Smrg# in func_to_host_file_result. 3309200d7199Smrgfunc_convert_file_nix_to_cygwin () 3310200d7199Smrg{ 3311b312a94cSmrg $debug_cmd 3312b312a94cSmrg 3313b312a94cSmrg func_to_host_file_result=$1 3314200d7199Smrg if test -n "$1"; then 3315200d7199Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3316200d7199Smrg func_convert_core_file_wine_to_w32 "$1" 3317200d7199Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3318b312a94cSmrg func_to_host_file_result=$func_cygpath_result 3319200d7199Smrg fi 3320200d7199Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3321200d7199Smrg} 3322200d7199Smrg# end func_convert_file_nix_to_cygwin 3323200d7199Smrg 3324200d7199Smrg 3325200d7199Smrg############################################# 3326200d7199Smrg# $build to $host PATH CONVERSION FUNCTIONS # 3327200d7199Smrg############################################# 3328b312a94cSmrg# invoked via '$to_host_path_cmd ARG' 3329200d7199Smrg# 3330200d7199Smrg# In each case, ARG is the path to be converted from $build to $host format. 3331200d7199Smrg# The result will be available in $func_to_host_path_result. 3332200d7199Smrg# 3333200d7199Smrg# Path separators are also converted from $build format to $host format. If 3334200d7199Smrg# ARG begins or ends with a path separator character, it is preserved (but 3335200d7199Smrg# converted to $host format) on output. 3336200d7199Smrg# 3337200d7199Smrg# All path conversion functions are named using the following convention: 3338200d7199Smrg# file name conversion function : func_convert_file_X_to_Y () 3339200d7199Smrg# path conversion function : func_convert_path_X_to_Y () 3340200d7199Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3341200d7199Smrg# same. If conversion functions are added for new $build/$host combinations, 3342200d7199Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3343200d7199Smrg# will break. 3344200d7199Smrg 3345200d7199Smrg 3346200d7199Smrg# func_init_to_host_path_cmd 3347200d7199Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3348200d7199Smrg# appropriate value, based on the value of $to_host_file_cmd. 3349200d7199Smrgto_host_path_cmd= 3350200d7199Smrgfunc_init_to_host_path_cmd () 3351200d7199Smrg{ 3352b312a94cSmrg $debug_cmd 3353b312a94cSmrg 3354200d7199Smrg if test -z "$to_host_path_cmd"; then 3355200d7199Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3356b312a94cSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 3357200d7199Smrg fi 3358200d7199Smrg} 3359200d7199Smrg 3360200d7199Smrg 3361200d7199Smrg# func_to_host_path ARG 3362200d7199Smrg# Converts the path ARG from $build format to $host format. Return result 3363200d7199Smrg# in func_to_host_path_result. 3364200d7199Smrgfunc_to_host_path () 3365200d7199Smrg{ 3366b312a94cSmrg $debug_cmd 3367b312a94cSmrg 3368200d7199Smrg func_init_to_host_path_cmd 3369200d7199Smrg $to_host_path_cmd "$1" 3370200d7199Smrg} 3371200d7199Smrg# end func_to_host_path 3372200d7199Smrg 3373200d7199Smrg 3374200d7199Smrg# func_convert_path_noop ARG 3375200d7199Smrg# Copy ARG to func_to_host_path_result. 3376200d7199Smrgfunc_convert_path_noop () 3377200d7199Smrg{ 3378b312a94cSmrg func_to_host_path_result=$1 3379200d7199Smrg} 3380200d7199Smrg# end func_convert_path_noop 3381200d7199Smrg 3382200d7199Smrg 3383200d7199Smrg# func_convert_path_msys_to_w32 ARG 3384200d7199Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3385200d7199Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 3386200d7199Smrg# func_to_host_path_result. 3387200d7199Smrgfunc_convert_path_msys_to_w32 () 338865eef222Smrg{ 3389b312a94cSmrg $debug_cmd 3390b312a94cSmrg 3391b312a94cSmrg func_to_host_path_result=$1 3392200d7199Smrg if test -n "$1"; then 3393200d7199Smrg # Remove leading and trailing path separator characters from ARG. MSYS 3394200d7199Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3395200d7199Smrg # and winepath ignores them completely. 3396200d7199Smrg func_stripname : : "$1" 3397200d7199Smrg func_to_host_path_tmp1=$func_stripname_result 3398200d7199Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3399b312a94cSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3400200d7199Smrg func_convert_path_check : ";" \ 3401200d7199Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3402200d7199Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3403200d7199Smrg fi 3404200d7199Smrg} 3405200d7199Smrg# end func_convert_path_msys_to_w32 340665eef222Smrg 340765eef222Smrg 3408200d7199Smrg# func_convert_path_cygwin_to_w32 ARG 3409200d7199Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 3410200d7199Smrg# func_to_host_file_result. 3411200d7199Smrgfunc_convert_path_cygwin_to_w32 () 3412200d7199Smrg{ 3413b312a94cSmrg $debug_cmd 3414b312a94cSmrg 3415b312a94cSmrg func_to_host_path_result=$1 3416200d7199Smrg if test -n "$1"; then 3417200d7199Smrg # See func_convert_path_msys_to_w32: 3418200d7199Smrg func_stripname : : "$1" 3419200d7199Smrg func_to_host_path_tmp1=$func_stripname_result 3420200d7199Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3421200d7199Smrg func_convert_path_check : ";" \ 3422200d7199Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3423200d7199Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3424200d7199Smrg fi 3425200d7199Smrg} 3426200d7199Smrg# end func_convert_path_cygwin_to_w32 342765eef222Smrg 342865eef222Smrg 3429200d7199Smrg# func_convert_path_nix_to_w32 ARG 3430200d7199Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3431200d7199Smrg# a working winepath. Returns result in func_to_host_file_result. 3432200d7199Smrgfunc_convert_path_nix_to_w32 () 3433200d7199Smrg{ 3434b312a94cSmrg $debug_cmd 3435b312a94cSmrg 3436b312a94cSmrg func_to_host_path_result=$1 3437200d7199Smrg if test -n "$1"; then 3438200d7199Smrg # See func_convert_path_msys_to_w32: 3439200d7199Smrg func_stripname : : "$1" 3440200d7199Smrg func_to_host_path_tmp1=$func_stripname_result 3441200d7199Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3442b312a94cSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3443200d7199Smrg func_convert_path_check : ";" \ 3444200d7199Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3445200d7199Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3446200d7199Smrg fi 3447200d7199Smrg} 3448200d7199Smrg# end func_convert_path_nix_to_w32 344965eef222Smrg 3450200d7199Smrg 3451200d7199Smrg# func_convert_path_msys_to_cygwin ARG 3452200d7199Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3453200d7199Smrg# Returns result in func_to_host_file_result. 3454200d7199Smrgfunc_convert_path_msys_to_cygwin () 3455200d7199Smrg{ 3456b312a94cSmrg $debug_cmd 3457b312a94cSmrg 3458b312a94cSmrg func_to_host_path_result=$1 3459200d7199Smrg if test -n "$1"; then 3460200d7199Smrg # See func_convert_path_msys_to_w32: 3461200d7199Smrg func_stripname : : "$1" 3462200d7199Smrg func_to_host_path_tmp1=$func_stripname_result 3463200d7199Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3464200d7199Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3465b312a94cSmrg func_to_host_path_result=$func_cygpath_result 3466200d7199Smrg func_convert_path_check : : \ 3467200d7199Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3468200d7199Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3469200d7199Smrg fi 3470200d7199Smrg} 3471200d7199Smrg# end func_convert_path_msys_to_cygwin 3472200d7199Smrg 3473200d7199Smrg 3474200d7199Smrg# func_convert_path_nix_to_cygwin ARG 3475200d7199Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3476200d7199Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3477200d7199Smrg# func_to_host_file_result. 3478200d7199Smrgfunc_convert_path_nix_to_cygwin () 3479200d7199Smrg{ 3480b312a94cSmrg $debug_cmd 3481b312a94cSmrg 3482b312a94cSmrg func_to_host_path_result=$1 3483200d7199Smrg if test -n "$1"; then 3484200d7199Smrg # Remove leading and trailing path separator characters from 3485200d7199Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 3486200d7199Smrg # into '.;' and ';.', and winepath ignores them completely. 3487200d7199Smrg func_stripname : : "$1" 3488200d7199Smrg func_to_host_path_tmp1=$func_stripname_result 3489200d7199Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3490200d7199Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3491b312a94cSmrg func_to_host_path_result=$func_cygpath_result 3492200d7199Smrg func_convert_path_check : : \ 3493200d7199Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3494200d7199Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3495200d7199Smrg fi 349665eef222Smrg} 3497200d7199Smrg# end func_convert_path_nix_to_cygwin 3498200d7199Smrg 349965eef222Smrg 3500b312a94cSmrg# func_dll_def_p FILE 3501b312a94cSmrg# True iff FILE is a Windows DLL '.def' file. 3502b312a94cSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3503b312a94cSmrgfunc_dll_def_p () 3504b312a94cSmrg{ 3505b312a94cSmrg $debug_cmd 3506b312a94cSmrg 3507b312a94cSmrg func_dll_def_p_tmp=`$SED -n \ 3508b312a94cSmrg -e 's/^[ ]*//' \ 3509b312a94cSmrg -e '/^\(;.*\)*$/d' \ 3510b312a94cSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3511b312a94cSmrg -e q \ 3512b312a94cSmrg "$1"` 3513b312a94cSmrg test DEF = "$func_dll_def_p_tmp" 3514b312a94cSmrg} 3515b312a94cSmrg 3516b312a94cSmrg 351765eef222Smrg# func_mode_compile arg... 351865eef222Smrgfunc_mode_compile () 351965eef222Smrg{ 3520b312a94cSmrg $debug_cmd 3521b312a94cSmrg 352265eef222Smrg # Get the compilation command and the source file. 352365eef222Smrg base_compile= 3524b312a94cSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 352565eef222Smrg suppress_opt=yes 352665eef222Smrg suppress_output= 352765eef222Smrg arg_mode=normal 352865eef222Smrg libobj= 352965eef222Smrg later= 353065eef222Smrg pie_flag= 353165eef222Smrg 353265eef222Smrg for arg 353365eef222Smrg do 353465eef222Smrg case $arg_mode in 353565eef222Smrg arg ) 353665eef222Smrg # do not "continue". Instead, add this to base_compile 3537b312a94cSmrg lastarg=$arg 353865eef222Smrg arg_mode=normal 353965eef222Smrg ;; 354065eef222Smrg 354165eef222Smrg target ) 3542b312a94cSmrg libobj=$arg 354365eef222Smrg arg_mode=normal 354465eef222Smrg continue 354565eef222Smrg ;; 354665eef222Smrg 354765eef222Smrg normal ) 354865eef222Smrg # Accept any command-line options. 354965eef222Smrg case $arg in 355065eef222Smrg -o) 355165eef222Smrg test -n "$libobj" && \ 3552b312a94cSmrg func_fatal_error "you cannot specify '-o' more than once" 355365eef222Smrg arg_mode=target 355465eef222Smrg continue 355565eef222Smrg ;; 355665eef222Smrg 355765eef222Smrg -pie | -fpie | -fPIE) 3558200d7199Smrg func_append pie_flag " $arg" 355965eef222Smrg continue 356065eef222Smrg ;; 356165eef222Smrg 356265eef222Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 3563200d7199Smrg func_append later " $arg" 356465eef222Smrg continue 356565eef222Smrg ;; 356665eef222Smrg 356765eef222Smrg -no-suppress) 356865eef222Smrg suppress_opt=no 356965eef222Smrg continue 357065eef222Smrg ;; 357165eef222Smrg 357265eef222Smrg -Xcompiler) 357365eef222Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 357465eef222Smrg continue # The current "srcfile" will either be retained or 357565eef222Smrg ;; # replaced later. I would guess that would be a bug. 357665eef222Smrg 357765eef222Smrg -Wc,*) 357865eef222Smrg func_stripname '-Wc,' '' "$arg" 357965eef222Smrg args=$func_stripname_result 358065eef222Smrg lastarg= 3581b312a94cSmrg save_ifs=$IFS; IFS=, 358265eef222Smrg for arg in $args; do 3583b312a94cSmrg IFS=$save_ifs 3584200d7199Smrg func_append_quoted lastarg "$arg" 3585ef981d24Smrg done 3586b312a94cSmrg IFS=$save_ifs 358765eef222Smrg func_stripname ' ' '' "$lastarg" 358865eef222Smrg lastarg=$func_stripname_result 3589ef981d24Smrg 3590ef981d24Smrg # Add the arguments to base_compile. 3591200d7199Smrg func_append base_compile " $lastarg" 3592ef981d24Smrg continue 3593ef981d24Smrg ;; 3594ef981d24Smrg 359565eef222Smrg *) 3596ef981d24Smrg # Accept the current argument as the source file. 3597ef981d24Smrg # The previous "srcfile" becomes the current argument. 3598ef981d24Smrg # 3599b312a94cSmrg lastarg=$srcfile 3600b312a94cSmrg srcfile=$arg 3601ef981d24Smrg ;; 3602ef981d24Smrg esac # case $arg 3603ef981d24Smrg ;; 3604ef981d24Smrg esac # case $arg_mode 3605ef981d24Smrg 3606ef981d24Smrg # Aesthetically quote the previous argument. 3607200d7199Smrg func_append_quoted base_compile "$lastarg" 3608ef981d24Smrg done # for arg 3609ef981d24Smrg 3610ef981d24Smrg case $arg_mode in 3611ef981d24Smrg arg) 361265eef222Smrg func_fatal_error "you must specify an argument for -Xcompile" 3613ef981d24Smrg ;; 3614ef981d24Smrg target) 3615b312a94cSmrg func_fatal_error "you must specify a target with '-o'" 3616ef981d24Smrg ;; 3617ef981d24Smrg *) 3618ef981d24Smrg # Get the name of the library object. 361965eef222Smrg test -z "$libobj" && { 362065eef222Smrg func_basename "$srcfile" 3621b312a94cSmrg libobj=$func_basename_result 362265eef222Smrg } 3623ef981d24Smrg ;; 3624ef981d24Smrg esac 3625ef981d24Smrg 3626ef981d24Smrg # Recognize several different file suffixes. 3627ef981d24Smrg # If the user specifies -o file.o, it is replaced with file.lo 3628ef981d24Smrg case $libobj in 362965eef222Smrg *.[cCFSifmso] | \ 363065eef222Smrg *.ada | *.adb | *.ads | *.asm | \ 363165eef222Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3632b312a94cSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 363365eef222Smrg func_xform "$libobj" 363465eef222Smrg libobj=$func_xform_result 363565eef222Smrg ;; 3636ef981d24Smrg esac 3637ef981d24Smrg 3638ef981d24Smrg case $libobj in 363965eef222Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3640ef981d24Smrg *) 3641b312a94cSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 3642ef981d24Smrg ;; 3643ef981d24Smrg esac 3644ef981d24Smrg 3645ef981d24Smrg func_infer_tag $base_compile 3646ef981d24Smrg 3647ef981d24Smrg for arg in $later; do 3648ef981d24Smrg case $arg in 364965eef222Smrg -shared) 3650b312a94cSmrg test yes = "$build_libtool_libs" \ 3651b312a94cSmrg || func_fatal_configuration "cannot build a shared library" 365265eef222Smrg build_old_libs=no 365365eef222Smrg continue 365465eef222Smrg ;; 365565eef222Smrg 3656ef981d24Smrg -static) 365765eef222Smrg build_libtool_libs=no 3658ef981d24Smrg build_old_libs=yes 3659ef981d24Smrg continue 3660ef981d24Smrg ;; 3661ef981d24Smrg 3662ef981d24Smrg -prefer-pic) 3663ef981d24Smrg pic_mode=yes 3664ef981d24Smrg continue 3665ef981d24Smrg ;; 3666ef981d24Smrg 3667ef981d24Smrg -prefer-non-pic) 3668ef981d24Smrg pic_mode=no 3669ef981d24Smrg continue 3670ef981d24Smrg ;; 3671ef981d24Smrg esac 3672ef981d24Smrg done 3673ef981d24Smrg 3674d5637ae9Smrg func_quote_arg pretty "$libobj" 3675d5637ae9Smrg test "X$libobj" != "X$func_quote_arg_result" \ 367665eef222Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3677b312a94cSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 367865eef222Smrg func_dirname_and_basename "$obj" "/" "" 3679b312a94cSmrg objname=$func_basename_result 3680b312a94cSmrg xdir=$func_dirname_result 3681b312a94cSmrg lobj=$xdir$objdir/$objname 3682ef981d24Smrg 368365eef222Smrg test -z "$base_compile" && \ 368465eef222Smrg func_fatal_help "you must specify a compilation command" 3685ef981d24Smrg 3686ef981d24Smrg # Delete any leftover library objects. 3687b312a94cSmrg if test yes = "$build_old_libs"; then 3688ef981d24Smrg removelist="$obj $lobj $libobj ${libobj}T" 3689ef981d24Smrg else 3690ef981d24Smrg removelist="$lobj $libobj ${libobj}T" 3691ef981d24Smrg fi 3692ef981d24Smrg 3693ef981d24Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 3694ef981d24Smrg case $host_os in 369565eef222Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3696ef981d24Smrg pic_mode=default 3697ef981d24Smrg ;; 3698ef981d24Smrg esac 3699b312a94cSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3700ef981d24Smrg # non-PIC code in shared libraries is not supported 3701ef981d24Smrg pic_mode=default 3702ef981d24Smrg fi 3703ef981d24Smrg 3704ef981d24Smrg # Calculate the filename of the output object if compiler does 3705ef981d24Smrg # not support -o with -c 3706b312a94cSmrg if test no = "$compiler_c_o"; then 3707b312a94cSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3708b312a94cSmrg lockfile=$output_obj.lock 3709ef981d24Smrg else 3710ef981d24Smrg output_obj= 3711ef981d24Smrg need_locks=no 3712ef981d24Smrg lockfile= 3713ef981d24Smrg fi 3714ef981d24Smrg 3715ef981d24Smrg # Lock this critical section if it is needed 3716ef981d24Smrg # We use this script file to make the link, it avoids creating a new file 3717b312a94cSmrg if test yes = "$need_locks"; then 371865eef222Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 371965eef222Smrg func_echo "Waiting for $lockfile to be removed" 3720ef981d24Smrg sleep 2 3721ef981d24Smrg done 3722b312a94cSmrg elif test warn = "$need_locks"; then 3723ef981d24Smrg if test -f "$lockfile"; then 372465eef222Smrg $ECHO "\ 3725ef981d24Smrg*** ERROR, $lockfile exists and contains: 3726ef981d24Smrg`cat $lockfile 2>/dev/null` 3727ef981d24Smrg 3728ef981d24SmrgThis indicates that another process is trying to use the same 3729ef981d24Smrgtemporary object file, and libtool could not work around it because 3730b312a94cSmrgyour compiler does not support '-c' and '-o' together. If you 3731ef981d24Smrgrepeat this compilation, it may succeed, by chance, but you had better 3732ef981d24Smrgavoid parallel builds (make -j) in this platform, or get a better 3733ef981d24Smrgcompiler." 3734ef981d24Smrg 373565eef222Smrg $opt_dry_run || $RM $removelist 3736ef981d24Smrg exit $EXIT_FAILURE 3737ef981d24Smrg fi 3738200d7199Smrg func_append removelist " $output_obj" 373965eef222Smrg $ECHO "$srcfile" > "$lockfile" 3740ef981d24Smrg fi 3741ef981d24Smrg 374265eef222Smrg $opt_dry_run || $RM $removelist 3743200d7199Smrg func_append removelist " $lockfile" 374465eef222Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 374565eef222Smrg 3746200d7199Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3747200d7199Smrg srcfile=$func_to_tool_file_result 3748d5637ae9Smrg func_quote_arg pretty "$srcfile" 3749d5637ae9Smrg qsrcfile=$func_quote_arg_result 3750ef981d24Smrg 3751ef981d24Smrg # Only build a PIC object if we are building libtool libraries. 3752b312a94cSmrg if test yes = "$build_libtool_libs"; then 3753ef981d24Smrg # Without this assignment, base_compile gets emptied. 3754ef981d24Smrg fbsd_hideous_sh_bug=$base_compile 3755ef981d24Smrg 3756b312a94cSmrg if test no != "$pic_mode"; then 3757ef981d24Smrg command="$base_compile $qsrcfile $pic_flag" 3758ef981d24Smrg else 3759ef981d24Smrg # Don't build PIC code 3760ef981d24Smrg command="$base_compile $qsrcfile" 3761ef981d24Smrg fi 3762ef981d24Smrg 376365eef222Smrg func_mkdir_p "$xdir$objdir" 3764ef981d24Smrg 3765ef981d24Smrg if test -z "$output_obj"; then 3766ef981d24Smrg # Place PIC objects in $objdir 3767200d7199Smrg func_append command " -o $lobj" 3768ef981d24Smrg fi 3769ef981d24Smrg 377065eef222Smrg func_show_eval_locale "$command" \ 377165eef222Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3772ef981d24Smrg 3773b312a94cSmrg if test warn = "$need_locks" && 3774ef981d24Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 377565eef222Smrg $ECHO "\ 3776ef981d24Smrg*** ERROR, $lockfile contains: 3777ef981d24Smrg`cat $lockfile 2>/dev/null` 3778ef981d24Smrg 3779ef981d24Smrgbut it should contain: 3780ef981d24Smrg$srcfile 3781ef981d24Smrg 3782ef981d24SmrgThis indicates that another process is trying to use the same 3783ef981d24Smrgtemporary object file, and libtool could not work around it because 3784b312a94cSmrgyour compiler does not support '-c' and '-o' together. If you 3785ef981d24Smrgrepeat this compilation, it may succeed, by chance, but you had better 3786ef981d24Smrgavoid parallel builds (make -j) in this platform, or get a better 3787ef981d24Smrgcompiler." 3788ef981d24Smrg 378965eef222Smrg $opt_dry_run || $RM $removelist 3790ef981d24Smrg exit $EXIT_FAILURE 3791ef981d24Smrg fi 3792ef981d24Smrg 3793ef981d24Smrg # Just move the object if needed, then go on to compile the next one 3794ef981d24Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 379565eef222Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 379665eef222Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3797ef981d24Smrg fi 3798ef981d24Smrg 3799ef981d24Smrg # Allow error messages only from the first compilation. 3800b312a94cSmrg if test yes = "$suppress_opt"; then 380165eef222Smrg suppress_output=' >/dev/null 2>&1' 3802ef981d24Smrg fi 3803ef981d24Smrg fi 3804ef981d24Smrg 3805ef981d24Smrg # Only build a position-dependent object if we build old libraries. 3806b312a94cSmrg if test yes = "$build_old_libs"; then 3807b312a94cSmrg if test yes != "$pic_mode"; then 3808ef981d24Smrg # Don't build PIC code 380965eef222Smrg command="$base_compile $qsrcfile$pie_flag" 3810ef981d24Smrg else 3811ef981d24Smrg command="$base_compile $qsrcfile $pic_flag" 3812ef981d24Smrg fi 3813b312a94cSmrg if test yes = "$compiler_c_o"; then 3814200d7199Smrg func_append command " -o $obj" 3815ef981d24Smrg fi 3816ef981d24Smrg 3817ef981d24Smrg # Suppress compiler output if we already did a PIC compilation. 3818200d7199Smrg func_append command "$suppress_output" 381965eef222Smrg func_show_eval_locale "$command" \ 382065eef222Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3821ef981d24Smrg 3822b312a94cSmrg if test warn = "$need_locks" && 3823ef981d24Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 382465eef222Smrg $ECHO "\ 3825ef981d24Smrg*** ERROR, $lockfile contains: 3826ef981d24Smrg`cat $lockfile 2>/dev/null` 3827ef981d24Smrg 3828ef981d24Smrgbut it should contain: 3829ef981d24Smrg$srcfile 3830ef981d24Smrg 3831ef981d24SmrgThis indicates that another process is trying to use the same 3832ef981d24Smrgtemporary object file, and libtool could not work around it because 3833b312a94cSmrgyour compiler does not support '-c' and '-o' together. If you 3834ef981d24Smrgrepeat this compilation, it may succeed, by chance, but you had better 3835ef981d24Smrgavoid parallel builds (make -j) in this platform, or get a better 3836ef981d24Smrgcompiler." 3837ef981d24Smrg 383865eef222Smrg $opt_dry_run || $RM $removelist 3839ef981d24Smrg exit $EXIT_FAILURE 3840ef981d24Smrg fi 3841ef981d24Smrg 3842ef981d24Smrg # Just move the object if needed 3843ef981d24Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 384465eef222Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 384565eef222Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3846ef981d24Smrg fi 3847ef981d24Smrg fi 3848ef981d24Smrg 384965eef222Smrg $opt_dry_run || { 385065eef222Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3851ef981d24Smrg 385265eef222Smrg # Unlock the critical section if it was locked 3853b312a94cSmrg if test no != "$need_locks"; then 385465eef222Smrg removelist=$lockfile 385565eef222Smrg $RM "$lockfile" 385665eef222Smrg fi 385765eef222Smrg } 3858ef981d24Smrg 3859ef981d24Smrg exit $EXIT_SUCCESS 386065eef222Smrg} 3861ef981d24Smrg 386265eef222Smrg$opt_help || { 3863b312a94cSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 386465eef222Smrg} 3865ef981d24Smrg 386665eef222Smrgfunc_mode_help () 386765eef222Smrg{ 386865eef222Smrg # We need to display help for each of the modes. 3869200d7199Smrg case $opt_mode in 387065eef222Smrg "") 387165eef222Smrg # Generic help is extracted from the usage comments 387265eef222Smrg # at the start of this file. 387365eef222Smrg func_help 387465eef222Smrg ;; 3875ef981d24Smrg 387665eef222Smrg clean) 387765eef222Smrg $ECHO \ 387865eef222Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3879ef981d24Smrg 388065eef222SmrgRemove files from the build directory. 3881ef981d24Smrg 388265eef222SmrgRM is the name of the program to use to delete files associated with each FILE 3883b312a94cSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 388465eef222Smrgto RM. 3885ef981d24Smrg 388665eef222SmrgIf FILE is a libtool library, object or program, all the files associated 388765eef222Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 388865eef222Smrg ;; 3889ef981d24Smrg 389065eef222Smrg compile) 389165eef222Smrg $ECHO \ 389265eef222Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3893ef981d24Smrg 389465eef222SmrgCompile a source file into a libtool library object. 3895ef981d24Smrg 389665eef222SmrgThis mode accepts the following additional options: 3897ef981d24Smrg 389865eef222Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 389965eef222Smrg -no-suppress do not suppress compiler output for multiple passes 390056957a04Smrg -prefer-pic try to build PIC objects only 390156957a04Smrg -prefer-non-pic try to build non-PIC objects only 3902b312a94cSmrg -shared do not build a '.o' file suitable for static linking 3903b312a94cSmrg -static only build a '.o' file suitable for static linking 3904d5637ae9Smrg -Wc,FLAG 3905d5637ae9Smrg -Xcompiler FLAG pass FLAG directly to the compiler 3906ef981d24Smrg 3907b312a94cSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 390865eef222Smrgfrom the given SOURCEFILE. 3909ef981d24Smrg 391065eef222SmrgThe output file name is determined by removing the directory component from 3911b312a94cSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 3912b312a94cSmrglibrary object suffix, '.lo'." 391365eef222Smrg ;; 3914ef981d24Smrg 391565eef222Smrg execute) 391665eef222Smrg $ECHO \ 391765eef222Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3918ef981d24Smrg 391965eef222SmrgAutomatically set library path, then run a program. 3920ef981d24Smrg 392165eef222SmrgThis mode accepts the following additional options: 3922ef981d24Smrg 392365eef222Smrg -dlopen FILE add the directory containing FILE to the library path 3924ef981d24Smrg 3925b312a94cSmrgThis mode sets the library path environment variable according to '-dlopen' 392665eef222Smrgflags. 3927ef981d24Smrg 392865eef222SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 392965eef222Smrginto their corresponding uninstalled binary, and any of their required library 393065eef222Smrgdirectories are added to the library path. 3931ef981d24Smrg 393265eef222SmrgThen, COMMAND is executed, with ARGS as arguments." 393365eef222Smrg ;; 3934ef981d24Smrg 393565eef222Smrg finish) 393665eef222Smrg $ECHO \ 393765eef222Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3938ef981d24Smrg 393965eef222SmrgComplete the installation of libtool libraries. 3940ef981d24Smrg 394165eef222SmrgEach LIBDIR is a directory that contains libtool libraries. 3942ef981d24Smrg 394365eef222SmrgThe commands that this mode executes may require superuser privileges. Use 3944b312a94cSmrgthe '--dry-run' option if you just want to see what would be executed." 394565eef222Smrg ;; 3946ef981d24Smrg 394765eef222Smrg install) 394865eef222Smrg $ECHO \ 394965eef222Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3950ef981d24Smrg 395165eef222SmrgInstall executables or libraries. 3952ef981d24Smrg 395365eef222SmrgINSTALL-COMMAND is the installation command. The first component should be 3954b312a94cSmrgeither the 'install' or 'cp' program. 3955ef981d24Smrg 395665eef222SmrgThe following components of INSTALL-COMMAND are treated specially: 3957ef981d24Smrg 395856957a04Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3959ef981d24Smrg 396065eef222SmrgThe rest of the components are interpreted as arguments to that command (only 396165eef222SmrgBSD-compatible install options are recognized)." 396265eef222Smrg ;; 3963ef981d24Smrg 396465eef222Smrg link) 396565eef222Smrg $ECHO \ 396665eef222Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3967ef981d24Smrg 396865eef222SmrgLink object files or libraries together to form another library, or to 396965eef222Smrgcreate an executable program. 3970ef981d24Smrg 397165eef222SmrgLINK-COMMAND is a command using the C compiler that you would use to create 397265eef222Smrga program from several object files. 3973ef981d24Smrg 397465eef222SmrgThe following components of LINK-COMMAND are treated specially: 3975ef981d24Smrg 397665eef222Smrg -all-static do not do any dynamic linking at all 397765eef222Smrg -avoid-version do not add a version suffix if possible 397856957a04Smrg -bindir BINDIR specify path to binaries directory (for systems where 397956957a04Smrg libraries must be found in the PATH setting at runtime) 3980b312a94cSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 398165eef222Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 398265eef222Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 398365eef222Smrg -export-symbols SYMFILE 398465eef222Smrg try to export only the symbols listed in SYMFILE 398565eef222Smrg -export-symbols-regex REGEX 398665eef222Smrg try to export only the symbols matching REGEX 398765eef222Smrg -LLIBDIR search LIBDIR for required installed libraries 398865eef222Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 398965eef222Smrg -module build a library that can dlopened 399065eef222Smrg -no-fast-install disable the fast-install mode 399165eef222Smrg -no-install link a not-installable executable 399265eef222Smrg -no-undefined declare that a library does not refer to external symbols 399365eef222Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3994b312a94cSmrg -objectlist FILE use a list of object files found in FILE to specify objects 3995b312a94cSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 399665eef222Smrg -precious-files-regex REGEX 399765eef222Smrg don't remove output files matching REGEX 399865eef222Smrg -release RELEASE specify package release information 399965eef222Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 400065eef222Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 400165eef222Smrg -shared only do dynamic linking of libtool libraries 400265eef222Smrg -shrext SUFFIX override the standard shared library file extension 400365eef222Smrg -static do not do any dynamic linking of uninstalled libtool libraries 400465eef222Smrg -static-libtool-libs 400565eef222Smrg do not do any dynamic linking of libtool libraries 400665eef222Smrg -version-info CURRENT[:REVISION[:AGE]] 400765eef222Smrg specify library version info [each variable defaults to 0] 400865eef222Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 400956957a04Smrg -Wc,FLAG 401056957a04Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 4011d5637ae9Smrg -Wa,FLAG 4012d5637ae9Smrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 401356957a04Smrg -Wl,FLAG 401456957a04Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 401556957a04Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 4016ef981d24Smrg 4017b312a94cSmrgAll other options (arguments beginning with '-') are ignored. 4018ef981d24Smrg 4019b312a94cSmrgEvery other argument is treated as a filename. Files ending in '.la' are 402065eef222Smrgtreated as uninstalled libtool libraries, other files are standard or library 402165eef222Smrgobject files. 4022ef981d24Smrg 4023b312a94cSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 4024b312a94cSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 402565eef222Smrgrequired, except when creating a convenience library. 4026ef981d24Smrg 4027b312a94cSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 4028b312a94cSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 4029ef981d24Smrg 4030b312a94cSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 403165eef222Smrgis created, otherwise an executable program is created." 4032ef981d24Smrg ;; 4033ef981d24Smrg 403465eef222Smrg uninstall) 403565eef222Smrg $ECHO \ 403665eef222Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 4037ef981d24Smrg 403865eef222SmrgRemove libraries from an installation directory. 4039ef981d24Smrg 404065eef222SmrgRM is the name of the program to use to delete files associated with each FILE 4041b312a94cSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 404265eef222Smrgto RM. 4043ef981d24Smrg 404465eef222SmrgIf FILE is a libtool library, all the files associated with it are deleted. 404565eef222SmrgOtherwise, only FILE itself is deleted using RM." 404665eef222Smrg ;; 4047ef981d24Smrg 404865eef222Smrg *) 4049b312a94cSmrg func_fatal_help "invalid operation mode '$opt_mode'" 405065eef222Smrg ;; 405165eef222Smrg esac 4052ef981d24Smrg 405356957a04Smrg echo 4054b312a94cSmrg $ECHO "Try '$progname --help' for more information about other modes." 405565eef222Smrg} 4056ef981d24Smrg 405756957a04Smrg# Now that we've collected a possible --mode arg, show help if necessary 405856957a04Smrgif $opt_help; then 4059b312a94cSmrg if test : = "$opt_help"; then 406056957a04Smrg func_mode_help 406156957a04Smrg else 406256957a04Smrg { 406356957a04Smrg func_help noexit 4064200d7199Smrg for opt_mode in compile link execute install finish uninstall clean; do 406556957a04Smrg func_mode_help 406656957a04Smrg done 4067b312a94cSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 406856957a04Smrg { 406956957a04Smrg func_help noexit 4070200d7199Smrg for opt_mode in compile link execute install finish uninstall clean; do 407156957a04Smrg echo 407256957a04Smrg func_mode_help 407356957a04Smrg done 407456957a04Smrg } | 4075b312a94cSmrg $SED '1d 407656957a04Smrg /^When reporting/,/^Report/{ 407756957a04Smrg H 407856957a04Smrg d 407956957a04Smrg } 408056957a04Smrg $x 408156957a04Smrg /information about other modes/d 408256957a04Smrg /more detailed .*MODE/d 408356957a04Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 408456957a04Smrg fi 408556957a04Smrg exit $? 408656957a04Smrgfi 4087ef981d24Smrg 4088ef981d24Smrg 408965eef222Smrg# func_mode_execute arg... 409065eef222Smrgfunc_mode_execute () 409165eef222Smrg{ 4092b312a94cSmrg $debug_cmd 4093b312a94cSmrg 409465eef222Smrg # The first argument is the command name. 4095b312a94cSmrg cmd=$nonopt 409665eef222Smrg test -z "$cmd" && \ 409765eef222Smrg func_fatal_help "you must specify a COMMAND" 4098ef981d24Smrg 409965eef222Smrg # Handle -dlopen flags immediately. 4100200d7199Smrg for file in $opt_dlopen; do 410165eef222Smrg test -f "$file" \ 4102b312a94cSmrg || func_fatal_help "'$file' is not a file" 4103ef981d24Smrg 410465eef222Smrg dir= 410565eef222Smrg case $file in 410665eef222Smrg *.la) 4107200d7199Smrg func_resolve_sysroot "$file" 4108200d7199Smrg file=$func_resolve_sysroot_result 4109200d7199Smrg 411065eef222Smrg # Check to see that this really is a libtool archive. 411165eef222Smrg func_lalib_unsafe_p "$file" \ 4112b312a94cSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 4113ef981d24Smrg 411465eef222Smrg # Read the libtool library. 411565eef222Smrg dlname= 411665eef222Smrg library_names= 411765eef222Smrg func_source "$file" 4118ef981d24Smrg 411965eef222Smrg # Skip this library if it cannot be dlopened. 412065eef222Smrg if test -z "$dlname"; then 412165eef222Smrg # Warn if it was a shared library. 412265eef222Smrg test -n "$library_names" && \ 4123b312a94cSmrg func_warning "'$file' was not linked with '-export-dynamic'" 412465eef222Smrg continue 412565eef222Smrg fi 4126ef981d24Smrg 412765eef222Smrg func_dirname "$file" "" "." 4128b312a94cSmrg dir=$func_dirname_result 4129ef981d24Smrg 413065eef222Smrg if test -f "$dir/$objdir/$dlname"; then 4131200d7199Smrg func_append dir "/$objdir" 413265eef222Smrg else 413365eef222Smrg if test ! -f "$dir/$dlname"; then 4134b312a94cSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 413565eef222Smrg fi 413665eef222Smrg fi 4137ef981d24Smrg ;; 4138ef981d24Smrg 413965eef222Smrg *.lo) 414065eef222Smrg # Just add the directory containing the .lo file. 414165eef222Smrg func_dirname "$file" "" "." 4142b312a94cSmrg dir=$func_dirname_result 4143ef981d24Smrg ;; 4144ef981d24Smrg 414565eef222Smrg *) 4146b312a94cSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 4147ef981d24Smrg continue 4148ef981d24Smrg ;; 414965eef222Smrg esac 4150ef981d24Smrg 415165eef222Smrg # Get the absolute pathname. 415265eef222Smrg absdir=`cd "$dir" && pwd` 4153b312a94cSmrg test -n "$absdir" && dir=$absdir 4154ef981d24Smrg 415565eef222Smrg # Now add the directory to shlibpath_var. 415665eef222Smrg if eval "test -z \"\$$shlibpath_var\""; then 415765eef222Smrg eval "$shlibpath_var=\"\$dir\"" 415865eef222Smrg else 415965eef222Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 416065eef222Smrg fi 416165eef222Smrg done 4162ef981d24Smrg 416365eef222Smrg # This variable tells wrapper scripts just to set shlibpath_var 416465eef222Smrg # rather than running their programs. 4165b312a94cSmrg libtool_execute_magic=$magic 4166ef981d24Smrg 416765eef222Smrg # Check if any of the arguments is a wrapper script. 416865eef222Smrg args= 416965eef222Smrg for file 417065eef222Smrg do 417165eef222Smrg case $file in 417256957a04Smrg -* | *.la | *.lo ) ;; 417365eef222Smrg *) 417465eef222Smrg # Do a test to see if this is really a libtool program. 417565eef222Smrg if func_ltwrapper_script_p "$file"; then 417665eef222Smrg func_source "$file" 417765eef222Smrg # Transform arg to wrapped name. 4178b312a94cSmrg file=$progdir/$program 417965eef222Smrg elif func_ltwrapper_executable_p "$file"; then 418065eef222Smrg func_ltwrapper_scriptname "$file" 418165eef222Smrg func_source "$func_ltwrapper_scriptname_result" 418265eef222Smrg # Transform arg to wrapped name. 4183b312a94cSmrg file=$progdir/$program 418465eef222Smrg fi 418565eef222Smrg ;; 418665eef222Smrg esac 418765eef222Smrg # Quote arguments (to preserve shell metacharacters). 4188200d7199Smrg func_append_quoted args "$file" 418965eef222Smrg done 4190ef981d24Smrg 4191b312a94cSmrg if $opt_dry_run; then 4192b312a94cSmrg # Display what would be done. 4193b312a94cSmrg if test -n "$shlibpath_var"; then 4194b312a94cSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 4195b312a94cSmrg echo "export $shlibpath_var" 4196b312a94cSmrg fi 4197b312a94cSmrg $ECHO "$cmd$args" 4198b312a94cSmrg exit $EXIT_SUCCESS 4199b312a94cSmrg else 420065eef222Smrg if test -n "$shlibpath_var"; then 420165eef222Smrg # Export the shlibpath_var. 420265eef222Smrg eval "export $shlibpath_var" 420365eef222Smrg fi 4204ef981d24Smrg 420565eef222Smrg # Restore saved environment variables 420665eef222Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 420765eef222Smrg do 420865eef222Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 420965eef222Smrg $lt_var=\$save_$lt_var; export $lt_var 421065eef222Smrg else 421165eef222Smrg $lt_unset $lt_var 421265eef222Smrg fi" 421365eef222Smrg done 4214ef981d24Smrg 421565eef222Smrg # Now prepare to actually exec the command. 4216b312a94cSmrg exec_cmd=\$cmd$args 421765eef222Smrg fi 421865eef222Smrg} 4219ef981d24Smrg 4220b312a94cSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 4221ef981d24Smrg 4222ef981d24Smrg 422365eef222Smrg# func_mode_finish arg... 422465eef222Smrgfunc_mode_finish () 422565eef222Smrg{ 4226b312a94cSmrg $debug_cmd 4227b312a94cSmrg 4228200d7199Smrg libs= 4229200d7199Smrg libdirs= 423065eef222Smrg admincmds= 4231ef981d24Smrg 4232200d7199Smrg for opt in "$nonopt" ${1+"$@"} 4233200d7199Smrg do 4234200d7199Smrg if test -d "$opt"; then 4235200d7199Smrg func_append libdirs " $opt" 4236200d7199Smrg 4237200d7199Smrg elif test -f "$opt"; then 4238200d7199Smrg if func_lalib_unsafe_p "$opt"; then 4239200d7199Smrg func_append libs " $opt" 4240200d7199Smrg else 4241b312a94cSmrg func_warning "'$opt' is not a valid libtool archive" 4242200d7199Smrg fi 4243200d7199Smrg 4244200d7199Smrg else 4245b312a94cSmrg func_fatal_error "invalid argument '$opt'" 4246200d7199Smrg fi 4247200d7199Smrg done 4248200d7199Smrg 4249200d7199Smrg if test -n "$libs"; then 4250200d7199Smrg if test -n "$lt_sysroot"; then 4251200d7199Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 4252200d7199Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 4253200d7199Smrg else 4254200d7199Smrg sysroot_cmd= 4255200d7199Smrg fi 4256200d7199Smrg 4257200d7199Smrg # Remove sysroot references 4258200d7199Smrg if $opt_dry_run; then 4259200d7199Smrg for lib in $libs; do 4260b312a94cSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4261200d7199Smrg done 4262200d7199Smrg else 4263200d7199Smrg tmpdir=`func_mktempdir` 4264200d7199Smrg for lib in $libs; do 4265b312a94cSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4266200d7199Smrg > $tmpdir/tmp-la 4267200d7199Smrg mv -f $tmpdir/tmp-la $lib 4268200d7199Smrg done 4269200d7199Smrg ${RM}r "$tmpdir" 4270200d7199Smrg fi 4271200d7199Smrg fi 4272ef981d24Smrg 4273200d7199Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 427465eef222Smrg for libdir in $libdirs; do 427565eef222Smrg if test -n "$finish_cmds"; then 427665eef222Smrg # Do each command in the finish commands. 427765eef222Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 427865eef222Smrg'"$cmd"'"' 427965eef222Smrg fi 428065eef222Smrg if test -n "$finish_eval"; then 428165eef222Smrg # Do the single finish_eval. 428265eef222Smrg eval cmds=\"$finish_eval\" 4283200d7199Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 428465eef222Smrg $cmds" 428565eef222Smrg fi 428665eef222Smrg done 428765eef222Smrg fi 4288ef981d24Smrg 428965eef222Smrg # Exit here if they wanted silent mode. 4290b312a94cSmrg $opt_quiet && exit $EXIT_SUCCESS 4291ef981d24Smrg 4292200d7199Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4293200d7199Smrg echo "----------------------------------------------------------------------" 4294200d7199Smrg echo "Libraries have been installed in:" 4295200d7199Smrg for libdir in $libdirs; do 4296200d7199Smrg $ECHO " $libdir" 4297200d7199Smrg done 4298200d7199Smrg echo 4299200d7199Smrg echo "If you ever happen to want to link against installed libraries" 4300200d7199Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 4301b312a94cSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4302200d7199Smrg echo "flag during linking and do at least one of the following:" 4303200d7199Smrg if test -n "$shlibpath_var"; then 4304b312a94cSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4305200d7199Smrg echo " during execution" 4306200d7199Smrg fi 4307200d7199Smrg if test -n "$runpath_var"; then 4308b312a94cSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4309200d7199Smrg echo " during linking" 4310200d7199Smrg fi 4311200d7199Smrg if test -n "$hardcode_libdir_flag_spec"; then 4312200d7199Smrg libdir=LIBDIR 4313200d7199Smrg eval flag=\"$hardcode_libdir_flag_spec\" 4314ef981d24Smrg 4315b312a94cSmrg $ECHO " - use the '$flag' linker flag" 4316200d7199Smrg fi 4317200d7199Smrg if test -n "$admincmds"; then 4318200d7199Smrg $ECHO " - have your system administrator run these commands:$admincmds" 4319200d7199Smrg fi 4320200d7199Smrg if test -f /etc/ld.so.conf; then 4321b312a94cSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4322200d7199Smrg fi 4323200d7199Smrg echo 4324ef981d24Smrg 4325200d7199Smrg echo "See any operating system documentation about shared libraries for" 4326200d7199Smrg case $host in 4327200d7199Smrg solaris2.[6789]|solaris2.1[0-9]) 4328200d7199Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4329200d7199Smrg echo "pages." 4330200d7199Smrg ;; 4331200d7199Smrg *) 4332200d7199Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4333200d7199Smrg ;; 4334200d7199Smrg esac 4335200d7199Smrg echo "----------------------------------------------------------------------" 4336200d7199Smrg fi 433765eef222Smrg exit $EXIT_SUCCESS 433865eef222Smrg} 4339ef981d24Smrg 4340b312a94cSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4341ef981d24Smrg 4342ef981d24Smrg 434365eef222Smrg# func_mode_install arg... 434465eef222Smrgfunc_mode_install () 434565eef222Smrg{ 4346b312a94cSmrg $debug_cmd 4347b312a94cSmrg 434865eef222Smrg # There may be an optional sh(1) argument at the beginning of 434965eef222Smrg # install_prog (especially on Windows NT). 4350b312a94cSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 435165eef222Smrg # Allow the use of GNU shtool's install command. 4352b312a94cSmrg case $nonopt in *shtool*) :;; *) false;; esac 4353b312a94cSmrg then 435465eef222Smrg # Aesthetically quote it. 4355d5637ae9Smrg func_quote_arg pretty "$nonopt" 4356d5637ae9Smrg install_prog="$func_quote_arg_result " 435765eef222Smrg arg=$1 435865eef222Smrg shift 435965eef222Smrg else 436065eef222Smrg install_prog= 436165eef222Smrg arg=$nonopt 436265eef222Smrg fi 4363ef981d24Smrg 436465eef222Smrg # The real first argument should be the name of the installation program. 436565eef222Smrg # Aesthetically quote it. 4366d5637ae9Smrg func_quote_arg pretty "$arg" 4367d5637ae9Smrg func_append install_prog "$func_quote_arg_result" 436856957a04Smrg install_shared_prog=$install_prog 436956957a04Smrg case " $install_prog " in 437056957a04Smrg *[\\\ /]cp\ *) install_cp=: ;; 437156957a04Smrg *) install_cp=false ;; 437256957a04Smrg esac 437365eef222Smrg 437465eef222Smrg # We need to accept at least all the BSD install flags. 437565eef222Smrg dest= 437665eef222Smrg files= 437765eef222Smrg opts= 437865eef222Smrg prev= 437965eef222Smrg install_type= 4380b312a94cSmrg isdir=false 438165eef222Smrg stripme= 438256957a04Smrg no_mode=: 438365eef222Smrg for arg 438465eef222Smrg do 438556957a04Smrg arg2= 438665eef222Smrg if test -n "$dest"; then 4387200d7199Smrg func_append files " $dest" 438865eef222Smrg dest=$arg 438965eef222Smrg continue 4390ef981d24Smrg fi 4391ef981d24Smrg 439265eef222Smrg case $arg in 4393b312a94cSmrg -d) isdir=: ;; 439465eef222Smrg -f) 439556957a04Smrg if $install_cp; then :; else 439656957a04Smrg prev=$arg 439756957a04Smrg fi 439865eef222Smrg ;; 439965eef222Smrg -g | -m | -o) 440065eef222Smrg prev=$arg 440165eef222Smrg ;; 440265eef222Smrg -s) 440365eef222Smrg stripme=" -s" 440465eef222Smrg continue 440565eef222Smrg ;; 440665eef222Smrg -*) 440765eef222Smrg ;; 440865eef222Smrg *) 440965eef222Smrg # If the previous option needed an argument, then skip it. 441065eef222Smrg if test -n "$prev"; then 4411b312a94cSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 441256957a04Smrg arg2=$install_override_mode 441356957a04Smrg no_mode=false 441456957a04Smrg fi 441565eef222Smrg prev= 441665eef222Smrg else 441765eef222Smrg dest=$arg 441865eef222Smrg continue 441965eef222Smrg fi 442065eef222Smrg ;; 442165eef222Smrg esac 4422ef981d24Smrg 442365eef222Smrg # Aesthetically quote the argument. 4424d5637ae9Smrg func_quote_arg pretty "$arg" 4425d5637ae9Smrg func_append install_prog " $func_quote_arg_result" 442656957a04Smrg if test -n "$arg2"; then 4427d5637ae9Smrg func_quote_arg pretty "$arg2" 442856957a04Smrg fi 4429d5637ae9Smrg func_append install_shared_prog " $func_quote_arg_result" 443065eef222Smrg done 4431ef981d24Smrg 443265eef222Smrg test -z "$install_prog" && \ 443365eef222Smrg func_fatal_help "you must specify an install program" 4434ef981d24Smrg 443565eef222Smrg test -n "$prev" && \ 4436b312a94cSmrg func_fatal_help "the '$prev' option requires an argument" 4437ef981d24Smrg 443856957a04Smrg if test -n "$install_override_mode" && $no_mode; then 443956957a04Smrg if $install_cp; then :; else 4440d5637ae9Smrg func_quote_arg pretty "$install_override_mode" 4441d5637ae9Smrg func_append install_shared_prog " -m $func_quote_arg_result" 444256957a04Smrg fi 444356957a04Smrg fi 444456957a04Smrg 444565eef222Smrg if test -z "$files"; then 444665eef222Smrg if test -z "$dest"; then 444765eef222Smrg func_fatal_help "no file or destination specified" 444865eef222Smrg else 444965eef222Smrg func_fatal_help "you must specify a destination" 4450ef981d24Smrg fi 4451ef981d24Smrg fi 4452ef981d24Smrg 445365eef222Smrg # Strip any trailing slash from the destination. 445465eef222Smrg func_stripname '' '/' "$dest" 445565eef222Smrg dest=$func_stripname_result 4456ef981d24Smrg 445765eef222Smrg # Check to see that the destination is a directory. 4458b312a94cSmrg test -d "$dest" && isdir=: 4459b312a94cSmrg if $isdir; then 4460b312a94cSmrg destdir=$dest 446165eef222Smrg destname= 446265eef222Smrg else 446365eef222Smrg func_dirname_and_basename "$dest" "" "." 4464b312a94cSmrg destdir=$func_dirname_result 4465b312a94cSmrg destname=$func_basename_result 446665eef222Smrg 446765eef222Smrg # Not a directory, so check to see that there is only one file specified. 446865eef222Smrg set dummy $files; shift 446965eef222Smrg test "$#" -gt 1 && \ 4470b312a94cSmrg func_fatal_help "'$dest' is not a directory" 447165eef222Smrg fi 447265eef222Smrg case $destdir in 447365eef222Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4474ef981d24Smrg *) 447565eef222Smrg for file in $files; do 447665eef222Smrg case $file in 447765eef222Smrg *.lo) ;; 447865eef222Smrg *) 4479b312a94cSmrg func_fatal_help "'$destdir' must be an absolute directory name" 448065eef222Smrg ;; 448165eef222Smrg esac 448265eef222Smrg done 4483ef981d24Smrg ;; 4484ef981d24Smrg esac 4485ef981d24Smrg 448665eef222Smrg # This variable tells wrapper scripts just to set variables rather 448765eef222Smrg # than running their programs. 4488b312a94cSmrg libtool_install_magic=$magic 4489ef981d24Smrg 449065eef222Smrg staticlibs= 449165eef222Smrg future_libdirs= 449265eef222Smrg current_libdirs= 449365eef222Smrg for file in $files; do 4494ef981d24Smrg 449565eef222Smrg # Do each installation. 449665eef222Smrg case $file in 449765eef222Smrg *.$libext) 449865eef222Smrg # Do the static libraries later. 4499200d7199Smrg func_append staticlibs " $file" 450065eef222Smrg ;; 450165eef222Smrg 450265eef222Smrg *.la) 4503200d7199Smrg func_resolve_sysroot "$file" 4504200d7199Smrg file=$func_resolve_sysroot_result 4505200d7199Smrg 450665eef222Smrg # Check to see that this really is a libtool archive. 450765eef222Smrg func_lalib_unsafe_p "$file" \ 4508b312a94cSmrg || func_fatal_help "'$file' is not a valid libtool archive" 450965eef222Smrg 451065eef222Smrg library_names= 451165eef222Smrg old_library= 451265eef222Smrg relink_command= 451365eef222Smrg func_source "$file" 451465eef222Smrg 451565eef222Smrg # Add the libdir to current_libdirs if it is the destination. 451665eef222Smrg if test "X$destdir" = "X$libdir"; then 451765eef222Smrg case "$current_libdirs " in 451865eef222Smrg *" $libdir "*) ;; 4519200d7199Smrg *) func_append current_libdirs " $libdir" ;; 4520ef981d24Smrg esac 452165eef222Smrg else 452265eef222Smrg # Note the libdir as a future libdir. 452365eef222Smrg case "$future_libdirs " in 452465eef222Smrg *" $libdir "*) ;; 4525200d7199Smrg *) func_append future_libdirs " $libdir" ;; 452665eef222Smrg esac 452765eef222Smrg fi 4528ef981d24Smrg 452965eef222Smrg func_dirname "$file" "/" "" 4530b312a94cSmrg dir=$func_dirname_result 4531200d7199Smrg func_append dir "$objdir" 453265eef222Smrg 453365eef222Smrg if test -n "$relink_command"; then 453465eef222Smrg # Determine the prefix the user has applied to our future dir. 453556957a04Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 453665eef222Smrg 453765eef222Smrg # Don't allow the user to place us outside of our expected 453865eef222Smrg # location b/c this prevents finding dependent libraries that 453965eef222Smrg # are installed to the same prefix. 454065eef222Smrg # At present, this check doesn't affect windows .dll's that 454165eef222Smrg # are installed into $libdir/../bin (currently, that works fine) 454265eef222Smrg # but it's something to keep an eye on. 454365eef222Smrg test "$inst_prefix_dir" = "$destdir" && \ 4544b312a94cSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 454565eef222Smrg 454665eef222Smrg if test -n "$inst_prefix_dir"; then 454765eef222Smrg # Stick the inst_prefix_dir data into the link command. 454856957a04Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 454965eef222Smrg else 455056957a04Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 455165eef222Smrg fi 455265eef222Smrg 4553b312a94cSmrg func_warning "relinking '$file'" 455465eef222Smrg func_show_eval "$relink_command" \ 4555b312a94cSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 455665eef222Smrg fi 455765eef222Smrg 455865eef222Smrg # See the names of the shared library. 455965eef222Smrg set dummy $library_names; shift 456065eef222Smrg if test -n "$1"; then 4561b312a94cSmrg realname=$1 456265eef222Smrg shift 456365eef222Smrg 4564b312a94cSmrg srcname=$realname 4565b312a94cSmrg test -n "$relink_command" && srcname=${realname}T 456665eef222Smrg 456765eef222Smrg # Install the shared library and build the symlinks. 456856957a04Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 456965eef222Smrg 'exit $?' 4570b312a94cSmrg tstripme=$stripme 457165eef222Smrg case $host_os in 457265eef222Smrg cygwin* | mingw* | pw32* | cegcc*) 457365eef222Smrg case $realname in 457465eef222Smrg *.dll.a) 4575b312a94cSmrg tstripme= 4576b312a94cSmrg ;; 4577b312a94cSmrg esac 4578b312a94cSmrg ;; 4579b312a94cSmrg os2*) 4580b312a94cSmrg case $realname in 4581b312a94cSmrg *_dll.a) 4582b312a94cSmrg tstripme= 458365eef222Smrg ;; 458465eef222Smrg esac 4585ef981d24Smrg ;; 4586ef981d24Smrg esac 458765eef222Smrg if test -n "$tstripme" && test -n "$striplib"; then 458865eef222Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4589ef981d24Smrg fi 459065eef222Smrg 459165eef222Smrg if test "$#" -gt 0; then 459265eef222Smrg # Delete the old symlinks, and create new ones. 4593b312a94cSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 459465eef222Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 459565eef222Smrg # so we also need to try rm && ln -s. 459665eef222Smrg for linkname 459765eef222Smrg do 459865eef222Smrg test "$linkname" != "$realname" \ 459965eef222Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4600ef981d24Smrg done 4601ef981d24Smrg fi 4602ef981d24Smrg 460365eef222Smrg # Do each command in the postinstall commands. 4604b312a94cSmrg lib=$destdir/$realname 460565eef222Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4606ef981d24Smrg fi 4607ef981d24Smrg 460865eef222Smrg # Install the pseudo-library for information purposes. 460965eef222Smrg func_basename "$file" 4610b312a94cSmrg name=$func_basename_result 4611b312a94cSmrg instname=$dir/${name}i 461265eef222Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4613ef981d24Smrg 461465eef222Smrg # Maybe install the static library, too. 4615200d7199Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 461665eef222Smrg ;; 4617ef981d24Smrg 461865eef222Smrg *.lo) 461965eef222Smrg # Install (i.e. copy) a libtool object. 4620ef981d24Smrg 462165eef222Smrg # Figure out destination file name, if it wasn't already specified. 462265eef222Smrg if test -n "$destname"; then 4623b312a94cSmrg destfile=$destdir/$destname 462465eef222Smrg else 462565eef222Smrg func_basename "$file" 4626b312a94cSmrg destfile=$func_basename_result 4627b312a94cSmrg destfile=$destdir/$destfile 462865eef222Smrg fi 462965eef222Smrg 463065eef222Smrg # Deduce the name of the destination old-style object file. 463165eef222Smrg case $destfile in 463265eef222Smrg *.lo) 463365eef222Smrg func_lo2o "$destfile" 463465eef222Smrg staticdest=$func_lo2o_result 463565eef222Smrg ;; 463665eef222Smrg *.$objext) 4637b312a94cSmrg staticdest=$destfile 463865eef222Smrg destfile= 463965eef222Smrg ;; 464065eef222Smrg *) 4641b312a94cSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 464265eef222Smrg ;; 4643ef981d24Smrg esac 4644ef981d24Smrg 464565eef222Smrg # Install the libtool object if requested. 464665eef222Smrg test -n "$destfile" && \ 464765eef222Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 464865eef222Smrg 464965eef222Smrg # Install the old object if enabled. 4650b312a94cSmrg if test yes = "$build_old_libs"; then 465165eef222Smrg # Deduce the name of the old-style object file. 465265eef222Smrg func_lo2o "$file" 465365eef222Smrg staticobj=$func_lo2o_result 465465eef222Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4655ef981d24Smrg fi 465665eef222Smrg exit $EXIT_SUCCESS 465765eef222Smrg ;; 4658ef981d24Smrg 465965eef222Smrg *) 466065eef222Smrg # Figure out destination file name, if it wasn't already specified. 466165eef222Smrg if test -n "$destname"; then 4662b312a94cSmrg destfile=$destdir/$destname 466365eef222Smrg else 466465eef222Smrg func_basename "$file" 4665b312a94cSmrg destfile=$func_basename_result 4666b312a94cSmrg destfile=$destdir/$destfile 466765eef222Smrg fi 466865eef222Smrg 466965eef222Smrg # If the file is missing, and there is a .exe on the end, strip it 467065eef222Smrg # because it is most likely a libtool script we actually want to 467165eef222Smrg # install 4672b312a94cSmrg stripped_ext= 467365eef222Smrg case $file in 467465eef222Smrg *.exe) 467565eef222Smrg if test ! -f "$file"; then 467665eef222Smrg func_stripname '' '.exe' "$file" 467765eef222Smrg file=$func_stripname_result 4678b312a94cSmrg stripped_ext=.exe 4679ef981d24Smrg fi 468065eef222Smrg ;; 468165eef222Smrg esac 4682ef981d24Smrg 468365eef222Smrg # Do a test to see if this is really a libtool program. 468465eef222Smrg case $host in 468565eef222Smrg *cygwin* | *mingw*) 468665eef222Smrg if func_ltwrapper_executable_p "$file"; then 468765eef222Smrg func_ltwrapper_scriptname "$file" 468865eef222Smrg wrapper=$func_ltwrapper_scriptname_result 468965eef222Smrg else 469065eef222Smrg func_stripname '' '.exe' "$file" 469165eef222Smrg wrapper=$func_stripname_result 469265eef222Smrg fi 469365eef222Smrg ;; 469465eef222Smrg *) 469565eef222Smrg wrapper=$file 469665eef222Smrg ;; 469765eef222Smrg esac 469865eef222Smrg if func_ltwrapper_script_p "$wrapper"; then 469965eef222Smrg notinst_deplibs= 470065eef222Smrg relink_command= 4701ef981d24Smrg 470265eef222Smrg func_source "$wrapper" 4703ef981d24Smrg 470465eef222Smrg # Check the variables that should have been set. 470565eef222Smrg test -z "$generated_by_libtool_version" && \ 4706b312a94cSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 470765eef222Smrg 4708b312a94cSmrg finalize=: 470965eef222Smrg for lib in $notinst_deplibs; do 471065eef222Smrg # Check to see that each library is installed. 471165eef222Smrg libdir= 471265eef222Smrg if test -f "$lib"; then 471365eef222Smrg func_source "$lib" 471465eef222Smrg fi 4715b312a94cSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 471665eef222Smrg if test -n "$libdir" && test ! -f "$libfile"; then 4717b312a94cSmrg func_warning "'$lib' has not been installed in '$libdir'" 4718b312a94cSmrg finalize=false 471965eef222Smrg fi 472065eef222Smrg done 472165eef222Smrg 472265eef222Smrg relink_command= 472365eef222Smrg func_source "$wrapper" 472465eef222Smrg 472565eef222Smrg outputname= 4726b312a94cSmrg if test no = "$fast_install" && test -n "$relink_command"; then 472765eef222Smrg $opt_dry_run || { 4728b312a94cSmrg if $finalize; then 472965eef222Smrg tmpdir=`func_mktempdir` 473065eef222Smrg func_basename "$file$stripped_ext" 4731b312a94cSmrg file=$func_basename_result 4732b312a94cSmrg outputname=$tmpdir/$file 473365eef222Smrg # Replace the output file specification. 473456957a04Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 473565eef222Smrg 4736b312a94cSmrg $opt_quiet || { 4737d5637ae9Smrg func_quote_arg expand,pretty "$relink_command" 4738d5637ae9Smrg eval "func_echo $func_quote_arg_result" 473965eef222Smrg } 474065eef222Smrg if eval "$relink_command"; then : 474165eef222Smrg else 4742b312a94cSmrg func_error "error: relink '$file' with the above command before installing it" 474365eef222Smrg $opt_dry_run || ${RM}r "$tmpdir" 474465eef222Smrg continue 474565eef222Smrg fi 4746b312a94cSmrg file=$outputname 474765eef222Smrg else 4748b312a94cSmrg func_warning "cannot relink '$file'" 474965eef222Smrg fi 475065eef222Smrg } 4751ef981d24Smrg else 475265eef222Smrg # Install the binary that we compiled earlier. 475356957a04Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4754ef981d24Smrg fi 475565eef222Smrg fi 4756ef981d24Smrg 475765eef222Smrg # remove .exe since cygwin /usr/bin/install will append another 475865eef222Smrg # one anyway 475965eef222Smrg case $install_prog,$host in 476065eef222Smrg */usr/bin/install*,*cygwin*) 476165eef222Smrg case $file:$destfile in 476265eef222Smrg *.exe:*.exe) 476365eef222Smrg # this is ok 476465eef222Smrg ;; 476565eef222Smrg *.exe:*) 476665eef222Smrg destfile=$destfile.exe 476765eef222Smrg ;; 476865eef222Smrg *:*.exe) 476965eef222Smrg func_stripname '' '.exe' "$destfile" 477065eef222Smrg destfile=$func_stripname_result 477165eef222Smrg ;; 477265eef222Smrg esac 4773ef981d24Smrg ;; 4774ef981d24Smrg esac 477565eef222Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 477665eef222Smrg $opt_dry_run || if test -n "$outputname"; then 477765eef222Smrg ${RM}r "$tmpdir" 477865eef222Smrg fi 477965eef222Smrg ;; 478065eef222Smrg esac 478165eef222Smrg done 4782ef981d24Smrg 478365eef222Smrg for file in $staticlibs; do 478465eef222Smrg func_basename "$file" 4785b312a94cSmrg name=$func_basename_result 4786ef981d24Smrg 478765eef222Smrg # Set up the ranlib parameters. 4788b312a94cSmrg oldlib=$destdir/$name 4789b312a94cSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4790b312a94cSmrg tool_oldlib=$func_to_tool_file_result 4791ef981d24Smrg 479265eef222Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4793ef981d24Smrg 479465eef222Smrg if test -n "$stripme" && test -n "$old_striplib"; then 4795b312a94cSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 479665eef222Smrg fi 4797ef981d24Smrg 479865eef222Smrg # Do each command in the postinstall commands. 479965eef222Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 480065eef222Smrg done 4801ef981d24Smrg 480265eef222Smrg test -n "$future_libdirs" && \ 4803b312a94cSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 4804ef981d24Smrg 480565eef222Smrg if test -n "$current_libdirs"; then 480665eef222Smrg # Maybe just do a dry run. 480765eef222Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 4808b312a94cSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 480965eef222Smrg else 481065eef222Smrg exit $EXIT_SUCCESS 481165eef222Smrg fi 481265eef222Smrg} 4813ef981d24Smrg 4814b312a94cSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4815ef981d24Smrg 4816ef981d24Smrg 481765eef222Smrg# func_generate_dlsyms outputname originator pic_p 481865eef222Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 481965eef222Smrg# a dlpreopen symbol table. 482065eef222Smrgfunc_generate_dlsyms () 482165eef222Smrg{ 4822b312a94cSmrg $debug_cmd 4823b312a94cSmrg 4824b312a94cSmrg my_outputname=$1 4825b312a94cSmrg my_originator=$2 4826b312a94cSmrg my_pic_p=${3-false} 4827b312a94cSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 482865eef222Smrg my_dlsyms= 482965eef222Smrg 4830b312a94cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 483165eef222Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4832b312a94cSmrg my_dlsyms=${my_outputname}S.c 483365eef222Smrg else 483465eef222Smrg func_error "not configured to extract global symbols from dlpreopened files" 483565eef222Smrg fi 483665eef222Smrg fi 4837ef981d24Smrg 483865eef222Smrg if test -n "$my_dlsyms"; then 483965eef222Smrg case $my_dlsyms in 484065eef222Smrg "") ;; 484165eef222Smrg *.c) 484265eef222Smrg # Discover the nlist of each of the dlfiles. 4843b312a94cSmrg nlist=$output_objdir/$my_outputname.nm 484465eef222Smrg 484565eef222Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 484665eef222Smrg 484765eef222Smrg # Parse the name list into a source file. 484865eef222Smrg func_verbose "creating $output_objdir/$my_dlsyms" 484965eef222Smrg 485065eef222Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4851b312a94cSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4852b312a94cSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 485365eef222Smrg 485465eef222Smrg#ifdef __cplusplus 485565eef222Smrgextern \"C\" { 485665eef222Smrg#endif 485765eef222Smrg 4858b312a94cSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 485956957a04Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 486056957a04Smrg#endif 486156957a04Smrg 4862200d7199Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4863b312a94cSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4864b312a94cSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4865200d7199Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4866200d7199Smrg# define LT_DLSYM_CONST 4867b312a94cSmrg#elif defined __osf__ 4868200d7199Smrg/* This system does not cope well with relocations in const data. */ 4869200d7199Smrg# define LT_DLSYM_CONST 4870200d7199Smrg#else 4871200d7199Smrg# define LT_DLSYM_CONST const 4872200d7199Smrg#endif 4873200d7199Smrg 4874b312a94cSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4875b312a94cSmrg 487665eef222Smrg/* External symbol declarations for the compiler. */\ 487765eef222Smrg" 487865eef222Smrg 4879b312a94cSmrg if test yes = "$dlself"; then 4880b312a94cSmrg func_verbose "generating symbol list for '$output'" 488165eef222Smrg 488265eef222Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 488365eef222Smrg 488465eef222Smrg # Add our own program objects to the symbol list. 488556957a04Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 488665eef222Smrg for progfile in $progfiles; do 4887200d7199Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4888b312a94cSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4889200d7199Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 489065eef222Smrg done 489165eef222Smrg 489265eef222Smrg if test -n "$exclude_expsyms"; then 489365eef222Smrg $opt_dry_run || { 489465eef222Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 489565eef222Smrg eval '$MV "$nlist"T "$nlist"' 489665eef222Smrg } 4897ef981d24Smrg fi 4898ef981d24Smrg 489965eef222Smrg if test -n "$export_symbols_regex"; then 490065eef222Smrg $opt_dry_run || { 490165eef222Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 490265eef222Smrg eval '$MV "$nlist"T "$nlist"' 490365eef222Smrg } 4904ef981d24Smrg fi 490565eef222Smrg 490665eef222Smrg # Prepare the list of exported symbols 490765eef222Smrg if test -z "$export_symbols"; then 4908b312a94cSmrg export_symbols=$output_objdir/$outputname.exp 490965eef222Smrg $opt_dry_run || { 491065eef222Smrg $RM $export_symbols 4911b312a94cSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 491265eef222Smrg case $host in 491365eef222Smrg *cygwin* | *mingw* | *cegcc* ) 491465eef222Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 491565eef222Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 491665eef222Smrg ;; 4917ef981d24Smrg esac 491865eef222Smrg } 491965eef222Smrg else 492065eef222Smrg $opt_dry_run || { 4921b312a94cSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 492265eef222Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 492365eef222Smrg eval '$MV "$nlist"T "$nlist"' 492465eef222Smrg case $host in 492556957a04Smrg *cygwin* | *mingw* | *cegcc* ) 492665eef222Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 492765eef222Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 492865eef222Smrg ;; 4929ef981d24Smrg esac 493065eef222Smrg } 4931ef981d24Smrg fi 493265eef222Smrg fi 4933ef981d24Smrg 493465eef222Smrg for dlprefile in $dlprefiles; do 4935b312a94cSmrg func_verbose "extracting global C symbols from '$dlprefile'" 493665eef222Smrg func_basename "$dlprefile" 4937b312a94cSmrg name=$func_basename_result 4938200d7199Smrg case $host in 4939200d7199Smrg *cygwin* | *mingw* | *cegcc* ) 4940200d7199Smrg # if an import library, we need to obtain dlname 4941200d7199Smrg if func_win32_import_lib_p "$dlprefile"; then 4942200d7199Smrg func_tr_sh "$dlprefile" 4943200d7199Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 4944b312a94cSmrg dlprefile_dlbasename= 4945200d7199Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4946200d7199Smrg # Use subshell, to avoid clobbering current variable values 4947200d7199Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4948b312a94cSmrg if test -n "$dlprefile_dlname"; then 4949200d7199Smrg func_basename "$dlprefile_dlname" 4950b312a94cSmrg dlprefile_dlbasename=$func_basename_result 4951200d7199Smrg else 4952200d7199Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 4953200d7199Smrg $sharedlib_from_linklib_cmd "$dlprefile" 4954200d7199Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4955200d7199Smrg fi 4956200d7199Smrg fi 4957200d7199Smrg $opt_dry_run || { 4958b312a94cSmrg if test -n "$dlprefile_dlbasename"; then 4959200d7199Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4960200d7199Smrg else 4961200d7199Smrg func_warning "Could not compute DLL name from $name" 4962200d7199Smrg eval '$ECHO ": $name " >> "$nlist"' 4963200d7199Smrg fi 4964200d7199Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4965200d7199Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4966200d7199Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4967200d7199Smrg } 4968200d7199Smrg else # not an import lib 4969200d7199Smrg $opt_dry_run || { 4970200d7199Smrg eval '$ECHO ": $name " >> "$nlist"' 4971200d7199Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4972200d7199Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4973200d7199Smrg } 4974200d7199Smrg fi 4975200d7199Smrg ;; 4976200d7199Smrg *) 4977200d7199Smrg $opt_dry_run || { 4978200d7199Smrg eval '$ECHO ": $name " >> "$nlist"' 4979200d7199Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4980200d7199Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4981200d7199Smrg } 4982200d7199Smrg ;; 4983200d7199Smrg esac 498465eef222Smrg done 4985ef981d24Smrg 498665eef222Smrg $opt_dry_run || { 498765eef222Smrg # Make sure we have at least an empty file. 498865eef222Smrg test -f "$nlist" || : > "$nlist" 4989ef981d24Smrg 499065eef222Smrg if test -n "$exclude_expsyms"; then 499165eef222Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 499265eef222Smrg $MV "$nlist"T "$nlist" 4993ef981d24Smrg fi 4994ef981d24Smrg 499565eef222Smrg # Try sorting and uniquifying the output. 499665eef222Smrg if $GREP -v "^: " < "$nlist" | 499765eef222Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 499865eef222Smrg sort -k 3 4999ef981d24Smrg else 500065eef222Smrg sort +2 500165eef222Smrg fi | 500265eef222Smrg uniq > "$nlist"S; then 500365eef222Smrg : 5004ef981d24Smrg else 500565eef222Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 5006ef981d24Smrg fi 5007ef981d24Smrg 500865eef222Smrg if test -f "$nlist"S; then 500965eef222Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 5010ef981d24Smrg else 501156957a04Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 5012ef981d24Smrg fi 5013ef981d24Smrg 5014b312a94cSmrg func_show_eval '$RM "${nlist}I"' 5015b312a94cSmrg if test -n "$global_symbol_to_import"; then 5016b312a94cSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 5017b312a94cSmrg fi 5018b312a94cSmrg 501956957a04Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5020ef981d24Smrg 502165eef222Smrg/* The mapping between symbol names and symbols. */ 502265eef222Smrgtypedef struct { 502365eef222Smrg const char *name; 502465eef222Smrg void *address; 502565eef222Smrg} lt_dlsymlist; 5026200d7199Smrgextern LT_DLSYM_CONST lt_dlsymlist 5027b312a94cSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 5028b312a94cSmrg" 5029b312a94cSmrg 5030b312a94cSmrg if test -s "$nlist"I; then 5031b312a94cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 5032b312a94cSmrgstatic void lt_syminit(void) 5033b312a94cSmrg{ 5034b312a94cSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 5035b312a94cSmrg for (; symbol->name; ++symbol) 5036b312a94cSmrg {" 5037b312a94cSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 5038b312a94cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 5039b312a94cSmrg } 5040b312a94cSmrg}" 5041b312a94cSmrg fi 5042b312a94cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 5043200d7199SmrgLT_DLSYM_CONST lt_dlsymlist 504465eef222Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 5045b312a94cSmrg{ {\"$my_originator\", (void *) 0}," 5046b312a94cSmrg 5047b312a94cSmrg if test -s "$nlist"I; then 5048b312a94cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 5049b312a94cSmrg {\"@INIT@\", (void *) <_syminit}," 5050b312a94cSmrg fi 505165eef222Smrg 505265eef222Smrg case $need_lib_prefix in 505365eef222Smrg no) 505465eef222Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 505565eef222Smrg ;; 505665eef222Smrg *) 505765eef222Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 505865eef222Smrg ;; 505965eef222Smrg esac 506056957a04Smrg echo >> "$output_objdir/$my_dlsyms" "\ 506165eef222Smrg {0, (void *) 0} 506265eef222Smrg}; 506365eef222Smrg 506465eef222Smrg/* This works around a problem in FreeBSD linker */ 506565eef222Smrg#ifdef FREEBSD_WORKAROUND 506665eef222Smrgstatic const void *lt_preloaded_setup() { 506765eef222Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 506865eef222Smrg} 506965eef222Smrg#endif 507065eef222Smrg 507165eef222Smrg#ifdef __cplusplus 507265eef222Smrg} 507365eef222Smrg#endif\ 507465eef222Smrg" 507565eef222Smrg } # !$opt_dry_run 507665eef222Smrg 507765eef222Smrg pic_flag_for_symtable= 507865eef222Smrg case "$compile_command " in 507965eef222Smrg *" -static "*) ;; 508065eef222Smrg *) 508165eef222Smrg case $host in 508265eef222Smrg # compiling the symbol table file with pic_flag works around 508365eef222Smrg # a FreeBSD bug that causes programs to crash when -lm is 508465eef222Smrg # linked before any other PIC object. But we must not use 508565eef222Smrg # pic_flag when linking with -static. The problem exists in 508665eef222Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 5087b312a94cSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 508865eef222Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 508965eef222Smrg *-*-hpux*) 509065eef222Smrg pic_flag_for_symtable=" $pic_flag" ;; 509165eef222Smrg *) 5092b312a94cSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 509365eef222Smrg ;; 509465eef222Smrg esac 509565eef222Smrg ;; 509665eef222Smrg esac 509765eef222Smrg symtab_cflags= 509865eef222Smrg for arg in $LTCFLAGS; do 509965eef222Smrg case $arg in 510065eef222Smrg -pie | -fpie | -fPIE) ;; 5101200d7199Smrg *) func_append symtab_cflags " $arg" ;; 510265eef222Smrg esac 510365eef222Smrg done 5104ef981d24Smrg 510565eef222Smrg # Now compile the dynamic symbol file. 510665eef222Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 5107ef981d24Smrg 510865eef222Smrg # Clean up the generated files. 5109b312a94cSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 511065eef222Smrg 511165eef222Smrg # Transform the symbol file into the correct name. 5112b312a94cSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 511365eef222Smrg case $host in 511465eef222Smrg *cygwin* | *mingw* | *cegcc* ) 511565eef222Smrg if test -f "$output_objdir/$my_outputname.def"; then 511656957a04Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 511756957a04Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 511865eef222Smrg else 511956957a04Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512056957a04Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512165eef222Smrg fi 512265eef222Smrg ;; 512365eef222Smrg *) 512456957a04Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512556957a04Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5126ef981d24Smrg ;; 5127ef981d24Smrg esac 512865eef222Smrg ;; 512965eef222Smrg *) 5130b312a94cSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 513165eef222Smrg ;; 513265eef222Smrg esac 513365eef222Smrg else 513465eef222Smrg # We keep going just in case the user didn't refer to 513565eef222Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 513665eef222Smrg # really was required. 513765eef222Smrg 513865eef222Smrg # Nullify the symbol file. 513956957a04Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 514056957a04Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 5141ef981d24Smrg fi 514265eef222Smrg} 5143ef981d24Smrg 5144b312a94cSmrg# func_cygming_gnu_implib_p ARG 5145b312a94cSmrg# This predicate returns with zero status (TRUE) if 5146b312a94cSmrg# ARG is a GNU/binutils-style import library. Returns 5147b312a94cSmrg# with nonzero status (FALSE) otherwise. 5148b312a94cSmrgfunc_cygming_gnu_implib_p () 5149b312a94cSmrg{ 5150b312a94cSmrg $debug_cmd 5151b312a94cSmrg 5152b312a94cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5153b312a94cSmrg 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)$'` 5154b312a94cSmrg test -n "$func_cygming_gnu_implib_tmp" 5155b312a94cSmrg} 5156b312a94cSmrg 5157b312a94cSmrg# func_cygming_ms_implib_p ARG 5158b312a94cSmrg# This predicate returns with zero status (TRUE) if 5159b312a94cSmrg# ARG is an MS-style import library. Returns 5160b312a94cSmrg# with nonzero status (FALSE) otherwise. 5161b312a94cSmrgfunc_cygming_ms_implib_p () 5162b312a94cSmrg{ 5163b312a94cSmrg $debug_cmd 5164b312a94cSmrg 5165b312a94cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5166b312a94cSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 5167b312a94cSmrg test -n "$func_cygming_ms_implib_tmp" 5168b312a94cSmrg} 5169b312a94cSmrg 517065eef222Smrg# func_win32_libid arg 517165eef222Smrg# return the library type of file 'arg' 517265eef222Smrg# 517365eef222Smrg# Need a lot of goo to handle *both* DLLs and import libs 517465eef222Smrg# Has to be a shell function in order to 'eat' the argument 517565eef222Smrg# that is supplied when $file_magic_command is called. 517656957a04Smrg# Despite the name, also deal with 64 bit binaries. 517765eef222Smrgfunc_win32_libid () 517865eef222Smrg{ 5179b312a94cSmrg $debug_cmd 5180b312a94cSmrg 5181b312a94cSmrg win32_libid_type=unknown 518265eef222Smrg win32_fileres=`file -L $1 2>/dev/null` 518365eef222Smrg case $win32_fileres in 518465eef222Smrg *ar\ archive\ import\ library*) # definitely import 518565eef222Smrg win32_libid_type="x86 archive import" 518665eef222Smrg ;; 518765eef222Smrg *ar\ archive*) # could be an import, or static 518856957a04Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 518965eef222Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 519056957a04Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 5191b312a94cSmrg case $nm_interface in 5192b312a94cSmrg "MS dumpbin") 5193b312a94cSmrg if func_cygming_ms_implib_p "$1" || 5194b312a94cSmrg func_cygming_gnu_implib_p "$1" 5195b312a94cSmrg then 5196b312a94cSmrg win32_nmres=import 5197b312a94cSmrg else 5198b312a94cSmrg win32_nmres= 5199b312a94cSmrg fi 5200b312a94cSmrg ;; 5201b312a94cSmrg *) 5202b312a94cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5203b312a94cSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 5204b312a94cSmrg $SED -n -e ' 520565eef222Smrg 1,100{ 520665eef222Smrg / I /{ 5207b312a94cSmrg s|.*|import| 520865eef222Smrg p 520965eef222Smrg q 521065eef222Smrg } 521165eef222Smrg }'` 5212b312a94cSmrg ;; 5213b312a94cSmrg esac 521465eef222Smrg case $win32_nmres in 521565eef222Smrg import*) win32_libid_type="x86 archive import";; 521665eef222Smrg *) win32_libid_type="x86 archive static";; 521765eef222Smrg esac 521865eef222Smrg fi 521965eef222Smrg ;; 522065eef222Smrg *DLL*) 522165eef222Smrg win32_libid_type="x86 DLL" 522265eef222Smrg ;; 522365eef222Smrg *executable*) # but shell scripts are "executable" too... 522465eef222Smrg case $win32_fileres in 522565eef222Smrg *MS\ Windows\ PE\ Intel*) 522665eef222Smrg win32_libid_type="x86 DLL" 522765eef222Smrg ;; 522865eef222Smrg esac 522965eef222Smrg ;; 523065eef222Smrg esac 523165eef222Smrg $ECHO "$win32_libid_type" 523265eef222Smrg} 5233ef981d24Smrg 5234200d7199Smrg# func_cygming_dll_for_implib ARG 5235200d7199Smrg# 5236200d7199Smrg# Platform-specific function to extract the 5237200d7199Smrg# name of the DLL associated with the specified 5238200d7199Smrg# import library ARG. 5239200d7199Smrg# Invoked by eval'ing the libtool variable 5240200d7199Smrg# $sharedlib_from_linklib_cmd 5241200d7199Smrg# Result is available in the variable 5242200d7199Smrg# $sharedlib_from_linklib_result 5243200d7199Smrgfunc_cygming_dll_for_implib () 5244200d7199Smrg{ 5245b312a94cSmrg $debug_cmd 5246b312a94cSmrg 5247200d7199Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 5248200d7199Smrg} 5249200d7199Smrg 5250200d7199Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 5251200d7199Smrg# 5252200d7199Smrg# The is the core of a fallback implementation of a 5253200d7199Smrg# platform-specific function to extract the name of the 5254200d7199Smrg# DLL associated with the specified import library LIBNAME. 5255200d7199Smrg# 5256200d7199Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5257200d7199Smrg# on the platform and compiler that created the implib. 5258200d7199Smrg# 5259200d7199Smrg# Echos the name of the DLL associated with the 5260200d7199Smrg# specified import library. 5261200d7199Smrgfunc_cygming_dll_for_implib_fallback_core () 5262200d7199Smrg{ 5263b312a94cSmrg $debug_cmd 5264b312a94cSmrg 5265200d7199Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5266200d7199Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5267200d7199Smrg $SED '/^Contents of section '"$match_literal"':/{ 5268200d7199Smrg # Place marker at beginning of archive member dllname section 5269200d7199Smrg s/.*/====MARK====/ 5270200d7199Smrg p 5271200d7199Smrg d 5272200d7199Smrg } 5273200d7199Smrg # These lines can sometimes be longer than 43 characters, but 5274200d7199Smrg # are always uninteresting 5275200d7199Smrg /:[ ]*file format pe[i]\{,1\}-/d 5276200d7199Smrg /^In archive [^:]*:/d 5277200d7199Smrg # Ensure marker is printed 5278200d7199Smrg /^====MARK====/p 5279200d7199Smrg # Remove all lines with less than 43 characters 5280200d7199Smrg /^.\{43\}/!d 5281200d7199Smrg # From remaining lines, remove first 43 characters 5282200d7199Smrg s/^.\{43\}//' | 5283200d7199Smrg $SED -n ' 5284200d7199Smrg # Join marker and all lines until next marker into a single line 5285200d7199Smrg /^====MARK====/ b para 5286200d7199Smrg H 5287200d7199Smrg $ b para 5288200d7199Smrg b 5289200d7199Smrg :para 5290200d7199Smrg x 5291200d7199Smrg s/\n//g 5292200d7199Smrg # Remove the marker 5293200d7199Smrg s/^====MARK====// 5294200d7199Smrg # Remove trailing dots and whitespace 5295200d7199Smrg s/[\. \t]*$// 5296200d7199Smrg # Print 5297200d7199Smrg /./p' | 5298200d7199Smrg # we now have a list, one entry per line, of the stringified 5299200d7199Smrg # contents of the appropriate section of all members of the 5300b312a94cSmrg # archive that possess that section. Heuristic: eliminate 5301b312a94cSmrg # all those that have a first or second character that is 5302200d7199Smrg # a '.' (that is, objdump's representation of an unprintable 5303200d7199Smrg # character.) This should work for all archives with less than 5304200d7199Smrg # 0x302f exports -- but will fail for DLLs whose name actually 5305200d7199Smrg # begins with a literal '.' or a single character followed by 5306200d7199Smrg # a '.'. 5307200d7199Smrg # 5308200d7199Smrg # Of those that remain, print the first one. 5309200d7199Smrg $SED -e '/^\./d;/^.\./d;q' 5310200d7199Smrg} 5311200d7199Smrg 5312200d7199Smrg# func_cygming_dll_for_implib_fallback ARG 5313200d7199Smrg# Platform-specific function to extract the 5314200d7199Smrg# name of the DLL associated with the specified 5315200d7199Smrg# import library ARG. 5316200d7199Smrg# 5317200d7199Smrg# This fallback implementation is for use when $DLLTOOL 5318200d7199Smrg# does not support the --identify-strict option. 5319200d7199Smrg# Invoked by eval'ing the libtool variable 5320200d7199Smrg# $sharedlib_from_linklib_cmd 5321200d7199Smrg# Result is available in the variable 5322200d7199Smrg# $sharedlib_from_linklib_result 5323200d7199Smrgfunc_cygming_dll_for_implib_fallback () 5324200d7199Smrg{ 5325b312a94cSmrg $debug_cmd 5326b312a94cSmrg 5327b312a94cSmrg if func_cygming_gnu_implib_p "$1"; then 5328200d7199Smrg # binutils import library 5329200d7199Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5330b312a94cSmrg elif func_cygming_ms_implib_p "$1"; then 5331200d7199Smrg # ms-generated import library 5332200d7199Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5333200d7199Smrg else 5334200d7199Smrg # unknown 5335b312a94cSmrg sharedlib_from_linklib_result= 5336200d7199Smrg fi 5337200d7199Smrg} 5338ef981d24Smrg 5339ef981d24Smrg 534065eef222Smrg# func_extract_an_archive dir oldlib 534165eef222Smrgfunc_extract_an_archive () 534265eef222Smrg{ 5343b312a94cSmrg $debug_cmd 5344b312a94cSmrg 5345b312a94cSmrg f_ex_an_ar_dir=$1; shift 5346b312a94cSmrg f_ex_an_ar_oldlib=$1 5347b312a94cSmrg if test yes = "$lock_old_archive_extraction"; then 534856957a04Smrg lockfile=$f_ex_an_ar_oldlib.lock 534956957a04Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 535056957a04Smrg func_echo "Waiting for $lockfile to be removed" 535156957a04Smrg sleep 2 535256957a04Smrg done 535356957a04Smrg fi 535456957a04Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 535556957a04Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 5356b312a94cSmrg if test yes = "$lock_old_archive_extraction"; then 535756957a04Smrg $opt_dry_run || rm -f "$lockfile" 535856957a04Smrg fi 535965eef222Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 536065eef222Smrg : 536165eef222Smrg else 536265eef222Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 536365eef222Smrg fi 536465eef222Smrg} 5365ef981d24Smrg 5366ef981d24Smrg 536765eef222Smrg# func_extract_archives gentop oldlib ... 536865eef222Smrgfunc_extract_archives () 536965eef222Smrg{ 5370b312a94cSmrg $debug_cmd 5371b312a94cSmrg 5372b312a94cSmrg my_gentop=$1; shift 537365eef222Smrg my_oldlibs=${1+"$@"} 5374b312a94cSmrg my_oldobjs= 5375b312a94cSmrg my_xlib= 5376b312a94cSmrg my_xabs= 5377b312a94cSmrg my_xdir= 5378ef981d24Smrg 537965eef222Smrg for my_xlib in $my_oldlibs; do 538065eef222Smrg # Extract the objects. 538165eef222Smrg case $my_xlib in 5382b312a94cSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 538365eef222Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 538465eef222Smrg esac 538565eef222Smrg func_basename "$my_xlib" 5386b312a94cSmrg my_xlib=$func_basename_result 538765eef222Smrg my_xlib_u=$my_xlib 538865eef222Smrg while :; do 538965eef222Smrg case " $extracted_archives " in 539065eef222Smrg *" $my_xlib_u "*) 539165eef222Smrg func_arith $extracted_serial + 1 539265eef222Smrg extracted_serial=$func_arith_result 539365eef222Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 539465eef222Smrg *) break ;; 539565eef222Smrg esac 539665eef222Smrg done 539765eef222Smrg extracted_archives="$extracted_archives $my_xlib_u" 5398b312a94cSmrg my_xdir=$my_gentop/$my_xlib_u 5399ef981d24Smrg 540065eef222Smrg func_mkdir_p "$my_xdir" 5401ef981d24Smrg 540265eef222Smrg case $host in 540365eef222Smrg *-darwin*) 540465eef222Smrg func_verbose "Extracting $my_xabs" 540565eef222Smrg # Do not bother doing anything if just a dry run 540665eef222Smrg $opt_dry_run || { 540765eef222Smrg darwin_orig_dir=`pwd` 540865eef222Smrg cd $my_xdir || exit $? 540965eef222Smrg darwin_archive=$my_xabs 541065eef222Smrg darwin_curdir=`pwd` 5411b312a94cSmrg func_basename "$darwin_archive" 5412b312a94cSmrg darwin_base_archive=$func_basename_result 541365eef222Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 541465eef222Smrg if test -n "$darwin_arches"; then 541565eef222Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 541665eef222Smrg darwin_arch= 541765eef222Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5418b312a94cSmrg for darwin_arch in $darwin_arches; do 5419b312a94cSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5420b312a94cSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5421b312a94cSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5422b312a94cSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 542365eef222Smrg cd "$darwin_curdir" 5424b312a94cSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 542565eef222Smrg done # $darwin_arches 542665eef222Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5427b312a94cSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 542865eef222Smrg darwin_file= 542965eef222Smrg darwin_files= 543065eef222Smrg for darwin_file in $darwin_filelist; do 543156957a04Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 543265eef222Smrg $LIPO -create -output "$darwin_file" $darwin_files 543365eef222Smrg done # $darwin_filelist 543465eef222Smrg $RM -rf unfat-$$ 543565eef222Smrg cd "$darwin_orig_dir" 543665eef222Smrg else 543765eef222Smrg cd $darwin_orig_dir 543865eef222Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 543965eef222Smrg fi # $darwin_arches 544065eef222Smrg } # !$opt_dry_run 544165eef222Smrg ;; 544265eef222Smrg *) 544365eef222Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 544465eef222Smrg ;; 5445ef981d24Smrg esac 544656957a04Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 544765eef222Smrg done 5448ef981d24Smrg 5449b312a94cSmrg func_extract_archives_result=$my_oldobjs 545065eef222Smrg} 5451ef981d24Smrg 5452ef981d24Smrg 545356957a04Smrg# func_emit_wrapper [arg=no] 545456957a04Smrg# 545556957a04Smrg# Emit a libtool wrapper script on stdout. 545656957a04Smrg# Don't directly open a file because we may want to 545756957a04Smrg# incorporate the script contents within a cygwin/mingw 545856957a04Smrg# wrapper executable. Must ONLY be called from within 545956957a04Smrg# func_mode_link because it depends on a number of variables 546056957a04Smrg# set therein. 546165eef222Smrg# 546256957a04Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 546356957a04Smrg# variable will take. If 'yes', then the emitted script 5464b312a94cSmrg# will assume that the directory where it is stored is 546556957a04Smrg# the $objdir directory. This is a cygwin/mingw-specific 546656957a04Smrg# behavior. 546756957a04Smrgfunc_emit_wrapper () 546865eef222Smrg{ 546956957a04Smrg func_emit_wrapper_arg1=${1-no} 5470ef981d24Smrg 547165eef222Smrg $ECHO "\ 547265eef222Smrg#! $SHELL 5473ef981d24Smrg 547465eef222Smrg# $output - temporary wrapper script for $objdir/$outputname 5475b312a94cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 547665eef222Smrg# 547765eef222Smrg# The $output program cannot be directly executed until all the libtool 547865eef222Smrg# libraries that it depends on are installed. 547965eef222Smrg# 548065eef222Smrg# This wrapper script should never be moved out of the build directory. 548165eef222Smrg# If it is, it will not operate correctly. 5482ef981d24Smrg 548365eef222Smrg# Sed substitution that helps us do robust quoting. It backslashifies 548465eef222Smrg# metacharacters that are still active within double-quoted strings. 548565eef222Smrgsed_quote_subst='$sed_quote_subst' 5486ef981d24Smrg 548765eef222Smrg# Be Bourne compatible 548865eef222Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 548965eef222Smrg emulate sh 549065eef222Smrg NULLCMD=: 549165eef222Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 549265eef222Smrg # is contrary to our usage. Disable this feature. 549365eef222Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 549465eef222Smrg setopt NO_GLOB_SUBST 549565eef222Smrgelse 549665eef222Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 549765eef222Smrgfi 549865eef222SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 549965eef222SmrgDUALCASE=1; export DUALCASE # for MKS sh 5500ef981d24Smrg 550165eef222Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 550265eef222Smrg# if CDPATH is set. 550365eef222Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5504ef981d24Smrg 550565eef222Smrgrelink_command=\"$relink_command\" 5506ef981d24Smrg 550765eef222Smrg# This environment variable determines our operation mode. 550865eef222Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 550965eef222Smrg # install mode needs the following variables: 551065eef222Smrg generated_by_libtool_version='$macro_version' 551165eef222Smrg notinst_deplibs='$notinst_deplibs' 551265eef222Smrgelse 551365eef222Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 551465eef222Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 551556957a04Smrg file=\"\$0\"" 551656957a04Smrg 5517d5637ae9Smrg func_quote_arg pretty "$ECHO" 5518d5637ae9Smrg qECHO=$func_quote_arg_result 551956957a04Smrg $ECHO "\ 552056957a04Smrg 552156957a04Smrg# A function that is used when there is no print builtin or printf. 552256957a04Smrgfunc_fallback_echo () 552356957a04Smrg{ 552456957a04Smrg eval 'cat <<_LTECHO_EOF 552556957a04Smrg\$1 552656957a04Smrg_LTECHO_EOF' 552756957a04Smrg} 5528d5637ae9Smrg ECHO=$qECHO 552956957a04Smrg fi 553056957a04Smrg 553156957a04Smrg# Very basic option parsing. These options are (a) specific to 553256957a04Smrg# the libtool wrapper, (b) are identical between the wrapper 5533b312a94cSmrg# /script/ and the wrapper /executable/ that is used only on 553456957a04Smrg# windows platforms, and (c) all begin with the string "--lt-" 5535b312a94cSmrg# (application programs are unlikely to have options that match 553656957a04Smrg# this pattern). 553756957a04Smrg# 553856957a04Smrg# There are only two supported options: --lt-debug and 553956957a04Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 554056957a04Smrg# 554156957a04Smrg# The first argument to this parsing function should be the 554256957a04Smrg# script's $0 value, followed by "$@". 554356957a04Smrglt_option_debug= 554456957a04Smrgfunc_parse_lt_options () 554556957a04Smrg{ 554656957a04Smrg lt_script_arg0=\$0 554756957a04Smrg shift 554856957a04Smrg for lt_opt 554956957a04Smrg do 555056957a04Smrg case \"\$lt_opt\" in 555156957a04Smrg --lt-debug) lt_option_debug=1 ;; 555256957a04Smrg --lt-dump-script) 555356957a04Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 555456957a04Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 555556957a04Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 555656957a04Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 555756957a04Smrg exit 0 555856957a04Smrg ;; 555956957a04Smrg --lt-*) 556056957a04Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 556156957a04Smrg exit 1 556256957a04Smrg ;; 556356957a04Smrg esac 556456957a04Smrg done 556556957a04Smrg 556656957a04Smrg # Print the debug banner immediately: 556756957a04Smrg if test -n \"\$lt_option_debug\"; then 5568b312a94cSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 556956957a04Smrg fi 557056957a04Smrg} 557156957a04Smrg 557256957a04Smrg# Used when --lt-debug. Prints its arguments to stdout 557356957a04Smrg# (redirection is the responsibility of the caller) 557456957a04Smrgfunc_lt_dump_args () 557556957a04Smrg{ 557656957a04Smrg lt_dump_args_N=1; 557756957a04Smrg for lt_arg 557856957a04Smrg do 5579b312a94cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 558056957a04Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 558156957a04Smrg done 558256957a04Smrg} 558356957a04Smrg 558456957a04Smrg# Core function for launching the target application 558556957a04Smrgfunc_exec_program_core () 558656957a04Smrg{ 558765eef222Smrg" 558856957a04Smrg case $host in 558956957a04Smrg # Backslashes separate directories on plain windows 559056957a04Smrg *-*-mingw | *-*-os2* | *-cegcc*) 559156957a04Smrg $ECHO "\ 559256957a04Smrg if test -n \"\$lt_option_debug\"; then 5593b312a94cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 559456957a04Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 559556957a04Smrg fi 559656957a04Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 559756957a04Smrg" 559856957a04Smrg ;; 559956957a04Smrg 560056957a04Smrg *) 560156957a04Smrg $ECHO "\ 560256957a04Smrg if test -n \"\$lt_option_debug\"; then 5603b312a94cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 560456957a04Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 560556957a04Smrg fi 560656957a04Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 560756957a04Smrg" 560856957a04Smrg ;; 560956957a04Smrg esac 561056957a04Smrg $ECHO "\ 561156957a04Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 561256957a04Smrg exit 1 561356957a04Smrg} 561456957a04Smrg 561556957a04Smrg# A function to encapsulate launching the target application 561656957a04Smrg# Strips options in the --lt-* namespace from \$@ and 561756957a04Smrg# launches target application with the remaining arguments. 561856957a04Smrgfunc_exec_program () 561956957a04Smrg{ 5620b312a94cSmrg case \" \$* \" in 5621b312a94cSmrg *\\ --lt-*) 5622b312a94cSmrg for lt_wr_arg 5623b312a94cSmrg do 5624b312a94cSmrg case \$lt_wr_arg in 5625b312a94cSmrg --lt-*) ;; 5626b312a94cSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5627b312a94cSmrg esac 5628b312a94cSmrg shift 5629b312a94cSmrg done ;; 5630b312a94cSmrg esac 563156957a04Smrg func_exec_program_core \${1+\"\$@\"} 563256957a04Smrg} 563356957a04Smrg 563456957a04Smrg # Parse options 563556957a04Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5636ef981d24Smrg 563765eef222Smrg # Find the directory that this script lives in. 563856957a04Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 563965eef222Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5640ef981d24Smrg 564165eef222Smrg # Follow symbolic links until we get to the real thisdir. 564256957a04Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 564365eef222Smrg while test -n \"\$file\"; do 564456957a04Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5645ef981d24Smrg 564665eef222Smrg # If there was a directory component, then change thisdir. 564765eef222Smrg if test \"x\$destdir\" != \"x\$file\"; then 564865eef222Smrg case \"\$destdir\" in 564965eef222Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 565065eef222Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 565165eef222Smrg esac 565265eef222Smrg fi 5653ef981d24Smrg 565456957a04Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 565556957a04Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 565665eef222Smrg done 5657ef981d24Smrg 565865eef222Smrg # Usually 'no', except on cygwin/mingw when embedded into 565965eef222Smrg # the cwrapper. 566056957a04Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 566165eef222Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 566265eef222Smrg # special case for '.' 566365eef222Smrg if test \"\$thisdir\" = \".\"; then 566465eef222Smrg thisdir=\`pwd\` 566565eef222Smrg fi 566665eef222Smrg # remove .libs from thisdir 566765eef222Smrg case \"\$thisdir\" in 566856957a04Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 566965eef222Smrg $objdir ) thisdir=. ;; 567065eef222Smrg esac 567165eef222Smrg fi 5672ef981d24Smrg 567365eef222Smrg # Try to get the absolute directory name. 567465eef222Smrg absdir=\`cd \"\$thisdir\" && pwd\` 567565eef222Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 567665eef222Smrg" 5677ef981d24Smrg 5678b312a94cSmrg if test yes = "$fast_install"; then 567965eef222Smrg $ECHO "\ 568065eef222Smrg program=lt-'$outputname'$exeext 568165eef222Smrg progdir=\"\$thisdir/$objdir\" 5682ef981d24Smrg 568365eef222Smrg if test ! -f \"\$progdir/\$program\" || 5684b312a94cSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 568565eef222Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5686ef981d24Smrg 568765eef222Smrg file=\"\$\$-\$program\" 5688ef981d24Smrg 568965eef222Smrg if test ! -d \"\$progdir\"; then 569065eef222Smrg $MKDIR \"\$progdir\" 569165eef222Smrg else 569265eef222Smrg $RM \"\$progdir/\$file\" 569365eef222Smrg fi" 5694ef981d24Smrg 569565eef222Smrg $ECHO "\ 5696ef981d24Smrg 569765eef222Smrg # relink executable if necessary 569865eef222Smrg if test -n \"\$relink_command\"; then 569965eef222Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 570065eef222Smrg else 5701b312a94cSmrg \$ECHO \"\$relink_command_output\" >&2 570265eef222Smrg $RM \"\$progdir/\$file\" 570365eef222Smrg exit 1 570465eef222Smrg fi 570565eef222Smrg fi 5706ef981d24Smrg 570765eef222Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 570865eef222Smrg { $RM \"\$progdir/\$program\"; 570965eef222Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 571065eef222Smrg $RM \"\$progdir/\$file\" 571165eef222Smrg fi" 571265eef222Smrg else 571365eef222Smrg $ECHO "\ 571465eef222Smrg program='$outputname' 571565eef222Smrg progdir=\"\$thisdir/$objdir\" 571665eef222Smrg" 571765eef222Smrg fi 5718ef981d24Smrg 571965eef222Smrg $ECHO "\ 5720ef981d24Smrg 572165eef222Smrg if test -f \"\$progdir/\$program\"; then" 5722ef981d24Smrg 5723200d7199Smrg # fixup the dll searchpath if we need to. 5724200d7199Smrg # 5725200d7199Smrg # Fix the DLL searchpath if we need to. Do this before prepending 5726200d7199Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 5727200d7199Smrg # libraries must come first. 5728200d7199Smrg if test -n "$dllsearchpath"; then 5729200d7199Smrg $ECHO "\ 5730200d7199Smrg # Add the dll search path components to the executable PATH 5731200d7199Smrg PATH=$dllsearchpath:\$PATH 5732200d7199Smrg" 5733200d7199Smrg fi 5734200d7199Smrg 573565eef222Smrg # Export our shlibpath_var if we have one. 5736b312a94cSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 573765eef222Smrg $ECHO "\ 573865eef222Smrg # Add our own library path to $shlibpath_var 573965eef222Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5740ef981d24Smrg 574165eef222Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 574265eef222Smrg # The second colon is a workaround for a bug in BeOS R4 sed 574356957a04Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5744ef981d24Smrg 574565eef222Smrg export $shlibpath_var 574665eef222Smrg" 5747ef981d24Smrg fi 5748ef981d24Smrg 574965eef222Smrg $ECHO "\ 575065eef222Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 575165eef222Smrg # Run the actual program with our arguments. 575256957a04Smrg func_exec_program \${1+\"\$@\"} 575365eef222Smrg fi 575465eef222Smrg else 575565eef222Smrg # The program doesn't exist. 5756b312a94cSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 575765eef222Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 575856957a04Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 575965eef222Smrg exit 1 576065eef222Smrg fi 576165eef222Smrgfi\ 576265eef222Smrg" 576365eef222Smrg} 5764ef981d24Smrg 5765ef981d24Smrg 576665eef222Smrg# func_emit_cwrapperexe_src 576765eef222Smrg# emit the source code for a wrapper executable on stdout 576865eef222Smrg# Must ONLY be called from within func_mode_link because 576965eef222Smrg# it depends on a number of variable set therein. 577065eef222Smrgfunc_emit_cwrapperexe_src () 577165eef222Smrg{ 577265eef222Smrg cat <<EOF 5773ef981d24Smrg 577465eef222Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5775b312a94cSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5776ef981d24Smrg 577765eef222Smrg The $output program cannot be directly executed until all the libtool 577865eef222Smrg libraries that it depends on are installed. 5779ef981d24Smrg 578065eef222Smrg This wrapper executable should never be moved out of the build directory. 578165eef222Smrg If it is, it will not operate correctly. 578265eef222Smrg*/ 578365eef222SmrgEOF 578465eef222Smrg cat <<"EOF" 578556957a04Smrg#ifdef _MSC_VER 578656957a04Smrg# define _CRT_SECURE_NO_DEPRECATE 1 578756957a04Smrg#endif 578865eef222Smrg#include <stdio.h> 578965eef222Smrg#include <stdlib.h> 579065eef222Smrg#ifdef _MSC_VER 579165eef222Smrg# include <direct.h> 579265eef222Smrg# include <process.h> 579365eef222Smrg# include <io.h> 579465eef222Smrg#else 579565eef222Smrg# include <unistd.h> 579665eef222Smrg# include <stdint.h> 579765eef222Smrg# ifdef __CYGWIN__ 579865eef222Smrg# include <io.h> 579965eef222Smrg# endif 580065eef222Smrg#endif 580165eef222Smrg#include <malloc.h> 580265eef222Smrg#include <stdarg.h> 580365eef222Smrg#include <assert.h> 580465eef222Smrg#include <string.h> 580565eef222Smrg#include <ctype.h> 580665eef222Smrg#include <errno.h> 580765eef222Smrg#include <fcntl.h> 580865eef222Smrg#include <sys/stat.h> 580965eef222Smrg 5810b312a94cSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5811b312a94cSmrg 581256957a04Smrg/* declarations of non-ANSI functions */ 5813b312a94cSmrg#if defined __MINGW32__ 581456957a04Smrg# ifdef __STRICT_ANSI__ 581556957a04Smrgint _putenv (const char *); 581656957a04Smrg# endif 5817b312a94cSmrg#elif defined __CYGWIN__ 581856957a04Smrg# ifdef __STRICT_ANSI__ 581956957a04Smrgchar *realpath (const char *, char *); 582056957a04Smrgint putenv (char *); 582156957a04Smrgint setenv (const char *, const char *, int); 582256957a04Smrg# endif 5823b312a94cSmrg/* #elif defined other_platform || defined ... */ 582456957a04Smrg#endif 582556957a04Smrg 582656957a04Smrg/* portability defines, excluding path handling macros */ 5827b312a94cSmrg#if defined _MSC_VER 582856957a04Smrg# define setmode _setmode 582956957a04Smrg# define stat _stat 583056957a04Smrg# define chmod _chmod 583156957a04Smrg# define getcwd _getcwd 583256957a04Smrg# define putenv _putenv 583356957a04Smrg# define S_IXUSR _S_IEXEC 5834b312a94cSmrg#elif defined __MINGW32__ 583556957a04Smrg# define setmode _setmode 583656957a04Smrg# define stat _stat 583756957a04Smrg# define chmod _chmod 583856957a04Smrg# define getcwd _getcwd 583956957a04Smrg# define putenv _putenv 5840b312a94cSmrg#elif defined __CYGWIN__ 584156957a04Smrg# define HAVE_SETENV 584256957a04Smrg# define FOPEN_WB "wb" 5843b312a94cSmrg/* #elif defined other platforms ... */ 584456957a04Smrg#endif 584556957a04Smrg 5846b312a94cSmrg#if defined PATH_MAX 584765eef222Smrg# define LT_PATHMAX PATH_MAX 5848b312a94cSmrg#elif defined MAXPATHLEN 584965eef222Smrg# define LT_PATHMAX MAXPATHLEN 585065eef222Smrg#else 585165eef222Smrg# define LT_PATHMAX 1024 585265eef222Smrg#endif 585365eef222Smrg 585465eef222Smrg#ifndef S_IXOTH 585565eef222Smrg# define S_IXOTH 0 585665eef222Smrg#endif 585765eef222Smrg#ifndef S_IXGRP 585865eef222Smrg# define S_IXGRP 0 585965eef222Smrg#endif 586065eef222Smrg 586156957a04Smrg/* path handling portability macros */ 586265eef222Smrg#ifndef DIR_SEPARATOR 586365eef222Smrg# define DIR_SEPARATOR '/' 586465eef222Smrg# define PATH_SEPARATOR ':' 586565eef222Smrg#endif 586665eef222Smrg 5867b312a94cSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5868b312a94cSmrg defined __OS2__ 586965eef222Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 587065eef222Smrg# define FOPEN_WB "wb" 587165eef222Smrg# ifndef DIR_SEPARATOR_2 587265eef222Smrg# define DIR_SEPARATOR_2 '\\' 587365eef222Smrg# endif 587465eef222Smrg# ifndef PATH_SEPARATOR_2 587565eef222Smrg# define PATH_SEPARATOR_2 ';' 587665eef222Smrg# endif 587765eef222Smrg#endif 587865eef222Smrg 587965eef222Smrg#ifndef DIR_SEPARATOR_2 588065eef222Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 588165eef222Smrg#else /* DIR_SEPARATOR_2 */ 588265eef222Smrg# define IS_DIR_SEPARATOR(ch) \ 588365eef222Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 588465eef222Smrg#endif /* DIR_SEPARATOR_2 */ 588565eef222Smrg 588665eef222Smrg#ifndef PATH_SEPARATOR_2 588765eef222Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 588865eef222Smrg#else /* PATH_SEPARATOR_2 */ 588965eef222Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 589065eef222Smrg#endif /* PATH_SEPARATOR_2 */ 589165eef222Smrg 589265eef222Smrg#ifndef FOPEN_WB 589365eef222Smrg# define FOPEN_WB "w" 589465eef222Smrg#endif 589565eef222Smrg#ifndef _O_BINARY 589665eef222Smrg# define _O_BINARY 0 589765eef222Smrg#endif 589865eef222Smrg 589965eef222Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 590065eef222Smrg#define XFREE(stale) do { \ 5901b312a94cSmrg if (stale) { free (stale); stale = 0; } \ 590265eef222Smrg} while (0) 590365eef222Smrg 5904b312a94cSmrg#if defined LT_DEBUGWRAPPER 590556957a04Smrgstatic int lt_debug = 1; 590665eef222Smrg#else 590756957a04Smrgstatic int lt_debug = 0; 590865eef222Smrg#endif 590965eef222Smrg 591056957a04Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 591165eef222Smrg 591265eef222Smrgvoid *xmalloc (size_t num); 591365eef222Smrgchar *xstrdup (const char *string); 591465eef222Smrgconst char *base_name (const char *name); 591565eef222Smrgchar *find_executable (const char *wrapper); 591665eef222Smrgchar *chase_symlinks (const char *pathspec); 591765eef222Smrgint make_executable (const char *path); 591865eef222Smrgint check_executable (const char *path); 591965eef222Smrgchar *strendzap (char *str, const char *pat); 592056957a04Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 592156957a04Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 592256957a04Smrgstatic const char *nonnull (const char *s); 592356957a04Smrgstatic const char *nonempty (const char *s); 592465eef222Smrgvoid lt_setenv (const char *name, const char *value); 592565eef222Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 592665eef222Smrgvoid lt_update_exe_path (const char *name, const char *value); 592765eef222Smrgvoid lt_update_lib_path (const char *name, const char *value); 592856957a04Smrgchar **prepare_spawn (char **argv); 592956957a04Smrgvoid lt_dump_script (FILE *f); 593065eef222SmrgEOF 593165eef222Smrg 593265eef222Smrg cat <<EOF 5933b312a94cSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5934b312a94cSmrg# define externally_visible volatile 5935b312a94cSmrg#else 5936b312a94cSmrg# define externally_visible __attribute__((externally_visible)) volatile 5937b312a94cSmrg#endif 5938b312a94cSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 593965eef222Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 594065eef222SmrgEOF 594165eef222Smrg 5942b312a94cSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5943200d7199Smrg func_to_host_path "$temp_rpath" 594465eef222Smrg cat <<EOF 5945200d7199Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5946ef981d24SmrgEOF 5947ef981d24Smrg else 594865eef222Smrg cat <<"EOF" 594965eef222Smrgconst char * LIB_PATH_VALUE = ""; 595065eef222SmrgEOF 5951ef981d24Smrg fi 595265eef222Smrg 595365eef222Smrg if test -n "$dllsearchpath"; then 5954200d7199Smrg func_to_host_path "$dllsearchpath:" 595565eef222Smrg cat <<EOF 595665eef222Smrgconst char * EXE_PATH_VARNAME = "PATH"; 5957200d7199Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 595865eef222SmrgEOF 5959ef981d24Smrg else 596065eef222Smrg cat <<"EOF" 596165eef222Smrgconst char * EXE_PATH_VARNAME = ""; 596265eef222Smrgconst char * EXE_PATH_VALUE = ""; 596365eef222SmrgEOF 5964ef981d24Smrg fi 596565eef222Smrg 5966b312a94cSmrg if test yes = "$fast_install"; then 596765eef222Smrg cat <<EOF 596865eef222Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 596965eef222SmrgEOF 5970ef981d24Smrg else 597165eef222Smrg cat <<EOF 597265eef222Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 597365eef222SmrgEOF 5974ef981d24Smrg fi 5975ef981d24Smrg 5976ef981d24Smrg 597765eef222Smrg cat <<"EOF" 5978ef981d24Smrg 597965eef222Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5980ef981d24Smrg 598165eef222Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 598265eef222Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 598356957a04Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5984ef981d24Smrg 598565eef222Smrgint 598665eef222Smrgmain (int argc, char *argv[]) 598765eef222Smrg{ 598865eef222Smrg char **newargz; 598965eef222Smrg int newargc; 599065eef222Smrg char *tmp_pathspec; 599165eef222Smrg char *actual_cwrapper_path; 599265eef222Smrg char *actual_cwrapper_name; 599365eef222Smrg char *target_name; 599465eef222Smrg char *lt_argv_zero; 5995b312a94cSmrg int rval = 127; 5996ef981d24Smrg 599765eef222Smrg int i; 5998ef981d24Smrg 599965eef222Smrg program_name = (char *) xstrdup (base_name (argv[0])); 6000b312a94cSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 6001ef981d24Smrg 600256957a04Smrg /* very simple arg parsing; don't want to rely on getopt 600356957a04Smrg * also, copy all non cwrapper options to newargz, except 600456957a04Smrg * argz[0], which is handled differently 600556957a04Smrg */ 600656957a04Smrg newargc=0; 600765eef222Smrg for (i = 1; i < argc; i++) 600865eef222Smrg { 6009b312a94cSmrg if (STREQ (argv[i], dumpscript_opt)) 601065eef222Smrg { 601165eef222SmrgEOF 6012b312a94cSmrg case $host in 601365eef222Smrg *mingw* | *cygwin* ) 601465eef222Smrg # make stdout use "unix" line endings 601565eef222Smrg echo " setmode(1,_O_BINARY);" 601665eef222Smrg ;; 601765eef222Smrg esac 6018ef981d24Smrg 601965eef222Smrg cat <<"EOF" 602056957a04Smrg lt_dump_script (stdout); 602165eef222Smrg return 0; 602265eef222Smrg } 6023b312a94cSmrg if (STREQ (argv[i], debug_opt)) 602456957a04Smrg { 602556957a04Smrg lt_debug = 1; 602656957a04Smrg continue; 602756957a04Smrg } 6028b312a94cSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 602956957a04Smrg { 603056957a04Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 603156957a04Smrg namespace, but it is not one of the ones we know about and 603256957a04Smrg have already dealt with, above (inluding dump-script), then 603356957a04Smrg report an error. Otherwise, targets might begin to believe 603456957a04Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 603556957a04Smrg namespace. The first time any user complains about this, we'll 603656957a04Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 603756957a04Smrg or a configure.ac-settable value. 603856957a04Smrg */ 603956957a04Smrg lt_fatal (__FILE__, __LINE__, 604056957a04Smrg "unrecognized %s option: '%s'", 604156957a04Smrg ltwrapper_option_prefix, argv[i]); 604256957a04Smrg } 604356957a04Smrg /* otherwise ... */ 604456957a04Smrg newargz[++newargc] = xstrdup (argv[i]); 604565eef222Smrg } 604656957a04Smrg newargz[++newargc] = NULL; 604756957a04Smrg 604856957a04SmrgEOF 604956957a04Smrg cat <<EOF 605056957a04Smrg /* The GNU banner must be the first non-error debug message */ 6051b312a94cSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 605256957a04SmrgEOF 605356957a04Smrg cat <<"EOF" 605456957a04Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 605556957a04Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 6056ef981d24Smrg 605765eef222Smrg tmp_pathspec = find_executable (argv[0]); 605865eef222Smrg if (tmp_pathspec == NULL) 605956957a04Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 606056957a04Smrg lt_debugprintf (__FILE__, __LINE__, 606156957a04Smrg "(main) found exe (before symlink chase) at: %s\n", 606256957a04Smrg tmp_pathspec); 606365eef222Smrg 606465eef222Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 606556957a04Smrg lt_debugprintf (__FILE__, __LINE__, 606656957a04Smrg "(main) found exe (after symlink chase) at: %s\n", 606756957a04Smrg actual_cwrapper_path); 606865eef222Smrg XFREE (tmp_pathspec); 606965eef222Smrg 607056957a04Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 607165eef222Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 607265eef222Smrg 607365eef222Smrg /* wrapper name transforms */ 607465eef222Smrg strendzap (actual_cwrapper_name, ".exe"); 607565eef222Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 607665eef222Smrg XFREE (actual_cwrapper_name); 607765eef222Smrg actual_cwrapper_name = tmp_pathspec; 607865eef222Smrg tmp_pathspec = 0; 607965eef222Smrg 608065eef222Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 608165eef222Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 608265eef222Smrg strendzap (target_name, ".exe"); 608365eef222Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 608465eef222Smrg XFREE (target_name); 608565eef222Smrg target_name = tmp_pathspec; 608665eef222Smrg tmp_pathspec = 0; 608765eef222Smrg 608856957a04Smrg lt_debugprintf (__FILE__, __LINE__, 608956957a04Smrg "(main) libtool target name: %s\n", 609056957a04Smrg target_name); 609165eef222SmrgEOF 6092ef981d24Smrg 609365eef222Smrg cat <<EOF 609465eef222Smrg newargz[0] = 609565eef222Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 609665eef222Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 609765eef222Smrg strcpy (newargz[0], actual_cwrapper_path); 609865eef222Smrg strcat (newargz[0], "$objdir"); 609965eef222Smrg strcat (newargz[0], "/"); 610065eef222SmrgEOF 6101ef981d24Smrg 610265eef222Smrg cat <<"EOF" 610365eef222Smrg /* stop here, and copy so we don't have to do this twice */ 610465eef222Smrg tmp_pathspec = xstrdup (newargz[0]); 6105ef981d24Smrg 610665eef222Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 610765eef222Smrg strcat (newargz[0], actual_cwrapper_name); 6108ef981d24Smrg 610965eef222Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 611065eef222Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 611165eef222Smrg XFREE (tmp_pathspec); 611265eef222Smrg tmp_pathspec = NULL; 611365eef222SmrgEOF 6114ef981d24Smrg 611565eef222Smrg case $host_os in 611665eef222Smrg mingw*) 611765eef222Smrg cat <<"EOF" 611865eef222Smrg { 611965eef222Smrg char* p; 612065eef222Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 612165eef222Smrg { 612265eef222Smrg *p = '/'; 612365eef222Smrg } 612465eef222Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 612565eef222Smrg { 612665eef222Smrg *p = '/'; 612765eef222Smrg } 612865eef222Smrg } 612965eef222SmrgEOF 613065eef222Smrg ;; 613165eef222Smrg esac 6132ef981d24Smrg 613365eef222Smrg cat <<"EOF" 613465eef222Smrg XFREE (target_name); 613565eef222Smrg XFREE (actual_cwrapper_path); 613665eef222Smrg XFREE (actual_cwrapper_name); 6137ef981d24Smrg 613865eef222Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 613965eef222Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 6140200d7199Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 6141200d7199Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 6142200d7199Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 6143200d7199Smrg libraries must come first. */ 614465eef222Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 6145200d7199Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 6146ef981d24Smrg 614756957a04Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 614856957a04Smrg nonnull (lt_argv_zero)); 614965eef222Smrg for (i = 0; i < newargc; i++) 615065eef222Smrg { 615156957a04Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 615256957a04Smrg i, nonnull (newargz[i])); 615365eef222Smrg } 6154ef981d24Smrg 615565eef222SmrgEOF 6156ef981d24Smrg 615765eef222Smrg case $host_os in 615865eef222Smrg mingw*) 615965eef222Smrg cat <<"EOF" 616065eef222Smrg /* execv doesn't actually work on mingw as expected on unix */ 616156957a04Smrg newargz = prepare_spawn (newargz); 6162b312a94cSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 616365eef222Smrg if (rval == -1) 616465eef222Smrg { 616565eef222Smrg /* failed to start process */ 616656957a04Smrg lt_debugprintf (__FILE__, __LINE__, 616756957a04Smrg "(main) failed to launch target \"%s\": %s\n", 616856957a04Smrg lt_argv_zero, nonnull (strerror (errno))); 616965eef222Smrg return 127; 617065eef222Smrg } 617165eef222Smrg return rval; 617265eef222SmrgEOF 617365eef222Smrg ;; 617465eef222Smrg *) 617565eef222Smrg cat <<"EOF" 617665eef222Smrg execv (lt_argv_zero, newargz); 617765eef222Smrg return rval; /* =127, but avoids unused variable warning */ 617865eef222SmrgEOF 617965eef222Smrg ;; 618065eef222Smrg esac 6181ef981d24Smrg 618265eef222Smrg cat <<"EOF" 618365eef222Smrg} 6184ef981d24Smrg 618565eef222Smrgvoid * 618665eef222Smrgxmalloc (size_t num) 618765eef222Smrg{ 618865eef222Smrg void *p = (void *) malloc (num); 618965eef222Smrg if (!p) 619056957a04Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 6191ef981d24Smrg 619265eef222Smrg return p; 619365eef222Smrg} 6194ef981d24Smrg 619565eef222Smrgchar * 619665eef222Smrgxstrdup (const char *string) 619765eef222Smrg{ 619865eef222Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 619965eef222Smrg string) : NULL; 620065eef222Smrg} 6201ef981d24Smrg 620265eef222Smrgconst char * 620365eef222Smrgbase_name (const char *name) 620465eef222Smrg{ 620565eef222Smrg const char *base; 6206ef981d24Smrg 6207b312a94cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 620865eef222Smrg /* Skip over the disk name in MSDOS pathnames. */ 620965eef222Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 621065eef222Smrg name += 2; 621165eef222Smrg#endif 6212ef981d24Smrg 621365eef222Smrg for (base = name; *name; name++) 621465eef222Smrg if (IS_DIR_SEPARATOR (*name)) 621565eef222Smrg base = name + 1; 621665eef222Smrg return base; 621765eef222Smrg} 6218ef981d24Smrg 621965eef222Smrgint 622065eef222Smrgcheck_executable (const char *path) 622165eef222Smrg{ 622265eef222Smrg struct stat st; 6223ef981d24Smrg 622456957a04Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 622556957a04Smrg nonempty (path)); 622665eef222Smrg if ((!path) || (!*path)) 622765eef222Smrg return 0; 6228ef981d24Smrg 622965eef222Smrg if ((stat (path, &st) >= 0) 623065eef222Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 623165eef222Smrg return 1; 623265eef222Smrg else 623365eef222Smrg return 0; 623465eef222Smrg} 6235ef981d24Smrg 623665eef222Smrgint 623765eef222Smrgmake_executable (const char *path) 623865eef222Smrg{ 623965eef222Smrg int rval = 0; 624065eef222Smrg struct stat st; 6241ef981d24Smrg 624256957a04Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 624356957a04Smrg nonempty (path)); 624465eef222Smrg if ((!path) || (!*path)) 624565eef222Smrg return 0; 6246ef981d24Smrg 624765eef222Smrg if (stat (path, &st) >= 0) 624865eef222Smrg { 624965eef222Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 625065eef222Smrg } 625165eef222Smrg return rval; 625265eef222Smrg} 6253ef981d24Smrg 625465eef222Smrg/* Searches for the full path of the wrapper. Returns 625565eef222Smrg newly allocated full path name if found, NULL otherwise 625665eef222Smrg Does not chase symlinks, even on platforms that support them. 625765eef222Smrg*/ 625865eef222Smrgchar * 625965eef222Smrgfind_executable (const char *wrapper) 626065eef222Smrg{ 626165eef222Smrg int has_slash = 0; 626265eef222Smrg const char *p; 626365eef222Smrg const char *p_next; 626465eef222Smrg /* static buffer for getcwd */ 626565eef222Smrg char tmp[LT_PATHMAX + 1]; 6266b312a94cSmrg size_t tmp_len; 626765eef222Smrg char *concat_name; 6268ef981d24Smrg 626956957a04Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 627056957a04Smrg nonempty (wrapper)); 6271ef981d24Smrg 627265eef222Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 627365eef222Smrg return NULL; 6274ef981d24Smrg 627565eef222Smrg /* Absolute path? */ 6276b312a94cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 627765eef222Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 627865eef222Smrg { 627965eef222Smrg concat_name = xstrdup (wrapper); 628065eef222Smrg if (check_executable (concat_name)) 628165eef222Smrg return concat_name; 628265eef222Smrg XFREE (concat_name); 628365eef222Smrg } 628465eef222Smrg else 628565eef222Smrg { 628665eef222Smrg#endif 628765eef222Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 628865eef222Smrg { 628965eef222Smrg concat_name = xstrdup (wrapper); 629065eef222Smrg if (check_executable (concat_name)) 629165eef222Smrg return concat_name; 629265eef222Smrg XFREE (concat_name); 629365eef222Smrg } 6294b312a94cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 629565eef222Smrg } 629665eef222Smrg#endif 6297ef981d24Smrg 629865eef222Smrg for (p = wrapper; *p; p++) 629965eef222Smrg if (*p == '/') 630065eef222Smrg { 630165eef222Smrg has_slash = 1; 630265eef222Smrg break; 630365eef222Smrg } 630465eef222Smrg if (!has_slash) 630565eef222Smrg { 630665eef222Smrg /* no slashes; search PATH */ 630765eef222Smrg const char *path = getenv ("PATH"); 630865eef222Smrg if (path != NULL) 630965eef222Smrg { 631065eef222Smrg for (p = path; *p; p = p_next) 631165eef222Smrg { 631265eef222Smrg const char *q; 631365eef222Smrg size_t p_len; 631465eef222Smrg for (q = p; *q; q++) 631565eef222Smrg if (IS_PATH_SEPARATOR (*q)) 631665eef222Smrg break; 6317b312a94cSmrg p_len = (size_t) (q - p); 631865eef222Smrg p_next = (*q == '\0' ? q : q + 1); 631965eef222Smrg if (p_len == 0) 632065eef222Smrg { 632165eef222Smrg /* empty path: current directory */ 632265eef222Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 632356957a04Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 632456957a04Smrg nonnull (strerror (errno))); 632565eef222Smrg tmp_len = strlen (tmp); 632665eef222Smrg concat_name = 632765eef222Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 632865eef222Smrg memcpy (concat_name, tmp, tmp_len); 632965eef222Smrg concat_name[tmp_len] = '/'; 633065eef222Smrg strcpy (concat_name + tmp_len + 1, wrapper); 633165eef222Smrg } 633265eef222Smrg else 633365eef222Smrg { 633465eef222Smrg concat_name = 633565eef222Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 633665eef222Smrg memcpy (concat_name, p, p_len); 633765eef222Smrg concat_name[p_len] = '/'; 633865eef222Smrg strcpy (concat_name + p_len + 1, wrapper); 633965eef222Smrg } 634065eef222Smrg if (check_executable (concat_name)) 634165eef222Smrg return concat_name; 634265eef222Smrg XFREE (concat_name); 634365eef222Smrg } 634465eef222Smrg } 634565eef222Smrg /* not found in PATH; assume curdir */ 634665eef222Smrg } 634765eef222Smrg /* Relative path | not found in path: prepend cwd */ 634865eef222Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 634956957a04Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 635056957a04Smrg nonnull (strerror (errno))); 635165eef222Smrg tmp_len = strlen (tmp); 635265eef222Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 635365eef222Smrg memcpy (concat_name, tmp, tmp_len); 635465eef222Smrg concat_name[tmp_len] = '/'; 635565eef222Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6356ef981d24Smrg 635765eef222Smrg if (check_executable (concat_name)) 635865eef222Smrg return concat_name; 635965eef222Smrg XFREE (concat_name); 636065eef222Smrg return NULL; 636165eef222Smrg} 6362ef981d24Smrg 636365eef222Smrgchar * 636465eef222Smrgchase_symlinks (const char *pathspec) 636565eef222Smrg{ 636665eef222Smrg#ifndef S_ISLNK 636765eef222Smrg return xstrdup (pathspec); 636865eef222Smrg#else 636965eef222Smrg char buf[LT_PATHMAX]; 637065eef222Smrg struct stat s; 637165eef222Smrg char *tmp_pathspec = xstrdup (pathspec); 637265eef222Smrg char *p; 637365eef222Smrg int has_symlinks = 0; 637465eef222Smrg while (strlen (tmp_pathspec) && !has_symlinks) 637565eef222Smrg { 637656957a04Smrg lt_debugprintf (__FILE__, __LINE__, 637756957a04Smrg "checking path component for symlinks: %s\n", 637856957a04Smrg tmp_pathspec); 637965eef222Smrg if (lstat (tmp_pathspec, &s) == 0) 638065eef222Smrg { 638165eef222Smrg if (S_ISLNK (s.st_mode) != 0) 638265eef222Smrg { 638365eef222Smrg has_symlinks = 1; 638465eef222Smrg break; 638565eef222Smrg } 6386ef981d24Smrg 638765eef222Smrg /* search backwards for last DIR_SEPARATOR */ 638865eef222Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 638965eef222Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 639065eef222Smrg p--; 639165eef222Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 639265eef222Smrg { 639365eef222Smrg /* no more DIR_SEPARATORS left */ 639465eef222Smrg break; 639565eef222Smrg } 639665eef222Smrg *p = '\0'; 639765eef222Smrg } 639865eef222Smrg else 639965eef222Smrg { 640056957a04Smrg lt_fatal (__FILE__, __LINE__, 640156957a04Smrg "error accessing file \"%s\": %s", 640256957a04Smrg tmp_pathspec, nonnull (strerror (errno))); 640365eef222Smrg } 640465eef222Smrg } 640565eef222Smrg XFREE (tmp_pathspec); 6406ef981d24Smrg 640765eef222Smrg if (!has_symlinks) 640865eef222Smrg { 640965eef222Smrg return xstrdup (pathspec); 641065eef222Smrg } 6411ef981d24Smrg 641265eef222Smrg tmp_pathspec = realpath (pathspec, buf); 641365eef222Smrg if (tmp_pathspec == 0) 641465eef222Smrg { 641556957a04Smrg lt_fatal (__FILE__, __LINE__, 641656957a04Smrg "could not follow symlinks for %s", pathspec); 641765eef222Smrg } 641865eef222Smrg return xstrdup (tmp_pathspec); 641965eef222Smrg#endif 642065eef222Smrg} 6421ef981d24Smrg 642265eef222Smrgchar * 642365eef222Smrgstrendzap (char *str, const char *pat) 642465eef222Smrg{ 642565eef222Smrg size_t len, patlen; 6426ef981d24Smrg 642765eef222Smrg assert (str != NULL); 642865eef222Smrg assert (pat != NULL); 6429ef981d24Smrg 643065eef222Smrg len = strlen (str); 643165eef222Smrg patlen = strlen (pat); 6432ef981d24Smrg 643365eef222Smrg if (patlen <= len) 643465eef222Smrg { 643565eef222Smrg str += len - patlen; 6436b312a94cSmrg if (STREQ (str, pat)) 643765eef222Smrg *str = '\0'; 643865eef222Smrg } 643965eef222Smrg return str; 644065eef222Smrg} 6441ef981d24Smrg 644256957a04Smrgvoid 644356957a04Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 644456957a04Smrg{ 644556957a04Smrg va_list args; 644656957a04Smrg if (lt_debug) 644756957a04Smrg { 644856957a04Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 644956957a04Smrg va_start (args, fmt); 645056957a04Smrg (void) vfprintf (stderr, fmt, args); 645156957a04Smrg va_end (args); 645256957a04Smrg } 645356957a04Smrg} 645456957a04Smrg 645565eef222Smrgstatic void 645656957a04Smrglt_error_core (int exit_status, const char *file, 645756957a04Smrg int line, const char *mode, 645865eef222Smrg const char *message, va_list ap) 645965eef222Smrg{ 646056957a04Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 646165eef222Smrg vfprintf (stderr, message, ap); 646265eef222Smrg fprintf (stderr, ".\n"); 6463ef981d24Smrg 646465eef222Smrg if (exit_status >= 0) 646565eef222Smrg exit (exit_status); 646665eef222Smrg} 6467ef981d24Smrg 646865eef222Smrgvoid 646956957a04Smrglt_fatal (const char *file, int line, const char *message, ...) 647065eef222Smrg{ 647165eef222Smrg va_list ap; 647265eef222Smrg va_start (ap, message); 647356957a04Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 647465eef222Smrg va_end (ap); 647565eef222Smrg} 6476ef981d24Smrg 647756957a04Smrgstatic const char * 647856957a04Smrgnonnull (const char *s) 647956957a04Smrg{ 648056957a04Smrg return s ? s : "(null)"; 648156957a04Smrg} 648256957a04Smrg 648356957a04Smrgstatic const char * 648456957a04Smrgnonempty (const char *s) 648556957a04Smrg{ 648656957a04Smrg return (s && !*s) ? "(empty)" : nonnull (s); 648756957a04Smrg} 648856957a04Smrg 648965eef222Smrgvoid 649065eef222Smrglt_setenv (const char *name, const char *value) 649165eef222Smrg{ 649256957a04Smrg lt_debugprintf (__FILE__, __LINE__, 649356957a04Smrg "(lt_setenv) setting '%s' to '%s'\n", 649456957a04Smrg nonnull (name), nonnull (value)); 649565eef222Smrg { 649665eef222Smrg#ifdef HAVE_SETENV 649765eef222Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 649865eef222Smrg char *str = xstrdup (value); 649965eef222Smrg setenv (name, str, 1); 650065eef222Smrg#else 6501b312a94cSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 650265eef222Smrg char *str = XMALLOC (char, len); 650365eef222Smrg sprintf (str, "%s=%s", name, value); 650465eef222Smrg if (putenv (str) != EXIT_SUCCESS) 650565eef222Smrg { 650665eef222Smrg XFREE (str); 650765eef222Smrg } 650865eef222Smrg#endif 650965eef222Smrg } 651065eef222Smrg} 6511ef981d24Smrg 651265eef222Smrgchar * 651365eef222Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 651465eef222Smrg{ 651565eef222Smrg char *new_value; 651665eef222Smrg if (orig_value && *orig_value) 651765eef222Smrg { 6518b312a94cSmrg size_t orig_value_len = strlen (orig_value); 6519b312a94cSmrg size_t add_len = strlen (add); 652065eef222Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 652165eef222Smrg if (to_end) 652265eef222Smrg { 652365eef222Smrg strcpy (new_value, orig_value); 652465eef222Smrg strcpy (new_value + orig_value_len, add); 652565eef222Smrg } 652665eef222Smrg else 652765eef222Smrg { 652865eef222Smrg strcpy (new_value, add); 652965eef222Smrg strcpy (new_value + add_len, orig_value); 653065eef222Smrg } 653165eef222Smrg } 653265eef222Smrg else 653365eef222Smrg { 653465eef222Smrg new_value = xstrdup (add); 653565eef222Smrg } 653665eef222Smrg return new_value; 653765eef222Smrg} 6538ef981d24Smrg 653965eef222Smrgvoid 654065eef222Smrglt_update_exe_path (const char *name, const char *value) 654165eef222Smrg{ 654256957a04Smrg lt_debugprintf (__FILE__, __LINE__, 654356957a04Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 654456957a04Smrg nonnull (name), nonnull (value)); 6545ef981d24Smrg 654665eef222Smrg if (name && *name && value && *value) 654765eef222Smrg { 654865eef222Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 654965eef222Smrg /* some systems can't cope with a ':'-terminated path #' */ 6550b312a94cSmrg size_t len = strlen (new_value); 6551b312a94cSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 655265eef222Smrg { 6553b312a94cSmrg new_value[--len] = '\0'; 655465eef222Smrg } 655565eef222Smrg lt_setenv (name, new_value); 655665eef222Smrg XFREE (new_value); 655765eef222Smrg } 655865eef222Smrg} 6559ef981d24Smrg 656065eef222Smrgvoid 656165eef222Smrglt_update_lib_path (const char *name, const char *value) 656265eef222Smrg{ 656356957a04Smrg lt_debugprintf (__FILE__, __LINE__, 656456957a04Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 656556957a04Smrg nonnull (name), nonnull (value)); 6566ef981d24Smrg 656765eef222Smrg if (name && *name && value && *value) 656865eef222Smrg { 656965eef222Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 657065eef222Smrg lt_setenv (name, new_value); 657165eef222Smrg XFREE (new_value); 657265eef222Smrg } 657365eef222Smrg} 6574ef981d24Smrg 657556957a04SmrgEOF 657656957a04Smrg case $host_os in 657756957a04Smrg mingw*) 657856957a04Smrg cat <<"EOF" 657956957a04Smrg 658056957a04Smrg/* Prepares an argument vector before calling spawn(). 658156957a04Smrg Note that spawn() does not by itself call the command interpreter 658256957a04Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 658356957a04Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 658456957a04Smrg GetVersionEx(&v); 658556957a04Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 658656957a04Smrg }) ? "cmd.exe" : "command.com"). 658756957a04Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 658856957a04Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 658956957a04Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 659056957a04Smrg special way: 659156957a04Smrg - Space and tab are interpreted as delimiters. They are not treated as 659256957a04Smrg delimiters if they are surrounded by double quotes: "...". 659356957a04Smrg - Unescaped double quotes are removed from the input. Their only effect is 659456957a04Smrg that within double quotes, space and tab are treated like normal 659556957a04Smrg characters. 659656957a04Smrg - Backslashes not followed by double quotes are not special. 659756957a04Smrg - But 2*n+1 backslashes followed by a double quote become 659856957a04Smrg n backslashes followed by a double quote (n >= 0): 659956957a04Smrg \" -> " 660056957a04Smrg \\\" -> \" 660156957a04Smrg \\\\\" -> \\" 660256957a04Smrg */ 660356957a04Smrg#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" 660456957a04Smrg#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" 660556957a04Smrgchar ** 660656957a04Smrgprepare_spawn (char **argv) 660756957a04Smrg{ 660856957a04Smrg size_t argc; 660956957a04Smrg char **new_argv; 661056957a04Smrg size_t i; 661156957a04Smrg 661256957a04Smrg /* Count number of arguments. */ 661356957a04Smrg for (argc = 0; argv[argc] != NULL; argc++) 661456957a04Smrg ; 661556957a04Smrg 661656957a04Smrg /* Allocate new argument vector. */ 661756957a04Smrg new_argv = XMALLOC (char *, argc + 1); 661856957a04Smrg 661956957a04Smrg /* Put quoted arguments into the new argument vector. */ 662056957a04Smrg for (i = 0; i < argc; i++) 662156957a04Smrg { 662256957a04Smrg const char *string = argv[i]; 662356957a04Smrg 662456957a04Smrg if (string[0] == '\0') 662556957a04Smrg new_argv[i] = xstrdup ("\"\""); 662656957a04Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 662756957a04Smrg { 662856957a04Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 662956957a04Smrg size_t length; 663056957a04Smrg unsigned int backslashes; 663156957a04Smrg const char *s; 663256957a04Smrg char *quoted_string; 663356957a04Smrg char *p; 663456957a04Smrg 663556957a04Smrg length = 0; 663656957a04Smrg backslashes = 0; 663756957a04Smrg if (quote_around) 663856957a04Smrg length++; 663956957a04Smrg for (s = string; *s != '\0'; s++) 664056957a04Smrg { 664156957a04Smrg char c = *s; 664256957a04Smrg if (c == '"') 664356957a04Smrg length += backslashes + 1; 664456957a04Smrg length++; 664556957a04Smrg if (c == '\\') 664656957a04Smrg backslashes++; 664756957a04Smrg else 664856957a04Smrg backslashes = 0; 664956957a04Smrg } 665056957a04Smrg if (quote_around) 665156957a04Smrg length += backslashes + 1; 665256957a04Smrg 665356957a04Smrg quoted_string = XMALLOC (char, length + 1); 665456957a04Smrg 665556957a04Smrg p = quoted_string; 665656957a04Smrg backslashes = 0; 665756957a04Smrg if (quote_around) 665856957a04Smrg *p++ = '"'; 665956957a04Smrg for (s = string; *s != '\0'; s++) 666056957a04Smrg { 666156957a04Smrg char c = *s; 666256957a04Smrg if (c == '"') 666356957a04Smrg { 666456957a04Smrg unsigned int j; 666556957a04Smrg for (j = backslashes + 1; j > 0; j--) 666656957a04Smrg *p++ = '\\'; 666756957a04Smrg } 666856957a04Smrg *p++ = c; 666956957a04Smrg if (c == '\\') 667056957a04Smrg backslashes++; 667156957a04Smrg else 667256957a04Smrg backslashes = 0; 667356957a04Smrg } 667456957a04Smrg if (quote_around) 667556957a04Smrg { 667656957a04Smrg unsigned int j; 667756957a04Smrg for (j = backslashes; j > 0; j--) 667856957a04Smrg *p++ = '\\'; 667956957a04Smrg *p++ = '"'; 668056957a04Smrg } 668156957a04Smrg *p = '\0'; 668256957a04Smrg 668356957a04Smrg new_argv[i] = quoted_string; 668456957a04Smrg } 668556957a04Smrg else 668656957a04Smrg new_argv[i] = (char *) string; 668756957a04Smrg } 668856957a04Smrg new_argv[argc] = NULL; 668956957a04Smrg 669056957a04Smrg return new_argv; 669156957a04Smrg} 669256957a04SmrgEOF 669356957a04Smrg ;; 669456957a04Smrg esac 669556957a04Smrg 669656957a04Smrg cat <<"EOF" 669756957a04Smrgvoid lt_dump_script (FILE* f) 669856957a04Smrg{ 669956957a04SmrgEOF 670056957a04Smrg func_emit_wrapper yes | 6701b312a94cSmrg $SED -n -e ' 6702b312a94cSmrgs/^\(.\{79\}\)\(..*\)/\1\ 6703b312a94cSmrg\2/ 6704b312a94cSmrgh 6705b312a94cSmrgs/\([\\"]\)/\\\1/g 6706b312a94cSmrgs/$/\\n/ 6707b312a94cSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6708b312a94cSmrgg 6709b312a94cSmrgD' 671056957a04Smrg cat <<"EOF" 671156957a04Smrg} 671265eef222SmrgEOF 671365eef222Smrg} 671465eef222Smrg# end: func_emit_cwrapperexe_src 6715ef981d24Smrg 671656957a04Smrg# func_win32_import_lib_p ARG 671756957a04Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 671856957a04Smrgfunc_win32_import_lib_p () 671956957a04Smrg{ 6720b312a94cSmrg $debug_cmd 6721b312a94cSmrg 672256957a04Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 672356957a04Smrg *import*) : ;; 672456957a04Smrg *) false ;; 672556957a04Smrg esac 672656957a04Smrg} 672756957a04Smrg 6728b312a94cSmrg# func_suncc_cstd_abi 6729b312a94cSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6730b312a94cSmrg# Several compiler flags select an ABI that is incompatible with the 6731b312a94cSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6732b312a94cSmrgfunc_suncc_cstd_abi () 6733b312a94cSmrg{ 6734b312a94cSmrg $debug_cmd 6735b312a94cSmrg 6736b312a94cSmrg case " $compile_command " in 6737b312a94cSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6738b312a94cSmrg suncc_use_cstd_abi=no 6739b312a94cSmrg ;; 6740b312a94cSmrg *) 6741b312a94cSmrg suncc_use_cstd_abi=yes 6742b312a94cSmrg ;; 6743b312a94cSmrg esac 6744b312a94cSmrg} 6745b312a94cSmrg 674665eef222Smrg# func_mode_link arg... 674765eef222Smrgfunc_mode_link () 674865eef222Smrg{ 6749b312a94cSmrg $debug_cmd 6750b312a94cSmrg 675165eef222Smrg case $host in 675265eef222Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 675365eef222Smrg # It is impossible to link a dll without this setting, and 675465eef222Smrg # we shouldn't force the makefile maintainer to figure out 6755b312a94cSmrg # what system we are compiling for in order to pass an extra 675665eef222Smrg # flag for every libtool invocation. 675765eef222Smrg # allow_undefined=no 6758ef981d24Smrg 675965eef222Smrg # FIXME: Unfortunately, there are problems with the above when trying 6760b312a94cSmrg # to make a dll that has undefined symbols, in which case not 676165eef222Smrg # even a static library is built. For now, we need to specify 676265eef222Smrg # -no-undefined on the libtool link line when we can be certain 676365eef222Smrg # that all symbols are satisfied, otherwise we get a static library. 676465eef222Smrg allow_undefined=yes 676565eef222Smrg ;; 676665eef222Smrg *) 676765eef222Smrg allow_undefined=yes 676865eef222Smrg ;; 676965eef222Smrg esac 677065eef222Smrg libtool_args=$nonopt 677165eef222Smrg base_compile="$nonopt $@" 677265eef222Smrg compile_command=$nonopt 677365eef222Smrg finalize_command=$nonopt 6774ef981d24Smrg 677565eef222Smrg compile_rpath= 677665eef222Smrg finalize_rpath= 677765eef222Smrg compile_shlibpath= 677865eef222Smrg finalize_shlibpath= 677965eef222Smrg convenience= 678065eef222Smrg old_convenience= 678165eef222Smrg deplibs= 678265eef222Smrg old_deplibs= 678365eef222Smrg compiler_flags= 678465eef222Smrg linker_flags= 678565eef222Smrg dllsearchpath= 678665eef222Smrg lib_search_path=`pwd` 678765eef222Smrg inst_prefix_dir= 678865eef222Smrg new_inherited_linker_flags= 6789ef981d24Smrg 679065eef222Smrg avoid_version=no 679156957a04Smrg bindir= 679265eef222Smrg dlfiles= 679365eef222Smrg dlprefiles= 679465eef222Smrg dlself=no 679565eef222Smrg export_dynamic=no 679665eef222Smrg export_symbols= 679765eef222Smrg export_symbols_regex= 679865eef222Smrg generated= 679965eef222Smrg libobjs= 680065eef222Smrg ltlibs= 680165eef222Smrg module=no 680265eef222Smrg no_install=no 680365eef222Smrg objs= 6804b312a94cSmrg os2dllname= 680565eef222Smrg non_pic_objects= 680665eef222Smrg precious_files_regex= 680765eef222Smrg prefer_static_libs=no 6808b312a94cSmrg preload=false 680965eef222Smrg prev= 681065eef222Smrg prevarg= 681165eef222Smrg release= 681265eef222Smrg rpath= 681365eef222Smrg xrpath= 681465eef222Smrg perm_rpath= 681565eef222Smrg temp_rpath= 681665eef222Smrg thread_safe=no 681765eef222Smrg vinfo= 681865eef222Smrg vinfo_number=no 681965eef222Smrg weak_libs= 6820b312a94cSmrg single_module=$wl-single_module 682165eef222Smrg func_infer_tag $base_compile 6822ef981d24Smrg 682365eef222Smrg # We need to know -static, to get the right output filenames. 682465eef222Smrg for arg 682565eef222Smrg do 682665eef222Smrg case $arg in 682765eef222Smrg -shared) 6828b312a94cSmrg test yes != "$build_libtool_libs" \ 6829b312a94cSmrg && func_fatal_configuration "cannot build a shared library" 683065eef222Smrg build_old_libs=no 683165eef222Smrg break 683265eef222Smrg ;; 683365eef222Smrg -all-static | -static | -static-libtool-libs) 683465eef222Smrg case $arg in 683565eef222Smrg -all-static) 6836b312a94cSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 683765eef222Smrg func_warning "complete static linking is impossible in this configuration" 6838ef981d24Smrg fi 683965eef222Smrg if test -n "$link_static_flag"; then 684065eef222Smrg dlopen_self=$dlopen_self_static 6841ef981d24Smrg fi 684265eef222Smrg prefer_static_libs=yes 6843ef981d24Smrg ;; 684465eef222Smrg -static) 684565eef222Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 684665eef222Smrg dlopen_self=$dlopen_self_static 684765eef222Smrg fi 684865eef222Smrg prefer_static_libs=built 684965eef222Smrg ;; 685065eef222Smrg -static-libtool-libs) 685165eef222Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 685265eef222Smrg dlopen_self=$dlopen_self_static 685365eef222Smrg fi 685465eef222Smrg prefer_static_libs=yes 6855ef981d24Smrg ;; 6856ef981d24Smrg esac 685765eef222Smrg build_libtool_libs=no 685865eef222Smrg build_old_libs=yes 685965eef222Smrg break 686065eef222Smrg ;; 686165eef222Smrg esac 686265eef222Smrg done 6863ef981d24Smrg 686465eef222Smrg # See if our shared archives depend on static archives. 686565eef222Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6866ef981d24Smrg 686765eef222Smrg # Go through the arguments, transforming them on the way. 686865eef222Smrg while test "$#" -gt 0; do 6869b312a94cSmrg arg=$1 687065eef222Smrg shift 6871d5637ae9Smrg func_quote_arg pretty,unquoted "$arg" 6872d5637ae9Smrg qarg=$func_quote_arg_unquoted_result 6873d5637ae9Smrg func_append libtool_args " $func_quote_arg_result" 6874ef981d24Smrg 687565eef222Smrg # If the previous option needs an argument, assign it. 687665eef222Smrg if test -n "$prev"; then 687765eef222Smrg case $prev in 687865eef222Smrg output) 687965eef222Smrg func_append compile_command " @OUTPUT@" 688065eef222Smrg func_append finalize_command " @OUTPUT@" 688165eef222Smrg ;; 688265eef222Smrg esac 6883ef981d24Smrg 688465eef222Smrg case $prev in 688556957a04Smrg bindir) 6886b312a94cSmrg bindir=$arg 688756957a04Smrg prev= 688856957a04Smrg continue 688956957a04Smrg ;; 689065eef222Smrg dlfiles|dlprefiles) 6891b312a94cSmrg $preload || { 689265eef222Smrg # Add the symbol object into the linking commands. 689365eef222Smrg func_append compile_command " @SYMFILE@" 689465eef222Smrg func_append finalize_command " @SYMFILE@" 6895b312a94cSmrg preload=: 6896b312a94cSmrg } 689765eef222Smrg case $arg in 689865eef222Smrg *.la | *.lo) ;; # We handle these cases below. 689965eef222Smrg force) 6900b312a94cSmrg if test no = "$dlself"; then 690165eef222Smrg dlself=needless 690265eef222Smrg export_dynamic=yes 690365eef222Smrg fi 690465eef222Smrg prev= 690565eef222Smrg continue 690665eef222Smrg ;; 690765eef222Smrg self) 6908b312a94cSmrg if test dlprefiles = "$prev"; then 690965eef222Smrg dlself=yes 6910b312a94cSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 691165eef222Smrg dlself=yes 691265eef222Smrg else 691365eef222Smrg dlself=needless 691465eef222Smrg export_dynamic=yes 691565eef222Smrg fi 691665eef222Smrg prev= 691765eef222Smrg continue 6918ef981d24Smrg ;; 6919ef981d24Smrg *) 6920b312a94cSmrg if test dlfiles = "$prev"; then 6921200d7199Smrg func_append dlfiles " $arg" 692265eef222Smrg else 6923200d7199Smrg func_append dlprefiles " $arg" 692465eef222Smrg fi 692565eef222Smrg prev= 692665eef222Smrg continue 6927ef981d24Smrg ;; 6928ef981d24Smrg esac 692965eef222Smrg ;; 693065eef222Smrg expsyms) 6931b312a94cSmrg export_symbols=$arg 693265eef222Smrg test -f "$arg" \ 6933b312a94cSmrg || func_fatal_error "symbol file '$arg' does not exist" 693465eef222Smrg prev= 693565eef222Smrg continue 693665eef222Smrg ;; 693765eef222Smrg expsyms_regex) 6938b312a94cSmrg export_symbols_regex=$arg 693965eef222Smrg prev= 694065eef222Smrg continue 694165eef222Smrg ;; 694265eef222Smrg framework) 694365eef222Smrg case $host in 694465eef222Smrg *-*-darwin*) 694565eef222Smrg case "$deplibs " in 694665eef222Smrg *" $qarg.ltframework "*) ;; 6947200d7199Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 694865eef222Smrg ;; 694965eef222Smrg esac 695065eef222Smrg ;; 695165eef222Smrg esac 695265eef222Smrg prev= 695365eef222Smrg continue 695465eef222Smrg ;; 695565eef222Smrg inst_prefix) 6956b312a94cSmrg inst_prefix_dir=$arg 6957b312a94cSmrg prev= 6958b312a94cSmrg continue 6959b312a94cSmrg ;; 6960b312a94cSmrg mllvm) 6961b312a94cSmrg # Clang does not use LLVM to link, so we can simply discard any 6962b312a94cSmrg # '-mllvm $arg' options when doing the link step. 696365eef222Smrg prev= 696465eef222Smrg continue 696565eef222Smrg ;; 696665eef222Smrg objectlist) 696765eef222Smrg if test -f "$arg"; then 696865eef222Smrg save_arg=$arg 696965eef222Smrg moreargs= 697065eef222Smrg for fil in `cat "$save_arg"` 697165eef222Smrg do 6972200d7199Smrg# func_append moreargs " $fil" 697365eef222Smrg arg=$fil 697465eef222Smrg # A libtool-controlled object. 6975ef981d24Smrg 697665eef222Smrg # Check to see that this really is a libtool object. 697765eef222Smrg if func_lalib_unsafe_p "$arg"; then 697865eef222Smrg pic_object= 697965eef222Smrg non_pic_object= 6980ef981d24Smrg 698165eef222Smrg # Read the .lo file 698265eef222Smrg func_source "$arg" 6983ef981d24Smrg 698465eef222Smrg if test -z "$pic_object" || 698565eef222Smrg test -z "$non_pic_object" || 6986b312a94cSmrg test none = "$pic_object" && 6987b312a94cSmrg test none = "$non_pic_object"; then 6988b312a94cSmrg func_fatal_error "cannot find name of object for '$arg'" 698965eef222Smrg fi 6990ef981d24Smrg 699165eef222Smrg # Extract subdirectory from the argument. 699265eef222Smrg func_dirname "$arg" "/" "" 6993b312a94cSmrg xdir=$func_dirname_result 6994ef981d24Smrg 6995b312a94cSmrg if test none != "$pic_object"; then 699665eef222Smrg # Prepend the subdirectory the object is found in. 6997b312a94cSmrg pic_object=$xdir$pic_object 6998ef981d24Smrg 6999b312a94cSmrg if test dlfiles = "$prev"; then 7000b312a94cSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7001200d7199Smrg func_append dlfiles " $pic_object" 700265eef222Smrg prev= 700365eef222Smrg continue 700465eef222Smrg else 700565eef222Smrg # If libtool objects are unsupported, then we need to preload. 700665eef222Smrg prev=dlprefiles 700765eef222Smrg fi 700865eef222Smrg fi 7009ef981d24Smrg 701065eef222Smrg # CHECK ME: I think I busted this. -Ossama 7011b312a94cSmrg if test dlprefiles = "$prev"; then 701265eef222Smrg # Preload the old-style object. 7013200d7199Smrg func_append dlprefiles " $pic_object" 701465eef222Smrg prev= 701565eef222Smrg fi 7016ef981d24Smrg 701765eef222Smrg # A PIC object. 701865eef222Smrg func_append libobjs " $pic_object" 7019b312a94cSmrg arg=$pic_object 702065eef222Smrg fi 7021ef981d24Smrg 702265eef222Smrg # Non-PIC object. 7023b312a94cSmrg if test none != "$non_pic_object"; then 702465eef222Smrg # Prepend the subdirectory the object is found in. 7025b312a94cSmrg non_pic_object=$xdir$non_pic_object 7026ef981d24Smrg 702765eef222Smrg # A standard non-PIC object 702865eef222Smrg func_append non_pic_objects " $non_pic_object" 7029b312a94cSmrg if test -z "$pic_object" || test none = "$pic_object"; then 7030b312a94cSmrg arg=$non_pic_object 703165eef222Smrg fi 703265eef222Smrg else 703365eef222Smrg # If the PIC object exists, use it instead. 703465eef222Smrg # $xdir was prepended to $pic_object above. 7035b312a94cSmrg non_pic_object=$pic_object 703665eef222Smrg func_append non_pic_objects " $non_pic_object" 703765eef222Smrg fi 703865eef222Smrg else 703965eef222Smrg # Only an error if not doing a dry-run. 704065eef222Smrg if $opt_dry_run; then 704165eef222Smrg # Extract subdirectory from the argument. 704265eef222Smrg func_dirname "$arg" "/" "" 7043b312a94cSmrg xdir=$func_dirname_result 704465eef222Smrg 704565eef222Smrg func_lo2o "$arg" 704665eef222Smrg pic_object=$xdir$objdir/$func_lo2o_result 704765eef222Smrg non_pic_object=$xdir$func_lo2o_result 704865eef222Smrg func_append libobjs " $pic_object" 704965eef222Smrg func_append non_pic_objects " $non_pic_object" 705065eef222Smrg else 7051b312a94cSmrg func_fatal_error "'$arg' is not a valid libtool object" 705265eef222Smrg fi 705365eef222Smrg fi 705465eef222Smrg done 705565eef222Smrg else 7056b312a94cSmrg func_fatal_error "link input file '$arg' does not exist" 705765eef222Smrg fi 705865eef222Smrg arg=$save_arg 705965eef222Smrg prev= 706065eef222Smrg continue 706165eef222Smrg ;; 7062b312a94cSmrg os2dllname) 7063b312a94cSmrg os2dllname=$arg 7064b312a94cSmrg prev= 7065b312a94cSmrg continue 7066b312a94cSmrg ;; 706765eef222Smrg precious_regex) 7068b312a94cSmrg precious_files_regex=$arg 706965eef222Smrg prev= 707065eef222Smrg continue 707165eef222Smrg ;; 707265eef222Smrg release) 7073b312a94cSmrg release=-$arg 707465eef222Smrg prev= 707565eef222Smrg continue 707665eef222Smrg ;; 707765eef222Smrg rpath | xrpath) 707865eef222Smrg # We need an absolute path. 707965eef222Smrg case $arg in 708065eef222Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 708165eef222Smrg *) 708265eef222Smrg func_fatal_error "only absolute run-paths are allowed" 708365eef222Smrg ;; 708465eef222Smrg esac 7085b312a94cSmrg if test rpath = "$prev"; then 708665eef222Smrg case "$rpath " in 708765eef222Smrg *" $arg "*) ;; 7088200d7199Smrg *) func_append rpath " $arg" ;; 708965eef222Smrg esac 709065eef222Smrg else 709165eef222Smrg case "$xrpath " in 709265eef222Smrg *" $arg "*) ;; 7093200d7199Smrg *) func_append xrpath " $arg" ;; 709465eef222Smrg esac 709565eef222Smrg fi 709665eef222Smrg prev= 709765eef222Smrg continue 709865eef222Smrg ;; 709965eef222Smrg shrext) 7100b312a94cSmrg shrext_cmds=$arg 710165eef222Smrg prev= 710265eef222Smrg continue 710365eef222Smrg ;; 710465eef222Smrg weak) 7105200d7199Smrg func_append weak_libs " $arg" 710665eef222Smrg prev= 710765eef222Smrg continue 710865eef222Smrg ;; 7109d5637ae9Smrg xassembler) 7110d5637ae9Smrg func_append compiler_flags " -Xassembler $qarg" 7111d5637ae9Smrg prev= 7112d5637ae9Smrg func_append compile_command " -Xassembler $qarg" 7113d5637ae9Smrg func_append finalize_command " -Xassembler $qarg" 7114d5637ae9Smrg continue 7115d5637ae9Smrg ;; 711665eef222Smrg xcclinker) 7117200d7199Smrg func_append linker_flags " $qarg" 7118200d7199Smrg func_append compiler_flags " $qarg" 711965eef222Smrg prev= 712065eef222Smrg func_append compile_command " $qarg" 712165eef222Smrg func_append finalize_command " $qarg" 712265eef222Smrg continue 712365eef222Smrg ;; 712465eef222Smrg xcompiler) 7125200d7199Smrg func_append compiler_flags " $qarg" 712665eef222Smrg prev= 712765eef222Smrg func_append compile_command " $qarg" 712865eef222Smrg func_append finalize_command " $qarg" 712965eef222Smrg continue 713065eef222Smrg ;; 713165eef222Smrg xlinker) 7132200d7199Smrg func_append linker_flags " $qarg" 7133200d7199Smrg func_append compiler_flags " $wl$qarg" 713465eef222Smrg prev= 713565eef222Smrg func_append compile_command " $wl$qarg" 713665eef222Smrg func_append finalize_command " $wl$qarg" 713765eef222Smrg continue 713865eef222Smrg ;; 713965eef222Smrg *) 714065eef222Smrg eval "$prev=\"\$arg\"" 714165eef222Smrg prev= 714265eef222Smrg continue 714365eef222Smrg ;; 7144ef981d24Smrg esac 714565eef222Smrg fi # test -n "$prev" 7146ef981d24Smrg 7147b312a94cSmrg prevarg=$arg 7148ef981d24Smrg 714965eef222Smrg case $arg in 715065eef222Smrg -all-static) 715165eef222Smrg if test -n "$link_static_flag"; then 715265eef222Smrg # See comment for -static flag below, for more details. 715365eef222Smrg func_append compile_command " $link_static_flag" 715465eef222Smrg func_append finalize_command " $link_static_flag" 715565eef222Smrg fi 715665eef222Smrg continue 715765eef222Smrg ;; 7158ef981d24Smrg 715965eef222Smrg -allow-undefined) 716065eef222Smrg # FIXME: remove this flag sometime in the future. 7161b312a94cSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 716265eef222Smrg ;; 7163ef981d24Smrg 716465eef222Smrg -avoid-version) 716565eef222Smrg avoid_version=yes 716665eef222Smrg continue 716765eef222Smrg ;; 7168ef981d24Smrg 716956957a04Smrg -bindir) 717056957a04Smrg prev=bindir 717156957a04Smrg continue 717256957a04Smrg ;; 717356957a04Smrg 717465eef222Smrg -dlopen) 717565eef222Smrg prev=dlfiles 717665eef222Smrg continue 717765eef222Smrg ;; 7178ef981d24Smrg 717965eef222Smrg -dlpreopen) 718065eef222Smrg prev=dlprefiles 718165eef222Smrg continue 718265eef222Smrg ;; 7183ef981d24Smrg 718465eef222Smrg -export-dynamic) 718565eef222Smrg export_dynamic=yes 718665eef222Smrg continue 718765eef222Smrg ;; 7188ef981d24Smrg 718965eef222Smrg -export-symbols | -export-symbols-regex) 719065eef222Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 719165eef222Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 719265eef222Smrg fi 7193b312a94cSmrg if test X-export-symbols = "X$arg"; then 719465eef222Smrg prev=expsyms 719565eef222Smrg else 719665eef222Smrg prev=expsyms_regex 719765eef222Smrg fi 719865eef222Smrg continue 719965eef222Smrg ;; 7200ef981d24Smrg 720165eef222Smrg -framework) 720265eef222Smrg prev=framework 720365eef222Smrg continue 720465eef222Smrg ;; 7205ef981d24Smrg 720665eef222Smrg -inst-prefix-dir) 720765eef222Smrg prev=inst_prefix 720865eef222Smrg continue 720965eef222Smrg ;; 7210ef981d24Smrg 721165eef222Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 721265eef222Smrg # so, if we see these flags be careful not to treat them like -L 721365eef222Smrg -L[A-Z][A-Z]*:*) 721465eef222Smrg case $with_gcc/$host in 721565eef222Smrg no/*-*-irix* | /*-*-irix*) 721665eef222Smrg func_append compile_command " $arg" 721765eef222Smrg func_append finalize_command " $arg" 721865eef222Smrg ;; 721965eef222Smrg esac 722065eef222Smrg continue 722165eef222Smrg ;; 7222ef981d24Smrg 722365eef222Smrg -L*) 7224200d7199Smrg func_stripname "-L" '' "$arg" 7225200d7199Smrg if test -z "$func_stripname_result"; then 722665eef222Smrg if test "$#" -gt 0; then 7227b312a94cSmrg func_fatal_error "require no space between '-L' and '$1'" 722865eef222Smrg else 7229b312a94cSmrg func_fatal_error "need path for '-L' option" 723065eef222Smrg fi 723165eef222Smrg fi 7232200d7199Smrg func_resolve_sysroot "$func_stripname_result" 7233200d7199Smrg dir=$func_resolve_sysroot_result 723465eef222Smrg # We need an absolute path. 723565eef222Smrg case $dir in 723665eef222Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 723765eef222Smrg *) 723865eef222Smrg absdir=`cd "$dir" && pwd` 723965eef222Smrg test -z "$absdir" && \ 7240b312a94cSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 7241b312a94cSmrg dir=$absdir 724265eef222Smrg ;; 724365eef222Smrg esac 724465eef222Smrg case "$deplibs " in 7245200d7199Smrg *" -L$dir "* | *" $arg "*) 7246200d7199Smrg # Will only happen for absolute or sysroot arguments 7247200d7199Smrg ;; 724865eef222Smrg *) 7249200d7199Smrg # Preserve sysroot, but never include relative directories 7250200d7199Smrg case $dir in 7251200d7199Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 7252200d7199Smrg *) func_append deplibs " -L$dir" ;; 7253200d7199Smrg esac 7254200d7199Smrg func_append lib_search_path " $dir" 725565eef222Smrg ;; 725665eef222Smrg esac 725765eef222Smrg case $host in 725865eef222Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 725956957a04Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 726065eef222Smrg case :$dllsearchpath: in 726165eef222Smrg *":$dir:"*) ;; 726265eef222Smrg ::) dllsearchpath=$dir;; 7263200d7199Smrg *) func_append dllsearchpath ":$dir";; 726465eef222Smrg esac 726565eef222Smrg case :$dllsearchpath: in 726665eef222Smrg *":$testbindir:"*) ;; 726765eef222Smrg ::) dllsearchpath=$testbindir;; 7268200d7199Smrg *) func_append dllsearchpath ":$testbindir";; 726965eef222Smrg esac 727065eef222Smrg ;; 727165eef222Smrg esac 727265eef222Smrg continue 727365eef222Smrg ;; 7274ef981d24Smrg 727565eef222Smrg -l*) 7276b312a94cSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 727765eef222Smrg case $host in 727856957a04Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 727965eef222Smrg # These systems don't actually have a C or math library (as such) 728065eef222Smrg continue 728165eef222Smrg ;; 728265eef222Smrg *-*-os2*) 728365eef222Smrg # These systems don't actually have a C library (as such) 7284b312a94cSmrg test X-lc = "X$arg" && continue 728565eef222Smrg ;; 7286d5637ae9Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 728765eef222Smrg # Do not include libc due to us having libc/libc_r. 7288b312a94cSmrg test X-lc = "X$arg" && continue 728965eef222Smrg ;; 729065eef222Smrg *-*-rhapsody* | *-*-darwin1.[012]) 729165eef222Smrg # Rhapsody C and math libraries are in the System framework 7292200d7199Smrg func_append deplibs " System.ltframework" 729365eef222Smrg continue 729465eef222Smrg ;; 729565eef222Smrg *-*-sco3.2v5* | *-*-sco5v6*) 729665eef222Smrg # Causes problems with __ctype 7297b312a94cSmrg test X-lc = "X$arg" && continue 729865eef222Smrg ;; 729965eef222Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 730065eef222Smrg # Compiler inserts libc in the correct place for threads to work 7301b312a94cSmrg test X-lc = "X$arg" && continue 730265eef222Smrg ;; 730365eef222Smrg esac 7304b312a94cSmrg elif test X-lc_r = "X$arg"; then 730565eef222Smrg case $host in 7306d5637ae9Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 730765eef222Smrg # Do not include libc_r directly, use -pthread flag. 730865eef222Smrg continue 730965eef222Smrg ;; 731065eef222Smrg esac 731165eef222Smrg fi 7312200d7199Smrg func_append deplibs " $arg" 731365eef222Smrg continue 731465eef222Smrg ;; 7315ef981d24Smrg 7316b312a94cSmrg -mllvm) 7317b312a94cSmrg prev=mllvm 7318b312a94cSmrg continue 7319b312a94cSmrg ;; 7320b312a94cSmrg 732165eef222Smrg -module) 732265eef222Smrg module=yes 732365eef222Smrg continue 732465eef222Smrg ;; 7325ef981d24Smrg 732665eef222Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 732765eef222Smrg # classes, name mangling, and exception handling. 732865eef222Smrg # Darwin uses the -arch flag to determine output architecture. 7329200d7199Smrg -model|-arch|-isysroot|--sysroot) 7330200d7199Smrg func_append compiler_flags " $arg" 733165eef222Smrg func_append compile_command " $arg" 733265eef222Smrg func_append finalize_command " $arg" 733365eef222Smrg prev=xcompiler 733465eef222Smrg continue 733565eef222Smrg ;; 7336d5637ae9Smrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 7337d5637ae9Smrg -pthread) 7338d5637ae9Smrg case $host in 7339d5637ae9Smrg *solaris2*) ;; 7340d5637ae9Smrg *) 7341d5637ae9Smrg case "$new_inherited_linker_flags " in 7342d5637ae9Smrg *" $arg "*) ;; 7343d5637ae9Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7344d5637ae9Smrg esac 7345d5637ae9Smrg ;; 7346d5637ae9Smrg esac 7347d5637ae9Smrg continue 7348d5637ae9Smrg ;; 7349d5637ae9Smrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 7350b312a94cSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7351200d7199Smrg func_append compiler_flags " $arg" 735265eef222Smrg func_append compile_command " $arg" 735365eef222Smrg func_append finalize_command " $arg" 735465eef222Smrg case "$new_inherited_linker_flags " in 735565eef222Smrg *" $arg "*) ;; 7356200d7199Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 735765eef222Smrg esac 735865eef222Smrg continue 735965eef222Smrg ;; 7360ef981d24Smrg 736165eef222Smrg -multi_module) 7362b312a94cSmrg single_module=$wl-multi_module 736365eef222Smrg continue 736465eef222Smrg ;; 7365ef981d24Smrg 736665eef222Smrg -no-fast-install) 736765eef222Smrg fast_install=no 736865eef222Smrg continue 736965eef222Smrg ;; 7370ef981d24Smrg 737165eef222Smrg -no-install) 737265eef222Smrg case $host in 737365eef222Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 737465eef222Smrg # The PATH hackery in wrapper scripts is required on Windows 737565eef222Smrg # and Darwin in order for the loader to find any dlls it needs. 7376b312a94cSmrg func_warning "'-no-install' is ignored for $host" 7377b312a94cSmrg func_warning "assuming '-no-fast-install' instead" 737865eef222Smrg fast_install=no 737965eef222Smrg ;; 738065eef222Smrg *) no_install=yes ;; 738165eef222Smrg esac 738265eef222Smrg continue 738365eef222Smrg ;; 7384ef981d24Smrg 738565eef222Smrg -no-undefined) 738665eef222Smrg allow_undefined=no 738765eef222Smrg continue 738865eef222Smrg ;; 7389ef981d24Smrg 739065eef222Smrg -objectlist) 739165eef222Smrg prev=objectlist 739265eef222Smrg continue 739365eef222Smrg ;; 7394ef981d24Smrg 7395b312a94cSmrg -os2dllname) 7396b312a94cSmrg prev=os2dllname 7397b312a94cSmrg continue 7398b312a94cSmrg ;; 7399b312a94cSmrg 740065eef222Smrg -o) prev=output ;; 7401ef981d24Smrg 740265eef222Smrg -precious-files-regex) 740365eef222Smrg prev=precious_regex 740465eef222Smrg continue 740565eef222Smrg ;; 7406ef981d24Smrg 740765eef222Smrg -release) 740865eef222Smrg prev=release 740965eef222Smrg continue 741065eef222Smrg ;; 7411ef981d24Smrg 741265eef222Smrg -rpath) 741365eef222Smrg prev=rpath 741465eef222Smrg continue 741565eef222Smrg ;; 7416ef981d24Smrg 741765eef222Smrg -R) 741865eef222Smrg prev=xrpath 741965eef222Smrg continue 742065eef222Smrg ;; 7421ef981d24Smrg 742265eef222Smrg -R*) 742365eef222Smrg func_stripname '-R' '' "$arg" 742465eef222Smrg dir=$func_stripname_result 742565eef222Smrg # We need an absolute path. 742665eef222Smrg case $dir in 742765eef222Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7428200d7199Smrg =*) 7429200d7199Smrg func_stripname '=' '' "$dir" 7430200d7199Smrg dir=$lt_sysroot$func_stripname_result 7431200d7199Smrg ;; 743265eef222Smrg *) 743365eef222Smrg func_fatal_error "only absolute run-paths are allowed" 743465eef222Smrg ;; 743565eef222Smrg esac 743665eef222Smrg case "$xrpath " in 743765eef222Smrg *" $dir "*) ;; 7438200d7199Smrg *) func_append xrpath " $dir" ;; 743965eef222Smrg esac 744065eef222Smrg continue 744165eef222Smrg ;; 7442ef981d24Smrg 744365eef222Smrg -shared) 744465eef222Smrg # The effects of -shared are defined in a previous loop. 744565eef222Smrg continue 744665eef222Smrg ;; 7447ef981d24Smrg 744865eef222Smrg -shrext) 744965eef222Smrg prev=shrext 745065eef222Smrg continue 745165eef222Smrg ;; 7452ef981d24Smrg 745365eef222Smrg -static | -static-libtool-libs) 745465eef222Smrg # The effects of -static are defined in a previous loop. 745565eef222Smrg # We used to do the same as -all-static on platforms that 745665eef222Smrg # didn't have a PIC flag, but the assumption that the effects 745765eef222Smrg # would be equivalent was wrong. It would break on at least 745865eef222Smrg # Digital Unix and AIX. 745965eef222Smrg continue 746065eef222Smrg ;; 7461ef981d24Smrg 746265eef222Smrg -thread-safe) 746365eef222Smrg thread_safe=yes 746465eef222Smrg continue 746565eef222Smrg ;; 7466ef981d24Smrg 746765eef222Smrg -version-info) 746865eef222Smrg prev=vinfo 746965eef222Smrg continue 747065eef222Smrg ;; 7471ef981d24Smrg 747265eef222Smrg -version-number) 747365eef222Smrg prev=vinfo 747465eef222Smrg vinfo_number=yes 747565eef222Smrg continue 747665eef222Smrg ;; 7477ef981d24Smrg 747865eef222Smrg -weak) 747965eef222Smrg prev=weak 748065eef222Smrg continue 748165eef222Smrg ;; 7482ef981d24Smrg 748365eef222Smrg -Wc,*) 748465eef222Smrg func_stripname '-Wc,' '' "$arg" 748565eef222Smrg args=$func_stripname_result 748665eef222Smrg arg= 7487b312a94cSmrg save_ifs=$IFS; IFS=, 748865eef222Smrg for flag in $args; do 7489b312a94cSmrg IFS=$save_ifs 7490d5637ae9Smrg func_quote_arg pretty "$flag" 7491d5637ae9Smrg func_append arg " $func_quote_arg_result" 7492d5637ae9Smrg func_append compiler_flags " $func_quote_arg_result" 749365eef222Smrg done 7494b312a94cSmrg IFS=$save_ifs 749565eef222Smrg func_stripname ' ' '' "$arg" 749665eef222Smrg arg=$func_stripname_result 749765eef222Smrg ;; 7498ef981d24Smrg 749965eef222Smrg -Wl,*) 750065eef222Smrg func_stripname '-Wl,' '' "$arg" 750165eef222Smrg args=$func_stripname_result 750265eef222Smrg arg= 7503b312a94cSmrg save_ifs=$IFS; IFS=, 750465eef222Smrg for flag in $args; do 7505b312a94cSmrg IFS=$save_ifs 7506d5637ae9Smrg func_quote_arg pretty "$flag" 7507d5637ae9Smrg func_append arg " $wl$func_quote_arg_result" 7508d5637ae9Smrg func_append compiler_flags " $wl$func_quote_arg_result" 7509d5637ae9Smrg func_append linker_flags " $func_quote_arg_result" 751065eef222Smrg done 7511b312a94cSmrg IFS=$save_ifs 751265eef222Smrg func_stripname ' ' '' "$arg" 751365eef222Smrg arg=$func_stripname_result 751465eef222Smrg ;; 7515ef981d24Smrg 7516d5637ae9Smrg -Xassembler) 7517d5637ae9Smrg prev=xassembler 7518d5637ae9Smrg continue 7519d5637ae9Smrg ;; 7520d5637ae9Smrg 752165eef222Smrg -Xcompiler) 752265eef222Smrg prev=xcompiler 752365eef222Smrg continue 752465eef222Smrg ;; 7525ef981d24Smrg 752665eef222Smrg -Xlinker) 752765eef222Smrg prev=xlinker 752865eef222Smrg continue 752965eef222Smrg ;; 7530ef981d24Smrg 753165eef222Smrg -XCClinker) 753265eef222Smrg prev=xcclinker 753365eef222Smrg continue 753465eef222Smrg ;; 7535ef981d24Smrg 753665eef222Smrg # -msg_* for osf cc 753765eef222Smrg -msg_*) 7538d5637ae9Smrg func_quote_arg pretty "$arg" 7539d5637ae9Smrg arg=$func_quote_arg_result 754065eef222Smrg ;; 7541ef981d24Smrg 754256957a04Smrg # Flags to be passed through unchanged, with rationale: 754356957a04Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 754456957a04Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 754556957a04Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 754656957a04Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 754756957a04Smrg # -q* compiler args for the IBM compiler 754856957a04Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 754956957a04Smrg # -F/path path to uninstalled frameworks, gcc on darwin 755056957a04Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7551b312a94cSmrg # -fstack-protector* stack protector flags for GCC 755256957a04Smrg # @file GCC response files 755356957a04Smrg # -tp=* Portland pgcc target processor selection 7554200d7199Smrg # --sysroot=* for sysroot support 7555b312a94cSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7556b312a94cSmrg # -specs=* GCC specs files 7557b312a94cSmrg # -stdlib=* select c++ std lib with clang 7558d5637ae9Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 7559d5637ae9Smrg # -fuse-ld=* Linker select flags for GCC 7560d5637ae9Smrg # -Wa,* Pass flags directly to the assembler 756165eef222Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7562200d7199Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7563b312a94cSmrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 7564d5637ae9Smrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 7565d5637ae9Smrg func_quote_arg pretty "$arg" 7566d5637ae9Smrg arg=$func_quote_arg_result 756765eef222Smrg func_append compile_command " $arg" 756865eef222Smrg func_append finalize_command " $arg" 7569200d7199Smrg func_append compiler_flags " $arg" 757065eef222Smrg continue 757165eef222Smrg ;; 7572ef981d24Smrg 7573b312a94cSmrg -Z*) 7574b312a94cSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 7575b312a94cSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 7576b312a94cSmrg compiler_flags="$compiler_flags $arg" 7577b312a94cSmrg func_append compile_command " $arg" 7578b312a94cSmrg func_append finalize_command " $arg" 7579b312a94cSmrg case $arg in 7580b312a94cSmrg -Zlinker | -Zstack) 7581b312a94cSmrg prev=xcompiler 7582b312a94cSmrg ;; 7583b312a94cSmrg esac 7584b312a94cSmrg continue 7585b312a94cSmrg else 7586b312a94cSmrg # Otherwise treat like 'Some other compiler flag' below 7587d5637ae9Smrg func_quote_arg pretty "$arg" 7588d5637ae9Smrg arg=$func_quote_arg_result 7589b312a94cSmrg fi 7590b312a94cSmrg ;; 7591b312a94cSmrg 759265eef222Smrg # Some other compiler flag. 759365eef222Smrg -* | +*) 7594d5637ae9Smrg func_quote_arg pretty "$arg" 7595d5637ae9Smrg arg=$func_quote_arg_result 759665eef222Smrg ;; 7597ef981d24Smrg 759865eef222Smrg *.$objext) 759965eef222Smrg # A standard object. 7600200d7199Smrg func_append objs " $arg" 760165eef222Smrg ;; 760265eef222Smrg 760365eef222Smrg *.lo) 760465eef222Smrg # A libtool-controlled object. 760565eef222Smrg 760665eef222Smrg # Check to see that this really is a libtool object. 760765eef222Smrg if func_lalib_unsafe_p "$arg"; then 760865eef222Smrg pic_object= 760965eef222Smrg non_pic_object= 761065eef222Smrg 761165eef222Smrg # Read the .lo file 761265eef222Smrg func_source "$arg" 761365eef222Smrg 761465eef222Smrg if test -z "$pic_object" || 761565eef222Smrg test -z "$non_pic_object" || 7616b312a94cSmrg test none = "$pic_object" && 7617b312a94cSmrg test none = "$non_pic_object"; then 7618b312a94cSmrg func_fatal_error "cannot find name of object for '$arg'" 761965eef222Smrg fi 762065eef222Smrg 762165eef222Smrg # Extract subdirectory from the argument. 762265eef222Smrg func_dirname "$arg" "/" "" 7623b312a94cSmrg xdir=$func_dirname_result 762465eef222Smrg 7625b312a94cSmrg test none = "$pic_object" || { 762665eef222Smrg # Prepend the subdirectory the object is found in. 7627b312a94cSmrg pic_object=$xdir$pic_object 762865eef222Smrg 7629b312a94cSmrg if test dlfiles = "$prev"; then 7630b312a94cSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7631200d7199Smrg func_append dlfiles " $pic_object" 763265eef222Smrg prev= 763365eef222Smrg continue 763465eef222Smrg else 763565eef222Smrg # If libtool objects are unsupported, then we need to preload. 763665eef222Smrg prev=dlprefiles 763765eef222Smrg fi 763865eef222Smrg fi 763965eef222Smrg 764065eef222Smrg # CHECK ME: I think I busted this. -Ossama 7641b312a94cSmrg if test dlprefiles = "$prev"; then 764265eef222Smrg # Preload the old-style object. 7643200d7199Smrg func_append dlprefiles " $pic_object" 764465eef222Smrg prev= 764565eef222Smrg fi 764665eef222Smrg 764765eef222Smrg # A PIC object. 764865eef222Smrg func_append libobjs " $pic_object" 7649b312a94cSmrg arg=$pic_object 7650b312a94cSmrg } 765165eef222Smrg 765265eef222Smrg # Non-PIC object. 7653b312a94cSmrg if test none != "$non_pic_object"; then 765465eef222Smrg # Prepend the subdirectory the object is found in. 7655b312a94cSmrg non_pic_object=$xdir$non_pic_object 765665eef222Smrg 765765eef222Smrg # A standard non-PIC object 765865eef222Smrg func_append non_pic_objects " $non_pic_object" 7659b312a94cSmrg if test -z "$pic_object" || test none = "$pic_object"; then 7660b312a94cSmrg arg=$non_pic_object 766165eef222Smrg fi 766265eef222Smrg else 766365eef222Smrg # If the PIC object exists, use it instead. 766465eef222Smrg # $xdir was prepended to $pic_object above. 7665b312a94cSmrg non_pic_object=$pic_object 766665eef222Smrg func_append non_pic_objects " $non_pic_object" 766765eef222Smrg fi 766865eef222Smrg else 766965eef222Smrg # Only an error if not doing a dry-run. 767065eef222Smrg if $opt_dry_run; then 767165eef222Smrg # Extract subdirectory from the argument. 767265eef222Smrg func_dirname "$arg" "/" "" 7673b312a94cSmrg xdir=$func_dirname_result 767465eef222Smrg 767565eef222Smrg func_lo2o "$arg" 767665eef222Smrg pic_object=$xdir$objdir/$func_lo2o_result 767765eef222Smrg non_pic_object=$xdir$func_lo2o_result 767865eef222Smrg func_append libobjs " $pic_object" 767965eef222Smrg func_append non_pic_objects " $non_pic_object" 768065eef222Smrg else 7681b312a94cSmrg func_fatal_error "'$arg' is not a valid libtool object" 768265eef222Smrg fi 768365eef222Smrg fi 768465eef222Smrg ;; 768565eef222Smrg 768665eef222Smrg *.$libext) 768765eef222Smrg # An archive. 7688200d7199Smrg func_append deplibs " $arg" 7689200d7199Smrg func_append old_deplibs " $arg" 769065eef222Smrg continue 769165eef222Smrg ;; 769265eef222Smrg 769365eef222Smrg *.la) 769465eef222Smrg # A libtool-controlled library. 769565eef222Smrg 7696200d7199Smrg func_resolve_sysroot "$arg" 7697b312a94cSmrg if test dlfiles = "$prev"; then 769865eef222Smrg # This library was specified with -dlopen. 7699200d7199Smrg func_append dlfiles " $func_resolve_sysroot_result" 770065eef222Smrg prev= 7701b312a94cSmrg elif test dlprefiles = "$prev"; then 770265eef222Smrg # The library was specified with -dlpreopen. 7703200d7199Smrg func_append dlprefiles " $func_resolve_sysroot_result" 770465eef222Smrg prev= 770565eef222Smrg else 7706200d7199Smrg func_append deplibs " $func_resolve_sysroot_result" 770765eef222Smrg fi 770865eef222Smrg continue 770965eef222Smrg ;; 771065eef222Smrg 771165eef222Smrg # Some other compiler argument. 771265eef222Smrg *) 771365eef222Smrg # Unknown arguments in both finalize_command and compile_command need 771465eef222Smrg # to be aesthetically quoted because they are evaled later. 7715d5637ae9Smrg func_quote_arg pretty "$arg" 7716d5637ae9Smrg arg=$func_quote_arg_result 771765eef222Smrg ;; 771865eef222Smrg esac # arg 771965eef222Smrg 772065eef222Smrg # Now actually substitute the argument into the commands. 772165eef222Smrg if test -n "$arg"; then 772265eef222Smrg func_append compile_command " $arg" 772365eef222Smrg func_append finalize_command " $arg" 772465eef222Smrg fi 772565eef222Smrg done # argument parsing loop 772665eef222Smrg 772765eef222Smrg test -n "$prev" && \ 7728b312a94cSmrg func_fatal_help "the '$prevarg' option requires an argument" 772965eef222Smrg 7730b312a94cSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 773165eef222Smrg eval arg=\"$export_dynamic_flag_spec\" 773265eef222Smrg func_append compile_command " $arg" 773365eef222Smrg func_append finalize_command " $arg" 773465eef222Smrg fi 773565eef222Smrg 773665eef222Smrg oldlibs= 773765eef222Smrg # calculate the name of the file, without its directory 773865eef222Smrg func_basename "$output" 7739b312a94cSmrg outputname=$func_basename_result 7740b312a94cSmrg libobjs_save=$libobjs 774165eef222Smrg 774265eef222Smrg if test -n "$shlibpath_var"; then 774365eef222Smrg # get the directories listed in $shlibpath_var 7744b312a94cSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7745ef981d24Smrg else 774665eef222Smrg shlib_search_path= 7747ef981d24Smrg fi 774865eef222Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 774965eef222Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7750ef981d24Smrg 7751b312a94cSmrg # Definition is injected by LT_CONFIG during libtool generation. 7752b312a94cSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7753b312a94cSmrg 775465eef222Smrg func_dirname "$output" "/" "" 7755b312a94cSmrg output_objdir=$func_dirname_result$objdir 7756200d7199Smrg func_to_tool_file "$output_objdir/" 7757200d7199Smrg tool_output_objdir=$func_to_tool_file_result 775865eef222Smrg # Create the object directory. 775965eef222Smrg func_mkdir_p "$output_objdir" 7760ef981d24Smrg 776165eef222Smrg # Determine the type of output 776265eef222Smrg case $output in 776365eef222Smrg "") 776465eef222Smrg func_fatal_help "you must specify an output file" 776565eef222Smrg ;; 776665eef222Smrg *.$libext) linkmode=oldlib ;; 776765eef222Smrg *.lo | *.$objext) linkmode=obj ;; 776865eef222Smrg *.la) linkmode=lib ;; 776965eef222Smrg *) linkmode=prog ;; # Anything else should be a program. 777065eef222Smrg esac 777165eef222Smrg 777265eef222Smrg specialdeplibs= 777365eef222Smrg 777465eef222Smrg libs= 777565eef222Smrg # Find all interdependent deplibs by searching for libraries 777665eef222Smrg # that are linked more than once (e.g. -la -lb -la) 777765eef222Smrg for deplib in $deplibs; do 7778b312a94cSmrg if $opt_preserve_dup_deps; then 777965eef222Smrg case "$libs " in 7780200d7199Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 778165eef222Smrg esac 778265eef222Smrg fi 7783200d7199Smrg func_append libs " $deplib" 778465eef222Smrg done 778565eef222Smrg 7786b312a94cSmrg if test lib = "$linkmode"; then 778765eef222Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 778865eef222Smrg 778965eef222Smrg # Compute libraries that are listed more than once in $predeps 779065eef222Smrg # $postdeps and mark them as special (i.e., whose duplicates are 779165eef222Smrg # not to be eliminated). 779265eef222Smrg pre_post_deps= 779365eef222Smrg if $opt_duplicate_compiler_generated_deps; then 779465eef222Smrg for pre_post_dep in $predeps $postdeps; do 779565eef222Smrg case "$pre_post_deps " in 7796200d7199Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 779765eef222Smrg esac 7798200d7199Smrg func_append pre_post_deps " $pre_post_dep" 779965eef222Smrg done 780065eef222Smrg fi 780165eef222Smrg pre_post_deps= 780265eef222Smrg fi 780365eef222Smrg 780465eef222Smrg deplibs= 780565eef222Smrg newdependency_libs= 780665eef222Smrg newlib_search_path= 780765eef222Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 780865eef222Smrg notinst_deplibs= # not-installed libtool libraries 780965eef222Smrg notinst_path= # paths that contain not-installed libtool libraries 781065eef222Smrg 781165eef222Smrg case $linkmode in 781265eef222Smrg lib) 781365eef222Smrg passes="conv dlpreopen link" 781465eef222Smrg for file in $dlfiles $dlprefiles; do 781565eef222Smrg case $file in 781665eef222Smrg *.la) ;; 781765eef222Smrg *) 7818b312a94cSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 781965eef222Smrg ;; 782065eef222Smrg esac 782165eef222Smrg done 782265eef222Smrg ;; 782365eef222Smrg prog) 782465eef222Smrg compile_deplibs= 782565eef222Smrg finalize_deplibs= 7826b312a94cSmrg alldeplibs=false 782765eef222Smrg newdlfiles= 782865eef222Smrg newdlprefiles= 782965eef222Smrg passes="conv scan dlopen dlpreopen link" 783065eef222Smrg ;; 783165eef222Smrg *) passes="conv" 783265eef222Smrg ;; 783365eef222Smrg esac 783465eef222Smrg 783565eef222Smrg for pass in $passes; do 783665eef222Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 783765eef222Smrg # so that -L comes before libs that need it for instance... 7838b312a94cSmrg if test lib,link = "$linkmode,$pass"; then 783965eef222Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 784065eef222Smrg ## order, and fix it there properly 784165eef222Smrg tmp_deplibs= 784265eef222Smrg for deplib in $deplibs; do 784365eef222Smrg tmp_deplibs="$deplib $tmp_deplibs" 784465eef222Smrg done 7845b312a94cSmrg deplibs=$tmp_deplibs 784665eef222Smrg fi 784765eef222Smrg 7848b312a94cSmrg if test lib,link = "$linkmode,$pass" || 7849b312a94cSmrg test prog,scan = "$linkmode,$pass"; then 7850b312a94cSmrg libs=$deplibs 785165eef222Smrg deplibs= 785265eef222Smrg fi 7853b312a94cSmrg if test prog = "$linkmode"; then 785465eef222Smrg case $pass in 7855b312a94cSmrg dlopen) libs=$dlfiles ;; 7856b312a94cSmrg dlpreopen) libs=$dlprefiles ;; 785765eef222Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 785865eef222Smrg esac 785965eef222Smrg fi 7860b312a94cSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 786165eef222Smrg # Collect and forward deplibs of preopened libtool libs 786265eef222Smrg for lib in $dlprefiles; do 786365eef222Smrg # Ignore non-libtool-libs 786465eef222Smrg dependency_libs= 7865200d7199Smrg func_resolve_sysroot "$lib" 786665eef222Smrg case $lib in 7867200d7199Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 786865eef222Smrg esac 786965eef222Smrg 787065eef222Smrg # Collect preopened libtool deplibs, except any this library 787165eef222Smrg # has declared as weak libs 787265eef222Smrg for deplib in $dependency_libs; do 787356957a04Smrg func_basename "$deplib" 787456957a04Smrg deplib_base=$func_basename_result 787565eef222Smrg case " $weak_libs " in 787665eef222Smrg *" $deplib_base "*) ;; 7877200d7199Smrg *) func_append deplibs " $deplib" ;; 787865eef222Smrg esac 787965eef222Smrg done 788065eef222Smrg done 7881b312a94cSmrg libs=$dlprefiles 788265eef222Smrg fi 7883b312a94cSmrg if test dlopen = "$pass"; then 788465eef222Smrg # Collect dlpreopened libraries 7885b312a94cSmrg save_deplibs=$deplibs 788665eef222Smrg deplibs= 788765eef222Smrg fi 788865eef222Smrg 788965eef222Smrg for deplib in $libs; do 789065eef222Smrg lib= 7891b312a94cSmrg found=false 789265eef222Smrg case $deplib in 7893b312a94cSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7894b312a94cSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7895b312a94cSmrg if test prog,link = "$linkmode,$pass"; then 789665eef222Smrg compile_deplibs="$deplib $compile_deplibs" 789765eef222Smrg finalize_deplibs="$deplib $finalize_deplibs" 789865eef222Smrg else 7899200d7199Smrg func_append compiler_flags " $deplib" 7900b312a94cSmrg if test lib = "$linkmode"; then 790165eef222Smrg case "$new_inherited_linker_flags " in 790265eef222Smrg *" $deplib "*) ;; 7903200d7199Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 790465eef222Smrg esac 790565eef222Smrg fi 790665eef222Smrg fi 790765eef222Smrg continue 790865eef222Smrg ;; 790965eef222Smrg -l*) 7910b312a94cSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 7911b312a94cSmrg func_warning "'-l' is ignored for archives/objects" 791265eef222Smrg continue 791365eef222Smrg fi 791465eef222Smrg func_stripname '-l' '' "$deplib" 791565eef222Smrg name=$func_stripname_result 7916b312a94cSmrg if test lib = "$linkmode"; then 791765eef222Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 791865eef222Smrg else 791965eef222Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 792065eef222Smrg fi 792165eef222Smrg for searchdir in $searchdirs; do 792265eef222Smrg for search_ext in .la $std_shrext .so .a; do 792365eef222Smrg # Search the libtool library 7924b312a94cSmrg lib=$searchdir/lib$name$search_ext 792565eef222Smrg if test -f "$lib"; then 7926b312a94cSmrg if test .la = "$search_ext"; then 7927b312a94cSmrg found=: 792865eef222Smrg else 7929b312a94cSmrg found=false 793065eef222Smrg fi 793165eef222Smrg break 2 793265eef222Smrg fi 793365eef222Smrg done 793465eef222Smrg done 7935b312a94cSmrg if $found; then 7936b312a94cSmrg # deplib is a libtool library 793765eef222Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 793865eef222Smrg # We need to do some special things here, and not later. 7939b312a94cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 794065eef222Smrg case " $predeps $postdeps " in 794165eef222Smrg *" $deplib "*) 794265eef222Smrg if func_lalib_p "$lib"; then 794365eef222Smrg library_names= 794465eef222Smrg old_library= 794565eef222Smrg func_source "$lib" 794665eef222Smrg for l in $old_library $library_names; do 7947b312a94cSmrg ll=$l 794865eef222Smrg done 7949b312a94cSmrg if test "X$ll" = "X$old_library"; then # only static version available 7950b312a94cSmrg found=false 795165eef222Smrg func_dirname "$lib" "" "." 7952b312a94cSmrg ladir=$func_dirname_result 795365eef222Smrg lib=$ladir/$old_library 7954b312a94cSmrg if test prog,link = "$linkmode,$pass"; then 795565eef222Smrg compile_deplibs="$deplib $compile_deplibs" 795665eef222Smrg finalize_deplibs="$deplib $finalize_deplibs" 795765eef222Smrg else 795865eef222Smrg deplibs="$deplib $deplibs" 7959b312a94cSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 796065eef222Smrg fi 796165eef222Smrg continue 796265eef222Smrg fi 796365eef222Smrg fi 796465eef222Smrg ;; 796565eef222Smrg *) ;; 796665eef222Smrg esac 796765eef222Smrg fi 7968b312a94cSmrg else 7969b312a94cSmrg # deplib doesn't seem to be a libtool library 7970b312a94cSmrg if test prog,link = "$linkmode,$pass"; then 7971b312a94cSmrg compile_deplibs="$deplib $compile_deplibs" 7972b312a94cSmrg finalize_deplibs="$deplib $finalize_deplibs" 7973b312a94cSmrg else 7974b312a94cSmrg deplibs="$deplib $deplibs" 7975b312a94cSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7976b312a94cSmrg fi 7977b312a94cSmrg continue 797865eef222Smrg fi 797965eef222Smrg ;; # -l 798065eef222Smrg *.ltframework) 7981b312a94cSmrg if test prog,link = "$linkmode,$pass"; then 798265eef222Smrg compile_deplibs="$deplib $compile_deplibs" 798365eef222Smrg finalize_deplibs="$deplib $finalize_deplibs" 798465eef222Smrg else 798565eef222Smrg deplibs="$deplib $deplibs" 7986b312a94cSmrg if test lib = "$linkmode"; then 798765eef222Smrg case "$new_inherited_linker_flags " in 798865eef222Smrg *" $deplib "*) ;; 7989200d7199Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 799065eef222Smrg esac 799165eef222Smrg fi 799265eef222Smrg fi 799365eef222Smrg continue 799465eef222Smrg ;; 799565eef222Smrg -L*) 799665eef222Smrg case $linkmode in 799765eef222Smrg lib) 799865eef222Smrg deplibs="$deplib $deplibs" 7999b312a94cSmrg test conv = "$pass" && continue 800065eef222Smrg newdependency_libs="$deplib $newdependency_libs" 800165eef222Smrg func_stripname '-L' '' "$deplib" 8002200d7199Smrg func_resolve_sysroot "$func_stripname_result" 8003200d7199Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 800465eef222Smrg ;; 800565eef222Smrg prog) 8006b312a94cSmrg if test conv = "$pass"; then 800765eef222Smrg deplibs="$deplib $deplibs" 800865eef222Smrg continue 800965eef222Smrg fi 8010b312a94cSmrg if test scan = "$pass"; then 801165eef222Smrg deplibs="$deplib $deplibs" 801265eef222Smrg else 801365eef222Smrg compile_deplibs="$deplib $compile_deplibs" 801465eef222Smrg finalize_deplibs="$deplib $finalize_deplibs" 801565eef222Smrg fi 801665eef222Smrg func_stripname '-L' '' "$deplib" 8017200d7199Smrg func_resolve_sysroot "$func_stripname_result" 8018200d7199Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 801965eef222Smrg ;; 802065eef222Smrg *) 8021b312a94cSmrg func_warning "'-L' is ignored for archives/objects" 802265eef222Smrg ;; 802365eef222Smrg esac # linkmode 802465eef222Smrg continue 802565eef222Smrg ;; # -L 802665eef222Smrg -R*) 8027b312a94cSmrg if test link = "$pass"; then 802865eef222Smrg func_stripname '-R' '' "$deplib" 8029200d7199Smrg func_resolve_sysroot "$func_stripname_result" 8030200d7199Smrg dir=$func_resolve_sysroot_result 803165eef222Smrg # Make sure the xrpath contains only unique directories. 803265eef222Smrg case "$xrpath " in 803365eef222Smrg *" $dir "*) ;; 8034200d7199Smrg *) func_append xrpath " $dir" ;; 803565eef222Smrg esac 803665eef222Smrg fi 803765eef222Smrg deplibs="$deplib $deplibs" 803865eef222Smrg continue 803965eef222Smrg ;; 8040200d7199Smrg *.la) 8041200d7199Smrg func_resolve_sysroot "$deplib" 8042200d7199Smrg lib=$func_resolve_sysroot_result 8043200d7199Smrg ;; 804465eef222Smrg *.$libext) 8045b312a94cSmrg if test conv = "$pass"; then 804665eef222Smrg deplibs="$deplib $deplibs" 804765eef222Smrg continue 804865eef222Smrg fi 804965eef222Smrg case $linkmode in 805065eef222Smrg lib) 805165eef222Smrg # Linking convenience modules into shared libraries is allowed, 805265eef222Smrg # but linking other static libraries is non-portable. 805365eef222Smrg case " $dlpreconveniencelibs " in 805465eef222Smrg *" $deplib "*) ;; 805565eef222Smrg *) 8056b312a94cSmrg valid_a_lib=false 805765eef222Smrg case $deplibs_check_method in 805865eef222Smrg match_pattern*) 805965eef222Smrg set dummy $deplibs_check_method; shift 806065eef222Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 806156957a04Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 806265eef222Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 8063b312a94cSmrg valid_a_lib=: 806465eef222Smrg fi 806565eef222Smrg ;; 806665eef222Smrg pass_all) 8067b312a94cSmrg valid_a_lib=: 806865eef222Smrg ;; 806965eef222Smrg esac 8070b312a94cSmrg if $valid_a_lib; then 8071b312a94cSmrg echo 8072b312a94cSmrg $ECHO "*** Warning: Linking the shared library $output against the" 8073b312a94cSmrg $ECHO "*** static library $deplib is not portable!" 8074b312a94cSmrg deplibs="$deplib $deplibs" 8075b312a94cSmrg else 807656957a04Smrg echo 807765eef222Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 807856957a04Smrg echo "*** I have the capability to make that library automatically link in when" 807956957a04Smrg echo "*** you link to this library. But I can only do this if you have a" 808056957a04Smrg echo "*** shared version of the library, which you do not appear to have" 808156957a04Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 808256957a04Smrg echo "*** that it is just a static archive that I should not use here." 808365eef222Smrg fi 808465eef222Smrg ;; 808565eef222Smrg esac 808665eef222Smrg continue 808765eef222Smrg ;; 808865eef222Smrg prog) 8089b312a94cSmrg if test link != "$pass"; then 809065eef222Smrg deplibs="$deplib $deplibs" 809165eef222Smrg else 809265eef222Smrg compile_deplibs="$deplib $compile_deplibs" 809365eef222Smrg finalize_deplibs="$deplib $finalize_deplibs" 809465eef222Smrg fi 809565eef222Smrg continue 809665eef222Smrg ;; 809765eef222Smrg esac # linkmode 809865eef222Smrg ;; # *.$libext 809965eef222Smrg *.lo | *.$objext) 8100b312a94cSmrg if test conv = "$pass"; then 810165eef222Smrg deplibs="$deplib $deplibs" 8102b312a94cSmrg elif test prog = "$linkmode"; then 8103b312a94cSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 810465eef222Smrg # If there is no dlopen support or we're linking statically, 810565eef222Smrg # we need to preload. 8106200d7199Smrg func_append newdlprefiles " $deplib" 810765eef222Smrg compile_deplibs="$deplib $compile_deplibs" 810865eef222Smrg finalize_deplibs="$deplib $finalize_deplibs" 810965eef222Smrg else 8110200d7199Smrg func_append newdlfiles " $deplib" 811165eef222Smrg fi 811265eef222Smrg fi 811365eef222Smrg continue 811465eef222Smrg ;; 811565eef222Smrg %DEPLIBS%) 8116b312a94cSmrg alldeplibs=: 811765eef222Smrg continue 811865eef222Smrg ;; 811965eef222Smrg esac # case $deplib 812065eef222Smrg 8121b312a94cSmrg $found || test -f "$lib" \ 8122b312a94cSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 812365eef222Smrg 812465eef222Smrg # Check to see that this really is a libtool archive. 812565eef222Smrg func_lalib_unsafe_p "$lib" \ 8126b312a94cSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 812765eef222Smrg 812865eef222Smrg func_dirname "$lib" "" "." 8129b312a94cSmrg ladir=$func_dirname_result 813065eef222Smrg 813165eef222Smrg dlname= 813265eef222Smrg dlopen= 813365eef222Smrg dlpreopen= 813465eef222Smrg libdir= 813565eef222Smrg library_names= 813665eef222Smrg old_library= 813765eef222Smrg inherited_linker_flags= 813865eef222Smrg # If the library was installed with an old release of libtool, 813965eef222Smrg # it will not redefine variables installed, or shouldnotlink 814065eef222Smrg installed=yes 814165eef222Smrg shouldnotlink=no 814265eef222Smrg avoidtemprpath= 814365eef222Smrg 814465eef222Smrg 814565eef222Smrg # Read the .la file 814665eef222Smrg func_source "$lib" 814765eef222Smrg 814865eef222Smrg # Convert "-framework foo" to "foo.ltframework" 814965eef222Smrg if test -n "$inherited_linker_flags"; then 815056957a04Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 815165eef222Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 815265eef222Smrg case " $new_inherited_linker_flags " in 815365eef222Smrg *" $tmp_inherited_linker_flag "*) ;; 8154200d7199Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 815565eef222Smrg esac 815665eef222Smrg done 815765eef222Smrg fi 815856957a04Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8159b312a94cSmrg if test lib,link = "$linkmode,$pass" || 8160b312a94cSmrg test prog,scan = "$linkmode,$pass" || 8161b312a94cSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 8162200d7199Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 8163200d7199Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 816465eef222Smrg fi 816565eef222Smrg 8166b312a94cSmrg if test conv = "$pass"; then 816765eef222Smrg # Only check for convenience libraries 816865eef222Smrg deplibs="$lib $deplibs" 816965eef222Smrg if test -z "$libdir"; then 817065eef222Smrg if test -z "$old_library"; then 8171b312a94cSmrg func_fatal_error "cannot find name of link library for '$lib'" 817265eef222Smrg fi 817365eef222Smrg # It is a libtool convenience library, so add in its objects. 8174200d7199Smrg func_append convenience " $ladir/$objdir/$old_library" 8175200d7199Smrg func_append old_convenience " $ladir/$objdir/$old_library" 8176b312a94cSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 8177b312a94cSmrg func_fatal_error "'$lib' is not a convenience library" 817865eef222Smrg fi 817965eef222Smrg tmp_libs= 818065eef222Smrg for deplib in $dependency_libs; do 818165eef222Smrg deplibs="$deplib $deplibs" 8182b312a94cSmrg if $opt_preserve_dup_deps; then 818365eef222Smrg case "$tmp_libs " in 8184200d7199Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 818565eef222Smrg esac 818665eef222Smrg fi 8187200d7199Smrg func_append tmp_libs " $deplib" 818865eef222Smrg done 818965eef222Smrg continue 819065eef222Smrg fi # $pass = conv 819165eef222Smrg 819265eef222Smrg 819365eef222Smrg # Get the name of the library we link against. 819465eef222Smrg linklib= 8195200d7199Smrg if test -n "$old_library" && 8196b312a94cSmrg { test yes = "$prefer_static_libs" || 8197b312a94cSmrg test built,no = "$prefer_static_libs,$installed"; }; then 8198200d7199Smrg linklib=$old_library 8199200d7199Smrg else 8200200d7199Smrg for l in $old_library $library_names; do 8201b312a94cSmrg linklib=$l 8202200d7199Smrg done 8203200d7199Smrg fi 820465eef222Smrg if test -z "$linklib"; then 8205b312a94cSmrg func_fatal_error "cannot find name of link library for '$lib'" 820665eef222Smrg fi 820765eef222Smrg 820865eef222Smrg # This library was specified with -dlopen. 8209b312a94cSmrg if test dlopen = "$pass"; then 8210b312a94cSmrg test -z "$libdir" \ 8211b312a94cSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 821265eef222Smrg if test -z "$dlname" || 8213b312a94cSmrg test yes != "$dlopen_support" || 8214b312a94cSmrg test no = "$build_libtool_libs" 8215b312a94cSmrg then 821665eef222Smrg # If there is no dlname, no dlopen support or we're linking 821765eef222Smrg # statically, we need to preload. We also need to preload any 821865eef222Smrg # dependent libraries so libltdl's deplib preloader doesn't 821965eef222Smrg # bomb out in the load deplibs phase. 8220200d7199Smrg func_append dlprefiles " $lib $dependency_libs" 822165eef222Smrg else 8222200d7199Smrg func_append newdlfiles " $lib" 822365eef222Smrg fi 822465eef222Smrg continue 822565eef222Smrg fi # $pass = dlopen 822665eef222Smrg 822765eef222Smrg # We need an absolute path. 822865eef222Smrg case $ladir in 8229b312a94cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 823065eef222Smrg *) 823165eef222Smrg abs_ladir=`cd "$ladir" && pwd` 823265eef222Smrg if test -z "$abs_ladir"; then 8233b312a94cSmrg func_warning "cannot determine absolute directory name of '$ladir'" 823465eef222Smrg func_warning "passing it literally to the linker, although it might fail" 8235b312a94cSmrg abs_ladir=$ladir 823665eef222Smrg fi 823765eef222Smrg ;; 823865eef222Smrg esac 823965eef222Smrg func_basename "$lib" 8240b312a94cSmrg laname=$func_basename_result 824165eef222Smrg 824265eef222Smrg # Find the relevant object directory and library name. 8243b312a94cSmrg if test yes = "$installed"; then 8244200d7199Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8245b312a94cSmrg func_warning "library '$lib' was moved." 8246b312a94cSmrg dir=$ladir 8247b312a94cSmrg absdir=$abs_ladir 8248b312a94cSmrg libdir=$abs_ladir 824965eef222Smrg else 8250b312a94cSmrg dir=$lt_sysroot$libdir 8251b312a94cSmrg absdir=$lt_sysroot$libdir 825265eef222Smrg fi 8253b312a94cSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 825465eef222Smrg else 825565eef222Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8256b312a94cSmrg dir=$ladir 8257b312a94cSmrg absdir=$abs_ladir 825865eef222Smrg # Remove this search path later 8259200d7199Smrg func_append notinst_path " $abs_ladir" 826065eef222Smrg else 8261b312a94cSmrg dir=$ladir/$objdir 8262b312a94cSmrg absdir=$abs_ladir/$objdir 826365eef222Smrg # Remove this search path later 8264200d7199Smrg func_append notinst_path " $abs_ladir" 826565eef222Smrg fi 826665eef222Smrg fi # $installed = yes 826765eef222Smrg func_stripname 'lib' '.la' "$laname" 826865eef222Smrg name=$func_stripname_result 826965eef222Smrg 827065eef222Smrg # This library was specified with -dlpreopen. 8271b312a94cSmrg if test dlpreopen = "$pass"; then 8272b312a94cSmrg if test -z "$libdir" && test prog = "$linkmode"; then 8273b312a94cSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 827465eef222Smrg fi 8275b312a94cSmrg case $host in 8276200d7199Smrg # special handling for platforms with PE-DLLs. 8277200d7199Smrg *cygwin* | *mingw* | *cegcc* ) 8278200d7199Smrg # Linker will automatically link against shared library if both 8279200d7199Smrg # static and shared are present. Therefore, ensure we extract 8280200d7199Smrg # symbols from the import library if a shared library is present 8281200d7199Smrg # (otherwise, the dlopen module name will be incorrect). We do 8282200d7199Smrg # this by putting the import library name into $newdlprefiles. 8283200d7199Smrg # We recover the dlopen module name by 'saving' the la file 8284200d7199Smrg # name in a special purpose variable, and (later) extracting the 8285200d7199Smrg # dlname from the la file. 8286200d7199Smrg if test -n "$dlname"; then 8287200d7199Smrg func_tr_sh "$dir/$linklib" 8288200d7199Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8289200d7199Smrg func_append newdlprefiles " $dir/$linklib" 8290200d7199Smrg else 8291200d7199Smrg func_append newdlprefiles " $dir/$old_library" 8292200d7199Smrg # Keep a list of preopened convenience libraries to check 8293200d7199Smrg # that they are being used correctly in the link pass. 8294200d7199Smrg test -z "$libdir" && \ 8295200d7199Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8296200d7199Smrg fi 8297200d7199Smrg ;; 8298200d7199Smrg * ) 8299200d7199Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8300200d7199Smrg # are required to link). 8301200d7199Smrg if test -n "$old_library"; then 8302200d7199Smrg func_append newdlprefiles " $dir/$old_library" 8303200d7199Smrg # Keep a list of preopened convenience libraries to check 8304200d7199Smrg # that they are being used correctly in the link pass. 8305200d7199Smrg test -z "$libdir" && \ 8306200d7199Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8307200d7199Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8308200d7199Smrg elif test -n "$dlname"; then 8309200d7199Smrg func_append newdlprefiles " $dir/$dlname" 8310200d7199Smrg else 8311200d7199Smrg func_append newdlprefiles " $dir/$linklib" 8312200d7199Smrg fi 8313200d7199Smrg ;; 8314200d7199Smrg esac 831565eef222Smrg fi # $pass = dlpreopen 831665eef222Smrg 831765eef222Smrg if test -z "$libdir"; then 831865eef222Smrg # Link the convenience library 8319b312a94cSmrg if test lib = "$linkmode"; then 832065eef222Smrg deplibs="$dir/$old_library $deplibs" 8321b312a94cSmrg elif test prog,link = "$linkmode,$pass"; then 832265eef222Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 832365eef222Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 832465eef222Smrg else 832565eef222Smrg deplibs="$lib $deplibs" # used for prog,scan pass 832665eef222Smrg fi 832765eef222Smrg continue 832865eef222Smrg fi 832965eef222Smrg 833065eef222Smrg 8331b312a94cSmrg if test prog = "$linkmode" && test link != "$pass"; then 8332200d7199Smrg func_append newlib_search_path " $ladir" 833365eef222Smrg deplibs="$lib $deplibs" 833465eef222Smrg 8335b312a94cSmrg linkalldeplibs=false 8336b312a94cSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 8337b312a94cSmrg test no = "$build_libtool_libs"; then 8338b312a94cSmrg linkalldeplibs=: 833965eef222Smrg fi 834065eef222Smrg 834165eef222Smrg tmp_libs= 834265eef222Smrg for deplib in $dependency_libs; do 834365eef222Smrg case $deplib in 834465eef222Smrg -L*) func_stripname '-L' '' "$deplib" 8345200d7199Smrg func_resolve_sysroot "$func_stripname_result" 8346200d7199Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 834765eef222Smrg ;; 834865eef222Smrg esac 834965eef222Smrg # Need to link against all dependency_libs? 8350b312a94cSmrg if $linkalldeplibs; then 835165eef222Smrg deplibs="$deplib $deplibs" 835265eef222Smrg else 835365eef222Smrg # Need to hardcode shared library paths 835465eef222Smrg # or/and link against static libraries 835565eef222Smrg newdependency_libs="$deplib $newdependency_libs" 835665eef222Smrg fi 8357b312a94cSmrg if $opt_preserve_dup_deps; then 835865eef222Smrg case "$tmp_libs " in 8359200d7199Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 836065eef222Smrg esac 836165eef222Smrg fi 8362200d7199Smrg func_append tmp_libs " $deplib" 836365eef222Smrg done # for deplib 836465eef222Smrg continue 836565eef222Smrg fi # $linkmode = prog... 836665eef222Smrg 8367b312a94cSmrg if test prog,link = "$linkmode,$pass"; then 836865eef222Smrg if test -n "$library_names" && 8369b312a94cSmrg { { test no = "$prefer_static_libs" || 8370b312a94cSmrg test built,yes = "$prefer_static_libs,$installed"; } || 837165eef222Smrg test -z "$old_library"; }; then 837265eef222Smrg # We need to hardcode the library path 8373b312a94cSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 837465eef222Smrg # Make sure the rpath contains only unique directories. 8375b312a94cSmrg case $temp_rpath: in 837665eef222Smrg *"$absdir:"*) ;; 8377200d7199Smrg *) func_append temp_rpath "$absdir:" ;; 837865eef222Smrg esac 837965eef222Smrg fi 838065eef222Smrg 838165eef222Smrg # Hardcode the library path. 838265eef222Smrg # Skip directories that are in the system default run-time 838365eef222Smrg # search path. 838465eef222Smrg case " $sys_lib_dlsearch_path " in 838565eef222Smrg *" $absdir "*) ;; 838665eef222Smrg *) 838765eef222Smrg case "$compile_rpath " in 838865eef222Smrg *" $absdir "*) ;; 8389200d7199Smrg *) func_append compile_rpath " $absdir" ;; 839065eef222Smrg esac 839165eef222Smrg ;; 839265eef222Smrg esac 839365eef222Smrg case " $sys_lib_dlsearch_path " in 839465eef222Smrg *" $libdir "*) ;; 839565eef222Smrg *) 839665eef222Smrg case "$finalize_rpath " in 839765eef222Smrg *" $libdir "*) ;; 8398200d7199Smrg *) func_append finalize_rpath " $libdir" ;; 839965eef222Smrg esac 840065eef222Smrg ;; 840165eef222Smrg esac 840265eef222Smrg fi # $linkmode,$pass = prog,link... 840365eef222Smrg 8404b312a94cSmrg if $alldeplibs && 8405b312a94cSmrg { test pass_all = "$deplibs_check_method" || 8406b312a94cSmrg { test yes = "$build_libtool_libs" && 840765eef222Smrg test -n "$library_names"; }; }; then 840865eef222Smrg # We only need to search for static libraries 840965eef222Smrg continue 841065eef222Smrg fi 841165eef222Smrg fi 841265eef222Smrg 841365eef222Smrg link_static=no # Whether the deplib will be linked statically 841465eef222Smrg use_static_libs=$prefer_static_libs 8415b312a94cSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 841665eef222Smrg use_static_libs=no 841765eef222Smrg fi 841865eef222Smrg if test -n "$library_names" && 8419b312a94cSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 842065eef222Smrg case $host in 8421b312a94cSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 842265eef222Smrg # No point in relinking DLLs because paths are not encoded 8423200d7199Smrg func_append notinst_deplibs " $lib" 842465eef222Smrg need_relink=no 842565eef222Smrg ;; 842665eef222Smrg *) 8427b312a94cSmrg if test no = "$installed"; then 8428200d7199Smrg func_append notinst_deplibs " $lib" 842965eef222Smrg need_relink=yes 843065eef222Smrg fi 843165eef222Smrg ;; 843265eef222Smrg esac 843365eef222Smrg # This is a shared library 843465eef222Smrg 843565eef222Smrg # Warn about portability, can't link against -module's on some 843665eef222Smrg # systems (darwin). Don't bleat about dlopened modules though! 8437b312a94cSmrg dlopenmodule= 843865eef222Smrg for dlpremoduletest in $dlprefiles; do 843965eef222Smrg if test "X$dlpremoduletest" = "X$lib"; then 8440b312a94cSmrg dlopenmodule=$dlpremoduletest 844165eef222Smrg break 844265eef222Smrg fi 844365eef222Smrg done 8444b312a94cSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 844556957a04Smrg echo 8446b312a94cSmrg if test prog = "$linkmode"; then 844765eef222Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 844865eef222Smrg else 844965eef222Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 845065eef222Smrg fi 845165eef222Smrg $ECHO "*** $linklib is not portable!" 845265eef222Smrg fi 8453b312a94cSmrg if test lib = "$linkmode" && 8454b312a94cSmrg test yes = "$hardcode_into_libs"; then 845565eef222Smrg # Hardcode the library path. 845665eef222Smrg # Skip directories that are in the system default run-time 845765eef222Smrg # search path. 845865eef222Smrg case " $sys_lib_dlsearch_path " in 845965eef222Smrg *" $absdir "*) ;; 846065eef222Smrg *) 846165eef222Smrg case "$compile_rpath " in 846265eef222Smrg *" $absdir "*) ;; 8463200d7199Smrg *) func_append compile_rpath " $absdir" ;; 846465eef222Smrg esac 846565eef222Smrg ;; 846665eef222Smrg esac 846765eef222Smrg case " $sys_lib_dlsearch_path " in 846865eef222Smrg *" $libdir "*) ;; 846965eef222Smrg *) 847065eef222Smrg case "$finalize_rpath " in 847165eef222Smrg *" $libdir "*) ;; 8472200d7199Smrg *) func_append finalize_rpath " $libdir" ;; 847365eef222Smrg esac 847465eef222Smrg ;; 847565eef222Smrg esac 847665eef222Smrg fi 847765eef222Smrg 847865eef222Smrg if test -n "$old_archive_from_expsyms_cmds"; then 847965eef222Smrg # figure out the soname 848065eef222Smrg set dummy $library_names 848165eef222Smrg shift 8482b312a94cSmrg realname=$1 848365eef222Smrg shift 848465eef222Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 848565eef222Smrg # use dlname if we got it. it's perfectly good, no? 848665eef222Smrg if test -n "$dlname"; then 8487b312a94cSmrg soname=$dlname 848865eef222Smrg elif test -n "$soname_spec"; then 848965eef222Smrg # bleh windows 849065eef222Smrg case $host in 8491b312a94cSmrg *cygwin* | mingw* | *cegcc* | *os2*) 849265eef222Smrg func_arith $current - $age 849365eef222Smrg major=$func_arith_result 8494b312a94cSmrg versuffix=-$major 849565eef222Smrg ;; 849665eef222Smrg esac 849765eef222Smrg eval soname=\"$soname_spec\" 849865eef222Smrg else 8499b312a94cSmrg soname=$realname 850065eef222Smrg fi 850165eef222Smrg 850265eef222Smrg # Make a new name for the extract_expsyms_cmds to use 8503b312a94cSmrg soroot=$soname 850465eef222Smrg func_basename "$soroot" 8505b312a94cSmrg soname=$func_basename_result 850665eef222Smrg func_stripname 'lib' '.dll' "$soname" 850765eef222Smrg newlib=libimp-$func_stripname_result.a 850865eef222Smrg 850965eef222Smrg # If the library has no export list, then create one now 851065eef222Smrg if test -f "$output_objdir/$soname-def"; then : 851165eef222Smrg else 8512b312a94cSmrg func_verbose "extracting exported symbol list from '$soname'" 851365eef222Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 851465eef222Smrg fi 851565eef222Smrg 851665eef222Smrg # Create $newlib 851765eef222Smrg if test -f "$output_objdir/$newlib"; then :; else 8518b312a94cSmrg func_verbose "generating import library for '$soname'" 851965eef222Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 852065eef222Smrg fi 852165eef222Smrg # make sure the library variables are pointing to the new library 852265eef222Smrg dir=$output_objdir 852365eef222Smrg linklib=$newlib 852465eef222Smrg fi # test -n "$old_archive_from_expsyms_cmds" 852565eef222Smrg 8526b312a94cSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 852765eef222Smrg add_shlibpath= 852865eef222Smrg add_dir= 852965eef222Smrg add= 853065eef222Smrg lib_linked=yes 853165eef222Smrg case $hardcode_action in 853265eef222Smrg immediate | unsupported) 8533b312a94cSmrg if test no = "$hardcode_direct"; then 8534b312a94cSmrg add=$dir/$linklib 853565eef222Smrg case $host in 8536b312a94cSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8537b312a94cSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 853865eef222Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8539b312a94cSmrg *-*-unixware7*) add_dir=-L$dir ;; 854065eef222Smrg *-*-darwin* ) 8541b312a94cSmrg # if the lib is a (non-dlopened) module then we cannot 854265eef222Smrg # link against it, someone is ignoring the earlier warnings 854365eef222Smrg if /usr/bin/file -L $add 2> /dev/null | 8544b312a94cSmrg $GREP ": [^:]* bundle" >/dev/null; then 854565eef222Smrg if test "X$dlopenmodule" != "X$lib"; then 854665eef222Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8547b312a94cSmrg if test -z "$old_library"; then 854856957a04Smrg echo 854956957a04Smrg echo "*** And there doesn't seem to be a static archive available" 855056957a04Smrg echo "*** The link will probably fail, sorry" 855165eef222Smrg else 8552b312a94cSmrg add=$dir/$old_library 855365eef222Smrg fi 855465eef222Smrg elif test -n "$old_library"; then 8555b312a94cSmrg add=$dir/$old_library 855665eef222Smrg fi 855765eef222Smrg fi 855865eef222Smrg esac 8559b312a94cSmrg elif test no = "$hardcode_minus_L"; then 856065eef222Smrg case $host in 8561b312a94cSmrg *-*-sunos*) add_shlibpath=$dir ;; 856265eef222Smrg esac 8563b312a94cSmrg add_dir=-L$dir 8564b312a94cSmrg add=-l$name 8565b312a94cSmrg elif test no = "$hardcode_shlibpath_var"; then 8566b312a94cSmrg add_shlibpath=$dir 8567b312a94cSmrg add=-l$name 856865eef222Smrg else 856965eef222Smrg lib_linked=no 857065eef222Smrg fi 857165eef222Smrg ;; 857265eef222Smrg relink) 8573b312a94cSmrg if test yes = "$hardcode_direct" && 8574b312a94cSmrg test no = "$hardcode_direct_absolute"; then 8575b312a94cSmrg add=$dir/$linklib 8576b312a94cSmrg elif test yes = "$hardcode_minus_L"; then 8577b312a94cSmrg add_dir=-L$absdir 857865eef222Smrg # Try looking first in the location we're being installed to. 857965eef222Smrg if test -n "$inst_prefix_dir"; then 858065eef222Smrg case $libdir in 858165eef222Smrg [\\/]*) 8582200d7199Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 858365eef222Smrg ;; 858465eef222Smrg esac 858565eef222Smrg fi 8586b312a94cSmrg add=-l$name 8587b312a94cSmrg elif test yes = "$hardcode_shlibpath_var"; then 8588b312a94cSmrg add_shlibpath=$dir 8589b312a94cSmrg add=-l$name 859065eef222Smrg else 859165eef222Smrg lib_linked=no 859265eef222Smrg fi 859365eef222Smrg ;; 859465eef222Smrg *) lib_linked=no ;; 859565eef222Smrg esac 859665eef222Smrg 8597b312a94cSmrg if test yes != "$lib_linked"; then 859865eef222Smrg func_fatal_configuration "unsupported hardcode properties" 859965eef222Smrg fi 860065eef222Smrg 860165eef222Smrg if test -n "$add_shlibpath"; then 860265eef222Smrg case :$compile_shlibpath: in 860365eef222Smrg *":$add_shlibpath:"*) ;; 8604200d7199Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 860565eef222Smrg esac 860665eef222Smrg fi 8607b312a94cSmrg if test prog = "$linkmode"; then 860865eef222Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 860965eef222Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 861065eef222Smrg else 861165eef222Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 861265eef222Smrg test -n "$add" && deplibs="$add $deplibs" 8613b312a94cSmrg if test yes != "$hardcode_direct" && 8614b312a94cSmrg test yes != "$hardcode_minus_L" && 8615b312a94cSmrg test yes = "$hardcode_shlibpath_var"; then 861665eef222Smrg case :$finalize_shlibpath: in 861765eef222Smrg *":$libdir:"*) ;; 8618200d7199Smrg *) func_append finalize_shlibpath "$libdir:" ;; 861965eef222Smrg esac 862065eef222Smrg fi 862165eef222Smrg fi 862265eef222Smrg fi 862365eef222Smrg 8624b312a94cSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 862565eef222Smrg add_shlibpath= 862665eef222Smrg add_dir= 862765eef222Smrg add= 862865eef222Smrg # Finalize command for both is simple: just hardcode it. 8629b312a94cSmrg if test yes = "$hardcode_direct" && 8630b312a94cSmrg test no = "$hardcode_direct_absolute"; then 8631b312a94cSmrg add=$libdir/$linklib 8632b312a94cSmrg elif test yes = "$hardcode_minus_L"; then 8633b312a94cSmrg add_dir=-L$libdir 8634b312a94cSmrg add=-l$name 8635b312a94cSmrg elif test yes = "$hardcode_shlibpath_var"; then 863665eef222Smrg case :$finalize_shlibpath: in 863765eef222Smrg *":$libdir:"*) ;; 8638200d7199Smrg *) func_append finalize_shlibpath "$libdir:" ;; 863965eef222Smrg esac 8640b312a94cSmrg add=-l$name 8641b312a94cSmrg elif test yes = "$hardcode_automatic"; then 864265eef222Smrg if test -n "$inst_prefix_dir" && 8643b312a94cSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 8644b312a94cSmrg add=$inst_prefix_dir$libdir/$linklib 864565eef222Smrg else 8646b312a94cSmrg add=$libdir/$linklib 864765eef222Smrg fi 864865eef222Smrg else 864965eef222Smrg # We cannot seem to hardcode it, guess we'll fake it. 8650b312a94cSmrg add_dir=-L$libdir 865165eef222Smrg # Try looking first in the location we're being installed to. 865265eef222Smrg if test -n "$inst_prefix_dir"; then 865365eef222Smrg case $libdir in 865465eef222Smrg [\\/]*) 8655200d7199Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 865665eef222Smrg ;; 865765eef222Smrg esac 865865eef222Smrg fi 8659b312a94cSmrg add=-l$name 866065eef222Smrg fi 866165eef222Smrg 8662b312a94cSmrg if test prog = "$linkmode"; then 866365eef222Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 866465eef222Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 866565eef222Smrg else 866665eef222Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 866765eef222Smrg test -n "$add" && deplibs="$add $deplibs" 866865eef222Smrg fi 866965eef222Smrg fi 8670b312a94cSmrg elif test prog = "$linkmode"; then 867165eef222Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 867265eef222Smrg # is not unsupported. This is valid on all known static and 867365eef222Smrg # shared platforms. 8674b312a94cSmrg if test unsupported != "$hardcode_direct"; then 8675b312a94cSmrg test -n "$old_library" && linklib=$old_library 867665eef222Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 867765eef222Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 867865eef222Smrg else 867965eef222Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 868065eef222Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 868165eef222Smrg fi 8682b312a94cSmrg elif test yes = "$build_libtool_libs"; then 868365eef222Smrg # Not a shared library 8684b312a94cSmrg if test pass_all != "$deplibs_check_method"; then 868565eef222Smrg # We're trying link a shared library against a static one 868665eef222Smrg # but the system doesn't support it. 868765eef222Smrg 868865eef222Smrg # Just print a warning and add the library to dependency_libs so 868965eef222Smrg # that the program can be linked against the static library. 869056957a04Smrg echo 8691b312a94cSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 869256957a04Smrg echo "*** I have the capability to make that library automatically link in when" 869356957a04Smrg echo "*** you link to this library. But I can only do this if you have a" 869456957a04Smrg echo "*** shared version of the library, which you do not appear to have." 8695b312a94cSmrg if test yes = "$module"; then 869656957a04Smrg echo "*** But as you try to build a module library, libtool will still create " 869756957a04Smrg echo "*** a static module, that should work as long as the dlopening application" 869856957a04Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 869965eef222Smrg if test -z "$global_symbol_pipe"; then 870056957a04Smrg echo 870156957a04Smrg echo "*** However, this would only work if libtool was able to extract symbol" 8702b312a94cSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 870356957a04Smrg echo "*** not find such a program. So, this module is probably useless." 8704b312a94cSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 870565eef222Smrg fi 8706b312a94cSmrg if test no = "$build_old_libs"; then 870765eef222Smrg build_libtool_libs=module 870865eef222Smrg build_old_libs=yes 870965eef222Smrg else 871065eef222Smrg build_libtool_libs=no 871165eef222Smrg fi 871265eef222Smrg fi 871365eef222Smrg else 871465eef222Smrg deplibs="$dir/$old_library $deplibs" 871565eef222Smrg link_static=yes 871665eef222Smrg fi 871765eef222Smrg fi # link shared/static library? 871865eef222Smrg 8719b312a94cSmrg if test lib = "$linkmode"; then 872065eef222Smrg if test -n "$dependency_libs" && 8721b312a94cSmrg { test yes != "$hardcode_into_libs" || 8722b312a94cSmrg test yes = "$build_old_libs" || 8723b312a94cSmrg test yes = "$link_static"; }; then 872465eef222Smrg # Extract -R from dependency_libs 872565eef222Smrg temp_deplibs= 872665eef222Smrg for libdir in $dependency_libs; do 872765eef222Smrg case $libdir in 872865eef222Smrg -R*) func_stripname '-R' '' "$libdir" 872965eef222Smrg temp_xrpath=$func_stripname_result 873065eef222Smrg case " $xrpath " in 873165eef222Smrg *" $temp_xrpath "*) ;; 8732200d7199Smrg *) func_append xrpath " $temp_xrpath";; 873365eef222Smrg esac;; 8734200d7199Smrg *) func_append temp_deplibs " $libdir";; 873565eef222Smrg esac 873665eef222Smrg done 8737b312a94cSmrg dependency_libs=$temp_deplibs 873865eef222Smrg fi 873965eef222Smrg 8740200d7199Smrg func_append newlib_search_path " $absdir" 874165eef222Smrg # Link against this library 8742b312a94cSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 874365eef222Smrg # ... and its dependency_libs 874465eef222Smrg tmp_libs= 874565eef222Smrg for deplib in $dependency_libs; do 874665eef222Smrg newdependency_libs="$deplib $newdependency_libs" 8747200d7199Smrg case $deplib in 8748200d7199Smrg -L*) func_stripname '-L' '' "$deplib" 8749200d7199Smrg func_resolve_sysroot "$func_stripname_result";; 8750200d7199Smrg *) func_resolve_sysroot "$deplib" ;; 8751200d7199Smrg esac 8752b312a94cSmrg if $opt_preserve_dup_deps; then 875365eef222Smrg case "$tmp_libs " in 8754200d7199Smrg *" $func_resolve_sysroot_result "*) 8755200d7199Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 875665eef222Smrg esac 875765eef222Smrg fi 8758200d7199Smrg func_append tmp_libs " $func_resolve_sysroot_result" 875965eef222Smrg done 876065eef222Smrg 8761b312a94cSmrg if test no != "$link_all_deplibs"; then 876265eef222Smrg # Add the search paths of all dependency libraries 876365eef222Smrg for deplib in $dependency_libs; do 876456957a04Smrg path= 876565eef222Smrg case $deplib in 8766b312a94cSmrg -L*) path=$deplib ;; 876765eef222Smrg *.la) 8768200d7199Smrg func_resolve_sysroot "$deplib" 8769200d7199Smrg deplib=$func_resolve_sysroot_result 877065eef222Smrg func_dirname "$deplib" "" "." 8771200d7199Smrg dir=$func_dirname_result 877265eef222Smrg # We need an absolute path. 877365eef222Smrg case $dir in 8774b312a94cSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 877565eef222Smrg *) 877665eef222Smrg absdir=`cd "$dir" && pwd` 877765eef222Smrg if test -z "$absdir"; then 8778b312a94cSmrg func_warning "cannot determine absolute directory name of '$dir'" 8779b312a94cSmrg absdir=$dir 878065eef222Smrg fi 878165eef222Smrg ;; 878265eef222Smrg esac 878365eef222Smrg if $GREP "^installed=no" $deplib > /dev/null; then 878465eef222Smrg case $host in 878565eef222Smrg *-*-darwin*) 878665eef222Smrg depdepl= 8787b312a94cSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8788b312a94cSmrg if test -n "$deplibrary_names"; then 8789b312a94cSmrg for tmp in $deplibrary_names; do 879065eef222Smrg depdepl=$tmp 879165eef222Smrg done 8792b312a94cSmrg if test -f "$absdir/$objdir/$depdepl"; then 8793b312a94cSmrg depdepl=$absdir/$objdir/$depdepl 8794b312a94cSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 879565eef222Smrg if test -z "$darwin_install_name"; then 8796b312a94cSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 879765eef222Smrg fi 8798b312a94cSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8799b312a94cSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 880065eef222Smrg path= 880165eef222Smrg fi 880265eef222Smrg fi 880365eef222Smrg ;; 880465eef222Smrg *) 8805b312a94cSmrg path=-L$absdir/$objdir 880665eef222Smrg ;; 880765eef222Smrg esac 880865eef222Smrg else 8809b312a94cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 881065eef222Smrg test -z "$libdir" && \ 8811b312a94cSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 881265eef222Smrg test "$absdir" != "$libdir" && \ 8813b312a94cSmrg func_warning "'$deplib' seems to be moved" 881465eef222Smrg 8815b312a94cSmrg path=-L$absdir 881665eef222Smrg fi 881765eef222Smrg ;; 881865eef222Smrg esac 881965eef222Smrg case " $deplibs " in 882065eef222Smrg *" $path "*) ;; 882165eef222Smrg *) deplibs="$path $deplibs" ;; 882265eef222Smrg esac 882365eef222Smrg done 882465eef222Smrg fi # link_all_deplibs != no 882565eef222Smrg fi # linkmode = lib 882665eef222Smrg done # for deplib in $libs 8827b312a94cSmrg if test link = "$pass"; then 8828b312a94cSmrg if test prog = "$linkmode"; then 882965eef222Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 883065eef222Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 883165eef222Smrg else 883256957a04Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 883365eef222Smrg fi 883465eef222Smrg fi 8835b312a94cSmrg dependency_libs=$newdependency_libs 8836b312a94cSmrg if test dlpreopen = "$pass"; then 883765eef222Smrg # Link the dlpreopened libraries before other libraries 883865eef222Smrg for deplib in $save_deplibs; do 883965eef222Smrg deplibs="$deplib $deplibs" 884065eef222Smrg done 884165eef222Smrg fi 8842b312a94cSmrg if test dlopen != "$pass"; then 8843b312a94cSmrg test conv = "$pass" || { 884465eef222Smrg # Make sure lib_search_path contains only unique directories. 884565eef222Smrg lib_search_path= 884665eef222Smrg for dir in $newlib_search_path; do 884765eef222Smrg case "$lib_search_path " in 884865eef222Smrg *" $dir "*) ;; 8849200d7199Smrg *) func_append lib_search_path " $dir" ;; 885065eef222Smrg esac 885165eef222Smrg done 885265eef222Smrg newlib_search_path= 8853b312a94cSmrg } 885465eef222Smrg 8855b312a94cSmrg if test prog,link = "$linkmode,$pass"; then 885665eef222Smrg vars="compile_deplibs finalize_deplibs" 8857b312a94cSmrg else 8858b312a94cSmrg vars=deplibs 885965eef222Smrg fi 886065eef222Smrg for var in $vars dependency_libs; do 886165eef222Smrg # Add libraries to $var in reverse order 886265eef222Smrg eval tmp_libs=\"\$$var\" 886365eef222Smrg new_libs= 886465eef222Smrg for deplib in $tmp_libs; do 886565eef222Smrg # FIXME: Pedantically, this is the right thing to do, so 886665eef222Smrg # that some nasty dependency loop isn't accidentally 886765eef222Smrg # broken: 886865eef222Smrg #new_libs="$deplib $new_libs" 886965eef222Smrg # Pragmatically, this seems to cause very few problems in 887065eef222Smrg # practice: 887165eef222Smrg case $deplib in 887265eef222Smrg -L*) new_libs="$deplib $new_libs" ;; 887365eef222Smrg -R*) ;; 887465eef222Smrg *) 887565eef222Smrg # And here is the reason: when a library appears more 887665eef222Smrg # than once as an explicit dependence of a library, or 887765eef222Smrg # is implicitly linked in more than once by the 887865eef222Smrg # compiler, it is considered special, and multiple 887965eef222Smrg # occurrences thereof are not removed. Compare this 888065eef222Smrg # with having the same library being listed as a 888165eef222Smrg # dependency of multiple other libraries: in this case, 888265eef222Smrg # we know (pedantically, we assume) the library does not 888365eef222Smrg # need to be listed more than once, so we keep only the 888465eef222Smrg # last copy. This is not always right, but it is rare 888565eef222Smrg # enough that we require users that really mean to play 888665eef222Smrg # such unportable linking tricks to link the library 888765eef222Smrg # using -Wl,-lname, so that libtool does not consider it 888865eef222Smrg # for duplicate removal. 888965eef222Smrg case " $specialdeplibs " in 889065eef222Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 889165eef222Smrg *) 889265eef222Smrg case " $new_libs " in 889365eef222Smrg *" $deplib "*) ;; 889465eef222Smrg *) new_libs="$deplib $new_libs" ;; 889565eef222Smrg esac 889665eef222Smrg ;; 889765eef222Smrg esac 889865eef222Smrg ;; 889965eef222Smrg esac 890065eef222Smrg done 890165eef222Smrg tmp_libs= 890265eef222Smrg for deplib in $new_libs; do 890365eef222Smrg case $deplib in 890465eef222Smrg -L*) 890565eef222Smrg case " $tmp_libs " in 890665eef222Smrg *" $deplib "*) ;; 8907200d7199Smrg *) func_append tmp_libs " $deplib" ;; 890865eef222Smrg esac 890965eef222Smrg ;; 8910200d7199Smrg *) func_append tmp_libs " $deplib" ;; 891165eef222Smrg esac 891265eef222Smrg done 891365eef222Smrg eval $var=\"$tmp_libs\" 891465eef222Smrg done # for var 891565eef222Smrg fi 8916b312a94cSmrg 8917b312a94cSmrg # Add Sun CC postdeps if required: 8918b312a94cSmrg test CXX = "$tagname" && { 8919b312a94cSmrg case $host_os in 8920b312a94cSmrg linux*) 8921d5637ae9Smrg case `$CC -V 2>&1 | $SED 5q` in 8922b312a94cSmrg *Sun\ C*) # Sun C++ 5.9 8923b312a94cSmrg func_suncc_cstd_abi 8924b312a94cSmrg 8925b312a94cSmrg if test no != "$suncc_use_cstd_abi"; then 8926b312a94cSmrg func_append postdeps ' -library=Cstd -library=Crun' 8927b312a94cSmrg fi 8928b312a94cSmrg ;; 8929b312a94cSmrg esac 8930b312a94cSmrg ;; 8931b312a94cSmrg 8932b312a94cSmrg solaris*) 8933b312a94cSmrg func_cc_basename "$CC" 8934b312a94cSmrg case $func_cc_basename_result in 8935b312a94cSmrg CC* | sunCC*) 8936b312a94cSmrg func_suncc_cstd_abi 8937b312a94cSmrg 8938b312a94cSmrg if test no != "$suncc_use_cstd_abi"; then 8939b312a94cSmrg func_append postdeps ' -library=Cstd -library=Crun' 8940b312a94cSmrg fi 8941b312a94cSmrg ;; 8942b312a94cSmrg esac 8943b312a94cSmrg ;; 8944b312a94cSmrg esac 8945b312a94cSmrg } 8946b312a94cSmrg 894765eef222Smrg # Last step: remove runtime libs from dependency_libs 894865eef222Smrg # (they stay in deplibs) 894965eef222Smrg tmp_libs= 8950b312a94cSmrg for i in $dependency_libs; do 895165eef222Smrg case " $predeps $postdeps $compiler_lib_search_path " in 895265eef222Smrg *" $i "*) 8953b312a94cSmrg i= 895465eef222Smrg ;; 895565eef222Smrg esac 8956b312a94cSmrg if test -n "$i"; then 8957200d7199Smrg func_append tmp_libs " $i" 895865eef222Smrg fi 895965eef222Smrg done 896065eef222Smrg dependency_libs=$tmp_libs 896165eef222Smrg done # for pass 8962b312a94cSmrg if test prog = "$linkmode"; then 8963b312a94cSmrg dlfiles=$newdlfiles 896465eef222Smrg fi 8965b312a94cSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 8966b312a94cSmrg dlprefiles=$newdlprefiles 896765eef222Smrg fi 896865eef222Smrg 896965eef222Smrg case $linkmode in 897065eef222Smrg oldlib) 8971b312a94cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8972b312a94cSmrg func_warning "'-dlopen' is ignored for archives" 897365eef222Smrg fi 897465eef222Smrg 897565eef222Smrg case " $deplibs" in 897665eef222Smrg *\ -l* | *\ -L*) 8977b312a94cSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 897865eef222Smrg esac 897965eef222Smrg 898065eef222Smrg test -n "$rpath" && \ 8981b312a94cSmrg func_warning "'-rpath' is ignored for archives" 898265eef222Smrg 898365eef222Smrg test -n "$xrpath" && \ 8984b312a94cSmrg func_warning "'-R' is ignored for archives" 898565eef222Smrg 898665eef222Smrg test -n "$vinfo" && \ 8987b312a94cSmrg func_warning "'-version-info/-version-number' is ignored for archives" 898865eef222Smrg 898965eef222Smrg test -n "$release" && \ 8990b312a94cSmrg func_warning "'-release' is ignored for archives" 899165eef222Smrg 899265eef222Smrg test -n "$export_symbols$export_symbols_regex" && \ 8993b312a94cSmrg func_warning "'-export-symbols' is ignored for archives" 899465eef222Smrg 899565eef222Smrg # Now set the variables for building old libraries. 899665eef222Smrg build_libtool_libs=no 8997b312a94cSmrg oldlibs=$output 8998200d7199Smrg func_append objs "$old_deplibs" 899965eef222Smrg ;; 900065eef222Smrg 900165eef222Smrg lib) 9002b312a94cSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 900365eef222Smrg case $outputname in 900465eef222Smrg lib*) 900565eef222Smrg func_stripname 'lib' '.la' "$outputname" 900665eef222Smrg name=$func_stripname_result 900765eef222Smrg eval shared_ext=\"$shrext_cmds\" 900865eef222Smrg eval libname=\"$libname_spec\" 900965eef222Smrg ;; 901065eef222Smrg *) 9011b312a94cSmrg test no = "$module" \ 9012b312a94cSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 901365eef222Smrg 9014b312a94cSmrg if test no != "$need_lib_prefix"; then 901565eef222Smrg # Add the "lib" prefix for modules if required 901665eef222Smrg func_stripname '' '.la' "$outputname" 901765eef222Smrg name=$func_stripname_result 901865eef222Smrg eval shared_ext=\"$shrext_cmds\" 901965eef222Smrg eval libname=\"$libname_spec\" 902065eef222Smrg else 902165eef222Smrg func_stripname '' '.la' "$outputname" 902265eef222Smrg libname=$func_stripname_result 902365eef222Smrg fi 902465eef222Smrg ;; 902565eef222Smrg esac 902665eef222Smrg 902765eef222Smrg if test -n "$objs"; then 9028b312a94cSmrg if test pass_all != "$deplibs_check_method"; then 9029b312a94cSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 903065eef222Smrg else 903156957a04Smrg echo 903265eef222Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 903365eef222Smrg $ECHO "*** objects $objs is not portable!" 9034200d7199Smrg func_append libobjs " $objs" 903565eef222Smrg fi 903665eef222Smrg fi 903765eef222Smrg 9038b312a94cSmrg test no = "$dlself" \ 9039b312a94cSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 904065eef222Smrg 904165eef222Smrg set dummy $rpath 904265eef222Smrg shift 9043b312a94cSmrg test 1 -lt "$#" \ 9044b312a94cSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 904565eef222Smrg 9046b312a94cSmrg install_libdir=$1 904765eef222Smrg 904865eef222Smrg oldlibs= 904965eef222Smrg if test -z "$rpath"; then 9050b312a94cSmrg if test yes = "$build_libtool_libs"; then 905165eef222Smrg # Building a libtool convenience library. 9052b312a94cSmrg # Some compilers have problems with a '.al' extension so 905365eef222Smrg # convenience libraries should have the same extension an 905465eef222Smrg # archive normally would. 905565eef222Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 905665eef222Smrg build_libtool_libs=convenience 905765eef222Smrg build_old_libs=yes 905865eef222Smrg fi 905965eef222Smrg 906065eef222Smrg test -n "$vinfo" && \ 9061b312a94cSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 906265eef222Smrg 906365eef222Smrg test -n "$release" && \ 9064b312a94cSmrg func_warning "'-release' is ignored for convenience libraries" 906565eef222Smrg else 906665eef222Smrg 906765eef222Smrg # Parse the version information argument. 9068b312a94cSmrg save_ifs=$IFS; IFS=: 906965eef222Smrg set dummy $vinfo 0 0 0 907065eef222Smrg shift 9071b312a94cSmrg IFS=$save_ifs 907265eef222Smrg 907365eef222Smrg test -n "$7" && \ 9074b312a94cSmrg func_fatal_help "too many parameters to '-version-info'" 907565eef222Smrg 907665eef222Smrg # convert absolute version numbers to libtool ages 907765eef222Smrg # this retains compatibility with .la files and attempts 907865eef222Smrg # to make the code below a bit more comprehensible 907965eef222Smrg 908065eef222Smrg case $vinfo_number in 908165eef222Smrg yes) 9082b312a94cSmrg number_major=$1 9083b312a94cSmrg number_minor=$2 9084b312a94cSmrg number_revision=$3 908565eef222Smrg # 908665eef222Smrg # There are really only two kinds -- those that 908765eef222Smrg # use the current revision as the major version 908865eef222Smrg # and those that subtract age and use age as 908965eef222Smrg # a minor version. But, then there is irix 9090b312a94cSmrg # that has an extra 1 added just for fun 909165eef222Smrg # 909265eef222Smrg case $version_type in 9093b312a94cSmrg # correct linux to gnu/linux during the next big refactor 9094d5637ae9Smrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 909565eef222Smrg func_arith $number_major + $number_minor 909665eef222Smrg current=$func_arith_result 9097b312a94cSmrg age=$number_minor 9098b312a94cSmrg revision=$number_revision 909965eef222Smrg ;; 9100b312a94cSmrg freebsd-aout|qnx|sunos) 9101b312a94cSmrg current=$number_major 9102b312a94cSmrg revision=$number_minor 9103b312a94cSmrg age=0 910465eef222Smrg ;; 910565eef222Smrg irix|nonstopux) 910665eef222Smrg func_arith $number_major + $number_minor 910765eef222Smrg current=$func_arith_result 9108b312a94cSmrg age=$number_minor 9109b312a94cSmrg revision=$number_minor 911065eef222Smrg lt_irix_increment=no 911165eef222Smrg ;; 911265eef222Smrg esac 911365eef222Smrg ;; 911465eef222Smrg no) 9115b312a94cSmrg current=$1 9116b312a94cSmrg revision=$2 9117b312a94cSmrg age=$3 911865eef222Smrg ;; 911965eef222Smrg esac 912065eef222Smrg 912165eef222Smrg # Check that each of the things are valid numbers. 912265eef222Smrg case $current in 912365eef222Smrg 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]) ;; 912465eef222Smrg *) 9125b312a94cSmrg func_error "CURRENT '$current' must be a nonnegative integer" 9126b312a94cSmrg func_fatal_error "'$vinfo' is not valid version information" 912765eef222Smrg ;; 912865eef222Smrg esac 912965eef222Smrg 913065eef222Smrg case $revision in 913165eef222Smrg 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]) ;; 913265eef222Smrg *) 9133b312a94cSmrg func_error "REVISION '$revision' must be a nonnegative integer" 9134b312a94cSmrg func_fatal_error "'$vinfo' is not valid version information" 913565eef222Smrg ;; 913665eef222Smrg esac 913765eef222Smrg 913865eef222Smrg case $age in 913965eef222Smrg 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]) ;; 914065eef222Smrg *) 9141b312a94cSmrg func_error "AGE '$age' must be a nonnegative integer" 9142b312a94cSmrg func_fatal_error "'$vinfo' is not valid version information" 914365eef222Smrg ;; 914465eef222Smrg esac 914565eef222Smrg 914665eef222Smrg if test "$age" -gt "$current"; then 9147b312a94cSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 9148b312a94cSmrg func_fatal_error "'$vinfo' is not valid version information" 914965eef222Smrg fi 915065eef222Smrg 915165eef222Smrg # Calculate the version variables. 915265eef222Smrg major= 915365eef222Smrg versuffix= 915465eef222Smrg verstring= 915565eef222Smrg case $version_type in 915665eef222Smrg none) ;; 915765eef222Smrg 915865eef222Smrg darwin) 915965eef222Smrg # Like Linux, but with the current version available in 916065eef222Smrg # verstring for coding it into the library header 916165eef222Smrg func_arith $current - $age 916265eef222Smrg major=.$func_arith_result 9163b312a94cSmrg versuffix=$major.$age.$revision 916465eef222Smrg # Darwin ld doesn't like 0 for these options... 916565eef222Smrg func_arith $current + 1 916665eef222Smrg minor_current=$func_arith_result 9167b312a94cSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 916865eef222Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9169b312a94cSmrg # On Darwin other compilers 9170b312a94cSmrg case $CC in 9171b312a94cSmrg nagfor*) 9172b312a94cSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9173b312a94cSmrg ;; 9174b312a94cSmrg *) 9175b312a94cSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9176b312a94cSmrg ;; 9177b312a94cSmrg esac 917865eef222Smrg ;; 917965eef222Smrg 918065eef222Smrg freebsd-aout) 9181b312a94cSmrg major=.$current 9182b312a94cSmrg versuffix=.$current.$revision 918365eef222Smrg ;; 918465eef222Smrg 9185d5637ae9Smrg freebsd-elf | midnightbsd-elf) 9186b312a94cSmrg func_arith $current - $age 9187b312a94cSmrg major=.$func_arith_result 9188b312a94cSmrg versuffix=$major.$age.$revision 918965eef222Smrg ;; 919065eef222Smrg 919165eef222Smrg irix | nonstopux) 9192b312a94cSmrg if test no = "$lt_irix_increment"; then 919365eef222Smrg func_arith $current - $age 919465eef222Smrg else 919565eef222Smrg func_arith $current - $age + 1 919665eef222Smrg fi 919765eef222Smrg major=$func_arith_result 919865eef222Smrg 919965eef222Smrg case $version_type in 920065eef222Smrg nonstopux) verstring_prefix=nonstopux ;; 920165eef222Smrg *) verstring_prefix=sgi ;; 920265eef222Smrg esac 9203b312a94cSmrg verstring=$verstring_prefix$major.$revision 920465eef222Smrg 920565eef222Smrg # Add in all the interfaces that we are compatible with. 920665eef222Smrg loop=$revision 9207b312a94cSmrg while test 0 -ne "$loop"; do 920865eef222Smrg func_arith $revision - $loop 920965eef222Smrg iface=$func_arith_result 921065eef222Smrg func_arith $loop - 1 921165eef222Smrg loop=$func_arith_result 9212b312a94cSmrg verstring=$verstring_prefix$major.$iface:$verstring 921365eef222Smrg done 921465eef222Smrg 9215b312a94cSmrg # Before this point, $major must not contain '.'. 921665eef222Smrg major=.$major 9217b312a94cSmrg versuffix=$major.$revision 921865eef222Smrg ;; 921965eef222Smrg 9220b312a94cSmrg linux) # correct to gnu/linux during the next big refactor 922165eef222Smrg func_arith $current - $age 922265eef222Smrg major=.$func_arith_result 9223b312a94cSmrg versuffix=$major.$age.$revision 922465eef222Smrg ;; 922565eef222Smrg 922665eef222Smrg osf) 922765eef222Smrg func_arith $current - $age 922865eef222Smrg major=.$func_arith_result 9229b312a94cSmrg versuffix=.$current.$age.$revision 9230b312a94cSmrg verstring=$current.$age.$revision 923165eef222Smrg 923265eef222Smrg # Add in all the interfaces that we are compatible with. 923365eef222Smrg loop=$age 9234b312a94cSmrg while test 0 -ne "$loop"; do 923565eef222Smrg func_arith $current - $loop 923665eef222Smrg iface=$func_arith_result 923765eef222Smrg func_arith $loop - 1 923865eef222Smrg loop=$func_arith_result 9239b312a94cSmrg verstring=$verstring:$iface.0 924065eef222Smrg done 924165eef222Smrg 924265eef222Smrg # Make executables depend on our current version. 9243b312a94cSmrg func_append verstring ":$current.0" 924465eef222Smrg ;; 924565eef222Smrg 924665eef222Smrg qnx) 9247b312a94cSmrg major=.$current 9248b312a94cSmrg versuffix=.$current 9249b312a94cSmrg ;; 9250b312a94cSmrg 9251b312a94cSmrg sco) 9252b312a94cSmrg major=.$current 9253b312a94cSmrg versuffix=.$current 925465eef222Smrg ;; 925565eef222Smrg 925665eef222Smrg sunos) 9257b312a94cSmrg major=.$current 9258b312a94cSmrg versuffix=.$current.$revision 925965eef222Smrg ;; 926065eef222Smrg 926165eef222Smrg windows) 926265eef222Smrg # Use '-' rather than '.', since we only want one 9263b312a94cSmrg # extension on DOS 8.3 file systems. 926465eef222Smrg func_arith $current - $age 926565eef222Smrg major=$func_arith_result 9266b312a94cSmrg versuffix=-$major 926765eef222Smrg ;; 926865eef222Smrg 926965eef222Smrg *) 9270b312a94cSmrg func_fatal_configuration "unknown library version type '$version_type'" 927165eef222Smrg ;; 927265eef222Smrg esac 927365eef222Smrg 927465eef222Smrg # Clear the version info if we defaulted, and they specified a release. 927565eef222Smrg if test -z "$vinfo" && test -n "$release"; then 927665eef222Smrg major= 927765eef222Smrg case $version_type in 927865eef222Smrg darwin) 927965eef222Smrg # we can't check for "0.0" in archive_cmds due to quoting 928065eef222Smrg # problems, so we reset it completely 928165eef222Smrg verstring= 928265eef222Smrg ;; 928365eef222Smrg *) 9284b312a94cSmrg verstring=0.0 928565eef222Smrg ;; 928665eef222Smrg esac 9287b312a94cSmrg if test no = "$need_version"; then 928865eef222Smrg versuffix= 928965eef222Smrg else 9290b312a94cSmrg versuffix=.0.0 929165eef222Smrg fi 929265eef222Smrg fi 929365eef222Smrg 929465eef222Smrg # Remove version info from name if versioning should be avoided 9295b312a94cSmrg if test yes,no = "$avoid_version,$need_version"; then 929665eef222Smrg major= 929765eef222Smrg versuffix= 9298b312a94cSmrg verstring= 929965eef222Smrg fi 930065eef222Smrg 930165eef222Smrg # Check to see if the archive will have undefined symbols. 9302b312a94cSmrg if test yes = "$allow_undefined"; then 9303b312a94cSmrg if test unsupported = "$allow_undefined_flag"; then 9304b312a94cSmrg if test yes = "$build_old_libs"; then 9305b312a94cSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9306b312a94cSmrg build_libtool_libs=no 9307b312a94cSmrg else 9308b312a94cSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9309b312a94cSmrg fi 931065eef222Smrg fi 931165eef222Smrg else 931265eef222Smrg # Don't allow undefined symbols. 9313b312a94cSmrg allow_undefined_flag=$no_undefined_flag 931465eef222Smrg fi 931565eef222Smrg 931665eef222Smrg fi 931765eef222Smrg 9318b312a94cSmrg func_generate_dlsyms "$libname" "$libname" : 9319200d7199Smrg func_append libobjs " $symfileobj" 9320b312a94cSmrg test " " = "$libobjs" && libobjs= 932165eef222Smrg 9322b312a94cSmrg if test relink != "$opt_mode"; then 932365eef222Smrg # Remove our outputs, but don't remove object files since they 932465eef222Smrg # may have been created when compiling PIC objects. 932565eef222Smrg removelist= 932665eef222Smrg tempremovelist=`$ECHO "$output_objdir/*"` 932765eef222Smrg for p in $tempremovelist; do 932865eef222Smrg case $p in 932965eef222Smrg *.$objext | *.gcno) 933065eef222Smrg ;; 9331b312a94cSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9332b312a94cSmrg if test -n "$precious_files_regex"; then 933365eef222Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 933465eef222Smrg then 933565eef222Smrg continue 933665eef222Smrg fi 933765eef222Smrg fi 9338200d7199Smrg func_append removelist " $p" 933965eef222Smrg ;; 934065eef222Smrg *) ;; 934165eef222Smrg esac 934265eef222Smrg done 934365eef222Smrg test -n "$removelist" && \ 934465eef222Smrg func_show_eval "${RM}r \$removelist" 934565eef222Smrg fi 934665eef222Smrg 934765eef222Smrg # Now set the variables for building old libraries. 9348b312a94cSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9349200d7199Smrg func_append oldlibs " $output_objdir/$libname.$libext" 935065eef222Smrg 935165eef222Smrg # Transform .lo files to .o files. 9352b312a94cSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 935365eef222Smrg fi 935465eef222Smrg 935565eef222Smrg # Eliminate all temporary directories. 935665eef222Smrg #for path in $notinst_path; do 935756957a04Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 935856957a04Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 935956957a04Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 936065eef222Smrg #done 936165eef222Smrg 936265eef222Smrg if test -n "$xrpath"; then 936365eef222Smrg # If the user specified any rpath flags, then add them. 936465eef222Smrg temp_xrpath= 936565eef222Smrg for libdir in $xrpath; do 9366200d7199Smrg func_replace_sysroot "$libdir" 9367200d7199Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 936865eef222Smrg case "$finalize_rpath " in 936965eef222Smrg *" $libdir "*) ;; 9370200d7199Smrg *) func_append finalize_rpath " $libdir" ;; 937165eef222Smrg esac 937265eef222Smrg done 9373b312a94cSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 937465eef222Smrg dependency_libs="$temp_xrpath $dependency_libs" 937565eef222Smrg fi 937665eef222Smrg fi 937765eef222Smrg 937865eef222Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 9379b312a94cSmrg old_dlfiles=$dlfiles 938065eef222Smrg dlfiles= 938165eef222Smrg for lib in $old_dlfiles; do 938265eef222Smrg case " $dlprefiles $dlfiles " in 938365eef222Smrg *" $lib "*) ;; 9384200d7199Smrg *) func_append dlfiles " $lib" ;; 938565eef222Smrg esac 938665eef222Smrg done 938765eef222Smrg 938865eef222Smrg # Make sure dlprefiles contains only unique files 9389b312a94cSmrg old_dlprefiles=$dlprefiles 939065eef222Smrg dlprefiles= 939165eef222Smrg for lib in $old_dlprefiles; do 939265eef222Smrg case "$dlprefiles " in 939365eef222Smrg *" $lib "*) ;; 9394200d7199Smrg *) func_append dlprefiles " $lib" ;; 939565eef222Smrg esac 939665eef222Smrg done 939765eef222Smrg 9398b312a94cSmrg if test yes = "$build_libtool_libs"; then 939965eef222Smrg if test -n "$rpath"; then 940065eef222Smrg case $host in 940156957a04Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 940265eef222Smrg # these systems don't actually have a c library (as such)! 940365eef222Smrg ;; 940465eef222Smrg *-*-rhapsody* | *-*-darwin1.[012]) 940565eef222Smrg # Rhapsody C library is in the System framework 9406200d7199Smrg func_append deplibs " System.ltframework" 940765eef222Smrg ;; 940865eef222Smrg *-*-netbsd*) 940965eef222Smrg # Don't link with libc until the a.out ld.so is fixed. 941065eef222Smrg ;; 9411d5637ae9Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 941265eef222Smrg # Do not include libc due to us having libc/libc_r. 941365eef222Smrg ;; 941465eef222Smrg *-*-sco3.2v5* | *-*-sco5v6*) 941565eef222Smrg # Causes problems with __ctype 941665eef222Smrg ;; 941765eef222Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 941865eef222Smrg # Compiler inserts libc in the correct place for threads to work 941965eef222Smrg ;; 942065eef222Smrg *) 942165eef222Smrg # Add libc to deplibs on all other systems if necessary. 9422b312a94cSmrg if test yes = "$build_libtool_need_lc"; then 9423200d7199Smrg func_append deplibs " -lc" 942465eef222Smrg fi 942565eef222Smrg ;; 942665eef222Smrg esac 942765eef222Smrg fi 942865eef222Smrg 942965eef222Smrg # Transform deplibs into only deplibs that can be linked in shared. 943065eef222Smrg name_save=$name 943165eef222Smrg libname_save=$libname 943265eef222Smrg release_save=$release 943365eef222Smrg versuffix_save=$versuffix 943465eef222Smrg major_save=$major 943565eef222Smrg # I'm not sure if I'm treating the release correctly. I think 943665eef222Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 943765eef222Smrg # add it in twice. Is that correct? 9438b312a94cSmrg release= 9439b312a94cSmrg versuffix= 9440b312a94cSmrg major= 944165eef222Smrg newdeplibs= 944265eef222Smrg droppeddeps=no 944365eef222Smrg case $deplibs_check_method in 944465eef222Smrg pass_all) 944565eef222Smrg # Don't check for shared/static. Everything works. 944665eef222Smrg # This might be a little naive. We might want to check 944765eef222Smrg # whether the library exists or not. But this is on 944865eef222Smrg # osf3 & osf4 and I'm not really sure... Just 944965eef222Smrg # implementing what was already the behavior. 945065eef222Smrg newdeplibs=$deplibs 945165eef222Smrg ;; 945265eef222Smrg test_compile) 945365eef222Smrg # This code stresses the "libraries are programs" paradigm to its 945465eef222Smrg # limits. Maybe even breaks it. We compile a program, linking it 945565eef222Smrg # against the deplibs as a proxy for the library. Then we can check 945665eef222Smrg # whether they linked in statically or dynamically with ldd. 945765eef222Smrg $opt_dry_run || $RM conftest.c 945865eef222Smrg cat > conftest.c <<EOF 945965eef222Smrg int main() { return 0; } 946065eef222SmrgEOF 946165eef222Smrg $opt_dry_run || $RM conftest 946265eef222Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 946365eef222Smrg ldd_output=`ldd conftest` 946465eef222Smrg for i in $deplibs; do 946565eef222Smrg case $i in 946665eef222Smrg -l*) 946765eef222Smrg func_stripname -l '' "$i" 946865eef222Smrg name=$func_stripname_result 9469b312a94cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 947065eef222Smrg case " $predeps $postdeps " in 947165eef222Smrg *" $i "*) 9472200d7199Smrg func_append newdeplibs " $i" 9473b312a94cSmrg i= 947465eef222Smrg ;; 947565eef222Smrg esac 947665eef222Smrg fi 9477b312a94cSmrg if test -n "$i"; then 947865eef222Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 947965eef222Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 948065eef222Smrg set dummy $deplib_matches; shift 948165eef222Smrg deplib_match=$1 9482b312a94cSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9483200d7199Smrg func_append newdeplibs " $i" 948465eef222Smrg else 948565eef222Smrg droppeddeps=yes 948656957a04Smrg echo 948765eef222Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 948856957a04Smrg echo "*** I have the capability to make that library automatically link in when" 948956957a04Smrg echo "*** you link to this library. But I can only do this if you have a" 949056957a04Smrg echo "*** shared version of the library, which I believe you do not have" 949156957a04Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 949256957a04Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 949365eef222Smrg fi 949465eef222Smrg fi 949565eef222Smrg ;; 949665eef222Smrg *) 9497200d7199Smrg func_append newdeplibs " $i" 949865eef222Smrg ;; 949965eef222Smrg esac 950065eef222Smrg done 950165eef222Smrg else 950265eef222Smrg # Error occurred in the first compile. Let's try to salvage 950365eef222Smrg # the situation: Compile a separate program for each library. 950465eef222Smrg for i in $deplibs; do 950565eef222Smrg case $i in 950665eef222Smrg -l*) 950765eef222Smrg func_stripname -l '' "$i" 950865eef222Smrg name=$func_stripname_result 950965eef222Smrg $opt_dry_run || $RM conftest 951065eef222Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 951165eef222Smrg ldd_output=`ldd conftest` 9512b312a94cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 951365eef222Smrg case " $predeps $postdeps " in 951465eef222Smrg *" $i "*) 9515200d7199Smrg func_append newdeplibs " $i" 9516b312a94cSmrg i= 951765eef222Smrg ;; 951865eef222Smrg esac 951965eef222Smrg fi 9520b312a94cSmrg if test -n "$i"; then 952165eef222Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 952265eef222Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 952365eef222Smrg set dummy $deplib_matches; shift 952465eef222Smrg deplib_match=$1 9525b312a94cSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9526200d7199Smrg func_append newdeplibs " $i" 952765eef222Smrg else 952865eef222Smrg droppeddeps=yes 952956957a04Smrg echo 953065eef222Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 953156957a04Smrg echo "*** I have the capability to make that library automatically link in when" 953256957a04Smrg echo "*** you link to this library. But I can only do this if you have a" 953356957a04Smrg echo "*** shared version of the library, which you do not appear to have" 953456957a04Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 953556957a04Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 953665eef222Smrg fi 953765eef222Smrg fi 953865eef222Smrg else 953965eef222Smrg droppeddeps=yes 954056957a04Smrg echo 954165eef222Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 954256957a04Smrg echo "*** make it link in! You will probably need to install it or some" 954356957a04Smrg echo "*** library that it depends on before this library will be fully" 954456957a04Smrg echo "*** functional. Installing it before continuing would be even better." 954565eef222Smrg fi 954665eef222Smrg ;; 954765eef222Smrg *) 9548200d7199Smrg func_append newdeplibs " $i" 954965eef222Smrg ;; 955065eef222Smrg esac 955165eef222Smrg done 955265eef222Smrg fi 955365eef222Smrg ;; 955465eef222Smrg file_magic*) 955565eef222Smrg set dummy $deplibs_check_method; shift 955665eef222Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 955765eef222Smrg for a_deplib in $deplibs; do 955865eef222Smrg case $a_deplib in 955965eef222Smrg -l*) 956065eef222Smrg func_stripname -l '' "$a_deplib" 956165eef222Smrg name=$func_stripname_result 9562b312a94cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 956365eef222Smrg case " $predeps $postdeps " in 956465eef222Smrg *" $a_deplib "*) 9565200d7199Smrg func_append newdeplibs " $a_deplib" 9566b312a94cSmrg a_deplib= 956765eef222Smrg ;; 956865eef222Smrg esac 956965eef222Smrg fi 9570b312a94cSmrg if test -n "$a_deplib"; then 957165eef222Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9572200d7199Smrg if test -n "$file_magic_glob"; then 9573200d7199Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9574200d7199Smrg else 9575200d7199Smrg libnameglob=$libname 9576200d7199Smrg fi 9577b312a94cSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 957865eef222Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9579b312a94cSmrg if test yes = "$want_nocaseglob"; then 9580200d7199Smrg shopt -s nocaseglob 9581200d7199Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9582200d7199Smrg $nocaseglob 9583200d7199Smrg else 9584200d7199Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9585200d7199Smrg fi 958665eef222Smrg for potent_lib in $potential_libs; do 958765eef222Smrg # Follow soft links. 958865eef222Smrg if ls -lLd "$potent_lib" 2>/dev/null | 958965eef222Smrg $GREP " -> " >/dev/null; then 959065eef222Smrg continue 959165eef222Smrg fi 959265eef222Smrg # The statement above tries to avoid entering an 959365eef222Smrg # endless loop below, in case of cyclic links. 959465eef222Smrg # We might still enter an endless loop, since a link 959565eef222Smrg # loop can be closed while we follow links, 959665eef222Smrg # but so what? 9597b312a94cSmrg potlib=$potent_lib 959865eef222Smrg while test -h "$potlib" 2>/dev/null; do 9599b312a94cSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 960065eef222Smrg case $potliblink in 9601b312a94cSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9602b312a94cSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 960365eef222Smrg esac 960465eef222Smrg done 960565eef222Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 960665eef222Smrg $SED -e 10q | 960765eef222Smrg $EGREP "$file_magic_regex" > /dev/null; then 9608200d7199Smrg func_append newdeplibs " $a_deplib" 9609b312a94cSmrg a_deplib= 961065eef222Smrg break 2 961165eef222Smrg fi 961265eef222Smrg done 961365eef222Smrg done 961465eef222Smrg fi 9615b312a94cSmrg if test -n "$a_deplib"; then 961665eef222Smrg droppeddeps=yes 961756957a04Smrg echo 961865eef222Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 961956957a04Smrg echo "*** I have the capability to make that library automatically link in when" 962056957a04Smrg echo "*** you link to this library. But I can only do this if you have a" 962156957a04Smrg echo "*** shared version of the library, which you do not appear to have" 962256957a04Smrg echo "*** because I did check the linker path looking for a file starting" 9623b312a94cSmrg if test -z "$potlib"; then 962465eef222Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 962565eef222Smrg else 962665eef222Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 962765eef222Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 962865eef222Smrg fi 962965eef222Smrg fi 963065eef222Smrg ;; 963165eef222Smrg *) 963265eef222Smrg # Add a -L argument. 9633200d7199Smrg func_append newdeplibs " $a_deplib" 963465eef222Smrg ;; 963565eef222Smrg esac 963665eef222Smrg done # Gone through all deplibs. 963765eef222Smrg ;; 963865eef222Smrg match_pattern*) 963965eef222Smrg set dummy $deplibs_check_method; shift 964065eef222Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 964165eef222Smrg for a_deplib in $deplibs; do 964265eef222Smrg case $a_deplib in 964365eef222Smrg -l*) 964465eef222Smrg func_stripname -l '' "$a_deplib" 964565eef222Smrg name=$func_stripname_result 9646b312a94cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 964765eef222Smrg case " $predeps $postdeps " in 964865eef222Smrg *" $a_deplib "*) 9649200d7199Smrg func_append newdeplibs " $a_deplib" 9650b312a94cSmrg a_deplib= 965165eef222Smrg ;; 965265eef222Smrg esac 965365eef222Smrg fi 9654b312a94cSmrg if test -n "$a_deplib"; then 965565eef222Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 965665eef222Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 965765eef222Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 965865eef222Smrg for potent_lib in $potential_libs; do 9659b312a94cSmrg potlib=$potent_lib # see symlink-check above in file_magic test 966056957a04Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 966165eef222Smrg $EGREP "$match_pattern_regex" > /dev/null; then 9662200d7199Smrg func_append newdeplibs " $a_deplib" 9663b312a94cSmrg a_deplib= 966465eef222Smrg break 2 966565eef222Smrg fi 966665eef222Smrg done 966765eef222Smrg done 966865eef222Smrg fi 9669b312a94cSmrg if test -n "$a_deplib"; then 967065eef222Smrg droppeddeps=yes 967156957a04Smrg echo 967265eef222Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 967356957a04Smrg echo "*** I have the capability to make that library automatically link in when" 967456957a04Smrg echo "*** you link to this library. But I can only do this if you have a" 967556957a04Smrg echo "*** shared version of the library, which you do not appear to have" 967656957a04Smrg echo "*** because I did check the linker path looking for a file starting" 9677b312a94cSmrg if test -z "$potlib"; then 967865eef222Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 967965eef222Smrg else 968065eef222Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 968165eef222Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 968265eef222Smrg fi 968365eef222Smrg fi 968465eef222Smrg ;; 968565eef222Smrg *) 968665eef222Smrg # Add a -L argument. 9687200d7199Smrg func_append newdeplibs " $a_deplib" 968865eef222Smrg ;; 968965eef222Smrg esac 969065eef222Smrg done # Gone through all deplibs. 969165eef222Smrg ;; 969265eef222Smrg none | unknown | *) 9693b312a94cSmrg newdeplibs= 969456957a04Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9695b312a94cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9696b312a94cSmrg for i in $predeps $postdeps; do 969765eef222Smrg # can't use Xsed below, because $i might contain '/' 9698b312a94cSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 969965eef222Smrg done 970065eef222Smrg fi 970156957a04Smrg case $tmp_deplibs in 970256957a04Smrg *[!\ \ ]*) 970356957a04Smrg echo 9704b312a94cSmrg if test none = "$deplibs_check_method"; then 970556957a04Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 970665eef222Smrg else 970756957a04Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 970865eef222Smrg fi 970956957a04Smrg echo "*** All declared inter-library dependencies are being dropped." 971065eef222Smrg droppeddeps=yes 971156957a04Smrg ;; 971256957a04Smrg esac 971365eef222Smrg ;; 971465eef222Smrg esac 971565eef222Smrg versuffix=$versuffix_save 971665eef222Smrg major=$major_save 971765eef222Smrg release=$release_save 971865eef222Smrg libname=$libname_save 971965eef222Smrg name=$name_save 972065eef222Smrg 972165eef222Smrg case $host in 972265eef222Smrg *-*-rhapsody* | *-*-darwin1.[012]) 972365eef222Smrg # On Rhapsody replace the C library with the System framework 972456957a04Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 972565eef222Smrg ;; 972665eef222Smrg esac 972765eef222Smrg 9728b312a94cSmrg if test yes = "$droppeddeps"; then 9729b312a94cSmrg if test yes = "$module"; then 973056957a04Smrg echo 973156957a04Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 973265eef222Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 973356957a04Smrg echo "*** a static module, that should work as long as the dlopening" 973456957a04Smrg echo "*** application is linked with the -dlopen flag." 973565eef222Smrg if test -z "$global_symbol_pipe"; then 973656957a04Smrg echo 973756957a04Smrg echo "*** However, this would only work if libtool was able to extract symbol" 9738b312a94cSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 973956957a04Smrg echo "*** not find such a program. So, this module is probably useless." 9740b312a94cSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 974165eef222Smrg fi 9742b312a94cSmrg if test no = "$build_old_libs"; then 9743b312a94cSmrg oldlibs=$output_objdir/$libname.$libext 974465eef222Smrg build_libtool_libs=module 974565eef222Smrg build_old_libs=yes 974665eef222Smrg else 974765eef222Smrg build_libtool_libs=no 974865eef222Smrg fi 974965eef222Smrg else 975056957a04Smrg echo "*** The inter-library dependencies that have been dropped here will be" 975156957a04Smrg echo "*** automatically added whenever a program is linked with this library" 975256957a04Smrg echo "*** or is declared to -dlopen it." 975365eef222Smrg 9754b312a94cSmrg if test no = "$allow_undefined"; then 975556957a04Smrg echo 975656957a04Smrg echo "*** Since this library must not contain undefined symbols," 975756957a04Smrg echo "*** because either the platform does not support them or" 975856957a04Smrg echo "*** it was explicitly requested with -no-undefined," 975956957a04Smrg echo "*** libtool will only create a static version of it." 9760b312a94cSmrg if test no = "$build_old_libs"; then 9761b312a94cSmrg oldlibs=$output_objdir/$libname.$libext 976265eef222Smrg build_libtool_libs=module 976365eef222Smrg build_old_libs=yes 976465eef222Smrg else 976565eef222Smrg build_libtool_libs=no 976665eef222Smrg fi 976765eef222Smrg fi 976865eef222Smrg fi 976965eef222Smrg fi 977065eef222Smrg # Done checking deplibs! 977165eef222Smrg deplibs=$newdeplibs 977265eef222Smrg fi 977365eef222Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 977465eef222Smrg case $host in 977565eef222Smrg *-*-darwin*) 977656957a04Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 977756957a04Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 977856957a04Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 977965eef222Smrg ;; 978065eef222Smrg esac 978165eef222Smrg 978265eef222Smrg # move library search paths that coincide with paths to not yet 978365eef222Smrg # installed libraries to the beginning of the library search list 978465eef222Smrg new_libs= 978565eef222Smrg for path in $notinst_path; do 978665eef222Smrg case " $new_libs " in 978765eef222Smrg *" -L$path/$objdir "*) ;; 978865eef222Smrg *) 978965eef222Smrg case " $deplibs " in 979065eef222Smrg *" -L$path/$objdir "*) 9791200d7199Smrg func_append new_libs " -L$path/$objdir" ;; 979265eef222Smrg esac 979365eef222Smrg ;; 979465eef222Smrg esac 979565eef222Smrg done 979665eef222Smrg for deplib in $deplibs; do 979765eef222Smrg case $deplib in 979865eef222Smrg -L*) 979965eef222Smrg case " $new_libs " in 980065eef222Smrg *" $deplib "*) ;; 9801200d7199Smrg *) func_append new_libs " $deplib" ;; 980265eef222Smrg esac 980365eef222Smrg ;; 9804200d7199Smrg *) func_append new_libs " $deplib" ;; 980565eef222Smrg esac 980665eef222Smrg done 9807b312a94cSmrg deplibs=$new_libs 980865eef222Smrg 980965eef222Smrg # All the library-specific variables (install_libdir is set above). 981065eef222Smrg library_names= 981165eef222Smrg old_library= 981265eef222Smrg dlname= 981365eef222Smrg 981465eef222Smrg # Test again, we may have decided not to build it any more 9815b312a94cSmrg if test yes = "$build_libtool_libs"; then 9816b312a94cSmrg # Remove $wl instances when linking with ld. 9817b312a94cSmrg # FIXME: should test the right _cmds variable. 9818b312a94cSmrg case $archive_cmds in 9819b312a94cSmrg *\$LD\ *) wl= ;; 9820b312a94cSmrg esac 9821b312a94cSmrg if test yes = "$hardcode_into_libs"; then 982265eef222Smrg # Hardcode the library paths 982365eef222Smrg hardcode_libdirs= 982465eef222Smrg dep_rpath= 9825b312a94cSmrg rpath=$finalize_rpath 9826b312a94cSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 982765eef222Smrg for libdir in $rpath; do 982865eef222Smrg if test -n "$hardcode_libdir_flag_spec"; then 982965eef222Smrg if test -n "$hardcode_libdir_separator"; then 9830200d7199Smrg func_replace_sysroot "$libdir" 9831200d7199Smrg libdir=$func_replace_sysroot_result 983265eef222Smrg if test -z "$hardcode_libdirs"; then 9833b312a94cSmrg hardcode_libdirs=$libdir 983465eef222Smrg else 983565eef222Smrg # Just accumulate the unique libdirs. 983665eef222Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 983765eef222Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 983865eef222Smrg ;; 983965eef222Smrg *) 9840200d7199Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 984165eef222Smrg ;; 984265eef222Smrg esac 984365eef222Smrg fi 984465eef222Smrg else 984565eef222Smrg eval flag=\"$hardcode_libdir_flag_spec\" 9846200d7199Smrg func_append dep_rpath " $flag" 984765eef222Smrg fi 984865eef222Smrg elif test -n "$runpath_var"; then 984965eef222Smrg case "$perm_rpath " in 985065eef222Smrg *" $libdir "*) ;; 9851b312a94cSmrg *) func_append perm_rpath " $libdir" ;; 985265eef222Smrg esac 985365eef222Smrg fi 985465eef222Smrg done 985565eef222Smrg # Substitute the hardcoded libdirs into the rpath. 985665eef222Smrg if test -n "$hardcode_libdir_separator" && 985765eef222Smrg test -n "$hardcode_libdirs"; then 9858b312a94cSmrg libdir=$hardcode_libdirs 9859b312a94cSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 986065eef222Smrg fi 986165eef222Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 986265eef222Smrg # We should set the runpath_var. 986365eef222Smrg rpath= 986465eef222Smrg for dir in $perm_rpath; do 9865200d7199Smrg func_append rpath "$dir:" 986665eef222Smrg done 986765eef222Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 986865eef222Smrg fi 986965eef222Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 987065eef222Smrg fi 9871ef981d24Smrg 9872b312a94cSmrg shlibpath=$finalize_shlibpath 9873b312a94cSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 987465eef222Smrg if test -n "$shlibpath"; then 987565eef222Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 987665eef222Smrg fi 9877ef981d24Smrg 987865eef222Smrg # Get the real and link names of the library. 987965eef222Smrg eval shared_ext=\"$shrext_cmds\" 988065eef222Smrg eval library_names=\"$library_names_spec\" 988165eef222Smrg set dummy $library_names 988265eef222Smrg shift 9883b312a94cSmrg realname=$1 988465eef222Smrg shift 9885ef981d24Smrg 988665eef222Smrg if test -n "$soname_spec"; then 988765eef222Smrg eval soname=\"$soname_spec\" 988865eef222Smrg else 9889b312a94cSmrg soname=$realname 989065eef222Smrg fi 989165eef222Smrg if test -z "$dlname"; then 989265eef222Smrg dlname=$soname 989365eef222Smrg fi 9894ef981d24Smrg 9895b312a94cSmrg lib=$output_objdir/$realname 989665eef222Smrg linknames= 989765eef222Smrg for link 989865eef222Smrg do 9899200d7199Smrg func_append linknames " $link" 990065eef222Smrg done 9901ef981d24Smrg 990265eef222Smrg # Use standard objects if they are pic 990356957a04Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 990465eef222Smrg test "X$libobjs" = "X " && libobjs= 9905ef981d24Smrg 990665eef222Smrg delfiles= 990765eef222Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 990865eef222Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9909b312a94cSmrg export_symbols=$output_objdir/$libname.uexp 9910200d7199Smrg func_append delfiles " $export_symbols" 991165eef222Smrg fi 9912ef981d24Smrg 991365eef222Smrg orig_export_symbols= 991465eef222Smrg case $host_os in 991565eef222Smrg cygwin* | mingw* | cegcc*) 991665eef222Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 991765eef222Smrg # exporting using user supplied symfile 9918b312a94cSmrg func_dll_def_p "$export_symbols" || { 991965eef222Smrg # and it's NOT already a .def file. Must figure out 992065eef222Smrg # which of the given symbols are data symbols and tag 992165eef222Smrg # them as such. So, trigger use of export_symbols_cmds. 992265eef222Smrg # export_symbols gets reassigned inside the "prepare 992365eef222Smrg # the list of exported symbols" if statement, so the 992465eef222Smrg # include_expsyms logic still works. 9925b312a94cSmrg orig_export_symbols=$export_symbols 992665eef222Smrg export_symbols= 992765eef222Smrg always_export_symbols=yes 9928b312a94cSmrg } 992965eef222Smrg fi 993065eef222Smrg ;; 993165eef222Smrg esac 9932ef981d24Smrg 993365eef222Smrg # Prepare the list of exported symbols 993465eef222Smrg if test -z "$export_symbols"; then 9935b312a94cSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9936b312a94cSmrg func_verbose "generating symbol list for '$libname.la'" 9937b312a94cSmrg export_symbols=$output_objdir/$libname.exp 993865eef222Smrg $opt_dry_run || $RM $export_symbols 993965eef222Smrg cmds=$export_symbols_cmds 9940b312a94cSmrg save_ifs=$IFS; IFS='~' 9941200d7199Smrg for cmd1 in $cmds; do 9942b312a94cSmrg IFS=$save_ifs 9943200d7199Smrg # Take the normal branch if the nm_file_list_spec branch 9944200d7199Smrg # doesn't work or if tool conversion is not needed. 9945200d7199Smrg case $nm_file_list_spec~$to_tool_file_cmd in 9946200d7199Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9947200d7199Smrg try_normal_branch=yes 9948200d7199Smrg eval cmd=\"$cmd1\" 9949200d7199Smrg func_len " $cmd" 9950200d7199Smrg len=$func_len_result 9951200d7199Smrg ;; 9952200d7199Smrg *) 9953200d7199Smrg try_normal_branch=no 9954200d7199Smrg ;; 9955200d7199Smrg esac 9956b312a94cSmrg if test yes = "$try_normal_branch" \ 9957200d7199Smrg && { test "$len" -lt "$max_cmd_len" \ 9958200d7199Smrg || test "$max_cmd_len" -le -1; } 9959200d7199Smrg then 9960200d7199Smrg func_show_eval "$cmd" 'exit $?' 9961200d7199Smrg skipped_export=false 9962200d7199Smrg elif test -n "$nm_file_list_spec"; then 9963200d7199Smrg func_basename "$output" 9964200d7199Smrg output_la=$func_basename_result 9965200d7199Smrg save_libobjs=$libobjs 9966200d7199Smrg save_output=$output 9967b312a94cSmrg output=$output_objdir/$output_la.nm 9968200d7199Smrg func_to_tool_file "$output" 9969200d7199Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9970200d7199Smrg func_append delfiles " $output" 9971200d7199Smrg func_verbose "creating $NM input file list: $output" 9972200d7199Smrg for obj in $save_libobjs; do 9973200d7199Smrg func_to_tool_file "$obj" 9974200d7199Smrg $ECHO "$func_to_tool_file_result" 9975200d7199Smrg done > "$output" 9976200d7199Smrg eval cmd=\"$cmd1\" 997765eef222Smrg func_show_eval "$cmd" 'exit $?' 9978200d7199Smrg output=$save_output 9979200d7199Smrg libobjs=$save_libobjs 998065eef222Smrg skipped_export=false 998165eef222Smrg else 998265eef222Smrg # The command line is too long to execute in one step. 998365eef222Smrg func_verbose "using reloadable object file for export list..." 998465eef222Smrg skipped_export=: 998565eef222Smrg # Break out early, otherwise skipped_export may be 998665eef222Smrg # set to false by a later but shorter cmd. 998765eef222Smrg break 998865eef222Smrg fi 998965eef222Smrg done 9990b312a94cSmrg IFS=$save_ifs 9991b312a94cSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 999265eef222Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 999365eef222Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 999465eef222Smrg fi 999565eef222Smrg fi 999665eef222Smrg fi 9997ef981d24Smrg 999865eef222Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9999b312a94cSmrg tmp_export_symbols=$export_symbols 10000b312a94cSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 1000156957a04Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 1000265eef222Smrg fi 10003ef981d24Smrg 10004b312a94cSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 1000565eef222Smrg # The given exports_symbols file has to be filtered, so filter it. 10006b312a94cSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 1000765eef222Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 10008b312a94cSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 1000965eef222Smrg # though. Also, the filter scales superlinearly with the number of 1001065eef222Smrg # global variables. join(1) would be nice here, but unfortunately 1001165eef222Smrg # isn't a blessed tool. 1001265eef222Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10013200d7199Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 1001465eef222Smrg export_symbols=$output_objdir/$libname.def 1001565eef222Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10016ef981d24Smrg fi 10017ef981d24Smrg 1001865eef222Smrg tmp_deplibs= 1001965eef222Smrg for test_deplib in $deplibs; do 1002065eef222Smrg case " $convenience " in 1002165eef222Smrg *" $test_deplib "*) ;; 1002265eef222Smrg *) 10023200d7199Smrg func_append tmp_deplibs " $test_deplib" 1002465eef222Smrg ;; 1002565eef222Smrg esac 1002665eef222Smrg done 10027b312a94cSmrg deplibs=$tmp_deplibs 10028ef981d24Smrg 1002965eef222Smrg if test -n "$convenience"; then 1003065eef222Smrg if test -n "$whole_archive_flag_spec" && 10031b312a94cSmrg test yes = "$compiler_needs_object" && 1003265eef222Smrg test -z "$libobjs"; then 1003365eef222Smrg # extract the archives, so we have objects to list. 1003465eef222Smrg # TODO: could optimize this to just extract one archive. 1003565eef222Smrg whole_archive_flag_spec= 1003665eef222Smrg fi 1003765eef222Smrg if test -n "$whole_archive_flag_spec"; then 1003865eef222Smrg save_libobjs=$libobjs 1003965eef222Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 1004065eef222Smrg test "X$libobjs" = "X " && libobjs= 1004165eef222Smrg else 10042b312a94cSmrg gentop=$output_objdir/${outputname}x 10043200d7199Smrg func_append generated " $gentop" 10044ef981d24Smrg 1004565eef222Smrg func_extract_archives $gentop $convenience 10046200d7199Smrg func_append libobjs " $func_extract_archives_result" 1004765eef222Smrg test "X$libobjs" = "X " && libobjs= 1004865eef222Smrg fi 1004965eef222Smrg fi 10050ef981d24Smrg 10051b312a94cSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 1005265eef222Smrg eval flag=\"$thread_safe_flag_spec\" 10053200d7199Smrg func_append linker_flags " $flag" 1005465eef222Smrg fi 10055ef981d24Smrg 1005665eef222Smrg # Make a backup of the uninstalled library when relinking 10057b312a94cSmrg if test relink = "$opt_mode"; then 1005865eef222Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 10059ef981d24Smrg fi 10060ef981d24Smrg 1006165eef222Smrg # Do each of the archive commands. 10062b312a94cSmrg if test yes = "$module" && test -n "$module_cmds"; then 1006365eef222Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 1006465eef222Smrg eval test_cmds=\"$module_expsym_cmds\" 1006565eef222Smrg cmds=$module_expsym_cmds 1006665eef222Smrg else 1006765eef222Smrg eval test_cmds=\"$module_cmds\" 1006865eef222Smrg cmds=$module_cmds 1006965eef222Smrg fi 1007065eef222Smrg else 1007165eef222Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 1007265eef222Smrg eval test_cmds=\"$archive_expsym_cmds\" 1007365eef222Smrg cmds=$archive_expsym_cmds 1007465eef222Smrg else 1007565eef222Smrg eval test_cmds=\"$archive_cmds\" 1007665eef222Smrg cmds=$archive_cmds 1007765eef222Smrg fi 10078ef981d24Smrg fi 10079ef981d24Smrg 10080b312a94cSmrg if test : != "$skipped_export" && 1008165eef222Smrg func_len " $test_cmds" && 1008265eef222Smrg len=$func_len_result && 1008365eef222Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 1008465eef222Smrg : 1008565eef222Smrg else 1008665eef222Smrg # The command line is too long to link in one step, link piecewise 1008765eef222Smrg # or, if using GNU ld and skipped_export is not :, use a linker 1008865eef222Smrg # script. 10089ef981d24Smrg 1009065eef222Smrg # Save the value of $output and $libobjs because we want to 1009165eef222Smrg # use them later. If we have whole_archive_flag_spec, we 1009265eef222Smrg # want to use save_libobjs as it was before 1009365eef222Smrg # whole_archive_flag_spec was expanded, because we can't 1009465eef222Smrg # assume the linker understands whole_archive_flag_spec. 1009565eef222Smrg # This may have to be revisited, in case too many 1009665eef222Smrg # convenience libraries get linked in and end up exceeding 1009765eef222Smrg # the spec. 1009865eef222Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 1009965eef222Smrg save_libobjs=$libobjs 1010065eef222Smrg fi 1010165eef222Smrg save_output=$output 1010256957a04Smrg func_basename "$output" 1010356957a04Smrg output_la=$func_basename_result 10104ef981d24Smrg 1010565eef222Smrg # Clear the reloadable object creation command queue and 1010665eef222Smrg # initialize k to one. 1010765eef222Smrg test_cmds= 1010865eef222Smrg concat_cmds= 1010965eef222Smrg objlist= 1011065eef222Smrg last_robj= 1011165eef222Smrg k=1 10112ef981d24Smrg 10113b312a94cSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 10114b312a94cSmrg output=$output_objdir/$output_la.lnkscript 1011565eef222Smrg func_verbose "creating GNU ld script: $output" 1011656957a04Smrg echo 'INPUT (' > $output 1011765eef222Smrg for obj in $save_libobjs 1011865eef222Smrg do 10119200d7199Smrg func_to_tool_file "$obj" 10120200d7199Smrg $ECHO "$func_to_tool_file_result" >> $output 1012165eef222Smrg done 1012256957a04Smrg echo ')' >> $output 10123200d7199Smrg func_append delfiles " $output" 10124200d7199Smrg func_to_tool_file "$output" 10125200d7199Smrg output=$func_to_tool_file_result 10126b312a94cSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 10127b312a94cSmrg output=$output_objdir/$output_la.lnk 1012865eef222Smrg func_verbose "creating linker input file list: $output" 1012965eef222Smrg : > $output 1013065eef222Smrg set x $save_libobjs 1013165eef222Smrg shift 1013265eef222Smrg firstobj= 10133b312a94cSmrg if test yes = "$compiler_needs_object"; then 1013465eef222Smrg firstobj="$1 " 1013565eef222Smrg shift 1013665eef222Smrg fi 1013765eef222Smrg for obj 1013865eef222Smrg do 10139200d7199Smrg func_to_tool_file "$obj" 10140200d7199Smrg $ECHO "$func_to_tool_file_result" >> $output 1014165eef222Smrg done 10142200d7199Smrg func_append delfiles " $output" 10143200d7199Smrg func_to_tool_file "$output" 10144200d7199Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 1014565eef222Smrg else 1014665eef222Smrg if test -n "$save_libobjs"; then 1014765eef222Smrg func_verbose "creating reloadable object files..." 10148b312a94cSmrg output=$output_objdir/$output_la-$k.$objext 1014965eef222Smrg eval test_cmds=\"$reload_cmds\" 1015065eef222Smrg func_len " $test_cmds" 1015165eef222Smrg len0=$func_len_result 1015265eef222Smrg len=$len0 1015365eef222Smrg 1015465eef222Smrg # Loop over the list of objects to be linked. 1015565eef222Smrg for obj in $save_libobjs 1015665eef222Smrg do 1015765eef222Smrg func_len " $obj" 1015865eef222Smrg func_arith $len + $func_len_result 1015965eef222Smrg len=$func_arith_result 10160b312a94cSmrg if test -z "$objlist" || 1016165eef222Smrg test "$len" -lt "$max_cmd_len"; then 1016265eef222Smrg func_append objlist " $obj" 1016365eef222Smrg else 1016465eef222Smrg # The command $test_cmds is almost too long, add a 1016565eef222Smrg # command to the queue. 10166b312a94cSmrg if test 1 -eq "$k"; then 1016765eef222Smrg # The first file doesn't have a previous command to add. 1016856957a04Smrg reload_objs=$objlist 1016956957a04Smrg eval concat_cmds=\"$reload_cmds\" 1017065eef222Smrg else 1017165eef222Smrg # All subsequent reloadable object files will link in 1017265eef222Smrg # the last one created. 1017356957a04Smrg reload_objs="$objlist $last_robj" 1017456957a04Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 1017565eef222Smrg fi 10176b312a94cSmrg last_robj=$output_objdir/$output_la-$k.$objext 1017765eef222Smrg func_arith $k + 1 1017865eef222Smrg k=$func_arith_result 10179b312a94cSmrg output=$output_objdir/$output_la-$k.$objext 1018056957a04Smrg objlist=" $obj" 1018165eef222Smrg func_len " $last_robj" 1018265eef222Smrg func_arith $len0 + $func_len_result 1018365eef222Smrg len=$func_arith_result 1018465eef222Smrg fi 1018565eef222Smrg done 1018665eef222Smrg # Handle the remaining objects by creating one last 1018765eef222Smrg # reloadable object file. All subsequent reloadable object 1018865eef222Smrg # files will link in the last one created. 1018965eef222Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1019056957a04Smrg reload_objs="$objlist $last_robj" 10191b312a94cSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 1019265eef222Smrg if test -n "$last_robj"; then 10193b312a94cSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 1019465eef222Smrg fi 10195200d7199Smrg func_append delfiles " $output" 10196ef981d24Smrg 1019765eef222Smrg else 1019865eef222Smrg output= 1019965eef222Smrg fi 10200ef981d24Smrg 10201b312a94cSmrg ${skipped_export-false} && { 10202b312a94cSmrg func_verbose "generating symbol list for '$libname.la'" 10203b312a94cSmrg export_symbols=$output_objdir/$libname.exp 1020465eef222Smrg $opt_dry_run || $RM $export_symbols 1020565eef222Smrg libobjs=$output 1020665eef222Smrg # Append the command to create the export file. 1020765eef222Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1020865eef222Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 1020965eef222Smrg if test -n "$last_robj"; then 1021065eef222Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 1021165eef222Smrg fi 10212b312a94cSmrg } 10213ef981d24Smrg 1021465eef222Smrg test -n "$save_libobjs" && 1021565eef222Smrg func_verbose "creating a temporary reloadable object file: $output" 10216ef981d24Smrg 1021765eef222Smrg # Loop through the commands generated above and execute them. 10218b312a94cSmrg save_ifs=$IFS; IFS='~' 1021965eef222Smrg for cmd in $concat_cmds; do 10220b312a94cSmrg IFS=$save_ifs 10221b312a94cSmrg $opt_quiet || { 10222d5637ae9Smrg func_quote_arg expand,pretty "$cmd" 10223d5637ae9Smrg eval "func_echo $func_quote_arg_result" 1022465eef222Smrg } 1022565eef222Smrg $opt_dry_run || eval "$cmd" || { 1022665eef222Smrg lt_exit=$? 1022765eef222Smrg 1022865eef222Smrg # Restore the uninstalled library and exit 10229b312a94cSmrg if test relink = "$opt_mode"; then 1023065eef222Smrg ( cd "$output_objdir" && \ 1023165eef222Smrg $RM "${realname}T" && \ 1023265eef222Smrg $MV "${realname}U" "$realname" ) 1023365eef222Smrg fi 10234ef981d24Smrg 1023565eef222Smrg exit $lt_exit 1023665eef222Smrg } 1023765eef222Smrg done 10238b312a94cSmrg IFS=$save_ifs 1023965eef222Smrg 1024065eef222Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 1024165eef222Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 1024265eef222Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 10243ef981d24Smrg fi 10244ef981d24Smrg fi 10245ef981d24Smrg 10246b312a94cSmrg ${skipped_export-false} && { 1024765eef222Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 10248b312a94cSmrg tmp_export_symbols=$export_symbols 10249b312a94cSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 1025056957a04Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 1025165eef222Smrg fi 10252ef981d24Smrg 1025365eef222Smrg if test -n "$orig_export_symbols"; then 1025465eef222Smrg # The given exports_symbols file has to be filtered, so filter it. 10255b312a94cSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 1025665eef222Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 10257b312a94cSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 1025865eef222Smrg # though. Also, the filter scales superlinearly with the number of 1025965eef222Smrg # global variables. join(1) would be nice here, but unfortunately 1026065eef222Smrg # isn't a blessed tool. 1026165eef222Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10262200d7199Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 1026365eef222Smrg export_symbols=$output_objdir/$libname.def 1026465eef222Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 1026565eef222Smrg fi 10266b312a94cSmrg } 10267ef981d24Smrg 1026865eef222Smrg libobjs=$output 1026965eef222Smrg # Restore the value of output. 1027065eef222Smrg output=$save_output 10271ef981d24Smrg 1027265eef222Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 1027365eef222Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 1027465eef222Smrg test "X$libobjs" = "X " && libobjs= 1027565eef222Smrg fi 1027665eef222Smrg # Expand the library linking commands again to reset the 1027765eef222Smrg # value of $libobjs for piecewise linking. 1027865eef222Smrg 1027965eef222Smrg # Do each of the archive commands. 10280b312a94cSmrg if test yes = "$module" && test -n "$module_cmds"; then 1028165eef222Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 1028265eef222Smrg cmds=$module_expsym_cmds 10283ef981d24Smrg else 1028465eef222Smrg cmds=$module_cmds 10285ef981d24Smrg fi 10286ef981d24Smrg else 1028765eef222Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 1028865eef222Smrg cmds=$archive_expsym_cmds 1028965eef222Smrg else 1029065eef222Smrg cmds=$archive_cmds 1029165eef222Smrg fi 10292ef981d24Smrg fi 10293ef981d24Smrg fi 10294ef981d24Smrg 1029565eef222Smrg if test -n "$delfiles"; then 1029665eef222Smrg # Append the command to remove temporary files to $cmds. 1029765eef222Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 1029865eef222Smrg fi 10299ef981d24Smrg 1030065eef222Smrg # Add any objects from preloaded convenience libraries 1030165eef222Smrg if test -n "$dlprefiles"; then 10302b312a94cSmrg gentop=$output_objdir/${outputname}x 10303200d7199Smrg func_append generated " $gentop" 10304ef981d24Smrg 1030565eef222Smrg func_extract_archives $gentop $dlprefiles 10306200d7199Smrg func_append libobjs " $func_extract_archives_result" 1030765eef222Smrg test "X$libobjs" = "X " && libobjs= 10308ef981d24Smrg fi 10309ef981d24Smrg 10310b312a94cSmrg save_ifs=$IFS; IFS='~' 1031165eef222Smrg for cmd in $cmds; do 10312b312a94cSmrg IFS=$sp$nl 1031365eef222Smrg eval cmd=\"$cmd\" 10314b312a94cSmrg IFS=$save_ifs 10315b312a94cSmrg $opt_quiet || { 10316d5637ae9Smrg func_quote_arg expand,pretty "$cmd" 10317d5637ae9Smrg eval "func_echo $func_quote_arg_result" 1031865eef222Smrg } 1031965eef222Smrg $opt_dry_run || eval "$cmd" || { 1032065eef222Smrg lt_exit=$? 10321ef981d24Smrg 1032265eef222Smrg # Restore the uninstalled library and exit 10323b312a94cSmrg if test relink = "$opt_mode"; then 1032465eef222Smrg ( cd "$output_objdir" && \ 1032565eef222Smrg $RM "${realname}T" && \ 1032665eef222Smrg $MV "${realname}U" "$realname" ) 1032765eef222Smrg fi 1032865eef222Smrg 1032965eef222Smrg exit $lt_exit 1033065eef222Smrg } 1033165eef222Smrg done 10332b312a94cSmrg IFS=$save_ifs 1033365eef222Smrg 1033465eef222Smrg # Restore the uninstalled library and exit 10335b312a94cSmrg if test relink = "$opt_mode"; then 1033665eef222Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 1033765eef222Smrg 1033865eef222Smrg if test -n "$convenience"; then 1033965eef222Smrg if test -z "$whole_archive_flag_spec"; then 1034065eef222Smrg func_show_eval '${RM}r "$gentop"' 10341ef981d24Smrg fi 10342ef981d24Smrg fi 10343ef981d24Smrg 1034465eef222Smrg exit $EXIT_SUCCESS 1034565eef222Smrg fi 10346ef981d24Smrg 1034765eef222Smrg # Create links to the real library. 1034865eef222Smrg for linkname in $linknames; do 1034965eef222Smrg if test "$realname" != "$linkname"; then 1035065eef222Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 1035165eef222Smrg fi 1035265eef222Smrg done 1035365eef222Smrg 1035465eef222Smrg # If -module or -export-dynamic was specified, set the dlname. 10355b312a94cSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 1035665eef222Smrg # On all known operating systems, these are identical. 10357b312a94cSmrg dlname=$soname 1035865eef222Smrg fi 1035965eef222Smrg fi 1036065eef222Smrg ;; 1036165eef222Smrg 1036265eef222Smrg obj) 10363b312a94cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10364b312a94cSmrg func_warning "'-dlopen' is ignored for objects" 1036565eef222Smrg fi 1036665eef222Smrg 1036765eef222Smrg case " $deplibs" in 1036865eef222Smrg *\ -l* | *\ -L*) 10369b312a94cSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 1037065eef222Smrg esac 1037165eef222Smrg 1037265eef222Smrg test -n "$rpath" && \ 10373b312a94cSmrg func_warning "'-rpath' is ignored for objects" 1037465eef222Smrg 1037565eef222Smrg test -n "$xrpath" && \ 10376b312a94cSmrg func_warning "'-R' is ignored for objects" 1037765eef222Smrg 1037865eef222Smrg test -n "$vinfo" && \ 10379b312a94cSmrg func_warning "'-version-info' is ignored for objects" 1038065eef222Smrg 1038165eef222Smrg test -n "$release" && \ 10382b312a94cSmrg func_warning "'-release' is ignored for objects" 1038365eef222Smrg 1038465eef222Smrg case $output in 1038565eef222Smrg *.lo) 1038665eef222Smrg test -n "$objs$old_deplibs" && \ 10387b312a94cSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 1038865eef222Smrg 1038965eef222Smrg libobj=$output 1039065eef222Smrg func_lo2o "$libobj" 1039165eef222Smrg obj=$func_lo2o_result 1039265eef222Smrg ;; 1039365eef222Smrg *) 1039465eef222Smrg libobj= 10395b312a94cSmrg obj=$output 1039665eef222Smrg ;; 1039765eef222Smrg esac 1039865eef222Smrg 1039965eef222Smrg # Delete the old objects. 1040065eef222Smrg $opt_dry_run || $RM $obj $libobj 1040165eef222Smrg 1040265eef222Smrg # Objects from convenience libraries. This assumes 1040365eef222Smrg # single-version convenience libraries. Whenever we create 1040465eef222Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 1040565eef222Smrg # the extraction. 1040665eef222Smrg reload_conv_objs= 1040765eef222Smrg gentop= 10408b312a94cSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 10409b312a94cSmrg # whole_archive_flag_spec and hope we can get by with turning comma 10410b312a94cSmrg # into space. 10411b312a94cSmrg case $reload_cmds in 10412b312a94cSmrg *\$LD[\ \$]*) wl= ;; 10413b312a94cSmrg esac 1041465eef222Smrg if test -n "$convenience"; then 1041565eef222Smrg if test -n "$whole_archive_flag_spec"; then 1041665eef222Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10417b312a94cSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10418b312a94cSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 1041965eef222Smrg else 10420b312a94cSmrg gentop=$output_objdir/${obj}x 10421200d7199Smrg func_append generated " $gentop" 1042265eef222Smrg 1042365eef222Smrg func_extract_archives $gentop $convenience 1042465eef222Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 1042565eef222Smrg fi 1042665eef222Smrg fi 10427ef981d24Smrg 10428200d7199Smrg # If we're not building shared, we need to use non_pic_objs 10429b312a94cSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10430200d7199Smrg 1043165eef222Smrg # Create the old-style object. 10432b312a94cSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10433ef981d24Smrg 10434b312a94cSmrg output=$obj 1043565eef222Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10436ef981d24Smrg 1043765eef222Smrg # Exit if we aren't doing a library object file. 1043865eef222Smrg if test -z "$libobj"; then 1043965eef222Smrg if test -n "$gentop"; then 1044065eef222Smrg func_show_eval '${RM}r "$gentop"' 1044165eef222Smrg fi 10442ef981d24Smrg 1044365eef222Smrg exit $EXIT_SUCCESS 1044465eef222Smrg fi 10445ef981d24Smrg 10446b312a94cSmrg test yes = "$build_libtool_libs" || { 1044765eef222Smrg if test -n "$gentop"; then 1044865eef222Smrg func_show_eval '${RM}r "$gentop"' 1044965eef222Smrg fi 10450ef981d24Smrg 1045165eef222Smrg # Create an invalid libtool object if no PIC, so that we don't 1045265eef222Smrg # accidentally link it into a program. 1045365eef222Smrg # $show "echo timestamp > $libobj" 1045465eef222Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 1045565eef222Smrg exit $EXIT_SUCCESS 10456b312a94cSmrg } 10457ef981d24Smrg 10458b312a94cSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 1045965eef222Smrg # Only do commands if we really have different PIC objects. 1046065eef222Smrg reload_objs="$libobjs $reload_conv_objs" 10461b312a94cSmrg output=$libobj 1046265eef222Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10463ef981d24Smrg fi 10464ef981d24Smrg 1046565eef222Smrg if test -n "$gentop"; then 1046665eef222Smrg func_show_eval '${RM}r "$gentop"' 1046765eef222Smrg fi 10468ef981d24Smrg 1046965eef222Smrg exit $EXIT_SUCCESS 1047065eef222Smrg ;; 10471ef981d24Smrg 1047265eef222Smrg prog) 1047365eef222Smrg case $host in 1047465eef222Smrg *cygwin*) func_stripname '' '.exe' "$output" 1047565eef222Smrg output=$func_stripname_result.exe;; 10476ef981d24Smrg esac 1047765eef222Smrg test -n "$vinfo" && \ 10478b312a94cSmrg func_warning "'-version-info' is ignored for programs" 10479ef981d24Smrg 1048065eef222Smrg test -n "$release" && \ 10481b312a94cSmrg func_warning "'-release' is ignored for programs" 10482ef981d24Smrg 10483b312a94cSmrg $preload \ 10484b312a94cSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10485b312a94cSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10486ef981d24Smrg 1048765eef222Smrg case $host in 1048865eef222Smrg *-*-rhapsody* | *-*-darwin1.[012]) 1048965eef222Smrg # On Rhapsody replace the C library is the System framework 1049056957a04Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 1049156957a04Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10492ef981d24Smrg ;; 10493ef981d24Smrg esac 10494ef981d24Smrg 1049565eef222Smrg case $host in 1049665eef222Smrg *-*-darwin*) 1049765eef222Smrg # Don't allow lazy linking, it breaks C++ global constructors 1049865eef222Smrg # But is supposedly fixed on 10.4 or later (yay!). 10499b312a94cSmrg if test CXX = "$tagname"; then 1050065eef222Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 1050165eef222Smrg 10.[0123]) 10502b312a94cSmrg func_append compile_command " $wl-bind_at_load" 10503b312a94cSmrg func_append finalize_command " $wl-bind_at_load" 1050465eef222Smrg ;; 1050565eef222Smrg esac 1050665eef222Smrg fi 1050765eef222Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 1050856957a04Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1050956957a04Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10510ef981d24Smrg ;; 10511ef981d24Smrg esac 10512ef981d24Smrg 10513ef981d24Smrg 1051465eef222Smrg # move library search paths that coincide with paths to not yet 1051565eef222Smrg # installed libraries to the beginning of the library search list 1051665eef222Smrg new_libs= 1051765eef222Smrg for path in $notinst_path; do 1051865eef222Smrg case " $new_libs " in 1051965eef222Smrg *" -L$path/$objdir "*) ;; 10520ef981d24Smrg *) 1052165eef222Smrg case " $compile_deplibs " in 1052265eef222Smrg *" -L$path/$objdir "*) 10523200d7199Smrg func_append new_libs " -L$path/$objdir" ;; 1052465eef222Smrg esac 10525ef981d24Smrg ;; 10526ef981d24Smrg esac 10527ef981d24Smrg done 1052865eef222Smrg for deplib in $compile_deplibs; do 1052965eef222Smrg case $deplib in 1053065eef222Smrg -L*) 1053165eef222Smrg case " $new_libs " in 1053265eef222Smrg *" $deplib "*) ;; 10533200d7199Smrg *) func_append new_libs " $deplib" ;; 1053465eef222Smrg esac 1053565eef222Smrg ;; 10536200d7199Smrg *) func_append new_libs " $deplib" ;; 1053765eef222Smrg esac 1053865eef222Smrg done 10539b312a94cSmrg compile_deplibs=$new_libs 10540ef981d24Smrg 10541ef981d24Smrg 10542200d7199Smrg func_append compile_command " $compile_deplibs" 10543200d7199Smrg func_append finalize_command " $finalize_deplibs" 10544ef981d24Smrg 1054565eef222Smrg if test -n "$rpath$xrpath"; then 1054665eef222Smrg # If the user specified any rpath flags, then add them. 1054765eef222Smrg for libdir in $rpath $xrpath; do 1054865eef222Smrg # This is the magic to use -rpath. 1054965eef222Smrg case "$finalize_rpath " in 1055065eef222Smrg *" $libdir "*) ;; 10551200d7199Smrg *) func_append finalize_rpath " $libdir" ;; 1055265eef222Smrg esac 1055365eef222Smrg done 1055465eef222Smrg fi 10555ef981d24Smrg 1055665eef222Smrg # Now hardcode the library paths 1055765eef222Smrg rpath= 1055865eef222Smrg hardcode_libdirs= 1055965eef222Smrg for libdir in $compile_rpath $finalize_rpath; do 1056065eef222Smrg if test -n "$hardcode_libdir_flag_spec"; then 1056165eef222Smrg if test -n "$hardcode_libdir_separator"; then 1056265eef222Smrg if test -z "$hardcode_libdirs"; then 10563b312a94cSmrg hardcode_libdirs=$libdir 1056465eef222Smrg else 1056565eef222Smrg # Just accumulate the unique libdirs. 1056665eef222Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1056765eef222Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1056865eef222Smrg ;; 1056965eef222Smrg *) 10570200d7199Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1057165eef222Smrg ;; 1057265eef222Smrg esac 1057365eef222Smrg fi 1057465eef222Smrg else 1057565eef222Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10576200d7199Smrg func_append rpath " $flag" 1057765eef222Smrg fi 1057865eef222Smrg elif test -n "$runpath_var"; then 1057965eef222Smrg case "$perm_rpath " in 10580ef981d24Smrg *" $libdir "*) ;; 10581200d7199Smrg *) func_append perm_rpath " $libdir" ;; 10582ef981d24Smrg esac 1058365eef222Smrg fi 1058465eef222Smrg case $host in 1058565eef222Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10586b312a94cSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 1058765eef222Smrg case :$dllsearchpath: in 1058865eef222Smrg *":$libdir:"*) ;; 1058965eef222Smrg ::) dllsearchpath=$libdir;; 10590200d7199Smrg *) func_append dllsearchpath ":$libdir";; 1059165eef222Smrg esac 1059265eef222Smrg case :$dllsearchpath: in 1059365eef222Smrg *":$testbindir:"*) ;; 1059465eef222Smrg ::) dllsearchpath=$testbindir;; 10595200d7199Smrg *) func_append dllsearchpath ":$testbindir";; 1059665eef222Smrg esac 1059765eef222Smrg ;; 1059865eef222Smrg esac 1059965eef222Smrg done 1060065eef222Smrg # Substitute the hardcoded libdirs into the rpath. 1060165eef222Smrg if test -n "$hardcode_libdir_separator" && 1060265eef222Smrg test -n "$hardcode_libdirs"; then 10603b312a94cSmrg libdir=$hardcode_libdirs 1060465eef222Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 1060565eef222Smrg fi 10606b312a94cSmrg compile_rpath=$rpath 1060765eef222Smrg 1060865eef222Smrg rpath= 1060965eef222Smrg hardcode_libdirs= 1061065eef222Smrg for libdir in $finalize_rpath; do 1061165eef222Smrg if test -n "$hardcode_libdir_flag_spec"; then 1061265eef222Smrg if test -n "$hardcode_libdir_separator"; then 1061365eef222Smrg if test -z "$hardcode_libdirs"; then 10614b312a94cSmrg hardcode_libdirs=$libdir 1061565eef222Smrg else 1061665eef222Smrg # Just accumulate the unique libdirs. 1061765eef222Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1061865eef222Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1061965eef222Smrg ;; 1062065eef222Smrg *) 10621200d7199Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1062265eef222Smrg ;; 1062365eef222Smrg esac 1062465eef222Smrg fi 1062565eef222Smrg else 1062665eef222Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10627200d7199Smrg func_append rpath " $flag" 1062865eef222Smrg fi 1062965eef222Smrg elif test -n "$runpath_var"; then 1063065eef222Smrg case "$finalize_perm_rpath " in 10631ef981d24Smrg *" $libdir "*) ;; 10632200d7199Smrg *) func_append finalize_perm_rpath " $libdir" ;; 10633ef981d24Smrg esac 10634ef981d24Smrg fi 1063565eef222Smrg done 1063665eef222Smrg # Substitute the hardcoded libdirs into the rpath. 1063765eef222Smrg if test -n "$hardcode_libdir_separator" && 1063865eef222Smrg test -n "$hardcode_libdirs"; then 10639b312a94cSmrg libdir=$hardcode_libdirs 1064065eef222Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 1064165eef222Smrg fi 10642b312a94cSmrg finalize_rpath=$rpath 10643ef981d24Smrg 10644b312a94cSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 1064565eef222Smrg # Transform all the library objects into standard objects. 1064656957a04Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1064756957a04Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1064865eef222Smrg fi 10649ef981d24Smrg 10650b312a94cSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10651ef981d24Smrg 1065265eef222Smrg # template prelinking step 1065365eef222Smrg if test -n "$prelink_cmds"; then 1065465eef222Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 1065565eef222Smrg fi 10656ef981d24Smrg 10657b312a94cSmrg wrappers_required=: 1065865eef222Smrg case $host in 1065956957a04Smrg *cegcc* | *mingw32ce*) 1066056957a04Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10661b312a94cSmrg wrappers_required=false 1066256957a04Smrg ;; 1066365eef222Smrg *cygwin* | *mingw* ) 10664b312a94cSmrg test yes = "$build_libtool_libs" || wrappers_required=false 1066565eef222Smrg ;; 1066665eef222Smrg *) 10667b312a94cSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10668b312a94cSmrg wrappers_required=false 1066965eef222Smrg fi 1067065eef222Smrg ;; 1067165eef222Smrg esac 10672b312a94cSmrg $wrappers_required || { 1067365eef222Smrg # Replace the output file specification. 1067456957a04Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10675b312a94cSmrg link_command=$compile_command$compile_rpath 10676ef981d24Smrg 1067765eef222Smrg # We have no uninstalled library dependencies, so finalize right now. 1067865eef222Smrg exit_status=0 1067965eef222Smrg func_show_eval "$link_command" 'exit_status=$?' 10680ef981d24Smrg 10681200d7199Smrg if test -n "$postlink_cmds"; then 10682200d7199Smrg func_to_tool_file "$output" 10683200d7199Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10684200d7199Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10685200d7199Smrg fi 10686200d7199Smrg 1068765eef222Smrg # Delete the generated files. 10688b312a94cSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 10689b312a94cSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 1069065eef222Smrg fi 10691ef981d24Smrg 1069265eef222Smrg exit $exit_status 10693b312a94cSmrg } 10694ef981d24Smrg 1069565eef222Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 1069665eef222Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 1069765eef222Smrg fi 1069865eef222Smrg if test -n "$finalize_shlibpath"; then 1069965eef222Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 1070065eef222Smrg fi 10701ef981d24Smrg 1070265eef222Smrg compile_var= 1070365eef222Smrg finalize_var= 1070465eef222Smrg if test -n "$runpath_var"; then 1070565eef222Smrg if test -n "$perm_rpath"; then 1070665eef222Smrg # We should set the runpath_var. 1070765eef222Smrg rpath= 1070865eef222Smrg for dir in $perm_rpath; do 10709200d7199Smrg func_append rpath "$dir:" 10710ef981d24Smrg done 1071165eef222Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10712ef981d24Smrg fi 1071365eef222Smrg if test -n "$finalize_perm_rpath"; then 1071465eef222Smrg # We should set the runpath_var. 1071565eef222Smrg rpath= 1071665eef222Smrg for dir in $finalize_perm_rpath; do 10717200d7199Smrg func_append rpath "$dir:" 1071865eef222Smrg done 1071965eef222Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 1072065eef222Smrg fi 1072165eef222Smrg fi 10722ef981d24Smrg 10723b312a94cSmrg if test yes = "$no_install"; then 1072465eef222Smrg # We don't need to create a wrapper script. 10725b312a94cSmrg link_command=$compile_var$compile_command$compile_rpath 1072665eef222Smrg # Replace the output file specification. 1072756957a04Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1072865eef222Smrg # Delete the old output file. 1072965eef222Smrg $opt_dry_run || $RM $output 1073065eef222Smrg # Link the executable and exit 1073165eef222Smrg func_show_eval "$link_command" 'exit $?' 10732200d7199Smrg 10733200d7199Smrg if test -n "$postlink_cmds"; then 10734200d7199Smrg func_to_tool_file "$output" 10735200d7199Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10736200d7199Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10737200d7199Smrg fi 10738200d7199Smrg 1073965eef222Smrg exit $EXIT_SUCCESS 1074065eef222Smrg fi 10741ef981d24Smrg 10742b312a94cSmrg case $hardcode_action,$fast_install in 10743b312a94cSmrg relink,*) 10744b312a94cSmrg # Fast installation is not supported 10745b312a94cSmrg link_command=$compile_var$compile_command$compile_rpath 10746b312a94cSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10747ef981d24Smrg 10748b312a94cSmrg func_warning "this platform does not like uninstalled shared libraries" 10749b312a94cSmrg func_warning "'$output' will be relinked during installation" 10750b312a94cSmrg ;; 10751b312a94cSmrg *,yes) 10752b312a94cSmrg link_command=$finalize_var$compile_command$finalize_rpath 10753b312a94cSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10754b312a94cSmrg ;; 10755b312a94cSmrg *,no) 10756b312a94cSmrg link_command=$compile_var$compile_command$compile_rpath 10757b312a94cSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10758b312a94cSmrg ;; 10759b312a94cSmrg *,needless) 10760b312a94cSmrg link_command=$finalize_var$compile_command$finalize_rpath 10761b312a94cSmrg relink_command= 10762b312a94cSmrg ;; 10763b312a94cSmrg esac 10764ef981d24Smrg 1076565eef222Smrg # Replace the output file specification. 1076656957a04Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10767ef981d24Smrg 1076865eef222Smrg # Delete the old output files. 1076965eef222Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10770ef981d24Smrg 1077165eef222Smrg func_show_eval "$link_command" 'exit $?' 10772ef981d24Smrg 10773200d7199Smrg if test -n "$postlink_cmds"; then 10774200d7199Smrg func_to_tool_file "$output_objdir/$outputname" 10775200d7199Smrg 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'` 10776200d7199Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10777200d7199Smrg fi 10778200d7199Smrg 1077965eef222Smrg # Now create the wrapper script. 1078065eef222Smrg func_verbose "creating $output" 10781ef981d24Smrg 1078265eef222Smrg # Quote the relink command for shipping. 1078365eef222Smrg if test -n "$relink_command"; then 1078465eef222Smrg # Preserve any variables that may affect compiler behavior 1078565eef222Smrg for var in $variables_saved_for_relink; do 1078665eef222Smrg if eval test -z \"\${$var+set}\"; then 1078765eef222Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1078865eef222Smrg elif eval var_value=\$$var; test -z "$var_value"; then 1078965eef222Smrg relink_command="$var=; export $var; $relink_command" 1079065eef222Smrg else 10791d5637ae9Smrg func_quote_arg pretty "$var_value" 10792d5637ae9Smrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 1079365eef222Smrg fi 1079465eef222Smrg done 10795d5637ae9Smrg func_quote eval cd "`pwd`" 10796d5637ae9Smrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 10797d5637ae9Smrg relink_command=$func_quote_arg_unquoted_result 1079865eef222Smrg fi 10799ef981d24Smrg 1080065eef222Smrg # Only actually do things if not in dry run mode. 1080165eef222Smrg $opt_dry_run || { 1080265eef222Smrg # win32 will think the script is a binary if it has 1080365eef222Smrg # a .exe suffix, so we strip it off here. 1080465eef222Smrg case $output in 1080565eef222Smrg *.exe) func_stripname '' '.exe' "$output" 1080665eef222Smrg output=$func_stripname_result ;; 1080765eef222Smrg esac 1080865eef222Smrg # test for cygwin because mv fails w/o .exe extensions 10809ef981d24Smrg case $host in 1081065eef222Smrg *cygwin*) 1081165eef222Smrg exeext=.exe 1081265eef222Smrg func_stripname '' '.exe' "$outputname" 1081365eef222Smrg outputname=$func_stripname_result ;; 1081465eef222Smrg *) exeext= ;; 10815ef981d24Smrg esac 1081665eef222Smrg case $host in 1081765eef222Smrg *cygwin* | *mingw* ) 1081865eef222Smrg func_dirname_and_basename "$output" "" "." 1081965eef222Smrg output_name=$func_basename_result 1082065eef222Smrg output_path=$func_dirname_result 10821b312a94cSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 10822b312a94cSmrg cwrapper=$output_path/$output_name.exe 1082365eef222Smrg $RM $cwrappersource $cwrapper 1082465eef222Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 1082565eef222Smrg 1082665eef222Smrg func_emit_cwrapperexe_src > $cwrappersource 1082765eef222Smrg 1082865eef222Smrg # The wrapper executable is built using the $host compiler, 1082965eef222Smrg # because it contains $host paths and files. If cross- 1083065eef222Smrg # compiling, it, like the target executable, must be 1083165eef222Smrg # executed on the $host or under an emulation environment. 1083265eef222Smrg $opt_dry_run || { 1083365eef222Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 1083465eef222Smrg $STRIP $cwrapper 1083565eef222Smrg } 10836ef981d24Smrg 1083765eef222Smrg # Now, create the wrapper script for func_source use: 1083865eef222Smrg func_ltwrapper_scriptname $cwrapper 1083965eef222Smrg $RM $func_ltwrapper_scriptname_result 1084065eef222Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 1084165eef222Smrg $opt_dry_run || { 1084265eef222Smrg # note: this script will not be executed, so do not chmod. 10843b312a94cSmrg if test "x$build" = "x$host"; then 1084465eef222Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10845ef981d24Smrg else 1084665eef222Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10847ef981d24Smrg fi 1084865eef222Smrg } 1084965eef222Smrg ;; 1085065eef222Smrg * ) 1085165eef222Smrg $RM $output 1085265eef222Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10853ef981d24Smrg 1085465eef222Smrg func_emit_wrapper no > $output 1085565eef222Smrg chmod +x $output 10856ef981d24Smrg ;; 10857ef981d24Smrg esac 1085865eef222Smrg } 1085965eef222Smrg exit $EXIT_SUCCESS 1086065eef222Smrg ;; 1086165eef222Smrg esac 10862ef981d24Smrg 1086365eef222Smrg # See if we need to build an old-fashioned archive. 1086465eef222Smrg for oldlib in $oldlibs; do 10865ef981d24Smrg 10866b312a94cSmrg case $build_libtool_libs in 10867b312a94cSmrg convenience) 10868b312a94cSmrg oldobjs="$libobjs_save $symfileobj" 10869b312a94cSmrg addlibs=$convenience 1087065eef222Smrg build_libtool_libs=no 10871b312a94cSmrg ;; 10872b312a94cSmrg module) 10873b312a94cSmrg oldobjs=$libobjs_save 10874b312a94cSmrg addlibs=$old_convenience 10875b312a94cSmrg build_libtool_libs=no 10876b312a94cSmrg ;; 10877b312a94cSmrg *) 1087865eef222Smrg oldobjs="$old_deplibs $non_pic_objects" 10879b312a94cSmrg $preload && test -f "$symfileobj" \ 10880b312a94cSmrg && func_append oldobjs " $symfileobj" 10881b312a94cSmrg addlibs=$old_convenience 10882b312a94cSmrg ;; 10883b312a94cSmrg esac 10884ef981d24Smrg 1088565eef222Smrg if test -n "$addlibs"; then 10886b312a94cSmrg gentop=$output_objdir/${outputname}x 10887200d7199Smrg func_append generated " $gentop" 10888ef981d24Smrg 1088965eef222Smrg func_extract_archives $gentop $addlibs 10890200d7199Smrg func_append oldobjs " $func_extract_archives_result" 1089165eef222Smrg fi 10892ef981d24Smrg 1089365eef222Smrg # Do each command in the archive commands. 10894b312a94cSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 1089565eef222Smrg cmds=$old_archive_from_new_cmds 1089665eef222Smrg else 10897ef981d24Smrg 1089865eef222Smrg # Add any objects from preloaded convenience libraries 1089965eef222Smrg if test -n "$dlprefiles"; then 10900b312a94cSmrg gentop=$output_objdir/${outputname}x 10901200d7199Smrg func_append generated " $gentop" 10902ef981d24Smrg 1090365eef222Smrg func_extract_archives $gentop $dlprefiles 10904200d7199Smrg func_append oldobjs " $func_extract_archives_result" 1090565eef222Smrg fi 10906ef981d24Smrg 1090765eef222Smrg # POSIX demands no paths to be encoded in archives. We have 1090865eef222Smrg # to avoid creating archives with duplicate basenames if we 1090965eef222Smrg # might have to extract them afterwards, e.g., when creating a 1091065eef222Smrg # static archive out of a convenience library, or when linking 1091165eef222Smrg # the entirety of a libtool archive into another (currently 1091265eef222Smrg # not supported by libtool). 1091365eef222Smrg if (for obj in $oldobjs 1091465eef222Smrg do 1091565eef222Smrg func_basename "$obj" 1091665eef222Smrg $ECHO "$func_basename_result" 1091765eef222Smrg done | sort | sort -uc >/dev/null 2>&1); then 1091865eef222Smrg : 1091965eef222Smrg else 1092056957a04Smrg echo "copying selected object files to avoid basename conflicts..." 10921b312a94cSmrg gentop=$output_objdir/${outputname}x 10922200d7199Smrg func_append generated " $gentop" 1092365eef222Smrg func_mkdir_p "$gentop" 1092465eef222Smrg save_oldobjs=$oldobjs 1092565eef222Smrg oldobjs= 1092665eef222Smrg counter=1 1092765eef222Smrg for obj in $save_oldobjs 1092865eef222Smrg do 1092965eef222Smrg func_basename "$obj" 10930b312a94cSmrg objbase=$func_basename_result 1093165eef222Smrg case " $oldobjs " in 1093265eef222Smrg " ") oldobjs=$obj ;; 1093365eef222Smrg *[\ /]"$objbase "*) 1093465eef222Smrg while :; do 1093565eef222Smrg # Make sure we don't pick an alternate name that also 1093665eef222Smrg # overlaps. 1093765eef222Smrg newobj=lt$counter-$objbase 1093865eef222Smrg func_arith $counter + 1 1093965eef222Smrg counter=$func_arith_result 1094065eef222Smrg case " $oldobjs " in 1094165eef222Smrg *[\ /]"$newobj "*) ;; 1094265eef222Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 1094365eef222Smrg esac 1094465eef222Smrg done 1094565eef222Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10946200d7199Smrg func_append oldobjs " $gentop/$newobj" 1094765eef222Smrg ;; 10948200d7199Smrg *) func_append oldobjs " $obj" ;; 1094965eef222Smrg esac 10950ef981d24Smrg done 10951ef981d24Smrg fi 10952b312a94cSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10953b312a94cSmrg tool_oldlib=$func_to_tool_file_result 1095465eef222Smrg eval cmds=\"$old_archive_cmds\" 10955ef981d24Smrg 1095665eef222Smrg func_len " $cmds" 1095765eef222Smrg len=$func_len_result 1095865eef222Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 1095965eef222Smrg cmds=$old_archive_cmds 10960200d7199Smrg elif test -n "$archiver_list_spec"; then 10961200d7199Smrg func_verbose "using command file archive linking..." 10962200d7199Smrg for obj in $oldobjs 10963200d7199Smrg do 10964200d7199Smrg func_to_tool_file "$obj" 10965200d7199Smrg $ECHO "$func_to_tool_file_result" 10966200d7199Smrg done > $output_objdir/$libname.libcmd 10967200d7199Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 10968200d7199Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10969200d7199Smrg cmds=$old_archive_cmds 1097065eef222Smrg else 1097165eef222Smrg # the command line is too long to link in one step, link in parts 1097265eef222Smrg func_verbose "using piecewise archive linking..." 1097365eef222Smrg save_RANLIB=$RANLIB 1097465eef222Smrg RANLIB=: 1097565eef222Smrg objlist= 1097665eef222Smrg concat_cmds= 1097765eef222Smrg save_oldobjs=$oldobjs 1097865eef222Smrg oldobjs= 1097965eef222Smrg # Is there a better way of finding the last object in the list? 1098065eef222Smrg for obj in $save_oldobjs 1098165eef222Smrg do 1098265eef222Smrg last_oldobj=$obj 1098365eef222Smrg done 1098465eef222Smrg eval test_cmds=\"$old_archive_cmds\" 1098565eef222Smrg func_len " $test_cmds" 1098665eef222Smrg len0=$func_len_result 1098765eef222Smrg len=$len0 1098865eef222Smrg for obj in $save_oldobjs 1098965eef222Smrg do 1099065eef222Smrg func_len " $obj" 1099165eef222Smrg func_arith $len + $func_len_result 1099265eef222Smrg len=$func_arith_result 1099365eef222Smrg func_append objlist " $obj" 1099465eef222Smrg if test "$len" -lt "$max_cmd_len"; then 1099565eef222Smrg : 1099665eef222Smrg else 1099765eef222Smrg # the above command should be used before it gets too long 1099865eef222Smrg oldobjs=$objlist 10999b312a94cSmrg if test "$obj" = "$last_oldobj"; then 1100065eef222Smrg RANLIB=$save_RANLIB 1100165eef222Smrg fi 1100265eef222Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 11003b312a94cSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 1100465eef222Smrg objlist= 1100565eef222Smrg len=$len0 1100665eef222Smrg fi 1100765eef222Smrg done 1100865eef222Smrg RANLIB=$save_RANLIB 1100965eef222Smrg oldobjs=$objlist 11010b312a94cSmrg if test -z "$oldobjs"; then 1101165eef222Smrg eval cmds=\"\$concat_cmds\" 1101265eef222Smrg else 1101365eef222Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 1101465eef222Smrg fi 1101565eef222Smrg fi 1101665eef222Smrg fi 1101765eef222Smrg func_execute_cmds "$cmds" 'exit $?' 11018ef981d24Smrg done 11019ef981d24Smrg 1102065eef222Smrg test -n "$generated" && \ 1102165eef222Smrg func_show_eval "${RM}r$generated" 11022ef981d24Smrg 1102365eef222Smrg # Now create the libtool archive. 1102465eef222Smrg case $output in 1102565eef222Smrg *.la) 1102665eef222Smrg old_library= 11027b312a94cSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 1102865eef222Smrg func_verbose "creating $output" 11029ef981d24Smrg 1103065eef222Smrg # Preserve any variables that may affect compiler behavior 1103165eef222Smrg for var in $variables_saved_for_relink; do 1103265eef222Smrg if eval test -z \"\${$var+set}\"; then 1103365eef222Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1103465eef222Smrg elif eval var_value=\$$var; test -z "$var_value"; then 1103565eef222Smrg relink_command="$var=; export $var; $relink_command" 11036ef981d24Smrg else 11037d5637ae9Smrg func_quote_arg pretty,unquoted "$var_value" 11038d5637ae9Smrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 11039ef981d24Smrg fi 1104065eef222Smrg done 1104165eef222Smrg # Quote the link command for shipping. 11042d5637ae9Smrg func_quote eval cd "`pwd`" 11043d5637ae9Smrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 11044d5637ae9Smrg func_quote_arg pretty,unquoted "$relink_command" 11045d5637ae9Smrg relink_command=$func_quote_arg_unquoted_result 11046b312a94cSmrg if test yes = "$hardcode_automatic"; then 1104765eef222Smrg relink_command= 1104865eef222Smrg fi 11049ef981d24Smrg 1105065eef222Smrg # Only create the output if not a dry run. 1105165eef222Smrg $opt_dry_run || { 1105265eef222Smrg for installed in no yes; do 11053b312a94cSmrg if test yes = "$installed"; then 1105465eef222Smrg if test -z "$install_libdir"; then 1105565eef222Smrg break 1105665eef222Smrg fi 11057b312a94cSmrg output=$output_objdir/${outputname}i 1105865eef222Smrg # Replace all uninstalled libtool libraries with the installed ones 1105965eef222Smrg newdependency_libs= 1106065eef222Smrg for deplib in $dependency_libs; do 1106165eef222Smrg case $deplib in 1106265eef222Smrg *.la) 1106365eef222Smrg func_basename "$deplib" 11064b312a94cSmrg name=$func_basename_result 11065b312a94cSmrg func_resolve_sysroot "$deplib" 11066b312a94cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 1106765eef222Smrg test -z "$libdir" && \ 11068b312a94cSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 11069200d7199Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 11070200d7199Smrg ;; 11071200d7199Smrg -L*) 11072200d7199Smrg func_stripname -L '' "$deplib" 11073200d7199Smrg func_replace_sysroot "$func_stripname_result" 11074200d7199Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 11075200d7199Smrg ;; 11076200d7199Smrg -R*) 11077200d7199Smrg func_stripname -R '' "$deplib" 11078200d7199Smrg func_replace_sysroot "$func_stripname_result" 11079200d7199Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 1108065eef222Smrg ;; 11081200d7199Smrg *) func_append newdependency_libs " $deplib" ;; 1108265eef222Smrg esac 1108365eef222Smrg done 11084b312a94cSmrg dependency_libs=$newdependency_libs 1108565eef222Smrg newdlfiles= 1108665eef222Smrg 1108765eef222Smrg for lib in $dlfiles; do 1108865eef222Smrg case $lib in 1108965eef222Smrg *.la) 1109065eef222Smrg func_basename "$lib" 11091b312a94cSmrg name=$func_basename_result 11092b312a94cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1109365eef222Smrg test -z "$libdir" && \ 11094b312a94cSmrg func_fatal_error "'$lib' is not a valid libtool archive" 11095200d7199Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 1109665eef222Smrg ;; 11097200d7199Smrg *) func_append newdlfiles " $lib" ;; 1109865eef222Smrg esac 1109965eef222Smrg done 11100b312a94cSmrg dlfiles=$newdlfiles 1110165eef222Smrg newdlprefiles= 1110265eef222Smrg for lib in $dlprefiles; do 1110365eef222Smrg case $lib in 1110465eef222Smrg *.la) 1110565eef222Smrg # Only pass preopened files to the pseudo-archive (for 1110665eef222Smrg # eventual linking with the app. that links it) if we 1110765eef222Smrg # didn't already link the preopened objects directly into 1110865eef222Smrg # the library: 1110965eef222Smrg func_basename "$lib" 11110b312a94cSmrg name=$func_basename_result 11111b312a94cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1111265eef222Smrg test -z "$libdir" && \ 11113b312a94cSmrg func_fatal_error "'$lib' is not a valid libtool archive" 11114200d7199Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 1111565eef222Smrg ;; 1111665eef222Smrg esac 1111765eef222Smrg done 11118b312a94cSmrg dlprefiles=$newdlprefiles 1111965eef222Smrg else 1112065eef222Smrg newdlfiles= 1112165eef222Smrg for lib in $dlfiles; do 1112265eef222Smrg case $lib in 11123b312a94cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1112465eef222Smrg *) abs=`pwd`"/$lib" ;; 1112565eef222Smrg esac 11126200d7199Smrg func_append newdlfiles " $abs" 1112765eef222Smrg done 11128b312a94cSmrg dlfiles=$newdlfiles 1112965eef222Smrg newdlprefiles= 1113065eef222Smrg for lib in $dlprefiles; do 1113165eef222Smrg case $lib in 11132b312a94cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1113365eef222Smrg *) abs=`pwd`"/$lib" ;; 1113465eef222Smrg esac 11135200d7199Smrg func_append newdlprefiles " $abs" 1113665eef222Smrg done 11137b312a94cSmrg dlprefiles=$newdlprefiles 1113865eef222Smrg fi 1113965eef222Smrg $RM $output 1114065eef222Smrg # place dlname in correct position for cygwin 1114156957a04Smrg # In fact, it would be nice if we could use this code for all target 1114256957a04Smrg # systems that can't hard-code library paths into their executables 1114356957a04Smrg # and that have no shared library path variable independent of PATH, 1114456957a04Smrg # but it turns out we can't easily determine that from inspecting 1114556957a04Smrg # libtool variables, so we have to hard-code the OSs to which it 1114656957a04Smrg # applies here; at the moment, that means platforms that use the PE 1114756957a04Smrg # object format with DLL files. See the long comment at the top of 1114856957a04Smrg # tests/bindir.at for full details. 1114965eef222Smrg tdlname=$dlname 1115065eef222Smrg case $host,$output,$installed,$module,$dlname in 1115156957a04Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 1115256957a04Smrg # If a -bindir argument was supplied, place the dll there. 11153b312a94cSmrg if test -n "$bindir"; then 1115456957a04Smrg func_relative_path "$install_libdir" "$bindir" 11155b312a94cSmrg tdlname=$func_relative_path_result/$dlname 1115656957a04Smrg else 1115756957a04Smrg # Otherwise fall back on heuristic. 1115856957a04Smrg tdlname=../bin/$dlname 1115956957a04Smrg fi 1116056957a04Smrg ;; 1116165eef222Smrg esac 1116265eef222Smrg $ECHO > $output "\ 1116365eef222Smrg# $outputname - a libtool library file 11164b312a94cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 1116565eef222Smrg# 1116665eef222Smrg# Please DO NOT delete this file! 1116765eef222Smrg# It is necessary for linking the library. 11168ef981d24Smrg 1116965eef222Smrg# The name that we can dlopen(3). 1117065eef222Smrgdlname='$tdlname' 11171ef981d24Smrg 1117265eef222Smrg# Names of this library. 1117365eef222Smrglibrary_names='$library_names' 11174ef981d24Smrg 1117565eef222Smrg# The name of the static archive. 1117665eef222Smrgold_library='$old_library' 11177ef981d24Smrg 11178b312a94cSmrg# Linker flags that cannot go in dependency_libs. 1117965eef222Smrginherited_linker_flags='$new_inherited_linker_flags' 11180ef981d24Smrg 1118165eef222Smrg# Libraries that this one depends upon. 1118265eef222Smrgdependency_libs='$dependency_libs' 11183ef981d24Smrg 1118465eef222Smrg# Names of additional weak libraries provided by this library 1118565eef222Smrgweak_library_names='$weak_libs' 11186ef981d24Smrg 1118765eef222Smrg# Version information for $libname. 1118865eef222Smrgcurrent=$current 1118965eef222Smrgage=$age 1119065eef222Smrgrevision=$revision 11191ef981d24Smrg 1119265eef222Smrg# Is this an already installed library? 1119365eef222Smrginstalled=$installed 11194ef981d24Smrg 1119565eef222Smrg# Should we warn about portability when linking against -modules? 1119665eef222Smrgshouldnotlink=$module 11197ef981d24Smrg 1119865eef222Smrg# Files to dlopen/dlpreopen 1119965eef222Smrgdlopen='$dlfiles' 1120065eef222Smrgdlpreopen='$dlprefiles' 11201ef981d24Smrg 1120265eef222Smrg# Directory that this library needs to be installed in: 1120365eef222Smrglibdir='$install_libdir'" 11204b312a94cSmrg if test no,yes = "$installed,$need_relink"; then 1120565eef222Smrg $ECHO >> $output "\ 1120665eef222Smrgrelink_command=\"$relink_command\"" 1120765eef222Smrg fi 1120865eef222Smrg done 1120965eef222Smrg } 11210ef981d24Smrg 1121165eef222Smrg # Do a symbolic link so that the libtool archive can be found in 1121265eef222Smrg # LD_LIBRARY_PATH before the program is installed. 1121365eef222Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 1121465eef222Smrg ;; 1121565eef222Smrg esac 1121665eef222Smrg exit $EXIT_SUCCESS 1121765eef222Smrg} 11218ef981d24Smrg 11219b312a94cSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 11220b312a94cSmrg func_mode_link ${1+"$@"} 11221b312a94cSmrgfi 11222ef981d24Smrg 11223ef981d24Smrg 1122465eef222Smrg# func_mode_uninstall arg... 1122565eef222Smrgfunc_mode_uninstall () 1122665eef222Smrg{ 11227b312a94cSmrg $debug_cmd 11228b312a94cSmrg 11229b312a94cSmrg RM=$nonopt 11230ef981d24Smrg files= 11231b312a94cSmrg rmforce=false 11232ef981d24Smrg exit_status=0 11233ef981d24Smrg 11234ef981d24Smrg # This variable tells wrapper scripts just to set variables rather 11235ef981d24Smrg # than running their programs. 11236b312a94cSmrg libtool_install_magic=$magic 11237ef981d24Smrg 11238ef981d24Smrg for arg 11239ef981d24Smrg do 11240ef981d24Smrg case $arg in 11241b312a94cSmrg -f) func_append RM " $arg"; rmforce=: ;; 11242200d7199Smrg -*) func_append RM " $arg" ;; 11243200d7199Smrg *) func_append files " $arg" ;; 11244ef981d24Smrg esac 11245ef981d24Smrg done 11246ef981d24Smrg 1124765eef222Smrg test -z "$RM" && \ 1124865eef222Smrg func_fatal_help "you must specify an RM program" 11249ef981d24Smrg 11250ef981d24Smrg rmdirs= 11251ef981d24Smrg 11252ef981d24Smrg for file in $files; do 1125365eef222Smrg func_dirname "$file" "" "." 11254b312a94cSmrg dir=$func_dirname_result 11255b312a94cSmrg if test . = "$dir"; then 11256b312a94cSmrg odir=$objdir 11257ef981d24Smrg else 11258b312a94cSmrg odir=$dir/$objdir 11259ef981d24Smrg fi 1126065eef222Smrg func_basename "$file" 11261b312a94cSmrg name=$func_basename_result 11262b312a94cSmrg test uninstall = "$opt_mode" && odir=$dir 11263ef981d24Smrg 11264200d7199Smrg # Remember odir for removal later, being careful to avoid duplicates 11265b312a94cSmrg if test clean = "$opt_mode"; then 11266ef981d24Smrg case " $rmdirs " in 11267200d7199Smrg *" $odir "*) ;; 11268200d7199Smrg *) func_append rmdirs " $odir" ;; 11269ef981d24Smrg esac 11270ef981d24Smrg fi 11271ef981d24Smrg 11272ef981d24Smrg # Don't error if the file doesn't exist and rm -f was used. 1127365eef222Smrg if { test -L "$file"; } >/dev/null 2>&1 || 1127465eef222Smrg { test -h "$file"; } >/dev/null 2>&1 || 1127565eef222Smrg test -f "$file"; then 11276ef981d24Smrg : 11277ef981d24Smrg elif test -d "$file"; then 11278ef981d24Smrg exit_status=1 11279ef981d24Smrg continue 11280b312a94cSmrg elif $rmforce; then 11281ef981d24Smrg continue 11282ef981d24Smrg fi 11283ef981d24Smrg 11284b312a94cSmrg rmfiles=$file 11285ef981d24Smrg 11286ef981d24Smrg case $name in 11287ef981d24Smrg *.la) 11288ef981d24Smrg # Possibly a libtool archive, so verify it. 1128965eef222Smrg if func_lalib_p "$file"; then 1129065eef222Smrg func_source $dir/$name 11291ef981d24Smrg 11292ef981d24Smrg # Delete the libtool libraries and symlinks. 11293ef981d24Smrg for n in $library_names; do 11294200d7199Smrg func_append rmfiles " $odir/$n" 11295ef981d24Smrg done 11296200d7199Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11297ef981d24Smrg 11298b312a94cSmrg case $opt_mode in 11299ef981d24Smrg clean) 11300200d7199Smrg case " $library_names " in 11301ef981d24Smrg *" $dlname "*) ;; 11302200d7199Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11303ef981d24Smrg esac 11304200d7199Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11305ef981d24Smrg ;; 11306ef981d24Smrg uninstall) 11307ef981d24Smrg if test -n "$library_names"; then 11308ef981d24Smrg # Do each command in the postuninstall commands. 11309b312a94cSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11310ef981d24Smrg fi 11311ef981d24Smrg 11312ef981d24Smrg if test -n "$old_library"; then 11313ef981d24Smrg # Do each command in the old_postuninstall commands. 11314b312a94cSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11315ef981d24Smrg fi 11316ef981d24Smrg # FIXME: should reinstall the best remaining shared library. 11317ef981d24Smrg ;; 11318ef981d24Smrg esac 11319ef981d24Smrg fi 11320ef981d24Smrg ;; 11321ef981d24Smrg 11322ef981d24Smrg *.lo) 11323ef981d24Smrg # Possibly a libtool object, so verify it. 1132465eef222Smrg if func_lalib_p "$file"; then 11325ef981d24Smrg 11326ef981d24Smrg # Read the .lo file 1132765eef222Smrg func_source $dir/$name 11328ef981d24Smrg 11329ef981d24Smrg # Add PIC object to the list of files to remove. 11330b312a94cSmrg if test -n "$pic_object" && test none != "$pic_object"; then 11331200d7199Smrg func_append rmfiles " $dir/$pic_object" 11332ef981d24Smrg fi 11333ef981d24Smrg 11334ef981d24Smrg # Add non-PIC object to the list of files to remove. 11335b312a94cSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11336200d7199Smrg func_append rmfiles " $dir/$non_pic_object" 11337ef981d24Smrg fi 11338ef981d24Smrg fi 11339ef981d24Smrg ;; 11340ef981d24Smrg 11341ef981d24Smrg *) 11342b312a94cSmrg if test clean = "$opt_mode"; then 11343ef981d24Smrg noexename=$name 11344ef981d24Smrg case $file in 11345ef981d24Smrg *.exe) 1134665eef222Smrg func_stripname '' '.exe' "$file" 1134765eef222Smrg file=$func_stripname_result 1134865eef222Smrg func_stripname '' '.exe' "$name" 1134965eef222Smrg noexename=$func_stripname_result 11350ef981d24Smrg # $file with .exe has already been added to rmfiles, 11351ef981d24Smrg # add $file without .exe 11352200d7199Smrg func_append rmfiles " $file" 11353ef981d24Smrg ;; 11354ef981d24Smrg esac 11355ef981d24Smrg # Do a test to see if this is a libtool program. 1135665eef222Smrg if func_ltwrapper_p "$file"; then 1135765eef222Smrg if func_ltwrapper_executable_p "$file"; then 1135865eef222Smrg func_ltwrapper_scriptname "$file" 1135965eef222Smrg relink_command= 1136065eef222Smrg func_source $func_ltwrapper_scriptname_result 11361200d7199Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 1136265eef222Smrg else 1136365eef222Smrg relink_command= 1136465eef222Smrg func_source $dir/$noexename 1136565eef222Smrg fi 11366ef981d24Smrg 11367ef981d24Smrg # note $name still contains .exe if it was in $file originally 11368ef981d24Smrg # as does the version of $file that was added into $rmfiles 11369b312a94cSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11370b312a94cSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 11371200d7199Smrg func_append rmfiles " $odir/lt-$name" 11372ef981d24Smrg fi 11373b312a94cSmrg if test "X$noexename" != "X$name"; then 11374b312a94cSmrg func_append rmfiles " $odir/lt-$noexename.c" 11375ef981d24Smrg fi 11376ef981d24Smrg fi 11377ef981d24Smrg fi 11378ef981d24Smrg ;; 11379ef981d24Smrg esac 1138065eef222Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11381ef981d24Smrg done 11382ef981d24Smrg 11383b312a94cSmrg # Try to remove the $objdir's in the directories where we deleted files 11384ef981d24Smrg for dir in $rmdirs; do 11385ef981d24Smrg if test -d "$dir"; then 1138665eef222Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11387ef981d24Smrg fi 11388ef981d24Smrg done 11389ef981d24Smrg 11390ef981d24Smrg exit $exit_status 1139165eef222Smrg} 11392ef981d24Smrg 11393b312a94cSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11394b312a94cSmrg func_mode_uninstall ${1+"$@"} 11395b312a94cSmrgfi 11396ef981d24Smrg 11397200d7199Smrgtest -z "$opt_mode" && { 11398b312a94cSmrg help=$generic_help 1139965eef222Smrg func_fatal_help "you must specify a MODE" 1140065eef222Smrg} 1140165eef222Smrg 1140265eef222Smrgtest -z "$exec_cmd" && \ 11403b312a94cSmrg func_fatal_help "invalid operation mode '$opt_mode'" 11404ef981d24Smrg 11405ef981d24Smrgif test -n "$exec_cmd"; then 1140665eef222Smrg eval exec "$exec_cmd" 11407ef981d24Smrg exit $EXIT_FAILURE 11408ef981d24Smrgfi 11409ef981d24Smrg 1141065eef222Smrgexit $exit_status 11411ef981d24Smrg 11412ef981d24Smrg 11413ef981d24Smrg# The TAGs below are defined such that we never get into a situation 11414b312a94cSmrg# where we disable both kinds of libraries. Given conflicting 11415ef981d24Smrg# choices, we go for a static library, that is the most portable, 11416ef981d24Smrg# since we can't tell whether shared libraries were disabled because 11417ef981d24Smrg# the user asked for that or because the platform doesn't support 11418ef981d24Smrg# them. This is particularly important on AIX, because we don't 11419ef981d24Smrg# support having both static and shared libraries enabled at the same 11420ef981d24Smrg# time on that platform, so we default to a shared-only configuration. 11421ef981d24Smrg# If a disable-shared tag is given, we'll fallback to a static-only 11422ef981d24Smrg# configuration. But we'll never go from static-only to shared-only. 11423ef981d24Smrg 11424ef981d24Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 1142565eef222Smrgbuild_libtool_libs=no 1142665eef222Smrgbuild_old_libs=yes 11427ef981d24Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 11428ef981d24Smrg 11429ef981d24Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 1143065eef222Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11431ef981d24Smrg# ### END LIBTOOL TAG CONFIG: disable-static 11432ef981d24Smrg 11433ef981d24Smrg# Local Variables: 11434ef981d24Smrg# mode:shell-script 11435ef981d24Smrg# sh-indentation:2 11436ef981d24Smrg# End: 11437