ltmain.sh revision 3e6c936a
1521070a0Smrg 23e6c936aSmrg# libtool (GNU libtool) 2.4.2 3521070a0Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 4521070a0Smrg 5ff63a143Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 63e6c936aSmrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 7521070a0Smrg# This is free software; see the source for copying conditions. There is NO 8521070a0Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9521070a0Smrg 10521070a0Smrg# GNU Libtool is free software; you can redistribute it and/or modify 114456fccdSmrg# it under the terms of the GNU General Public License as published by 124456fccdSmrg# the Free Software Foundation; either version 2 of the License, or 134456fccdSmrg# (at your option) any later version. 144456fccdSmrg# 15521070a0Smrg# As a special exception to the GNU General Public License, 16521070a0Smrg# if you distribute this file as part of a program or library that 17521070a0Smrg# is built using GNU Libtool, you may include this file under the 18521070a0Smrg# same distribution terms that you use for the rest of that program. 19521070a0Smrg# 20521070a0Smrg# GNU Libtool is distributed in the hope that it will be useful, but 214456fccdSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 224456fccdSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 234456fccdSmrg# General Public License for more details. 244456fccdSmrg# 254456fccdSmrg# You should have received a copy of the GNU General Public License 26521070a0Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 27521070a0Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 28521070a0Smrg# or obtained by writing to the Free Software Foundation, Inc., 29521070a0Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 304456fccdSmrg 31521070a0Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 32521070a0Smrg# 33521070a0Smrg# Provide generalized library-building support services. 34521070a0Smrg# 35ff63a143Smrg# --config show all configuration variables 36ff63a143Smrg# --debug enable verbose shell tracing 37ff63a143Smrg# -n, --dry-run display commands without modifying any files 38ff63a143Smrg# --features display basic configuration information and exit 39ff63a143Smrg# --mode=MODE use operation mode MODE 40ff63a143Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 41ff63a143Smrg# --quiet, --silent don't print informational messages 42ff63a143Smrg# --no-quiet, --no-silent 43ff63a143Smrg# print informational messages (default) 443e6c936aSmrg# --no-warn don't display warning messages 45ff63a143Smrg# --tag=TAG use configuration variables from tag TAG 46ff63a143Smrg# -v, --verbose print more informational messages than default 47ff63a143Smrg# --no-verbose don't print the extra informational messages 48ff63a143Smrg# --version print version information 49ff63a143Smrg# -h, --help, --help-all print short, long, or detailed help message 50521070a0Smrg# 51521070a0Smrg# MODE must be one of the following: 52521070a0Smrg# 53ff63a143Smrg# clean remove files from the build directory 54ff63a143Smrg# compile compile a source file into a libtool object 55ff63a143Smrg# execute automatically set library path, then run a program 56ff63a143Smrg# finish complete the installation of libtool libraries 57ff63a143Smrg# install install libraries or executables 58ff63a143Smrg# link create a library or an executable 59ff63a143Smrg# uninstall remove libraries from an installed directory 60521070a0Smrg# 61ff63a143Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 62ff63a143Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 63521070a0Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 64521070a0Smrg# 65521070a0Smrg# When reporting a bug, please describe a test case to reproduce it and 66521070a0Smrg# include the following information: 67521070a0Smrg# 68ff63a143Smrg# host-triplet: $host 69ff63a143Smrg# shell: $SHELL 70ff63a143Smrg# compiler: $LTCC 71ff63a143Smrg# compiler flags: $LTCFLAGS 72ff63a143Smrg# linker: $LD (gnu? $with_gnu_ld) 733e6c936aSmrg# $progname: (GNU libtool) 2.4.2 74ff63a143Smrg# automake: $automake_version 75ff63a143Smrg# autoconf: $autoconf_version 76521070a0Smrg# 77521070a0Smrg# Report bugs to <bug-libtool@gnu.org>. 783e6c936aSmrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 793e6c936aSmrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 804456fccdSmrg 81ff63a143SmrgPROGRAM=libtool 824456fccdSmrgPACKAGE=libtool 833e6c936aSmrgVERSION=2.4.2 84521070a0SmrgTIMESTAMP="" 853e6c936aSmrgpackage_revision=1.3337 8642d69509Smrg 87521070a0Smrg# Be Bourne compatible 8842d69509Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 8942d69509Smrg emulate sh 9042d69509Smrg NULLCMD=: 9142d69509Smrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 9242d69509Smrg # is contrary to our usage. Disable this feature. 9342d69509Smrg alias -g '${1+"$@"}'='"$@"' 944456fccdSmrg setopt NO_GLOB_SUBST 9542d69509Smrgelse 9642d69509Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 974456fccdSmrgfi 9842d69509SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 9942d69509SmrgDUALCASE=1; export DUALCASE # for MKS sh 1004456fccdSmrg 101ff63a143Smrg# A function that is used when there is no print builtin or printf. 102ff63a143Smrgfunc_fallback_echo () 103ff63a143Smrg{ 104ff63a143Smrg eval 'cat <<_LTECHO_EOF 105ff63a143Smrg$1 106ff63a143Smrg_LTECHO_EOF' 107ff63a143Smrg} 108ff63a143Smrg 109521070a0Smrg# NLS nuisances: We save the old values to restore during execute mode. 110521070a0Smrglt_user_locale= 111521070a0Smrglt_safe_locale= 11242d69509Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 11342d69509Smrgdo 11442d69509Smrg eval "if test \"\${$lt_var+set}\" = set; then 115521070a0Smrg save_$lt_var=\$$lt_var 116521070a0Smrg $lt_var=C 11742d69509Smrg export $lt_var 118521070a0Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 119521070a0Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 12042d69509Smrg fi" 12142d69509Smrgdone 122ff63a143SmrgLC_ALL=C 123ff63a143SmrgLANGUAGE=C 124ff63a143Smrgexport LANGUAGE LC_ALL 12542d69509Smrg 126521070a0Smrg$lt_unset CDPATH 127521070a0Smrg 128521070a0Smrg 129ff63a143Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 130ff63a143Smrg# is ksh but when the shell is invoked as "sh" and the current value of 131ff63a143Smrg# the _XPG environment variable is not equal to 1 (one), the special 132ff63a143Smrg# positional parameter $0, within a function call, is the name of the 133ff63a143Smrg# function. 134ff63a143Smrgprogpath="$0" 135521070a0Smrg 136521070a0Smrg 137521070a0Smrg 138521070a0Smrg: ${CP="cp -f"} 139ff63a143Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 140521070a0Smrg: ${MAKE="make"} 141521070a0Smrg: ${MKDIR="mkdir"} 142521070a0Smrg: ${MV="mv -f"} 143521070a0Smrg: ${RM="rm -f"} 144521070a0Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 145521070a0Smrg: ${Xsed="$SED -e 1s/^X//"} 146521070a0Smrg 147521070a0Smrg# Global variables: 148521070a0SmrgEXIT_SUCCESS=0 149521070a0SmrgEXIT_FAILURE=1 150521070a0SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 151521070a0SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 152521070a0Smrg 153521070a0Smrgexit_status=$EXIT_SUCCESS 1544456fccdSmrg 1554456fccdSmrg# Make sure IFS has a sensible default 1564456fccdSmrglt_nl=' 1574456fccdSmrg' 1584456fccdSmrgIFS=" $lt_nl" 1594456fccdSmrg 160521070a0Smrgdirname="s,/[^/]*$,," 161521070a0Smrgbasename="s,^.*/,," 162521070a0Smrg 1633e6c936aSmrg# func_dirname file append nondir_replacement 1643e6c936aSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 1653e6c936aSmrg# otherwise set result to NONDIR_REPLACEMENT. 1663e6c936aSmrgfunc_dirname () 1673e6c936aSmrg{ 1683e6c936aSmrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 1693e6c936aSmrg if test "X$func_dirname_result" = "X${1}"; then 1703e6c936aSmrg func_dirname_result="${3}" 1713e6c936aSmrg else 1723e6c936aSmrg func_dirname_result="$func_dirname_result${2}" 1733e6c936aSmrg fi 1743e6c936aSmrg} # func_dirname may be replaced by extended shell implementation 1753e6c936aSmrg 1763e6c936aSmrg 1773e6c936aSmrg# func_basename file 1783e6c936aSmrgfunc_basename () 1793e6c936aSmrg{ 1803e6c936aSmrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 1813e6c936aSmrg} # func_basename may be replaced by extended shell implementation 1823e6c936aSmrg 1833e6c936aSmrg 184521070a0Smrg# func_dirname_and_basename file append nondir_replacement 185521070a0Smrg# perform func_basename and func_dirname in a single function 186521070a0Smrg# call: 187521070a0Smrg# dirname: Compute the dirname of FILE. If nonempty, 188521070a0Smrg# add APPEND to the result, otherwise set result 189521070a0Smrg# to NONDIR_REPLACEMENT. 190521070a0Smrg# value returned in "$func_dirname_result" 191521070a0Smrg# basename: Compute filename of FILE. 192521070a0Smrg# value retuned in "$func_basename_result" 193521070a0Smrg# Implementation must be kept synchronized with func_dirname 194521070a0Smrg# and func_basename. For efficiency, we do not delegate to 195521070a0Smrg# those functions but instead duplicate the functionality here. 196521070a0Smrgfunc_dirname_and_basename () 197521070a0Smrg{ 1983e6c936aSmrg # Extract subdirectory from the argument. 1993e6c936aSmrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 2003e6c936aSmrg if test "X$func_dirname_result" = "X${1}"; then 2013e6c936aSmrg func_dirname_result="${3}" 2023e6c936aSmrg else 2033e6c936aSmrg func_dirname_result="$func_dirname_result${2}" 2043e6c936aSmrg fi 2053e6c936aSmrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 2063e6c936aSmrg} # func_dirname_and_basename may be replaced by extended shell implementation 2073e6c936aSmrg 2083e6c936aSmrg 2093e6c936aSmrg# func_stripname prefix suffix name 2103e6c936aSmrg# strip PREFIX and SUFFIX off of NAME. 2113e6c936aSmrg# PREFIX and SUFFIX must not contain globbing or regex special 2123e6c936aSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 2133e6c936aSmrg# dot (in which case that matches only a dot). 2143e6c936aSmrg# func_strip_suffix prefix name 2153e6c936aSmrgfunc_stripname () 2163e6c936aSmrg{ 2173e6c936aSmrg case ${2} in 2183e6c936aSmrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 2193e6c936aSmrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 2203e6c936aSmrg esac 2213e6c936aSmrg} # func_stripname may be replaced by extended shell implementation 2224456fccdSmrg 223521070a0Smrg 224ff63a143Smrg# These SED scripts presuppose an absolute path with a trailing slash. 225ff63a143Smrgpathcar='s,^/\([^/]*\).*$,\1,' 226ff63a143Smrgpathcdr='s,^/[^/]*,,' 227ff63a143Smrgremovedotparts=':dotsl 228ff63a143Smrg s@/\./@/@g 229ff63a143Smrg t dotsl 230ff63a143Smrg s,/\.$,/,' 231ff63a143Smrgcollapseslashes='s@/\{1,\}@/@g' 232ff63a143Smrgfinalslash='s,/*$,/,' 233ff63a143Smrg 234ff63a143Smrg# func_normal_abspath PATH 235ff63a143Smrg# Remove doubled-up and trailing slashes, "." path components, 236ff63a143Smrg# and cancel out any ".." path components in PATH after making 237ff63a143Smrg# it an absolute path. 238ff63a143Smrg# value returned in "$func_normal_abspath_result" 239ff63a143Smrgfunc_normal_abspath () 240ff63a143Smrg{ 241ff63a143Smrg # Start from root dir and reassemble the path. 242ff63a143Smrg func_normal_abspath_result= 243ff63a143Smrg func_normal_abspath_tpath=$1 244ff63a143Smrg func_normal_abspath_altnamespace= 245ff63a143Smrg case $func_normal_abspath_tpath in 246ff63a143Smrg "") 247ff63a143Smrg # Empty path, that just means $cwd. 248ff63a143Smrg func_stripname '' '/' "`pwd`" 249ff63a143Smrg func_normal_abspath_result=$func_stripname_result 250ff63a143Smrg return 251ff63a143Smrg ;; 252ff63a143Smrg # The next three entries are used to spot a run of precisely 253ff63a143Smrg # two leading slashes without using negated character classes; 254ff63a143Smrg # we take advantage of case's first-match behaviour. 255ff63a143Smrg ///*) 256ff63a143Smrg # Unusual form of absolute path, do nothing. 257ff63a143Smrg ;; 258ff63a143Smrg //*) 259ff63a143Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 260ff63a143Smrg # and for example Cygwin uses it to access remote file shares 261ff63a143Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 262ff63a143Smrg func_normal_abspath_altnamespace=/ 263ff63a143Smrg ;; 264ff63a143Smrg /*) 265ff63a143Smrg # Absolute path, do nothing. 266ff63a143Smrg ;; 267ff63a143Smrg *) 268ff63a143Smrg # Relative path, prepend $cwd. 269ff63a143Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 270ff63a143Smrg ;; 271ff63a143Smrg esac 272ff63a143Smrg # Cancel out all the simple stuff to save iterations. We also want 273ff63a143Smrg # the path to end with a slash for ease of parsing, so make sure 274ff63a143Smrg # there is one (and only one) here. 275ff63a143Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 276ff63a143Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 277ff63a143Smrg while :; do 278ff63a143Smrg # Processed it all yet? 279ff63a143Smrg if test "$func_normal_abspath_tpath" = / ; then 280ff63a143Smrg # If we ascended to the root using ".." the result may be empty now. 281ff63a143Smrg if test -z "$func_normal_abspath_result" ; then 282ff63a143Smrg func_normal_abspath_result=/ 283ff63a143Smrg fi 284ff63a143Smrg break 285ff63a143Smrg fi 286ff63a143Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 287ff63a143Smrg -e "$pathcar"` 288ff63a143Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 289ff63a143Smrg -e "$pathcdr"` 290ff63a143Smrg # Figure out what to do with it 291ff63a143Smrg case $func_normal_abspath_tcomponent in 292ff63a143Smrg "") 293ff63a143Smrg # Trailing empty path component, ignore it. 294ff63a143Smrg ;; 295ff63a143Smrg ..) 296ff63a143Smrg # Parent dir; strip last assembled component from result. 297ff63a143Smrg func_dirname "$func_normal_abspath_result" 298ff63a143Smrg func_normal_abspath_result=$func_dirname_result 299ff63a143Smrg ;; 300ff63a143Smrg *) 301ff63a143Smrg # Actual path component, append it. 302ff63a143Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 303ff63a143Smrg ;; 304ff63a143Smrg esac 305ff63a143Smrg done 306ff63a143Smrg # Restore leading double-slash if one was found on entry. 307ff63a143Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 308ff63a143Smrg} 309ff63a143Smrg 310ff63a143Smrg# func_relative_path SRCDIR DSTDIR 311ff63a143Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 312ff63a143Smrg# slash if non-empty, suitable for immediately appending a filename 313ff63a143Smrg# without needing to append a separator. 314ff63a143Smrg# value returned in "$func_relative_path_result" 315ff63a143Smrgfunc_relative_path () 316ff63a143Smrg{ 317ff63a143Smrg func_relative_path_result= 318ff63a143Smrg func_normal_abspath "$1" 319ff63a143Smrg func_relative_path_tlibdir=$func_normal_abspath_result 320ff63a143Smrg func_normal_abspath "$2" 321ff63a143Smrg func_relative_path_tbindir=$func_normal_abspath_result 322ff63a143Smrg 323ff63a143Smrg # Ascend the tree starting from libdir 324ff63a143Smrg while :; do 325ff63a143Smrg # check if we have found a prefix of bindir 326ff63a143Smrg case $func_relative_path_tbindir in 327ff63a143Smrg $func_relative_path_tlibdir) 328ff63a143Smrg # found an exact match 329ff63a143Smrg func_relative_path_tcancelled= 330ff63a143Smrg break 331ff63a143Smrg ;; 332ff63a143Smrg $func_relative_path_tlibdir*) 333ff63a143Smrg # found a matching prefix 334ff63a143Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 335ff63a143Smrg func_relative_path_tcancelled=$func_stripname_result 336ff63a143Smrg if test -z "$func_relative_path_result"; then 337ff63a143Smrg func_relative_path_result=. 338ff63a143Smrg fi 339ff63a143Smrg break 340ff63a143Smrg ;; 341ff63a143Smrg *) 342ff63a143Smrg func_dirname $func_relative_path_tlibdir 343ff63a143Smrg func_relative_path_tlibdir=${func_dirname_result} 344ff63a143Smrg if test "x$func_relative_path_tlibdir" = x ; then 345ff63a143Smrg # Have to descend all the way to the root! 346ff63a143Smrg func_relative_path_result=../$func_relative_path_result 347ff63a143Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 348ff63a143Smrg break 349ff63a143Smrg fi 350ff63a143Smrg func_relative_path_result=../$func_relative_path_result 351ff63a143Smrg ;; 352ff63a143Smrg esac 353ff63a143Smrg done 354ff63a143Smrg 355ff63a143Smrg # Now calculate path; take care to avoid doubling-up slashes. 356ff63a143Smrg func_stripname '' '/' "$func_relative_path_result" 357ff63a143Smrg func_relative_path_result=$func_stripname_result 358ff63a143Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 359ff63a143Smrg if test "x$func_stripname_result" != x ; then 360ff63a143Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 361ff63a143Smrg fi 362ff63a143Smrg 363ff63a143Smrg # Normalisation. If bindir is libdir, return empty string, 364ff63a143Smrg # else relative path ending with a slash; either way, target 365ff63a143Smrg # file name can be directly appended. 366ff63a143Smrg if test ! -z "$func_relative_path_result"; then 367ff63a143Smrg func_stripname './' '' "$func_relative_path_result/" 368ff63a143Smrg func_relative_path_result=$func_stripname_result 369ff63a143Smrg fi 370ff63a143Smrg} 371521070a0Smrg 372521070a0Smrg# The name of this program: 373521070a0Smrgfunc_dirname_and_basename "$progpath" 374521070a0Smrgprogname=$func_basename_result 375521070a0Smrg 376521070a0Smrg# Make sure we have an absolute path for reexecution: 377521070a0Smrgcase $progpath in 378521070a0Smrg [\\/]*|[A-Za-z]:\\*) ;; 379521070a0Smrg *[\\/]*) 380521070a0Smrg progdir=$func_dirname_result 381521070a0Smrg progdir=`cd "$progdir" && pwd` 382521070a0Smrg progpath="$progdir/$progname" 383521070a0Smrg ;; 384521070a0Smrg *) 385521070a0Smrg save_IFS="$IFS" 3863e6c936aSmrg IFS=${PATH_SEPARATOR-:} 387521070a0Smrg for progdir in $PATH; do 388521070a0Smrg IFS="$save_IFS" 389521070a0Smrg test -x "$progdir/$progname" && break 390521070a0Smrg done 391521070a0Smrg IFS="$save_IFS" 392521070a0Smrg test -n "$progdir" || progdir=`pwd` 393521070a0Smrg progpath="$progdir/$progname" 394521070a0Smrg ;; 395521070a0Smrgesac 396521070a0Smrg 397521070a0Smrg# Sed substitution that helps us do robust quoting. It backslashifies 398521070a0Smrg# metacharacters that are still active within double-quoted strings. 399521070a0SmrgXsed="${SED}"' -e 1s/^X//' 400521070a0Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 401521070a0Smrg 402521070a0Smrg# Same as above, but do not quote variable references. 403521070a0Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 404521070a0Smrg 4053e6c936aSmrg# Sed substitution that turns a string into a regex matching for the 4063e6c936aSmrg# string literally. 4073e6c936aSmrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 4083e6c936aSmrg 4093e6c936aSmrg# Sed substitution that converts a w32 file name or path 4103e6c936aSmrg# which contains forward slashes, into one that contains 4113e6c936aSmrg# (escaped) backslashes. A very naive implementation. 4123e6c936aSmrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 4133e6c936aSmrg 414521070a0Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 415521070a0Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 416521070a0Smrg# in input to double_quote_subst, that '$' was protected from expansion. 417521070a0Smrg# Since each input `\' is now two `\'s, look for any number of runs of 418521070a0Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 419521070a0Smrgbs='\\' 420521070a0Smrgbs2='\\\\' 421521070a0Smrgbs4='\\\\\\\\' 422521070a0Smrgdollar='\$' 423521070a0Smrgsed_double_backslash="\ 424521070a0Smrg s/$bs4/&\\ 425521070a0Smrg/g 426521070a0Smrg s/^$bs2$dollar/$bs&/ 427521070a0Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 428521070a0Smrg s/\n//g" 429521070a0Smrg 430521070a0Smrg# Standard options: 431521070a0Smrgopt_dry_run=false 432521070a0Smrgopt_help=false 433521070a0Smrgopt_quiet=false 434521070a0Smrgopt_verbose=false 435521070a0Smrgopt_warning=: 436521070a0Smrg 437521070a0Smrg# func_echo arg... 438521070a0Smrg# Echo program name prefixed message, along with the current mode 439521070a0Smrg# name if it has been set yet. 440521070a0Smrgfunc_echo () 441521070a0Smrg{ 4423e6c936aSmrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 443521070a0Smrg} 444521070a0Smrg 445521070a0Smrg# func_verbose arg... 446521070a0Smrg# Echo program name prefixed message in verbose mode only. 447521070a0Smrgfunc_verbose () 448521070a0Smrg{ 449521070a0Smrg $opt_verbose && func_echo ${1+"$@"} 450521070a0Smrg 451521070a0Smrg # A bug in bash halts the script if the last line of a function 452521070a0Smrg # fails when set -e is in force, so we need another command to 453521070a0Smrg # work around that: 454521070a0Smrg : 455521070a0Smrg} 456521070a0Smrg 457ff63a143Smrg# func_echo_all arg... 458ff63a143Smrg# Invoke $ECHO with all args, space-separated. 459ff63a143Smrgfunc_echo_all () 460ff63a143Smrg{ 461ff63a143Smrg $ECHO "$*" 462ff63a143Smrg} 463ff63a143Smrg 464521070a0Smrg# func_error arg... 465521070a0Smrg# Echo program name prefixed message to standard error. 466521070a0Smrgfunc_error () 467521070a0Smrg{ 4683e6c936aSmrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 469521070a0Smrg} 470521070a0Smrg 471521070a0Smrg# func_warning arg... 472521070a0Smrg# Echo program name prefixed warning message to standard error. 473521070a0Smrgfunc_warning () 474521070a0Smrg{ 4753e6c936aSmrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 476521070a0Smrg 477521070a0Smrg # bash bug again: 478521070a0Smrg : 479521070a0Smrg} 480521070a0Smrg 481521070a0Smrg# func_fatal_error arg... 482521070a0Smrg# Echo program name prefixed message to standard error, and exit. 483521070a0Smrgfunc_fatal_error () 484521070a0Smrg{ 485521070a0Smrg func_error ${1+"$@"} 486521070a0Smrg exit $EXIT_FAILURE 487521070a0Smrg} 488521070a0Smrg 489521070a0Smrg# func_fatal_help arg... 490521070a0Smrg# Echo program name prefixed message to standard error, followed by 491521070a0Smrg# a help hint, and exit. 492521070a0Smrgfunc_fatal_help () 493521070a0Smrg{ 494521070a0Smrg func_error ${1+"$@"} 495521070a0Smrg func_fatal_error "$help" 496521070a0Smrg} 497521070a0Smrghelp="Try \`$progname --help' for more information." ## default 498521070a0Smrg 499521070a0Smrg 500521070a0Smrg# func_grep expression filename 501521070a0Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 502521070a0Smrgfunc_grep () 503521070a0Smrg{ 504521070a0Smrg $GREP "$1" "$2" >/dev/null 2>&1 505521070a0Smrg} 506521070a0Smrg 507521070a0Smrg 508521070a0Smrg# func_mkdir_p directory-path 509521070a0Smrg# Make sure the entire path to DIRECTORY-PATH is available. 510521070a0Smrgfunc_mkdir_p () 511521070a0Smrg{ 512521070a0Smrg my_directory_path="$1" 513521070a0Smrg my_dir_list= 514521070a0Smrg 515521070a0Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 516521070a0Smrg 517521070a0Smrg # Protect directory names starting with `-' 518521070a0Smrg case $my_directory_path in 519521070a0Smrg -*) my_directory_path="./$my_directory_path" ;; 520521070a0Smrg esac 521521070a0Smrg 522521070a0Smrg # While some portion of DIR does not yet exist... 523521070a0Smrg while test ! -d "$my_directory_path"; do 524521070a0Smrg # ...make a list in topmost first order. Use a colon delimited 525521070a0Smrg # list incase some portion of path contains whitespace. 526521070a0Smrg my_dir_list="$my_directory_path:$my_dir_list" 527521070a0Smrg 528521070a0Smrg # If the last portion added has no slash in it, the list is done 529521070a0Smrg case $my_directory_path in */*) ;; *) break ;; esac 530521070a0Smrg 531521070a0Smrg # ...otherwise throw away the child directory and loop 532ff63a143Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 533521070a0Smrg done 534ff63a143Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 535521070a0Smrg 536521070a0Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 537521070a0Smrg for my_dir in $my_dir_list; do 538521070a0Smrg IFS="$save_mkdir_p_IFS" 539521070a0Smrg # mkdir can fail with a `File exist' error if two processes 540521070a0Smrg # try to create one of the directories concurrently. Don't 541521070a0Smrg # stop in that case! 542521070a0Smrg $MKDIR "$my_dir" 2>/dev/null || : 543521070a0Smrg done 544521070a0Smrg IFS="$save_mkdir_p_IFS" 545521070a0Smrg 546521070a0Smrg # Bail out if we (or some other process) failed to create a directory. 547521070a0Smrg test -d "$my_directory_path" || \ 548521070a0Smrg func_fatal_error "Failed to create \`$1'" 549521070a0Smrg fi 550521070a0Smrg} 5514456fccdSmrg 5524456fccdSmrg 5534456fccdSmrg# func_mktempdir [string] 5544456fccdSmrg# Make a temporary directory that won't clash with other running 5554456fccdSmrg# libtool processes, and avoids race conditions if possible. If 5564456fccdSmrg# given, STRING is the basename for that directory. 5574456fccdSmrgfunc_mktempdir () 5584456fccdSmrg{ 5594456fccdSmrg my_template="${TMPDIR-/tmp}/${1-$progname}" 5604456fccdSmrg 561521070a0Smrg if test "$opt_dry_run" = ":"; then 5624456fccdSmrg # Return a directory name, but don't create it in dry-run mode 5634456fccdSmrg my_tmpdir="${my_template}-$$" 5644456fccdSmrg else 5654456fccdSmrg 5664456fccdSmrg # If mktemp works, use that first and foremost 5674456fccdSmrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 5684456fccdSmrg 5694456fccdSmrg if test ! -d "$my_tmpdir"; then 570521070a0Smrg # Failing that, at least try and use $RANDOM to avoid a race 571521070a0Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 5724456fccdSmrg 573521070a0Smrg save_mktempdir_umask=`umask` 574521070a0Smrg umask 0077 575521070a0Smrg $MKDIR "$my_tmpdir" 576521070a0Smrg umask $save_mktempdir_umask 5774456fccdSmrg fi 5784456fccdSmrg 5794456fccdSmrg # If we're not in dry-run mode, bomb out on failure 580521070a0Smrg test -d "$my_tmpdir" || \ 581521070a0Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 5824456fccdSmrg fi 5834456fccdSmrg 584ff63a143Smrg $ECHO "$my_tmpdir" 5854456fccdSmrg} 5864456fccdSmrg 5874456fccdSmrg 588521070a0Smrg# func_quote_for_eval arg 589521070a0Smrg# Aesthetically quote ARG to be evaled later. 590521070a0Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 591521070a0Smrg# is double-quoted, suitable for a subsequent eval, whereas 592521070a0Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 593521070a0Smrg# which are still active within double quotes backslashified. 594521070a0Smrgfunc_quote_for_eval () 5954456fccdSmrg{ 596521070a0Smrg case $1 in 597521070a0Smrg *[\\\`\"\$]*) 598ff63a143Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 599521070a0Smrg *) 600521070a0Smrg func_quote_for_eval_unquoted_result="$1" ;; 601521070a0Smrg esac 602521070a0Smrg 603521070a0Smrg case $func_quote_for_eval_unquoted_result in 604521070a0Smrg # Double-quote args containing shell metacharacters to delay 605521070a0Smrg # word splitting, command substitution and and variable 606521070a0Smrg # expansion for a subsequent eval. 607521070a0Smrg # Many Bourne shells cannot handle close brackets correctly 608521070a0Smrg # in scan sets, so we specify it separately. 609521070a0Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 610521070a0Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 611521070a0Smrg ;; 612521070a0Smrg *) 613521070a0Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 6144456fccdSmrg esac 6154456fccdSmrg} 6164456fccdSmrg 6174456fccdSmrg 618521070a0Smrg# func_quote_for_expand arg 619521070a0Smrg# Aesthetically quote ARG to be evaled later; same as above, 620521070a0Smrg# but do not quote variable references. 621521070a0Smrgfunc_quote_for_expand () 6224456fccdSmrg{ 623521070a0Smrg case $1 in 624521070a0Smrg *[\\\`\"]*) 625ff63a143Smrg my_arg=`$ECHO "$1" | $SED \ 626521070a0Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 6274456fccdSmrg *) 628521070a0Smrg my_arg="$1" ;; 629521070a0Smrg esac 630521070a0Smrg 631521070a0Smrg case $my_arg in 632521070a0Smrg # Double-quote args containing shell metacharacters to delay 633521070a0Smrg # word splitting and command substitution for a subsequent eval. 634521070a0Smrg # Many Bourne shells cannot handle close brackets correctly 635521070a0Smrg # in scan sets, so we specify it separately. 636521070a0Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 637521070a0Smrg my_arg="\"$my_arg\"" 638521070a0Smrg ;; 639521070a0Smrg esac 640521070a0Smrg 641521070a0Smrg func_quote_for_expand_result="$my_arg" 6424456fccdSmrg} 6434456fccdSmrg 6444456fccdSmrg 645521070a0Smrg# func_show_eval cmd [fail_exp] 646521070a0Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 647521070a0Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 648521070a0Smrg# is given, then evaluate it. 649521070a0Smrgfunc_show_eval () 6504456fccdSmrg{ 651521070a0Smrg my_cmd="$1" 652521070a0Smrg my_fail_exp="${2-:}" 6534456fccdSmrg 654521070a0Smrg ${opt_silent-false} || { 655521070a0Smrg func_quote_for_expand "$my_cmd" 656521070a0Smrg eval "func_echo $func_quote_for_expand_result" 657521070a0Smrg } 658521070a0Smrg 659521070a0Smrg if ${opt_dry_run-false}; then :; else 660521070a0Smrg eval "$my_cmd" 661521070a0Smrg my_status=$? 662521070a0Smrg if test "$my_status" -eq 0; then :; else 663521070a0Smrg eval "(exit $my_status); $my_fail_exp" 664521070a0Smrg fi 6654456fccdSmrg fi 6664456fccdSmrg} 6674456fccdSmrg 668521070a0Smrg 669521070a0Smrg# func_show_eval_locale cmd [fail_exp] 670521070a0Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 671521070a0Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 672521070a0Smrg# is given, then evaluate it. Use the saved locale for evaluation. 673521070a0Smrgfunc_show_eval_locale () 6744456fccdSmrg{ 675521070a0Smrg my_cmd="$1" 676521070a0Smrg my_fail_exp="${2-:}" 677521070a0Smrg 678521070a0Smrg ${opt_silent-false} || { 679521070a0Smrg func_quote_for_expand "$my_cmd" 680521070a0Smrg eval "func_echo $func_quote_for_expand_result" 681521070a0Smrg } 682521070a0Smrg 683521070a0Smrg if ${opt_dry_run-false}; then :; else 684521070a0Smrg eval "$lt_user_locale 685521070a0Smrg $my_cmd" 686521070a0Smrg my_status=$? 687521070a0Smrg eval "$lt_safe_locale" 688521070a0Smrg if test "$my_status" -eq 0; then :; else 689521070a0Smrg eval "(exit $my_status); $my_fail_exp" 690521070a0Smrg fi 6914456fccdSmrg fi 692521070a0Smrg} 6934456fccdSmrg 6943e6c936aSmrg# func_tr_sh 6953e6c936aSmrg# Turn $1 into a string suitable for a shell variable name. 6963e6c936aSmrg# Result is stored in $func_tr_sh_result. All characters 6973e6c936aSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 6983e6c936aSmrg# if $1 begins with a digit, a '_' is prepended as well. 6993e6c936aSmrgfunc_tr_sh () 7003e6c936aSmrg{ 7013e6c936aSmrg case $1 in 7023e6c936aSmrg [0-9]* | *[!a-zA-Z0-9_]*) 7033e6c936aSmrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 7043e6c936aSmrg ;; 7053e6c936aSmrg * ) 7063e6c936aSmrg func_tr_sh_result=$1 7073e6c936aSmrg ;; 7083e6c936aSmrg esac 7093e6c936aSmrg} 7103e6c936aSmrg 7114456fccdSmrg 712521070a0Smrg# func_version 713521070a0Smrg# Echo version message to standard output and exit. 714521070a0Smrgfunc_version () 715521070a0Smrg{ 7163e6c936aSmrg $opt_debug 7173e6c936aSmrg 718ff63a143Smrg $SED -n '/(C)/!b go 719ff63a143Smrg :more 720ff63a143Smrg /\./!{ 721ff63a143Smrg N 722ff63a143Smrg s/\n# / / 723ff63a143Smrg b more 724ff63a143Smrg } 725ff63a143Smrg :go 726ff63a143Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 727521070a0Smrg s/^# // 728521070a0Smrg s/^# *$// 729521070a0Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 730521070a0Smrg p 731521070a0Smrg }' < "$progpath" 732521070a0Smrg exit $? 733521070a0Smrg} 734521070a0Smrg 735521070a0Smrg# func_usage 736521070a0Smrg# Echo short help message to standard output and exit. 737521070a0Smrgfunc_usage () 738521070a0Smrg{ 7393e6c936aSmrg $opt_debug 7403e6c936aSmrg 741ff63a143Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 742521070a0Smrg s/^# // 743521070a0Smrg s/^# *$// 744521070a0Smrg s/\$progname/'$progname'/ 745521070a0Smrg p 746521070a0Smrg }' < "$progpath" 747ff63a143Smrg echo 748521070a0Smrg $ECHO "run \`$progname --help | more' for full usage" 749521070a0Smrg exit $? 750521070a0Smrg} 751521070a0Smrg 752ff63a143Smrg# func_help [NOEXIT] 753ff63a143Smrg# Echo long help message to standard output and exit, 754ff63a143Smrg# unless 'noexit' is passed as argument. 755521070a0Smrgfunc_help () 756521070a0Smrg{ 7573e6c936aSmrg $opt_debug 7583e6c936aSmrg 759521070a0Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 7603e6c936aSmrg :print 761521070a0Smrg s/^# // 762521070a0Smrg s/^# *$// 763521070a0Smrg s*\$progname*'$progname'* 764521070a0Smrg s*\$host*'"$host"'* 765521070a0Smrg s*\$SHELL*'"$SHELL"'* 766521070a0Smrg s*\$LTCC*'"$LTCC"'* 767521070a0Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 768521070a0Smrg s*\$LD*'"$LD"'* 769521070a0Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 7703e6c936aSmrg s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ 7713e6c936aSmrg s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ 772521070a0Smrg p 7733e6c936aSmrg d 7743e6c936aSmrg } 7753e6c936aSmrg /^# .* home page:/b print 7763e6c936aSmrg /^# General help using/b print 7773e6c936aSmrg ' < "$progpath" 778ff63a143Smrg ret=$? 779ff63a143Smrg if test -z "$1"; then 780ff63a143Smrg exit $ret 781ff63a143Smrg fi 782521070a0Smrg} 783521070a0Smrg 784521070a0Smrg# func_missing_arg argname 785521070a0Smrg# Echo program name prefixed message to standard error and set global 786521070a0Smrg# exit_cmd. 787521070a0Smrgfunc_missing_arg () 788521070a0Smrg{ 7893e6c936aSmrg $opt_debug 7903e6c936aSmrg 791ff63a143Smrg func_error "missing argument for $1." 792521070a0Smrg exit_cmd=exit 7934456fccdSmrg} 7944456fccdSmrg 7954456fccdSmrg 7963e6c936aSmrg# func_split_short_opt shortopt 7973e6c936aSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 7983e6c936aSmrg# variables after splitting SHORTOPT after the 2nd character. 7993e6c936aSmrgfunc_split_short_opt () 8003e6c936aSmrg{ 8013e6c936aSmrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 8023e6c936aSmrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 8033e6c936aSmrg 8043e6c936aSmrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 8053e6c936aSmrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 8063e6c936aSmrg} # func_split_short_opt may be replaced by extended shell implementation 8073e6c936aSmrg 8083e6c936aSmrg 8093e6c936aSmrg# func_split_long_opt longopt 8103e6c936aSmrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 8113e6c936aSmrg# variables after splitting LONGOPT at the `=' sign. 8123e6c936aSmrgfunc_split_long_opt () 8133e6c936aSmrg{ 8143e6c936aSmrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 8153e6c936aSmrg my_sed_long_arg='1s/^--[^=]*=//' 8163e6c936aSmrg 8173e6c936aSmrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 8183e6c936aSmrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 8193e6c936aSmrg} # func_split_long_opt may be replaced by extended shell implementation 8203e6c936aSmrg 8213e6c936aSmrgexit_cmd=: 8224456fccdSmrg 823521070a0Smrg 824521070a0Smrg 825521070a0Smrg 8264456fccdSmrg 827521070a0Smrgmagic="%%%MAGIC variable%%%" 828521070a0Smrgmagic_exe="%%%MAGIC EXE variable%%%" 8294456fccdSmrg 830521070a0Smrg# Global variables. 831521070a0Smrgnonopt= 832521070a0Smrgpreserve_args= 833521070a0Smrglo2o="s/\\.lo\$/.${objext}/" 834521070a0Smrgo2lo="s/\\.${objext}\$/.lo/" 835521070a0Smrgextracted_archives= 836521070a0Smrgextracted_serial=0 8374456fccdSmrg 838521070a0Smrg# If this variable is set in any of the actions, the command in it 839521070a0Smrg# will be execed at the end. This prevents here-documents from being 840521070a0Smrg# left over by shells. 841521070a0Smrgexec_cmd= 842521070a0Smrg 8433e6c936aSmrg# func_append var value 8443e6c936aSmrg# Append VALUE to the end of shell variable VAR. 8453e6c936aSmrgfunc_append () 8463e6c936aSmrg{ 8473e6c936aSmrg eval "${1}=\$${1}\${2}" 8483e6c936aSmrg} # func_append may be replaced by extended shell implementation 8493e6c936aSmrg 8503e6c936aSmrg# func_append_quoted var value 8513e6c936aSmrg# Quote VALUE and append to the end of shell variable VAR, separated 8523e6c936aSmrg# by a space. 8533e6c936aSmrgfunc_append_quoted () 8543e6c936aSmrg{ 8553e6c936aSmrg func_quote_for_eval "${2}" 8563e6c936aSmrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 8573e6c936aSmrg} # func_append_quoted may be replaced by extended shell implementation 8583e6c936aSmrg 8593e6c936aSmrg 8603e6c936aSmrg# func_arith arithmetic-term... 8613e6c936aSmrgfunc_arith () 8623e6c936aSmrg{ 8633e6c936aSmrg func_arith_result=`expr "${@}"` 8643e6c936aSmrg} # func_arith may be replaced by extended shell implementation 8653e6c936aSmrg 8663e6c936aSmrg 8673e6c936aSmrg# func_len string 8683e6c936aSmrg# STRING may not start with a hyphen. 8693e6c936aSmrgfunc_len () 8703e6c936aSmrg{ 8713e6c936aSmrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 8723e6c936aSmrg} # func_len may be replaced by extended shell implementation 8733e6c936aSmrg 8743e6c936aSmrg 8753e6c936aSmrg# func_lo2o object 8763e6c936aSmrgfunc_lo2o () 8773e6c936aSmrg{ 8783e6c936aSmrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 8793e6c936aSmrg} # func_lo2o may be replaced by extended shell implementation 8803e6c936aSmrg 8813e6c936aSmrg 8823e6c936aSmrg# func_xform libobj-or-source 8833e6c936aSmrgfunc_xform () 8843e6c936aSmrg{ 8853e6c936aSmrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 8863e6c936aSmrg} # func_xform may be replaced by extended shell implementation 8873e6c936aSmrg 8883e6c936aSmrg 889521070a0Smrg# func_fatal_configuration arg... 890521070a0Smrg# Echo program name prefixed message to standard error, followed by 891521070a0Smrg# a configuration failure hint, and exit. 892521070a0Smrgfunc_fatal_configuration () 893521070a0Smrg{ 894521070a0Smrg func_error ${1+"$@"} 895521070a0Smrg func_error "See the $PACKAGE documentation for more information." 896521070a0Smrg func_fatal_error "Fatal configuration error." 897521070a0Smrg} 8984456fccdSmrg 89942d69509Smrg 900521070a0Smrg# func_config 901521070a0Smrg# Display the configuration for all the tags in this script. 902521070a0Smrgfunc_config () 903521070a0Smrg{ 904521070a0Smrg re_begincf='^# ### BEGIN LIBTOOL' 905521070a0Smrg re_endcf='^# ### END LIBTOOL' 906521070a0Smrg 907521070a0Smrg # Default configuration. 908521070a0Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 9094456fccdSmrg 9104456fccdSmrg # Now print the configurations for the tags. 9114456fccdSmrg for tagname in $taglist; do 912521070a0Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 9134456fccdSmrg done 9144456fccdSmrg 915521070a0Smrg exit $? 916521070a0Smrg} 9174456fccdSmrg 918521070a0Smrg# func_features 919521070a0Smrg# Display the features supported by this script. 920521070a0Smrgfunc_features () 921521070a0Smrg{ 922ff63a143Smrg echo "host: $host" 9234456fccdSmrg if test "$build_libtool_libs" = yes; then 924ff63a143Smrg echo "enable shared libraries" 9254456fccdSmrg else 926ff63a143Smrg echo "disable shared libraries" 9274456fccdSmrg fi 9284456fccdSmrg if test "$build_old_libs" = yes; then 929ff63a143Smrg echo "enable static libraries" 9304456fccdSmrg else 931ff63a143Smrg echo "disable static libraries" 9324456fccdSmrg fi 933521070a0Smrg 9344456fccdSmrg exit $? 935521070a0Smrg} 9364456fccdSmrg 937521070a0Smrg# func_enable_tag tagname 938521070a0Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 939521070a0Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 940521070a0Smrg# variable here. 941521070a0Smrgfunc_enable_tag () 942521070a0Smrg{ 943521070a0Smrg # Global variable: 944521070a0Smrg tagname="$1" 9454456fccdSmrg 946521070a0Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 947521070a0Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 948521070a0Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 9494456fccdSmrg 950521070a0Smrg # Validate tagname. 951521070a0Smrg case $tagname in 952521070a0Smrg *[!-_A-Za-z0-9,/]*) 953521070a0Smrg func_fatal_error "invalid tag name: $tagname" 954521070a0Smrg ;; 955521070a0Smrg esac 9564456fccdSmrg 957521070a0Smrg # Don't test for the "default" C tag, as we know it's 958521070a0Smrg # there but not specially marked. 959521070a0Smrg case $tagname in 960521070a0Smrg CC) ;; 961521070a0Smrg *) 962521070a0Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 963521070a0Smrg taglist="$taglist $tagname" 964521070a0Smrg 965521070a0Smrg # Evaluate the configuration. Be careful to quote the path 966521070a0Smrg # and the sed script, to avoid splitting on whitespace, but 967521070a0Smrg # also don't use non-portable quotes within backquotes within 968521070a0Smrg # quotes we have to do it in 2 steps: 969521070a0Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 970521070a0Smrg eval "$extractedcf" 971521070a0Smrg else 972521070a0Smrg func_error "ignoring unknown tag $tagname" 973521070a0Smrg fi 974521070a0Smrg ;; 975521070a0Smrg esac 976521070a0Smrg} 977521070a0Smrg 9783e6c936aSmrg# func_check_version_match 9793e6c936aSmrg# Ensure that we are using m4 macros, and libtool script from the same 9803e6c936aSmrg# release of libtool. 9813e6c936aSmrgfunc_check_version_match () 982521070a0Smrg{ 9833e6c936aSmrg if test "$package_revision" != "$macro_revision"; then 9843e6c936aSmrg if test "$VERSION" != "$macro_version"; then 9853e6c936aSmrg if test -z "$macro_version"; then 9863e6c936aSmrg cat >&2 <<_LT_EOF 9873e6c936aSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 9883e6c936aSmrg$progname: definition of this LT_INIT comes from an older release. 9893e6c936aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 9903e6c936aSmrg$progname: and run autoconf again. 9913e6c936aSmrg_LT_EOF 9923e6c936aSmrg else 9933e6c936aSmrg cat >&2 <<_LT_EOF 9943e6c936aSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 9953e6c936aSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 9963e6c936aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 9973e6c936aSmrg$progname: and run autoconf again. 9983e6c936aSmrg_LT_EOF 9993e6c936aSmrg fi 10003e6c936aSmrg else 10013e6c936aSmrg cat >&2 <<_LT_EOF 10023e6c936aSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 10033e6c936aSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 10043e6c936aSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 10053e6c936aSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 10063e6c936aSmrg_LT_EOF 10073e6c936aSmrg fi 10083e6c936aSmrg 10093e6c936aSmrg exit $EXIT_MISMATCH 10103e6c936aSmrg fi 10113e6c936aSmrg} 10123e6c936aSmrg 10133e6c936aSmrg 10143e6c936aSmrg# Shorthand for --mode=foo, only valid as the first argument 10153e6c936aSmrgcase $1 in 10163e6c936aSmrgclean|clea|cle|cl) 10173e6c936aSmrg shift; set dummy --mode clean ${1+"$@"}; shift 10183e6c936aSmrg ;; 10193e6c936aSmrgcompile|compil|compi|comp|com|co|c) 10203e6c936aSmrg shift; set dummy --mode compile ${1+"$@"}; shift 10213e6c936aSmrg ;; 10223e6c936aSmrgexecute|execut|execu|exec|exe|ex|e) 10233e6c936aSmrg shift; set dummy --mode execute ${1+"$@"}; shift 10243e6c936aSmrg ;; 10253e6c936aSmrgfinish|finis|fini|fin|fi|f) 10263e6c936aSmrg shift; set dummy --mode finish ${1+"$@"}; shift 10273e6c936aSmrg ;; 10283e6c936aSmrginstall|instal|insta|inst|ins|in|i) 10293e6c936aSmrg shift; set dummy --mode install ${1+"$@"}; shift 10303e6c936aSmrg ;; 10313e6c936aSmrglink|lin|li|l) 10323e6c936aSmrg shift; set dummy --mode link ${1+"$@"}; shift 10333e6c936aSmrg ;; 10343e6c936aSmrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 10353e6c936aSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 10363e6c936aSmrg ;; 10373e6c936aSmrgesac 10383e6c936aSmrg 10393e6c936aSmrg 10403e6c936aSmrg 10413e6c936aSmrg# Option defaults: 10423e6c936aSmrgopt_debug=: 10433e6c936aSmrgopt_dry_run=false 10443e6c936aSmrgopt_config=false 10453e6c936aSmrgopt_preserve_dup_deps=false 10463e6c936aSmrgopt_features=false 10473e6c936aSmrgopt_finish=false 10483e6c936aSmrgopt_help=false 10493e6c936aSmrgopt_help_all=false 10503e6c936aSmrgopt_silent=: 10513e6c936aSmrgopt_warning=: 10523e6c936aSmrgopt_verbose=: 10533e6c936aSmrgopt_silent=false 10543e6c936aSmrgopt_verbose=false 10554456fccdSmrg 10564456fccdSmrg 10573e6c936aSmrg# Parse options once, thoroughly. This comes as soon as possible in the 10583e6c936aSmrg# script to make things like `--version' happen as quickly as we can. 10593e6c936aSmrg{ 10603e6c936aSmrg # this just eases exit handling 10613e6c936aSmrg while test $# -gt 0; do 1062521070a0Smrg opt="$1" 1063521070a0Smrg shift 1064521070a0Smrg case $opt in 10653e6c936aSmrg --debug|-x) opt_debug='set -x' 1066521070a0Smrg func_echo "enabling shell trace mode" 1067521070a0Smrg $opt_debug 1068521070a0Smrg ;; 10693e6c936aSmrg --dry-run|--dryrun|-n) 10703e6c936aSmrg opt_dry_run=: 1071521070a0Smrg ;; 10723e6c936aSmrg --config) 10733e6c936aSmrg opt_config=: 10743e6c936aSmrgfunc_config 10753e6c936aSmrg ;; 10763e6c936aSmrg --dlopen|-dlopen) 10773e6c936aSmrg optarg="$1" 10783e6c936aSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 10793e6c936aSmrg}$optarg" 1080521070a0Smrg shift 1081521070a0Smrg ;; 1082521070a0Smrg --preserve-dup-deps) 10833e6c936aSmrg opt_preserve_dup_deps=: 1084ff63a143Smrg ;; 10853e6c936aSmrg --features) 10863e6c936aSmrg opt_features=: 10873e6c936aSmrgfunc_features 1088521070a0Smrg ;; 10893e6c936aSmrg --finish) 10903e6c936aSmrg opt_finish=: 10913e6c936aSmrgset dummy --mode finish ${1+"$@"}; shift 10923e6c936aSmrg ;; 10933e6c936aSmrg --help) 10943e6c936aSmrg opt_help=: 10953e6c936aSmrg ;; 10963e6c936aSmrg --help-all) 10973e6c936aSmrg opt_help_all=: 10983e6c936aSmrgopt_help=': help-all' 10993e6c936aSmrg ;; 11003e6c936aSmrg --mode) 11013e6c936aSmrg test $# = 0 && func_missing_arg $opt && break 11023e6c936aSmrg optarg="$1" 11033e6c936aSmrg opt_mode="$optarg" 11043e6c936aSmrgcase $optarg in 11053e6c936aSmrg # Valid mode arguments: 11063e6c936aSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 11073e6c936aSmrg 11083e6c936aSmrg # Catch anything else as an error 11093e6c936aSmrg *) func_error "invalid argument for $opt" 11103e6c936aSmrg exit_cmd=exit 11113e6c936aSmrg break 11123e6c936aSmrg ;; 11133e6c936aSmrgesac 11143e6c936aSmrg shift 11153e6c936aSmrg ;; 11163e6c936aSmrg --no-silent|--no-quiet) 1117521070a0Smrg opt_silent=false 11183e6c936aSmrgfunc_append preserve_args " $opt" 1119ff63a143Smrg ;; 11203e6c936aSmrg --no-warning|--no-warn) 11213e6c936aSmrg opt_warning=false 11223e6c936aSmrgfunc_append preserve_args " $opt" 11233e6c936aSmrg ;; 11243e6c936aSmrg --no-verbose) 1125ff63a143Smrg opt_verbose=false 11263e6c936aSmrgfunc_append preserve_args " $opt" 1127521070a0Smrg ;; 11283e6c936aSmrg --silent|--quiet) 11293e6c936aSmrg opt_silent=: 11303e6c936aSmrgfunc_append preserve_args " $opt" 11313e6c936aSmrg opt_verbose=false 11323e6c936aSmrg ;; 11333e6c936aSmrg --verbose|-v) 11343e6c936aSmrg opt_verbose=: 11353e6c936aSmrgfunc_append preserve_args " $opt" 11363e6c936aSmrgopt_silent=false 11373e6c936aSmrg ;; 11383e6c936aSmrg --tag) 11393e6c936aSmrg test $# = 0 && func_missing_arg $opt && break 11403e6c936aSmrg optarg="$1" 11413e6c936aSmrg opt_tag="$optarg" 11423e6c936aSmrgfunc_append preserve_args " $opt $optarg" 11433e6c936aSmrgfunc_enable_tag "$optarg" 1144521070a0Smrg shift 1145521070a0Smrg ;; 1146521070a0Smrg 11473e6c936aSmrg -\?|-h) func_usage ;; 11483e6c936aSmrg --help) func_help ;; 11493e6c936aSmrg --version) func_version ;; 11503e6c936aSmrg 1151521070a0Smrg # Separate optargs to long options: 11523e6c936aSmrg --*=*) 11533e6c936aSmrg func_split_long_opt "$opt" 11543e6c936aSmrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 1155521070a0Smrg shift 1156521070a0Smrg ;; 1157521070a0Smrg 11583e6c936aSmrg # Separate non-argument short options: 11593e6c936aSmrg -\?*|-h*|-n*|-v*) 11603e6c936aSmrg func_split_short_opt "$opt" 11613e6c936aSmrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 11623e6c936aSmrg shift 1163521070a0Smrg ;; 11643e6c936aSmrg 11653e6c936aSmrg --) break ;; 11663e6c936aSmrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 11673e6c936aSmrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 1168521070a0Smrg esac 1169521070a0Smrg done 1170521070a0Smrg 11713e6c936aSmrg # Validate options: 11723e6c936aSmrg 11733e6c936aSmrg # save first non-option argument 11743e6c936aSmrg if test "$#" -gt 0; then 11753e6c936aSmrg nonopt="$opt" 11763e6c936aSmrg shift 11773e6c936aSmrg fi 11783e6c936aSmrg 11793e6c936aSmrg # preserve --debug 11803e6c936aSmrg test "$opt_debug" = : || func_append preserve_args " --debug" 1181521070a0Smrg 1182521070a0Smrg case $host in 1183521070a0Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 1184521070a0Smrg # don't eliminate duplications in $postdeps and $predeps 1185521070a0Smrg opt_duplicate_compiler_generated_deps=: 11864456fccdSmrg ;; 11874456fccdSmrg *) 11883e6c936aSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 1189521070a0Smrg ;; 1190521070a0Smrg esac 11914456fccdSmrg 11923e6c936aSmrg $opt_help || { 11933e6c936aSmrg # Sanity checks first: 11943e6c936aSmrg func_check_version_match 1195521070a0Smrg 11963e6c936aSmrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 11973e6c936aSmrg func_fatal_configuration "not configured to build any kind of library" 1198521070a0Smrg fi 1199521070a0Smrg 12003e6c936aSmrg # Darwin sucks 12013e6c936aSmrg eval std_shrext=\"$shrext_cmds\" 1202521070a0Smrg 12033e6c936aSmrg # Only execute mode is allowed to have -dlopen flags. 12043e6c936aSmrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 12053e6c936aSmrg func_error "unrecognized option \`-dlopen'" 12063e6c936aSmrg $ECHO "$help" 1>&2 12073e6c936aSmrg exit $EXIT_FAILURE 12083e6c936aSmrg fi 1209521070a0Smrg 12103e6c936aSmrg # Change the help message to a mode-specific one. 12113e6c936aSmrg generic_help="$help" 12123e6c936aSmrg help="Try \`$progname --help --mode=$opt_mode' for more information." 12133e6c936aSmrg } 1214521070a0Smrg 1215521070a0Smrg 12163e6c936aSmrg # Bail if the options were screwed 12173e6c936aSmrg $exit_cmd $EXIT_FAILURE 12183e6c936aSmrg} 1219521070a0Smrg 1220521070a0Smrg 12214456fccdSmrg 12224456fccdSmrg 12233e6c936aSmrg## ----------- ## 12243e6c936aSmrg## Main. ## 12253e6c936aSmrg## ----------- ## 12264456fccdSmrg 1227521070a0Smrg# func_lalib_p file 1228521070a0Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 1229521070a0Smrg# This function is only a basic sanity check; it will hardly flush out 1230521070a0Smrg# determined imposters. 1231521070a0Smrgfunc_lalib_p () 1232521070a0Smrg{ 1233521070a0Smrg test -f "$1" && 1234521070a0Smrg $SED -e 4q "$1" 2>/dev/null \ 1235521070a0Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 1236521070a0Smrg} 12374456fccdSmrg 1238521070a0Smrg# func_lalib_unsafe_p file 1239521070a0Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 1240521070a0Smrg# This function implements the same check as func_lalib_p without 1241521070a0Smrg# resorting to external programs. To this end, it redirects stdin and 1242521070a0Smrg# closes it afterwards, without saving the original file descriptor. 1243521070a0Smrg# As a safety measure, use it only where a negative result would be 1244521070a0Smrg# fatal anyway. Works if `file' does not exist. 1245521070a0Smrgfunc_lalib_unsafe_p () 1246521070a0Smrg{ 1247521070a0Smrg lalib_p=no 1248521070a0Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 1249521070a0Smrg for lalib_p_l in 1 2 3 4 1250521070a0Smrg do 1251521070a0Smrg read lalib_p_line 1252521070a0Smrg case "$lalib_p_line" in 1253521070a0Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 1254521070a0Smrg esac 1255521070a0Smrg done 1256521070a0Smrg exec 0<&5 5<&- 1257521070a0Smrg fi 1258521070a0Smrg test "$lalib_p" = yes 1259521070a0Smrg} 12604456fccdSmrg 1261521070a0Smrg# func_ltwrapper_script_p file 1262521070a0Smrg# True iff FILE is a libtool wrapper script 1263521070a0Smrg# This function is only a basic sanity check; it will hardly flush out 1264521070a0Smrg# determined imposters. 1265521070a0Smrgfunc_ltwrapper_script_p () 1266521070a0Smrg{ 1267521070a0Smrg func_lalib_p "$1" 1268521070a0Smrg} 12694456fccdSmrg 1270521070a0Smrg# func_ltwrapper_executable_p file 1271521070a0Smrg# True iff FILE is a libtool wrapper executable 1272521070a0Smrg# This function is only a basic sanity check; it will hardly flush out 1273521070a0Smrg# determined imposters. 1274521070a0Smrgfunc_ltwrapper_executable_p () 1275521070a0Smrg{ 1276521070a0Smrg func_ltwrapper_exec_suffix= 1277521070a0Smrg case $1 in 1278521070a0Smrg *.exe) ;; 1279521070a0Smrg *) func_ltwrapper_exec_suffix=.exe ;; 1280521070a0Smrg esac 1281521070a0Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 1282521070a0Smrg} 12834456fccdSmrg 1284521070a0Smrg# func_ltwrapper_scriptname file 1285521070a0Smrg# Assumes file is an ltwrapper_executable 1286521070a0Smrg# uses $file to determine the appropriate filename for a 1287521070a0Smrg# temporary ltwrapper_script. 1288521070a0Smrgfunc_ltwrapper_scriptname () 1289521070a0Smrg{ 12903e6c936aSmrg func_dirname_and_basename "$1" "" "." 12913e6c936aSmrg func_stripname '' '.exe' "$func_basename_result" 12923e6c936aSmrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 1293521070a0Smrg} 1294521070a0Smrg 1295521070a0Smrg# func_ltwrapper_p file 1296521070a0Smrg# True iff FILE is a libtool wrapper script or wrapper executable 1297521070a0Smrg# This function is only a basic sanity check; it will hardly flush out 1298521070a0Smrg# determined imposters. 1299521070a0Smrgfunc_ltwrapper_p () 1300521070a0Smrg{ 1301521070a0Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 1302521070a0Smrg} 1303521070a0Smrg 1304521070a0Smrg 1305521070a0Smrg# func_execute_cmds commands fail_cmd 1306521070a0Smrg# Execute tilde-delimited COMMANDS. 1307521070a0Smrg# If FAIL_CMD is given, eval that upon failure. 1308521070a0Smrg# FAIL_CMD may read-access the current command in variable CMD! 1309521070a0Smrgfunc_execute_cmds () 1310521070a0Smrg{ 1311521070a0Smrg $opt_debug 1312521070a0Smrg save_ifs=$IFS; IFS='~' 1313521070a0Smrg for cmd in $1; do 1314521070a0Smrg IFS=$save_ifs 1315521070a0Smrg eval cmd=\"$cmd\" 1316521070a0Smrg func_show_eval "$cmd" "${2-:}" 1317521070a0Smrg done 1318521070a0Smrg IFS=$save_ifs 1319521070a0Smrg} 1320521070a0Smrg 1321521070a0Smrg 1322521070a0Smrg# func_source file 1323521070a0Smrg# Source FILE, adding directory component if necessary. 1324521070a0Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 1325521070a0Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 1326521070a0Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 1327521070a0Smrg# `FILE.' does not work on cygwin managed mounts. 1328521070a0Smrgfunc_source () 1329521070a0Smrg{ 1330521070a0Smrg $opt_debug 1331521070a0Smrg case $1 in 1332521070a0Smrg */* | *\\*) . "$1" ;; 1333521070a0Smrg *) . "./$1" ;; 1334521070a0Smrg esac 1335521070a0Smrg} 1336521070a0Smrg 1337521070a0Smrg 13383e6c936aSmrg# func_resolve_sysroot PATH 13393e6c936aSmrg# Replace a leading = in PATH with a sysroot. Store the result into 13403e6c936aSmrg# func_resolve_sysroot_result 13413e6c936aSmrgfunc_resolve_sysroot () 13423e6c936aSmrg{ 13433e6c936aSmrg func_resolve_sysroot_result=$1 13443e6c936aSmrg case $func_resolve_sysroot_result in 13453e6c936aSmrg =*) 13463e6c936aSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 13473e6c936aSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 13483e6c936aSmrg ;; 13493e6c936aSmrg esac 13503e6c936aSmrg} 13513e6c936aSmrg 13523e6c936aSmrg# func_replace_sysroot PATH 13533e6c936aSmrg# If PATH begins with the sysroot, replace it with = and 13543e6c936aSmrg# store the result into func_replace_sysroot_result. 13553e6c936aSmrgfunc_replace_sysroot () 13563e6c936aSmrg{ 13573e6c936aSmrg case "$lt_sysroot:$1" in 13583e6c936aSmrg ?*:"$lt_sysroot"*) 13593e6c936aSmrg func_stripname "$lt_sysroot" '' "$1" 13603e6c936aSmrg func_replace_sysroot_result="=$func_stripname_result" 13613e6c936aSmrg ;; 13623e6c936aSmrg *) 13633e6c936aSmrg # Including no sysroot. 13643e6c936aSmrg func_replace_sysroot_result=$1 13653e6c936aSmrg ;; 13663e6c936aSmrg esac 13673e6c936aSmrg} 13683e6c936aSmrg 1369521070a0Smrg# func_infer_tag arg 1370521070a0Smrg# Infer tagged configuration to use if any are available and 1371521070a0Smrg# if one wasn't chosen via the "--tag" command line option. 1372521070a0Smrg# Only attempt this if the compiler in the base compile 1373521070a0Smrg# command doesn't match the default compiler. 1374521070a0Smrg# arg is usually of the form 'gcc ...' 1375521070a0Smrgfunc_infer_tag () 1376521070a0Smrg{ 1377521070a0Smrg $opt_debug 1378521070a0Smrg if test -n "$available_tags" && test -z "$tagname"; then 1379521070a0Smrg CC_quoted= 1380521070a0Smrg for arg in $CC; do 13813e6c936aSmrg func_append_quoted CC_quoted "$arg" 1382521070a0Smrg done 1383ff63a143Smrg CC_expanded=`func_echo_all $CC` 1384ff63a143Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 1385521070a0Smrg case $@ in 1386521070a0Smrg # Blanks in the command may have been stripped by the calling shell, 1387521070a0Smrg # but not from the CC environment variable when configure was run. 1388ff63a143Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1389ff63a143Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 1390521070a0Smrg # Blanks at the start of $base_compile will cause this to fail 1391521070a0Smrg # if we don't check for them as well. 1392521070a0Smrg *) 1393521070a0Smrg for z in $available_tags; do 1394521070a0Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 1395521070a0Smrg # Evaluate the configuration. 1396521070a0Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 1397521070a0Smrg CC_quoted= 1398521070a0Smrg for arg in $CC; do 1399521070a0Smrg # Double-quote args containing other shell metacharacters. 14003e6c936aSmrg func_append_quoted CC_quoted "$arg" 1401521070a0Smrg done 1402ff63a143Smrg CC_expanded=`func_echo_all $CC` 1403ff63a143Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 1404521070a0Smrg case "$@ " in 1405ff63a143Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1406ff63a143Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 1407521070a0Smrg # The compiler in the base compile command matches 1408521070a0Smrg # the one in the tagged configuration. 1409521070a0Smrg # Assume this is the tagged configuration we want. 1410521070a0Smrg tagname=$z 1411521070a0Smrg break 1412521070a0Smrg ;; 1413521070a0Smrg esac 1414521070a0Smrg fi 1415521070a0Smrg done 1416521070a0Smrg # If $tagname still isn't set, then no tagged configuration 1417521070a0Smrg # was found and let the user know that the "--tag" command 1418521070a0Smrg # line option must be used. 1419521070a0Smrg if test -z "$tagname"; then 1420521070a0Smrg func_echo "unable to infer tagged configuration" 1421521070a0Smrg func_fatal_error "specify a tag with \`--tag'" 1422521070a0Smrg# else 1423521070a0Smrg# func_verbose "using $tagname tagged configuration" 1424521070a0Smrg fi 1425521070a0Smrg ;; 1426521070a0Smrg esac 1427521070a0Smrg fi 1428521070a0Smrg} 1429521070a0Smrg 1430521070a0Smrg 14313e6c936aSmrg 14323e6c936aSmrg# func_write_libtool_object output_name pic_name nonpic_name 14333e6c936aSmrg# Create a libtool object file (analogous to a ".la" file), 14343e6c936aSmrg# but don't create it if we're doing a dry run. 14353e6c936aSmrgfunc_write_libtool_object () 14363e6c936aSmrg{ 14373e6c936aSmrg write_libobj=${1} 14383e6c936aSmrg if test "$build_libtool_libs" = yes; then 14393e6c936aSmrg write_lobj=\'${2}\' 14403e6c936aSmrg else 14413e6c936aSmrg write_lobj=none 14423e6c936aSmrg fi 14433e6c936aSmrg 14443e6c936aSmrg if test "$build_old_libs" = yes; then 14453e6c936aSmrg write_oldobj=\'${3}\' 14463e6c936aSmrg else 14473e6c936aSmrg write_oldobj=none 14483e6c936aSmrg fi 14493e6c936aSmrg 14503e6c936aSmrg $opt_dry_run || { 14513e6c936aSmrg cat >${write_libobj}T <<EOF 14523e6c936aSmrg# $write_libobj - a libtool object file 14533e6c936aSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 14543e6c936aSmrg# 14553e6c936aSmrg# Please DO NOT delete this file! 14563e6c936aSmrg# It is necessary for linking the library. 14573e6c936aSmrg 14583e6c936aSmrg# Name of the PIC object. 14593e6c936aSmrgpic_object=$write_lobj 14603e6c936aSmrg 14613e6c936aSmrg# Name of the non-PIC object 14623e6c936aSmrgnon_pic_object=$write_oldobj 14633e6c936aSmrg 14643e6c936aSmrgEOF 14653e6c936aSmrg $MV "${write_libobj}T" "${write_libobj}" 14663e6c936aSmrg } 14673e6c936aSmrg} 14683e6c936aSmrg 14693e6c936aSmrg 14703e6c936aSmrg################################################## 14713e6c936aSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 14723e6c936aSmrg################################################## 14733e6c936aSmrg 14743e6c936aSmrg# func_convert_core_file_wine_to_w32 ARG 14753e6c936aSmrg# Helper function used by file name conversion functions when $build is *nix, 14763e6c936aSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 14773e6c936aSmrg# correctly configured wine environment available, with the winepath program 14783e6c936aSmrg# in $build's $PATH. 14793e6c936aSmrg# 14803e6c936aSmrg# ARG is the $build file name to be converted to w32 format. 14813e6c936aSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 14823e6c936aSmrg# be empty on error (or when ARG is empty) 14833e6c936aSmrgfunc_convert_core_file_wine_to_w32 () 14843e6c936aSmrg{ 14853e6c936aSmrg $opt_debug 14863e6c936aSmrg func_convert_core_file_wine_to_w32_result="$1" 14873e6c936aSmrg if test -n "$1"; then 14883e6c936aSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 14893e6c936aSmrg # are forced to check the contents of stdout. On the other hand, if the 14903e6c936aSmrg # command is not found, the shell will set an exit code of 127 and print 14913e6c936aSmrg # *an error message* to stdout. So we must check for both error code of 14923e6c936aSmrg # zero AND non-empty stdout, which explains the odd construction: 14933e6c936aSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 14943e6c936aSmrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 14953e6c936aSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 14963e6c936aSmrg $SED -e "$lt_sed_naive_backslashify"` 14973e6c936aSmrg else 14983e6c936aSmrg func_convert_core_file_wine_to_w32_result= 14993e6c936aSmrg fi 15003e6c936aSmrg fi 15013e6c936aSmrg} 15023e6c936aSmrg# end: func_convert_core_file_wine_to_w32 15033e6c936aSmrg 15043e6c936aSmrg 15053e6c936aSmrg# func_convert_core_path_wine_to_w32 ARG 15063e6c936aSmrg# Helper function used by path conversion functions when $build is *nix, and 15073e6c936aSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 15083e6c936aSmrg# configured wine environment available, with the winepath program in $build's 15093e6c936aSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 15103e6c936aSmrg# 15113e6c936aSmrg# ARG is path to be converted from $build format to win32. 15123e6c936aSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 15133e6c936aSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 15143e6c936aSmrg# are convertible, then the result may be empty. 15153e6c936aSmrgfunc_convert_core_path_wine_to_w32 () 15163e6c936aSmrg{ 15173e6c936aSmrg $opt_debug 15183e6c936aSmrg # unfortunately, winepath doesn't convert paths, only file names 15193e6c936aSmrg func_convert_core_path_wine_to_w32_result="" 15203e6c936aSmrg if test -n "$1"; then 15213e6c936aSmrg oldIFS=$IFS 15223e6c936aSmrg IFS=: 15233e6c936aSmrg for func_convert_core_path_wine_to_w32_f in $1; do 15243e6c936aSmrg IFS=$oldIFS 15253e6c936aSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 15263e6c936aSmrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 15273e6c936aSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 15283e6c936aSmrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 15293e6c936aSmrg else 15303e6c936aSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 15313e6c936aSmrg fi 15323e6c936aSmrg fi 15333e6c936aSmrg done 15343e6c936aSmrg IFS=$oldIFS 15353e6c936aSmrg fi 15363e6c936aSmrg} 15373e6c936aSmrg# end: func_convert_core_path_wine_to_w32 15383e6c936aSmrg 15393e6c936aSmrg 15403e6c936aSmrg# func_cygpath ARGS... 15413e6c936aSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 15423e6c936aSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 15433e6c936aSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 15443e6c936aSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 15453e6c936aSmrg# file name or path is assumed to be in w32 format, as previously converted 15463e6c936aSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 15473e6c936aSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 15483e6c936aSmrg# Cygwin format). Returns an empty string on error. 15493e6c936aSmrg# 15503e6c936aSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 15513e6c936aSmrg# be converted. 15523e6c936aSmrg# 15533e6c936aSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 15543e6c936aSmrg# environment variable; do not put it in $PATH. 15553e6c936aSmrgfunc_cygpath () 15563e6c936aSmrg{ 15573e6c936aSmrg $opt_debug 15583e6c936aSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 15593e6c936aSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 15603e6c936aSmrg if test "$?" -ne 0; then 15613e6c936aSmrg # on failure, ensure result is empty 15623e6c936aSmrg func_cygpath_result= 15633e6c936aSmrg fi 15643e6c936aSmrg else 15653e6c936aSmrg func_cygpath_result= 15663e6c936aSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 15673e6c936aSmrg fi 15683e6c936aSmrg} 15693e6c936aSmrg#end: func_cygpath 15703e6c936aSmrg 15713e6c936aSmrg 15723e6c936aSmrg# func_convert_core_msys_to_w32 ARG 15733e6c936aSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 15743e6c936aSmrg# result in func_convert_core_msys_to_w32_result. 15753e6c936aSmrgfunc_convert_core_msys_to_w32 () 15763e6c936aSmrg{ 15773e6c936aSmrg $opt_debug 15783e6c936aSmrg # awkward: cmd appends spaces to result 15793e6c936aSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 15803e6c936aSmrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 15813e6c936aSmrg} 15823e6c936aSmrg#end: func_convert_core_msys_to_w32 15833e6c936aSmrg 15843e6c936aSmrg 15853e6c936aSmrg# func_convert_file_check ARG1 ARG2 15863e6c936aSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 15873e6c936aSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 15883e6c936aSmrg# func_to_host_file_result to ARG1). 15893e6c936aSmrgfunc_convert_file_check () 15903e6c936aSmrg{ 15913e6c936aSmrg $opt_debug 15923e6c936aSmrg if test -z "$2" && test -n "$1" ; then 15933e6c936aSmrg func_error "Could not determine host file name corresponding to" 15943e6c936aSmrg func_error " \`$1'" 15953e6c936aSmrg func_error "Continuing, but uninstalled executables may not work." 15963e6c936aSmrg # Fallback: 15973e6c936aSmrg func_to_host_file_result="$1" 15983e6c936aSmrg fi 15993e6c936aSmrg} 16003e6c936aSmrg# end func_convert_file_check 16013e6c936aSmrg 16023e6c936aSmrg 16033e6c936aSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 16043e6c936aSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 16053e6c936aSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 16063e6c936aSmrg# func_to_host_file_result to a simplistic fallback value (see below). 16073e6c936aSmrgfunc_convert_path_check () 16083e6c936aSmrg{ 16093e6c936aSmrg $opt_debug 16103e6c936aSmrg if test -z "$4" && test -n "$3"; then 16113e6c936aSmrg func_error "Could not determine the host path corresponding to" 16123e6c936aSmrg func_error " \`$3'" 16133e6c936aSmrg func_error "Continuing, but uninstalled executables may not work." 16143e6c936aSmrg # Fallback. This is a deliberately simplistic "conversion" and 16153e6c936aSmrg # should not be "improved". See libtool.info. 16163e6c936aSmrg if test "x$1" != "x$2"; then 16173e6c936aSmrg lt_replace_pathsep_chars="s|$1|$2|g" 16183e6c936aSmrg func_to_host_path_result=`echo "$3" | 16193e6c936aSmrg $SED -e "$lt_replace_pathsep_chars"` 16203e6c936aSmrg else 16213e6c936aSmrg func_to_host_path_result="$3" 16223e6c936aSmrg fi 16233e6c936aSmrg fi 16243e6c936aSmrg} 16253e6c936aSmrg# end func_convert_path_check 16263e6c936aSmrg 16273e6c936aSmrg 16283e6c936aSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 16293e6c936aSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 16303e6c936aSmrg# and appending REPL if ORIG matches BACKPAT. 16313e6c936aSmrgfunc_convert_path_front_back_pathsep () 16323e6c936aSmrg{ 16333e6c936aSmrg $opt_debug 16343e6c936aSmrg case $4 in 16353e6c936aSmrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 16363e6c936aSmrg ;; 16373e6c936aSmrg esac 16383e6c936aSmrg case $4 in 16393e6c936aSmrg $2 ) func_append func_to_host_path_result "$3" 16403e6c936aSmrg ;; 16413e6c936aSmrg esac 16423e6c936aSmrg} 16433e6c936aSmrg# end func_convert_path_front_back_pathsep 16443e6c936aSmrg 16453e6c936aSmrg 16463e6c936aSmrg################################################## 16473e6c936aSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 16483e6c936aSmrg################################################## 16493e6c936aSmrg# invoked via `$to_host_file_cmd ARG' 16503e6c936aSmrg# 16513e6c936aSmrg# In each case, ARG is the path to be converted from $build to $host format. 16523e6c936aSmrg# Result will be available in $func_to_host_file_result. 16533e6c936aSmrg 16543e6c936aSmrg 16553e6c936aSmrg# func_to_host_file ARG 16563e6c936aSmrg# Converts the file name ARG from $build format to $host format. Return result 16573e6c936aSmrg# in func_to_host_file_result. 16583e6c936aSmrgfunc_to_host_file () 16593e6c936aSmrg{ 16603e6c936aSmrg $opt_debug 16613e6c936aSmrg $to_host_file_cmd "$1" 16623e6c936aSmrg} 16633e6c936aSmrg# end func_to_host_file 16643e6c936aSmrg 16653e6c936aSmrg 16663e6c936aSmrg# func_to_tool_file ARG LAZY 16673e6c936aSmrg# converts the file name ARG from $build format to toolchain format. Return 16683e6c936aSmrg# result in func_to_tool_file_result. If the conversion in use is listed 16693e6c936aSmrg# in (the comma separated) LAZY, no conversion takes place. 16703e6c936aSmrgfunc_to_tool_file () 16713e6c936aSmrg{ 16723e6c936aSmrg $opt_debug 16733e6c936aSmrg case ,$2, in 16743e6c936aSmrg *,"$to_tool_file_cmd",*) 16753e6c936aSmrg func_to_tool_file_result=$1 16763e6c936aSmrg ;; 16773e6c936aSmrg *) 16783e6c936aSmrg $to_tool_file_cmd "$1" 16793e6c936aSmrg func_to_tool_file_result=$func_to_host_file_result 16803e6c936aSmrg ;; 16813e6c936aSmrg esac 16823e6c936aSmrg} 16833e6c936aSmrg# end func_to_tool_file 16843e6c936aSmrg 16853e6c936aSmrg 16863e6c936aSmrg# func_convert_file_noop ARG 16873e6c936aSmrg# Copy ARG to func_to_host_file_result. 16883e6c936aSmrgfunc_convert_file_noop () 16893e6c936aSmrg{ 16903e6c936aSmrg func_to_host_file_result="$1" 16913e6c936aSmrg} 16923e6c936aSmrg# end func_convert_file_noop 16933e6c936aSmrg 16943e6c936aSmrg 16953e6c936aSmrg# func_convert_file_msys_to_w32 ARG 16963e6c936aSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 16973e6c936aSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 16983e6c936aSmrg# func_to_host_file_result. 16993e6c936aSmrgfunc_convert_file_msys_to_w32 () 17003e6c936aSmrg{ 17013e6c936aSmrg $opt_debug 17023e6c936aSmrg func_to_host_file_result="$1" 17033e6c936aSmrg if test -n "$1"; then 17043e6c936aSmrg func_convert_core_msys_to_w32 "$1" 17053e6c936aSmrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 17063e6c936aSmrg fi 17073e6c936aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 17083e6c936aSmrg} 17093e6c936aSmrg# end func_convert_file_msys_to_w32 17103e6c936aSmrg 17113e6c936aSmrg 17123e6c936aSmrg# func_convert_file_cygwin_to_w32 ARG 17133e6c936aSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 17143e6c936aSmrg# func_to_host_file_result. 17153e6c936aSmrgfunc_convert_file_cygwin_to_w32 () 17163e6c936aSmrg{ 17173e6c936aSmrg $opt_debug 17183e6c936aSmrg func_to_host_file_result="$1" 17193e6c936aSmrg if test -n "$1"; then 17203e6c936aSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 17213e6c936aSmrg # LT_CYGPATH in this case. 17223e6c936aSmrg func_to_host_file_result=`cygpath -m "$1"` 17233e6c936aSmrg fi 17243e6c936aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 17253e6c936aSmrg} 17263e6c936aSmrg# end func_convert_file_cygwin_to_w32 17273e6c936aSmrg 17283e6c936aSmrg 17293e6c936aSmrg# func_convert_file_nix_to_w32 ARG 17303e6c936aSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 17313e6c936aSmrg# and a working winepath. Returns result in func_to_host_file_result. 17323e6c936aSmrgfunc_convert_file_nix_to_w32 () 17333e6c936aSmrg{ 17343e6c936aSmrg $opt_debug 17353e6c936aSmrg func_to_host_file_result="$1" 17363e6c936aSmrg if test -n "$1"; then 17373e6c936aSmrg func_convert_core_file_wine_to_w32 "$1" 17383e6c936aSmrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 17393e6c936aSmrg fi 17403e6c936aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 17413e6c936aSmrg} 17423e6c936aSmrg# end func_convert_file_nix_to_w32 17433e6c936aSmrg 17443e6c936aSmrg 17453e6c936aSmrg# func_convert_file_msys_to_cygwin ARG 17463e6c936aSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 17473e6c936aSmrg# Returns result in func_to_host_file_result. 17483e6c936aSmrgfunc_convert_file_msys_to_cygwin () 17493e6c936aSmrg{ 17503e6c936aSmrg $opt_debug 17513e6c936aSmrg func_to_host_file_result="$1" 17523e6c936aSmrg if test -n "$1"; then 17533e6c936aSmrg func_convert_core_msys_to_w32 "$1" 17543e6c936aSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 17553e6c936aSmrg func_to_host_file_result="$func_cygpath_result" 17563e6c936aSmrg fi 17573e6c936aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 17583e6c936aSmrg} 17593e6c936aSmrg# end func_convert_file_msys_to_cygwin 17603e6c936aSmrg 17613e6c936aSmrg 17623e6c936aSmrg# func_convert_file_nix_to_cygwin ARG 17633e6c936aSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 17643e6c936aSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 17653e6c936aSmrg# in func_to_host_file_result. 17663e6c936aSmrgfunc_convert_file_nix_to_cygwin () 17673e6c936aSmrg{ 17683e6c936aSmrg $opt_debug 17693e6c936aSmrg func_to_host_file_result="$1" 17703e6c936aSmrg if test -n "$1"; then 17713e6c936aSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 17723e6c936aSmrg func_convert_core_file_wine_to_w32 "$1" 17733e6c936aSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 17743e6c936aSmrg func_to_host_file_result="$func_cygpath_result" 17753e6c936aSmrg fi 17763e6c936aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 17773e6c936aSmrg} 17783e6c936aSmrg# end func_convert_file_nix_to_cygwin 17793e6c936aSmrg 17803e6c936aSmrg 17813e6c936aSmrg############################################# 17823e6c936aSmrg# $build to $host PATH CONVERSION FUNCTIONS # 17833e6c936aSmrg############################################# 17843e6c936aSmrg# invoked via `$to_host_path_cmd ARG' 17853e6c936aSmrg# 17863e6c936aSmrg# In each case, ARG is the path to be converted from $build to $host format. 17873e6c936aSmrg# The result will be available in $func_to_host_path_result. 17883e6c936aSmrg# 17893e6c936aSmrg# Path separators are also converted from $build format to $host format. If 17903e6c936aSmrg# ARG begins or ends with a path separator character, it is preserved (but 17913e6c936aSmrg# converted to $host format) on output. 17923e6c936aSmrg# 17933e6c936aSmrg# All path conversion functions are named using the following convention: 17943e6c936aSmrg# file name conversion function : func_convert_file_X_to_Y () 17953e6c936aSmrg# path conversion function : func_convert_path_X_to_Y () 17963e6c936aSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 17973e6c936aSmrg# same. If conversion functions are added for new $build/$host combinations, 17983e6c936aSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 17993e6c936aSmrg# will break. 18003e6c936aSmrg 18013e6c936aSmrg 18023e6c936aSmrg# func_init_to_host_path_cmd 18033e6c936aSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 18043e6c936aSmrg# appropriate value, based on the value of $to_host_file_cmd. 18053e6c936aSmrgto_host_path_cmd= 18063e6c936aSmrgfunc_init_to_host_path_cmd () 18073e6c936aSmrg{ 18083e6c936aSmrg $opt_debug 18093e6c936aSmrg if test -z "$to_host_path_cmd"; then 18103e6c936aSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 18113e6c936aSmrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 18123e6c936aSmrg fi 18133e6c936aSmrg} 18143e6c936aSmrg 18153e6c936aSmrg 18163e6c936aSmrg# func_to_host_path ARG 18173e6c936aSmrg# Converts the path ARG from $build format to $host format. Return result 18183e6c936aSmrg# in func_to_host_path_result. 18193e6c936aSmrgfunc_to_host_path () 18203e6c936aSmrg{ 18213e6c936aSmrg $opt_debug 18223e6c936aSmrg func_init_to_host_path_cmd 18233e6c936aSmrg $to_host_path_cmd "$1" 18243e6c936aSmrg} 18253e6c936aSmrg# end func_to_host_path 18263e6c936aSmrg 18273e6c936aSmrg 18283e6c936aSmrg# func_convert_path_noop ARG 18293e6c936aSmrg# Copy ARG to func_to_host_path_result. 18303e6c936aSmrgfunc_convert_path_noop () 18313e6c936aSmrg{ 18323e6c936aSmrg func_to_host_path_result="$1" 18333e6c936aSmrg} 18343e6c936aSmrg# end func_convert_path_noop 18353e6c936aSmrg 18363e6c936aSmrg 18373e6c936aSmrg# func_convert_path_msys_to_w32 ARG 18383e6c936aSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 18393e6c936aSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 18403e6c936aSmrg# func_to_host_path_result. 18413e6c936aSmrgfunc_convert_path_msys_to_w32 () 18423e6c936aSmrg{ 18433e6c936aSmrg $opt_debug 18443e6c936aSmrg func_to_host_path_result="$1" 18453e6c936aSmrg if test -n "$1"; then 18463e6c936aSmrg # Remove leading and trailing path separator characters from ARG. MSYS 18473e6c936aSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 18483e6c936aSmrg # and winepath ignores them completely. 18493e6c936aSmrg func_stripname : : "$1" 18503e6c936aSmrg func_to_host_path_tmp1=$func_stripname_result 18513e6c936aSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 18523e6c936aSmrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 18533e6c936aSmrg func_convert_path_check : ";" \ 18543e6c936aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 18553e6c936aSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 18563e6c936aSmrg fi 18573e6c936aSmrg} 18583e6c936aSmrg# end func_convert_path_msys_to_w32 18593e6c936aSmrg 18603e6c936aSmrg 18613e6c936aSmrg# func_convert_path_cygwin_to_w32 ARG 18623e6c936aSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 18633e6c936aSmrg# func_to_host_file_result. 18643e6c936aSmrgfunc_convert_path_cygwin_to_w32 () 18653e6c936aSmrg{ 18663e6c936aSmrg $opt_debug 18673e6c936aSmrg func_to_host_path_result="$1" 18683e6c936aSmrg if test -n "$1"; then 18693e6c936aSmrg # See func_convert_path_msys_to_w32: 18703e6c936aSmrg func_stripname : : "$1" 18713e6c936aSmrg func_to_host_path_tmp1=$func_stripname_result 18723e6c936aSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 18733e6c936aSmrg func_convert_path_check : ";" \ 18743e6c936aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 18753e6c936aSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 18763e6c936aSmrg fi 18773e6c936aSmrg} 18783e6c936aSmrg# end func_convert_path_cygwin_to_w32 18793e6c936aSmrg 18803e6c936aSmrg 18813e6c936aSmrg# func_convert_path_nix_to_w32 ARG 18823e6c936aSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 18833e6c936aSmrg# a working winepath. Returns result in func_to_host_file_result. 18843e6c936aSmrgfunc_convert_path_nix_to_w32 () 1885521070a0Smrg{ 18863e6c936aSmrg $opt_debug 18873e6c936aSmrg func_to_host_path_result="$1" 18883e6c936aSmrg if test -n "$1"; then 18893e6c936aSmrg # See func_convert_path_msys_to_w32: 18903e6c936aSmrg func_stripname : : "$1" 18913e6c936aSmrg func_to_host_path_tmp1=$func_stripname_result 18923e6c936aSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 18933e6c936aSmrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 18943e6c936aSmrg func_convert_path_check : ";" \ 18953e6c936aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 18963e6c936aSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 18973e6c936aSmrg fi 18983e6c936aSmrg} 18993e6c936aSmrg# end func_convert_path_nix_to_w32 1900521070a0Smrg 1901521070a0Smrg 19023e6c936aSmrg# func_convert_path_msys_to_cygwin ARG 19033e6c936aSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 19043e6c936aSmrg# Returns result in func_to_host_file_result. 19053e6c936aSmrgfunc_convert_path_msys_to_cygwin () 19063e6c936aSmrg{ 19073e6c936aSmrg $opt_debug 19083e6c936aSmrg func_to_host_path_result="$1" 19093e6c936aSmrg if test -n "$1"; then 19103e6c936aSmrg # See func_convert_path_msys_to_w32: 19113e6c936aSmrg func_stripname : : "$1" 19123e6c936aSmrg func_to_host_path_tmp1=$func_stripname_result 19133e6c936aSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 19143e6c936aSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 19153e6c936aSmrg func_to_host_path_result="$func_cygpath_result" 19163e6c936aSmrg func_convert_path_check : : \ 19173e6c936aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 19183e6c936aSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 19193e6c936aSmrg fi 19203e6c936aSmrg} 19213e6c936aSmrg# end func_convert_path_msys_to_cygwin 1922521070a0Smrg 1923521070a0Smrg 19243e6c936aSmrg# func_convert_path_nix_to_cygwin ARG 19253e6c936aSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 19263e6c936aSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 19273e6c936aSmrg# func_to_host_file_result. 19283e6c936aSmrgfunc_convert_path_nix_to_cygwin () 19293e6c936aSmrg{ 19303e6c936aSmrg $opt_debug 19313e6c936aSmrg func_to_host_path_result="$1" 19323e6c936aSmrg if test -n "$1"; then 19333e6c936aSmrg # Remove leading and trailing path separator characters from 19343e6c936aSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 19353e6c936aSmrg # into '.;' and ';.', and winepath ignores them completely. 19363e6c936aSmrg func_stripname : : "$1" 19373e6c936aSmrg func_to_host_path_tmp1=$func_stripname_result 19383e6c936aSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 19393e6c936aSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 19403e6c936aSmrg func_to_host_path_result="$func_cygpath_result" 19413e6c936aSmrg func_convert_path_check : : \ 19423e6c936aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 19433e6c936aSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 19443e6c936aSmrg fi 1945521070a0Smrg} 19463e6c936aSmrg# end func_convert_path_nix_to_cygwin 19473e6c936aSmrg 1948521070a0Smrg 1949521070a0Smrg# func_mode_compile arg... 1950521070a0Smrgfunc_mode_compile () 1951521070a0Smrg{ 1952521070a0Smrg $opt_debug 1953521070a0Smrg # Get the compilation command and the source file. 1954521070a0Smrg base_compile= 1955521070a0Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 1956521070a0Smrg suppress_opt=yes 1957521070a0Smrg suppress_output= 1958521070a0Smrg arg_mode=normal 1959521070a0Smrg libobj= 1960521070a0Smrg later= 1961521070a0Smrg pie_flag= 1962521070a0Smrg 1963521070a0Smrg for arg 1964521070a0Smrg do 1965521070a0Smrg case $arg_mode in 1966521070a0Smrg arg ) 1967521070a0Smrg # do not "continue". Instead, add this to base_compile 1968521070a0Smrg lastarg="$arg" 1969521070a0Smrg arg_mode=normal 1970521070a0Smrg ;; 1971521070a0Smrg 1972521070a0Smrg target ) 1973521070a0Smrg libobj="$arg" 1974521070a0Smrg arg_mode=normal 1975521070a0Smrg continue 1976521070a0Smrg ;; 1977521070a0Smrg 1978521070a0Smrg normal ) 1979521070a0Smrg # Accept any command-line options. 1980521070a0Smrg case $arg in 1981521070a0Smrg -o) 1982521070a0Smrg test -n "$libobj" && \ 1983521070a0Smrg func_fatal_error "you cannot specify \`-o' more than once" 1984521070a0Smrg arg_mode=target 1985521070a0Smrg continue 1986521070a0Smrg ;; 1987521070a0Smrg 1988521070a0Smrg -pie | -fpie | -fPIE) 19893e6c936aSmrg func_append pie_flag " $arg" 1990521070a0Smrg continue 1991521070a0Smrg ;; 1992521070a0Smrg 1993521070a0Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 19943e6c936aSmrg func_append later " $arg" 1995521070a0Smrg continue 1996521070a0Smrg ;; 1997521070a0Smrg 1998521070a0Smrg -no-suppress) 19994456fccdSmrg suppress_opt=no 20004456fccdSmrg continue 20014456fccdSmrg ;; 20024456fccdSmrg 20034456fccdSmrg -Xcompiler) 20044456fccdSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 20054456fccdSmrg continue # The current "srcfile" will either be retained or 20064456fccdSmrg ;; # replaced later. I would guess that would be a bug. 20074456fccdSmrg 20084456fccdSmrg -Wc,*) 2009521070a0Smrg func_stripname '-Wc,' '' "$arg" 2010521070a0Smrg args=$func_stripname_result 20114456fccdSmrg lastarg= 20124456fccdSmrg save_ifs="$IFS"; IFS=',' 2013521070a0Smrg for arg in $args; do 20144456fccdSmrg IFS="$save_ifs" 20153e6c936aSmrg func_append_quoted lastarg "$arg" 20164456fccdSmrg done 20174456fccdSmrg IFS="$save_ifs" 2018521070a0Smrg func_stripname ' ' '' "$lastarg" 2019521070a0Smrg lastarg=$func_stripname_result 20204456fccdSmrg 20214456fccdSmrg # Add the arguments to base_compile. 20223e6c936aSmrg func_append base_compile " $lastarg" 20234456fccdSmrg continue 20244456fccdSmrg ;; 20254456fccdSmrg 2026521070a0Smrg *) 20274456fccdSmrg # Accept the current argument as the source file. 20284456fccdSmrg # The previous "srcfile" becomes the current argument. 20294456fccdSmrg # 20304456fccdSmrg lastarg="$srcfile" 20314456fccdSmrg srcfile="$arg" 20324456fccdSmrg ;; 20334456fccdSmrg esac # case $arg 20344456fccdSmrg ;; 20354456fccdSmrg esac # case $arg_mode 20364456fccdSmrg 20374456fccdSmrg # Aesthetically quote the previous argument. 20383e6c936aSmrg func_append_quoted base_compile "$lastarg" 20394456fccdSmrg done # for arg 20404456fccdSmrg 20414456fccdSmrg case $arg_mode in 20424456fccdSmrg arg) 2043521070a0Smrg func_fatal_error "you must specify an argument for -Xcompile" 20444456fccdSmrg ;; 20454456fccdSmrg target) 2046521070a0Smrg func_fatal_error "you must specify a target with \`-o'" 20474456fccdSmrg ;; 20484456fccdSmrg *) 20494456fccdSmrg # Get the name of the library object. 2050521070a0Smrg test -z "$libobj" && { 2051521070a0Smrg func_basename "$srcfile" 2052521070a0Smrg libobj="$func_basename_result" 2053521070a0Smrg } 20544456fccdSmrg ;; 20554456fccdSmrg esac 20564456fccdSmrg 20574456fccdSmrg # Recognize several different file suffixes. 20584456fccdSmrg # If the user specifies -o file.o, it is replaced with file.lo 20594456fccdSmrg case $libobj in 2060521070a0Smrg *.[cCFSifmso] | \ 2061521070a0Smrg *.ada | *.adb | *.ads | *.asm | \ 2062521070a0Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 20633e6c936aSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 2064521070a0Smrg func_xform "$libobj" 2065521070a0Smrg libobj=$func_xform_result 2066521070a0Smrg ;; 20674456fccdSmrg esac 20684456fccdSmrg 20694456fccdSmrg case $libobj in 2070521070a0Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 20714456fccdSmrg *) 2072521070a0Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 20734456fccdSmrg ;; 20744456fccdSmrg esac 20754456fccdSmrg 20764456fccdSmrg func_infer_tag $base_compile 20774456fccdSmrg 20784456fccdSmrg for arg in $later; do 20794456fccdSmrg case $arg in 2080521070a0Smrg -shared) 2081521070a0Smrg test "$build_libtool_libs" != yes && \ 2082521070a0Smrg func_fatal_configuration "can not build a shared library" 2083521070a0Smrg build_old_libs=no 2084521070a0Smrg continue 2085521070a0Smrg ;; 2086521070a0Smrg 20874456fccdSmrg -static) 2088521070a0Smrg build_libtool_libs=no 20894456fccdSmrg build_old_libs=yes 20904456fccdSmrg continue 20914456fccdSmrg ;; 20924456fccdSmrg 20934456fccdSmrg -prefer-pic) 20944456fccdSmrg pic_mode=yes 20954456fccdSmrg continue 20964456fccdSmrg ;; 20974456fccdSmrg 20984456fccdSmrg -prefer-non-pic) 20994456fccdSmrg pic_mode=no 21004456fccdSmrg continue 21014456fccdSmrg ;; 21024456fccdSmrg esac 21034456fccdSmrg done 21044456fccdSmrg 2105521070a0Smrg func_quote_for_eval "$libobj" 2106521070a0Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 2107521070a0Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 2108521070a0Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 2109521070a0Smrg func_dirname_and_basename "$obj" "/" "" 2110521070a0Smrg objname="$func_basename_result" 2111521070a0Smrg xdir="$func_dirname_result" 21124456fccdSmrg lobj=${xdir}$objdir/$objname 21134456fccdSmrg 2114521070a0Smrg test -z "$base_compile" && \ 2115521070a0Smrg func_fatal_help "you must specify a compilation command" 21164456fccdSmrg 21174456fccdSmrg # Delete any leftover library objects. 21184456fccdSmrg if test "$build_old_libs" = yes; then 21194456fccdSmrg removelist="$obj $lobj $libobj ${libobj}T" 21204456fccdSmrg else 21214456fccdSmrg removelist="$lobj $libobj ${libobj}T" 21224456fccdSmrg fi 21234456fccdSmrg 21244456fccdSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 21254456fccdSmrg case $host_os in 2126521070a0Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 21274456fccdSmrg pic_mode=default 21284456fccdSmrg ;; 21294456fccdSmrg esac 21304456fccdSmrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 21314456fccdSmrg # non-PIC code in shared libraries is not supported 21324456fccdSmrg pic_mode=default 21334456fccdSmrg fi 21344456fccdSmrg 21354456fccdSmrg # Calculate the filename of the output object if compiler does 21364456fccdSmrg # not support -o with -c 21374456fccdSmrg if test "$compiler_c_o" = no; then 2138ff63a143Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 21394456fccdSmrg lockfile="$output_obj.lock" 21404456fccdSmrg else 21414456fccdSmrg output_obj= 21424456fccdSmrg need_locks=no 21434456fccdSmrg lockfile= 21444456fccdSmrg fi 21454456fccdSmrg 21464456fccdSmrg # Lock this critical section if it is needed 21474456fccdSmrg # We use this script file to make the link, it avoids creating a new file 21484456fccdSmrg if test "$need_locks" = yes; then 2149521070a0Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 2150521070a0Smrg func_echo "Waiting for $lockfile to be removed" 21514456fccdSmrg sleep 2 21524456fccdSmrg done 21534456fccdSmrg elif test "$need_locks" = warn; then 21544456fccdSmrg if test -f "$lockfile"; then 2155521070a0Smrg $ECHO "\ 21564456fccdSmrg*** ERROR, $lockfile exists and contains: 21574456fccdSmrg`cat $lockfile 2>/dev/null` 21584456fccdSmrg 21594456fccdSmrgThis indicates that another process is trying to use the same 21604456fccdSmrgtemporary object file, and libtool could not work around it because 21614456fccdSmrgyour compiler does not support \`-c' and \`-o' together. If you 21624456fccdSmrgrepeat this compilation, it may succeed, by chance, but you had better 21634456fccdSmrgavoid parallel builds (make -j) in this platform, or get a better 21644456fccdSmrgcompiler." 21654456fccdSmrg 2166521070a0Smrg $opt_dry_run || $RM $removelist 21674456fccdSmrg exit $EXIT_FAILURE 21684456fccdSmrg fi 21693e6c936aSmrg func_append removelist " $output_obj" 2170521070a0Smrg $ECHO "$srcfile" > "$lockfile" 21714456fccdSmrg fi 21724456fccdSmrg 2173521070a0Smrg $opt_dry_run || $RM $removelist 21743e6c936aSmrg func_append removelist " $lockfile" 2175521070a0Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 2176521070a0Smrg 21773e6c936aSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 21783e6c936aSmrg srcfile=$func_to_tool_file_result 2179521070a0Smrg func_quote_for_eval "$srcfile" 2180521070a0Smrg qsrcfile=$func_quote_for_eval_result 21814456fccdSmrg 21824456fccdSmrg # Only build a PIC object if we are building libtool libraries. 21834456fccdSmrg if test "$build_libtool_libs" = yes; then 21844456fccdSmrg # Without this assignment, base_compile gets emptied. 21854456fccdSmrg fbsd_hideous_sh_bug=$base_compile 21864456fccdSmrg 21874456fccdSmrg if test "$pic_mode" != no; then 21884456fccdSmrg command="$base_compile $qsrcfile $pic_flag" 21894456fccdSmrg else 21904456fccdSmrg # Don't build PIC code 21914456fccdSmrg command="$base_compile $qsrcfile" 21924456fccdSmrg fi 21934456fccdSmrg 2194521070a0Smrg func_mkdir_p "$xdir$objdir" 21954456fccdSmrg 21964456fccdSmrg if test -z "$output_obj"; then 21974456fccdSmrg # Place PIC objects in $objdir 21983e6c936aSmrg func_append command " -o $lobj" 21994456fccdSmrg fi 22004456fccdSmrg 2201521070a0Smrg func_show_eval_locale "$command" \ 2202521070a0Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 22034456fccdSmrg 22044456fccdSmrg if test "$need_locks" = warn && 22054456fccdSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2206521070a0Smrg $ECHO "\ 22074456fccdSmrg*** ERROR, $lockfile contains: 22084456fccdSmrg`cat $lockfile 2>/dev/null` 22094456fccdSmrg 22104456fccdSmrgbut it should contain: 22114456fccdSmrg$srcfile 22124456fccdSmrg 22134456fccdSmrgThis indicates that another process is trying to use the same 22144456fccdSmrgtemporary object file, and libtool could not work around it because 22154456fccdSmrgyour compiler does not support \`-c' and \`-o' together. If you 22164456fccdSmrgrepeat this compilation, it may succeed, by chance, but you had better 22174456fccdSmrgavoid parallel builds (make -j) in this platform, or get a better 22184456fccdSmrgcompiler." 22194456fccdSmrg 2220521070a0Smrg $opt_dry_run || $RM $removelist 22214456fccdSmrg exit $EXIT_FAILURE 22224456fccdSmrg fi 22234456fccdSmrg 22244456fccdSmrg # Just move the object if needed, then go on to compile the next one 22254456fccdSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 2226521070a0Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 2227521070a0Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 22284456fccdSmrg fi 22294456fccdSmrg 22304456fccdSmrg # Allow error messages only from the first compilation. 22314456fccdSmrg if test "$suppress_opt" = yes; then 2232521070a0Smrg suppress_output=' >/dev/null 2>&1' 22334456fccdSmrg fi 22344456fccdSmrg fi 22354456fccdSmrg 22364456fccdSmrg # Only build a position-dependent object if we build old libraries. 22374456fccdSmrg if test "$build_old_libs" = yes; then 22384456fccdSmrg if test "$pic_mode" != yes; then 22394456fccdSmrg # Don't build PIC code 2240521070a0Smrg command="$base_compile $qsrcfile$pie_flag" 22414456fccdSmrg else 22424456fccdSmrg command="$base_compile $qsrcfile $pic_flag" 22434456fccdSmrg fi 22444456fccdSmrg if test "$compiler_c_o" = yes; then 22453e6c936aSmrg func_append command " -o $obj" 22464456fccdSmrg fi 22474456fccdSmrg 22484456fccdSmrg # Suppress compiler output if we already did a PIC compilation. 22493e6c936aSmrg func_append command "$suppress_output" 2250521070a0Smrg func_show_eval_locale "$command" \ 2251521070a0Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 22524456fccdSmrg 22534456fccdSmrg if test "$need_locks" = warn && 22544456fccdSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2255521070a0Smrg $ECHO "\ 22564456fccdSmrg*** ERROR, $lockfile contains: 22574456fccdSmrg`cat $lockfile 2>/dev/null` 22584456fccdSmrg 22594456fccdSmrgbut it should contain: 22604456fccdSmrg$srcfile 22614456fccdSmrg 22624456fccdSmrgThis indicates that another process is trying to use the same 22634456fccdSmrgtemporary object file, and libtool could not work around it because 22644456fccdSmrgyour compiler does not support \`-c' and \`-o' together. If you 22654456fccdSmrgrepeat this compilation, it may succeed, by chance, but you had better 22664456fccdSmrgavoid parallel builds (make -j) in this platform, or get a better 22674456fccdSmrgcompiler." 22684456fccdSmrg 2269521070a0Smrg $opt_dry_run || $RM $removelist 22704456fccdSmrg exit $EXIT_FAILURE 22714456fccdSmrg fi 22724456fccdSmrg 22734456fccdSmrg # Just move the object if needed 22744456fccdSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 2275521070a0Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 2276521070a0Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 22774456fccdSmrg fi 22784456fccdSmrg fi 22794456fccdSmrg 2280521070a0Smrg $opt_dry_run || { 2281521070a0Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 22824456fccdSmrg 2283521070a0Smrg # Unlock the critical section if it was locked 2284521070a0Smrg if test "$need_locks" != no; then 2285521070a0Smrg removelist=$lockfile 2286521070a0Smrg $RM "$lockfile" 2287521070a0Smrg fi 2288521070a0Smrg } 22894456fccdSmrg 22904456fccdSmrg exit $EXIT_SUCCESS 2291521070a0Smrg} 22924456fccdSmrg 2293521070a0Smrg$opt_help || { 22943e6c936aSmrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 2295521070a0Smrg} 22964456fccdSmrg 2297521070a0Smrgfunc_mode_help () 2298521070a0Smrg{ 2299521070a0Smrg # We need to display help for each of the modes. 23003e6c936aSmrg case $opt_mode in 2301521070a0Smrg "") 2302521070a0Smrg # Generic help is extracted from the usage comments 2303521070a0Smrg # at the start of this file. 2304521070a0Smrg func_help 2305521070a0Smrg ;; 23064456fccdSmrg 2307521070a0Smrg clean) 2308521070a0Smrg $ECHO \ 2309521070a0Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 23104456fccdSmrg 2311521070a0SmrgRemove files from the build directory. 23124456fccdSmrg 2313521070a0SmrgRM is the name of the program to use to delete files associated with each FILE 2314521070a0Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2315521070a0Smrgto RM. 23164456fccdSmrg 2317521070a0SmrgIf FILE is a libtool library, object or program, all the files associated 2318521070a0Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 2319521070a0Smrg ;; 23204456fccdSmrg 2321521070a0Smrg compile) 2322521070a0Smrg $ECHO \ 2323521070a0Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 23244456fccdSmrg 2325521070a0SmrgCompile a source file into a libtool library object. 23264456fccdSmrg 2327521070a0SmrgThis mode accepts the following additional options: 23284456fccdSmrg 2329521070a0Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 2330521070a0Smrg -no-suppress do not suppress compiler output for multiple passes 2331ff63a143Smrg -prefer-pic try to build PIC objects only 2332ff63a143Smrg -prefer-non-pic try to build non-PIC objects only 2333521070a0Smrg -shared do not build a \`.o' file suitable for static linking 2334521070a0Smrg -static only build a \`.o' file suitable for static linking 2335ff63a143Smrg -Wc,FLAG pass FLAG directly to the compiler 23364456fccdSmrg 2337521070a0SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 2338521070a0Smrgfrom the given SOURCEFILE. 23394456fccdSmrg 2340521070a0SmrgThe output file name is determined by removing the directory component from 2341521070a0SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 2342521070a0Smrglibrary object suffix, \`.lo'." 2343521070a0Smrg ;; 23444456fccdSmrg 2345521070a0Smrg execute) 2346521070a0Smrg $ECHO \ 2347521070a0Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 23484456fccdSmrg 2349521070a0SmrgAutomatically set library path, then run a program. 23504456fccdSmrg 2351521070a0SmrgThis mode accepts the following additional options: 23524456fccdSmrg 2353521070a0Smrg -dlopen FILE add the directory containing FILE to the library path 23544456fccdSmrg 2355521070a0SmrgThis mode sets the library path environment variable according to \`-dlopen' 2356521070a0Smrgflags. 23574456fccdSmrg 2358521070a0SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 2359521070a0Smrginto their corresponding uninstalled binary, and any of their required library 2360521070a0Smrgdirectories are added to the library path. 23614456fccdSmrg 2362521070a0SmrgThen, COMMAND is executed, with ARGS as arguments." 2363521070a0Smrg ;; 23644456fccdSmrg 2365521070a0Smrg finish) 2366521070a0Smrg $ECHO \ 2367521070a0Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 23684456fccdSmrg 2369521070a0SmrgComplete the installation of libtool libraries. 23704456fccdSmrg 2371521070a0SmrgEach LIBDIR is a directory that contains libtool libraries. 23724456fccdSmrg 2373521070a0SmrgThe commands that this mode executes may require superuser privileges. Use 2374521070a0Smrgthe \`--dry-run' option if you just want to see what would be executed." 2375521070a0Smrg ;; 23764456fccdSmrg 2377521070a0Smrg install) 2378521070a0Smrg $ECHO \ 2379521070a0Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 23804456fccdSmrg 2381521070a0SmrgInstall executables or libraries. 23824456fccdSmrg 2383521070a0SmrgINSTALL-COMMAND is the installation command. The first component should be 2384521070a0Smrgeither the \`install' or \`cp' program. 23854456fccdSmrg 2386521070a0SmrgThe following components of INSTALL-COMMAND are treated specially: 23874456fccdSmrg 2388ff63a143Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 23894456fccdSmrg 2390521070a0SmrgThe rest of the components are interpreted as arguments to that command (only 2391521070a0SmrgBSD-compatible install options are recognized)." 2392521070a0Smrg ;; 23934456fccdSmrg 2394521070a0Smrg link) 2395521070a0Smrg $ECHO \ 2396521070a0Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 23974456fccdSmrg 2398521070a0SmrgLink object files or libraries together to form another library, or to 2399521070a0Smrgcreate an executable program. 24004456fccdSmrg 2401521070a0SmrgLINK-COMMAND is a command using the C compiler that you would use to create 2402521070a0Smrga program from several object files. 24034456fccdSmrg 2404521070a0SmrgThe following components of LINK-COMMAND are treated specially: 24054456fccdSmrg 2406521070a0Smrg -all-static do not do any dynamic linking at all 2407521070a0Smrg -avoid-version do not add a version suffix if possible 2408ff63a143Smrg -bindir BINDIR specify path to binaries directory (for systems where 2409ff63a143Smrg libraries must be found in the PATH setting at runtime) 2410521070a0Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 2411521070a0Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 2412521070a0Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 2413521070a0Smrg -export-symbols SYMFILE 2414521070a0Smrg try to export only the symbols listed in SYMFILE 2415521070a0Smrg -export-symbols-regex REGEX 2416521070a0Smrg try to export only the symbols matching REGEX 2417521070a0Smrg -LLIBDIR search LIBDIR for required installed libraries 2418521070a0Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 2419521070a0Smrg -module build a library that can dlopened 2420521070a0Smrg -no-fast-install disable the fast-install mode 2421521070a0Smrg -no-install link a not-installable executable 2422521070a0Smrg -no-undefined declare that a library does not refer to external symbols 2423521070a0Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 2424521070a0Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 2425521070a0Smrg -precious-files-regex REGEX 2426521070a0Smrg don't remove output files matching REGEX 2427521070a0Smrg -release RELEASE specify package release information 2428521070a0Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 2429521070a0Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 2430521070a0Smrg -shared only do dynamic linking of libtool libraries 2431521070a0Smrg -shrext SUFFIX override the standard shared library file extension 2432521070a0Smrg -static do not do any dynamic linking of uninstalled libtool libraries 2433521070a0Smrg -static-libtool-libs 2434521070a0Smrg do not do any dynamic linking of libtool libraries 2435521070a0Smrg -version-info CURRENT[:REVISION[:AGE]] 2436521070a0Smrg specify library version info [each variable defaults to 0] 2437521070a0Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 2438ff63a143Smrg -Wc,FLAG 2439ff63a143Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 2440ff63a143Smrg -Wl,FLAG 2441ff63a143Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 2442ff63a143Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 24434456fccdSmrg 2444521070a0SmrgAll other options (arguments beginning with \`-') are ignored. 24454456fccdSmrg 2446521070a0SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 2447521070a0Smrgtreated as uninstalled libtool libraries, other files are standard or library 2448521070a0Smrgobject files. 244942d69509Smrg 2450521070a0SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 2451521070a0Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 2452521070a0Smrgrequired, except when creating a convenience library. 24534456fccdSmrg 2454521070a0SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 2455521070a0Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 24564456fccdSmrg 2457521070a0SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 2458521070a0Smrgis created, otherwise an executable program is created." 24594456fccdSmrg ;; 24604456fccdSmrg 2461521070a0Smrg uninstall) 2462521070a0Smrg $ECHO \ 2463521070a0Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 24644456fccdSmrg 2465521070a0SmrgRemove libraries from an installation directory. 24664456fccdSmrg 2467521070a0SmrgRM is the name of the program to use to delete files associated with each FILE 2468521070a0Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2469521070a0Smrgto RM. 24704456fccdSmrg 2471521070a0SmrgIf FILE is a libtool library, all the files associated with it are deleted. 2472521070a0SmrgOtherwise, only FILE itself is deleted using RM." 2473521070a0Smrg ;; 24744456fccdSmrg 2475521070a0Smrg *) 24763e6c936aSmrg func_fatal_help "invalid operation mode \`$opt_mode'" 2477521070a0Smrg ;; 2478521070a0Smrg esac 24794456fccdSmrg 2480ff63a143Smrg echo 2481521070a0Smrg $ECHO "Try \`$progname --help' for more information about other modes." 2482521070a0Smrg} 24834456fccdSmrg 2484ff63a143Smrg# Now that we've collected a possible --mode arg, show help if necessary 2485ff63a143Smrgif $opt_help; then 2486ff63a143Smrg if test "$opt_help" = :; then 2487ff63a143Smrg func_mode_help 2488ff63a143Smrg else 2489ff63a143Smrg { 2490ff63a143Smrg func_help noexit 24913e6c936aSmrg for opt_mode in compile link execute install finish uninstall clean; do 2492ff63a143Smrg func_mode_help 2493ff63a143Smrg done 2494ff63a143Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 2495ff63a143Smrg { 2496ff63a143Smrg func_help noexit 24973e6c936aSmrg for opt_mode in compile link execute install finish uninstall clean; do 2498ff63a143Smrg echo 2499ff63a143Smrg func_mode_help 2500ff63a143Smrg done 2501ff63a143Smrg } | 2502ff63a143Smrg sed '1d 2503ff63a143Smrg /^When reporting/,/^Report/{ 2504ff63a143Smrg H 2505ff63a143Smrg d 2506ff63a143Smrg } 2507ff63a143Smrg $x 2508ff63a143Smrg /information about other modes/d 2509ff63a143Smrg /more detailed .*MODE/d 2510ff63a143Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 2511ff63a143Smrg fi 2512ff63a143Smrg exit $? 2513ff63a143Smrgfi 25144456fccdSmrg 25154456fccdSmrg 2516521070a0Smrg# func_mode_execute arg... 2517521070a0Smrgfunc_mode_execute () 2518521070a0Smrg{ 2519521070a0Smrg $opt_debug 2520521070a0Smrg # The first argument is the command name. 2521521070a0Smrg cmd="$nonopt" 2522521070a0Smrg test -z "$cmd" && \ 2523521070a0Smrg func_fatal_help "you must specify a COMMAND" 25244456fccdSmrg 2525521070a0Smrg # Handle -dlopen flags immediately. 25263e6c936aSmrg for file in $opt_dlopen; do 2527521070a0Smrg test -f "$file" \ 2528521070a0Smrg || func_fatal_help "\`$file' is not a file" 25294456fccdSmrg 2530521070a0Smrg dir= 2531521070a0Smrg case $file in 2532521070a0Smrg *.la) 25333e6c936aSmrg func_resolve_sysroot "$file" 25343e6c936aSmrg file=$func_resolve_sysroot_result 25353e6c936aSmrg 2536521070a0Smrg # Check to see that this really is a libtool archive. 2537521070a0Smrg func_lalib_unsafe_p "$file" \ 2538521070a0Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 25394456fccdSmrg 2540521070a0Smrg # Read the libtool library. 2541521070a0Smrg dlname= 2542521070a0Smrg library_names= 2543521070a0Smrg func_source "$file" 25444456fccdSmrg 2545521070a0Smrg # Skip this library if it cannot be dlopened. 2546521070a0Smrg if test -z "$dlname"; then 2547521070a0Smrg # Warn if it was a shared library. 2548521070a0Smrg test -n "$library_names" && \ 2549521070a0Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 2550521070a0Smrg continue 2551521070a0Smrg fi 25524456fccdSmrg 2553521070a0Smrg func_dirname "$file" "" "." 2554521070a0Smrg dir="$func_dirname_result" 25554456fccdSmrg 2556521070a0Smrg if test -f "$dir/$objdir/$dlname"; then 25573e6c936aSmrg func_append dir "/$objdir" 2558521070a0Smrg else 2559521070a0Smrg if test ! -f "$dir/$dlname"; then 2560521070a0Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 2561521070a0Smrg fi 2562521070a0Smrg fi 25634456fccdSmrg ;; 25644456fccdSmrg 2565521070a0Smrg *.lo) 2566521070a0Smrg # Just add the directory containing the .lo file. 2567521070a0Smrg func_dirname "$file" "" "." 2568521070a0Smrg dir="$func_dirname_result" 25694456fccdSmrg ;; 25704456fccdSmrg 2571521070a0Smrg *) 2572521070a0Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 25734456fccdSmrg continue 25744456fccdSmrg ;; 2575521070a0Smrg esac 25764456fccdSmrg 2577521070a0Smrg # Get the absolute pathname. 2578521070a0Smrg absdir=`cd "$dir" && pwd` 2579521070a0Smrg test -n "$absdir" && dir="$absdir" 25804456fccdSmrg 2581521070a0Smrg # Now add the directory to shlibpath_var. 2582521070a0Smrg if eval "test -z \"\$$shlibpath_var\""; then 2583521070a0Smrg eval "$shlibpath_var=\"\$dir\"" 2584521070a0Smrg else 2585521070a0Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 2586521070a0Smrg fi 2587521070a0Smrg done 25884456fccdSmrg 2589521070a0Smrg # This variable tells wrapper scripts just to set shlibpath_var 2590521070a0Smrg # rather than running their programs. 2591521070a0Smrg libtool_execute_magic="$magic" 25924456fccdSmrg 2593521070a0Smrg # Check if any of the arguments is a wrapper script. 2594521070a0Smrg args= 2595521070a0Smrg for file 2596521070a0Smrg do 2597521070a0Smrg case $file in 2598ff63a143Smrg -* | *.la | *.lo ) ;; 2599521070a0Smrg *) 2600521070a0Smrg # Do a test to see if this is really a libtool program. 2601521070a0Smrg if func_ltwrapper_script_p "$file"; then 2602521070a0Smrg func_source "$file" 2603521070a0Smrg # Transform arg to wrapped name. 2604521070a0Smrg file="$progdir/$program" 2605521070a0Smrg elif func_ltwrapper_executable_p "$file"; then 2606521070a0Smrg func_ltwrapper_scriptname "$file" 2607521070a0Smrg func_source "$func_ltwrapper_scriptname_result" 2608521070a0Smrg # Transform arg to wrapped name. 2609521070a0Smrg file="$progdir/$program" 2610521070a0Smrg fi 2611521070a0Smrg ;; 2612521070a0Smrg esac 2613521070a0Smrg # Quote arguments (to preserve shell metacharacters). 26143e6c936aSmrg func_append_quoted args "$file" 2615521070a0Smrg done 26164456fccdSmrg 2617521070a0Smrg if test "X$opt_dry_run" = Xfalse; then 2618521070a0Smrg if test -n "$shlibpath_var"; then 2619521070a0Smrg # Export the shlibpath_var. 2620521070a0Smrg eval "export $shlibpath_var" 2621521070a0Smrg fi 26224456fccdSmrg 2623521070a0Smrg # Restore saved environment variables 2624521070a0Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 2625521070a0Smrg do 2626521070a0Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 2627521070a0Smrg $lt_var=\$save_$lt_var; export $lt_var 26284456fccdSmrg else 2629521070a0Smrg $lt_unset $lt_var 2630521070a0Smrg fi" 2631521070a0Smrg done 26324456fccdSmrg 2633521070a0Smrg # Now prepare to actually exec the command. 2634521070a0Smrg exec_cmd="\$cmd$args" 2635521070a0Smrg else 2636521070a0Smrg # Display what would be done. 2637521070a0Smrg if test -n "$shlibpath_var"; then 2638521070a0Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 2639ff63a143Smrg echo "export $shlibpath_var" 2640521070a0Smrg fi 2641521070a0Smrg $ECHO "$cmd$args" 2642521070a0Smrg exit $EXIT_SUCCESS 2643521070a0Smrg fi 2644521070a0Smrg} 26454456fccdSmrg 26463e6c936aSmrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 26474456fccdSmrg 26484456fccdSmrg 2649521070a0Smrg# func_mode_finish arg... 2650521070a0Smrgfunc_mode_finish () 2651521070a0Smrg{ 2652521070a0Smrg $opt_debug 26533e6c936aSmrg libs= 26543e6c936aSmrg libdirs= 2655521070a0Smrg admincmds= 26564456fccdSmrg 26573e6c936aSmrg for opt in "$nonopt" ${1+"$@"} 26583e6c936aSmrg do 26593e6c936aSmrg if test -d "$opt"; then 26603e6c936aSmrg func_append libdirs " $opt" 26613e6c936aSmrg 26623e6c936aSmrg elif test -f "$opt"; then 26633e6c936aSmrg if func_lalib_unsafe_p "$opt"; then 26643e6c936aSmrg func_append libs " $opt" 26653e6c936aSmrg else 26663e6c936aSmrg func_warning "\`$opt' is not a valid libtool archive" 26673e6c936aSmrg fi 26683e6c936aSmrg 26693e6c936aSmrg else 26703e6c936aSmrg func_fatal_error "invalid argument \`$opt'" 26713e6c936aSmrg fi 26723e6c936aSmrg done 26733e6c936aSmrg 26743e6c936aSmrg if test -n "$libs"; then 26753e6c936aSmrg if test -n "$lt_sysroot"; then 26763e6c936aSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 26773e6c936aSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 26783e6c936aSmrg else 26793e6c936aSmrg sysroot_cmd= 26803e6c936aSmrg fi 26813e6c936aSmrg 26823e6c936aSmrg # Remove sysroot references 26833e6c936aSmrg if $opt_dry_run; then 26843e6c936aSmrg for lib in $libs; do 26853e6c936aSmrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 26863e6c936aSmrg done 26873e6c936aSmrg else 26883e6c936aSmrg tmpdir=`func_mktempdir` 26893e6c936aSmrg for lib in $libs; do 26903e6c936aSmrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 26913e6c936aSmrg > $tmpdir/tmp-la 26923e6c936aSmrg mv -f $tmpdir/tmp-la $lib 26933e6c936aSmrg done 26943e6c936aSmrg ${RM}r "$tmpdir" 26953e6c936aSmrg fi 26963e6c936aSmrg fi 26974456fccdSmrg 26983e6c936aSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2699521070a0Smrg for libdir in $libdirs; do 2700521070a0Smrg if test -n "$finish_cmds"; then 2701521070a0Smrg # Do each command in the finish commands. 2702521070a0Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 2703521070a0Smrg'"$cmd"'"' 27044456fccdSmrg fi 2705521070a0Smrg if test -n "$finish_eval"; then 2706521070a0Smrg # Do the single finish_eval. 2707521070a0Smrg eval cmds=\"$finish_eval\" 27083e6c936aSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 2709521070a0Smrg $cmds" 2710521070a0Smrg fi 2711521070a0Smrg done 2712521070a0Smrg fi 27134456fccdSmrg 2714521070a0Smrg # Exit here if they wanted silent mode. 2715521070a0Smrg $opt_silent && exit $EXIT_SUCCESS 27164456fccdSmrg 27173e6c936aSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 27183e6c936aSmrg echo "----------------------------------------------------------------------" 27193e6c936aSmrg echo "Libraries have been installed in:" 27203e6c936aSmrg for libdir in $libdirs; do 27213e6c936aSmrg $ECHO " $libdir" 27223e6c936aSmrg done 27233e6c936aSmrg echo 27243e6c936aSmrg echo "If you ever happen to want to link against installed libraries" 27253e6c936aSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 27263e6c936aSmrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 27273e6c936aSmrg echo "flag during linking and do at least one of the following:" 27283e6c936aSmrg if test -n "$shlibpath_var"; then 27293e6c936aSmrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 27303e6c936aSmrg echo " during execution" 27313e6c936aSmrg fi 27323e6c936aSmrg if test -n "$runpath_var"; then 27333e6c936aSmrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 27343e6c936aSmrg echo " during linking" 27353e6c936aSmrg fi 27363e6c936aSmrg if test -n "$hardcode_libdir_flag_spec"; then 27373e6c936aSmrg libdir=LIBDIR 27383e6c936aSmrg eval flag=\"$hardcode_libdir_flag_spec\" 2739521070a0Smrg 27403e6c936aSmrg $ECHO " - use the \`$flag' linker flag" 27413e6c936aSmrg fi 27423e6c936aSmrg if test -n "$admincmds"; then 27433e6c936aSmrg $ECHO " - have your system administrator run these commands:$admincmds" 27443e6c936aSmrg fi 27453e6c936aSmrg if test -f /etc/ld.so.conf; then 27463e6c936aSmrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 27473e6c936aSmrg fi 27483e6c936aSmrg echo 2749521070a0Smrg 27503e6c936aSmrg echo "See any operating system documentation about shared libraries for" 27513e6c936aSmrg case $host in 27523e6c936aSmrg solaris2.[6789]|solaris2.1[0-9]) 27533e6c936aSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 27543e6c936aSmrg echo "pages." 27553e6c936aSmrg ;; 27563e6c936aSmrg *) 27573e6c936aSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 27583e6c936aSmrg ;; 27593e6c936aSmrg esac 27603e6c936aSmrg echo "----------------------------------------------------------------------" 27613e6c936aSmrg fi 2762521070a0Smrg exit $EXIT_SUCCESS 2763521070a0Smrg} 2764521070a0Smrg 27653e6c936aSmrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 2766521070a0Smrg 2767521070a0Smrg 2768521070a0Smrg# func_mode_install arg... 2769521070a0Smrgfunc_mode_install () 2770521070a0Smrg{ 2771521070a0Smrg $opt_debug 2772521070a0Smrg # There may be an optional sh(1) argument at the beginning of 2773521070a0Smrg # install_prog (especially on Windows NT). 2774521070a0Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 2775521070a0Smrg # Allow the use of GNU shtool's install command. 2776ff63a143Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 2777521070a0Smrg # Aesthetically quote it. 2778521070a0Smrg func_quote_for_eval "$nonopt" 2779521070a0Smrg install_prog="$func_quote_for_eval_result " 2780521070a0Smrg arg=$1 2781521070a0Smrg shift 2782521070a0Smrg else 2783521070a0Smrg install_prog= 2784521070a0Smrg arg=$nonopt 2785521070a0Smrg fi 2786521070a0Smrg 2787521070a0Smrg # The real first argument should be the name of the installation program. 2788521070a0Smrg # Aesthetically quote it. 2789521070a0Smrg func_quote_for_eval "$arg" 27903e6c936aSmrg func_append install_prog "$func_quote_for_eval_result" 2791ff63a143Smrg install_shared_prog=$install_prog 2792ff63a143Smrg case " $install_prog " in 2793ff63a143Smrg *[\\\ /]cp\ *) install_cp=: ;; 2794ff63a143Smrg *) install_cp=false ;; 2795ff63a143Smrg esac 2796521070a0Smrg 2797521070a0Smrg # We need to accept at least all the BSD install flags. 2798521070a0Smrg dest= 2799521070a0Smrg files= 2800521070a0Smrg opts= 2801521070a0Smrg prev= 2802521070a0Smrg install_type= 2803521070a0Smrg isdir=no 2804521070a0Smrg stripme= 2805ff63a143Smrg no_mode=: 2806521070a0Smrg for arg 2807521070a0Smrg do 2808ff63a143Smrg arg2= 2809521070a0Smrg if test -n "$dest"; then 28103e6c936aSmrg func_append files " $dest" 2811521070a0Smrg dest=$arg 2812521070a0Smrg continue 2813521070a0Smrg fi 2814521070a0Smrg 2815521070a0Smrg case $arg in 2816521070a0Smrg -d) isdir=yes ;; 2817521070a0Smrg -f) 2818ff63a143Smrg if $install_cp; then :; else 2819ff63a143Smrg prev=$arg 2820ff63a143Smrg fi 2821521070a0Smrg ;; 2822521070a0Smrg -g | -m | -o) 2823521070a0Smrg prev=$arg 2824521070a0Smrg ;; 2825521070a0Smrg -s) 2826521070a0Smrg stripme=" -s" 2827521070a0Smrg continue 2828521070a0Smrg ;; 2829521070a0Smrg -*) 2830521070a0Smrg ;; 2831521070a0Smrg *) 2832521070a0Smrg # If the previous option needed an argument, then skip it. 2833521070a0Smrg if test -n "$prev"; then 2834ff63a143Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 2835ff63a143Smrg arg2=$install_override_mode 2836ff63a143Smrg no_mode=false 2837ff63a143Smrg fi 28384456fccdSmrg prev= 28394456fccdSmrg else 2840521070a0Smrg dest=$arg 2841521070a0Smrg continue 28424456fccdSmrg fi 28434456fccdSmrg ;; 2844521070a0Smrg esac 28454456fccdSmrg 2846521070a0Smrg # Aesthetically quote the argument. 2847521070a0Smrg func_quote_for_eval "$arg" 28483e6c936aSmrg func_append install_prog " $func_quote_for_eval_result" 2849ff63a143Smrg if test -n "$arg2"; then 2850ff63a143Smrg func_quote_for_eval "$arg2" 2851ff63a143Smrg fi 28523e6c936aSmrg func_append install_shared_prog " $func_quote_for_eval_result" 2853521070a0Smrg done 28544456fccdSmrg 2855521070a0Smrg test -z "$install_prog" && \ 2856521070a0Smrg func_fatal_help "you must specify an install program" 28574456fccdSmrg 2858521070a0Smrg test -n "$prev" && \ 2859521070a0Smrg func_fatal_help "the \`$prev' option requires an argument" 28604456fccdSmrg 2861ff63a143Smrg if test -n "$install_override_mode" && $no_mode; then 2862ff63a143Smrg if $install_cp; then :; else 2863ff63a143Smrg func_quote_for_eval "$install_override_mode" 28643e6c936aSmrg func_append install_shared_prog " -m $func_quote_for_eval_result" 2865ff63a143Smrg fi 2866ff63a143Smrg fi 2867ff63a143Smrg 2868521070a0Smrg if test -z "$files"; then 2869521070a0Smrg if test -z "$dest"; then 2870521070a0Smrg func_fatal_help "no file or destination specified" 2871521070a0Smrg else 2872521070a0Smrg func_fatal_help "you must specify a destination" 2873521070a0Smrg fi 28744456fccdSmrg fi 28754456fccdSmrg 2876521070a0Smrg # Strip any trailing slash from the destination. 2877521070a0Smrg func_stripname '' '/' "$dest" 2878521070a0Smrg dest=$func_stripname_result 28794456fccdSmrg 2880521070a0Smrg # Check to see that the destination is a directory. 2881521070a0Smrg test -d "$dest" && isdir=yes 2882521070a0Smrg if test "$isdir" = yes; then 2883521070a0Smrg destdir="$dest" 2884521070a0Smrg destname= 28854456fccdSmrg else 2886521070a0Smrg func_dirname_and_basename "$dest" "" "." 2887521070a0Smrg destdir="$func_dirname_result" 2888521070a0Smrg destname="$func_basename_result" 28894456fccdSmrg 2890521070a0Smrg # Not a directory, so check to see that there is only one file specified. 2891521070a0Smrg set dummy $files; shift 2892521070a0Smrg test "$#" -gt 1 && \ 2893521070a0Smrg func_fatal_help "\`$dest' is not a directory" 28944456fccdSmrg fi 2895521070a0Smrg case $destdir in 2896521070a0Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 28974456fccdSmrg *) 2898521070a0Smrg for file in $files; do 2899521070a0Smrg case $file in 2900521070a0Smrg *.lo) ;; 2901521070a0Smrg *) 2902521070a0Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 2903521070a0Smrg ;; 2904521070a0Smrg esac 2905521070a0Smrg done 29064456fccdSmrg ;; 29074456fccdSmrg esac 29084456fccdSmrg 2909521070a0Smrg # This variable tells wrapper scripts just to set variables rather 2910521070a0Smrg # than running their programs. 2911521070a0Smrg libtool_install_magic="$magic" 29124456fccdSmrg 2913521070a0Smrg staticlibs= 2914521070a0Smrg future_libdirs= 2915521070a0Smrg current_libdirs= 2916521070a0Smrg for file in $files; do 29174456fccdSmrg 2918521070a0Smrg # Do each installation. 2919521070a0Smrg case $file in 2920521070a0Smrg *.$libext) 2921521070a0Smrg # Do the static libraries later. 29223e6c936aSmrg func_append staticlibs " $file" 2923521070a0Smrg ;; 2924521070a0Smrg 2925521070a0Smrg *.la) 29263e6c936aSmrg func_resolve_sysroot "$file" 29273e6c936aSmrg file=$func_resolve_sysroot_result 29283e6c936aSmrg 2929521070a0Smrg # Check to see that this really is a libtool archive. 2930521070a0Smrg func_lalib_unsafe_p "$file" \ 2931521070a0Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 2932521070a0Smrg 2933521070a0Smrg library_names= 2934521070a0Smrg old_library= 2935521070a0Smrg relink_command= 2936521070a0Smrg func_source "$file" 2937521070a0Smrg 2938521070a0Smrg # Add the libdir to current_libdirs if it is the destination. 2939521070a0Smrg if test "X$destdir" = "X$libdir"; then 2940521070a0Smrg case "$current_libdirs " in 2941521070a0Smrg *" $libdir "*) ;; 29423e6c936aSmrg *) func_append current_libdirs " $libdir" ;; 29434456fccdSmrg esac 2944521070a0Smrg else 2945521070a0Smrg # Note the libdir as a future libdir. 2946521070a0Smrg case "$future_libdirs " in 2947521070a0Smrg *" $libdir "*) ;; 29483e6c936aSmrg *) func_append future_libdirs " $libdir" ;; 2949521070a0Smrg esac 2950521070a0Smrg fi 29514456fccdSmrg 2952521070a0Smrg func_dirname "$file" "/" "" 2953521070a0Smrg dir="$func_dirname_result" 29543e6c936aSmrg func_append dir "$objdir" 2955521070a0Smrg 2956521070a0Smrg if test -n "$relink_command"; then 2957521070a0Smrg # Determine the prefix the user has applied to our future dir. 2958ff63a143Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 2959521070a0Smrg 2960521070a0Smrg # Don't allow the user to place us outside of our expected 2961521070a0Smrg # location b/c this prevents finding dependent libraries that 2962521070a0Smrg # are installed to the same prefix. 2963521070a0Smrg # At present, this check doesn't affect windows .dll's that 2964521070a0Smrg # are installed into $libdir/../bin (currently, that works fine) 2965521070a0Smrg # but it's something to keep an eye on. 2966521070a0Smrg test "$inst_prefix_dir" = "$destdir" && \ 2967521070a0Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 2968521070a0Smrg 2969521070a0Smrg if test -n "$inst_prefix_dir"; then 2970521070a0Smrg # Stick the inst_prefix_dir data into the link command. 2971ff63a143Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 2972521070a0Smrg else 2973ff63a143Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 2974521070a0Smrg fi 2975521070a0Smrg 2976521070a0Smrg func_warning "relinking \`$file'" 2977521070a0Smrg func_show_eval "$relink_command" \ 2978521070a0Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 2979521070a0Smrg fi 2980521070a0Smrg 2981521070a0Smrg # See the names of the shared library. 2982521070a0Smrg set dummy $library_names; shift 2983521070a0Smrg if test -n "$1"; then 2984521070a0Smrg realname="$1" 2985521070a0Smrg shift 2986521070a0Smrg 2987521070a0Smrg srcname="$realname" 2988521070a0Smrg test -n "$relink_command" && srcname="$realname"T 2989521070a0Smrg 2990521070a0Smrg # Install the shared library and build the symlinks. 2991ff63a143Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 2992521070a0Smrg 'exit $?' 2993521070a0Smrg tstripme="$stripme" 2994521070a0Smrg case $host_os in 2995521070a0Smrg cygwin* | mingw* | pw32* | cegcc*) 2996521070a0Smrg case $realname in 2997521070a0Smrg *.dll.a) 2998521070a0Smrg tstripme="" 2999521070a0Smrg ;; 3000521070a0Smrg esac 30014456fccdSmrg ;; 30024456fccdSmrg esac 3003521070a0Smrg if test -n "$tstripme" && test -n "$striplib"; then 3004521070a0Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 30054456fccdSmrg fi 3006521070a0Smrg 3007521070a0Smrg if test "$#" -gt 0; then 3008521070a0Smrg # Delete the old symlinks, and create new ones. 3009521070a0Smrg # Try `ln -sf' first, because the `ln' binary might depend on 3010521070a0Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 3011521070a0Smrg # so we also need to try rm && ln -s. 3012521070a0Smrg for linkname 3013521070a0Smrg do 3014521070a0Smrg test "$linkname" != "$realname" \ 3015521070a0Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 30164456fccdSmrg done 30174456fccdSmrg fi 30184456fccdSmrg 3019521070a0Smrg # Do each command in the postinstall commands. 3020521070a0Smrg lib="$destdir/$realname" 3021521070a0Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 30224456fccdSmrg fi 30234456fccdSmrg 3024521070a0Smrg # Install the pseudo-library for information purposes. 3025521070a0Smrg func_basename "$file" 3026521070a0Smrg name="$func_basename_result" 3027521070a0Smrg instname="$dir/$name"i 3028521070a0Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 30294456fccdSmrg 3030521070a0Smrg # Maybe install the static library, too. 30313e6c936aSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 3032521070a0Smrg ;; 30334456fccdSmrg 3034521070a0Smrg *.lo) 3035521070a0Smrg # Install (i.e. copy) a libtool object. 30364456fccdSmrg 3037521070a0Smrg # Figure out destination file name, if it wasn't already specified. 3038521070a0Smrg if test -n "$destname"; then 3039521070a0Smrg destfile="$destdir/$destname" 3040521070a0Smrg else 3041521070a0Smrg func_basename "$file" 3042521070a0Smrg destfile="$func_basename_result" 3043521070a0Smrg destfile="$destdir/$destfile" 30444456fccdSmrg fi 30454456fccdSmrg 3046521070a0Smrg # Deduce the name of the destination old-style object file. 3047521070a0Smrg case $destfile in 3048521070a0Smrg *.lo) 3049521070a0Smrg func_lo2o "$destfile" 3050521070a0Smrg staticdest=$func_lo2o_result 3051521070a0Smrg ;; 3052521070a0Smrg *.$objext) 3053521070a0Smrg staticdest="$destfile" 3054521070a0Smrg destfile= 3055521070a0Smrg ;; 3056521070a0Smrg *) 3057521070a0Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 3058521070a0Smrg ;; 3059521070a0Smrg esac 30604456fccdSmrg 3061521070a0Smrg # Install the libtool object if requested. 3062521070a0Smrg test -n "$destfile" && \ 3063521070a0Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 30644456fccdSmrg 3065521070a0Smrg # Install the old object if enabled. 3066521070a0Smrg if test "$build_old_libs" = yes; then 3067521070a0Smrg # Deduce the name of the old-style object file. 3068521070a0Smrg func_lo2o "$file" 3069521070a0Smrg staticobj=$func_lo2o_result 3070521070a0Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 30714456fccdSmrg fi 3072521070a0Smrg exit $EXIT_SUCCESS 3073521070a0Smrg ;; 30744456fccdSmrg 3075521070a0Smrg *) 3076521070a0Smrg # Figure out destination file name, if it wasn't already specified. 3077521070a0Smrg if test -n "$destname"; then 3078521070a0Smrg destfile="$destdir/$destname" 3079521070a0Smrg else 3080521070a0Smrg func_basename "$file" 3081521070a0Smrg destfile="$func_basename_result" 3082521070a0Smrg destfile="$destdir/$destfile" 3083521070a0Smrg fi 30844456fccdSmrg 3085521070a0Smrg # If the file is missing, and there is a .exe on the end, strip it 3086521070a0Smrg # because it is most likely a libtool script we actually want to 3087521070a0Smrg # install 3088521070a0Smrg stripped_ext="" 3089521070a0Smrg case $file in 3090521070a0Smrg *.exe) 3091521070a0Smrg if test ! -f "$file"; then 3092521070a0Smrg func_stripname '' '.exe' "$file" 3093521070a0Smrg file=$func_stripname_result 3094521070a0Smrg stripped_ext=".exe" 3095521070a0Smrg fi 3096521070a0Smrg ;; 3097521070a0Smrg esac 3098521070a0Smrg 3099521070a0Smrg # Do a test to see if this is really a libtool program. 3100521070a0Smrg case $host in 3101521070a0Smrg *cygwin* | *mingw*) 3102521070a0Smrg if func_ltwrapper_executable_p "$file"; then 3103521070a0Smrg func_ltwrapper_scriptname "$file" 3104521070a0Smrg wrapper=$func_ltwrapper_scriptname_result 3105521070a0Smrg else 3106521070a0Smrg func_stripname '' '.exe' "$file" 3107521070a0Smrg wrapper=$func_stripname_result 3108521070a0Smrg fi 3109521070a0Smrg ;; 31104456fccdSmrg *) 3111521070a0Smrg wrapper=$file 3112521070a0Smrg ;; 3113521070a0Smrg esac 3114521070a0Smrg if func_ltwrapper_script_p "$wrapper"; then 3115521070a0Smrg notinst_deplibs= 3116521070a0Smrg relink_command= 3117521070a0Smrg 3118521070a0Smrg func_source "$wrapper" 3119521070a0Smrg 3120521070a0Smrg # Check the variables that should have been set. 3121521070a0Smrg test -z "$generated_by_libtool_version" && \ 3122521070a0Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 3123521070a0Smrg 3124521070a0Smrg finalize=yes 3125521070a0Smrg for lib in $notinst_deplibs; do 3126521070a0Smrg # Check to see that each library is installed. 3127521070a0Smrg libdir= 3128521070a0Smrg if test -f "$lib"; then 3129521070a0Smrg func_source "$lib" 3130521070a0Smrg fi 3131ff63a143Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 3132521070a0Smrg if test -n "$libdir" && test ! -f "$libfile"; then 3133521070a0Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 3134521070a0Smrg finalize=no 3135521070a0Smrg fi 3136521070a0Smrg done 3137521070a0Smrg 3138521070a0Smrg relink_command= 3139521070a0Smrg func_source "$wrapper" 3140521070a0Smrg 3141521070a0Smrg outputname= 3142521070a0Smrg if test "$fast_install" = no && test -n "$relink_command"; then 3143521070a0Smrg $opt_dry_run || { 3144521070a0Smrg if test "$finalize" = yes; then 3145521070a0Smrg tmpdir=`func_mktempdir` 3146521070a0Smrg func_basename "$file$stripped_ext" 3147521070a0Smrg file="$func_basename_result" 3148521070a0Smrg outputname="$tmpdir/$file" 3149521070a0Smrg # Replace the output file specification. 3150ff63a143Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 3151521070a0Smrg 3152521070a0Smrg $opt_silent || { 3153521070a0Smrg func_quote_for_expand "$relink_command" 3154521070a0Smrg eval "func_echo $func_quote_for_expand_result" 3155521070a0Smrg } 3156521070a0Smrg if eval "$relink_command"; then : 3157521070a0Smrg else 3158521070a0Smrg func_error "error: relink \`$file' with the above command before installing it" 3159521070a0Smrg $opt_dry_run || ${RM}r "$tmpdir" 3160521070a0Smrg continue 3161521070a0Smrg fi 3162521070a0Smrg file="$outputname" 3163521070a0Smrg else 3164521070a0Smrg func_warning "cannot relink \`$file'" 3165521070a0Smrg fi 3166521070a0Smrg } 3167521070a0Smrg else 3168521070a0Smrg # Install the binary that we compiled earlier. 3169ff63a143Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 31704456fccdSmrg fi 3171521070a0Smrg fi 3172521070a0Smrg 3173521070a0Smrg # remove .exe since cygwin /usr/bin/install will append another 3174521070a0Smrg # one anyway 3175521070a0Smrg case $install_prog,$host in 3176521070a0Smrg */usr/bin/install*,*cygwin*) 3177521070a0Smrg case $file:$destfile in 3178521070a0Smrg *.exe:*.exe) 3179521070a0Smrg # this is ok 3180521070a0Smrg ;; 3181521070a0Smrg *.exe:*) 3182521070a0Smrg destfile=$destfile.exe 3183521070a0Smrg ;; 3184521070a0Smrg *:*.exe) 3185521070a0Smrg func_stripname '' '.exe' "$destfile" 3186521070a0Smrg destfile=$func_stripname_result 3187521070a0Smrg ;; 3188521070a0Smrg esac 31894456fccdSmrg ;; 31904456fccdSmrg esac 3191521070a0Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 3192521070a0Smrg $opt_dry_run || if test -n "$outputname"; then 3193521070a0Smrg ${RM}r "$tmpdir" 3194521070a0Smrg fi 3195521070a0Smrg ;; 3196521070a0Smrg esac 3197521070a0Smrg done 31984456fccdSmrg 3199521070a0Smrg for file in $staticlibs; do 3200521070a0Smrg func_basename "$file" 3201521070a0Smrg name="$func_basename_result" 3202521070a0Smrg 3203521070a0Smrg # Set up the ranlib parameters. 3204521070a0Smrg oldlib="$destdir/$name" 32053e6c936aSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 32063e6c936aSmrg tool_oldlib=$func_to_tool_file_result 3207521070a0Smrg 3208521070a0Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 3209521070a0Smrg 3210521070a0Smrg if test -n "$stripme" && test -n "$old_striplib"; then 32113e6c936aSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 3212521070a0Smrg fi 3213521070a0Smrg 3214521070a0Smrg # Do each command in the postinstall commands. 3215521070a0Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 3216521070a0Smrg done 3217521070a0Smrg 3218521070a0Smrg test -n "$future_libdirs" && \ 3219521070a0Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 3220521070a0Smrg 3221521070a0Smrg if test -n "$current_libdirs"; then 3222521070a0Smrg # Maybe just do a dry run. 3223521070a0Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 3224521070a0Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 3225521070a0Smrg else 3226521070a0Smrg exit $EXIT_SUCCESS 3227521070a0Smrg fi 3228521070a0Smrg} 3229521070a0Smrg 32303e6c936aSmrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 3231521070a0Smrg 3232521070a0Smrg 3233521070a0Smrg# func_generate_dlsyms outputname originator pic_p 3234521070a0Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 3235521070a0Smrg# a dlpreopen symbol table. 3236521070a0Smrgfunc_generate_dlsyms () 3237521070a0Smrg{ 3238521070a0Smrg $opt_debug 3239521070a0Smrg my_outputname="$1" 3240521070a0Smrg my_originator="$2" 3241521070a0Smrg my_pic_p="${3-no}" 3242521070a0Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 3243521070a0Smrg my_dlsyms= 3244521070a0Smrg 3245521070a0Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 3246521070a0Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 3247521070a0Smrg my_dlsyms="${my_outputname}S.c" 3248521070a0Smrg else 3249521070a0Smrg func_error "not configured to extract global symbols from dlpreopened files" 3250521070a0Smrg fi 3251521070a0Smrg fi 3252521070a0Smrg 3253521070a0Smrg if test -n "$my_dlsyms"; then 3254521070a0Smrg case $my_dlsyms in 3255521070a0Smrg "") ;; 3256521070a0Smrg *.c) 3257521070a0Smrg # Discover the nlist of each of the dlfiles. 3258521070a0Smrg nlist="$output_objdir/${my_outputname}.nm" 3259521070a0Smrg 3260521070a0Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 3261521070a0Smrg 3262521070a0Smrg # Parse the name list into a source file. 3263521070a0Smrg func_verbose "creating $output_objdir/$my_dlsyms" 3264521070a0Smrg 3265521070a0Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 3266521070a0Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 3267521070a0Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 3268521070a0Smrg 3269521070a0Smrg#ifdef __cplusplus 3270521070a0Smrgextern \"C\" { 3271521070a0Smrg#endif 3272521070a0Smrg 3273ff63a143Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 3274ff63a143Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 3275ff63a143Smrg#endif 3276ff63a143Smrg 32773e6c936aSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 32783e6c936aSmrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 32793e6c936aSmrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 32803e6c936aSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 32813e6c936aSmrg# define LT_DLSYM_CONST 32823e6c936aSmrg#elif defined(__osf__) 32833e6c936aSmrg/* This system does not cope well with relocations in const data. */ 32843e6c936aSmrg# define LT_DLSYM_CONST 32853e6c936aSmrg#else 32863e6c936aSmrg# define LT_DLSYM_CONST const 32873e6c936aSmrg#endif 32883e6c936aSmrg 3289521070a0Smrg/* External symbol declarations for the compiler. */\ 3290521070a0Smrg" 3291521070a0Smrg 3292521070a0Smrg if test "$dlself" = yes; then 3293521070a0Smrg func_verbose "generating symbol list for \`$output'" 3294521070a0Smrg 3295521070a0Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 3296521070a0Smrg 3297521070a0Smrg # Add our own program objects to the symbol list. 3298ff63a143Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 3299521070a0Smrg for progfile in $progfiles; do 33003e6c936aSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 33013e6c936aSmrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 33023e6c936aSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 3303521070a0Smrg done 3304521070a0Smrg 3305521070a0Smrg if test -n "$exclude_expsyms"; then 3306521070a0Smrg $opt_dry_run || { 3307521070a0Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 3308521070a0Smrg eval '$MV "$nlist"T "$nlist"' 3309521070a0Smrg } 33104456fccdSmrg fi 3311521070a0Smrg 3312521070a0Smrg if test -n "$export_symbols_regex"; then 3313521070a0Smrg $opt_dry_run || { 3314521070a0Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 3315521070a0Smrg eval '$MV "$nlist"T "$nlist"' 3316521070a0Smrg } 3317521070a0Smrg fi 3318521070a0Smrg 3319521070a0Smrg # Prepare the list of exported symbols 3320521070a0Smrg if test -z "$export_symbols"; then 3321521070a0Smrg export_symbols="$output_objdir/$outputname.exp" 3322521070a0Smrg $opt_dry_run || { 3323521070a0Smrg $RM $export_symbols 3324521070a0Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 3325521070a0Smrg case $host in 3326521070a0Smrg *cygwin* | *mingw* | *cegcc* ) 3327521070a0Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3328521070a0Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 3329521070a0Smrg ;; 3330521070a0Smrg esac 3331521070a0Smrg } 33324456fccdSmrg else 3333521070a0Smrg $opt_dry_run || { 3334521070a0Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 3335521070a0Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 3336521070a0Smrg eval '$MV "$nlist"T "$nlist"' 3337521070a0Smrg case $host in 3338ff63a143Smrg *cygwin* | *mingw* | *cegcc* ) 3339521070a0Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3340521070a0Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 3341521070a0Smrg ;; 3342521070a0Smrg esac 3343521070a0Smrg } 33444456fccdSmrg fi 3345521070a0Smrg fi 33464456fccdSmrg 3347521070a0Smrg for dlprefile in $dlprefiles; do 3348521070a0Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 3349521070a0Smrg func_basename "$dlprefile" 3350521070a0Smrg name="$func_basename_result" 33513e6c936aSmrg case $host in 33523e6c936aSmrg *cygwin* | *mingw* | *cegcc* ) 33533e6c936aSmrg # if an import library, we need to obtain dlname 33543e6c936aSmrg if func_win32_import_lib_p "$dlprefile"; then 33553e6c936aSmrg func_tr_sh "$dlprefile" 33563e6c936aSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 33573e6c936aSmrg dlprefile_dlbasename="" 33583e6c936aSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 33593e6c936aSmrg # Use subshell, to avoid clobbering current variable values 33603e6c936aSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 33613e6c936aSmrg if test -n "$dlprefile_dlname" ; then 33623e6c936aSmrg func_basename "$dlprefile_dlname" 33633e6c936aSmrg dlprefile_dlbasename="$func_basename_result" 33643e6c936aSmrg else 33653e6c936aSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 33663e6c936aSmrg $sharedlib_from_linklib_cmd "$dlprefile" 33673e6c936aSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 33683e6c936aSmrg fi 33693e6c936aSmrg fi 33703e6c936aSmrg $opt_dry_run || { 33713e6c936aSmrg if test -n "$dlprefile_dlbasename" ; then 33723e6c936aSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 33733e6c936aSmrg else 33743e6c936aSmrg func_warning "Could not compute DLL name from $name" 33753e6c936aSmrg eval '$ECHO ": $name " >> "$nlist"' 33763e6c936aSmrg fi 33773e6c936aSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 33783e6c936aSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 33793e6c936aSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 33803e6c936aSmrg } 33813e6c936aSmrg else # not an import lib 33823e6c936aSmrg $opt_dry_run || { 33833e6c936aSmrg eval '$ECHO ": $name " >> "$nlist"' 33843e6c936aSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 33853e6c936aSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 33863e6c936aSmrg } 33873e6c936aSmrg fi 33883e6c936aSmrg ;; 33893e6c936aSmrg *) 33903e6c936aSmrg $opt_dry_run || { 33913e6c936aSmrg eval '$ECHO ": $name " >> "$nlist"' 33923e6c936aSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 33933e6c936aSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 33943e6c936aSmrg } 33953e6c936aSmrg ;; 33963e6c936aSmrg esac 3397521070a0Smrg done 3398521070a0Smrg 3399521070a0Smrg $opt_dry_run || { 3400521070a0Smrg # Make sure we have at least an empty file. 3401521070a0Smrg test -f "$nlist" || : > "$nlist" 3402521070a0Smrg 3403521070a0Smrg if test -n "$exclude_expsyms"; then 3404521070a0Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 3405521070a0Smrg $MV "$nlist"T "$nlist" 34064456fccdSmrg fi 3407521070a0Smrg 3408521070a0Smrg # Try sorting and uniquifying the output. 3409521070a0Smrg if $GREP -v "^: " < "$nlist" | 3410521070a0Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 3411521070a0Smrg sort -k 3 3412521070a0Smrg else 3413521070a0Smrg sort +2 3414521070a0Smrg fi | 3415521070a0Smrg uniq > "$nlist"S; then 3416521070a0Smrg : 34174456fccdSmrg else 3418521070a0Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 34194456fccdSmrg fi 34204456fccdSmrg 3421521070a0Smrg if test -f "$nlist"S; then 3422521070a0Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 34234456fccdSmrg else 3424ff63a143Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 34254456fccdSmrg fi 34264456fccdSmrg 3427ff63a143Smrg echo >> "$output_objdir/$my_dlsyms" "\ 34284456fccdSmrg 3429521070a0Smrg/* The mapping between symbol names and symbols. */ 3430521070a0Smrgtypedef struct { 3431521070a0Smrg const char *name; 3432521070a0Smrg void *address; 3433521070a0Smrg} lt_dlsymlist; 34343e6c936aSmrgextern LT_DLSYM_CONST lt_dlsymlist 3435521070a0Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 34363e6c936aSmrgLT_DLSYM_CONST lt_dlsymlist 3437521070a0Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 3438521070a0Smrg{\ 3439521070a0Smrg { \"$my_originator\", (void *) 0 }," 34404456fccdSmrg 3441521070a0Smrg case $need_lib_prefix in 3442521070a0Smrg no) 3443521070a0Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 3444521070a0Smrg ;; 3445521070a0Smrg *) 3446521070a0Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 3447521070a0Smrg ;; 3448521070a0Smrg esac 3449ff63a143Smrg echo >> "$output_objdir/$my_dlsyms" "\ 3450521070a0Smrg {0, (void *) 0} 3451521070a0Smrg}; 34524456fccdSmrg 3453521070a0Smrg/* This works around a problem in FreeBSD linker */ 3454521070a0Smrg#ifdef FREEBSD_WORKAROUND 3455521070a0Smrgstatic const void *lt_preloaded_setup() { 3456521070a0Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 3457521070a0Smrg} 3458521070a0Smrg#endif 3459521070a0Smrg 3460521070a0Smrg#ifdef __cplusplus 3461521070a0Smrg} 3462521070a0Smrg#endif\ 3463521070a0Smrg" 3464521070a0Smrg } # !$opt_dry_run 3465521070a0Smrg 3466521070a0Smrg pic_flag_for_symtable= 3467521070a0Smrg case "$compile_command " in 3468521070a0Smrg *" -static "*) ;; 3469521070a0Smrg *) 3470521070a0Smrg case $host in 3471521070a0Smrg # compiling the symbol table file with pic_flag works around 3472521070a0Smrg # a FreeBSD bug that causes programs to crash when -lm is 3473521070a0Smrg # linked before any other PIC object. But we must not use 3474521070a0Smrg # pic_flag when linking with -static. The problem exists in 3475521070a0Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 34763e6c936aSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 3477521070a0Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 3478521070a0Smrg *-*-hpux*) 3479521070a0Smrg pic_flag_for_symtable=" $pic_flag" ;; 3480521070a0Smrg *) 3481521070a0Smrg if test "X$my_pic_p" != Xno; then 3482521070a0Smrg pic_flag_for_symtable=" $pic_flag" 34834456fccdSmrg fi 3484521070a0Smrg ;; 3485521070a0Smrg esac 3486521070a0Smrg ;; 3487521070a0Smrg esac 3488521070a0Smrg symtab_cflags= 3489521070a0Smrg for arg in $LTCFLAGS; do 3490521070a0Smrg case $arg in 3491521070a0Smrg -pie | -fpie | -fPIE) ;; 34923e6c936aSmrg *) func_append symtab_cflags " $arg" ;; 3493521070a0Smrg esac 3494521070a0Smrg done 34954456fccdSmrg 3496521070a0Smrg # Now compile the dynamic symbol file. 3497521070a0Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 34984456fccdSmrg 3499521070a0Smrg # Clean up the generated files. 3500521070a0Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 35014456fccdSmrg 3502521070a0Smrg # Transform the symbol file into the correct name. 3503521070a0Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 3504521070a0Smrg case $host in 3505521070a0Smrg *cygwin* | *mingw* | *cegcc* ) 3506521070a0Smrg if test -f "$output_objdir/$my_outputname.def"; then 3507ff63a143Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3508ff63a143Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3509521070a0Smrg else 3510ff63a143Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3511ff63a143Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 35124456fccdSmrg fi 3513521070a0Smrg ;; 3514521070a0Smrg *) 3515ff63a143Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3516ff63a143Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3517521070a0Smrg ;; 3518521070a0Smrg esac 3519521070a0Smrg ;; 3520521070a0Smrg *) 3521521070a0Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 3522521070a0Smrg ;; 3523521070a0Smrg esac 3524521070a0Smrg else 3525521070a0Smrg # We keep going just in case the user didn't refer to 3526521070a0Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 3527521070a0Smrg # really was required. 35284456fccdSmrg 3529521070a0Smrg # Nullify the symbol file. 3530ff63a143Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 3531ff63a143Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 3532521070a0Smrg fi 3533521070a0Smrg} 35344456fccdSmrg 3535521070a0Smrg# func_win32_libid arg 3536521070a0Smrg# return the library type of file 'arg' 3537521070a0Smrg# 3538521070a0Smrg# Need a lot of goo to handle *both* DLLs and import libs 3539521070a0Smrg# Has to be a shell function in order to 'eat' the argument 3540521070a0Smrg# that is supplied when $file_magic_command is called. 3541ff63a143Smrg# Despite the name, also deal with 64 bit binaries. 3542521070a0Smrgfunc_win32_libid () 3543521070a0Smrg{ 3544521070a0Smrg $opt_debug 3545521070a0Smrg win32_libid_type="unknown" 3546521070a0Smrg win32_fileres=`file -L $1 2>/dev/null` 3547521070a0Smrg case $win32_fileres in 3548521070a0Smrg *ar\ archive\ import\ library*) # definitely import 3549521070a0Smrg win32_libid_type="x86 archive import" 3550521070a0Smrg ;; 3551521070a0Smrg *ar\ archive*) # could be an import, or static 3552ff63a143Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 3553521070a0Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 3554ff63a143Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 35553e6c936aSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 35563e6c936aSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 3557521070a0Smrg $SED -n -e ' 3558521070a0Smrg 1,100{ 3559521070a0Smrg / I /{ 3560521070a0Smrg s,.*,import, 3561521070a0Smrg p 3562521070a0Smrg q 3563521070a0Smrg } 3564521070a0Smrg }'` 3565521070a0Smrg case $win32_nmres in 3566521070a0Smrg import*) win32_libid_type="x86 archive import";; 3567521070a0Smrg *) win32_libid_type="x86 archive static";; 3568521070a0Smrg esac 3569521070a0Smrg fi 3570521070a0Smrg ;; 3571521070a0Smrg *DLL*) 3572521070a0Smrg win32_libid_type="x86 DLL" 3573521070a0Smrg ;; 3574521070a0Smrg *executable*) # but shell scripts are "executable" too... 3575521070a0Smrg case $win32_fileres in 3576521070a0Smrg *MS\ Windows\ PE\ Intel*) 3577521070a0Smrg win32_libid_type="x86 DLL" 3578521070a0Smrg ;; 3579521070a0Smrg esac 3580521070a0Smrg ;; 3581521070a0Smrg esac 3582521070a0Smrg $ECHO "$win32_libid_type" 3583521070a0Smrg} 35844456fccdSmrg 35853e6c936aSmrg# func_cygming_dll_for_implib ARG 35863e6c936aSmrg# 35873e6c936aSmrg# Platform-specific function to extract the 35883e6c936aSmrg# name of the DLL associated with the specified 35893e6c936aSmrg# import library ARG. 35903e6c936aSmrg# Invoked by eval'ing the libtool variable 35913e6c936aSmrg# $sharedlib_from_linklib_cmd 35923e6c936aSmrg# Result is available in the variable 35933e6c936aSmrg# $sharedlib_from_linklib_result 35943e6c936aSmrgfunc_cygming_dll_for_implib () 35953e6c936aSmrg{ 35963e6c936aSmrg $opt_debug 35973e6c936aSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 35983e6c936aSmrg} 35993e6c936aSmrg 36003e6c936aSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 36013e6c936aSmrg# 36023e6c936aSmrg# The is the core of a fallback implementation of a 36033e6c936aSmrg# platform-specific function to extract the name of the 36043e6c936aSmrg# DLL associated with the specified import library LIBNAME. 36053e6c936aSmrg# 36063e6c936aSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 36073e6c936aSmrg# on the platform and compiler that created the implib. 36083e6c936aSmrg# 36093e6c936aSmrg# Echos the name of the DLL associated with the 36103e6c936aSmrg# specified import library. 36113e6c936aSmrgfunc_cygming_dll_for_implib_fallback_core () 36123e6c936aSmrg{ 36133e6c936aSmrg $opt_debug 36143e6c936aSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 36153e6c936aSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 36163e6c936aSmrg $SED '/^Contents of section '"$match_literal"':/{ 36173e6c936aSmrg # Place marker at beginning of archive member dllname section 36183e6c936aSmrg s/.*/====MARK====/ 36193e6c936aSmrg p 36203e6c936aSmrg d 36213e6c936aSmrg } 36223e6c936aSmrg # These lines can sometimes be longer than 43 characters, but 36233e6c936aSmrg # are always uninteresting 36243e6c936aSmrg /:[ ]*file format pe[i]\{,1\}-/d 36253e6c936aSmrg /^In archive [^:]*:/d 36263e6c936aSmrg # Ensure marker is printed 36273e6c936aSmrg /^====MARK====/p 36283e6c936aSmrg # Remove all lines with less than 43 characters 36293e6c936aSmrg /^.\{43\}/!d 36303e6c936aSmrg # From remaining lines, remove first 43 characters 36313e6c936aSmrg s/^.\{43\}//' | 36323e6c936aSmrg $SED -n ' 36333e6c936aSmrg # Join marker and all lines until next marker into a single line 36343e6c936aSmrg /^====MARK====/ b para 36353e6c936aSmrg H 36363e6c936aSmrg $ b para 36373e6c936aSmrg b 36383e6c936aSmrg :para 36393e6c936aSmrg x 36403e6c936aSmrg s/\n//g 36413e6c936aSmrg # Remove the marker 36423e6c936aSmrg s/^====MARK====// 36433e6c936aSmrg # Remove trailing dots and whitespace 36443e6c936aSmrg s/[\. \t]*$// 36453e6c936aSmrg # Print 36463e6c936aSmrg /./p' | 36473e6c936aSmrg # we now have a list, one entry per line, of the stringified 36483e6c936aSmrg # contents of the appropriate section of all members of the 36493e6c936aSmrg # archive which possess that section. Heuristic: eliminate 36503e6c936aSmrg # all those which have a first or second character that is 36513e6c936aSmrg # a '.' (that is, objdump's representation of an unprintable 36523e6c936aSmrg # character.) This should work for all archives with less than 36533e6c936aSmrg # 0x302f exports -- but will fail for DLLs whose name actually 36543e6c936aSmrg # begins with a literal '.' or a single character followed by 36553e6c936aSmrg # a '.'. 36563e6c936aSmrg # 36573e6c936aSmrg # Of those that remain, print the first one. 36583e6c936aSmrg $SED -e '/^\./d;/^.\./d;q' 36593e6c936aSmrg} 36603e6c936aSmrg 36613e6c936aSmrg# func_cygming_gnu_implib_p ARG 36623e6c936aSmrg# This predicate returns with zero status (TRUE) if 36633e6c936aSmrg# ARG is a GNU/binutils-style import library. Returns 36643e6c936aSmrg# with nonzero status (FALSE) otherwise. 36653e6c936aSmrgfunc_cygming_gnu_implib_p () 36663e6c936aSmrg{ 36673e6c936aSmrg $opt_debug 36683e6c936aSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 36693e6c936aSmrg 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)$'` 36703e6c936aSmrg test -n "$func_cygming_gnu_implib_tmp" 36713e6c936aSmrg} 36723e6c936aSmrg 36733e6c936aSmrg# func_cygming_ms_implib_p ARG 36743e6c936aSmrg# This predicate returns with zero status (TRUE) if 36753e6c936aSmrg# ARG is an MS-style import library. Returns 36763e6c936aSmrg# with nonzero status (FALSE) otherwise. 36773e6c936aSmrgfunc_cygming_ms_implib_p () 36783e6c936aSmrg{ 36793e6c936aSmrg $opt_debug 36803e6c936aSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 36813e6c936aSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 36823e6c936aSmrg test -n "$func_cygming_ms_implib_tmp" 36833e6c936aSmrg} 36843e6c936aSmrg 36853e6c936aSmrg# func_cygming_dll_for_implib_fallback ARG 36863e6c936aSmrg# Platform-specific function to extract the 36873e6c936aSmrg# name of the DLL associated with the specified 36883e6c936aSmrg# import library ARG. 36893e6c936aSmrg# 36903e6c936aSmrg# This fallback implementation is for use when $DLLTOOL 36913e6c936aSmrg# does not support the --identify-strict option. 36923e6c936aSmrg# Invoked by eval'ing the libtool variable 36933e6c936aSmrg# $sharedlib_from_linklib_cmd 36943e6c936aSmrg# Result is available in the variable 36953e6c936aSmrg# $sharedlib_from_linklib_result 36963e6c936aSmrgfunc_cygming_dll_for_implib_fallback () 36973e6c936aSmrg{ 36983e6c936aSmrg $opt_debug 36993e6c936aSmrg if func_cygming_gnu_implib_p "$1" ; then 37003e6c936aSmrg # binutils import library 37013e6c936aSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 37023e6c936aSmrg elif func_cygming_ms_implib_p "$1" ; then 37033e6c936aSmrg # ms-generated import library 37043e6c936aSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 37053e6c936aSmrg else 37063e6c936aSmrg # unknown 37073e6c936aSmrg sharedlib_from_linklib_result="" 37083e6c936aSmrg fi 37093e6c936aSmrg} 37104456fccdSmrg 37114456fccdSmrg 3712521070a0Smrg# func_extract_an_archive dir oldlib 3713521070a0Smrgfunc_extract_an_archive () 3714521070a0Smrg{ 3715521070a0Smrg $opt_debug 3716521070a0Smrg f_ex_an_ar_dir="$1"; shift 3717521070a0Smrg f_ex_an_ar_oldlib="$1" 3718ff63a143Smrg if test "$lock_old_archive_extraction" = yes; then 3719ff63a143Smrg lockfile=$f_ex_an_ar_oldlib.lock 3720ff63a143Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3721ff63a143Smrg func_echo "Waiting for $lockfile to be removed" 3722ff63a143Smrg sleep 2 3723ff63a143Smrg done 3724ff63a143Smrg fi 3725ff63a143Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 3726ff63a143Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 3727ff63a143Smrg if test "$lock_old_archive_extraction" = yes; then 3728ff63a143Smrg $opt_dry_run || rm -f "$lockfile" 3729ff63a143Smrg fi 3730521070a0Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 3731521070a0Smrg : 3732521070a0Smrg else 3733521070a0Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 3734521070a0Smrg fi 3735521070a0Smrg} 37364456fccdSmrg 37374456fccdSmrg 3738521070a0Smrg# func_extract_archives gentop oldlib ... 3739521070a0Smrgfunc_extract_archives () 3740521070a0Smrg{ 3741521070a0Smrg $opt_debug 3742521070a0Smrg my_gentop="$1"; shift 3743521070a0Smrg my_oldlibs=${1+"$@"} 3744521070a0Smrg my_oldobjs="" 3745521070a0Smrg my_xlib="" 3746521070a0Smrg my_xabs="" 3747521070a0Smrg my_xdir="" 37484456fccdSmrg 3749521070a0Smrg for my_xlib in $my_oldlibs; do 3750521070a0Smrg # Extract the objects. 3751521070a0Smrg case $my_xlib in 3752521070a0Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 3753521070a0Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 3754521070a0Smrg esac 3755521070a0Smrg func_basename "$my_xlib" 3756521070a0Smrg my_xlib="$func_basename_result" 3757521070a0Smrg my_xlib_u=$my_xlib 3758521070a0Smrg while :; do 3759521070a0Smrg case " $extracted_archives " in 3760521070a0Smrg *" $my_xlib_u "*) 3761521070a0Smrg func_arith $extracted_serial + 1 3762521070a0Smrg extracted_serial=$func_arith_result 3763521070a0Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 3764521070a0Smrg *) break ;; 3765521070a0Smrg esac 3766521070a0Smrg done 3767521070a0Smrg extracted_archives="$extracted_archives $my_xlib_u" 3768521070a0Smrg my_xdir="$my_gentop/$my_xlib_u" 37694456fccdSmrg 3770521070a0Smrg func_mkdir_p "$my_xdir" 37714456fccdSmrg 3772521070a0Smrg case $host in 3773521070a0Smrg *-darwin*) 3774521070a0Smrg func_verbose "Extracting $my_xabs" 3775521070a0Smrg # Do not bother doing anything if just a dry run 3776521070a0Smrg $opt_dry_run || { 3777521070a0Smrg darwin_orig_dir=`pwd` 3778521070a0Smrg cd $my_xdir || exit $? 3779521070a0Smrg darwin_archive=$my_xabs 3780521070a0Smrg darwin_curdir=`pwd` 3781521070a0Smrg darwin_base_archive=`basename "$darwin_archive"` 3782521070a0Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 3783521070a0Smrg if test -n "$darwin_arches"; then 3784521070a0Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 3785521070a0Smrg darwin_arch= 3786521070a0Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 3787521070a0Smrg for darwin_arch in $darwin_arches ; do 3788521070a0Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3789521070a0Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 3790521070a0Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3791521070a0Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 3792521070a0Smrg cd "$darwin_curdir" 3793521070a0Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 3794521070a0Smrg done # $darwin_arches 3795521070a0Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 3796521070a0Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 3797521070a0Smrg darwin_file= 3798521070a0Smrg darwin_files= 3799521070a0Smrg for darwin_file in $darwin_filelist; do 3800ff63a143Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 3801521070a0Smrg $LIPO -create -output "$darwin_file" $darwin_files 3802521070a0Smrg done # $darwin_filelist 3803521070a0Smrg $RM -rf unfat-$$ 3804521070a0Smrg cd "$darwin_orig_dir" 38054456fccdSmrg else 3806521070a0Smrg cd $darwin_orig_dir 3807521070a0Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 3808521070a0Smrg fi # $darwin_arches 3809521070a0Smrg } # !$opt_dry_run 3810521070a0Smrg ;; 3811521070a0Smrg *) 3812521070a0Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 3813521070a0Smrg ;; 3814521070a0Smrg esac 3815ff63a143Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 3816521070a0Smrg done 38174456fccdSmrg 3818521070a0Smrg func_extract_archives_result="$my_oldobjs" 3819521070a0Smrg} 38204456fccdSmrg 38214456fccdSmrg 3822ff63a143Smrg# func_emit_wrapper [arg=no] 3823ff63a143Smrg# 3824ff63a143Smrg# Emit a libtool wrapper script on stdout. 3825ff63a143Smrg# Don't directly open a file because we may want to 3826ff63a143Smrg# incorporate the script contents within a cygwin/mingw 3827ff63a143Smrg# wrapper executable. Must ONLY be called from within 3828ff63a143Smrg# func_mode_link because it depends on a number of variables 3829ff63a143Smrg# set therein. 3830521070a0Smrg# 3831ff63a143Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 3832ff63a143Smrg# variable will take. If 'yes', then the emitted script 3833ff63a143Smrg# will assume that the directory in which it is stored is 3834ff63a143Smrg# the $objdir directory. This is a cygwin/mingw-specific 3835ff63a143Smrg# behavior. 3836ff63a143Smrgfunc_emit_wrapper () 3837521070a0Smrg{ 3838ff63a143Smrg func_emit_wrapper_arg1=${1-no} 38394456fccdSmrg 3840521070a0Smrg $ECHO "\ 3841521070a0Smrg#! $SHELL 38424456fccdSmrg 3843521070a0Smrg# $output - temporary wrapper script for $objdir/$outputname 3844521070a0Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 3845521070a0Smrg# 3846521070a0Smrg# The $output program cannot be directly executed until all the libtool 3847521070a0Smrg# libraries that it depends on are installed. 3848521070a0Smrg# 3849521070a0Smrg# This wrapper script should never be moved out of the build directory. 3850521070a0Smrg# If it is, it will not operate correctly. 38514456fccdSmrg 3852521070a0Smrg# Sed substitution that helps us do robust quoting. It backslashifies 3853521070a0Smrg# metacharacters that are still active within double-quoted strings. 3854521070a0Smrgsed_quote_subst='$sed_quote_subst' 38554456fccdSmrg 3856521070a0Smrg# Be Bourne compatible 3857521070a0Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 3858521070a0Smrg emulate sh 3859521070a0Smrg NULLCMD=: 3860521070a0Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 3861521070a0Smrg # is contrary to our usage. Disable this feature. 3862521070a0Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 3863521070a0Smrg setopt NO_GLOB_SUBST 3864521070a0Smrgelse 3865521070a0Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 3866521070a0Smrgfi 3867521070a0SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 3868521070a0SmrgDUALCASE=1; export DUALCASE # for MKS sh 38694456fccdSmrg 3870521070a0Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 3871521070a0Smrg# if CDPATH is set. 3872521070a0Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 38734456fccdSmrg 3874521070a0Smrgrelink_command=\"$relink_command\" 38754456fccdSmrg 3876521070a0Smrg# This environment variable determines our operation mode. 3877521070a0Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 3878521070a0Smrg # install mode needs the following variables: 3879521070a0Smrg generated_by_libtool_version='$macro_version' 3880521070a0Smrg notinst_deplibs='$notinst_deplibs' 3881521070a0Smrgelse 3882521070a0Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 3883521070a0Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 3884ff63a143Smrg file=\"\$0\"" 3885ff63a143Smrg 3886ff63a143Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 3887ff63a143Smrg $ECHO "\ 3888ff63a143Smrg 3889ff63a143Smrg# A function that is used when there is no print builtin or printf. 3890ff63a143Smrgfunc_fallback_echo () 3891ff63a143Smrg{ 3892ff63a143Smrg eval 'cat <<_LTECHO_EOF 3893ff63a143Smrg\$1 3894ff63a143Smrg_LTECHO_EOF' 3895ff63a143Smrg} 3896ff63a143Smrg ECHO=\"$qECHO\" 3897ff63a143Smrg fi 3898ff63a143Smrg 3899ff63a143Smrg# Very basic option parsing. These options are (a) specific to 3900ff63a143Smrg# the libtool wrapper, (b) are identical between the wrapper 3901ff63a143Smrg# /script/ and the wrapper /executable/ which is used only on 3902ff63a143Smrg# windows platforms, and (c) all begin with the string "--lt-" 3903ff63a143Smrg# (application programs are unlikely to have options which match 3904ff63a143Smrg# this pattern). 3905ff63a143Smrg# 3906ff63a143Smrg# There are only two supported options: --lt-debug and 3907ff63a143Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 3908ff63a143Smrg# 3909ff63a143Smrg# The first argument to this parsing function should be the 3910ff63a143Smrg# script's $0 value, followed by "$@". 3911ff63a143Smrglt_option_debug= 3912ff63a143Smrgfunc_parse_lt_options () 3913ff63a143Smrg{ 3914ff63a143Smrg lt_script_arg0=\$0 3915ff63a143Smrg shift 3916ff63a143Smrg for lt_opt 3917ff63a143Smrg do 3918ff63a143Smrg case \"\$lt_opt\" in 3919ff63a143Smrg --lt-debug) lt_option_debug=1 ;; 3920ff63a143Smrg --lt-dump-script) 3921ff63a143Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 3922ff63a143Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 3923ff63a143Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 3924ff63a143Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 3925ff63a143Smrg exit 0 3926ff63a143Smrg ;; 3927ff63a143Smrg --lt-*) 3928ff63a143Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 3929ff63a143Smrg exit 1 3930ff63a143Smrg ;; 3931ff63a143Smrg esac 3932ff63a143Smrg done 3933ff63a143Smrg 3934ff63a143Smrg # Print the debug banner immediately: 3935ff63a143Smrg if test -n \"\$lt_option_debug\"; then 3936ff63a143Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 3937ff63a143Smrg fi 3938ff63a143Smrg} 3939ff63a143Smrg 3940ff63a143Smrg# Used when --lt-debug. Prints its arguments to stdout 3941ff63a143Smrg# (redirection is the responsibility of the caller) 3942ff63a143Smrgfunc_lt_dump_args () 3943ff63a143Smrg{ 3944ff63a143Smrg lt_dump_args_N=1; 3945ff63a143Smrg for lt_arg 3946ff63a143Smrg do 3947ff63a143Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 3948ff63a143Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 3949ff63a143Smrg done 3950ff63a143Smrg} 3951ff63a143Smrg 3952ff63a143Smrg# Core function for launching the target application 3953ff63a143Smrgfunc_exec_program_core () 3954ff63a143Smrg{ 3955521070a0Smrg" 3956ff63a143Smrg case $host in 3957ff63a143Smrg # Backslashes separate directories on plain windows 3958ff63a143Smrg *-*-mingw | *-*-os2* | *-cegcc*) 3959ff63a143Smrg $ECHO "\ 3960ff63a143Smrg if test -n \"\$lt_option_debug\"; then 3961ff63a143Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 3962ff63a143Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 3963ff63a143Smrg fi 3964ff63a143Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 3965ff63a143Smrg" 3966ff63a143Smrg ;; 3967ff63a143Smrg 3968ff63a143Smrg *) 3969ff63a143Smrg $ECHO "\ 3970ff63a143Smrg if test -n \"\$lt_option_debug\"; then 3971ff63a143Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 3972ff63a143Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 3973ff63a143Smrg fi 3974ff63a143Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 3975ff63a143Smrg" 3976ff63a143Smrg ;; 3977ff63a143Smrg esac 3978ff63a143Smrg $ECHO "\ 3979ff63a143Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 3980ff63a143Smrg exit 1 3981ff63a143Smrg} 3982ff63a143Smrg 3983ff63a143Smrg# A function to encapsulate launching the target application 3984ff63a143Smrg# Strips options in the --lt-* namespace from \$@ and 3985ff63a143Smrg# launches target application with the remaining arguments. 3986ff63a143Smrgfunc_exec_program () 3987ff63a143Smrg{ 39883e6c936aSmrg case \" \$* \" in 39893e6c936aSmrg *\\ --lt-*) 39903e6c936aSmrg for lt_wr_arg 39913e6c936aSmrg do 39923e6c936aSmrg case \$lt_wr_arg in 39933e6c936aSmrg --lt-*) ;; 39943e6c936aSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 39953e6c936aSmrg esac 39963e6c936aSmrg shift 39973e6c936aSmrg done ;; 39983e6c936aSmrg esac 3999ff63a143Smrg func_exec_program_core \${1+\"\$@\"} 4000ff63a143Smrg} 4001ff63a143Smrg 4002ff63a143Smrg # Parse options 4003ff63a143Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 40044456fccdSmrg 4005521070a0Smrg # Find the directory that this script lives in. 4006ff63a143Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 4007521070a0Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 40084456fccdSmrg 4009521070a0Smrg # Follow symbolic links until we get to the real thisdir. 4010ff63a143Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 4011521070a0Smrg while test -n \"\$file\"; do 4012ff63a143Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 40134456fccdSmrg 4014521070a0Smrg # If there was a directory component, then change thisdir. 4015521070a0Smrg if test \"x\$destdir\" != \"x\$file\"; then 4016521070a0Smrg case \"\$destdir\" in 4017521070a0Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 4018521070a0Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 40194456fccdSmrg esac 4020521070a0Smrg fi 40214456fccdSmrg 4022ff63a143Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 4023ff63a143Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 4024521070a0Smrg done 40254456fccdSmrg 4026521070a0Smrg # Usually 'no', except on cygwin/mingw when embedded into 4027521070a0Smrg # the cwrapper. 4028ff63a143Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 4029521070a0Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 4030521070a0Smrg # special case for '.' 4031521070a0Smrg if test \"\$thisdir\" = \".\"; then 4032521070a0Smrg thisdir=\`pwd\` 4033521070a0Smrg fi 4034521070a0Smrg # remove .libs from thisdir 4035521070a0Smrg case \"\$thisdir\" in 4036ff63a143Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 4037521070a0Smrg $objdir ) thisdir=. ;; 4038521070a0Smrg esac 4039521070a0Smrg fi 4040521070a0Smrg 4041521070a0Smrg # Try to get the absolute directory name. 4042521070a0Smrg absdir=\`cd \"\$thisdir\" && pwd\` 4043521070a0Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 4044521070a0Smrg" 4045521070a0Smrg 4046521070a0Smrg if test "$fast_install" = yes; then 4047521070a0Smrg $ECHO "\ 4048521070a0Smrg program=lt-'$outputname'$exeext 4049521070a0Smrg progdir=\"\$thisdir/$objdir\" 4050521070a0Smrg 4051521070a0Smrg if test ! -f \"\$progdir/\$program\" || 4052521070a0Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 4053521070a0Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 4054521070a0Smrg 4055521070a0Smrg file=\"\$\$-\$program\" 4056521070a0Smrg 4057521070a0Smrg if test ! -d \"\$progdir\"; then 4058521070a0Smrg $MKDIR \"\$progdir\" 4059521070a0Smrg else 4060521070a0Smrg $RM \"\$progdir/\$file\" 4061521070a0Smrg fi" 4062521070a0Smrg 4063521070a0Smrg $ECHO "\ 4064521070a0Smrg 4065521070a0Smrg # relink executable if necessary 4066521070a0Smrg if test -n \"\$relink_command\"; then 4067521070a0Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 4068521070a0Smrg else 4069521070a0Smrg $ECHO \"\$relink_command_output\" >&2 4070521070a0Smrg $RM \"\$progdir/\$file\" 4071521070a0Smrg exit 1 40724456fccdSmrg fi 4073521070a0Smrg fi 40744456fccdSmrg 4075521070a0Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 4076521070a0Smrg { $RM \"\$progdir/\$program\"; 4077521070a0Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 4078521070a0Smrg $RM \"\$progdir/\$file\" 4079521070a0Smrg fi" 4080521070a0Smrg else 4081521070a0Smrg $ECHO "\ 4082521070a0Smrg program='$outputname' 4083521070a0Smrg progdir=\"\$thisdir/$objdir\" 4084521070a0Smrg" 40854456fccdSmrg fi 40864456fccdSmrg 4087521070a0Smrg $ECHO "\ 40884456fccdSmrg 4089521070a0Smrg if test -f \"\$progdir/\$program\"; then" 40904456fccdSmrg 40913e6c936aSmrg # fixup the dll searchpath if we need to. 40923e6c936aSmrg # 40933e6c936aSmrg # Fix the DLL searchpath if we need to. Do this before prepending 40943e6c936aSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 40953e6c936aSmrg # libraries must come first. 40963e6c936aSmrg if test -n "$dllsearchpath"; then 40973e6c936aSmrg $ECHO "\ 40983e6c936aSmrg # Add the dll search path components to the executable PATH 40993e6c936aSmrg PATH=$dllsearchpath:\$PATH 41003e6c936aSmrg" 41013e6c936aSmrg fi 41023e6c936aSmrg 4103521070a0Smrg # Export our shlibpath_var if we have one. 4104521070a0Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4105521070a0Smrg $ECHO "\ 4106521070a0Smrg # Add our own library path to $shlibpath_var 4107521070a0Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 4108521070a0Smrg 4109521070a0Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 4110521070a0Smrg # The second colon is a workaround for a bug in BeOS R4 sed 4111ff63a143Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 41124456fccdSmrg 4113521070a0Smrg export $shlibpath_var 4114521070a0Smrg" 41154456fccdSmrg fi 41164456fccdSmrg 4117521070a0Smrg $ECHO "\ 4118521070a0Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 4119521070a0Smrg # Run the actual program with our arguments. 4120ff63a143Smrg func_exec_program \${1+\"\$@\"} 4121521070a0Smrg fi 4122521070a0Smrg else 4123521070a0Smrg # The program doesn't exist. 4124521070a0Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 4125521070a0Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 4126ff63a143Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 4127521070a0Smrg exit 1 4128521070a0Smrg fi 4129521070a0Smrgfi\ 4130521070a0Smrg" 4131521070a0Smrg} 41324456fccdSmrg 41334456fccdSmrg 4134521070a0Smrg# func_emit_cwrapperexe_src 4135521070a0Smrg# emit the source code for a wrapper executable on stdout 4136521070a0Smrg# Must ONLY be called from within func_mode_link because 4137521070a0Smrg# it depends on a number of variable set therein. 4138521070a0Smrgfunc_emit_cwrapperexe_src () 4139521070a0Smrg{ 4140521070a0Smrg cat <<EOF 41414456fccdSmrg 4142521070a0Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 4143521070a0Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 41444456fccdSmrg 4145521070a0Smrg The $output program cannot be directly executed until all the libtool 4146521070a0Smrg libraries that it depends on are installed. 41474456fccdSmrg 4148521070a0Smrg This wrapper executable should never be moved out of the build directory. 4149521070a0Smrg If it is, it will not operate correctly. 4150521070a0Smrg*/ 4151521070a0SmrgEOF 4152521070a0Smrg cat <<"EOF" 4153ff63a143Smrg#ifdef _MSC_VER 4154ff63a143Smrg# define _CRT_SECURE_NO_DEPRECATE 1 4155ff63a143Smrg#endif 4156521070a0Smrg#include <stdio.h> 4157521070a0Smrg#include <stdlib.h> 4158521070a0Smrg#ifdef _MSC_VER 4159521070a0Smrg# include <direct.h> 4160521070a0Smrg# include <process.h> 4161521070a0Smrg# include <io.h> 4162521070a0Smrg#else 4163521070a0Smrg# include <unistd.h> 4164521070a0Smrg# include <stdint.h> 4165521070a0Smrg# ifdef __CYGWIN__ 4166521070a0Smrg# include <io.h> 4167521070a0Smrg# endif 4168521070a0Smrg#endif 4169521070a0Smrg#include <malloc.h> 4170521070a0Smrg#include <stdarg.h> 4171521070a0Smrg#include <assert.h> 4172521070a0Smrg#include <string.h> 4173521070a0Smrg#include <ctype.h> 4174521070a0Smrg#include <errno.h> 4175521070a0Smrg#include <fcntl.h> 4176521070a0Smrg#include <sys/stat.h> 41774456fccdSmrg 4178ff63a143Smrg/* declarations of non-ANSI functions */ 4179ff63a143Smrg#if defined(__MINGW32__) 4180ff63a143Smrg# ifdef __STRICT_ANSI__ 4181ff63a143Smrgint _putenv (const char *); 4182ff63a143Smrg# endif 4183ff63a143Smrg#elif defined(__CYGWIN__) 4184ff63a143Smrg# ifdef __STRICT_ANSI__ 4185ff63a143Smrgchar *realpath (const char *, char *); 4186ff63a143Smrgint putenv (char *); 4187ff63a143Smrgint setenv (const char *, const char *, int); 4188ff63a143Smrg# endif 4189ff63a143Smrg/* #elif defined (other platforms) ... */ 4190ff63a143Smrg#endif 4191ff63a143Smrg 4192ff63a143Smrg/* portability defines, excluding path handling macros */ 4193ff63a143Smrg#if defined(_MSC_VER) 4194ff63a143Smrg# define setmode _setmode 4195ff63a143Smrg# define stat _stat 4196ff63a143Smrg# define chmod _chmod 4197ff63a143Smrg# define getcwd _getcwd 4198ff63a143Smrg# define putenv _putenv 4199ff63a143Smrg# define S_IXUSR _S_IEXEC 4200ff63a143Smrg# ifndef _INTPTR_T_DEFINED 4201ff63a143Smrg# define _INTPTR_T_DEFINED 4202ff63a143Smrg# define intptr_t int 4203ff63a143Smrg# endif 4204ff63a143Smrg#elif defined(__MINGW32__) 4205ff63a143Smrg# define setmode _setmode 4206ff63a143Smrg# define stat _stat 4207ff63a143Smrg# define chmod _chmod 4208ff63a143Smrg# define getcwd _getcwd 4209ff63a143Smrg# define putenv _putenv 4210ff63a143Smrg#elif defined(__CYGWIN__) 4211ff63a143Smrg# define HAVE_SETENV 4212ff63a143Smrg# define FOPEN_WB "wb" 4213ff63a143Smrg/* #elif defined (other platforms) ... */ 4214ff63a143Smrg#endif 4215ff63a143Smrg 4216521070a0Smrg#if defined(PATH_MAX) 4217521070a0Smrg# define LT_PATHMAX PATH_MAX 4218521070a0Smrg#elif defined(MAXPATHLEN) 4219521070a0Smrg# define LT_PATHMAX MAXPATHLEN 4220521070a0Smrg#else 4221521070a0Smrg# define LT_PATHMAX 1024 4222521070a0Smrg#endif 42234456fccdSmrg 4224521070a0Smrg#ifndef S_IXOTH 4225521070a0Smrg# define S_IXOTH 0 4226521070a0Smrg#endif 4227521070a0Smrg#ifndef S_IXGRP 4228521070a0Smrg# define S_IXGRP 0 4229521070a0Smrg#endif 42304456fccdSmrg 4231ff63a143Smrg/* path handling portability macros */ 4232521070a0Smrg#ifndef DIR_SEPARATOR 4233521070a0Smrg# define DIR_SEPARATOR '/' 4234521070a0Smrg# define PATH_SEPARATOR ':' 4235521070a0Smrg#endif 42364456fccdSmrg 4237521070a0Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 4238521070a0Smrg defined (__OS2__) 4239521070a0Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 4240521070a0Smrg# define FOPEN_WB "wb" 4241521070a0Smrg# ifndef DIR_SEPARATOR_2 4242521070a0Smrg# define DIR_SEPARATOR_2 '\\' 4243521070a0Smrg# endif 4244521070a0Smrg# ifndef PATH_SEPARATOR_2 4245521070a0Smrg# define PATH_SEPARATOR_2 ';' 4246521070a0Smrg# endif 4247521070a0Smrg#endif 42484456fccdSmrg 4249521070a0Smrg#ifndef DIR_SEPARATOR_2 4250521070a0Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 4251521070a0Smrg#else /* DIR_SEPARATOR_2 */ 4252521070a0Smrg# define IS_DIR_SEPARATOR(ch) \ 4253521070a0Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 4254521070a0Smrg#endif /* DIR_SEPARATOR_2 */ 42554456fccdSmrg 4256521070a0Smrg#ifndef PATH_SEPARATOR_2 4257521070a0Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 4258521070a0Smrg#else /* PATH_SEPARATOR_2 */ 4259521070a0Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 4260521070a0Smrg#endif /* PATH_SEPARATOR_2 */ 42614456fccdSmrg 4262521070a0Smrg#ifndef FOPEN_WB 4263521070a0Smrg# define FOPEN_WB "w" 4264521070a0Smrg#endif 4265521070a0Smrg#ifndef _O_BINARY 4266521070a0Smrg# define _O_BINARY 0 4267521070a0Smrg#endif 42684456fccdSmrg 4269521070a0Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 4270521070a0Smrg#define XFREE(stale) do { \ 4271521070a0Smrg if (stale) { free ((void *) stale); stale = 0; } \ 4272521070a0Smrg} while (0) 42734456fccdSmrg 4274ff63a143Smrg#if defined(LT_DEBUGWRAPPER) 4275ff63a143Smrgstatic int lt_debug = 1; 4276521070a0Smrg#else 4277ff63a143Smrgstatic int lt_debug = 0; 4278521070a0Smrg#endif 42794456fccdSmrg 4280ff63a143Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 42814456fccdSmrg 4282521070a0Smrgvoid *xmalloc (size_t num); 4283521070a0Smrgchar *xstrdup (const char *string); 4284521070a0Smrgconst char *base_name (const char *name); 4285521070a0Smrgchar *find_executable (const char *wrapper); 4286521070a0Smrgchar *chase_symlinks (const char *pathspec); 4287521070a0Smrgint make_executable (const char *path); 4288521070a0Smrgint check_executable (const char *path); 4289521070a0Smrgchar *strendzap (char *str, const char *pat); 4290ff63a143Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 4291ff63a143Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 4292ff63a143Smrgstatic const char *nonnull (const char *s); 4293ff63a143Smrgstatic const char *nonempty (const char *s); 4294521070a0Smrgvoid lt_setenv (const char *name, const char *value); 4295521070a0Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 4296521070a0Smrgvoid lt_update_exe_path (const char *name, const char *value); 4297521070a0Smrgvoid lt_update_lib_path (const char *name, const char *value); 4298ff63a143Smrgchar **prepare_spawn (char **argv); 4299ff63a143Smrgvoid lt_dump_script (FILE *f); 4300521070a0SmrgEOF 4301521070a0Smrg 4302521070a0Smrg cat <<EOF 43033e6c936aSmrgvolatile const char * MAGIC_EXE = "$magic_exe"; 4304521070a0Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 4305521070a0SmrgEOF 43064456fccdSmrg 4307521070a0Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 43083e6c936aSmrg func_to_host_path "$temp_rpath" 4309521070a0Smrg cat <<EOF 43103e6c936aSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 4311521070a0SmrgEOF 4312521070a0Smrg else 4313521070a0Smrg cat <<"EOF" 4314521070a0Smrgconst char * LIB_PATH_VALUE = ""; 4315521070a0SmrgEOF 43164456fccdSmrg fi 43174456fccdSmrg 4318521070a0Smrg if test -n "$dllsearchpath"; then 43193e6c936aSmrg func_to_host_path "$dllsearchpath:" 4320521070a0Smrg cat <<EOF 4321521070a0Smrgconst char * EXE_PATH_VARNAME = "PATH"; 43223e6c936aSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 43234456fccdSmrgEOF 43244456fccdSmrg else 4325521070a0Smrg cat <<"EOF" 4326521070a0Smrgconst char * EXE_PATH_VARNAME = ""; 4327521070a0Smrgconst char * EXE_PATH_VALUE = ""; 4328521070a0SmrgEOF 43294456fccdSmrg fi 4330521070a0Smrg 4331521070a0Smrg if test "$fast_install" = yes; then 4332521070a0Smrg cat <<EOF 4333521070a0Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 4334521070a0SmrgEOF 43354456fccdSmrg else 4336521070a0Smrg cat <<EOF 4337521070a0Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 4338521070a0SmrgEOF 43394456fccdSmrg fi 43404456fccdSmrg 43414456fccdSmrg 4342521070a0Smrg cat <<"EOF" 43434456fccdSmrg 4344521070a0Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 43454456fccdSmrg 4346521070a0Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 4347521070a0Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 4348ff63a143Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 43494456fccdSmrg 4350521070a0Smrgint 4351521070a0Smrgmain (int argc, char *argv[]) 4352521070a0Smrg{ 4353521070a0Smrg char **newargz; 4354521070a0Smrg int newargc; 4355521070a0Smrg char *tmp_pathspec; 4356521070a0Smrg char *actual_cwrapper_path; 4357521070a0Smrg char *actual_cwrapper_name; 4358521070a0Smrg char *target_name; 4359521070a0Smrg char *lt_argv_zero; 4360521070a0Smrg intptr_t rval = 127; 43614456fccdSmrg 4362521070a0Smrg int i; 43634456fccdSmrg 4364521070a0Smrg program_name = (char *) xstrdup (base_name (argv[0])); 4365ff63a143Smrg newargz = XMALLOC (char *, argc + 1); 43664456fccdSmrg 4367ff63a143Smrg /* very simple arg parsing; don't want to rely on getopt 4368ff63a143Smrg * also, copy all non cwrapper options to newargz, except 4369ff63a143Smrg * argz[0], which is handled differently 4370ff63a143Smrg */ 4371ff63a143Smrg newargc=0; 4372521070a0Smrg for (i = 1; i < argc; i++) 4373521070a0Smrg { 4374521070a0Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 4375521070a0Smrg { 4376521070a0SmrgEOF 4377521070a0Smrg case "$host" in 4378521070a0Smrg *mingw* | *cygwin* ) 4379521070a0Smrg # make stdout use "unix" line endings 4380521070a0Smrg echo " setmode(1,_O_BINARY);" 4381521070a0Smrg ;; 4382521070a0Smrg esac 43834456fccdSmrg 4384521070a0Smrg cat <<"EOF" 4385ff63a143Smrg lt_dump_script (stdout); 4386521070a0Smrg return 0; 4387521070a0Smrg } 4388ff63a143Smrg if (strcmp (argv[i], debug_opt) == 0) 4389ff63a143Smrg { 4390ff63a143Smrg lt_debug = 1; 4391ff63a143Smrg continue; 4392ff63a143Smrg } 4393ff63a143Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 4394ff63a143Smrg { 4395ff63a143Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 4396ff63a143Smrg namespace, but it is not one of the ones we know about and 4397ff63a143Smrg have already dealt with, above (inluding dump-script), then 4398ff63a143Smrg report an error. Otherwise, targets might begin to believe 4399ff63a143Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 4400ff63a143Smrg namespace. The first time any user complains about this, we'll 4401ff63a143Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 4402ff63a143Smrg or a configure.ac-settable value. 4403ff63a143Smrg */ 4404ff63a143Smrg lt_fatal (__FILE__, __LINE__, 4405ff63a143Smrg "unrecognized %s option: '%s'", 4406ff63a143Smrg ltwrapper_option_prefix, argv[i]); 4407ff63a143Smrg } 4408ff63a143Smrg /* otherwise ... */ 4409ff63a143Smrg newargz[++newargc] = xstrdup (argv[i]); 4410521070a0Smrg } 4411ff63a143Smrg newargz[++newargc] = NULL; 4412ff63a143Smrg 4413ff63a143SmrgEOF 4414ff63a143Smrg cat <<EOF 4415ff63a143Smrg /* The GNU banner must be the first non-error debug message */ 4416ff63a143Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 4417ff63a143SmrgEOF 4418ff63a143Smrg cat <<"EOF" 4419ff63a143Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 4420ff63a143Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 44214456fccdSmrg 4422521070a0Smrg tmp_pathspec = find_executable (argv[0]); 4423521070a0Smrg if (tmp_pathspec == NULL) 4424ff63a143Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 4425ff63a143Smrg lt_debugprintf (__FILE__, __LINE__, 4426ff63a143Smrg "(main) found exe (before symlink chase) at: %s\n", 4427ff63a143Smrg tmp_pathspec); 4428521070a0Smrg 4429521070a0Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 4430ff63a143Smrg lt_debugprintf (__FILE__, __LINE__, 4431ff63a143Smrg "(main) found exe (after symlink chase) at: %s\n", 4432ff63a143Smrg actual_cwrapper_path); 4433521070a0Smrg XFREE (tmp_pathspec); 4434521070a0Smrg 4435ff63a143Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 4436521070a0Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 4437521070a0Smrg 4438521070a0Smrg /* wrapper name transforms */ 4439521070a0Smrg strendzap (actual_cwrapper_name, ".exe"); 4440521070a0Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 4441521070a0Smrg XFREE (actual_cwrapper_name); 4442521070a0Smrg actual_cwrapper_name = tmp_pathspec; 4443521070a0Smrg tmp_pathspec = 0; 4444521070a0Smrg 4445521070a0Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 4446521070a0Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 4447521070a0Smrg strendzap (target_name, ".exe"); 4448521070a0Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 4449521070a0Smrg XFREE (target_name); 4450521070a0Smrg target_name = tmp_pathspec; 4451521070a0Smrg tmp_pathspec = 0; 4452521070a0Smrg 4453ff63a143Smrg lt_debugprintf (__FILE__, __LINE__, 4454ff63a143Smrg "(main) libtool target name: %s\n", 4455ff63a143Smrg target_name); 4456521070a0SmrgEOF 44574456fccdSmrg 4458521070a0Smrg cat <<EOF 4459521070a0Smrg newargz[0] = 4460521070a0Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 4461521070a0Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 4462521070a0Smrg strcpy (newargz[0], actual_cwrapper_path); 4463521070a0Smrg strcat (newargz[0], "$objdir"); 4464521070a0Smrg strcat (newargz[0], "/"); 4465521070a0SmrgEOF 44664456fccdSmrg 4467521070a0Smrg cat <<"EOF" 4468521070a0Smrg /* stop here, and copy so we don't have to do this twice */ 4469521070a0Smrg tmp_pathspec = xstrdup (newargz[0]); 44704456fccdSmrg 4471521070a0Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 4472521070a0Smrg strcat (newargz[0], actual_cwrapper_name); 44734456fccdSmrg 4474521070a0Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 4475521070a0Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 4476521070a0Smrg XFREE (tmp_pathspec); 4477521070a0Smrg tmp_pathspec = NULL; 4478521070a0SmrgEOF 44794456fccdSmrg 4480521070a0Smrg case $host_os in 4481521070a0Smrg mingw*) 4482521070a0Smrg cat <<"EOF" 4483521070a0Smrg { 4484521070a0Smrg char* p; 4485521070a0Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 4486521070a0Smrg { 4487521070a0Smrg *p = '/'; 4488521070a0Smrg } 4489521070a0Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 4490521070a0Smrg { 4491521070a0Smrg *p = '/'; 4492521070a0Smrg } 4493521070a0Smrg } 4494521070a0SmrgEOF 4495521070a0Smrg ;; 4496521070a0Smrg esac 44974456fccdSmrg 4498521070a0Smrg cat <<"EOF" 4499521070a0Smrg XFREE (target_name); 4500521070a0Smrg XFREE (actual_cwrapper_path); 4501521070a0Smrg XFREE (actual_cwrapper_name); 45024456fccdSmrg 4503521070a0Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 4504521070a0Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 45053e6c936aSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 45063e6c936aSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 45073e6c936aSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 45083e6c936aSmrg libraries must come first. */ 4509521070a0Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 45103e6c936aSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 45114456fccdSmrg 4512ff63a143Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 4513ff63a143Smrg nonnull (lt_argv_zero)); 4514521070a0Smrg for (i = 0; i < newargc; i++) 4515521070a0Smrg { 4516ff63a143Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 4517ff63a143Smrg i, nonnull (newargz[i])); 4518521070a0Smrg } 45194456fccdSmrg 4520521070a0SmrgEOF 45214456fccdSmrg 4522521070a0Smrg case $host_os in 4523521070a0Smrg mingw*) 4524521070a0Smrg cat <<"EOF" 4525521070a0Smrg /* execv doesn't actually work on mingw as expected on unix */ 4526ff63a143Smrg newargz = prepare_spawn (newargz); 4527521070a0Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 4528521070a0Smrg if (rval == -1) 4529521070a0Smrg { 4530521070a0Smrg /* failed to start process */ 4531ff63a143Smrg lt_debugprintf (__FILE__, __LINE__, 4532ff63a143Smrg "(main) failed to launch target \"%s\": %s\n", 4533ff63a143Smrg lt_argv_zero, nonnull (strerror (errno))); 4534521070a0Smrg return 127; 4535521070a0Smrg } 4536521070a0Smrg return rval; 4537521070a0SmrgEOF 4538521070a0Smrg ;; 4539521070a0Smrg *) 4540521070a0Smrg cat <<"EOF" 4541521070a0Smrg execv (lt_argv_zero, newargz); 4542521070a0Smrg return rval; /* =127, but avoids unused variable warning */ 4543521070a0SmrgEOF 4544521070a0Smrg ;; 4545521070a0Smrg esac 45464456fccdSmrg 4547521070a0Smrg cat <<"EOF" 4548521070a0Smrg} 45494456fccdSmrg 4550521070a0Smrgvoid * 4551521070a0Smrgxmalloc (size_t num) 4552521070a0Smrg{ 4553521070a0Smrg void *p = (void *) malloc (num); 4554521070a0Smrg if (!p) 4555ff63a143Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 45564456fccdSmrg 4557521070a0Smrg return p; 4558521070a0Smrg} 45594456fccdSmrg 4560521070a0Smrgchar * 4561521070a0Smrgxstrdup (const char *string) 4562521070a0Smrg{ 4563521070a0Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 4564521070a0Smrg string) : NULL; 4565521070a0Smrg} 45664456fccdSmrg 4567521070a0Smrgconst char * 4568521070a0Smrgbase_name (const char *name) 4569521070a0Smrg{ 4570521070a0Smrg const char *base; 45714456fccdSmrg 4572521070a0Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4573521070a0Smrg /* Skip over the disk name in MSDOS pathnames. */ 4574521070a0Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 4575521070a0Smrg name += 2; 4576521070a0Smrg#endif 45774456fccdSmrg 4578521070a0Smrg for (base = name; *name; name++) 4579521070a0Smrg if (IS_DIR_SEPARATOR (*name)) 4580521070a0Smrg base = name + 1; 4581521070a0Smrg return base; 4582521070a0Smrg} 45834456fccdSmrg 4584521070a0Smrgint 4585521070a0Smrgcheck_executable (const char *path) 4586521070a0Smrg{ 4587521070a0Smrg struct stat st; 45884456fccdSmrg 4589ff63a143Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 4590ff63a143Smrg nonempty (path)); 4591521070a0Smrg if ((!path) || (!*path)) 4592521070a0Smrg return 0; 45934456fccdSmrg 4594521070a0Smrg if ((stat (path, &st) >= 0) 4595521070a0Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 4596521070a0Smrg return 1; 4597521070a0Smrg else 4598521070a0Smrg return 0; 4599521070a0Smrg} 46004456fccdSmrg 4601521070a0Smrgint 4602521070a0Smrgmake_executable (const char *path) 4603521070a0Smrg{ 4604521070a0Smrg int rval = 0; 4605521070a0Smrg struct stat st; 46064456fccdSmrg 4607ff63a143Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 4608ff63a143Smrg nonempty (path)); 4609521070a0Smrg if ((!path) || (!*path)) 4610521070a0Smrg return 0; 46114456fccdSmrg 4612521070a0Smrg if (stat (path, &st) >= 0) 4613521070a0Smrg { 4614521070a0Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 4615521070a0Smrg } 4616521070a0Smrg return rval; 4617521070a0Smrg} 46184456fccdSmrg 4619521070a0Smrg/* Searches for the full path of the wrapper. Returns 4620521070a0Smrg newly allocated full path name if found, NULL otherwise 4621521070a0Smrg Does not chase symlinks, even on platforms that support them. 4622521070a0Smrg*/ 4623521070a0Smrgchar * 4624521070a0Smrgfind_executable (const char *wrapper) 4625521070a0Smrg{ 4626521070a0Smrg int has_slash = 0; 4627521070a0Smrg const char *p; 4628521070a0Smrg const char *p_next; 4629521070a0Smrg /* static buffer for getcwd */ 4630521070a0Smrg char tmp[LT_PATHMAX + 1]; 4631521070a0Smrg int tmp_len; 4632521070a0Smrg char *concat_name; 46334456fccdSmrg 4634ff63a143Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 4635ff63a143Smrg nonempty (wrapper)); 46364456fccdSmrg 4637521070a0Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 4638521070a0Smrg return NULL; 46394456fccdSmrg 4640521070a0Smrg /* Absolute path? */ 4641521070a0Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4642521070a0Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 4643521070a0Smrg { 4644521070a0Smrg concat_name = xstrdup (wrapper); 4645521070a0Smrg if (check_executable (concat_name)) 4646521070a0Smrg return concat_name; 4647521070a0Smrg XFREE (concat_name); 4648521070a0Smrg } 4649521070a0Smrg else 4650521070a0Smrg { 4651521070a0Smrg#endif 4652521070a0Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 4653521070a0Smrg { 4654521070a0Smrg concat_name = xstrdup (wrapper); 4655521070a0Smrg if (check_executable (concat_name)) 4656521070a0Smrg return concat_name; 4657521070a0Smrg XFREE (concat_name); 4658521070a0Smrg } 4659521070a0Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4660521070a0Smrg } 4661521070a0Smrg#endif 46624456fccdSmrg 4663521070a0Smrg for (p = wrapper; *p; p++) 4664521070a0Smrg if (*p == '/') 4665521070a0Smrg { 4666521070a0Smrg has_slash = 1; 4667521070a0Smrg break; 4668521070a0Smrg } 4669521070a0Smrg if (!has_slash) 4670521070a0Smrg { 4671521070a0Smrg /* no slashes; search PATH */ 4672521070a0Smrg const char *path = getenv ("PATH"); 4673521070a0Smrg if (path != NULL) 4674521070a0Smrg { 4675521070a0Smrg for (p = path; *p; p = p_next) 4676521070a0Smrg { 4677521070a0Smrg const char *q; 4678521070a0Smrg size_t p_len; 4679521070a0Smrg for (q = p; *q; q++) 4680521070a0Smrg if (IS_PATH_SEPARATOR (*q)) 4681521070a0Smrg break; 4682521070a0Smrg p_len = q - p; 4683521070a0Smrg p_next = (*q == '\0' ? q : q + 1); 4684521070a0Smrg if (p_len == 0) 4685521070a0Smrg { 4686521070a0Smrg /* empty path: current directory */ 4687521070a0Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 4688ff63a143Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4689ff63a143Smrg nonnull (strerror (errno))); 4690521070a0Smrg tmp_len = strlen (tmp); 4691521070a0Smrg concat_name = 4692521070a0Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4693521070a0Smrg memcpy (concat_name, tmp, tmp_len); 4694521070a0Smrg concat_name[tmp_len] = '/'; 4695521070a0Smrg strcpy (concat_name + tmp_len + 1, wrapper); 4696521070a0Smrg } 4697521070a0Smrg else 4698521070a0Smrg { 4699521070a0Smrg concat_name = 4700521070a0Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 4701521070a0Smrg memcpy (concat_name, p, p_len); 4702521070a0Smrg concat_name[p_len] = '/'; 4703521070a0Smrg strcpy (concat_name + p_len + 1, wrapper); 4704521070a0Smrg } 4705521070a0Smrg if (check_executable (concat_name)) 4706521070a0Smrg return concat_name; 4707521070a0Smrg XFREE (concat_name); 4708521070a0Smrg } 4709521070a0Smrg } 4710521070a0Smrg /* not found in PATH; assume curdir */ 4711521070a0Smrg } 4712521070a0Smrg /* Relative path | not found in path: prepend cwd */ 4713521070a0Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 4714ff63a143Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4715ff63a143Smrg nonnull (strerror (errno))); 4716521070a0Smrg tmp_len = strlen (tmp); 4717521070a0Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4718521070a0Smrg memcpy (concat_name, tmp, tmp_len); 4719521070a0Smrg concat_name[tmp_len] = '/'; 4720521070a0Smrg strcpy (concat_name + tmp_len + 1, wrapper); 47214456fccdSmrg 4722521070a0Smrg if (check_executable (concat_name)) 4723521070a0Smrg return concat_name; 4724521070a0Smrg XFREE (concat_name); 4725521070a0Smrg return NULL; 4726521070a0Smrg} 47274456fccdSmrg 4728521070a0Smrgchar * 4729521070a0Smrgchase_symlinks (const char *pathspec) 4730521070a0Smrg{ 4731521070a0Smrg#ifndef S_ISLNK 4732521070a0Smrg return xstrdup (pathspec); 4733521070a0Smrg#else 4734521070a0Smrg char buf[LT_PATHMAX]; 4735521070a0Smrg struct stat s; 4736521070a0Smrg char *tmp_pathspec = xstrdup (pathspec); 4737521070a0Smrg char *p; 4738521070a0Smrg int has_symlinks = 0; 4739521070a0Smrg while (strlen (tmp_pathspec) && !has_symlinks) 4740521070a0Smrg { 4741ff63a143Smrg lt_debugprintf (__FILE__, __LINE__, 4742ff63a143Smrg "checking path component for symlinks: %s\n", 4743ff63a143Smrg tmp_pathspec); 4744521070a0Smrg if (lstat (tmp_pathspec, &s) == 0) 4745521070a0Smrg { 4746521070a0Smrg if (S_ISLNK (s.st_mode) != 0) 4747521070a0Smrg { 4748521070a0Smrg has_symlinks = 1; 4749521070a0Smrg break; 4750521070a0Smrg } 47514456fccdSmrg 4752521070a0Smrg /* search backwards for last DIR_SEPARATOR */ 4753521070a0Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 4754521070a0Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4755521070a0Smrg p--; 4756521070a0Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4757521070a0Smrg { 4758521070a0Smrg /* no more DIR_SEPARATORS left */ 4759521070a0Smrg break; 4760521070a0Smrg } 4761521070a0Smrg *p = '\0'; 4762521070a0Smrg } 4763521070a0Smrg else 4764521070a0Smrg { 4765ff63a143Smrg lt_fatal (__FILE__, __LINE__, 4766ff63a143Smrg "error accessing file \"%s\": %s", 4767ff63a143Smrg tmp_pathspec, nonnull (strerror (errno))); 4768521070a0Smrg } 4769521070a0Smrg } 4770521070a0Smrg XFREE (tmp_pathspec); 47714456fccdSmrg 4772521070a0Smrg if (!has_symlinks) 4773521070a0Smrg { 4774521070a0Smrg return xstrdup (pathspec); 4775521070a0Smrg } 47764456fccdSmrg 4777521070a0Smrg tmp_pathspec = realpath (pathspec, buf); 4778521070a0Smrg if (tmp_pathspec == 0) 4779521070a0Smrg { 4780ff63a143Smrg lt_fatal (__FILE__, __LINE__, 4781ff63a143Smrg "could not follow symlinks for %s", pathspec); 4782521070a0Smrg } 4783521070a0Smrg return xstrdup (tmp_pathspec); 4784521070a0Smrg#endif 4785521070a0Smrg} 47864456fccdSmrg 4787521070a0Smrgchar * 4788521070a0Smrgstrendzap (char *str, const char *pat) 4789521070a0Smrg{ 4790521070a0Smrg size_t len, patlen; 47914456fccdSmrg 4792521070a0Smrg assert (str != NULL); 4793521070a0Smrg assert (pat != NULL); 47944456fccdSmrg 4795521070a0Smrg len = strlen (str); 4796521070a0Smrg patlen = strlen (pat); 47974456fccdSmrg 4798521070a0Smrg if (patlen <= len) 4799521070a0Smrg { 4800521070a0Smrg str += len - patlen; 4801521070a0Smrg if (strcmp (str, pat) == 0) 4802521070a0Smrg *str = '\0'; 4803521070a0Smrg } 4804521070a0Smrg return str; 4805521070a0Smrg} 48064456fccdSmrg 4807ff63a143Smrgvoid 4808ff63a143Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 4809ff63a143Smrg{ 4810ff63a143Smrg va_list args; 4811ff63a143Smrg if (lt_debug) 4812ff63a143Smrg { 4813ff63a143Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 4814ff63a143Smrg va_start (args, fmt); 4815ff63a143Smrg (void) vfprintf (stderr, fmt, args); 4816ff63a143Smrg va_end (args); 4817ff63a143Smrg } 4818ff63a143Smrg} 4819ff63a143Smrg 4820521070a0Smrgstatic void 4821ff63a143Smrglt_error_core (int exit_status, const char *file, 4822ff63a143Smrg int line, const char *mode, 4823521070a0Smrg const char *message, va_list ap) 4824521070a0Smrg{ 4825ff63a143Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 4826521070a0Smrg vfprintf (stderr, message, ap); 4827521070a0Smrg fprintf (stderr, ".\n"); 48284456fccdSmrg 4829521070a0Smrg if (exit_status >= 0) 4830521070a0Smrg exit (exit_status); 4831521070a0Smrg} 48324456fccdSmrg 4833521070a0Smrgvoid 4834ff63a143Smrglt_fatal (const char *file, int line, const char *message, ...) 4835521070a0Smrg{ 4836521070a0Smrg va_list ap; 4837521070a0Smrg va_start (ap, message); 4838ff63a143Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 4839521070a0Smrg va_end (ap); 4840521070a0Smrg} 48414456fccdSmrg 4842ff63a143Smrgstatic const char * 4843ff63a143Smrgnonnull (const char *s) 4844ff63a143Smrg{ 4845ff63a143Smrg return s ? s : "(null)"; 4846ff63a143Smrg} 4847ff63a143Smrg 4848ff63a143Smrgstatic const char * 4849ff63a143Smrgnonempty (const char *s) 4850ff63a143Smrg{ 4851ff63a143Smrg return (s && !*s) ? "(empty)" : nonnull (s); 4852ff63a143Smrg} 4853ff63a143Smrg 4854521070a0Smrgvoid 4855521070a0Smrglt_setenv (const char *name, const char *value) 4856521070a0Smrg{ 4857ff63a143Smrg lt_debugprintf (__FILE__, __LINE__, 4858ff63a143Smrg "(lt_setenv) setting '%s' to '%s'\n", 4859ff63a143Smrg nonnull (name), nonnull (value)); 4860521070a0Smrg { 4861521070a0Smrg#ifdef HAVE_SETENV 4862521070a0Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 4863521070a0Smrg char *str = xstrdup (value); 4864521070a0Smrg setenv (name, str, 1); 4865521070a0Smrg#else 4866521070a0Smrg int len = strlen (name) + 1 + strlen (value) + 1; 4867521070a0Smrg char *str = XMALLOC (char, len); 4868521070a0Smrg sprintf (str, "%s=%s", name, value); 4869521070a0Smrg if (putenv (str) != EXIT_SUCCESS) 4870521070a0Smrg { 4871521070a0Smrg XFREE (str); 4872521070a0Smrg } 4873521070a0Smrg#endif 4874521070a0Smrg } 4875521070a0Smrg} 48764456fccdSmrg 4877521070a0Smrgchar * 4878521070a0Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 4879521070a0Smrg{ 4880521070a0Smrg char *new_value; 4881521070a0Smrg if (orig_value && *orig_value) 4882521070a0Smrg { 4883521070a0Smrg int orig_value_len = strlen (orig_value); 4884521070a0Smrg int add_len = strlen (add); 4885521070a0Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 4886521070a0Smrg if (to_end) 4887521070a0Smrg { 4888521070a0Smrg strcpy (new_value, orig_value); 4889521070a0Smrg strcpy (new_value + orig_value_len, add); 4890521070a0Smrg } 4891521070a0Smrg else 4892521070a0Smrg { 4893521070a0Smrg strcpy (new_value, add); 4894521070a0Smrg strcpy (new_value + add_len, orig_value); 4895521070a0Smrg } 4896521070a0Smrg } 4897521070a0Smrg else 4898521070a0Smrg { 4899521070a0Smrg new_value = xstrdup (add); 4900521070a0Smrg } 4901521070a0Smrg return new_value; 4902521070a0Smrg} 49034456fccdSmrg 4904521070a0Smrgvoid 4905521070a0Smrglt_update_exe_path (const char *name, const char *value) 4906521070a0Smrg{ 4907ff63a143Smrg lt_debugprintf (__FILE__, __LINE__, 4908ff63a143Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 4909ff63a143Smrg nonnull (name), nonnull (value)); 49104456fccdSmrg 4911521070a0Smrg if (name && *name && value && *value) 4912521070a0Smrg { 4913521070a0Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 4914521070a0Smrg /* some systems can't cope with a ':'-terminated path #' */ 4915521070a0Smrg int len = strlen (new_value); 4916521070a0Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 4917521070a0Smrg { 4918521070a0Smrg new_value[len-1] = '\0'; 4919521070a0Smrg } 4920521070a0Smrg lt_setenv (name, new_value); 4921521070a0Smrg XFREE (new_value); 4922521070a0Smrg } 4923521070a0Smrg} 49244456fccdSmrg 4925521070a0Smrgvoid 4926521070a0Smrglt_update_lib_path (const char *name, const char *value) 4927521070a0Smrg{ 4928ff63a143Smrg lt_debugprintf (__FILE__, __LINE__, 4929ff63a143Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 4930ff63a143Smrg nonnull (name), nonnull (value)); 49314456fccdSmrg 4932521070a0Smrg if (name && *name && value && *value) 4933521070a0Smrg { 4934521070a0Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 4935521070a0Smrg lt_setenv (name, new_value); 4936521070a0Smrg XFREE (new_value); 4937521070a0Smrg } 4938521070a0Smrg} 49394456fccdSmrg 4940ff63a143SmrgEOF 4941ff63a143Smrg case $host_os in 4942ff63a143Smrg mingw*) 4943ff63a143Smrg cat <<"EOF" 4944ff63a143Smrg 4945ff63a143Smrg/* Prepares an argument vector before calling spawn(). 4946ff63a143Smrg Note that spawn() does not by itself call the command interpreter 4947ff63a143Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 4948ff63a143Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 4949ff63a143Smrg GetVersionEx(&v); 4950ff63a143Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 4951ff63a143Smrg }) ? "cmd.exe" : "command.com"). 4952ff63a143Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 4953ff63a143Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 4954ff63a143Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 4955ff63a143Smrg special way: 4956ff63a143Smrg - Space and tab are interpreted as delimiters. They are not treated as 4957ff63a143Smrg delimiters if they are surrounded by double quotes: "...". 4958ff63a143Smrg - Unescaped double quotes are removed from the input. Their only effect is 4959ff63a143Smrg that within double quotes, space and tab are treated like normal 4960ff63a143Smrg characters. 4961ff63a143Smrg - Backslashes not followed by double quotes are not special. 4962ff63a143Smrg - But 2*n+1 backslashes followed by a double quote become 4963ff63a143Smrg n backslashes followed by a double quote (n >= 0): 4964ff63a143Smrg \" -> " 4965ff63a143Smrg \\\" -> \" 4966ff63a143Smrg \\\\\" -> \\" 4967ff63a143Smrg */ 4968ff63a143Smrg#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" 4969ff63a143Smrg#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" 4970ff63a143Smrgchar ** 4971ff63a143Smrgprepare_spawn (char **argv) 4972ff63a143Smrg{ 4973ff63a143Smrg size_t argc; 4974ff63a143Smrg char **new_argv; 4975ff63a143Smrg size_t i; 4976ff63a143Smrg 4977ff63a143Smrg /* Count number of arguments. */ 4978ff63a143Smrg for (argc = 0; argv[argc] != NULL; argc++) 4979ff63a143Smrg ; 4980ff63a143Smrg 4981ff63a143Smrg /* Allocate new argument vector. */ 4982ff63a143Smrg new_argv = XMALLOC (char *, argc + 1); 4983ff63a143Smrg 4984ff63a143Smrg /* Put quoted arguments into the new argument vector. */ 4985ff63a143Smrg for (i = 0; i < argc; i++) 4986ff63a143Smrg { 4987ff63a143Smrg const char *string = argv[i]; 4988ff63a143Smrg 4989ff63a143Smrg if (string[0] == '\0') 4990ff63a143Smrg new_argv[i] = xstrdup ("\"\""); 4991ff63a143Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 4992ff63a143Smrg { 4993ff63a143Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 4994ff63a143Smrg size_t length; 4995ff63a143Smrg unsigned int backslashes; 4996ff63a143Smrg const char *s; 4997ff63a143Smrg char *quoted_string; 4998ff63a143Smrg char *p; 4999ff63a143Smrg 5000ff63a143Smrg length = 0; 5001ff63a143Smrg backslashes = 0; 5002ff63a143Smrg if (quote_around) 5003ff63a143Smrg length++; 5004ff63a143Smrg for (s = string; *s != '\0'; s++) 5005ff63a143Smrg { 5006ff63a143Smrg char c = *s; 5007ff63a143Smrg if (c == '"') 5008ff63a143Smrg length += backslashes + 1; 5009ff63a143Smrg length++; 5010ff63a143Smrg if (c == '\\') 5011ff63a143Smrg backslashes++; 5012ff63a143Smrg else 5013ff63a143Smrg backslashes = 0; 5014ff63a143Smrg } 5015ff63a143Smrg if (quote_around) 5016ff63a143Smrg length += backslashes + 1; 5017ff63a143Smrg 5018ff63a143Smrg quoted_string = XMALLOC (char, length + 1); 5019ff63a143Smrg 5020ff63a143Smrg p = quoted_string; 5021ff63a143Smrg backslashes = 0; 5022ff63a143Smrg if (quote_around) 5023ff63a143Smrg *p++ = '"'; 5024ff63a143Smrg for (s = string; *s != '\0'; s++) 5025ff63a143Smrg { 5026ff63a143Smrg char c = *s; 5027ff63a143Smrg if (c == '"') 5028ff63a143Smrg { 5029ff63a143Smrg unsigned int j; 5030ff63a143Smrg for (j = backslashes + 1; j > 0; j--) 5031ff63a143Smrg *p++ = '\\'; 5032ff63a143Smrg } 5033ff63a143Smrg *p++ = c; 5034ff63a143Smrg if (c == '\\') 5035ff63a143Smrg backslashes++; 5036ff63a143Smrg else 5037ff63a143Smrg backslashes = 0; 5038ff63a143Smrg } 5039ff63a143Smrg if (quote_around) 5040ff63a143Smrg { 5041ff63a143Smrg unsigned int j; 5042ff63a143Smrg for (j = backslashes; j > 0; j--) 5043ff63a143Smrg *p++ = '\\'; 5044ff63a143Smrg *p++ = '"'; 5045ff63a143Smrg } 5046ff63a143Smrg *p = '\0'; 5047ff63a143Smrg 5048ff63a143Smrg new_argv[i] = quoted_string; 5049ff63a143Smrg } 5050ff63a143Smrg else 5051ff63a143Smrg new_argv[i] = (char *) string; 5052ff63a143Smrg } 5053ff63a143Smrg new_argv[argc] = NULL; 5054ff63a143Smrg 5055ff63a143Smrg return new_argv; 5056ff63a143Smrg} 5057ff63a143SmrgEOF 5058ff63a143Smrg ;; 5059ff63a143Smrg esac 5060ff63a143Smrg 5061ff63a143Smrg cat <<"EOF" 5062ff63a143Smrgvoid lt_dump_script (FILE* f) 5063ff63a143Smrg{ 5064ff63a143SmrgEOF 5065ff63a143Smrg func_emit_wrapper yes | 50663e6c936aSmrg $SED -n -e ' 50673e6c936aSmrgs/^\(.\{79\}\)\(..*\)/\1\ 50683e6c936aSmrg\2/ 50693e6c936aSmrgh 50703e6c936aSmrgs/\([\\"]\)/\\\1/g 50713e6c936aSmrgs/$/\\n/ 50723e6c936aSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 50733e6c936aSmrgg 50743e6c936aSmrgD' 5075ff63a143Smrg cat <<"EOF" 5076ff63a143Smrg} 5077521070a0SmrgEOF 5078521070a0Smrg} 5079521070a0Smrg# end: func_emit_cwrapperexe_src 50804456fccdSmrg 5081ff63a143Smrg# func_win32_import_lib_p ARG 5082ff63a143Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 5083ff63a143Smrgfunc_win32_import_lib_p () 5084ff63a143Smrg{ 5085ff63a143Smrg $opt_debug 5086ff63a143Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 5087ff63a143Smrg *import*) : ;; 5088ff63a143Smrg *) false ;; 5089ff63a143Smrg esac 5090ff63a143Smrg} 5091ff63a143Smrg 5092521070a0Smrg# func_mode_link arg... 5093521070a0Smrgfunc_mode_link () 5094521070a0Smrg{ 5095521070a0Smrg $opt_debug 5096521070a0Smrg case $host in 5097521070a0Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5098521070a0Smrg # It is impossible to link a dll without this setting, and 5099521070a0Smrg # we shouldn't force the makefile maintainer to figure out 5100521070a0Smrg # which system we are compiling for in order to pass an extra 5101521070a0Smrg # flag for every libtool invocation. 5102521070a0Smrg # allow_undefined=no 51034456fccdSmrg 5104521070a0Smrg # FIXME: Unfortunately, there are problems with the above when trying 5105521070a0Smrg # to make a dll which has undefined symbols, in which case not 5106521070a0Smrg # even a static library is built. For now, we need to specify 5107521070a0Smrg # -no-undefined on the libtool link line when we can be certain 5108521070a0Smrg # that all symbols are satisfied, otherwise we get a static library. 5109521070a0Smrg allow_undefined=yes 5110521070a0Smrg ;; 5111521070a0Smrg *) 5112521070a0Smrg allow_undefined=yes 5113521070a0Smrg ;; 5114521070a0Smrg esac 5115521070a0Smrg libtool_args=$nonopt 5116521070a0Smrg base_compile="$nonopt $@" 5117521070a0Smrg compile_command=$nonopt 5118521070a0Smrg finalize_command=$nonopt 51194456fccdSmrg 5120521070a0Smrg compile_rpath= 5121521070a0Smrg finalize_rpath= 5122521070a0Smrg compile_shlibpath= 5123521070a0Smrg finalize_shlibpath= 5124521070a0Smrg convenience= 5125521070a0Smrg old_convenience= 5126521070a0Smrg deplibs= 5127521070a0Smrg old_deplibs= 5128521070a0Smrg compiler_flags= 5129521070a0Smrg linker_flags= 5130521070a0Smrg dllsearchpath= 5131521070a0Smrg lib_search_path=`pwd` 5132521070a0Smrg inst_prefix_dir= 5133521070a0Smrg new_inherited_linker_flags= 51344456fccdSmrg 5135521070a0Smrg avoid_version=no 5136ff63a143Smrg bindir= 5137521070a0Smrg dlfiles= 5138521070a0Smrg dlprefiles= 5139521070a0Smrg dlself=no 5140521070a0Smrg export_dynamic=no 5141521070a0Smrg export_symbols= 5142521070a0Smrg export_symbols_regex= 5143521070a0Smrg generated= 5144521070a0Smrg libobjs= 5145521070a0Smrg ltlibs= 5146521070a0Smrg module=no 5147521070a0Smrg no_install=no 5148521070a0Smrg objs= 5149521070a0Smrg non_pic_objects= 5150521070a0Smrg precious_files_regex= 5151521070a0Smrg prefer_static_libs=no 5152521070a0Smrg preload=no 5153521070a0Smrg prev= 5154521070a0Smrg prevarg= 5155521070a0Smrg release= 5156521070a0Smrg rpath= 5157521070a0Smrg xrpath= 5158521070a0Smrg perm_rpath= 5159521070a0Smrg temp_rpath= 5160521070a0Smrg thread_safe=no 5161521070a0Smrg vinfo= 5162521070a0Smrg vinfo_number=no 5163521070a0Smrg weak_libs= 5164521070a0Smrg single_module="${wl}-single_module" 5165521070a0Smrg func_infer_tag $base_compile 5166521070a0Smrg 5167521070a0Smrg # We need to know -static, to get the right output filenames. 5168521070a0Smrg for arg 5169521070a0Smrg do 5170521070a0Smrg case $arg in 5171521070a0Smrg -shared) 5172521070a0Smrg test "$build_libtool_libs" != yes && \ 5173521070a0Smrg func_fatal_configuration "can not build a shared library" 5174521070a0Smrg build_old_libs=no 5175521070a0Smrg break 5176521070a0Smrg ;; 5177521070a0Smrg -all-static | -static | -static-libtool-libs) 5178521070a0Smrg case $arg in 5179521070a0Smrg -all-static) 5180521070a0Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 5181521070a0Smrg func_warning "complete static linking is impossible in this configuration" 5182521070a0Smrg fi 5183521070a0Smrg if test -n "$link_static_flag"; then 5184521070a0Smrg dlopen_self=$dlopen_self_static 5185521070a0Smrg fi 5186521070a0Smrg prefer_static_libs=yes 5187521070a0Smrg ;; 5188521070a0Smrg -static) 5189521070a0Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 5190521070a0Smrg dlopen_self=$dlopen_self_static 5191521070a0Smrg fi 5192521070a0Smrg prefer_static_libs=built 5193521070a0Smrg ;; 5194521070a0Smrg -static-libtool-libs) 5195521070a0Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 5196521070a0Smrg dlopen_self=$dlopen_self_static 51974456fccdSmrg fi 5198521070a0Smrg prefer_static_libs=yes 5199521070a0Smrg ;; 5200521070a0Smrg esac 5201521070a0Smrg build_libtool_libs=no 5202521070a0Smrg build_old_libs=yes 5203521070a0Smrg break 5204521070a0Smrg ;; 5205521070a0Smrg esac 5206521070a0Smrg done 52074456fccdSmrg 5208521070a0Smrg # See if our shared archives depend on static archives. 5209521070a0Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 52104456fccdSmrg 5211521070a0Smrg # Go through the arguments, transforming them on the way. 5212521070a0Smrg while test "$#" -gt 0; do 5213521070a0Smrg arg="$1" 5214521070a0Smrg shift 5215521070a0Smrg func_quote_for_eval "$arg" 5216521070a0Smrg qarg=$func_quote_for_eval_unquoted_result 5217521070a0Smrg func_append libtool_args " $func_quote_for_eval_result" 52184456fccdSmrg 5219521070a0Smrg # If the previous option needs an argument, assign it. 5220521070a0Smrg if test -n "$prev"; then 5221521070a0Smrg case $prev in 5222521070a0Smrg output) 5223521070a0Smrg func_append compile_command " @OUTPUT@" 5224521070a0Smrg func_append finalize_command " @OUTPUT@" 5225521070a0Smrg ;; 5226521070a0Smrg esac 52274456fccdSmrg 5228521070a0Smrg case $prev in 5229ff63a143Smrg bindir) 5230ff63a143Smrg bindir="$arg" 5231ff63a143Smrg prev= 5232ff63a143Smrg continue 5233ff63a143Smrg ;; 5234521070a0Smrg dlfiles|dlprefiles) 5235521070a0Smrg if test "$preload" = no; then 5236521070a0Smrg # Add the symbol object into the linking commands. 5237521070a0Smrg func_append compile_command " @SYMFILE@" 5238521070a0Smrg func_append finalize_command " @SYMFILE@" 5239521070a0Smrg preload=yes 5240521070a0Smrg fi 5241521070a0Smrg case $arg in 5242521070a0Smrg *.la | *.lo) ;; # We handle these cases below. 5243521070a0Smrg force) 5244521070a0Smrg if test "$dlself" = no; then 5245521070a0Smrg dlself=needless 5246521070a0Smrg export_dynamic=yes 5247521070a0Smrg fi 5248521070a0Smrg prev= 5249521070a0Smrg continue 5250521070a0Smrg ;; 5251521070a0Smrg self) 5252521070a0Smrg if test "$prev" = dlprefiles; then 5253521070a0Smrg dlself=yes 5254521070a0Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 5255521070a0Smrg dlself=yes 52564456fccdSmrg else 5257521070a0Smrg dlself=needless 5258521070a0Smrg export_dynamic=yes 52594456fccdSmrg fi 5260521070a0Smrg prev= 5261521070a0Smrg continue 5262521070a0Smrg ;; 5263521070a0Smrg *) 5264521070a0Smrg if test "$prev" = dlfiles; then 52653e6c936aSmrg func_append dlfiles " $arg" 52664456fccdSmrg else 52673e6c936aSmrg func_append dlprefiles " $arg" 52684456fccdSmrg fi 5269521070a0Smrg prev= 5270521070a0Smrg continue 5271521070a0Smrg ;; 5272521070a0Smrg esac 5273521070a0Smrg ;; 5274521070a0Smrg expsyms) 5275521070a0Smrg export_symbols="$arg" 5276521070a0Smrg test -f "$arg" \ 5277521070a0Smrg || func_fatal_error "symbol file \`$arg' does not exist" 5278521070a0Smrg prev= 5279521070a0Smrg continue 5280521070a0Smrg ;; 5281521070a0Smrg expsyms_regex) 5282521070a0Smrg export_symbols_regex="$arg" 5283521070a0Smrg prev= 5284521070a0Smrg continue 5285521070a0Smrg ;; 5286521070a0Smrg framework) 52874456fccdSmrg case $host in 5288521070a0Smrg *-*-darwin*) 5289521070a0Smrg case "$deplibs " in 5290521070a0Smrg *" $qarg.ltframework "*) ;; 52913e6c936aSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 5292521070a0Smrg ;; 5293521070a0Smrg esac 5294521070a0Smrg ;; 52954456fccdSmrg esac 5296521070a0Smrg prev= 5297521070a0Smrg continue 52984456fccdSmrg ;; 5299521070a0Smrg inst_prefix) 5300521070a0Smrg inst_prefix_dir="$arg" 5301521070a0Smrg prev= 5302521070a0Smrg continue 53034456fccdSmrg ;; 5304521070a0Smrg objectlist) 5305521070a0Smrg if test -f "$arg"; then 5306521070a0Smrg save_arg=$arg 5307521070a0Smrg moreargs= 5308521070a0Smrg for fil in `cat "$save_arg"` 5309521070a0Smrg do 53103e6c936aSmrg# func_append moreargs " $fil" 5311521070a0Smrg arg=$fil 5312521070a0Smrg # A libtool-controlled object. 53134456fccdSmrg 5314521070a0Smrg # Check to see that this really is a libtool object. 5315521070a0Smrg if func_lalib_unsafe_p "$arg"; then 5316521070a0Smrg pic_object= 5317521070a0Smrg non_pic_object= 53184456fccdSmrg 5319521070a0Smrg # Read the .lo file 5320521070a0Smrg func_source "$arg" 53214456fccdSmrg 5322521070a0Smrg if test -z "$pic_object" || 5323521070a0Smrg test -z "$non_pic_object" || 5324521070a0Smrg test "$pic_object" = none && 5325521070a0Smrg test "$non_pic_object" = none; then 5326521070a0Smrg func_fatal_error "cannot find name of object for \`$arg'" 5327521070a0Smrg fi 53284456fccdSmrg 5329521070a0Smrg # Extract subdirectory from the argument. 5330521070a0Smrg func_dirname "$arg" "/" "" 5331521070a0Smrg xdir="$func_dirname_result" 53324456fccdSmrg 5333521070a0Smrg if test "$pic_object" != none; then 5334521070a0Smrg # Prepend the subdirectory the object is found in. 5335521070a0Smrg pic_object="$xdir$pic_object" 53364456fccdSmrg 5337521070a0Smrg if test "$prev" = dlfiles; then 5338521070a0Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 53393e6c936aSmrg func_append dlfiles " $pic_object" 5340521070a0Smrg prev= 5341521070a0Smrg continue 5342521070a0Smrg else 5343521070a0Smrg # If libtool objects are unsupported, then we need to preload. 5344521070a0Smrg prev=dlprefiles 5345521070a0Smrg fi 5346521070a0Smrg fi 53474456fccdSmrg 5348521070a0Smrg # CHECK ME: I think I busted this. -Ossama 5349521070a0Smrg if test "$prev" = dlprefiles; then 5350521070a0Smrg # Preload the old-style object. 53513e6c936aSmrg func_append dlprefiles " $pic_object" 5352521070a0Smrg prev= 5353521070a0Smrg fi 53544456fccdSmrg 5355521070a0Smrg # A PIC object. 5356521070a0Smrg func_append libobjs " $pic_object" 5357521070a0Smrg arg="$pic_object" 5358521070a0Smrg fi 53594456fccdSmrg 5360521070a0Smrg # Non-PIC object. 5361521070a0Smrg if test "$non_pic_object" != none; then 5362521070a0Smrg # Prepend the subdirectory the object is found in. 5363521070a0Smrg non_pic_object="$xdir$non_pic_object" 53644456fccdSmrg 5365521070a0Smrg # A standard non-PIC object 5366521070a0Smrg func_append non_pic_objects " $non_pic_object" 5367521070a0Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 5368521070a0Smrg arg="$non_pic_object" 5369521070a0Smrg fi 5370521070a0Smrg else 5371521070a0Smrg # If the PIC object exists, use it instead. 5372521070a0Smrg # $xdir was prepended to $pic_object above. 5373521070a0Smrg non_pic_object="$pic_object" 5374521070a0Smrg func_append non_pic_objects " $non_pic_object" 5375521070a0Smrg fi 5376521070a0Smrg else 5377521070a0Smrg # Only an error if not doing a dry-run. 5378521070a0Smrg if $opt_dry_run; then 5379521070a0Smrg # Extract subdirectory from the argument. 5380521070a0Smrg func_dirname "$arg" "/" "" 5381521070a0Smrg xdir="$func_dirname_result" 5382521070a0Smrg 5383521070a0Smrg func_lo2o "$arg" 5384521070a0Smrg pic_object=$xdir$objdir/$func_lo2o_result 5385521070a0Smrg non_pic_object=$xdir$func_lo2o_result 5386521070a0Smrg func_append libobjs " $pic_object" 5387521070a0Smrg func_append non_pic_objects " $non_pic_object" 5388521070a0Smrg else 5389521070a0Smrg func_fatal_error "\`$arg' is not a valid libtool object" 5390521070a0Smrg fi 5391521070a0Smrg fi 5392521070a0Smrg done 53934456fccdSmrg else 5394521070a0Smrg func_fatal_error "link input file \`$arg' does not exist" 53954456fccdSmrg fi 5396521070a0Smrg arg=$save_arg 5397521070a0Smrg prev= 5398521070a0Smrg continue 5399521070a0Smrg ;; 5400521070a0Smrg precious_regex) 5401521070a0Smrg precious_files_regex="$arg" 5402521070a0Smrg prev= 5403521070a0Smrg continue 5404521070a0Smrg ;; 5405521070a0Smrg release) 5406521070a0Smrg release="-$arg" 5407521070a0Smrg prev= 5408521070a0Smrg continue 5409521070a0Smrg ;; 5410521070a0Smrg rpath | xrpath) 5411521070a0Smrg # We need an absolute path. 5412521070a0Smrg case $arg in 5413521070a0Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5414521070a0Smrg *) 5415521070a0Smrg func_fatal_error "only absolute run-paths are allowed" 5416521070a0Smrg ;; 5417521070a0Smrg esac 5418521070a0Smrg if test "$prev" = rpath; then 5419521070a0Smrg case "$rpath " in 5420521070a0Smrg *" $arg "*) ;; 54213e6c936aSmrg *) func_append rpath " $arg" ;; 5422521070a0Smrg esac 54234456fccdSmrg else 5424521070a0Smrg case "$xrpath " in 5425521070a0Smrg *" $arg "*) ;; 54263e6c936aSmrg *) func_append xrpath " $arg" ;; 5427521070a0Smrg esac 54284456fccdSmrg fi 5429521070a0Smrg prev= 5430521070a0Smrg continue 5431521070a0Smrg ;; 5432521070a0Smrg shrext) 5433521070a0Smrg shrext_cmds="$arg" 5434521070a0Smrg prev= 5435521070a0Smrg continue 5436521070a0Smrg ;; 5437521070a0Smrg weak) 54383e6c936aSmrg func_append weak_libs " $arg" 5439521070a0Smrg prev= 5440521070a0Smrg continue 5441521070a0Smrg ;; 5442521070a0Smrg xcclinker) 54433e6c936aSmrg func_append linker_flags " $qarg" 54443e6c936aSmrg func_append compiler_flags " $qarg" 5445521070a0Smrg prev= 5446521070a0Smrg func_append compile_command " $qarg" 5447521070a0Smrg func_append finalize_command " $qarg" 5448521070a0Smrg continue 5449521070a0Smrg ;; 5450521070a0Smrg xcompiler) 54513e6c936aSmrg func_append compiler_flags " $qarg" 5452521070a0Smrg prev= 5453521070a0Smrg func_append compile_command " $qarg" 5454521070a0Smrg func_append finalize_command " $qarg" 5455521070a0Smrg continue 5456521070a0Smrg ;; 5457521070a0Smrg xlinker) 54583e6c936aSmrg func_append linker_flags " $qarg" 54593e6c936aSmrg func_append compiler_flags " $wl$qarg" 5460521070a0Smrg prev= 5461521070a0Smrg func_append compile_command " $wl$qarg" 5462521070a0Smrg func_append finalize_command " $wl$qarg" 5463521070a0Smrg continue 5464521070a0Smrg ;; 5465521070a0Smrg *) 5466521070a0Smrg eval "$prev=\"\$arg\"" 5467521070a0Smrg prev= 5468521070a0Smrg continue 5469521070a0Smrg ;; 54704456fccdSmrg esac 5471521070a0Smrg fi # test -n "$prev" 54724456fccdSmrg 5473521070a0Smrg prevarg="$arg" 54744456fccdSmrg 5475521070a0Smrg case $arg in 5476521070a0Smrg -all-static) 5477521070a0Smrg if test -n "$link_static_flag"; then 5478521070a0Smrg # See comment for -static flag below, for more details. 5479521070a0Smrg func_append compile_command " $link_static_flag" 5480521070a0Smrg func_append finalize_command " $link_static_flag" 5481521070a0Smrg fi 5482521070a0Smrg continue 5483521070a0Smrg ;; 54844456fccdSmrg 5485521070a0Smrg -allow-undefined) 5486521070a0Smrg # FIXME: remove this flag sometime in the future. 5487521070a0Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 5488521070a0Smrg ;; 54894456fccdSmrg 5490521070a0Smrg -avoid-version) 5491521070a0Smrg avoid_version=yes 5492521070a0Smrg continue 5493521070a0Smrg ;; 54944456fccdSmrg 5495ff63a143Smrg -bindir) 5496ff63a143Smrg prev=bindir 5497ff63a143Smrg continue 5498ff63a143Smrg ;; 5499ff63a143Smrg 5500521070a0Smrg -dlopen) 5501521070a0Smrg prev=dlfiles 5502521070a0Smrg continue 5503521070a0Smrg ;; 55044456fccdSmrg 5505521070a0Smrg -dlpreopen) 5506521070a0Smrg prev=dlprefiles 5507521070a0Smrg continue 5508521070a0Smrg ;; 55094456fccdSmrg 5510521070a0Smrg -export-dynamic) 5511521070a0Smrg export_dynamic=yes 5512521070a0Smrg continue 5513521070a0Smrg ;; 55144456fccdSmrg 5515521070a0Smrg -export-symbols | -export-symbols-regex) 5516521070a0Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 5517521070a0Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 5518521070a0Smrg fi 5519521070a0Smrg if test "X$arg" = "X-export-symbols"; then 5520521070a0Smrg prev=expsyms 5521521070a0Smrg else 5522521070a0Smrg prev=expsyms_regex 5523521070a0Smrg fi 5524521070a0Smrg continue 5525521070a0Smrg ;; 55264456fccdSmrg 5527521070a0Smrg -framework) 5528521070a0Smrg prev=framework 5529521070a0Smrg continue 5530521070a0Smrg ;; 55314456fccdSmrg 5532521070a0Smrg -inst-prefix-dir) 5533521070a0Smrg prev=inst_prefix 5534521070a0Smrg continue 5535521070a0Smrg ;; 55364456fccdSmrg 5537521070a0Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 5538521070a0Smrg # so, if we see these flags be careful not to treat them like -L 5539521070a0Smrg -L[A-Z][A-Z]*:*) 5540521070a0Smrg case $with_gcc/$host in 5541521070a0Smrg no/*-*-irix* | /*-*-irix*) 5542521070a0Smrg func_append compile_command " $arg" 5543521070a0Smrg func_append finalize_command " $arg" 5544521070a0Smrg ;; 5545521070a0Smrg esac 5546521070a0Smrg continue 5547521070a0Smrg ;; 55484456fccdSmrg 5549521070a0Smrg -L*) 55503e6c936aSmrg func_stripname "-L" '' "$arg" 55513e6c936aSmrg if test -z "$func_stripname_result"; then 5552521070a0Smrg if test "$#" -gt 0; then 5553521070a0Smrg func_fatal_error "require no space between \`-L' and \`$1'" 5554521070a0Smrg else 5555521070a0Smrg func_fatal_error "need path for \`-L' option" 5556521070a0Smrg fi 5557521070a0Smrg fi 55583e6c936aSmrg func_resolve_sysroot "$func_stripname_result" 55593e6c936aSmrg dir=$func_resolve_sysroot_result 5560521070a0Smrg # We need an absolute path. 5561521070a0Smrg case $dir in 5562521070a0Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5563521070a0Smrg *) 5564521070a0Smrg absdir=`cd "$dir" && pwd` 5565521070a0Smrg test -z "$absdir" && \ 5566521070a0Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 5567521070a0Smrg dir="$absdir" 5568521070a0Smrg ;; 5569521070a0Smrg esac 5570521070a0Smrg case "$deplibs " in 55713e6c936aSmrg *" -L$dir "* | *" $arg "*) 55723e6c936aSmrg # Will only happen for absolute or sysroot arguments 55733e6c936aSmrg ;; 5574521070a0Smrg *) 55753e6c936aSmrg # Preserve sysroot, but never include relative directories 55763e6c936aSmrg case $dir in 55773e6c936aSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 55783e6c936aSmrg *) func_append deplibs " -L$dir" ;; 55793e6c936aSmrg esac 55803e6c936aSmrg func_append lib_search_path " $dir" 5581521070a0Smrg ;; 5582521070a0Smrg esac 5583521070a0Smrg case $host in 5584521070a0Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5585ff63a143Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 5586521070a0Smrg case :$dllsearchpath: in 5587521070a0Smrg *":$dir:"*) ;; 5588521070a0Smrg ::) dllsearchpath=$dir;; 55893e6c936aSmrg *) func_append dllsearchpath ":$dir";; 5590521070a0Smrg esac 5591521070a0Smrg case :$dllsearchpath: in 5592521070a0Smrg *":$testbindir:"*) ;; 5593521070a0Smrg ::) dllsearchpath=$testbindir;; 55943e6c936aSmrg *) func_append dllsearchpath ":$testbindir";; 5595521070a0Smrg esac 5596521070a0Smrg ;; 5597521070a0Smrg esac 5598521070a0Smrg continue 5599521070a0Smrg ;; 56004456fccdSmrg 5601521070a0Smrg -l*) 5602521070a0Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 5603521070a0Smrg case $host in 5604ff63a143Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 5605521070a0Smrg # These systems don't actually have a C or math library (as such) 5606521070a0Smrg continue 5607521070a0Smrg ;; 5608521070a0Smrg *-*-os2*) 5609521070a0Smrg # These systems don't actually have a C library (as such) 5610521070a0Smrg test "X$arg" = "X-lc" && continue 5611521070a0Smrg ;; 5612521070a0Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5613521070a0Smrg # Do not include libc due to us having libc/libc_r. 5614521070a0Smrg test "X$arg" = "X-lc" && continue 5615521070a0Smrg ;; 5616521070a0Smrg *-*-rhapsody* | *-*-darwin1.[012]) 5617521070a0Smrg # Rhapsody C and math libraries are in the System framework 56183e6c936aSmrg func_append deplibs " System.ltframework" 5619521070a0Smrg continue 5620521070a0Smrg ;; 5621521070a0Smrg *-*-sco3.2v5* | *-*-sco5v6*) 5622521070a0Smrg # Causes problems with __ctype 5623521070a0Smrg test "X$arg" = "X-lc" && continue 5624521070a0Smrg ;; 5625521070a0Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 5626521070a0Smrg # Compiler inserts libc in the correct place for threads to work 5627521070a0Smrg test "X$arg" = "X-lc" && continue 5628521070a0Smrg ;; 5629521070a0Smrg esac 5630521070a0Smrg elif test "X$arg" = "X-lc_r"; then 5631521070a0Smrg case $host in 5632521070a0Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5633521070a0Smrg # Do not include libc_r directly, use -pthread flag. 5634521070a0Smrg continue 5635521070a0Smrg ;; 5636521070a0Smrg esac 5637521070a0Smrg fi 56383e6c936aSmrg func_append deplibs " $arg" 5639521070a0Smrg continue 5640521070a0Smrg ;; 56414456fccdSmrg 5642521070a0Smrg -module) 5643521070a0Smrg module=yes 5644521070a0Smrg continue 5645521070a0Smrg ;; 56464456fccdSmrg 5647521070a0Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 5648521070a0Smrg # classes, name mangling, and exception handling. 5649521070a0Smrg # Darwin uses the -arch flag to determine output architecture. 56503e6c936aSmrg -model|-arch|-isysroot|--sysroot) 56513e6c936aSmrg func_append compiler_flags " $arg" 5652521070a0Smrg func_append compile_command " $arg" 5653521070a0Smrg func_append finalize_command " $arg" 5654521070a0Smrg prev=xcompiler 5655521070a0Smrg continue 5656521070a0Smrg ;; 56574456fccdSmrg 56583e6c936aSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 56593e6c936aSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 56603e6c936aSmrg func_append compiler_flags " $arg" 5661521070a0Smrg func_append compile_command " $arg" 5662521070a0Smrg func_append finalize_command " $arg" 5663521070a0Smrg case "$new_inherited_linker_flags " in 5664521070a0Smrg *" $arg "*) ;; 56653e6c936aSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 5666521070a0Smrg esac 5667521070a0Smrg continue 5668521070a0Smrg ;; 56694456fccdSmrg 5670521070a0Smrg -multi_module) 5671521070a0Smrg single_module="${wl}-multi_module" 5672521070a0Smrg continue 5673521070a0Smrg ;; 56744456fccdSmrg 5675521070a0Smrg -no-fast-install) 5676521070a0Smrg fast_install=no 5677521070a0Smrg continue 5678521070a0Smrg ;; 56794456fccdSmrg 5680521070a0Smrg -no-install) 5681521070a0Smrg case $host in 5682521070a0Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 5683521070a0Smrg # The PATH hackery in wrapper scripts is required on Windows 5684521070a0Smrg # and Darwin in order for the loader to find any dlls it needs. 5685521070a0Smrg func_warning "\`-no-install' is ignored for $host" 5686521070a0Smrg func_warning "assuming \`-no-fast-install' instead" 5687521070a0Smrg fast_install=no 5688521070a0Smrg ;; 5689521070a0Smrg *) no_install=yes ;; 5690521070a0Smrg esac 5691521070a0Smrg continue 5692521070a0Smrg ;; 56934456fccdSmrg 5694521070a0Smrg -no-undefined) 5695521070a0Smrg allow_undefined=no 5696521070a0Smrg continue 5697521070a0Smrg ;; 56984456fccdSmrg 5699521070a0Smrg -objectlist) 5700521070a0Smrg prev=objectlist 5701521070a0Smrg continue 5702521070a0Smrg ;; 57034456fccdSmrg 5704521070a0Smrg -o) prev=output ;; 57054456fccdSmrg 5706521070a0Smrg -precious-files-regex) 5707521070a0Smrg prev=precious_regex 5708521070a0Smrg continue 5709521070a0Smrg ;; 57104456fccdSmrg 5711521070a0Smrg -release) 5712521070a0Smrg prev=release 5713521070a0Smrg continue 5714521070a0Smrg ;; 57154456fccdSmrg 5716521070a0Smrg -rpath) 5717521070a0Smrg prev=rpath 5718521070a0Smrg continue 5719521070a0Smrg ;; 57204456fccdSmrg 5721521070a0Smrg -R) 5722521070a0Smrg prev=xrpath 5723521070a0Smrg continue 5724521070a0Smrg ;; 57254456fccdSmrg 5726521070a0Smrg -R*) 5727521070a0Smrg func_stripname '-R' '' "$arg" 5728521070a0Smrg dir=$func_stripname_result 5729521070a0Smrg # We need an absolute path. 5730521070a0Smrg case $dir in 5731521070a0Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 57323e6c936aSmrg =*) 57333e6c936aSmrg func_stripname '=' '' "$dir" 57343e6c936aSmrg dir=$lt_sysroot$func_stripname_result 57353e6c936aSmrg ;; 5736521070a0Smrg *) 5737521070a0Smrg func_fatal_error "only absolute run-paths are allowed" 5738521070a0Smrg ;; 5739521070a0Smrg esac 5740521070a0Smrg case "$xrpath " in 5741521070a0Smrg *" $dir "*) ;; 57423e6c936aSmrg *) func_append xrpath " $dir" ;; 5743521070a0Smrg esac 5744521070a0Smrg continue 5745521070a0Smrg ;; 57464456fccdSmrg 5747521070a0Smrg -shared) 5748521070a0Smrg # The effects of -shared are defined in a previous loop. 5749521070a0Smrg continue 5750521070a0Smrg ;; 57514456fccdSmrg 5752521070a0Smrg -shrext) 5753521070a0Smrg prev=shrext 5754521070a0Smrg continue 5755521070a0Smrg ;; 57564456fccdSmrg 5757521070a0Smrg -static | -static-libtool-libs) 5758521070a0Smrg # The effects of -static are defined in a previous loop. 5759521070a0Smrg # We used to do the same as -all-static on platforms that 5760521070a0Smrg # didn't have a PIC flag, but the assumption that the effects 5761521070a0Smrg # would be equivalent was wrong. It would break on at least 5762521070a0Smrg # Digital Unix and AIX. 5763521070a0Smrg continue 5764521070a0Smrg ;; 57654456fccdSmrg 5766521070a0Smrg -thread-safe) 5767521070a0Smrg thread_safe=yes 5768521070a0Smrg continue 5769521070a0Smrg ;; 57704456fccdSmrg 5771521070a0Smrg -version-info) 5772521070a0Smrg prev=vinfo 5773521070a0Smrg continue 5774521070a0Smrg ;; 57754456fccdSmrg 5776521070a0Smrg -version-number) 5777521070a0Smrg prev=vinfo 5778521070a0Smrg vinfo_number=yes 5779521070a0Smrg continue 5780521070a0Smrg ;; 57814456fccdSmrg 5782521070a0Smrg -weak) 5783521070a0Smrg prev=weak 5784521070a0Smrg continue 5785521070a0Smrg ;; 57864456fccdSmrg 5787521070a0Smrg -Wc,*) 5788521070a0Smrg func_stripname '-Wc,' '' "$arg" 5789521070a0Smrg args=$func_stripname_result 5790521070a0Smrg arg= 5791521070a0Smrg save_ifs="$IFS"; IFS=',' 5792521070a0Smrg for flag in $args; do 5793521070a0Smrg IFS="$save_ifs" 5794521070a0Smrg func_quote_for_eval "$flag" 57953e6c936aSmrg func_append arg " $func_quote_for_eval_result" 57963e6c936aSmrg func_append compiler_flags " $func_quote_for_eval_result" 5797521070a0Smrg done 5798521070a0Smrg IFS="$save_ifs" 5799521070a0Smrg func_stripname ' ' '' "$arg" 5800521070a0Smrg arg=$func_stripname_result 5801521070a0Smrg ;; 58024456fccdSmrg 5803521070a0Smrg -Wl,*) 5804521070a0Smrg func_stripname '-Wl,' '' "$arg" 5805521070a0Smrg args=$func_stripname_result 5806521070a0Smrg arg= 5807521070a0Smrg save_ifs="$IFS"; IFS=',' 5808521070a0Smrg for flag in $args; do 5809521070a0Smrg IFS="$save_ifs" 5810521070a0Smrg func_quote_for_eval "$flag" 58113e6c936aSmrg func_append arg " $wl$func_quote_for_eval_result" 58123e6c936aSmrg func_append compiler_flags " $wl$func_quote_for_eval_result" 58133e6c936aSmrg func_append linker_flags " $func_quote_for_eval_result" 5814521070a0Smrg done 5815521070a0Smrg IFS="$save_ifs" 5816521070a0Smrg func_stripname ' ' '' "$arg" 5817521070a0Smrg arg=$func_stripname_result 5818521070a0Smrg ;; 58194456fccdSmrg 5820521070a0Smrg -Xcompiler) 5821521070a0Smrg prev=xcompiler 5822521070a0Smrg continue 5823521070a0Smrg ;; 58244456fccdSmrg 5825521070a0Smrg -Xlinker) 5826521070a0Smrg prev=xlinker 5827521070a0Smrg continue 5828521070a0Smrg ;; 58294456fccdSmrg 5830521070a0Smrg -XCClinker) 5831521070a0Smrg prev=xcclinker 5832521070a0Smrg continue 5833521070a0Smrg ;; 58344456fccdSmrg 5835521070a0Smrg # -msg_* for osf cc 5836521070a0Smrg -msg_*) 5837521070a0Smrg func_quote_for_eval "$arg" 5838521070a0Smrg arg="$func_quote_for_eval_result" 5839521070a0Smrg ;; 58404456fccdSmrg 5841ff63a143Smrg # Flags to be passed through unchanged, with rationale: 5842ff63a143Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 5843ff63a143Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 5844ff63a143Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 5845ff63a143Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 5846ff63a143Smrg # -q* compiler args for the IBM compiler 5847ff63a143Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 5848ff63a143Smrg # -F/path path to uninstalled frameworks, gcc on darwin 5849ff63a143Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 5850ff63a143Smrg # @file GCC response files 5851ff63a143Smrg # -tp=* Portland pgcc target processor selection 58523e6c936aSmrg # --sysroot=* for sysroot support 58533e6c936aSmrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 5854521070a0Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 58553e6c936aSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 58563e6c936aSmrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 5857521070a0Smrg func_quote_for_eval "$arg" 5858521070a0Smrg arg="$func_quote_for_eval_result" 5859521070a0Smrg func_append compile_command " $arg" 5860521070a0Smrg func_append finalize_command " $arg" 58613e6c936aSmrg func_append compiler_flags " $arg" 5862521070a0Smrg continue 5863521070a0Smrg ;; 58644456fccdSmrg 5865521070a0Smrg # Some other compiler flag. 5866521070a0Smrg -* | +*) 5867521070a0Smrg func_quote_for_eval "$arg" 5868521070a0Smrg arg="$func_quote_for_eval_result" 5869521070a0Smrg ;; 58704456fccdSmrg 5871521070a0Smrg *.$objext) 5872521070a0Smrg # A standard object. 58733e6c936aSmrg func_append objs " $arg" 5874521070a0Smrg ;; 58754456fccdSmrg 5876521070a0Smrg *.lo) 5877521070a0Smrg # A libtool-controlled object. 58784456fccdSmrg 5879521070a0Smrg # Check to see that this really is a libtool object. 5880521070a0Smrg if func_lalib_unsafe_p "$arg"; then 5881521070a0Smrg pic_object= 5882521070a0Smrg non_pic_object= 58834456fccdSmrg 5884521070a0Smrg # Read the .lo file 5885521070a0Smrg func_source "$arg" 58864456fccdSmrg 5887521070a0Smrg if test -z "$pic_object" || 5888521070a0Smrg test -z "$non_pic_object" || 5889521070a0Smrg test "$pic_object" = none && 5890521070a0Smrg test "$non_pic_object" = none; then 5891521070a0Smrg func_fatal_error "cannot find name of object for \`$arg'" 5892521070a0Smrg fi 58934456fccdSmrg 5894521070a0Smrg # Extract subdirectory from the argument. 5895521070a0Smrg func_dirname "$arg" "/" "" 5896521070a0Smrg xdir="$func_dirname_result" 589742d69509Smrg 5898521070a0Smrg if test "$pic_object" != none; then 5899521070a0Smrg # Prepend the subdirectory the object is found in. 5900521070a0Smrg pic_object="$xdir$pic_object" 59014456fccdSmrg 5902521070a0Smrg if test "$prev" = dlfiles; then 5903521070a0Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 59043e6c936aSmrg func_append dlfiles " $pic_object" 5905521070a0Smrg prev= 5906521070a0Smrg continue 5907521070a0Smrg else 5908521070a0Smrg # If libtool objects are unsupported, then we need to preload. 5909521070a0Smrg prev=dlprefiles 5910521070a0Smrg fi 5911521070a0Smrg fi 59124456fccdSmrg 5913521070a0Smrg # CHECK ME: I think I busted this. -Ossama 5914521070a0Smrg if test "$prev" = dlprefiles; then 5915521070a0Smrg # Preload the old-style object. 59163e6c936aSmrg func_append dlprefiles " $pic_object" 5917521070a0Smrg prev= 5918521070a0Smrg fi 59194456fccdSmrg 5920521070a0Smrg # A PIC object. 5921521070a0Smrg func_append libobjs " $pic_object" 5922521070a0Smrg arg="$pic_object" 5923521070a0Smrg fi 59244456fccdSmrg 5925521070a0Smrg # Non-PIC object. 5926521070a0Smrg if test "$non_pic_object" != none; then 5927521070a0Smrg # Prepend the subdirectory the object is found in. 5928521070a0Smrg non_pic_object="$xdir$non_pic_object" 59294456fccdSmrg 5930521070a0Smrg # A standard non-PIC object 5931521070a0Smrg func_append non_pic_objects " $non_pic_object" 5932521070a0Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 5933521070a0Smrg arg="$non_pic_object" 5934521070a0Smrg fi 5935521070a0Smrg else 5936521070a0Smrg # If the PIC object exists, use it instead. 5937521070a0Smrg # $xdir was prepended to $pic_object above. 5938521070a0Smrg non_pic_object="$pic_object" 5939521070a0Smrg func_append non_pic_objects " $non_pic_object" 5940521070a0Smrg fi 5941521070a0Smrg else 5942521070a0Smrg # Only an error if not doing a dry-run. 5943521070a0Smrg if $opt_dry_run; then 5944521070a0Smrg # Extract subdirectory from the argument. 5945521070a0Smrg func_dirname "$arg" "/" "" 5946521070a0Smrg xdir="$func_dirname_result" 5947521070a0Smrg 5948521070a0Smrg func_lo2o "$arg" 5949521070a0Smrg pic_object=$xdir$objdir/$func_lo2o_result 5950521070a0Smrg non_pic_object=$xdir$func_lo2o_result 5951521070a0Smrg func_append libobjs " $pic_object" 5952521070a0Smrg func_append non_pic_objects " $non_pic_object" 5953521070a0Smrg else 5954521070a0Smrg func_fatal_error "\`$arg' is not a valid libtool object" 5955521070a0Smrg fi 5956521070a0Smrg fi 5957521070a0Smrg ;; 59584456fccdSmrg 5959521070a0Smrg *.$libext) 5960521070a0Smrg # An archive. 59613e6c936aSmrg func_append deplibs " $arg" 59623e6c936aSmrg func_append old_deplibs " $arg" 5963521070a0Smrg continue 5964521070a0Smrg ;; 5965521070a0Smrg 5966521070a0Smrg *.la) 5967521070a0Smrg # A libtool-controlled library. 5968521070a0Smrg 59693e6c936aSmrg func_resolve_sysroot "$arg" 5970521070a0Smrg if test "$prev" = dlfiles; then 5971521070a0Smrg # This library was specified with -dlopen. 59723e6c936aSmrg func_append dlfiles " $func_resolve_sysroot_result" 5973521070a0Smrg prev= 5974521070a0Smrg elif test "$prev" = dlprefiles; then 5975521070a0Smrg # The library was specified with -dlpreopen. 59763e6c936aSmrg func_append dlprefiles " $func_resolve_sysroot_result" 5977521070a0Smrg prev= 5978521070a0Smrg else 59793e6c936aSmrg func_append deplibs " $func_resolve_sysroot_result" 5980521070a0Smrg fi 5981521070a0Smrg continue 5982521070a0Smrg ;; 5983521070a0Smrg 5984521070a0Smrg # Some other compiler argument. 5985521070a0Smrg *) 5986521070a0Smrg # Unknown arguments in both finalize_command and compile_command need 5987521070a0Smrg # to be aesthetically quoted because they are evaled later. 5988521070a0Smrg func_quote_for_eval "$arg" 5989521070a0Smrg arg="$func_quote_for_eval_result" 5990521070a0Smrg ;; 5991521070a0Smrg esac # arg 5992521070a0Smrg 5993521070a0Smrg # Now actually substitute the argument into the commands. 5994521070a0Smrg if test -n "$arg"; then 5995521070a0Smrg func_append compile_command " $arg" 5996521070a0Smrg func_append finalize_command " $arg" 5997521070a0Smrg fi 5998521070a0Smrg done # argument parsing loop 5999521070a0Smrg 6000521070a0Smrg test -n "$prev" && \ 6001521070a0Smrg func_fatal_help "the \`$prevarg' option requires an argument" 6002521070a0Smrg 6003521070a0Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 6004521070a0Smrg eval arg=\"$export_dynamic_flag_spec\" 6005521070a0Smrg func_append compile_command " $arg" 6006521070a0Smrg func_append finalize_command " $arg" 6007521070a0Smrg fi 6008521070a0Smrg 6009521070a0Smrg oldlibs= 6010521070a0Smrg # calculate the name of the file, without its directory 6011521070a0Smrg func_basename "$output" 6012521070a0Smrg outputname="$func_basename_result" 6013521070a0Smrg libobjs_save="$libobjs" 6014521070a0Smrg 6015521070a0Smrg if test -n "$shlibpath_var"; then 6016521070a0Smrg # get the directories listed in $shlibpath_var 6017ff63a143Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 6018521070a0Smrg else 6019521070a0Smrg shlib_search_path= 6020521070a0Smrg fi 6021521070a0Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 6022521070a0Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 6023521070a0Smrg 6024521070a0Smrg func_dirname "$output" "/" "" 6025521070a0Smrg output_objdir="$func_dirname_result$objdir" 60263e6c936aSmrg func_to_tool_file "$output_objdir/" 60273e6c936aSmrg tool_output_objdir=$func_to_tool_file_result 6028521070a0Smrg # Create the object directory. 6029521070a0Smrg func_mkdir_p "$output_objdir" 6030521070a0Smrg 6031521070a0Smrg # Determine the type of output 6032521070a0Smrg case $output in 6033521070a0Smrg "") 6034521070a0Smrg func_fatal_help "you must specify an output file" 6035521070a0Smrg ;; 6036521070a0Smrg *.$libext) linkmode=oldlib ;; 6037521070a0Smrg *.lo | *.$objext) linkmode=obj ;; 6038521070a0Smrg *.la) linkmode=lib ;; 6039521070a0Smrg *) linkmode=prog ;; # Anything else should be a program. 6040521070a0Smrg esac 6041521070a0Smrg 6042521070a0Smrg specialdeplibs= 6043521070a0Smrg 6044521070a0Smrg libs= 6045521070a0Smrg # Find all interdependent deplibs by searching for libraries 6046521070a0Smrg # that are linked more than once (e.g. -la -lb -la) 6047521070a0Smrg for deplib in $deplibs; do 60483e6c936aSmrg if $opt_preserve_dup_deps ; then 6049521070a0Smrg case "$libs " in 60503e6c936aSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6051521070a0Smrg esac 6052521070a0Smrg fi 60533e6c936aSmrg func_append libs " $deplib" 6054521070a0Smrg done 6055521070a0Smrg 6056521070a0Smrg if test "$linkmode" = lib; then 6057521070a0Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 6058521070a0Smrg 6059521070a0Smrg # Compute libraries that are listed more than once in $predeps 6060521070a0Smrg # $postdeps and mark them as special (i.e., whose duplicates are 6061521070a0Smrg # not to be eliminated). 6062521070a0Smrg pre_post_deps= 6063521070a0Smrg if $opt_duplicate_compiler_generated_deps; then 6064521070a0Smrg for pre_post_dep in $predeps $postdeps; do 6065521070a0Smrg case "$pre_post_deps " in 60663e6c936aSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 6067521070a0Smrg esac 60683e6c936aSmrg func_append pre_post_deps " $pre_post_dep" 6069521070a0Smrg done 6070521070a0Smrg fi 6071521070a0Smrg pre_post_deps= 6072521070a0Smrg fi 6073521070a0Smrg 6074521070a0Smrg deplibs= 6075521070a0Smrg newdependency_libs= 6076521070a0Smrg newlib_search_path= 6077521070a0Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 6078521070a0Smrg notinst_deplibs= # not-installed libtool libraries 6079521070a0Smrg notinst_path= # paths that contain not-installed libtool libraries 6080521070a0Smrg 6081521070a0Smrg case $linkmode in 6082521070a0Smrg lib) 6083521070a0Smrg passes="conv dlpreopen link" 6084521070a0Smrg for file in $dlfiles $dlprefiles; do 6085521070a0Smrg case $file in 6086521070a0Smrg *.la) ;; 6087521070a0Smrg *) 6088521070a0Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 6089521070a0Smrg ;; 6090521070a0Smrg esac 6091521070a0Smrg done 6092521070a0Smrg ;; 6093521070a0Smrg prog) 6094521070a0Smrg compile_deplibs= 6095521070a0Smrg finalize_deplibs= 6096521070a0Smrg alldeplibs=no 6097521070a0Smrg newdlfiles= 6098521070a0Smrg newdlprefiles= 6099521070a0Smrg passes="conv scan dlopen dlpreopen link" 6100521070a0Smrg ;; 6101521070a0Smrg *) passes="conv" 6102521070a0Smrg ;; 6103521070a0Smrg esac 6104521070a0Smrg 6105521070a0Smrg for pass in $passes; do 6106521070a0Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 6107521070a0Smrg # so that -L comes before libs that need it for instance... 6108521070a0Smrg if test "$linkmode,$pass" = "lib,link"; then 6109521070a0Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 6110521070a0Smrg ## order, and fix it there properly 6111521070a0Smrg tmp_deplibs= 6112521070a0Smrg for deplib in $deplibs; do 6113521070a0Smrg tmp_deplibs="$deplib $tmp_deplibs" 6114521070a0Smrg done 6115521070a0Smrg deplibs="$tmp_deplibs" 6116521070a0Smrg fi 6117521070a0Smrg 6118521070a0Smrg if test "$linkmode,$pass" = "lib,link" || 6119521070a0Smrg test "$linkmode,$pass" = "prog,scan"; then 6120521070a0Smrg libs="$deplibs" 6121521070a0Smrg deplibs= 6122521070a0Smrg fi 6123521070a0Smrg if test "$linkmode" = prog; then 6124521070a0Smrg case $pass in 6125521070a0Smrg dlopen) libs="$dlfiles" ;; 6126521070a0Smrg dlpreopen) libs="$dlprefiles" ;; 6127521070a0Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 6128521070a0Smrg esac 6129521070a0Smrg fi 6130521070a0Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 6131521070a0Smrg # Collect and forward deplibs of preopened libtool libs 6132521070a0Smrg for lib in $dlprefiles; do 6133521070a0Smrg # Ignore non-libtool-libs 6134521070a0Smrg dependency_libs= 61353e6c936aSmrg func_resolve_sysroot "$lib" 6136521070a0Smrg case $lib in 61373e6c936aSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 6138521070a0Smrg esac 6139521070a0Smrg 6140521070a0Smrg # Collect preopened libtool deplibs, except any this library 6141521070a0Smrg # has declared as weak libs 6142521070a0Smrg for deplib in $dependency_libs; do 6143ff63a143Smrg func_basename "$deplib" 6144ff63a143Smrg deplib_base=$func_basename_result 6145521070a0Smrg case " $weak_libs " in 6146521070a0Smrg *" $deplib_base "*) ;; 61473e6c936aSmrg *) func_append deplibs " $deplib" ;; 6148521070a0Smrg esac 6149521070a0Smrg done 6150521070a0Smrg done 6151521070a0Smrg libs="$dlprefiles" 6152521070a0Smrg fi 6153521070a0Smrg if test "$pass" = dlopen; then 6154521070a0Smrg # Collect dlpreopened libraries 6155521070a0Smrg save_deplibs="$deplibs" 6156521070a0Smrg deplibs= 6157521070a0Smrg fi 6158521070a0Smrg 6159521070a0Smrg for deplib in $libs; do 6160521070a0Smrg lib= 6161521070a0Smrg found=no 6162521070a0Smrg case $deplib in 61633e6c936aSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 61643e6c936aSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 6165521070a0Smrg if test "$linkmode,$pass" = "prog,link"; then 6166521070a0Smrg compile_deplibs="$deplib $compile_deplibs" 6167521070a0Smrg finalize_deplibs="$deplib $finalize_deplibs" 6168521070a0Smrg else 61693e6c936aSmrg func_append compiler_flags " $deplib" 6170521070a0Smrg if test "$linkmode" = lib ; then 6171521070a0Smrg case "$new_inherited_linker_flags " in 6172521070a0Smrg *" $deplib "*) ;; 61733e6c936aSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 6174521070a0Smrg esac 6175521070a0Smrg fi 6176521070a0Smrg fi 6177521070a0Smrg continue 6178521070a0Smrg ;; 6179521070a0Smrg -l*) 6180521070a0Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 6181521070a0Smrg func_warning "\`-l' is ignored for archives/objects" 6182521070a0Smrg continue 6183521070a0Smrg fi 6184521070a0Smrg func_stripname '-l' '' "$deplib" 6185521070a0Smrg name=$func_stripname_result 6186521070a0Smrg if test "$linkmode" = lib; then 6187521070a0Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 6188521070a0Smrg else 6189521070a0Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 6190521070a0Smrg fi 6191521070a0Smrg for searchdir in $searchdirs; do 6192521070a0Smrg for search_ext in .la $std_shrext .so .a; do 6193521070a0Smrg # Search the libtool library 6194521070a0Smrg lib="$searchdir/lib${name}${search_ext}" 6195521070a0Smrg if test -f "$lib"; then 6196521070a0Smrg if test "$search_ext" = ".la"; then 6197521070a0Smrg found=yes 6198521070a0Smrg else 6199521070a0Smrg found=no 6200521070a0Smrg fi 6201521070a0Smrg break 2 6202521070a0Smrg fi 6203521070a0Smrg done 6204521070a0Smrg done 6205521070a0Smrg if test "$found" != yes; then 6206521070a0Smrg # deplib doesn't seem to be a libtool library 6207521070a0Smrg if test "$linkmode,$pass" = "prog,link"; then 6208521070a0Smrg compile_deplibs="$deplib $compile_deplibs" 6209521070a0Smrg finalize_deplibs="$deplib $finalize_deplibs" 6210521070a0Smrg else 6211521070a0Smrg deplibs="$deplib $deplibs" 6212521070a0Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6213521070a0Smrg fi 6214521070a0Smrg continue 6215521070a0Smrg else # deplib is a libtool library 6216521070a0Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 6217521070a0Smrg # We need to do some special things here, and not later. 6218521070a0Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 6219521070a0Smrg case " $predeps $postdeps " in 6220521070a0Smrg *" $deplib "*) 6221521070a0Smrg if func_lalib_p "$lib"; then 6222521070a0Smrg library_names= 6223521070a0Smrg old_library= 6224521070a0Smrg func_source "$lib" 6225521070a0Smrg for l in $old_library $library_names; do 6226521070a0Smrg ll="$l" 6227521070a0Smrg done 6228521070a0Smrg if test "X$ll" = "X$old_library" ; then # only static version available 6229521070a0Smrg found=no 6230521070a0Smrg func_dirname "$lib" "" "." 6231521070a0Smrg ladir="$func_dirname_result" 6232521070a0Smrg lib=$ladir/$old_library 6233521070a0Smrg if test "$linkmode,$pass" = "prog,link"; then 6234521070a0Smrg compile_deplibs="$deplib $compile_deplibs" 6235521070a0Smrg finalize_deplibs="$deplib $finalize_deplibs" 6236521070a0Smrg else 6237521070a0Smrg deplibs="$deplib $deplibs" 6238521070a0Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6239521070a0Smrg fi 6240521070a0Smrg continue 6241521070a0Smrg fi 6242521070a0Smrg fi 6243521070a0Smrg ;; 6244521070a0Smrg *) ;; 6245521070a0Smrg esac 6246521070a0Smrg fi 6247521070a0Smrg fi 6248521070a0Smrg ;; # -l 6249521070a0Smrg *.ltframework) 6250521070a0Smrg if test "$linkmode,$pass" = "prog,link"; then 6251521070a0Smrg compile_deplibs="$deplib $compile_deplibs" 6252521070a0Smrg finalize_deplibs="$deplib $finalize_deplibs" 6253521070a0Smrg else 6254521070a0Smrg deplibs="$deplib $deplibs" 6255521070a0Smrg if test "$linkmode" = lib ; then 6256521070a0Smrg case "$new_inherited_linker_flags " in 6257521070a0Smrg *" $deplib "*) ;; 62583e6c936aSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 6259521070a0Smrg esac 6260521070a0Smrg fi 6261521070a0Smrg fi 6262521070a0Smrg continue 6263521070a0Smrg ;; 6264521070a0Smrg -L*) 6265521070a0Smrg case $linkmode in 6266521070a0Smrg lib) 6267521070a0Smrg deplibs="$deplib $deplibs" 6268521070a0Smrg test "$pass" = conv && continue 6269521070a0Smrg newdependency_libs="$deplib $newdependency_libs" 6270521070a0Smrg func_stripname '-L' '' "$deplib" 62713e6c936aSmrg func_resolve_sysroot "$func_stripname_result" 62723e6c936aSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 6273521070a0Smrg ;; 6274521070a0Smrg prog) 6275521070a0Smrg if test "$pass" = conv; then 6276521070a0Smrg deplibs="$deplib $deplibs" 6277521070a0Smrg continue 6278521070a0Smrg fi 6279521070a0Smrg if test "$pass" = scan; then 6280521070a0Smrg deplibs="$deplib $deplibs" 6281521070a0Smrg else 6282521070a0Smrg compile_deplibs="$deplib $compile_deplibs" 6283521070a0Smrg finalize_deplibs="$deplib $finalize_deplibs" 6284521070a0Smrg fi 6285521070a0Smrg func_stripname '-L' '' "$deplib" 62863e6c936aSmrg func_resolve_sysroot "$func_stripname_result" 62873e6c936aSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 6288521070a0Smrg ;; 6289521070a0Smrg *) 6290521070a0Smrg func_warning "\`-L' is ignored for archives/objects" 6291521070a0Smrg ;; 6292521070a0Smrg esac # linkmode 6293521070a0Smrg continue 6294521070a0Smrg ;; # -L 6295521070a0Smrg -R*) 6296521070a0Smrg if test "$pass" = link; then 6297521070a0Smrg func_stripname '-R' '' "$deplib" 62983e6c936aSmrg func_resolve_sysroot "$func_stripname_result" 62993e6c936aSmrg dir=$func_resolve_sysroot_result 6300521070a0Smrg # Make sure the xrpath contains only unique directories. 6301521070a0Smrg case "$xrpath " in 6302521070a0Smrg *" $dir "*) ;; 63033e6c936aSmrg *) func_append xrpath " $dir" ;; 6304521070a0Smrg esac 6305521070a0Smrg fi 6306521070a0Smrg deplibs="$deplib $deplibs" 6307521070a0Smrg continue 6308521070a0Smrg ;; 63093e6c936aSmrg *.la) 63103e6c936aSmrg func_resolve_sysroot "$deplib" 63113e6c936aSmrg lib=$func_resolve_sysroot_result 63123e6c936aSmrg ;; 6313521070a0Smrg *.$libext) 6314521070a0Smrg if test "$pass" = conv; then 6315521070a0Smrg deplibs="$deplib $deplibs" 6316521070a0Smrg continue 6317521070a0Smrg fi 6318521070a0Smrg case $linkmode in 6319521070a0Smrg lib) 6320521070a0Smrg # Linking convenience modules into shared libraries is allowed, 6321521070a0Smrg # but linking other static libraries is non-portable. 6322521070a0Smrg case " $dlpreconveniencelibs " in 6323521070a0Smrg *" $deplib "*) ;; 6324521070a0Smrg *) 6325521070a0Smrg valid_a_lib=no 6326521070a0Smrg case $deplibs_check_method in 6327521070a0Smrg match_pattern*) 6328521070a0Smrg set dummy $deplibs_check_method; shift 6329521070a0Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 6330ff63a143Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 6331521070a0Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 6332521070a0Smrg valid_a_lib=yes 6333521070a0Smrg fi 6334521070a0Smrg ;; 6335521070a0Smrg pass_all) 6336521070a0Smrg valid_a_lib=yes 6337521070a0Smrg ;; 6338521070a0Smrg esac 6339521070a0Smrg if test "$valid_a_lib" != yes; then 6340ff63a143Smrg echo 6341521070a0Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 6342ff63a143Smrg echo "*** I have the capability to make that library automatically link in when" 6343ff63a143Smrg echo "*** you link to this library. But I can only do this if you have a" 6344ff63a143Smrg echo "*** shared version of the library, which you do not appear to have" 6345ff63a143Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 6346ff63a143Smrg echo "*** that it is just a static archive that I should not use here." 6347521070a0Smrg else 6348ff63a143Smrg echo 6349521070a0Smrg $ECHO "*** Warning: Linking the shared library $output against the" 6350521070a0Smrg $ECHO "*** static library $deplib is not portable!" 6351521070a0Smrg deplibs="$deplib $deplibs" 6352521070a0Smrg fi 6353521070a0Smrg ;; 6354521070a0Smrg esac 6355521070a0Smrg continue 6356521070a0Smrg ;; 6357521070a0Smrg prog) 6358521070a0Smrg if test "$pass" != link; then 6359521070a0Smrg deplibs="$deplib $deplibs" 6360521070a0Smrg else 6361521070a0Smrg compile_deplibs="$deplib $compile_deplibs" 6362521070a0Smrg finalize_deplibs="$deplib $finalize_deplibs" 6363521070a0Smrg fi 6364521070a0Smrg continue 6365521070a0Smrg ;; 6366521070a0Smrg esac # linkmode 6367521070a0Smrg ;; # *.$libext 6368521070a0Smrg *.lo | *.$objext) 6369521070a0Smrg if test "$pass" = conv; then 6370521070a0Smrg deplibs="$deplib $deplibs" 6371521070a0Smrg elif test "$linkmode" = prog; then 6372521070a0Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 6373521070a0Smrg # If there is no dlopen support or we're linking statically, 6374521070a0Smrg # we need to preload. 63753e6c936aSmrg func_append newdlprefiles " $deplib" 6376521070a0Smrg compile_deplibs="$deplib $compile_deplibs" 6377521070a0Smrg finalize_deplibs="$deplib $finalize_deplibs" 6378521070a0Smrg else 63793e6c936aSmrg func_append newdlfiles " $deplib" 6380521070a0Smrg fi 6381521070a0Smrg fi 6382521070a0Smrg continue 6383521070a0Smrg ;; 6384521070a0Smrg %DEPLIBS%) 6385521070a0Smrg alldeplibs=yes 6386521070a0Smrg continue 6387521070a0Smrg ;; 6388521070a0Smrg esac # case $deplib 6389521070a0Smrg 6390521070a0Smrg if test "$found" = yes || test -f "$lib"; then : 6391521070a0Smrg else 6392521070a0Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 6393521070a0Smrg fi 6394521070a0Smrg 6395521070a0Smrg # Check to see that this really is a libtool archive. 6396521070a0Smrg func_lalib_unsafe_p "$lib" \ 6397521070a0Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 6398521070a0Smrg 6399521070a0Smrg func_dirname "$lib" "" "." 6400521070a0Smrg ladir="$func_dirname_result" 6401521070a0Smrg 6402521070a0Smrg dlname= 6403521070a0Smrg dlopen= 6404521070a0Smrg dlpreopen= 6405521070a0Smrg libdir= 6406521070a0Smrg library_names= 6407521070a0Smrg old_library= 6408521070a0Smrg inherited_linker_flags= 6409521070a0Smrg # If the library was installed with an old release of libtool, 6410521070a0Smrg # it will not redefine variables installed, or shouldnotlink 6411521070a0Smrg installed=yes 6412521070a0Smrg shouldnotlink=no 6413521070a0Smrg avoidtemprpath= 6414521070a0Smrg 6415521070a0Smrg 6416521070a0Smrg # Read the .la file 6417521070a0Smrg func_source "$lib" 6418521070a0Smrg 6419521070a0Smrg # Convert "-framework foo" to "foo.ltframework" 6420521070a0Smrg if test -n "$inherited_linker_flags"; then 6421ff63a143Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 6422521070a0Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 6423521070a0Smrg case " $new_inherited_linker_flags " in 6424521070a0Smrg *" $tmp_inherited_linker_flag "*) ;; 64253e6c936aSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 6426521070a0Smrg esac 6427521070a0Smrg done 6428521070a0Smrg fi 6429ff63a143Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 6430521070a0Smrg if test "$linkmode,$pass" = "lib,link" || 6431521070a0Smrg test "$linkmode,$pass" = "prog,scan" || 6432521070a0Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 64333e6c936aSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 64343e6c936aSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 6435521070a0Smrg fi 6436521070a0Smrg 6437521070a0Smrg if test "$pass" = conv; then 6438521070a0Smrg # Only check for convenience libraries 6439521070a0Smrg deplibs="$lib $deplibs" 6440521070a0Smrg if test -z "$libdir"; then 6441521070a0Smrg if test -z "$old_library"; then 6442521070a0Smrg func_fatal_error "cannot find name of link library for \`$lib'" 6443521070a0Smrg fi 6444521070a0Smrg # It is a libtool convenience library, so add in its objects. 64453e6c936aSmrg func_append convenience " $ladir/$objdir/$old_library" 64463e6c936aSmrg func_append old_convenience " $ladir/$objdir/$old_library" 6447521070a0Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 6448521070a0Smrg func_fatal_error "\`$lib' is not a convenience library" 6449521070a0Smrg fi 6450521070a0Smrg tmp_libs= 6451521070a0Smrg for deplib in $dependency_libs; do 6452521070a0Smrg deplibs="$deplib $deplibs" 64533e6c936aSmrg if $opt_preserve_dup_deps ; then 6454521070a0Smrg case "$tmp_libs " in 64553e6c936aSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6456521070a0Smrg esac 6457521070a0Smrg fi 64583e6c936aSmrg func_append tmp_libs " $deplib" 6459521070a0Smrg done 6460521070a0Smrg continue 6461521070a0Smrg fi # $pass = conv 6462521070a0Smrg 6463521070a0Smrg 6464521070a0Smrg # Get the name of the library we link against. 6465521070a0Smrg linklib= 64663e6c936aSmrg if test -n "$old_library" && 64673e6c936aSmrg { test "$prefer_static_libs" = yes || 64683e6c936aSmrg test "$prefer_static_libs,$installed" = "built,no"; }; then 64693e6c936aSmrg linklib=$old_library 64703e6c936aSmrg else 64713e6c936aSmrg for l in $old_library $library_names; do 64723e6c936aSmrg linklib="$l" 64733e6c936aSmrg done 64743e6c936aSmrg fi 6475521070a0Smrg if test -z "$linklib"; then 6476521070a0Smrg func_fatal_error "cannot find name of link library for \`$lib'" 6477521070a0Smrg fi 6478521070a0Smrg 6479521070a0Smrg # This library was specified with -dlopen. 6480521070a0Smrg if test "$pass" = dlopen; then 6481521070a0Smrg if test -z "$libdir"; then 6482521070a0Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 6483521070a0Smrg fi 6484521070a0Smrg if test -z "$dlname" || 6485521070a0Smrg test "$dlopen_support" != yes || 6486521070a0Smrg test "$build_libtool_libs" = no; then 6487521070a0Smrg # If there is no dlname, no dlopen support or we're linking 6488521070a0Smrg # statically, we need to preload. We also need to preload any 6489521070a0Smrg # dependent libraries so libltdl's deplib preloader doesn't 6490521070a0Smrg # bomb out in the load deplibs phase. 64913e6c936aSmrg func_append dlprefiles " $lib $dependency_libs" 6492521070a0Smrg else 64933e6c936aSmrg func_append newdlfiles " $lib" 6494521070a0Smrg fi 6495521070a0Smrg continue 6496521070a0Smrg fi # $pass = dlopen 6497521070a0Smrg 6498521070a0Smrg # We need an absolute path. 6499521070a0Smrg case $ladir in 6500521070a0Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 6501521070a0Smrg *) 6502521070a0Smrg abs_ladir=`cd "$ladir" && pwd` 6503521070a0Smrg if test -z "$abs_ladir"; then 6504521070a0Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 6505521070a0Smrg func_warning "passing it literally to the linker, although it might fail" 6506521070a0Smrg abs_ladir="$ladir" 6507521070a0Smrg fi 6508521070a0Smrg ;; 6509521070a0Smrg esac 6510521070a0Smrg func_basename "$lib" 6511521070a0Smrg laname="$func_basename_result" 6512521070a0Smrg 6513521070a0Smrg # Find the relevant object directory and library name. 6514521070a0Smrg if test "X$installed" = Xyes; then 65153e6c936aSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6516521070a0Smrg func_warning "library \`$lib' was moved." 6517521070a0Smrg dir="$ladir" 6518521070a0Smrg absdir="$abs_ladir" 6519521070a0Smrg libdir="$abs_ladir" 6520521070a0Smrg else 65213e6c936aSmrg dir="$lt_sysroot$libdir" 65223e6c936aSmrg absdir="$lt_sysroot$libdir" 6523521070a0Smrg fi 6524521070a0Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 6525521070a0Smrg else 6526521070a0Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6527521070a0Smrg dir="$ladir" 6528521070a0Smrg absdir="$abs_ladir" 6529521070a0Smrg # Remove this search path later 65303e6c936aSmrg func_append notinst_path " $abs_ladir" 6531521070a0Smrg else 6532521070a0Smrg dir="$ladir/$objdir" 6533521070a0Smrg absdir="$abs_ladir/$objdir" 6534521070a0Smrg # Remove this search path later 65353e6c936aSmrg func_append notinst_path " $abs_ladir" 6536521070a0Smrg fi 6537521070a0Smrg fi # $installed = yes 6538521070a0Smrg func_stripname 'lib' '.la' "$laname" 6539521070a0Smrg name=$func_stripname_result 6540521070a0Smrg 6541521070a0Smrg # This library was specified with -dlpreopen. 6542521070a0Smrg if test "$pass" = dlpreopen; then 6543521070a0Smrg if test -z "$libdir" && test "$linkmode" = prog; then 6544521070a0Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 6545521070a0Smrg fi 65463e6c936aSmrg case "$host" in 65473e6c936aSmrg # special handling for platforms with PE-DLLs. 65483e6c936aSmrg *cygwin* | *mingw* | *cegcc* ) 65493e6c936aSmrg # Linker will automatically link against shared library if both 65503e6c936aSmrg # static and shared are present. Therefore, ensure we extract 65513e6c936aSmrg # symbols from the import library if a shared library is present 65523e6c936aSmrg # (otherwise, the dlopen module name will be incorrect). We do 65533e6c936aSmrg # this by putting the import library name into $newdlprefiles. 65543e6c936aSmrg # We recover the dlopen module name by 'saving' the la file 65553e6c936aSmrg # name in a special purpose variable, and (later) extracting the 65563e6c936aSmrg # dlname from the la file. 65573e6c936aSmrg if test -n "$dlname"; then 65583e6c936aSmrg func_tr_sh "$dir/$linklib" 65593e6c936aSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 65603e6c936aSmrg func_append newdlprefiles " $dir/$linklib" 65613e6c936aSmrg else 65623e6c936aSmrg func_append newdlprefiles " $dir/$old_library" 65633e6c936aSmrg # Keep a list of preopened convenience libraries to check 65643e6c936aSmrg # that they are being used correctly in the link pass. 65653e6c936aSmrg test -z "$libdir" && \ 65663e6c936aSmrg func_append dlpreconveniencelibs " $dir/$old_library" 65673e6c936aSmrg fi 65683e6c936aSmrg ;; 65693e6c936aSmrg * ) 65703e6c936aSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 65713e6c936aSmrg # are required to link). 65723e6c936aSmrg if test -n "$old_library"; then 65733e6c936aSmrg func_append newdlprefiles " $dir/$old_library" 65743e6c936aSmrg # Keep a list of preopened convenience libraries to check 65753e6c936aSmrg # that they are being used correctly in the link pass. 65763e6c936aSmrg test -z "$libdir" && \ 65773e6c936aSmrg func_append dlpreconveniencelibs " $dir/$old_library" 65783e6c936aSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 65793e6c936aSmrg elif test -n "$dlname"; then 65803e6c936aSmrg func_append newdlprefiles " $dir/$dlname" 65813e6c936aSmrg else 65823e6c936aSmrg func_append newdlprefiles " $dir/$linklib" 65833e6c936aSmrg fi 65843e6c936aSmrg ;; 65853e6c936aSmrg esac 6586521070a0Smrg fi # $pass = dlpreopen 6587521070a0Smrg 6588521070a0Smrg if test -z "$libdir"; then 6589521070a0Smrg # Link the convenience library 6590521070a0Smrg if test "$linkmode" = lib; then 6591521070a0Smrg deplibs="$dir/$old_library $deplibs" 6592521070a0Smrg elif test "$linkmode,$pass" = "prog,link"; then 6593521070a0Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 6594521070a0Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 6595521070a0Smrg else 6596521070a0Smrg deplibs="$lib $deplibs" # used for prog,scan pass 6597521070a0Smrg fi 6598521070a0Smrg continue 6599521070a0Smrg fi 6600521070a0Smrg 6601521070a0Smrg 6602521070a0Smrg if test "$linkmode" = prog && test "$pass" != link; then 66033e6c936aSmrg func_append newlib_search_path " $ladir" 6604521070a0Smrg deplibs="$lib $deplibs" 6605521070a0Smrg 6606521070a0Smrg linkalldeplibs=no 6607521070a0Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 6608521070a0Smrg test "$build_libtool_libs" = no; then 6609521070a0Smrg linkalldeplibs=yes 6610521070a0Smrg fi 6611521070a0Smrg 6612521070a0Smrg tmp_libs= 6613521070a0Smrg for deplib in $dependency_libs; do 6614521070a0Smrg case $deplib in 6615521070a0Smrg -L*) func_stripname '-L' '' "$deplib" 66163e6c936aSmrg func_resolve_sysroot "$func_stripname_result" 66173e6c936aSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 6618521070a0Smrg ;; 6619521070a0Smrg esac 6620521070a0Smrg # Need to link against all dependency_libs? 6621521070a0Smrg if test "$linkalldeplibs" = yes; then 6622521070a0Smrg deplibs="$deplib $deplibs" 6623521070a0Smrg else 6624521070a0Smrg # Need to hardcode shared library paths 6625521070a0Smrg # or/and link against static libraries 6626521070a0Smrg newdependency_libs="$deplib $newdependency_libs" 6627521070a0Smrg fi 66283e6c936aSmrg if $opt_preserve_dup_deps ; then 6629521070a0Smrg case "$tmp_libs " in 66303e6c936aSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6631521070a0Smrg esac 6632521070a0Smrg fi 66333e6c936aSmrg func_append tmp_libs " $deplib" 6634521070a0Smrg done # for deplib 6635521070a0Smrg continue 6636521070a0Smrg fi # $linkmode = prog... 6637521070a0Smrg 6638521070a0Smrg if test "$linkmode,$pass" = "prog,link"; then 6639521070a0Smrg if test -n "$library_names" && 6640521070a0Smrg { { test "$prefer_static_libs" = no || 6641521070a0Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 6642521070a0Smrg test -z "$old_library"; }; then 6643521070a0Smrg # We need to hardcode the library path 6644521070a0Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 6645521070a0Smrg # Make sure the rpath contains only unique directories. 6646521070a0Smrg case "$temp_rpath:" in 6647521070a0Smrg *"$absdir:"*) ;; 66483e6c936aSmrg *) func_append temp_rpath "$absdir:" ;; 6649521070a0Smrg esac 6650521070a0Smrg fi 6651521070a0Smrg 6652521070a0Smrg # Hardcode the library path. 6653521070a0Smrg # Skip directories that are in the system default run-time 6654521070a0Smrg # search path. 6655521070a0Smrg case " $sys_lib_dlsearch_path " in 6656521070a0Smrg *" $absdir "*) ;; 6657521070a0Smrg *) 6658521070a0Smrg case "$compile_rpath " in 6659521070a0Smrg *" $absdir "*) ;; 66603e6c936aSmrg *) func_append compile_rpath " $absdir" ;; 6661521070a0Smrg esac 6662521070a0Smrg ;; 6663521070a0Smrg esac 6664521070a0Smrg case " $sys_lib_dlsearch_path " in 6665521070a0Smrg *" $libdir "*) ;; 6666521070a0Smrg *) 6667521070a0Smrg case "$finalize_rpath " in 6668521070a0Smrg *" $libdir "*) ;; 66693e6c936aSmrg *) func_append finalize_rpath " $libdir" ;; 6670521070a0Smrg esac 6671521070a0Smrg ;; 6672521070a0Smrg esac 6673521070a0Smrg fi # $linkmode,$pass = prog,link... 6674521070a0Smrg 6675521070a0Smrg if test "$alldeplibs" = yes && 6676521070a0Smrg { test "$deplibs_check_method" = pass_all || 6677521070a0Smrg { test "$build_libtool_libs" = yes && 6678521070a0Smrg test -n "$library_names"; }; }; then 6679521070a0Smrg # We only need to search for static libraries 6680521070a0Smrg continue 6681521070a0Smrg fi 6682521070a0Smrg fi 6683521070a0Smrg 6684521070a0Smrg link_static=no # Whether the deplib will be linked statically 6685521070a0Smrg use_static_libs=$prefer_static_libs 6686521070a0Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 6687521070a0Smrg use_static_libs=no 6688521070a0Smrg fi 6689521070a0Smrg if test -n "$library_names" && 6690521070a0Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 6691521070a0Smrg case $host in 6692521070a0Smrg *cygwin* | *mingw* | *cegcc*) 6693521070a0Smrg # No point in relinking DLLs because paths are not encoded 66943e6c936aSmrg func_append notinst_deplibs " $lib" 6695521070a0Smrg need_relink=no 6696521070a0Smrg ;; 6697521070a0Smrg *) 6698521070a0Smrg if test "$installed" = no; then 66993e6c936aSmrg func_append notinst_deplibs " $lib" 6700521070a0Smrg need_relink=yes 6701521070a0Smrg fi 6702521070a0Smrg ;; 6703521070a0Smrg esac 6704521070a0Smrg # This is a shared library 6705521070a0Smrg 6706521070a0Smrg # Warn about portability, can't link against -module's on some 6707521070a0Smrg # systems (darwin). Don't bleat about dlopened modules though! 6708521070a0Smrg dlopenmodule="" 6709521070a0Smrg for dlpremoduletest in $dlprefiles; do 6710521070a0Smrg if test "X$dlpremoduletest" = "X$lib"; then 6711521070a0Smrg dlopenmodule="$dlpremoduletest" 6712521070a0Smrg break 6713521070a0Smrg fi 6714521070a0Smrg done 6715521070a0Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 6716ff63a143Smrg echo 6717521070a0Smrg if test "$linkmode" = prog; then 6718521070a0Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 6719521070a0Smrg else 6720521070a0Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 6721521070a0Smrg fi 6722521070a0Smrg $ECHO "*** $linklib is not portable!" 6723521070a0Smrg fi 6724521070a0Smrg if test "$linkmode" = lib && 6725521070a0Smrg test "$hardcode_into_libs" = yes; then 6726521070a0Smrg # Hardcode the library path. 6727521070a0Smrg # Skip directories that are in the system default run-time 6728521070a0Smrg # search path. 6729521070a0Smrg case " $sys_lib_dlsearch_path " in 6730521070a0Smrg *" $absdir "*) ;; 6731521070a0Smrg *) 6732521070a0Smrg case "$compile_rpath " in 6733521070a0Smrg *" $absdir "*) ;; 67343e6c936aSmrg *) func_append compile_rpath " $absdir" ;; 6735521070a0Smrg esac 6736521070a0Smrg ;; 6737521070a0Smrg esac 6738521070a0Smrg case " $sys_lib_dlsearch_path " in 6739521070a0Smrg *" $libdir "*) ;; 6740521070a0Smrg *) 6741521070a0Smrg case "$finalize_rpath " in 6742521070a0Smrg *" $libdir "*) ;; 67433e6c936aSmrg *) func_append finalize_rpath " $libdir" ;; 6744521070a0Smrg esac 6745521070a0Smrg ;; 6746521070a0Smrg esac 6747521070a0Smrg fi 6748521070a0Smrg 6749521070a0Smrg if test -n "$old_archive_from_expsyms_cmds"; then 6750521070a0Smrg # figure out the soname 6751521070a0Smrg set dummy $library_names 6752521070a0Smrg shift 6753521070a0Smrg realname="$1" 6754521070a0Smrg shift 6755521070a0Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 6756521070a0Smrg # use dlname if we got it. it's perfectly good, no? 6757521070a0Smrg if test -n "$dlname"; then 6758521070a0Smrg soname="$dlname" 6759521070a0Smrg elif test -n "$soname_spec"; then 6760521070a0Smrg # bleh windows 6761521070a0Smrg case $host in 6762521070a0Smrg *cygwin* | mingw* | *cegcc*) 6763521070a0Smrg func_arith $current - $age 6764521070a0Smrg major=$func_arith_result 6765521070a0Smrg versuffix="-$major" 6766521070a0Smrg ;; 6767521070a0Smrg esac 6768521070a0Smrg eval soname=\"$soname_spec\" 6769521070a0Smrg else 6770521070a0Smrg soname="$realname" 6771521070a0Smrg fi 6772521070a0Smrg 6773521070a0Smrg # Make a new name for the extract_expsyms_cmds to use 6774521070a0Smrg soroot="$soname" 6775521070a0Smrg func_basename "$soroot" 6776521070a0Smrg soname="$func_basename_result" 6777521070a0Smrg func_stripname 'lib' '.dll' "$soname" 6778521070a0Smrg newlib=libimp-$func_stripname_result.a 6779521070a0Smrg 6780521070a0Smrg # If the library has no export list, then create one now 6781521070a0Smrg if test -f "$output_objdir/$soname-def"; then : 6782521070a0Smrg else 6783521070a0Smrg func_verbose "extracting exported symbol list from \`$soname'" 6784521070a0Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 6785521070a0Smrg fi 6786521070a0Smrg 6787521070a0Smrg # Create $newlib 6788521070a0Smrg if test -f "$output_objdir/$newlib"; then :; else 6789521070a0Smrg func_verbose "generating import library for \`$soname'" 6790521070a0Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 6791521070a0Smrg fi 6792521070a0Smrg # make sure the library variables are pointing to the new library 6793521070a0Smrg dir=$output_objdir 6794521070a0Smrg linklib=$newlib 6795521070a0Smrg fi # test -n "$old_archive_from_expsyms_cmds" 6796521070a0Smrg 67973e6c936aSmrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 6798521070a0Smrg add_shlibpath= 6799521070a0Smrg add_dir= 6800521070a0Smrg add= 6801521070a0Smrg lib_linked=yes 6802521070a0Smrg case $hardcode_action in 6803521070a0Smrg immediate | unsupported) 6804521070a0Smrg if test "$hardcode_direct" = no; then 6805521070a0Smrg add="$dir/$linklib" 6806521070a0Smrg case $host in 6807521070a0Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 6808521070a0Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 6809521070a0Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 6810521070a0Smrg *-*-unixware7*) add_dir="-L$dir" ;; 6811521070a0Smrg *-*-darwin* ) 6812521070a0Smrg # if the lib is a (non-dlopened) module then we can not 6813521070a0Smrg # link against it, someone is ignoring the earlier warnings 6814521070a0Smrg if /usr/bin/file -L $add 2> /dev/null | 6815521070a0Smrg $GREP ": [^:]* bundle" >/dev/null ; then 6816521070a0Smrg if test "X$dlopenmodule" != "X$lib"; then 6817521070a0Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 6818521070a0Smrg if test -z "$old_library" ; then 6819ff63a143Smrg echo 6820ff63a143Smrg echo "*** And there doesn't seem to be a static archive available" 6821ff63a143Smrg echo "*** The link will probably fail, sorry" 6822521070a0Smrg else 6823521070a0Smrg add="$dir/$old_library" 6824521070a0Smrg fi 6825521070a0Smrg elif test -n "$old_library"; then 6826521070a0Smrg add="$dir/$old_library" 6827521070a0Smrg fi 6828521070a0Smrg fi 6829521070a0Smrg esac 6830521070a0Smrg elif test "$hardcode_minus_L" = no; then 6831521070a0Smrg case $host in 6832521070a0Smrg *-*-sunos*) add_shlibpath="$dir" ;; 6833521070a0Smrg esac 6834521070a0Smrg add_dir="-L$dir" 6835521070a0Smrg add="-l$name" 6836521070a0Smrg elif test "$hardcode_shlibpath_var" = no; then 6837521070a0Smrg add_shlibpath="$dir" 6838521070a0Smrg add="-l$name" 6839521070a0Smrg else 6840521070a0Smrg lib_linked=no 6841521070a0Smrg fi 6842521070a0Smrg ;; 6843521070a0Smrg relink) 6844521070a0Smrg if test "$hardcode_direct" = yes && 6845521070a0Smrg test "$hardcode_direct_absolute" = no; then 6846521070a0Smrg add="$dir/$linklib" 6847521070a0Smrg elif test "$hardcode_minus_L" = yes; then 68483e6c936aSmrg add_dir="-L$absdir" 6849521070a0Smrg # Try looking first in the location we're being installed to. 6850521070a0Smrg if test -n "$inst_prefix_dir"; then 6851521070a0Smrg case $libdir in 6852521070a0Smrg [\\/]*) 68533e6c936aSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 6854521070a0Smrg ;; 6855521070a0Smrg esac 6856521070a0Smrg fi 6857521070a0Smrg add="-l$name" 6858521070a0Smrg elif test "$hardcode_shlibpath_var" = yes; then 6859521070a0Smrg add_shlibpath="$dir" 6860521070a0Smrg add="-l$name" 6861521070a0Smrg else 6862521070a0Smrg lib_linked=no 6863521070a0Smrg fi 6864521070a0Smrg ;; 6865521070a0Smrg *) lib_linked=no ;; 6866521070a0Smrg esac 6867521070a0Smrg 6868521070a0Smrg if test "$lib_linked" != yes; then 6869521070a0Smrg func_fatal_configuration "unsupported hardcode properties" 6870521070a0Smrg fi 6871521070a0Smrg 6872521070a0Smrg if test -n "$add_shlibpath"; then 6873521070a0Smrg case :$compile_shlibpath: in 6874521070a0Smrg *":$add_shlibpath:"*) ;; 68753e6c936aSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 6876521070a0Smrg esac 6877521070a0Smrg fi 6878521070a0Smrg if test "$linkmode" = prog; then 6879521070a0Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 6880521070a0Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 6881521070a0Smrg else 6882521070a0Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 6883521070a0Smrg test -n "$add" && deplibs="$add $deplibs" 6884521070a0Smrg if test "$hardcode_direct" != yes && 6885521070a0Smrg test "$hardcode_minus_L" != yes && 6886521070a0Smrg test "$hardcode_shlibpath_var" = yes; then 6887521070a0Smrg case :$finalize_shlibpath: in 6888521070a0Smrg *":$libdir:"*) ;; 68893e6c936aSmrg *) func_append finalize_shlibpath "$libdir:" ;; 6890521070a0Smrg esac 6891521070a0Smrg fi 6892521070a0Smrg fi 6893521070a0Smrg fi 6894521070a0Smrg 68953e6c936aSmrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 6896521070a0Smrg add_shlibpath= 6897521070a0Smrg add_dir= 6898521070a0Smrg add= 6899521070a0Smrg # Finalize command for both is simple: just hardcode it. 6900521070a0Smrg if test "$hardcode_direct" = yes && 6901521070a0Smrg test "$hardcode_direct_absolute" = no; then 6902521070a0Smrg add="$libdir/$linklib" 6903521070a0Smrg elif test "$hardcode_minus_L" = yes; then 6904521070a0Smrg add_dir="-L$libdir" 6905521070a0Smrg add="-l$name" 6906521070a0Smrg elif test "$hardcode_shlibpath_var" = yes; then 6907521070a0Smrg case :$finalize_shlibpath: in 6908521070a0Smrg *":$libdir:"*) ;; 69093e6c936aSmrg *) func_append finalize_shlibpath "$libdir:" ;; 6910521070a0Smrg esac 6911521070a0Smrg add="-l$name" 6912521070a0Smrg elif test "$hardcode_automatic" = yes; then 6913521070a0Smrg if test -n "$inst_prefix_dir" && 6914521070a0Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 6915521070a0Smrg add="$inst_prefix_dir$libdir/$linklib" 6916521070a0Smrg else 6917521070a0Smrg add="$libdir/$linklib" 6918521070a0Smrg fi 6919521070a0Smrg else 6920521070a0Smrg # We cannot seem to hardcode it, guess we'll fake it. 6921521070a0Smrg add_dir="-L$libdir" 6922521070a0Smrg # Try looking first in the location we're being installed to. 6923521070a0Smrg if test -n "$inst_prefix_dir"; then 6924521070a0Smrg case $libdir in 6925521070a0Smrg [\\/]*) 69263e6c936aSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 6927521070a0Smrg ;; 6928521070a0Smrg esac 6929521070a0Smrg fi 6930521070a0Smrg add="-l$name" 6931521070a0Smrg fi 6932521070a0Smrg 6933521070a0Smrg if test "$linkmode" = prog; then 6934521070a0Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 6935521070a0Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 6936521070a0Smrg else 6937521070a0Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 6938521070a0Smrg test -n "$add" && deplibs="$add $deplibs" 6939521070a0Smrg fi 6940521070a0Smrg fi 6941521070a0Smrg elif test "$linkmode" = prog; then 6942521070a0Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 6943521070a0Smrg # is not unsupported. This is valid on all known static and 6944521070a0Smrg # shared platforms. 6945521070a0Smrg if test "$hardcode_direct" != unsupported; then 6946521070a0Smrg test -n "$old_library" && linklib="$old_library" 6947521070a0Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 6948521070a0Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 6949521070a0Smrg else 6950521070a0Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 6951521070a0Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 6952521070a0Smrg fi 6953521070a0Smrg elif test "$build_libtool_libs" = yes; then 6954521070a0Smrg # Not a shared library 6955521070a0Smrg if test "$deplibs_check_method" != pass_all; then 6956521070a0Smrg # We're trying link a shared library against a static one 6957521070a0Smrg # but the system doesn't support it. 6958521070a0Smrg 6959521070a0Smrg # Just print a warning and add the library to dependency_libs so 6960521070a0Smrg # that the program can be linked against the static library. 6961ff63a143Smrg echo 6962521070a0Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 6963ff63a143Smrg echo "*** I have the capability to make that library automatically link in when" 6964ff63a143Smrg echo "*** you link to this library. But I can only do this if you have a" 6965ff63a143Smrg echo "*** shared version of the library, which you do not appear to have." 6966521070a0Smrg if test "$module" = yes; then 6967ff63a143Smrg echo "*** But as you try to build a module library, libtool will still create " 6968ff63a143Smrg echo "*** a static module, that should work as long as the dlopening application" 6969ff63a143Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 6970521070a0Smrg if test -z "$global_symbol_pipe"; then 6971ff63a143Smrg echo 6972ff63a143Smrg echo "*** However, this would only work if libtool was able to extract symbol" 6973ff63a143Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 6974ff63a143Smrg echo "*** not find such a program. So, this module is probably useless." 6975ff63a143Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 6976521070a0Smrg fi 6977521070a0Smrg if test "$build_old_libs" = no; then 6978521070a0Smrg build_libtool_libs=module 6979521070a0Smrg build_old_libs=yes 6980521070a0Smrg else 6981521070a0Smrg build_libtool_libs=no 6982521070a0Smrg fi 6983521070a0Smrg fi 6984521070a0Smrg else 6985521070a0Smrg deplibs="$dir/$old_library $deplibs" 6986521070a0Smrg link_static=yes 6987521070a0Smrg fi 6988521070a0Smrg fi # link shared/static library? 6989521070a0Smrg 6990521070a0Smrg if test "$linkmode" = lib; then 6991521070a0Smrg if test -n "$dependency_libs" && 6992521070a0Smrg { test "$hardcode_into_libs" != yes || 6993521070a0Smrg test "$build_old_libs" = yes || 6994521070a0Smrg test "$link_static" = yes; }; then 6995521070a0Smrg # Extract -R from dependency_libs 6996521070a0Smrg temp_deplibs= 6997521070a0Smrg for libdir in $dependency_libs; do 6998521070a0Smrg case $libdir in 6999521070a0Smrg -R*) func_stripname '-R' '' "$libdir" 7000521070a0Smrg temp_xrpath=$func_stripname_result 7001521070a0Smrg case " $xrpath " in 7002521070a0Smrg *" $temp_xrpath "*) ;; 70033e6c936aSmrg *) func_append xrpath " $temp_xrpath";; 7004521070a0Smrg esac;; 70053e6c936aSmrg *) func_append temp_deplibs " $libdir";; 7006521070a0Smrg esac 7007521070a0Smrg done 7008521070a0Smrg dependency_libs="$temp_deplibs" 7009521070a0Smrg fi 7010521070a0Smrg 70113e6c936aSmrg func_append newlib_search_path " $absdir" 7012521070a0Smrg # Link against this library 7013521070a0Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 7014521070a0Smrg # ... and its dependency_libs 7015521070a0Smrg tmp_libs= 7016521070a0Smrg for deplib in $dependency_libs; do 7017521070a0Smrg newdependency_libs="$deplib $newdependency_libs" 70183e6c936aSmrg case $deplib in 70193e6c936aSmrg -L*) func_stripname '-L' '' "$deplib" 70203e6c936aSmrg func_resolve_sysroot "$func_stripname_result";; 70213e6c936aSmrg *) func_resolve_sysroot "$deplib" ;; 70223e6c936aSmrg esac 70233e6c936aSmrg if $opt_preserve_dup_deps ; then 7024521070a0Smrg case "$tmp_libs " in 70253e6c936aSmrg *" $func_resolve_sysroot_result "*) 70263e6c936aSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 7027521070a0Smrg esac 7028521070a0Smrg fi 70293e6c936aSmrg func_append tmp_libs " $func_resolve_sysroot_result" 7030521070a0Smrg done 7031521070a0Smrg 7032521070a0Smrg if test "$link_all_deplibs" != no; then 7033521070a0Smrg # Add the search paths of all dependency libraries 7034521070a0Smrg for deplib in $dependency_libs; do 7035ff63a143Smrg path= 7036521070a0Smrg case $deplib in 7037521070a0Smrg -L*) path="$deplib" ;; 7038521070a0Smrg *.la) 70393e6c936aSmrg func_resolve_sysroot "$deplib" 70403e6c936aSmrg deplib=$func_resolve_sysroot_result 7041521070a0Smrg func_dirname "$deplib" "" "." 70423e6c936aSmrg dir=$func_dirname_result 7043521070a0Smrg # We need an absolute path. 7044521070a0Smrg case $dir in 7045521070a0Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 7046521070a0Smrg *) 7047521070a0Smrg absdir=`cd "$dir" && pwd` 7048521070a0Smrg if test -z "$absdir"; then 7049521070a0Smrg func_warning "cannot determine absolute directory name of \`$dir'" 7050521070a0Smrg absdir="$dir" 7051521070a0Smrg fi 7052521070a0Smrg ;; 7053521070a0Smrg esac 7054521070a0Smrg if $GREP "^installed=no" $deplib > /dev/null; then 7055521070a0Smrg case $host in 7056521070a0Smrg *-*-darwin*) 7057521070a0Smrg depdepl= 7058521070a0Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 7059521070a0Smrg if test -n "$deplibrary_names" ; then 7060521070a0Smrg for tmp in $deplibrary_names ; do 7061521070a0Smrg depdepl=$tmp 7062521070a0Smrg done 7063521070a0Smrg if test -f "$absdir/$objdir/$depdepl" ; then 7064521070a0Smrg depdepl="$absdir/$objdir/$depdepl" 7065521070a0Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7066521070a0Smrg if test -z "$darwin_install_name"; then 7067521070a0Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7068521070a0Smrg fi 70693e6c936aSmrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 70703e6c936aSmrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 7071521070a0Smrg path= 7072521070a0Smrg fi 7073521070a0Smrg fi 7074521070a0Smrg ;; 7075521070a0Smrg *) 7076521070a0Smrg path="-L$absdir/$objdir" 7077521070a0Smrg ;; 7078521070a0Smrg esac 7079521070a0Smrg else 7080521070a0Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 7081521070a0Smrg test -z "$libdir" && \ 7082521070a0Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 7083521070a0Smrg test "$absdir" != "$libdir" && \ 7084521070a0Smrg func_warning "\`$deplib' seems to be moved" 7085521070a0Smrg 7086521070a0Smrg path="-L$absdir" 7087521070a0Smrg fi 7088521070a0Smrg ;; 7089521070a0Smrg esac 7090521070a0Smrg case " $deplibs " in 7091521070a0Smrg *" $path "*) ;; 7092521070a0Smrg *) deplibs="$path $deplibs" ;; 7093521070a0Smrg esac 7094521070a0Smrg done 7095521070a0Smrg fi # link_all_deplibs != no 7096521070a0Smrg fi # linkmode = lib 7097521070a0Smrg done # for deplib in $libs 7098521070a0Smrg if test "$pass" = link; then 7099521070a0Smrg if test "$linkmode" = "prog"; then 7100521070a0Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 7101521070a0Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 7102521070a0Smrg else 7103ff63a143Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7104521070a0Smrg fi 7105521070a0Smrg fi 7106521070a0Smrg dependency_libs="$newdependency_libs" 7107521070a0Smrg if test "$pass" = dlpreopen; then 7108521070a0Smrg # Link the dlpreopened libraries before other libraries 7109521070a0Smrg for deplib in $save_deplibs; do 7110521070a0Smrg deplibs="$deplib $deplibs" 7111521070a0Smrg done 7112521070a0Smrg fi 7113521070a0Smrg if test "$pass" != dlopen; then 7114521070a0Smrg if test "$pass" != conv; then 7115521070a0Smrg # Make sure lib_search_path contains only unique directories. 7116521070a0Smrg lib_search_path= 7117521070a0Smrg for dir in $newlib_search_path; do 7118521070a0Smrg case "$lib_search_path " in 7119521070a0Smrg *" $dir "*) ;; 71203e6c936aSmrg *) func_append lib_search_path " $dir" ;; 7121521070a0Smrg esac 7122521070a0Smrg done 7123521070a0Smrg newlib_search_path= 7124521070a0Smrg fi 7125521070a0Smrg 7126521070a0Smrg if test "$linkmode,$pass" != "prog,link"; then 7127521070a0Smrg vars="deplibs" 7128521070a0Smrg else 7129521070a0Smrg vars="compile_deplibs finalize_deplibs" 7130521070a0Smrg fi 7131521070a0Smrg for var in $vars dependency_libs; do 7132521070a0Smrg # Add libraries to $var in reverse order 7133521070a0Smrg eval tmp_libs=\"\$$var\" 7134521070a0Smrg new_libs= 7135521070a0Smrg for deplib in $tmp_libs; do 7136521070a0Smrg # FIXME: Pedantically, this is the right thing to do, so 7137521070a0Smrg # that some nasty dependency loop isn't accidentally 7138521070a0Smrg # broken: 7139521070a0Smrg #new_libs="$deplib $new_libs" 7140521070a0Smrg # Pragmatically, this seems to cause very few problems in 7141521070a0Smrg # practice: 7142521070a0Smrg case $deplib in 7143521070a0Smrg -L*) new_libs="$deplib $new_libs" ;; 7144521070a0Smrg -R*) ;; 7145521070a0Smrg *) 7146521070a0Smrg # And here is the reason: when a library appears more 7147521070a0Smrg # than once as an explicit dependence of a library, or 7148521070a0Smrg # is implicitly linked in more than once by the 7149521070a0Smrg # compiler, it is considered special, and multiple 7150521070a0Smrg # occurrences thereof are not removed. Compare this 7151521070a0Smrg # with having the same library being listed as a 7152521070a0Smrg # dependency of multiple other libraries: in this case, 7153521070a0Smrg # we know (pedantically, we assume) the library does not 7154521070a0Smrg # need to be listed more than once, so we keep only the 7155521070a0Smrg # last copy. This is not always right, but it is rare 7156521070a0Smrg # enough that we require users that really mean to play 7157521070a0Smrg # such unportable linking tricks to link the library 7158521070a0Smrg # using -Wl,-lname, so that libtool does not consider it 7159521070a0Smrg # for duplicate removal. 7160521070a0Smrg case " $specialdeplibs " in 7161521070a0Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 7162521070a0Smrg *) 7163521070a0Smrg case " $new_libs " in 7164521070a0Smrg *" $deplib "*) ;; 7165521070a0Smrg *) new_libs="$deplib $new_libs" ;; 7166521070a0Smrg esac 7167521070a0Smrg ;; 7168521070a0Smrg esac 7169521070a0Smrg ;; 7170521070a0Smrg esac 7171521070a0Smrg done 7172521070a0Smrg tmp_libs= 7173521070a0Smrg for deplib in $new_libs; do 7174521070a0Smrg case $deplib in 7175521070a0Smrg -L*) 7176521070a0Smrg case " $tmp_libs " in 7177521070a0Smrg *" $deplib "*) ;; 71783e6c936aSmrg *) func_append tmp_libs " $deplib" ;; 7179521070a0Smrg esac 7180521070a0Smrg ;; 71813e6c936aSmrg *) func_append tmp_libs " $deplib" ;; 7182521070a0Smrg esac 7183521070a0Smrg done 7184521070a0Smrg eval $var=\"$tmp_libs\" 7185521070a0Smrg done # for var 7186521070a0Smrg fi 7187521070a0Smrg # Last step: remove runtime libs from dependency_libs 7188521070a0Smrg # (they stay in deplibs) 7189521070a0Smrg tmp_libs= 7190521070a0Smrg for i in $dependency_libs ; do 7191521070a0Smrg case " $predeps $postdeps $compiler_lib_search_path " in 7192521070a0Smrg *" $i "*) 7193521070a0Smrg i="" 7194521070a0Smrg ;; 7195521070a0Smrg esac 7196521070a0Smrg if test -n "$i" ; then 71973e6c936aSmrg func_append tmp_libs " $i" 7198521070a0Smrg fi 7199521070a0Smrg done 7200521070a0Smrg dependency_libs=$tmp_libs 7201521070a0Smrg done # for pass 7202521070a0Smrg if test "$linkmode" = prog; then 7203521070a0Smrg dlfiles="$newdlfiles" 7204521070a0Smrg fi 7205521070a0Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 7206521070a0Smrg dlprefiles="$newdlprefiles" 7207521070a0Smrg fi 7208521070a0Smrg 7209521070a0Smrg case $linkmode in 7210521070a0Smrg oldlib) 7211521070a0Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 7212521070a0Smrg func_warning "\`-dlopen' is ignored for archives" 7213521070a0Smrg fi 7214521070a0Smrg 7215521070a0Smrg case " $deplibs" in 7216521070a0Smrg *\ -l* | *\ -L*) 7217521070a0Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 7218521070a0Smrg esac 7219521070a0Smrg 7220521070a0Smrg test -n "$rpath" && \ 7221521070a0Smrg func_warning "\`-rpath' is ignored for archives" 7222521070a0Smrg 7223521070a0Smrg test -n "$xrpath" && \ 7224521070a0Smrg func_warning "\`-R' is ignored for archives" 7225521070a0Smrg 7226521070a0Smrg test -n "$vinfo" && \ 7227521070a0Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 7228521070a0Smrg 7229521070a0Smrg test -n "$release" && \ 7230521070a0Smrg func_warning "\`-release' is ignored for archives" 7231521070a0Smrg 7232521070a0Smrg test -n "$export_symbols$export_symbols_regex" && \ 7233521070a0Smrg func_warning "\`-export-symbols' is ignored for archives" 7234521070a0Smrg 7235521070a0Smrg # Now set the variables for building old libraries. 7236521070a0Smrg build_libtool_libs=no 7237521070a0Smrg oldlibs="$output" 72383e6c936aSmrg func_append objs "$old_deplibs" 7239521070a0Smrg ;; 7240521070a0Smrg 7241521070a0Smrg lib) 7242521070a0Smrg # Make sure we only generate libraries of the form `libNAME.la'. 7243521070a0Smrg case $outputname in 7244521070a0Smrg lib*) 7245521070a0Smrg func_stripname 'lib' '.la' "$outputname" 7246521070a0Smrg name=$func_stripname_result 7247521070a0Smrg eval shared_ext=\"$shrext_cmds\" 7248521070a0Smrg eval libname=\"$libname_spec\" 7249521070a0Smrg ;; 7250521070a0Smrg *) 7251521070a0Smrg test "$module" = no && \ 7252521070a0Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 7253521070a0Smrg 7254521070a0Smrg if test "$need_lib_prefix" != no; then 7255521070a0Smrg # Add the "lib" prefix for modules if required 7256521070a0Smrg func_stripname '' '.la' "$outputname" 7257521070a0Smrg name=$func_stripname_result 7258521070a0Smrg eval shared_ext=\"$shrext_cmds\" 7259521070a0Smrg eval libname=\"$libname_spec\" 7260521070a0Smrg else 7261521070a0Smrg func_stripname '' '.la' "$outputname" 7262521070a0Smrg libname=$func_stripname_result 7263521070a0Smrg fi 7264521070a0Smrg ;; 7265521070a0Smrg esac 7266521070a0Smrg 7267521070a0Smrg if test -n "$objs"; then 7268521070a0Smrg if test "$deplibs_check_method" != pass_all; then 7269521070a0Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 7270521070a0Smrg else 7271ff63a143Smrg echo 7272521070a0Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 7273521070a0Smrg $ECHO "*** objects $objs is not portable!" 72743e6c936aSmrg func_append libobjs " $objs" 7275521070a0Smrg fi 7276521070a0Smrg fi 7277521070a0Smrg 7278521070a0Smrg test "$dlself" != no && \ 7279521070a0Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 7280521070a0Smrg 7281521070a0Smrg set dummy $rpath 7282521070a0Smrg shift 7283521070a0Smrg test "$#" -gt 1 && \ 7284521070a0Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 7285521070a0Smrg 7286521070a0Smrg install_libdir="$1" 7287521070a0Smrg 7288521070a0Smrg oldlibs= 7289521070a0Smrg if test -z "$rpath"; then 7290521070a0Smrg if test "$build_libtool_libs" = yes; then 7291521070a0Smrg # Building a libtool convenience library. 7292521070a0Smrg # Some compilers have problems with a `.al' extension so 7293521070a0Smrg # convenience libraries should have the same extension an 7294521070a0Smrg # archive normally would. 7295521070a0Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 7296521070a0Smrg build_libtool_libs=convenience 7297521070a0Smrg build_old_libs=yes 7298521070a0Smrg fi 7299521070a0Smrg 7300521070a0Smrg test -n "$vinfo" && \ 7301521070a0Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 7302521070a0Smrg 7303521070a0Smrg test -n "$release" && \ 7304521070a0Smrg func_warning "\`-release' is ignored for convenience libraries" 7305521070a0Smrg else 7306521070a0Smrg 7307521070a0Smrg # Parse the version information argument. 7308521070a0Smrg save_ifs="$IFS"; IFS=':' 7309521070a0Smrg set dummy $vinfo 0 0 0 7310521070a0Smrg shift 7311521070a0Smrg IFS="$save_ifs" 7312521070a0Smrg 7313521070a0Smrg test -n "$7" && \ 7314521070a0Smrg func_fatal_help "too many parameters to \`-version-info'" 7315521070a0Smrg 7316521070a0Smrg # convert absolute version numbers to libtool ages 7317521070a0Smrg # this retains compatibility with .la files and attempts 7318521070a0Smrg # to make the code below a bit more comprehensible 7319521070a0Smrg 7320521070a0Smrg case $vinfo_number in 7321521070a0Smrg yes) 7322521070a0Smrg number_major="$1" 7323521070a0Smrg number_minor="$2" 7324521070a0Smrg number_revision="$3" 7325521070a0Smrg # 7326521070a0Smrg # There are really only two kinds -- those that 7327521070a0Smrg # use the current revision as the major version 7328521070a0Smrg # and those that subtract age and use age as 7329521070a0Smrg # a minor version. But, then there is irix 7330521070a0Smrg # which has an extra 1 added just for fun 7331521070a0Smrg # 7332521070a0Smrg case $version_type in 73333e6c936aSmrg # correct linux to gnu/linux during the next big refactor 7334521070a0Smrg darwin|linux|osf|windows|none) 7335521070a0Smrg func_arith $number_major + $number_minor 7336521070a0Smrg current=$func_arith_result 7337521070a0Smrg age="$number_minor" 7338521070a0Smrg revision="$number_revision" 7339521070a0Smrg ;; 7340ff63a143Smrg freebsd-aout|freebsd-elf|qnx|sunos) 7341521070a0Smrg current="$number_major" 7342521070a0Smrg revision="$number_minor" 7343521070a0Smrg age="0" 7344521070a0Smrg ;; 7345521070a0Smrg irix|nonstopux) 7346521070a0Smrg func_arith $number_major + $number_minor 7347521070a0Smrg current=$func_arith_result 7348521070a0Smrg age="$number_minor" 7349521070a0Smrg revision="$number_minor" 7350521070a0Smrg lt_irix_increment=no 7351521070a0Smrg ;; 7352521070a0Smrg esac 7353521070a0Smrg ;; 7354521070a0Smrg no) 7355521070a0Smrg current="$1" 7356521070a0Smrg revision="$2" 7357521070a0Smrg age="$3" 7358521070a0Smrg ;; 7359521070a0Smrg esac 7360521070a0Smrg 7361521070a0Smrg # Check that each of the things are valid numbers. 7362521070a0Smrg case $current in 7363521070a0Smrg 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]) ;; 7364521070a0Smrg *) 7365521070a0Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 7366521070a0Smrg func_fatal_error "\`$vinfo' is not valid version information" 7367521070a0Smrg ;; 7368521070a0Smrg esac 7369521070a0Smrg 7370521070a0Smrg case $revision in 7371521070a0Smrg 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]) ;; 7372521070a0Smrg *) 7373521070a0Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 7374521070a0Smrg func_fatal_error "\`$vinfo' is not valid version information" 7375521070a0Smrg ;; 7376521070a0Smrg esac 7377521070a0Smrg 7378521070a0Smrg case $age in 7379521070a0Smrg 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]) ;; 7380521070a0Smrg *) 7381521070a0Smrg func_error "AGE \`$age' must be a nonnegative integer" 7382521070a0Smrg func_fatal_error "\`$vinfo' is not valid version information" 7383521070a0Smrg ;; 7384521070a0Smrg esac 7385521070a0Smrg 7386521070a0Smrg if test "$age" -gt "$current"; then 7387521070a0Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 7388521070a0Smrg func_fatal_error "\`$vinfo' is not valid version information" 7389521070a0Smrg fi 7390521070a0Smrg 7391521070a0Smrg # Calculate the version variables. 7392521070a0Smrg major= 7393521070a0Smrg versuffix= 7394521070a0Smrg verstring= 7395521070a0Smrg case $version_type in 7396521070a0Smrg none) ;; 7397521070a0Smrg 7398521070a0Smrg darwin) 7399521070a0Smrg # Like Linux, but with the current version available in 7400521070a0Smrg # verstring for coding it into the library header 7401521070a0Smrg func_arith $current - $age 7402521070a0Smrg major=.$func_arith_result 7403521070a0Smrg versuffix="$major.$age.$revision" 7404521070a0Smrg # Darwin ld doesn't like 0 for these options... 7405521070a0Smrg func_arith $current + 1 7406521070a0Smrg minor_current=$func_arith_result 7407521070a0Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 7408521070a0Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 7409521070a0Smrg ;; 7410521070a0Smrg 7411521070a0Smrg freebsd-aout) 7412521070a0Smrg major=".$current" 7413521070a0Smrg versuffix=".$current.$revision"; 7414521070a0Smrg ;; 7415521070a0Smrg 7416521070a0Smrg freebsd-elf) 7417521070a0Smrg major=".$current" 7418521070a0Smrg versuffix=".$current" 7419521070a0Smrg ;; 7420521070a0Smrg 7421521070a0Smrg irix | nonstopux) 7422521070a0Smrg if test "X$lt_irix_increment" = "Xno"; then 7423521070a0Smrg func_arith $current - $age 7424521070a0Smrg else 7425521070a0Smrg func_arith $current - $age + 1 7426521070a0Smrg fi 7427521070a0Smrg major=$func_arith_result 7428521070a0Smrg 7429521070a0Smrg case $version_type in 7430521070a0Smrg nonstopux) verstring_prefix=nonstopux ;; 7431521070a0Smrg *) verstring_prefix=sgi ;; 7432521070a0Smrg esac 7433521070a0Smrg verstring="$verstring_prefix$major.$revision" 7434521070a0Smrg 7435521070a0Smrg # Add in all the interfaces that we are compatible with. 7436521070a0Smrg loop=$revision 7437521070a0Smrg while test "$loop" -ne 0; do 7438521070a0Smrg func_arith $revision - $loop 7439521070a0Smrg iface=$func_arith_result 7440521070a0Smrg func_arith $loop - 1 7441521070a0Smrg loop=$func_arith_result 7442521070a0Smrg verstring="$verstring_prefix$major.$iface:$verstring" 7443521070a0Smrg done 7444521070a0Smrg 7445521070a0Smrg # Before this point, $major must not contain `.'. 7446521070a0Smrg major=.$major 7447521070a0Smrg versuffix="$major.$revision" 7448521070a0Smrg ;; 7449521070a0Smrg 74503e6c936aSmrg linux) # correct to gnu/linux during the next big refactor 7451521070a0Smrg func_arith $current - $age 7452521070a0Smrg major=.$func_arith_result 7453521070a0Smrg versuffix="$major.$age.$revision" 7454521070a0Smrg ;; 7455521070a0Smrg 7456521070a0Smrg osf) 7457521070a0Smrg func_arith $current - $age 7458521070a0Smrg major=.$func_arith_result 7459521070a0Smrg versuffix=".$current.$age.$revision" 7460521070a0Smrg verstring="$current.$age.$revision" 7461521070a0Smrg 7462521070a0Smrg # Add in all the interfaces that we are compatible with. 7463521070a0Smrg loop=$age 7464521070a0Smrg while test "$loop" -ne 0; do 7465521070a0Smrg func_arith $current - $loop 7466521070a0Smrg iface=$func_arith_result 7467521070a0Smrg func_arith $loop - 1 7468521070a0Smrg loop=$func_arith_result 7469521070a0Smrg verstring="$verstring:${iface}.0" 7470521070a0Smrg done 7471521070a0Smrg 7472521070a0Smrg # Make executables depend on our current version. 74733e6c936aSmrg func_append verstring ":${current}.0" 7474521070a0Smrg ;; 7475521070a0Smrg 7476521070a0Smrg qnx) 7477521070a0Smrg major=".$current" 7478521070a0Smrg versuffix=".$current" 7479521070a0Smrg ;; 7480521070a0Smrg 7481521070a0Smrg sunos) 7482521070a0Smrg major=".$current" 7483521070a0Smrg versuffix=".$current.$revision" 7484521070a0Smrg ;; 7485521070a0Smrg 7486521070a0Smrg windows) 7487521070a0Smrg # Use '-' rather than '.', since we only want one 7488521070a0Smrg # extension on DOS 8.3 filesystems. 7489521070a0Smrg func_arith $current - $age 7490521070a0Smrg major=$func_arith_result 7491521070a0Smrg versuffix="-$major" 7492521070a0Smrg ;; 7493521070a0Smrg 7494521070a0Smrg *) 7495521070a0Smrg func_fatal_configuration "unknown library version type \`$version_type'" 7496521070a0Smrg ;; 7497521070a0Smrg esac 7498521070a0Smrg 7499521070a0Smrg # Clear the version info if we defaulted, and they specified a release. 7500521070a0Smrg if test -z "$vinfo" && test -n "$release"; then 7501521070a0Smrg major= 7502521070a0Smrg case $version_type in 7503521070a0Smrg darwin) 7504521070a0Smrg # we can't check for "0.0" in archive_cmds due to quoting 7505521070a0Smrg # problems, so we reset it completely 7506521070a0Smrg verstring= 7507521070a0Smrg ;; 7508521070a0Smrg *) 7509521070a0Smrg verstring="0.0" 7510521070a0Smrg ;; 7511521070a0Smrg esac 7512521070a0Smrg if test "$need_version" = no; then 7513521070a0Smrg versuffix= 7514521070a0Smrg else 7515521070a0Smrg versuffix=".0.0" 7516521070a0Smrg fi 7517521070a0Smrg fi 7518521070a0Smrg 7519521070a0Smrg # Remove version info from name if versioning should be avoided 7520521070a0Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 7521521070a0Smrg major= 7522521070a0Smrg versuffix= 7523521070a0Smrg verstring="" 7524521070a0Smrg fi 7525521070a0Smrg 7526521070a0Smrg # Check to see if the archive will have undefined symbols. 7527521070a0Smrg if test "$allow_undefined" = yes; then 7528521070a0Smrg if test "$allow_undefined_flag" = unsupported; then 7529521070a0Smrg func_warning "undefined symbols not allowed in $host shared libraries" 7530521070a0Smrg build_libtool_libs=no 7531521070a0Smrg build_old_libs=yes 7532521070a0Smrg fi 7533521070a0Smrg else 7534521070a0Smrg # Don't allow undefined symbols. 7535521070a0Smrg allow_undefined_flag="$no_undefined_flag" 7536521070a0Smrg fi 7537521070a0Smrg 7538521070a0Smrg fi 7539521070a0Smrg 7540521070a0Smrg func_generate_dlsyms "$libname" "$libname" "yes" 75413e6c936aSmrg func_append libobjs " $symfileobj" 7542521070a0Smrg test "X$libobjs" = "X " && libobjs= 7543521070a0Smrg 75443e6c936aSmrg if test "$opt_mode" != relink; then 7545521070a0Smrg # Remove our outputs, but don't remove object files since they 7546521070a0Smrg # may have been created when compiling PIC objects. 7547521070a0Smrg removelist= 7548521070a0Smrg tempremovelist=`$ECHO "$output_objdir/*"` 7549521070a0Smrg for p in $tempremovelist; do 7550521070a0Smrg case $p in 7551521070a0Smrg *.$objext | *.gcno) 7552521070a0Smrg ;; 7553521070a0Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 7554521070a0Smrg if test "X$precious_files_regex" != "X"; then 7555521070a0Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 7556521070a0Smrg then 7557521070a0Smrg continue 7558521070a0Smrg fi 7559521070a0Smrg fi 75603e6c936aSmrg func_append removelist " $p" 7561521070a0Smrg ;; 7562521070a0Smrg *) ;; 7563521070a0Smrg esac 7564521070a0Smrg done 7565521070a0Smrg test -n "$removelist" && \ 7566521070a0Smrg func_show_eval "${RM}r \$removelist" 7567521070a0Smrg fi 7568521070a0Smrg 7569521070a0Smrg # Now set the variables for building old libraries. 7570521070a0Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 75713e6c936aSmrg func_append oldlibs " $output_objdir/$libname.$libext" 7572521070a0Smrg 7573521070a0Smrg # Transform .lo files to .o files. 7574ff63a143Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 7575521070a0Smrg fi 7576521070a0Smrg 7577521070a0Smrg # Eliminate all temporary directories. 7578521070a0Smrg #for path in $notinst_path; do 7579ff63a143Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 7580ff63a143Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 7581ff63a143Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 7582521070a0Smrg #done 7583521070a0Smrg 7584521070a0Smrg if test -n "$xrpath"; then 7585521070a0Smrg # If the user specified any rpath flags, then add them. 7586521070a0Smrg temp_xrpath= 7587521070a0Smrg for libdir in $xrpath; do 75883e6c936aSmrg func_replace_sysroot "$libdir" 75893e6c936aSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 7590521070a0Smrg case "$finalize_rpath " in 7591521070a0Smrg *" $libdir "*) ;; 75923e6c936aSmrg *) func_append finalize_rpath " $libdir" ;; 7593521070a0Smrg esac 7594521070a0Smrg done 7595521070a0Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 7596521070a0Smrg dependency_libs="$temp_xrpath $dependency_libs" 7597521070a0Smrg fi 7598521070a0Smrg fi 7599521070a0Smrg 7600521070a0Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 7601521070a0Smrg old_dlfiles="$dlfiles" 7602521070a0Smrg dlfiles= 7603521070a0Smrg for lib in $old_dlfiles; do 7604521070a0Smrg case " $dlprefiles $dlfiles " in 7605521070a0Smrg *" $lib "*) ;; 76063e6c936aSmrg *) func_append dlfiles " $lib" ;; 7607521070a0Smrg esac 7608521070a0Smrg done 7609521070a0Smrg 7610521070a0Smrg # Make sure dlprefiles contains only unique files 7611521070a0Smrg old_dlprefiles="$dlprefiles" 7612521070a0Smrg dlprefiles= 7613521070a0Smrg for lib in $old_dlprefiles; do 7614521070a0Smrg case "$dlprefiles " in 7615521070a0Smrg *" $lib "*) ;; 76163e6c936aSmrg *) func_append dlprefiles " $lib" ;; 7617521070a0Smrg esac 7618521070a0Smrg done 7619521070a0Smrg 7620521070a0Smrg if test "$build_libtool_libs" = yes; then 7621521070a0Smrg if test -n "$rpath"; then 7622521070a0Smrg case $host in 7623ff63a143Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 7624521070a0Smrg # these systems don't actually have a c library (as such)! 7625521070a0Smrg ;; 7626521070a0Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7627521070a0Smrg # Rhapsody C library is in the System framework 76283e6c936aSmrg func_append deplibs " System.ltframework" 7629521070a0Smrg ;; 7630521070a0Smrg *-*-netbsd*) 7631521070a0Smrg # Don't link with libc until the a.out ld.so is fixed. 7632521070a0Smrg ;; 7633521070a0Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 7634521070a0Smrg # Do not include libc due to us having libc/libc_r. 7635521070a0Smrg ;; 7636521070a0Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7637521070a0Smrg # Causes problems with __ctype 7638521070a0Smrg ;; 7639521070a0Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7640521070a0Smrg # Compiler inserts libc in the correct place for threads to work 7641521070a0Smrg ;; 7642521070a0Smrg *) 7643521070a0Smrg # Add libc to deplibs on all other systems if necessary. 7644521070a0Smrg if test "$build_libtool_need_lc" = "yes"; then 76453e6c936aSmrg func_append deplibs " -lc" 7646521070a0Smrg fi 7647521070a0Smrg ;; 7648521070a0Smrg esac 7649521070a0Smrg fi 7650521070a0Smrg 7651521070a0Smrg # Transform deplibs into only deplibs that can be linked in shared. 7652521070a0Smrg name_save=$name 7653521070a0Smrg libname_save=$libname 7654521070a0Smrg release_save=$release 7655521070a0Smrg versuffix_save=$versuffix 7656521070a0Smrg major_save=$major 7657521070a0Smrg # I'm not sure if I'm treating the release correctly. I think 7658521070a0Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 7659521070a0Smrg # add it in twice. Is that correct? 7660521070a0Smrg release="" 7661521070a0Smrg versuffix="" 7662521070a0Smrg major="" 7663521070a0Smrg newdeplibs= 7664521070a0Smrg droppeddeps=no 7665521070a0Smrg case $deplibs_check_method in 7666521070a0Smrg pass_all) 7667521070a0Smrg # Don't check for shared/static. Everything works. 7668521070a0Smrg # This might be a little naive. We might want to check 7669521070a0Smrg # whether the library exists or not. But this is on 7670521070a0Smrg # osf3 & osf4 and I'm not really sure... Just 7671521070a0Smrg # implementing what was already the behavior. 7672521070a0Smrg newdeplibs=$deplibs 7673521070a0Smrg ;; 7674521070a0Smrg test_compile) 7675521070a0Smrg # This code stresses the "libraries are programs" paradigm to its 7676521070a0Smrg # limits. Maybe even breaks it. We compile a program, linking it 7677521070a0Smrg # against the deplibs as a proxy for the library. Then we can check 7678521070a0Smrg # whether they linked in statically or dynamically with ldd. 7679521070a0Smrg $opt_dry_run || $RM conftest.c 7680521070a0Smrg cat > conftest.c <<EOF 7681521070a0Smrg int main() { return 0; } 7682521070a0SmrgEOF 7683521070a0Smrg $opt_dry_run || $RM conftest 7684521070a0Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 7685521070a0Smrg ldd_output=`ldd conftest` 7686521070a0Smrg for i in $deplibs; do 7687521070a0Smrg case $i in 7688521070a0Smrg -l*) 7689521070a0Smrg func_stripname -l '' "$i" 7690521070a0Smrg name=$func_stripname_result 7691521070a0Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7692521070a0Smrg case " $predeps $postdeps " in 7693521070a0Smrg *" $i "*) 76943e6c936aSmrg func_append newdeplibs " $i" 7695521070a0Smrg i="" 7696521070a0Smrg ;; 7697521070a0Smrg esac 7698521070a0Smrg fi 7699521070a0Smrg if test -n "$i" ; then 7700521070a0Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7701521070a0Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7702521070a0Smrg set dummy $deplib_matches; shift 7703521070a0Smrg deplib_match=$1 7704521070a0Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 77053e6c936aSmrg func_append newdeplibs " $i" 7706521070a0Smrg else 7707521070a0Smrg droppeddeps=yes 7708ff63a143Smrg echo 7709521070a0Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7710ff63a143Smrg echo "*** I have the capability to make that library automatically link in when" 7711ff63a143Smrg echo "*** you link to this library. But I can only do this if you have a" 7712ff63a143Smrg echo "*** shared version of the library, which I believe you do not have" 7713ff63a143Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 7714ff63a143Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 7715521070a0Smrg fi 7716521070a0Smrg fi 7717521070a0Smrg ;; 7718521070a0Smrg *) 77193e6c936aSmrg func_append newdeplibs " $i" 7720521070a0Smrg ;; 7721521070a0Smrg esac 7722521070a0Smrg done 7723521070a0Smrg else 7724521070a0Smrg # Error occurred in the first compile. Let's try to salvage 7725521070a0Smrg # the situation: Compile a separate program for each library. 7726521070a0Smrg for i in $deplibs; do 7727521070a0Smrg case $i in 7728521070a0Smrg -l*) 7729521070a0Smrg func_stripname -l '' "$i" 7730521070a0Smrg name=$func_stripname_result 7731521070a0Smrg $opt_dry_run || $RM conftest 7732521070a0Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 7733521070a0Smrg ldd_output=`ldd conftest` 7734521070a0Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7735521070a0Smrg case " $predeps $postdeps " in 7736521070a0Smrg *" $i "*) 77373e6c936aSmrg func_append newdeplibs " $i" 7738521070a0Smrg i="" 7739521070a0Smrg ;; 7740521070a0Smrg esac 7741521070a0Smrg fi 7742521070a0Smrg if test -n "$i" ; then 7743521070a0Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7744521070a0Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7745521070a0Smrg set dummy $deplib_matches; shift 7746521070a0Smrg deplib_match=$1 7747521070a0Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 77483e6c936aSmrg func_append newdeplibs " $i" 7749521070a0Smrg else 7750521070a0Smrg droppeddeps=yes 7751ff63a143Smrg echo 7752521070a0Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7753ff63a143Smrg echo "*** I have the capability to make that library automatically link in when" 7754ff63a143Smrg echo "*** you link to this library. But I can only do this if you have a" 7755ff63a143Smrg echo "*** shared version of the library, which you do not appear to have" 7756ff63a143Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 7757ff63a143Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 7758521070a0Smrg fi 7759521070a0Smrg fi 7760521070a0Smrg else 7761521070a0Smrg droppeddeps=yes 7762ff63a143Smrg echo 7763521070a0Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 7764ff63a143Smrg echo "*** make it link in! You will probably need to install it or some" 7765ff63a143Smrg echo "*** library that it depends on before this library will be fully" 7766ff63a143Smrg echo "*** functional. Installing it before continuing would be even better." 7767521070a0Smrg fi 7768521070a0Smrg ;; 7769521070a0Smrg *) 77703e6c936aSmrg func_append newdeplibs " $i" 7771521070a0Smrg ;; 7772521070a0Smrg esac 7773521070a0Smrg done 7774521070a0Smrg fi 7775521070a0Smrg ;; 7776521070a0Smrg file_magic*) 7777521070a0Smrg set dummy $deplibs_check_method; shift 7778521070a0Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7779521070a0Smrg for a_deplib in $deplibs; do 7780521070a0Smrg case $a_deplib in 7781521070a0Smrg -l*) 7782521070a0Smrg func_stripname -l '' "$a_deplib" 7783521070a0Smrg name=$func_stripname_result 7784521070a0Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7785521070a0Smrg case " $predeps $postdeps " in 7786521070a0Smrg *" $a_deplib "*) 77873e6c936aSmrg func_append newdeplibs " $a_deplib" 7788521070a0Smrg a_deplib="" 7789521070a0Smrg ;; 7790521070a0Smrg esac 7791521070a0Smrg fi 7792521070a0Smrg if test -n "$a_deplib" ; then 7793521070a0Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 77943e6c936aSmrg if test -n "$file_magic_glob"; then 77953e6c936aSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 77963e6c936aSmrg else 77973e6c936aSmrg libnameglob=$libname 77983e6c936aSmrg fi 77993e6c936aSmrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 7800521070a0Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 78013e6c936aSmrg if test "$want_nocaseglob" = yes; then 78023e6c936aSmrg shopt -s nocaseglob 78033e6c936aSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 78043e6c936aSmrg $nocaseglob 78053e6c936aSmrg else 78063e6c936aSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 78073e6c936aSmrg fi 7808521070a0Smrg for potent_lib in $potential_libs; do 7809521070a0Smrg # Follow soft links. 7810521070a0Smrg if ls -lLd "$potent_lib" 2>/dev/null | 7811521070a0Smrg $GREP " -> " >/dev/null; then 7812521070a0Smrg continue 7813521070a0Smrg fi 7814521070a0Smrg # The statement above tries to avoid entering an 7815521070a0Smrg # endless loop below, in case of cyclic links. 7816521070a0Smrg # We might still enter an endless loop, since a link 7817521070a0Smrg # loop can be closed while we follow links, 7818521070a0Smrg # but so what? 7819521070a0Smrg potlib="$potent_lib" 7820521070a0Smrg while test -h "$potlib" 2>/dev/null; do 7821521070a0Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 7822521070a0Smrg case $potliblink in 7823521070a0Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 7824ff63a143Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 7825521070a0Smrg esac 7826521070a0Smrg done 7827521070a0Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 7828521070a0Smrg $SED -e 10q | 7829521070a0Smrg $EGREP "$file_magic_regex" > /dev/null; then 78303e6c936aSmrg func_append newdeplibs " $a_deplib" 7831521070a0Smrg a_deplib="" 7832521070a0Smrg break 2 7833521070a0Smrg fi 7834521070a0Smrg done 7835521070a0Smrg done 7836521070a0Smrg fi 7837521070a0Smrg if test -n "$a_deplib" ; then 7838521070a0Smrg droppeddeps=yes 7839ff63a143Smrg echo 7840521070a0Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7841ff63a143Smrg echo "*** I have the capability to make that library automatically link in when" 7842ff63a143Smrg echo "*** you link to this library. But I can only do this if you have a" 7843ff63a143Smrg echo "*** shared version of the library, which you do not appear to have" 7844ff63a143Smrg echo "*** because I did check the linker path looking for a file starting" 7845521070a0Smrg if test -z "$potlib" ; then 7846521070a0Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 7847521070a0Smrg else 7848521070a0Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 7849521070a0Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 7850521070a0Smrg fi 7851521070a0Smrg fi 7852521070a0Smrg ;; 7853521070a0Smrg *) 7854521070a0Smrg # Add a -L argument. 78553e6c936aSmrg func_append newdeplibs " $a_deplib" 7856521070a0Smrg ;; 7857521070a0Smrg esac 7858521070a0Smrg done # Gone through all deplibs. 7859521070a0Smrg ;; 7860521070a0Smrg match_pattern*) 7861521070a0Smrg set dummy $deplibs_check_method; shift 7862521070a0Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7863521070a0Smrg for a_deplib in $deplibs; do 7864521070a0Smrg case $a_deplib in 7865521070a0Smrg -l*) 7866521070a0Smrg func_stripname -l '' "$a_deplib" 7867521070a0Smrg name=$func_stripname_result 7868521070a0Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7869521070a0Smrg case " $predeps $postdeps " in 7870521070a0Smrg *" $a_deplib "*) 78713e6c936aSmrg func_append newdeplibs " $a_deplib" 7872521070a0Smrg a_deplib="" 7873521070a0Smrg ;; 7874521070a0Smrg esac 7875521070a0Smrg fi 7876521070a0Smrg if test -n "$a_deplib" ; then 7877521070a0Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7878521070a0Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7879521070a0Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 7880521070a0Smrg for potent_lib in $potential_libs; do 7881521070a0Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 7882ff63a143Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 7883521070a0Smrg $EGREP "$match_pattern_regex" > /dev/null; then 78843e6c936aSmrg func_append newdeplibs " $a_deplib" 7885521070a0Smrg a_deplib="" 7886521070a0Smrg break 2 7887521070a0Smrg fi 7888521070a0Smrg done 7889521070a0Smrg done 7890521070a0Smrg fi 7891521070a0Smrg if test -n "$a_deplib" ; then 7892521070a0Smrg droppeddeps=yes 7893ff63a143Smrg echo 7894521070a0Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7895ff63a143Smrg echo "*** I have the capability to make that library automatically link in when" 7896ff63a143Smrg echo "*** you link to this library. But I can only do this if you have a" 7897ff63a143Smrg echo "*** shared version of the library, which you do not appear to have" 7898ff63a143Smrg echo "*** because I did check the linker path looking for a file starting" 7899521070a0Smrg if test -z "$potlib" ; then 7900521070a0Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 7901521070a0Smrg else 7902521070a0Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 7903521070a0Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 7904521070a0Smrg fi 7905521070a0Smrg fi 7906521070a0Smrg ;; 7907521070a0Smrg *) 7908521070a0Smrg # Add a -L argument. 79093e6c936aSmrg func_append newdeplibs " $a_deplib" 7910521070a0Smrg ;; 7911521070a0Smrg esac 7912521070a0Smrg done # Gone through all deplibs. 7913521070a0Smrg ;; 7914521070a0Smrg none | unknown | *) 7915521070a0Smrg newdeplibs="" 7916ff63a143Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 7917521070a0Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7918521070a0Smrg for i in $predeps $postdeps ; do 7919521070a0Smrg # can't use Xsed below, because $i might contain '/' 7920ff63a143Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 7921521070a0Smrg done 7922521070a0Smrg fi 7923ff63a143Smrg case $tmp_deplibs in 7924ff63a143Smrg *[!\ \ ]*) 7925ff63a143Smrg echo 7926521070a0Smrg if test "X$deplibs_check_method" = "Xnone"; then 7927ff63a143Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 7928521070a0Smrg else 7929ff63a143Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 7930521070a0Smrg fi 7931ff63a143Smrg echo "*** All declared inter-library dependencies are being dropped." 7932521070a0Smrg droppeddeps=yes 7933ff63a143Smrg ;; 7934ff63a143Smrg esac 7935521070a0Smrg ;; 7936521070a0Smrg esac 7937521070a0Smrg versuffix=$versuffix_save 7938521070a0Smrg major=$major_save 7939521070a0Smrg release=$release_save 7940521070a0Smrg libname=$libname_save 7941521070a0Smrg name=$name_save 7942521070a0Smrg 7943521070a0Smrg case $host in 7944521070a0Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7945521070a0Smrg # On Rhapsody replace the C library with the System framework 7946ff63a143Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 7947521070a0Smrg ;; 7948521070a0Smrg esac 7949521070a0Smrg 7950521070a0Smrg if test "$droppeddeps" = yes; then 7951521070a0Smrg if test "$module" = yes; then 7952ff63a143Smrg echo 7953ff63a143Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 7954521070a0Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 7955ff63a143Smrg echo "*** a static module, that should work as long as the dlopening" 7956ff63a143Smrg echo "*** application is linked with the -dlopen flag." 7957521070a0Smrg if test -z "$global_symbol_pipe"; then 7958ff63a143Smrg echo 7959ff63a143Smrg echo "*** However, this would only work if libtool was able to extract symbol" 7960ff63a143Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 7961ff63a143Smrg echo "*** not find such a program. So, this module is probably useless." 7962ff63a143Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 7963521070a0Smrg fi 7964521070a0Smrg if test "$build_old_libs" = no; then 7965521070a0Smrg oldlibs="$output_objdir/$libname.$libext" 7966521070a0Smrg build_libtool_libs=module 7967521070a0Smrg build_old_libs=yes 7968521070a0Smrg else 7969521070a0Smrg build_libtool_libs=no 7970521070a0Smrg fi 7971521070a0Smrg else 7972ff63a143Smrg echo "*** The inter-library dependencies that have been dropped here will be" 7973ff63a143Smrg echo "*** automatically added whenever a program is linked with this library" 7974ff63a143Smrg echo "*** or is declared to -dlopen it." 7975521070a0Smrg 7976521070a0Smrg if test "$allow_undefined" = no; then 7977ff63a143Smrg echo 7978ff63a143Smrg echo "*** Since this library must not contain undefined symbols," 7979ff63a143Smrg echo "*** because either the platform does not support them or" 7980ff63a143Smrg echo "*** it was explicitly requested with -no-undefined," 7981ff63a143Smrg echo "*** libtool will only create a static version of it." 7982521070a0Smrg if test "$build_old_libs" = no; then 7983521070a0Smrg oldlibs="$output_objdir/$libname.$libext" 7984521070a0Smrg build_libtool_libs=module 7985521070a0Smrg build_old_libs=yes 7986521070a0Smrg else 7987521070a0Smrg build_libtool_libs=no 7988521070a0Smrg fi 7989521070a0Smrg fi 7990521070a0Smrg fi 7991521070a0Smrg fi 7992521070a0Smrg # Done checking deplibs! 7993521070a0Smrg deplibs=$newdeplibs 7994521070a0Smrg fi 7995521070a0Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 7996521070a0Smrg case $host in 7997521070a0Smrg *-*-darwin*) 7998ff63a143Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7999ff63a143Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8000ff63a143Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8001521070a0Smrg ;; 8002521070a0Smrg esac 8003521070a0Smrg 8004521070a0Smrg # move library search paths that coincide with paths to not yet 8005521070a0Smrg # installed libraries to the beginning of the library search list 8006521070a0Smrg new_libs= 8007521070a0Smrg for path in $notinst_path; do 8008521070a0Smrg case " $new_libs " in 8009521070a0Smrg *" -L$path/$objdir "*) ;; 8010521070a0Smrg *) 8011521070a0Smrg case " $deplibs " in 8012521070a0Smrg *" -L$path/$objdir "*) 80133e6c936aSmrg func_append new_libs " -L$path/$objdir" ;; 8014521070a0Smrg esac 8015521070a0Smrg ;; 8016521070a0Smrg esac 8017521070a0Smrg done 8018521070a0Smrg for deplib in $deplibs; do 8019521070a0Smrg case $deplib in 8020521070a0Smrg -L*) 8021521070a0Smrg case " $new_libs " in 8022521070a0Smrg *" $deplib "*) ;; 80233e6c936aSmrg *) func_append new_libs " $deplib" ;; 8024521070a0Smrg esac 8025521070a0Smrg ;; 80263e6c936aSmrg *) func_append new_libs " $deplib" ;; 8027521070a0Smrg esac 8028521070a0Smrg done 8029521070a0Smrg deplibs="$new_libs" 8030521070a0Smrg 8031521070a0Smrg # All the library-specific variables (install_libdir is set above). 8032521070a0Smrg library_names= 8033521070a0Smrg old_library= 8034521070a0Smrg dlname= 8035521070a0Smrg 8036521070a0Smrg # Test again, we may have decided not to build it any more 8037521070a0Smrg if test "$build_libtool_libs" = yes; then 80383e6c936aSmrg # Remove ${wl} instances when linking with ld. 80393e6c936aSmrg # FIXME: should test the right _cmds variable. 80403e6c936aSmrg case $archive_cmds in 80413e6c936aSmrg *\$LD\ *) wl= ;; 80423e6c936aSmrg esac 8043521070a0Smrg if test "$hardcode_into_libs" = yes; then 8044521070a0Smrg # Hardcode the library paths 8045521070a0Smrg hardcode_libdirs= 8046521070a0Smrg dep_rpath= 8047521070a0Smrg rpath="$finalize_rpath" 80483e6c936aSmrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 8049521070a0Smrg for libdir in $rpath; do 8050521070a0Smrg if test -n "$hardcode_libdir_flag_spec"; then 8051521070a0Smrg if test -n "$hardcode_libdir_separator"; then 80523e6c936aSmrg func_replace_sysroot "$libdir" 80533e6c936aSmrg libdir=$func_replace_sysroot_result 8054521070a0Smrg if test -z "$hardcode_libdirs"; then 8055521070a0Smrg hardcode_libdirs="$libdir" 8056521070a0Smrg else 8057521070a0Smrg # Just accumulate the unique libdirs. 8058521070a0Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8059521070a0Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8060521070a0Smrg ;; 8061521070a0Smrg *) 80623e6c936aSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8063521070a0Smrg ;; 8064521070a0Smrg esac 8065521070a0Smrg fi 8066521070a0Smrg else 8067521070a0Smrg eval flag=\"$hardcode_libdir_flag_spec\" 80683e6c936aSmrg func_append dep_rpath " $flag" 8069521070a0Smrg fi 8070521070a0Smrg elif test -n "$runpath_var"; then 8071521070a0Smrg case "$perm_rpath " in 8072521070a0Smrg *" $libdir "*) ;; 80733e6c936aSmrg *) func_append perm_rpath " $libdir" ;; 8074521070a0Smrg esac 8075521070a0Smrg fi 8076521070a0Smrg done 8077521070a0Smrg # Substitute the hardcoded libdirs into the rpath. 8078521070a0Smrg if test -n "$hardcode_libdir_separator" && 8079521070a0Smrg test -n "$hardcode_libdirs"; then 8080521070a0Smrg libdir="$hardcode_libdirs" 80813e6c936aSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 8082521070a0Smrg fi 8083521070a0Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 8084521070a0Smrg # We should set the runpath_var. 8085521070a0Smrg rpath= 8086521070a0Smrg for dir in $perm_rpath; do 80873e6c936aSmrg func_append rpath "$dir:" 8088521070a0Smrg done 8089521070a0Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 8090521070a0Smrg fi 8091521070a0Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 8092521070a0Smrg fi 80934456fccdSmrg 8094521070a0Smrg shlibpath="$finalize_shlibpath" 80953e6c936aSmrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 8096521070a0Smrg if test -n "$shlibpath"; then 8097521070a0Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 8098521070a0Smrg fi 80994456fccdSmrg 8100521070a0Smrg # Get the real and link names of the library. 8101521070a0Smrg eval shared_ext=\"$shrext_cmds\" 8102521070a0Smrg eval library_names=\"$library_names_spec\" 8103521070a0Smrg set dummy $library_names 8104521070a0Smrg shift 8105521070a0Smrg realname="$1" 8106521070a0Smrg shift 81074456fccdSmrg 8108521070a0Smrg if test -n "$soname_spec"; then 8109521070a0Smrg eval soname=\"$soname_spec\" 8110521070a0Smrg else 8111521070a0Smrg soname="$realname" 8112521070a0Smrg fi 8113521070a0Smrg if test -z "$dlname"; then 8114521070a0Smrg dlname=$soname 8115521070a0Smrg fi 81164456fccdSmrg 8117521070a0Smrg lib="$output_objdir/$realname" 8118521070a0Smrg linknames= 8119521070a0Smrg for link 8120521070a0Smrg do 81213e6c936aSmrg func_append linknames " $link" 8122521070a0Smrg done 81234456fccdSmrg 8124521070a0Smrg # Use standard objects if they are pic 8125ff63a143Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 8126521070a0Smrg test "X$libobjs" = "X " && libobjs= 81274456fccdSmrg 8128521070a0Smrg delfiles= 8129521070a0Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8130521070a0Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 8131521070a0Smrg export_symbols="$output_objdir/$libname.uexp" 81323e6c936aSmrg func_append delfiles " $export_symbols" 8133521070a0Smrg fi 81344456fccdSmrg 8135521070a0Smrg orig_export_symbols= 8136521070a0Smrg case $host_os in 8137521070a0Smrg cygwin* | mingw* | cegcc*) 8138521070a0Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 8139521070a0Smrg # exporting using user supplied symfile 8140521070a0Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 8141521070a0Smrg # and it's NOT already a .def file. Must figure out 8142521070a0Smrg # which of the given symbols are data symbols and tag 8143521070a0Smrg # them as such. So, trigger use of export_symbols_cmds. 8144521070a0Smrg # export_symbols gets reassigned inside the "prepare 8145521070a0Smrg # the list of exported symbols" if statement, so the 8146521070a0Smrg # include_expsyms logic still works. 8147521070a0Smrg orig_export_symbols="$export_symbols" 8148521070a0Smrg export_symbols= 8149521070a0Smrg always_export_symbols=yes 8150521070a0Smrg fi 8151521070a0Smrg fi 8152521070a0Smrg ;; 8153521070a0Smrg esac 81544456fccdSmrg 8155521070a0Smrg # Prepare the list of exported symbols 8156521070a0Smrg if test -z "$export_symbols"; then 8157521070a0Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 8158521070a0Smrg func_verbose "generating symbol list for \`$libname.la'" 8159521070a0Smrg export_symbols="$output_objdir/$libname.exp" 8160521070a0Smrg $opt_dry_run || $RM $export_symbols 8161521070a0Smrg cmds=$export_symbols_cmds 8162521070a0Smrg save_ifs="$IFS"; IFS='~' 81633e6c936aSmrg for cmd1 in $cmds; do 8164521070a0Smrg IFS="$save_ifs" 81653e6c936aSmrg # Take the normal branch if the nm_file_list_spec branch 81663e6c936aSmrg # doesn't work or if tool conversion is not needed. 81673e6c936aSmrg case $nm_file_list_spec~$to_tool_file_cmd in 81683e6c936aSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 81693e6c936aSmrg try_normal_branch=yes 81703e6c936aSmrg eval cmd=\"$cmd1\" 81713e6c936aSmrg func_len " $cmd" 81723e6c936aSmrg len=$func_len_result 81733e6c936aSmrg ;; 81743e6c936aSmrg *) 81753e6c936aSmrg try_normal_branch=no 81763e6c936aSmrg ;; 81773e6c936aSmrg esac 81783e6c936aSmrg if test "$try_normal_branch" = yes \ 81793e6c936aSmrg && { test "$len" -lt "$max_cmd_len" \ 81803e6c936aSmrg || test "$max_cmd_len" -le -1; } 81813e6c936aSmrg then 81823e6c936aSmrg func_show_eval "$cmd" 'exit $?' 81833e6c936aSmrg skipped_export=false 81843e6c936aSmrg elif test -n "$nm_file_list_spec"; then 81853e6c936aSmrg func_basename "$output" 81863e6c936aSmrg output_la=$func_basename_result 81873e6c936aSmrg save_libobjs=$libobjs 81883e6c936aSmrg save_output=$output 81893e6c936aSmrg output=${output_objdir}/${output_la}.nm 81903e6c936aSmrg func_to_tool_file "$output" 81913e6c936aSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 81923e6c936aSmrg func_append delfiles " $output" 81933e6c936aSmrg func_verbose "creating $NM input file list: $output" 81943e6c936aSmrg for obj in $save_libobjs; do 81953e6c936aSmrg func_to_tool_file "$obj" 81963e6c936aSmrg $ECHO "$func_to_tool_file_result" 81973e6c936aSmrg done > "$output" 81983e6c936aSmrg eval cmd=\"$cmd1\" 8199521070a0Smrg func_show_eval "$cmd" 'exit $?' 82003e6c936aSmrg output=$save_output 82013e6c936aSmrg libobjs=$save_libobjs 8202521070a0Smrg skipped_export=false 8203521070a0Smrg else 8204521070a0Smrg # The command line is too long to execute in one step. 8205521070a0Smrg func_verbose "using reloadable object file for export list..." 8206521070a0Smrg skipped_export=: 8207521070a0Smrg # Break out early, otherwise skipped_export may be 8208521070a0Smrg # set to false by a later but shorter cmd. 8209521070a0Smrg break 8210521070a0Smrg fi 8211521070a0Smrg done 8212521070a0Smrg IFS="$save_ifs" 8213521070a0Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 8214521070a0Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8215521070a0Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8216521070a0Smrg fi 8217521070a0Smrg fi 82184456fccdSmrg fi 82194456fccdSmrg 8220521070a0Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8221521070a0Smrg tmp_export_symbols="$export_symbols" 8222521070a0Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8223ff63a143Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8224521070a0Smrg fi 82254456fccdSmrg 8226521070a0Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 8227521070a0Smrg # The given exports_symbols file has to be filtered, so filter it. 8228521070a0Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8229521070a0Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 8230521070a0Smrg # 's' commands which not all seds can handle. GNU sed should be fine 8231521070a0Smrg # though. Also, the filter scales superlinearly with the number of 8232521070a0Smrg # global variables. join(1) would be nice here, but unfortunately 8233521070a0Smrg # isn't a blessed tool. 8234521070a0Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 82353e6c936aSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8236521070a0Smrg export_symbols=$output_objdir/$libname.def 8237521070a0Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8238521070a0Smrg fi 82394456fccdSmrg 8240521070a0Smrg tmp_deplibs= 8241521070a0Smrg for test_deplib in $deplibs; do 8242521070a0Smrg case " $convenience " in 8243521070a0Smrg *" $test_deplib "*) ;; 8244521070a0Smrg *) 82453e6c936aSmrg func_append tmp_deplibs " $test_deplib" 8246521070a0Smrg ;; 8247521070a0Smrg esac 8248521070a0Smrg done 8249521070a0Smrg deplibs="$tmp_deplibs" 82504456fccdSmrg 8251521070a0Smrg if test -n "$convenience"; then 8252521070a0Smrg if test -n "$whole_archive_flag_spec" && 8253521070a0Smrg test "$compiler_needs_object" = yes && 8254521070a0Smrg test -z "$libobjs"; then 8255521070a0Smrg # extract the archives, so we have objects to list. 8256521070a0Smrg # TODO: could optimize this to just extract one archive. 8257521070a0Smrg whole_archive_flag_spec= 8258521070a0Smrg fi 8259521070a0Smrg if test -n "$whole_archive_flag_spec"; then 8260521070a0Smrg save_libobjs=$libobjs 8261521070a0Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8262521070a0Smrg test "X$libobjs" = "X " && libobjs= 8263521070a0Smrg else 8264521070a0Smrg gentop="$output_objdir/${outputname}x" 82653e6c936aSmrg func_append generated " $gentop" 82664456fccdSmrg 8267521070a0Smrg func_extract_archives $gentop $convenience 82683e6c936aSmrg func_append libobjs " $func_extract_archives_result" 8269521070a0Smrg test "X$libobjs" = "X " && libobjs= 8270521070a0Smrg fi 82714456fccdSmrg fi 82724456fccdSmrg 8273521070a0Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 8274521070a0Smrg eval flag=\"$thread_safe_flag_spec\" 82753e6c936aSmrg func_append linker_flags " $flag" 82764456fccdSmrg fi 82774456fccdSmrg 8278521070a0Smrg # Make a backup of the uninstalled library when relinking 82793e6c936aSmrg if test "$opt_mode" = relink; then 8280521070a0Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 8281521070a0Smrg fi 82824456fccdSmrg 8283521070a0Smrg # Do each of the archive commands. 8284521070a0Smrg if test "$module" = yes && test -n "$module_cmds" ; then 8285521070a0Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8286521070a0Smrg eval test_cmds=\"$module_expsym_cmds\" 8287521070a0Smrg cmds=$module_expsym_cmds 8288521070a0Smrg else 8289521070a0Smrg eval test_cmds=\"$module_cmds\" 8290521070a0Smrg cmds=$module_cmds 8291521070a0Smrg fi 82924456fccdSmrg else 8293521070a0Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8294521070a0Smrg eval test_cmds=\"$archive_expsym_cmds\" 8295521070a0Smrg cmds=$archive_expsym_cmds 8296521070a0Smrg else 8297521070a0Smrg eval test_cmds=\"$archive_cmds\" 8298521070a0Smrg cmds=$archive_cmds 8299521070a0Smrg fi 83004456fccdSmrg fi 83014456fccdSmrg 8302521070a0Smrg if test "X$skipped_export" != "X:" && 8303521070a0Smrg func_len " $test_cmds" && 8304521070a0Smrg len=$func_len_result && 8305521070a0Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 8306521070a0Smrg : 8307521070a0Smrg else 8308521070a0Smrg # The command line is too long to link in one step, link piecewise 8309521070a0Smrg # or, if using GNU ld and skipped_export is not :, use a linker 8310521070a0Smrg # script. 83114456fccdSmrg 8312521070a0Smrg # Save the value of $output and $libobjs because we want to 8313521070a0Smrg # use them later. If we have whole_archive_flag_spec, we 8314521070a0Smrg # want to use save_libobjs as it was before 8315521070a0Smrg # whole_archive_flag_spec was expanded, because we can't 8316521070a0Smrg # assume the linker understands whole_archive_flag_spec. 8317521070a0Smrg # This may have to be revisited, in case too many 8318521070a0Smrg # convenience libraries get linked in and end up exceeding 8319521070a0Smrg # the spec. 8320521070a0Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 8321521070a0Smrg save_libobjs=$libobjs 8322521070a0Smrg fi 8323521070a0Smrg save_output=$output 8324ff63a143Smrg func_basename "$output" 8325ff63a143Smrg output_la=$func_basename_result 83264456fccdSmrg 8327521070a0Smrg # Clear the reloadable object creation command queue and 8328521070a0Smrg # initialize k to one. 8329521070a0Smrg test_cmds= 8330521070a0Smrg concat_cmds= 8331521070a0Smrg objlist= 8332521070a0Smrg last_robj= 8333521070a0Smrg k=1 8334521070a0Smrg 8335521070a0Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 8336521070a0Smrg output=${output_objdir}/${output_la}.lnkscript 8337521070a0Smrg func_verbose "creating GNU ld script: $output" 8338ff63a143Smrg echo 'INPUT (' > $output 8339521070a0Smrg for obj in $save_libobjs 83404456fccdSmrg do 83413e6c936aSmrg func_to_tool_file "$obj" 83423e6c936aSmrg $ECHO "$func_to_tool_file_result" >> $output 8343521070a0Smrg done 8344ff63a143Smrg echo ')' >> $output 83453e6c936aSmrg func_append delfiles " $output" 83463e6c936aSmrg func_to_tool_file "$output" 83473e6c936aSmrg output=$func_to_tool_file_result 8348521070a0Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 8349521070a0Smrg output=${output_objdir}/${output_la}.lnk 8350521070a0Smrg func_verbose "creating linker input file list: $output" 8351521070a0Smrg : > $output 8352521070a0Smrg set x $save_libobjs 8353521070a0Smrg shift 8354521070a0Smrg firstobj= 8355521070a0Smrg if test "$compiler_needs_object" = yes; then 8356521070a0Smrg firstobj="$1 " 8357521070a0Smrg shift 8358521070a0Smrg fi 8359521070a0Smrg for obj 8360521070a0Smrg do 83613e6c936aSmrg func_to_tool_file "$obj" 83623e6c936aSmrg $ECHO "$func_to_tool_file_result" >> $output 8363521070a0Smrg done 83643e6c936aSmrg func_append delfiles " $output" 83653e6c936aSmrg func_to_tool_file "$output" 83663e6c936aSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 8367521070a0Smrg else 8368521070a0Smrg if test -n "$save_libobjs"; then 8369521070a0Smrg func_verbose "creating reloadable object files..." 8370521070a0Smrg output=$output_objdir/$output_la-${k}.$objext 8371521070a0Smrg eval test_cmds=\"$reload_cmds\" 8372521070a0Smrg func_len " $test_cmds" 8373521070a0Smrg len0=$func_len_result 8374521070a0Smrg len=$len0 8375521070a0Smrg 8376521070a0Smrg # Loop over the list of objects to be linked. 8377521070a0Smrg for obj in $save_libobjs 8378521070a0Smrg do 8379521070a0Smrg func_len " $obj" 8380521070a0Smrg func_arith $len + $func_len_result 8381521070a0Smrg len=$func_arith_result 8382521070a0Smrg if test "X$objlist" = X || 8383521070a0Smrg test "$len" -lt "$max_cmd_len"; then 8384521070a0Smrg func_append objlist " $obj" 8385521070a0Smrg else 8386521070a0Smrg # The command $test_cmds is almost too long, add a 8387521070a0Smrg # command to the queue. 8388521070a0Smrg if test "$k" -eq 1 ; then 8389521070a0Smrg # The first file doesn't have a previous command to add. 8390ff63a143Smrg reload_objs=$objlist 8391ff63a143Smrg eval concat_cmds=\"$reload_cmds\" 8392521070a0Smrg else 8393521070a0Smrg # All subsequent reloadable object files will link in 8394521070a0Smrg # the last one created. 8395ff63a143Smrg reload_objs="$objlist $last_robj" 8396ff63a143Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 8397521070a0Smrg fi 8398521070a0Smrg last_robj=$output_objdir/$output_la-${k}.$objext 8399521070a0Smrg func_arith $k + 1 8400521070a0Smrg k=$func_arith_result 8401521070a0Smrg output=$output_objdir/$output_la-${k}.$objext 8402ff63a143Smrg objlist=" $obj" 8403521070a0Smrg func_len " $last_robj" 8404521070a0Smrg func_arith $len0 + $func_len_result 8405521070a0Smrg len=$func_arith_result 8406521070a0Smrg fi 8407521070a0Smrg done 8408521070a0Smrg # Handle the remaining objects by creating one last 8409521070a0Smrg # reloadable object file. All subsequent reloadable object 8410521070a0Smrg # files will link in the last one created. 8411521070a0Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8412ff63a143Smrg reload_objs="$objlist $last_robj" 8413ff63a143Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 8414521070a0Smrg if test -n "$last_robj"; then 8415521070a0Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 8416521070a0Smrg fi 84173e6c936aSmrg func_append delfiles " $output" 84184456fccdSmrg 8419521070a0Smrg else 8420521070a0Smrg output= 8421521070a0Smrg fi 84224456fccdSmrg 8423521070a0Smrg if ${skipped_export-false}; then 8424521070a0Smrg func_verbose "generating symbol list for \`$libname.la'" 8425521070a0Smrg export_symbols="$output_objdir/$libname.exp" 8426521070a0Smrg $opt_dry_run || $RM $export_symbols 8427521070a0Smrg libobjs=$output 8428521070a0Smrg # Append the command to create the export file. 8429521070a0Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8430521070a0Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 8431521070a0Smrg if test -n "$last_robj"; then 8432521070a0Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 8433521070a0Smrg fi 84344456fccdSmrg fi 84354456fccdSmrg 8436521070a0Smrg test -n "$save_libobjs" && 8437521070a0Smrg func_verbose "creating a temporary reloadable object file: $output" 84384456fccdSmrg 8439521070a0Smrg # Loop through the commands generated above and execute them. 8440521070a0Smrg save_ifs="$IFS"; IFS='~' 8441521070a0Smrg for cmd in $concat_cmds; do 8442521070a0Smrg IFS="$save_ifs" 8443521070a0Smrg $opt_silent || { 8444521070a0Smrg func_quote_for_expand "$cmd" 8445521070a0Smrg eval "func_echo $func_quote_for_expand_result" 8446521070a0Smrg } 8447521070a0Smrg $opt_dry_run || eval "$cmd" || { 8448521070a0Smrg lt_exit=$? 8449521070a0Smrg 8450521070a0Smrg # Restore the uninstalled library and exit 84513e6c936aSmrg if test "$opt_mode" = relink; then 8452521070a0Smrg ( cd "$output_objdir" && \ 8453521070a0Smrg $RM "${realname}T" && \ 8454521070a0Smrg $MV "${realname}U" "$realname" ) 8455521070a0Smrg fi 84564456fccdSmrg 8457521070a0Smrg exit $lt_exit 8458521070a0Smrg } 8459521070a0Smrg done 8460521070a0Smrg IFS="$save_ifs" 84614456fccdSmrg 8462521070a0Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 8463521070a0Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8464521070a0Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 84654456fccdSmrg fi 84664456fccdSmrg fi 84674456fccdSmrg 8468521070a0Smrg if ${skipped_export-false}; then 8469521070a0Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8470521070a0Smrg tmp_export_symbols="$export_symbols" 8471521070a0Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8472ff63a143Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8473521070a0Smrg fi 84744456fccdSmrg 8475521070a0Smrg if test -n "$orig_export_symbols"; then 8476521070a0Smrg # The given exports_symbols file has to be filtered, so filter it. 8477521070a0Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8478521070a0Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 8479521070a0Smrg # 's' commands which not all seds can handle. GNU sed should be fine 8480521070a0Smrg # though. Also, the filter scales superlinearly with the number of 8481521070a0Smrg # global variables. join(1) would be nice here, but unfortunately 8482521070a0Smrg # isn't a blessed tool. 8483521070a0Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 84843e6c936aSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8485521070a0Smrg export_symbols=$output_objdir/$libname.def 8486521070a0Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8487521070a0Smrg fi 8488521070a0Smrg fi 84894456fccdSmrg 8490521070a0Smrg libobjs=$output 8491521070a0Smrg # Restore the value of output. 8492521070a0Smrg output=$save_output 84934456fccdSmrg 8494521070a0Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 8495521070a0Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8496521070a0Smrg test "X$libobjs" = "X " && libobjs= 8497521070a0Smrg fi 8498521070a0Smrg # Expand the library linking commands again to reset the 8499521070a0Smrg # value of $libobjs for piecewise linking. 85004456fccdSmrg 8501521070a0Smrg # Do each of the archive commands. 8502521070a0Smrg if test "$module" = yes && test -n "$module_cmds" ; then 8503521070a0Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8504521070a0Smrg cmds=$module_expsym_cmds 8505521070a0Smrg else 8506521070a0Smrg cmds=$module_cmds 85074456fccdSmrg fi 85084456fccdSmrg else 8509521070a0Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8510521070a0Smrg cmds=$archive_expsym_cmds 8511521070a0Smrg else 8512521070a0Smrg cmds=$archive_cmds 8513521070a0Smrg fi 85144456fccdSmrg fi 8515521070a0Smrg fi 85164456fccdSmrg 8517521070a0Smrg if test -n "$delfiles"; then 8518521070a0Smrg # Append the command to remove temporary files to $cmds. 8519521070a0Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 8520521070a0Smrg fi 85214456fccdSmrg 8522521070a0Smrg # Add any objects from preloaded convenience libraries 8523521070a0Smrg if test -n "$dlprefiles"; then 8524521070a0Smrg gentop="$output_objdir/${outputname}x" 85253e6c936aSmrg func_append generated " $gentop" 85264456fccdSmrg 8527521070a0Smrg func_extract_archives $gentop $dlprefiles 85283e6c936aSmrg func_append libobjs " $func_extract_archives_result" 8529521070a0Smrg test "X$libobjs" = "X " && libobjs= 8530521070a0Smrg fi 85314456fccdSmrg 8532521070a0Smrg save_ifs="$IFS"; IFS='~' 8533521070a0Smrg for cmd in $cmds; do 8534521070a0Smrg IFS="$save_ifs" 8535521070a0Smrg eval cmd=\"$cmd\" 8536521070a0Smrg $opt_silent || { 8537521070a0Smrg func_quote_for_expand "$cmd" 8538521070a0Smrg eval "func_echo $func_quote_for_expand_result" 8539521070a0Smrg } 8540521070a0Smrg $opt_dry_run || eval "$cmd" || { 8541521070a0Smrg lt_exit=$? 85424456fccdSmrg 8543521070a0Smrg # Restore the uninstalled library and exit 85443e6c936aSmrg if test "$opt_mode" = relink; then 8545521070a0Smrg ( cd "$output_objdir" && \ 8546521070a0Smrg $RM "${realname}T" && \ 8547521070a0Smrg $MV "${realname}U" "$realname" ) 8548521070a0Smrg fi 85494456fccdSmrg 8550521070a0Smrg exit $lt_exit 8551521070a0Smrg } 8552521070a0Smrg done 8553521070a0Smrg IFS="$save_ifs" 85544456fccdSmrg 8555521070a0Smrg # Restore the uninstalled library and exit 85563e6c936aSmrg if test "$opt_mode" = relink; then 8557521070a0Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 85584456fccdSmrg 8559521070a0Smrg if test -n "$convenience"; then 8560521070a0Smrg if test -z "$whole_archive_flag_spec"; then 8561521070a0Smrg func_show_eval '${RM}r "$gentop"' 8562521070a0Smrg fi 8563521070a0Smrg fi 85644456fccdSmrg 8565521070a0Smrg exit $EXIT_SUCCESS 8566521070a0Smrg fi 8567521070a0Smrg 8568521070a0Smrg # Create links to the real library. 8569521070a0Smrg for linkname in $linknames; do 8570521070a0Smrg if test "$realname" != "$linkname"; then 8571521070a0Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 85724456fccdSmrg fi 85734456fccdSmrg done 85744456fccdSmrg 8575521070a0Smrg # If -module or -export-dynamic was specified, set the dlname. 8576521070a0Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 8577521070a0Smrg # On all known operating systems, these are identical. 8578521070a0Smrg dlname="$soname" 8579521070a0Smrg fi 8580521070a0Smrg fi 85814456fccdSmrg ;; 85824456fccdSmrg 8583521070a0Smrg obj) 8584521070a0Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 8585521070a0Smrg func_warning "\`-dlopen' is ignored for objects" 8586521070a0Smrg fi 85874456fccdSmrg 8588521070a0Smrg case " $deplibs" in 8589521070a0Smrg *\ -l* | *\ -L*) 8590521070a0Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 85914456fccdSmrg esac 85924456fccdSmrg 8593521070a0Smrg test -n "$rpath" && \ 8594521070a0Smrg func_warning "\`-rpath' is ignored for objects" 8595521070a0Smrg 8596521070a0Smrg test -n "$xrpath" && \ 8597521070a0Smrg func_warning "\`-R' is ignored for objects" 85984456fccdSmrg 8599521070a0Smrg test -n "$vinfo" && \ 8600521070a0Smrg func_warning "\`-version-info' is ignored for objects" 86014456fccdSmrg 8602521070a0Smrg test -n "$release" && \ 8603521070a0Smrg func_warning "\`-release' is ignored for objects" 8604521070a0Smrg 8605521070a0Smrg case $output in 8606521070a0Smrg *.lo) 8607521070a0Smrg test -n "$objs$old_deplibs" && \ 8608521070a0Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 8609521070a0Smrg 8610521070a0Smrg libobj=$output 8611521070a0Smrg func_lo2o "$libobj" 8612521070a0Smrg obj=$func_lo2o_result 86134456fccdSmrg ;; 86144456fccdSmrg *) 8615521070a0Smrg libobj= 8616521070a0Smrg obj="$output" 86174456fccdSmrg ;; 86184456fccdSmrg esac 86194456fccdSmrg 8620521070a0Smrg # Delete the old objects. 8621521070a0Smrg $opt_dry_run || $RM $obj $libobj 86224456fccdSmrg 8623521070a0Smrg # Objects from convenience libraries. This assumes 8624521070a0Smrg # single-version convenience libraries. Whenever we create 8625521070a0Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 8626521070a0Smrg # the extraction. 8627521070a0Smrg reload_conv_objs= 8628521070a0Smrg gentop= 8629521070a0Smrg # reload_cmds runs $LD directly, so let us get rid of 8630521070a0Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 8631521070a0Smrg # turning comma into space.. 8632521070a0Smrg wl= 86334456fccdSmrg 8634521070a0Smrg if test -n "$convenience"; then 8635521070a0Smrg if test -n "$whole_archive_flag_spec"; then 8636521070a0Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 8637ff63a143Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 8638521070a0Smrg else 8639521070a0Smrg gentop="$output_objdir/${obj}x" 86403e6c936aSmrg func_append generated " $gentop" 86414456fccdSmrg 8642521070a0Smrg func_extract_archives $gentop $convenience 8643521070a0Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 8644521070a0Smrg fi 86454456fccdSmrg fi 86464456fccdSmrg 86473e6c936aSmrg # If we're not building shared, we need to use non_pic_objs 86483e6c936aSmrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 86493e6c936aSmrg 8650521070a0Smrg # Create the old-style object. 8651ff63a143Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 86524456fccdSmrg 8653521070a0Smrg output="$obj" 8654521070a0Smrg func_execute_cmds "$reload_cmds" 'exit $?' 86554456fccdSmrg 8656521070a0Smrg # Exit if we aren't doing a library object file. 8657521070a0Smrg if test -z "$libobj"; then 8658521070a0Smrg if test -n "$gentop"; then 8659521070a0Smrg func_show_eval '${RM}r "$gentop"' 8660521070a0Smrg fi 8661521070a0Smrg 8662521070a0Smrg exit $EXIT_SUCCESS 86634456fccdSmrg fi 8664521070a0Smrg 8665521070a0Smrg if test "$build_libtool_libs" != yes; then 8666521070a0Smrg if test -n "$gentop"; then 8667521070a0Smrg func_show_eval '${RM}r "$gentop"' 8668521070a0Smrg fi 8669521070a0Smrg 8670521070a0Smrg # Create an invalid libtool object if no PIC, so that we don't 8671521070a0Smrg # accidentally link it into a program. 8672521070a0Smrg # $show "echo timestamp > $libobj" 8673521070a0Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 8674521070a0Smrg exit $EXIT_SUCCESS 8675521070a0Smrg fi 8676521070a0Smrg 8677521070a0Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 8678521070a0Smrg # Only do commands if we really have different PIC objects. 8679521070a0Smrg reload_objs="$libobjs $reload_conv_objs" 8680521070a0Smrg output="$libobj" 8681521070a0Smrg func_execute_cmds "$reload_cmds" 'exit $?' 8682521070a0Smrg fi 8683521070a0Smrg 8684521070a0Smrg if test -n "$gentop"; then 8685521070a0Smrg func_show_eval '${RM}r "$gentop"' 8686521070a0Smrg fi 8687521070a0Smrg 8688521070a0Smrg exit $EXIT_SUCCESS 86894456fccdSmrg ;; 86904456fccdSmrg 8691521070a0Smrg prog) 8692521070a0Smrg case $host in 8693521070a0Smrg *cygwin*) func_stripname '' '.exe' "$output" 8694521070a0Smrg output=$func_stripname_result.exe;; 8695521070a0Smrg esac 8696521070a0Smrg test -n "$vinfo" && \ 8697521070a0Smrg func_warning "\`-version-info' is ignored for programs" 86984456fccdSmrg 8699521070a0Smrg test -n "$release" && \ 8700521070a0Smrg func_warning "\`-release' is ignored for programs" 87014456fccdSmrg 8702521070a0Smrg test "$preload" = yes \ 8703521070a0Smrg && test "$dlopen_support" = unknown \ 8704521070a0Smrg && test "$dlopen_self" = unknown \ 8705521070a0Smrg && test "$dlopen_self_static" = unknown && \ 8706521070a0Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 8707521070a0Smrg 8708521070a0Smrg case $host in 8709521070a0Smrg *-*-rhapsody* | *-*-darwin1.[012]) 8710521070a0Smrg # On Rhapsody replace the C library is the System framework 8711ff63a143Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 8712ff63a143Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 87134456fccdSmrg ;; 8714521070a0Smrg esac 87154456fccdSmrg 8716521070a0Smrg case $host in 8717521070a0Smrg *-*-darwin*) 8718521070a0Smrg # Don't allow lazy linking, it breaks C++ global constructors 8719521070a0Smrg # But is supposedly fixed on 10.4 or later (yay!). 8720521070a0Smrg if test "$tagname" = CXX ; then 8721521070a0Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 8722521070a0Smrg 10.[0123]) 87233e6c936aSmrg func_append compile_command " ${wl}-bind_at_load" 87243e6c936aSmrg func_append finalize_command " ${wl}-bind_at_load" 8725521070a0Smrg ;; 8726521070a0Smrg esac 87274456fccdSmrg fi 8728521070a0Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 8729ff63a143Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8730ff63a143Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8731521070a0Smrg ;; 8732521070a0Smrg esac 87334456fccdSmrg 87344456fccdSmrg 8735521070a0Smrg # move library search paths that coincide with paths to not yet 8736521070a0Smrg # installed libraries to the beginning of the library search list 8737521070a0Smrg new_libs= 8738521070a0Smrg for path in $notinst_path; do 8739521070a0Smrg case " $new_libs " in 8740521070a0Smrg *" -L$path/$objdir "*) ;; 8741521070a0Smrg *) 8742521070a0Smrg case " $compile_deplibs " in 8743521070a0Smrg *" -L$path/$objdir "*) 87443e6c936aSmrg func_append new_libs " -L$path/$objdir" ;; 87454456fccdSmrg esac 8746521070a0Smrg ;; 8747521070a0Smrg esac 8748521070a0Smrg done 8749521070a0Smrg for deplib in $compile_deplibs; do 8750521070a0Smrg case $deplib in 8751521070a0Smrg -L*) 8752521070a0Smrg case " $new_libs " in 8753521070a0Smrg *" $deplib "*) ;; 87543e6c936aSmrg *) func_append new_libs " $deplib" ;; 87554456fccdSmrg esac 8756521070a0Smrg ;; 87573e6c936aSmrg *) func_append new_libs " $deplib" ;; 8758521070a0Smrg esac 8759521070a0Smrg done 8760521070a0Smrg compile_deplibs="$new_libs" 87614456fccdSmrg 87624456fccdSmrg 87633e6c936aSmrg func_append compile_command " $compile_deplibs" 87643e6c936aSmrg func_append finalize_command " $finalize_deplibs" 87654456fccdSmrg 8766521070a0Smrg if test -n "$rpath$xrpath"; then 8767521070a0Smrg # If the user specified any rpath flags, then add them. 8768521070a0Smrg for libdir in $rpath $xrpath; do 8769521070a0Smrg # This is the magic to use -rpath. 8770521070a0Smrg case "$finalize_rpath " in 8771521070a0Smrg *" $libdir "*) ;; 87723e6c936aSmrg *) func_append finalize_rpath " $libdir" ;; 8773521070a0Smrg esac 8774521070a0Smrg done 8775521070a0Smrg fi 87764456fccdSmrg 8777521070a0Smrg # Now hardcode the library paths 8778521070a0Smrg rpath= 8779521070a0Smrg hardcode_libdirs= 8780521070a0Smrg for libdir in $compile_rpath $finalize_rpath; do 8781521070a0Smrg if test -n "$hardcode_libdir_flag_spec"; then 8782521070a0Smrg if test -n "$hardcode_libdir_separator"; then 8783521070a0Smrg if test -z "$hardcode_libdirs"; then 8784521070a0Smrg hardcode_libdirs="$libdir" 8785521070a0Smrg else 8786521070a0Smrg # Just accumulate the unique libdirs. 8787521070a0Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8788521070a0Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8789521070a0Smrg ;; 8790521070a0Smrg *) 87913e6c936aSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8792521070a0Smrg ;; 8793521070a0Smrg esac 8794521070a0Smrg fi 87954456fccdSmrg else 8796521070a0Smrg eval flag=\"$hardcode_libdir_flag_spec\" 87973e6c936aSmrg func_append rpath " $flag" 87984456fccdSmrg fi 8799521070a0Smrg elif test -n "$runpath_var"; then 8800521070a0Smrg case "$perm_rpath " in 8801521070a0Smrg *" $libdir "*) ;; 88023e6c936aSmrg *) func_append perm_rpath " $libdir" ;; 8803521070a0Smrg esac 8804521070a0Smrg fi 8805521070a0Smrg case $host in 8806521070a0Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 8807521070a0Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 8808521070a0Smrg case :$dllsearchpath: in 8809521070a0Smrg *":$libdir:"*) ;; 8810521070a0Smrg ::) dllsearchpath=$libdir;; 88113e6c936aSmrg *) func_append dllsearchpath ":$libdir";; 8812521070a0Smrg esac 8813521070a0Smrg case :$dllsearchpath: in 8814521070a0Smrg *":$testbindir:"*) ;; 8815521070a0Smrg ::) dllsearchpath=$testbindir;; 88163e6c936aSmrg *) func_append dllsearchpath ":$testbindir";; 8817521070a0Smrg esac 8818521070a0Smrg ;; 8819521070a0Smrg esac 8820521070a0Smrg done 8821521070a0Smrg # Substitute the hardcoded libdirs into the rpath. 8822521070a0Smrg if test -n "$hardcode_libdir_separator" && 8823521070a0Smrg test -n "$hardcode_libdirs"; then 8824521070a0Smrg libdir="$hardcode_libdirs" 8825521070a0Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 8826521070a0Smrg fi 8827521070a0Smrg compile_rpath="$rpath" 88284456fccdSmrg 8829521070a0Smrg rpath= 8830521070a0Smrg hardcode_libdirs= 8831521070a0Smrg for libdir in $finalize_rpath; do 8832521070a0Smrg if test -n "$hardcode_libdir_flag_spec"; then 8833521070a0Smrg if test -n "$hardcode_libdir_separator"; then 8834521070a0Smrg if test -z "$hardcode_libdirs"; then 8835521070a0Smrg hardcode_libdirs="$libdir" 8836521070a0Smrg else 8837521070a0Smrg # Just accumulate the unique libdirs. 8838521070a0Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8839521070a0Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8840521070a0Smrg ;; 8841521070a0Smrg *) 88423e6c936aSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8843521070a0Smrg ;; 8844521070a0Smrg esac 8845521070a0Smrg fi 88464456fccdSmrg else 8847521070a0Smrg eval flag=\"$hardcode_libdir_flag_spec\" 88483e6c936aSmrg func_append rpath " $flag" 88494456fccdSmrg fi 8850521070a0Smrg elif test -n "$runpath_var"; then 8851521070a0Smrg case "$finalize_perm_rpath " in 8852521070a0Smrg *" $libdir "*) ;; 88533e6c936aSmrg *) func_append finalize_perm_rpath " $libdir" ;; 8854521070a0Smrg esac 88554456fccdSmrg fi 8856521070a0Smrg done 8857521070a0Smrg # Substitute the hardcoded libdirs into the rpath. 8858521070a0Smrg if test -n "$hardcode_libdir_separator" && 8859521070a0Smrg test -n "$hardcode_libdirs"; then 8860521070a0Smrg libdir="$hardcode_libdirs" 8861521070a0Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 8862521070a0Smrg fi 8863521070a0Smrg finalize_rpath="$rpath" 88644456fccdSmrg 8865521070a0Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 8866521070a0Smrg # Transform all the library objects into standard objects. 8867ff63a143Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8868ff63a143Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8869521070a0Smrg fi 88704456fccdSmrg 8871521070a0Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 88724456fccdSmrg 8873521070a0Smrg # template prelinking step 8874521070a0Smrg if test -n "$prelink_cmds"; then 8875521070a0Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 8876521070a0Smrg fi 88774456fccdSmrg 8878521070a0Smrg wrappers_required=yes 8879521070a0Smrg case $host in 8880ff63a143Smrg *cegcc* | *mingw32ce*) 8881ff63a143Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 8882ff63a143Smrg wrappers_required=no 8883ff63a143Smrg ;; 8884521070a0Smrg *cygwin* | *mingw* ) 8885521070a0Smrg if test "$build_libtool_libs" != yes; then 8886521070a0Smrg wrappers_required=no 8887521070a0Smrg fi 8888521070a0Smrg ;; 8889521070a0Smrg *) 8890521070a0Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 8891521070a0Smrg wrappers_required=no 8892521070a0Smrg fi 8893521070a0Smrg ;; 8894521070a0Smrg esac 8895521070a0Smrg if test "$wrappers_required" = no; then 8896521070a0Smrg # Replace the output file specification. 8897ff63a143Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8898521070a0Smrg link_command="$compile_command$compile_rpath" 88994456fccdSmrg 8900521070a0Smrg # We have no uninstalled library dependencies, so finalize right now. 8901521070a0Smrg exit_status=0 8902521070a0Smrg func_show_eval "$link_command" 'exit_status=$?' 89034456fccdSmrg 89043e6c936aSmrg if test -n "$postlink_cmds"; then 89053e6c936aSmrg func_to_tool_file "$output" 89063e6c936aSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 89073e6c936aSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 89083e6c936aSmrg fi 89093e6c936aSmrg 8910521070a0Smrg # Delete the generated files. 8911521070a0Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 8912521070a0Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 89134456fccdSmrg fi 89144456fccdSmrg 8915521070a0Smrg exit $exit_status 8916521070a0Smrg fi 89174456fccdSmrg 8918521070a0Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 8919521070a0Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 8920521070a0Smrg fi 8921521070a0Smrg if test -n "$finalize_shlibpath"; then 8922521070a0Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 8923521070a0Smrg fi 89244456fccdSmrg 8925521070a0Smrg compile_var= 8926521070a0Smrg finalize_var= 8927521070a0Smrg if test -n "$runpath_var"; then 8928521070a0Smrg if test -n "$perm_rpath"; then 8929521070a0Smrg # We should set the runpath_var. 8930521070a0Smrg rpath= 8931521070a0Smrg for dir in $perm_rpath; do 89323e6c936aSmrg func_append rpath "$dir:" 8933521070a0Smrg done 8934521070a0Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 89354456fccdSmrg fi 8936521070a0Smrg if test -n "$finalize_perm_rpath"; then 8937521070a0Smrg # We should set the runpath_var. 8938521070a0Smrg rpath= 8939521070a0Smrg for dir in $finalize_perm_rpath; do 89403e6c936aSmrg func_append rpath "$dir:" 8941521070a0Smrg done 8942521070a0Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 89434456fccdSmrg fi 8944521070a0Smrg fi 89454456fccdSmrg 8946521070a0Smrg if test "$no_install" = yes; then 8947521070a0Smrg # We don't need to create a wrapper script. 8948521070a0Smrg link_command="$compile_var$compile_command$compile_rpath" 8949521070a0Smrg # Replace the output file specification. 8950ff63a143Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8951521070a0Smrg # Delete the old output file. 8952521070a0Smrg $opt_dry_run || $RM $output 8953521070a0Smrg # Link the executable and exit 8954521070a0Smrg func_show_eval "$link_command" 'exit $?' 89553e6c936aSmrg 89563e6c936aSmrg if test -n "$postlink_cmds"; then 89573e6c936aSmrg func_to_tool_file "$output" 89583e6c936aSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 89593e6c936aSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 89603e6c936aSmrg fi 89613e6c936aSmrg 89624456fccdSmrg exit $EXIT_SUCCESS 8963521070a0Smrg fi 89644456fccdSmrg 8965521070a0Smrg if test "$hardcode_action" = relink; then 8966521070a0Smrg # Fast installation is not supported 8967521070a0Smrg link_command="$compile_var$compile_command$compile_rpath" 8968521070a0Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8969521070a0Smrg 8970521070a0Smrg func_warning "this platform does not like uninstalled shared libraries" 8971521070a0Smrg func_warning "\`$output' will be relinked during installation" 8972521070a0Smrg else 8973521070a0Smrg if test "$fast_install" != no; then 8974521070a0Smrg link_command="$finalize_var$compile_command$finalize_rpath" 8975521070a0Smrg if test "$fast_install" = yes; then 8976ff63a143Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 8977521070a0Smrg else 8978521070a0Smrg # fast_install is set to needless 8979521070a0Smrg relink_command= 8980521070a0Smrg fi 89814456fccdSmrg else 8982521070a0Smrg link_command="$compile_var$compile_command$compile_rpath" 8983521070a0Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 89844456fccdSmrg fi 8985521070a0Smrg fi 89864456fccdSmrg 8987521070a0Smrg # Replace the output file specification. 8988ff63a143Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 89894456fccdSmrg 8990521070a0Smrg # Delete the old output files. 8991521070a0Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 89924456fccdSmrg 8993521070a0Smrg func_show_eval "$link_command" 'exit $?' 89944456fccdSmrg 89953e6c936aSmrg if test -n "$postlink_cmds"; then 89963e6c936aSmrg func_to_tool_file "$output_objdir/$outputname" 89973e6c936aSmrg 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'` 89983e6c936aSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 89993e6c936aSmrg fi 90003e6c936aSmrg 9001521070a0Smrg # Now create the wrapper script. 9002521070a0Smrg func_verbose "creating $output" 90034456fccdSmrg 9004521070a0Smrg # Quote the relink command for shipping. 9005521070a0Smrg if test -n "$relink_command"; then 9006521070a0Smrg # Preserve any variables that may affect compiler behavior 9007521070a0Smrg for var in $variables_saved_for_relink; do 9008521070a0Smrg if eval test -z \"\${$var+set}\"; then 9009521070a0Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9010521070a0Smrg elif eval var_value=\$$var; test -z "$var_value"; then 9011521070a0Smrg relink_command="$var=; export $var; $relink_command" 90124456fccdSmrg else 9013521070a0Smrg func_quote_for_eval "$var_value" 9014521070a0Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 90154456fccdSmrg fi 9016521070a0Smrg done 9017521070a0Smrg relink_command="(cd `pwd`; $relink_command)" 9018ff63a143Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9019521070a0Smrg fi 9020521070a0Smrg 9021521070a0Smrg # Only actually do things if not in dry run mode. 9022521070a0Smrg $opt_dry_run || { 9023521070a0Smrg # win32 will think the script is a binary if it has 9024521070a0Smrg # a .exe suffix, so we strip it off here. 9025521070a0Smrg case $output in 9026521070a0Smrg *.exe) func_stripname '' '.exe' "$output" 9027521070a0Smrg output=$func_stripname_result ;; 9028521070a0Smrg esac 9029521070a0Smrg # test for cygwin because mv fails w/o .exe extensions 9030521070a0Smrg case $host in 9031521070a0Smrg *cygwin*) 9032521070a0Smrg exeext=.exe 9033521070a0Smrg func_stripname '' '.exe' "$outputname" 9034521070a0Smrg outputname=$func_stripname_result ;; 9035521070a0Smrg *) exeext= ;; 90364456fccdSmrg esac 9037521070a0Smrg case $host in 9038521070a0Smrg *cygwin* | *mingw* ) 9039521070a0Smrg func_dirname_and_basename "$output" "" "." 9040521070a0Smrg output_name=$func_basename_result 9041521070a0Smrg output_path=$func_dirname_result 9042521070a0Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 9043521070a0Smrg cwrapper="$output_path/$output_name.exe" 9044521070a0Smrg $RM $cwrappersource $cwrapper 9045521070a0Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 9046521070a0Smrg 9047521070a0Smrg func_emit_cwrapperexe_src > $cwrappersource 9048521070a0Smrg 9049521070a0Smrg # The wrapper executable is built using the $host compiler, 9050521070a0Smrg # because it contains $host paths and files. If cross- 9051521070a0Smrg # compiling, it, like the target executable, must be 9052521070a0Smrg # executed on the $host or under an emulation environment. 9053521070a0Smrg $opt_dry_run || { 9054521070a0Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 9055521070a0Smrg $STRIP $cwrapper 9056521070a0Smrg } 90574456fccdSmrg 9058521070a0Smrg # Now, create the wrapper script for func_source use: 9059521070a0Smrg func_ltwrapper_scriptname $cwrapper 9060521070a0Smrg $RM $func_ltwrapper_scriptname_result 9061521070a0Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 9062521070a0Smrg $opt_dry_run || { 9063521070a0Smrg # note: this script will not be executed, so do not chmod. 9064521070a0Smrg if test "x$build" = "x$host" ; then 9065521070a0Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 9066521070a0Smrg else 9067521070a0Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 9068521070a0Smrg fi 9069521070a0Smrg } 9070521070a0Smrg ;; 9071521070a0Smrg * ) 9072521070a0Smrg $RM $output 9073521070a0Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 90744456fccdSmrg 9075521070a0Smrg func_emit_wrapper no > $output 9076521070a0Smrg chmod +x $output 9077521070a0Smrg ;; 9078521070a0Smrg esac 9079521070a0Smrg } 9080521070a0Smrg exit $EXIT_SUCCESS 9081521070a0Smrg ;; 9082521070a0Smrg esac 90834456fccdSmrg 9084521070a0Smrg # See if we need to build an old-fashioned archive. 9085521070a0Smrg for oldlib in $oldlibs; do 90864456fccdSmrg 9087521070a0Smrg if test "$build_libtool_libs" = convenience; then 9088521070a0Smrg oldobjs="$libobjs_save $symfileobj" 9089521070a0Smrg addlibs="$convenience" 9090521070a0Smrg build_libtool_libs=no 9091521070a0Smrg else 9092521070a0Smrg if test "$build_libtool_libs" = module; then 9093521070a0Smrg oldobjs="$libobjs_save" 9094521070a0Smrg build_libtool_libs=no 9095521070a0Smrg else 9096521070a0Smrg oldobjs="$old_deplibs $non_pic_objects" 9097521070a0Smrg if test "$preload" = yes && test -f "$symfileobj"; then 90983e6c936aSmrg func_append oldobjs " $symfileobj" 9099521070a0Smrg fi 9100521070a0Smrg fi 9101521070a0Smrg addlibs="$old_convenience" 91024456fccdSmrg fi 91034456fccdSmrg 9104521070a0Smrg if test -n "$addlibs"; then 9105521070a0Smrg gentop="$output_objdir/${outputname}x" 91063e6c936aSmrg func_append generated " $gentop" 91074456fccdSmrg 9108521070a0Smrg func_extract_archives $gentop $addlibs 91093e6c936aSmrg func_append oldobjs " $func_extract_archives_result" 9110521070a0Smrg fi 91114456fccdSmrg 9112521070a0Smrg # Do each command in the archive commands. 9113521070a0Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 9114521070a0Smrg cmds=$old_archive_from_new_cmds 9115521070a0Smrg else 91164456fccdSmrg 9117521070a0Smrg # Add any objects from preloaded convenience libraries 9118521070a0Smrg if test -n "$dlprefiles"; then 9119521070a0Smrg gentop="$output_objdir/${outputname}x" 91203e6c936aSmrg func_append generated " $gentop" 91214456fccdSmrg 9122521070a0Smrg func_extract_archives $gentop $dlprefiles 91233e6c936aSmrg func_append oldobjs " $func_extract_archives_result" 9124521070a0Smrg fi 91254456fccdSmrg 9126521070a0Smrg # POSIX demands no paths to be encoded in archives. We have 9127521070a0Smrg # to avoid creating archives with duplicate basenames if we 9128521070a0Smrg # might have to extract them afterwards, e.g., when creating a 9129521070a0Smrg # static archive out of a convenience library, or when linking 9130521070a0Smrg # the entirety of a libtool archive into another (currently 9131521070a0Smrg # not supported by libtool). 9132521070a0Smrg if (for obj in $oldobjs 9133521070a0Smrg do 9134521070a0Smrg func_basename "$obj" 9135521070a0Smrg $ECHO "$func_basename_result" 9136521070a0Smrg done | sort | sort -uc >/dev/null 2>&1); then 9137521070a0Smrg : 9138521070a0Smrg else 9139ff63a143Smrg echo "copying selected object files to avoid basename conflicts..." 9140521070a0Smrg gentop="$output_objdir/${outputname}x" 91413e6c936aSmrg func_append generated " $gentop" 9142521070a0Smrg func_mkdir_p "$gentop" 9143521070a0Smrg save_oldobjs=$oldobjs 9144521070a0Smrg oldobjs= 9145521070a0Smrg counter=1 9146521070a0Smrg for obj in $save_oldobjs 9147521070a0Smrg do 9148521070a0Smrg func_basename "$obj" 9149521070a0Smrg objbase="$func_basename_result" 9150521070a0Smrg case " $oldobjs " in 9151521070a0Smrg " ") oldobjs=$obj ;; 9152521070a0Smrg *[\ /]"$objbase "*) 9153521070a0Smrg while :; do 9154521070a0Smrg # Make sure we don't pick an alternate name that also 9155521070a0Smrg # overlaps. 9156521070a0Smrg newobj=lt$counter-$objbase 9157521070a0Smrg func_arith $counter + 1 9158521070a0Smrg counter=$func_arith_result 9159521070a0Smrg case " $oldobjs " in 9160521070a0Smrg *[\ /]"$newobj "*) ;; 9161521070a0Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 9162521070a0Smrg esac 9163521070a0Smrg done 9164521070a0Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 91653e6c936aSmrg func_append oldobjs " $gentop/$newobj" 9166521070a0Smrg ;; 91673e6c936aSmrg *) func_append oldobjs " $obj" ;; 9168521070a0Smrg esac 91694456fccdSmrg done 91704456fccdSmrg fi 91713e6c936aSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 91723e6c936aSmrg tool_oldlib=$func_to_tool_file_result 9173521070a0Smrg eval cmds=\"$old_archive_cmds\" 91744456fccdSmrg 9175521070a0Smrg func_len " $cmds" 9176521070a0Smrg len=$func_len_result 9177521070a0Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9178521070a0Smrg cmds=$old_archive_cmds 91793e6c936aSmrg elif test -n "$archiver_list_spec"; then 91803e6c936aSmrg func_verbose "using command file archive linking..." 91813e6c936aSmrg for obj in $oldobjs 91823e6c936aSmrg do 91833e6c936aSmrg func_to_tool_file "$obj" 91843e6c936aSmrg $ECHO "$func_to_tool_file_result" 91853e6c936aSmrg done > $output_objdir/$libname.libcmd 91863e6c936aSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 91873e6c936aSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 91883e6c936aSmrg cmds=$old_archive_cmds 9189521070a0Smrg else 9190521070a0Smrg # the command line is too long to link in one step, link in parts 9191521070a0Smrg func_verbose "using piecewise archive linking..." 9192521070a0Smrg save_RANLIB=$RANLIB 9193521070a0Smrg RANLIB=: 9194521070a0Smrg objlist= 9195521070a0Smrg concat_cmds= 9196521070a0Smrg save_oldobjs=$oldobjs 9197521070a0Smrg oldobjs= 9198521070a0Smrg # Is there a better way of finding the last object in the list? 9199521070a0Smrg for obj in $save_oldobjs 9200521070a0Smrg do 9201521070a0Smrg last_oldobj=$obj 9202521070a0Smrg done 9203521070a0Smrg eval test_cmds=\"$old_archive_cmds\" 9204521070a0Smrg func_len " $test_cmds" 9205521070a0Smrg len0=$func_len_result 9206521070a0Smrg len=$len0 9207521070a0Smrg for obj in $save_oldobjs 9208521070a0Smrg do 9209521070a0Smrg func_len " $obj" 9210521070a0Smrg func_arith $len + $func_len_result 9211521070a0Smrg len=$func_arith_result 9212521070a0Smrg func_append objlist " $obj" 9213521070a0Smrg if test "$len" -lt "$max_cmd_len"; then 9214521070a0Smrg : 9215521070a0Smrg else 9216521070a0Smrg # the above command should be used before it gets too long 9217521070a0Smrg oldobjs=$objlist 9218521070a0Smrg if test "$obj" = "$last_oldobj" ; then 9219521070a0Smrg RANLIB=$save_RANLIB 9220521070a0Smrg fi 9221521070a0Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9222521070a0Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 9223521070a0Smrg objlist= 9224521070a0Smrg len=$len0 9225521070a0Smrg fi 9226521070a0Smrg done 9227521070a0Smrg RANLIB=$save_RANLIB 9228521070a0Smrg oldobjs=$objlist 9229521070a0Smrg if test "X$oldobjs" = "X" ; then 9230521070a0Smrg eval cmds=\"\$concat_cmds\" 9231521070a0Smrg else 9232521070a0Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 9233521070a0Smrg fi 9234521070a0Smrg fi 9235521070a0Smrg fi 9236521070a0Smrg func_execute_cmds "$cmds" 'exit $?' 92374456fccdSmrg done 92384456fccdSmrg 9239521070a0Smrg test -n "$generated" && \ 9240521070a0Smrg func_show_eval "${RM}r$generated" 92414456fccdSmrg 9242521070a0Smrg # Now create the libtool archive. 9243521070a0Smrg case $output in 9244521070a0Smrg *.la) 9245521070a0Smrg old_library= 9246521070a0Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 9247521070a0Smrg func_verbose "creating $output" 92484456fccdSmrg 9249521070a0Smrg # Preserve any variables that may affect compiler behavior 9250521070a0Smrg for var in $variables_saved_for_relink; do 9251521070a0Smrg if eval test -z \"\${$var+set}\"; then 9252521070a0Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9253521070a0Smrg elif eval var_value=\$$var; test -z "$var_value"; then 9254521070a0Smrg relink_command="$var=; export $var; $relink_command" 92554456fccdSmrg else 9256521070a0Smrg func_quote_for_eval "$var_value" 9257521070a0Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 92584456fccdSmrg fi 9259521070a0Smrg done 9260521070a0Smrg # Quote the link command for shipping. 9261521070a0Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 9262ff63a143Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9263521070a0Smrg if test "$hardcode_automatic" = yes ; then 9264521070a0Smrg relink_command= 9265521070a0Smrg fi 92664456fccdSmrg 9267521070a0Smrg # Only create the output if not a dry run. 9268521070a0Smrg $opt_dry_run || { 9269521070a0Smrg for installed in no yes; do 9270521070a0Smrg if test "$installed" = yes; then 9271521070a0Smrg if test -z "$install_libdir"; then 9272521070a0Smrg break 9273521070a0Smrg fi 9274521070a0Smrg output="$output_objdir/$outputname"i 9275521070a0Smrg # Replace all uninstalled libtool libraries with the installed ones 9276521070a0Smrg newdependency_libs= 9277521070a0Smrg for deplib in $dependency_libs; do 9278521070a0Smrg case $deplib in 9279521070a0Smrg *.la) 9280521070a0Smrg func_basename "$deplib" 9281521070a0Smrg name="$func_basename_result" 92823e6c936aSmrg func_resolve_sysroot "$deplib" 92833e6c936aSmrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 9284521070a0Smrg test -z "$libdir" && \ 9285521070a0Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 92863e6c936aSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 92873e6c936aSmrg ;; 92883e6c936aSmrg -L*) 92893e6c936aSmrg func_stripname -L '' "$deplib" 92903e6c936aSmrg func_replace_sysroot "$func_stripname_result" 92913e6c936aSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 92923e6c936aSmrg ;; 92933e6c936aSmrg -R*) 92943e6c936aSmrg func_stripname -R '' "$deplib" 92953e6c936aSmrg func_replace_sysroot "$func_stripname_result" 92963e6c936aSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 9297521070a0Smrg ;; 92983e6c936aSmrg *) func_append newdependency_libs " $deplib" ;; 9299521070a0Smrg esac 9300521070a0Smrg done 9301521070a0Smrg dependency_libs="$newdependency_libs" 9302521070a0Smrg newdlfiles= 9303521070a0Smrg 9304521070a0Smrg for lib in $dlfiles; do 9305521070a0Smrg case $lib in 9306521070a0Smrg *.la) 9307521070a0Smrg func_basename "$lib" 9308521070a0Smrg name="$func_basename_result" 9309521070a0Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9310521070a0Smrg test -z "$libdir" && \ 9311521070a0Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 93123e6c936aSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 9313521070a0Smrg ;; 93143e6c936aSmrg *) func_append newdlfiles " $lib" ;; 9315521070a0Smrg esac 9316521070a0Smrg done 9317521070a0Smrg dlfiles="$newdlfiles" 9318521070a0Smrg newdlprefiles= 9319521070a0Smrg for lib in $dlprefiles; do 9320521070a0Smrg case $lib in 9321521070a0Smrg *.la) 9322521070a0Smrg # Only pass preopened files to the pseudo-archive (for 9323521070a0Smrg # eventual linking with the app. that links it) if we 9324521070a0Smrg # didn't already link the preopened objects directly into 9325521070a0Smrg # the library: 9326521070a0Smrg func_basename "$lib" 9327521070a0Smrg name="$func_basename_result" 9328521070a0Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9329521070a0Smrg test -z "$libdir" && \ 9330521070a0Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 93313e6c936aSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 9332521070a0Smrg ;; 9333521070a0Smrg esac 9334521070a0Smrg done 9335521070a0Smrg dlprefiles="$newdlprefiles" 9336521070a0Smrg else 9337521070a0Smrg newdlfiles= 9338521070a0Smrg for lib in $dlfiles; do 9339521070a0Smrg case $lib in 9340521070a0Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9341521070a0Smrg *) abs=`pwd`"/$lib" ;; 9342521070a0Smrg esac 93433e6c936aSmrg func_append newdlfiles " $abs" 9344521070a0Smrg done 9345521070a0Smrg dlfiles="$newdlfiles" 9346521070a0Smrg newdlprefiles= 9347521070a0Smrg for lib in $dlprefiles; do 9348521070a0Smrg case $lib in 9349521070a0Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9350521070a0Smrg *) abs=`pwd`"/$lib" ;; 9351521070a0Smrg esac 93523e6c936aSmrg func_append newdlprefiles " $abs" 9353521070a0Smrg done 9354521070a0Smrg dlprefiles="$newdlprefiles" 9355521070a0Smrg fi 9356521070a0Smrg $RM $output 9357521070a0Smrg # place dlname in correct position for cygwin 9358ff63a143Smrg # In fact, it would be nice if we could use this code for all target 9359ff63a143Smrg # systems that can't hard-code library paths into their executables 9360ff63a143Smrg # and that have no shared library path variable independent of PATH, 9361ff63a143Smrg # but it turns out we can't easily determine that from inspecting 9362ff63a143Smrg # libtool variables, so we have to hard-code the OSs to which it 9363ff63a143Smrg # applies here; at the moment, that means platforms that use the PE 9364ff63a143Smrg # object format with DLL files. See the long comment at the top of 9365ff63a143Smrg # tests/bindir.at for full details. 9366521070a0Smrg tdlname=$dlname 9367521070a0Smrg case $host,$output,$installed,$module,$dlname in 9368ff63a143Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 9369ff63a143Smrg # If a -bindir argument was supplied, place the dll there. 9370ff63a143Smrg if test "x$bindir" != x ; 9371ff63a143Smrg then 9372ff63a143Smrg func_relative_path "$install_libdir" "$bindir" 9373ff63a143Smrg tdlname=$func_relative_path_result$dlname 9374ff63a143Smrg else 9375ff63a143Smrg # Otherwise fall back on heuristic. 9376ff63a143Smrg tdlname=../bin/$dlname 9377ff63a143Smrg fi 9378ff63a143Smrg ;; 9379521070a0Smrg esac 9380521070a0Smrg $ECHO > $output "\ 9381521070a0Smrg# $outputname - a libtool library file 9382521070a0Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 9383521070a0Smrg# 9384521070a0Smrg# Please DO NOT delete this file! 9385521070a0Smrg# It is necessary for linking the library. 93864456fccdSmrg 9387521070a0Smrg# The name that we can dlopen(3). 9388521070a0Smrgdlname='$tdlname' 93894456fccdSmrg 9390521070a0Smrg# Names of this library. 9391521070a0Smrglibrary_names='$library_names' 93924456fccdSmrg 9393521070a0Smrg# The name of the static archive. 9394521070a0Smrgold_library='$old_library' 93954456fccdSmrg 9396521070a0Smrg# Linker flags that can not go in dependency_libs. 9397521070a0Smrginherited_linker_flags='$new_inherited_linker_flags' 93984456fccdSmrg 9399521070a0Smrg# Libraries that this one depends upon. 9400521070a0Smrgdependency_libs='$dependency_libs' 94014456fccdSmrg 9402521070a0Smrg# Names of additional weak libraries provided by this library 9403521070a0Smrgweak_library_names='$weak_libs' 94044456fccdSmrg 9405521070a0Smrg# Version information for $libname. 9406521070a0Smrgcurrent=$current 9407521070a0Smrgage=$age 9408521070a0Smrgrevision=$revision 94094456fccdSmrg 9410521070a0Smrg# Is this an already installed library? 9411521070a0Smrginstalled=$installed 94124456fccdSmrg 9413521070a0Smrg# Should we warn about portability when linking against -modules? 9414521070a0Smrgshouldnotlink=$module 94154456fccdSmrg 9416521070a0Smrg# Files to dlopen/dlpreopen 9417521070a0Smrgdlopen='$dlfiles' 9418521070a0Smrgdlpreopen='$dlprefiles' 94194456fccdSmrg 9420521070a0Smrg# Directory that this library needs to be installed in: 9421521070a0Smrglibdir='$install_libdir'" 9422521070a0Smrg if test "$installed" = no && test "$need_relink" = yes; then 9423521070a0Smrg $ECHO >> $output "\ 9424521070a0Smrgrelink_command=\"$relink_command\"" 9425521070a0Smrg fi 9426521070a0Smrg done 9427521070a0Smrg } 94284456fccdSmrg 9429521070a0Smrg # Do a symbolic link so that the libtool archive can be found in 9430521070a0Smrg # LD_LIBRARY_PATH before the program is installed. 9431521070a0Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 9432521070a0Smrg ;; 9433521070a0Smrg esac 9434521070a0Smrg exit $EXIT_SUCCESS 9435521070a0Smrg} 94364456fccdSmrg 94373e6c936aSmrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 9438521070a0Smrg func_mode_link ${1+"$@"} 94394456fccdSmrg 94404456fccdSmrg 9441521070a0Smrg# func_mode_uninstall arg... 9442521070a0Smrgfunc_mode_uninstall () 9443521070a0Smrg{ 9444521070a0Smrg $opt_debug 9445521070a0Smrg RM="$nonopt" 94464456fccdSmrg files= 94474456fccdSmrg rmforce= 94484456fccdSmrg exit_status=0 94494456fccdSmrg 94504456fccdSmrg # This variable tells wrapper scripts just to set variables rather 94514456fccdSmrg # than running their programs. 94524456fccdSmrg libtool_install_magic="$magic" 94534456fccdSmrg 94544456fccdSmrg for arg 94554456fccdSmrg do 94564456fccdSmrg case $arg in 94573e6c936aSmrg -f) func_append RM " $arg"; rmforce=yes ;; 94583e6c936aSmrg -*) func_append RM " $arg" ;; 94593e6c936aSmrg *) func_append files " $arg" ;; 94604456fccdSmrg esac 94614456fccdSmrg done 94624456fccdSmrg 9463521070a0Smrg test -z "$RM" && \ 9464521070a0Smrg func_fatal_help "you must specify an RM program" 94654456fccdSmrg 94664456fccdSmrg rmdirs= 94674456fccdSmrg 94684456fccdSmrg for file in $files; do 9469521070a0Smrg func_dirname "$file" "" "." 9470521070a0Smrg dir="$func_dirname_result" 9471521070a0Smrg if test "X$dir" = X.; then 94723e6c936aSmrg odir="$objdir" 94734456fccdSmrg else 94743e6c936aSmrg odir="$dir/$objdir" 94754456fccdSmrg fi 9476521070a0Smrg func_basename "$file" 9477521070a0Smrg name="$func_basename_result" 94783e6c936aSmrg test "$opt_mode" = uninstall && odir="$dir" 94794456fccdSmrg 94803e6c936aSmrg # Remember odir for removal later, being careful to avoid duplicates 94813e6c936aSmrg if test "$opt_mode" = clean; then 94824456fccdSmrg case " $rmdirs " in 94833e6c936aSmrg *" $odir "*) ;; 94843e6c936aSmrg *) func_append rmdirs " $odir" ;; 94854456fccdSmrg esac 94864456fccdSmrg fi 94874456fccdSmrg 94884456fccdSmrg # Don't error if the file doesn't exist and rm -f was used. 9489521070a0Smrg if { test -L "$file"; } >/dev/null 2>&1 || 9490521070a0Smrg { test -h "$file"; } >/dev/null 2>&1 || 9491521070a0Smrg test -f "$file"; then 94924456fccdSmrg : 94934456fccdSmrg elif test -d "$file"; then 94944456fccdSmrg exit_status=1 94954456fccdSmrg continue 94964456fccdSmrg elif test "$rmforce" = yes; then 94974456fccdSmrg continue 94984456fccdSmrg fi 94994456fccdSmrg 95004456fccdSmrg rmfiles="$file" 95014456fccdSmrg 95024456fccdSmrg case $name in 95034456fccdSmrg *.la) 95044456fccdSmrg # Possibly a libtool archive, so verify it. 9505521070a0Smrg if func_lalib_p "$file"; then 9506521070a0Smrg func_source $dir/$name 95074456fccdSmrg 95084456fccdSmrg # Delete the libtool libraries and symlinks. 95094456fccdSmrg for n in $library_names; do 95103e6c936aSmrg func_append rmfiles " $odir/$n" 95114456fccdSmrg done 95123e6c936aSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 95134456fccdSmrg 95143e6c936aSmrg case "$opt_mode" in 95154456fccdSmrg clean) 95163e6c936aSmrg case " $library_names " in 95174456fccdSmrg *" $dlname "*) ;; 95183e6c936aSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 95194456fccdSmrg esac 95203e6c936aSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 95214456fccdSmrg ;; 95224456fccdSmrg uninstall) 95234456fccdSmrg if test -n "$library_names"; then 95244456fccdSmrg # Do each command in the postuninstall commands. 9525521070a0Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 95264456fccdSmrg fi 95274456fccdSmrg 95284456fccdSmrg if test -n "$old_library"; then 95294456fccdSmrg # Do each command in the old_postuninstall commands. 9530521070a0Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 95314456fccdSmrg fi 95324456fccdSmrg # FIXME: should reinstall the best remaining shared library. 95334456fccdSmrg ;; 95344456fccdSmrg esac 95354456fccdSmrg fi 95364456fccdSmrg ;; 95374456fccdSmrg 95384456fccdSmrg *.lo) 95394456fccdSmrg # Possibly a libtool object, so verify it. 9540521070a0Smrg if func_lalib_p "$file"; then 95414456fccdSmrg 95424456fccdSmrg # Read the .lo file 9543521070a0Smrg func_source $dir/$name 95444456fccdSmrg 95454456fccdSmrg # Add PIC object to the list of files to remove. 9546521070a0Smrg if test -n "$pic_object" && 9547521070a0Smrg test "$pic_object" != none; then 95483e6c936aSmrg func_append rmfiles " $dir/$pic_object" 95494456fccdSmrg fi 95504456fccdSmrg 95514456fccdSmrg # Add non-PIC object to the list of files to remove. 9552521070a0Smrg if test -n "$non_pic_object" && 9553521070a0Smrg test "$non_pic_object" != none; then 95543e6c936aSmrg func_append rmfiles " $dir/$non_pic_object" 95554456fccdSmrg fi 95564456fccdSmrg fi 95574456fccdSmrg ;; 95584456fccdSmrg 95594456fccdSmrg *) 95603e6c936aSmrg if test "$opt_mode" = clean ; then 95614456fccdSmrg noexename=$name 95624456fccdSmrg case $file in 95634456fccdSmrg *.exe) 9564521070a0Smrg func_stripname '' '.exe' "$file" 9565521070a0Smrg file=$func_stripname_result 9566521070a0Smrg func_stripname '' '.exe' "$name" 9567521070a0Smrg noexename=$func_stripname_result 95684456fccdSmrg # $file with .exe has already been added to rmfiles, 95694456fccdSmrg # add $file without .exe 95703e6c936aSmrg func_append rmfiles " $file" 95714456fccdSmrg ;; 95724456fccdSmrg esac 95734456fccdSmrg # Do a test to see if this is a libtool program. 9574521070a0Smrg if func_ltwrapper_p "$file"; then 9575521070a0Smrg if func_ltwrapper_executable_p "$file"; then 9576521070a0Smrg func_ltwrapper_scriptname "$file" 9577521070a0Smrg relink_command= 9578521070a0Smrg func_source $func_ltwrapper_scriptname_result 95793e6c936aSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 9580521070a0Smrg else 9581521070a0Smrg relink_command= 9582521070a0Smrg func_source $dir/$noexename 9583521070a0Smrg fi 95844456fccdSmrg 95854456fccdSmrg # note $name still contains .exe if it was in $file originally 95864456fccdSmrg # as does the version of $file that was added into $rmfiles 95873e6c936aSmrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 95884456fccdSmrg if test "$fast_install" = yes && test -n "$relink_command"; then 95893e6c936aSmrg func_append rmfiles " $odir/lt-$name" 95904456fccdSmrg fi 95914456fccdSmrg if test "X$noexename" != "X$name" ; then 95923e6c936aSmrg func_append rmfiles " $odir/lt-${noexename}.c" 95934456fccdSmrg fi 95944456fccdSmrg fi 95954456fccdSmrg fi 95964456fccdSmrg ;; 95974456fccdSmrg esac 9598521070a0Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 95994456fccdSmrg done 96004456fccdSmrg 96014456fccdSmrg # Try to remove the ${objdir}s in the directories where we deleted files 96024456fccdSmrg for dir in $rmdirs; do 96034456fccdSmrg if test -d "$dir"; then 9604521070a0Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 96054456fccdSmrg fi 96064456fccdSmrg done 96074456fccdSmrg 96084456fccdSmrg exit $exit_status 9609521070a0Smrg} 96104456fccdSmrg 96113e6c936aSmrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 9612521070a0Smrg func_mode_uninstall ${1+"$@"} 96134456fccdSmrg 96143e6c936aSmrgtest -z "$opt_mode" && { 9615521070a0Smrg help="$generic_help" 9616521070a0Smrg func_fatal_help "you must specify a MODE" 9617521070a0Smrg} 9618521070a0Smrg 9619521070a0Smrgtest -z "$exec_cmd" && \ 96203e6c936aSmrg func_fatal_help "invalid operation mode \`$opt_mode'" 96214456fccdSmrg 96224456fccdSmrgif test -n "$exec_cmd"; then 9623521070a0Smrg eval exec "$exec_cmd" 96244456fccdSmrg exit $EXIT_FAILURE 96254456fccdSmrgfi 96264456fccdSmrg 9627521070a0Smrgexit $exit_status 96284456fccdSmrg 96294456fccdSmrg 96304456fccdSmrg# The TAGs below are defined such that we never get into a situation 96314456fccdSmrg# in which we disable both kinds of libraries. Given conflicting 96324456fccdSmrg# choices, we go for a static library, that is the most portable, 96334456fccdSmrg# since we can't tell whether shared libraries were disabled because 96344456fccdSmrg# the user asked for that or because the platform doesn't support 96354456fccdSmrg# them. This is particularly important on AIX, because we don't 96364456fccdSmrg# support having both static and shared libraries enabled at the same 96374456fccdSmrg# time on that platform, so we default to a shared-only configuration. 96384456fccdSmrg# If a disable-shared tag is given, we'll fallback to a static-only 96394456fccdSmrg# configuration. But we'll never go from static-only to shared-only. 96404456fccdSmrg 96414456fccdSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 9642521070a0Smrgbuild_libtool_libs=no 9643521070a0Smrgbuild_old_libs=yes 96444456fccdSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 96454456fccdSmrg 96464456fccdSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 9647521070a0Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 96484456fccdSmrg# ### END LIBTOOL TAG CONFIG: disable-static 96494456fccdSmrg 96504456fccdSmrg# Local Variables: 96514456fccdSmrg# mode:shell-script 96524456fccdSmrg# sh-indentation:2 96534456fccdSmrg# End: 9654521070a0Smrg# vi:sw=2 9655521070a0Smrg 9656