ltmain.sh revision bd23fbfa
18c4a8e55Smrg 2bd23fbfaSmrg# libtool (GNU libtool) 2.4 38c4a8e55Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 48c4a8e55Smrg 5706b6b52Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 6706b6b52Smrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 78c4a8e55Smrg# This is free software; see the source for copying conditions. There is NO 88c4a8e55Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 98c4a8e55Smrg 108c4a8e55Smrg# GNU Libtool is free software; you can redistribute it and/or modify 11b042e37fSmrg# it under the terms of the GNU General Public License as published by 12b042e37fSmrg# the Free Software Foundation; either version 2 of the License, or 13b042e37fSmrg# (at your option) any later version. 14b042e37fSmrg# 158c4a8e55Smrg# As a special exception to the GNU General Public License, 168c4a8e55Smrg# if you distribute this file as part of a program or library that 178c4a8e55Smrg# is built using GNU Libtool, you may include this file under the 188c4a8e55Smrg# same distribution terms that you use for the rest of that program. 198c4a8e55Smrg# 208c4a8e55Smrg# GNU Libtool is distributed in the hope that it will be useful, but 21b042e37fSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 22b042e37fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23b042e37fSmrg# General Public License for more details. 24b042e37fSmrg# 25b042e37fSmrg# You should have received a copy of the GNU General Public License 268c4a8e55Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 278c4a8e55Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 288c4a8e55Smrg# or obtained by writing to the Free Software Foundation, Inc., 298c4a8e55Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 308c4a8e55Smrg 318c4a8e55Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 328c4a8e55Smrg# 338c4a8e55Smrg# Provide generalized library-building support services. 34b042e37fSmrg# 35706b6b52Smrg# --config show all configuration variables 36706b6b52Smrg# --debug enable verbose shell tracing 37706b6b52Smrg# -n, --dry-run display commands without modifying any files 38706b6b52Smrg# --features display basic configuration information and exit 39706b6b52Smrg# --mode=MODE use operation mode MODE 40706b6b52Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 41706b6b52Smrg# --quiet, --silent don't print informational messages 42706b6b52Smrg# --no-quiet, --no-silent 43706b6b52Smrg# print informational messages (default) 44706b6b52Smrg# --tag=TAG use configuration variables from tag TAG 45706b6b52Smrg# -v, --verbose print more informational messages than default 46706b6b52Smrg# --no-verbose don't print the extra informational messages 47706b6b52Smrg# --version print version information 48706b6b52Smrg# -h, --help, --help-all print short, long, or detailed help message 498c4a8e55Smrg# 508c4a8e55Smrg# MODE must be one of the following: 518c4a8e55Smrg# 52706b6b52Smrg# clean remove files from the build directory 53706b6b52Smrg# compile compile a source file into a libtool object 54706b6b52Smrg# execute automatically set library path, then run a program 55706b6b52Smrg# finish complete the installation of libtool libraries 56706b6b52Smrg# install install libraries or executables 57706b6b52Smrg# link create a library or an executable 58706b6b52Smrg# uninstall remove libraries from an installed directory 598c4a8e55Smrg# 60706b6b52Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 61706b6b52Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 628c4a8e55Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 638c4a8e55Smrg# 648c4a8e55Smrg# When reporting a bug, please describe a test case to reproduce it and 658c4a8e55Smrg# include the following information: 668c4a8e55Smrg# 67706b6b52Smrg# host-triplet: $host 68706b6b52Smrg# shell: $SHELL 69706b6b52Smrg# compiler: $LTCC 70706b6b52Smrg# compiler flags: $LTCFLAGS 71706b6b52Smrg# linker: $LD (gnu? $with_gnu_ld) 72bd23fbfaSmrg# $progname: (GNU libtool) 2.4 73706b6b52Smrg# automake: $automake_version 74706b6b52Smrg# autoconf: $autoconf_version 758c4a8e55Smrg# 768c4a8e55Smrg# Report bugs to <bug-libtool@gnu.org>. 77bd23fbfaSmrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 78bd23fbfaSmrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 798c4a8e55Smrg 80706b6b52SmrgPROGRAM=libtool 818c4a8e55SmrgPACKAGE=libtool 82bd23fbfaSmrgVERSION=2.4 838c4a8e55SmrgTIMESTAMP="" 84bd23fbfaSmrgpackage_revision=1.3293 858c4a8e55Smrg 868c4a8e55Smrg# Be Bourne compatible 878c4a8e55Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 888c4a8e55Smrg emulate sh 898c4a8e55Smrg NULLCMD=: 908c4a8e55Smrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 918c4a8e55Smrg # is contrary to our usage. Disable this feature. 928c4a8e55Smrg alias -g '${1+"$@"}'='"$@"' 938c4a8e55Smrg setopt NO_GLOB_SUBST 948c4a8e55Smrgelse 958c4a8e55Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 968c4a8e55Smrgfi 978c4a8e55SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 988c4a8e55SmrgDUALCASE=1; export DUALCASE # for MKS sh 998c4a8e55Smrg 100706b6b52Smrg# A function that is used when there is no print builtin or printf. 101706b6b52Smrgfunc_fallback_echo () 102706b6b52Smrg{ 103706b6b52Smrg eval 'cat <<_LTECHO_EOF 104706b6b52Smrg$1 105706b6b52Smrg_LTECHO_EOF' 106706b6b52Smrg} 107706b6b52Smrg 1088c4a8e55Smrg# NLS nuisances: We save the old values to restore during execute mode. 1098c4a8e55Smrglt_user_locale= 1108c4a8e55Smrglt_safe_locale= 1118c4a8e55Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1128c4a8e55Smrgdo 1138c4a8e55Smrg eval "if test \"\${$lt_var+set}\" = set; then 1148c4a8e55Smrg save_$lt_var=\$$lt_var 1158c4a8e55Smrg $lt_var=C 1168c4a8e55Smrg export $lt_var 1178c4a8e55Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 1188c4a8e55Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 1198c4a8e55Smrg fi" 1208c4a8e55Smrgdone 121706b6b52SmrgLC_ALL=C 122706b6b52SmrgLANGUAGE=C 123706b6b52Smrgexport LANGUAGE LC_ALL 1248c4a8e55Smrg 1258c4a8e55Smrg$lt_unset CDPATH 1268c4a8e55Smrg 1278c4a8e55Smrg 128706b6b52Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 129706b6b52Smrg# is ksh but when the shell is invoked as "sh" and the current value of 130706b6b52Smrg# the _XPG environment variable is not equal to 1 (one), the special 131706b6b52Smrg# positional parameter $0, within a function call, is the name of the 132706b6b52Smrg# function. 133706b6b52Smrgprogpath="$0" 1348c4a8e55Smrg 1358c4a8e55Smrg 1368c4a8e55Smrg 1378c4a8e55Smrg: ${CP="cp -f"} 138706b6b52Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 139706b6b52Smrg: ${EGREP="grep -E"} 140706b6b52Smrg: ${FGREP="grep -F"} 141706b6b52Smrg: ${GREP="grep"} 1428c4a8e55Smrg: ${LN_S="ln -s"} 1438c4a8e55Smrg: ${MAKE="make"} 1448c4a8e55Smrg: ${MKDIR="mkdir"} 1458c4a8e55Smrg: ${MV="mv -f"} 1468c4a8e55Smrg: ${RM="rm -f"} 147706b6b52Smrg: ${SED="sed"} 1488c4a8e55Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 1498c4a8e55Smrg: ${Xsed="$SED -e 1s/^X//"} 150b042e37fSmrg 1518c4a8e55Smrg# Global variables: 1528c4a8e55SmrgEXIT_SUCCESS=0 1538c4a8e55SmrgEXIT_FAILURE=1 1548c4a8e55SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 1558c4a8e55SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 1568c4a8e55Smrg 1578c4a8e55Smrgexit_status=$EXIT_SUCCESS 1588c4a8e55Smrg 1598c4a8e55Smrg# Make sure IFS has a sensible default 1608c4a8e55Smrglt_nl=' 1618c4a8e55Smrg' 1628c4a8e55SmrgIFS=" $lt_nl" 1638c4a8e55Smrg 1648c4a8e55Smrgdirname="s,/[^/]*$,," 1658c4a8e55Smrgbasename="s,^.*/,," 1668c4a8e55Smrg 167bd23fbfaSmrg# func_dirname file append nondir_replacement 168bd23fbfaSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 169bd23fbfaSmrg# otherwise set result to NONDIR_REPLACEMENT. 170bd23fbfaSmrgfunc_dirname () 171bd23fbfaSmrg{ 172bd23fbfaSmrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 173bd23fbfaSmrg if test "X$func_dirname_result" = "X${1}"; then 174bd23fbfaSmrg func_dirname_result="${3}" 175bd23fbfaSmrg else 176bd23fbfaSmrg func_dirname_result="$func_dirname_result${2}" 177bd23fbfaSmrg fi 178bd23fbfaSmrg} # func_dirname may be replaced by extended shell implementation 179bd23fbfaSmrg 180bd23fbfaSmrg 181bd23fbfaSmrg# func_basename file 182bd23fbfaSmrgfunc_basename () 183bd23fbfaSmrg{ 184bd23fbfaSmrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 185bd23fbfaSmrg} # func_basename may be replaced by extended shell implementation 186bd23fbfaSmrg 187bd23fbfaSmrg 1888c4a8e55Smrg# func_dirname_and_basename file append nondir_replacement 1898c4a8e55Smrg# perform func_basename and func_dirname in a single function 1908c4a8e55Smrg# call: 1918c4a8e55Smrg# dirname: Compute the dirname of FILE. If nonempty, 1928c4a8e55Smrg# add APPEND to the result, otherwise set result 1938c4a8e55Smrg# to NONDIR_REPLACEMENT. 1948c4a8e55Smrg# value returned in "$func_dirname_result" 1958c4a8e55Smrg# basename: Compute filename of FILE. 1968c4a8e55Smrg# value retuned in "$func_basename_result" 1978c4a8e55Smrg# Implementation must be kept synchronized with func_dirname 1988c4a8e55Smrg# and func_basename. For efficiency, we do not delegate to 1998c4a8e55Smrg# those functions but instead duplicate the functionality here. 2008c4a8e55Smrgfunc_dirname_and_basename () 2018c4a8e55Smrg{ 202bd23fbfaSmrg # Extract subdirectory from the argument. 203bd23fbfaSmrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 204bd23fbfaSmrg if test "X$func_dirname_result" = "X${1}"; then 205bd23fbfaSmrg func_dirname_result="${3}" 206bd23fbfaSmrg else 207bd23fbfaSmrg func_dirname_result="$func_dirname_result${2}" 208bd23fbfaSmrg fi 209bd23fbfaSmrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 210bd23fbfaSmrg} # func_dirname_and_basename may be replaced by extended shell implementation 211bd23fbfaSmrg 212bd23fbfaSmrg 213bd23fbfaSmrg# func_stripname prefix suffix name 214bd23fbfaSmrg# strip PREFIX and SUFFIX off of NAME. 215bd23fbfaSmrg# PREFIX and SUFFIX must not contain globbing or regex special 216bd23fbfaSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 217bd23fbfaSmrg# dot (in which case that matches only a dot). 218bd23fbfaSmrg# func_strip_suffix prefix name 219bd23fbfaSmrgfunc_stripname () 220bd23fbfaSmrg{ 221bd23fbfaSmrg case ${2} in 222bd23fbfaSmrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 223bd23fbfaSmrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 224bd23fbfaSmrg esac 225bd23fbfaSmrg} # func_stripname may be replaced by extended shell implementation 2268c4a8e55Smrg 227b042e37fSmrg 228706b6b52Smrg# These SED scripts presuppose an absolute path with a trailing slash. 229706b6b52Smrgpathcar='s,^/\([^/]*\).*$,\1,' 230706b6b52Smrgpathcdr='s,^/[^/]*,,' 231706b6b52Smrgremovedotparts=':dotsl 232706b6b52Smrg s@/\./@/@g 233706b6b52Smrg t dotsl 234706b6b52Smrg s,/\.$,/,' 235706b6b52Smrgcollapseslashes='s@/\{1,\}@/@g' 236706b6b52Smrgfinalslash='s,/*$,/,' 237706b6b52Smrg 238706b6b52Smrg# func_normal_abspath PATH 239706b6b52Smrg# Remove doubled-up and trailing slashes, "." path components, 240706b6b52Smrg# and cancel out any ".." path components in PATH after making 241706b6b52Smrg# it an absolute path. 242706b6b52Smrg# value returned in "$func_normal_abspath_result" 243706b6b52Smrgfunc_normal_abspath () 244706b6b52Smrg{ 245706b6b52Smrg # Start from root dir and reassemble the path. 246706b6b52Smrg func_normal_abspath_result= 247706b6b52Smrg func_normal_abspath_tpath=$1 248706b6b52Smrg func_normal_abspath_altnamespace= 249706b6b52Smrg case $func_normal_abspath_tpath in 250706b6b52Smrg "") 251706b6b52Smrg # Empty path, that just means $cwd. 252706b6b52Smrg func_stripname '' '/' "`pwd`" 253706b6b52Smrg func_normal_abspath_result=$func_stripname_result 254706b6b52Smrg return 255706b6b52Smrg ;; 256706b6b52Smrg # The next three entries are used to spot a run of precisely 257706b6b52Smrg # two leading slashes without using negated character classes; 258706b6b52Smrg # we take advantage of case's first-match behaviour. 259706b6b52Smrg ///*) 260706b6b52Smrg # Unusual form of absolute path, do nothing. 261706b6b52Smrg ;; 262706b6b52Smrg //*) 263706b6b52Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 264706b6b52Smrg # and for example Cygwin uses it to access remote file shares 265706b6b52Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 266706b6b52Smrg func_normal_abspath_altnamespace=/ 267706b6b52Smrg ;; 268706b6b52Smrg /*) 269706b6b52Smrg # Absolute path, do nothing. 270706b6b52Smrg ;; 271706b6b52Smrg *) 272706b6b52Smrg # Relative path, prepend $cwd. 273706b6b52Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 274706b6b52Smrg ;; 275706b6b52Smrg esac 276706b6b52Smrg # Cancel out all the simple stuff to save iterations. We also want 277706b6b52Smrg # the path to end with a slash for ease of parsing, so make sure 278706b6b52Smrg # there is one (and only one) here. 279706b6b52Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 280706b6b52Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 281706b6b52Smrg while :; do 282706b6b52Smrg # Processed it all yet? 283706b6b52Smrg if test "$func_normal_abspath_tpath" = / ; then 284706b6b52Smrg # If we ascended to the root using ".." the result may be empty now. 285706b6b52Smrg if test -z "$func_normal_abspath_result" ; then 286706b6b52Smrg func_normal_abspath_result=/ 287706b6b52Smrg fi 288706b6b52Smrg break 289706b6b52Smrg fi 290706b6b52Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 291706b6b52Smrg -e "$pathcar"` 292706b6b52Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 293706b6b52Smrg -e "$pathcdr"` 294706b6b52Smrg # Figure out what to do with it 295706b6b52Smrg case $func_normal_abspath_tcomponent in 296706b6b52Smrg "") 297706b6b52Smrg # Trailing empty path component, ignore it. 298706b6b52Smrg ;; 299706b6b52Smrg ..) 300706b6b52Smrg # Parent dir; strip last assembled component from result. 301706b6b52Smrg func_dirname "$func_normal_abspath_result" 302706b6b52Smrg func_normal_abspath_result=$func_dirname_result 303706b6b52Smrg ;; 304706b6b52Smrg *) 305706b6b52Smrg # Actual path component, append it. 306706b6b52Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 307706b6b52Smrg ;; 308706b6b52Smrg esac 309706b6b52Smrg done 310706b6b52Smrg # Restore leading double-slash if one was found on entry. 311706b6b52Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 312706b6b52Smrg} 313706b6b52Smrg 314706b6b52Smrg# func_relative_path SRCDIR DSTDIR 315706b6b52Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 316706b6b52Smrg# slash if non-empty, suitable for immediately appending a filename 317706b6b52Smrg# without needing to append a separator. 318706b6b52Smrg# value returned in "$func_relative_path_result" 319706b6b52Smrgfunc_relative_path () 320706b6b52Smrg{ 321706b6b52Smrg func_relative_path_result= 322706b6b52Smrg func_normal_abspath "$1" 323706b6b52Smrg func_relative_path_tlibdir=$func_normal_abspath_result 324706b6b52Smrg func_normal_abspath "$2" 325706b6b52Smrg func_relative_path_tbindir=$func_normal_abspath_result 326706b6b52Smrg 327706b6b52Smrg # Ascend the tree starting from libdir 328706b6b52Smrg while :; do 329706b6b52Smrg # check if we have found a prefix of bindir 330706b6b52Smrg case $func_relative_path_tbindir in 331706b6b52Smrg $func_relative_path_tlibdir) 332706b6b52Smrg # found an exact match 333706b6b52Smrg func_relative_path_tcancelled= 334706b6b52Smrg break 335706b6b52Smrg ;; 336706b6b52Smrg $func_relative_path_tlibdir*) 337706b6b52Smrg # found a matching prefix 338706b6b52Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 339706b6b52Smrg func_relative_path_tcancelled=$func_stripname_result 340706b6b52Smrg if test -z "$func_relative_path_result"; then 341706b6b52Smrg func_relative_path_result=. 342706b6b52Smrg fi 343706b6b52Smrg break 344706b6b52Smrg ;; 345706b6b52Smrg *) 346706b6b52Smrg func_dirname $func_relative_path_tlibdir 347706b6b52Smrg func_relative_path_tlibdir=${func_dirname_result} 348706b6b52Smrg if test "x$func_relative_path_tlibdir" = x ; then 349706b6b52Smrg # Have to descend all the way to the root! 350706b6b52Smrg func_relative_path_result=../$func_relative_path_result 351706b6b52Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 352706b6b52Smrg break 353706b6b52Smrg fi 354706b6b52Smrg func_relative_path_result=../$func_relative_path_result 355706b6b52Smrg ;; 356706b6b52Smrg esac 357706b6b52Smrg done 358706b6b52Smrg 359706b6b52Smrg # Now calculate path; take care to avoid doubling-up slashes. 360706b6b52Smrg func_stripname '' '/' "$func_relative_path_result" 361706b6b52Smrg func_relative_path_result=$func_stripname_result 362706b6b52Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 363706b6b52Smrg if test "x$func_stripname_result" != x ; then 364706b6b52Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 365706b6b52Smrg fi 366706b6b52Smrg 367706b6b52Smrg # Normalisation. If bindir is libdir, return empty string, 368706b6b52Smrg # else relative path ending with a slash; either way, target 369706b6b52Smrg # file name can be directly appended. 370706b6b52Smrg if test ! -z "$func_relative_path_result"; then 371706b6b52Smrg func_stripname './' '' "$func_relative_path_result/" 372706b6b52Smrg func_relative_path_result=$func_stripname_result 373706b6b52Smrg fi 374706b6b52Smrg} 375b042e37fSmrg 376b042e37fSmrg# The name of this program: 3778c4a8e55Smrgfunc_dirname_and_basename "$progpath" 3788c4a8e55Smrgprogname=$func_basename_result 379b042e37fSmrg 3808c4a8e55Smrg# Make sure we have an absolute path for reexecution: 3818c4a8e55Smrgcase $progpath in 3828c4a8e55Smrg [\\/]*|[A-Za-z]:\\*) ;; 3838c4a8e55Smrg *[\\/]*) 3848c4a8e55Smrg progdir=$func_dirname_result 3858c4a8e55Smrg progdir=`cd "$progdir" && pwd` 3868c4a8e55Smrg progpath="$progdir/$progname" 3878c4a8e55Smrg ;; 3888c4a8e55Smrg *) 3898c4a8e55Smrg save_IFS="$IFS" 3908c4a8e55Smrg IFS=: 3918c4a8e55Smrg for progdir in $PATH; do 3928c4a8e55Smrg IFS="$save_IFS" 3938c4a8e55Smrg test -x "$progdir/$progname" && break 3948c4a8e55Smrg done 3958c4a8e55Smrg IFS="$save_IFS" 3968c4a8e55Smrg test -n "$progdir" || progdir=`pwd` 3978c4a8e55Smrg progpath="$progdir/$progname" 3988c4a8e55Smrg ;; 3998c4a8e55Smrgesac 400b042e37fSmrg 4018c4a8e55Smrg# Sed substitution that helps us do robust quoting. It backslashifies 4028c4a8e55Smrg# metacharacters that are still active within double-quoted strings. 4038c4a8e55SmrgXsed="${SED}"' -e 1s/^X//' 4048c4a8e55Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 4058c4a8e55Smrg 4068c4a8e55Smrg# Same as above, but do not quote variable references. 4078c4a8e55Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 4088c4a8e55Smrg 409bd23fbfaSmrg# Sed substitution that turns a string into a regex matching for the 410bd23fbfaSmrg# string literally. 411bd23fbfaSmrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 412bd23fbfaSmrg 413bd23fbfaSmrg# Sed substitution that converts a w32 file name or path 414bd23fbfaSmrg# which contains forward slashes, into one that contains 415bd23fbfaSmrg# (escaped) backslashes. A very naive implementation. 416bd23fbfaSmrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 417bd23fbfaSmrg 4188c4a8e55Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 4198c4a8e55Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 4208c4a8e55Smrg# in input to double_quote_subst, that '$' was protected from expansion. 4218c4a8e55Smrg# Since each input `\' is now two `\'s, look for any number of runs of 4228c4a8e55Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 4238c4a8e55Smrgbs='\\' 4248c4a8e55Smrgbs2='\\\\' 4258c4a8e55Smrgbs4='\\\\\\\\' 4268c4a8e55Smrgdollar='\$' 4278c4a8e55Smrgsed_double_backslash="\ 4288c4a8e55Smrg s/$bs4/&\\ 4298c4a8e55Smrg/g 4308c4a8e55Smrg s/^$bs2$dollar/$bs&/ 4318c4a8e55Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 4328c4a8e55Smrg s/\n//g" 4338c4a8e55Smrg 4348c4a8e55Smrg# Standard options: 4358c4a8e55Smrgopt_dry_run=false 4368c4a8e55Smrgopt_help=false 4378c4a8e55Smrgopt_quiet=false 4388c4a8e55Smrgopt_verbose=false 4398c4a8e55Smrgopt_warning=: 4408c4a8e55Smrg 4418c4a8e55Smrg# func_echo arg... 4428c4a8e55Smrg# Echo program name prefixed message, along with the current mode 4438c4a8e55Smrg# name if it has been set yet. 4448c4a8e55Smrgfunc_echo () 4458c4a8e55Smrg{ 446bd23fbfaSmrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 4478c4a8e55Smrg} 448b042e37fSmrg 4498c4a8e55Smrg# func_verbose arg... 4508c4a8e55Smrg# Echo program name prefixed message in verbose mode only. 4518c4a8e55Smrgfunc_verbose () 4528c4a8e55Smrg{ 4538c4a8e55Smrg $opt_verbose && func_echo ${1+"$@"} 454b042e37fSmrg 4558c4a8e55Smrg # A bug in bash halts the script if the last line of a function 4568c4a8e55Smrg # fails when set -e is in force, so we need another command to 4578c4a8e55Smrg # work around that: 4588c4a8e55Smrg : 4598c4a8e55Smrg} 460b042e37fSmrg 461706b6b52Smrg# func_echo_all arg... 462706b6b52Smrg# Invoke $ECHO with all args, space-separated. 463706b6b52Smrgfunc_echo_all () 464706b6b52Smrg{ 465706b6b52Smrg $ECHO "$*" 466706b6b52Smrg} 467706b6b52Smrg 4688c4a8e55Smrg# func_error arg... 4698c4a8e55Smrg# Echo program name prefixed message to standard error. 4708c4a8e55Smrgfunc_error () 4718c4a8e55Smrg{ 472bd23fbfaSmrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 4738c4a8e55Smrg} 474b042e37fSmrg 4758c4a8e55Smrg# func_warning arg... 4768c4a8e55Smrg# Echo program name prefixed warning message to standard error. 4778c4a8e55Smrgfunc_warning () 4788c4a8e55Smrg{ 479bd23fbfaSmrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 480b042e37fSmrg 4818c4a8e55Smrg # bash bug again: 4828c4a8e55Smrg : 4838c4a8e55Smrg} 484b042e37fSmrg 4858c4a8e55Smrg# func_fatal_error arg... 4868c4a8e55Smrg# Echo program name prefixed message to standard error, and exit. 4878c4a8e55Smrgfunc_fatal_error () 4888c4a8e55Smrg{ 4898c4a8e55Smrg func_error ${1+"$@"} 4908c4a8e55Smrg exit $EXIT_FAILURE 4918c4a8e55Smrg} 492b042e37fSmrg 4938c4a8e55Smrg# func_fatal_help arg... 4948c4a8e55Smrg# Echo program name prefixed message to standard error, followed by 4958c4a8e55Smrg# a help hint, and exit. 4968c4a8e55Smrgfunc_fatal_help () 4978c4a8e55Smrg{ 4988c4a8e55Smrg func_error ${1+"$@"} 4998c4a8e55Smrg func_fatal_error "$help" 5008c4a8e55Smrg} 5018c4a8e55Smrghelp="Try \`$progname --help' for more information." ## default 502b042e37fSmrg 503b042e37fSmrg 5048c4a8e55Smrg# func_grep expression filename 5058c4a8e55Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 5068c4a8e55Smrgfunc_grep () 5078c4a8e55Smrg{ 5088c4a8e55Smrg $GREP "$1" "$2" >/dev/null 2>&1 5098c4a8e55Smrg} 5108c4a8e55Smrg 5118c4a8e55Smrg 5128c4a8e55Smrg# func_mkdir_p directory-path 5138c4a8e55Smrg# Make sure the entire path to DIRECTORY-PATH is available. 5148c4a8e55Smrgfunc_mkdir_p () 5158c4a8e55Smrg{ 5168c4a8e55Smrg my_directory_path="$1" 5178c4a8e55Smrg my_dir_list= 5188c4a8e55Smrg 5198c4a8e55Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 5208c4a8e55Smrg 5218c4a8e55Smrg # Protect directory names starting with `-' 5228c4a8e55Smrg case $my_directory_path in 5238c4a8e55Smrg -*) my_directory_path="./$my_directory_path" ;; 5248c4a8e55Smrg esac 5258c4a8e55Smrg 5268c4a8e55Smrg # While some portion of DIR does not yet exist... 5278c4a8e55Smrg while test ! -d "$my_directory_path"; do 5288c4a8e55Smrg # ...make a list in topmost first order. Use a colon delimited 5298c4a8e55Smrg # list incase some portion of path contains whitespace. 5308c4a8e55Smrg my_dir_list="$my_directory_path:$my_dir_list" 5318c4a8e55Smrg 5328c4a8e55Smrg # If the last portion added has no slash in it, the list is done 5338c4a8e55Smrg case $my_directory_path in */*) ;; *) break ;; esac 5348c4a8e55Smrg 5358c4a8e55Smrg # ...otherwise throw away the child directory and loop 536706b6b52Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 5378c4a8e55Smrg done 538706b6b52Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 5398c4a8e55Smrg 5408c4a8e55Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 5418c4a8e55Smrg for my_dir in $my_dir_list; do 5428c4a8e55Smrg IFS="$save_mkdir_p_IFS" 5438c4a8e55Smrg # mkdir can fail with a `File exist' error if two processes 5448c4a8e55Smrg # try to create one of the directories concurrently. Don't 5458c4a8e55Smrg # stop in that case! 5468c4a8e55Smrg $MKDIR "$my_dir" 2>/dev/null || : 5478c4a8e55Smrg done 5488c4a8e55Smrg IFS="$save_mkdir_p_IFS" 5498c4a8e55Smrg 5508c4a8e55Smrg # Bail out if we (or some other process) failed to create a directory. 5518c4a8e55Smrg test -d "$my_directory_path" || \ 5528c4a8e55Smrg func_fatal_error "Failed to create \`$1'" 5538c4a8e55Smrg fi 5548c4a8e55Smrg} 555b042e37fSmrg 556b042e37fSmrg 557b042e37fSmrg# func_mktempdir [string] 558b042e37fSmrg# Make a temporary directory that won't clash with other running 559b042e37fSmrg# libtool processes, and avoids race conditions if possible. If 560b042e37fSmrg# given, STRING is the basename for that directory. 561b042e37fSmrgfunc_mktempdir () 562b042e37fSmrg{ 563b042e37fSmrg my_template="${TMPDIR-/tmp}/${1-$progname}" 564b042e37fSmrg 5658c4a8e55Smrg if test "$opt_dry_run" = ":"; then 566b042e37fSmrg # Return a directory name, but don't create it in dry-run mode 567b042e37fSmrg my_tmpdir="${my_template}-$$" 568b042e37fSmrg else 569b042e37fSmrg 570b042e37fSmrg # If mktemp works, use that first and foremost 571b042e37fSmrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 572b042e37fSmrg 573b042e37fSmrg if test ! -d "$my_tmpdir"; then 5748c4a8e55Smrg # Failing that, at least try and use $RANDOM to avoid a race 5758c4a8e55Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 576b042e37fSmrg 5778c4a8e55Smrg save_mktempdir_umask=`umask` 5788c4a8e55Smrg umask 0077 5798c4a8e55Smrg $MKDIR "$my_tmpdir" 5808c4a8e55Smrg umask $save_mktempdir_umask 581b042e37fSmrg fi 582b042e37fSmrg 583b042e37fSmrg # If we're not in dry-run mode, bomb out on failure 5848c4a8e55Smrg test -d "$my_tmpdir" || \ 5858c4a8e55Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 586b042e37fSmrg fi 587b042e37fSmrg 588706b6b52Smrg $ECHO "$my_tmpdir" 589b042e37fSmrg} 590b042e37fSmrg 591b042e37fSmrg 5928c4a8e55Smrg# func_quote_for_eval arg 5938c4a8e55Smrg# Aesthetically quote ARG to be evaled later. 5948c4a8e55Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 5958c4a8e55Smrg# is double-quoted, suitable for a subsequent eval, whereas 5968c4a8e55Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 5978c4a8e55Smrg# which are still active within double quotes backslashified. 5988c4a8e55Smrgfunc_quote_for_eval () 599b042e37fSmrg{ 6008c4a8e55Smrg case $1 in 6018c4a8e55Smrg *[\\\`\"\$]*) 602706b6b52Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 6038c4a8e55Smrg *) 6048c4a8e55Smrg func_quote_for_eval_unquoted_result="$1" ;; 6058c4a8e55Smrg esac 6068c4a8e55Smrg 6078c4a8e55Smrg case $func_quote_for_eval_unquoted_result in 6088c4a8e55Smrg # Double-quote args containing shell metacharacters to delay 6098c4a8e55Smrg # word splitting, command substitution and and variable 6108c4a8e55Smrg # expansion for a subsequent eval. 6118c4a8e55Smrg # Many Bourne shells cannot handle close brackets correctly 6128c4a8e55Smrg # in scan sets, so we specify it separately. 6138c4a8e55Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 6148c4a8e55Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 6158c4a8e55Smrg ;; 6168c4a8e55Smrg *) 6178c4a8e55Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 618b042e37fSmrg esac 619b042e37fSmrg} 620b042e37fSmrg 621b042e37fSmrg 6228c4a8e55Smrg# func_quote_for_expand arg 6238c4a8e55Smrg# Aesthetically quote ARG to be evaled later; same as above, 6248c4a8e55Smrg# but do not quote variable references. 6258c4a8e55Smrgfunc_quote_for_expand () 626b042e37fSmrg{ 6278c4a8e55Smrg case $1 in 6288c4a8e55Smrg *[\\\`\"]*) 629706b6b52Smrg my_arg=`$ECHO "$1" | $SED \ 6308c4a8e55Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 631b042e37fSmrg *) 6328c4a8e55Smrg my_arg="$1" ;; 6338c4a8e55Smrg esac 634b042e37fSmrg 6358c4a8e55Smrg case $my_arg in 6368c4a8e55Smrg # Double-quote args containing shell metacharacters to delay 6378c4a8e55Smrg # word splitting and command substitution for a subsequent eval. 6388c4a8e55Smrg # Many Bourne shells cannot handle close brackets correctly 6398c4a8e55Smrg # in scan sets, so we specify it separately. 6408c4a8e55Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 6418c4a8e55Smrg my_arg="\"$my_arg\"" 6428c4a8e55Smrg ;; 6438c4a8e55Smrg esac 6448c4a8e55Smrg 6458c4a8e55Smrg func_quote_for_expand_result="$my_arg" 646b042e37fSmrg} 647b042e37fSmrg 648b042e37fSmrg 6498c4a8e55Smrg# func_show_eval cmd [fail_exp] 6508c4a8e55Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 6518c4a8e55Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 6528c4a8e55Smrg# is given, then evaluate it. 6538c4a8e55Smrgfunc_show_eval () 654b042e37fSmrg{ 6558c4a8e55Smrg my_cmd="$1" 6568c4a8e55Smrg my_fail_exp="${2-:}" 657b042e37fSmrg 6588c4a8e55Smrg ${opt_silent-false} || { 6598c4a8e55Smrg func_quote_for_expand "$my_cmd" 6608c4a8e55Smrg eval "func_echo $func_quote_for_expand_result" 6618c4a8e55Smrg } 6628c4a8e55Smrg 6638c4a8e55Smrg if ${opt_dry_run-false}; then :; else 6648c4a8e55Smrg eval "$my_cmd" 6658c4a8e55Smrg my_status=$? 6668c4a8e55Smrg if test "$my_status" -eq 0; then :; else 6678c4a8e55Smrg eval "(exit $my_status); $my_fail_exp" 6688c4a8e55Smrg fi 669b042e37fSmrg fi 670b042e37fSmrg} 671b042e37fSmrg 6728c4a8e55Smrg 6738c4a8e55Smrg# func_show_eval_locale cmd [fail_exp] 6748c4a8e55Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 6758c4a8e55Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 6768c4a8e55Smrg# is given, then evaluate it. Use the saved locale for evaluation. 6778c4a8e55Smrgfunc_show_eval_locale () 678b042e37fSmrg{ 6798c4a8e55Smrg my_cmd="$1" 6808c4a8e55Smrg my_fail_exp="${2-:}" 681b042e37fSmrg 6828c4a8e55Smrg ${opt_silent-false} || { 6838c4a8e55Smrg func_quote_for_expand "$my_cmd" 6848c4a8e55Smrg eval "func_echo $func_quote_for_expand_result" 6858c4a8e55Smrg } 6868c4a8e55Smrg 6878c4a8e55Smrg if ${opt_dry_run-false}; then :; else 6888c4a8e55Smrg eval "$lt_user_locale 6898c4a8e55Smrg $my_cmd" 6908c4a8e55Smrg my_status=$? 6918c4a8e55Smrg eval "$lt_safe_locale" 6928c4a8e55Smrg if test "$my_status" -eq 0; then :; else 6938c4a8e55Smrg eval "(exit $my_status); $my_fail_exp" 694b042e37fSmrg fi 6958c4a8e55Smrg fi 696b042e37fSmrg} 697b042e37fSmrg 698bd23fbfaSmrg# func_tr_sh 699bd23fbfaSmrg# Turn $1 into a string suitable for a shell variable name. 700bd23fbfaSmrg# Result is stored in $func_tr_sh_result. All characters 701bd23fbfaSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 702bd23fbfaSmrg# if $1 begins with a digit, a '_' is prepended as well. 703bd23fbfaSmrgfunc_tr_sh () 704bd23fbfaSmrg{ 705bd23fbfaSmrg case $1 in 706bd23fbfaSmrg [0-9]* | *[!a-zA-Z0-9_]*) 707bd23fbfaSmrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 708bd23fbfaSmrg ;; 709bd23fbfaSmrg * ) 710bd23fbfaSmrg func_tr_sh_result=$1 711bd23fbfaSmrg ;; 712bd23fbfaSmrg esac 713bd23fbfaSmrg} 714bd23fbfaSmrg 715b042e37fSmrg 7168c4a8e55Smrg# func_version 7178c4a8e55Smrg# Echo version message to standard output and exit. 7188c4a8e55Smrgfunc_version () 7198c4a8e55Smrg{ 720bd23fbfaSmrg $opt_debug 721bd23fbfaSmrg 722706b6b52Smrg $SED -n '/(C)/!b go 723706b6b52Smrg :more 724706b6b52Smrg /\./!{ 725706b6b52Smrg N 726706b6b52Smrg s/\n# / / 727706b6b52Smrg b more 728706b6b52Smrg } 729706b6b52Smrg :go 730706b6b52Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 7318c4a8e55Smrg s/^# // 7328c4a8e55Smrg s/^# *$// 7338c4a8e55Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 7348c4a8e55Smrg p 7358c4a8e55Smrg }' < "$progpath" 7368c4a8e55Smrg exit $? 7378c4a8e55Smrg} 7388c4a8e55Smrg 7398c4a8e55Smrg# func_usage 7408c4a8e55Smrg# Echo short help message to standard output and exit. 7418c4a8e55Smrgfunc_usage () 7428c4a8e55Smrg{ 743bd23fbfaSmrg $opt_debug 744bd23fbfaSmrg 745706b6b52Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 7468c4a8e55Smrg s/^# // 7478c4a8e55Smrg s/^# *$// 7488c4a8e55Smrg s/\$progname/'$progname'/ 7498c4a8e55Smrg p 7508c4a8e55Smrg }' < "$progpath" 751706b6b52Smrg echo 7528c4a8e55Smrg $ECHO "run \`$progname --help | more' for full usage" 7538c4a8e55Smrg exit $? 7548c4a8e55Smrg} 7558c4a8e55Smrg 756706b6b52Smrg# func_help [NOEXIT] 757706b6b52Smrg# Echo long help message to standard output and exit, 758706b6b52Smrg# unless 'noexit' is passed as argument. 7598c4a8e55Smrgfunc_help () 7608c4a8e55Smrg{ 761bd23fbfaSmrg $opt_debug 762bd23fbfaSmrg 7638c4a8e55Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 764bd23fbfaSmrg :print 7658c4a8e55Smrg s/^# // 7668c4a8e55Smrg s/^# *$// 7678c4a8e55Smrg s*\$progname*'$progname'* 7688c4a8e55Smrg s*\$host*'"$host"'* 7698c4a8e55Smrg s*\$SHELL*'"$SHELL"'* 7708c4a8e55Smrg s*\$LTCC*'"$LTCC"'* 7718c4a8e55Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 7728c4a8e55Smrg s*\$LD*'"$LD"'* 7738c4a8e55Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 7748c4a8e55Smrg s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ 7758c4a8e55Smrg s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ 7768c4a8e55Smrg p 777bd23fbfaSmrg d 778bd23fbfaSmrg } 779bd23fbfaSmrg /^# .* home page:/b print 780bd23fbfaSmrg /^# General help using/b print 781bd23fbfaSmrg ' < "$progpath" 782706b6b52Smrg ret=$? 783706b6b52Smrg if test -z "$1"; then 784706b6b52Smrg exit $ret 785706b6b52Smrg fi 7868c4a8e55Smrg} 7878c4a8e55Smrg 7888c4a8e55Smrg# func_missing_arg argname 7898c4a8e55Smrg# Echo program name prefixed message to standard error and set global 7908c4a8e55Smrg# exit_cmd. 7918c4a8e55Smrgfunc_missing_arg () 7928c4a8e55Smrg{ 793bd23fbfaSmrg $opt_debug 794bd23fbfaSmrg 795706b6b52Smrg func_error "missing argument for $1." 7968c4a8e55Smrg exit_cmd=exit 7978c4a8e55Smrg} 7988c4a8e55Smrg 7998c4a8e55Smrg 800bd23fbfaSmrg# func_split_short_opt shortopt 801bd23fbfaSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 802bd23fbfaSmrg# variables after splitting SHORTOPT after the 2nd character. 803bd23fbfaSmrgfunc_split_short_opt () 804bd23fbfaSmrg{ 805bd23fbfaSmrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 806bd23fbfaSmrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 807bd23fbfaSmrg 808bd23fbfaSmrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 809bd23fbfaSmrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 810bd23fbfaSmrg} # func_split_short_opt may be replaced by extended shell implementation 811bd23fbfaSmrg 812bd23fbfaSmrg 813bd23fbfaSmrg# func_split_long_opt longopt 814bd23fbfaSmrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 815bd23fbfaSmrg# variables after splitting LONGOPT at the `=' sign. 816bd23fbfaSmrgfunc_split_long_opt () 817bd23fbfaSmrg{ 818bd23fbfaSmrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 819bd23fbfaSmrg my_sed_long_arg='1s/^--[^=]*=//' 820bd23fbfaSmrg 821bd23fbfaSmrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 822bd23fbfaSmrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 823bd23fbfaSmrg} # func_split_long_opt may be replaced by extended shell implementation 824bd23fbfaSmrg 825bd23fbfaSmrgexit_cmd=: 8268c4a8e55Smrg 8278c4a8e55Smrg 8288c4a8e55Smrg 8298c4a8e55Smrg 830b042e37fSmrg 8318c4a8e55Smrgmagic="%%%MAGIC variable%%%" 8328c4a8e55Smrgmagic_exe="%%%MAGIC EXE variable%%%" 833b042e37fSmrg 8348c4a8e55Smrg# Global variables. 8358c4a8e55Smrgnonopt= 8368c4a8e55Smrgpreserve_args= 8378c4a8e55Smrglo2o="s/\\.lo\$/.${objext}/" 8388c4a8e55Smrgo2lo="s/\\.${objext}\$/.lo/" 8398c4a8e55Smrgextracted_archives= 8408c4a8e55Smrgextracted_serial=0 841b042e37fSmrg 8428c4a8e55Smrg# If this variable is set in any of the actions, the command in it 8438c4a8e55Smrg# will be execed at the end. This prevents here-documents from being 8448c4a8e55Smrg# left over by shells. 8458c4a8e55Smrgexec_cmd= 8468c4a8e55Smrg 847bd23fbfaSmrg# func_append var value 848bd23fbfaSmrg# Append VALUE to the end of shell variable VAR. 849bd23fbfaSmrgfunc_append () 850bd23fbfaSmrg{ 851bd23fbfaSmrg eval "${1}=\$${1}\${2}" 852bd23fbfaSmrg} # func_append may be replaced by extended shell implementation 853bd23fbfaSmrg 854bd23fbfaSmrg# func_append_quoted var value 855bd23fbfaSmrg# Quote VALUE and append to the end of shell variable VAR, separated 856bd23fbfaSmrg# by a space. 857bd23fbfaSmrgfunc_append_quoted () 858bd23fbfaSmrg{ 859bd23fbfaSmrg func_quote_for_eval "${2}" 860bd23fbfaSmrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 861bd23fbfaSmrg} # func_append_quoted may be replaced by extended shell implementation 862bd23fbfaSmrg 863bd23fbfaSmrg 864bd23fbfaSmrg# func_arith arithmetic-term... 865bd23fbfaSmrgfunc_arith () 866bd23fbfaSmrg{ 867bd23fbfaSmrg func_arith_result=`expr "${@}"` 868bd23fbfaSmrg} # func_arith may be replaced by extended shell implementation 869bd23fbfaSmrg 870bd23fbfaSmrg 871bd23fbfaSmrg# func_len string 872bd23fbfaSmrg# STRING may not start with a hyphen. 873bd23fbfaSmrgfunc_len () 874bd23fbfaSmrg{ 875bd23fbfaSmrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 876bd23fbfaSmrg} # func_len may be replaced by extended shell implementation 877bd23fbfaSmrg 878bd23fbfaSmrg 879bd23fbfaSmrg# func_lo2o object 880bd23fbfaSmrgfunc_lo2o () 881bd23fbfaSmrg{ 882bd23fbfaSmrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 883bd23fbfaSmrg} # func_lo2o may be replaced by extended shell implementation 884bd23fbfaSmrg 885bd23fbfaSmrg 886bd23fbfaSmrg# func_xform libobj-or-source 887bd23fbfaSmrgfunc_xform () 888bd23fbfaSmrg{ 889bd23fbfaSmrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 890bd23fbfaSmrg} # func_xform may be replaced by extended shell implementation 891bd23fbfaSmrg 892bd23fbfaSmrg 8938c4a8e55Smrg# func_fatal_configuration arg... 8948c4a8e55Smrg# Echo program name prefixed message to standard error, followed by 8958c4a8e55Smrg# a configuration failure hint, and exit. 8968c4a8e55Smrgfunc_fatal_configuration () 8978c4a8e55Smrg{ 8988c4a8e55Smrg func_error ${1+"$@"} 8998c4a8e55Smrg func_error "See the $PACKAGE documentation for more information." 9008c4a8e55Smrg func_fatal_error "Fatal configuration error." 9018c4a8e55Smrg} 902b042e37fSmrg 903b042e37fSmrg 9048c4a8e55Smrg# func_config 9058c4a8e55Smrg# Display the configuration for all the tags in this script. 9068c4a8e55Smrgfunc_config () 9078c4a8e55Smrg{ 9088c4a8e55Smrg re_begincf='^# ### BEGIN LIBTOOL' 9098c4a8e55Smrg re_endcf='^# ### END LIBTOOL' 9108c4a8e55Smrg 9118c4a8e55Smrg # Default configuration. 9128c4a8e55Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 9138c4a8e55Smrg 914b042e37fSmrg # Now print the configurations for the tags. 915b042e37fSmrg for tagname in $taglist; do 9168c4a8e55Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 917b042e37fSmrg done 918b042e37fSmrg 9198c4a8e55Smrg exit $? 9208c4a8e55Smrg} 921b042e37fSmrg 9228c4a8e55Smrg# func_features 9238c4a8e55Smrg# Display the features supported by this script. 9248c4a8e55Smrgfunc_features () 9258c4a8e55Smrg{ 926706b6b52Smrg echo "host: $host" 927b042e37fSmrg if test "$build_libtool_libs" = yes; then 928706b6b52Smrg echo "enable shared libraries" 929b042e37fSmrg else 930706b6b52Smrg echo "disable shared libraries" 931b042e37fSmrg fi 932b042e37fSmrg if test "$build_old_libs" = yes; then 933706b6b52Smrg echo "enable static libraries" 934b042e37fSmrg else 935706b6b52Smrg echo "disable static libraries" 936b042e37fSmrg fi 9378c4a8e55Smrg 938b042e37fSmrg exit $? 9398c4a8e55Smrg} 940b042e37fSmrg 9418c4a8e55Smrg# func_enable_tag tagname 9428c4a8e55Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 9438c4a8e55Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 9448c4a8e55Smrg# variable here. 9458c4a8e55Smrgfunc_enable_tag () 9468c4a8e55Smrg{ 9478c4a8e55Smrg # Global variable: 9488c4a8e55Smrg tagname="$1" 949b042e37fSmrg 9508c4a8e55Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 9518c4a8e55Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 9528c4a8e55Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 953b042e37fSmrg 9548c4a8e55Smrg # Validate tagname. 9558c4a8e55Smrg case $tagname in 9568c4a8e55Smrg *[!-_A-Za-z0-9,/]*) 9578c4a8e55Smrg func_fatal_error "invalid tag name: $tagname" 9588c4a8e55Smrg ;; 9598c4a8e55Smrg esac 960b042e37fSmrg 9618c4a8e55Smrg # Don't test for the "default" C tag, as we know it's 9628c4a8e55Smrg # there but not specially marked. 9638c4a8e55Smrg case $tagname in 9648c4a8e55Smrg CC) ;; 9658c4a8e55Smrg *) 9668c4a8e55Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 9678c4a8e55Smrg taglist="$taglist $tagname" 9688c4a8e55Smrg 9698c4a8e55Smrg # Evaluate the configuration. Be careful to quote the path 9708c4a8e55Smrg # and the sed script, to avoid splitting on whitespace, but 9718c4a8e55Smrg # also don't use non-portable quotes within backquotes within 9728c4a8e55Smrg # quotes we have to do it in 2 steps: 9738c4a8e55Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 9748c4a8e55Smrg eval "$extractedcf" 9758c4a8e55Smrg else 9768c4a8e55Smrg func_error "ignoring unknown tag $tagname" 9778c4a8e55Smrg fi 9788c4a8e55Smrg ;; 9798c4a8e55Smrg esac 9808c4a8e55Smrg} 981b042e37fSmrg 982bd23fbfaSmrg# func_check_version_match 983bd23fbfaSmrg# Ensure that we are using m4 macros, and libtool script from the same 984bd23fbfaSmrg# release of libtool. 985bd23fbfaSmrgfunc_check_version_match () 9868c4a8e55Smrg{ 987bd23fbfaSmrg if test "$package_revision" != "$macro_revision"; then 988bd23fbfaSmrg if test "$VERSION" != "$macro_version"; then 989bd23fbfaSmrg if test -z "$macro_version"; then 990bd23fbfaSmrg cat >&2 <<_LT_EOF 991bd23fbfaSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 992bd23fbfaSmrg$progname: definition of this LT_INIT comes from an older release. 993bd23fbfaSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 994bd23fbfaSmrg$progname: and run autoconf again. 995bd23fbfaSmrg_LT_EOF 996bd23fbfaSmrg else 997bd23fbfaSmrg cat >&2 <<_LT_EOF 998bd23fbfaSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 999bd23fbfaSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 1000bd23fbfaSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 1001bd23fbfaSmrg$progname: and run autoconf again. 1002bd23fbfaSmrg_LT_EOF 1003bd23fbfaSmrg fi 1004bd23fbfaSmrg else 1005bd23fbfaSmrg cat >&2 <<_LT_EOF 1006bd23fbfaSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 1007bd23fbfaSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 1008bd23fbfaSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 1009bd23fbfaSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 1010bd23fbfaSmrg_LT_EOF 1011bd23fbfaSmrg fi 10128c4a8e55Smrg 1013bd23fbfaSmrg exit $EXIT_MISMATCH 1014bd23fbfaSmrg fi 1015bd23fbfaSmrg} 1016bd23fbfaSmrg 1017bd23fbfaSmrg 1018bd23fbfaSmrg# Shorthand for --mode=foo, only valid as the first argument 1019bd23fbfaSmrgcase $1 in 1020bd23fbfaSmrgclean|clea|cle|cl) 1021bd23fbfaSmrg shift; set dummy --mode clean ${1+"$@"}; shift 1022bd23fbfaSmrg ;; 1023bd23fbfaSmrgcompile|compil|compi|comp|com|co|c) 1024bd23fbfaSmrg shift; set dummy --mode compile ${1+"$@"}; shift 1025bd23fbfaSmrg ;; 1026bd23fbfaSmrgexecute|execut|execu|exec|exe|ex|e) 1027bd23fbfaSmrg shift; set dummy --mode execute ${1+"$@"}; shift 1028bd23fbfaSmrg ;; 1029bd23fbfaSmrgfinish|finis|fini|fin|fi|f) 1030bd23fbfaSmrg shift; set dummy --mode finish ${1+"$@"}; shift 1031bd23fbfaSmrg ;; 1032bd23fbfaSmrginstall|instal|insta|inst|ins|in|i) 1033bd23fbfaSmrg shift; set dummy --mode install ${1+"$@"}; shift 1034bd23fbfaSmrg ;; 1035bd23fbfaSmrglink|lin|li|l) 1036bd23fbfaSmrg shift; set dummy --mode link ${1+"$@"}; shift 1037bd23fbfaSmrg ;; 1038bd23fbfaSmrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 1039bd23fbfaSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 1040bd23fbfaSmrg ;; 1041bd23fbfaSmrgesac 1042b042e37fSmrg 1043bd23fbfaSmrg 1044bd23fbfaSmrg 1045bd23fbfaSmrg# Option defaults: 1046bd23fbfaSmrgopt_debug=: 1047bd23fbfaSmrgopt_dry_run=false 1048bd23fbfaSmrgopt_config=false 1049bd23fbfaSmrgopt_preserve_dup_deps=false 1050bd23fbfaSmrgopt_features=false 1051bd23fbfaSmrgopt_finish=false 1052bd23fbfaSmrgopt_help=false 1053bd23fbfaSmrgopt_help_all=false 1054bd23fbfaSmrgopt_silent=: 1055bd23fbfaSmrgopt_verbose=: 1056bd23fbfaSmrgopt_silent=false 1057bd23fbfaSmrgopt_verbose=false 1058bd23fbfaSmrg 1059bd23fbfaSmrg 1060bd23fbfaSmrg# Parse options once, thoroughly. This comes as soon as possible in the 1061bd23fbfaSmrg# script to make things like `--version' happen as quickly as we can. 1062bd23fbfaSmrg{ 1063bd23fbfaSmrg # this just eases exit handling 1064bd23fbfaSmrg while test $# -gt 0; do 10658c4a8e55Smrg opt="$1" 10668c4a8e55Smrg shift 10678c4a8e55Smrg case $opt in 1068bd23fbfaSmrg --debug|-x) opt_debug='set -x' 10698c4a8e55Smrg func_echo "enabling shell trace mode" 10708c4a8e55Smrg $opt_debug 10718c4a8e55Smrg ;; 1072bd23fbfaSmrg --dry-run|--dryrun|-n) 1073bd23fbfaSmrg opt_dry_run=: 10748c4a8e55Smrg ;; 1075bd23fbfaSmrg --config) 1076bd23fbfaSmrg opt_config=: 1077bd23fbfaSmrgfunc_config 1078bd23fbfaSmrg ;; 1079bd23fbfaSmrg --dlopen|-dlopen) 1080bd23fbfaSmrg optarg="$1" 1081bd23fbfaSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 1082bd23fbfaSmrg}$optarg" 10838c4a8e55Smrg shift 10848c4a8e55Smrg ;; 10858c4a8e55Smrg --preserve-dup-deps) 1086bd23fbfaSmrg opt_preserve_dup_deps=: 1087706b6b52Smrg ;; 1088bd23fbfaSmrg --features) 1089bd23fbfaSmrg opt_features=: 1090bd23fbfaSmrgfunc_features 10918c4a8e55Smrg ;; 1092bd23fbfaSmrg --finish) 1093bd23fbfaSmrg opt_finish=: 1094bd23fbfaSmrgset dummy --mode finish ${1+"$@"}; shift 1095bd23fbfaSmrg ;; 1096bd23fbfaSmrg --help) 1097bd23fbfaSmrg opt_help=: 1098bd23fbfaSmrg ;; 1099bd23fbfaSmrg --help-all) 1100bd23fbfaSmrg opt_help_all=: 1101bd23fbfaSmrgopt_help=': help-all' 1102bd23fbfaSmrg ;; 1103bd23fbfaSmrg --mode) 1104bd23fbfaSmrg test $# = 0 && func_missing_arg $opt && break 1105bd23fbfaSmrg optarg="$1" 1106bd23fbfaSmrg opt_mode="$optarg" 1107bd23fbfaSmrgcase $optarg in 1108bd23fbfaSmrg # Valid mode arguments: 1109bd23fbfaSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 1110bd23fbfaSmrg 1111bd23fbfaSmrg # Catch anything else as an error 1112bd23fbfaSmrg *) func_error "invalid argument for $opt" 1113bd23fbfaSmrg exit_cmd=exit 1114bd23fbfaSmrg break 1115bd23fbfaSmrg ;; 1116bd23fbfaSmrgesac 1117bd23fbfaSmrg shift 1118bd23fbfaSmrg ;; 1119bd23fbfaSmrg --no-silent|--no-quiet) 11208c4a8e55Smrg opt_silent=false 1121bd23fbfaSmrgfunc_append preserve_args " $opt" 1122706b6b52Smrg ;; 1123bd23fbfaSmrg --no-verbose) 1124706b6b52Smrg opt_verbose=false 1125bd23fbfaSmrgfunc_append preserve_args " $opt" 11268c4a8e55Smrg ;; 1127bd23fbfaSmrg --silent|--quiet) 1128bd23fbfaSmrg opt_silent=: 1129bd23fbfaSmrgfunc_append preserve_args " $opt" 1130bd23fbfaSmrg opt_verbose=false 1131bd23fbfaSmrg ;; 1132bd23fbfaSmrg --verbose|-v) 1133bd23fbfaSmrg opt_verbose=: 1134bd23fbfaSmrgfunc_append preserve_args " $opt" 1135bd23fbfaSmrgopt_silent=false 1136bd23fbfaSmrg ;; 1137bd23fbfaSmrg --tag) 1138bd23fbfaSmrg test $# = 0 && func_missing_arg $opt && break 1139bd23fbfaSmrg optarg="$1" 1140bd23fbfaSmrg opt_tag="$optarg" 1141bd23fbfaSmrgfunc_append preserve_args " $opt $optarg" 1142bd23fbfaSmrgfunc_enable_tag "$optarg" 11438c4a8e55Smrg shift 11448c4a8e55Smrg ;; 11458c4a8e55Smrg 1146bd23fbfaSmrg -\?|-h) func_usage ;; 1147bd23fbfaSmrg --help) func_help ;; 1148bd23fbfaSmrg --version) func_version ;; 1149bd23fbfaSmrg 11508c4a8e55Smrg # Separate optargs to long options: 1151bd23fbfaSmrg --*=*) 1152bd23fbfaSmrg func_split_long_opt "$opt" 1153bd23fbfaSmrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 11548c4a8e55Smrg shift 11558c4a8e55Smrg ;; 11568c4a8e55Smrg 1157bd23fbfaSmrg # Separate non-argument short options: 1158bd23fbfaSmrg -\?*|-h*|-n*|-v*) 1159bd23fbfaSmrg func_split_short_opt "$opt" 1160bd23fbfaSmrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 1161bd23fbfaSmrg shift 11628c4a8e55Smrg ;; 1163bd23fbfaSmrg 1164bd23fbfaSmrg --) break ;; 1165bd23fbfaSmrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 1166bd23fbfaSmrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 11678c4a8e55Smrg esac 11688c4a8e55Smrg done 11698c4a8e55Smrg 1170bd23fbfaSmrg # Validate options: 1171bd23fbfaSmrg 1172bd23fbfaSmrg # save first non-option argument 1173bd23fbfaSmrg if test "$#" -gt 0; then 1174bd23fbfaSmrg nonopt="$opt" 1175bd23fbfaSmrg shift 1176bd23fbfaSmrg fi 1177bd23fbfaSmrg 1178bd23fbfaSmrg # preserve --debug 1179bd23fbfaSmrg test "$opt_debug" = : || func_append preserve_args " --debug" 11808c4a8e55Smrg 11818c4a8e55Smrg case $host in 11828c4a8e55Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 11838c4a8e55Smrg # don't eliminate duplications in $postdeps and $predeps 11848c4a8e55Smrg opt_duplicate_compiler_generated_deps=: 1185b042e37fSmrg ;; 1186b042e37fSmrg *) 1187bd23fbfaSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 11888c4a8e55Smrg ;; 11898c4a8e55Smrg esac 1190b042e37fSmrg 1191bd23fbfaSmrg $opt_help || { 1192bd23fbfaSmrg # Sanity checks first: 1193bd23fbfaSmrg func_check_version_match 11948c4a8e55Smrg 1195bd23fbfaSmrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 1196bd23fbfaSmrg func_fatal_configuration "not configured to build any kind of library" 11978c4a8e55Smrg fi 11988c4a8e55Smrg 1199bd23fbfaSmrg # Darwin sucks 1200bd23fbfaSmrg eval std_shrext=\"$shrext_cmds\" 12018c4a8e55Smrg 1202bd23fbfaSmrg # Only execute mode is allowed to have -dlopen flags. 1203bd23fbfaSmrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 1204bd23fbfaSmrg func_error "unrecognized option \`-dlopen'" 1205bd23fbfaSmrg $ECHO "$help" 1>&2 1206bd23fbfaSmrg exit $EXIT_FAILURE 1207bd23fbfaSmrg fi 12088c4a8e55Smrg 1209bd23fbfaSmrg # Change the help message to a mode-specific one. 1210bd23fbfaSmrg generic_help="$help" 1211bd23fbfaSmrg help="Try \`$progname --help --mode=$opt_mode' for more information." 1212bd23fbfaSmrg } 12138c4a8e55Smrg 12148c4a8e55Smrg 1215bd23fbfaSmrg # Bail if the options were screwed 1216bd23fbfaSmrg $exit_cmd $EXIT_FAILURE 1217bd23fbfaSmrg} 12188c4a8e55Smrg 12198c4a8e55Smrg 1220b042e37fSmrg 1221b042e37fSmrg 1222bd23fbfaSmrg## ----------- ## 1223bd23fbfaSmrg## Main. ## 1224bd23fbfaSmrg## ----------- ## 1225b042e37fSmrg 12268c4a8e55Smrg# func_lalib_p file 12278c4a8e55Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 12288c4a8e55Smrg# This function is only a basic sanity check; it will hardly flush out 12298c4a8e55Smrg# determined imposters. 12308c4a8e55Smrgfunc_lalib_p () 12318c4a8e55Smrg{ 12328c4a8e55Smrg test -f "$1" && 12338c4a8e55Smrg $SED -e 4q "$1" 2>/dev/null \ 12348c4a8e55Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 12358c4a8e55Smrg} 1236b042e37fSmrg 12378c4a8e55Smrg# func_lalib_unsafe_p file 12388c4a8e55Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 12398c4a8e55Smrg# This function implements the same check as func_lalib_p without 12408c4a8e55Smrg# resorting to external programs. To this end, it redirects stdin and 12418c4a8e55Smrg# closes it afterwards, without saving the original file descriptor. 12428c4a8e55Smrg# As a safety measure, use it only where a negative result would be 12438c4a8e55Smrg# fatal anyway. Works if `file' does not exist. 12448c4a8e55Smrgfunc_lalib_unsafe_p () 12458c4a8e55Smrg{ 12468c4a8e55Smrg lalib_p=no 12478c4a8e55Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 12488c4a8e55Smrg for lalib_p_l in 1 2 3 4 12498c4a8e55Smrg do 12508c4a8e55Smrg read lalib_p_line 12518c4a8e55Smrg case "$lalib_p_line" in 12528c4a8e55Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 12538c4a8e55Smrg esac 12548c4a8e55Smrg done 12558c4a8e55Smrg exec 0<&5 5<&- 12568c4a8e55Smrg fi 12578c4a8e55Smrg test "$lalib_p" = yes 12588c4a8e55Smrg} 1259b042e37fSmrg 12608c4a8e55Smrg# func_ltwrapper_script_p file 12618c4a8e55Smrg# True iff FILE is a libtool wrapper script 12628c4a8e55Smrg# This function is only a basic sanity check; it will hardly flush out 12638c4a8e55Smrg# determined imposters. 12648c4a8e55Smrgfunc_ltwrapper_script_p () 12658c4a8e55Smrg{ 12668c4a8e55Smrg func_lalib_p "$1" 12678c4a8e55Smrg} 1268b042e37fSmrg 12698c4a8e55Smrg# func_ltwrapper_executable_p file 12708c4a8e55Smrg# True iff FILE is a libtool wrapper executable 12718c4a8e55Smrg# This function is only a basic sanity check; it will hardly flush out 12728c4a8e55Smrg# determined imposters. 12738c4a8e55Smrgfunc_ltwrapper_executable_p () 12748c4a8e55Smrg{ 12758c4a8e55Smrg func_ltwrapper_exec_suffix= 12768c4a8e55Smrg case $1 in 12778c4a8e55Smrg *.exe) ;; 12788c4a8e55Smrg *) func_ltwrapper_exec_suffix=.exe ;; 12798c4a8e55Smrg esac 12808c4a8e55Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 12818c4a8e55Smrg} 1282b042e37fSmrg 12838c4a8e55Smrg# func_ltwrapper_scriptname file 12848c4a8e55Smrg# Assumes file is an ltwrapper_executable 12858c4a8e55Smrg# uses $file to determine the appropriate filename for a 12868c4a8e55Smrg# temporary ltwrapper_script. 12878c4a8e55Smrgfunc_ltwrapper_scriptname () 12888c4a8e55Smrg{ 1289bd23fbfaSmrg func_dirname_and_basename "$1" "" "." 1290bd23fbfaSmrg func_stripname '' '.exe' "$func_basename_result" 1291bd23fbfaSmrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 12928c4a8e55Smrg} 1293b042e37fSmrg 12948c4a8e55Smrg# func_ltwrapper_p file 12958c4a8e55Smrg# True iff FILE is a libtool wrapper script or wrapper executable 12968c4a8e55Smrg# This function is only a basic sanity check; it will hardly flush out 12978c4a8e55Smrg# determined imposters. 12988c4a8e55Smrgfunc_ltwrapper_p () 12998c4a8e55Smrg{ 13008c4a8e55Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 13018c4a8e55Smrg} 13028c4a8e55Smrg 13038c4a8e55Smrg 13048c4a8e55Smrg# func_execute_cmds commands fail_cmd 13058c4a8e55Smrg# Execute tilde-delimited COMMANDS. 13068c4a8e55Smrg# If FAIL_CMD is given, eval that upon failure. 13078c4a8e55Smrg# FAIL_CMD may read-access the current command in variable CMD! 13088c4a8e55Smrgfunc_execute_cmds () 13098c4a8e55Smrg{ 13108c4a8e55Smrg $opt_debug 13118c4a8e55Smrg save_ifs=$IFS; IFS='~' 13128c4a8e55Smrg for cmd in $1; do 13138c4a8e55Smrg IFS=$save_ifs 13148c4a8e55Smrg eval cmd=\"$cmd\" 13158c4a8e55Smrg func_show_eval "$cmd" "${2-:}" 13168c4a8e55Smrg done 13178c4a8e55Smrg IFS=$save_ifs 13188c4a8e55Smrg} 13198c4a8e55Smrg 13208c4a8e55Smrg 13218c4a8e55Smrg# func_source file 13228c4a8e55Smrg# Source FILE, adding directory component if necessary. 13238c4a8e55Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 13248c4a8e55Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 13258c4a8e55Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 13268c4a8e55Smrg# `FILE.' does not work on cygwin managed mounts. 13278c4a8e55Smrgfunc_source () 13288c4a8e55Smrg{ 13298c4a8e55Smrg $opt_debug 13308c4a8e55Smrg case $1 in 13318c4a8e55Smrg */* | *\\*) . "$1" ;; 13328c4a8e55Smrg *) . "./$1" ;; 13338c4a8e55Smrg esac 13348c4a8e55Smrg} 13358c4a8e55Smrg 13368c4a8e55Smrg 1337bd23fbfaSmrg# func_resolve_sysroot PATH 1338bd23fbfaSmrg# Replace a leading = in PATH with a sysroot. Store the result into 1339bd23fbfaSmrg# func_resolve_sysroot_result 1340bd23fbfaSmrgfunc_resolve_sysroot () 1341bd23fbfaSmrg{ 1342bd23fbfaSmrg func_resolve_sysroot_result=$1 1343bd23fbfaSmrg case $func_resolve_sysroot_result in 1344bd23fbfaSmrg =*) 1345bd23fbfaSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 1346bd23fbfaSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 1347bd23fbfaSmrg ;; 1348bd23fbfaSmrg esac 1349bd23fbfaSmrg} 1350bd23fbfaSmrg 1351bd23fbfaSmrg# func_replace_sysroot PATH 1352bd23fbfaSmrg# If PATH begins with the sysroot, replace it with = and 1353bd23fbfaSmrg# store the result into func_replace_sysroot_result. 1354bd23fbfaSmrgfunc_replace_sysroot () 1355bd23fbfaSmrg{ 1356bd23fbfaSmrg case "$lt_sysroot:$1" in 1357bd23fbfaSmrg ?*:"$lt_sysroot"*) 1358bd23fbfaSmrg func_stripname "$lt_sysroot" '' "$1" 1359bd23fbfaSmrg func_replace_sysroot_result="=$func_stripname_result" 1360bd23fbfaSmrg ;; 1361bd23fbfaSmrg *) 1362bd23fbfaSmrg # Including no sysroot. 1363bd23fbfaSmrg func_replace_sysroot_result=$1 1364bd23fbfaSmrg ;; 1365bd23fbfaSmrg esac 1366bd23fbfaSmrg} 1367bd23fbfaSmrg 13688c4a8e55Smrg# func_infer_tag arg 13698c4a8e55Smrg# Infer tagged configuration to use if any are available and 13708c4a8e55Smrg# if one wasn't chosen via the "--tag" command line option. 13718c4a8e55Smrg# Only attempt this if the compiler in the base compile 13728c4a8e55Smrg# command doesn't match the default compiler. 13738c4a8e55Smrg# arg is usually of the form 'gcc ...' 13748c4a8e55Smrgfunc_infer_tag () 13758c4a8e55Smrg{ 13768c4a8e55Smrg $opt_debug 13778c4a8e55Smrg if test -n "$available_tags" && test -z "$tagname"; then 13788c4a8e55Smrg CC_quoted= 13798c4a8e55Smrg for arg in $CC; do 1380bd23fbfaSmrg func_append_quoted CC_quoted "$arg" 13818c4a8e55Smrg done 1382706b6b52Smrg CC_expanded=`func_echo_all $CC` 1383706b6b52Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 13848c4a8e55Smrg case $@ in 13858c4a8e55Smrg # Blanks in the command may have been stripped by the calling shell, 13868c4a8e55Smrg # but not from the CC environment variable when configure was run. 1387706b6b52Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1388706b6b52Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 13898c4a8e55Smrg # Blanks at the start of $base_compile will cause this to fail 13908c4a8e55Smrg # if we don't check for them as well. 13918c4a8e55Smrg *) 13928c4a8e55Smrg for z in $available_tags; do 13938c4a8e55Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 13948c4a8e55Smrg # Evaluate the configuration. 13958c4a8e55Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 13968c4a8e55Smrg CC_quoted= 13978c4a8e55Smrg for arg in $CC; do 13988c4a8e55Smrg # Double-quote args containing other shell metacharacters. 1399bd23fbfaSmrg func_append_quoted CC_quoted "$arg" 14008c4a8e55Smrg done 1401706b6b52Smrg CC_expanded=`func_echo_all $CC` 1402706b6b52Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 14038c4a8e55Smrg case "$@ " in 1404706b6b52Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1405706b6b52Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 14068c4a8e55Smrg # The compiler in the base compile command matches 14078c4a8e55Smrg # the one in the tagged configuration. 14088c4a8e55Smrg # Assume this is the tagged configuration we want. 14098c4a8e55Smrg tagname=$z 14108c4a8e55Smrg break 14118c4a8e55Smrg ;; 14128c4a8e55Smrg esac 14138c4a8e55Smrg fi 14148c4a8e55Smrg done 14158c4a8e55Smrg # If $tagname still isn't set, then no tagged configuration 14168c4a8e55Smrg # was found and let the user know that the "--tag" command 14178c4a8e55Smrg # line option must be used. 14188c4a8e55Smrg if test -z "$tagname"; then 14198c4a8e55Smrg func_echo "unable to infer tagged configuration" 14208c4a8e55Smrg func_fatal_error "specify a tag with \`--tag'" 14218c4a8e55Smrg# else 14228c4a8e55Smrg# func_verbose "using $tagname tagged configuration" 14238c4a8e55Smrg fi 14248c4a8e55Smrg ;; 14258c4a8e55Smrg esac 14268c4a8e55Smrg fi 14278c4a8e55Smrg} 14288c4a8e55Smrg 14298c4a8e55Smrg 14308c4a8e55Smrg 1431bd23fbfaSmrg# func_write_libtool_object output_name pic_name nonpic_name 1432bd23fbfaSmrg# Create a libtool object file (analogous to a ".la" file), 1433bd23fbfaSmrg# but don't create it if we're doing a dry run. 1434bd23fbfaSmrgfunc_write_libtool_object () 1435bd23fbfaSmrg{ 1436bd23fbfaSmrg write_libobj=${1} 1437bd23fbfaSmrg if test "$build_libtool_libs" = yes; then 1438bd23fbfaSmrg write_lobj=\'${2}\' 1439bd23fbfaSmrg else 1440bd23fbfaSmrg write_lobj=none 1441bd23fbfaSmrg fi 1442bd23fbfaSmrg 1443bd23fbfaSmrg if test "$build_old_libs" = yes; then 1444bd23fbfaSmrg write_oldobj=\'${3}\' 1445bd23fbfaSmrg else 1446bd23fbfaSmrg write_oldobj=none 1447bd23fbfaSmrg fi 1448bd23fbfaSmrg 1449bd23fbfaSmrg $opt_dry_run || { 1450bd23fbfaSmrg cat >${write_libobj}T <<EOF 1451bd23fbfaSmrg# $write_libobj - a libtool object file 1452bd23fbfaSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 1453bd23fbfaSmrg# 1454bd23fbfaSmrg# Please DO NOT delete this file! 1455bd23fbfaSmrg# It is necessary for linking the library. 1456bd23fbfaSmrg 1457bd23fbfaSmrg# Name of the PIC object. 1458bd23fbfaSmrgpic_object=$write_lobj 1459bd23fbfaSmrg 1460bd23fbfaSmrg# Name of the non-PIC object 1461bd23fbfaSmrgnon_pic_object=$write_oldobj 1462bd23fbfaSmrg 1463bd23fbfaSmrgEOF 1464bd23fbfaSmrg $MV "${write_libobj}T" "${write_libobj}" 1465bd23fbfaSmrg } 1466bd23fbfaSmrg} 1467bd23fbfaSmrg 1468bd23fbfaSmrg 1469bd23fbfaSmrg################################################## 1470bd23fbfaSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 1471bd23fbfaSmrg################################################## 1472bd23fbfaSmrg 1473bd23fbfaSmrg# func_convert_core_file_wine_to_w32 ARG 1474bd23fbfaSmrg# Helper function used by file name conversion functions when $build is *nix, 1475bd23fbfaSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 1476bd23fbfaSmrg# correctly configured wine environment available, with the winepath program 1477bd23fbfaSmrg# in $build's $PATH. 1478bd23fbfaSmrg# 1479bd23fbfaSmrg# ARG is the $build file name to be converted to w32 format. 1480bd23fbfaSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 1481bd23fbfaSmrg# be empty on error (or when ARG is empty) 1482bd23fbfaSmrgfunc_convert_core_file_wine_to_w32 () 1483bd23fbfaSmrg{ 1484bd23fbfaSmrg $opt_debug 1485bd23fbfaSmrg func_convert_core_file_wine_to_w32_result="$1" 1486bd23fbfaSmrg if test -n "$1"; then 1487bd23fbfaSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 1488bd23fbfaSmrg # are forced to check the contents of stdout. On the other hand, if the 1489bd23fbfaSmrg # command is not found, the shell will set an exit code of 127 and print 1490bd23fbfaSmrg # *an error message* to stdout. So we must check for both error code of 1491bd23fbfaSmrg # zero AND non-empty stdout, which explains the odd construction: 1492bd23fbfaSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 1493bd23fbfaSmrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 1494bd23fbfaSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 1495bd23fbfaSmrg $SED -e "$lt_sed_naive_backslashify"` 1496bd23fbfaSmrg else 1497bd23fbfaSmrg func_convert_core_file_wine_to_w32_result= 1498bd23fbfaSmrg fi 1499bd23fbfaSmrg fi 1500bd23fbfaSmrg} 1501bd23fbfaSmrg# end: func_convert_core_file_wine_to_w32 1502bd23fbfaSmrg 1503bd23fbfaSmrg 1504bd23fbfaSmrg# func_convert_core_path_wine_to_w32 ARG 1505bd23fbfaSmrg# Helper function used by path conversion functions when $build is *nix, and 1506bd23fbfaSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 1507bd23fbfaSmrg# configured wine environment available, with the winepath program in $build's 1508bd23fbfaSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 1509bd23fbfaSmrg# 1510bd23fbfaSmrg# ARG is path to be converted from $build format to win32. 1511bd23fbfaSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 1512bd23fbfaSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 1513bd23fbfaSmrg# are convertible, then the result may be empty. 1514bd23fbfaSmrgfunc_convert_core_path_wine_to_w32 () 1515bd23fbfaSmrg{ 1516bd23fbfaSmrg $opt_debug 1517bd23fbfaSmrg # unfortunately, winepath doesn't convert paths, only file names 1518bd23fbfaSmrg func_convert_core_path_wine_to_w32_result="" 1519bd23fbfaSmrg if test -n "$1"; then 1520bd23fbfaSmrg oldIFS=$IFS 1521bd23fbfaSmrg IFS=: 1522bd23fbfaSmrg for func_convert_core_path_wine_to_w32_f in $1; do 1523bd23fbfaSmrg IFS=$oldIFS 1524bd23fbfaSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 1525bd23fbfaSmrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 1526bd23fbfaSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 1527bd23fbfaSmrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 1528bd23fbfaSmrg else 1529bd23fbfaSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 1530bd23fbfaSmrg fi 1531bd23fbfaSmrg fi 1532bd23fbfaSmrg done 1533bd23fbfaSmrg IFS=$oldIFS 1534bd23fbfaSmrg fi 1535bd23fbfaSmrg} 1536bd23fbfaSmrg# end: func_convert_core_path_wine_to_w32 1537bd23fbfaSmrg 1538bd23fbfaSmrg 1539bd23fbfaSmrg# func_cygpath ARGS... 1540bd23fbfaSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 1541bd23fbfaSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 1542bd23fbfaSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 1543bd23fbfaSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 1544bd23fbfaSmrg# file name or path is assumed to be in w32 format, as previously converted 1545bd23fbfaSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 1546bd23fbfaSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 1547bd23fbfaSmrg# Cygwin format). Returns an empty string on error. 1548bd23fbfaSmrg# 1549bd23fbfaSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 1550bd23fbfaSmrg# be converted. 1551bd23fbfaSmrg# 1552bd23fbfaSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 1553bd23fbfaSmrg# environment variable; do not put it in $PATH. 1554bd23fbfaSmrgfunc_cygpath () 1555bd23fbfaSmrg{ 1556bd23fbfaSmrg $opt_debug 1557bd23fbfaSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 1558bd23fbfaSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 1559bd23fbfaSmrg if test "$?" -ne 0; then 1560bd23fbfaSmrg # on failure, ensure result is empty 1561bd23fbfaSmrg func_cygpath_result= 1562bd23fbfaSmrg fi 1563bd23fbfaSmrg else 1564bd23fbfaSmrg func_cygpath_result= 1565bd23fbfaSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 1566bd23fbfaSmrg fi 1567bd23fbfaSmrg} 1568bd23fbfaSmrg#end: func_cygpath 1569bd23fbfaSmrg 1570bd23fbfaSmrg 1571bd23fbfaSmrg# func_convert_core_msys_to_w32 ARG 1572bd23fbfaSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 1573bd23fbfaSmrg# result in func_convert_core_msys_to_w32_result. 1574bd23fbfaSmrgfunc_convert_core_msys_to_w32 () 1575bd23fbfaSmrg{ 1576bd23fbfaSmrg $opt_debug 1577bd23fbfaSmrg # awkward: cmd appends spaces to result 1578bd23fbfaSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 1579bd23fbfaSmrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 1580bd23fbfaSmrg} 1581bd23fbfaSmrg#end: func_convert_core_msys_to_w32 1582bd23fbfaSmrg 1583bd23fbfaSmrg 1584bd23fbfaSmrg# func_convert_file_check ARG1 ARG2 1585bd23fbfaSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 1586bd23fbfaSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 1587bd23fbfaSmrg# func_to_host_file_result to ARG1). 1588bd23fbfaSmrgfunc_convert_file_check () 1589bd23fbfaSmrg{ 1590bd23fbfaSmrg $opt_debug 1591bd23fbfaSmrg if test -z "$2" && test -n "$1" ; then 1592bd23fbfaSmrg func_error "Could not determine host file name corresponding to" 1593bd23fbfaSmrg func_error " \`$1'" 1594bd23fbfaSmrg func_error "Continuing, but uninstalled executables may not work." 1595bd23fbfaSmrg # Fallback: 1596bd23fbfaSmrg func_to_host_file_result="$1" 1597bd23fbfaSmrg fi 1598bd23fbfaSmrg} 1599bd23fbfaSmrg# end func_convert_file_check 1600bd23fbfaSmrg 1601bd23fbfaSmrg 1602bd23fbfaSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 1603bd23fbfaSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 1604bd23fbfaSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 1605bd23fbfaSmrg# func_to_host_file_result to a simplistic fallback value (see below). 1606bd23fbfaSmrgfunc_convert_path_check () 1607bd23fbfaSmrg{ 1608bd23fbfaSmrg $opt_debug 1609bd23fbfaSmrg if test -z "$4" && test -n "$3"; then 1610bd23fbfaSmrg func_error "Could not determine the host path corresponding to" 1611bd23fbfaSmrg func_error " \`$3'" 1612bd23fbfaSmrg func_error "Continuing, but uninstalled executables may not work." 1613bd23fbfaSmrg # Fallback. This is a deliberately simplistic "conversion" and 1614bd23fbfaSmrg # should not be "improved". See libtool.info. 1615bd23fbfaSmrg if test "x$1" != "x$2"; then 1616bd23fbfaSmrg lt_replace_pathsep_chars="s|$1|$2|g" 1617bd23fbfaSmrg func_to_host_path_result=`echo "$3" | 1618bd23fbfaSmrg $SED -e "$lt_replace_pathsep_chars"` 1619bd23fbfaSmrg else 1620bd23fbfaSmrg func_to_host_path_result="$3" 1621bd23fbfaSmrg fi 1622bd23fbfaSmrg fi 1623bd23fbfaSmrg} 1624bd23fbfaSmrg# end func_convert_path_check 1625bd23fbfaSmrg 1626bd23fbfaSmrg 1627bd23fbfaSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 1628bd23fbfaSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 1629bd23fbfaSmrg# and appending REPL if ORIG matches BACKPAT. 1630bd23fbfaSmrgfunc_convert_path_front_back_pathsep () 1631bd23fbfaSmrg{ 1632bd23fbfaSmrg $opt_debug 1633bd23fbfaSmrg case $4 in 1634bd23fbfaSmrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 1635bd23fbfaSmrg ;; 1636bd23fbfaSmrg esac 1637bd23fbfaSmrg case $4 in 1638bd23fbfaSmrg $2 ) func_append func_to_host_path_result "$3" 1639bd23fbfaSmrg ;; 1640bd23fbfaSmrg esac 1641bd23fbfaSmrg} 1642bd23fbfaSmrg# end func_convert_path_front_back_pathsep 1643bd23fbfaSmrg 1644bd23fbfaSmrg 1645bd23fbfaSmrg################################################## 1646bd23fbfaSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 1647bd23fbfaSmrg################################################## 1648bd23fbfaSmrg# invoked via `$to_host_file_cmd ARG' 1649bd23fbfaSmrg# 1650bd23fbfaSmrg# In each case, ARG is the path to be converted from $build to $host format. 1651bd23fbfaSmrg# Result will be available in $func_to_host_file_result. 1652bd23fbfaSmrg 1653bd23fbfaSmrg 1654bd23fbfaSmrg# func_to_host_file ARG 1655bd23fbfaSmrg# Converts the file name ARG from $build format to $host format. Return result 1656bd23fbfaSmrg# in func_to_host_file_result. 1657bd23fbfaSmrgfunc_to_host_file () 1658bd23fbfaSmrg{ 1659bd23fbfaSmrg $opt_debug 1660bd23fbfaSmrg $to_host_file_cmd "$1" 1661bd23fbfaSmrg} 1662bd23fbfaSmrg# end func_to_host_file 1663bd23fbfaSmrg 1664bd23fbfaSmrg 1665bd23fbfaSmrg# func_to_tool_file ARG LAZY 1666bd23fbfaSmrg# converts the file name ARG from $build format to toolchain format. Return 1667bd23fbfaSmrg# result in func_to_tool_file_result. If the conversion in use is listed 1668bd23fbfaSmrg# in (the comma separated) LAZY, no conversion takes place. 1669bd23fbfaSmrgfunc_to_tool_file () 1670bd23fbfaSmrg{ 1671bd23fbfaSmrg $opt_debug 1672bd23fbfaSmrg case ,$2, in 1673bd23fbfaSmrg *,"$to_tool_file_cmd",*) 1674bd23fbfaSmrg func_to_tool_file_result=$1 1675bd23fbfaSmrg ;; 1676bd23fbfaSmrg *) 1677bd23fbfaSmrg $to_tool_file_cmd "$1" 1678bd23fbfaSmrg func_to_tool_file_result=$func_to_host_file_result 1679bd23fbfaSmrg ;; 1680bd23fbfaSmrg esac 1681bd23fbfaSmrg} 1682bd23fbfaSmrg# end func_to_tool_file 1683bd23fbfaSmrg 1684bd23fbfaSmrg 1685bd23fbfaSmrg# func_convert_file_noop ARG 1686bd23fbfaSmrg# Copy ARG to func_to_host_file_result. 1687bd23fbfaSmrgfunc_convert_file_noop () 1688bd23fbfaSmrg{ 1689bd23fbfaSmrg func_to_host_file_result="$1" 1690bd23fbfaSmrg} 1691bd23fbfaSmrg# end func_convert_file_noop 1692bd23fbfaSmrg 1693bd23fbfaSmrg 1694bd23fbfaSmrg# func_convert_file_msys_to_w32 ARG 1695bd23fbfaSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 1696bd23fbfaSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 1697bd23fbfaSmrg# func_to_host_file_result. 1698bd23fbfaSmrgfunc_convert_file_msys_to_w32 () 1699bd23fbfaSmrg{ 1700bd23fbfaSmrg $opt_debug 1701bd23fbfaSmrg func_to_host_file_result="$1" 1702bd23fbfaSmrg if test -n "$1"; then 1703bd23fbfaSmrg func_convert_core_msys_to_w32 "$1" 1704bd23fbfaSmrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 1705bd23fbfaSmrg fi 1706bd23fbfaSmrg func_convert_file_check "$1" "$func_to_host_file_result" 1707bd23fbfaSmrg} 1708bd23fbfaSmrg# end func_convert_file_msys_to_w32 1709bd23fbfaSmrg 1710bd23fbfaSmrg 1711bd23fbfaSmrg# func_convert_file_cygwin_to_w32 ARG 1712bd23fbfaSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 1713bd23fbfaSmrg# func_to_host_file_result. 1714bd23fbfaSmrgfunc_convert_file_cygwin_to_w32 () 1715bd23fbfaSmrg{ 1716bd23fbfaSmrg $opt_debug 1717bd23fbfaSmrg func_to_host_file_result="$1" 1718bd23fbfaSmrg if test -n "$1"; then 1719bd23fbfaSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 1720bd23fbfaSmrg # LT_CYGPATH in this case. 1721bd23fbfaSmrg func_to_host_file_result=`cygpath -m "$1"` 1722bd23fbfaSmrg fi 1723bd23fbfaSmrg func_convert_file_check "$1" "$func_to_host_file_result" 1724bd23fbfaSmrg} 1725bd23fbfaSmrg# end func_convert_file_cygwin_to_w32 1726bd23fbfaSmrg 1727bd23fbfaSmrg 1728bd23fbfaSmrg# func_convert_file_nix_to_w32 ARG 1729bd23fbfaSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 1730bd23fbfaSmrg# and a working winepath. Returns result in func_to_host_file_result. 1731bd23fbfaSmrgfunc_convert_file_nix_to_w32 () 1732bd23fbfaSmrg{ 1733bd23fbfaSmrg $opt_debug 1734bd23fbfaSmrg func_to_host_file_result="$1" 1735bd23fbfaSmrg if test -n "$1"; then 1736bd23fbfaSmrg func_convert_core_file_wine_to_w32 "$1" 1737bd23fbfaSmrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 1738bd23fbfaSmrg fi 1739bd23fbfaSmrg func_convert_file_check "$1" "$func_to_host_file_result" 1740bd23fbfaSmrg} 1741bd23fbfaSmrg# end func_convert_file_nix_to_w32 1742bd23fbfaSmrg 1743bd23fbfaSmrg 1744bd23fbfaSmrg# func_convert_file_msys_to_cygwin ARG 1745bd23fbfaSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1746bd23fbfaSmrg# Returns result in func_to_host_file_result. 1747bd23fbfaSmrgfunc_convert_file_msys_to_cygwin () 1748bd23fbfaSmrg{ 1749bd23fbfaSmrg $opt_debug 1750bd23fbfaSmrg func_to_host_file_result="$1" 1751bd23fbfaSmrg if test -n "$1"; then 1752bd23fbfaSmrg func_convert_core_msys_to_w32 "$1" 1753bd23fbfaSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 1754bd23fbfaSmrg func_to_host_file_result="$func_cygpath_result" 1755bd23fbfaSmrg fi 1756bd23fbfaSmrg func_convert_file_check "$1" "$func_to_host_file_result" 1757bd23fbfaSmrg} 1758bd23fbfaSmrg# end func_convert_file_msys_to_cygwin 1759bd23fbfaSmrg 1760bd23fbfaSmrg 1761bd23fbfaSmrg# func_convert_file_nix_to_cygwin ARG 1762bd23fbfaSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 1763bd23fbfaSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 1764bd23fbfaSmrg# in func_to_host_file_result. 1765bd23fbfaSmrgfunc_convert_file_nix_to_cygwin () 1766bd23fbfaSmrg{ 1767bd23fbfaSmrg $opt_debug 1768bd23fbfaSmrg func_to_host_file_result="$1" 1769bd23fbfaSmrg if test -n "$1"; then 1770bd23fbfaSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 1771bd23fbfaSmrg func_convert_core_file_wine_to_w32 "$1" 1772bd23fbfaSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 1773bd23fbfaSmrg func_to_host_file_result="$func_cygpath_result" 1774bd23fbfaSmrg fi 1775bd23fbfaSmrg func_convert_file_check "$1" "$func_to_host_file_result" 1776bd23fbfaSmrg} 1777bd23fbfaSmrg# end func_convert_file_nix_to_cygwin 1778bd23fbfaSmrg 1779bd23fbfaSmrg 1780bd23fbfaSmrg############################################# 1781bd23fbfaSmrg# $build to $host PATH CONVERSION FUNCTIONS # 1782bd23fbfaSmrg############################################# 1783bd23fbfaSmrg# invoked via `$to_host_path_cmd ARG' 1784bd23fbfaSmrg# 1785bd23fbfaSmrg# In each case, ARG is the path to be converted from $build to $host format. 1786bd23fbfaSmrg# The result will be available in $func_to_host_path_result. 1787bd23fbfaSmrg# 1788bd23fbfaSmrg# Path separators are also converted from $build format to $host format. If 1789bd23fbfaSmrg# ARG begins or ends with a path separator character, it is preserved (but 1790bd23fbfaSmrg# converted to $host format) on output. 1791bd23fbfaSmrg# 1792bd23fbfaSmrg# All path conversion functions are named using the following convention: 1793bd23fbfaSmrg# file name conversion function : func_convert_file_X_to_Y () 1794bd23fbfaSmrg# path conversion function : func_convert_path_X_to_Y () 1795bd23fbfaSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 1796bd23fbfaSmrg# same. If conversion functions are added for new $build/$host combinations, 1797bd23fbfaSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 1798bd23fbfaSmrg# will break. 1799bd23fbfaSmrg 1800bd23fbfaSmrg 1801bd23fbfaSmrg# func_init_to_host_path_cmd 1802bd23fbfaSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 1803bd23fbfaSmrg# appropriate value, based on the value of $to_host_file_cmd. 1804bd23fbfaSmrgto_host_path_cmd= 1805bd23fbfaSmrgfunc_init_to_host_path_cmd () 1806bd23fbfaSmrg{ 1807bd23fbfaSmrg $opt_debug 1808bd23fbfaSmrg if test -z "$to_host_path_cmd"; then 1809bd23fbfaSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 1810bd23fbfaSmrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 1811bd23fbfaSmrg fi 1812bd23fbfaSmrg} 1813bd23fbfaSmrg 1814bd23fbfaSmrg 1815bd23fbfaSmrg# func_to_host_path ARG 1816bd23fbfaSmrg# Converts the path ARG from $build format to $host format. Return result 1817bd23fbfaSmrg# in func_to_host_path_result. 1818bd23fbfaSmrgfunc_to_host_path () 1819bd23fbfaSmrg{ 1820bd23fbfaSmrg $opt_debug 1821bd23fbfaSmrg func_init_to_host_path_cmd 1822bd23fbfaSmrg $to_host_path_cmd "$1" 1823bd23fbfaSmrg} 1824bd23fbfaSmrg# end func_to_host_path 1825bd23fbfaSmrg 1826bd23fbfaSmrg 1827bd23fbfaSmrg# func_convert_path_noop ARG 1828bd23fbfaSmrg# Copy ARG to func_to_host_path_result. 1829bd23fbfaSmrgfunc_convert_path_noop () 1830bd23fbfaSmrg{ 1831bd23fbfaSmrg func_to_host_path_result="$1" 1832bd23fbfaSmrg} 1833bd23fbfaSmrg# end func_convert_path_noop 1834bd23fbfaSmrg 1835bd23fbfaSmrg 1836bd23fbfaSmrg# func_convert_path_msys_to_w32 ARG 1837bd23fbfaSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 1838bd23fbfaSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 1839bd23fbfaSmrg# func_to_host_path_result. 1840bd23fbfaSmrgfunc_convert_path_msys_to_w32 () 18418c4a8e55Smrg{ 1842bd23fbfaSmrg $opt_debug 1843bd23fbfaSmrg func_to_host_path_result="$1" 1844bd23fbfaSmrg if test -n "$1"; then 1845bd23fbfaSmrg # Remove leading and trailing path separator characters from ARG. MSYS 1846bd23fbfaSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 1847bd23fbfaSmrg # and winepath ignores them completely. 1848bd23fbfaSmrg func_stripname : : "$1" 1849bd23fbfaSmrg func_to_host_path_tmp1=$func_stripname_result 1850bd23fbfaSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1851bd23fbfaSmrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 1852bd23fbfaSmrg func_convert_path_check : ";" \ 1853bd23fbfaSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1854bd23fbfaSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1855bd23fbfaSmrg fi 1856bd23fbfaSmrg} 1857bd23fbfaSmrg# end func_convert_path_msys_to_w32 18588c4a8e55Smrg 18598c4a8e55Smrg 1860bd23fbfaSmrg# func_convert_path_cygwin_to_w32 ARG 1861bd23fbfaSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 1862bd23fbfaSmrg# func_to_host_file_result. 1863bd23fbfaSmrgfunc_convert_path_cygwin_to_w32 () 1864bd23fbfaSmrg{ 1865bd23fbfaSmrg $opt_debug 1866bd23fbfaSmrg func_to_host_path_result="$1" 1867bd23fbfaSmrg if test -n "$1"; then 1868bd23fbfaSmrg # See func_convert_path_msys_to_w32: 1869bd23fbfaSmrg func_stripname : : "$1" 1870bd23fbfaSmrg func_to_host_path_tmp1=$func_stripname_result 1871bd23fbfaSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 1872bd23fbfaSmrg func_convert_path_check : ";" \ 1873bd23fbfaSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1874bd23fbfaSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1875bd23fbfaSmrg fi 1876bd23fbfaSmrg} 1877bd23fbfaSmrg# end func_convert_path_cygwin_to_w32 18788c4a8e55Smrg 18798c4a8e55Smrg 1880bd23fbfaSmrg# func_convert_path_nix_to_w32 ARG 1881bd23fbfaSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 1882bd23fbfaSmrg# a working winepath. Returns result in func_to_host_file_result. 1883bd23fbfaSmrgfunc_convert_path_nix_to_w32 () 1884bd23fbfaSmrg{ 1885bd23fbfaSmrg $opt_debug 1886bd23fbfaSmrg func_to_host_path_result="$1" 1887bd23fbfaSmrg if test -n "$1"; then 1888bd23fbfaSmrg # See func_convert_path_msys_to_w32: 1889bd23fbfaSmrg func_stripname : : "$1" 1890bd23fbfaSmrg func_to_host_path_tmp1=$func_stripname_result 1891bd23fbfaSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1892bd23fbfaSmrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 1893bd23fbfaSmrg func_convert_path_check : ";" \ 1894bd23fbfaSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1895bd23fbfaSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1896bd23fbfaSmrg fi 1897bd23fbfaSmrg} 1898bd23fbfaSmrg# end func_convert_path_nix_to_w32 18998c4a8e55Smrg 1900bd23fbfaSmrg 1901bd23fbfaSmrg# func_convert_path_msys_to_cygwin ARG 1902bd23fbfaSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1903bd23fbfaSmrg# Returns result in func_to_host_file_result. 1904bd23fbfaSmrgfunc_convert_path_msys_to_cygwin () 1905bd23fbfaSmrg{ 1906bd23fbfaSmrg $opt_debug 1907bd23fbfaSmrg func_to_host_path_result="$1" 1908bd23fbfaSmrg if test -n "$1"; then 1909bd23fbfaSmrg # See func_convert_path_msys_to_w32: 1910bd23fbfaSmrg func_stripname : : "$1" 1911bd23fbfaSmrg func_to_host_path_tmp1=$func_stripname_result 1912bd23fbfaSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1913bd23fbfaSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 1914bd23fbfaSmrg func_to_host_path_result="$func_cygpath_result" 1915bd23fbfaSmrg func_convert_path_check : : \ 1916bd23fbfaSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1917bd23fbfaSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1918bd23fbfaSmrg fi 1919bd23fbfaSmrg} 1920bd23fbfaSmrg# end func_convert_path_msys_to_cygwin 1921bd23fbfaSmrg 1922bd23fbfaSmrg 1923bd23fbfaSmrg# func_convert_path_nix_to_cygwin ARG 1924bd23fbfaSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 1925bd23fbfaSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 1926bd23fbfaSmrg# func_to_host_file_result. 1927bd23fbfaSmrgfunc_convert_path_nix_to_cygwin () 1928bd23fbfaSmrg{ 1929bd23fbfaSmrg $opt_debug 1930bd23fbfaSmrg func_to_host_path_result="$1" 1931bd23fbfaSmrg if test -n "$1"; then 1932bd23fbfaSmrg # Remove leading and trailing path separator characters from 1933bd23fbfaSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 1934bd23fbfaSmrg # into '.;' and ';.', and winepath ignores them completely. 1935bd23fbfaSmrg func_stripname : : "$1" 1936bd23fbfaSmrg func_to_host_path_tmp1=$func_stripname_result 1937bd23fbfaSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1938bd23fbfaSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 1939bd23fbfaSmrg func_to_host_path_result="$func_cygpath_result" 1940bd23fbfaSmrg func_convert_path_check : : \ 1941bd23fbfaSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1942bd23fbfaSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1943bd23fbfaSmrg fi 19448c4a8e55Smrg} 1945bd23fbfaSmrg# end func_convert_path_nix_to_cygwin 1946bd23fbfaSmrg 19478c4a8e55Smrg 19488c4a8e55Smrg# func_mode_compile arg... 19498c4a8e55Smrgfunc_mode_compile () 19508c4a8e55Smrg{ 19518c4a8e55Smrg $opt_debug 19528c4a8e55Smrg # Get the compilation command and the source file. 19538c4a8e55Smrg base_compile= 19548c4a8e55Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 19558c4a8e55Smrg suppress_opt=yes 19568c4a8e55Smrg suppress_output= 19578c4a8e55Smrg arg_mode=normal 19588c4a8e55Smrg libobj= 19598c4a8e55Smrg later= 19608c4a8e55Smrg pie_flag= 19618c4a8e55Smrg 19628c4a8e55Smrg for arg 19638c4a8e55Smrg do 19648c4a8e55Smrg case $arg_mode in 19658c4a8e55Smrg arg ) 19668c4a8e55Smrg # do not "continue". Instead, add this to base_compile 19678c4a8e55Smrg lastarg="$arg" 19688c4a8e55Smrg arg_mode=normal 19698c4a8e55Smrg ;; 19708c4a8e55Smrg 19718c4a8e55Smrg target ) 19728c4a8e55Smrg libobj="$arg" 19738c4a8e55Smrg arg_mode=normal 19748c4a8e55Smrg continue 19758c4a8e55Smrg ;; 19768c4a8e55Smrg 19778c4a8e55Smrg normal ) 19788c4a8e55Smrg # Accept any command-line options. 19798c4a8e55Smrg case $arg in 19808c4a8e55Smrg -o) 19818c4a8e55Smrg test -n "$libobj" && \ 19828c4a8e55Smrg func_fatal_error "you cannot specify \`-o' more than once" 19838c4a8e55Smrg arg_mode=target 19848c4a8e55Smrg continue 19858c4a8e55Smrg ;; 19868c4a8e55Smrg 19878c4a8e55Smrg -pie | -fpie | -fPIE) 1988bd23fbfaSmrg func_append pie_flag " $arg" 19898c4a8e55Smrg continue 19908c4a8e55Smrg ;; 19918c4a8e55Smrg 19928c4a8e55Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 1993bd23fbfaSmrg func_append later " $arg" 19948c4a8e55Smrg continue 19958c4a8e55Smrg ;; 19968c4a8e55Smrg 19978c4a8e55Smrg -no-suppress) 19988c4a8e55Smrg suppress_opt=no 19998c4a8e55Smrg continue 20008c4a8e55Smrg ;; 20018c4a8e55Smrg 20028c4a8e55Smrg -Xcompiler) 20038c4a8e55Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 20048c4a8e55Smrg continue # The current "srcfile" will either be retained or 20058c4a8e55Smrg ;; # replaced later. I would guess that would be a bug. 2006b042e37fSmrg 2007b042e37fSmrg -Wc,*) 20088c4a8e55Smrg func_stripname '-Wc,' '' "$arg" 20098c4a8e55Smrg args=$func_stripname_result 2010b042e37fSmrg lastarg= 2011b042e37fSmrg save_ifs="$IFS"; IFS=',' 20128c4a8e55Smrg for arg in $args; do 2013b042e37fSmrg IFS="$save_ifs" 2014bd23fbfaSmrg func_append_quoted lastarg "$arg" 2015b042e37fSmrg done 2016b042e37fSmrg IFS="$save_ifs" 20178c4a8e55Smrg func_stripname ' ' '' "$lastarg" 20188c4a8e55Smrg lastarg=$func_stripname_result 2019b042e37fSmrg 2020b042e37fSmrg # Add the arguments to base_compile. 2021bd23fbfaSmrg func_append base_compile " $lastarg" 2022b042e37fSmrg continue 2023b042e37fSmrg ;; 2024b042e37fSmrg 20258c4a8e55Smrg *) 2026b042e37fSmrg # Accept the current argument as the source file. 2027b042e37fSmrg # The previous "srcfile" becomes the current argument. 2028b042e37fSmrg # 2029b042e37fSmrg lastarg="$srcfile" 2030b042e37fSmrg srcfile="$arg" 2031b042e37fSmrg ;; 2032b042e37fSmrg esac # case $arg 2033b042e37fSmrg ;; 2034b042e37fSmrg esac # case $arg_mode 2035b042e37fSmrg 2036b042e37fSmrg # Aesthetically quote the previous argument. 2037bd23fbfaSmrg func_append_quoted base_compile "$lastarg" 2038b042e37fSmrg done # for arg 2039b042e37fSmrg 2040b042e37fSmrg case $arg_mode in 2041b042e37fSmrg arg) 20428c4a8e55Smrg func_fatal_error "you must specify an argument for -Xcompile" 2043b042e37fSmrg ;; 2044b042e37fSmrg target) 20458c4a8e55Smrg func_fatal_error "you must specify a target with \`-o'" 2046b042e37fSmrg ;; 2047b042e37fSmrg *) 2048b042e37fSmrg # Get the name of the library object. 20498c4a8e55Smrg test -z "$libobj" && { 20508c4a8e55Smrg func_basename "$srcfile" 20518c4a8e55Smrg libobj="$func_basename_result" 20528c4a8e55Smrg } 2053b042e37fSmrg ;; 2054b042e37fSmrg esac 2055b042e37fSmrg 2056b042e37fSmrg # Recognize several different file suffixes. 2057b042e37fSmrg # If the user specifies -o file.o, it is replaced with file.lo 2058b042e37fSmrg case $libobj in 20598c4a8e55Smrg *.[cCFSifmso] | \ 20608c4a8e55Smrg *.ada | *.adb | *.ads | *.asm | \ 20618c4a8e55Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 2062706b6b52Smrg *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup) 20638c4a8e55Smrg func_xform "$libobj" 20648c4a8e55Smrg libobj=$func_xform_result 20658c4a8e55Smrg ;; 2066b042e37fSmrg esac 2067b042e37fSmrg 2068b042e37fSmrg case $libobj in 20698c4a8e55Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 2070b042e37fSmrg *) 20718c4a8e55Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 2072b042e37fSmrg ;; 2073b042e37fSmrg esac 2074b042e37fSmrg 2075b042e37fSmrg func_infer_tag $base_compile 2076b042e37fSmrg 2077b042e37fSmrg for arg in $later; do 2078b042e37fSmrg case $arg in 20798c4a8e55Smrg -shared) 20808c4a8e55Smrg test "$build_libtool_libs" != yes && \ 20818c4a8e55Smrg func_fatal_configuration "can not build a shared library" 20828c4a8e55Smrg build_old_libs=no 20838c4a8e55Smrg continue 20848c4a8e55Smrg ;; 20858c4a8e55Smrg 2086b042e37fSmrg -static) 20878c4a8e55Smrg build_libtool_libs=no 2088b042e37fSmrg build_old_libs=yes 2089b042e37fSmrg continue 2090b042e37fSmrg ;; 2091b042e37fSmrg 2092b042e37fSmrg -prefer-pic) 2093b042e37fSmrg pic_mode=yes 2094b042e37fSmrg continue 2095b042e37fSmrg ;; 2096b042e37fSmrg 2097b042e37fSmrg -prefer-non-pic) 2098b042e37fSmrg pic_mode=no 2099b042e37fSmrg continue 2100b042e37fSmrg ;; 2101b042e37fSmrg esac 2102b042e37fSmrg done 2103b042e37fSmrg 21048c4a8e55Smrg func_quote_for_eval "$libobj" 21058c4a8e55Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 21068c4a8e55Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 21078c4a8e55Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 21088c4a8e55Smrg func_dirname_and_basename "$obj" "/" "" 21098c4a8e55Smrg objname="$func_basename_result" 21108c4a8e55Smrg xdir="$func_dirname_result" 2111b042e37fSmrg lobj=${xdir}$objdir/$objname 2112b042e37fSmrg 21138c4a8e55Smrg test -z "$base_compile" && \ 21148c4a8e55Smrg func_fatal_help "you must specify a compilation command" 2115b042e37fSmrg 2116b042e37fSmrg # Delete any leftover library objects. 2117b042e37fSmrg if test "$build_old_libs" = yes; then 2118b042e37fSmrg removelist="$obj $lobj $libobj ${libobj}T" 2119b042e37fSmrg else 2120b042e37fSmrg removelist="$lobj $libobj ${libobj}T" 2121b042e37fSmrg fi 2122b042e37fSmrg 2123b042e37fSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 2124b042e37fSmrg case $host_os in 21258c4a8e55Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 2126b042e37fSmrg pic_mode=default 2127b042e37fSmrg ;; 2128b042e37fSmrg esac 2129b042e37fSmrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 2130b042e37fSmrg # non-PIC code in shared libraries is not supported 2131b042e37fSmrg pic_mode=default 2132b042e37fSmrg fi 2133b042e37fSmrg 2134b042e37fSmrg # Calculate the filename of the output object if compiler does 2135b042e37fSmrg # not support -o with -c 2136b042e37fSmrg if test "$compiler_c_o" = no; then 2137706b6b52Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 2138b042e37fSmrg lockfile="$output_obj.lock" 2139b042e37fSmrg else 2140b042e37fSmrg output_obj= 2141b042e37fSmrg need_locks=no 2142b042e37fSmrg lockfile= 2143b042e37fSmrg fi 2144b042e37fSmrg 2145b042e37fSmrg # Lock this critical section if it is needed 2146b042e37fSmrg # We use this script file to make the link, it avoids creating a new file 2147b042e37fSmrg if test "$need_locks" = yes; then 21488c4a8e55Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 21498c4a8e55Smrg func_echo "Waiting for $lockfile to be removed" 2150b042e37fSmrg sleep 2 2151b042e37fSmrg done 2152b042e37fSmrg elif test "$need_locks" = warn; then 2153b042e37fSmrg if test -f "$lockfile"; then 21548c4a8e55Smrg $ECHO "\ 2155b042e37fSmrg*** ERROR, $lockfile exists and contains: 2156b042e37fSmrg`cat $lockfile 2>/dev/null` 2157b042e37fSmrg 2158b042e37fSmrgThis indicates that another process is trying to use the same 2159b042e37fSmrgtemporary object file, and libtool could not work around it because 2160b042e37fSmrgyour compiler does not support \`-c' and \`-o' together. If you 2161b042e37fSmrgrepeat this compilation, it may succeed, by chance, but you had better 2162b042e37fSmrgavoid parallel builds (make -j) in this platform, or get a better 2163b042e37fSmrgcompiler." 2164b042e37fSmrg 21658c4a8e55Smrg $opt_dry_run || $RM $removelist 2166b042e37fSmrg exit $EXIT_FAILURE 2167b042e37fSmrg fi 2168bd23fbfaSmrg func_append removelist " $output_obj" 21698c4a8e55Smrg $ECHO "$srcfile" > "$lockfile" 2170b042e37fSmrg fi 2171b042e37fSmrg 21728c4a8e55Smrg $opt_dry_run || $RM $removelist 2173bd23fbfaSmrg func_append removelist " $lockfile" 21748c4a8e55Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 21758c4a8e55Smrg 2176bd23fbfaSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 2177bd23fbfaSmrg srcfile=$func_to_tool_file_result 21788c4a8e55Smrg func_quote_for_eval "$srcfile" 21798c4a8e55Smrg qsrcfile=$func_quote_for_eval_result 2180b042e37fSmrg 2181b042e37fSmrg # Only build a PIC object if we are building libtool libraries. 2182b042e37fSmrg if test "$build_libtool_libs" = yes; then 2183b042e37fSmrg # Without this assignment, base_compile gets emptied. 2184b042e37fSmrg fbsd_hideous_sh_bug=$base_compile 2185b042e37fSmrg 2186b042e37fSmrg if test "$pic_mode" != no; then 2187b042e37fSmrg command="$base_compile $qsrcfile $pic_flag" 2188b042e37fSmrg else 2189b042e37fSmrg # Don't build PIC code 2190b042e37fSmrg command="$base_compile $qsrcfile" 2191b042e37fSmrg fi 2192b042e37fSmrg 21938c4a8e55Smrg func_mkdir_p "$xdir$objdir" 2194b042e37fSmrg 2195b042e37fSmrg if test -z "$output_obj"; then 2196b042e37fSmrg # Place PIC objects in $objdir 2197bd23fbfaSmrg func_append command " -o $lobj" 2198b042e37fSmrg fi 2199b042e37fSmrg 22008c4a8e55Smrg func_show_eval_locale "$command" \ 22018c4a8e55Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 2202b042e37fSmrg 2203b042e37fSmrg if test "$need_locks" = warn && 2204b042e37fSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 22058c4a8e55Smrg $ECHO "\ 2206b042e37fSmrg*** ERROR, $lockfile contains: 2207b042e37fSmrg`cat $lockfile 2>/dev/null` 2208b042e37fSmrg 2209b042e37fSmrgbut it should contain: 2210b042e37fSmrg$srcfile 2211b042e37fSmrg 2212b042e37fSmrgThis indicates that another process is trying to use the same 2213b042e37fSmrgtemporary object file, and libtool could not work around it because 2214b042e37fSmrgyour compiler does not support \`-c' and \`-o' together. If you 2215b042e37fSmrgrepeat this compilation, it may succeed, by chance, but you had better 2216b042e37fSmrgavoid parallel builds (make -j) in this platform, or get a better 2217b042e37fSmrgcompiler." 2218b042e37fSmrg 22198c4a8e55Smrg $opt_dry_run || $RM $removelist 2220b042e37fSmrg exit $EXIT_FAILURE 2221b042e37fSmrg fi 2222b042e37fSmrg 2223b042e37fSmrg # Just move the object if needed, then go on to compile the next one 2224b042e37fSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 22258c4a8e55Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 22268c4a8e55Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2227b042e37fSmrg fi 2228b042e37fSmrg 2229b042e37fSmrg # Allow error messages only from the first compilation. 2230b042e37fSmrg if test "$suppress_opt" = yes; then 22318c4a8e55Smrg suppress_output=' >/dev/null 2>&1' 2232b042e37fSmrg fi 2233b042e37fSmrg fi 2234b042e37fSmrg 2235b042e37fSmrg # Only build a position-dependent object if we build old libraries. 2236b042e37fSmrg if test "$build_old_libs" = yes; then 2237b042e37fSmrg if test "$pic_mode" != yes; then 2238b042e37fSmrg # Don't build PIC code 22398c4a8e55Smrg command="$base_compile $qsrcfile$pie_flag" 2240b042e37fSmrg else 2241b042e37fSmrg command="$base_compile $qsrcfile $pic_flag" 2242b042e37fSmrg fi 2243b042e37fSmrg if test "$compiler_c_o" = yes; then 2244bd23fbfaSmrg func_append command " -o $obj" 2245b042e37fSmrg fi 2246b042e37fSmrg 2247b042e37fSmrg # Suppress compiler output if we already did a PIC compilation. 2248bd23fbfaSmrg func_append command "$suppress_output" 22498c4a8e55Smrg func_show_eval_locale "$command" \ 22508c4a8e55Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 2251b042e37fSmrg 2252b042e37fSmrg if test "$need_locks" = warn && 2253b042e37fSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 22548c4a8e55Smrg $ECHO "\ 2255b042e37fSmrg*** ERROR, $lockfile contains: 2256b042e37fSmrg`cat $lockfile 2>/dev/null` 2257b042e37fSmrg 2258b042e37fSmrgbut it should contain: 2259b042e37fSmrg$srcfile 2260b042e37fSmrg 2261b042e37fSmrgThis indicates that another process is trying to use the same 2262b042e37fSmrgtemporary object file, and libtool could not work around it because 2263b042e37fSmrgyour compiler does not support \`-c' and \`-o' together. If you 2264b042e37fSmrgrepeat this compilation, it may succeed, by chance, but you had better 2265b042e37fSmrgavoid parallel builds (make -j) in this platform, or get a better 2266b042e37fSmrgcompiler." 2267b042e37fSmrg 22688c4a8e55Smrg $opt_dry_run || $RM $removelist 2269b042e37fSmrg exit $EXIT_FAILURE 2270b042e37fSmrg fi 2271b042e37fSmrg 2272b042e37fSmrg # Just move the object if needed 2273b042e37fSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 22748c4a8e55Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 22758c4a8e55Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2276b042e37fSmrg fi 22778c4a8e55Smrg fi 2278b042e37fSmrg 22798c4a8e55Smrg $opt_dry_run || { 22808c4a8e55Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 2281b042e37fSmrg 22828c4a8e55Smrg # Unlock the critical section if it was locked 22838c4a8e55Smrg if test "$need_locks" != no; then 22848c4a8e55Smrg removelist=$lockfile 22858c4a8e55Smrg $RM "$lockfile" 22868c4a8e55Smrg fi 22878c4a8e55Smrg } 2288b042e37fSmrg 22898c4a8e55Smrg exit $EXIT_SUCCESS 22908c4a8e55Smrg} 2291b042e37fSmrg 22928c4a8e55Smrg$opt_help || { 2293bd23fbfaSmrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 22948c4a8e55Smrg} 2295b042e37fSmrg 22968c4a8e55Smrgfunc_mode_help () 22978c4a8e55Smrg{ 22988c4a8e55Smrg # We need to display help for each of the modes. 2299bd23fbfaSmrg case $opt_mode in 23008c4a8e55Smrg "") 23018c4a8e55Smrg # Generic help is extracted from the usage comments 23028c4a8e55Smrg # at the start of this file. 23038c4a8e55Smrg func_help 23048c4a8e55Smrg ;; 2305b042e37fSmrg 23068c4a8e55Smrg clean) 23078c4a8e55Smrg $ECHO \ 23088c4a8e55Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 2309b042e37fSmrg 23108c4a8e55SmrgRemove files from the build directory. 2311b042e37fSmrg 23128c4a8e55SmrgRM is the name of the program to use to delete files associated with each FILE 23138c4a8e55Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 23148c4a8e55Smrgto RM. 2315b042e37fSmrg 23168c4a8e55SmrgIf FILE is a libtool library, object or program, all the files associated 23178c4a8e55Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 23188c4a8e55Smrg ;; 2319b042e37fSmrg 23208c4a8e55Smrg compile) 23218c4a8e55Smrg $ECHO \ 23228c4a8e55Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 2323b042e37fSmrg 23248c4a8e55SmrgCompile a source file into a libtool library object. 2325b042e37fSmrg 23268c4a8e55SmrgThis mode accepts the following additional options: 2327b042e37fSmrg 23288c4a8e55Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 23298c4a8e55Smrg -no-suppress do not suppress compiler output for multiple passes 2330706b6b52Smrg -prefer-pic try to build PIC objects only 2331706b6b52Smrg -prefer-non-pic try to build non-PIC objects only 23328c4a8e55Smrg -shared do not build a \`.o' file suitable for static linking 23338c4a8e55Smrg -static only build a \`.o' file suitable for static linking 2334706b6b52Smrg -Wc,FLAG pass FLAG directly to the compiler 2335b042e37fSmrg 23368c4a8e55SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 23378c4a8e55Smrgfrom the given SOURCEFILE. 2338b042e37fSmrg 23398c4a8e55SmrgThe output file name is determined by removing the directory component from 23408c4a8e55SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 23418c4a8e55Smrglibrary object suffix, \`.lo'." 23428c4a8e55Smrg ;; 2343b042e37fSmrg 23448c4a8e55Smrg execute) 23458c4a8e55Smrg $ECHO \ 23468c4a8e55Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 2347b042e37fSmrg 23488c4a8e55SmrgAutomatically set library path, then run a program. 2349b042e37fSmrg 23508c4a8e55SmrgThis mode accepts the following additional options: 2351b042e37fSmrg 23528c4a8e55Smrg -dlopen FILE add the directory containing FILE to the library path 2353b042e37fSmrg 23548c4a8e55SmrgThis mode sets the library path environment variable according to \`-dlopen' 23558c4a8e55Smrgflags. 2356b042e37fSmrg 23578c4a8e55SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 23588c4a8e55Smrginto their corresponding uninstalled binary, and any of their required library 23598c4a8e55Smrgdirectories are added to the library path. 2360b042e37fSmrg 23618c4a8e55SmrgThen, COMMAND is executed, with ARGS as arguments." 23628c4a8e55Smrg ;; 2363b042e37fSmrg 23648c4a8e55Smrg finish) 23658c4a8e55Smrg $ECHO \ 23668c4a8e55Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 2367b042e37fSmrg 23688c4a8e55SmrgComplete the installation of libtool libraries. 2369b042e37fSmrg 23708c4a8e55SmrgEach LIBDIR is a directory that contains libtool libraries. 2371b042e37fSmrg 23728c4a8e55SmrgThe commands that this mode executes may require superuser privileges. Use 23738c4a8e55Smrgthe \`--dry-run' option if you just want to see what would be executed." 23748c4a8e55Smrg ;; 2375b042e37fSmrg 23768c4a8e55Smrg install) 23778c4a8e55Smrg $ECHO \ 23788c4a8e55Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 2379b042e37fSmrg 23808c4a8e55SmrgInstall executables or libraries. 2381b042e37fSmrg 23828c4a8e55SmrgINSTALL-COMMAND is the installation command. The first component should be 23838c4a8e55Smrgeither the \`install' or \`cp' program. 2384b042e37fSmrg 23858c4a8e55SmrgThe following components of INSTALL-COMMAND are treated specially: 2386b042e37fSmrg 2387706b6b52Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 2388b042e37fSmrg 23898c4a8e55SmrgThe rest of the components are interpreted as arguments to that command (only 23908c4a8e55SmrgBSD-compatible install options are recognized)." 23918c4a8e55Smrg ;; 2392b042e37fSmrg 23938c4a8e55Smrg link) 23948c4a8e55Smrg $ECHO \ 23958c4a8e55Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 2396b042e37fSmrg 23978c4a8e55SmrgLink object files or libraries together to form another library, or to 23988c4a8e55Smrgcreate an executable program. 2399b042e37fSmrg 24008c4a8e55SmrgLINK-COMMAND is a command using the C compiler that you would use to create 24018c4a8e55Smrga program from several object files. 2402b042e37fSmrg 24038c4a8e55SmrgThe following components of LINK-COMMAND are treated specially: 2404b042e37fSmrg 24058c4a8e55Smrg -all-static do not do any dynamic linking at all 24068c4a8e55Smrg -avoid-version do not add a version suffix if possible 2407706b6b52Smrg -bindir BINDIR specify path to binaries directory (for systems where 2408706b6b52Smrg libraries must be found in the PATH setting at runtime) 24098c4a8e55Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 24108c4a8e55Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 24118c4a8e55Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 24128c4a8e55Smrg -export-symbols SYMFILE 24138c4a8e55Smrg try to export only the symbols listed in SYMFILE 24148c4a8e55Smrg -export-symbols-regex REGEX 24158c4a8e55Smrg try to export only the symbols matching REGEX 24168c4a8e55Smrg -LLIBDIR search LIBDIR for required installed libraries 24178c4a8e55Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 24188c4a8e55Smrg -module build a library that can dlopened 24198c4a8e55Smrg -no-fast-install disable the fast-install mode 24208c4a8e55Smrg -no-install link a not-installable executable 24218c4a8e55Smrg -no-undefined declare that a library does not refer to external symbols 24228c4a8e55Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 24238c4a8e55Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 24248c4a8e55Smrg -precious-files-regex REGEX 24258c4a8e55Smrg don't remove output files matching REGEX 24268c4a8e55Smrg -release RELEASE specify package release information 24278c4a8e55Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 24288c4a8e55Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 24298c4a8e55Smrg -shared only do dynamic linking of libtool libraries 24308c4a8e55Smrg -shrext SUFFIX override the standard shared library file extension 24318c4a8e55Smrg -static do not do any dynamic linking of uninstalled libtool libraries 24328c4a8e55Smrg -static-libtool-libs 24338c4a8e55Smrg do not do any dynamic linking of libtool libraries 24348c4a8e55Smrg -version-info CURRENT[:REVISION[:AGE]] 24358c4a8e55Smrg specify library version info [each variable defaults to 0] 24368c4a8e55Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 2437706b6b52Smrg -Wc,FLAG 2438706b6b52Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 2439706b6b52Smrg -Wl,FLAG 2440706b6b52Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 2441706b6b52Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 2442b042e37fSmrg 24438c4a8e55SmrgAll other options (arguments beginning with \`-') are ignored. 2444b042e37fSmrg 24458c4a8e55SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 24468c4a8e55Smrgtreated as uninstalled libtool libraries, other files are standard or library 24478c4a8e55Smrgobject files. 2448b042e37fSmrg 24498c4a8e55SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 24508c4a8e55Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 24518c4a8e55Smrgrequired, except when creating a convenience library. 2452b042e37fSmrg 24538c4a8e55SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 24548c4a8e55Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 2455b042e37fSmrg 24568c4a8e55SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 24578c4a8e55Smrgis created, otherwise an executable program is created." 24588c4a8e55Smrg ;; 2459b042e37fSmrg 24608c4a8e55Smrg uninstall) 24618c4a8e55Smrg $ECHO \ 24628c4a8e55Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 2463b042e37fSmrg 24648c4a8e55SmrgRemove libraries from an installation directory. 2465b042e37fSmrg 24668c4a8e55SmrgRM is the name of the program to use to delete files associated with each FILE 24678c4a8e55Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 24688c4a8e55Smrgto RM. 2469b042e37fSmrg 24708c4a8e55SmrgIf FILE is a libtool library, all the files associated with it are deleted. 24718c4a8e55SmrgOtherwise, only FILE itself is deleted using RM." 2472b042e37fSmrg ;; 2473b042e37fSmrg 24748c4a8e55Smrg *) 2475bd23fbfaSmrg func_fatal_help "invalid operation mode \`$opt_mode'" 24768c4a8e55Smrg ;; 24778c4a8e55Smrg esac 2478b042e37fSmrg 2479706b6b52Smrg echo 24808c4a8e55Smrg $ECHO "Try \`$progname --help' for more information about other modes." 24818c4a8e55Smrg} 2482b042e37fSmrg 2483706b6b52Smrg# Now that we've collected a possible --mode arg, show help if necessary 2484706b6b52Smrgif $opt_help; then 2485706b6b52Smrg if test "$opt_help" = :; then 2486706b6b52Smrg func_mode_help 2487706b6b52Smrg else 2488706b6b52Smrg { 2489706b6b52Smrg func_help noexit 2490bd23fbfaSmrg for opt_mode in compile link execute install finish uninstall clean; do 2491706b6b52Smrg func_mode_help 2492706b6b52Smrg done 2493706b6b52Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 2494706b6b52Smrg { 2495706b6b52Smrg func_help noexit 2496bd23fbfaSmrg for opt_mode in compile link execute install finish uninstall clean; do 2497706b6b52Smrg echo 2498706b6b52Smrg func_mode_help 2499706b6b52Smrg done 2500706b6b52Smrg } | 2501706b6b52Smrg sed '1d 2502706b6b52Smrg /^When reporting/,/^Report/{ 2503706b6b52Smrg H 2504706b6b52Smrg d 2505706b6b52Smrg } 2506706b6b52Smrg $x 2507706b6b52Smrg /information about other modes/d 2508706b6b52Smrg /more detailed .*MODE/d 2509706b6b52Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 2510706b6b52Smrg fi 2511706b6b52Smrg exit $? 2512706b6b52Smrgfi 2513b042e37fSmrg 2514b042e37fSmrg 25158c4a8e55Smrg# func_mode_execute arg... 25168c4a8e55Smrgfunc_mode_execute () 25178c4a8e55Smrg{ 25188c4a8e55Smrg $opt_debug 25198c4a8e55Smrg # The first argument is the command name. 25208c4a8e55Smrg cmd="$nonopt" 25218c4a8e55Smrg test -z "$cmd" && \ 25228c4a8e55Smrg func_fatal_help "you must specify a COMMAND" 2523b042e37fSmrg 25248c4a8e55Smrg # Handle -dlopen flags immediately. 2525bd23fbfaSmrg for file in $opt_dlopen; do 25268c4a8e55Smrg test -f "$file" \ 25278c4a8e55Smrg || func_fatal_help "\`$file' is not a file" 2528b042e37fSmrg 25298c4a8e55Smrg dir= 25308c4a8e55Smrg case $file in 25318c4a8e55Smrg *.la) 2532bd23fbfaSmrg func_resolve_sysroot "$file" 2533bd23fbfaSmrg file=$func_resolve_sysroot_result 2534bd23fbfaSmrg 25358c4a8e55Smrg # Check to see that this really is a libtool archive. 25368c4a8e55Smrg func_lalib_unsafe_p "$file" \ 25378c4a8e55Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 2538b042e37fSmrg 25398c4a8e55Smrg # Read the libtool library. 25408c4a8e55Smrg dlname= 25418c4a8e55Smrg library_names= 25428c4a8e55Smrg func_source "$file" 2543b042e37fSmrg 25448c4a8e55Smrg # Skip this library if it cannot be dlopened. 25458c4a8e55Smrg if test -z "$dlname"; then 25468c4a8e55Smrg # Warn if it was a shared library. 25478c4a8e55Smrg test -n "$library_names" && \ 25488c4a8e55Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 25498c4a8e55Smrg continue 25508c4a8e55Smrg fi 2551b042e37fSmrg 25528c4a8e55Smrg func_dirname "$file" "" "." 25538c4a8e55Smrg dir="$func_dirname_result" 2554b042e37fSmrg 25558c4a8e55Smrg if test -f "$dir/$objdir/$dlname"; then 2556bd23fbfaSmrg func_append dir "/$objdir" 25578c4a8e55Smrg else 25588c4a8e55Smrg if test ! -f "$dir/$dlname"; then 25598c4a8e55Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 25608c4a8e55Smrg fi 25618c4a8e55Smrg fi 2562b042e37fSmrg ;; 2563b042e37fSmrg 25648c4a8e55Smrg *.lo) 25658c4a8e55Smrg # Just add the directory containing the .lo file. 25668c4a8e55Smrg func_dirname "$file" "" "." 25678c4a8e55Smrg dir="$func_dirname_result" 2568b042e37fSmrg ;; 2569b042e37fSmrg 25708c4a8e55Smrg *) 25718c4a8e55Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 2572b042e37fSmrg continue 2573b042e37fSmrg ;; 25748c4a8e55Smrg esac 2575b042e37fSmrg 25768c4a8e55Smrg # Get the absolute pathname. 25778c4a8e55Smrg absdir=`cd "$dir" && pwd` 25788c4a8e55Smrg test -n "$absdir" && dir="$absdir" 2579b042e37fSmrg 25808c4a8e55Smrg # Now add the directory to shlibpath_var. 25818c4a8e55Smrg if eval "test -z \"\$$shlibpath_var\""; then 25828c4a8e55Smrg eval "$shlibpath_var=\"\$dir\"" 25838c4a8e55Smrg else 25848c4a8e55Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 25858c4a8e55Smrg fi 25868c4a8e55Smrg done 2587b042e37fSmrg 25888c4a8e55Smrg # This variable tells wrapper scripts just to set shlibpath_var 25898c4a8e55Smrg # rather than running their programs. 25908c4a8e55Smrg libtool_execute_magic="$magic" 2591b042e37fSmrg 25928c4a8e55Smrg # Check if any of the arguments is a wrapper script. 25938c4a8e55Smrg args= 25948c4a8e55Smrg for file 25958c4a8e55Smrg do 25968c4a8e55Smrg case $file in 2597706b6b52Smrg -* | *.la | *.lo ) ;; 25988c4a8e55Smrg *) 25998c4a8e55Smrg # Do a test to see if this is really a libtool program. 26008c4a8e55Smrg if func_ltwrapper_script_p "$file"; then 26018c4a8e55Smrg func_source "$file" 26028c4a8e55Smrg # Transform arg to wrapped name. 26038c4a8e55Smrg file="$progdir/$program" 26048c4a8e55Smrg elif func_ltwrapper_executable_p "$file"; then 26058c4a8e55Smrg func_ltwrapper_scriptname "$file" 26068c4a8e55Smrg func_source "$func_ltwrapper_scriptname_result" 26078c4a8e55Smrg # Transform arg to wrapped name. 26088c4a8e55Smrg file="$progdir/$program" 26098c4a8e55Smrg fi 2610b042e37fSmrg ;; 26118c4a8e55Smrg esac 26128c4a8e55Smrg # Quote arguments (to preserve shell metacharacters). 2613bd23fbfaSmrg func_append_quoted args "$file" 26148c4a8e55Smrg done 2615b042e37fSmrg 26168c4a8e55Smrg if test "X$opt_dry_run" = Xfalse; then 26178c4a8e55Smrg if test -n "$shlibpath_var"; then 26188c4a8e55Smrg # Export the shlibpath_var. 26198c4a8e55Smrg eval "export $shlibpath_var" 26208c4a8e55Smrg fi 2621b042e37fSmrg 26228c4a8e55Smrg # Restore saved environment variables 26238c4a8e55Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 26248c4a8e55Smrg do 26258c4a8e55Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 26268c4a8e55Smrg $lt_var=\$save_$lt_var; export $lt_var 26278c4a8e55Smrg else 26288c4a8e55Smrg $lt_unset $lt_var 26298c4a8e55Smrg fi" 26308c4a8e55Smrg done 2631b042e37fSmrg 26328c4a8e55Smrg # Now prepare to actually exec the command. 26338c4a8e55Smrg exec_cmd="\$cmd$args" 26348c4a8e55Smrg else 26358c4a8e55Smrg # Display what would be done. 26368c4a8e55Smrg if test -n "$shlibpath_var"; then 26378c4a8e55Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 2638706b6b52Smrg echo "export $shlibpath_var" 26398c4a8e55Smrg fi 26408c4a8e55Smrg $ECHO "$cmd$args" 26418c4a8e55Smrg exit $EXIT_SUCCESS 26428c4a8e55Smrg fi 26438c4a8e55Smrg} 2644b042e37fSmrg 2645bd23fbfaSmrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 2646b042e37fSmrg 2647b042e37fSmrg 26488c4a8e55Smrg# func_mode_finish arg... 26498c4a8e55Smrgfunc_mode_finish () 26508c4a8e55Smrg{ 26518c4a8e55Smrg $opt_debug 2652bd23fbfaSmrg libs= 2653bd23fbfaSmrg libdirs= 26548c4a8e55Smrg admincmds= 2655b042e37fSmrg 2656bd23fbfaSmrg for opt in "$nonopt" ${1+"$@"} 2657bd23fbfaSmrg do 2658bd23fbfaSmrg if test -d "$opt"; then 2659bd23fbfaSmrg func_append libdirs " $opt" 2660bd23fbfaSmrg 2661bd23fbfaSmrg elif test -f "$opt"; then 2662bd23fbfaSmrg if func_lalib_unsafe_p "$opt"; then 2663bd23fbfaSmrg func_append libs " $opt" 2664bd23fbfaSmrg else 2665bd23fbfaSmrg func_warning "\`$opt' is not a valid libtool archive" 2666bd23fbfaSmrg fi 2667bd23fbfaSmrg 2668bd23fbfaSmrg else 2669bd23fbfaSmrg func_fatal_error "invalid argument \`$opt'" 2670bd23fbfaSmrg fi 2671bd23fbfaSmrg done 2672bd23fbfaSmrg 2673bd23fbfaSmrg if test -n "$libs"; then 2674bd23fbfaSmrg if test -n "$lt_sysroot"; then 2675bd23fbfaSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 2676bd23fbfaSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 2677bd23fbfaSmrg else 2678bd23fbfaSmrg sysroot_cmd= 2679bd23fbfaSmrg fi 2680bd23fbfaSmrg 2681bd23fbfaSmrg # Remove sysroot references 2682bd23fbfaSmrg if $opt_dry_run; then 2683bd23fbfaSmrg for lib in $libs; do 2684bd23fbfaSmrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 2685bd23fbfaSmrg done 2686bd23fbfaSmrg else 2687bd23fbfaSmrg tmpdir=`func_mktempdir` 2688bd23fbfaSmrg for lib in $libs; do 2689bd23fbfaSmrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 2690bd23fbfaSmrg > $tmpdir/tmp-la 2691bd23fbfaSmrg mv -f $tmpdir/tmp-la $lib 2692bd23fbfaSmrg done 2693bd23fbfaSmrg ${RM}r "$tmpdir" 2694bd23fbfaSmrg fi 2695bd23fbfaSmrg fi 2696b042e37fSmrg 2697bd23fbfaSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 26988c4a8e55Smrg for libdir in $libdirs; do 26998c4a8e55Smrg if test -n "$finish_cmds"; then 27008c4a8e55Smrg # Do each command in the finish commands. 27018c4a8e55Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 27028c4a8e55Smrg'"$cmd"'"' 27038c4a8e55Smrg fi 27048c4a8e55Smrg if test -n "$finish_eval"; then 27058c4a8e55Smrg # Do the single finish_eval. 27068c4a8e55Smrg eval cmds=\"$finish_eval\" 2707bd23fbfaSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 27088c4a8e55Smrg $cmds" 27098c4a8e55Smrg fi 27108c4a8e55Smrg done 27118c4a8e55Smrg fi 2712b042e37fSmrg 27138c4a8e55Smrg # Exit here if they wanted silent mode. 27148c4a8e55Smrg $opt_silent && exit $EXIT_SUCCESS 2715b042e37fSmrg 2716bd23fbfaSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2717bd23fbfaSmrg echo "----------------------------------------------------------------------" 2718bd23fbfaSmrg echo "Libraries have been installed in:" 2719bd23fbfaSmrg for libdir in $libdirs; do 2720bd23fbfaSmrg $ECHO " $libdir" 2721bd23fbfaSmrg done 2722bd23fbfaSmrg echo 2723bd23fbfaSmrg echo "If you ever happen to want to link against installed libraries" 2724bd23fbfaSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 2725bd23fbfaSmrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 2726bd23fbfaSmrg echo "flag during linking and do at least one of the following:" 2727bd23fbfaSmrg if test -n "$shlibpath_var"; then 2728bd23fbfaSmrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 2729bd23fbfaSmrg echo " during execution" 2730bd23fbfaSmrg fi 2731bd23fbfaSmrg if test -n "$runpath_var"; then 2732bd23fbfaSmrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 2733bd23fbfaSmrg echo " during linking" 2734bd23fbfaSmrg fi 2735bd23fbfaSmrg if test -n "$hardcode_libdir_flag_spec"; then 2736bd23fbfaSmrg libdir=LIBDIR 2737bd23fbfaSmrg eval flag=\"$hardcode_libdir_flag_spec\" 2738b042e37fSmrg 2739bd23fbfaSmrg $ECHO " - use the \`$flag' linker flag" 2740bd23fbfaSmrg fi 2741bd23fbfaSmrg if test -n "$admincmds"; then 2742bd23fbfaSmrg $ECHO " - have your system administrator run these commands:$admincmds" 2743bd23fbfaSmrg fi 2744bd23fbfaSmrg if test -f /etc/ld.so.conf; then 2745bd23fbfaSmrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 2746bd23fbfaSmrg fi 2747bd23fbfaSmrg echo 2748b042e37fSmrg 2749bd23fbfaSmrg echo "See any operating system documentation about shared libraries for" 2750bd23fbfaSmrg case $host in 2751bd23fbfaSmrg solaris2.[6789]|solaris2.1[0-9]) 2752bd23fbfaSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 2753bd23fbfaSmrg echo "pages." 2754bd23fbfaSmrg ;; 2755bd23fbfaSmrg *) 2756bd23fbfaSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 2757bd23fbfaSmrg ;; 2758bd23fbfaSmrg esac 2759bd23fbfaSmrg echo "----------------------------------------------------------------------" 2760bd23fbfaSmrg fi 27618c4a8e55Smrg exit $EXIT_SUCCESS 27628c4a8e55Smrg} 2763b042e37fSmrg 2764bd23fbfaSmrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 2765b042e37fSmrg 2766b042e37fSmrg 27678c4a8e55Smrg# func_mode_install arg... 27688c4a8e55Smrgfunc_mode_install () 27698c4a8e55Smrg{ 27708c4a8e55Smrg $opt_debug 27718c4a8e55Smrg # There may be an optional sh(1) argument at the beginning of 27728c4a8e55Smrg # install_prog (especially on Windows NT). 27738c4a8e55Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 27748c4a8e55Smrg # Allow the use of GNU shtool's install command. 2775706b6b52Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 27768c4a8e55Smrg # Aesthetically quote it. 27778c4a8e55Smrg func_quote_for_eval "$nonopt" 27788c4a8e55Smrg install_prog="$func_quote_for_eval_result " 27798c4a8e55Smrg arg=$1 27808c4a8e55Smrg shift 27818c4a8e55Smrg else 27828c4a8e55Smrg install_prog= 27838c4a8e55Smrg arg=$nonopt 27848c4a8e55Smrg fi 27858c4a8e55Smrg 27868c4a8e55Smrg # The real first argument should be the name of the installation program. 27878c4a8e55Smrg # Aesthetically quote it. 27888c4a8e55Smrg func_quote_for_eval "$arg" 2789bd23fbfaSmrg func_append install_prog "$func_quote_for_eval_result" 2790706b6b52Smrg install_shared_prog=$install_prog 2791706b6b52Smrg case " $install_prog " in 2792706b6b52Smrg *[\\\ /]cp\ *) install_cp=: ;; 2793706b6b52Smrg *) install_cp=false ;; 2794706b6b52Smrg esac 27958c4a8e55Smrg 27968c4a8e55Smrg # We need to accept at least all the BSD install flags. 27978c4a8e55Smrg dest= 27988c4a8e55Smrg files= 27998c4a8e55Smrg opts= 28008c4a8e55Smrg prev= 28018c4a8e55Smrg install_type= 28028c4a8e55Smrg isdir=no 28038c4a8e55Smrg stripme= 2804706b6b52Smrg no_mode=: 28058c4a8e55Smrg for arg 28068c4a8e55Smrg do 2807706b6b52Smrg arg2= 28088c4a8e55Smrg if test -n "$dest"; then 2809bd23fbfaSmrg func_append files " $dest" 28108c4a8e55Smrg dest=$arg 2811b042e37fSmrg continue 28128c4a8e55Smrg fi 2813b042e37fSmrg 28148c4a8e55Smrg case $arg in 28158c4a8e55Smrg -d) isdir=yes ;; 28168c4a8e55Smrg -f) 2817706b6b52Smrg if $install_cp; then :; else 2818706b6b52Smrg prev=$arg 2819706b6b52Smrg fi 2820b042e37fSmrg ;; 28218c4a8e55Smrg -g | -m | -o) 28228c4a8e55Smrg prev=$arg 28238c4a8e55Smrg ;; 28248c4a8e55Smrg -s) 28258c4a8e55Smrg stripme=" -s" 28268c4a8e55Smrg continue 28278c4a8e55Smrg ;; 28288c4a8e55Smrg -*) 28298c4a8e55Smrg ;; 28308c4a8e55Smrg *) 28318c4a8e55Smrg # If the previous option needed an argument, then skip it. 28328c4a8e55Smrg if test -n "$prev"; then 2833706b6b52Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 2834706b6b52Smrg arg2=$install_override_mode 2835706b6b52Smrg no_mode=false 2836706b6b52Smrg fi 28378c4a8e55Smrg prev= 28388c4a8e55Smrg else 28398c4a8e55Smrg dest=$arg 28408c4a8e55Smrg continue 28418c4a8e55Smrg fi 28428c4a8e55Smrg ;; 28438c4a8e55Smrg esac 2844b042e37fSmrg 28458c4a8e55Smrg # Aesthetically quote the argument. 28468c4a8e55Smrg func_quote_for_eval "$arg" 2847bd23fbfaSmrg func_append install_prog " $func_quote_for_eval_result" 2848706b6b52Smrg if test -n "$arg2"; then 2849706b6b52Smrg func_quote_for_eval "$arg2" 2850706b6b52Smrg fi 2851bd23fbfaSmrg func_append install_shared_prog " $func_quote_for_eval_result" 28528c4a8e55Smrg done 2853b042e37fSmrg 28548c4a8e55Smrg test -z "$install_prog" && \ 28558c4a8e55Smrg func_fatal_help "you must specify an install program" 2856b042e37fSmrg 28578c4a8e55Smrg test -n "$prev" && \ 28588c4a8e55Smrg func_fatal_help "the \`$prev' option requires an argument" 28598c4a8e55Smrg 2860706b6b52Smrg if test -n "$install_override_mode" && $no_mode; then 2861706b6b52Smrg if $install_cp; then :; else 2862706b6b52Smrg func_quote_for_eval "$install_override_mode" 2863bd23fbfaSmrg func_append install_shared_prog " -m $func_quote_for_eval_result" 2864706b6b52Smrg fi 2865706b6b52Smrg fi 2866706b6b52Smrg 28678c4a8e55Smrg if test -z "$files"; then 28688c4a8e55Smrg if test -z "$dest"; then 28698c4a8e55Smrg func_fatal_help "no file or destination specified" 28708c4a8e55Smrg else 28718c4a8e55Smrg func_fatal_help "you must specify a destination" 28728c4a8e55Smrg fi 2873b042e37fSmrg fi 2874b042e37fSmrg 28758c4a8e55Smrg # Strip any trailing slash from the destination. 28768c4a8e55Smrg func_stripname '' '/' "$dest" 28778c4a8e55Smrg dest=$func_stripname_result 2878b042e37fSmrg 28798c4a8e55Smrg # Check to see that the destination is a directory. 28808c4a8e55Smrg test -d "$dest" && isdir=yes 28818c4a8e55Smrg if test "$isdir" = yes; then 28828c4a8e55Smrg destdir="$dest" 28838c4a8e55Smrg destname= 2884b042e37fSmrg else 28858c4a8e55Smrg func_dirname_and_basename "$dest" "" "." 28868c4a8e55Smrg destdir="$func_dirname_result" 28878c4a8e55Smrg destname="$func_basename_result" 2888b042e37fSmrg 28898c4a8e55Smrg # Not a directory, so check to see that there is only one file specified. 28908c4a8e55Smrg set dummy $files; shift 28918c4a8e55Smrg test "$#" -gt 1 && \ 28928c4a8e55Smrg func_fatal_help "\`$dest' is not a directory" 2893b042e37fSmrg fi 28948c4a8e55Smrg case $destdir in 28958c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 2896b042e37fSmrg *) 28978c4a8e55Smrg for file in $files; do 28988c4a8e55Smrg case $file in 28998c4a8e55Smrg *.lo) ;; 29008c4a8e55Smrg *) 29018c4a8e55Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 29028c4a8e55Smrg ;; 29038c4a8e55Smrg esac 29048c4a8e55Smrg done 2905b042e37fSmrg ;; 2906b042e37fSmrg esac 2907b042e37fSmrg 29088c4a8e55Smrg # This variable tells wrapper scripts just to set variables rather 29098c4a8e55Smrg # than running their programs. 29108c4a8e55Smrg libtool_install_magic="$magic" 2911b042e37fSmrg 29128c4a8e55Smrg staticlibs= 29138c4a8e55Smrg future_libdirs= 29148c4a8e55Smrg current_libdirs= 29158c4a8e55Smrg for file in $files; do 2916b042e37fSmrg 29178c4a8e55Smrg # Do each installation. 29188c4a8e55Smrg case $file in 29198c4a8e55Smrg *.$libext) 29208c4a8e55Smrg # Do the static libraries later. 2921bd23fbfaSmrg func_append staticlibs " $file" 29228c4a8e55Smrg ;; 29238c4a8e55Smrg 29248c4a8e55Smrg *.la) 2925bd23fbfaSmrg func_resolve_sysroot "$file" 2926bd23fbfaSmrg file=$func_resolve_sysroot_result 2927bd23fbfaSmrg 29288c4a8e55Smrg # Check to see that this really is a libtool archive. 29298c4a8e55Smrg func_lalib_unsafe_p "$file" \ 29308c4a8e55Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 29318c4a8e55Smrg 29328c4a8e55Smrg library_names= 29338c4a8e55Smrg old_library= 29348c4a8e55Smrg relink_command= 29358c4a8e55Smrg func_source "$file" 29368c4a8e55Smrg 29378c4a8e55Smrg # Add the libdir to current_libdirs if it is the destination. 29388c4a8e55Smrg if test "X$destdir" = "X$libdir"; then 29398c4a8e55Smrg case "$current_libdirs " in 29408c4a8e55Smrg *" $libdir "*) ;; 2941bd23fbfaSmrg *) func_append current_libdirs " $libdir" ;; 2942b042e37fSmrg esac 29438c4a8e55Smrg else 29448c4a8e55Smrg # Note the libdir as a future libdir. 29458c4a8e55Smrg case "$future_libdirs " in 29468c4a8e55Smrg *" $libdir "*) ;; 2947bd23fbfaSmrg *) func_append future_libdirs " $libdir" ;; 29488c4a8e55Smrg esac 29498c4a8e55Smrg fi 2950b042e37fSmrg 29518c4a8e55Smrg func_dirname "$file" "/" "" 29528c4a8e55Smrg dir="$func_dirname_result" 2953bd23fbfaSmrg func_append dir "$objdir" 29548c4a8e55Smrg 29558c4a8e55Smrg if test -n "$relink_command"; then 29568c4a8e55Smrg # Determine the prefix the user has applied to our future dir. 2957706b6b52Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 29588c4a8e55Smrg 29598c4a8e55Smrg # Don't allow the user to place us outside of our expected 29608c4a8e55Smrg # location b/c this prevents finding dependent libraries that 29618c4a8e55Smrg # are installed to the same prefix. 29628c4a8e55Smrg # At present, this check doesn't affect windows .dll's that 29638c4a8e55Smrg # are installed into $libdir/../bin (currently, that works fine) 29648c4a8e55Smrg # but it's something to keep an eye on. 29658c4a8e55Smrg test "$inst_prefix_dir" = "$destdir" && \ 29668c4a8e55Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 29678c4a8e55Smrg 29688c4a8e55Smrg if test -n "$inst_prefix_dir"; then 29698c4a8e55Smrg # Stick the inst_prefix_dir data into the link command. 2970706b6b52Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 29718c4a8e55Smrg else 2972706b6b52Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 29738c4a8e55Smrg fi 29748c4a8e55Smrg 29758c4a8e55Smrg func_warning "relinking \`$file'" 29768c4a8e55Smrg func_show_eval "$relink_command" \ 29778c4a8e55Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 29788c4a8e55Smrg fi 29798c4a8e55Smrg 29808c4a8e55Smrg # See the names of the shared library. 29818c4a8e55Smrg set dummy $library_names; shift 29828c4a8e55Smrg if test -n "$1"; then 29838c4a8e55Smrg realname="$1" 29848c4a8e55Smrg shift 29858c4a8e55Smrg 29868c4a8e55Smrg srcname="$realname" 29878c4a8e55Smrg test -n "$relink_command" && srcname="$realname"T 29888c4a8e55Smrg 29898c4a8e55Smrg # Install the shared library and build the symlinks. 2990706b6b52Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 29918c4a8e55Smrg 'exit $?' 29928c4a8e55Smrg tstripme="$stripme" 29938c4a8e55Smrg case $host_os in 29948c4a8e55Smrg cygwin* | mingw* | pw32* | cegcc*) 29958c4a8e55Smrg case $realname in 29968c4a8e55Smrg *.dll.a) 29978c4a8e55Smrg tstripme="" 29988c4a8e55Smrg ;; 29998c4a8e55Smrg esac 3000b042e37fSmrg ;; 3001b042e37fSmrg esac 30028c4a8e55Smrg if test -n "$tstripme" && test -n "$striplib"; then 30038c4a8e55Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 3004b042e37fSmrg fi 3005b042e37fSmrg 30068c4a8e55Smrg if test "$#" -gt 0; then 30078c4a8e55Smrg # Delete the old symlinks, and create new ones. 30088c4a8e55Smrg # Try `ln -sf' first, because the `ln' binary might depend on 30098c4a8e55Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 30108c4a8e55Smrg # so we also need to try rm && ln -s. 30118c4a8e55Smrg for linkname 30128c4a8e55Smrg do 30138c4a8e55Smrg test "$linkname" != "$realname" \ 30148c4a8e55Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 3015b042e37fSmrg done 3016b042e37fSmrg fi 3017b042e37fSmrg 30188c4a8e55Smrg # Do each command in the postinstall commands. 30198c4a8e55Smrg lib="$destdir/$realname" 30208c4a8e55Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 3021b042e37fSmrg fi 3022b042e37fSmrg 30238c4a8e55Smrg # Install the pseudo-library for information purposes. 30248c4a8e55Smrg func_basename "$file" 30258c4a8e55Smrg name="$func_basename_result" 30268c4a8e55Smrg instname="$dir/$name"i 30278c4a8e55Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 3028b042e37fSmrg 30298c4a8e55Smrg # Maybe install the static library, too. 3030bd23fbfaSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 30318c4a8e55Smrg ;; 3032b042e37fSmrg 30338c4a8e55Smrg *.lo) 30348c4a8e55Smrg # Install (i.e. copy) a libtool object. 3035b042e37fSmrg 30368c4a8e55Smrg # Figure out destination file name, if it wasn't already specified. 30378c4a8e55Smrg if test -n "$destname"; then 30388c4a8e55Smrg destfile="$destdir/$destname" 30398c4a8e55Smrg else 30408c4a8e55Smrg func_basename "$file" 30418c4a8e55Smrg destfile="$func_basename_result" 30428c4a8e55Smrg destfile="$destdir/$destfile" 3043b042e37fSmrg fi 3044b042e37fSmrg 30458c4a8e55Smrg # Deduce the name of the destination old-style object file. 30468c4a8e55Smrg case $destfile in 30478c4a8e55Smrg *.lo) 30488c4a8e55Smrg func_lo2o "$destfile" 30498c4a8e55Smrg staticdest=$func_lo2o_result 30508c4a8e55Smrg ;; 30518c4a8e55Smrg *.$objext) 30528c4a8e55Smrg staticdest="$destfile" 30538c4a8e55Smrg destfile= 30548c4a8e55Smrg ;; 30558c4a8e55Smrg *) 30568c4a8e55Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 30578c4a8e55Smrg ;; 30588c4a8e55Smrg esac 3059b042e37fSmrg 30608c4a8e55Smrg # Install the libtool object if requested. 30618c4a8e55Smrg test -n "$destfile" && \ 30628c4a8e55Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 3063b042e37fSmrg 30648c4a8e55Smrg # Install the old object if enabled. 30658c4a8e55Smrg if test "$build_old_libs" = yes; then 30668c4a8e55Smrg # Deduce the name of the old-style object file. 30678c4a8e55Smrg func_lo2o "$file" 30688c4a8e55Smrg staticobj=$func_lo2o_result 30698c4a8e55Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 3070b042e37fSmrg fi 30718c4a8e55Smrg exit $EXIT_SUCCESS 30728c4a8e55Smrg ;; 3073b042e37fSmrg 30748c4a8e55Smrg *) 30758c4a8e55Smrg # Figure out destination file name, if it wasn't already specified. 30768c4a8e55Smrg if test -n "$destname"; then 30778c4a8e55Smrg destfile="$destdir/$destname" 30788c4a8e55Smrg else 30798c4a8e55Smrg func_basename "$file" 30808c4a8e55Smrg destfile="$func_basename_result" 30818c4a8e55Smrg destfile="$destdir/$destfile" 30828c4a8e55Smrg fi 3083b042e37fSmrg 30848c4a8e55Smrg # If the file is missing, and there is a .exe on the end, strip it 30858c4a8e55Smrg # because it is most likely a libtool script we actually want to 30868c4a8e55Smrg # install 30878c4a8e55Smrg stripped_ext="" 30888c4a8e55Smrg case $file in 30898c4a8e55Smrg *.exe) 30908c4a8e55Smrg if test ! -f "$file"; then 30918c4a8e55Smrg func_stripname '' '.exe' "$file" 30928c4a8e55Smrg file=$func_stripname_result 30938c4a8e55Smrg stripped_ext=".exe" 30948c4a8e55Smrg fi 30958c4a8e55Smrg ;; 30968c4a8e55Smrg esac 30978c4a8e55Smrg 30988c4a8e55Smrg # Do a test to see if this is really a libtool program. 30998c4a8e55Smrg case $host in 31008c4a8e55Smrg *cygwin* | *mingw*) 31018c4a8e55Smrg if func_ltwrapper_executable_p "$file"; then 31028c4a8e55Smrg func_ltwrapper_scriptname "$file" 31038c4a8e55Smrg wrapper=$func_ltwrapper_scriptname_result 31048c4a8e55Smrg else 31058c4a8e55Smrg func_stripname '' '.exe' "$file" 31068c4a8e55Smrg wrapper=$func_stripname_result 31078c4a8e55Smrg fi 31088c4a8e55Smrg ;; 3109b042e37fSmrg *) 31108c4a8e55Smrg wrapper=$file 31118c4a8e55Smrg ;; 31128c4a8e55Smrg esac 31138c4a8e55Smrg if func_ltwrapper_script_p "$wrapper"; then 31148c4a8e55Smrg notinst_deplibs= 31158c4a8e55Smrg relink_command= 31168c4a8e55Smrg 31178c4a8e55Smrg func_source "$wrapper" 31188c4a8e55Smrg 31198c4a8e55Smrg # Check the variables that should have been set. 31208c4a8e55Smrg test -z "$generated_by_libtool_version" && \ 31218c4a8e55Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 31228c4a8e55Smrg 31238c4a8e55Smrg finalize=yes 31248c4a8e55Smrg for lib in $notinst_deplibs; do 31258c4a8e55Smrg # Check to see that each library is installed. 31268c4a8e55Smrg libdir= 31278c4a8e55Smrg if test -f "$lib"; then 31288c4a8e55Smrg func_source "$lib" 31298c4a8e55Smrg fi 3130706b6b52Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 31318c4a8e55Smrg if test -n "$libdir" && test ! -f "$libfile"; then 31328c4a8e55Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 31338c4a8e55Smrg finalize=no 31348c4a8e55Smrg fi 31358c4a8e55Smrg done 31368c4a8e55Smrg 31378c4a8e55Smrg relink_command= 31388c4a8e55Smrg func_source "$wrapper" 31398c4a8e55Smrg 31408c4a8e55Smrg outputname= 31418c4a8e55Smrg if test "$fast_install" = no && test -n "$relink_command"; then 31428c4a8e55Smrg $opt_dry_run || { 31438c4a8e55Smrg if test "$finalize" = yes; then 31448c4a8e55Smrg tmpdir=`func_mktempdir` 31458c4a8e55Smrg func_basename "$file$stripped_ext" 31468c4a8e55Smrg file="$func_basename_result" 31478c4a8e55Smrg outputname="$tmpdir/$file" 31488c4a8e55Smrg # Replace the output file specification. 3149706b6b52Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 31508c4a8e55Smrg 31518c4a8e55Smrg $opt_silent || { 31528c4a8e55Smrg func_quote_for_expand "$relink_command" 31538c4a8e55Smrg eval "func_echo $func_quote_for_expand_result" 31548c4a8e55Smrg } 31558c4a8e55Smrg if eval "$relink_command"; then : 31568c4a8e55Smrg else 31578c4a8e55Smrg func_error "error: relink \`$file' with the above command before installing it" 31588c4a8e55Smrg $opt_dry_run || ${RM}r "$tmpdir" 31598c4a8e55Smrg continue 31608c4a8e55Smrg fi 31618c4a8e55Smrg file="$outputname" 31628c4a8e55Smrg else 31638c4a8e55Smrg func_warning "cannot relink \`$file'" 31648c4a8e55Smrg fi 31658c4a8e55Smrg } 31668c4a8e55Smrg else 31678c4a8e55Smrg # Install the binary that we compiled earlier. 3168706b6b52Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 3169b042e37fSmrg fi 31708c4a8e55Smrg fi 31718c4a8e55Smrg 31728c4a8e55Smrg # remove .exe since cygwin /usr/bin/install will append another 31738c4a8e55Smrg # one anyway 31748c4a8e55Smrg case $install_prog,$host in 31758c4a8e55Smrg */usr/bin/install*,*cygwin*) 31768c4a8e55Smrg case $file:$destfile in 31778c4a8e55Smrg *.exe:*.exe) 31788c4a8e55Smrg # this is ok 31798c4a8e55Smrg ;; 31808c4a8e55Smrg *.exe:*) 31818c4a8e55Smrg destfile=$destfile.exe 31828c4a8e55Smrg ;; 31838c4a8e55Smrg *:*.exe) 31848c4a8e55Smrg func_stripname '' '.exe' "$destfile" 31858c4a8e55Smrg destfile=$func_stripname_result 31868c4a8e55Smrg ;; 31878c4a8e55Smrg esac 3188b042e37fSmrg ;; 3189b042e37fSmrg esac 31908c4a8e55Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 31918c4a8e55Smrg $opt_dry_run || if test -n "$outputname"; then 31928c4a8e55Smrg ${RM}r "$tmpdir" 31938c4a8e55Smrg fi 31948c4a8e55Smrg ;; 31958c4a8e55Smrg esac 31968c4a8e55Smrg done 3197b042e37fSmrg 31988c4a8e55Smrg for file in $staticlibs; do 31998c4a8e55Smrg func_basename "$file" 32008c4a8e55Smrg name="$func_basename_result" 32018c4a8e55Smrg 32028c4a8e55Smrg # Set up the ranlib parameters. 32038c4a8e55Smrg oldlib="$destdir/$name" 32048c4a8e55Smrg 32058c4a8e55Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 32068c4a8e55Smrg 32078c4a8e55Smrg if test -n "$stripme" && test -n "$old_striplib"; then 32088c4a8e55Smrg func_show_eval "$old_striplib $oldlib" 'exit $?' 32098c4a8e55Smrg fi 32108c4a8e55Smrg 32118c4a8e55Smrg # Do each command in the postinstall commands. 32128c4a8e55Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 32138c4a8e55Smrg done 32148c4a8e55Smrg 32158c4a8e55Smrg test -n "$future_libdirs" && \ 32168c4a8e55Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 32178c4a8e55Smrg 32188c4a8e55Smrg if test -n "$current_libdirs"; then 32198c4a8e55Smrg # Maybe just do a dry run. 32208c4a8e55Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 32218c4a8e55Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 32228c4a8e55Smrg else 32238c4a8e55Smrg exit $EXIT_SUCCESS 32248c4a8e55Smrg fi 32258c4a8e55Smrg} 32268c4a8e55Smrg 3227bd23fbfaSmrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 32288c4a8e55Smrg 32298c4a8e55Smrg 32308c4a8e55Smrg# func_generate_dlsyms outputname originator pic_p 32318c4a8e55Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 32328c4a8e55Smrg# a dlpreopen symbol table. 32338c4a8e55Smrgfunc_generate_dlsyms () 32348c4a8e55Smrg{ 32358c4a8e55Smrg $opt_debug 32368c4a8e55Smrg my_outputname="$1" 32378c4a8e55Smrg my_originator="$2" 32388c4a8e55Smrg my_pic_p="${3-no}" 32398c4a8e55Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 32408c4a8e55Smrg my_dlsyms= 32418c4a8e55Smrg 32428c4a8e55Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 32438c4a8e55Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 32448c4a8e55Smrg my_dlsyms="${my_outputname}S.c" 32458c4a8e55Smrg else 32468c4a8e55Smrg func_error "not configured to extract global symbols from dlpreopened files" 32478c4a8e55Smrg fi 32488c4a8e55Smrg fi 32498c4a8e55Smrg 32508c4a8e55Smrg if test -n "$my_dlsyms"; then 32518c4a8e55Smrg case $my_dlsyms in 32528c4a8e55Smrg "") ;; 32538c4a8e55Smrg *.c) 32548c4a8e55Smrg # Discover the nlist of each of the dlfiles. 32558c4a8e55Smrg nlist="$output_objdir/${my_outputname}.nm" 32568c4a8e55Smrg 32578c4a8e55Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 32588c4a8e55Smrg 32598c4a8e55Smrg # Parse the name list into a source file. 32608c4a8e55Smrg func_verbose "creating $output_objdir/$my_dlsyms" 32618c4a8e55Smrg 32628c4a8e55Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 32638c4a8e55Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 32648c4a8e55Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 32658c4a8e55Smrg 32668c4a8e55Smrg#ifdef __cplusplus 32678c4a8e55Smrgextern \"C\" { 32688c4a8e55Smrg#endif 32698c4a8e55Smrg 3270706b6b52Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 3271706b6b52Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 3272706b6b52Smrg#endif 3273706b6b52Smrg 3274bd23fbfaSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 3275bd23fbfaSmrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 3276bd23fbfaSmrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 3277bd23fbfaSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 3278bd23fbfaSmrg# define LT_DLSYM_CONST 3279bd23fbfaSmrg#elif defined(__osf__) 3280bd23fbfaSmrg/* This system does not cope well with relocations in const data. */ 3281bd23fbfaSmrg# define LT_DLSYM_CONST 3282bd23fbfaSmrg#else 3283bd23fbfaSmrg# define LT_DLSYM_CONST const 3284bd23fbfaSmrg#endif 3285bd23fbfaSmrg 32868c4a8e55Smrg/* External symbol declarations for the compiler. */\ 32878c4a8e55Smrg" 32888c4a8e55Smrg 32898c4a8e55Smrg if test "$dlself" = yes; then 32908c4a8e55Smrg func_verbose "generating symbol list for \`$output'" 32918c4a8e55Smrg 32928c4a8e55Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 32938c4a8e55Smrg 32948c4a8e55Smrg # Add our own program objects to the symbol list. 3295706b6b52Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 32968c4a8e55Smrg for progfile in $progfiles; do 3297bd23fbfaSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 3298bd23fbfaSmrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 3299bd23fbfaSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 33008c4a8e55Smrg done 33018c4a8e55Smrg 33028c4a8e55Smrg if test -n "$exclude_expsyms"; then 33038c4a8e55Smrg $opt_dry_run || { 33048c4a8e55Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 33058c4a8e55Smrg eval '$MV "$nlist"T "$nlist"' 33068c4a8e55Smrg } 3307b042e37fSmrg fi 33088c4a8e55Smrg 33098c4a8e55Smrg if test -n "$export_symbols_regex"; then 33108c4a8e55Smrg $opt_dry_run || { 33118c4a8e55Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 33128c4a8e55Smrg eval '$MV "$nlist"T "$nlist"' 33138c4a8e55Smrg } 33148c4a8e55Smrg fi 33158c4a8e55Smrg 33168c4a8e55Smrg # Prepare the list of exported symbols 33178c4a8e55Smrg if test -z "$export_symbols"; then 33188c4a8e55Smrg export_symbols="$output_objdir/$outputname.exp" 33198c4a8e55Smrg $opt_dry_run || { 33208c4a8e55Smrg $RM $export_symbols 33218c4a8e55Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 33228c4a8e55Smrg case $host in 33238c4a8e55Smrg *cygwin* | *mingw* | *cegcc* ) 33248c4a8e55Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 33258c4a8e55Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 33268c4a8e55Smrg ;; 33278c4a8e55Smrg esac 33288c4a8e55Smrg } 3329b042e37fSmrg else 33308c4a8e55Smrg $opt_dry_run || { 33318c4a8e55Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 33328c4a8e55Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 33338c4a8e55Smrg eval '$MV "$nlist"T "$nlist"' 33348c4a8e55Smrg case $host in 3335706b6b52Smrg *cygwin* | *mingw* | *cegcc* ) 33368c4a8e55Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 33378c4a8e55Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 33388c4a8e55Smrg ;; 33398c4a8e55Smrg esac 33408c4a8e55Smrg } 3341b042e37fSmrg fi 33428c4a8e55Smrg fi 3343b042e37fSmrg 33448c4a8e55Smrg for dlprefile in $dlprefiles; do 33458c4a8e55Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 33468c4a8e55Smrg func_basename "$dlprefile" 33478c4a8e55Smrg name="$func_basename_result" 3348bd23fbfaSmrg case $host in 3349bd23fbfaSmrg *cygwin* | *mingw* | *cegcc* ) 3350bd23fbfaSmrg # if an import library, we need to obtain dlname 3351bd23fbfaSmrg if func_win32_import_lib_p "$dlprefile"; then 3352bd23fbfaSmrg func_tr_sh "$dlprefile" 3353bd23fbfaSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 3354bd23fbfaSmrg dlprefile_dlbasename="" 3355bd23fbfaSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 3356bd23fbfaSmrg # Use subshell, to avoid clobbering current variable values 3357bd23fbfaSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 3358bd23fbfaSmrg if test -n "$dlprefile_dlname" ; then 3359bd23fbfaSmrg func_basename "$dlprefile_dlname" 3360bd23fbfaSmrg dlprefile_dlbasename="$func_basename_result" 3361bd23fbfaSmrg else 3362bd23fbfaSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 3363bd23fbfaSmrg $sharedlib_from_linklib_cmd "$dlprefile" 3364bd23fbfaSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 3365bd23fbfaSmrg fi 3366bd23fbfaSmrg fi 3367bd23fbfaSmrg $opt_dry_run || { 3368bd23fbfaSmrg if test -n "$dlprefile_dlbasename" ; then 3369bd23fbfaSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 3370bd23fbfaSmrg else 3371bd23fbfaSmrg func_warning "Could not compute DLL name from $name" 3372bd23fbfaSmrg eval '$ECHO ": $name " >> "$nlist"' 3373bd23fbfaSmrg fi 3374bd23fbfaSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3375bd23fbfaSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 3376bd23fbfaSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 3377bd23fbfaSmrg } 3378bd23fbfaSmrg else # not an import lib 3379bd23fbfaSmrg $opt_dry_run || { 3380bd23fbfaSmrg eval '$ECHO ": $name " >> "$nlist"' 3381bd23fbfaSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3382bd23fbfaSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3383bd23fbfaSmrg } 3384bd23fbfaSmrg fi 3385bd23fbfaSmrg ;; 3386bd23fbfaSmrg *) 3387bd23fbfaSmrg $opt_dry_run || { 3388bd23fbfaSmrg eval '$ECHO ": $name " >> "$nlist"' 3389bd23fbfaSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3390bd23fbfaSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3391bd23fbfaSmrg } 3392bd23fbfaSmrg ;; 3393bd23fbfaSmrg esac 33948c4a8e55Smrg done 33958c4a8e55Smrg 33968c4a8e55Smrg $opt_dry_run || { 33978c4a8e55Smrg # Make sure we have at least an empty file. 33988c4a8e55Smrg test -f "$nlist" || : > "$nlist" 33998c4a8e55Smrg 34008c4a8e55Smrg if test -n "$exclude_expsyms"; then 34018c4a8e55Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 34028c4a8e55Smrg $MV "$nlist"T "$nlist" 3403b042e37fSmrg fi 34048c4a8e55Smrg 34058c4a8e55Smrg # Try sorting and uniquifying the output. 34068c4a8e55Smrg if $GREP -v "^: " < "$nlist" | 34078c4a8e55Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 34088c4a8e55Smrg sort -k 3 34098c4a8e55Smrg else 34108c4a8e55Smrg sort +2 34118c4a8e55Smrg fi | 34128c4a8e55Smrg uniq > "$nlist"S; then 34138c4a8e55Smrg : 3414b042e37fSmrg else 34158c4a8e55Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 3416b042e37fSmrg fi 3417b042e37fSmrg 34188c4a8e55Smrg if test -f "$nlist"S; then 34198c4a8e55Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 3420b042e37fSmrg else 3421706b6b52Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 3422b042e37fSmrg fi 3423b042e37fSmrg 3424706b6b52Smrg echo >> "$output_objdir/$my_dlsyms" "\ 3425b042e37fSmrg 34268c4a8e55Smrg/* The mapping between symbol names and symbols. */ 34278c4a8e55Smrgtypedef struct { 34288c4a8e55Smrg const char *name; 34298c4a8e55Smrg void *address; 34308c4a8e55Smrg} lt_dlsymlist; 3431bd23fbfaSmrgextern LT_DLSYM_CONST lt_dlsymlist 34328c4a8e55Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 3433bd23fbfaSmrgLT_DLSYM_CONST lt_dlsymlist 34348c4a8e55Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 34358c4a8e55Smrg{\ 34368c4a8e55Smrg { \"$my_originator\", (void *) 0 }," 3437b042e37fSmrg 34388c4a8e55Smrg case $need_lib_prefix in 34398c4a8e55Smrg no) 34408c4a8e55Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 34418c4a8e55Smrg ;; 34428c4a8e55Smrg *) 34438c4a8e55Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 34448c4a8e55Smrg ;; 34458c4a8e55Smrg esac 3446706b6b52Smrg echo >> "$output_objdir/$my_dlsyms" "\ 34478c4a8e55Smrg {0, (void *) 0} 34488c4a8e55Smrg}; 3449b042e37fSmrg 34508c4a8e55Smrg/* This works around a problem in FreeBSD linker */ 34518c4a8e55Smrg#ifdef FREEBSD_WORKAROUND 34528c4a8e55Smrgstatic const void *lt_preloaded_setup() { 34538c4a8e55Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 34548c4a8e55Smrg} 34558c4a8e55Smrg#endif 3456b042e37fSmrg 34578c4a8e55Smrg#ifdef __cplusplus 34588c4a8e55Smrg} 34598c4a8e55Smrg#endif\ 34608c4a8e55Smrg" 34618c4a8e55Smrg } # !$opt_dry_run 3462b042e37fSmrg 34638c4a8e55Smrg pic_flag_for_symtable= 34648c4a8e55Smrg case "$compile_command " in 34658c4a8e55Smrg *" -static "*) ;; 34668c4a8e55Smrg *) 34678c4a8e55Smrg case $host in 34688c4a8e55Smrg # compiling the symbol table file with pic_flag works around 34698c4a8e55Smrg # a FreeBSD bug that causes programs to crash when -lm is 34708c4a8e55Smrg # linked before any other PIC object. But we must not use 34718c4a8e55Smrg # pic_flag when linking with -static. The problem exists in 34728c4a8e55Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 34738c4a8e55Smrg *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 34748c4a8e55Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 34758c4a8e55Smrg *-*-hpux*) 34768c4a8e55Smrg pic_flag_for_symtable=" $pic_flag" ;; 34778c4a8e55Smrg *) 34788c4a8e55Smrg if test "X$my_pic_p" != Xno; then 34798c4a8e55Smrg pic_flag_for_symtable=" $pic_flag" 34808c4a8e55Smrg fi 34818c4a8e55Smrg ;; 34828c4a8e55Smrg esac 34838c4a8e55Smrg ;; 34848c4a8e55Smrg esac 34858c4a8e55Smrg symtab_cflags= 34868c4a8e55Smrg for arg in $LTCFLAGS; do 34878c4a8e55Smrg case $arg in 34888c4a8e55Smrg -pie | -fpie | -fPIE) ;; 3489bd23fbfaSmrg *) func_append symtab_cflags " $arg" ;; 34908c4a8e55Smrg esac 34918c4a8e55Smrg done 3492b042e37fSmrg 34938c4a8e55Smrg # Now compile the dynamic symbol file. 34948c4a8e55Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 3495b042e37fSmrg 34968c4a8e55Smrg # Clean up the generated files. 34978c4a8e55Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 34988c4a8e55Smrg 34998c4a8e55Smrg # Transform the symbol file into the correct name. 35008c4a8e55Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 35018c4a8e55Smrg case $host in 35028c4a8e55Smrg *cygwin* | *mingw* | *cegcc* ) 35038c4a8e55Smrg if test -f "$output_objdir/$my_outputname.def"; then 3504706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3505706b6b52Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 35068c4a8e55Smrg else 3507706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3508706b6b52Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3509b042e37fSmrg fi 35108c4a8e55Smrg ;; 35118c4a8e55Smrg *) 3512706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3513706b6b52Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 35148c4a8e55Smrg ;; 35158c4a8e55Smrg esac 35168c4a8e55Smrg ;; 35178c4a8e55Smrg *) 35188c4a8e55Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 35198c4a8e55Smrg ;; 35208c4a8e55Smrg esac 35218c4a8e55Smrg else 35228c4a8e55Smrg # We keep going just in case the user didn't refer to 35238c4a8e55Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 35248c4a8e55Smrg # really was required. 3525b042e37fSmrg 35268c4a8e55Smrg # Nullify the symbol file. 3527706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 3528706b6b52Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 35298c4a8e55Smrg fi 35308c4a8e55Smrg} 3531b042e37fSmrg 35328c4a8e55Smrg# func_win32_libid arg 35338c4a8e55Smrg# return the library type of file 'arg' 35348c4a8e55Smrg# 35358c4a8e55Smrg# Need a lot of goo to handle *both* DLLs and import libs 35368c4a8e55Smrg# Has to be a shell function in order to 'eat' the argument 35378c4a8e55Smrg# that is supplied when $file_magic_command is called. 3538706b6b52Smrg# Despite the name, also deal with 64 bit binaries. 35398c4a8e55Smrgfunc_win32_libid () 35408c4a8e55Smrg{ 35418c4a8e55Smrg $opt_debug 35428c4a8e55Smrg win32_libid_type="unknown" 35438c4a8e55Smrg win32_fileres=`file -L $1 2>/dev/null` 35448c4a8e55Smrg case $win32_fileres in 35458c4a8e55Smrg *ar\ archive\ import\ library*) # definitely import 35468c4a8e55Smrg win32_libid_type="x86 archive import" 35478c4a8e55Smrg ;; 35488c4a8e55Smrg *ar\ archive*) # could be an import, or static 3549706b6b52Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 35508c4a8e55Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 3551706b6b52Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 3552bd23fbfaSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3553bd23fbfaSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 35548c4a8e55Smrg $SED -n -e ' 35558c4a8e55Smrg 1,100{ 35568c4a8e55Smrg / I /{ 35578c4a8e55Smrg s,.*,import, 35588c4a8e55Smrg p 35598c4a8e55Smrg q 35608c4a8e55Smrg } 35618c4a8e55Smrg }'` 35628c4a8e55Smrg case $win32_nmres in 35638c4a8e55Smrg import*) win32_libid_type="x86 archive import";; 35648c4a8e55Smrg *) win32_libid_type="x86 archive static";; 35658c4a8e55Smrg esac 35668c4a8e55Smrg fi 35678c4a8e55Smrg ;; 35688c4a8e55Smrg *DLL*) 35698c4a8e55Smrg win32_libid_type="x86 DLL" 35708c4a8e55Smrg ;; 35718c4a8e55Smrg *executable*) # but shell scripts are "executable" too... 35728c4a8e55Smrg case $win32_fileres in 35738c4a8e55Smrg *MS\ Windows\ PE\ Intel*) 35748c4a8e55Smrg win32_libid_type="x86 DLL" 35758c4a8e55Smrg ;; 35768c4a8e55Smrg esac 35778c4a8e55Smrg ;; 35788c4a8e55Smrg esac 35798c4a8e55Smrg $ECHO "$win32_libid_type" 35808c4a8e55Smrg} 3581b042e37fSmrg 3582bd23fbfaSmrg# func_cygming_dll_for_implib ARG 3583bd23fbfaSmrg# 3584bd23fbfaSmrg# Platform-specific function to extract the 3585bd23fbfaSmrg# name of the DLL associated with the specified 3586bd23fbfaSmrg# import library ARG. 3587bd23fbfaSmrg# Invoked by eval'ing the libtool variable 3588bd23fbfaSmrg# $sharedlib_from_linklib_cmd 3589bd23fbfaSmrg# Result is available in the variable 3590bd23fbfaSmrg# $sharedlib_from_linklib_result 3591bd23fbfaSmrgfunc_cygming_dll_for_implib () 3592bd23fbfaSmrg{ 3593bd23fbfaSmrg $opt_debug 3594bd23fbfaSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 3595bd23fbfaSmrg} 3596bd23fbfaSmrg 3597bd23fbfaSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 3598bd23fbfaSmrg# 3599bd23fbfaSmrg# The is the core of a fallback implementation of a 3600bd23fbfaSmrg# platform-specific function to extract the name of the 3601bd23fbfaSmrg# DLL associated with the specified import library LIBNAME. 3602bd23fbfaSmrg# 3603bd23fbfaSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 3604bd23fbfaSmrg# on the platform and compiler that created the implib. 3605bd23fbfaSmrg# 3606bd23fbfaSmrg# Echos the name of the DLL associated with the 3607bd23fbfaSmrg# specified import library. 3608bd23fbfaSmrgfunc_cygming_dll_for_implib_fallback_core () 3609bd23fbfaSmrg{ 3610bd23fbfaSmrg $opt_debug 3611bd23fbfaSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 3612bd23fbfaSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 3613bd23fbfaSmrg $SED '/^Contents of section '"$match_literal"':/{ 3614bd23fbfaSmrg # Place marker at beginning of archive member dllname section 3615bd23fbfaSmrg s/.*/====MARK====/ 3616bd23fbfaSmrg p 3617bd23fbfaSmrg d 3618bd23fbfaSmrg } 3619bd23fbfaSmrg # These lines can sometimes be longer than 43 characters, but 3620bd23fbfaSmrg # are always uninteresting 3621bd23fbfaSmrg /:[ ]*file format pe[i]\{,1\}-/d 3622bd23fbfaSmrg /^In archive [^:]*:/d 3623bd23fbfaSmrg # Ensure marker is printed 3624bd23fbfaSmrg /^====MARK====/p 3625bd23fbfaSmrg # Remove all lines with less than 43 characters 3626bd23fbfaSmrg /^.\{43\}/!d 3627bd23fbfaSmrg # From remaining lines, remove first 43 characters 3628bd23fbfaSmrg s/^.\{43\}//' | 3629bd23fbfaSmrg $SED -n ' 3630bd23fbfaSmrg # Join marker and all lines until next marker into a single line 3631bd23fbfaSmrg /^====MARK====/ b para 3632bd23fbfaSmrg H 3633bd23fbfaSmrg $ b para 3634bd23fbfaSmrg b 3635bd23fbfaSmrg :para 3636bd23fbfaSmrg x 3637bd23fbfaSmrg s/\n//g 3638bd23fbfaSmrg # Remove the marker 3639bd23fbfaSmrg s/^====MARK====// 3640bd23fbfaSmrg # Remove trailing dots and whitespace 3641bd23fbfaSmrg s/[\. \t]*$// 3642bd23fbfaSmrg # Print 3643bd23fbfaSmrg /./p' | 3644bd23fbfaSmrg # we now have a list, one entry per line, of the stringified 3645bd23fbfaSmrg # contents of the appropriate section of all members of the 3646bd23fbfaSmrg # archive which possess that section. Heuristic: eliminate 3647bd23fbfaSmrg # all those which have a first or second character that is 3648bd23fbfaSmrg # a '.' (that is, objdump's representation of an unprintable 3649bd23fbfaSmrg # character.) This should work for all archives with less than 3650bd23fbfaSmrg # 0x302f exports -- but will fail for DLLs whose name actually 3651bd23fbfaSmrg # begins with a literal '.' or a single character followed by 3652bd23fbfaSmrg # a '.'. 3653bd23fbfaSmrg # 3654bd23fbfaSmrg # Of those that remain, print the first one. 3655bd23fbfaSmrg $SED -e '/^\./d;/^.\./d;q' 3656bd23fbfaSmrg} 3657bd23fbfaSmrg 3658bd23fbfaSmrg# func_cygming_gnu_implib_p ARG 3659bd23fbfaSmrg# This predicate returns with zero status (TRUE) if 3660bd23fbfaSmrg# ARG is a GNU/binutils-style import library. Returns 3661bd23fbfaSmrg# with nonzero status (FALSE) otherwise. 3662bd23fbfaSmrgfunc_cygming_gnu_implib_p () 3663bd23fbfaSmrg{ 3664bd23fbfaSmrg $opt_debug 3665bd23fbfaSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3666bd23fbfaSmrg 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)$'` 3667bd23fbfaSmrg test -n "$func_cygming_gnu_implib_tmp" 3668bd23fbfaSmrg} 3669bd23fbfaSmrg 3670bd23fbfaSmrg# func_cygming_ms_implib_p ARG 3671bd23fbfaSmrg# This predicate returns with zero status (TRUE) if 3672bd23fbfaSmrg# ARG is an MS-style import library. Returns 3673bd23fbfaSmrg# with nonzero status (FALSE) otherwise. 3674bd23fbfaSmrgfunc_cygming_ms_implib_p () 3675bd23fbfaSmrg{ 3676bd23fbfaSmrg $opt_debug 3677bd23fbfaSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3678bd23fbfaSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 3679bd23fbfaSmrg test -n "$func_cygming_ms_implib_tmp" 3680bd23fbfaSmrg} 3681bd23fbfaSmrg 3682bd23fbfaSmrg# func_cygming_dll_for_implib_fallback ARG 3683bd23fbfaSmrg# Platform-specific function to extract the 3684bd23fbfaSmrg# name of the DLL associated with the specified 3685bd23fbfaSmrg# import library ARG. 3686bd23fbfaSmrg# 3687bd23fbfaSmrg# This fallback implementation is for use when $DLLTOOL 3688bd23fbfaSmrg# does not support the --identify-strict option. 3689bd23fbfaSmrg# Invoked by eval'ing the libtool variable 3690bd23fbfaSmrg# $sharedlib_from_linklib_cmd 3691bd23fbfaSmrg# Result is available in the variable 3692bd23fbfaSmrg# $sharedlib_from_linklib_result 3693bd23fbfaSmrgfunc_cygming_dll_for_implib_fallback () 3694bd23fbfaSmrg{ 3695bd23fbfaSmrg $opt_debug 3696bd23fbfaSmrg if func_cygming_gnu_implib_p "$1" ; then 3697bd23fbfaSmrg # binutils import library 3698bd23fbfaSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 3699bd23fbfaSmrg elif func_cygming_ms_implib_p "$1" ; then 3700bd23fbfaSmrg # ms-generated import library 3701bd23fbfaSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 3702bd23fbfaSmrg else 3703bd23fbfaSmrg # unknown 3704bd23fbfaSmrg sharedlib_from_linklib_result="" 3705bd23fbfaSmrg fi 3706bd23fbfaSmrg} 3707b042e37fSmrg 3708b042e37fSmrg 37098c4a8e55Smrg# func_extract_an_archive dir oldlib 37108c4a8e55Smrgfunc_extract_an_archive () 37118c4a8e55Smrg{ 37128c4a8e55Smrg $opt_debug 37138c4a8e55Smrg f_ex_an_ar_dir="$1"; shift 37148c4a8e55Smrg f_ex_an_ar_oldlib="$1" 3715706b6b52Smrg if test "$lock_old_archive_extraction" = yes; then 3716706b6b52Smrg lockfile=$f_ex_an_ar_oldlib.lock 3717706b6b52Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3718706b6b52Smrg func_echo "Waiting for $lockfile to be removed" 3719706b6b52Smrg sleep 2 3720706b6b52Smrg done 3721706b6b52Smrg fi 3722706b6b52Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 3723706b6b52Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 3724706b6b52Smrg if test "$lock_old_archive_extraction" = yes; then 3725706b6b52Smrg $opt_dry_run || rm -f "$lockfile" 3726706b6b52Smrg fi 37278c4a8e55Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 37288c4a8e55Smrg : 37298c4a8e55Smrg else 37308c4a8e55Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 37318c4a8e55Smrg fi 37328c4a8e55Smrg} 3733b042e37fSmrg 3734b042e37fSmrg 37358c4a8e55Smrg# func_extract_archives gentop oldlib ... 37368c4a8e55Smrgfunc_extract_archives () 37378c4a8e55Smrg{ 37388c4a8e55Smrg $opt_debug 37398c4a8e55Smrg my_gentop="$1"; shift 37408c4a8e55Smrg my_oldlibs=${1+"$@"} 37418c4a8e55Smrg my_oldobjs="" 37428c4a8e55Smrg my_xlib="" 37438c4a8e55Smrg my_xabs="" 37448c4a8e55Smrg my_xdir="" 3745b042e37fSmrg 37468c4a8e55Smrg for my_xlib in $my_oldlibs; do 37478c4a8e55Smrg # Extract the objects. 37488c4a8e55Smrg case $my_xlib in 37498c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 37508c4a8e55Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 37518c4a8e55Smrg esac 37528c4a8e55Smrg func_basename "$my_xlib" 37538c4a8e55Smrg my_xlib="$func_basename_result" 37548c4a8e55Smrg my_xlib_u=$my_xlib 37558c4a8e55Smrg while :; do 37568c4a8e55Smrg case " $extracted_archives " in 37578c4a8e55Smrg *" $my_xlib_u "*) 37588c4a8e55Smrg func_arith $extracted_serial + 1 37598c4a8e55Smrg extracted_serial=$func_arith_result 37608c4a8e55Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 37618c4a8e55Smrg *) break ;; 37628c4a8e55Smrg esac 37638c4a8e55Smrg done 37648c4a8e55Smrg extracted_archives="$extracted_archives $my_xlib_u" 37658c4a8e55Smrg my_xdir="$my_gentop/$my_xlib_u" 3766b042e37fSmrg 37678c4a8e55Smrg func_mkdir_p "$my_xdir" 3768b042e37fSmrg 37698c4a8e55Smrg case $host in 37708c4a8e55Smrg *-darwin*) 37718c4a8e55Smrg func_verbose "Extracting $my_xabs" 37728c4a8e55Smrg # Do not bother doing anything if just a dry run 37738c4a8e55Smrg $opt_dry_run || { 37748c4a8e55Smrg darwin_orig_dir=`pwd` 37758c4a8e55Smrg cd $my_xdir || exit $? 37768c4a8e55Smrg darwin_archive=$my_xabs 37778c4a8e55Smrg darwin_curdir=`pwd` 37788c4a8e55Smrg darwin_base_archive=`basename "$darwin_archive"` 37798c4a8e55Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 37808c4a8e55Smrg if test -n "$darwin_arches"; then 37818c4a8e55Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 37828c4a8e55Smrg darwin_arch= 37838c4a8e55Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 37848c4a8e55Smrg for darwin_arch in $darwin_arches ; do 37858c4a8e55Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 37868c4a8e55Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 37878c4a8e55Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 37888c4a8e55Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 37898c4a8e55Smrg cd "$darwin_curdir" 37908c4a8e55Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 37918c4a8e55Smrg done # $darwin_arches 37928c4a8e55Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 37938c4a8e55Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 37948c4a8e55Smrg darwin_file= 37958c4a8e55Smrg darwin_files= 37968c4a8e55Smrg for darwin_file in $darwin_filelist; do 3797706b6b52Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 37988c4a8e55Smrg $LIPO -create -output "$darwin_file" $darwin_files 37998c4a8e55Smrg done # $darwin_filelist 38008c4a8e55Smrg $RM -rf unfat-$$ 38018c4a8e55Smrg cd "$darwin_orig_dir" 3802b042e37fSmrg else 38038c4a8e55Smrg cd $darwin_orig_dir 38048c4a8e55Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 38058c4a8e55Smrg fi # $darwin_arches 38068c4a8e55Smrg } # !$opt_dry_run 38078c4a8e55Smrg ;; 38088c4a8e55Smrg *) 38098c4a8e55Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 38108c4a8e55Smrg ;; 38118c4a8e55Smrg esac 3812706b6b52Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 38138c4a8e55Smrg done 3814b042e37fSmrg 38158c4a8e55Smrg func_extract_archives_result="$my_oldobjs" 38168c4a8e55Smrg} 3817b042e37fSmrg 3818b042e37fSmrg 3819706b6b52Smrg# func_emit_wrapper [arg=no] 3820706b6b52Smrg# 3821706b6b52Smrg# Emit a libtool wrapper script on stdout. 3822706b6b52Smrg# Don't directly open a file because we may want to 3823706b6b52Smrg# incorporate the script contents within a cygwin/mingw 3824706b6b52Smrg# wrapper executable. Must ONLY be called from within 3825706b6b52Smrg# func_mode_link because it depends on a number of variables 3826706b6b52Smrg# set therein. 38278c4a8e55Smrg# 3828706b6b52Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 3829706b6b52Smrg# variable will take. If 'yes', then the emitted script 3830706b6b52Smrg# will assume that the directory in which it is stored is 3831706b6b52Smrg# the $objdir directory. This is a cygwin/mingw-specific 3832706b6b52Smrg# behavior. 3833706b6b52Smrgfunc_emit_wrapper () 38348c4a8e55Smrg{ 3835706b6b52Smrg func_emit_wrapper_arg1=${1-no} 3836b042e37fSmrg 38378c4a8e55Smrg $ECHO "\ 38388c4a8e55Smrg#! $SHELL 3839b042e37fSmrg 38408c4a8e55Smrg# $output - temporary wrapper script for $objdir/$outputname 38418c4a8e55Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 38428c4a8e55Smrg# 38438c4a8e55Smrg# The $output program cannot be directly executed until all the libtool 38448c4a8e55Smrg# libraries that it depends on are installed. 38458c4a8e55Smrg# 38468c4a8e55Smrg# This wrapper script should never be moved out of the build directory. 38478c4a8e55Smrg# If it is, it will not operate correctly. 3848b042e37fSmrg 38498c4a8e55Smrg# Sed substitution that helps us do robust quoting. It backslashifies 38508c4a8e55Smrg# metacharacters that are still active within double-quoted strings. 38518c4a8e55Smrgsed_quote_subst='$sed_quote_subst' 3852b042e37fSmrg 38538c4a8e55Smrg# Be Bourne compatible 38548c4a8e55Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 38558c4a8e55Smrg emulate sh 38568c4a8e55Smrg NULLCMD=: 38578c4a8e55Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 38588c4a8e55Smrg # is contrary to our usage. Disable this feature. 38598c4a8e55Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 38608c4a8e55Smrg setopt NO_GLOB_SUBST 38618c4a8e55Smrgelse 38628c4a8e55Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 38638c4a8e55Smrgfi 38648c4a8e55SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 38658c4a8e55SmrgDUALCASE=1; export DUALCASE # for MKS sh 3866b042e37fSmrg 38678c4a8e55Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 38688c4a8e55Smrg# if CDPATH is set. 38698c4a8e55Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 3870b042e37fSmrg 38718c4a8e55Smrgrelink_command=\"$relink_command\" 3872b042e37fSmrg 38738c4a8e55Smrg# This environment variable determines our operation mode. 38748c4a8e55Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 38758c4a8e55Smrg # install mode needs the following variables: 38768c4a8e55Smrg generated_by_libtool_version='$macro_version' 38778c4a8e55Smrg notinst_deplibs='$notinst_deplibs' 38788c4a8e55Smrgelse 38798c4a8e55Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 38808c4a8e55Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 3881706b6b52Smrg file=\"\$0\"" 3882706b6b52Smrg 3883706b6b52Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 3884706b6b52Smrg $ECHO "\ 3885706b6b52Smrg 3886706b6b52Smrg# A function that is used when there is no print builtin or printf. 3887706b6b52Smrgfunc_fallback_echo () 3888706b6b52Smrg{ 3889706b6b52Smrg eval 'cat <<_LTECHO_EOF 3890706b6b52Smrg\$1 3891706b6b52Smrg_LTECHO_EOF' 3892706b6b52Smrg} 3893706b6b52Smrg ECHO=\"$qECHO\" 3894706b6b52Smrg fi 3895706b6b52Smrg 3896706b6b52Smrg# Very basic option parsing. These options are (a) specific to 3897706b6b52Smrg# the libtool wrapper, (b) are identical between the wrapper 3898706b6b52Smrg# /script/ and the wrapper /executable/ which is used only on 3899706b6b52Smrg# windows platforms, and (c) all begin with the string "--lt-" 3900706b6b52Smrg# (application programs are unlikely to have options which match 3901706b6b52Smrg# this pattern). 3902706b6b52Smrg# 3903706b6b52Smrg# There are only two supported options: --lt-debug and 3904706b6b52Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 3905706b6b52Smrg# 3906706b6b52Smrg# The first argument to this parsing function should be the 3907706b6b52Smrg# script's $0 value, followed by "$@". 3908706b6b52Smrglt_option_debug= 3909706b6b52Smrgfunc_parse_lt_options () 3910706b6b52Smrg{ 3911706b6b52Smrg lt_script_arg0=\$0 3912706b6b52Smrg shift 3913706b6b52Smrg for lt_opt 3914706b6b52Smrg do 3915706b6b52Smrg case \"\$lt_opt\" in 3916706b6b52Smrg --lt-debug) lt_option_debug=1 ;; 3917706b6b52Smrg --lt-dump-script) 3918706b6b52Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 3919706b6b52Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 3920706b6b52Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 3921706b6b52Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 3922706b6b52Smrg exit 0 3923706b6b52Smrg ;; 3924706b6b52Smrg --lt-*) 3925706b6b52Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 3926706b6b52Smrg exit 1 3927706b6b52Smrg ;; 3928706b6b52Smrg esac 3929706b6b52Smrg done 3930706b6b52Smrg 3931706b6b52Smrg # Print the debug banner immediately: 3932706b6b52Smrg if test -n \"\$lt_option_debug\"; then 3933706b6b52Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 3934706b6b52Smrg fi 3935706b6b52Smrg} 3936706b6b52Smrg 3937706b6b52Smrg# Used when --lt-debug. Prints its arguments to stdout 3938706b6b52Smrg# (redirection is the responsibility of the caller) 3939706b6b52Smrgfunc_lt_dump_args () 3940706b6b52Smrg{ 3941706b6b52Smrg lt_dump_args_N=1; 3942706b6b52Smrg for lt_arg 3943706b6b52Smrg do 3944706b6b52Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 3945706b6b52Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 3946706b6b52Smrg done 3947706b6b52Smrg} 3948706b6b52Smrg 3949706b6b52Smrg# Core function for launching the target application 3950706b6b52Smrgfunc_exec_program_core () 3951706b6b52Smrg{ 39528c4a8e55Smrg" 3953706b6b52Smrg case $host in 3954706b6b52Smrg # Backslashes separate directories on plain windows 3955706b6b52Smrg *-*-mingw | *-*-os2* | *-cegcc*) 3956706b6b52Smrg $ECHO "\ 3957706b6b52Smrg if test -n \"\$lt_option_debug\"; then 3958706b6b52Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 3959706b6b52Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 3960706b6b52Smrg fi 3961706b6b52Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 3962706b6b52Smrg" 3963706b6b52Smrg ;; 3964706b6b52Smrg 3965706b6b52Smrg *) 3966706b6b52Smrg $ECHO "\ 3967706b6b52Smrg if test -n \"\$lt_option_debug\"; then 3968706b6b52Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 3969706b6b52Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 3970706b6b52Smrg fi 3971706b6b52Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 3972706b6b52Smrg" 3973706b6b52Smrg ;; 3974706b6b52Smrg esac 3975706b6b52Smrg $ECHO "\ 3976706b6b52Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 3977706b6b52Smrg exit 1 3978706b6b52Smrg} 3979706b6b52Smrg 3980706b6b52Smrg# A function to encapsulate launching the target application 3981706b6b52Smrg# Strips options in the --lt-* namespace from \$@ and 3982706b6b52Smrg# launches target application with the remaining arguments. 3983706b6b52Smrgfunc_exec_program () 3984706b6b52Smrg{ 3985706b6b52Smrg for lt_wr_arg 3986706b6b52Smrg do 3987706b6b52Smrg case \$lt_wr_arg in 3988706b6b52Smrg --lt-*) ;; 3989706b6b52Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 3990706b6b52Smrg esac 3991706b6b52Smrg shift 3992706b6b52Smrg done 3993706b6b52Smrg func_exec_program_core \${1+\"\$@\"} 3994706b6b52Smrg} 3995706b6b52Smrg 3996706b6b52Smrg # Parse options 3997706b6b52Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 3998b042e37fSmrg 39998c4a8e55Smrg # Find the directory that this script lives in. 4000706b6b52Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 40018c4a8e55Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 4002b042e37fSmrg 40038c4a8e55Smrg # Follow symbolic links until we get to the real thisdir. 4004706b6b52Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 40058c4a8e55Smrg while test -n \"\$file\"; do 4006706b6b52Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 40078c4a8e55Smrg 40088c4a8e55Smrg # If there was a directory component, then change thisdir. 40098c4a8e55Smrg if test \"x\$destdir\" != \"x\$file\"; then 40108c4a8e55Smrg case \"\$destdir\" in 40118c4a8e55Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 40128c4a8e55Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 4013b042e37fSmrg esac 40148c4a8e55Smrg fi 4015b042e37fSmrg 4016706b6b52Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 4017706b6b52Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 40188c4a8e55Smrg done 4019b042e37fSmrg 40208c4a8e55Smrg # Usually 'no', except on cygwin/mingw when embedded into 40218c4a8e55Smrg # the cwrapper. 4022706b6b52Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 40238c4a8e55Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 40248c4a8e55Smrg # special case for '.' 40258c4a8e55Smrg if test \"\$thisdir\" = \".\"; then 40268c4a8e55Smrg thisdir=\`pwd\` 40278c4a8e55Smrg fi 40288c4a8e55Smrg # remove .libs from thisdir 40298c4a8e55Smrg case \"\$thisdir\" in 4030706b6b52Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 40318c4a8e55Smrg $objdir ) thisdir=. ;; 40328c4a8e55Smrg esac 40338c4a8e55Smrg fi 40348c4a8e55Smrg 40358c4a8e55Smrg # Try to get the absolute directory name. 40368c4a8e55Smrg absdir=\`cd \"\$thisdir\" && pwd\` 40378c4a8e55Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 40388c4a8e55Smrg" 40398c4a8e55Smrg 40408c4a8e55Smrg if test "$fast_install" = yes; then 40418c4a8e55Smrg $ECHO "\ 40428c4a8e55Smrg program=lt-'$outputname'$exeext 40438c4a8e55Smrg progdir=\"\$thisdir/$objdir\" 40448c4a8e55Smrg 40458c4a8e55Smrg if test ! -f \"\$progdir/\$program\" || 40468c4a8e55Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 40478c4a8e55Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 40488c4a8e55Smrg 40498c4a8e55Smrg file=\"\$\$-\$program\" 40508c4a8e55Smrg 40518c4a8e55Smrg if test ! -d \"\$progdir\"; then 40528c4a8e55Smrg $MKDIR \"\$progdir\" 40538c4a8e55Smrg else 40548c4a8e55Smrg $RM \"\$progdir/\$file\" 40558c4a8e55Smrg fi" 40568c4a8e55Smrg 40578c4a8e55Smrg $ECHO "\ 40588c4a8e55Smrg 40598c4a8e55Smrg # relink executable if necessary 40608c4a8e55Smrg if test -n \"\$relink_command\"; then 40618c4a8e55Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 40628c4a8e55Smrg else 40638c4a8e55Smrg $ECHO \"\$relink_command_output\" >&2 40648c4a8e55Smrg $RM \"\$progdir/\$file\" 40658c4a8e55Smrg exit 1 4066b042e37fSmrg fi 40678c4a8e55Smrg fi 4068b042e37fSmrg 40698c4a8e55Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 40708c4a8e55Smrg { $RM \"\$progdir/\$program\"; 40718c4a8e55Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 40728c4a8e55Smrg $RM \"\$progdir/\$file\" 40738c4a8e55Smrg fi" 40748c4a8e55Smrg else 40758c4a8e55Smrg $ECHO "\ 40768c4a8e55Smrg program='$outputname' 40778c4a8e55Smrg progdir=\"\$thisdir/$objdir\" 40788c4a8e55Smrg" 4079b042e37fSmrg fi 4080b042e37fSmrg 40818c4a8e55Smrg $ECHO "\ 4082b042e37fSmrg 40838c4a8e55Smrg if test -f \"\$progdir/\$program\"; then" 4084b042e37fSmrg 4085bd23fbfaSmrg # fixup the dll searchpath if we need to. 4086bd23fbfaSmrg # 4087bd23fbfaSmrg # Fix the DLL searchpath if we need to. Do this before prepending 4088bd23fbfaSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 4089bd23fbfaSmrg # libraries must come first. 4090bd23fbfaSmrg if test -n "$dllsearchpath"; then 4091bd23fbfaSmrg $ECHO "\ 4092bd23fbfaSmrg # Add the dll search path components to the executable PATH 4093bd23fbfaSmrg PATH=$dllsearchpath:\$PATH 4094bd23fbfaSmrg" 4095bd23fbfaSmrg fi 4096bd23fbfaSmrg 40978c4a8e55Smrg # Export our shlibpath_var if we have one. 40988c4a8e55Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 40998c4a8e55Smrg $ECHO "\ 41008c4a8e55Smrg # Add our own library path to $shlibpath_var 41018c4a8e55Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 41028c4a8e55Smrg 41038c4a8e55Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 41048c4a8e55Smrg # The second colon is a workaround for a bug in BeOS R4 sed 4105706b6b52Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 4106b042e37fSmrg 41078c4a8e55Smrg export $shlibpath_var 41088c4a8e55Smrg" 4109b042e37fSmrg fi 4110b042e37fSmrg 41118c4a8e55Smrg $ECHO "\ 41128c4a8e55Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 41138c4a8e55Smrg # Run the actual program with our arguments. 4114706b6b52Smrg func_exec_program \${1+\"\$@\"} 41158c4a8e55Smrg fi 41168c4a8e55Smrg else 41178c4a8e55Smrg # The program doesn't exist. 41188c4a8e55Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 41198c4a8e55Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 4120706b6b52Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 41218c4a8e55Smrg exit 1 41228c4a8e55Smrg fi 41238c4a8e55Smrgfi\ 41248c4a8e55Smrg" 41258c4a8e55Smrg} 4126b042e37fSmrg 4127b042e37fSmrg 41288c4a8e55Smrg# func_emit_cwrapperexe_src 41298c4a8e55Smrg# emit the source code for a wrapper executable on stdout 41308c4a8e55Smrg# Must ONLY be called from within func_mode_link because 41318c4a8e55Smrg# it depends on a number of variable set therein. 41328c4a8e55Smrgfunc_emit_cwrapperexe_src () 41338c4a8e55Smrg{ 41348c4a8e55Smrg cat <<EOF 4135b042e37fSmrg 41368c4a8e55Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 41378c4a8e55Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4138b042e37fSmrg 41398c4a8e55Smrg The $output program cannot be directly executed until all the libtool 41408c4a8e55Smrg libraries that it depends on are installed. 4141b042e37fSmrg 41428c4a8e55Smrg This wrapper executable should never be moved out of the build directory. 41438c4a8e55Smrg If it is, it will not operate correctly. 41448c4a8e55Smrg*/ 41458c4a8e55SmrgEOF 41468c4a8e55Smrg cat <<"EOF" 4147706b6b52Smrg#ifdef _MSC_VER 4148706b6b52Smrg# define _CRT_SECURE_NO_DEPRECATE 1 4149706b6b52Smrg#endif 41508c4a8e55Smrg#include <stdio.h> 41518c4a8e55Smrg#include <stdlib.h> 41528c4a8e55Smrg#ifdef _MSC_VER 41538c4a8e55Smrg# include <direct.h> 41548c4a8e55Smrg# include <process.h> 41558c4a8e55Smrg# include <io.h> 41568c4a8e55Smrg#else 41578c4a8e55Smrg# include <unistd.h> 41588c4a8e55Smrg# include <stdint.h> 41598c4a8e55Smrg# ifdef __CYGWIN__ 41608c4a8e55Smrg# include <io.h> 41618c4a8e55Smrg# endif 41628c4a8e55Smrg#endif 41638c4a8e55Smrg#include <malloc.h> 41648c4a8e55Smrg#include <stdarg.h> 41658c4a8e55Smrg#include <assert.h> 41668c4a8e55Smrg#include <string.h> 41678c4a8e55Smrg#include <ctype.h> 41688c4a8e55Smrg#include <errno.h> 41698c4a8e55Smrg#include <fcntl.h> 41708c4a8e55Smrg#include <sys/stat.h> 4171b042e37fSmrg 4172706b6b52Smrg/* declarations of non-ANSI functions */ 4173706b6b52Smrg#if defined(__MINGW32__) 4174706b6b52Smrg# ifdef __STRICT_ANSI__ 4175706b6b52Smrgint _putenv (const char *); 4176706b6b52Smrg# endif 4177706b6b52Smrg#elif defined(__CYGWIN__) 4178706b6b52Smrg# ifdef __STRICT_ANSI__ 4179706b6b52Smrgchar *realpath (const char *, char *); 4180706b6b52Smrgint putenv (char *); 4181706b6b52Smrgint setenv (const char *, const char *, int); 4182706b6b52Smrg# endif 4183706b6b52Smrg/* #elif defined (other platforms) ... */ 4184706b6b52Smrg#endif 4185706b6b52Smrg 4186706b6b52Smrg/* portability defines, excluding path handling macros */ 4187706b6b52Smrg#if defined(_MSC_VER) 4188706b6b52Smrg# define setmode _setmode 4189706b6b52Smrg# define stat _stat 4190706b6b52Smrg# define chmod _chmod 4191706b6b52Smrg# define getcwd _getcwd 4192706b6b52Smrg# define putenv _putenv 4193706b6b52Smrg# define S_IXUSR _S_IEXEC 4194706b6b52Smrg# ifndef _INTPTR_T_DEFINED 4195706b6b52Smrg# define _INTPTR_T_DEFINED 4196706b6b52Smrg# define intptr_t int 4197706b6b52Smrg# endif 4198706b6b52Smrg#elif defined(__MINGW32__) 4199706b6b52Smrg# define setmode _setmode 4200706b6b52Smrg# define stat _stat 4201706b6b52Smrg# define chmod _chmod 4202706b6b52Smrg# define getcwd _getcwd 4203706b6b52Smrg# define putenv _putenv 4204706b6b52Smrg#elif defined(__CYGWIN__) 4205706b6b52Smrg# define HAVE_SETENV 4206706b6b52Smrg# define FOPEN_WB "wb" 4207706b6b52Smrg/* #elif defined (other platforms) ... */ 4208706b6b52Smrg#endif 4209706b6b52Smrg 42108c4a8e55Smrg#if defined(PATH_MAX) 42118c4a8e55Smrg# define LT_PATHMAX PATH_MAX 42128c4a8e55Smrg#elif defined(MAXPATHLEN) 42138c4a8e55Smrg# define LT_PATHMAX MAXPATHLEN 42148c4a8e55Smrg#else 42158c4a8e55Smrg# define LT_PATHMAX 1024 42168c4a8e55Smrg#endif 4217b042e37fSmrg 42188c4a8e55Smrg#ifndef S_IXOTH 42198c4a8e55Smrg# define S_IXOTH 0 42208c4a8e55Smrg#endif 42218c4a8e55Smrg#ifndef S_IXGRP 42228c4a8e55Smrg# define S_IXGRP 0 42238c4a8e55Smrg#endif 4224b042e37fSmrg 4225706b6b52Smrg/* path handling portability macros */ 42268c4a8e55Smrg#ifndef DIR_SEPARATOR 42278c4a8e55Smrg# define DIR_SEPARATOR '/' 42288c4a8e55Smrg# define PATH_SEPARATOR ':' 42298c4a8e55Smrg#endif 4230b042e37fSmrg 42318c4a8e55Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 42328c4a8e55Smrg defined (__OS2__) 42338c4a8e55Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 42348c4a8e55Smrg# define FOPEN_WB "wb" 42358c4a8e55Smrg# ifndef DIR_SEPARATOR_2 42368c4a8e55Smrg# define DIR_SEPARATOR_2 '\\' 42378c4a8e55Smrg# endif 42388c4a8e55Smrg# ifndef PATH_SEPARATOR_2 42398c4a8e55Smrg# define PATH_SEPARATOR_2 ';' 42408c4a8e55Smrg# endif 42418c4a8e55Smrg#endif 4242b042e37fSmrg 42438c4a8e55Smrg#ifndef DIR_SEPARATOR_2 42448c4a8e55Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 42458c4a8e55Smrg#else /* DIR_SEPARATOR_2 */ 42468c4a8e55Smrg# define IS_DIR_SEPARATOR(ch) \ 42478c4a8e55Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 42488c4a8e55Smrg#endif /* DIR_SEPARATOR_2 */ 4249b042e37fSmrg 42508c4a8e55Smrg#ifndef PATH_SEPARATOR_2 42518c4a8e55Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 42528c4a8e55Smrg#else /* PATH_SEPARATOR_2 */ 42538c4a8e55Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 42548c4a8e55Smrg#endif /* PATH_SEPARATOR_2 */ 4255b042e37fSmrg 42568c4a8e55Smrg#ifndef FOPEN_WB 42578c4a8e55Smrg# define FOPEN_WB "w" 42588c4a8e55Smrg#endif 42598c4a8e55Smrg#ifndef _O_BINARY 42608c4a8e55Smrg# define _O_BINARY 0 42618c4a8e55Smrg#endif 4262b042e37fSmrg 42638c4a8e55Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 42648c4a8e55Smrg#define XFREE(stale) do { \ 42658c4a8e55Smrg if (stale) { free ((void *) stale); stale = 0; } \ 42668c4a8e55Smrg} while (0) 4267b042e37fSmrg 4268706b6b52Smrg#if defined(LT_DEBUGWRAPPER) 4269706b6b52Smrgstatic int lt_debug = 1; 42708c4a8e55Smrg#else 4271706b6b52Smrgstatic int lt_debug = 0; 42728c4a8e55Smrg#endif 4273b042e37fSmrg 4274706b6b52Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 4275b042e37fSmrg 42768c4a8e55Smrgvoid *xmalloc (size_t num); 42778c4a8e55Smrgchar *xstrdup (const char *string); 42788c4a8e55Smrgconst char *base_name (const char *name); 42798c4a8e55Smrgchar *find_executable (const char *wrapper); 42808c4a8e55Smrgchar *chase_symlinks (const char *pathspec); 42818c4a8e55Smrgint make_executable (const char *path); 42828c4a8e55Smrgint check_executable (const char *path); 42838c4a8e55Smrgchar *strendzap (char *str, const char *pat); 4284706b6b52Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 4285706b6b52Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 4286706b6b52Smrgstatic const char *nonnull (const char *s); 4287706b6b52Smrgstatic const char *nonempty (const char *s); 42888c4a8e55Smrgvoid lt_setenv (const char *name, const char *value); 42898c4a8e55Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 42908c4a8e55Smrgvoid lt_update_exe_path (const char *name, const char *value); 42918c4a8e55Smrgvoid lt_update_lib_path (const char *name, const char *value); 4292706b6b52Smrgchar **prepare_spawn (char **argv); 4293706b6b52Smrgvoid lt_dump_script (FILE *f); 42948c4a8e55SmrgEOF 42958c4a8e55Smrg 42968c4a8e55Smrg cat <<EOF 4297bd23fbfaSmrgvolatile const char * MAGIC_EXE = "$magic_exe"; 42988c4a8e55Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 42998c4a8e55SmrgEOF 4300b042e37fSmrg 43018c4a8e55Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4302bd23fbfaSmrg func_to_host_path "$temp_rpath" 43038c4a8e55Smrg cat <<EOF 4304bd23fbfaSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 4305b042e37fSmrgEOF 4306b042e37fSmrg else 43078c4a8e55Smrg cat <<"EOF" 43088c4a8e55Smrgconst char * LIB_PATH_VALUE = ""; 43098c4a8e55SmrgEOF 4310b042e37fSmrg fi 43118c4a8e55Smrg 43128c4a8e55Smrg if test -n "$dllsearchpath"; then 4313bd23fbfaSmrg func_to_host_path "$dllsearchpath:" 43148c4a8e55Smrg cat <<EOF 43158c4a8e55Smrgconst char * EXE_PATH_VARNAME = "PATH"; 4316bd23fbfaSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 43178c4a8e55SmrgEOF 4318b042e37fSmrg else 43198c4a8e55Smrg cat <<"EOF" 43208c4a8e55Smrgconst char * EXE_PATH_VARNAME = ""; 43218c4a8e55Smrgconst char * EXE_PATH_VALUE = ""; 43228c4a8e55SmrgEOF 4323b042e37fSmrg fi 43248c4a8e55Smrg 43258c4a8e55Smrg if test "$fast_install" = yes; then 43268c4a8e55Smrg cat <<EOF 43278c4a8e55Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 43288c4a8e55SmrgEOF 4329b042e37fSmrg else 43308c4a8e55Smrg cat <<EOF 43318c4a8e55Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 43328c4a8e55SmrgEOF 4333b042e37fSmrg fi 4334b042e37fSmrg 4335b042e37fSmrg 43368c4a8e55Smrg cat <<"EOF" 4337b042e37fSmrg 43388c4a8e55Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 4339b042e37fSmrg 43408c4a8e55Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 43418c4a8e55Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 4342706b6b52Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 4343b042e37fSmrg 43448c4a8e55Smrgint 43458c4a8e55Smrgmain (int argc, char *argv[]) 43468c4a8e55Smrg{ 43478c4a8e55Smrg char **newargz; 43488c4a8e55Smrg int newargc; 43498c4a8e55Smrg char *tmp_pathspec; 43508c4a8e55Smrg char *actual_cwrapper_path; 43518c4a8e55Smrg char *actual_cwrapper_name; 43528c4a8e55Smrg char *target_name; 43538c4a8e55Smrg char *lt_argv_zero; 43548c4a8e55Smrg intptr_t rval = 127; 4355b042e37fSmrg 43568c4a8e55Smrg int i; 4357b042e37fSmrg 43588c4a8e55Smrg program_name = (char *) xstrdup (base_name (argv[0])); 4359706b6b52Smrg newargz = XMALLOC (char *, argc + 1); 4360b042e37fSmrg 4361706b6b52Smrg /* very simple arg parsing; don't want to rely on getopt 4362706b6b52Smrg * also, copy all non cwrapper options to newargz, except 4363706b6b52Smrg * argz[0], which is handled differently 4364706b6b52Smrg */ 4365706b6b52Smrg newargc=0; 43668c4a8e55Smrg for (i = 1; i < argc; i++) 43678c4a8e55Smrg { 43688c4a8e55Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 43698c4a8e55Smrg { 43708c4a8e55SmrgEOF 43718c4a8e55Smrg case "$host" in 43728c4a8e55Smrg *mingw* | *cygwin* ) 43738c4a8e55Smrg # make stdout use "unix" line endings 43748c4a8e55Smrg echo " setmode(1,_O_BINARY);" 43758c4a8e55Smrg ;; 43768c4a8e55Smrg esac 4377b042e37fSmrg 43788c4a8e55Smrg cat <<"EOF" 4379706b6b52Smrg lt_dump_script (stdout); 43808c4a8e55Smrg return 0; 43818c4a8e55Smrg } 4382706b6b52Smrg if (strcmp (argv[i], debug_opt) == 0) 4383706b6b52Smrg { 4384706b6b52Smrg lt_debug = 1; 4385706b6b52Smrg continue; 4386706b6b52Smrg } 4387706b6b52Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 4388706b6b52Smrg { 4389706b6b52Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 4390706b6b52Smrg namespace, but it is not one of the ones we know about and 4391706b6b52Smrg have already dealt with, above (inluding dump-script), then 4392706b6b52Smrg report an error. Otherwise, targets might begin to believe 4393706b6b52Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 4394706b6b52Smrg namespace. The first time any user complains about this, we'll 4395706b6b52Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 4396706b6b52Smrg or a configure.ac-settable value. 4397706b6b52Smrg */ 4398706b6b52Smrg lt_fatal (__FILE__, __LINE__, 4399706b6b52Smrg "unrecognized %s option: '%s'", 4400706b6b52Smrg ltwrapper_option_prefix, argv[i]); 4401706b6b52Smrg } 4402706b6b52Smrg /* otherwise ... */ 4403706b6b52Smrg newargz[++newargc] = xstrdup (argv[i]); 44048c4a8e55Smrg } 4405706b6b52Smrg newargz[++newargc] = NULL; 4406706b6b52Smrg 4407706b6b52SmrgEOF 4408706b6b52Smrg cat <<EOF 4409706b6b52Smrg /* The GNU banner must be the first non-error debug message */ 4410706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 4411706b6b52SmrgEOF 4412706b6b52Smrg cat <<"EOF" 4413706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 4414706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 4415b042e37fSmrg 44168c4a8e55Smrg tmp_pathspec = find_executable (argv[0]); 44178c4a8e55Smrg if (tmp_pathspec == NULL) 4418706b6b52Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 4419706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 4420706b6b52Smrg "(main) found exe (before symlink chase) at: %s\n", 4421706b6b52Smrg tmp_pathspec); 44228c4a8e55Smrg 44238c4a8e55Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 4424706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 4425706b6b52Smrg "(main) found exe (after symlink chase) at: %s\n", 4426706b6b52Smrg actual_cwrapper_path); 44278c4a8e55Smrg XFREE (tmp_pathspec); 44288c4a8e55Smrg 4429706b6b52Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 44308c4a8e55Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 44318c4a8e55Smrg 44328c4a8e55Smrg /* wrapper name transforms */ 44338c4a8e55Smrg strendzap (actual_cwrapper_name, ".exe"); 44348c4a8e55Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 44358c4a8e55Smrg XFREE (actual_cwrapper_name); 44368c4a8e55Smrg actual_cwrapper_name = tmp_pathspec; 44378c4a8e55Smrg tmp_pathspec = 0; 44388c4a8e55Smrg 44398c4a8e55Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 44408c4a8e55Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 44418c4a8e55Smrg strendzap (target_name, ".exe"); 44428c4a8e55Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 44438c4a8e55Smrg XFREE (target_name); 44448c4a8e55Smrg target_name = tmp_pathspec; 44458c4a8e55Smrg tmp_pathspec = 0; 44468c4a8e55Smrg 4447706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 4448706b6b52Smrg "(main) libtool target name: %s\n", 4449706b6b52Smrg target_name); 44508c4a8e55SmrgEOF 4451b042e37fSmrg 44528c4a8e55Smrg cat <<EOF 44538c4a8e55Smrg newargz[0] = 44548c4a8e55Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 44558c4a8e55Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 44568c4a8e55Smrg strcpy (newargz[0], actual_cwrapper_path); 44578c4a8e55Smrg strcat (newargz[0], "$objdir"); 44588c4a8e55Smrg strcat (newargz[0], "/"); 44598c4a8e55SmrgEOF 4460b042e37fSmrg 44618c4a8e55Smrg cat <<"EOF" 44628c4a8e55Smrg /* stop here, and copy so we don't have to do this twice */ 44638c4a8e55Smrg tmp_pathspec = xstrdup (newargz[0]); 4464b042e37fSmrg 44658c4a8e55Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 44668c4a8e55Smrg strcat (newargz[0], actual_cwrapper_name); 4467b042e37fSmrg 44688c4a8e55Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 44698c4a8e55Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 44708c4a8e55Smrg XFREE (tmp_pathspec); 44718c4a8e55Smrg tmp_pathspec = NULL; 44728c4a8e55SmrgEOF 4473b042e37fSmrg 44748c4a8e55Smrg case $host_os in 44758c4a8e55Smrg mingw*) 44768c4a8e55Smrg cat <<"EOF" 44778c4a8e55Smrg { 44788c4a8e55Smrg char* p; 44798c4a8e55Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 44808c4a8e55Smrg { 44818c4a8e55Smrg *p = '/'; 44828c4a8e55Smrg } 44838c4a8e55Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 44848c4a8e55Smrg { 44858c4a8e55Smrg *p = '/'; 44868c4a8e55Smrg } 44878c4a8e55Smrg } 44888c4a8e55SmrgEOF 44898c4a8e55Smrg ;; 44908c4a8e55Smrg esac 4491b042e37fSmrg 44928c4a8e55Smrg cat <<"EOF" 44938c4a8e55Smrg XFREE (target_name); 44948c4a8e55Smrg XFREE (actual_cwrapper_path); 44958c4a8e55Smrg XFREE (actual_cwrapper_name); 4496b042e37fSmrg 44978c4a8e55Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 44988c4a8e55Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 4499bd23fbfaSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 4500bd23fbfaSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 4501bd23fbfaSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 4502bd23fbfaSmrg libraries must come first. */ 45038c4a8e55Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 4504bd23fbfaSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 4505b042e37fSmrg 4506706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 4507706b6b52Smrg nonnull (lt_argv_zero)); 45088c4a8e55Smrg for (i = 0; i < newargc; i++) 45098c4a8e55Smrg { 4510706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 4511706b6b52Smrg i, nonnull (newargz[i])); 45128c4a8e55Smrg } 4513b042e37fSmrg 45148c4a8e55SmrgEOF 4515b042e37fSmrg 45168c4a8e55Smrg case $host_os in 45178c4a8e55Smrg mingw*) 45188c4a8e55Smrg cat <<"EOF" 45198c4a8e55Smrg /* execv doesn't actually work on mingw as expected on unix */ 4520706b6b52Smrg newargz = prepare_spawn (newargz); 45218c4a8e55Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 45228c4a8e55Smrg if (rval == -1) 45238c4a8e55Smrg { 45248c4a8e55Smrg /* failed to start process */ 4525706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 4526706b6b52Smrg "(main) failed to launch target \"%s\": %s\n", 4527706b6b52Smrg lt_argv_zero, nonnull (strerror (errno))); 45288c4a8e55Smrg return 127; 45298c4a8e55Smrg } 45308c4a8e55Smrg return rval; 45318c4a8e55SmrgEOF 45328c4a8e55Smrg ;; 45338c4a8e55Smrg *) 45348c4a8e55Smrg cat <<"EOF" 45358c4a8e55Smrg execv (lt_argv_zero, newargz); 45368c4a8e55Smrg return rval; /* =127, but avoids unused variable warning */ 45378c4a8e55SmrgEOF 45388c4a8e55Smrg ;; 45398c4a8e55Smrg esac 4540b042e37fSmrg 45418c4a8e55Smrg cat <<"EOF" 45428c4a8e55Smrg} 4543b042e37fSmrg 45448c4a8e55Smrgvoid * 45458c4a8e55Smrgxmalloc (size_t num) 45468c4a8e55Smrg{ 45478c4a8e55Smrg void *p = (void *) malloc (num); 45488c4a8e55Smrg if (!p) 4549706b6b52Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 4550b042e37fSmrg 45518c4a8e55Smrg return p; 45528c4a8e55Smrg} 4553b042e37fSmrg 45548c4a8e55Smrgchar * 45558c4a8e55Smrgxstrdup (const char *string) 45568c4a8e55Smrg{ 45578c4a8e55Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 45588c4a8e55Smrg string) : NULL; 45598c4a8e55Smrg} 4560b042e37fSmrg 45618c4a8e55Smrgconst char * 45628c4a8e55Smrgbase_name (const char *name) 45638c4a8e55Smrg{ 45648c4a8e55Smrg const char *base; 4565b042e37fSmrg 45668c4a8e55Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 45678c4a8e55Smrg /* Skip over the disk name in MSDOS pathnames. */ 45688c4a8e55Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 45698c4a8e55Smrg name += 2; 45708c4a8e55Smrg#endif 4571b042e37fSmrg 45728c4a8e55Smrg for (base = name; *name; name++) 45738c4a8e55Smrg if (IS_DIR_SEPARATOR (*name)) 45748c4a8e55Smrg base = name + 1; 45758c4a8e55Smrg return base; 45768c4a8e55Smrg} 4577b042e37fSmrg 45788c4a8e55Smrgint 45798c4a8e55Smrgcheck_executable (const char *path) 45808c4a8e55Smrg{ 45818c4a8e55Smrg struct stat st; 4582b042e37fSmrg 4583706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 4584706b6b52Smrg nonempty (path)); 45858c4a8e55Smrg if ((!path) || (!*path)) 45868c4a8e55Smrg return 0; 4587b042e37fSmrg 45888c4a8e55Smrg if ((stat (path, &st) >= 0) 45898c4a8e55Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 45908c4a8e55Smrg return 1; 45918c4a8e55Smrg else 45928c4a8e55Smrg return 0; 45938c4a8e55Smrg} 4594b042e37fSmrg 45958c4a8e55Smrgint 45968c4a8e55Smrgmake_executable (const char *path) 45978c4a8e55Smrg{ 45988c4a8e55Smrg int rval = 0; 45998c4a8e55Smrg struct stat st; 4600b042e37fSmrg 4601706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 4602706b6b52Smrg nonempty (path)); 46038c4a8e55Smrg if ((!path) || (!*path)) 46048c4a8e55Smrg return 0; 4605b042e37fSmrg 46068c4a8e55Smrg if (stat (path, &st) >= 0) 46078c4a8e55Smrg { 46088c4a8e55Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 46098c4a8e55Smrg } 46108c4a8e55Smrg return rval; 46118c4a8e55Smrg} 4612b042e37fSmrg 46138c4a8e55Smrg/* Searches for the full path of the wrapper. Returns 46148c4a8e55Smrg newly allocated full path name if found, NULL otherwise 46158c4a8e55Smrg Does not chase symlinks, even on platforms that support them. 46168c4a8e55Smrg*/ 46178c4a8e55Smrgchar * 46188c4a8e55Smrgfind_executable (const char *wrapper) 46198c4a8e55Smrg{ 46208c4a8e55Smrg int has_slash = 0; 46218c4a8e55Smrg const char *p; 46228c4a8e55Smrg const char *p_next; 46238c4a8e55Smrg /* static buffer for getcwd */ 46248c4a8e55Smrg char tmp[LT_PATHMAX + 1]; 46258c4a8e55Smrg int tmp_len; 46268c4a8e55Smrg char *concat_name; 4627b042e37fSmrg 4628706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 4629706b6b52Smrg nonempty (wrapper)); 4630b042e37fSmrg 46318c4a8e55Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 46328c4a8e55Smrg return NULL; 4633b042e37fSmrg 46348c4a8e55Smrg /* Absolute path? */ 46358c4a8e55Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 46368c4a8e55Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 46378c4a8e55Smrg { 46388c4a8e55Smrg concat_name = xstrdup (wrapper); 46398c4a8e55Smrg if (check_executable (concat_name)) 46408c4a8e55Smrg return concat_name; 46418c4a8e55Smrg XFREE (concat_name); 46428c4a8e55Smrg } 46438c4a8e55Smrg else 46448c4a8e55Smrg { 46458c4a8e55Smrg#endif 46468c4a8e55Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 46478c4a8e55Smrg { 46488c4a8e55Smrg concat_name = xstrdup (wrapper); 46498c4a8e55Smrg if (check_executable (concat_name)) 46508c4a8e55Smrg return concat_name; 46518c4a8e55Smrg XFREE (concat_name); 46528c4a8e55Smrg } 46538c4a8e55Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 46548c4a8e55Smrg } 46558c4a8e55Smrg#endif 4656b042e37fSmrg 46578c4a8e55Smrg for (p = wrapper; *p; p++) 46588c4a8e55Smrg if (*p == '/') 46598c4a8e55Smrg { 46608c4a8e55Smrg has_slash = 1; 46618c4a8e55Smrg break; 46628c4a8e55Smrg } 46638c4a8e55Smrg if (!has_slash) 46648c4a8e55Smrg { 46658c4a8e55Smrg /* no slashes; search PATH */ 46668c4a8e55Smrg const char *path = getenv ("PATH"); 46678c4a8e55Smrg if (path != NULL) 46688c4a8e55Smrg { 46698c4a8e55Smrg for (p = path; *p; p = p_next) 46708c4a8e55Smrg { 46718c4a8e55Smrg const char *q; 46728c4a8e55Smrg size_t p_len; 46738c4a8e55Smrg for (q = p; *q; q++) 46748c4a8e55Smrg if (IS_PATH_SEPARATOR (*q)) 46758c4a8e55Smrg break; 46768c4a8e55Smrg p_len = q - p; 46778c4a8e55Smrg p_next = (*q == '\0' ? q : q + 1); 46788c4a8e55Smrg if (p_len == 0) 46798c4a8e55Smrg { 46808c4a8e55Smrg /* empty path: current directory */ 46818c4a8e55Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 4682706b6b52Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4683706b6b52Smrg nonnull (strerror (errno))); 46848c4a8e55Smrg tmp_len = strlen (tmp); 46858c4a8e55Smrg concat_name = 46868c4a8e55Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 46878c4a8e55Smrg memcpy (concat_name, tmp, tmp_len); 46888c4a8e55Smrg concat_name[tmp_len] = '/'; 46898c4a8e55Smrg strcpy (concat_name + tmp_len + 1, wrapper); 46908c4a8e55Smrg } 46918c4a8e55Smrg else 46928c4a8e55Smrg { 46938c4a8e55Smrg concat_name = 46948c4a8e55Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 46958c4a8e55Smrg memcpy (concat_name, p, p_len); 46968c4a8e55Smrg concat_name[p_len] = '/'; 46978c4a8e55Smrg strcpy (concat_name + p_len + 1, wrapper); 46988c4a8e55Smrg } 46998c4a8e55Smrg if (check_executable (concat_name)) 47008c4a8e55Smrg return concat_name; 47018c4a8e55Smrg XFREE (concat_name); 47028c4a8e55Smrg } 47038c4a8e55Smrg } 47048c4a8e55Smrg /* not found in PATH; assume curdir */ 47058c4a8e55Smrg } 47068c4a8e55Smrg /* Relative path | not found in path: prepend cwd */ 47078c4a8e55Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 4708706b6b52Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4709706b6b52Smrg nonnull (strerror (errno))); 47108c4a8e55Smrg tmp_len = strlen (tmp); 47118c4a8e55Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 47128c4a8e55Smrg memcpy (concat_name, tmp, tmp_len); 47138c4a8e55Smrg concat_name[tmp_len] = '/'; 47148c4a8e55Smrg strcpy (concat_name + tmp_len + 1, wrapper); 4715b042e37fSmrg 47168c4a8e55Smrg if (check_executable (concat_name)) 47178c4a8e55Smrg return concat_name; 47188c4a8e55Smrg XFREE (concat_name); 47198c4a8e55Smrg return NULL; 47208c4a8e55Smrg} 4721b042e37fSmrg 47228c4a8e55Smrgchar * 47238c4a8e55Smrgchase_symlinks (const char *pathspec) 47248c4a8e55Smrg{ 47258c4a8e55Smrg#ifndef S_ISLNK 47268c4a8e55Smrg return xstrdup (pathspec); 47278c4a8e55Smrg#else 47288c4a8e55Smrg char buf[LT_PATHMAX]; 47298c4a8e55Smrg struct stat s; 47308c4a8e55Smrg char *tmp_pathspec = xstrdup (pathspec); 47318c4a8e55Smrg char *p; 47328c4a8e55Smrg int has_symlinks = 0; 47338c4a8e55Smrg while (strlen (tmp_pathspec) && !has_symlinks) 47348c4a8e55Smrg { 4735706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 4736706b6b52Smrg "checking path component for symlinks: %s\n", 4737706b6b52Smrg tmp_pathspec); 47388c4a8e55Smrg if (lstat (tmp_pathspec, &s) == 0) 47398c4a8e55Smrg { 47408c4a8e55Smrg if (S_ISLNK (s.st_mode) != 0) 47418c4a8e55Smrg { 47428c4a8e55Smrg has_symlinks = 1; 47438c4a8e55Smrg break; 47448c4a8e55Smrg } 4745b042e37fSmrg 47468c4a8e55Smrg /* search backwards for last DIR_SEPARATOR */ 47478c4a8e55Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 47488c4a8e55Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 47498c4a8e55Smrg p--; 47508c4a8e55Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 47518c4a8e55Smrg { 47528c4a8e55Smrg /* no more DIR_SEPARATORS left */ 47538c4a8e55Smrg break; 47548c4a8e55Smrg } 47558c4a8e55Smrg *p = '\0'; 47568c4a8e55Smrg } 47578c4a8e55Smrg else 47588c4a8e55Smrg { 4759706b6b52Smrg lt_fatal (__FILE__, __LINE__, 4760706b6b52Smrg "error accessing file \"%s\": %s", 4761706b6b52Smrg tmp_pathspec, nonnull (strerror (errno))); 47628c4a8e55Smrg } 47638c4a8e55Smrg } 47648c4a8e55Smrg XFREE (tmp_pathspec); 4765b042e37fSmrg 47668c4a8e55Smrg if (!has_symlinks) 47678c4a8e55Smrg { 47688c4a8e55Smrg return xstrdup (pathspec); 47698c4a8e55Smrg } 4770b042e37fSmrg 47718c4a8e55Smrg tmp_pathspec = realpath (pathspec, buf); 47728c4a8e55Smrg if (tmp_pathspec == 0) 47738c4a8e55Smrg { 4774706b6b52Smrg lt_fatal (__FILE__, __LINE__, 4775706b6b52Smrg "could not follow symlinks for %s", pathspec); 47768c4a8e55Smrg } 47778c4a8e55Smrg return xstrdup (tmp_pathspec); 47788c4a8e55Smrg#endif 47798c4a8e55Smrg} 4780b042e37fSmrg 47818c4a8e55Smrgchar * 47828c4a8e55Smrgstrendzap (char *str, const char *pat) 47838c4a8e55Smrg{ 47848c4a8e55Smrg size_t len, patlen; 4785b042e37fSmrg 47868c4a8e55Smrg assert (str != NULL); 47878c4a8e55Smrg assert (pat != NULL); 4788b042e37fSmrg 47898c4a8e55Smrg len = strlen (str); 47908c4a8e55Smrg patlen = strlen (pat); 4791b042e37fSmrg 47928c4a8e55Smrg if (patlen <= len) 47938c4a8e55Smrg { 47948c4a8e55Smrg str += len - patlen; 47958c4a8e55Smrg if (strcmp (str, pat) == 0) 47968c4a8e55Smrg *str = '\0'; 47978c4a8e55Smrg } 47988c4a8e55Smrg return str; 47998c4a8e55Smrg} 4800b042e37fSmrg 4801706b6b52Smrgvoid 4802706b6b52Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 4803706b6b52Smrg{ 4804706b6b52Smrg va_list args; 4805706b6b52Smrg if (lt_debug) 4806706b6b52Smrg { 4807706b6b52Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 4808706b6b52Smrg va_start (args, fmt); 4809706b6b52Smrg (void) vfprintf (stderr, fmt, args); 4810706b6b52Smrg va_end (args); 4811706b6b52Smrg } 4812706b6b52Smrg} 4813706b6b52Smrg 48148c4a8e55Smrgstatic void 4815706b6b52Smrglt_error_core (int exit_status, const char *file, 4816706b6b52Smrg int line, const char *mode, 48178c4a8e55Smrg const char *message, va_list ap) 48188c4a8e55Smrg{ 4819706b6b52Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 48208c4a8e55Smrg vfprintf (stderr, message, ap); 48218c4a8e55Smrg fprintf (stderr, ".\n"); 4822b042e37fSmrg 48238c4a8e55Smrg if (exit_status >= 0) 48248c4a8e55Smrg exit (exit_status); 48258c4a8e55Smrg} 4826b042e37fSmrg 48278c4a8e55Smrgvoid 4828706b6b52Smrglt_fatal (const char *file, int line, const char *message, ...) 48298c4a8e55Smrg{ 48308c4a8e55Smrg va_list ap; 48318c4a8e55Smrg va_start (ap, message); 4832706b6b52Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 48338c4a8e55Smrg va_end (ap); 48348c4a8e55Smrg} 4835b042e37fSmrg 4836706b6b52Smrgstatic const char * 4837706b6b52Smrgnonnull (const char *s) 4838706b6b52Smrg{ 4839706b6b52Smrg return s ? s : "(null)"; 4840706b6b52Smrg} 4841706b6b52Smrg 4842706b6b52Smrgstatic const char * 4843706b6b52Smrgnonempty (const char *s) 4844706b6b52Smrg{ 4845706b6b52Smrg return (s && !*s) ? "(empty)" : nonnull (s); 4846706b6b52Smrg} 4847706b6b52Smrg 48488c4a8e55Smrgvoid 48498c4a8e55Smrglt_setenv (const char *name, const char *value) 48508c4a8e55Smrg{ 4851706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 4852706b6b52Smrg "(lt_setenv) setting '%s' to '%s'\n", 4853706b6b52Smrg nonnull (name), nonnull (value)); 48548c4a8e55Smrg { 48558c4a8e55Smrg#ifdef HAVE_SETENV 48568c4a8e55Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 48578c4a8e55Smrg char *str = xstrdup (value); 48588c4a8e55Smrg setenv (name, str, 1); 48598c4a8e55Smrg#else 48608c4a8e55Smrg int len = strlen (name) + 1 + strlen (value) + 1; 48618c4a8e55Smrg char *str = XMALLOC (char, len); 48628c4a8e55Smrg sprintf (str, "%s=%s", name, value); 48638c4a8e55Smrg if (putenv (str) != EXIT_SUCCESS) 48648c4a8e55Smrg { 48658c4a8e55Smrg XFREE (str); 48668c4a8e55Smrg } 48678c4a8e55Smrg#endif 48688c4a8e55Smrg } 48698c4a8e55Smrg} 4870b042e37fSmrg 48718c4a8e55Smrgchar * 48728c4a8e55Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 48738c4a8e55Smrg{ 48748c4a8e55Smrg char *new_value; 48758c4a8e55Smrg if (orig_value && *orig_value) 48768c4a8e55Smrg { 48778c4a8e55Smrg int orig_value_len = strlen (orig_value); 48788c4a8e55Smrg int add_len = strlen (add); 48798c4a8e55Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 48808c4a8e55Smrg if (to_end) 48818c4a8e55Smrg { 48828c4a8e55Smrg strcpy (new_value, orig_value); 48838c4a8e55Smrg strcpy (new_value + orig_value_len, add); 48848c4a8e55Smrg } 48858c4a8e55Smrg else 48868c4a8e55Smrg { 48878c4a8e55Smrg strcpy (new_value, add); 48888c4a8e55Smrg strcpy (new_value + add_len, orig_value); 48898c4a8e55Smrg } 48908c4a8e55Smrg } 48918c4a8e55Smrg else 48928c4a8e55Smrg { 48938c4a8e55Smrg new_value = xstrdup (add); 48948c4a8e55Smrg } 48958c4a8e55Smrg return new_value; 48968c4a8e55Smrg} 4897b042e37fSmrg 48988c4a8e55Smrgvoid 48998c4a8e55Smrglt_update_exe_path (const char *name, const char *value) 49008c4a8e55Smrg{ 4901706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 4902706b6b52Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 4903706b6b52Smrg nonnull (name), nonnull (value)); 4904b042e37fSmrg 49058c4a8e55Smrg if (name && *name && value && *value) 49068c4a8e55Smrg { 49078c4a8e55Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 49088c4a8e55Smrg /* some systems can't cope with a ':'-terminated path #' */ 49098c4a8e55Smrg int len = strlen (new_value); 49108c4a8e55Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 49118c4a8e55Smrg { 49128c4a8e55Smrg new_value[len-1] = '\0'; 49138c4a8e55Smrg } 49148c4a8e55Smrg lt_setenv (name, new_value); 49158c4a8e55Smrg XFREE (new_value); 49168c4a8e55Smrg } 49178c4a8e55Smrg} 4918b042e37fSmrg 49198c4a8e55Smrgvoid 49208c4a8e55Smrglt_update_lib_path (const char *name, const char *value) 49218c4a8e55Smrg{ 4922706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 4923706b6b52Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 4924706b6b52Smrg nonnull (name), nonnull (value)); 4925b042e37fSmrg 49268c4a8e55Smrg if (name && *name && value && *value) 49278c4a8e55Smrg { 49288c4a8e55Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 49298c4a8e55Smrg lt_setenv (name, new_value); 49308c4a8e55Smrg XFREE (new_value); 49318c4a8e55Smrg } 49328c4a8e55Smrg} 4933b042e37fSmrg 4934706b6b52SmrgEOF 4935706b6b52Smrg case $host_os in 4936706b6b52Smrg mingw*) 4937706b6b52Smrg cat <<"EOF" 4938706b6b52Smrg 4939706b6b52Smrg/* Prepares an argument vector before calling spawn(). 4940706b6b52Smrg Note that spawn() does not by itself call the command interpreter 4941706b6b52Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 4942706b6b52Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 4943706b6b52Smrg GetVersionEx(&v); 4944706b6b52Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 4945706b6b52Smrg }) ? "cmd.exe" : "command.com"). 4946706b6b52Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 4947706b6b52Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 4948706b6b52Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 4949706b6b52Smrg special way: 4950706b6b52Smrg - Space and tab are interpreted as delimiters. They are not treated as 4951706b6b52Smrg delimiters if they are surrounded by double quotes: "...". 4952706b6b52Smrg - Unescaped double quotes are removed from the input. Their only effect is 4953706b6b52Smrg that within double quotes, space and tab are treated like normal 4954706b6b52Smrg characters. 4955706b6b52Smrg - Backslashes not followed by double quotes are not special. 4956706b6b52Smrg - But 2*n+1 backslashes followed by a double quote become 4957706b6b52Smrg n backslashes followed by a double quote (n >= 0): 4958706b6b52Smrg \" -> " 4959706b6b52Smrg \\\" -> \" 4960706b6b52Smrg \\\\\" -> \\" 4961706b6b52Smrg */ 4962706b6b52Smrg#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" 4963706b6b52Smrg#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" 4964706b6b52Smrgchar ** 4965706b6b52Smrgprepare_spawn (char **argv) 4966706b6b52Smrg{ 4967706b6b52Smrg size_t argc; 4968706b6b52Smrg char **new_argv; 4969706b6b52Smrg size_t i; 4970706b6b52Smrg 4971706b6b52Smrg /* Count number of arguments. */ 4972706b6b52Smrg for (argc = 0; argv[argc] != NULL; argc++) 4973706b6b52Smrg ; 4974706b6b52Smrg 4975706b6b52Smrg /* Allocate new argument vector. */ 4976706b6b52Smrg new_argv = XMALLOC (char *, argc + 1); 4977706b6b52Smrg 4978706b6b52Smrg /* Put quoted arguments into the new argument vector. */ 4979706b6b52Smrg for (i = 0; i < argc; i++) 4980706b6b52Smrg { 4981706b6b52Smrg const char *string = argv[i]; 4982706b6b52Smrg 4983706b6b52Smrg if (string[0] == '\0') 4984706b6b52Smrg new_argv[i] = xstrdup ("\"\""); 4985706b6b52Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 4986706b6b52Smrg { 4987706b6b52Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 4988706b6b52Smrg size_t length; 4989706b6b52Smrg unsigned int backslashes; 4990706b6b52Smrg const char *s; 4991706b6b52Smrg char *quoted_string; 4992706b6b52Smrg char *p; 4993706b6b52Smrg 4994706b6b52Smrg length = 0; 4995706b6b52Smrg backslashes = 0; 4996706b6b52Smrg if (quote_around) 4997706b6b52Smrg length++; 4998706b6b52Smrg for (s = string; *s != '\0'; s++) 4999706b6b52Smrg { 5000706b6b52Smrg char c = *s; 5001706b6b52Smrg if (c == '"') 5002706b6b52Smrg length += backslashes + 1; 5003706b6b52Smrg length++; 5004706b6b52Smrg if (c == '\\') 5005706b6b52Smrg backslashes++; 5006706b6b52Smrg else 5007706b6b52Smrg backslashes = 0; 5008706b6b52Smrg } 5009706b6b52Smrg if (quote_around) 5010706b6b52Smrg length += backslashes + 1; 5011706b6b52Smrg 5012706b6b52Smrg quoted_string = XMALLOC (char, length + 1); 5013706b6b52Smrg 5014706b6b52Smrg p = quoted_string; 5015706b6b52Smrg backslashes = 0; 5016706b6b52Smrg if (quote_around) 5017706b6b52Smrg *p++ = '"'; 5018706b6b52Smrg for (s = string; *s != '\0'; s++) 5019706b6b52Smrg { 5020706b6b52Smrg char c = *s; 5021706b6b52Smrg if (c == '"') 5022706b6b52Smrg { 5023706b6b52Smrg unsigned int j; 5024706b6b52Smrg for (j = backslashes + 1; j > 0; j--) 5025706b6b52Smrg *p++ = '\\'; 5026706b6b52Smrg } 5027706b6b52Smrg *p++ = c; 5028706b6b52Smrg if (c == '\\') 5029706b6b52Smrg backslashes++; 5030706b6b52Smrg else 5031706b6b52Smrg backslashes = 0; 5032706b6b52Smrg } 5033706b6b52Smrg if (quote_around) 5034706b6b52Smrg { 5035706b6b52Smrg unsigned int j; 5036706b6b52Smrg for (j = backslashes; j > 0; j--) 5037706b6b52Smrg *p++ = '\\'; 5038706b6b52Smrg *p++ = '"'; 5039706b6b52Smrg } 5040706b6b52Smrg *p = '\0'; 5041706b6b52Smrg 5042706b6b52Smrg new_argv[i] = quoted_string; 5043706b6b52Smrg } 5044706b6b52Smrg else 5045706b6b52Smrg new_argv[i] = (char *) string; 5046706b6b52Smrg } 5047706b6b52Smrg new_argv[argc] = NULL; 5048706b6b52Smrg 5049706b6b52Smrg return new_argv; 5050706b6b52Smrg} 5051706b6b52SmrgEOF 5052706b6b52Smrg ;; 5053706b6b52Smrg esac 5054706b6b52Smrg 5055706b6b52Smrg cat <<"EOF" 5056706b6b52Smrgvoid lt_dump_script (FILE* f) 5057706b6b52Smrg{ 5058706b6b52SmrgEOF 5059706b6b52Smrg func_emit_wrapper yes | 5060706b6b52Smrg $SED -e 's/\([\\"]\)/\\\1/g' \ 5061706b6b52Smrg -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' 5062b042e37fSmrg 5063706b6b52Smrg cat <<"EOF" 5064706b6b52Smrg} 50658c4a8e55SmrgEOF 50668c4a8e55Smrg} 50678c4a8e55Smrg# end: func_emit_cwrapperexe_src 5068b042e37fSmrg 5069706b6b52Smrg# func_win32_import_lib_p ARG 5070706b6b52Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 5071706b6b52Smrgfunc_win32_import_lib_p () 5072706b6b52Smrg{ 5073706b6b52Smrg $opt_debug 5074706b6b52Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 5075706b6b52Smrg *import*) : ;; 5076706b6b52Smrg *) false ;; 5077706b6b52Smrg esac 5078706b6b52Smrg} 5079706b6b52Smrg 50808c4a8e55Smrg# func_mode_link arg... 50818c4a8e55Smrgfunc_mode_link () 50828c4a8e55Smrg{ 50838c4a8e55Smrg $opt_debug 50848c4a8e55Smrg case $host in 50858c4a8e55Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 50868c4a8e55Smrg # It is impossible to link a dll without this setting, and 50878c4a8e55Smrg # we shouldn't force the makefile maintainer to figure out 50888c4a8e55Smrg # which system we are compiling for in order to pass an extra 50898c4a8e55Smrg # flag for every libtool invocation. 50908c4a8e55Smrg # allow_undefined=no 5091b042e37fSmrg 50928c4a8e55Smrg # FIXME: Unfortunately, there are problems with the above when trying 50938c4a8e55Smrg # to make a dll which has undefined symbols, in which case not 50948c4a8e55Smrg # even a static library is built. For now, we need to specify 50958c4a8e55Smrg # -no-undefined on the libtool link line when we can be certain 50968c4a8e55Smrg # that all symbols are satisfied, otherwise we get a static library. 50978c4a8e55Smrg allow_undefined=yes 50988c4a8e55Smrg ;; 50998c4a8e55Smrg *) 51008c4a8e55Smrg allow_undefined=yes 51018c4a8e55Smrg ;; 51028c4a8e55Smrg esac 51038c4a8e55Smrg libtool_args=$nonopt 51048c4a8e55Smrg base_compile="$nonopt $@" 51058c4a8e55Smrg compile_command=$nonopt 51068c4a8e55Smrg finalize_command=$nonopt 5107b042e37fSmrg 51088c4a8e55Smrg compile_rpath= 51098c4a8e55Smrg finalize_rpath= 51108c4a8e55Smrg compile_shlibpath= 51118c4a8e55Smrg finalize_shlibpath= 51128c4a8e55Smrg convenience= 51138c4a8e55Smrg old_convenience= 51148c4a8e55Smrg deplibs= 51158c4a8e55Smrg old_deplibs= 51168c4a8e55Smrg compiler_flags= 51178c4a8e55Smrg linker_flags= 51188c4a8e55Smrg dllsearchpath= 51198c4a8e55Smrg lib_search_path=`pwd` 51208c4a8e55Smrg inst_prefix_dir= 51218c4a8e55Smrg new_inherited_linker_flags= 5122b042e37fSmrg 51238c4a8e55Smrg avoid_version=no 5124706b6b52Smrg bindir= 51258c4a8e55Smrg dlfiles= 51268c4a8e55Smrg dlprefiles= 51278c4a8e55Smrg dlself=no 51288c4a8e55Smrg export_dynamic=no 51298c4a8e55Smrg export_symbols= 51308c4a8e55Smrg export_symbols_regex= 51318c4a8e55Smrg generated= 51328c4a8e55Smrg libobjs= 51338c4a8e55Smrg ltlibs= 51348c4a8e55Smrg module=no 51358c4a8e55Smrg no_install=no 51368c4a8e55Smrg objs= 51378c4a8e55Smrg non_pic_objects= 51388c4a8e55Smrg precious_files_regex= 51398c4a8e55Smrg prefer_static_libs=no 51408c4a8e55Smrg preload=no 51418c4a8e55Smrg prev= 51428c4a8e55Smrg prevarg= 51438c4a8e55Smrg release= 51448c4a8e55Smrg rpath= 51458c4a8e55Smrg xrpath= 51468c4a8e55Smrg perm_rpath= 51478c4a8e55Smrg temp_rpath= 51488c4a8e55Smrg thread_safe=no 51498c4a8e55Smrg vinfo= 51508c4a8e55Smrg vinfo_number=no 51518c4a8e55Smrg weak_libs= 51528c4a8e55Smrg single_module="${wl}-single_module" 51538c4a8e55Smrg func_infer_tag $base_compile 5154b042e37fSmrg 51558c4a8e55Smrg # We need to know -static, to get the right output filenames. 51568c4a8e55Smrg for arg 51578c4a8e55Smrg do 51588c4a8e55Smrg case $arg in 51598c4a8e55Smrg -shared) 51608c4a8e55Smrg test "$build_libtool_libs" != yes && \ 51618c4a8e55Smrg func_fatal_configuration "can not build a shared library" 51628c4a8e55Smrg build_old_libs=no 51638c4a8e55Smrg break 51648c4a8e55Smrg ;; 51658c4a8e55Smrg -all-static | -static | -static-libtool-libs) 51668c4a8e55Smrg case $arg in 51678c4a8e55Smrg -all-static) 51688c4a8e55Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 51698c4a8e55Smrg func_warning "complete static linking is impossible in this configuration" 51708c4a8e55Smrg fi 51718c4a8e55Smrg if test -n "$link_static_flag"; then 51728c4a8e55Smrg dlopen_self=$dlopen_self_static 51738c4a8e55Smrg fi 51748c4a8e55Smrg prefer_static_libs=yes 51758c4a8e55Smrg ;; 51768c4a8e55Smrg -static) 51778c4a8e55Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 51788c4a8e55Smrg dlopen_self=$dlopen_self_static 51798c4a8e55Smrg fi 51808c4a8e55Smrg prefer_static_libs=built 51818c4a8e55Smrg ;; 51828c4a8e55Smrg -static-libtool-libs) 51838c4a8e55Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 51848c4a8e55Smrg dlopen_self=$dlopen_self_static 51858c4a8e55Smrg fi 51868c4a8e55Smrg prefer_static_libs=yes 51878c4a8e55Smrg ;; 51888c4a8e55Smrg esac 51898c4a8e55Smrg build_libtool_libs=no 51908c4a8e55Smrg build_old_libs=yes 51918c4a8e55Smrg break 51928c4a8e55Smrg ;; 51938c4a8e55Smrg esac 51948c4a8e55Smrg done 5195b042e37fSmrg 51968c4a8e55Smrg # See if our shared archives depend on static archives. 51978c4a8e55Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 5198b042e37fSmrg 51998c4a8e55Smrg # Go through the arguments, transforming them on the way. 52008c4a8e55Smrg while test "$#" -gt 0; do 52018c4a8e55Smrg arg="$1" 52028c4a8e55Smrg shift 52038c4a8e55Smrg func_quote_for_eval "$arg" 52048c4a8e55Smrg qarg=$func_quote_for_eval_unquoted_result 52058c4a8e55Smrg func_append libtool_args " $func_quote_for_eval_result" 5206b042e37fSmrg 52078c4a8e55Smrg # If the previous option needs an argument, assign it. 52088c4a8e55Smrg if test -n "$prev"; then 52098c4a8e55Smrg case $prev in 52108c4a8e55Smrg output) 52118c4a8e55Smrg func_append compile_command " @OUTPUT@" 52128c4a8e55Smrg func_append finalize_command " @OUTPUT@" 52138c4a8e55Smrg ;; 52148c4a8e55Smrg esac 5215b042e37fSmrg 52168c4a8e55Smrg case $prev in 5217706b6b52Smrg bindir) 5218706b6b52Smrg bindir="$arg" 5219706b6b52Smrg prev= 5220706b6b52Smrg continue 5221706b6b52Smrg ;; 52228c4a8e55Smrg dlfiles|dlprefiles) 52238c4a8e55Smrg if test "$preload" = no; then 52248c4a8e55Smrg # Add the symbol object into the linking commands. 52258c4a8e55Smrg func_append compile_command " @SYMFILE@" 52268c4a8e55Smrg func_append finalize_command " @SYMFILE@" 52278c4a8e55Smrg preload=yes 52288c4a8e55Smrg fi 52298c4a8e55Smrg case $arg in 52308c4a8e55Smrg *.la | *.lo) ;; # We handle these cases below. 52318c4a8e55Smrg force) 52328c4a8e55Smrg if test "$dlself" = no; then 52338c4a8e55Smrg dlself=needless 52348c4a8e55Smrg export_dynamic=yes 52358c4a8e55Smrg fi 52368c4a8e55Smrg prev= 52378c4a8e55Smrg continue 52388c4a8e55Smrg ;; 52398c4a8e55Smrg self) 52408c4a8e55Smrg if test "$prev" = dlprefiles; then 52418c4a8e55Smrg dlself=yes 52428c4a8e55Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 52438c4a8e55Smrg dlself=yes 52448c4a8e55Smrg else 52458c4a8e55Smrg dlself=needless 52468c4a8e55Smrg export_dynamic=yes 52478c4a8e55Smrg fi 52488c4a8e55Smrg prev= 52498c4a8e55Smrg continue 52508c4a8e55Smrg ;; 52518c4a8e55Smrg *) 52528c4a8e55Smrg if test "$prev" = dlfiles; then 5253bd23fbfaSmrg func_append dlfiles " $arg" 52548c4a8e55Smrg else 5255bd23fbfaSmrg func_append dlprefiles " $arg" 52568c4a8e55Smrg fi 52578c4a8e55Smrg prev= 52588c4a8e55Smrg continue 52598c4a8e55Smrg ;; 52608c4a8e55Smrg esac 52618c4a8e55Smrg ;; 52628c4a8e55Smrg expsyms) 52638c4a8e55Smrg export_symbols="$arg" 52648c4a8e55Smrg test -f "$arg" \ 52658c4a8e55Smrg || func_fatal_error "symbol file \`$arg' does not exist" 52668c4a8e55Smrg prev= 52678c4a8e55Smrg continue 52688c4a8e55Smrg ;; 52698c4a8e55Smrg expsyms_regex) 52708c4a8e55Smrg export_symbols_regex="$arg" 52718c4a8e55Smrg prev= 52728c4a8e55Smrg continue 52738c4a8e55Smrg ;; 52748c4a8e55Smrg framework) 52758c4a8e55Smrg case $host in 52768c4a8e55Smrg *-*-darwin*) 52778c4a8e55Smrg case "$deplibs " in 52788c4a8e55Smrg *" $qarg.ltframework "*) ;; 5279bd23fbfaSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 52808c4a8e55Smrg ;; 52818c4a8e55Smrg esac 5282b042e37fSmrg ;; 52838c4a8e55Smrg esac 52848c4a8e55Smrg prev= 52858c4a8e55Smrg continue 52868c4a8e55Smrg ;; 52878c4a8e55Smrg inst_prefix) 52888c4a8e55Smrg inst_prefix_dir="$arg" 52898c4a8e55Smrg prev= 52908c4a8e55Smrg continue 52918c4a8e55Smrg ;; 52928c4a8e55Smrg objectlist) 52938c4a8e55Smrg if test -f "$arg"; then 52948c4a8e55Smrg save_arg=$arg 52958c4a8e55Smrg moreargs= 52968c4a8e55Smrg for fil in `cat "$save_arg"` 52978c4a8e55Smrg do 5298bd23fbfaSmrg# func_append moreargs " $fil" 52998c4a8e55Smrg arg=$fil 53008c4a8e55Smrg # A libtool-controlled object. 5301b042e37fSmrg 53028c4a8e55Smrg # Check to see that this really is a libtool object. 53038c4a8e55Smrg if func_lalib_unsafe_p "$arg"; then 53048c4a8e55Smrg pic_object= 53058c4a8e55Smrg non_pic_object= 5306b042e37fSmrg 53078c4a8e55Smrg # Read the .lo file 53088c4a8e55Smrg func_source "$arg" 5309b042e37fSmrg 53108c4a8e55Smrg if test -z "$pic_object" || 53118c4a8e55Smrg test -z "$non_pic_object" || 53128c4a8e55Smrg test "$pic_object" = none && 53138c4a8e55Smrg test "$non_pic_object" = none; then 53148c4a8e55Smrg func_fatal_error "cannot find name of object for \`$arg'" 53158c4a8e55Smrg fi 5316b042e37fSmrg 53178c4a8e55Smrg # Extract subdirectory from the argument. 53188c4a8e55Smrg func_dirname "$arg" "/" "" 53198c4a8e55Smrg xdir="$func_dirname_result" 5320b042e37fSmrg 53218c4a8e55Smrg if test "$pic_object" != none; then 53228c4a8e55Smrg # Prepend the subdirectory the object is found in. 53238c4a8e55Smrg pic_object="$xdir$pic_object" 5324b042e37fSmrg 53258c4a8e55Smrg if test "$prev" = dlfiles; then 53268c4a8e55Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5327bd23fbfaSmrg func_append dlfiles " $pic_object" 53288c4a8e55Smrg prev= 53298c4a8e55Smrg continue 53308c4a8e55Smrg else 53318c4a8e55Smrg # If libtool objects are unsupported, then we need to preload. 53328c4a8e55Smrg prev=dlprefiles 53338c4a8e55Smrg fi 53348c4a8e55Smrg fi 5335b042e37fSmrg 53368c4a8e55Smrg # CHECK ME: I think I busted this. -Ossama 53378c4a8e55Smrg if test "$prev" = dlprefiles; then 53388c4a8e55Smrg # Preload the old-style object. 5339bd23fbfaSmrg func_append dlprefiles " $pic_object" 53408c4a8e55Smrg prev= 53418c4a8e55Smrg fi 5342b042e37fSmrg 53438c4a8e55Smrg # A PIC object. 53448c4a8e55Smrg func_append libobjs " $pic_object" 53458c4a8e55Smrg arg="$pic_object" 53468c4a8e55Smrg fi 5347b042e37fSmrg 53488c4a8e55Smrg # Non-PIC object. 53498c4a8e55Smrg if test "$non_pic_object" != none; then 53508c4a8e55Smrg # Prepend the subdirectory the object is found in. 53518c4a8e55Smrg non_pic_object="$xdir$non_pic_object" 5352b042e37fSmrg 53538c4a8e55Smrg # A standard non-PIC object 53548c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 53558c4a8e55Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 53568c4a8e55Smrg arg="$non_pic_object" 53578c4a8e55Smrg fi 53588c4a8e55Smrg else 53598c4a8e55Smrg # If the PIC object exists, use it instead. 53608c4a8e55Smrg # $xdir was prepended to $pic_object above. 53618c4a8e55Smrg non_pic_object="$pic_object" 53628c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 53638c4a8e55Smrg fi 53648c4a8e55Smrg else 53658c4a8e55Smrg # Only an error if not doing a dry-run. 53668c4a8e55Smrg if $opt_dry_run; then 53678c4a8e55Smrg # Extract subdirectory from the argument. 53688c4a8e55Smrg func_dirname "$arg" "/" "" 53698c4a8e55Smrg xdir="$func_dirname_result" 53708c4a8e55Smrg 53718c4a8e55Smrg func_lo2o "$arg" 53728c4a8e55Smrg pic_object=$xdir$objdir/$func_lo2o_result 53738c4a8e55Smrg non_pic_object=$xdir$func_lo2o_result 53748c4a8e55Smrg func_append libobjs " $pic_object" 53758c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 53768c4a8e55Smrg else 53778c4a8e55Smrg func_fatal_error "\`$arg' is not a valid libtool object" 53788c4a8e55Smrg fi 53798c4a8e55Smrg fi 53808c4a8e55Smrg done 53818c4a8e55Smrg else 53828c4a8e55Smrg func_fatal_error "link input file \`$arg' does not exist" 53838c4a8e55Smrg fi 53848c4a8e55Smrg arg=$save_arg 53858c4a8e55Smrg prev= 53868c4a8e55Smrg continue 5387b042e37fSmrg ;; 53888c4a8e55Smrg precious_regex) 53898c4a8e55Smrg precious_files_regex="$arg" 53908c4a8e55Smrg prev= 53918c4a8e55Smrg continue 5392b042e37fSmrg ;; 53938c4a8e55Smrg release) 53948c4a8e55Smrg release="-$arg" 53958c4a8e55Smrg prev= 53968c4a8e55Smrg continue 5397b042e37fSmrg ;; 53988c4a8e55Smrg rpath | xrpath) 53998c4a8e55Smrg # We need an absolute path. 54008c4a8e55Smrg case $arg in 54018c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5402b042e37fSmrg *) 54038c4a8e55Smrg func_fatal_error "only absolute run-paths are allowed" 5404b042e37fSmrg ;; 5405b042e37fSmrg esac 54068c4a8e55Smrg if test "$prev" = rpath; then 54078c4a8e55Smrg case "$rpath " in 54088c4a8e55Smrg *" $arg "*) ;; 5409bd23fbfaSmrg *) func_append rpath " $arg" ;; 54108c4a8e55Smrg esac 54118c4a8e55Smrg else 54128c4a8e55Smrg case "$xrpath " in 54138c4a8e55Smrg *" $arg "*) ;; 5414bd23fbfaSmrg *) func_append xrpath " $arg" ;; 54158c4a8e55Smrg esac 54168c4a8e55Smrg fi 54178c4a8e55Smrg prev= 54188c4a8e55Smrg continue 54198c4a8e55Smrg ;; 54208c4a8e55Smrg shrext) 54218c4a8e55Smrg shrext_cmds="$arg" 54228c4a8e55Smrg prev= 54238c4a8e55Smrg continue 54248c4a8e55Smrg ;; 54258c4a8e55Smrg weak) 5426bd23fbfaSmrg func_append weak_libs " $arg" 54278c4a8e55Smrg prev= 54288c4a8e55Smrg continue 54298c4a8e55Smrg ;; 54308c4a8e55Smrg xcclinker) 5431bd23fbfaSmrg func_append linker_flags " $qarg" 5432bd23fbfaSmrg func_append compiler_flags " $qarg" 54338c4a8e55Smrg prev= 54348c4a8e55Smrg func_append compile_command " $qarg" 54358c4a8e55Smrg func_append finalize_command " $qarg" 54368c4a8e55Smrg continue 54378c4a8e55Smrg ;; 54388c4a8e55Smrg xcompiler) 5439bd23fbfaSmrg func_append compiler_flags " $qarg" 54408c4a8e55Smrg prev= 54418c4a8e55Smrg func_append compile_command " $qarg" 54428c4a8e55Smrg func_append finalize_command " $qarg" 54438c4a8e55Smrg continue 54448c4a8e55Smrg ;; 54458c4a8e55Smrg xlinker) 5446bd23fbfaSmrg func_append linker_flags " $qarg" 5447bd23fbfaSmrg func_append compiler_flags " $wl$qarg" 54488c4a8e55Smrg prev= 54498c4a8e55Smrg func_append compile_command " $wl$qarg" 54508c4a8e55Smrg func_append finalize_command " $wl$qarg" 54518c4a8e55Smrg continue 54528c4a8e55Smrg ;; 54538c4a8e55Smrg *) 54548c4a8e55Smrg eval "$prev=\"\$arg\"" 54558c4a8e55Smrg prev= 54568c4a8e55Smrg continue 54578c4a8e55Smrg ;; 54588c4a8e55Smrg esac 54598c4a8e55Smrg fi # test -n "$prev" 54608c4a8e55Smrg 54618c4a8e55Smrg prevarg="$arg" 54628c4a8e55Smrg 54638c4a8e55Smrg case $arg in 54648c4a8e55Smrg -all-static) 54658c4a8e55Smrg if test -n "$link_static_flag"; then 54668c4a8e55Smrg # See comment for -static flag below, for more details. 54678c4a8e55Smrg func_append compile_command " $link_static_flag" 54688c4a8e55Smrg func_append finalize_command " $link_static_flag" 5469b042e37fSmrg fi 54708c4a8e55Smrg continue 54718c4a8e55Smrg ;; 5472b042e37fSmrg 54738c4a8e55Smrg -allow-undefined) 54748c4a8e55Smrg # FIXME: remove this flag sometime in the future. 54758c4a8e55Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 54768c4a8e55Smrg ;; 5477b042e37fSmrg 54788c4a8e55Smrg -avoid-version) 54798c4a8e55Smrg avoid_version=yes 54808c4a8e55Smrg continue 54818c4a8e55Smrg ;; 5482b042e37fSmrg 5483706b6b52Smrg -bindir) 5484706b6b52Smrg prev=bindir 5485706b6b52Smrg continue 5486706b6b52Smrg ;; 5487706b6b52Smrg 54888c4a8e55Smrg -dlopen) 54898c4a8e55Smrg prev=dlfiles 54908c4a8e55Smrg continue 54918c4a8e55Smrg ;; 54928c4a8e55Smrg 54938c4a8e55Smrg -dlpreopen) 54948c4a8e55Smrg prev=dlprefiles 54958c4a8e55Smrg continue 54968c4a8e55Smrg ;; 54978c4a8e55Smrg 54988c4a8e55Smrg -export-dynamic) 54998c4a8e55Smrg export_dynamic=yes 55008c4a8e55Smrg continue 55018c4a8e55Smrg ;; 55028c4a8e55Smrg 55038c4a8e55Smrg -export-symbols | -export-symbols-regex) 55048c4a8e55Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 55058c4a8e55Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 55068c4a8e55Smrg fi 55078c4a8e55Smrg if test "X$arg" = "X-export-symbols"; then 55088c4a8e55Smrg prev=expsyms 5509b042e37fSmrg else 55108c4a8e55Smrg prev=expsyms_regex 5511b042e37fSmrg fi 55128c4a8e55Smrg continue 55138c4a8e55Smrg ;; 5514b042e37fSmrg 55158c4a8e55Smrg -framework) 55168c4a8e55Smrg prev=framework 55178c4a8e55Smrg continue 55188c4a8e55Smrg ;; 5519b042e37fSmrg 55208c4a8e55Smrg -inst-prefix-dir) 55218c4a8e55Smrg prev=inst_prefix 55228c4a8e55Smrg continue 55238c4a8e55Smrg ;; 5524b042e37fSmrg 55258c4a8e55Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 55268c4a8e55Smrg # so, if we see these flags be careful not to treat them like -L 55278c4a8e55Smrg -L[A-Z][A-Z]*:*) 55288c4a8e55Smrg case $with_gcc/$host in 55298c4a8e55Smrg no/*-*-irix* | /*-*-irix*) 55308c4a8e55Smrg func_append compile_command " $arg" 55318c4a8e55Smrg func_append finalize_command " $arg" 55328c4a8e55Smrg ;; 55338c4a8e55Smrg esac 55348c4a8e55Smrg continue 55358c4a8e55Smrg ;; 5536b042e37fSmrg 55378c4a8e55Smrg -L*) 5538bd23fbfaSmrg func_stripname "-L" '' "$arg" 5539bd23fbfaSmrg if test -z "$func_stripname_result"; then 55408c4a8e55Smrg if test "$#" -gt 0; then 55418c4a8e55Smrg func_fatal_error "require no space between \`-L' and \`$1'" 5542b042e37fSmrg else 55438c4a8e55Smrg func_fatal_error "need path for \`-L' option" 5544b042e37fSmrg fi 55458c4a8e55Smrg fi 5546bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result" 5547bd23fbfaSmrg dir=$func_resolve_sysroot_result 55488c4a8e55Smrg # We need an absolute path. 55498c4a8e55Smrg case $dir in 55508c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 55518c4a8e55Smrg *) 55528c4a8e55Smrg absdir=`cd "$dir" && pwd` 55538c4a8e55Smrg test -z "$absdir" && \ 55548c4a8e55Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 55558c4a8e55Smrg dir="$absdir" 55568c4a8e55Smrg ;; 5557b042e37fSmrg esac 55588c4a8e55Smrg case "$deplibs " in 5559bd23fbfaSmrg *" -L$dir "* | *" $arg "*) 5560bd23fbfaSmrg # Will only happen for absolute or sysroot arguments 5561bd23fbfaSmrg ;; 55628c4a8e55Smrg *) 5563bd23fbfaSmrg # Preserve sysroot, but never include relative directories 5564bd23fbfaSmrg case $dir in 5565bd23fbfaSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 5566bd23fbfaSmrg *) func_append deplibs " -L$dir" ;; 5567bd23fbfaSmrg esac 5568bd23fbfaSmrg func_append lib_search_path " $dir" 55698c4a8e55Smrg ;; 5570b042e37fSmrg esac 5571b042e37fSmrg case $host in 55728c4a8e55Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5573706b6b52Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 55748c4a8e55Smrg case :$dllsearchpath: in 55758c4a8e55Smrg *":$dir:"*) ;; 55768c4a8e55Smrg ::) dllsearchpath=$dir;; 5577bd23fbfaSmrg *) func_append dllsearchpath ":$dir";; 55788c4a8e55Smrg esac 55798c4a8e55Smrg case :$dllsearchpath: in 55808c4a8e55Smrg *":$testbindir:"*) ;; 55818c4a8e55Smrg ::) dllsearchpath=$testbindir;; 5582bd23fbfaSmrg *) func_append dllsearchpath ":$testbindir";; 55838c4a8e55Smrg esac 55848c4a8e55Smrg ;; 5585b042e37fSmrg esac 55868c4a8e55Smrg continue 55878c4a8e55Smrg ;; 5588b042e37fSmrg 55898c4a8e55Smrg -l*) 55908c4a8e55Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 55918c4a8e55Smrg case $host in 5592706b6b52Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 55938c4a8e55Smrg # These systems don't actually have a C or math library (as such) 55948c4a8e55Smrg continue 55958c4a8e55Smrg ;; 55968c4a8e55Smrg *-*-os2*) 55978c4a8e55Smrg # These systems don't actually have a C library (as such) 55988c4a8e55Smrg test "X$arg" = "X-lc" && continue 55998c4a8e55Smrg ;; 56008c4a8e55Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 56018c4a8e55Smrg # Do not include libc due to us having libc/libc_r. 56028c4a8e55Smrg test "X$arg" = "X-lc" && continue 56038c4a8e55Smrg ;; 56048c4a8e55Smrg *-*-rhapsody* | *-*-darwin1.[012]) 56058c4a8e55Smrg # Rhapsody C and math libraries are in the System framework 5606bd23fbfaSmrg func_append deplibs " System.ltframework" 56078c4a8e55Smrg continue 56088c4a8e55Smrg ;; 56098c4a8e55Smrg *-*-sco3.2v5* | *-*-sco5v6*) 56108c4a8e55Smrg # Causes problems with __ctype 56118c4a8e55Smrg test "X$arg" = "X-lc" && continue 56128c4a8e55Smrg ;; 56138c4a8e55Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 56148c4a8e55Smrg # Compiler inserts libc in the correct place for threads to work 56158c4a8e55Smrg test "X$arg" = "X-lc" && continue 56168c4a8e55Smrg ;; 56178c4a8e55Smrg esac 56188c4a8e55Smrg elif test "X$arg" = "X-lc_r"; then 56198c4a8e55Smrg case $host in 56208c4a8e55Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 56218c4a8e55Smrg # Do not include libc_r directly, use -pthread flag. 56228c4a8e55Smrg continue 56238c4a8e55Smrg ;; 56248c4a8e55Smrg esac 56258c4a8e55Smrg fi 5626bd23fbfaSmrg func_append deplibs " $arg" 56278c4a8e55Smrg continue 56288c4a8e55Smrg ;; 5629b042e37fSmrg 56308c4a8e55Smrg -module) 56318c4a8e55Smrg module=yes 56328c4a8e55Smrg continue 56338c4a8e55Smrg ;; 5634b042e37fSmrg 56358c4a8e55Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 56368c4a8e55Smrg # classes, name mangling, and exception handling. 56378c4a8e55Smrg # Darwin uses the -arch flag to determine output architecture. 5638bd23fbfaSmrg -model|-arch|-isysroot|--sysroot) 5639bd23fbfaSmrg func_append compiler_flags " $arg" 56408c4a8e55Smrg func_append compile_command " $arg" 56418c4a8e55Smrg func_append finalize_command " $arg" 56428c4a8e55Smrg prev=xcompiler 56438c4a8e55Smrg continue 56448c4a8e55Smrg ;; 5645b042e37fSmrg 56468c4a8e55Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 5647bd23fbfaSmrg func_append compiler_flags " $arg" 56488c4a8e55Smrg func_append compile_command " $arg" 56498c4a8e55Smrg func_append finalize_command " $arg" 56508c4a8e55Smrg case "$new_inherited_linker_flags " in 56518c4a8e55Smrg *" $arg "*) ;; 5652bd23fbfaSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 56538c4a8e55Smrg esac 56548c4a8e55Smrg continue 56558c4a8e55Smrg ;; 5656b042e37fSmrg 56578c4a8e55Smrg -multi_module) 56588c4a8e55Smrg single_module="${wl}-multi_module" 56598c4a8e55Smrg continue 56608c4a8e55Smrg ;; 5661b042e37fSmrg 56628c4a8e55Smrg -no-fast-install) 56638c4a8e55Smrg fast_install=no 56648c4a8e55Smrg continue 56658c4a8e55Smrg ;; 5666b042e37fSmrg 56678c4a8e55Smrg -no-install) 56688c4a8e55Smrg case $host in 56698c4a8e55Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 56708c4a8e55Smrg # The PATH hackery in wrapper scripts is required on Windows 56718c4a8e55Smrg # and Darwin in order for the loader to find any dlls it needs. 56728c4a8e55Smrg func_warning "\`-no-install' is ignored for $host" 56738c4a8e55Smrg func_warning "assuming \`-no-fast-install' instead" 56748c4a8e55Smrg fast_install=no 56758c4a8e55Smrg ;; 56768c4a8e55Smrg *) no_install=yes ;; 56778c4a8e55Smrg esac 56788c4a8e55Smrg continue 56798c4a8e55Smrg ;; 5680b042e37fSmrg 56818c4a8e55Smrg -no-undefined) 56828c4a8e55Smrg allow_undefined=no 56838c4a8e55Smrg continue 56848c4a8e55Smrg ;; 5685b042e37fSmrg 56868c4a8e55Smrg -objectlist) 56878c4a8e55Smrg prev=objectlist 56888c4a8e55Smrg continue 56898c4a8e55Smrg ;; 5690b042e37fSmrg 56918c4a8e55Smrg -o) prev=output ;; 5692b042e37fSmrg 56938c4a8e55Smrg -precious-files-regex) 56948c4a8e55Smrg prev=precious_regex 56958c4a8e55Smrg continue 56968c4a8e55Smrg ;; 5697b042e37fSmrg 56988c4a8e55Smrg -release) 56998c4a8e55Smrg prev=release 57008c4a8e55Smrg continue 57018c4a8e55Smrg ;; 5702b042e37fSmrg 57038c4a8e55Smrg -rpath) 57048c4a8e55Smrg prev=rpath 57058c4a8e55Smrg continue 57068c4a8e55Smrg ;; 5707b042e37fSmrg 57088c4a8e55Smrg -R) 57098c4a8e55Smrg prev=xrpath 57108c4a8e55Smrg continue 57118c4a8e55Smrg ;; 5712b042e37fSmrg 57138c4a8e55Smrg -R*) 57148c4a8e55Smrg func_stripname '-R' '' "$arg" 57158c4a8e55Smrg dir=$func_stripname_result 57168c4a8e55Smrg # We need an absolute path. 57178c4a8e55Smrg case $dir in 57188c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5719bd23fbfaSmrg =*) 5720bd23fbfaSmrg func_stripname '=' '' "$dir" 5721bd23fbfaSmrg dir=$lt_sysroot$func_stripname_result 5722bd23fbfaSmrg ;; 57238c4a8e55Smrg *) 57248c4a8e55Smrg func_fatal_error "only absolute run-paths are allowed" 57258c4a8e55Smrg ;; 57268c4a8e55Smrg esac 57278c4a8e55Smrg case "$xrpath " in 57288c4a8e55Smrg *" $dir "*) ;; 5729bd23fbfaSmrg *) func_append xrpath " $dir" ;; 57308c4a8e55Smrg esac 57318c4a8e55Smrg continue 57328c4a8e55Smrg ;; 5733b042e37fSmrg 57348c4a8e55Smrg -shared) 57358c4a8e55Smrg # The effects of -shared are defined in a previous loop. 57368c4a8e55Smrg continue 57378c4a8e55Smrg ;; 5738b042e37fSmrg 57398c4a8e55Smrg -shrext) 57408c4a8e55Smrg prev=shrext 57418c4a8e55Smrg continue 57428c4a8e55Smrg ;; 5743b042e37fSmrg 57448c4a8e55Smrg -static | -static-libtool-libs) 57458c4a8e55Smrg # The effects of -static are defined in a previous loop. 57468c4a8e55Smrg # We used to do the same as -all-static on platforms that 57478c4a8e55Smrg # didn't have a PIC flag, but the assumption that the effects 57488c4a8e55Smrg # would be equivalent was wrong. It would break on at least 57498c4a8e55Smrg # Digital Unix and AIX. 57508c4a8e55Smrg continue 57518c4a8e55Smrg ;; 5752b042e37fSmrg 57538c4a8e55Smrg -thread-safe) 57548c4a8e55Smrg thread_safe=yes 57558c4a8e55Smrg continue 57568c4a8e55Smrg ;; 5757b042e37fSmrg 57588c4a8e55Smrg -version-info) 57598c4a8e55Smrg prev=vinfo 57608c4a8e55Smrg continue 57618c4a8e55Smrg ;; 5762b042e37fSmrg 57638c4a8e55Smrg -version-number) 57648c4a8e55Smrg prev=vinfo 57658c4a8e55Smrg vinfo_number=yes 57668c4a8e55Smrg continue 57678c4a8e55Smrg ;; 5768b042e37fSmrg 57698c4a8e55Smrg -weak) 57708c4a8e55Smrg prev=weak 57718c4a8e55Smrg continue 57728c4a8e55Smrg ;; 5773b042e37fSmrg 57748c4a8e55Smrg -Wc,*) 57758c4a8e55Smrg func_stripname '-Wc,' '' "$arg" 57768c4a8e55Smrg args=$func_stripname_result 57778c4a8e55Smrg arg= 57788c4a8e55Smrg save_ifs="$IFS"; IFS=',' 57798c4a8e55Smrg for flag in $args; do 57808c4a8e55Smrg IFS="$save_ifs" 57818c4a8e55Smrg func_quote_for_eval "$flag" 5782bd23fbfaSmrg func_append arg " $func_quote_for_eval_result" 5783bd23fbfaSmrg func_append compiler_flags " $func_quote_for_eval_result" 57848c4a8e55Smrg done 57858c4a8e55Smrg IFS="$save_ifs" 57868c4a8e55Smrg func_stripname ' ' '' "$arg" 57878c4a8e55Smrg arg=$func_stripname_result 57888c4a8e55Smrg ;; 5789b042e37fSmrg 57908c4a8e55Smrg -Wl,*) 57918c4a8e55Smrg func_stripname '-Wl,' '' "$arg" 57928c4a8e55Smrg args=$func_stripname_result 57938c4a8e55Smrg arg= 57948c4a8e55Smrg save_ifs="$IFS"; IFS=',' 57958c4a8e55Smrg for flag in $args; do 57968c4a8e55Smrg IFS="$save_ifs" 57978c4a8e55Smrg func_quote_for_eval "$flag" 5798bd23fbfaSmrg func_append arg " $wl$func_quote_for_eval_result" 5799bd23fbfaSmrg func_append compiler_flags " $wl$func_quote_for_eval_result" 5800bd23fbfaSmrg func_append linker_flags " $func_quote_for_eval_result" 58018c4a8e55Smrg done 58028c4a8e55Smrg IFS="$save_ifs" 58038c4a8e55Smrg func_stripname ' ' '' "$arg" 58048c4a8e55Smrg arg=$func_stripname_result 58058c4a8e55Smrg ;; 5806b042e37fSmrg 58078c4a8e55Smrg -Xcompiler) 58088c4a8e55Smrg prev=xcompiler 58098c4a8e55Smrg continue 58108c4a8e55Smrg ;; 5811b042e37fSmrg 58128c4a8e55Smrg -Xlinker) 58138c4a8e55Smrg prev=xlinker 58148c4a8e55Smrg continue 58158c4a8e55Smrg ;; 5816b042e37fSmrg 58178c4a8e55Smrg -XCClinker) 58188c4a8e55Smrg prev=xcclinker 58198c4a8e55Smrg continue 58208c4a8e55Smrg ;; 5821b042e37fSmrg 58228c4a8e55Smrg # -msg_* for osf cc 58238c4a8e55Smrg -msg_*) 58248c4a8e55Smrg func_quote_for_eval "$arg" 58258c4a8e55Smrg arg="$func_quote_for_eval_result" 58268c4a8e55Smrg ;; 5827b042e37fSmrg 5828706b6b52Smrg # Flags to be passed through unchanged, with rationale: 5829706b6b52Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 5830706b6b52Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 5831706b6b52Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 5832706b6b52Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 5833706b6b52Smrg # -q* compiler args for the IBM compiler 5834706b6b52Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 5835706b6b52Smrg # -F/path path to uninstalled frameworks, gcc on darwin 5836706b6b52Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 5837706b6b52Smrg # @file GCC response files 5838706b6b52Smrg # -tp=* Portland pgcc target processor selection 5839bd23fbfaSmrg # --sysroot=* for sysroot support 5840bd23fbfaSmrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 58418c4a8e55Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 5842bd23fbfaSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 5843bd23fbfaSmrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 58448c4a8e55Smrg func_quote_for_eval "$arg" 58458c4a8e55Smrg arg="$func_quote_for_eval_result" 58468c4a8e55Smrg func_append compile_command " $arg" 58478c4a8e55Smrg func_append finalize_command " $arg" 5848bd23fbfaSmrg func_append compiler_flags " $arg" 58498c4a8e55Smrg continue 58508c4a8e55Smrg ;; 5851b042e37fSmrg 58528c4a8e55Smrg # Some other compiler flag. 58538c4a8e55Smrg -* | +*) 58548c4a8e55Smrg func_quote_for_eval "$arg" 58558c4a8e55Smrg arg="$func_quote_for_eval_result" 58568c4a8e55Smrg ;; 5857b042e37fSmrg 58588c4a8e55Smrg *.$objext) 58598c4a8e55Smrg # A standard object. 5860bd23fbfaSmrg func_append objs " $arg" 58618c4a8e55Smrg ;; 5862b042e37fSmrg 58638c4a8e55Smrg *.lo) 58648c4a8e55Smrg # A libtool-controlled object. 5865b042e37fSmrg 58668c4a8e55Smrg # Check to see that this really is a libtool object. 58678c4a8e55Smrg if func_lalib_unsafe_p "$arg"; then 58688c4a8e55Smrg pic_object= 58698c4a8e55Smrg non_pic_object= 5870b042e37fSmrg 58718c4a8e55Smrg # Read the .lo file 58728c4a8e55Smrg func_source "$arg" 5873b042e37fSmrg 58748c4a8e55Smrg if test -z "$pic_object" || 58758c4a8e55Smrg test -z "$non_pic_object" || 58768c4a8e55Smrg test "$pic_object" = none && 58778c4a8e55Smrg test "$non_pic_object" = none; then 58788c4a8e55Smrg func_fatal_error "cannot find name of object for \`$arg'" 58798c4a8e55Smrg fi 5880b042e37fSmrg 58818c4a8e55Smrg # Extract subdirectory from the argument. 58828c4a8e55Smrg func_dirname "$arg" "/" "" 58838c4a8e55Smrg xdir="$func_dirname_result" 5884b042e37fSmrg 58858c4a8e55Smrg if test "$pic_object" != none; then 58868c4a8e55Smrg # Prepend the subdirectory the object is found in. 58878c4a8e55Smrg pic_object="$xdir$pic_object" 5888b042e37fSmrg 58898c4a8e55Smrg if test "$prev" = dlfiles; then 58908c4a8e55Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5891bd23fbfaSmrg func_append dlfiles " $pic_object" 58928c4a8e55Smrg prev= 58938c4a8e55Smrg continue 58948c4a8e55Smrg else 58958c4a8e55Smrg # If libtool objects are unsupported, then we need to preload. 58968c4a8e55Smrg prev=dlprefiles 58978c4a8e55Smrg fi 58988c4a8e55Smrg fi 5899b042e37fSmrg 59008c4a8e55Smrg # CHECK ME: I think I busted this. -Ossama 59018c4a8e55Smrg if test "$prev" = dlprefiles; then 59028c4a8e55Smrg # Preload the old-style object. 5903bd23fbfaSmrg func_append dlprefiles " $pic_object" 59048c4a8e55Smrg prev= 59058c4a8e55Smrg fi 5906b042e37fSmrg 59078c4a8e55Smrg # A PIC object. 59088c4a8e55Smrg func_append libobjs " $pic_object" 59098c4a8e55Smrg arg="$pic_object" 59108c4a8e55Smrg fi 5911b042e37fSmrg 59128c4a8e55Smrg # Non-PIC object. 59138c4a8e55Smrg if test "$non_pic_object" != none; then 59148c4a8e55Smrg # Prepend the subdirectory the object is found in. 59158c4a8e55Smrg non_pic_object="$xdir$non_pic_object" 5916b042e37fSmrg 59178c4a8e55Smrg # A standard non-PIC object 59188c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 59198c4a8e55Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 59208c4a8e55Smrg arg="$non_pic_object" 59218c4a8e55Smrg fi 59228c4a8e55Smrg else 59238c4a8e55Smrg # If the PIC object exists, use it instead. 59248c4a8e55Smrg # $xdir was prepended to $pic_object above. 59258c4a8e55Smrg non_pic_object="$pic_object" 59268c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 59278c4a8e55Smrg fi 59288c4a8e55Smrg else 59298c4a8e55Smrg # Only an error if not doing a dry-run. 59308c4a8e55Smrg if $opt_dry_run; then 59318c4a8e55Smrg # Extract subdirectory from the argument. 59328c4a8e55Smrg func_dirname "$arg" "/" "" 59338c4a8e55Smrg xdir="$func_dirname_result" 59348c4a8e55Smrg 59358c4a8e55Smrg func_lo2o "$arg" 59368c4a8e55Smrg pic_object=$xdir$objdir/$func_lo2o_result 59378c4a8e55Smrg non_pic_object=$xdir$func_lo2o_result 59388c4a8e55Smrg func_append libobjs " $pic_object" 59398c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 59408c4a8e55Smrg else 59418c4a8e55Smrg func_fatal_error "\`$arg' is not a valid libtool object" 59428c4a8e55Smrg fi 59438c4a8e55Smrg fi 59448c4a8e55Smrg ;; 5945b042e37fSmrg 59468c4a8e55Smrg *.$libext) 59478c4a8e55Smrg # An archive. 5948bd23fbfaSmrg func_append deplibs " $arg" 5949bd23fbfaSmrg func_append old_deplibs " $arg" 59508c4a8e55Smrg continue 59518c4a8e55Smrg ;; 5952b042e37fSmrg 59538c4a8e55Smrg *.la) 59548c4a8e55Smrg # A libtool-controlled library. 5955b042e37fSmrg 5956bd23fbfaSmrg func_resolve_sysroot "$arg" 59578c4a8e55Smrg if test "$prev" = dlfiles; then 59588c4a8e55Smrg # This library was specified with -dlopen. 5959bd23fbfaSmrg func_append dlfiles " $func_resolve_sysroot_result" 59608c4a8e55Smrg prev= 59618c4a8e55Smrg elif test "$prev" = dlprefiles; then 59628c4a8e55Smrg # The library was specified with -dlpreopen. 5963bd23fbfaSmrg func_append dlprefiles " $func_resolve_sysroot_result" 59648c4a8e55Smrg prev= 59658c4a8e55Smrg else 5966bd23fbfaSmrg func_append deplibs " $func_resolve_sysroot_result" 59678c4a8e55Smrg fi 59688c4a8e55Smrg continue 59698c4a8e55Smrg ;; 5970b042e37fSmrg 59718c4a8e55Smrg # Some other compiler argument. 59728c4a8e55Smrg *) 59738c4a8e55Smrg # Unknown arguments in both finalize_command and compile_command need 59748c4a8e55Smrg # to be aesthetically quoted because they are evaled later. 59758c4a8e55Smrg func_quote_for_eval "$arg" 59768c4a8e55Smrg arg="$func_quote_for_eval_result" 59778c4a8e55Smrg ;; 59788c4a8e55Smrg esac # arg 5979b042e37fSmrg 59808c4a8e55Smrg # Now actually substitute the argument into the commands. 59818c4a8e55Smrg if test -n "$arg"; then 59828c4a8e55Smrg func_append compile_command " $arg" 59838c4a8e55Smrg func_append finalize_command " $arg" 59848c4a8e55Smrg fi 59858c4a8e55Smrg done # argument parsing loop 5986b042e37fSmrg 59878c4a8e55Smrg test -n "$prev" && \ 59888c4a8e55Smrg func_fatal_help "the \`$prevarg' option requires an argument" 5989b042e37fSmrg 59908c4a8e55Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 59918c4a8e55Smrg eval arg=\"$export_dynamic_flag_spec\" 59928c4a8e55Smrg func_append compile_command " $arg" 59938c4a8e55Smrg func_append finalize_command " $arg" 59948c4a8e55Smrg fi 5995b042e37fSmrg 59968c4a8e55Smrg oldlibs= 59978c4a8e55Smrg # calculate the name of the file, without its directory 59988c4a8e55Smrg func_basename "$output" 59998c4a8e55Smrg outputname="$func_basename_result" 60008c4a8e55Smrg libobjs_save="$libobjs" 60018c4a8e55Smrg 60028c4a8e55Smrg if test -n "$shlibpath_var"; then 60038c4a8e55Smrg # get the directories listed in $shlibpath_var 6004706b6b52Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 6005b042e37fSmrg else 60068c4a8e55Smrg shlib_search_path= 6007b042e37fSmrg fi 60088c4a8e55Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 60098c4a8e55Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 6010b042e37fSmrg 60118c4a8e55Smrg func_dirname "$output" "/" "" 60128c4a8e55Smrg output_objdir="$func_dirname_result$objdir" 6013bd23fbfaSmrg func_to_tool_file "$output_objdir/" 6014bd23fbfaSmrg tool_output_objdir=$func_to_tool_file_result 60158c4a8e55Smrg # Create the object directory. 60168c4a8e55Smrg func_mkdir_p "$output_objdir" 6017b042e37fSmrg 60188c4a8e55Smrg # Determine the type of output 60198c4a8e55Smrg case $output in 60208c4a8e55Smrg "") 60218c4a8e55Smrg func_fatal_help "you must specify an output file" 60228c4a8e55Smrg ;; 60238c4a8e55Smrg *.$libext) linkmode=oldlib ;; 60248c4a8e55Smrg *.lo | *.$objext) linkmode=obj ;; 60258c4a8e55Smrg *.la) linkmode=lib ;; 60268c4a8e55Smrg *) linkmode=prog ;; # Anything else should be a program. 60278c4a8e55Smrg esac 60288c4a8e55Smrg 60298c4a8e55Smrg specialdeplibs= 60308c4a8e55Smrg 60318c4a8e55Smrg libs= 60328c4a8e55Smrg # Find all interdependent deplibs by searching for libraries 60338c4a8e55Smrg # that are linked more than once (e.g. -la -lb -la) 60348c4a8e55Smrg for deplib in $deplibs; do 6035bd23fbfaSmrg if $opt_preserve_dup_deps ; then 60368c4a8e55Smrg case "$libs " in 6037bd23fbfaSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 60388c4a8e55Smrg esac 60398c4a8e55Smrg fi 6040bd23fbfaSmrg func_append libs " $deplib" 60418c4a8e55Smrg done 60428c4a8e55Smrg 60438c4a8e55Smrg if test "$linkmode" = lib; then 60448c4a8e55Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 60458c4a8e55Smrg 60468c4a8e55Smrg # Compute libraries that are listed more than once in $predeps 60478c4a8e55Smrg # $postdeps and mark them as special (i.e., whose duplicates are 60488c4a8e55Smrg # not to be eliminated). 60498c4a8e55Smrg pre_post_deps= 60508c4a8e55Smrg if $opt_duplicate_compiler_generated_deps; then 60518c4a8e55Smrg for pre_post_dep in $predeps $postdeps; do 60528c4a8e55Smrg case "$pre_post_deps " in 6053bd23fbfaSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 60548c4a8e55Smrg esac 6055bd23fbfaSmrg func_append pre_post_deps " $pre_post_dep" 60568c4a8e55Smrg done 60578c4a8e55Smrg fi 60588c4a8e55Smrg pre_post_deps= 60598c4a8e55Smrg fi 60608c4a8e55Smrg 60618c4a8e55Smrg deplibs= 60628c4a8e55Smrg newdependency_libs= 60638c4a8e55Smrg newlib_search_path= 60648c4a8e55Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 60658c4a8e55Smrg notinst_deplibs= # not-installed libtool libraries 60668c4a8e55Smrg notinst_path= # paths that contain not-installed libtool libraries 60678c4a8e55Smrg 60688c4a8e55Smrg case $linkmode in 60698c4a8e55Smrg lib) 60708c4a8e55Smrg passes="conv dlpreopen link" 60718c4a8e55Smrg for file in $dlfiles $dlprefiles; do 60728c4a8e55Smrg case $file in 60738c4a8e55Smrg *.la) ;; 60748c4a8e55Smrg *) 60758c4a8e55Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 60768c4a8e55Smrg ;; 60778c4a8e55Smrg esac 60788c4a8e55Smrg done 60798c4a8e55Smrg ;; 60808c4a8e55Smrg prog) 60818c4a8e55Smrg compile_deplibs= 60828c4a8e55Smrg finalize_deplibs= 60838c4a8e55Smrg alldeplibs=no 60848c4a8e55Smrg newdlfiles= 60858c4a8e55Smrg newdlprefiles= 60868c4a8e55Smrg passes="conv scan dlopen dlpreopen link" 60878c4a8e55Smrg ;; 60888c4a8e55Smrg *) passes="conv" 60898c4a8e55Smrg ;; 60908c4a8e55Smrg esac 60918c4a8e55Smrg 60928c4a8e55Smrg for pass in $passes; do 60938c4a8e55Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 60948c4a8e55Smrg # so that -L comes before libs that need it for instance... 60958c4a8e55Smrg if test "$linkmode,$pass" = "lib,link"; then 60968c4a8e55Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 60978c4a8e55Smrg ## order, and fix it there properly 60988c4a8e55Smrg tmp_deplibs= 60998c4a8e55Smrg for deplib in $deplibs; do 61008c4a8e55Smrg tmp_deplibs="$deplib $tmp_deplibs" 61018c4a8e55Smrg done 61028c4a8e55Smrg deplibs="$tmp_deplibs" 61038c4a8e55Smrg fi 61048c4a8e55Smrg 61058c4a8e55Smrg if test "$linkmode,$pass" = "lib,link" || 61068c4a8e55Smrg test "$linkmode,$pass" = "prog,scan"; then 61078c4a8e55Smrg libs="$deplibs" 61088c4a8e55Smrg deplibs= 61098c4a8e55Smrg fi 61108c4a8e55Smrg if test "$linkmode" = prog; then 61118c4a8e55Smrg case $pass in 61128c4a8e55Smrg dlopen) libs="$dlfiles" ;; 61138c4a8e55Smrg dlpreopen) libs="$dlprefiles" ;; 61148c4a8e55Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 61158c4a8e55Smrg esac 61168c4a8e55Smrg fi 61178c4a8e55Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 61188c4a8e55Smrg # Collect and forward deplibs of preopened libtool libs 61198c4a8e55Smrg for lib in $dlprefiles; do 61208c4a8e55Smrg # Ignore non-libtool-libs 61218c4a8e55Smrg dependency_libs= 6122bd23fbfaSmrg func_resolve_sysroot "$lib" 61238c4a8e55Smrg case $lib in 6124bd23fbfaSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 61258c4a8e55Smrg esac 61268c4a8e55Smrg 61278c4a8e55Smrg # Collect preopened libtool deplibs, except any this library 61288c4a8e55Smrg # has declared as weak libs 61298c4a8e55Smrg for deplib in $dependency_libs; do 6130706b6b52Smrg func_basename "$deplib" 6131706b6b52Smrg deplib_base=$func_basename_result 61328c4a8e55Smrg case " $weak_libs " in 61338c4a8e55Smrg *" $deplib_base "*) ;; 6134bd23fbfaSmrg *) func_append deplibs " $deplib" ;; 61358c4a8e55Smrg esac 61368c4a8e55Smrg done 61378c4a8e55Smrg done 61388c4a8e55Smrg libs="$dlprefiles" 61398c4a8e55Smrg fi 61408c4a8e55Smrg if test "$pass" = dlopen; then 61418c4a8e55Smrg # Collect dlpreopened libraries 61428c4a8e55Smrg save_deplibs="$deplibs" 61438c4a8e55Smrg deplibs= 61448c4a8e55Smrg fi 61458c4a8e55Smrg 61468c4a8e55Smrg for deplib in $libs; do 61478c4a8e55Smrg lib= 61488c4a8e55Smrg found=no 61498c4a8e55Smrg case $deplib in 61508c4a8e55Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 61518c4a8e55Smrg if test "$linkmode,$pass" = "prog,link"; then 61528c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 61538c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 61548c4a8e55Smrg else 6155bd23fbfaSmrg func_append compiler_flags " $deplib" 61568c4a8e55Smrg if test "$linkmode" = lib ; then 61578c4a8e55Smrg case "$new_inherited_linker_flags " in 61588c4a8e55Smrg *" $deplib "*) ;; 6159bd23fbfaSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 61608c4a8e55Smrg esac 61618c4a8e55Smrg fi 61628c4a8e55Smrg fi 61638c4a8e55Smrg continue 61648c4a8e55Smrg ;; 61658c4a8e55Smrg -l*) 61668c4a8e55Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 61678c4a8e55Smrg func_warning "\`-l' is ignored for archives/objects" 61688c4a8e55Smrg continue 61698c4a8e55Smrg fi 61708c4a8e55Smrg func_stripname '-l' '' "$deplib" 61718c4a8e55Smrg name=$func_stripname_result 61728c4a8e55Smrg if test "$linkmode" = lib; then 61738c4a8e55Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 61748c4a8e55Smrg else 61758c4a8e55Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 61768c4a8e55Smrg fi 61778c4a8e55Smrg for searchdir in $searchdirs; do 61788c4a8e55Smrg for search_ext in .la $std_shrext .so .a; do 61798c4a8e55Smrg # Search the libtool library 61808c4a8e55Smrg lib="$searchdir/lib${name}${search_ext}" 61818c4a8e55Smrg if test -f "$lib"; then 61828c4a8e55Smrg if test "$search_ext" = ".la"; then 61838c4a8e55Smrg found=yes 61848c4a8e55Smrg else 61858c4a8e55Smrg found=no 61868c4a8e55Smrg fi 61878c4a8e55Smrg break 2 61888c4a8e55Smrg fi 61898c4a8e55Smrg done 61908c4a8e55Smrg done 61918c4a8e55Smrg if test "$found" != yes; then 61928c4a8e55Smrg # deplib doesn't seem to be a libtool library 61938c4a8e55Smrg if test "$linkmode,$pass" = "prog,link"; then 61948c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 61958c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 61968c4a8e55Smrg else 61978c4a8e55Smrg deplibs="$deplib $deplibs" 61988c4a8e55Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 61998c4a8e55Smrg fi 62008c4a8e55Smrg continue 62018c4a8e55Smrg else # deplib is a libtool library 62028c4a8e55Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 62038c4a8e55Smrg # We need to do some special things here, and not later. 62048c4a8e55Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 62058c4a8e55Smrg case " $predeps $postdeps " in 62068c4a8e55Smrg *" $deplib "*) 62078c4a8e55Smrg if func_lalib_p "$lib"; then 62088c4a8e55Smrg library_names= 62098c4a8e55Smrg old_library= 62108c4a8e55Smrg func_source "$lib" 62118c4a8e55Smrg for l in $old_library $library_names; do 62128c4a8e55Smrg ll="$l" 62138c4a8e55Smrg done 62148c4a8e55Smrg if test "X$ll" = "X$old_library" ; then # only static version available 62158c4a8e55Smrg found=no 62168c4a8e55Smrg func_dirname "$lib" "" "." 62178c4a8e55Smrg ladir="$func_dirname_result" 62188c4a8e55Smrg lib=$ladir/$old_library 62198c4a8e55Smrg if test "$linkmode,$pass" = "prog,link"; then 62208c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 62218c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 62228c4a8e55Smrg else 62238c4a8e55Smrg deplibs="$deplib $deplibs" 62248c4a8e55Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 62258c4a8e55Smrg fi 62268c4a8e55Smrg continue 62278c4a8e55Smrg fi 62288c4a8e55Smrg fi 62298c4a8e55Smrg ;; 62308c4a8e55Smrg *) ;; 62318c4a8e55Smrg esac 62328c4a8e55Smrg fi 62338c4a8e55Smrg fi 62348c4a8e55Smrg ;; # -l 62358c4a8e55Smrg *.ltframework) 62368c4a8e55Smrg if test "$linkmode,$pass" = "prog,link"; then 62378c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 62388c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 62398c4a8e55Smrg else 62408c4a8e55Smrg deplibs="$deplib $deplibs" 62418c4a8e55Smrg if test "$linkmode" = lib ; then 62428c4a8e55Smrg case "$new_inherited_linker_flags " in 62438c4a8e55Smrg *" $deplib "*) ;; 6244bd23fbfaSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 62458c4a8e55Smrg esac 62468c4a8e55Smrg fi 62478c4a8e55Smrg fi 62488c4a8e55Smrg continue 62498c4a8e55Smrg ;; 62508c4a8e55Smrg -L*) 62518c4a8e55Smrg case $linkmode in 62528c4a8e55Smrg lib) 62538c4a8e55Smrg deplibs="$deplib $deplibs" 62548c4a8e55Smrg test "$pass" = conv && continue 62558c4a8e55Smrg newdependency_libs="$deplib $newdependency_libs" 62568c4a8e55Smrg func_stripname '-L' '' "$deplib" 6257bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result" 6258bd23fbfaSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 62598c4a8e55Smrg ;; 62608c4a8e55Smrg prog) 62618c4a8e55Smrg if test "$pass" = conv; then 62628c4a8e55Smrg deplibs="$deplib $deplibs" 62638c4a8e55Smrg continue 62648c4a8e55Smrg fi 62658c4a8e55Smrg if test "$pass" = scan; then 62668c4a8e55Smrg deplibs="$deplib $deplibs" 62678c4a8e55Smrg else 62688c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 62698c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 62708c4a8e55Smrg fi 62718c4a8e55Smrg func_stripname '-L' '' "$deplib" 6272bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result" 6273bd23fbfaSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 62748c4a8e55Smrg ;; 62758c4a8e55Smrg *) 62768c4a8e55Smrg func_warning "\`-L' is ignored for archives/objects" 62778c4a8e55Smrg ;; 62788c4a8e55Smrg esac # linkmode 62798c4a8e55Smrg continue 62808c4a8e55Smrg ;; # -L 62818c4a8e55Smrg -R*) 62828c4a8e55Smrg if test "$pass" = link; then 62838c4a8e55Smrg func_stripname '-R' '' "$deplib" 6284bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result" 6285bd23fbfaSmrg dir=$func_resolve_sysroot_result 62868c4a8e55Smrg # Make sure the xrpath contains only unique directories. 62878c4a8e55Smrg case "$xrpath " in 62888c4a8e55Smrg *" $dir "*) ;; 6289bd23fbfaSmrg *) func_append xrpath " $dir" ;; 62908c4a8e55Smrg esac 62918c4a8e55Smrg fi 62928c4a8e55Smrg deplibs="$deplib $deplibs" 62938c4a8e55Smrg continue 62948c4a8e55Smrg ;; 6295bd23fbfaSmrg *.la) 6296bd23fbfaSmrg func_resolve_sysroot "$deplib" 6297bd23fbfaSmrg lib=$func_resolve_sysroot_result 6298bd23fbfaSmrg ;; 62998c4a8e55Smrg *.$libext) 63008c4a8e55Smrg if test "$pass" = conv; then 63018c4a8e55Smrg deplibs="$deplib $deplibs" 63028c4a8e55Smrg continue 63038c4a8e55Smrg fi 63048c4a8e55Smrg case $linkmode in 63058c4a8e55Smrg lib) 63068c4a8e55Smrg # Linking convenience modules into shared libraries is allowed, 63078c4a8e55Smrg # but linking other static libraries is non-portable. 63088c4a8e55Smrg case " $dlpreconveniencelibs " in 63098c4a8e55Smrg *" $deplib "*) ;; 63108c4a8e55Smrg *) 63118c4a8e55Smrg valid_a_lib=no 63128c4a8e55Smrg case $deplibs_check_method in 63138c4a8e55Smrg match_pattern*) 63148c4a8e55Smrg set dummy $deplibs_check_method; shift 63158c4a8e55Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 6316706b6b52Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 63178c4a8e55Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 63188c4a8e55Smrg valid_a_lib=yes 63198c4a8e55Smrg fi 63208c4a8e55Smrg ;; 63218c4a8e55Smrg pass_all) 63228c4a8e55Smrg valid_a_lib=yes 63238c4a8e55Smrg ;; 63248c4a8e55Smrg esac 63258c4a8e55Smrg if test "$valid_a_lib" != yes; then 6326706b6b52Smrg echo 63278c4a8e55Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 6328706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 6329706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 6330706b6b52Smrg echo "*** shared version of the library, which you do not appear to have" 6331706b6b52Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 6332706b6b52Smrg echo "*** that it is just a static archive that I should not use here." 63338c4a8e55Smrg else 6334706b6b52Smrg echo 63358c4a8e55Smrg $ECHO "*** Warning: Linking the shared library $output against the" 63368c4a8e55Smrg $ECHO "*** static library $deplib is not portable!" 63378c4a8e55Smrg deplibs="$deplib $deplibs" 63388c4a8e55Smrg fi 63398c4a8e55Smrg ;; 63408c4a8e55Smrg esac 63418c4a8e55Smrg continue 63428c4a8e55Smrg ;; 63438c4a8e55Smrg prog) 63448c4a8e55Smrg if test "$pass" != link; then 63458c4a8e55Smrg deplibs="$deplib $deplibs" 63468c4a8e55Smrg else 63478c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 63488c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 63498c4a8e55Smrg fi 63508c4a8e55Smrg continue 63518c4a8e55Smrg ;; 63528c4a8e55Smrg esac # linkmode 63538c4a8e55Smrg ;; # *.$libext 63548c4a8e55Smrg *.lo | *.$objext) 63558c4a8e55Smrg if test "$pass" = conv; then 63568c4a8e55Smrg deplibs="$deplib $deplibs" 63578c4a8e55Smrg elif test "$linkmode" = prog; then 63588c4a8e55Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 63598c4a8e55Smrg # If there is no dlopen support or we're linking statically, 63608c4a8e55Smrg # we need to preload. 6361bd23fbfaSmrg func_append newdlprefiles " $deplib" 63628c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 63638c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 63648c4a8e55Smrg else 6365bd23fbfaSmrg func_append newdlfiles " $deplib" 63668c4a8e55Smrg fi 63678c4a8e55Smrg fi 63688c4a8e55Smrg continue 63698c4a8e55Smrg ;; 63708c4a8e55Smrg %DEPLIBS%) 63718c4a8e55Smrg alldeplibs=yes 63728c4a8e55Smrg continue 63738c4a8e55Smrg ;; 63748c4a8e55Smrg esac # case $deplib 63758c4a8e55Smrg 63768c4a8e55Smrg if test "$found" = yes || test -f "$lib"; then : 63778c4a8e55Smrg else 63788c4a8e55Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 63798c4a8e55Smrg fi 63808c4a8e55Smrg 63818c4a8e55Smrg # Check to see that this really is a libtool archive. 63828c4a8e55Smrg func_lalib_unsafe_p "$lib" \ 63838c4a8e55Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 63848c4a8e55Smrg 63858c4a8e55Smrg func_dirname "$lib" "" "." 63868c4a8e55Smrg ladir="$func_dirname_result" 63878c4a8e55Smrg 63888c4a8e55Smrg dlname= 63898c4a8e55Smrg dlopen= 63908c4a8e55Smrg dlpreopen= 63918c4a8e55Smrg libdir= 63928c4a8e55Smrg library_names= 63938c4a8e55Smrg old_library= 63948c4a8e55Smrg inherited_linker_flags= 63958c4a8e55Smrg # If the library was installed with an old release of libtool, 63968c4a8e55Smrg # it will not redefine variables installed, or shouldnotlink 63978c4a8e55Smrg installed=yes 63988c4a8e55Smrg shouldnotlink=no 63998c4a8e55Smrg avoidtemprpath= 64008c4a8e55Smrg 64018c4a8e55Smrg 64028c4a8e55Smrg # Read the .la file 64038c4a8e55Smrg func_source "$lib" 64048c4a8e55Smrg 64058c4a8e55Smrg # Convert "-framework foo" to "foo.ltframework" 64068c4a8e55Smrg if test -n "$inherited_linker_flags"; then 6407706b6b52Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 64088c4a8e55Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 64098c4a8e55Smrg case " $new_inherited_linker_flags " in 64108c4a8e55Smrg *" $tmp_inherited_linker_flag "*) ;; 6411bd23fbfaSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 64128c4a8e55Smrg esac 64138c4a8e55Smrg done 64148c4a8e55Smrg fi 6415706b6b52Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 64168c4a8e55Smrg if test "$linkmode,$pass" = "lib,link" || 64178c4a8e55Smrg test "$linkmode,$pass" = "prog,scan" || 64188c4a8e55Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 6419bd23fbfaSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 6420bd23fbfaSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 64218c4a8e55Smrg fi 64228c4a8e55Smrg 64238c4a8e55Smrg if test "$pass" = conv; then 64248c4a8e55Smrg # Only check for convenience libraries 64258c4a8e55Smrg deplibs="$lib $deplibs" 64268c4a8e55Smrg if test -z "$libdir"; then 64278c4a8e55Smrg if test -z "$old_library"; then 64288c4a8e55Smrg func_fatal_error "cannot find name of link library for \`$lib'" 64298c4a8e55Smrg fi 64308c4a8e55Smrg # It is a libtool convenience library, so add in its objects. 6431bd23fbfaSmrg func_append convenience " $ladir/$objdir/$old_library" 6432bd23fbfaSmrg func_append old_convenience " $ladir/$objdir/$old_library" 64338c4a8e55Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 64348c4a8e55Smrg func_fatal_error "\`$lib' is not a convenience library" 64358c4a8e55Smrg fi 64368c4a8e55Smrg tmp_libs= 64378c4a8e55Smrg for deplib in $dependency_libs; do 64388c4a8e55Smrg deplibs="$deplib $deplibs" 6439bd23fbfaSmrg if $opt_preserve_dup_deps ; then 64408c4a8e55Smrg case "$tmp_libs " in 6441bd23fbfaSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 64428c4a8e55Smrg esac 64438c4a8e55Smrg fi 6444bd23fbfaSmrg func_append tmp_libs " $deplib" 64458c4a8e55Smrg done 64468c4a8e55Smrg continue 64478c4a8e55Smrg fi # $pass = conv 64488c4a8e55Smrg 64498c4a8e55Smrg 64508c4a8e55Smrg # Get the name of the library we link against. 64518c4a8e55Smrg linklib= 6452bd23fbfaSmrg if test -n "$old_library" && 6453bd23fbfaSmrg { test "$prefer_static_libs" = yes || 6454bd23fbfaSmrg test "$prefer_static_libs,$installed" = "built,no"; }; then 6455bd23fbfaSmrg linklib=$old_library 6456bd23fbfaSmrg else 6457bd23fbfaSmrg for l in $old_library $library_names; do 6458bd23fbfaSmrg linklib="$l" 6459bd23fbfaSmrg done 6460bd23fbfaSmrg fi 64618c4a8e55Smrg if test -z "$linklib"; then 64628c4a8e55Smrg func_fatal_error "cannot find name of link library for \`$lib'" 64638c4a8e55Smrg fi 64648c4a8e55Smrg 64658c4a8e55Smrg # This library was specified with -dlopen. 64668c4a8e55Smrg if test "$pass" = dlopen; then 64678c4a8e55Smrg if test -z "$libdir"; then 64688c4a8e55Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 64698c4a8e55Smrg fi 64708c4a8e55Smrg if test -z "$dlname" || 64718c4a8e55Smrg test "$dlopen_support" != yes || 64728c4a8e55Smrg test "$build_libtool_libs" = no; then 64738c4a8e55Smrg # If there is no dlname, no dlopen support or we're linking 64748c4a8e55Smrg # statically, we need to preload. We also need to preload any 64758c4a8e55Smrg # dependent libraries so libltdl's deplib preloader doesn't 64768c4a8e55Smrg # bomb out in the load deplibs phase. 6477bd23fbfaSmrg func_append dlprefiles " $lib $dependency_libs" 64788c4a8e55Smrg else 6479bd23fbfaSmrg func_append newdlfiles " $lib" 64808c4a8e55Smrg fi 64818c4a8e55Smrg continue 64828c4a8e55Smrg fi # $pass = dlopen 64838c4a8e55Smrg 64848c4a8e55Smrg # We need an absolute path. 64858c4a8e55Smrg case $ladir in 64868c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 64878c4a8e55Smrg *) 64888c4a8e55Smrg abs_ladir=`cd "$ladir" && pwd` 64898c4a8e55Smrg if test -z "$abs_ladir"; then 64908c4a8e55Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 64918c4a8e55Smrg func_warning "passing it literally to the linker, although it might fail" 64928c4a8e55Smrg abs_ladir="$ladir" 64938c4a8e55Smrg fi 64948c4a8e55Smrg ;; 64958c4a8e55Smrg esac 64968c4a8e55Smrg func_basename "$lib" 64978c4a8e55Smrg laname="$func_basename_result" 64988c4a8e55Smrg 64998c4a8e55Smrg # Find the relevant object directory and library name. 65008c4a8e55Smrg if test "X$installed" = Xyes; then 6501bd23fbfaSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 65028c4a8e55Smrg func_warning "library \`$lib' was moved." 65038c4a8e55Smrg dir="$ladir" 65048c4a8e55Smrg absdir="$abs_ladir" 65058c4a8e55Smrg libdir="$abs_ladir" 65068c4a8e55Smrg else 6507bd23fbfaSmrg dir="$lt_sysroot$libdir" 6508bd23fbfaSmrg absdir="$lt_sysroot$libdir" 65098c4a8e55Smrg fi 65108c4a8e55Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 65118c4a8e55Smrg else 65128c4a8e55Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 65138c4a8e55Smrg dir="$ladir" 65148c4a8e55Smrg absdir="$abs_ladir" 65158c4a8e55Smrg # Remove this search path later 6516bd23fbfaSmrg func_append notinst_path " $abs_ladir" 65178c4a8e55Smrg else 65188c4a8e55Smrg dir="$ladir/$objdir" 65198c4a8e55Smrg absdir="$abs_ladir/$objdir" 65208c4a8e55Smrg # Remove this search path later 6521bd23fbfaSmrg func_append notinst_path " $abs_ladir" 65228c4a8e55Smrg fi 65238c4a8e55Smrg fi # $installed = yes 65248c4a8e55Smrg func_stripname 'lib' '.la' "$laname" 65258c4a8e55Smrg name=$func_stripname_result 65268c4a8e55Smrg 65278c4a8e55Smrg # This library was specified with -dlpreopen. 65288c4a8e55Smrg if test "$pass" = dlpreopen; then 65298c4a8e55Smrg if test -z "$libdir" && test "$linkmode" = prog; then 65308c4a8e55Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 65318c4a8e55Smrg fi 6532bd23fbfaSmrg case "$host" in 6533bd23fbfaSmrg # special handling for platforms with PE-DLLs. 6534bd23fbfaSmrg *cygwin* | *mingw* | *cegcc* ) 6535bd23fbfaSmrg # Linker will automatically link against shared library if both 6536bd23fbfaSmrg # static and shared are present. Therefore, ensure we extract 6537bd23fbfaSmrg # symbols from the import library if a shared library is present 6538bd23fbfaSmrg # (otherwise, the dlopen module name will be incorrect). We do 6539bd23fbfaSmrg # this by putting the import library name into $newdlprefiles. 6540bd23fbfaSmrg # We recover the dlopen module name by 'saving' the la file 6541bd23fbfaSmrg # name in a special purpose variable, and (later) extracting the 6542bd23fbfaSmrg # dlname from the la file. 6543bd23fbfaSmrg if test -n "$dlname"; then 6544bd23fbfaSmrg func_tr_sh "$dir/$linklib" 6545bd23fbfaSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 6546bd23fbfaSmrg func_append newdlprefiles " $dir/$linklib" 6547bd23fbfaSmrg else 6548bd23fbfaSmrg func_append newdlprefiles " $dir/$old_library" 6549bd23fbfaSmrg # Keep a list of preopened convenience libraries to check 6550bd23fbfaSmrg # that they are being used correctly in the link pass. 6551bd23fbfaSmrg test -z "$libdir" && \ 6552bd23fbfaSmrg func_append dlpreconveniencelibs " $dir/$old_library" 6553bd23fbfaSmrg fi 6554bd23fbfaSmrg ;; 6555bd23fbfaSmrg * ) 6556bd23fbfaSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 6557bd23fbfaSmrg # are required to link). 6558bd23fbfaSmrg if test -n "$old_library"; then 6559bd23fbfaSmrg func_append newdlprefiles " $dir/$old_library" 6560bd23fbfaSmrg # Keep a list of preopened convenience libraries to check 6561bd23fbfaSmrg # that they are being used correctly in the link pass. 6562bd23fbfaSmrg test -z "$libdir" && \ 6563bd23fbfaSmrg func_append dlpreconveniencelibs " $dir/$old_library" 6564bd23fbfaSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 6565bd23fbfaSmrg elif test -n "$dlname"; then 6566bd23fbfaSmrg func_append newdlprefiles " $dir/$dlname" 6567bd23fbfaSmrg else 6568bd23fbfaSmrg func_append newdlprefiles " $dir/$linklib" 6569bd23fbfaSmrg fi 6570bd23fbfaSmrg ;; 6571bd23fbfaSmrg esac 65728c4a8e55Smrg fi # $pass = dlpreopen 65738c4a8e55Smrg 65748c4a8e55Smrg if test -z "$libdir"; then 65758c4a8e55Smrg # Link the convenience library 65768c4a8e55Smrg if test "$linkmode" = lib; then 65778c4a8e55Smrg deplibs="$dir/$old_library $deplibs" 65788c4a8e55Smrg elif test "$linkmode,$pass" = "prog,link"; then 65798c4a8e55Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 65808c4a8e55Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 65818c4a8e55Smrg else 65828c4a8e55Smrg deplibs="$lib $deplibs" # used for prog,scan pass 65838c4a8e55Smrg fi 65848c4a8e55Smrg continue 65858c4a8e55Smrg fi 65868c4a8e55Smrg 65878c4a8e55Smrg 65888c4a8e55Smrg if test "$linkmode" = prog && test "$pass" != link; then 6589bd23fbfaSmrg func_append newlib_search_path " $ladir" 65908c4a8e55Smrg deplibs="$lib $deplibs" 65918c4a8e55Smrg 65928c4a8e55Smrg linkalldeplibs=no 65938c4a8e55Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 65948c4a8e55Smrg test "$build_libtool_libs" = no; then 65958c4a8e55Smrg linkalldeplibs=yes 65968c4a8e55Smrg fi 65978c4a8e55Smrg 65988c4a8e55Smrg tmp_libs= 65998c4a8e55Smrg for deplib in $dependency_libs; do 66008c4a8e55Smrg case $deplib in 66018c4a8e55Smrg -L*) func_stripname '-L' '' "$deplib" 6602bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result" 6603bd23fbfaSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 66048c4a8e55Smrg ;; 66058c4a8e55Smrg esac 66068c4a8e55Smrg # Need to link against all dependency_libs? 66078c4a8e55Smrg if test "$linkalldeplibs" = yes; then 66088c4a8e55Smrg deplibs="$deplib $deplibs" 66098c4a8e55Smrg else 66108c4a8e55Smrg # Need to hardcode shared library paths 66118c4a8e55Smrg # or/and link against static libraries 66128c4a8e55Smrg newdependency_libs="$deplib $newdependency_libs" 66138c4a8e55Smrg fi 6614bd23fbfaSmrg if $opt_preserve_dup_deps ; then 66158c4a8e55Smrg case "$tmp_libs " in 6616bd23fbfaSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 66178c4a8e55Smrg esac 66188c4a8e55Smrg fi 6619bd23fbfaSmrg func_append tmp_libs " $deplib" 66208c4a8e55Smrg done # for deplib 66218c4a8e55Smrg continue 66228c4a8e55Smrg fi # $linkmode = prog... 66238c4a8e55Smrg 66248c4a8e55Smrg if test "$linkmode,$pass" = "prog,link"; then 66258c4a8e55Smrg if test -n "$library_names" && 66268c4a8e55Smrg { { test "$prefer_static_libs" = no || 66278c4a8e55Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 66288c4a8e55Smrg test -z "$old_library"; }; then 66298c4a8e55Smrg # We need to hardcode the library path 66308c4a8e55Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 66318c4a8e55Smrg # Make sure the rpath contains only unique directories. 66328c4a8e55Smrg case "$temp_rpath:" in 66338c4a8e55Smrg *"$absdir:"*) ;; 6634bd23fbfaSmrg *) func_append temp_rpath "$absdir:" ;; 66358c4a8e55Smrg esac 66368c4a8e55Smrg fi 66378c4a8e55Smrg 66388c4a8e55Smrg # Hardcode the library path. 66398c4a8e55Smrg # Skip directories that are in the system default run-time 66408c4a8e55Smrg # search path. 66418c4a8e55Smrg case " $sys_lib_dlsearch_path " in 66428c4a8e55Smrg *" $absdir "*) ;; 66438c4a8e55Smrg *) 66448c4a8e55Smrg case "$compile_rpath " in 66458c4a8e55Smrg *" $absdir "*) ;; 6646bd23fbfaSmrg *) func_append compile_rpath " $absdir" ;; 66478c4a8e55Smrg esac 66488c4a8e55Smrg ;; 66498c4a8e55Smrg esac 66508c4a8e55Smrg case " $sys_lib_dlsearch_path " in 66518c4a8e55Smrg *" $libdir "*) ;; 66528c4a8e55Smrg *) 66538c4a8e55Smrg case "$finalize_rpath " in 66548c4a8e55Smrg *" $libdir "*) ;; 6655bd23fbfaSmrg *) func_append finalize_rpath " $libdir" ;; 66568c4a8e55Smrg esac 66578c4a8e55Smrg ;; 66588c4a8e55Smrg esac 66598c4a8e55Smrg fi # $linkmode,$pass = prog,link... 66608c4a8e55Smrg 66618c4a8e55Smrg if test "$alldeplibs" = yes && 66628c4a8e55Smrg { test "$deplibs_check_method" = pass_all || 66638c4a8e55Smrg { test "$build_libtool_libs" = yes && 66648c4a8e55Smrg test -n "$library_names"; }; }; then 66658c4a8e55Smrg # We only need to search for static libraries 66668c4a8e55Smrg continue 66678c4a8e55Smrg fi 66688c4a8e55Smrg fi 66698c4a8e55Smrg 66708c4a8e55Smrg link_static=no # Whether the deplib will be linked statically 66718c4a8e55Smrg use_static_libs=$prefer_static_libs 66728c4a8e55Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 66738c4a8e55Smrg use_static_libs=no 66748c4a8e55Smrg fi 66758c4a8e55Smrg if test -n "$library_names" && 66768c4a8e55Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 66778c4a8e55Smrg case $host in 66788c4a8e55Smrg *cygwin* | *mingw* | *cegcc*) 66798c4a8e55Smrg # No point in relinking DLLs because paths are not encoded 6680bd23fbfaSmrg func_append notinst_deplibs " $lib" 66818c4a8e55Smrg need_relink=no 66828c4a8e55Smrg ;; 66838c4a8e55Smrg *) 66848c4a8e55Smrg if test "$installed" = no; then 6685bd23fbfaSmrg func_append notinst_deplibs " $lib" 66868c4a8e55Smrg need_relink=yes 66878c4a8e55Smrg fi 66888c4a8e55Smrg ;; 66898c4a8e55Smrg esac 66908c4a8e55Smrg # This is a shared library 66918c4a8e55Smrg 66928c4a8e55Smrg # Warn about portability, can't link against -module's on some 66938c4a8e55Smrg # systems (darwin). Don't bleat about dlopened modules though! 66948c4a8e55Smrg dlopenmodule="" 66958c4a8e55Smrg for dlpremoduletest in $dlprefiles; do 66968c4a8e55Smrg if test "X$dlpremoduletest" = "X$lib"; then 66978c4a8e55Smrg dlopenmodule="$dlpremoduletest" 66988c4a8e55Smrg break 66998c4a8e55Smrg fi 67008c4a8e55Smrg done 67018c4a8e55Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 6702706b6b52Smrg echo 67038c4a8e55Smrg if test "$linkmode" = prog; then 67048c4a8e55Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 67058c4a8e55Smrg else 67068c4a8e55Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 67078c4a8e55Smrg fi 67088c4a8e55Smrg $ECHO "*** $linklib is not portable!" 67098c4a8e55Smrg fi 67108c4a8e55Smrg if test "$linkmode" = lib && 67118c4a8e55Smrg test "$hardcode_into_libs" = yes; then 67128c4a8e55Smrg # Hardcode the library path. 67138c4a8e55Smrg # Skip directories that are in the system default run-time 67148c4a8e55Smrg # search path. 67158c4a8e55Smrg case " $sys_lib_dlsearch_path " in 67168c4a8e55Smrg *" $absdir "*) ;; 67178c4a8e55Smrg *) 67188c4a8e55Smrg case "$compile_rpath " in 67198c4a8e55Smrg *" $absdir "*) ;; 6720bd23fbfaSmrg *) func_append compile_rpath " $absdir" ;; 67218c4a8e55Smrg esac 67228c4a8e55Smrg ;; 67238c4a8e55Smrg esac 67248c4a8e55Smrg case " $sys_lib_dlsearch_path " in 67258c4a8e55Smrg *" $libdir "*) ;; 67268c4a8e55Smrg *) 67278c4a8e55Smrg case "$finalize_rpath " in 67288c4a8e55Smrg *" $libdir "*) ;; 6729bd23fbfaSmrg *) func_append finalize_rpath " $libdir" ;; 67308c4a8e55Smrg esac 67318c4a8e55Smrg ;; 67328c4a8e55Smrg esac 67338c4a8e55Smrg fi 67348c4a8e55Smrg 67358c4a8e55Smrg if test -n "$old_archive_from_expsyms_cmds"; then 67368c4a8e55Smrg # figure out the soname 67378c4a8e55Smrg set dummy $library_names 67388c4a8e55Smrg shift 67398c4a8e55Smrg realname="$1" 67408c4a8e55Smrg shift 67418c4a8e55Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 67428c4a8e55Smrg # use dlname if we got it. it's perfectly good, no? 67438c4a8e55Smrg if test -n "$dlname"; then 67448c4a8e55Smrg soname="$dlname" 67458c4a8e55Smrg elif test -n "$soname_spec"; then 67468c4a8e55Smrg # bleh windows 67478c4a8e55Smrg case $host in 67488c4a8e55Smrg *cygwin* | mingw* | *cegcc*) 67498c4a8e55Smrg func_arith $current - $age 67508c4a8e55Smrg major=$func_arith_result 67518c4a8e55Smrg versuffix="-$major" 67528c4a8e55Smrg ;; 67538c4a8e55Smrg esac 67548c4a8e55Smrg eval soname=\"$soname_spec\" 67558c4a8e55Smrg else 67568c4a8e55Smrg soname="$realname" 67578c4a8e55Smrg fi 67588c4a8e55Smrg 67598c4a8e55Smrg # Make a new name for the extract_expsyms_cmds to use 67608c4a8e55Smrg soroot="$soname" 67618c4a8e55Smrg func_basename "$soroot" 67628c4a8e55Smrg soname="$func_basename_result" 67638c4a8e55Smrg func_stripname 'lib' '.dll' "$soname" 67648c4a8e55Smrg newlib=libimp-$func_stripname_result.a 67658c4a8e55Smrg 67668c4a8e55Smrg # If the library has no export list, then create one now 67678c4a8e55Smrg if test -f "$output_objdir/$soname-def"; then : 67688c4a8e55Smrg else 67698c4a8e55Smrg func_verbose "extracting exported symbol list from \`$soname'" 67708c4a8e55Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 67718c4a8e55Smrg fi 67728c4a8e55Smrg 67738c4a8e55Smrg # Create $newlib 67748c4a8e55Smrg if test -f "$output_objdir/$newlib"; then :; else 67758c4a8e55Smrg func_verbose "generating import library for \`$soname'" 67768c4a8e55Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 67778c4a8e55Smrg fi 67788c4a8e55Smrg # make sure the library variables are pointing to the new library 67798c4a8e55Smrg dir=$output_objdir 67808c4a8e55Smrg linklib=$newlib 67818c4a8e55Smrg fi # test -n "$old_archive_from_expsyms_cmds" 67828c4a8e55Smrg 6783bd23fbfaSmrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 67848c4a8e55Smrg add_shlibpath= 67858c4a8e55Smrg add_dir= 67868c4a8e55Smrg add= 67878c4a8e55Smrg lib_linked=yes 67888c4a8e55Smrg case $hardcode_action in 67898c4a8e55Smrg immediate | unsupported) 67908c4a8e55Smrg if test "$hardcode_direct" = no; then 67918c4a8e55Smrg add="$dir/$linklib" 67928c4a8e55Smrg case $host in 67938c4a8e55Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 67948c4a8e55Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 67958c4a8e55Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 67968c4a8e55Smrg *-*-unixware7*) add_dir="-L$dir" ;; 67978c4a8e55Smrg *-*-darwin* ) 67988c4a8e55Smrg # if the lib is a (non-dlopened) module then we can not 67998c4a8e55Smrg # link against it, someone is ignoring the earlier warnings 68008c4a8e55Smrg if /usr/bin/file -L $add 2> /dev/null | 68018c4a8e55Smrg $GREP ": [^:]* bundle" >/dev/null ; then 68028c4a8e55Smrg if test "X$dlopenmodule" != "X$lib"; then 68038c4a8e55Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 68048c4a8e55Smrg if test -z "$old_library" ; then 6805706b6b52Smrg echo 6806706b6b52Smrg echo "*** And there doesn't seem to be a static archive available" 6807706b6b52Smrg echo "*** The link will probably fail, sorry" 68088c4a8e55Smrg else 68098c4a8e55Smrg add="$dir/$old_library" 68108c4a8e55Smrg fi 68118c4a8e55Smrg elif test -n "$old_library"; then 68128c4a8e55Smrg add="$dir/$old_library" 68138c4a8e55Smrg fi 68148c4a8e55Smrg fi 68158c4a8e55Smrg esac 68168c4a8e55Smrg elif test "$hardcode_minus_L" = no; then 68178c4a8e55Smrg case $host in 68188c4a8e55Smrg *-*-sunos*) add_shlibpath="$dir" ;; 68198c4a8e55Smrg esac 68208c4a8e55Smrg add_dir="-L$dir" 68218c4a8e55Smrg add="-l$name" 68228c4a8e55Smrg elif test "$hardcode_shlibpath_var" = no; then 68238c4a8e55Smrg add_shlibpath="$dir" 68248c4a8e55Smrg add="-l$name" 68258c4a8e55Smrg else 68268c4a8e55Smrg lib_linked=no 68278c4a8e55Smrg fi 68288c4a8e55Smrg ;; 68298c4a8e55Smrg relink) 68308c4a8e55Smrg if test "$hardcode_direct" = yes && 68318c4a8e55Smrg test "$hardcode_direct_absolute" = no; then 68328c4a8e55Smrg add="$dir/$linklib" 68338c4a8e55Smrg elif test "$hardcode_minus_L" = yes; then 68348c4a8e55Smrg add_dir="-L$dir" 68358c4a8e55Smrg # Try looking first in the location we're being installed to. 68368c4a8e55Smrg if test -n "$inst_prefix_dir"; then 68378c4a8e55Smrg case $libdir in 68388c4a8e55Smrg [\\/]*) 6839bd23fbfaSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 68408c4a8e55Smrg ;; 68418c4a8e55Smrg esac 68428c4a8e55Smrg fi 68438c4a8e55Smrg add="-l$name" 68448c4a8e55Smrg elif test "$hardcode_shlibpath_var" = yes; then 68458c4a8e55Smrg add_shlibpath="$dir" 68468c4a8e55Smrg add="-l$name" 68478c4a8e55Smrg else 68488c4a8e55Smrg lib_linked=no 68498c4a8e55Smrg fi 68508c4a8e55Smrg ;; 68518c4a8e55Smrg *) lib_linked=no ;; 68528c4a8e55Smrg esac 68538c4a8e55Smrg 68548c4a8e55Smrg if test "$lib_linked" != yes; then 68558c4a8e55Smrg func_fatal_configuration "unsupported hardcode properties" 68568c4a8e55Smrg fi 68578c4a8e55Smrg 68588c4a8e55Smrg if test -n "$add_shlibpath"; then 68598c4a8e55Smrg case :$compile_shlibpath: in 68608c4a8e55Smrg *":$add_shlibpath:"*) ;; 6861bd23fbfaSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 68628c4a8e55Smrg esac 68638c4a8e55Smrg fi 68648c4a8e55Smrg if test "$linkmode" = prog; then 68658c4a8e55Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 68668c4a8e55Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 68678c4a8e55Smrg else 68688c4a8e55Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 68698c4a8e55Smrg test -n "$add" && deplibs="$add $deplibs" 68708c4a8e55Smrg if test "$hardcode_direct" != yes && 68718c4a8e55Smrg test "$hardcode_minus_L" != yes && 68728c4a8e55Smrg test "$hardcode_shlibpath_var" = yes; then 68738c4a8e55Smrg case :$finalize_shlibpath: in 68748c4a8e55Smrg *":$libdir:"*) ;; 6875bd23fbfaSmrg *) func_append finalize_shlibpath "$libdir:" ;; 68768c4a8e55Smrg esac 68778c4a8e55Smrg fi 68788c4a8e55Smrg fi 68798c4a8e55Smrg fi 68808c4a8e55Smrg 6881bd23fbfaSmrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 68828c4a8e55Smrg add_shlibpath= 68838c4a8e55Smrg add_dir= 68848c4a8e55Smrg add= 68858c4a8e55Smrg # Finalize command for both is simple: just hardcode it. 68868c4a8e55Smrg if test "$hardcode_direct" = yes && 68878c4a8e55Smrg test "$hardcode_direct_absolute" = no; then 68888c4a8e55Smrg add="$libdir/$linklib" 68898c4a8e55Smrg elif test "$hardcode_minus_L" = yes; then 68908c4a8e55Smrg add_dir="-L$libdir" 68918c4a8e55Smrg add="-l$name" 68928c4a8e55Smrg elif test "$hardcode_shlibpath_var" = yes; then 68938c4a8e55Smrg case :$finalize_shlibpath: in 68948c4a8e55Smrg *":$libdir:"*) ;; 6895bd23fbfaSmrg *) func_append finalize_shlibpath "$libdir:" ;; 68968c4a8e55Smrg esac 68978c4a8e55Smrg add="-l$name" 68988c4a8e55Smrg elif test "$hardcode_automatic" = yes; then 68998c4a8e55Smrg if test -n "$inst_prefix_dir" && 69008c4a8e55Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 69018c4a8e55Smrg add="$inst_prefix_dir$libdir/$linklib" 69028c4a8e55Smrg else 69038c4a8e55Smrg add="$libdir/$linklib" 69048c4a8e55Smrg fi 69058c4a8e55Smrg else 69068c4a8e55Smrg # We cannot seem to hardcode it, guess we'll fake it. 69078c4a8e55Smrg add_dir="-L$libdir" 69088c4a8e55Smrg # Try looking first in the location we're being installed to. 69098c4a8e55Smrg if test -n "$inst_prefix_dir"; then 69108c4a8e55Smrg case $libdir in 69118c4a8e55Smrg [\\/]*) 6912bd23fbfaSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 69138c4a8e55Smrg ;; 69148c4a8e55Smrg esac 69158c4a8e55Smrg fi 69168c4a8e55Smrg add="-l$name" 69178c4a8e55Smrg fi 69188c4a8e55Smrg 69198c4a8e55Smrg if test "$linkmode" = prog; then 69208c4a8e55Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 69218c4a8e55Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 69228c4a8e55Smrg else 69238c4a8e55Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 69248c4a8e55Smrg test -n "$add" && deplibs="$add $deplibs" 69258c4a8e55Smrg fi 69268c4a8e55Smrg fi 69278c4a8e55Smrg elif test "$linkmode" = prog; then 69288c4a8e55Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 69298c4a8e55Smrg # is not unsupported. This is valid on all known static and 69308c4a8e55Smrg # shared platforms. 69318c4a8e55Smrg if test "$hardcode_direct" != unsupported; then 69328c4a8e55Smrg test -n "$old_library" && linklib="$old_library" 69338c4a8e55Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 69348c4a8e55Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 69358c4a8e55Smrg else 69368c4a8e55Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 69378c4a8e55Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 69388c4a8e55Smrg fi 69398c4a8e55Smrg elif test "$build_libtool_libs" = yes; then 69408c4a8e55Smrg # Not a shared library 69418c4a8e55Smrg if test "$deplibs_check_method" != pass_all; then 69428c4a8e55Smrg # We're trying link a shared library against a static one 69438c4a8e55Smrg # but the system doesn't support it. 69448c4a8e55Smrg 69458c4a8e55Smrg # Just print a warning and add the library to dependency_libs so 69468c4a8e55Smrg # that the program can be linked against the static library. 6947706b6b52Smrg echo 69488c4a8e55Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 6949706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 6950706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 6951706b6b52Smrg echo "*** shared version of the library, which you do not appear to have." 69528c4a8e55Smrg if test "$module" = yes; then 6953706b6b52Smrg echo "*** But as you try to build a module library, libtool will still create " 6954706b6b52Smrg echo "*** a static module, that should work as long as the dlopening application" 6955706b6b52Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 69568c4a8e55Smrg if test -z "$global_symbol_pipe"; then 6957706b6b52Smrg echo 6958706b6b52Smrg echo "*** However, this would only work if libtool was able to extract symbol" 6959706b6b52Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 6960706b6b52Smrg echo "*** not find such a program. So, this module is probably useless." 6961706b6b52Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 69628c4a8e55Smrg fi 69638c4a8e55Smrg if test "$build_old_libs" = no; then 69648c4a8e55Smrg build_libtool_libs=module 69658c4a8e55Smrg build_old_libs=yes 69668c4a8e55Smrg else 69678c4a8e55Smrg build_libtool_libs=no 69688c4a8e55Smrg fi 69698c4a8e55Smrg fi 69708c4a8e55Smrg else 69718c4a8e55Smrg deplibs="$dir/$old_library $deplibs" 69728c4a8e55Smrg link_static=yes 69738c4a8e55Smrg fi 69748c4a8e55Smrg fi # link shared/static library? 69758c4a8e55Smrg 69768c4a8e55Smrg if test "$linkmode" = lib; then 69778c4a8e55Smrg if test -n "$dependency_libs" && 69788c4a8e55Smrg { test "$hardcode_into_libs" != yes || 69798c4a8e55Smrg test "$build_old_libs" = yes || 69808c4a8e55Smrg test "$link_static" = yes; }; then 69818c4a8e55Smrg # Extract -R from dependency_libs 69828c4a8e55Smrg temp_deplibs= 69838c4a8e55Smrg for libdir in $dependency_libs; do 69848c4a8e55Smrg case $libdir in 69858c4a8e55Smrg -R*) func_stripname '-R' '' "$libdir" 69868c4a8e55Smrg temp_xrpath=$func_stripname_result 69878c4a8e55Smrg case " $xrpath " in 69888c4a8e55Smrg *" $temp_xrpath "*) ;; 6989bd23fbfaSmrg *) func_append xrpath " $temp_xrpath";; 69908c4a8e55Smrg esac;; 6991bd23fbfaSmrg *) func_append temp_deplibs " $libdir";; 69928c4a8e55Smrg esac 69938c4a8e55Smrg done 69948c4a8e55Smrg dependency_libs="$temp_deplibs" 69958c4a8e55Smrg fi 69968c4a8e55Smrg 6997bd23fbfaSmrg func_append newlib_search_path " $absdir" 69988c4a8e55Smrg # Link against this library 69998c4a8e55Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 70008c4a8e55Smrg # ... and its dependency_libs 70018c4a8e55Smrg tmp_libs= 70028c4a8e55Smrg for deplib in $dependency_libs; do 70038c4a8e55Smrg newdependency_libs="$deplib $newdependency_libs" 7004bd23fbfaSmrg case $deplib in 7005bd23fbfaSmrg -L*) func_stripname '-L' '' "$deplib" 7006bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result";; 7007bd23fbfaSmrg *) func_resolve_sysroot "$deplib" ;; 7008bd23fbfaSmrg esac 7009bd23fbfaSmrg if $opt_preserve_dup_deps ; then 70108c4a8e55Smrg case "$tmp_libs " in 7011bd23fbfaSmrg *" $func_resolve_sysroot_result "*) 7012bd23fbfaSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 70138c4a8e55Smrg esac 70148c4a8e55Smrg fi 7015bd23fbfaSmrg func_append tmp_libs " $func_resolve_sysroot_result" 70168c4a8e55Smrg done 70178c4a8e55Smrg 70188c4a8e55Smrg if test "$link_all_deplibs" != no; then 70198c4a8e55Smrg # Add the search paths of all dependency libraries 70208c4a8e55Smrg for deplib in $dependency_libs; do 7021706b6b52Smrg path= 70228c4a8e55Smrg case $deplib in 70238c4a8e55Smrg -L*) path="$deplib" ;; 70248c4a8e55Smrg *.la) 7025bd23fbfaSmrg func_resolve_sysroot "$deplib" 7026bd23fbfaSmrg deplib=$func_resolve_sysroot_result 70278c4a8e55Smrg func_dirname "$deplib" "" "." 7028bd23fbfaSmrg dir=$func_dirname_result 70298c4a8e55Smrg # We need an absolute path. 70308c4a8e55Smrg case $dir in 70318c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 70328c4a8e55Smrg *) 70338c4a8e55Smrg absdir=`cd "$dir" && pwd` 70348c4a8e55Smrg if test -z "$absdir"; then 70358c4a8e55Smrg func_warning "cannot determine absolute directory name of \`$dir'" 70368c4a8e55Smrg absdir="$dir" 70378c4a8e55Smrg fi 70388c4a8e55Smrg ;; 70398c4a8e55Smrg esac 70408c4a8e55Smrg if $GREP "^installed=no" $deplib > /dev/null; then 70418c4a8e55Smrg case $host in 70428c4a8e55Smrg *-*-darwin*) 70438c4a8e55Smrg depdepl= 70448c4a8e55Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 70458c4a8e55Smrg if test -n "$deplibrary_names" ; then 70468c4a8e55Smrg for tmp in $deplibrary_names ; do 70478c4a8e55Smrg depdepl=$tmp 70488c4a8e55Smrg done 70498c4a8e55Smrg if test -f "$absdir/$objdir/$depdepl" ; then 70508c4a8e55Smrg depdepl="$absdir/$objdir/$depdepl" 70518c4a8e55Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 70528c4a8e55Smrg if test -z "$darwin_install_name"; then 70538c4a8e55Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 70548c4a8e55Smrg fi 7055bd23fbfaSmrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 7056bd23fbfaSmrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 70578c4a8e55Smrg path= 70588c4a8e55Smrg fi 70598c4a8e55Smrg fi 70608c4a8e55Smrg ;; 70618c4a8e55Smrg *) 70628c4a8e55Smrg path="-L$absdir/$objdir" 70638c4a8e55Smrg ;; 70648c4a8e55Smrg esac 70658c4a8e55Smrg else 70668c4a8e55Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 70678c4a8e55Smrg test -z "$libdir" && \ 70688c4a8e55Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 70698c4a8e55Smrg test "$absdir" != "$libdir" && \ 70708c4a8e55Smrg func_warning "\`$deplib' seems to be moved" 70718c4a8e55Smrg 70728c4a8e55Smrg path="-L$absdir" 70738c4a8e55Smrg fi 70748c4a8e55Smrg ;; 70758c4a8e55Smrg esac 70768c4a8e55Smrg case " $deplibs " in 70778c4a8e55Smrg *" $path "*) ;; 70788c4a8e55Smrg *) deplibs="$path $deplibs" ;; 70798c4a8e55Smrg esac 70808c4a8e55Smrg done 70818c4a8e55Smrg fi # link_all_deplibs != no 70828c4a8e55Smrg fi # linkmode = lib 70838c4a8e55Smrg done # for deplib in $libs 70848c4a8e55Smrg if test "$pass" = link; then 70858c4a8e55Smrg if test "$linkmode" = "prog"; then 70868c4a8e55Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 70878c4a8e55Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 70888c4a8e55Smrg else 7089706b6b52Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 70908c4a8e55Smrg fi 70918c4a8e55Smrg fi 70928c4a8e55Smrg dependency_libs="$newdependency_libs" 70938c4a8e55Smrg if test "$pass" = dlpreopen; then 70948c4a8e55Smrg # Link the dlpreopened libraries before other libraries 70958c4a8e55Smrg for deplib in $save_deplibs; do 70968c4a8e55Smrg deplibs="$deplib $deplibs" 70978c4a8e55Smrg done 70988c4a8e55Smrg fi 70998c4a8e55Smrg if test "$pass" != dlopen; then 71008c4a8e55Smrg if test "$pass" != conv; then 71018c4a8e55Smrg # Make sure lib_search_path contains only unique directories. 71028c4a8e55Smrg lib_search_path= 71038c4a8e55Smrg for dir in $newlib_search_path; do 71048c4a8e55Smrg case "$lib_search_path " in 71058c4a8e55Smrg *" $dir "*) ;; 7106bd23fbfaSmrg *) func_append lib_search_path " $dir" ;; 71078c4a8e55Smrg esac 71088c4a8e55Smrg done 71098c4a8e55Smrg newlib_search_path= 71108c4a8e55Smrg fi 71118c4a8e55Smrg 71128c4a8e55Smrg if test "$linkmode,$pass" != "prog,link"; then 71138c4a8e55Smrg vars="deplibs" 71148c4a8e55Smrg else 71158c4a8e55Smrg vars="compile_deplibs finalize_deplibs" 71168c4a8e55Smrg fi 71178c4a8e55Smrg for var in $vars dependency_libs; do 71188c4a8e55Smrg # Add libraries to $var in reverse order 71198c4a8e55Smrg eval tmp_libs=\"\$$var\" 71208c4a8e55Smrg new_libs= 71218c4a8e55Smrg for deplib in $tmp_libs; do 71228c4a8e55Smrg # FIXME: Pedantically, this is the right thing to do, so 71238c4a8e55Smrg # that some nasty dependency loop isn't accidentally 71248c4a8e55Smrg # broken: 71258c4a8e55Smrg #new_libs="$deplib $new_libs" 71268c4a8e55Smrg # Pragmatically, this seems to cause very few problems in 71278c4a8e55Smrg # practice: 71288c4a8e55Smrg case $deplib in 71298c4a8e55Smrg -L*) new_libs="$deplib $new_libs" ;; 71308c4a8e55Smrg -R*) ;; 71318c4a8e55Smrg *) 71328c4a8e55Smrg # And here is the reason: when a library appears more 71338c4a8e55Smrg # than once as an explicit dependence of a library, or 71348c4a8e55Smrg # is implicitly linked in more than once by the 71358c4a8e55Smrg # compiler, it is considered special, and multiple 71368c4a8e55Smrg # occurrences thereof are not removed. Compare this 71378c4a8e55Smrg # with having the same library being listed as a 71388c4a8e55Smrg # dependency of multiple other libraries: in this case, 71398c4a8e55Smrg # we know (pedantically, we assume) the library does not 71408c4a8e55Smrg # need to be listed more than once, so we keep only the 71418c4a8e55Smrg # last copy. This is not always right, but it is rare 71428c4a8e55Smrg # enough that we require users that really mean to play 71438c4a8e55Smrg # such unportable linking tricks to link the library 71448c4a8e55Smrg # using -Wl,-lname, so that libtool does not consider it 71458c4a8e55Smrg # for duplicate removal. 71468c4a8e55Smrg case " $specialdeplibs " in 71478c4a8e55Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 71488c4a8e55Smrg *) 71498c4a8e55Smrg case " $new_libs " in 71508c4a8e55Smrg *" $deplib "*) ;; 71518c4a8e55Smrg *) new_libs="$deplib $new_libs" ;; 71528c4a8e55Smrg esac 71538c4a8e55Smrg ;; 71548c4a8e55Smrg esac 71558c4a8e55Smrg ;; 71568c4a8e55Smrg esac 71578c4a8e55Smrg done 71588c4a8e55Smrg tmp_libs= 71598c4a8e55Smrg for deplib in $new_libs; do 71608c4a8e55Smrg case $deplib in 71618c4a8e55Smrg -L*) 71628c4a8e55Smrg case " $tmp_libs " in 71638c4a8e55Smrg *" $deplib "*) ;; 7164bd23fbfaSmrg *) func_append tmp_libs " $deplib" ;; 71658c4a8e55Smrg esac 71668c4a8e55Smrg ;; 7167bd23fbfaSmrg *) func_append tmp_libs " $deplib" ;; 71688c4a8e55Smrg esac 71698c4a8e55Smrg done 71708c4a8e55Smrg eval $var=\"$tmp_libs\" 71718c4a8e55Smrg done # for var 71728c4a8e55Smrg fi 71738c4a8e55Smrg # Last step: remove runtime libs from dependency_libs 71748c4a8e55Smrg # (they stay in deplibs) 71758c4a8e55Smrg tmp_libs= 71768c4a8e55Smrg for i in $dependency_libs ; do 71778c4a8e55Smrg case " $predeps $postdeps $compiler_lib_search_path " in 71788c4a8e55Smrg *" $i "*) 71798c4a8e55Smrg i="" 71808c4a8e55Smrg ;; 71818c4a8e55Smrg esac 71828c4a8e55Smrg if test -n "$i" ; then 7183bd23fbfaSmrg func_append tmp_libs " $i" 71848c4a8e55Smrg fi 71858c4a8e55Smrg done 71868c4a8e55Smrg dependency_libs=$tmp_libs 71878c4a8e55Smrg done # for pass 71888c4a8e55Smrg if test "$linkmode" = prog; then 71898c4a8e55Smrg dlfiles="$newdlfiles" 71908c4a8e55Smrg fi 71918c4a8e55Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 71928c4a8e55Smrg dlprefiles="$newdlprefiles" 71938c4a8e55Smrg fi 71948c4a8e55Smrg 71958c4a8e55Smrg case $linkmode in 71968c4a8e55Smrg oldlib) 71978c4a8e55Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 71988c4a8e55Smrg func_warning "\`-dlopen' is ignored for archives" 71998c4a8e55Smrg fi 72008c4a8e55Smrg 72018c4a8e55Smrg case " $deplibs" in 72028c4a8e55Smrg *\ -l* | *\ -L*) 72038c4a8e55Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 72048c4a8e55Smrg esac 72058c4a8e55Smrg 72068c4a8e55Smrg test -n "$rpath" && \ 72078c4a8e55Smrg func_warning "\`-rpath' is ignored for archives" 72088c4a8e55Smrg 72098c4a8e55Smrg test -n "$xrpath" && \ 72108c4a8e55Smrg func_warning "\`-R' is ignored for archives" 72118c4a8e55Smrg 72128c4a8e55Smrg test -n "$vinfo" && \ 72138c4a8e55Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 72148c4a8e55Smrg 72158c4a8e55Smrg test -n "$release" && \ 72168c4a8e55Smrg func_warning "\`-release' is ignored for archives" 72178c4a8e55Smrg 72188c4a8e55Smrg test -n "$export_symbols$export_symbols_regex" && \ 72198c4a8e55Smrg func_warning "\`-export-symbols' is ignored for archives" 72208c4a8e55Smrg 72218c4a8e55Smrg # Now set the variables for building old libraries. 72228c4a8e55Smrg build_libtool_libs=no 72238c4a8e55Smrg oldlibs="$output" 7224bd23fbfaSmrg func_append objs "$old_deplibs" 72258c4a8e55Smrg ;; 72268c4a8e55Smrg 72278c4a8e55Smrg lib) 72288c4a8e55Smrg # Make sure we only generate libraries of the form `libNAME.la'. 72298c4a8e55Smrg case $outputname in 72308c4a8e55Smrg lib*) 72318c4a8e55Smrg func_stripname 'lib' '.la' "$outputname" 72328c4a8e55Smrg name=$func_stripname_result 72338c4a8e55Smrg eval shared_ext=\"$shrext_cmds\" 72348c4a8e55Smrg eval libname=\"$libname_spec\" 72358c4a8e55Smrg ;; 72368c4a8e55Smrg *) 72378c4a8e55Smrg test "$module" = no && \ 72388c4a8e55Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 72398c4a8e55Smrg 72408c4a8e55Smrg if test "$need_lib_prefix" != no; then 72418c4a8e55Smrg # Add the "lib" prefix for modules if required 72428c4a8e55Smrg func_stripname '' '.la' "$outputname" 72438c4a8e55Smrg name=$func_stripname_result 72448c4a8e55Smrg eval shared_ext=\"$shrext_cmds\" 72458c4a8e55Smrg eval libname=\"$libname_spec\" 72468c4a8e55Smrg else 72478c4a8e55Smrg func_stripname '' '.la' "$outputname" 72488c4a8e55Smrg libname=$func_stripname_result 72498c4a8e55Smrg fi 72508c4a8e55Smrg ;; 72518c4a8e55Smrg esac 72528c4a8e55Smrg 72538c4a8e55Smrg if test -n "$objs"; then 72548c4a8e55Smrg if test "$deplibs_check_method" != pass_all; then 72558c4a8e55Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 72568c4a8e55Smrg else 7257706b6b52Smrg echo 72588c4a8e55Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 72598c4a8e55Smrg $ECHO "*** objects $objs is not portable!" 7260bd23fbfaSmrg func_append libobjs " $objs" 72618c4a8e55Smrg fi 72628c4a8e55Smrg fi 72638c4a8e55Smrg 72648c4a8e55Smrg test "$dlself" != no && \ 72658c4a8e55Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 72668c4a8e55Smrg 72678c4a8e55Smrg set dummy $rpath 72688c4a8e55Smrg shift 72698c4a8e55Smrg test "$#" -gt 1 && \ 72708c4a8e55Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 72718c4a8e55Smrg 72728c4a8e55Smrg install_libdir="$1" 72738c4a8e55Smrg 72748c4a8e55Smrg oldlibs= 72758c4a8e55Smrg if test -z "$rpath"; then 72768c4a8e55Smrg if test "$build_libtool_libs" = yes; then 72778c4a8e55Smrg # Building a libtool convenience library. 72788c4a8e55Smrg # Some compilers have problems with a `.al' extension so 72798c4a8e55Smrg # convenience libraries should have the same extension an 72808c4a8e55Smrg # archive normally would. 72818c4a8e55Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 72828c4a8e55Smrg build_libtool_libs=convenience 72838c4a8e55Smrg build_old_libs=yes 72848c4a8e55Smrg fi 72858c4a8e55Smrg 72868c4a8e55Smrg test -n "$vinfo" && \ 72878c4a8e55Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 72888c4a8e55Smrg 72898c4a8e55Smrg test -n "$release" && \ 72908c4a8e55Smrg func_warning "\`-release' is ignored for convenience libraries" 72918c4a8e55Smrg else 72928c4a8e55Smrg 72938c4a8e55Smrg # Parse the version information argument. 72948c4a8e55Smrg save_ifs="$IFS"; IFS=':' 72958c4a8e55Smrg set dummy $vinfo 0 0 0 72968c4a8e55Smrg shift 72978c4a8e55Smrg IFS="$save_ifs" 72988c4a8e55Smrg 72998c4a8e55Smrg test -n "$7" && \ 73008c4a8e55Smrg func_fatal_help "too many parameters to \`-version-info'" 73018c4a8e55Smrg 73028c4a8e55Smrg # convert absolute version numbers to libtool ages 73038c4a8e55Smrg # this retains compatibility with .la files and attempts 73048c4a8e55Smrg # to make the code below a bit more comprehensible 73058c4a8e55Smrg 73068c4a8e55Smrg case $vinfo_number in 73078c4a8e55Smrg yes) 73088c4a8e55Smrg number_major="$1" 73098c4a8e55Smrg number_minor="$2" 73108c4a8e55Smrg number_revision="$3" 73118c4a8e55Smrg # 73128c4a8e55Smrg # There are really only two kinds -- those that 73138c4a8e55Smrg # use the current revision as the major version 73148c4a8e55Smrg # and those that subtract age and use age as 73158c4a8e55Smrg # a minor version. But, then there is irix 73168c4a8e55Smrg # which has an extra 1 added just for fun 73178c4a8e55Smrg # 73188c4a8e55Smrg case $version_type in 73198c4a8e55Smrg darwin|linux|osf|windows|none) 73208c4a8e55Smrg func_arith $number_major + $number_minor 73218c4a8e55Smrg current=$func_arith_result 73228c4a8e55Smrg age="$number_minor" 73238c4a8e55Smrg revision="$number_revision" 73248c4a8e55Smrg ;; 7325706b6b52Smrg freebsd-aout|freebsd-elf|qnx|sunos) 73268c4a8e55Smrg current="$number_major" 73278c4a8e55Smrg revision="$number_minor" 73288c4a8e55Smrg age="0" 73298c4a8e55Smrg ;; 73308c4a8e55Smrg irix|nonstopux) 73318c4a8e55Smrg func_arith $number_major + $number_minor 73328c4a8e55Smrg current=$func_arith_result 73338c4a8e55Smrg age="$number_minor" 73348c4a8e55Smrg revision="$number_minor" 73358c4a8e55Smrg lt_irix_increment=no 73368c4a8e55Smrg ;; 73378c4a8e55Smrg esac 73388c4a8e55Smrg ;; 73398c4a8e55Smrg no) 73408c4a8e55Smrg current="$1" 73418c4a8e55Smrg revision="$2" 73428c4a8e55Smrg age="$3" 73438c4a8e55Smrg ;; 73448c4a8e55Smrg esac 73458c4a8e55Smrg 73468c4a8e55Smrg # Check that each of the things are valid numbers. 73478c4a8e55Smrg case $current in 73488c4a8e55Smrg 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]) ;; 73498c4a8e55Smrg *) 73508c4a8e55Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 73518c4a8e55Smrg func_fatal_error "\`$vinfo' is not valid version information" 73528c4a8e55Smrg ;; 73538c4a8e55Smrg esac 73548c4a8e55Smrg 73558c4a8e55Smrg case $revision in 73568c4a8e55Smrg 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]) ;; 73578c4a8e55Smrg *) 73588c4a8e55Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 73598c4a8e55Smrg func_fatal_error "\`$vinfo' is not valid version information" 73608c4a8e55Smrg ;; 73618c4a8e55Smrg esac 73628c4a8e55Smrg 73638c4a8e55Smrg case $age in 73648c4a8e55Smrg 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]) ;; 73658c4a8e55Smrg *) 73668c4a8e55Smrg func_error "AGE \`$age' must be a nonnegative integer" 73678c4a8e55Smrg func_fatal_error "\`$vinfo' is not valid version information" 73688c4a8e55Smrg ;; 73698c4a8e55Smrg esac 73708c4a8e55Smrg 73718c4a8e55Smrg if test "$age" -gt "$current"; then 73728c4a8e55Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 73738c4a8e55Smrg func_fatal_error "\`$vinfo' is not valid version information" 73748c4a8e55Smrg fi 73758c4a8e55Smrg 73768c4a8e55Smrg # Calculate the version variables. 73778c4a8e55Smrg major= 73788c4a8e55Smrg versuffix= 73798c4a8e55Smrg verstring= 73808c4a8e55Smrg case $version_type in 73818c4a8e55Smrg none) ;; 73828c4a8e55Smrg 73838c4a8e55Smrg darwin) 73848c4a8e55Smrg # Like Linux, but with the current version available in 73858c4a8e55Smrg # verstring for coding it into the library header 73868c4a8e55Smrg func_arith $current - $age 73878c4a8e55Smrg major=.$func_arith_result 73888c4a8e55Smrg versuffix="$major.$age.$revision" 73898c4a8e55Smrg # Darwin ld doesn't like 0 for these options... 73908c4a8e55Smrg func_arith $current + 1 73918c4a8e55Smrg minor_current=$func_arith_result 73928c4a8e55Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 73938c4a8e55Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 73948c4a8e55Smrg ;; 73958c4a8e55Smrg 73968c4a8e55Smrg freebsd-aout) 73978c4a8e55Smrg major=".$current" 73988c4a8e55Smrg versuffix=".$current.$revision"; 73998c4a8e55Smrg ;; 74008c4a8e55Smrg 74018c4a8e55Smrg freebsd-elf) 74028c4a8e55Smrg major=".$current" 74038c4a8e55Smrg versuffix=".$current" 74048c4a8e55Smrg ;; 74058c4a8e55Smrg 74068c4a8e55Smrg irix | nonstopux) 74078c4a8e55Smrg if test "X$lt_irix_increment" = "Xno"; then 74088c4a8e55Smrg func_arith $current - $age 74098c4a8e55Smrg else 74108c4a8e55Smrg func_arith $current - $age + 1 74118c4a8e55Smrg fi 74128c4a8e55Smrg major=$func_arith_result 74138c4a8e55Smrg 74148c4a8e55Smrg case $version_type in 74158c4a8e55Smrg nonstopux) verstring_prefix=nonstopux ;; 74168c4a8e55Smrg *) verstring_prefix=sgi ;; 74178c4a8e55Smrg esac 74188c4a8e55Smrg verstring="$verstring_prefix$major.$revision" 74198c4a8e55Smrg 74208c4a8e55Smrg # Add in all the interfaces that we are compatible with. 74218c4a8e55Smrg loop=$revision 74228c4a8e55Smrg while test "$loop" -ne 0; do 74238c4a8e55Smrg func_arith $revision - $loop 74248c4a8e55Smrg iface=$func_arith_result 74258c4a8e55Smrg func_arith $loop - 1 74268c4a8e55Smrg loop=$func_arith_result 74278c4a8e55Smrg verstring="$verstring_prefix$major.$iface:$verstring" 74288c4a8e55Smrg done 74298c4a8e55Smrg 74308c4a8e55Smrg # Before this point, $major must not contain `.'. 74318c4a8e55Smrg major=.$major 74328c4a8e55Smrg versuffix="$major.$revision" 74338c4a8e55Smrg ;; 74348c4a8e55Smrg 74358c4a8e55Smrg linux) 74368c4a8e55Smrg func_arith $current - $age 74378c4a8e55Smrg major=.$func_arith_result 74388c4a8e55Smrg versuffix="$major.$age.$revision" 74398c4a8e55Smrg ;; 74408c4a8e55Smrg 74418c4a8e55Smrg osf) 74428c4a8e55Smrg func_arith $current - $age 74438c4a8e55Smrg major=.$func_arith_result 74448c4a8e55Smrg versuffix=".$current.$age.$revision" 74458c4a8e55Smrg verstring="$current.$age.$revision" 74468c4a8e55Smrg 74478c4a8e55Smrg # Add in all the interfaces that we are compatible with. 74488c4a8e55Smrg loop=$age 74498c4a8e55Smrg while test "$loop" -ne 0; do 74508c4a8e55Smrg func_arith $current - $loop 74518c4a8e55Smrg iface=$func_arith_result 74528c4a8e55Smrg func_arith $loop - 1 74538c4a8e55Smrg loop=$func_arith_result 74548c4a8e55Smrg verstring="$verstring:${iface}.0" 74558c4a8e55Smrg done 74568c4a8e55Smrg 74578c4a8e55Smrg # Make executables depend on our current version. 7458bd23fbfaSmrg func_append verstring ":${current}.0" 74598c4a8e55Smrg ;; 74608c4a8e55Smrg 74618c4a8e55Smrg qnx) 74628c4a8e55Smrg major=".$current" 74638c4a8e55Smrg versuffix=".$current" 74648c4a8e55Smrg ;; 74658c4a8e55Smrg 74668c4a8e55Smrg sunos) 74678c4a8e55Smrg major=".$current" 74688c4a8e55Smrg versuffix=".$current.$revision" 74698c4a8e55Smrg ;; 74708c4a8e55Smrg 74718c4a8e55Smrg windows) 74728c4a8e55Smrg # Use '-' rather than '.', since we only want one 74738c4a8e55Smrg # extension on DOS 8.3 filesystems. 74748c4a8e55Smrg func_arith $current - $age 74758c4a8e55Smrg major=$func_arith_result 74768c4a8e55Smrg versuffix="-$major" 74778c4a8e55Smrg ;; 74788c4a8e55Smrg 74798c4a8e55Smrg *) 74808c4a8e55Smrg func_fatal_configuration "unknown library version type \`$version_type'" 74818c4a8e55Smrg ;; 74828c4a8e55Smrg esac 74838c4a8e55Smrg 74848c4a8e55Smrg # Clear the version info if we defaulted, and they specified a release. 74858c4a8e55Smrg if test -z "$vinfo" && test -n "$release"; then 74868c4a8e55Smrg major= 74878c4a8e55Smrg case $version_type in 74888c4a8e55Smrg darwin) 74898c4a8e55Smrg # we can't check for "0.0" in archive_cmds due to quoting 74908c4a8e55Smrg # problems, so we reset it completely 74918c4a8e55Smrg verstring= 74928c4a8e55Smrg ;; 74938c4a8e55Smrg *) 74948c4a8e55Smrg verstring="0.0" 74958c4a8e55Smrg ;; 74968c4a8e55Smrg esac 74978c4a8e55Smrg if test "$need_version" = no; then 74988c4a8e55Smrg versuffix= 74998c4a8e55Smrg else 75008c4a8e55Smrg versuffix=".0.0" 75018c4a8e55Smrg fi 75028c4a8e55Smrg fi 75038c4a8e55Smrg 75048c4a8e55Smrg # Remove version info from name if versioning should be avoided 75058c4a8e55Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 75068c4a8e55Smrg major= 75078c4a8e55Smrg versuffix= 75088c4a8e55Smrg verstring="" 75098c4a8e55Smrg fi 75108c4a8e55Smrg 75118c4a8e55Smrg # Check to see if the archive will have undefined symbols. 75128c4a8e55Smrg if test "$allow_undefined" = yes; then 75138c4a8e55Smrg if test "$allow_undefined_flag" = unsupported; then 75148c4a8e55Smrg func_warning "undefined symbols not allowed in $host shared libraries" 75158c4a8e55Smrg build_libtool_libs=no 75168c4a8e55Smrg build_old_libs=yes 75178c4a8e55Smrg fi 75188c4a8e55Smrg else 75198c4a8e55Smrg # Don't allow undefined symbols. 75208c4a8e55Smrg allow_undefined_flag="$no_undefined_flag" 75218c4a8e55Smrg fi 75228c4a8e55Smrg 75238c4a8e55Smrg fi 75248c4a8e55Smrg 75258c4a8e55Smrg func_generate_dlsyms "$libname" "$libname" "yes" 7526bd23fbfaSmrg func_append libobjs " $symfileobj" 75278c4a8e55Smrg test "X$libobjs" = "X " && libobjs= 75288c4a8e55Smrg 7529bd23fbfaSmrg if test "$opt_mode" != relink; then 75308c4a8e55Smrg # Remove our outputs, but don't remove object files since they 75318c4a8e55Smrg # may have been created when compiling PIC objects. 75328c4a8e55Smrg removelist= 75338c4a8e55Smrg tempremovelist=`$ECHO "$output_objdir/*"` 75348c4a8e55Smrg for p in $tempremovelist; do 75358c4a8e55Smrg case $p in 75368c4a8e55Smrg *.$objext | *.gcno) 75378c4a8e55Smrg ;; 75388c4a8e55Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 75398c4a8e55Smrg if test "X$precious_files_regex" != "X"; then 75408c4a8e55Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 75418c4a8e55Smrg then 75428c4a8e55Smrg continue 75438c4a8e55Smrg fi 75448c4a8e55Smrg fi 7545bd23fbfaSmrg func_append removelist " $p" 75468c4a8e55Smrg ;; 75478c4a8e55Smrg *) ;; 75488c4a8e55Smrg esac 75498c4a8e55Smrg done 75508c4a8e55Smrg test -n "$removelist" && \ 75518c4a8e55Smrg func_show_eval "${RM}r \$removelist" 75528c4a8e55Smrg fi 75538c4a8e55Smrg 75548c4a8e55Smrg # Now set the variables for building old libraries. 75558c4a8e55Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 7556bd23fbfaSmrg func_append oldlibs " $output_objdir/$libname.$libext" 75578c4a8e55Smrg 75588c4a8e55Smrg # Transform .lo files to .o files. 7559706b6b52Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 75608c4a8e55Smrg fi 75618c4a8e55Smrg 75628c4a8e55Smrg # Eliminate all temporary directories. 75638c4a8e55Smrg #for path in $notinst_path; do 7564706b6b52Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 7565706b6b52Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 7566706b6b52Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 75678c4a8e55Smrg #done 75688c4a8e55Smrg 75698c4a8e55Smrg if test -n "$xrpath"; then 75708c4a8e55Smrg # If the user specified any rpath flags, then add them. 75718c4a8e55Smrg temp_xrpath= 75728c4a8e55Smrg for libdir in $xrpath; do 7573bd23fbfaSmrg func_replace_sysroot "$libdir" 7574bd23fbfaSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 75758c4a8e55Smrg case "$finalize_rpath " in 75768c4a8e55Smrg *" $libdir "*) ;; 7577bd23fbfaSmrg *) func_append finalize_rpath " $libdir" ;; 75788c4a8e55Smrg esac 75798c4a8e55Smrg done 75808c4a8e55Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 75818c4a8e55Smrg dependency_libs="$temp_xrpath $dependency_libs" 75828c4a8e55Smrg fi 75838c4a8e55Smrg fi 75848c4a8e55Smrg 75858c4a8e55Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 75868c4a8e55Smrg old_dlfiles="$dlfiles" 75878c4a8e55Smrg dlfiles= 75888c4a8e55Smrg for lib in $old_dlfiles; do 75898c4a8e55Smrg case " $dlprefiles $dlfiles " in 75908c4a8e55Smrg *" $lib "*) ;; 7591bd23fbfaSmrg *) func_append dlfiles " $lib" ;; 75928c4a8e55Smrg esac 75938c4a8e55Smrg done 75948c4a8e55Smrg 75958c4a8e55Smrg # Make sure dlprefiles contains only unique files 75968c4a8e55Smrg old_dlprefiles="$dlprefiles" 75978c4a8e55Smrg dlprefiles= 75988c4a8e55Smrg for lib in $old_dlprefiles; do 75998c4a8e55Smrg case "$dlprefiles " in 76008c4a8e55Smrg *" $lib "*) ;; 7601bd23fbfaSmrg *) func_append dlprefiles " $lib" ;; 76028c4a8e55Smrg esac 76038c4a8e55Smrg done 76048c4a8e55Smrg 76058c4a8e55Smrg if test "$build_libtool_libs" = yes; then 76068c4a8e55Smrg if test -n "$rpath"; then 76078c4a8e55Smrg case $host in 7608706b6b52Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 76098c4a8e55Smrg # these systems don't actually have a c library (as such)! 76108c4a8e55Smrg ;; 76118c4a8e55Smrg *-*-rhapsody* | *-*-darwin1.[012]) 76128c4a8e55Smrg # Rhapsody C library is in the System framework 7613bd23fbfaSmrg func_append deplibs " System.ltframework" 76148c4a8e55Smrg ;; 76158c4a8e55Smrg *-*-netbsd*) 76168c4a8e55Smrg # Don't link with libc until the a.out ld.so is fixed. 76178c4a8e55Smrg ;; 76188c4a8e55Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 76198c4a8e55Smrg # Do not include libc due to us having libc/libc_r. 76208c4a8e55Smrg ;; 76218c4a8e55Smrg *-*-sco3.2v5* | *-*-sco5v6*) 76228c4a8e55Smrg # Causes problems with __ctype 76238c4a8e55Smrg ;; 76248c4a8e55Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 76258c4a8e55Smrg # Compiler inserts libc in the correct place for threads to work 76268c4a8e55Smrg ;; 76278c4a8e55Smrg *) 76288c4a8e55Smrg # Add libc to deplibs on all other systems if necessary. 76298c4a8e55Smrg if test "$build_libtool_need_lc" = "yes"; then 7630bd23fbfaSmrg func_append deplibs " -lc" 76318c4a8e55Smrg fi 76328c4a8e55Smrg ;; 76338c4a8e55Smrg esac 76348c4a8e55Smrg fi 76358c4a8e55Smrg 76368c4a8e55Smrg # Transform deplibs into only deplibs that can be linked in shared. 76378c4a8e55Smrg name_save=$name 76388c4a8e55Smrg libname_save=$libname 76398c4a8e55Smrg release_save=$release 76408c4a8e55Smrg versuffix_save=$versuffix 76418c4a8e55Smrg major_save=$major 76428c4a8e55Smrg # I'm not sure if I'm treating the release correctly. I think 76438c4a8e55Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 76448c4a8e55Smrg # add it in twice. Is that correct? 76458c4a8e55Smrg release="" 76468c4a8e55Smrg versuffix="" 76478c4a8e55Smrg major="" 76488c4a8e55Smrg newdeplibs= 76498c4a8e55Smrg droppeddeps=no 76508c4a8e55Smrg case $deplibs_check_method in 76518c4a8e55Smrg pass_all) 76528c4a8e55Smrg # Don't check for shared/static. Everything works. 76538c4a8e55Smrg # This might be a little naive. We might want to check 76548c4a8e55Smrg # whether the library exists or not. But this is on 76558c4a8e55Smrg # osf3 & osf4 and I'm not really sure... Just 76568c4a8e55Smrg # implementing what was already the behavior. 76578c4a8e55Smrg newdeplibs=$deplibs 76588c4a8e55Smrg ;; 76598c4a8e55Smrg test_compile) 76608c4a8e55Smrg # This code stresses the "libraries are programs" paradigm to its 76618c4a8e55Smrg # limits. Maybe even breaks it. We compile a program, linking it 76628c4a8e55Smrg # against the deplibs as a proxy for the library. Then we can check 76638c4a8e55Smrg # whether they linked in statically or dynamically with ldd. 76648c4a8e55Smrg $opt_dry_run || $RM conftest.c 76658c4a8e55Smrg cat > conftest.c <<EOF 76668c4a8e55Smrg int main() { return 0; } 76678c4a8e55SmrgEOF 76688c4a8e55Smrg $opt_dry_run || $RM conftest 76698c4a8e55Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 76708c4a8e55Smrg ldd_output=`ldd conftest` 76718c4a8e55Smrg for i in $deplibs; do 76728c4a8e55Smrg case $i in 76738c4a8e55Smrg -l*) 76748c4a8e55Smrg func_stripname -l '' "$i" 76758c4a8e55Smrg name=$func_stripname_result 76768c4a8e55Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 76778c4a8e55Smrg case " $predeps $postdeps " in 76788c4a8e55Smrg *" $i "*) 7679bd23fbfaSmrg func_append newdeplibs " $i" 76808c4a8e55Smrg i="" 76818c4a8e55Smrg ;; 76828c4a8e55Smrg esac 76838c4a8e55Smrg fi 76848c4a8e55Smrg if test -n "$i" ; then 76858c4a8e55Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 76868c4a8e55Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 76878c4a8e55Smrg set dummy $deplib_matches; shift 76888c4a8e55Smrg deplib_match=$1 76898c4a8e55Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7690bd23fbfaSmrg func_append newdeplibs " $i" 76918c4a8e55Smrg else 76928c4a8e55Smrg droppeddeps=yes 7693706b6b52Smrg echo 76948c4a8e55Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7695706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 7696706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 7697706b6b52Smrg echo "*** shared version of the library, which I believe you do not have" 7698706b6b52Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 7699706b6b52Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 77008c4a8e55Smrg fi 77018c4a8e55Smrg fi 77028c4a8e55Smrg ;; 77038c4a8e55Smrg *) 7704bd23fbfaSmrg func_append newdeplibs " $i" 77058c4a8e55Smrg ;; 77068c4a8e55Smrg esac 77078c4a8e55Smrg done 77088c4a8e55Smrg else 77098c4a8e55Smrg # Error occurred in the first compile. Let's try to salvage 77108c4a8e55Smrg # the situation: Compile a separate program for each library. 77118c4a8e55Smrg for i in $deplibs; do 77128c4a8e55Smrg case $i in 77138c4a8e55Smrg -l*) 77148c4a8e55Smrg func_stripname -l '' "$i" 77158c4a8e55Smrg name=$func_stripname_result 77168c4a8e55Smrg $opt_dry_run || $RM conftest 77178c4a8e55Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 77188c4a8e55Smrg ldd_output=`ldd conftest` 77198c4a8e55Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 77208c4a8e55Smrg case " $predeps $postdeps " in 77218c4a8e55Smrg *" $i "*) 7722bd23fbfaSmrg func_append newdeplibs " $i" 77238c4a8e55Smrg i="" 77248c4a8e55Smrg ;; 77258c4a8e55Smrg esac 77268c4a8e55Smrg fi 77278c4a8e55Smrg if test -n "$i" ; then 77288c4a8e55Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 77298c4a8e55Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 77308c4a8e55Smrg set dummy $deplib_matches; shift 77318c4a8e55Smrg deplib_match=$1 77328c4a8e55Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7733bd23fbfaSmrg func_append newdeplibs " $i" 77348c4a8e55Smrg else 77358c4a8e55Smrg droppeddeps=yes 7736706b6b52Smrg echo 77378c4a8e55Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7738706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 7739706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 7740706b6b52Smrg echo "*** shared version of the library, which you do not appear to have" 7741706b6b52Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 7742706b6b52Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 77438c4a8e55Smrg fi 77448c4a8e55Smrg fi 77458c4a8e55Smrg else 77468c4a8e55Smrg droppeddeps=yes 7747706b6b52Smrg echo 77488c4a8e55Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 7749706b6b52Smrg echo "*** make it link in! You will probably need to install it or some" 7750706b6b52Smrg echo "*** library that it depends on before this library will be fully" 7751706b6b52Smrg echo "*** functional. Installing it before continuing would be even better." 77528c4a8e55Smrg fi 77538c4a8e55Smrg ;; 77548c4a8e55Smrg *) 7755bd23fbfaSmrg func_append newdeplibs " $i" 77568c4a8e55Smrg ;; 77578c4a8e55Smrg esac 77588c4a8e55Smrg done 77598c4a8e55Smrg fi 77608c4a8e55Smrg ;; 77618c4a8e55Smrg file_magic*) 77628c4a8e55Smrg set dummy $deplibs_check_method; shift 77638c4a8e55Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 77648c4a8e55Smrg for a_deplib in $deplibs; do 77658c4a8e55Smrg case $a_deplib in 77668c4a8e55Smrg -l*) 77678c4a8e55Smrg func_stripname -l '' "$a_deplib" 77688c4a8e55Smrg name=$func_stripname_result 77698c4a8e55Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 77708c4a8e55Smrg case " $predeps $postdeps " in 77718c4a8e55Smrg *" $a_deplib "*) 7772bd23fbfaSmrg func_append newdeplibs " $a_deplib" 77738c4a8e55Smrg a_deplib="" 77748c4a8e55Smrg ;; 77758c4a8e55Smrg esac 77768c4a8e55Smrg fi 77778c4a8e55Smrg if test -n "$a_deplib" ; then 77788c4a8e55Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7779bd23fbfaSmrg if test -n "$file_magic_glob"; then 7780bd23fbfaSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 7781bd23fbfaSmrg else 7782bd23fbfaSmrg libnameglob=$libname 7783bd23fbfaSmrg fi 7784bd23fbfaSmrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 77858c4a8e55Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7786bd23fbfaSmrg if test "$want_nocaseglob" = yes; then 7787bd23fbfaSmrg shopt -s nocaseglob 7788bd23fbfaSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7789bd23fbfaSmrg $nocaseglob 7790bd23fbfaSmrg else 7791bd23fbfaSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7792bd23fbfaSmrg fi 77938c4a8e55Smrg for potent_lib in $potential_libs; do 77948c4a8e55Smrg # Follow soft links. 77958c4a8e55Smrg if ls -lLd "$potent_lib" 2>/dev/null | 77968c4a8e55Smrg $GREP " -> " >/dev/null; then 77978c4a8e55Smrg continue 77988c4a8e55Smrg fi 77998c4a8e55Smrg # The statement above tries to avoid entering an 78008c4a8e55Smrg # endless loop below, in case of cyclic links. 78018c4a8e55Smrg # We might still enter an endless loop, since a link 78028c4a8e55Smrg # loop can be closed while we follow links, 78038c4a8e55Smrg # but so what? 78048c4a8e55Smrg potlib="$potent_lib" 78058c4a8e55Smrg while test -h "$potlib" 2>/dev/null; do 78068c4a8e55Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 78078c4a8e55Smrg case $potliblink in 78088c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 7809706b6b52Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 78108c4a8e55Smrg esac 78118c4a8e55Smrg done 78128c4a8e55Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 78138c4a8e55Smrg $SED -e 10q | 78148c4a8e55Smrg $EGREP "$file_magic_regex" > /dev/null; then 7815bd23fbfaSmrg func_append newdeplibs " $a_deplib" 78168c4a8e55Smrg a_deplib="" 78178c4a8e55Smrg break 2 78188c4a8e55Smrg fi 78198c4a8e55Smrg done 78208c4a8e55Smrg done 78218c4a8e55Smrg fi 78228c4a8e55Smrg if test -n "$a_deplib" ; then 78238c4a8e55Smrg droppeddeps=yes 7824706b6b52Smrg echo 78258c4a8e55Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7826706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 7827706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 7828706b6b52Smrg echo "*** shared version of the library, which you do not appear to have" 7829706b6b52Smrg echo "*** because I did check the linker path looking for a file starting" 78308c4a8e55Smrg if test -z "$potlib" ; then 78318c4a8e55Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 78328c4a8e55Smrg else 78338c4a8e55Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 78348c4a8e55Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 78358c4a8e55Smrg fi 78368c4a8e55Smrg fi 78378c4a8e55Smrg ;; 78388c4a8e55Smrg *) 78398c4a8e55Smrg # Add a -L argument. 7840bd23fbfaSmrg func_append newdeplibs " $a_deplib" 78418c4a8e55Smrg ;; 78428c4a8e55Smrg esac 78438c4a8e55Smrg done # Gone through all deplibs. 78448c4a8e55Smrg ;; 78458c4a8e55Smrg match_pattern*) 78468c4a8e55Smrg set dummy $deplibs_check_method; shift 78478c4a8e55Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 78488c4a8e55Smrg for a_deplib in $deplibs; do 78498c4a8e55Smrg case $a_deplib in 78508c4a8e55Smrg -l*) 78518c4a8e55Smrg func_stripname -l '' "$a_deplib" 78528c4a8e55Smrg name=$func_stripname_result 78538c4a8e55Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 78548c4a8e55Smrg case " $predeps $postdeps " in 78558c4a8e55Smrg *" $a_deplib "*) 7856bd23fbfaSmrg func_append newdeplibs " $a_deplib" 78578c4a8e55Smrg a_deplib="" 78588c4a8e55Smrg ;; 78598c4a8e55Smrg esac 78608c4a8e55Smrg fi 78618c4a8e55Smrg if test -n "$a_deplib" ; then 78628c4a8e55Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 78638c4a8e55Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 78648c4a8e55Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 78658c4a8e55Smrg for potent_lib in $potential_libs; do 78668c4a8e55Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 7867706b6b52Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 78688c4a8e55Smrg $EGREP "$match_pattern_regex" > /dev/null; then 7869bd23fbfaSmrg func_append newdeplibs " $a_deplib" 78708c4a8e55Smrg a_deplib="" 78718c4a8e55Smrg break 2 78728c4a8e55Smrg fi 78738c4a8e55Smrg done 78748c4a8e55Smrg done 78758c4a8e55Smrg fi 78768c4a8e55Smrg if test -n "$a_deplib" ; then 78778c4a8e55Smrg droppeddeps=yes 7878706b6b52Smrg echo 78798c4a8e55Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7880706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 7881706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 7882706b6b52Smrg echo "*** shared version of the library, which you do not appear to have" 7883706b6b52Smrg echo "*** because I did check the linker path looking for a file starting" 78848c4a8e55Smrg if test -z "$potlib" ; then 78858c4a8e55Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 78868c4a8e55Smrg else 78878c4a8e55Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 78888c4a8e55Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 78898c4a8e55Smrg fi 78908c4a8e55Smrg fi 78918c4a8e55Smrg ;; 78928c4a8e55Smrg *) 78938c4a8e55Smrg # Add a -L argument. 7894bd23fbfaSmrg func_append newdeplibs " $a_deplib" 78958c4a8e55Smrg ;; 78968c4a8e55Smrg esac 78978c4a8e55Smrg done # Gone through all deplibs. 78988c4a8e55Smrg ;; 78998c4a8e55Smrg none | unknown | *) 79008c4a8e55Smrg newdeplibs="" 7901706b6b52Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 79028c4a8e55Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 79038c4a8e55Smrg for i in $predeps $postdeps ; do 79048c4a8e55Smrg # can't use Xsed below, because $i might contain '/' 7905706b6b52Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 79068c4a8e55Smrg done 79078c4a8e55Smrg fi 7908706b6b52Smrg case $tmp_deplibs in 7909706b6b52Smrg *[!\ \ ]*) 7910706b6b52Smrg echo 79118c4a8e55Smrg if test "X$deplibs_check_method" = "Xnone"; then 7912706b6b52Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 79138c4a8e55Smrg else 7914706b6b52Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 79158c4a8e55Smrg fi 7916706b6b52Smrg echo "*** All declared inter-library dependencies are being dropped." 79178c4a8e55Smrg droppeddeps=yes 7918706b6b52Smrg ;; 7919706b6b52Smrg esac 79208c4a8e55Smrg ;; 79218c4a8e55Smrg esac 79228c4a8e55Smrg versuffix=$versuffix_save 79238c4a8e55Smrg major=$major_save 79248c4a8e55Smrg release=$release_save 79258c4a8e55Smrg libname=$libname_save 79268c4a8e55Smrg name=$name_save 79278c4a8e55Smrg 79288c4a8e55Smrg case $host in 79298c4a8e55Smrg *-*-rhapsody* | *-*-darwin1.[012]) 79308c4a8e55Smrg # On Rhapsody replace the C library with the System framework 7931706b6b52Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 79328c4a8e55Smrg ;; 79338c4a8e55Smrg esac 79348c4a8e55Smrg 79358c4a8e55Smrg if test "$droppeddeps" = yes; then 79368c4a8e55Smrg if test "$module" = yes; then 7937706b6b52Smrg echo 7938706b6b52Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 79398c4a8e55Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 7940706b6b52Smrg echo "*** a static module, that should work as long as the dlopening" 7941706b6b52Smrg echo "*** application is linked with the -dlopen flag." 79428c4a8e55Smrg if test -z "$global_symbol_pipe"; then 7943706b6b52Smrg echo 7944706b6b52Smrg echo "*** However, this would only work if libtool was able to extract symbol" 7945706b6b52Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 7946706b6b52Smrg echo "*** not find such a program. So, this module is probably useless." 7947706b6b52Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 79488c4a8e55Smrg fi 79498c4a8e55Smrg if test "$build_old_libs" = no; then 79508c4a8e55Smrg oldlibs="$output_objdir/$libname.$libext" 79518c4a8e55Smrg build_libtool_libs=module 79528c4a8e55Smrg build_old_libs=yes 79538c4a8e55Smrg else 79548c4a8e55Smrg build_libtool_libs=no 79558c4a8e55Smrg fi 79568c4a8e55Smrg else 7957706b6b52Smrg echo "*** The inter-library dependencies that have been dropped here will be" 7958706b6b52Smrg echo "*** automatically added whenever a program is linked with this library" 7959706b6b52Smrg echo "*** or is declared to -dlopen it." 79608c4a8e55Smrg 79618c4a8e55Smrg if test "$allow_undefined" = no; then 7962706b6b52Smrg echo 7963706b6b52Smrg echo "*** Since this library must not contain undefined symbols," 7964706b6b52Smrg echo "*** because either the platform does not support them or" 7965706b6b52Smrg echo "*** it was explicitly requested with -no-undefined," 7966706b6b52Smrg echo "*** libtool will only create a static version of it." 79678c4a8e55Smrg if test "$build_old_libs" = no; then 79688c4a8e55Smrg oldlibs="$output_objdir/$libname.$libext" 79698c4a8e55Smrg build_libtool_libs=module 79708c4a8e55Smrg build_old_libs=yes 79718c4a8e55Smrg else 79728c4a8e55Smrg build_libtool_libs=no 79738c4a8e55Smrg fi 79748c4a8e55Smrg fi 79758c4a8e55Smrg fi 79768c4a8e55Smrg fi 79778c4a8e55Smrg # Done checking deplibs! 79788c4a8e55Smrg deplibs=$newdeplibs 79798c4a8e55Smrg fi 79808c4a8e55Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 79818c4a8e55Smrg case $host in 79828c4a8e55Smrg *-*-darwin*) 7983706b6b52Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7984706b6b52Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7985706b6b52Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 79868c4a8e55Smrg ;; 79878c4a8e55Smrg esac 79888c4a8e55Smrg 79898c4a8e55Smrg # move library search paths that coincide with paths to not yet 79908c4a8e55Smrg # installed libraries to the beginning of the library search list 79918c4a8e55Smrg new_libs= 79928c4a8e55Smrg for path in $notinst_path; do 79938c4a8e55Smrg case " $new_libs " in 79948c4a8e55Smrg *" -L$path/$objdir "*) ;; 79958c4a8e55Smrg *) 79968c4a8e55Smrg case " $deplibs " in 79978c4a8e55Smrg *" -L$path/$objdir "*) 7998bd23fbfaSmrg func_append new_libs " -L$path/$objdir" ;; 79998c4a8e55Smrg esac 80008c4a8e55Smrg ;; 80018c4a8e55Smrg esac 80028c4a8e55Smrg done 80038c4a8e55Smrg for deplib in $deplibs; do 80048c4a8e55Smrg case $deplib in 80058c4a8e55Smrg -L*) 80068c4a8e55Smrg case " $new_libs " in 80078c4a8e55Smrg *" $deplib "*) ;; 8008bd23fbfaSmrg *) func_append new_libs " $deplib" ;; 80098c4a8e55Smrg esac 80108c4a8e55Smrg ;; 8011bd23fbfaSmrg *) func_append new_libs " $deplib" ;; 80128c4a8e55Smrg esac 80138c4a8e55Smrg done 80148c4a8e55Smrg deplibs="$new_libs" 80158c4a8e55Smrg 80168c4a8e55Smrg # All the library-specific variables (install_libdir is set above). 80178c4a8e55Smrg library_names= 80188c4a8e55Smrg old_library= 80198c4a8e55Smrg dlname= 80208c4a8e55Smrg 80218c4a8e55Smrg # Test again, we may have decided not to build it any more 80228c4a8e55Smrg if test "$build_libtool_libs" = yes; then 80238c4a8e55Smrg if test "$hardcode_into_libs" = yes; then 80248c4a8e55Smrg # Hardcode the library paths 80258c4a8e55Smrg hardcode_libdirs= 80268c4a8e55Smrg dep_rpath= 80278c4a8e55Smrg rpath="$finalize_rpath" 8028bd23fbfaSmrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 80298c4a8e55Smrg for libdir in $rpath; do 80308c4a8e55Smrg if test -n "$hardcode_libdir_flag_spec"; then 80318c4a8e55Smrg if test -n "$hardcode_libdir_separator"; then 8032bd23fbfaSmrg func_replace_sysroot "$libdir" 8033bd23fbfaSmrg libdir=$func_replace_sysroot_result 80348c4a8e55Smrg if test -z "$hardcode_libdirs"; then 80358c4a8e55Smrg hardcode_libdirs="$libdir" 80368c4a8e55Smrg else 80378c4a8e55Smrg # Just accumulate the unique libdirs. 80388c4a8e55Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 80398c4a8e55Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 80408c4a8e55Smrg ;; 80418c4a8e55Smrg *) 8042bd23fbfaSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 80438c4a8e55Smrg ;; 80448c4a8e55Smrg esac 80458c4a8e55Smrg fi 80468c4a8e55Smrg else 80478c4a8e55Smrg eval flag=\"$hardcode_libdir_flag_spec\" 8048bd23fbfaSmrg func_append dep_rpath " $flag" 80498c4a8e55Smrg fi 80508c4a8e55Smrg elif test -n "$runpath_var"; then 80518c4a8e55Smrg case "$perm_rpath " in 80528c4a8e55Smrg *" $libdir "*) ;; 8053bd23fbfaSmrg *) func_apped perm_rpath " $libdir" ;; 80548c4a8e55Smrg esac 80558c4a8e55Smrg fi 80568c4a8e55Smrg done 80578c4a8e55Smrg # Substitute the hardcoded libdirs into the rpath. 80588c4a8e55Smrg if test -n "$hardcode_libdir_separator" && 80598c4a8e55Smrg test -n "$hardcode_libdirs"; then 80608c4a8e55Smrg libdir="$hardcode_libdirs" 80618c4a8e55Smrg if test -n "$hardcode_libdir_flag_spec_ld"; then 80628c4a8e55Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" 80638c4a8e55Smrg else 80648c4a8e55Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec\" 80658c4a8e55Smrg fi 80668c4a8e55Smrg fi 80678c4a8e55Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 80688c4a8e55Smrg # We should set the runpath_var. 80698c4a8e55Smrg rpath= 80708c4a8e55Smrg for dir in $perm_rpath; do 8071bd23fbfaSmrg func_append rpath "$dir:" 80728c4a8e55Smrg done 80738c4a8e55Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 80748c4a8e55Smrg fi 80758c4a8e55Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 80768c4a8e55Smrg fi 8077b042e37fSmrg 80788c4a8e55Smrg shlibpath="$finalize_shlibpath" 8079bd23fbfaSmrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 80808c4a8e55Smrg if test -n "$shlibpath"; then 80818c4a8e55Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 80828c4a8e55Smrg fi 8083b042e37fSmrg 80848c4a8e55Smrg # Get the real and link names of the library. 80858c4a8e55Smrg eval shared_ext=\"$shrext_cmds\" 80868c4a8e55Smrg eval library_names=\"$library_names_spec\" 80878c4a8e55Smrg set dummy $library_names 80888c4a8e55Smrg shift 80898c4a8e55Smrg realname="$1" 80908c4a8e55Smrg shift 8091b042e37fSmrg 80928c4a8e55Smrg if test -n "$soname_spec"; then 80938c4a8e55Smrg eval soname=\"$soname_spec\" 80948c4a8e55Smrg else 80958c4a8e55Smrg soname="$realname" 80968c4a8e55Smrg fi 80978c4a8e55Smrg if test -z "$dlname"; then 80988c4a8e55Smrg dlname=$soname 80998c4a8e55Smrg fi 8100b042e37fSmrg 81018c4a8e55Smrg lib="$output_objdir/$realname" 81028c4a8e55Smrg linknames= 81038c4a8e55Smrg for link 81048c4a8e55Smrg do 8105bd23fbfaSmrg func_append linknames " $link" 81068c4a8e55Smrg done 8107b042e37fSmrg 81088c4a8e55Smrg # Use standard objects if they are pic 8109706b6b52Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 81108c4a8e55Smrg test "X$libobjs" = "X " && libobjs= 8111b042e37fSmrg 81128c4a8e55Smrg delfiles= 81138c4a8e55Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 81148c4a8e55Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 81158c4a8e55Smrg export_symbols="$output_objdir/$libname.uexp" 8116bd23fbfaSmrg func_append delfiles " $export_symbols" 81178c4a8e55Smrg fi 8118b042e37fSmrg 81198c4a8e55Smrg orig_export_symbols= 81208c4a8e55Smrg case $host_os in 81218c4a8e55Smrg cygwin* | mingw* | cegcc*) 81228c4a8e55Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 81238c4a8e55Smrg # exporting using user supplied symfile 81248c4a8e55Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 81258c4a8e55Smrg # and it's NOT already a .def file. Must figure out 81268c4a8e55Smrg # which of the given symbols are data symbols and tag 81278c4a8e55Smrg # them as such. So, trigger use of export_symbols_cmds. 81288c4a8e55Smrg # export_symbols gets reassigned inside the "prepare 81298c4a8e55Smrg # the list of exported symbols" if statement, so the 81308c4a8e55Smrg # include_expsyms logic still works. 81318c4a8e55Smrg orig_export_symbols="$export_symbols" 81328c4a8e55Smrg export_symbols= 81338c4a8e55Smrg always_export_symbols=yes 81348c4a8e55Smrg fi 81358c4a8e55Smrg fi 81368c4a8e55Smrg ;; 81378c4a8e55Smrg esac 8138b042e37fSmrg 81398c4a8e55Smrg # Prepare the list of exported symbols 81408c4a8e55Smrg if test -z "$export_symbols"; then 81418c4a8e55Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 81428c4a8e55Smrg func_verbose "generating symbol list for \`$libname.la'" 81438c4a8e55Smrg export_symbols="$output_objdir/$libname.exp" 81448c4a8e55Smrg $opt_dry_run || $RM $export_symbols 81458c4a8e55Smrg cmds=$export_symbols_cmds 81468c4a8e55Smrg save_ifs="$IFS"; IFS='~' 8147bd23fbfaSmrg for cmd1 in $cmds; do 81488c4a8e55Smrg IFS="$save_ifs" 8149bd23fbfaSmrg # Take the normal branch if the nm_file_list_spec branch 8150bd23fbfaSmrg # doesn't work or if tool conversion is not needed. 8151bd23fbfaSmrg case $nm_file_list_spec~$to_tool_file_cmd in 8152bd23fbfaSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 8153bd23fbfaSmrg try_normal_branch=yes 8154bd23fbfaSmrg eval cmd=\"$cmd1\" 8155bd23fbfaSmrg func_len " $cmd" 8156bd23fbfaSmrg len=$func_len_result 8157bd23fbfaSmrg ;; 8158bd23fbfaSmrg *) 8159bd23fbfaSmrg try_normal_branch=no 8160bd23fbfaSmrg ;; 8161bd23fbfaSmrg esac 8162bd23fbfaSmrg if test "$try_normal_branch" = yes \ 8163bd23fbfaSmrg && { test "$len" -lt "$max_cmd_len" \ 8164bd23fbfaSmrg || test "$max_cmd_len" -le -1; } 8165bd23fbfaSmrg then 8166bd23fbfaSmrg func_show_eval "$cmd" 'exit $?' 8167bd23fbfaSmrg skipped_export=false 8168bd23fbfaSmrg elif test -n "$nm_file_list_spec"; then 8169bd23fbfaSmrg func_basename "$output" 8170bd23fbfaSmrg output_la=$func_basename_result 8171bd23fbfaSmrg save_libobjs=$libobjs 8172bd23fbfaSmrg save_output=$output 8173bd23fbfaSmrg output=${output_objdir}/${output_la}.nm 8174bd23fbfaSmrg func_to_tool_file "$output" 8175bd23fbfaSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 8176bd23fbfaSmrg func_append delfiles " $output" 8177bd23fbfaSmrg func_verbose "creating $NM input file list: $output" 8178bd23fbfaSmrg for obj in $save_libobjs; do 8179bd23fbfaSmrg func_to_tool_file "$obj" 8180bd23fbfaSmrg $ECHO "$func_to_tool_file_result" 8181bd23fbfaSmrg done > "$output" 8182bd23fbfaSmrg eval cmd=\"$cmd1\" 81838c4a8e55Smrg func_show_eval "$cmd" 'exit $?' 8184bd23fbfaSmrg output=$save_output 8185bd23fbfaSmrg libobjs=$save_libobjs 81868c4a8e55Smrg skipped_export=false 81878c4a8e55Smrg else 81888c4a8e55Smrg # The command line is too long to execute in one step. 81898c4a8e55Smrg func_verbose "using reloadable object file for export list..." 81908c4a8e55Smrg skipped_export=: 81918c4a8e55Smrg # Break out early, otherwise skipped_export may be 81928c4a8e55Smrg # set to false by a later but shorter cmd. 81938c4a8e55Smrg break 81948c4a8e55Smrg fi 81958c4a8e55Smrg done 81968c4a8e55Smrg IFS="$save_ifs" 81978c4a8e55Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 81988c4a8e55Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 81998c4a8e55Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 82008c4a8e55Smrg fi 82018c4a8e55Smrg fi 82028c4a8e55Smrg fi 8203b042e37fSmrg 82048c4a8e55Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 82058c4a8e55Smrg tmp_export_symbols="$export_symbols" 82068c4a8e55Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8207706b6b52Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 82088c4a8e55Smrg fi 8209b042e37fSmrg 82108c4a8e55Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 82118c4a8e55Smrg # The given exports_symbols file has to be filtered, so filter it. 82128c4a8e55Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 82138c4a8e55Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 82148c4a8e55Smrg # 's' commands which not all seds can handle. GNU sed should be fine 82158c4a8e55Smrg # though. Also, the filter scales superlinearly with the number of 82168c4a8e55Smrg # global variables. join(1) would be nice here, but unfortunately 82178c4a8e55Smrg # isn't a blessed tool. 82188c4a8e55Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8219bd23fbfaSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 82208c4a8e55Smrg export_symbols=$output_objdir/$libname.def 82218c4a8e55Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8222b042e37fSmrg fi 8223b042e37fSmrg 82248c4a8e55Smrg tmp_deplibs= 82258c4a8e55Smrg for test_deplib in $deplibs; do 82268c4a8e55Smrg case " $convenience " in 82278c4a8e55Smrg *" $test_deplib "*) ;; 82288c4a8e55Smrg *) 8229bd23fbfaSmrg func_append tmp_deplibs " $test_deplib" 82308c4a8e55Smrg ;; 82318c4a8e55Smrg esac 82328c4a8e55Smrg done 82338c4a8e55Smrg deplibs="$tmp_deplibs" 8234b042e37fSmrg 82358c4a8e55Smrg if test -n "$convenience"; then 82368c4a8e55Smrg if test -n "$whole_archive_flag_spec" && 82378c4a8e55Smrg test "$compiler_needs_object" = yes && 82388c4a8e55Smrg test -z "$libobjs"; then 82398c4a8e55Smrg # extract the archives, so we have objects to list. 82408c4a8e55Smrg # TODO: could optimize this to just extract one archive. 82418c4a8e55Smrg whole_archive_flag_spec= 82428c4a8e55Smrg fi 82438c4a8e55Smrg if test -n "$whole_archive_flag_spec"; then 82448c4a8e55Smrg save_libobjs=$libobjs 82458c4a8e55Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 82468c4a8e55Smrg test "X$libobjs" = "X " && libobjs= 82478c4a8e55Smrg else 82488c4a8e55Smrg gentop="$output_objdir/${outputname}x" 8249bd23fbfaSmrg func_append generated " $gentop" 8250b042e37fSmrg 82518c4a8e55Smrg func_extract_archives $gentop $convenience 8252bd23fbfaSmrg func_append libobjs " $func_extract_archives_result" 82538c4a8e55Smrg test "X$libobjs" = "X " && libobjs= 82548c4a8e55Smrg fi 82558c4a8e55Smrg fi 8256b042e37fSmrg 82578c4a8e55Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 82588c4a8e55Smrg eval flag=\"$thread_safe_flag_spec\" 8259bd23fbfaSmrg func_append linker_flags " $flag" 82608c4a8e55Smrg fi 8261b042e37fSmrg 82628c4a8e55Smrg # Make a backup of the uninstalled library when relinking 8263bd23fbfaSmrg if test "$opt_mode" = relink; then 82648c4a8e55Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 8265b042e37fSmrg fi 8266b042e37fSmrg 82678c4a8e55Smrg # Do each of the archive commands. 82688c4a8e55Smrg if test "$module" = yes && test -n "$module_cmds" ; then 82698c4a8e55Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 82708c4a8e55Smrg eval test_cmds=\"$module_expsym_cmds\" 82718c4a8e55Smrg cmds=$module_expsym_cmds 82728c4a8e55Smrg else 82738c4a8e55Smrg eval test_cmds=\"$module_cmds\" 82748c4a8e55Smrg cmds=$module_cmds 82758c4a8e55Smrg fi 82768c4a8e55Smrg else 82778c4a8e55Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 82788c4a8e55Smrg eval test_cmds=\"$archive_expsym_cmds\" 82798c4a8e55Smrg cmds=$archive_expsym_cmds 82808c4a8e55Smrg else 82818c4a8e55Smrg eval test_cmds=\"$archive_cmds\" 82828c4a8e55Smrg cmds=$archive_cmds 82838c4a8e55Smrg fi 8284b042e37fSmrg fi 8285b042e37fSmrg 82868c4a8e55Smrg if test "X$skipped_export" != "X:" && 82878c4a8e55Smrg func_len " $test_cmds" && 82888c4a8e55Smrg len=$func_len_result && 82898c4a8e55Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 82908c4a8e55Smrg : 82918c4a8e55Smrg else 82928c4a8e55Smrg # The command line is too long to link in one step, link piecewise 82938c4a8e55Smrg # or, if using GNU ld and skipped_export is not :, use a linker 82948c4a8e55Smrg # script. 8295b042e37fSmrg 82968c4a8e55Smrg # Save the value of $output and $libobjs because we want to 82978c4a8e55Smrg # use them later. If we have whole_archive_flag_spec, we 82988c4a8e55Smrg # want to use save_libobjs as it was before 82998c4a8e55Smrg # whole_archive_flag_spec was expanded, because we can't 83008c4a8e55Smrg # assume the linker understands whole_archive_flag_spec. 83018c4a8e55Smrg # This may have to be revisited, in case too many 83028c4a8e55Smrg # convenience libraries get linked in and end up exceeding 83038c4a8e55Smrg # the spec. 83048c4a8e55Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 83058c4a8e55Smrg save_libobjs=$libobjs 83068c4a8e55Smrg fi 83078c4a8e55Smrg save_output=$output 8308706b6b52Smrg func_basename "$output" 8309706b6b52Smrg output_la=$func_basename_result 8310b042e37fSmrg 83118c4a8e55Smrg # Clear the reloadable object creation command queue and 83128c4a8e55Smrg # initialize k to one. 83138c4a8e55Smrg test_cmds= 83148c4a8e55Smrg concat_cmds= 83158c4a8e55Smrg objlist= 83168c4a8e55Smrg last_robj= 83178c4a8e55Smrg k=1 8318b042e37fSmrg 83198c4a8e55Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 83208c4a8e55Smrg output=${output_objdir}/${output_la}.lnkscript 83218c4a8e55Smrg func_verbose "creating GNU ld script: $output" 8322706b6b52Smrg echo 'INPUT (' > $output 83238c4a8e55Smrg for obj in $save_libobjs 83248c4a8e55Smrg do 8325bd23fbfaSmrg func_to_tool_file "$obj" 8326bd23fbfaSmrg $ECHO "$func_to_tool_file_result" >> $output 83278c4a8e55Smrg done 8328706b6b52Smrg echo ')' >> $output 8329bd23fbfaSmrg func_append delfiles " $output" 8330bd23fbfaSmrg func_to_tool_file "$output" 8331bd23fbfaSmrg output=$func_to_tool_file_result 83328c4a8e55Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 83338c4a8e55Smrg output=${output_objdir}/${output_la}.lnk 83348c4a8e55Smrg func_verbose "creating linker input file list: $output" 83358c4a8e55Smrg : > $output 83368c4a8e55Smrg set x $save_libobjs 83378c4a8e55Smrg shift 83388c4a8e55Smrg firstobj= 83398c4a8e55Smrg if test "$compiler_needs_object" = yes; then 83408c4a8e55Smrg firstobj="$1 " 83418c4a8e55Smrg shift 83428c4a8e55Smrg fi 83438c4a8e55Smrg for obj 83448c4a8e55Smrg do 8345bd23fbfaSmrg func_to_tool_file "$obj" 8346bd23fbfaSmrg $ECHO "$func_to_tool_file_result" >> $output 83478c4a8e55Smrg done 8348bd23fbfaSmrg func_append delfiles " $output" 8349bd23fbfaSmrg func_to_tool_file "$output" 8350bd23fbfaSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 83518c4a8e55Smrg else 83528c4a8e55Smrg if test -n "$save_libobjs"; then 83538c4a8e55Smrg func_verbose "creating reloadable object files..." 83548c4a8e55Smrg output=$output_objdir/$output_la-${k}.$objext 83558c4a8e55Smrg eval test_cmds=\"$reload_cmds\" 83568c4a8e55Smrg func_len " $test_cmds" 83578c4a8e55Smrg len0=$func_len_result 83588c4a8e55Smrg len=$len0 83598c4a8e55Smrg 83608c4a8e55Smrg # Loop over the list of objects to be linked. 83618c4a8e55Smrg for obj in $save_libobjs 83628c4a8e55Smrg do 83638c4a8e55Smrg func_len " $obj" 83648c4a8e55Smrg func_arith $len + $func_len_result 83658c4a8e55Smrg len=$func_arith_result 83668c4a8e55Smrg if test "X$objlist" = X || 83678c4a8e55Smrg test "$len" -lt "$max_cmd_len"; then 83688c4a8e55Smrg func_append objlist " $obj" 83698c4a8e55Smrg else 83708c4a8e55Smrg # The command $test_cmds is almost too long, add a 83718c4a8e55Smrg # command to the queue. 83728c4a8e55Smrg if test "$k" -eq 1 ; then 83738c4a8e55Smrg # The first file doesn't have a previous command to add. 8374706b6b52Smrg reload_objs=$objlist 8375706b6b52Smrg eval concat_cmds=\"$reload_cmds\" 83768c4a8e55Smrg else 83778c4a8e55Smrg # All subsequent reloadable object files will link in 83788c4a8e55Smrg # the last one created. 8379706b6b52Smrg reload_objs="$objlist $last_robj" 8380706b6b52Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 83818c4a8e55Smrg fi 83828c4a8e55Smrg last_robj=$output_objdir/$output_la-${k}.$objext 83838c4a8e55Smrg func_arith $k + 1 83848c4a8e55Smrg k=$func_arith_result 83858c4a8e55Smrg output=$output_objdir/$output_la-${k}.$objext 8386706b6b52Smrg objlist=" $obj" 83878c4a8e55Smrg func_len " $last_robj" 83888c4a8e55Smrg func_arith $len0 + $func_len_result 83898c4a8e55Smrg len=$func_arith_result 83908c4a8e55Smrg fi 83918c4a8e55Smrg done 83928c4a8e55Smrg # Handle the remaining objects by creating one last 83938c4a8e55Smrg # reloadable object file. All subsequent reloadable object 83948c4a8e55Smrg # files will link in the last one created. 83958c4a8e55Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8396706b6b52Smrg reload_objs="$objlist $last_robj" 8397706b6b52Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 83988c4a8e55Smrg if test -n "$last_robj"; then 83998c4a8e55Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 84008c4a8e55Smrg fi 8401bd23fbfaSmrg func_append delfiles " $output" 8402b042e37fSmrg 84038c4a8e55Smrg else 84048c4a8e55Smrg output= 84058c4a8e55Smrg fi 8406b042e37fSmrg 84078c4a8e55Smrg if ${skipped_export-false}; then 84088c4a8e55Smrg func_verbose "generating symbol list for \`$libname.la'" 84098c4a8e55Smrg export_symbols="$output_objdir/$libname.exp" 84108c4a8e55Smrg $opt_dry_run || $RM $export_symbols 84118c4a8e55Smrg libobjs=$output 84128c4a8e55Smrg # Append the command to create the export file. 84138c4a8e55Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 84148c4a8e55Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 84158c4a8e55Smrg if test -n "$last_robj"; then 84168c4a8e55Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 84178c4a8e55Smrg fi 84188c4a8e55Smrg fi 8419b042e37fSmrg 84208c4a8e55Smrg test -n "$save_libobjs" && 84218c4a8e55Smrg func_verbose "creating a temporary reloadable object file: $output" 8422b042e37fSmrg 84238c4a8e55Smrg # Loop through the commands generated above and execute them. 84248c4a8e55Smrg save_ifs="$IFS"; IFS='~' 84258c4a8e55Smrg for cmd in $concat_cmds; do 84268c4a8e55Smrg IFS="$save_ifs" 84278c4a8e55Smrg $opt_silent || { 84288c4a8e55Smrg func_quote_for_expand "$cmd" 84298c4a8e55Smrg eval "func_echo $func_quote_for_expand_result" 84308c4a8e55Smrg } 84318c4a8e55Smrg $opt_dry_run || eval "$cmd" || { 84328c4a8e55Smrg lt_exit=$? 84338c4a8e55Smrg 84348c4a8e55Smrg # Restore the uninstalled library and exit 8435bd23fbfaSmrg if test "$opt_mode" = relink; then 84368c4a8e55Smrg ( cd "$output_objdir" && \ 84378c4a8e55Smrg $RM "${realname}T" && \ 84388c4a8e55Smrg $MV "${realname}U" "$realname" ) 84398c4a8e55Smrg fi 8440b042e37fSmrg 84418c4a8e55Smrg exit $lt_exit 84428c4a8e55Smrg } 84438c4a8e55Smrg done 84448c4a8e55Smrg IFS="$save_ifs" 84458c4a8e55Smrg 84468c4a8e55Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 84478c4a8e55Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 84488c4a8e55Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8449b042e37fSmrg fi 8450b042e37fSmrg fi 8451b042e37fSmrg 84528c4a8e55Smrg if ${skipped_export-false}; then 84538c4a8e55Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 84548c4a8e55Smrg tmp_export_symbols="$export_symbols" 84558c4a8e55Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8456706b6b52Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 84578c4a8e55Smrg fi 8458b042e37fSmrg 84598c4a8e55Smrg if test -n "$orig_export_symbols"; then 84608c4a8e55Smrg # The given exports_symbols file has to be filtered, so filter it. 84618c4a8e55Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 84628c4a8e55Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 84638c4a8e55Smrg # 's' commands which not all seds can handle. GNU sed should be fine 84648c4a8e55Smrg # though. Also, the filter scales superlinearly with the number of 84658c4a8e55Smrg # global variables. join(1) would be nice here, but unfortunately 84668c4a8e55Smrg # isn't a blessed tool. 84678c4a8e55Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8468bd23fbfaSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 84698c4a8e55Smrg export_symbols=$output_objdir/$libname.def 84708c4a8e55Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 84718c4a8e55Smrg fi 84728c4a8e55Smrg fi 8473b042e37fSmrg 84748c4a8e55Smrg libobjs=$output 84758c4a8e55Smrg # Restore the value of output. 84768c4a8e55Smrg output=$save_output 8477b042e37fSmrg 84788c4a8e55Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 84798c4a8e55Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 84808c4a8e55Smrg test "X$libobjs" = "X " && libobjs= 84818c4a8e55Smrg fi 84828c4a8e55Smrg # Expand the library linking commands again to reset the 84838c4a8e55Smrg # value of $libobjs for piecewise linking. 84848c4a8e55Smrg 84858c4a8e55Smrg # Do each of the archive commands. 84868c4a8e55Smrg if test "$module" = yes && test -n "$module_cmds" ; then 84878c4a8e55Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 84888c4a8e55Smrg cmds=$module_expsym_cmds 8489b042e37fSmrg else 84908c4a8e55Smrg cmds=$module_cmds 8491b042e37fSmrg fi 8492b042e37fSmrg else 84938c4a8e55Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 84948c4a8e55Smrg cmds=$archive_expsym_cmds 84958c4a8e55Smrg else 84968c4a8e55Smrg cmds=$archive_cmds 84978c4a8e55Smrg fi 8498b042e37fSmrg fi 8499b042e37fSmrg fi 8500b042e37fSmrg 85018c4a8e55Smrg if test -n "$delfiles"; then 85028c4a8e55Smrg # Append the command to remove temporary files to $cmds. 85038c4a8e55Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 85048c4a8e55Smrg fi 8505b042e37fSmrg 85068c4a8e55Smrg # Add any objects from preloaded convenience libraries 85078c4a8e55Smrg if test -n "$dlprefiles"; then 85088c4a8e55Smrg gentop="$output_objdir/${outputname}x" 8509bd23fbfaSmrg func_append generated " $gentop" 8510b042e37fSmrg 85118c4a8e55Smrg func_extract_archives $gentop $dlprefiles 8512bd23fbfaSmrg func_append libobjs " $func_extract_archives_result" 85138c4a8e55Smrg test "X$libobjs" = "X " && libobjs= 8514b042e37fSmrg fi 8515b042e37fSmrg 85168c4a8e55Smrg save_ifs="$IFS"; IFS='~' 85178c4a8e55Smrg for cmd in $cmds; do 85188c4a8e55Smrg IFS="$save_ifs" 85198c4a8e55Smrg eval cmd=\"$cmd\" 85208c4a8e55Smrg $opt_silent || { 85218c4a8e55Smrg func_quote_for_expand "$cmd" 85228c4a8e55Smrg eval "func_echo $func_quote_for_expand_result" 85238c4a8e55Smrg } 85248c4a8e55Smrg $opt_dry_run || eval "$cmd" || { 85258c4a8e55Smrg lt_exit=$? 8526b042e37fSmrg 85278c4a8e55Smrg # Restore the uninstalled library and exit 8528bd23fbfaSmrg if test "$opt_mode" = relink; then 85298c4a8e55Smrg ( cd "$output_objdir" && \ 85308c4a8e55Smrg $RM "${realname}T" && \ 85318c4a8e55Smrg $MV "${realname}U" "$realname" ) 85328c4a8e55Smrg fi 85338c4a8e55Smrg 85348c4a8e55Smrg exit $lt_exit 85358c4a8e55Smrg } 85368c4a8e55Smrg done 85378c4a8e55Smrg IFS="$save_ifs" 85388c4a8e55Smrg 85398c4a8e55Smrg # Restore the uninstalled library and exit 8540bd23fbfaSmrg if test "$opt_mode" = relink; then 85418c4a8e55Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 85428c4a8e55Smrg 85438c4a8e55Smrg if test -n "$convenience"; then 85448c4a8e55Smrg if test -z "$whole_archive_flag_spec"; then 85458c4a8e55Smrg func_show_eval '${RM}r "$gentop"' 8546b042e37fSmrg fi 8547b042e37fSmrg fi 8548b042e37fSmrg 85498c4a8e55Smrg exit $EXIT_SUCCESS 85508c4a8e55Smrg fi 8551b042e37fSmrg 85528c4a8e55Smrg # Create links to the real library. 85538c4a8e55Smrg for linkname in $linknames; do 85548c4a8e55Smrg if test "$realname" != "$linkname"; then 85558c4a8e55Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 85568c4a8e55Smrg fi 85578c4a8e55Smrg done 85588c4a8e55Smrg 85598c4a8e55Smrg # If -module or -export-dynamic was specified, set the dlname. 85608c4a8e55Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 85618c4a8e55Smrg # On all known operating systems, these are identical. 85628c4a8e55Smrg dlname="$soname" 85638c4a8e55Smrg fi 85648c4a8e55Smrg fi 85658c4a8e55Smrg ;; 85668c4a8e55Smrg 85678c4a8e55Smrg obj) 85688c4a8e55Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 85698c4a8e55Smrg func_warning "\`-dlopen' is ignored for objects" 85708c4a8e55Smrg fi 85718c4a8e55Smrg 85728c4a8e55Smrg case " $deplibs" in 85738c4a8e55Smrg *\ -l* | *\ -L*) 85748c4a8e55Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 85758c4a8e55Smrg esac 85768c4a8e55Smrg 85778c4a8e55Smrg test -n "$rpath" && \ 85788c4a8e55Smrg func_warning "\`-rpath' is ignored for objects" 85798c4a8e55Smrg 85808c4a8e55Smrg test -n "$xrpath" && \ 85818c4a8e55Smrg func_warning "\`-R' is ignored for objects" 85828c4a8e55Smrg 85838c4a8e55Smrg test -n "$vinfo" && \ 85848c4a8e55Smrg func_warning "\`-version-info' is ignored for objects" 85858c4a8e55Smrg 85868c4a8e55Smrg test -n "$release" && \ 85878c4a8e55Smrg func_warning "\`-release' is ignored for objects" 85888c4a8e55Smrg 85898c4a8e55Smrg case $output in 85908c4a8e55Smrg *.lo) 85918c4a8e55Smrg test -n "$objs$old_deplibs" && \ 85928c4a8e55Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 85938c4a8e55Smrg 85948c4a8e55Smrg libobj=$output 85958c4a8e55Smrg func_lo2o "$libobj" 85968c4a8e55Smrg obj=$func_lo2o_result 85978c4a8e55Smrg ;; 85988c4a8e55Smrg *) 85998c4a8e55Smrg libobj= 86008c4a8e55Smrg obj="$output" 86018c4a8e55Smrg ;; 86028c4a8e55Smrg esac 86038c4a8e55Smrg 86048c4a8e55Smrg # Delete the old objects. 86058c4a8e55Smrg $opt_dry_run || $RM $obj $libobj 86068c4a8e55Smrg 86078c4a8e55Smrg # Objects from convenience libraries. This assumes 86088c4a8e55Smrg # single-version convenience libraries. Whenever we create 86098c4a8e55Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 86108c4a8e55Smrg # the extraction. 86118c4a8e55Smrg reload_conv_objs= 86128c4a8e55Smrg gentop= 86138c4a8e55Smrg # reload_cmds runs $LD directly, so let us get rid of 86148c4a8e55Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 86158c4a8e55Smrg # turning comma into space.. 86168c4a8e55Smrg wl= 86178c4a8e55Smrg 86188c4a8e55Smrg if test -n "$convenience"; then 86198c4a8e55Smrg if test -n "$whole_archive_flag_spec"; then 86208c4a8e55Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 8621706b6b52Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 86228c4a8e55Smrg else 86238c4a8e55Smrg gentop="$output_objdir/${obj}x" 8624bd23fbfaSmrg func_append generated " $gentop" 86258c4a8e55Smrg 86268c4a8e55Smrg func_extract_archives $gentop $convenience 86278c4a8e55Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 86288c4a8e55Smrg fi 86298c4a8e55Smrg fi 8630b042e37fSmrg 8631bd23fbfaSmrg # If we're not building shared, we need to use non_pic_objs 8632bd23fbfaSmrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 8633bd23fbfaSmrg 86348c4a8e55Smrg # Create the old-style object. 8635706b6b52Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 8636b042e37fSmrg 86378c4a8e55Smrg output="$obj" 86388c4a8e55Smrg func_execute_cmds "$reload_cmds" 'exit $?' 8639b042e37fSmrg 86408c4a8e55Smrg # Exit if we aren't doing a library object file. 86418c4a8e55Smrg if test -z "$libobj"; then 86428c4a8e55Smrg if test -n "$gentop"; then 86438c4a8e55Smrg func_show_eval '${RM}r "$gentop"' 86448c4a8e55Smrg fi 8645b042e37fSmrg 86468c4a8e55Smrg exit $EXIT_SUCCESS 86478c4a8e55Smrg fi 8648b042e37fSmrg 86498c4a8e55Smrg if test "$build_libtool_libs" != yes; then 86508c4a8e55Smrg if test -n "$gentop"; then 86518c4a8e55Smrg func_show_eval '${RM}r "$gentop"' 86528c4a8e55Smrg fi 8653b042e37fSmrg 86548c4a8e55Smrg # Create an invalid libtool object if no PIC, so that we don't 86558c4a8e55Smrg # accidentally link it into a program. 86568c4a8e55Smrg # $show "echo timestamp > $libobj" 86578c4a8e55Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 86588c4a8e55Smrg exit $EXIT_SUCCESS 86598c4a8e55Smrg fi 8660b042e37fSmrg 86618c4a8e55Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 86628c4a8e55Smrg # Only do commands if we really have different PIC objects. 86638c4a8e55Smrg reload_objs="$libobjs $reload_conv_objs" 86648c4a8e55Smrg output="$libobj" 86658c4a8e55Smrg func_execute_cmds "$reload_cmds" 'exit $?' 8666b042e37fSmrg fi 8667b042e37fSmrg 86688c4a8e55Smrg if test -n "$gentop"; then 86698c4a8e55Smrg func_show_eval '${RM}r "$gentop"' 86708c4a8e55Smrg fi 8671b042e37fSmrg 86728c4a8e55Smrg exit $EXIT_SUCCESS 86738c4a8e55Smrg ;; 8674b042e37fSmrg 86758c4a8e55Smrg prog) 86768c4a8e55Smrg case $host in 86778c4a8e55Smrg *cygwin*) func_stripname '' '.exe' "$output" 86788c4a8e55Smrg output=$func_stripname_result.exe;; 8679b042e37fSmrg esac 86808c4a8e55Smrg test -n "$vinfo" && \ 86818c4a8e55Smrg func_warning "\`-version-info' is ignored for programs" 8682b042e37fSmrg 86838c4a8e55Smrg test -n "$release" && \ 86848c4a8e55Smrg func_warning "\`-release' is ignored for programs" 8685b042e37fSmrg 86868c4a8e55Smrg test "$preload" = yes \ 86878c4a8e55Smrg && test "$dlopen_support" = unknown \ 86888c4a8e55Smrg && test "$dlopen_self" = unknown \ 86898c4a8e55Smrg && test "$dlopen_self_static" = unknown && \ 86908c4a8e55Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 8691b042e37fSmrg 86928c4a8e55Smrg case $host in 86938c4a8e55Smrg *-*-rhapsody* | *-*-darwin1.[012]) 86948c4a8e55Smrg # On Rhapsody replace the C library is the System framework 8695706b6b52Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 8696706b6b52Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 8697b042e37fSmrg ;; 8698b042e37fSmrg esac 8699b042e37fSmrg 87008c4a8e55Smrg case $host in 87018c4a8e55Smrg *-*-darwin*) 87028c4a8e55Smrg # Don't allow lazy linking, it breaks C++ global constructors 87038c4a8e55Smrg # But is supposedly fixed on 10.4 or later (yay!). 87048c4a8e55Smrg if test "$tagname" = CXX ; then 87058c4a8e55Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 87068c4a8e55Smrg 10.[0123]) 8707bd23fbfaSmrg func_append compile_command " ${wl}-bind_at_load" 8708bd23fbfaSmrg func_append finalize_command " ${wl}-bind_at_load" 87098c4a8e55Smrg ;; 87108c4a8e55Smrg esac 87118c4a8e55Smrg fi 87128c4a8e55Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 8713706b6b52Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8714706b6b52Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8715b042e37fSmrg ;; 8716b042e37fSmrg esac 8717b042e37fSmrg 8718b042e37fSmrg 87198c4a8e55Smrg # move library search paths that coincide with paths to not yet 87208c4a8e55Smrg # installed libraries to the beginning of the library search list 87218c4a8e55Smrg new_libs= 87228c4a8e55Smrg for path in $notinst_path; do 87238c4a8e55Smrg case " $new_libs " in 87248c4a8e55Smrg *" -L$path/$objdir "*) ;; 8725b042e37fSmrg *) 87268c4a8e55Smrg case " $compile_deplibs " in 87278c4a8e55Smrg *" -L$path/$objdir "*) 8728bd23fbfaSmrg func_append new_libs " -L$path/$objdir" ;; 87298c4a8e55Smrg esac 8730b042e37fSmrg ;; 8731b042e37fSmrg esac 8732b042e37fSmrg done 87338c4a8e55Smrg for deplib in $compile_deplibs; do 87348c4a8e55Smrg case $deplib in 87358c4a8e55Smrg -L*) 87368c4a8e55Smrg case " $new_libs " in 87378c4a8e55Smrg *" $deplib "*) ;; 8738bd23fbfaSmrg *) func_append new_libs " $deplib" ;; 87398c4a8e55Smrg esac 87408c4a8e55Smrg ;; 8741bd23fbfaSmrg *) func_append new_libs " $deplib" ;; 87428c4a8e55Smrg esac 87438c4a8e55Smrg done 87448c4a8e55Smrg compile_deplibs="$new_libs" 8745b042e37fSmrg 8746b042e37fSmrg 8747bd23fbfaSmrg func_append compile_command " $compile_deplibs" 8748bd23fbfaSmrg func_append finalize_command " $finalize_deplibs" 8749b042e37fSmrg 87508c4a8e55Smrg if test -n "$rpath$xrpath"; then 87518c4a8e55Smrg # If the user specified any rpath flags, then add them. 87528c4a8e55Smrg for libdir in $rpath $xrpath; do 87538c4a8e55Smrg # This is the magic to use -rpath. 87548c4a8e55Smrg case "$finalize_rpath " in 87558c4a8e55Smrg *" $libdir "*) ;; 8756bd23fbfaSmrg *) func_append finalize_rpath " $libdir" ;; 87578c4a8e55Smrg esac 87588c4a8e55Smrg done 87598c4a8e55Smrg fi 8760b042e37fSmrg 87618c4a8e55Smrg # Now hardcode the library paths 87628c4a8e55Smrg rpath= 87638c4a8e55Smrg hardcode_libdirs= 87648c4a8e55Smrg for libdir in $compile_rpath $finalize_rpath; do 87658c4a8e55Smrg if test -n "$hardcode_libdir_flag_spec"; then 87668c4a8e55Smrg if test -n "$hardcode_libdir_separator"; then 87678c4a8e55Smrg if test -z "$hardcode_libdirs"; then 87688c4a8e55Smrg hardcode_libdirs="$libdir" 87698c4a8e55Smrg else 87708c4a8e55Smrg # Just accumulate the unique libdirs. 87718c4a8e55Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 87728c4a8e55Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 87738c4a8e55Smrg ;; 87748c4a8e55Smrg *) 8775bd23fbfaSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 87768c4a8e55Smrg ;; 87778c4a8e55Smrg esac 87788c4a8e55Smrg fi 87798c4a8e55Smrg else 87808c4a8e55Smrg eval flag=\"$hardcode_libdir_flag_spec\" 8781bd23fbfaSmrg func_append rpath " $flag" 87828c4a8e55Smrg fi 87838c4a8e55Smrg elif test -n "$runpath_var"; then 87848c4a8e55Smrg case "$perm_rpath " in 8785b042e37fSmrg *" $libdir "*) ;; 8786bd23fbfaSmrg *) func_append perm_rpath " $libdir" ;; 8787b042e37fSmrg esac 87888c4a8e55Smrg fi 87898c4a8e55Smrg case $host in 87908c4a8e55Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 87918c4a8e55Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 87928c4a8e55Smrg case :$dllsearchpath: in 87938c4a8e55Smrg *":$libdir:"*) ;; 87948c4a8e55Smrg ::) dllsearchpath=$libdir;; 8795bd23fbfaSmrg *) func_append dllsearchpath ":$libdir";; 87968c4a8e55Smrg esac 87978c4a8e55Smrg case :$dllsearchpath: in 87988c4a8e55Smrg *":$testbindir:"*) ;; 87998c4a8e55Smrg ::) dllsearchpath=$testbindir;; 8800bd23fbfaSmrg *) func_append dllsearchpath ":$testbindir";; 88018c4a8e55Smrg esac 88028c4a8e55Smrg ;; 88038c4a8e55Smrg esac 88048c4a8e55Smrg done 88058c4a8e55Smrg # Substitute the hardcoded libdirs into the rpath. 88068c4a8e55Smrg if test -n "$hardcode_libdir_separator" && 88078c4a8e55Smrg test -n "$hardcode_libdirs"; then 88088c4a8e55Smrg libdir="$hardcode_libdirs" 88098c4a8e55Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 88108c4a8e55Smrg fi 88118c4a8e55Smrg compile_rpath="$rpath" 88128c4a8e55Smrg 88138c4a8e55Smrg rpath= 88148c4a8e55Smrg hardcode_libdirs= 88158c4a8e55Smrg for libdir in $finalize_rpath; do 88168c4a8e55Smrg if test -n "$hardcode_libdir_flag_spec"; then 88178c4a8e55Smrg if test -n "$hardcode_libdir_separator"; then 88188c4a8e55Smrg if test -z "$hardcode_libdirs"; then 88198c4a8e55Smrg hardcode_libdirs="$libdir" 88208c4a8e55Smrg else 88218c4a8e55Smrg # Just accumulate the unique libdirs. 88228c4a8e55Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 88238c4a8e55Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 88248c4a8e55Smrg ;; 88258c4a8e55Smrg *) 8826bd23fbfaSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 88278c4a8e55Smrg ;; 88288c4a8e55Smrg esac 88298c4a8e55Smrg fi 88308c4a8e55Smrg else 88318c4a8e55Smrg eval flag=\"$hardcode_libdir_flag_spec\" 8832bd23fbfaSmrg func_append rpath " $flag" 88338c4a8e55Smrg fi 88348c4a8e55Smrg elif test -n "$runpath_var"; then 88358c4a8e55Smrg case "$finalize_perm_rpath " in 8836b042e37fSmrg *" $libdir "*) ;; 8837bd23fbfaSmrg *) func_append finalize_perm_rpath " $libdir" ;; 8838b042e37fSmrg esac 8839b042e37fSmrg fi 88408c4a8e55Smrg done 88418c4a8e55Smrg # Substitute the hardcoded libdirs into the rpath. 88428c4a8e55Smrg if test -n "$hardcode_libdir_separator" && 88438c4a8e55Smrg test -n "$hardcode_libdirs"; then 88448c4a8e55Smrg libdir="$hardcode_libdirs" 88458c4a8e55Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 88468c4a8e55Smrg fi 88478c4a8e55Smrg finalize_rpath="$rpath" 8848b042e37fSmrg 88498c4a8e55Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 88508c4a8e55Smrg # Transform all the library objects into standard objects. 8851706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8852706b6b52Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 88538c4a8e55Smrg fi 8854b042e37fSmrg 88558c4a8e55Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8856b042e37fSmrg 88578c4a8e55Smrg # template prelinking step 88588c4a8e55Smrg if test -n "$prelink_cmds"; then 88598c4a8e55Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 88608c4a8e55Smrg fi 8861b042e37fSmrg 88628c4a8e55Smrg wrappers_required=yes 88638c4a8e55Smrg case $host in 8864706b6b52Smrg *cegcc* | *mingw32ce*) 8865706b6b52Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 8866706b6b52Smrg wrappers_required=no 8867706b6b52Smrg ;; 88688c4a8e55Smrg *cygwin* | *mingw* ) 88698c4a8e55Smrg if test "$build_libtool_libs" != yes; then 88708c4a8e55Smrg wrappers_required=no 88718c4a8e55Smrg fi 88728c4a8e55Smrg ;; 88738c4a8e55Smrg *) 88748c4a8e55Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 88758c4a8e55Smrg wrappers_required=no 88768c4a8e55Smrg fi 88778c4a8e55Smrg ;; 88788c4a8e55Smrg esac 88798c4a8e55Smrg if test "$wrappers_required" = no; then 88808c4a8e55Smrg # Replace the output file specification. 8881706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 88828c4a8e55Smrg link_command="$compile_command$compile_rpath" 8883b042e37fSmrg 88848c4a8e55Smrg # We have no uninstalled library dependencies, so finalize right now. 88858c4a8e55Smrg exit_status=0 88868c4a8e55Smrg func_show_eval "$link_command" 'exit_status=$?' 8887b042e37fSmrg 8888bd23fbfaSmrg if test -n "$postlink_cmds"; then 8889bd23fbfaSmrg func_to_tool_file "$output" 8890bd23fbfaSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8891bd23fbfaSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 8892bd23fbfaSmrg fi 8893bd23fbfaSmrg 88948c4a8e55Smrg # Delete the generated files. 88958c4a8e55Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 88968c4a8e55Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 88978c4a8e55Smrg fi 8898b042e37fSmrg 88998c4a8e55Smrg exit $exit_status 89008c4a8e55Smrg fi 8901b042e37fSmrg 89028c4a8e55Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 89038c4a8e55Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 89048c4a8e55Smrg fi 89058c4a8e55Smrg if test -n "$finalize_shlibpath"; then 89068c4a8e55Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 89078c4a8e55Smrg fi 8908b042e37fSmrg 89098c4a8e55Smrg compile_var= 89108c4a8e55Smrg finalize_var= 89118c4a8e55Smrg if test -n "$runpath_var"; then 89128c4a8e55Smrg if test -n "$perm_rpath"; then 89138c4a8e55Smrg # We should set the runpath_var. 89148c4a8e55Smrg rpath= 89158c4a8e55Smrg for dir in $perm_rpath; do 8916bd23fbfaSmrg func_append rpath "$dir:" 8917b042e37fSmrg done 89188c4a8e55Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8919b042e37fSmrg fi 89208c4a8e55Smrg if test -n "$finalize_perm_rpath"; then 89218c4a8e55Smrg # We should set the runpath_var. 89228c4a8e55Smrg rpath= 89238c4a8e55Smrg for dir in $finalize_perm_rpath; do 8924bd23fbfaSmrg func_append rpath "$dir:" 89258c4a8e55Smrg done 89268c4a8e55Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 89278c4a8e55Smrg fi 89288c4a8e55Smrg fi 8929b042e37fSmrg 89308c4a8e55Smrg if test "$no_install" = yes; then 89318c4a8e55Smrg # We don't need to create a wrapper script. 89328c4a8e55Smrg link_command="$compile_var$compile_command$compile_rpath" 89338c4a8e55Smrg # Replace the output file specification. 8934706b6b52Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 89358c4a8e55Smrg # Delete the old output file. 89368c4a8e55Smrg $opt_dry_run || $RM $output 89378c4a8e55Smrg # Link the executable and exit 89388c4a8e55Smrg func_show_eval "$link_command" 'exit $?' 8939bd23fbfaSmrg 8940bd23fbfaSmrg if test -n "$postlink_cmds"; then 8941bd23fbfaSmrg func_to_tool_file "$output" 8942bd23fbfaSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8943bd23fbfaSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 8944bd23fbfaSmrg fi 8945bd23fbfaSmrg 89468c4a8e55Smrg exit $EXIT_SUCCESS 89478c4a8e55Smrg fi 8948b042e37fSmrg 89498c4a8e55Smrg if test "$hardcode_action" = relink; then 89508c4a8e55Smrg # Fast installation is not supported 89518c4a8e55Smrg link_command="$compile_var$compile_command$compile_rpath" 89528c4a8e55Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8953b042e37fSmrg 89548c4a8e55Smrg func_warning "this platform does not like uninstalled shared libraries" 89558c4a8e55Smrg func_warning "\`$output' will be relinked during installation" 89568c4a8e55Smrg else 89578c4a8e55Smrg if test "$fast_install" != no; then 89588c4a8e55Smrg link_command="$finalize_var$compile_command$finalize_rpath" 89598c4a8e55Smrg if test "$fast_install" = yes; then 8960706b6b52Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 89618c4a8e55Smrg else 89628c4a8e55Smrg # fast_install is set to needless 89638c4a8e55Smrg relink_command= 89648c4a8e55Smrg fi 8965b042e37fSmrg else 89668c4a8e55Smrg link_command="$compile_var$compile_command$compile_rpath" 89678c4a8e55Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8968b042e37fSmrg fi 89698c4a8e55Smrg fi 8970b042e37fSmrg 89718c4a8e55Smrg # Replace the output file specification. 8972706b6b52Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 8973b042e37fSmrg 89748c4a8e55Smrg # Delete the old output files. 89758c4a8e55Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 8976b042e37fSmrg 89778c4a8e55Smrg func_show_eval "$link_command" 'exit $?' 8978b042e37fSmrg 8979bd23fbfaSmrg if test -n "$postlink_cmds"; then 8980bd23fbfaSmrg func_to_tool_file "$output_objdir/$outputname" 8981bd23fbfaSmrg 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'` 8982bd23fbfaSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 8983bd23fbfaSmrg fi 8984bd23fbfaSmrg 89858c4a8e55Smrg # Now create the wrapper script. 89868c4a8e55Smrg func_verbose "creating $output" 8987b042e37fSmrg 89888c4a8e55Smrg # Quote the relink command for shipping. 89898c4a8e55Smrg if test -n "$relink_command"; then 89908c4a8e55Smrg # Preserve any variables that may affect compiler behavior 89918c4a8e55Smrg for var in $variables_saved_for_relink; do 89928c4a8e55Smrg if eval test -z \"\${$var+set}\"; then 89938c4a8e55Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 89948c4a8e55Smrg elif eval var_value=\$$var; test -z "$var_value"; then 89958c4a8e55Smrg relink_command="$var=; export $var; $relink_command" 89968c4a8e55Smrg else 89978c4a8e55Smrg func_quote_for_eval "$var_value" 89988c4a8e55Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 89998c4a8e55Smrg fi 90008c4a8e55Smrg done 90018c4a8e55Smrg relink_command="(cd `pwd`; $relink_command)" 9002706b6b52Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 90038c4a8e55Smrg fi 9004b042e37fSmrg 90058c4a8e55Smrg # Only actually do things if not in dry run mode. 90068c4a8e55Smrg $opt_dry_run || { 90078c4a8e55Smrg # win32 will think the script is a binary if it has 90088c4a8e55Smrg # a .exe suffix, so we strip it off here. 90098c4a8e55Smrg case $output in 90108c4a8e55Smrg *.exe) func_stripname '' '.exe' "$output" 90118c4a8e55Smrg output=$func_stripname_result ;; 90128c4a8e55Smrg esac 90138c4a8e55Smrg # test for cygwin because mv fails w/o .exe extensions 9014b042e37fSmrg case $host in 90158c4a8e55Smrg *cygwin*) 90168c4a8e55Smrg exeext=.exe 90178c4a8e55Smrg func_stripname '' '.exe' "$outputname" 90188c4a8e55Smrg outputname=$func_stripname_result ;; 90198c4a8e55Smrg *) exeext= ;; 9020b042e37fSmrg esac 90218c4a8e55Smrg case $host in 90228c4a8e55Smrg *cygwin* | *mingw* ) 90238c4a8e55Smrg func_dirname_and_basename "$output" "" "." 90248c4a8e55Smrg output_name=$func_basename_result 90258c4a8e55Smrg output_path=$func_dirname_result 90268c4a8e55Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 90278c4a8e55Smrg cwrapper="$output_path/$output_name.exe" 90288c4a8e55Smrg $RM $cwrappersource $cwrapper 90298c4a8e55Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 90308c4a8e55Smrg 90318c4a8e55Smrg func_emit_cwrapperexe_src > $cwrappersource 90328c4a8e55Smrg 90338c4a8e55Smrg # The wrapper executable is built using the $host compiler, 90348c4a8e55Smrg # because it contains $host paths and files. If cross- 90358c4a8e55Smrg # compiling, it, like the target executable, must be 90368c4a8e55Smrg # executed on the $host or under an emulation environment. 90378c4a8e55Smrg $opt_dry_run || { 90388c4a8e55Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 90398c4a8e55Smrg $STRIP $cwrapper 90408c4a8e55Smrg } 9041b042e37fSmrg 90428c4a8e55Smrg # Now, create the wrapper script for func_source use: 90438c4a8e55Smrg func_ltwrapper_scriptname $cwrapper 90448c4a8e55Smrg $RM $func_ltwrapper_scriptname_result 90458c4a8e55Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 90468c4a8e55Smrg $opt_dry_run || { 90478c4a8e55Smrg # note: this script will not be executed, so do not chmod. 90488c4a8e55Smrg if test "x$build" = "x$host" ; then 90498c4a8e55Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 9050b042e37fSmrg else 90518c4a8e55Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 9052b042e37fSmrg fi 90538c4a8e55Smrg } 90548c4a8e55Smrg ;; 90558c4a8e55Smrg * ) 90568c4a8e55Smrg $RM $output 90578c4a8e55Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 9058b042e37fSmrg 90598c4a8e55Smrg func_emit_wrapper no > $output 90608c4a8e55Smrg chmod +x $output 9061b042e37fSmrg ;; 9062b042e37fSmrg esac 90638c4a8e55Smrg } 90648c4a8e55Smrg exit $EXIT_SUCCESS 90658c4a8e55Smrg ;; 90668c4a8e55Smrg esac 9067b042e37fSmrg 90688c4a8e55Smrg # See if we need to build an old-fashioned archive. 90698c4a8e55Smrg for oldlib in $oldlibs; do 9070b042e37fSmrg 90718c4a8e55Smrg if test "$build_libtool_libs" = convenience; then 90728c4a8e55Smrg oldobjs="$libobjs_save $symfileobj" 90738c4a8e55Smrg addlibs="$convenience" 90748c4a8e55Smrg build_libtool_libs=no 90758c4a8e55Smrg else 90768c4a8e55Smrg if test "$build_libtool_libs" = module; then 90778c4a8e55Smrg oldobjs="$libobjs_save" 90788c4a8e55Smrg build_libtool_libs=no 90798c4a8e55Smrg else 90808c4a8e55Smrg oldobjs="$old_deplibs $non_pic_objects" 90818c4a8e55Smrg if test "$preload" = yes && test -f "$symfileobj"; then 9082bd23fbfaSmrg func_append oldobjs " $symfileobj" 90838c4a8e55Smrg fi 90848c4a8e55Smrg fi 90858c4a8e55Smrg addlibs="$old_convenience" 9086b042e37fSmrg fi 9087b042e37fSmrg 90888c4a8e55Smrg if test -n "$addlibs"; then 90898c4a8e55Smrg gentop="$output_objdir/${outputname}x" 9090bd23fbfaSmrg func_append generated " $gentop" 9091b042e37fSmrg 90928c4a8e55Smrg func_extract_archives $gentop $addlibs 9093bd23fbfaSmrg func_append oldobjs " $func_extract_archives_result" 90948c4a8e55Smrg fi 9095b042e37fSmrg 90968c4a8e55Smrg # Do each command in the archive commands. 90978c4a8e55Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 90988c4a8e55Smrg cmds=$old_archive_from_new_cmds 90998c4a8e55Smrg else 9100b042e37fSmrg 91018c4a8e55Smrg # Add any objects from preloaded convenience libraries 91028c4a8e55Smrg if test -n "$dlprefiles"; then 91038c4a8e55Smrg gentop="$output_objdir/${outputname}x" 9104bd23fbfaSmrg func_append generated " $gentop" 9105b042e37fSmrg 91068c4a8e55Smrg func_extract_archives $gentop $dlprefiles 9107bd23fbfaSmrg func_append oldobjs " $func_extract_archives_result" 91088c4a8e55Smrg fi 9109b042e37fSmrg 91108c4a8e55Smrg # POSIX demands no paths to be encoded in archives. We have 91118c4a8e55Smrg # to avoid creating archives with duplicate basenames if we 91128c4a8e55Smrg # might have to extract them afterwards, e.g., when creating a 91138c4a8e55Smrg # static archive out of a convenience library, or when linking 91148c4a8e55Smrg # the entirety of a libtool archive into another (currently 91158c4a8e55Smrg # not supported by libtool). 91168c4a8e55Smrg if (for obj in $oldobjs 91178c4a8e55Smrg do 91188c4a8e55Smrg func_basename "$obj" 91198c4a8e55Smrg $ECHO "$func_basename_result" 91208c4a8e55Smrg done | sort | sort -uc >/dev/null 2>&1); then 91218c4a8e55Smrg : 91228c4a8e55Smrg else 9123706b6b52Smrg echo "copying selected object files to avoid basename conflicts..." 91248c4a8e55Smrg gentop="$output_objdir/${outputname}x" 9125bd23fbfaSmrg func_append generated " $gentop" 91268c4a8e55Smrg func_mkdir_p "$gentop" 91278c4a8e55Smrg save_oldobjs=$oldobjs 91288c4a8e55Smrg oldobjs= 91298c4a8e55Smrg counter=1 91308c4a8e55Smrg for obj in $save_oldobjs 91318c4a8e55Smrg do 91328c4a8e55Smrg func_basename "$obj" 91338c4a8e55Smrg objbase="$func_basename_result" 91348c4a8e55Smrg case " $oldobjs " in 91358c4a8e55Smrg " ") oldobjs=$obj ;; 91368c4a8e55Smrg *[\ /]"$objbase "*) 91378c4a8e55Smrg while :; do 91388c4a8e55Smrg # Make sure we don't pick an alternate name that also 91398c4a8e55Smrg # overlaps. 91408c4a8e55Smrg newobj=lt$counter-$objbase 91418c4a8e55Smrg func_arith $counter + 1 91428c4a8e55Smrg counter=$func_arith_result 91438c4a8e55Smrg case " $oldobjs " in 91448c4a8e55Smrg *[\ /]"$newobj "*) ;; 91458c4a8e55Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 91468c4a8e55Smrg esac 91478c4a8e55Smrg done 91488c4a8e55Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 9149bd23fbfaSmrg func_append oldobjs " $gentop/$newobj" 91508c4a8e55Smrg ;; 9151bd23fbfaSmrg *) func_append oldobjs " $obj" ;; 91528c4a8e55Smrg esac 9153b042e37fSmrg done 9154b042e37fSmrg fi 91558c4a8e55Smrg eval cmds=\"$old_archive_cmds\" 9156b042e37fSmrg 91578c4a8e55Smrg func_len " $cmds" 91588c4a8e55Smrg len=$func_len_result 91598c4a8e55Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 91608c4a8e55Smrg cmds=$old_archive_cmds 9161bd23fbfaSmrg elif test -n "$archiver_list_spec"; then 9162bd23fbfaSmrg func_verbose "using command file archive linking..." 9163bd23fbfaSmrg for obj in $oldobjs 9164bd23fbfaSmrg do 9165bd23fbfaSmrg func_to_tool_file "$obj" 9166bd23fbfaSmrg $ECHO "$func_to_tool_file_result" 9167bd23fbfaSmrg done > $output_objdir/$libname.libcmd 9168bd23fbfaSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 9169bd23fbfaSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 9170bd23fbfaSmrg cmds=$old_archive_cmds 91718c4a8e55Smrg else 91728c4a8e55Smrg # the command line is too long to link in one step, link in parts 91738c4a8e55Smrg func_verbose "using piecewise archive linking..." 91748c4a8e55Smrg save_RANLIB=$RANLIB 91758c4a8e55Smrg RANLIB=: 91768c4a8e55Smrg objlist= 91778c4a8e55Smrg concat_cmds= 91788c4a8e55Smrg save_oldobjs=$oldobjs 91798c4a8e55Smrg oldobjs= 91808c4a8e55Smrg # Is there a better way of finding the last object in the list? 91818c4a8e55Smrg for obj in $save_oldobjs 91828c4a8e55Smrg do 91838c4a8e55Smrg last_oldobj=$obj 91848c4a8e55Smrg done 91858c4a8e55Smrg eval test_cmds=\"$old_archive_cmds\" 91868c4a8e55Smrg func_len " $test_cmds" 91878c4a8e55Smrg len0=$func_len_result 91888c4a8e55Smrg len=$len0 91898c4a8e55Smrg for obj in $save_oldobjs 91908c4a8e55Smrg do 91918c4a8e55Smrg func_len " $obj" 91928c4a8e55Smrg func_arith $len + $func_len_result 91938c4a8e55Smrg len=$func_arith_result 91948c4a8e55Smrg func_append objlist " $obj" 91958c4a8e55Smrg if test "$len" -lt "$max_cmd_len"; then 91968c4a8e55Smrg : 91978c4a8e55Smrg else 91988c4a8e55Smrg # the above command should be used before it gets too long 91998c4a8e55Smrg oldobjs=$objlist 92008c4a8e55Smrg if test "$obj" = "$last_oldobj" ; then 92018c4a8e55Smrg RANLIB=$save_RANLIB 92028c4a8e55Smrg fi 92038c4a8e55Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 92048c4a8e55Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 92058c4a8e55Smrg objlist= 92068c4a8e55Smrg len=$len0 92078c4a8e55Smrg fi 92088c4a8e55Smrg done 92098c4a8e55Smrg RANLIB=$save_RANLIB 92108c4a8e55Smrg oldobjs=$objlist 92118c4a8e55Smrg if test "X$oldobjs" = "X" ; then 92128c4a8e55Smrg eval cmds=\"\$concat_cmds\" 92138c4a8e55Smrg else 92148c4a8e55Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 92158c4a8e55Smrg fi 92168c4a8e55Smrg fi 92178c4a8e55Smrg fi 92188c4a8e55Smrg func_execute_cmds "$cmds" 'exit $?' 9219b042e37fSmrg done 9220b042e37fSmrg 92218c4a8e55Smrg test -n "$generated" && \ 92228c4a8e55Smrg func_show_eval "${RM}r$generated" 9223b042e37fSmrg 92248c4a8e55Smrg # Now create the libtool archive. 92258c4a8e55Smrg case $output in 92268c4a8e55Smrg *.la) 92278c4a8e55Smrg old_library= 92288c4a8e55Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 92298c4a8e55Smrg func_verbose "creating $output" 9230b042e37fSmrg 92318c4a8e55Smrg # Preserve any variables that may affect compiler behavior 92328c4a8e55Smrg for var in $variables_saved_for_relink; do 92338c4a8e55Smrg if eval test -z \"\${$var+set}\"; then 92348c4a8e55Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 92358c4a8e55Smrg elif eval var_value=\$$var; test -z "$var_value"; then 92368c4a8e55Smrg relink_command="$var=; export $var; $relink_command" 9237b042e37fSmrg else 92388c4a8e55Smrg func_quote_for_eval "$var_value" 92398c4a8e55Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9240b042e37fSmrg fi 92418c4a8e55Smrg done 92428c4a8e55Smrg # Quote the link command for shipping. 92438c4a8e55Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 9244706b6b52Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 92458c4a8e55Smrg if test "$hardcode_automatic" = yes ; then 92468c4a8e55Smrg relink_command= 92478c4a8e55Smrg fi 9248b042e37fSmrg 92498c4a8e55Smrg # Only create the output if not a dry run. 92508c4a8e55Smrg $opt_dry_run || { 92518c4a8e55Smrg for installed in no yes; do 92528c4a8e55Smrg if test "$installed" = yes; then 92538c4a8e55Smrg if test -z "$install_libdir"; then 92548c4a8e55Smrg break 92558c4a8e55Smrg fi 92568c4a8e55Smrg output="$output_objdir/$outputname"i 92578c4a8e55Smrg # Replace all uninstalled libtool libraries with the installed ones 92588c4a8e55Smrg newdependency_libs= 92598c4a8e55Smrg for deplib in $dependency_libs; do 92608c4a8e55Smrg case $deplib in 92618c4a8e55Smrg *.la) 92628c4a8e55Smrg func_basename "$deplib" 92638c4a8e55Smrg name="$func_basename_result" 92648c4a8e55Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 92658c4a8e55Smrg test -z "$libdir" && \ 92668c4a8e55Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 9267bd23fbfaSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 9268bd23fbfaSmrg ;; 9269bd23fbfaSmrg -L*) 9270bd23fbfaSmrg func_stripname -L '' "$deplib" 9271bd23fbfaSmrg func_replace_sysroot "$func_stripname_result" 9272bd23fbfaSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 9273bd23fbfaSmrg ;; 9274bd23fbfaSmrg -R*) 9275bd23fbfaSmrg func_stripname -R '' "$deplib" 9276bd23fbfaSmrg func_replace_sysroot "$func_stripname_result" 9277bd23fbfaSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 92788c4a8e55Smrg ;; 9279bd23fbfaSmrg *) func_append newdependency_libs " $deplib" ;; 92808c4a8e55Smrg esac 92818c4a8e55Smrg done 92828c4a8e55Smrg dependency_libs="$newdependency_libs" 92838c4a8e55Smrg newdlfiles= 92848c4a8e55Smrg 92858c4a8e55Smrg for lib in $dlfiles; do 92868c4a8e55Smrg case $lib in 92878c4a8e55Smrg *.la) 92888c4a8e55Smrg func_basename "$lib" 92898c4a8e55Smrg name="$func_basename_result" 92908c4a8e55Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 92918c4a8e55Smrg test -z "$libdir" && \ 92928c4a8e55Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 9293bd23fbfaSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 92948c4a8e55Smrg ;; 9295bd23fbfaSmrg *) func_append newdlfiles " $lib" ;; 92968c4a8e55Smrg esac 92978c4a8e55Smrg done 92988c4a8e55Smrg dlfiles="$newdlfiles" 92998c4a8e55Smrg newdlprefiles= 93008c4a8e55Smrg for lib in $dlprefiles; do 93018c4a8e55Smrg case $lib in 93028c4a8e55Smrg *.la) 93038c4a8e55Smrg # Only pass preopened files to the pseudo-archive (for 93048c4a8e55Smrg # eventual linking with the app. that links it) if we 93058c4a8e55Smrg # didn't already link the preopened objects directly into 93068c4a8e55Smrg # the library: 93078c4a8e55Smrg func_basename "$lib" 93088c4a8e55Smrg name="$func_basename_result" 93098c4a8e55Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 93108c4a8e55Smrg test -z "$libdir" && \ 93118c4a8e55Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 9312bd23fbfaSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 93138c4a8e55Smrg ;; 93148c4a8e55Smrg esac 93158c4a8e55Smrg done 93168c4a8e55Smrg dlprefiles="$newdlprefiles" 93178c4a8e55Smrg else 93188c4a8e55Smrg newdlfiles= 93198c4a8e55Smrg for lib in $dlfiles; do 93208c4a8e55Smrg case $lib in 93218c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 93228c4a8e55Smrg *) abs=`pwd`"/$lib" ;; 93238c4a8e55Smrg esac 9324bd23fbfaSmrg func_append newdlfiles " $abs" 93258c4a8e55Smrg done 93268c4a8e55Smrg dlfiles="$newdlfiles" 93278c4a8e55Smrg newdlprefiles= 93288c4a8e55Smrg for lib in $dlprefiles; do 93298c4a8e55Smrg case $lib in 93308c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 93318c4a8e55Smrg *) abs=`pwd`"/$lib" ;; 93328c4a8e55Smrg esac 9333bd23fbfaSmrg func_append newdlprefiles " $abs" 93348c4a8e55Smrg done 93358c4a8e55Smrg dlprefiles="$newdlprefiles" 93368c4a8e55Smrg fi 93378c4a8e55Smrg $RM $output 93388c4a8e55Smrg # place dlname in correct position for cygwin 9339706b6b52Smrg # In fact, it would be nice if we could use this code for all target 9340706b6b52Smrg # systems that can't hard-code library paths into their executables 9341706b6b52Smrg # and that have no shared library path variable independent of PATH, 9342706b6b52Smrg # but it turns out we can't easily determine that from inspecting 9343706b6b52Smrg # libtool variables, so we have to hard-code the OSs to which it 9344706b6b52Smrg # applies here; at the moment, that means platforms that use the PE 9345706b6b52Smrg # object format with DLL files. See the long comment at the top of 9346706b6b52Smrg # tests/bindir.at for full details. 93478c4a8e55Smrg tdlname=$dlname 93488c4a8e55Smrg case $host,$output,$installed,$module,$dlname in 9349706b6b52Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 9350706b6b52Smrg # If a -bindir argument was supplied, place the dll there. 9351706b6b52Smrg if test "x$bindir" != x ; 9352706b6b52Smrg then 9353706b6b52Smrg func_relative_path "$install_libdir" "$bindir" 9354706b6b52Smrg tdlname=$func_relative_path_result$dlname 9355706b6b52Smrg else 9356706b6b52Smrg # Otherwise fall back on heuristic. 9357706b6b52Smrg tdlname=../bin/$dlname 9358706b6b52Smrg fi 9359706b6b52Smrg ;; 93608c4a8e55Smrg esac 93618c4a8e55Smrg $ECHO > $output "\ 93628c4a8e55Smrg# $outputname - a libtool library file 93638c4a8e55Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 93648c4a8e55Smrg# 93658c4a8e55Smrg# Please DO NOT delete this file! 93668c4a8e55Smrg# It is necessary for linking the library. 9367b042e37fSmrg 93688c4a8e55Smrg# The name that we can dlopen(3). 93698c4a8e55Smrgdlname='$tdlname' 9370b042e37fSmrg 93718c4a8e55Smrg# Names of this library. 93728c4a8e55Smrglibrary_names='$library_names' 9373b042e37fSmrg 93748c4a8e55Smrg# The name of the static archive. 93758c4a8e55Smrgold_library='$old_library' 9376b042e37fSmrg 93778c4a8e55Smrg# Linker flags that can not go in dependency_libs. 93788c4a8e55Smrginherited_linker_flags='$new_inherited_linker_flags' 9379b042e37fSmrg 93808c4a8e55Smrg# Libraries that this one depends upon. 93818c4a8e55Smrgdependency_libs='$dependency_libs' 9382b042e37fSmrg 93838c4a8e55Smrg# Names of additional weak libraries provided by this library 93848c4a8e55Smrgweak_library_names='$weak_libs' 9385b042e37fSmrg 93868c4a8e55Smrg# Version information for $libname. 93878c4a8e55Smrgcurrent=$current 93888c4a8e55Smrgage=$age 93898c4a8e55Smrgrevision=$revision 9390b042e37fSmrg 93918c4a8e55Smrg# Is this an already installed library? 93928c4a8e55Smrginstalled=$installed 9393b042e37fSmrg 93948c4a8e55Smrg# Should we warn about portability when linking against -modules? 93958c4a8e55Smrgshouldnotlink=$module 9396b042e37fSmrg 93978c4a8e55Smrg# Files to dlopen/dlpreopen 93988c4a8e55Smrgdlopen='$dlfiles' 93998c4a8e55Smrgdlpreopen='$dlprefiles' 9400b042e37fSmrg 94018c4a8e55Smrg# Directory that this library needs to be installed in: 94028c4a8e55Smrglibdir='$install_libdir'" 94038c4a8e55Smrg if test "$installed" = no && test "$need_relink" = yes; then 94048c4a8e55Smrg $ECHO >> $output "\ 94058c4a8e55Smrgrelink_command=\"$relink_command\"" 94068c4a8e55Smrg fi 94078c4a8e55Smrg done 94088c4a8e55Smrg } 9409b042e37fSmrg 94108c4a8e55Smrg # Do a symbolic link so that the libtool archive can be found in 94118c4a8e55Smrg # LD_LIBRARY_PATH before the program is installed. 94128c4a8e55Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 94138c4a8e55Smrg ;; 94148c4a8e55Smrg esac 94158c4a8e55Smrg exit $EXIT_SUCCESS 94168c4a8e55Smrg} 9417b042e37fSmrg 9418bd23fbfaSmrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 94198c4a8e55Smrg func_mode_link ${1+"$@"} 9420b042e37fSmrg 9421b042e37fSmrg 94228c4a8e55Smrg# func_mode_uninstall arg... 94238c4a8e55Smrgfunc_mode_uninstall () 94248c4a8e55Smrg{ 94258c4a8e55Smrg $opt_debug 94268c4a8e55Smrg RM="$nonopt" 9427b042e37fSmrg files= 9428b042e37fSmrg rmforce= 9429b042e37fSmrg exit_status=0 9430b042e37fSmrg 9431b042e37fSmrg # This variable tells wrapper scripts just to set variables rather 9432b042e37fSmrg # than running their programs. 9433b042e37fSmrg libtool_install_magic="$magic" 9434b042e37fSmrg 9435b042e37fSmrg for arg 9436b042e37fSmrg do 9437b042e37fSmrg case $arg in 9438bd23fbfaSmrg -f) func_append RM " $arg"; rmforce=yes ;; 9439bd23fbfaSmrg -*) func_append RM " $arg" ;; 9440bd23fbfaSmrg *) func_append files " $arg" ;; 9441b042e37fSmrg esac 9442b042e37fSmrg done 9443b042e37fSmrg 94448c4a8e55Smrg test -z "$RM" && \ 94458c4a8e55Smrg func_fatal_help "you must specify an RM program" 9446b042e37fSmrg 9447b042e37fSmrg rmdirs= 9448b042e37fSmrg 9449b042e37fSmrg for file in $files; do 94508c4a8e55Smrg func_dirname "$file" "" "." 94518c4a8e55Smrg dir="$func_dirname_result" 94528c4a8e55Smrg if test "X$dir" = X.; then 9453bd23fbfaSmrg odir="$objdir" 9454b042e37fSmrg else 9455bd23fbfaSmrg odir="$dir/$objdir" 9456b042e37fSmrg fi 94578c4a8e55Smrg func_basename "$file" 94588c4a8e55Smrg name="$func_basename_result" 9459bd23fbfaSmrg test "$opt_mode" = uninstall && odir="$dir" 9460b042e37fSmrg 9461bd23fbfaSmrg # Remember odir for removal later, being careful to avoid duplicates 9462bd23fbfaSmrg if test "$opt_mode" = clean; then 9463b042e37fSmrg case " $rmdirs " in 9464bd23fbfaSmrg *" $odir "*) ;; 9465bd23fbfaSmrg *) func_append rmdirs " $odir" ;; 9466b042e37fSmrg esac 9467b042e37fSmrg fi 9468b042e37fSmrg 9469b042e37fSmrg # Don't error if the file doesn't exist and rm -f was used. 94708c4a8e55Smrg if { test -L "$file"; } >/dev/null 2>&1 || 94718c4a8e55Smrg { test -h "$file"; } >/dev/null 2>&1 || 94728c4a8e55Smrg test -f "$file"; then 9473b042e37fSmrg : 9474b042e37fSmrg elif test -d "$file"; then 9475b042e37fSmrg exit_status=1 9476b042e37fSmrg continue 9477b042e37fSmrg elif test "$rmforce" = yes; then 9478b042e37fSmrg continue 9479b042e37fSmrg fi 9480b042e37fSmrg 9481b042e37fSmrg rmfiles="$file" 9482b042e37fSmrg 9483b042e37fSmrg case $name in 9484b042e37fSmrg *.la) 9485b042e37fSmrg # Possibly a libtool archive, so verify it. 94868c4a8e55Smrg if func_lalib_p "$file"; then 94878c4a8e55Smrg func_source $dir/$name 9488b042e37fSmrg 9489b042e37fSmrg # Delete the libtool libraries and symlinks. 9490b042e37fSmrg for n in $library_names; do 9491bd23fbfaSmrg func_append rmfiles " $odir/$n" 9492b042e37fSmrg done 9493bd23fbfaSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 9494b042e37fSmrg 9495bd23fbfaSmrg case "$opt_mode" in 9496b042e37fSmrg clean) 9497bd23fbfaSmrg case " $library_names " in 9498b042e37fSmrg *" $dlname "*) ;; 9499bd23fbfaSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 9500b042e37fSmrg esac 9501bd23fbfaSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 9502b042e37fSmrg ;; 9503b042e37fSmrg uninstall) 9504b042e37fSmrg if test -n "$library_names"; then 9505b042e37fSmrg # Do each command in the postuninstall commands. 95068c4a8e55Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9507b042e37fSmrg fi 9508b042e37fSmrg 9509b042e37fSmrg if test -n "$old_library"; then 9510b042e37fSmrg # Do each command in the old_postuninstall commands. 95118c4a8e55Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9512b042e37fSmrg fi 9513b042e37fSmrg # FIXME: should reinstall the best remaining shared library. 9514b042e37fSmrg ;; 9515b042e37fSmrg esac 9516b042e37fSmrg fi 9517b042e37fSmrg ;; 9518b042e37fSmrg 9519b042e37fSmrg *.lo) 9520b042e37fSmrg # Possibly a libtool object, so verify it. 95218c4a8e55Smrg if func_lalib_p "$file"; then 9522b042e37fSmrg 9523b042e37fSmrg # Read the .lo file 95248c4a8e55Smrg func_source $dir/$name 9525b042e37fSmrg 9526b042e37fSmrg # Add PIC object to the list of files to remove. 95278c4a8e55Smrg if test -n "$pic_object" && 95288c4a8e55Smrg test "$pic_object" != none; then 9529bd23fbfaSmrg func_append rmfiles " $dir/$pic_object" 9530b042e37fSmrg fi 9531b042e37fSmrg 9532b042e37fSmrg # Add non-PIC object to the list of files to remove. 95338c4a8e55Smrg if test -n "$non_pic_object" && 95348c4a8e55Smrg test "$non_pic_object" != none; then 9535bd23fbfaSmrg func_append rmfiles " $dir/$non_pic_object" 9536b042e37fSmrg fi 9537b042e37fSmrg fi 9538b042e37fSmrg ;; 9539b042e37fSmrg 9540b042e37fSmrg *) 9541bd23fbfaSmrg if test "$opt_mode" = clean ; then 9542b042e37fSmrg noexename=$name 9543b042e37fSmrg case $file in 9544b042e37fSmrg *.exe) 95458c4a8e55Smrg func_stripname '' '.exe' "$file" 95468c4a8e55Smrg file=$func_stripname_result 95478c4a8e55Smrg func_stripname '' '.exe' "$name" 95488c4a8e55Smrg noexename=$func_stripname_result 9549b042e37fSmrg # $file with .exe has already been added to rmfiles, 9550b042e37fSmrg # add $file without .exe 9551bd23fbfaSmrg func_append rmfiles " $file" 9552b042e37fSmrg ;; 9553b042e37fSmrg esac 9554b042e37fSmrg # Do a test to see if this is a libtool program. 95558c4a8e55Smrg if func_ltwrapper_p "$file"; then 95568c4a8e55Smrg if func_ltwrapper_executable_p "$file"; then 95578c4a8e55Smrg func_ltwrapper_scriptname "$file" 95588c4a8e55Smrg relink_command= 95598c4a8e55Smrg func_source $func_ltwrapper_scriptname_result 9560bd23fbfaSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 95618c4a8e55Smrg else 95628c4a8e55Smrg relink_command= 95638c4a8e55Smrg func_source $dir/$noexename 95648c4a8e55Smrg fi 9565b042e37fSmrg 9566b042e37fSmrg # note $name still contains .exe if it was in $file originally 9567b042e37fSmrg # as does the version of $file that was added into $rmfiles 9568bd23fbfaSmrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9569b042e37fSmrg if test "$fast_install" = yes && test -n "$relink_command"; then 9570bd23fbfaSmrg func_append rmfiles " $odir/lt-$name" 9571b042e37fSmrg fi 9572b042e37fSmrg if test "X$noexename" != "X$name" ; then 9573bd23fbfaSmrg func_append rmfiles " $odir/lt-${noexename}.c" 9574b042e37fSmrg fi 9575b042e37fSmrg fi 9576b042e37fSmrg fi 9577b042e37fSmrg ;; 9578b042e37fSmrg esac 95798c4a8e55Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 9580b042e37fSmrg done 9581b042e37fSmrg 9582b042e37fSmrg # Try to remove the ${objdir}s in the directories where we deleted files 9583b042e37fSmrg for dir in $rmdirs; do 9584b042e37fSmrg if test -d "$dir"; then 95858c4a8e55Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 9586b042e37fSmrg fi 9587b042e37fSmrg done 9588b042e37fSmrg 9589b042e37fSmrg exit $exit_status 95908c4a8e55Smrg} 9591b042e37fSmrg 9592bd23fbfaSmrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 95938c4a8e55Smrg func_mode_uninstall ${1+"$@"} 9594b042e37fSmrg 9595bd23fbfaSmrgtest -z "$opt_mode" && { 95968c4a8e55Smrg help="$generic_help" 95978c4a8e55Smrg func_fatal_help "you must specify a MODE" 95988c4a8e55Smrg} 95998c4a8e55Smrg 96008c4a8e55Smrgtest -z "$exec_cmd" && \ 9601bd23fbfaSmrg func_fatal_help "invalid operation mode \`$opt_mode'" 9602b042e37fSmrg 9603b042e37fSmrgif test -n "$exec_cmd"; then 96048c4a8e55Smrg eval exec "$exec_cmd" 9605b042e37fSmrg exit $EXIT_FAILURE 9606b042e37fSmrgfi 9607b042e37fSmrg 96088c4a8e55Smrgexit $exit_status 9609b042e37fSmrg 9610b042e37fSmrg 9611b042e37fSmrg# The TAGs below are defined such that we never get into a situation 9612b042e37fSmrg# in which we disable both kinds of libraries. Given conflicting 9613b042e37fSmrg# choices, we go for a static library, that is the most portable, 9614b042e37fSmrg# since we can't tell whether shared libraries were disabled because 9615b042e37fSmrg# the user asked for that or because the platform doesn't support 9616b042e37fSmrg# them. This is particularly important on AIX, because we don't 9617b042e37fSmrg# support having both static and shared libraries enabled at the same 9618b042e37fSmrg# time on that platform, so we default to a shared-only configuration. 9619b042e37fSmrg# If a disable-shared tag is given, we'll fallback to a static-only 9620b042e37fSmrg# configuration. But we'll never go from static-only to shared-only. 9621b042e37fSmrg 9622b042e37fSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 96238c4a8e55Smrgbuild_libtool_libs=no 96248c4a8e55Smrgbuild_old_libs=yes 9625b042e37fSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 9626b042e37fSmrg 9627b042e37fSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 96288c4a8e55Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 9629b042e37fSmrg# ### END LIBTOOL TAG CONFIG: disable-static 9630b042e37fSmrg 9631b042e37fSmrg# Local Variables: 9632b042e37fSmrg# mode:shell-script 9633b042e37fSmrg# sh-indentation:2 9634b042e37fSmrg# End: 96358c4a8e55Smrg# vi:sw=2 96368c4a8e55Smrg 9637