ltmain.sh revision 0597fb56
18c4a8e55Smrg 20597fb56Smrg# libtool (GNU libtool) 2.4.2 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, 60597fb56Smrg# 2007, 2008, 2009, 2010, 2011 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) 440597fb56Smrg# --no-warn don't display warning messages 45706b6b52Smrg# --tag=TAG use configuration variables from tag TAG 46706b6b52Smrg# -v, --verbose print more informational messages than default 47706b6b52Smrg# --no-verbose don't print the extra informational messages 48706b6b52Smrg# --version print version information 49706b6b52Smrg# -h, --help, --help-all print short, long, or detailed help message 508c4a8e55Smrg# 518c4a8e55Smrg# MODE must be one of the following: 528c4a8e55Smrg# 53706b6b52Smrg# clean remove files from the build directory 54706b6b52Smrg# compile compile a source file into a libtool object 55706b6b52Smrg# execute automatically set library path, then run a program 56706b6b52Smrg# finish complete the installation of libtool libraries 57706b6b52Smrg# install install libraries or executables 58706b6b52Smrg# link create a library or an executable 59706b6b52Smrg# uninstall remove libraries from an installed directory 608c4a8e55Smrg# 61706b6b52Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 62706b6b52Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 638c4a8e55Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 648c4a8e55Smrg# 658c4a8e55Smrg# When reporting a bug, please describe a test case to reproduce it and 668c4a8e55Smrg# include the following information: 678c4a8e55Smrg# 68706b6b52Smrg# host-triplet: $host 69706b6b52Smrg# shell: $SHELL 70706b6b52Smrg# compiler: $LTCC 71706b6b52Smrg# compiler flags: $LTCFLAGS 72706b6b52Smrg# linker: $LD (gnu? $with_gnu_ld) 730597fb56Smrg# $progname: (GNU libtool) 2.4.2 74706b6b52Smrg# automake: $automake_version 75706b6b52Smrg# autoconf: $autoconf_version 768c4a8e55Smrg# 778c4a8e55Smrg# Report bugs to <bug-libtool@gnu.org>. 78bd23fbfaSmrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 79bd23fbfaSmrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 808c4a8e55Smrg 81706b6b52SmrgPROGRAM=libtool 828c4a8e55SmrgPACKAGE=libtool 830597fb56SmrgVERSION=2.4.2 848c4a8e55SmrgTIMESTAMP="" 850597fb56Smrgpackage_revision=1.3337 868c4a8e55Smrg 878c4a8e55Smrg# Be Bourne compatible 888c4a8e55Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 898c4a8e55Smrg emulate sh 908c4a8e55Smrg NULLCMD=: 918c4a8e55Smrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 928c4a8e55Smrg # is contrary to our usage. Disable this feature. 938c4a8e55Smrg alias -g '${1+"$@"}'='"$@"' 948c4a8e55Smrg setopt NO_GLOB_SUBST 958c4a8e55Smrgelse 968c4a8e55Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 978c4a8e55Smrgfi 988c4a8e55SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 998c4a8e55SmrgDUALCASE=1; export DUALCASE # for MKS sh 1008c4a8e55Smrg 101706b6b52Smrg# A function that is used when there is no print builtin or printf. 102706b6b52Smrgfunc_fallback_echo () 103706b6b52Smrg{ 104706b6b52Smrg eval 'cat <<_LTECHO_EOF 105706b6b52Smrg$1 106706b6b52Smrg_LTECHO_EOF' 107706b6b52Smrg} 108706b6b52Smrg 1098c4a8e55Smrg# NLS nuisances: We save the old values to restore during execute mode. 1108c4a8e55Smrglt_user_locale= 1118c4a8e55Smrglt_safe_locale= 1128c4a8e55Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1138c4a8e55Smrgdo 1148c4a8e55Smrg eval "if test \"\${$lt_var+set}\" = set; then 1158c4a8e55Smrg save_$lt_var=\$$lt_var 1168c4a8e55Smrg $lt_var=C 1178c4a8e55Smrg export $lt_var 1188c4a8e55Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 1198c4a8e55Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 1208c4a8e55Smrg fi" 1218c4a8e55Smrgdone 122706b6b52SmrgLC_ALL=C 123706b6b52SmrgLANGUAGE=C 124706b6b52Smrgexport LANGUAGE LC_ALL 1258c4a8e55Smrg 1268c4a8e55Smrg$lt_unset CDPATH 1278c4a8e55Smrg 1288c4a8e55Smrg 129706b6b52Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 130706b6b52Smrg# is ksh but when the shell is invoked as "sh" and the current value of 131706b6b52Smrg# the _XPG environment variable is not equal to 1 (one), the special 132706b6b52Smrg# positional parameter $0, within a function call, is the name of the 133706b6b52Smrg# function. 134706b6b52Smrgprogpath="$0" 1358c4a8e55Smrg 1368c4a8e55Smrg 1378c4a8e55Smrg 1388c4a8e55Smrg: ${CP="cp -f"} 139706b6b52Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 1408c4a8e55Smrg: ${MAKE="make"} 1418c4a8e55Smrg: ${MKDIR="mkdir"} 1428c4a8e55Smrg: ${MV="mv -f"} 1438c4a8e55Smrg: ${RM="rm -f"} 1448c4a8e55Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 1458c4a8e55Smrg: ${Xsed="$SED -e 1s/^X//"} 146b042e37fSmrg 1478c4a8e55Smrg# Global variables: 1488c4a8e55SmrgEXIT_SUCCESS=0 1498c4a8e55SmrgEXIT_FAILURE=1 1508c4a8e55SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 1518c4a8e55SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 1528c4a8e55Smrg 1538c4a8e55Smrgexit_status=$EXIT_SUCCESS 1548c4a8e55Smrg 1558c4a8e55Smrg# Make sure IFS has a sensible default 1568c4a8e55Smrglt_nl=' 1578c4a8e55Smrg' 1588c4a8e55SmrgIFS=" $lt_nl" 1598c4a8e55Smrg 1608c4a8e55Smrgdirname="s,/[^/]*$,," 1618c4a8e55Smrgbasename="s,^.*/,," 1628c4a8e55Smrg 163bd23fbfaSmrg# func_dirname file append nondir_replacement 164bd23fbfaSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 165bd23fbfaSmrg# otherwise set result to NONDIR_REPLACEMENT. 166bd23fbfaSmrgfunc_dirname () 167bd23fbfaSmrg{ 168bd23fbfaSmrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 169bd23fbfaSmrg if test "X$func_dirname_result" = "X${1}"; then 170bd23fbfaSmrg func_dirname_result="${3}" 171bd23fbfaSmrg else 172bd23fbfaSmrg func_dirname_result="$func_dirname_result${2}" 173bd23fbfaSmrg fi 174bd23fbfaSmrg} # func_dirname may be replaced by extended shell implementation 175bd23fbfaSmrg 176bd23fbfaSmrg 177bd23fbfaSmrg# func_basename file 178bd23fbfaSmrgfunc_basename () 179bd23fbfaSmrg{ 180bd23fbfaSmrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 181bd23fbfaSmrg} # func_basename may be replaced by extended shell implementation 182bd23fbfaSmrg 183bd23fbfaSmrg 1848c4a8e55Smrg# func_dirname_and_basename file append nondir_replacement 1858c4a8e55Smrg# perform func_basename and func_dirname in a single function 1868c4a8e55Smrg# call: 1878c4a8e55Smrg# dirname: Compute the dirname of FILE. If nonempty, 1888c4a8e55Smrg# add APPEND to the result, otherwise set result 1898c4a8e55Smrg# to NONDIR_REPLACEMENT. 1908c4a8e55Smrg# value returned in "$func_dirname_result" 1918c4a8e55Smrg# basename: Compute filename of FILE. 1928c4a8e55Smrg# value retuned in "$func_basename_result" 1938c4a8e55Smrg# Implementation must be kept synchronized with func_dirname 1948c4a8e55Smrg# and func_basename. For efficiency, we do not delegate to 1958c4a8e55Smrg# those functions but instead duplicate the functionality here. 1968c4a8e55Smrgfunc_dirname_and_basename () 1978c4a8e55Smrg{ 198bd23fbfaSmrg # Extract subdirectory from the argument. 199bd23fbfaSmrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 200bd23fbfaSmrg if test "X$func_dirname_result" = "X${1}"; then 201bd23fbfaSmrg func_dirname_result="${3}" 202bd23fbfaSmrg else 203bd23fbfaSmrg func_dirname_result="$func_dirname_result${2}" 204bd23fbfaSmrg fi 205bd23fbfaSmrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 206bd23fbfaSmrg} # func_dirname_and_basename may be replaced by extended shell implementation 207bd23fbfaSmrg 208bd23fbfaSmrg 209bd23fbfaSmrg# func_stripname prefix suffix name 210bd23fbfaSmrg# strip PREFIX and SUFFIX off of NAME. 211bd23fbfaSmrg# PREFIX and SUFFIX must not contain globbing or regex special 212bd23fbfaSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 213bd23fbfaSmrg# dot (in which case that matches only a dot). 214bd23fbfaSmrg# func_strip_suffix prefix name 215bd23fbfaSmrgfunc_stripname () 216bd23fbfaSmrg{ 217bd23fbfaSmrg case ${2} in 218bd23fbfaSmrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 219bd23fbfaSmrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 220bd23fbfaSmrg esac 221bd23fbfaSmrg} # func_stripname may be replaced by extended shell implementation 2228c4a8e55Smrg 223b042e37fSmrg 224706b6b52Smrg# These SED scripts presuppose an absolute path with a trailing slash. 225706b6b52Smrgpathcar='s,^/\([^/]*\).*$,\1,' 226706b6b52Smrgpathcdr='s,^/[^/]*,,' 227706b6b52Smrgremovedotparts=':dotsl 228706b6b52Smrg s@/\./@/@g 229706b6b52Smrg t dotsl 230706b6b52Smrg s,/\.$,/,' 231706b6b52Smrgcollapseslashes='s@/\{1,\}@/@g' 232706b6b52Smrgfinalslash='s,/*$,/,' 233706b6b52Smrg 234706b6b52Smrg# func_normal_abspath PATH 235706b6b52Smrg# Remove doubled-up and trailing slashes, "." path components, 236706b6b52Smrg# and cancel out any ".." path components in PATH after making 237706b6b52Smrg# it an absolute path. 238706b6b52Smrg# value returned in "$func_normal_abspath_result" 239706b6b52Smrgfunc_normal_abspath () 240706b6b52Smrg{ 241706b6b52Smrg # Start from root dir and reassemble the path. 242706b6b52Smrg func_normal_abspath_result= 243706b6b52Smrg func_normal_abspath_tpath=$1 244706b6b52Smrg func_normal_abspath_altnamespace= 245706b6b52Smrg case $func_normal_abspath_tpath in 246706b6b52Smrg "") 247706b6b52Smrg # Empty path, that just means $cwd. 248706b6b52Smrg func_stripname '' '/' "`pwd`" 249706b6b52Smrg func_normal_abspath_result=$func_stripname_result 250706b6b52Smrg return 251706b6b52Smrg ;; 252706b6b52Smrg # The next three entries are used to spot a run of precisely 253706b6b52Smrg # two leading slashes without using negated character classes; 254706b6b52Smrg # we take advantage of case's first-match behaviour. 255706b6b52Smrg ///*) 256706b6b52Smrg # Unusual form of absolute path, do nothing. 257706b6b52Smrg ;; 258706b6b52Smrg //*) 259706b6b52Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 260706b6b52Smrg # and for example Cygwin uses it to access remote file shares 261706b6b52Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 262706b6b52Smrg func_normal_abspath_altnamespace=/ 263706b6b52Smrg ;; 264706b6b52Smrg /*) 265706b6b52Smrg # Absolute path, do nothing. 266706b6b52Smrg ;; 267706b6b52Smrg *) 268706b6b52Smrg # Relative path, prepend $cwd. 269706b6b52Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 270706b6b52Smrg ;; 271706b6b52Smrg esac 272706b6b52Smrg # Cancel out all the simple stuff to save iterations. We also want 273706b6b52Smrg # the path to end with a slash for ease of parsing, so make sure 274706b6b52Smrg # there is one (and only one) here. 275706b6b52Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 276706b6b52Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 277706b6b52Smrg while :; do 278706b6b52Smrg # Processed it all yet? 279706b6b52Smrg if test "$func_normal_abspath_tpath" = / ; then 280706b6b52Smrg # If we ascended to the root using ".." the result may be empty now. 281706b6b52Smrg if test -z "$func_normal_abspath_result" ; then 282706b6b52Smrg func_normal_abspath_result=/ 283706b6b52Smrg fi 284706b6b52Smrg break 285706b6b52Smrg fi 286706b6b52Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 287706b6b52Smrg -e "$pathcar"` 288706b6b52Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 289706b6b52Smrg -e "$pathcdr"` 290706b6b52Smrg # Figure out what to do with it 291706b6b52Smrg case $func_normal_abspath_tcomponent in 292706b6b52Smrg "") 293706b6b52Smrg # Trailing empty path component, ignore it. 294706b6b52Smrg ;; 295706b6b52Smrg ..) 296706b6b52Smrg # Parent dir; strip last assembled component from result. 297706b6b52Smrg func_dirname "$func_normal_abspath_result" 298706b6b52Smrg func_normal_abspath_result=$func_dirname_result 299706b6b52Smrg ;; 300706b6b52Smrg *) 301706b6b52Smrg # Actual path component, append it. 302706b6b52Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 303706b6b52Smrg ;; 304706b6b52Smrg esac 305706b6b52Smrg done 306706b6b52Smrg # Restore leading double-slash if one was found on entry. 307706b6b52Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 308706b6b52Smrg} 309706b6b52Smrg 310706b6b52Smrg# func_relative_path SRCDIR DSTDIR 311706b6b52Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 312706b6b52Smrg# slash if non-empty, suitable for immediately appending a filename 313706b6b52Smrg# without needing to append a separator. 314706b6b52Smrg# value returned in "$func_relative_path_result" 315706b6b52Smrgfunc_relative_path () 316706b6b52Smrg{ 317706b6b52Smrg func_relative_path_result= 318706b6b52Smrg func_normal_abspath "$1" 319706b6b52Smrg func_relative_path_tlibdir=$func_normal_abspath_result 320706b6b52Smrg func_normal_abspath "$2" 321706b6b52Smrg func_relative_path_tbindir=$func_normal_abspath_result 322706b6b52Smrg 323706b6b52Smrg # Ascend the tree starting from libdir 324706b6b52Smrg while :; do 325706b6b52Smrg # check if we have found a prefix of bindir 326706b6b52Smrg case $func_relative_path_tbindir in 327706b6b52Smrg $func_relative_path_tlibdir) 328706b6b52Smrg # found an exact match 329706b6b52Smrg func_relative_path_tcancelled= 330706b6b52Smrg break 331706b6b52Smrg ;; 332706b6b52Smrg $func_relative_path_tlibdir*) 333706b6b52Smrg # found a matching prefix 334706b6b52Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 335706b6b52Smrg func_relative_path_tcancelled=$func_stripname_result 336706b6b52Smrg if test -z "$func_relative_path_result"; then 337706b6b52Smrg func_relative_path_result=. 338706b6b52Smrg fi 339706b6b52Smrg break 340706b6b52Smrg ;; 341706b6b52Smrg *) 342706b6b52Smrg func_dirname $func_relative_path_tlibdir 343706b6b52Smrg func_relative_path_tlibdir=${func_dirname_result} 344706b6b52Smrg if test "x$func_relative_path_tlibdir" = x ; then 345706b6b52Smrg # Have to descend all the way to the root! 346706b6b52Smrg func_relative_path_result=../$func_relative_path_result 347706b6b52Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 348706b6b52Smrg break 349706b6b52Smrg fi 350706b6b52Smrg func_relative_path_result=../$func_relative_path_result 351706b6b52Smrg ;; 352706b6b52Smrg esac 353706b6b52Smrg done 354706b6b52Smrg 355706b6b52Smrg # Now calculate path; take care to avoid doubling-up slashes. 356706b6b52Smrg func_stripname '' '/' "$func_relative_path_result" 357706b6b52Smrg func_relative_path_result=$func_stripname_result 358706b6b52Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 359706b6b52Smrg if test "x$func_stripname_result" != x ; then 360706b6b52Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 361706b6b52Smrg fi 362706b6b52Smrg 363706b6b52Smrg # Normalisation. If bindir is libdir, return empty string, 364706b6b52Smrg # else relative path ending with a slash; either way, target 365706b6b52Smrg # file name can be directly appended. 366706b6b52Smrg if test ! -z "$func_relative_path_result"; then 367706b6b52Smrg func_stripname './' '' "$func_relative_path_result/" 368706b6b52Smrg func_relative_path_result=$func_stripname_result 369706b6b52Smrg fi 370706b6b52Smrg} 371b042e37fSmrg 372b042e37fSmrg# The name of this program: 3738c4a8e55Smrgfunc_dirname_and_basename "$progpath" 3748c4a8e55Smrgprogname=$func_basename_result 375b042e37fSmrg 3768c4a8e55Smrg# Make sure we have an absolute path for reexecution: 3778c4a8e55Smrgcase $progpath in 3788c4a8e55Smrg [\\/]*|[A-Za-z]:\\*) ;; 3798c4a8e55Smrg *[\\/]*) 3808c4a8e55Smrg progdir=$func_dirname_result 3818c4a8e55Smrg progdir=`cd "$progdir" && pwd` 3828c4a8e55Smrg progpath="$progdir/$progname" 3838c4a8e55Smrg ;; 3848c4a8e55Smrg *) 3858c4a8e55Smrg save_IFS="$IFS" 3860597fb56Smrg IFS=${PATH_SEPARATOR-:} 3878c4a8e55Smrg for progdir in $PATH; do 3888c4a8e55Smrg IFS="$save_IFS" 3898c4a8e55Smrg test -x "$progdir/$progname" && break 3908c4a8e55Smrg done 3918c4a8e55Smrg IFS="$save_IFS" 3928c4a8e55Smrg test -n "$progdir" || progdir=`pwd` 3938c4a8e55Smrg progpath="$progdir/$progname" 3948c4a8e55Smrg ;; 3958c4a8e55Smrgesac 396b042e37fSmrg 3978c4a8e55Smrg# Sed substitution that helps us do robust quoting. It backslashifies 3988c4a8e55Smrg# metacharacters that are still active within double-quoted strings. 3998c4a8e55SmrgXsed="${SED}"' -e 1s/^X//' 4008c4a8e55Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 4018c4a8e55Smrg 4028c4a8e55Smrg# Same as above, but do not quote variable references. 4038c4a8e55Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 4048c4a8e55Smrg 405bd23fbfaSmrg# Sed substitution that turns a string into a regex matching for the 406bd23fbfaSmrg# string literally. 407bd23fbfaSmrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 408bd23fbfaSmrg 409bd23fbfaSmrg# Sed substitution that converts a w32 file name or path 410bd23fbfaSmrg# which contains forward slashes, into one that contains 411bd23fbfaSmrg# (escaped) backslashes. A very naive implementation. 412bd23fbfaSmrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 413bd23fbfaSmrg 4148c4a8e55Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 4158c4a8e55Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 4168c4a8e55Smrg# in input to double_quote_subst, that '$' was protected from expansion. 4178c4a8e55Smrg# Since each input `\' is now two `\'s, look for any number of runs of 4188c4a8e55Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 4198c4a8e55Smrgbs='\\' 4208c4a8e55Smrgbs2='\\\\' 4218c4a8e55Smrgbs4='\\\\\\\\' 4228c4a8e55Smrgdollar='\$' 4238c4a8e55Smrgsed_double_backslash="\ 4248c4a8e55Smrg s/$bs4/&\\ 4258c4a8e55Smrg/g 4268c4a8e55Smrg s/^$bs2$dollar/$bs&/ 4278c4a8e55Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 4288c4a8e55Smrg s/\n//g" 4298c4a8e55Smrg 4308c4a8e55Smrg# Standard options: 4318c4a8e55Smrgopt_dry_run=false 4328c4a8e55Smrgopt_help=false 4338c4a8e55Smrgopt_quiet=false 4348c4a8e55Smrgopt_verbose=false 4358c4a8e55Smrgopt_warning=: 4368c4a8e55Smrg 4378c4a8e55Smrg# func_echo arg... 4388c4a8e55Smrg# Echo program name prefixed message, along with the current mode 4398c4a8e55Smrg# name if it has been set yet. 4408c4a8e55Smrgfunc_echo () 4418c4a8e55Smrg{ 442bd23fbfaSmrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 4438c4a8e55Smrg} 444b042e37fSmrg 4458c4a8e55Smrg# func_verbose arg... 4468c4a8e55Smrg# Echo program name prefixed message in verbose mode only. 4478c4a8e55Smrgfunc_verbose () 4488c4a8e55Smrg{ 4498c4a8e55Smrg $opt_verbose && func_echo ${1+"$@"} 450b042e37fSmrg 4518c4a8e55Smrg # A bug in bash halts the script if the last line of a function 4528c4a8e55Smrg # fails when set -e is in force, so we need another command to 4538c4a8e55Smrg # work around that: 4548c4a8e55Smrg : 4558c4a8e55Smrg} 456b042e37fSmrg 457706b6b52Smrg# func_echo_all arg... 458706b6b52Smrg# Invoke $ECHO with all args, space-separated. 459706b6b52Smrgfunc_echo_all () 460706b6b52Smrg{ 461706b6b52Smrg $ECHO "$*" 462706b6b52Smrg} 463706b6b52Smrg 4648c4a8e55Smrg# func_error arg... 4658c4a8e55Smrg# Echo program name prefixed message to standard error. 4668c4a8e55Smrgfunc_error () 4678c4a8e55Smrg{ 468bd23fbfaSmrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 4698c4a8e55Smrg} 470b042e37fSmrg 4718c4a8e55Smrg# func_warning arg... 4728c4a8e55Smrg# Echo program name prefixed warning message to standard error. 4738c4a8e55Smrgfunc_warning () 4748c4a8e55Smrg{ 475bd23fbfaSmrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 476b042e37fSmrg 4778c4a8e55Smrg # bash bug again: 4788c4a8e55Smrg : 4798c4a8e55Smrg} 480b042e37fSmrg 4818c4a8e55Smrg# func_fatal_error arg... 4828c4a8e55Smrg# Echo program name prefixed message to standard error, and exit. 4838c4a8e55Smrgfunc_fatal_error () 4848c4a8e55Smrg{ 4858c4a8e55Smrg func_error ${1+"$@"} 4868c4a8e55Smrg exit $EXIT_FAILURE 4878c4a8e55Smrg} 488b042e37fSmrg 4898c4a8e55Smrg# func_fatal_help arg... 4908c4a8e55Smrg# Echo program name prefixed message to standard error, followed by 4918c4a8e55Smrg# a help hint, and exit. 4928c4a8e55Smrgfunc_fatal_help () 4938c4a8e55Smrg{ 4948c4a8e55Smrg func_error ${1+"$@"} 4958c4a8e55Smrg func_fatal_error "$help" 4968c4a8e55Smrg} 4978c4a8e55Smrghelp="Try \`$progname --help' for more information." ## default 498b042e37fSmrg 499b042e37fSmrg 5008c4a8e55Smrg# func_grep expression filename 5018c4a8e55Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 5028c4a8e55Smrgfunc_grep () 5038c4a8e55Smrg{ 5048c4a8e55Smrg $GREP "$1" "$2" >/dev/null 2>&1 5058c4a8e55Smrg} 5068c4a8e55Smrg 5078c4a8e55Smrg 5088c4a8e55Smrg# func_mkdir_p directory-path 5098c4a8e55Smrg# Make sure the entire path to DIRECTORY-PATH is available. 5108c4a8e55Smrgfunc_mkdir_p () 5118c4a8e55Smrg{ 5128c4a8e55Smrg my_directory_path="$1" 5138c4a8e55Smrg my_dir_list= 5148c4a8e55Smrg 5158c4a8e55Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 5168c4a8e55Smrg 5178c4a8e55Smrg # Protect directory names starting with `-' 5188c4a8e55Smrg case $my_directory_path in 5198c4a8e55Smrg -*) my_directory_path="./$my_directory_path" ;; 5208c4a8e55Smrg esac 5218c4a8e55Smrg 5228c4a8e55Smrg # While some portion of DIR does not yet exist... 5238c4a8e55Smrg while test ! -d "$my_directory_path"; do 5248c4a8e55Smrg # ...make a list in topmost first order. Use a colon delimited 5258c4a8e55Smrg # list incase some portion of path contains whitespace. 5268c4a8e55Smrg my_dir_list="$my_directory_path:$my_dir_list" 5278c4a8e55Smrg 5288c4a8e55Smrg # If the last portion added has no slash in it, the list is done 5298c4a8e55Smrg case $my_directory_path in */*) ;; *) break ;; esac 5308c4a8e55Smrg 5318c4a8e55Smrg # ...otherwise throw away the child directory and loop 532706b6b52Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 5338c4a8e55Smrg done 534706b6b52Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 5358c4a8e55Smrg 5368c4a8e55Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 5378c4a8e55Smrg for my_dir in $my_dir_list; do 5388c4a8e55Smrg IFS="$save_mkdir_p_IFS" 5398c4a8e55Smrg # mkdir can fail with a `File exist' error if two processes 5408c4a8e55Smrg # try to create one of the directories concurrently. Don't 5418c4a8e55Smrg # stop in that case! 5428c4a8e55Smrg $MKDIR "$my_dir" 2>/dev/null || : 5438c4a8e55Smrg done 5448c4a8e55Smrg IFS="$save_mkdir_p_IFS" 5458c4a8e55Smrg 5468c4a8e55Smrg # Bail out if we (or some other process) failed to create a directory. 5478c4a8e55Smrg test -d "$my_directory_path" || \ 5488c4a8e55Smrg func_fatal_error "Failed to create \`$1'" 5498c4a8e55Smrg fi 5508c4a8e55Smrg} 551b042e37fSmrg 552b042e37fSmrg 553b042e37fSmrg# func_mktempdir [string] 554b042e37fSmrg# Make a temporary directory that won't clash with other running 555b042e37fSmrg# libtool processes, and avoids race conditions if possible. If 556b042e37fSmrg# given, STRING is the basename for that directory. 557b042e37fSmrgfunc_mktempdir () 558b042e37fSmrg{ 559b042e37fSmrg my_template="${TMPDIR-/tmp}/${1-$progname}" 560b042e37fSmrg 5618c4a8e55Smrg if test "$opt_dry_run" = ":"; then 562b042e37fSmrg # Return a directory name, but don't create it in dry-run mode 563b042e37fSmrg my_tmpdir="${my_template}-$$" 564b042e37fSmrg else 565b042e37fSmrg 566b042e37fSmrg # If mktemp works, use that first and foremost 567b042e37fSmrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 568b042e37fSmrg 569b042e37fSmrg if test ! -d "$my_tmpdir"; then 5708c4a8e55Smrg # Failing that, at least try and use $RANDOM to avoid a race 5718c4a8e55Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 572b042e37fSmrg 5738c4a8e55Smrg save_mktempdir_umask=`umask` 5748c4a8e55Smrg umask 0077 5758c4a8e55Smrg $MKDIR "$my_tmpdir" 5768c4a8e55Smrg umask $save_mktempdir_umask 577b042e37fSmrg fi 578b042e37fSmrg 579b042e37fSmrg # If we're not in dry-run mode, bomb out on failure 5808c4a8e55Smrg test -d "$my_tmpdir" || \ 5818c4a8e55Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 582b042e37fSmrg fi 583b042e37fSmrg 584706b6b52Smrg $ECHO "$my_tmpdir" 585b042e37fSmrg} 586b042e37fSmrg 587b042e37fSmrg 5888c4a8e55Smrg# func_quote_for_eval arg 5898c4a8e55Smrg# Aesthetically quote ARG to be evaled later. 5908c4a8e55Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 5918c4a8e55Smrg# is double-quoted, suitable for a subsequent eval, whereas 5928c4a8e55Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 5938c4a8e55Smrg# which are still active within double quotes backslashified. 5948c4a8e55Smrgfunc_quote_for_eval () 595b042e37fSmrg{ 5968c4a8e55Smrg case $1 in 5978c4a8e55Smrg *[\\\`\"\$]*) 598706b6b52Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 5998c4a8e55Smrg *) 6008c4a8e55Smrg func_quote_for_eval_unquoted_result="$1" ;; 6018c4a8e55Smrg esac 6028c4a8e55Smrg 6038c4a8e55Smrg case $func_quote_for_eval_unquoted_result in 6048c4a8e55Smrg # Double-quote args containing shell metacharacters to delay 6058c4a8e55Smrg # word splitting, command substitution and and variable 6068c4a8e55Smrg # expansion for a subsequent eval. 6078c4a8e55Smrg # Many Bourne shells cannot handle close brackets correctly 6088c4a8e55Smrg # in scan sets, so we specify it separately. 6098c4a8e55Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 6108c4a8e55Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 6118c4a8e55Smrg ;; 6128c4a8e55Smrg *) 6138c4a8e55Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 614b042e37fSmrg esac 615b042e37fSmrg} 616b042e37fSmrg 617b042e37fSmrg 6188c4a8e55Smrg# func_quote_for_expand arg 6198c4a8e55Smrg# Aesthetically quote ARG to be evaled later; same as above, 6208c4a8e55Smrg# but do not quote variable references. 6218c4a8e55Smrgfunc_quote_for_expand () 622b042e37fSmrg{ 6238c4a8e55Smrg case $1 in 6248c4a8e55Smrg *[\\\`\"]*) 625706b6b52Smrg my_arg=`$ECHO "$1" | $SED \ 6268c4a8e55Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 627b042e37fSmrg *) 6288c4a8e55Smrg my_arg="$1" ;; 6298c4a8e55Smrg esac 630b042e37fSmrg 6318c4a8e55Smrg case $my_arg in 6328c4a8e55Smrg # Double-quote args containing shell metacharacters to delay 6338c4a8e55Smrg # word splitting and command substitution for a subsequent eval. 6348c4a8e55Smrg # Many Bourne shells cannot handle close brackets correctly 6358c4a8e55Smrg # in scan sets, so we specify it separately. 6368c4a8e55Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 6378c4a8e55Smrg my_arg="\"$my_arg\"" 6388c4a8e55Smrg ;; 6398c4a8e55Smrg esac 6408c4a8e55Smrg 6418c4a8e55Smrg func_quote_for_expand_result="$my_arg" 642b042e37fSmrg} 643b042e37fSmrg 644b042e37fSmrg 6458c4a8e55Smrg# func_show_eval cmd [fail_exp] 6468c4a8e55Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 6478c4a8e55Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 6488c4a8e55Smrg# is given, then evaluate it. 6498c4a8e55Smrgfunc_show_eval () 650b042e37fSmrg{ 6518c4a8e55Smrg my_cmd="$1" 6528c4a8e55Smrg my_fail_exp="${2-:}" 653b042e37fSmrg 6548c4a8e55Smrg ${opt_silent-false} || { 6558c4a8e55Smrg func_quote_for_expand "$my_cmd" 6568c4a8e55Smrg eval "func_echo $func_quote_for_expand_result" 6578c4a8e55Smrg } 6588c4a8e55Smrg 6598c4a8e55Smrg if ${opt_dry_run-false}; then :; else 6608c4a8e55Smrg eval "$my_cmd" 6618c4a8e55Smrg my_status=$? 6628c4a8e55Smrg if test "$my_status" -eq 0; then :; else 6638c4a8e55Smrg eval "(exit $my_status); $my_fail_exp" 6648c4a8e55Smrg fi 665b042e37fSmrg fi 666b042e37fSmrg} 667b042e37fSmrg 6688c4a8e55Smrg 6698c4a8e55Smrg# func_show_eval_locale cmd [fail_exp] 6708c4a8e55Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 6718c4a8e55Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 6728c4a8e55Smrg# is given, then evaluate it. Use the saved locale for evaluation. 6738c4a8e55Smrgfunc_show_eval_locale () 674b042e37fSmrg{ 6758c4a8e55Smrg my_cmd="$1" 6768c4a8e55Smrg my_fail_exp="${2-:}" 677b042e37fSmrg 6788c4a8e55Smrg ${opt_silent-false} || { 6798c4a8e55Smrg func_quote_for_expand "$my_cmd" 6808c4a8e55Smrg eval "func_echo $func_quote_for_expand_result" 6818c4a8e55Smrg } 6828c4a8e55Smrg 6838c4a8e55Smrg if ${opt_dry_run-false}; then :; else 6848c4a8e55Smrg eval "$lt_user_locale 6858c4a8e55Smrg $my_cmd" 6868c4a8e55Smrg my_status=$? 6878c4a8e55Smrg eval "$lt_safe_locale" 6888c4a8e55Smrg if test "$my_status" -eq 0; then :; else 6898c4a8e55Smrg eval "(exit $my_status); $my_fail_exp" 690b042e37fSmrg fi 6918c4a8e55Smrg fi 692b042e37fSmrg} 693b042e37fSmrg 694bd23fbfaSmrg# func_tr_sh 695bd23fbfaSmrg# Turn $1 into a string suitable for a shell variable name. 696bd23fbfaSmrg# Result is stored in $func_tr_sh_result. All characters 697bd23fbfaSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 698bd23fbfaSmrg# if $1 begins with a digit, a '_' is prepended as well. 699bd23fbfaSmrgfunc_tr_sh () 700bd23fbfaSmrg{ 701bd23fbfaSmrg case $1 in 702bd23fbfaSmrg [0-9]* | *[!a-zA-Z0-9_]*) 703bd23fbfaSmrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 704bd23fbfaSmrg ;; 705bd23fbfaSmrg * ) 706bd23fbfaSmrg func_tr_sh_result=$1 707bd23fbfaSmrg ;; 708bd23fbfaSmrg esac 709bd23fbfaSmrg} 710bd23fbfaSmrg 711b042e37fSmrg 7128c4a8e55Smrg# func_version 7138c4a8e55Smrg# Echo version message to standard output and exit. 7148c4a8e55Smrgfunc_version () 7158c4a8e55Smrg{ 716bd23fbfaSmrg $opt_debug 717bd23fbfaSmrg 718706b6b52Smrg $SED -n '/(C)/!b go 719706b6b52Smrg :more 720706b6b52Smrg /\./!{ 721706b6b52Smrg N 722706b6b52Smrg s/\n# / / 723706b6b52Smrg b more 724706b6b52Smrg } 725706b6b52Smrg :go 726706b6b52Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 7278c4a8e55Smrg s/^# // 7288c4a8e55Smrg s/^# *$// 7298c4a8e55Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 7308c4a8e55Smrg p 7318c4a8e55Smrg }' < "$progpath" 7328c4a8e55Smrg exit $? 7338c4a8e55Smrg} 7348c4a8e55Smrg 7358c4a8e55Smrg# func_usage 7368c4a8e55Smrg# Echo short help message to standard output and exit. 7378c4a8e55Smrgfunc_usage () 7388c4a8e55Smrg{ 739bd23fbfaSmrg $opt_debug 740bd23fbfaSmrg 741706b6b52Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 7428c4a8e55Smrg s/^# // 7438c4a8e55Smrg s/^# *$// 7448c4a8e55Smrg s/\$progname/'$progname'/ 7458c4a8e55Smrg p 7468c4a8e55Smrg }' < "$progpath" 747706b6b52Smrg echo 7488c4a8e55Smrg $ECHO "run \`$progname --help | more' for full usage" 7498c4a8e55Smrg exit $? 7508c4a8e55Smrg} 7518c4a8e55Smrg 752706b6b52Smrg# func_help [NOEXIT] 753706b6b52Smrg# Echo long help message to standard output and exit, 754706b6b52Smrg# unless 'noexit' is passed as argument. 7558c4a8e55Smrgfunc_help () 7568c4a8e55Smrg{ 757bd23fbfaSmrg $opt_debug 758bd23fbfaSmrg 7598c4a8e55Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 760bd23fbfaSmrg :print 7618c4a8e55Smrg s/^# // 7628c4a8e55Smrg s/^# *$// 7638c4a8e55Smrg s*\$progname*'$progname'* 7648c4a8e55Smrg s*\$host*'"$host"'* 7658c4a8e55Smrg s*\$SHELL*'"$SHELL"'* 7668c4a8e55Smrg s*\$LTCC*'"$LTCC"'* 7678c4a8e55Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 7688c4a8e55Smrg s*\$LD*'"$LD"'* 7698c4a8e55Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 7700597fb56Smrg s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ 7710597fb56Smrg s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ 7728c4a8e55Smrg p 773bd23fbfaSmrg d 774bd23fbfaSmrg } 775bd23fbfaSmrg /^# .* home page:/b print 776bd23fbfaSmrg /^# General help using/b print 777bd23fbfaSmrg ' < "$progpath" 778706b6b52Smrg ret=$? 779706b6b52Smrg if test -z "$1"; then 780706b6b52Smrg exit $ret 781706b6b52Smrg fi 7828c4a8e55Smrg} 7838c4a8e55Smrg 7848c4a8e55Smrg# func_missing_arg argname 7858c4a8e55Smrg# Echo program name prefixed message to standard error and set global 7868c4a8e55Smrg# exit_cmd. 7878c4a8e55Smrgfunc_missing_arg () 7888c4a8e55Smrg{ 789bd23fbfaSmrg $opt_debug 790bd23fbfaSmrg 791706b6b52Smrg func_error "missing argument for $1." 7928c4a8e55Smrg exit_cmd=exit 7938c4a8e55Smrg} 7948c4a8e55Smrg 7958c4a8e55Smrg 796bd23fbfaSmrg# func_split_short_opt shortopt 797bd23fbfaSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 798bd23fbfaSmrg# variables after splitting SHORTOPT after the 2nd character. 799bd23fbfaSmrgfunc_split_short_opt () 800bd23fbfaSmrg{ 801bd23fbfaSmrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 802bd23fbfaSmrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 803bd23fbfaSmrg 804bd23fbfaSmrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 805bd23fbfaSmrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 806bd23fbfaSmrg} # func_split_short_opt may be replaced by extended shell implementation 807bd23fbfaSmrg 808bd23fbfaSmrg 809bd23fbfaSmrg# func_split_long_opt longopt 810bd23fbfaSmrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 811bd23fbfaSmrg# variables after splitting LONGOPT at the `=' sign. 812bd23fbfaSmrgfunc_split_long_opt () 813bd23fbfaSmrg{ 814bd23fbfaSmrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 815bd23fbfaSmrg my_sed_long_arg='1s/^--[^=]*=//' 816bd23fbfaSmrg 817bd23fbfaSmrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 818bd23fbfaSmrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 819bd23fbfaSmrg} # func_split_long_opt may be replaced by extended shell implementation 820bd23fbfaSmrg 821bd23fbfaSmrgexit_cmd=: 8228c4a8e55Smrg 8238c4a8e55Smrg 8248c4a8e55Smrg 8258c4a8e55Smrg 826b042e37fSmrg 8278c4a8e55Smrgmagic="%%%MAGIC variable%%%" 8288c4a8e55Smrgmagic_exe="%%%MAGIC EXE variable%%%" 829b042e37fSmrg 8308c4a8e55Smrg# Global variables. 8318c4a8e55Smrgnonopt= 8328c4a8e55Smrgpreserve_args= 8338c4a8e55Smrglo2o="s/\\.lo\$/.${objext}/" 8348c4a8e55Smrgo2lo="s/\\.${objext}\$/.lo/" 8358c4a8e55Smrgextracted_archives= 8368c4a8e55Smrgextracted_serial=0 837b042e37fSmrg 8388c4a8e55Smrg# If this variable is set in any of the actions, the command in it 8398c4a8e55Smrg# will be execed at the end. This prevents here-documents from being 8408c4a8e55Smrg# left over by shells. 8418c4a8e55Smrgexec_cmd= 8428c4a8e55Smrg 843bd23fbfaSmrg# func_append var value 844bd23fbfaSmrg# Append VALUE to the end of shell variable VAR. 845bd23fbfaSmrgfunc_append () 846bd23fbfaSmrg{ 847bd23fbfaSmrg eval "${1}=\$${1}\${2}" 848bd23fbfaSmrg} # func_append may be replaced by extended shell implementation 849bd23fbfaSmrg 850bd23fbfaSmrg# func_append_quoted var value 851bd23fbfaSmrg# Quote VALUE and append to the end of shell variable VAR, separated 852bd23fbfaSmrg# by a space. 853bd23fbfaSmrgfunc_append_quoted () 854bd23fbfaSmrg{ 855bd23fbfaSmrg func_quote_for_eval "${2}" 856bd23fbfaSmrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 857bd23fbfaSmrg} # func_append_quoted may be replaced by extended shell implementation 858bd23fbfaSmrg 859bd23fbfaSmrg 860bd23fbfaSmrg# func_arith arithmetic-term... 861bd23fbfaSmrgfunc_arith () 862bd23fbfaSmrg{ 863bd23fbfaSmrg func_arith_result=`expr "${@}"` 864bd23fbfaSmrg} # func_arith may be replaced by extended shell implementation 865bd23fbfaSmrg 866bd23fbfaSmrg 867bd23fbfaSmrg# func_len string 868bd23fbfaSmrg# STRING may not start with a hyphen. 869bd23fbfaSmrgfunc_len () 870bd23fbfaSmrg{ 871bd23fbfaSmrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 872bd23fbfaSmrg} # func_len may be replaced by extended shell implementation 873bd23fbfaSmrg 874bd23fbfaSmrg 875bd23fbfaSmrg# func_lo2o object 876bd23fbfaSmrgfunc_lo2o () 877bd23fbfaSmrg{ 878bd23fbfaSmrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 879bd23fbfaSmrg} # func_lo2o may be replaced by extended shell implementation 880bd23fbfaSmrg 881bd23fbfaSmrg 882bd23fbfaSmrg# func_xform libobj-or-source 883bd23fbfaSmrgfunc_xform () 884bd23fbfaSmrg{ 885bd23fbfaSmrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 886bd23fbfaSmrg} # func_xform may be replaced by extended shell implementation 887bd23fbfaSmrg 888bd23fbfaSmrg 8898c4a8e55Smrg# func_fatal_configuration arg... 8908c4a8e55Smrg# Echo program name prefixed message to standard error, followed by 8918c4a8e55Smrg# a configuration failure hint, and exit. 8928c4a8e55Smrgfunc_fatal_configuration () 8938c4a8e55Smrg{ 8948c4a8e55Smrg func_error ${1+"$@"} 8958c4a8e55Smrg func_error "See the $PACKAGE documentation for more information." 8968c4a8e55Smrg func_fatal_error "Fatal configuration error." 8978c4a8e55Smrg} 898b042e37fSmrg 899b042e37fSmrg 9008c4a8e55Smrg# func_config 9018c4a8e55Smrg# Display the configuration for all the tags in this script. 9028c4a8e55Smrgfunc_config () 9038c4a8e55Smrg{ 9048c4a8e55Smrg re_begincf='^# ### BEGIN LIBTOOL' 9058c4a8e55Smrg re_endcf='^# ### END LIBTOOL' 9068c4a8e55Smrg 9078c4a8e55Smrg # Default configuration. 9088c4a8e55Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 9098c4a8e55Smrg 910b042e37fSmrg # Now print the configurations for the tags. 911b042e37fSmrg for tagname in $taglist; do 9128c4a8e55Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 913b042e37fSmrg done 914b042e37fSmrg 9158c4a8e55Smrg exit $? 9168c4a8e55Smrg} 917b042e37fSmrg 9188c4a8e55Smrg# func_features 9198c4a8e55Smrg# Display the features supported by this script. 9208c4a8e55Smrgfunc_features () 9218c4a8e55Smrg{ 922706b6b52Smrg echo "host: $host" 923b042e37fSmrg if test "$build_libtool_libs" = yes; then 924706b6b52Smrg echo "enable shared libraries" 925b042e37fSmrg else 926706b6b52Smrg echo "disable shared libraries" 927b042e37fSmrg fi 928b042e37fSmrg if test "$build_old_libs" = yes; then 929706b6b52Smrg echo "enable static libraries" 930b042e37fSmrg else 931706b6b52Smrg echo "disable static libraries" 932b042e37fSmrg fi 9338c4a8e55Smrg 934b042e37fSmrg exit $? 9358c4a8e55Smrg} 936b042e37fSmrg 9378c4a8e55Smrg# func_enable_tag tagname 9388c4a8e55Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 9398c4a8e55Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 9408c4a8e55Smrg# variable here. 9418c4a8e55Smrgfunc_enable_tag () 9428c4a8e55Smrg{ 9438c4a8e55Smrg # Global variable: 9448c4a8e55Smrg tagname="$1" 945b042e37fSmrg 9468c4a8e55Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 9478c4a8e55Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 9488c4a8e55Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 949b042e37fSmrg 9508c4a8e55Smrg # Validate tagname. 9518c4a8e55Smrg case $tagname in 9528c4a8e55Smrg *[!-_A-Za-z0-9,/]*) 9538c4a8e55Smrg func_fatal_error "invalid tag name: $tagname" 9548c4a8e55Smrg ;; 9558c4a8e55Smrg esac 956b042e37fSmrg 9578c4a8e55Smrg # Don't test for the "default" C tag, as we know it's 9588c4a8e55Smrg # there but not specially marked. 9598c4a8e55Smrg case $tagname in 9608c4a8e55Smrg CC) ;; 9618c4a8e55Smrg *) 9628c4a8e55Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 9638c4a8e55Smrg taglist="$taglist $tagname" 9648c4a8e55Smrg 9658c4a8e55Smrg # Evaluate the configuration. Be careful to quote the path 9668c4a8e55Smrg # and the sed script, to avoid splitting on whitespace, but 9678c4a8e55Smrg # also don't use non-portable quotes within backquotes within 9688c4a8e55Smrg # quotes we have to do it in 2 steps: 9698c4a8e55Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 9708c4a8e55Smrg eval "$extractedcf" 9718c4a8e55Smrg else 9728c4a8e55Smrg func_error "ignoring unknown tag $tagname" 9738c4a8e55Smrg fi 9748c4a8e55Smrg ;; 9758c4a8e55Smrg esac 9768c4a8e55Smrg} 977b042e37fSmrg 978bd23fbfaSmrg# func_check_version_match 979bd23fbfaSmrg# Ensure that we are using m4 macros, and libtool script from the same 980bd23fbfaSmrg# release of libtool. 981bd23fbfaSmrgfunc_check_version_match () 9828c4a8e55Smrg{ 983bd23fbfaSmrg if test "$package_revision" != "$macro_revision"; then 984bd23fbfaSmrg if test "$VERSION" != "$macro_version"; then 985bd23fbfaSmrg if test -z "$macro_version"; then 986bd23fbfaSmrg cat >&2 <<_LT_EOF 987bd23fbfaSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 988bd23fbfaSmrg$progname: definition of this LT_INIT comes from an older release. 989bd23fbfaSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 990bd23fbfaSmrg$progname: and run autoconf again. 991bd23fbfaSmrg_LT_EOF 992bd23fbfaSmrg else 993bd23fbfaSmrg cat >&2 <<_LT_EOF 994bd23fbfaSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 995bd23fbfaSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 996bd23fbfaSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 997bd23fbfaSmrg$progname: and run autoconf again. 998bd23fbfaSmrg_LT_EOF 999bd23fbfaSmrg fi 1000bd23fbfaSmrg else 1001bd23fbfaSmrg cat >&2 <<_LT_EOF 1002bd23fbfaSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 1003bd23fbfaSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 1004bd23fbfaSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 1005bd23fbfaSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 1006bd23fbfaSmrg_LT_EOF 1007bd23fbfaSmrg fi 10088c4a8e55Smrg 1009bd23fbfaSmrg exit $EXIT_MISMATCH 1010bd23fbfaSmrg fi 1011bd23fbfaSmrg} 1012bd23fbfaSmrg 1013bd23fbfaSmrg 1014bd23fbfaSmrg# Shorthand for --mode=foo, only valid as the first argument 1015bd23fbfaSmrgcase $1 in 1016bd23fbfaSmrgclean|clea|cle|cl) 1017bd23fbfaSmrg shift; set dummy --mode clean ${1+"$@"}; shift 1018bd23fbfaSmrg ;; 1019bd23fbfaSmrgcompile|compil|compi|comp|com|co|c) 1020bd23fbfaSmrg shift; set dummy --mode compile ${1+"$@"}; shift 1021bd23fbfaSmrg ;; 1022bd23fbfaSmrgexecute|execut|execu|exec|exe|ex|e) 1023bd23fbfaSmrg shift; set dummy --mode execute ${1+"$@"}; shift 1024bd23fbfaSmrg ;; 1025bd23fbfaSmrgfinish|finis|fini|fin|fi|f) 1026bd23fbfaSmrg shift; set dummy --mode finish ${1+"$@"}; shift 1027bd23fbfaSmrg ;; 1028bd23fbfaSmrginstall|instal|insta|inst|ins|in|i) 1029bd23fbfaSmrg shift; set dummy --mode install ${1+"$@"}; shift 1030bd23fbfaSmrg ;; 1031bd23fbfaSmrglink|lin|li|l) 1032bd23fbfaSmrg shift; set dummy --mode link ${1+"$@"}; shift 1033bd23fbfaSmrg ;; 1034bd23fbfaSmrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 1035bd23fbfaSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 1036bd23fbfaSmrg ;; 1037bd23fbfaSmrgesac 1038b042e37fSmrg 1039bd23fbfaSmrg 1040bd23fbfaSmrg 1041bd23fbfaSmrg# Option defaults: 1042bd23fbfaSmrgopt_debug=: 1043bd23fbfaSmrgopt_dry_run=false 1044bd23fbfaSmrgopt_config=false 1045bd23fbfaSmrgopt_preserve_dup_deps=false 1046bd23fbfaSmrgopt_features=false 1047bd23fbfaSmrgopt_finish=false 1048bd23fbfaSmrgopt_help=false 1049bd23fbfaSmrgopt_help_all=false 1050bd23fbfaSmrgopt_silent=: 10510597fb56Smrgopt_warning=: 1052bd23fbfaSmrgopt_verbose=: 1053bd23fbfaSmrgopt_silent=false 1054bd23fbfaSmrgopt_verbose=false 1055bd23fbfaSmrg 1056bd23fbfaSmrg 1057bd23fbfaSmrg# Parse options once, thoroughly. This comes as soon as possible in the 1058bd23fbfaSmrg# script to make things like `--version' happen as quickly as we can. 1059bd23fbfaSmrg{ 1060bd23fbfaSmrg # this just eases exit handling 1061bd23fbfaSmrg while test $# -gt 0; do 10628c4a8e55Smrg opt="$1" 10638c4a8e55Smrg shift 10648c4a8e55Smrg case $opt in 1065bd23fbfaSmrg --debug|-x) opt_debug='set -x' 10668c4a8e55Smrg func_echo "enabling shell trace mode" 10678c4a8e55Smrg $opt_debug 10688c4a8e55Smrg ;; 1069bd23fbfaSmrg --dry-run|--dryrun|-n) 1070bd23fbfaSmrg opt_dry_run=: 10718c4a8e55Smrg ;; 1072bd23fbfaSmrg --config) 1073bd23fbfaSmrg opt_config=: 1074bd23fbfaSmrgfunc_config 1075bd23fbfaSmrg ;; 1076bd23fbfaSmrg --dlopen|-dlopen) 1077bd23fbfaSmrg optarg="$1" 1078bd23fbfaSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 1079bd23fbfaSmrg}$optarg" 10808c4a8e55Smrg shift 10818c4a8e55Smrg ;; 10828c4a8e55Smrg --preserve-dup-deps) 1083bd23fbfaSmrg opt_preserve_dup_deps=: 1084706b6b52Smrg ;; 1085bd23fbfaSmrg --features) 1086bd23fbfaSmrg opt_features=: 1087bd23fbfaSmrgfunc_features 10888c4a8e55Smrg ;; 1089bd23fbfaSmrg --finish) 1090bd23fbfaSmrg opt_finish=: 1091bd23fbfaSmrgset dummy --mode finish ${1+"$@"}; shift 1092bd23fbfaSmrg ;; 1093bd23fbfaSmrg --help) 1094bd23fbfaSmrg opt_help=: 1095bd23fbfaSmrg ;; 1096bd23fbfaSmrg --help-all) 1097bd23fbfaSmrg opt_help_all=: 1098bd23fbfaSmrgopt_help=': help-all' 1099bd23fbfaSmrg ;; 1100bd23fbfaSmrg --mode) 1101bd23fbfaSmrg test $# = 0 && func_missing_arg $opt && break 1102bd23fbfaSmrg optarg="$1" 1103bd23fbfaSmrg opt_mode="$optarg" 1104bd23fbfaSmrgcase $optarg in 1105bd23fbfaSmrg # Valid mode arguments: 1106bd23fbfaSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 1107bd23fbfaSmrg 1108bd23fbfaSmrg # Catch anything else as an error 1109bd23fbfaSmrg *) func_error "invalid argument for $opt" 1110bd23fbfaSmrg exit_cmd=exit 1111bd23fbfaSmrg break 1112bd23fbfaSmrg ;; 1113bd23fbfaSmrgesac 1114bd23fbfaSmrg shift 1115bd23fbfaSmrg ;; 1116bd23fbfaSmrg --no-silent|--no-quiet) 11178c4a8e55Smrg opt_silent=false 11180597fb56Smrgfunc_append preserve_args " $opt" 11190597fb56Smrg ;; 11200597fb56Smrg --no-warning|--no-warn) 11210597fb56Smrg opt_warning=false 1122bd23fbfaSmrgfunc_append preserve_args " $opt" 1123706b6b52Smrg ;; 1124bd23fbfaSmrg --no-verbose) 1125706b6b52Smrg opt_verbose=false 1126bd23fbfaSmrgfunc_append preserve_args " $opt" 11278c4a8e55Smrg ;; 1128bd23fbfaSmrg --silent|--quiet) 1129bd23fbfaSmrg opt_silent=: 1130bd23fbfaSmrgfunc_append preserve_args " $opt" 1131bd23fbfaSmrg opt_verbose=false 1132bd23fbfaSmrg ;; 1133bd23fbfaSmrg --verbose|-v) 1134bd23fbfaSmrg opt_verbose=: 1135bd23fbfaSmrgfunc_append preserve_args " $opt" 1136bd23fbfaSmrgopt_silent=false 1137bd23fbfaSmrg ;; 1138bd23fbfaSmrg --tag) 1139bd23fbfaSmrg test $# = 0 && func_missing_arg $opt && break 1140bd23fbfaSmrg optarg="$1" 1141bd23fbfaSmrg opt_tag="$optarg" 1142bd23fbfaSmrgfunc_append preserve_args " $opt $optarg" 1143bd23fbfaSmrgfunc_enable_tag "$optarg" 11448c4a8e55Smrg shift 11458c4a8e55Smrg ;; 11468c4a8e55Smrg 1147bd23fbfaSmrg -\?|-h) func_usage ;; 1148bd23fbfaSmrg --help) func_help ;; 1149bd23fbfaSmrg --version) func_version ;; 1150bd23fbfaSmrg 11518c4a8e55Smrg # Separate optargs to long options: 1152bd23fbfaSmrg --*=*) 1153bd23fbfaSmrg func_split_long_opt "$opt" 1154bd23fbfaSmrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 11558c4a8e55Smrg shift 11568c4a8e55Smrg ;; 11578c4a8e55Smrg 1158bd23fbfaSmrg # Separate non-argument short options: 1159bd23fbfaSmrg -\?*|-h*|-n*|-v*) 1160bd23fbfaSmrg func_split_short_opt "$opt" 1161bd23fbfaSmrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 1162bd23fbfaSmrg shift 11638c4a8e55Smrg ;; 1164bd23fbfaSmrg 1165bd23fbfaSmrg --) break ;; 1166bd23fbfaSmrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 1167bd23fbfaSmrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 11688c4a8e55Smrg esac 11698c4a8e55Smrg done 11708c4a8e55Smrg 1171bd23fbfaSmrg # Validate options: 1172bd23fbfaSmrg 1173bd23fbfaSmrg # save first non-option argument 1174bd23fbfaSmrg if test "$#" -gt 0; then 1175bd23fbfaSmrg nonopt="$opt" 1176bd23fbfaSmrg shift 1177bd23fbfaSmrg fi 1178bd23fbfaSmrg 1179bd23fbfaSmrg # preserve --debug 1180bd23fbfaSmrg test "$opt_debug" = : || func_append preserve_args " --debug" 11818c4a8e55Smrg 11828c4a8e55Smrg case $host in 11838c4a8e55Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 11848c4a8e55Smrg # don't eliminate duplications in $postdeps and $predeps 11858c4a8e55Smrg opt_duplicate_compiler_generated_deps=: 1186b042e37fSmrg ;; 1187b042e37fSmrg *) 1188bd23fbfaSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 11898c4a8e55Smrg ;; 11908c4a8e55Smrg esac 1191b042e37fSmrg 1192bd23fbfaSmrg $opt_help || { 1193bd23fbfaSmrg # Sanity checks first: 1194bd23fbfaSmrg func_check_version_match 11958c4a8e55Smrg 1196bd23fbfaSmrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 1197bd23fbfaSmrg func_fatal_configuration "not configured to build any kind of library" 11988c4a8e55Smrg fi 11998c4a8e55Smrg 1200bd23fbfaSmrg # Darwin sucks 1201bd23fbfaSmrg eval std_shrext=\"$shrext_cmds\" 12028c4a8e55Smrg 1203bd23fbfaSmrg # Only execute mode is allowed to have -dlopen flags. 1204bd23fbfaSmrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 1205bd23fbfaSmrg func_error "unrecognized option \`-dlopen'" 1206bd23fbfaSmrg $ECHO "$help" 1>&2 1207bd23fbfaSmrg exit $EXIT_FAILURE 1208bd23fbfaSmrg fi 12098c4a8e55Smrg 1210bd23fbfaSmrg # Change the help message to a mode-specific one. 1211bd23fbfaSmrg generic_help="$help" 1212bd23fbfaSmrg help="Try \`$progname --help --mode=$opt_mode' for more information." 1213bd23fbfaSmrg } 12148c4a8e55Smrg 12158c4a8e55Smrg 1216bd23fbfaSmrg # Bail if the options were screwed 1217bd23fbfaSmrg $exit_cmd $EXIT_FAILURE 1218bd23fbfaSmrg} 12198c4a8e55Smrg 12208c4a8e55Smrg 1221b042e37fSmrg 1222b042e37fSmrg 1223bd23fbfaSmrg## ----------- ## 1224bd23fbfaSmrg## Main. ## 1225bd23fbfaSmrg## ----------- ## 1226b042e37fSmrg 12278c4a8e55Smrg# func_lalib_p file 12288c4a8e55Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 12298c4a8e55Smrg# This function is only a basic sanity check; it will hardly flush out 12308c4a8e55Smrg# determined imposters. 12318c4a8e55Smrgfunc_lalib_p () 12328c4a8e55Smrg{ 12338c4a8e55Smrg test -f "$1" && 12348c4a8e55Smrg $SED -e 4q "$1" 2>/dev/null \ 12358c4a8e55Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 12368c4a8e55Smrg} 1237b042e37fSmrg 12388c4a8e55Smrg# func_lalib_unsafe_p file 12398c4a8e55Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 12408c4a8e55Smrg# This function implements the same check as func_lalib_p without 12418c4a8e55Smrg# resorting to external programs. To this end, it redirects stdin and 12428c4a8e55Smrg# closes it afterwards, without saving the original file descriptor. 12438c4a8e55Smrg# As a safety measure, use it only where a negative result would be 12448c4a8e55Smrg# fatal anyway. Works if `file' does not exist. 12458c4a8e55Smrgfunc_lalib_unsafe_p () 12468c4a8e55Smrg{ 12478c4a8e55Smrg lalib_p=no 12488c4a8e55Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 12498c4a8e55Smrg for lalib_p_l in 1 2 3 4 12508c4a8e55Smrg do 12518c4a8e55Smrg read lalib_p_line 12528c4a8e55Smrg case "$lalib_p_line" in 12538c4a8e55Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 12548c4a8e55Smrg esac 12558c4a8e55Smrg done 12568c4a8e55Smrg exec 0<&5 5<&- 12578c4a8e55Smrg fi 12588c4a8e55Smrg test "$lalib_p" = yes 12598c4a8e55Smrg} 1260b042e37fSmrg 12618c4a8e55Smrg# func_ltwrapper_script_p file 12628c4a8e55Smrg# True iff FILE is a libtool wrapper script 12638c4a8e55Smrg# This function is only a basic sanity check; it will hardly flush out 12648c4a8e55Smrg# determined imposters. 12658c4a8e55Smrgfunc_ltwrapper_script_p () 12668c4a8e55Smrg{ 12678c4a8e55Smrg func_lalib_p "$1" 12688c4a8e55Smrg} 1269b042e37fSmrg 12708c4a8e55Smrg# func_ltwrapper_executable_p file 12718c4a8e55Smrg# True iff FILE is a libtool wrapper executable 12728c4a8e55Smrg# This function is only a basic sanity check; it will hardly flush out 12738c4a8e55Smrg# determined imposters. 12748c4a8e55Smrgfunc_ltwrapper_executable_p () 12758c4a8e55Smrg{ 12768c4a8e55Smrg func_ltwrapper_exec_suffix= 12778c4a8e55Smrg case $1 in 12788c4a8e55Smrg *.exe) ;; 12798c4a8e55Smrg *) func_ltwrapper_exec_suffix=.exe ;; 12808c4a8e55Smrg esac 12818c4a8e55Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 12828c4a8e55Smrg} 1283b042e37fSmrg 12848c4a8e55Smrg# func_ltwrapper_scriptname file 12858c4a8e55Smrg# Assumes file is an ltwrapper_executable 12868c4a8e55Smrg# uses $file to determine the appropriate filename for a 12878c4a8e55Smrg# temporary ltwrapper_script. 12888c4a8e55Smrgfunc_ltwrapper_scriptname () 12898c4a8e55Smrg{ 1290bd23fbfaSmrg func_dirname_and_basename "$1" "" "." 1291bd23fbfaSmrg func_stripname '' '.exe' "$func_basename_result" 1292bd23fbfaSmrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 12938c4a8e55Smrg} 1294b042e37fSmrg 12958c4a8e55Smrg# func_ltwrapper_p file 12968c4a8e55Smrg# True iff FILE is a libtool wrapper script or wrapper executable 12978c4a8e55Smrg# This function is only a basic sanity check; it will hardly flush out 12988c4a8e55Smrg# determined imposters. 12998c4a8e55Smrgfunc_ltwrapper_p () 13008c4a8e55Smrg{ 13018c4a8e55Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 13028c4a8e55Smrg} 13038c4a8e55Smrg 13048c4a8e55Smrg 13058c4a8e55Smrg# func_execute_cmds commands fail_cmd 13068c4a8e55Smrg# Execute tilde-delimited COMMANDS. 13078c4a8e55Smrg# If FAIL_CMD is given, eval that upon failure. 13088c4a8e55Smrg# FAIL_CMD may read-access the current command in variable CMD! 13098c4a8e55Smrgfunc_execute_cmds () 13108c4a8e55Smrg{ 13118c4a8e55Smrg $opt_debug 13128c4a8e55Smrg save_ifs=$IFS; IFS='~' 13138c4a8e55Smrg for cmd in $1; do 13148c4a8e55Smrg IFS=$save_ifs 13158c4a8e55Smrg eval cmd=\"$cmd\" 13168c4a8e55Smrg func_show_eval "$cmd" "${2-:}" 13178c4a8e55Smrg done 13188c4a8e55Smrg IFS=$save_ifs 13198c4a8e55Smrg} 13208c4a8e55Smrg 13218c4a8e55Smrg 13228c4a8e55Smrg# func_source file 13238c4a8e55Smrg# Source FILE, adding directory component if necessary. 13248c4a8e55Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 13258c4a8e55Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 13268c4a8e55Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 13278c4a8e55Smrg# `FILE.' does not work on cygwin managed mounts. 13288c4a8e55Smrgfunc_source () 13298c4a8e55Smrg{ 13308c4a8e55Smrg $opt_debug 13318c4a8e55Smrg case $1 in 13328c4a8e55Smrg */* | *\\*) . "$1" ;; 13338c4a8e55Smrg *) . "./$1" ;; 13348c4a8e55Smrg esac 13358c4a8e55Smrg} 13368c4a8e55Smrg 13378c4a8e55Smrg 1338bd23fbfaSmrg# func_resolve_sysroot PATH 1339bd23fbfaSmrg# Replace a leading = in PATH with a sysroot. Store the result into 1340bd23fbfaSmrg# func_resolve_sysroot_result 1341bd23fbfaSmrgfunc_resolve_sysroot () 1342bd23fbfaSmrg{ 1343bd23fbfaSmrg func_resolve_sysroot_result=$1 1344bd23fbfaSmrg case $func_resolve_sysroot_result in 1345bd23fbfaSmrg =*) 1346bd23fbfaSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 1347bd23fbfaSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 1348bd23fbfaSmrg ;; 1349bd23fbfaSmrg esac 1350bd23fbfaSmrg} 1351bd23fbfaSmrg 1352bd23fbfaSmrg# func_replace_sysroot PATH 1353bd23fbfaSmrg# If PATH begins with the sysroot, replace it with = and 1354bd23fbfaSmrg# store the result into func_replace_sysroot_result. 1355bd23fbfaSmrgfunc_replace_sysroot () 1356bd23fbfaSmrg{ 1357bd23fbfaSmrg case "$lt_sysroot:$1" in 1358bd23fbfaSmrg ?*:"$lt_sysroot"*) 1359bd23fbfaSmrg func_stripname "$lt_sysroot" '' "$1" 1360bd23fbfaSmrg func_replace_sysroot_result="=$func_stripname_result" 1361bd23fbfaSmrg ;; 1362bd23fbfaSmrg *) 1363bd23fbfaSmrg # Including no sysroot. 1364bd23fbfaSmrg func_replace_sysroot_result=$1 1365bd23fbfaSmrg ;; 1366bd23fbfaSmrg esac 1367bd23fbfaSmrg} 1368bd23fbfaSmrg 13698c4a8e55Smrg# func_infer_tag arg 13708c4a8e55Smrg# Infer tagged configuration to use if any are available and 13718c4a8e55Smrg# if one wasn't chosen via the "--tag" command line option. 13728c4a8e55Smrg# Only attempt this if the compiler in the base compile 13738c4a8e55Smrg# command doesn't match the default compiler. 13748c4a8e55Smrg# arg is usually of the form 'gcc ...' 13758c4a8e55Smrgfunc_infer_tag () 13768c4a8e55Smrg{ 13778c4a8e55Smrg $opt_debug 13788c4a8e55Smrg if test -n "$available_tags" && test -z "$tagname"; then 13798c4a8e55Smrg CC_quoted= 13808c4a8e55Smrg for arg in $CC; do 1381bd23fbfaSmrg func_append_quoted CC_quoted "$arg" 13828c4a8e55Smrg done 1383706b6b52Smrg CC_expanded=`func_echo_all $CC` 1384706b6b52Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 13858c4a8e55Smrg case $@ in 13868c4a8e55Smrg # Blanks in the command may have been stripped by the calling shell, 13878c4a8e55Smrg # but not from the CC environment variable when configure was run. 1388706b6b52Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1389706b6b52Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 13908c4a8e55Smrg # Blanks at the start of $base_compile will cause this to fail 13918c4a8e55Smrg # if we don't check for them as well. 13928c4a8e55Smrg *) 13938c4a8e55Smrg for z in $available_tags; do 13948c4a8e55Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 13958c4a8e55Smrg # Evaluate the configuration. 13968c4a8e55Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 13978c4a8e55Smrg CC_quoted= 13988c4a8e55Smrg for arg in $CC; do 13998c4a8e55Smrg # Double-quote args containing other shell metacharacters. 1400bd23fbfaSmrg func_append_quoted CC_quoted "$arg" 14018c4a8e55Smrg done 1402706b6b52Smrg CC_expanded=`func_echo_all $CC` 1403706b6b52Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 14048c4a8e55Smrg case "$@ " in 1405706b6b52Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1406706b6b52Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 14078c4a8e55Smrg # The compiler in the base compile command matches 14088c4a8e55Smrg # the one in the tagged configuration. 14098c4a8e55Smrg # Assume this is the tagged configuration we want. 14108c4a8e55Smrg tagname=$z 14118c4a8e55Smrg break 14128c4a8e55Smrg ;; 14138c4a8e55Smrg esac 14148c4a8e55Smrg fi 14158c4a8e55Smrg done 14168c4a8e55Smrg # If $tagname still isn't set, then no tagged configuration 14178c4a8e55Smrg # was found and let the user know that the "--tag" command 14188c4a8e55Smrg # line option must be used. 14198c4a8e55Smrg if test -z "$tagname"; then 14208c4a8e55Smrg func_echo "unable to infer tagged configuration" 14218c4a8e55Smrg func_fatal_error "specify a tag with \`--tag'" 14228c4a8e55Smrg# else 14238c4a8e55Smrg# func_verbose "using $tagname tagged configuration" 14248c4a8e55Smrg fi 14258c4a8e55Smrg ;; 14268c4a8e55Smrg esac 14278c4a8e55Smrg fi 14288c4a8e55Smrg} 14298c4a8e55Smrg 14308c4a8e55Smrg 14318c4a8e55Smrg 1432bd23fbfaSmrg# func_write_libtool_object output_name pic_name nonpic_name 1433bd23fbfaSmrg# Create a libtool object file (analogous to a ".la" file), 1434bd23fbfaSmrg# but don't create it if we're doing a dry run. 1435bd23fbfaSmrgfunc_write_libtool_object () 1436bd23fbfaSmrg{ 1437bd23fbfaSmrg write_libobj=${1} 1438bd23fbfaSmrg if test "$build_libtool_libs" = yes; then 1439bd23fbfaSmrg write_lobj=\'${2}\' 1440bd23fbfaSmrg else 1441bd23fbfaSmrg write_lobj=none 1442bd23fbfaSmrg fi 1443bd23fbfaSmrg 1444bd23fbfaSmrg if test "$build_old_libs" = yes; then 1445bd23fbfaSmrg write_oldobj=\'${3}\' 1446bd23fbfaSmrg else 1447bd23fbfaSmrg write_oldobj=none 1448bd23fbfaSmrg fi 1449bd23fbfaSmrg 1450bd23fbfaSmrg $opt_dry_run || { 1451bd23fbfaSmrg cat >${write_libobj}T <<EOF 1452bd23fbfaSmrg# $write_libobj - a libtool object file 1453bd23fbfaSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 1454bd23fbfaSmrg# 1455bd23fbfaSmrg# Please DO NOT delete this file! 1456bd23fbfaSmrg# It is necessary for linking the library. 1457bd23fbfaSmrg 1458bd23fbfaSmrg# Name of the PIC object. 1459bd23fbfaSmrgpic_object=$write_lobj 1460bd23fbfaSmrg 1461bd23fbfaSmrg# Name of the non-PIC object 1462bd23fbfaSmrgnon_pic_object=$write_oldobj 1463bd23fbfaSmrg 1464bd23fbfaSmrgEOF 1465bd23fbfaSmrg $MV "${write_libobj}T" "${write_libobj}" 1466bd23fbfaSmrg } 1467bd23fbfaSmrg} 1468bd23fbfaSmrg 1469bd23fbfaSmrg 1470bd23fbfaSmrg################################################## 1471bd23fbfaSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 1472bd23fbfaSmrg################################################## 1473bd23fbfaSmrg 1474bd23fbfaSmrg# func_convert_core_file_wine_to_w32 ARG 1475bd23fbfaSmrg# Helper function used by file name conversion functions when $build is *nix, 1476bd23fbfaSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 1477bd23fbfaSmrg# correctly configured wine environment available, with the winepath program 1478bd23fbfaSmrg# in $build's $PATH. 1479bd23fbfaSmrg# 1480bd23fbfaSmrg# ARG is the $build file name to be converted to w32 format. 1481bd23fbfaSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 1482bd23fbfaSmrg# be empty on error (or when ARG is empty) 1483bd23fbfaSmrgfunc_convert_core_file_wine_to_w32 () 1484bd23fbfaSmrg{ 1485bd23fbfaSmrg $opt_debug 1486bd23fbfaSmrg func_convert_core_file_wine_to_w32_result="$1" 1487bd23fbfaSmrg if test -n "$1"; then 1488bd23fbfaSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 1489bd23fbfaSmrg # are forced to check the contents of stdout. On the other hand, if the 1490bd23fbfaSmrg # command is not found, the shell will set an exit code of 127 and print 1491bd23fbfaSmrg # *an error message* to stdout. So we must check for both error code of 1492bd23fbfaSmrg # zero AND non-empty stdout, which explains the odd construction: 1493bd23fbfaSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 1494bd23fbfaSmrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 1495bd23fbfaSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 1496bd23fbfaSmrg $SED -e "$lt_sed_naive_backslashify"` 1497bd23fbfaSmrg else 1498bd23fbfaSmrg func_convert_core_file_wine_to_w32_result= 1499bd23fbfaSmrg fi 1500bd23fbfaSmrg fi 1501bd23fbfaSmrg} 1502bd23fbfaSmrg# end: func_convert_core_file_wine_to_w32 1503bd23fbfaSmrg 1504bd23fbfaSmrg 1505bd23fbfaSmrg# func_convert_core_path_wine_to_w32 ARG 1506bd23fbfaSmrg# Helper function used by path conversion functions when $build is *nix, and 1507bd23fbfaSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 1508bd23fbfaSmrg# configured wine environment available, with the winepath program in $build's 1509bd23fbfaSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 1510bd23fbfaSmrg# 1511bd23fbfaSmrg# ARG is path to be converted from $build format to win32. 1512bd23fbfaSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 1513bd23fbfaSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 1514bd23fbfaSmrg# are convertible, then the result may be empty. 1515bd23fbfaSmrgfunc_convert_core_path_wine_to_w32 () 1516bd23fbfaSmrg{ 1517bd23fbfaSmrg $opt_debug 1518bd23fbfaSmrg # unfortunately, winepath doesn't convert paths, only file names 1519bd23fbfaSmrg func_convert_core_path_wine_to_w32_result="" 1520bd23fbfaSmrg if test -n "$1"; then 1521bd23fbfaSmrg oldIFS=$IFS 1522bd23fbfaSmrg IFS=: 1523bd23fbfaSmrg for func_convert_core_path_wine_to_w32_f in $1; do 1524bd23fbfaSmrg IFS=$oldIFS 1525bd23fbfaSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 1526bd23fbfaSmrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 1527bd23fbfaSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 1528bd23fbfaSmrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 1529bd23fbfaSmrg else 1530bd23fbfaSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 1531bd23fbfaSmrg fi 1532bd23fbfaSmrg fi 1533bd23fbfaSmrg done 1534bd23fbfaSmrg IFS=$oldIFS 1535bd23fbfaSmrg fi 1536bd23fbfaSmrg} 1537bd23fbfaSmrg# end: func_convert_core_path_wine_to_w32 1538bd23fbfaSmrg 1539bd23fbfaSmrg 1540bd23fbfaSmrg# func_cygpath ARGS... 1541bd23fbfaSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 1542bd23fbfaSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 1543bd23fbfaSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 1544bd23fbfaSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 1545bd23fbfaSmrg# file name or path is assumed to be in w32 format, as previously converted 1546bd23fbfaSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 1547bd23fbfaSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 1548bd23fbfaSmrg# Cygwin format). Returns an empty string on error. 1549bd23fbfaSmrg# 1550bd23fbfaSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 1551bd23fbfaSmrg# be converted. 1552bd23fbfaSmrg# 1553bd23fbfaSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 1554bd23fbfaSmrg# environment variable; do not put it in $PATH. 1555bd23fbfaSmrgfunc_cygpath () 1556bd23fbfaSmrg{ 1557bd23fbfaSmrg $opt_debug 1558bd23fbfaSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 1559bd23fbfaSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 1560bd23fbfaSmrg if test "$?" -ne 0; then 1561bd23fbfaSmrg # on failure, ensure result is empty 1562bd23fbfaSmrg func_cygpath_result= 1563bd23fbfaSmrg fi 1564bd23fbfaSmrg else 1565bd23fbfaSmrg func_cygpath_result= 1566bd23fbfaSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 1567bd23fbfaSmrg fi 1568bd23fbfaSmrg} 1569bd23fbfaSmrg#end: func_cygpath 1570bd23fbfaSmrg 1571bd23fbfaSmrg 1572bd23fbfaSmrg# func_convert_core_msys_to_w32 ARG 1573bd23fbfaSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 1574bd23fbfaSmrg# result in func_convert_core_msys_to_w32_result. 1575bd23fbfaSmrgfunc_convert_core_msys_to_w32 () 1576bd23fbfaSmrg{ 1577bd23fbfaSmrg $opt_debug 1578bd23fbfaSmrg # awkward: cmd appends spaces to result 1579bd23fbfaSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 1580bd23fbfaSmrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 1581bd23fbfaSmrg} 1582bd23fbfaSmrg#end: func_convert_core_msys_to_w32 1583bd23fbfaSmrg 1584bd23fbfaSmrg 1585bd23fbfaSmrg# func_convert_file_check ARG1 ARG2 1586bd23fbfaSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 1587bd23fbfaSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 1588bd23fbfaSmrg# func_to_host_file_result to ARG1). 1589bd23fbfaSmrgfunc_convert_file_check () 1590bd23fbfaSmrg{ 1591bd23fbfaSmrg $opt_debug 1592bd23fbfaSmrg if test -z "$2" && test -n "$1" ; then 1593bd23fbfaSmrg func_error "Could not determine host file name corresponding to" 1594bd23fbfaSmrg func_error " \`$1'" 1595bd23fbfaSmrg func_error "Continuing, but uninstalled executables may not work." 1596bd23fbfaSmrg # Fallback: 1597bd23fbfaSmrg func_to_host_file_result="$1" 1598bd23fbfaSmrg fi 1599bd23fbfaSmrg} 1600bd23fbfaSmrg# end func_convert_file_check 1601bd23fbfaSmrg 1602bd23fbfaSmrg 1603bd23fbfaSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 1604bd23fbfaSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 1605bd23fbfaSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 1606bd23fbfaSmrg# func_to_host_file_result to a simplistic fallback value (see below). 1607bd23fbfaSmrgfunc_convert_path_check () 1608bd23fbfaSmrg{ 1609bd23fbfaSmrg $opt_debug 1610bd23fbfaSmrg if test -z "$4" && test -n "$3"; then 1611bd23fbfaSmrg func_error "Could not determine the host path corresponding to" 1612bd23fbfaSmrg func_error " \`$3'" 1613bd23fbfaSmrg func_error "Continuing, but uninstalled executables may not work." 1614bd23fbfaSmrg # Fallback. This is a deliberately simplistic "conversion" and 1615bd23fbfaSmrg # should not be "improved". See libtool.info. 1616bd23fbfaSmrg if test "x$1" != "x$2"; then 1617bd23fbfaSmrg lt_replace_pathsep_chars="s|$1|$2|g" 1618bd23fbfaSmrg func_to_host_path_result=`echo "$3" | 1619bd23fbfaSmrg $SED -e "$lt_replace_pathsep_chars"` 1620bd23fbfaSmrg else 1621bd23fbfaSmrg func_to_host_path_result="$3" 1622bd23fbfaSmrg fi 1623bd23fbfaSmrg fi 1624bd23fbfaSmrg} 1625bd23fbfaSmrg# end func_convert_path_check 1626bd23fbfaSmrg 1627bd23fbfaSmrg 1628bd23fbfaSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 1629bd23fbfaSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 1630bd23fbfaSmrg# and appending REPL if ORIG matches BACKPAT. 1631bd23fbfaSmrgfunc_convert_path_front_back_pathsep () 1632bd23fbfaSmrg{ 1633bd23fbfaSmrg $opt_debug 1634bd23fbfaSmrg case $4 in 1635bd23fbfaSmrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 1636bd23fbfaSmrg ;; 1637bd23fbfaSmrg esac 1638bd23fbfaSmrg case $4 in 1639bd23fbfaSmrg $2 ) func_append func_to_host_path_result "$3" 1640bd23fbfaSmrg ;; 1641bd23fbfaSmrg esac 1642bd23fbfaSmrg} 1643bd23fbfaSmrg# end func_convert_path_front_back_pathsep 1644bd23fbfaSmrg 1645bd23fbfaSmrg 1646bd23fbfaSmrg################################################## 1647bd23fbfaSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 1648bd23fbfaSmrg################################################## 1649bd23fbfaSmrg# invoked via `$to_host_file_cmd ARG' 1650bd23fbfaSmrg# 1651bd23fbfaSmrg# In each case, ARG is the path to be converted from $build to $host format. 1652bd23fbfaSmrg# Result will be available in $func_to_host_file_result. 1653bd23fbfaSmrg 1654bd23fbfaSmrg 1655bd23fbfaSmrg# func_to_host_file ARG 1656bd23fbfaSmrg# Converts the file name ARG from $build format to $host format. Return result 1657bd23fbfaSmrg# in func_to_host_file_result. 1658bd23fbfaSmrgfunc_to_host_file () 1659bd23fbfaSmrg{ 1660bd23fbfaSmrg $opt_debug 1661bd23fbfaSmrg $to_host_file_cmd "$1" 1662bd23fbfaSmrg} 1663bd23fbfaSmrg# end func_to_host_file 1664bd23fbfaSmrg 1665bd23fbfaSmrg 1666bd23fbfaSmrg# func_to_tool_file ARG LAZY 1667bd23fbfaSmrg# converts the file name ARG from $build format to toolchain format. Return 1668bd23fbfaSmrg# result in func_to_tool_file_result. If the conversion in use is listed 1669bd23fbfaSmrg# in (the comma separated) LAZY, no conversion takes place. 1670bd23fbfaSmrgfunc_to_tool_file () 1671bd23fbfaSmrg{ 1672bd23fbfaSmrg $opt_debug 1673bd23fbfaSmrg case ,$2, in 1674bd23fbfaSmrg *,"$to_tool_file_cmd",*) 1675bd23fbfaSmrg func_to_tool_file_result=$1 1676bd23fbfaSmrg ;; 1677bd23fbfaSmrg *) 1678bd23fbfaSmrg $to_tool_file_cmd "$1" 1679bd23fbfaSmrg func_to_tool_file_result=$func_to_host_file_result 1680bd23fbfaSmrg ;; 1681bd23fbfaSmrg esac 1682bd23fbfaSmrg} 1683bd23fbfaSmrg# end func_to_tool_file 1684bd23fbfaSmrg 1685bd23fbfaSmrg 1686bd23fbfaSmrg# func_convert_file_noop ARG 1687bd23fbfaSmrg# Copy ARG to func_to_host_file_result. 1688bd23fbfaSmrgfunc_convert_file_noop () 1689bd23fbfaSmrg{ 1690bd23fbfaSmrg func_to_host_file_result="$1" 1691bd23fbfaSmrg} 1692bd23fbfaSmrg# end func_convert_file_noop 1693bd23fbfaSmrg 1694bd23fbfaSmrg 1695bd23fbfaSmrg# func_convert_file_msys_to_w32 ARG 1696bd23fbfaSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 1697bd23fbfaSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 1698bd23fbfaSmrg# func_to_host_file_result. 1699bd23fbfaSmrgfunc_convert_file_msys_to_w32 () 1700bd23fbfaSmrg{ 1701bd23fbfaSmrg $opt_debug 1702bd23fbfaSmrg func_to_host_file_result="$1" 1703bd23fbfaSmrg if test -n "$1"; then 1704bd23fbfaSmrg func_convert_core_msys_to_w32 "$1" 1705bd23fbfaSmrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 1706bd23fbfaSmrg fi 1707bd23fbfaSmrg func_convert_file_check "$1" "$func_to_host_file_result" 1708bd23fbfaSmrg} 1709bd23fbfaSmrg# end func_convert_file_msys_to_w32 1710bd23fbfaSmrg 1711bd23fbfaSmrg 1712bd23fbfaSmrg# func_convert_file_cygwin_to_w32 ARG 1713bd23fbfaSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 1714bd23fbfaSmrg# func_to_host_file_result. 1715bd23fbfaSmrgfunc_convert_file_cygwin_to_w32 () 1716bd23fbfaSmrg{ 1717bd23fbfaSmrg $opt_debug 1718bd23fbfaSmrg func_to_host_file_result="$1" 1719bd23fbfaSmrg if test -n "$1"; then 1720bd23fbfaSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 1721bd23fbfaSmrg # LT_CYGPATH in this case. 1722bd23fbfaSmrg func_to_host_file_result=`cygpath -m "$1"` 1723bd23fbfaSmrg fi 1724bd23fbfaSmrg func_convert_file_check "$1" "$func_to_host_file_result" 1725bd23fbfaSmrg} 1726bd23fbfaSmrg# end func_convert_file_cygwin_to_w32 1727bd23fbfaSmrg 1728bd23fbfaSmrg 1729bd23fbfaSmrg# func_convert_file_nix_to_w32 ARG 1730bd23fbfaSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 1731bd23fbfaSmrg# and a working winepath. Returns result in func_to_host_file_result. 1732bd23fbfaSmrgfunc_convert_file_nix_to_w32 () 1733bd23fbfaSmrg{ 1734bd23fbfaSmrg $opt_debug 1735bd23fbfaSmrg func_to_host_file_result="$1" 1736bd23fbfaSmrg if test -n "$1"; then 1737bd23fbfaSmrg func_convert_core_file_wine_to_w32 "$1" 1738bd23fbfaSmrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 1739bd23fbfaSmrg fi 1740bd23fbfaSmrg func_convert_file_check "$1" "$func_to_host_file_result" 1741bd23fbfaSmrg} 1742bd23fbfaSmrg# end func_convert_file_nix_to_w32 1743bd23fbfaSmrg 1744bd23fbfaSmrg 1745bd23fbfaSmrg# func_convert_file_msys_to_cygwin ARG 1746bd23fbfaSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1747bd23fbfaSmrg# Returns result in func_to_host_file_result. 1748bd23fbfaSmrgfunc_convert_file_msys_to_cygwin () 1749bd23fbfaSmrg{ 1750bd23fbfaSmrg $opt_debug 1751bd23fbfaSmrg func_to_host_file_result="$1" 1752bd23fbfaSmrg if test -n "$1"; then 1753bd23fbfaSmrg func_convert_core_msys_to_w32 "$1" 1754bd23fbfaSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 1755bd23fbfaSmrg func_to_host_file_result="$func_cygpath_result" 1756bd23fbfaSmrg fi 1757bd23fbfaSmrg func_convert_file_check "$1" "$func_to_host_file_result" 1758bd23fbfaSmrg} 1759bd23fbfaSmrg# end func_convert_file_msys_to_cygwin 1760bd23fbfaSmrg 1761bd23fbfaSmrg 1762bd23fbfaSmrg# func_convert_file_nix_to_cygwin ARG 1763bd23fbfaSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 1764bd23fbfaSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 1765bd23fbfaSmrg# in func_to_host_file_result. 1766bd23fbfaSmrgfunc_convert_file_nix_to_cygwin () 1767bd23fbfaSmrg{ 1768bd23fbfaSmrg $opt_debug 1769bd23fbfaSmrg func_to_host_file_result="$1" 1770bd23fbfaSmrg if test -n "$1"; then 1771bd23fbfaSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 1772bd23fbfaSmrg func_convert_core_file_wine_to_w32 "$1" 1773bd23fbfaSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 1774bd23fbfaSmrg func_to_host_file_result="$func_cygpath_result" 1775bd23fbfaSmrg fi 1776bd23fbfaSmrg func_convert_file_check "$1" "$func_to_host_file_result" 1777bd23fbfaSmrg} 1778bd23fbfaSmrg# end func_convert_file_nix_to_cygwin 1779bd23fbfaSmrg 1780bd23fbfaSmrg 1781bd23fbfaSmrg############################################# 1782bd23fbfaSmrg# $build to $host PATH CONVERSION FUNCTIONS # 1783bd23fbfaSmrg############################################# 1784bd23fbfaSmrg# invoked via `$to_host_path_cmd ARG' 1785bd23fbfaSmrg# 1786bd23fbfaSmrg# In each case, ARG is the path to be converted from $build to $host format. 1787bd23fbfaSmrg# The result will be available in $func_to_host_path_result. 1788bd23fbfaSmrg# 1789bd23fbfaSmrg# Path separators are also converted from $build format to $host format. If 1790bd23fbfaSmrg# ARG begins or ends with a path separator character, it is preserved (but 1791bd23fbfaSmrg# converted to $host format) on output. 1792bd23fbfaSmrg# 1793bd23fbfaSmrg# All path conversion functions are named using the following convention: 1794bd23fbfaSmrg# file name conversion function : func_convert_file_X_to_Y () 1795bd23fbfaSmrg# path conversion function : func_convert_path_X_to_Y () 1796bd23fbfaSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 1797bd23fbfaSmrg# same. If conversion functions are added for new $build/$host combinations, 1798bd23fbfaSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 1799bd23fbfaSmrg# will break. 1800bd23fbfaSmrg 1801bd23fbfaSmrg 1802bd23fbfaSmrg# func_init_to_host_path_cmd 1803bd23fbfaSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 1804bd23fbfaSmrg# appropriate value, based on the value of $to_host_file_cmd. 1805bd23fbfaSmrgto_host_path_cmd= 1806bd23fbfaSmrgfunc_init_to_host_path_cmd () 1807bd23fbfaSmrg{ 1808bd23fbfaSmrg $opt_debug 1809bd23fbfaSmrg if test -z "$to_host_path_cmd"; then 1810bd23fbfaSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 1811bd23fbfaSmrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 1812bd23fbfaSmrg fi 1813bd23fbfaSmrg} 1814bd23fbfaSmrg 1815bd23fbfaSmrg 1816bd23fbfaSmrg# func_to_host_path ARG 1817bd23fbfaSmrg# Converts the path ARG from $build format to $host format. Return result 1818bd23fbfaSmrg# in func_to_host_path_result. 1819bd23fbfaSmrgfunc_to_host_path () 1820bd23fbfaSmrg{ 1821bd23fbfaSmrg $opt_debug 1822bd23fbfaSmrg func_init_to_host_path_cmd 1823bd23fbfaSmrg $to_host_path_cmd "$1" 1824bd23fbfaSmrg} 1825bd23fbfaSmrg# end func_to_host_path 1826bd23fbfaSmrg 1827bd23fbfaSmrg 1828bd23fbfaSmrg# func_convert_path_noop ARG 1829bd23fbfaSmrg# Copy ARG to func_to_host_path_result. 1830bd23fbfaSmrgfunc_convert_path_noop () 1831bd23fbfaSmrg{ 1832bd23fbfaSmrg func_to_host_path_result="$1" 1833bd23fbfaSmrg} 1834bd23fbfaSmrg# end func_convert_path_noop 1835bd23fbfaSmrg 1836bd23fbfaSmrg 1837bd23fbfaSmrg# func_convert_path_msys_to_w32 ARG 1838bd23fbfaSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 1839bd23fbfaSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 1840bd23fbfaSmrg# func_to_host_path_result. 1841bd23fbfaSmrgfunc_convert_path_msys_to_w32 () 18428c4a8e55Smrg{ 1843bd23fbfaSmrg $opt_debug 1844bd23fbfaSmrg func_to_host_path_result="$1" 1845bd23fbfaSmrg if test -n "$1"; then 1846bd23fbfaSmrg # Remove leading and trailing path separator characters from ARG. MSYS 1847bd23fbfaSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 1848bd23fbfaSmrg # and winepath ignores them completely. 1849bd23fbfaSmrg func_stripname : : "$1" 1850bd23fbfaSmrg func_to_host_path_tmp1=$func_stripname_result 1851bd23fbfaSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1852bd23fbfaSmrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 1853bd23fbfaSmrg func_convert_path_check : ";" \ 1854bd23fbfaSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1855bd23fbfaSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1856bd23fbfaSmrg fi 1857bd23fbfaSmrg} 1858bd23fbfaSmrg# end func_convert_path_msys_to_w32 18598c4a8e55Smrg 18608c4a8e55Smrg 1861bd23fbfaSmrg# func_convert_path_cygwin_to_w32 ARG 1862bd23fbfaSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 1863bd23fbfaSmrg# func_to_host_file_result. 1864bd23fbfaSmrgfunc_convert_path_cygwin_to_w32 () 1865bd23fbfaSmrg{ 1866bd23fbfaSmrg $opt_debug 1867bd23fbfaSmrg func_to_host_path_result="$1" 1868bd23fbfaSmrg if test -n "$1"; then 1869bd23fbfaSmrg # See func_convert_path_msys_to_w32: 1870bd23fbfaSmrg func_stripname : : "$1" 1871bd23fbfaSmrg func_to_host_path_tmp1=$func_stripname_result 1872bd23fbfaSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 1873bd23fbfaSmrg func_convert_path_check : ";" \ 1874bd23fbfaSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1875bd23fbfaSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1876bd23fbfaSmrg fi 1877bd23fbfaSmrg} 1878bd23fbfaSmrg# end func_convert_path_cygwin_to_w32 18798c4a8e55Smrg 18808c4a8e55Smrg 1881bd23fbfaSmrg# func_convert_path_nix_to_w32 ARG 1882bd23fbfaSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 1883bd23fbfaSmrg# a working winepath. Returns result in func_to_host_file_result. 1884bd23fbfaSmrgfunc_convert_path_nix_to_w32 () 1885bd23fbfaSmrg{ 1886bd23fbfaSmrg $opt_debug 1887bd23fbfaSmrg func_to_host_path_result="$1" 1888bd23fbfaSmrg if test -n "$1"; then 1889bd23fbfaSmrg # See func_convert_path_msys_to_w32: 1890bd23fbfaSmrg func_stripname : : "$1" 1891bd23fbfaSmrg func_to_host_path_tmp1=$func_stripname_result 1892bd23fbfaSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1893bd23fbfaSmrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 1894bd23fbfaSmrg func_convert_path_check : ";" \ 1895bd23fbfaSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1896bd23fbfaSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1897bd23fbfaSmrg fi 1898bd23fbfaSmrg} 1899bd23fbfaSmrg# end func_convert_path_nix_to_w32 19008c4a8e55Smrg 1901bd23fbfaSmrg 1902bd23fbfaSmrg# func_convert_path_msys_to_cygwin ARG 1903bd23fbfaSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1904bd23fbfaSmrg# Returns result in func_to_host_file_result. 1905bd23fbfaSmrgfunc_convert_path_msys_to_cygwin () 1906bd23fbfaSmrg{ 1907bd23fbfaSmrg $opt_debug 1908bd23fbfaSmrg func_to_host_path_result="$1" 1909bd23fbfaSmrg if test -n "$1"; then 1910bd23fbfaSmrg # See func_convert_path_msys_to_w32: 1911bd23fbfaSmrg func_stripname : : "$1" 1912bd23fbfaSmrg func_to_host_path_tmp1=$func_stripname_result 1913bd23fbfaSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1914bd23fbfaSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 1915bd23fbfaSmrg func_to_host_path_result="$func_cygpath_result" 1916bd23fbfaSmrg func_convert_path_check : : \ 1917bd23fbfaSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1918bd23fbfaSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1919bd23fbfaSmrg fi 1920bd23fbfaSmrg} 1921bd23fbfaSmrg# end func_convert_path_msys_to_cygwin 1922bd23fbfaSmrg 1923bd23fbfaSmrg 1924bd23fbfaSmrg# func_convert_path_nix_to_cygwin ARG 1925bd23fbfaSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 1926bd23fbfaSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 1927bd23fbfaSmrg# func_to_host_file_result. 1928bd23fbfaSmrgfunc_convert_path_nix_to_cygwin () 1929bd23fbfaSmrg{ 1930bd23fbfaSmrg $opt_debug 1931bd23fbfaSmrg func_to_host_path_result="$1" 1932bd23fbfaSmrg if test -n "$1"; then 1933bd23fbfaSmrg # Remove leading and trailing path separator characters from 1934bd23fbfaSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 1935bd23fbfaSmrg # into '.;' and ';.', and winepath ignores them completely. 1936bd23fbfaSmrg func_stripname : : "$1" 1937bd23fbfaSmrg func_to_host_path_tmp1=$func_stripname_result 1938bd23fbfaSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1939bd23fbfaSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 1940bd23fbfaSmrg func_to_host_path_result="$func_cygpath_result" 1941bd23fbfaSmrg func_convert_path_check : : \ 1942bd23fbfaSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1943bd23fbfaSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1944bd23fbfaSmrg fi 19458c4a8e55Smrg} 1946bd23fbfaSmrg# end func_convert_path_nix_to_cygwin 1947bd23fbfaSmrg 19488c4a8e55Smrg 19498c4a8e55Smrg# func_mode_compile arg... 19508c4a8e55Smrgfunc_mode_compile () 19518c4a8e55Smrg{ 19528c4a8e55Smrg $opt_debug 19538c4a8e55Smrg # Get the compilation command and the source file. 19548c4a8e55Smrg base_compile= 19558c4a8e55Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 19568c4a8e55Smrg suppress_opt=yes 19578c4a8e55Smrg suppress_output= 19588c4a8e55Smrg arg_mode=normal 19598c4a8e55Smrg libobj= 19608c4a8e55Smrg later= 19618c4a8e55Smrg pie_flag= 19628c4a8e55Smrg 19638c4a8e55Smrg for arg 19648c4a8e55Smrg do 19658c4a8e55Smrg case $arg_mode in 19668c4a8e55Smrg arg ) 19678c4a8e55Smrg # do not "continue". Instead, add this to base_compile 19688c4a8e55Smrg lastarg="$arg" 19698c4a8e55Smrg arg_mode=normal 19708c4a8e55Smrg ;; 19718c4a8e55Smrg 19728c4a8e55Smrg target ) 19738c4a8e55Smrg libobj="$arg" 19748c4a8e55Smrg arg_mode=normal 19758c4a8e55Smrg continue 19768c4a8e55Smrg ;; 19778c4a8e55Smrg 19788c4a8e55Smrg normal ) 19798c4a8e55Smrg # Accept any command-line options. 19808c4a8e55Smrg case $arg in 19818c4a8e55Smrg -o) 19828c4a8e55Smrg test -n "$libobj" && \ 19838c4a8e55Smrg func_fatal_error "you cannot specify \`-o' more than once" 19848c4a8e55Smrg arg_mode=target 19858c4a8e55Smrg continue 19868c4a8e55Smrg ;; 19878c4a8e55Smrg 19888c4a8e55Smrg -pie | -fpie | -fPIE) 1989bd23fbfaSmrg func_append pie_flag " $arg" 19908c4a8e55Smrg continue 19918c4a8e55Smrg ;; 19928c4a8e55Smrg 19938c4a8e55Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 1994bd23fbfaSmrg func_append later " $arg" 19958c4a8e55Smrg continue 19968c4a8e55Smrg ;; 19978c4a8e55Smrg 19988c4a8e55Smrg -no-suppress) 19998c4a8e55Smrg suppress_opt=no 20008c4a8e55Smrg continue 20018c4a8e55Smrg ;; 20028c4a8e55Smrg 20038c4a8e55Smrg -Xcompiler) 20048c4a8e55Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 20058c4a8e55Smrg continue # The current "srcfile" will either be retained or 20068c4a8e55Smrg ;; # replaced later. I would guess that would be a bug. 2007b042e37fSmrg 2008b042e37fSmrg -Wc,*) 20098c4a8e55Smrg func_stripname '-Wc,' '' "$arg" 20108c4a8e55Smrg args=$func_stripname_result 2011b042e37fSmrg lastarg= 2012b042e37fSmrg save_ifs="$IFS"; IFS=',' 20138c4a8e55Smrg for arg in $args; do 2014b042e37fSmrg IFS="$save_ifs" 2015bd23fbfaSmrg func_append_quoted lastarg "$arg" 2016b042e37fSmrg done 2017b042e37fSmrg IFS="$save_ifs" 20188c4a8e55Smrg func_stripname ' ' '' "$lastarg" 20198c4a8e55Smrg lastarg=$func_stripname_result 2020b042e37fSmrg 2021b042e37fSmrg # Add the arguments to base_compile. 2022bd23fbfaSmrg func_append base_compile " $lastarg" 2023b042e37fSmrg continue 2024b042e37fSmrg ;; 2025b042e37fSmrg 20268c4a8e55Smrg *) 2027b042e37fSmrg # Accept the current argument as the source file. 2028b042e37fSmrg # The previous "srcfile" becomes the current argument. 2029b042e37fSmrg # 2030b042e37fSmrg lastarg="$srcfile" 2031b042e37fSmrg srcfile="$arg" 2032b042e37fSmrg ;; 2033b042e37fSmrg esac # case $arg 2034b042e37fSmrg ;; 2035b042e37fSmrg esac # case $arg_mode 2036b042e37fSmrg 2037b042e37fSmrg # Aesthetically quote the previous argument. 2038bd23fbfaSmrg func_append_quoted base_compile "$lastarg" 2039b042e37fSmrg done # for arg 2040b042e37fSmrg 2041b042e37fSmrg case $arg_mode in 2042b042e37fSmrg arg) 20438c4a8e55Smrg func_fatal_error "you must specify an argument for -Xcompile" 2044b042e37fSmrg ;; 2045b042e37fSmrg target) 20468c4a8e55Smrg func_fatal_error "you must specify a target with \`-o'" 2047b042e37fSmrg ;; 2048b042e37fSmrg *) 2049b042e37fSmrg # Get the name of the library object. 20508c4a8e55Smrg test -z "$libobj" && { 20518c4a8e55Smrg func_basename "$srcfile" 20528c4a8e55Smrg libobj="$func_basename_result" 20538c4a8e55Smrg } 2054b042e37fSmrg ;; 2055b042e37fSmrg esac 2056b042e37fSmrg 2057b042e37fSmrg # Recognize several different file suffixes. 2058b042e37fSmrg # If the user specifies -o file.o, it is replaced with file.lo 2059b042e37fSmrg case $libobj in 20608c4a8e55Smrg *.[cCFSifmso] | \ 20618c4a8e55Smrg *.ada | *.adb | *.ads | *.asm | \ 20628c4a8e55Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 20630597fb56Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 20648c4a8e55Smrg func_xform "$libobj" 20658c4a8e55Smrg libobj=$func_xform_result 20668c4a8e55Smrg ;; 2067b042e37fSmrg esac 2068b042e37fSmrg 2069b042e37fSmrg case $libobj in 20708c4a8e55Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 2071b042e37fSmrg *) 20728c4a8e55Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 2073b042e37fSmrg ;; 2074b042e37fSmrg esac 2075b042e37fSmrg 2076b042e37fSmrg func_infer_tag $base_compile 2077b042e37fSmrg 2078b042e37fSmrg for arg in $later; do 2079b042e37fSmrg case $arg in 20808c4a8e55Smrg -shared) 20818c4a8e55Smrg test "$build_libtool_libs" != yes && \ 20828c4a8e55Smrg func_fatal_configuration "can not build a shared library" 20838c4a8e55Smrg build_old_libs=no 20848c4a8e55Smrg continue 20858c4a8e55Smrg ;; 20868c4a8e55Smrg 2087b042e37fSmrg -static) 20888c4a8e55Smrg build_libtool_libs=no 2089b042e37fSmrg build_old_libs=yes 2090b042e37fSmrg continue 2091b042e37fSmrg ;; 2092b042e37fSmrg 2093b042e37fSmrg -prefer-pic) 2094b042e37fSmrg pic_mode=yes 2095b042e37fSmrg continue 2096b042e37fSmrg ;; 2097b042e37fSmrg 2098b042e37fSmrg -prefer-non-pic) 2099b042e37fSmrg pic_mode=no 2100b042e37fSmrg continue 2101b042e37fSmrg ;; 2102b042e37fSmrg esac 2103b042e37fSmrg done 2104b042e37fSmrg 21058c4a8e55Smrg func_quote_for_eval "$libobj" 21068c4a8e55Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 21078c4a8e55Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 21088c4a8e55Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 21098c4a8e55Smrg func_dirname_and_basename "$obj" "/" "" 21108c4a8e55Smrg objname="$func_basename_result" 21118c4a8e55Smrg xdir="$func_dirname_result" 2112b042e37fSmrg lobj=${xdir}$objdir/$objname 2113b042e37fSmrg 21148c4a8e55Smrg test -z "$base_compile" && \ 21158c4a8e55Smrg func_fatal_help "you must specify a compilation command" 2116b042e37fSmrg 2117b042e37fSmrg # Delete any leftover library objects. 2118b042e37fSmrg if test "$build_old_libs" = yes; then 2119b042e37fSmrg removelist="$obj $lobj $libobj ${libobj}T" 2120b042e37fSmrg else 2121b042e37fSmrg removelist="$lobj $libobj ${libobj}T" 2122b042e37fSmrg fi 2123b042e37fSmrg 2124b042e37fSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 2125b042e37fSmrg case $host_os in 21268c4a8e55Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 2127b042e37fSmrg pic_mode=default 2128b042e37fSmrg ;; 2129b042e37fSmrg esac 2130b042e37fSmrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 2131b042e37fSmrg # non-PIC code in shared libraries is not supported 2132b042e37fSmrg pic_mode=default 2133b042e37fSmrg fi 2134b042e37fSmrg 2135b042e37fSmrg # Calculate the filename of the output object if compiler does 2136b042e37fSmrg # not support -o with -c 2137b042e37fSmrg if test "$compiler_c_o" = no; then 2138706b6b52Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 2139b042e37fSmrg lockfile="$output_obj.lock" 2140b042e37fSmrg else 2141b042e37fSmrg output_obj= 2142b042e37fSmrg need_locks=no 2143b042e37fSmrg lockfile= 2144b042e37fSmrg fi 2145b042e37fSmrg 2146b042e37fSmrg # Lock this critical section if it is needed 2147b042e37fSmrg # We use this script file to make the link, it avoids creating a new file 2148b042e37fSmrg if test "$need_locks" = yes; then 21498c4a8e55Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 21508c4a8e55Smrg func_echo "Waiting for $lockfile to be removed" 2151b042e37fSmrg sleep 2 2152b042e37fSmrg done 2153b042e37fSmrg elif test "$need_locks" = warn; then 2154b042e37fSmrg if test -f "$lockfile"; then 21558c4a8e55Smrg $ECHO "\ 2156b042e37fSmrg*** ERROR, $lockfile exists and contains: 2157b042e37fSmrg`cat $lockfile 2>/dev/null` 2158b042e37fSmrg 2159b042e37fSmrgThis indicates that another process is trying to use the same 2160b042e37fSmrgtemporary object file, and libtool could not work around it because 2161b042e37fSmrgyour compiler does not support \`-c' and \`-o' together. If you 2162b042e37fSmrgrepeat this compilation, it may succeed, by chance, but you had better 2163b042e37fSmrgavoid parallel builds (make -j) in this platform, or get a better 2164b042e37fSmrgcompiler." 2165b042e37fSmrg 21668c4a8e55Smrg $opt_dry_run || $RM $removelist 2167b042e37fSmrg exit $EXIT_FAILURE 2168b042e37fSmrg fi 2169bd23fbfaSmrg func_append removelist " $output_obj" 21708c4a8e55Smrg $ECHO "$srcfile" > "$lockfile" 2171b042e37fSmrg fi 2172b042e37fSmrg 21738c4a8e55Smrg $opt_dry_run || $RM $removelist 2174bd23fbfaSmrg func_append removelist " $lockfile" 21758c4a8e55Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 21768c4a8e55Smrg 2177bd23fbfaSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 2178bd23fbfaSmrg srcfile=$func_to_tool_file_result 21798c4a8e55Smrg func_quote_for_eval "$srcfile" 21808c4a8e55Smrg qsrcfile=$func_quote_for_eval_result 2181b042e37fSmrg 2182b042e37fSmrg # Only build a PIC object if we are building libtool libraries. 2183b042e37fSmrg if test "$build_libtool_libs" = yes; then 2184b042e37fSmrg # Without this assignment, base_compile gets emptied. 2185b042e37fSmrg fbsd_hideous_sh_bug=$base_compile 2186b042e37fSmrg 2187b042e37fSmrg if test "$pic_mode" != no; then 2188b042e37fSmrg command="$base_compile $qsrcfile $pic_flag" 2189b042e37fSmrg else 2190b042e37fSmrg # Don't build PIC code 2191b042e37fSmrg command="$base_compile $qsrcfile" 2192b042e37fSmrg fi 2193b042e37fSmrg 21948c4a8e55Smrg func_mkdir_p "$xdir$objdir" 2195b042e37fSmrg 2196b042e37fSmrg if test -z "$output_obj"; then 2197b042e37fSmrg # Place PIC objects in $objdir 2198bd23fbfaSmrg func_append command " -o $lobj" 2199b042e37fSmrg fi 2200b042e37fSmrg 22018c4a8e55Smrg func_show_eval_locale "$command" \ 22028c4a8e55Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 2203b042e37fSmrg 2204b042e37fSmrg if test "$need_locks" = warn && 2205b042e37fSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 22068c4a8e55Smrg $ECHO "\ 2207b042e37fSmrg*** ERROR, $lockfile contains: 2208b042e37fSmrg`cat $lockfile 2>/dev/null` 2209b042e37fSmrg 2210b042e37fSmrgbut it should contain: 2211b042e37fSmrg$srcfile 2212b042e37fSmrg 2213b042e37fSmrgThis indicates that another process is trying to use the same 2214b042e37fSmrgtemporary object file, and libtool could not work around it because 2215b042e37fSmrgyour compiler does not support \`-c' and \`-o' together. If you 2216b042e37fSmrgrepeat this compilation, it may succeed, by chance, but you had better 2217b042e37fSmrgavoid parallel builds (make -j) in this platform, or get a better 2218b042e37fSmrgcompiler." 2219b042e37fSmrg 22208c4a8e55Smrg $opt_dry_run || $RM $removelist 2221b042e37fSmrg exit $EXIT_FAILURE 2222b042e37fSmrg fi 2223b042e37fSmrg 2224b042e37fSmrg # Just move the object if needed, then go on to compile the next one 2225b042e37fSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 22268c4a8e55Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 22278c4a8e55Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2228b042e37fSmrg fi 2229b042e37fSmrg 2230b042e37fSmrg # Allow error messages only from the first compilation. 2231b042e37fSmrg if test "$suppress_opt" = yes; then 22328c4a8e55Smrg suppress_output=' >/dev/null 2>&1' 2233b042e37fSmrg fi 2234b042e37fSmrg fi 2235b042e37fSmrg 2236b042e37fSmrg # Only build a position-dependent object if we build old libraries. 2237b042e37fSmrg if test "$build_old_libs" = yes; then 2238b042e37fSmrg if test "$pic_mode" != yes; then 2239b042e37fSmrg # Don't build PIC code 22408c4a8e55Smrg command="$base_compile $qsrcfile$pie_flag" 2241b042e37fSmrg else 2242b042e37fSmrg command="$base_compile $qsrcfile $pic_flag" 2243b042e37fSmrg fi 2244b042e37fSmrg if test "$compiler_c_o" = yes; then 2245bd23fbfaSmrg func_append command " -o $obj" 2246b042e37fSmrg fi 2247b042e37fSmrg 2248b042e37fSmrg # Suppress compiler output if we already did a PIC compilation. 2249bd23fbfaSmrg func_append command "$suppress_output" 22508c4a8e55Smrg func_show_eval_locale "$command" \ 22518c4a8e55Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 2252b042e37fSmrg 2253b042e37fSmrg if test "$need_locks" = warn && 2254b042e37fSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 22558c4a8e55Smrg $ECHO "\ 2256b042e37fSmrg*** ERROR, $lockfile contains: 2257b042e37fSmrg`cat $lockfile 2>/dev/null` 2258b042e37fSmrg 2259b042e37fSmrgbut it should contain: 2260b042e37fSmrg$srcfile 2261b042e37fSmrg 2262b042e37fSmrgThis indicates that another process is trying to use the same 2263b042e37fSmrgtemporary object file, and libtool could not work around it because 2264b042e37fSmrgyour compiler does not support \`-c' and \`-o' together. If you 2265b042e37fSmrgrepeat this compilation, it may succeed, by chance, but you had better 2266b042e37fSmrgavoid parallel builds (make -j) in this platform, or get a better 2267b042e37fSmrgcompiler." 2268b042e37fSmrg 22698c4a8e55Smrg $opt_dry_run || $RM $removelist 2270b042e37fSmrg exit $EXIT_FAILURE 2271b042e37fSmrg fi 2272b042e37fSmrg 2273b042e37fSmrg # Just move the object if needed 2274b042e37fSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 22758c4a8e55Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 22768c4a8e55Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2277b042e37fSmrg fi 22788c4a8e55Smrg fi 2279b042e37fSmrg 22808c4a8e55Smrg $opt_dry_run || { 22818c4a8e55Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 2282b042e37fSmrg 22838c4a8e55Smrg # Unlock the critical section if it was locked 22848c4a8e55Smrg if test "$need_locks" != no; then 22858c4a8e55Smrg removelist=$lockfile 22868c4a8e55Smrg $RM "$lockfile" 22878c4a8e55Smrg fi 22888c4a8e55Smrg } 2289b042e37fSmrg 22908c4a8e55Smrg exit $EXIT_SUCCESS 22918c4a8e55Smrg} 2292b042e37fSmrg 22938c4a8e55Smrg$opt_help || { 2294bd23fbfaSmrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 22958c4a8e55Smrg} 2296b042e37fSmrg 22978c4a8e55Smrgfunc_mode_help () 22988c4a8e55Smrg{ 22998c4a8e55Smrg # We need to display help for each of the modes. 2300bd23fbfaSmrg case $opt_mode in 23018c4a8e55Smrg "") 23028c4a8e55Smrg # Generic help is extracted from the usage comments 23038c4a8e55Smrg # at the start of this file. 23048c4a8e55Smrg func_help 23058c4a8e55Smrg ;; 2306b042e37fSmrg 23078c4a8e55Smrg clean) 23088c4a8e55Smrg $ECHO \ 23098c4a8e55Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 2310b042e37fSmrg 23118c4a8e55SmrgRemove files from the build directory. 2312b042e37fSmrg 23138c4a8e55SmrgRM is the name of the program to use to delete files associated with each FILE 23148c4a8e55Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 23158c4a8e55Smrgto RM. 2316b042e37fSmrg 23178c4a8e55SmrgIf FILE is a libtool library, object or program, all the files associated 23188c4a8e55Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 23198c4a8e55Smrg ;; 2320b042e37fSmrg 23218c4a8e55Smrg compile) 23228c4a8e55Smrg $ECHO \ 23238c4a8e55Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 2324b042e37fSmrg 23258c4a8e55SmrgCompile a source file into a libtool library object. 2326b042e37fSmrg 23278c4a8e55SmrgThis mode accepts the following additional options: 2328b042e37fSmrg 23298c4a8e55Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 23308c4a8e55Smrg -no-suppress do not suppress compiler output for multiple passes 2331706b6b52Smrg -prefer-pic try to build PIC objects only 2332706b6b52Smrg -prefer-non-pic try to build non-PIC objects only 23338c4a8e55Smrg -shared do not build a \`.o' file suitable for static linking 23348c4a8e55Smrg -static only build a \`.o' file suitable for static linking 2335706b6b52Smrg -Wc,FLAG pass FLAG directly to the compiler 2336b042e37fSmrg 23378c4a8e55SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 23388c4a8e55Smrgfrom the given SOURCEFILE. 2339b042e37fSmrg 23408c4a8e55SmrgThe output file name is determined by removing the directory component from 23418c4a8e55SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 23428c4a8e55Smrglibrary object suffix, \`.lo'." 23438c4a8e55Smrg ;; 2344b042e37fSmrg 23458c4a8e55Smrg execute) 23468c4a8e55Smrg $ECHO \ 23478c4a8e55Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 2348b042e37fSmrg 23498c4a8e55SmrgAutomatically set library path, then run a program. 2350b042e37fSmrg 23518c4a8e55SmrgThis mode accepts the following additional options: 2352b042e37fSmrg 23538c4a8e55Smrg -dlopen FILE add the directory containing FILE to the library path 2354b042e37fSmrg 23558c4a8e55SmrgThis mode sets the library path environment variable according to \`-dlopen' 23568c4a8e55Smrgflags. 2357b042e37fSmrg 23588c4a8e55SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 23598c4a8e55Smrginto their corresponding uninstalled binary, and any of their required library 23608c4a8e55Smrgdirectories are added to the library path. 2361b042e37fSmrg 23628c4a8e55SmrgThen, COMMAND is executed, with ARGS as arguments." 23638c4a8e55Smrg ;; 2364b042e37fSmrg 23658c4a8e55Smrg finish) 23668c4a8e55Smrg $ECHO \ 23678c4a8e55Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 2368b042e37fSmrg 23698c4a8e55SmrgComplete the installation of libtool libraries. 2370b042e37fSmrg 23718c4a8e55SmrgEach LIBDIR is a directory that contains libtool libraries. 2372b042e37fSmrg 23738c4a8e55SmrgThe commands that this mode executes may require superuser privileges. Use 23748c4a8e55Smrgthe \`--dry-run' option if you just want to see what would be executed." 23758c4a8e55Smrg ;; 2376b042e37fSmrg 23778c4a8e55Smrg install) 23788c4a8e55Smrg $ECHO \ 23798c4a8e55Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 2380b042e37fSmrg 23818c4a8e55SmrgInstall executables or libraries. 2382b042e37fSmrg 23838c4a8e55SmrgINSTALL-COMMAND is the installation command. The first component should be 23848c4a8e55Smrgeither the \`install' or \`cp' program. 2385b042e37fSmrg 23868c4a8e55SmrgThe following components of INSTALL-COMMAND are treated specially: 2387b042e37fSmrg 2388706b6b52Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 2389b042e37fSmrg 23908c4a8e55SmrgThe rest of the components are interpreted as arguments to that command (only 23918c4a8e55SmrgBSD-compatible install options are recognized)." 23928c4a8e55Smrg ;; 2393b042e37fSmrg 23948c4a8e55Smrg link) 23958c4a8e55Smrg $ECHO \ 23968c4a8e55Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 2397b042e37fSmrg 23988c4a8e55SmrgLink object files or libraries together to form another library, or to 23998c4a8e55Smrgcreate an executable program. 2400b042e37fSmrg 24018c4a8e55SmrgLINK-COMMAND is a command using the C compiler that you would use to create 24028c4a8e55Smrga program from several object files. 2403b042e37fSmrg 24048c4a8e55SmrgThe following components of LINK-COMMAND are treated specially: 2405b042e37fSmrg 24068c4a8e55Smrg -all-static do not do any dynamic linking at all 24078c4a8e55Smrg -avoid-version do not add a version suffix if possible 2408706b6b52Smrg -bindir BINDIR specify path to binaries directory (for systems where 2409706b6b52Smrg libraries must be found in the PATH setting at runtime) 24108c4a8e55Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 24118c4a8e55Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 24128c4a8e55Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 24138c4a8e55Smrg -export-symbols SYMFILE 24148c4a8e55Smrg try to export only the symbols listed in SYMFILE 24158c4a8e55Smrg -export-symbols-regex REGEX 24168c4a8e55Smrg try to export only the symbols matching REGEX 24178c4a8e55Smrg -LLIBDIR search LIBDIR for required installed libraries 24188c4a8e55Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 24198c4a8e55Smrg -module build a library that can dlopened 24208c4a8e55Smrg -no-fast-install disable the fast-install mode 24218c4a8e55Smrg -no-install link a not-installable executable 24228c4a8e55Smrg -no-undefined declare that a library does not refer to external symbols 24238c4a8e55Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 24248c4a8e55Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 24258c4a8e55Smrg -precious-files-regex REGEX 24268c4a8e55Smrg don't remove output files matching REGEX 24278c4a8e55Smrg -release RELEASE specify package release information 24288c4a8e55Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 24298c4a8e55Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 24308c4a8e55Smrg -shared only do dynamic linking of libtool libraries 24318c4a8e55Smrg -shrext SUFFIX override the standard shared library file extension 24328c4a8e55Smrg -static do not do any dynamic linking of uninstalled libtool libraries 24338c4a8e55Smrg -static-libtool-libs 24348c4a8e55Smrg do not do any dynamic linking of libtool libraries 24358c4a8e55Smrg -version-info CURRENT[:REVISION[:AGE]] 24368c4a8e55Smrg specify library version info [each variable defaults to 0] 24378c4a8e55Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 2438706b6b52Smrg -Wc,FLAG 2439706b6b52Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 2440706b6b52Smrg -Wl,FLAG 2441706b6b52Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 2442706b6b52Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 2443b042e37fSmrg 24448c4a8e55SmrgAll other options (arguments beginning with \`-') are ignored. 2445b042e37fSmrg 24468c4a8e55SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 24478c4a8e55Smrgtreated as uninstalled libtool libraries, other files are standard or library 24488c4a8e55Smrgobject files. 2449b042e37fSmrg 24508c4a8e55SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 24518c4a8e55Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 24528c4a8e55Smrgrequired, except when creating a convenience library. 2453b042e37fSmrg 24548c4a8e55SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 24558c4a8e55Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 2456b042e37fSmrg 24578c4a8e55SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 24588c4a8e55Smrgis created, otherwise an executable program is created." 24598c4a8e55Smrg ;; 2460b042e37fSmrg 24618c4a8e55Smrg uninstall) 24628c4a8e55Smrg $ECHO \ 24638c4a8e55Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 2464b042e37fSmrg 24658c4a8e55SmrgRemove libraries from an installation directory. 2466b042e37fSmrg 24678c4a8e55SmrgRM is the name of the program to use to delete files associated with each FILE 24688c4a8e55Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 24698c4a8e55Smrgto RM. 2470b042e37fSmrg 24718c4a8e55SmrgIf FILE is a libtool library, all the files associated with it are deleted. 24728c4a8e55SmrgOtherwise, only FILE itself is deleted using RM." 2473b042e37fSmrg ;; 2474b042e37fSmrg 24758c4a8e55Smrg *) 2476bd23fbfaSmrg func_fatal_help "invalid operation mode \`$opt_mode'" 24778c4a8e55Smrg ;; 24788c4a8e55Smrg esac 2479b042e37fSmrg 2480706b6b52Smrg echo 24818c4a8e55Smrg $ECHO "Try \`$progname --help' for more information about other modes." 24828c4a8e55Smrg} 2483b042e37fSmrg 2484706b6b52Smrg# Now that we've collected a possible --mode arg, show help if necessary 2485706b6b52Smrgif $opt_help; then 2486706b6b52Smrg if test "$opt_help" = :; then 2487706b6b52Smrg func_mode_help 2488706b6b52Smrg else 2489706b6b52Smrg { 2490706b6b52Smrg func_help noexit 2491bd23fbfaSmrg for opt_mode in compile link execute install finish uninstall clean; do 2492706b6b52Smrg func_mode_help 2493706b6b52Smrg done 2494706b6b52Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 2495706b6b52Smrg { 2496706b6b52Smrg func_help noexit 2497bd23fbfaSmrg for opt_mode in compile link execute install finish uninstall clean; do 2498706b6b52Smrg echo 2499706b6b52Smrg func_mode_help 2500706b6b52Smrg done 2501706b6b52Smrg } | 2502706b6b52Smrg sed '1d 2503706b6b52Smrg /^When reporting/,/^Report/{ 2504706b6b52Smrg H 2505706b6b52Smrg d 2506706b6b52Smrg } 2507706b6b52Smrg $x 2508706b6b52Smrg /information about other modes/d 2509706b6b52Smrg /more detailed .*MODE/d 2510706b6b52Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 2511706b6b52Smrg fi 2512706b6b52Smrg exit $? 2513706b6b52Smrgfi 2514b042e37fSmrg 2515b042e37fSmrg 25168c4a8e55Smrg# func_mode_execute arg... 25178c4a8e55Smrgfunc_mode_execute () 25188c4a8e55Smrg{ 25198c4a8e55Smrg $opt_debug 25208c4a8e55Smrg # The first argument is the command name. 25218c4a8e55Smrg cmd="$nonopt" 25228c4a8e55Smrg test -z "$cmd" && \ 25238c4a8e55Smrg func_fatal_help "you must specify a COMMAND" 2524b042e37fSmrg 25258c4a8e55Smrg # Handle -dlopen flags immediately. 2526bd23fbfaSmrg for file in $opt_dlopen; do 25278c4a8e55Smrg test -f "$file" \ 25288c4a8e55Smrg || func_fatal_help "\`$file' is not a file" 2529b042e37fSmrg 25308c4a8e55Smrg dir= 25318c4a8e55Smrg case $file in 25328c4a8e55Smrg *.la) 2533bd23fbfaSmrg func_resolve_sysroot "$file" 2534bd23fbfaSmrg file=$func_resolve_sysroot_result 2535bd23fbfaSmrg 25368c4a8e55Smrg # Check to see that this really is a libtool archive. 25378c4a8e55Smrg func_lalib_unsafe_p "$file" \ 25388c4a8e55Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 2539b042e37fSmrg 25408c4a8e55Smrg # Read the libtool library. 25418c4a8e55Smrg dlname= 25428c4a8e55Smrg library_names= 25438c4a8e55Smrg func_source "$file" 2544b042e37fSmrg 25458c4a8e55Smrg # Skip this library if it cannot be dlopened. 25468c4a8e55Smrg if test -z "$dlname"; then 25478c4a8e55Smrg # Warn if it was a shared library. 25488c4a8e55Smrg test -n "$library_names" && \ 25498c4a8e55Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 25508c4a8e55Smrg continue 25518c4a8e55Smrg fi 2552b042e37fSmrg 25538c4a8e55Smrg func_dirname "$file" "" "." 25548c4a8e55Smrg dir="$func_dirname_result" 2555b042e37fSmrg 25568c4a8e55Smrg if test -f "$dir/$objdir/$dlname"; then 2557bd23fbfaSmrg func_append dir "/$objdir" 25588c4a8e55Smrg else 25598c4a8e55Smrg if test ! -f "$dir/$dlname"; then 25608c4a8e55Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 25618c4a8e55Smrg fi 25628c4a8e55Smrg fi 2563b042e37fSmrg ;; 2564b042e37fSmrg 25658c4a8e55Smrg *.lo) 25668c4a8e55Smrg # Just add the directory containing the .lo file. 25678c4a8e55Smrg func_dirname "$file" "" "." 25688c4a8e55Smrg dir="$func_dirname_result" 2569b042e37fSmrg ;; 2570b042e37fSmrg 25718c4a8e55Smrg *) 25728c4a8e55Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 2573b042e37fSmrg continue 2574b042e37fSmrg ;; 25758c4a8e55Smrg esac 2576b042e37fSmrg 25778c4a8e55Smrg # Get the absolute pathname. 25788c4a8e55Smrg absdir=`cd "$dir" && pwd` 25798c4a8e55Smrg test -n "$absdir" && dir="$absdir" 2580b042e37fSmrg 25818c4a8e55Smrg # Now add the directory to shlibpath_var. 25828c4a8e55Smrg if eval "test -z \"\$$shlibpath_var\""; then 25838c4a8e55Smrg eval "$shlibpath_var=\"\$dir\"" 25848c4a8e55Smrg else 25858c4a8e55Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 25868c4a8e55Smrg fi 25878c4a8e55Smrg done 2588b042e37fSmrg 25898c4a8e55Smrg # This variable tells wrapper scripts just to set shlibpath_var 25908c4a8e55Smrg # rather than running their programs. 25918c4a8e55Smrg libtool_execute_magic="$magic" 2592b042e37fSmrg 25938c4a8e55Smrg # Check if any of the arguments is a wrapper script. 25948c4a8e55Smrg args= 25958c4a8e55Smrg for file 25968c4a8e55Smrg do 25978c4a8e55Smrg case $file in 2598706b6b52Smrg -* | *.la | *.lo ) ;; 25998c4a8e55Smrg *) 26008c4a8e55Smrg # Do a test to see if this is really a libtool program. 26018c4a8e55Smrg if func_ltwrapper_script_p "$file"; then 26028c4a8e55Smrg func_source "$file" 26038c4a8e55Smrg # Transform arg to wrapped name. 26048c4a8e55Smrg file="$progdir/$program" 26058c4a8e55Smrg elif func_ltwrapper_executable_p "$file"; then 26068c4a8e55Smrg func_ltwrapper_scriptname "$file" 26078c4a8e55Smrg func_source "$func_ltwrapper_scriptname_result" 26088c4a8e55Smrg # Transform arg to wrapped name. 26098c4a8e55Smrg file="$progdir/$program" 26108c4a8e55Smrg fi 2611b042e37fSmrg ;; 26128c4a8e55Smrg esac 26138c4a8e55Smrg # Quote arguments (to preserve shell metacharacters). 2614bd23fbfaSmrg func_append_quoted args "$file" 26158c4a8e55Smrg done 2616b042e37fSmrg 26178c4a8e55Smrg if test "X$opt_dry_run" = Xfalse; then 26188c4a8e55Smrg if test -n "$shlibpath_var"; then 26198c4a8e55Smrg # Export the shlibpath_var. 26208c4a8e55Smrg eval "export $shlibpath_var" 26218c4a8e55Smrg fi 2622b042e37fSmrg 26238c4a8e55Smrg # Restore saved environment variables 26248c4a8e55Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 26258c4a8e55Smrg do 26268c4a8e55Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 26278c4a8e55Smrg $lt_var=\$save_$lt_var; export $lt_var 26288c4a8e55Smrg else 26298c4a8e55Smrg $lt_unset $lt_var 26308c4a8e55Smrg fi" 26318c4a8e55Smrg done 2632b042e37fSmrg 26338c4a8e55Smrg # Now prepare to actually exec the command. 26348c4a8e55Smrg exec_cmd="\$cmd$args" 26358c4a8e55Smrg else 26368c4a8e55Smrg # Display what would be done. 26378c4a8e55Smrg if test -n "$shlibpath_var"; then 26388c4a8e55Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 2639706b6b52Smrg echo "export $shlibpath_var" 26408c4a8e55Smrg fi 26418c4a8e55Smrg $ECHO "$cmd$args" 26428c4a8e55Smrg exit $EXIT_SUCCESS 26438c4a8e55Smrg fi 26448c4a8e55Smrg} 2645b042e37fSmrg 2646bd23fbfaSmrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 2647b042e37fSmrg 2648b042e37fSmrg 26498c4a8e55Smrg# func_mode_finish arg... 26508c4a8e55Smrgfunc_mode_finish () 26518c4a8e55Smrg{ 26528c4a8e55Smrg $opt_debug 2653bd23fbfaSmrg libs= 2654bd23fbfaSmrg libdirs= 26558c4a8e55Smrg admincmds= 2656b042e37fSmrg 2657bd23fbfaSmrg for opt in "$nonopt" ${1+"$@"} 2658bd23fbfaSmrg do 2659bd23fbfaSmrg if test -d "$opt"; then 2660bd23fbfaSmrg func_append libdirs " $opt" 2661bd23fbfaSmrg 2662bd23fbfaSmrg elif test -f "$opt"; then 2663bd23fbfaSmrg if func_lalib_unsafe_p "$opt"; then 2664bd23fbfaSmrg func_append libs " $opt" 2665bd23fbfaSmrg else 2666bd23fbfaSmrg func_warning "\`$opt' is not a valid libtool archive" 2667bd23fbfaSmrg fi 2668bd23fbfaSmrg 2669bd23fbfaSmrg else 2670bd23fbfaSmrg func_fatal_error "invalid argument \`$opt'" 2671bd23fbfaSmrg fi 2672bd23fbfaSmrg done 2673bd23fbfaSmrg 2674bd23fbfaSmrg if test -n "$libs"; then 2675bd23fbfaSmrg if test -n "$lt_sysroot"; then 2676bd23fbfaSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 2677bd23fbfaSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 2678bd23fbfaSmrg else 2679bd23fbfaSmrg sysroot_cmd= 2680bd23fbfaSmrg fi 2681bd23fbfaSmrg 2682bd23fbfaSmrg # Remove sysroot references 2683bd23fbfaSmrg if $opt_dry_run; then 2684bd23fbfaSmrg for lib in $libs; do 2685bd23fbfaSmrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 2686bd23fbfaSmrg done 2687bd23fbfaSmrg else 2688bd23fbfaSmrg tmpdir=`func_mktempdir` 2689bd23fbfaSmrg for lib in $libs; do 2690bd23fbfaSmrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 2691bd23fbfaSmrg > $tmpdir/tmp-la 2692bd23fbfaSmrg mv -f $tmpdir/tmp-la $lib 2693bd23fbfaSmrg done 2694bd23fbfaSmrg ${RM}r "$tmpdir" 2695bd23fbfaSmrg fi 2696bd23fbfaSmrg fi 2697b042e37fSmrg 2698bd23fbfaSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 26998c4a8e55Smrg for libdir in $libdirs; do 27008c4a8e55Smrg if test -n "$finish_cmds"; then 27018c4a8e55Smrg # Do each command in the finish commands. 27028c4a8e55Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 27038c4a8e55Smrg'"$cmd"'"' 27048c4a8e55Smrg fi 27058c4a8e55Smrg if test -n "$finish_eval"; then 27068c4a8e55Smrg # Do the single finish_eval. 27078c4a8e55Smrg eval cmds=\"$finish_eval\" 2708bd23fbfaSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 27098c4a8e55Smrg $cmds" 27108c4a8e55Smrg fi 27118c4a8e55Smrg done 27128c4a8e55Smrg fi 2713b042e37fSmrg 27148c4a8e55Smrg # Exit here if they wanted silent mode. 27158c4a8e55Smrg $opt_silent && exit $EXIT_SUCCESS 2716b042e37fSmrg 2717bd23fbfaSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2718bd23fbfaSmrg echo "----------------------------------------------------------------------" 2719bd23fbfaSmrg echo "Libraries have been installed in:" 2720bd23fbfaSmrg for libdir in $libdirs; do 2721bd23fbfaSmrg $ECHO " $libdir" 2722bd23fbfaSmrg done 2723bd23fbfaSmrg echo 2724bd23fbfaSmrg echo "If you ever happen to want to link against installed libraries" 2725bd23fbfaSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 2726bd23fbfaSmrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 2727bd23fbfaSmrg echo "flag during linking and do at least one of the following:" 2728bd23fbfaSmrg if test -n "$shlibpath_var"; then 2729bd23fbfaSmrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 2730bd23fbfaSmrg echo " during execution" 2731bd23fbfaSmrg fi 2732bd23fbfaSmrg if test -n "$runpath_var"; then 2733bd23fbfaSmrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 2734bd23fbfaSmrg echo " during linking" 2735bd23fbfaSmrg fi 2736bd23fbfaSmrg if test -n "$hardcode_libdir_flag_spec"; then 2737bd23fbfaSmrg libdir=LIBDIR 2738bd23fbfaSmrg eval flag=\"$hardcode_libdir_flag_spec\" 2739b042e37fSmrg 2740bd23fbfaSmrg $ECHO " - use the \`$flag' linker flag" 2741bd23fbfaSmrg fi 2742bd23fbfaSmrg if test -n "$admincmds"; then 2743bd23fbfaSmrg $ECHO " - have your system administrator run these commands:$admincmds" 2744bd23fbfaSmrg fi 2745bd23fbfaSmrg if test -f /etc/ld.so.conf; then 2746bd23fbfaSmrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 2747bd23fbfaSmrg fi 2748bd23fbfaSmrg echo 2749b042e37fSmrg 2750bd23fbfaSmrg echo "See any operating system documentation about shared libraries for" 2751bd23fbfaSmrg case $host in 2752bd23fbfaSmrg solaris2.[6789]|solaris2.1[0-9]) 2753bd23fbfaSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 2754bd23fbfaSmrg echo "pages." 2755bd23fbfaSmrg ;; 2756bd23fbfaSmrg *) 2757bd23fbfaSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 2758bd23fbfaSmrg ;; 2759bd23fbfaSmrg esac 2760bd23fbfaSmrg echo "----------------------------------------------------------------------" 2761bd23fbfaSmrg fi 27628c4a8e55Smrg exit $EXIT_SUCCESS 27638c4a8e55Smrg} 2764b042e37fSmrg 2765bd23fbfaSmrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 2766b042e37fSmrg 2767b042e37fSmrg 27688c4a8e55Smrg# func_mode_install arg... 27698c4a8e55Smrgfunc_mode_install () 27708c4a8e55Smrg{ 27718c4a8e55Smrg $opt_debug 27728c4a8e55Smrg # There may be an optional sh(1) argument at the beginning of 27738c4a8e55Smrg # install_prog (especially on Windows NT). 27748c4a8e55Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 27758c4a8e55Smrg # Allow the use of GNU shtool's install command. 2776706b6b52Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 27778c4a8e55Smrg # Aesthetically quote it. 27788c4a8e55Smrg func_quote_for_eval "$nonopt" 27798c4a8e55Smrg install_prog="$func_quote_for_eval_result " 27808c4a8e55Smrg arg=$1 27818c4a8e55Smrg shift 27828c4a8e55Smrg else 27838c4a8e55Smrg install_prog= 27848c4a8e55Smrg arg=$nonopt 27858c4a8e55Smrg fi 27868c4a8e55Smrg 27878c4a8e55Smrg # The real first argument should be the name of the installation program. 27888c4a8e55Smrg # Aesthetically quote it. 27898c4a8e55Smrg func_quote_for_eval "$arg" 2790bd23fbfaSmrg func_append install_prog "$func_quote_for_eval_result" 2791706b6b52Smrg install_shared_prog=$install_prog 2792706b6b52Smrg case " $install_prog " in 2793706b6b52Smrg *[\\\ /]cp\ *) install_cp=: ;; 2794706b6b52Smrg *) install_cp=false ;; 2795706b6b52Smrg esac 27968c4a8e55Smrg 27978c4a8e55Smrg # We need to accept at least all the BSD install flags. 27988c4a8e55Smrg dest= 27998c4a8e55Smrg files= 28008c4a8e55Smrg opts= 28018c4a8e55Smrg prev= 28028c4a8e55Smrg install_type= 28038c4a8e55Smrg isdir=no 28048c4a8e55Smrg stripme= 2805706b6b52Smrg no_mode=: 28068c4a8e55Smrg for arg 28078c4a8e55Smrg do 2808706b6b52Smrg arg2= 28098c4a8e55Smrg if test -n "$dest"; then 2810bd23fbfaSmrg func_append files " $dest" 28118c4a8e55Smrg dest=$arg 2812b042e37fSmrg continue 28138c4a8e55Smrg fi 2814b042e37fSmrg 28158c4a8e55Smrg case $arg in 28168c4a8e55Smrg -d) isdir=yes ;; 28178c4a8e55Smrg -f) 2818706b6b52Smrg if $install_cp; then :; else 2819706b6b52Smrg prev=$arg 2820706b6b52Smrg fi 2821b042e37fSmrg ;; 28228c4a8e55Smrg -g | -m | -o) 28238c4a8e55Smrg prev=$arg 28248c4a8e55Smrg ;; 28258c4a8e55Smrg -s) 28268c4a8e55Smrg stripme=" -s" 28278c4a8e55Smrg continue 28288c4a8e55Smrg ;; 28298c4a8e55Smrg -*) 28308c4a8e55Smrg ;; 28318c4a8e55Smrg *) 28328c4a8e55Smrg # If the previous option needed an argument, then skip it. 28338c4a8e55Smrg if test -n "$prev"; then 2834706b6b52Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 2835706b6b52Smrg arg2=$install_override_mode 2836706b6b52Smrg no_mode=false 2837706b6b52Smrg fi 28388c4a8e55Smrg prev= 28398c4a8e55Smrg else 28408c4a8e55Smrg dest=$arg 28418c4a8e55Smrg continue 28428c4a8e55Smrg fi 28438c4a8e55Smrg ;; 28448c4a8e55Smrg esac 2845b042e37fSmrg 28468c4a8e55Smrg # Aesthetically quote the argument. 28478c4a8e55Smrg func_quote_for_eval "$arg" 2848bd23fbfaSmrg func_append install_prog " $func_quote_for_eval_result" 2849706b6b52Smrg if test -n "$arg2"; then 2850706b6b52Smrg func_quote_for_eval "$arg2" 2851706b6b52Smrg fi 2852bd23fbfaSmrg func_append install_shared_prog " $func_quote_for_eval_result" 28538c4a8e55Smrg done 2854b042e37fSmrg 28558c4a8e55Smrg test -z "$install_prog" && \ 28568c4a8e55Smrg func_fatal_help "you must specify an install program" 2857b042e37fSmrg 28588c4a8e55Smrg test -n "$prev" && \ 28598c4a8e55Smrg func_fatal_help "the \`$prev' option requires an argument" 28608c4a8e55Smrg 2861706b6b52Smrg if test -n "$install_override_mode" && $no_mode; then 2862706b6b52Smrg if $install_cp; then :; else 2863706b6b52Smrg func_quote_for_eval "$install_override_mode" 2864bd23fbfaSmrg func_append install_shared_prog " -m $func_quote_for_eval_result" 2865706b6b52Smrg fi 2866706b6b52Smrg fi 2867706b6b52Smrg 28688c4a8e55Smrg if test -z "$files"; then 28698c4a8e55Smrg if test -z "$dest"; then 28708c4a8e55Smrg func_fatal_help "no file or destination specified" 28718c4a8e55Smrg else 28728c4a8e55Smrg func_fatal_help "you must specify a destination" 28738c4a8e55Smrg fi 2874b042e37fSmrg fi 2875b042e37fSmrg 28768c4a8e55Smrg # Strip any trailing slash from the destination. 28778c4a8e55Smrg func_stripname '' '/' "$dest" 28788c4a8e55Smrg dest=$func_stripname_result 2879b042e37fSmrg 28808c4a8e55Smrg # Check to see that the destination is a directory. 28818c4a8e55Smrg test -d "$dest" && isdir=yes 28828c4a8e55Smrg if test "$isdir" = yes; then 28838c4a8e55Smrg destdir="$dest" 28848c4a8e55Smrg destname= 2885b042e37fSmrg else 28868c4a8e55Smrg func_dirname_and_basename "$dest" "" "." 28878c4a8e55Smrg destdir="$func_dirname_result" 28888c4a8e55Smrg destname="$func_basename_result" 2889b042e37fSmrg 28908c4a8e55Smrg # Not a directory, so check to see that there is only one file specified. 28918c4a8e55Smrg set dummy $files; shift 28928c4a8e55Smrg test "$#" -gt 1 && \ 28938c4a8e55Smrg func_fatal_help "\`$dest' is not a directory" 2894b042e37fSmrg fi 28958c4a8e55Smrg case $destdir in 28968c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 2897b042e37fSmrg *) 28988c4a8e55Smrg for file in $files; do 28998c4a8e55Smrg case $file in 29008c4a8e55Smrg *.lo) ;; 29018c4a8e55Smrg *) 29028c4a8e55Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 29038c4a8e55Smrg ;; 29048c4a8e55Smrg esac 29058c4a8e55Smrg done 2906b042e37fSmrg ;; 2907b042e37fSmrg esac 2908b042e37fSmrg 29098c4a8e55Smrg # This variable tells wrapper scripts just to set variables rather 29108c4a8e55Smrg # than running their programs. 29118c4a8e55Smrg libtool_install_magic="$magic" 2912b042e37fSmrg 29138c4a8e55Smrg staticlibs= 29148c4a8e55Smrg future_libdirs= 29158c4a8e55Smrg current_libdirs= 29168c4a8e55Smrg for file in $files; do 2917b042e37fSmrg 29188c4a8e55Smrg # Do each installation. 29198c4a8e55Smrg case $file in 29208c4a8e55Smrg *.$libext) 29218c4a8e55Smrg # Do the static libraries later. 2922bd23fbfaSmrg func_append staticlibs " $file" 29238c4a8e55Smrg ;; 29248c4a8e55Smrg 29258c4a8e55Smrg *.la) 2926bd23fbfaSmrg func_resolve_sysroot "$file" 2927bd23fbfaSmrg file=$func_resolve_sysroot_result 2928bd23fbfaSmrg 29298c4a8e55Smrg # Check to see that this really is a libtool archive. 29308c4a8e55Smrg func_lalib_unsafe_p "$file" \ 29318c4a8e55Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 29328c4a8e55Smrg 29338c4a8e55Smrg library_names= 29348c4a8e55Smrg old_library= 29358c4a8e55Smrg relink_command= 29368c4a8e55Smrg func_source "$file" 29378c4a8e55Smrg 29388c4a8e55Smrg # Add the libdir to current_libdirs if it is the destination. 29398c4a8e55Smrg if test "X$destdir" = "X$libdir"; then 29408c4a8e55Smrg case "$current_libdirs " in 29418c4a8e55Smrg *" $libdir "*) ;; 2942bd23fbfaSmrg *) func_append current_libdirs " $libdir" ;; 2943b042e37fSmrg esac 29448c4a8e55Smrg else 29458c4a8e55Smrg # Note the libdir as a future libdir. 29468c4a8e55Smrg case "$future_libdirs " in 29478c4a8e55Smrg *" $libdir "*) ;; 2948bd23fbfaSmrg *) func_append future_libdirs " $libdir" ;; 29498c4a8e55Smrg esac 29508c4a8e55Smrg fi 2951b042e37fSmrg 29528c4a8e55Smrg func_dirname "$file" "/" "" 29538c4a8e55Smrg dir="$func_dirname_result" 2954bd23fbfaSmrg func_append dir "$objdir" 29558c4a8e55Smrg 29568c4a8e55Smrg if test -n "$relink_command"; then 29578c4a8e55Smrg # Determine the prefix the user has applied to our future dir. 2958706b6b52Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 29598c4a8e55Smrg 29608c4a8e55Smrg # Don't allow the user to place us outside of our expected 29618c4a8e55Smrg # location b/c this prevents finding dependent libraries that 29628c4a8e55Smrg # are installed to the same prefix. 29638c4a8e55Smrg # At present, this check doesn't affect windows .dll's that 29648c4a8e55Smrg # are installed into $libdir/../bin (currently, that works fine) 29658c4a8e55Smrg # but it's something to keep an eye on. 29668c4a8e55Smrg test "$inst_prefix_dir" = "$destdir" && \ 29678c4a8e55Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 29688c4a8e55Smrg 29698c4a8e55Smrg if test -n "$inst_prefix_dir"; then 29708c4a8e55Smrg # Stick the inst_prefix_dir data into the link command. 2971706b6b52Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 29728c4a8e55Smrg else 2973706b6b52Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 29748c4a8e55Smrg fi 29758c4a8e55Smrg 29768c4a8e55Smrg func_warning "relinking \`$file'" 29778c4a8e55Smrg func_show_eval "$relink_command" \ 29788c4a8e55Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 29798c4a8e55Smrg fi 29808c4a8e55Smrg 29818c4a8e55Smrg # See the names of the shared library. 29828c4a8e55Smrg set dummy $library_names; shift 29838c4a8e55Smrg if test -n "$1"; then 29848c4a8e55Smrg realname="$1" 29858c4a8e55Smrg shift 29868c4a8e55Smrg 29878c4a8e55Smrg srcname="$realname" 29888c4a8e55Smrg test -n "$relink_command" && srcname="$realname"T 29898c4a8e55Smrg 29908c4a8e55Smrg # Install the shared library and build the symlinks. 2991706b6b52Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 29928c4a8e55Smrg 'exit $?' 29938c4a8e55Smrg tstripme="$stripme" 29948c4a8e55Smrg case $host_os in 29958c4a8e55Smrg cygwin* | mingw* | pw32* | cegcc*) 29968c4a8e55Smrg case $realname in 29978c4a8e55Smrg *.dll.a) 29988c4a8e55Smrg tstripme="" 29998c4a8e55Smrg ;; 30008c4a8e55Smrg esac 3001b042e37fSmrg ;; 3002b042e37fSmrg esac 30038c4a8e55Smrg if test -n "$tstripme" && test -n "$striplib"; then 30048c4a8e55Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 3005b042e37fSmrg fi 3006b042e37fSmrg 30078c4a8e55Smrg if test "$#" -gt 0; then 30088c4a8e55Smrg # Delete the old symlinks, and create new ones. 30098c4a8e55Smrg # Try `ln -sf' first, because the `ln' binary might depend on 30108c4a8e55Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 30118c4a8e55Smrg # so we also need to try rm && ln -s. 30128c4a8e55Smrg for linkname 30138c4a8e55Smrg do 30148c4a8e55Smrg test "$linkname" != "$realname" \ 30158c4a8e55Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 3016b042e37fSmrg done 3017b042e37fSmrg fi 3018b042e37fSmrg 30198c4a8e55Smrg # Do each command in the postinstall commands. 30208c4a8e55Smrg lib="$destdir/$realname" 30218c4a8e55Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 3022b042e37fSmrg fi 3023b042e37fSmrg 30248c4a8e55Smrg # Install the pseudo-library for information purposes. 30258c4a8e55Smrg func_basename "$file" 30268c4a8e55Smrg name="$func_basename_result" 30278c4a8e55Smrg instname="$dir/$name"i 30288c4a8e55Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 3029b042e37fSmrg 30308c4a8e55Smrg # Maybe install the static library, too. 3031bd23fbfaSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 30328c4a8e55Smrg ;; 3033b042e37fSmrg 30348c4a8e55Smrg *.lo) 30358c4a8e55Smrg # Install (i.e. copy) a libtool object. 3036b042e37fSmrg 30378c4a8e55Smrg # Figure out destination file name, if it wasn't already specified. 30388c4a8e55Smrg if test -n "$destname"; then 30398c4a8e55Smrg destfile="$destdir/$destname" 30408c4a8e55Smrg else 30418c4a8e55Smrg func_basename "$file" 30428c4a8e55Smrg destfile="$func_basename_result" 30438c4a8e55Smrg destfile="$destdir/$destfile" 3044b042e37fSmrg fi 3045b042e37fSmrg 30468c4a8e55Smrg # Deduce the name of the destination old-style object file. 30478c4a8e55Smrg case $destfile in 30488c4a8e55Smrg *.lo) 30498c4a8e55Smrg func_lo2o "$destfile" 30508c4a8e55Smrg staticdest=$func_lo2o_result 30518c4a8e55Smrg ;; 30528c4a8e55Smrg *.$objext) 30538c4a8e55Smrg staticdest="$destfile" 30548c4a8e55Smrg destfile= 30558c4a8e55Smrg ;; 30568c4a8e55Smrg *) 30578c4a8e55Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 30588c4a8e55Smrg ;; 30598c4a8e55Smrg esac 3060b042e37fSmrg 30618c4a8e55Smrg # Install the libtool object if requested. 30628c4a8e55Smrg test -n "$destfile" && \ 30638c4a8e55Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 3064b042e37fSmrg 30658c4a8e55Smrg # Install the old object if enabled. 30668c4a8e55Smrg if test "$build_old_libs" = yes; then 30678c4a8e55Smrg # Deduce the name of the old-style object file. 30688c4a8e55Smrg func_lo2o "$file" 30698c4a8e55Smrg staticobj=$func_lo2o_result 30708c4a8e55Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 3071b042e37fSmrg fi 30728c4a8e55Smrg exit $EXIT_SUCCESS 30738c4a8e55Smrg ;; 3074b042e37fSmrg 30758c4a8e55Smrg *) 30768c4a8e55Smrg # Figure out destination file name, if it wasn't already specified. 30778c4a8e55Smrg if test -n "$destname"; then 30788c4a8e55Smrg destfile="$destdir/$destname" 30798c4a8e55Smrg else 30808c4a8e55Smrg func_basename "$file" 30818c4a8e55Smrg destfile="$func_basename_result" 30828c4a8e55Smrg destfile="$destdir/$destfile" 30838c4a8e55Smrg fi 3084b042e37fSmrg 30858c4a8e55Smrg # If the file is missing, and there is a .exe on the end, strip it 30868c4a8e55Smrg # because it is most likely a libtool script we actually want to 30878c4a8e55Smrg # install 30888c4a8e55Smrg stripped_ext="" 30898c4a8e55Smrg case $file in 30908c4a8e55Smrg *.exe) 30918c4a8e55Smrg if test ! -f "$file"; then 30928c4a8e55Smrg func_stripname '' '.exe' "$file" 30938c4a8e55Smrg file=$func_stripname_result 30948c4a8e55Smrg stripped_ext=".exe" 30958c4a8e55Smrg fi 30968c4a8e55Smrg ;; 30978c4a8e55Smrg esac 30988c4a8e55Smrg 30998c4a8e55Smrg # Do a test to see if this is really a libtool program. 31008c4a8e55Smrg case $host in 31018c4a8e55Smrg *cygwin* | *mingw*) 31028c4a8e55Smrg if func_ltwrapper_executable_p "$file"; then 31038c4a8e55Smrg func_ltwrapper_scriptname "$file" 31048c4a8e55Smrg wrapper=$func_ltwrapper_scriptname_result 31058c4a8e55Smrg else 31068c4a8e55Smrg func_stripname '' '.exe' "$file" 31078c4a8e55Smrg wrapper=$func_stripname_result 31088c4a8e55Smrg fi 31098c4a8e55Smrg ;; 3110b042e37fSmrg *) 31118c4a8e55Smrg wrapper=$file 31128c4a8e55Smrg ;; 31138c4a8e55Smrg esac 31148c4a8e55Smrg if func_ltwrapper_script_p "$wrapper"; then 31158c4a8e55Smrg notinst_deplibs= 31168c4a8e55Smrg relink_command= 31178c4a8e55Smrg 31188c4a8e55Smrg func_source "$wrapper" 31198c4a8e55Smrg 31208c4a8e55Smrg # Check the variables that should have been set. 31218c4a8e55Smrg test -z "$generated_by_libtool_version" && \ 31228c4a8e55Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 31238c4a8e55Smrg 31248c4a8e55Smrg finalize=yes 31258c4a8e55Smrg for lib in $notinst_deplibs; do 31268c4a8e55Smrg # Check to see that each library is installed. 31278c4a8e55Smrg libdir= 31288c4a8e55Smrg if test -f "$lib"; then 31298c4a8e55Smrg func_source "$lib" 31308c4a8e55Smrg fi 3131706b6b52Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 31328c4a8e55Smrg if test -n "$libdir" && test ! -f "$libfile"; then 31338c4a8e55Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 31348c4a8e55Smrg finalize=no 31358c4a8e55Smrg fi 31368c4a8e55Smrg done 31378c4a8e55Smrg 31388c4a8e55Smrg relink_command= 31398c4a8e55Smrg func_source "$wrapper" 31408c4a8e55Smrg 31418c4a8e55Smrg outputname= 31428c4a8e55Smrg if test "$fast_install" = no && test -n "$relink_command"; then 31438c4a8e55Smrg $opt_dry_run || { 31448c4a8e55Smrg if test "$finalize" = yes; then 31458c4a8e55Smrg tmpdir=`func_mktempdir` 31468c4a8e55Smrg func_basename "$file$stripped_ext" 31478c4a8e55Smrg file="$func_basename_result" 31488c4a8e55Smrg outputname="$tmpdir/$file" 31498c4a8e55Smrg # Replace the output file specification. 3150706b6b52Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 31518c4a8e55Smrg 31528c4a8e55Smrg $opt_silent || { 31538c4a8e55Smrg func_quote_for_expand "$relink_command" 31548c4a8e55Smrg eval "func_echo $func_quote_for_expand_result" 31558c4a8e55Smrg } 31568c4a8e55Smrg if eval "$relink_command"; then : 31578c4a8e55Smrg else 31588c4a8e55Smrg func_error "error: relink \`$file' with the above command before installing it" 31598c4a8e55Smrg $opt_dry_run || ${RM}r "$tmpdir" 31608c4a8e55Smrg continue 31618c4a8e55Smrg fi 31628c4a8e55Smrg file="$outputname" 31638c4a8e55Smrg else 31648c4a8e55Smrg func_warning "cannot relink \`$file'" 31658c4a8e55Smrg fi 31668c4a8e55Smrg } 31678c4a8e55Smrg else 31688c4a8e55Smrg # Install the binary that we compiled earlier. 3169706b6b52Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 3170b042e37fSmrg fi 31718c4a8e55Smrg fi 31728c4a8e55Smrg 31738c4a8e55Smrg # remove .exe since cygwin /usr/bin/install will append another 31748c4a8e55Smrg # one anyway 31758c4a8e55Smrg case $install_prog,$host in 31768c4a8e55Smrg */usr/bin/install*,*cygwin*) 31778c4a8e55Smrg case $file:$destfile in 31788c4a8e55Smrg *.exe:*.exe) 31798c4a8e55Smrg # this is ok 31808c4a8e55Smrg ;; 31818c4a8e55Smrg *.exe:*) 31828c4a8e55Smrg destfile=$destfile.exe 31838c4a8e55Smrg ;; 31848c4a8e55Smrg *:*.exe) 31858c4a8e55Smrg func_stripname '' '.exe' "$destfile" 31868c4a8e55Smrg destfile=$func_stripname_result 31878c4a8e55Smrg ;; 31888c4a8e55Smrg esac 3189b042e37fSmrg ;; 3190b042e37fSmrg esac 31918c4a8e55Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 31928c4a8e55Smrg $opt_dry_run || if test -n "$outputname"; then 31938c4a8e55Smrg ${RM}r "$tmpdir" 31948c4a8e55Smrg fi 31958c4a8e55Smrg ;; 31968c4a8e55Smrg esac 31978c4a8e55Smrg done 3198b042e37fSmrg 31998c4a8e55Smrg for file in $staticlibs; do 32008c4a8e55Smrg func_basename "$file" 32018c4a8e55Smrg name="$func_basename_result" 32028c4a8e55Smrg 32038c4a8e55Smrg # Set up the ranlib parameters. 32048c4a8e55Smrg oldlib="$destdir/$name" 32050597fb56Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 32060597fb56Smrg tool_oldlib=$func_to_tool_file_result 32078c4a8e55Smrg 32088c4a8e55Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 32098c4a8e55Smrg 32108c4a8e55Smrg if test -n "$stripme" && test -n "$old_striplib"; then 32110597fb56Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 32128c4a8e55Smrg fi 32138c4a8e55Smrg 32148c4a8e55Smrg # Do each command in the postinstall commands. 32158c4a8e55Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 32168c4a8e55Smrg done 32178c4a8e55Smrg 32188c4a8e55Smrg test -n "$future_libdirs" && \ 32198c4a8e55Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 32208c4a8e55Smrg 32218c4a8e55Smrg if test -n "$current_libdirs"; then 32228c4a8e55Smrg # Maybe just do a dry run. 32238c4a8e55Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 32248c4a8e55Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 32258c4a8e55Smrg else 32268c4a8e55Smrg exit $EXIT_SUCCESS 32278c4a8e55Smrg fi 32288c4a8e55Smrg} 32298c4a8e55Smrg 3230bd23fbfaSmrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 32318c4a8e55Smrg 32328c4a8e55Smrg 32338c4a8e55Smrg# func_generate_dlsyms outputname originator pic_p 32348c4a8e55Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 32358c4a8e55Smrg# a dlpreopen symbol table. 32368c4a8e55Smrgfunc_generate_dlsyms () 32378c4a8e55Smrg{ 32388c4a8e55Smrg $opt_debug 32398c4a8e55Smrg my_outputname="$1" 32408c4a8e55Smrg my_originator="$2" 32418c4a8e55Smrg my_pic_p="${3-no}" 32428c4a8e55Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 32438c4a8e55Smrg my_dlsyms= 32448c4a8e55Smrg 32458c4a8e55Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 32468c4a8e55Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 32478c4a8e55Smrg my_dlsyms="${my_outputname}S.c" 32488c4a8e55Smrg else 32498c4a8e55Smrg func_error "not configured to extract global symbols from dlpreopened files" 32508c4a8e55Smrg fi 32518c4a8e55Smrg fi 32528c4a8e55Smrg 32538c4a8e55Smrg if test -n "$my_dlsyms"; then 32548c4a8e55Smrg case $my_dlsyms in 32558c4a8e55Smrg "") ;; 32568c4a8e55Smrg *.c) 32578c4a8e55Smrg # Discover the nlist of each of the dlfiles. 32588c4a8e55Smrg nlist="$output_objdir/${my_outputname}.nm" 32598c4a8e55Smrg 32608c4a8e55Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 32618c4a8e55Smrg 32628c4a8e55Smrg # Parse the name list into a source file. 32638c4a8e55Smrg func_verbose "creating $output_objdir/$my_dlsyms" 32648c4a8e55Smrg 32658c4a8e55Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 32668c4a8e55Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 32678c4a8e55Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 32688c4a8e55Smrg 32698c4a8e55Smrg#ifdef __cplusplus 32708c4a8e55Smrgextern \"C\" { 32718c4a8e55Smrg#endif 32728c4a8e55Smrg 3273706b6b52Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 3274706b6b52Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 3275706b6b52Smrg#endif 3276706b6b52Smrg 3277bd23fbfaSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 3278bd23fbfaSmrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 3279bd23fbfaSmrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 3280bd23fbfaSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 3281bd23fbfaSmrg# define LT_DLSYM_CONST 3282bd23fbfaSmrg#elif defined(__osf__) 3283bd23fbfaSmrg/* This system does not cope well with relocations in const data. */ 3284bd23fbfaSmrg# define LT_DLSYM_CONST 3285bd23fbfaSmrg#else 3286bd23fbfaSmrg# define LT_DLSYM_CONST const 3287bd23fbfaSmrg#endif 3288bd23fbfaSmrg 32898c4a8e55Smrg/* External symbol declarations for the compiler. */\ 32908c4a8e55Smrg" 32918c4a8e55Smrg 32928c4a8e55Smrg if test "$dlself" = yes; then 32938c4a8e55Smrg func_verbose "generating symbol list for \`$output'" 32948c4a8e55Smrg 32958c4a8e55Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 32968c4a8e55Smrg 32978c4a8e55Smrg # Add our own program objects to the symbol list. 3298706b6b52Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 32998c4a8e55Smrg for progfile in $progfiles; do 3300bd23fbfaSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 3301bd23fbfaSmrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 3302bd23fbfaSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 33038c4a8e55Smrg done 33048c4a8e55Smrg 33058c4a8e55Smrg if test -n "$exclude_expsyms"; then 33068c4a8e55Smrg $opt_dry_run || { 33078c4a8e55Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 33088c4a8e55Smrg eval '$MV "$nlist"T "$nlist"' 33098c4a8e55Smrg } 3310b042e37fSmrg fi 33118c4a8e55Smrg 33128c4a8e55Smrg if test -n "$export_symbols_regex"; then 33138c4a8e55Smrg $opt_dry_run || { 33148c4a8e55Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 33158c4a8e55Smrg eval '$MV "$nlist"T "$nlist"' 33168c4a8e55Smrg } 33178c4a8e55Smrg fi 33188c4a8e55Smrg 33198c4a8e55Smrg # Prepare the list of exported symbols 33208c4a8e55Smrg if test -z "$export_symbols"; then 33218c4a8e55Smrg export_symbols="$output_objdir/$outputname.exp" 33228c4a8e55Smrg $opt_dry_run || { 33238c4a8e55Smrg $RM $export_symbols 33248c4a8e55Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 33258c4a8e55Smrg case $host in 33268c4a8e55Smrg *cygwin* | *mingw* | *cegcc* ) 33278c4a8e55Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 33288c4a8e55Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 33298c4a8e55Smrg ;; 33308c4a8e55Smrg esac 33318c4a8e55Smrg } 3332b042e37fSmrg else 33338c4a8e55Smrg $opt_dry_run || { 33348c4a8e55Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 33358c4a8e55Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 33368c4a8e55Smrg eval '$MV "$nlist"T "$nlist"' 33378c4a8e55Smrg case $host in 3338706b6b52Smrg *cygwin* | *mingw* | *cegcc* ) 33398c4a8e55Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 33408c4a8e55Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 33418c4a8e55Smrg ;; 33428c4a8e55Smrg esac 33438c4a8e55Smrg } 3344b042e37fSmrg fi 33458c4a8e55Smrg fi 3346b042e37fSmrg 33478c4a8e55Smrg for dlprefile in $dlprefiles; do 33488c4a8e55Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 33498c4a8e55Smrg func_basename "$dlprefile" 33508c4a8e55Smrg name="$func_basename_result" 3351bd23fbfaSmrg case $host in 3352bd23fbfaSmrg *cygwin* | *mingw* | *cegcc* ) 3353bd23fbfaSmrg # if an import library, we need to obtain dlname 3354bd23fbfaSmrg if func_win32_import_lib_p "$dlprefile"; then 3355bd23fbfaSmrg func_tr_sh "$dlprefile" 3356bd23fbfaSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 3357bd23fbfaSmrg dlprefile_dlbasename="" 3358bd23fbfaSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 3359bd23fbfaSmrg # Use subshell, to avoid clobbering current variable values 3360bd23fbfaSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 3361bd23fbfaSmrg if test -n "$dlprefile_dlname" ; then 3362bd23fbfaSmrg func_basename "$dlprefile_dlname" 3363bd23fbfaSmrg dlprefile_dlbasename="$func_basename_result" 3364bd23fbfaSmrg else 3365bd23fbfaSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 3366bd23fbfaSmrg $sharedlib_from_linklib_cmd "$dlprefile" 3367bd23fbfaSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 3368bd23fbfaSmrg fi 3369bd23fbfaSmrg fi 3370bd23fbfaSmrg $opt_dry_run || { 3371bd23fbfaSmrg if test -n "$dlprefile_dlbasename" ; then 3372bd23fbfaSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 3373bd23fbfaSmrg else 3374bd23fbfaSmrg func_warning "Could not compute DLL name from $name" 3375bd23fbfaSmrg eval '$ECHO ": $name " >> "$nlist"' 3376bd23fbfaSmrg fi 3377bd23fbfaSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3378bd23fbfaSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 3379bd23fbfaSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 3380bd23fbfaSmrg } 3381bd23fbfaSmrg else # not an import lib 3382bd23fbfaSmrg $opt_dry_run || { 3383bd23fbfaSmrg eval '$ECHO ": $name " >> "$nlist"' 3384bd23fbfaSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3385bd23fbfaSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3386bd23fbfaSmrg } 3387bd23fbfaSmrg fi 3388bd23fbfaSmrg ;; 3389bd23fbfaSmrg *) 3390bd23fbfaSmrg $opt_dry_run || { 3391bd23fbfaSmrg eval '$ECHO ": $name " >> "$nlist"' 3392bd23fbfaSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3393bd23fbfaSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3394bd23fbfaSmrg } 3395bd23fbfaSmrg ;; 3396bd23fbfaSmrg esac 33978c4a8e55Smrg done 33988c4a8e55Smrg 33998c4a8e55Smrg $opt_dry_run || { 34008c4a8e55Smrg # Make sure we have at least an empty file. 34018c4a8e55Smrg test -f "$nlist" || : > "$nlist" 34028c4a8e55Smrg 34038c4a8e55Smrg if test -n "$exclude_expsyms"; then 34048c4a8e55Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 34058c4a8e55Smrg $MV "$nlist"T "$nlist" 3406b042e37fSmrg fi 34078c4a8e55Smrg 34088c4a8e55Smrg # Try sorting and uniquifying the output. 34098c4a8e55Smrg if $GREP -v "^: " < "$nlist" | 34108c4a8e55Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 34118c4a8e55Smrg sort -k 3 34128c4a8e55Smrg else 34138c4a8e55Smrg sort +2 34148c4a8e55Smrg fi | 34158c4a8e55Smrg uniq > "$nlist"S; then 34168c4a8e55Smrg : 3417b042e37fSmrg else 34188c4a8e55Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 3419b042e37fSmrg fi 3420b042e37fSmrg 34218c4a8e55Smrg if test -f "$nlist"S; then 34228c4a8e55Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 3423b042e37fSmrg else 3424706b6b52Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 3425b042e37fSmrg fi 3426b042e37fSmrg 3427706b6b52Smrg echo >> "$output_objdir/$my_dlsyms" "\ 3428b042e37fSmrg 34298c4a8e55Smrg/* The mapping between symbol names and symbols. */ 34308c4a8e55Smrgtypedef struct { 34318c4a8e55Smrg const char *name; 34328c4a8e55Smrg void *address; 34338c4a8e55Smrg} lt_dlsymlist; 3434bd23fbfaSmrgextern LT_DLSYM_CONST lt_dlsymlist 34358c4a8e55Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 3436bd23fbfaSmrgLT_DLSYM_CONST lt_dlsymlist 34378c4a8e55Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 34388c4a8e55Smrg{\ 34398c4a8e55Smrg { \"$my_originator\", (void *) 0 }," 3440b042e37fSmrg 34418c4a8e55Smrg case $need_lib_prefix in 34428c4a8e55Smrg no) 34438c4a8e55Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 34448c4a8e55Smrg ;; 34458c4a8e55Smrg *) 34468c4a8e55Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 34478c4a8e55Smrg ;; 34488c4a8e55Smrg esac 3449706b6b52Smrg echo >> "$output_objdir/$my_dlsyms" "\ 34508c4a8e55Smrg {0, (void *) 0} 34518c4a8e55Smrg}; 3452b042e37fSmrg 34538c4a8e55Smrg/* This works around a problem in FreeBSD linker */ 34548c4a8e55Smrg#ifdef FREEBSD_WORKAROUND 34558c4a8e55Smrgstatic const void *lt_preloaded_setup() { 34568c4a8e55Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 34578c4a8e55Smrg} 34588c4a8e55Smrg#endif 3459b042e37fSmrg 34608c4a8e55Smrg#ifdef __cplusplus 34618c4a8e55Smrg} 34628c4a8e55Smrg#endif\ 34638c4a8e55Smrg" 34648c4a8e55Smrg } # !$opt_dry_run 3465b042e37fSmrg 34668c4a8e55Smrg pic_flag_for_symtable= 34678c4a8e55Smrg case "$compile_command " in 34688c4a8e55Smrg *" -static "*) ;; 34698c4a8e55Smrg *) 34708c4a8e55Smrg case $host in 34718c4a8e55Smrg # compiling the symbol table file with pic_flag works around 34728c4a8e55Smrg # a FreeBSD bug that causes programs to crash when -lm is 34738c4a8e55Smrg # linked before any other PIC object. But we must not use 34748c4a8e55Smrg # pic_flag when linking with -static. The problem exists in 34758c4a8e55Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 34760597fb56Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 34778c4a8e55Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 34788c4a8e55Smrg *-*-hpux*) 34798c4a8e55Smrg pic_flag_for_symtable=" $pic_flag" ;; 34808c4a8e55Smrg *) 34818c4a8e55Smrg if test "X$my_pic_p" != Xno; then 34828c4a8e55Smrg pic_flag_for_symtable=" $pic_flag" 34838c4a8e55Smrg fi 34848c4a8e55Smrg ;; 34858c4a8e55Smrg esac 34868c4a8e55Smrg ;; 34878c4a8e55Smrg esac 34888c4a8e55Smrg symtab_cflags= 34898c4a8e55Smrg for arg in $LTCFLAGS; do 34908c4a8e55Smrg case $arg in 34918c4a8e55Smrg -pie | -fpie | -fPIE) ;; 3492bd23fbfaSmrg *) func_append symtab_cflags " $arg" ;; 34938c4a8e55Smrg esac 34948c4a8e55Smrg done 3495b042e37fSmrg 34968c4a8e55Smrg # Now compile the dynamic symbol file. 34978c4a8e55Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 3498b042e37fSmrg 34998c4a8e55Smrg # Clean up the generated files. 35008c4a8e55Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 35018c4a8e55Smrg 35028c4a8e55Smrg # Transform the symbol file into the correct name. 35038c4a8e55Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 35048c4a8e55Smrg case $host in 35058c4a8e55Smrg *cygwin* | *mingw* | *cegcc* ) 35068c4a8e55Smrg if test -f "$output_objdir/$my_outputname.def"; then 3507706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3508706b6b52Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 35098c4a8e55Smrg else 3510706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3511706b6b52Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3512b042e37fSmrg fi 35138c4a8e55Smrg ;; 35148c4a8e55Smrg *) 3515706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3516706b6b52Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 35178c4a8e55Smrg ;; 35188c4a8e55Smrg esac 35198c4a8e55Smrg ;; 35208c4a8e55Smrg *) 35218c4a8e55Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 35228c4a8e55Smrg ;; 35238c4a8e55Smrg esac 35248c4a8e55Smrg else 35258c4a8e55Smrg # We keep going just in case the user didn't refer to 35268c4a8e55Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 35278c4a8e55Smrg # really was required. 3528b042e37fSmrg 35298c4a8e55Smrg # Nullify the symbol file. 3530706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 3531706b6b52Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 35328c4a8e55Smrg fi 35338c4a8e55Smrg} 3534b042e37fSmrg 35358c4a8e55Smrg# func_win32_libid arg 35368c4a8e55Smrg# return the library type of file 'arg' 35378c4a8e55Smrg# 35388c4a8e55Smrg# Need a lot of goo to handle *both* DLLs and import libs 35398c4a8e55Smrg# Has to be a shell function in order to 'eat' the argument 35408c4a8e55Smrg# that is supplied when $file_magic_command is called. 3541706b6b52Smrg# Despite the name, also deal with 64 bit binaries. 35428c4a8e55Smrgfunc_win32_libid () 35438c4a8e55Smrg{ 35448c4a8e55Smrg $opt_debug 35458c4a8e55Smrg win32_libid_type="unknown" 35468c4a8e55Smrg win32_fileres=`file -L $1 2>/dev/null` 35478c4a8e55Smrg case $win32_fileres in 35488c4a8e55Smrg *ar\ archive\ import\ library*) # definitely import 35498c4a8e55Smrg win32_libid_type="x86 archive import" 35508c4a8e55Smrg ;; 35518c4a8e55Smrg *ar\ archive*) # could be an import, or static 3552706b6b52Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 35538c4a8e55Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 3554706b6b52Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 3555bd23fbfaSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3556bd23fbfaSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 35578c4a8e55Smrg $SED -n -e ' 35588c4a8e55Smrg 1,100{ 35598c4a8e55Smrg / I /{ 35608c4a8e55Smrg s,.*,import, 35618c4a8e55Smrg p 35628c4a8e55Smrg q 35638c4a8e55Smrg } 35648c4a8e55Smrg }'` 35658c4a8e55Smrg case $win32_nmres in 35668c4a8e55Smrg import*) win32_libid_type="x86 archive import";; 35678c4a8e55Smrg *) win32_libid_type="x86 archive static";; 35688c4a8e55Smrg esac 35698c4a8e55Smrg fi 35708c4a8e55Smrg ;; 35718c4a8e55Smrg *DLL*) 35728c4a8e55Smrg win32_libid_type="x86 DLL" 35738c4a8e55Smrg ;; 35748c4a8e55Smrg *executable*) # but shell scripts are "executable" too... 35758c4a8e55Smrg case $win32_fileres in 35768c4a8e55Smrg *MS\ Windows\ PE\ Intel*) 35778c4a8e55Smrg win32_libid_type="x86 DLL" 35788c4a8e55Smrg ;; 35798c4a8e55Smrg esac 35808c4a8e55Smrg ;; 35818c4a8e55Smrg esac 35828c4a8e55Smrg $ECHO "$win32_libid_type" 35838c4a8e55Smrg} 3584b042e37fSmrg 3585bd23fbfaSmrg# func_cygming_dll_for_implib ARG 3586bd23fbfaSmrg# 3587bd23fbfaSmrg# Platform-specific function to extract the 3588bd23fbfaSmrg# name of the DLL associated with the specified 3589bd23fbfaSmrg# import library ARG. 3590bd23fbfaSmrg# Invoked by eval'ing the libtool variable 3591bd23fbfaSmrg# $sharedlib_from_linklib_cmd 3592bd23fbfaSmrg# Result is available in the variable 3593bd23fbfaSmrg# $sharedlib_from_linklib_result 3594bd23fbfaSmrgfunc_cygming_dll_for_implib () 3595bd23fbfaSmrg{ 3596bd23fbfaSmrg $opt_debug 3597bd23fbfaSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 3598bd23fbfaSmrg} 3599bd23fbfaSmrg 3600bd23fbfaSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 3601bd23fbfaSmrg# 3602bd23fbfaSmrg# The is the core of a fallback implementation of a 3603bd23fbfaSmrg# platform-specific function to extract the name of the 3604bd23fbfaSmrg# DLL associated with the specified import library LIBNAME. 3605bd23fbfaSmrg# 3606bd23fbfaSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 3607bd23fbfaSmrg# on the platform and compiler that created the implib. 3608bd23fbfaSmrg# 3609bd23fbfaSmrg# Echos the name of the DLL associated with the 3610bd23fbfaSmrg# specified import library. 3611bd23fbfaSmrgfunc_cygming_dll_for_implib_fallback_core () 3612bd23fbfaSmrg{ 3613bd23fbfaSmrg $opt_debug 3614bd23fbfaSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 3615bd23fbfaSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 3616bd23fbfaSmrg $SED '/^Contents of section '"$match_literal"':/{ 3617bd23fbfaSmrg # Place marker at beginning of archive member dllname section 3618bd23fbfaSmrg s/.*/====MARK====/ 3619bd23fbfaSmrg p 3620bd23fbfaSmrg d 3621bd23fbfaSmrg } 3622bd23fbfaSmrg # These lines can sometimes be longer than 43 characters, but 3623bd23fbfaSmrg # are always uninteresting 3624bd23fbfaSmrg /:[ ]*file format pe[i]\{,1\}-/d 3625bd23fbfaSmrg /^In archive [^:]*:/d 3626bd23fbfaSmrg # Ensure marker is printed 3627bd23fbfaSmrg /^====MARK====/p 3628bd23fbfaSmrg # Remove all lines with less than 43 characters 3629bd23fbfaSmrg /^.\{43\}/!d 3630bd23fbfaSmrg # From remaining lines, remove first 43 characters 3631bd23fbfaSmrg s/^.\{43\}//' | 3632bd23fbfaSmrg $SED -n ' 3633bd23fbfaSmrg # Join marker and all lines until next marker into a single line 3634bd23fbfaSmrg /^====MARK====/ b para 3635bd23fbfaSmrg H 3636bd23fbfaSmrg $ b para 3637bd23fbfaSmrg b 3638bd23fbfaSmrg :para 3639bd23fbfaSmrg x 3640bd23fbfaSmrg s/\n//g 3641bd23fbfaSmrg # Remove the marker 3642bd23fbfaSmrg s/^====MARK====// 3643bd23fbfaSmrg # Remove trailing dots and whitespace 3644bd23fbfaSmrg s/[\. \t]*$// 3645bd23fbfaSmrg # Print 3646bd23fbfaSmrg /./p' | 3647bd23fbfaSmrg # we now have a list, one entry per line, of the stringified 3648bd23fbfaSmrg # contents of the appropriate section of all members of the 3649bd23fbfaSmrg # archive which possess that section. Heuristic: eliminate 3650bd23fbfaSmrg # all those which have a first or second character that is 3651bd23fbfaSmrg # a '.' (that is, objdump's representation of an unprintable 3652bd23fbfaSmrg # character.) This should work for all archives with less than 3653bd23fbfaSmrg # 0x302f exports -- but will fail for DLLs whose name actually 3654bd23fbfaSmrg # begins with a literal '.' or a single character followed by 3655bd23fbfaSmrg # a '.'. 3656bd23fbfaSmrg # 3657bd23fbfaSmrg # Of those that remain, print the first one. 3658bd23fbfaSmrg $SED -e '/^\./d;/^.\./d;q' 3659bd23fbfaSmrg} 3660bd23fbfaSmrg 3661bd23fbfaSmrg# func_cygming_gnu_implib_p ARG 3662bd23fbfaSmrg# This predicate returns with zero status (TRUE) if 3663bd23fbfaSmrg# ARG is a GNU/binutils-style import library. Returns 3664bd23fbfaSmrg# with nonzero status (FALSE) otherwise. 3665bd23fbfaSmrgfunc_cygming_gnu_implib_p () 3666bd23fbfaSmrg{ 3667bd23fbfaSmrg $opt_debug 3668bd23fbfaSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3669bd23fbfaSmrg 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)$'` 3670bd23fbfaSmrg test -n "$func_cygming_gnu_implib_tmp" 3671bd23fbfaSmrg} 3672bd23fbfaSmrg 3673bd23fbfaSmrg# func_cygming_ms_implib_p ARG 3674bd23fbfaSmrg# This predicate returns with zero status (TRUE) if 3675bd23fbfaSmrg# ARG is an MS-style import library. Returns 3676bd23fbfaSmrg# with nonzero status (FALSE) otherwise. 3677bd23fbfaSmrgfunc_cygming_ms_implib_p () 3678bd23fbfaSmrg{ 3679bd23fbfaSmrg $opt_debug 3680bd23fbfaSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3681bd23fbfaSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 3682bd23fbfaSmrg test -n "$func_cygming_ms_implib_tmp" 3683bd23fbfaSmrg} 3684bd23fbfaSmrg 3685bd23fbfaSmrg# func_cygming_dll_for_implib_fallback ARG 3686bd23fbfaSmrg# Platform-specific function to extract the 3687bd23fbfaSmrg# name of the DLL associated with the specified 3688bd23fbfaSmrg# import library ARG. 3689bd23fbfaSmrg# 3690bd23fbfaSmrg# This fallback implementation is for use when $DLLTOOL 3691bd23fbfaSmrg# does not support the --identify-strict option. 3692bd23fbfaSmrg# Invoked by eval'ing the libtool variable 3693bd23fbfaSmrg# $sharedlib_from_linklib_cmd 3694bd23fbfaSmrg# Result is available in the variable 3695bd23fbfaSmrg# $sharedlib_from_linklib_result 3696bd23fbfaSmrgfunc_cygming_dll_for_implib_fallback () 3697bd23fbfaSmrg{ 3698bd23fbfaSmrg $opt_debug 3699bd23fbfaSmrg if func_cygming_gnu_implib_p "$1" ; then 3700bd23fbfaSmrg # binutils import library 3701bd23fbfaSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 3702bd23fbfaSmrg elif func_cygming_ms_implib_p "$1" ; then 3703bd23fbfaSmrg # ms-generated import library 3704bd23fbfaSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 3705bd23fbfaSmrg else 3706bd23fbfaSmrg # unknown 3707bd23fbfaSmrg sharedlib_from_linklib_result="" 3708bd23fbfaSmrg fi 3709bd23fbfaSmrg} 3710b042e37fSmrg 3711b042e37fSmrg 37128c4a8e55Smrg# func_extract_an_archive dir oldlib 37138c4a8e55Smrgfunc_extract_an_archive () 37148c4a8e55Smrg{ 37158c4a8e55Smrg $opt_debug 37168c4a8e55Smrg f_ex_an_ar_dir="$1"; shift 37178c4a8e55Smrg f_ex_an_ar_oldlib="$1" 3718706b6b52Smrg if test "$lock_old_archive_extraction" = yes; then 3719706b6b52Smrg lockfile=$f_ex_an_ar_oldlib.lock 3720706b6b52Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3721706b6b52Smrg func_echo "Waiting for $lockfile to be removed" 3722706b6b52Smrg sleep 2 3723706b6b52Smrg done 3724706b6b52Smrg fi 3725706b6b52Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 3726706b6b52Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 3727706b6b52Smrg if test "$lock_old_archive_extraction" = yes; then 3728706b6b52Smrg $opt_dry_run || rm -f "$lockfile" 3729706b6b52Smrg fi 37308c4a8e55Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 37318c4a8e55Smrg : 37328c4a8e55Smrg else 37338c4a8e55Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 37348c4a8e55Smrg fi 37358c4a8e55Smrg} 3736b042e37fSmrg 3737b042e37fSmrg 37388c4a8e55Smrg# func_extract_archives gentop oldlib ... 37398c4a8e55Smrgfunc_extract_archives () 37408c4a8e55Smrg{ 37418c4a8e55Smrg $opt_debug 37428c4a8e55Smrg my_gentop="$1"; shift 37438c4a8e55Smrg my_oldlibs=${1+"$@"} 37448c4a8e55Smrg my_oldobjs="" 37458c4a8e55Smrg my_xlib="" 37468c4a8e55Smrg my_xabs="" 37478c4a8e55Smrg my_xdir="" 3748b042e37fSmrg 37498c4a8e55Smrg for my_xlib in $my_oldlibs; do 37508c4a8e55Smrg # Extract the objects. 37518c4a8e55Smrg case $my_xlib in 37528c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 37538c4a8e55Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 37548c4a8e55Smrg esac 37558c4a8e55Smrg func_basename "$my_xlib" 37568c4a8e55Smrg my_xlib="$func_basename_result" 37578c4a8e55Smrg my_xlib_u=$my_xlib 37588c4a8e55Smrg while :; do 37598c4a8e55Smrg case " $extracted_archives " in 37608c4a8e55Smrg *" $my_xlib_u "*) 37618c4a8e55Smrg func_arith $extracted_serial + 1 37628c4a8e55Smrg extracted_serial=$func_arith_result 37638c4a8e55Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 37648c4a8e55Smrg *) break ;; 37658c4a8e55Smrg esac 37668c4a8e55Smrg done 37678c4a8e55Smrg extracted_archives="$extracted_archives $my_xlib_u" 37688c4a8e55Smrg my_xdir="$my_gentop/$my_xlib_u" 3769b042e37fSmrg 37708c4a8e55Smrg func_mkdir_p "$my_xdir" 3771b042e37fSmrg 37728c4a8e55Smrg case $host in 37738c4a8e55Smrg *-darwin*) 37748c4a8e55Smrg func_verbose "Extracting $my_xabs" 37758c4a8e55Smrg # Do not bother doing anything if just a dry run 37768c4a8e55Smrg $opt_dry_run || { 37778c4a8e55Smrg darwin_orig_dir=`pwd` 37788c4a8e55Smrg cd $my_xdir || exit $? 37798c4a8e55Smrg darwin_archive=$my_xabs 37808c4a8e55Smrg darwin_curdir=`pwd` 37818c4a8e55Smrg darwin_base_archive=`basename "$darwin_archive"` 37828c4a8e55Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 37838c4a8e55Smrg if test -n "$darwin_arches"; then 37848c4a8e55Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 37858c4a8e55Smrg darwin_arch= 37868c4a8e55Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 37878c4a8e55Smrg for darwin_arch in $darwin_arches ; do 37888c4a8e55Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 37898c4a8e55Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 37908c4a8e55Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 37918c4a8e55Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 37928c4a8e55Smrg cd "$darwin_curdir" 37938c4a8e55Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 37948c4a8e55Smrg done # $darwin_arches 37958c4a8e55Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 37968c4a8e55Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 37978c4a8e55Smrg darwin_file= 37988c4a8e55Smrg darwin_files= 37998c4a8e55Smrg for darwin_file in $darwin_filelist; do 3800706b6b52Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 38018c4a8e55Smrg $LIPO -create -output "$darwin_file" $darwin_files 38028c4a8e55Smrg done # $darwin_filelist 38038c4a8e55Smrg $RM -rf unfat-$$ 38048c4a8e55Smrg cd "$darwin_orig_dir" 3805b042e37fSmrg else 38068c4a8e55Smrg cd $darwin_orig_dir 38078c4a8e55Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 38088c4a8e55Smrg fi # $darwin_arches 38098c4a8e55Smrg } # !$opt_dry_run 38108c4a8e55Smrg ;; 38118c4a8e55Smrg *) 38128c4a8e55Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 38138c4a8e55Smrg ;; 38148c4a8e55Smrg esac 3815706b6b52Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 38168c4a8e55Smrg done 3817b042e37fSmrg 38188c4a8e55Smrg func_extract_archives_result="$my_oldobjs" 38198c4a8e55Smrg} 3820b042e37fSmrg 3821b042e37fSmrg 3822706b6b52Smrg# func_emit_wrapper [arg=no] 3823706b6b52Smrg# 3824706b6b52Smrg# Emit a libtool wrapper script on stdout. 3825706b6b52Smrg# Don't directly open a file because we may want to 3826706b6b52Smrg# incorporate the script contents within a cygwin/mingw 3827706b6b52Smrg# wrapper executable. Must ONLY be called from within 3828706b6b52Smrg# func_mode_link because it depends on a number of variables 3829706b6b52Smrg# set therein. 38308c4a8e55Smrg# 3831706b6b52Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 3832706b6b52Smrg# variable will take. If 'yes', then the emitted script 3833706b6b52Smrg# will assume that the directory in which it is stored is 3834706b6b52Smrg# the $objdir directory. This is a cygwin/mingw-specific 3835706b6b52Smrg# behavior. 3836706b6b52Smrgfunc_emit_wrapper () 38378c4a8e55Smrg{ 3838706b6b52Smrg func_emit_wrapper_arg1=${1-no} 3839b042e37fSmrg 38408c4a8e55Smrg $ECHO "\ 38418c4a8e55Smrg#! $SHELL 3842b042e37fSmrg 38438c4a8e55Smrg# $output - temporary wrapper script for $objdir/$outputname 38448c4a8e55Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 38458c4a8e55Smrg# 38468c4a8e55Smrg# The $output program cannot be directly executed until all the libtool 38478c4a8e55Smrg# libraries that it depends on are installed. 38488c4a8e55Smrg# 38498c4a8e55Smrg# This wrapper script should never be moved out of the build directory. 38508c4a8e55Smrg# If it is, it will not operate correctly. 3851b042e37fSmrg 38528c4a8e55Smrg# Sed substitution that helps us do robust quoting. It backslashifies 38538c4a8e55Smrg# metacharacters that are still active within double-quoted strings. 38548c4a8e55Smrgsed_quote_subst='$sed_quote_subst' 3855b042e37fSmrg 38568c4a8e55Smrg# Be Bourne compatible 38578c4a8e55Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 38588c4a8e55Smrg emulate sh 38598c4a8e55Smrg NULLCMD=: 38608c4a8e55Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 38618c4a8e55Smrg # is contrary to our usage. Disable this feature. 38628c4a8e55Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 38638c4a8e55Smrg setopt NO_GLOB_SUBST 38648c4a8e55Smrgelse 38658c4a8e55Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 38668c4a8e55Smrgfi 38678c4a8e55SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 38688c4a8e55SmrgDUALCASE=1; export DUALCASE # for MKS sh 3869b042e37fSmrg 38708c4a8e55Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 38718c4a8e55Smrg# if CDPATH is set. 38728c4a8e55Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 3873b042e37fSmrg 38748c4a8e55Smrgrelink_command=\"$relink_command\" 3875b042e37fSmrg 38768c4a8e55Smrg# This environment variable determines our operation mode. 38778c4a8e55Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 38788c4a8e55Smrg # install mode needs the following variables: 38798c4a8e55Smrg generated_by_libtool_version='$macro_version' 38808c4a8e55Smrg notinst_deplibs='$notinst_deplibs' 38818c4a8e55Smrgelse 38828c4a8e55Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 38838c4a8e55Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 3884706b6b52Smrg file=\"\$0\"" 3885706b6b52Smrg 3886706b6b52Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 3887706b6b52Smrg $ECHO "\ 3888706b6b52Smrg 3889706b6b52Smrg# A function that is used when there is no print builtin or printf. 3890706b6b52Smrgfunc_fallback_echo () 3891706b6b52Smrg{ 3892706b6b52Smrg eval 'cat <<_LTECHO_EOF 3893706b6b52Smrg\$1 3894706b6b52Smrg_LTECHO_EOF' 3895706b6b52Smrg} 3896706b6b52Smrg ECHO=\"$qECHO\" 3897706b6b52Smrg fi 3898706b6b52Smrg 3899706b6b52Smrg# Very basic option parsing. These options are (a) specific to 3900706b6b52Smrg# the libtool wrapper, (b) are identical between the wrapper 3901706b6b52Smrg# /script/ and the wrapper /executable/ which is used only on 3902706b6b52Smrg# windows platforms, and (c) all begin with the string "--lt-" 3903706b6b52Smrg# (application programs are unlikely to have options which match 3904706b6b52Smrg# this pattern). 3905706b6b52Smrg# 3906706b6b52Smrg# There are only two supported options: --lt-debug and 3907706b6b52Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 3908706b6b52Smrg# 3909706b6b52Smrg# The first argument to this parsing function should be the 3910706b6b52Smrg# script's $0 value, followed by "$@". 3911706b6b52Smrglt_option_debug= 3912706b6b52Smrgfunc_parse_lt_options () 3913706b6b52Smrg{ 3914706b6b52Smrg lt_script_arg0=\$0 3915706b6b52Smrg shift 3916706b6b52Smrg for lt_opt 3917706b6b52Smrg do 3918706b6b52Smrg case \"\$lt_opt\" in 3919706b6b52Smrg --lt-debug) lt_option_debug=1 ;; 3920706b6b52Smrg --lt-dump-script) 3921706b6b52Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 3922706b6b52Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 3923706b6b52Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 3924706b6b52Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 3925706b6b52Smrg exit 0 3926706b6b52Smrg ;; 3927706b6b52Smrg --lt-*) 3928706b6b52Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 3929706b6b52Smrg exit 1 3930706b6b52Smrg ;; 3931706b6b52Smrg esac 3932706b6b52Smrg done 3933706b6b52Smrg 3934706b6b52Smrg # Print the debug banner immediately: 3935706b6b52Smrg if test -n \"\$lt_option_debug\"; then 3936706b6b52Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 3937706b6b52Smrg fi 3938706b6b52Smrg} 3939706b6b52Smrg 3940706b6b52Smrg# Used when --lt-debug. Prints its arguments to stdout 3941706b6b52Smrg# (redirection is the responsibility of the caller) 3942706b6b52Smrgfunc_lt_dump_args () 3943706b6b52Smrg{ 3944706b6b52Smrg lt_dump_args_N=1; 3945706b6b52Smrg for lt_arg 3946706b6b52Smrg do 3947706b6b52Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 3948706b6b52Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 3949706b6b52Smrg done 3950706b6b52Smrg} 3951706b6b52Smrg 3952706b6b52Smrg# Core function for launching the target application 3953706b6b52Smrgfunc_exec_program_core () 3954706b6b52Smrg{ 39558c4a8e55Smrg" 3956706b6b52Smrg case $host in 3957706b6b52Smrg # Backslashes separate directories on plain windows 3958706b6b52Smrg *-*-mingw | *-*-os2* | *-cegcc*) 3959706b6b52Smrg $ECHO "\ 3960706b6b52Smrg if test -n \"\$lt_option_debug\"; then 3961706b6b52Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 3962706b6b52Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 3963706b6b52Smrg fi 3964706b6b52Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 3965706b6b52Smrg" 3966706b6b52Smrg ;; 3967706b6b52Smrg 3968706b6b52Smrg *) 3969706b6b52Smrg $ECHO "\ 3970706b6b52Smrg if test -n \"\$lt_option_debug\"; then 3971706b6b52Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 3972706b6b52Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 3973706b6b52Smrg fi 3974706b6b52Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 3975706b6b52Smrg" 3976706b6b52Smrg ;; 3977706b6b52Smrg esac 3978706b6b52Smrg $ECHO "\ 3979706b6b52Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 3980706b6b52Smrg exit 1 3981706b6b52Smrg} 3982706b6b52Smrg 3983706b6b52Smrg# A function to encapsulate launching the target application 3984706b6b52Smrg# Strips options in the --lt-* namespace from \$@ and 3985706b6b52Smrg# launches target application with the remaining arguments. 3986706b6b52Smrgfunc_exec_program () 3987706b6b52Smrg{ 39880597fb56Smrg case \" \$* \" in 39890597fb56Smrg *\\ --lt-*) 39900597fb56Smrg for lt_wr_arg 39910597fb56Smrg do 39920597fb56Smrg case \$lt_wr_arg in 39930597fb56Smrg --lt-*) ;; 39940597fb56Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 39950597fb56Smrg esac 39960597fb56Smrg shift 39970597fb56Smrg done ;; 39980597fb56Smrg esac 3999706b6b52Smrg func_exec_program_core \${1+\"\$@\"} 4000706b6b52Smrg} 4001706b6b52Smrg 4002706b6b52Smrg # Parse options 4003706b6b52Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 4004b042e37fSmrg 40058c4a8e55Smrg # Find the directory that this script lives in. 4006706b6b52Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 40078c4a8e55Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 4008b042e37fSmrg 40098c4a8e55Smrg # Follow symbolic links until we get to the real thisdir. 4010706b6b52Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 40118c4a8e55Smrg while test -n \"\$file\"; do 4012706b6b52Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 40138c4a8e55Smrg 40148c4a8e55Smrg # If there was a directory component, then change thisdir. 40158c4a8e55Smrg if test \"x\$destdir\" != \"x\$file\"; then 40168c4a8e55Smrg case \"\$destdir\" in 40178c4a8e55Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 40188c4a8e55Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 4019b042e37fSmrg esac 40208c4a8e55Smrg fi 4021b042e37fSmrg 4022706b6b52Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 4023706b6b52Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 40248c4a8e55Smrg done 4025b042e37fSmrg 40268c4a8e55Smrg # Usually 'no', except on cygwin/mingw when embedded into 40278c4a8e55Smrg # the cwrapper. 4028706b6b52Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 40298c4a8e55Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 40308c4a8e55Smrg # special case for '.' 40318c4a8e55Smrg if test \"\$thisdir\" = \".\"; then 40328c4a8e55Smrg thisdir=\`pwd\` 40338c4a8e55Smrg fi 40348c4a8e55Smrg # remove .libs from thisdir 40358c4a8e55Smrg case \"\$thisdir\" in 4036706b6b52Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 40378c4a8e55Smrg $objdir ) thisdir=. ;; 40388c4a8e55Smrg esac 40398c4a8e55Smrg fi 40408c4a8e55Smrg 40418c4a8e55Smrg # Try to get the absolute directory name. 40428c4a8e55Smrg absdir=\`cd \"\$thisdir\" && pwd\` 40438c4a8e55Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 40448c4a8e55Smrg" 40458c4a8e55Smrg 40468c4a8e55Smrg if test "$fast_install" = yes; then 40478c4a8e55Smrg $ECHO "\ 40488c4a8e55Smrg program=lt-'$outputname'$exeext 40498c4a8e55Smrg progdir=\"\$thisdir/$objdir\" 40508c4a8e55Smrg 40518c4a8e55Smrg if test ! -f \"\$progdir/\$program\" || 40528c4a8e55Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 40538c4a8e55Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 40548c4a8e55Smrg 40558c4a8e55Smrg file=\"\$\$-\$program\" 40568c4a8e55Smrg 40578c4a8e55Smrg if test ! -d \"\$progdir\"; then 40588c4a8e55Smrg $MKDIR \"\$progdir\" 40598c4a8e55Smrg else 40608c4a8e55Smrg $RM \"\$progdir/\$file\" 40618c4a8e55Smrg fi" 40628c4a8e55Smrg 40638c4a8e55Smrg $ECHO "\ 40648c4a8e55Smrg 40658c4a8e55Smrg # relink executable if necessary 40668c4a8e55Smrg if test -n \"\$relink_command\"; then 40678c4a8e55Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 40688c4a8e55Smrg else 40698c4a8e55Smrg $ECHO \"\$relink_command_output\" >&2 40708c4a8e55Smrg $RM \"\$progdir/\$file\" 40718c4a8e55Smrg exit 1 4072b042e37fSmrg fi 40738c4a8e55Smrg fi 4074b042e37fSmrg 40758c4a8e55Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 40768c4a8e55Smrg { $RM \"\$progdir/\$program\"; 40778c4a8e55Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 40788c4a8e55Smrg $RM \"\$progdir/\$file\" 40798c4a8e55Smrg fi" 40808c4a8e55Smrg else 40818c4a8e55Smrg $ECHO "\ 40828c4a8e55Smrg program='$outputname' 40838c4a8e55Smrg progdir=\"\$thisdir/$objdir\" 40848c4a8e55Smrg" 4085b042e37fSmrg fi 4086b042e37fSmrg 40878c4a8e55Smrg $ECHO "\ 4088b042e37fSmrg 40898c4a8e55Smrg if test -f \"\$progdir/\$program\"; then" 4090b042e37fSmrg 4091bd23fbfaSmrg # fixup the dll searchpath if we need to. 4092bd23fbfaSmrg # 4093bd23fbfaSmrg # Fix the DLL searchpath if we need to. Do this before prepending 4094bd23fbfaSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 4095bd23fbfaSmrg # libraries must come first. 4096bd23fbfaSmrg if test -n "$dllsearchpath"; then 4097bd23fbfaSmrg $ECHO "\ 4098bd23fbfaSmrg # Add the dll search path components to the executable PATH 4099bd23fbfaSmrg PATH=$dllsearchpath:\$PATH 4100bd23fbfaSmrg" 4101bd23fbfaSmrg fi 4102bd23fbfaSmrg 41038c4a8e55Smrg # Export our shlibpath_var if we have one. 41048c4a8e55Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 41058c4a8e55Smrg $ECHO "\ 41068c4a8e55Smrg # Add our own library path to $shlibpath_var 41078c4a8e55Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 41088c4a8e55Smrg 41098c4a8e55Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 41108c4a8e55Smrg # The second colon is a workaround for a bug in BeOS R4 sed 4111706b6b52Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 4112b042e37fSmrg 41138c4a8e55Smrg export $shlibpath_var 41148c4a8e55Smrg" 4115b042e37fSmrg fi 4116b042e37fSmrg 41178c4a8e55Smrg $ECHO "\ 41188c4a8e55Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 41198c4a8e55Smrg # Run the actual program with our arguments. 4120706b6b52Smrg func_exec_program \${1+\"\$@\"} 41218c4a8e55Smrg fi 41228c4a8e55Smrg else 41238c4a8e55Smrg # The program doesn't exist. 41248c4a8e55Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 41258c4a8e55Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 4126706b6b52Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 41278c4a8e55Smrg exit 1 41288c4a8e55Smrg fi 41298c4a8e55Smrgfi\ 41308c4a8e55Smrg" 41318c4a8e55Smrg} 4132b042e37fSmrg 4133b042e37fSmrg 41348c4a8e55Smrg# func_emit_cwrapperexe_src 41358c4a8e55Smrg# emit the source code for a wrapper executable on stdout 41368c4a8e55Smrg# Must ONLY be called from within func_mode_link because 41378c4a8e55Smrg# it depends on a number of variable set therein. 41388c4a8e55Smrgfunc_emit_cwrapperexe_src () 41398c4a8e55Smrg{ 41408c4a8e55Smrg cat <<EOF 4141b042e37fSmrg 41428c4a8e55Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 41438c4a8e55Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4144b042e37fSmrg 41458c4a8e55Smrg The $output program cannot be directly executed until all the libtool 41468c4a8e55Smrg libraries that it depends on are installed. 4147b042e37fSmrg 41488c4a8e55Smrg This wrapper executable should never be moved out of the build directory. 41498c4a8e55Smrg If it is, it will not operate correctly. 41508c4a8e55Smrg*/ 41518c4a8e55SmrgEOF 41528c4a8e55Smrg cat <<"EOF" 4153706b6b52Smrg#ifdef _MSC_VER 4154706b6b52Smrg# define _CRT_SECURE_NO_DEPRECATE 1 4155706b6b52Smrg#endif 41568c4a8e55Smrg#include <stdio.h> 41578c4a8e55Smrg#include <stdlib.h> 41588c4a8e55Smrg#ifdef _MSC_VER 41598c4a8e55Smrg# include <direct.h> 41608c4a8e55Smrg# include <process.h> 41618c4a8e55Smrg# include <io.h> 41628c4a8e55Smrg#else 41638c4a8e55Smrg# include <unistd.h> 41648c4a8e55Smrg# include <stdint.h> 41658c4a8e55Smrg# ifdef __CYGWIN__ 41668c4a8e55Smrg# include <io.h> 41678c4a8e55Smrg# endif 41688c4a8e55Smrg#endif 41698c4a8e55Smrg#include <malloc.h> 41708c4a8e55Smrg#include <stdarg.h> 41718c4a8e55Smrg#include <assert.h> 41728c4a8e55Smrg#include <string.h> 41738c4a8e55Smrg#include <ctype.h> 41748c4a8e55Smrg#include <errno.h> 41758c4a8e55Smrg#include <fcntl.h> 41768c4a8e55Smrg#include <sys/stat.h> 4177b042e37fSmrg 4178706b6b52Smrg/* declarations of non-ANSI functions */ 4179706b6b52Smrg#if defined(__MINGW32__) 4180706b6b52Smrg# ifdef __STRICT_ANSI__ 4181706b6b52Smrgint _putenv (const char *); 4182706b6b52Smrg# endif 4183706b6b52Smrg#elif defined(__CYGWIN__) 4184706b6b52Smrg# ifdef __STRICT_ANSI__ 4185706b6b52Smrgchar *realpath (const char *, char *); 4186706b6b52Smrgint putenv (char *); 4187706b6b52Smrgint setenv (const char *, const char *, int); 4188706b6b52Smrg# endif 4189706b6b52Smrg/* #elif defined (other platforms) ... */ 4190706b6b52Smrg#endif 4191706b6b52Smrg 4192706b6b52Smrg/* portability defines, excluding path handling macros */ 4193706b6b52Smrg#if defined(_MSC_VER) 4194706b6b52Smrg# define setmode _setmode 4195706b6b52Smrg# define stat _stat 4196706b6b52Smrg# define chmod _chmod 4197706b6b52Smrg# define getcwd _getcwd 4198706b6b52Smrg# define putenv _putenv 4199706b6b52Smrg# define S_IXUSR _S_IEXEC 4200706b6b52Smrg# ifndef _INTPTR_T_DEFINED 4201706b6b52Smrg# define _INTPTR_T_DEFINED 4202706b6b52Smrg# define intptr_t int 4203706b6b52Smrg# endif 4204706b6b52Smrg#elif defined(__MINGW32__) 4205706b6b52Smrg# define setmode _setmode 4206706b6b52Smrg# define stat _stat 4207706b6b52Smrg# define chmod _chmod 4208706b6b52Smrg# define getcwd _getcwd 4209706b6b52Smrg# define putenv _putenv 4210706b6b52Smrg#elif defined(__CYGWIN__) 4211706b6b52Smrg# define HAVE_SETENV 4212706b6b52Smrg# define FOPEN_WB "wb" 4213706b6b52Smrg/* #elif defined (other platforms) ... */ 4214706b6b52Smrg#endif 4215706b6b52Smrg 42168c4a8e55Smrg#if defined(PATH_MAX) 42178c4a8e55Smrg# define LT_PATHMAX PATH_MAX 42188c4a8e55Smrg#elif defined(MAXPATHLEN) 42198c4a8e55Smrg# define LT_PATHMAX MAXPATHLEN 42208c4a8e55Smrg#else 42218c4a8e55Smrg# define LT_PATHMAX 1024 42228c4a8e55Smrg#endif 4223b042e37fSmrg 42248c4a8e55Smrg#ifndef S_IXOTH 42258c4a8e55Smrg# define S_IXOTH 0 42268c4a8e55Smrg#endif 42278c4a8e55Smrg#ifndef S_IXGRP 42288c4a8e55Smrg# define S_IXGRP 0 42298c4a8e55Smrg#endif 4230b042e37fSmrg 4231706b6b52Smrg/* path handling portability macros */ 42328c4a8e55Smrg#ifndef DIR_SEPARATOR 42338c4a8e55Smrg# define DIR_SEPARATOR '/' 42348c4a8e55Smrg# define PATH_SEPARATOR ':' 42358c4a8e55Smrg#endif 4236b042e37fSmrg 42378c4a8e55Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 42388c4a8e55Smrg defined (__OS2__) 42398c4a8e55Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 42408c4a8e55Smrg# define FOPEN_WB "wb" 42418c4a8e55Smrg# ifndef DIR_SEPARATOR_2 42428c4a8e55Smrg# define DIR_SEPARATOR_2 '\\' 42438c4a8e55Smrg# endif 42448c4a8e55Smrg# ifndef PATH_SEPARATOR_2 42458c4a8e55Smrg# define PATH_SEPARATOR_2 ';' 42468c4a8e55Smrg# endif 42478c4a8e55Smrg#endif 4248b042e37fSmrg 42498c4a8e55Smrg#ifndef DIR_SEPARATOR_2 42508c4a8e55Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 42518c4a8e55Smrg#else /* DIR_SEPARATOR_2 */ 42528c4a8e55Smrg# define IS_DIR_SEPARATOR(ch) \ 42538c4a8e55Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 42548c4a8e55Smrg#endif /* DIR_SEPARATOR_2 */ 4255b042e37fSmrg 42568c4a8e55Smrg#ifndef PATH_SEPARATOR_2 42578c4a8e55Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 42588c4a8e55Smrg#else /* PATH_SEPARATOR_2 */ 42598c4a8e55Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 42608c4a8e55Smrg#endif /* PATH_SEPARATOR_2 */ 4261b042e37fSmrg 42628c4a8e55Smrg#ifndef FOPEN_WB 42638c4a8e55Smrg# define FOPEN_WB "w" 42648c4a8e55Smrg#endif 42658c4a8e55Smrg#ifndef _O_BINARY 42668c4a8e55Smrg# define _O_BINARY 0 42678c4a8e55Smrg#endif 4268b042e37fSmrg 42698c4a8e55Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 42708c4a8e55Smrg#define XFREE(stale) do { \ 42718c4a8e55Smrg if (stale) { free ((void *) stale); stale = 0; } \ 42728c4a8e55Smrg} while (0) 4273b042e37fSmrg 4274706b6b52Smrg#if defined(LT_DEBUGWRAPPER) 4275706b6b52Smrgstatic int lt_debug = 1; 42768c4a8e55Smrg#else 4277706b6b52Smrgstatic int lt_debug = 0; 42788c4a8e55Smrg#endif 4279b042e37fSmrg 4280706b6b52Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 4281b042e37fSmrg 42828c4a8e55Smrgvoid *xmalloc (size_t num); 42838c4a8e55Smrgchar *xstrdup (const char *string); 42848c4a8e55Smrgconst char *base_name (const char *name); 42858c4a8e55Smrgchar *find_executable (const char *wrapper); 42868c4a8e55Smrgchar *chase_symlinks (const char *pathspec); 42878c4a8e55Smrgint make_executable (const char *path); 42888c4a8e55Smrgint check_executable (const char *path); 42898c4a8e55Smrgchar *strendzap (char *str, const char *pat); 4290706b6b52Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 4291706b6b52Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 4292706b6b52Smrgstatic const char *nonnull (const char *s); 4293706b6b52Smrgstatic const char *nonempty (const char *s); 42948c4a8e55Smrgvoid lt_setenv (const char *name, const char *value); 42958c4a8e55Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 42968c4a8e55Smrgvoid lt_update_exe_path (const char *name, const char *value); 42978c4a8e55Smrgvoid lt_update_lib_path (const char *name, const char *value); 4298706b6b52Smrgchar **prepare_spawn (char **argv); 4299706b6b52Smrgvoid lt_dump_script (FILE *f); 43008c4a8e55SmrgEOF 43018c4a8e55Smrg 43028c4a8e55Smrg cat <<EOF 4303bd23fbfaSmrgvolatile const char * MAGIC_EXE = "$magic_exe"; 43048c4a8e55Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 43058c4a8e55SmrgEOF 4306b042e37fSmrg 43078c4a8e55Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4308bd23fbfaSmrg func_to_host_path "$temp_rpath" 43098c4a8e55Smrg cat <<EOF 4310bd23fbfaSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 4311b042e37fSmrgEOF 4312b042e37fSmrg else 43138c4a8e55Smrg cat <<"EOF" 43148c4a8e55Smrgconst char * LIB_PATH_VALUE = ""; 43158c4a8e55SmrgEOF 4316b042e37fSmrg fi 43178c4a8e55Smrg 43188c4a8e55Smrg if test -n "$dllsearchpath"; then 4319bd23fbfaSmrg func_to_host_path "$dllsearchpath:" 43208c4a8e55Smrg cat <<EOF 43218c4a8e55Smrgconst char * EXE_PATH_VARNAME = "PATH"; 4322bd23fbfaSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 43238c4a8e55SmrgEOF 4324b042e37fSmrg else 43258c4a8e55Smrg cat <<"EOF" 43268c4a8e55Smrgconst char * EXE_PATH_VARNAME = ""; 43278c4a8e55Smrgconst char * EXE_PATH_VALUE = ""; 43288c4a8e55SmrgEOF 4329b042e37fSmrg fi 43308c4a8e55Smrg 43318c4a8e55Smrg if test "$fast_install" = yes; then 43328c4a8e55Smrg cat <<EOF 43338c4a8e55Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 43348c4a8e55SmrgEOF 4335b042e37fSmrg else 43368c4a8e55Smrg cat <<EOF 43378c4a8e55Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 43388c4a8e55SmrgEOF 4339b042e37fSmrg fi 4340b042e37fSmrg 4341b042e37fSmrg 43428c4a8e55Smrg cat <<"EOF" 4343b042e37fSmrg 43448c4a8e55Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 4345b042e37fSmrg 43468c4a8e55Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 43478c4a8e55Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 4348706b6b52Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 4349b042e37fSmrg 43508c4a8e55Smrgint 43518c4a8e55Smrgmain (int argc, char *argv[]) 43528c4a8e55Smrg{ 43538c4a8e55Smrg char **newargz; 43548c4a8e55Smrg int newargc; 43558c4a8e55Smrg char *tmp_pathspec; 43568c4a8e55Smrg char *actual_cwrapper_path; 43578c4a8e55Smrg char *actual_cwrapper_name; 43588c4a8e55Smrg char *target_name; 43598c4a8e55Smrg char *lt_argv_zero; 43608c4a8e55Smrg intptr_t rval = 127; 4361b042e37fSmrg 43628c4a8e55Smrg int i; 4363b042e37fSmrg 43648c4a8e55Smrg program_name = (char *) xstrdup (base_name (argv[0])); 4365706b6b52Smrg newargz = XMALLOC (char *, argc + 1); 4366b042e37fSmrg 4367706b6b52Smrg /* very simple arg parsing; don't want to rely on getopt 4368706b6b52Smrg * also, copy all non cwrapper options to newargz, except 4369706b6b52Smrg * argz[0], which is handled differently 4370706b6b52Smrg */ 4371706b6b52Smrg newargc=0; 43728c4a8e55Smrg for (i = 1; i < argc; i++) 43738c4a8e55Smrg { 43748c4a8e55Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 43758c4a8e55Smrg { 43768c4a8e55SmrgEOF 43778c4a8e55Smrg case "$host" in 43788c4a8e55Smrg *mingw* | *cygwin* ) 43798c4a8e55Smrg # make stdout use "unix" line endings 43808c4a8e55Smrg echo " setmode(1,_O_BINARY);" 43818c4a8e55Smrg ;; 43828c4a8e55Smrg esac 4383b042e37fSmrg 43848c4a8e55Smrg cat <<"EOF" 4385706b6b52Smrg lt_dump_script (stdout); 43868c4a8e55Smrg return 0; 43878c4a8e55Smrg } 4388706b6b52Smrg if (strcmp (argv[i], debug_opt) == 0) 4389706b6b52Smrg { 4390706b6b52Smrg lt_debug = 1; 4391706b6b52Smrg continue; 4392706b6b52Smrg } 4393706b6b52Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 4394706b6b52Smrg { 4395706b6b52Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 4396706b6b52Smrg namespace, but it is not one of the ones we know about and 4397706b6b52Smrg have already dealt with, above (inluding dump-script), then 4398706b6b52Smrg report an error. Otherwise, targets might begin to believe 4399706b6b52Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 4400706b6b52Smrg namespace. The first time any user complains about this, we'll 4401706b6b52Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 4402706b6b52Smrg or a configure.ac-settable value. 4403706b6b52Smrg */ 4404706b6b52Smrg lt_fatal (__FILE__, __LINE__, 4405706b6b52Smrg "unrecognized %s option: '%s'", 4406706b6b52Smrg ltwrapper_option_prefix, argv[i]); 4407706b6b52Smrg } 4408706b6b52Smrg /* otherwise ... */ 4409706b6b52Smrg newargz[++newargc] = xstrdup (argv[i]); 44108c4a8e55Smrg } 4411706b6b52Smrg newargz[++newargc] = NULL; 4412706b6b52Smrg 4413706b6b52SmrgEOF 4414706b6b52Smrg cat <<EOF 4415706b6b52Smrg /* The GNU banner must be the first non-error debug message */ 4416706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 4417706b6b52SmrgEOF 4418706b6b52Smrg cat <<"EOF" 4419706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 4420706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 4421b042e37fSmrg 44228c4a8e55Smrg tmp_pathspec = find_executable (argv[0]); 44238c4a8e55Smrg if (tmp_pathspec == NULL) 4424706b6b52Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 4425706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 4426706b6b52Smrg "(main) found exe (before symlink chase) at: %s\n", 4427706b6b52Smrg tmp_pathspec); 44288c4a8e55Smrg 44298c4a8e55Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 4430706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 4431706b6b52Smrg "(main) found exe (after symlink chase) at: %s\n", 4432706b6b52Smrg actual_cwrapper_path); 44338c4a8e55Smrg XFREE (tmp_pathspec); 44348c4a8e55Smrg 4435706b6b52Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 44368c4a8e55Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 44378c4a8e55Smrg 44388c4a8e55Smrg /* wrapper name transforms */ 44398c4a8e55Smrg strendzap (actual_cwrapper_name, ".exe"); 44408c4a8e55Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 44418c4a8e55Smrg XFREE (actual_cwrapper_name); 44428c4a8e55Smrg actual_cwrapper_name = tmp_pathspec; 44438c4a8e55Smrg tmp_pathspec = 0; 44448c4a8e55Smrg 44458c4a8e55Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 44468c4a8e55Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 44478c4a8e55Smrg strendzap (target_name, ".exe"); 44488c4a8e55Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 44498c4a8e55Smrg XFREE (target_name); 44508c4a8e55Smrg target_name = tmp_pathspec; 44518c4a8e55Smrg tmp_pathspec = 0; 44528c4a8e55Smrg 4453706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 4454706b6b52Smrg "(main) libtool target name: %s\n", 4455706b6b52Smrg target_name); 44568c4a8e55SmrgEOF 4457b042e37fSmrg 44588c4a8e55Smrg cat <<EOF 44598c4a8e55Smrg newargz[0] = 44608c4a8e55Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 44618c4a8e55Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 44628c4a8e55Smrg strcpy (newargz[0], actual_cwrapper_path); 44638c4a8e55Smrg strcat (newargz[0], "$objdir"); 44648c4a8e55Smrg strcat (newargz[0], "/"); 44658c4a8e55SmrgEOF 4466b042e37fSmrg 44678c4a8e55Smrg cat <<"EOF" 44688c4a8e55Smrg /* stop here, and copy so we don't have to do this twice */ 44698c4a8e55Smrg tmp_pathspec = xstrdup (newargz[0]); 4470b042e37fSmrg 44718c4a8e55Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 44728c4a8e55Smrg strcat (newargz[0], actual_cwrapper_name); 4473b042e37fSmrg 44748c4a8e55Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 44758c4a8e55Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 44768c4a8e55Smrg XFREE (tmp_pathspec); 44778c4a8e55Smrg tmp_pathspec = NULL; 44788c4a8e55SmrgEOF 4479b042e37fSmrg 44808c4a8e55Smrg case $host_os in 44818c4a8e55Smrg mingw*) 44828c4a8e55Smrg cat <<"EOF" 44838c4a8e55Smrg { 44848c4a8e55Smrg char* p; 44858c4a8e55Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 44868c4a8e55Smrg { 44878c4a8e55Smrg *p = '/'; 44888c4a8e55Smrg } 44898c4a8e55Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 44908c4a8e55Smrg { 44918c4a8e55Smrg *p = '/'; 44928c4a8e55Smrg } 44938c4a8e55Smrg } 44948c4a8e55SmrgEOF 44958c4a8e55Smrg ;; 44968c4a8e55Smrg esac 4497b042e37fSmrg 44988c4a8e55Smrg cat <<"EOF" 44998c4a8e55Smrg XFREE (target_name); 45008c4a8e55Smrg XFREE (actual_cwrapper_path); 45018c4a8e55Smrg XFREE (actual_cwrapper_name); 4502b042e37fSmrg 45038c4a8e55Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 45048c4a8e55Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 4505bd23fbfaSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 4506bd23fbfaSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 4507bd23fbfaSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 4508bd23fbfaSmrg libraries must come first. */ 45098c4a8e55Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 4510bd23fbfaSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 4511b042e37fSmrg 4512706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 4513706b6b52Smrg nonnull (lt_argv_zero)); 45148c4a8e55Smrg for (i = 0; i < newargc; i++) 45158c4a8e55Smrg { 4516706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 4517706b6b52Smrg i, nonnull (newargz[i])); 45188c4a8e55Smrg } 4519b042e37fSmrg 45208c4a8e55SmrgEOF 4521b042e37fSmrg 45228c4a8e55Smrg case $host_os in 45238c4a8e55Smrg mingw*) 45248c4a8e55Smrg cat <<"EOF" 45258c4a8e55Smrg /* execv doesn't actually work on mingw as expected on unix */ 4526706b6b52Smrg newargz = prepare_spawn (newargz); 45278c4a8e55Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 45288c4a8e55Smrg if (rval == -1) 45298c4a8e55Smrg { 45308c4a8e55Smrg /* failed to start process */ 4531706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 4532706b6b52Smrg "(main) failed to launch target \"%s\": %s\n", 4533706b6b52Smrg lt_argv_zero, nonnull (strerror (errno))); 45348c4a8e55Smrg return 127; 45358c4a8e55Smrg } 45368c4a8e55Smrg return rval; 45378c4a8e55SmrgEOF 45388c4a8e55Smrg ;; 45398c4a8e55Smrg *) 45408c4a8e55Smrg cat <<"EOF" 45418c4a8e55Smrg execv (lt_argv_zero, newargz); 45428c4a8e55Smrg return rval; /* =127, but avoids unused variable warning */ 45438c4a8e55SmrgEOF 45448c4a8e55Smrg ;; 45458c4a8e55Smrg esac 4546b042e37fSmrg 45478c4a8e55Smrg cat <<"EOF" 45488c4a8e55Smrg} 4549b042e37fSmrg 45508c4a8e55Smrgvoid * 45518c4a8e55Smrgxmalloc (size_t num) 45528c4a8e55Smrg{ 45538c4a8e55Smrg void *p = (void *) malloc (num); 45548c4a8e55Smrg if (!p) 4555706b6b52Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 4556b042e37fSmrg 45578c4a8e55Smrg return p; 45588c4a8e55Smrg} 4559b042e37fSmrg 45608c4a8e55Smrgchar * 45618c4a8e55Smrgxstrdup (const char *string) 45628c4a8e55Smrg{ 45638c4a8e55Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 45648c4a8e55Smrg string) : NULL; 45658c4a8e55Smrg} 4566b042e37fSmrg 45678c4a8e55Smrgconst char * 45688c4a8e55Smrgbase_name (const char *name) 45698c4a8e55Smrg{ 45708c4a8e55Smrg const char *base; 4571b042e37fSmrg 45728c4a8e55Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 45738c4a8e55Smrg /* Skip over the disk name in MSDOS pathnames. */ 45748c4a8e55Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 45758c4a8e55Smrg name += 2; 45768c4a8e55Smrg#endif 4577b042e37fSmrg 45788c4a8e55Smrg for (base = name; *name; name++) 45798c4a8e55Smrg if (IS_DIR_SEPARATOR (*name)) 45808c4a8e55Smrg base = name + 1; 45818c4a8e55Smrg return base; 45828c4a8e55Smrg} 4583b042e37fSmrg 45848c4a8e55Smrgint 45858c4a8e55Smrgcheck_executable (const char *path) 45868c4a8e55Smrg{ 45878c4a8e55Smrg struct stat st; 4588b042e37fSmrg 4589706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 4590706b6b52Smrg nonempty (path)); 45918c4a8e55Smrg if ((!path) || (!*path)) 45928c4a8e55Smrg return 0; 4593b042e37fSmrg 45948c4a8e55Smrg if ((stat (path, &st) >= 0) 45958c4a8e55Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 45968c4a8e55Smrg return 1; 45978c4a8e55Smrg else 45988c4a8e55Smrg return 0; 45998c4a8e55Smrg} 4600b042e37fSmrg 46018c4a8e55Smrgint 46028c4a8e55Smrgmake_executable (const char *path) 46038c4a8e55Smrg{ 46048c4a8e55Smrg int rval = 0; 46058c4a8e55Smrg struct stat st; 4606b042e37fSmrg 4607706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 4608706b6b52Smrg nonempty (path)); 46098c4a8e55Smrg if ((!path) || (!*path)) 46108c4a8e55Smrg return 0; 4611b042e37fSmrg 46128c4a8e55Smrg if (stat (path, &st) >= 0) 46138c4a8e55Smrg { 46148c4a8e55Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 46158c4a8e55Smrg } 46168c4a8e55Smrg return rval; 46178c4a8e55Smrg} 4618b042e37fSmrg 46198c4a8e55Smrg/* Searches for the full path of the wrapper. Returns 46208c4a8e55Smrg newly allocated full path name if found, NULL otherwise 46218c4a8e55Smrg Does not chase symlinks, even on platforms that support them. 46228c4a8e55Smrg*/ 46238c4a8e55Smrgchar * 46248c4a8e55Smrgfind_executable (const char *wrapper) 46258c4a8e55Smrg{ 46268c4a8e55Smrg int has_slash = 0; 46278c4a8e55Smrg const char *p; 46288c4a8e55Smrg const char *p_next; 46298c4a8e55Smrg /* static buffer for getcwd */ 46308c4a8e55Smrg char tmp[LT_PATHMAX + 1]; 46318c4a8e55Smrg int tmp_len; 46328c4a8e55Smrg char *concat_name; 4633b042e37fSmrg 4634706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 4635706b6b52Smrg nonempty (wrapper)); 4636b042e37fSmrg 46378c4a8e55Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 46388c4a8e55Smrg return NULL; 4639b042e37fSmrg 46408c4a8e55Smrg /* Absolute path? */ 46418c4a8e55Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 46428c4a8e55Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 46438c4a8e55Smrg { 46448c4a8e55Smrg concat_name = xstrdup (wrapper); 46458c4a8e55Smrg if (check_executable (concat_name)) 46468c4a8e55Smrg return concat_name; 46478c4a8e55Smrg XFREE (concat_name); 46488c4a8e55Smrg } 46498c4a8e55Smrg else 46508c4a8e55Smrg { 46518c4a8e55Smrg#endif 46528c4a8e55Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 46538c4a8e55Smrg { 46548c4a8e55Smrg concat_name = xstrdup (wrapper); 46558c4a8e55Smrg if (check_executable (concat_name)) 46568c4a8e55Smrg return concat_name; 46578c4a8e55Smrg XFREE (concat_name); 46588c4a8e55Smrg } 46598c4a8e55Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 46608c4a8e55Smrg } 46618c4a8e55Smrg#endif 4662b042e37fSmrg 46638c4a8e55Smrg for (p = wrapper; *p; p++) 46648c4a8e55Smrg if (*p == '/') 46658c4a8e55Smrg { 46668c4a8e55Smrg has_slash = 1; 46678c4a8e55Smrg break; 46688c4a8e55Smrg } 46698c4a8e55Smrg if (!has_slash) 46708c4a8e55Smrg { 46718c4a8e55Smrg /* no slashes; search PATH */ 46728c4a8e55Smrg const char *path = getenv ("PATH"); 46738c4a8e55Smrg if (path != NULL) 46748c4a8e55Smrg { 46758c4a8e55Smrg for (p = path; *p; p = p_next) 46768c4a8e55Smrg { 46778c4a8e55Smrg const char *q; 46788c4a8e55Smrg size_t p_len; 46798c4a8e55Smrg for (q = p; *q; q++) 46808c4a8e55Smrg if (IS_PATH_SEPARATOR (*q)) 46818c4a8e55Smrg break; 46828c4a8e55Smrg p_len = q - p; 46838c4a8e55Smrg p_next = (*q == '\0' ? q : q + 1); 46848c4a8e55Smrg if (p_len == 0) 46858c4a8e55Smrg { 46868c4a8e55Smrg /* empty path: current directory */ 46878c4a8e55Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 4688706b6b52Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4689706b6b52Smrg nonnull (strerror (errno))); 46908c4a8e55Smrg tmp_len = strlen (tmp); 46918c4a8e55Smrg concat_name = 46928c4a8e55Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 46938c4a8e55Smrg memcpy (concat_name, tmp, tmp_len); 46948c4a8e55Smrg concat_name[tmp_len] = '/'; 46958c4a8e55Smrg strcpy (concat_name + tmp_len + 1, wrapper); 46968c4a8e55Smrg } 46978c4a8e55Smrg else 46988c4a8e55Smrg { 46998c4a8e55Smrg concat_name = 47008c4a8e55Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 47018c4a8e55Smrg memcpy (concat_name, p, p_len); 47028c4a8e55Smrg concat_name[p_len] = '/'; 47038c4a8e55Smrg strcpy (concat_name + p_len + 1, wrapper); 47048c4a8e55Smrg } 47058c4a8e55Smrg if (check_executable (concat_name)) 47068c4a8e55Smrg return concat_name; 47078c4a8e55Smrg XFREE (concat_name); 47088c4a8e55Smrg } 47098c4a8e55Smrg } 47108c4a8e55Smrg /* not found in PATH; assume curdir */ 47118c4a8e55Smrg } 47128c4a8e55Smrg /* Relative path | not found in path: prepend cwd */ 47138c4a8e55Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 4714706b6b52Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4715706b6b52Smrg nonnull (strerror (errno))); 47168c4a8e55Smrg tmp_len = strlen (tmp); 47178c4a8e55Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 47188c4a8e55Smrg memcpy (concat_name, tmp, tmp_len); 47198c4a8e55Smrg concat_name[tmp_len] = '/'; 47208c4a8e55Smrg strcpy (concat_name + tmp_len + 1, wrapper); 4721b042e37fSmrg 47228c4a8e55Smrg if (check_executable (concat_name)) 47238c4a8e55Smrg return concat_name; 47248c4a8e55Smrg XFREE (concat_name); 47258c4a8e55Smrg return NULL; 47268c4a8e55Smrg} 4727b042e37fSmrg 47288c4a8e55Smrgchar * 47298c4a8e55Smrgchase_symlinks (const char *pathspec) 47308c4a8e55Smrg{ 47318c4a8e55Smrg#ifndef S_ISLNK 47328c4a8e55Smrg return xstrdup (pathspec); 47338c4a8e55Smrg#else 47348c4a8e55Smrg char buf[LT_PATHMAX]; 47358c4a8e55Smrg struct stat s; 47368c4a8e55Smrg char *tmp_pathspec = xstrdup (pathspec); 47378c4a8e55Smrg char *p; 47388c4a8e55Smrg int has_symlinks = 0; 47398c4a8e55Smrg while (strlen (tmp_pathspec) && !has_symlinks) 47408c4a8e55Smrg { 4741706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 4742706b6b52Smrg "checking path component for symlinks: %s\n", 4743706b6b52Smrg tmp_pathspec); 47448c4a8e55Smrg if (lstat (tmp_pathspec, &s) == 0) 47458c4a8e55Smrg { 47468c4a8e55Smrg if (S_ISLNK (s.st_mode) != 0) 47478c4a8e55Smrg { 47488c4a8e55Smrg has_symlinks = 1; 47498c4a8e55Smrg break; 47508c4a8e55Smrg } 4751b042e37fSmrg 47528c4a8e55Smrg /* search backwards for last DIR_SEPARATOR */ 47538c4a8e55Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 47548c4a8e55Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 47558c4a8e55Smrg p--; 47568c4a8e55Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 47578c4a8e55Smrg { 47588c4a8e55Smrg /* no more DIR_SEPARATORS left */ 47598c4a8e55Smrg break; 47608c4a8e55Smrg } 47618c4a8e55Smrg *p = '\0'; 47628c4a8e55Smrg } 47638c4a8e55Smrg else 47648c4a8e55Smrg { 4765706b6b52Smrg lt_fatal (__FILE__, __LINE__, 4766706b6b52Smrg "error accessing file \"%s\": %s", 4767706b6b52Smrg tmp_pathspec, nonnull (strerror (errno))); 47688c4a8e55Smrg } 47698c4a8e55Smrg } 47708c4a8e55Smrg XFREE (tmp_pathspec); 4771b042e37fSmrg 47728c4a8e55Smrg if (!has_symlinks) 47738c4a8e55Smrg { 47748c4a8e55Smrg return xstrdup (pathspec); 47758c4a8e55Smrg } 4776b042e37fSmrg 47778c4a8e55Smrg tmp_pathspec = realpath (pathspec, buf); 47788c4a8e55Smrg if (tmp_pathspec == 0) 47798c4a8e55Smrg { 4780706b6b52Smrg lt_fatal (__FILE__, __LINE__, 4781706b6b52Smrg "could not follow symlinks for %s", pathspec); 47828c4a8e55Smrg } 47838c4a8e55Smrg return xstrdup (tmp_pathspec); 47848c4a8e55Smrg#endif 47858c4a8e55Smrg} 4786b042e37fSmrg 47878c4a8e55Smrgchar * 47888c4a8e55Smrgstrendzap (char *str, const char *pat) 47898c4a8e55Smrg{ 47908c4a8e55Smrg size_t len, patlen; 4791b042e37fSmrg 47928c4a8e55Smrg assert (str != NULL); 47938c4a8e55Smrg assert (pat != NULL); 4794b042e37fSmrg 47958c4a8e55Smrg len = strlen (str); 47968c4a8e55Smrg patlen = strlen (pat); 4797b042e37fSmrg 47988c4a8e55Smrg if (patlen <= len) 47998c4a8e55Smrg { 48008c4a8e55Smrg str += len - patlen; 48018c4a8e55Smrg if (strcmp (str, pat) == 0) 48028c4a8e55Smrg *str = '\0'; 48038c4a8e55Smrg } 48048c4a8e55Smrg return str; 48058c4a8e55Smrg} 4806b042e37fSmrg 4807706b6b52Smrgvoid 4808706b6b52Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 4809706b6b52Smrg{ 4810706b6b52Smrg va_list args; 4811706b6b52Smrg if (lt_debug) 4812706b6b52Smrg { 4813706b6b52Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 4814706b6b52Smrg va_start (args, fmt); 4815706b6b52Smrg (void) vfprintf (stderr, fmt, args); 4816706b6b52Smrg va_end (args); 4817706b6b52Smrg } 4818706b6b52Smrg} 4819706b6b52Smrg 48208c4a8e55Smrgstatic void 4821706b6b52Smrglt_error_core (int exit_status, const char *file, 4822706b6b52Smrg int line, const char *mode, 48238c4a8e55Smrg const char *message, va_list ap) 48248c4a8e55Smrg{ 4825706b6b52Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 48268c4a8e55Smrg vfprintf (stderr, message, ap); 48278c4a8e55Smrg fprintf (stderr, ".\n"); 4828b042e37fSmrg 48298c4a8e55Smrg if (exit_status >= 0) 48308c4a8e55Smrg exit (exit_status); 48318c4a8e55Smrg} 4832b042e37fSmrg 48338c4a8e55Smrgvoid 4834706b6b52Smrglt_fatal (const char *file, int line, const char *message, ...) 48358c4a8e55Smrg{ 48368c4a8e55Smrg va_list ap; 48378c4a8e55Smrg va_start (ap, message); 4838706b6b52Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 48398c4a8e55Smrg va_end (ap); 48408c4a8e55Smrg} 4841b042e37fSmrg 4842706b6b52Smrgstatic const char * 4843706b6b52Smrgnonnull (const char *s) 4844706b6b52Smrg{ 4845706b6b52Smrg return s ? s : "(null)"; 4846706b6b52Smrg} 4847706b6b52Smrg 4848706b6b52Smrgstatic const char * 4849706b6b52Smrgnonempty (const char *s) 4850706b6b52Smrg{ 4851706b6b52Smrg return (s && !*s) ? "(empty)" : nonnull (s); 4852706b6b52Smrg} 4853706b6b52Smrg 48548c4a8e55Smrgvoid 48558c4a8e55Smrglt_setenv (const char *name, const char *value) 48568c4a8e55Smrg{ 4857706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 4858706b6b52Smrg "(lt_setenv) setting '%s' to '%s'\n", 4859706b6b52Smrg nonnull (name), nonnull (value)); 48608c4a8e55Smrg { 48618c4a8e55Smrg#ifdef HAVE_SETENV 48628c4a8e55Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 48638c4a8e55Smrg char *str = xstrdup (value); 48648c4a8e55Smrg setenv (name, str, 1); 48658c4a8e55Smrg#else 48668c4a8e55Smrg int len = strlen (name) + 1 + strlen (value) + 1; 48678c4a8e55Smrg char *str = XMALLOC (char, len); 48688c4a8e55Smrg sprintf (str, "%s=%s", name, value); 48698c4a8e55Smrg if (putenv (str) != EXIT_SUCCESS) 48708c4a8e55Smrg { 48718c4a8e55Smrg XFREE (str); 48728c4a8e55Smrg } 48738c4a8e55Smrg#endif 48748c4a8e55Smrg } 48758c4a8e55Smrg} 4876b042e37fSmrg 48778c4a8e55Smrgchar * 48788c4a8e55Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 48798c4a8e55Smrg{ 48808c4a8e55Smrg char *new_value; 48818c4a8e55Smrg if (orig_value && *orig_value) 48828c4a8e55Smrg { 48838c4a8e55Smrg int orig_value_len = strlen (orig_value); 48848c4a8e55Smrg int add_len = strlen (add); 48858c4a8e55Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 48868c4a8e55Smrg if (to_end) 48878c4a8e55Smrg { 48888c4a8e55Smrg strcpy (new_value, orig_value); 48898c4a8e55Smrg strcpy (new_value + orig_value_len, add); 48908c4a8e55Smrg } 48918c4a8e55Smrg else 48928c4a8e55Smrg { 48938c4a8e55Smrg strcpy (new_value, add); 48948c4a8e55Smrg strcpy (new_value + add_len, orig_value); 48958c4a8e55Smrg } 48968c4a8e55Smrg } 48978c4a8e55Smrg else 48988c4a8e55Smrg { 48998c4a8e55Smrg new_value = xstrdup (add); 49008c4a8e55Smrg } 49018c4a8e55Smrg return new_value; 49028c4a8e55Smrg} 4903b042e37fSmrg 49048c4a8e55Smrgvoid 49058c4a8e55Smrglt_update_exe_path (const char *name, const char *value) 49068c4a8e55Smrg{ 4907706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 4908706b6b52Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 4909706b6b52Smrg nonnull (name), nonnull (value)); 4910b042e37fSmrg 49118c4a8e55Smrg if (name && *name && value && *value) 49128c4a8e55Smrg { 49138c4a8e55Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 49148c4a8e55Smrg /* some systems can't cope with a ':'-terminated path #' */ 49158c4a8e55Smrg int len = strlen (new_value); 49168c4a8e55Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 49178c4a8e55Smrg { 49188c4a8e55Smrg new_value[len-1] = '\0'; 49198c4a8e55Smrg } 49208c4a8e55Smrg lt_setenv (name, new_value); 49218c4a8e55Smrg XFREE (new_value); 49228c4a8e55Smrg } 49238c4a8e55Smrg} 4924b042e37fSmrg 49258c4a8e55Smrgvoid 49268c4a8e55Smrglt_update_lib_path (const char *name, const char *value) 49278c4a8e55Smrg{ 4928706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 4929706b6b52Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 4930706b6b52Smrg nonnull (name), nonnull (value)); 4931b042e37fSmrg 49328c4a8e55Smrg if (name && *name && value && *value) 49338c4a8e55Smrg { 49348c4a8e55Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 49358c4a8e55Smrg lt_setenv (name, new_value); 49368c4a8e55Smrg XFREE (new_value); 49378c4a8e55Smrg } 49388c4a8e55Smrg} 4939b042e37fSmrg 4940706b6b52SmrgEOF 4941706b6b52Smrg case $host_os in 4942706b6b52Smrg mingw*) 4943706b6b52Smrg cat <<"EOF" 4944706b6b52Smrg 4945706b6b52Smrg/* Prepares an argument vector before calling spawn(). 4946706b6b52Smrg Note that spawn() does not by itself call the command interpreter 4947706b6b52Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 4948706b6b52Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 4949706b6b52Smrg GetVersionEx(&v); 4950706b6b52Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 4951706b6b52Smrg }) ? "cmd.exe" : "command.com"). 4952706b6b52Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 4953706b6b52Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 4954706b6b52Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 4955706b6b52Smrg special way: 4956706b6b52Smrg - Space and tab are interpreted as delimiters. They are not treated as 4957706b6b52Smrg delimiters if they are surrounded by double quotes: "...". 4958706b6b52Smrg - Unescaped double quotes are removed from the input. Their only effect is 4959706b6b52Smrg that within double quotes, space and tab are treated like normal 4960706b6b52Smrg characters. 4961706b6b52Smrg - Backslashes not followed by double quotes are not special. 4962706b6b52Smrg - But 2*n+1 backslashes followed by a double quote become 4963706b6b52Smrg n backslashes followed by a double quote (n >= 0): 4964706b6b52Smrg \" -> " 4965706b6b52Smrg \\\" -> \" 4966706b6b52Smrg \\\\\" -> \\" 4967706b6b52Smrg */ 4968706b6b52Smrg#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" 4969706b6b52Smrg#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" 4970706b6b52Smrgchar ** 4971706b6b52Smrgprepare_spawn (char **argv) 4972706b6b52Smrg{ 4973706b6b52Smrg size_t argc; 4974706b6b52Smrg char **new_argv; 4975706b6b52Smrg size_t i; 4976706b6b52Smrg 4977706b6b52Smrg /* Count number of arguments. */ 4978706b6b52Smrg for (argc = 0; argv[argc] != NULL; argc++) 4979706b6b52Smrg ; 4980706b6b52Smrg 4981706b6b52Smrg /* Allocate new argument vector. */ 4982706b6b52Smrg new_argv = XMALLOC (char *, argc + 1); 4983706b6b52Smrg 4984706b6b52Smrg /* Put quoted arguments into the new argument vector. */ 4985706b6b52Smrg for (i = 0; i < argc; i++) 4986706b6b52Smrg { 4987706b6b52Smrg const char *string = argv[i]; 4988706b6b52Smrg 4989706b6b52Smrg if (string[0] == '\0') 4990706b6b52Smrg new_argv[i] = xstrdup ("\"\""); 4991706b6b52Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 4992706b6b52Smrg { 4993706b6b52Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 4994706b6b52Smrg size_t length; 4995706b6b52Smrg unsigned int backslashes; 4996706b6b52Smrg const char *s; 4997706b6b52Smrg char *quoted_string; 4998706b6b52Smrg char *p; 4999706b6b52Smrg 5000706b6b52Smrg length = 0; 5001706b6b52Smrg backslashes = 0; 5002706b6b52Smrg if (quote_around) 5003706b6b52Smrg length++; 5004706b6b52Smrg for (s = string; *s != '\0'; s++) 5005706b6b52Smrg { 5006706b6b52Smrg char c = *s; 5007706b6b52Smrg if (c == '"') 5008706b6b52Smrg length += backslashes + 1; 5009706b6b52Smrg length++; 5010706b6b52Smrg if (c == '\\') 5011706b6b52Smrg backslashes++; 5012706b6b52Smrg else 5013706b6b52Smrg backslashes = 0; 5014706b6b52Smrg } 5015706b6b52Smrg if (quote_around) 5016706b6b52Smrg length += backslashes + 1; 5017706b6b52Smrg 5018706b6b52Smrg quoted_string = XMALLOC (char, length + 1); 5019706b6b52Smrg 5020706b6b52Smrg p = quoted_string; 5021706b6b52Smrg backslashes = 0; 5022706b6b52Smrg if (quote_around) 5023706b6b52Smrg *p++ = '"'; 5024706b6b52Smrg for (s = string; *s != '\0'; s++) 5025706b6b52Smrg { 5026706b6b52Smrg char c = *s; 5027706b6b52Smrg if (c == '"') 5028706b6b52Smrg { 5029706b6b52Smrg unsigned int j; 5030706b6b52Smrg for (j = backslashes + 1; j > 0; j--) 5031706b6b52Smrg *p++ = '\\'; 5032706b6b52Smrg } 5033706b6b52Smrg *p++ = c; 5034706b6b52Smrg if (c == '\\') 5035706b6b52Smrg backslashes++; 5036706b6b52Smrg else 5037706b6b52Smrg backslashes = 0; 5038706b6b52Smrg } 5039706b6b52Smrg if (quote_around) 5040706b6b52Smrg { 5041706b6b52Smrg unsigned int j; 5042706b6b52Smrg for (j = backslashes; j > 0; j--) 5043706b6b52Smrg *p++ = '\\'; 5044706b6b52Smrg *p++ = '"'; 5045706b6b52Smrg } 5046706b6b52Smrg *p = '\0'; 5047706b6b52Smrg 5048706b6b52Smrg new_argv[i] = quoted_string; 5049706b6b52Smrg } 5050706b6b52Smrg else 5051706b6b52Smrg new_argv[i] = (char *) string; 5052706b6b52Smrg } 5053706b6b52Smrg new_argv[argc] = NULL; 5054706b6b52Smrg 5055706b6b52Smrg return new_argv; 5056706b6b52Smrg} 5057706b6b52SmrgEOF 5058706b6b52Smrg ;; 5059706b6b52Smrg esac 5060706b6b52Smrg 5061706b6b52Smrg cat <<"EOF" 5062706b6b52Smrgvoid lt_dump_script (FILE* f) 5063706b6b52Smrg{ 5064706b6b52SmrgEOF 5065706b6b52Smrg func_emit_wrapper yes | 50660597fb56Smrg $SED -n -e ' 50670597fb56Smrgs/^\(.\{79\}\)\(..*\)/\1\ 50680597fb56Smrg\2/ 50690597fb56Smrgh 50700597fb56Smrgs/\([\\"]\)/\\\1/g 50710597fb56Smrgs/$/\\n/ 50720597fb56Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 50730597fb56Smrgg 50740597fb56SmrgD' 5075706b6b52Smrg cat <<"EOF" 5076706b6b52Smrg} 50778c4a8e55SmrgEOF 50788c4a8e55Smrg} 50798c4a8e55Smrg# end: func_emit_cwrapperexe_src 5080b042e37fSmrg 5081706b6b52Smrg# func_win32_import_lib_p ARG 5082706b6b52Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 5083706b6b52Smrgfunc_win32_import_lib_p () 5084706b6b52Smrg{ 5085706b6b52Smrg $opt_debug 5086706b6b52Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 5087706b6b52Smrg *import*) : ;; 5088706b6b52Smrg *) false ;; 5089706b6b52Smrg esac 5090706b6b52Smrg} 5091706b6b52Smrg 50928c4a8e55Smrg# func_mode_link arg... 50938c4a8e55Smrgfunc_mode_link () 50948c4a8e55Smrg{ 50958c4a8e55Smrg $opt_debug 50968c4a8e55Smrg case $host in 50978c4a8e55Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 50988c4a8e55Smrg # It is impossible to link a dll without this setting, and 50998c4a8e55Smrg # we shouldn't force the makefile maintainer to figure out 51008c4a8e55Smrg # which system we are compiling for in order to pass an extra 51018c4a8e55Smrg # flag for every libtool invocation. 51028c4a8e55Smrg # allow_undefined=no 5103b042e37fSmrg 51048c4a8e55Smrg # FIXME: Unfortunately, there are problems with the above when trying 51058c4a8e55Smrg # to make a dll which has undefined symbols, in which case not 51068c4a8e55Smrg # even a static library is built. For now, we need to specify 51078c4a8e55Smrg # -no-undefined on the libtool link line when we can be certain 51088c4a8e55Smrg # that all symbols are satisfied, otherwise we get a static library. 51098c4a8e55Smrg allow_undefined=yes 51108c4a8e55Smrg ;; 51118c4a8e55Smrg *) 51128c4a8e55Smrg allow_undefined=yes 51138c4a8e55Smrg ;; 51148c4a8e55Smrg esac 51158c4a8e55Smrg libtool_args=$nonopt 51168c4a8e55Smrg base_compile="$nonopt $@" 51178c4a8e55Smrg compile_command=$nonopt 51188c4a8e55Smrg finalize_command=$nonopt 5119b042e37fSmrg 51208c4a8e55Smrg compile_rpath= 51218c4a8e55Smrg finalize_rpath= 51228c4a8e55Smrg compile_shlibpath= 51238c4a8e55Smrg finalize_shlibpath= 51248c4a8e55Smrg convenience= 51258c4a8e55Smrg old_convenience= 51268c4a8e55Smrg deplibs= 51278c4a8e55Smrg old_deplibs= 51288c4a8e55Smrg compiler_flags= 51298c4a8e55Smrg linker_flags= 51308c4a8e55Smrg dllsearchpath= 51318c4a8e55Smrg lib_search_path=`pwd` 51328c4a8e55Smrg inst_prefix_dir= 51338c4a8e55Smrg new_inherited_linker_flags= 5134b042e37fSmrg 51358c4a8e55Smrg avoid_version=no 5136706b6b52Smrg bindir= 51378c4a8e55Smrg dlfiles= 51388c4a8e55Smrg dlprefiles= 51398c4a8e55Smrg dlself=no 51408c4a8e55Smrg export_dynamic=no 51418c4a8e55Smrg export_symbols= 51428c4a8e55Smrg export_symbols_regex= 51438c4a8e55Smrg generated= 51448c4a8e55Smrg libobjs= 51458c4a8e55Smrg ltlibs= 51468c4a8e55Smrg module=no 51478c4a8e55Smrg no_install=no 51488c4a8e55Smrg objs= 51498c4a8e55Smrg non_pic_objects= 51508c4a8e55Smrg precious_files_regex= 51518c4a8e55Smrg prefer_static_libs=no 51528c4a8e55Smrg preload=no 51538c4a8e55Smrg prev= 51548c4a8e55Smrg prevarg= 51558c4a8e55Smrg release= 51568c4a8e55Smrg rpath= 51578c4a8e55Smrg xrpath= 51588c4a8e55Smrg perm_rpath= 51598c4a8e55Smrg temp_rpath= 51608c4a8e55Smrg thread_safe=no 51618c4a8e55Smrg vinfo= 51628c4a8e55Smrg vinfo_number=no 51638c4a8e55Smrg weak_libs= 51648c4a8e55Smrg single_module="${wl}-single_module" 51658c4a8e55Smrg func_infer_tag $base_compile 5166b042e37fSmrg 51678c4a8e55Smrg # We need to know -static, to get the right output filenames. 51688c4a8e55Smrg for arg 51698c4a8e55Smrg do 51708c4a8e55Smrg case $arg in 51718c4a8e55Smrg -shared) 51728c4a8e55Smrg test "$build_libtool_libs" != yes && \ 51738c4a8e55Smrg func_fatal_configuration "can not build a shared library" 51748c4a8e55Smrg build_old_libs=no 51758c4a8e55Smrg break 51768c4a8e55Smrg ;; 51778c4a8e55Smrg -all-static | -static | -static-libtool-libs) 51788c4a8e55Smrg case $arg in 51798c4a8e55Smrg -all-static) 51808c4a8e55Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 51818c4a8e55Smrg func_warning "complete static linking is impossible in this configuration" 51828c4a8e55Smrg fi 51838c4a8e55Smrg if test -n "$link_static_flag"; then 51848c4a8e55Smrg dlopen_self=$dlopen_self_static 51858c4a8e55Smrg fi 51868c4a8e55Smrg prefer_static_libs=yes 51878c4a8e55Smrg ;; 51888c4a8e55Smrg -static) 51898c4a8e55Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 51908c4a8e55Smrg dlopen_self=$dlopen_self_static 51918c4a8e55Smrg fi 51928c4a8e55Smrg prefer_static_libs=built 51938c4a8e55Smrg ;; 51948c4a8e55Smrg -static-libtool-libs) 51958c4a8e55Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 51968c4a8e55Smrg dlopen_self=$dlopen_self_static 51978c4a8e55Smrg fi 51988c4a8e55Smrg prefer_static_libs=yes 51998c4a8e55Smrg ;; 52008c4a8e55Smrg esac 52018c4a8e55Smrg build_libtool_libs=no 52028c4a8e55Smrg build_old_libs=yes 52038c4a8e55Smrg break 52048c4a8e55Smrg ;; 52058c4a8e55Smrg esac 52068c4a8e55Smrg done 5207b042e37fSmrg 52088c4a8e55Smrg # See if our shared archives depend on static archives. 52098c4a8e55Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 5210b042e37fSmrg 52118c4a8e55Smrg # Go through the arguments, transforming them on the way. 52128c4a8e55Smrg while test "$#" -gt 0; do 52138c4a8e55Smrg arg="$1" 52148c4a8e55Smrg shift 52158c4a8e55Smrg func_quote_for_eval "$arg" 52168c4a8e55Smrg qarg=$func_quote_for_eval_unquoted_result 52178c4a8e55Smrg func_append libtool_args " $func_quote_for_eval_result" 5218b042e37fSmrg 52198c4a8e55Smrg # If the previous option needs an argument, assign it. 52208c4a8e55Smrg if test -n "$prev"; then 52218c4a8e55Smrg case $prev in 52228c4a8e55Smrg output) 52238c4a8e55Smrg func_append compile_command " @OUTPUT@" 52248c4a8e55Smrg func_append finalize_command " @OUTPUT@" 52258c4a8e55Smrg ;; 52268c4a8e55Smrg esac 5227b042e37fSmrg 52288c4a8e55Smrg case $prev in 5229706b6b52Smrg bindir) 5230706b6b52Smrg bindir="$arg" 5231706b6b52Smrg prev= 5232706b6b52Smrg continue 5233706b6b52Smrg ;; 52348c4a8e55Smrg dlfiles|dlprefiles) 52358c4a8e55Smrg if test "$preload" = no; then 52368c4a8e55Smrg # Add the symbol object into the linking commands. 52378c4a8e55Smrg func_append compile_command " @SYMFILE@" 52388c4a8e55Smrg func_append finalize_command " @SYMFILE@" 52398c4a8e55Smrg preload=yes 52408c4a8e55Smrg fi 52418c4a8e55Smrg case $arg in 52428c4a8e55Smrg *.la | *.lo) ;; # We handle these cases below. 52438c4a8e55Smrg force) 52448c4a8e55Smrg if test "$dlself" = no; then 52458c4a8e55Smrg dlself=needless 52468c4a8e55Smrg export_dynamic=yes 52478c4a8e55Smrg fi 52488c4a8e55Smrg prev= 52498c4a8e55Smrg continue 52508c4a8e55Smrg ;; 52518c4a8e55Smrg self) 52528c4a8e55Smrg if test "$prev" = dlprefiles; then 52538c4a8e55Smrg dlself=yes 52548c4a8e55Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 52558c4a8e55Smrg dlself=yes 52568c4a8e55Smrg else 52578c4a8e55Smrg dlself=needless 52588c4a8e55Smrg export_dynamic=yes 52598c4a8e55Smrg fi 52608c4a8e55Smrg prev= 52618c4a8e55Smrg continue 52628c4a8e55Smrg ;; 52638c4a8e55Smrg *) 52648c4a8e55Smrg if test "$prev" = dlfiles; then 5265bd23fbfaSmrg func_append dlfiles " $arg" 52668c4a8e55Smrg else 5267bd23fbfaSmrg func_append dlprefiles " $arg" 52688c4a8e55Smrg fi 52698c4a8e55Smrg prev= 52708c4a8e55Smrg continue 52718c4a8e55Smrg ;; 52728c4a8e55Smrg esac 52738c4a8e55Smrg ;; 52748c4a8e55Smrg expsyms) 52758c4a8e55Smrg export_symbols="$arg" 52768c4a8e55Smrg test -f "$arg" \ 52778c4a8e55Smrg || func_fatal_error "symbol file \`$arg' does not exist" 52788c4a8e55Smrg prev= 52798c4a8e55Smrg continue 52808c4a8e55Smrg ;; 52818c4a8e55Smrg expsyms_regex) 52828c4a8e55Smrg export_symbols_regex="$arg" 52838c4a8e55Smrg prev= 52848c4a8e55Smrg continue 52858c4a8e55Smrg ;; 52868c4a8e55Smrg framework) 52878c4a8e55Smrg case $host in 52888c4a8e55Smrg *-*-darwin*) 52898c4a8e55Smrg case "$deplibs " in 52908c4a8e55Smrg *" $qarg.ltframework "*) ;; 5291bd23fbfaSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 52928c4a8e55Smrg ;; 52938c4a8e55Smrg esac 5294b042e37fSmrg ;; 52958c4a8e55Smrg esac 52968c4a8e55Smrg prev= 52978c4a8e55Smrg continue 52988c4a8e55Smrg ;; 52998c4a8e55Smrg inst_prefix) 53008c4a8e55Smrg inst_prefix_dir="$arg" 53018c4a8e55Smrg prev= 53028c4a8e55Smrg continue 53038c4a8e55Smrg ;; 53048c4a8e55Smrg objectlist) 53058c4a8e55Smrg if test -f "$arg"; then 53068c4a8e55Smrg save_arg=$arg 53078c4a8e55Smrg moreargs= 53088c4a8e55Smrg for fil in `cat "$save_arg"` 53098c4a8e55Smrg do 5310bd23fbfaSmrg# func_append moreargs " $fil" 53118c4a8e55Smrg arg=$fil 53128c4a8e55Smrg # A libtool-controlled object. 5313b042e37fSmrg 53148c4a8e55Smrg # Check to see that this really is a libtool object. 53158c4a8e55Smrg if func_lalib_unsafe_p "$arg"; then 53168c4a8e55Smrg pic_object= 53178c4a8e55Smrg non_pic_object= 5318b042e37fSmrg 53198c4a8e55Smrg # Read the .lo file 53208c4a8e55Smrg func_source "$arg" 5321b042e37fSmrg 53228c4a8e55Smrg if test -z "$pic_object" || 53238c4a8e55Smrg test -z "$non_pic_object" || 53248c4a8e55Smrg test "$pic_object" = none && 53258c4a8e55Smrg test "$non_pic_object" = none; then 53268c4a8e55Smrg func_fatal_error "cannot find name of object for \`$arg'" 53278c4a8e55Smrg fi 5328b042e37fSmrg 53298c4a8e55Smrg # Extract subdirectory from the argument. 53308c4a8e55Smrg func_dirname "$arg" "/" "" 53318c4a8e55Smrg xdir="$func_dirname_result" 5332b042e37fSmrg 53338c4a8e55Smrg if test "$pic_object" != none; then 53348c4a8e55Smrg # Prepend the subdirectory the object is found in. 53358c4a8e55Smrg pic_object="$xdir$pic_object" 5336b042e37fSmrg 53378c4a8e55Smrg if test "$prev" = dlfiles; then 53388c4a8e55Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5339bd23fbfaSmrg func_append dlfiles " $pic_object" 53408c4a8e55Smrg prev= 53418c4a8e55Smrg continue 53428c4a8e55Smrg else 53438c4a8e55Smrg # If libtool objects are unsupported, then we need to preload. 53448c4a8e55Smrg prev=dlprefiles 53458c4a8e55Smrg fi 53468c4a8e55Smrg fi 5347b042e37fSmrg 53488c4a8e55Smrg # CHECK ME: I think I busted this. -Ossama 53498c4a8e55Smrg if test "$prev" = dlprefiles; then 53508c4a8e55Smrg # Preload the old-style object. 5351bd23fbfaSmrg func_append dlprefiles " $pic_object" 53528c4a8e55Smrg prev= 53538c4a8e55Smrg fi 5354b042e37fSmrg 53558c4a8e55Smrg # A PIC object. 53568c4a8e55Smrg func_append libobjs " $pic_object" 53578c4a8e55Smrg arg="$pic_object" 53588c4a8e55Smrg fi 5359b042e37fSmrg 53608c4a8e55Smrg # Non-PIC object. 53618c4a8e55Smrg if test "$non_pic_object" != none; then 53628c4a8e55Smrg # Prepend the subdirectory the object is found in. 53638c4a8e55Smrg non_pic_object="$xdir$non_pic_object" 5364b042e37fSmrg 53658c4a8e55Smrg # A standard non-PIC object 53668c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 53678c4a8e55Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 53688c4a8e55Smrg arg="$non_pic_object" 53698c4a8e55Smrg fi 53708c4a8e55Smrg else 53718c4a8e55Smrg # If the PIC object exists, use it instead. 53728c4a8e55Smrg # $xdir was prepended to $pic_object above. 53738c4a8e55Smrg non_pic_object="$pic_object" 53748c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 53758c4a8e55Smrg fi 53768c4a8e55Smrg else 53778c4a8e55Smrg # Only an error if not doing a dry-run. 53788c4a8e55Smrg if $opt_dry_run; then 53798c4a8e55Smrg # Extract subdirectory from the argument. 53808c4a8e55Smrg func_dirname "$arg" "/" "" 53818c4a8e55Smrg xdir="$func_dirname_result" 53828c4a8e55Smrg 53838c4a8e55Smrg func_lo2o "$arg" 53848c4a8e55Smrg pic_object=$xdir$objdir/$func_lo2o_result 53858c4a8e55Smrg non_pic_object=$xdir$func_lo2o_result 53868c4a8e55Smrg func_append libobjs " $pic_object" 53878c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 53888c4a8e55Smrg else 53898c4a8e55Smrg func_fatal_error "\`$arg' is not a valid libtool object" 53908c4a8e55Smrg fi 53918c4a8e55Smrg fi 53928c4a8e55Smrg done 53938c4a8e55Smrg else 53948c4a8e55Smrg func_fatal_error "link input file \`$arg' does not exist" 53958c4a8e55Smrg fi 53968c4a8e55Smrg arg=$save_arg 53978c4a8e55Smrg prev= 53988c4a8e55Smrg continue 5399b042e37fSmrg ;; 54008c4a8e55Smrg precious_regex) 54018c4a8e55Smrg precious_files_regex="$arg" 54028c4a8e55Smrg prev= 54038c4a8e55Smrg continue 5404b042e37fSmrg ;; 54058c4a8e55Smrg release) 54068c4a8e55Smrg release="-$arg" 54078c4a8e55Smrg prev= 54088c4a8e55Smrg continue 5409b042e37fSmrg ;; 54108c4a8e55Smrg rpath | xrpath) 54118c4a8e55Smrg # We need an absolute path. 54128c4a8e55Smrg case $arg in 54138c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5414b042e37fSmrg *) 54158c4a8e55Smrg func_fatal_error "only absolute run-paths are allowed" 5416b042e37fSmrg ;; 5417b042e37fSmrg esac 54188c4a8e55Smrg if test "$prev" = rpath; then 54198c4a8e55Smrg case "$rpath " in 54208c4a8e55Smrg *" $arg "*) ;; 5421bd23fbfaSmrg *) func_append rpath " $arg" ;; 54228c4a8e55Smrg esac 54238c4a8e55Smrg else 54248c4a8e55Smrg case "$xrpath " in 54258c4a8e55Smrg *" $arg "*) ;; 5426bd23fbfaSmrg *) func_append xrpath " $arg" ;; 54278c4a8e55Smrg esac 54288c4a8e55Smrg fi 54298c4a8e55Smrg prev= 54308c4a8e55Smrg continue 54318c4a8e55Smrg ;; 54328c4a8e55Smrg shrext) 54338c4a8e55Smrg shrext_cmds="$arg" 54348c4a8e55Smrg prev= 54358c4a8e55Smrg continue 54368c4a8e55Smrg ;; 54378c4a8e55Smrg weak) 5438bd23fbfaSmrg func_append weak_libs " $arg" 54398c4a8e55Smrg prev= 54408c4a8e55Smrg continue 54418c4a8e55Smrg ;; 54428c4a8e55Smrg xcclinker) 5443bd23fbfaSmrg func_append linker_flags " $qarg" 5444bd23fbfaSmrg func_append compiler_flags " $qarg" 54458c4a8e55Smrg prev= 54468c4a8e55Smrg func_append compile_command " $qarg" 54478c4a8e55Smrg func_append finalize_command " $qarg" 54488c4a8e55Smrg continue 54498c4a8e55Smrg ;; 54508c4a8e55Smrg xcompiler) 5451bd23fbfaSmrg func_append compiler_flags " $qarg" 54528c4a8e55Smrg prev= 54538c4a8e55Smrg func_append compile_command " $qarg" 54548c4a8e55Smrg func_append finalize_command " $qarg" 54558c4a8e55Smrg continue 54568c4a8e55Smrg ;; 54578c4a8e55Smrg xlinker) 5458bd23fbfaSmrg func_append linker_flags " $qarg" 5459bd23fbfaSmrg func_append compiler_flags " $wl$qarg" 54608c4a8e55Smrg prev= 54618c4a8e55Smrg func_append compile_command " $wl$qarg" 54628c4a8e55Smrg func_append finalize_command " $wl$qarg" 54638c4a8e55Smrg continue 54648c4a8e55Smrg ;; 54658c4a8e55Smrg *) 54668c4a8e55Smrg eval "$prev=\"\$arg\"" 54678c4a8e55Smrg prev= 54688c4a8e55Smrg continue 54698c4a8e55Smrg ;; 54708c4a8e55Smrg esac 54718c4a8e55Smrg fi # test -n "$prev" 54728c4a8e55Smrg 54738c4a8e55Smrg prevarg="$arg" 54748c4a8e55Smrg 54758c4a8e55Smrg case $arg in 54768c4a8e55Smrg -all-static) 54778c4a8e55Smrg if test -n "$link_static_flag"; then 54788c4a8e55Smrg # See comment for -static flag below, for more details. 54798c4a8e55Smrg func_append compile_command " $link_static_flag" 54808c4a8e55Smrg func_append finalize_command " $link_static_flag" 5481b042e37fSmrg fi 54828c4a8e55Smrg continue 54838c4a8e55Smrg ;; 5484b042e37fSmrg 54858c4a8e55Smrg -allow-undefined) 54868c4a8e55Smrg # FIXME: remove this flag sometime in the future. 54878c4a8e55Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 54888c4a8e55Smrg ;; 5489b042e37fSmrg 54908c4a8e55Smrg -avoid-version) 54918c4a8e55Smrg avoid_version=yes 54928c4a8e55Smrg continue 54938c4a8e55Smrg ;; 5494b042e37fSmrg 5495706b6b52Smrg -bindir) 5496706b6b52Smrg prev=bindir 5497706b6b52Smrg continue 5498706b6b52Smrg ;; 5499706b6b52Smrg 55008c4a8e55Smrg -dlopen) 55018c4a8e55Smrg prev=dlfiles 55028c4a8e55Smrg continue 55038c4a8e55Smrg ;; 55048c4a8e55Smrg 55058c4a8e55Smrg -dlpreopen) 55068c4a8e55Smrg prev=dlprefiles 55078c4a8e55Smrg continue 55088c4a8e55Smrg ;; 55098c4a8e55Smrg 55108c4a8e55Smrg -export-dynamic) 55118c4a8e55Smrg export_dynamic=yes 55128c4a8e55Smrg continue 55138c4a8e55Smrg ;; 55148c4a8e55Smrg 55158c4a8e55Smrg -export-symbols | -export-symbols-regex) 55168c4a8e55Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 55178c4a8e55Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 55188c4a8e55Smrg fi 55198c4a8e55Smrg if test "X$arg" = "X-export-symbols"; then 55208c4a8e55Smrg prev=expsyms 5521b042e37fSmrg else 55228c4a8e55Smrg prev=expsyms_regex 5523b042e37fSmrg fi 55248c4a8e55Smrg continue 55258c4a8e55Smrg ;; 5526b042e37fSmrg 55278c4a8e55Smrg -framework) 55288c4a8e55Smrg prev=framework 55298c4a8e55Smrg continue 55308c4a8e55Smrg ;; 5531b042e37fSmrg 55328c4a8e55Smrg -inst-prefix-dir) 55338c4a8e55Smrg prev=inst_prefix 55348c4a8e55Smrg continue 55358c4a8e55Smrg ;; 5536b042e37fSmrg 55378c4a8e55Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 55388c4a8e55Smrg # so, if we see these flags be careful not to treat them like -L 55398c4a8e55Smrg -L[A-Z][A-Z]*:*) 55408c4a8e55Smrg case $with_gcc/$host in 55418c4a8e55Smrg no/*-*-irix* | /*-*-irix*) 55428c4a8e55Smrg func_append compile_command " $arg" 55438c4a8e55Smrg func_append finalize_command " $arg" 55448c4a8e55Smrg ;; 55458c4a8e55Smrg esac 55468c4a8e55Smrg continue 55478c4a8e55Smrg ;; 5548b042e37fSmrg 55498c4a8e55Smrg -L*) 5550bd23fbfaSmrg func_stripname "-L" '' "$arg" 5551bd23fbfaSmrg if test -z "$func_stripname_result"; then 55528c4a8e55Smrg if test "$#" -gt 0; then 55538c4a8e55Smrg func_fatal_error "require no space between \`-L' and \`$1'" 5554b042e37fSmrg else 55558c4a8e55Smrg func_fatal_error "need path for \`-L' option" 5556b042e37fSmrg fi 55578c4a8e55Smrg fi 5558bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result" 5559bd23fbfaSmrg dir=$func_resolve_sysroot_result 55608c4a8e55Smrg # We need an absolute path. 55618c4a8e55Smrg case $dir in 55628c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 55638c4a8e55Smrg *) 55648c4a8e55Smrg absdir=`cd "$dir" && pwd` 55658c4a8e55Smrg test -z "$absdir" && \ 55668c4a8e55Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 55678c4a8e55Smrg dir="$absdir" 55688c4a8e55Smrg ;; 5569b042e37fSmrg esac 55708c4a8e55Smrg case "$deplibs " in 5571bd23fbfaSmrg *" -L$dir "* | *" $arg "*) 5572bd23fbfaSmrg # Will only happen for absolute or sysroot arguments 5573bd23fbfaSmrg ;; 55748c4a8e55Smrg *) 5575bd23fbfaSmrg # Preserve sysroot, but never include relative directories 5576bd23fbfaSmrg case $dir in 5577bd23fbfaSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 5578bd23fbfaSmrg *) func_append deplibs " -L$dir" ;; 5579bd23fbfaSmrg esac 5580bd23fbfaSmrg func_append lib_search_path " $dir" 55818c4a8e55Smrg ;; 5582b042e37fSmrg esac 5583b042e37fSmrg case $host in 55848c4a8e55Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5585706b6b52Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 55868c4a8e55Smrg case :$dllsearchpath: in 55878c4a8e55Smrg *":$dir:"*) ;; 55888c4a8e55Smrg ::) dllsearchpath=$dir;; 5589bd23fbfaSmrg *) func_append dllsearchpath ":$dir";; 55908c4a8e55Smrg esac 55918c4a8e55Smrg case :$dllsearchpath: in 55928c4a8e55Smrg *":$testbindir:"*) ;; 55938c4a8e55Smrg ::) dllsearchpath=$testbindir;; 5594bd23fbfaSmrg *) func_append dllsearchpath ":$testbindir";; 55958c4a8e55Smrg esac 55968c4a8e55Smrg ;; 5597b042e37fSmrg esac 55988c4a8e55Smrg continue 55998c4a8e55Smrg ;; 5600b042e37fSmrg 56018c4a8e55Smrg -l*) 56028c4a8e55Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 56038c4a8e55Smrg case $host in 5604706b6b52Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 56058c4a8e55Smrg # These systems don't actually have a C or math library (as such) 56068c4a8e55Smrg continue 56078c4a8e55Smrg ;; 56088c4a8e55Smrg *-*-os2*) 56098c4a8e55Smrg # These systems don't actually have a C library (as such) 56108c4a8e55Smrg test "X$arg" = "X-lc" && continue 56118c4a8e55Smrg ;; 56128c4a8e55Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 56138c4a8e55Smrg # Do not include libc due to us having libc/libc_r. 56148c4a8e55Smrg test "X$arg" = "X-lc" && continue 56158c4a8e55Smrg ;; 56168c4a8e55Smrg *-*-rhapsody* | *-*-darwin1.[012]) 56178c4a8e55Smrg # Rhapsody C and math libraries are in the System framework 5618bd23fbfaSmrg func_append deplibs " System.ltframework" 56198c4a8e55Smrg continue 56208c4a8e55Smrg ;; 56218c4a8e55Smrg *-*-sco3.2v5* | *-*-sco5v6*) 56228c4a8e55Smrg # Causes problems with __ctype 56238c4a8e55Smrg test "X$arg" = "X-lc" && continue 56248c4a8e55Smrg ;; 56258c4a8e55Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 56268c4a8e55Smrg # Compiler inserts libc in the correct place for threads to work 56278c4a8e55Smrg test "X$arg" = "X-lc" && continue 56288c4a8e55Smrg ;; 56298c4a8e55Smrg esac 56308c4a8e55Smrg elif test "X$arg" = "X-lc_r"; then 56318c4a8e55Smrg case $host in 56328c4a8e55Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 56338c4a8e55Smrg # Do not include libc_r directly, use -pthread flag. 56348c4a8e55Smrg continue 56358c4a8e55Smrg ;; 56368c4a8e55Smrg esac 56378c4a8e55Smrg fi 5638bd23fbfaSmrg func_append deplibs " $arg" 56398c4a8e55Smrg continue 56408c4a8e55Smrg ;; 5641b042e37fSmrg 56428c4a8e55Smrg -module) 56438c4a8e55Smrg module=yes 56448c4a8e55Smrg continue 56458c4a8e55Smrg ;; 5646b042e37fSmrg 56478c4a8e55Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 56488c4a8e55Smrg # classes, name mangling, and exception handling. 56498c4a8e55Smrg # Darwin uses the -arch flag to determine output architecture. 5650bd23fbfaSmrg -model|-arch|-isysroot|--sysroot) 5651bd23fbfaSmrg func_append compiler_flags " $arg" 56528c4a8e55Smrg func_append compile_command " $arg" 56538c4a8e55Smrg func_append finalize_command " $arg" 56548c4a8e55Smrg prev=xcompiler 56558c4a8e55Smrg continue 56568c4a8e55Smrg ;; 5657b042e37fSmrg 56580597fb56Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 56590597fb56Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 5660bd23fbfaSmrg func_append compiler_flags " $arg" 56618c4a8e55Smrg func_append compile_command " $arg" 56628c4a8e55Smrg func_append finalize_command " $arg" 56638c4a8e55Smrg case "$new_inherited_linker_flags " in 56648c4a8e55Smrg *" $arg "*) ;; 5665bd23fbfaSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 56668c4a8e55Smrg esac 56678c4a8e55Smrg continue 56688c4a8e55Smrg ;; 5669b042e37fSmrg 56708c4a8e55Smrg -multi_module) 56718c4a8e55Smrg single_module="${wl}-multi_module" 56728c4a8e55Smrg continue 56738c4a8e55Smrg ;; 5674b042e37fSmrg 56758c4a8e55Smrg -no-fast-install) 56768c4a8e55Smrg fast_install=no 56778c4a8e55Smrg continue 56788c4a8e55Smrg ;; 5679b042e37fSmrg 56808c4a8e55Smrg -no-install) 56818c4a8e55Smrg case $host in 56828c4a8e55Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 56838c4a8e55Smrg # The PATH hackery in wrapper scripts is required on Windows 56848c4a8e55Smrg # and Darwin in order for the loader to find any dlls it needs. 56858c4a8e55Smrg func_warning "\`-no-install' is ignored for $host" 56868c4a8e55Smrg func_warning "assuming \`-no-fast-install' instead" 56878c4a8e55Smrg fast_install=no 56888c4a8e55Smrg ;; 56898c4a8e55Smrg *) no_install=yes ;; 56908c4a8e55Smrg esac 56918c4a8e55Smrg continue 56928c4a8e55Smrg ;; 5693b042e37fSmrg 56948c4a8e55Smrg -no-undefined) 56958c4a8e55Smrg allow_undefined=no 56968c4a8e55Smrg continue 56978c4a8e55Smrg ;; 5698b042e37fSmrg 56998c4a8e55Smrg -objectlist) 57008c4a8e55Smrg prev=objectlist 57018c4a8e55Smrg continue 57028c4a8e55Smrg ;; 5703b042e37fSmrg 57048c4a8e55Smrg -o) prev=output ;; 5705b042e37fSmrg 57068c4a8e55Smrg -precious-files-regex) 57078c4a8e55Smrg prev=precious_regex 57088c4a8e55Smrg continue 57098c4a8e55Smrg ;; 5710b042e37fSmrg 57118c4a8e55Smrg -release) 57128c4a8e55Smrg prev=release 57138c4a8e55Smrg continue 57148c4a8e55Smrg ;; 5715b042e37fSmrg 57168c4a8e55Smrg -rpath) 57178c4a8e55Smrg prev=rpath 57188c4a8e55Smrg continue 57198c4a8e55Smrg ;; 5720b042e37fSmrg 57218c4a8e55Smrg -R) 57228c4a8e55Smrg prev=xrpath 57238c4a8e55Smrg continue 57248c4a8e55Smrg ;; 5725b042e37fSmrg 57268c4a8e55Smrg -R*) 57278c4a8e55Smrg func_stripname '-R' '' "$arg" 57288c4a8e55Smrg dir=$func_stripname_result 57298c4a8e55Smrg # We need an absolute path. 57308c4a8e55Smrg case $dir in 57318c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5732bd23fbfaSmrg =*) 5733bd23fbfaSmrg func_stripname '=' '' "$dir" 5734bd23fbfaSmrg dir=$lt_sysroot$func_stripname_result 5735bd23fbfaSmrg ;; 57368c4a8e55Smrg *) 57378c4a8e55Smrg func_fatal_error "only absolute run-paths are allowed" 57388c4a8e55Smrg ;; 57398c4a8e55Smrg esac 57408c4a8e55Smrg case "$xrpath " in 57418c4a8e55Smrg *" $dir "*) ;; 5742bd23fbfaSmrg *) func_append xrpath " $dir" ;; 57438c4a8e55Smrg esac 57448c4a8e55Smrg continue 57458c4a8e55Smrg ;; 5746b042e37fSmrg 57478c4a8e55Smrg -shared) 57488c4a8e55Smrg # The effects of -shared are defined in a previous loop. 57498c4a8e55Smrg continue 57508c4a8e55Smrg ;; 5751b042e37fSmrg 57528c4a8e55Smrg -shrext) 57538c4a8e55Smrg prev=shrext 57548c4a8e55Smrg continue 57558c4a8e55Smrg ;; 5756b042e37fSmrg 57578c4a8e55Smrg -static | -static-libtool-libs) 57588c4a8e55Smrg # The effects of -static are defined in a previous loop. 57598c4a8e55Smrg # We used to do the same as -all-static on platforms that 57608c4a8e55Smrg # didn't have a PIC flag, but the assumption that the effects 57618c4a8e55Smrg # would be equivalent was wrong. It would break on at least 57628c4a8e55Smrg # Digital Unix and AIX. 57638c4a8e55Smrg continue 57648c4a8e55Smrg ;; 5765b042e37fSmrg 57668c4a8e55Smrg -thread-safe) 57678c4a8e55Smrg thread_safe=yes 57688c4a8e55Smrg continue 57698c4a8e55Smrg ;; 5770b042e37fSmrg 57718c4a8e55Smrg -version-info) 57728c4a8e55Smrg prev=vinfo 57738c4a8e55Smrg continue 57748c4a8e55Smrg ;; 5775b042e37fSmrg 57768c4a8e55Smrg -version-number) 57778c4a8e55Smrg prev=vinfo 57788c4a8e55Smrg vinfo_number=yes 57798c4a8e55Smrg continue 57808c4a8e55Smrg ;; 5781b042e37fSmrg 57828c4a8e55Smrg -weak) 57838c4a8e55Smrg prev=weak 57848c4a8e55Smrg continue 57858c4a8e55Smrg ;; 5786b042e37fSmrg 57878c4a8e55Smrg -Wc,*) 57888c4a8e55Smrg func_stripname '-Wc,' '' "$arg" 57898c4a8e55Smrg args=$func_stripname_result 57908c4a8e55Smrg arg= 57918c4a8e55Smrg save_ifs="$IFS"; IFS=',' 57928c4a8e55Smrg for flag in $args; do 57938c4a8e55Smrg IFS="$save_ifs" 57948c4a8e55Smrg func_quote_for_eval "$flag" 5795bd23fbfaSmrg func_append arg " $func_quote_for_eval_result" 5796bd23fbfaSmrg func_append compiler_flags " $func_quote_for_eval_result" 57978c4a8e55Smrg done 57988c4a8e55Smrg IFS="$save_ifs" 57998c4a8e55Smrg func_stripname ' ' '' "$arg" 58008c4a8e55Smrg arg=$func_stripname_result 58018c4a8e55Smrg ;; 5802b042e37fSmrg 58038c4a8e55Smrg -Wl,*) 58048c4a8e55Smrg func_stripname '-Wl,' '' "$arg" 58058c4a8e55Smrg args=$func_stripname_result 58068c4a8e55Smrg arg= 58078c4a8e55Smrg save_ifs="$IFS"; IFS=',' 58088c4a8e55Smrg for flag in $args; do 58098c4a8e55Smrg IFS="$save_ifs" 58108c4a8e55Smrg func_quote_for_eval "$flag" 5811bd23fbfaSmrg func_append arg " $wl$func_quote_for_eval_result" 5812bd23fbfaSmrg func_append compiler_flags " $wl$func_quote_for_eval_result" 5813bd23fbfaSmrg func_append linker_flags " $func_quote_for_eval_result" 58148c4a8e55Smrg done 58158c4a8e55Smrg IFS="$save_ifs" 58168c4a8e55Smrg func_stripname ' ' '' "$arg" 58178c4a8e55Smrg arg=$func_stripname_result 58188c4a8e55Smrg ;; 5819b042e37fSmrg 58208c4a8e55Smrg -Xcompiler) 58218c4a8e55Smrg prev=xcompiler 58228c4a8e55Smrg continue 58238c4a8e55Smrg ;; 5824b042e37fSmrg 58258c4a8e55Smrg -Xlinker) 58268c4a8e55Smrg prev=xlinker 58278c4a8e55Smrg continue 58288c4a8e55Smrg ;; 5829b042e37fSmrg 58308c4a8e55Smrg -XCClinker) 58318c4a8e55Smrg prev=xcclinker 58328c4a8e55Smrg continue 58338c4a8e55Smrg ;; 5834b042e37fSmrg 58358c4a8e55Smrg # -msg_* for osf cc 58368c4a8e55Smrg -msg_*) 58378c4a8e55Smrg func_quote_for_eval "$arg" 58388c4a8e55Smrg arg="$func_quote_for_eval_result" 58398c4a8e55Smrg ;; 5840b042e37fSmrg 5841706b6b52Smrg # Flags to be passed through unchanged, with rationale: 5842706b6b52Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 5843706b6b52Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 5844706b6b52Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 5845706b6b52Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 5846706b6b52Smrg # -q* compiler args for the IBM compiler 5847706b6b52Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 5848706b6b52Smrg # -F/path path to uninstalled frameworks, gcc on darwin 5849706b6b52Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 5850706b6b52Smrg # @file GCC response files 5851706b6b52Smrg # -tp=* Portland pgcc target processor selection 5852bd23fbfaSmrg # --sysroot=* for sysroot support 5853bd23fbfaSmrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 58548c4a8e55Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 5855bd23fbfaSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 5856bd23fbfaSmrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 58578c4a8e55Smrg func_quote_for_eval "$arg" 58588c4a8e55Smrg arg="$func_quote_for_eval_result" 58598c4a8e55Smrg func_append compile_command " $arg" 58608c4a8e55Smrg func_append finalize_command " $arg" 5861bd23fbfaSmrg func_append compiler_flags " $arg" 58628c4a8e55Smrg continue 58638c4a8e55Smrg ;; 5864b042e37fSmrg 58658c4a8e55Smrg # Some other compiler flag. 58668c4a8e55Smrg -* | +*) 58678c4a8e55Smrg func_quote_for_eval "$arg" 58688c4a8e55Smrg arg="$func_quote_for_eval_result" 58698c4a8e55Smrg ;; 5870b042e37fSmrg 58718c4a8e55Smrg *.$objext) 58728c4a8e55Smrg # A standard object. 5873bd23fbfaSmrg func_append objs " $arg" 58748c4a8e55Smrg ;; 5875b042e37fSmrg 58768c4a8e55Smrg *.lo) 58778c4a8e55Smrg # A libtool-controlled object. 5878b042e37fSmrg 58798c4a8e55Smrg # Check to see that this really is a libtool object. 58808c4a8e55Smrg if func_lalib_unsafe_p "$arg"; then 58818c4a8e55Smrg pic_object= 58828c4a8e55Smrg non_pic_object= 5883b042e37fSmrg 58848c4a8e55Smrg # Read the .lo file 58858c4a8e55Smrg func_source "$arg" 5886b042e37fSmrg 58878c4a8e55Smrg if test -z "$pic_object" || 58888c4a8e55Smrg test -z "$non_pic_object" || 58898c4a8e55Smrg test "$pic_object" = none && 58908c4a8e55Smrg test "$non_pic_object" = none; then 58918c4a8e55Smrg func_fatal_error "cannot find name of object for \`$arg'" 58928c4a8e55Smrg fi 5893b042e37fSmrg 58948c4a8e55Smrg # Extract subdirectory from the argument. 58958c4a8e55Smrg func_dirname "$arg" "/" "" 58968c4a8e55Smrg xdir="$func_dirname_result" 5897b042e37fSmrg 58988c4a8e55Smrg if test "$pic_object" != none; then 58998c4a8e55Smrg # Prepend the subdirectory the object is found in. 59008c4a8e55Smrg pic_object="$xdir$pic_object" 5901b042e37fSmrg 59028c4a8e55Smrg if test "$prev" = dlfiles; then 59038c4a8e55Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5904bd23fbfaSmrg func_append dlfiles " $pic_object" 59058c4a8e55Smrg prev= 59068c4a8e55Smrg continue 59078c4a8e55Smrg else 59088c4a8e55Smrg # If libtool objects are unsupported, then we need to preload. 59098c4a8e55Smrg prev=dlprefiles 59108c4a8e55Smrg fi 59118c4a8e55Smrg fi 5912b042e37fSmrg 59138c4a8e55Smrg # CHECK ME: I think I busted this. -Ossama 59148c4a8e55Smrg if test "$prev" = dlprefiles; then 59158c4a8e55Smrg # Preload the old-style object. 5916bd23fbfaSmrg func_append dlprefiles " $pic_object" 59178c4a8e55Smrg prev= 59188c4a8e55Smrg fi 5919b042e37fSmrg 59208c4a8e55Smrg # A PIC object. 59218c4a8e55Smrg func_append libobjs " $pic_object" 59228c4a8e55Smrg arg="$pic_object" 59238c4a8e55Smrg fi 5924b042e37fSmrg 59258c4a8e55Smrg # Non-PIC object. 59268c4a8e55Smrg if test "$non_pic_object" != none; then 59278c4a8e55Smrg # Prepend the subdirectory the object is found in. 59288c4a8e55Smrg non_pic_object="$xdir$non_pic_object" 5929b042e37fSmrg 59308c4a8e55Smrg # A standard non-PIC object 59318c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 59328c4a8e55Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 59338c4a8e55Smrg arg="$non_pic_object" 59348c4a8e55Smrg fi 59358c4a8e55Smrg else 59368c4a8e55Smrg # If the PIC object exists, use it instead. 59378c4a8e55Smrg # $xdir was prepended to $pic_object above. 59388c4a8e55Smrg non_pic_object="$pic_object" 59398c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 59408c4a8e55Smrg fi 59418c4a8e55Smrg else 59428c4a8e55Smrg # Only an error if not doing a dry-run. 59438c4a8e55Smrg if $opt_dry_run; then 59448c4a8e55Smrg # Extract subdirectory from the argument. 59458c4a8e55Smrg func_dirname "$arg" "/" "" 59468c4a8e55Smrg xdir="$func_dirname_result" 59478c4a8e55Smrg 59488c4a8e55Smrg func_lo2o "$arg" 59498c4a8e55Smrg pic_object=$xdir$objdir/$func_lo2o_result 59508c4a8e55Smrg non_pic_object=$xdir$func_lo2o_result 59518c4a8e55Smrg func_append libobjs " $pic_object" 59528c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 59538c4a8e55Smrg else 59548c4a8e55Smrg func_fatal_error "\`$arg' is not a valid libtool object" 59558c4a8e55Smrg fi 59568c4a8e55Smrg fi 59578c4a8e55Smrg ;; 5958b042e37fSmrg 59598c4a8e55Smrg *.$libext) 59608c4a8e55Smrg # An archive. 5961bd23fbfaSmrg func_append deplibs " $arg" 5962bd23fbfaSmrg func_append old_deplibs " $arg" 59638c4a8e55Smrg continue 59648c4a8e55Smrg ;; 5965b042e37fSmrg 59668c4a8e55Smrg *.la) 59678c4a8e55Smrg # A libtool-controlled library. 5968b042e37fSmrg 5969bd23fbfaSmrg func_resolve_sysroot "$arg" 59708c4a8e55Smrg if test "$prev" = dlfiles; then 59718c4a8e55Smrg # This library was specified with -dlopen. 5972bd23fbfaSmrg func_append dlfiles " $func_resolve_sysroot_result" 59738c4a8e55Smrg prev= 59748c4a8e55Smrg elif test "$prev" = dlprefiles; then 59758c4a8e55Smrg # The library was specified with -dlpreopen. 5976bd23fbfaSmrg func_append dlprefiles " $func_resolve_sysroot_result" 59778c4a8e55Smrg prev= 59788c4a8e55Smrg else 5979bd23fbfaSmrg func_append deplibs " $func_resolve_sysroot_result" 59808c4a8e55Smrg fi 59818c4a8e55Smrg continue 59828c4a8e55Smrg ;; 5983b042e37fSmrg 59848c4a8e55Smrg # Some other compiler argument. 59858c4a8e55Smrg *) 59868c4a8e55Smrg # Unknown arguments in both finalize_command and compile_command need 59878c4a8e55Smrg # to be aesthetically quoted because they are evaled later. 59888c4a8e55Smrg func_quote_for_eval "$arg" 59898c4a8e55Smrg arg="$func_quote_for_eval_result" 59908c4a8e55Smrg ;; 59918c4a8e55Smrg esac # arg 5992b042e37fSmrg 59938c4a8e55Smrg # Now actually substitute the argument into the commands. 59948c4a8e55Smrg if test -n "$arg"; then 59958c4a8e55Smrg func_append compile_command " $arg" 59968c4a8e55Smrg func_append finalize_command " $arg" 59978c4a8e55Smrg fi 59988c4a8e55Smrg done # argument parsing loop 5999b042e37fSmrg 60008c4a8e55Smrg test -n "$prev" && \ 60018c4a8e55Smrg func_fatal_help "the \`$prevarg' option requires an argument" 6002b042e37fSmrg 60038c4a8e55Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 60048c4a8e55Smrg eval arg=\"$export_dynamic_flag_spec\" 60058c4a8e55Smrg func_append compile_command " $arg" 60068c4a8e55Smrg func_append finalize_command " $arg" 60078c4a8e55Smrg fi 6008b042e37fSmrg 60098c4a8e55Smrg oldlibs= 60108c4a8e55Smrg # calculate the name of the file, without its directory 60118c4a8e55Smrg func_basename "$output" 60128c4a8e55Smrg outputname="$func_basename_result" 60138c4a8e55Smrg libobjs_save="$libobjs" 60148c4a8e55Smrg 60158c4a8e55Smrg if test -n "$shlibpath_var"; then 60168c4a8e55Smrg # get the directories listed in $shlibpath_var 6017706b6b52Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 6018b042e37fSmrg else 60198c4a8e55Smrg shlib_search_path= 6020b042e37fSmrg fi 60218c4a8e55Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 60228c4a8e55Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 6023b042e37fSmrg 60248c4a8e55Smrg func_dirname "$output" "/" "" 60258c4a8e55Smrg output_objdir="$func_dirname_result$objdir" 6026bd23fbfaSmrg func_to_tool_file "$output_objdir/" 6027bd23fbfaSmrg tool_output_objdir=$func_to_tool_file_result 60288c4a8e55Smrg # Create the object directory. 60298c4a8e55Smrg func_mkdir_p "$output_objdir" 6030b042e37fSmrg 60318c4a8e55Smrg # Determine the type of output 60328c4a8e55Smrg case $output in 60338c4a8e55Smrg "") 60348c4a8e55Smrg func_fatal_help "you must specify an output file" 60358c4a8e55Smrg ;; 60368c4a8e55Smrg *.$libext) linkmode=oldlib ;; 60378c4a8e55Smrg *.lo | *.$objext) linkmode=obj ;; 60388c4a8e55Smrg *.la) linkmode=lib ;; 60398c4a8e55Smrg *) linkmode=prog ;; # Anything else should be a program. 60408c4a8e55Smrg esac 60418c4a8e55Smrg 60428c4a8e55Smrg specialdeplibs= 60438c4a8e55Smrg 60448c4a8e55Smrg libs= 60458c4a8e55Smrg # Find all interdependent deplibs by searching for libraries 60468c4a8e55Smrg # that are linked more than once (e.g. -la -lb -la) 60478c4a8e55Smrg for deplib in $deplibs; do 6048bd23fbfaSmrg if $opt_preserve_dup_deps ; then 60498c4a8e55Smrg case "$libs " in 6050bd23fbfaSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 60518c4a8e55Smrg esac 60528c4a8e55Smrg fi 6053bd23fbfaSmrg func_append libs " $deplib" 60548c4a8e55Smrg done 60558c4a8e55Smrg 60568c4a8e55Smrg if test "$linkmode" = lib; then 60578c4a8e55Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 60588c4a8e55Smrg 60598c4a8e55Smrg # Compute libraries that are listed more than once in $predeps 60608c4a8e55Smrg # $postdeps and mark them as special (i.e., whose duplicates are 60618c4a8e55Smrg # not to be eliminated). 60628c4a8e55Smrg pre_post_deps= 60638c4a8e55Smrg if $opt_duplicate_compiler_generated_deps; then 60648c4a8e55Smrg for pre_post_dep in $predeps $postdeps; do 60658c4a8e55Smrg case "$pre_post_deps " in 6066bd23fbfaSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 60678c4a8e55Smrg esac 6068bd23fbfaSmrg func_append pre_post_deps " $pre_post_dep" 60698c4a8e55Smrg done 60708c4a8e55Smrg fi 60718c4a8e55Smrg pre_post_deps= 60728c4a8e55Smrg fi 60738c4a8e55Smrg 60748c4a8e55Smrg deplibs= 60758c4a8e55Smrg newdependency_libs= 60768c4a8e55Smrg newlib_search_path= 60778c4a8e55Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 60788c4a8e55Smrg notinst_deplibs= # not-installed libtool libraries 60798c4a8e55Smrg notinst_path= # paths that contain not-installed libtool libraries 60808c4a8e55Smrg 60818c4a8e55Smrg case $linkmode in 60828c4a8e55Smrg lib) 60838c4a8e55Smrg passes="conv dlpreopen link" 60848c4a8e55Smrg for file in $dlfiles $dlprefiles; do 60858c4a8e55Smrg case $file in 60868c4a8e55Smrg *.la) ;; 60878c4a8e55Smrg *) 60888c4a8e55Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 60898c4a8e55Smrg ;; 60908c4a8e55Smrg esac 60918c4a8e55Smrg done 60928c4a8e55Smrg ;; 60938c4a8e55Smrg prog) 60948c4a8e55Smrg compile_deplibs= 60958c4a8e55Smrg finalize_deplibs= 60968c4a8e55Smrg alldeplibs=no 60978c4a8e55Smrg newdlfiles= 60988c4a8e55Smrg newdlprefiles= 60998c4a8e55Smrg passes="conv scan dlopen dlpreopen link" 61008c4a8e55Smrg ;; 61018c4a8e55Smrg *) passes="conv" 61028c4a8e55Smrg ;; 61038c4a8e55Smrg esac 61048c4a8e55Smrg 61058c4a8e55Smrg for pass in $passes; do 61068c4a8e55Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 61078c4a8e55Smrg # so that -L comes before libs that need it for instance... 61088c4a8e55Smrg if test "$linkmode,$pass" = "lib,link"; then 61098c4a8e55Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 61108c4a8e55Smrg ## order, and fix it there properly 61118c4a8e55Smrg tmp_deplibs= 61128c4a8e55Smrg for deplib in $deplibs; do 61138c4a8e55Smrg tmp_deplibs="$deplib $tmp_deplibs" 61148c4a8e55Smrg done 61158c4a8e55Smrg deplibs="$tmp_deplibs" 61168c4a8e55Smrg fi 61178c4a8e55Smrg 61188c4a8e55Smrg if test "$linkmode,$pass" = "lib,link" || 61198c4a8e55Smrg test "$linkmode,$pass" = "prog,scan"; then 61208c4a8e55Smrg libs="$deplibs" 61218c4a8e55Smrg deplibs= 61228c4a8e55Smrg fi 61238c4a8e55Smrg if test "$linkmode" = prog; then 61248c4a8e55Smrg case $pass in 61258c4a8e55Smrg dlopen) libs="$dlfiles" ;; 61268c4a8e55Smrg dlpreopen) libs="$dlprefiles" ;; 61278c4a8e55Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 61288c4a8e55Smrg esac 61298c4a8e55Smrg fi 61308c4a8e55Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 61318c4a8e55Smrg # Collect and forward deplibs of preopened libtool libs 61328c4a8e55Smrg for lib in $dlprefiles; do 61338c4a8e55Smrg # Ignore non-libtool-libs 61348c4a8e55Smrg dependency_libs= 6135bd23fbfaSmrg func_resolve_sysroot "$lib" 61368c4a8e55Smrg case $lib in 6137bd23fbfaSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 61388c4a8e55Smrg esac 61398c4a8e55Smrg 61408c4a8e55Smrg # Collect preopened libtool deplibs, except any this library 61418c4a8e55Smrg # has declared as weak libs 61428c4a8e55Smrg for deplib in $dependency_libs; do 6143706b6b52Smrg func_basename "$deplib" 6144706b6b52Smrg deplib_base=$func_basename_result 61458c4a8e55Smrg case " $weak_libs " in 61468c4a8e55Smrg *" $deplib_base "*) ;; 6147bd23fbfaSmrg *) func_append deplibs " $deplib" ;; 61488c4a8e55Smrg esac 61498c4a8e55Smrg done 61508c4a8e55Smrg done 61518c4a8e55Smrg libs="$dlprefiles" 61528c4a8e55Smrg fi 61538c4a8e55Smrg if test "$pass" = dlopen; then 61548c4a8e55Smrg # Collect dlpreopened libraries 61558c4a8e55Smrg save_deplibs="$deplibs" 61568c4a8e55Smrg deplibs= 61578c4a8e55Smrg fi 61588c4a8e55Smrg 61598c4a8e55Smrg for deplib in $libs; do 61608c4a8e55Smrg lib= 61618c4a8e55Smrg found=no 61628c4a8e55Smrg case $deplib in 61630597fb56Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 61640597fb56Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 61658c4a8e55Smrg if test "$linkmode,$pass" = "prog,link"; then 61668c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 61678c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 61688c4a8e55Smrg else 6169bd23fbfaSmrg func_append compiler_flags " $deplib" 61708c4a8e55Smrg if test "$linkmode" = lib ; then 61718c4a8e55Smrg case "$new_inherited_linker_flags " in 61728c4a8e55Smrg *" $deplib "*) ;; 6173bd23fbfaSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 61748c4a8e55Smrg esac 61758c4a8e55Smrg fi 61768c4a8e55Smrg fi 61778c4a8e55Smrg continue 61788c4a8e55Smrg ;; 61798c4a8e55Smrg -l*) 61808c4a8e55Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 61818c4a8e55Smrg func_warning "\`-l' is ignored for archives/objects" 61828c4a8e55Smrg continue 61838c4a8e55Smrg fi 61848c4a8e55Smrg func_stripname '-l' '' "$deplib" 61858c4a8e55Smrg name=$func_stripname_result 61868c4a8e55Smrg if test "$linkmode" = lib; then 61878c4a8e55Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 61888c4a8e55Smrg else 61898c4a8e55Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 61908c4a8e55Smrg fi 61918c4a8e55Smrg for searchdir in $searchdirs; do 61928c4a8e55Smrg for search_ext in .la $std_shrext .so .a; do 61938c4a8e55Smrg # Search the libtool library 61948c4a8e55Smrg lib="$searchdir/lib${name}${search_ext}" 61958c4a8e55Smrg if test -f "$lib"; then 61968c4a8e55Smrg if test "$search_ext" = ".la"; then 61978c4a8e55Smrg found=yes 61988c4a8e55Smrg else 61998c4a8e55Smrg found=no 62008c4a8e55Smrg fi 62018c4a8e55Smrg break 2 62028c4a8e55Smrg fi 62038c4a8e55Smrg done 62048c4a8e55Smrg done 62058c4a8e55Smrg if test "$found" != yes; then 62068c4a8e55Smrg # deplib doesn't seem to be a libtool library 62078c4a8e55Smrg if test "$linkmode,$pass" = "prog,link"; then 62088c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 62098c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 62108c4a8e55Smrg else 62118c4a8e55Smrg deplibs="$deplib $deplibs" 62128c4a8e55Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 62138c4a8e55Smrg fi 62148c4a8e55Smrg continue 62158c4a8e55Smrg else # deplib is a libtool library 62168c4a8e55Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 62178c4a8e55Smrg # We need to do some special things here, and not later. 62188c4a8e55Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 62198c4a8e55Smrg case " $predeps $postdeps " in 62208c4a8e55Smrg *" $deplib "*) 62218c4a8e55Smrg if func_lalib_p "$lib"; then 62228c4a8e55Smrg library_names= 62238c4a8e55Smrg old_library= 62248c4a8e55Smrg func_source "$lib" 62258c4a8e55Smrg for l in $old_library $library_names; do 62268c4a8e55Smrg ll="$l" 62278c4a8e55Smrg done 62288c4a8e55Smrg if test "X$ll" = "X$old_library" ; then # only static version available 62298c4a8e55Smrg found=no 62308c4a8e55Smrg func_dirname "$lib" "" "." 62318c4a8e55Smrg ladir="$func_dirname_result" 62328c4a8e55Smrg lib=$ladir/$old_library 62338c4a8e55Smrg if test "$linkmode,$pass" = "prog,link"; then 62348c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 62358c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 62368c4a8e55Smrg else 62378c4a8e55Smrg deplibs="$deplib $deplibs" 62388c4a8e55Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 62398c4a8e55Smrg fi 62408c4a8e55Smrg continue 62418c4a8e55Smrg fi 62428c4a8e55Smrg fi 62438c4a8e55Smrg ;; 62448c4a8e55Smrg *) ;; 62458c4a8e55Smrg esac 62468c4a8e55Smrg fi 62478c4a8e55Smrg fi 62488c4a8e55Smrg ;; # -l 62498c4a8e55Smrg *.ltframework) 62508c4a8e55Smrg if test "$linkmode,$pass" = "prog,link"; then 62518c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 62528c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 62538c4a8e55Smrg else 62548c4a8e55Smrg deplibs="$deplib $deplibs" 62558c4a8e55Smrg if test "$linkmode" = lib ; then 62568c4a8e55Smrg case "$new_inherited_linker_flags " in 62578c4a8e55Smrg *" $deplib "*) ;; 6258bd23fbfaSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 62598c4a8e55Smrg esac 62608c4a8e55Smrg fi 62618c4a8e55Smrg fi 62628c4a8e55Smrg continue 62638c4a8e55Smrg ;; 62648c4a8e55Smrg -L*) 62658c4a8e55Smrg case $linkmode in 62668c4a8e55Smrg lib) 62678c4a8e55Smrg deplibs="$deplib $deplibs" 62688c4a8e55Smrg test "$pass" = conv && continue 62698c4a8e55Smrg newdependency_libs="$deplib $newdependency_libs" 62708c4a8e55Smrg func_stripname '-L' '' "$deplib" 6271bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result" 6272bd23fbfaSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 62738c4a8e55Smrg ;; 62748c4a8e55Smrg prog) 62758c4a8e55Smrg if test "$pass" = conv; then 62768c4a8e55Smrg deplibs="$deplib $deplibs" 62778c4a8e55Smrg continue 62788c4a8e55Smrg fi 62798c4a8e55Smrg if test "$pass" = scan; then 62808c4a8e55Smrg deplibs="$deplib $deplibs" 62818c4a8e55Smrg else 62828c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 62838c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 62848c4a8e55Smrg fi 62858c4a8e55Smrg func_stripname '-L' '' "$deplib" 6286bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result" 6287bd23fbfaSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 62888c4a8e55Smrg ;; 62898c4a8e55Smrg *) 62908c4a8e55Smrg func_warning "\`-L' is ignored for archives/objects" 62918c4a8e55Smrg ;; 62928c4a8e55Smrg esac # linkmode 62938c4a8e55Smrg continue 62948c4a8e55Smrg ;; # -L 62958c4a8e55Smrg -R*) 62968c4a8e55Smrg if test "$pass" = link; then 62978c4a8e55Smrg func_stripname '-R' '' "$deplib" 6298bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result" 6299bd23fbfaSmrg dir=$func_resolve_sysroot_result 63008c4a8e55Smrg # Make sure the xrpath contains only unique directories. 63018c4a8e55Smrg case "$xrpath " in 63028c4a8e55Smrg *" $dir "*) ;; 6303bd23fbfaSmrg *) func_append xrpath " $dir" ;; 63048c4a8e55Smrg esac 63058c4a8e55Smrg fi 63068c4a8e55Smrg deplibs="$deplib $deplibs" 63078c4a8e55Smrg continue 63088c4a8e55Smrg ;; 6309bd23fbfaSmrg *.la) 6310bd23fbfaSmrg func_resolve_sysroot "$deplib" 6311bd23fbfaSmrg lib=$func_resolve_sysroot_result 6312bd23fbfaSmrg ;; 63138c4a8e55Smrg *.$libext) 63148c4a8e55Smrg if test "$pass" = conv; then 63158c4a8e55Smrg deplibs="$deplib $deplibs" 63168c4a8e55Smrg continue 63178c4a8e55Smrg fi 63188c4a8e55Smrg case $linkmode in 63198c4a8e55Smrg lib) 63208c4a8e55Smrg # Linking convenience modules into shared libraries is allowed, 63218c4a8e55Smrg # but linking other static libraries is non-portable. 63228c4a8e55Smrg case " $dlpreconveniencelibs " in 63238c4a8e55Smrg *" $deplib "*) ;; 63248c4a8e55Smrg *) 63258c4a8e55Smrg valid_a_lib=no 63268c4a8e55Smrg case $deplibs_check_method in 63278c4a8e55Smrg match_pattern*) 63288c4a8e55Smrg set dummy $deplibs_check_method; shift 63298c4a8e55Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 6330706b6b52Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 63318c4a8e55Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 63328c4a8e55Smrg valid_a_lib=yes 63338c4a8e55Smrg fi 63348c4a8e55Smrg ;; 63358c4a8e55Smrg pass_all) 63368c4a8e55Smrg valid_a_lib=yes 63378c4a8e55Smrg ;; 63388c4a8e55Smrg esac 63398c4a8e55Smrg if test "$valid_a_lib" != yes; then 6340706b6b52Smrg echo 63418c4a8e55Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 6342706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 6343706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 6344706b6b52Smrg echo "*** shared version of the library, which you do not appear to have" 6345706b6b52Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 6346706b6b52Smrg echo "*** that it is just a static archive that I should not use here." 63478c4a8e55Smrg else 6348706b6b52Smrg echo 63498c4a8e55Smrg $ECHO "*** Warning: Linking the shared library $output against the" 63508c4a8e55Smrg $ECHO "*** static library $deplib is not portable!" 63518c4a8e55Smrg deplibs="$deplib $deplibs" 63528c4a8e55Smrg fi 63538c4a8e55Smrg ;; 63548c4a8e55Smrg esac 63558c4a8e55Smrg continue 63568c4a8e55Smrg ;; 63578c4a8e55Smrg prog) 63588c4a8e55Smrg if test "$pass" != link; then 63598c4a8e55Smrg deplibs="$deplib $deplibs" 63608c4a8e55Smrg else 63618c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 63628c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 63638c4a8e55Smrg fi 63648c4a8e55Smrg continue 63658c4a8e55Smrg ;; 63668c4a8e55Smrg esac # linkmode 63678c4a8e55Smrg ;; # *.$libext 63688c4a8e55Smrg *.lo | *.$objext) 63698c4a8e55Smrg if test "$pass" = conv; then 63708c4a8e55Smrg deplibs="$deplib $deplibs" 63718c4a8e55Smrg elif test "$linkmode" = prog; then 63728c4a8e55Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 63738c4a8e55Smrg # If there is no dlopen support or we're linking statically, 63748c4a8e55Smrg # we need to preload. 6375bd23fbfaSmrg func_append newdlprefiles " $deplib" 63768c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 63778c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 63788c4a8e55Smrg else 6379bd23fbfaSmrg func_append newdlfiles " $deplib" 63808c4a8e55Smrg fi 63818c4a8e55Smrg fi 63828c4a8e55Smrg continue 63838c4a8e55Smrg ;; 63848c4a8e55Smrg %DEPLIBS%) 63858c4a8e55Smrg alldeplibs=yes 63868c4a8e55Smrg continue 63878c4a8e55Smrg ;; 63888c4a8e55Smrg esac # case $deplib 63898c4a8e55Smrg 63908c4a8e55Smrg if test "$found" = yes || test -f "$lib"; then : 63918c4a8e55Smrg else 63928c4a8e55Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 63938c4a8e55Smrg fi 63948c4a8e55Smrg 63958c4a8e55Smrg # Check to see that this really is a libtool archive. 63968c4a8e55Smrg func_lalib_unsafe_p "$lib" \ 63978c4a8e55Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 63988c4a8e55Smrg 63998c4a8e55Smrg func_dirname "$lib" "" "." 64008c4a8e55Smrg ladir="$func_dirname_result" 64018c4a8e55Smrg 64028c4a8e55Smrg dlname= 64038c4a8e55Smrg dlopen= 64048c4a8e55Smrg dlpreopen= 64058c4a8e55Smrg libdir= 64068c4a8e55Smrg library_names= 64078c4a8e55Smrg old_library= 64088c4a8e55Smrg inherited_linker_flags= 64098c4a8e55Smrg # If the library was installed with an old release of libtool, 64108c4a8e55Smrg # it will not redefine variables installed, or shouldnotlink 64118c4a8e55Smrg installed=yes 64128c4a8e55Smrg shouldnotlink=no 64138c4a8e55Smrg avoidtemprpath= 64148c4a8e55Smrg 64158c4a8e55Smrg 64168c4a8e55Smrg # Read the .la file 64178c4a8e55Smrg func_source "$lib" 64188c4a8e55Smrg 64198c4a8e55Smrg # Convert "-framework foo" to "foo.ltframework" 64208c4a8e55Smrg if test -n "$inherited_linker_flags"; then 6421706b6b52Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 64228c4a8e55Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 64238c4a8e55Smrg case " $new_inherited_linker_flags " in 64248c4a8e55Smrg *" $tmp_inherited_linker_flag "*) ;; 6425bd23fbfaSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 64268c4a8e55Smrg esac 64278c4a8e55Smrg done 64288c4a8e55Smrg fi 6429706b6b52Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 64308c4a8e55Smrg if test "$linkmode,$pass" = "lib,link" || 64318c4a8e55Smrg test "$linkmode,$pass" = "prog,scan" || 64328c4a8e55Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 6433bd23fbfaSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 6434bd23fbfaSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 64358c4a8e55Smrg fi 64368c4a8e55Smrg 64378c4a8e55Smrg if test "$pass" = conv; then 64388c4a8e55Smrg # Only check for convenience libraries 64398c4a8e55Smrg deplibs="$lib $deplibs" 64408c4a8e55Smrg if test -z "$libdir"; then 64418c4a8e55Smrg if test -z "$old_library"; then 64428c4a8e55Smrg func_fatal_error "cannot find name of link library for \`$lib'" 64438c4a8e55Smrg fi 64448c4a8e55Smrg # It is a libtool convenience library, so add in its objects. 6445bd23fbfaSmrg func_append convenience " $ladir/$objdir/$old_library" 6446bd23fbfaSmrg func_append old_convenience " $ladir/$objdir/$old_library" 64478c4a8e55Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 64488c4a8e55Smrg func_fatal_error "\`$lib' is not a convenience library" 64498c4a8e55Smrg fi 64508c4a8e55Smrg tmp_libs= 64518c4a8e55Smrg for deplib in $dependency_libs; do 64528c4a8e55Smrg deplibs="$deplib $deplibs" 6453bd23fbfaSmrg if $opt_preserve_dup_deps ; then 64548c4a8e55Smrg case "$tmp_libs " in 6455bd23fbfaSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 64568c4a8e55Smrg esac 64578c4a8e55Smrg fi 6458bd23fbfaSmrg func_append tmp_libs " $deplib" 64598c4a8e55Smrg done 64608c4a8e55Smrg continue 64618c4a8e55Smrg fi # $pass = conv 64628c4a8e55Smrg 64638c4a8e55Smrg 64648c4a8e55Smrg # Get the name of the library we link against. 64658c4a8e55Smrg linklib= 6466bd23fbfaSmrg if test -n "$old_library" && 6467bd23fbfaSmrg { test "$prefer_static_libs" = yes || 6468bd23fbfaSmrg test "$prefer_static_libs,$installed" = "built,no"; }; then 6469bd23fbfaSmrg linklib=$old_library 6470bd23fbfaSmrg else 6471bd23fbfaSmrg for l in $old_library $library_names; do 6472bd23fbfaSmrg linklib="$l" 6473bd23fbfaSmrg done 6474bd23fbfaSmrg fi 64758c4a8e55Smrg if test -z "$linklib"; then 64768c4a8e55Smrg func_fatal_error "cannot find name of link library for \`$lib'" 64778c4a8e55Smrg fi 64788c4a8e55Smrg 64798c4a8e55Smrg # This library was specified with -dlopen. 64808c4a8e55Smrg if test "$pass" = dlopen; then 64818c4a8e55Smrg if test -z "$libdir"; then 64828c4a8e55Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 64838c4a8e55Smrg fi 64848c4a8e55Smrg if test -z "$dlname" || 64858c4a8e55Smrg test "$dlopen_support" != yes || 64868c4a8e55Smrg test "$build_libtool_libs" = no; then 64878c4a8e55Smrg # If there is no dlname, no dlopen support or we're linking 64888c4a8e55Smrg # statically, we need to preload. We also need to preload any 64898c4a8e55Smrg # dependent libraries so libltdl's deplib preloader doesn't 64908c4a8e55Smrg # bomb out in the load deplibs phase. 6491bd23fbfaSmrg func_append dlprefiles " $lib $dependency_libs" 64928c4a8e55Smrg else 6493bd23fbfaSmrg func_append newdlfiles " $lib" 64948c4a8e55Smrg fi 64958c4a8e55Smrg continue 64968c4a8e55Smrg fi # $pass = dlopen 64978c4a8e55Smrg 64988c4a8e55Smrg # We need an absolute path. 64998c4a8e55Smrg case $ladir in 65008c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 65018c4a8e55Smrg *) 65028c4a8e55Smrg abs_ladir=`cd "$ladir" && pwd` 65038c4a8e55Smrg if test -z "$abs_ladir"; then 65048c4a8e55Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 65058c4a8e55Smrg func_warning "passing it literally to the linker, although it might fail" 65068c4a8e55Smrg abs_ladir="$ladir" 65078c4a8e55Smrg fi 65088c4a8e55Smrg ;; 65098c4a8e55Smrg esac 65108c4a8e55Smrg func_basename "$lib" 65118c4a8e55Smrg laname="$func_basename_result" 65128c4a8e55Smrg 65138c4a8e55Smrg # Find the relevant object directory and library name. 65148c4a8e55Smrg if test "X$installed" = Xyes; then 6515bd23fbfaSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 65168c4a8e55Smrg func_warning "library \`$lib' was moved." 65178c4a8e55Smrg dir="$ladir" 65188c4a8e55Smrg absdir="$abs_ladir" 65198c4a8e55Smrg libdir="$abs_ladir" 65208c4a8e55Smrg else 6521bd23fbfaSmrg dir="$lt_sysroot$libdir" 6522bd23fbfaSmrg absdir="$lt_sysroot$libdir" 65238c4a8e55Smrg fi 65248c4a8e55Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 65258c4a8e55Smrg else 65268c4a8e55Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 65278c4a8e55Smrg dir="$ladir" 65288c4a8e55Smrg absdir="$abs_ladir" 65298c4a8e55Smrg # Remove this search path later 6530bd23fbfaSmrg func_append notinst_path " $abs_ladir" 65318c4a8e55Smrg else 65328c4a8e55Smrg dir="$ladir/$objdir" 65338c4a8e55Smrg absdir="$abs_ladir/$objdir" 65348c4a8e55Smrg # Remove this search path later 6535bd23fbfaSmrg func_append notinst_path " $abs_ladir" 65368c4a8e55Smrg fi 65378c4a8e55Smrg fi # $installed = yes 65388c4a8e55Smrg func_stripname 'lib' '.la' "$laname" 65398c4a8e55Smrg name=$func_stripname_result 65408c4a8e55Smrg 65418c4a8e55Smrg # This library was specified with -dlpreopen. 65428c4a8e55Smrg if test "$pass" = dlpreopen; then 65438c4a8e55Smrg if test -z "$libdir" && test "$linkmode" = prog; then 65448c4a8e55Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 65458c4a8e55Smrg fi 6546bd23fbfaSmrg case "$host" in 6547bd23fbfaSmrg # special handling for platforms with PE-DLLs. 6548bd23fbfaSmrg *cygwin* | *mingw* | *cegcc* ) 6549bd23fbfaSmrg # Linker will automatically link against shared library if both 6550bd23fbfaSmrg # static and shared are present. Therefore, ensure we extract 6551bd23fbfaSmrg # symbols from the import library if a shared library is present 6552bd23fbfaSmrg # (otherwise, the dlopen module name will be incorrect). We do 6553bd23fbfaSmrg # this by putting the import library name into $newdlprefiles. 6554bd23fbfaSmrg # We recover the dlopen module name by 'saving' the la file 6555bd23fbfaSmrg # name in a special purpose variable, and (later) extracting the 6556bd23fbfaSmrg # dlname from the la file. 6557bd23fbfaSmrg if test -n "$dlname"; then 6558bd23fbfaSmrg func_tr_sh "$dir/$linklib" 6559bd23fbfaSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 6560bd23fbfaSmrg func_append newdlprefiles " $dir/$linklib" 6561bd23fbfaSmrg else 6562bd23fbfaSmrg func_append newdlprefiles " $dir/$old_library" 6563bd23fbfaSmrg # Keep a list of preopened convenience libraries to check 6564bd23fbfaSmrg # that they are being used correctly in the link pass. 6565bd23fbfaSmrg test -z "$libdir" && \ 6566bd23fbfaSmrg func_append dlpreconveniencelibs " $dir/$old_library" 6567bd23fbfaSmrg fi 6568bd23fbfaSmrg ;; 6569bd23fbfaSmrg * ) 6570bd23fbfaSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 6571bd23fbfaSmrg # are required to link). 6572bd23fbfaSmrg if test -n "$old_library"; then 6573bd23fbfaSmrg func_append newdlprefiles " $dir/$old_library" 6574bd23fbfaSmrg # Keep a list of preopened convenience libraries to check 6575bd23fbfaSmrg # that they are being used correctly in the link pass. 6576bd23fbfaSmrg test -z "$libdir" && \ 6577bd23fbfaSmrg func_append dlpreconveniencelibs " $dir/$old_library" 6578bd23fbfaSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 6579bd23fbfaSmrg elif test -n "$dlname"; then 6580bd23fbfaSmrg func_append newdlprefiles " $dir/$dlname" 6581bd23fbfaSmrg else 6582bd23fbfaSmrg func_append newdlprefiles " $dir/$linklib" 6583bd23fbfaSmrg fi 6584bd23fbfaSmrg ;; 6585bd23fbfaSmrg esac 65868c4a8e55Smrg fi # $pass = dlpreopen 65878c4a8e55Smrg 65888c4a8e55Smrg if test -z "$libdir"; then 65898c4a8e55Smrg # Link the convenience library 65908c4a8e55Smrg if test "$linkmode" = lib; then 65918c4a8e55Smrg deplibs="$dir/$old_library $deplibs" 65928c4a8e55Smrg elif test "$linkmode,$pass" = "prog,link"; then 65938c4a8e55Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 65948c4a8e55Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 65958c4a8e55Smrg else 65968c4a8e55Smrg deplibs="$lib $deplibs" # used for prog,scan pass 65978c4a8e55Smrg fi 65988c4a8e55Smrg continue 65998c4a8e55Smrg fi 66008c4a8e55Smrg 66018c4a8e55Smrg 66028c4a8e55Smrg if test "$linkmode" = prog && test "$pass" != link; then 6603bd23fbfaSmrg func_append newlib_search_path " $ladir" 66048c4a8e55Smrg deplibs="$lib $deplibs" 66058c4a8e55Smrg 66068c4a8e55Smrg linkalldeplibs=no 66078c4a8e55Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 66088c4a8e55Smrg test "$build_libtool_libs" = no; then 66098c4a8e55Smrg linkalldeplibs=yes 66108c4a8e55Smrg fi 66118c4a8e55Smrg 66128c4a8e55Smrg tmp_libs= 66138c4a8e55Smrg for deplib in $dependency_libs; do 66148c4a8e55Smrg case $deplib in 66158c4a8e55Smrg -L*) func_stripname '-L' '' "$deplib" 6616bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result" 6617bd23fbfaSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 66188c4a8e55Smrg ;; 66198c4a8e55Smrg esac 66208c4a8e55Smrg # Need to link against all dependency_libs? 66218c4a8e55Smrg if test "$linkalldeplibs" = yes; then 66228c4a8e55Smrg deplibs="$deplib $deplibs" 66238c4a8e55Smrg else 66248c4a8e55Smrg # Need to hardcode shared library paths 66258c4a8e55Smrg # or/and link against static libraries 66268c4a8e55Smrg newdependency_libs="$deplib $newdependency_libs" 66278c4a8e55Smrg fi 6628bd23fbfaSmrg if $opt_preserve_dup_deps ; then 66298c4a8e55Smrg case "$tmp_libs " in 6630bd23fbfaSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 66318c4a8e55Smrg esac 66328c4a8e55Smrg fi 6633bd23fbfaSmrg func_append tmp_libs " $deplib" 66348c4a8e55Smrg done # for deplib 66358c4a8e55Smrg continue 66368c4a8e55Smrg fi # $linkmode = prog... 66378c4a8e55Smrg 66388c4a8e55Smrg if test "$linkmode,$pass" = "prog,link"; then 66398c4a8e55Smrg if test -n "$library_names" && 66408c4a8e55Smrg { { test "$prefer_static_libs" = no || 66418c4a8e55Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 66428c4a8e55Smrg test -z "$old_library"; }; then 66438c4a8e55Smrg # We need to hardcode the library path 66448c4a8e55Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 66458c4a8e55Smrg # Make sure the rpath contains only unique directories. 66468c4a8e55Smrg case "$temp_rpath:" in 66478c4a8e55Smrg *"$absdir:"*) ;; 6648bd23fbfaSmrg *) func_append temp_rpath "$absdir:" ;; 66498c4a8e55Smrg esac 66508c4a8e55Smrg fi 66518c4a8e55Smrg 66528c4a8e55Smrg # Hardcode the library path. 66538c4a8e55Smrg # Skip directories that are in the system default run-time 66548c4a8e55Smrg # search path. 66558c4a8e55Smrg case " $sys_lib_dlsearch_path " in 66568c4a8e55Smrg *" $absdir "*) ;; 66578c4a8e55Smrg *) 66588c4a8e55Smrg case "$compile_rpath " in 66598c4a8e55Smrg *" $absdir "*) ;; 6660bd23fbfaSmrg *) func_append compile_rpath " $absdir" ;; 66618c4a8e55Smrg esac 66628c4a8e55Smrg ;; 66638c4a8e55Smrg esac 66648c4a8e55Smrg case " $sys_lib_dlsearch_path " in 66658c4a8e55Smrg *" $libdir "*) ;; 66668c4a8e55Smrg *) 66678c4a8e55Smrg case "$finalize_rpath " in 66688c4a8e55Smrg *" $libdir "*) ;; 6669bd23fbfaSmrg *) func_append finalize_rpath " $libdir" ;; 66708c4a8e55Smrg esac 66718c4a8e55Smrg ;; 66728c4a8e55Smrg esac 66738c4a8e55Smrg fi # $linkmode,$pass = prog,link... 66748c4a8e55Smrg 66758c4a8e55Smrg if test "$alldeplibs" = yes && 66768c4a8e55Smrg { test "$deplibs_check_method" = pass_all || 66778c4a8e55Smrg { test "$build_libtool_libs" = yes && 66788c4a8e55Smrg test -n "$library_names"; }; }; then 66798c4a8e55Smrg # We only need to search for static libraries 66808c4a8e55Smrg continue 66818c4a8e55Smrg fi 66828c4a8e55Smrg fi 66838c4a8e55Smrg 66848c4a8e55Smrg link_static=no # Whether the deplib will be linked statically 66858c4a8e55Smrg use_static_libs=$prefer_static_libs 66868c4a8e55Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 66878c4a8e55Smrg use_static_libs=no 66888c4a8e55Smrg fi 66898c4a8e55Smrg if test -n "$library_names" && 66908c4a8e55Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 66918c4a8e55Smrg case $host in 66928c4a8e55Smrg *cygwin* | *mingw* | *cegcc*) 66938c4a8e55Smrg # No point in relinking DLLs because paths are not encoded 6694bd23fbfaSmrg func_append notinst_deplibs " $lib" 66958c4a8e55Smrg need_relink=no 66968c4a8e55Smrg ;; 66978c4a8e55Smrg *) 66988c4a8e55Smrg if test "$installed" = no; then 6699bd23fbfaSmrg func_append notinst_deplibs " $lib" 67008c4a8e55Smrg need_relink=yes 67018c4a8e55Smrg fi 67028c4a8e55Smrg ;; 67038c4a8e55Smrg esac 67048c4a8e55Smrg # This is a shared library 67058c4a8e55Smrg 67068c4a8e55Smrg # Warn about portability, can't link against -module's on some 67078c4a8e55Smrg # systems (darwin). Don't bleat about dlopened modules though! 67088c4a8e55Smrg dlopenmodule="" 67098c4a8e55Smrg for dlpremoduletest in $dlprefiles; do 67108c4a8e55Smrg if test "X$dlpremoduletest" = "X$lib"; then 67118c4a8e55Smrg dlopenmodule="$dlpremoduletest" 67128c4a8e55Smrg break 67138c4a8e55Smrg fi 67148c4a8e55Smrg done 67158c4a8e55Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 6716706b6b52Smrg echo 67178c4a8e55Smrg if test "$linkmode" = prog; then 67188c4a8e55Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 67198c4a8e55Smrg else 67208c4a8e55Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 67218c4a8e55Smrg fi 67228c4a8e55Smrg $ECHO "*** $linklib is not portable!" 67238c4a8e55Smrg fi 67248c4a8e55Smrg if test "$linkmode" = lib && 67258c4a8e55Smrg test "$hardcode_into_libs" = yes; then 67268c4a8e55Smrg # Hardcode the library path. 67278c4a8e55Smrg # Skip directories that are in the system default run-time 67288c4a8e55Smrg # search path. 67298c4a8e55Smrg case " $sys_lib_dlsearch_path " in 67308c4a8e55Smrg *" $absdir "*) ;; 67318c4a8e55Smrg *) 67328c4a8e55Smrg case "$compile_rpath " in 67338c4a8e55Smrg *" $absdir "*) ;; 6734bd23fbfaSmrg *) func_append compile_rpath " $absdir" ;; 67358c4a8e55Smrg esac 67368c4a8e55Smrg ;; 67378c4a8e55Smrg esac 67388c4a8e55Smrg case " $sys_lib_dlsearch_path " in 67398c4a8e55Smrg *" $libdir "*) ;; 67408c4a8e55Smrg *) 67418c4a8e55Smrg case "$finalize_rpath " in 67428c4a8e55Smrg *" $libdir "*) ;; 6743bd23fbfaSmrg *) func_append finalize_rpath " $libdir" ;; 67448c4a8e55Smrg esac 67458c4a8e55Smrg ;; 67468c4a8e55Smrg esac 67478c4a8e55Smrg fi 67488c4a8e55Smrg 67498c4a8e55Smrg if test -n "$old_archive_from_expsyms_cmds"; then 67508c4a8e55Smrg # figure out the soname 67518c4a8e55Smrg set dummy $library_names 67528c4a8e55Smrg shift 67538c4a8e55Smrg realname="$1" 67548c4a8e55Smrg shift 67558c4a8e55Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 67568c4a8e55Smrg # use dlname if we got it. it's perfectly good, no? 67578c4a8e55Smrg if test -n "$dlname"; then 67588c4a8e55Smrg soname="$dlname" 67598c4a8e55Smrg elif test -n "$soname_spec"; then 67608c4a8e55Smrg # bleh windows 67618c4a8e55Smrg case $host in 67628c4a8e55Smrg *cygwin* | mingw* | *cegcc*) 67638c4a8e55Smrg func_arith $current - $age 67648c4a8e55Smrg major=$func_arith_result 67658c4a8e55Smrg versuffix="-$major" 67668c4a8e55Smrg ;; 67678c4a8e55Smrg esac 67688c4a8e55Smrg eval soname=\"$soname_spec\" 67698c4a8e55Smrg else 67708c4a8e55Smrg soname="$realname" 67718c4a8e55Smrg fi 67728c4a8e55Smrg 67738c4a8e55Smrg # Make a new name for the extract_expsyms_cmds to use 67748c4a8e55Smrg soroot="$soname" 67758c4a8e55Smrg func_basename "$soroot" 67768c4a8e55Smrg soname="$func_basename_result" 67778c4a8e55Smrg func_stripname 'lib' '.dll' "$soname" 67788c4a8e55Smrg newlib=libimp-$func_stripname_result.a 67798c4a8e55Smrg 67808c4a8e55Smrg # If the library has no export list, then create one now 67818c4a8e55Smrg if test -f "$output_objdir/$soname-def"; then : 67828c4a8e55Smrg else 67838c4a8e55Smrg func_verbose "extracting exported symbol list from \`$soname'" 67848c4a8e55Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 67858c4a8e55Smrg fi 67868c4a8e55Smrg 67878c4a8e55Smrg # Create $newlib 67888c4a8e55Smrg if test -f "$output_objdir/$newlib"; then :; else 67898c4a8e55Smrg func_verbose "generating import library for \`$soname'" 67908c4a8e55Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 67918c4a8e55Smrg fi 67928c4a8e55Smrg # make sure the library variables are pointing to the new library 67938c4a8e55Smrg dir=$output_objdir 67948c4a8e55Smrg linklib=$newlib 67958c4a8e55Smrg fi # test -n "$old_archive_from_expsyms_cmds" 67968c4a8e55Smrg 6797bd23fbfaSmrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 67988c4a8e55Smrg add_shlibpath= 67998c4a8e55Smrg add_dir= 68008c4a8e55Smrg add= 68018c4a8e55Smrg lib_linked=yes 68028c4a8e55Smrg case $hardcode_action in 68038c4a8e55Smrg immediate | unsupported) 68048c4a8e55Smrg if test "$hardcode_direct" = no; then 68058c4a8e55Smrg add="$dir/$linklib" 68068c4a8e55Smrg case $host in 68078c4a8e55Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 68088c4a8e55Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 68098c4a8e55Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 68108c4a8e55Smrg *-*-unixware7*) add_dir="-L$dir" ;; 68118c4a8e55Smrg *-*-darwin* ) 68128c4a8e55Smrg # if the lib is a (non-dlopened) module then we can not 68138c4a8e55Smrg # link against it, someone is ignoring the earlier warnings 68148c4a8e55Smrg if /usr/bin/file -L $add 2> /dev/null | 68158c4a8e55Smrg $GREP ": [^:]* bundle" >/dev/null ; then 68168c4a8e55Smrg if test "X$dlopenmodule" != "X$lib"; then 68178c4a8e55Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 68188c4a8e55Smrg if test -z "$old_library" ; then 6819706b6b52Smrg echo 6820706b6b52Smrg echo "*** And there doesn't seem to be a static archive available" 6821706b6b52Smrg echo "*** The link will probably fail, sorry" 68228c4a8e55Smrg else 68238c4a8e55Smrg add="$dir/$old_library" 68248c4a8e55Smrg fi 68258c4a8e55Smrg elif test -n "$old_library"; then 68268c4a8e55Smrg add="$dir/$old_library" 68278c4a8e55Smrg fi 68288c4a8e55Smrg fi 68298c4a8e55Smrg esac 68308c4a8e55Smrg elif test "$hardcode_minus_L" = no; then 68318c4a8e55Smrg case $host in 68328c4a8e55Smrg *-*-sunos*) add_shlibpath="$dir" ;; 68338c4a8e55Smrg esac 68348c4a8e55Smrg add_dir="-L$dir" 68358c4a8e55Smrg add="-l$name" 68368c4a8e55Smrg elif test "$hardcode_shlibpath_var" = no; then 68378c4a8e55Smrg add_shlibpath="$dir" 68388c4a8e55Smrg add="-l$name" 68398c4a8e55Smrg else 68408c4a8e55Smrg lib_linked=no 68418c4a8e55Smrg fi 68428c4a8e55Smrg ;; 68438c4a8e55Smrg relink) 68448c4a8e55Smrg if test "$hardcode_direct" = yes && 68458c4a8e55Smrg test "$hardcode_direct_absolute" = no; then 68468c4a8e55Smrg add="$dir/$linklib" 68478c4a8e55Smrg elif test "$hardcode_minus_L" = yes; then 68480597fb56Smrg add_dir="-L$absdir" 68498c4a8e55Smrg # Try looking first in the location we're being installed to. 68508c4a8e55Smrg if test -n "$inst_prefix_dir"; then 68518c4a8e55Smrg case $libdir in 68528c4a8e55Smrg [\\/]*) 6853bd23fbfaSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 68548c4a8e55Smrg ;; 68558c4a8e55Smrg esac 68568c4a8e55Smrg fi 68578c4a8e55Smrg add="-l$name" 68588c4a8e55Smrg elif test "$hardcode_shlibpath_var" = yes; then 68598c4a8e55Smrg add_shlibpath="$dir" 68608c4a8e55Smrg add="-l$name" 68618c4a8e55Smrg else 68628c4a8e55Smrg lib_linked=no 68638c4a8e55Smrg fi 68648c4a8e55Smrg ;; 68658c4a8e55Smrg *) lib_linked=no ;; 68668c4a8e55Smrg esac 68678c4a8e55Smrg 68688c4a8e55Smrg if test "$lib_linked" != yes; then 68698c4a8e55Smrg func_fatal_configuration "unsupported hardcode properties" 68708c4a8e55Smrg fi 68718c4a8e55Smrg 68728c4a8e55Smrg if test -n "$add_shlibpath"; then 68738c4a8e55Smrg case :$compile_shlibpath: in 68748c4a8e55Smrg *":$add_shlibpath:"*) ;; 6875bd23fbfaSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 68768c4a8e55Smrg esac 68778c4a8e55Smrg fi 68788c4a8e55Smrg if test "$linkmode" = prog; then 68798c4a8e55Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 68808c4a8e55Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 68818c4a8e55Smrg else 68828c4a8e55Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 68838c4a8e55Smrg test -n "$add" && deplibs="$add $deplibs" 68848c4a8e55Smrg if test "$hardcode_direct" != yes && 68858c4a8e55Smrg test "$hardcode_minus_L" != yes && 68868c4a8e55Smrg test "$hardcode_shlibpath_var" = yes; then 68878c4a8e55Smrg case :$finalize_shlibpath: in 68888c4a8e55Smrg *":$libdir:"*) ;; 6889bd23fbfaSmrg *) func_append finalize_shlibpath "$libdir:" ;; 68908c4a8e55Smrg esac 68918c4a8e55Smrg fi 68928c4a8e55Smrg fi 68938c4a8e55Smrg fi 68948c4a8e55Smrg 6895bd23fbfaSmrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 68968c4a8e55Smrg add_shlibpath= 68978c4a8e55Smrg add_dir= 68988c4a8e55Smrg add= 68998c4a8e55Smrg # Finalize command for both is simple: just hardcode it. 69008c4a8e55Smrg if test "$hardcode_direct" = yes && 69018c4a8e55Smrg test "$hardcode_direct_absolute" = no; then 69028c4a8e55Smrg add="$libdir/$linklib" 69038c4a8e55Smrg elif test "$hardcode_minus_L" = yes; then 69048c4a8e55Smrg add_dir="-L$libdir" 69058c4a8e55Smrg add="-l$name" 69068c4a8e55Smrg elif test "$hardcode_shlibpath_var" = yes; then 69078c4a8e55Smrg case :$finalize_shlibpath: in 69088c4a8e55Smrg *":$libdir:"*) ;; 6909bd23fbfaSmrg *) func_append finalize_shlibpath "$libdir:" ;; 69108c4a8e55Smrg esac 69118c4a8e55Smrg add="-l$name" 69128c4a8e55Smrg elif test "$hardcode_automatic" = yes; then 69138c4a8e55Smrg if test -n "$inst_prefix_dir" && 69148c4a8e55Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 69158c4a8e55Smrg add="$inst_prefix_dir$libdir/$linklib" 69168c4a8e55Smrg else 69178c4a8e55Smrg add="$libdir/$linklib" 69188c4a8e55Smrg fi 69198c4a8e55Smrg else 69208c4a8e55Smrg # We cannot seem to hardcode it, guess we'll fake it. 69218c4a8e55Smrg add_dir="-L$libdir" 69228c4a8e55Smrg # Try looking first in the location we're being installed to. 69238c4a8e55Smrg if test -n "$inst_prefix_dir"; then 69248c4a8e55Smrg case $libdir in 69258c4a8e55Smrg [\\/]*) 6926bd23fbfaSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 69278c4a8e55Smrg ;; 69288c4a8e55Smrg esac 69298c4a8e55Smrg fi 69308c4a8e55Smrg add="-l$name" 69318c4a8e55Smrg fi 69328c4a8e55Smrg 69338c4a8e55Smrg if test "$linkmode" = prog; then 69348c4a8e55Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 69358c4a8e55Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 69368c4a8e55Smrg else 69378c4a8e55Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 69388c4a8e55Smrg test -n "$add" && deplibs="$add $deplibs" 69398c4a8e55Smrg fi 69408c4a8e55Smrg fi 69418c4a8e55Smrg elif test "$linkmode" = prog; then 69428c4a8e55Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 69438c4a8e55Smrg # is not unsupported. This is valid on all known static and 69448c4a8e55Smrg # shared platforms. 69458c4a8e55Smrg if test "$hardcode_direct" != unsupported; then 69468c4a8e55Smrg test -n "$old_library" && linklib="$old_library" 69478c4a8e55Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 69488c4a8e55Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 69498c4a8e55Smrg else 69508c4a8e55Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 69518c4a8e55Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 69528c4a8e55Smrg fi 69538c4a8e55Smrg elif test "$build_libtool_libs" = yes; then 69548c4a8e55Smrg # Not a shared library 69558c4a8e55Smrg if test "$deplibs_check_method" != pass_all; then 69568c4a8e55Smrg # We're trying link a shared library against a static one 69578c4a8e55Smrg # but the system doesn't support it. 69588c4a8e55Smrg 69598c4a8e55Smrg # Just print a warning and add the library to dependency_libs so 69608c4a8e55Smrg # that the program can be linked against the static library. 6961706b6b52Smrg echo 69628c4a8e55Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 6963706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 6964706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 6965706b6b52Smrg echo "*** shared version of the library, which you do not appear to have." 69668c4a8e55Smrg if test "$module" = yes; then 6967706b6b52Smrg echo "*** But as you try to build a module library, libtool will still create " 6968706b6b52Smrg echo "*** a static module, that should work as long as the dlopening application" 6969706b6b52Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 69708c4a8e55Smrg if test -z "$global_symbol_pipe"; then 6971706b6b52Smrg echo 6972706b6b52Smrg echo "*** However, this would only work if libtool was able to extract symbol" 6973706b6b52Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 6974706b6b52Smrg echo "*** not find such a program. So, this module is probably useless." 6975706b6b52Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 69768c4a8e55Smrg fi 69778c4a8e55Smrg if test "$build_old_libs" = no; then 69788c4a8e55Smrg build_libtool_libs=module 69798c4a8e55Smrg build_old_libs=yes 69808c4a8e55Smrg else 69818c4a8e55Smrg build_libtool_libs=no 69828c4a8e55Smrg fi 69838c4a8e55Smrg fi 69848c4a8e55Smrg else 69858c4a8e55Smrg deplibs="$dir/$old_library $deplibs" 69868c4a8e55Smrg link_static=yes 69878c4a8e55Smrg fi 69888c4a8e55Smrg fi # link shared/static library? 69898c4a8e55Smrg 69908c4a8e55Smrg if test "$linkmode" = lib; then 69918c4a8e55Smrg if test -n "$dependency_libs" && 69928c4a8e55Smrg { test "$hardcode_into_libs" != yes || 69938c4a8e55Smrg test "$build_old_libs" = yes || 69948c4a8e55Smrg test "$link_static" = yes; }; then 69958c4a8e55Smrg # Extract -R from dependency_libs 69968c4a8e55Smrg temp_deplibs= 69978c4a8e55Smrg for libdir in $dependency_libs; do 69988c4a8e55Smrg case $libdir in 69998c4a8e55Smrg -R*) func_stripname '-R' '' "$libdir" 70008c4a8e55Smrg temp_xrpath=$func_stripname_result 70018c4a8e55Smrg case " $xrpath " in 70028c4a8e55Smrg *" $temp_xrpath "*) ;; 7003bd23fbfaSmrg *) func_append xrpath " $temp_xrpath";; 70048c4a8e55Smrg esac;; 7005bd23fbfaSmrg *) func_append temp_deplibs " $libdir";; 70068c4a8e55Smrg esac 70078c4a8e55Smrg done 70088c4a8e55Smrg dependency_libs="$temp_deplibs" 70098c4a8e55Smrg fi 70108c4a8e55Smrg 7011bd23fbfaSmrg func_append newlib_search_path " $absdir" 70128c4a8e55Smrg # Link against this library 70138c4a8e55Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 70148c4a8e55Smrg # ... and its dependency_libs 70158c4a8e55Smrg tmp_libs= 70168c4a8e55Smrg for deplib in $dependency_libs; do 70178c4a8e55Smrg newdependency_libs="$deplib $newdependency_libs" 7018bd23fbfaSmrg case $deplib in 7019bd23fbfaSmrg -L*) func_stripname '-L' '' "$deplib" 7020bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result";; 7021bd23fbfaSmrg *) func_resolve_sysroot "$deplib" ;; 7022bd23fbfaSmrg esac 7023bd23fbfaSmrg if $opt_preserve_dup_deps ; then 70248c4a8e55Smrg case "$tmp_libs " in 7025bd23fbfaSmrg *" $func_resolve_sysroot_result "*) 7026bd23fbfaSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 70278c4a8e55Smrg esac 70288c4a8e55Smrg fi 7029bd23fbfaSmrg func_append tmp_libs " $func_resolve_sysroot_result" 70308c4a8e55Smrg done 70318c4a8e55Smrg 70328c4a8e55Smrg if test "$link_all_deplibs" != no; then 70338c4a8e55Smrg # Add the search paths of all dependency libraries 70348c4a8e55Smrg for deplib in $dependency_libs; do 7035706b6b52Smrg path= 70368c4a8e55Smrg case $deplib in 70378c4a8e55Smrg -L*) path="$deplib" ;; 70388c4a8e55Smrg *.la) 7039bd23fbfaSmrg func_resolve_sysroot "$deplib" 7040bd23fbfaSmrg deplib=$func_resolve_sysroot_result 70418c4a8e55Smrg func_dirname "$deplib" "" "." 7042bd23fbfaSmrg dir=$func_dirname_result 70438c4a8e55Smrg # We need an absolute path. 70448c4a8e55Smrg case $dir in 70458c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 70468c4a8e55Smrg *) 70478c4a8e55Smrg absdir=`cd "$dir" && pwd` 70488c4a8e55Smrg if test -z "$absdir"; then 70498c4a8e55Smrg func_warning "cannot determine absolute directory name of \`$dir'" 70508c4a8e55Smrg absdir="$dir" 70518c4a8e55Smrg fi 70528c4a8e55Smrg ;; 70538c4a8e55Smrg esac 70548c4a8e55Smrg if $GREP "^installed=no" $deplib > /dev/null; then 70558c4a8e55Smrg case $host in 70568c4a8e55Smrg *-*-darwin*) 70578c4a8e55Smrg depdepl= 70588c4a8e55Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 70598c4a8e55Smrg if test -n "$deplibrary_names" ; then 70608c4a8e55Smrg for tmp in $deplibrary_names ; do 70618c4a8e55Smrg depdepl=$tmp 70628c4a8e55Smrg done 70638c4a8e55Smrg if test -f "$absdir/$objdir/$depdepl" ; then 70648c4a8e55Smrg depdepl="$absdir/$objdir/$depdepl" 70658c4a8e55Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 70668c4a8e55Smrg if test -z "$darwin_install_name"; then 70678c4a8e55Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 70688c4a8e55Smrg fi 7069bd23fbfaSmrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 7070bd23fbfaSmrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 70718c4a8e55Smrg path= 70728c4a8e55Smrg fi 70738c4a8e55Smrg fi 70748c4a8e55Smrg ;; 70758c4a8e55Smrg *) 70768c4a8e55Smrg path="-L$absdir/$objdir" 70778c4a8e55Smrg ;; 70788c4a8e55Smrg esac 70798c4a8e55Smrg else 70808c4a8e55Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 70818c4a8e55Smrg test -z "$libdir" && \ 70828c4a8e55Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 70838c4a8e55Smrg test "$absdir" != "$libdir" && \ 70848c4a8e55Smrg func_warning "\`$deplib' seems to be moved" 70858c4a8e55Smrg 70868c4a8e55Smrg path="-L$absdir" 70878c4a8e55Smrg fi 70888c4a8e55Smrg ;; 70898c4a8e55Smrg esac 70908c4a8e55Smrg case " $deplibs " in 70918c4a8e55Smrg *" $path "*) ;; 70928c4a8e55Smrg *) deplibs="$path $deplibs" ;; 70938c4a8e55Smrg esac 70948c4a8e55Smrg done 70958c4a8e55Smrg fi # link_all_deplibs != no 70968c4a8e55Smrg fi # linkmode = lib 70978c4a8e55Smrg done # for deplib in $libs 70988c4a8e55Smrg if test "$pass" = link; then 70998c4a8e55Smrg if test "$linkmode" = "prog"; then 71008c4a8e55Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 71018c4a8e55Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 71028c4a8e55Smrg else 7103706b6b52Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 71048c4a8e55Smrg fi 71058c4a8e55Smrg fi 71068c4a8e55Smrg dependency_libs="$newdependency_libs" 71078c4a8e55Smrg if test "$pass" = dlpreopen; then 71088c4a8e55Smrg # Link the dlpreopened libraries before other libraries 71098c4a8e55Smrg for deplib in $save_deplibs; do 71108c4a8e55Smrg deplibs="$deplib $deplibs" 71118c4a8e55Smrg done 71128c4a8e55Smrg fi 71138c4a8e55Smrg if test "$pass" != dlopen; then 71148c4a8e55Smrg if test "$pass" != conv; then 71158c4a8e55Smrg # Make sure lib_search_path contains only unique directories. 71168c4a8e55Smrg lib_search_path= 71178c4a8e55Smrg for dir in $newlib_search_path; do 71188c4a8e55Smrg case "$lib_search_path " in 71198c4a8e55Smrg *" $dir "*) ;; 7120bd23fbfaSmrg *) func_append lib_search_path " $dir" ;; 71218c4a8e55Smrg esac 71228c4a8e55Smrg done 71238c4a8e55Smrg newlib_search_path= 71248c4a8e55Smrg fi 71258c4a8e55Smrg 71268c4a8e55Smrg if test "$linkmode,$pass" != "prog,link"; then 71278c4a8e55Smrg vars="deplibs" 71288c4a8e55Smrg else 71298c4a8e55Smrg vars="compile_deplibs finalize_deplibs" 71308c4a8e55Smrg fi 71318c4a8e55Smrg for var in $vars dependency_libs; do 71328c4a8e55Smrg # Add libraries to $var in reverse order 71338c4a8e55Smrg eval tmp_libs=\"\$$var\" 71348c4a8e55Smrg new_libs= 71358c4a8e55Smrg for deplib in $tmp_libs; do 71368c4a8e55Smrg # FIXME: Pedantically, this is the right thing to do, so 71378c4a8e55Smrg # that some nasty dependency loop isn't accidentally 71388c4a8e55Smrg # broken: 71398c4a8e55Smrg #new_libs="$deplib $new_libs" 71408c4a8e55Smrg # Pragmatically, this seems to cause very few problems in 71418c4a8e55Smrg # practice: 71428c4a8e55Smrg case $deplib in 71438c4a8e55Smrg -L*) new_libs="$deplib $new_libs" ;; 71448c4a8e55Smrg -R*) ;; 71458c4a8e55Smrg *) 71468c4a8e55Smrg # And here is the reason: when a library appears more 71478c4a8e55Smrg # than once as an explicit dependence of a library, or 71488c4a8e55Smrg # is implicitly linked in more than once by the 71498c4a8e55Smrg # compiler, it is considered special, and multiple 71508c4a8e55Smrg # occurrences thereof are not removed. Compare this 71518c4a8e55Smrg # with having the same library being listed as a 71528c4a8e55Smrg # dependency of multiple other libraries: in this case, 71538c4a8e55Smrg # we know (pedantically, we assume) the library does not 71548c4a8e55Smrg # need to be listed more than once, so we keep only the 71558c4a8e55Smrg # last copy. This is not always right, but it is rare 71568c4a8e55Smrg # enough that we require users that really mean to play 71578c4a8e55Smrg # such unportable linking tricks to link the library 71588c4a8e55Smrg # using -Wl,-lname, so that libtool does not consider it 71598c4a8e55Smrg # for duplicate removal. 71608c4a8e55Smrg case " $specialdeplibs " in 71618c4a8e55Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 71628c4a8e55Smrg *) 71638c4a8e55Smrg case " $new_libs " in 71648c4a8e55Smrg *" $deplib "*) ;; 71658c4a8e55Smrg *) new_libs="$deplib $new_libs" ;; 71668c4a8e55Smrg esac 71678c4a8e55Smrg ;; 71688c4a8e55Smrg esac 71698c4a8e55Smrg ;; 71708c4a8e55Smrg esac 71718c4a8e55Smrg done 71728c4a8e55Smrg tmp_libs= 71738c4a8e55Smrg for deplib in $new_libs; do 71748c4a8e55Smrg case $deplib in 71758c4a8e55Smrg -L*) 71768c4a8e55Smrg case " $tmp_libs " in 71778c4a8e55Smrg *" $deplib "*) ;; 7178bd23fbfaSmrg *) func_append tmp_libs " $deplib" ;; 71798c4a8e55Smrg esac 71808c4a8e55Smrg ;; 7181bd23fbfaSmrg *) func_append tmp_libs " $deplib" ;; 71828c4a8e55Smrg esac 71838c4a8e55Smrg done 71848c4a8e55Smrg eval $var=\"$tmp_libs\" 71858c4a8e55Smrg done # for var 71868c4a8e55Smrg fi 71878c4a8e55Smrg # Last step: remove runtime libs from dependency_libs 71888c4a8e55Smrg # (they stay in deplibs) 71898c4a8e55Smrg tmp_libs= 71908c4a8e55Smrg for i in $dependency_libs ; do 71918c4a8e55Smrg case " $predeps $postdeps $compiler_lib_search_path " in 71928c4a8e55Smrg *" $i "*) 71938c4a8e55Smrg i="" 71948c4a8e55Smrg ;; 71958c4a8e55Smrg esac 71968c4a8e55Smrg if test -n "$i" ; then 7197bd23fbfaSmrg func_append tmp_libs " $i" 71988c4a8e55Smrg fi 71998c4a8e55Smrg done 72008c4a8e55Smrg dependency_libs=$tmp_libs 72018c4a8e55Smrg done # for pass 72028c4a8e55Smrg if test "$linkmode" = prog; then 72038c4a8e55Smrg dlfiles="$newdlfiles" 72048c4a8e55Smrg fi 72058c4a8e55Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 72068c4a8e55Smrg dlprefiles="$newdlprefiles" 72078c4a8e55Smrg fi 72088c4a8e55Smrg 72098c4a8e55Smrg case $linkmode in 72108c4a8e55Smrg oldlib) 72118c4a8e55Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 72128c4a8e55Smrg func_warning "\`-dlopen' is ignored for archives" 72138c4a8e55Smrg fi 72148c4a8e55Smrg 72158c4a8e55Smrg case " $deplibs" in 72168c4a8e55Smrg *\ -l* | *\ -L*) 72178c4a8e55Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 72188c4a8e55Smrg esac 72198c4a8e55Smrg 72208c4a8e55Smrg test -n "$rpath" && \ 72218c4a8e55Smrg func_warning "\`-rpath' is ignored for archives" 72228c4a8e55Smrg 72238c4a8e55Smrg test -n "$xrpath" && \ 72248c4a8e55Smrg func_warning "\`-R' is ignored for archives" 72258c4a8e55Smrg 72268c4a8e55Smrg test -n "$vinfo" && \ 72278c4a8e55Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 72288c4a8e55Smrg 72298c4a8e55Smrg test -n "$release" && \ 72308c4a8e55Smrg func_warning "\`-release' is ignored for archives" 72318c4a8e55Smrg 72328c4a8e55Smrg test -n "$export_symbols$export_symbols_regex" && \ 72338c4a8e55Smrg func_warning "\`-export-symbols' is ignored for archives" 72348c4a8e55Smrg 72358c4a8e55Smrg # Now set the variables for building old libraries. 72368c4a8e55Smrg build_libtool_libs=no 72378c4a8e55Smrg oldlibs="$output" 7238bd23fbfaSmrg func_append objs "$old_deplibs" 72398c4a8e55Smrg ;; 72408c4a8e55Smrg 72418c4a8e55Smrg lib) 72428c4a8e55Smrg # Make sure we only generate libraries of the form `libNAME.la'. 72438c4a8e55Smrg case $outputname in 72448c4a8e55Smrg lib*) 72458c4a8e55Smrg func_stripname 'lib' '.la' "$outputname" 72468c4a8e55Smrg name=$func_stripname_result 72478c4a8e55Smrg eval shared_ext=\"$shrext_cmds\" 72488c4a8e55Smrg eval libname=\"$libname_spec\" 72498c4a8e55Smrg ;; 72508c4a8e55Smrg *) 72518c4a8e55Smrg test "$module" = no && \ 72528c4a8e55Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 72538c4a8e55Smrg 72548c4a8e55Smrg if test "$need_lib_prefix" != no; then 72558c4a8e55Smrg # Add the "lib" prefix for modules if required 72568c4a8e55Smrg func_stripname '' '.la' "$outputname" 72578c4a8e55Smrg name=$func_stripname_result 72588c4a8e55Smrg eval shared_ext=\"$shrext_cmds\" 72598c4a8e55Smrg eval libname=\"$libname_spec\" 72608c4a8e55Smrg else 72618c4a8e55Smrg func_stripname '' '.la' "$outputname" 72628c4a8e55Smrg libname=$func_stripname_result 72638c4a8e55Smrg fi 72648c4a8e55Smrg ;; 72658c4a8e55Smrg esac 72668c4a8e55Smrg 72678c4a8e55Smrg if test -n "$objs"; then 72688c4a8e55Smrg if test "$deplibs_check_method" != pass_all; then 72698c4a8e55Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 72708c4a8e55Smrg else 7271706b6b52Smrg echo 72728c4a8e55Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 72738c4a8e55Smrg $ECHO "*** objects $objs is not portable!" 7274bd23fbfaSmrg func_append libobjs " $objs" 72758c4a8e55Smrg fi 72768c4a8e55Smrg fi 72778c4a8e55Smrg 72788c4a8e55Smrg test "$dlself" != no && \ 72798c4a8e55Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 72808c4a8e55Smrg 72818c4a8e55Smrg set dummy $rpath 72828c4a8e55Smrg shift 72838c4a8e55Smrg test "$#" -gt 1 && \ 72848c4a8e55Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 72858c4a8e55Smrg 72868c4a8e55Smrg install_libdir="$1" 72878c4a8e55Smrg 72888c4a8e55Smrg oldlibs= 72898c4a8e55Smrg if test -z "$rpath"; then 72908c4a8e55Smrg if test "$build_libtool_libs" = yes; then 72918c4a8e55Smrg # Building a libtool convenience library. 72928c4a8e55Smrg # Some compilers have problems with a `.al' extension so 72938c4a8e55Smrg # convenience libraries should have the same extension an 72948c4a8e55Smrg # archive normally would. 72958c4a8e55Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 72968c4a8e55Smrg build_libtool_libs=convenience 72978c4a8e55Smrg build_old_libs=yes 72988c4a8e55Smrg fi 72998c4a8e55Smrg 73008c4a8e55Smrg test -n "$vinfo" && \ 73018c4a8e55Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 73028c4a8e55Smrg 73038c4a8e55Smrg test -n "$release" && \ 73048c4a8e55Smrg func_warning "\`-release' is ignored for convenience libraries" 73058c4a8e55Smrg else 73068c4a8e55Smrg 73078c4a8e55Smrg # Parse the version information argument. 73088c4a8e55Smrg save_ifs="$IFS"; IFS=':' 73098c4a8e55Smrg set dummy $vinfo 0 0 0 73108c4a8e55Smrg shift 73118c4a8e55Smrg IFS="$save_ifs" 73128c4a8e55Smrg 73138c4a8e55Smrg test -n "$7" && \ 73148c4a8e55Smrg func_fatal_help "too many parameters to \`-version-info'" 73158c4a8e55Smrg 73168c4a8e55Smrg # convert absolute version numbers to libtool ages 73178c4a8e55Smrg # this retains compatibility with .la files and attempts 73188c4a8e55Smrg # to make the code below a bit more comprehensible 73198c4a8e55Smrg 73208c4a8e55Smrg case $vinfo_number in 73218c4a8e55Smrg yes) 73228c4a8e55Smrg number_major="$1" 73238c4a8e55Smrg number_minor="$2" 73248c4a8e55Smrg number_revision="$3" 73258c4a8e55Smrg # 73268c4a8e55Smrg # There are really only two kinds -- those that 73278c4a8e55Smrg # use the current revision as the major version 73288c4a8e55Smrg # and those that subtract age and use age as 73298c4a8e55Smrg # a minor version. But, then there is irix 73308c4a8e55Smrg # which has an extra 1 added just for fun 73318c4a8e55Smrg # 73328c4a8e55Smrg case $version_type in 73330597fb56Smrg # correct linux to gnu/linux during the next big refactor 73348c4a8e55Smrg darwin|linux|osf|windows|none) 73358c4a8e55Smrg func_arith $number_major + $number_minor 73368c4a8e55Smrg current=$func_arith_result 73378c4a8e55Smrg age="$number_minor" 73388c4a8e55Smrg revision="$number_revision" 73398c4a8e55Smrg ;; 7340706b6b52Smrg freebsd-aout|freebsd-elf|qnx|sunos) 73418c4a8e55Smrg current="$number_major" 73428c4a8e55Smrg revision="$number_minor" 73438c4a8e55Smrg age="0" 73448c4a8e55Smrg ;; 73458c4a8e55Smrg irix|nonstopux) 73468c4a8e55Smrg func_arith $number_major + $number_minor 73478c4a8e55Smrg current=$func_arith_result 73488c4a8e55Smrg age="$number_minor" 73498c4a8e55Smrg revision="$number_minor" 73508c4a8e55Smrg lt_irix_increment=no 73518c4a8e55Smrg ;; 73528c4a8e55Smrg esac 73538c4a8e55Smrg ;; 73548c4a8e55Smrg no) 73558c4a8e55Smrg current="$1" 73568c4a8e55Smrg revision="$2" 73578c4a8e55Smrg age="$3" 73588c4a8e55Smrg ;; 73598c4a8e55Smrg esac 73608c4a8e55Smrg 73618c4a8e55Smrg # Check that each of the things are valid numbers. 73628c4a8e55Smrg case $current in 73638c4a8e55Smrg 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]) ;; 73648c4a8e55Smrg *) 73658c4a8e55Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 73668c4a8e55Smrg func_fatal_error "\`$vinfo' is not valid version information" 73678c4a8e55Smrg ;; 73688c4a8e55Smrg esac 73698c4a8e55Smrg 73708c4a8e55Smrg case $revision in 73718c4a8e55Smrg 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]) ;; 73728c4a8e55Smrg *) 73738c4a8e55Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 73748c4a8e55Smrg func_fatal_error "\`$vinfo' is not valid version information" 73758c4a8e55Smrg ;; 73768c4a8e55Smrg esac 73778c4a8e55Smrg 73788c4a8e55Smrg case $age in 73798c4a8e55Smrg 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]) ;; 73808c4a8e55Smrg *) 73818c4a8e55Smrg func_error "AGE \`$age' must be a nonnegative integer" 73828c4a8e55Smrg func_fatal_error "\`$vinfo' is not valid version information" 73838c4a8e55Smrg ;; 73848c4a8e55Smrg esac 73858c4a8e55Smrg 73868c4a8e55Smrg if test "$age" -gt "$current"; then 73878c4a8e55Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 73888c4a8e55Smrg func_fatal_error "\`$vinfo' is not valid version information" 73898c4a8e55Smrg fi 73908c4a8e55Smrg 73918c4a8e55Smrg # Calculate the version variables. 73928c4a8e55Smrg major= 73938c4a8e55Smrg versuffix= 73948c4a8e55Smrg verstring= 73958c4a8e55Smrg case $version_type in 73968c4a8e55Smrg none) ;; 73978c4a8e55Smrg 73988c4a8e55Smrg darwin) 73998c4a8e55Smrg # Like Linux, but with the current version available in 74008c4a8e55Smrg # verstring for coding it into the library header 74018c4a8e55Smrg func_arith $current - $age 74028c4a8e55Smrg major=.$func_arith_result 74038c4a8e55Smrg versuffix="$major.$age.$revision" 74048c4a8e55Smrg # Darwin ld doesn't like 0 for these options... 74058c4a8e55Smrg func_arith $current + 1 74068c4a8e55Smrg minor_current=$func_arith_result 74078c4a8e55Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 74088c4a8e55Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 74098c4a8e55Smrg ;; 74108c4a8e55Smrg 74118c4a8e55Smrg freebsd-aout) 74128c4a8e55Smrg major=".$current" 74138c4a8e55Smrg versuffix=".$current.$revision"; 74148c4a8e55Smrg ;; 74158c4a8e55Smrg 74168c4a8e55Smrg freebsd-elf) 74178c4a8e55Smrg major=".$current" 74188c4a8e55Smrg versuffix=".$current" 74198c4a8e55Smrg ;; 74208c4a8e55Smrg 74218c4a8e55Smrg irix | nonstopux) 74228c4a8e55Smrg if test "X$lt_irix_increment" = "Xno"; then 74238c4a8e55Smrg func_arith $current - $age 74248c4a8e55Smrg else 74258c4a8e55Smrg func_arith $current - $age + 1 74268c4a8e55Smrg fi 74278c4a8e55Smrg major=$func_arith_result 74288c4a8e55Smrg 74298c4a8e55Smrg case $version_type in 74308c4a8e55Smrg nonstopux) verstring_prefix=nonstopux ;; 74318c4a8e55Smrg *) verstring_prefix=sgi ;; 74328c4a8e55Smrg esac 74338c4a8e55Smrg verstring="$verstring_prefix$major.$revision" 74348c4a8e55Smrg 74358c4a8e55Smrg # Add in all the interfaces that we are compatible with. 74368c4a8e55Smrg loop=$revision 74378c4a8e55Smrg while test "$loop" -ne 0; do 74388c4a8e55Smrg func_arith $revision - $loop 74398c4a8e55Smrg iface=$func_arith_result 74408c4a8e55Smrg func_arith $loop - 1 74418c4a8e55Smrg loop=$func_arith_result 74428c4a8e55Smrg verstring="$verstring_prefix$major.$iface:$verstring" 74438c4a8e55Smrg done 74448c4a8e55Smrg 74458c4a8e55Smrg # Before this point, $major must not contain `.'. 74468c4a8e55Smrg major=.$major 74478c4a8e55Smrg versuffix="$major.$revision" 74488c4a8e55Smrg ;; 74498c4a8e55Smrg 74500597fb56Smrg linux) # correct to gnu/linux during the next big refactor 74518c4a8e55Smrg func_arith $current - $age 74528c4a8e55Smrg major=.$func_arith_result 74538c4a8e55Smrg versuffix="$major.$age.$revision" 74548c4a8e55Smrg ;; 74558c4a8e55Smrg 74568c4a8e55Smrg osf) 74578c4a8e55Smrg func_arith $current - $age 74588c4a8e55Smrg major=.$func_arith_result 74598c4a8e55Smrg versuffix=".$current.$age.$revision" 74608c4a8e55Smrg verstring="$current.$age.$revision" 74618c4a8e55Smrg 74628c4a8e55Smrg # Add in all the interfaces that we are compatible with. 74638c4a8e55Smrg loop=$age 74648c4a8e55Smrg while test "$loop" -ne 0; do 74658c4a8e55Smrg func_arith $current - $loop 74668c4a8e55Smrg iface=$func_arith_result 74678c4a8e55Smrg func_arith $loop - 1 74688c4a8e55Smrg loop=$func_arith_result 74698c4a8e55Smrg verstring="$verstring:${iface}.0" 74708c4a8e55Smrg done 74718c4a8e55Smrg 74728c4a8e55Smrg # Make executables depend on our current version. 7473bd23fbfaSmrg func_append verstring ":${current}.0" 74748c4a8e55Smrg ;; 74758c4a8e55Smrg 74768c4a8e55Smrg qnx) 74778c4a8e55Smrg major=".$current" 74788c4a8e55Smrg versuffix=".$current" 74798c4a8e55Smrg ;; 74808c4a8e55Smrg 74818c4a8e55Smrg sunos) 74828c4a8e55Smrg major=".$current" 74838c4a8e55Smrg versuffix=".$current.$revision" 74848c4a8e55Smrg ;; 74858c4a8e55Smrg 74868c4a8e55Smrg windows) 74878c4a8e55Smrg # Use '-' rather than '.', since we only want one 74888c4a8e55Smrg # extension on DOS 8.3 filesystems. 74898c4a8e55Smrg func_arith $current - $age 74908c4a8e55Smrg major=$func_arith_result 74918c4a8e55Smrg versuffix="-$major" 74928c4a8e55Smrg ;; 74938c4a8e55Smrg 74948c4a8e55Smrg *) 74958c4a8e55Smrg func_fatal_configuration "unknown library version type \`$version_type'" 74968c4a8e55Smrg ;; 74978c4a8e55Smrg esac 74988c4a8e55Smrg 74998c4a8e55Smrg # Clear the version info if we defaulted, and they specified a release. 75008c4a8e55Smrg if test -z "$vinfo" && test -n "$release"; then 75018c4a8e55Smrg major= 75028c4a8e55Smrg case $version_type in 75038c4a8e55Smrg darwin) 75048c4a8e55Smrg # we can't check for "0.0" in archive_cmds due to quoting 75058c4a8e55Smrg # problems, so we reset it completely 75068c4a8e55Smrg verstring= 75078c4a8e55Smrg ;; 75088c4a8e55Smrg *) 75098c4a8e55Smrg verstring="0.0" 75108c4a8e55Smrg ;; 75118c4a8e55Smrg esac 75128c4a8e55Smrg if test "$need_version" = no; then 75138c4a8e55Smrg versuffix= 75148c4a8e55Smrg else 75158c4a8e55Smrg versuffix=".0.0" 75168c4a8e55Smrg fi 75178c4a8e55Smrg fi 75188c4a8e55Smrg 75198c4a8e55Smrg # Remove version info from name if versioning should be avoided 75208c4a8e55Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 75218c4a8e55Smrg major= 75228c4a8e55Smrg versuffix= 75238c4a8e55Smrg verstring="" 75248c4a8e55Smrg fi 75258c4a8e55Smrg 75268c4a8e55Smrg # Check to see if the archive will have undefined symbols. 75278c4a8e55Smrg if test "$allow_undefined" = yes; then 75288c4a8e55Smrg if test "$allow_undefined_flag" = unsupported; then 75298c4a8e55Smrg func_warning "undefined symbols not allowed in $host shared libraries" 75308c4a8e55Smrg build_libtool_libs=no 75318c4a8e55Smrg build_old_libs=yes 75328c4a8e55Smrg fi 75338c4a8e55Smrg else 75348c4a8e55Smrg # Don't allow undefined symbols. 75358c4a8e55Smrg allow_undefined_flag="$no_undefined_flag" 75368c4a8e55Smrg fi 75378c4a8e55Smrg 75388c4a8e55Smrg fi 75398c4a8e55Smrg 75408c4a8e55Smrg func_generate_dlsyms "$libname" "$libname" "yes" 7541bd23fbfaSmrg func_append libobjs " $symfileobj" 75428c4a8e55Smrg test "X$libobjs" = "X " && libobjs= 75438c4a8e55Smrg 7544bd23fbfaSmrg if test "$opt_mode" != relink; then 75458c4a8e55Smrg # Remove our outputs, but don't remove object files since they 75468c4a8e55Smrg # may have been created when compiling PIC objects. 75478c4a8e55Smrg removelist= 75488c4a8e55Smrg tempremovelist=`$ECHO "$output_objdir/*"` 75498c4a8e55Smrg for p in $tempremovelist; do 75508c4a8e55Smrg case $p in 75518c4a8e55Smrg *.$objext | *.gcno) 75528c4a8e55Smrg ;; 75538c4a8e55Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 75548c4a8e55Smrg if test "X$precious_files_regex" != "X"; then 75558c4a8e55Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 75568c4a8e55Smrg then 75578c4a8e55Smrg continue 75588c4a8e55Smrg fi 75598c4a8e55Smrg fi 7560bd23fbfaSmrg func_append removelist " $p" 75618c4a8e55Smrg ;; 75628c4a8e55Smrg *) ;; 75638c4a8e55Smrg esac 75648c4a8e55Smrg done 75658c4a8e55Smrg test -n "$removelist" && \ 75668c4a8e55Smrg func_show_eval "${RM}r \$removelist" 75678c4a8e55Smrg fi 75688c4a8e55Smrg 75698c4a8e55Smrg # Now set the variables for building old libraries. 75708c4a8e55Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 7571bd23fbfaSmrg func_append oldlibs " $output_objdir/$libname.$libext" 75728c4a8e55Smrg 75738c4a8e55Smrg # Transform .lo files to .o files. 7574706b6b52Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 75758c4a8e55Smrg fi 75768c4a8e55Smrg 75778c4a8e55Smrg # Eliminate all temporary directories. 75788c4a8e55Smrg #for path in $notinst_path; do 7579706b6b52Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 7580706b6b52Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 7581706b6b52Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 75828c4a8e55Smrg #done 75838c4a8e55Smrg 75848c4a8e55Smrg if test -n "$xrpath"; then 75858c4a8e55Smrg # If the user specified any rpath flags, then add them. 75868c4a8e55Smrg temp_xrpath= 75878c4a8e55Smrg for libdir in $xrpath; do 7588bd23fbfaSmrg func_replace_sysroot "$libdir" 7589bd23fbfaSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 75908c4a8e55Smrg case "$finalize_rpath " in 75918c4a8e55Smrg *" $libdir "*) ;; 7592bd23fbfaSmrg *) func_append finalize_rpath " $libdir" ;; 75938c4a8e55Smrg esac 75948c4a8e55Smrg done 75958c4a8e55Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 75968c4a8e55Smrg dependency_libs="$temp_xrpath $dependency_libs" 75978c4a8e55Smrg fi 75988c4a8e55Smrg fi 75998c4a8e55Smrg 76008c4a8e55Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 76018c4a8e55Smrg old_dlfiles="$dlfiles" 76028c4a8e55Smrg dlfiles= 76038c4a8e55Smrg for lib in $old_dlfiles; do 76048c4a8e55Smrg case " $dlprefiles $dlfiles " in 76058c4a8e55Smrg *" $lib "*) ;; 7606bd23fbfaSmrg *) func_append dlfiles " $lib" ;; 76078c4a8e55Smrg esac 76088c4a8e55Smrg done 76098c4a8e55Smrg 76108c4a8e55Smrg # Make sure dlprefiles contains only unique files 76118c4a8e55Smrg old_dlprefiles="$dlprefiles" 76128c4a8e55Smrg dlprefiles= 76138c4a8e55Smrg for lib in $old_dlprefiles; do 76148c4a8e55Smrg case "$dlprefiles " in 76158c4a8e55Smrg *" $lib "*) ;; 7616bd23fbfaSmrg *) func_append dlprefiles " $lib" ;; 76178c4a8e55Smrg esac 76188c4a8e55Smrg done 76198c4a8e55Smrg 76208c4a8e55Smrg if test "$build_libtool_libs" = yes; then 76218c4a8e55Smrg if test -n "$rpath"; then 76228c4a8e55Smrg case $host in 7623706b6b52Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 76248c4a8e55Smrg # these systems don't actually have a c library (as such)! 76258c4a8e55Smrg ;; 76268c4a8e55Smrg *-*-rhapsody* | *-*-darwin1.[012]) 76278c4a8e55Smrg # Rhapsody C library is in the System framework 7628bd23fbfaSmrg func_append deplibs " System.ltframework" 76298c4a8e55Smrg ;; 76308c4a8e55Smrg *-*-netbsd*) 76318c4a8e55Smrg # Don't link with libc until the a.out ld.so is fixed. 76328c4a8e55Smrg ;; 76338c4a8e55Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 76348c4a8e55Smrg # Do not include libc due to us having libc/libc_r. 76358c4a8e55Smrg ;; 76368c4a8e55Smrg *-*-sco3.2v5* | *-*-sco5v6*) 76378c4a8e55Smrg # Causes problems with __ctype 76388c4a8e55Smrg ;; 76398c4a8e55Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 76408c4a8e55Smrg # Compiler inserts libc in the correct place for threads to work 76418c4a8e55Smrg ;; 76428c4a8e55Smrg *) 76438c4a8e55Smrg # Add libc to deplibs on all other systems if necessary. 76448c4a8e55Smrg if test "$build_libtool_need_lc" = "yes"; then 7645bd23fbfaSmrg func_append deplibs " -lc" 76468c4a8e55Smrg fi 76478c4a8e55Smrg ;; 76488c4a8e55Smrg esac 76498c4a8e55Smrg fi 76508c4a8e55Smrg 76518c4a8e55Smrg # Transform deplibs into only deplibs that can be linked in shared. 76528c4a8e55Smrg name_save=$name 76538c4a8e55Smrg libname_save=$libname 76548c4a8e55Smrg release_save=$release 76558c4a8e55Smrg versuffix_save=$versuffix 76568c4a8e55Smrg major_save=$major 76578c4a8e55Smrg # I'm not sure if I'm treating the release correctly. I think 76588c4a8e55Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 76598c4a8e55Smrg # add it in twice. Is that correct? 76608c4a8e55Smrg release="" 76618c4a8e55Smrg versuffix="" 76628c4a8e55Smrg major="" 76638c4a8e55Smrg newdeplibs= 76648c4a8e55Smrg droppeddeps=no 76658c4a8e55Smrg case $deplibs_check_method in 76668c4a8e55Smrg pass_all) 76678c4a8e55Smrg # Don't check for shared/static. Everything works. 76688c4a8e55Smrg # This might be a little naive. We might want to check 76698c4a8e55Smrg # whether the library exists or not. But this is on 76708c4a8e55Smrg # osf3 & osf4 and I'm not really sure... Just 76718c4a8e55Smrg # implementing what was already the behavior. 76728c4a8e55Smrg newdeplibs=$deplibs 76738c4a8e55Smrg ;; 76748c4a8e55Smrg test_compile) 76758c4a8e55Smrg # This code stresses the "libraries are programs" paradigm to its 76768c4a8e55Smrg # limits. Maybe even breaks it. We compile a program, linking it 76778c4a8e55Smrg # against the deplibs as a proxy for the library. Then we can check 76788c4a8e55Smrg # whether they linked in statically or dynamically with ldd. 76798c4a8e55Smrg $opt_dry_run || $RM conftest.c 76808c4a8e55Smrg cat > conftest.c <<EOF 76818c4a8e55Smrg int main() { return 0; } 76828c4a8e55SmrgEOF 76838c4a8e55Smrg $opt_dry_run || $RM conftest 76848c4a8e55Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 76858c4a8e55Smrg ldd_output=`ldd conftest` 76868c4a8e55Smrg for i in $deplibs; do 76878c4a8e55Smrg case $i in 76888c4a8e55Smrg -l*) 76898c4a8e55Smrg func_stripname -l '' "$i" 76908c4a8e55Smrg name=$func_stripname_result 76918c4a8e55Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 76928c4a8e55Smrg case " $predeps $postdeps " in 76938c4a8e55Smrg *" $i "*) 7694bd23fbfaSmrg func_append newdeplibs " $i" 76958c4a8e55Smrg i="" 76968c4a8e55Smrg ;; 76978c4a8e55Smrg esac 76988c4a8e55Smrg fi 76998c4a8e55Smrg if test -n "$i" ; then 77008c4a8e55Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 77018c4a8e55Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 77028c4a8e55Smrg set dummy $deplib_matches; shift 77038c4a8e55Smrg deplib_match=$1 77048c4a8e55Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7705bd23fbfaSmrg func_append newdeplibs " $i" 77068c4a8e55Smrg else 77078c4a8e55Smrg droppeddeps=yes 7708706b6b52Smrg echo 77098c4a8e55Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7710706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 7711706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 7712706b6b52Smrg echo "*** shared version of the library, which I believe you do not have" 7713706b6b52Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 7714706b6b52Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 77158c4a8e55Smrg fi 77168c4a8e55Smrg fi 77178c4a8e55Smrg ;; 77188c4a8e55Smrg *) 7719bd23fbfaSmrg func_append newdeplibs " $i" 77208c4a8e55Smrg ;; 77218c4a8e55Smrg esac 77228c4a8e55Smrg done 77238c4a8e55Smrg else 77248c4a8e55Smrg # Error occurred in the first compile. Let's try to salvage 77258c4a8e55Smrg # the situation: Compile a separate program for each library. 77268c4a8e55Smrg for i in $deplibs; do 77278c4a8e55Smrg case $i in 77288c4a8e55Smrg -l*) 77298c4a8e55Smrg func_stripname -l '' "$i" 77308c4a8e55Smrg name=$func_stripname_result 77318c4a8e55Smrg $opt_dry_run || $RM conftest 77328c4a8e55Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 77338c4a8e55Smrg ldd_output=`ldd conftest` 77348c4a8e55Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 77358c4a8e55Smrg case " $predeps $postdeps " in 77368c4a8e55Smrg *" $i "*) 7737bd23fbfaSmrg func_append newdeplibs " $i" 77388c4a8e55Smrg i="" 77398c4a8e55Smrg ;; 77408c4a8e55Smrg esac 77418c4a8e55Smrg fi 77428c4a8e55Smrg if test -n "$i" ; then 77438c4a8e55Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 77448c4a8e55Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 77458c4a8e55Smrg set dummy $deplib_matches; shift 77468c4a8e55Smrg deplib_match=$1 77478c4a8e55Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7748bd23fbfaSmrg func_append newdeplibs " $i" 77498c4a8e55Smrg else 77508c4a8e55Smrg droppeddeps=yes 7751706b6b52Smrg echo 77528c4a8e55Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7753706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 7754706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 7755706b6b52Smrg echo "*** shared version of the library, which you do not appear to have" 7756706b6b52Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 7757706b6b52Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 77588c4a8e55Smrg fi 77598c4a8e55Smrg fi 77608c4a8e55Smrg else 77618c4a8e55Smrg droppeddeps=yes 7762706b6b52Smrg echo 77638c4a8e55Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 7764706b6b52Smrg echo "*** make it link in! You will probably need to install it or some" 7765706b6b52Smrg echo "*** library that it depends on before this library will be fully" 7766706b6b52Smrg echo "*** functional. Installing it before continuing would be even better." 77678c4a8e55Smrg fi 77688c4a8e55Smrg ;; 77698c4a8e55Smrg *) 7770bd23fbfaSmrg func_append newdeplibs " $i" 77718c4a8e55Smrg ;; 77728c4a8e55Smrg esac 77738c4a8e55Smrg done 77748c4a8e55Smrg fi 77758c4a8e55Smrg ;; 77768c4a8e55Smrg file_magic*) 77778c4a8e55Smrg set dummy $deplibs_check_method; shift 77788c4a8e55Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 77798c4a8e55Smrg for a_deplib in $deplibs; do 77808c4a8e55Smrg case $a_deplib in 77818c4a8e55Smrg -l*) 77828c4a8e55Smrg func_stripname -l '' "$a_deplib" 77838c4a8e55Smrg name=$func_stripname_result 77848c4a8e55Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 77858c4a8e55Smrg case " $predeps $postdeps " in 77868c4a8e55Smrg *" $a_deplib "*) 7787bd23fbfaSmrg func_append newdeplibs " $a_deplib" 77888c4a8e55Smrg a_deplib="" 77898c4a8e55Smrg ;; 77908c4a8e55Smrg esac 77918c4a8e55Smrg fi 77928c4a8e55Smrg if test -n "$a_deplib" ; then 77938c4a8e55Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7794bd23fbfaSmrg if test -n "$file_magic_glob"; then 7795bd23fbfaSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 7796bd23fbfaSmrg else 7797bd23fbfaSmrg libnameglob=$libname 7798bd23fbfaSmrg fi 7799bd23fbfaSmrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 78008c4a8e55Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7801bd23fbfaSmrg if test "$want_nocaseglob" = yes; then 7802bd23fbfaSmrg shopt -s nocaseglob 7803bd23fbfaSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7804bd23fbfaSmrg $nocaseglob 7805bd23fbfaSmrg else 7806bd23fbfaSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7807bd23fbfaSmrg fi 78088c4a8e55Smrg for potent_lib in $potential_libs; do 78098c4a8e55Smrg # Follow soft links. 78108c4a8e55Smrg if ls -lLd "$potent_lib" 2>/dev/null | 78118c4a8e55Smrg $GREP " -> " >/dev/null; then 78128c4a8e55Smrg continue 78138c4a8e55Smrg fi 78148c4a8e55Smrg # The statement above tries to avoid entering an 78158c4a8e55Smrg # endless loop below, in case of cyclic links. 78168c4a8e55Smrg # We might still enter an endless loop, since a link 78178c4a8e55Smrg # loop can be closed while we follow links, 78188c4a8e55Smrg # but so what? 78198c4a8e55Smrg potlib="$potent_lib" 78208c4a8e55Smrg while test -h "$potlib" 2>/dev/null; do 78218c4a8e55Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 78228c4a8e55Smrg case $potliblink in 78238c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 7824706b6b52Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 78258c4a8e55Smrg esac 78268c4a8e55Smrg done 78278c4a8e55Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 78288c4a8e55Smrg $SED -e 10q | 78298c4a8e55Smrg $EGREP "$file_magic_regex" > /dev/null; then 7830bd23fbfaSmrg func_append newdeplibs " $a_deplib" 78318c4a8e55Smrg a_deplib="" 78328c4a8e55Smrg break 2 78338c4a8e55Smrg fi 78348c4a8e55Smrg done 78358c4a8e55Smrg done 78368c4a8e55Smrg fi 78378c4a8e55Smrg if test -n "$a_deplib" ; then 78388c4a8e55Smrg droppeddeps=yes 7839706b6b52Smrg echo 78408c4a8e55Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7841706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 7842706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 7843706b6b52Smrg echo "*** shared version of the library, which you do not appear to have" 7844706b6b52Smrg echo "*** because I did check the linker path looking for a file starting" 78458c4a8e55Smrg if test -z "$potlib" ; then 78468c4a8e55Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 78478c4a8e55Smrg else 78488c4a8e55Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 78498c4a8e55Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 78508c4a8e55Smrg fi 78518c4a8e55Smrg fi 78528c4a8e55Smrg ;; 78538c4a8e55Smrg *) 78548c4a8e55Smrg # Add a -L argument. 7855bd23fbfaSmrg func_append newdeplibs " $a_deplib" 78568c4a8e55Smrg ;; 78578c4a8e55Smrg esac 78588c4a8e55Smrg done # Gone through all deplibs. 78598c4a8e55Smrg ;; 78608c4a8e55Smrg match_pattern*) 78618c4a8e55Smrg set dummy $deplibs_check_method; shift 78628c4a8e55Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 78638c4a8e55Smrg for a_deplib in $deplibs; do 78648c4a8e55Smrg case $a_deplib in 78658c4a8e55Smrg -l*) 78668c4a8e55Smrg func_stripname -l '' "$a_deplib" 78678c4a8e55Smrg name=$func_stripname_result 78688c4a8e55Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 78698c4a8e55Smrg case " $predeps $postdeps " in 78708c4a8e55Smrg *" $a_deplib "*) 7871bd23fbfaSmrg func_append newdeplibs " $a_deplib" 78728c4a8e55Smrg a_deplib="" 78738c4a8e55Smrg ;; 78748c4a8e55Smrg esac 78758c4a8e55Smrg fi 78768c4a8e55Smrg if test -n "$a_deplib" ; then 78778c4a8e55Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 78788c4a8e55Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 78798c4a8e55Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 78808c4a8e55Smrg for potent_lib in $potential_libs; do 78818c4a8e55Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 7882706b6b52Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 78838c4a8e55Smrg $EGREP "$match_pattern_regex" > /dev/null; then 7884bd23fbfaSmrg func_append newdeplibs " $a_deplib" 78858c4a8e55Smrg a_deplib="" 78868c4a8e55Smrg break 2 78878c4a8e55Smrg fi 78888c4a8e55Smrg done 78898c4a8e55Smrg done 78908c4a8e55Smrg fi 78918c4a8e55Smrg if test -n "$a_deplib" ; then 78928c4a8e55Smrg droppeddeps=yes 7893706b6b52Smrg echo 78948c4a8e55Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7895706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 7896706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 7897706b6b52Smrg echo "*** shared version of the library, which you do not appear to have" 7898706b6b52Smrg echo "*** because I did check the linker path looking for a file starting" 78998c4a8e55Smrg if test -z "$potlib" ; then 79008c4a8e55Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 79018c4a8e55Smrg else 79028c4a8e55Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 79038c4a8e55Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 79048c4a8e55Smrg fi 79058c4a8e55Smrg fi 79068c4a8e55Smrg ;; 79078c4a8e55Smrg *) 79088c4a8e55Smrg # Add a -L argument. 7909bd23fbfaSmrg func_append newdeplibs " $a_deplib" 79108c4a8e55Smrg ;; 79118c4a8e55Smrg esac 79128c4a8e55Smrg done # Gone through all deplibs. 79138c4a8e55Smrg ;; 79148c4a8e55Smrg none | unknown | *) 79158c4a8e55Smrg newdeplibs="" 7916706b6b52Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 79178c4a8e55Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 79188c4a8e55Smrg for i in $predeps $postdeps ; do 79198c4a8e55Smrg # can't use Xsed below, because $i might contain '/' 7920706b6b52Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 79218c4a8e55Smrg done 79228c4a8e55Smrg fi 7923706b6b52Smrg case $tmp_deplibs in 7924706b6b52Smrg *[!\ \ ]*) 7925706b6b52Smrg echo 79268c4a8e55Smrg if test "X$deplibs_check_method" = "Xnone"; then 7927706b6b52Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 79288c4a8e55Smrg else 7929706b6b52Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 79308c4a8e55Smrg fi 7931706b6b52Smrg echo "*** All declared inter-library dependencies are being dropped." 79328c4a8e55Smrg droppeddeps=yes 7933706b6b52Smrg ;; 7934706b6b52Smrg esac 79358c4a8e55Smrg ;; 79368c4a8e55Smrg esac 79378c4a8e55Smrg versuffix=$versuffix_save 79388c4a8e55Smrg major=$major_save 79398c4a8e55Smrg release=$release_save 79408c4a8e55Smrg libname=$libname_save 79418c4a8e55Smrg name=$name_save 79428c4a8e55Smrg 79438c4a8e55Smrg case $host in 79448c4a8e55Smrg *-*-rhapsody* | *-*-darwin1.[012]) 79458c4a8e55Smrg # On Rhapsody replace the C library with the System framework 7946706b6b52Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 79478c4a8e55Smrg ;; 79488c4a8e55Smrg esac 79498c4a8e55Smrg 79508c4a8e55Smrg if test "$droppeddeps" = yes; then 79518c4a8e55Smrg if test "$module" = yes; then 7952706b6b52Smrg echo 7953706b6b52Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 79548c4a8e55Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 7955706b6b52Smrg echo "*** a static module, that should work as long as the dlopening" 7956706b6b52Smrg echo "*** application is linked with the -dlopen flag." 79578c4a8e55Smrg if test -z "$global_symbol_pipe"; then 7958706b6b52Smrg echo 7959706b6b52Smrg echo "*** However, this would only work if libtool was able to extract symbol" 7960706b6b52Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 7961706b6b52Smrg echo "*** not find such a program. So, this module is probably useless." 7962706b6b52Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 79638c4a8e55Smrg fi 79648c4a8e55Smrg if test "$build_old_libs" = no; then 79658c4a8e55Smrg oldlibs="$output_objdir/$libname.$libext" 79668c4a8e55Smrg build_libtool_libs=module 79678c4a8e55Smrg build_old_libs=yes 79688c4a8e55Smrg else 79698c4a8e55Smrg build_libtool_libs=no 79708c4a8e55Smrg fi 79718c4a8e55Smrg else 7972706b6b52Smrg echo "*** The inter-library dependencies that have been dropped here will be" 7973706b6b52Smrg echo "*** automatically added whenever a program is linked with this library" 7974706b6b52Smrg echo "*** or is declared to -dlopen it." 79758c4a8e55Smrg 79768c4a8e55Smrg if test "$allow_undefined" = no; then 7977706b6b52Smrg echo 7978706b6b52Smrg echo "*** Since this library must not contain undefined symbols," 7979706b6b52Smrg echo "*** because either the platform does not support them or" 7980706b6b52Smrg echo "*** it was explicitly requested with -no-undefined," 7981706b6b52Smrg echo "*** libtool will only create a static version of it." 79828c4a8e55Smrg if test "$build_old_libs" = no; then 79838c4a8e55Smrg oldlibs="$output_objdir/$libname.$libext" 79848c4a8e55Smrg build_libtool_libs=module 79858c4a8e55Smrg build_old_libs=yes 79868c4a8e55Smrg else 79878c4a8e55Smrg build_libtool_libs=no 79888c4a8e55Smrg fi 79898c4a8e55Smrg fi 79908c4a8e55Smrg fi 79918c4a8e55Smrg fi 79928c4a8e55Smrg # Done checking deplibs! 79938c4a8e55Smrg deplibs=$newdeplibs 79948c4a8e55Smrg fi 79958c4a8e55Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 79968c4a8e55Smrg case $host in 79978c4a8e55Smrg *-*-darwin*) 7998706b6b52Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7999706b6b52Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8000706b6b52Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 80018c4a8e55Smrg ;; 80028c4a8e55Smrg esac 80038c4a8e55Smrg 80048c4a8e55Smrg # move library search paths that coincide with paths to not yet 80058c4a8e55Smrg # installed libraries to the beginning of the library search list 80068c4a8e55Smrg new_libs= 80078c4a8e55Smrg for path in $notinst_path; do 80088c4a8e55Smrg case " $new_libs " in 80098c4a8e55Smrg *" -L$path/$objdir "*) ;; 80108c4a8e55Smrg *) 80118c4a8e55Smrg case " $deplibs " in 80128c4a8e55Smrg *" -L$path/$objdir "*) 8013bd23fbfaSmrg func_append new_libs " -L$path/$objdir" ;; 80148c4a8e55Smrg esac 80158c4a8e55Smrg ;; 80168c4a8e55Smrg esac 80178c4a8e55Smrg done 80188c4a8e55Smrg for deplib in $deplibs; do 80198c4a8e55Smrg case $deplib in 80208c4a8e55Smrg -L*) 80218c4a8e55Smrg case " $new_libs " in 80228c4a8e55Smrg *" $deplib "*) ;; 8023bd23fbfaSmrg *) func_append new_libs " $deplib" ;; 80248c4a8e55Smrg esac 80258c4a8e55Smrg ;; 8026bd23fbfaSmrg *) func_append new_libs " $deplib" ;; 80278c4a8e55Smrg esac 80288c4a8e55Smrg done 80298c4a8e55Smrg deplibs="$new_libs" 80308c4a8e55Smrg 80318c4a8e55Smrg # All the library-specific variables (install_libdir is set above). 80328c4a8e55Smrg library_names= 80338c4a8e55Smrg old_library= 80348c4a8e55Smrg dlname= 80358c4a8e55Smrg 80368c4a8e55Smrg # Test again, we may have decided not to build it any more 80378c4a8e55Smrg if test "$build_libtool_libs" = yes; then 80380597fb56Smrg # Remove ${wl} instances when linking with ld. 80390597fb56Smrg # FIXME: should test the right _cmds variable. 80400597fb56Smrg case $archive_cmds in 80410597fb56Smrg *\$LD\ *) wl= ;; 80420597fb56Smrg esac 80438c4a8e55Smrg if test "$hardcode_into_libs" = yes; then 80448c4a8e55Smrg # Hardcode the library paths 80458c4a8e55Smrg hardcode_libdirs= 80468c4a8e55Smrg dep_rpath= 80478c4a8e55Smrg rpath="$finalize_rpath" 8048bd23fbfaSmrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 80498c4a8e55Smrg for libdir in $rpath; do 80508c4a8e55Smrg if test -n "$hardcode_libdir_flag_spec"; then 80518c4a8e55Smrg if test -n "$hardcode_libdir_separator"; then 8052bd23fbfaSmrg func_replace_sysroot "$libdir" 8053bd23fbfaSmrg libdir=$func_replace_sysroot_result 80548c4a8e55Smrg if test -z "$hardcode_libdirs"; then 80558c4a8e55Smrg hardcode_libdirs="$libdir" 80568c4a8e55Smrg else 80578c4a8e55Smrg # Just accumulate the unique libdirs. 80588c4a8e55Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 80598c4a8e55Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 80608c4a8e55Smrg ;; 80618c4a8e55Smrg *) 8062bd23fbfaSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 80638c4a8e55Smrg ;; 80648c4a8e55Smrg esac 80658c4a8e55Smrg fi 80668c4a8e55Smrg else 80678c4a8e55Smrg eval flag=\"$hardcode_libdir_flag_spec\" 8068bd23fbfaSmrg func_append dep_rpath " $flag" 80698c4a8e55Smrg fi 80708c4a8e55Smrg elif test -n "$runpath_var"; then 80718c4a8e55Smrg case "$perm_rpath " in 80728c4a8e55Smrg *" $libdir "*) ;; 80730597fb56Smrg *) func_append perm_rpath " $libdir" ;; 80748c4a8e55Smrg esac 80758c4a8e55Smrg fi 80768c4a8e55Smrg done 80778c4a8e55Smrg # Substitute the hardcoded libdirs into the rpath. 80788c4a8e55Smrg if test -n "$hardcode_libdir_separator" && 80798c4a8e55Smrg test -n "$hardcode_libdirs"; then 80808c4a8e55Smrg libdir="$hardcode_libdirs" 80810597fb56Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 80828c4a8e55Smrg fi 80838c4a8e55Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 80848c4a8e55Smrg # We should set the runpath_var. 80858c4a8e55Smrg rpath= 80868c4a8e55Smrg for dir in $perm_rpath; do 8087bd23fbfaSmrg func_append rpath "$dir:" 80888c4a8e55Smrg done 80898c4a8e55Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 80908c4a8e55Smrg fi 80918c4a8e55Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 80928c4a8e55Smrg fi 8093b042e37fSmrg 80948c4a8e55Smrg shlibpath="$finalize_shlibpath" 8095bd23fbfaSmrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 80968c4a8e55Smrg if test -n "$shlibpath"; then 80978c4a8e55Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 80988c4a8e55Smrg fi 8099b042e37fSmrg 81008c4a8e55Smrg # Get the real and link names of the library. 81018c4a8e55Smrg eval shared_ext=\"$shrext_cmds\" 81028c4a8e55Smrg eval library_names=\"$library_names_spec\" 81038c4a8e55Smrg set dummy $library_names 81048c4a8e55Smrg shift 81058c4a8e55Smrg realname="$1" 81068c4a8e55Smrg shift 8107b042e37fSmrg 81088c4a8e55Smrg if test -n "$soname_spec"; then 81098c4a8e55Smrg eval soname=\"$soname_spec\" 81108c4a8e55Smrg else 81118c4a8e55Smrg soname="$realname" 81128c4a8e55Smrg fi 81138c4a8e55Smrg if test -z "$dlname"; then 81148c4a8e55Smrg dlname=$soname 81158c4a8e55Smrg fi 8116b042e37fSmrg 81178c4a8e55Smrg lib="$output_objdir/$realname" 81188c4a8e55Smrg linknames= 81198c4a8e55Smrg for link 81208c4a8e55Smrg do 8121bd23fbfaSmrg func_append linknames " $link" 81228c4a8e55Smrg done 8123b042e37fSmrg 81248c4a8e55Smrg # Use standard objects if they are pic 8125706b6b52Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 81268c4a8e55Smrg test "X$libobjs" = "X " && libobjs= 8127b042e37fSmrg 81288c4a8e55Smrg delfiles= 81298c4a8e55Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 81308c4a8e55Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 81318c4a8e55Smrg export_symbols="$output_objdir/$libname.uexp" 8132bd23fbfaSmrg func_append delfiles " $export_symbols" 81338c4a8e55Smrg fi 8134b042e37fSmrg 81358c4a8e55Smrg orig_export_symbols= 81368c4a8e55Smrg case $host_os in 81378c4a8e55Smrg cygwin* | mingw* | cegcc*) 81388c4a8e55Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 81398c4a8e55Smrg # exporting using user supplied symfile 81408c4a8e55Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 81418c4a8e55Smrg # and it's NOT already a .def file. Must figure out 81428c4a8e55Smrg # which of the given symbols are data symbols and tag 81438c4a8e55Smrg # them as such. So, trigger use of export_symbols_cmds. 81448c4a8e55Smrg # export_symbols gets reassigned inside the "prepare 81458c4a8e55Smrg # the list of exported symbols" if statement, so the 81468c4a8e55Smrg # include_expsyms logic still works. 81478c4a8e55Smrg orig_export_symbols="$export_symbols" 81488c4a8e55Smrg export_symbols= 81498c4a8e55Smrg always_export_symbols=yes 81508c4a8e55Smrg fi 81518c4a8e55Smrg fi 81528c4a8e55Smrg ;; 81538c4a8e55Smrg esac 8154b042e37fSmrg 81558c4a8e55Smrg # Prepare the list of exported symbols 81568c4a8e55Smrg if test -z "$export_symbols"; then 81578c4a8e55Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 81588c4a8e55Smrg func_verbose "generating symbol list for \`$libname.la'" 81598c4a8e55Smrg export_symbols="$output_objdir/$libname.exp" 81608c4a8e55Smrg $opt_dry_run || $RM $export_symbols 81618c4a8e55Smrg cmds=$export_symbols_cmds 81628c4a8e55Smrg save_ifs="$IFS"; IFS='~' 8163bd23fbfaSmrg for cmd1 in $cmds; do 81648c4a8e55Smrg IFS="$save_ifs" 8165bd23fbfaSmrg # Take the normal branch if the nm_file_list_spec branch 8166bd23fbfaSmrg # doesn't work or if tool conversion is not needed. 8167bd23fbfaSmrg case $nm_file_list_spec~$to_tool_file_cmd in 8168bd23fbfaSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 8169bd23fbfaSmrg try_normal_branch=yes 8170bd23fbfaSmrg eval cmd=\"$cmd1\" 8171bd23fbfaSmrg func_len " $cmd" 8172bd23fbfaSmrg len=$func_len_result 8173bd23fbfaSmrg ;; 8174bd23fbfaSmrg *) 8175bd23fbfaSmrg try_normal_branch=no 8176bd23fbfaSmrg ;; 8177bd23fbfaSmrg esac 8178bd23fbfaSmrg if test "$try_normal_branch" = yes \ 8179bd23fbfaSmrg && { test "$len" -lt "$max_cmd_len" \ 8180bd23fbfaSmrg || test "$max_cmd_len" -le -1; } 8181bd23fbfaSmrg then 8182bd23fbfaSmrg func_show_eval "$cmd" 'exit $?' 8183bd23fbfaSmrg skipped_export=false 8184bd23fbfaSmrg elif test -n "$nm_file_list_spec"; then 8185bd23fbfaSmrg func_basename "$output" 8186bd23fbfaSmrg output_la=$func_basename_result 8187bd23fbfaSmrg save_libobjs=$libobjs 8188bd23fbfaSmrg save_output=$output 8189bd23fbfaSmrg output=${output_objdir}/${output_la}.nm 8190bd23fbfaSmrg func_to_tool_file "$output" 8191bd23fbfaSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 8192bd23fbfaSmrg func_append delfiles " $output" 8193bd23fbfaSmrg func_verbose "creating $NM input file list: $output" 8194bd23fbfaSmrg for obj in $save_libobjs; do 8195bd23fbfaSmrg func_to_tool_file "$obj" 8196bd23fbfaSmrg $ECHO "$func_to_tool_file_result" 8197bd23fbfaSmrg done > "$output" 8198bd23fbfaSmrg eval cmd=\"$cmd1\" 81998c4a8e55Smrg func_show_eval "$cmd" 'exit $?' 8200bd23fbfaSmrg output=$save_output 8201bd23fbfaSmrg libobjs=$save_libobjs 82028c4a8e55Smrg skipped_export=false 82038c4a8e55Smrg else 82048c4a8e55Smrg # The command line is too long to execute in one step. 82058c4a8e55Smrg func_verbose "using reloadable object file for export list..." 82068c4a8e55Smrg skipped_export=: 82078c4a8e55Smrg # Break out early, otherwise skipped_export may be 82088c4a8e55Smrg # set to false by a later but shorter cmd. 82098c4a8e55Smrg break 82108c4a8e55Smrg fi 82118c4a8e55Smrg done 82128c4a8e55Smrg IFS="$save_ifs" 82138c4a8e55Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 82148c4a8e55Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 82158c4a8e55Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 82168c4a8e55Smrg fi 82178c4a8e55Smrg fi 82188c4a8e55Smrg fi 8219b042e37fSmrg 82208c4a8e55Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 82218c4a8e55Smrg tmp_export_symbols="$export_symbols" 82228c4a8e55Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8223706b6b52Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 82248c4a8e55Smrg fi 8225b042e37fSmrg 82268c4a8e55Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 82278c4a8e55Smrg # The given exports_symbols file has to be filtered, so filter it. 82288c4a8e55Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 82298c4a8e55Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 82308c4a8e55Smrg # 's' commands which not all seds can handle. GNU sed should be fine 82318c4a8e55Smrg # though. Also, the filter scales superlinearly with the number of 82328c4a8e55Smrg # global variables. join(1) would be nice here, but unfortunately 82338c4a8e55Smrg # isn't a blessed tool. 82348c4a8e55Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8235bd23fbfaSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 82368c4a8e55Smrg export_symbols=$output_objdir/$libname.def 82378c4a8e55Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8238b042e37fSmrg fi 8239b042e37fSmrg 82408c4a8e55Smrg tmp_deplibs= 82418c4a8e55Smrg for test_deplib in $deplibs; do 82428c4a8e55Smrg case " $convenience " in 82438c4a8e55Smrg *" $test_deplib "*) ;; 82448c4a8e55Smrg *) 8245bd23fbfaSmrg func_append tmp_deplibs " $test_deplib" 82468c4a8e55Smrg ;; 82478c4a8e55Smrg esac 82488c4a8e55Smrg done 82498c4a8e55Smrg deplibs="$tmp_deplibs" 8250b042e37fSmrg 82518c4a8e55Smrg if test -n "$convenience"; then 82528c4a8e55Smrg if test -n "$whole_archive_flag_spec" && 82538c4a8e55Smrg test "$compiler_needs_object" = yes && 82548c4a8e55Smrg test -z "$libobjs"; then 82558c4a8e55Smrg # extract the archives, so we have objects to list. 82568c4a8e55Smrg # TODO: could optimize this to just extract one archive. 82578c4a8e55Smrg whole_archive_flag_spec= 82588c4a8e55Smrg fi 82598c4a8e55Smrg if test -n "$whole_archive_flag_spec"; then 82608c4a8e55Smrg save_libobjs=$libobjs 82618c4a8e55Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 82628c4a8e55Smrg test "X$libobjs" = "X " && libobjs= 82638c4a8e55Smrg else 82648c4a8e55Smrg gentop="$output_objdir/${outputname}x" 8265bd23fbfaSmrg func_append generated " $gentop" 8266b042e37fSmrg 82678c4a8e55Smrg func_extract_archives $gentop $convenience 8268bd23fbfaSmrg func_append libobjs " $func_extract_archives_result" 82698c4a8e55Smrg test "X$libobjs" = "X " && libobjs= 82708c4a8e55Smrg fi 82718c4a8e55Smrg fi 8272b042e37fSmrg 82738c4a8e55Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 82748c4a8e55Smrg eval flag=\"$thread_safe_flag_spec\" 8275bd23fbfaSmrg func_append linker_flags " $flag" 82768c4a8e55Smrg fi 8277b042e37fSmrg 82788c4a8e55Smrg # Make a backup of the uninstalled library when relinking 8279bd23fbfaSmrg if test "$opt_mode" = relink; then 82808c4a8e55Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 8281b042e37fSmrg fi 8282b042e37fSmrg 82838c4a8e55Smrg # Do each of the archive commands. 82848c4a8e55Smrg if test "$module" = yes && test -n "$module_cmds" ; then 82858c4a8e55Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 82868c4a8e55Smrg eval test_cmds=\"$module_expsym_cmds\" 82878c4a8e55Smrg cmds=$module_expsym_cmds 82888c4a8e55Smrg else 82898c4a8e55Smrg eval test_cmds=\"$module_cmds\" 82908c4a8e55Smrg cmds=$module_cmds 82918c4a8e55Smrg fi 82928c4a8e55Smrg else 82938c4a8e55Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 82948c4a8e55Smrg eval test_cmds=\"$archive_expsym_cmds\" 82958c4a8e55Smrg cmds=$archive_expsym_cmds 82968c4a8e55Smrg else 82978c4a8e55Smrg eval test_cmds=\"$archive_cmds\" 82988c4a8e55Smrg cmds=$archive_cmds 82998c4a8e55Smrg fi 8300b042e37fSmrg fi 8301b042e37fSmrg 83028c4a8e55Smrg if test "X$skipped_export" != "X:" && 83038c4a8e55Smrg func_len " $test_cmds" && 83048c4a8e55Smrg len=$func_len_result && 83058c4a8e55Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 83068c4a8e55Smrg : 83078c4a8e55Smrg else 83088c4a8e55Smrg # The command line is too long to link in one step, link piecewise 83098c4a8e55Smrg # or, if using GNU ld and skipped_export is not :, use a linker 83108c4a8e55Smrg # script. 8311b042e37fSmrg 83128c4a8e55Smrg # Save the value of $output and $libobjs because we want to 83138c4a8e55Smrg # use them later. If we have whole_archive_flag_spec, we 83148c4a8e55Smrg # want to use save_libobjs as it was before 83158c4a8e55Smrg # whole_archive_flag_spec was expanded, because we can't 83168c4a8e55Smrg # assume the linker understands whole_archive_flag_spec. 83178c4a8e55Smrg # This may have to be revisited, in case too many 83188c4a8e55Smrg # convenience libraries get linked in and end up exceeding 83198c4a8e55Smrg # the spec. 83208c4a8e55Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 83218c4a8e55Smrg save_libobjs=$libobjs 83228c4a8e55Smrg fi 83238c4a8e55Smrg save_output=$output 8324706b6b52Smrg func_basename "$output" 8325706b6b52Smrg output_la=$func_basename_result 8326b042e37fSmrg 83278c4a8e55Smrg # Clear the reloadable object creation command queue and 83288c4a8e55Smrg # initialize k to one. 83298c4a8e55Smrg test_cmds= 83308c4a8e55Smrg concat_cmds= 83318c4a8e55Smrg objlist= 83328c4a8e55Smrg last_robj= 83338c4a8e55Smrg k=1 8334b042e37fSmrg 83358c4a8e55Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 83368c4a8e55Smrg output=${output_objdir}/${output_la}.lnkscript 83378c4a8e55Smrg func_verbose "creating GNU ld script: $output" 8338706b6b52Smrg echo 'INPUT (' > $output 83398c4a8e55Smrg for obj in $save_libobjs 83408c4a8e55Smrg do 8341bd23fbfaSmrg func_to_tool_file "$obj" 8342bd23fbfaSmrg $ECHO "$func_to_tool_file_result" >> $output 83438c4a8e55Smrg done 8344706b6b52Smrg echo ')' >> $output 8345bd23fbfaSmrg func_append delfiles " $output" 8346bd23fbfaSmrg func_to_tool_file "$output" 8347bd23fbfaSmrg output=$func_to_tool_file_result 83488c4a8e55Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 83498c4a8e55Smrg output=${output_objdir}/${output_la}.lnk 83508c4a8e55Smrg func_verbose "creating linker input file list: $output" 83518c4a8e55Smrg : > $output 83528c4a8e55Smrg set x $save_libobjs 83538c4a8e55Smrg shift 83548c4a8e55Smrg firstobj= 83558c4a8e55Smrg if test "$compiler_needs_object" = yes; then 83568c4a8e55Smrg firstobj="$1 " 83578c4a8e55Smrg shift 83588c4a8e55Smrg fi 83598c4a8e55Smrg for obj 83608c4a8e55Smrg do 8361bd23fbfaSmrg func_to_tool_file "$obj" 8362bd23fbfaSmrg $ECHO "$func_to_tool_file_result" >> $output 83638c4a8e55Smrg done 8364bd23fbfaSmrg func_append delfiles " $output" 8365bd23fbfaSmrg func_to_tool_file "$output" 8366bd23fbfaSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 83678c4a8e55Smrg else 83688c4a8e55Smrg if test -n "$save_libobjs"; then 83698c4a8e55Smrg func_verbose "creating reloadable object files..." 83708c4a8e55Smrg output=$output_objdir/$output_la-${k}.$objext 83718c4a8e55Smrg eval test_cmds=\"$reload_cmds\" 83728c4a8e55Smrg func_len " $test_cmds" 83738c4a8e55Smrg len0=$func_len_result 83748c4a8e55Smrg len=$len0 83758c4a8e55Smrg 83768c4a8e55Smrg # Loop over the list of objects to be linked. 83778c4a8e55Smrg for obj in $save_libobjs 83788c4a8e55Smrg do 83798c4a8e55Smrg func_len " $obj" 83808c4a8e55Smrg func_arith $len + $func_len_result 83818c4a8e55Smrg len=$func_arith_result 83828c4a8e55Smrg if test "X$objlist" = X || 83838c4a8e55Smrg test "$len" -lt "$max_cmd_len"; then 83848c4a8e55Smrg func_append objlist " $obj" 83858c4a8e55Smrg else 83868c4a8e55Smrg # The command $test_cmds is almost too long, add a 83878c4a8e55Smrg # command to the queue. 83888c4a8e55Smrg if test "$k" -eq 1 ; then 83898c4a8e55Smrg # The first file doesn't have a previous command to add. 8390706b6b52Smrg reload_objs=$objlist 8391706b6b52Smrg eval concat_cmds=\"$reload_cmds\" 83928c4a8e55Smrg else 83938c4a8e55Smrg # All subsequent reloadable object files will link in 83948c4a8e55Smrg # the last one created. 8395706b6b52Smrg reload_objs="$objlist $last_robj" 8396706b6b52Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 83978c4a8e55Smrg fi 83988c4a8e55Smrg last_robj=$output_objdir/$output_la-${k}.$objext 83998c4a8e55Smrg func_arith $k + 1 84008c4a8e55Smrg k=$func_arith_result 84018c4a8e55Smrg output=$output_objdir/$output_la-${k}.$objext 8402706b6b52Smrg objlist=" $obj" 84038c4a8e55Smrg func_len " $last_robj" 84048c4a8e55Smrg func_arith $len0 + $func_len_result 84058c4a8e55Smrg len=$func_arith_result 84068c4a8e55Smrg fi 84078c4a8e55Smrg done 84088c4a8e55Smrg # Handle the remaining objects by creating one last 84098c4a8e55Smrg # reloadable object file. All subsequent reloadable object 84108c4a8e55Smrg # files will link in the last one created. 84118c4a8e55Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8412706b6b52Smrg reload_objs="$objlist $last_robj" 8413706b6b52Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 84148c4a8e55Smrg if test -n "$last_robj"; then 84158c4a8e55Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 84168c4a8e55Smrg fi 8417bd23fbfaSmrg func_append delfiles " $output" 8418b042e37fSmrg 84198c4a8e55Smrg else 84208c4a8e55Smrg output= 84218c4a8e55Smrg fi 8422b042e37fSmrg 84238c4a8e55Smrg if ${skipped_export-false}; then 84248c4a8e55Smrg func_verbose "generating symbol list for \`$libname.la'" 84258c4a8e55Smrg export_symbols="$output_objdir/$libname.exp" 84268c4a8e55Smrg $opt_dry_run || $RM $export_symbols 84278c4a8e55Smrg libobjs=$output 84288c4a8e55Smrg # Append the command to create the export file. 84298c4a8e55Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 84308c4a8e55Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 84318c4a8e55Smrg if test -n "$last_robj"; then 84328c4a8e55Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 84338c4a8e55Smrg fi 84348c4a8e55Smrg fi 8435b042e37fSmrg 84368c4a8e55Smrg test -n "$save_libobjs" && 84378c4a8e55Smrg func_verbose "creating a temporary reloadable object file: $output" 8438b042e37fSmrg 84398c4a8e55Smrg # Loop through the commands generated above and execute them. 84408c4a8e55Smrg save_ifs="$IFS"; IFS='~' 84418c4a8e55Smrg for cmd in $concat_cmds; do 84428c4a8e55Smrg IFS="$save_ifs" 84438c4a8e55Smrg $opt_silent || { 84448c4a8e55Smrg func_quote_for_expand "$cmd" 84458c4a8e55Smrg eval "func_echo $func_quote_for_expand_result" 84468c4a8e55Smrg } 84478c4a8e55Smrg $opt_dry_run || eval "$cmd" || { 84488c4a8e55Smrg lt_exit=$? 84498c4a8e55Smrg 84508c4a8e55Smrg # Restore the uninstalled library and exit 8451bd23fbfaSmrg if test "$opt_mode" = relink; then 84528c4a8e55Smrg ( cd "$output_objdir" && \ 84538c4a8e55Smrg $RM "${realname}T" && \ 84548c4a8e55Smrg $MV "${realname}U" "$realname" ) 84558c4a8e55Smrg fi 8456b042e37fSmrg 84578c4a8e55Smrg exit $lt_exit 84588c4a8e55Smrg } 84598c4a8e55Smrg done 84608c4a8e55Smrg IFS="$save_ifs" 84618c4a8e55Smrg 84628c4a8e55Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 84638c4a8e55Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 84648c4a8e55Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8465b042e37fSmrg fi 8466b042e37fSmrg fi 8467b042e37fSmrg 84688c4a8e55Smrg if ${skipped_export-false}; then 84698c4a8e55Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 84708c4a8e55Smrg tmp_export_symbols="$export_symbols" 84718c4a8e55Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8472706b6b52Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 84738c4a8e55Smrg fi 8474b042e37fSmrg 84758c4a8e55Smrg if test -n "$orig_export_symbols"; then 84768c4a8e55Smrg # The given exports_symbols file has to be filtered, so filter it. 84778c4a8e55Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 84788c4a8e55Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 84798c4a8e55Smrg # 's' commands which not all seds can handle. GNU sed should be fine 84808c4a8e55Smrg # though. Also, the filter scales superlinearly with the number of 84818c4a8e55Smrg # global variables. join(1) would be nice here, but unfortunately 84828c4a8e55Smrg # isn't a blessed tool. 84838c4a8e55Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8484bd23fbfaSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 84858c4a8e55Smrg export_symbols=$output_objdir/$libname.def 84868c4a8e55Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 84878c4a8e55Smrg fi 84888c4a8e55Smrg fi 8489b042e37fSmrg 84908c4a8e55Smrg libobjs=$output 84918c4a8e55Smrg # Restore the value of output. 84928c4a8e55Smrg output=$save_output 8493b042e37fSmrg 84948c4a8e55Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 84958c4a8e55Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 84968c4a8e55Smrg test "X$libobjs" = "X " && libobjs= 84978c4a8e55Smrg fi 84988c4a8e55Smrg # Expand the library linking commands again to reset the 84998c4a8e55Smrg # value of $libobjs for piecewise linking. 85008c4a8e55Smrg 85018c4a8e55Smrg # Do each of the archive commands. 85028c4a8e55Smrg if test "$module" = yes && test -n "$module_cmds" ; then 85038c4a8e55Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 85048c4a8e55Smrg cmds=$module_expsym_cmds 8505b042e37fSmrg else 85068c4a8e55Smrg cmds=$module_cmds 8507b042e37fSmrg fi 8508b042e37fSmrg else 85098c4a8e55Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 85108c4a8e55Smrg cmds=$archive_expsym_cmds 85118c4a8e55Smrg else 85128c4a8e55Smrg cmds=$archive_cmds 85138c4a8e55Smrg fi 8514b042e37fSmrg fi 8515b042e37fSmrg fi 8516b042e37fSmrg 85178c4a8e55Smrg if test -n "$delfiles"; then 85188c4a8e55Smrg # Append the command to remove temporary files to $cmds. 85198c4a8e55Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 85208c4a8e55Smrg fi 8521b042e37fSmrg 85228c4a8e55Smrg # Add any objects from preloaded convenience libraries 85238c4a8e55Smrg if test -n "$dlprefiles"; then 85248c4a8e55Smrg gentop="$output_objdir/${outputname}x" 8525bd23fbfaSmrg func_append generated " $gentop" 8526b042e37fSmrg 85278c4a8e55Smrg func_extract_archives $gentop $dlprefiles 8528bd23fbfaSmrg func_append libobjs " $func_extract_archives_result" 85298c4a8e55Smrg test "X$libobjs" = "X " && libobjs= 8530b042e37fSmrg fi 8531b042e37fSmrg 85328c4a8e55Smrg save_ifs="$IFS"; IFS='~' 85338c4a8e55Smrg for cmd in $cmds; do 85348c4a8e55Smrg IFS="$save_ifs" 85358c4a8e55Smrg eval cmd=\"$cmd\" 85368c4a8e55Smrg $opt_silent || { 85378c4a8e55Smrg func_quote_for_expand "$cmd" 85388c4a8e55Smrg eval "func_echo $func_quote_for_expand_result" 85398c4a8e55Smrg } 85408c4a8e55Smrg $opt_dry_run || eval "$cmd" || { 85418c4a8e55Smrg lt_exit=$? 8542b042e37fSmrg 85438c4a8e55Smrg # Restore the uninstalled library and exit 8544bd23fbfaSmrg if test "$opt_mode" = relink; then 85458c4a8e55Smrg ( cd "$output_objdir" && \ 85468c4a8e55Smrg $RM "${realname}T" && \ 85478c4a8e55Smrg $MV "${realname}U" "$realname" ) 85488c4a8e55Smrg fi 85498c4a8e55Smrg 85508c4a8e55Smrg exit $lt_exit 85518c4a8e55Smrg } 85528c4a8e55Smrg done 85538c4a8e55Smrg IFS="$save_ifs" 85548c4a8e55Smrg 85558c4a8e55Smrg # Restore the uninstalled library and exit 8556bd23fbfaSmrg if test "$opt_mode" = relink; then 85578c4a8e55Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 85588c4a8e55Smrg 85598c4a8e55Smrg if test -n "$convenience"; then 85608c4a8e55Smrg if test -z "$whole_archive_flag_spec"; then 85618c4a8e55Smrg func_show_eval '${RM}r "$gentop"' 8562b042e37fSmrg fi 8563b042e37fSmrg fi 8564b042e37fSmrg 85658c4a8e55Smrg exit $EXIT_SUCCESS 85668c4a8e55Smrg fi 8567b042e37fSmrg 85688c4a8e55Smrg # Create links to the real library. 85698c4a8e55Smrg for linkname in $linknames; do 85708c4a8e55Smrg if test "$realname" != "$linkname"; then 85718c4a8e55Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 85728c4a8e55Smrg fi 85738c4a8e55Smrg done 85748c4a8e55Smrg 85758c4a8e55Smrg # If -module or -export-dynamic was specified, set the dlname. 85768c4a8e55Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 85778c4a8e55Smrg # On all known operating systems, these are identical. 85788c4a8e55Smrg dlname="$soname" 85798c4a8e55Smrg fi 85808c4a8e55Smrg fi 85818c4a8e55Smrg ;; 85828c4a8e55Smrg 85838c4a8e55Smrg obj) 85848c4a8e55Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 85858c4a8e55Smrg func_warning "\`-dlopen' is ignored for objects" 85868c4a8e55Smrg fi 85878c4a8e55Smrg 85888c4a8e55Smrg case " $deplibs" in 85898c4a8e55Smrg *\ -l* | *\ -L*) 85908c4a8e55Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 85918c4a8e55Smrg esac 85928c4a8e55Smrg 85938c4a8e55Smrg test -n "$rpath" && \ 85948c4a8e55Smrg func_warning "\`-rpath' is ignored for objects" 85958c4a8e55Smrg 85968c4a8e55Smrg test -n "$xrpath" && \ 85978c4a8e55Smrg func_warning "\`-R' is ignored for objects" 85988c4a8e55Smrg 85998c4a8e55Smrg test -n "$vinfo" && \ 86008c4a8e55Smrg func_warning "\`-version-info' is ignored for objects" 86018c4a8e55Smrg 86028c4a8e55Smrg test -n "$release" && \ 86038c4a8e55Smrg func_warning "\`-release' is ignored for objects" 86048c4a8e55Smrg 86058c4a8e55Smrg case $output in 86068c4a8e55Smrg *.lo) 86078c4a8e55Smrg test -n "$objs$old_deplibs" && \ 86088c4a8e55Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 86098c4a8e55Smrg 86108c4a8e55Smrg libobj=$output 86118c4a8e55Smrg func_lo2o "$libobj" 86128c4a8e55Smrg obj=$func_lo2o_result 86138c4a8e55Smrg ;; 86148c4a8e55Smrg *) 86158c4a8e55Smrg libobj= 86168c4a8e55Smrg obj="$output" 86178c4a8e55Smrg ;; 86188c4a8e55Smrg esac 86198c4a8e55Smrg 86208c4a8e55Smrg # Delete the old objects. 86218c4a8e55Smrg $opt_dry_run || $RM $obj $libobj 86228c4a8e55Smrg 86238c4a8e55Smrg # Objects from convenience libraries. This assumes 86248c4a8e55Smrg # single-version convenience libraries. Whenever we create 86258c4a8e55Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 86268c4a8e55Smrg # the extraction. 86278c4a8e55Smrg reload_conv_objs= 86288c4a8e55Smrg gentop= 86298c4a8e55Smrg # reload_cmds runs $LD directly, so let us get rid of 86308c4a8e55Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 86318c4a8e55Smrg # turning comma into space.. 86328c4a8e55Smrg wl= 86338c4a8e55Smrg 86348c4a8e55Smrg if test -n "$convenience"; then 86358c4a8e55Smrg if test -n "$whole_archive_flag_spec"; then 86368c4a8e55Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 8637706b6b52Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 86388c4a8e55Smrg else 86398c4a8e55Smrg gentop="$output_objdir/${obj}x" 8640bd23fbfaSmrg func_append generated " $gentop" 86418c4a8e55Smrg 86428c4a8e55Smrg func_extract_archives $gentop $convenience 86438c4a8e55Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 86448c4a8e55Smrg fi 86458c4a8e55Smrg fi 8646b042e37fSmrg 8647bd23fbfaSmrg # If we're not building shared, we need to use non_pic_objs 8648bd23fbfaSmrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 8649bd23fbfaSmrg 86508c4a8e55Smrg # Create the old-style object. 8651706b6b52Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 8652b042e37fSmrg 86538c4a8e55Smrg output="$obj" 86548c4a8e55Smrg func_execute_cmds "$reload_cmds" 'exit $?' 8655b042e37fSmrg 86568c4a8e55Smrg # Exit if we aren't doing a library object file. 86578c4a8e55Smrg if test -z "$libobj"; then 86588c4a8e55Smrg if test -n "$gentop"; then 86598c4a8e55Smrg func_show_eval '${RM}r "$gentop"' 86608c4a8e55Smrg fi 8661b042e37fSmrg 86628c4a8e55Smrg exit $EXIT_SUCCESS 86638c4a8e55Smrg fi 8664b042e37fSmrg 86658c4a8e55Smrg if test "$build_libtool_libs" != yes; then 86668c4a8e55Smrg if test -n "$gentop"; then 86678c4a8e55Smrg func_show_eval '${RM}r "$gentop"' 86688c4a8e55Smrg fi 8669b042e37fSmrg 86708c4a8e55Smrg # Create an invalid libtool object if no PIC, so that we don't 86718c4a8e55Smrg # accidentally link it into a program. 86728c4a8e55Smrg # $show "echo timestamp > $libobj" 86738c4a8e55Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 86748c4a8e55Smrg exit $EXIT_SUCCESS 86758c4a8e55Smrg fi 8676b042e37fSmrg 86778c4a8e55Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 86788c4a8e55Smrg # Only do commands if we really have different PIC objects. 86798c4a8e55Smrg reload_objs="$libobjs $reload_conv_objs" 86808c4a8e55Smrg output="$libobj" 86818c4a8e55Smrg func_execute_cmds "$reload_cmds" 'exit $?' 8682b042e37fSmrg fi 8683b042e37fSmrg 86848c4a8e55Smrg if test -n "$gentop"; then 86858c4a8e55Smrg func_show_eval '${RM}r "$gentop"' 86868c4a8e55Smrg fi 8687b042e37fSmrg 86888c4a8e55Smrg exit $EXIT_SUCCESS 86898c4a8e55Smrg ;; 8690b042e37fSmrg 86918c4a8e55Smrg prog) 86928c4a8e55Smrg case $host in 86938c4a8e55Smrg *cygwin*) func_stripname '' '.exe' "$output" 86948c4a8e55Smrg output=$func_stripname_result.exe;; 8695b042e37fSmrg esac 86968c4a8e55Smrg test -n "$vinfo" && \ 86978c4a8e55Smrg func_warning "\`-version-info' is ignored for programs" 8698b042e37fSmrg 86998c4a8e55Smrg test -n "$release" && \ 87008c4a8e55Smrg func_warning "\`-release' is ignored for programs" 8701b042e37fSmrg 87028c4a8e55Smrg test "$preload" = yes \ 87038c4a8e55Smrg && test "$dlopen_support" = unknown \ 87048c4a8e55Smrg && test "$dlopen_self" = unknown \ 87058c4a8e55Smrg && test "$dlopen_self_static" = unknown && \ 87068c4a8e55Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 8707b042e37fSmrg 87088c4a8e55Smrg case $host in 87098c4a8e55Smrg *-*-rhapsody* | *-*-darwin1.[012]) 87108c4a8e55Smrg # On Rhapsody replace the C library is the System framework 8711706b6b52Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 8712706b6b52Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 8713b042e37fSmrg ;; 8714b042e37fSmrg esac 8715b042e37fSmrg 87168c4a8e55Smrg case $host in 87178c4a8e55Smrg *-*-darwin*) 87188c4a8e55Smrg # Don't allow lazy linking, it breaks C++ global constructors 87198c4a8e55Smrg # But is supposedly fixed on 10.4 or later (yay!). 87208c4a8e55Smrg if test "$tagname" = CXX ; then 87218c4a8e55Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 87228c4a8e55Smrg 10.[0123]) 8723bd23fbfaSmrg func_append compile_command " ${wl}-bind_at_load" 8724bd23fbfaSmrg func_append finalize_command " ${wl}-bind_at_load" 87258c4a8e55Smrg ;; 87268c4a8e55Smrg esac 87278c4a8e55Smrg fi 87288c4a8e55Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 8729706b6b52Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8730706b6b52Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8731b042e37fSmrg ;; 8732b042e37fSmrg esac 8733b042e37fSmrg 8734b042e37fSmrg 87358c4a8e55Smrg # move library search paths that coincide with paths to not yet 87368c4a8e55Smrg # installed libraries to the beginning of the library search list 87378c4a8e55Smrg new_libs= 87388c4a8e55Smrg for path in $notinst_path; do 87398c4a8e55Smrg case " $new_libs " in 87408c4a8e55Smrg *" -L$path/$objdir "*) ;; 8741b042e37fSmrg *) 87428c4a8e55Smrg case " $compile_deplibs " in 87438c4a8e55Smrg *" -L$path/$objdir "*) 8744bd23fbfaSmrg func_append new_libs " -L$path/$objdir" ;; 87458c4a8e55Smrg esac 8746b042e37fSmrg ;; 8747b042e37fSmrg esac 8748b042e37fSmrg done 87498c4a8e55Smrg for deplib in $compile_deplibs; do 87508c4a8e55Smrg case $deplib in 87518c4a8e55Smrg -L*) 87528c4a8e55Smrg case " $new_libs " in 87538c4a8e55Smrg *" $deplib "*) ;; 8754bd23fbfaSmrg *) func_append new_libs " $deplib" ;; 87558c4a8e55Smrg esac 87568c4a8e55Smrg ;; 8757bd23fbfaSmrg *) func_append new_libs " $deplib" ;; 87588c4a8e55Smrg esac 87598c4a8e55Smrg done 87608c4a8e55Smrg compile_deplibs="$new_libs" 8761b042e37fSmrg 8762b042e37fSmrg 8763bd23fbfaSmrg func_append compile_command " $compile_deplibs" 8764bd23fbfaSmrg func_append finalize_command " $finalize_deplibs" 8765b042e37fSmrg 87668c4a8e55Smrg if test -n "$rpath$xrpath"; then 87678c4a8e55Smrg # If the user specified any rpath flags, then add them. 87688c4a8e55Smrg for libdir in $rpath $xrpath; do 87698c4a8e55Smrg # This is the magic to use -rpath. 87708c4a8e55Smrg case "$finalize_rpath " in 87718c4a8e55Smrg *" $libdir "*) ;; 8772bd23fbfaSmrg *) func_append finalize_rpath " $libdir" ;; 87738c4a8e55Smrg esac 87748c4a8e55Smrg done 87758c4a8e55Smrg fi 8776b042e37fSmrg 87778c4a8e55Smrg # Now hardcode the library paths 87788c4a8e55Smrg rpath= 87798c4a8e55Smrg hardcode_libdirs= 87808c4a8e55Smrg for libdir in $compile_rpath $finalize_rpath; do 87818c4a8e55Smrg if test -n "$hardcode_libdir_flag_spec"; then 87828c4a8e55Smrg if test -n "$hardcode_libdir_separator"; then 87838c4a8e55Smrg if test -z "$hardcode_libdirs"; then 87848c4a8e55Smrg hardcode_libdirs="$libdir" 87858c4a8e55Smrg else 87868c4a8e55Smrg # Just accumulate the unique libdirs. 87878c4a8e55Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 87888c4a8e55Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 87898c4a8e55Smrg ;; 87908c4a8e55Smrg *) 8791bd23fbfaSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 87928c4a8e55Smrg ;; 87938c4a8e55Smrg esac 87948c4a8e55Smrg fi 87958c4a8e55Smrg else 87968c4a8e55Smrg eval flag=\"$hardcode_libdir_flag_spec\" 8797bd23fbfaSmrg func_append rpath " $flag" 87988c4a8e55Smrg fi 87998c4a8e55Smrg elif test -n "$runpath_var"; then 88008c4a8e55Smrg case "$perm_rpath " in 8801b042e37fSmrg *" $libdir "*) ;; 8802bd23fbfaSmrg *) func_append perm_rpath " $libdir" ;; 8803b042e37fSmrg esac 88048c4a8e55Smrg fi 88058c4a8e55Smrg case $host in 88068c4a8e55Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 88078c4a8e55Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 88088c4a8e55Smrg case :$dllsearchpath: in 88098c4a8e55Smrg *":$libdir:"*) ;; 88108c4a8e55Smrg ::) dllsearchpath=$libdir;; 8811bd23fbfaSmrg *) func_append dllsearchpath ":$libdir";; 88128c4a8e55Smrg esac 88138c4a8e55Smrg case :$dllsearchpath: in 88148c4a8e55Smrg *":$testbindir:"*) ;; 88158c4a8e55Smrg ::) dllsearchpath=$testbindir;; 8816bd23fbfaSmrg *) func_append dllsearchpath ":$testbindir";; 88178c4a8e55Smrg esac 88188c4a8e55Smrg ;; 88198c4a8e55Smrg esac 88208c4a8e55Smrg done 88218c4a8e55Smrg # Substitute the hardcoded libdirs into the rpath. 88228c4a8e55Smrg if test -n "$hardcode_libdir_separator" && 88238c4a8e55Smrg test -n "$hardcode_libdirs"; then 88248c4a8e55Smrg libdir="$hardcode_libdirs" 88258c4a8e55Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 88268c4a8e55Smrg fi 88278c4a8e55Smrg compile_rpath="$rpath" 88288c4a8e55Smrg 88298c4a8e55Smrg rpath= 88308c4a8e55Smrg hardcode_libdirs= 88318c4a8e55Smrg for libdir in $finalize_rpath; do 88328c4a8e55Smrg if test -n "$hardcode_libdir_flag_spec"; then 88338c4a8e55Smrg if test -n "$hardcode_libdir_separator"; then 88348c4a8e55Smrg if test -z "$hardcode_libdirs"; then 88358c4a8e55Smrg hardcode_libdirs="$libdir" 88368c4a8e55Smrg else 88378c4a8e55Smrg # Just accumulate the unique libdirs. 88388c4a8e55Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 88398c4a8e55Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 88408c4a8e55Smrg ;; 88418c4a8e55Smrg *) 8842bd23fbfaSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 88438c4a8e55Smrg ;; 88448c4a8e55Smrg esac 88458c4a8e55Smrg fi 88468c4a8e55Smrg else 88478c4a8e55Smrg eval flag=\"$hardcode_libdir_flag_spec\" 8848bd23fbfaSmrg func_append rpath " $flag" 88498c4a8e55Smrg fi 88508c4a8e55Smrg elif test -n "$runpath_var"; then 88518c4a8e55Smrg case "$finalize_perm_rpath " in 8852b042e37fSmrg *" $libdir "*) ;; 8853bd23fbfaSmrg *) func_append finalize_perm_rpath " $libdir" ;; 8854b042e37fSmrg esac 8855b042e37fSmrg fi 88568c4a8e55Smrg done 88578c4a8e55Smrg # Substitute the hardcoded libdirs into the rpath. 88588c4a8e55Smrg if test -n "$hardcode_libdir_separator" && 88598c4a8e55Smrg test -n "$hardcode_libdirs"; then 88608c4a8e55Smrg libdir="$hardcode_libdirs" 88618c4a8e55Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 88628c4a8e55Smrg fi 88638c4a8e55Smrg finalize_rpath="$rpath" 8864b042e37fSmrg 88658c4a8e55Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 88668c4a8e55Smrg # Transform all the library objects into standard objects. 8867706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8868706b6b52Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 88698c4a8e55Smrg fi 8870b042e37fSmrg 88718c4a8e55Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8872b042e37fSmrg 88738c4a8e55Smrg # template prelinking step 88748c4a8e55Smrg if test -n "$prelink_cmds"; then 88758c4a8e55Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 88768c4a8e55Smrg fi 8877b042e37fSmrg 88788c4a8e55Smrg wrappers_required=yes 88798c4a8e55Smrg case $host in 8880706b6b52Smrg *cegcc* | *mingw32ce*) 8881706b6b52Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 8882706b6b52Smrg wrappers_required=no 8883706b6b52Smrg ;; 88848c4a8e55Smrg *cygwin* | *mingw* ) 88858c4a8e55Smrg if test "$build_libtool_libs" != yes; then 88868c4a8e55Smrg wrappers_required=no 88878c4a8e55Smrg fi 88888c4a8e55Smrg ;; 88898c4a8e55Smrg *) 88908c4a8e55Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 88918c4a8e55Smrg wrappers_required=no 88928c4a8e55Smrg fi 88938c4a8e55Smrg ;; 88948c4a8e55Smrg esac 88958c4a8e55Smrg if test "$wrappers_required" = no; then 88968c4a8e55Smrg # Replace the output file specification. 8897706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 88988c4a8e55Smrg link_command="$compile_command$compile_rpath" 8899b042e37fSmrg 89008c4a8e55Smrg # We have no uninstalled library dependencies, so finalize right now. 89018c4a8e55Smrg exit_status=0 89028c4a8e55Smrg func_show_eval "$link_command" 'exit_status=$?' 8903b042e37fSmrg 8904bd23fbfaSmrg if test -n "$postlink_cmds"; then 8905bd23fbfaSmrg func_to_tool_file "$output" 8906bd23fbfaSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8907bd23fbfaSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 8908bd23fbfaSmrg fi 8909bd23fbfaSmrg 89108c4a8e55Smrg # Delete the generated files. 89118c4a8e55Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 89128c4a8e55Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 89138c4a8e55Smrg fi 8914b042e37fSmrg 89158c4a8e55Smrg exit $exit_status 89168c4a8e55Smrg fi 8917b042e37fSmrg 89188c4a8e55Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 89198c4a8e55Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 89208c4a8e55Smrg fi 89218c4a8e55Smrg if test -n "$finalize_shlibpath"; then 89228c4a8e55Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 89238c4a8e55Smrg fi 8924b042e37fSmrg 89258c4a8e55Smrg compile_var= 89268c4a8e55Smrg finalize_var= 89278c4a8e55Smrg if test -n "$runpath_var"; then 89288c4a8e55Smrg if test -n "$perm_rpath"; then 89298c4a8e55Smrg # We should set the runpath_var. 89308c4a8e55Smrg rpath= 89318c4a8e55Smrg for dir in $perm_rpath; do 8932bd23fbfaSmrg func_append rpath "$dir:" 8933b042e37fSmrg done 89348c4a8e55Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8935b042e37fSmrg fi 89368c4a8e55Smrg if test -n "$finalize_perm_rpath"; then 89378c4a8e55Smrg # We should set the runpath_var. 89388c4a8e55Smrg rpath= 89398c4a8e55Smrg for dir in $finalize_perm_rpath; do 8940bd23fbfaSmrg func_append rpath "$dir:" 89418c4a8e55Smrg done 89428c4a8e55Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 89438c4a8e55Smrg fi 89448c4a8e55Smrg fi 8945b042e37fSmrg 89468c4a8e55Smrg if test "$no_install" = yes; then 89478c4a8e55Smrg # We don't need to create a wrapper script. 89488c4a8e55Smrg link_command="$compile_var$compile_command$compile_rpath" 89498c4a8e55Smrg # Replace the output file specification. 8950706b6b52Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 89518c4a8e55Smrg # Delete the old output file. 89528c4a8e55Smrg $opt_dry_run || $RM $output 89538c4a8e55Smrg # Link the executable and exit 89548c4a8e55Smrg func_show_eval "$link_command" 'exit $?' 8955bd23fbfaSmrg 8956bd23fbfaSmrg if test -n "$postlink_cmds"; then 8957bd23fbfaSmrg func_to_tool_file "$output" 8958bd23fbfaSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8959bd23fbfaSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 8960bd23fbfaSmrg fi 8961bd23fbfaSmrg 89628c4a8e55Smrg exit $EXIT_SUCCESS 89638c4a8e55Smrg fi 8964b042e37fSmrg 89658c4a8e55Smrg if test "$hardcode_action" = relink; then 89668c4a8e55Smrg # Fast installation is not supported 89678c4a8e55Smrg link_command="$compile_var$compile_command$compile_rpath" 89688c4a8e55Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8969b042e37fSmrg 89708c4a8e55Smrg func_warning "this platform does not like uninstalled shared libraries" 89718c4a8e55Smrg func_warning "\`$output' will be relinked during installation" 89728c4a8e55Smrg else 89738c4a8e55Smrg if test "$fast_install" != no; then 89748c4a8e55Smrg link_command="$finalize_var$compile_command$finalize_rpath" 89758c4a8e55Smrg if test "$fast_install" = yes; then 8976706b6b52Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 89778c4a8e55Smrg else 89788c4a8e55Smrg # fast_install is set to needless 89798c4a8e55Smrg relink_command= 89808c4a8e55Smrg fi 8981b042e37fSmrg else 89828c4a8e55Smrg link_command="$compile_var$compile_command$compile_rpath" 89838c4a8e55Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8984b042e37fSmrg fi 89858c4a8e55Smrg fi 8986b042e37fSmrg 89878c4a8e55Smrg # Replace the output file specification. 8988706b6b52Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 8989b042e37fSmrg 89908c4a8e55Smrg # Delete the old output files. 89918c4a8e55Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 8992b042e37fSmrg 89938c4a8e55Smrg func_show_eval "$link_command" 'exit $?' 8994b042e37fSmrg 8995bd23fbfaSmrg if test -n "$postlink_cmds"; then 8996bd23fbfaSmrg func_to_tool_file "$output_objdir/$outputname" 8997bd23fbfaSmrg 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'` 8998bd23fbfaSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 8999bd23fbfaSmrg fi 9000bd23fbfaSmrg 90018c4a8e55Smrg # Now create the wrapper script. 90028c4a8e55Smrg func_verbose "creating $output" 9003b042e37fSmrg 90048c4a8e55Smrg # Quote the relink command for shipping. 90058c4a8e55Smrg if test -n "$relink_command"; then 90068c4a8e55Smrg # Preserve any variables that may affect compiler behavior 90078c4a8e55Smrg for var in $variables_saved_for_relink; do 90088c4a8e55Smrg if eval test -z \"\${$var+set}\"; then 90098c4a8e55Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 90108c4a8e55Smrg elif eval var_value=\$$var; test -z "$var_value"; then 90118c4a8e55Smrg relink_command="$var=; export $var; $relink_command" 90128c4a8e55Smrg else 90138c4a8e55Smrg func_quote_for_eval "$var_value" 90148c4a8e55Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 90158c4a8e55Smrg fi 90168c4a8e55Smrg done 90178c4a8e55Smrg relink_command="(cd `pwd`; $relink_command)" 9018706b6b52Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 90198c4a8e55Smrg fi 9020b042e37fSmrg 90218c4a8e55Smrg # Only actually do things if not in dry run mode. 90228c4a8e55Smrg $opt_dry_run || { 90238c4a8e55Smrg # win32 will think the script is a binary if it has 90248c4a8e55Smrg # a .exe suffix, so we strip it off here. 90258c4a8e55Smrg case $output in 90268c4a8e55Smrg *.exe) func_stripname '' '.exe' "$output" 90278c4a8e55Smrg output=$func_stripname_result ;; 90288c4a8e55Smrg esac 90298c4a8e55Smrg # test for cygwin because mv fails w/o .exe extensions 9030b042e37fSmrg case $host in 90318c4a8e55Smrg *cygwin*) 90328c4a8e55Smrg exeext=.exe 90338c4a8e55Smrg func_stripname '' '.exe' "$outputname" 90348c4a8e55Smrg outputname=$func_stripname_result ;; 90358c4a8e55Smrg *) exeext= ;; 9036b042e37fSmrg esac 90378c4a8e55Smrg case $host in 90388c4a8e55Smrg *cygwin* | *mingw* ) 90398c4a8e55Smrg func_dirname_and_basename "$output" "" "." 90408c4a8e55Smrg output_name=$func_basename_result 90418c4a8e55Smrg output_path=$func_dirname_result 90428c4a8e55Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 90438c4a8e55Smrg cwrapper="$output_path/$output_name.exe" 90448c4a8e55Smrg $RM $cwrappersource $cwrapper 90458c4a8e55Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 90468c4a8e55Smrg 90478c4a8e55Smrg func_emit_cwrapperexe_src > $cwrappersource 90488c4a8e55Smrg 90498c4a8e55Smrg # The wrapper executable is built using the $host compiler, 90508c4a8e55Smrg # because it contains $host paths and files. If cross- 90518c4a8e55Smrg # compiling, it, like the target executable, must be 90528c4a8e55Smrg # executed on the $host or under an emulation environment. 90538c4a8e55Smrg $opt_dry_run || { 90548c4a8e55Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 90558c4a8e55Smrg $STRIP $cwrapper 90568c4a8e55Smrg } 9057b042e37fSmrg 90588c4a8e55Smrg # Now, create the wrapper script for func_source use: 90598c4a8e55Smrg func_ltwrapper_scriptname $cwrapper 90608c4a8e55Smrg $RM $func_ltwrapper_scriptname_result 90618c4a8e55Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 90628c4a8e55Smrg $opt_dry_run || { 90638c4a8e55Smrg # note: this script will not be executed, so do not chmod. 90648c4a8e55Smrg if test "x$build" = "x$host" ; then 90658c4a8e55Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 9066b042e37fSmrg else 90678c4a8e55Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 9068b042e37fSmrg fi 90698c4a8e55Smrg } 90708c4a8e55Smrg ;; 90718c4a8e55Smrg * ) 90728c4a8e55Smrg $RM $output 90738c4a8e55Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 9074b042e37fSmrg 90758c4a8e55Smrg func_emit_wrapper no > $output 90768c4a8e55Smrg chmod +x $output 9077b042e37fSmrg ;; 9078b042e37fSmrg esac 90798c4a8e55Smrg } 90808c4a8e55Smrg exit $EXIT_SUCCESS 90818c4a8e55Smrg ;; 90828c4a8e55Smrg esac 9083b042e37fSmrg 90848c4a8e55Smrg # See if we need to build an old-fashioned archive. 90858c4a8e55Smrg for oldlib in $oldlibs; do 9086b042e37fSmrg 90878c4a8e55Smrg if test "$build_libtool_libs" = convenience; then 90888c4a8e55Smrg oldobjs="$libobjs_save $symfileobj" 90898c4a8e55Smrg addlibs="$convenience" 90908c4a8e55Smrg build_libtool_libs=no 90918c4a8e55Smrg else 90928c4a8e55Smrg if test "$build_libtool_libs" = module; then 90938c4a8e55Smrg oldobjs="$libobjs_save" 90948c4a8e55Smrg build_libtool_libs=no 90958c4a8e55Smrg else 90968c4a8e55Smrg oldobjs="$old_deplibs $non_pic_objects" 90978c4a8e55Smrg if test "$preload" = yes && test -f "$symfileobj"; then 9098bd23fbfaSmrg func_append oldobjs " $symfileobj" 90998c4a8e55Smrg fi 91008c4a8e55Smrg fi 91018c4a8e55Smrg addlibs="$old_convenience" 9102b042e37fSmrg fi 9103b042e37fSmrg 91048c4a8e55Smrg if test -n "$addlibs"; then 91058c4a8e55Smrg gentop="$output_objdir/${outputname}x" 9106bd23fbfaSmrg func_append generated " $gentop" 9107b042e37fSmrg 91088c4a8e55Smrg func_extract_archives $gentop $addlibs 9109bd23fbfaSmrg func_append oldobjs " $func_extract_archives_result" 91108c4a8e55Smrg fi 9111b042e37fSmrg 91128c4a8e55Smrg # Do each command in the archive commands. 91138c4a8e55Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 91148c4a8e55Smrg cmds=$old_archive_from_new_cmds 91158c4a8e55Smrg else 9116b042e37fSmrg 91178c4a8e55Smrg # Add any objects from preloaded convenience libraries 91188c4a8e55Smrg if test -n "$dlprefiles"; then 91198c4a8e55Smrg gentop="$output_objdir/${outputname}x" 9120bd23fbfaSmrg func_append generated " $gentop" 9121b042e37fSmrg 91228c4a8e55Smrg func_extract_archives $gentop $dlprefiles 9123bd23fbfaSmrg func_append oldobjs " $func_extract_archives_result" 91248c4a8e55Smrg fi 9125b042e37fSmrg 91268c4a8e55Smrg # POSIX demands no paths to be encoded in archives. We have 91278c4a8e55Smrg # to avoid creating archives with duplicate basenames if we 91288c4a8e55Smrg # might have to extract them afterwards, e.g., when creating a 91298c4a8e55Smrg # static archive out of a convenience library, or when linking 91308c4a8e55Smrg # the entirety of a libtool archive into another (currently 91318c4a8e55Smrg # not supported by libtool). 91328c4a8e55Smrg if (for obj in $oldobjs 91338c4a8e55Smrg do 91348c4a8e55Smrg func_basename "$obj" 91358c4a8e55Smrg $ECHO "$func_basename_result" 91368c4a8e55Smrg done | sort | sort -uc >/dev/null 2>&1); then 91378c4a8e55Smrg : 91388c4a8e55Smrg else 9139706b6b52Smrg echo "copying selected object files to avoid basename conflicts..." 91408c4a8e55Smrg gentop="$output_objdir/${outputname}x" 9141bd23fbfaSmrg func_append generated " $gentop" 91428c4a8e55Smrg func_mkdir_p "$gentop" 91438c4a8e55Smrg save_oldobjs=$oldobjs 91448c4a8e55Smrg oldobjs= 91458c4a8e55Smrg counter=1 91468c4a8e55Smrg for obj in $save_oldobjs 91478c4a8e55Smrg do 91488c4a8e55Smrg func_basename "$obj" 91498c4a8e55Smrg objbase="$func_basename_result" 91508c4a8e55Smrg case " $oldobjs " in 91518c4a8e55Smrg " ") oldobjs=$obj ;; 91528c4a8e55Smrg *[\ /]"$objbase "*) 91538c4a8e55Smrg while :; do 91548c4a8e55Smrg # Make sure we don't pick an alternate name that also 91558c4a8e55Smrg # overlaps. 91568c4a8e55Smrg newobj=lt$counter-$objbase 91578c4a8e55Smrg func_arith $counter + 1 91588c4a8e55Smrg counter=$func_arith_result 91598c4a8e55Smrg case " $oldobjs " in 91608c4a8e55Smrg *[\ /]"$newobj "*) ;; 91618c4a8e55Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 91628c4a8e55Smrg esac 91638c4a8e55Smrg done 91648c4a8e55Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 9165bd23fbfaSmrg func_append oldobjs " $gentop/$newobj" 91668c4a8e55Smrg ;; 9167bd23fbfaSmrg *) func_append oldobjs " $obj" ;; 91688c4a8e55Smrg esac 9169b042e37fSmrg done 9170b042e37fSmrg fi 91710597fb56Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 91720597fb56Smrg tool_oldlib=$func_to_tool_file_result 91738c4a8e55Smrg eval cmds=\"$old_archive_cmds\" 9174b042e37fSmrg 91758c4a8e55Smrg func_len " $cmds" 91768c4a8e55Smrg len=$func_len_result 91778c4a8e55Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 91788c4a8e55Smrg cmds=$old_archive_cmds 9179bd23fbfaSmrg elif test -n "$archiver_list_spec"; then 9180bd23fbfaSmrg func_verbose "using command file archive linking..." 9181bd23fbfaSmrg for obj in $oldobjs 9182bd23fbfaSmrg do 9183bd23fbfaSmrg func_to_tool_file "$obj" 9184bd23fbfaSmrg $ECHO "$func_to_tool_file_result" 9185bd23fbfaSmrg done > $output_objdir/$libname.libcmd 9186bd23fbfaSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 9187bd23fbfaSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 9188bd23fbfaSmrg cmds=$old_archive_cmds 91898c4a8e55Smrg else 91908c4a8e55Smrg # the command line is too long to link in one step, link in parts 91918c4a8e55Smrg func_verbose "using piecewise archive linking..." 91928c4a8e55Smrg save_RANLIB=$RANLIB 91938c4a8e55Smrg RANLIB=: 91948c4a8e55Smrg objlist= 91958c4a8e55Smrg concat_cmds= 91968c4a8e55Smrg save_oldobjs=$oldobjs 91978c4a8e55Smrg oldobjs= 91988c4a8e55Smrg # Is there a better way of finding the last object in the list? 91998c4a8e55Smrg for obj in $save_oldobjs 92008c4a8e55Smrg do 92018c4a8e55Smrg last_oldobj=$obj 92028c4a8e55Smrg done 92038c4a8e55Smrg eval test_cmds=\"$old_archive_cmds\" 92048c4a8e55Smrg func_len " $test_cmds" 92058c4a8e55Smrg len0=$func_len_result 92068c4a8e55Smrg len=$len0 92078c4a8e55Smrg for obj in $save_oldobjs 92088c4a8e55Smrg do 92098c4a8e55Smrg func_len " $obj" 92108c4a8e55Smrg func_arith $len + $func_len_result 92118c4a8e55Smrg len=$func_arith_result 92128c4a8e55Smrg func_append objlist " $obj" 92138c4a8e55Smrg if test "$len" -lt "$max_cmd_len"; then 92148c4a8e55Smrg : 92158c4a8e55Smrg else 92168c4a8e55Smrg # the above command should be used before it gets too long 92178c4a8e55Smrg oldobjs=$objlist 92188c4a8e55Smrg if test "$obj" = "$last_oldobj" ; then 92198c4a8e55Smrg RANLIB=$save_RANLIB 92208c4a8e55Smrg fi 92218c4a8e55Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 92228c4a8e55Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 92238c4a8e55Smrg objlist= 92248c4a8e55Smrg len=$len0 92258c4a8e55Smrg fi 92268c4a8e55Smrg done 92278c4a8e55Smrg RANLIB=$save_RANLIB 92288c4a8e55Smrg oldobjs=$objlist 92298c4a8e55Smrg if test "X$oldobjs" = "X" ; then 92308c4a8e55Smrg eval cmds=\"\$concat_cmds\" 92318c4a8e55Smrg else 92328c4a8e55Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 92338c4a8e55Smrg fi 92348c4a8e55Smrg fi 92358c4a8e55Smrg fi 92368c4a8e55Smrg func_execute_cmds "$cmds" 'exit $?' 9237b042e37fSmrg done 9238b042e37fSmrg 92398c4a8e55Smrg test -n "$generated" && \ 92408c4a8e55Smrg func_show_eval "${RM}r$generated" 9241b042e37fSmrg 92428c4a8e55Smrg # Now create the libtool archive. 92438c4a8e55Smrg case $output in 92448c4a8e55Smrg *.la) 92458c4a8e55Smrg old_library= 92468c4a8e55Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 92478c4a8e55Smrg func_verbose "creating $output" 9248b042e37fSmrg 92498c4a8e55Smrg # Preserve any variables that may affect compiler behavior 92508c4a8e55Smrg for var in $variables_saved_for_relink; do 92518c4a8e55Smrg if eval test -z \"\${$var+set}\"; then 92528c4a8e55Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 92538c4a8e55Smrg elif eval var_value=\$$var; test -z "$var_value"; then 92548c4a8e55Smrg relink_command="$var=; export $var; $relink_command" 9255b042e37fSmrg else 92568c4a8e55Smrg func_quote_for_eval "$var_value" 92578c4a8e55Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9258b042e37fSmrg fi 92598c4a8e55Smrg done 92608c4a8e55Smrg # Quote the link command for shipping. 92618c4a8e55Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 9262706b6b52Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 92638c4a8e55Smrg if test "$hardcode_automatic" = yes ; then 92648c4a8e55Smrg relink_command= 92658c4a8e55Smrg fi 9266b042e37fSmrg 92678c4a8e55Smrg # Only create the output if not a dry run. 92688c4a8e55Smrg $opt_dry_run || { 92698c4a8e55Smrg for installed in no yes; do 92708c4a8e55Smrg if test "$installed" = yes; then 92718c4a8e55Smrg if test -z "$install_libdir"; then 92728c4a8e55Smrg break 92738c4a8e55Smrg fi 92748c4a8e55Smrg output="$output_objdir/$outputname"i 92758c4a8e55Smrg # Replace all uninstalled libtool libraries with the installed ones 92768c4a8e55Smrg newdependency_libs= 92778c4a8e55Smrg for deplib in $dependency_libs; do 92788c4a8e55Smrg case $deplib in 92798c4a8e55Smrg *.la) 92808c4a8e55Smrg func_basename "$deplib" 92818c4a8e55Smrg name="$func_basename_result" 92820597fb56Smrg func_resolve_sysroot "$deplib" 92830597fb56Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 92848c4a8e55Smrg test -z "$libdir" && \ 92858c4a8e55Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 9286bd23fbfaSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 9287bd23fbfaSmrg ;; 9288bd23fbfaSmrg -L*) 9289bd23fbfaSmrg func_stripname -L '' "$deplib" 9290bd23fbfaSmrg func_replace_sysroot "$func_stripname_result" 9291bd23fbfaSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 9292bd23fbfaSmrg ;; 9293bd23fbfaSmrg -R*) 9294bd23fbfaSmrg func_stripname -R '' "$deplib" 9295bd23fbfaSmrg func_replace_sysroot "$func_stripname_result" 9296bd23fbfaSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 92978c4a8e55Smrg ;; 9298bd23fbfaSmrg *) func_append newdependency_libs " $deplib" ;; 92998c4a8e55Smrg esac 93008c4a8e55Smrg done 93018c4a8e55Smrg dependency_libs="$newdependency_libs" 93028c4a8e55Smrg newdlfiles= 93038c4a8e55Smrg 93048c4a8e55Smrg for lib in $dlfiles; do 93058c4a8e55Smrg case $lib in 93068c4a8e55Smrg *.la) 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 newdlfiles " ${lt_sysroot:+=}$libdir/$name" 93138c4a8e55Smrg ;; 9314bd23fbfaSmrg *) func_append newdlfiles " $lib" ;; 93158c4a8e55Smrg esac 93168c4a8e55Smrg done 93178c4a8e55Smrg dlfiles="$newdlfiles" 93188c4a8e55Smrg newdlprefiles= 93198c4a8e55Smrg for lib in $dlprefiles; do 93208c4a8e55Smrg case $lib in 93218c4a8e55Smrg *.la) 93228c4a8e55Smrg # Only pass preopened files to the pseudo-archive (for 93238c4a8e55Smrg # eventual linking with the app. that links it) if we 93248c4a8e55Smrg # didn't already link the preopened objects directly into 93258c4a8e55Smrg # the library: 93268c4a8e55Smrg func_basename "$lib" 93278c4a8e55Smrg name="$func_basename_result" 93288c4a8e55Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 93298c4a8e55Smrg test -z "$libdir" && \ 93308c4a8e55Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 9331bd23fbfaSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 93328c4a8e55Smrg ;; 93338c4a8e55Smrg esac 93348c4a8e55Smrg done 93358c4a8e55Smrg dlprefiles="$newdlprefiles" 93368c4a8e55Smrg else 93378c4a8e55Smrg newdlfiles= 93388c4a8e55Smrg for lib in $dlfiles; do 93398c4a8e55Smrg case $lib in 93408c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 93418c4a8e55Smrg *) abs=`pwd`"/$lib" ;; 93428c4a8e55Smrg esac 9343bd23fbfaSmrg func_append newdlfiles " $abs" 93448c4a8e55Smrg done 93458c4a8e55Smrg dlfiles="$newdlfiles" 93468c4a8e55Smrg newdlprefiles= 93478c4a8e55Smrg for lib in $dlprefiles; do 93488c4a8e55Smrg case $lib in 93498c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 93508c4a8e55Smrg *) abs=`pwd`"/$lib" ;; 93518c4a8e55Smrg esac 9352bd23fbfaSmrg func_append newdlprefiles " $abs" 93538c4a8e55Smrg done 93548c4a8e55Smrg dlprefiles="$newdlprefiles" 93558c4a8e55Smrg fi 93568c4a8e55Smrg $RM $output 93578c4a8e55Smrg # place dlname in correct position for cygwin 9358706b6b52Smrg # In fact, it would be nice if we could use this code for all target 9359706b6b52Smrg # systems that can't hard-code library paths into their executables 9360706b6b52Smrg # and that have no shared library path variable independent of PATH, 9361706b6b52Smrg # but it turns out we can't easily determine that from inspecting 9362706b6b52Smrg # libtool variables, so we have to hard-code the OSs to which it 9363706b6b52Smrg # applies here; at the moment, that means platforms that use the PE 9364706b6b52Smrg # object format with DLL files. See the long comment at the top of 9365706b6b52Smrg # tests/bindir.at for full details. 93668c4a8e55Smrg tdlname=$dlname 93678c4a8e55Smrg case $host,$output,$installed,$module,$dlname in 9368706b6b52Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 9369706b6b52Smrg # If a -bindir argument was supplied, place the dll there. 9370706b6b52Smrg if test "x$bindir" != x ; 9371706b6b52Smrg then 9372706b6b52Smrg func_relative_path "$install_libdir" "$bindir" 9373706b6b52Smrg tdlname=$func_relative_path_result$dlname 9374706b6b52Smrg else 9375706b6b52Smrg # Otherwise fall back on heuristic. 9376706b6b52Smrg tdlname=../bin/$dlname 9377706b6b52Smrg fi 9378706b6b52Smrg ;; 93798c4a8e55Smrg esac 93808c4a8e55Smrg $ECHO > $output "\ 93818c4a8e55Smrg# $outputname - a libtool library file 93828c4a8e55Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 93838c4a8e55Smrg# 93848c4a8e55Smrg# Please DO NOT delete this file! 93858c4a8e55Smrg# It is necessary for linking the library. 9386b042e37fSmrg 93878c4a8e55Smrg# The name that we can dlopen(3). 93888c4a8e55Smrgdlname='$tdlname' 9389b042e37fSmrg 93908c4a8e55Smrg# Names of this library. 93918c4a8e55Smrglibrary_names='$library_names' 9392b042e37fSmrg 93938c4a8e55Smrg# The name of the static archive. 93948c4a8e55Smrgold_library='$old_library' 9395b042e37fSmrg 93968c4a8e55Smrg# Linker flags that can not go in dependency_libs. 93978c4a8e55Smrginherited_linker_flags='$new_inherited_linker_flags' 9398b042e37fSmrg 93998c4a8e55Smrg# Libraries that this one depends upon. 94008c4a8e55Smrgdependency_libs='$dependency_libs' 9401b042e37fSmrg 94028c4a8e55Smrg# Names of additional weak libraries provided by this library 94038c4a8e55Smrgweak_library_names='$weak_libs' 9404b042e37fSmrg 94058c4a8e55Smrg# Version information for $libname. 94068c4a8e55Smrgcurrent=$current 94078c4a8e55Smrgage=$age 94088c4a8e55Smrgrevision=$revision 9409b042e37fSmrg 94108c4a8e55Smrg# Is this an already installed library? 94118c4a8e55Smrginstalled=$installed 9412b042e37fSmrg 94138c4a8e55Smrg# Should we warn about portability when linking against -modules? 94148c4a8e55Smrgshouldnotlink=$module 9415b042e37fSmrg 94168c4a8e55Smrg# Files to dlopen/dlpreopen 94178c4a8e55Smrgdlopen='$dlfiles' 94188c4a8e55Smrgdlpreopen='$dlprefiles' 9419b042e37fSmrg 94208c4a8e55Smrg# Directory that this library needs to be installed in: 94218c4a8e55Smrglibdir='$install_libdir'" 94228c4a8e55Smrg if test "$installed" = no && test "$need_relink" = yes; then 94238c4a8e55Smrg $ECHO >> $output "\ 94248c4a8e55Smrgrelink_command=\"$relink_command\"" 94258c4a8e55Smrg fi 94268c4a8e55Smrg done 94278c4a8e55Smrg } 9428b042e37fSmrg 94298c4a8e55Smrg # Do a symbolic link so that the libtool archive can be found in 94308c4a8e55Smrg # LD_LIBRARY_PATH before the program is installed. 94318c4a8e55Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 94328c4a8e55Smrg ;; 94338c4a8e55Smrg esac 94348c4a8e55Smrg exit $EXIT_SUCCESS 94358c4a8e55Smrg} 9436b042e37fSmrg 9437bd23fbfaSmrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 94388c4a8e55Smrg func_mode_link ${1+"$@"} 9439b042e37fSmrg 9440b042e37fSmrg 94418c4a8e55Smrg# func_mode_uninstall arg... 94428c4a8e55Smrgfunc_mode_uninstall () 94438c4a8e55Smrg{ 94448c4a8e55Smrg $opt_debug 94458c4a8e55Smrg RM="$nonopt" 9446b042e37fSmrg files= 9447b042e37fSmrg rmforce= 9448b042e37fSmrg exit_status=0 9449b042e37fSmrg 9450b042e37fSmrg # This variable tells wrapper scripts just to set variables rather 9451b042e37fSmrg # than running their programs. 9452b042e37fSmrg libtool_install_magic="$magic" 9453b042e37fSmrg 9454b042e37fSmrg for arg 9455b042e37fSmrg do 9456b042e37fSmrg case $arg in 9457bd23fbfaSmrg -f) func_append RM " $arg"; rmforce=yes ;; 9458bd23fbfaSmrg -*) func_append RM " $arg" ;; 9459bd23fbfaSmrg *) func_append files " $arg" ;; 9460b042e37fSmrg esac 9461b042e37fSmrg done 9462b042e37fSmrg 94638c4a8e55Smrg test -z "$RM" && \ 94648c4a8e55Smrg func_fatal_help "you must specify an RM program" 9465b042e37fSmrg 9466b042e37fSmrg rmdirs= 9467b042e37fSmrg 9468b042e37fSmrg for file in $files; do 94698c4a8e55Smrg func_dirname "$file" "" "." 94708c4a8e55Smrg dir="$func_dirname_result" 94718c4a8e55Smrg if test "X$dir" = X.; then 9472bd23fbfaSmrg odir="$objdir" 9473b042e37fSmrg else 9474bd23fbfaSmrg odir="$dir/$objdir" 9475b042e37fSmrg fi 94768c4a8e55Smrg func_basename "$file" 94778c4a8e55Smrg name="$func_basename_result" 9478bd23fbfaSmrg test "$opt_mode" = uninstall && odir="$dir" 9479b042e37fSmrg 9480bd23fbfaSmrg # Remember odir for removal later, being careful to avoid duplicates 9481bd23fbfaSmrg if test "$opt_mode" = clean; then 9482b042e37fSmrg case " $rmdirs " in 9483bd23fbfaSmrg *" $odir "*) ;; 9484bd23fbfaSmrg *) func_append rmdirs " $odir" ;; 9485b042e37fSmrg esac 9486b042e37fSmrg fi 9487b042e37fSmrg 9488b042e37fSmrg # Don't error if the file doesn't exist and rm -f was used. 94898c4a8e55Smrg if { test -L "$file"; } >/dev/null 2>&1 || 94908c4a8e55Smrg { test -h "$file"; } >/dev/null 2>&1 || 94918c4a8e55Smrg test -f "$file"; then 9492b042e37fSmrg : 9493b042e37fSmrg elif test -d "$file"; then 9494b042e37fSmrg exit_status=1 9495b042e37fSmrg continue 9496b042e37fSmrg elif test "$rmforce" = yes; then 9497b042e37fSmrg continue 9498b042e37fSmrg fi 9499b042e37fSmrg 9500b042e37fSmrg rmfiles="$file" 9501b042e37fSmrg 9502b042e37fSmrg case $name in 9503b042e37fSmrg *.la) 9504b042e37fSmrg # Possibly a libtool archive, so verify it. 95058c4a8e55Smrg if func_lalib_p "$file"; then 95068c4a8e55Smrg func_source $dir/$name 9507b042e37fSmrg 9508b042e37fSmrg # Delete the libtool libraries and symlinks. 9509b042e37fSmrg for n in $library_names; do 9510bd23fbfaSmrg func_append rmfiles " $odir/$n" 9511b042e37fSmrg done 9512bd23fbfaSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 9513b042e37fSmrg 9514bd23fbfaSmrg case "$opt_mode" in 9515b042e37fSmrg clean) 9516bd23fbfaSmrg case " $library_names " in 9517b042e37fSmrg *" $dlname "*) ;; 9518bd23fbfaSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 9519b042e37fSmrg esac 9520bd23fbfaSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 9521b042e37fSmrg ;; 9522b042e37fSmrg uninstall) 9523b042e37fSmrg if test -n "$library_names"; then 9524b042e37fSmrg # Do each command in the postuninstall commands. 95258c4a8e55Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9526b042e37fSmrg fi 9527b042e37fSmrg 9528b042e37fSmrg if test -n "$old_library"; then 9529b042e37fSmrg # Do each command in the old_postuninstall commands. 95308c4a8e55Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9531b042e37fSmrg fi 9532b042e37fSmrg # FIXME: should reinstall the best remaining shared library. 9533b042e37fSmrg ;; 9534b042e37fSmrg esac 9535b042e37fSmrg fi 9536b042e37fSmrg ;; 9537b042e37fSmrg 9538b042e37fSmrg *.lo) 9539b042e37fSmrg # Possibly a libtool object, so verify it. 95408c4a8e55Smrg if func_lalib_p "$file"; then 9541b042e37fSmrg 9542b042e37fSmrg # Read the .lo file 95438c4a8e55Smrg func_source $dir/$name 9544b042e37fSmrg 9545b042e37fSmrg # Add PIC object to the list of files to remove. 95468c4a8e55Smrg if test -n "$pic_object" && 95478c4a8e55Smrg test "$pic_object" != none; then 9548bd23fbfaSmrg func_append rmfiles " $dir/$pic_object" 9549b042e37fSmrg fi 9550b042e37fSmrg 9551b042e37fSmrg # Add non-PIC object to the list of files to remove. 95528c4a8e55Smrg if test -n "$non_pic_object" && 95538c4a8e55Smrg test "$non_pic_object" != none; then 9554bd23fbfaSmrg func_append rmfiles " $dir/$non_pic_object" 9555b042e37fSmrg fi 9556b042e37fSmrg fi 9557b042e37fSmrg ;; 9558b042e37fSmrg 9559b042e37fSmrg *) 9560bd23fbfaSmrg if test "$opt_mode" = clean ; then 9561b042e37fSmrg noexename=$name 9562b042e37fSmrg case $file in 9563b042e37fSmrg *.exe) 95648c4a8e55Smrg func_stripname '' '.exe' "$file" 95658c4a8e55Smrg file=$func_stripname_result 95668c4a8e55Smrg func_stripname '' '.exe' "$name" 95678c4a8e55Smrg noexename=$func_stripname_result 9568b042e37fSmrg # $file with .exe has already been added to rmfiles, 9569b042e37fSmrg # add $file without .exe 9570bd23fbfaSmrg func_append rmfiles " $file" 9571b042e37fSmrg ;; 9572b042e37fSmrg esac 9573b042e37fSmrg # Do a test to see if this is a libtool program. 95748c4a8e55Smrg if func_ltwrapper_p "$file"; then 95758c4a8e55Smrg if func_ltwrapper_executable_p "$file"; then 95768c4a8e55Smrg func_ltwrapper_scriptname "$file" 95778c4a8e55Smrg relink_command= 95788c4a8e55Smrg func_source $func_ltwrapper_scriptname_result 9579bd23fbfaSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 95808c4a8e55Smrg else 95818c4a8e55Smrg relink_command= 95828c4a8e55Smrg func_source $dir/$noexename 95838c4a8e55Smrg fi 9584b042e37fSmrg 9585b042e37fSmrg # note $name still contains .exe if it was in $file originally 9586b042e37fSmrg # as does the version of $file that was added into $rmfiles 9587bd23fbfaSmrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9588b042e37fSmrg if test "$fast_install" = yes && test -n "$relink_command"; then 9589bd23fbfaSmrg func_append rmfiles " $odir/lt-$name" 9590b042e37fSmrg fi 9591b042e37fSmrg if test "X$noexename" != "X$name" ; then 9592bd23fbfaSmrg func_append rmfiles " $odir/lt-${noexename}.c" 9593b042e37fSmrg fi 9594b042e37fSmrg fi 9595b042e37fSmrg fi 9596b042e37fSmrg ;; 9597b042e37fSmrg esac 95988c4a8e55Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 9599b042e37fSmrg done 9600b042e37fSmrg 9601b042e37fSmrg # Try to remove the ${objdir}s in the directories where we deleted files 9602b042e37fSmrg for dir in $rmdirs; do 9603b042e37fSmrg if test -d "$dir"; then 96048c4a8e55Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 9605b042e37fSmrg fi 9606b042e37fSmrg done 9607b042e37fSmrg 9608b042e37fSmrg exit $exit_status 96098c4a8e55Smrg} 9610b042e37fSmrg 9611bd23fbfaSmrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 96128c4a8e55Smrg func_mode_uninstall ${1+"$@"} 9613b042e37fSmrg 9614bd23fbfaSmrgtest -z "$opt_mode" && { 96158c4a8e55Smrg help="$generic_help" 96168c4a8e55Smrg func_fatal_help "you must specify a MODE" 96178c4a8e55Smrg} 96188c4a8e55Smrg 96198c4a8e55Smrgtest -z "$exec_cmd" && \ 9620bd23fbfaSmrg func_fatal_help "invalid operation mode \`$opt_mode'" 9621b042e37fSmrg 9622b042e37fSmrgif test -n "$exec_cmd"; then 96238c4a8e55Smrg eval exec "$exec_cmd" 9624b042e37fSmrg exit $EXIT_FAILURE 9625b042e37fSmrgfi 9626b042e37fSmrg 96278c4a8e55Smrgexit $exit_status 9628b042e37fSmrg 9629b042e37fSmrg 9630b042e37fSmrg# The TAGs below are defined such that we never get into a situation 9631b042e37fSmrg# in which we disable both kinds of libraries. Given conflicting 9632b042e37fSmrg# choices, we go for a static library, that is the most portable, 9633b042e37fSmrg# since we can't tell whether shared libraries were disabled because 9634b042e37fSmrg# the user asked for that or because the platform doesn't support 9635b042e37fSmrg# them. This is particularly important on AIX, because we don't 9636b042e37fSmrg# support having both static and shared libraries enabled at the same 9637b042e37fSmrg# time on that platform, so we default to a shared-only configuration. 9638b042e37fSmrg# If a disable-shared tag is given, we'll fallback to a static-only 9639b042e37fSmrg# configuration. But we'll never go from static-only to shared-only. 9640b042e37fSmrg 9641b042e37fSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 96428c4a8e55Smrgbuild_libtool_libs=no 96438c4a8e55Smrgbuild_old_libs=yes 9644b042e37fSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 9645b042e37fSmrg 9646b042e37fSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 96478c4a8e55Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 9648b042e37fSmrg# ### END LIBTOOL TAG CONFIG: disable-static 9649b042e37fSmrg 9650b042e37fSmrg# Local Variables: 9651b042e37fSmrg# mode:shell-script 9652b042e37fSmrg# sh-indentation:2 9653b042e37fSmrg# End: 96548c4a8e55Smrg# vi:sw=2 96558c4a8e55Smrg 9656