11e423a8fSmrg#! /usr/bin/env sh 2493f84f4Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 31e423a8fSmrg## by inline-source v2019-02-19.15 4a31a186aSmrg 51e423a8fSmrg# libtool (GNU libtool) 2.4.7 6493f84f4Smrg# Provide generalized library-building support services. 7a31a186aSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8a31a186aSmrg 91e423a8fSmrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 10a31a186aSmrg# This is free software; see the source for copying conditions. There is NO 11a31a186aSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12a31a186aSmrg 13a31a186aSmrg# GNU Libtool is free software; you can redistribute it and/or modify 14fe5e51b7Smrg# it under the terms of the GNU General Public License as published by 15fe5e51b7Smrg# the Free Software Foundation; either version 2 of the License, or 16fe5e51b7Smrg# (at your option) any later version. 17fe5e51b7Smrg# 18a31a186aSmrg# As a special exception to the GNU General Public License, 19a31a186aSmrg# if you distribute this file as part of a program or library that 20a31a186aSmrg# is built using GNU Libtool, you may include this file under the 21a31a186aSmrg# same distribution terms that you use for the rest of that program. 22a31a186aSmrg# 23a31a186aSmrg# GNU Libtool is distributed in the hope that it will be useful, but 24fe5e51b7Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25fe5e51b7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26fe5e51b7Smrg# General Public License for more details. 27fe5e51b7Smrg# 28fe5e51b7Smrg# You should have received a copy of the GNU General Public License 29493f84f4Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30643b027fSmrg 31fe5e51b7Smrg 320bb88ba4SmrgPROGRAM=libtool 33fe5e51b7SmrgPACKAGE=libtool 341e423a8fSmrgVERSION=2.4.7 351e423a8fSmrgpackage_revision=2.4.7 36fe5e51b7Smrg 37493f84f4Smrg 38493f84f4Smrg## ------ ## 39493f84f4Smrg## Usage. ## 40493f84f4Smrg## ------ ## 41493f84f4Smrg 42493f84f4Smrg# Run './libtool --help' for help with using this script from the 43493f84f4Smrg# command line. 44493f84f4Smrg 45493f84f4Smrg 46493f84f4Smrg## ------------------------------- ## 47493f84f4Smrg## User overridable command paths. ## 48493f84f4Smrg## ------------------------------- ## 49493f84f4Smrg 50493f84f4Smrg# After configure completes, it has a better idea of some of the 51493f84f4Smrg# shell tools we need than the defaults used by the functions shared 52493f84f4Smrg# with bootstrap, so set those here where they can still be over- 53493f84f4Smrg# ridden by the user, but otherwise take precedence. 54493f84f4Smrg 55493f84f4Smrg: ${AUTOCONF="autoconf"} 56493f84f4Smrg: ${AUTOMAKE="automake"} 57493f84f4Smrg 58493f84f4Smrg 59493f84f4Smrg## -------------------------- ## 60493f84f4Smrg## Source external libraries. ## 61493f84f4Smrg## -------------------------- ## 62493f84f4Smrg 63493f84f4Smrg# Much of our low-level functionality needs to be sourced from external 64493f84f4Smrg# libraries, which are installed to $pkgauxdir. 65493f84f4Smrg 66493f84f4Smrg# Set a version string for this script. 671e423a8fSmrgscriptversion=2019-02-19.15; # UTC 68493f84f4Smrg 69493f84f4Smrg# General shell script boiler plate, and helper functions. 70493f84f4Smrg# Written by Gary V. Vaughan, 2004 71493f84f4Smrg 721e423a8fSmrg# This is free software. There is NO warranty; not even for 731e423a8fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 741e423a8fSmrg# 751e423a8fSmrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 761e423a8fSmrg# 771e423a8fSmrg# This file is dual licensed under the terms of the MIT license 781e423a8fSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 791e423a8fSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 801e423a8fSmrg# these licenses when using or redistributing this software or any of 811e423a8fSmrg# the files within it. See the URLs above, or the file `LICENSE` 821e423a8fSmrg# included in the Bootstrap distribution for the full license texts. 83493f84f4Smrg 841e423a8fSmrg# Please report bugs or propose patches to: 851e423a8fSmrg# <https://github.com/gnulib-modules/bootstrap/issues> 86493f84f4Smrg 87493f84f4Smrg 88493f84f4Smrg## ------ ## 89493f84f4Smrg## Usage. ## 90493f84f4Smrg## ------ ## 91493f84f4Smrg 92493f84f4Smrg# Evaluate this file near the top of your script to gain access to 93493f84f4Smrg# the functions and variables defined here: 94493f84f4Smrg# 95493f84f4Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 96493f84f4Smrg# 97493f84f4Smrg# If you need to override any of the default environment variable 98493f84f4Smrg# settings, do that before evaluating this file. 99493f84f4Smrg 100493f84f4Smrg 101493f84f4Smrg## -------------------- ## 102493f84f4Smrg## Shell normalisation. ## 103493f84f4Smrg## -------------------- ## 104493f84f4Smrg 105493f84f4Smrg# Some shells need a little help to be as Bourne compatible as possible. 106493f84f4Smrg# Before doing anything else, make sure all that help has been provided! 107493f84f4Smrg 108493f84f4SmrgDUALCASE=1; export DUALCASE # for MKS sh 109493f84f4Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 110fe5e51b7Smrg emulate sh 111fe5e51b7Smrg NULLCMD=: 112493f84f4Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 113fe5e51b7Smrg # is contrary to our usage. Disable this feature. 114fe5e51b7Smrg alias -g '${1+"$@"}'='"$@"' 115fe5e51b7Smrg setopt NO_GLOB_SUBST 116fe5e51b7Smrgelse 117493f84f4Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 118fe5e51b7Smrgfi 1190bb88ba4Smrg 120493f84f4Smrg# NLS nuisances: We save the old values in case they are required later. 121493f84f4Smrg_G_user_locale= 122493f84f4Smrg_G_safe_locale= 123493f84f4Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 124fe5e51b7Smrgdo 125493f84f4Smrg eval "if test set = \"\${$_G_var+set}\"; then 126493f84f4Smrg save_$_G_var=\$$_G_var 127493f84f4Smrg $_G_var=C 128493f84f4Smrg export $_G_var 129493f84f4Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 130493f84f4Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 131fe5e51b7Smrg fi" 132fe5e51b7Smrgdone 1331e423a8fSmrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 1341e423a8fSmrg# in case the environment reset is needed later and the $save_* variant is not 1351e423a8fSmrg# defined (see the code above). 1361e423a8fSmrgLC_ALL=C 1371e423a8fSmrgLANGUAGE=C 1381e423a8fSmrgexport LANGUAGE LC_ALL 139a31a186aSmrg 140493f84f4Smrg# Make sure IFS has a sensible default 141493f84f4Smrgsp=' ' 142493f84f4Smrgnl=' 143493f84f4Smrg' 144493f84f4SmrgIFS="$sp $nl" 145493f84f4Smrg 146493f84f4Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 147493f84f4Smrgif test "${PATH_SEPARATOR+set}" != set; then 148493f84f4Smrg PATH_SEPARATOR=: 149493f84f4Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 150493f84f4Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 151493f84f4Smrg PATH_SEPARATOR=';' 152493f84f4Smrg } 153493f84f4Smrgfi 154a31a186aSmrg 155a31a186aSmrg 1561e423a8fSmrg# func_unset VAR 1571e423a8fSmrg# -------------- 1581e423a8fSmrg# Portably unset VAR. 1591e423a8fSmrg# In some shells, an 'unset VAR' statement leaves a non-zero return 1601e423a8fSmrg# status if VAR is already unset, which might be problematic if the 1611e423a8fSmrg# statement is used at the end of a function (thus poisoning its return 1621e423a8fSmrg# value) or when 'set -e' is active (causing even a spurious abort of 1631e423a8fSmrg# the script in this case). 1641e423a8fSmrgfunc_unset () 1651e423a8fSmrg{ 1661e423a8fSmrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 1671e423a8fSmrg} 1681e423a8fSmrg 1691e423a8fSmrg 1701e423a8fSmrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 1711e423a8fSmrgfunc_unset CDPATH 1721e423a8fSmrg 1731e423a8fSmrg# Make sure ${,E,F}GREP behave sanely. 1741e423a8fSmrgfunc_unset GREP_OPTIONS 1751e423a8fSmrg 176a31a186aSmrg 177493f84f4Smrg## ------------------------- ## 178493f84f4Smrg## Locate command utilities. ## 179493f84f4Smrg## ------------------------- ## 180493f84f4Smrg 181493f84f4Smrg 182493f84f4Smrg# func_executable_p FILE 183493f84f4Smrg# ---------------------- 184493f84f4Smrg# Check that FILE is an executable regular file. 185493f84f4Smrgfunc_executable_p () 186493f84f4Smrg{ 187493f84f4Smrg test -f "$1" && test -x "$1" 188493f84f4Smrg} 189493f84f4Smrg 190493f84f4Smrg 191493f84f4Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 192493f84f4Smrg# -------------------------------------------- 193493f84f4Smrg# Search for either a program that responds to --version with output 194493f84f4Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 195493f84f4Smrg# trying all the directories in PATH with each of the elements of 196493f84f4Smrg# PROGS_LIST. 197493f84f4Smrg# 198493f84f4Smrg# CHECK_FUNC should accept the path to a candidate program, and 199493f84f4Smrg# set $func_check_prog_result if it truncates its output less than 200493f84f4Smrg# $_G_path_prog_max characters. 201493f84f4Smrgfunc_path_progs () 202493f84f4Smrg{ 203493f84f4Smrg _G_progs_list=$1 204493f84f4Smrg _G_check_func=$2 205493f84f4Smrg _G_PATH=${3-"$PATH"} 206493f84f4Smrg 207493f84f4Smrg _G_path_prog_max=0 208493f84f4Smrg _G_path_prog_found=false 209ee82cb62Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 210493f84f4Smrg for _G_dir in $_G_PATH; do 211493f84f4Smrg IFS=$_G_save_IFS 212493f84f4Smrg test -z "$_G_dir" && _G_dir=. 213493f84f4Smrg for _G_prog_name in $_G_progs_list; do 214493f84f4Smrg for _exeext in '' .EXE; do 215493f84f4Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 216493f84f4Smrg func_executable_p "$_G_path_prog" || continue 217493f84f4Smrg case `"$_G_path_prog" --version 2>&1` in 218493f84f4Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 219493f84f4Smrg *) $_G_check_func $_G_path_prog 220493f84f4Smrg func_path_progs_result=$func_check_prog_result 221493f84f4Smrg ;; 222493f84f4Smrg esac 223493f84f4Smrg $_G_path_prog_found && break 3 224493f84f4Smrg done 225493f84f4Smrg done 226493f84f4Smrg done 227493f84f4Smrg IFS=$_G_save_IFS 228493f84f4Smrg test -z "$func_path_progs_result" && { 229493f84f4Smrg echo "no acceptable sed could be found in \$PATH" >&2 230493f84f4Smrg exit 1 231493f84f4Smrg } 232493f84f4Smrg} 233493f84f4Smrg 234493f84f4Smrg 235493f84f4Smrg# We want to be able to use the functions in this file before configure 236493f84f4Smrg# has figured out where the best binaries are kept, which means we have 237493f84f4Smrg# to search for them ourselves - except when the results are already set 238493f84f4Smrg# where we skip the searches. 239493f84f4Smrg 240493f84f4Smrg# Unless the user overrides by setting SED, search the path for either GNU 241493f84f4Smrg# sed, or the sed that truncates its output the least. 242493f84f4Smrgtest -z "$SED" && { 243493f84f4Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 244493f84f4Smrg for _G_i in 1 2 3 4 5 6 7; do 245493f84f4Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 246493f84f4Smrg done 247493f84f4Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 248493f84f4Smrg _G_sed_script= 249493f84f4Smrg 250493f84f4Smrg func_check_prog_sed () 251493f84f4Smrg { 252493f84f4Smrg _G_path_prog=$1 253493f84f4Smrg 254493f84f4Smrg _G_count=0 255493f84f4Smrg printf 0123456789 >conftest.in 256493f84f4Smrg while : 257493f84f4Smrg do 258493f84f4Smrg cat conftest.in conftest.in >conftest.tmp 259493f84f4Smrg mv conftest.tmp conftest.in 260493f84f4Smrg cp conftest.in conftest.nl 261493f84f4Smrg echo '' >> conftest.nl 262493f84f4Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 263493f84f4Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 264493f84f4Smrg _G_count=`expr $_G_count + 1` 265493f84f4Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 266493f84f4Smrg # Best one so far, save it but keep looking for a better one 267493f84f4Smrg func_check_prog_result=$_G_path_prog 268493f84f4Smrg _G_path_prog_max=$_G_count 269493f84f4Smrg fi 270493f84f4Smrg # 10*(2^10) chars as input seems more than enough 271493f84f4Smrg test 10 -lt "$_G_count" && break 272493f84f4Smrg done 273493f84f4Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 274493f84f4Smrg } 275493f84f4Smrg 2761e423a8fSmrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 277493f84f4Smrg rm -f conftest.sed 278493f84f4Smrg SED=$func_path_progs_result 279493f84f4Smrg} 280493f84f4Smrg 281493f84f4Smrg 282493f84f4Smrg# Unless the user overrides by setting GREP, search the path for either GNU 283493f84f4Smrg# grep, or the grep that truncates its output the least. 284493f84f4Smrgtest -z "$GREP" && { 285493f84f4Smrg func_check_prog_grep () 286493f84f4Smrg { 287493f84f4Smrg _G_path_prog=$1 288493f84f4Smrg 289493f84f4Smrg _G_count=0 290493f84f4Smrg _G_path_prog_max=0 291493f84f4Smrg printf 0123456789 >conftest.in 292493f84f4Smrg while : 293493f84f4Smrg do 294493f84f4Smrg cat conftest.in conftest.in >conftest.tmp 295493f84f4Smrg mv conftest.tmp conftest.in 296493f84f4Smrg cp conftest.in conftest.nl 297493f84f4Smrg echo 'GREP' >> conftest.nl 298493f84f4Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 299493f84f4Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 300493f84f4Smrg _G_count=`expr $_G_count + 1` 301493f84f4Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 302493f84f4Smrg # Best one so far, save it but keep looking for a better one 303493f84f4Smrg func_check_prog_result=$_G_path_prog 304493f84f4Smrg _G_path_prog_max=$_G_count 305493f84f4Smrg fi 306493f84f4Smrg # 10*(2^10) chars as input seems more than enough 307493f84f4Smrg test 10 -lt "$_G_count" && break 308493f84f4Smrg done 309493f84f4Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 310493f84f4Smrg } 311493f84f4Smrg 3121e423a8fSmrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 313493f84f4Smrg GREP=$func_path_progs_result 314493f84f4Smrg} 315493f84f4Smrg 316493f84f4Smrg 317493f84f4Smrg## ------------------------------- ## 318493f84f4Smrg## User overridable command paths. ## 319493f84f4Smrg## ------------------------------- ## 320493f84f4Smrg 321493f84f4Smrg# All uppercase variable names are used for environment variables. These 322493f84f4Smrg# variables can be overridden by the user before calling a script that 323493f84f4Smrg# uses them if a suitable command of that name is not already available 324493f84f4Smrg# in the command search PATH. 325a31a186aSmrg 326a31a186aSmrg: ${CP="cp -f"} 327493f84f4Smrg: ${ECHO="printf %s\n"} 328493f84f4Smrg: ${EGREP="$GREP -E"} 329493f84f4Smrg: ${FGREP="$GREP -F"} 330493f84f4Smrg: ${LN_S="ln -s"} 331a31a186aSmrg: ${MAKE="make"} 332a31a186aSmrg: ${MKDIR="mkdir"} 333a31a186aSmrg: ${MV="mv -f"} 334a31a186aSmrg: ${RM="rm -f"} 335a31a186aSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 336fe5e51b7Smrg 337a31a186aSmrg 338493f84f4Smrg## -------------------- ## 339493f84f4Smrg## Useful sed snippets. ## 340493f84f4Smrg## -------------------- ## 3410bb88ba4Smrg 342493f84f4Smrgsed_dirname='s|/[^/]*$||' 343493f84f4Smrgsed_basename='s|^.*/||' 3440bb88ba4Smrg 345493f84f4Smrg# Sed substitution that helps us do robust quoting. It backslashifies 346493f84f4Smrg# metacharacters that are still active within double-quoted strings. 347493f84f4Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 3480bb88ba4Smrg 349493f84f4Smrg# Same as above, but do not quote variable references. 350493f84f4Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 3510bb88ba4Smrg 352493f84f4Smrg# Sed substitution that turns a string into a regex matching for the 353493f84f4Smrg# string literally. 354493f84f4Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 3550bb88ba4Smrg 356493f84f4Smrg# Sed substitution that converts a w32 file name or path 357493f84f4Smrg# that contains forward slashes, into one that contains 358493f84f4Smrg# (escaped) backslashes. A very naive implementation. 359493f84f4Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 360493f84f4Smrg 361493f84f4Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 362493f84f4Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 363493f84f4Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 364493f84f4Smrg# expansion. Since each input '\' is now two '\'s, look for any number 365493f84f4Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 366493f84f4Smrg_G_bs='\\' 367493f84f4Smrg_G_bs2='\\\\' 368493f84f4Smrg_G_bs4='\\\\\\\\' 369493f84f4Smrg_G_dollar='\$' 370493f84f4Smrgsed_double_backslash="\ 371493f84f4Smrg s/$_G_bs4/&\\ 372493f84f4Smrg/g 373493f84f4Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 374493f84f4Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 375493f84f4Smrg s/\n//g" 3760bb88ba4Smrg 3771e423a8fSmrg# require_check_ifs_backslash 3781e423a8fSmrg# --------------------------- 3791e423a8fSmrg# Check if we can use backslash as IFS='\' separator, and set 3801e423a8fSmrg# $check_ifs_backshlash_broken to ':' or 'false'. 3811e423a8fSmrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 3821e423a8fSmrgfunc_require_check_ifs_backslash () 3831e423a8fSmrg{ 3841e423a8fSmrg _G_save_IFS=$IFS 3851e423a8fSmrg IFS='\' 3861e423a8fSmrg _G_check_ifs_backshlash='a\\b' 3871e423a8fSmrg for _G_i in $_G_check_ifs_backshlash 3881e423a8fSmrg do 3891e423a8fSmrg case $_G_i in 3901e423a8fSmrg a) 3911e423a8fSmrg check_ifs_backshlash_broken=false 3921e423a8fSmrg ;; 3931e423a8fSmrg '') 3941e423a8fSmrg break 3951e423a8fSmrg ;; 3961e423a8fSmrg *) 3971e423a8fSmrg check_ifs_backshlash_broken=: 3981e423a8fSmrg break 3991e423a8fSmrg ;; 4001e423a8fSmrg esac 4011e423a8fSmrg done 4021e423a8fSmrg IFS=$_G_save_IFS 4031e423a8fSmrg require_check_ifs_backslash=: 4041e423a8fSmrg} 4051e423a8fSmrg 4060bb88ba4Smrg 407493f84f4Smrg## ----------------- ## 408493f84f4Smrg## Global variables. ## 409493f84f4Smrg## ----------------- ## 4100bb88ba4Smrg 411493f84f4Smrg# Except for the global variables explicitly listed below, the following 412493f84f4Smrg# functions in the '^func_' namespace, and the '^require_' namespace 413493f84f4Smrg# variables initialised in the 'Resource management' section, sourcing 414493f84f4Smrg# this file will not pollute your global namespace with anything 415493f84f4Smrg# else. There's no portable way to scope variables in Bourne shell 416493f84f4Smrg# though, so actually running these functions will sometimes place 417493f84f4Smrg# results into a variable named after the function, and often use 418493f84f4Smrg# temporary variables in the '^_G_' namespace. If you are careful to 419493f84f4Smrg# avoid using those namespaces casually in your sourcing script, things 420493f84f4Smrg# should continue to work as you expect. And, of course, you can freely 421493f84f4Smrg# overwrite any of the functions or variables defined here before 422493f84f4Smrg# calling anything to customize them. 4230bb88ba4Smrg 424493f84f4SmrgEXIT_SUCCESS=0 425493f84f4SmrgEXIT_FAILURE=1 426493f84f4SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 427493f84f4SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 428eda3803bSmrg 429493f84f4Smrg# Allow overriding, eg assuming that you follow the convention of 430493f84f4Smrg# putting '$debug_cmd' at the start of all your functions, you can get 431493f84f4Smrg# bash to show function call trace with: 432493f84f4Smrg# 433493f84f4Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 434493f84f4Smrgdebug_cmd=${debug_cmd-":"} 435493f84f4Smrgexit_cmd=: 436a31a186aSmrg 437493f84f4Smrg# By convention, finish your script with: 438493f84f4Smrg# 439493f84f4Smrg# exit $exit_status 440493f84f4Smrg# 441493f84f4Smrg# so that you can set exit_status to non-zero if you want to indicate 442493f84f4Smrg# something went wrong during execution without actually bailing out at 443493f84f4Smrg# the point of failure. 444493f84f4Smrgexit_status=$EXIT_SUCCESS 4450bb88ba4Smrg 446493f84f4Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 447493f84f4Smrg# is ksh but when the shell is invoked as "sh" and the current value of 448493f84f4Smrg# the _XPG environment variable is not equal to 1 (one), the special 449493f84f4Smrg# positional parameter $0, within a function call, is the name of the 450493f84f4Smrg# function. 451493f84f4Smrgprogpath=$0 452a31a186aSmrg 453493f84f4Smrg# The name of this program. 454493f84f4Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 455a31a186aSmrg 456493f84f4Smrg# Make sure we have an absolute progpath for reexecution: 457a31a186aSmrgcase $progpath in 458a31a186aSmrg [\\/]*|[A-Za-z]:\\*) ;; 459a31a186aSmrg *[\\/]*) 460493f84f4Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 461a31a186aSmrg progdir=`cd "$progdir" && pwd` 462493f84f4Smrg progpath=$progdir/$progname 463a31a186aSmrg ;; 464a31a186aSmrg *) 465493f84f4Smrg _G_IFS=$IFS 4660bb88ba4Smrg IFS=${PATH_SEPARATOR-:} 467a31a186aSmrg for progdir in $PATH; do 468493f84f4Smrg IFS=$_G_IFS 469a31a186aSmrg test -x "$progdir/$progname" && break 470a31a186aSmrg done 471493f84f4Smrg IFS=$_G_IFS 472a31a186aSmrg test -n "$progdir" || progdir=`pwd` 473493f84f4Smrg progpath=$progdir/$progname 474a31a186aSmrg ;; 475a31a186aSmrgesac 476a31a186aSmrg 477a31a186aSmrg 478493f84f4Smrg## ----------------- ## 479493f84f4Smrg## Standard options. ## 480493f84f4Smrg## ----------------- ## 4810bb88ba4Smrg 482493f84f4Smrg# The following options affect the operation of the functions defined 483493f84f4Smrg# below, and should be set appropriately depending on run-time para- 484493f84f4Smrg# meters passed on the command line. 485a31a186aSmrg 486a31a186aSmrgopt_dry_run=false 487a31a186aSmrgopt_quiet=false 488a31a186aSmrgopt_verbose=false 489a31a186aSmrg 490493f84f4Smrg# Categories 'all' and 'none' are always available. Append any others 491493f84f4Smrg# you will pass as the first argument to func_warning from your own 492493f84f4Smrg# code. 493493f84f4Smrgwarning_categories= 494a31a186aSmrg 495493f84f4Smrg# By default, display warnings according to 'opt_warning_types'. Set 496493f84f4Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 497493f84f4Smrg# treat the next displayed warning as a fatal error. 498493f84f4Smrgwarning_func=func_warn_and_continue 499a31a186aSmrg 500493f84f4Smrg# Set to 'all' to display all warnings, 'none' to suppress all 501493f84f4Smrg# warnings, or a space delimited list of some subset of 502493f84f4Smrg# 'warning_categories' to display only the listed warnings. 503493f84f4Smrgopt_warning_types=all 504a31a186aSmrg 5050bb88ba4Smrg 506493f84f4Smrg## -------------------- ## 507493f84f4Smrg## Resource management. ## 508493f84f4Smrg## -------------------- ## 509a31a186aSmrg 510493f84f4Smrg# This section contains definitions for functions that each ensure a 511493f84f4Smrg# particular resource (a file, or a non-empty configuration variable for 512493f84f4Smrg# example) is available, and if appropriate to extract default values 513493f84f4Smrg# from pertinent package files. Call them using their associated 514493f84f4Smrg# 'require_*' variable to ensure that they are executed, at most, once. 515493f84f4Smrg# 516493f84f4Smrg# It's entirely deliberate that calling these functions can set 517493f84f4Smrg# variables that don't obey the namespace limitations obeyed by the rest 518493f84f4Smrg# of this file, in order that that they be as useful as possible to 519493f84f4Smrg# callers. 520a31a186aSmrg 521a31a186aSmrg 522493f84f4Smrg# require_term_colors 523493f84f4Smrg# ------------------- 524493f84f4Smrg# Allow display of bold text on terminals that support it. 525493f84f4Smrgrequire_term_colors=func_require_term_colors 526493f84f4Smrgfunc_require_term_colors () 527a31a186aSmrg{ 528493f84f4Smrg $debug_cmd 529493f84f4Smrg 530493f84f4Smrg test -t 1 && { 531493f84f4Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 532493f84f4Smrg # precedence, because most terminfo databases neglect to describe 533493f84f4Smrg # whether color sequences are supported. 534493f84f4Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 535493f84f4Smrg 536493f84f4Smrg if test 1 = "$USE_ANSI_COLORS"; then 537493f84f4Smrg # Standard ANSI escape sequences 538493f84f4Smrg tc_reset='[0m' 539493f84f4Smrg tc_bold='[1m'; tc_standout='[7m' 540493f84f4Smrg tc_red='[31m'; tc_green='[32m' 541493f84f4Smrg tc_blue='[34m'; tc_cyan='[36m' 542493f84f4Smrg else 543493f84f4Smrg # Otherwise trust the terminfo database after all. 544493f84f4Smrg test -n "`tput sgr0 2>/dev/null`" && { 545493f84f4Smrg tc_reset=`tput sgr0` 546493f84f4Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 547493f84f4Smrg tc_standout=$tc_bold 548493f84f4Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 549493f84f4Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 550493f84f4Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 551493f84f4Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 552493f84f4Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 553493f84f4Smrg } 554493f84f4Smrg fi 555493f84f4Smrg } 556a31a186aSmrg 557493f84f4Smrg require_term_colors=: 558a31a186aSmrg} 559a31a186aSmrg 560a31a186aSmrg 561493f84f4Smrg## ----------------- ## 562493f84f4Smrg## Function library. ## 563493f84f4Smrg## ----------------- ## 564493f84f4Smrg 565493f84f4Smrg# This section contains a variety of useful functions to call in your 566493f84f4Smrg# scripts. Take note of the portable wrappers for features provided by 567493f84f4Smrg# some modern shells, which will fall back to slower equivalents on 568493f84f4Smrg# less featureful shells. 569493f84f4Smrg 570493f84f4Smrg 571493f84f4Smrg# func_append VAR VALUE 572493f84f4Smrg# --------------------- 573493f84f4Smrg# Append VALUE onto the existing contents of VAR. 574493f84f4Smrg 575493f84f4Smrg # We should try to minimise forks, especially on Windows where they are 576493f84f4Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 577493f84f4Smrg # being used: 578493f84f4Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 579493f84f4Smrg : ${_G_HAVE_ARITH_OP="yes"} 580493f84f4Smrg : ${_G_HAVE_XSI_OPS="yes"} 581493f84f4Smrg # The += operator was introduced in bash 3.1 582493f84f4Smrg case $BASH_VERSION in 583493f84f4Smrg [12].* | 3.0 | 3.0*) ;; 584493f84f4Smrg *) 585493f84f4Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 586493f84f4Smrg ;; 587493f84f4Smrg esac 588493f84f4Smrg fi 589493f84f4Smrg 590493f84f4Smrg # _G_HAVE_PLUSEQ_OP 591493f84f4Smrg # Can be empty, in which case the shell is probed, "yes" if += is 592493f84f4Smrg # useable or anything else if it does not work. 593493f84f4Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 594493f84f4Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 595493f84f4Smrg && _G_HAVE_PLUSEQ_OP=yes 596493f84f4Smrg 597493f84f4Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 598493f84f4Smrgthen 599493f84f4Smrg # This is an XSI compatible shell, allowing a faster implementation... 600493f84f4Smrg eval 'func_append () 601493f84f4Smrg { 602493f84f4Smrg $debug_cmd 603493f84f4Smrg 604493f84f4Smrg eval "$1+=\$2" 605493f84f4Smrg }' 606493f84f4Smrgelse 607493f84f4Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 608493f84f4Smrg func_append () 609493f84f4Smrg { 610493f84f4Smrg $debug_cmd 611493f84f4Smrg 612493f84f4Smrg eval "$1=\$$1\$2" 613493f84f4Smrg } 614493f84f4Smrgfi 615493f84f4Smrg 616493f84f4Smrg 617493f84f4Smrg# func_append_quoted VAR VALUE 618493f84f4Smrg# ---------------------------- 619493f84f4Smrg# Quote VALUE and append to the end of shell variable VAR, separated 620493f84f4Smrg# by a space. 621493f84f4Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 622493f84f4Smrg eval 'func_append_quoted () 623493f84f4Smrg { 624493f84f4Smrg $debug_cmd 625493f84f4Smrg 6261e423a8fSmrg func_quote_arg pretty "$2" 6271e423a8fSmrg eval "$1+=\\ \$func_quote_arg_result" 628493f84f4Smrg }' 629493f84f4Smrgelse 630493f84f4Smrg func_append_quoted () 631493f84f4Smrg { 632493f84f4Smrg $debug_cmd 633493f84f4Smrg 6341e423a8fSmrg func_quote_arg pretty "$2" 6351e423a8fSmrg eval "$1=\$$1\\ \$func_quote_arg_result" 636493f84f4Smrg } 637493f84f4Smrgfi 638493f84f4Smrg 639493f84f4Smrg 640493f84f4Smrg# func_append_uniq VAR VALUE 641493f84f4Smrg# -------------------------- 642493f84f4Smrg# Append unique VALUE onto the existing contents of VAR, assuming 643493f84f4Smrg# entries are delimited by the first character of VALUE. For example: 644493f84f4Smrg# 645493f84f4Smrg# func_append_uniq options " --another-option option-argument" 646493f84f4Smrg# 647493f84f4Smrg# will only append to $options if " --another-option option-argument " 648493f84f4Smrg# is not already present somewhere in $options already (note spaces at 649493f84f4Smrg# each end implied by leading space in second argument). 650493f84f4Smrgfunc_append_uniq () 651493f84f4Smrg{ 652493f84f4Smrg $debug_cmd 653493f84f4Smrg 654493f84f4Smrg eval _G_current_value='`$ECHO $'$1'`' 655493f84f4Smrg _G_delim=`expr "$2" : '\(.\)'` 656493f84f4Smrg 657493f84f4Smrg case $_G_delim$_G_current_value$_G_delim in 658493f84f4Smrg *"$2$_G_delim"*) ;; 659493f84f4Smrg *) func_append "$@" ;; 660493f84f4Smrg esac 661493f84f4Smrg} 662493f84f4Smrg 663493f84f4Smrg 664493f84f4Smrg# func_arith TERM... 665493f84f4Smrg# ------------------ 666493f84f4Smrg# Set func_arith_result to the result of evaluating TERMs. 667493f84f4Smrg test -z "$_G_HAVE_ARITH_OP" \ 668493f84f4Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 669493f84f4Smrg && _G_HAVE_ARITH_OP=yes 670493f84f4Smrg 671493f84f4Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 672493f84f4Smrg eval 'func_arith () 673493f84f4Smrg { 674493f84f4Smrg $debug_cmd 675493f84f4Smrg 676493f84f4Smrg func_arith_result=$(( $* )) 677493f84f4Smrg }' 678493f84f4Smrgelse 679493f84f4Smrg func_arith () 680493f84f4Smrg { 681493f84f4Smrg $debug_cmd 682493f84f4Smrg 683493f84f4Smrg func_arith_result=`expr "$@"` 684493f84f4Smrg } 685493f84f4Smrgfi 686493f84f4Smrg 687493f84f4Smrg 688493f84f4Smrg# func_basename FILE 689493f84f4Smrg# ------------------ 690493f84f4Smrg# Set func_basename_result to FILE with everything up to and including 691493f84f4Smrg# the last / stripped. 692493f84f4Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 693493f84f4Smrg # If this shell supports suffix pattern removal, then use it to avoid 694493f84f4Smrg # forking. Hide the definitions single quotes in case the shell chokes 695493f84f4Smrg # on unsupported syntax... 696493f84f4Smrg _b='func_basename_result=${1##*/}' 697493f84f4Smrg _d='case $1 in 698493f84f4Smrg */*) func_dirname_result=${1%/*}$2 ;; 699493f84f4Smrg * ) func_dirname_result=$3 ;; 700493f84f4Smrg esac' 701493f84f4Smrg 702493f84f4Smrgelse 703493f84f4Smrg # ...otherwise fall back to using sed. 704493f84f4Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 705493f84f4Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 706493f84f4Smrg if test "X$func_dirname_result" = "X$1"; then 707493f84f4Smrg func_dirname_result=$3 708493f84f4Smrg else 709493f84f4Smrg func_append func_dirname_result "$2" 710493f84f4Smrg fi' 711493f84f4Smrgfi 712493f84f4Smrg 713493f84f4Smrgeval 'func_basename () 714493f84f4Smrg{ 715493f84f4Smrg $debug_cmd 716493f84f4Smrg 717493f84f4Smrg '"$_b"' 718493f84f4Smrg}' 719493f84f4Smrg 720493f84f4Smrg 721493f84f4Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 722493f84f4Smrg# ------------------------------------------- 723493f84f4Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 724493f84f4Smrg# otherwise set result to NONDIR_REPLACEMENT. 725493f84f4Smrgeval 'func_dirname () 726493f84f4Smrg{ 727493f84f4Smrg $debug_cmd 728493f84f4Smrg 729493f84f4Smrg '"$_d"' 730493f84f4Smrg}' 731493f84f4Smrg 732493f84f4Smrg 733493f84f4Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 734493f84f4Smrg# -------------------------------------------------------- 735493f84f4Smrg# Perform func_basename and func_dirname in a single function 736493f84f4Smrg# call: 737493f84f4Smrg# dirname: Compute the dirname of FILE. If nonempty, 738493f84f4Smrg# add APPEND to the result, otherwise set result 739493f84f4Smrg# to NONDIR_REPLACEMENT. 740493f84f4Smrg# value returned in "$func_dirname_result" 741493f84f4Smrg# basename: Compute filename of FILE. 742493f84f4Smrg# value retuned in "$func_basename_result" 743493f84f4Smrg# For efficiency, we do not delegate to the functions above but instead 744493f84f4Smrg# duplicate the functionality here. 745493f84f4Smrgeval 'func_dirname_and_basename () 746493f84f4Smrg{ 747493f84f4Smrg $debug_cmd 748493f84f4Smrg 749493f84f4Smrg '"$_b"' 750493f84f4Smrg '"$_d"' 751493f84f4Smrg}' 752493f84f4Smrg 753493f84f4Smrg 754493f84f4Smrg# func_echo ARG... 755493f84f4Smrg# ---------------- 756493f84f4Smrg# Echo program name prefixed message. 757493f84f4Smrgfunc_echo () 758493f84f4Smrg{ 759493f84f4Smrg $debug_cmd 760493f84f4Smrg 761493f84f4Smrg _G_message=$* 762493f84f4Smrg 763493f84f4Smrg func_echo_IFS=$IFS 764493f84f4Smrg IFS=$nl 765493f84f4Smrg for _G_line in $_G_message; do 766493f84f4Smrg IFS=$func_echo_IFS 767493f84f4Smrg $ECHO "$progname: $_G_line" 768493f84f4Smrg done 769493f84f4Smrg IFS=$func_echo_IFS 770493f84f4Smrg} 771493f84f4Smrg 772493f84f4Smrg 773493f84f4Smrg# func_echo_all ARG... 774493f84f4Smrg# -------------------- 775493f84f4Smrg# Invoke $ECHO with all args, space-separated. 776493f84f4Smrgfunc_echo_all () 777493f84f4Smrg{ 778493f84f4Smrg $ECHO "$*" 779493f84f4Smrg} 780493f84f4Smrg 781493f84f4Smrg 782493f84f4Smrg# func_echo_infix_1 INFIX ARG... 783493f84f4Smrg# ------------------------------ 784493f84f4Smrg# Echo program name, followed by INFIX on the first line, with any 785493f84f4Smrg# additional lines not showing INFIX. 786493f84f4Smrgfunc_echo_infix_1 () 787493f84f4Smrg{ 788493f84f4Smrg $debug_cmd 789493f84f4Smrg 790493f84f4Smrg $require_term_colors 791493f84f4Smrg 792493f84f4Smrg _G_infix=$1; shift 793493f84f4Smrg _G_indent=$_G_infix 794493f84f4Smrg _G_prefix="$progname: $_G_infix: " 795493f84f4Smrg _G_message=$* 796493f84f4Smrg 797493f84f4Smrg # Strip color escape sequences before counting printable length 798493f84f4Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 799493f84f4Smrg do 800493f84f4Smrg test -n "$_G_tc" && { 801493f84f4Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 802493f84f4Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 803493f84f4Smrg } 804493f84f4Smrg done 805493f84f4Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 806493f84f4Smrg 807493f84f4Smrg func_echo_infix_1_IFS=$IFS 808493f84f4Smrg IFS=$nl 809493f84f4Smrg for _G_line in $_G_message; do 810493f84f4Smrg IFS=$func_echo_infix_1_IFS 811493f84f4Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 812493f84f4Smrg _G_prefix=$_G_indent 813493f84f4Smrg done 814493f84f4Smrg IFS=$func_echo_infix_1_IFS 815493f84f4Smrg} 816493f84f4Smrg 817493f84f4Smrg 818493f84f4Smrg# func_error ARG... 819493f84f4Smrg# ----------------- 820493f84f4Smrg# Echo program name prefixed message to standard error. 821493f84f4Smrgfunc_error () 822493f84f4Smrg{ 823493f84f4Smrg $debug_cmd 824493f84f4Smrg 825493f84f4Smrg $require_term_colors 826493f84f4Smrg 827493f84f4Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 828493f84f4Smrg} 829493f84f4Smrg 830493f84f4Smrg 831493f84f4Smrg# func_fatal_error ARG... 832493f84f4Smrg# ----------------------- 833493f84f4Smrg# Echo program name prefixed message to standard error, and exit. 834493f84f4Smrgfunc_fatal_error () 835493f84f4Smrg{ 836493f84f4Smrg $debug_cmd 837493f84f4Smrg 838493f84f4Smrg func_error "$*" 839493f84f4Smrg exit $EXIT_FAILURE 840493f84f4Smrg} 841493f84f4Smrg 842493f84f4Smrg 843493f84f4Smrg# func_grep EXPRESSION FILENAME 844493f84f4Smrg# ----------------------------- 845a31a186aSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 846a31a186aSmrgfunc_grep () 847a31a186aSmrg{ 848493f84f4Smrg $debug_cmd 849493f84f4Smrg 850a31a186aSmrg $GREP "$1" "$2" >/dev/null 2>&1 851a31a186aSmrg} 852a31a186aSmrg 853a31a186aSmrg 854493f84f4Smrg# func_len STRING 855493f84f4Smrg# --------------- 856493f84f4Smrg# Set func_len_result to the length of STRING. STRING may not 857493f84f4Smrg# start with a hyphen. 858493f84f4Smrg test -z "$_G_HAVE_XSI_OPS" \ 859493f84f4Smrg && (eval 'x=a/b/c; 860493f84f4Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 861493f84f4Smrg && _G_HAVE_XSI_OPS=yes 862493f84f4Smrg 863493f84f4Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 864493f84f4Smrg eval 'func_len () 865493f84f4Smrg { 866493f84f4Smrg $debug_cmd 867493f84f4Smrg 868493f84f4Smrg func_len_result=${#1} 869493f84f4Smrg }' 870493f84f4Smrgelse 871493f84f4Smrg func_len () 872493f84f4Smrg { 873493f84f4Smrg $debug_cmd 874493f84f4Smrg 875493f84f4Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 876493f84f4Smrg } 877493f84f4Smrgfi 878493f84f4Smrg 879493f84f4Smrg 880493f84f4Smrg# func_mkdir_p DIRECTORY-PATH 881493f84f4Smrg# --------------------------- 882a31a186aSmrg# Make sure the entire path to DIRECTORY-PATH is available. 883a31a186aSmrgfunc_mkdir_p () 884a31a186aSmrg{ 885493f84f4Smrg $debug_cmd 886a31a186aSmrg 887493f84f4Smrg _G_directory_path=$1 888493f84f4Smrg _G_dir_list= 889a31a186aSmrg 890493f84f4Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 891493f84f4Smrg 892493f84f4Smrg # Protect directory names starting with '-' 893493f84f4Smrg case $_G_directory_path in 894493f84f4Smrg -*) _G_directory_path=./$_G_directory_path ;; 895a31a186aSmrg esac 896a31a186aSmrg 897a31a186aSmrg # While some portion of DIR does not yet exist... 898493f84f4Smrg while test ! -d "$_G_directory_path"; do 899a31a186aSmrg # ...make a list in topmost first order. Use a colon delimited 900a31a186aSmrg # list incase some portion of path contains whitespace. 901493f84f4Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 902a31a186aSmrg 903a31a186aSmrg # If the last portion added has no slash in it, the list is done 904493f84f4Smrg case $_G_directory_path in */*) ;; *) break ;; esac 905a31a186aSmrg 906a31a186aSmrg # ...otherwise throw away the child directory and loop 907493f84f4Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 908a31a186aSmrg done 909493f84f4Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 910a31a186aSmrg 911493f84f4Smrg func_mkdir_p_IFS=$IFS; IFS=: 912493f84f4Smrg for _G_dir in $_G_dir_list; do 913493f84f4Smrg IFS=$func_mkdir_p_IFS 914493f84f4Smrg # mkdir can fail with a 'File exist' error if two processes 915a31a186aSmrg # try to create one of the directories concurrently. Don't 916a31a186aSmrg # stop in that case! 917493f84f4Smrg $MKDIR "$_G_dir" 2>/dev/null || : 918a31a186aSmrg done 919493f84f4Smrg IFS=$func_mkdir_p_IFS 920a31a186aSmrg 921a31a186aSmrg # Bail out if we (or some other process) failed to create a directory. 922493f84f4Smrg test -d "$_G_directory_path" || \ 923493f84f4Smrg func_fatal_error "Failed to create '$1'" 924a31a186aSmrg fi 925a31a186aSmrg} 926fe5e51b7Smrg 927fe5e51b7Smrg 928493f84f4Smrg# func_mktempdir [BASENAME] 929493f84f4Smrg# ------------------------- 930fe5e51b7Smrg# Make a temporary directory that won't clash with other running 931fe5e51b7Smrg# libtool processes, and avoids race conditions if possible. If 932493f84f4Smrg# given, BASENAME is the basename for that directory. 933fe5e51b7Smrgfunc_mktempdir () 934fe5e51b7Smrg{ 935493f84f4Smrg $debug_cmd 936493f84f4Smrg 937493f84f4Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 938fe5e51b7Smrg 939493f84f4Smrg if test : = "$opt_dry_run"; then 940fe5e51b7Smrg # Return a directory name, but don't create it in dry-run mode 941493f84f4Smrg _G_tmpdir=$_G_template-$$ 942fe5e51b7Smrg else 943fe5e51b7Smrg 944fe5e51b7Smrg # If mktemp works, use that first and foremost 945493f84f4Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 946fe5e51b7Smrg 947493f84f4Smrg if test ! -d "$_G_tmpdir"; then 948a31a186aSmrg # Failing that, at least try and use $RANDOM to avoid a race 949493f84f4Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 950493f84f4Smrg 951493f84f4Smrg func_mktempdir_umask=`umask` 952493f84f4Smrg umask 0077 953493f84f4Smrg $MKDIR "$_G_tmpdir" 954493f84f4Smrg umask $func_mktempdir_umask 955493f84f4Smrg fi 956493f84f4Smrg 957493f84f4Smrg # If we're not in dry-run mode, bomb out on failure 958493f84f4Smrg test -d "$_G_tmpdir" || \ 959493f84f4Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 960493f84f4Smrg fi 961493f84f4Smrg 962493f84f4Smrg $ECHO "$_G_tmpdir" 963493f84f4Smrg} 964493f84f4Smrg 965493f84f4Smrg 966493f84f4Smrg# func_normal_abspath PATH 967493f84f4Smrg# ------------------------ 968493f84f4Smrg# Remove doubled-up and trailing slashes, "." path components, 969493f84f4Smrg# and cancel out any ".." path components in PATH after making 970493f84f4Smrg# it an absolute path. 971493f84f4Smrgfunc_normal_abspath () 972493f84f4Smrg{ 973493f84f4Smrg $debug_cmd 974493f84f4Smrg 975493f84f4Smrg # These SED scripts presuppose an absolute path with a trailing slash. 976493f84f4Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 977493f84f4Smrg _G_pathcdr='s|^/[^/]*||' 978493f84f4Smrg _G_removedotparts=':dotsl 979493f84f4Smrg s|/\./|/|g 980493f84f4Smrg t dotsl 981493f84f4Smrg s|/\.$|/|' 982493f84f4Smrg _G_collapseslashes='s|/\{1,\}|/|g' 983493f84f4Smrg _G_finalslash='s|/*$|/|' 984493f84f4Smrg 985493f84f4Smrg # Start from root dir and reassemble the path. 986493f84f4Smrg func_normal_abspath_result= 987493f84f4Smrg func_normal_abspath_tpath=$1 988493f84f4Smrg func_normal_abspath_altnamespace= 989493f84f4Smrg case $func_normal_abspath_tpath in 990493f84f4Smrg "") 991493f84f4Smrg # Empty path, that just means $cwd. 992493f84f4Smrg func_stripname '' '/' "`pwd`" 993493f84f4Smrg func_normal_abspath_result=$func_stripname_result 994493f84f4Smrg return 995493f84f4Smrg ;; 996493f84f4Smrg # The next three entries are used to spot a run of precisely 997493f84f4Smrg # two leading slashes without using negated character classes; 998493f84f4Smrg # we take advantage of case's first-match behaviour. 999493f84f4Smrg ///*) 1000493f84f4Smrg # Unusual form of absolute path, do nothing. 1001493f84f4Smrg ;; 1002493f84f4Smrg //*) 1003493f84f4Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 1004493f84f4Smrg # and for example Cygwin uses it to access remote file shares 1005493f84f4Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 1006493f84f4Smrg func_normal_abspath_altnamespace=/ 1007493f84f4Smrg ;; 1008493f84f4Smrg /*) 1009493f84f4Smrg # Absolute path, do nothing. 1010493f84f4Smrg ;; 1011493f84f4Smrg *) 1012493f84f4Smrg # Relative path, prepend $cwd. 1013493f84f4Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 1014493f84f4Smrg ;; 1015493f84f4Smrg esac 1016493f84f4Smrg 1017493f84f4Smrg # Cancel out all the simple stuff to save iterations. We also want 1018493f84f4Smrg # the path to end with a slash for ease of parsing, so make sure 1019493f84f4Smrg # there is one (and only one) here. 1020493f84f4Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1021493f84f4Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 1022493f84f4Smrg while :; do 1023493f84f4Smrg # Processed it all yet? 1024493f84f4Smrg if test / = "$func_normal_abspath_tpath"; then 1025493f84f4Smrg # If we ascended to the root using ".." the result may be empty now. 1026493f84f4Smrg if test -z "$func_normal_abspath_result"; then 1027493f84f4Smrg func_normal_abspath_result=/ 1028493f84f4Smrg fi 1029493f84f4Smrg break 1030493f84f4Smrg fi 1031493f84f4Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1032493f84f4Smrg -e "$_G_pathcar"` 1033493f84f4Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1034493f84f4Smrg -e "$_G_pathcdr"` 1035493f84f4Smrg # Figure out what to do with it 1036493f84f4Smrg case $func_normal_abspath_tcomponent in 1037493f84f4Smrg "") 1038493f84f4Smrg # Trailing empty path component, ignore it. 1039493f84f4Smrg ;; 1040493f84f4Smrg ..) 1041493f84f4Smrg # Parent dir; strip last assembled component from result. 1042493f84f4Smrg func_dirname "$func_normal_abspath_result" 1043493f84f4Smrg func_normal_abspath_result=$func_dirname_result 1044493f84f4Smrg ;; 1045493f84f4Smrg *) 1046493f84f4Smrg # Actual path component, append it. 1047493f84f4Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1048493f84f4Smrg ;; 1049493f84f4Smrg esac 1050493f84f4Smrg done 1051493f84f4Smrg # Restore leading double-slash if one was found on entry. 1052493f84f4Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1053493f84f4Smrg} 1054493f84f4Smrg 1055493f84f4Smrg 1056493f84f4Smrg# func_notquiet ARG... 1057493f84f4Smrg# -------------------- 1058493f84f4Smrg# Echo program name prefixed message only when not in quiet mode. 1059493f84f4Smrgfunc_notquiet () 1060493f84f4Smrg{ 1061493f84f4Smrg $debug_cmd 1062493f84f4Smrg 1063493f84f4Smrg $opt_quiet || func_echo ${1+"$@"} 1064493f84f4Smrg 1065493f84f4Smrg # A bug in bash halts the script if the last line of a function 1066493f84f4Smrg # fails when set -e is in force, so we need another command to 1067493f84f4Smrg # work around that: 1068493f84f4Smrg : 1069493f84f4Smrg} 1070493f84f4Smrg 1071493f84f4Smrg 1072493f84f4Smrg# func_relative_path SRCDIR DSTDIR 1073493f84f4Smrg# -------------------------------- 1074493f84f4Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1075493f84f4Smrgfunc_relative_path () 1076493f84f4Smrg{ 1077493f84f4Smrg $debug_cmd 1078493f84f4Smrg 1079493f84f4Smrg func_relative_path_result= 1080493f84f4Smrg func_normal_abspath "$1" 1081493f84f4Smrg func_relative_path_tlibdir=$func_normal_abspath_result 1082493f84f4Smrg func_normal_abspath "$2" 1083493f84f4Smrg func_relative_path_tbindir=$func_normal_abspath_result 1084493f84f4Smrg 1085493f84f4Smrg # Ascend the tree starting from libdir 1086493f84f4Smrg while :; do 1087493f84f4Smrg # check if we have found a prefix of bindir 1088493f84f4Smrg case $func_relative_path_tbindir in 1089493f84f4Smrg $func_relative_path_tlibdir) 1090493f84f4Smrg # found an exact match 1091493f84f4Smrg func_relative_path_tcancelled= 1092493f84f4Smrg break 1093493f84f4Smrg ;; 1094493f84f4Smrg $func_relative_path_tlibdir*) 1095493f84f4Smrg # found a matching prefix 1096493f84f4Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1097493f84f4Smrg func_relative_path_tcancelled=$func_stripname_result 1098493f84f4Smrg if test -z "$func_relative_path_result"; then 1099493f84f4Smrg func_relative_path_result=. 1100493f84f4Smrg fi 1101493f84f4Smrg break 1102493f84f4Smrg ;; 1103493f84f4Smrg *) 1104493f84f4Smrg func_dirname $func_relative_path_tlibdir 1105493f84f4Smrg func_relative_path_tlibdir=$func_dirname_result 1106493f84f4Smrg if test -z "$func_relative_path_tlibdir"; then 1107493f84f4Smrg # Have to descend all the way to the root! 1108493f84f4Smrg func_relative_path_result=../$func_relative_path_result 1109493f84f4Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 1110493f84f4Smrg break 1111493f84f4Smrg fi 1112493f84f4Smrg func_relative_path_result=../$func_relative_path_result 1113493f84f4Smrg ;; 1114493f84f4Smrg esac 1115493f84f4Smrg done 1116493f84f4Smrg 1117493f84f4Smrg # Now calculate path; take care to avoid doubling-up slashes. 1118493f84f4Smrg func_stripname '' '/' "$func_relative_path_result" 1119493f84f4Smrg func_relative_path_result=$func_stripname_result 1120493f84f4Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 1121493f84f4Smrg if test -n "$func_stripname_result"; then 1122493f84f4Smrg func_append func_relative_path_result "/$func_stripname_result" 1123493f84f4Smrg fi 1124493f84f4Smrg 1125493f84f4Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 1126493f84f4Smrg if test -n "$func_relative_path_result"; then 1127493f84f4Smrg func_stripname './' '' "$func_relative_path_result" 1128493f84f4Smrg func_relative_path_result=$func_stripname_result 1129493f84f4Smrg fi 1130493f84f4Smrg 1131493f84f4Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 1132493f84f4Smrg 1133493f84f4Smrg : 1134493f84f4Smrg} 1135493f84f4Smrg 1136493f84f4Smrg 11371e423a8fSmrg# func_quote_portable EVAL ARG 11381e423a8fSmrg# ---------------------------- 11391e423a8fSmrg# Internal function to portably implement func_quote_arg. Note that we still 11401e423a8fSmrg# keep attention to performance here so we as much as possible try to avoid 11411e423a8fSmrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 11421e423a8fSmrgfunc_quote_portable () 1143493f84f4Smrg{ 1144493f84f4Smrg $debug_cmd 1145493f84f4Smrg 11461e423a8fSmrg $require_check_ifs_backslash 11471e423a8fSmrg 11481e423a8fSmrg func_quote_portable_result=$2 11491e423a8fSmrg 11501e423a8fSmrg # one-time-loop (easy break) 11511e423a8fSmrg while true 11521e423a8fSmrg do 11531e423a8fSmrg if $1; then 11541e423a8fSmrg func_quote_portable_result=`$ECHO "$2" | $SED \ 11551e423a8fSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 11561e423a8fSmrg break 1157493f84f4Smrg fi 1158493f84f4Smrg 11591e423a8fSmrg # Quote for eval. 11601e423a8fSmrg case $func_quote_portable_result in 11611e423a8fSmrg *[\\\`\"\$]*) 11621e423a8fSmrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 11631e423a8fSmrg # contains the shell wildcard characters. 11641e423a8fSmrg case $check_ifs_backshlash_broken$func_quote_portable_result in 11651e423a8fSmrg :*|*[\[\*\?]*) 11661e423a8fSmrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 11671e423a8fSmrg | $SED "$sed_quote_subst"` 11681e423a8fSmrg break 11691e423a8fSmrg ;; 11701e423a8fSmrg esac 11711e423a8fSmrg 11721e423a8fSmrg func_quote_portable_old_IFS=$IFS 11731e423a8fSmrg for _G_char in '\' '`' '"' '$' 11741e423a8fSmrg do 11751e423a8fSmrg # STATE($1) PREV($2) SEPARATOR($3) 11761e423a8fSmrg set start "" "" 11771e423a8fSmrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 11781e423a8fSmrg IFS=$_G_char 11791e423a8fSmrg for _G_part in $func_quote_portable_result 11801e423a8fSmrg do 11811e423a8fSmrg case $1 in 11821e423a8fSmrg quote) 11831e423a8fSmrg func_append func_quote_portable_result "$3$2" 11841e423a8fSmrg set quote "$_G_part" "\\$_G_char" 11851e423a8fSmrg ;; 11861e423a8fSmrg start) 11871e423a8fSmrg set first "" "" 11881e423a8fSmrg func_quote_portable_result= 11891e423a8fSmrg ;; 11901e423a8fSmrg first) 11911e423a8fSmrg set quote "$_G_part" "" 11921e423a8fSmrg ;; 11931e423a8fSmrg esac 11941e423a8fSmrg done 11951e423a8fSmrg done 11961e423a8fSmrg IFS=$func_quote_portable_old_IFS 1197493f84f4Smrg ;; 11981e423a8fSmrg *) ;; 1199493f84f4Smrg esac 12001e423a8fSmrg break 1201493f84f4Smrg done 12021e423a8fSmrg 12031e423a8fSmrg func_quote_portable_unquoted_result=$func_quote_portable_result 12041e423a8fSmrg case $func_quote_portable_result in 12051e423a8fSmrg # double-quote args containing shell metacharacters to delay 12061e423a8fSmrg # word splitting, command substitution and variable expansion 12071e423a8fSmrg # for a subsequent eval. 12081e423a8fSmrg # many bourne shells cannot handle close brackets correctly 12091e423a8fSmrg # in scan sets, so we specify it separately. 12101e423a8fSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 12111e423a8fSmrg func_quote_portable_result=\"$func_quote_portable_result\" 12121e423a8fSmrg ;; 12131e423a8fSmrg esac 1214493f84f4Smrg} 1215493f84f4Smrg 1216493f84f4Smrg 12171e423a8fSmrg# func_quotefast_eval ARG 12181e423a8fSmrg# ----------------------- 12191e423a8fSmrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 12201e423a8fSmrg# but optimized for speed. Result is stored in $func_quotefast_eval. 12211e423a8fSmrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 12221e423a8fSmrg printf -v _GL_test_printf_tilde %q '~' 12231e423a8fSmrg if test '\~' = "$_GL_test_printf_tilde"; then 12241e423a8fSmrg func_quotefast_eval () 12251e423a8fSmrg { 12261e423a8fSmrg printf -v func_quotefast_eval_result %q "$1" 12271e423a8fSmrg } 12281e423a8fSmrg else 12291e423a8fSmrg # Broken older Bash implementations. Make those faster too if possible. 12301e423a8fSmrg func_quotefast_eval () 12311e423a8fSmrg { 12321e423a8fSmrg case $1 in 12331e423a8fSmrg '~'*) 12341e423a8fSmrg func_quote_portable false "$1" 12351e423a8fSmrg func_quotefast_eval_result=$func_quote_portable_result 12361e423a8fSmrg ;; 12371e423a8fSmrg *) 12381e423a8fSmrg printf -v func_quotefast_eval_result %q "$1" 12391e423a8fSmrg ;; 12401e423a8fSmrg esac 12411e423a8fSmrg } 12421e423a8fSmrg fi 12431e423a8fSmrgelse 12441e423a8fSmrg func_quotefast_eval () 12451e423a8fSmrg { 12461e423a8fSmrg func_quote_portable false "$1" 12471e423a8fSmrg func_quotefast_eval_result=$func_quote_portable_result 12481e423a8fSmrg } 12491e423a8fSmrgfi 1250493f84f4Smrg 12511e423a8fSmrg 12521e423a8fSmrg# func_quote_arg MODEs ARG 12531e423a8fSmrg# ------------------------ 12541e423a8fSmrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 12551e423a8fSmrg# specifiers listed below separated by ',' character. This function returns two 12561e423a8fSmrg# values: 12571e423a8fSmrg# i) func_quote_arg_result 12581e423a8fSmrg# double-quoted (when needed), suitable for a subsequent eval 12591e423a8fSmrg# ii) func_quote_arg_unquoted_result 12601e423a8fSmrg# has all characters that are still active within double 12611e423a8fSmrg# quotes backslashified. Available only if 'unquoted' is specified. 12621e423a8fSmrg# 12631e423a8fSmrg# Available modes: 12641e423a8fSmrg# ---------------- 12651e423a8fSmrg# 'eval' (default) 12661e423a8fSmrg# - escape shell special characters 12671e423a8fSmrg# 'expand' 12681e423a8fSmrg# - the same as 'eval'; but do not quote variable references 12691e423a8fSmrg# 'pretty' 12701e423a8fSmrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 12711e423a8fSmrg# be used later in func_quote to get output like: 'echo "a b"' instead 12721e423a8fSmrg# of 'echo a\ b'. This is slower than default on some shells. 12731e423a8fSmrg# 'unquoted' 12741e423a8fSmrg# - produce also $func_quote_arg_unquoted_result which does not contain 12751e423a8fSmrg# wrapping double-quotes. 12761e423a8fSmrg# 12771e423a8fSmrg# Examples for 'func_quote_arg pretty,unquoted string': 12781e423a8fSmrg# 12791e423a8fSmrg# string | *_result | *_unquoted_result 12801e423a8fSmrg# ------------+-----------------------+------------------- 12811e423a8fSmrg# " | \" | \" 12821e423a8fSmrg# a b | "a b" | a b 12831e423a8fSmrg# "a b" | "\"a b\"" | \"a b\" 12841e423a8fSmrg# * | "*" | * 12851e423a8fSmrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 12861e423a8fSmrg# 12871e423a8fSmrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 12881e423a8fSmrg# 12891e423a8fSmrg# string | *_result | *_unquoted_result 12901e423a8fSmrg# --------------+---------------------+-------------------- 12911e423a8fSmrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 12921e423a8fSmrgfunc_quote_arg () 12931e423a8fSmrg{ 12941e423a8fSmrg _G_quote_expand=false 12951e423a8fSmrg case ,$1, in 12961e423a8fSmrg *,expand,*) 12971e423a8fSmrg _G_quote_expand=: 12981e423a8fSmrg ;; 1299493f84f4Smrg esac 1300493f84f4Smrg 13011e423a8fSmrg case ,$1, in 13021e423a8fSmrg *,pretty,*|*,expand,*|*,unquoted,*) 13031e423a8fSmrg func_quote_portable $_G_quote_expand "$2" 13041e423a8fSmrg func_quote_arg_result=$func_quote_portable_result 13051e423a8fSmrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 13061e423a8fSmrg ;; 13071e423a8fSmrg *) 13081e423a8fSmrg # Faster quote-for-eval for some shells. 13091e423a8fSmrg func_quotefast_eval "$2" 13101e423a8fSmrg func_quote_arg_result=$func_quotefast_eval_result 1311493f84f4Smrg ;; 1312493f84f4Smrg esac 13131e423a8fSmrg} 13141e423a8fSmrg 1315493f84f4Smrg 13161e423a8fSmrg# func_quote MODEs ARGs... 13171e423a8fSmrg# ------------------------ 13181e423a8fSmrg# Quote all ARGs to be evaled later and join them into single command. See 13191e423a8fSmrg# func_quote_arg's description for more info. 13201e423a8fSmrgfunc_quote () 13211e423a8fSmrg{ 13221e423a8fSmrg $debug_cmd 13231e423a8fSmrg _G_func_quote_mode=$1 ; shift 13241e423a8fSmrg func_quote_result= 13251e423a8fSmrg while test 0 -lt $#; do 13261e423a8fSmrg func_quote_arg "$_G_func_quote_mode" "$1" 13271e423a8fSmrg if test -n "$func_quote_result"; then 13281e423a8fSmrg func_append func_quote_result " $func_quote_arg_result" 13291e423a8fSmrg else 13301e423a8fSmrg func_append func_quote_result "$func_quote_arg_result" 13311e423a8fSmrg fi 13321e423a8fSmrg shift 13331e423a8fSmrg done 1334493f84f4Smrg} 1335493f84f4Smrg 1336493f84f4Smrg 1337493f84f4Smrg# func_stripname PREFIX SUFFIX NAME 1338493f84f4Smrg# --------------------------------- 1339493f84f4Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1340493f84f4Smrg# PREFIX and SUFFIX must not contain globbing or regex special 1341493f84f4Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 1342493f84f4Smrg# dot (in which case that matches only a dot). 1343493f84f4Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 1344493f84f4Smrg eval 'func_stripname () 1345493f84f4Smrg { 1346493f84f4Smrg $debug_cmd 1347493f84f4Smrg 1348493f84f4Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1349493f84f4Smrg # positional parameters, so assign one to ordinary variable first. 1350493f84f4Smrg func_stripname_result=$3 1351493f84f4Smrg func_stripname_result=${func_stripname_result#"$1"} 1352493f84f4Smrg func_stripname_result=${func_stripname_result%"$2"} 1353493f84f4Smrg }' 1354493f84f4Smrgelse 1355493f84f4Smrg func_stripname () 1356493f84f4Smrg { 1357493f84f4Smrg $debug_cmd 1358493f84f4Smrg 1359493f84f4Smrg case $2 in 1360493f84f4Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1361493f84f4Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1362493f84f4Smrg esac 1363493f84f4Smrg } 1364493f84f4Smrgfi 1365493f84f4Smrg 1366493f84f4Smrg 1367493f84f4Smrg# func_show_eval CMD [FAIL_EXP] 1368493f84f4Smrg# ----------------------------- 1369493f84f4Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1370493f84f4Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1371493f84f4Smrg# is given, then evaluate it. 1372493f84f4Smrgfunc_show_eval () 1373493f84f4Smrg{ 1374493f84f4Smrg $debug_cmd 1375493f84f4Smrg 1376493f84f4Smrg _G_cmd=$1 1377493f84f4Smrg _G_fail_exp=${2-':'} 1378493f84f4Smrg 13791e423a8fSmrg func_quote_arg pretty,expand "$_G_cmd" 13801e423a8fSmrg eval "func_notquiet $func_quote_arg_result" 1381493f84f4Smrg 1382493f84f4Smrg $opt_dry_run || { 1383493f84f4Smrg eval "$_G_cmd" 1384493f84f4Smrg _G_status=$? 1385493f84f4Smrg if test 0 -ne "$_G_status"; then 1386493f84f4Smrg eval "(exit $_G_status); $_G_fail_exp" 1387493f84f4Smrg fi 1388493f84f4Smrg } 1389493f84f4Smrg} 1390493f84f4Smrg 1391493f84f4Smrg 1392493f84f4Smrg# func_show_eval_locale CMD [FAIL_EXP] 1393493f84f4Smrg# ------------------------------------ 1394493f84f4Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1395493f84f4Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1396493f84f4Smrg# is given, then evaluate it. Use the saved locale for evaluation. 1397493f84f4Smrgfunc_show_eval_locale () 1398493f84f4Smrg{ 1399493f84f4Smrg $debug_cmd 1400493f84f4Smrg 1401493f84f4Smrg _G_cmd=$1 1402493f84f4Smrg _G_fail_exp=${2-':'} 1403493f84f4Smrg 1404493f84f4Smrg $opt_quiet || { 14051e423a8fSmrg func_quote_arg expand,pretty "$_G_cmd" 14061e423a8fSmrg eval "func_echo $func_quote_arg_result" 1407493f84f4Smrg } 1408493f84f4Smrg 1409493f84f4Smrg $opt_dry_run || { 1410493f84f4Smrg eval "$_G_user_locale 1411493f84f4Smrg $_G_cmd" 1412493f84f4Smrg _G_status=$? 1413493f84f4Smrg eval "$_G_safe_locale" 1414493f84f4Smrg if test 0 -ne "$_G_status"; then 1415493f84f4Smrg eval "(exit $_G_status); $_G_fail_exp" 1416493f84f4Smrg fi 1417493f84f4Smrg } 1418493f84f4Smrg} 1419493f84f4Smrg 1420493f84f4Smrg 1421493f84f4Smrg# func_tr_sh 1422493f84f4Smrg# ---------- 1423493f84f4Smrg# Turn $1 into a string suitable for a shell variable name. 1424493f84f4Smrg# Result is stored in $func_tr_sh_result. All characters 1425493f84f4Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1426493f84f4Smrg# if $1 begins with a digit, a '_' is prepended as well. 1427493f84f4Smrgfunc_tr_sh () 1428493f84f4Smrg{ 1429493f84f4Smrg $debug_cmd 1430493f84f4Smrg 1431493f84f4Smrg case $1 in 1432493f84f4Smrg [0-9]* | *[!a-zA-Z0-9_]*) 1433493f84f4Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1434493f84f4Smrg ;; 1435493f84f4Smrg * ) 1436493f84f4Smrg func_tr_sh_result=$1 1437493f84f4Smrg ;; 1438493f84f4Smrg esac 1439493f84f4Smrg} 1440493f84f4Smrg 1441493f84f4Smrg 1442493f84f4Smrg# func_verbose ARG... 1443493f84f4Smrg# ------------------- 1444493f84f4Smrg# Echo program name prefixed message in verbose mode only. 1445493f84f4Smrgfunc_verbose () 1446493f84f4Smrg{ 1447493f84f4Smrg $debug_cmd 1448493f84f4Smrg 1449493f84f4Smrg $opt_verbose && func_echo "$*" 1450493f84f4Smrg 1451493f84f4Smrg : 1452493f84f4Smrg} 1453493f84f4Smrg 1454493f84f4Smrg 1455493f84f4Smrg# func_warn_and_continue ARG... 1456493f84f4Smrg# ----------------------------- 1457493f84f4Smrg# Echo program name prefixed warning message to standard error. 1458493f84f4Smrgfunc_warn_and_continue () 1459493f84f4Smrg{ 1460493f84f4Smrg $debug_cmd 1461493f84f4Smrg 1462493f84f4Smrg $require_term_colors 1463493f84f4Smrg 1464493f84f4Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1465493f84f4Smrg} 1466493f84f4Smrg 1467493f84f4Smrg 1468493f84f4Smrg# func_warning CATEGORY ARG... 1469493f84f4Smrg# ---------------------------- 1470493f84f4Smrg# Echo program name prefixed warning message to standard error. Warning 1471493f84f4Smrg# messages can be filtered according to CATEGORY, where this function 1472493f84f4Smrg# elides messages where CATEGORY is not listed in the global variable 1473493f84f4Smrg# 'opt_warning_types'. 1474493f84f4Smrgfunc_warning () 1475493f84f4Smrg{ 1476493f84f4Smrg $debug_cmd 1477493f84f4Smrg 1478493f84f4Smrg # CATEGORY must be in the warning_categories list! 1479493f84f4Smrg case " $warning_categories " in 1480493f84f4Smrg *" $1 "*) ;; 1481493f84f4Smrg *) func_internal_error "invalid warning category '$1'" ;; 1482493f84f4Smrg esac 1483493f84f4Smrg 1484493f84f4Smrg _G_category=$1 1485493f84f4Smrg shift 1486493f84f4Smrg 1487493f84f4Smrg case " $opt_warning_types " in 1488493f84f4Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 1489493f84f4Smrg esac 1490493f84f4Smrg} 1491493f84f4Smrg 1492493f84f4Smrg 1493493f84f4Smrg# func_sort_ver VER1 VER2 1494493f84f4Smrg# ----------------------- 1495493f84f4Smrg# 'sort -V' is not generally available. 1496493f84f4Smrg# Note this deviates from the version comparison in automake 1497493f84f4Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1498493f84f4Smrg# but this should suffice as we won't be specifying old 1499493f84f4Smrg# version formats or redundant trailing .0 in bootstrap.conf. 1500493f84f4Smrg# If we did want full compatibility then we should probably 1501493f84f4Smrg# use m4_version_compare from autoconf. 1502493f84f4Smrgfunc_sort_ver () 1503493f84f4Smrg{ 1504493f84f4Smrg $debug_cmd 1505493f84f4Smrg 1506493f84f4Smrg printf '%s\n%s\n' "$1" "$2" \ 1507493f84f4Smrg | 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 1508493f84f4Smrg} 1509493f84f4Smrg 1510493f84f4Smrg# func_lt_ver PREV CURR 1511493f84f4Smrg# --------------------- 1512493f84f4Smrg# Return true if PREV and CURR are in the correct order according to 1513493f84f4Smrg# func_sort_ver, otherwise false. Use it like this: 1514493f84f4Smrg# 1515493f84f4Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1516493f84f4Smrgfunc_lt_ver () 1517493f84f4Smrg{ 1518493f84f4Smrg $debug_cmd 1519493f84f4Smrg 1520493f84f4Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1521493f84f4Smrg} 1522493f84f4Smrg 1523493f84f4Smrg 1524493f84f4Smrg# Local variables: 1525493f84f4Smrg# mode: shell-script 1526493f84f4Smrg# sh-indentation: 2 1527493f84f4Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 1528493f84f4Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1529493f84f4Smrg# time-stamp-time-zone: "UTC" 1530493f84f4Smrg# End: 1531493f84f4Smrg#! /bin/sh 1532493f84f4Smrg 1533493f84f4Smrg# A portable, pluggable option parser for Bourne shell. 1534493f84f4Smrg# Written by Gary V. Vaughan, 2010 1535493f84f4Smrg 15361e423a8fSmrg# This is free software. There is NO warranty; not even for 15371e423a8fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15381e423a8fSmrg# 15391e423a8fSmrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 15401e423a8fSmrg# 15411e423a8fSmrg# This file is dual licensed under the terms of the MIT license 15421e423a8fSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 15431e423a8fSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 15441e423a8fSmrg# these licenses when using or redistributing this software or any of 15451e423a8fSmrg# the files within it. See the URLs above, or the file `LICENSE` 15461e423a8fSmrg# included in the Bootstrap distribution for the full license texts. 1547493f84f4Smrg 15481e423a8fSmrg# Please report bugs or propose patches to: 15491e423a8fSmrg# <https://github.com/gnulib-modules/bootstrap/issues> 1550493f84f4Smrg 15511e423a8fSmrg# Set a version string for this script. 15521e423a8fSmrgscriptversion=2019-02-19.15; # UTC 1553493f84f4Smrg 1554493f84f4Smrg 1555493f84f4Smrg## ------ ## 1556493f84f4Smrg## Usage. ## 1557493f84f4Smrg## ------ ## 1558493f84f4Smrg 1559493f84f4Smrg# This file is a library for parsing options in your shell scripts along 1560493f84f4Smrg# with assorted other useful supporting features that you can make use 1561493f84f4Smrg# of too. 1562493f84f4Smrg# 1563493f84f4Smrg# For the simplest scripts you might need only: 1564493f84f4Smrg# 1565493f84f4Smrg# #!/bin/sh 1566493f84f4Smrg# . relative/path/to/funclib.sh 1567493f84f4Smrg# . relative/path/to/options-parser 1568493f84f4Smrg# scriptversion=1.0 1569493f84f4Smrg# func_options ${1+"$@"} 1570493f84f4Smrg# eval set dummy "$func_options_result"; shift 1571493f84f4Smrg# ...rest of your script... 1572493f84f4Smrg# 1573493f84f4Smrg# In order for the '--version' option to work, you will need to have a 1574493f84f4Smrg# suitably formatted comment like the one at the top of this file 15751e423a8fSmrg# starting with '# Written by ' and ending with '# Copyright'. 1576493f84f4Smrg# 1577493f84f4Smrg# For '-h' and '--help' to work, you will also need a one line 1578493f84f4Smrg# description of your script's purpose in a comment directly above the 1579493f84f4Smrg# '# Written by ' line, like the one at the top of this file. 1580493f84f4Smrg# 1581493f84f4Smrg# The default options also support '--debug', which will turn on shell 1582493f84f4Smrg# execution tracing (see the comment above debug_cmd below for another 1583493f84f4Smrg# use), and '--verbose' and the func_verbose function to allow your script 1584493f84f4Smrg# to display verbose messages only when your user has specified 1585493f84f4Smrg# '--verbose'. 1586493f84f4Smrg# 15871e423a8fSmrg# After sourcing this file, you can plug in processing for additional 1588493f84f4Smrg# options by amending the variables from the 'Configuration' section 1589493f84f4Smrg# below, and following the instructions in the 'Option parsing' 1590493f84f4Smrg# section further down. 1591493f84f4Smrg 1592493f84f4Smrg## -------------- ## 1593493f84f4Smrg## Configuration. ## 1594493f84f4Smrg## -------------- ## 1595493f84f4Smrg 1596493f84f4Smrg# You should override these variables in your script after sourcing this 1597493f84f4Smrg# file so that they reflect the customisations you have added to the 1598493f84f4Smrg# option parser. 1599493f84f4Smrg 1600493f84f4Smrg# The usage line for option parsing errors and the start of '-h' and 1601493f84f4Smrg# '--help' output messages. You can embed shell variables for delayed 1602493f84f4Smrg# expansion at the time the message is displayed, but you will need to 1603493f84f4Smrg# quote other shell meta-characters carefully to prevent them being 1604493f84f4Smrg# expanded when the contents are evaled. 1605493f84f4Smrgusage='$progpath [OPTION]...' 1606493f84f4Smrg 1607493f84f4Smrg# Short help message in response to '-h' and '--help'. Add to this or 1608493f84f4Smrg# override it after sourcing this library to reflect the full set of 1609493f84f4Smrg# options your script accepts. 1610493f84f4Smrgusage_message="\ 1611493f84f4Smrg --debug enable verbose shell tracing 1612493f84f4Smrg -W, --warnings=CATEGORY 1613493f84f4Smrg report the warnings falling in CATEGORY [all] 1614493f84f4Smrg -v, --verbose verbosely report processing 1615493f84f4Smrg --version print version information and exit 1616493f84f4Smrg -h, --help print short or long help message and exit 1617493f84f4Smrg" 1618493f84f4Smrg 1619493f84f4Smrg# Additional text appended to 'usage_message' in response to '--help'. 1620493f84f4Smrglong_help_message=" 1621493f84f4SmrgWarning categories include: 1622493f84f4Smrg 'all' show all warnings 1623493f84f4Smrg 'none' turn off all the warnings 1624493f84f4Smrg 'error' warnings are treated as fatal errors" 1625493f84f4Smrg 1626493f84f4Smrg# Help message printed before fatal option parsing errors. 1627493f84f4Smrgfatal_help="Try '\$progname --help' for more information." 1628493f84f4Smrg 1629493f84f4Smrg 1630493f84f4Smrg 1631493f84f4Smrg## ------------------------- ## 1632493f84f4Smrg## Hook function management. ## 1633493f84f4Smrg## ------------------------- ## 1634493f84f4Smrg 1635493f84f4Smrg# This section contains functions for adding, removing, and running hooks 16361e423a8fSmrg# in the main code. A hook is just a list of function names that can be 16371e423a8fSmrg# run in order later on. 1638493f84f4Smrg 1639493f84f4Smrg# func_hookable FUNC_NAME 1640493f84f4Smrg# ----------------------- 1641493f84f4Smrg# Declare that FUNC_NAME will run hooks added with 1642493f84f4Smrg# 'func_add_hook FUNC_NAME ...'. 1643493f84f4Smrgfunc_hookable () 1644493f84f4Smrg{ 1645493f84f4Smrg $debug_cmd 1646493f84f4Smrg 1647493f84f4Smrg func_append hookable_fns " $1" 1648493f84f4Smrg} 1649493f84f4Smrg 1650493f84f4Smrg 1651493f84f4Smrg# func_add_hook FUNC_NAME HOOK_FUNC 1652493f84f4Smrg# --------------------------------- 1653493f84f4Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1654493f84f4Smrg# first have been declared "hookable" by a call to 'func_hookable'. 1655493f84f4Smrgfunc_add_hook () 1656493f84f4Smrg{ 1657493f84f4Smrg $debug_cmd 1658493f84f4Smrg 1659493f84f4Smrg case " $hookable_fns " in 1660493f84f4Smrg *" $1 "*) ;; 1661493f84f4Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 1662493f84f4Smrg esac 1663493f84f4Smrg 1664493f84f4Smrg eval func_append ${1}_hooks '" $2"' 1665493f84f4Smrg} 1666493f84f4Smrg 1667493f84f4Smrg 1668493f84f4Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 1669493f84f4Smrg# ------------------------------------ 16701e423a8fSmrg# Remove HOOK_FUNC from the list of hook functions to be called by 16711e423a8fSmrg# FUNC_NAME. 1672493f84f4Smrgfunc_remove_hook () 1673493f84f4Smrg{ 1674493f84f4Smrg $debug_cmd 1675493f84f4Smrg 1676493f84f4Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1677493f84f4Smrg} 1678493f84f4Smrg 1679493f84f4Smrg 16801e423a8fSmrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 16811e423a8fSmrg# --------------------------------------------- 16821e423a8fSmrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 16831e423a8fSmrg# *_result variable of FUNC_NAME_B. 16841e423a8fSmrgfunc_propagate_result () 16851e423a8fSmrg{ 16861e423a8fSmrg $debug_cmd 16871e423a8fSmrg 16881e423a8fSmrg func_propagate_result_result=: 16891e423a8fSmrg if eval "test \"\${${1}_result+set}\" = set" 16901e423a8fSmrg then 16911e423a8fSmrg eval "${2}_result=\$${1}_result" 16921e423a8fSmrg else 16931e423a8fSmrg func_propagate_result_result=false 16941e423a8fSmrg fi 16951e423a8fSmrg} 16961e423a8fSmrg 16971e423a8fSmrg 1698493f84f4Smrg# func_run_hooks FUNC_NAME [ARG]... 1699493f84f4Smrg# --------------------------------- 1700493f84f4Smrg# Run all hook functions registered to FUNC_NAME. 17011e423a8fSmrg# It's assumed that the list of hook functions contains nothing more 1702493f84f4Smrg# than a whitespace-delimited list of legal shell function names, and 1703493f84f4Smrg# no effort is wasted trying to catch shell meta-characters or preserve 1704493f84f4Smrg# whitespace. 1705493f84f4Smrgfunc_run_hooks () 1706493f84f4Smrg{ 1707493f84f4Smrg $debug_cmd 1708493f84f4Smrg 1709493f84f4Smrg case " $hookable_fns " in 1710493f84f4Smrg *" $1 "*) ;; 17111e423a8fSmrg *) func_fatal_error "'$1' does not support hook functions." ;; 1712493f84f4Smrg esac 1713493f84f4Smrg 1714493f84f4Smrg eval _G_hook_fns=\$$1_hooks; shift 1715493f84f4Smrg 1716493f84f4Smrg for _G_hook in $_G_hook_fns; do 17171e423a8fSmrg func_unset "${_G_hook}_result" 17181e423a8fSmrg eval $_G_hook '${1+"$@"}' 17191e423a8fSmrg func_propagate_result $_G_hook func_run_hooks 17201e423a8fSmrg if $func_propagate_result_result; then 17211e423a8fSmrg eval set dummy "$func_run_hooks_result"; shift 17221e423a8fSmrg fi 1723493f84f4Smrg done 1724493f84f4Smrg} 1725493f84f4Smrg 1726493f84f4Smrg 1727493f84f4Smrg 1728493f84f4Smrg## --------------- ## 1729493f84f4Smrg## Option parsing. ## 1730493f84f4Smrg## --------------- ## 1731493f84f4Smrg 1732493f84f4Smrg# In order to add your own option parsing hooks, you must accept the 17331e423a8fSmrg# full positional parameter list from your hook function. You may remove 17341e423a8fSmrg# or edit any options that you action, and then pass back the remaining 17351e423a8fSmrg# unprocessed options in '<hooked_function_name>_result', escaped 17361e423a8fSmrg# suitably for 'eval'. 17371e423a8fSmrg# 17381e423a8fSmrg# The '<hooked_function_name>_result' variable is automatically unset 17391e423a8fSmrg# before your hook gets called; for best performance, only set the 17401e423a8fSmrg# *_result variable when necessary (i.e. don't call the 'func_quote' 17411e423a8fSmrg# function unnecessarily because it can be an expensive operation on some 17421e423a8fSmrg# machines). 17431e423a8fSmrg# 17441e423a8fSmrg# Like this: 1745493f84f4Smrg# 1746493f84f4Smrg# my_options_prep () 1747493f84f4Smrg# { 1748493f84f4Smrg# $debug_cmd 1749493f84f4Smrg# 1750493f84f4Smrg# # Extend the existing usage message. 1751493f84f4Smrg# usage_message=$usage_message' 1752493f84f4Smrg# -s, --silent don'\''t print informational messages 1753493f84f4Smrg# ' 17541e423a8fSmrg# # No change in '$@' (ignored completely by this hook). Leave 17551e423a8fSmrg# # my_options_prep_result variable intact. 1756493f84f4Smrg# } 1757493f84f4Smrg# func_add_hook func_options_prep my_options_prep 1758493f84f4Smrg# 1759493f84f4Smrg# 1760493f84f4Smrg# my_silent_option () 1761493f84f4Smrg# { 1762493f84f4Smrg# $debug_cmd 1763493f84f4Smrg# 17641e423a8fSmrg# args_changed=false 17651e423a8fSmrg# 17661e423a8fSmrg# # Note that, for efficiency, we parse as many options as we can 1767493f84f4Smrg# # recognise in a loop before passing the remainder back to the 1768493f84f4Smrg# # caller on the first unrecognised argument we encounter. 1769493f84f4Smrg# while test $# -gt 0; do 1770493f84f4Smrg# opt=$1; shift 1771493f84f4Smrg# case $opt in 17721e423a8fSmrg# --silent|-s) opt_silent=: 17731e423a8fSmrg# args_changed=: 17741e423a8fSmrg# ;; 1775493f84f4Smrg# # Separate non-argument short options: 1776493f84f4Smrg# -s*) func_split_short_opt "$_G_opt" 1777493f84f4Smrg# set dummy "$func_split_short_opt_name" \ 1778493f84f4Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 1779493f84f4Smrg# shift 17801e423a8fSmrg# args_changed=: 1781493f84f4Smrg# ;; 17821e423a8fSmrg# *) # Make sure the first unrecognised option "$_G_opt" 17831e423a8fSmrg# # is added back to "$@" in case we need it later, 17841e423a8fSmrg# # if $args_changed was set to 'true'. 17851e423a8fSmrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1786493f84f4Smrg# esac 1787493f84f4Smrg# done 1788493f84f4Smrg# 17891e423a8fSmrg# # Only call 'func_quote' here if we processed at least one argument. 17901e423a8fSmrg# if $args_changed; then 17911e423a8fSmrg# func_quote eval ${1+"$@"} 17921e423a8fSmrg# my_silent_option_result=$func_quote_result 17931e423a8fSmrg# fi 1794493f84f4Smrg# } 1795493f84f4Smrg# func_add_hook func_parse_options my_silent_option 1796493f84f4Smrg# 1797493f84f4Smrg# 1798493f84f4Smrg# my_option_validation () 1799493f84f4Smrg# { 1800493f84f4Smrg# $debug_cmd 1801493f84f4Smrg# 1802493f84f4Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 1803493f84f4Smrg# '--silent' and '--verbose' options are mutually exclusive." 1804493f84f4Smrg# } 1805493f84f4Smrg# func_add_hook func_validate_options my_option_validation 1806493f84f4Smrg# 18071e423a8fSmrg# You'll also need to manually amend $usage_message to reflect the extra 1808493f84f4Smrg# options you parse. It's preferable to append if you can, so that 1809493f84f4Smrg# multiple option parsing hooks can be added safely. 1810493f84f4Smrg 1811493f84f4Smrg 18121e423a8fSmrg# func_options_finish [ARG]... 18131e423a8fSmrg# ---------------------------- 18141e423a8fSmrg# Finishing the option parse loop (call 'func_options' hooks ATM). 18151e423a8fSmrgfunc_options_finish () 18161e423a8fSmrg{ 18171e423a8fSmrg $debug_cmd 18181e423a8fSmrg 18191e423a8fSmrg func_run_hooks func_options ${1+"$@"} 18201e423a8fSmrg func_propagate_result func_run_hooks func_options_finish 18211e423a8fSmrg} 18221e423a8fSmrg 18231e423a8fSmrg 1824493f84f4Smrg# func_options [ARG]... 1825493f84f4Smrg# --------------------- 1826493f84f4Smrg# All the functions called inside func_options are hookable. See the 1827493f84f4Smrg# individual implementations for details. 1828493f84f4Smrgfunc_hookable func_options 1829493f84f4Smrgfunc_options () 1830493f84f4Smrg{ 1831493f84f4Smrg $debug_cmd 1832fe5e51b7Smrg 18331e423a8fSmrg _G_options_quoted=false 1834fe5e51b7Smrg 18351e423a8fSmrg for my_func in options_prep parse_options validate_options options_finish 18361e423a8fSmrg do 18371e423a8fSmrg func_unset func_${my_func}_result 18381e423a8fSmrg func_unset func_run_hooks_result 18391e423a8fSmrg eval func_$my_func '${1+"$@"}' 18401e423a8fSmrg func_propagate_result func_$my_func func_options 18411e423a8fSmrg if $func_propagate_result_result; then 18421e423a8fSmrg eval set dummy "$func_options_result"; shift 18431e423a8fSmrg _G_options_quoted=: 18441e423a8fSmrg fi 18451e423a8fSmrg done 1846fe5e51b7Smrg 18471e423a8fSmrg $_G_options_quoted || { 18481e423a8fSmrg # As we (func_options) are top-level options-parser function and 18491e423a8fSmrg # nobody quoted "$@" for us yet, we need to do it explicitly for 18501e423a8fSmrg # caller. 18511e423a8fSmrg func_quote eval ${1+"$@"} 18521e423a8fSmrg func_options_result=$func_quote_result 18531e423a8fSmrg } 1854fe5e51b7Smrg} 1855fe5e51b7Smrg 1856fe5e51b7Smrg 1857493f84f4Smrg# func_options_prep [ARG]... 1858493f84f4Smrg# -------------------------- 1859493f84f4Smrg# All initialisations required before starting the option parse loop. 1860493f84f4Smrg# Note that when calling hook functions, we pass through the list of 1861493f84f4Smrg# positional parameters. If a hook function modifies that list, and 18621e423a8fSmrg# needs to propagate that back to rest of this script, then the complete 18631e423a8fSmrg# modified list must be put in 'func_run_hooks_result' before returning. 1864493f84f4Smrgfunc_hookable func_options_prep 1865493f84f4Smrgfunc_options_prep () 1866fe5e51b7Smrg{ 1867493f84f4Smrg $debug_cmd 1868a31a186aSmrg 1869493f84f4Smrg # Option defaults: 1870493f84f4Smrg opt_verbose=false 1871493f84f4Smrg opt_warning_types= 1872493f84f4Smrg 1873493f84f4Smrg func_run_hooks func_options_prep ${1+"$@"} 18741e423a8fSmrg func_propagate_result func_run_hooks func_options_prep 1875fe5e51b7Smrg} 1876fe5e51b7Smrg 1877fe5e51b7Smrg 1878493f84f4Smrg# func_parse_options [ARG]... 1879493f84f4Smrg# --------------------------- 1880493f84f4Smrg# The main option parsing loop. 1881493f84f4Smrgfunc_hookable func_parse_options 1882493f84f4Smrgfunc_parse_options () 1883fe5e51b7Smrg{ 1884493f84f4Smrg $debug_cmd 1885a31a186aSmrg 18861e423a8fSmrg _G_parse_options_requote=false 1887493f84f4Smrg # this just eases exit handling 1888493f84f4Smrg while test $# -gt 0; do 1889493f84f4Smrg # Defer to hook functions for initial option parsing, so they 1890493f84f4Smrg # get priority in the event of reusing an option name. 1891493f84f4Smrg func_run_hooks func_parse_options ${1+"$@"} 18921e423a8fSmrg func_propagate_result func_run_hooks func_parse_options 18931e423a8fSmrg if $func_propagate_result_result; then 18941e423a8fSmrg eval set dummy "$func_parse_options_result"; shift 18951e423a8fSmrg # Even though we may have changed "$@", we passed the "$@" array 18961e423a8fSmrg # down into the hook and it quoted it for us (because we are in 18971e423a8fSmrg # this if-branch). No need to quote it again. 18981e423a8fSmrg _G_parse_options_requote=false 18991e423a8fSmrg fi 1900fe5e51b7Smrg 1901493f84f4Smrg # Break out of the loop if we already parsed every option. 1902493f84f4Smrg test $# -gt 0 || break 1903eda3803bSmrg 19041e423a8fSmrg # We expect that one of the options parsed in this function matches 19051e423a8fSmrg # and thus we remove _G_opt from "$@" and need to re-quote. 19061e423a8fSmrg _G_match_parse_options=: 1907493f84f4Smrg _G_opt=$1 1908493f84f4Smrg shift 1909493f84f4Smrg case $_G_opt in 1910493f84f4Smrg --debug|-x) debug_cmd='set -x' 19111e423a8fSmrg func_echo "enabling shell trace mode" >&2 1912493f84f4Smrg $debug_cmd 1913493f84f4Smrg ;; 1914493f84f4Smrg 1915493f84f4Smrg --no-warnings|--no-warning|--no-warn) 1916493f84f4Smrg set dummy --warnings none ${1+"$@"} 1917493f84f4Smrg shift 1918493f84f4Smrg ;; 1919a31a186aSmrg 1920493f84f4Smrg --warnings|--warning|-W) 19211e423a8fSmrg if test $# = 0 && func_missing_arg $_G_opt; then 19221e423a8fSmrg _G_parse_options_requote=: 19231e423a8fSmrg break 19241e423a8fSmrg fi 1925493f84f4Smrg case " $warning_categories $1" in 1926493f84f4Smrg *" $1 "*) 1927493f84f4Smrg # trailing space prevents matching last $1 above 1928493f84f4Smrg func_append_uniq opt_warning_types " $1" 1929493f84f4Smrg ;; 1930493f84f4Smrg *all) 1931493f84f4Smrg opt_warning_types=$warning_categories 1932493f84f4Smrg ;; 1933493f84f4Smrg *none) 1934493f84f4Smrg opt_warning_types=none 1935493f84f4Smrg warning_func=: 1936493f84f4Smrg ;; 1937493f84f4Smrg *error) 1938493f84f4Smrg opt_warning_types=$warning_categories 1939493f84f4Smrg warning_func=func_fatal_error 1940493f84f4Smrg ;; 1941493f84f4Smrg *) 1942493f84f4Smrg func_fatal_error \ 1943493f84f4Smrg "unsupported warning category: '$1'" 1944493f84f4Smrg ;; 1945493f84f4Smrg esac 1946493f84f4Smrg shift 1947493f84f4Smrg ;; 1948493f84f4Smrg 1949493f84f4Smrg --verbose|-v) opt_verbose=: ;; 1950493f84f4Smrg --version) func_version ;; 1951493f84f4Smrg -\?|-h) func_usage ;; 1952493f84f4Smrg --help) func_help ;; 1953493f84f4Smrg 1954493f84f4Smrg # Separate optargs to long options (plugins may need this): 1955493f84f4Smrg --*=*) func_split_equals "$_G_opt" 1956493f84f4Smrg set dummy "$func_split_equals_lhs" \ 1957493f84f4Smrg "$func_split_equals_rhs" ${1+"$@"} 1958493f84f4Smrg shift 1959493f84f4Smrg ;; 1960493f84f4Smrg 1961493f84f4Smrg # Separate optargs to short options: 1962493f84f4Smrg -W*) 1963493f84f4Smrg func_split_short_opt "$_G_opt" 1964493f84f4Smrg set dummy "$func_split_short_opt_name" \ 1965493f84f4Smrg "$func_split_short_opt_arg" ${1+"$@"} 1966493f84f4Smrg shift 1967493f84f4Smrg ;; 1968493f84f4Smrg 1969493f84f4Smrg # Separate non-argument short options: 1970493f84f4Smrg -\?*|-h*|-v*|-x*) 1971493f84f4Smrg func_split_short_opt "$_G_opt" 1972493f84f4Smrg set dummy "$func_split_short_opt_name" \ 1973493f84f4Smrg "-$func_split_short_opt_arg" ${1+"$@"} 1974493f84f4Smrg shift 1975493f84f4Smrg ;; 1976493f84f4Smrg 19771e423a8fSmrg --) _G_parse_options_requote=: ; break ;; 1978493f84f4Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 19791e423a8fSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift 19801e423a8fSmrg _G_match_parse_options=false 19811e423a8fSmrg break 19821e423a8fSmrg ;; 1983493f84f4Smrg esac 19841e423a8fSmrg 19851e423a8fSmrg if $_G_match_parse_options; then 19861e423a8fSmrg _G_parse_options_requote=: 19871e423a8fSmrg fi 1988493f84f4Smrg done 1989493f84f4Smrg 19901e423a8fSmrg if $_G_parse_options_requote; then 19911e423a8fSmrg # save modified positional parameters for caller 19921e423a8fSmrg func_quote eval ${1+"$@"} 19931e423a8fSmrg func_parse_options_result=$func_quote_result 19941e423a8fSmrg fi 1995fe5e51b7Smrg} 1996fe5e51b7Smrg 1997a31a186aSmrg 1998493f84f4Smrg# func_validate_options [ARG]... 1999493f84f4Smrg# ------------------------------ 2000493f84f4Smrg# Perform any sanity checks on option settings and/or unconsumed 2001493f84f4Smrg# arguments. 2002493f84f4Smrgfunc_hookable func_validate_options 2003493f84f4Smrgfunc_validate_options () 2004fe5e51b7Smrg{ 2005493f84f4Smrg $debug_cmd 2006a31a186aSmrg 2007493f84f4Smrg # Display all warnings if -W was not given. 2008493f84f4Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 2009a31a186aSmrg 2010493f84f4Smrg func_run_hooks func_validate_options ${1+"$@"} 20111e423a8fSmrg func_propagate_result func_run_hooks func_validate_options 2012fe5e51b7Smrg 2013493f84f4Smrg # Bail if the options were screwed! 2014493f84f4Smrg $exit_cmd $EXIT_FAILURE 20150bb88ba4Smrg} 2016a31a186aSmrg 2017a31a186aSmrg 20180bb88ba4Smrg 2019493f84f4Smrg## ----------------- ## 2020493f84f4Smrg## Helper functions. ## 2021493f84f4Smrg## ----------------- ## 2022a31a186aSmrg 2023493f84f4Smrg# This section contains the helper functions used by the rest of the 2024493f84f4Smrg# hookable option parser framework in ascii-betical order. 2025493f84f4Smrg 2026493f84f4Smrg 2027493f84f4Smrg# func_fatal_help ARG... 2028493f84f4Smrg# ---------------------- 2029493f84f4Smrg# Echo program name prefixed message to standard error, followed by 2030493f84f4Smrg# a help hint, and exit. 2031493f84f4Smrgfunc_fatal_help () 2032a31a186aSmrg{ 2033493f84f4Smrg $debug_cmd 20340bb88ba4Smrg 2035493f84f4Smrg eval \$ECHO \""Usage: $usage"\" 2036493f84f4Smrg eval \$ECHO \""$fatal_help"\" 2037493f84f4Smrg func_error ${1+"$@"} 2038493f84f4Smrg exit $EXIT_FAILURE 2039a31a186aSmrg} 2040a31a186aSmrg 2041493f84f4Smrg 2042493f84f4Smrg# func_help 2043493f84f4Smrg# --------- 2044493f84f4Smrg# Echo long help message to standard output and exit. 2045a31a186aSmrgfunc_help () 2046a31a186aSmrg{ 2047493f84f4Smrg $debug_cmd 2048493f84f4Smrg 2049493f84f4Smrg func_usage_message 2050493f84f4Smrg $ECHO "$long_help_message" 2051493f84f4Smrg exit 0 2052a31a186aSmrg} 2053a31a186aSmrg 2054493f84f4Smrg 2055493f84f4Smrg# func_missing_arg ARGNAME 2056493f84f4Smrg# ------------------------ 2057a31a186aSmrg# Echo program name prefixed message to standard error and set global 2058a31a186aSmrg# exit_cmd. 2059a31a186aSmrgfunc_missing_arg () 2060a31a186aSmrg{ 2061493f84f4Smrg $debug_cmd 20620bb88ba4Smrg 2063493f84f4Smrg func_error "Missing argument for '$1'." 2064a31a186aSmrg exit_cmd=exit 2065fe5e51b7Smrg} 2066fe5e51b7Smrg 2067eda3803bSmrg 2068493f84f4Smrg# func_split_equals STRING 2069493f84f4Smrg# ------------------------ 20701e423a8fSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 20711e423a8fSmrg# after splitting STRING at the '=' sign. 2072493f84f4Smrgtest -z "$_G_HAVE_XSI_OPS" \ 2073493f84f4Smrg && (eval 'x=a/b/c; 2074493f84f4Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 2075493f84f4Smrg && _G_HAVE_XSI_OPS=yes 2076493f84f4Smrg 2077493f84f4Smrgif test yes = "$_G_HAVE_XSI_OPS" 2078493f84f4Smrgthen 2079493f84f4Smrg # This is an XSI compatible shell, allowing a faster implementation... 2080493f84f4Smrg eval 'func_split_equals () 2081493f84f4Smrg { 2082493f84f4Smrg $debug_cmd 2083493f84f4Smrg 2084493f84f4Smrg func_split_equals_lhs=${1%%=*} 2085493f84f4Smrg func_split_equals_rhs=${1#*=} 20861e423a8fSmrg if test "x$func_split_equals_lhs" = "x$1"; then 20871e423a8fSmrg func_split_equals_rhs= 20881e423a8fSmrg fi 2089493f84f4Smrg }' 2090493f84f4Smrgelse 2091493f84f4Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 2092493f84f4Smrg func_split_equals () 2093493f84f4Smrg { 2094493f84f4Smrg $debug_cmd 2095493f84f4Smrg 2096493f84f4Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 2097493f84f4Smrg func_split_equals_rhs= 20981e423a8fSmrg test "x$func_split_equals_lhs=" = "x$1" \ 2099493f84f4Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 2100493f84f4Smrg } 2101493f84f4Smrgfi #func_split_equals 2102493f84f4Smrg 2103493f84f4Smrg 2104493f84f4Smrg# func_split_short_opt SHORTOPT 2105493f84f4Smrg# ----------------------------- 21060bb88ba4Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 21070bb88ba4Smrg# variables after splitting SHORTOPT after the 2nd character. 2108493f84f4Smrgif test yes = "$_G_HAVE_XSI_OPS" 2109493f84f4Smrgthen 2110493f84f4Smrg # This is an XSI compatible shell, allowing a faster implementation... 2111493f84f4Smrg eval 'func_split_short_opt () 2112493f84f4Smrg { 2113493f84f4Smrg $debug_cmd 2114493f84f4Smrg 2115493f84f4Smrg func_split_short_opt_arg=${1#??} 2116493f84f4Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 2117493f84f4Smrg }' 2118493f84f4Smrgelse 2119493f84f4Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 2120493f84f4Smrg func_split_short_opt () 2121493f84f4Smrg { 2122493f84f4Smrg $debug_cmd 2123493f84f4Smrg 21241e423a8fSmrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 2125493f84f4Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 2126493f84f4Smrg } 2127493f84f4Smrgfi #func_split_short_opt 2128493f84f4Smrg 2129493f84f4Smrg 2130493f84f4Smrg# func_usage 2131493f84f4Smrg# ---------- 2132493f84f4Smrg# Echo short help message to standard output and exit. 2133493f84f4Smrgfunc_usage () 21340bb88ba4Smrg{ 2135493f84f4Smrg $debug_cmd 2136eda3803bSmrg 2137493f84f4Smrg func_usage_message 2138493f84f4Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 2139493f84f4Smrg exit 0 2140493f84f4Smrg} 21410bb88ba4Smrg 21420bb88ba4Smrg 2143493f84f4Smrg# func_usage_message 2144493f84f4Smrg# ------------------ 2145493f84f4Smrg# Echo short help message to standard output. 2146493f84f4Smrgfunc_usage_message () 21470bb88ba4Smrg{ 2148493f84f4Smrg $debug_cmd 21490bb88ba4Smrg 2150493f84f4Smrg eval \$ECHO \""Usage: $usage"\" 2151493f84f4Smrg echo 2152493f84f4Smrg $SED -n 's|^# || 2153493f84f4Smrg /^Written by/{ 2154493f84f4Smrg x;p;x 2155493f84f4Smrg } 2156493f84f4Smrg h 2157493f84f4Smrg /^Written by/q' < "$progpath" 2158493f84f4Smrg echo 2159493f84f4Smrg eval \$ECHO \""$usage_message"\" 2160493f84f4Smrg} 21610bb88ba4Smrg 2162a31a186aSmrg 2163493f84f4Smrg# func_version 2164493f84f4Smrg# ------------ 2165493f84f4Smrg# Echo version message to standard output and exit. 21661e423a8fSmrg# The version message is extracted from the calling file's header 21671e423a8fSmrg# comments, with leading '# ' stripped: 21681e423a8fSmrg# 1. First display the progname and version 21691e423a8fSmrg# 2. Followed by the header comment line matching /^# Written by / 21701e423a8fSmrg# 3. Then a blank line followed by the first following line matching 21711e423a8fSmrg# /^# Copyright / 21721e423a8fSmrg# 4. Immediately followed by any lines between the previous matches, 21731e423a8fSmrg# except lines preceding the intervening completely blank line. 21741e423a8fSmrg# For example, see the header comments of this file. 2175493f84f4Smrgfunc_version () 2176493f84f4Smrg{ 2177493f84f4Smrg $debug_cmd 2178a31a186aSmrg 2179493f84f4Smrg printf '%s\n' "$progname $scriptversion" 2180493f84f4Smrg $SED -n ' 21811e423a8fSmrg /^# Written by /!b 21821e423a8fSmrg s|^# ||; p; n 21831e423a8fSmrg 21841e423a8fSmrg :fwd2blnk 21851e423a8fSmrg /./ { 21861e423a8fSmrg n 21871e423a8fSmrg b fwd2blnk 2188493f84f4Smrg } 21891e423a8fSmrg p; n 21901e423a8fSmrg 21911e423a8fSmrg :holdwrnt 21921e423a8fSmrg s|^# || 21931e423a8fSmrg s|^# *$|| 21941e423a8fSmrg /^Copyright /!{ 21951e423a8fSmrg /./H 21961e423a8fSmrg n 21971e423a8fSmrg b holdwrnt 2198493f84f4Smrg } 21991e423a8fSmrg 22001e423a8fSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 22011e423a8fSmrg G 22021e423a8fSmrg s|\(\n\)\n*|\1|g 22031e423a8fSmrg p; q' < "$progpath" 2204a31a186aSmrg 2205493f84f4Smrg exit $? 2206493f84f4Smrg} 2207fe5e51b7Smrg 2208fe5e51b7Smrg 2209493f84f4Smrg# Local variables: 2210493f84f4Smrg# mode: shell-script 2211493f84f4Smrg# sh-indentation: 2 2212493f84f4Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 22131e423a8fSmrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 2214493f84f4Smrg# time-stamp-time-zone: "UTC" 2215493f84f4Smrg# End: 2216fe5e51b7Smrg 2217493f84f4Smrg# Set a version string. 22181e423a8fSmrgscriptversion='(GNU libtool) 2.4.7' 2219eda3803bSmrg 2220a31a186aSmrg 2221493f84f4Smrg# func_echo ARG... 2222493f84f4Smrg# ---------------- 2223493f84f4Smrg# Libtool also displays the current mode in messages, so override 2224493f84f4Smrg# funclib.sh func_echo with this custom definition. 2225493f84f4Smrgfunc_echo () 22260bb88ba4Smrg{ 2227493f84f4Smrg $debug_cmd 22280bb88ba4Smrg 2229493f84f4Smrg _G_message=$* 22300bb88ba4Smrg 2231493f84f4Smrg func_echo_IFS=$IFS 2232493f84f4Smrg IFS=$nl 2233493f84f4Smrg for _G_line in $_G_message; do 2234493f84f4Smrg IFS=$func_echo_IFS 2235493f84f4Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 2236493f84f4Smrg done 2237493f84f4Smrg IFS=$func_echo_IFS 2238493f84f4Smrg} 22390bb88ba4Smrg 2240493f84f4Smrg 2241493f84f4Smrg# func_warning ARG... 2242493f84f4Smrg# ------------------- 2243493f84f4Smrg# Libtool warnings are not categorized, so override funclib.sh 2244493f84f4Smrg# func_warning with this simpler definition. 2245493f84f4Smrgfunc_warning () 22460bb88ba4Smrg{ 2247493f84f4Smrg $debug_cmd 22480bb88ba4Smrg 2249493f84f4Smrg $warning_func ${1+"$@"} 2250493f84f4Smrg} 22510bb88ba4Smrg 22520bb88ba4Smrg 2253493f84f4Smrg## ---------------- ## 2254493f84f4Smrg## Options parsing. ## 2255493f84f4Smrg## ---------------- ## 2256493f84f4Smrg 2257493f84f4Smrg# Hook in the functions to make sure our own options are parsed during 2258493f84f4Smrg# the option parsing loop. 2259493f84f4Smrg 2260493f84f4Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 2261493f84f4Smrg 2262493f84f4Smrg# Short help message in response to '-h'. 2263493f84f4Smrgusage_message="Options: 2264493f84f4Smrg --config show all configuration variables 2265493f84f4Smrg --debug enable verbose shell tracing 2266493f84f4Smrg -n, --dry-run display commands without modifying any files 2267493f84f4Smrg --features display basic configuration information and exit 2268493f84f4Smrg --mode=MODE use operation mode MODE 2269493f84f4Smrg --no-warnings equivalent to '-Wnone' 2270493f84f4Smrg --preserve-dup-deps don't remove duplicate dependency libraries 2271493f84f4Smrg --quiet, --silent don't print informational messages 2272493f84f4Smrg --tag=TAG use configuration variables from tag TAG 2273493f84f4Smrg -v, --verbose print more informational messages than default 2274493f84f4Smrg --version print version information 2275493f84f4Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2276493f84f4Smrg -h, --help, --help-all print short, long, or detailed help message 2277493f84f4Smrg" 22780bb88ba4Smrg 2279493f84f4Smrg# Additional text appended to 'usage_message' in response to '--help'. 2280ee82cb62Smrgfunc_help () 2281ee82cb62Smrg{ 2282ee82cb62Smrg $debug_cmd 2283ee82cb62Smrg 2284ee82cb62Smrg func_usage_message 2285ee82cb62Smrg $ECHO "$long_help_message 22860bb88ba4Smrg 2287493f84f4SmrgMODE must be one of the following: 22880bb88ba4Smrg 2289493f84f4Smrg clean remove files from the build directory 2290493f84f4Smrg compile compile a source file into a libtool object 2291493f84f4Smrg execute automatically set library path, then run a program 2292493f84f4Smrg finish complete the installation of libtool libraries 2293493f84f4Smrg install install libraries or executables 2294493f84f4Smrg link create a library or an executable 2295493f84f4Smrg uninstall remove libraries from an installed directory 2296493f84f4Smrg 2297493f84f4SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 2298493f84f4Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2299493f84f4SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2300493f84f4Smrg 2301493f84f4SmrgWhen reporting a bug, please describe a test case to reproduce it and 2302493f84f4Smrginclude the following information: 2303493f84f4Smrg 2304493f84f4Smrg host-triplet: $host 2305493f84f4Smrg shell: $SHELL 2306493f84f4Smrg compiler: $LTCC 2307493f84f4Smrg compiler flags: $LTCFLAGS 2308493f84f4Smrg linker: $LD (gnu? $with_gnu_ld) 23091e423a8fSmrg version: $progname (GNU libtool) 2.4.7 2310493f84f4Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2311493f84f4Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2312493f84f4Smrg 2313493f84f4SmrgReport bugs to <bug-libtool@gnu.org>. 23141e423a8fSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 2315493f84f4SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2316ee82cb62Smrg exit 0 2317ee82cb62Smrg} 2318493f84f4Smrg 2319493f84f4Smrg 2320493f84f4Smrg# func_lo2o OBJECT-NAME 2321493f84f4Smrg# --------------------- 2322493f84f4Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2323493f84f4Smrg# object suffix. 2324493f84f4Smrg 2325493f84f4Smrglo2o=s/\\.lo\$/.$objext/ 2326493f84f4Smrgo2lo=s/\\.$objext\$/.lo/ 2327493f84f4Smrg 2328493f84f4Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 2329493f84f4Smrg eval 'func_lo2o () 2330493f84f4Smrg { 2331493f84f4Smrg case $1 in 2332493f84f4Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2333493f84f4Smrg * ) func_lo2o_result=$1 ;; 2334493f84f4Smrg esac 2335493f84f4Smrg }' 2336493f84f4Smrg 2337493f84f4Smrg # func_xform LIBOBJ-OR-SOURCE 2338493f84f4Smrg # --------------------------- 2339493f84f4Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2340493f84f4Smrg # suffix to a '.lo' libtool-object suffix. 2341493f84f4Smrg eval 'func_xform () 2342493f84f4Smrg { 2343493f84f4Smrg func_xform_result=${1%.*}.lo 2344493f84f4Smrg }' 2345493f84f4Smrgelse 2346493f84f4Smrg # ...otherwise fall back to using sed. 2347493f84f4Smrg func_lo2o () 2348493f84f4Smrg { 2349493f84f4Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2350493f84f4Smrg } 2351493f84f4Smrg 2352493f84f4Smrg func_xform () 2353493f84f4Smrg { 2354493f84f4Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2355493f84f4Smrg } 2356493f84f4Smrgfi 23570bb88ba4Smrg 23580bb88ba4Smrg 2359493f84f4Smrg# func_fatal_configuration ARG... 2360493f84f4Smrg# ------------------------------- 2361a31a186aSmrg# Echo program name prefixed message to standard error, followed by 2362a31a186aSmrg# a configuration failure hint, and exit. 2363a31a186aSmrgfunc_fatal_configuration () 2364a31a186aSmrg{ 23651e423a8fSmrg func_fatal_error ${1+"$@"} \ 2366493f84f4Smrg "See the $PACKAGE documentation for more information." \ 2367493f84f4Smrg "Fatal configuration error." 2368a31a186aSmrg} 2369fe5e51b7Smrg 2370eda3803bSmrg 2371a31a186aSmrg# func_config 2372493f84f4Smrg# ----------- 2373a31a186aSmrg# Display the configuration for all the tags in this script. 2374a31a186aSmrgfunc_config () 2375a31a186aSmrg{ 2376a31a186aSmrg re_begincf='^# ### BEGIN LIBTOOL' 2377a31a186aSmrg re_endcf='^# ### END LIBTOOL' 2378a31a186aSmrg 2379a31a186aSmrg # Default configuration. 2380a31a186aSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2381fe5e51b7Smrg 2382fe5e51b7Smrg # Now print the configurations for the tags. 2383fe5e51b7Smrg for tagname in $taglist; do 2384a31a186aSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2385fe5e51b7Smrg done 2386643b027fSmrg 2387a31a186aSmrg exit $? 2388a31a186aSmrg} 2389643b027fSmrg 2390493f84f4Smrg 2391a31a186aSmrg# func_features 2392493f84f4Smrg# ------------- 2393a31a186aSmrg# Display the features supported by this script. 2394a31a186aSmrgfunc_features () 2395a31a186aSmrg{ 23960bb88ba4Smrg echo "host: $host" 2397493f84f4Smrg if test yes = "$build_libtool_libs"; then 23980bb88ba4Smrg echo "enable shared libraries" 2399fe5e51b7Smrg else 24000bb88ba4Smrg echo "disable shared libraries" 2401fe5e51b7Smrg fi 2402493f84f4Smrg if test yes = "$build_old_libs"; then 24030bb88ba4Smrg echo "enable static libraries" 2404fe5e51b7Smrg else 24050bb88ba4Smrg echo "disable static libraries" 2406fe5e51b7Smrg fi 2407a31a186aSmrg 2408fe5e51b7Smrg exit $? 2409a31a186aSmrg} 2410fe5e51b7Smrg 2411493f84f4Smrg 2412493f84f4Smrg# func_enable_tag TAGNAME 2413493f84f4Smrg# ----------------------- 2414a31a186aSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2415a31a186aSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2416a31a186aSmrg# variable here. 2417a31a186aSmrgfunc_enable_tag () 2418a31a186aSmrg{ 2419493f84f4Smrg # Global variable: 2420493f84f4Smrg tagname=$1 2421fe5e51b7Smrg 2422493f84f4Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2423493f84f4Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2424493f84f4Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2425eda3803bSmrg 2426493f84f4Smrg # Validate tagname. 2427493f84f4Smrg case $tagname in 2428493f84f4Smrg *[!-_A-Za-z0-9,/]*) 2429493f84f4Smrg func_fatal_error "invalid tag name: $tagname" 2430493f84f4Smrg ;; 2431493f84f4Smrg esac 2432fe5e51b7Smrg 2433493f84f4Smrg # Don't test for the "default" C tag, as we know it's 2434493f84f4Smrg # there but not specially marked. 2435493f84f4Smrg case $tagname in 2436493f84f4Smrg CC) ;; 2437a31a186aSmrg *) 2438493f84f4Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2439493f84f4Smrg taglist="$taglist $tagname" 2440493f84f4Smrg 2441493f84f4Smrg # Evaluate the configuration. Be careful to quote the path 2442493f84f4Smrg # and the sed script, to avoid splitting on whitespace, but 2443493f84f4Smrg # also don't use non-portable quotes within backquotes within 2444493f84f4Smrg # quotes we have to do it in 2 steps: 2445493f84f4Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2446493f84f4Smrg eval "$extractedcf" 2447493f84f4Smrg else 2448493f84f4Smrg func_error "ignoring unknown tag $tagname" 2449493f84f4Smrg fi 2450493f84f4Smrg ;; 2451493f84f4Smrg esac 2452a31a186aSmrg} 2453a31a186aSmrg 2454493f84f4Smrg 24550bb88ba4Smrg# func_check_version_match 2456493f84f4Smrg# ------------------------ 24570bb88ba4Smrg# Ensure that we are using m4 macros, and libtool script from the same 24580bb88ba4Smrg# release of libtool. 24590bb88ba4Smrgfunc_check_version_match () 2460a31a186aSmrg{ 2461493f84f4Smrg if test "$package_revision" != "$macro_revision"; then 2462493f84f4Smrg if test "$VERSION" != "$macro_version"; then 2463493f84f4Smrg if test -z "$macro_version"; then 2464493f84f4Smrg cat >&2 <<_LT_EOF 24650bb88ba4Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 24660bb88ba4Smrg$progname: definition of this LT_INIT comes from an older release. 24670bb88ba4Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 24680bb88ba4Smrg$progname: and run autoconf again. 24690bb88ba4Smrg_LT_EOF 2470493f84f4Smrg else 2471493f84f4Smrg cat >&2 <<_LT_EOF 24720bb88ba4Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 24730bb88ba4Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 24740bb88ba4Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 24750bb88ba4Smrg$progname: and run autoconf again. 24760bb88ba4Smrg_LT_EOF 2477493f84f4Smrg fi 2478493f84f4Smrg else 2479493f84f4Smrg cat >&2 <<_LT_EOF 24800bb88ba4Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 24810bb88ba4Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 24820bb88ba4Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 24830bb88ba4Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 24840bb88ba4Smrg_LT_EOF 2485493f84f4Smrg fi 24860bb88ba4Smrg 2487493f84f4Smrg exit $EXIT_MISMATCH 2488493f84f4Smrg fi 24890bb88ba4Smrg} 24900bb88ba4Smrg 24910bb88ba4Smrg 2492493f84f4Smrg# libtool_options_prep [ARG]... 2493493f84f4Smrg# ----------------------------- 2494493f84f4Smrg# Preparation for options parsed by libtool. 2495493f84f4Smrglibtool_options_prep () 2496493f84f4Smrg{ 2497493f84f4Smrg $debug_mode 24980bb88ba4Smrg 2499493f84f4Smrg # Option defaults: 2500493f84f4Smrg opt_config=false 2501493f84f4Smrg opt_dlopen= 2502493f84f4Smrg opt_dry_run=false 2503493f84f4Smrg opt_help=false 2504493f84f4Smrg opt_mode= 2505493f84f4Smrg opt_preserve_dup_deps=false 2506493f84f4Smrg opt_quiet=false 25070bb88ba4Smrg 2508493f84f4Smrg nonopt= 2509493f84f4Smrg preserve_args= 25100bb88ba4Smrg 25111e423a8fSmrg _G_rc_lt_options_prep=: 25121e423a8fSmrg 2513493f84f4Smrg # Shorthand for --mode=foo, only valid as the first argument 2514493f84f4Smrg case $1 in 2515493f84f4Smrg clean|clea|cle|cl) 2516493f84f4Smrg shift; set dummy --mode clean ${1+"$@"}; shift 2517493f84f4Smrg ;; 2518493f84f4Smrg compile|compil|compi|comp|com|co|c) 2519493f84f4Smrg shift; set dummy --mode compile ${1+"$@"}; shift 2520493f84f4Smrg ;; 2521493f84f4Smrg execute|execut|execu|exec|exe|ex|e) 2522493f84f4Smrg shift; set dummy --mode execute ${1+"$@"}; shift 2523493f84f4Smrg ;; 2524493f84f4Smrg finish|finis|fini|fin|fi|f) 2525493f84f4Smrg shift; set dummy --mode finish ${1+"$@"}; shift 2526493f84f4Smrg ;; 2527493f84f4Smrg install|instal|insta|inst|ins|in|i) 2528493f84f4Smrg shift; set dummy --mode install ${1+"$@"}; shift 2529493f84f4Smrg ;; 2530493f84f4Smrg link|lin|li|l) 2531493f84f4Smrg shift; set dummy --mode link ${1+"$@"}; shift 2532493f84f4Smrg ;; 2533493f84f4Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2534493f84f4Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 2535493f84f4Smrg ;; 25361e423a8fSmrg *) 25371e423a8fSmrg _G_rc_lt_options_prep=false 25381e423a8fSmrg ;; 2539493f84f4Smrg esac 2540493f84f4Smrg 25411e423a8fSmrg if $_G_rc_lt_options_prep; then 25421e423a8fSmrg # Pass back the list of options. 25431e423a8fSmrg func_quote eval ${1+"$@"} 25441e423a8fSmrg libtool_options_prep_result=$func_quote_result 25451e423a8fSmrg fi 2546493f84f4Smrg} 2547493f84f4Smrgfunc_add_hook func_options_prep libtool_options_prep 2548643b027fSmrg 2549fe5e51b7Smrg 2550493f84f4Smrg# libtool_parse_options [ARG]... 2551493f84f4Smrg# --------------------------------- 2552493f84f4Smrg# Provide handling for libtool specific options. 2553493f84f4Smrglibtool_parse_options () 25540bb88ba4Smrg{ 2555493f84f4Smrg $debug_cmd 2556a31a186aSmrg 25571e423a8fSmrg _G_rc_lt_parse_options=false 25581e423a8fSmrg 2559493f84f4Smrg # Perform our own loop to consume as many options as possible in 2560493f84f4Smrg # each iteration. 2561493f84f4Smrg while test $# -gt 0; do 25621e423a8fSmrg _G_match_lt_parse_options=: 2563493f84f4Smrg _G_opt=$1 2564493f84f4Smrg shift 2565493f84f4Smrg case $_G_opt in 2566493f84f4Smrg --dry-run|--dryrun|-n) 2567493f84f4Smrg opt_dry_run=: 2568493f84f4Smrg ;; 2569493f84f4Smrg 2570493f84f4Smrg --config) func_config ;; 2571493f84f4Smrg 2572493f84f4Smrg --dlopen|-dlopen) 2573493f84f4Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 2574493f84f4Smrg}$1" 2575493f84f4Smrg shift 2576493f84f4Smrg ;; 2577493f84f4Smrg 2578493f84f4Smrg --preserve-dup-deps) 2579493f84f4Smrg opt_preserve_dup_deps=: ;; 2580493f84f4Smrg 2581493f84f4Smrg --features) func_features ;; 2582493f84f4Smrg 2583493f84f4Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2584493f84f4Smrg 2585493f84f4Smrg --help) opt_help=: ;; 2586493f84f4Smrg 2587493f84f4Smrg --help-all) opt_help=': help-all' ;; 2588493f84f4Smrg 2589493f84f4Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 2590493f84f4Smrg opt_mode=$1 2591493f84f4Smrg case $1 in 2592493f84f4Smrg # Valid mode arguments: 2593493f84f4Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 2594493f84f4Smrg 2595493f84f4Smrg # Catch anything else as an error 2596493f84f4Smrg *) func_error "invalid argument for $_G_opt" 2597493f84f4Smrg exit_cmd=exit 2598493f84f4Smrg break 2599493f84f4Smrg ;; 2600493f84f4Smrg esac 2601493f84f4Smrg shift 2602493f84f4Smrg ;; 2603493f84f4Smrg 2604493f84f4Smrg --no-silent|--no-quiet) 2605493f84f4Smrg opt_quiet=false 2606493f84f4Smrg func_append preserve_args " $_G_opt" 2607493f84f4Smrg ;; 2608493f84f4Smrg 2609493f84f4Smrg --no-warnings|--no-warning|--no-warn) 2610493f84f4Smrg opt_warning=false 2611493f84f4Smrg func_append preserve_args " $_G_opt" 2612493f84f4Smrg ;; 2613493f84f4Smrg 2614493f84f4Smrg --no-verbose) 2615493f84f4Smrg opt_verbose=false 2616493f84f4Smrg func_append preserve_args " $_G_opt" 2617493f84f4Smrg ;; 2618493f84f4Smrg 2619493f84f4Smrg --silent|--quiet) 2620493f84f4Smrg opt_quiet=: 2621493f84f4Smrg opt_verbose=false 2622493f84f4Smrg func_append preserve_args " $_G_opt" 2623493f84f4Smrg ;; 2624493f84f4Smrg 2625493f84f4Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 2626493f84f4Smrg opt_tag=$1 2627493f84f4Smrg func_append preserve_args " $_G_opt $1" 2628493f84f4Smrg func_enable_tag "$1" 2629493f84f4Smrg shift 2630493f84f4Smrg ;; 2631493f84f4Smrg 2632493f84f4Smrg --verbose|-v) opt_quiet=false 2633493f84f4Smrg opt_verbose=: 2634493f84f4Smrg func_append preserve_args " $_G_opt" 2635493f84f4Smrg ;; 2636493f84f4Smrg 26371e423a8fSmrg # An option not handled by this hook function: 26381e423a8fSmrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 26391e423a8fSmrg _G_match_lt_parse_options=false 26401e423a8fSmrg break 26411e423a8fSmrg ;; 2642493f84f4Smrg esac 26431e423a8fSmrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 2644493f84f4Smrg done 26450bb88ba4Smrg 26461e423a8fSmrg if $_G_rc_lt_parse_options; then 26471e423a8fSmrg # save modified positional parameters for caller 26481e423a8fSmrg func_quote eval ${1+"$@"} 26491e423a8fSmrg libtool_parse_options_result=$func_quote_result 26501e423a8fSmrg fi 2651493f84f4Smrg} 2652493f84f4Smrgfunc_add_hook func_parse_options libtool_parse_options 2653a31a186aSmrg 2654eda3803bSmrg 2655a31a186aSmrg 2656493f84f4Smrg# libtool_validate_options [ARG]... 2657493f84f4Smrg# --------------------------------- 2658493f84f4Smrg# Perform any sanity checks on option settings and/or unconsumed 2659493f84f4Smrg# arguments. 2660493f84f4Smrglibtool_validate_options () 2661493f84f4Smrg{ 2662493f84f4Smrg # save first non-option argument 2663493f84f4Smrg if test 0 -lt $#; then 2664493f84f4Smrg nonopt=$1 2665493f84f4Smrg shift 2666a31a186aSmrg fi 2667a31a186aSmrg 2668493f84f4Smrg # preserve --debug 2669493f84f4Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2670a31a186aSmrg 2671493f84f4Smrg case $host in 2672493f84f4Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2673493f84f4Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2674493f84f4Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2675493f84f4Smrg # don't eliminate duplications in $postdeps and $predeps 2676493f84f4Smrg opt_duplicate_compiler_generated_deps=: 2677493f84f4Smrg ;; 2678493f84f4Smrg *) 2679493f84f4Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2680493f84f4Smrg ;; 2681493f84f4Smrg esac 2682fe5e51b7Smrg 2683493f84f4Smrg $opt_help || { 2684493f84f4Smrg # Sanity checks first: 2685493f84f4Smrg func_check_version_match 2686493f84f4Smrg 2687493f84f4Smrg test yes != "$build_libtool_libs" \ 2688493f84f4Smrg && test yes != "$build_old_libs" \ 2689493f84f4Smrg && func_fatal_configuration "not configured to build any kind of library" 2690493f84f4Smrg 2691493f84f4Smrg # Darwin sucks 2692493f84f4Smrg eval std_shrext=\"$shrext_cmds\" 2693a31a186aSmrg 2694493f84f4Smrg # Only execute mode is allowed to have -dlopen flags. 2695493f84f4Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2696493f84f4Smrg func_error "unrecognized option '-dlopen'" 2697493f84f4Smrg $ECHO "$help" 1>&2 2698493f84f4Smrg exit $EXIT_FAILURE 2699493f84f4Smrg fi 2700493f84f4Smrg 2701493f84f4Smrg # Change the help message to a mode-specific one. 2702493f84f4Smrg generic_help=$help 2703493f84f4Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 2704493f84f4Smrg } 2705a31a186aSmrg 2706493f84f4Smrg # Pass back the unparsed argument list 27071e423a8fSmrg func_quote eval ${1+"$@"} 27081e423a8fSmrg libtool_validate_options_result=$func_quote_result 27090bb88ba4Smrg} 2710493f84f4Smrgfunc_add_hook func_validate_options libtool_validate_options 2711493f84f4Smrg 2712a31a186aSmrg 2713493f84f4Smrg# Process options as early as possible so that --help and --version 2714493f84f4Smrg# can return quickly. 2715493f84f4Smrgfunc_options ${1+"$@"} 2716493f84f4Smrgeval set dummy "$func_options_result"; shift 2717493f84f4Smrg 2718493f84f4Smrg 2719493f84f4Smrg 2720493f84f4Smrg## ----------- ## 2721493f84f4Smrg## Main. ## 2722493f84f4Smrg## ----------- ## 2723493f84f4Smrg 2724493f84f4Smrgmagic='%%%MAGIC variable%%%' 2725493f84f4Smrgmagic_exe='%%%MAGIC EXE variable%%%' 2726493f84f4Smrg 2727493f84f4Smrg# Global variables. 2728493f84f4Smrgextracted_archives= 2729493f84f4Smrgextracted_serial=0 2730493f84f4Smrg 2731493f84f4Smrg# If this variable is set in any of the actions, the command in it 2732493f84f4Smrg# will be execed at the end. This prevents here-documents from being 2733493f84f4Smrg# left over by shells. 2734493f84f4Smrgexec_cmd= 2735a31a186aSmrg 2736fe5e51b7Smrg 2737493f84f4Smrg# A function that is used when there is no print builtin or printf. 2738493f84f4Smrgfunc_fallback_echo () 2739493f84f4Smrg{ 2740493f84f4Smrg eval 'cat <<_LTECHO_EOF 2741493f84f4Smrg$1 2742493f84f4Smrg_LTECHO_EOF' 2743493f84f4Smrg} 2744fe5e51b7Smrg 2745493f84f4Smrg# func_generated_by_libtool 2746493f84f4Smrg# True iff stdin has been generated by Libtool. This function is only 2747493f84f4Smrg# a basic sanity check; it will hardly flush out determined imposters. 2748493f84f4Smrgfunc_generated_by_libtool_p () 2749493f84f4Smrg{ 2750493f84f4Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2751493f84f4Smrg} 2752fe5e51b7Smrg 2753a31a186aSmrg# func_lalib_p file 2754493f84f4Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2755a31a186aSmrg# This function is only a basic sanity check; it will hardly flush out 2756a31a186aSmrg# determined imposters. 2757a31a186aSmrgfunc_lalib_p () 2758a31a186aSmrg{ 2759a31a186aSmrg test -f "$1" && 2760493f84f4Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2761a31a186aSmrg} 2762fe5e51b7Smrg 2763a31a186aSmrg# func_lalib_unsafe_p file 2764493f84f4Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2765a31a186aSmrg# This function implements the same check as func_lalib_p without 2766a31a186aSmrg# resorting to external programs. To this end, it redirects stdin and 2767a31a186aSmrg# closes it afterwards, without saving the original file descriptor. 2768a31a186aSmrg# As a safety measure, use it only where a negative result would be 2769493f84f4Smrg# fatal anyway. Works if 'file' does not exist. 2770a31a186aSmrgfunc_lalib_unsafe_p () 2771a31a186aSmrg{ 2772a31a186aSmrg lalib_p=no 2773a31a186aSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2774a31a186aSmrg for lalib_p_l in 1 2 3 4 2775a31a186aSmrg do 2776a31a186aSmrg read lalib_p_line 2777493f84f4Smrg case $lalib_p_line in 2778a31a186aSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2779a31a186aSmrg esac 2780a31a186aSmrg done 2781a31a186aSmrg exec 0<&5 5<&- 2782a31a186aSmrg fi 2783493f84f4Smrg test yes = "$lalib_p" 2784a31a186aSmrg} 2785fe5e51b7Smrg 2786a31a186aSmrg# func_ltwrapper_script_p file 2787a31a186aSmrg# True iff FILE is a libtool wrapper script 2788a31a186aSmrg# This function is only a basic sanity check; it will hardly flush out 2789a31a186aSmrg# determined imposters. 2790a31a186aSmrgfunc_ltwrapper_script_p () 2791a31a186aSmrg{ 2792493f84f4Smrg test -f "$1" && 2793493f84f4Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2794a31a186aSmrg} 2795fe5e51b7Smrg 2796a31a186aSmrg# func_ltwrapper_executable_p file 2797a31a186aSmrg# True iff FILE is a libtool wrapper executable 2798a31a186aSmrg# This function is only a basic sanity check; it will hardly flush out 2799a31a186aSmrg# determined imposters. 2800a31a186aSmrgfunc_ltwrapper_executable_p () 2801a31a186aSmrg{ 2802a31a186aSmrg func_ltwrapper_exec_suffix= 2803a31a186aSmrg case $1 in 2804a31a186aSmrg *.exe) ;; 2805a31a186aSmrg *) func_ltwrapper_exec_suffix=.exe ;; 2806a31a186aSmrg esac 2807a31a186aSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2808a31a186aSmrg} 2809eda3803bSmrg 2810a31a186aSmrg# func_ltwrapper_scriptname file 2811a31a186aSmrg# Assumes file is an ltwrapper_executable 2812a31a186aSmrg# uses $file to determine the appropriate filename for a 2813a31a186aSmrg# temporary ltwrapper_script. 2814a31a186aSmrgfunc_ltwrapper_scriptname () 2815a31a186aSmrg{ 28160bb88ba4Smrg func_dirname_and_basename "$1" "" "." 28170bb88ba4Smrg func_stripname '' '.exe' "$func_basename_result" 2818493f84f4Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2819a31a186aSmrg} 2820a31a186aSmrg 2821a31a186aSmrg# func_ltwrapper_p file 2822a31a186aSmrg# True iff FILE is a libtool wrapper script or wrapper executable 2823a31a186aSmrg# This function is only a basic sanity check; it will hardly flush out 2824a31a186aSmrg# determined imposters. 2825a31a186aSmrgfunc_ltwrapper_p () 2826a31a186aSmrg{ 2827a31a186aSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2828a31a186aSmrg} 2829a31a186aSmrg 2830a31a186aSmrg 2831a31a186aSmrg# func_execute_cmds commands fail_cmd 2832a31a186aSmrg# Execute tilde-delimited COMMANDS. 2833a31a186aSmrg# If FAIL_CMD is given, eval that upon failure. 2834a31a186aSmrg# FAIL_CMD may read-access the current command in variable CMD! 2835a31a186aSmrgfunc_execute_cmds () 2836a31a186aSmrg{ 2837493f84f4Smrg $debug_cmd 2838493f84f4Smrg 2839a31a186aSmrg save_ifs=$IFS; IFS='~' 2840a31a186aSmrg for cmd in $1; do 2841493f84f4Smrg IFS=$sp$nl 2842a31a186aSmrg eval cmd=\"$cmd\" 2843493f84f4Smrg IFS=$save_ifs 2844a31a186aSmrg func_show_eval "$cmd" "${2-:}" 2845a31a186aSmrg done 2846a31a186aSmrg IFS=$save_ifs 2847a31a186aSmrg} 2848a31a186aSmrg 2849a31a186aSmrg 2850a31a186aSmrg# func_source file 2851a31a186aSmrg# Source FILE, adding directory component if necessary. 2852a31a186aSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 2853a31a186aSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2854a31a186aSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 2855493f84f4Smrg# 'FILE.' does not work on cygwin managed mounts. 2856a31a186aSmrgfunc_source () 2857a31a186aSmrg{ 2858493f84f4Smrg $debug_cmd 2859493f84f4Smrg 2860a31a186aSmrg case $1 in 2861a31a186aSmrg */* | *\\*) . "$1" ;; 2862a31a186aSmrg *) . "./$1" ;; 2863a31a186aSmrg esac 2864a31a186aSmrg} 2865a31a186aSmrg 2866a31a186aSmrg 28670bb88ba4Smrg# func_resolve_sysroot PATH 28680bb88ba4Smrg# Replace a leading = in PATH with a sysroot. Store the result into 28690bb88ba4Smrg# func_resolve_sysroot_result 28700bb88ba4Smrgfunc_resolve_sysroot () 28710bb88ba4Smrg{ 28720bb88ba4Smrg func_resolve_sysroot_result=$1 28730bb88ba4Smrg case $func_resolve_sysroot_result in 28740bb88ba4Smrg =*) 28750bb88ba4Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 28760bb88ba4Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 28770bb88ba4Smrg ;; 28780bb88ba4Smrg esac 28790bb88ba4Smrg} 28800bb88ba4Smrg 28810bb88ba4Smrg# func_replace_sysroot PATH 28820bb88ba4Smrg# If PATH begins with the sysroot, replace it with = and 28830bb88ba4Smrg# store the result into func_replace_sysroot_result. 28840bb88ba4Smrgfunc_replace_sysroot () 28850bb88ba4Smrg{ 2886493f84f4Smrg case $lt_sysroot:$1 in 28870bb88ba4Smrg ?*:"$lt_sysroot"*) 28880bb88ba4Smrg func_stripname "$lt_sysroot" '' "$1" 2889493f84f4Smrg func_replace_sysroot_result='='$func_stripname_result 28900bb88ba4Smrg ;; 28910bb88ba4Smrg *) 28920bb88ba4Smrg # Including no sysroot. 28930bb88ba4Smrg func_replace_sysroot_result=$1 28940bb88ba4Smrg ;; 28950bb88ba4Smrg esac 28960bb88ba4Smrg} 28970bb88ba4Smrg 2898a31a186aSmrg# func_infer_tag arg 2899a31a186aSmrg# Infer tagged configuration to use if any are available and 2900a31a186aSmrg# if one wasn't chosen via the "--tag" command line option. 2901a31a186aSmrg# Only attempt this if the compiler in the base compile 2902a31a186aSmrg# command doesn't match the default compiler. 2903a31a186aSmrg# arg is usually of the form 'gcc ...' 2904a31a186aSmrgfunc_infer_tag () 2905a31a186aSmrg{ 2906493f84f4Smrg $debug_cmd 2907493f84f4Smrg 2908a31a186aSmrg if test -n "$available_tags" && test -z "$tagname"; then 2909a31a186aSmrg CC_quoted= 2910a31a186aSmrg for arg in $CC; do 29110bb88ba4Smrg func_append_quoted CC_quoted "$arg" 2912a31a186aSmrg done 29130bb88ba4Smrg CC_expanded=`func_echo_all $CC` 29140bb88ba4Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2915a31a186aSmrg case $@ in 2916a31a186aSmrg # Blanks in the command may have been stripped by the calling shell, 2917a31a186aSmrg # but not from the CC environment variable when configure was run. 29180bb88ba4Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 29190bb88ba4Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2920a31a186aSmrg # Blanks at the start of $base_compile will cause this to fail 2921a31a186aSmrg # if we don't check for them as well. 2922a31a186aSmrg *) 2923a31a186aSmrg for z in $available_tags; do 2924a31a186aSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2925a31a186aSmrg # Evaluate the configuration. 2926493f84f4Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2927a31a186aSmrg CC_quoted= 2928a31a186aSmrg for arg in $CC; do 2929a31a186aSmrg # Double-quote args containing other shell metacharacters. 29300bb88ba4Smrg func_append_quoted CC_quoted "$arg" 2931a31a186aSmrg done 29320bb88ba4Smrg CC_expanded=`func_echo_all $CC` 29330bb88ba4Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2934a31a186aSmrg case "$@ " in 29350bb88ba4Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 29360bb88ba4Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2937a31a186aSmrg # The compiler in the base compile command matches 2938a31a186aSmrg # the one in the tagged configuration. 2939a31a186aSmrg # Assume this is the tagged configuration we want. 2940a31a186aSmrg tagname=$z 2941a31a186aSmrg break 2942a31a186aSmrg ;; 2943a31a186aSmrg esac 2944a31a186aSmrg fi 2945a31a186aSmrg done 2946a31a186aSmrg # If $tagname still isn't set, then no tagged configuration 2947a31a186aSmrg # was found and let the user know that the "--tag" command 2948a31a186aSmrg # line option must be used. 2949a31a186aSmrg if test -z "$tagname"; then 2950a31a186aSmrg func_echo "unable to infer tagged configuration" 2951493f84f4Smrg func_fatal_error "specify a tag with '--tag'" 2952a31a186aSmrg# else 2953a31a186aSmrg# func_verbose "using $tagname tagged configuration" 2954a31a186aSmrg fi 2955a31a186aSmrg ;; 2956a31a186aSmrg esac 2957a31a186aSmrg fi 2958a31a186aSmrg} 2959a31a186aSmrg 2960a31a186aSmrg 2961a31a186aSmrg 2962a31a186aSmrg# func_write_libtool_object output_name pic_name nonpic_name 2963a31a186aSmrg# Create a libtool object file (analogous to a ".la" file), 2964a31a186aSmrg# but don't create it if we're doing a dry run. 2965a31a186aSmrgfunc_write_libtool_object () 2966a31a186aSmrg{ 2967493f84f4Smrg write_libobj=$1 2968493f84f4Smrg if test yes = "$build_libtool_libs"; then 2969493f84f4Smrg write_lobj=\'$2\' 2970a31a186aSmrg else 2971a31a186aSmrg write_lobj=none 2972a31a186aSmrg fi 2973a31a186aSmrg 2974493f84f4Smrg if test yes = "$build_old_libs"; then 2975493f84f4Smrg write_oldobj=\'$3\' 2976a31a186aSmrg else 2977a31a186aSmrg write_oldobj=none 2978a31a186aSmrg fi 2979a31a186aSmrg 2980a31a186aSmrg $opt_dry_run || { 2981a31a186aSmrg cat >${write_libobj}T <<EOF 2982a31a186aSmrg# $write_libobj - a libtool object file 2983493f84f4Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2984a31a186aSmrg# 2985a31a186aSmrg# Please DO NOT delete this file! 2986a31a186aSmrg# It is necessary for linking the library. 2987a31a186aSmrg 2988a31a186aSmrg# Name of the PIC object. 2989a31a186aSmrgpic_object=$write_lobj 2990a31a186aSmrg 2991a31a186aSmrg# Name of the non-PIC object 2992a31a186aSmrgnon_pic_object=$write_oldobj 2993a31a186aSmrg 2994a31a186aSmrgEOF 2995493f84f4Smrg $MV "${write_libobj}T" "$write_libobj" 2996a31a186aSmrg } 2997a31a186aSmrg} 2998a31a186aSmrg 29990bb88ba4Smrg 30000bb88ba4Smrg################################################## 30010bb88ba4Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 30020bb88ba4Smrg################################################## 30030bb88ba4Smrg 30040bb88ba4Smrg# func_convert_core_file_wine_to_w32 ARG 30050bb88ba4Smrg# Helper function used by file name conversion functions when $build is *nix, 30060bb88ba4Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 30070bb88ba4Smrg# correctly configured wine environment available, with the winepath program 30080bb88ba4Smrg# in $build's $PATH. 30090bb88ba4Smrg# 30100bb88ba4Smrg# ARG is the $build file name to be converted to w32 format. 30110bb88ba4Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 30120bb88ba4Smrg# be empty on error (or when ARG is empty) 30130bb88ba4Smrgfunc_convert_core_file_wine_to_w32 () 30140bb88ba4Smrg{ 3015493f84f4Smrg $debug_cmd 3016493f84f4Smrg 3017493f84f4Smrg func_convert_core_file_wine_to_w32_result=$1 30180bb88ba4Smrg if test -n "$1"; then 30190bb88ba4Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 30200bb88ba4Smrg # are forced to check the contents of stdout. On the other hand, if the 30210bb88ba4Smrg # command is not found, the shell will set an exit code of 127 and print 30220bb88ba4Smrg # *an error message* to stdout. So we must check for both error code of 30230bb88ba4Smrg # zero AND non-empty stdout, which explains the odd construction: 30240bb88ba4Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 3025493f84f4Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 30260bb88ba4Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 3027493f84f4Smrg $SED -e "$sed_naive_backslashify"` 30280bb88ba4Smrg else 30290bb88ba4Smrg func_convert_core_file_wine_to_w32_result= 30300bb88ba4Smrg fi 30310bb88ba4Smrg fi 30320bb88ba4Smrg} 30330bb88ba4Smrg# end: func_convert_core_file_wine_to_w32 30340bb88ba4Smrg 30350bb88ba4Smrg 30360bb88ba4Smrg# func_convert_core_path_wine_to_w32 ARG 30370bb88ba4Smrg# Helper function used by path conversion functions when $build is *nix, and 30380bb88ba4Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 30390bb88ba4Smrg# configured wine environment available, with the winepath program in $build's 30400bb88ba4Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 30410bb88ba4Smrg# 30420bb88ba4Smrg# ARG is path to be converted from $build format to win32. 30430bb88ba4Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 30440bb88ba4Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 30450bb88ba4Smrg# are convertible, then the result may be empty. 30460bb88ba4Smrgfunc_convert_core_path_wine_to_w32 () 30470bb88ba4Smrg{ 3048493f84f4Smrg $debug_cmd 3049493f84f4Smrg 30500bb88ba4Smrg # unfortunately, winepath doesn't convert paths, only file names 3051493f84f4Smrg func_convert_core_path_wine_to_w32_result= 30520bb88ba4Smrg if test -n "$1"; then 30530bb88ba4Smrg oldIFS=$IFS 30540bb88ba4Smrg IFS=: 30550bb88ba4Smrg for func_convert_core_path_wine_to_w32_f in $1; do 30560bb88ba4Smrg IFS=$oldIFS 30570bb88ba4Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 3058493f84f4Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 30590bb88ba4Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 3060493f84f4Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 30610bb88ba4Smrg else 30620bb88ba4Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 30630bb88ba4Smrg fi 30640bb88ba4Smrg fi 30650bb88ba4Smrg done 30660bb88ba4Smrg IFS=$oldIFS 30670bb88ba4Smrg fi 30680bb88ba4Smrg} 30690bb88ba4Smrg# end: func_convert_core_path_wine_to_w32 30700bb88ba4Smrg 30710bb88ba4Smrg 30720bb88ba4Smrg# func_cygpath ARGS... 30730bb88ba4Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 30740bb88ba4Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 30750bb88ba4Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 30760bb88ba4Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 30770bb88ba4Smrg# file name or path is assumed to be in w32 format, as previously converted 30780bb88ba4Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 30790bb88ba4Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 30800bb88ba4Smrg# Cygwin format). Returns an empty string on error. 30810bb88ba4Smrg# 30820bb88ba4Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 30830bb88ba4Smrg# be converted. 30840bb88ba4Smrg# 30850bb88ba4Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 30860bb88ba4Smrg# environment variable; do not put it in $PATH. 30870bb88ba4Smrgfunc_cygpath () 30880bb88ba4Smrg{ 3089493f84f4Smrg $debug_cmd 3090493f84f4Smrg 30910bb88ba4Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 30920bb88ba4Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 30930bb88ba4Smrg if test "$?" -ne 0; then 30940bb88ba4Smrg # on failure, ensure result is empty 30950bb88ba4Smrg func_cygpath_result= 30960bb88ba4Smrg fi 30970bb88ba4Smrg else 30980bb88ba4Smrg func_cygpath_result= 3099493f84f4Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 31000bb88ba4Smrg fi 31010bb88ba4Smrg} 31020bb88ba4Smrg#end: func_cygpath 31030bb88ba4Smrg 31040bb88ba4Smrg 31050bb88ba4Smrg# func_convert_core_msys_to_w32 ARG 31060bb88ba4Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 31070bb88ba4Smrg# result in func_convert_core_msys_to_w32_result. 31080bb88ba4Smrgfunc_convert_core_msys_to_w32 () 31090bb88ba4Smrg{ 3110493f84f4Smrg $debug_cmd 3111493f84f4Smrg 31120bb88ba4Smrg # awkward: cmd appends spaces to result 31130bb88ba4Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 3114493f84f4Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 31150bb88ba4Smrg} 31160bb88ba4Smrg#end: func_convert_core_msys_to_w32 31170bb88ba4Smrg 31180bb88ba4Smrg 31190bb88ba4Smrg# func_convert_file_check ARG1 ARG2 31200bb88ba4Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 31210bb88ba4Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 31220bb88ba4Smrg# func_to_host_file_result to ARG1). 31230bb88ba4Smrgfunc_convert_file_check () 31240bb88ba4Smrg{ 3125493f84f4Smrg $debug_cmd 3126493f84f4Smrg 3127493f84f4Smrg if test -z "$2" && test -n "$1"; then 31280bb88ba4Smrg func_error "Could not determine host file name corresponding to" 3129493f84f4Smrg func_error " '$1'" 31300bb88ba4Smrg func_error "Continuing, but uninstalled executables may not work." 31310bb88ba4Smrg # Fallback: 3132493f84f4Smrg func_to_host_file_result=$1 31330bb88ba4Smrg fi 31340bb88ba4Smrg} 31350bb88ba4Smrg# end func_convert_file_check 31360bb88ba4Smrg 31370bb88ba4Smrg 31380bb88ba4Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 31390bb88ba4Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 31400bb88ba4Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 31410bb88ba4Smrg# func_to_host_file_result to a simplistic fallback value (see below). 31420bb88ba4Smrgfunc_convert_path_check () 31430bb88ba4Smrg{ 3144493f84f4Smrg $debug_cmd 3145493f84f4Smrg 31460bb88ba4Smrg if test -z "$4" && test -n "$3"; then 31470bb88ba4Smrg func_error "Could not determine the host path corresponding to" 3148493f84f4Smrg func_error " '$3'" 31490bb88ba4Smrg func_error "Continuing, but uninstalled executables may not work." 31500bb88ba4Smrg # Fallback. This is a deliberately simplistic "conversion" and 31510bb88ba4Smrg # should not be "improved". See libtool.info. 31520bb88ba4Smrg if test "x$1" != "x$2"; then 31530bb88ba4Smrg lt_replace_pathsep_chars="s|$1|$2|g" 31540bb88ba4Smrg func_to_host_path_result=`echo "$3" | 31550bb88ba4Smrg $SED -e "$lt_replace_pathsep_chars"` 31560bb88ba4Smrg else 3157493f84f4Smrg func_to_host_path_result=$3 31580bb88ba4Smrg fi 31590bb88ba4Smrg fi 31600bb88ba4Smrg} 31610bb88ba4Smrg# end func_convert_path_check 31620bb88ba4Smrg 31630bb88ba4Smrg 31640bb88ba4Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 31650bb88ba4Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 31660bb88ba4Smrg# and appending REPL if ORIG matches BACKPAT. 31670bb88ba4Smrgfunc_convert_path_front_back_pathsep () 31680bb88ba4Smrg{ 3169493f84f4Smrg $debug_cmd 3170493f84f4Smrg 31710bb88ba4Smrg case $4 in 3172493f84f4Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 31730bb88ba4Smrg ;; 31740bb88ba4Smrg esac 31750bb88ba4Smrg case $4 in 31760bb88ba4Smrg $2 ) func_append func_to_host_path_result "$3" 31770bb88ba4Smrg ;; 31780bb88ba4Smrg esac 31790bb88ba4Smrg} 31800bb88ba4Smrg# end func_convert_path_front_back_pathsep 31810bb88ba4Smrg 31820bb88ba4Smrg 31830bb88ba4Smrg################################################## 31840bb88ba4Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 31850bb88ba4Smrg################################################## 3186493f84f4Smrg# invoked via '$to_host_file_cmd ARG' 31870bb88ba4Smrg# 31880bb88ba4Smrg# In each case, ARG is the path to be converted from $build to $host format. 31890bb88ba4Smrg# Result will be available in $func_to_host_file_result. 31900bb88ba4Smrg 31910bb88ba4Smrg 31920bb88ba4Smrg# func_to_host_file ARG 31930bb88ba4Smrg# Converts the file name ARG from $build format to $host format. Return result 31940bb88ba4Smrg# in func_to_host_file_result. 31950bb88ba4Smrgfunc_to_host_file () 31960bb88ba4Smrg{ 3197493f84f4Smrg $debug_cmd 3198493f84f4Smrg 31990bb88ba4Smrg $to_host_file_cmd "$1" 32000bb88ba4Smrg} 32010bb88ba4Smrg# end func_to_host_file 32020bb88ba4Smrg 32030bb88ba4Smrg 32040bb88ba4Smrg# func_to_tool_file ARG LAZY 32050bb88ba4Smrg# converts the file name ARG from $build format to toolchain format. Return 32060bb88ba4Smrg# result in func_to_tool_file_result. If the conversion in use is listed 32070bb88ba4Smrg# in (the comma separated) LAZY, no conversion takes place. 32080bb88ba4Smrgfunc_to_tool_file () 32090bb88ba4Smrg{ 3210493f84f4Smrg $debug_cmd 3211493f84f4Smrg 32120bb88ba4Smrg case ,$2, in 32130bb88ba4Smrg *,"$to_tool_file_cmd",*) 32140bb88ba4Smrg func_to_tool_file_result=$1 32150bb88ba4Smrg ;; 32160bb88ba4Smrg *) 32170bb88ba4Smrg $to_tool_file_cmd "$1" 32180bb88ba4Smrg func_to_tool_file_result=$func_to_host_file_result 32190bb88ba4Smrg ;; 32200bb88ba4Smrg esac 32210bb88ba4Smrg} 32220bb88ba4Smrg# end func_to_tool_file 32230bb88ba4Smrg 32240bb88ba4Smrg 32250bb88ba4Smrg# func_convert_file_noop ARG 32260bb88ba4Smrg# Copy ARG to func_to_host_file_result. 32270bb88ba4Smrgfunc_convert_file_noop () 32280bb88ba4Smrg{ 3229493f84f4Smrg func_to_host_file_result=$1 32300bb88ba4Smrg} 32310bb88ba4Smrg# end func_convert_file_noop 32320bb88ba4Smrg 32330bb88ba4Smrg 32340bb88ba4Smrg# func_convert_file_msys_to_w32 ARG 32350bb88ba4Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 32360bb88ba4Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 32370bb88ba4Smrg# func_to_host_file_result. 32380bb88ba4Smrgfunc_convert_file_msys_to_w32 () 32390bb88ba4Smrg{ 3240493f84f4Smrg $debug_cmd 3241493f84f4Smrg 3242493f84f4Smrg func_to_host_file_result=$1 32430bb88ba4Smrg if test -n "$1"; then 32440bb88ba4Smrg func_convert_core_msys_to_w32 "$1" 3245493f84f4Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 32460bb88ba4Smrg fi 32470bb88ba4Smrg func_convert_file_check "$1" "$func_to_host_file_result" 32480bb88ba4Smrg} 32490bb88ba4Smrg# end func_convert_file_msys_to_w32 32500bb88ba4Smrg 32510bb88ba4Smrg 32520bb88ba4Smrg# func_convert_file_cygwin_to_w32 ARG 32530bb88ba4Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 32540bb88ba4Smrg# func_to_host_file_result. 32550bb88ba4Smrgfunc_convert_file_cygwin_to_w32 () 32560bb88ba4Smrg{ 3257493f84f4Smrg $debug_cmd 3258493f84f4Smrg 3259493f84f4Smrg func_to_host_file_result=$1 32600bb88ba4Smrg if test -n "$1"; then 32610bb88ba4Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 32620bb88ba4Smrg # LT_CYGPATH in this case. 32630bb88ba4Smrg func_to_host_file_result=`cygpath -m "$1"` 32640bb88ba4Smrg fi 32650bb88ba4Smrg func_convert_file_check "$1" "$func_to_host_file_result" 32660bb88ba4Smrg} 32670bb88ba4Smrg# end func_convert_file_cygwin_to_w32 32680bb88ba4Smrg 32690bb88ba4Smrg 32700bb88ba4Smrg# func_convert_file_nix_to_w32 ARG 32710bb88ba4Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 32720bb88ba4Smrg# and a working winepath. Returns result in func_to_host_file_result. 32730bb88ba4Smrgfunc_convert_file_nix_to_w32 () 32740bb88ba4Smrg{ 3275493f84f4Smrg $debug_cmd 3276493f84f4Smrg 3277493f84f4Smrg func_to_host_file_result=$1 32780bb88ba4Smrg if test -n "$1"; then 32790bb88ba4Smrg func_convert_core_file_wine_to_w32 "$1" 3280493f84f4Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 32810bb88ba4Smrg fi 32820bb88ba4Smrg func_convert_file_check "$1" "$func_to_host_file_result" 32830bb88ba4Smrg} 32840bb88ba4Smrg# end func_convert_file_nix_to_w32 32850bb88ba4Smrg 32860bb88ba4Smrg 32870bb88ba4Smrg# func_convert_file_msys_to_cygwin ARG 32880bb88ba4Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 32890bb88ba4Smrg# Returns result in func_to_host_file_result. 32900bb88ba4Smrgfunc_convert_file_msys_to_cygwin () 32910bb88ba4Smrg{ 3292493f84f4Smrg $debug_cmd 3293493f84f4Smrg 3294493f84f4Smrg func_to_host_file_result=$1 32950bb88ba4Smrg if test -n "$1"; then 32960bb88ba4Smrg func_convert_core_msys_to_w32 "$1" 32970bb88ba4Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 3298493f84f4Smrg func_to_host_file_result=$func_cygpath_result 32990bb88ba4Smrg fi 33000bb88ba4Smrg func_convert_file_check "$1" "$func_to_host_file_result" 33010bb88ba4Smrg} 33020bb88ba4Smrg# end func_convert_file_msys_to_cygwin 33030bb88ba4Smrg 33040bb88ba4Smrg 33050bb88ba4Smrg# func_convert_file_nix_to_cygwin ARG 33060bb88ba4Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 33070bb88ba4Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 33080bb88ba4Smrg# in func_to_host_file_result. 33090bb88ba4Smrgfunc_convert_file_nix_to_cygwin () 33100bb88ba4Smrg{ 3311493f84f4Smrg $debug_cmd 3312493f84f4Smrg 3313493f84f4Smrg func_to_host_file_result=$1 33140bb88ba4Smrg if test -n "$1"; then 33150bb88ba4Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 33160bb88ba4Smrg func_convert_core_file_wine_to_w32 "$1" 33170bb88ba4Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3318493f84f4Smrg func_to_host_file_result=$func_cygpath_result 33190bb88ba4Smrg fi 33200bb88ba4Smrg func_convert_file_check "$1" "$func_to_host_file_result" 33210bb88ba4Smrg} 33220bb88ba4Smrg# end func_convert_file_nix_to_cygwin 33230bb88ba4Smrg 33240bb88ba4Smrg 33250bb88ba4Smrg############################################# 33260bb88ba4Smrg# $build to $host PATH CONVERSION FUNCTIONS # 33270bb88ba4Smrg############################################# 3328493f84f4Smrg# invoked via '$to_host_path_cmd ARG' 33290bb88ba4Smrg# 33300bb88ba4Smrg# In each case, ARG is the path to be converted from $build to $host format. 33310bb88ba4Smrg# The result will be available in $func_to_host_path_result. 33320bb88ba4Smrg# 33330bb88ba4Smrg# Path separators are also converted from $build format to $host format. If 33340bb88ba4Smrg# ARG begins or ends with a path separator character, it is preserved (but 33350bb88ba4Smrg# converted to $host format) on output. 33360bb88ba4Smrg# 33370bb88ba4Smrg# All path conversion functions are named using the following convention: 33380bb88ba4Smrg# file name conversion function : func_convert_file_X_to_Y () 33390bb88ba4Smrg# path conversion function : func_convert_path_X_to_Y () 33400bb88ba4Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 33410bb88ba4Smrg# same. If conversion functions are added for new $build/$host combinations, 33420bb88ba4Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 33430bb88ba4Smrg# will break. 33440bb88ba4Smrg 33450bb88ba4Smrg 33460bb88ba4Smrg# func_init_to_host_path_cmd 33470bb88ba4Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 33480bb88ba4Smrg# appropriate value, based on the value of $to_host_file_cmd. 33490bb88ba4Smrgto_host_path_cmd= 33500bb88ba4Smrgfunc_init_to_host_path_cmd () 33510bb88ba4Smrg{ 3352493f84f4Smrg $debug_cmd 3353493f84f4Smrg 33540bb88ba4Smrg if test -z "$to_host_path_cmd"; then 33550bb88ba4Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3356493f84f4Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 33570bb88ba4Smrg fi 33580bb88ba4Smrg} 33590bb88ba4Smrg 33600bb88ba4Smrg 33610bb88ba4Smrg# func_to_host_path ARG 33620bb88ba4Smrg# Converts the path ARG from $build format to $host format. Return result 33630bb88ba4Smrg# in func_to_host_path_result. 33640bb88ba4Smrgfunc_to_host_path () 33650bb88ba4Smrg{ 3366493f84f4Smrg $debug_cmd 3367493f84f4Smrg 33680bb88ba4Smrg func_init_to_host_path_cmd 33690bb88ba4Smrg $to_host_path_cmd "$1" 33700bb88ba4Smrg} 33710bb88ba4Smrg# end func_to_host_path 33720bb88ba4Smrg 33730bb88ba4Smrg 33740bb88ba4Smrg# func_convert_path_noop ARG 33750bb88ba4Smrg# Copy ARG to func_to_host_path_result. 33760bb88ba4Smrgfunc_convert_path_noop () 33770bb88ba4Smrg{ 3378493f84f4Smrg func_to_host_path_result=$1 33790bb88ba4Smrg} 33800bb88ba4Smrg# end func_convert_path_noop 33810bb88ba4Smrg 33820bb88ba4Smrg 33830bb88ba4Smrg# func_convert_path_msys_to_w32 ARG 33840bb88ba4Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 33850bb88ba4Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 33860bb88ba4Smrg# func_to_host_path_result. 33870bb88ba4Smrgfunc_convert_path_msys_to_w32 () 33880bb88ba4Smrg{ 3389493f84f4Smrg $debug_cmd 3390493f84f4Smrg 3391493f84f4Smrg func_to_host_path_result=$1 33920bb88ba4Smrg if test -n "$1"; then 33930bb88ba4Smrg # Remove leading and trailing path separator characters from ARG. MSYS 33940bb88ba4Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 33950bb88ba4Smrg # and winepath ignores them completely. 33960bb88ba4Smrg func_stripname : : "$1" 33970bb88ba4Smrg func_to_host_path_tmp1=$func_stripname_result 33980bb88ba4Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3399493f84f4Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 34000bb88ba4Smrg func_convert_path_check : ";" \ 34010bb88ba4Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34020bb88ba4Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34030bb88ba4Smrg fi 34040bb88ba4Smrg} 34050bb88ba4Smrg# end func_convert_path_msys_to_w32 34060bb88ba4Smrg 34070bb88ba4Smrg 34080bb88ba4Smrg# func_convert_path_cygwin_to_w32 ARG 34090bb88ba4Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 34100bb88ba4Smrg# func_to_host_file_result. 34110bb88ba4Smrgfunc_convert_path_cygwin_to_w32 () 34120bb88ba4Smrg{ 3413493f84f4Smrg $debug_cmd 3414493f84f4Smrg 3415493f84f4Smrg func_to_host_path_result=$1 34160bb88ba4Smrg if test -n "$1"; then 34170bb88ba4Smrg # See func_convert_path_msys_to_w32: 34180bb88ba4Smrg func_stripname : : "$1" 34190bb88ba4Smrg func_to_host_path_tmp1=$func_stripname_result 34200bb88ba4Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 34210bb88ba4Smrg func_convert_path_check : ";" \ 34220bb88ba4Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34230bb88ba4Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34240bb88ba4Smrg fi 34250bb88ba4Smrg} 34260bb88ba4Smrg# end func_convert_path_cygwin_to_w32 34270bb88ba4Smrg 34280bb88ba4Smrg 34290bb88ba4Smrg# func_convert_path_nix_to_w32 ARG 34300bb88ba4Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 34310bb88ba4Smrg# a working winepath. Returns result in func_to_host_file_result. 34320bb88ba4Smrgfunc_convert_path_nix_to_w32 () 34330bb88ba4Smrg{ 3434493f84f4Smrg $debug_cmd 3435493f84f4Smrg 3436493f84f4Smrg func_to_host_path_result=$1 34370bb88ba4Smrg if test -n "$1"; then 34380bb88ba4Smrg # See func_convert_path_msys_to_w32: 34390bb88ba4Smrg func_stripname : : "$1" 34400bb88ba4Smrg func_to_host_path_tmp1=$func_stripname_result 34410bb88ba4Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3442493f84f4Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 34430bb88ba4Smrg func_convert_path_check : ";" \ 34440bb88ba4Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34450bb88ba4Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34460bb88ba4Smrg fi 34470bb88ba4Smrg} 34480bb88ba4Smrg# end func_convert_path_nix_to_w32 34490bb88ba4Smrg 34500bb88ba4Smrg 34510bb88ba4Smrg# func_convert_path_msys_to_cygwin ARG 34520bb88ba4Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 34530bb88ba4Smrg# Returns result in func_to_host_file_result. 34540bb88ba4Smrgfunc_convert_path_msys_to_cygwin () 34550bb88ba4Smrg{ 3456493f84f4Smrg $debug_cmd 3457493f84f4Smrg 3458493f84f4Smrg func_to_host_path_result=$1 34590bb88ba4Smrg if test -n "$1"; then 34600bb88ba4Smrg # See func_convert_path_msys_to_w32: 34610bb88ba4Smrg func_stripname : : "$1" 34620bb88ba4Smrg func_to_host_path_tmp1=$func_stripname_result 34630bb88ba4Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 34640bb88ba4Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3465493f84f4Smrg func_to_host_path_result=$func_cygpath_result 34660bb88ba4Smrg func_convert_path_check : : \ 34670bb88ba4Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34680bb88ba4Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 34690bb88ba4Smrg fi 34700bb88ba4Smrg} 34710bb88ba4Smrg# end func_convert_path_msys_to_cygwin 34720bb88ba4Smrg 34730bb88ba4Smrg 34740bb88ba4Smrg# func_convert_path_nix_to_cygwin ARG 34750bb88ba4Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 34760bb88ba4Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 34770bb88ba4Smrg# func_to_host_file_result. 34780bb88ba4Smrgfunc_convert_path_nix_to_cygwin () 34790bb88ba4Smrg{ 3480493f84f4Smrg $debug_cmd 3481493f84f4Smrg 3482493f84f4Smrg func_to_host_path_result=$1 34830bb88ba4Smrg if test -n "$1"; then 34840bb88ba4Smrg # Remove leading and trailing path separator characters from 34850bb88ba4Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 34860bb88ba4Smrg # into '.;' and ';.', and winepath ignores them completely. 34870bb88ba4Smrg func_stripname : : "$1" 34880bb88ba4Smrg func_to_host_path_tmp1=$func_stripname_result 34890bb88ba4Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 34900bb88ba4Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3491493f84f4Smrg func_to_host_path_result=$func_cygpath_result 34920bb88ba4Smrg func_convert_path_check : : \ 34930bb88ba4Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34940bb88ba4Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 34950bb88ba4Smrg fi 34960bb88ba4Smrg} 34970bb88ba4Smrg# end func_convert_path_nix_to_cygwin 34980bb88ba4Smrg 34990bb88ba4Smrg 3500493f84f4Smrg# func_dll_def_p FILE 3501493f84f4Smrg# True iff FILE is a Windows DLL '.def' file. 3502493f84f4Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3503493f84f4Smrgfunc_dll_def_p () 3504493f84f4Smrg{ 3505493f84f4Smrg $debug_cmd 3506493f84f4Smrg 3507493f84f4Smrg func_dll_def_p_tmp=`$SED -n \ 3508493f84f4Smrg -e 's/^[ ]*//' \ 3509493f84f4Smrg -e '/^\(;.*\)*$/d' \ 3510493f84f4Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3511493f84f4Smrg -e q \ 3512493f84f4Smrg "$1"` 3513493f84f4Smrg test DEF = "$func_dll_def_p_tmp" 3514493f84f4Smrg} 3515493f84f4Smrg 3516493f84f4Smrg 3517a31a186aSmrg# func_mode_compile arg... 3518a31a186aSmrgfunc_mode_compile () 3519a31a186aSmrg{ 3520493f84f4Smrg $debug_cmd 3521493f84f4Smrg 3522a31a186aSmrg # Get the compilation command and the source file. 3523a31a186aSmrg base_compile= 3524493f84f4Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3525a31a186aSmrg suppress_opt=yes 3526a31a186aSmrg suppress_output= 3527a31a186aSmrg arg_mode=normal 3528a31a186aSmrg libobj= 3529a31a186aSmrg later= 3530a31a186aSmrg pie_flag= 3531a31a186aSmrg 3532a31a186aSmrg for arg 3533a31a186aSmrg do 3534a31a186aSmrg case $arg_mode in 3535a31a186aSmrg arg ) 3536a31a186aSmrg # do not "continue". Instead, add this to base_compile 3537493f84f4Smrg lastarg=$arg 3538a31a186aSmrg arg_mode=normal 3539a31a186aSmrg ;; 3540a31a186aSmrg 3541a31a186aSmrg target ) 3542493f84f4Smrg libobj=$arg 3543a31a186aSmrg arg_mode=normal 3544a31a186aSmrg continue 3545a31a186aSmrg ;; 3546a31a186aSmrg 3547a31a186aSmrg normal ) 3548a31a186aSmrg # Accept any command-line options. 3549a31a186aSmrg case $arg in 3550a31a186aSmrg -o) 3551a31a186aSmrg test -n "$libobj" && \ 3552493f84f4Smrg func_fatal_error "you cannot specify '-o' more than once" 3553a31a186aSmrg arg_mode=target 3554a31a186aSmrg continue 3555a31a186aSmrg ;; 3556a31a186aSmrg 3557a31a186aSmrg -pie | -fpie | -fPIE) 35580bb88ba4Smrg func_append pie_flag " $arg" 3559a31a186aSmrg continue 3560a31a186aSmrg ;; 3561a31a186aSmrg 3562a31a186aSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 35630bb88ba4Smrg func_append later " $arg" 3564a31a186aSmrg continue 3565a31a186aSmrg ;; 3566a31a186aSmrg 3567a31a186aSmrg -no-suppress) 3568fe5e51b7Smrg suppress_opt=no 3569fe5e51b7Smrg continue 3570fe5e51b7Smrg ;; 3571fe5e51b7Smrg 3572fe5e51b7Smrg -Xcompiler) 3573fe5e51b7Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 3574fe5e51b7Smrg continue # The current "srcfile" will either be retained or 3575fe5e51b7Smrg ;; # replaced later. I would guess that would be a bug. 3576fe5e51b7Smrg 3577fe5e51b7Smrg -Wc,*) 3578a31a186aSmrg func_stripname '-Wc,' '' "$arg" 3579a31a186aSmrg args=$func_stripname_result 3580fe5e51b7Smrg lastarg= 3581493f84f4Smrg save_ifs=$IFS; IFS=, 3582a31a186aSmrg for arg in $args; do 3583493f84f4Smrg IFS=$save_ifs 35840bb88ba4Smrg func_append_quoted lastarg "$arg" 3585fe5e51b7Smrg done 3586493f84f4Smrg IFS=$save_ifs 3587a31a186aSmrg func_stripname ' ' '' "$lastarg" 3588a31a186aSmrg lastarg=$func_stripname_result 3589fe5e51b7Smrg 3590fe5e51b7Smrg # Add the arguments to base_compile. 35910bb88ba4Smrg func_append base_compile " $lastarg" 3592fe5e51b7Smrg continue 3593fe5e51b7Smrg ;; 3594fe5e51b7Smrg 3595a31a186aSmrg *) 3596fe5e51b7Smrg # Accept the current argument as the source file. 3597fe5e51b7Smrg # The previous "srcfile" becomes the current argument. 3598fe5e51b7Smrg # 3599493f84f4Smrg lastarg=$srcfile 3600493f84f4Smrg srcfile=$arg 3601fe5e51b7Smrg ;; 3602fe5e51b7Smrg esac # case $arg 3603fe5e51b7Smrg ;; 3604fe5e51b7Smrg esac # case $arg_mode 3605fe5e51b7Smrg 3606fe5e51b7Smrg # Aesthetically quote the previous argument. 36070bb88ba4Smrg func_append_quoted base_compile "$lastarg" 3608fe5e51b7Smrg done # for arg 3609fe5e51b7Smrg 3610fe5e51b7Smrg case $arg_mode in 3611fe5e51b7Smrg arg) 3612a31a186aSmrg func_fatal_error "you must specify an argument for -Xcompile" 3613fe5e51b7Smrg ;; 3614fe5e51b7Smrg target) 3615493f84f4Smrg func_fatal_error "you must specify a target with '-o'" 3616fe5e51b7Smrg ;; 3617fe5e51b7Smrg *) 3618fe5e51b7Smrg # Get the name of the library object. 3619a31a186aSmrg test -z "$libobj" && { 3620a31a186aSmrg func_basename "$srcfile" 3621493f84f4Smrg libobj=$func_basename_result 3622a31a186aSmrg } 3623fe5e51b7Smrg ;; 3624fe5e51b7Smrg esac 3625fe5e51b7Smrg 3626fe5e51b7Smrg # Recognize several different file suffixes. 3627fe5e51b7Smrg # If the user specifies -o file.o, it is replaced with file.lo 3628fe5e51b7Smrg case $libobj in 3629a31a186aSmrg *.[cCFSifmso] | \ 3630a31a186aSmrg *.ada | *.adb | *.ads | *.asm | \ 3631a31a186aSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 36320bb88ba4Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3633a31a186aSmrg func_xform "$libobj" 3634a31a186aSmrg libobj=$func_xform_result 3635a31a186aSmrg ;; 3636fe5e51b7Smrg esac 3637fe5e51b7Smrg 3638fe5e51b7Smrg case $libobj in 3639a31a186aSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3640fe5e51b7Smrg *) 3641493f84f4Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 3642fe5e51b7Smrg ;; 3643fe5e51b7Smrg esac 3644fe5e51b7Smrg 3645fe5e51b7Smrg func_infer_tag $base_compile 3646fe5e51b7Smrg 3647fe5e51b7Smrg for arg in $later; do 3648fe5e51b7Smrg case $arg in 3649a31a186aSmrg -shared) 3650493f84f4Smrg test yes = "$build_libtool_libs" \ 3651493f84f4Smrg || func_fatal_configuration "cannot build a shared library" 3652a31a186aSmrg build_old_libs=no 3653a31a186aSmrg continue 3654a31a186aSmrg ;; 3655a31a186aSmrg 3656fe5e51b7Smrg -static) 3657a31a186aSmrg build_libtool_libs=no 3658fe5e51b7Smrg build_old_libs=yes 3659fe5e51b7Smrg continue 3660fe5e51b7Smrg ;; 3661fe5e51b7Smrg 3662fe5e51b7Smrg -prefer-pic) 3663fe5e51b7Smrg pic_mode=yes 3664fe5e51b7Smrg continue 3665fe5e51b7Smrg ;; 3666fe5e51b7Smrg 3667fe5e51b7Smrg -prefer-non-pic) 3668fe5e51b7Smrg pic_mode=no 3669fe5e51b7Smrg continue 3670fe5e51b7Smrg ;; 3671fe5e51b7Smrg esac 3672fe5e51b7Smrg done 3673fe5e51b7Smrg 36741e423a8fSmrg func_quote_arg pretty "$libobj" 36751e423a8fSmrg test "X$libobj" != "X$func_quote_arg_result" \ 3676a31a186aSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3677493f84f4Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3678a31a186aSmrg func_dirname_and_basename "$obj" "/" "" 3679493f84f4Smrg objname=$func_basename_result 3680493f84f4Smrg xdir=$func_dirname_result 3681493f84f4Smrg lobj=$xdir$objdir/$objname 3682fe5e51b7Smrg 3683a31a186aSmrg test -z "$base_compile" && \ 3684a31a186aSmrg func_fatal_help "you must specify a compilation command" 3685fe5e51b7Smrg 3686fe5e51b7Smrg # Delete any leftover library objects. 3687493f84f4Smrg if test yes = "$build_old_libs"; then 3688fe5e51b7Smrg removelist="$obj $lobj $libobj ${libobj}T" 3689fe5e51b7Smrg else 3690fe5e51b7Smrg removelist="$lobj $libobj ${libobj}T" 3691fe5e51b7Smrg fi 3692fe5e51b7Smrg 3693fe5e51b7Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 3694fe5e51b7Smrg case $host_os in 3695a31a186aSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3696fe5e51b7Smrg pic_mode=default 3697fe5e51b7Smrg ;; 3698fe5e51b7Smrg esac 3699493f84f4Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3700fe5e51b7Smrg # non-PIC code in shared libraries is not supported 3701fe5e51b7Smrg pic_mode=default 3702fe5e51b7Smrg fi 3703fe5e51b7Smrg 3704fe5e51b7Smrg # Calculate the filename of the output object if compiler does 3705fe5e51b7Smrg # not support -o with -c 3706493f84f4Smrg if test no = "$compiler_c_o"; then 3707493f84f4Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3708493f84f4Smrg lockfile=$output_obj.lock 3709fe5e51b7Smrg else 3710fe5e51b7Smrg output_obj= 3711fe5e51b7Smrg need_locks=no 3712fe5e51b7Smrg lockfile= 3713fe5e51b7Smrg fi 3714fe5e51b7Smrg 3715fe5e51b7Smrg # Lock this critical section if it is needed 3716fe5e51b7Smrg # We use this script file to make the link, it avoids creating a new file 3717493f84f4Smrg if test yes = "$need_locks"; then 3718a31a186aSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3719a31a186aSmrg func_echo "Waiting for $lockfile to be removed" 3720fe5e51b7Smrg sleep 2 3721fe5e51b7Smrg done 3722493f84f4Smrg elif test warn = "$need_locks"; then 3723fe5e51b7Smrg if test -f "$lockfile"; then 3724a31a186aSmrg $ECHO "\ 3725fe5e51b7Smrg*** ERROR, $lockfile exists and contains: 3726fe5e51b7Smrg`cat $lockfile 2>/dev/null` 3727fe5e51b7Smrg 3728fe5e51b7SmrgThis indicates that another process is trying to use the same 3729fe5e51b7Smrgtemporary object file, and libtool could not work around it because 3730493f84f4Smrgyour compiler does not support '-c' and '-o' together. If you 3731fe5e51b7Smrgrepeat this compilation, it may succeed, by chance, but you had better 3732fe5e51b7Smrgavoid parallel builds (make -j) in this platform, or get a better 3733fe5e51b7Smrgcompiler." 3734fe5e51b7Smrg 3735a31a186aSmrg $opt_dry_run || $RM $removelist 3736fe5e51b7Smrg exit $EXIT_FAILURE 3737fe5e51b7Smrg fi 37380bb88ba4Smrg func_append removelist " $output_obj" 3739a31a186aSmrg $ECHO "$srcfile" > "$lockfile" 3740fe5e51b7Smrg fi 3741fe5e51b7Smrg 3742a31a186aSmrg $opt_dry_run || $RM $removelist 37430bb88ba4Smrg func_append removelist " $lockfile" 3744a31a186aSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3745a31a186aSmrg 37460bb88ba4Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 37470bb88ba4Smrg srcfile=$func_to_tool_file_result 37481e423a8fSmrg func_quote_arg pretty "$srcfile" 37491e423a8fSmrg qsrcfile=$func_quote_arg_result 3750fe5e51b7Smrg 3751fe5e51b7Smrg # Only build a PIC object if we are building libtool libraries. 3752493f84f4Smrg if test yes = "$build_libtool_libs"; then 3753fe5e51b7Smrg # Without this assignment, base_compile gets emptied. 3754fe5e51b7Smrg fbsd_hideous_sh_bug=$base_compile 3755fe5e51b7Smrg 3756493f84f4Smrg if test no != "$pic_mode"; then 3757fe5e51b7Smrg command="$base_compile $qsrcfile $pic_flag" 3758fe5e51b7Smrg else 3759fe5e51b7Smrg # Don't build PIC code 3760fe5e51b7Smrg command="$base_compile $qsrcfile" 3761fe5e51b7Smrg fi 3762fe5e51b7Smrg 3763a31a186aSmrg func_mkdir_p "$xdir$objdir" 3764fe5e51b7Smrg 3765fe5e51b7Smrg if test -z "$output_obj"; then 3766fe5e51b7Smrg # Place PIC objects in $objdir 37670bb88ba4Smrg func_append command " -o $lobj" 3768fe5e51b7Smrg fi 3769fe5e51b7Smrg 3770a31a186aSmrg func_show_eval_locale "$command" \ 3771a31a186aSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3772fe5e51b7Smrg 3773493f84f4Smrg if test warn = "$need_locks" && 3774fe5e51b7Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3775a31a186aSmrg $ECHO "\ 3776fe5e51b7Smrg*** ERROR, $lockfile contains: 3777fe5e51b7Smrg`cat $lockfile 2>/dev/null` 3778fe5e51b7Smrg 3779fe5e51b7Smrgbut it should contain: 3780fe5e51b7Smrg$srcfile 3781fe5e51b7Smrg 3782fe5e51b7SmrgThis indicates that another process is trying to use the same 3783fe5e51b7Smrgtemporary object file, and libtool could not work around it because 3784493f84f4Smrgyour compiler does not support '-c' and '-o' together. If you 3785fe5e51b7Smrgrepeat this compilation, it may succeed, by chance, but you had better 3786fe5e51b7Smrgavoid parallel builds (make -j) in this platform, or get a better 3787fe5e51b7Smrgcompiler." 3788fe5e51b7Smrg 3789a31a186aSmrg $opt_dry_run || $RM $removelist 3790fe5e51b7Smrg exit $EXIT_FAILURE 3791fe5e51b7Smrg fi 3792fe5e51b7Smrg 3793fe5e51b7Smrg # Just move the object if needed, then go on to compile the next one 3794fe5e51b7Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3795a31a186aSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3796a31a186aSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3797fe5e51b7Smrg fi 3798fe5e51b7Smrg 3799fe5e51b7Smrg # Allow error messages only from the first compilation. 3800493f84f4Smrg if test yes = "$suppress_opt"; then 3801a31a186aSmrg suppress_output=' >/dev/null 2>&1' 3802fe5e51b7Smrg fi 3803fe5e51b7Smrg fi 3804fe5e51b7Smrg 3805fe5e51b7Smrg # Only build a position-dependent object if we build old libraries. 3806493f84f4Smrg if test yes = "$build_old_libs"; then 3807493f84f4Smrg if test yes != "$pic_mode"; then 3808fe5e51b7Smrg # Don't build PIC code 3809a31a186aSmrg command="$base_compile $qsrcfile$pie_flag" 3810fe5e51b7Smrg else 3811fe5e51b7Smrg command="$base_compile $qsrcfile $pic_flag" 3812fe5e51b7Smrg fi 3813493f84f4Smrg if test yes = "$compiler_c_o"; then 38140bb88ba4Smrg func_append command " -o $obj" 3815fe5e51b7Smrg fi 3816fe5e51b7Smrg 3817fe5e51b7Smrg # Suppress compiler output if we already did a PIC compilation. 38180bb88ba4Smrg func_append command "$suppress_output" 3819a31a186aSmrg func_show_eval_locale "$command" \ 3820a31a186aSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3821fe5e51b7Smrg 3822493f84f4Smrg if test warn = "$need_locks" && 3823fe5e51b7Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3824a31a186aSmrg $ECHO "\ 3825fe5e51b7Smrg*** ERROR, $lockfile contains: 3826fe5e51b7Smrg`cat $lockfile 2>/dev/null` 3827fe5e51b7Smrg 3828fe5e51b7Smrgbut it should contain: 3829fe5e51b7Smrg$srcfile 3830fe5e51b7Smrg 3831fe5e51b7SmrgThis indicates that another process is trying to use the same 3832fe5e51b7Smrgtemporary object file, and libtool could not work around it because 3833493f84f4Smrgyour compiler does not support '-c' and '-o' together. If you 3834fe5e51b7Smrgrepeat this compilation, it may succeed, by chance, but you had better 3835fe5e51b7Smrgavoid parallel builds (make -j) in this platform, or get a better 3836fe5e51b7Smrgcompiler." 3837fe5e51b7Smrg 3838a31a186aSmrg $opt_dry_run || $RM $removelist 3839fe5e51b7Smrg exit $EXIT_FAILURE 3840fe5e51b7Smrg fi 3841fe5e51b7Smrg 3842fe5e51b7Smrg # Just move the object if needed 3843fe5e51b7Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3844a31a186aSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 3845a31a186aSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3846fe5e51b7Smrg fi 3847fe5e51b7Smrg fi 3848fe5e51b7Smrg 3849a31a186aSmrg $opt_dry_run || { 3850a31a186aSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3851fe5e51b7Smrg 3852a31a186aSmrg # Unlock the critical section if it was locked 3853493f84f4Smrg if test no != "$need_locks"; then 3854a31a186aSmrg removelist=$lockfile 3855a31a186aSmrg $RM "$lockfile" 3856a31a186aSmrg fi 3857a31a186aSmrg } 3858fe5e51b7Smrg 3859fe5e51b7Smrg exit $EXIT_SUCCESS 3860a31a186aSmrg} 3861fe5e51b7Smrg 3862a31a186aSmrg$opt_help || { 3863493f84f4Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3864a31a186aSmrg} 3865fe5e51b7Smrg 3866a31a186aSmrgfunc_mode_help () 3867a31a186aSmrg{ 3868a31a186aSmrg # We need to display help for each of the modes. 38690bb88ba4Smrg case $opt_mode in 3870a31a186aSmrg "") 3871a31a186aSmrg # Generic help is extracted from the usage comments 3872a31a186aSmrg # at the start of this file. 3873a31a186aSmrg func_help 3874a31a186aSmrg ;; 3875fe5e51b7Smrg 3876a31a186aSmrg clean) 3877a31a186aSmrg $ECHO \ 3878a31a186aSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3879fe5e51b7Smrg 3880a31a186aSmrgRemove files from the build directory. 3881fe5e51b7Smrg 3882a31a186aSmrgRM is the name of the program to use to delete files associated with each FILE 3883493f84f4Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3884a31a186aSmrgto RM. 3885fe5e51b7Smrg 3886a31a186aSmrgIf FILE is a libtool library, object or program, all the files associated 3887a31a186aSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3888a31a186aSmrg ;; 3889fe5e51b7Smrg 3890a31a186aSmrg compile) 3891a31a186aSmrg $ECHO \ 3892a31a186aSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3893fe5e51b7Smrg 3894a31a186aSmrgCompile a source file into a libtool library object. 3895fe5e51b7Smrg 3896a31a186aSmrgThis mode accepts the following additional options: 3897fe5e51b7Smrg 3898a31a186aSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3899a31a186aSmrg -no-suppress do not suppress compiler output for multiple passes 39000bb88ba4Smrg -prefer-pic try to build PIC objects only 39010bb88ba4Smrg -prefer-non-pic try to build non-PIC objects only 3902493f84f4Smrg -shared do not build a '.o' file suitable for static linking 3903493f84f4Smrg -static only build a '.o' file suitable for static linking 39041e423a8fSmrg -Wc,FLAG 39051e423a8fSmrg -Xcompiler FLAG pass FLAG directly to the compiler 3906fe5e51b7Smrg 3907493f84f4SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3908a31a186aSmrgfrom the given SOURCEFILE. 3909fe5e51b7Smrg 3910a31a186aSmrgThe output file name is determined by removing the directory component from 3911493f84f4SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 3912493f84f4Smrglibrary object suffix, '.lo'." 3913a31a186aSmrg ;; 3914fe5e51b7Smrg 3915a31a186aSmrg execute) 3916a31a186aSmrg $ECHO \ 3917a31a186aSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3918fe5e51b7Smrg 3919a31a186aSmrgAutomatically set library path, then run a program. 3920fe5e51b7Smrg 3921a31a186aSmrgThis mode accepts the following additional options: 3922fe5e51b7Smrg 3923a31a186aSmrg -dlopen FILE add the directory containing FILE to the library path 3924fe5e51b7Smrg 3925493f84f4SmrgThis mode sets the library path environment variable according to '-dlopen' 3926a31a186aSmrgflags. 3927fe5e51b7Smrg 3928a31a186aSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3929a31a186aSmrginto their corresponding uninstalled binary, and any of their required library 3930a31a186aSmrgdirectories are added to the library path. 3931fe5e51b7Smrg 3932a31a186aSmrgThen, COMMAND is executed, with ARGS as arguments." 3933a31a186aSmrg ;; 3934fe5e51b7Smrg 3935a31a186aSmrg finish) 3936a31a186aSmrg $ECHO \ 3937a31a186aSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3938fe5e51b7Smrg 3939a31a186aSmrgComplete the installation of libtool libraries. 3940fe5e51b7Smrg 3941a31a186aSmrgEach LIBDIR is a directory that contains libtool libraries. 3942fe5e51b7Smrg 3943a31a186aSmrgThe commands that this mode executes may require superuser privileges. Use 3944493f84f4Smrgthe '--dry-run' option if you just want to see what would be executed." 3945a31a186aSmrg ;; 3946fe5e51b7Smrg 3947a31a186aSmrg install) 3948a31a186aSmrg $ECHO \ 3949a31a186aSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3950fe5e51b7Smrg 3951a31a186aSmrgInstall executables or libraries. 3952fe5e51b7Smrg 3953a31a186aSmrgINSTALL-COMMAND is the installation command. The first component should be 3954493f84f4Smrgeither the 'install' or 'cp' program. 3955fe5e51b7Smrg 3956a31a186aSmrgThe following components of INSTALL-COMMAND are treated specially: 3957fe5e51b7Smrg 39580bb88ba4Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3959fe5e51b7Smrg 3960a31a186aSmrgThe rest of the components are interpreted as arguments to that command (only 3961a31a186aSmrgBSD-compatible install options are recognized)." 3962a31a186aSmrg ;; 3963fe5e51b7Smrg 3964a31a186aSmrg link) 3965a31a186aSmrg $ECHO \ 3966a31a186aSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3967fe5e51b7Smrg 3968a31a186aSmrgLink object files or libraries together to form another library, or to 3969a31a186aSmrgcreate an executable program. 3970fe5e51b7Smrg 3971a31a186aSmrgLINK-COMMAND is a command using the C compiler that you would use to create 3972a31a186aSmrga program from several object files. 3973fe5e51b7Smrg 3974a31a186aSmrgThe following components of LINK-COMMAND are treated specially: 3975fe5e51b7Smrg 3976a31a186aSmrg -all-static do not do any dynamic linking at all 3977a31a186aSmrg -avoid-version do not add a version suffix if possible 39780bb88ba4Smrg -bindir BINDIR specify path to binaries directory (for systems where 39790bb88ba4Smrg libraries must be found in the PATH setting at runtime) 3980493f84f4Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3981a31a186aSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3982a31a186aSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3983a31a186aSmrg -export-symbols SYMFILE 3984a31a186aSmrg try to export only the symbols listed in SYMFILE 3985a31a186aSmrg -export-symbols-regex REGEX 3986a31a186aSmrg try to export only the symbols matching REGEX 3987a31a186aSmrg -LLIBDIR search LIBDIR for required installed libraries 3988a31a186aSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 3989a31a186aSmrg -module build a library that can dlopened 3990a31a186aSmrg -no-fast-install disable the fast-install mode 3991a31a186aSmrg -no-install link a not-installable executable 3992a31a186aSmrg -no-undefined declare that a library does not refer to external symbols 3993a31a186aSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3994493f84f4Smrg -objectlist FILE use a list of object files found in FILE to specify objects 3995493f84f4Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3996a31a186aSmrg -precious-files-regex REGEX 3997a31a186aSmrg don't remove output files matching REGEX 3998a31a186aSmrg -release RELEASE specify package release information 3999a31a186aSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 4000a31a186aSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 4001a31a186aSmrg -shared only do dynamic linking of libtool libraries 4002a31a186aSmrg -shrext SUFFIX override the standard shared library file extension 4003a31a186aSmrg -static do not do any dynamic linking of uninstalled libtool libraries 4004a31a186aSmrg -static-libtool-libs 4005a31a186aSmrg do not do any dynamic linking of libtool libraries 4006a31a186aSmrg -version-info CURRENT[:REVISION[:AGE]] 4007a31a186aSmrg specify library version info [each variable defaults to 0] 4008a31a186aSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 40090bb88ba4Smrg -Wc,FLAG 40100bb88ba4Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 40111e423a8fSmrg -Wa,FLAG 40121e423a8fSmrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 40130bb88ba4Smrg -Wl,FLAG 40140bb88ba4Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 40150bb88ba4Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 4016fe5e51b7Smrg 4017493f84f4SmrgAll other options (arguments beginning with '-') are ignored. 4018fe5e51b7Smrg 4019493f84f4SmrgEvery other argument is treated as a filename. Files ending in '.la' are 4020a31a186aSmrgtreated as uninstalled libtool libraries, other files are standard or library 4021a31a186aSmrgobject files. 4022fe5e51b7Smrg 4023493f84f4SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 4024493f84f4Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 4025a31a186aSmrgrequired, except when creating a convenience library. 4026fe5e51b7Smrg 4027493f84f4SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 4028493f84f4Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 4029fe5e51b7Smrg 4030493f84f4SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 4031a31a186aSmrgis created, otherwise an executable program is created." 4032643b027fSmrg ;; 4033fe5e51b7Smrg 4034a31a186aSmrg uninstall) 4035a31a186aSmrg $ECHO \ 4036a31a186aSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 4037fe5e51b7Smrg 4038a31a186aSmrgRemove libraries from an installation directory. 4039fe5e51b7Smrg 4040a31a186aSmrgRM is the name of the program to use to delete files associated with each FILE 4041493f84f4Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 4042a31a186aSmrgto RM. 4043fe5e51b7Smrg 4044a31a186aSmrgIf FILE is a libtool library, all the files associated with it are deleted. 4045a31a186aSmrgOtherwise, only FILE itself is deleted using RM." 4046a31a186aSmrg ;; 4047eda3803bSmrg 4048a31a186aSmrg *) 4049493f84f4Smrg func_fatal_help "invalid operation mode '$opt_mode'" 4050a31a186aSmrg ;; 4051a31a186aSmrg esac 4052eda3803bSmrg 40530bb88ba4Smrg echo 4054493f84f4Smrg $ECHO "Try '$progname --help' for more information about other modes." 4055a31a186aSmrg} 4056eda3803bSmrg 40570bb88ba4Smrg# Now that we've collected a possible --mode arg, show help if necessary 40580bb88ba4Smrgif $opt_help; then 4059493f84f4Smrg if test : = "$opt_help"; then 40600bb88ba4Smrg func_mode_help 40610bb88ba4Smrg else 40620bb88ba4Smrg { 40630bb88ba4Smrg func_help noexit 40640bb88ba4Smrg for opt_mode in compile link execute install finish uninstall clean; do 40650bb88ba4Smrg func_mode_help 40660bb88ba4Smrg done 4067493f84f4Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 40680bb88ba4Smrg { 40690bb88ba4Smrg func_help noexit 40700bb88ba4Smrg for opt_mode in compile link execute install finish uninstall clean; do 40710bb88ba4Smrg echo 40720bb88ba4Smrg func_mode_help 40730bb88ba4Smrg done 40740bb88ba4Smrg } | 4075493f84f4Smrg $SED '1d 40760bb88ba4Smrg /^When reporting/,/^Report/{ 40770bb88ba4Smrg H 40780bb88ba4Smrg d 40790bb88ba4Smrg } 40800bb88ba4Smrg $x 40810bb88ba4Smrg /information about other modes/d 40820bb88ba4Smrg /more detailed .*MODE/d 40830bb88ba4Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 40840bb88ba4Smrg fi 40850bb88ba4Smrg exit $? 40860bb88ba4Smrgfi 4087eda3803bSmrg 4088eda3803bSmrg 4089a31a186aSmrg# func_mode_execute arg... 4090a31a186aSmrgfunc_mode_execute () 4091a31a186aSmrg{ 4092493f84f4Smrg $debug_cmd 4093493f84f4Smrg 4094a31a186aSmrg # The first argument is the command name. 4095493f84f4Smrg cmd=$nonopt 4096a31a186aSmrg test -z "$cmd" && \ 4097a31a186aSmrg func_fatal_help "you must specify a COMMAND" 4098643b027fSmrg 4099a31a186aSmrg # Handle -dlopen flags immediately. 41000bb88ba4Smrg for file in $opt_dlopen; do 4101a31a186aSmrg test -f "$file" \ 4102493f84f4Smrg || func_fatal_help "'$file' is not a file" 4103643b027fSmrg 4104a31a186aSmrg dir= 4105a31a186aSmrg case $file in 4106a31a186aSmrg *.la) 41070bb88ba4Smrg func_resolve_sysroot "$file" 41080bb88ba4Smrg file=$func_resolve_sysroot_result 41090bb88ba4Smrg 4110a31a186aSmrg # Check to see that this really is a libtool archive. 4111a31a186aSmrg func_lalib_unsafe_p "$file" \ 4112493f84f4Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 4113643b027fSmrg 4114a31a186aSmrg # Read the libtool library. 4115a31a186aSmrg dlname= 4116a31a186aSmrg library_names= 4117a31a186aSmrg func_source "$file" 4118fe5e51b7Smrg 4119a31a186aSmrg # Skip this library if it cannot be dlopened. 4120a31a186aSmrg if test -z "$dlname"; then 4121a31a186aSmrg # Warn if it was a shared library. 4122a31a186aSmrg test -n "$library_names" && \ 4123493f84f4Smrg func_warning "'$file' was not linked with '-export-dynamic'" 4124a31a186aSmrg continue 4125a31a186aSmrg fi 4126fe5e51b7Smrg 4127a31a186aSmrg func_dirname "$file" "" "." 4128493f84f4Smrg dir=$func_dirname_result 4129fe5e51b7Smrg 4130a31a186aSmrg if test -f "$dir/$objdir/$dlname"; then 41310bb88ba4Smrg func_append dir "/$objdir" 4132a31a186aSmrg else 4133a31a186aSmrg if test ! -f "$dir/$dlname"; then 4134493f84f4Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 4135a31a186aSmrg fi 4136a31a186aSmrg fi 4137643b027fSmrg ;; 4138fe5e51b7Smrg 4139a31a186aSmrg *.lo) 4140a31a186aSmrg # Just add the directory containing the .lo file. 4141a31a186aSmrg func_dirname "$file" "" "." 4142493f84f4Smrg dir=$func_dirname_result 4143643b027fSmrg ;; 4144fe5e51b7Smrg 4145a31a186aSmrg *) 4146493f84f4Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 4147643b027fSmrg continue 4148643b027fSmrg ;; 4149a31a186aSmrg esac 4150fe5e51b7Smrg 4151a31a186aSmrg # Get the absolute pathname. 4152a31a186aSmrg absdir=`cd "$dir" && pwd` 4153493f84f4Smrg test -n "$absdir" && dir=$absdir 4154eda3803bSmrg 4155a31a186aSmrg # Now add the directory to shlibpath_var. 4156a31a186aSmrg if eval "test -z \"\$$shlibpath_var\""; then 4157a31a186aSmrg eval "$shlibpath_var=\"\$dir\"" 4158a31a186aSmrg else 4159a31a186aSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 4160a31a186aSmrg fi 4161a31a186aSmrg done 4162eda3803bSmrg 4163a31a186aSmrg # This variable tells wrapper scripts just to set shlibpath_var 4164a31a186aSmrg # rather than running their programs. 4165493f84f4Smrg libtool_execute_magic=$magic 4166eda3803bSmrg 4167a31a186aSmrg # Check if any of the arguments is a wrapper script. 4168a31a186aSmrg args= 4169a31a186aSmrg for file 4170a31a186aSmrg do 4171a31a186aSmrg case $file in 41720bb88ba4Smrg -* | *.la | *.lo ) ;; 4173a31a186aSmrg *) 4174a31a186aSmrg # Do a test to see if this is really a libtool program. 4175a31a186aSmrg if func_ltwrapper_script_p "$file"; then 4176a31a186aSmrg func_source "$file" 4177a31a186aSmrg # Transform arg to wrapped name. 4178493f84f4Smrg file=$progdir/$program 4179a31a186aSmrg elif func_ltwrapper_executable_p "$file"; then 4180a31a186aSmrg func_ltwrapper_scriptname "$file" 4181a31a186aSmrg func_source "$func_ltwrapper_scriptname_result" 4182a31a186aSmrg # Transform arg to wrapped name. 4183493f84f4Smrg file=$progdir/$program 4184a31a186aSmrg fi 4185a31a186aSmrg ;; 4186a31a186aSmrg esac 4187a31a186aSmrg # Quote arguments (to preserve shell metacharacters). 41880bb88ba4Smrg func_append_quoted args "$file" 4189a31a186aSmrg done 4190eda3803bSmrg 4191493f84f4Smrg if $opt_dry_run; then 4192493f84f4Smrg # Display what would be done. 4193493f84f4Smrg if test -n "$shlibpath_var"; then 4194493f84f4Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 4195493f84f4Smrg echo "export $shlibpath_var" 4196493f84f4Smrg fi 4197493f84f4Smrg $ECHO "$cmd$args" 4198493f84f4Smrg exit $EXIT_SUCCESS 4199493f84f4Smrg else 4200a31a186aSmrg if test -n "$shlibpath_var"; then 4201a31a186aSmrg # Export the shlibpath_var. 4202a31a186aSmrg eval "export $shlibpath_var" 4203a31a186aSmrg fi 4204eda3803bSmrg 4205a31a186aSmrg # Restore saved environment variables 4206a31a186aSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 4207a31a186aSmrg do 4208a31a186aSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 4209a31a186aSmrg $lt_var=\$save_$lt_var; export $lt_var 4210643b027fSmrg else 4211a31a186aSmrg $lt_unset $lt_var 4212a31a186aSmrg fi" 4213a31a186aSmrg done 4214eda3803bSmrg 4215a31a186aSmrg # Now prepare to actually exec the command. 4216493f84f4Smrg exec_cmd=\$cmd$args 4217a31a186aSmrg fi 4218a31a186aSmrg} 4219eda3803bSmrg 4220493f84f4Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 4221eda3803bSmrg 4222643b027fSmrg 4223a31a186aSmrg# func_mode_finish arg... 4224a31a186aSmrgfunc_mode_finish () 4225a31a186aSmrg{ 4226493f84f4Smrg $debug_cmd 4227493f84f4Smrg 42280bb88ba4Smrg libs= 42290bb88ba4Smrg libdirs= 4230a31a186aSmrg admincmds= 4231fe5e51b7Smrg 42320bb88ba4Smrg for opt in "$nonopt" ${1+"$@"} 42330bb88ba4Smrg do 42340bb88ba4Smrg if test -d "$opt"; then 42350bb88ba4Smrg func_append libdirs " $opt" 42360bb88ba4Smrg 42370bb88ba4Smrg elif test -f "$opt"; then 42380bb88ba4Smrg if func_lalib_unsafe_p "$opt"; then 42390bb88ba4Smrg func_append libs " $opt" 42400bb88ba4Smrg else 4241493f84f4Smrg func_warning "'$opt' is not a valid libtool archive" 42420bb88ba4Smrg fi 42430bb88ba4Smrg 42440bb88ba4Smrg else 4245493f84f4Smrg func_fatal_error "invalid argument '$opt'" 42460bb88ba4Smrg fi 42470bb88ba4Smrg done 42480bb88ba4Smrg 42490bb88ba4Smrg if test -n "$libs"; then 42500bb88ba4Smrg if test -n "$lt_sysroot"; then 42510bb88ba4Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 42520bb88ba4Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 42530bb88ba4Smrg else 42540bb88ba4Smrg sysroot_cmd= 42550bb88ba4Smrg fi 42560bb88ba4Smrg 42570bb88ba4Smrg # Remove sysroot references 42580bb88ba4Smrg if $opt_dry_run; then 42590bb88ba4Smrg for lib in $libs; do 4260493f84f4Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 42610bb88ba4Smrg done 42620bb88ba4Smrg else 42630bb88ba4Smrg tmpdir=`func_mktempdir` 42640bb88ba4Smrg for lib in $libs; do 4265493f84f4Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 42660bb88ba4Smrg > $tmpdir/tmp-la 42670bb88ba4Smrg mv -f $tmpdir/tmp-la $lib 42680bb88ba4Smrg done 42690bb88ba4Smrg ${RM}r "$tmpdir" 42700bb88ba4Smrg fi 42710bb88ba4Smrg fi 4272fe5e51b7Smrg 42730bb88ba4Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4274a31a186aSmrg for libdir in $libdirs; do 4275a31a186aSmrg if test -n "$finish_cmds"; then 4276a31a186aSmrg # Do each command in the finish commands. 4277a31a186aSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4278a31a186aSmrg'"$cmd"'"' 4279643b027fSmrg fi 4280a31a186aSmrg if test -n "$finish_eval"; then 4281a31a186aSmrg # Do the single finish_eval. 4282a31a186aSmrg eval cmds=\"$finish_eval\" 42830bb88ba4Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4284a31a186aSmrg $cmds" 4285a31a186aSmrg fi 4286a31a186aSmrg done 4287a31a186aSmrg fi 4288fe5e51b7Smrg 4289a31a186aSmrg # Exit here if they wanted silent mode. 4290493f84f4Smrg $opt_quiet && exit $EXIT_SUCCESS 4291fe5e51b7Smrg 42920bb88ba4Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 42930bb88ba4Smrg echo "----------------------------------------------------------------------" 42940bb88ba4Smrg echo "Libraries have been installed in:" 42950bb88ba4Smrg for libdir in $libdirs; do 42960bb88ba4Smrg $ECHO " $libdir" 42970bb88ba4Smrg done 42980bb88ba4Smrg echo 42990bb88ba4Smrg echo "If you ever happen to want to link against installed libraries" 43000bb88ba4Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 4301493f84f4Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 43020bb88ba4Smrg echo "flag during linking and do at least one of the following:" 43030bb88ba4Smrg if test -n "$shlibpath_var"; then 4304493f84f4Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 43050bb88ba4Smrg echo " during execution" 43060bb88ba4Smrg fi 43070bb88ba4Smrg if test -n "$runpath_var"; then 4308493f84f4Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 43090bb88ba4Smrg echo " during linking" 43100bb88ba4Smrg fi 43110bb88ba4Smrg if test -n "$hardcode_libdir_flag_spec"; then 43120bb88ba4Smrg libdir=LIBDIR 43130bb88ba4Smrg eval flag=\"$hardcode_libdir_flag_spec\" 4314a31a186aSmrg 4315493f84f4Smrg $ECHO " - use the '$flag' linker flag" 43160bb88ba4Smrg fi 43170bb88ba4Smrg if test -n "$admincmds"; then 43180bb88ba4Smrg $ECHO " - have your system administrator run these commands:$admincmds" 43190bb88ba4Smrg fi 43200bb88ba4Smrg if test -f /etc/ld.so.conf; then 4321493f84f4Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 43220bb88ba4Smrg fi 43230bb88ba4Smrg echo 4324a31a186aSmrg 43250bb88ba4Smrg echo "See any operating system documentation about shared libraries for" 43260bb88ba4Smrg case $host in 43270bb88ba4Smrg solaris2.[6789]|solaris2.1[0-9]) 43280bb88ba4Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 43290bb88ba4Smrg echo "pages." 43300bb88ba4Smrg ;; 43310bb88ba4Smrg *) 43320bb88ba4Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 43330bb88ba4Smrg ;; 43340bb88ba4Smrg esac 43350bb88ba4Smrg echo "----------------------------------------------------------------------" 43360bb88ba4Smrg fi 4337a31a186aSmrg exit $EXIT_SUCCESS 4338a31a186aSmrg} 4339a31a186aSmrg 4340493f84f4Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4341a31a186aSmrg 4342a31a186aSmrg 4343a31a186aSmrg# func_mode_install arg... 4344a31a186aSmrgfunc_mode_install () 4345a31a186aSmrg{ 4346493f84f4Smrg $debug_cmd 4347493f84f4Smrg 4348a31a186aSmrg # There may be an optional sh(1) argument at the beginning of 4349a31a186aSmrg # install_prog (especially on Windows NT). 4350493f84f4Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4351a31a186aSmrg # Allow the use of GNU shtool's install command. 4352493f84f4Smrg case $nonopt in *shtool*) :;; *) false;; esac 4353493f84f4Smrg then 4354a31a186aSmrg # Aesthetically quote it. 43551e423a8fSmrg func_quote_arg pretty "$nonopt" 43561e423a8fSmrg install_prog="$func_quote_arg_result " 4357a31a186aSmrg arg=$1 4358a31a186aSmrg shift 4359a31a186aSmrg else 4360a31a186aSmrg install_prog= 4361a31a186aSmrg arg=$nonopt 4362a31a186aSmrg fi 4363a31a186aSmrg 4364a31a186aSmrg # The real first argument should be the name of the installation program. 4365a31a186aSmrg # Aesthetically quote it. 43661e423a8fSmrg func_quote_arg pretty "$arg" 43671e423a8fSmrg func_append install_prog "$func_quote_arg_result" 43680bb88ba4Smrg install_shared_prog=$install_prog 43690bb88ba4Smrg case " $install_prog " in 43700bb88ba4Smrg *[\\\ /]cp\ *) install_cp=: ;; 43710bb88ba4Smrg *) install_cp=false ;; 43720bb88ba4Smrg esac 4373a31a186aSmrg 4374a31a186aSmrg # We need to accept at least all the BSD install flags. 4375a31a186aSmrg dest= 4376a31a186aSmrg files= 4377a31a186aSmrg opts= 4378a31a186aSmrg prev= 4379a31a186aSmrg install_type= 4380493f84f4Smrg isdir=false 4381a31a186aSmrg stripme= 43820bb88ba4Smrg no_mode=: 4383a31a186aSmrg for arg 4384a31a186aSmrg do 43850bb88ba4Smrg arg2= 4386a31a186aSmrg if test -n "$dest"; then 43870bb88ba4Smrg func_append files " $dest" 4388a31a186aSmrg dest=$arg 4389a31a186aSmrg continue 4390a31a186aSmrg fi 4391a31a186aSmrg 4392a31a186aSmrg case $arg in 4393493f84f4Smrg -d) isdir=: ;; 4394a31a186aSmrg -f) 43950bb88ba4Smrg if $install_cp; then :; else 43960bb88ba4Smrg prev=$arg 43970bb88ba4Smrg fi 4398a31a186aSmrg ;; 4399a31a186aSmrg -g | -m | -o) 4400a31a186aSmrg prev=$arg 4401a31a186aSmrg ;; 4402a31a186aSmrg -s) 4403a31a186aSmrg stripme=" -s" 4404a31a186aSmrg continue 4405a31a186aSmrg ;; 4406a31a186aSmrg -*) 4407a31a186aSmrg ;; 4408a31a186aSmrg *) 4409a31a186aSmrg # If the previous option needed an argument, then skip it. 4410a31a186aSmrg if test -n "$prev"; then 4411493f84f4Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 44120bb88ba4Smrg arg2=$install_override_mode 44130bb88ba4Smrg no_mode=false 44140bb88ba4Smrg fi 4415643b027fSmrg prev= 4416eda3803bSmrg else 4417a31a186aSmrg dest=$arg 4418a31a186aSmrg continue 4419fe5e51b7Smrg fi 4420643b027fSmrg ;; 4421a31a186aSmrg esac 4422fe5e51b7Smrg 4423a31a186aSmrg # Aesthetically quote the argument. 44241e423a8fSmrg func_quote_arg pretty "$arg" 44251e423a8fSmrg func_append install_prog " $func_quote_arg_result" 44260bb88ba4Smrg if test -n "$arg2"; then 44271e423a8fSmrg func_quote_arg pretty "$arg2" 44280bb88ba4Smrg fi 44291e423a8fSmrg func_append install_shared_prog " $func_quote_arg_result" 4430a31a186aSmrg done 4431fe5e51b7Smrg 4432a31a186aSmrg test -z "$install_prog" && \ 4433a31a186aSmrg func_fatal_help "you must specify an install program" 4434fe5e51b7Smrg 4435a31a186aSmrg test -n "$prev" && \ 4436493f84f4Smrg func_fatal_help "the '$prev' option requires an argument" 4437eda3803bSmrg 44380bb88ba4Smrg if test -n "$install_override_mode" && $no_mode; then 44390bb88ba4Smrg if $install_cp; then :; else 44401e423a8fSmrg func_quote_arg pretty "$install_override_mode" 44411e423a8fSmrg func_append install_shared_prog " -m $func_quote_arg_result" 44420bb88ba4Smrg fi 44430bb88ba4Smrg fi 44440bb88ba4Smrg 4445a31a186aSmrg if test -z "$files"; then 4446a31a186aSmrg if test -z "$dest"; then 4447a31a186aSmrg func_fatal_help "no file or destination specified" 4448a31a186aSmrg else 4449a31a186aSmrg func_fatal_help "you must specify a destination" 4450a31a186aSmrg fi 4451643b027fSmrg fi 4452eda3803bSmrg 4453a31a186aSmrg # Strip any trailing slash from the destination. 4454a31a186aSmrg func_stripname '' '/' "$dest" 4455a31a186aSmrg dest=$func_stripname_result 4456eda3803bSmrg 4457a31a186aSmrg # Check to see that the destination is a directory. 4458493f84f4Smrg test -d "$dest" && isdir=: 4459493f84f4Smrg if $isdir; then 4460493f84f4Smrg destdir=$dest 4461a31a186aSmrg destname= 4462643b027fSmrg else 4463a31a186aSmrg func_dirname_and_basename "$dest" "" "." 4464493f84f4Smrg destdir=$func_dirname_result 4465493f84f4Smrg destname=$func_basename_result 4466eda3803bSmrg 4467a31a186aSmrg # Not a directory, so check to see that there is only one file specified. 4468a31a186aSmrg set dummy $files; shift 4469a31a186aSmrg test "$#" -gt 1 && \ 4470493f84f4Smrg func_fatal_help "'$dest' is not a directory" 4471eda3803bSmrg fi 4472a31a186aSmrg case $destdir in 4473a31a186aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4474643b027fSmrg *) 4475a31a186aSmrg for file in $files; do 4476a31a186aSmrg case $file in 4477a31a186aSmrg *.lo) ;; 4478a31a186aSmrg *) 4479493f84f4Smrg func_fatal_help "'$destdir' must be an absolute directory name" 4480a31a186aSmrg ;; 4481a31a186aSmrg esac 4482a31a186aSmrg done 4483643b027fSmrg ;; 4484643b027fSmrg esac 4485fe5e51b7Smrg 4486a31a186aSmrg # This variable tells wrapper scripts just to set variables rather 4487a31a186aSmrg # than running their programs. 4488493f84f4Smrg libtool_install_magic=$magic 4489fe5e51b7Smrg 4490a31a186aSmrg staticlibs= 4491a31a186aSmrg future_libdirs= 4492a31a186aSmrg current_libdirs= 4493a31a186aSmrg for file in $files; do 4494fe5e51b7Smrg 4495a31a186aSmrg # Do each installation. 4496a31a186aSmrg case $file in 4497a31a186aSmrg *.$libext) 4498a31a186aSmrg # Do the static libraries later. 44990bb88ba4Smrg func_append staticlibs " $file" 4500a31a186aSmrg ;; 4501a31a186aSmrg 4502a31a186aSmrg *.la) 45030bb88ba4Smrg func_resolve_sysroot "$file" 45040bb88ba4Smrg file=$func_resolve_sysroot_result 45050bb88ba4Smrg 4506a31a186aSmrg # Check to see that this really is a libtool archive. 4507a31a186aSmrg func_lalib_unsafe_p "$file" \ 4508493f84f4Smrg || func_fatal_help "'$file' is not a valid libtool archive" 4509a31a186aSmrg 4510a31a186aSmrg library_names= 4511a31a186aSmrg old_library= 4512a31a186aSmrg relink_command= 4513a31a186aSmrg func_source "$file" 4514a31a186aSmrg 4515a31a186aSmrg # Add the libdir to current_libdirs if it is the destination. 4516a31a186aSmrg if test "X$destdir" = "X$libdir"; then 4517a31a186aSmrg case "$current_libdirs " in 4518a31a186aSmrg *" $libdir "*) ;; 45190bb88ba4Smrg *) func_append current_libdirs " $libdir" ;; 4520eda3803bSmrg esac 4521a31a186aSmrg else 4522a31a186aSmrg # Note the libdir as a future libdir. 4523a31a186aSmrg case "$future_libdirs " in 4524a31a186aSmrg *" $libdir "*) ;; 45250bb88ba4Smrg *) func_append future_libdirs " $libdir" ;; 4526a31a186aSmrg esac 4527a31a186aSmrg fi 4528fe5e51b7Smrg 4529a31a186aSmrg func_dirname "$file" "/" "" 4530493f84f4Smrg dir=$func_dirname_result 45310bb88ba4Smrg func_append dir "$objdir" 4532a31a186aSmrg 4533a31a186aSmrg if test -n "$relink_command"; then 4534a31a186aSmrg # Determine the prefix the user has applied to our future dir. 45350bb88ba4Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4536a31a186aSmrg 4537a31a186aSmrg # Don't allow the user to place us outside of our expected 4538a31a186aSmrg # location b/c this prevents finding dependent libraries that 4539a31a186aSmrg # are installed to the same prefix. 4540a31a186aSmrg # At present, this check doesn't affect windows .dll's that 4541a31a186aSmrg # are installed into $libdir/../bin (currently, that works fine) 4542a31a186aSmrg # but it's something to keep an eye on. 4543a31a186aSmrg test "$inst_prefix_dir" = "$destdir" && \ 4544493f84f4Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4545a31a186aSmrg 4546a31a186aSmrg if test -n "$inst_prefix_dir"; then 4547a31a186aSmrg # Stick the inst_prefix_dir data into the link command. 45480bb88ba4Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4549a31a186aSmrg else 45500bb88ba4Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4551a31a186aSmrg fi 4552a31a186aSmrg 4553493f84f4Smrg func_warning "relinking '$file'" 4554a31a186aSmrg func_show_eval "$relink_command" \ 4555493f84f4Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4556a31a186aSmrg fi 4557a31a186aSmrg 4558a31a186aSmrg # See the names of the shared library. 4559a31a186aSmrg set dummy $library_names; shift 4560a31a186aSmrg if test -n "$1"; then 4561493f84f4Smrg realname=$1 4562a31a186aSmrg shift 4563a31a186aSmrg 4564493f84f4Smrg srcname=$realname 4565493f84f4Smrg test -n "$relink_command" && srcname=${realname}T 4566a31a186aSmrg 4567a31a186aSmrg # Install the shared library and build the symlinks. 45680bb88ba4Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4569a31a186aSmrg 'exit $?' 4570493f84f4Smrg tstripme=$stripme 4571a31a186aSmrg case $host_os in 4572a31a186aSmrg cygwin* | mingw* | pw32* | cegcc*) 4573a31a186aSmrg case $realname in 4574a31a186aSmrg *.dll.a) 4575493f84f4Smrg tstripme= 4576493f84f4Smrg ;; 4577493f84f4Smrg esac 4578493f84f4Smrg ;; 4579493f84f4Smrg os2*) 4580493f84f4Smrg case $realname in 4581493f84f4Smrg *_dll.a) 4582493f84f4Smrg tstripme= 4583a31a186aSmrg ;; 4584a31a186aSmrg esac 4585eda3803bSmrg ;; 4586eda3803bSmrg esac 4587a31a186aSmrg if test -n "$tstripme" && test -n "$striplib"; then 4588a31a186aSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4589643b027fSmrg fi 4590a31a186aSmrg 4591a31a186aSmrg if test "$#" -gt 0; then 4592a31a186aSmrg # Delete the old symlinks, and create new ones. 4593493f84f4Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4594a31a186aSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4595a31a186aSmrg # so we also need to try rm && ln -s. 4596a31a186aSmrg for linkname 4597a31a186aSmrg do 4598a31a186aSmrg test "$linkname" != "$realname" \ 4599a31a186aSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4600643b027fSmrg done 4601643b027fSmrg fi 4602fe5e51b7Smrg 4603a31a186aSmrg # Do each command in the postinstall commands. 4604493f84f4Smrg lib=$destdir/$realname 4605a31a186aSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4606643b027fSmrg fi 4607fe5e51b7Smrg 4608a31a186aSmrg # Install the pseudo-library for information purposes. 4609a31a186aSmrg func_basename "$file" 4610493f84f4Smrg name=$func_basename_result 4611493f84f4Smrg instname=$dir/${name}i 4612a31a186aSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4613fe5e51b7Smrg 4614a31a186aSmrg # Maybe install the static library, too. 46150bb88ba4Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4616a31a186aSmrg ;; 4617fe5e51b7Smrg 4618a31a186aSmrg *.lo) 4619a31a186aSmrg # Install (i.e. copy) a libtool object. 4620fe5e51b7Smrg 4621a31a186aSmrg # Figure out destination file name, if it wasn't already specified. 4622a31a186aSmrg if test -n "$destname"; then 4623493f84f4Smrg destfile=$destdir/$destname 4624a31a186aSmrg else 4625a31a186aSmrg func_basename "$file" 4626493f84f4Smrg destfile=$func_basename_result 4627493f84f4Smrg destfile=$destdir/$destfile 4628643b027fSmrg fi 4629fe5e51b7Smrg 4630a31a186aSmrg # Deduce the name of the destination old-style object file. 4631a31a186aSmrg case $destfile in 4632a31a186aSmrg *.lo) 4633a31a186aSmrg func_lo2o "$destfile" 4634a31a186aSmrg staticdest=$func_lo2o_result 4635a31a186aSmrg ;; 4636a31a186aSmrg *.$objext) 4637493f84f4Smrg staticdest=$destfile 4638a31a186aSmrg destfile= 4639a31a186aSmrg ;; 4640a31a186aSmrg *) 4641493f84f4Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4642a31a186aSmrg ;; 4643a31a186aSmrg esac 4644fe5e51b7Smrg 4645a31a186aSmrg # Install the libtool object if requested. 4646a31a186aSmrg test -n "$destfile" && \ 4647a31a186aSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4648fe5e51b7Smrg 4649a31a186aSmrg # Install the old object if enabled. 4650493f84f4Smrg if test yes = "$build_old_libs"; then 4651a31a186aSmrg # Deduce the name of the old-style object file. 4652a31a186aSmrg func_lo2o "$file" 4653a31a186aSmrg staticobj=$func_lo2o_result 4654a31a186aSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4655fe5e51b7Smrg fi 4656a31a186aSmrg exit $EXIT_SUCCESS 4657a31a186aSmrg ;; 4658fe5e51b7Smrg 4659a31a186aSmrg *) 4660a31a186aSmrg # Figure out destination file name, if it wasn't already specified. 4661a31a186aSmrg if test -n "$destname"; then 4662493f84f4Smrg destfile=$destdir/$destname 4663a31a186aSmrg else 4664a31a186aSmrg func_basename "$file" 4665493f84f4Smrg destfile=$func_basename_result 4666493f84f4Smrg destfile=$destdir/$destfile 4667a31a186aSmrg fi 4668fe5e51b7Smrg 4669a31a186aSmrg # If the file is missing, and there is a .exe on the end, strip it 4670a31a186aSmrg # because it is most likely a libtool script we actually want to 4671a31a186aSmrg # install 4672493f84f4Smrg stripped_ext= 4673a31a186aSmrg case $file in 4674a31a186aSmrg *.exe) 4675a31a186aSmrg if test ! -f "$file"; then 4676a31a186aSmrg func_stripname '' '.exe' "$file" 4677a31a186aSmrg file=$func_stripname_result 4678493f84f4Smrg stripped_ext=.exe 4679a31a186aSmrg fi 4680a31a186aSmrg ;; 4681a31a186aSmrg esac 4682a31a186aSmrg 4683a31a186aSmrg # Do a test to see if this is really a libtool program. 4684a31a186aSmrg case $host in 4685a31a186aSmrg *cygwin* | *mingw*) 4686a31a186aSmrg if func_ltwrapper_executable_p "$file"; then 4687a31a186aSmrg func_ltwrapper_scriptname "$file" 4688a31a186aSmrg wrapper=$func_ltwrapper_scriptname_result 4689a31a186aSmrg else 4690a31a186aSmrg func_stripname '' '.exe' "$file" 4691a31a186aSmrg wrapper=$func_stripname_result 4692a31a186aSmrg fi 4693a31a186aSmrg ;; 4694643b027fSmrg *) 4695a31a186aSmrg wrapper=$file 4696a31a186aSmrg ;; 4697a31a186aSmrg esac 4698a31a186aSmrg if func_ltwrapper_script_p "$wrapper"; then 4699a31a186aSmrg notinst_deplibs= 4700a31a186aSmrg relink_command= 4701a31a186aSmrg 4702a31a186aSmrg func_source "$wrapper" 4703a31a186aSmrg 4704a31a186aSmrg # Check the variables that should have been set. 4705a31a186aSmrg test -z "$generated_by_libtool_version" && \ 4706493f84f4Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4707a31a186aSmrg 4708493f84f4Smrg finalize=: 4709a31a186aSmrg for lib in $notinst_deplibs; do 4710a31a186aSmrg # Check to see that each library is installed. 4711a31a186aSmrg libdir= 4712a31a186aSmrg if test -f "$lib"; then 4713a31a186aSmrg func_source "$lib" 4714a31a186aSmrg fi 4715493f84f4Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4716a31a186aSmrg if test -n "$libdir" && test ! -f "$libfile"; then 4717493f84f4Smrg func_warning "'$lib' has not been installed in '$libdir'" 4718493f84f4Smrg finalize=false 4719a31a186aSmrg fi 4720a31a186aSmrg done 4721a31a186aSmrg 4722a31a186aSmrg relink_command= 4723a31a186aSmrg func_source "$wrapper" 4724a31a186aSmrg 4725a31a186aSmrg outputname= 4726493f84f4Smrg if test no = "$fast_install" && test -n "$relink_command"; then 4727a31a186aSmrg $opt_dry_run || { 4728493f84f4Smrg if $finalize; then 4729a31a186aSmrg tmpdir=`func_mktempdir` 4730a31a186aSmrg func_basename "$file$stripped_ext" 4731493f84f4Smrg file=$func_basename_result 4732493f84f4Smrg outputname=$tmpdir/$file 4733a31a186aSmrg # Replace the output file specification. 47340bb88ba4Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4735a31a186aSmrg 4736493f84f4Smrg $opt_quiet || { 47371e423a8fSmrg func_quote_arg expand,pretty "$relink_command" 47381e423a8fSmrg eval "func_echo $func_quote_arg_result" 4739a31a186aSmrg } 4740a31a186aSmrg if eval "$relink_command"; then : 4741a31a186aSmrg else 4742493f84f4Smrg func_error "error: relink '$file' with the above command before installing it" 4743a31a186aSmrg $opt_dry_run || ${RM}r "$tmpdir" 4744a31a186aSmrg continue 4745a31a186aSmrg fi 4746493f84f4Smrg file=$outputname 4747a31a186aSmrg else 4748493f84f4Smrg func_warning "cannot relink '$file'" 4749a31a186aSmrg fi 4750a31a186aSmrg } 4751a31a186aSmrg else 4752a31a186aSmrg # Install the binary that we compiled earlier. 47530bb88ba4Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4754643b027fSmrg fi 4755a31a186aSmrg fi 4756a31a186aSmrg 4757a31a186aSmrg # remove .exe since cygwin /usr/bin/install will append another 4758a31a186aSmrg # one anyway 4759a31a186aSmrg case $install_prog,$host in 4760a31a186aSmrg */usr/bin/install*,*cygwin*) 4761a31a186aSmrg case $file:$destfile in 4762a31a186aSmrg *.exe:*.exe) 4763a31a186aSmrg # this is ok 4764a31a186aSmrg ;; 4765a31a186aSmrg *.exe:*) 4766a31a186aSmrg destfile=$destfile.exe 4767a31a186aSmrg ;; 4768a31a186aSmrg *:*.exe) 4769a31a186aSmrg func_stripname '' '.exe' "$destfile" 4770a31a186aSmrg destfile=$func_stripname_result 4771a31a186aSmrg ;; 4772a31a186aSmrg esac 4773643b027fSmrg ;; 4774643b027fSmrg esac 4775a31a186aSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4776a31a186aSmrg $opt_dry_run || if test -n "$outputname"; then 4777a31a186aSmrg ${RM}r "$tmpdir" 4778a31a186aSmrg fi 4779a31a186aSmrg ;; 4780a31a186aSmrg esac 4781a31a186aSmrg done 4782fe5e51b7Smrg 4783a31a186aSmrg for file in $staticlibs; do 4784a31a186aSmrg func_basename "$file" 4785493f84f4Smrg name=$func_basename_result 4786a31a186aSmrg 4787a31a186aSmrg # Set up the ranlib parameters. 4788493f84f4Smrg oldlib=$destdir/$name 47890bb88ba4Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 47900bb88ba4Smrg tool_oldlib=$func_to_tool_file_result 4791a31a186aSmrg 4792a31a186aSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4793a31a186aSmrg 4794a31a186aSmrg if test -n "$stripme" && test -n "$old_striplib"; then 47950bb88ba4Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4796a31a186aSmrg fi 4797a31a186aSmrg 4798a31a186aSmrg # Do each command in the postinstall commands. 4799a31a186aSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4800a31a186aSmrg done 4801a31a186aSmrg 4802a31a186aSmrg test -n "$future_libdirs" && \ 4803493f84f4Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 4804a31a186aSmrg 4805a31a186aSmrg if test -n "$current_libdirs"; then 4806a31a186aSmrg # Maybe just do a dry run. 4807a31a186aSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 4808493f84f4Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4809a31a186aSmrg else 4810a31a186aSmrg exit $EXIT_SUCCESS 4811a31a186aSmrg fi 4812a31a186aSmrg} 4813a31a186aSmrg 4814493f84f4Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4815a31a186aSmrg 4816a31a186aSmrg 4817a31a186aSmrg# func_generate_dlsyms outputname originator pic_p 4818a31a186aSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4819a31a186aSmrg# a dlpreopen symbol table. 4820a31a186aSmrgfunc_generate_dlsyms () 4821a31a186aSmrg{ 4822493f84f4Smrg $debug_cmd 4823493f84f4Smrg 4824493f84f4Smrg my_outputname=$1 4825493f84f4Smrg my_originator=$2 4826493f84f4Smrg my_pic_p=${3-false} 4827493f84f4Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4828a31a186aSmrg my_dlsyms= 4829a31a186aSmrg 4830493f84f4Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4831a31a186aSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4832493f84f4Smrg my_dlsyms=${my_outputname}S.c 4833a31a186aSmrg else 4834a31a186aSmrg func_error "not configured to extract global symbols from dlpreopened files" 4835a31a186aSmrg fi 4836a31a186aSmrg fi 4837a31a186aSmrg 4838a31a186aSmrg if test -n "$my_dlsyms"; then 4839a31a186aSmrg case $my_dlsyms in 4840a31a186aSmrg "") ;; 4841a31a186aSmrg *.c) 4842a31a186aSmrg # Discover the nlist of each of the dlfiles. 4843493f84f4Smrg nlist=$output_objdir/$my_outputname.nm 4844a31a186aSmrg 4845a31a186aSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4846a31a186aSmrg 4847a31a186aSmrg # Parse the name list into a source file. 4848a31a186aSmrg func_verbose "creating $output_objdir/$my_dlsyms" 4849a31a186aSmrg 4850a31a186aSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4851493f84f4Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4852493f84f4Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4853a31a186aSmrg 4854a31a186aSmrg#ifdef __cplusplus 4855a31a186aSmrgextern \"C\" { 4856a31a186aSmrg#endif 4857a31a186aSmrg 4858493f84f4Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 48590bb88ba4Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 48600bb88ba4Smrg#endif 48610bb88ba4Smrg 48620bb88ba4Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4863493f84f4Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4864493f84f4Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 48650bb88ba4Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 48660bb88ba4Smrg# define LT_DLSYM_CONST 4867493f84f4Smrg#elif defined __osf__ 48680bb88ba4Smrg/* This system does not cope well with relocations in const data. */ 48690bb88ba4Smrg# define LT_DLSYM_CONST 48700bb88ba4Smrg#else 48710bb88ba4Smrg# define LT_DLSYM_CONST const 48720bb88ba4Smrg#endif 48730bb88ba4Smrg 4874493f84f4Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4875493f84f4Smrg 4876a31a186aSmrg/* External symbol declarations for the compiler. */\ 4877a31a186aSmrg" 4878a31a186aSmrg 4879493f84f4Smrg if test yes = "$dlself"; then 4880493f84f4Smrg func_verbose "generating symbol list for '$output'" 4881a31a186aSmrg 4882a31a186aSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4883a31a186aSmrg 4884a31a186aSmrg # Add our own program objects to the symbol list. 48850bb88ba4Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4886a31a186aSmrg for progfile in $progfiles; do 48870bb88ba4Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4888493f84f4Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 48890bb88ba4Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4890a31a186aSmrg done 4891a31a186aSmrg 4892a31a186aSmrg if test -n "$exclude_expsyms"; then 4893a31a186aSmrg $opt_dry_run || { 4894a31a186aSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4895a31a186aSmrg eval '$MV "$nlist"T "$nlist"' 4896a31a186aSmrg } 4897643b027fSmrg fi 4898a31a186aSmrg 4899a31a186aSmrg if test -n "$export_symbols_regex"; then 4900a31a186aSmrg $opt_dry_run || { 4901a31a186aSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4902a31a186aSmrg eval '$MV "$nlist"T "$nlist"' 4903a31a186aSmrg } 4904a31a186aSmrg fi 4905a31a186aSmrg 4906a31a186aSmrg # Prepare the list of exported symbols 4907a31a186aSmrg if test -z "$export_symbols"; then 4908493f84f4Smrg export_symbols=$output_objdir/$outputname.exp 4909a31a186aSmrg $opt_dry_run || { 4910a31a186aSmrg $RM $export_symbols 4911493f84f4Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4912a31a186aSmrg case $host in 4913a31a186aSmrg *cygwin* | *mingw* | *cegcc* ) 4914a31a186aSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4915a31a186aSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4916a31a186aSmrg ;; 4917a31a186aSmrg esac 4918a31a186aSmrg } 4919643b027fSmrg else 4920a31a186aSmrg $opt_dry_run || { 4921493f84f4Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4922a31a186aSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4923a31a186aSmrg eval '$MV "$nlist"T "$nlist"' 4924a31a186aSmrg case $host in 49250bb88ba4Smrg *cygwin* | *mingw* | *cegcc* ) 4926a31a186aSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4927a31a186aSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4928a31a186aSmrg ;; 4929a31a186aSmrg esac 4930a31a186aSmrg } 4931643b027fSmrg fi 4932a31a186aSmrg fi 4933fe5e51b7Smrg 4934a31a186aSmrg for dlprefile in $dlprefiles; do 4935493f84f4Smrg func_verbose "extracting global C symbols from '$dlprefile'" 4936a31a186aSmrg func_basename "$dlprefile" 4937493f84f4Smrg name=$func_basename_result 49380bb88ba4Smrg case $host in 49390bb88ba4Smrg *cygwin* | *mingw* | *cegcc* ) 49400bb88ba4Smrg # if an import library, we need to obtain dlname 49410bb88ba4Smrg if func_win32_import_lib_p "$dlprefile"; then 49420bb88ba4Smrg func_tr_sh "$dlprefile" 49430bb88ba4Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 4944493f84f4Smrg dlprefile_dlbasename= 49450bb88ba4Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 49460bb88ba4Smrg # Use subshell, to avoid clobbering current variable values 49470bb88ba4Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4948493f84f4Smrg if test -n "$dlprefile_dlname"; then 49490bb88ba4Smrg func_basename "$dlprefile_dlname" 4950493f84f4Smrg dlprefile_dlbasename=$func_basename_result 49510bb88ba4Smrg else 49520bb88ba4Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 49530bb88ba4Smrg $sharedlib_from_linklib_cmd "$dlprefile" 49540bb88ba4Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 49550bb88ba4Smrg fi 49560bb88ba4Smrg fi 49570bb88ba4Smrg $opt_dry_run || { 4958493f84f4Smrg if test -n "$dlprefile_dlbasename"; then 49590bb88ba4Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 49600bb88ba4Smrg else 49610bb88ba4Smrg func_warning "Could not compute DLL name from $name" 49620bb88ba4Smrg eval '$ECHO ": $name " >> "$nlist"' 49630bb88ba4Smrg fi 49640bb88ba4Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49650bb88ba4Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 49660bb88ba4Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 49670bb88ba4Smrg } 49680bb88ba4Smrg else # not an import lib 49690bb88ba4Smrg $opt_dry_run || { 49700bb88ba4Smrg eval '$ECHO ": $name " >> "$nlist"' 49710bb88ba4Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49720bb88ba4Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 49730bb88ba4Smrg } 49740bb88ba4Smrg fi 49750bb88ba4Smrg ;; 49760bb88ba4Smrg *) 49770bb88ba4Smrg $opt_dry_run || { 49780bb88ba4Smrg eval '$ECHO ": $name " >> "$nlist"' 49790bb88ba4Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49800bb88ba4Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 49810bb88ba4Smrg } 49820bb88ba4Smrg ;; 49830bb88ba4Smrg esac 4984a31a186aSmrg done 4985a31a186aSmrg 4986a31a186aSmrg $opt_dry_run || { 4987a31a186aSmrg # Make sure we have at least an empty file. 4988a31a186aSmrg test -f "$nlist" || : > "$nlist" 4989a31a186aSmrg 4990a31a186aSmrg if test -n "$exclude_expsyms"; then 4991a31a186aSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4992a31a186aSmrg $MV "$nlist"T "$nlist" 4993643b027fSmrg fi 4994a31a186aSmrg 4995a31a186aSmrg # Try sorting and uniquifying the output. 4996a31a186aSmrg if $GREP -v "^: " < "$nlist" | 4997a31a186aSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4998a31a186aSmrg sort -k 3 4999a31a186aSmrg else 5000a31a186aSmrg sort +2 5001a31a186aSmrg fi | 5002a31a186aSmrg uniq > "$nlist"S; then 5003a31a186aSmrg : 5004643b027fSmrg else 5005a31a186aSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 5006643b027fSmrg fi 5007fe5e51b7Smrg 5008a31a186aSmrg if test -f "$nlist"S; then 5009a31a186aSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 5010643b027fSmrg else 50110bb88ba4Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 5012643b027fSmrg fi 5013fe5e51b7Smrg 5014493f84f4Smrg func_show_eval '$RM "${nlist}I"' 5015493f84f4Smrg if test -n "$global_symbol_to_import"; then 5016493f84f4Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 5017493f84f4Smrg fi 5018493f84f4Smrg 50190bb88ba4Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5020fe5e51b7Smrg 5021a31a186aSmrg/* The mapping between symbol names and symbols. */ 5022a31a186aSmrgtypedef struct { 5023a31a186aSmrg const char *name; 5024a31a186aSmrg void *address; 5025a31a186aSmrg} lt_dlsymlist; 50260bb88ba4Smrgextern LT_DLSYM_CONST lt_dlsymlist 5027493f84f4Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 5028493f84f4Smrg" 5029493f84f4Smrg 5030493f84f4Smrg if test -s "$nlist"I; then 5031493f84f4Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5032493f84f4Smrgstatic void lt_syminit(void) 5033493f84f4Smrg{ 5034493f84f4Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 5035493f84f4Smrg for (; symbol->name; ++symbol) 5036493f84f4Smrg {" 5037493f84f4Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 5038493f84f4Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5039493f84f4Smrg } 5040493f84f4Smrg}" 5041493f84f4Smrg fi 5042493f84f4Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50430bb88ba4SmrgLT_DLSYM_CONST lt_dlsymlist 5044a31a186aSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 5045493f84f4Smrg{ {\"$my_originator\", (void *) 0}," 5046493f84f4Smrg 5047493f84f4Smrg if test -s "$nlist"I; then 5048493f84f4Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5049493f84f4Smrg {\"@INIT@\", (void *) <_syminit}," 5050493f84f4Smrg fi 5051fe5e51b7Smrg 5052a31a186aSmrg case $need_lib_prefix in 5053a31a186aSmrg no) 5054a31a186aSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 5055a31a186aSmrg ;; 5056a31a186aSmrg *) 5057a31a186aSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 5058a31a186aSmrg ;; 5059a31a186aSmrg esac 50600bb88ba4Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5061a31a186aSmrg {0, (void *) 0} 5062a31a186aSmrg}; 5063eda3803bSmrg 5064a31a186aSmrg/* This works around a problem in FreeBSD linker */ 5065a31a186aSmrg#ifdef FREEBSD_WORKAROUND 5066a31a186aSmrgstatic const void *lt_preloaded_setup() { 5067a31a186aSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 5068a31a186aSmrg} 5069a31a186aSmrg#endif 5070a31a186aSmrg 5071a31a186aSmrg#ifdef __cplusplus 5072a31a186aSmrg} 5073a31a186aSmrg#endif\ 5074a31a186aSmrg" 5075a31a186aSmrg } # !$opt_dry_run 5076a31a186aSmrg 5077a31a186aSmrg pic_flag_for_symtable= 5078a31a186aSmrg case "$compile_command " in 5079a31a186aSmrg *" -static "*) ;; 5080a31a186aSmrg *) 5081a31a186aSmrg case $host in 5082a31a186aSmrg # compiling the symbol table file with pic_flag works around 5083a31a186aSmrg # a FreeBSD bug that causes programs to crash when -lm is 5084a31a186aSmrg # linked before any other PIC object. But we must not use 5085a31a186aSmrg # pic_flag when linking with -static. The problem exists in 5086a31a186aSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 50870bb88ba4Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 5088a31a186aSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 5089a31a186aSmrg *-*-hpux*) 5090a31a186aSmrg pic_flag_for_symtable=" $pic_flag" ;; 5091a31a186aSmrg *) 5092493f84f4Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 5093a31a186aSmrg ;; 5094a31a186aSmrg esac 5095a31a186aSmrg ;; 5096a31a186aSmrg esac 5097a31a186aSmrg symtab_cflags= 5098a31a186aSmrg for arg in $LTCFLAGS; do 5099a31a186aSmrg case $arg in 5100a31a186aSmrg -pie | -fpie | -fPIE) ;; 51010bb88ba4Smrg *) func_append symtab_cflags " $arg" ;; 5102a31a186aSmrg esac 5103a31a186aSmrg done 5104fe5e51b7Smrg 5105a31a186aSmrg # Now compile the dynamic symbol file. 5106a31a186aSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 5107eda3803bSmrg 5108a31a186aSmrg # Clean up the generated files. 5109493f84f4Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 5110fe5e51b7Smrg 5111a31a186aSmrg # Transform the symbol file into the correct name. 5112493f84f4Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 5113a31a186aSmrg case $host in 5114a31a186aSmrg *cygwin* | *mingw* | *cegcc* ) 5115a31a186aSmrg if test -f "$output_objdir/$my_outputname.def"; then 51160bb88ba4Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 51170bb88ba4Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5118a31a186aSmrg else 51190bb88ba4Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51200bb88ba4Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5121643b027fSmrg fi 5122a31a186aSmrg ;; 5123a31a186aSmrg *) 51240bb88ba4Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51250bb88ba4Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5126a31a186aSmrg ;; 5127a31a186aSmrg esac 5128a31a186aSmrg ;; 5129a31a186aSmrg *) 5130493f84f4Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 5131a31a186aSmrg ;; 5132a31a186aSmrg esac 5133a31a186aSmrg else 5134a31a186aSmrg # We keep going just in case the user didn't refer to 5135a31a186aSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 5136a31a186aSmrg # really was required. 5137fe5e51b7Smrg 5138a31a186aSmrg # Nullify the symbol file. 51390bb88ba4Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 51400bb88ba4Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 5141a31a186aSmrg fi 5142a31a186aSmrg} 5143eda3803bSmrg 5144493f84f4Smrg# func_cygming_gnu_implib_p ARG 5145493f84f4Smrg# This predicate returns with zero status (TRUE) if 5146493f84f4Smrg# ARG is a GNU/binutils-style import library. Returns 5147493f84f4Smrg# with nonzero status (FALSE) otherwise. 5148493f84f4Smrgfunc_cygming_gnu_implib_p () 5149493f84f4Smrg{ 5150493f84f4Smrg $debug_cmd 5151493f84f4Smrg 5152493f84f4Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5153493f84f4Smrg 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)$'` 5154493f84f4Smrg test -n "$func_cygming_gnu_implib_tmp" 5155493f84f4Smrg} 5156493f84f4Smrg 5157493f84f4Smrg# func_cygming_ms_implib_p ARG 5158493f84f4Smrg# This predicate returns with zero status (TRUE) if 5159493f84f4Smrg# ARG is an MS-style import library. Returns 5160493f84f4Smrg# with nonzero status (FALSE) otherwise. 5161493f84f4Smrgfunc_cygming_ms_implib_p () 5162493f84f4Smrg{ 5163493f84f4Smrg $debug_cmd 5164493f84f4Smrg 5165493f84f4Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5166493f84f4Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 5167493f84f4Smrg test -n "$func_cygming_ms_implib_tmp" 5168493f84f4Smrg} 5169493f84f4Smrg 5170a31a186aSmrg# func_win32_libid arg 5171a31a186aSmrg# return the library type of file 'arg' 5172a31a186aSmrg# 5173a31a186aSmrg# Need a lot of goo to handle *both* DLLs and import libs 5174a31a186aSmrg# Has to be a shell function in order to 'eat' the argument 5175a31a186aSmrg# that is supplied when $file_magic_command is called. 51760bb88ba4Smrg# Despite the name, also deal with 64 bit binaries. 5177a31a186aSmrgfunc_win32_libid () 5178a31a186aSmrg{ 5179493f84f4Smrg $debug_cmd 5180493f84f4Smrg 5181493f84f4Smrg win32_libid_type=unknown 5182a31a186aSmrg win32_fileres=`file -L $1 2>/dev/null` 5183a31a186aSmrg case $win32_fileres in 5184a31a186aSmrg *ar\ archive\ import\ library*) # definitely import 5185a31a186aSmrg win32_libid_type="x86 archive import" 5186a31a186aSmrg ;; 5187a31a186aSmrg *ar\ archive*) # could be an import, or static 51880bb88ba4Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 5189a31a186aSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 51900bb88ba4Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 5191493f84f4Smrg case $nm_interface in 5192493f84f4Smrg "MS dumpbin") 5193493f84f4Smrg if func_cygming_ms_implib_p "$1" || 5194493f84f4Smrg func_cygming_gnu_implib_p "$1" 5195493f84f4Smrg then 5196493f84f4Smrg win32_nmres=import 5197493f84f4Smrg else 5198493f84f4Smrg win32_nmres= 5199493f84f4Smrg fi 5200493f84f4Smrg ;; 5201493f84f4Smrg *) 5202493f84f4Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5203493f84f4Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 5204493f84f4Smrg $SED -n -e ' 5205a31a186aSmrg 1,100{ 5206a31a186aSmrg / I /{ 5207493f84f4Smrg s|.*|import| 5208a31a186aSmrg p 5209a31a186aSmrg q 5210a31a186aSmrg } 5211a31a186aSmrg }'` 5212493f84f4Smrg ;; 5213493f84f4Smrg esac 5214a31a186aSmrg case $win32_nmres in 5215a31a186aSmrg import*) win32_libid_type="x86 archive import";; 5216a31a186aSmrg *) win32_libid_type="x86 archive static";; 5217a31a186aSmrg esac 5218a31a186aSmrg fi 5219a31a186aSmrg ;; 5220a31a186aSmrg *DLL*) 5221a31a186aSmrg win32_libid_type="x86 DLL" 5222a31a186aSmrg ;; 5223a31a186aSmrg *executable*) # but shell scripts are "executable" too... 5224a31a186aSmrg case $win32_fileres in 5225a31a186aSmrg *MS\ Windows\ PE\ Intel*) 5226a31a186aSmrg win32_libid_type="x86 DLL" 5227a31a186aSmrg ;; 5228a31a186aSmrg esac 5229a31a186aSmrg ;; 5230a31a186aSmrg esac 5231a31a186aSmrg $ECHO "$win32_libid_type" 5232a31a186aSmrg} 5233eda3803bSmrg 52340bb88ba4Smrg# func_cygming_dll_for_implib ARG 52350bb88ba4Smrg# 52360bb88ba4Smrg# Platform-specific function to extract the 52370bb88ba4Smrg# name of the DLL associated with the specified 52380bb88ba4Smrg# import library ARG. 52390bb88ba4Smrg# Invoked by eval'ing the libtool variable 52400bb88ba4Smrg# $sharedlib_from_linklib_cmd 52410bb88ba4Smrg# Result is available in the variable 52420bb88ba4Smrg# $sharedlib_from_linklib_result 52430bb88ba4Smrgfunc_cygming_dll_for_implib () 52440bb88ba4Smrg{ 5245493f84f4Smrg $debug_cmd 5246493f84f4Smrg 52470bb88ba4Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 52480bb88ba4Smrg} 52490bb88ba4Smrg 52500bb88ba4Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 52510bb88ba4Smrg# 52520bb88ba4Smrg# The is the core of a fallback implementation of a 52530bb88ba4Smrg# platform-specific function to extract the name of the 52540bb88ba4Smrg# DLL associated with the specified import library LIBNAME. 52550bb88ba4Smrg# 52560bb88ba4Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 52570bb88ba4Smrg# on the platform and compiler that created the implib. 52580bb88ba4Smrg# 52590bb88ba4Smrg# Echos the name of the DLL associated with the 52600bb88ba4Smrg# specified import library. 52610bb88ba4Smrgfunc_cygming_dll_for_implib_fallback_core () 52620bb88ba4Smrg{ 5263493f84f4Smrg $debug_cmd 5264493f84f4Smrg 52650bb88ba4Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 52660bb88ba4Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 52670bb88ba4Smrg $SED '/^Contents of section '"$match_literal"':/{ 52680bb88ba4Smrg # Place marker at beginning of archive member dllname section 52690bb88ba4Smrg s/.*/====MARK====/ 52700bb88ba4Smrg p 52710bb88ba4Smrg d 52720bb88ba4Smrg } 52730bb88ba4Smrg # These lines can sometimes be longer than 43 characters, but 52740bb88ba4Smrg # are always uninteresting 52750bb88ba4Smrg /:[ ]*file format pe[i]\{,1\}-/d 52760bb88ba4Smrg /^In archive [^:]*:/d 52770bb88ba4Smrg # Ensure marker is printed 52780bb88ba4Smrg /^====MARK====/p 52790bb88ba4Smrg # Remove all lines with less than 43 characters 52800bb88ba4Smrg /^.\{43\}/!d 52810bb88ba4Smrg # From remaining lines, remove first 43 characters 52820bb88ba4Smrg s/^.\{43\}//' | 52830bb88ba4Smrg $SED -n ' 52840bb88ba4Smrg # Join marker and all lines until next marker into a single line 52850bb88ba4Smrg /^====MARK====/ b para 52860bb88ba4Smrg H 52870bb88ba4Smrg $ b para 52880bb88ba4Smrg b 52890bb88ba4Smrg :para 52900bb88ba4Smrg x 52910bb88ba4Smrg s/\n//g 52920bb88ba4Smrg # Remove the marker 52930bb88ba4Smrg s/^====MARK====// 52940bb88ba4Smrg # Remove trailing dots and whitespace 52950bb88ba4Smrg s/[\. \t]*$// 52960bb88ba4Smrg # Print 52970bb88ba4Smrg /./p' | 52980bb88ba4Smrg # we now have a list, one entry per line, of the stringified 52990bb88ba4Smrg # contents of the appropriate section of all members of the 5300493f84f4Smrg # archive that possess that section. Heuristic: eliminate 5301493f84f4Smrg # all those that have a first or second character that is 53020bb88ba4Smrg # a '.' (that is, objdump's representation of an unprintable 53030bb88ba4Smrg # character.) This should work for all archives with less than 53040bb88ba4Smrg # 0x302f exports -- but will fail for DLLs whose name actually 53050bb88ba4Smrg # begins with a literal '.' or a single character followed by 53060bb88ba4Smrg # a '.'. 53070bb88ba4Smrg # 53080bb88ba4Smrg # Of those that remain, print the first one. 53090bb88ba4Smrg $SED -e '/^\./d;/^.\./d;q' 53100bb88ba4Smrg} 53110bb88ba4Smrg 53120bb88ba4Smrg# func_cygming_dll_for_implib_fallback ARG 53130bb88ba4Smrg# Platform-specific function to extract the 53140bb88ba4Smrg# name of the DLL associated with the specified 53150bb88ba4Smrg# import library ARG. 53160bb88ba4Smrg# 53170bb88ba4Smrg# This fallback implementation is for use when $DLLTOOL 53180bb88ba4Smrg# does not support the --identify-strict option. 53190bb88ba4Smrg# Invoked by eval'ing the libtool variable 53200bb88ba4Smrg# $sharedlib_from_linklib_cmd 53210bb88ba4Smrg# Result is available in the variable 53220bb88ba4Smrg# $sharedlib_from_linklib_result 53230bb88ba4Smrgfunc_cygming_dll_for_implib_fallback () 53240bb88ba4Smrg{ 5325493f84f4Smrg $debug_cmd 5326493f84f4Smrg 5327493f84f4Smrg if func_cygming_gnu_implib_p "$1"; then 53280bb88ba4Smrg # binutils import library 53290bb88ba4Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5330493f84f4Smrg elif func_cygming_ms_implib_p "$1"; then 53310bb88ba4Smrg # ms-generated import library 53320bb88ba4Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 53330bb88ba4Smrg else 53340bb88ba4Smrg # unknown 5335493f84f4Smrg sharedlib_from_linklib_result= 53360bb88ba4Smrg fi 53370bb88ba4Smrg} 5338eda3803bSmrg 5339eda3803bSmrg 5340a31a186aSmrg# func_extract_an_archive dir oldlib 5341a31a186aSmrgfunc_extract_an_archive () 5342a31a186aSmrg{ 5343493f84f4Smrg $debug_cmd 5344493f84f4Smrg 5345493f84f4Smrg f_ex_an_ar_dir=$1; shift 5346493f84f4Smrg f_ex_an_ar_oldlib=$1 5347493f84f4Smrg if test yes = "$lock_old_archive_extraction"; then 53480bb88ba4Smrg lockfile=$f_ex_an_ar_oldlib.lock 53490bb88ba4Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 53500bb88ba4Smrg func_echo "Waiting for $lockfile to be removed" 53510bb88ba4Smrg sleep 2 53520bb88ba4Smrg done 53530bb88ba4Smrg fi 53540bb88ba4Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 53550bb88ba4Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 5356493f84f4Smrg if test yes = "$lock_old_archive_extraction"; then 53570bb88ba4Smrg $opt_dry_run || rm -f "$lockfile" 53580bb88ba4Smrg fi 5359a31a186aSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5360a31a186aSmrg : 5361a31a186aSmrg else 5362a31a186aSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5363a31a186aSmrg fi 5364a31a186aSmrg} 5365fe5e51b7Smrg 5366fe5e51b7Smrg 5367a31a186aSmrg# func_extract_archives gentop oldlib ... 5368a31a186aSmrgfunc_extract_archives () 5369a31a186aSmrg{ 5370493f84f4Smrg $debug_cmd 5371493f84f4Smrg 5372493f84f4Smrg my_gentop=$1; shift 5373a31a186aSmrg my_oldlibs=${1+"$@"} 5374493f84f4Smrg my_oldobjs= 5375493f84f4Smrg my_xlib= 5376493f84f4Smrg my_xabs= 5377493f84f4Smrg my_xdir= 5378eda3803bSmrg 5379a31a186aSmrg for my_xlib in $my_oldlibs; do 5380a31a186aSmrg # Extract the objects. 5381a31a186aSmrg case $my_xlib in 5382493f84f4Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5383a31a186aSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 5384a31a186aSmrg esac 5385a31a186aSmrg func_basename "$my_xlib" 5386493f84f4Smrg my_xlib=$func_basename_result 5387a31a186aSmrg my_xlib_u=$my_xlib 5388a31a186aSmrg while :; do 5389a31a186aSmrg case " $extracted_archives " in 5390a31a186aSmrg *" $my_xlib_u "*) 5391a31a186aSmrg func_arith $extracted_serial + 1 5392a31a186aSmrg extracted_serial=$func_arith_result 5393a31a186aSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5394a31a186aSmrg *) break ;; 5395a31a186aSmrg esac 5396a31a186aSmrg done 5397a31a186aSmrg extracted_archives="$extracted_archives $my_xlib_u" 5398493f84f4Smrg my_xdir=$my_gentop/$my_xlib_u 5399eda3803bSmrg 5400a31a186aSmrg func_mkdir_p "$my_xdir" 5401eda3803bSmrg 5402a31a186aSmrg case $host in 5403a31a186aSmrg *-darwin*) 5404a31a186aSmrg func_verbose "Extracting $my_xabs" 5405a31a186aSmrg # Do not bother doing anything if just a dry run 5406a31a186aSmrg $opt_dry_run || { 5407a31a186aSmrg darwin_orig_dir=`pwd` 5408a31a186aSmrg cd $my_xdir || exit $? 5409a31a186aSmrg darwin_archive=$my_xabs 5410a31a186aSmrg darwin_curdir=`pwd` 5411493f84f4Smrg func_basename "$darwin_archive" 5412493f84f4Smrg darwin_base_archive=$func_basename_result 5413a31a186aSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5414a31a186aSmrg if test -n "$darwin_arches"; then 5415a31a186aSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5416a31a186aSmrg darwin_arch= 5417a31a186aSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5418493f84f4Smrg for darwin_arch in $darwin_arches; do 5419493f84f4Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5420493f84f4Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5421493f84f4Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5422493f84f4Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5423a31a186aSmrg cd "$darwin_curdir" 5424493f84f4Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5425a31a186aSmrg done # $darwin_arches 5426a31a186aSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5427493f84f4Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5428a31a186aSmrg darwin_file= 5429a31a186aSmrg darwin_files= 5430a31a186aSmrg for darwin_file in $darwin_filelist; do 54310bb88ba4Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5432a31a186aSmrg $LIPO -create -output "$darwin_file" $darwin_files 5433a31a186aSmrg done # $darwin_filelist 5434a31a186aSmrg $RM -rf unfat-$$ 5435a31a186aSmrg cd "$darwin_orig_dir" 5436643b027fSmrg else 5437a31a186aSmrg cd $darwin_orig_dir 5438a31a186aSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 5439a31a186aSmrg fi # $darwin_arches 5440a31a186aSmrg } # !$opt_dry_run 5441a31a186aSmrg ;; 5442a31a186aSmrg *) 5443a31a186aSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 5444a31a186aSmrg ;; 5445a31a186aSmrg esac 54460bb88ba4Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5447a31a186aSmrg done 5448eda3803bSmrg 5449493f84f4Smrg func_extract_archives_result=$my_oldobjs 5450a31a186aSmrg} 5451fe5e51b7Smrg 5452fe5e51b7Smrg 54530bb88ba4Smrg# func_emit_wrapper [arg=no] 54540bb88ba4Smrg# 54550bb88ba4Smrg# Emit a libtool wrapper script on stdout. 54560bb88ba4Smrg# Don't directly open a file because we may want to 54570bb88ba4Smrg# incorporate the script contents within a cygwin/mingw 54580bb88ba4Smrg# wrapper executable. Must ONLY be called from within 54590bb88ba4Smrg# func_mode_link because it depends on a number of variables 54600bb88ba4Smrg# set therein. 5461a31a186aSmrg# 54620bb88ba4Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 54630bb88ba4Smrg# variable will take. If 'yes', then the emitted script 5464493f84f4Smrg# will assume that the directory where it is stored is 54650bb88ba4Smrg# the $objdir directory. This is a cygwin/mingw-specific 54660bb88ba4Smrg# behavior. 54670bb88ba4Smrgfunc_emit_wrapper () 5468a31a186aSmrg{ 54690bb88ba4Smrg func_emit_wrapper_arg1=${1-no} 5470643b027fSmrg 5471a31a186aSmrg $ECHO "\ 5472a31a186aSmrg#! $SHELL 5473eda3803bSmrg 5474a31a186aSmrg# $output - temporary wrapper script for $objdir/$outputname 5475493f84f4Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5476a31a186aSmrg# 5477a31a186aSmrg# The $output program cannot be directly executed until all the libtool 5478a31a186aSmrg# libraries that it depends on are installed. 5479a31a186aSmrg# 5480a31a186aSmrg# This wrapper script should never be moved out of the build directory. 5481a31a186aSmrg# If it is, it will not operate correctly. 5482fe5e51b7Smrg 5483a31a186aSmrg# Sed substitution that helps us do robust quoting. It backslashifies 5484a31a186aSmrg# metacharacters that are still active within double-quoted strings. 5485a31a186aSmrgsed_quote_subst='$sed_quote_subst' 5486fe5e51b7Smrg 5487a31a186aSmrg# Be Bourne compatible 5488a31a186aSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5489a31a186aSmrg emulate sh 5490a31a186aSmrg NULLCMD=: 5491a31a186aSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5492a31a186aSmrg # is contrary to our usage. Disable this feature. 5493a31a186aSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5494a31a186aSmrg setopt NO_GLOB_SUBST 5495a31a186aSmrgelse 5496a31a186aSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5497a31a186aSmrgfi 5498a31a186aSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5499a31a186aSmrgDUALCASE=1; export DUALCASE # for MKS sh 5500fe5e51b7Smrg 5501a31a186aSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5502a31a186aSmrg# if CDPATH is set. 5503a31a186aSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5504fe5e51b7Smrg 5505a31a186aSmrgrelink_command=\"$relink_command\" 5506fe5e51b7Smrg 5507a31a186aSmrg# This environment variable determines our operation mode. 5508a31a186aSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5509a31a186aSmrg # install mode needs the following variables: 5510a31a186aSmrg generated_by_libtool_version='$macro_version' 5511a31a186aSmrg notinst_deplibs='$notinst_deplibs' 5512a31a186aSmrgelse 5513a31a186aSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5514a31a186aSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 55150bb88ba4Smrg file=\"\$0\"" 55160bb88ba4Smrg 55171e423a8fSmrg func_quote_arg pretty "$ECHO" 55181e423a8fSmrg qECHO=$func_quote_arg_result 55190bb88ba4Smrg $ECHO "\ 55200bb88ba4Smrg 55210bb88ba4Smrg# A function that is used when there is no print builtin or printf. 55220bb88ba4Smrgfunc_fallback_echo () 55230bb88ba4Smrg{ 55240bb88ba4Smrg eval 'cat <<_LTECHO_EOF 55250bb88ba4Smrg\$1 55260bb88ba4Smrg_LTECHO_EOF' 55270bb88ba4Smrg} 55281e423a8fSmrg ECHO=$qECHO 55290bb88ba4Smrg fi 55300bb88ba4Smrg 55310bb88ba4Smrg# Very basic option parsing. These options are (a) specific to 55320bb88ba4Smrg# the libtool wrapper, (b) are identical between the wrapper 5533493f84f4Smrg# /script/ and the wrapper /executable/ that is used only on 55340bb88ba4Smrg# windows platforms, and (c) all begin with the string "--lt-" 5535493f84f4Smrg# (application programs are unlikely to have options that match 55360bb88ba4Smrg# this pattern). 55370bb88ba4Smrg# 55380bb88ba4Smrg# There are only two supported options: --lt-debug and 55390bb88ba4Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 55400bb88ba4Smrg# 55410bb88ba4Smrg# The first argument to this parsing function should be the 55420bb88ba4Smrg# script's $0 value, followed by "$@". 55430bb88ba4Smrglt_option_debug= 55440bb88ba4Smrgfunc_parse_lt_options () 55450bb88ba4Smrg{ 55460bb88ba4Smrg lt_script_arg0=\$0 55470bb88ba4Smrg shift 55480bb88ba4Smrg for lt_opt 55490bb88ba4Smrg do 55500bb88ba4Smrg case \"\$lt_opt\" in 55510bb88ba4Smrg --lt-debug) lt_option_debug=1 ;; 55520bb88ba4Smrg --lt-dump-script) 55530bb88ba4Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 55540bb88ba4Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 55550bb88ba4Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 55560bb88ba4Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 55570bb88ba4Smrg exit 0 55580bb88ba4Smrg ;; 55590bb88ba4Smrg --lt-*) 55600bb88ba4Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 55610bb88ba4Smrg exit 1 55620bb88ba4Smrg ;; 55630bb88ba4Smrg esac 55640bb88ba4Smrg done 55650bb88ba4Smrg 55660bb88ba4Smrg # Print the debug banner immediately: 55670bb88ba4Smrg if test -n \"\$lt_option_debug\"; then 5568493f84f4Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 55690bb88ba4Smrg fi 55700bb88ba4Smrg} 55710bb88ba4Smrg 55720bb88ba4Smrg# Used when --lt-debug. Prints its arguments to stdout 55730bb88ba4Smrg# (redirection is the responsibility of the caller) 55740bb88ba4Smrgfunc_lt_dump_args () 55750bb88ba4Smrg{ 55760bb88ba4Smrg lt_dump_args_N=1; 55770bb88ba4Smrg for lt_arg 55780bb88ba4Smrg do 5579493f84f4Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 55800bb88ba4Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 55810bb88ba4Smrg done 55820bb88ba4Smrg} 55830bb88ba4Smrg 55840bb88ba4Smrg# Core function for launching the target application 55850bb88ba4Smrgfunc_exec_program_core () 55860bb88ba4Smrg{ 5587a31a186aSmrg" 55880bb88ba4Smrg case $host in 55890bb88ba4Smrg # Backslashes separate directories on plain windows 55900bb88ba4Smrg *-*-mingw | *-*-os2* | *-cegcc*) 55910bb88ba4Smrg $ECHO "\ 55920bb88ba4Smrg if test -n \"\$lt_option_debug\"; then 5593493f84f4Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 55940bb88ba4Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 55950bb88ba4Smrg fi 55960bb88ba4Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 55970bb88ba4Smrg" 55980bb88ba4Smrg ;; 55990bb88ba4Smrg 56000bb88ba4Smrg *) 56010bb88ba4Smrg $ECHO "\ 56020bb88ba4Smrg if test -n \"\$lt_option_debug\"; then 5603493f84f4Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 56040bb88ba4Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 56050bb88ba4Smrg fi 56060bb88ba4Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 56070bb88ba4Smrg" 56080bb88ba4Smrg ;; 56090bb88ba4Smrg esac 56100bb88ba4Smrg $ECHO "\ 56110bb88ba4Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 56120bb88ba4Smrg exit 1 56130bb88ba4Smrg} 56140bb88ba4Smrg 56150bb88ba4Smrg# A function to encapsulate launching the target application 56160bb88ba4Smrg# Strips options in the --lt-* namespace from \$@ and 56170bb88ba4Smrg# launches target application with the remaining arguments. 56180bb88ba4Smrgfunc_exec_program () 56190bb88ba4Smrg{ 56200bb88ba4Smrg case \" \$* \" in 56210bb88ba4Smrg *\\ --lt-*) 56220bb88ba4Smrg for lt_wr_arg 56230bb88ba4Smrg do 56240bb88ba4Smrg case \$lt_wr_arg in 56250bb88ba4Smrg --lt-*) ;; 56260bb88ba4Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 56270bb88ba4Smrg esac 56280bb88ba4Smrg shift 56290bb88ba4Smrg done ;; 56300bb88ba4Smrg esac 56310bb88ba4Smrg func_exec_program_core \${1+\"\$@\"} 56320bb88ba4Smrg} 56330bb88ba4Smrg 56340bb88ba4Smrg # Parse options 56350bb88ba4Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5636fe5e51b7Smrg 5637a31a186aSmrg # Find the directory that this script lives in. 56380bb88ba4Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5639a31a186aSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5640fe5e51b7Smrg 5641a31a186aSmrg # Follow symbolic links until we get to the real thisdir. 56420bb88ba4Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5643a31a186aSmrg while test -n \"\$file\"; do 56440bb88ba4Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5645fe5e51b7Smrg 5646a31a186aSmrg # If there was a directory component, then change thisdir. 5647a31a186aSmrg if test \"x\$destdir\" != \"x\$file\"; then 5648a31a186aSmrg case \"\$destdir\" in 5649a31a186aSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5650a31a186aSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5651643b027fSmrg esac 5652a31a186aSmrg fi 5653fe5e51b7Smrg 56540bb88ba4Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 56550bb88ba4Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5656a31a186aSmrg done 5657fe5e51b7Smrg 5658a31a186aSmrg # Usually 'no', except on cygwin/mingw when embedded into 5659a31a186aSmrg # the cwrapper. 56600bb88ba4Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5661a31a186aSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5662a31a186aSmrg # special case for '.' 5663a31a186aSmrg if test \"\$thisdir\" = \".\"; then 5664a31a186aSmrg thisdir=\`pwd\` 5665a31a186aSmrg fi 5666a31a186aSmrg # remove .libs from thisdir 5667a31a186aSmrg case \"\$thisdir\" in 56680bb88ba4Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5669a31a186aSmrg $objdir ) thisdir=. ;; 5670a31a186aSmrg esac 5671a31a186aSmrg fi 5672a31a186aSmrg 5673a31a186aSmrg # Try to get the absolute directory name. 5674a31a186aSmrg absdir=\`cd \"\$thisdir\" && pwd\` 5675a31a186aSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5676a31a186aSmrg" 5677a31a186aSmrg 5678493f84f4Smrg if test yes = "$fast_install"; then 5679a31a186aSmrg $ECHO "\ 5680a31a186aSmrg program=lt-'$outputname'$exeext 5681a31a186aSmrg progdir=\"\$thisdir/$objdir\" 5682a31a186aSmrg 5683a31a186aSmrg if test ! -f \"\$progdir/\$program\" || 5684493f84f4Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5685a31a186aSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5686a31a186aSmrg 5687a31a186aSmrg file=\"\$\$-\$program\" 5688a31a186aSmrg 5689a31a186aSmrg if test ! -d \"\$progdir\"; then 5690a31a186aSmrg $MKDIR \"\$progdir\" 5691a31a186aSmrg else 5692a31a186aSmrg $RM \"\$progdir/\$file\" 5693a31a186aSmrg fi" 5694a31a186aSmrg 5695a31a186aSmrg $ECHO "\ 5696a31a186aSmrg 5697a31a186aSmrg # relink executable if necessary 5698a31a186aSmrg if test -n \"\$relink_command\"; then 5699a31a186aSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5700a31a186aSmrg else 5701493f84f4Smrg \$ECHO \"\$relink_command_output\" >&2 5702a31a186aSmrg $RM \"\$progdir/\$file\" 5703a31a186aSmrg exit 1 5704643b027fSmrg fi 5705a31a186aSmrg fi 5706fe5e51b7Smrg 5707a31a186aSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5708a31a186aSmrg { $RM \"\$progdir/\$program\"; 5709a31a186aSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5710a31a186aSmrg $RM \"\$progdir/\$file\" 5711a31a186aSmrg fi" 5712a31a186aSmrg else 5713a31a186aSmrg $ECHO "\ 5714a31a186aSmrg program='$outputname' 5715a31a186aSmrg progdir=\"\$thisdir/$objdir\" 5716a31a186aSmrg" 5717643b027fSmrg fi 5718fe5e51b7Smrg 5719a31a186aSmrg $ECHO "\ 5720fe5e51b7Smrg 5721a31a186aSmrg if test -f \"\$progdir/\$program\"; then" 5722fe5e51b7Smrg 57230bb88ba4Smrg # fixup the dll searchpath if we need to. 57240bb88ba4Smrg # 57250bb88ba4Smrg # Fix the DLL searchpath if we need to. Do this before prepending 57260bb88ba4Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 57270bb88ba4Smrg # libraries must come first. 57280bb88ba4Smrg if test -n "$dllsearchpath"; then 57290bb88ba4Smrg $ECHO "\ 57300bb88ba4Smrg # Add the dll search path components to the executable PATH 57310bb88ba4Smrg PATH=$dllsearchpath:\$PATH 57320bb88ba4Smrg" 57330bb88ba4Smrg fi 57340bb88ba4Smrg 5735a31a186aSmrg # Export our shlibpath_var if we have one. 5736493f84f4Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5737a31a186aSmrg $ECHO "\ 5738a31a186aSmrg # Add our own library path to $shlibpath_var 5739a31a186aSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5740a31a186aSmrg 5741a31a186aSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 5742a31a186aSmrg # The second colon is a workaround for a bug in BeOS R4 sed 57430bb88ba4Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5744fe5e51b7Smrg 5745a31a186aSmrg export $shlibpath_var 5746a31a186aSmrg" 5747643b027fSmrg fi 5748fe5e51b7Smrg 5749a31a186aSmrg $ECHO "\ 5750a31a186aSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5751a31a186aSmrg # Run the actual program with our arguments. 57520bb88ba4Smrg func_exec_program \${1+\"\$@\"} 5753a31a186aSmrg fi 5754a31a186aSmrg else 5755a31a186aSmrg # The program doesn't exist. 5756493f84f4Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5757a31a186aSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 57580bb88ba4Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5759a31a186aSmrg exit 1 5760a31a186aSmrg fi 5761a31a186aSmrgfi\ 5762a31a186aSmrg" 5763a31a186aSmrg} 5764fe5e51b7Smrg 5765fe5e51b7Smrg 5766a31a186aSmrg# func_emit_cwrapperexe_src 5767a31a186aSmrg# emit the source code for a wrapper executable on stdout 5768a31a186aSmrg# Must ONLY be called from within func_mode_link because 5769a31a186aSmrg# it depends on a number of variable set therein. 5770a31a186aSmrgfunc_emit_cwrapperexe_src () 5771a31a186aSmrg{ 5772a31a186aSmrg cat <<EOF 5773fe5e51b7Smrg 5774a31a186aSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5775493f84f4Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5776fe5e51b7Smrg 5777a31a186aSmrg The $output program cannot be directly executed until all the libtool 5778a31a186aSmrg libraries that it depends on are installed. 5779fe5e51b7Smrg 5780a31a186aSmrg This wrapper executable should never be moved out of the build directory. 5781a31a186aSmrg If it is, it will not operate correctly. 5782a31a186aSmrg*/ 5783a31a186aSmrgEOF 5784a31a186aSmrg cat <<"EOF" 57850bb88ba4Smrg#ifdef _MSC_VER 57860bb88ba4Smrg# define _CRT_SECURE_NO_DEPRECATE 1 57870bb88ba4Smrg#endif 5788a31a186aSmrg#include <stdio.h> 5789a31a186aSmrg#include <stdlib.h> 5790a31a186aSmrg#ifdef _MSC_VER 5791a31a186aSmrg# include <direct.h> 5792a31a186aSmrg# include <process.h> 5793a31a186aSmrg# include <io.h> 5794a31a186aSmrg#else 5795a31a186aSmrg# include <unistd.h> 5796a31a186aSmrg# include <stdint.h> 5797a31a186aSmrg# ifdef __CYGWIN__ 5798a31a186aSmrg# include <io.h> 5799a31a186aSmrg# endif 5800a31a186aSmrg#endif 5801a31a186aSmrg#include <malloc.h> 5802a31a186aSmrg#include <stdarg.h> 5803a31a186aSmrg#include <assert.h> 5804a31a186aSmrg#include <string.h> 5805a31a186aSmrg#include <ctype.h> 5806a31a186aSmrg#include <errno.h> 5807a31a186aSmrg#include <fcntl.h> 5808a31a186aSmrg#include <sys/stat.h> 5809eda3803bSmrg 5810493f84f4Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5811493f84f4Smrg 58120bb88ba4Smrg/* declarations of non-ANSI functions */ 5813493f84f4Smrg#if defined __MINGW32__ 58140bb88ba4Smrg# ifdef __STRICT_ANSI__ 58150bb88ba4Smrgint _putenv (const char *); 58160bb88ba4Smrg# endif 5817493f84f4Smrg#elif defined __CYGWIN__ 58180bb88ba4Smrg# ifdef __STRICT_ANSI__ 58190bb88ba4Smrgchar *realpath (const char *, char *); 58200bb88ba4Smrgint putenv (char *); 58210bb88ba4Smrgint setenv (const char *, const char *, int); 58220bb88ba4Smrg# endif 5823493f84f4Smrg/* #elif defined other_platform || defined ... */ 58240bb88ba4Smrg#endif 58250bb88ba4Smrg 58260bb88ba4Smrg/* portability defines, excluding path handling macros */ 5827493f84f4Smrg#if defined _MSC_VER 58280bb88ba4Smrg# define setmode _setmode 58290bb88ba4Smrg# define stat _stat 58300bb88ba4Smrg# define chmod _chmod 58310bb88ba4Smrg# define getcwd _getcwd 58320bb88ba4Smrg# define putenv _putenv 58330bb88ba4Smrg# define S_IXUSR _S_IEXEC 5834493f84f4Smrg#elif defined __MINGW32__ 58350bb88ba4Smrg# define setmode _setmode 58360bb88ba4Smrg# define stat _stat 58370bb88ba4Smrg# define chmod _chmod 58380bb88ba4Smrg# define getcwd _getcwd 58390bb88ba4Smrg# define putenv _putenv 5840493f84f4Smrg#elif defined __CYGWIN__ 58410bb88ba4Smrg# define HAVE_SETENV 58420bb88ba4Smrg# define FOPEN_WB "wb" 5843493f84f4Smrg/* #elif defined other platforms ... */ 58440bb88ba4Smrg#endif 58450bb88ba4Smrg 5846493f84f4Smrg#if defined PATH_MAX 5847a31a186aSmrg# define LT_PATHMAX PATH_MAX 5848493f84f4Smrg#elif defined MAXPATHLEN 5849a31a186aSmrg# define LT_PATHMAX MAXPATHLEN 5850a31a186aSmrg#else 5851a31a186aSmrg# define LT_PATHMAX 1024 5852a31a186aSmrg#endif 5853eda3803bSmrg 5854a31a186aSmrg#ifndef S_IXOTH 5855a31a186aSmrg# define S_IXOTH 0 5856a31a186aSmrg#endif 5857a31a186aSmrg#ifndef S_IXGRP 5858a31a186aSmrg# define S_IXGRP 0 5859a31a186aSmrg#endif 5860eda3803bSmrg 58610bb88ba4Smrg/* path handling portability macros */ 5862a31a186aSmrg#ifndef DIR_SEPARATOR 5863a31a186aSmrg# define DIR_SEPARATOR '/' 5864a31a186aSmrg# define PATH_SEPARATOR ':' 5865a31a186aSmrg#endif 5866eda3803bSmrg 5867493f84f4Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5868493f84f4Smrg defined __OS2__ 5869a31a186aSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 5870a31a186aSmrg# define FOPEN_WB "wb" 5871a31a186aSmrg# ifndef DIR_SEPARATOR_2 5872a31a186aSmrg# define DIR_SEPARATOR_2 '\\' 5873a31a186aSmrg# endif 5874a31a186aSmrg# ifndef PATH_SEPARATOR_2 5875a31a186aSmrg# define PATH_SEPARATOR_2 ';' 5876a31a186aSmrg# endif 5877a31a186aSmrg#endif 5878eda3803bSmrg 5879a31a186aSmrg#ifndef DIR_SEPARATOR_2 5880a31a186aSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5881a31a186aSmrg#else /* DIR_SEPARATOR_2 */ 5882a31a186aSmrg# define IS_DIR_SEPARATOR(ch) \ 5883a31a186aSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5884a31a186aSmrg#endif /* DIR_SEPARATOR_2 */ 5885fe5e51b7Smrg 5886a31a186aSmrg#ifndef PATH_SEPARATOR_2 5887a31a186aSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5888a31a186aSmrg#else /* PATH_SEPARATOR_2 */ 5889a31a186aSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5890a31a186aSmrg#endif /* PATH_SEPARATOR_2 */ 5891fe5e51b7Smrg 5892a31a186aSmrg#ifndef FOPEN_WB 5893a31a186aSmrg# define FOPEN_WB "w" 5894a31a186aSmrg#endif 5895a31a186aSmrg#ifndef _O_BINARY 5896a31a186aSmrg# define _O_BINARY 0 5897a31a186aSmrg#endif 5898fe5e51b7Smrg 5899a31a186aSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5900a31a186aSmrg#define XFREE(stale) do { \ 5901493f84f4Smrg if (stale) { free (stale); stale = 0; } \ 5902a31a186aSmrg} while (0) 5903fe5e51b7Smrg 5904493f84f4Smrg#if defined LT_DEBUGWRAPPER 59050bb88ba4Smrgstatic int lt_debug = 1; 5906a31a186aSmrg#else 59070bb88ba4Smrgstatic int lt_debug = 0; 5908a31a186aSmrg#endif 5909fe5e51b7Smrg 59100bb88ba4Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5911fe5e51b7Smrg 5912a31a186aSmrgvoid *xmalloc (size_t num); 5913a31a186aSmrgchar *xstrdup (const char *string); 5914a31a186aSmrgconst char *base_name (const char *name); 5915a31a186aSmrgchar *find_executable (const char *wrapper); 5916a31a186aSmrgchar *chase_symlinks (const char *pathspec); 5917a31a186aSmrgint make_executable (const char *path); 5918a31a186aSmrgint check_executable (const char *path); 5919a31a186aSmrgchar *strendzap (char *str, const char *pat); 59200bb88ba4Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 59210bb88ba4Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 59220bb88ba4Smrgstatic const char *nonnull (const char *s); 59230bb88ba4Smrgstatic const char *nonempty (const char *s); 5924a31a186aSmrgvoid lt_setenv (const char *name, const char *value); 5925a31a186aSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5926a31a186aSmrgvoid lt_update_exe_path (const char *name, const char *value); 5927a31a186aSmrgvoid lt_update_lib_path (const char *name, const char *value); 59280bb88ba4Smrgchar **prepare_spawn (char **argv); 59290bb88ba4Smrgvoid lt_dump_script (FILE *f); 5930a31a186aSmrgEOF 5931a31a186aSmrg 5932a31a186aSmrg cat <<EOF 5933493f84f4Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5934493f84f4Smrg# define externally_visible volatile 5935493f84f4Smrg#else 5936493f84f4Smrg# define externally_visible __attribute__((externally_visible)) volatile 5937493f84f4Smrg#endif 5938493f84f4Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5939a31a186aSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5940a31a186aSmrgEOF 5941fe5e51b7Smrg 5942493f84f4Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 59430bb88ba4Smrg func_to_host_path "$temp_rpath" 5944a31a186aSmrg cat <<EOF 59450bb88ba4Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5946a31a186aSmrgEOF 5947a31a186aSmrg else 5948a31a186aSmrg cat <<"EOF" 5949a31a186aSmrgconst char * LIB_PATH_VALUE = ""; 5950a31a186aSmrgEOF 5951643b027fSmrg fi 5952fe5e51b7Smrg 5953a31a186aSmrg if test -n "$dllsearchpath"; then 59540bb88ba4Smrg func_to_host_path "$dllsearchpath:" 5955a31a186aSmrg cat <<EOF 5956a31a186aSmrgconst char * EXE_PATH_VARNAME = "PATH"; 59570bb88ba4Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5958643b027fSmrgEOF 5959643b027fSmrg else 5960a31a186aSmrg cat <<"EOF" 5961a31a186aSmrgconst char * EXE_PATH_VARNAME = ""; 5962a31a186aSmrgconst char * EXE_PATH_VALUE = ""; 5963a31a186aSmrgEOF 5964643b027fSmrg fi 5965a31a186aSmrg 5966493f84f4Smrg if test yes = "$fast_install"; then 5967a31a186aSmrg cat <<EOF 5968a31a186aSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5969a31a186aSmrgEOF 5970643b027fSmrg else 5971a31a186aSmrg cat <<EOF 5972a31a186aSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5973a31a186aSmrgEOF 5974643b027fSmrg fi 5975fe5e51b7Smrg 5976fe5e51b7Smrg 5977a31a186aSmrg cat <<"EOF" 5978fe5e51b7Smrg 5979a31a186aSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5980fe5e51b7Smrg 5981a31a186aSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5982a31a186aSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 59830bb88ba4Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5984fe5e51b7Smrg 5985a31a186aSmrgint 5986a31a186aSmrgmain (int argc, char *argv[]) 5987a31a186aSmrg{ 5988a31a186aSmrg char **newargz; 5989a31a186aSmrg int newargc; 5990a31a186aSmrg char *tmp_pathspec; 5991a31a186aSmrg char *actual_cwrapper_path; 5992a31a186aSmrg char *actual_cwrapper_name; 5993a31a186aSmrg char *target_name; 5994a31a186aSmrg char *lt_argv_zero; 5995493f84f4Smrg int rval = 127; 5996fe5e51b7Smrg 5997a31a186aSmrg int i; 5998fe5e51b7Smrg 5999a31a186aSmrg program_name = (char *) xstrdup (base_name (argv[0])); 6000493f84f4Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 6001fe5e51b7Smrg 60020bb88ba4Smrg /* very simple arg parsing; don't want to rely on getopt 60030bb88ba4Smrg * also, copy all non cwrapper options to newargz, except 60040bb88ba4Smrg * argz[0], which is handled differently 60050bb88ba4Smrg */ 60060bb88ba4Smrg newargc=0; 6007a31a186aSmrg for (i = 1; i < argc; i++) 6008a31a186aSmrg { 6009493f84f4Smrg if (STREQ (argv[i], dumpscript_opt)) 6010a31a186aSmrg { 6011a31a186aSmrgEOF 6012493f84f4Smrg case $host in 6013a31a186aSmrg *mingw* | *cygwin* ) 6014a31a186aSmrg # make stdout use "unix" line endings 6015a31a186aSmrg echo " setmode(1,_O_BINARY);" 6016a31a186aSmrg ;; 6017a31a186aSmrg esac 6018fe5e51b7Smrg 6019a31a186aSmrg cat <<"EOF" 60200bb88ba4Smrg lt_dump_script (stdout); 6021a31a186aSmrg return 0; 6022a31a186aSmrg } 6023493f84f4Smrg if (STREQ (argv[i], debug_opt)) 60240bb88ba4Smrg { 60250bb88ba4Smrg lt_debug = 1; 60260bb88ba4Smrg continue; 60270bb88ba4Smrg } 6028493f84f4Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 60290bb88ba4Smrg { 60300bb88ba4Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 60310bb88ba4Smrg namespace, but it is not one of the ones we know about and 60320bb88ba4Smrg have already dealt with, above (inluding dump-script), then 60330bb88ba4Smrg report an error. Otherwise, targets might begin to believe 60340bb88ba4Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 60350bb88ba4Smrg namespace. The first time any user complains about this, we'll 60360bb88ba4Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 60370bb88ba4Smrg or a configure.ac-settable value. 60380bb88ba4Smrg */ 60390bb88ba4Smrg lt_fatal (__FILE__, __LINE__, 60400bb88ba4Smrg "unrecognized %s option: '%s'", 60410bb88ba4Smrg ltwrapper_option_prefix, argv[i]); 60420bb88ba4Smrg } 60430bb88ba4Smrg /* otherwise ... */ 60440bb88ba4Smrg newargz[++newargc] = xstrdup (argv[i]); 6045a31a186aSmrg } 60460bb88ba4Smrg newargz[++newargc] = NULL; 60470bb88ba4Smrg 60480bb88ba4SmrgEOF 60490bb88ba4Smrg cat <<EOF 60500bb88ba4Smrg /* The GNU banner must be the first non-error debug message */ 6051493f84f4Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 60520bb88ba4SmrgEOF 60530bb88ba4Smrg cat <<"EOF" 60540bb88ba4Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 60550bb88ba4Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 6056fe5e51b7Smrg 6057a31a186aSmrg tmp_pathspec = find_executable (argv[0]); 6058a31a186aSmrg if (tmp_pathspec == NULL) 60590bb88ba4Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 60600bb88ba4Smrg lt_debugprintf (__FILE__, __LINE__, 60610bb88ba4Smrg "(main) found exe (before symlink chase) at: %s\n", 60620bb88ba4Smrg tmp_pathspec); 6063a31a186aSmrg 6064a31a186aSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 60650bb88ba4Smrg lt_debugprintf (__FILE__, __LINE__, 60660bb88ba4Smrg "(main) found exe (after symlink chase) at: %s\n", 60670bb88ba4Smrg actual_cwrapper_path); 6068a31a186aSmrg XFREE (tmp_pathspec); 6069a31a186aSmrg 60700bb88ba4Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 6071a31a186aSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 6072a31a186aSmrg 6073a31a186aSmrg /* wrapper name transforms */ 6074a31a186aSmrg strendzap (actual_cwrapper_name, ".exe"); 6075a31a186aSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 6076a31a186aSmrg XFREE (actual_cwrapper_name); 6077a31a186aSmrg actual_cwrapper_name = tmp_pathspec; 6078a31a186aSmrg tmp_pathspec = 0; 6079a31a186aSmrg 6080a31a186aSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 6081a31a186aSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 6082a31a186aSmrg strendzap (target_name, ".exe"); 6083a31a186aSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 6084a31a186aSmrg XFREE (target_name); 6085a31a186aSmrg target_name = tmp_pathspec; 6086a31a186aSmrg tmp_pathspec = 0; 6087a31a186aSmrg 60880bb88ba4Smrg lt_debugprintf (__FILE__, __LINE__, 60890bb88ba4Smrg "(main) libtool target name: %s\n", 60900bb88ba4Smrg target_name); 6091a31a186aSmrgEOF 6092fe5e51b7Smrg 6093a31a186aSmrg cat <<EOF 6094a31a186aSmrg newargz[0] = 6095a31a186aSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 6096a31a186aSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 6097a31a186aSmrg strcpy (newargz[0], actual_cwrapper_path); 6098a31a186aSmrg strcat (newargz[0], "$objdir"); 6099a31a186aSmrg strcat (newargz[0], "/"); 6100a31a186aSmrgEOF 6101fe5e51b7Smrg 6102a31a186aSmrg cat <<"EOF" 6103a31a186aSmrg /* stop here, and copy so we don't have to do this twice */ 6104a31a186aSmrg tmp_pathspec = xstrdup (newargz[0]); 6105fe5e51b7Smrg 6106a31a186aSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 6107a31a186aSmrg strcat (newargz[0], actual_cwrapper_name); 6108fe5e51b7Smrg 6109a31a186aSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 6110a31a186aSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 6111a31a186aSmrg XFREE (tmp_pathspec); 6112a31a186aSmrg tmp_pathspec = NULL; 6113a31a186aSmrgEOF 6114fe5e51b7Smrg 6115a31a186aSmrg case $host_os in 6116a31a186aSmrg mingw*) 6117a31a186aSmrg cat <<"EOF" 6118a31a186aSmrg { 6119a31a186aSmrg char* p; 6120a31a186aSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 6121a31a186aSmrg { 6122a31a186aSmrg *p = '/'; 6123a31a186aSmrg } 6124a31a186aSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 6125a31a186aSmrg { 6126a31a186aSmrg *p = '/'; 6127a31a186aSmrg } 6128a31a186aSmrg } 6129a31a186aSmrgEOF 6130a31a186aSmrg ;; 6131a31a186aSmrg esac 6132fe5e51b7Smrg 6133a31a186aSmrg cat <<"EOF" 6134a31a186aSmrg XFREE (target_name); 6135a31a186aSmrg XFREE (actual_cwrapper_path); 6136a31a186aSmrg XFREE (actual_cwrapper_name); 6137fe5e51b7Smrg 6138a31a186aSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 6139a31a186aSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 61400bb88ba4Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 61410bb88ba4Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 61420bb88ba4Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 61430bb88ba4Smrg libraries must come first. */ 6144a31a186aSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 61450bb88ba4Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 6146fe5e51b7Smrg 61470bb88ba4Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 61480bb88ba4Smrg nonnull (lt_argv_zero)); 6149a31a186aSmrg for (i = 0; i < newargc; i++) 6150a31a186aSmrg { 61510bb88ba4Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 61520bb88ba4Smrg i, nonnull (newargz[i])); 6153a31a186aSmrg } 6154fe5e51b7Smrg 6155a31a186aSmrgEOF 6156fe5e51b7Smrg 6157a31a186aSmrg case $host_os in 6158a31a186aSmrg mingw*) 6159a31a186aSmrg cat <<"EOF" 6160a31a186aSmrg /* execv doesn't actually work on mingw as expected on unix */ 61610bb88ba4Smrg newargz = prepare_spawn (newargz); 6162493f84f4Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 6163a31a186aSmrg if (rval == -1) 6164a31a186aSmrg { 6165a31a186aSmrg /* failed to start process */ 61660bb88ba4Smrg lt_debugprintf (__FILE__, __LINE__, 61670bb88ba4Smrg "(main) failed to launch target \"%s\": %s\n", 61680bb88ba4Smrg lt_argv_zero, nonnull (strerror (errno))); 6169a31a186aSmrg return 127; 6170a31a186aSmrg } 6171a31a186aSmrg return rval; 6172a31a186aSmrgEOF 6173a31a186aSmrg ;; 6174a31a186aSmrg *) 6175a31a186aSmrg cat <<"EOF" 6176a31a186aSmrg execv (lt_argv_zero, newargz); 6177a31a186aSmrg return rval; /* =127, but avoids unused variable warning */ 6178a31a186aSmrgEOF 6179a31a186aSmrg ;; 6180a31a186aSmrg esac 6181fe5e51b7Smrg 6182a31a186aSmrg cat <<"EOF" 6183a31a186aSmrg} 6184fe5e51b7Smrg 6185a31a186aSmrgvoid * 6186a31a186aSmrgxmalloc (size_t num) 6187a31a186aSmrg{ 6188a31a186aSmrg void *p = (void *) malloc (num); 6189a31a186aSmrg if (!p) 61900bb88ba4Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 6191fe5e51b7Smrg 6192a31a186aSmrg return p; 6193a31a186aSmrg} 6194fe5e51b7Smrg 6195a31a186aSmrgchar * 6196a31a186aSmrgxstrdup (const char *string) 6197a31a186aSmrg{ 6198a31a186aSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 6199a31a186aSmrg string) : NULL; 6200a31a186aSmrg} 6201fe5e51b7Smrg 6202a31a186aSmrgconst char * 6203a31a186aSmrgbase_name (const char *name) 6204a31a186aSmrg{ 6205a31a186aSmrg const char *base; 6206643b027fSmrg 6207493f84f4Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6208a31a186aSmrg /* Skip over the disk name in MSDOS pathnames. */ 6209a31a186aSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 6210a31a186aSmrg name += 2; 6211a31a186aSmrg#endif 6212643b027fSmrg 6213a31a186aSmrg for (base = name; *name; name++) 6214a31a186aSmrg if (IS_DIR_SEPARATOR (*name)) 6215a31a186aSmrg base = name + 1; 6216a31a186aSmrg return base; 6217a31a186aSmrg} 6218643b027fSmrg 6219a31a186aSmrgint 6220a31a186aSmrgcheck_executable (const char *path) 6221a31a186aSmrg{ 6222a31a186aSmrg struct stat st; 6223643b027fSmrg 62240bb88ba4Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 62250bb88ba4Smrg nonempty (path)); 6226a31a186aSmrg if ((!path) || (!*path)) 6227a31a186aSmrg return 0; 6228643b027fSmrg 6229a31a186aSmrg if ((stat (path, &st) >= 0) 6230a31a186aSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 6231a31a186aSmrg return 1; 6232a31a186aSmrg else 6233a31a186aSmrg return 0; 6234a31a186aSmrg} 6235fe5e51b7Smrg 6236a31a186aSmrgint 6237a31a186aSmrgmake_executable (const char *path) 6238a31a186aSmrg{ 6239a31a186aSmrg int rval = 0; 6240a31a186aSmrg struct stat st; 6241fe5e51b7Smrg 62420bb88ba4Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 62430bb88ba4Smrg nonempty (path)); 6244a31a186aSmrg if ((!path) || (!*path)) 6245a31a186aSmrg return 0; 6246fe5e51b7Smrg 6247a31a186aSmrg if (stat (path, &st) >= 0) 6248a31a186aSmrg { 6249a31a186aSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 6250a31a186aSmrg } 6251a31a186aSmrg return rval; 6252a31a186aSmrg} 6253643b027fSmrg 6254a31a186aSmrg/* Searches for the full path of the wrapper. Returns 6255a31a186aSmrg newly allocated full path name if found, NULL otherwise 6256a31a186aSmrg Does not chase symlinks, even on platforms that support them. 6257a31a186aSmrg*/ 6258a31a186aSmrgchar * 6259a31a186aSmrgfind_executable (const char *wrapper) 6260a31a186aSmrg{ 6261a31a186aSmrg int has_slash = 0; 6262a31a186aSmrg const char *p; 6263a31a186aSmrg const char *p_next; 6264a31a186aSmrg /* static buffer for getcwd */ 6265a31a186aSmrg char tmp[LT_PATHMAX + 1]; 6266493f84f4Smrg size_t tmp_len; 6267a31a186aSmrg char *concat_name; 6268643b027fSmrg 62690bb88ba4Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 62700bb88ba4Smrg nonempty (wrapper)); 6271643b027fSmrg 6272a31a186aSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 6273a31a186aSmrg return NULL; 6274643b027fSmrg 6275a31a186aSmrg /* Absolute path? */ 6276493f84f4Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6277a31a186aSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6278a31a186aSmrg { 6279a31a186aSmrg concat_name = xstrdup (wrapper); 6280a31a186aSmrg if (check_executable (concat_name)) 6281a31a186aSmrg return concat_name; 6282a31a186aSmrg XFREE (concat_name); 6283a31a186aSmrg } 6284a31a186aSmrg else 6285a31a186aSmrg { 6286a31a186aSmrg#endif 6287a31a186aSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 6288a31a186aSmrg { 6289a31a186aSmrg concat_name = xstrdup (wrapper); 6290a31a186aSmrg if (check_executable (concat_name)) 6291a31a186aSmrg return concat_name; 6292a31a186aSmrg XFREE (concat_name); 6293a31a186aSmrg } 6294493f84f4Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6295a31a186aSmrg } 6296a31a186aSmrg#endif 6297fe5e51b7Smrg 6298a31a186aSmrg for (p = wrapper; *p; p++) 6299a31a186aSmrg if (*p == '/') 6300a31a186aSmrg { 6301a31a186aSmrg has_slash = 1; 6302a31a186aSmrg break; 6303a31a186aSmrg } 6304a31a186aSmrg if (!has_slash) 6305a31a186aSmrg { 6306a31a186aSmrg /* no slashes; search PATH */ 6307a31a186aSmrg const char *path = getenv ("PATH"); 6308a31a186aSmrg if (path != NULL) 6309a31a186aSmrg { 6310a31a186aSmrg for (p = path; *p; p = p_next) 6311a31a186aSmrg { 6312a31a186aSmrg const char *q; 6313a31a186aSmrg size_t p_len; 6314a31a186aSmrg for (q = p; *q; q++) 6315a31a186aSmrg if (IS_PATH_SEPARATOR (*q)) 6316a31a186aSmrg break; 6317493f84f4Smrg p_len = (size_t) (q - p); 6318a31a186aSmrg p_next = (*q == '\0' ? q : q + 1); 6319a31a186aSmrg if (p_len == 0) 6320a31a186aSmrg { 6321a31a186aSmrg /* empty path: current directory */ 6322a31a186aSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 63230bb88ba4Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 63240bb88ba4Smrg nonnull (strerror (errno))); 6325a31a186aSmrg tmp_len = strlen (tmp); 6326a31a186aSmrg concat_name = 6327a31a186aSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6328a31a186aSmrg memcpy (concat_name, tmp, tmp_len); 6329a31a186aSmrg concat_name[tmp_len] = '/'; 6330a31a186aSmrg strcpy (concat_name + tmp_len + 1, wrapper); 6331a31a186aSmrg } 6332a31a186aSmrg else 6333a31a186aSmrg { 6334a31a186aSmrg concat_name = 6335a31a186aSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6336a31a186aSmrg memcpy (concat_name, p, p_len); 6337a31a186aSmrg concat_name[p_len] = '/'; 6338a31a186aSmrg strcpy (concat_name + p_len + 1, wrapper); 6339a31a186aSmrg } 6340a31a186aSmrg if (check_executable (concat_name)) 6341a31a186aSmrg return concat_name; 6342a31a186aSmrg XFREE (concat_name); 6343a31a186aSmrg } 6344a31a186aSmrg } 6345a31a186aSmrg /* not found in PATH; assume curdir */ 6346a31a186aSmrg } 6347a31a186aSmrg /* Relative path | not found in path: prepend cwd */ 6348a31a186aSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 63490bb88ba4Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 63500bb88ba4Smrg nonnull (strerror (errno))); 6351a31a186aSmrg tmp_len = strlen (tmp); 6352a31a186aSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6353a31a186aSmrg memcpy (concat_name, tmp, tmp_len); 6354a31a186aSmrg concat_name[tmp_len] = '/'; 6355a31a186aSmrg strcpy (concat_name + tmp_len + 1, wrapper); 6356fe5e51b7Smrg 6357a31a186aSmrg if (check_executable (concat_name)) 6358a31a186aSmrg return concat_name; 6359a31a186aSmrg XFREE (concat_name); 6360a31a186aSmrg return NULL; 6361a31a186aSmrg} 6362fe5e51b7Smrg 6363a31a186aSmrgchar * 6364a31a186aSmrgchase_symlinks (const char *pathspec) 6365a31a186aSmrg{ 6366a31a186aSmrg#ifndef S_ISLNK 6367a31a186aSmrg return xstrdup (pathspec); 6368a31a186aSmrg#else 6369a31a186aSmrg char buf[LT_PATHMAX]; 6370a31a186aSmrg struct stat s; 6371a31a186aSmrg char *tmp_pathspec = xstrdup (pathspec); 6372a31a186aSmrg char *p; 6373a31a186aSmrg int has_symlinks = 0; 6374a31a186aSmrg while (strlen (tmp_pathspec) && !has_symlinks) 6375a31a186aSmrg { 63760bb88ba4Smrg lt_debugprintf (__FILE__, __LINE__, 63770bb88ba4Smrg "checking path component for symlinks: %s\n", 63780bb88ba4Smrg tmp_pathspec); 6379a31a186aSmrg if (lstat (tmp_pathspec, &s) == 0) 6380a31a186aSmrg { 6381a31a186aSmrg if (S_ISLNK (s.st_mode) != 0) 6382a31a186aSmrg { 6383a31a186aSmrg has_symlinks = 1; 6384a31a186aSmrg break; 6385a31a186aSmrg } 6386fe5e51b7Smrg 6387a31a186aSmrg /* search backwards for last DIR_SEPARATOR */ 6388a31a186aSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6389a31a186aSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6390a31a186aSmrg p--; 6391a31a186aSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6392a31a186aSmrg { 6393a31a186aSmrg /* no more DIR_SEPARATORS left */ 6394a31a186aSmrg break; 6395a31a186aSmrg } 6396a31a186aSmrg *p = '\0'; 6397a31a186aSmrg } 6398a31a186aSmrg else 6399a31a186aSmrg { 64000bb88ba4Smrg lt_fatal (__FILE__, __LINE__, 64010bb88ba4Smrg "error accessing file \"%s\": %s", 64020bb88ba4Smrg tmp_pathspec, nonnull (strerror (errno))); 6403a31a186aSmrg } 6404a31a186aSmrg } 6405a31a186aSmrg XFREE (tmp_pathspec); 6406fe5e51b7Smrg 6407a31a186aSmrg if (!has_symlinks) 6408a31a186aSmrg { 6409a31a186aSmrg return xstrdup (pathspec); 6410a31a186aSmrg } 6411fe5e51b7Smrg 6412a31a186aSmrg tmp_pathspec = realpath (pathspec, buf); 6413a31a186aSmrg if (tmp_pathspec == 0) 6414a31a186aSmrg { 64150bb88ba4Smrg lt_fatal (__FILE__, __LINE__, 64160bb88ba4Smrg "could not follow symlinks for %s", pathspec); 6417a31a186aSmrg } 6418a31a186aSmrg return xstrdup (tmp_pathspec); 6419a31a186aSmrg#endif 6420a31a186aSmrg} 6421fe5e51b7Smrg 6422a31a186aSmrgchar * 6423a31a186aSmrgstrendzap (char *str, const char *pat) 6424a31a186aSmrg{ 6425a31a186aSmrg size_t len, patlen; 6426fe5e51b7Smrg 6427a31a186aSmrg assert (str != NULL); 6428a31a186aSmrg assert (pat != NULL); 6429fe5e51b7Smrg 6430a31a186aSmrg len = strlen (str); 6431a31a186aSmrg patlen = strlen (pat); 6432fe5e51b7Smrg 6433a31a186aSmrg if (patlen <= len) 6434a31a186aSmrg { 6435a31a186aSmrg str += len - patlen; 6436493f84f4Smrg if (STREQ (str, pat)) 6437a31a186aSmrg *str = '\0'; 6438a31a186aSmrg } 6439a31a186aSmrg return str; 6440a31a186aSmrg} 6441fe5e51b7Smrg 64420bb88ba4Smrgvoid 64430bb88ba4Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 64440bb88ba4Smrg{ 64450bb88ba4Smrg va_list args; 64460bb88ba4Smrg if (lt_debug) 64470bb88ba4Smrg { 64480bb88ba4Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 64490bb88ba4Smrg va_start (args, fmt); 64500bb88ba4Smrg (void) vfprintf (stderr, fmt, args); 64510bb88ba4Smrg va_end (args); 64520bb88ba4Smrg } 64530bb88ba4Smrg} 64540bb88ba4Smrg 6455a31a186aSmrgstatic void 64560bb88ba4Smrglt_error_core (int exit_status, const char *file, 64570bb88ba4Smrg int line, const char *mode, 6458a31a186aSmrg const char *message, va_list ap) 6459a31a186aSmrg{ 64600bb88ba4Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6461a31a186aSmrg vfprintf (stderr, message, ap); 6462a31a186aSmrg fprintf (stderr, ".\n"); 6463fe5e51b7Smrg 6464a31a186aSmrg if (exit_status >= 0) 6465a31a186aSmrg exit (exit_status); 6466a31a186aSmrg} 6467fe5e51b7Smrg 6468a31a186aSmrgvoid 64690bb88ba4Smrglt_fatal (const char *file, int line, const char *message, ...) 6470a31a186aSmrg{ 6471a31a186aSmrg va_list ap; 6472a31a186aSmrg va_start (ap, message); 64730bb88ba4Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6474a31a186aSmrg va_end (ap); 6475a31a186aSmrg} 6476fe5e51b7Smrg 64770bb88ba4Smrgstatic const char * 64780bb88ba4Smrgnonnull (const char *s) 64790bb88ba4Smrg{ 64800bb88ba4Smrg return s ? s : "(null)"; 64810bb88ba4Smrg} 64820bb88ba4Smrg 64830bb88ba4Smrgstatic const char * 64840bb88ba4Smrgnonempty (const char *s) 64850bb88ba4Smrg{ 64860bb88ba4Smrg return (s && !*s) ? "(empty)" : nonnull (s); 64870bb88ba4Smrg} 64880bb88ba4Smrg 6489a31a186aSmrgvoid 6490a31a186aSmrglt_setenv (const char *name, const char *value) 6491a31a186aSmrg{ 64920bb88ba4Smrg lt_debugprintf (__FILE__, __LINE__, 64930bb88ba4Smrg "(lt_setenv) setting '%s' to '%s'\n", 64940bb88ba4Smrg nonnull (name), nonnull (value)); 6495a31a186aSmrg { 6496a31a186aSmrg#ifdef HAVE_SETENV 6497a31a186aSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 6498a31a186aSmrg char *str = xstrdup (value); 6499a31a186aSmrg setenv (name, str, 1); 6500a31a186aSmrg#else 6501493f84f4Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6502a31a186aSmrg char *str = XMALLOC (char, len); 6503a31a186aSmrg sprintf (str, "%s=%s", name, value); 6504a31a186aSmrg if (putenv (str) != EXIT_SUCCESS) 6505a31a186aSmrg { 6506a31a186aSmrg XFREE (str); 6507a31a186aSmrg } 6508a31a186aSmrg#endif 6509a31a186aSmrg } 6510a31a186aSmrg} 6511fe5e51b7Smrg 6512a31a186aSmrgchar * 6513a31a186aSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 6514a31a186aSmrg{ 6515a31a186aSmrg char *new_value; 6516a31a186aSmrg if (orig_value && *orig_value) 6517a31a186aSmrg { 6518493f84f4Smrg size_t orig_value_len = strlen (orig_value); 6519493f84f4Smrg size_t add_len = strlen (add); 6520a31a186aSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6521a31a186aSmrg if (to_end) 6522a31a186aSmrg { 6523a31a186aSmrg strcpy (new_value, orig_value); 6524a31a186aSmrg strcpy (new_value + orig_value_len, add); 6525a31a186aSmrg } 6526a31a186aSmrg else 6527a31a186aSmrg { 6528a31a186aSmrg strcpy (new_value, add); 6529a31a186aSmrg strcpy (new_value + add_len, orig_value); 6530a31a186aSmrg } 6531a31a186aSmrg } 6532a31a186aSmrg else 6533a31a186aSmrg { 6534a31a186aSmrg new_value = xstrdup (add); 6535a31a186aSmrg } 6536a31a186aSmrg return new_value; 6537a31a186aSmrg} 6538fe5e51b7Smrg 6539a31a186aSmrgvoid 6540a31a186aSmrglt_update_exe_path (const char *name, const char *value) 6541a31a186aSmrg{ 65420bb88ba4Smrg lt_debugprintf (__FILE__, __LINE__, 65430bb88ba4Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 65440bb88ba4Smrg nonnull (name), nonnull (value)); 6545fe5e51b7Smrg 6546a31a186aSmrg if (name && *name && value && *value) 6547a31a186aSmrg { 6548a31a186aSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 6549a31a186aSmrg /* some systems can't cope with a ':'-terminated path #' */ 6550493f84f4Smrg size_t len = strlen (new_value); 6551493f84f4Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6552a31a186aSmrg { 6553493f84f4Smrg new_value[--len] = '\0'; 6554a31a186aSmrg } 6555a31a186aSmrg lt_setenv (name, new_value); 6556a31a186aSmrg XFREE (new_value); 6557a31a186aSmrg } 6558a31a186aSmrg} 6559fe5e51b7Smrg 6560a31a186aSmrgvoid 6561a31a186aSmrglt_update_lib_path (const char *name, const char *value) 6562a31a186aSmrg{ 65630bb88ba4Smrg lt_debugprintf (__FILE__, __LINE__, 65640bb88ba4Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 65650bb88ba4Smrg nonnull (name), nonnull (value)); 6566fe5e51b7Smrg 6567a31a186aSmrg if (name && *name && value && *value) 6568a31a186aSmrg { 6569a31a186aSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 6570a31a186aSmrg lt_setenv (name, new_value); 6571a31a186aSmrg XFREE (new_value); 6572a31a186aSmrg } 6573a31a186aSmrg} 6574fe5e51b7Smrg 65750bb88ba4SmrgEOF 65760bb88ba4Smrg case $host_os in 65770bb88ba4Smrg mingw*) 65780bb88ba4Smrg cat <<"EOF" 65790bb88ba4Smrg 65800bb88ba4Smrg/* Prepares an argument vector before calling spawn(). 65810bb88ba4Smrg Note that spawn() does not by itself call the command interpreter 65820bb88ba4Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 65830bb88ba4Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 65840bb88ba4Smrg GetVersionEx(&v); 65850bb88ba4Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 65860bb88ba4Smrg }) ? "cmd.exe" : "command.com"). 65870bb88ba4Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 65880bb88ba4Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 65890bb88ba4Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 65900bb88ba4Smrg special way: 65910bb88ba4Smrg - Space and tab are interpreted as delimiters. They are not treated as 65920bb88ba4Smrg delimiters if they are surrounded by double quotes: "...". 65930bb88ba4Smrg - Unescaped double quotes are removed from the input. Their only effect is 65940bb88ba4Smrg that within double quotes, space and tab are treated like normal 65950bb88ba4Smrg characters. 65960bb88ba4Smrg - Backslashes not followed by double quotes are not special. 65970bb88ba4Smrg - But 2*n+1 backslashes followed by a double quote become 65980bb88ba4Smrg n backslashes followed by a double quote (n >= 0): 65990bb88ba4Smrg \" -> " 66000bb88ba4Smrg \\\" -> \" 66010bb88ba4Smrg \\\\\" -> \\" 66020bb88ba4Smrg */ 66030bb88ba4Smrg#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" 66040bb88ba4Smrg#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" 66050bb88ba4Smrgchar ** 66060bb88ba4Smrgprepare_spawn (char **argv) 66070bb88ba4Smrg{ 66080bb88ba4Smrg size_t argc; 66090bb88ba4Smrg char **new_argv; 66100bb88ba4Smrg size_t i; 66110bb88ba4Smrg 66120bb88ba4Smrg /* Count number of arguments. */ 66130bb88ba4Smrg for (argc = 0; argv[argc] != NULL; argc++) 66140bb88ba4Smrg ; 66150bb88ba4Smrg 66160bb88ba4Smrg /* Allocate new argument vector. */ 66170bb88ba4Smrg new_argv = XMALLOC (char *, argc + 1); 66180bb88ba4Smrg 66190bb88ba4Smrg /* Put quoted arguments into the new argument vector. */ 66200bb88ba4Smrg for (i = 0; i < argc; i++) 66210bb88ba4Smrg { 66220bb88ba4Smrg const char *string = argv[i]; 66230bb88ba4Smrg 66240bb88ba4Smrg if (string[0] == '\0') 66250bb88ba4Smrg new_argv[i] = xstrdup ("\"\""); 66260bb88ba4Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 66270bb88ba4Smrg { 66280bb88ba4Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 66290bb88ba4Smrg size_t length; 66300bb88ba4Smrg unsigned int backslashes; 66310bb88ba4Smrg const char *s; 66320bb88ba4Smrg char *quoted_string; 66330bb88ba4Smrg char *p; 66340bb88ba4Smrg 66350bb88ba4Smrg length = 0; 66360bb88ba4Smrg backslashes = 0; 66370bb88ba4Smrg if (quote_around) 66380bb88ba4Smrg length++; 66390bb88ba4Smrg for (s = string; *s != '\0'; s++) 66400bb88ba4Smrg { 66410bb88ba4Smrg char c = *s; 66420bb88ba4Smrg if (c == '"') 66430bb88ba4Smrg length += backslashes + 1; 66440bb88ba4Smrg length++; 66450bb88ba4Smrg if (c == '\\') 66460bb88ba4Smrg backslashes++; 66470bb88ba4Smrg else 66480bb88ba4Smrg backslashes = 0; 66490bb88ba4Smrg } 66500bb88ba4Smrg if (quote_around) 66510bb88ba4Smrg length += backslashes + 1; 66520bb88ba4Smrg 66530bb88ba4Smrg quoted_string = XMALLOC (char, length + 1); 66540bb88ba4Smrg 66550bb88ba4Smrg p = quoted_string; 66560bb88ba4Smrg backslashes = 0; 66570bb88ba4Smrg if (quote_around) 66580bb88ba4Smrg *p++ = '"'; 66590bb88ba4Smrg for (s = string; *s != '\0'; s++) 66600bb88ba4Smrg { 66610bb88ba4Smrg char c = *s; 66620bb88ba4Smrg if (c == '"') 66630bb88ba4Smrg { 66640bb88ba4Smrg unsigned int j; 66650bb88ba4Smrg for (j = backslashes + 1; j > 0; j--) 66660bb88ba4Smrg *p++ = '\\'; 66670bb88ba4Smrg } 66680bb88ba4Smrg *p++ = c; 66690bb88ba4Smrg if (c == '\\') 66700bb88ba4Smrg backslashes++; 66710bb88ba4Smrg else 66720bb88ba4Smrg backslashes = 0; 66730bb88ba4Smrg } 66740bb88ba4Smrg if (quote_around) 66750bb88ba4Smrg { 66760bb88ba4Smrg unsigned int j; 66770bb88ba4Smrg for (j = backslashes; j > 0; j--) 66780bb88ba4Smrg *p++ = '\\'; 66790bb88ba4Smrg *p++ = '"'; 66800bb88ba4Smrg } 66810bb88ba4Smrg *p = '\0'; 66820bb88ba4Smrg 66830bb88ba4Smrg new_argv[i] = quoted_string; 66840bb88ba4Smrg } 66850bb88ba4Smrg else 66860bb88ba4Smrg new_argv[i] = (char *) string; 66870bb88ba4Smrg } 66880bb88ba4Smrg new_argv[argc] = NULL; 66890bb88ba4Smrg 66900bb88ba4Smrg return new_argv; 66910bb88ba4Smrg} 66920bb88ba4SmrgEOF 66930bb88ba4Smrg ;; 66940bb88ba4Smrg esac 6695fe5e51b7Smrg 66960bb88ba4Smrg cat <<"EOF" 66970bb88ba4Smrgvoid lt_dump_script (FILE* f) 66980bb88ba4Smrg{ 66990bb88ba4SmrgEOF 67000bb88ba4Smrg func_emit_wrapper yes | 67010bb88ba4Smrg $SED -n -e ' 67020bb88ba4Smrgs/^\(.\{79\}\)\(..*\)/\1\ 67030bb88ba4Smrg\2/ 67040bb88ba4Smrgh 67050bb88ba4Smrgs/\([\\"]\)/\\\1/g 67060bb88ba4Smrgs/$/\\n/ 67070bb88ba4Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 67080bb88ba4Smrgg 67090bb88ba4SmrgD' 67100bb88ba4Smrg cat <<"EOF" 67110bb88ba4Smrg} 6712a31a186aSmrgEOF 6713a31a186aSmrg} 6714a31a186aSmrg# end: func_emit_cwrapperexe_src 6715fe5e51b7Smrg 67160bb88ba4Smrg# func_win32_import_lib_p ARG 67170bb88ba4Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 67180bb88ba4Smrgfunc_win32_import_lib_p () 67190bb88ba4Smrg{ 6720493f84f4Smrg $debug_cmd 6721493f84f4Smrg 67220bb88ba4Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 67230bb88ba4Smrg *import*) : ;; 67240bb88ba4Smrg *) false ;; 67250bb88ba4Smrg esac 67260bb88ba4Smrg} 67270bb88ba4Smrg 6728ee82cb62Smrg# func_suncc_cstd_abi 6729ee82cb62Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6730ee82cb62Smrg# Several compiler flags select an ABI that is incompatible with the 6731ee82cb62Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6732ee82cb62Smrgfunc_suncc_cstd_abi () 6733ee82cb62Smrg{ 6734ee82cb62Smrg $debug_cmd 6735ee82cb62Smrg 6736ee82cb62Smrg case " $compile_command " in 6737ee82cb62Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6738ee82cb62Smrg suncc_use_cstd_abi=no 6739ee82cb62Smrg ;; 6740ee82cb62Smrg *) 6741ee82cb62Smrg suncc_use_cstd_abi=yes 6742ee82cb62Smrg ;; 6743ee82cb62Smrg esac 6744ee82cb62Smrg} 6745ee82cb62Smrg 6746a31a186aSmrg# func_mode_link arg... 6747a31a186aSmrgfunc_mode_link () 6748a31a186aSmrg{ 6749493f84f4Smrg $debug_cmd 6750493f84f4Smrg 6751a31a186aSmrg case $host in 6752a31a186aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6753a31a186aSmrg # It is impossible to link a dll without this setting, and 6754a31a186aSmrg # we shouldn't force the makefile maintainer to figure out 6755493f84f4Smrg # what system we are compiling for in order to pass an extra 6756a31a186aSmrg # flag for every libtool invocation. 6757a31a186aSmrg # allow_undefined=no 6758fe5e51b7Smrg 6759a31a186aSmrg # FIXME: Unfortunately, there are problems with the above when trying 6760493f84f4Smrg # to make a dll that has undefined symbols, in which case not 6761a31a186aSmrg # even a static library is built. For now, we need to specify 6762a31a186aSmrg # -no-undefined on the libtool link line when we can be certain 6763a31a186aSmrg # that all symbols are satisfied, otherwise we get a static library. 6764a31a186aSmrg allow_undefined=yes 6765a31a186aSmrg ;; 6766a31a186aSmrg *) 6767a31a186aSmrg allow_undefined=yes 6768a31a186aSmrg ;; 6769a31a186aSmrg esac 6770a31a186aSmrg libtool_args=$nonopt 6771a31a186aSmrg base_compile="$nonopt $@" 6772a31a186aSmrg compile_command=$nonopt 6773a31a186aSmrg finalize_command=$nonopt 6774fe5e51b7Smrg 6775a31a186aSmrg compile_rpath= 6776a31a186aSmrg finalize_rpath= 6777a31a186aSmrg compile_shlibpath= 6778a31a186aSmrg finalize_shlibpath= 6779a31a186aSmrg convenience= 6780a31a186aSmrg old_convenience= 6781a31a186aSmrg deplibs= 6782a31a186aSmrg old_deplibs= 6783a31a186aSmrg compiler_flags= 6784a31a186aSmrg linker_flags= 6785a31a186aSmrg dllsearchpath= 6786a31a186aSmrg lib_search_path=`pwd` 6787a31a186aSmrg inst_prefix_dir= 6788a31a186aSmrg new_inherited_linker_flags= 6789fe5e51b7Smrg 6790a31a186aSmrg avoid_version=no 67910bb88ba4Smrg bindir= 6792a31a186aSmrg dlfiles= 6793a31a186aSmrg dlprefiles= 6794a31a186aSmrg dlself=no 6795a31a186aSmrg export_dynamic=no 6796a31a186aSmrg export_symbols= 6797a31a186aSmrg export_symbols_regex= 6798a31a186aSmrg generated= 6799a31a186aSmrg libobjs= 6800a31a186aSmrg ltlibs= 6801a31a186aSmrg module=no 6802a31a186aSmrg no_install=no 6803a31a186aSmrg objs= 6804493f84f4Smrg os2dllname= 6805a31a186aSmrg non_pic_objects= 6806a31a186aSmrg precious_files_regex= 6807a31a186aSmrg prefer_static_libs=no 6808493f84f4Smrg preload=false 6809a31a186aSmrg prev= 6810a31a186aSmrg prevarg= 6811a31a186aSmrg release= 6812a31a186aSmrg rpath= 6813a31a186aSmrg xrpath= 6814a31a186aSmrg perm_rpath= 6815a31a186aSmrg temp_rpath= 6816a31a186aSmrg thread_safe=no 6817a31a186aSmrg vinfo= 6818a31a186aSmrg vinfo_number=no 6819a31a186aSmrg weak_libs= 6820493f84f4Smrg single_module=$wl-single_module 6821a31a186aSmrg func_infer_tag $base_compile 6822a31a186aSmrg 6823a31a186aSmrg # We need to know -static, to get the right output filenames. 6824a31a186aSmrg for arg 6825a31a186aSmrg do 6826a31a186aSmrg case $arg in 6827a31a186aSmrg -shared) 6828493f84f4Smrg test yes != "$build_libtool_libs" \ 6829493f84f4Smrg && func_fatal_configuration "cannot build a shared library" 6830a31a186aSmrg build_old_libs=no 6831a31a186aSmrg break 6832a31a186aSmrg ;; 6833a31a186aSmrg -all-static | -static | -static-libtool-libs) 6834a31a186aSmrg case $arg in 6835a31a186aSmrg -all-static) 6836493f84f4Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6837a31a186aSmrg func_warning "complete static linking is impossible in this configuration" 6838a31a186aSmrg fi 6839a31a186aSmrg if test -n "$link_static_flag"; then 6840a31a186aSmrg dlopen_self=$dlopen_self_static 6841a31a186aSmrg fi 6842a31a186aSmrg prefer_static_libs=yes 6843a31a186aSmrg ;; 6844a31a186aSmrg -static) 6845a31a186aSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6846a31a186aSmrg dlopen_self=$dlopen_self_static 6847a31a186aSmrg fi 6848a31a186aSmrg prefer_static_libs=built 6849a31a186aSmrg ;; 6850a31a186aSmrg -static-libtool-libs) 6851a31a186aSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6852a31a186aSmrg dlopen_self=$dlopen_self_static 6853643b027fSmrg fi 6854a31a186aSmrg prefer_static_libs=yes 6855a31a186aSmrg ;; 6856a31a186aSmrg esac 6857a31a186aSmrg build_libtool_libs=no 6858a31a186aSmrg build_old_libs=yes 6859a31a186aSmrg break 6860a31a186aSmrg ;; 6861a31a186aSmrg esac 6862a31a186aSmrg done 6863fe5e51b7Smrg 6864a31a186aSmrg # See if our shared archives depend on static archives. 6865a31a186aSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6866fe5e51b7Smrg 6867a31a186aSmrg # Go through the arguments, transforming them on the way. 6868a31a186aSmrg while test "$#" -gt 0; do 6869493f84f4Smrg arg=$1 6870a31a186aSmrg shift 68711e423a8fSmrg func_quote_arg pretty,unquoted "$arg" 68721e423a8fSmrg qarg=$func_quote_arg_unquoted_result 68731e423a8fSmrg func_append libtool_args " $func_quote_arg_result" 6874fe5e51b7Smrg 6875a31a186aSmrg # If the previous option needs an argument, assign it. 6876a31a186aSmrg if test -n "$prev"; then 6877a31a186aSmrg case $prev in 6878a31a186aSmrg output) 6879a31a186aSmrg func_append compile_command " @OUTPUT@" 6880a31a186aSmrg func_append finalize_command " @OUTPUT@" 6881a31a186aSmrg ;; 6882a31a186aSmrg esac 6883fe5e51b7Smrg 6884a31a186aSmrg case $prev in 68850bb88ba4Smrg bindir) 6886493f84f4Smrg bindir=$arg 68870bb88ba4Smrg prev= 68880bb88ba4Smrg continue 68890bb88ba4Smrg ;; 6890a31a186aSmrg dlfiles|dlprefiles) 6891493f84f4Smrg $preload || { 6892a31a186aSmrg # Add the symbol object into the linking commands. 6893a31a186aSmrg func_append compile_command " @SYMFILE@" 6894a31a186aSmrg func_append finalize_command " @SYMFILE@" 6895493f84f4Smrg preload=: 6896493f84f4Smrg } 6897a31a186aSmrg case $arg in 6898a31a186aSmrg *.la | *.lo) ;; # We handle these cases below. 6899a31a186aSmrg force) 6900493f84f4Smrg if test no = "$dlself"; then 6901a31a186aSmrg dlself=needless 6902a31a186aSmrg export_dynamic=yes 6903a31a186aSmrg fi 6904a31a186aSmrg prev= 6905a31a186aSmrg continue 6906a31a186aSmrg ;; 6907a31a186aSmrg self) 6908493f84f4Smrg if test dlprefiles = "$prev"; then 6909a31a186aSmrg dlself=yes 6910493f84f4Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6911a31a186aSmrg dlself=yes 6912643b027fSmrg else 6913a31a186aSmrg dlself=needless 6914a31a186aSmrg export_dynamic=yes 6915643b027fSmrg fi 6916a31a186aSmrg prev= 6917a31a186aSmrg continue 6918a31a186aSmrg ;; 6919a31a186aSmrg *) 6920493f84f4Smrg if test dlfiles = "$prev"; then 69210bb88ba4Smrg func_append dlfiles " $arg" 6922643b027fSmrg else 69230bb88ba4Smrg func_append dlprefiles " $arg" 6924643b027fSmrg fi 6925a31a186aSmrg prev= 6926a31a186aSmrg continue 6927a31a186aSmrg ;; 6928a31a186aSmrg esac 6929a31a186aSmrg ;; 6930a31a186aSmrg expsyms) 6931493f84f4Smrg export_symbols=$arg 6932a31a186aSmrg test -f "$arg" \ 6933493f84f4Smrg || func_fatal_error "symbol file '$arg' does not exist" 6934a31a186aSmrg prev= 6935a31a186aSmrg continue 6936a31a186aSmrg ;; 6937a31a186aSmrg expsyms_regex) 6938493f84f4Smrg export_symbols_regex=$arg 6939a31a186aSmrg prev= 6940a31a186aSmrg continue 6941a31a186aSmrg ;; 6942a31a186aSmrg framework) 6943643b027fSmrg case $host in 6944a31a186aSmrg *-*-darwin*) 6945a31a186aSmrg case "$deplibs " in 6946a31a186aSmrg *" $qarg.ltframework "*) ;; 69470bb88ba4Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6948a31a186aSmrg ;; 6949a31a186aSmrg esac 6950a31a186aSmrg ;; 6951643b027fSmrg esac 6952a31a186aSmrg prev= 6953a31a186aSmrg continue 6954643b027fSmrg ;; 6955a31a186aSmrg inst_prefix) 6956493f84f4Smrg inst_prefix_dir=$arg 6957493f84f4Smrg prev= 6958493f84f4Smrg continue 6959493f84f4Smrg ;; 6960493f84f4Smrg mllvm) 6961493f84f4Smrg # Clang does not use LLVM to link, so we can simply discard any 6962493f84f4Smrg # '-mllvm $arg' options when doing the link step. 6963a31a186aSmrg prev= 6964a31a186aSmrg continue 6965643b027fSmrg ;; 6966a31a186aSmrg objectlist) 6967a31a186aSmrg if test -f "$arg"; then 6968a31a186aSmrg save_arg=$arg 6969a31a186aSmrg moreargs= 6970a31a186aSmrg for fil in `cat "$save_arg"` 6971a31a186aSmrg do 69720bb88ba4Smrg# func_append moreargs " $fil" 6973a31a186aSmrg arg=$fil 6974a31a186aSmrg # A libtool-controlled object. 6975fe5e51b7Smrg 6976a31a186aSmrg # Check to see that this really is a libtool object. 6977a31a186aSmrg if func_lalib_unsafe_p "$arg"; then 6978a31a186aSmrg pic_object= 6979a31a186aSmrg non_pic_object= 6980fe5e51b7Smrg 6981a31a186aSmrg # Read the .lo file 6982a31a186aSmrg func_source "$arg" 6983fe5e51b7Smrg 6984a31a186aSmrg if test -z "$pic_object" || 6985a31a186aSmrg test -z "$non_pic_object" || 6986493f84f4Smrg test none = "$pic_object" && 6987493f84f4Smrg test none = "$non_pic_object"; then 6988493f84f4Smrg func_fatal_error "cannot find name of object for '$arg'" 6989a31a186aSmrg fi 6990fe5e51b7Smrg 6991a31a186aSmrg # Extract subdirectory from the argument. 6992a31a186aSmrg func_dirname "$arg" "/" "" 6993493f84f4Smrg xdir=$func_dirname_result 6994fe5e51b7Smrg 6995493f84f4Smrg if test none != "$pic_object"; then 6996a31a186aSmrg # Prepend the subdirectory the object is found in. 6997493f84f4Smrg pic_object=$xdir$pic_object 6998fe5e51b7Smrg 6999493f84f4Smrg if test dlfiles = "$prev"; then 7000493f84f4Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 70010bb88ba4Smrg func_append dlfiles " $pic_object" 7002a31a186aSmrg prev= 7003a31a186aSmrg continue 7004a31a186aSmrg else 7005a31a186aSmrg # If libtool objects are unsupported, then we need to preload. 7006a31a186aSmrg prev=dlprefiles 7007a31a186aSmrg fi 7008a31a186aSmrg fi 7009fe5e51b7Smrg 7010a31a186aSmrg # CHECK ME: I think I busted this. -Ossama 7011493f84f4Smrg if test dlprefiles = "$prev"; then 7012a31a186aSmrg # Preload the old-style object. 70130bb88ba4Smrg func_append dlprefiles " $pic_object" 7014a31a186aSmrg prev= 7015a31a186aSmrg fi 7016fe5e51b7Smrg 7017a31a186aSmrg # A PIC object. 7018a31a186aSmrg func_append libobjs " $pic_object" 7019493f84f4Smrg arg=$pic_object 7020a31a186aSmrg fi 7021eda3803bSmrg 7022a31a186aSmrg # Non-PIC object. 7023493f84f4Smrg if test none != "$non_pic_object"; then 7024a31a186aSmrg # Prepend the subdirectory the object is found in. 7025493f84f4Smrg non_pic_object=$xdir$non_pic_object 7026eda3803bSmrg 7027a31a186aSmrg # A standard non-PIC object 7028a31a186aSmrg func_append non_pic_objects " $non_pic_object" 7029493f84f4Smrg if test -z "$pic_object" || test none = "$pic_object"; then 7030493f84f4Smrg arg=$non_pic_object 7031a31a186aSmrg fi 7032a31a186aSmrg else 7033a31a186aSmrg # If the PIC object exists, use it instead. 7034a31a186aSmrg # $xdir was prepended to $pic_object above. 7035493f84f4Smrg non_pic_object=$pic_object 7036a31a186aSmrg func_append non_pic_objects " $non_pic_object" 7037a31a186aSmrg fi 7038a31a186aSmrg else 7039a31a186aSmrg # Only an error if not doing a dry-run. 7040a31a186aSmrg if $opt_dry_run; then 7041a31a186aSmrg # Extract subdirectory from the argument. 7042a31a186aSmrg func_dirname "$arg" "/" "" 7043493f84f4Smrg xdir=$func_dirname_result 7044a31a186aSmrg 7045a31a186aSmrg func_lo2o "$arg" 7046a31a186aSmrg pic_object=$xdir$objdir/$func_lo2o_result 7047a31a186aSmrg non_pic_object=$xdir$func_lo2o_result 7048a31a186aSmrg func_append libobjs " $pic_object" 7049a31a186aSmrg func_append non_pic_objects " $non_pic_object" 7050a31a186aSmrg else 7051493f84f4Smrg func_fatal_error "'$arg' is not a valid libtool object" 7052a31a186aSmrg fi 7053a31a186aSmrg fi 7054a31a186aSmrg done 7055643b027fSmrg else 7056493f84f4Smrg func_fatal_error "link input file '$arg' does not exist" 7057643b027fSmrg fi 7058a31a186aSmrg arg=$save_arg 7059a31a186aSmrg prev= 7060a31a186aSmrg continue 7061a31a186aSmrg ;; 7062493f84f4Smrg os2dllname) 7063493f84f4Smrg os2dllname=$arg 7064493f84f4Smrg prev= 7065493f84f4Smrg continue 7066493f84f4Smrg ;; 7067a31a186aSmrg precious_regex) 7068493f84f4Smrg precious_files_regex=$arg 7069a31a186aSmrg prev= 7070a31a186aSmrg continue 7071a31a186aSmrg ;; 7072a31a186aSmrg release) 7073493f84f4Smrg release=-$arg 7074a31a186aSmrg prev= 7075a31a186aSmrg continue 7076a31a186aSmrg ;; 7077a31a186aSmrg rpath | xrpath) 7078a31a186aSmrg # We need an absolute path. 7079a31a186aSmrg case $arg in 7080a31a186aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7081a31a186aSmrg *) 7082a31a186aSmrg func_fatal_error "only absolute run-paths are allowed" 7083a31a186aSmrg ;; 7084a31a186aSmrg esac 7085493f84f4Smrg if test rpath = "$prev"; then 7086a31a186aSmrg case "$rpath " in 7087a31a186aSmrg *" $arg "*) ;; 70880bb88ba4Smrg *) func_append rpath " $arg" ;; 7089a31a186aSmrg esac 7090643b027fSmrg else 7091a31a186aSmrg case "$xrpath " in 7092a31a186aSmrg *" $arg "*) ;; 70930bb88ba4Smrg *) func_append xrpath " $arg" ;; 7094a31a186aSmrg esac 7095643b027fSmrg fi 7096a31a186aSmrg prev= 7097a31a186aSmrg continue 7098a31a186aSmrg ;; 7099a31a186aSmrg shrext) 7100493f84f4Smrg shrext_cmds=$arg 7101a31a186aSmrg prev= 7102a31a186aSmrg continue 7103a31a186aSmrg ;; 7104a31a186aSmrg weak) 71050bb88ba4Smrg func_append weak_libs " $arg" 7106a31a186aSmrg prev= 7107a31a186aSmrg continue 7108a31a186aSmrg ;; 71091e423a8fSmrg xassembler) 71101e423a8fSmrg func_append compiler_flags " -Xassembler $qarg" 71111e423a8fSmrg prev= 71121e423a8fSmrg func_append compile_command " -Xassembler $qarg" 71131e423a8fSmrg func_append finalize_command " -Xassembler $qarg" 71141e423a8fSmrg continue 71151e423a8fSmrg ;; 7116a31a186aSmrg xcclinker) 71170bb88ba4Smrg func_append linker_flags " $qarg" 71180bb88ba4Smrg func_append compiler_flags " $qarg" 7119a31a186aSmrg prev= 7120a31a186aSmrg func_append compile_command " $qarg" 7121a31a186aSmrg func_append finalize_command " $qarg" 7122a31a186aSmrg continue 7123a31a186aSmrg ;; 7124a31a186aSmrg xcompiler) 71250bb88ba4Smrg func_append compiler_flags " $qarg" 7126a31a186aSmrg prev= 7127a31a186aSmrg func_append compile_command " $qarg" 7128a31a186aSmrg func_append finalize_command " $qarg" 7129a31a186aSmrg continue 7130a31a186aSmrg ;; 7131a31a186aSmrg xlinker) 71320bb88ba4Smrg func_append linker_flags " $qarg" 71330bb88ba4Smrg func_append compiler_flags " $wl$qarg" 7134a31a186aSmrg prev= 7135a31a186aSmrg func_append compile_command " $wl$qarg" 7136a31a186aSmrg func_append finalize_command " $wl$qarg" 7137a31a186aSmrg continue 7138a31a186aSmrg ;; 7139a31a186aSmrg *) 7140a31a186aSmrg eval "$prev=\"\$arg\"" 7141a31a186aSmrg prev= 7142a31a186aSmrg continue 7143a31a186aSmrg ;; 7144eda3803bSmrg esac 7145a31a186aSmrg fi # test -n "$prev" 7146eda3803bSmrg 7147493f84f4Smrg prevarg=$arg 7148eda3803bSmrg 7149a31a186aSmrg case $arg in 7150a31a186aSmrg -all-static) 7151a31a186aSmrg if test -n "$link_static_flag"; then 7152a31a186aSmrg # See comment for -static flag below, for more details. 7153a31a186aSmrg func_append compile_command " $link_static_flag" 7154a31a186aSmrg func_append finalize_command " $link_static_flag" 7155a31a186aSmrg fi 7156a31a186aSmrg continue 7157a31a186aSmrg ;; 7158eda3803bSmrg 7159a31a186aSmrg -allow-undefined) 7160a31a186aSmrg # FIXME: remove this flag sometime in the future. 7161493f84f4Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 7162a31a186aSmrg ;; 7163eda3803bSmrg 7164a31a186aSmrg -avoid-version) 7165a31a186aSmrg avoid_version=yes 7166a31a186aSmrg continue 7167a31a186aSmrg ;; 7168eda3803bSmrg 71690bb88ba4Smrg -bindir) 71700bb88ba4Smrg prev=bindir 71710bb88ba4Smrg continue 71720bb88ba4Smrg ;; 71730bb88ba4Smrg 7174a31a186aSmrg -dlopen) 7175a31a186aSmrg prev=dlfiles 7176a31a186aSmrg continue 7177a31a186aSmrg ;; 7178eda3803bSmrg 7179a31a186aSmrg -dlpreopen) 7180a31a186aSmrg prev=dlprefiles 7181a31a186aSmrg continue 7182a31a186aSmrg ;; 7183eda3803bSmrg 7184a31a186aSmrg -export-dynamic) 7185a31a186aSmrg export_dynamic=yes 7186a31a186aSmrg continue 7187a31a186aSmrg ;; 7188eda3803bSmrg 7189a31a186aSmrg -export-symbols | -export-symbols-regex) 7190a31a186aSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 7191a31a186aSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 7192a31a186aSmrg fi 7193493f84f4Smrg if test X-export-symbols = "X$arg"; then 7194a31a186aSmrg prev=expsyms 7195a31a186aSmrg else 7196a31a186aSmrg prev=expsyms_regex 7197a31a186aSmrg fi 7198a31a186aSmrg continue 7199a31a186aSmrg ;; 7200eda3803bSmrg 7201a31a186aSmrg -framework) 7202a31a186aSmrg prev=framework 7203a31a186aSmrg continue 7204a31a186aSmrg ;; 7205eda3803bSmrg 7206a31a186aSmrg -inst-prefix-dir) 7207a31a186aSmrg prev=inst_prefix 7208a31a186aSmrg continue 7209a31a186aSmrg ;; 7210eda3803bSmrg 7211a31a186aSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 7212a31a186aSmrg # so, if we see these flags be careful not to treat them like -L 7213a31a186aSmrg -L[A-Z][A-Z]*:*) 7214a31a186aSmrg case $with_gcc/$host in 7215a31a186aSmrg no/*-*-irix* | /*-*-irix*) 7216a31a186aSmrg func_append compile_command " $arg" 7217a31a186aSmrg func_append finalize_command " $arg" 7218a31a186aSmrg ;; 7219a31a186aSmrg esac 7220a31a186aSmrg continue 7221a31a186aSmrg ;; 7222eda3803bSmrg 7223a31a186aSmrg -L*) 72240bb88ba4Smrg func_stripname "-L" '' "$arg" 72250bb88ba4Smrg if test -z "$func_stripname_result"; then 7226a31a186aSmrg if test "$#" -gt 0; then 7227493f84f4Smrg func_fatal_error "require no space between '-L' and '$1'" 7228a31a186aSmrg else 7229493f84f4Smrg func_fatal_error "need path for '-L' option" 7230a31a186aSmrg fi 7231a31a186aSmrg fi 72320bb88ba4Smrg func_resolve_sysroot "$func_stripname_result" 72330bb88ba4Smrg dir=$func_resolve_sysroot_result 7234a31a186aSmrg # We need an absolute path. 7235a31a186aSmrg case $dir in 7236a31a186aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7237a31a186aSmrg *) 7238a31a186aSmrg absdir=`cd "$dir" && pwd` 7239a31a186aSmrg test -z "$absdir" && \ 7240493f84f4Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 7241493f84f4Smrg dir=$absdir 7242a31a186aSmrg ;; 7243a31a186aSmrg esac 7244a31a186aSmrg case "$deplibs " in 72450bb88ba4Smrg *" -L$dir "* | *" $arg "*) 72460bb88ba4Smrg # Will only happen for absolute or sysroot arguments 72470bb88ba4Smrg ;; 7248a31a186aSmrg *) 72490bb88ba4Smrg # Preserve sysroot, but never include relative directories 72500bb88ba4Smrg case $dir in 72510bb88ba4Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 72520bb88ba4Smrg *) func_append deplibs " -L$dir" ;; 72530bb88ba4Smrg esac 72540bb88ba4Smrg func_append lib_search_path " $dir" 7255a31a186aSmrg ;; 7256a31a186aSmrg esac 7257a31a186aSmrg case $host in 7258a31a186aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 72590bb88ba4Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 7260a31a186aSmrg case :$dllsearchpath: in 7261a31a186aSmrg *":$dir:"*) ;; 7262a31a186aSmrg ::) dllsearchpath=$dir;; 72630bb88ba4Smrg *) func_append dllsearchpath ":$dir";; 7264a31a186aSmrg esac 7265a31a186aSmrg case :$dllsearchpath: in 7266a31a186aSmrg *":$testbindir:"*) ;; 7267a31a186aSmrg ::) dllsearchpath=$testbindir;; 72680bb88ba4Smrg *) func_append dllsearchpath ":$testbindir";; 7269a31a186aSmrg esac 7270a31a186aSmrg ;; 7271a31a186aSmrg esac 7272a31a186aSmrg continue 7273a31a186aSmrg ;; 7274eda3803bSmrg 7275a31a186aSmrg -l*) 7276493f84f4Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7277a31a186aSmrg case $host in 72780bb88ba4Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7279a31a186aSmrg # These systems don't actually have a C or math library (as such) 7280a31a186aSmrg continue 7281a31a186aSmrg ;; 7282a31a186aSmrg *-*-os2*) 7283a31a186aSmrg # These systems don't actually have a C library (as such) 7284493f84f4Smrg test X-lc = "X$arg" && continue 7285a31a186aSmrg ;; 72861e423a8fSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7287a31a186aSmrg # Do not include libc due to us having libc/libc_r. 7288493f84f4Smrg test X-lc = "X$arg" && continue 7289a31a186aSmrg ;; 7290a31a186aSmrg *-*-rhapsody* | *-*-darwin1.[012]) 7291a31a186aSmrg # Rhapsody C and math libraries are in the System framework 72920bb88ba4Smrg func_append deplibs " System.ltframework" 7293a31a186aSmrg continue 7294a31a186aSmrg ;; 7295a31a186aSmrg *-*-sco3.2v5* | *-*-sco5v6*) 7296a31a186aSmrg # Causes problems with __ctype 7297493f84f4Smrg test X-lc = "X$arg" && continue 7298a31a186aSmrg ;; 7299a31a186aSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7300a31a186aSmrg # Compiler inserts libc in the correct place for threads to work 7301493f84f4Smrg test X-lc = "X$arg" && continue 7302a31a186aSmrg ;; 7303a31a186aSmrg esac 7304493f84f4Smrg elif test X-lc_r = "X$arg"; then 7305a31a186aSmrg case $host in 73061e423a8fSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7307a31a186aSmrg # Do not include libc_r directly, use -pthread flag. 7308a31a186aSmrg continue 7309a31a186aSmrg ;; 7310a31a186aSmrg esac 7311a31a186aSmrg fi 73120bb88ba4Smrg func_append deplibs " $arg" 7313a31a186aSmrg continue 7314a31a186aSmrg ;; 7315eda3803bSmrg 7316493f84f4Smrg -mllvm) 7317493f84f4Smrg prev=mllvm 7318493f84f4Smrg continue 7319493f84f4Smrg ;; 7320493f84f4Smrg 7321a31a186aSmrg -module) 7322a31a186aSmrg module=yes 7323a31a186aSmrg continue 7324a31a186aSmrg ;; 7325eda3803bSmrg 7326a31a186aSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7327a31a186aSmrg # classes, name mangling, and exception handling. 7328a31a186aSmrg # Darwin uses the -arch flag to determine output architecture. 73290bb88ba4Smrg -model|-arch|-isysroot|--sysroot) 73300bb88ba4Smrg func_append compiler_flags " $arg" 7331a31a186aSmrg func_append compile_command " $arg" 7332a31a186aSmrg func_append finalize_command " $arg" 7333a31a186aSmrg prev=xcompiler 7334a31a186aSmrg continue 7335a31a186aSmrg ;; 73361e423a8fSmrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 73371e423a8fSmrg -pthread) 73381e423a8fSmrg case $host in 73391e423a8fSmrg *solaris2*) ;; 73401e423a8fSmrg *) 73411e423a8fSmrg case "$new_inherited_linker_flags " in 73421e423a8fSmrg *" $arg "*) ;; 73431e423a8fSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 73441e423a8fSmrg esac 73451e423a8fSmrg ;; 73461e423a8fSmrg esac 73471e423a8fSmrg continue 73481e423a8fSmrg ;; 73491e423a8fSmrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 73500bb88ba4Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 73510bb88ba4Smrg func_append compiler_flags " $arg" 7352a31a186aSmrg func_append compile_command " $arg" 7353a31a186aSmrg func_append finalize_command " $arg" 7354a31a186aSmrg case "$new_inherited_linker_flags " in 7355a31a186aSmrg *" $arg "*) ;; 73560bb88ba4Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7357a31a186aSmrg esac 7358a31a186aSmrg continue 7359a31a186aSmrg ;; 7360eda3803bSmrg 7361a31a186aSmrg -multi_module) 7362493f84f4Smrg single_module=$wl-multi_module 7363a31a186aSmrg continue 7364a31a186aSmrg ;; 7365eda3803bSmrg 7366a31a186aSmrg -no-fast-install) 7367a31a186aSmrg fast_install=no 7368a31a186aSmrg continue 7369a31a186aSmrg ;; 7370eda3803bSmrg 7371a31a186aSmrg -no-install) 7372a31a186aSmrg case $host in 7373a31a186aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7374a31a186aSmrg # The PATH hackery in wrapper scripts is required on Windows 7375a31a186aSmrg # and Darwin in order for the loader to find any dlls it needs. 7376493f84f4Smrg func_warning "'-no-install' is ignored for $host" 7377493f84f4Smrg func_warning "assuming '-no-fast-install' instead" 7378a31a186aSmrg fast_install=no 7379a31a186aSmrg ;; 7380a31a186aSmrg *) no_install=yes ;; 7381a31a186aSmrg esac 7382a31a186aSmrg continue 7383a31a186aSmrg ;; 7384eda3803bSmrg 7385a31a186aSmrg -no-undefined) 7386a31a186aSmrg allow_undefined=no 7387a31a186aSmrg continue 7388a31a186aSmrg ;; 7389eda3803bSmrg 7390a31a186aSmrg -objectlist) 7391a31a186aSmrg prev=objectlist 7392a31a186aSmrg continue 7393a31a186aSmrg ;; 7394eda3803bSmrg 7395493f84f4Smrg -os2dllname) 7396493f84f4Smrg prev=os2dllname 7397493f84f4Smrg continue 7398493f84f4Smrg ;; 7399493f84f4Smrg 7400a31a186aSmrg -o) prev=output ;; 7401eda3803bSmrg 7402a31a186aSmrg -precious-files-regex) 7403a31a186aSmrg prev=precious_regex 7404a31a186aSmrg continue 7405a31a186aSmrg ;; 7406eda3803bSmrg 7407a31a186aSmrg -release) 7408a31a186aSmrg prev=release 7409a31a186aSmrg continue 7410a31a186aSmrg ;; 7411eda3803bSmrg 7412a31a186aSmrg -rpath) 7413a31a186aSmrg prev=rpath 7414a31a186aSmrg continue 7415a31a186aSmrg ;; 7416eda3803bSmrg 7417a31a186aSmrg -R) 7418a31a186aSmrg prev=xrpath 7419a31a186aSmrg continue 7420a31a186aSmrg ;; 7421eda3803bSmrg 7422a31a186aSmrg -R*) 7423a31a186aSmrg func_stripname '-R' '' "$arg" 7424a31a186aSmrg dir=$func_stripname_result 7425a31a186aSmrg # We need an absolute path. 7426a31a186aSmrg case $dir in 7427a31a186aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 74280bb88ba4Smrg =*) 74290bb88ba4Smrg func_stripname '=' '' "$dir" 74300bb88ba4Smrg dir=$lt_sysroot$func_stripname_result 74310bb88ba4Smrg ;; 7432a31a186aSmrg *) 7433a31a186aSmrg func_fatal_error "only absolute run-paths are allowed" 7434a31a186aSmrg ;; 7435a31a186aSmrg esac 7436a31a186aSmrg case "$xrpath " in 7437a31a186aSmrg *" $dir "*) ;; 74380bb88ba4Smrg *) func_append xrpath " $dir" ;; 7439a31a186aSmrg esac 7440a31a186aSmrg continue 7441a31a186aSmrg ;; 7442eda3803bSmrg 7443a31a186aSmrg -shared) 7444a31a186aSmrg # The effects of -shared are defined in a previous loop. 7445a31a186aSmrg continue 7446a31a186aSmrg ;; 7447eda3803bSmrg 7448a31a186aSmrg -shrext) 7449a31a186aSmrg prev=shrext 7450a31a186aSmrg continue 7451a31a186aSmrg ;; 7452eda3803bSmrg 7453a31a186aSmrg -static | -static-libtool-libs) 7454a31a186aSmrg # The effects of -static are defined in a previous loop. 7455a31a186aSmrg # We used to do the same as -all-static on platforms that 7456a31a186aSmrg # didn't have a PIC flag, but the assumption that the effects 7457a31a186aSmrg # would be equivalent was wrong. It would break on at least 7458a31a186aSmrg # Digital Unix and AIX. 7459a31a186aSmrg continue 7460a31a186aSmrg ;; 7461eda3803bSmrg 7462a31a186aSmrg -thread-safe) 7463a31a186aSmrg thread_safe=yes 7464a31a186aSmrg continue 7465a31a186aSmrg ;; 7466eda3803bSmrg 7467a31a186aSmrg -version-info) 7468a31a186aSmrg prev=vinfo 7469a31a186aSmrg continue 7470a31a186aSmrg ;; 7471eda3803bSmrg 7472a31a186aSmrg -version-number) 7473a31a186aSmrg prev=vinfo 7474a31a186aSmrg vinfo_number=yes 7475a31a186aSmrg continue 7476a31a186aSmrg ;; 7477eda3803bSmrg 7478a31a186aSmrg -weak) 7479a31a186aSmrg prev=weak 7480a31a186aSmrg continue 7481a31a186aSmrg ;; 7482fe5e51b7Smrg 7483a31a186aSmrg -Wc,*) 7484a31a186aSmrg func_stripname '-Wc,' '' "$arg" 7485a31a186aSmrg args=$func_stripname_result 7486a31a186aSmrg arg= 7487493f84f4Smrg save_ifs=$IFS; IFS=, 7488a31a186aSmrg for flag in $args; do 7489493f84f4Smrg IFS=$save_ifs 74901e423a8fSmrg func_quote_arg pretty "$flag" 74911e423a8fSmrg func_append arg " $func_quote_arg_result" 74921e423a8fSmrg func_append compiler_flags " $func_quote_arg_result" 7493a31a186aSmrg done 7494493f84f4Smrg IFS=$save_ifs 7495a31a186aSmrg func_stripname ' ' '' "$arg" 7496a31a186aSmrg arg=$func_stripname_result 7497a31a186aSmrg ;; 7498643b027fSmrg 7499a31a186aSmrg -Wl,*) 7500a31a186aSmrg func_stripname '-Wl,' '' "$arg" 7501a31a186aSmrg args=$func_stripname_result 7502a31a186aSmrg arg= 7503493f84f4Smrg save_ifs=$IFS; IFS=, 7504a31a186aSmrg for flag in $args; do 7505493f84f4Smrg IFS=$save_ifs 75061e423a8fSmrg func_quote_arg pretty "$flag" 75071e423a8fSmrg func_append arg " $wl$func_quote_arg_result" 75081e423a8fSmrg func_append compiler_flags " $wl$func_quote_arg_result" 75091e423a8fSmrg func_append linker_flags " $func_quote_arg_result" 7510a31a186aSmrg done 7511493f84f4Smrg IFS=$save_ifs 7512a31a186aSmrg func_stripname ' ' '' "$arg" 7513a31a186aSmrg arg=$func_stripname_result 7514a31a186aSmrg ;; 7515643b027fSmrg 75161e423a8fSmrg -Xassembler) 75171e423a8fSmrg prev=xassembler 75181e423a8fSmrg continue 75191e423a8fSmrg ;; 75201e423a8fSmrg 7521a31a186aSmrg -Xcompiler) 7522a31a186aSmrg prev=xcompiler 7523a31a186aSmrg continue 7524a31a186aSmrg ;; 7525643b027fSmrg 7526a31a186aSmrg -Xlinker) 7527a31a186aSmrg prev=xlinker 7528a31a186aSmrg continue 7529a31a186aSmrg ;; 7530643b027fSmrg 7531a31a186aSmrg -XCClinker) 7532a31a186aSmrg prev=xcclinker 7533a31a186aSmrg continue 7534a31a186aSmrg ;; 7535643b027fSmrg 7536a31a186aSmrg # -msg_* for osf cc 7537a31a186aSmrg -msg_*) 75381e423a8fSmrg func_quote_arg pretty "$arg" 75391e423a8fSmrg arg=$func_quote_arg_result 7540a31a186aSmrg ;; 7541643b027fSmrg 75420bb88ba4Smrg # Flags to be passed through unchanged, with rationale: 75430bb88ba4Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 75440bb88ba4Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 75450bb88ba4Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 75460bb88ba4Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 75470bb88ba4Smrg # -q* compiler args for the IBM compiler 75480bb88ba4Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 75490bb88ba4Smrg # -F/path path to uninstalled frameworks, gcc on darwin 75500bb88ba4Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7551493f84f4Smrg # -fstack-protector* stack protector flags for GCC 75520bb88ba4Smrg # @file GCC response files 75530bb88ba4Smrg # -tp=* Portland pgcc target processor selection 75540bb88ba4Smrg # --sysroot=* for sysroot support 7555493f84f4Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7556b0de6900Smrg # -specs=* GCC specs files 7557493f84f4Smrg # -stdlib=* select c++ std lib with clang 7558b0de6900Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 75591e423a8fSmrg # -fuse-ld=* Linker select flags for GCC 75601e423a8fSmrg # -Wa,* Pass flags directly to the assembler 7561a31a186aSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 75620bb88ba4Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7563b0de6900Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 75641e423a8fSmrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 75651e423a8fSmrg func_quote_arg pretty "$arg" 75661e423a8fSmrg arg=$func_quote_arg_result 7567a31a186aSmrg func_append compile_command " $arg" 7568a31a186aSmrg func_append finalize_command " $arg" 75690bb88ba4Smrg func_append compiler_flags " $arg" 7570a31a186aSmrg continue 7571a31a186aSmrg ;; 7572643b027fSmrg 7573493f84f4Smrg -Z*) 7574493f84f4Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 7575493f84f4Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 7576493f84f4Smrg compiler_flags="$compiler_flags $arg" 7577493f84f4Smrg func_append compile_command " $arg" 7578493f84f4Smrg func_append finalize_command " $arg" 7579493f84f4Smrg case $arg in 7580493f84f4Smrg -Zlinker | -Zstack) 7581493f84f4Smrg prev=xcompiler 7582493f84f4Smrg ;; 7583493f84f4Smrg esac 7584493f84f4Smrg continue 7585493f84f4Smrg else 7586493f84f4Smrg # Otherwise treat like 'Some other compiler flag' below 75871e423a8fSmrg func_quote_arg pretty "$arg" 75881e423a8fSmrg arg=$func_quote_arg_result 7589493f84f4Smrg fi 7590493f84f4Smrg ;; 7591493f84f4Smrg 7592a31a186aSmrg # Some other compiler flag. 7593a31a186aSmrg -* | +*) 75941e423a8fSmrg func_quote_arg pretty "$arg" 75951e423a8fSmrg arg=$func_quote_arg_result 7596a31a186aSmrg ;; 7597643b027fSmrg 7598a31a186aSmrg *.$objext) 7599a31a186aSmrg # A standard object. 76000bb88ba4Smrg func_append objs " $arg" 7601a31a186aSmrg ;; 7602643b027fSmrg 7603a31a186aSmrg *.lo) 7604a31a186aSmrg # A libtool-controlled object. 7605643b027fSmrg 7606a31a186aSmrg # Check to see that this really is a libtool object. 7607a31a186aSmrg if func_lalib_unsafe_p "$arg"; then 7608a31a186aSmrg pic_object= 7609a31a186aSmrg non_pic_object= 7610643b027fSmrg 7611a31a186aSmrg # Read the .lo file 7612a31a186aSmrg func_source "$arg" 7613643b027fSmrg 7614a31a186aSmrg if test -z "$pic_object" || 7615a31a186aSmrg test -z "$non_pic_object" || 7616493f84f4Smrg test none = "$pic_object" && 7617493f84f4Smrg test none = "$non_pic_object"; then 7618493f84f4Smrg func_fatal_error "cannot find name of object for '$arg'" 7619a31a186aSmrg fi 7620643b027fSmrg 7621a31a186aSmrg # Extract subdirectory from the argument. 7622a31a186aSmrg func_dirname "$arg" "/" "" 7623493f84f4Smrg xdir=$func_dirname_result 7624643b027fSmrg 7625493f84f4Smrg test none = "$pic_object" || { 7626a31a186aSmrg # Prepend the subdirectory the object is found in. 7627493f84f4Smrg pic_object=$xdir$pic_object 7628643b027fSmrg 7629493f84f4Smrg if test dlfiles = "$prev"; then 7630493f84f4Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 76310bb88ba4Smrg func_append dlfiles " $pic_object" 7632a31a186aSmrg prev= 7633a31a186aSmrg continue 7634a31a186aSmrg else 7635a31a186aSmrg # If libtool objects are unsupported, then we need to preload. 7636a31a186aSmrg prev=dlprefiles 7637a31a186aSmrg fi 7638a31a186aSmrg fi 7639643b027fSmrg 7640a31a186aSmrg # CHECK ME: I think I busted this. -Ossama 7641493f84f4Smrg if test dlprefiles = "$prev"; then 7642a31a186aSmrg # Preload the old-style object. 76430bb88ba4Smrg func_append dlprefiles " $pic_object" 7644a31a186aSmrg prev= 7645a31a186aSmrg fi 7646fe5e51b7Smrg 7647a31a186aSmrg # A PIC object. 7648a31a186aSmrg func_append libobjs " $pic_object" 7649493f84f4Smrg arg=$pic_object 7650493f84f4Smrg } 7651fe5e51b7Smrg 7652a31a186aSmrg # Non-PIC object. 7653493f84f4Smrg if test none != "$non_pic_object"; then 7654a31a186aSmrg # Prepend the subdirectory the object is found in. 7655493f84f4Smrg non_pic_object=$xdir$non_pic_object 7656fe5e51b7Smrg 7657a31a186aSmrg # A standard non-PIC object 7658a31a186aSmrg func_append non_pic_objects " $non_pic_object" 7659493f84f4Smrg if test -z "$pic_object" || test none = "$pic_object"; then 7660493f84f4Smrg arg=$non_pic_object 7661a31a186aSmrg fi 7662a31a186aSmrg else 7663a31a186aSmrg # If the PIC object exists, use it instead. 7664a31a186aSmrg # $xdir was prepended to $pic_object above. 7665493f84f4Smrg non_pic_object=$pic_object 7666a31a186aSmrg func_append non_pic_objects " $non_pic_object" 7667a31a186aSmrg fi 7668a31a186aSmrg else 7669a31a186aSmrg # Only an error if not doing a dry-run. 7670a31a186aSmrg if $opt_dry_run; then 7671a31a186aSmrg # Extract subdirectory from the argument. 7672a31a186aSmrg func_dirname "$arg" "/" "" 7673493f84f4Smrg xdir=$func_dirname_result 7674a31a186aSmrg 7675a31a186aSmrg func_lo2o "$arg" 7676a31a186aSmrg pic_object=$xdir$objdir/$func_lo2o_result 7677a31a186aSmrg non_pic_object=$xdir$func_lo2o_result 7678a31a186aSmrg func_append libobjs " $pic_object" 7679a31a186aSmrg func_append non_pic_objects " $non_pic_object" 7680a31a186aSmrg else 7681493f84f4Smrg func_fatal_error "'$arg' is not a valid libtool object" 7682a31a186aSmrg fi 7683a31a186aSmrg fi 7684a31a186aSmrg ;; 7685fe5e51b7Smrg 7686a31a186aSmrg *.$libext) 7687a31a186aSmrg # An archive. 76880bb88ba4Smrg func_append deplibs " $arg" 76890bb88ba4Smrg func_append old_deplibs " $arg" 7690a31a186aSmrg continue 7691a31a186aSmrg ;; 7692a31a186aSmrg 7693a31a186aSmrg *.la) 7694a31a186aSmrg # A libtool-controlled library. 7695a31a186aSmrg 76960bb88ba4Smrg func_resolve_sysroot "$arg" 7697493f84f4Smrg if test dlfiles = "$prev"; then 7698a31a186aSmrg # This library was specified with -dlopen. 76990bb88ba4Smrg func_append dlfiles " $func_resolve_sysroot_result" 7700a31a186aSmrg prev= 7701493f84f4Smrg elif test dlprefiles = "$prev"; then 7702a31a186aSmrg # The library was specified with -dlpreopen. 77030bb88ba4Smrg func_append dlprefiles " $func_resolve_sysroot_result" 7704a31a186aSmrg prev= 7705a31a186aSmrg else 77060bb88ba4Smrg func_append deplibs " $func_resolve_sysroot_result" 7707a31a186aSmrg fi 7708a31a186aSmrg continue 7709a31a186aSmrg ;; 7710a31a186aSmrg 7711a31a186aSmrg # Some other compiler argument. 7712a31a186aSmrg *) 7713a31a186aSmrg # Unknown arguments in both finalize_command and compile_command need 7714a31a186aSmrg # to be aesthetically quoted because they are evaled later. 77151e423a8fSmrg func_quote_arg pretty "$arg" 77161e423a8fSmrg arg=$func_quote_arg_result 7717a31a186aSmrg ;; 7718a31a186aSmrg esac # arg 7719a31a186aSmrg 7720a31a186aSmrg # Now actually substitute the argument into the commands. 7721a31a186aSmrg if test -n "$arg"; then 7722a31a186aSmrg func_append compile_command " $arg" 7723a31a186aSmrg func_append finalize_command " $arg" 7724a31a186aSmrg fi 7725a31a186aSmrg done # argument parsing loop 7726a31a186aSmrg 7727a31a186aSmrg test -n "$prev" && \ 7728493f84f4Smrg func_fatal_help "the '$prevarg' option requires an argument" 7729a31a186aSmrg 7730493f84f4Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7731a31a186aSmrg eval arg=\"$export_dynamic_flag_spec\" 7732a31a186aSmrg func_append compile_command " $arg" 7733a31a186aSmrg func_append finalize_command " $arg" 7734a31a186aSmrg fi 7735a31a186aSmrg 7736a31a186aSmrg oldlibs= 7737a31a186aSmrg # calculate the name of the file, without its directory 7738a31a186aSmrg func_basename "$output" 7739493f84f4Smrg outputname=$func_basename_result 7740493f84f4Smrg libobjs_save=$libobjs 7741a31a186aSmrg 7742a31a186aSmrg if test -n "$shlibpath_var"; then 7743a31a186aSmrg # get the directories listed in $shlibpath_var 7744493f84f4Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7745a31a186aSmrg else 7746a31a186aSmrg shlib_search_path= 7747a31a186aSmrg fi 7748a31a186aSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7749a31a186aSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7750a31a186aSmrg 7751ee82cb62Smrg # Definition is injected by LT_CONFIG during libtool generation. 7752ee82cb62Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7753ee82cb62Smrg 7754a31a186aSmrg func_dirname "$output" "/" "" 7755493f84f4Smrg output_objdir=$func_dirname_result$objdir 77560bb88ba4Smrg func_to_tool_file "$output_objdir/" 77570bb88ba4Smrg tool_output_objdir=$func_to_tool_file_result 7758a31a186aSmrg # Create the object directory. 7759a31a186aSmrg func_mkdir_p "$output_objdir" 7760a31a186aSmrg 7761a31a186aSmrg # Determine the type of output 7762a31a186aSmrg case $output in 7763a31a186aSmrg "") 7764a31a186aSmrg func_fatal_help "you must specify an output file" 7765a31a186aSmrg ;; 7766a31a186aSmrg *.$libext) linkmode=oldlib ;; 7767a31a186aSmrg *.lo | *.$objext) linkmode=obj ;; 7768a31a186aSmrg *.la) linkmode=lib ;; 7769a31a186aSmrg *) linkmode=prog ;; # Anything else should be a program. 7770a31a186aSmrg esac 7771a31a186aSmrg 7772a31a186aSmrg specialdeplibs= 7773a31a186aSmrg 7774a31a186aSmrg libs= 7775a31a186aSmrg # Find all interdependent deplibs by searching for libraries 7776a31a186aSmrg # that are linked more than once (e.g. -la -lb -la) 7777a31a186aSmrg for deplib in $deplibs; do 7778493f84f4Smrg if $opt_preserve_dup_deps; then 7779a31a186aSmrg case "$libs " in 77800bb88ba4Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7781a31a186aSmrg esac 7782a31a186aSmrg fi 77830bb88ba4Smrg func_append libs " $deplib" 7784a31a186aSmrg done 7785a31a186aSmrg 7786493f84f4Smrg if test lib = "$linkmode"; then 7787a31a186aSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7788a31a186aSmrg 7789a31a186aSmrg # Compute libraries that are listed more than once in $predeps 7790a31a186aSmrg # $postdeps and mark them as special (i.e., whose duplicates are 7791a31a186aSmrg # not to be eliminated). 7792a31a186aSmrg pre_post_deps= 7793a31a186aSmrg if $opt_duplicate_compiler_generated_deps; then 7794a31a186aSmrg for pre_post_dep in $predeps $postdeps; do 7795a31a186aSmrg case "$pre_post_deps " in 77960bb88ba4Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7797a31a186aSmrg esac 77980bb88ba4Smrg func_append pre_post_deps " $pre_post_dep" 7799a31a186aSmrg done 7800a31a186aSmrg fi 7801a31a186aSmrg pre_post_deps= 7802a31a186aSmrg fi 7803a31a186aSmrg 7804a31a186aSmrg deplibs= 7805a31a186aSmrg newdependency_libs= 7806a31a186aSmrg newlib_search_path= 7807a31a186aSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 7808a31a186aSmrg notinst_deplibs= # not-installed libtool libraries 7809a31a186aSmrg notinst_path= # paths that contain not-installed libtool libraries 7810a31a186aSmrg 7811a31a186aSmrg case $linkmode in 7812a31a186aSmrg lib) 7813a31a186aSmrg passes="conv dlpreopen link" 7814a31a186aSmrg for file in $dlfiles $dlprefiles; do 7815a31a186aSmrg case $file in 7816a31a186aSmrg *.la) ;; 7817a31a186aSmrg *) 7818493f84f4Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7819a31a186aSmrg ;; 7820a31a186aSmrg esac 7821a31a186aSmrg done 7822a31a186aSmrg ;; 7823a31a186aSmrg prog) 7824a31a186aSmrg compile_deplibs= 7825a31a186aSmrg finalize_deplibs= 7826493f84f4Smrg alldeplibs=false 7827a31a186aSmrg newdlfiles= 7828a31a186aSmrg newdlprefiles= 7829a31a186aSmrg passes="conv scan dlopen dlpreopen link" 7830a31a186aSmrg ;; 7831a31a186aSmrg *) passes="conv" 7832a31a186aSmrg ;; 7833a31a186aSmrg esac 7834a31a186aSmrg 7835a31a186aSmrg for pass in $passes; do 7836a31a186aSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 7837a31a186aSmrg # so that -L comes before libs that need it for instance... 7838493f84f4Smrg if test lib,link = "$linkmode,$pass"; then 7839a31a186aSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 7840a31a186aSmrg ## order, and fix it there properly 7841a31a186aSmrg tmp_deplibs= 7842a31a186aSmrg for deplib in $deplibs; do 7843a31a186aSmrg tmp_deplibs="$deplib $tmp_deplibs" 7844a31a186aSmrg done 7845493f84f4Smrg deplibs=$tmp_deplibs 7846a31a186aSmrg fi 7847a31a186aSmrg 7848493f84f4Smrg if test lib,link = "$linkmode,$pass" || 7849493f84f4Smrg test prog,scan = "$linkmode,$pass"; then 7850493f84f4Smrg libs=$deplibs 7851a31a186aSmrg deplibs= 7852a31a186aSmrg fi 7853493f84f4Smrg if test prog = "$linkmode"; then 7854a31a186aSmrg case $pass in 7855493f84f4Smrg dlopen) libs=$dlfiles ;; 7856493f84f4Smrg dlpreopen) libs=$dlprefiles ;; 78571e423a8fSmrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7858a31a186aSmrg esac 7859a31a186aSmrg fi 7860493f84f4Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 7861a31a186aSmrg # Collect and forward deplibs of preopened libtool libs 7862a31a186aSmrg for lib in $dlprefiles; do 7863a31a186aSmrg # Ignore non-libtool-libs 7864a31a186aSmrg dependency_libs= 78650bb88ba4Smrg func_resolve_sysroot "$lib" 7866a31a186aSmrg case $lib in 78670bb88ba4Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 7868a31a186aSmrg esac 7869a31a186aSmrg 7870a31a186aSmrg # Collect preopened libtool deplibs, except any this library 7871a31a186aSmrg # has declared as weak libs 7872a31a186aSmrg for deplib in $dependency_libs; do 78730bb88ba4Smrg func_basename "$deplib" 78740bb88ba4Smrg deplib_base=$func_basename_result 7875a31a186aSmrg case " $weak_libs " in 7876a31a186aSmrg *" $deplib_base "*) ;; 78770bb88ba4Smrg *) func_append deplibs " $deplib" ;; 7878a31a186aSmrg esac 7879a31a186aSmrg done 7880a31a186aSmrg done 7881493f84f4Smrg libs=$dlprefiles 7882a31a186aSmrg fi 7883493f84f4Smrg if test dlopen = "$pass"; then 7884a31a186aSmrg # Collect dlpreopened libraries 7885493f84f4Smrg save_deplibs=$deplibs 7886a31a186aSmrg deplibs= 7887a31a186aSmrg fi 7888a31a186aSmrg 7889a31a186aSmrg for deplib in $libs; do 7890a31a186aSmrg lib= 7891493f84f4Smrg found=false 7892a31a186aSmrg case $deplib in 78930bb88ba4Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 78940bb88ba4Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7895493f84f4Smrg if test prog,link = "$linkmode,$pass"; then 7896a31a186aSmrg compile_deplibs="$deplib $compile_deplibs" 7897a31a186aSmrg finalize_deplibs="$deplib $finalize_deplibs" 7898a31a186aSmrg else 78990bb88ba4Smrg func_append compiler_flags " $deplib" 7900493f84f4Smrg if test lib = "$linkmode"; then 7901a31a186aSmrg case "$new_inherited_linker_flags " in 7902a31a186aSmrg *" $deplib "*) ;; 79030bb88ba4Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7904a31a186aSmrg esac 7905a31a186aSmrg fi 7906a31a186aSmrg fi 7907a31a186aSmrg continue 7908a31a186aSmrg ;; 7909a31a186aSmrg -l*) 7910493f84f4Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 7911493f84f4Smrg func_warning "'-l' is ignored for archives/objects" 7912a31a186aSmrg continue 7913a31a186aSmrg fi 7914a31a186aSmrg func_stripname '-l' '' "$deplib" 7915a31a186aSmrg name=$func_stripname_result 7916493f84f4Smrg if test lib = "$linkmode"; then 7917a31a186aSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7918a31a186aSmrg else 7919a31a186aSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7920a31a186aSmrg fi 7921a31a186aSmrg for searchdir in $searchdirs; do 7922a31a186aSmrg for search_ext in .la $std_shrext .so .a; do 7923a31a186aSmrg # Search the libtool library 7924493f84f4Smrg lib=$searchdir/lib$name$search_ext 7925a31a186aSmrg if test -f "$lib"; then 7926493f84f4Smrg if test .la = "$search_ext"; then 7927493f84f4Smrg found=: 7928a31a186aSmrg else 7929493f84f4Smrg found=false 7930a31a186aSmrg fi 7931a31a186aSmrg break 2 7932a31a186aSmrg fi 7933a31a186aSmrg done 7934a31a186aSmrg done 7935493f84f4Smrg if $found; then 7936493f84f4Smrg # deplib is a libtool library 7937a31a186aSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7938a31a186aSmrg # We need to do some special things here, and not later. 7939493f84f4Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7940a31a186aSmrg case " $predeps $postdeps " in 7941a31a186aSmrg *" $deplib "*) 7942a31a186aSmrg if func_lalib_p "$lib"; then 7943a31a186aSmrg library_names= 7944a31a186aSmrg old_library= 7945a31a186aSmrg func_source "$lib" 7946a31a186aSmrg for l in $old_library $library_names; do 7947493f84f4Smrg ll=$l 7948a31a186aSmrg done 7949493f84f4Smrg if test "X$ll" = "X$old_library"; then # only static version available 7950493f84f4Smrg found=false 7951a31a186aSmrg func_dirname "$lib" "" "." 7952493f84f4Smrg ladir=$func_dirname_result 7953a31a186aSmrg lib=$ladir/$old_library 7954493f84f4Smrg if test prog,link = "$linkmode,$pass"; then 7955a31a186aSmrg compile_deplibs="$deplib $compile_deplibs" 7956a31a186aSmrg finalize_deplibs="$deplib $finalize_deplibs" 7957a31a186aSmrg else 7958a31a186aSmrg deplibs="$deplib $deplibs" 7959493f84f4Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7960a31a186aSmrg fi 7961a31a186aSmrg continue 7962a31a186aSmrg fi 7963a31a186aSmrg fi 7964a31a186aSmrg ;; 7965a31a186aSmrg *) ;; 7966a31a186aSmrg esac 7967a31a186aSmrg fi 7968493f84f4Smrg else 7969493f84f4Smrg # deplib doesn't seem to be a libtool library 7970493f84f4Smrg if test prog,link = "$linkmode,$pass"; then 7971493f84f4Smrg compile_deplibs="$deplib $compile_deplibs" 7972493f84f4Smrg finalize_deplibs="$deplib $finalize_deplibs" 7973493f84f4Smrg else 7974493f84f4Smrg deplibs="$deplib $deplibs" 7975493f84f4Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7976493f84f4Smrg fi 7977493f84f4Smrg continue 7978a31a186aSmrg fi 7979a31a186aSmrg ;; # -l 7980a31a186aSmrg *.ltframework) 7981493f84f4Smrg if test prog,link = "$linkmode,$pass"; then 7982a31a186aSmrg compile_deplibs="$deplib $compile_deplibs" 7983a31a186aSmrg finalize_deplibs="$deplib $finalize_deplibs" 7984a31a186aSmrg else 7985a31a186aSmrg deplibs="$deplib $deplibs" 7986493f84f4Smrg if test lib = "$linkmode"; then 7987a31a186aSmrg case "$new_inherited_linker_flags " in 7988a31a186aSmrg *" $deplib "*) ;; 79890bb88ba4Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7990a31a186aSmrg esac 7991a31a186aSmrg fi 7992a31a186aSmrg fi 7993a31a186aSmrg continue 7994a31a186aSmrg ;; 7995a31a186aSmrg -L*) 7996a31a186aSmrg case $linkmode in 7997a31a186aSmrg lib) 7998a31a186aSmrg deplibs="$deplib $deplibs" 7999493f84f4Smrg test conv = "$pass" && continue 8000a31a186aSmrg newdependency_libs="$deplib $newdependency_libs" 8001a31a186aSmrg func_stripname '-L' '' "$deplib" 80020bb88ba4Smrg func_resolve_sysroot "$func_stripname_result" 80030bb88ba4Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8004a31a186aSmrg ;; 8005a31a186aSmrg prog) 8006493f84f4Smrg if test conv = "$pass"; then 8007a31a186aSmrg deplibs="$deplib $deplibs" 8008a31a186aSmrg continue 8009a31a186aSmrg fi 8010493f84f4Smrg if test scan = "$pass"; then 8011a31a186aSmrg deplibs="$deplib $deplibs" 8012a31a186aSmrg else 8013a31a186aSmrg compile_deplibs="$deplib $compile_deplibs" 8014a31a186aSmrg finalize_deplibs="$deplib $finalize_deplibs" 8015a31a186aSmrg fi 8016a31a186aSmrg func_stripname '-L' '' "$deplib" 80170bb88ba4Smrg func_resolve_sysroot "$func_stripname_result" 80180bb88ba4Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8019a31a186aSmrg ;; 8020a31a186aSmrg *) 8021493f84f4Smrg func_warning "'-L' is ignored for archives/objects" 8022a31a186aSmrg ;; 8023a31a186aSmrg esac # linkmode 8024a31a186aSmrg continue 8025a31a186aSmrg ;; # -L 8026a31a186aSmrg -R*) 8027493f84f4Smrg if test link = "$pass"; then 8028a31a186aSmrg func_stripname '-R' '' "$deplib" 80290bb88ba4Smrg func_resolve_sysroot "$func_stripname_result" 80300bb88ba4Smrg dir=$func_resolve_sysroot_result 8031a31a186aSmrg # Make sure the xrpath contains only unique directories. 8032a31a186aSmrg case "$xrpath " in 8033a31a186aSmrg *" $dir "*) ;; 80340bb88ba4Smrg *) func_append xrpath " $dir" ;; 8035a31a186aSmrg esac 8036a31a186aSmrg fi 8037a31a186aSmrg deplibs="$deplib $deplibs" 8038a31a186aSmrg continue 8039a31a186aSmrg ;; 80400bb88ba4Smrg *.la) 80410bb88ba4Smrg func_resolve_sysroot "$deplib" 80420bb88ba4Smrg lib=$func_resolve_sysroot_result 80430bb88ba4Smrg ;; 8044a31a186aSmrg *.$libext) 8045493f84f4Smrg if test conv = "$pass"; then 8046a31a186aSmrg deplibs="$deplib $deplibs" 8047a31a186aSmrg continue 8048a31a186aSmrg fi 8049a31a186aSmrg case $linkmode in 8050a31a186aSmrg lib) 8051a31a186aSmrg # Linking convenience modules into shared libraries is allowed, 8052a31a186aSmrg # but linking other static libraries is non-portable. 8053a31a186aSmrg case " $dlpreconveniencelibs " in 8054a31a186aSmrg *" $deplib "*) ;; 8055a31a186aSmrg *) 8056493f84f4Smrg valid_a_lib=false 8057a31a186aSmrg case $deplibs_check_method in 8058a31a186aSmrg match_pattern*) 8059a31a186aSmrg set dummy $deplibs_check_method; shift 8060a31a186aSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 80610bb88ba4Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 8062a31a186aSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 8063493f84f4Smrg valid_a_lib=: 8064a31a186aSmrg fi 8065a31a186aSmrg ;; 8066a31a186aSmrg pass_all) 8067493f84f4Smrg valid_a_lib=: 8068a31a186aSmrg ;; 8069a31a186aSmrg esac 8070493f84f4Smrg if $valid_a_lib; then 8071493f84f4Smrg echo 8072493f84f4Smrg $ECHO "*** Warning: Linking the shared library $output against the" 8073493f84f4Smrg $ECHO "*** static library $deplib is not portable!" 8074493f84f4Smrg deplibs="$deplib $deplibs" 8075493f84f4Smrg else 80760bb88ba4Smrg echo 8077a31a186aSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 80780bb88ba4Smrg echo "*** I have the capability to make that library automatically link in when" 80790bb88ba4Smrg echo "*** you link to this library. But I can only do this if you have a" 80800bb88ba4Smrg echo "*** shared version of the library, which you do not appear to have" 80810bb88ba4Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 80820bb88ba4Smrg echo "*** that it is just a static archive that I should not use here." 8083a31a186aSmrg fi 8084a31a186aSmrg ;; 8085a31a186aSmrg esac 8086a31a186aSmrg continue 8087a31a186aSmrg ;; 8088a31a186aSmrg prog) 8089493f84f4Smrg if test link != "$pass"; then 8090a31a186aSmrg deplibs="$deplib $deplibs" 8091a31a186aSmrg else 8092a31a186aSmrg compile_deplibs="$deplib $compile_deplibs" 8093a31a186aSmrg finalize_deplibs="$deplib $finalize_deplibs" 8094a31a186aSmrg fi 8095a31a186aSmrg continue 8096a31a186aSmrg ;; 8097a31a186aSmrg esac # linkmode 8098a31a186aSmrg ;; # *.$libext 8099a31a186aSmrg *.lo | *.$objext) 8100493f84f4Smrg if test conv = "$pass"; then 8101a31a186aSmrg deplibs="$deplib $deplibs" 8102493f84f4Smrg elif test prog = "$linkmode"; then 8103493f84f4Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 8104a31a186aSmrg # If there is no dlopen support or we're linking statically, 8105a31a186aSmrg # we need to preload. 81060bb88ba4Smrg func_append newdlprefiles " $deplib" 8107a31a186aSmrg compile_deplibs="$deplib $compile_deplibs" 8108a31a186aSmrg finalize_deplibs="$deplib $finalize_deplibs" 8109a31a186aSmrg else 81100bb88ba4Smrg func_append newdlfiles " $deplib" 8111a31a186aSmrg fi 8112a31a186aSmrg fi 8113a31a186aSmrg continue 8114a31a186aSmrg ;; 8115a31a186aSmrg %DEPLIBS%) 8116493f84f4Smrg alldeplibs=: 8117a31a186aSmrg continue 8118a31a186aSmrg ;; 8119a31a186aSmrg esac # case $deplib 8120a31a186aSmrg 8121493f84f4Smrg $found || test -f "$lib" \ 8122493f84f4Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 8123a31a186aSmrg 8124a31a186aSmrg # Check to see that this really is a libtool archive. 8125a31a186aSmrg func_lalib_unsafe_p "$lib" \ 8126493f84f4Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 8127a31a186aSmrg 8128a31a186aSmrg func_dirname "$lib" "" "." 8129493f84f4Smrg ladir=$func_dirname_result 8130a31a186aSmrg 8131a31a186aSmrg dlname= 8132a31a186aSmrg dlopen= 8133a31a186aSmrg dlpreopen= 8134a31a186aSmrg libdir= 8135a31a186aSmrg library_names= 8136a31a186aSmrg old_library= 8137a31a186aSmrg inherited_linker_flags= 8138a31a186aSmrg # If the library was installed with an old release of libtool, 8139a31a186aSmrg # it will not redefine variables installed, or shouldnotlink 8140a31a186aSmrg installed=yes 8141a31a186aSmrg shouldnotlink=no 8142a31a186aSmrg avoidtemprpath= 8143a31a186aSmrg 8144a31a186aSmrg 8145a31a186aSmrg # Read the .la file 8146a31a186aSmrg func_source "$lib" 8147a31a186aSmrg 8148a31a186aSmrg # Convert "-framework foo" to "foo.ltframework" 8149a31a186aSmrg if test -n "$inherited_linker_flags"; then 81500bb88ba4Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 8151a31a186aSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 8152a31a186aSmrg case " $new_inherited_linker_flags " in 8153a31a186aSmrg *" $tmp_inherited_linker_flag "*) ;; 81540bb88ba4Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 8155a31a186aSmrg esac 8156a31a186aSmrg done 8157a31a186aSmrg fi 81580bb88ba4Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8159493f84f4Smrg if test lib,link = "$linkmode,$pass" || 8160493f84f4Smrg test prog,scan = "$linkmode,$pass" || 8161493f84f4Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 81620bb88ba4Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 81630bb88ba4Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 8164a31a186aSmrg fi 8165a31a186aSmrg 8166493f84f4Smrg if test conv = "$pass"; then 8167a31a186aSmrg # Only check for convenience libraries 8168a31a186aSmrg deplibs="$lib $deplibs" 8169a31a186aSmrg if test -z "$libdir"; then 8170a31a186aSmrg if test -z "$old_library"; then 8171493f84f4Smrg func_fatal_error "cannot find name of link library for '$lib'" 8172a31a186aSmrg fi 8173a31a186aSmrg # It is a libtool convenience library, so add in its objects. 81740bb88ba4Smrg func_append convenience " $ladir/$objdir/$old_library" 81750bb88ba4Smrg func_append old_convenience " $ladir/$objdir/$old_library" 8176493f84f4Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 8177493f84f4Smrg func_fatal_error "'$lib' is not a convenience library" 8178a31a186aSmrg fi 81791e423a8fSmrg tmp_libs= 81801e423a8fSmrg for deplib in $dependency_libs; do 81811e423a8fSmrg deplibs="$deplib $deplibs" 81821e423a8fSmrg if $opt_preserve_dup_deps; then 81831e423a8fSmrg case "$tmp_libs " in 81841e423a8fSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 81851e423a8fSmrg esac 81861e423a8fSmrg fi 81871e423a8fSmrg func_append tmp_libs " $deplib" 81881e423a8fSmrg done 8189a31a186aSmrg continue 8190a31a186aSmrg fi # $pass = conv 8191a31a186aSmrg 8192a31a186aSmrg 8193a31a186aSmrg # Get the name of the library we link against. 8194a31a186aSmrg linklib= 81950bb88ba4Smrg if test -n "$old_library" && 8196493f84f4Smrg { test yes = "$prefer_static_libs" || 8197493f84f4Smrg test built,no = "$prefer_static_libs,$installed"; }; then 81980bb88ba4Smrg linklib=$old_library 81990bb88ba4Smrg else 82000bb88ba4Smrg for l in $old_library $library_names; do 8201493f84f4Smrg linklib=$l 82020bb88ba4Smrg done 82030bb88ba4Smrg fi 8204a31a186aSmrg if test -z "$linklib"; then 8205493f84f4Smrg func_fatal_error "cannot find name of link library for '$lib'" 8206a31a186aSmrg fi 8207a31a186aSmrg 8208a31a186aSmrg # This library was specified with -dlopen. 8209493f84f4Smrg if test dlopen = "$pass"; then 8210493f84f4Smrg test -z "$libdir" \ 8211493f84f4Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 8212a31a186aSmrg if test -z "$dlname" || 8213493f84f4Smrg test yes != "$dlopen_support" || 8214493f84f4Smrg test no = "$build_libtool_libs" 8215493f84f4Smrg then 8216a31a186aSmrg # If there is no dlname, no dlopen support or we're linking 8217a31a186aSmrg # statically, we need to preload. We also need to preload any 8218a31a186aSmrg # dependent libraries so libltdl's deplib preloader doesn't 8219a31a186aSmrg # bomb out in the load deplibs phase. 82200bb88ba4Smrg func_append dlprefiles " $lib $dependency_libs" 8221a31a186aSmrg else 82220bb88ba4Smrg func_append newdlfiles " $lib" 8223a31a186aSmrg fi 8224a31a186aSmrg continue 8225a31a186aSmrg fi # $pass = dlopen 8226a31a186aSmrg 8227a31a186aSmrg # We need an absolute path. 8228a31a186aSmrg case $ladir in 8229493f84f4Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 8230a31a186aSmrg *) 8231a31a186aSmrg abs_ladir=`cd "$ladir" && pwd` 8232a31a186aSmrg if test -z "$abs_ladir"; then 8233493f84f4Smrg func_warning "cannot determine absolute directory name of '$ladir'" 8234a31a186aSmrg func_warning "passing it literally to the linker, although it might fail" 8235493f84f4Smrg abs_ladir=$ladir 8236a31a186aSmrg fi 8237a31a186aSmrg ;; 8238a31a186aSmrg esac 8239a31a186aSmrg func_basename "$lib" 8240493f84f4Smrg laname=$func_basename_result 8241a31a186aSmrg 8242a31a186aSmrg # Find the relevant object directory and library name. 8243493f84f4Smrg if test yes = "$installed"; then 82440bb88ba4Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8245493f84f4Smrg func_warning "library '$lib' was moved." 8246493f84f4Smrg dir=$ladir 8247493f84f4Smrg absdir=$abs_ladir 8248493f84f4Smrg libdir=$abs_ladir 8249a31a186aSmrg else 8250493f84f4Smrg dir=$lt_sysroot$libdir 8251493f84f4Smrg absdir=$lt_sysroot$libdir 8252a31a186aSmrg fi 8253493f84f4Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 8254a31a186aSmrg else 8255a31a186aSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8256493f84f4Smrg dir=$ladir 8257493f84f4Smrg absdir=$abs_ladir 8258a31a186aSmrg # Remove this search path later 82590bb88ba4Smrg func_append notinst_path " $abs_ladir" 8260a31a186aSmrg else 8261493f84f4Smrg dir=$ladir/$objdir 8262493f84f4Smrg absdir=$abs_ladir/$objdir 8263a31a186aSmrg # Remove this search path later 82640bb88ba4Smrg func_append notinst_path " $abs_ladir" 8265a31a186aSmrg fi 8266a31a186aSmrg fi # $installed = yes 8267a31a186aSmrg func_stripname 'lib' '.la' "$laname" 8268a31a186aSmrg name=$func_stripname_result 8269a31a186aSmrg 8270a31a186aSmrg # This library was specified with -dlpreopen. 8271493f84f4Smrg if test dlpreopen = "$pass"; then 8272493f84f4Smrg if test -z "$libdir" && test prog = "$linkmode"; then 8273493f84f4Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 8274a31a186aSmrg fi 8275493f84f4Smrg case $host in 82760bb88ba4Smrg # special handling for platforms with PE-DLLs. 82770bb88ba4Smrg *cygwin* | *mingw* | *cegcc* ) 82780bb88ba4Smrg # Linker will automatically link against shared library if both 82790bb88ba4Smrg # static and shared are present. Therefore, ensure we extract 82800bb88ba4Smrg # symbols from the import library if a shared library is present 82810bb88ba4Smrg # (otherwise, the dlopen module name will be incorrect). We do 82820bb88ba4Smrg # this by putting the import library name into $newdlprefiles. 82830bb88ba4Smrg # We recover the dlopen module name by 'saving' the la file 82840bb88ba4Smrg # name in a special purpose variable, and (later) extracting the 82850bb88ba4Smrg # dlname from the la file. 82860bb88ba4Smrg if test -n "$dlname"; then 82870bb88ba4Smrg func_tr_sh "$dir/$linklib" 82880bb88ba4Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 82890bb88ba4Smrg func_append newdlprefiles " $dir/$linklib" 82900bb88ba4Smrg else 82910bb88ba4Smrg func_append newdlprefiles " $dir/$old_library" 82920bb88ba4Smrg # Keep a list of preopened convenience libraries to check 82930bb88ba4Smrg # that they are being used correctly in the link pass. 82940bb88ba4Smrg test -z "$libdir" && \ 82950bb88ba4Smrg func_append dlpreconveniencelibs " $dir/$old_library" 82960bb88ba4Smrg fi 82970bb88ba4Smrg ;; 82980bb88ba4Smrg * ) 82990bb88ba4Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 83000bb88ba4Smrg # are required to link). 83010bb88ba4Smrg if test -n "$old_library"; then 83020bb88ba4Smrg func_append newdlprefiles " $dir/$old_library" 83030bb88ba4Smrg # Keep a list of preopened convenience libraries to check 83040bb88ba4Smrg # that they are being used correctly in the link pass. 83050bb88ba4Smrg test -z "$libdir" && \ 83060bb88ba4Smrg func_append dlpreconveniencelibs " $dir/$old_library" 83070bb88ba4Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 83080bb88ba4Smrg elif test -n "$dlname"; then 83090bb88ba4Smrg func_append newdlprefiles " $dir/$dlname" 83100bb88ba4Smrg else 83110bb88ba4Smrg func_append newdlprefiles " $dir/$linklib" 83120bb88ba4Smrg fi 83130bb88ba4Smrg ;; 83140bb88ba4Smrg esac 8315a31a186aSmrg fi # $pass = dlpreopen 8316a31a186aSmrg 8317a31a186aSmrg if test -z "$libdir"; then 8318a31a186aSmrg # Link the convenience library 8319493f84f4Smrg if test lib = "$linkmode"; then 8320a31a186aSmrg deplibs="$dir/$old_library $deplibs" 8321493f84f4Smrg elif test prog,link = "$linkmode,$pass"; then 8322a31a186aSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 8323a31a186aSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8324a31a186aSmrg else 8325a31a186aSmrg deplibs="$lib $deplibs" # used for prog,scan pass 8326a31a186aSmrg fi 8327a31a186aSmrg continue 8328a31a186aSmrg fi 8329a31a186aSmrg 8330a31a186aSmrg 8331493f84f4Smrg if test prog = "$linkmode" && test link != "$pass"; then 83320bb88ba4Smrg func_append newlib_search_path " $ladir" 8333a31a186aSmrg deplibs="$lib $deplibs" 8334a31a186aSmrg 8335493f84f4Smrg linkalldeplibs=false 8336493f84f4Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 8337493f84f4Smrg test no = "$build_libtool_libs"; then 8338493f84f4Smrg linkalldeplibs=: 8339a31a186aSmrg fi 8340a31a186aSmrg 8341a31a186aSmrg tmp_libs= 8342a31a186aSmrg for deplib in $dependency_libs; do 8343a31a186aSmrg case $deplib in 8344a31a186aSmrg -L*) func_stripname '-L' '' "$deplib" 83450bb88ba4Smrg func_resolve_sysroot "$func_stripname_result" 83460bb88ba4Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8347a31a186aSmrg ;; 8348a31a186aSmrg esac 8349a31a186aSmrg # Need to link against all dependency_libs? 8350493f84f4Smrg if $linkalldeplibs; then 8351a31a186aSmrg deplibs="$deplib $deplibs" 8352a31a186aSmrg else 8353a31a186aSmrg # Need to hardcode shared library paths 8354a31a186aSmrg # or/and link against static libraries 8355a31a186aSmrg newdependency_libs="$deplib $newdependency_libs" 8356a31a186aSmrg fi 8357493f84f4Smrg if $opt_preserve_dup_deps; then 8358a31a186aSmrg case "$tmp_libs " in 83590bb88ba4Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8360a31a186aSmrg esac 8361a31a186aSmrg fi 83620bb88ba4Smrg func_append tmp_libs " $deplib" 8363a31a186aSmrg done # for deplib 8364a31a186aSmrg continue 8365a31a186aSmrg fi # $linkmode = prog... 8366a31a186aSmrg 8367493f84f4Smrg if test prog,link = "$linkmode,$pass"; then 8368a31a186aSmrg if test -n "$library_names" && 8369493f84f4Smrg { { test no = "$prefer_static_libs" || 8370493f84f4Smrg test built,yes = "$prefer_static_libs,$installed"; } || 8371a31a186aSmrg test -z "$old_library"; }; then 8372a31a186aSmrg # We need to hardcode the library path 8373493f84f4Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8374a31a186aSmrg # Make sure the rpath contains only unique directories. 8375493f84f4Smrg case $temp_rpath: in 8376a31a186aSmrg *"$absdir:"*) ;; 83770bb88ba4Smrg *) func_append temp_rpath "$absdir:" ;; 8378a31a186aSmrg esac 8379a31a186aSmrg fi 8380a31a186aSmrg 8381a31a186aSmrg # Hardcode the library path. 8382a31a186aSmrg # Skip directories that are in the system default run-time 8383a31a186aSmrg # search path. 8384a31a186aSmrg case " $sys_lib_dlsearch_path " in 8385a31a186aSmrg *" $absdir "*) ;; 8386a31a186aSmrg *) 8387a31a186aSmrg case "$compile_rpath " in 8388a31a186aSmrg *" $absdir "*) ;; 83890bb88ba4Smrg *) func_append compile_rpath " $absdir" ;; 8390a31a186aSmrg esac 8391a31a186aSmrg ;; 8392a31a186aSmrg esac 8393a31a186aSmrg case " $sys_lib_dlsearch_path " in 8394a31a186aSmrg *" $libdir "*) ;; 8395a31a186aSmrg *) 8396a31a186aSmrg case "$finalize_rpath " in 8397a31a186aSmrg *" $libdir "*) ;; 83980bb88ba4Smrg *) func_append finalize_rpath " $libdir" ;; 8399a31a186aSmrg esac 8400a31a186aSmrg ;; 8401a31a186aSmrg esac 8402a31a186aSmrg fi # $linkmode,$pass = prog,link... 8403a31a186aSmrg 8404493f84f4Smrg if $alldeplibs && 8405493f84f4Smrg { test pass_all = "$deplibs_check_method" || 8406493f84f4Smrg { test yes = "$build_libtool_libs" && 8407a31a186aSmrg test -n "$library_names"; }; }; then 8408a31a186aSmrg # We only need to search for static libraries 8409a31a186aSmrg continue 8410a31a186aSmrg fi 8411a31a186aSmrg fi 8412a31a186aSmrg 8413a31a186aSmrg link_static=no # Whether the deplib will be linked statically 8414a31a186aSmrg use_static_libs=$prefer_static_libs 8415493f84f4Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 8416a31a186aSmrg use_static_libs=no 8417a31a186aSmrg fi 8418a31a186aSmrg if test -n "$library_names" && 8419493f84f4Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8420a31a186aSmrg case $host in 8421493f84f4Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 8422a31a186aSmrg # No point in relinking DLLs because paths are not encoded 84230bb88ba4Smrg func_append notinst_deplibs " $lib" 8424a31a186aSmrg need_relink=no 8425a31a186aSmrg ;; 8426a31a186aSmrg *) 8427493f84f4Smrg if test no = "$installed"; then 84280bb88ba4Smrg func_append notinst_deplibs " $lib" 8429a31a186aSmrg need_relink=yes 8430a31a186aSmrg fi 8431a31a186aSmrg ;; 8432a31a186aSmrg esac 8433a31a186aSmrg # This is a shared library 8434a31a186aSmrg 8435a31a186aSmrg # Warn about portability, can't link against -module's on some 8436a31a186aSmrg # systems (darwin). Don't bleat about dlopened modules though! 8437493f84f4Smrg dlopenmodule= 8438a31a186aSmrg for dlpremoduletest in $dlprefiles; do 8439a31a186aSmrg if test "X$dlpremoduletest" = "X$lib"; then 8440493f84f4Smrg dlopenmodule=$dlpremoduletest 8441a31a186aSmrg break 8442a31a186aSmrg fi 8443a31a186aSmrg done 8444493f84f4Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 84450bb88ba4Smrg echo 8446493f84f4Smrg if test prog = "$linkmode"; then 8447a31a186aSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8448a31a186aSmrg else 8449a31a186aSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8450a31a186aSmrg fi 8451a31a186aSmrg $ECHO "*** $linklib is not portable!" 8452a31a186aSmrg fi 8453493f84f4Smrg if test lib = "$linkmode" && 8454493f84f4Smrg test yes = "$hardcode_into_libs"; then 8455a31a186aSmrg # Hardcode the library path. 8456a31a186aSmrg # Skip directories that are in the system default run-time 8457a31a186aSmrg # search path. 8458a31a186aSmrg case " $sys_lib_dlsearch_path " in 8459a31a186aSmrg *" $absdir "*) ;; 8460a31a186aSmrg *) 8461a31a186aSmrg case "$compile_rpath " in 8462a31a186aSmrg *" $absdir "*) ;; 84630bb88ba4Smrg *) func_append compile_rpath " $absdir" ;; 8464a31a186aSmrg esac 8465a31a186aSmrg ;; 8466a31a186aSmrg esac 8467a31a186aSmrg case " $sys_lib_dlsearch_path " in 8468a31a186aSmrg *" $libdir "*) ;; 8469a31a186aSmrg *) 8470a31a186aSmrg case "$finalize_rpath " in 8471a31a186aSmrg *" $libdir "*) ;; 84720bb88ba4Smrg *) func_append finalize_rpath " $libdir" ;; 8473a31a186aSmrg esac 8474a31a186aSmrg ;; 8475a31a186aSmrg esac 8476a31a186aSmrg fi 8477a31a186aSmrg 8478a31a186aSmrg if test -n "$old_archive_from_expsyms_cmds"; then 8479a31a186aSmrg # figure out the soname 8480a31a186aSmrg set dummy $library_names 8481a31a186aSmrg shift 8482493f84f4Smrg realname=$1 8483a31a186aSmrg shift 8484a31a186aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 8485a31a186aSmrg # use dlname if we got it. it's perfectly good, no? 8486a31a186aSmrg if test -n "$dlname"; then 8487493f84f4Smrg soname=$dlname 8488a31a186aSmrg elif test -n "$soname_spec"; then 8489a31a186aSmrg # bleh windows 8490a31a186aSmrg case $host in 8491493f84f4Smrg *cygwin* | mingw* | *cegcc* | *os2*) 8492a31a186aSmrg func_arith $current - $age 8493a31a186aSmrg major=$func_arith_result 8494493f84f4Smrg versuffix=-$major 8495a31a186aSmrg ;; 8496a31a186aSmrg esac 8497a31a186aSmrg eval soname=\"$soname_spec\" 8498a31a186aSmrg else 8499493f84f4Smrg soname=$realname 8500a31a186aSmrg fi 8501a31a186aSmrg 8502a31a186aSmrg # Make a new name for the extract_expsyms_cmds to use 8503493f84f4Smrg soroot=$soname 8504a31a186aSmrg func_basename "$soroot" 8505493f84f4Smrg soname=$func_basename_result 8506a31a186aSmrg func_stripname 'lib' '.dll' "$soname" 8507a31a186aSmrg newlib=libimp-$func_stripname_result.a 8508a31a186aSmrg 8509a31a186aSmrg # If the library has no export list, then create one now 8510a31a186aSmrg if test -f "$output_objdir/$soname-def"; then : 8511a31a186aSmrg else 8512493f84f4Smrg func_verbose "extracting exported symbol list from '$soname'" 8513a31a186aSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8514a31a186aSmrg fi 8515a31a186aSmrg 8516a31a186aSmrg # Create $newlib 8517a31a186aSmrg if test -f "$output_objdir/$newlib"; then :; else 8518493f84f4Smrg func_verbose "generating import library for '$soname'" 8519a31a186aSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8520a31a186aSmrg fi 8521a31a186aSmrg # make sure the library variables are pointing to the new library 8522a31a186aSmrg dir=$output_objdir 8523a31a186aSmrg linklib=$newlib 8524a31a186aSmrg fi # test -n "$old_archive_from_expsyms_cmds" 8525a31a186aSmrg 8526493f84f4Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8527a31a186aSmrg add_shlibpath= 8528a31a186aSmrg add_dir= 8529a31a186aSmrg add= 8530a31a186aSmrg lib_linked=yes 8531a31a186aSmrg case $hardcode_action in 8532a31a186aSmrg immediate | unsupported) 8533493f84f4Smrg if test no = "$hardcode_direct"; then 8534493f84f4Smrg add=$dir/$linklib 8535a31a186aSmrg case $host in 8536493f84f4Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8537493f84f4Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8538a31a186aSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8539493f84f4Smrg *-*-unixware7*) add_dir=-L$dir ;; 8540a31a186aSmrg *-*-darwin* ) 8541493f84f4Smrg # if the lib is a (non-dlopened) module then we cannot 8542a31a186aSmrg # link against it, someone is ignoring the earlier warnings 8543a31a186aSmrg if /usr/bin/file -L $add 2> /dev/null | 8544493f84f4Smrg $GREP ": [^:]* bundle" >/dev/null; then 8545a31a186aSmrg if test "X$dlopenmodule" != "X$lib"; then 8546a31a186aSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8547493f84f4Smrg if test -z "$old_library"; then 85480bb88ba4Smrg echo 85490bb88ba4Smrg echo "*** And there doesn't seem to be a static archive available" 85500bb88ba4Smrg echo "*** The link will probably fail, sorry" 8551a31a186aSmrg else 8552493f84f4Smrg add=$dir/$old_library 8553a31a186aSmrg fi 8554a31a186aSmrg elif test -n "$old_library"; then 8555493f84f4Smrg add=$dir/$old_library 8556a31a186aSmrg fi 8557a31a186aSmrg fi 8558a31a186aSmrg esac 8559493f84f4Smrg elif test no = "$hardcode_minus_L"; then 8560a31a186aSmrg case $host in 8561493f84f4Smrg *-*-sunos*) add_shlibpath=$dir ;; 8562a31a186aSmrg esac 8563493f84f4Smrg add_dir=-L$dir 8564493f84f4Smrg add=-l$name 8565493f84f4Smrg elif test no = "$hardcode_shlibpath_var"; then 8566493f84f4Smrg add_shlibpath=$dir 8567493f84f4Smrg add=-l$name 8568a31a186aSmrg else 8569a31a186aSmrg lib_linked=no 8570a31a186aSmrg fi 8571a31a186aSmrg ;; 8572a31a186aSmrg relink) 8573493f84f4Smrg if test yes = "$hardcode_direct" && 8574493f84f4Smrg test no = "$hardcode_direct_absolute"; then 8575493f84f4Smrg add=$dir/$linklib 8576493f84f4Smrg elif test yes = "$hardcode_minus_L"; then 8577493f84f4Smrg add_dir=-L$absdir 8578a31a186aSmrg # Try looking first in the location we're being installed to. 8579a31a186aSmrg if test -n "$inst_prefix_dir"; then 8580a31a186aSmrg case $libdir in 8581a31a186aSmrg [\\/]*) 85820bb88ba4Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8583a31a186aSmrg ;; 8584a31a186aSmrg esac 8585a31a186aSmrg fi 8586493f84f4Smrg add=-l$name 8587493f84f4Smrg elif test yes = "$hardcode_shlibpath_var"; then 8588493f84f4Smrg add_shlibpath=$dir 8589493f84f4Smrg add=-l$name 8590a31a186aSmrg else 8591a31a186aSmrg lib_linked=no 8592a31a186aSmrg fi 8593a31a186aSmrg ;; 8594a31a186aSmrg *) lib_linked=no ;; 8595a31a186aSmrg esac 8596a31a186aSmrg 8597493f84f4Smrg if test yes != "$lib_linked"; then 8598a31a186aSmrg func_fatal_configuration "unsupported hardcode properties" 8599a31a186aSmrg fi 8600a31a186aSmrg 8601a31a186aSmrg if test -n "$add_shlibpath"; then 8602a31a186aSmrg case :$compile_shlibpath: in 8603a31a186aSmrg *":$add_shlibpath:"*) ;; 86040bb88ba4Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8605a31a186aSmrg esac 8606a31a186aSmrg fi 8607493f84f4Smrg if test prog = "$linkmode"; then 8608a31a186aSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8609a31a186aSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8610a31a186aSmrg else 8611a31a186aSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8612a31a186aSmrg test -n "$add" && deplibs="$add $deplibs" 8613493f84f4Smrg if test yes != "$hardcode_direct" && 8614493f84f4Smrg test yes != "$hardcode_minus_L" && 8615493f84f4Smrg test yes = "$hardcode_shlibpath_var"; then 8616a31a186aSmrg case :$finalize_shlibpath: in 8617a31a186aSmrg *":$libdir:"*) ;; 86180bb88ba4Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8619a31a186aSmrg esac 8620a31a186aSmrg fi 8621a31a186aSmrg fi 8622a31a186aSmrg fi 8623a31a186aSmrg 8624493f84f4Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8625a31a186aSmrg add_shlibpath= 8626a31a186aSmrg add_dir= 8627a31a186aSmrg add= 8628a31a186aSmrg # Finalize command for both is simple: just hardcode it. 8629493f84f4Smrg if test yes = "$hardcode_direct" && 8630493f84f4Smrg test no = "$hardcode_direct_absolute"; then 8631493f84f4Smrg add=$libdir/$linklib 8632493f84f4Smrg elif test yes = "$hardcode_minus_L"; then 8633493f84f4Smrg add_dir=-L$libdir 8634493f84f4Smrg add=-l$name 8635493f84f4Smrg elif test yes = "$hardcode_shlibpath_var"; then 8636a31a186aSmrg case :$finalize_shlibpath: in 8637a31a186aSmrg *":$libdir:"*) ;; 86380bb88ba4Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8639a31a186aSmrg esac 8640493f84f4Smrg add=-l$name 8641493f84f4Smrg elif test yes = "$hardcode_automatic"; then 8642a31a186aSmrg if test -n "$inst_prefix_dir" && 8643493f84f4Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 8644493f84f4Smrg add=$inst_prefix_dir$libdir/$linklib 8645a31a186aSmrg else 8646493f84f4Smrg add=$libdir/$linklib 8647a31a186aSmrg fi 8648a31a186aSmrg else 8649a31a186aSmrg # We cannot seem to hardcode it, guess we'll fake it. 8650493f84f4Smrg add_dir=-L$libdir 8651a31a186aSmrg # Try looking first in the location we're being installed to. 8652a31a186aSmrg if test -n "$inst_prefix_dir"; then 8653a31a186aSmrg case $libdir in 8654a31a186aSmrg [\\/]*) 86550bb88ba4Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8656a31a186aSmrg ;; 8657a31a186aSmrg esac 8658a31a186aSmrg fi 8659493f84f4Smrg add=-l$name 8660a31a186aSmrg fi 8661a31a186aSmrg 8662493f84f4Smrg if test prog = "$linkmode"; then 8663a31a186aSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8664a31a186aSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8665a31a186aSmrg else 8666a31a186aSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8667a31a186aSmrg test -n "$add" && deplibs="$add $deplibs" 8668a31a186aSmrg fi 8669a31a186aSmrg fi 8670493f84f4Smrg elif test prog = "$linkmode"; then 8671a31a186aSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8672a31a186aSmrg # is not unsupported. This is valid on all known static and 8673a31a186aSmrg # shared platforms. 8674493f84f4Smrg if test unsupported != "$hardcode_direct"; then 8675493f84f4Smrg test -n "$old_library" && linklib=$old_library 8676a31a186aSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 8677a31a186aSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8678a31a186aSmrg else 8679a31a186aSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8680a31a186aSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8681a31a186aSmrg fi 8682493f84f4Smrg elif test yes = "$build_libtool_libs"; then 8683a31a186aSmrg # Not a shared library 8684493f84f4Smrg if test pass_all != "$deplibs_check_method"; then 8685a31a186aSmrg # We're trying link a shared library against a static one 8686a31a186aSmrg # but the system doesn't support it. 8687a31a186aSmrg 8688a31a186aSmrg # Just print a warning and add the library to dependency_libs so 8689a31a186aSmrg # that the program can be linked against the static library. 86900bb88ba4Smrg echo 8691493f84f4Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 86920bb88ba4Smrg echo "*** I have the capability to make that library automatically link in when" 86930bb88ba4Smrg echo "*** you link to this library. But I can only do this if you have a" 86940bb88ba4Smrg echo "*** shared version of the library, which you do not appear to have." 8695493f84f4Smrg if test yes = "$module"; then 86960bb88ba4Smrg echo "*** But as you try to build a module library, libtool will still create " 86970bb88ba4Smrg echo "*** a static module, that should work as long as the dlopening application" 86980bb88ba4Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8699a31a186aSmrg if test -z "$global_symbol_pipe"; then 87000bb88ba4Smrg echo 87010bb88ba4Smrg echo "*** However, this would only work if libtool was able to extract symbol" 8702493f84f4Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 87030bb88ba4Smrg echo "*** not find such a program. So, this module is probably useless." 8704493f84f4Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8705a31a186aSmrg fi 8706493f84f4Smrg if test no = "$build_old_libs"; then 8707a31a186aSmrg build_libtool_libs=module 8708a31a186aSmrg build_old_libs=yes 8709a31a186aSmrg else 8710a31a186aSmrg build_libtool_libs=no 8711a31a186aSmrg fi 8712a31a186aSmrg fi 8713a31a186aSmrg else 8714a31a186aSmrg deplibs="$dir/$old_library $deplibs" 8715a31a186aSmrg link_static=yes 8716a31a186aSmrg fi 8717a31a186aSmrg fi # link shared/static library? 8718a31a186aSmrg 8719493f84f4Smrg if test lib = "$linkmode"; then 8720a31a186aSmrg if test -n "$dependency_libs" && 8721493f84f4Smrg { test yes != "$hardcode_into_libs" || 8722493f84f4Smrg test yes = "$build_old_libs" || 8723493f84f4Smrg test yes = "$link_static"; }; then 8724a31a186aSmrg # Extract -R from dependency_libs 8725a31a186aSmrg temp_deplibs= 8726a31a186aSmrg for libdir in $dependency_libs; do 8727a31a186aSmrg case $libdir in 8728a31a186aSmrg -R*) func_stripname '-R' '' "$libdir" 8729a31a186aSmrg temp_xrpath=$func_stripname_result 8730a31a186aSmrg case " $xrpath " in 8731a31a186aSmrg *" $temp_xrpath "*) ;; 87320bb88ba4Smrg *) func_append xrpath " $temp_xrpath";; 8733a31a186aSmrg esac;; 87340bb88ba4Smrg *) func_append temp_deplibs " $libdir";; 8735a31a186aSmrg esac 8736a31a186aSmrg done 8737493f84f4Smrg dependency_libs=$temp_deplibs 8738a31a186aSmrg fi 8739a31a186aSmrg 87400bb88ba4Smrg func_append newlib_search_path " $absdir" 8741a31a186aSmrg # Link against this library 8742493f84f4Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8743a31a186aSmrg # ... and its dependency_libs 8744a31a186aSmrg tmp_libs= 8745a31a186aSmrg for deplib in $dependency_libs; do 8746a31a186aSmrg newdependency_libs="$deplib $newdependency_libs" 87470bb88ba4Smrg case $deplib in 87480bb88ba4Smrg -L*) func_stripname '-L' '' "$deplib" 87490bb88ba4Smrg func_resolve_sysroot "$func_stripname_result";; 87500bb88ba4Smrg *) func_resolve_sysroot "$deplib" ;; 87510bb88ba4Smrg esac 8752493f84f4Smrg if $opt_preserve_dup_deps; then 8753a31a186aSmrg case "$tmp_libs " in 87540bb88ba4Smrg *" $func_resolve_sysroot_result "*) 87550bb88ba4Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8756a31a186aSmrg esac 8757a31a186aSmrg fi 87580bb88ba4Smrg func_append tmp_libs " $func_resolve_sysroot_result" 8759a31a186aSmrg done 8760a31a186aSmrg 8761493f84f4Smrg if test no != "$link_all_deplibs"; then 8762a31a186aSmrg # Add the search paths of all dependency libraries 8763a31a186aSmrg for deplib in $dependency_libs; do 87640bb88ba4Smrg path= 8765a31a186aSmrg case $deplib in 8766493f84f4Smrg -L*) path=$deplib ;; 8767a31a186aSmrg *.la) 87680bb88ba4Smrg func_resolve_sysroot "$deplib" 87690bb88ba4Smrg deplib=$func_resolve_sysroot_result 8770a31a186aSmrg func_dirname "$deplib" "" "." 87710bb88ba4Smrg dir=$func_dirname_result 8772a31a186aSmrg # We need an absolute path. 8773a31a186aSmrg case $dir in 8774493f84f4Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8775a31a186aSmrg *) 8776a31a186aSmrg absdir=`cd "$dir" && pwd` 8777a31a186aSmrg if test -z "$absdir"; then 8778493f84f4Smrg func_warning "cannot determine absolute directory name of '$dir'" 8779493f84f4Smrg absdir=$dir 8780a31a186aSmrg fi 8781a31a186aSmrg ;; 8782a31a186aSmrg esac 8783a31a186aSmrg if $GREP "^installed=no" $deplib > /dev/null; then 8784a31a186aSmrg case $host in 8785a31a186aSmrg *-*-darwin*) 8786a31a186aSmrg depdepl= 8787493f84f4Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8788493f84f4Smrg if test -n "$deplibrary_names"; then 8789493f84f4Smrg for tmp in $deplibrary_names; do 8790a31a186aSmrg depdepl=$tmp 8791a31a186aSmrg done 8792493f84f4Smrg if test -f "$absdir/$objdir/$depdepl"; then 8793493f84f4Smrg depdepl=$absdir/$objdir/$depdepl 8794493f84f4Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8795a31a186aSmrg if test -z "$darwin_install_name"; then 8796493f84f4Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8797a31a186aSmrg fi 8798493f84f4Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8799493f84f4Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8800a31a186aSmrg path= 8801a31a186aSmrg fi 8802a31a186aSmrg fi 8803a31a186aSmrg ;; 8804a31a186aSmrg *) 8805493f84f4Smrg path=-L$absdir/$objdir 8806a31a186aSmrg ;; 8807a31a186aSmrg esac 8808a31a186aSmrg else 8809493f84f4Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8810a31a186aSmrg test -z "$libdir" && \ 8811493f84f4Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 8812a31a186aSmrg test "$absdir" != "$libdir" && \ 8813493f84f4Smrg func_warning "'$deplib' seems to be moved" 8814a31a186aSmrg 8815493f84f4Smrg path=-L$absdir 8816a31a186aSmrg fi 8817a31a186aSmrg ;; 8818a31a186aSmrg esac 8819a31a186aSmrg case " $deplibs " in 8820a31a186aSmrg *" $path "*) ;; 8821a31a186aSmrg *) deplibs="$path $deplibs" ;; 8822a31a186aSmrg esac 8823a31a186aSmrg done 8824a31a186aSmrg fi # link_all_deplibs != no 8825a31a186aSmrg fi # linkmode = lib 8826a31a186aSmrg done # for deplib in $libs 8827493f84f4Smrg if test link = "$pass"; then 8828493f84f4Smrg if test prog = "$linkmode"; then 8829a31a186aSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8830a31a186aSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8831a31a186aSmrg else 88320bb88ba4Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8833a31a186aSmrg fi 8834a31a186aSmrg fi 8835493f84f4Smrg dependency_libs=$newdependency_libs 8836493f84f4Smrg if test dlpreopen = "$pass"; then 8837a31a186aSmrg # Link the dlpreopened libraries before other libraries 8838a31a186aSmrg for deplib in $save_deplibs; do 8839a31a186aSmrg deplibs="$deplib $deplibs" 8840a31a186aSmrg done 8841a31a186aSmrg fi 8842493f84f4Smrg if test dlopen != "$pass"; then 8843493f84f4Smrg test conv = "$pass" || { 8844a31a186aSmrg # Make sure lib_search_path contains only unique directories. 8845a31a186aSmrg lib_search_path= 8846a31a186aSmrg for dir in $newlib_search_path; do 8847a31a186aSmrg case "$lib_search_path " in 8848a31a186aSmrg *" $dir "*) ;; 88490bb88ba4Smrg *) func_append lib_search_path " $dir" ;; 8850a31a186aSmrg esac 8851a31a186aSmrg done 8852a31a186aSmrg newlib_search_path= 8853493f84f4Smrg } 8854a31a186aSmrg 8855493f84f4Smrg if test prog,link = "$linkmode,$pass"; then 8856a31a186aSmrg vars="compile_deplibs finalize_deplibs" 8857493f84f4Smrg else 8858493f84f4Smrg vars=deplibs 8859a31a186aSmrg fi 8860a31a186aSmrg for var in $vars dependency_libs; do 8861a31a186aSmrg # Add libraries to $var in reverse order 8862a31a186aSmrg eval tmp_libs=\"\$$var\" 8863a31a186aSmrg new_libs= 8864a31a186aSmrg for deplib in $tmp_libs; do 8865a31a186aSmrg # FIXME: Pedantically, this is the right thing to do, so 8866a31a186aSmrg # that some nasty dependency loop isn't accidentally 8867a31a186aSmrg # broken: 8868a31a186aSmrg #new_libs="$deplib $new_libs" 8869a31a186aSmrg # Pragmatically, this seems to cause very few problems in 8870a31a186aSmrg # practice: 8871a31a186aSmrg case $deplib in 8872a31a186aSmrg -L*) new_libs="$deplib $new_libs" ;; 8873a31a186aSmrg -R*) ;; 8874a31a186aSmrg *) 8875a31a186aSmrg # And here is the reason: when a library appears more 8876a31a186aSmrg # than once as an explicit dependence of a library, or 8877a31a186aSmrg # is implicitly linked in more than once by the 8878a31a186aSmrg # compiler, it is considered special, and multiple 8879a31a186aSmrg # occurrences thereof are not removed. Compare this 8880a31a186aSmrg # with having the same library being listed as a 8881a31a186aSmrg # dependency of multiple other libraries: in this case, 8882a31a186aSmrg # we know (pedantically, we assume) the library does not 8883a31a186aSmrg # need to be listed more than once, so we keep only the 8884a31a186aSmrg # last copy. This is not always right, but it is rare 8885a31a186aSmrg # enough that we require users that really mean to play 8886a31a186aSmrg # such unportable linking tricks to link the library 8887a31a186aSmrg # using -Wl,-lname, so that libtool does not consider it 8888a31a186aSmrg # for duplicate removal. 8889a31a186aSmrg case " $specialdeplibs " in 8890a31a186aSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8891a31a186aSmrg *) 8892a31a186aSmrg case " $new_libs " in 8893a31a186aSmrg *" $deplib "*) ;; 8894a31a186aSmrg *) new_libs="$deplib $new_libs" ;; 8895a31a186aSmrg esac 8896a31a186aSmrg ;; 8897a31a186aSmrg esac 8898a31a186aSmrg ;; 8899a31a186aSmrg esac 8900a31a186aSmrg done 8901a31a186aSmrg tmp_libs= 8902a31a186aSmrg for deplib in $new_libs; do 8903a31a186aSmrg case $deplib in 8904a31a186aSmrg -L*) 8905a31a186aSmrg case " $tmp_libs " in 8906a31a186aSmrg *" $deplib "*) ;; 89070bb88ba4Smrg *) func_append tmp_libs " $deplib" ;; 8908a31a186aSmrg esac 8909a31a186aSmrg ;; 89100bb88ba4Smrg *) func_append tmp_libs " $deplib" ;; 8911a31a186aSmrg esac 8912a31a186aSmrg done 8913a31a186aSmrg eval $var=\"$tmp_libs\" 8914a31a186aSmrg done # for var 8915a31a186aSmrg fi 8916ee82cb62Smrg 8917ee82cb62Smrg # Add Sun CC postdeps if required: 8918ee82cb62Smrg test CXX = "$tagname" && { 8919ee82cb62Smrg case $host_os in 8920ee82cb62Smrg linux*) 89211e423a8fSmrg case `$CC -V 2>&1 | $SED 5q` in 8922ee82cb62Smrg *Sun\ C*) # Sun C++ 5.9 8923ee82cb62Smrg func_suncc_cstd_abi 8924ee82cb62Smrg 8925ee82cb62Smrg if test no != "$suncc_use_cstd_abi"; then 8926ee82cb62Smrg func_append postdeps ' -library=Cstd -library=Crun' 8927ee82cb62Smrg fi 8928ee82cb62Smrg ;; 8929ee82cb62Smrg esac 8930ee82cb62Smrg ;; 8931ee82cb62Smrg 8932ee82cb62Smrg solaris*) 8933ee82cb62Smrg func_cc_basename "$CC" 8934ee82cb62Smrg case $func_cc_basename_result in 8935ee82cb62Smrg CC* | sunCC*) 8936ee82cb62Smrg func_suncc_cstd_abi 8937ee82cb62Smrg 8938ee82cb62Smrg if test no != "$suncc_use_cstd_abi"; then 8939ee82cb62Smrg func_append postdeps ' -library=Cstd -library=Crun' 8940ee82cb62Smrg fi 8941ee82cb62Smrg ;; 8942ee82cb62Smrg esac 8943ee82cb62Smrg ;; 8944ee82cb62Smrg esac 8945ee82cb62Smrg } 8946ee82cb62Smrg 8947a31a186aSmrg # Last step: remove runtime libs from dependency_libs 8948a31a186aSmrg # (they stay in deplibs) 8949a31a186aSmrg tmp_libs= 8950493f84f4Smrg for i in $dependency_libs; do 8951a31a186aSmrg case " $predeps $postdeps $compiler_lib_search_path " in 8952a31a186aSmrg *" $i "*) 8953493f84f4Smrg i= 8954a31a186aSmrg ;; 8955a31a186aSmrg esac 8956493f84f4Smrg if test -n "$i"; then 89570bb88ba4Smrg func_append tmp_libs " $i" 8958a31a186aSmrg fi 8959a31a186aSmrg done 8960a31a186aSmrg dependency_libs=$tmp_libs 8961a31a186aSmrg done # for pass 8962493f84f4Smrg if test prog = "$linkmode"; then 8963493f84f4Smrg dlfiles=$newdlfiles 8964a31a186aSmrg fi 8965493f84f4Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 8966493f84f4Smrg dlprefiles=$newdlprefiles 8967a31a186aSmrg fi 8968a31a186aSmrg 8969a31a186aSmrg case $linkmode in 8970a31a186aSmrg oldlib) 8971493f84f4Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8972493f84f4Smrg func_warning "'-dlopen' is ignored for archives" 8973a31a186aSmrg fi 8974a31a186aSmrg 8975a31a186aSmrg case " $deplibs" in 8976a31a186aSmrg *\ -l* | *\ -L*) 8977493f84f4Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 8978a31a186aSmrg esac 8979a31a186aSmrg 8980a31a186aSmrg test -n "$rpath" && \ 8981493f84f4Smrg func_warning "'-rpath' is ignored for archives" 8982a31a186aSmrg 8983a31a186aSmrg test -n "$xrpath" && \ 8984493f84f4Smrg func_warning "'-R' is ignored for archives" 8985a31a186aSmrg 8986a31a186aSmrg test -n "$vinfo" && \ 8987493f84f4Smrg func_warning "'-version-info/-version-number' is ignored for archives" 8988a31a186aSmrg 8989a31a186aSmrg test -n "$release" && \ 8990493f84f4Smrg func_warning "'-release' is ignored for archives" 8991a31a186aSmrg 8992a31a186aSmrg test -n "$export_symbols$export_symbols_regex" && \ 8993493f84f4Smrg func_warning "'-export-symbols' is ignored for archives" 8994a31a186aSmrg 8995a31a186aSmrg # Now set the variables for building old libraries. 8996a31a186aSmrg build_libtool_libs=no 8997493f84f4Smrg oldlibs=$output 89980bb88ba4Smrg func_append objs "$old_deplibs" 8999a31a186aSmrg ;; 9000a31a186aSmrg 9001a31a186aSmrg lib) 9002493f84f4Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 9003a31a186aSmrg case $outputname in 9004a31a186aSmrg lib*) 9005a31a186aSmrg func_stripname 'lib' '.la' "$outputname" 9006a31a186aSmrg name=$func_stripname_result 9007a31a186aSmrg eval shared_ext=\"$shrext_cmds\" 9008a31a186aSmrg eval libname=\"$libname_spec\" 9009a31a186aSmrg ;; 9010a31a186aSmrg *) 9011493f84f4Smrg test no = "$module" \ 9012493f84f4Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 9013a31a186aSmrg 9014493f84f4Smrg if test no != "$need_lib_prefix"; then 9015a31a186aSmrg # Add the "lib" prefix for modules if required 9016a31a186aSmrg func_stripname '' '.la' "$outputname" 9017a31a186aSmrg name=$func_stripname_result 9018a31a186aSmrg eval shared_ext=\"$shrext_cmds\" 9019a31a186aSmrg eval libname=\"$libname_spec\" 9020a31a186aSmrg else 9021a31a186aSmrg func_stripname '' '.la' "$outputname" 9022a31a186aSmrg libname=$func_stripname_result 9023a31a186aSmrg fi 9024a31a186aSmrg ;; 9025a31a186aSmrg esac 9026a31a186aSmrg 9027a31a186aSmrg if test -n "$objs"; then 9028493f84f4Smrg if test pass_all != "$deplibs_check_method"; then 9029493f84f4Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 9030a31a186aSmrg else 90310bb88ba4Smrg echo 9032a31a186aSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 9033a31a186aSmrg $ECHO "*** objects $objs is not portable!" 90340bb88ba4Smrg func_append libobjs " $objs" 9035a31a186aSmrg fi 9036a31a186aSmrg fi 9037a31a186aSmrg 9038493f84f4Smrg test no = "$dlself" \ 9039493f84f4Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 9040a31a186aSmrg 9041a31a186aSmrg set dummy $rpath 9042a31a186aSmrg shift 9043493f84f4Smrg test 1 -lt "$#" \ 9044493f84f4Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 9045a31a186aSmrg 9046493f84f4Smrg install_libdir=$1 9047a31a186aSmrg 9048a31a186aSmrg oldlibs= 9049a31a186aSmrg if test -z "$rpath"; then 9050493f84f4Smrg if test yes = "$build_libtool_libs"; then 9051a31a186aSmrg # Building a libtool convenience library. 9052493f84f4Smrg # Some compilers have problems with a '.al' extension so 9053a31a186aSmrg # convenience libraries should have the same extension an 9054a31a186aSmrg # archive normally would. 9055a31a186aSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 9056a31a186aSmrg build_libtool_libs=convenience 9057a31a186aSmrg build_old_libs=yes 9058a31a186aSmrg fi 9059a31a186aSmrg 9060a31a186aSmrg test -n "$vinfo" && \ 9061493f84f4Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 9062a31a186aSmrg 9063a31a186aSmrg test -n "$release" && \ 9064493f84f4Smrg func_warning "'-release' is ignored for convenience libraries" 9065a31a186aSmrg else 9066a31a186aSmrg 9067a31a186aSmrg # Parse the version information argument. 9068493f84f4Smrg save_ifs=$IFS; IFS=: 9069a31a186aSmrg set dummy $vinfo 0 0 0 9070a31a186aSmrg shift 9071493f84f4Smrg IFS=$save_ifs 9072a31a186aSmrg 9073a31a186aSmrg test -n "$7" && \ 9074493f84f4Smrg func_fatal_help "too many parameters to '-version-info'" 9075a31a186aSmrg 9076a31a186aSmrg # convert absolute version numbers to libtool ages 9077a31a186aSmrg # this retains compatibility with .la files and attempts 9078a31a186aSmrg # to make the code below a bit more comprehensible 9079a31a186aSmrg 9080a31a186aSmrg case $vinfo_number in 9081a31a186aSmrg yes) 9082493f84f4Smrg number_major=$1 9083493f84f4Smrg number_minor=$2 9084493f84f4Smrg number_revision=$3 9085a31a186aSmrg # 9086a31a186aSmrg # There are really only two kinds -- those that 9087a31a186aSmrg # use the current revision as the major version 9088a31a186aSmrg # and those that subtract age and use age as 9089a31a186aSmrg # a minor version. But, then there is irix 9090493f84f4Smrg # that has an extra 1 added just for fun 9091a31a186aSmrg # 9092a31a186aSmrg case $version_type in 90930bb88ba4Smrg # correct linux to gnu/linux during the next big refactor 90941e423a8fSmrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 9095a31a186aSmrg func_arith $number_major + $number_minor 9096a31a186aSmrg current=$func_arith_result 9097493f84f4Smrg age=$number_minor 9098493f84f4Smrg revision=$number_revision 9099a31a186aSmrg ;; 9100493f84f4Smrg freebsd-aout|qnx|sunos) 9101493f84f4Smrg current=$number_major 9102493f84f4Smrg revision=$number_minor 9103493f84f4Smrg age=0 9104a31a186aSmrg ;; 9105a31a186aSmrg irix|nonstopux) 9106a31a186aSmrg func_arith $number_major + $number_minor 9107a31a186aSmrg current=$func_arith_result 9108493f84f4Smrg age=$number_minor 9109493f84f4Smrg revision=$number_minor 9110a31a186aSmrg lt_irix_increment=no 9111a31a186aSmrg ;; 9112a31a186aSmrg esac 9113a31a186aSmrg ;; 9114a31a186aSmrg no) 9115493f84f4Smrg current=$1 9116493f84f4Smrg revision=$2 9117493f84f4Smrg age=$3 9118a31a186aSmrg ;; 9119a31a186aSmrg esac 9120a31a186aSmrg 9121a31a186aSmrg # Check that each of the things are valid numbers. 9122a31a186aSmrg case $current in 9123a31a186aSmrg 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]) ;; 9124a31a186aSmrg *) 9125493f84f4Smrg func_error "CURRENT '$current' must be a nonnegative integer" 9126493f84f4Smrg func_fatal_error "'$vinfo' is not valid version information" 9127a31a186aSmrg ;; 9128a31a186aSmrg esac 9129a31a186aSmrg 9130a31a186aSmrg case $revision in 9131a31a186aSmrg 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]) ;; 9132a31a186aSmrg *) 9133493f84f4Smrg func_error "REVISION '$revision' must be a nonnegative integer" 9134493f84f4Smrg func_fatal_error "'$vinfo' is not valid version information" 9135a31a186aSmrg ;; 9136a31a186aSmrg esac 9137a31a186aSmrg 9138a31a186aSmrg case $age in 9139a31a186aSmrg 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]) ;; 9140a31a186aSmrg *) 9141493f84f4Smrg func_error "AGE '$age' must be a nonnegative integer" 9142493f84f4Smrg func_fatal_error "'$vinfo' is not valid version information" 9143a31a186aSmrg ;; 9144a31a186aSmrg esac 9145a31a186aSmrg 9146a31a186aSmrg if test "$age" -gt "$current"; then 9147493f84f4Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 9148493f84f4Smrg func_fatal_error "'$vinfo' is not valid version information" 9149a31a186aSmrg fi 9150a31a186aSmrg 9151a31a186aSmrg # Calculate the version variables. 9152a31a186aSmrg major= 9153a31a186aSmrg versuffix= 9154a31a186aSmrg verstring= 9155a31a186aSmrg case $version_type in 9156a31a186aSmrg none) ;; 9157a31a186aSmrg 9158a31a186aSmrg darwin) 9159a31a186aSmrg # Like Linux, but with the current version available in 9160a31a186aSmrg # verstring for coding it into the library header 9161a31a186aSmrg func_arith $current - $age 9162a31a186aSmrg major=.$func_arith_result 9163493f84f4Smrg versuffix=$major.$age.$revision 9164a31a186aSmrg # Darwin ld doesn't like 0 for these options... 9165a31a186aSmrg func_arith $current + 1 9166a31a186aSmrg minor_current=$func_arith_result 9167493f84f4Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9168a31a186aSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9169493f84f4Smrg # On Darwin other compilers 9170493f84f4Smrg case $CC in 9171493f84f4Smrg nagfor*) 9172493f84f4Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9173493f84f4Smrg ;; 9174493f84f4Smrg *) 9175493f84f4Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9176493f84f4Smrg ;; 9177493f84f4Smrg esac 9178a31a186aSmrg ;; 9179a31a186aSmrg 9180a31a186aSmrg freebsd-aout) 9181493f84f4Smrg major=.$current 9182493f84f4Smrg versuffix=.$current.$revision 9183a31a186aSmrg ;; 9184a31a186aSmrg 91851e423a8fSmrg freebsd-elf | midnightbsd-elf) 9186493f84f4Smrg func_arith $current - $age 9187493f84f4Smrg major=.$func_arith_result 9188493f84f4Smrg versuffix=$major.$age.$revision 9189a31a186aSmrg ;; 9190a31a186aSmrg 9191a31a186aSmrg irix | nonstopux) 9192493f84f4Smrg if test no = "$lt_irix_increment"; then 9193a31a186aSmrg func_arith $current - $age 9194a31a186aSmrg else 9195a31a186aSmrg func_arith $current - $age + 1 9196a31a186aSmrg fi 9197a31a186aSmrg major=$func_arith_result 9198a31a186aSmrg 9199a31a186aSmrg case $version_type in 9200a31a186aSmrg nonstopux) verstring_prefix=nonstopux ;; 9201a31a186aSmrg *) verstring_prefix=sgi ;; 9202a31a186aSmrg esac 9203493f84f4Smrg verstring=$verstring_prefix$major.$revision 9204a31a186aSmrg 9205a31a186aSmrg # Add in all the interfaces that we are compatible with. 9206a31a186aSmrg loop=$revision 9207493f84f4Smrg while test 0 -ne "$loop"; do 9208a31a186aSmrg func_arith $revision - $loop 9209a31a186aSmrg iface=$func_arith_result 9210a31a186aSmrg func_arith $loop - 1 9211a31a186aSmrg loop=$func_arith_result 9212493f84f4Smrg verstring=$verstring_prefix$major.$iface:$verstring 9213a31a186aSmrg done 9214a31a186aSmrg 9215493f84f4Smrg # Before this point, $major must not contain '.'. 9216a31a186aSmrg major=.$major 9217493f84f4Smrg versuffix=$major.$revision 9218a31a186aSmrg ;; 9219a31a186aSmrg 92200bb88ba4Smrg linux) # correct to gnu/linux during the next big refactor 9221a31a186aSmrg func_arith $current - $age 9222a31a186aSmrg major=.$func_arith_result 9223493f84f4Smrg versuffix=$major.$age.$revision 9224a31a186aSmrg ;; 9225a31a186aSmrg 9226a31a186aSmrg osf) 9227a31a186aSmrg func_arith $current - $age 9228a31a186aSmrg major=.$func_arith_result 9229493f84f4Smrg versuffix=.$current.$age.$revision 9230493f84f4Smrg verstring=$current.$age.$revision 9231a31a186aSmrg 9232a31a186aSmrg # Add in all the interfaces that we are compatible with. 9233a31a186aSmrg loop=$age 9234493f84f4Smrg while test 0 -ne "$loop"; do 9235a31a186aSmrg func_arith $current - $loop 9236a31a186aSmrg iface=$func_arith_result 9237a31a186aSmrg func_arith $loop - 1 9238a31a186aSmrg loop=$func_arith_result 9239493f84f4Smrg verstring=$verstring:$iface.0 9240a31a186aSmrg done 9241a31a186aSmrg 9242a31a186aSmrg # Make executables depend on our current version. 9243493f84f4Smrg func_append verstring ":$current.0" 9244a31a186aSmrg ;; 9245a31a186aSmrg 9246a31a186aSmrg qnx) 9247493f84f4Smrg major=.$current 9248493f84f4Smrg versuffix=.$current 9249493f84f4Smrg ;; 9250493f84f4Smrg 9251493f84f4Smrg sco) 9252493f84f4Smrg major=.$current 9253493f84f4Smrg versuffix=.$current 9254a31a186aSmrg ;; 9255a31a186aSmrg 9256a31a186aSmrg sunos) 9257493f84f4Smrg major=.$current 9258493f84f4Smrg versuffix=.$current.$revision 9259a31a186aSmrg ;; 9260a31a186aSmrg 9261a31a186aSmrg windows) 9262a31a186aSmrg # Use '-' rather than '.', since we only want one 9263493f84f4Smrg # extension on DOS 8.3 file systems. 9264a31a186aSmrg func_arith $current - $age 9265a31a186aSmrg major=$func_arith_result 9266493f84f4Smrg versuffix=-$major 9267a31a186aSmrg ;; 9268a31a186aSmrg 9269a31a186aSmrg *) 9270493f84f4Smrg func_fatal_configuration "unknown library version type '$version_type'" 9271a31a186aSmrg ;; 9272a31a186aSmrg esac 9273a31a186aSmrg 9274a31a186aSmrg # Clear the version info if we defaulted, and they specified a release. 9275a31a186aSmrg if test -z "$vinfo" && test -n "$release"; then 9276a31a186aSmrg major= 9277a31a186aSmrg case $version_type in 9278a31a186aSmrg darwin) 9279a31a186aSmrg # we can't check for "0.0" in archive_cmds due to quoting 9280a31a186aSmrg # problems, so we reset it completely 9281a31a186aSmrg verstring= 9282a31a186aSmrg ;; 9283a31a186aSmrg *) 9284493f84f4Smrg verstring=0.0 9285a31a186aSmrg ;; 9286a31a186aSmrg esac 9287493f84f4Smrg if test no = "$need_version"; then 9288a31a186aSmrg versuffix= 9289a31a186aSmrg else 9290493f84f4Smrg versuffix=.0.0 9291a31a186aSmrg fi 9292a31a186aSmrg fi 9293a31a186aSmrg 9294a31a186aSmrg # Remove version info from name if versioning should be avoided 9295493f84f4Smrg if test yes,no = "$avoid_version,$need_version"; then 9296a31a186aSmrg major= 9297a31a186aSmrg versuffix= 9298493f84f4Smrg verstring= 9299a31a186aSmrg fi 9300a31a186aSmrg 9301a31a186aSmrg # Check to see if the archive will have undefined symbols. 9302493f84f4Smrg if test yes = "$allow_undefined"; then 9303493f84f4Smrg if test unsupported = "$allow_undefined_flag"; then 9304493f84f4Smrg if test yes = "$build_old_libs"; then 9305493f84f4Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9306493f84f4Smrg build_libtool_libs=no 9307493f84f4Smrg else 9308493f84f4Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9309493f84f4Smrg fi 9310a31a186aSmrg fi 9311a31a186aSmrg else 9312a31a186aSmrg # Don't allow undefined symbols. 9313493f84f4Smrg allow_undefined_flag=$no_undefined_flag 9314a31a186aSmrg fi 9315a31a186aSmrg 9316a31a186aSmrg fi 9317a31a186aSmrg 9318493f84f4Smrg func_generate_dlsyms "$libname" "$libname" : 93190bb88ba4Smrg func_append libobjs " $symfileobj" 9320493f84f4Smrg test " " = "$libobjs" && libobjs= 9321a31a186aSmrg 9322493f84f4Smrg if test relink != "$opt_mode"; then 9323a31a186aSmrg # Remove our outputs, but don't remove object files since they 9324a31a186aSmrg # may have been created when compiling PIC objects. 9325a31a186aSmrg removelist= 9326a31a186aSmrg tempremovelist=`$ECHO "$output_objdir/*"` 9327a31a186aSmrg for p in $tempremovelist; do 9328a31a186aSmrg case $p in 9329a31a186aSmrg *.$objext | *.gcno) 9330a31a186aSmrg ;; 9331493f84f4Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9332493f84f4Smrg if test -n "$precious_files_regex"; then 9333a31a186aSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9334a31a186aSmrg then 9335a31a186aSmrg continue 9336a31a186aSmrg fi 9337a31a186aSmrg fi 93380bb88ba4Smrg func_append removelist " $p" 9339a31a186aSmrg ;; 9340a31a186aSmrg *) ;; 9341a31a186aSmrg esac 9342a31a186aSmrg done 9343a31a186aSmrg test -n "$removelist" && \ 9344a31a186aSmrg func_show_eval "${RM}r \$removelist" 9345a31a186aSmrg fi 9346a31a186aSmrg 9347a31a186aSmrg # Now set the variables for building old libraries. 9348493f84f4Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 93490bb88ba4Smrg func_append oldlibs " $output_objdir/$libname.$libext" 9350a31a186aSmrg 9351a31a186aSmrg # Transform .lo files to .o files. 9352493f84f4Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9353a31a186aSmrg fi 9354a31a186aSmrg 9355a31a186aSmrg # Eliminate all temporary directories. 9356a31a186aSmrg #for path in $notinst_path; do 93570bb88ba4Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 93580bb88ba4Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 93590bb88ba4Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9360a31a186aSmrg #done 9361a31a186aSmrg 9362a31a186aSmrg if test -n "$xrpath"; then 9363a31a186aSmrg # If the user specified any rpath flags, then add them. 9364a31a186aSmrg temp_xrpath= 9365a31a186aSmrg for libdir in $xrpath; do 93660bb88ba4Smrg func_replace_sysroot "$libdir" 93670bb88ba4Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9368a31a186aSmrg case "$finalize_rpath " in 9369a31a186aSmrg *" $libdir "*) ;; 93700bb88ba4Smrg *) func_append finalize_rpath " $libdir" ;; 9371a31a186aSmrg esac 9372a31a186aSmrg done 9373493f84f4Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9374a31a186aSmrg dependency_libs="$temp_xrpath $dependency_libs" 9375a31a186aSmrg fi 9376a31a186aSmrg fi 9377a31a186aSmrg 9378a31a186aSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 9379493f84f4Smrg old_dlfiles=$dlfiles 9380a31a186aSmrg dlfiles= 9381a31a186aSmrg for lib in $old_dlfiles; do 9382a31a186aSmrg case " $dlprefiles $dlfiles " in 9383a31a186aSmrg *" $lib "*) ;; 93840bb88ba4Smrg *) func_append dlfiles " $lib" ;; 9385a31a186aSmrg esac 9386a31a186aSmrg done 9387a31a186aSmrg 9388a31a186aSmrg # Make sure dlprefiles contains only unique files 9389493f84f4Smrg old_dlprefiles=$dlprefiles 9390a31a186aSmrg dlprefiles= 9391a31a186aSmrg for lib in $old_dlprefiles; do 9392a31a186aSmrg case "$dlprefiles " in 9393a31a186aSmrg *" $lib "*) ;; 93940bb88ba4Smrg *) func_append dlprefiles " $lib" ;; 9395a31a186aSmrg esac 9396a31a186aSmrg done 9397a31a186aSmrg 9398493f84f4Smrg if test yes = "$build_libtool_libs"; then 9399a31a186aSmrg if test -n "$rpath"; then 9400a31a186aSmrg case $host in 94010bb88ba4Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9402a31a186aSmrg # these systems don't actually have a c library (as such)! 9403a31a186aSmrg ;; 9404a31a186aSmrg *-*-rhapsody* | *-*-darwin1.[012]) 9405a31a186aSmrg # Rhapsody C library is in the System framework 94060bb88ba4Smrg func_append deplibs " System.ltframework" 9407a31a186aSmrg ;; 9408a31a186aSmrg *-*-netbsd*) 9409a31a186aSmrg # Don't link with libc until the a.out ld.so is fixed. 9410a31a186aSmrg ;; 94111e423a8fSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 9412a31a186aSmrg # Do not include libc due to us having libc/libc_r. 9413a31a186aSmrg ;; 9414a31a186aSmrg *-*-sco3.2v5* | *-*-sco5v6*) 9415a31a186aSmrg # Causes problems with __ctype 9416a31a186aSmrg ;; 9417a31a186aSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9418a31a186aSmrg # Compiler inserts libc in the correct place for threads to work 9419a31a186aSmrg ;; 9420a31a186aSmrg *) 9421a31a186aSmrg # Add libc to deplibs on all other systems if necessary. 9422493f84f4Smrg if test yes = "$build_libtool_need_lc"; then 94230bb88ba4Smrg func_append deplibs " -lc" 9424a31a186aSmrg fi 9425a31a186aSmrg ;; 9426a31a186aSmrg esac 9427a31a186aSmrg fi 9428a31a186aSmrg 9429a31a186aSmrg # Transform deplibs into only deplibs that can be linked in shared. 9430a31a186aSmrg name_save=$name 9431a31a186aSmrg libname_save=$libname 9432a31a186aSmrg release_save=$release 9433a31a186aSmrg versuffix_save=$versuffix 9434a31a186aSmrg major_save=$major 9435a31a186aSmrg # I'm not sure if I'm treating the release correctly. I think 9436a31a186aSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 9437a31a186aSmrg # add it in twice. Is that correct? 9438493f84f4Smrg release= 9439493f84f4Smrg versuffix= 9440493f84f4Smrg major= 9441a31a186aSmrg newdeplibs= 9442a31a186aSmrg droppeddeps=no 9443a31a186aSmrg case $deplibs_check_method in 9444a31a186aSmrg pass_all) 9445a31a186aSmrg # Don't check for shared/static. Everything works. 9446a31a186aSmrg # This might be a little naive. We might want to check 9447a31a186aSmrg # whether the library exists or not. But this is on 9448a31a186aSmrg # osf3 & osf4 and I'm not really sure... Just 9449a31a186aSmrg # implementing what was already the behavior. 9450a31a186aSmrg newdeplibs=$deplibs 9451a31a186aSmrg ;; 9452a31a186aSmrg test_compile) 9453a31a186aSmrg # This code stresses the "libraries are programs" paradigm to its 9454a31a186aSmrg # limits. Maybe even breaks it. We compile a program, linking it 9455a31a186aSmrg # against the deplibs as a proxy for the library. Then we can check 9456a31a186aSmrg # whether they linked in statically or dynamically with ldd. 9457a31a186aSmrg $opt_dry_run || $RM conftest.c 9458a31a186aSmrg cat > conftest.c <<EOF 9459a31a186aSmrg int main() { return 0; } 9460a31a186aSmrgEOF 9461a31a186aSmrg $opt_dry_run || $RM conftest 9462a31a186aSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9463a31a186aSmrg ldd_output=`ldd conftest` 9464a31a186aSmrg for i in $deplibs; do 9465a31a186aSmrg case $i in 9466a31a186aSmrg -l*) 9467a31a186aSmrg func_stripname -l '' "$i" 9468a31a186aSmrg name=$func_stripname_result 9469493f84f4Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9470a31a186aSmrg case " $predeps $postdeps " in 9471a31a186aSmrg *" $i "*) 94720bb88ba4Smrg func_append newdeplibs " $i" 9473493f84f4Smrg i= 9474a31a186aSmrg ;; 9475a31a186aSmrg esac 9476a31a186aSmrg fi 9477493f84f4Smrg if test -n "$i"; then 9478a31a186aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9479a31a186aSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9480a31a186aSmrg set dummy $deplib_matches; shift 9481a31a186aSmrg deplib_match=$1 9482493f84f4Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 94830bb88ba4Smrg func_append newdeplibs " $i" 9484a31a186aSmrg else 9485a31a186aSmrg droppeddeps=yes 94860bb88ba4Smrg echo 9487a31a186aSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 94880bb88ba4Smrg echo "*** I have the capability to make that library automatically link in when" 94890bb88ba4Smrg echo "*** you link to this library. But I can only do this if you have a" 94900bb88ba4Smrg echo "*** shared version of the library, which I believe you do not have" 94910bb88ba4Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 94920bb88ba4Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9493a31a186aSmrg fi 9494a31a186aSmrg fi 9495a31a186aSmrg ;; 9496a31a186aSmrg *) 94970bb88ba4Smrg func_append newdeplibs " $i" 9498a31a186aSmrg ;; 9499a31a186aSmrg esac 9500a31a186aSmrg done 9501a31a186aSmrg else 9502a31a186aSmrg # Error occurred in the first compile. Let's try to salvage 9503a31a186aSmrg # the situation: Compile a separate program for each library. 9504a31a186aSmrg for i in $deplibs; do 9505a31a186aSmrg case $i in 9506a31a186aSmrg -l*) 9507a31a186aSmrg func_stripname -l '' "$i" 9508a31a186aSmrg name=$func_stripname_result 9509a31a186aSmrg $opt_dry_run || $RM conftest 9510a31a186aSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9511a31a186aSmrg ldd_output=`ldd conftest` 9512493f84f4Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9513a31a186aSmrg case " $predeps $postdeps " in 9514a31a186aSmrg *" $i "*) 95150bb88ba4Smrg func_append newdeplibs " $i" 9516493f84f4Smrg i= 9517a31a186aSmrg ;; 9518a31a186aSmrg esac 9519a31a186aSmrg fi 9520493f84f4Smrg if test -n "$i"; then 9521a31a186aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9522a31a186aSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9523a31a186aSmrg set dummy $deplib_matches; shift 9524a31a186aSmrg deplib_match=$1 9525493f84f4Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 95260bb88ba4Smrg func_append newdeplibs " $i" 9527a31a186aSmrg else 9528a31a186aSmrg droppeddeps=yes 95290bb88ba4Smrg echo 9530a31a186aSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 95310bb88ba4Smrg echo "*** I have the capability to make that library automatically link in when" 95320bb88ba4Smrg echo "*** you link to this library. But I can only do this if you have a" 95330bb88ba4Smrg echo "*** shared version of the library, which you do not appear to have" 95340bb88ba4Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 95350bb88ba4Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9536a31a186aSmrg fi 9537a31a186aSmrg fi 9538a31a186aSmrg else 9539a31a186aSmrg droppeddeps=yes 95400bb88ba4Smrg echo 9541a31a186aSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 95420bb88ba4Smrg echo "*** make it link in! You will probably need to install it or some" 95430bb88ba4Smrg echo "*** library that it depends on before this library will be fully" 95440bb88ba4Smrg echo "*** functional. Installing it before continuing would be even better." 9545a31a186aSmrg fi 9546a31a186aSmrg ;; 9547a31a186aSmrg *) 95480bb88ba4Smrg func_append newdeplibs " $i" 9549a31a186aSmrg ;; 9550a31a186aSmrg esac 9551a31a186aSmrg done 9552a31a186aSmrg fi 9553a31a186aSmrg ;; 9554a31a186aSmrg file_magic*) 9555a31a186aSmrg set dummy $deplibs_check_method; shift 9556a31a186aSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9557a31a186aSmrg for a_deplib in $deplibs; do 9558a31a186aSmrg case $a_deplib in 9559a31a186aSmrg -l*) 9560a31a186aSmrg func_stripname -l '' "$a_deplib" 9561a31a186aSmrg name=$func_stripname_result 9562493f84f4Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9563a31a186aSmrg case " $predeps $postdeps " in 9564a31a186aSmrg *" $a_deplib "*) 95650bb88ba4Smrg func_append newdeplibs " $a_deplib" 9566493f84f4Smrg a_deplib= 9567a31a186aSmrg ;; 9568a31a186aSmrg esac 9569a31a186aSmrg fi 9570493f84f4Smrg if test -n "$a_deplib"; then 9571a31a186aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 95720bb88ba4Smrg if test -n "$file_magic_glob"; then 95730bb88ba4Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 95740bb88ba4Smrg else 95750bb88ba4Smrg libnameglob=$libname 95760bb88ba4Smrg fi 9577493f84f4Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9578a31a186aSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9579493f84f4Smrg if test yes = "$want_nocaseglob"; then 95800bb88ba4Smrg shopt -s nocaseglob 95810bb88ba4Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 95820bb88ba4Smrg $nocaseglob 95830bb88ba4Smrg else 95840bb88ba4Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 95850bb88ba4Smrg fi 9586a31a186aSmrg for potent_lib in $potential_libs; do 9587a31a186aSmrg # Follow soft links. 9588a31a186aSmrg if ls -lLd "$potent_lib" 2>/dev/null | 9589a31a186aSmrg $GREP " -> " >/dev/null; then 9590a31a186aSmrg continue 9591a31a186aSmrg fi 9592a31a186aSmrg # The statement above tries to avoid entering an 9593a31a186aSmrg # endless loop below, in case of cyclic links. 9594a31a186aSmrg # We might still enter an endless loop, since a link 9595a31a186aSmrg # loop can be closed while we follow links, 9596a31a186aSmrg # but so what? 9597493f84f4Smrg potlib=$potent_lib 9598a31a186aSmrg while test -h "$potlib" 2>/dev/null; do 9599493f84f4Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9600a31a186aSmrg case $potliblink in 9601493f84f4Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9602493f84f4Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9603a31a186aSmrg esac 9604a31a186aSmrg done 9605a31a186aSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9606a31a186aSmrg $SED -e 10q | 9607a31a186aSmrg $EGREP "$file_magic_regex" > /dev/null; then 96080bb88ba4Smrg func_append newdeplibs " $a_deplib" 9609493f84f4Smrg a_deplib= 9610a31a186aSmrg break 2 9611a31a186aSmrg fi 9612a31a186aSmrg done 9613a31a186aSmrg done 9614a31a186aSmrg fi 9615493f84f4Smrg if test -n "$a_deplib"; then 9616a31a186aSmrg droppeddeps=yes 96170bb88ba4Smrg echo 9618a31a186aSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 96190bb88ba4Smrg echo "*** I have the capability to make that library automatically link in when" 96200bb88ba4Smrg echo "*** you link to this library. But I can only do this if you have a" 96210bb88ba4Smrg echo "*** shared version of the library, which you do not appear to have" 96220bb88ba4Smrg echo "*** because I did check the linker path looking for a file starting" 9623493f84f4Smrg if test -z "$potlib"; then 9624a31a186aSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9625a31a186aSmrg else 9626a31a186aSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9627a31a186aSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 9628a31a186aSmrg fi 9629a31a186aSmrg fi 9630a31a186aSmrg ;; 9631a31a186aSmrg *) 9632a31a186aSmrg # Add a -L argument. 96330bb88ba4Smrg func_append newdeplibs " $a_deplib" 9634a31a186aSmrg ;; 9635a31a186aSmrg esac 9636a31a186aSmrg done # Gone through all deplibs. 9637a31a186aSmrg ;; 9638a31a186aSmrg match_pattern*) 9639a31a186aSmrg set dummy $deplibs_check_method; shift 9640a31a186aSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9641a31a186aSmrg for a_deplib in $deplibs; do 9642a31a186aSmrg case $a_deplib in 9643a31a186aSmrg -l*) 9644a31a186aSmrg func_stripname -l '' "$a_deplib" 9645a31a186aSmrg name=$func_stripname_result 9646493f84f4Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9647a31a186aSmrg case " $predeps $postdeps " in 9648a31a186aSmrg *" $a_deplib "*) 96490bb88ba4Smrg func_append newdeplibs " $a_deplib" 9650493f84f4Smrg a_deplib= 9651a31a186aSmrg ;; 9652a31a186aSmrg esac 9653a31a186aSmrg fi 9654493f84f4Smrg if test -n "$a_deplib"; then 9655a31a186aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9656a31a186aSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9657a31a186aSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9658a31a186aSmrg for potent_lib in $potential_libs; do 9659493f84f4Smrg potlib=$potent_lib # see symlink-check above in file_magic test 96600bb88ba4Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9661a31a186aSmrg $EGREP "$match_pattern_regex" > /dev/null; then 96620bb88ba4Smrg func_append newdeplibs " $a_deplib" 9663493f84f4Smrg a_deplib= 9664a31a186aSmrg break 2 9665a31a186aSmrg fi 9666a31a186aSmrg done 9667a31a186aSmrg done 9668a31a186aSmrg fi 9669493f84f4Smrg if test -n "$a_deplib"; then 9670a31a186aSmrg droppeddeps=yes 96710bb88ba4Smrg echo 9672a31a186aSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 96730bb88ba4Smrg echo "*** I have the capability to make that library automatically link in when" 96740bb88ba4Smrg echo "*** you link to this library. But I can only do this if you have a" 96750bb88ba4Smrg echo "*** shared version of the library, which you do not appear to have" 96760bb88ba4Smrg echo "*** because I did check the linker path looking for a file starting" 9677493f84f4Smrg if test -z "$potlib"; then 9678a31a186aSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9679a31a186aSmrg else 9680a31a186aSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9681a31a186aSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9682a31a186aSmrg fi 9683a31a186aSmrg fi 9684a31a186aSmrg ;; 9685a31a186aSmrg *) 9686a31a186aSmrg # Add a -L argument. 96870bb88ba4Smrg func_append newdeplibs " $a_deplib" 9688a31a186aSmrg ;; 9689a31a186aSmrg esac 9690a31a186aSmrg done # Gone through all deplibs. 9691a31a186aSmrg ;; 9692a31a186aSmrg none | unknown | *) 9693493f84f4Smrg newdeplibs= 96940bb88ba4Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9695493f84f4Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9696493f84f4Smrg for i in $predeps $postdeps; do 9697a31a186aSmrg # can't use Xsed below, because $i might contain '/' 9698493f84f4Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9699a31a186aSmrg done 9700a31a186aSmrg fi 97010bb88ba4Smrg case $tmp_deplibs in 97020bb88ba4Smrg *[!\ \ ]*) 97030bb88ba4Smrg echo 9704493f84f4Smrg if test none = "$deplibs_check_method"; then 97050bb88ba4Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9706a31a186aSmrg else 97070bb88ba4Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 9708a31a186aSmrg fi 97090bb88ba4Smrg echo "*** All declared inter-library dependencies are being dropped." 9710a31a186aSmrg droppeddeps=yes 97110bb88ba4Smrg ;; 97120bb88ba4Smrg esac 9713a31a186aSmrg ;; 9714a31a186aSmrg esac 9715a31a186aSmrg versuffix=$versuffix_save 9716a31a186aSmrg major=$major_save 9717a31a186aSmrg release=$release_save 9718a31a186aSmrg libname=$libname_save 9719a31a186aSmrg name=$name_save 9720a31a186aSmrg 9721a31a186aSmrg case $host in 9722a31a186aSmrg *-*-rhapsody* | *-*-darwin1.[012]) 9723a31a186aSmrg # On Rhapsody replace the C library with the System framework 97240bb88ba4Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9725a31a186aSmrg ;; 9726a31a186aSmrg esac 9727a31a186aSmrg 9728493f84f4Smrg if test yes = "$droppeddeps"; then 9729493f84f4Smrg if test yes = "$module"; then 97300bb88ba4Smrg echo 97310bb88ba4Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9732a31a186aSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 97330bb88ba4Smrg echo "*** a static module, that should work as long as the dlopening" 97340bb88ba4Smrg echo "*** application is linked with the -dlopen flag." 9735a31a186aSmrg if test -z "$global_symbol_pipe"; then 97360bb88ba4Smrg echo 97370bb88ba4Smrg echo "*** However, this would only work if libtool was able to extract symbol" 9738493f84f4Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 97390bb88ba4Smrg echo "*** not find such a program. So, this module is probably useless." 9740493f84f4Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9741a31a186aSmrg fi 9742493f84f4Smrg if test no = "$build_old_libs"; then 9743493f84f4Smrg oldlibs=$output_objdir/$libname.$libext 9744a31a186aSmrg build_libtool_libs=module 9745a31a186aSmrg build_old_libs=yes 9746a31a186aSmrg else 9747a31a186aSmrg build_libtool_libs=no 9748a31a186aSmrg fi 9749a31a186aSmrg else 97500bb88ba4Smrg echo "*** The inter-library dependencies that have been dropped here will be" 97510bb88ba4Smrg echo "*** automatically added whenever a program is linked with this library" 97520bb88ba4Smrg echo "*** or is declared to -dlopen it." 9753a31a186aSmrg 9754493f84f4Smrg if test no = "$allow_undefined"; then 97550bb88ba4Smrg echo 97560bb88ba4Smrg echo "*** Since this library must not contain undefined symbols," 97570bb88ba4Smrg echo "*** because either the platform does not support them or" 97580bb88ba4Smrg echo "*** it was explicitly requested with -no-undefined," 97590bb88ba4Smrg echo "*** libtool will only create a static version of it." 9760493f84f4Smrg if test no = "$build_old_libs"; then 9761493f84f4Smrg oldlibs=$output_objdir/$libname.$libext 9762a31a186aSmrg build_libtool_libs=module 9763a31a186aSmrg build_old_libs=yes 9764a31a186aSmrg else 9765a31a186aSmrg build_libtool_libs=no 9766a31a186aSmrg fi 9767a31a186aSmrg fi 9768a31a186aSmrg fi 9769a31a186aSmrg fi 9770a31a186aSmrg # Done checking deplibs! 9771a31a186aSmrg deplibs=$newdeplibs 9772a31a186aSmrg fi 9773a31a186aSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9774a31a186aSmrg case $host in 9775a31a186aSmrg *-*-darwin*) 97760bb88ba4Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97770bb88ba4Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97780bb88ba4Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9779a31a186aSmrg ;; 9780a31a186aSmrg esac 9781a31a186aSmrg 9782a31a186aSmrg # move library search paths that coincide with paths to not yet 9783a31a186aSmrg # installed libraries to the beginning of the library search list 9784a31a186aSmrg new_libs= 9785a31a186aSmrg for path in $notinst_path; do 9786a31a186aSmrg case " $new_libs " in 9787a31a186aSmrg *" -L$path/$objdir "*) ;; 9788a31a186aSmrg *) 9789a31a186aSmrg case " $deplibs " in 9790a31a186aSmrg *" -L$path/$objdir "*) 97910bb88ba4Smrg func_append new_libs " -L$path/$objdir" ;; 9792a31a186aSmrg esac 9793a31a186aSmrg ;; 9794a31a186aSmrg esac 9795a31a186aSmrg done 9796a31a186aSmrg for deplib in $deplibs; do 9797a31a186aSmrg case $deplib in 9798a31a186aSmrg -L*) 9799a31a186aSmrg case " $new_libs " in 9800a31a186aSmrg *" $deplib "*) ;; 98010bb88ba4Smrg *) func_append new_libs " $deplib" ;; 9802a31a186aSmrg esac 9803a31a186aSmrg ;; 98040bb88ba4Smrg *) func_append new_libs " $deplib" ;; 9805a31a186aSmrg esac 9806a31a186aSmrg done 9807493f84f4Smrg deplibs=$new_libs 9808a31a186aSmrg 9809a31a186aSmrg # All the library-specific variables (install_libdir is set above). 9810a31a186aSmrg library_names= 9811a31a186aSmrg old_library= 9812a31a186aSmrg dlname= 9813a31a186aSmrg 9814a31a186aSmrg # Test again, we may have decided not to build it any more 9815493f84f4Smrg if test yes = "$build_libtool_libs"; then 9816493f84f4Smrg # Remove $wl instances when linking with ld. 98170bb88ba4Smrg # FIXME: should test the right _cmds variable. 98180bb88ba4Smrg case $archive_cmds in 98190bb88ba4Smrg *\$LD\ *) wl= ;; 98200bb88ba4Smrg esac 9821493f84f4Smrg if test yes = "$hardcode_into_libs"; then 9822a31a186aSmrg # Hardcode the library paths 9823a31a186aSmrg hardcode_libdirs= 9824a31a186aSmrg dep_rpath= 9825493f84f4Smrg rpath=$finalize_rpath 9826493f84f4Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9827a31a186aSmrg for libdir in $rpath; do 9828a31a186aSmrg if test -n "$hardcode_libdir_flag_spec"; then 9829a31a186aSmrg if test -n "$hardcode_libdir_separator"; then 98300bb88ba4Smrg func_replace_sysroot "$libdir" 98310bb88ba4Smrg libdir=$func_replace_sysroot_result 9832a31a186aSmrg if test -z "$hardcode_libdirs"; then 9833493f84f4Smrg hardcode_libdirs=$libdir 9834a31a186aSmrg else 9835a31a186aSmrg # Just accumulate the unique libdirs. 9836a31a186aSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9837a31a186aSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9838a31a186aSmrg ;; 9839a31a186aSmrg *) 98400bb88ba4Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9841a31a186aSmrg ;; 9842a31a186aSmrg esac 9843a31a186aSmrg fi 9844a31a186aSmrg else 9845a31a186aSmrg eval flag=\"$hardcode_libdir_flag_spec\" 98460bb88ba4Smrg func_append dep_rpath " $flag" 9847a31a186aSmrg fi 9848a31a186aSmrg elif test -n "$runpath_var"; then 9849a31a186aSmrg case "$perm_rpath " in 9850a31a186aSmrg *" $libdir "*) ;; 98510bb88ba4Smrg *) func_append perm_rpath " $libdir" ;; 9852a31a186aSmrg esac 9853a31a186aSmrg fi 9854a31a186aSmrg done 9855a31a186aSmrg # Substitute the hardcoded libdirs into the rpath. 9856a31a186aSmrg if test -n "$hardcode_libdir_separator" && 9857a31a186aSmrg test -n "$hardcode_libdirs"; then 9858493f84f4Smrg libdir=$hardcode_libdirs 98590bb88ba4Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9860a31a186aSmrg fi 9861a31a186aSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9862a31a186aSmrg # We should set the runpath_var. 9863a31a186aSmrg rpath= 9864a31a186aSmrg for dir in $perm_rpath; do 98650bb88ba4Smrg func_append rpath "$dir:" 9866a31a186aSmrg done 9867a31a186aSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9868a31a186aSmrg fi 9869a31a186aSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9870a31a186aSmrg fi 9871fe5e51b7Smrg 9872493f84f4Smrg shlibpath=$finalize_shlibpath 9873493f84f4Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9874a31a186aSmrg if test -n "$shlibpath"; then 9875a31a186aSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9876a31a186aSmrg fi 9877fe5e51b7Smrg 9878a31a186aSmrg # Get the real and link names of the library. 9879a31a186aSmrg eval shared_ext=\"$shrext_cmds\" 9880a31a186aSmrg eval library_names=\"$library_names_spec\" 9881a31a186aSmrg set dummy $library_names 9882a31a186aSmrg shift 9883493f84f4Smrg realname=$1 9884a31a186aSmrg shift 9885fe5e51b7Smrg 9886a31a186aSmrg if test -n "$soname_spec"; then 9887a31a186aSmrg eval soname=\"$soname_spec\" 9888a31a186aSmrg else 9889493f84f4Smrg soname=$realname 9890a31a186aSmrg fi 9891a31a186aSmrg if test -z "$dlname"; then 9892a31a186aSmrg dlname=$soname 9893a31a186aSmrg fi 9894fe5e51b7Smrg 9895493f84f4Smrg lib=$output_objdir/$realname 9896a31a186aSmrg linknames= 9897a31a186aSmrg for link 9898a31a186aSmrg do 98990bb88ba4Smrg func_append linknames " $link" 9900a31a186aSmrg done 9901fe5e51b7Smrg 9902a31a186aSmrg # Use standard objects if they are pic 99030bb88ba4Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9904a31a186aSmrg test "X$libobjs" = "X " && libobjs= 9905fe5e51b7Smrg 9906a31a186aSmrg delfiles= 9907a31a186aSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9908a31a186aSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9909493f84f4Smrg export_symbols=$output_objdir/$libname.uexp 99100bb88ba4Smrg func_append delfiles " $export_symbols" 9911a31a186aSmrg fi 9912fe5e51b7Smrg 9913a31a186aSmrg orig_export_symbols= 9914a31a186aSmrg case $host_os in 9915a31a186aSmrg cygwin* | mingw* | cegcc*) 9916a31a186aSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9917a31a186aSmrg # exporting using user supplied symfile 9918493f84f4Smrg func_dll_def_p "$export_symbols" || { 9919a31a186aSmrg # and it's NOT already a .def file. Must figure out 9920a31a186aSmrg # which of the given symbols are data symbols and tag 9921a31a186aSmrg # them as such. So, trigger use of export_symbols_cmds. 9922a31a186aSmrg # export_symbols gets reassigned inside the "prepare 9923a31a186aSmrg # the list of exported symbols" if statement, so the 9924a31a186aSmrg # include_expsyms logic still works. 9925493f84f4Smrg orig_export_symbols=$export_symbols 9926a31a186aSmrg export_symbols= 9927a31a186aSmrg always_export_symbols=yes 9928493f84f4Smrg } 9929a31a186aSmrg fi 9930a31a186aSmrg ;; 9931a31a186aSmrg esac 9932fe5e51b7Smrg 9933a31a186aSmrg # Prepare the list of exported symbols 9934a31a186aSmrg if test -z "$export_symbols"; then 9935493f84f4Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9936493f84f4Smrg func_verbose "generating symbol list for '$libname.la'" 9937493f84f4Smrg export_symbols=$output_objdir/$libname.exp 9938a31a186aSmrg $opt_dry_run || $RM $export_symbols 9939a31a186aSmrg cmds=$export_symbols_cmds 9940493f84f4Smrg save_ifs=$IFS; IFS='~' 99410bb88ba4Smrg for cmd1 in $cmds; do 9942493f84f4Smrg IFS=$save_ifs 99430bb88ba4Smrg # Take the normal branch if the nm_file_list_spec branch 99440bb88ba4Smrg # doesn't work or if tool conversion is not needed. 99450bb88ba4Smrg case $nm_file_list_spec~$to_tool_file_cmd in 99460bb88ba4Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 99470bb88ba4Smrg try_normal_branch=yes 99480bb88ba4Smrg eval cmd=\"$cmd1\" 99490bb88ba4Smrg func_len " $cmd" 99500bb88ba4Smrg len=$func_len_result 99510bb88ba4Smrg ;; 99520bb88ba4Smrg *) 99530bb88ba4Smrg try_normal_branch=no 99540bb88ba4Smrg ;; 99550bb88ba4Smrg esac 9956493f84f4Smrg if test yes = "$try_normal_branch" \ 99570bb88ba4Smrg && { test "$len" -lt "$max_cmd_len" \ 99580bb88ba4Smrg || test "$max_cmd_len" -le -1; } 99590bb88ba4Smrg then 99600bb88ba4Smrg func_show_eval "$cmd" 'exit $?' 99610bb88ba4Smrg skipped_export=false 99620bb88ba4Smrg elif test -n "$nm_file_list_spec"; then 99630bb88ba4Smrg func_basename "$output" 99640bb88ba4Smrg output_la=$func_basename_result 99650bb88ba4Smrg save_libobjs=$libobjs 99660bb88ba4Smrg save_output=$output 9967493f84f4Smrg output=$output_objdir/$output_la.nm 99680bb88ba4Smrg func_to_tool_file "$output" 99690bb88ba4Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 99700bb88ba4Smrg func_append delfiles " $output" 99710bb88ba4Smrg func_verbose "creating $NM input file list: $output" 99720bb88ba4Smrg for obj in $save_libobjs; do 99730bb88ba4Smrg func_to_tool_file "$obj" 99740bb88ba4Smrg $ECHO "$func_to_tool_file_result" 99750bb88ba4Smrg done > "$output" 99760bb88ba4Smrg eval cmd=\"$cmd1\" 9977a31a186aSmrg func_show_eval "$cmd" 'exit $?' 99780bb88ba4Smrg output=$save_output 99790bb88ba4Smrg libobjs=$save_libobjs 9980a31a186aSmrg skipped_export=false 9981a31a186aSmrg else 9982a31a186aSmrg # The command line is too long to execute in one step. 9983a31a186aSmrg func_verbose "using reloadable object file for export list..." 9984a31a186aSmrg skipped_export=: 9985a31a186aSmrg # Break out early, otherwise skipped_export may be 9986a31a186aSmrg # set to false by a later but shorter cmd. 9987a31a186aSmrg break 9988a31a186aSmrg fi 9989a31a186aSmrg done 9990493f84f4Smrg IFS=$save_ifs 9991493f84f4Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9992a31a186aSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9993a31a186aSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9994a31a186aSmrg fi 9995a31a186aSmrg fi 9996eda3803bSmrg fi 9997fe5e51b7Smrg 9998a31a186aSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9999493f84f4Smrg tmp_export_symbols=$export_symbols 10000493f84f4Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 100010bb88ba4Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10002a31a186aSmrg fi 10003fe5e51b7Smrg 10004493f84f4Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 10005a31a186aSmrg # The given exports_symbols file has to be filtered, so filter it. 10006493f84f4Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10007a31a186aSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 10008493f84f4Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 10009a31a186aSmrg # though. Also, the filter scales superlinearly with the number of 10010a31a186aSmrg # global variables. join(1) would be nice here, but unfortunately 10011a31a186aSmrg # isn't a blessed tool. 10012a31a186aSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 100130bb88ba4Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10014a31a186aSmrg export_symbols=$output_objdir/$libname.def 10015a31a186aSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10016a31a186aSmrg fi 10017fe5e51b7Smrg 10018a31a186aSmrg tmp_deplibs= 10019a31a186aSmrg for test_deplib in $deplibs; do 10020a31a186aSmrg case " $convenience " in 10021a31a186aSmrg *" $test_deplib "*) ;; 10022a31a186aSmrg *) 100230bb88ba4Smrg func_append tmp_deplibs " $test_deplib" 10024a31a186aSmrg ;; 10025a31a186aSmrg esac 10026a31a186aSmrg done 10027493f84f4Smrg deplibs=$tmp_deplibs 10028fe5e51b7Smrg 10029a31a186aSmrg if test -n "$convenience"; then 10030a31a186aSmrg if test -n "$whole_archive_flag_spec" && 10031493f84f4Smrg test yes = "$compiler_needs_object" && 10032a31a186aSmrg test -z "$libobjs"; then 10033a31a186aSmrg # extract the archives, so we have objects to list. 10034a31a186aSmrg # TODO: could optimize this to just extract one archive. 10035a31a186aSmrg whole_archive_flag_spec= 10036a31a186aSmrg fi 10037a31a186aSmrg if test -n "$whole_archive_flag_spec"; then 10038a31a186aSmrg save_libobjs=$libobjs 10039a31a186aSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10040a31a186aSmrg test "X$libobjs" = "X " && libobjs= 10041a31a186aSmrg else 10042493f84f4Smrg gentop=$output_objdir/${outputname}x 100430bb88ba4Smrg func_append generated " $gentop" 10044fe5e51b7Smrg 10045a31a186aSmrg func_extract_archives $gentop $convenience 100460bb88ba4Smrg func_append libobjs " $func_extract_archives_result" 10047a31a186aSmrg test "X$libobjs" = "X " && libobjs= 10048a31a186aSmrg fi 10049643b027fSmrg fi 10050fe5e51b7Smrg 10051493f84f4Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 10052a31a186aSmrg eval flag=\"$thread_safe_flag_spec\" 100530bb88ba4Smrg func_append linker_flags " $flag" 10054643b027fSmrg fi 10055fe5e51b7Smrg 10056a31a186aSmrg # Make a backup of the uninstalled library when relinking 10057493f84f4Smrg if test relink = "$opt_mode"; then 10058a31a186aSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 10059a31a186aSmrg fi 10060fe5e51b7Smrg 10061a31a186aSmrg # Do each of the archive commands. 10062493f84f4Smrg if test yes = "$module" && test -n "$module_cmds"; then 10063a31a186aSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10064a31a186aSmrg eval test_cmds=\"$module_expsym_cmds\" 10065a31a186aSmrg cmds=$module_expsym_cmds 10066a31a186aSmrg else 10067a31a186aSmrg eval test_cmds=\"$module_cmds\" 10068a31a186aSmrg cmds=$module_cmds 10069a31a186aSmrg fi 10070643b027fSmrg else 10071a31a186aSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10072a31a186aSmrg eval test_cmds=\"$archive_expsym_cmds\" 10073a31a186aSmrg cmds=$archive_expsym_cmds 10074a31a186aSmrg else 10075a31a186aSmrg eval test_cmds=\"$archive_cmds\" 10076a31a186aSmrg cmds=$archive_cmds 10077a31a186aSmrg fi 10078643b027fSmrg fi 10079fe5e51b7Smrg 10080493f84f4Smrg if test : != "$skipped_export" && 10081a31a186aSmrg func_len " $test_cmds" && 10082a31a186aSmrg len=$func_len_result && 10083a31a186aSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10084a31a186aSmrg : 10085a31a186aSmrg else 10086a31a186aSmrg # The command line is too long to link in one step, link piecewise 10087a31a186aSmrg # or, if using GNU ld and skipped_export is not :, use a linker 10088a31a186aSmrg # script. 10089fe5e51b7Smrg 10090a31a186aSmrg # Save the value of $output and $libobjs because we want to 10091a31a186aSmrg # use them later. If we have whole_archive_flag_spec, we 10092a31a186aSmrg # want to use save_libobjs as it was before 10093a31a186aSmrg # whole_archive_flag_spec was expanded, because we can't 10094a31a186aSmrg # assume the linker understands whole_archive_flag_spec. 10095a31a186aSmrg # This may have to be revisited, in case too many 10096a31a186aSmrg # convenience libraries get linked in and end up exceeding 10097a31a186aSmrg # the spec. 10098a31a186aSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 10099a31a186aSmrg save_libobjs=$libobjs 10100a31a186aSmrg fi 10101a31a186aSmrg save_output=$output 101020bb88ba4Smrg func_basename "$output" 101030bb88ba4Smrg output_la=$func_basename_result 10104fe5e51b7Smrg 10105a31a186aSmrg # Clear the reloadable object creation command queue and 10106a31a186aSmrg # initialize k to one. 10107a31a186aSmrg test_cmds= 10108a31a186aSmrg concat_cmds= 10109a31a186aSmrg objlist= 10110a31a186aSmrg last_robj= 10111a31a186aSmrg k=1 10112a31a186aSmrg 10113493f84f4Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 10114493f84f4Smrg output=$output_objdir/$output_la.lnkscript 10115a31a186aSmrg func_verbose "creating GNU ld script: $output" 101160bb88ba4Smrg echo 'INPUT (' > $output 10117a31a186aSmrg for obj in $save_libobjs 10118643b027fSmrg do 101190bb88ba4Smrg func_to_tool_file "$obj" 101200bb88ba4Smrg $ECHO "$func_to_tool_file_result" >> $output 10121a31a186aSmrg done 101220bb88ba4Smrg echo ')' >> $output 101230bb88ba4Smrg func_append delfiles " $output" 101240bb88ba4Smrg func_to_tool_file "$output" 101250bb88ba4Smrg output=$func_to_tool_file_result 10126493f84f4Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 10127493f84f4Smrg output=$output_objdir/$output_la.lnk 10128a31a186aSmrg func_verbose "creating linker input file list: $output" 10129a31a186aSmrg : > $output 10130a31a186aSmrg set x $save_libobjs 10131a31a186aSmrg shift 10132a31a186aSmrg firstobj= 10133493f84f4Smrg if test yes = "$compiler_needs_object"; then 10134a31a186aSmrg firstobj="$1 " 10135a31a186aSmrg shift 10136a31a186aSmrg fi 10137a31a186aSmrg for obj 10138a31a186aSmrg do 101390bb88ba4Smrg func_to_tool_file "$obj" 101400bb88ba4Smrg $ECHO "$func_to_tool_file_result" >> $output 10141a31a186aSmrg done 101420bb88ba4Smrg func_append delfiles " $output" 101430bb88ba4Smrg func_to_tool_file "$output" 101440bb88ba4Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 10145a31a186aSmrg else 10146a31a186aSmrg if test -n "$save_libobjs"; then 10147a31a186aSmrg func_verbose "creating reloadable object files..." 10148493f84f4Smrg output=$output_objdir/$output_la-$k.$objext 10149a31a186aSmrg eval test_cmds=\"$reload_cmds\" 10150a31a186aSmrg func_len " $test_cmds" 10151a31a186aSmrg len0=$func_len_result 10152a31a186aSmrg len=$len0 10153a31a186aSmrg 10154a31a186aSmrg # Loop over the list of objects to be linked. 10155a31a186aSmrg for obj in $save_libobjs 10156a31a186aSmrg do 10157a31a186aSmrg func_len " $obj" 10158a31a186aSmrg func_arith $len + $func_len_result 10159a31a186aSmrg len=$func_arith_result 10160493f84f4Smrg if test -z "$objlist" || 10161a31a186aSmrg test "$len" -lt "$max_cmd_len"; then 10162a31a186aSmrg func_append objlist " $obj" 10163a31a186aSmrg else 10164a31a186aSmrg # The command $test_cmds is almost too long, add a 10165a31a186aSmrg # command to the queue. 10166493f84f4Smrg if test 1 -eq "$k"; then 10167a31a186aSmrg # The first file doesn't have a previous command to add. 101680bb88ba4Smrg reload_objs=$objlist 101690bb88ba4Smrg eval concat_cmds=\"$reload_cmds\" 10170a31a186aSmrg else 10171a31a186aSmrg # All subsequent reloadable object files will link in 10172a31a186aSmrg # the last one created. 101730bb88ba4Smrg reload_objs="$objlist $last_robj" 101740bb88ba4Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 10175a31a186aSmrg fi 10176493f84f4Smrg last_robj=$output_objdir/$output_la-$k.$objext 10177a31a186aSmrg func_arith $k + 1 10178a31a186aSmrg k=$func_arith_result 10179493f84f4Smrg output=$output_objdir/$output_la-$k.$objext 101800bb88ba4Smrg objlist=" $obj" 10181a31a186aSmrg func_len " $last_robj" 10182a31a186aSmrg func_arith $len0 + $func_len_result 10183a31a186aSmrg len=$func_arith_result 10184a31a186aSmrg fi 10185a31a186aSmrg done 10186a31a186aSmrg # Handle the remaining objects by creating one last 10187a31a186aSmrg # reloadable object file. All subsequent reloadable object 10188a31a186aSmrg # files will link in the last one created. 10189a31a186aSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 101900bb88ba4Smrg reload_objs="$objlist $last_robj" 10191493f84f4Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 10192a31a186aSmrg if test -n "$last_robj"; then 10193493f84f4Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10194a31a186aSmrg fi 101950bb88ba4Smrg func_append delfiles " $output" 10196fe5e51b7Smrg 10197a31a186aSmrg else 10198a31a186aSmrg output= 10199a31a186aSmrg fi 10200fe5e51b7Smrg 10201493f84f4Smrg ${skipped_export-false} && { 10202493f84f4Smrg func_verbose "generating symbol list for '$libname.la'" 10203493f84f4Smrg export_symbols=$output_objdir/$libname.exp 10204a31a186aSmrg $opt_dry_run || $RM $export_symbols 10205a31a186aSmrg libobjs=$output 10206a31a186aSmrg # Append the command to create the export file. 10207a31a186aSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10208a31a186aSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 10209a31a186aSmrg if test -n "$last_robj"; then 10210a31a186aSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10211a31a186aSmrg fi 10212493f84f4Smrg } 10213fe5e51b7Smrg 10214a31a186aSmrg test -n "$save_libobjs" && 10215a31a186aSmrg func_verbose "creating a temporary reloadable object file: $output" 10216fe5e51b7Smrg 10217a31a186aSmrg # Loop through the commands generated above and execute them. 10218493f84f4Smrg save_ifs=$IFS; IFS='~' 10219a31a186aSmrg for cmd in $concat_cmds; do 10220493f84f4Smrg IFS=$save_ifs 10221493f84f4Smrg $opt_quiet || { 102221e423a8fSmrg func_quote_arg expand,pretty "$cmd" 102231e423a8fSmrg eval "func_echo $func_quote_arg_result" 10224a31a186aSmrg } 10225a31a186aSmrg $opt_dry_run || eval "$cmd" || { 10226a31a186aSmrg lt_exit=$? 10227a31a186aSmrg 10228a31a186aSmrg # Restore the uninstalled library and exit 10229493f84f4Smrg if test relink = "$opt_mode"; then 10230a31a186aSmrg ( cd "$output_objdir" && \ 10231a31a186aSmrg $RM "${realname}T" && \ 10232a31a186aSmrg $MV "${realname}U" "$realname" ) 10233a31a186aSmrg fi 10234eda3803bSmrg 10235a31a186aSmrg exit $lt_exit 10236a31a186aSmrg } 10237a31a186aSmrg done 10238493f84f4Smrg IFS=$save_ifs 10239643b027fSmrg 10240a31a186aSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 10241a31a186aSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 10242a31a186aSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 10243fe5e51b7Smrg fi 10244fe5e51b7Smrg fi 10245fe5e51b7Smrg 10246493f84f4Smrg ${skipped_export-false} && { 10247a31a186aSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 10248493f84f4Smrg tmp_export_symbols=$export_symbols 10249493f84f4Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 102500bb88ba4Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10251a31a186aSmrg fi 10252fe5e51b7Smrg 10253a31a186aSmrg if test -n "$orig_export_symbols"; then 10254a31a186aSmrg # The given exports_symbols file has to be filtered, so filter it. 10255493f84f4Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10256a31a186aSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 10257493f84f4Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 10258a31a186aSmrg # though. Also, the filter scales superlinearly with the number of 10259a31a186aSmrg # global variables. join(1) would be nice here, but unfortunately 10260a31a186aSmrg # isn't a blessed tool. 10261a31a186aSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 102620bb88ba4Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10263a31a186aSmrg export_symbols=$output_objdir/$libname.def 10264a31a186aSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10265a31a186aSmrg fi 10266493f84f4Smrg } 10267fe5e51b7Smrg 10268a31a186aSmrg libobjs=$output 10269a31a186aSmrg # Restore the value of output. 10270a31a186aSmrg output=$save_output 10271fe5e51b7Smrg 10272a31a186aSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 10273a31a186aSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10274a31a186aSmrg test "X$libobjs" = "X " && libobjs= 10275a31a186aSmrg fi 10276a31a186aSmrg # Expand the library linking commands again to reset the 10277a31a186aSmrg # value of $libobjs for piecewise linking. 10278fe5e51b7Smrg 10279a31a186aSmrg # Do each of the archive commands. 10280493f84f4Smrg if test yes = "$module" && test -n "$module_cmds"; then 10281a31a186aSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10282a31a186aSmrg cmds=$module_expsym_cmds 10283a31a186aSmrg else 10284a31a186aSmrg cmds=$module_cmds 10285643b027fSmrg fi 10286643b027fSmrg else 10287a31a186aSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10288a31a186aSmrg cmds=$archive_expsym_cmds 10289a31a186aSmrg else 10290a31a186aSmrg cmds=$archive_cmds 10291a31a186aSmrg fi 10292643b027fSmrg fi 10293a31a186aSmrg fi 10294fe5e51b7Smrg 10295a31a186aSmrg if test -n "$delfiles"; then 10296a31a186aSmrg # Append the command to remove temporary files to $cmds. 10297a31a186aSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 10298a31a186aSmrg fi 10299fe5e51b7Smrg 10300a31a186aSmrg # Add any objects from preloaded convenience libraries 10301a31a186aSmrg if test -n "$dlprefiles"; then 10302493f84f4Smrg gentop=$output_objdir/${outputname}x 103030bb88ba4Smrg func_append generated " $gentop" 10304fe5e51b7Smrg 10305a31a186aSmrg func_extract_archives $gentop $dlprefiles 103060bb88ba4Smrg func_append libobjs " $func_extract_archives_result" 10307a31a186aSmrg test "X$libobjs" = "X " && libobjs= 10308a31a186aSmrg fi 10309fe5e51b7Smrg 10310493f84f4Smrg save_ifs=$IFS; IFS='~' 10311a31a186aSmrg for cmd in $cmds; do 10312493f84f4Smrg IFS=$sp$nl 10313a31a186aSmrg eval cmd=\"$cmd\" 10314493f84f4Smrg IFS=$save_ifs 10315493f84f4Smrg $opt_quiet || { 103161e423a8fSmrg func_quote_arg expand,pretty "$cmd" 103171e423a8fSmrg eval "func_echo $func_quote_arg_result" 10318a31a186aSmrg } 10319a31a186aSmrg $opt_dry_run || eval "$cmd" || { 10320a31a186aSmrg lt_exit=$? 10321eda3803bSmrg 10322a31a186aSmrg # Restore the uninstalled library and exit 10323493f84f4Smrg if test relink = "$opt_mode"; then 10324a31a186aSmrg ( cd "$output_objdir" && \ 10325a31a186aSmrg $RM "${realname}T" && \ 10326a31a186aSmrg $MV "${realname}U" "$realname" ) 10327a31a186aSmrg fi 10328eda3803bSmrg 10329a31a186aSmrg exit $lt_exit 10330a31a186aSmrg } 10331a31a186aSmrg done 10332493f84f4Smrg IFS=$save_ifs 10333eda3803bSmrg 10334a31a186aSmrg # Restore the uninstalled library and exit 10335493f84f4Smrg if test relink = "$opt_mode"; then 10336a31a186aSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10337eda3803bSmrg 10338a31a186aSmrg if test -n "$convenience"; then 10339a31a186aSmrg if test -z "$whole_archive_flag_spec"; then 10340a31a186aSmrg func_show_eval '${RM}r "$gentop"' 10341a31a186aSmrg fi 10342a31a186aSmrg fi 10343eda3803bSmrg 10344a31a186aSmrg exit $EXIT_SUCCESS 10345a31a186aSmrg fi 10346a31a186aSmrg 10347a31a186aSmrg # Create links to the real library. 10348a31a186aSmrg for linkname in $linknames; do 10349a31a186aSmrg if test "$realname" != "$linkname"; then 10350a31a186aSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10351643b027fSmrg fi 10352643b027fSmrg done 10353eda3803bSmrg 10354a31a186aSmrg # If -module or -export-dynamic was specified, set the dlname. 10355493f84f4Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 10356a31a186aSmrg # On all known operating systems, these are identical. 10357493f84f4Smrg dlname=$soname 10358a31a186aSmrg fi 10359a31a186aSmrg fi 10360fe5e51b7Smrg ;; 10361fe5e51b7Smrg 10362a31a186aSmrg obj) 10363493f84f4Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10364493f84f4Smrg func_warning "'-dlopen' is ignored for objects" 10365a31a186aSmrg fi 10366643b027fSmrg 10367a31a186aSmrg case " $deplibs" in 10368a31a186aSmrg *\ -l* | *\ -L*) 10369493f84f4Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 10370eda3803bSmrg esac 10371fe5e51b7Smrg 10372a31a186aSmrg test -n "$rpath" && \ 10373493f84f4Smrg func_warning "'-rpath' is ignored for objects" 10374a31a186aSmrg 10375a31a186aSmrg test -n "$xrpath" && \ 10376493f84f4Smrg func_warning "'-R' is ignored for objects" 10377fe5e51b7Smrg 10378a31a186aSmrg test -n "$vinfo" && \ 10379493f84f4Smrg func_warning "'-version-info' is ignored for objects" 10380eda3803bSmrg 10381a31a186aSmrg test -n "$release" && \ 10382493f84f4Smrg func_warning "'-release' is ignored for objects" 10383a31a186aSmrg 10384a31a186aSmrg case $output in 10385a31a186aSmrg *.lo) 10386a31a186aSmrg test -n "$objs$old_deplibs" && \ 10387493f84f4Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10388a31a186aSmrg 10389a31a186aSmrg libobj=$output 10390a31a186aSmrg func_lo2o "$libobj" 10391a31a186aSmrg obj=$func_lo2o_result 10392643b027fSmrg ;; 10393643b027fSmrg *) 10394a31a186aSmrg libobj= 10395493f84f4Smrg obj=$output 10396fe5e51b7Smrg ;; 10397eda3803bSmrg esac 10398fe5e51b7Smrg 10399a31a186aSmrg # Delete the old objects. 10400a31a186aSmrg $opt_dry_run || $RM $obj $libobj 10401fe5e51b7Smrg 10402a31a186aSmrg # Objects from convenience libraries. This assumes 10403a31a186aSmrg # single-version convenience libraries. Whenever we create 10404a31a186aSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 10405a31a186aSmrg # the extraction. 10406a31a186aSmrg reload_conv_objs= 10407a31a186aSmrg gentop= 10408493f84f4Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 10409493f84f4Smrg # whole_archive_flag_spec and hope we can get by with turning comma 10410493f84f4Smrg # into space. 10411493f84f4Smrg case $reload_cmds in 10412493f84f4Smrg *\$LD[\ \$]*) wl= ;; 10413493f84f4Smrg esac 10414a31a186aSmrg if test -n "$convenience"; then 10415a31a186aSmrg if test -n "$whole_archive_flag_spec"; then 10416a31a186aSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10417493f84f4Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10418493f84f4Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10419a31a186aSmrg else 10420493f84f4Smrg gentop=$output_objdir/${obj}x 104210bb88ba4Smrg func_append generated " $gentop" 10422643b027fSmrg 10423a31a186aSmrg func_extract_archives $gentop $convenience 10424a31a186aSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10425a31a186aSmrg fi 10426643b027fSmrg fi 10427643b027fSmrg 104280bb88ba4Smrg # If we're not building shared, we need to use non_pic_objs 10429493f84f4Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 104300bb88ba4Smrg 10431a31a186aSmrg # Create the old-style object. 10432493f84f4Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10433643b027fSmrg 10434493f84f4Smrg output=$obj 10435a31a186aSmrg func_execute_cmds "$reload_cmds" 'exit $?' 10436643b027fSmrg 10437a31a186aSmrg # Exit if we aren't doing a library object file. 10438a31a186aSmrg if test -z "$libobj"; then 10439a31a186aSmrg if test -n "$gentop"; then 10440a31a186aSmrg func_show_eval '${RM}r "$gentop"' 10441a31a186aSmrg fi 10442a31a186aSmrg 10443a31a186aSmrg exit $EXIT_SUCCESS 10444643b027fSmrg fi 10445a31a186aSmrg 10446493f84f4Smrg test yes = "$build_libtool_libs" || { 10447a31a186aSmrg if test -n "$gentop"; then 10448a31a186aSmrg func_show_eval '${RM}r "$gentop"' 10449a31a186aSmrg fi 10450a31a186aSmrg 10451a31a186aSmrg # Create an invalid libtool object if no PIC, so that we don't 10452a31a186aSmrg # accidentally link it into a program. 10453a31a186aSmrg # $show "echo timestamp > $libobj" 10454a31a186aSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10455a31a186aSmrg exit $EXIT_SUCCESS 10456493f84f4Smrg } 10457a31a186aSmrg 10458493f84f4Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10459a31a186aSmrg # Only do commands if we really have different PIC objects. 10460a31a186aSmrg reload_objs="$libobjs $reload_conv_objs" 10461493f84f4Smrg output=$libobj 10462a31a186aSmrg func_execute_cmds "$reload_cmds" 'exit $?' 10463a31a186aSmrg fi 10464a31a186aSmrg 10465a31a186aSmrg if test -n "$gentop"; then 10466a31a186aSmrg func_show_eval '${RM}r "$gentop"' 10467a31a186aSmrg fi 10468a31a186aSmrg 10469a31a186aSmrg exit $EXIT_SUCCESS 10470643b027fSmrg ;; 10471fe5e51b7Smrg 10472a31a186aSmrg prog) 10473a31a186aSmrg case $host in 10474a31a186aSmrg *cygwin*) func_stripname '' '.exe' "$output" 10475a31a186aSmrg output=$func_stripname_result.exe;; 10476a31a186aSmrg esac 10477a31a186aSmrg test -n "$vinfo" && \ 10478493f84f4Smrg func_warning "'-version-info' is ignored for programs" 10479fe5e51b7Smrg 10480a31a186aSmrg test -n "$release" && \ 10481493f84f4Smrg func_warning "'-release' is ignored for programs" 10482fe5e51b7Smrg 10483493f84f4Smrg $preload \ 10484493f84f4Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10485493f84f4Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10486a31a186aSmrg 10487a31a186aSmrg case $host in 10488a31a186aSmrg *-*-rhapsody* | *-*-darwin1.[012]) 10489a31a186aSmrg # On Rhapsody replace the C library is the System framework 104900bb88ba4Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 104910bb88ba4Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10492643b027fSmrg ;; 10493a31a186aSmrg esac 10494643b027fSmrg 10495a31a186aSmrg case $host in 10496a31a186aSmrg *-*-darwin*) 10497a31a186aSmrg # Don't allow lazy linking, it breaks C++ global constructors 10498a31a186aSmrg # But is supposedly fixed on 10.4 or later (yay!). 10499493f84f4Smrg if test CXX = "$tagname"; then 10500a31a186aSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10501a31a186aSmrg 10.[0123]) 10502493f84f4Smrg func_append compile_command " $wl-bind_at_load" 10503493f84f4Smrg func_append finalize_command " $wl-bind_at_load" 10504a31a186aSmrg ;; 10505a31a186aSmrg esac 10506643b027fSmrg fi 10507a31a186aSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 105080bb88ba4Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 105090bb88ba4Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10510a31a186aSmrg ;; 10511a31a186aSmrg esac 10512643b027fSmrg 10513643b027fSmrg 10514a31a186aSmrg # move library search paths that coincide with paths to not yet 10515a31a186aSmrg # installed libraries to the beginning of the library search list 10516a31a186aSmrg new_libs= 10517a31a186aSmrg for path in $notinst_path; do 10518a31a186aSmrg case " $new_libs " in 10519a31a186aSmrg *" -L$path/$objdir "*) ;; 10520a31a186aSmrg *) 10521a31a186aSmrg case " $compile_deplibs " in 10522a31a186aSmrg *" -L$path/$objdir "*) 105230bb88ba4Smrg func_append new_libs " -L$path/$objdir" ;; 10524eda3803bSmrg esac 10525a31a186aSmrg ;; 10526a31a186aSmrg esac 10527a31a186aSmrg done 10528a31a186aSmrg for deplib in $compile_deplibs; do 10529a31a186aSmrg case $deplib in 10530a31a186aSmrg -L*) 10531a31a186aSmrg case " $new_libs " in 10532a31a186aSmrg *" $deplib "*) ;; 105330bb88ba4Smrg *) func_append new_libs " $deplib" ;; 10534eda3803bSmrg esac 10535a31a186aSmrg ;; 105360bb88ba4Smrg *) func_append new_libs " $deplib" ;; 10537a31a186aSmrg esac 10538a31a186aSmrg done 10539493f84f4Smrg compile_deplibs=$new_libs 10540fe5e51b7Smrg 10541643b027fSmrg 105420bb88ba4Smrg func_append compile_command " $compile_deplibs" 105430bb88ba4Smrg func_append finalize_command " $finalize_deplibs" 10544643b027fSmrg 10545a31a186aSmrg if test -n "$rpath$xrpath"; then 10546a31a186aSmrg # If the user specified any rpath flags, then add them. 10547a31a186aSmrg for libdir in $rpath $xrpath; do 10548a31a186aSmrg # This is the magic to use -rpath. 10549a31a186aSmrg case "$finalize_rpath " in 10550a31a186aSmrg *" $libdir "*) ;; 105510bb88ba4Smrg *) func_append finalize_rpath " $libdir" ;; 10552a31a186aSmrg esac 10553a31a186aSmrg done 10554a31a186aSmrg fi 10555643b027fSmrg 10556a31a186aSmrg # Now hardcode the library paths 10557a31a186aSmrg rpath= 10558a31a186aSmrg hardcode_libdirs= 10559a31a186aSmrg for libdir in $compile_rpath $finalize_rpath; do 10560a31a186aSmrg if test -n "$hardcode_libdir_flag_spec"; then 10561a31a186aSmrg if test -n "$hardcode_libdir_separator"; then 10562a31a186aSmrg if test -z "$hardcode_libdirs"; then 10563493f84f4Smrg hardcode_libdirs=$libdir 10564a31a186aSmrg else 10565a31a186aSmrg # Just accumulate the unique libdirs. 10566a31a186aSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10567a31a186aSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10568a31a186aSmrg ;; 10569a31a186aSmrg *) 105700bb88ba4Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10571a31a186aSmrg ;; 10572a31a186aSmrg esac 10573a31a186aSmrg fi 10574643b027fSmrg else 10575a31a186aSmrg eval flag=\"$hardcode_libdir_flag_spec\" 105760bb88ba4Smrg func_append rpath " $flag" 10577643b027fSmrg fi 10578a31a186aSmrg elif test -n "$runpath_var"; then 10579a31a186aSmrg case "$perm_rpath " in 10580a31a186aSmrg *" $libdir "*) ;; 105810bb88ba4Smrg *) func_append perm_rpath " $libdir" ;; 10582a31a186aSmrg esac 10583a31a186aSmrg fi 10584a31a186aSmrg case $host in 10585a31a186aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10586493f84f4Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10587a31a186aSmrg case :$dllsearchpath: in 10588a31a186aSmrg *":$libdir:"*) ;; 10589a31a186aSmrg ::) dllsearchpath=$libdir;; 105900bb88ba4Smrg *) func_append dllsearchpath ":$libdir";; 10591a31a186aSmrg esac 10592a31a186aSmrg case :$dllsearchpath: in 10593a31a186aSmrg *":$testbindir:"*) ;; 10594a31a186aSmrg ::) dllsearchpath=$testbindir;; 105950bb88ba4Smrg *) func_append dllsearchpath ":$testbindir";; 10596a31a186aSmrg esac 10597a31a186aSmrg ;; 10598a31a186aSmrg esac 10599a31a186aSmrg done 10600a31a186aSmrg # Substitute the hardcoded libdirs into the rpath. 10601a31a186aSmrg if test -n "$hardcode_libdir_separator" && 10602a31a186aSmrg test -n "$hardcode_libdirs"; then 10603493f84f4Smrg libdir=$hardcode_libdirs 10604a31a186aSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 10605a31a186aSmrg fi 10606493f84f4Smrg compile_rpath=$rpath 10607643b027fSmrg 10608a31a186aSmrg rpath= 10609a31a186aSmrg hardcode_libdirs= 10610a31a186aSmrg for libdir in $finalize_rpath; do 10611a31a186aSmrg if test -n "$hardcode_libdir_flag_spec"; then 10612a31a186aSmrg if test -n "$hardcode_libdir_separator"; then 10613a31a186aSmrg if test -z "$hardcode_libdirs"; then 10614493f84f4Smrg hardcode_libdirs=$libdir 10615a31a186aSmrg else 10616a31a186aSmrg # Just accumulate the unique libdirs. 10617a31a186aSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10618a31a186aSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10619a31a186aSmrg ;; 10620a31a186aSmrg *) 106210bb88ba4Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10622a31a186aSmrg ;; 10623a31a186aSmrg esac 10624a31a186aSmrg fi 10625fe5e51b7Smrg else 10626a31a186aSmrg eval flag=\"$hardcode_libdir_flag_spec\" 106270bb88ba4Smrg func_append rpath " $flag" 10628fe5e51b7Smrg fi 10629a31a186aSmrg elif test -n "$runpath_var"; then 10630a31a186aSmrg case "$finalize_perm_rpath " in 10631a31a186aSmrg *" $libdir "*) ;; 106320bb88ba4Smrg *) func_append finalize_perm_rpath " $libdir" ;; 10633a31a186aSmrg esac 10634fe5e51b7Smrg fi 10635a31a186aSmrg done 10636a31a186aSmrg # Substitute the hardcoded libdirs into the rpath. 10637a31a186aSmrg if test -n "$hardcode_libdir_separator" && 10638a31a186aSmrg test -n "$hardcode_libdirs"; then 10639493f84f4Smrg libdir=$hardcode_libdirs 10640a31a186aSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 10641a31a186aSmrg fi 10642493f84f4Smrg finalize_rpath=$rpath 10643fe5e51b7Smrg 10644493f84f4Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10645a31a186aSmrg # Transform all the library objects into standard objects. 106460bb88ba4Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 106470bb88ba4Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10648a31a186aSmrg fi 10649fe5e51b7Smrg 10650493f84f4Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10651fe5e51b7Smrg 10652a31a186aSmrg # template prelinking step 10653a31a186aSmrg if test -n "$prelink_cmds"; then 10654a31a186aSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 10655a31a186aSmrg fi 10656fe5e51b7Smrg 10657493f84f4Smrg wrappers_required=: 10658a31a186aSmrg case $host in 106590bb88ba4Smrg *cegcc* | *mingw32ce*) 106600bb88ba4Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10661493f84f4Smrg wrappers_required=false 106620bb88ba4Smrg ;; 10663a31a186aSmrg *cygwin* | *mingw* ) 10664493f84f4Smrg test yes = "$build_libtool_libs" || wrappers_required=false 10665a31a186aSmrg ;; 10666a31a186aSmrg *) 10667493f84f4Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10668493f84f4Smrg wrappers_required=false 10669a31a186aSmrg fi 10670a31a186aSmrg ;; 10671a31a186aSmrg esac 10672493f84f4Smrg $wrappers_required || { 10673a31a186aSmrg # Replace the output file specification. 106740bb88ba4Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10675493f84f4Smrg link_command=$compile_command$compile_rpath 10676fe5e51b7Smrg 10677a31a186aSmrg # We have no uninstalled library dependencies, so finalize right now. 10678a31a186aSmrg exit_status=0 10679a31a186aSmrg func_show_eval "$link_command" 'exit_status=$?' 10680fe5e51b7Smrg 106810bb88ba4Smrg if test -n "$postlink_cmds"; then 106820bb88ba4Smrg func_to_tool_file "$output" 106830bb88ba4Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 106840bb88ba4Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 106850bb88ba4Smrg fi 106860bb88ba4Smrg 10687a31a186aSmrg # Delete the generated files. 10688493f84f4Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 10689493f84f4Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10690fe5e51b7Smrg fi 10691fe5e51b7Smrg 10692a31a186aSmrg exit $exit_status 10693493f84f4Smrg } 10694fe5e51b7Smrg 10695a31a186aSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10696a31a186aSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10697a31a186aSmrg fi 10698a31a186aSmrg if test -n "$finalize_shlibpath"; then 10699a31a186aSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10700a31a186aSmrg fi 10701643b027fSmrg 10702a31a186aSmrg compile_var= 10703a31a186aSmrg finalize_var= 10704a31a186aSmrg if test -n "$runpath_var"; then 10705a31a186aSmrg if test -n "$perm_rpath"; then 10706a31a186aSmrg # We should set the runpath_var. 10707a31a186aSmrg rpath= 10708a31a186aSmrg for dir in $perm_rpath; do 107090bb88ba4Smrg func_append rpath "$dir:" 10710a31a186aSmrg done 10711a31a186aSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10712fe5e51b7Smrg fi 10713a31a186aSmrg if test -n "$finalize_perm_rpath"; then 10714a31a186aSmrg # We should set the runpath_var. 10715a31a186aSmrg rpath= 10716a31a186aSmrg for dir in $finalize_perm_rpath; do 107170bb88ba4Smrg func_append rpath "$dir:" 10718a31a186aSmrg done 10719a31a186aSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10720fe5e51b7Smrg fi 10721a31a186aSmrg fi 10722fe5e51b7Smrg 10723493f84f4Smrg if test yes = "$no_install"; then 10724a31a186aSmrg # We don't need to create a wrapper script. 10725493f84f4Smrg link_command=$compile_var$compile_command$compile_rpath 10726a31a186aSmrg # Replace the output file specification. 107270bb88ba4Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10728a31a186aSmrg # Delete the old output file. 10729a31a186aSmrg $opt_dry_run || $RM $output 10730a31a186aSmrg # Link the executable and exit 10731a31a186aSmrg func_show_eval "$link_command" 'exit $?' 107320bb88ba4Smrg 107330bb88ba4Smrg if test -n "$postlink_cmds"; then 107340bb88ba4Smrg func_to_tool_file "$output" 107350bb88ba4Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 107360bb88ba4Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 107370bb88ba4Smrg fi 107380bb88ba4Smrg 10739643b027fSmrg exit $EXIT_SUCCESS 10740a31a186aSmrg fi 10741eda3803bSmrg 10742493f84f4Smrg case $hardcode_action,$fast_install in 10743493f84f4Smrg relink,*) 10744493f84f4Smrg # Fast installation is not supported 10745493f84f4Smrg link_command=$compile_var$compile_command$compile_rpath 10746493f84f4Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10747a31a186aSmrg 10748493f84f4Smrg func_warning "this platform does not like uninstalled shared libraries" 10749493f84f4Smrg func_warning "'$output' will be relinked during installation" 10750493f84f4Smrg ;; 10751493f84f4Smrg *,yes) 10752493f84f4Smrg link_command=$finalize_var$compile_command$finalize_rpath 10753493f84f4Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10754493f84f4Smrg ;; 10755493f84f4Smrg *,no) 10756493f84f4Smrg link_command=$compile_var$compile_command$compile_rpath 10757493f84f4Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10758493f84f4Smrg ;; 10759493f84f4Smrg *,needless) 10760493f84f4Smrg link_command=$finalize_var$compile_command$finalize_rpath 10761493f84f4Smrg relink_command= 10762493f84f4Smrg ;; 10763493f84f4Smrg esac 10764fe5e51b7Smrg 10765a31a186aSmrg # Replace the output file specification. 107660bb88ba4Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10767fe5e51b7Smrg 10768a31a186aSmrg # Delete the old output files. 10769a31a186aSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10770fe5e51b7Smrg 10771a31a186aSmrg func_show_eval "$link_command" 'exit $?' 10772643b027fSmrg 107730bb88ba4Smrg if test -n "$postlink_cmds"; then 107740bb88ba4Smrg func_to_tool_file "$output_objdir/$outputname" 107750bb88ba4Smrg 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'` 107760bb88ba4Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 107770bb88ba4Smrg fi 107780bb88ba4Smrg 10779a31a186aSmrg # Now create the wrapper script. 10780a31a186aSmrg func_verbose "creating $output" 10781643b027fSmrg 10782a31a186aSmrg # Quote the relink command for shipping. 10783a31a186aSmrg if test -n "$relink_command"; then 10784a31a186aSmrg # Preserve any variables that may affect compiler behavior 10785a31a186aSmrg for var in $variables_saved_for_relink; do 10786a31a186aSmrg if eval test -z \"\${$var+set}\"; then 10787a31a186aSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10788a31a186aSmrg elif eval var_value=\$$var; test -z "$var_value"; then 10789a31a186aSmrg relink_command="$var=; export $var; $relink_command" 10790fe5e51b7Smrg else 107911e423a8fSmrg func_quote_arg pretty "$var_value" 107921e423a8fSmrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 10793fe5e51b7Smrg fi 10794a31a186aSmrg done 107951e423a8fSmrg func_quote eval cd "`pwd`" 107961e423a8fSmrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 107971e423a8fSmrg relink_command=$func_quote_arg_unquoted_result 10798a31a186aSmrg fi 10799a31a186aSmrg 10800a31a186aSmrg # Only actually do things if not in dry run mode. 10801a31a186aSmrg $opt_dry_run || { 10802a31a186aSmrg # win32 will think the script is a binary if it has 10803a31a186aSmrg # a .exe suffix, so we strip it off here. 10804a31a186aSmrg case $output in 10805a31a186aSmrg *.exe) func_stripname '' '.exe' "$output" 10806a31a186aSmrg output=$func_stripname_result ;; 10807a31a186aSmrg esac 10808a31a186aSmrg # test for cygwin because mv fails w/o .exe extensions 10809a31a186aSmrg case $host in 10810a31a186aSmrg *cygwin*) 10811a31a186aSmrg exeext=.exe 10812a31a186aSmrg func_stripname '' '.exe' "$outputname" 10813a31a186aSmrg outputname=$func_stripname_result ;; 10814a31a186aSmrg *) exeext= ;; 10815fe5e51b7Smrg esac 10816a31a186aSmrg case $host in 10817a31a186aSmrg *cygwin* | *mingw* ) 10818a31a186aSmrg func_dirname_and_basename "$output" "" "." 10819a31a186aSmrg output_name=$func_basename_result 10820a31a186aSmrg output_path=$func_dirname_result 10821493f84f4Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 10822493f84f4Smrg cwrapper=$output_path/$output_name.exe 10823a31a186aSmrg $RM $cwrappersource $cwrapper 10824a31a186aSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10825a31a186aSmrg 10826a31a186aSmrg func_emit_cwrapperexe_src > $cwrappersource 10827a31a186aSmrg 10828a31a186aSmrg # The wrapper executable is built using the $host compiler, 10829a31a186aSmrg # because it contains $host paths and files. If cross- 10830a31a186aSmrg # compiling, it, like the target executable, must be 10831a31a186aSmrg # executed on the $host or under an emulation environment. 10832a31a186aSmrg $opt_dry_run || { 10833a31a186aSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10834a31a186aSmrg $STRIP $cwrapper 10835a31a186aSmrg } 10836fe5e51b7Smrg 10837a31a186aSmrg # Now, create the wrapper script for func_source use: 10838a31a186aSmrg func_ltwrapper_scriptname $cwrapper 10839a31a186aSmrg $RM $func_ltwrapper_scriptname_result 10840a31a186aSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10841a31a186aSmrg $opt_dry_run || { 10842a31a186aSmrg # note: this script will not be executed, so do not chmod. 10843493f84f4Smrg if test "x$build" = "x$host"; then 10844a31a186aSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10845a31a186aSmrg else 10846a31a186aSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10847a31a186aSmrg fi 10848a31a186aSmrg } 10849a31a186aSmrg ;; 10850a31a186aSmrg * ) 10851a31a186aSmrg $RM $output 10852a31a186aSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10853fe5e51b7Smrg 10854a31a186aSmrg func_emit_wrapper no > $output 10855a31a186aSmrg chmod +x $output 10856a31a186aSmrg ;; 10857a31a186aSmrg esac 10858a31a186aSmrg } 10859a31a186aSmrg exit $EXIT_SUCCESS 10860a31a186aSmrg ;; 10861a31a186aSmrg esac 10862fe5e51b7Smrg 10863a31a186aSmrg # See if we need to build an old-fashioned archive. 10864a31a186aSmrg for oldlib in $oldlibs; do 10865fe5e51b7Smrg 10866493f84f4Smrg case $build_libtool_libs in 10867493f84f4Smrg convenience) 10868493f84f4Smrg oldobjs="$libobjs_save $symfileobj" 10869493f84f4Smrg addlibs=$convenience 10870a31a186aSmrg build_libtool_libs=no 10871493f84f4Smrg ;; 10872493f84f4Smrg module) 10873493f84f4Smrg oldobjs=$libobjs_save 10874493f84f4Smrg addlibs=$old_convenience 10875493f84f4Smrg build_libtool_libs=no 10876493f84f4Smrg ;; 10877493f84f4Smrg *) 10878a31a186aSmrg oldobjs="$old_deplibs $non_pic_objects" 10879493f84f4Smrg $preload && test -f "$symfileobj" \ 10880493f84f4Smrg && func_append oldobjs " $symfileobj" 10881493f84f4Smrg addlibs=$old_convenience 10882493f84f4Smrg ;; 10883493f84f4Smrg esac 10884fe5e51b7Smrg 10885a31a186aSmrg if test -n "$addlibs"; then 10886493f84f4Smrg gentop=$output_objdir/${outputname}x 108870bb88ba4Smrg func_append generated " $gentop" 10888fe5e51b7Smrg 10889a31a186aSmrg func_extract_archives $gentop $addlibs 108900bb88ba4Smrg func_append oldobjs " $func_extract_archives_result" 10891a31a186aSmrg fi 10892fe5e51b7Smrg 10893a31a186aSmrg # Do each command in the archive commands. 10894493f84f4Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10895a31a186aSmrg cmds=$old_archive_from_new_cmds 10896a31a186aSmrg else 10897fe5e51b7Smrg 10898a31a186aSmrg # Add any objects from preloaded convenience libraries 10899a31a186aSmrg if test -n "$dlprefiles"; then 10900493f84f4Smrg gentop=$output_objdir/${outputname}x 109010bb88ba4Smrg func_append generated " $gentop" 10902fe5e51b7Smrg 10903a31a186aSmrg func_extract_archives $gentop $dlprefiles 109040bb88ba4Smrg func_append oldobjs " $func_extract_archives_result" 10905a31a186aSmrg fi 10906fe5e51b7Smrg 10907a31a186aSmrg # POSIX demands no paths to be encoded in archives. We have 10908a31a186aSmrg # to avoid creating archives with duplicate basenames if we 10909a31a186aSmrg # might have to extract them afterwards, e.g., when creating a 10910a31a186aSmrg # static archive out of a convenience library, or when linking 10911a31a186aSmrg # the entirety of a libtool archive into another (currently 10912a31a186aSmrg # not supported by libtool). 10913a31a186aSmrg if (for obj in $oldobjs 10914a31a186aSmrg do 10915a31a186aSmrg func_basename "$obj" 10916a31a186aSmrg $ECHO "$func_basename_result" 10917a31a186aSmrg done | sort | sort -uc >/dev/null 2>&1); then 10918a31a186aSmrg : 10919a31a186aSmrg else 109200bb88ba4Smrg echo "copying selected object files to avoid basename conflicts..." 10921493f84f4Smrg gentop=$output_objdir/${outputname}x 109220bb88ba4Smrg func_append generated " $gentop" 10923a31a186aSmrg func_mkdir_p "$gentop" 10924a31a186aSmrg save_oldobjs=$oldobjs 10925a31a186aSmrg oldobjs= 10926a31a186aSmrg counter=1 10927a31a186aSmrg for obj in $save_oldobjs 10928a31a186aSmrg do 10929a31a186aSmrg func_basename "$obj" 10930493f84f4Smrg objbase=$func_basename_result 10931a31a186aSmrg case " $oldobjs " in 10932a31a186aSmrg " ") oldobjs=$obj ;; 10933a31a186aSmrg *[\ /]"$objbase "*) 10934a31a186aSmrg while :; do 10935a31a186aSmrg # Make sure we don't pick an alternate name that also 10936a31a186aSmrg # overlaps. 10937a31a186aSmrg newobj=lt$counter-$objbase 10938a31a186aSmrg func_arith $counter + 1 10939a31a186aSmrg counter=$func_arith_result 10940a31a186aSmrg case " $oldobjs " in 10941a31a186aSmrg *[\ /]"$newobj "*) ;; 10942a31a186aSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10943a31a186aSmrg esac 10944a31a186aSmrg done 10945a31a186aSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 109460bb88ba4Smrg func_append oldobjs " $gentop/$newobj" 10947a31a186aSmrg ;; 109480bb88ba4Smrg *) func_append oldobjs " $obj" ;; 10949a31a186aSmrg esac 10950fe5e51b7Smrg done 10951eda3803bSmrg fi 109520bb88ba4Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 109530bb88ba4Smrg tool_oldlib=$func_to_tool_file_result 10954a31a186aSmrg eval cmds=\"$old_archive_cmds\" 10955643b027fSmrg 10956a31a186aSmrg func_len " $cmds" 10957a31a186aSmrg len=$func_len_result 10958a31a186aSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10959a31a186aSmrg cmds=$old_archive_cmds 109600bb88ba4Smrg elif test -n "$archiver_list_spec"; then 109610bb88ba4Smrg func_verbose "using command file archive linking..." 109620bb88ba4Smrg for obj in $oldobjs 109630bb88ba4Smrg do 109640bb88ba4Smrg func_to_tool_file "$obj" 109650bb88ba4Smrg $ECHO "$func_to_tool_file_result" 109660bb88ba4Smrg done > $output_objdir/$libname.libcmd 109670bb88ba4Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 109680bb88ba4Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 109690bb88ba4Smrg cmds=$old_archive_cmds 10970a31a186aSmrg else 10971a31a186aSmrg # the command line is too long to link in one step, link in parts 10972a31a186aSmrg func_verbose "using piecewise archive linking..." 10973a31a186aSmrg save_RANLIB=$RANLIB 10974a31a186aSmrg RANLIB=: 10975a31a186aSmrg objlist= 10976a31a186aSmrg concat_cmds= 10977a31a186aSmrg save_oldobjs=$oldobjs 10978a31a186aSmrg oldobjs= 10979a31a186aSmrg # Is there a better way of finding the last object in the list? 10980a31a186aSmrg for obj in $save_oldobjs 10981a31a186aSmrg do 10982a31a186aSmrg last_oldobj=$obj 10983a31a186aSmrg done 10984a31a186aSmrg eval test_cmds=\"$old_archive_cmds\" 10985a31a186aSmrg func_len " $test_cmds" 10986a31a186aSmrg len0=$func_len_result 10987a31a186aSmrg len=$len0 10988a31a186aSmrg for obj in $save_oldobjs 10989a31a186aSmrg do 10990a31a186aSmrg func_len " $obj" 10991a31a186aSmrg func_arith $len + $func_len_result 10992a31a186aSmrg len=$func_arith_result 10993a31a186aSmrg func_append objlist " $obj" 10994a31a186aSmrg if test "$len" -lt "$max_cmd_len"; then 10995a31a186aSmrg : 10996a31a186aSmrg else 10997a31a186aSmrg # the above command should be used before it gets too long 10998a31a186aSmrg oldobjs=$objlist 10999493f84f4Smrg if test "$obj" = "$last_oldobj"; then 11000a31a186aSmrg RANLIB=$save_RANLIB 11001a31a186aSmrg fi 11002a31a186aSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 11003493f84f4Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 11004a31a186aSmrg objlist= 11005a31a186aSmrg len=$len0 11006a31a186aSmrg fi 11007a31a186aSmrg done 11008a31a186aSmrg RANLIB=$save_RANLIB 11009a31a186aSmrg oldobjs=$objlist 11010493f84f4Smrg if test -z "$oldobjs"; then 11011a31a186aSmrg eval cmds=\"\$concat_cmds\" 11012a31a186aSmrg else 11013a31a186aSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 11014a31a186aSmrg fi 11015a31a186aSmrg fi 11016a31a186aSmrg fi 11017a31a186aSmrg func_execute_cmds "$cmds" 'exit $?' 11018fe5e51b7Smrg done 11019fe5e51b7Smrg 11020a31a186aSmrg test -n "$generated" && \ 11021a31a186aSmrg func_show_eval "${RM}r$generated" 11022fe5e51b7Smrg 11023a31a186aSmrg # Now create the libtool archive. 11024a31a186aSmrg case $output in 11025a31a186aSmrg *.la) 11026a31a186aSmrg old_library= 11027493f84f4Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 11028a31a186aSmrg func_verbose "creating $output" 11029eda3803bSmrg 11030a31a186aSmrg # Preserve any variables that may affect compiler behavior 11031a31a186aSmrg for var in $variables_saved_for_relink; do 11032a31a186aSmrg if eval test -z \"\${$var+set}\"; then 11033a31a186aSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 11034a31a186aSmrg elif eval var_value=\$$var; test -z "$var_value"; then 11035a31a186aSmrg relink_command="$var=; export $var; $relink_command" 11036643b027fSmrg else 110371e423a8fSmrg func_quote_arg pretty,unquoted "$var_value" 110381e423a8fSmrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 11039643b027fSmrg fi 11040a31a186aSmrg done 11041a31a186aSmrg # Quote the link command for shipping. 110421e423a8fSmrg func_quote eval cd "`pwd`" 110431e423a8fSmrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 110441e423a8fSmrg func_quote_arg pretty,unquoted "$relink_command" 110451e423a8fSmrg relink_command=$func_quote_arg_unquoted_result 11046493f84f4Smrg if test yes = "$hardcode_automatic"; then 11047a31a186aSmrg relink_command= 11048a31a186aSmrg fi 11049fe5e51b7Smrg 11050a31a186aSmrg # Only create the output if not a dry run. 11051a31a186aSmrg $opt_dry_run || { 11052a31a186aSmrg for installed in no yes; do 11053493f84f4Smrg if test yes = "$installed"; then 11054a31a186aSmrg if test -z "$install_libdir"; then 11055a31a186aSmrg break 11056a31a186aSmrg fi 11057493f84f4Smrg output=$output_objdir/${outputname}i 11058a31a186aSmrg # Replace all uninstalled libtool libraries with the installed ones 11059a31a186aSmrg newdependency_libs= 11060a31a186aSmrg for deplib in $dependency_libs; do 11061a31a186aSmrg case $deplib in 11062a31a186aSmrg *.la) 11063a31a186aSmrg func_basename "$deplib" 11064493f84f4Smrg name=$func_basename_result 110650bb88ba4Smrg func_resolve_sysroot "$deplib" 11066493f84f4Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 11067a31a186aSmrg test -z "$libdir" && \ 11068493f84f4Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 110690bb88ba4Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 110700bb88ba4Smrg ;; 110710bb88ba4Smrg -L*) 110720bb88ba4Smrg func_stripname -L '' "$deplib" 110730bb88ba4Smrg func_replace_sysroot "$func_stripname_result" 110740bb88ba4Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 11075a31a186aSmrg ;; 110760bb88ba4Smrg -R*) 110770bb88ba4Smrg func_stripname -R '' "$deplib" 110780bb88ba4Smrg func_replace_sysroot "$func_stripname_result" 110790bb88ba4Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 110800bb88ba4Smrg ;; 110810bb88ba4Smrg *) func_append newdependency_libs " $deplib" ;; 11082a31a186aSmrg esac 11083a31a186aSmrg done 11084493f84f4Smrg dependency_libs=$newdependency_libs 11085a31a186aSmrg newdlfiles= 11086a31a186aSmrg 11087a31a186aSmrg for lib in $dlfiles; do 11088a31a186aSmrg case $lib in 11089a31a186aSmrg *.la) 11090a31a186aSmrg func_basename "$lib" 11091493f84f4Smrg name=$func_basename_result 11092493f84f4Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11093a31a186aSmrg test -z "$libdir" && \ 11094493f84f4Smrg func_fatal_error "'$lib' is not a valid libtool archive" 110950bb88ba4Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 11096a31a186aSmrg ;; 110970bb88ba4Smrg *) func_append newdlfiles " $lib" ;; 11098a31a186aSmrg esac 11099a31a186aSmrg done 11100493f84f4Smrg dlfiles=$newdlfiles 11101a31a186aSmrg newdlprefiles= 11102a31a186aSmrg for lib in $dlprefiles; do 11103a31a186aSmrg case $lib in 11104a31a186aSmrg *.la) 11105a31a186aSmrg # Only pass preopened files to the pseudo-archive (for 11106a31a186aSmrg # eventual linking with the app. that links it) if we 11107a31a186aSmrg # didn't already link the preopened objects directly into 11108a31a186aSmrg # the library: 11109a31a186aSmrg func_basename "$lib" 11110493f84f4Smrg name=$func_basename_result 11111493f84f4Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11112a31a186aSmrg test -z "$libdir" && \ 11113493f84f4Smrg func_fatal_error "'$lib' is not a valid libtool archive" 111140bb88ba4Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 11115a31a186aSmrg ;; 11116a31a186aSmrg esac 11117a31a186aSmrg done 11118493f84f4Smrg dlprefiles=$newdlprefiles 11119a31a186aSmrg else 11120a31a186aSmrg newdlfiles= 11121a31a186aSmrg for lib in $dlfiles; do 11122a31a186aSmrg case $lib in 11123493f84f4Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11124a31a186aSmrg *) abs=`pwd`"/$lib" ;; 11125a31a186aSmrg esac 111260bb88ba4Smrg func_append newdlfiles " $abs" 11127a31a186aSmrg done 11128493f84f4Smrg dlfiles=$newdlfiles 11129a31a186aSmrg newdlprefiles= 11130a31a186aSmrg for lib in $dlprefiles; do 11131a31a186aSmrg case $lib in 11132493f84f4Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11133a31a186aSmrg *) abs=`pwd`"/$lib" ;; 11134a31a186aSmrg esac 111350bb88ba4Smrg func_append newdlprefiles " $abs" 11136a31a186aSmrg done 11137493f84f4Smrg dlprefiles=$newdlprefiles 11138a31a186aSmrg fi 11139a31a186aSmrg $RM $output 11140a31a186aSmrg # place dlname in correct position for cygwin 111410bb88ba4Smrg # In fact, it would be nice if we could use this code for all target 111420bb88ba4Smrg # systems that can't hard-code library paths into their executables 111430bb88ba4Smrg # and that have no shared library path variable independent of PATH, 111440bb88ba4Smrg # but it turns out we can't easily determine that from inspecting 111450bb88ba4Smrg # libtool variables, so we have to hard-code the OSs to which it 111460bb88ba4Smrg # applies here; at the moment, that means platforms that use the PE 111470bb88ba4Smrg # object format with DLL files. See the long comment at the top of 111480bb88ba4Smrg # tests/bindir.at for full details. 11149a31a186aSmrg tdlname=$dlname 11150a31a186aSmrg case $host,$output,$installed,$module,$dlname in 111510bb88ba4Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 111520bb88ba4Smrg # If a -bindir argument was supplied, place the dll there. 11153493f84f4Smrg if test -n "$bindir"; then 111540bb88ba4Smrg func_relative_path "$install_libdir" "$bindir" 11155493f84f4Smrg tdlname=$func_relative_path_result/$dlname 111560bb88ba4Smrg else 111570bb88ba4Smrg # Otherwise fall back on heuristic. 111580bb88ba4Smrg tdlname=../bin/$dlname 111590bb88ba4Smrg fi 111600bb88ba4Smrg ;; 11161a31a186aSmrg esac 11162a31a186aSmrg $ECHO > $output "\ 11163a31a186aSmrg# $outputname - a libtool library file 11164493f84f4Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 11165a31a186aSmrg# 11166a31a186aSmrg# Please DO NOT delete this file! 11167a31a186aSmrg# It is necessary for linking the library. 11168fe5e51b7Smrg 11169a31a186aSmrg# The name that we can dlopen(3). 11170a31a186aSmrgdlname='$tdlname' 11171fe5e51b7Smrg 11172a31a186aSmrg# Names of this library. 11173a31a186aSmrglibrary_names='$library_names' 11174fe5e51b7Smrg 11175a31a186aSmrg# The name of the static archive. 11176a31a186aSmrgold_library='$old_library' 11177fe5e51b7Smrg 11178493f84f4Smrg# Linker flags that cannot go in dependency_libs. 11179a31a186aSmrginherited_linker_flags='$new_inherited_linker_flags' 11180fe5e51b7Smrg 11181a31a186aSmrg# Libraries that this one depends upon. 11182a31a186aSmrgdependency_libs='$dependency_libs' 11183fe5e51b7Smrg 11184a31a186aSmrg# Names of additional weak libraries provided by this library 11185a31a186aSmrgweak_library_names='$weak_libs' 11186fe5e51b7Smrg 11187a31a186aSmrg# Version information for $libname. 11188a31a186aSmrgcurrent=$current 11189a31a186aSmrgage=$age 11190a31a186aSmrgrevision=$revision 11191fe5e51b7Smrg 11192a31a186aSmrg# Is this an already installed library? 11193a31a186aSmrginstalled=$installed 11194fe5e51b7Smrg 11195a31a186aSmrg# Should we warn about portability when linking against -modules? 11196a31a186aSmrgshouldnotlink=$module 11197fe5e51b7Smrg 11198a31a186aSmrg# Files to dlopen/dlpreopen 11199a31a186aSmrgdlopen='$dlfiles' 11200a31a186aSmrgdlpreopen='$dlprefiles' 11201fe5e51b7Smrg 11202a31a186aSmrg# Directory that this library needs to be installed in: 11203a31a186aSmrglibdir='$install_libdir'" 11204493f84f4Smrg if test no,yes = "$installed,$need_relink"; then 11205a31a186aSmrg $ECHO >> $output "\ 11206a31a186aSmrgrelink_command=\"$relink_command\"" 11207a31a186aSmrg fi 11208a31a186aSmrg done 11209a31a186aSmrg } 11210fe5e51b7Smrg 11211a31a186aSmrg # Do a symbolic link so that the libtool archive can be found in 11212a31a186aSmrg # LD_LIBRARY_PATH before the program is installed. 11213a31a186aSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 11214a31a186aSmrg ;; 11215a31a186aSmrg esac 11216a31a186aSmrg exit $EXIT_SUCCESS 11217a31a186aSmrg} 11218643b027fSmrg 11219493f84f4Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 11220493f84f4Smrg func_mode_link ${1+"$@"} 11221493f84f4Smrgfi 11222fe5e51b7Smrg 11223fe5e51b7Smrg 11224a31a186aSmrg# func_mode_uninstall arg... 11225a31a186aSmrgfunc_mode_uninstall () 11226a31a186aSmrg{ 11227493f84f4Smrg $debug_cmd 11228493f84f4Smrg 11229493f84f4Smrg RM=$nonopt 11230fe5e51b7Smrg files= 11231493f84f4Smrg rmforce=false 11232fe5e51b7Smrg exit_status=0 11233fe5e51b7Smrg 11234fe5e51b7Smrg # This variable tells wrapper scripts just to set variables rather 11235fe5e51b7Smrg # than running their programs. 11236493f84f4Smrg libtool_install_magic=$magic 11237fe5e51b7Smrg 11238fe5e51b7Smrg for arg 11239fe5e51b7Smrg do 11240fe5e51b7Smrg case $arg in 11241493f84f4Smrg -f) func_append RM " $arg"; rmforce=: ;; 112420bb88ba4Smrg -*) func_append RM " $arg" ;; 112430bb88ba4Smrg *) func_append files " $arg" ;; 11244fe5e51b7Smrg esac 11245fe5e51b7Smrg done 11246fe5e51b7Smrg 11247a31a186aSmrg test -z "$RM" && \ 11248a31a186aSmrg func_fatal_help "you must specify an RM program" 11249fe5e51b7Smrg 11250fe5e51b7Smrg rmdirs= 11251fe5e51b7Smrg 11252fe5e51b7Smrg for file in $files; do 11253a31a186aSmrg func_dirname "$file" "" "." 11254493f84f4Smrg dir=$func_dirname_result 11255493f84f4Smrg if test . = "$dir"; then 11256493f84f4Smrg odir=$objdir 11257fe5e51b7Smrg else 11258493f84f4Smrg odir=$dir/$objdir 11259fe5e51b7Smrg fi 11260a31a186aSmrg func_basename "$file" 11261493f84f4Smrg name=$func_basename_result 11262493f84f4Smrg test uninstall = "$opt_mode" && odir=$dir 11263fe5e51b7Smrg 112640bb88ba4Smrg # Remember odir for removal later, being careful to avoid duplicates 11265493f84f4Smrg if test clean = "$opt_mode"; then 11266fe5e51b7Smrg case " $rmdirs " in 112670bb88ba4Smrg *" $odir "*) ;; 112680bb88ba4Smrg *) func_append rmdirs " $odir" ;; 11269fe5e51b7Smrg esac 11270fe5e51b7Smrg fi 11271fe5e51b7Smrg 11272fe5e51b7Smrg # Don't error if the file doesn't exist and rm -f was used. 11273a31a186aSmrg if { test -L "$file"; } >/dev/null 2>&1 || 11274a31a186aSmrg { test -h "$file"; } >/dev/null 2>&1 || 11275a31a186aSmrg test -f "$file"; then 11276fe5e51b7Smrg : 11277fe5e51b7Smrg elif test -d "$file"; then 11278fe5e51b7Smrg exit_status=1 11279fe5e51b7Smrg continue 11280493f84f4Smrg elif $rmforce; then 11281fe5e51b7Smrg continue 11282fe5e51b7Smrg fi 11283fe5e51b7Smrg 11284493f84f4Smrg rmfiles=$file 11285fe5e51b7Smrg 11286fe5e51b7Smrg case $name in 11287fe5e51b7Smrg *.la) 11288fe5e51b7Smrg # Possibly a libtool archive, so verify it. 11289a31a186aSmrg if func_lalib_p "$file"; then 11290a31a186aSmrg func_source $dir/$name 11291fe5e51b7Smrg 11292fe5e51b7Smrg # Delete the libtool libraries and symlinks. 11293fe5e51b7Smrg for n in $library_names; do 112940bb88ba4Smrg func_append rmfiles " $odir/$n" 11295fe5e51b7Smrg done 112960bb88ba4Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11297fe5e51b7Smrg 11298493f84f4Smrg case $opt_mode in 11299fe5e51b7Smrg clean) 113000bb88ba4Smrg case " $library_names " in 11301fe5e51b7Smrg *" $dlname "*) ;; 113020bb88ba4Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11303fe5e51b7Smrg esac 113040bb88ba4Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11305fe5e51b7Smrg ;; 11306fe5e51b7Smrg uninstall) 11307fe5e51b7Smrg if test -n "$library_names"; then 11308fe5e51b7Smrg # Do each command in the postuninstall commands. 11309493f84f4Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11310fe5e51b7Smrg fi 11311fe5e51b7Smrg 11312fe5e51b7Smrg if test -n "$old_library"; then 11313fe5e51b7Smrg # Do each command in the old_postuninstall commands. 11314493f84f4Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11315fe5e51b7Smrg fi 11316fe5e51b7Smrg # FIXME: should reinstall the best remaining shared library. 11317fe5e51b7Smrg ;; 11318fe5e51b7Smrg esac 11319fe5e51b7Smrg fi 11320fe5e51b7Smrg ;; 11321fe5e51b7Smrg 11322fe5e51b7Smrg *.lo) 11323fe5e51b7Smrg # Possibly a libtool object, so verify it. 11324a31a186aSmrg if func_lalib_p "$file"; then 11325fe5e51b7Smrg 11326fe5e51b7Smrg # Read the .lo file 11327a31a186aSmrg func_source $dir/$name 11328fe5e51b7Smrg 11329fe5e51b7Smrg # Add PIC object to the list of files to remove. 11330493f84f4Smrg if test -n "$pic_object" && test none != "$pic_object"; then 113310bb88ba4Smrg func_append rmfiles " $dir/$pic_object" 11332fe5e51b7Smrg fi 11333fe5e51b7Smrg 11334fe5e51b7Smrg # Add non-PIC object to the list of files to remove. 11335493f84f4Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 113360bb88ba4Smrg func_append rmfiles " $dir/$non_pic_object" 11337fe5e51b7Smrg fi 11338fe5e51b7Smrg fi 11339fe5e51b7Smrg ;; 11340fe5e51b7Smrg 11341fe5e51b7Smrg *) 11342493f84f4Smrg if test clean = "$opt_mode"; then 11343fe5e51b7Smrg noexename=$name 11344fe5e51b7Smrg case $file in 11345fe5e51b7Smrg *.exe) 11346a31a186aSmrg func_stripname '' '.exe' "$file" 11347a31a186aSmrg file=$func_stripname_result 11348a31a186aSmrg func_stripname '' '.exe' "$name" 11349a31a186aSmrg noexename=$func_stripname_result 11350fe5e51b7Smrg # $file with .exe has already been added to rmfiles, 11351fe5e51b7Smrg # add $file without .exe 113520bb88ba4Smrg func_append rmfiles " $file" 11353fe5e51b7Smrg ;; 11354fe5e51b7Smrg esac 11355fe5e51b7Smrg # Do a test to see if this is a libtool program. 11356a31a186aSmrg if func_ltwrapper_p "$file"; then 11357a31a186aSmrg if func_ltwrapper_executable_p "$file"; then 11358a31a186aSmrg func_ltwrapper_scriptname "$file" 11359a31a186aSmrg relink_command= 11360a31a186aSmrg func_source $func_ltwrapper_scriptname_result 113610bb88ba4Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11362a31a186aSmrg else 11363a31a186aSmrg relink_command= 11364a31a186aSmrg func_source $dir/$noexename 11365a31a186aSmrg fi 11366fe5e51b7Smrg 11367fe5e51b7Smrg # note $name still contains .exe if it was in $file originally 11368fe5e51b7Smrg # as does the version of $file that was added into $rmfiles 11369493f84f4Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11370493f84f4Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 113710bb88ba4Smrg func_append rmfiles " $odir/lt-$name" 11372fe5e51b7Smrg fi 11373493f84f4Smrg if test "X$noexename" != "X$name"; then 11374493f84f4Smrg func_append rmfiles " $odir/lt-$noexename.c" 11375fe5e51b7Smrg fi 11376fe5e51b7Smrg fi 11377fe5e51b7Smrg fi 11378fe5e51b7Smrg ;; 11379fe5e51b7Smrg esac 11380a31a186aSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11381fe5e51b7Smrg done 11382fe5e51b7Smrg 11383493f84f4Smrg # Try to remove the $objdir's in the directories where we deleted files 11384fe5e51b7Smrg for dir in $rmdirs; do 11385fe5e51b7Smrg if test -d "$dir"; then 11386a31a186aSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11387fe5e51b7Smrg fi 11388fe5e51b7Smrg done 11389fe5e51b7Smrg 11390fe5e51b7Smrg exit $exit_status 11391a31a186aSmrg} 11392fe5e51b7Smrg 11393493f84f4Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11394493f84f4Smrg func_mode_uninstall ${1+"$@"} 11395493f84f4Smrgfi 11396eda3803bSmrg 113970bb88ba4Smrgtest -z "$opt_mode" && { 11398493f84f4Smrg help=$generic_help 11399a31a186aSmrg func_fatal_help "you must specify a MODE" 11400a31a186aSmrg} 11401a31a186aSmrg 11402a31a186aSmrgtest -z "$exec_cmd" && \ 11403493f84f4Smrg func_fatal_help "invalid operation mode '$opt_mode'" 11404fe5e51b7Smrg 11405fe5e51b7Smrgif test -n "$exec_cmd"; then 11406a31a186aSmrg eval exec "$exec_cmd" 11407fe5e51b7Smrg exit $EXIT_FAILURE 11408fe5e51b7Smrgfi 11409fe5e51b7Smrg 11410a31a186aSmrgexit $exit_status 11411fe5e51b7Smrg 11412fe5e51b7Smrg 11413fe5e51b7Smrg# The TAGs below are defined such that we never get into a situation 11414493f84f4Smrg# where we disable both kinds of libraries. Given conflicting 11415fe5e51b7Smrg# choices, we go for a static library, that is the most portable, 11416fe5e51b7Smrg# since we can't tell whether shared libraries were disabled because 11417fe5e51b7Smrg# the user asked for that or because the platform doesn't support 11418fe5e51b7Smrg# them. This is particularly important on AIX, because we don't 11419fe5e51b7Smrg# support having both static and shared libraries enabled at the same 11420fe5e51b7Smrg# time on that platform, so we default to a shared-only configuration. 11421fe5e51b7Smrg# If a disable-shared tag is given, we'll fallback to a static-only 11422fe5e51b7Smrg# configuration. But we'll never go from static-only to shared-only. 11423fe5e51b7Smrg 11424fe5e51b7Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11425a31a186aSmrgbuild_libtool_libs=no 11426a31a186aSmrgbuild_old_libs=yes 11427fe5e51b7Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 11428fe5e51b7Smrg 11429fe5e51b7Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11430a31a186aSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11431fe5e51b7Smrg# ### END LIBTOOL TAG CONFIG: disable-static 11432fe5e51b7Smrg 11433fe5e51b7Smrg# Local Variables: 11434fe5e51b7Smrg# mode:shell-script 11435fe5e51b7Smrg# sh-indentation:2 11436fe5e51b7Smrg# End: 11437