ltmain.sh revision 3e72ca8c
134977a2fSmrg 23e72ca8cSmrg# libtool (GNU libtool) 2.4.2 334977a2fSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 434977a2fSmrg 5b425557eSmrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 63e72ca8cSmrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 734977a2fSmrg# This is free software; see the source for copying conditions. There is NO 834977a2fSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 934977a2fSmrg 1034977a2fSmrg# GNU Libtool is free software; you can redistribute it and/or modify 11ee3138f1Smrg# it under the terms of the GNU General Public License as published by 12ee3138f1Smrg# the Free Software Foundation; either version 2 of the License, or 13ee3138f1Smrg# (at your option) any later version. 14ee3138f1Smrg# 1534977a2fSmrg# As a special exception to the GNU General Public License, 1634977a2fSmrg# if you distribute this file as part of a program or library that 1734977a2fSmrg# is built using GNU Libtool, you may include this file under the 1834977a2fSmrg# same distribution terms that you use for the rest of that program. 1934977a2fSmrg# 2034977a2fSmrg# GNU Libtool is distributed in the hope that it will be useful, but 21ee3138f1Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 22ee3138f1Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23ee3138f1Smrg# General Public License for more details. 24ee3138f1Smrg# 25ee3138f1Smrg# You should have received a copy of the GNU General Public License 2634977a2fSmrg# along with GNU Libtool; see the file COPYING. If not, a copy 2734977a2fSmrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 2834977a2fSmrg# or obtained by writing to the Free Software Foundation, Inc., 2934977a2fSmrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 3079a8a9c6Smrg 3134977a2fSmrg# Usage: $progname [OPTION]... [MODE-ARG]... 3234977a2fSmrg# 3334977a2fSmrg# Provide generalized library-building support services. 3434977a2fSmrg# 35b425557eSmrg# --config show all configuration variables 36b425557eSmrg# --debug enable verbose shell tracing 37b425557eSmrg# -n, --dry-run display commands without modifying any files 38b425557eSmrg# --features display basic configuration information and exit 39b425557eSmrg# --mode=MODE use operation mode MODE 40b425557eSmrg# --preserve-dup-deps don't remove duplicate dependency libraries 41b425557eSmrg# --quiet, --silent don't print informational messages 42b425557eSmrg# --no-quiet, --no-silent 43b425557eSmrg# print informational messages (default) 443e72ca8cSmrg# --no-warn don't display warning messages 45b425557eSmrg# --tag=TAG use configuration variables from tag TAG 46b425557eSmrg# -v, --verbose print more informational messages than default 47b425557eSmrg# --no-verbose don't print the extra informational messages 48b425557eSmrg# --version print version information 49b425557eSmrg# -h, --help, --help-all print short, long, or detailed help message 5034977a2fSmrg# 5134977a2fSmrg# MODE must be one of the following: 5234977a2fSmrg# 53b425557eSmrg# clean remove files from the build directory 54b425557eSmrg# compile compile a source file into a libtool object 55b425557eSmrg# execute automatically set library path, then run a program 56b425557eSmrg# finish complete the installation of libtool libraries 57b425557eSmrg# install install libraries or executables 58b425557eSmrg# link create a library or an executable 59b425557eSmrg# uninstall remove libraries from an installed directory 6034977a2fSmrg# 61b425557eSmrg# MODE-ARGS vary depending on the MODE. When passed as first option, 62b425557eSmrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 6334977a2fSmrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 6434977a2fSmrg# 6534977a2fSmrg# When reporting a bug, please describe a test case to reproduce it and 6634977a2fSmrg# include the following information: 6734977a2fSmrg# 68b425557eSmrg# host-triplet: $host 69b425557eSmrg# shell: $SHELL 70b425557eSmrg# compiler: $LTCC 71b425557eSmrg# compiler flags: $LTCFLAGS 72b425557eSmrg# linker: $LD (gnu? $with_gnu_ld) 733e72ca8cSmrg# $progname: (GNU libtool) 2.4.2 74b425557eSmrg# automake: $automake_version 75b425557eSmrg# autoconf: $autoconf_version 7634977a2fSmrg# 7734977a2fSmrg# Report bugs to <bug-libtool@gnu.org>. 783e72ca8cSmrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 793e72ca8cSmrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 80ee3138f1Smrg 81b425557eSmrgPROGRAM=libtool 82ee3138f1SmrgPACKAGE=libtool 833e72ca8cSmrgVERSION=2.4.2 8434977a2fSmrgTIMESTAMP="" 853e72ca8cSmrgpackage_revision=1.3337 86ee3138f1Smrg 8734977a2fSmrg# Be Bourne compatible 88ee3138f1Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 89ee3138f1Smrg emulate sh 90ee3138f1Smrg NULLCMD=: 91ee3138f1Smrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 92ee3138f1Smrg # is contrary to our usage. Disable this feature. 93ee3138f1Smrg alias -g '${1+"$@"}'='"$@"' 94ee3138f1Smrg setopt NO_GLOB_SUBST 95ee3138f1Smrgelse 96ee3138f1Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 97ee3138f1Smrgfi 98ee3138f1SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 99ee3138f1SmrgDUALCASE=1; export DUALCASE # for MKS sh 100ee3138f1Smrg 101b425557eSmrg# A function that is used when there is no print builtin or printf. 102b425557eSmrgfunc_fallback_echo () 103b425557eSmrg{ 104b425557eSmrg eval 'cat <<_LTECHO_EOF 105b425557eSmrg$1 106b425557eSmrg_LTECHO_EOF' 107b425557eSmrg} 108b425557eSmrg 10934977a2fSmrg# NLS nuisances: We save the old values to restore during execute mode. 11034977a2fSmrglt_user_locale= 11134977a2fSmrglt_safe_locale= 11279a8a9c6Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 113ee3138f1Smrgdo 114ee3138f1Smrg eval "if test \"\${$lt_var+set}\" = set; then 11534977a2fSmrg save_$lt_var=\$$lt_var 11634977a2fSmrg $lt_var=C 117ee3138f1Smrg export $lt_var 11834977a2fSmrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 11934977a2fSmrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 120ee3138f1Smrg fi" 121ee3138f1Smrgdone 122b425557eSmrgLC_ALL=C 123b425557eSmrgLANGUAGE=C 124b425557eSmrgexport LANGUAGE LC_ALL 125ee3138f1Smrg 12634977a2fSmrg$lt_unset CDPATH 12734977a2fSmrg 12834977a2fSmrg 129b425557eSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 130b425557eSmrg# is ksh but when the shell is invoked as "sh" and the current value of 131b425557eSmrg# the _XPG environment variable is not equal to 1 (one), the special 132b425557eSmrg# positional parameter $0, within a function call, is the name of the 133b425557eSmrg# function. 134b425557eSmrgprogpath="$0" 13534977a2fSmrg 13634977a2fSmrg 13734977a2fSmrg 13834977a2fSmrg: ${CP="cp -f"} 139b425557eSmrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 14034977a2fSmrg: ${MAKE="make"} 14134977a2fSmrg: ${MKDIR="mkdir"} 14234977a2fSmrg: ${MV="mv -f"} 14334977a2fSmrg: ${RM="rm -f"} 14434977a2fSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 14534977a2fSmrg: ${Xsed="$SED -e 1s/^X//"} 14634977a2fSmrg 14734977a2fSmrg# Global variables: 14834977a2fSmrgEXIT_SUCCESS=0 14934977a2fSmrgEXIT_FAILURE=1 15034977a2fSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 15134977a2fSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 15234977a2fSmrg 15334977a2fSmrgexit_status=$EXIT_SUCCESS 15479a8a9c6Smrg 155ee3138f1Smrg# Make sure IFS has a sensible default 156ee3138f1Smrglt_nl=' 157ee3138f1Smrg' 158ee3138f1SmrgIFS=" $lt_nl" 159ee3138f1Smrg 16034977a2fSmrgdirname="s,/[^/]*$,," 16134977a2fSmrgbasename="s,^.*/,," 16234977a2fSmrg 1633e72ca8cSmrg# func_dirname file append nondir_replacement 1643e72ca8cSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 1653e72ca8cSmrg# otherwise set result to NONDIR_REPLACEMENT. 1663e72ca8cSmrgfunc_dirname () 1673e72ca8cSmrg{ 1683e72ca8cSmrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 1693e72ca8cSmrg if test "X$func_dirname_result" = "X${1}"; then 1703e72ca8cSmrg func_dirname_result="${3}" 1713e72ca8cSmrg else 1723e72ca8cSmrg func_dirname_result="$func_dirname_result${2}" 1733e72ca8cSmrg fi 1743e72ca8cSmrg} # func_dirname may be replaced by extended shell implementation 1753e72ca8cSmrg 1763e72ca8cSmrg 1773e72ca8cSmrg# func_basename file 1783e72ca8cSmrgfunc_basename () 1793e72ca8cSmrg{ 1803e72ca8cSmrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 1813e72ca8cSmrg} # func_basename may be replaced by extended shell implementation 1823e72ca8cSmrg 1833e72ca8cSmrg 18434977a2fSmrg# func_dirname_and_basename file append nondir_replacement 18534977a2fSmrg# perform func_basename and func_dirname in a single function 18634977a2fSmrg# call: 18734977a2fSmrg# dirname: Compute the dirname of FILE. If nonempty, 18834977a2fSmrg# add APPEND to the result, otherwise set result 18934977a2fSmrg# to NONDIR_REPLACEMENT. 19034977a2fSmrg# value returned in "$func_dirname_result" 19134977a2fSmrg# basename: Compute filename of FILE. 19234977a2fSmrg# value retuned in "$func_basename_result" 19334977a2fSmrg# Implementation must be kept synchronized with func_dirname 19434977a2fSmrg# and func_basename. For efficiency, we do not delegate to 19534977a2fSmrg# those functions but instead duplicate the functionality here. 19634977a2fSmrgfunc_dirname_and_basename () 19734977a2fSmrg{ 1983e72ca8cSmrg # Extract subdirectory from the argument. 1993e72ca8cSmrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 2003e72ca8cSmrg if test "X$func_dirname_result" = "X${1}"; then 2013e72ca8cSmrg func_dirname_result="${3}" 2023e72ca8cSmrg else 2033e72ca8cSmrg func_dirname_result="$func_dirname_result${2}" 2043e72ca8cSmrg fi 2053e72ca8cSmrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 2063e72ca8cSmrg} # func_dirname_and_basename may be replaced by extended shell implementation 2073e72ca8cSmrg 2083e72ca8cSmrg 2093e72ca8cSmrg# func_stripname prefix suffix name 2103e72ca8cSmrg# strip PREFIX and SUFFIX off of NAME. 2113e72ca8cSmrg# PREFIX and SUFFIX must not contain globbing or regex special 2123e72ca8cSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 2133e72ca8cSmrg# dot (in which case that matches only a dot). 2143e72ca8cSmrg# func_strip_suffix prefix name 2153e72ca8cSmrgfunc_stripname () 2163e72ca8cSmrg{ 2173e72ca8cSmrg case ${2} in 2183e72ca8cSmrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 2193e72ca8cSmrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 2203e72ca8cSmrg esac 2213e72ca8cSmrg} # func_stripname may be replaced by extended shell implementation 222ee3138f1Smrg 22334977a2fSmrg 224b425557eSmrg# These SED scripts presuppose an absolute path with a trailing slash. 225b425557eSmrgpathcar='s,^/\([^/]*\).*$,\1,' 226b425557eSmrgpathcdr='s,^/[^/]*,,' 227b425557eSmrgremovedotparts=':dotsl 228b425557eSmrg s@/\./@/@g 229b425557eSmrg t dotsl 230b425557eSmrg s,/\.$,/,' 231b425557eSmrgcollapseslashes='s@/\{1,\}@/@g' 232b425557eSmrgfinalslash='s,/*$,/,' 233b425557eSmrg 234b425557eSmrg# func_normal_abspath PATH 235b425557eSmrg# Remove doubled-up and trailing slashes, "." path components, 236b425557eSmrg# and cancel out any ".." path components in PATH after making 237b425557eSmrg# it an absolute path. 238b425557eSmrg# value returned in "$func_normal_abspath_result" 239b425557eSmrgfunc_normal_abspath () 240b425557eSmrg{ 241b425557eSmrg # Start from root dir and reassemble the path. 242b425557eSmrg func_normal_abspath_result= 243b425557eSmrg func_normal_abspath_tpath=$1 244b425557eSmrg func_normal_abspath_altnamespace= 245b425557eSmrg case $func_normal_abspath_tpath in 246b425557eSmrg "") 247b425557eSmrg # Empty path, that just means $cwd. 248b425557eSmrg func_stripname '' '/' "`pwd`" 249b425557eSmrg func_normal_abspath_result=$func_stripname_result 250b425557eSmrg return 251b425557eSmrg ;; 252b425557eSmrg # The next three entries are used to spot a run of precisely 253b425557eSmrg # two leading slashes without using negated character classes; 254b425557eSmrg # we take advantage of case's first-match behaviour. 255b425557eSmrg ///*) 256b425557eSmrg # Unusual form of absolute path, do nothing. 257b425557eSmrg ;; 258b425557eSmrg //*) 259b425557eSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 260b425557eSmrg # and for example Cygwin uses it to access remote file shares 261b425557eSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 262b425557eSmrg func_normal_abspath_altnamespace=/ 263b425557eSmrg ;; 264b425557eSmrg /*) 265b425557eSmrg # Absolute path, do nothing. 266b425557eSmrg ;; 267b425557eSmrg *) 268b425557eSmrg # Relative path, prepend $cwd. 269b425557eSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 270b425557eSmrg ;; 271b425557eSmrg esac 272b425557eSmrg # Cancel out all the simple stuff to save iterations. We also want 273b425557eSmrg # the path to end with a slash for ease of parsing, so make sure 274b425557eSmrg # there is one (and only one) here. 275b425557eSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 276b425557eSmrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 277b425557eSmrg while :; do 278b425557eSmrg # Processed it all yet? 279b425557eSmrg if test "$func_normal_abspath_tpath" = / ; then 280b425557eSmrg # If we ascended to the root using ".." the result may be empty now. 281b425557eSmrg if test -z "$func_normal_abspath_result" ; then 282b425557eSmrg func_normal_abspath_result=/ 283b425557eSmrg fi 284b425557eSmrg break 285b425557eSmrg fi 286b425557eSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 287b425557eSmrg -e "$pathcar"` 288b425557eSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 289b425557eSmrg -e "$pathcdr"` 290b425557eSmrg # Figure out what to do with it 291b425557eSmrg case $func_normal_abspath_tcomponent in 292b425557eSmrg "") 293b425557eSmrg # Trailing empty path component, ignore it. 294b425557eSmrg ;; 295b425557eSmrg ..) 296b425557eSmrg # Parent dir; strip last assembled component from result. 297b425557eSmrg func_dirname "$func_normal_abspath_result" 298b425557eSmrg func_normal_abspath_result=$func_dirname_result 299b425557eSmrg ;; 300b425557eSmrg *) 301b425557eSmrg # Actual path component, append it. 302b425557eSmrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 303b425557eSmrg ;; 304b425557eSmrg esac 305b425557eSmrg done 306b425557eSmrg # Restore leading double-slash if one was found on entry. 307b425557eSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 308b425557eSmrg} 309b425557eSmrg 310b425557eSmrg# func_relative_path SRCDIR DSTDIR 311b425557eSmrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 312b425557eSmrg# slash if non-empty, suitable for immediately appending a filename 313b425557eSmrg# without needing to append a separator. 314b425557eSmrg# value returned in "$func_relative_path_result" 315b425557eSmrgfunc_relative_path () 316b425557eSmrg{ 317b425557eSmrg func_relative_path_result= 318b425557eSmrg func_normal_abspath "$1" 319b425557eSmrg func_relative_path_tlibdir=$func_normal_abspath_result 320b425557eSmrg func_normal_abspath "$2" 321b425557eSmrg func_relative_path_tbindir=$func_normal_abspath_result 322b425557eSmrg 323b425557eSmrg # Ascend the tree starting from libdir 324b425557eSmrg while :; do 325b425557eSmrg # check if we have found a prefix of bindir 326b425557eSmrg case $func_relative_path_tbindir in 327b425557eSmrg $func_relative_path_tlibdir) 328b425557eSmrg # found an exact match 329b425557eSmrg func_relative_path_tcancelled= 330b425557eSmrg break 331b425557eSmrg ;; 332b425557eSmrg $func_relative_path_tlibdir*) 333b425557eSmrg # found a matching prefix 334b425557eSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 335b425557eSmrg func_relative_path_tcancelled=$func_stripname_result 336b425557eSmrg if test -z "$func_relative_path_result"; then 337b425557eSmrg func_relative_path_result=. 338b425557eSmrg fi 339b425557eSmrg break 340b425557eSmrg ;; 341b425557eSmrg *) 342b425557eSmrg func_dirname $func_relative_path_tlibdir 343b425557eSmrg func_relative_path_tlibdir=${func_dirname_result} 344b425557eSmrg if test "x$func_relative_path_tlibdir" = x ; then 345b425557eSmrg # Have to descend all the way to the root! 346b425557eSmrg func_relative_path_result=../$func_relative_path_result 347b425557eSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 348b425557eSmrg break 349b425557eSmrg fi 350b425557eSmrg func_relative_path_result=../$func_relative_path_result 351b425557eSmrg ;; 352b425557eSmrg esac 353b425557eSmrg done 354b425557eSmrg 355b425557eSmrg # Now calculate path; take care to avoid doubling-up slashes. 356b425557eSmrg func_stripname '' '/' "$func_relative_path_result" 357b425557eSmrg func_relative_path_result=$func_stripname_result 358b425557eSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 359b425557eSmrg if test "x$func_stripname_result" != x ; then 360b425557eSmrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 361b425557eSmrg fi 362b425557eSmrg 363b425557eSmrg # Normalisation. If bindir is libdir, return empty string, 364b425557eSmrg # else relative path ending with a slash; either way, target 365b425557eSmrg # file name can be directly appended. 366b425557eSmrg if test ! -z "$func_relative_path_result"; then 367b425557eSmrg func_stripname './' '' "$func_relative_path_result/" 368b425557eSmrg func_relative_path_result=$func_stripname_result 369b425557eSmrg fi 370b425557eSmrg} 37134977a2fSmrg 37234977a2fSmrg# The name of this program: 37334977a2fSmrgfunc_dirname_and_basename "$progpath" 37434977a2fSmrgprogname=$func_basename_result 37534977a2fSmrg 37634977a2fSmrg# Make sure we have an absolute path for reexecution: 37734977a2fSmrgcase $progpath in 37834977a2fSmrg [\\/]*|[A-Za-z]:\\*) ;; 37934977a2fSmrg *[\\/]*) 38034977a2fSmrg progdir=$func_dirname_result 38134977a2fSmrg progdir=`cd "$progdir" && pwd` 38234977a2fSmrg progpath="$progdir/$progname" 38334977a2fSmrg ;; 38434977a2fSmrg *) 38534977a2fSmrg save_IFS="$IFS" 3863e72ca8cSmrg IFS=${PATH_SEPARATOR-:} 38734977a2fSmrg for progdir in $PATH; do 38834977a2fSmrg IFS="$save_IFS" 38934977a2fSmrg test -x "$progdir/$progname" && break 39034977a2fSmrg done 39134977a2fSmrg IFS="$save_IFS" 39234977a2fSmrg test -n "$progdir" || progdir=`pwd` 39334977a2fSmrg progpath="$progdir/$progname" 39434977a2fSmrg ;; 39534977a2fSmrgesac 39634977a2fSmrg 39734977a2fSmrg# Sed substitution that helps us do robust quoting. It backslashifies 39834977a2fSmrg# metacharacters that are still active within double-quoted strings. 39934977a2fSmrgXsed="${SED}"' -e 1s/^X//' 40034977a2fSmrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 40134977a2fSmrg 40234977a2fSmrg# Same as above, but do not quote variable references. 40334977a2fSmrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 40434977a2fSmrg 4053e72ca8cSmrg# Sed substitution that turns a string into a regex matching for the 4063e72ca8cSmrg# string literally. 4073e72ca8cSmrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 4083e72ca8cSmrg 4093e72ca8cSmrg# Sed substitution that converts a w32 file name or path 4103e72ca8cSmrg# which contains forward slashes, into one that contains 4113e72ca8cSmrg# (escaped) backslashes. A very naive implementation. 4123e72ca8cSmrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 4133e72ca8cSmrg 41434977a2fSmrg# Re-`\' parameter expansions in output of double_quote_subst that were 41534977a2fSmrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 41634977a2fSmrg# in input to double_quote_subst, that '$' was protected from expansion. 41734977a2fSmrg# Since each input `\' is now two `\'s, look for any number of runs of 41834977a2fSmrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 41934977a2fSmrgbs='\\' 42034977a2fSmrgbs2='\\\\' 42134977a2fSmrgbs4='\\\\\\\\' 42234977a2fSmrgdollar='\$' 42334977a2fSmrgsed_double_backslash="\ 42434977a2fSmrg s/$bs4/&\\ 42534977a2fSmrg/g 42634977a2fSmrg s/^$bs2$dollar/$bs&/ 42734977a2fSmrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 42834977a2fSmrg s/\n//g" 42934977a2fSmrg 43034977a2fSmrg# Standard options: 43134977a2fSmrgopt_dry_run=false 43234977a2fSmrgopt_help=false 43334977a2fSmrgopt_quiet=false 43434977a2fSmrgopt_verbose=false 43534977a2fSmrgopt_warning=: 43634977a2fSmrg 43734977a2fSmrg# func_echo arg... 43834977a2fSmrg# Echo program name prefixed message, along with the current mode 43934977a2fSmrg# name if it has been set yet. 44034977a2fSmrgfunc_echo () 44134977a2fSmrg{ 4423e72ca8cSmrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 44334977a2fSmrg} 44434977a2fSmrg 44534977a2fSmrg# func_verbose arg... 44634977a2fSmrg# Echo program name prefixed message in verbose mode only. 44734977a2fSmrgfunc_verbose () 44834977a2fSmrg{ 44934977a2fSmrg $opt_verbose && func_echo ${1+"$@"} 45034977a2fSmrg 45134977a2fSmrg # A bug in bash halts the script if the last line of a function 45234977a2fSmrg # fails when set -e is in force, so we need another command to 45334977a2fSmrg # work around that: 45434977a2fSmrg : 45534977a2fSmrg} 45634977a2fSmrg 457b425557eSmrg# func_echo_all arg... 458b425557eSmrg# Invoke $ECHO with all args, space-separated. 459b425557eSmrgfunc_echo_all () 460b425557eSmrg{ 461b425557eSmrg $ECHO "$*" 462b425557eSmrg} 463b425557eSmrg 46434977a2fSmrg# func_error arg... 46534977a2fSmrg# Echo program name prefixed message to standard error. 46634977a2fSmrgfunc_error () 46734977a2fSmrg{ 4683e72ca8cSmrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 46934977a2fSmrg} 47034977a2fSmrg 47134977a2fSmrg# func_warning arg... 47234977a2fSmrg# Echo program name prefixed warning message to standard error. 47334977a2fSmrgfunc_warning () 47434977a2fSmrg{ 4753e72ca8cSmrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 47634977a2fSmrg 47734977a2fSmrg # bash bug again: 47834977a2fSmrg : 47934977a2fSmrg} 48034977a2fSmrg 48134977a2fSmrg# func_fatal_error arg... 48234977a2fSmrg# Echo program name prefixed message to standard error, and exit. 48334977a2fSmrgfunc_fatal_error () 48434977a2fSmrg{ 48534977a2fSmrg func_error ${1+"$@"} 48634977a2fSmrg exit $EXIT_FAILURE 48734977a2fSmrg} 48834977a2fSmrg 48934977a2fSmrg# func_fatal_help arg... 49034977a2fSmrg# Echo program name prefixed message to standard error, followed by 49134977a2fSmrg# a help hint, and exit. 49234977a2fSmrgfunc_fatal_help () 49334977a2fSmrg{ 49434977a2fSmrg func_error ${1+"$@"} 49534977a2fSmrg func_fatal_error "$help" 49634977a2fSmrg} 49734977a2fSmrghelp="Try \`$progname --help' for more information." ## default 49834977a2fSmrg 49934977a2fSmrg 50034977a2fSmrg# func_grep expression filename 50134977a2fSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 50234977a2fSmrgfunc_grep () 50334977a2fSmrg{ 50434977a2fSmrg $GREP "$1" "$2" >/dev/null 2>&1 50534977a2fSmrg} 50634977a2fSmrg 50734977a2fSmrg 50834977a2fSmrg# func_mkdir_p directory-path 50934977a2fSmrg# Make sure the entire path to DIRECTORY-PATH is available. 51034977a2fSmrgfunc_mkdir_p () 51134977a2fSmrg{ 51234977a2fSmrg my_directory_path="$1" 51334977a2fSmrg my_dir_list= 51434977a2fSmrg 51534977a2fSmrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 51634977a2fSmrg 51734977a2fSmrg # Protect directory names starting with `-' 51834977a2fSmrg case $my_directory_path in 51934977a2fSmrg -*) my_directory_path="./$my_directory_path" ;; 52034977a2fSmrg esac 52134977a2fSmrg 52234977a2fSmrg # While some portion of DIR does not yet exist... 52334977a2fSmrg while test ! -d "$my_directory_path"; do 52434977a2fSmrg # ...make a list in topmost first order. Use a colon delimited 52534977a2fSmrg # list incase some portion of path contains whitespace. 52634977a2fSmrg my_dir_list="$my_directory_path:$my_dir_list" 52734977a2fSmrg 52834977a2fSmrg # If the last portion added has no slash in it, the list is done 52934977a2fSmrg case $my_directory_path in */*) ;; *) break ;; esac 53034977a2fSmrg 53134977a2fSmrg # ...otherwise throw away the child directory and loop 532b425557eSmrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 53334977a2fSmrg done 534b425557eSmrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 53534977a2fSmrg 53634977a2fSmrg save_mkdir_p_IFS="$IFS"; IFS=':' 53734977a2fSmrg for my_dir in $my_dir_list; do 53834977a2fSmrg IFS="$save_mkdir_p_IFS" 53934977a2fSmrg # mkdir can fail with a `File exist' error if two processes 54034977a2fSmrg # try to create one of the directories concurrently. Don't 54134977a2fSmrg # stop in that case! 54234977a2fSmrg $MKDIR "$my_dir" 2>/dev/null || : 54334977a2fSmrg done 54434977a2fSmrg IFS="$save_mkdir_p_IFS" 54534977a2fSmrg 54634977a2fSmrg # Bail out if we (or some other process) failed to create a directory. 54734977a2fSmrg test -d "$my_directory_path" || \ 54834977a2fSmrg func_fatal_error "Failed to create \`$1'" 54934977a2fSmrg fi 55034977a2fSmrg} 551ee3138f1Smrg 552ee3138f1Smrg 553ee3138f1Smrg# func_mktempdir [string] 554ee3138f1Smrg# Make a temporary directory that won't clash with other running 555ee3138f1Smrg# libtool processes, and avoids race conditions if possible. If 556ee3138f1Smrg# given, STRING is the basename for that directory. 557ee3138f1Smrgfunc_mktempdir () 558ee3138f1Smrg{ 559ee3138f1Smrg my_template="${TMPDIR-/tmp}/${1-$progname}" 560ee3138f1Smrg 56134977a2fSmrg if test "$opt_dry_run" = ":"; then 562ee3138f1Smrg # Return a directory name, but don't create it in dry-run mode 563ee3138f1Smrg my_tmpdir="${my_template}-$$" 564ee3138f1Smrg else 565ee3138f1Smrg 566ee3138f1Smrg # If mktemp works, use that first and foremost 567ee3138f1Smrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 568ee3138f1Smrg 569ee3138f1Smrg if test ! -d "$my_tmpdir"; then 57034977a2fSmrg # Failing that, at least try and use $RANDOM to avoid a race 57134977a2fSmrg my_tmpdir="${my_template}-${RANDOM-0}$$" 572ee3138f1Smrg 57334977a2fSmrg save_mktempdir_umask=`umask` 57434977a2fSmrg umask 0077 57534977a2fSmrg $MKDIR "$my_tmpdir" 57634977a2fSmrg umask $save_mktempdir_umask 577ee3138f1Smrg fi 578ee3138f1Smrg 579ee3138f1Smrg # If we're not in dry-run mode, bomb out on failure 58034977a2fSmrg test -d "$my_tmpdir" || \ 58134977a2fSmrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 582ee3138f1Smrg fi 583ee3138f1Smrg 584b425557eSmrg $ECHO "$my_tmpdir" 585ee3138f1Smrg} 586ee3138f1Smrg 587ee3138f1Smrg 58834977a2fSmrg# func_quote_for_eval arg 58934977a2fSmrg# Aesthetically quote ARG to be evaled later. 59034977a2fSmrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 59134977a2fSmrg# is double-quoted, suitable for a subsequent eval, whereas 59234977a2fSmrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 59334977a2fSmrg# which are still active within double quotes backslashified. 59434977a2fSmrgfunc_quote_for_eval () 595ee3138f1Smrg{ 59634977a2fSmrg case $1 in 59734977a2fSmrg *[\\\`\"\$]*) 598b425557eSmrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 59934977a2fSmrg *) 60034977a2fSmrg func_quote_for_eval_unquoted_result="$1" ;; 60134977a2fSmrg esac 60234977a2fSmrg 60334977a2fSmrg case $func_quote_for_eval_unquoted_result in 60434977a2fSmrg # Double-quote args containing shell metacharacters to delay 60534977a2fSmrg # word splitting, command substitution and and variable 60634977a2fSmrg # expansion for a subsequent eval. 60734977a2fSmrg # Many Bourne shells cannot handle close brackets correctly 60834977a2fSmrg # in scan sets, so we specify it separately. 60934977a2fSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 61034977a2fSmrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 61134977a2fSmrg ;; 61234977a2fSmrg *) 61334977a2fSmrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 614ee3138f1Smrg esac 615ee3138f1Smrg} 616ee3138f1Smrg 617ee3138f1Smrg 61834977a2fSmrg# func_quote_for_expand arg 61934977a2fSmrg# Aesthetically quote ARG to be evaled later; same as above, 62034977a2fSmrg# but do not quote variable references. 62134977a2fSmrgfunc_quote_for_expand () 622ee3138f1Smrg{ 62334977a2fSmrg case $1 in 62434977a2fSmrg *[\\\`\"]*) 625b425557eSmrg my_arg=`$ECHO "$1" | $SED \ 62634977a2fSmrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 627ee3138f1Smrg *) 62834977a2fSmrg my_arg="$1" ;; 62934977a2fSmrg esac 63034977a2fSmrg 63134977a2fSmrg case $my_arg in 63234977a2fSmrg # Double-quote args containing shell metacharacters to delay 63334977a2fSmrg # word splitting and command substitution for a subsequent eval. 63434977a2fSmrg # Many Bourne shells cannot handle close brackets correctly 63534977a2fSmrg # in scan sets, so we specify it separately. 63634977a2fSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 63734977a2fSmrg my_arg="\"$my_arg\"" 63834977a2fSmrg ;; 63934977a2fSmrg esac 64034977a2fSmrg 64134977a2fSmrg func_quote_for_expand_result="$my_arg" 642ee3138f1Smrg} 643ee3138f1Smrg 644ee3138f1Smrg 64534977a2fSmrg# func_show_eval cmd [fail_exp] 64634977a2fSmrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 64734977a2fSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 64834977a2fSmrg# is given, then evaluate it. 64934977a2fSmrgfunc_show_eval () 650ee3138f1Smrg{ 65134977a2fSmrg my_cmd="$1" 65234977a2fSmrg my_fail_exp="${2-:}" 653ee3138f1Smrg 65434977a2fSmrg ${opt_silent-false} || { 65534977a2fSmrg func_quote_for_expand "$my_cmd" 65634977a2fSmrg eval "func_echo $func_quote_for_expand_result" 65734977a2fSmrg } 65834977a2fSmrg 65934977a2fSmrg if ${opt_dry_run-false}; then :; else 66034977a2fSmrg eval "$my_cmd" 66134977a2fSmrg my_status=$? 66234977a2fSmrg if test "$my_status" -eq 0; then :; else 66334977a2fSmrg eval "(exit $my_status); $my_fail_exp" 66434977a2fSmrg fi 665ee3138f1Smrg fi 666ee3138f1Smrg} 667ee3138f1Smrg 66834977a2fSmrg 66934977a2fSmrg# func_show_eval_locale cmd [fail_exp] 67034977a2fSmrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 67134977a2fSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 67234977a2fSmrg# is given, then evaluate it. Use the saved locale for evaluation. 67334977a2fSmrgfunc_show_eval_locale () 674ee3138f1Smrg{ 67534977a2fSmrg my_cmd="$1" 67634977a2fSmrg my_fail_exp="${2-:}" 67734977a2fSmrg 67834977a2fSmrg ${opt_silent-false} || { 67934977a2fSmrg func_quote_for_expand "$my_cmd" 68034977a2fSmrg eval "func_echo $func_quote_for_expand_result" 68134977a2fSmrg } 68234977a2fSmrg 68334977a2fSmrg if ${opt_dry_run-false}; then :; else 68434977a2fSmrg eval "$lt_user_locale 68534977a2fSmrg $my_cmd" 68634977a2fSmrg my_status=$? 68734977a2fSmrg eval "$lt_safe_locale" 68834977a2fSmrg if test "$my_status" -eq 0; then :; else 68934977a2fSmrg eval "(exit $my_status); $my_fail_exp" 69034977a2fSmrg fi 691ee3138f1Smrg fi 69234977a2fSmrg} 693ee3138f1Smrg 6943e72ca8cSmrg# func_tr_sh 6953e72ca8cSmrg# Turn $1 into a string suitable for a shell variable name. 6963e72ca8cSmrg# Result is stored in $func_tr_sh_result. All characters 6973e72ca8cSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 6983e72ca8cSmrg# if $1 begins with a digit, a '_' is prepended as well. 6993e72ca8cSmrgfunc_tr_sh () 7003e72ca8cSmrg{ 7013e72ca8cSmrg case $1 in 7023e72ca8cSmrg [0-9]* | *[!a-zA-Z0-9_]*) 7033e72ca8cSmrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 7043e72ca8cSmrg ;; 7053e72ca8cSmrg * ) 7063e72ca8cSmrg func_tr_sh_result=$1 7073e72ca8cSmrg ;; 7083e72ca8cSmrg esac 7093e72ca8cSmrg} 7103e72ca8cSmrg 711ee3138f1Smrg 71234977a2fSmrg# func_version 71334977a2fSmrg# Echo version message to standard output and exit. 71434977a2fSmrgfunc_version () 71534977a2fSmrg{ 7163e72ca8cSmrg $opt_debug 7173e72ca8cSmrg 718b425557eSmrg $SED -n '/(C)/!b go 719b425557eSmrg :more 720b425557eSmrg /\./!{ 721b425557eSmrg N 722b425557eSmrg s/\n# / / 723b425557eSmrg b more 724b425557eSmrg } 725b425557eSmrg :go 726b425557eSmrg /^# '$PROGRAM' (GNU /,/# warranty; / { 72734977a2fSmrg s/^# // 72834977a2fSmrg s/^# *$// 72934977a2fSmrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 73034977a2fSmrg p 73134977a2fSmrg }' < "$progpath" 73234977a2fSmrg exit $? 733ee3138f1Smrg} 734ee3138f1Smrg 73534977a2fSmrg# func_usage 73634977a2fSmrg# Echo short help message to standard output and exit. 73734977a2fSmrgfunc_usage () 73834977a2fSmrg{ 7393e72ca8cSmrg $opt_debug 7403e72ca8cSmrg 741b425557eSmrg $SED -n '/^# Usage:/,/^# *.*--help/ { 74234977a2fSmrg s/^# // 74334977a2fSmrg s/^# *$// 74434977a2fSmrg s/\$progname/'$progname'/ 74534977a2fSmrg p 74634977a2fSmrg }' < "$progpath" 747b425557eSmrg echo 74834977a2fSmrg $ECHO "run \`$progname --help | more' for full usage" 74934977a2fSmrg exit $? 75034977a2fSmrg} 751ee3138f1Smrg 752b425557eSmrg# func_help [NOEXIT] 753b425557eSmrg# Echo long help message to standard output and exit, 754b425557eSmrg# unless 'noexit' is passed as argument. 75534977a2fSmrgfunc_help () 75634977a2fSmrg{ 7573e72ca8cSmrg $opt_debug 7583e72ca8cSmrg 75934977a2fSmrg $SED -n '/^# Usage:/,/# Report bugs to/ { 7603e72ca8cSmrg :print 76134977a2fSmrg s/^# // 76234977a2fSmrg s/^# *$// 76334977a2fSmrg s*\$progname*'$progname'* 76434977a2fSmrg s*\$host*'"$host"'* 76534977a2fSmrg s*\$SHELL*'"$SHELL"'* 76634977a2fSmrg s*\$LTCC*'"$LTCC"'* 76734977a2fSmrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 76834977a2fSmrg s*\$LD*'"$LD"'* 76934977a2fSmrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 7703e72ca8cSmrg s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ 7713e72ca8cSmrg s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ 77234977a2fSmrg p 7733e72ca8cSmrg d 7743e72ca8cSmrg } 7753e72ca8cSmrg /^# .* home page:/b print 7763e72ca8cSmrg /^# General help using/b print 7773e72ca8cSmrg ' < "$progpath" 778b425557eSmrg ret=$? 779b425557eSmrg if test -z "$1"; then 780b425557eSmrg exit $ret 781b425557eSmrg fi 78234977a2fSmrg} 783ee3138f1Smrg 78434977a2fSmrg# func_missing_arg argname 78534977a2fSmrg# Echo program name prefixed message to standard error and set global 78634977a2fSmrg# exit_cmd. 78734977a2fSmrgfunc_missing_arg () 78834977a2fSmrg{ 7893e72ca8cSmrg $opt_debug 7903e72ca8cSmrg 791b425557eSmrg func_error "missing argument for $1." 79234977a2fSmrg exit_cmd=exit 79334977a2fSmrg} 79434977a2fSmrg 79534977a2fSmrg 7963e72ca8cSmrg# func_split_short_opt shortopt 7973e72ca8cSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 7983e72ca8cSmrg# variables after splitting SHORTOPT after the 2nd character. 7993e72ca8cSmrgfunc_split_short_opt () 8003e72ca8cSmrg{ 8013e72ca8cSmrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 8023e72ca8cSmrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 8033e72ca8cSmrg 8043e72ca8cSmrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 8053e72ca8cSmrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 8063e72ca8cSmrg} # func_split_short_opt may be replaced by extended shell implementation 8073e72ca8cSmrg 8083e72ca8cSmrg 8093e72ca8cSmrg# func_split_long_opt longopt 8103e72ca8cSmrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 8113e72ca8cSmrg# variables after splitting LONGOPT at the `=' sign. 8123e72ca8cSmrgfunc_split_long_opt () 8133e72ca8cSmrg{ 8143e72ca8cSmrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 8153e72ca8cSmrg my_sed_long_arg='1s/^--[^=]*=//' 8163e72ca8cSmrg 8173e72ca8cSmrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 8183e72ca8cSmrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 8193e72ca8cSmrg} # func_split_long_opt may be replaced by extended shell implementation 8203e72ca8cSmrg 8213e72ca8cSmrgexit_cmd=: 82234977a2fSmrg 82334977a2fSmrg 82434977a2fSmrg 82534977a2fSmrg 826ee3138f1Smrg 82734977a2fSmrgmagic="%%%MAGIC variable%%%" 82834977a2fSmrgmagic_exe="%%%MAGIC EXE variable%%%" 829ee3138f1Smrg 83034977a2fSmrg# Global variables. 83134977a2fSmrgnonopt= 83234977a2fSmrgpreserve_args= 83334977a2fSmrglo2o="s/\\.lo\$/.${objext}/" 83434977a2fSmrgo2lo="s/\\.${objext}\$/.lo/" 83534977a2fSmrgextracted_archives= 83634977a2fSmrgextracted_serial=0 837ee3138f1Smrg 83834977a2fSmrg# If this variable is set in any of the actions, the command in it 83934977a2fSmrg# will be execed at the end. This prevents here-documents from being 84034977a2fSmrg# left over by shells. 84134977a2fSmrgexec_cmd= 84234977a2fSmrg 8433e72ca8cSmrg# func_append var value 8443e72ca8cSmrg# Append VALUE to the end of shell variable VAR. 8453e72ca8cSmrgfunc_append () 8463e72ca8cSmrg{ 8473e72ca8cSmrg eval "${1}=\$${1}\${2}" 8483e72ca8cSmrg} # func_append may be replaced by extended shell implementation 8493e72ca8cSmrg 8503e72ca8cSmrg# func_append_quoted var value 8513e72ca8cSmrg# Quote VALUE and append to the end of shell variable VAR, separated 8523e72ca8cSmrg# by a space. 8533e72ca8cSmrgfunc_append_quoted () 8543e72ca8cSmrg{ 8553e72ca8cSmrg func_quote_for_eval "${2}" 8563e72ca8cSmrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 8573e72ca8cSmrg} # func_append_quoted may be replaced by extended shell implementation 8583e72ca8cSmrg 8593e72ca8cSmrg 8603e72ca8cSmrg# func_arith arithmetic-term... 8613e72ca8cSmrgfunc_arith () 8623e72ca8cSmrg{ 8633e72ca8cSmrg func_arith_result=`expr "${@}"` 8643e72ca8cSmrg} # func_arith may be replaced by extended shell implementation 8653e72ca8cSmrg 8663e72ca8cSmrg 8673e72ca8cSmrg# func_len string 8683e72ca8cSmrg# STRING may not start with a hyphen. 8693e72ca8cSmrgfunc_len () 8703e72ca8cSmrg{ 8713e72ca8cSmrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 8723e72ca8cSmrg} # func_len may be replaced by extended shell implementation 8733e72ca8cSmrg 8743e72ca8cSmrg 8753e72ca8cSmrg# func_lo2o object 8763e72ca8cSmrgfunc_lo2o () 8773e72ca8cSmrg{ 8783e72ca8cSmrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 8793e72ca8cSmrg} # func_lo2o may be replaced by extended shell implementation 8803e72ca8cSmrg 8813e72ca8cSmrg 8823e72ca8cSmrg# func_xform libobj-or-source 8833e72ca8cSmrgfunc_xform () 8843e72ca8cSmrg{ 8853e72ca8cSmrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 8863e72ca8cSmrg} # func_xform may be replaced by extended shell implementation 8873e72ca8cSmrg 8883e72ca8cSmrg 88934977a2fSmrg# func_fatal_configuration arg... 89034977a2fSmrg# Echo program name prefixed message to standard error, followed by 89134977a2fSmrg# a configuration failure hint, and exit. 89234977a2fSmrgfunc_fatal_configuration () 89334977a2fSmrg{ 89434977a2fSmrg func_error ${1+"$@"} 89534977a2fSmrg func_error "See the $PACKAGE documentation for more information." 89634977a2fSmrg func_fatal_error "Fatal configuration error." 89734977a2fSmrg} 898ee3138f1Smrg 899ee3138f1Smrg 90034977a2fSmrg# func_config 90134977a2fSmrg# Display the configuration for all the tags in this script. 90234977a2fSmrgfunc_config () 90334977a2fSmrg{ 90434977a2fSmrg re_begincf='^# ### BEGIN LIBTOOL' 90534977a2fSmrg re_endcf='^# ### END LIBTOOL' 90634977a2fSmrg 90734977a2fSmrg # Default configuration. 90834977a2fSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 909ee3138f1Smrg 910ee3138f1Smrg # Now print the configurations for the tags. 911ee3138f1Smrg for tagname in $taglist; do 91234977a2fSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 913ee3138f1Smrg done 914ee3138f1Smrg 91534977a2fSmrg exit $? 91634977a2fSmrg} 917ee3138f1Smrg 91834977a2fSmrg# func_features 91934977a2fSmrg# Display the features supported by this script. 92034977a2fSmrgfunc_features () 92134977a2fSmrg{ 922b425557eSmrg echo "host: $host" 923ee3138f1Smrg if test "$build_libtool_libs" = yes; then 924b425557eSmrg echo "enable shared libraries" 925ee3138f1Smrg else 926b425557eSmrg echo "disable shared libraries" 927ee3138f1Smrg fi 928ee3138f1Smrg if test "$build_old_libs" = yes; then 929b425557eSmrg echo "enable static libraries" 930ee3138f1Smrg else 931b425557eSmrg echo "disable static libraries" 932ee3138f1Smrg fi 93334977a2fSmrg 934ee3138f1Smrg exit $? 93534977a2fSmrg} 936ee3138f1Smrg 93734977a2fSmrg# func_enable_tag tagname 93834977a2fSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 93934977a2fSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 94034977a2fSmrg# variable here. 94134977a2fSmrgfunc_enable_tag () 94234977a2fSmrg{ 94334977a2fSmrg # Global variable: 94434977a2fSmrg tagname="$1" 945ee3138f1Smrg 94634977a2fSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 94734977a2fSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 94834977a2fSmrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 949ee3138f1Smrg 95034977a2fSmrg # Validate tagname. 95134977a2fSmrg case $tagname in 95234977a2fSmrg *[!-_A-Za-z0-9,/]*) 95334977a2fSmrg func_fatal_error "invalid tag name: $tagname" 95434977a2fSmrg ;; 95534977a2fSmrg esac 956ee3138f1Smrg 95734977a2fSmrg # Don't test for the "default" C tag, as we know it's 95834977a2fSmrg # there but not specially marked. 95934977a2fSmrg case $tagname in 96034977a2fSmrg CC) ;; 96134977a2fSmrg *) 96234977a2fSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 96334977a2fSmrg taglist="$taglist $tagname" 96434977a2fSmrg 96534977a2fSmrg # Evaluate the configuration. Be careful to quote the path 96634977a2fSmrg # and the sed script, to avoid splitting on whitespace, but 96734977a2fSmrg # also don't use non-portable quotes within backquotes within 96834977a2fSmrg # quotes we have to do it in 2 steps: 96934977a2fSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 97034977a2fSmrg eval "$extractedcf" 97134977a2fSmrg else 97234977a2fSmrg func_error "ignoring unknown tag $tagname" 97334977a2fSmrg fi 97434977a2fSmrg ;; 97534977a2fSmrg esac 97634977a2fSmrg} 97734977a2fSmrg 9783e72ca8cSmrg# func_check_version_match 9793e72ca8cSmrg# Ensure that we are using m4 macros, and libtool script from the same 9803e72ca8cSmrg# release of libtool. 9813e72ca8cSmrgfunc_check_version_match () 98234977a2fSmrg{ 9833e72ca8cSmrg if test "$package_revision" != "$macro_revision"; then 9843e72ca8cSmrg if test "$VERSION" != "$macro_version"; then 9853e72ca8cSmrg if test -z "$macro_version"; then 9863e72ca8cSmrg cat >&2 <<_LT_EOF 9873e72ca8cSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 9883e72ca8cSmrg$progname: definition of this LT_INIT comes from an older release. 9893e72ca8cSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 9903e72ca8cSmrg$progname: and run autoconf again. 9913e72ca8cSmrg_LT_EOF 9923e72ca8cSmrg else 9933e72ca8cSmrg cat >&2 <<_LT_EOF 9943e72ca8cSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 9953e72ca8cSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 9963e72ca8cSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 9973e72ca8cSmrg$progname: and run autoconf again. 9983e72ca8cSmrg_LT_EOF 9993e72ca8cSmrg fi 10003e72ca8cSmrg else 10013e72ca8cSmrg cat >&2 <<_LT_EOF 10023e72ca8cSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 10033e72ca8cSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 10043e72ca8cSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 10053e72ca8cSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 10063e72ca8cSmrg_LT_EOF 10073e72ca8cSmrg fi 10083e72ca8cSmrg 10093e72ca8cSmrg exit $EXIT_MISMATCH 10103e72ca8cSmrg fi 10113e72ca8cSmrg} 10123e72ca8cSmrg 10133e72ca8cSmrg 10143e72ca8cSmrg# Shorthand for --mode=foo, only valid as the first argument 10153e72ca8cSmrgcase $1 in 10163e72ca8cSmrgclean|clea|cle|cl) 10173e72ca8cSmrg shift; set dummy --mode clean ${1+"$@"}; shift 10183e72ca8cSmrg ;; 10193e72ca8cSmrgcompile|compil|compi|comp|com|co|c) 10203e72ca8cSmrg shift; set dummy --mode compile ${1+"$@"}; shift 10213e72ca8cSmrg ;; 10223e72ca8cSmrgexecute|execut|execu|exec|exe|ex|e) 10233e72ca8cSmrg shift; set dummy --mode execute ${1+"$@"}; shift 10243e72ca8cSmrg ;; 10253e72ca8cSmrgfinish|finis|fini|fin|fi|f) 10263e72ca8cSmrg shift; set dummy --mode finish ${1+"$@"}; shift 10273e72ca8cSmrg ;; 10283e72ca8cSmrginstall|instal|insta|inst|ins|in|i) 10293e72ca8cSmrg shift; set dummy --mode install ${1+"$@"}; shift 10303e72ca8cSmrg ;; 10313e72ca8cSmrglink|lin|li|l) 10323e72ca8cSmrg shift; set dummy --mode link ${1+"$@"}; shift 10333e72ca8cSmrg ;; 10343e72ca8cSmrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 10353e72ca8cSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 10363e72ca8cSmrg ;; 10373e72ca8cSmrgesac 10383e72ca8cSmrg 10393e72ca8cSmrg 10403e72ca8cSmrg 10413e72ca8cSmrg# Option defaults: 10423e72ca8cSmrgopt_debug=: 10433e72ca8cSmrgopt_dry_run=false 10443e72ca8cSmrgopt_config=false 10453e72ca8cSmrgopt_preserve_dup_deps=false 10463e72ca8cSmrgopt_features=false 10473e72ca8cSmrgopt_finish=false 10483e72ca8cSmrgopt_help=false 10493e72ca8cSmrgopt_help_all=false 10503e72ca8cSmrgopt_silent=: 10513e72ca8cSmrgopt_warning=: 10523e72ca8cSmrgopt_verbose=: 10533e72ca8cSmrgopt_silent=false 10543e72ca8cSmrgopt_verbose=false 1055ee3138f1Smrg 1056ee3138f1Smrg 10573e72ca8cSmrg# Parse options once, thoroughly. This comes as soon as possible in the 10583e72ca8cSmrg# script to make things like `--version' happen as quickly as we can. 10593e72ca8cSmrg{ 10603e72ca8cSmrg # this just eases exit handling 10613e72ca8cSmrg while test $# -gt 0; do 106234977a2fSmrg opt="$1" 106334977a2fSmrg shift 106434977a2fSmrg case $opt in 10653e72ca8cSmrg --debug|-x) opt_debug='set -x' 106634977a2fSmrg func_echo "enabling shell trace mode" 106734977a2fSmrg $opt_debug 106834977a2fSmrg ;; 10693e72ca8cSmrg --dry-run|--dryrun|-n) 10703e72ca8cSmrg opt_dry_run=: 107134977a2fSmrg ;; 10723e72ca8cSmrg --config) 10733e72ca8cSmrg opt_config=: 10743e72ca8cSmrgfunc_config 10753e72ca8cSmrg ;; 10763e72ca8cSmrg --dlopen|-dlopen) 10773e72ca8cSmrg optarg="$1" 10783e72ca8cSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 10793e72ca8cSmrg}$optarg" 108034977a2fSmrg shift 108134977a2fSmrg ;; 108234977a2fSmrg --preserve-dup-deps) 10833e72ca8cSmrg opt_preserve_dup_deps=: 1084b425557eSmrg ;; 10853e72ca8cSmrg --features) 10863e72ca8cSmrg opt_features=: 10873e72ca8cSmrgfunc_features 108834977a2fSmrg ;; 10893e72ca8cSmrg --finish) 10903e72ca8cSmrg opt_finish=: 10913e72ca8cSmrgset dummy --mode finish ${1+"$@"}; shift 10923e72ca8cSmrg ;; 10933e72ca8cSmrg --help) 10943e72ca8cSmrg opt_help=: 10953e72ca8cSmrg ;; 10963e72ca8cSmrg --help-all) 10973e72ca8cSmrg opt_help_all=: 10983e72ca8cSmrgopt_help=': help-all' 10993e72ca8cSmrg ;; 11003e72ca8cSmrg --mode) 11013e72ca8cSmrg test $# = 0 && func_missing_arg $opt && break 11023e72ca8cSmrg optarg="$1" 11033e72ca8cSmrg opt_mode="$optarg" 11043e72ca8cSmrgcase $optarg in 11053e72ca8cSmrg # Valid mode arguments: 11063e72ca8cSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 11073e72ca8cSmrg 11083e72ca8cSmrg # Catch anything else as an error 11093e72ca8cSmrg *) func_error "invalid argument for $opt" 11103e72ca8cSmrg exit_cmd=exit 11113e72ca8cSmrg break 11123e72ca8cSmrg ;; 11133e72ca8cSmrgesac 11143e72ca8cSmrg shift 11153e72ca8cSmrg ;; 11163e72ca8cSmrg --no-silent|--no-quiet) 111734977a2fSmrg opt_silent=false 11183e72ca8cSmrgfunc_append preserve_args " $opt" 1119b425557eSmrg ;; 11203e72ca8cSmrg --no-warning|--no-warn) 11213e72ca8cSmrg opt_warning=false 11223e72ca8cSmrgfunc_append preserve_args " $opt" 11233e72ca8cSmrg ;; 11243e72ca8cSmrg --no-verbose) 1125b425557eSmrg opt_verbose=false 11263e72ca8cSmrgfunc_append preserve_args " $opt" 112734977a2fSmrg ;; 11283e72ca8cSmrg --silent|--quiet) 11293e72ca8cSmrg opt_silent=: 11303e72ca8cSmrgfunc_append preserve_args " $opt" 11313e72ca8cSmrg opt_verbose=false 11323e72ca8cSmrg ;; 11333e72ca8cSmrg --verbose|-v) 11343e72ca8cSmrg opt_verbose=: 11353e72ca8cSmrgfunc_append preserve_args " $opt" 11363e72ca8cSmrgopt_silent=false 11373e72ca8cSmrg ;; 11383e72ca8cSmrg --tag) 11393e72ca8cSmrg test $# = 0 && func_missing_arg $opt && break 11403e72ca8cSmrg optarg="$1" 11413e72ca8cSmrg opt_tag="$optarg" 11423e72ca8cSmrgfunc_append preserve_args " $opt $optarg" 11433e72ca8cSmrgfunc_enable_tag "$optarg" 114434977a2fSmrg shift 114534977a2fSmrg ;; 114634977a2fSmrg 11473e72ca8cSmrg -\?|-h) func_usage ;; 11483e72ca8cSmrg --help) func_help ;; 11493e72ca8cSmrg --version) func_version ;; 11503e72ca8cSmrg 115134977a2fSmrg # Separate optargs to long options: 11523e72ca8cSmrg --*=*) 11533e72ca8cSmrg func_split_long_opt "$opt" 11543e72ca8cSmrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 115534977a2fSmrg shift 115634977a2fSmrg ;; 115734977a2fSmrg 11583e72ca8cSmrg # Separate non-argument short options: 11593e72ca8cSmrg -\?*|-h*|-n*|-v*) 11603e72ca8cSmrg func_split_short_opt "$opt" 11613e72ca8cSmrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 11623e72ca8cSmrg shift 116334977a2fSmrg ;; 11643e72ca8cSmrg 11653e72ca8cSmrg --) break ;; 11663e72ca8cSmrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 11673e72ca8cSmrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 116834977a2fSmrg esac 116934977a2fSmrg done 117034977a2fSmrg 11713e72ca8cSmrg # Validate options: 11723e72ca8cSmrg 11733e72ca8cSmrg # save first non-option argument 11743e72ca8cSmrg if test "$#" -gt 0; then 11753e72ca8cSmrg nonopt="$opt" 11763e72ca8cSmrg shift 11773e72ca8cSmrg fi 11783e72ca8cSmrg 11793e72ca8cSmrg # preserve --debug 11803e72ca8cSmrg test "$opt_debug" = : || func_append preserve_args " --debug" 118134977a2fSmrg 118234977a2fSmrg case $host in 118334977a2fSmrg *cygwin* | *mingw* | *pw32* | *cegcc*) 118434977a2fSmrg # don't eliminate duplications in $postdeps and $predeps 118534977a2fSmrg opt_duplicate_compiler_generated_deps=: 1186ee3138f1Smrg ;; 1187ee3138f1Smrg *) 11883e72ca8cSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 118934977a2fSmrg ;; 119034977a2fSmrg esac 1191ee3138f1Smrg 11923e72ca8cSmrg $opt_help || { 11933e72ca8cSmrg # Sanity checks first: 11943e72ca8cSmrg func_check_version_match 119534977a2fSmrg 11963e72ca8cSmrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 11973e72ca8cSmrg func_fatal_configuration "not configured to build any kind of library" 119834977a2fSmrg fi 119934977a2fSmrg 12003e72ca8cSmrg # Darwin sucks 12013e72ca8cSmrg eval std_shrext=\"$shrext_cmds\" 120234977a2fSmrg 12033e72ca8cSmrg # Only execute mode is allowed to have -dlopen flags. 12043e72ca8cSmrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 12053e72ca8cSmrg func_error "unrecognized option \`-dlopen'" 12063e72ca8cSmrg $ECHO "$help" 1>&2 12073e72ca8cSmrg exit $EXIT_FAILURE 12083e72ca8cSmrg fi 120934977a2fSmrg 12103e72ca8cSmrg # Change the help message to a mode-specific one. 12113e72ca8cSmrg generic_help="$help" 12123e72ca8cSmrg help="Try \`$progname --help --mode=$opt_mode' for more information." 12133e72ca8cSmrg } 121434977a2fSmrg 121534977a2fSmrg 12163e72ca8cSmrg # Bail if the options were screwed 12173e72ca8cSmrg $exit_cmd $EXIT_FAILURE 12183e72ca8cSmrg} 121934977a2fSmrg 1220ee3138f1Smrg 1221ee3138f1Smrg 1222ee3138f1Smrg 12233e72ca8cSmrg## ----------- ## 12243e72ca8cSmrg## Main. ## 12253e72ca8cSmrg## ----------- ## 1226ee3138f1Smrg 122734977a2fSmrg# func_lalib_p file 122834977a2fSmrg# True iff FILE is a libtool `.la' library or `.lo' object file. 122934977a2fSmrg# This function is only a basic sanity check; it will hardly flush out 123034977a2fSmrg# determined imposters. 123134977a2fSmrgfunc_lalib_p () 123234977a2fSmrg{ 123334977a2fSmrg test -f "$1" && 123434977a2fSmrg $SED -e 4q "$1" 2>/dev/null \ 123534977a2fSmrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 123634977a2fSmrg} 1237ee3138f1Smrg 123834977a2fSmrg# func_lalib_unsafe_p file 123934977a2fSmrg# True iff FILE is a libtool `.la' library or `.lo' object file. 124034977a2fSmrg# This function implements the same check as func_lalib_p without 124134977a2fSmrg# resorting to external programs. To this end, it redirects stdin and 124234977a2fSmrg# closes it afterwards, without saving the original file descriptor. 124334977a2fSmrg# As a safety measure, use it only where a negative result would be 124434977a2fSmrg# fatal anyway. Works if `file' does not exist. 124534977a2fSmrgfunc_lalib_unsafe_p () 124634977a2fSmrg{ 124734977a2fSmrg lalib_p=no 124834977a2fSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 124934977a2fSmrg for lalib_p_l in 1 2 3 4 125034977a2fSmrg do 125134977a2fSmrg read lalib_p_line 125234977a2fSmrg case "$lalib_p_line" in 125334977a2fSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 125434977a2fSmrg esac 125534977a2fSmrg done 125634977a2fSmrg exec 0<&5 5<&- 125734977a2fSmrg fi 125834977a2fSmrg test "$lalib_p" = yes 125934977a2fSmrg} 1260ee3138f1Smrg 126134977a2fSmrg# func_ltwrapper_script_p file 126234977a2fSmrg# True iff FILE is a libtool wrapper script 126334977a2fSmrg# This function is only a basic sanity check; it will hardly flush out 126434977a2fSmrg# determined imposters. 126534977a2fSmrgfunc_ltwrapper_script_p () 126634977a2fSmrg{ 126734977a2fSmrg func_lalib_p "$1" 126834977a2fSmrg} 1269ee3138f1Smrg 127034977a2fSmrg# func_ltwrapper_executable_p file 127134977a2fSmrg# True iff FILE is a libtool wrapper executable 127234977a2fSmrg# This function is only a basic sanity check; it will hardly flush out 127334977a2fSmrg# determined imposters. 127434977a2fSmrgfunc_ltwrapper_executable_p () 127534977a2fSmrg{ 127634977a2fSmrg func_ltwrapper_exec_suffix= 127734977a2fSmrg case $1 in 127834977a2fSmrg *.exe) ;; 127934977a2fSmrg *) func_ltwrapper_exec_suffix=.exe ;; 128034977a2fSmrg esac 128134977a2fSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 128234977a2fSmrg} 128334977a2fSmrg 128434977a2fSmrg# func_ltwrapper_scriptname file 128534977a2fSmrg# Assumes file is an ltwrapper_executable 128634977a2fSmrg# uses $file to determine the appropriate filename for a 128734977a2fSmrg# temporary ltwrapper_script. 128834977a2fSmrgfunc_ltwrapper_scriptname () 128934977a2fSmrg{ 12903e72ca8cSmrg func_dirname_and_basename "$1" "" "." 12913e72ca8cSmrg func_stripname '' '.exe' "$func_basename_result" 12923e72ca8cSmrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 129334977a2fSmrg} 129434977a2fSmrg 129534977a2fSmrg# func_ltwrapper_p file 129634977a2fSmrg# True iff FILE is a libtool wrapper script or wrapper executable 129734977a2fSmrg# This function is only a basic sanity check; it will hardly flush out 129834977a2fSmrg# determined imposters. 129934977a2fSmrgfunc_ltwrapper_p () 130034977a2fSmrg{ 130134977a2fSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 130234977a2fSmrg} 130334977a2fSmrg 130434977a2fSmrg 130534977a2fSmrg# func_execute_cmds commands fail_cmd 130634977a2fSmrg# Execute tilde-delimited COMMANDS. 130734977a2fSmrg# If FAIL_CMD is given, eval that upon failure. 130834977a2fSmrg# FAIL_CMD may read-access the current command in variable CMD! 130934977a2fSmrgfunc_execute_cmds () 131034977a2fSmrg{ 131134977a2fSmrg $opt_debug 131234977a2fSmrg save_ifs=$IFS; IFS='~' 131334977a2fSmrg for cmd in $1; do 131434977a2fSmrg IFS=$save_ifs 131534977a2fSmrg eval cmd=\"$cmd\" 131634977a2fSmrg func_show_eval "$cmd" "${2-:}" 131734977a2fSmrg done 131834977a2fSmrg IFS=$save_ifs 131934977a2fSmrg} 132034977a2fSmrg 132134977a2fSmrg 132234977a2fSmrg# func_source file 132334977a2fSmrg# Source FILE, adding directory component if necessary. 132434977a2fSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 132534977a2fSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 132634977a2fSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 132734977a2fSmrg# `FILE.' does not work on cygwin managed mounts. 132834977a2fSmrgfunc_source () 132934977a2fSmrg{ 133034977a2fSmrg $opt_debug 133134977a2fSmrg case $1 in 133234977a2fSmrg */* | *\\*) . "$1" ;; 133334977a2fSmrg *) . "./$1" ;; 133434977a2fSmrg esac 133534977a2fSmrg} 133634977a2fSmrg 133734977a2fSmrg 13383e72ca8cSmrg# func_resolve_sysroot PATH 13393e72ca8cSmrg# Replace a leading = in PATH with a sysroot. Store the result into 13403e72ca8cSmrg# func_resolve_sysroot_result 13413e72ca8cSmrgfunc_resolve_sysroot () 13423e72ca8cSmrg{ 13433e72ca8cSmrg func_resolve_sysroot_result=$1 13443e72ca8cSmrg case $func_resolve_sysroot_result in 13453e72ca8cSmrg =*) 13463e72ca8cSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 13473e72ca8cSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 13483e72ca8cSmrg ;; 13493e72ca8cSmrg esac 13503e72ca8cSmrg} 13513e72ca8cSmrg 13523e72ca8cSmrg# func_replace_sysroot PATH 13533e72ca8cSmrg# If PATH begins with the sysroot, replace it with = and 13543e72ca8cSmrg# store the result into func_replace_sysroot_result. 13553e72ca8cSmrgfunc_replace_sysroot () 13563e72ca8cSmrg{ 13573e72ca8cSmrg case "$lt_sysroot:$1" in 13583e72ca8cSmrg ?*:"$lt_sysroot"*) 13593e72ca8cSmrg func_stripname "$lt_sysroot" '' "$1" 13603e72ca8cSmrg func_replace_sysroot_result="=$func_stripname_result" 13613e72ca8cSmrg ;; 13623e72ca8cSmrg *) 13633e72ca8cSmrg # Including no sysroot. 13643e72ca8cSmrg func_replace_sysroot_result=$1 13653e72ca8cSmrg ;; 13663e72ca8cSmrg esac 13673e72ca8cSmrg} 13683e72ca8cSmrg 136934977a2fSmrg# func_infer_tag arg 137034977a2fSmrg# Infer tagged configuration to use if any are available and 137134977a2fSmrg# if one wasn't chosen via the "--tag" command line option. 137234977a2fSmrg# Only attempt this if the compiler in the base compile 137334977a2fSmrg# command doesn't match the default compiler. 137434977a2fSmrg# arg is usually of the form 'gcc ...' 137534977a2fSmrgfunc_infer_tag () 137634977a2fSmrg{ 137734977a2fSmrg $opt_debug 137834977a2fSmrg if test -n "$available_tags" && test -z "$tagname"; then 137934977a2fSmrg CC_quoted= 138034977a2fSmrg for arg in $CC; do 13813e72ca8cSmrg func_append_quoted CC_quoted "$arg" 138234977a2fSmrg done 1383b425557eSmrg CC_expanded=`func_echo_all $CC` 1384b425557eSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 138534977a2fSmrg case $@ in 138634977a2fSmrg # Blanks in the command may have been stripped by the calling shell, 138734977a2fSmrg # but not from the CC environment variable when configure was run. 1388b425557eSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1389b425557eSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 139034977a2fSmrg # Blanks at the start of $base_compile will cause this to fail 139134977a2fSmrg # if we don't check for them as well. 139234977a2fSmrg *) 139334977a2fSmrg for z in $available_tags; do 139434977a2fSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 139534977a2fSmrg # Evaluate the configuration. 139634977a2fSmrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 139734977a2fSmrg CC_quoted= 139834977a2fSmrg for arg in $CC; do 139934977a2fSmrg # Double-quote args containing other shell metacharacters. 14003e72ca8cSmrg func_append_quoted CC_quoted "$arg" 140134977a2fSmrg done 1402b425557eSmrg CC_expanded=`func_echo_all $CC` 1403b425557eSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 140434977a2fSmrg case "$@ " in 1405b425557eSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1406b425557eSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 140734977a2fSmrg # The compiler in the base compile command matches 140834977a2fSmrg # the one in the tagged configuration. 140934977a2fSmrg # Assume this is the tagged configuration we want. 141034977a2fSmrg tagname=$z 141134977a2fSmrg break 141234977a2fSmrg ;; 141334977a2fSmrg esac 141434977a2fSmrg fi 141534977a2fSmrg done 141634977a2fSmrg # If $tagname still isn't set, then no tagged configuration 141734977a2fSmrg # was found and let the user know that the "--tag" command 141834977a2fSmrg # line option must be used. 141934977a2fSmrg if test -z "$tagname"; then 142034977a2fSmrg func_echo "unable to infer tagged configuration" 142134977a2fSmrg func_fatal_error "specify a tag with \`--tag'" 142234977a2fSmrg# else 142334977a2fSmrg# func_verbose "using $tagname tagged configuration" 142434977a2fSmrg fi 142534977a2fSmrg ;; 142634977a2fSmrg esac 142734977a2fSmrg fi 142834977a2fSmrg} 142934977a2fSmrg 143034977a2fSmrg 14313e72ca8cSmrg 14323e72ca8cSmrg# func_write_libtool_object output_name pic_name nonpic_name 14333e72ca8cSmrg# Create a libtool object file (analogous to a ".la" file), 14343e72ca8cSmrg# but don't create it if we're doing a dry run. 14353e72ca8cSmrgfunc_write_libtool_object () 14363e72ca8cSmrg{ 14373e72ca8cSmrg write_libobj=${1} 14383e72ca8cSmrg if test "$build_libtool_libs" = yes; then 14393e72ca8cSmrg write_lobj=\'${2}\' 14403e72ca8cSmrg else 14413e72ca8cSmrg write_lobj=none 14423e72ca8cSmrg fi 14433e72ca8cSmrg 14443e72ca8cSmrg if test "$build_old_libs" = yes; then 14453e72ca8cSmrg write_oldobj=\'${3}\' 14463e72ca8cSmrg else 14473e72ca8cSmrg write_oldobj=none 14483e72ca8cSmrg fi 14493e72ca8cSmrg 14503e72ca8cSmrg $opt_dry_run || { 14513e72ca8cSmrg cat >${write_libobj}T <<EOF 14523e72ca8cSmrg# $write_libobj - a libtool object file 14533e72ca8cSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 14543e72ca8cSmrg# 14553e72ca8cSmrg# Please DO NOT delete this file! 14563e72ca8cSmrg# It is necessary for linking the library. 14573e72ca8cSmrg 14583e72ca8cSmrg# Name of the PIC object. 14593e72ca8cSmrgpic_object=$write_lobj 14603e72ca8cSmrg 14613e72ca8cSmrg# Name of the non-PIC object 14623e72ca8cSmrgnon_pic_object=$write_oldobj 14633e72ca8cSmrg 14643e72ca8cSmrgEOF 14653e72ca8cSmrg $MV "${write_libobj}T" "${write_libobj}" 14663e72ca8cSmrg } 14673e72ca8cSmrg} 14683e72ca8cSmrg 14693e72ca8cSmrg 14703e72ca8cSmrg################################################## 14713e72ca8cSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 14723e72ca8cSmrg################################################## 14733e72ca8cSmrg 14743e72ca8cSmrg# func_convert_core_file_wine_to_w32 ARG 14753e72ca8cSmrg# Helper function used by file name conversion functions when $build is *nix, 14763e72ca8cSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 14773e72ca8cSmrg# correctly configured wine environment available, with the winepath program 14783e72ca8cSmrg# in $build's $PATH. 14793e72ca8cSmrg# 14803e72ca8cSmrg# ARG is the $build file name to be converted to w32 format. 14813e72ca8cSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 14823e72ca8cSmrg# be empty on error (or when ARG is empty) 14833e72ca8cSmrgfunc_convert_core_file_wine_to_w32 () 14843e72ca8cSmrg{ 14853e72ca8cSmrg $opt_debug 14863e72ca8cSmrg func_convert_core_file_wine_to_w32_result="$1" 14873e72ca8cSmrg if test -n "$1"; then 14883e72ca8cSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 14893e72ca8cSmrg # are forced to check the contents of stdout. On the other hand, if the 14903e72ca8cSmrg # command is not found, the shell will set an exit code of 127 and print 14913e72ca8cSmrg # *an error message* to stdout. So we must check for both error code of 14923e72ca8cSmrg # zero AND non-empty stdout, which explains the odd construction: 14933e72ca8cSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 14943e72ca8cSmrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 14953e72ca8cSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 14963e72ca8cSmrg $SED -e "$lt_sed_naive_backslashify"` 14973e72ca8cSmrg else 14983e72ca8cSmrg func_convert_core_file_wine_to_w32_result= 14993e72ca8cSmrg fi 15003e72ca8cSmrg fi 15013e72ca8cSmrg} 15023e72ca8cSmrg# end: func_convert_core_file_wine_to_w32 15033e72ca8cSmrg 15043e72ca8cSmrg 15053e72ca8cSmrg# func_convert_core_path_wine_to_w32 ARG 15063e72ca8cSmrg# Helper function used by path conversion functions when $build is *nix, and 15073e72ca8cSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 15083e72ca8cSmrg# configured wine environment available, with the winepath program in $build's 15093e72ca8cSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 15103e72ca8cSmrg# 15113e72ca8cSmrg# ARG is path to be converted from $build format to win32. 15123e72ca8cSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 15133e72ca8cSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 15143e72ca8cSmrg# are convertible, then the result may be empty. 15153e72ca8cSmrgfunc_convert_core_path_wine_to_w32 () 15163e72ca8cSmrg{ 15173e72ca8cSmrg $opt_debug 15183e72ca8cSmrg # unfortunately, winepath doesn't convert paths, only file names 15193e72ca8cSmrg func_convert_core_path_wine_to_w32_result="" 15203e72ca8cSmrg if test -n "$1"; then 15213e72ca8cSmrg oldIFS=$IFS 15223e72ca8cSmrg IFS=: 15233e72ca8cSmrg for func_convert_core_path_wine_to_w32_f in $1; do 15243e72ca8cSmrg IFS=$oldIFS 15253e72ca8cSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 15263e72ca8cSmrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 15273e72ca8cSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 15283e72ca8cSmrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 15293e72ca8cSmrg else 15303e72ca8cSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 15313e72ca8cSmrg fi 15323e72ca8cSmrg fi 15333e72ca8cSmrg done 15343e72ca8cSmrg IFS=$oldIFS 15353e72ca8cSmrg fi 15363e72ca8cSmrg} 15373e72ca8cSmrg# end: func_convert_core_path_wine_to_w32 15383e72ca8cSmrg 15393e72ca8cSmrg 15403e72ca8cSmrg# func_cygpath ARGS... 15413e72ca8cSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 15423e72ca8cSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 15433e72ca8cSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 15443e72ca8cSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 15453e72ca8cSmrg# file name or path is assumed to be in w32 format, as previously converted 15463e72ca8cSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 15473e72ca8cSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 15483e72ca8cSmrg# Cygwin format). Returns an empty string on error. 15493e72ca8cSmrg# 15503e72ca8cSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 15513e72ca8cSmrg# be converted. 15523e72ca8cSmrg# 15533e72ca8cSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 15543e72ca8cSmrg# environment variable; do not put it in $PATH. 15553e72ca8cSmrgfunc_cygpath () 15563e72ca8cSmrg{ 15573e72ca8cSmrg $opt_debug 15583e72ca8cSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 15593e72ca8cSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 15603e72ca8cSmrg if test "$?" -ne 0; then 15613e72ca8cSmrg # on failure, ensure result is empty 15623e72ca8cSmrg func_cygpath_result= 15633e72ca8cSmrg fi 15643e72ca8cSmrg else 15653e72ca8cSmrg func_cygpath_result= 15663e72ca8cSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 15673e72ca8cSmrg fi 15683e72ca8cSmrg} 15693e72ca8cSmrg#end: func_cygpath 15703e72ca8cSmrg 15713e72ca8cSmrg 15723e72ca8cSmrg# func_convert_core_msys_to_w32 ARG 15733e72ca8cSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 15743e72ca8cSmrg# result in func_convert_core_msys_to_w32_result. 15753e72ca8cSmrgfunc_convert_core_msys_to_w32 () 15763e72ca8cSmrg{ 15773e72ca8cSmrg $opt_debug 15783e72ca8cSmrg # awkward: cmd appends spaces to result 15793e72ca8cSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 15803e72ca8cSmrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 15813e72ca8cSmrg} 15823e72ca8cSmrg#end: func_convert_core_msys_to_w32 15833e72ca8cSmrg 15843e72ca8cSmrg 15853e72ca8cSmrg# func_convert_file_check ARG1 ARG2 15863e72ca8cSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 15873e72ca8cSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 15883e72ca8cSmrg# func_to_host_file_result to ARG1). 15893e72ca8cSmrgfunc_convert_file_check () 15903e72ca8cSmrg{ 15913e72ca8cSmrg $opt_debug 15923e72ca8cSmrg if test -z "$2" && test -n "$1" ; then 15933e72ca8cSmrg func_error "Could not determine host file name corresponding to" 15943e72ca8cSmrg func_error " \`$1'" 15953e72ca8cSmrg func_error "Continuing, but uninstalled executables may not work." 15963e72ca8cSmrg # Fallback: 15973e72ca8cSmrg func_to_host_file_result="$1" 15983e72ca8cSmrg fi 15993e72ca8cSmrg} 16003e72ca8cSmrg# end func_convert_file_check 16013e72ca8cSmrg 16023e72ca8cSmrg 16033e72ca8cSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 16043e72ca8cSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 16053e72ca8cSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 16063e72ca8cSmrg# func_to_host_file_result to a simplistic fallback value (see below). 16073e72ca8cSmrgfunc_convert_path_check () 16083e72ca8cSmrg{ 16093e72ca8cSmrg $opt_debug 16103e72ca8cSmrg if test -z "$4" && test -n "$3"; then 16113e72ca8cSmrg func_error "Could not determine the host path corresponding to" 16123e72ca8cSmrg func_error " \`$3'" 16133e72ca8cSmrg func_error "Continuing, but uninstalled executables may not work." 16143e72ca8cSmrg # Fallback. This is a deliberately simplistic "conversion" and 16153e72ca8cSmrg # should not be "improved". See libtool.info. 16163e72ca8cSmrg if test "x$1" != "x$2"; then 16173e72ca8cSmrg lt_replace_pathsep_chars="s|$1|$2|g" 16183e72ca8cSmrg func_to_host_path_result=`echo "$3" | 16193e72ca8cSmrg $SED -e "$lt_replace_pathsep_chars"` 16203e72ca8cSmrg else 16213e72ca8cSmrg func_to_host_path_result="$3" 16223e72ca8cSmrg fi 16233e72ca8cSmrg fi 16243e72ca8cSmrg} 16253e72ca8cSmrg# end func_convert_path_check 16263e72ca8cSmrg 16273e72ca8cSmrg 16283e72ca8cSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 16293e72ca8cSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 16303e72ca8cSmrg# and appending REPL if ORIG matches BACKPAT. 16313e72ca8cSmrgfunc_convert_path_front_back_pathsep () 16323e72ca8cSmrg{ 16333e72ca8cSmrg $opt_debug 16343e72ca8cSmrg case $4 in 16353e72ca8cSmrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 16363e72ca8cSmrg ;; 16373e72ca8cSmrg esac 16383e72ca8cSmrg case $4 in 16393e72ca8cSmrg $2 ) func_append func_to_host_path_result "$3" 16403e72ca8cSmrg ;; 16413e72ca8cSmrg esac 16423e72ca8cSmrg} 16433e72ca8cSmrg# end func_convert_path_front_back_pathsep 16443e72ca8cSmrg 16453e72ca8cSmrg 16463e72ca8cSmrg################################################## 16473e72ca8cSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 16483e72ca8cSmrg################################################## 16493e72ca8cSmrg# invoked via `$to_host_file_cmd ARG' 16503e72ca8cSmrg# 16513e72ca8cSmrg# In each case, ARG is the path to be converted from $build to $host format. 16523e72ca8cSmrg# Result will be available in $func_to_host_file_result. 16533e72ca8cSmrg 16543e72ca8cSmrg 16553e72ca8cSmrg# func_to_host_file ARG 16563e72ca8cSmrg# Converts the file name ARG from $build format to $host format. Return result 16573e72ca8cSmrg# in func_to_host_file_result. 16583e72ca8cSmrgfunc_to_host_file () 16593e72ca8cSmrg{ 16603e72ca8cSmrg $opt_debug 16613e72ca8cSmrg $to_host_file_cmd "$1" 16623e72ca8cSmrg} 16633e72ca8cSmrg# end func_to_host_file 16643e72ca8cSmrg 16653e72ca8cSmrg 16663e72ca8cSmrg# func_to_tool_file ARG LAZY 16673e72ca8cSmrg# converts the file name ARG from $build format to toolchain format. Return 16683e72ca8cSmrg# result in func_to_tool_file_result. If the conversion in use is listed 16693e72ca8cSmrg# in (the comma separated) LAZY, no conversion takes place. 16703e72ca8cSmrgfunc_to_tool_file () 16713e72ca8cSmrg{ 16723e72ca8cSmrg $opt_debug 16733e72ca8cSmrg case ,$2, in 16743e72ca8cSmrg *,"$to_tool_file_cmd",*) 16753e72ca8cSmrg func_to_tool_file_result=$1 16763e72ca8cSmrg ;; 16773e72ca8cSmrg *) 16783e72ca8cSmrg $to_tool_file_cmd "$1" 16793e72ca8cSmrg func_to_tool_file_result=$func_to_host_file_result 16803e72ca8cSmrg ;; 16813e72ca8cSmrg esac 16823e72ca8cSmrg} 16833e72ca8cSmrg# end func_to_tool_file 16843e72ca8cSmrg 16853e72ca8cSmrg 16863e72ca8cSmrg# func_convert_file_noop ARG 16873e72ca8cSmrg# Copy ARG to func_to_host_file_result. 16883e72ca8cSmrgfunc_convert_file_noop () 16893e72ca8cSmrg{ 16903e72ca8cSmrg func_to_host_file_result="$1" 16913e72ca8cSmrg} 16923e72ca8cSmrg# end func_convert_file_noop 16933e72ca8cSmrg 16943e72ca8cSmrg 16953e72ca8cSmrg# func_convert_file_msys_to_w32 ARG 16963e72ca8cSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 16973e72ca8cSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 16983e72ca8cSmrg# func_to_host_file_result. 16993e72ca8cSmrgfunc_convert_file_msys_to_w32 () 17003e72ca8cSmrg{ 17013e72ca8cSmrg $opt_debug 17023e72ca8cSmrg func_to_host_file_result="$1" 17033e72ca8cSmrg if test -n "$1"; then 17043e72ca8cSmrg func_convert_core_msys_to_w32 "$1" 17053e72ca8cSmrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 17063e72ca8cSmrg fi 17073e72ca8cSmrg func_convert_file_check "$1" "$func_to_host_file_result" 17083e72ca8cSmrg} 17093e72ca8cSmrg# end func_convert_file_msys_to_w32 17103e72ca8cSmrg 17113e72ca8cSmrg 17123e72ca8cSmrg# func_convert_file_cygwin_to_w32 ARG 17133e72ca8cSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 17143e72ca8cSmrg# func_to_host_file_result. 17153e72ca8cSmrgfunc_convert_file_cygwin_to_w32 () 17163e72ca8cSmrg{ 17173e72ca8cSmrg $opt_debug 17183e72ca8cSmrg func_to_host_file_result="$1" 17193e72ca8cSmrg if test -n "$1"; then 17203e72ca8cSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 17213e72ca8cSmrg # LT_CYGPATH in this case. 17223e72ca8cSmrg func_to_host_file_result=`cygpath -m "$1"` 17233e72ca8cSmrg fi 17243e72ca8cSmrg func_convert_file_check "$1" "$func_to_host_file_result" 17253e72ca8cSmrg} 17263e72ca8cSmrg# end func_convert_file_cygwin_to_w32 17273e72ca8cSmrg 17283e72ca8cSmrg 17293e72ca8cSmrg# func_convert_file_nix_to_w32 ARG 17303e72ca8cSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 17313e72ca8cSmrg# and a working winepath. Returns result in func_to_host_file_result. 17323e72ca8cSmrgfunc_convert_file_nix_to_w32 () 17333e72ca8cSmrg{ 17343e72ca8cSmrg $opt_debug 17353e72ca8cSmrg func_to_host_file_result="$1" 17363e72ca8cSmrg if test -n "$1"; then 17373e72ca8cSmrg func_convert_core_file_wine_to_w32 "$1" 17383e72ca8cSmrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 17393e72ca8cSmrg fi 17403e72ca8cSmrg func_convert_file_check "$1" "$func_to_host_file_result" 17413e72ca8cSmrg} 17423e72ca8cSmrg# end func_convert_file_nix_to_w32 17433e72ca8cSmrg 17443e72ca8cSmrg 17453e72ca8cSmrg# func_convert_file_msys_to_cygwin ARG 17463e72ca8cSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 17473e72ca8cSmrg# Returns result in func_to_host_file_result. 17483e72ca8cSmrgfunc_convert_file_msys_to_cygwin () 17493e72ca8cSmrg{ 17503e72ca8cSmrg $opt_debug 17513e72ca8cSmrg func_to_host_file_result="$1" 17523e72ca8cSmrg if test -n "$1"; then 17533e72ca8cSmrg func_convert_core_msys_to_w32 "$1" 17543e72ca8cSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 17553e72ca8cSmrg func_to_host_file_result="$func_cygpath_result" 17563e72ca8cSmrg fi 17573e72ca8cSmrg func_convert_file_check "$1" "$func_to_host_file_result" 17583e72ca8cSmrg} 17593e72ca8cSmrg# end func_convert_file_msys_to_cygwin 17603e72ca8cSmrg 17613e72ca8cSmrg 17623e72ca8cSmrg# func_convert_file_nix_to_cygwin ARG 17633e72ca8cSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 17643e72ca8cSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 17653e72ca8cSmrg# in func_to_host_file_result. 17663e72ca8cSmrgfunc_convert_file_nix_to_cygwin () 17673e72ca8cSmrg{ 17683e72ca8cSmrg $opt_debug 17693e72ca8cSmrg func_to_host_file_result="$1" 17703e72ca8cSmrg if test -n "$1"; then 17713e72ca8cSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 17723e72ca8cSmrg func_convert_core_file_wine_to_w32 "$1" 17733e72ca8cSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 17743e72ca8cSmrg func_to_host_file_result="$func_cygpath_result" 17753e72ca8cSmrg fi 17763e72ca8cSmrg func_convert_file_check "$1" "$func_to_host_file_result" 17773e72ca8cSmrg} 17783e72ca8cSmrg# end func_convert_file_nix_to_cygwin 17793e72ca8cSmrg 17803e72ca8cSmrg 17813e72ca8cSmrg############################################# 17823e72ca8cSmrg# $build to $host PATH CONVERSION FUNCTIONS # 17833e72ca8cSmrg############################################# 17843e72ca8cSmrg# invoked via `$to_host_path_cmd ARG' 17853e72ca8cSmrg# 17863e72ca8cSmrg# In each case, ARG is the path to be converted from $build to $host format. 17873e72ca8cSmrg# The result will be available in $func_to_host_path_result. 17883e72ca8cSmrg# 17893e72ca8cSmrg# Path separators are also converted from $build format to $host format. If 17903e72ca8cSmrg# ARG begins or ends with a path separator character, it is preserved (but 17913e72ca8cSmrg# converted to $host format) on output. 17923e72ca8cSmrg# 17933e72ca8cSmrg# All path conversion functions are named using the following convention: 17943e72ca8cSmrg# file name conversion function : func_convert_file_X_to_Y () 17953e72ca8cSmrg# path conversion function : func_convert_path_X_to_Y () 17963e72ca8cSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 17973e72ca8cSmrg# same. If conversion functions are added for new $build/$host combinations, 17983e72ca8cSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 17993e72ca8cSmrg# will break. 18003e72ca8cSmrg 18013e72ca8cSmrg 18023e72ca8cSmrg# func_init_to_host_path_cmd 18033e72ca8cSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 18043e72ca8cSmrg# appropriate value, based on the value of $to_host_file_cmd. 18053e72ca8cSmrgto_host_path_cmd= 18063e72ca8cSmrgfunc_init_to_host_path_cmd () 18073e72ca8cSmrg{ 18083e72ca8cSmrg $opt_debug 18093e72ca8cSmrg if test -z "$to_host_path_cmd"; then 18103e72ca8cSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 18113e72ca8cSmrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 18123e72ca8cSmrg fi 18133e72ca8cSmrg} 18143e72ca8cSmrg 18153e72ca8cSmrg 18163e72ca8cSmrg# func_to_host_path ARG 18173e72ca8cSmrg# Converts the path ARG from $build format to $host format. Return result 18183e72ca8cSmrg# in func_to_host_path_result. 18193e72ca8cSmrgfunc_to_host_path () 18203e72ca8cSmrg{ 18213e72ca8cSmrg $opt_debug 18223e72ca8cSmrg func_init_to_host_path_cmd 18233e72ca8cSmrg $to_host_path_cmd "$1" 18243e72ca8cSmrg} 18253e72ca8cSmrg# end func_to_host_path 18263e72ca8cSmrg 18273e72ca8cSmrg 18283e72ca8cSmrg# func_convert_path_noop ARG 18293e72ca8cSmrg# Copy ARG to func_to_host_path_result. 18303e72ca8cSmrgfunc_convert_path_noop () 18313e72ca8cSmrg{ 18323e72ca8cSmrg func_to_host_path_result="$1" 18333e72ca8cSmrg} 18343e72ca8cSmrg# end func_convert_path_noop 18353e72ca8cSmrg 18363e72ca8cSmrg 18373e72ca8cSmrg# func_convert_path_msys_to_w32 ARG 18383e72ca8cSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 18393e72ca8cSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 18403e72ca8cSmrg# func_to_host_path_result. 18413e72ca8cSmrgfunc_convert_path_msys_to_w32 () 18423e72ca8cSmrg{ 18433e72ca8cSmrg $opt_debug 18443e72ca8cSmrg func_to_host_path_result="$1" 18453e72ca8cSmrg if test -n "$1"; then 18463e72ca8cSmrg # Remove leading and trailing path separator characters from ARG. MSYS 18473e72ca8cSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 18483e72ca8cSmrg # and winepath ignores them completely. 18493e72ca8cSmrg func_stripname : : "$1" 18503e72ca8cSmrg func_to_host_path_tmp1=$func_stripname_result 18513e72ca8cSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 18523e72ca8cSmrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 18533e72ca8cSmrg func_convert_path_check : ";" \ 18543e72ca8cSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 18553e72ca8cSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 18563e72ca8cSmrg fi 18573e72ca8cSmrg} 18583e72ca8cSmrg# end func_convert_path_msys_to_w32 18593e72ca8cSmrg 18603e72ca8cSmrg 18613e72ca8cSmrg# func_convert_path_cygwin_to_w32 ARG 18623e72ca8cSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 18633e72ca8cSmrg# func_to_host_file_result. 18643e72ca8cSmrgfunc_convert_path_cygwin_to_w32 () 18653e72ca8cSmrg{ 18663e72ca8cSmrg $opt_debug 18673e72ca8cSmrg func_to_host_path_result="$1" 18683e72ca8cSmrg if test -n "$1"; then 18693e72ca8cSmrg # See func_convert_path_msys_to_w32: 18703e72ca8cSmrg func_stripname : : "$1" 18713e72ca8cSmrg func_to_host_path_tmp1=$func_stripname_result 18723e72ca8cSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 18733e72ca8cSmrg func_convert_path_check : ";" \ 18743e72ca8cSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 18753e72ca8cSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 18763e72ca8cSmrg fi 18773e72ca8cSmrg} 18783e72ca8cSmrg# end func_convert_path_cygwin_to_w32 18793e72ca8cSmrg 18803e72ca8cSmrg 18813e72ca8cSmrg# func_convert_path_nix_to_w32 ARG 18823e72ca8cSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 18833e72ca8cSmrg# a working winepath. Returns result in func_to_host_file_result. 18843e72ca8cSmrgfunc_convert_path_nix_to_w32 () 188534977a2fSmrg{ 18863e72ca8cSmrg $opt_debug 18873e72ca8cSmrg func_to_host_path_result="$1" 18883e72ca8cSmrg if test -n "$1"; then 18893e72ca8cSmrg # See func_convert_path_msys_to_w32: 18903e72ca8cSmrg func_stripname : : "$1" 18913e72ca8cSmrg func_to_host_path_tmp1=$func_stripname_result 18923e72ca8cSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 18933e72ca8cSmrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 18943e72ca8cSmrg func_convert_path_check : ";" \ 18953e72ca8cSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 18963e72ca8cSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 18973e72ca8cSmrg fi 18983e72ca8cSmrg} 18993e72ca8cSmrg# end func_convert_path_nix_to_w32 190034977a2fSmrg 190134977a2fSmrg 19023e72ca8cSmrg# func_convert_path_msys_to_cygwin ARG 19033e72ca8cSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 19043e72ca8cSmrg# Returns result in func_to_host_file_result. 19053e72ca8cSmrgfunc_convert_path_msys_to_cygwin () 19063e72ca8cSmrg{ 19073e72ca8cSmrg $opt_debug 19083e72ca8cSmrg func_to_host_path_result="$1" 19093e72ca8cSmrg if test -n "$1"; then 19103e72ca8cSmrg # See func_convert_path_msys_to_w32: 19113e72ca8cSmrg func_stripname : : "$1" 19123e72ca8cSmrg func_to_host_path_tmp1=$func_stripname_result 19133e72ca8cSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 19143e72ca8cSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 19153e72ca8cSmrg func_to_host_path_result="$func_cygpath_result" 19163e72ca8cSmrg func_convert_path_check : : \ 19173e72ca8cSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 19183e72ca8cSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 19193e72ca8cSmrg fi 19203e72ca8cSmrg} 19213e72ca8cSmrg# end func_convert_path_msys_to_cygwin 192234977a2fSmrg 192334977a2fSmrg 19243e72ca8cSmrg# func_convert_path_nix_to_cygwin ARG 19253e72ca8cSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 19263e72ca8cSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 19273e72ca8cSmrg# func_to_host_file_result. 19283e72ca8cSmrgfunc_convert_path_nix_to_cygwin () 19293e72ca8cSmrg{ 19303e72ca8cSmrg $opt_debug 19313e72ca8cSmrg func_to_host_path_result="$1" 19323e72ca8cSmrg if test -n "$1"; then 19333e72ca8cSmrg # Remove leading and trailing path separator characters from 19343e72ca8cSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 19353e72ca8cSmrg # into '.;' and ';.', and winepath ignores them completely. 19363e72ca8cSmrg func_stripname : : "$1" 19373e72ca8cSmrg func_to_host_path_tmp1=$func_stripname_result 19383e72ca8cSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 19393e72ca8cSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 19403e72ca8cSmrg func_to_host_path_result="$func_cygpath_result" 19413e72ca8cSmrg func_convert_path_check : : \ 19423e72ca8cSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 19433e72ca8cSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 19443e72ca8cSmrg fi 194534977a2fSmrg} 19463e72ca8cSmrg# end func_convert_path_nix_to_cygwin 19473e72ca8cSmrg 194834977a2fSmrg 194934977a2fSmrg# func_mode_compile arg... 195034977a2fSmrgfunc_mode_compile () 195134977a2fSmrg{ 195234977a2fSmrg $opt_debug 195334977a2fSmrg # Get the compilation command and the source file. 195434977a2fSmrg base_compile= 195534977a2fSmrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 195634977a2fSmrg suppress_opt=yes 195734977a2fSmrg suppress_output= 195834977a2fSmrg arg_mode=normal 195934977a2fSmrg libobj= 196034977a2fSmrg later= 196134977a2fSmrg pie_flag= 196234977a2fSmrg 196334977a2fSmrg for arg 196434977a2fSmrg do 196534977a2fSmrg case $arg_mode in 196634977a2fSmrg arg ) 196734977a2fSmrg # do not "continue". Instead, add this to base_compile 196834977a2fSmrg lastarg="$arg" 196934977a2fSmrg arg_mode=normal 197034977a2fSmrg ;; 197134977a2fSmrg 197234977a2fSmrg target ) 197334977a2fSmrg libobj="$arg" 197434977a2fSmrg arg_mode=normal 197534977a2fSmrg continue 197634977a2fSmrg ;; 197734977a2fSmrg 197834977a2fSmrg normal ) 197934977a2fSmrg # Accept any command-line options. 198034977a2fSmrg case $arg in 198134977a2fSmrg -o) 198234977a2fSmrg test -n "$libobj" && \ 198334977a2fSmrg func_fatal_error "you cannot specify \`-o' more than once" 198434977a2fSmrg arg_mode=target 198534977a2fSmrg continue 198634977a2fSmrg ;; 198734977a2fSmrg 198834977a2fSmrg -pie | -fpie | -fPIE) 19893e72ca8cSmrg func_append pie_flag " $arg" 199034977a2fSmrg continue 199134977a2fSmrg ;; 199234977a2fSmrg 199334977a2fSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 19943e72ca8cSmrg func_append later " $arg" 199534977a2fSmrg continue 199634977a2fSmrg ;; 1997ee3138f1Smrg 1998ee3138f1Smrg -no-suppress) 1999ee3138f1Smrg suppress_opt=no 2000ee3138f1Smrg continue 2001ee3138f1Smrg ;; 2002ee3138f1Smrg 2003ee3138f1Smrg -Xcompiler) 2004ee3138f1Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 2005ee3138f1Smrg continue # The current "srcfile" will either be retained or 2006ee3138f1Smrg ;; # replaced later. I would guess that would be a bug. 2007ee3138f1Smrg 2008ee3138f1Smrg -Wc,*) 200934977a2fSmrg func_stripname '-Wc,' '' "$arg" 201034977a2fSmrg args=$func_stripname_result 2011ee3138f1Smrg lastarg= 2012ee3138f1Smrg save_ifs="$IFS"; IFS=',' 201334977a2fSmrg for arg in $args; do 2014ee3138f1Smrg IFS="$save_ifs" 20153e72ca8cSmrg func_append_quoted lastarg "$arg" 2016ee3138f1Smrg done 2017ee3138f1Smrg IFS="$save_ifs" 201834977a2fSmrg func_stripname ' ' '' "$lastarg" 201934977a2fSmrg lastarg=$func_stripname_result 2020ee3138f1Smrg 2021ee3138f1Smrg # Add the arguments to base_compile. 20223e72ca8cSmrg func_append base_compile " $lastarg" 2023ee3138f1Smrg continue 2024ee3138f1Smrg ;; 2025ee3138f1Smrg 202634977a2fSmrg *) 2027ee3138f1Smrg # Accept the current argument as the source file. 2028ee3138f1Smrg # The previous "srcfile" becomes the current argument. 2029ee3138f1Smrg # 2030ee3138f1Smrg lastarg="$srcfile" 2031ee3138f1Smrg srcfile="$arg" 2032ee3138f1Smrg ;; 2033ee3138f1Smrg esac # case $arg 2034ee3138f1Smrg ;; 2035ee3138f1Smrg esac # case $arg_mode 2036ee3138f1Smrg 2037ee3138f1Smrg # Aesthetically quote the previous argument. 20383e72ca8cSmrg func_append_quoted base_compile "$lastarg" 2039ee3138f1Smrg done # for arg 2040ee3138f1Smrg 2041ee3138f1Smrg case $arg_mode in 2042ee3138f1Smrg arg) 204334977a2fSmrg func_fatal_error "you must specify an argument for -Xcompile" 2044ee3138f1Smrg ;; 2045ee3138f1Smrg target) 204634977a2fSmrg func_fatal_error "you must specify a target with \`-o'" 2047ee3138f1Smrg ;; 2048ee3138f1Smrg *) 2049ee3138f1Smrg # Get the name of the library object. 205034977a2fSmrg test -z "$libobj" && { 205134977a2fSmrg func_basename "$srcfile" 205234977a2fSmrg libobj="$func_basename_result" 205334977a2fSmrg } 2054ee3138f1Smrg ;; 2055ee3138f1Smrg esac 2056ee3138f1Smrg 2057ee3138f1Smrg # Recognize several different file suffixes. 2058ee3138f1Smrg # If the user specifies -o file.o, it is replaced with file.lo 2059ee3138f1Smrg case $libobj in 206034977a2fSmrg *.[cCFSifmso] | \ 206134977a2fSmrg *.ada | *.adb | *.ads | *.asm | \ 206234977a2fSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 20633e72ca8cSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 206434977a2fSmrg func_xform "$libobj" 206534977a2fSmrg libobj=$func_xform_result 206634977a2fSmrg ;; 2067ee3138f1Smrg esac 2068ee3138f1Smrg 2069ee3138f1Smrg case $libobj in 207034977a2fSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 2071ee3138f1Smrg *) 207234977a2fSmrg func_fatal_error "cannot determine name of library object from \`$libobj'" 2073ee3138f1Smrg ;; 2074ee3138f1Smrg esac 2075ee3138f1Smrg 2076ee3138f1Smrg func_infer_tag $base_compile 2077ee3138f1Smrg 2078ee3138f1Smrg for arg in $later; do 2079ee3138f1Smrg case $arg in 208034977a2fSmrg -shared) 208134977a2fSmrg test "$build_libtool_libs" != yes && \ 208234977a2fSmrg func_fatal_configuration "can not build a shared library" 208334977a2fSmrg build_old_libs=no 208434977a2fSmrg continue 208534977a2fSmrg ;; 208634977a2fSmrg 2087ee3138f1Smrg -static) 208834977a2fSmrg build_libtool_libs=no 2089ee3138f1Smrg build_old_libs=yes 2090ee3138f1Smrg continue 2091ee3138f1Smrg ;; 2092ee3138f1Smrg 2093ee3138f1Smrg -prefer-pic) 2094ee3138f1Smrg pic_mode=yes 2095ee3138f1Smrg continue 2096ee3138f1Smrg ;; 2097ee3138f1Smrg 2098ee3138f1Smrg -prefer-non-pic) 2099ee3138f1Smrg pic_mode=no 2100ee3138f1Smrg continue 2101ee3138f1Smrg ;; 2102ee3138f1Smrg esac 2103ee3138f1Smrg done 2104ee3138f1Smrg 210534977a2fSmrg func_quote_for_eval "$libobj" 210634977a2fSmrg test "X$libobj" != "X$func_quote_for_eval_result" \ 210734977a2fSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 210834977a2fSmrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 210934977a2fSmrg func_dirname_and_basename "$obj" "/" "" 211034977a2fSmrg objname="$func_basename_result" 211134977a2fSmrg xdir="$func_dirname_result" 2112ee3138f1Smrg lobj=${xdir}$objdir/$objname 2113ee3138f1Smrg 211434977a2fSmrg test -z "$base_compile" && \ 211534977a2fSmrg func_fatal_help "you must specify a compilation command" 2116ee3138f1Smrg 2117ee3138f1Smrg # Delete any leftover library objects. 2118ee3138f1Smrg if test "$build_old_libs" = yes; then 2119ee3138f1Smrg removelist="$obj $lobj $libobj ${libobj}T" 2120ee3138f1Smrg else 2121ee3138f1Smrg removelist="$lobj $libobj ${libobj}T" 2122ee3138f1Smrg fi 2123ee3138f1Smrg 2124ee3138f1Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 2125ee3138f1Smrg case $host_os in 212634977a2fSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 2127ee3138f1Smrg pic_mode=default 2128ee3138f1Smrg ;; 2129ee3138f1Smrg esac 2130ee3138f1Smrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 2131ee3138f1Smrg # non-PIC code in shared libraries is not supported 2132ee3138f1Smrg pic_mode=default 2133ee3138f1Smrg fi 2134ee3138f1Smrg 2135ee3138f1Smrg # Calculate the filename of the output object if compiler does 2136ee3138f1Smrg # not support -o with -c 2137ee3138f1Smrg if test "$compiler_c_o" = no; then 2138b425557eSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 2139ee3138f1Smrg lockfile="$output_obj.lock" 2140ee3138f1Smrg else 2141ee3138f1Smrg output_obj= 2142ee3138f1Smrg need_locks=no 2143ee3138f1Smrg lockfile= 2144ee3138f1Smrg fi 2145ee3138f1Smrg 2146ee3138f1Smrg # Lock this critical section if it is needed 2147ee3138f1Smrg # We use this script file to make the link, it avoids creating a new file 2148ee3138f1Smrg if test "$need_locks" = yes; then 214934977a2fSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 215034977a2fSmrg func_echo "Waiting for $lockfile to be removed" 2151ee3138f1Smrg sleep 2 2152ee3138f1Smrg done 2153ee3138f1Smrg elif test "$need_locks" = warn; then 2154ee3138f1Smrg if test -f "$lockfile"; then 215534977a2fSmrg $ECHO "\ 2156ee3138f1Smrg*** ERROR, $lockfile exists and contains: 2157ee3138f1Smrg`cat $lockfile 2>/dev/null` 2158ee3138f1Smrg 2159ee3138f1SmrgThis indicates that another process is trying to use the same 2160ee3138f1Smrgtemporary object file, and libtool could not work around it because 2161ee3138f1Smrgyour compiler does not support \`-c' and \`-o' together. If you 2162ee3138f1Smrgrepeat this compilation, it may succeed, by chance, but you had better 2163ee3138f1Smrgavoid parallel builds (make -j) in this platform, or get a better 2164ee3138f1Smrgcompiler." 2165ee3138f1Smrg 216634977a2fSmrg $opt_dry_run || $RM $removelist 2167ee3138f1Smrg exit $EXIT_FAILURE 2168ee3138f1Smrg fi 21693e72ca8cSmrg func_append removelist " $output_obj" 217034977a2fSmrg $ECHO "$srcfile" > "$lockfile" 2171ee3138f1Smrg fi 2172ee3138f1Smrg 217334977a2fSmrg $opt_dry_run || $RM $removelist 21743e72ca8cSmrg func_append removelist " $lockfile" 217534977a2fSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 217634977a2fSmrg 21773e72ca8cSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 21783e72ca8cSmrg srcfile=$func_to_tool_file_result 217934977a2fSmrg func_quote_for_eval "$srcfile" 218034977a2fSmrg qsrcfile=$func_quote_for_eval_result 2181ee3138f1Smrg 2182ee3138f1Smrg # Only build a PIC object if we are building libtool libraries. 2183ee3138f1Smrg if test "$build_libtool_libs" = yes; then 2184ee3138f1Smrg # Without this assignment, base_compile gets emptied. 2185ee3138f1Smrg fbsd_hideous_sh_bug=$base_compile 2186ee3138f1Smrg 2187ee3138f1Smrg if test "$pic_mode" != no; then 2188ee3138f1Smrg command="$base_compile $qsrcfile $pic_flag" 2189ee3138f1Smrg else 2190ee3138f1Smrg # Don't build PIC code 2191ee3138f1Smrg command="$base_compile $qsrcfile" 2192ee3138f1Smrg fi 2193ee3138f1Smrg 219434977a2fSmrg func_mkdir_p "$xdir$objdir" 2195ee3138f1Smrg 2196ee3138f1Smrg if test -z "$output_obj"; then 2197ee3138f1Smrg # Place PIC objects in $objdir 21983e72ca8cSmrg func_append command " -o $lobj" 2199ee3138f1Smrg fi 2200ee3138f1Smrg 220134977a2fSmrg func_show_eval_locale "$command" \ 220234977a2fSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 2203ee3138f1Smrg 2204ee3138f1Smrg if test "$need_locks" = warn && 2205ee3138f1Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 220634977a2fSmrg $ECHO "\ 2207ee3138f1Smrg*** ERROR, $lockfile contains: 2208ee3138f1Smrg`cat $lockfile 2>/dev/null` 2209ee3138f1Smrg 2210ee3138f1Smrgbut it should contain: 2211ee3138f1Smrg$srcfile 2212ee3138f1Smrg 2213ee3138f1SmrgThis indicates that another process is trying to use the same 2214ee3138f1Smrgtemporary object file, and libtool could not work around it because 2215ee3138f1Smrgyour compiler does not support \`-c' and \`-o' together. If you 2216ee3138f1Smrgrepeat this compilation, it may succeed, by chance, but you had better 2217ee3138f1Smrgavoid parallel builds (make -j) in this platform, or get a better 2218ee3138f1Smrgcompiler." 2219ee3138f1Smrg 222034977a2fSmrg $opt_dry_run || $RM $removelist 2221ee3138f1Smrg exit $EXIT_FAILURE 2222ee3138f1Smrg fi 2223ee3138f1Smrg 2224ee3138f1Smrg # Just move the object if needed, then go on to compile the next one 2225ee3138f1Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 222634977a2fSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 222734977a2fSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2228ee3138f1Smrg fi 2229ee3138f1Smrg 2230ee3138f1Smrg # Allow error messages only from the first compilation. 2231ee3138f1Smrg if test "$suppress_opt" = yes; then 223234977a2fSmrg suppress_output=' >/dev/null 2>&1' 2233ee3138f1Smrg fi 2234ee3138f1Smrg fi 2235ee3138f1Smrg 2236ee3138f1Smrg # Only build a position-dependent object if we build old libraries. 2237ee3138f1Smrg if test "$build_old_libs" = yes; then 2238ee3138f1Smrg if test "$pic_mode" != yes; then 2239ee3138f1Smrg # Don't build PIC code 224034977a2fSmrg command="$base_compile $qsrcfile$pie_flag" 2241ee3138f1Smrg else 2242ee3138f1Smrg command="$base_compile $qsrcfile $pic_flag" 2243ee3138f1Smrg fi 2244ee3138f1Smrg if test "$compiler_c_o" = yes; then 22453e72ca8cSmrg func_append command " -o $obj" 2246ee3138f1Smrg fi 2247ee3138f1Smrg 2248ee3138f1Smrg # Suppress compiler output if we already did a PIC compilation. 22493e72ca8cSmrg func_append command "$suppress_output" 225034977a2fSmrg func_show_eval_locale "$command" \ 225134977a2fSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 2252ee3138f1Smrg 2253ee3138f1Smrg if test "$need_locks" = warn && 2254ee3138f1Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 225534977a2fSmrg $ECHO "\ 2256ee3138f1Smrg*** ERROR, $lockfile contains: 2257ee3138f1Smrg`cat $lockfile 2>/dev/null` 2258ee3138f1Smrg 2259ee3138f1Smrgbut it should contain: 2260ee3138f1Smrg$srcfile 2261ee3138f1Smrg 2262ee3138f1SmrgThis indicates that another process is trying to use the same 2263ee3138f1Smrgtemporary object file, and libtool could not work around it because 2264ee3138f1Smrgyour compiler does not support \`-c' and \`-o' together. If you 2265ee3138f1Smrgrepeat this compilation, it may succeed, by chance, but you had better 2266ee3138f1Smrgavoid parallel builds (make -j) in this platform, or get a better 2267ee3138f1Smrgcompiler." 2268ee3138f1Smrg 226934977a2fSmrg $opt_dry_run || $RM $removelist 2270ee3138f1Smrg exit $EXIT_FAILURE 2271ee3138f1Smrg fi 2272ee3138f1Smrg 2273ee3138f1Smrg # Just move the object if needed 2274ee3138f1Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 227534977a2fSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 227634977a2fSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2277ee3138f1Smrg fi 2278ee3138f1Smrg fi 2279ee3138f1Smrg 228034977a2fSmrg $opt_dry_run || { 228134977a2fSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 2282ee3138f1Smrg 228334977a2fSmrg # Unlock the critical section if it was locked 228434977a2fSmrg if test "$need_locks" != no; then 228534977a2fSmrg removelist=$lockfile 228634977a2fSmrg $RM "$lockfile" 228734977a2fSmrg fi 228834977a2fSmrg } 2289ee3138f1Smrg 2290ee3138f1Smrg exit $EXIT_SUCCESS 229134977a2fSmrg} 2292ee3138f1Smrg 229334977a2fSmrg$opt_help || { 22943e72ca8cSmrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 229534977a2fSmrg} 2296ee3138f1Smrg 229734977a2fSmrgfunc_mode_help () 229834977a2fSmrg{ 229934977a2fSmrg # We need to display help for each of the modes. 23003e72ca8cSmrg case $opt_mode in 230134977a2fSmrg "") 230234977a2fSmrg # Generic help is extracted from the usage comments 230334977a2fSmrg # at the start of this file. 230434977a2fSmrg func_help 230534977a2fSmrg ;; 2306ee3138f1Smrg 230734977a2fSmrg clean) 230834977a2fSmrg $ECHO \ 230934977a2fSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 2310ee3138f1Smrg 231134977a2fSmrgRemove files from the build directory. 2312ee3138f1Smrg 231334977a2fSmrgRM is the name of the program to use to delete files associated with each FILE 231434977a2fSmrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 231534977a2fSmrgto RM. 2316ee3138f1Smrg 231734977a2fSmrgIf FILE is a libtool library, object or program, all the files associated 231834977a2fSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 231934977a2fSmrg ;; 2320ee3138f1Smrg 232134977a2fSmrg compile) 232234977a2fSmrg $ECHO \ 232334977a2fSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 2324ee3138f1Smrg 232534977a2fSmrgCompile a source file into a libtool library object. 2326ee3138f1Smrg 232734977a2fSmrgThis mode accepts the following additional options: 2328ee3138f1Smrg 232934977a2fSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 233034977a2fSmrg -no-suppress do not suppress compiler output for multiple passes 2331b425557eSmrg -prefer-pic try to build PIC objects only 2332b425557eSmrg -prefer-non-pic try to build non-PIC objects only 233334977a2fSmrg -shared do not build a \`.o' file suitable for static linking 233434977a2fSmrg -static only build a \`.o' file suitable for static linking 2335b425557eSmrg -Wc,FLAG pass FLAG directly to the compiler 2336ee3138f1Smrg 233734977a2fSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 233834977a2fSmrgfrom the given SOURCEFILE. 2339ee3138f1Smrg 234034977a2fSmrgThe output file name is determined by removing the directory component from 234134977a2fSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 234234977a2fSmrglibrary object suffix, \`.lo'." 234334977a2fSmrg ;; 2344ee3138f1Smrg 234534977a2fSmrg execute) 234634977a2fSmrg $ECHO \ 234734977a2fSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 2348ee3138f1Smrg 234934977a2fSmrgAutomatically set library path, then run a program. 2350ee3138f1Smrg 235134977a2fSmrgThis mode accepts the following additional options: 2352ee3138f1Smrg 235334977a2fSmrg -dlopen FILE add the directory containing FILE to the library path 2354ee3138f1Smrg 235534977a2fSmrgThis mode sets the library path environment variable according to \`-dlopen' 235634977a2fSmrgflags. 2357ee3138f1Smrg 235834977a2fSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 235934977a2fSmrginto their corresponding uninstalled binary, and any of their required library 236034977a2fSmrgdirectories are added to the library path. 2361ee3138f1Smrg 236234977a2fSmrgThen, COMMAND is executed, with ARGS as arguments." 236334977a2fSmrg ;; 2364ee3138f1Smrg 236534977a2fSmrg finish) 236634977a2fSmrg $ECHO \ 236734977a2fSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 2368ee3138f1Smrg 236934977a2fSmrgComplete the installation of libtool libraries. 2370ee3138f1Smrg 237134977a2fSmrgEach LIBDIR is a directory that contains libtool libraries. 2372ee3138f1Smrg 237334977a2fSmrgThe commands that this mode executes may require superuser privileges. Use 237434977a2fSmrgthe \`--dry-run' option if you just want to see what would be executed." 237534977a2fSmrg ;; 2376ee3138f1Smrg 237734977a2fSmrg install) 237834977a2fSmrg $ECHO \ 237934977a2fSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 2380ee3138f1Smrg 238134977a2fSmrgInstall executables or libraries. 2382ee3138f1Smrg 238334977a2fSmrgINSTALL-COMMAND is the installation command. The first component should be 238434977a2fSmrgeither the \`install' or \`cp' program. 2385ee3138f1Smrg 238634977a2fSmrgThe following components of INSTALL-COMMAND are treated specially: 2387ee3138f1Smrg 2388b425557eSmrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 2389ee3138f1Smrg 239034977a2fSmrgThe rest of the components are interpreted as arguments to that command (only 239134977a2fSmrgBSD-compatible install options are recognized)." 239234977a2fSmrg ;; 2393ee3138f1Smrg 239434977a2fSmrg link) 239534977a2fSmrg $ECHO \ 239634977a2fSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 2397ee3138f1Smrg 239834977a2fSmrgLink object files or libraries together to form another library, or to 239934977a2fSmrgcreate an executable program. 2400ee3138f1Smrg 240134977a2fSmrgLINK-COMMAND is a command using the C compiler that you would use to create 240234977a2fSmrga program from several object files. 2403ee3138f1Smrg 240434977a2fSmrgThe following components of LINK-COMMAND are treated specially: 2405ee3138f1Smrg 240634977a2fSmrg -all-static do not do any dynamic linking at all 240734977a2fSmrg -avoid-version do not add a version suffix if possible 2408b425557eSmrg -bindir BINDIR specify path to binaries directory (for systems where 2409b425557eSmrg libraries must be found in the PATH setting at runtime) 241034977a2fSmrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 241134977a2fSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 241234977a2fSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 241334977a2fSmrg -export-symbols SYMFILE 241434977a2fSmrg try to export only the symbols listed in SYMFILE 241534977a2fSmrg -export-symbols-regex REGEX 241634977a2fSmrg try to export only the symbols matching REGEX 241734977a2fSmrg -LLIBDIR search LIBDIR for required installed libraries 241834977a2fSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 241934977a2fSmrg -module build a library that can dlopened 242034977a2fSmrg -no-fast-install disable the fast-install mode 242134977a2fSmrg -no-install link a not-installable executable 242234977a2fSmrg -no-undefined declare that a library does not refer to external symbols 242334977a2fSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 242434977a2fSmrg -objectlist FILE Use a list of object files found in FILE to specify objects 242534977a2fSmrg -precious-files-regex REGEX 242634977a2fSmrg don't remove output files matching REGEX 242734977a2fSmrg -release RELEASE specify package release information 242834977a2fSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 242934977a2fSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 243034977a2fSmrg -shared only do dynamic linking of libtool libraries 243134977a2fSmrg -shrext SUFFIX override the standard shared library file extension 243234977a2fSmrg -static do not do any dynamic linking of uninstalled libtool libraries 243334977a2fSmrg -static-libtool-libs 243434977a2fSmrg do not do any dynamic linking of libtool libraries 243534977a2fSmrg -version-info CURRENT[:REVISION[:AGE]] 243634977a2fSmrg specify library version info [each variable defaults to 0] 243734977a2fSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 2438b425557eSmrg -Wc,FLAG 2439b425557eSmrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 2440b425557eSmrg -Wl,FLAG 2441b425557eSmrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 2442b425557eSmrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 2443ee3138f1Smrg 244434977a2fSmrgAll other options (arguments beginning with \`-') are ignored. 2445ee3138f1Smrg 244634977a2fSmrgEvery other argument is treated as a filename. Files ending in \`.la' are 244734977a2fSmrgtreated as uninstalled libtool libraries, other files are standard or library 244834977a2fSmrgobject files. 244979a8a9c6Smrg 245034977a2fSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 245134977a2fSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 245234977a2fSmrgrequired, except when creating a convenience library. 2453ee3138f1Smrg 245434977a2fSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 245534977a2fSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 2456ee3138f1Smrg 245734977a2fSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 245834977a2fSmrgis created, otherwise an executable program is created." 2459ee3138f1Smrg ;; 2460ee3138f1Smrg 246134977a2fSmrg uninstall) 246234977a2fSmrg $ECHO \ 246334977a2fSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 2464ee3138f1Smrg 246534977a2fSmrgRemove libraries from an installation directory. 2466ee3138f1Smrg 246734977a2fSmrgRM is the name of the program to use to delete files associated with each FILE 246834977a2fSmrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 246934977a2fSmrgto RM. 2470ee3138f1Smrg 247134977a2fSmrgIf FILE is a libtool library, all the files associated with it are deleted. 247234977a2fSmrgOtherwise, only FILE itself is deleted using RM." 247334977a2fSmrg ;; 2474ee3138f1Smrg 247534977a2fSmrg *) 24763e72ca8cSmrg func_fatal_help "invalid operation mode \`$opt_mode'" 247734977a2fSmrg ;; 247834977a2fSmrg esac 2479ee3138f1Smrg 2480b425557eSmrg echo 248134977a2fSmrg $ECHO "Try \`$progname --help' for more information about other modes." 248234977a2fSmrg} 2483ee3138f1Smrg 2484b425557eSmrg# Now that we've collected a possible --mode arg, show help if necessary 2485b425557eSmrgif $opt_help; then 2486b425557eSmrg if test "$opt_help" = :; then 2487b425557eSmrg func_mode_help 2488b425557eSmrg else 2489b425557eSmrg { 2490b425557eSmrg func_help noexit 24913e72ca8cSmrg for opt_mode in compile link execute install finish uninstall clean; do 2492b425557eSmrg func_mode_help 2493b425557eSmrg done 2494b425557eSmrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 2495b425557eSmrg { 2496b425557eSmrg func_help noexit 24973e72ca8cSmrg for opt_mode in compile link execute install finish uninstall clean; do 2498b425557eSmrg echo 2499b425557eSmrg func_mode_help 2500b425557eSmrg done 2501b425557eSmrg } | 2502b425557eSmrg sed '1d 2503b425557eSmrg /^When reporting/,/^Report/{ 2504b425557eSmrg H 2505b425557eSmrg d 2506b425557eSmrg } 2507b425557eSmrg $x 2508b425557eSmrg /information about other modes/d 2509b425557eSmrg /more detailed .*MODE/d 2510b425557eSmrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 2511b425557eSmrg fi 2512b425557eSmrg exit $? 2513b425557eSmrgfi 2514ee3138f1Smrg 2515ee3138f1Smrg 251634977a2fSmrg# func_mode_execute arg... 251734977a2fSmrgfunc_mode_execute () 251834977a2fSmrg{ 251934977a2fSmrg $opt_debug 252034977a2fSmrg # The first argument is the command name. 252134977a2fSmrg cmd="$nonopt" 252234977a2fSmrg test -z "$cmd" && \ 252334977a2fSmrg func_fatal_help "you must specify a COMMAND" 2524ee3138f1Smrg 252534977a2fSmrg # Handle -dlopen flags immediately. 25263e72ca8cSmrg for file in $opt_dlopen; do 252734977a2fSmrg test -f "$file" \ 252834977a2fSmrg || func_fatal_help "\`$file' is not a file" 2529ee3138f1Smrg 253034977a2fSmrg dir= 253134977a2fSmrg case $file in 253234977a2fSmrg *.la) 25333e72ca8cSmrg func_resolve_sysroot "$file" 25343e72ca8cSmrg file=$func_resolve_sysroot_result 25353e72ca8cSmrg 253634977a2fSmrg # Check to see that this really is a libtool archive. 253734977a2fSmrg func_lalib_unsafe_p "$file" \ 253834977a2fSmrg || func_fatal_help "\`$lib' is not a valid libtool archive" 2539ee3138f1Smrg 254034977a2fSmrg # Read the libtool library. 254134977a2fSmrg dlname= 254234977a2fSmrg library_names= 254334977a2fSmrg func_source "$file" 2544ee3138f1Smrg 254534977a2fSmrg # Skip this library if it cannot be dlopened. 254634977a2fSmrg if test -z "$dlname"; then 254734977a2fSmrg # Warn if it was a shared library. 254834977a2fSmrg test -n "$library_names" && \ 254934977a2fSmrg func_warning "\`$file' was not linked with \`-export-dynamic'" 255034977a2fSmrg continue 255134977a2fSmrg fi 2552ee3138f1Smrg 255334977a2fSmrg func_dirname "$file" "" "." 255434977a2fSmrg dir="$func_dirname_result" 2555ee3138f1Smrg 255634977a2fSmrg if test -f "$dir/$objdir/$dlname"; then 25573e72ca8cSmrg func_append dir "/$objdir" 255834977a2fSmrg else 255934977a2fSmrg if test ! -f "$dir/$dlname"; then 256034977a2fSmrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 256134977a2fSmrg fi 256234977a2fSmrg fi 2563ee3138f1Smrg ;; 2564ee3138f1Smrg 256534977a2fSmrg *.lo) 256634977a2fSmrg # Just add the directory containing the .lo file. 256734977a2fSmrg func_dirname "$file" "" "." 256834977a2fSmrg dir="$func_dirname_result" 2569ee3138f1Smrg ;; 2570ee3138f1Smrg 257134977a2fSmrg *) 257234977a2fSmrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 2573ee3138f1Smrg continue 2574ee3138f1Smrg ;; 257534977a2fSmrg esac 2576ee3138f1Smrg 257734977a2fSmrg # Get the absolute pathname. 257834977a2fSmrg absdir=`cd "$dir" && pwd` 257934977a2fSmrg test -n "$absdir" && dir="$absdir" 2580ee3138f1Smrg 258134977a2fSmrg # Now add the directory to shlibpath_var. 258234977a2fSmrg if eval "test -z \"\$$shlibpath_var\""; then 258334977a2fSmrg eval "$shlibpath_var=\"\$dir\"" 258434977a2fSmrg else 258534977a2fSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 258634977a2fSmrg fi 258734977a2fSmrg done 2588ee3138f1Smrg 258934977a2fSmrg # This variable tells wrapper scripts just to set shlibpath_var 259034977a2fSmrg # rather than running their programs. 259134977a2fSmrg libtool_execute_magic="$magic" 2592ee3138f1Smrg 259334977a2fSmrg # Check if any of the arguments is a wrapper script. 259434977a2fSmrg args= 259534977a2fSmrg for file 259634977a2fSmrg do 259734977a2fSmrg case $file in 2598b425557eSmrg -* | *.la | *.lo ) ;; 259934977a2fSmrg *) 260034977a2fSmrg # Do a test to see if this is really a libtool program. 260134977a2fSmrg if func_ltwrapper_script_p "$file"; then 260234977a2fSmrg func_source "$file" 260334977a2fSmrg # Transform arg to wrapped name. 260434977a2fSmrg file="$progdir/$program" 260534977a2fSmrg elif func_ltwrapper_executable_p "$file"; then 260634977a2fSmrg func_ltwrapper_scriptname "$file" 260734977a2fSmrg func_source "$func_ltwrapper_scriptname_result" 260834977a2fSmrg # Transform arg to wrapped name. 260934977a2fSmrg file="$progdir/$program" 261034977a2fSmrg fi 261134977a2fSmrg ;; 261234977a2fSmrg esac 261334977a2fSmrg # Quote arguments (to preserve shell metacharacters). 26143e72ca8cSmrg func_append_quoted args "$file" 261534977a2fSmrg done 2616ee3138f1Smrg 261734977a2fSmrg if test "X$opt_dry_run" = Xfalse; then 261834977a2fSmrg if test -n "$shlibpath_var"; then 261934977a2fSmrg # Export the shlibpath_var. 262034977a2fSmrg eval "export $shlibpath_var" 262134977a2fSmrg fi 2622ee3138f1Smrg 262334977a2fSmrg # Restore saved environment variables 262434977a2fSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 262534977a2fSmrg do 262634977a2fSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 262734977a2fSmrg $lt_var=\$save_$lt_var; export $lt_var 2628ee3138f1Smrg else 262934977a2fSmrg $lt_unset $lt_var 263034977a2fSmrg fi" 263134977a2fSmrg done 2632ee3138f1Smrg 263334977a2fSmrg # Now prepare to actually exec the command. 263434977a2fSmrg exec_cmd="\$cmd$args" 263534977a2fSmrg else 263634977a2fSmrg # Display what would be done. 263734977a2fSmrg if test -n "$shlibpath_var"; then 263834977a2fSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 2639b425557eSmrg echo "export $shlibpath_var" 264034977a2fSmrg fi 264134977a2fSmrg $ECHO "$cmd$args" 264234977a2fSmrg exit $EXIT_SUCCESS 264334977a2fSmrg fi 264434977a2fSmrg} 2645ee3138f1Smrg 26463e72ca8cSmrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 2647ee3138f1Smrg 2648ee3138f1Smrg 264934977a2fSmrg# func_mode_finish arg... 265034977a2fSmrgfunc_mode_finish () 265134977a2fSmrg{ 265234977a2fSmrg $opt_debug 26533e72ca8cSmrg libs= 26543e72ca8cSmrg libdirs= 265534977a2fSmrg admincmds= 2656ee3138f1Smrg 26573e72ca8cSmrg for opt in "$nonopt" ${1+"$@"} 26583e72ca8cSmrg do 26593e72ca8cSmrg if test -d "$opt"; then 26603e72ca8cSmrg func_append libdirs " $opt" 26613e72ca8cSmrg 26623e72ca8cSmrg elif test -f "$opt"; then 26633e72ca8cSmrg if func_lalib_unsafe_p "$opt"; then 26643e72ca8cSmrg func_append libs " $opt" 26653e72ca8cSmrg else 26663e72ca8cSmrg func_warning "\`$opt' is not a valid libtool archive" 26673e72ca8cSmrg fi 26683e72ca8cSmrg 26693e72ca8cSmrg else 26703e72ca8cSmrg func_fatal_error "invalid argument \`$opt'" 26713e72ca8cSmrg fi 26723e72ca8cSmrg done 26733e72ca8cSmrg 26743e72ca8cSmrg if test -n "$libs"; then 26753e72ca8cSmrg if test -n "$lt_sysroot"; then 26763e72ca8cSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 26773e72ca8cSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 26783e72ca8cSmrg else 26793e72ca8cSmrg sysroot_cmd= 26803e72ca8cSmrg fi 26813e72ca8cSmrg 26823e72ca8cSmrg # Remove sysroot references 26833e72ca8cSmrg if $opt_dry_run; then 26843e72ca8cSmrg for lib in $libs; do 26853e72ca8cSmrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 26863e72ca8cSmrg done 26873e72ca8cSmrg else 26883e72ca8cSmrg tmpdir=`func_mktempdir` 26893e72ca8cSmrg for lib in $libs; do 26903e72ca8cSmrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 26913e72ca8cSmrg > $tmpdir/tmp-la 26923e72ca8cSmrg mv -f $tmpdir/tmp-la $lib 26933e72ca8cSmrg done 26943e72ca8cSmrg ${RM}r "$tmpdir" 26953e72ca8cSmrg fi 26963e72ca8cSmrg fi 2697ee3138f1Smrg 26983e72ca8cSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 269934977a2fSmrg for libdir in $libdirs; do 270034977a2fSmrg if test -n "$finish_cmds"; then 270134977a2fSmrg # Do each command in the finish commands. 270234977a2fSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 270334977a2fSmrg'"$cmd"'"' 2704ee3138f1Smrg fi 270534977a2fSmrg if test -n "$finish_eval"; then 270634977a2fSmrg # Do the single finish_eval. 270734977a2fSmrg eval cmds=\"$finish_eval\" 27083e72ca8cSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 270934977a2fSmrg $cmds" 271034977a2fSmrg fi 271134977a2fSmrg done 271234977a2fSmrg fi 2713ee3138f1Smrg 271434977a2fSmrg # Exit here if they wanted silent mode. 271534977a2fSmrg $opt_silent && exit $EXIT_SUCCESS 2716ee3138f1Smrg 27173e72ca8cSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 27183e72ca8cSmrg echo "----------------------------------------------------------------------" 27193e72ca8cSmrg echo "Libraries have been installed in:" 27203e72ca8cSmrg for libdir in $libdirs; do 27213e72ca8cSmrg $ECHO " $libdir" 27223e72ca8cSmrg done 27233e72ca8cSmrg echo 27243e72ca8cSmrg echo "If you ever happen to want to link against installed libraries" 27253e72ca8cSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 27263e72ca8cSmrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 27273e72ca8cSmrg echo "flag during linking and do at least one of the following:" 27283e72ca8cSmrg if test -n "$shlibpath_var"; then 27293e72ca8cSmrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 27303e72ca8cSmrg echo " during execution" 27313e72ca8cSmrg fi 27323e72ca8cSmrg if test -n "$runpath_var"; then 27333e72ca8cSmrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 27343e72ca8cSmrg echo " during linking" 27353e72ca8cSmrg fi 27363e72ca8cSmrg if test -n "$hardcode_libdir_flag_spec"; then 27373e72ca8cSmrg libdir=LIBDIR 27383e72ca8cSmrg eval flag=\"$hardcode_libdir_flag_spec\" 2739ee3138f1Smrg 27403e72ca8cSmrg $ECHO " - use the \`$flag' linker flag" 27413e72ca8cSmrg fi 27423e72ca8cSmrg if test -n "$admincmds"; then 27433e72ca8cSmrg $ECHO " - have your system administrator run these commands:$admincmds" 27443e72ca8cSmrg fi 27453e72ca8cSmrg if test -f /etc/ld.so.conf; then 27463e72ca8cSmrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 27473e72ca8cSmrg fi 27483e72ca8cSmrg echo 274934977a2fSmrg 27503e72ca8cSmrg echo "See any operating system documentation about shared libraries for" 27513e72ca8cSmrg case $host in 27523e72ca8cSmrg solaris2.[6789]|solaris2.1[0-9]) 27533e72ca8cSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 27543e72ca8cSmrg echo "pages." 27553e72ca8cSmrg ;; 27563e72ca8cSmrg *) 27573e72ca8cSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 27583e72ca8cSmrg ;; 27593e72ca8cSmrg esac 27603e72ca8cSmrg echo "----------------------------------------------------------------------" 27613e72ca8cSmrg fi 276234977a2fSmrg exit $EXIT_SUCCESS 276334977a2fSmrg} 2764ee3138f1Smrg 27653e72ca8cSmrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 2766ee3138f1Smrg 276779a8a9c6Smrg 276834977a2fSmrg# func_mode_install arg... 276934977a2fSmrgfunc_mode_install () 277034977a2fSmrg{ 277134977a2fSmrg $opt_debug 277234977a2fSmrg # There may be an optional sh(1) argument at the beginning of 277334977a2fSmrg # install_prog (especially on Windows NT). 277434977a2fSmrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 277534977a2fSmrg # Allow the use of GNU shtool's install command. 2776b425557eSmrg case $nonopt in *shtool*) :;; *) false;; esac; then 277734977a2fSmrg # Aesthetically quote it. 277834977a2fSmrg func_quote_for_eval "$nonopt" 277934977a2fSmrg install_prog="$func_quote_for_eval_result " 278034977a2fSmrg arg=$1 278134977a2fSmrg shift 278234977a2fSmrg else 278334977a2fSmrg install_prog= 278434977a2fSmrg arg=$nonopt 2785ee3138f1Smrg fi 2786ee3138f1Smrg 278734977a2fSmrg # The real first argument should be the name of the installation program. 278834977a2fSmrg # Aesthetically quote it. 278934977a2fSmrg func_quote_for_eval "$arg" 27903e72ca8cSmrg func_append install_prog "$func_quote_for_eval_result" 2791b425557eSmrg install_shared_prog=$install_prog 2792b425557eSmrg case " $install_prog " in 2793b425557eSmrg *[\\\ /]cp\ *) install_cp=: ;; 2794b425557eSmrg *) install_cp=false ;; 2795b425557eSmrg esac 2796ee3138f1Smrg 279734977a2fSmrg # We need to accept at least all the BSD install flags. 279834977a2fSmrg dest= 279934977a2fSmrg files= 280034977a2fSmrg opts= 280134977a2fSmrg prev= 280234977a2fSmrg install_type= 280334977a2fSmrg isdir=no 280434977a2fSmrg stripme= 2805b425557eSmrg no_mode=: 280634977a2fSmrg for arg 280734977a2fSmrg do 2808b425557eSmrg arg2= 280934977a2fSmrg if test -n "$dest"; then 28103e72ca8cSmrg func_append files " $dest" 281134977a2fSmrg dest=$arg 281234977a2fSmrg continue 281334977a2fSmrg fi 2814ee3138f1Smrg 281534977a2fSmrg case $arg in 281634977a2fSmrg -d) isdir=yes ;; 281734977a2fSmrg -f) 2818b425557eSmrg if $install_cp; then :; else 2819b425557eSmrg prev=$arg 2820b425557eSmrg fi 282134977a2fSmrg ;; 282234977a2fSmrg -g | -m | -o) 282334977a2fSmrg prev=$arg 282434977a2fSmrg ;; 282534977a2fSmrg -s) 282634977a2fSmrg stripme=" -s" 282734977a2fSmrg continue 282834977a2fSmrg ;; 282934977a2fSmrg -*) 283034977a2fSmrg ;; 283134977a2fSmrg *) 283234977a2fSmrg # If the previous option needed an argument, then skip it. 283334977a2fSmrg if test -n "$prev"; then 2834b425557eSmrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 2835b425557eSmrg arg2=$install_override_mode 2836b425557eSmrg no_mode=false 2837b425557eSmrg fi 283834977a2fSmrg prev= 283934977a2fSmrg else 284034977a2fSmrg dest=$arg 284134977a2fSmrg continue 284234977a2fSmrg fi 284334977a2fSmrg ;; 284434977a2fSmrg esac 2845ee3138f1Smrg 284634977a2fSmrg # Aesthetically quote the argument. 284734977a2fSmrg func_quote_for_eval "$arg" 28483e72ca8cSmrg func_append install_prog " $func_quote_for_eval_result" 2849b425557eSmrg if test -n "$arg2"; then 2850b425557eSmrg func_quote_for_eval "$arg2" 2851b425557eSmrg fi 28523e72ca8cSmrg func_append install_shared_prog " $func_quote_for_eval_result" 285334977a2fSmrg done 285434977a2fSmrg 285534977a2fSmrg test -z "$install_prog" && \ 285634977a2fSmrg func_fatal_help "you must specify an install program" 285734977a2fSmrg 285834977a2fSmrg test -n "$prev" && \ 285934977a2fSmrg func_fatal_help "the \`$prev' option requires an argument" 286034977a2fSmrg 2861b425557eSmrg if test -n "$install_override_mode" && $no_mode; then 2862b425557eSmrg if $install_cp; then :; else 2863b425557eSmrg func_quote_for_eval "$install_override_mode" 28643e72ca8cSmrg func_append install_shared_prog " -m $func_quote_for_eval_result" 2865b425557eSmrg fi 2866b425557eSmrg fi 2867b425557eSmrg 286834977a2fSmrg if test -z "$files"; then 286934977a2fSmrg if test -z "$dest"; then 287034977a2fSmrg func_fatal_help "no file or destination specified" 287134977a2fSmrg else 287234977a2fSmrg func_fatal_help "you must specify a destination" 2873ee3138f1Smrg fi 2874ee3138f1Smrg fi 2875ee3138f1Smrg 287634977a2fSmrg # Strip any trailing slash from the destination. 287734977a2fSmrg func_stripname '' '/' "$dest" 287834977a2fSmrg dest=$func_stripname_result 2879ee3138f1Smrg 288034977a2fSmrg # Check to see that the destination is a directory. 288134977a2fSmrg test -d "$dest" && isdir=yes 288234977a2fSmrg if test "$isdir" = yes; then 288334977a2fSmrg destdir="$dest" 288434977a2fSmrg destname= 288534977a2fSmrg else 288634977a2fSmrg func_dirname_and_basename "$dest" "" "." 288734977a2fSmrg destdir="$func_dirname_result" 288834977a2fSmrg destname="$func_basename_result" 288934977a2fSmrg 289034977a2fSmrg # Not a directory, so check to see that there is only one file specified. 289134977a2fSmrg set dummy $files; shift 289234977a2fSmrg test "$#" -gt 1 && \ 289334977a2fSmrg func_fatal_help "\`$dest' is not a directory" 289434977a2fSmrg fi 289534977a2fSmrg case $destdir in 289634977a2fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 2897ee3138f1Smrg *) 289834977a2fSmrg for file in $files; do 289934977a2fSmrg case $file in 290034977a2fSmrg *.lo) ;; 290134977a2fSmrg *) 290234977a2fSmrg func_fatal_help "\`$destdir' must be an absolute directory name" 290334977a2fSmrg ;; 290434977a2fSmrg esac 290534977a2fSmrg done 2906ee3138f1Smrg ;; 2907ee3138f1Smrg esac 2908ee3138f1Smrg 290934977a2fSmrg # This variable tells wrapper scripts just to set variables rather 291034977a2fSmrg # than running their programs. 291134977a2fSmrg libtool_install_magic="$magic" 2912ee3138f1Smrg 291334977a2fSmrg staticlibs= 291434977a2fSmrg future_libdirs= 291534977a2fSmrg current_libdirs= 291634977a2fSmrg for file in $files; do 2917ee3138f1Smrg 291834977a2fSmrg # Do each installation. 291934977a2fSmrg case $file in 292034977a2fSmrg *.$libext) 292134977a2fSmrg # Do the static libraries later. 29223e72ca8cSmrg func_append staticlibs " $file" 292334977a2fSmrg ;; 292434977a2fSmrg 292534977a2fSmrg *.la) 29263e72ca8cSmrg func_resolve_sysroot "$file" 29273e72ca8cSmrg file=$func_resolve_sysroot_result 29283e72ca8cSmrg 292934977a2fSmrg # Check to see that this really is a libtool archive. 293034977a2fSmrg func_lalib_unsafe_p "$file" \ 293134977a2fSmrg || func_fatal_help "\`$file' is not a valid libtool archive" 293234977a2fSmrg 293334977a2fSmrg library_names= 293434977a2fSmrg old_library= 293534977a2fSmrg relink_command= 293634977a2fSmrg func_source "$file" 293734977a2fSmrg 293834977a2fSmrg # Add the libdir to current_libdirs if it is the destination. 293934977a2fSmrg if test "X$destdir" = "X$libdir"; then 294034977a2fSmrg case "$current_libdirs " in 294134977a2fSmrg *" $libdir "*) ;; 29423e72ca8cSmrg *) func_append current_libdirs " $libdir" ;; 2943ee3138f1Smrg esac 294434977a2fSmrg else 294534977a2fSmrg # Note the libdir as a future libdir. 294634977a2fSmrg case "$future_libdirs " in 294734977a2fSmrg *" $libdir "*) ;; 29483e72ca8cSmrg *) func_append future_libdirs " $libdir" ;; 294934977a2fSmrg esac 295034977a2fSmrg fi 2951ee3138f1Smrg 295234977a2fSmrg func_dirname "$file" "/" "" 295334977a2fSmrg dir="$func_dirname_result" 29543e72ca8cSmrg func_append dir "$objdir" 295534977a2fSmrg 295634977a2fSmrg if test -n "$relink_command"; then 295734977a2fSmrg # Determine the prefix the user has applied to our future dir. 2958b425557eSmrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 295934977a2fSmrg 296034977a2fSmrg # Don't allow the user to place us outside of our expected 296134977a2fSmrg # location b/c this prevents finding dependent libraries that 296234977a2fSmrg # are installed to the same prefix. 296334977a2fSmrg # At present, this check doesn't affect windows .dll's that 296434977a2fSmrg # are installed into $libdir/../bin (currently, that works fine) 296534977a2fSmrg # but it's something to keep an eye on. 296634977a2fSmrg test "$inst_prefix_dir" = "$destdir" && \ 296734977a2fSmrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 296834977a2fSmrg 296934977a2fSmrg if test -n "$inst_prefix_dir"; then 297034977a2fSmrg # Stick the inst_prefix_dir data into the link command. 2971b425557eSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 297234977a2fSmrg else 2973b425557eSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 297434977a2fSmrg fi 297534977a2fSmrg 297634977a2fSmrg func_warning "relinking \`$file'" 297734977a2fSmrg func_show_eval "$relink_command" \ 297834977a2fSmrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 297934977a2fSmrg fi 298034977a2fSmrg 298134977a2fSmrg # See the names of the shared library. 298234977a2fSmrg set dummy $library_names; shift 298334977a2fSmrg if test -n "$1"; then 298434977a2fSmrg realname="$1" 298534977a2fSmrg shift 298634977a2fSmrg 298734977a2fSmrg srcname="$realname" 298834977a2fSmrg test -n "$relink_command" && srcname="$realname"T 298934977a2fSmrg 299034977a2fSmrg # Install the shared library and build the symlinks. 2991b425557eSmrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 299234977a2fSmrg 'exit $?' 299334977a2fSmrg tstripme="$stripme" 299434977a2fSmrg case $host_os in 299534977a2fSmrg cygwin* | mingw* | pw32* | cegcc*) 299634977a2fSmrg case $realname in 299734977a2fSmrg *.dll.a) 299834977a2fSmrg tstripme="" 299934977a2fSmrg ;; 300034977a2fSmrg esac 3001ee3138f1Smrg ;; 3002ee3138f1Smrg esac 300334977a2fSmrg if test -n "$tstripme" && test -n "$striplib"; then 300434977a2fSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 300579a8a9c6Smrg fi 300634977a2fSmrg 300734977a2fSmrg if test "$#" -gt 0; then 300834977a2fSmrg # Delete the old symlinks, and create new ones. 300934977a2fSmrg # Try `ln -sf' first, because the `ln' binary might depend on 301034977a2fSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 301134977a2fSmrg # so we also need to try rm && ln -s. 301234977a2fSmrg for linkname 301334977a2fSmrg do 301434977a2fSmrg test "$linkname" != "$realname" \ 301534977a2fSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 3016ee3138f1Smrg done 3017ee3138f1Smrg fi 3018ee3138f1Smrg 301934977a2fSmrg # Do each command in the postinstall commands. 302034977a2fSmrg lib="$destdir/$realname" 302134977a2fSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 3022ee3138f1Smrg fi 3023ee3138f1Smrg 302434977a2fSmrg # Install the pseudo-library for information purposes. 302534977a2fSmrg func_basename "$file" 302634977a2fSmrg name="$func_basename_result" 302734977a2fSmrg instname="$dir/$name"i 302834977a2fSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 3029ee3138f1Smrg 303034977a2fSmrg # Maybe install the static library, too. 30313e72ca8cSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 303234977a2fSmrg ;; 3033ee3138f1Smrg 303434977a2fSmrg *.lo) 303534977a2fSmrg # Install (i.e. copy) a libtool object. 3036ee3138f1Smrg 303734977a2fSmrg # Figure out destination file name, if it wasn't already specified. 303834977a2fSmrg if test -n "$destname"; then 303934977a2fSmrg destfile="$destdir/$destname" 304034977a2fSmrg else 304134977a2fSmrg func_basename "$file" 304234977a2fSmrg destfile="$func_basename_result" 304334977a2fSmrg destfile="$destdir/$destfile" 304434977a2fSmrg fi 304534977a2fSmrg 304634977a2fSmrg # Deduce the name of the destination old-style object file. 304734977a2fSmrg case $destfile in 304834977a2fSmrg *.lo) 304934977a2fSmrg func_lo2o "$destfile" 305034977a2fSmrg staticdest=$func_lo2o_result 305134977a2fSmrg ;; 305234977a2fSmrg *.$objext) 305334977a2fSmrg staticdest="$destfile" 305434977a2fSmrg destfile= 305534977a2fSmrg ;; 305634977a2fSmrg *) 305734977a2fSmrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 305834977a2fSmrg ;; 3059ee3138f1Smrg esac 3060ee3138f1Smrg 306134977a2fSmrg # Install the libtool object if requested. 306234977a2fSmrg test -n "$destfile" && \ 306334977a2fSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 306434977a2fSmrg 306534977a2fSmrg # Install the old object if enabled. 306634977a2fSmrg if test "$build_old_libs" = yes; then 306734977a2fSmrg # Deduce the name of the old-style object file. 306834977a2fSmrg func_lo2o "$file" 306934977a2fSmrg staticobj=$func_lo2o_result 307034977a2fSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 3071ee3138f1Smrg fi 307234977a2fSmrg exit $EXIT_SUCCESS 307334977a2fSmrg ;; 3074ee3138f1Smrg 307534977a2fSmrg *) 307634977a2fSmrg # Figure out destination file name, if it wasn't already specified. 307734977a2fSmrg if test -n "$destname"; then 307834977a2fSmrg destfile="$destdir/$destname" 307934977a2fSmrg else 308034977a2fSmrg func_basename "$file" 308134977a2fSmrg destfile="$func_basename_result" 308234977a2fSmrg destfile="$destdir/$destfile" 308334977a2fSmrg fi 3084ee3138f1Smrg 308534977a2fSmrg # If the file is missing, and there is a .exe on the end, strip it 308634977a2fSmrg # because it is most likely a libtool script we actually want to 308734977a2fSmrg # install 308834977a2fSmrg stripped_ext="" 308934977a2fSmrg case $file in 309034977a2fSmrg *.exe) 309134977a2fSmrg if test ! -f "$file"; then 309234977a2fSmrg func_stripname '' '.exe' "$file" 309334977a2fSmrg file=$func_stripname_result 309434977a2fSmrg stripped_ext=".exe" 309534977a2fSmrg fi 309634977a2fSmrg ;; 309734977a2fSmrg esac 3098ee3138f1Smrg 309934977a2fSmrg # Do a test to see if this is really a libtool program. 310034977a2fSmrg case $host in 310134977a2fSmrg *cygwin* | *mingw*) 310234977a2fSmrg if func_ltwrapper_executable_p "$file"; then 310334977a2fSmrg func_ltwrapper_scriptname "$file" 310434977a2fSmrg wrapper=$func_ltwrapper_scriptname_result 310534977a2fSmrg else 310634977a2fSmrg func_stripname '' '.exe' "$file" 310734977a2fSmrg wrapper=$func_stripname_result 310834977a2fSmrg fi 310934977a2fSmrg ;; 311034977a2fSmrg *) 311134977a2fSmrg wrapper=$file 311234977a2fSmrg ;; 311334977a2fSmrg esac 311434977a2fSmrg if func_ltwrapper_script_p "$wrapper"; then 311534977a2fSmrg notinst_deplibs= 311634977a2fSmrg relink_command= 3117ee3138f1Smrg 311834977a2fSmrg func_source "$wrapper" 311934977a2fSmrg 312034977a2fSmrg # Check the variables that should have been set. 312134977a2fSmrg test -z "$generated_by_libtool_version" && \ 312234977a2fSmrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 312334977a2fSmrg 312434977a2fSmrg finalize=yes 312534977a2fSmrg for lib in $notinst_deplibs; do 312634977a2fSmrg # Check to see that each library is installed. 312734977a2fSmrg libdir= 312834977a2fSmrg if test -f "$lib"; then 312934977a2fSmrg func_source "$lib" 313034977a2fSmrg fi 3131b425557eSmrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 313234977a2fSmrg if test -n "$libdir" && test ! -f "$libfile"; then 313334977a2fSmrg func_warning "\`$lib' has not been installed in \`$libdir'" 313434977a2fSmrg finalize=no 313534977a2fSmrg fi 313634977a2fSmrg done 313734977a2fSmrg 313834977a2fSmrg relink_command= 313934977a2fSmrg func_source "$wrapper" 314034977a2fSmrg 314134977a2fSmrg outputname= 314234977a2fSmrg if test "$fast_install" = no && test -n "$relink_command"; then 314334977a2fSmrg $opt_dry_run || { 314434977a2fSmrg if test "$finalize" = yes; then 314534977a2fSmrg tmpdir=`func_mktempdir` 314634977a2fSmrg func_basename "$file$stripped_ext" 314734977a2fSmrg file="$func_basename_result" 314834977a2fSmrg outputname="$tmpdir/$file" 314934977a2fSmrg # Replace the output file specification. 3150b425557eSmrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 315134977a2fSmrg 315234977a2fSmrg $opt_silent || { 315334977a2fSmrg func_quote_for_expand "$relink_command" 315434977a2fSmrg eval "func_echo $func_quote_for_expand_result" 315534977a2fSmrg } 315634977a2fSmrg if eval "$relink_command"; then : 315734977a2fSmrg else 315834977a2fSmrg func_error "error: relink \`$file' with the above command before installing it" 315934977a2fSmrg $opt_dry_run || ${RM}r "$tmpdir" 316034977a2fSmrg continue 316134977a2fSmrg fi 316234977a2fSmrg file="$outputname" 316334977a2fSmrg else 316434977a2fSmrg func_warning "cannot relink \`$file'" 316534977a2fSmrg fi 316634977a2fSmrg } 3167ee3138f1Smrg else 316834977a2fSmrg # Install the binary that we compiled earlier. 3169b425557eSmrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 3170ee3138f1Smrg fi 317134977a2fSmrg fi 3172ee3138f1Smrg 317334977a2fSmrg # remove .exe since cygwin /usr/bin/install will append another 317434977a2fSmrg # one anyway 317534977a2fSmrg case $install_prog,$host in 317634977a2fSmrg */usr/bin/install*,*cygwin*) 317734977a2fSmrg case $file:$destfile in 317834977a2fSmrg *.exe:*.exe) 317934977a2fSmrg # this is ok 318034977a2fSmrg ;; 318134977a2fSmrg *.exe:*) 318234977a2fSmrg destfile=$destfile.exe 318334977a2fSmrg ;; 318434977a2fSmrg *:*.exe) 318534977a2fSmrg func_stripname '' '.exe' "$destfile" 318634977a2fSmrg destfile=$func_stripname_result 318734977a2fSmrg ;; 318834977a2fSmrg esac 3189ee3138f1Smrg ;; 3190ee3138f1Smrg esac 319134977a2fSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 319234977a2fSmrg $opt_dry_run || if test -n "$outputname"; then 319334977a2fSmrg ${RM}r "$tmpdir" 319434977a2fSmrg fi 319534977a2fSmrg ;; 319634977a2fSmrg esac 319734977a2fSmrg done 3198ee3138f1Smrg 319934977a2fSmrg for file in $staticlibs; do 320034977a2fSmrg func_basename "$file" 320134977a2fSmrg name="$func_basename_result" 320234977a2fSmrg 320334977a2fSmrg # Set up the ranlib parameters. 320434977a2fSmrg oldlib="$destdir/$name" 32053e72ca8cSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 32063e72ca8cSmrg tool_oldlib=$func_to_tool_file_result 320734977a2fSmrg 320834977a2fSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 320934977a2fSmrg 321034977a2fSmrg if test -n "$stripme" && test -n "$old_striplib"; then 32113e72ca8cSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 321234977a2fSmrg fi 321334977a2fSmrg 321434977a2fSmrg # Do each command in the postinstall commands. 321534977a2fSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 321634977a2fSmrg done 321734977a2fSmrg 321834977a2fSmrg test -n "$future_libdirs" && \ 321934977a2fSmrg func_warning "remember to run \`$progname --finish$future_libdirs'" 322034977a2fSmrg 322134977a2fSmrg if test -n "$current_libdirs"; then 322234977a2fSmrg # Maybe just do a dry run. 322334977a2fSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 322434977a2fSmrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 322534977a2fSmrg else 322634977a2fSmrg exit $EXIT_SUCCESS 322734977a2fSmrg fi 322834977a2fSmrg} 322934977a2fSmrg 32303e72ca8cSmrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 323134977a2fSmrg 323234977a2fSmrg 323334977a2fSmrg# func_generate_dlsyms outputname originator pic_p 323434977a2fSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 323534977a2fSmrg# a dlpreopen symbol table. 323634977a2fSmrgfunc_generate_dlsyms () 323734977a2fSmrg{ 323834977a2fSmrg $opt_debug 323934977a2fSmrg my_outputname="$1" 324034977a2fSmrg my_originator="$2" 324134977a2fSmrg my_pic_p="${3-no}" 324234977a2fSmrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 324334977a2fSmrg my_dlsyms= 324434977a2fSmrg 324534977a2fSmrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 324634977a2fSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 324734977a2fSmrg my_dlsyms="${my_outputname}S.c" 324834977a2fSmrg else 324934977a2fSmrg func_error "not configured to extract global symbols from dlpreopened files" 325034977a2fSmrg fi 325134977a2fSmrg fi 325234977a2fSmrg 325334977a2fSmrg if test -n "$my_dlsyms"; then 325434977a2fSmrg case $my_dlsyms in 325534977a2fSmrg "") ;; 325634977a2fSmrg *.c) 325734977a2fSmrg # Discover the nlist of each of the dlfiles. 325834977a2fSmrg nlist="$output_objdir/${my_outputname}.nm" 325934977a2fSmrg 326034977a2fSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 326134977a2fSmrg 326234977a2fSmrg # Parse the name list into a source file. 326334977a2fSmrg func_verbose "creating $output_objdir/$my_dlsyms" 326434977a2fSmrg 326534977a2fSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 326634977a2fSmrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 326734977a2fSmrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 326834977a2fSmrg 326934977a2fSmrg#ifdef __cplusplus 327034977a2fSmrgextern \"C\" { 327134977a2fSmrg#endif 327234977a2fSmrg 3273b425557eSmrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 3274b425557eSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 3275b425557eSmrg#endif 3276b425557eSmrg 32773e72ca8cSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 32783e72ca8cSmrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 32793e72ca8cSmrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 32803e72ca8cSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 32813e72ca8cSmrg# define LT_DLSYM_CONST 32823e72ca8cSmrg#elif defined(__osf__) 32833e72ca8cSmrg/* This system does not cope well with relocations in const data. */ 32843e72ca8cSmrg# define LT_DLSYM_CONST 32853e72ca8cSmrg#else 32863e72ca8cSmrg# define LT_DLSYM_CONST const 32873e72ca8cSmrg#endif 32883e72ca8cSmrg 328934977a2fSmrg/* External symbol declarations for the compiler. */\ 329034977a2fSmrg" 329134977a2fSmrg 329234977a2fSmrg if test "$dlself" = yes; then 329334977a2fSmrg func_verbose "generating symbol list for \`$output'" 329434977a2fSmrg 329534977a2fSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 329634977a2fSmrg 329734977a2fSmrg # Add our own program objects to the symbol list. 3298b425557eSmrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 329934977a2fSmrg for progfile in $progfiles; do 33003e72ca8cSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 33013e72ca8cSmrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 33023e72ca8cSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 330334977a2fSmrg done 330434977a2fSmrg 330534977a2fSmrg if test -n "$exclude_expsyms"; then 330634977a2fSmrg $opt_dry_run || { 330734977a2fSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 330834977a2fSmrg eval '$MV "$nlist"T "$nlist"' 330934977a2fSmrg } 3310ee3138f1Smrg fi 331134977a2fSmrg 331234977a2fSmrg if test -n "$export_symbols_regex"; then 331334977a2fSmrg $opt_dry_run || { 331434977a2fSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 331534977a2fSmrg eval '$MV "$nlist"T "$nlist"' 331634977a2fSmrg } 331734977a2fSmrg fi 331834977a2fSmrg 331934977a2fSmrg # Prepare the list of exported symbols 332034977a2fSmrg if test -z "$export_symbols"; then 332134977a2fSmrg export_symbols="$output_objdir/$outputname.exp" 332234977a2fSmrg $opt_dry_run || { 332334977a2fSmrg $RM $export_symbols 332434977a2fSmrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 332534977a2fSmrg case $host in 332634977a2fSmrg *cygwin* | *mingw* | *cegcc* ) 332734977a2fSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 332834977a2fSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 332934977a2fSmrg ;; 333034977a2fSmrg esac 333134977a2fSmrg } 3332ee3138f1Smrg else 333334977a2fSmrg $opt_dry_run || { 333434977a2fSmrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 333534977a2fSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 333634977a2fSmrg eval '$MV "$nlist"T "$nlist"' 333734977a2fSmrg case $host in 3338b425557eSmrg *cygwin* | *mingw* | *cegcc* ) 333934977a2fSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 334034977a2fSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 334134977a2fSmrg ;; 334234977a2fSmrg esac 334334977a2fSmrg } 3344ee3138f1Smrg fi 334534977a2fSmrg fi 3346ee3138f1Smrg 334734977a2fSmrg for dlprefile in $dlprefiles; do 334834977a2fSmrg func_verbose "extracting global C symbols from \`$dlprefile'" 334934977a2fSmrg func_basename "$dlprefile" 335034977a2fSmrg name="$func_basename_result" 33513e72ca8cSmrg case $host in 33523e72ca8cSmrg *cygwin* | *mingw* | *cegcc* ) 33533e72ca8cSmrg # if an import library, we need to obtain dlname 33543e72ca8cSmrg if func_win32_import_lib_p "$dlprefile"; then 33553e72ca8cSmrg func_tr_sh "$dlprefile" 33563e72ca8cSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 33573e72ca8cSmrg dlprefile_dlbasename="" 33583e72ca8cSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 33593e72ca8cSmrg # Use subshell, to avoid clobbering current variable values 33603e72ca8cSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 33613e72ca8cSmrg if test -n "$dlprefile_dlname" ; then 33623e72ca8cSmrg func_basename "$dlprefile_dlname" 33633e72ca8cSmrg dlprefile_dlbasename="$func_basename_result" 33643e72ca8cSmrg else 33653e72ca8cSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 33663e72ca8cSmrg $sharedlib_from_linklib_cmd "$dlprefile" 33673e72ca8cSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 33683e72ca8cSmrg fi 33693e72ca8cSmrg fi 33703e72ca8cSmrg $opt_dry_run || { 33713e72ca8cSmrg if test -n "$dlprefile_dlbasename" ; then 33723e72ca8cSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 33733e72ca8cSmrg else 33743e72ca8cSmrg func_warning "Could not compute DLL name from $name" 33753e72ca8cSmrg eval '$ECHO ": $name " >> "$nlist"' 33763e72ca8cSmrg fi 33773e72ca8cSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 33783e72ca8cSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 33793e72ca8cSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 33803e72ca8cSmrg } 33813e72ca8cSmrg else # not an import lib 33823e72ca8cSmrg $opt_dry_run || { 33833e72ca8cSmrg eval '$ECHO ": $name " >> "$nlist"' 33843e72ca8cSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 33853e72ca8cSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 33863e72ca8cSmrg } 33873e72ca8cSmrg fi 33883e72ca8cSmrg ;; 33893e72ca8cSmrg *) 33903e72ca8cSmrg $opt_dry_run || { 33913e72ca8cSmrg eval '$ECHO ": $name " >> "$nlist"' 33923e72ca8cSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 33933e72ca8cSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 33943e72ca8cSmrg } 33953e72ca8cSmrg ;; 33963e72ca8cSmrg esac 339734977a2fSmrg done 339834977a2fSmrg 339934977a2fSmrg $opt_dry_run || { 340034977a2fSmrg # Make sure we have at least an empty file. 340134977a2fSmrg test -f "$nlist" || : > "$nlist" 340234977a2fSmrg 340334977a2fSmrg if test -n "$exclude_expsyms"; then 340434977a2fSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 340534977a2fSmrg $MV "$nlist"T "$nlist" 3406ee3138f1Smrg fi 340734977a2fSmrg 340834977a2fSmrg # Try sorting and uniquifying the output. 340934977a2fSmrg if $GREP -v "^: " < "$nlist" | 341034977a2fSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 341134977a2fSmrg sort -k 3 341234977a2fSmrg else 341334977a2fSmrg sort +2 341434977a2fSmrg fi | 341534977a2fSmrg uniq > "$nlist"S; then 341634977a2fSmrg : 3417ee3138f1Smrg else 341834977a2fSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 3419ee3138f1Smrg fi 3420ee3138f1Smrg 342134977a2fSmrg if test -f "$nlist"S; then 342234977a2fSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 3423ee3138f1Smrg else 3424b425557eSmrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 3425ee3138f1Smrg fi 3426ee3138f1Smrg 3427b425557eSmrg echo >> "$output_objdir/$my_dlsyms" "\ 3428ee3138f1Smrg 342934977a2fSmrg/* The mapping between symbol names and symbols. */ 343034977a2fSmrgtypedef struct { 343134977a2fSmrg const char *name; 343234977a2fSmrg void *address; 343334977a2fSmrg} lt_dlsymlist; 34343e72ca8cSmrgextern LT_DLSYM_CONST lt_dlsymlist 343534977a2fSmrglt_${my_prefix}_LTX_preloaded_symbols[]; 34363e72ca8cSmrgLT_DLSYM_CONST lt_dlsymlist 343734977a2fSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 343834977a2fSmrg{\ 343934977a2fSmrg { \"$my_originator\", (void *) 0 }," 3440ee3138f1Smrg 344134977a2fSmrg case $need_lib_prefix in 344234977a2fSmrg no) 344334977a2fSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 344434977a2fSmrg ;; 344534977a2fSmrg *) 344634977a2fSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 344734977a2fSmrg ;; 344834977a2fSmrg esac 3449b425557eSmrg echo >> "$output_objdir/$my_dlsyms" "\ 345034977a2fSmrg {0, (void *) 0} 345134977a2fSmrg}; 3452ee3138f1Smrg 345334977a2fSmrg/* This works around a problem in FreeBSD linker */ 345434977a2fSmrg#ifdef FREEBSD_WORKAROUND 345534977a2fSmrgstatic const void *lt_preloaded_setup() { 345634977a2fSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 345734977a2fSmrg} 345834977a2fSmrg#endif 345934977a2fSmrg 346034977a2fSmrg#ifdef __cplusplus 346134977a2fSmrg} 346234977a2fSmrg#endif\ 346334977a2fSmrg" 346434977a2fSmrg } # !$opt_dry_run 346534977a2fSmrg 346634977a2fSmrg pic_flag_for_symtable= 346734977a2fSmrg case "$compile_command " in 346834977a2fSmrg *" -static "*) ;; 346934977a2fSmrg *) 347034977a2fSmrg case $host in 347134977a2fSmrg # compiling the symbol table file with pic_flag works around 347234977a2fSmrg # a FreeBSD bug that causes programs to crash when -lm is 347334977a2fSmrg # linked before any other PIC object. But we must not use 347434977a2fSmrg # pic_flag when linking with -static. The problem exists in 347534977a2fSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 34763e72ca8cSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 347734977a2fSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 347834977a2fSmrg *-*-hpux*) 347934977a2fSmrg pic_flag_for_symtable=" $pic_flag" ;; 348034977a2fSmrg *) 348134977a2fSmrg if test "X$my_pic_p" != Xno; then 348234977a2fSmrg pic_flag_for_symtable=" $pic_flag" 3483ee3138f1Smrg fi 348434977a2fSmrg ;; 348534977a2fSmrg esac 348634977a2fSmrg ;; 348734977a2fSmrg esac 348834977a2fSmrg symtab_cflags= 348934977a2fSmrg for arg in $LTCFLAGS; do 349034977a2fSmrg case $arg in 349134977a2fSmrg -pie | -fpie | -fPIE) ;; 34923e72ca8cSmrg *) func_append symtab_cflags " $arg" ;; 349334977a2fSmrg esac 349434977a2fSmrg done 3495ee3138f1Smrg 349634977a2fSmrg # Now compile the dynamic symbol file. 349734977a2fSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 3498ee3138f1Smrg 349934977a2fSmrg # Clean up the generated files. 350034977a2fSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 3501ee3138f1Smrg 350234977a2fSmrg # Transform the symbol file into the correct name. 350334977a2fSmrg symfileobj="$output_objdir/${my_outputname}S.$objext" 350434977a2fSmrg case $host in 350534977a2fSmrg *cygwin* | *mingw* | *cegcc* ) 350634977a2fSmrg if test -f "$output_objdir/$my_outputname.def"; then 3507b425557eSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3508b425557eSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 350934977a2fSmrg else 3510b425557eSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3511b425557eSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3512ee3138f1Smrg fi 351334977a2fSmrg ;; 351434977a2fSmrg *) 3515b425557eSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3516b425557eSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351734977a2fSmrg ;; 351834977a2fSmrg esac 351934977a2fSmrg ;; 352034977a2fSmrg *) 352134977a2fSmrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 352234977a2fSmrg ;; 352334977a2fSmrg esac 352434977a2fSmrg else 352534977a2fSmrg # We keep going just in case the user didn't refer to 352634977a2fSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 352734977a2fSmrg # really was required. 3528ee3138f1Smrg 352934977a2fSmrg # Nullify the symbol file. 3530b425557eSmrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 3531b425557eSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 353234977a2fSmrg fi 353334977a2fSmrg} 3534ee3138f1Smrg 353534977a2fSmrg# func_win32_libid arg 353634977a2fSmrg# return the library type of file 'arg' 353734977a2fSmrg# 353834977a2fSmrg# Need a lot of goo to handle *both* DLLs and import libs 353934977a2fSmrg# Has to be a shell function in order to 'eat' the argument 354034977a2fSmrg# that is supplied when $file_magic_command is called. 3541b425557eSmrg# Despite the name, also deal with 64 bit binaries. 354234977a2fSmrgfunc_win32_libid () 354334977a2fSmrg{ 354434977a2fSmrg $opt_debug 354534977a2fSmrg win32_libid_type="unknown" 354634977a2fSmrg win32_fileres=`file -L $1 2>/dev/null` 354734977a2fSmrg case $win32_fileres in 354834977a2fSmrg *ar\ archive\ import\ library*) # definitely import 354934977a2fSmrg win32_libid_type="x86 archive import" 355034977a2fSmrg ;; 355134977a2fSmrg *ar\ archive*) # could be an import, or static 3552b425557eSmrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 355334977a2fSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 3554b425557eSmrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 35553e72ca8cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 35563e72ca8cSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 355734977a2fSmrg $SED -n -e ' 355834977a2fSmrg 1,100{ 355934977a2fSmrg / I /{ 356034977a2fSmrg s,.*,import, 356134977a2fSmrg p 356234977a2fSmrg q 356334977a2fSmrg } 356434977a2fSmrg }'` 356534977a2fSmrg case $win32_nmres in 356634977a2fSmrg import*) win32_libid_type="x86 archive import";; 356734977a2fSmrg *) win32_libid_type="x86 archive static";; 356834977a2fSmrg esac 356934977a2fSmrg fi 357034977a2fSmrg ;; 357134977a2fSmrg *DLL*) 357234977a2fSmrg win32_libid_type="x86 DLL" 357334977a2fSmrg ;; 357434977a2fSmrg *executable*) # but shell scripts are "executable" too... 357534977a2fSmrg case $win32_fileres in 357634977a2fSmrg *MS\ Windows\ PE\ Intel*) 357734977a2fSmrg win32_libid_type="x86 DLL" 357834977a2fSmrg ;; 357934977a2fSmrg esac 358034977a2fSmrg ;; 358134977a2fSmrg esac 358234977a2fSmrg $ECHO "$win32_libid_type" 358334977a2fSmrg} 3584ee3138f1Smrg 35853e72ca8cSmrg# func_cygming_dll_for_implib ARG 35863e72ca8cSmrg# 35873e72ca8cSmrg# Platform-specific function to extract the 35883e72ca8cSmrg# name of the DLL associated with the specified 35893e72ca8cSmrg# import library ARG. 35903e72ca8cSmrg# Invoked by eval'ing the libtool variable 35913e72ca8cSmrg# $sharedlib_from_linklib_cmd 35923e72ca8cSmrg# Result is available in the variable 35933e72ca8cSmrg# $sharedlib_from_linklib_result 35943e72ca8cSmrgfunc_cygming_dll_for_implib () 35953e72ca8cSmrg{ 35963e72ca8cSmrg $opt_debug 35973e72ca8cSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 35983e72ca8cSmrg} 35993e72ca8cSmrg 36003e72ca8cSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 36013e72ca8cSmrg# 36023e72ca8cSmrg# The is the core of a fallback implementation of a 36033e72ca8cSmrg# platform-specific function to extract the name of the 36043e72ca8cSmrg# DLL associated with the specified import library LIBNAME. 36053e72ca8cSmrg# 36063e72ca8cSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 36073e72ca8cSmrg# on the platform and compiler that created the implib. 36083e72ca8cSmrg# 36093e72ca8cSmrg# Echos the name of the DLL associated with the 36103e72ca8cSmrg# specified import library. 36113e72ca8cSmrgfunc_cygming_dll_for_implib_fallback_core () 36123e72ca8cSmrg{ 36133e72ca8cSmrg $opt_debug 36143e72ca8cSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 36153e72ca8cSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 36163e72ca8cSmrg $SED '/^Contents of section '"$match_literal"':/{ 36173e72ca8cSmrg # Place marker at beginning of archive member dllname section 36183e72ca8cSmrg s/.*/====MARK====/ 36193e72ca8cSmrg p 36203e72ca8cSmrg d 36213e72ca8cSmrg } 36223e72ca8cSmrg # These lines can sometimes be longer than 43 characters, but 36233e72ca8cSmrg # are always uninteresting 36243e72ca8cSmrg /:[ ]*file format pe[i]\{,1\}-/d 36253e72ca8cSmrg /^In archive [^:]*:/d 36263e72ca8cSmrg # Ensure marker is printed 36273e72ca8cSmrg /^====MARK====/p 36283e72ca8cSmrg # Remove all lines with less than 43 characters 36293e72ca8cSmrg /^.\{43\}/!d 36303e72ca8cSmrg # From remaining lines, remove first 43 characters 36313e72ca8cSmrg s/^.\{43\}//' | 36323e72ca8cSmrg $SED -n ' 36333e72ca8cSmrg # Join marker and all lines until next marker into a single line 36343e72ca8cSmrg /^====MARK====/ b para 36353e72ca8cSmrg H 36363e72ca8cSmrg $ b para 36373e72ca8cSmrg b 36383e72ca8cSmrg :para 36393e72ca8cSmrg x 36403e72ca8cSmrg s/\n//g 36413e72ca8cSmrg # Remove the marker 36423e72ca8cSmrg s/^====MARK====// 36433e72ca8cSmrg # Remove trailing dots and whitespace 36443e72ca8cSmrg s/[\. \t]*$// 36453e72ca8cSmrg # Print 36463e72ca8cSmrg /./p' | 36473e72ca8cSmrg # we now have a list, one entry per line, of the stringified 36483e72ca8cSmrg # contents of the appropriate section of all members of the 36493e72ca8cSmrg # archive which possess that section. Heuristic: eliminate 36503e72ca8cSmrg # all those which have a first or second character that is 36513e72ca8cSmrg # a '.' (that is, objdump's representation of an unprintable 36523e72ca8cSmrg # character.) This should work for all archives with less than 36533e72ca8cSmrg # 0x302f exports -- but will fail for DLLs whose name actually 36543e72ca8cSmrg # begins with a literal '.' or a single character followed by 36553e72ca8cSmrg # a '.'. 36563e72ca8cSmrg # 36573e72ca8cSmrg # Of those that remain, print the first one. 36583e72ca8cSmrg $SED -e '/^\./d;/^.\./d;q' 36593e72ca8cSmrg} 36603e72ca8cSmrg 36613e72ca8cSmrg# func_cygming_gnu_implib_p ARG 36623e72ca8cSmrg# This predicate returns with zero status (TRUE) if 36633e72ca8cSmrg# ARG is a GNU/binutils-style import library. Returns 36643e72ca8cSmrg# with nonzero status (FALSE) otherwise. 36653e72ca8cSmrgfunc_cygming_gnu_implib_p () 36663e72ca8cSmrg{ 36673e72ca8cSmrg $opt_debug 36683e72ca8cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 36693e72ca8cSmrg 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)$'` 36703e72ca8cSmrg test -n "$func_cygming_gnu_implib_tmp" 36713e72ca8cSmrg} 36723e72ca8cSmrg 36733e72ca8cSmrg# func_cygming_ms_implib_p ARG 36743e72ca8cSmrg# This predicate returns with zero status (TRUE) if 36753e72ca8cSmrg# ARG is an MS-style import library. Returns 36763e72ca8cSmrg# with nonzero status (FALSE) otherwise. 36773e72ca8cSmrgfunc_cygming_ms_implib_p () 36783e72ca8cSmrg{ 36793e72ca8cSmrg $opt_debug 36803e72ca8cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 36813e72ca8cSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 36823e72ca8cSmrg test -n "$func_cygming_ms_implib_tmp" 36833e72ca8cSmrg} 36843e72ca8cSmrg 36853e72ca8cSmrg# func_cygming_dll_for_implib_fallback ARG 36863e72ca8cSmrg# Platform-specific function to extract the 36873e72ca8cSmrg# name of the DLL associated with the specified 36883e72ca8cSmrg# import library ARG. 36893e72ca8cSmrg# 36903e72ca8cSmrg# This fallback implementation is for use when $DLLTOOL 36913e72ca8cSmrg# does not support the --identify-strict option. 36923e72ca8cSmrg# Invoked by eval'ing the libtool variable 36933e72ca8cSmrg# $sharedlib_from_linklib_cmd 36943e72ca8cSmrg# Result is available in the variable 36953e72ca8cSmrg# $sharedlib_from_linklib_result 36963e72ca8cSmrgfunc_cygming_dll_for_implib_fallback () 36973e72ca8cSmrg{ 36983e72ca8cSmrg $opt_debug 36993e72ca8cSmrg if func_cygming_gnu_implib_p "$1" ; then 37003e72ca8cSmrg # binutils import library 37013e72ca8cSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 37023e72ca8cSmrg elif func_cygming_ms_implib_p "$1" ; then 37033e72ca8cSmrg # ms-generated import library 37043e72ca8cSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 37053e72ca8cSmrg else 37063e72ca8cSmrg # unknown 37073e72ca8cSmrg sharedlib_from_linklib_result="" 37083e72ca8cSmrg fi 37093e72ca8cSmrg} 3710ee3138f1Smrg 3711ee3138f1Smrg 371234977a2fSmrg# func_extract_an_archive dir oldlib 371334977a2fSmrgfunc_extract_an_archive () 371434977a2fSmrg{ 371534977a2fSmrg $opt_debug 371634977a2fSmrg f_ex_an_ar_dir="$1"; shift 371734977a2fSmrg f_ex_an_ar_oldlib="$1" 3718b425557eSmrg if test "$lock_old_archive_extraction" = yes; then 3719b425557eSmrg lockfile=$f_ex_an_ar_oldlib.lock 3720b425557eSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3721b425557eSmrg func_echo "Waiting for $lockfile to be removed" 3722b425557eSmrg sleep 2 3723b425557eSmrg done 3724b425557eSmrg fi 3725b425557eSmrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 3726b425557eSmrg 'stat=$?; rm -f "$lockfile"; exit $stat' 3727b425557eSmrg if test "$lock_old_archive_extraction" = yes; then 3728b425557eSmrg $opt_dry_run || rm -f "$lockfile" 3729b425557eSmrg fi 373034977a2fSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 373134977a2fSmrg : 373234977a2fSmrg else 373334977a2fSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 373434977a2fSmrg fi 373534977a2fSmrg} 3736ee3138f1Smrg 3737ee3138f1Smrg 373834977a2fSmrg# func_extract_archives gentop oldlib ... 373934977a2fSmrgfunc_extract_archives () 374034977a2fSmrg{ 374134977a2fSmrg $opt_debug 374234977a2fSmrg my_gentop="$1"; shift 374334977a2fSmrg my_oldlibs=${1+"$@"} 374434977a2fSmrg my_oldobjs="" 374534977a2fSmrg my_xlib="" 374634977a2fSmrg my_xabs="" 374734977a2fSmrg my_xdir="" 3748ee3138f1Smrg 374934977a2fSmrg for my_xlib in $my_oldlibs; do 375034977a2fSmrg # Extract the objects. 375134977a2fSmrg case $my_xlib in 375234977a2fSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 375334977a2fSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 375434977a2fSmrg esac 375534977a2fSmrg func_basename "$my_xlib" 375634977a2fSmrg my_xlib="$func_basename_result" 375734977a2fSmrg my_xlib_u=$my_xlib 375834977a2fSmrg while :; do 375934977a2fSmrg case " $extracted_archives " in 376034977a2fSmrg *" $my_xlib_u "*) 376134977a2fSmrg func_arith $extracted_serial + 1 376234977a2fSmrg extracted_serial=$func_arith_result 376334977a2fSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 376434977a2fSmrg *) break ;; 376534977a2fSmrg esac 376634977a2fSmrg done 376734977a2fSmrg extracted_archives="$extracted_archives $my_xlib_u" 376834977a2fSmrg my_xdir="$my_gentop/$my_xlib_u" 3769ee3138f1Smrg 377034977a2fSmrg func_mkdir_p "$my_xdir" 3771ee3138f1Smrg 377234977a2fSmrg case $host in 377334977a2fSmrg *-darwin*) 377434977a2fSmrg func_verbose "Extracting $my_xabs" 377534977a2fSmrg # Do not bother doing anything if just a dry run 377634977a2fSmrg $opt_dry_run || { 377734977a2fSmrg darwin_orig_dir=`pwd` 377834977a2fSmrg cd $my_xdir || exit $? 377934977a2fSmrg darwin_archive=$my_xabs 378034977a2fSmrg darwin_curdir=`pwd` 378134977a2fSmrg darwin_base_archive=`basename "$darwin_archive"` 378234977a2fSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 378334977a2fSmrg if test -n "$darwin_arches"; then 378434977a2fSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 378534977a2fSmrg darwin_arch= 378634977a2fSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 378734977a2fSmrg for darwin_arch in $darwin_arches ; do 378834977a2fSmrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 378934977a2fSmrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 379034977a2fSmrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 379134977a2fSmrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 379234977a2fSmrg cd "$darwin_curdir" 379334977a2fSmrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 379434977a2fSmrg done # $darwin_arches 379534977a2fSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 379634977a2fSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 379734977a2fSmrg darwin_file= 379834977a2fSmrg darwin_files= 379934977a2fSmrg for darwin_file in $darwin_filelist; do 3800b425557eSmrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 380134977a2fSmrg $LIPO -create -output "$darwin_file" $darwin_files 380234977a2fSmrg done # $darwin_filelist 380334977a2fSmrg $RM -rf unfat-$$ 380434977a2fSmrg cd "$darwin_orig_dir" 3805ee3138f1Smrg else 380634977a2fSmrg cd $darwin_orig_dir 380734977a2fSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 380834977a2fSmrg fi # $darwin_arches 380934977a2fSmrg } # !$opt_dry_run 381034977a2fSmrg ;; 381134977a2fSmrg *) 381234977a2fSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 381334977a2fSmrg ;; 381434977a2fSmrg esac 3815b425557eSmrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 381634977a2fSmrg done 3817ee3138f1Smrg 381834977a2fSmrg func_extract_archives_result="$my_oldobjs" 381934977a2fSmrg} 3820ee3138f1Smrg 3821ee3138f1Smrg 3822b425557eSmrg# func_emit_wrapper [arg=no] 3823b425557eSmrg# 3824b425557eSmrg# Emit a libtool wrapper script on stdout. 3825b425557eSmrg# Don't directly open a file because we may want to 3826b425557eSmrg# incorporate the script contents within a cygwin/mingw 3827b425557eSmrg# wrapper executable. Must ONLY be called from within 3828b425557eSmrg# func_mode_link because it depends on a number of variables 3829b425557eSmrg# set therein. 383034977a2fSmrg# 3831b425557eSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 3832b425557eSmrg# variable will take. If 'yes', then the emitted script 3833b425557eSmrg# will assume that the directory in which it is stored is 3834b425557eSmrg# the $objdir directory. This is a cygwin/mingw-specific 3835b425557eSmrg# behavior. 3836b425557eSmrgfunc_emit_wrapper () 383734977a2fSmrg{ 3838b425557eSmrg func_emit_wrapper_arg1=${1-no} 3839ee3138f1Smrg 384034977a2fSmrg $ECHO "\ 384134977a2fSmrg#! $SHELL 3842ee3138f1Smrg 384334977a2fSmrg# $output - temporary wrapper script for $objdir/$outputname 384434977a2fSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 384534977a2fSmrg# 384634977a2fSmrg# The $output program cannot be directly executed until all the libtool 384734977a2fSmrg# libraries that it depends on are installed. 384834977a2fSmrg# 384934977a2fSmrg# This wrapper script should never be moved out of the build directory. 385034977a2fSmrg# If it is, it will not operate correctly. 3851ee3138f1Smrg 385234977a2fSmrg# Sed substitution that helps us do robust quoting. It backslashifies 385334977a2fSmrg# metacharacters that are still active within double-quoted strings. 385434977a2fSmrgsed_quote_subst='$sed_quote_subst' 3855ee3138f1Smrg 385634977a2fSmrg# Be Bourne compatible 385734977a2fSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 385834977a2fSmrg emulate sh 385934977a2fSmrg NULLCMD=: 386034977a2fSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 386134977a2fSmrg # is contrary to our usage. Disable this feature. 386234977a2fSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 386334977a2fSmrg setopt NO_GLOB_SUBST 386434977a2fSmrgelse 386534977a2fSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 386634977a2fSmrgfi 386734977a2fSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 386834977a2fSmrgDUALCASE=1; export DUALCASE # for MKS sh 3869ee3138f1Smrg 387034977a2fSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 387134977a2fSmrg# if CDPATH is set. 387234977a2fSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 3873ee3138f1Smrg 387434977a2fSmrgrelink_command=\"$relink_command\" 3875ee3138f1Smrg 387634977a2fSmrg# This environment variable determines our operation mode. 387734977a2fSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 387834977a2fSmrg # install mode needs the following variables: 387934977a2fSmrg generated_by_libtool_version='$macro_version' 388034977a2fSmrg notinst_deplibs='$notinst_deplibs' 388134977a2fSmrgelse 388234977a2fSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 388334977a2fSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 3884b425557eSmrg file=\"\$0\"" 3885b425557eSmrg 3886b425557eSmrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 3887b425557eSmrg $ECHO "\ 3888b425557eSmrg 3889b425557eSmrg# A function that is used when there is no print builtin or printf. 3890b425557eSmrgfunc_fallback_echo () 3891b425557eSmrg{ 3892b425557eSmrg eval 'cat <<_LTECHO_EOF 3893b425557eSmrg\$1 3894b425557eSmrg_LTECHO_EOF' 3895b425557eSmrg} 3896b425557eSmrg ECHO=\"$qECHO\" 3897b425557eSmrg fi 3898b425557eSmrg 3899b425557eSmrg# Very basic option parsing. These options are (a) specific to 3900b425557eSmrg# the libtool wrapper, (b) are identical between the wrapper 3901b425557eSmrg# /script/ and the wrapper /executable/ which is used only on 3902b425557eSmrg# windows platforms, and (c) all begin with the string "--lt-" 3903b425557eSmrg# (application programs are unlikely to have options which match 3904b425557eSmrg# this pattern). 3905b425557eSmrg# 3906b425557eSmrg# There are only two supported options: --lt-debug and 3907b425557eSmrg# --lt-dump-script. There is, deliberately, no --lt-help. 3908b425557eSmrg# 3909b425557eSmrg# The first argument to this parsing function should be the 3910b425557eSmrg# script's $0 value, followed by "$@". 3911b425557eSmrglt_option_debug= 3912b425557eSmrgfunc_parse_lt_options () 3913b425557eSmrg{ 3914b425557eSmrg lt_script_arg0=\$0 3915b425557eSmrg shift 3916b425557eSmrg for lt_opt 3917b425557eSmrg do 3918b425557eSmrg case \"\$lt_opt\" in 3919b425557eSmrg --lt-debug) lt_option_debug=1 ;; 3920b425557eSmrg --lt-dump-script) 3921b425557eSmrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 3922b425557eSmrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 3923b425557eSmrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 3924b425557eSmrg cat \"\$lt_dump_D/\$lt_dump_F\" 3925b425557eSmrg exit 0 3926b425557eSmrg ;; 3927b425557eSmrg --lt-*) 3928b425557eSmrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 3929b425557eSmrg exit 1 3930b425557eSmrg ;; 3931b425557eSmrg esac 3932b425557eSmrg done 3933b425557eSmrg 3934b425557eSmrg # Print the debug banner immediately: 3935b425557eSmrg if test -n \"\$lt_option_debug\"; then 3936b425557eSmrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 3937b425557eSmrg fi 3938b425557eSmrg} 3939b425557eSmrg 3940b425557eSmrg# Used when --lt-debug. Prints its arguments to stdout 3941b425557eSmrg# (redirection is the responsibility of the caller) 3942b425557eSmrgfunc_lt_dump_args () 3943b425557eSmrg{ 3944b425557eSmrg lt_dump_args_N=1; 3945b425557eSmrg for lt_arg 3946b425557eSmrg do 3947b425557eSmrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 3948b425557eSmrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 3949b425557eSmrg done 3950b425557eSmrg} 3951b425557eSmrg 3952b425557eSmrg# Core function for launching the target application 3953b425557eSmrgfunc_exec_program_core () 3954b425557eSmrg{ 395534977a2fSmrg" 3956b425557eSmrg case $host in 3957b425557eSmrg # Backslashes separate directories on plain windows 3958b425557eSmrg *-*-mingw | *-*-os2* | *-cegcc*) 3959b425557eSmrg $ECHO "\ 3960b425557eSmrg if test -n \"\$lt_option_debug\"; then 3961b425557eSmrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 3962b425557eSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 3963b425557eSmrg fi 3964b425557eSmrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 3965b425557eSmrg" 3966b425557eSmrg ;; 3967b425557eSmrg 3968b425557eSmrg *) 3969b425557eSmrg $ECHO "\ 3970b425557eSmrg if test -n \"\$lt_option_debug\"; then 3971b425557eSmrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 3972b425557eSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 3973b425557eSmrg fi 3974b425557eSmrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 3975b425557eSmrg" 3976b425557eSmrg ;; 3977b425557eSmrg esac 3978b425557eSmrg $ECHO "\ 3979b425557eSmrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 3980b425557eSmrg exit 1 3981b425557eSmrg} 3982b425557eSmrg 3983b425557eSmrg# A function to encapsulate launching the target application 3984b425557eSmrg# Strips options in the --lt-* namespace from \$@ and 3985b425557eSmrg# launches target application with the remaining arguments. 3986b425557eSmrgfunc_exec_program () 3987b425557eSmrg{ 39883e72ca8cSmrg case \" \$* \" in 39893e72ca8cSmrg *\\ --lt-*) 39903e72ca8cSmrg for lt_wr_arg 39913e72ca8cSmrg do 39923e72ca8cSmrg case \$lt_wr_arg in 39933e72ca8cSmrg --lt-*) ;; 39943e72ca8cSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 39953e72ca8cSmrg esac 39963e72ca8cSmrg shift 39973e72ca8cSmrg done ;; 39983e72ca8cSmrg esac 3999b425557eSmrg func_exec_program_core \${1+\"\$@\"} 4000b425557eSmrg} 4001b425557eSmrg 4002b425557eSmrg # Parse options 4003b425557eSmrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 4004ee3138f1Smrg 400534977a2fSmrg # Find the directory that this script lives in. 4006b425557eSmrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 400734977a2fSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 4008ee3138f1Smrg 400934977a2fSmrg # Follow symbolic links until we get to the real thisdir. 4010b425557eSmrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 401134977a2fSmrg while test -n \"\$file\"; do 4012b425557eSmrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 4013ee3138f1Smrg 401434977a2fSmrg # If there was a directory component, then change thisdir. 401534977a2fSmrg if test \"x\$destdir\" != \"x\$file\"; then 401634977a2fSmrg case \"\$destdir\" in 401734977a2fSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 401834977a2fSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 4019ee3138f1Smrg esac 402034977a2fSmrg fi 4021ee3138f1Smrg 4022b425557eSmrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 4023b425557eSmrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 402434977a2fSmrg done 4025ee3138f1Smrg 402634977a2fSmrg # Usually 'no', except on cygwin/mingw when embedded into 402734977a2fSmrg # the cwrapper. 4028b425557eSmrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 402934977a2fSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 403034977a2fSmrg # special case for '.' 403134977a2fSmrg if test \"\$thisdir\" = \".\"; then 403234977a2fSmrg thisdir=\`pwd\` 403334977a2fSmrg fi 403434977a2fSmrg # remove .libs from thisdir 403534977a2fSmrg case \"\$thisdir\" in 4036b425557eSmrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 403734977a2fSmrg $objdir ) thisdir=. ;; 403834977a2fSmrg esac 403934977a2fSmrg fi 404034977a2fSmrg 404134977a2fSmrg # Try to get the absolute directory name. 404234977a2fSmrg absdir=\`cd \"\$thisdir\" && pwd\` 404334977a2fSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 404434977a2fSmrg" 404534977a2fSmrg 404634977a2fSmrg if test "$fast_install" = yes; then 404734977a2fSmrg $ECHO "\ 404834977a2fSmrg program=lt-'$outputname'$exeext 404934977a2fSmrg progdir=\"\$thisdir/$objdir\" 405034977a2fSmrg 405134977a2fSmrg if test ! -f \"\$progdir/\$program\" || 405234977a2fSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 405334977a2fSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 405434977a2fSmrg 405534977a2fSmrg file=\"\$\$-\$program\" 405634977a2fSmrg 405734977a2fSmrg if test ! -d \"\$progdir\"; then 405834977a2fSmrg $MKDIR \"\$progdir\" 405934977a2fSmrg else 406034977a2fSmrg $RM \"\$progdir/\$file\" 406134977a2fSmrg fi" 406234977a2fSmrg 406334977a2fSmrg $ECHO "\ 406434977a2fSmrg 406534977a2fSmrg # relink executable if necessary 406634977a2fSmrg if test -n \"\$relink_command\"; then 406734977a2fSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 406834977a2fSmrg else 406934977a2fSmrg $ECHO \"\$relink_command_output\" >&2 407034977a2fSmrg $RM \"\$progdir/\$file\" 407134977a2fSmrg exit 1 4072ee3138f1Smrg fi 407334977a2fSmrg fi 4074ee3138f1Smrg 407534977a2fSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 407634977a2fSmrg { $RM \"\$progdir/\$program\"; 407734977a2fSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 407834977a2fSmrg $RM \"\$progdir/\$file\" 407934977a2fSmrg fi" 408034977a2fSmrg else 408134977a2fSmrg $ECHO "\ 408234977a2fSmrg program='$outputname' 408334977a2fSmrg progdir=\"\$thisdir/$objdir\" 408434977a2fSmrg" 4085ee3138f1Smrg fi 4086ee3138f1Smrg 408734977a2fSmrg $ECHO "\ 4088ee3138f1Smrg 408934977a2fSmrg if test -f \"\$progdir/\$program\"; then" 4090ee3138f1Smrg 40913e72ca8cSmrg # fixup the dll searchpath if we need to. 40923e72ca8cSmrg # 40933e72ca8cSmrg # Fix the DLL searchpath if we need to. Do this before prepending 40943e72ca8cSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 40953e72ca8cSmrg # libraries must come first. 40963e72ca8cSmrg if test -n "$dllsearchpath"; then 40973e72ca8cSmrg $ECHO "\ 40983e72ca8cSmrg # Add the dll search path components to the executable PATH 40993e72ca8cSmrg PATH=$dllsearchpath:\$PATH 41003e72ca8cSmrg" 41013e72ca8cSmrg fi 41023e72ca8cSmrg 410334977a2fSmrg # Export our shlibpath_var if we have one. 410434977a2fSmrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 410534977a2fSmrg $ECHO "\ 410634977a2fSmrg # Add our own library path to $shlibpath_var 410734977a2fSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 4108ee3138f1Smrg 410934977a2fSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 411034977a2fSmrg # The second colon is a workaround for a bug in BeOS R4 sed 4111b425557eSmrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 411234977a2fSmrg 411334977a2fSmrg export $shlibpath_var 411434977a2fSmrg" 4115ee3138f1Smrg fi 4116ee3138f1Smrg 411734977a2fSmrg $ECHO "\ 411834977a2fSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 411934977a2fSmrg # Run the actual program with our arguments. 4120b425557eSmrg func_exec_program \${1+\"\$@\"} 412134977a2fSmrg fi 412234977a2fSmrg else 412334977a2fSmrg # The program doesn't exist. 412434977a2fSmrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 412534977a2fSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 4126b425557eSmrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 412734977a2fSmrg exit 1 412834977a2fSmrg fi 412934977a2fSmrgfi\ 413034977a2fSmrg" 413134977a2fSmrg} 4132ee3138f1Smrg 4133ee3138f1Smrg 413434977a2fSmrg# func_emit_cwrapperexe_src 413534977a2fSmrg# emit the source code for a wrapper executable on stdout 413634977a2fSmrg# Must ONLY be called from within func_mode_link because 413734977a2fSmrg# it depends on a number of variable set therein. 413834977a2fSmrgfunc_emit_cwrapperexe_src () 413934977a2fSmrg{ 414034977a2fSmrg cat <<EOF 4141ee3138f1Smrg 414234977a2fSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 414334977a2fSmrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4144ee3138f1Smrg 414534977a2fSmrg The $output program cannot be directly executed until all the libtool 414634977a2fSmrg libraries that it depends on are installed. 4147ee3138f1Smrg 414834977a2fSmrg This wrapper executable should never be moved out of the build directory. 414934977a2fSmrg If it is, it will not operate correctly. 415034977a2fSmrg*/ 415134977a2fSmrgEOF 415234977a2fSmrg cat <<"EOF" 4153b425557eSmrg#ifdef _MSC_VER 4154b425557eSmrg# define _CRT_SECURE_NO_DEPRECATE 1 4155b425557eSmrg#endif 415634977a2fSmrg#include <stdio.h> 415734977a2fSmrg#include <stdlib.h> 415834977a2fSmrg#ifdef _MSC_VER 415934977a2fSmrg# include <direct.h> 416034977a2fSmrg# include <process.h> 416134977a2fSmrg# include <io.h> 416234977a2fSmrg#else 416334977a2fSmrg# include <unistd.h> 416434977a2fSmrg# include <stdint.h> 416534977a2fSmrg# ifdef __CYGWIN__ 416634977a2fSmrg# include <io.h> 416734977a2fSmrg# endif 416834977a2fSmrg#endif 416934977a2fSmrg#include <malloc.h> 417034977a2fSmrg#include <stdarg.h> 417134977a2fSmrg#include <assert.h> 417234977a2fSmrg#include <string.h> 417334977a2fSmrg#include <ctype.h> 417434977a2fSmrg#include <errno.h> 417534977a2fSmrg#include <fcntl.h> 417634977a2fSmrg#include <sys/stat.h> 4177ee3138f1Smrg 4178b425557eSmrg/* declarations of non-ANSI functions */ 4179b425557eSmrg#if defined(__MINGW32__) 4180b425557eSmrg# ifdef __STRICT_ANSI__ 4181b425557eSmrgint _putenv (const char *); 4182b425557eSmrg# endif 4183b425557eSmrg#elif defined(__CYGWIN__) 4184b425557eSmrg# ifdef __STRICT_ANSI__ 4185b425557eSmrgchar *realpath (const char *, char *); 4186b425557eSmrgint putenv (char *); 4187b425557eSmrgint setenv (const char *, const char *, int); 4188b425557eSmrg# endif 4189b425557eSmrg/* #elif defined (other platforms) ... */ 4190b425557eSmrg#endif 4191b425557eSmrg 4192b425557eSmrg/* portability defines, excluding path handling macros */ 4193b425557eSmrg#if defined(_MSC_VER) 4194b425557eSmrg# define setmode _setmode 4195b425557eSmrg# define stat _stat 4196b425557eSmrg# define chmod _chmod 4197b425557eSmrg# define getcwd _getcwd 4198b425557eSmrg# define putenv _putenv 4199b425557eSmrg# define S_IXUSR _S_IEXEC 4200b425557eSmrg# ifndef _INTPTR_T_DEFINED 4201b425557eSmrg# define _INTPTR_T_DEFINED 4202b425557eSmrg# define intptr_t int 4203b425557eSmrg# endif 4204b425557eSmrg#elif defined(__MINGW32__) 4205b425557eSmrg# define setmode _setmode 4206b425557eSmrg# define stat _stat 4207b425557eSmrg# define chmod _chmod 4208b425557eSmrg# define getcwd _getcwd 4209b425557eSmrg# define putenv _putenv 4210b425557eSmrg#elif defined(__CYGWIN__) 4211b425557eSmrg# define HAVE_SETENV 4212b425557eSmrg# define FOPEN_WB "wb" 4213b425557eSmrg/* #elif defined (other platforms) ... */ 4214b425557eSmrg#endif 4215b425557eSmrg 421634977a2fSmrg#if defined(PATH_MAX) 421734977a2fSmrg# define LT_PATHMAX PATH_MAX 421834977a2fSmrg#elif defined(MAXPATHLEN) 421934977a2fSmrg# define LT_PATHMAX MAXPATHLEN 422034977a2fSmrg#else 422134977a2fSmrg# define LT_PATHMAX 1024 422234977a2fSmrg#endif 4223ee3138f1Smrg 422434977a2fSmrg#ifndef S_IXOTH 422534977a2fSmrg# define S_IXOTH 0 422634977a2fSmrg#endif 422734977a2fSmrg#ifndef S_IXGRP 422834977a2fSmrg# define S_IXGRP 0 422934977a2fSmrg#endif 4230ee3138f1Smrg 4231b425557eSmrg/* path handling portability macros */ 423234977a2fSmrg#ifndef DIR_SEPARATOR 423334977a2fSmrg# define DIR_SEPARATOR '/' 423434977a2fSmrg# define PATH_SEPARATOR ':' 423534977a2fSmrg#endif 4236ee3138f1Smrg 423734977a2fSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 423834977a2fSmrg defined (__OS2__) 423934977a2fSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 424034977a2fSmrg# define FOPEN_WB "wb" 424134977a2fSmrg# ifndef DIR_SEPARATOR_2 424234977a2fSmrg# define DIR_SEPARATOR_2 '\\' 424334977a2fSmrg# endif 424434977a2fSmrg# ifndef PATH_SEPARATOR_2 424534977a2fSmrg# define PATH_SEPARATOR_2 ';' 424634977a2fSmrg# endif 424734977a2fSmrg#endif 4248ee3138f1Smrg 424934977a2fSmrg#ifndef DIR_SEPARATOR_2 425034977a2fSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 425134977a2fSmrg#else /* DIR_SEPARATOR_2 */ 425234977a2fSmrg# define IS_DIR_SEPARATOR(ch) \ 425334977a2fSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 425434977a2fSmrg#endif /* DIR_SEPARATOR_2 */ 4255ee3138f1Smrg 425634977a2fSmrg#ifndef PATH_SEPARATOR_2 425734977a2fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 425834977a2fSmrg#else /* PATH_SEPARATOR_2 */ 425934977a2fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 426034977a2fSmrg#endif /* PATH_SEPARATOR_2 */ 4261ee3138f1Smrg 426234977a2fSmrg#ifndef FOPEN_WB 426334977a2fSmrg# define FOPEN_WB "w" 426434977a2fSmrg#endif 426534977a2fSmrg#ifndef _O_BINARY 426634977a2fSmrg# define _O_BINARY 0 426734977a2fSmrg#endif 4268ee3138f1Smrg 426934977a2fSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 427034977a2fSmrg#define XFREE(stale) do { \ 427134977a2fSmrg if (stale) { free ((void *) stale); stale = 0; } \ 427234977a2fSmrg} while (0) 4273ee3138f1Smrg 4274b425557eSmrg#if defined(LT_DEBUGWRAPPER) 4275b425557eSmrgstatic int lt_debug = 1; 427634977a2fSmrg#else 4277b425557eSmrgstatic int lt_debug = 0; 427834977a2fSmrg#endif 4279ee3138f1Smrg 4280b425557eSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 4281ee3138f1Smrg 428234977a2fSmrgvoid *xmalloc (size_t num); 428334977a2fSmrgchar *xstrdup (const char *string); 428434977a2fSmrgconst char *base_name (const char *name); 428534977a2fSmrgchar *find_executable (const char *wrapper); 428634977a2fSmrgchar *chase_symlinks (const char *pathspec); 428734977a2fSmrgint make_executable (const char *path); 428834977a2fSmrgint check_executable (const char *path); 428934977a2fSmrgchar *strendzap (char *str, const char *pat); 4290b425557eSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 4291b425557eSmrgvoid lt_fatal (const char *file, int line, const char *message, ...); 4292b425557eSmrgstatic const char *nonnull (const char *s); 4293b425557eSmrgstatic const char *nonempty (const char *s); 429434977a2fSmrgvoid lt_setenv (const char *name, const char *value); 429534977a2fSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 429634977a2fSmrgvoid lt_update_exe_path (const char *name, const char *value); 429734977a2fSmrgvoid lt_update_lib_path (const char *name, const char *value); 4298b425557eSmrgchar **prepare_spawn (char **argv); 4299b425557eSmrgvoid lt_dump_script (FILE *f); 430034977a2fSmrgEOF 430134977a2fSmrg 430234977a2fSmrg cat <<EOF 43033e72ca8cSmrgvolatile const char * MAGIC_EXE = "$magic_exe"; 430434977a2fSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 430534977a2fSmrgEOF 4306ee3138f1Smrg 430734977a2fSmrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 43083e72ca8cSmrg func_to_host_path "$temp_rpath" 430934977a2fSmrg cat <<EOF 43103e72ca8cSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 431134977a2fSmrgEOF 431234977a2fSmrg else 431334977a2fSmrg cat <<"EOF" 431434977a2fSmrgconst char * LIB_PATH_VALUE = ""; 431534977a2fSmrgEOF 4316ee3138f1Smrg fi 4317ee3138f1Smrg 431834977a2fSmrg if test -n "$dllsearchpath"; then 43193e72ca8cSmrg func_to_host_path "$dllsearchpath:" 432034977a2fSmrg cat <<EOF 432134977a2fSmrgconst char * EXE_PATH_VARNAME = "PATH"; 43223e72ca8cSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 4323ee3138f1SmrgEOF 4324ee3138f1Smrg else 432534977a2fSmrg cat <<"EOF" 432634977a2fSmrgconst char * EXE_PATH_VARNAME = ""; 432734977a2fSmrgconst char * EXE_PATH_VALUE = ""; 432834977a2fSmrgEOF 4329ee3138f1Smrg fi 433034977a2fSmrg 433134977a2fSmrg if test "$fast_install" = yes; then 433234977a2fSmrg cat <<EOF 433334977a2fSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 433434977a2fSmrgEOF 4335ee3138f1Smrg else 433634977a2fSmrg cat <<EOF 433734977a2fSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 433834977a2fSmrgEOF 4339ee3138f1Smrg fi 4340ee3138f1Smrg 4341ee3138f1Smrg 434234977a2fSmrg cat <<"EOF" 4343ee3138f1Smrg 434434977a2fSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 4345ee3138f1Smrg 434634977a2fSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 434734977a2fSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 4348b425557eSmrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 4349ee3138f1Smrg 435034977a2fSmrgint 435134977a2fSmrgmain (int argc, char *argv[]) 435234977a2fSmrg{ 435334977a2fSmrg char **newargz; 435434977a2fSmrg int newargc; 435534977a2fSmrg char *tmp_pathspec; 435634977a2fSmrg char *actual_cwrapper_path; 435734977a2fSmrg char *actual_cwrapper_name; 435834977a2fSmrg char *target_name; 435934977a2fSmrg char *lt_argv_zero; 436034977a2fSmrg intptr_t rval = 127; 4361ee3138f1Smrg 436234977a2fSmrg int i; 4363ee3138f1Smrg 436434977a2fSmrg program_name = (char *) xstrdup (base_name (argv[0])); 4365b425557eSmrg newargz = XMALLOC (char *, argc + 1); 4366ee3138f1Smrg 4367b425557eSmrg /* very simple arg parsing; don't want to rely on getopt 4368b425557eSmrg * also, copy all non cwrapper options to newargz, except 4369b425557eSmrg * argz[0], which is handled differently 4370b425557eSmrg */ 4371b425557eSmrg newargc=0; 437234977a2fSmrg for (i = 1; i < argc; i++) 437334977a2fSmrg { 437434977a2fSmrg if (strcmp (argv[i], dumpscript_opt) == 0) 437534977a2fSmrg { 437634977a2fSmrgEOF 437734977a2fSmrg case "$host" in 437834977a2fSmrg *mingw* | *cygwin* ) 437934977a2fSmrg # make stdout use "unix" line endings 438034977a2fSmrg echo " setmode(1,_O_BINARY);" 438134977a2fSmrg ;; 438234977a2fSmrg esac 4383ee3138f1Smrg 438434977a2fSmrg cat <<"EOF" 4385b425557eSmrg lt_dump_script (stdout); 438634977a2fSmrg return 0; 438734977a2fSmrg } 4388b425557eSmrg if (strcmp (argv[i], debug_opt) == 0) 4389b425557eSmrg { 4390b425557eSmrg lt_debug = 1; 4391b425557eSmrg continue; 4392b425557eSmrg } 4393b425557eSmrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 4394b425557eSmrg { 4395b425557eSmrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 4396b425557eSmrg namespace, but it is not one of the ones we know about and 4397b425557eSmrg have already dealt with, above (inluding dump-script), then 4398b425557eSmrg report an error. Otherwise, targets might begin to believe 4399b425557eSmrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 4400b425557eSmrg namespace. The first time any user complains about this, we'll 4401b425557eSmrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 4402b425557eSmrg or a configure.ac-settable value. 4403b425557eSmrg */ 4404b425557eSmrg lt_fatal (__FILE__, __LINE__, 4405b425557eSmrg "unrecognized %s option: '%s'", 4406b425557eSmrg ltwrapper_option_prefix, argv[i]); 4407b425557eSmrg } 4408b425557eSmrg /* otherwise ... */ 4409b425557eSmrg newargz[++newargc] = xstrdup (argv[i]); 441034977a2fSmrg } 4411b425557eSmrg newargz[++newargc] = NULL; 4412b425557eSmrg 4413b425557eSmrgEOF 4414b425557eSmrg cat <<EOF 4415b425557eSmrg /* The GNU banner must be the first non-error debug message */ 4416b425557eSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 4417b425557eSmrgEOF 4418b425557eSmrg cat <<"EOF" 4419b425557eSmrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 4420b425557eSmrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 4421ee3138f1Smrg 442234977a2fSmrg tmp_pathspec = find_executable (argv[0]); 442334977a2fSmrg if (tmp_pathspec == NULL) 4424b425557eSmrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 4425b425557eSmrg lt_debugprintf (__FILE__, __LINE__, 4426b425557eSmrg "(main) found exe (before symlink chase) at: %s\n", 4427b425557eSmrg tmp_pathspec); 442834977a2fSmrg 442934977a2fSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 4430b425557eSmrg lt_debugprintf (__FILE__, __LINE__, 4431b425557eSmrg "(main) found exe (after symlink chase) at: %s\n", 4432b425557eSmrg actual_cwrapper_path); 443334977a2fSmrg XFREE (tmp_pathspec); 443434977a2fSmrg 4435b425557eSmrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 443634977a2fSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 443734977a2fSmrg 443834977a2fSmrg /* wrapper name transforms */ 443934977a2fSmrg strendzap (actual_cwrapper_name, ".exe"); 444034977a2fSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 444134977a2fSmrg XFREE (actual_cwrapper_name); 444234977a2fSmrg actual_cwrapper_name = tmp_pathspec; 444334977a2fSmrg tmp_pathspec = 0; 444434977a2fSmrg 444534977a2fSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 444634977a2fSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 444734977a2fSmrg strendzap (target_name, ".exe"); 444834977a2fSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 444934977a2fSmrg XFREE (target_name); 445034977a2fSmrg target_name = tmp_pathspec; 445134977a2fSmrg tmp_pathspec = 0; 445234977a2fSmrg 4453b425557eSmrg lt_debugprintf (__FILE__, __LINE__, 4454b425557eSmrg "(main) libtool target name: %s\n", 4455b425557eSmrg target_name); 445634977a2fSmrgEOF 4457ee3138f1Smrg 445834977a2fSmrg cat <<EOF 445934977a2fSmrg newargz[0] = 446034977a2fSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 446134977a2fSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 446234977a2fSmrg strcpy (newargz[0], actual_cwrapper_path); 446334977a2fSmrg strcat (newargz[0], "$objdir"); 446434977a2fSmrg strcat (newargz[0], "/"); 446534977a2fSmrgEOF 4466ee3138f1Smrg 446734977a2fSmrg cat <<"EOF" 446834977a2fSmrg /* stop here, and copy so we don't have to do this twice */ 446934977a2fSmrg tmp_pathspec = xstrdup (newargz[0]); 4470ee3138f1Smrg 447134977a2fSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 447234977a2fSmrg strcat (newargz[0], actual_cwrapper_name); 4473ee3138f1Smrg 447434977a2fSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 447534977a2fSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 447634977a2fSmrg XFREE (tmp_pathspec); 447734977a2fSmrg tmp_pathspec = NULL; 447834977a2fSmrgEOF 4479ee3138f1Smrg 448034977a2fSmrg case $host_os in 448134977a2fSmrg mingw*) 448234977a2fSmrg cat <<"EOF" 448334977a2fSmrg { 448434977a2fSmrg char* p; 448534977a2fSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 448634977a2fSmrg { 448734977a2fSmrg *p = '/'; 448834977a2fSmrg } 448934977a2fSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 449034977a2fSmrg { 449134977a2fSmrg *p = '/'; 449234977a2fSmrg } 449334977a2fSmrg } 449434977a2fSmrgEOF 449534977a2fSmrg ;; 449634977a2fSmrg esac 4497ee3138f1Smrg 449834977a2fSmrg cat <<"EOF" 449934977a2fSmrg XFREE (target_name); 450034977a2fSmrg XFREE (actual_cwrapper_path); 450134977a2fSmrg XFREE (actual_cwrapper_name); 4502ee3138f1Smrg 450334977a2fSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 450434977a2fSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 45053e72ca8cSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 45063e72ca8cSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 45073e72ca8cSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 45083e72ca8cSmrg libraries must come first. */ 450934977a2fSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 45103e72ca8cSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 4511ee3138f1Smrg 4512b425557eSmrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 4513b425557eSmrg nonnull (lt_argv_zero)); 451434977a2fSmrg for (i = 0; i < newargc; i++) 451534977a2fSmrg { 4516b425557eSmrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 4517b425557eSmrg i, nonnull (newargz[i])); 451834977a2fSmrg } 4519ee3138f1Smrg 452034977a2fSmrgEOF 4521ee3138f1Smrg 452234977a2fSmrg case $host_os in 452334977a2fSmrg mingw*) 452434977a2fSmrg cat <<"EOF" 452534977a2fSmrg /* execv doesn't actually work on mingw as expected on unix */ 4526b425557eSmrg newargz = prepare_spawn (newargz); 452734977a2fSmrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 452834977a2fSmrg if (rval == -1) 452934977a2fSmrg { 453034977a2fSmrg /* failed to start process */ 4531b425557eSmrg lt_debugprintf (__FILE__, __LINE__, 4532b425557eSmrg "(main) failed to launch target \"%s\": %s\n", 4533b425557eSmrg lt_argv_zero, nonnull (strerror (errno))); 453434977a2fSmrg return 127; 453534977a2fSmrg } 453634977a2fSmrg return rval; 453734977a2fSmrgEOF 453834977a2fSmrg ;; 453934977a2fSmrg *) 454034977a2fSmrg cat <<"EOF" 454134977a2fSmrg execv (lt_argv_zero, newargz); 454234977a2fSmrg return rval; /* =127, but avoids unused variable warning */ 454334977a2fSmrgEOF 454434977a2fSmrg ;; 454534977a2fSmrg esac 4546ee3138f1Smrg 454734977a2fSmrg cat <<"EOF" 454834977a2fSmrg} 4549ee3138f1Smrg 455034977a2fSmrgvoid * 455134977a2fSmrgxmalloc (size_t num) 455234977a2fSmrg{ 455334977a2fSmrg void *p = (void *) malloc (num); 455434977a2fSmrg if (!p) 4555b425557eSmrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 4556ee3138f1Smrg 455734977a2fSmrg return p; 455834977a2fSmrg} 4559ee3138f1Smrg 456034977a2fSmrgchar * 456134977a2fSmrgxstrdup (const char *string) 456234977a2fSmrg{ 456334977a2fSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 456434977a2fSmrg string) : NULL; 456534977a2fSmrg} 4566ee3138f1Smrg 456734977a2fSmrgconst char * 456834977a2fSmrgbase_name (const char *name) 456934977a2fSmrg{ 457034977a2fSmrg const char *base; 4571ee3138f1Smrg 457234977a2fSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 457334977a2fSmrg /* Skip over the disk name in MSDOS pathnames. */ 457434977a2fSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 457534977a2fSmrg name += 2; 457634977a2fSmrg#endif 4577ee3138f1Smrg 457834977a2fSmrg for (base = name; *name; name++) 457934977a2fSmrg if (IS_DIR_SEPARATOR (*name)) 458034977a2fSmrg base = name + 1; 458134977a2fSmrg return base; 458234977a2fSmrg} 4583ee3138f1Smrg 458434977a2fSmrgint 458534977a2fSmrgcheck_executable (const char *path) 458634977a2fSmrg{ 458734977a2fSmrg struct stat st; 4588ee3138f1Smrg 4589b425557eSmrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 4590b425557eSmrg nonempty (path)); 459134977a2fSmrg if ((!path) || (!*path)) 459234977a2fSmrg return 0; 4593ee3138f1Smrg 459434977a2fSmrg if ((stat (path, &st) >= 0) 459534977a2fSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 459634977a2fSmrg return 1; 459734977a2fSmrg else 459834977a2fSmrg return 0; 459934977a2fSmrg} 4600ee3138f1Smrg 460134977a2fSmrgint 460234977a2fSmrgmake_executable (const char *path) 460334977a2fSmrg{ 460434977a2fSmrg int rval = 0; 460534977a2fSmrg struct stat st; 4606ee3138f1Smrg 4607b425557eSmrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 4608b425557eSmrg nonempty (path)); 460934977a2fSmrg if ((!path) || (!*path)) 461034977a2fSmrg return 0; 4611ee3138f1Smrg 461234977a2fSmrg if (stat (path, &st) >= 0) 461334977a2fSmrg { 461434977a2fSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 461534977a2fSmrg } 461634977a2fSmrg return rval; 461734977a2fSmrg} 4618ee3138f1Smrg 461934977a2fSmrg/* Searches for the full path of the wrapper. Returns 462034977a2fSmrg newly allocated full path name if found, NULL otherwise 462134977a2fSmrg Does not chase symlinks, even on platforms that support them. 462234977a2fSmrg*/ 462334977a2fSmrgchar * 462434977a2fSmrgfind_executable (const char *wrapper) 462534977a2fSmrg{ 462634977a2fSmrg int has_slash = 0; 462734977a2fSmrg const char *p; 462834977a2fSmrg const char *p_next; 462934977a2fSmrg /* static buffer for getcwd */ 463034977a2fSmrg char tmp[LT_PATHMAX + 1]; 463134977a2fSmrg int tmp_len; 463234977a2fSmrg char *concat_name; 4633ee3138f1Smrg 4634b425557eSmrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 4635b425557eSmrg nonempty (wrapper)); 4636ee3138f1Smrg 463734977a2fSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 463834977a2fSmrg return NULL; 4639ee3138f1Smrg 464034977a2fSmrg /* Absolute path? */ 464134977a2fSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 464234977a2fSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 464334977a2fSmrg { 464434977a2fSmrg concat_name = xstrdup (wrapper); 464534977a2fSmrg if (check_executable (concat_name)) 464634977a2fSmrg return concat_name; 464734977a2fSmrg XFREE (concat_name); 464834977a2fSmrg } 464934977a2fSmrg else 465034977a2fSmrg { 465134977a2fSmrg#endif 465234977a2fSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 465334977a2fSmrg { 465434977a2fSmrg concat_name = xstrdup (wrapper); 465534977a2fSmrg if (check_executable (concat_name)) 465634977a2fSmrg return concat_name; 465734977a2fSmrg XFREE (concat_name); 465834977a2fSmrg } 465934977a2fSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 466034977a2fSmrg } 466134977a2fSmrg#endif 4662ee3138f1Smrg 466334977a2fSmrg for (p = wrapper; *p; p++) 466434977a2fSmrg if (*p == '/') 466534977a2fSmrg { 466634977a2fSmrg has_slash = 1; 466734977a2fSmrg break; 466834977a2fSmrg } 466934977a2fSmrg if (!has_slash) 467034977a2fSmrg { 467134977a2fSmrg /* no slashes; search PATH */ 467234977a2fSmrg const char *path = getenv ("PATH"); 467334977a2fSmrg if (path != NULL) 467434977a2fSmrg { 467534977a2fSmrg for (p = path; *p; p = p_next) 467634977a2fSmrg { 467734977a2fSmrg const char *q; 467834977a2fSmrg size_t p_len; 467934977a2fSmrg for (q = p; *q; q++) 468034977a2fSmrg if (IS_PATH_SEPARATOR (*q)) 468134977a2fSmrg break; 468234977a2fSmrg p_len = q - p; 468334977a2fSmrg p_next = (*q == '\0' ? q : q + 1); 468434977a2fSmrg if (p_len == 0) 468534977a2fSmrg { 468634977a2fSmrg /* empty path: current directory */ 468734977a2fSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 4688b425557eSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4689b425557eSmrg nonnull (strerror (errno))); 469034977a2fSmrg tmp_len = strlen (tmp); 469134977a2fSmrg concat_name = 469234977a2fSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 469334977a2fSmrg memcpy (concat_name, tmp, tmp_len); 469434977a2fSmrg concat_name[tmp_len] = '/'; 469534977a2fSmrg strcpy (concat_name + tmp_len + 1, wrapper); 469634977a2fSmrg } 469734977a2fSmrg else 469834977a2fSmrg { 469934977a2fSmrg concat_name = 470034977a2fSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 470134977a2fSmrg memcpy (concat_name, p, p_len); 470234977a2fSmrg concat_name[p_len] = '/'; 470334977a2fSmrg strcpy (concat_name + p_len + 1, wrapper); 470434977a2fSmrg } 470534977a2fSmrg if (check_executable (concat_name)) 470634977a2fSmrg return concat_name; 470734977a2fSmrg XFREE (concat_name); 470834977a2fSmrg } 470934977a2fSmrg } 471034977a2fSmrg /* not found in PATH; assume curdir */ 471134977a2fSmrg } 471234977a2fSmrg /* Relative path | not found in path: prepend cwd */ 471334977a2fSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 4714b425557eSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4715b425557eSmrg nonnull (strerror (errno))); 471634977a2fSmrg tmp_len = strlen (tmp); 471734977a2fSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 471834977a2fSmrg memcpy (concat_name, tmp, tmp_len); 471934977a2fSmrg concat_name[tmp_len] = '/'; 472034977a2fSmrg strcpy (concat_name + tmp_len + 1, wrapper); 4721ee3138f1Smrg 472234977a2fSmrg if (check_executable (concat_name)) 472334977a2fSmrg return concat_name; 472434977a2fSmrg XFREE (concat_name); 472534977a2fSmrg return NULL; 472634977a2fSmrg} 4727ee3138f1Smrg 472834977a2fSmrgchar * 472934977a2fSmrgchase_symlinks (const char *pathspec) 473034977a2fSmrg{ 473134977a2fSmrg#ifndef S_ISLNK 473234977a2fSmrg return xstrdup (pathspec); 473334977a2fSmrg#else 473434977a2fSmrg char buf[LT_PATHMAX]; 473534977a2fSmrg struct stat s; 473634977a2fSmrg char *tmp_pathspec = xstrdup (pathspec); 473734977a2fSmrg char *p; 473834977a2fSmrg int has_symlinks = 0; 473934977a2fSmrg while (strlen (tmp_pathspec) && !has_symlinks) 474034977a2fSmrg { 4741b425557eSmrg lt_debugprintf (__FILE__, __LINE__, 4742b425557eSmrg "checking path component for symlinks: %s\n", 4743b425557eSmrg tmp_pathspec); 474434977a2fSmrg if (lstat (tmp_pathspec, &s) == 0) 474534977a2fSmrg { 474634977a2fSmrg if (S_ISLNK (s.st_mode) != 0) 474734977a2fSmrg { 474834977a2fSmrg has_symlinks = 1; 474934977a2fSmrg break; 475034977a2fSmrg } 4751ee3138f1Smrg 475234977a2fSmrg /* search backwards for last DIR_SEPARATOR */ 475334977a2fSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 475434977a2fSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 475534977a2fSmrg p--; 475634977a2fSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 475734977a2fSmrg { 475834977a2fSmrg /* no more DIR_SEPARATORS left */ 475934977a2fSmrg break; 476034977a2fSmrg } 476134977a2fSmrg *p = '\0'; 476234977a2fSmrg } 476334977a2fSmrg else 476434977a2fSmrg { 4765b425557eSmrg lt_fatal (__FILE__, __LINE__, 4766b425557eSmrg "error accessing file \"%s\": %s", 4767b425557eSmrg tmp_pathspec, nonnull (strerror (errno))); 476834977a2fSmrg } 476934977a2fSmrg } 477034977a2fSmrg XFREE (tmp_pathspec); 4771ee3138f1Smrg 477234977a2fSmrg if (!has_symlinks) 477334977a2fSmrg { 477434977a2fSmrg return xstrdup (pathspec); 477534977a2fSmrg } 4776ee3138f1Smrg 477734977a2fSmrg tmp_pathspec = realpath (pathspec, buf); 477834977a2fSmrg if (tmp_pathspec == 0) 477934977a2fSmrg { 4780b425557eSmrg lt_fatal (__FILE__, __LINE__, 4781b425557eSmrg "could not follow symlinks for %s", pathspec); 478234977a2fSmrg } 478334977a2fSmrg return xstrdup (tmp_pathspec); 478434977a2fSmrg#endif 478534977a2fSmrg} 4786ee3138f1Smrg 478734977a2fSmrgchar * 478834977a2fSmrgstrendzap (char *str, const char *pat) 478934977a2fSmrg{ 479034977a2fSmrg size_t len, patlen; 4791ee3138f1Smrg 479234977a2fSmrg assert (str != NULL); 479334977a2fSmrg assert (pat != NULL); 4794ee3138f1Smrg 479534977a2fSmrg len = strlen (str); 479634977a2fSmrg patlen = strlen (pat); 4797ee3138f1Smrg 479834977a2fSmrg if (patlen <= len) 479934977a2fSmrg { 480034977a2fSmrg str += len - patlen; 480134977a2fSmrg if (strcmp (str, pat) == 0) 480234977a2fSmrg *str = '\0'; 480334977a2fSmrg } 480434977a2fSmrg return str; 480534977a2fSmrg} 4806ee3138f1Smrg 4807b425557eSmrgvoid 4808b425557eSmrglt_debugprintf (const char *file, int line, const char *fmt, ...) 4809b425557eSmrg{ 4810b425557eSmrg va_list args; 4811b425557eSmrg if (lt_debug) 4812b425557eSmrg { 4813b425557eSmrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 4814b425557eSmrg va_start (args, fmt); 4815b425557eSmrg (void) vfprintf (stderr, fmt, args); 4816b425557eSmrg va_end (args); 4817b425557eSmrg } 4818b425557eSmrg} 4819b425557eSmrg 482034977a2fSmrgstatic void 4821b425557eSmrglt_error_core (int exit_status, const char *file, 4822b425557eSmrg int line, const char *mode, 482334977a2fSmrg const char *message, va_list ap) 482434977a2fSmrg{ 4825b425557eSmrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 482634977a2fSmrg vfprintf (stderr, message, ap); 482734977a2fSmrg fprintf (stderr, ".\n"); 4828ee3138f1Smrg 482934977a2fSmrg if (exit_status >= 0) 483034977a2fSmrg exit (exit_status); 483134977a2fSmrg} 4832ee3138f1Smrg 483334977a2fSmrgvoid 4834b425557eSmrglt_fatal (const char *file, int line, const char *message, ...) 483534977a2fSmrg{ 483634977a2fSmrg va_list ap; 483734977a2fSmrg va_start (ap, message); 4838b425557eSmrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 483934977a2fSmrg va_end (ap); 484034977a2fSmrg} 4841ee3138f1Smrg 4842b425557eSmrgstatic const char * 4843b425557eSmrgnonnull (const char *s) 4844b425557eSmrg{ 4845b425557eSmrg return s ? s : "(null)"; 4846b425557eSmrg} 4847b425557eSmrg 4848b425557eSmrgstatic const char * 4849b425557eSmrgnonempty (const char *s) 4850b425557eSmrg{ 4851b425557eSmrg return (s && !*s) ? "(empty)" : nonnull (s); 4852b425557eSmrg} 4853b425557eSmrg 485434977a2fSmrgvoid 485534977a2fSmrglt_setenv (const char *name, const char *value) 485634977a2fSmrg{ 4857b425557eSmrg lt_debugprintf (__FILE__, __LINE__, 4858b425557eSmrg "(lt_setenv) setting '%s' to '%s'\n", 4859b425557eSmrg nonnull (name), nonnull (value)); 486034977a2fSmrg { 486134977a2fSmrg#ifdef HAVE_SETENV 486234977a2fSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 486334977a2fSmrg char *str = xstrdup (value); 486434977a2fSmrg setenv (name, str, 1); 486534977a2fSmrg#else 486634977a2fSmrg int len = strlen (name) + 1 + strlen (value) + 1; 486734977a2fSmrg char *str = XMALLOC (char, len); 486834977a2fSmrg sprintf (str, "%s=%s", name, value); 486934977a2fSmrg if (putenv (str) != EXIT_SUCCESS) 487034977a2fSmrg { 487134977a2fSmrg XFREE (str); 487234977a2fSmrg } 487334977a2fSmrg#endif 487434977a2fSmrg } 487534977a2fSmrg} 4876ee3138f1Smrg 487734977a2fSmrgchar * 487834977a2fSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 487934977a2fSmrg{ 488034977a2fSmrg char *new_value; 488134977a2fSmrg if (orig_value && *orig_value) 488234977a2fSmrg { 488334977a2fSmrg int orig_value_len = strlen (orig_value); 488434977a2fSmrg int add_len = strlen (add); 488534977a2fSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 488634977a2fSmrg if (to_end) 488734977a2fSmrg { 488834977a2fSmrg strcpy (new_value, orig_value); 488934977a2fSmrg strcpy (new_value + orig_value_len, add); 489034977a2fSmrg } 489134977a2fSmrg else 489234977a2fSmrg { 489334977a2fSmrg strcpy (new_value, add); 489434977a2fSmrg strcpy (new_value + add_len, orig_value); 489534977a2fSmrg } 489634977a2fSmrg } 489734977a2fSmrg else 489834977a2fSmrg { 489934977a2fSmrg new_value = xstrdup (add); 490034977a2fSmrg } 490134977a2fSmrg return new_value; 490234977a2fSmrg} 4903ee3138f1Smrg 490434977a2fSmrgvoid 490534977a2fSmrglt_update_exe_path (const char *name, const char *value) 490634977a2fSmrg{ 4907b425557eSmrg lt_debugprintf (__FILE__, __LINE__, 4908b425557eSmrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 4909b425557eSmrg nonnull (name), nonnull (value)); 4910ee3138f1Smrg 491134977a2fSmrg if (name && *name && value && *value) 491234977a2fSmrg { 491334977a2fSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 491434977a2fSmrg /* some systems can't cope with a ':'-terminated path #' */ 491534977a2fSmrg int len = strlen (new_value); 491634977a2fSmrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 491734977a2fSmrg { 491834977a2fSmrg new_value[len-1] = '\0'; 491934977a2fSmrg } 492034977a2fSmrg lt_setenv (name, new_value); 492134977a2fSmrg XFREE (new_value); 492234977a2fSmrg } 492334977a2fSmrg} 4924ee3138f1Smrg 492534977a2fSmrgvoid 492634977a2fSmrglt_update_lib_path (const char *name, const char *value) 492734977a2fSmrg{ 4928b425557eSmrg lt_debugprintf (__FILE__, __LINE__, 4929b425557eSmrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 4930b425557eSmrg nonnull (name), nonnull (value)); 4931ee3138f1Smrg 493234977a2fSmrg if (name && *name && value && *value) 493334977a2fSmrg { 493434977a2fSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 493534977a2fSmrg lt_setenv (name, new_value); 493634977a2fSmrg XFREE (new_value); 493734977a2fSmrg } 493834977a2fSmrg} 4939ee3138f1Smrg 4940b425557eSmrgEOF 4941b425557eSmrg case $host_os in 4942b425557eSmrg mingw*) 4943b425557eSmrg cat <<"EOF" 4944b425557eSmrg 4945b425557eSmrg/* Prepares an argument vector before calling spawn(). 4946b425557eSmrg Note that spawn() does not by itself call the command interpreter 4947b425557eSmrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 4948b425557eSmrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 4949b425557eSmrg GetVersionEx(&v); 4950b425557eSmrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 4951b425557eSmrg }) ? "cmd.exe" : "command.com"). 4952b425557eSmrg Instead it simply concatenates the arguments, separated by ' ', and calls 4953b425557eSmrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 4954b425557eSmrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 4955b425557eSmrg special way: 4956b425557eSmrg - Space and tab are interpreted as delimiters. They are not treated as 4957b425557eSmrg delimiters if they are surrounded by double quotes: "...". 4958b425557eSmrg - Unescaped double quotes are removed from the input. Their only effect is 4959b425557eSmrg that within double quotes, space and tab are treated like normal 4960b425557eSmrg characters. 4961b425557eSmrg - Backslashes not followed by double quotes are not special. 4962b425557eSmrg - But 2*n+1 backslashes followed by a double quote become 4963b425557eSmrg n backslashes followed by a double quote (n >= 0): 4964b425557eSmrg \" -> " 4965b425557eSmrg \\\" -> \" 4966b425557eSmrg \\\\\" -> \\" 4967b425557eSmrg */ 4968b425557eSmrg#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" 4969b425557eSmrg#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" 4970b425557eSmrgchar ** 4971b425557eSmrgprepare_spawn (char **argv) 4972b425557eSmrg{ 4973b425557eSmrg size_t argc; 4974b425557eSmrg char **new_argv; 4975b425557eSmrg size_t i; 4976b425557eSmrg 4977b425557eSmrg /* Count number of arguments. */ 4978b425557eSmrg for (argc = 0; argv[argc] != NULL; argc++) 4979b425557eSmrg ; 4980b425557eSmrg 4981b425557eSmrg /* Allocate new argument vector. */ 4982b425557eSmrg new_argv = XMALLOC (char *, argc + 1); 4983b425557eSmrg 4984b425557eSmrg /* Put quoted arguments into the new argument vector. */ 4985b425557eSmrg for (i = 0; i < argc; i++) 4986b425557eSmrg { 4987b425557eSmrg const char *string = argv[i]; 4988b425557eSmrg 4989b425557eSmrg if (string[0] == '\0') 4990b425557eSmrg new_argv[i] = xstrdup ("\"\""); 4991b425557eSmrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 4992b425557eSmrg { 4993b425557eSmrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 4994b425557eSmrg size_t length; 4995b425557eSmrg unsigned int backslashes; 4996b425557eSmrg const char *s; 4997b425557eSmrg char *quoted_string; 4998b425557eSmrg char *p; 4999b425557eSmrg 5000b425557eSmrg length = 0; 5001b425557eSmrg backslashes = 0; 5002b425557eSmrg if (quote_around) 5003b425557eSmrg length++; 5004b425557eSmrg for (s = string; *s != '\0'; s++) 5005b425557eSmrg { 5006b425557eSmrg char c = *s; 5007b425557eSmrg if (c == '"') 5008b425557eSmrg length += backslashes + 1; 5009b425557eSmrg length++; 5010b425557eSmrg if (c == '\\') 5011b425557eSmrg backslashes++; 5012b425557eSmrg else 5013b425557eSmrg backslashes = 0; 5014b425557eSmrg } 5015b425557eSmrg if (quote_around) 5016b425557eSmrg length += backslashes + 1; 5017b425557eSmrg 5018b425557eSmrg quoted_string = XMALLOC (char, length + 1); 5019b425557eSmrg 5020b425557eSmrg p = quoted_string; 5021b425557eSmrg backslashes = 0; 5022b425557eSmrg if (quote_around) 5023b425557eSmrg *p++ = '"'; 5024b425557eSmrg for (s = string; *s != '\0'; s++) 5025b425557eSmrg { 5026b425557eSmrg char c = *s; 5027b425557eSmrg if (c == '"') 5028b425557eSmrg { 5029b425557eSmrg unsigned int j; 5030b425557eSmrg for (j = backslashes + 1; j > 0; j--) 5031b425557eSmrg *p++ = '\\'; 5032b425557eSmrg } 5033b425557eSmrg *p++ = c; 5034b425557eSmrg if (c == '\\') 5035b425557eSmrg backslashes++; 5036b425557eSmrg else 5037b425557eSmrg backslashes = 0; 5038b425557eSmrg } 5039b425557eSmrg if (quote_around) 5040b425557eSmrg { 5041b425557eSmrg unsigned int j; 5042b425557eSmrg for (j = backslashes; j > 0; j--) 5043b425557eSmrg *p++ = '\\'; 5044b425557eSmrg *p++ = '"'; 5045b425557eSmrg } 5046b425557eSmrg *p = '\0'; 5047b425557eSmrg 5048b425557eSmrg new_argv[i] = quoted_string; 5049b425557eSmrg } 5050b425557eSmrg else 5051b425557eSmrg new_argv[i] = (char *) string; 5052b425557eSmrg } 5053b425557eSmrg new_argv[argc] = NULL; 5054b425557eSmrg 5055b425557eSmrg return new_argv; 5056b425557eSmrg} 5057b425557eSmrgEOF 5058b425557eSmrg ;; 5059b425557eSmrg esac 5060b425557eSmrg 5061b425557eSmrg cat <<"EOF" 5062b425557eSmrgvoid lt_dump_script (FILE* f) 5063b425557eSmrg{ 5064b425557eSmrgEOF 5065b425557eSmrg func_emit_wrapper yes | 50663e72ca8cSmrg $SED -n -e ' 50673e72ca8cSmrgs/^\(.\{79\}\)\(..*\)/\1\ 50683e72ca8cSmrg\2/ 50693e72ca8cSmrgh 50703e72ca8cSmrgs/\([\\"]\)/\\\1/g 50713e72ca8cSmrgs/$/\\n/ 50723e72ca8cSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 50733e72ca8cSmrgg 50743e72ca8cSmrgD' 5075b425557eSmrg cat <<"EOF" 5076b425557eSmrg} 507734977a2fSmrgEOF 507834977a2fSmrg} 507934977a2fSmrg# end: func_emit_cwrapperexe_src 5080ee3138f1Smrg 5081b425557eSmrg# func_win32_import_lib_p ARG 5082b425557eSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd 5083b425557eSmrgfunc_win32_import_lib_p () 5084b425557eSmrg{ 5085b425557eSmrg $opt_debug 5086b425557eSmrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 5087b425557eSmrg *import*) : ;; 5088b425557eSmrg *) false ;; 5089b425557eSmrg esac 5090b425557eSmrg} 5091b425557eSmrg 509234977a2fSmrg# func_mode_link arg... 509334977a2fSmrgfunc_mode_link () 509434977a2fSmrg{ 509534977a2fSmrg $opt_debug 509634977a2fSmrg case $host in 509734977a2fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 509834977a2fSmrg # It is impossible to link a dll without this setting, and 509934977a2fSmrg # we shouldn't force the makefile maintainer to figure out 510034977a2fSmrg # which system we are compiling for in order to pass an extra 510134977a2fSmrg # flag for every libtool invocation. 510234977a2fSmrg # allow_undefined=no 5103ee3138f1Smrg 510434977a2fSmrg # FIXME: Unfortunately, there are problems with the above when trying 510534977a2fSmrg # to make a dll which has undefined symbols, in which case not 510634977a2fSmrg # even a static library is built. For now, we need to specify 510734977a2fSmrg # -no-undefined on the libtool link line when we can be certain 510834977a2fSmrg # that all symbols are satisfied, otherwise we get a static library. 510934977a2fSmrg allow_undefined=yes 511034977a2fSmrg ;; 511134977a2fSmrg *) 511234977a2fSmrg allow_undefined=yes 511334977a2fSmrg ;; 511434977a2fSmrg esac 511534977a2fSmrg libtool_args=$nonopt 511634977a2fSmrg base_compile="$nonopt $@" 511734977a2fSmrg compile_command=$nonopt 511834977a2fSmrg finalize_command=$nonopt 5119ee3138f1Smrg 512034977a2fSmrg compile_rpath= 512134977a2fSmrg finalize_rpath= 512234977a2fSmrg compile_shlibpath= 512334977a2fSmrg finalize_shlibpath= 512434977a2fSmrg convenience= 512534977a2fSmrg old_convenience= 512634977a2fSmrg deplibs= 512734977a2fSmrg old_deplibs= 512834977a2fSmrg compiler_flags= 512934977a2fSmrg linker_flags= 513034977a2fSmrg dllsearchpath= 513134977a2fSmrg lib_search_path=`pwd` 513234977a2fSmrg inst_prefix_dir= 513334977a2fSmrg new_inherited_linker_flags= 5134ee3138f1Smrg 513534977a2fSmrg avoid_version=no 5136b425557eSmrg bindir= 513734977a2fSmrg dlfiles= 513834977a2fSmrg dlprefiles= 513934977a2fSmrg dlself=no 514034977a2fSmrg export_dynamic=no 514134977a2fSmrg export_symbols= 514234977a2fSmrg export_symbols_regex= 514334977a2fSmrg generated= 514434977a2fSmrg libobjs= 514534977a2fSmrg ltlibs= 514634977a2fSmrg module=no 514734977a2fSmrg no_install=no 514834977a2fSmrg objs= 514934977a2fSmrg non_pic_objects= 515034977a2fSmrg precious_files_regex= 515134977a2fSmrg prefer_static_libs=no 515234977a2fSmrg preload=no 515334977a2fSmrg prev= 515434977a2fSmrg prevarg= 515534977a2fSmrg release= 515634977a2fSmrg rpath= 515734977a2fSmrg xrpath= 515834977a2fSmrg perm_rpath= 515934977a2fSmrg temp_rpath= 516034977a2fSmrg thread_safe=no 516134977a2fSmrg vinfo= 516234977a2fSmrg vinfo_number=no 516334977a2fSmrg weak_libs= 516434977a2fSmrg single_module="${wl}-single_module" 516534977a2fSmrg func_infer_tag $base_compile 5166ee3138f1Smrg 516734977a2fSmrg # We need to know -static, to get the right output filenames. 516834977a2fSmrg for arg 516934977a2fSmrg do 517034977a2fSmrg case $arg in 517134977a2fSmrg -shared) 517234977a2fSmrg test "$build_libtool_libs" != yes && \ 517334977a2fSmrg func_fatal_configuration "can not build a shared library" 517434977a2fSmrg build_old_libs=no 517534977a2fSmrg break 517634977a2fSmrg ;; 517734977a2fSmrg -all-static | -static | -static-libtool-libs) 517834977a2fSmrg case $arg in 517934977a2fSmrg -all-static) 518034977a2fSmrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 518134977a2fSmrg func_warning "complete static linking is impossible in this configuration" 518234977a2fSmrg fi 518334977a2fSmrg if test -n "$link_static_flag"; then 518434977a2fSmrg dlopen_self=$dlopen_self_static 518534977a2fSmrg fi 518634977a2fSmrg prefer_static_libs=yes 518734977a2fSmrg ;; 518834977a2fSmrg -static) 518934977a2fSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 519034977a2fSmrg dlopen_self=$dlopen_self_static 519134977a2fSmrg fi 519234977a2fSmrg prefer_static_libs=built 519334977a2fSmrg ;; 519434977a2fSmrg -static-libtool-libs) 519534977a2fSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 519634977a2fSmrg dlopen_self=$dlopen_self_static 519734977a2fSmrg fi 519834977a2fSmrg prefer_static_libs=yes 519934977a2fSmrg ;; 520034977a2fSmrg esac 520134977a2fSmrg build_libtool_libs=no 520234977a2fSmrg build_old_libs=yes 520334977a2fSmrg break 520434977a2fSmrg ;; 520534977a2fSmrg esac 520634977a2fSmrg done 5207ee3138f1Smrg 520834977a2fSmrg # See if our shared archives depend on static archives. 520934977a2fSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 5210ee3138f1Smrg 521134977a2fSmrg # Go through the arguments, transforming them on the way. 521234977a2fSmrg while test "$#" -gt 0; do 521334977a2fSmrg arg="$1" 521434977a2fSmrg shift 521534977a2fSmrg func_quote_for_eval "$arg" 521634977a2fSmrg qarg=$func_quote_for_eval_unquoted_result 521734977a2fSmrg func_append libtool_args " $func_quote_for_eval_result" 5218ee3138f1Smrg 521934977a2fSmrg # If the previous option needs an argument, assign it. 522034977a2fSmrg if test -n "$prev"; then 522134977a2fSmrg case $prev in 522234977a2fSmrg output) 522334977a2fSmrg func_append compile_command " @OUTPUT@" 522434977a2fSmrg func_append finalize_command " @OUTPUT@" 522534977a2fSmrg ;; 522634977a2fSmrg esac 5227ee3138f1Smrg 522834977a2fSmrg case $prev in 5229b425557eSmrg bindir) 5230b425557eSmrg bindir="$arg" 5231b425557eSmrg prev= 5232b425557eSmrg continue 5233b425557eSmrg ;; 523434977a2fSmrg dlfiles|dlprefiles) 523534977a2fSmrg if test "$preload" = no; then 523634977a2fSmrg # Add the symbol object into the linking commands. 523734977a2fSmrg func_append compile_command " @SYMFILE@" 523834977a2fSmrg func_append finalize_command " @SYMFILE@" 523934977a2fSmrg preload=yes 5240ee3138f1Smrg fi 524134977a2fSmrg case $arg in 524234977a2fSmrg *.la | *.lo) ;; # We handle these cases below. 524334977a2fSmrg force) 524434977a2fSmrg if test "$dlself" = no; then 524534977a2fSmrg dlself=needless 524634977a2fSmrg export_dynamic=yes 524734977a2fSmrg fi 524834977a2fSmrg prev= 524934977a2fSmrg continue 525034977a2fSmrg ;; 525134977a2fSmrg self) 525234977a2fSmrg if test "$prev" = dlprefiles; then 525334977a2fSmrg dlself=yes 525434977a2fSmrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 525534977a2fSmrg dlself=yes 525634977a2fSmrg else 525734977a2fSmrg dlself=needless 525834977a2fSmrg export_dynamic=yes 525934977a2fSmrg fi 526034977a2fSmrg prev= 526134977a2fSmrg continue 526234977a2fSmrg ;; 526334977a2fSmrg *) 526434977a2fSmrg if test "$prev" = dlfiles; then 52653e72ca8cSmrg func_append dlfiles " $arg" 526634977a2fSmrg else 52673e72ca8cSmrg func_append dlprefiles " $arg" 526834977a2fSmrg fi 526934977a2fSmrg prev= 527034977a2fSmrg continue 527134977a2fSmrg ;; 527234977a2fSmrg esac 527334977a2fSmrg ;; 527434977a2fSmrg expsyms) 527534977a2fSmrg export_symbols="$arg" 527634977a2fSmrg test -f "$arg" \ 527734977a2fSmrg || func_fatal_error "symbol file \`$arg' does not exist" 527834977a2fSmrg prev= 527934977a2fSmrg continue 528034977a2fSmrg ;; 528134977a2fSmrg expsyms_regex) 528234977a2fSmrg export_symbols_regex="$arg" 528334977a2fSmrg prev= 528434977a2fSmrg continue 528534977a2fSmrg ;; 528634977a2fSmrg framework) 5287ee3138f1Smrg case $host in 528834977a2fSmrg *-*-darwin*) 528934977a2fSmrg case "$deplibs " in 529034977a2fSmrg *" $qarg.ltframework "*) ;; 52913e72ca8cSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 529234977a2fSmrg ;; 529334977a2fSmrg esac 529434977a2fSmrg ;; 5295ee3138f1Smrg esac 529634977a2fSmrg prev= 529734977a2fSmrg continue 5298ee3138f1Smrg ;; 529934977a2fSmrg inst_prefix) 530034977a2fSmrg inst_prefix_dir="$arg" 530134977a2fSmrg prev= 530234977a2fSmrg continue 5303ee3138f1Smrg ;; 530434977a2fSmrg objectlist) 530534977a2fSmrg if test -f "$arg"; then 530634977a2fSmrg save_arg=$arg 530734977a2fSmrg moreargs= 530834977a2fSmrg for fil in `cat "$save_arg"` 530934977a2fSmrg do 53103e72ca8cSmrg# func_append moreargs " $fil" 531134977a2fSmrg arg=$fil 531234977a2fSmrg # A libtool-controlled object. 5313ee3138f1Smrg 531434977a2fSmrg # Check to see that this really is a libtool object. 531534977a2fSmrg if func_lalib_unsafe_p "$arg"; then 531634977a2fSmrg pic_object= 531734977a2fSmrg non_pic_object= 5318ee3138f1Smrg 531934977a2fSmrg # Read the .lo file 532034977a2fSmrg func_source "$arg" 5321ee3138f1Smrg 532234977a2fSmrg if test -z "$pic_object" || 532334977a2fSmrg test -z "$non_pic_object" || 532434977a2fSmrg test "$pic_object" = none && 532534977a2fSmrg test "$non_pic_object" = none; then 532634977a2fSmrg func_fatal_error "cannot find name of object for \`$arg'" 532734977a2fSmrg fi 5328ee3138f1Smrg 532934977a2fSmrg # Extract subdirectory from the argument. 533034977a2fSmrg func_dirname "$arg" "/" "" 533134977a2fSmrg xdir="$func_dirname_result" 5332ee3138f1Smrg 533334977a2fSmrg if test "$pic_object" != none; then 533434977a2fSmrg # Prepend the subdirectory the object is found in. 533534977a2fSmrg pic_object="$xdir$pic_object" 5336ee3138f1Smrg 533734977a2fSmrg if test "$prev" = dlfiles; then 533834977a2fSmrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 53393e72ca8cSmrg func_append dlfiles " $pic_object" 534034977a2fSmrg prev= 534134977a2fSmrg continue 534234977a2fSmrg else 534334977a2fSmrg # If libtool objects are unsupported, then we need to preload. 534434977a2fSmrg prev=dlprefiles 534534977a2fSmrg fi 534634977a2fSmrg fi 5347ee3138f1Smrg 534834977a2fSmrg # CHECK ME: I think I busted this. -Ossama 534934977a2fSmrg if test "$prev" = dlprefiles; then 535034977a2fSmrg # Preload the old-style object. 53513e72ca8cSmrg func_append dlprefiles " $pic_object" 535234977a2fSmrg prev= 535334977a2fSmrg fi 5354ee3138f1Smrg 535534977a2fSmrg # A PIC object. 535634977a2fSmrg func_append libobjs " $pic_object" 535734977a2fSmrg arg="$pic_object" 535834977a2fSmrg fi 5359ee3138f1Smrg 536034977a2fSmrg # Non-PIC object. 536134977a2fSmrg if test "$non_pic_object" != none; then 536234977a2fSmrg # Prepend the subdirectory the object is found in. 536334977a2fSmrg non_pic_object="$xdir$non_pic_object" 536434977a2fSmrg 536534977a2fSmrg # A standard non-PIC object 536634977a2fSmrg func_append non_pic_objects " $non_pic_object" 536734977a2fSmrg if test -z "$pic_object" || test "$pic_object" = none ; then 536834977a2fSmrg arg="$non_pic_object" 536934977a2fSmrg fi 537034977a2fSmrg else 537134977a2fSmrg # If the PIC object exists, use it instead. 537234977a2fSmrg # $xdir was prepended to $pic_object above. 537334977a2fSmrg non_pic_object="$pic_object" 537434977a2fSmrg func_append non_pic_objects " $non_pic_object" 537534977a2fSmrg fi 537634977a2fSmrg else 537734977a2fSmrg # Only an error if not doing a dry-run. 537834977a2fSmrg if $opt_dry_run; then 537934977a2fSmrg # Extract subdirectory from the argument. 538034977a2fSmrg func_dirname "$arg" "/" "" 538134977a2fSmrg xdir="$func_dirname_result" 538234977a2fSmrg 538334977a2fSmrg func_lo2o "$arg" 538434977a2fSmrg pic_object=$xdir$objdir/$func_lo2o_result 538534977a2fSmrg non_pic_object=$xdir$func_lo2o_result 538634977a2fSmrg func_append libobjs " $pic_object" 538734977a2fSmrg func_append non_pic_objects " $non_pic_object" 538834977a2fSmrg else 538934977a2fSmrg func_fatal_error "\`$arg' is not a valid libtool object" 539034977a2fSmrg fi 539134977a2fSmrg fi 539234977a2fSmrg done 5393ee3138f1Smrg else 539434977a2fSmrg func_fatal_error "link input file \`$arg' does not exist" 5395ee3138f1Smrg fi 539634977a2fSmrg arg=$save_arg 539734977a2fSmrg prev= 539834977a2fSmrg continue 539934977a2fSmrg ;; 540034977a2fSmrg precious_regex) 540134977a2fSmrg precious_files_regex="$arg" 540234977a2fSmrg prev= 540334977a2fSmrg continue 540434977a2fSmrg ;; 540534977a2fSmrg release) 540634977a2fSmrg release="-$arg" 540734977a2fSmrg prev= 540834977a2fSmrg continue 540934977a2fSmrg ;; 541034977a2fSmrg rpath | xrpath) 541134977a2fSmrg # We need an absolute path. 541234977a2fSmrg case $arg in 541334977a2fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 541434977a2fSmrg *) 541534977a2fSmrg func_fatal_error "only absolute run-paths are allowed" 541634977a2fSmrg ;; 541734977a2fSmrg esac 541834977a2fSmrg if test "$prev" = rpath; then 541934977a2fSmrg case "$rpath " in 542034977a2fSmrg *" $arg "*) ;; 54213e72ca8cSmrg *) func_append rpath " $arg" ;; 542234977a2fSmrg esac 5423ee3138f1Smrg else 542434977a2fSmrg case "$xrpath " in 542534977a2fSmrg *" $arg "*) ;; 54263e72ca8cSmrg *) func_append xrpath " $arg" ;; 542734977a2fSmrg esac 5428ee3138f1Smrg fi 542934977a2fSmrg prev= 543034977a2fSmrg continue 543134977a2fSmrg ;; 543234977a2fSmrg shrext) 543334977a2fSmrg shrext_cmds="$arg" 543434977a2fSmrg prev= 543534977a2fSmrg continue 543634977a2fSmrg ;; 543734977a2fSmrg weak) 54383e72ca8cSmrg func_append weak_libs " $arg" 543934977a2fSmrg prev= 544034977a2fSmrg continue 544134977a2fSmrg ;; 544234977a2fSmrg xcclinker) 54433e72ca8cSmrg func_append linker_flags " $qarg" 54443e72ca8cSmrg func_append compiler_flags " $qarg" 544534977a2fSmrg prev= 544634977a2fSmrg func_append compile_command " $qarg" 544734977a2fSmrg func_append finalize_command " $qarg" 544834977a2fSmrg continue 544934977a2fSmrg ;; 545034977a2fSmrg xcompiler) 54513e72ca8cSmrg func_append compiler_flags " $qarg" 545234977a2fSmrg prev= 545334977a2fSmrg func_append compile_command " $qarg" 545434977a2fSmrg func_append finalize_command " $qarg" 545534977a2fSmrg continue 545634977a2fSmrg ;; 545734977a2fSmrg xlinker) 54583e72ca8cSmrg func_append linker_flags " $qarg" 54593e72ca8cSmrg func_append compiler_flags " $wl$qarg" 546034977a2fSmrg prev= 546134977a2fSmrg func_append compile_command " $wl$qarg" 546234977a2fSmrg func_append finalize_command " $wl$qarg" 546334977a2fSmrg continue 546434977a2fSmrg ;; 546534977a2fSmrg *) 546634977a2fSmrg eval "$prev=\"\$arg\"" 546734977a2fSmrg prev= 546834977a2fSmrg continue 546934977a2fSmrg ;; 5470ee3138f1Smrg esac 547134977a2fSmrg fi # test -n "$prev" 5472ee3138f1Smrg 547334977a2fSmrg prevarg="$arg" 5474ee3138f1Smrg 547534977a2fSmrg case $arg in 547634977a2fSmrg -all-static) 547734977a2fSmrg if test -n "$link_static_flag"; then 547834977a2fSmrg # See comment for -static flag below, for more details. 547934977a2fSmrg func_append compile_command " $link_static_flag" 548034977a2fSmrg func_append finalize_command " $link_static_flag" 548134977a2fSmrg fi 548234977a2fSmrg continue 548334977a2fSmrg ;; 5484ee3138f1Smrg 548534977a2fSmrg -allow-undefined) 548634977a2fSmrg # FIXME: remove this flag sometime in the future. 548734977a2fSmrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 548834977a2fSmrg ;; 5489ee3138f1Smrg 549034977a2fSmrg -avoid-version) 549134977a2fSmrg avoid_version=yes 549234977a2fSmrg continue 549334977a2fSmrg ;; 5494ee3138f1Smrg 5495b425557eSmrg -bindir) 5496b425557eSmrg prev=bindir 5497b425557eSmrg continue 5498b425557eSmrg ;; 5499b425557eSmrg 550034977a2fSmrg -dlopen) 550134977a2fSmrg prev=dlfiles 550234977a2fSmrg continue 550334977a2fSmrg ;; 5504ee3138f1Smrg 550534977a2fSmrg -dlpreopen) 550634977a2fSmrg prev=dlprefiles 550734977a2fSmrg continue 550834977a2fSmrg ;; 5509ee3138f1Smrg 551034977a2fSmrg -export-dynamic) 551134977a2fSmrg export_dynamic=yes 551234977a2fSmrg continue 551334977a2fSmrg ;; 5514ee3138f1Smrg 551534977a2fSmrg -export-symbols | -export-symbols-regex) 551634977a2fSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 551734977a2fSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 551834977a2fSmrg fi 551934977a2fSmrg if test "X$arg" = "X-export-symbols"; then 552034977a2fSmrg prev=expsyms 552134977a2fSmrg else 552234977a2fSmrg prev=expsyms_regex 552334977a2fSmrg fi 552434977a2fSmrg continue 552534977a2fSmrg ;; 5526ee3138f1Smrg 552734977a2fSmrg -framework) 552834977a2fSmrg prev=framework 552934977a2fSmrg continue 553034977a2fSmrg ;; 5531ee3138f1Smrg 553234977a2fSmrg -inst-prefix-dir) 553334977a2fSmrg prev=inst_prefix 553434977a2fSmrg continue 553534977a2fSmrg ;; 5536ee3138f1Smrg 553734977a2fSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 553834977a2fSmrg # so, if we see these flags be careful not to treat them like -L 553934977a2fSmrg -L[A-Z][A-Z]*:*) 554034977a2fSmrg case $with_gcc/$host in 554134977a2fSmrg no/*-*-irix* | /*-*-irix*) 554234977a2fSmrg func_append compile_command " $arg" 554334977a2fSmrg func_append finalize_command " $arg" 554434977a2fSmrg ;; 554534977a2fSmrg esac 554634977a2fSmrg continue 554734977a2fSmrg ;; 5548ee3138f1Smrg 554934977a2fSmrg -L*) 55503e72ca8cSmrg func_stripname "-L" '' "$arg" 55513e72ca8cSmrg if test -z "$func_stripname_result"; then 555234977a2fSmrg if test "$#" -gt 0; then 555334977a2fSmrg func_fatal_error "require no space between \`-L' and \`$1'" 555434977a2fSmrg else 555534977a2fSmrg func_fatal_error "need path for \`-L' option" 555634977a2fSmrg fi 555734977a2fSmrg fi 55583e72ca8cSmrg func_resolve_sysroot "$func_stripname_result" 55593e72ca8cSmrg dir=$func_resolve_sysroot_result 556034977a2fSmrg # We need an absolute path. 556134977a2fSmrg case $dir in 556234977a2fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 556334977a2fSmrg *) 556434977a2fSmrg absdir=`cd "$dir" && pwd` 556534977a2fSmrg test -z "$absdir" && \ 556634977a2fSmrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 556734977a2fSmrg dir="$absdir" 556834977a2fSmrg ;; 556934977a2fSmrg esac 557034977a2fSmrg case "$deplibs " in 55713e72ca8cSmrg *" -L$dir "* | *" $arg "*) 55723e72ca8cSmrg # Will only happen for absolute or sysroot arguments 55733e72ca8cSmrg ;; 557434977a2fSmrg *) 55753e72ca8cSmrg # Preserve sysroot, but never include relative directories 55763e72ca8cSmrg case $dir in 55773e72ca8cSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 55783e72ca8cSmrg *) func_append deplibs " -L$dir" ;; 55793e72ca8cSmrg esac 55803e72ca8cSmrg func_append lib_search_path " $dir" 558134977a2fSmrg ;; 558234977a2fSmrg esac 558334977a2fSmrg case $host in 558434977a2fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5585b425557eSmrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 558634977a2fSmrg case :$dllsearchpath: in 558734977a2fSmrg *":$dir:"*) ;; 558834977a2fSmrg ::) dllsearchpath=$dir;; 55893e72ca8cSmrg *) func_append dllsearchpath ":$dir";; 559034977a2fSmrg esac 559134977a2fSmrg case :$dllsearchpath: in 559234977a2fSmrg *":$testbindir:"*) ;; 559334977a2fSmrg ::) dllsearchpath=$testbindir;; 55943e72ca8cSmrg *) func_append dllsearchpath ":$testbindir";; 559534977a2fSmrg esac 559634977a2fSmrg ;; 559734977a2fSmrg esac 559834977a2fSmrg continue 559934977a2fSmrg ;; 5600ee3138f1Smrg 560134977a2fSmrg -l*) 560234977a2fSmrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 560334977a2fSmrg case $host in 5604b425557eSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 560534977a2fSmrg # These systems don't actually have a C or math library (as such) 560634977a2fSmrg continue 560734977a2fSmrg ;; 560834977a2fSmrg *-*-os2*) 560934977a2fSmrg # These systems don't actually have a C library (as such) 561034977a2fSmrg test "X$arg" = "X-lc" && continue 561134977a2fSmrg ;; 561234977a2fSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 561334977a2fSmrg # Do not include libc due to us having libc/libc_r. 561434977a2fSmrg test "X$arg" = "X-lc" && continue 561534977a2fSmrg ;; 561634977a2fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 561734977a2fSmrg # Rhapsody C and math libraries are in the System framework 56183e72ca8cSmrg func_append deplibs " System.ltframework" 561934977a2fSmrg continue 562034977a2fSmrg ;; 562134977a2fSmrg *-*-sco3.2v5* | *-*-sco5v6*) 562234977a2fSmrg # Causes problems with __ctype 562334977a2fSmrg test "X$arg" = "X-lc" && continue 562434977a2fSmrg ;; 562534977a2fSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 562634977a2fSmrg # Compiler inserts libc in the correct place for threads to work 562734977a2fSmrg test "X$arg" = "X-lc" && continue 562834977a2fSmrg ;; 562934977a2fSmrg esac 563034977a2fSmrg elif test "X$arg" = "X-lc_r"; then 563134977a2fSmrg case $host in 563234977a2fSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 563334977a2fSmrg # Do not include libc_r directly, use -pthread flag. 563434977a2fSmrg continue 563534977a2fSmrg ;; 563634977a2fSmrg esac 563734977a2fSmrg fi 56383e72ca8cSmrg func_append deplibs " $arg" 563934977a2fSmrg continue 564034977a2fSmrg ;; 5641ee3138f1Smrg 564234977a2fSmrg -module) 564334977a2fSmrg module=yes 564434977a2fSmrg continue 564534977a2fSmrg ;; 5646ee3138f1Smrg 564734977a2fSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 564834977a2fSmrg # classes, name mangling, and exception handling. 564934977a2fSmrg # Darwin uses the -arch flag to determine output architecture. 56503e72ca8cSmrg -model|-arch|-isysroot|--sysroot) 56513e72ca8cSmrg func_append compiler_flags " $arg" 565234977a2fSmrg func_append compile_command " $arg" 565334977a2fSmrg func_append finalize_command " $arg" 565434977a2fSmrg prev=xcompiler 565534977a2fSmrg continue 565634977a2fSmrg ;; 5657ee3138f1Smrg 56583e72ca8cSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 56593e72ca8cSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 56603e72ca8cSmrg func_append compiler_flags " $arg" 566134977a2fSmrg func_append compile_command " $arg" 566234977a2fSmrg func_append finalize_command " $arg" 566334977a2fSmrg case "$new_inherited_linker_flags " in 566434977a2fSmrg *" $arg "*) ;; 56653e72ca8cSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 566634977a2fSmrg esac 566734977a2fSmrg continue 566834977a2fSmrg ;; 5669ee3138f1Smrg 567034977a2fSmrg -multi_module) 567134977a2fSmrg single_module="${wl}-multi_module" 567234977a2fSmrg continue 567334977a2fSmrg ;; 5674ee3138f1Smrg 567534977a2fSmrg -no-fast-install) 567634977a2fSmrg fast_install=no 567734977a2fSmrg continue 567834977a2fSmrg ;; 5679ee3138f1Smrg 568034977a2fSmrg -no-install) 568134977a2fSmrg case $host in 568234977a2fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 568334977a2fSmrg # The PATH hackery in wrapper scripts is required on Windows 568434977a2fSmrg # and Darwin in order for the loader to find any dlls it needs. 568534977a2fSmrg func_warning "\`-no-install' is ignored for $host" 568634977a2fSmrg func_warning "assuming \`-no-fast-install' instead" 568734977a2fSmrg fast_install=no 568834977a2fSmrg ;; 568934977a2fSmrg *) no_install=yes ;; 569034977a2fSmrg esac 569134977a2fSmrg continue 569234977a2fSmrg ;; 5693ee3138f1Smrg 569434977a2fSmrg -no-undefined) 569534977a2fSmrg allow_undefined=no 569634977a2fSmrg continue 569734977a2fSmrg ;; 5698ee3138f1Smrg 569934977a2fSmrg -objectlist) 570034977a2fSmrg prev=objectlist 570134977a2fSmrg continue 570234977a2fSmrg ;; 5703ee3138f1Smrg 570434977a2fSmrg -o) prev=output ;; 5705ee3138f1Smrg 570634977a2fSmrg -precious-files-regex) 570734977a2fSmrg prev=precious_regex 570834977a2fSmrg continue 570934977a2fSmrg ;; 5710ee3138f1Smrg 571134977a2fSmrg -release) 571234977a2fSmrg prev=release 571334977a2fSmrg continue 571434977a2fSmrg ;; 5715ee3138f1Smrg 571634977a2fSmrg -rpath) 571734977a2fSmrg prev=rpath 571834977a2fSmrg continue 571934977a2fSmrg ;; 5720ee3138f1Smrg 572134977a2fSmrg -R) 572234977a2fSmrg prev=xrpath 572334977a2fSmrg continue 572434977a2fSmrg ;; 5725ee3138f1Smrg 572634977a2fSmrg -R*) 572734977a2fSmrg func_stripname '-R' '' "$arg" 572834977a2fSmrg dir=$func_stripname_result 572934977a2fSmrg # We need an absolute path. 573034977a2fSmrg case $dir in 573134977a2fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 57323e72ca8cSmrg =*) 57333e72ca8cSmrg func_stripname '=' '' "$dir" 57343e72ca8cSmrg dir=$lt_sysroot$func_stripname_result 57353e72ca8cSmrg ;; 573634977a2fSmrg *) 573734977a2fSmrg func_fatal_error "only absolute run-paths are allowed" 573834977a2fSmrg ;; 573934977a2fSmrg esac 574034977a2fSmrg case "$xrpath " in 574134977a2fSmrg *" $dir "*) ;; 57423e72ca8cSmrg *) func_append xrpath " $dir" ;; 574334977a2fSmrg esac 574434977a2fSmrg continue 574534977a2fSmrg ;; 5746ee3138f1Smrg 574734977a2fSmrg -shared) 574834977a2fSmrg # The effects of -shared are defined in a previous loop. 574934977a2fSmrg continue 575034977a2fSmrg ;; 5751ee3138f1Smrg 575234977a2fSmrg -shrext) 575334977a2fSmrg prev=shrext 575434977a2fSmrg continue 575534977a2fSmrg ;; 5756ee3138f1Smrg 575734977a2fSmrg -static | -static-libtool-libs) 575834977a2fSmrg # The effects of -static are defined in a previous loop. 575934977a2fSmrg # We used to do the same as -all-static on platforms that 576034977a2fSmrg # didn't have a PIC flag, but the assumption that the effects 576134977a2fSmrg # would be equivalent was wrong. It would break on at least 576234977a2fSmrg # Digital Unix and AIX. 576334977a2fSmrg continue 576434977a2fSmrg ;; 5765ee3138f1Smrg 576634977a2fSmrg -thread-safe) 576734977a2fSmrg thread_safe=yes 576834977a2fSmrg continue 576934977a2fSmrg ;; 5770ee3138f1Smrg 577134977a2fSmrg -version-info) 577234977a2fSmrg prev=vinfo 577334977a2fSmrg continue 577434977a2fSmrg ;; 5775ee3138f1Smrg 577634977a2fSmrg -version-number) 577734977a2fSmrg prev=vinfo 577834977a2fSmrg vinfo_number=yes 577934977a2fSmrg continue 578034977a2fSmrg ;; 5781ee3138f1Smrg 578234977a2fSmrg -weak) 578334977a2fSmrg prev=weak 578434977a2fSmrg continue 578534977a2fSmrg ;; 5786ee3138f1Smrg 578734977a2fSmrg -Wc,*) 578834977a2fSmrg func_stripname '-Wc,' '' "$arg" 578934977a2fSmrg args=$func_stripname_result 579034977a2fSmrg arg= 579134977a2fSmrg save_ifs="$IFS"; IFS=',' 579234977a2fSmrg for flag in $args; do 579334977a2fSmrg IFS="$save_ifs" 579434977a2fSmrg func_quote_for_eval "$flag" 57953e72ca8cSmrg func_append arg " $func_quote_for_eval_result" 57963e72ca8cSmrg func_append compiler_flags " $func_quote_for_eval_result" 579734977a2fSmrg done 579834977a2fSmrg IFS="$save_ifs" 579934977a2fSmrg func_stripname ' ' '' "$arg" 580034977a2fSmrg arg=$func_stripname_result 580134977a2fSmrg ;; 5802ee3138f1Smrg 580334977a2fSmrg -Wl,*) 580434977a2fSmrg func_stripname '-Wl,' '' "$arg" 580534977a2fSmrg args=$func_stripname_result 580634977a2fSmrg arg= 580734977a2fSmrg save_ifs="$IFS"; IFS=',' 580834977a2fSmrg for flag in $args; do 580934977a2fSmrg IFS="$save_ifs" 581034977a2fSmrg func_quote_for_eval "$flag" 58113e72ca8cSmrg func_append arg " $wl$func_quote_for_eval_result" 58123e72ca8cSmrg func_append compiler_flags " $wl$func_quote_for_eval_result" 58133e72ca8cSmrg func_append linker_flags " $func_quote_for_eval_result" 581434977a2fSmrg done 581534977a2fSmrg IFS="$save_ifs" 581634977a2fSmrg func_stripname ' ' '' "$arg" 581734977a2fSmrg arg=$func_stripname_result 581834977a2fSmrg ;; 5819ee3138f1Smrg 582034977a2fSmrg -Xcompiler) 582134977a2fSmrg prev=xcompiler 582234977a2fSmrg continue 582334977a2fSmrg ;; 5824ee3138f1Smrg 582534977a2fSmrg -Xlinker) 582634977a2fSmrg prev=xlinker 582734977a2fSmrg continue 582834977a2fSmrg ;; 5829ee3138f1Smrg 583034977a2fSmrg -XCClinker) 583134977a2fSmrg prev=xcclinker 583234977a2fSmrg continue 583334977a2fSmrg ;; 5834ee3138f1Smrg 583534977a2fSmrg # -msg_* for osf cc 583634977a2fSmrg -msg_*) 583734977a2fSmrg func_quote_for_eval "$arg" 583834977a2fSmrg arg="$func_quote_for_eval_result" 583934977a2fSmrg ;; 5840ee3138f1Smrg 5841b425557eSmrg # Flags to be passed through unchanged, with rationale: 5842b425557eSmrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 5843b425557eSmrg # -r[0-9][0-9]* specify processor for the SGI compiler 5844b425557eSmrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 5845b425557eSmrg # +DA*, +DD* enable 64-bit mode for the HP compiler 5846b425557eSmrg # -q* compiler args for the IBM compiler 5847b425557eSmrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 5848b425557eSmrg # -F/path path to uninstalled frameworks, gcc on darwin 5849b425557eSmrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 5850b425557eSmrg # @file GCC response files 5851b425557eSmrg # -tp=* Portland pgcc target processor selection 58523e72ca8cSmrg # --sysroot=* for sysroot support 58533e72ca8cSmrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 585434977a2fSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 58553e72ca8cSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 58563e72ca8cSmrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 585734977a2fSmrg func_quote_for_eval "$arg" 585834977a2fSmrg arg="$func_quote_for_eval_result" 585934977a2fSmrg func_append compile_command " $arg" 586034977a2fSmrg func_append finalize_command " $arg" 58613e72ca8cSmrg func_append compiler_flags " $arg" 586234977a2fSmrg continue 586334977a2fSmrg ;; 5864ee3138f1Smrg 586534977a2fSmrg # Some other compiler flag. 586634977a2fSmrg -* | +*) 586734977a2fSmrg func_quote_for_eval "$arg" 586834977a2fSmrg arg="$func_quote_for_eval_result" 586934977a2fSmrg ;; 5870ee3138f1Smrg 587134977a2fSmrg *.$objext) 587234977a2fSmrg # A standard object. 58733e72ca8cSmrg func_append objs " $arg" 587434977a2fSmrg ;; 5875ee3138f1Smrg 587634977a2fSmrg *.lo) 587734977a2fSmrg # A libtool-controlled object. 5878ee3138f1Smrg 587934977a2fSmrg # Check to see that this really is a libtool object. 588034977a2fSmrg if func_lalib_unsafe_p "$arg"; then 588134977a2fSmrg pic_object= 588234977a2fSmrg non_pic_object= 5883ee3138f1Smrg 588434977a2fSmrg # Read the .lo file 588534977a2fSmrg func_source "$arg" 5886ee3138f1Smrg 588734977a2fSmrg if test -z "$pic_object" || 588834977a2fSmrg test -z "$non_pic_object" || 588934977a2fSmrg test "$pic_object" = none && 589034977a2fSmrg test "$non_pic_object" = none; then 589134977a2fSmrg func_fatal_error "cannot find name of object for \`$arg'" 589234977a2fSmrg fi 5893ee3138f1Smrg 589434977a2fSmrg # Extract subdirectory from the argument. 589534977a2fSmrg func_dirname "$arg" "/" "" 589634977a2fSmrg xdir="$func_dirname_result" 5897ee3138f1Smrg 589834977a2fSmrg if test "$pic_object" != none; then 589934977a2fSmrg # Prepend the subdirectory the object is found in. 590034977a2fSmrg pic_object="$xdir$pic_object" 5901ee3138f1Smrg 590234977a2fSmrg if test "$prev" = dlfiles; then 590334977a2fSmrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 59043e72ca8cSmrg func_append dlfiles " $pic_object" 590534977a2fSmrg prev= 590634977a2fSmrg continue 590734977a2fSmrg else 590834977a2fSmrg # If libtool objects are unsupported, then we need to preload. 590934977a2fSmrg prev=dlprefiles 591034977a2fSmrg fi 591134977a2fSmrg fi 5912ee3138f1Smrg 591334977a2fSmrg # CHECK ME: I think I busted this. -Ossama 591434977a2fSmrg if test "$prev" = dlprefiles; then 591534977a2fSmrg # Preload the old-style object. 59163e72ca8cSmrg func_append dlprefiles " $pic_object" 591734977a2fSmrg prev= 591834977a2fSmrg fi 5919ee3138f1Smrg 592034977a2fSmrg # A PIC object. 592134977a2fSmrg func_append libobjs " $pic_object" 592234977a2fSmrg arg="$pic_object" 592334977a2fSmrg fi 5924ee3138f1Smrg 592534977a2fSmrg # Non-PIC object. 592634977a2fSmrg if test "$non_pic_object" != none; then 592734977a2fSmrg # Prepend the subdirectory the object is found in. 592834977a2fSmrg non_pic_object="$xdir$non_pic_object" 5929ee3138f1Smrg 593034977a2fSmrg # A standard non-PIC object 593134977a2fSmrg func_append non_pic_objects " $non_pic_object" 593234977a2fSmrg if test -z "$pic_object" || test "$pic_object" = none ; then 593334977a2fSmrg arg="$non_pic_object" 593434977a2fSmrg fi 593534977a2fSmrg else 593634977a2fSmrg # If the PIC object exists, use it instead. 593734977a2fSmrg # $xdir was prepended to $pic_object above. 593834977a2fSmrg non_pic_object="$pic_object" 593934977a2fSmrg func_append non_pic_objects " $non_pic_object" 594034977a2fSmrg fi 594134977a2fSmrg else 594234977a2fSmrg # Only an error if not doing a dry-run. 594334977a2fSmrg if $opt_dry_run; then 594434977a2fSmrg # Extract subdirectory from the argument. 594534977a2fSmrg func_dirname "$arg" "/" "" 594634977a2fSmrg xdir="$func_dirname_result" 594734977a2fSmrg 594834977a2fSmrg func_lo2o "$arg" 594934977a2fSmrg pic_object=$xdir$objdir/$func_lo2o_result 595034977a2fSmrg non_pic_object=$xdir$func_lo2o_result 595134977a2fSmrg func_append libobjs " $pic_object" 595234977a2fSmrg func_append non_pic_objects " $non_pic_object" 595334977a2fSmrg else 595434977a2fSmrg func_fatal_error "\`$arg' is not a valid libtool object" 595534977a2fSmrg fi 595634977a2fSmrg fi 595734977a2fSmrg ;; 595834977a2fSmrg 595934977a2fSmrg *.$libext) 596034977a2fSmrg # An archive. 59613e72ca8cSmrg func_append deplibs " $arg" 59623e72ca8cSmrg func_append old_deplibs " $arg" 596334977a2fSmrg continue 596434977a2fSmrg ;; 596534977a2fSmrg 596634977a2fSmrg *.la) 596734977a2fSmrg # A libtool-controlled library. 596834977a2fSmrg 59693e72ca8cSmrg func_resolve_sysroot "$arg" 597034977a2fSmrg if test "$prev" = dlfiles; then 597134977a2fSmrg # This library was specified with -dlopen. 59723e72ca8cSmrg func_append dlfiles " $func_resolve_sysroot_result" 597334977a2fSmrg prev= 597434977a2fSmrg elif test "$prev" = dlprefiles; then 597534977a2fSmrg # The library was specified with -dlpreopen. 59763e72ca8cSmrg func_append dlprefiles " $func_resolve_sysroot_result" 597734977a2fSmrg prev= 597834977a2fSmrg else 59793e72ca8cSmrg func_append deplibs " $func_resolve_sysroot_result" 598034977a2fSmrg fi 598134977a2fSmrg continue 598234977a2fSmrg ;; 598334977a2fSmrg 598434977a2fSmrg # Some other compiler argument. 598534977a2fSmrg *) 598634977a2fSmrg # Unknown arguments in both finalize_command and compile_command need 598734977a2fSmrg # to be aesthetically quoted because they are evaled later. 598834977a2fSmrg func_quote_for_eval "$arg" 598934977a2fSmrg arg="$func_quote_for_eval_result" 599034977a2fSmrg ;; 599134977a2fSmrg esac # arg 599234977a2fSmrg 599334977a2fSmrg # Now actually substitute the argument into the commands. 599434977a2fSmrg if test -n "$arg"; then 599534977a2fSmrg func_append compile_command " $arg" 599634977a2fSmrg func_append finalize_command " $arg" 599734977a2fSmrg fi 599834977a2fSmrg done # argument parsing loop 599934977a2fSmrg 600034977a2fSmrg test -n "$prev" && \ 600134977a2fSmrg func_fatal_help "the \`$prevarg' option requires an argument" 600234977a2fSmrg 600334977a2fSmrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 600434977a2fSmrg eval arg=\"$export_dynamic_flag_spec\" 600534977a2fSmrg func_append compile_command " $arg" 600634977a2fSmrg func_append finalize_command " $arg" 600734977a2fSmrg fi 600834977a2fSmrg 600934977a2fSmrg oldlibs= 601034977a2fSmrg # calculate the name of the file, without its directory 601134977a2fSmrg func_basename "$output" 601234977a2fSmrg outputname="$func_basename_result" 601334977a2fSmrg libobjs_save="$libobjs" 601434977a2fSmrg 601534977a2fSmrg if test -n "$shlibpath_var"; then 601634977a2fSmrg # get the directories listed in $shlibpath_var 6017b425557eSmrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 601834977a2fSmrg else 601934977a2fSmrg shlib_search_path= 602034977a2fSmrg fi 602134977a2fSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 602234977a2fSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 602334977a2fSmrg 602434977a2fSmrg func_dirname "$output" "/" "" 602534977a2fSmrg output_objdir="$func_dirname_result$objdir" 60263e72ca8cSmrg func_to_tool_file "$output_objdir/" 60273e72ca8cSmrg tool_output_objdir=$func_to_tool_file_result 602834977a2fSmrg # Create the object directory. 602934977a2fSmrg func_mkdir_p "$output_objdir" 603034977a2fSmrg 603134977a2fSmrg # Determine the type of output 603234977a2fSmrg case $output in 603334977a2fSmrg "") 603434977a2fSmrg func_fatal_help "you must specify an output file" 603534977a2fSmrg ;; 603634977a2fSmrg *.$libext) linkmode=oldlib ;; 603734977a2fSmrg *.lo | *.$objext) linkmode=obj ;; 603834977a2fSmrg *.la) linkmode=lib ;; 603934977a2fSmrg *) linkmode=prog ;; # Anything else should be a program. 604034977a2fSmrg esac 604134977a2fSmrg 604234977a2fSmrg specialdeplibs= 604334977a2fSmrg 604434977a2fSmrg libs= 604534977a2fSmrg # Find all interdependent deplibs by searching for libraries 604634977a2fSmrg # that are linked more than once (e.g. -la -lb -la) 604734977a2fSmrg for deplib in $deplibs; do 60483e72ca8cSmrg if $opt_preserve_dup_deps ; then 604934977a2fSmrg case "$libs " in 60503e72ca8cSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 605134977a2fSmrg esac 605234977a2fSmrg fi 60533e72ca8cSmrg func_append libs " $deplib" 605434977a2fSmrg done 605534977a2fSmrg 605634977a2fSmrg if test "$linkmode" = lib; then 605734977a2fSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 605834977a2fSmrg 605934977a2fSmrg # Compute libraries that are listed more than once in $predeps 606034977a2fSmrg # $postdeps and mark them as special (i.e., whose duplicates are 606134977a2fSmrg # not to be eliminated). 606234977a2fSmrg pre_post_deps= 606334977a2fSmrg if $opt_duplicate_compiler_generated_deps; then 606434977a2fSmrg for pre_post_dep in $predeps $postdeps; do 606534977a2fSmrg case "$pre_post_deps " in 60663e72ca8cSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 606734977a2fSmrg esac 60683e72ca8cSmrg func_append pre_post_deps " $pre_post_dep" 606934977a2fSmrg done 607034977a2fSmrg fi 607134977a2fSmrg pre_post_deps= 607234977a2fSmrg fi 607334977a2fSmrg 607434977a2fSmrg deplibs= 607534977a2fSmrg newdependency_libs= 607634977a2fSmrg newlib_search_path= 607734977a2fSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 607834977a2fSmrg notinst_deplibs= # not-installed libtool libraries 607934977a2fSmrg notinst_path= # paths that contain not-installed libtool libraries 608034977a2fSmrg 608134977a2fSmrg case $linkmode in 608234977a2fSmrg lib) 608334977a2fSmrg passes="conv dlpreopen link" 608434977a2fSmrg for file in $dlfiles $dlprefiles; do 608534977a2fSmrg case $file in 608634977a2fSmrg *.la) ;; 608734977a2fSmrg *) 608834977a2fSmrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 608934977a2fSmrg ;; 609034977a2fSmrg esac 609134977a2fSmrg done 609234977a2fSmrg ;; 609334977a2fSmrg prog) 609434977a2fSmrg compile_deplibs= 609534977a2fSmrg finalize_deplibs= 609634977a2fSmrg alldeplibs=no 609734977a2fSmrg newdlfiles= 609834977a2fSmrg newdlprefiles= 609934977a2fSmrg passes="conv scan dlopen dlpreopen link" 610034977a2fSmrg ;; 610134977a2fSmrg *) passes="conv" 610234977a2fSmrg ;; 610334977a2fSmrg esac 610434977a2fSmrg 610534977a2fSmrg for pass in $passes; do 610634977a2fSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 610734977a2fSmrg # so that -L comes before libs that need it for instance... 610834977a2fSmrg if test "$linkmode,$pass" = "lib,link"; then 610934977a2fSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 611034977a2fSmrg ## order, and fix it there properly 611134977a2fSmrg tmp_deplibs= 611234977a2fSmrg for deplib in $deplibs; do 611334977a2fSmrg tmp_deplibs="$deplib $tmp_deplibs" 611434977a2fSmrg done 611534977a2fSmrg deplibs="$tmp_deplibs" 611634977a2fSmrg fi 611734977a2fSmrg 611834977a2fSmrg if test "$linkmode,$pass" = "lib,link" || 611934977a2fSmrg test "$linkmode,$pass" = "prog,scan"; then 612034977a2fSmrg libs="$deplibs" 612134977a2fSmrg deplibs= 612234977a2fSmrg fi 612334977a2fSmrg if test "$linkmode" = prog; then 612434977a2fSmrg case $pass in 612534977a2fSmrg dlopen) libs="$dlfiles" ;; 612634977a2fSmrg dlpreopen) libs="$dlprefiles" ;; 612734977a2fSmrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 612834977a2fSmrg esac 612934977a2fSmrg fi 613034977a2fSmrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 613134977a2fSmrg # Collect and forward deplibs of preopened libtool libs 613234977a2fSmrg for lib in $dlprefiles; do 613334977a2fSmrg # Ignore non-libtool-libs 613434977a2fSmrg dependency_libs= 61353e72ca8cSmrg func_resolve_sysroot "$lib" 613634977a2fSmrg case $lib in 61373e72ca8cSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 613834977a2fSmrg esac 613934977a2fSmrg 614034977a2fSmrg # Collect preopened libtool deplibs, except any this library 614134977a2fSmrg # has declared as weak libs 614234977a2fSmrg for deplib in $dependency_libs; do 6143b425557eSmrg func_basename "$deplib" 6144b425557eSmrg deplib_base=$func_basename_result 614534977a2fSmrg case " $weak_libs " in 614634977a2fSmrg *" $deplib_base "*) ;; 61473e72ca8cSmrg *) func_append deplibs " $deplib" ;; 614834977a2fSmrg esac 614934977a2fSmrg done 615034977a2fSmrg done 615134977a2fSmrg libs="$dlprefiles" 615234977a2fSmrg fi 615334977a2fSmrg if test "$pass" = dlopen; then 615434977a2fSmrg # Collect dlpreopened libraries 615534977a2fSmrg save_deplibs="$deplibs" 615634977a2fSmrg deplibs= 615734977a2fSmrg fi 615834977a2fSmrg 615934977a2fSmrg for deplib in $libs; do 616034977a2fSmrg lib= 616134977a2fSmrg found=no 616234977a2fSmrg case $deplib in 61633e72ca8cSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 61643e72ca8cSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 616534977a2fSmrg if test "$linkmode,$pass" = "prog,link"; then 616634977a2fSmrg compile_deplibs="$deplib $compile_deplibs" 616734977a2fSmrg finalize_deplibs="$deplib $finalize_deplibs" 616834977a2fSmrg else 61693e72ca8cSmrg func_append compiler_flags " $deplib" 617034977a2fSmrg if test "$linkmode" = lib ; then 617134977a2fSmrg case "$new_inherited_linker_flags " in 617234977a2fSmrg *" $deplib "*) ;; 61733e72ca8cSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 617434977a2fSmrg esac 617534977a2fSmrg fi 617634977a2fSmrg fi 617734977a2fSmrg continue 617834977a2fSmrg ;; 617934977a2fSmrg -l*) 618034977a2fSmrg if test "$linkmode" != lib && test "$linkmode" != prog; then 618134977a2fSmrg func_warning "\`-l' is ignored for archives/objects" 618234977a2fSmrg continue 618334977a2fSmrg fi 618434977a2fSmrg func_stripname '-l' '' "$deplib" 618534977a2fSmrg name=$func_stripname_result 618634977a2fSmrg if test "$linkmode" = lib; then 618734977a2fSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 618834977a2fSmrg else 618934977a2fSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 619034977a2fSmrg fi 619134977a2fSmrg for searchdir in $searchdirs; do 619234977a2fSmrg for search_ext in .la $std_shrext .so .a; do 619334977a2fSmrg # Search the libtool library 619434977a2fSmrg lib="$searchdir/lib${name}${search_ext}" 619534977a2fSmrg if test -f "$lib"; then 619634977a2fSmrg if test "$search_ext" = ".la"; then 619734977a2fSmrg found=yes 619834977a2fSmrg else 619934977a2fSmrg found=no 620034977a2fSmrg fi 620134977a2fSmrg break 2 620234977a2fSmrg fi 620334977a2fSmrg done 620434977a2fSmrg done 620534977a2fSmrg if test "$found" != yes; then 620634977a2fSmrg # deplib doesn't seem to be a libtool library 620734977a2fSmrg if test "$linkmode,$pass" = "prog,link"; then 620834977a2fSmrg compile_deplibs="$deplib $compile_deplibs" 620934977a2fSmrg finalize_deplibs="$deplib $finalize_deplibs" 621034977a2fSmrg else 621134977a2fSmrg deplibs="$deplib $deplibs" 621234977a2fSmrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 621334977a2fSmrg fi 621434977a2fSmrg continue 621534977a2fSmrg else # deplib is a libtool library 621634977a2fSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 621734977a2fSmrg # We need to do some special things here, and not later. 621834977a2fSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 621934977a2fSmrg case " $predeps $postdeps " in 622034977a2fSmrg *" $deplib "*) 622134977a2fSmrg if func_lalib_p "$lib"; then 622234977a2fSmrg library_names= 622334977a2fSmrg old_library= 622434977a2fSmrg func_source "$lib" 622534977a2fSmrg for l in $old_library $library_names; do 622634977a2fSmrg ll="$l" 622734977a2fSmrg done 622834977a2fSmrg if test "X$ll" = "X$old_library" ; then # only static version available 622934977a2fSmrg found=no 623034977a2fSmrg func_dirname "$lib" "" "." 623134977a2fSmrg ladir="$func_dirname_result" 623234977a2fSmrg lib=$ladir/$old_library 623334977a2fSmrg if test "$linkmode,$pass" = "prog,link"; then 623434977a2fSmrg compile_deplibs="$deplib $compile_deplibs" 623534977a2fSmrg finalize_deplibs="$deplib $finalize_deplibs" 623634977a2fSmrg else 623734977a2fSmrg deplibs="$deplib $deplibs" 623834977a2fSmrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 623934977a2fSmrg fi 624034977a2fSmrg continue 624134977a2fSmrg fi 624234977a2fSmrg fi 624334977a2fSmrg ;; 624434977a2fSmrg *) ;; 624534977a2fSmrg esac 624634977a2fSmrg fi 624734977a2fSmrg fi 624834977a2fSmrg ;; # -l 624934977a2fSmrg *.ltframework) 625034977a2fSmrg if test "$linkmode,$pass" = "prog,link"; then 625134977a2fSmrg compile_deplibs="$deplib $compile_deplibs" 625234977a2fSmrg finalize_deplibs="$deplib $finalize_deplibs" 625334977a2fSmrg else 625434977a2fSmrg deplibs="$deplib $deplibs" 625534977a2fSmrg if test "$linkmode" = lib ; then 625634977a2fSmrg case "$new_inherited_linker_flags " in 625734977a2fSmrg *" $deplib "*) ;; 62583e72ca8cSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 625934977a2fSmrg esac 626034977a2fSmrg fi 626134977a2fSmrg fi 626234977a2fSmrg continue 626334977a2fSmrg ;; 626434977a2fSmrg -L*) 626534977a2fSmrg case $linkmode in 626634977a2fSmrg lib) 626734977a2fSmrg deplibs="$deplib $deplibs" 626834977a2fSmrg test "$pass" = conv && continue 626934977a2fSmrg newdependency_libs="$deplib $newdependency_libs" 627034977a2fSmrg func_stripname '-L' '' "$deplib" 62713e72ca8cSmrg func_resolve_sysroot "$func_stripname_result" 62723e72ca8cSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 627334977a2fSmrg ;; 627434977a2fSmrg prog) 627534977a2fSmrg if test "$pass" = conv; then 627634977a2fSmrg deplibs="$deplib $deplibs" 627734977a2fSmrg continue 627834977a2fSmrg fi 627934977a2fSmrg if test "$pass" = scan; then 628034977a2fSmrg deplibs="$deplib $deplibs" 628134977a2fSmrg else 628234977a2fSmrg compile_deplibs="$deplib $compile_deplibs" 628334977a2fSmrg finalize_deplibs="$deplib $finalize_deplibs" 628434977a2fSmrg fi 628534977a2fSmrg func_stripname '-L' '' "$deplib" 62863e72ca8cSmrg func_resolve_sysroot "$func_stripname_result" 62873e72ca8cSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 628834977a2fSmrg ;; 628934977a2fSmrg *) 629034977a2fSmrg func_warning "\`-L' is ignored for archives/objects" 629134977a2fSmrg ;; 629234977a2fSmrg esac # linkmode 629334977a2fSmrg continue 629434977a2fSmrg ;; # -L 629534977a2fSmrg -R*) 629634977a2fSmrg if test "$pass" = link; then 629734977a2fSmrg func_stripname '-R' '' "$deplib" 62983e72ca8cSmrg func_resolve_sysroot "$func_stripname_result" 62993e72ca8cSmrg dir=$func_resolve_sysroot_result 630034977a2fSmrg # Make sure the xrpath contains only unique directories. 630134977a2fSmrg case "$xrpath " in 630234977a2fSmrg *" $dir "*) ;; 63033e72ca8cSmrg *) func_append xrpath " $dir" ;; 630434977a2fSmrg esac 630534977a2fSmrg fi 630634977a2fSmrg deplibs="$deplib $deplibs" 630734977a2fSmrg continue 630834977a2fSmrg ;; 63093e72ca8cSmrg *.la) 63103e72ca8cSmrg func_resolve_sysroot "$deplib" 63113e72ca8cSmrg lib=$func_resolve_sysroot_result 63123e72ca8cSmrg ;; 631334977a2fSmrg *.$libext) 631434977a2fSmrg if test "$pass" = conv; then 631534977a2fSmrg deplibs="$deplib $deplibs" 631634977a2fSmrg continue 631734977a2fSmrg fi 631834977a2fSmrg case $linkmode in 631934977a2fSmrg lib) 632034977a2fSmrg # Linking convenience modules into shared libraries is allowed, 632134977a2fSmrg # but linking other static libraries is non-portable. 632234977a2fSmrg case " $dlpreconveniencelibs " in 632334977a2fSmrg *" $deplib "*) ;; 632434977a2fSmrg *) 632534977a2fSmrg valid_a_lib=no 632634977a2fSmrg case $deplibs_check_method in 632734977a2fSmrg match_pattern*) 632834977a2fSmrg set dummy $deplibs_check_method; shift 632934977a2fSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 6330b425557eSmrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 633134977a2fSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 633234977a2fSmrg valid_a_lib=yes 633334977a2fSmrg fi 633434977a2fSmrg ;; 633534977a2fSmrg pass_all) 633634977a2fSmrg valid_a_lib=yes 633734977a2fSmrg ;; 633834977a2fSmrg esac 633934977a2fSmrg if test "$valid_a_lib" != yes; then 6340b425557eSmrg echo 634134977a2fSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 6342b425557eSmrg echo "*** I have the capability to make that library automatically link in when" 6343b425557eSmrg echo "*** you link to this library. But I can only do this if you have a" 6344b425557eSmrg echo "*** shared version of the library, which you do not appear to have" 6345b425557eSmrg echo "*** because the file extensions .$libext of this argument makes me believe" 6346b425557eSmrg echo "*** that it is just a static archive that I should not use here." 634734977a2fSmrg else 6348b425557eSmrg echo 634934977a2fSmrg $ECHO "*** Warning: Linking the shared library $output against the" 635034977a2fSmrg $ECHO "*** static library $deplib is not portable!" 635134977a2fSmrg deplibs="$deplib $deplibs" 635234977a2fSmrg fi 635334977a2fSmrg ;; 635434977a2fSmrg esac 635534977a2fSmrg continue 635634977a2fSmrg ;; 635734977a2fSmrg prog) 635834977a2fSmrg if test "$pass" != link; then 635934977a2fSmrg deplibs="$deplib $deplibs" 636034977a2fSmrg else 636134977a2fSmrg compile_deplibs="$deplib $compile_deplibs" 636234977a2fSmrg finalize_deplibs="$deplib $finalize_deplibs" 636334977a2fSmrg fi 636434977a2fSmrg continue 636534977a2fSmrg ;; 636634977a2fSmrg esac # linkmode 636734977a2fSmrg ;; # *.$libext 636834977a2fSmrg *.lo | *.$objext) 636934977a2fSmrg if test "$pass" = conv; then 637034977a2fSmrg deplibs="$deplib $deplibs" 637134977a2fSmrg elif test "$linkmode" = prog; then 637234977a2fSmrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 637334977a2fSmrg # If there is no dlopen support or we're linking statically, 637434977a2fSmrg # we need to preload. 63753e72ca8cSmrg func_append newdlprefiles " $deplib" 637634977a2fSmrg compile_deplibs="$deplib $compile_deplibs" 637734977a2fSmrg finalize_deplibs="$deplib $finalize_deplibs" 637834977a2fSmrg else 63793e72ca8cSmrg func_append newdlfiles " $deplib" 638034977a2fSmrg fi 638134977a2fSmrg fi 638234977a2fSmrg continue 638334977a2fSmrg ;; 638434977a2fSmrg %DEPLIBS%) 638534977a2fSmrg alldeplibs=yes 638634977a2fSmrg continue 638734977a2fSmrg ;; 638834977a2fSmrg esac # case $deplib 638934977a2fSmrg 639034977a2fSmrg if test "$found" = yes || test -f "$lib"; then : 639134977a2fSmrg else 639234977a2fSmrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 639334977a2fSmrg fi 639434977a2fSmrg 639534977a2fSmrg # Check to see that this really is a libtool archive. 639634977a2fSmrg func_lalib_unsafe_p "$lib" \ 639734977a2fSmrg || func_fatal_error "\`$lib' is not a valid libtool archive" 639834977a2fSmrg 639934977a2fSmrg func_dirname "$lib" "" "." 640034977a2fSmrg ladir="$func_dirname_result" 640134977a2fSmrg 640234977a2fSmrg dlname= 640334977a2fSmrg dlopen= 640434977a2fSmrg dlpreopen= 640534977a2fSmrg libdir= 640634977a2fSmrg library_names= 640734977a2fSmrg old_library= 640834977a2fSmrg inherited_linker_flags= 640934977a2fSmrg # If the library was installed with an old release of libtool, 641034977a2fSmrg # it will not redefine variables installed, or shouldnotlink 641134977a2fSmrg installed=yes 641234977a2fSmrg shouldnotlink=no 641334977a2fSmrg avoidtemprpath= 641434977a2fSmrg 641534977a2fSmrg 641634977a2fSmrg # Read the .la file 641734977a2fSmrg func_source "$lib" 641834977a2fSmrg 641934977a2fSmrg # Convert "-framework foo" to "foo.ltframework" 642034977a2fSmrg if test -n "$inherited_linker_flags"; then 6421b425557eSmrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 642234977a2fSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 642334977a2fSmrg case " $new_inherited_linker_flags " in 642434977a2fSmrg *" $tmp_inherited_linker_flag "*) ;; 64253e72ca8cSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 642634977a2fSmrg esac 642734977a2fSmrg done 642834977a2fSmrg fi 6429b425557eSmrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 643034977a2fSmrg if test "$linkmode,$pass" = "lib,link" || 643134977a2fSmrg test "$linkmode,$pass" = "prog,scan" || 643234977a2fSmrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 64333e72ca8cSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 64343e72ca8cSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 643534977a2fSmrg fi 643634977a2fSmrg 643734977a2fSmrg if test "$pass" = conv; then 643834977a2fSmrg # Only check for convenience libraries 643934977a2fSmrg deplibs="$lib $deplibs" 644034977a2fSmrg if test -z "$libdir"; then 644134977a2fSmrg if test -z "$old_library"; then 644234977a2fSmrg func_fatal_error "cannot find name of link library for \`$lib'" 644334977a2fSmrg fi 644434977a2fSmrg # It is a libtool convenience library, so add in its objects. 64453e72ca8cSmrg func_append convenience " $ladir/$objdir/$old_library" 64463e72ca8cSmrg func_append old_convenience " $ladir/$objdir/$old_library" 644734977a2fSmrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 644834977a2fSmrg func_fatal_error "\`$lib' is not a convenience library" 644934977a2fSmrg fi 645034977a2fSmrg tmp_libs= 645134977a2fSmrg for deplib in $dependency_libs; do 645234977a2fSmrg deplibs="$deplib $deplibs" 64533e72ca8cSmrg if $opt_preserve_dup_deps ; then 645434977a2fSmrg case "$tmp_libs " in 64553e72ca8cSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 645634977a2fSmrg esac 645734977a2fSmrg fi 64583e72ca8cSmrg func_append tmp_libs " $deplib" 645934977a2fSmrg done 646034977a2fSmrg continue 646134977a2fSmrg fi # $pass = conv 646234977a2fSmrg 646334977a2fSmrg 646434977a2fSmrg # Get the name of the library we link against. 646534977a2fSmrg linklib= 64663e72ca8cSmrg if test -n "$old_library" && 64673e72ca8cSmrg { test "$prefer_static_libs" = yes || 64683e72ca8cSmrg test "$prefer_static_libs,$installed" = "built,no"; }; then 64693e72ca8cSmrg linklib=$old_library 64703e72ca8cSmrg else 64713e72ca8cSmrg for l in $old_library $library_names; do 64723e72ca8cSmrg linklib="$l" 64733e72ca8cSmrg done 64743e72ca8cSmrg fi 647534977a2fSmrg if test -z "$linklib"; then 647634977a2fSmrg func_fatal_error "cannot find name of link library for \`$lib'" 647734977a2fSmrg fi 647834977a2fSmrg 647934977a2fSmrg # This library was specified with -dlopen. 648034977a2fSmrg if test "$pass" = dlopen; then 648134977a2fSmrg if test -z "$libdir"; then 648234977a2fSmrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 648334977a2fSmrg fi 648434977a2fSmrg if test -z "$dlname" || 648534977a2fSmrg test "$dlopen_support" != yes || 648634977a2fSmrg test "$build_libtool_libs" = no; then 648734977a2fSmrg # If there is no dlname, no dlopen support or we're linking 648834977a2fSmrg # statically, we need to preload. We also need to preload any 648934977a2fSmrg # dependent libraries so libltdl's deplib preloader doesn't 649034977a2fSmrg # bomb out in the load deplibs phase. 64913e72ca8cSmrg func_append dlprefiles " $lib $dependency_libs" 649234977a2fSmrg else 64933e72ca8cSmrg func_append newdlfiles " $lib" 649434977a2fSmrg fi 649534977a2fSmrg continue 649634977a2fSmrg fi # $pass = dlopen 649734977a2fSmrg 649834977a2fSmrg # We need an absolute path. 649934977a2fSmrg case $ladir in 650034977a2fSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 650134977a2fSmrg *) 650234977a2fSmrg abs_ladir=`cd "$ladir" && pwd` 650334977a2fSmrg if test -z "$abs_ladir"; then 650434977a2fSmrg func_warning "cannot determine absolute directory name of \`$ladir'" 650534977a2fSmrg func_warning "passing it literally to the linker, although it might fail" 650634977a2fSmrg abs_ladir="$ladir" 650734977a2fSmrg fi 650834977a2fSmrg ;; 650934977a2fSmrg esac 651034977a2fSmrg func_basename "$lib" 651134977a2fSmrg laname="$func_basename_result" 651234977a2fSmrg 651334977a2fSmrg # Find the relevant object directory and library name. 651434977a2fSmrg if test "X$installed" = Xyes; then 65153e72ca8cSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 651634977a2fSmrg func_warning "library \`$lib' was moved." 651734977a2fSmrg dir="$ladir" 651834977a2fSmrg absdir="$abs_ladir" 651934977a2fSmrg libdir="$abs_ladir" 652034977a2fSmrg else 65213e72ca8cSmrg dir="$lt_sysroot$libdir" 65223e72ca8cSmrg absdir="$lt_sysroot$libdir" 652334977a2fSmrg fi 652434977a2fSmrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 652534977a2fSmrg else 652634977a2fSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 652734977a2fSmrg dir="$ladir" 652834977a2fSmrg absdir="$abs_ladir" 652934977a2fSmrg # Remove this search path later 65303e72ca8cSmrg func_append notinst_path " $abs_ladir" 653134977a2fSmrg else 653234977a2fSmrg dir="$ladir/$objdir" 653334977a2fSmrg absdir="$abs_ladir/$objdir" 653434977a2fSmrg # Remove this search path later 65353e72ca8cSmrg func_append notinst_path " $abs_ladir" 653634977a2fSmrg fi 653734977a2fSmrg fi # $installed = yes 653834977a2fSmrg func_stripname 'lib' '.la' "$laname" 653934977a2fSmrg name=$func_stripname_result 654034977a2fSmrg 654134977a2fSmrg # This library was specified with -dlpreopen. 654234977a2fSmrg if test "$pass" = dlpreopen; then 654334977a2fSmrg if test -z "$libdir" && test "$linkmode" = prog; then 654434977a2fSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 654534977a2fSmrg fi 65463e72ca8cSmrg case "$host" in 65473e72ca8cSmrg # special handling for platforms with PE-DLLs. 65483e72ca8cSmrg *cygwin* | *mingw* | *cegcc* ) 65493e72ca8cSmrg # Linker will automatically link against shared library if both 65503e72ca8cSmrg # static and shared are present. Therefore, ensure we extract 65513e72ca8cSmrg # symbols from the import library if a shared library is present 65523e72ca8cSmrg # (otherwise, the dlopen module name will be incorrect). We do 65533e72ca8cSmrg # this by putting the import library name into $newdlprefiles. 65543e72ca8cSmrg # We recover the dlopen module name by 'saving' the la file 65553e72ca8cSmrg # name in a special purpose variable, and (later) extracting the 65563e72ca8cSmrg # dlname from the la file. 65573e72ca8cSmrg if test -n "$dlname"; then 65583e72ca8cSmrg func_tr_sh "$dir/$linklib" 65593e72ca8cSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 65603e72ca8cSmrg func_append newdlprefiles " $dir/$linklib" 65613e72ca8cSmrg else 65623e72ca8cSmrg func_append newdlprefiles " $dir/$old_library" 65633e72ca8cSmrg # Keep a list of preopened convenience libraries to check 65643e72ca8cSmrg # that they are being used correctly in the link pass. 65653e72ca8cSmrg test -z "$libdir" && \ 65663e72ca8cSmrg func_append dlpreconveniencelibs " $dir/$old_library" 65673e72ca8cSmrg fi 65683e72ca8cSmrg ;; 65693e72ca8cSmrg * ) 65703e72ca8cSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 65713e72ca8cSmrg # are required to link). 65723e72ca8cSmrg if test -n "$old_library"; then 65733e72ca8cSmrg func_append newdlprefiles " $dir/$old_library" 65743e72ca8cSmrg # Keep a list of preopened convenience libraries to check 65753e72ca8cSmrg # that they are being used correctly in the link pass. 65763e72ca8cSmrg test -z "$libdir" && \ 65773e72ca8cSmrg func_append dlpreconveniencelibs " $dir/$old_library" 65783e72ca8cSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 65793e72ca8cSmrg elif test -n "$dlname"; then 65803e72ca8cSmrg func_append newdlprefiles " $dir/$dlname" 65813e72ca8cSmrg else 65823e72ca8cSmrg func_append newdlprefiles " $dir/$linklib" 65833e72ca8cSmrg fi 65843e72ca8cSmrg ;; 65853e72ca8cSmrg esac 658634977a2fSmrg fi # $pass = dlpreopen 658734977a2fSmrg 658834977a2fSmrg if test -z "$libdir"; then 658934977a2fSmrg # Link the convenience library 659034977a2fSmrg if test "$linkmode" = lib; then 659134977a2fSmrg deplibs="$dir/$old_library $deplibs" 659234977a2fSmrg elif test "$linkmode,$pass" = "prog,link"; then 659334977a2fSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 659434977a2fSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 659534977a2fSmrg else 659634977a2fSmrg deplibs="$lib $deplibs" # used for prog,scan pass 659734977a2fSmrg fi 659834977a2fSmrg continue 659934977a2fSmrg fi 660034977a2fSmrg 660134977a2fSmrg 660234977a2fSmrg if test "$linkmode" = prog && test "$pass" != link; then 66033e72ca8cSmrg func_append newlib_search_path " $ladir" 660434977a2fSmrg deplibs="$lib $deplibs" 660534977a2fSmrg 660634977a2fSmrg linkalldeplibs=no 660734977a2fSmrg if test "$link_all_deplibs" != no || test -z "$library_names" || 660834977a2fSmrg test "$build_libtool_libs" = no; then 660934977a2fSmrg linkalldeplibs=yes 661034977a2fSmrg fi 661134977a2fSmrg 661234977a2fSmrg tmp_libs= 661334977a2fSmrg for deplib in $dependency_libs; do 661434977a2fSmrg case $deplib in 661534977a2fSmrg -L*) func_stripname '-L' '' "$deplib" 66163e72ca8cSmrg func_resolve_sysroot "$func_stripname_result" 66173e72ca8cSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 661834977a2fSmrg ;; 661934977a2fSmrg esac 662034977a2fSmrg # Need to link against all dependency_libs? 662134977a2fSmrg if test "$linkalldeplibs" = yes; then 662234977a2fSmrg deplibs="$deplib $deplibs" 662334977a2fSmrg else 662434977a2fSmrg # Need to hardcode shared library paths 662534977a2fSmrg # or/and link against static libraries 662634977a2fSmrg newdependency_libs="$deplib $newdependency_libs" 662734977a2fSmrg fi 66283e72ca8cSmrg if $opt_preserve_dup_deps ; then 662934977a2fSmrg case "$tmp_libs " in 66303e72ca8cSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 663134977a2fSmrg esac 663234977a2fSmrg fi 66333e72ca8cSmrg func_append tmp_libs " $deplib" 663434977a2fSmrg done # for deplib 663534977a2fSmrg continue 663634977a2fSmrg fi # $linkmode = prog... 663734977a2fSmrg 663834977a2fSmrg if test "$linkmode,$pass" = "prog,link"; then 663934977a2fSmrg if test -n "$library_names" && 664034977a2fSmrg { { test "$prefer_static_libs" = no || 664134977a2fSmrg test "$prefer_static_libs,$installed" = "built,yes"; } || 664234977a2fSmrg test -z "$old_library"; }; then 664334977a2fSmrg # We need to hardcode the library path 664434977a2fSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 664534977a2fSmrg # Make sure the rpath contains only unique directories. 664634977a2fSmrg case "$temp_rpath:" in 664734977a2fSmrg *"$absdir:"*) ;; 66483e72ca8cSmrg *) func_append temp_rpath "$absdir:" ;; 664934977a2fSmrg esac 665034977a2fSmrg fi 665134977a2fSmrg 665234977a2fSmrg # Hardcode the library path. 665334977a2fSmrg # Skip directories that are in the system default run-time 665434977a2fSmrg # search path. 665534977a2fSmrg case " $sys_lib_dlsearch_path " in 665634977a2fSmrg *" $absdir "*) ;; 665734977a2fSmrg *) 665834977a2fSmrg case "$compile_rpath " in 665934977a2fSmrg *" $absdir "*) ;; 66603e72ca8cSmrg *) func_append compile_rpath " $absdir" ;; 666134977a2fSmrg esac 666234977a2fSmrg ;; 666334977a2fSmrg esac 666434977a2fSmrg case " $sys_lib_dlsearch_path " in 666534977a2fSmrg *" $libdir "*) ;; 666634977a2fSmrg *) 666734977a2fSmrg case "$finalize_rpath " in 666834977a2fSmrg *" $libdir "*) ;; 66693e72ca8cSmrg *) func_append finalize_rpath " $libdir" ;; 667034977a2fSmrg esac 667134977a2fSmrg ;; 667234977a2fSmrg esac 667334977a2fSmrg fi # $linkmode,$pass = prog,link... 667434977a2fSmrg 667534977a2fSmrg if test "$alldeplibs" = yes && 667634977a2fSmrg { test "$deplibs_check_method" = pass_all || 667734977a2fSmrg { test "$build_libtool_libs" = yes && 667834977a2fSmrg test -n "$library_names"; }; }; then 667934977a2fSmrg # We only need to search for static libraries 668034977a2fSmrg continue 668134977a2fSmrg fi 668234977a2fSmrg fi 668334977a2fSmrg 668434977a2fSmrg link_static=no # Whether the deplib will be linked statically 668534977a2fSmrg use_static_libs=$prefer_static_libs 668634977a2fSmrg if test "$use_static_libs" = built && test "$installed" = yes; then 668734977a2fSmrg use_static_libs=no 668834977a2fSmrg fi 668934977a2fSmrg if test -n "$library_names" && 669034977a2fSmrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 669134977a2fSmrg case $host in 669234977a2fSmrg *cygwin* | *mingw* | *cegcc*) 669334977a2fSmrg # No point in relinking DLLs because paths are not encoded 66943e72ca8cSmrg func_append notinst_deplibs " $lib" 669534977a2fSmrg need_relink=no 669634977a2fSmrg ;; 669734977a2fSmrg *) 669834977a2fSmrg if test "$installed" = no; then 66993e72ca8cSmrg func_append notinst_deplibs " $lib" 670034977a2fSmrg need_relink=yes 670134977a2fSmrg fi 670234977a2fSmrg ;; 670334977a2fSmrg esac 670434977a2fSmrg # This is a shared library 670534977a2fSmrg 670634977a2fSmrg # Warn about portability, can't link against -module's on some 670734977a2fSmrg # systems (darwin). Don't bleat about dlopened modules though! 670834977a2fSmrg dlopenmodule="" 670934977a2fSmrg for dlpremoduletest in $dlprefiles; do 671034977a2fSmrg if test "X$dlpremoduletest" = "X$lib"; then 671134977a2fSmrg dlopenmodule="$dlpremoduletest" 671234977a2fSmrg break 671334977a2fSmrg fi 671434977a2fSmrg done 671534977a2fSmrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 6716b425557eSmrg echo 671734977a2fSmrg if test "$linkmode" = prog; then 671834977a2fSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 671934977a2fSmrg else 672034977a2fSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 672134977a2fSmrg fi 672234977a2fSmrg $ECHO "*** $linklib is not portable!" 672334977a2fSmrg fi 672434977a2fSmrg if test "$linkmode" = lib && 672534977a2fSmrg test "$hardcode_into_libs" = yes; then 672634977a2fSmrg # Hardcode the library path. 672734977a2fSmrg # Skip directories that are in the system default run-time 672834977a2fSmrg # search path. 672934977a2fSmrg case " $sys_lib_dlsearch_path " in 673034977a2fSmrg *" $absdir "*) ;; 673134977a2fSmrg *) 673234977a2fSmrg case "$compile_rpath " in 673334977a2fSmrg *" $absdir "*) ;; 67343e72ca8cSmrg *) func_append compile_rpath " $absdir" ;; 673534977a2fSmrg esac 673634977a2fSmrg ;; 673734977a2fSmrg esac 673834977a2fSmrg case " $sys_lib_dlsearch_path " in 673934977a2fSmrg *" $libdir "*) ;; 674034977a2fSmrg *) 674134977a2fSmrg case "$finalize_rpath " in 674234977a2fSmrg *" $libdir "*) ;; 67433e72ca8cSmrg *) func_append finalize_rpath " $libdir" ;; 674434977a2fSmrg esac 674534977a2fSmrg ;; 674634977a2fSmrg esac 674734977a2fSmrg fi 674834977a2fSmrg 674934977a2fSmrg if test -n "$old_archive_from_expsyms_cmds"; then 675034977a2fSmrg # figure out the soname 675134977a2fSmrg set dummy $library_names 675234977a2fSmrg shift 675334977a2fSmrg realname="$1" 675434977a2fSmrg shift 675534977a2fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 675634977a2fSmrg # use dlname if we got it. it's perfectly good, no? 675734977a2fSmrg if test -n "$dlname"; then 675834977a2fSmrg soname="$dlname" 675934977a2fSmrg elif test -n "$soname_spec"; then 676034977a2fSmrg # bleh windows 676134977a2fSmrg case $host in 676234977a2fSmrg *cygwin* | mingw* | *cegcc*) 676334977a2fSmrg func_arith $current - $age 676434977a2fSmrg major=$func_arith_result 676534977a2fSmrg versuffix="-$major" 676634977a2fSmrg ;; 676734977a2fSmrg esac 676834977a2fSmrg eval soname=\"$soname_spec\" 676934977a2fSmrg else 677034977a2fSmrg soname="$realname" 677134977a2fSmrg fi 677234977a2fSmrg 677334977a2fSmrg # Make a new name for the extract_expsyms_cmds to use 677434977a2fSmrg soroot="$soname" 677534977a2fSmrg func_basename "$soroot" 677634977a2fSmrg soname="$func_basename_result" 677734977a2fSmrg func_stripname 'lib' '.dll' "$soname" 677834977a2fSmrg newlib=libimp-$func_stripname_result.a 677934977a2fSmrg 678034977a2fSmrg # If the library has no export list, then create one now 678134977a2fSmrg if test -f "$output_objdir/$soname-def"; then : 678234977a2fSmrg else 678334977a2fSmrg func_verbose "extracting exported symbol list from \`$soname'" 678434977a2fSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 678534977a2fSmrg fi 678634977a2fSmrg 678734977a2fSmrg # Create $newlib 678834977a2fSmrg if test -f "$output_objdir/$newlib"; then :; else 678934977a2fSmrg func_verbose "generating import library for \`$soname'" 679034977a2fSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 679134977a2fSmrg fi 679234977a2fSmrg # make sure the library variables are pointing to the new library 679334977a2fSmrg dir=$output_objdir 679434977a2fSmrg linklib=$newlib 679534977a2fSmrg fi # test -n "$old_archive_from_expsyms_cmds" 679634977a2fSmrg 67973e72ca8cSmrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 679834977a2fSmrg add_shlibpath= 679934977a2fSmrg add_dir= 680034977a2fSmrg add= 680134977a2fSmrg lib_linked=yes 680234977a2fSmrg case $hardcode_action in 680334977a2fSmrg immediate | unsupported) 680434977a2fSmrg if test "$hardcode_direct" = no; then 680534977a2fSmrg add="$dir/$linklib" 680634977a2fSmrg case $host in 680734977a2fSmrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 680834977a2fSmrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 680934977a2fSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 681034977a2fSmrg *-*-unixware7*) add_dir="-L$dir" ;; 681134977a2fSmrg *-*-darwin* ) 681234977a2fSmrg # if the lib is a (non-dlopened) module then we can not 681334977a2fSmrg # link against it, someone is ignoring the earlier warnings 681434977a2fSmrg if /usr/bin/file -L $add 2> /dev/null | 681534977a2fSmrg $GREP ": [^:]* bundle" >/dev/null ; then 681634977a2fSmrg if test "X$dlopenmodule" != "X$lib"; then 681734977a2fSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 681834977a2fSmrg if test -z "$old_library" ; then 6819b425557eSmrg echo 6820b425557eSmrg echo "*** And there doesn't seem to be a static archive available" 6821b425557eSmrg echo "*** The link will probably fail, sorry" 682234977a2fSmrg else 682334977a2fSmrg add="$dir/$old_library" 682434977a2fSmrg fi 682534977a2fSmrg elif test -n "$old_library"; then 682634977a2fSmrg add="$dir/$old_library" 682734977a2fSmrg fi 682834977a2fSmrg fi 682934977a2fSmrg esac 683034977a2fSmrg elif test "$hardcode_minus_L" = no; then 683134977a2fSmrg case $host in 683234977a2fSmrg *-*-sunos*) add_shlibpath="$dir" ;; 683334977a2fSmrg esac 683434977a2fSmrg add_dir="-L$dir" 683534977a2fSmrg add="-l$name" 683634977a2fSmrg elif test "$hardcode_shlibpath_var" = no; then 683734977a2fSmrg add_shlibpath="$dir" 683834977a2fSmrg add="-l$name" 683934977a2fSmrg else 684034977a2fSmrg lib_linked=no 684134977a2fSmrg fi 684234977a2fSmrg ;; 684334977a2fSmrg relink) 684434977a2fSmrg if test "$hardcode_direct" = yes && 684534977a2fSmrg test "$hardcode_direct_absolute" = no; then 684634977a2fSmrg add="$dir/$linklib" 684734977a2fSmrg elif test "$hardcode_minus_L" = yes; then 68483e72ca8cSmrg add_dir="-L$absdir" 684934977a2fSmrg # Try looking first in the location we're being installed to. 685034977a2fSmrg if test -n "$inst_prefix_dir"; then 685134977a2fSmrg case $libdir in 685234977a2fSmrg [\\/]*) 68533e72ca8cSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 685434977a2fSmrg ;; 685534977a2fSmrg esac 685634977a2fSmrg fi 685734977a2fSmrg add="-l$name" 685834977a2fSmrg elif test "$hardcode_shlibpath_var" = yes; then 685934977a2fSmrg add_shlibpath="$dir" 686034977a2fSmrg add="-l$name" 686134977a2fSmrg else 686234977a2fSmrg lib_linked=no 686334977a2fSmrg fi 686434977a2fSmrg ;; 686534977a2fSmrg *) lib_linked=no ;; 686634977a2fSmrg esac 686734977a2fSmrg 686834977a2fSmrg if test "$lib_linked" != yes; then 686934977a2fSmrg func_fatal_configuration "unsupported hardcode properties" 687034977a2fSmrg fi 687134977a2fSmrg 687234977a2fSmrg if test -n "$add_shlibpath"; then 687334977a2fSmrg case :$compile_shlibpath: in 687434977a2fSmrg *":$add_shlibpath:"*) ;; 68753e72ca8cSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 687634977a2fSmrg esac 687734977a2fSmrg fi 687834977a2fSmrg if test "$linkmode" = prog; then 687934977a2fSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 688034977a2fSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 688134977a2fSmrg else 688234977a2fSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 688334977a2fSmrg test -n "$add" && deplibs="$add $deplibs" 688434977a2fSmrg if test "$hardcode_direct" != yes && 688534977a2fSmrg test "$hardcode_minus_L" != yes && 688634977a2fSmrg test "$hardcode_shlibpath_var" = yes; then 688734977a2fSmrg case :$finalize_shlibpath: in 688834977a2fSmrg *":$libdir:"*) ;; 68893e72ca8cSmrg *) func_append finalize_shlibpath "$libdir:" ;; 689034977a2fSmrg esac 689134977a2fSmrg fi 689234977a2fSmrg fi 689334977a2fSmrg fi 689434977a2fSmrg 68953e72ca8cSmrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 689634977a2fSmrg add_shlibpath= 689734977a2fSmrg add_dir= 689834977a2fSmrg add= 689934977a2fSmrg # Finalize command for both is simple: just hardcode it. 690034977a2fSmrg if test "$hardcode_direct" = yes && 690134977a2fSmrg test "$hardcode_direct_absolute" = no; then 690234977a2fSmrg add="$libdir/$linklib" 690334977a2fSmrg elif test "$hardcode_minus_L" = yes; then 690434977a2fSmrg add_dir="-L$libdir" 690534977a2fSmrg add="-l$name" 690634977a2fSmrg elif test "$hardcode_shlibpath_var" = yes; then 690734977a2fSmrg case :$finalize_shlibpath: in 690834977a2fSmrg *":$libdir:"*) ;; 69093e72ca8cSmrg *) func_append finalize_shlibpath "$libdir:" ;; 691034977a2fSmrg esac 691134977a2fSmrg add="-l$name" 691234977a2fSmrg elif test "$hardcode_automatic" = yes; then 691334977a2fSmrg if test -n "$inst_prefix_dir" && 691434977a2fSmrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 691534977a2fSmrg add="$inst_prefix_dir$libdir/$linklib" 691634977a2fSmrg else 691734977a2fSmrg add="$libdir/$linklib" 691834977a2fSmrg fi 691934977a2fSmrg else 692034977a2fSmrg # We cannot seem to hardcode it, guess we'll fake it. 692134977a2fSmrg add_dir="-L$libdir" 692234977a2fSmrg # Try looking first in the location we're being installed to. 692334977a2fSmrg if test -n "$inst_prefix_dir"; then 692434977a2fSmrg case $libdir in 692534977a2fSmrg [\\/]*) 69263e72ca8cSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 692734977a2fSmrg ;; 692834977a2fSmrg esac 692934977a2fSmrg fi 693034977a2fSmrg add="-l$name" 693134977a2fSmrg fi 693234977a2fSmrg 693334977a2fSmrg if test "$linkmode" = prog; then 693434977a2fSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 693534977a2fSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 693634977a2fSmrg else 693734977a2fSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 693834977a2fSmrg test -n "$add" && deplibs="$add $deplibs" 693934977a2fSmrg fi 694034977a2fSmrg fi 694134977a2fSmrg elif test "$linkmode" = prog; then 694234977a2fSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 694334977a2fSmrg # is not unsupported. This is valid on all known static and 694434977a2fSmrg # shared platforms. 694534977a2fSmrg if test "$hardcode_direct" != unsupported; then 694634977a2fSmrg test -n "$old_library" && linklib="$old_library" 694734977a2fSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 694834977a2fSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 694934977a2fSmrg else 695034977a2fSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 695134977a2fSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 695234977a2fSmrg fi 695334977a2fSmrg elif test "$build_libtool_libs" = yes; then 695434977a2fSmrg # Not a shared library 695534977a2fSmrg if test "$deplibs_check_method" != pass_all; then 695634977a2fSmrg # We're trying link a shared library against a static one 695734977a2fSmrg # but the system doesn't support it. 695834977a2fSmrg 695934977a2fSmrg # Just print a warning and add the library to dependency_libs so 696034977a2fSmrg # that the program can be linked against the static library. 6961b425557eSmrg echo 696234977a2fSmrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 6963b425557eSmrg echo "*** I have the capability to make that library automatically link in when" 6964b425557eSmrg echo "*** you link to this library. But I can only do this if you have a" 6965b425557eSmrg echo "*** shared version of the library, which you do not appear to have." 696634977a2fSmrg if test "$module" = yes; then 6967b425557eSmrg echo "*** But as you try to build a module library, libtool will still create " 6968b425557eSmrg echo "*** a static module, that should work as long as the dlopening application" 6969b425557eSmrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 697034977a2fSmrg if test -z "$global_symbol_pipe"; then 6971b425557eSmrg echo 6972b425557eSmrg echo "*** However, this would only work if libtool was able to extract symbol" 6973b425557eSmrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 6974b425557eSmrg echo "*** not find such a program. So, this module is probably useless." 6975b425557eSmrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 697634977a2fSmrg fi 697734977a2fSmrg if test "$build_old_libs" = no; then 697834977a2fSmrg build_libtool_libs=module 697934977a2fSmrg build_old_libs=yes 698034977a2fSmrg else 698134977a2fSmrg build_libtool_libs=no 698234977a2fSmrg fi 698334977a2fSmrg fi 698434977a2fSmrg else 698534977a2fSmrg deplibs="$dir/$old_library $deplibs" 698634977a2fSmrg link_static=yes 698734977a2fSmrg fi 698834977a2fSmrg fi # link shared/static library? 698934977a2fSmrg 699034977a2fSmrg if test "$linkmode" = lib; then 699134977a2fSmrg if test -n "$dependency_libs" && 699234977a2fSmrg { test "$hardcode_into_libs" != yes || 699334977a2fSmrg test "$build_old_libs" = yes || 699434977a2fSmrg test "$link_static" = yes; }; then 699534977a2fSmrg # Extract -R from dependency_libs 699634977a2fSmrg temp_deplibs= 699734977a2fSmrg for libdir in $dependency_libs; do 699834977a2fSmrg case $libdir in 699934977a2fSmrg -R*) func_stripname '-R' '' "$libdir" 700034977a2fSmrg temp_xrpath=$func_stripname_result 700134977a2fSmrg case " $xrpath " in 700234977a2fSmrg *" $temp_xrpath "*) ;; 70033e72ca8cSmrg *) func_append xrpath " $temp_xrpath";; 700434977a2fSmrg esac;; 70053e72ca8cSmrg *) func_append temp_deplibs " $libdir";; 700634977a2fSmrg esac 700734977a2fSmrg done 700834977a2fSmrg dependency_libs="$temp_deplibs" 700934977a2fSmrg fi 701034977a2fSmrg 70113e72ca8cSmrg func_append newlib_search_path " $absdir" 701234977a2fSmrg # Link against this library 701334977a2fSmrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 701434977a2fSmrg # ... and its dependency_libs 701534977a2fSmrg tmp_libs= 701634977a2fSmrg for deplib in $dependency_libs; do 701734977a2fSmrg newdependency_libs="$deplib $newdependency_libs" 70183e72ca8cSmrg case $deplib in 70193e72ca8cSmrg -L*) func_stripname '-L' '' "$deplib" 70203e72ca8cSmrg func_resolve_sysroot "$func_stripname_result";; 70213e72ca8cSmrg *) func_resolve_sysroot "$deplib" ;; 70223e72ca8cSmrg esac 70233e72ca8cSmrg if $opt_preserve_dup_deps ; then 702434977a2fSmrg case "$tmp_libs " in 70253e72ca8cSmrg *" $func_resolve_sysroot_result "*) 70263e72ca8cSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 702734977a2fSmrg esac 702834977a2fSmrg fi 70293e72ca8cSmrg func_append tmp_libs " $func_resolve_sysroot_result" 703034977a2fSmrg done 703134977a2fSmrg 703234977a2fSmrg if test "$link_all_deplibs" != no; then 703334977a2fSmrg # Add the search paths of all dependency libraries 703434977a2fSmrg for deplib in $dependency_libs; do 7035b425557eSmrg path= 703634977a2fSmrg case $deplib in 703734977a2fSmrg -L*) path="$deplib" ;; 703834977a2fSmrg *.la) 70393e72ca8cSmrg func_resolve_sysroot "$deplib" 70403e72ca8cSmrg deplib=$func_resolve_sysroot_result 704134977a2fSmrg func_dirname "$deplib" "" "." 70423e72ca8cSmrg dir=$func_dirname_result 704334977a2fSmrg # We need an absolute path. 704434977a2fSmrg case $dir in 704534977a2fSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 704634977a2fSmrg *) 704734977a2fSmrg absdir=`cd "$dir" && pwd` 704834977a2fSmrg if test -z "$absdir"; then 704934977a2fSmrg func_warning "cannot determine absolute directory name of \`$dir'" 705034977a2fSmrg absdir="$dir" 705134977a2fSmrg fi 705234977a2fSmrg ;; 705334977a2fSmrg esac 705434977a2fSmrg if $GREP "^installed=no" $deplib > /dev/null; then 705534977a2fSmrg case $host in 705634977a2fSmrg *-*-darwin*) 705734977a2fSmrg depdepl= 705834977a2fSmrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 705934977a2fSmrg if test -n "$deplibrary_names" ; then 706034977a2fSmrg for tmp in $deplibrary_names ; do 706134977a2fSmrg depdepl=$tmp 706234977a2fSmrg done 706334977a2fSmrg if test -f "$absdir/$objdir/$depdepl" ; then 706434977a2fSmrg depdepl="$absdir/$objdir/$depdepl" 706534977a2fSmrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 706634977a2fSmrg if test -z "$darwin_install_name"; then 706734977a2fSmrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 706834977a2fSmrg fi 70693e72ca8cSmrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 70703e72ca8cSmrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 707134977a2fSmrg path= 707234977a2fSmrg fi 707334977a2fSmrg fi 707434977a2fSmrg ;; 707534977a2fSmrg *) 707634977a2fSmrg path="-L$absdir/$objdir" 707734977a2fSmrg ;; 707834977a2fSmrg esac 707934977a2fSmrg else 708034977a2fSmrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 708134977a2fSmrg test -z "$libdir" && \ 708234977a2fSmrg func_fatal_error "\`$deplib' is not a valid libtool archive" 708334977a2fSmrg test "$absdir" != "$libdir" && \ 708434977a2fSmrg func_warning "\`$deplib' seems to be moved" 708534977a2fSmrg 708634977a2fSmrg path="-L$absdir" 708734977a2fSmrg fi 708834977a2fSmrg ;; 708934977a2fSmrg esac 709034977a2fSmrg case " $deplibs " in 709134977a2fSmrg *" $path "*) ;; 709234977a2fSmrg *) deplibs="$path $deplibs" ;; 709334977a2fSmrg esac 709434977a2fSmrg done 709534977a2fSmrg fi # link_all_deplibs != no 709634977a2fSmrg fi # linkmode = lib 709734977a2fSmrg done # for deplib in $libs 709834977a2fSmrg if test "$pass" = link; then 709934977a2fSmrg if test "$linkmode" = "prog"; then 710034977a2fSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 710134977a2fSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 710234977a2fSmrg else 7103b425557eSmrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 710434977a2fSmrg fi 710534977a2fSmrg fi 710634977a2fSmrg dependency_libs="$newdependency_libs" 710734977a2fSmrg if test "$pass" = dlpreopen; then 710834977a2fSmrg # Link the dlpreopened libraries before other libraries 710934977a2fSmrg for deplib in $save_deplibs; do 711034977a2fSmrg deplibs="$deplib $deplibs" 711134977a2fSmrg done 711234977a2fSmrg fi 711334977a2fSmrg if test "$pass" != dlopen; then 711434977a2fSmrg if test "$pass" != conv; then 711534977a2fSmrg # Make sure lib_search_path contains only unique directories. 711634977a2fSmrg lib_search_path= 711734977a2fSmrg for dir in $newlib_search_path; do 711834977a2fSmrg case "$lib_search_path " in 711934977a2fSmrg *" $dir "*) ;; 71203e72ca8cSmrg *) func_append lib_search_path " $dir" ;; 712134977a2fSmrg esac 712234977a2fSmrg done 712334977a2fSmrg newlib_search_path= 712434977a2fSmrg fi 712534977a2fSmrg 712634977a2fSmrg if test "$linkmode,$pass" != "prog,link"; then 712734977a2fSmrg vars="deplibs" 712834977a2fSmrg else 712934977a2fSmrg vars="compile_deplibs finalize_deplibs" 713034977a2fSmrg fi 713134977a2fSmrg for var in $vars dependency_libs; do 713234977a2fSmrg # Add libraries to $var in reverse order 713334977a2fSmrg eval tmp_libs=\"\$$var\" 713434977a2fSmrg new_libs= 713534977a2fSmrg for deplib in $tmp_libs; do 713634977a2fSmrg # FIXME: Pedantically, this is the right thing to do, so 713734977a2fSmrg # that some nasty dependency loop isn't accidentally 713834977a2fSmrg # broken: 713934977a2fSmrg #new_libs="$deplib $new_libs" 714034977a2fSmrg # Pragmatically, this seems to cause very few problems in 714134977a2fSmrg # practice: 714234977a2fSmrg case $deplib in 714334977a2fSmrg -L*) new_libs="$deplib $new_libs" ;; 714434977a2fSmrg -R*) ;; 714534977a2fSmrg *) 714634977a2fSmrg # And here is the reason: when a library appears more 714734977a2fSmrg # than once as an explicit dependence of a library, or 714834977a2fSmrg # is implicitly linked in more than once by the 714934977a2fSmrg # compiler, it is considered special, and multiple 715034977a2fSmrg # occurrences thereof are not removed. Compare this 715134977a2fSmrg # with having the same library being listed as a 715234977a2fSmrg # dependency of multiple other libraries: in this case, 715334977a2fSmrg # we know (pedantically, we assume) the library does not 715434977a2fSmrg # need to be listed more than once, so we keep only the 715534977a2fSmrg # last copy. This is not always right, but it is rare 715634977a2fSmrg # enough that we require users that really mean to play 715734977a2fSmrg # such unportable linking tricks to link the library 715834977a2fSmrg # using -Wl,-lname, so that libtool does not consider it 715934977a2fSmrg # for duplicate removal. 716034977a2fSmrg case " $specialdeplibs " in 716134977a2fSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 716234977a2fSmrg *) 716334977a2fSmrg case " $new_libs " in 716434977a2fSmrg *" $deplib "*) ;; 716534977a2fSmrg *) new_libs="$deplib $new_libs" ;; 716634977a2fSmrg esac 716734977a2fSmrg ;; 716834977a2fSmrg esac 716934977a2fSmrg ;; 717034977a2fSmrg esac 717134977a2fSmrg done 717234977a2fSmrg tmp_libs= 717334977a2fSmrg for deplib in $new_libs; do 717434977a2fSmrg case $deplib in 717534977a2fSmrg -L*) 717634977a2fSmrg case " $tmp_libs " in 717734977a2fSmrg *" $deplib "*) ;; 71783e72ca8cSmrg *) func_append tmp_libs " $deplib" ;; 717934977a2fSmrg esac 718034977a2fSmrg ;; 71813e72ca8cSmrg *) func_append tmp_libs " $deplib" ;; 718234977a2fSmrg esac 718334977a2fSmrg done 718434977a2fSmrg eval $var=\"$tmp_libs\" 718534977a2fSmrg done # for var 718634977a2fSmrg fi 718734977a2fSmrg # Last step: remove runtime libs from dependency_libs 718834977a2fSmrg # (they stay in deplibs) 718934977a2fSmrg tmp_libs= 719034977a2fSmrg for i in $dependency_libs ; do 719134977a2fSmrg case " $predeps $postdeps $compiler_lib_search_path " in 719234977a2fSmrg *" $i "*) 719334977a2fSmrg i="" 719434977a2fSmrg ;; 719534977a2fSmrg esac 719634977a2fSmrg if test -n "$i" ; then 71973e72ca8cSmrg func_append tmp_libs " $i" 719834977a2fSmrg fi 719934977a2fSmrg done 720034977a2fSmrg dependency_libs=$tmp_libs 720134977a2fSmrg done # for pass 720234977a2fSmrg if test "$linkmode" = prog; then 720334977a2fSmrg dlfiles="$newdlfiles" 720434977a2fSmrg fi 720534977a2fSmrg if test "$linkmode" = prog || test "$linkmode" = lib; then 720634977a2fSmrg dlprefiles="$newdlprefiles" 720734977a2fSmrg fi 720834977a2fSmrg 720934977a2fSmrg case $linkmode in 721034977a2fSmrg oldlib) 721134977a2fSmrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 721234977a2fSmrg func_warning "\`-dlopen' is ignored for archives" 721334977a2fSmrg fi 721434977a2fSmrg 721534977a2fSmrg case " $deplibs" in 721634977a2fSmrg *\ -l* | *\ -L*) 721734977a2fSmrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 721834977a2fSmrg esac 721934977a2fSmrg 722034977a2fSmrg test -n "$rpath" && \ 722134977a2fSmrg func_warning "\`-rpath' is ignored for archives" 722234977a2fSmrg 722334977a2fSmrg test -n "$xrpath" && \ 722434977a2fSmrg func_warning "\`-R' is ignored for archives" 722534977a2fSmrg 722634977a2fSmrg test -n "$vinfo" && \ 722734977a2fSmrg func_warning "\`-version-info/-version-number' is ignored for archives" 722834977a2fSmrg 722934977a2fSmrg test -n "$release" && \ 723034977a2fSmrg func_warning "\`-release' is ignored for archives" 723134977a2fSmrg 723234977a2fSmrg test -n "$export_symbols$export_symbols_regex" && \ 723334977a2fSmrg func_warning "\`-export-symbols' is ignored for archives" 723434977a2fSmrg 723534977a2fSmrg # Now set the variables for building old libraries. 723634977a2fSmrg build_libtool_libs=no 723734977a2fSmrg oldlibs="$output" 72383e72ca8cSmrg func_append objs "$old_deplibs" 723934977a2fSmrg ;; 724034977a2fSmrg 724134977a2fSmrg lib) 724234977a2fSmrg # Make sure we only generate libraries of the form `libNAME.la'. 724334977a2fSmrg case $outputname in 724434977a2fSmrg lib*) 724534977a2fSmrg func_stripname 'lib' '.la' "$outputname" 724634977a2fSmrg name=$func_stripname_result 724734977a2fSmrg eval shared_ext=\"$shrext_cmds\" 724834977a2fSmrg eval libname=\"$libname_spec\" 724934977a2fSmrg ;; 725034977a2fSmrg *) 725134977a2fSmrg test "$module" = no && \ 725234977a2fSmrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 725334977a2fSmrg 725434977a2fSmrg if test "$need_lib_prefix" != no; then 725534977a2fSmrg # Add the "lib" prefix for modules if required 725634977a2fSmrg func_stripname '' '.la' "$outputname" 725734977a2fSmrg name=$func_stripname_result 725834977a2fSmrg eval shared_ext=\"$shrext_cmds\" 725934977a2fSmrg eval libname=\"$libname_spec\" 726034977a2fSmrg else 726134977a2fSmrg func_stripname '' '.la' "$outputname" 726234977a2fSmrg libname=$func_stripname_result 726334977a2fSmrg fi 726434977a2fSmrg ;; 726534977a2fSmrg esac 726634977a2fSmrg 726734977a2fSmrg if test -n "$objs"; then 726834977a2fSmrg if test "$deplibs_check_method" != pass_all; then 726934977a2fSmrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 727034977a2fSmrg else 7271b425557eSmrg echo 727234977a2fSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 727334977a2fSmrg $ECHO "*** objects $objs is not portable!" 72743e72ca8cSmrg func_append libobjs " $objs" 727534977a2fSmrg fi 727634977a2fSmrg fi 727734977a2fSmrg 727834977a2fSmrg test "$dlself" != no && \ 727934977a2fSmrg func_warning "\`-dlopen self' is ignored for libtool libraries" 728034977a2fSmrg 728134977a2fSmrg set dummy $rpath 728234977a2fSmrg shift 728334977a2fSmrg test "$#" -gt 1 && \ 728434977a2fSmrg func_warning "ignoring multiple \`-rpath's for a libtool library" 728534977a2fSmrg 728634977a2fSmrg install_libdir="$1" 728734977a2fSmrg 728834977a2fSmrg oldlibs= 728934977a2fSmrg if test -z "$rpath"; then 729034977a2fSmrg if test "$build_libtool_libs" = yes; then 729134977a2fSmrg # Building a libtool convenience library. 729234977a2fSmrg # Some compilers have problems with a `.al' extension so 729334977a2fSmrg # convenience libraries should have the same extension an 729434977a2fSmrg # archive normally would. 729534977a2fSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 729634977a2fSmrg build_libtool_libs=convenience 729734977a2fSmrg build_old_libs=yes 729834977a2fSmrg fi 729934977a2fSmrg 730034977a2fSmrg test -n "$vinfo" && \ 730134977a2fSmrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 730234977a2fSmrg 730334977a2fSmrg test -n "$release" && \ 730434977a2fSmrg func_warning "\`-release' is ignored for convenience libraries" 730534977a2fSmrg else 730634977a2fSmrg 730734977a2fSmrg # Parse the version information argument. 730834977a2fSmrg save_ifs="$IFS"; IFS=':' 730934977a2fSmrg set dummy $vinfo 0 0 0 731034977a2fSmrg shift 731134977a2fSmrg IFS="$save_ifs" 731234977a2fSmrg 731334977a2fSmrg test -n "$7" && \ 731434977a2fSmrg func_fatal_help "too many parameters to \`-version-info'" 731534977a2fSmrg 731634977a2fSmrg # convert absolute version numbers to libtool ages 731734977a2fSmrg # this retains compatibility with .la files and attempts 731834977a2fSmrg # to make the code below a bit more comprehensible 731934977a2fSmrg 732034977a2fSmrg case $vinfo_number in 732134977a2fSmrg yes) 732234977a2fSmrg number_major="$1" 732334977a2fSmrg number_minor="$2" 732434977a2fSmrg number_revision="$3" 732534977a2fSmrg # 732634977a2fSmrg # There are really only two kinds -- those that 732734977a2fSmrg # use the current revision as the major version 732834977a2fSmrg # and those that subtract age and use age as 732934977a2fSmrg # a minor version. But, then there is irix 733034977a2fSmrg # which has an extra 1 added just for fun 733134977a2fSmrg # 733234977a2fSmrg case $version_type in 73333e72ca8cSmrg # correct linux to gnu/linux during the next big refactor 733434977a2fSmrg darwin|linux|osf|windows|none) 733534977a2fSmrg func_arith $number_major + $number_minor 733634977a2fSmrg current=$func_arith_result 733734977a2fSmrg age="$number_minor" 733834977a2fSmrg revision="$number_revision" 733934977a2fSmrg ;; 7340b425557eSmrg freebsd-aout|freebsd-elf|qnx|sunos) 734134977a2fSmrg current="$number_major" 734234977a2fSmrg revision="$number_minor" 734334977a2fSmrg age="0" 734434977a2fSmrg ;; 734534977a2fSmrg irix|nonstopux) 734634977a2fSmrg func_arith $number_major + $number_minor 734734977a2fSmrg current=$func_arith_result 734834977a2fSmrg age="$number_minor" 734934977a2fSmrg revision="$number_minor" 735034977a2fSmrg lt_irix_increment=no 735134977a2fSmrg ;; 735234977a2fSmrg esac 735334977a2fSmrg ;; 735434977a2fSmrg no) 735534977a2fSmrg current="$1" 735634977a2fSmrg revision="$2" 735734977a2fSmrg age="$3" 735834977a2fSmrg ;; 735934977a2fSmrg esac 736034977a2fSmrg 736134977a2fSmrg # Check that each of the things are valid numbers. 736234977a2fSmrg case $current in 736334977a2fSmrg 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]) ;; 736434977a2fSmrg *) 736534977a2fSmrg func_error "CURRENT \`$current' must be a nonnegative integer" 736634977a2fSmrg func_fatal_error "\`$vinfo' is not valid version information" 736734977a2fSmrg ;; 736834977a2fSmrg esac 736934977a2fSmrg 737034977a2fSmrg case $revision in 737134977a2fSmrg 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]) ;; 737234977a2fSmrg *) 737334977a2fSmrg func_error "REVISION \`$revision' must be a nonnegative integer" 737434977a2fSmrg func_fatal_error "\`$vinfo' is not valid version information" 737534977a2fSmrg ;; 737634977a2fSmrg esac 737734977a2fSmrg 737834977a2fSmrg case $age in 737934977a2fSmrg 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]) ;; 738034977a2fSmrg *) 738134977a2fSmrg func_error "AGE \`$age' must be a nonnegative integer" 738234977a2fSmrg func_fatal_error "\`$vinfo' is not valid version information" 738334977a2fSmrg ;; 738434977a2fSmrg esac 738534977a2fSmrg 738634977a2fSmrg if test "$age" -gt "$current"; then 738734977a2fSmrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 738834977a2fSmrg func_fatal_error "\`$vinfo' is not valid version information" 738934977a2fSmrg fi 739034977a2fSmrg 739134977a2fSmrg # Calculate the version variables. 739234977a2fSmrg major= 739334977a2fSmrg versuffix= 739434977a2fSmrg verstring= 739534977a2fSmrg case $version_type in 739634977a2fSmrg none) ;; 739734977a2fSmrg 739834977a2fSmrg darwin) 739934977a2fSmrg # Like Linux, but with the current version available in 740034977a2fSmrg # verstring for coding it into the library header 740134977a2fSmrg func_arith $current - $age 740234977a2fSmrg major=.$func_arith_result 740334977a2fSmrg versuffix="$major.$age.$revision" 740434977a2fSmrg # Darwin ld doesn't like 0 for these options... 740534977a2fSmrg func_arith $current + 1 740634977a2fSmrg minor_current=$func_arith_result 740734977a2fSmrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 740834977a2fSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 740934977a2fSmrg ;; 741034977a2fSmrg 741134977a2fSmrg freebsd-aout) 741234977a2fSmrg major=".$current" 741334977a2fSmrg versuffix=".$current.$revision"; 741434977a2fSmrg ;; 741534977a2fSmrg 741634977a2fSmrg freebsd-elf) 741734977a2fSmrg major=".$current" 741834977a2fSmrg versuffix=".$current" 741934977a2fSmrg ;; 742034977a2fSmrg 742134977a2fSmrg irix | nonstopux) 742234977a2fSmrg if test "X$lt_irix_increment" = "Xno"; then 742334977a2fSmrg func_arith $current - $age 742434977a2fSmrg else 742534977a2fSmrg func_arith $current - $age + 1 742634977a2fSmrg fi 742734977a2fSmrg major=$func_arith_result 742834977a2fSmrg 742934977a2fSmrg case $version_type in 743034977a2fSmrg nonstopux) verstring_prefix=nonstopux ;; 743134977a2fSmrg *) verstring_prefix=sgi ;; 743234977a2fSmrg esac 743334977a2fSmrg verstring="$verstring_prefix$major.$revision" 743434977a2fSmrg 743534977a2fSmrg # Add in all the interfaces that we are compatible with. 743634977a2fSmrg loop=$revision 743734977a2fSmrg while test "$loop" -ne 0; do 743834977a2fSmrg func_arith $revision - $loop 743934977a2fSmrg iface=$func_arith_result 744034977a2fSmrg func_arith $loop - 1 744134977a2fSmrg loop=$func_arith_result 744234977a2fSmrg verstring="$verstring_prefix$major.$iface:$verstring" 744334977a2fSmrg done 744434977a2fSmrg 744534977a2fSmrg # Before this point, $major must not contain `.'. 744634977a2fSmrg major=.$major 744734977a2fSmrg versuffix="$major.$revision" 744834977a2fSmrg ;; 744934977a2fSmrg 74503e72ca8cSmrg linux) # correct to gnu/linux during the next big refactor 745134977a2fSmrg func_arith $current - $age 745234977a2fSmrg major=.$func_arith_result 745334977a2fSmrg versuffix="$major.$age.$revision" 745434977a2fSmrg ;; 745534977a2fSmrg 745634977a2fSmrg osf) 745734977a2fSmrg func_arith $current - $age 745834977a2fSmrg major=.$func_arith_result 745934977a2fSmrg versuffix=".$current.$age.$revision" 746034977a2fSmrg verstring="$current.$age.$revision" 746134977a2fSmrg 746234977a2fSmrg # Add in all the interfaces that we are compatible with. 746334977a2fSmrg loop=$age 746434977a2fSmrg while test "$loop" -ne 0; do 746534977a2fSmrg func_arith $current - $loop 746634977a2fSmrg iface=$func_arith_result 746734977a2fSmrg func_arith $loop - 1 746834977a2fSmrg loop=$func_arith_result 746934977a2fSmrg verstring="$verstring:${iface}.0" 747034977a2fSmrg done 747134977a2fSmrg 747234977a2fSmrg # Make executables depend on our current version. 74733e72ca8cSmrg func_append verstring ":${current}.0" 747434977a2fSmrg ;; 747534977a2fSmrg 747634977a2fSmrg qnx) 747734977a2fSmrg major=".$current" 747834977a2fSmrg versuffix=".$current" 747934977a2fSmrg ;; 748034977a2fSmrg 748134977a2fSmrg sunos) 748234977a2fSmrg major=".$current" 748334977a2fSmrg versuffix=".$current.$revision" 748434977a2fSmrg ;; 748534977a2fSmrg 748634977a2fSmrg windows) 748734977a2fSmrg # Use '-' rather than '.', since we only want one 748834977a2fSmrg # extension on DOS 8.3 filesystems. 748934977a2fSmrg func_arith $current - $age 749034977a2fSmrg major=$func_arith_result 749134977a2fSmrg versuffix="-$major" 749234977a2fSmrg ;; 749334977a2fSmrg 749434977a2fSmrg *) 749534977a2fSmrg func_fatal_configuration "unknown library version type \`$version_type'" 749634977a2fSmrg ;; 749734977a2fSmrg esac 749834977a2fSmrg 749934977a2fSmrg # Clear the version info if we defaulted, and they specified a release. 750034977a2fSmrg if test -z "$vinfo" && test -n "$release"; then 750134977a2fSmrg major= 750234977a2fSmrg case $version_type in 750334977a2fSmrg darwin) 750434977a2fSmrg # we can't check for "0.0" in archive_cmds due to quoting 750534977a2fSmrg # problems, so we reset it completely 750634977a2fSmrg verstring= 750734977a2fSmrg ;; 750834977a2fSmrg *) 750934977a2fSmrg verstring="0.0" 751034977a2fSmrg ;; 751134977a2fSmrg esac 751234977a2fSmrg if test "$need_version" = no; then 751334977a2fSmrg versuffix= 751434977a2fSmrg else 751534977a2fSmrg versuffix=".0.0" 751634977a2fSmrg fi 751734977a2fSmrg fi 751834977a2fSmrg 751934977a2fSmrg # Remove version info from name if versioning should be avoided 752034977a2fSmrg if test "$avoid_version" = yes && test "$need_version" = no; then 752134977a2fSmrg major= 752234977a2fSmrg versuffix= 752334977a2fSmrg verstring="" 752434977a2fSmrg fi 752534977a2fSmrg 752634977a2fSmrg # Check to see if the archive will have undefined symbols. 752734977a2fSmrg if test "$allow_undefined" = yes; then 752834977a2fSmrg if test "$allow_undefined_flag" = unsupported; then 752934977a2fSmrg func_warning "undefined symbols not allowed in $host shared libraries" 753034977a2fSmrg build_libtool_libs=no 753134977a2fSmrg build_old_libs=yes 753234977a2fSmrg fi 753334977a2fSmrg else 753434977a2fSmrg # Don't allow undefined symbols. 753534977a2fSmrg allow_undefined_flag="$no_undefined_flag" 753634977a2fSmrg fi 753734977a2fSmrg 753834977a2fSmrg fi 753934977a2fSmrg 754034977a2fSmrg func_generate_dlsyms "$libname" "$libname" "yes" 75413e72ca8cSmrg func_append libobjs " $symfileobj" 754234977a2fSmrg test "X$libobjs" = "X " && libobjs= 754334977a2fSmrg 75443e72ca8cSmrg if test "$opt_mode" != relink; then 754534977a2fSmrg # Remove our outputs, but don't remove object files since they 754634977a2fSmrg # may have been created when compiling PIC objects. 754734977a2fSmrg removelist= 754834977a2fSmrg tempremovelist=`$ECHO "$output_objdir/*"` 754934977a2fSmrg for p in $tempremovelist; do 755034977a2fSmrg case $p in 755134977a2fSmrg *.$objext | *.gcno) 755234977a2fSmrg ;; 755334977a2fSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 755434977a2fSmrg if test "X$precious_files_regex" != "X"; then 755534977a2fSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 755634977a2fSmrg then 755734977a2fSmrg continue 755834977a2fSmrg fi 755934977a2fSmrg fi 75603e72ca8cSmrg func_append removelist " $p" 756134977a2fSmrg ;; 756234977a2fSmrg *) ;; 756334977a2fSmrg esac 756434977a2fSmrg done 756534977a2fSmrg test -n "$removelist" && \ 756634977a2fSmrg func_show_eval "${RM}r \$removelist" 756734977a2fSmrg fi 756834977a2fSmrg 756934977a2fSmrg # Now set the variables for building old libraries. 757034977a2fSmrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 75713e72ca8cSmrg func_append oldlibs " $output_objdir/$libname.$libext" 757234977a2fSmrg 757334977a2fSmrg # Transform .lo files to .o files. 7574b425557eSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 757534977a2fSmrg fi 757634977a2fSmrg 757734977a2fSmrg # Eliminate all temporary directories. 757834977a2fSmrg #for path in $notinst_path; do 7579b425557eSmrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 7580b425557eSmrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 7581b425557eSmrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 758234977a2fSmrg #done 758334977a2fSmrg 758434977a2fSmrg if test -n "$xrpath"; then 758534977a2fSmrg # If the user specified any rpath flags, then add them. 758634977a2fSmrg temp_xrpath= 758734977a2fSmrg for libdir in $xrpath; do 75883e72ca8cSmrg func_replace_sysroot "$libdir" 75893e72ca8cSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 759034977a2fSmrg case "$finalize_rpath " in 759134977a2fSmrg *" $libdir "*) ;; 75923e72ca8cSmrg *) func_append finalize_rpath " $libdir" ;; 759334977a2fSmrg esac 759434977a2fSmrg done 759534977a2fSmrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 759634977a2fSmrg dependency_libs="$temp_xrpath $dependency_libs" 759734977a2fSmrg fi 759834977a2fSmrg fi 759934977a2fSmrg 760034977a2fSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 760134977a2fSmrg old_dlfiles="$dlfiles" 760234977a2fSmrg dlfiles= 760334977a2fSmrg for lib in $old_dlfiles; do 760434977a2fSmrg case " $dlprefiles $dlfiles " in 760534977a2fSmrg *" $lib "*) ;; 76063e72ca8cSmrg *) func_append dlfiles " $lib" ;; 760734977a2fSmrg esac 760834977a2fSmrg done 760934977a2fSmrg 761034977a2fSmrg # Make sure dlprefiles contains only unique files 761134977a2fSmrg old_dlprefiles="$dlprefiles" 761234977a2fSmrg dlprefiles= 761334977a2fSmrg for lib in $old_dlprefiles; do 761434977a2fSmrg case "$dlprefiles " in 761534977a2fSmrg *" $lib "*) ;; 76163e72ca8cSmrg *) func_append dlprefiles " $lib" ;; 761734977a2fSmrg esac 761834977a2fSmrg done 761934977a2fSmrg 762034977a2fSmrg if test "$build_libtool_libs" = yes; then 762134977a2fSmrg if test -n "$rpath"; then 762234977a2fSmrg case $host in 7623b425557eSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 762434977a2fSmrg # these systems don't actually have a c library (as such)! 762534977a2fSmrg ;; 762634977a2fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 762734977a2fSmrg # Rhapsody C library is in the System framework 76283e72ca8cSmrg func_append deplibs " System.ltframework" 762934977a2fSmrg ;; 763034977a2fSmrg *-*-netbsd*) 763134977a2fSmrg # Don't link with libc until the a.out ld.so is fixed. 763234977a2fSmrg ;; 763334977a2fSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 763434977a2fSmrg # Do not include libc due to us having libc/libc_r. 763534977a2fSmrg ;; 763634977a2fSmrg *-*-sco3.2v5* | *-*-sco5v6*) 763734977a2fSmrg # Causes problems with __ctype 763834977a2fSmrg ;; 763934977a2fSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 764034977a2fSmrg # Compiler inserts libc in the correct place for threads to work 764134977a2fSmrg ;; 764234977a2fSmrg *) 764334977a2fSmrg # Add libc to deplibs on all other systems if necessary. 764434977a2fSmrg if test "$build_libtool_need_lc" = "yes"; then 76453e72ca8cSmrg func_append deplibs " -lc" 764634977a2fSmrg fi 764734977a2fSmrg ;; 764834977a2fSmrg esac 764934977a2fSmrg fi 765034977a2fSmrg 765134977a2fSmrg # Transform deplibs into only deplibs that can be linked in shared. 765234977a2fSmrg name_save=$name 765334977a2fSmrg libname_save=$libname 765434977a2fSmrg release_save=$release 765534977a2fSmrg versuffix_save=$versuffix 765634977a2fSmrg major_save=$major 765734977a2fSmrg # I'm not sure if I'm treating the release correctly. I think 765834977a2fSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 765934977a2fSmrg # add it in twice. Is that correct? 766034977a2fSmrg release="" 766134977a2fSmrg versuffix="" 766234977a2fSmrg major="" 766334977a2fSmrg newdeplibs= 766434977a2fSmrg droppeddeps=no 766534977a2fSmrg case $deplibs_check_method in 766634977a2fSmrg pass_all) 766734977a2fSmrg # Don't check for shared/static. Everything works. 766834977a2fSmrg # This might be a little naive. We might want to check 766934977a2fSmrg # whether the library exists or not. But this is on 767034977a2fSmrg # osf3 & osf4 and I'm not really sure... Just 767134977a2fSmrg # implementing what was already the behavior. 767234977a2fSmrg newdeplibs=$deplibs 767334977a2fSmrg ;; 767434977a2fSmrg test_compile) 767534977a2fSmrg # This code stresses the "libraries are programs" paradigm to its 767634977a2fSmrg # limits. Maybe even breaks it. We compile a program, linking it 767734977a2fSmrg # against the deplibs as a proxy for the library. Then we can check 767834977a2fSmrg # whether they linked in statically or dynamically with ldd. 767934977a2fSmrg $opt_dry_run || $RM conftest.c 768034977a2fSmrg cat > conftest.c <<EOF 768134977a2fSmrg int main() { return 0; } 768234977a2fSmrgEOF 768334977a2fSmrg $opt_dry_run || $RM conftest 768434977a2fSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 768534977a2fSmrg ldd_output=`ldd conftest` 768634977a2fSmrg for i in $deplibs; do 768734977a2fSmrg case $i in 768834977a2fSmrg -l*) 768934977a2fSmrg func_stripname -l '' "$i" 769034977a2fSmrg name=$func_stripname_result 769134977a2fSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 769234977a2fSmrg case " $predeps $postdeps " in 769334977a2fSmrg *" $i "*) 76943e72ca8cSmrg func_append newdeplibs " $i" 769534977a2fSmrg i="" 769634977a2fSmrg ;; 769734977a2fSmrg esac 769834977a2fSmrg fi 769934977a2fSmrg if test -n "$i" ; then 770034977a2fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 770134977a2fSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 770234977a2fSmrg set dummy $deplib_matches; shift 770334977a2fSmrg deplib_match=$1 770434977a2fSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 77053e72ca8cSmrg func_append newdeplibs " $i" 770634977a2fSmrg else 770734977a2fSmrg droppeddeps=yes 7708b425557eSmrg echo 770934977a2fSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7710b425557eSmrg echo "*** I have the capability to make that library automatically link in when" 7711b425557eSmrg echo "*** you link to this library. But I can only do this if you have a" 7712b425557eSmrg echo "*** shared version of the library, which I believe you do not have" 7713b425557eSmrg echo "*** because a test_compile did reveal that the linker did not use it for" 7714b425557eSmrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 771534977a2fSmrg fi 771634977a2fSmrg fi 771734977a2fSmrg ;; 771834977a2fSmrg *) 77193e72ca8cSmrg func_append newdeplibs " $i" 772034977a2fSmrg ;; 772134977a2fSmrg esac 772234977a2fSmrg done 772334977a2fSmrg else 772434977a2fSmrg # Error occurred in the first compile. Let's try to salvage 772534977a2fSmrg # the situation: Compile a separate program for each library. 772634977a2fSmrg for i in $deplibs; do 772734977a2fSmrg case $i in 772834977a2fSmrg -l*) 772934977a2fSmrg func_stripname -l '' "$i" 773034977a2fSmrg name=$func_stripname_result 773134977a2fSmrg $opt_dry_run || $RM conftest 773234977a2fSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 773334977a2fSmrg ldd_output=`ldd conftest` 773434977a2fSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 773534977a2fSmrg case " $predeps $postdeps " in 773634977a2fSmrg *" $i "*) 77373e72ca8cSmrg func_append newdeplibs " $i" 773834977a2fSmrg i="" 773934977a2fSmrg ;; 774034977a2fSmrg esac 774134977a2fSmrg fi 774234977a2fSmrg if test -n "$i" ; then 774334977a2fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 774434977a2fSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 774534977a2fSmrg set dummy $deplib_matches; shift 774634977a2fSmrg deplib_match=$1 774734977a2fSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 77483e72ca8cSmrg func_append newdeplibs " $i" 774934977a2fSmrg else 775034977a2fSmrg droppeddeps=yes 7751b425557eSmrg echo 775234977a2fSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7753b425557eSmrg echo "*** I have the capability to make that library automatically link in when" 7754b425557eSmrg echo "*** you link to this library. But I can only do this if you have a" 7755b425557eSmrg echo "*** shared version of the library, which you do not appear to have" 7756b425557eSmrg echo "*** because a test_compile did reveal that the linker did not use this one" 7757b425557eSmrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 775834977a2fSmrg fi 775934977a2fSmrg fi 776034977a2fSmrg else 776134977a2fSmrg droppeddeps=yes 7762b425557eSmrg echo 776334977a2fSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 7764b425557eSmrg echo "*** make it link in! You will probably need to install it or some" 7765b425557eSmrg echo "*** library that it depends on before this library will be fully" 7766b425557eSmrg echo "*** functional. Installing it before continuing would be even better." 776734977a2fSmrg fi 776834977a2fSmrg ;; 776934977a2fSmrg *) 77703e72ca8cSmrg func_append newdeplibs " $i" 777134977a2fSmrg ;; 777234977a2fSmrg esac 777334977a2fSmrg done 777434977a2fSmrg fi 777534977a2fSmrg ;; 777634977a2fSmrg file_magic*) 777734977a2fSmrg set dummy $deplibs_check_method; shift 777834977a2fSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 777934977a2fSmrg for a_deplib in $deplibs; do 778034977a2fSmrg case $a_deplib in 778134977a2fSmrg -l*) 778234977a2fSmrg func_stripname -l '' "$a_deplib" 778334977a2fSmrg name=$func_stripname_result 778434977a2fSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 778534977a2fSmrg case " $predeps $postdeps " in 778634977a2fSmrg *" $a_deplib "*) 77873e72ca8cSmrg func_append newdeplibs " $a_deplib" 778834977a2fSmrg a_deplib="" 778934977a2fSmrg ;; 779034977a2fSmrg esac 779134977a2fSmrg fi 779234977a2fSmrg if test -n "$a_deplib" ; then 779334977a2fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 77943e72ca8cSmrg if test -n "$file_magic_glob"; then 77953e72ca8cSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 77963e72ca8cSmrg else 77973e72ca8cSmrg libnameglob=$libname 77983e72ca8cSmrg fi 77993e72ca8cSmrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 780034977a2fSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 78013e72ca8cSmrg if test "$want_nocaseglob" = yes; then 78023e72ca8cSmrg shopt -s nocaseglob 78033e72ca8cSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 78043e72ca8cSmrg $nocaseglob 78053e72ca8cSmrg else 78063e72ca8cSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 78073e72ca8cSmrg fi 780834977a2fSmrg for potent_lib in $potential_libs; do 780934977a2fSmrg # Follow soft links. 781034977a2fSmrg if ls -lLd "$potent_lib" 2>/dev/null | 781134977a2fSmrg $GREP " -> " >/dev/null; then 781234977a2fSmrg continue 781334977a2fSmrg fi 781434977a2fSmrg # The statement above tries to avoid entering an 781534977a2fSmrg # endless loop below, in case of cyclic links. 781634977a2fSmrg # We might still enter an endless loop, since a link 781734977a2fSmrg # loop can be closed while we follow links, 781834977a2fSmrg # but so what? 781934977a2fSmrg potlib="$potent_lib" 782034977a2fSmrg while test -h "$potlib" 2>/dev/null; do 782134977a2fSmrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 782234977a2fSmrg case $potliblink in 782334977a2fSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 7824b425557eSmrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 782534977a2fSmrg esac 782634977a2fSmrg done 782734977a2fSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 782834977a2fSmrg $SED -e 10q | 782934977a2fSmrg $EGREP "$file_magic_regex" > /dev/null; then 78303e72ca8cSmrg func_append newdeplibs " $a_deplib" 783134977a2fSmrg a_deplib="" 783234977a2fSmrg break 2 783334977a2fSmrg fi 783434977a2fSmrg done 783534977a2fSmrg done 783634977a2fSmrg fi 783734977a2fSmrg if test -n "$a_deplib" ; then 783834977a2fSmrg droppeddeps=yes 7839b425557eSmrg echo 784034977a2fSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7841b425557eSmrg echo "*** I have the capability to make that library automatically link in when" 7842b425557eSmrg echo "*** you link to this library. But I can only do this if you have a" 7843b425557eSmrg echo "*** shared version of the library, which you do not appear to have" 7844b425557eSmrg echo "*** because I did check the linker path looking for a file starting" 784534977a2fSmrg if test -z "$potlib" ; then 784634977a2fSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 784734977a2fSmrg else 784834977a2fSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 784934977a2fSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 785034977a2fSmrg fi 785134977a2fSmrg fi 785234977a2fSmrg ;; 785334977a2fSmrg *) 785434977a2fSmrg # Add a -L argument. 78553e72ca8cSmrg func_append newdeplibs " $a_deplib" 785634977a2fSmrg ;; 785734977a2fSmrg esac 785834977a2fSmrg done # Gone through all deplibs. 785934977a2fSmrg ;; 786034977a2fSmrg match_pattern*) 786134977a2fSmrg set dummy $deplibs_check_method; shift 786234977a2fSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 786334977a2fSmrg for a_deplib in $deplibs; do 786434977a2fSmrg case $a_deplib in 786534977a2fSmrg -l*) 786634977a2fSmrg func_stripname -l '' "$a_deplib" 786734977a2fSmrg name=$func_stripname_result 786834977a2fSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 786934977a2fSmrg case " $predeps $postdeps " in 787034977a2fSmrg *" $a_deplib "*) 78713e72ca8cSmrg func_append newdeplibs " $a_deplib" 787234977a2fSmrg a_deplib="" 787334977a2fSmrg ;; 787434977a2fSmrg esac 787534977a2fSmrg fi 787634977a2fSmrg if test -n "$a_deplib" ; then 787734977a2fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 787834977a2fSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 787934977a2fSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 788034977a2fSmrg for potent_lib in $potential_libs; do 788134977a2fSmrg potlib="$potent_lib" # see symlink-check above in file_magic test 7882b425557eSmrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 788334977a2fSmrg $EGREP "$match_pattern_regex" > /dev/null; then 78843e72ca8cSmrg func_append newdeplibs " $a_deplib" 788534977a2fSmrg a_deplib="" 788634977a2fSmrg break 2 788734977a2fSmrg fi 788834977a2fSmrg done 788934977a2fSmrg done 789034977a2fSmrg fi 789134977a2fSmrg if test -n "$a_deplib" ; then 789234977a2fSmrg droppeddeps=yes 7893b425557eSmrg echo 789434977a2fSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7895b425557eSmrg echo "*** I have the capability to make that library automatically link in when" 7896b425557eSmrg echo "*** you link to this library. But I can only do this if you have a" 7897b425557eSmrg echo "*** shared version of the library, which you do not appear to have" 7898b425557eSmrg echo "*** because I did check the linker path looking for a file starting" 789934977a2fSmrg if test -z "$potlib" ; then 790034977a2fSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 790134977a2fSmrg else 790234977a2fSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 790334977a2fSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 790434977a2fSmrg fi 790534977a2fSmrg fi 790634977a2fSmrg ;; 790734977a2fSmrg *) 790834977a2fSmrg # Add a -L argument. 79093e72ca8cSmrg func_append newdeplibs " $a_deplib" 791034977a2fSmrg ;; 791134977a2fSmrg esac 791234977a2fSmrg done # Gone through all deplibs. 791334977a2fSmrg ;; 791434977a2fSmrg none | unknown | *) 791534977a2fSmrg newdeplibs="" 7916b425557eSmrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 791734977a2fSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 791834977a2fSmrg for i in $predeps $postdeps ; do 791934977a2fSmrg # can't use Xsed below, because $i might contain '/' 7920b425557eSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 792134977a2fSmrg done 792234977a2fSmrg fi 7923b425557eSmrg case $tmp_deplibs in 7924b425557eSmrg *[!\ \ ]*) 7925b425557eSmrg echo 792634977a2fSmrg if test "X$deplibs_check_method" = "Xnone"; then 7927b425557eSmrg echo "*** Warning: inter-library dependencies are not supported in this platform." 792834977a2fSmrg else 7929b425557eSmrg echo "*** Warning: inter-library dependencies are not known to be supported." 793034977a2fSmrg fi 7931b425557eSmrg echo "*** All declared inter-library dependencies are being dropped." 793234977a2fSmrg droppeddeps=yes 7933b425557eSmrg ;; 7934b425557eSmrg esac 793534977a2fSmrg ;; 793634977a2fSmrg esac 793734977a2fSmrg versuffix=$versuffix_save 793834977a2fSmrg major=$major_save 793934977a2fSmrg release=$release_save 794034977a2fSmrg libname=$libname_save 794134977a2fSmrg name=$name_save 794234977a2fSmrg 794334977a2fSmrg case $host in 794434977a2fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 794534977a2fSmrg # On Rhapsody replace the C library with the System framework 7946b425557eSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 794734977a2fSmrg ;; 794834977a2fSmrg esac 794934977a2fSmrg 795034977a2fSmrg if test "$droppeddeps" = yes; then 795134977a2fSmrg if test "$module" = yes; then 7952b425557eSmrg echo 7953b425557eSmrg echo "*** Warning: libtool could not satisfy all declared inter-library" 795434977a2fSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 7955b425557eSmrg echo "*** a static module, that should work as long as the dlopening" 7956b425557eSmrg echo "*** application is linked with the -dlopen flag." 795734977a2fSmrg if test -z "$global_symbol_pipe"; then 7958b425557eSmrg echo 7959b425557eSmrg echo "*** However, this would only work if libtool was able to extract symbol" 7960b425557eSmrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 7961b425557eSmrg echo "*** not find such a program. So, this module is probably useless." 7962b425557eSmrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 796334977a2fSmrg fi 796434977a2fSmrg if test "$build_old_libs" = no; then 796534977a2fSmrg oldlibs="$output_objdir/$libname.$libext" 796634977a2fSmrg build_libtool_libs=module 796734977a2fSmrg build_old_libs=yes 796834977a2fSmrg else 796934977a2fSmrg build_libtool_libs=no 797034977a2fSmrg fi 797134977a2fSmrg else 7972b425557eSmrg echo "*** The inter-library dependencies that have been dropped here will be" 7973b425557eSmrg echo "*** automatically added whenever a program is linked with this library" 7974b425557eSmrg echo "*** or is declared to -dlopen it." 797534977a2fSmrg 797634977a2fSmrg if test "$allow_undefined" = no; then 7977b425557eSmrg echo 7978b425557eSmrg echo "*** Since this library must not contain undefined symbols," 7979b425557eSmrg echo "*** because either the platform does not support them or" 7980b425557eSmrg echo "*** it was explicitly requested with -no-undefined," 7981b425557eSmrg echo "*** libtool will only create a static version of it." 798234977a2fSmrg if test "$build_old_libs" = no; then 798334977a2fSmrg oldlibs="$output_objdir/$libname.$libext" 798434977a2fSmrg build_libtool_libs=module 798534977a2fSmrg build_old_libs=yes 798634977a2fSmrg else 798734977a2fSmrg build_libtool_libs=no 798834977a2fSmrg fi 798934977a2fSmrg fi 799034977a2fSmrg fi 799134977a2fSmrg fi 799234977a2fSmrg # Done checking deplibs! 799334977a2fSmrg deplibs=$newdeplibs 799434977a2fSmrg fi 799534977a2fSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 799634977a2fSmrg case $host in 799734977a2fSmrg *-*-darwin*) 7998b425557eSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7999b425557eSmrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8000b425557eSmrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 800134977a2fSmrg ;; 800234977a2fSmrg esac 800334977a2fSmrg 800434977a2fSmrg # move library search paths that coincide with paths to not yet 800534977a2fSmrg # installed libraries to the beginning of the library search list 800634977a2fSmrg new_libs= 800734977a2fSmrg for path in $notinst_path; do 800834977a2fSmrg case " $new_libs " in 800934977a2fSmrg *" -L$path/$objdir "*) ;; 801034977a2fSmrg *) 801134977a2fSmrg case " $deplibs " in 801234977a2fSmrg *" -L$path/$objdir "*) 80133e72ca8cSmrg func_append new_libs " -L$path/$objdir" ;; 801434977a2fSmrg esac 801534977a2fSmrg ;; 801634977a2fSmrg esac 801734977a2fSmrg done 801834977a2fSmrg for deplib in $deplibs; do 801934977a2fSmrg case $deplib in 802034977a2fSmrg -L*) 802134977a2fSmrg case " $new_libs " in 802234977a2fSmrg *" $deplib "*) ;; 80233e72ca8cSmrg *) func_append new_libs " $deplib" ;; 802434977a2fSmrg esac 802534977a2fSmrg ;; 80263e72ca8cSmrg *) func_append new_libs " $deplib" ;; 802734977a2fSmrg esac 802834977a2fSmrg done 802934977a2fSmrg deplibs="$new_libs" 803034977a2fSmrg 803134977a2fSmrg # All the library-specific variables (install_libdir is set above). 803234977a2fSmrg library_names= 803334977a2fSmrg old_library= 803434977a2fSmrg dlname= 803534977a2fSmrg 803634977a2fSmrg # Test again, we may have decided not to build it any more 803734977a2fSmrg if test "$build_libtool_libs" = yes; then 80383e72ca8cSmrg # Remove ${wl} instances when linking with ld. 80393e72ca8cSmrg # FIXME: should test the right _cmds variable. 80403e72ca8cSmrg case $archive_cmds in 80413e72ca8cSmrg *\$LD\ *) wl= ;; 80423e72ca8cSmrg esac 804334977a2fSmrg if test "$hardcode_into_libs" = yes; then 804434977a2fSmrg # Hardcode the library paths 804534977a2fSmrg hardcode_libdirs= 804634977a2fSmrg dep_rpath= 804734977a2fSmrg rpath="$finalize_rpath" 80483e72ca8cSmrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 804934977a2fSmrg for libdir in $rpath; do 805034977a2fSmrg if test -n "$hardcode_libdir_flag_spec"; then 805134977a2fSmrg if test -n "$hardcode_libdir_separator"; then 80523e72ca8cSmrg func_replace_sysroot "$libdir" 80533e72ca8cSmrg libdir=$func_replace_sysroot_result 805434977a2fSmrg if test -z "$hardcode_libdirs"; then 805534977a2fSmrg hardcode_libdirs="$libdir" 805634977a2fSmrg else 805734977a2fSmrg # Just accumulate the unique libdirs. 805834977a2fSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 805934977a2fSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 806034977a2fSmrg ;; 806134977a2fSmrg *) 80623e72ca8cSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 806334977a2fSmrg ;; 806434977a2fSmrg esac 806534977a2fSmrg fi 806634977a2fSmrg else 806734977a2fSmrg eval flag=\"$hardcode_libdir_flag_spec\" 80683e72ca8cSmrg func_append dep_rpath " $flag" 806934977a2fSmrg fi 807034977a2fSmrg elif test -n "$runpath_var"; then 807134977a2fSmrg case "$perm_rpath " in 807234977a2fSmrg *" $libdir "*) ;; 80733e72ca8cSmrg *) func_append perm_rpath " $libdir" ;; 807434977a2fSmrg esac 807534977a2fSmrg fi 807634977a2fSmrg done 807734977a2fSmrg # Substitute the hardcoded libdirs into the rpath. 807834977a2fSmrg if test -n "$hardcode_libdir_separator" && 807934977a2fSmrg test -n "$hardcode_libdirs"; then 808034977a2fSmrg libdir="$hardcode_libdirs" 80813e72ca8cSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 808234977a2fSmrg fi 808334977a2fSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 808434977a2fSmrg # We should set the runpath_var. 808534977a2fSmrg rpath= 808634977a2fSmrg for dir in $perm_rpath; do 80873e72ca8cSmrg func_append rpath "$dir:" 808834977a2fSmrg done 808934977a2fSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 809034977a2fSmrg fi 809134977a2fSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 809234977a2fSmrg fi 8093ee3138f1Smrg 809434977a2fSmrg shlibpath="$finalize_shlibpath" 80953e72ca8cSmrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 809634977a2fSmrg if test -n "$shlibpath"; then 809734977a2fSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 809834977a2fSmrg fi 8099ee3138f1Smrg 810034977a2fSmrg # Get the real and link names of the library. 810134977a2fSmrg eval shared_ext=\"$shrext_cmds\" 810234977a2fSmrg eval library_names=\"$library_names_spec\" 810334977a2fSmrg set dummy $library_names 810434977a2fSmrg shift 810534977a2fSmrg realname="$1" 810634977a2fSmrg shift 8107ee3138f1Smrg 810834977a2fSmrg if test -n "$soname_spec"; then 810934977a2fSmrg eval soname=\"$soname_spec\" 811034977a2fSmrg else 811134977a2fSmrg soname="$realname" 811234977a2fSmrg fi 811334977a2fSmrg if test -z "$dlname"; then 811434977a2fSmrg dlname=$soname 811534977a2fSmrg fi 8116ee3138f1Smrg 811734977a2fSmrg lib="$output_objdir/$realname" 811834977a2fSmrg linknames= 811934977a2fSmrg for link 812034977a2fSmrg do 81213e72ca8cSmrg func_append linknames " $link" 812234977a2fSmrg done 8123ee3138f1Smrg 812434977a2fSmrg # Use standard objects if they are pic 8125b425557eSmrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 812634977a2fSmrg test "X$libobjs" = "X " && libobjs= 8127ee3138f1Smrg 812834977a2fSmrg delfiles= 812934977a2fSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 813034977a2fSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 813134977a2fSmrg export_symbols="$output_objdir/$libname.uexp" 81323e72ca8cSmrg func_append delfiles " $export_symbols" 813334977a2fSmrg fi 8134ee3138f1Smrg 813534977a2fSmrg orig_export_symbols= 813634977a2fSmrg case $host_os in 813734977a2fSmrg cygwin* | mingw* | cegcc*) 813834977a2fSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 813934977a2fSmrg # exporting using user supplied symfile 814034977a2fSmrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 814134977a2fSmrg # and it's NOT already a .def file. Must figure out 814234977a2fSmrg # which of the given symbols are data symbols and tag 814334977a2fSmrg # them as such. So, trigger use of export_symbols_cmds. 814434977a2fSmrg # export_symbols gets reassigned inside the "prepare 814534977a2fSmrg # the list of exported symbols" if statement, so the 814634977a2fSmrg # include_expsyms logic still works. 814734977a2fSmrg orig_export_symbols="$export_symbols" 814834977a2fSmrg export_symbols= 814934977a2fSmrg always_export_symbols=yes 815034977a2fSmrg fi 815134977a2fSmrg fi 815234977a2fSmrg ;; 815334977a2fSmrg esac 8154ee3138f1Smrg 815534977a2fSmrg # Prepare the list of exported symbols 815634977a2fSmrg if test -z "$export_symbols"; then 815734977a2fSmrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 815834977a2fSmrg func_verbose "generating symbol list for \`$libname.la'" 815934977a2fSmrg export_symbols="$output_objdir/$libname.exp" 816034977a2fSmrg $opt_dry_run || $RM $export_symbols 816134977a2fSmrg cmds=$export_symbols_cmds 816234977a2fSmrg save_ifs="$IFS"; IFS='~' 81633e72ca8cSmrg for cmd1 in $cmds; do 816434977a2fSmrg IFS="$save_ifs" 81653e72ca8cSmrg # Take the normal branch if the nm_file_list_spec branch 81663e72ca8cSmrg # doesn't work or if tool conversion is not needed. 81673e72ca8cSmrg case $nm_file_list_spec~$to_tool_file_cmd in 81683e72ca8cSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 81693e72ca8cSmrg try_normal_branch=yes 81703e72ca8cSmrg eval cmd=\"$cmd1\" 81713e72ca8cSmrg func_len " $cmd" 81723e72ca8cSmrg len=$func_len_result 81733e72ca8cSmrg ;; 81743e72ca8cSmrg *) 81753e72ca8cSmrg try_normal_branch=no 81763e72ca8cSmrg ;; 81773e72ca8cSmrg esac 81783e72ca8cSmrg if test "$try_normal_branch" = yes \ 81793e72ca8cSmrg && { test "$len" -lt "$max_cmd_len" \ 81803e72ca8cSmrg || test "$max_cmd_len" -le -1; } 81813e72ca8cSmrg then 81823e72ca8cSmrg func_show_eval "$cmd" 'exit $?' 81833e72ca8cSmrg skipped_export=false 81843e72ca8cSmrg elif test -n "$nm_file_list_spec"; then 81853e72ca8cSmrg func_basename "$output" 81863e72ca8cSmrg output_la=$func_basename_result 81873e72ca8cSmrg save_libobjs=$libobjs 81883e72ca8cSmrg save_output=$output 81893e72ca8cSmrg output=${output_objdir}/${output_la}.nm 81903e72ca8cSmrg func_to_tool_file "$output" 81913e72ca8cSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 81923e72ca8cSmrg func_append delfiles " $output" 81933e72ca8cSmrg func_verbose "creating $NM input file list: $output" 81943e72ca8cSmrg for obj in $save_libobjs; do 81953e72ca8cSmrg func_to_tool_file "$obj" 81963e72ca8cSmrg $ECHO "$func_to_tool_file_result" 81973e72ca8cSmrg done > "$output" 81983e72ca8cSmrg eval cmd=\"$cmd1\" 819934977a2fSmrg func_show_eval "$cmd" 'exit $?' 82003e72ca8cSmrg output=$save_output 82013e72ca8cSmrg libobjs=$save_libobjs 820234977a2fSmrg skipped_export=false 820334977a2fSmrg else 820434977a2fSmrg # The command line is too long to execute in one step. 820534977a2fSmrg func_verbose "using reloadable object file for export list..." 820634977a2fSmrg skipped_export=: 820734977a2fSmrg # Break out early, otherwise skipped_export may be 820834977a2fSmrg # set to false by a later but shorter cmd. 820934977a2fSmrg break 821034977a2fSmrg fi 821134977a2fSmrg done 821234977a2fSmrg IFS="$save_ifs" 821334977a2fSmrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 821434977a2fSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 821534977a2fSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 821634977a2fSmrg fi 821734977a2fSmrg fi 8218ee3138f1Smrg fi 8219ee3138f1Smrg 822034977a2fSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 822134977a2fSmrg tmp_export_symbols="$export_symbols" 822234977a2fSmrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8223b425557eSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 822434977a2fSmrg fi 8225ee3138f1Smrg 822634977a2fSmrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 822734977a2fSmrg # The given exports_symbols file has to be filtered, so filter it. 822834977a2fSmrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 822934977a2fSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 823034977a2fSmrg # 's' commands which not all seds can handle. GNU sed should be fine 823134977a2fSmrg # though. Also, the filter scales superlinearly with the number of 823234977a2fSmrg # global variables. join(1) would be nice here, but unfortunately 823334977a2fSmrg # isn't a blessed tool. 823434977a2fSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 82353e72ca8cSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 823634977a2fSmrg export_symbols=$output_objdir/$libname.def 823734977a2fSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 823834977a2fSmrg fi 8239ee3138f1Smrg 824034977a2fSmrg tmp_deplibs= 824134977a2fSmrg for test_deplib in $deplibs; do 824234977a2fSmrg case " $convenience " in 824334977a2fSmrg *" $test_deplib "*) ;; 824434977a2fSmrg *) 82453e72ca8cSmrg func_append tmp_deplibs " $test_deplib" 824634977a2fSmrg ;; 824734977a2fSmrg esac 824834977a2fSmrg done 824934977a2fSmrg deplibs="$tmp_deplibs" 8250ee3138f1Smrg 825134977a2fSmrg if test -n "$convenience"; then 825234977a2fSmrg if test -n "$whole_archive_flag_spec" && 825334977a2fSmrg test "$compiler_needs_object" = yes && 825434977a2fSmrg test -z "$libobjs"; then 825534977a2fSmrg # extract the archives, so we have objects to list. 825634977a2fSmrg # TODO: could optimize this to just extract one archive. 825734977a2fSmrg whole_archive_flag_spec= 825834977a2fSmrg fi 825934977a2fSmrg if test -n "$whole_archive_flag_spec"; then 826034977a2fSmrg save_libobjs=$libobjs 826134977a2fSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 826234977a2fSmrg test "X$libobjs" = "X " && libobjs= 826334977a2fSmrg else 826434977a2fSmrg gentop="$output_objdir/${outputname}x" 82653e72ca8cSmrg func_append generated " $gentop" 8266ee3138f1Smrg 826734977a2fSmrg func_extract_archives $gentop $convenience 82683e72ca8cSmrg func_append libobjs " $func_extract_archives_result" 826934977a2fSmrg test "X$libobjs" = "X " && libobjs= 827034977a2fSmrg fi 8271ee3138f1Smrg fi 8272ee3138f1Smrg 827334977a2fSmrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 827434977a2fSmrg eval flag=\"$thread_safe_flag_spec\" 82753e72ca8cSmrg func_append linker_flags " $flag" 8276ee3138f1Smrg fi 8277ee3138f1Smrg 827834977a2fSmrg # Make a backup of the uninstalled library when relinking 82793e72ca8cSmrg if test "$opt_mode" = relink; then 828034977a2fSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 828134977a2fSmrg fi 8282ee3138f1Smrg 828334977a2fSmrg # Do each of the archive commands. 828434977a2fSmrg if test "$module" = yes && test -n "$module_cmds" ; then 828534977a2fSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 828634977a2fSmrg eval test_cmds=\"$module_expsym_cmds\" 828734977a2fSmrg cmds=$module_expsym_cmds 828834977a2fSmrg else 828934977a2fSmrg eval test_cmds=\"$module_cmds\" 829034977a2fSmrg cmds=$module_cmds 829134977a2fSmrg fi 8292ee3138f1Smrg else 829334977a2fSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 829434977a2fSmrg eval test_cmds=\"$archive_expsym_cmds\" 829534977a2fSmrg cmds=$archive_expsym_cmds 829634977a2fSmrg else 829734977a2fSmrg eval test_cmds=\"$archive_cmds\" 829834977a2fSmrg cmds=$archive_cmds 829934977a2fSmrg fi 8300ee3138f1Smrg fi 8301ee3138f1Smrg 830234977a2fSmrg if test "X$skipped_export" != "X:" && 830334977a2fSmrg func_len " $test_cmds" && 830434977a2fSmrg len=$func_len_result && 830534977a2fSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 830634977a2fSmrg : 830734977a2fSmrg else 830834977a2fSmrg # The command line is too long to link in one step, link piecewise 830934977a2fSmrg # or, if using GNU ld and skipped_export is not :, use a linker 831034977a2fSmrg # script. 8311ee3138f1Smrg 831234977a2fSmrg # Save the value of $output and $libobjs because we want to 831334977a2fSmrg # use them later. If we have whole_archive_flag_spec, we 831434977a2fSmrg # want to use save_libobjs as it was before 831534977a2fSmrg # whole_archive_flag_spec was expanded, because we can't 831634977a2fSmrg # assume the linker understands whole_archive_flag_spec. 831734977a2fSmrg # This may have to be revisited, in case too many 831834977a2fSmrg # convenience libraries get linked in and end up exceeding 831934977a2fSmrg # the spec. 832034977a2fSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 832134977a2fSmrg save_libobjs=$libobjs 832234977a2fSmrg fi 832334977a2fSmrg save_output=$output 8324b425557eSmrg func_basename "$output" 8325b425557eSmrg output_la=$func_basename_result 8326ee3138f1Smrg 832734977a2fSmrg # Clear the reloadable object creation command queue and 832834977a2fSmrg # initialize k to one. 832934977a2fSmrg test_cmds= 833034977a2fSmrg concat_cmds= 833134977a2fSmrg objlist= 833234977a2fSmrg last_robj= 833334977a2fSmrg k=1 833434977a2fSmrg 833534977a2fSmrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 833634977a2fSmrg output=${output_objdir}/${output_la}.lnkscript 833734977a2fSmrg func_verbose "creating GNU ld script: $output" 8338b425557eSmrg echo 'INPUT (' > $output 833934977a2fSmrg for obj in $save_libobjs 8340ee3138f1Smrg do 83413e72ca8cSmrg func_to_tool_file "$obj" 83423e72ca8cSmrg $ECHO "$func_to_tool_file_result" >> $output 834334977a2fSmrg done 8344b425557eSmrg echo ')' >> $output 83453e72ca8cSmrg func_append delfiles " $output" 83463e72ca8cSmrg func_to_tool_file "$output" 83473e72ca8cSmrg output=$func_to_tool_file_result 834834977a2fSmrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 834934977a2fSmrg output=${output_objdir}/${output_la}.lnk 835034977a2fSmrg func_verbose "creating linker input file list: $output" 835134977a2fSmrg : > $output 835234977a2fSmrg set x $save_libobjs 835334977a2fSmrg shift 835434977a2fSmrg firstobj= 835534977a2fSmrg if test "$compiler_needs_object" = yes; then 835634977a2fSmrg firstobj="$1 " 835734977a2fSmrg shift 835834977a2fSmrg fi 835934977a2fSmrg for obj 836034977a2fSmrg do 83613e72ca8cSmrg func_to_tool_file "$obj" 83623e72ca8cSmrg $ECHO "$func_to_tool_file_result" >> $output 836334977a2fSmrg done 83643e72ca8cSmrg func_append delfiles " $output" 83653e72ca8cSmrg func_to_tool_file "$output" 83663e72ca8cSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 836734977a2fSmrg else 836834977a2fSmrg if test -n "$save_libobjs"; then 836934977a2fSmrg func_verbose "creating reloadable object files..." 837034977a2fSmrg output=$output_objdir/$output_la-${k}.$objext 837134977a2fSmrg eval test_cmds=\"$reload_cmds\" 837234977a2fSmrg func_len " $test_cmds" 837334977a2fSmrg len0=$func_len_result 837434977a2fSmrg len=$len0 837534977a2fSmrg 837634977a2fSmrg # Loop over the list of objects to be linked. 837734977a2fSmrg for obj in $save_libobjs 837834977a2fSmrg do 837934977a2fSmrg func_len " $obj" 838034977a2fSmrg func_arith $len + $func_len_result 838134977a2fSmrg len=$func_arith_result 838234977a2fSmrg if test "X$objlist" = X || 838334977a2fSmrg test "$len" -lt "$max_cmd_len"; then 838434977a2fSmrg func_append objlist " $obj" 838534977a2fSmrg else 838634977a2fSmrg # The command $test_cmds is almost too long, add a 838734977a2fSmrg # command to the queue. 838834977a2fSmrg if test "$k" -eq 1 ; then 838934977a2fSmrg # The first file doesn't have a previous command to add. 8390b425557eSmrg reload_objs=$objlist 8391b425557eSmrg eval concat_cmds=\"$reload_cmds\" 839234977a2fSmrg else 839334977a2fSmrg # All subsequent reloadable object files will link in 839434977a2fSmrg # the last one created. 8395b425557eSmrg reload_objs="$objlist $last_robj" 8396b425557eSmrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 839734977a2fSmrg fi 839834977a2fSmrg last_robj=$output_objdir/$output_la-${k}.$objext 839934977a2fSmrg func_arith $k + 1 840034977a2fSmrg k=$func_arith_result 840134977a2fSmrg output=$output_objdir/$output_la-${k}.$objext 8402b425557eSmrg objlist=" $obj" 840334977a2fSmrg func_len " $last_robj" 840434977a2fSmrg func_arith $len0 + $func_len_result 840534977a2fSmrg len=$func_arith_result 840634977a2fSmrg fi 840734977a2fSmrg done 840834977a2fSmrg # Handle the remaining objects by creating one last 840934977a2fSmrg # reloadable object file. All subsequent reloadable object 841034977a2fSmrg # files will link in the last one created. 841134977a2fSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8412b425557eSmrg reload_objs="$objlist $last_robj" 8413b425557eSmrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 841434977a2fSmrg if test -n "$last_robj"; then 841534977a2fSmrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 841634977a2fSmrg fi 84173e72ca8cSmrg func_append delfiles " $output" 8418ee3138f1Smrg 841934977a2fSmrg else 842034977a2fSmrg output= 842134977a2fSmrg fi 8422ee3138f1Smrg 842334977a2fSmrg if ${skipped_export-false}; then 842434977a2fSmrg func_verbose "generating symbol list for \`$libname.la'" 842534977a2fSmrg export_symbols="$output_objdir/$libname.exp" 842634977a2fSmrg $opt_dry_run || $RM $export_symbols 842734977a2fSmrg libobjs=$output 842834977a2fSmrg # Append the command to create the export file. 842934977a2fSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 843034977a2fSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 843134977a2fSmrg if test -n "$last_robj"; then 843234977a2fSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 843334977a2fSmrg fi 8434ee3138f1Smrg fi 8435ee3138f1Smrg 843634977a2fSmrg test -n "$save_libobjs" && 843734977a2fSmrg func_verbose "creating a temporary reloadable object file: $output" 8438ee3138f1Smrg 843934977a2fSmrg # Loop through the commands generated above and execute them. 844034977a2fSmrg save_ifs="$IFS"; IFS='~' 844134977a2fSmrg for cmd in $concat_cmds; do 844234977a2fSmrg IFS="$save_ifs" 844334977a2fSmrg $opt_silent || { 844434977a2fSmrg func_quote_for_expand "$cmd" 844534977a2fSmrg eval "func_echo $func_quote_for_expand_result" 844634977a2fSmrg } 844734977a2fSmrg $opt_dry_run || eval "$cmd" || { 844834977a2fSmrg lt_exit=$? 844934977a2fSmrg 845034977a2fSmrg # Restore the uninstalled library and exit 84513e72ca8cSmrg if test "$opt_mode" = relink; then 845234977a2fSmrg ( cd "$output_objdir" && \ 845334977a2fSmrg $RM "${realname}T" && \ 845434977a2fSmrg $MV "${realname}U" "$realname" ) 845534977a2fSmrg fi 8456ee3138f1Smrg 845734977a2fSmrg exit $lt_exit 845834977a2fSmrg } 845934977a2fSmrg done 846034977a2fSmrg IFS="$save_ifs" 8461ee3138f1Smrg 846234977a2fSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 846334977a2fSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 846434977a2fSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8465ee3138f1Smrg fi 8466ee3138f1Smrg fi 8467ee3138f1Smrg 846834977a2fSmrg if ${skipped_export-false}; then 846934977a2fSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 847034977a2fSmrg tmp_export_symbols="$export_symbols" 847134977a2fSmrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8472b425557eSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 847334977a2fSmrg fi 8474ee3138f1Smrg 847534977a2fSmrg if test -n "$orig_export_symbols"; then 847634977a2fSmrg # The given exports_symbols file has to be filtered, so filter it. 847734977a2fSmrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 847834977a2fSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 847934977a2fSmrg # 's' commands which not all seds can handle. GNU sed should be fine 848034977a2fSmrg # though. Also, the filter scales superlinearly with the number of 848134977a2fSmrg # global variables. join(1) would be nice here, but unfortunately 848234977a2fSmrg # isn't a blessed tool. 848334977a2fSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 84843e72ca8cSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 848534977a2fSmrg export_symbols=$output_objdir/$libname.def 848634977a2fSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 848734977a2fSmrg fi 848834977a2fSmrg fi 8489ee3138f1Smrg 849034977a2fSmrg libobjs=$output 849134977a2fSmrg # Restore the value of output. 849234977a2fSmrg output=$save_output 8493ee3138f1Smrg 849434977a2fSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 849534977a2fSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 849634977a2fSmrg test "X$libobjs" = "X " && libobjs= 849734977a2fSmrg fi 849834977a2fSmrg # Expand the library linking commands again to reset the 849934977a2fSmrg # value of $libobjs for piecewise linking. 8500ee3138f1Smrg 850134977a2fSmrg # Do each of the archive commands. 850234977a2fSmrg if test "$module" = yes && test -n "$module_cmds" ; then 850334977a2fSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 850434977a2fSmrg cmds=$module_expsym_cmds 850534977a2fSmrg else 850634977a2fSmrg cmds=$module_cmds 8507ee3138f1Smrg fi 8508ee3138f1Smrg else 850934977a2fSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 851034977a2fSmrg cmds=$archive_expsym_cmds 851134977a2fSmrg else 851234977a2fSmrg cmds=$archive_cmds 851334977a2fSmrg fi 8514ee3138f1Smrg fi 851534977a2fSmrg fi 8516ee3138f1Smrg 851734977a2fSmrg if test -n "$delfiles"; then 851834977a2fSmrg # Append the command to remove temporary files to $cmds. 851934977a2fSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 852034977a2fSmrg fi 8521ee3138f1Smrg 852234977a2fSmrg # Add any objects from preloaded convenience libraries 852334977a2fSmrg if test -n "$dlprefiles"; then 852434977a2fSmrg gentop="$output_objdir/${outputname}x" 85253e72ca8cSmrg func_append generated " $gentop" 8526ee3138f1Smrg 852734977a2fSmrg func_extract_archives $gentop $dlprefiles 85283e72ca8cSmrg func_append libobjs " $func_extract_archives_result" 852934977a2fSmrg test "X$libobjs" = "X " && libobjs= 853034977a2fSmrg fi 8531ee3138f1Smrg 853234977a2fSmrg save_ifs="$IFS"; IFS='~' 853334977a2fSmrg for cmd in $cmds; do 853434977a2fSmrg IFS="$save_ifs" 853534977a2fSmrg eval cmd=\"$cmd\" 853634977a2fSmrg $opt_silent || { 853734977a2fSmrg func_quote_for_expand "$cmd" 853834977a2fSmrg eval "func_echo $func_quote_for_expand_result" 853934977a2fSmrg } 854034977a2fSmrg $opt_dry_run || eval "$cmd" || { 854134977a2fSmrg lt_exit=$? 8542ee3138f1Smrg 854334977a2fSmrg # Restore the uninstalled library and exit 85443e72ca8cSmrg if test "$opt_mode" = relink; then 854534977a2fSmrg ( cd "$output_objdir" && \ 854634977a2fSmrg $RM "${realname}T" && \ 854734977a2fSmrg $MV "${realname}U" "$realname" ) 854834977a2fSmrg fi 8549ee3138f1Smrg 855034977a2fSmrg exit $lt_exit 855134977a2fSmrg } 855234977a2fSmrg done 855334977a2fSmrg IFS="$save_ifs" 8554ee3138f1Smrg 855534977a2fSmrg # Restore the uninstalled library and exit 85563e72ca8cSmrg if test "$opt_mode" = relink; then 855734977a2fSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 8558ee3138f1Smrg 855934977a2fSmrg if test -n "$convenience"; then 856034977a2fSmrg if test -z "$whole_archive_flag_spec"; then 856134977a2fSmrg func_show_eval '${RM}r "$gentop"' 856234977a2fSmrg fi 856334977a2fSmrg fi 8564ee3138f1Smrg 856534977a2fSmrg exit $EXIT_SUCCESS 856634977a2fSmrg fi 856734977a2fSmrg 856834977a2fSmrg # Create links to the real library. 856934977a2fSmrg for linkname in $linknames; do 857034977a2fSmrg if test "$realname" != "$linkname"; then 857134977a2fSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 8572ee3138f1Smrg fi 8573ee3138f1Smrg done 8574ee3138f1Smrg 857534977a2fSmrg # If -module or -export-dynamic was specified, set the dlname. 857634977a2fSmrg if test "$module" = yes || test "$export_dynamic" = yes; then 857734977a2fSmrg # On all known operating systems, these are identical. 857834977a2fSmrg dlname="$soname" 857934977a2fSmrg fi 858034977a2fSmrg fi 8581ee3138f1Smrg ;; 8582ee3138f1Smrg 858334977a2fSmrg obj) 858434977a2fSmrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 858534977a2fSmrg func_warning "\`-dlopen' is ignored for objects" 858634977a2fSmrg fi 8587ee3138f1Smrg 858834977a2fSmrg case " $deplibs" in 858934977a2fSmrg *\ -l* | *\ -L*) 859034977a2fSmrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 8591ee3138f1Smrg esac 8592ee3138f1Smrg 859334977a2fSmrg test -n "$rpath" && \ 859434977a2fSmrg func_warning "\`-rpath' is ignored for objects" 859534977a2fSmrg 859634977a2fSmrg test -n "$xrpath" && \ 859734977a2fSmrg func_warning "\`-R' is ignored for objects" 8598ee3138f1Smrg 859934977a2fSmrg test -n "$vinfo" && \ 860034977a2fSmrg func_warning "\`-version-info' is ignored for objects" 8601ee3138f1Smrg 860234977a2fSmrg test -n "$release" && \ 860334977a2fSmrg func_warning "\`-release' is ignored for objects" 860434977a2fSmrg 860534977a2fSmrg case $output in 860634977a2fSmrg *.lo) 860734977a2fSmrg test -n "$objs$old_deplibs" && \ 860834977a2fSmrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 860934977a2fSmrg 861034977a2fSmrg libobj=$output 861134977a2fSmrg func_lo2o "$libobj" 861234977a2fSmrg obj=$func_lo2o_result 8613ee3138f1Smrg ;; 8614ee3138f1Smrg *) 861534977a2fSmrg libobj= 861634977a2fSmrg obj="$output" 8617ee3138f1Smrg ;; 8618ee3138f1Smrg esac 8619ee3138f1Smrg 862034977a2fSmrg # Delete the old objects. 862134977a2fSmrg $opt_dry_run || $RM $obj $libobj 8622ee3138f1Smrg 862334977a2fSmrg # Objects from convenience libraries. This assumes 862434977a2fSmrg # single-version convenience libraries. Whenever we create 862534977a2fSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 862634977a2fSmrg # the extraction. 862734977a2fSmrg reload_conv_objs= 862834977a2fSmrg gentop= 862934977a2fSmrg # reload_cmds runs $LD directly, so let us get rid of 863034977a2fSmrg # -Wl from whole_archive_flag_spec and hope we can get by with 863134977a2fSmrg # turning comma into space.. 863234977a2fSmrg wl= 8633ee3138f1Smrg 863434977a2fSmrg if test -n "$convenience"; then 863534977a2fSmrg if test -n "$whole_archive_flag_spec"; then 863634977a2fSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 8637b425557eSmrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 863834977a2fSmrg else 863934977a2fSmrg gentop="$output_objdir/${obj}x" 86403e72ca8cSmrg func_append generated " $gentop" 8641ee3138f1Smrg 864234977a2fSmrg func_extract_archives $gentop $convenience 864334977a2fSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 864434977a2fSmrg fi 8645ee3138f1Smrg fi 8646ee3138f1Smrg 86473e72ca8cSmrg # If we're not building shared, we need to use non_pic_objs 86483e72ca8cSmrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 86493e72ca8cSmrg 865034977a2fSmrg # Create the old-style object. 8651b425557eSmrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 8652ee3138f1Smrg 865334977a2fSmrg output="$obj" 865434977a2fSmrg func_execute_cmds "$reload_cmds" 'exit $?' 8655ee3138f1Smrg 865634977a2fSmrg # Exit if we aren't doing a library object file. 865734977a2fSmrg if test -z "$libobj"; then 865834977a2fSmrg if test -n "$gentop"; then 865934977a2fSmrg func_show_eval '${RM}r "$gentop"' 866034977a2fSmrg fi 866134977a2fSmrg 866234977a2fSmrg exit $EXIT_SUCCESS 8663ee3138f1Smrg fi 866434977a2fSmrg 866534977a2fSmrg if test "$build_libtool_libs" != yes; then 866634977a2fSmrg if test -n "$gentop"; then 866734977a2fSmrg func_show_eval '${RM}r "$gentop"' 866834977a2fSmrg fi 866934977a2fSmrg 867034977a2fSmrg # Create an invalid libtool object if no PIC, so that we don't 867134977a2fSmrg # accidentally link it into a program. 867234977a2fSmrg # $show "echo timestamp > $libobj" 867334977a2fSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 867434977a2fSmrg exit $EXIT_SUCCESS 867534977a2fSmrg fi 867634977a2fSmrg 867734977a2fSmrg if test -n "$pic_flag" || test "$pic_mode" != default; then 867834977a2fSmrg # Only do commands if we really have different PIC objects. 867934977a2fSmrg reload_objs="$libobjs $reload_conv_objs" 868034977a2fSmrg output="$libobj" 868134977a2fSmrg func_execute_cmds "$reload_cmds" 'exit $?' 868234977a2fSmrg fi 868334977a2fSmrg 868434977a2fSmrg if test -n "$gentop"; then 868534977a2fSmrg func_show_eval '${RM}r "$gentop"' 868634977a2fSmrg fi 868734977a2fSmrg 868834977a2fSmrg exit $EXIT_SUCCESS 8689ee3138f1Smrg ;; 8690ee3138f1Smrg 869134977a2fSmrg prog) 869234977a2fSmrg case $host in 869334977a2fSmrg *cygwin*) func_stripname '' '.exe' "$output" 869434977a2fSmrg output=$func_stripname_result.exe;; 869534977a2fSmrg esac 869634977a2fSmrg test -n "$vinfo" && \ 869734977a2fSmrg func_warning "\`-version-info' is ignored for programs" 8698ee3138f1Smrg 869934977a2fSmrg test -n "$release" && \ 870034977a2fSmrg func_warning "\`-release' is ignored for programs" 8701ee3138f1Smrg 870234977a2fSmrg test "$preload" = yes \ 870334977a2fSmrg && test "$dlopen_support" = unknown \ 870434977a2fSmrg && test "$dlopen_self" = unknown \ 870534977a2fSmrg && test "$dlopen_self_static" = unknown && \ 870634977a2fSmrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 870734977a2fSmrg 870834977a2fSmrg case $host in 870934977a2fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 871034977a2fSmrg # On Rhapsody replace the C library is the System framework 8711b425557eSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 8712b425557eSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 8713ee3138f1Smrg ;; 871434977a2fSmrg esac 8715ee3138f1Smrg 871634977a2fSmrg case $host in 871734977a2fSmrg *-*-darwin*) 871834977a2fSmrg # Don't allow lazy linking, it breaks C++ global constructors 871934977a2fSmrg # But is supposedly fixed on 10.4 or later (yay!). 872034977a2fSmrg if test "$tagname" = CXX ; then 872134977a2fSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 872234977a2fSmrg 10.[0123]) 87233e72ca8cSmrg func_append compile_command " ${wl}-bind_at_load" 87243e72ca8cSmrg func_append finalize_command " ${wl}-bind_at_load" 872534977a2fSmrg ;; 872634977a2fSmrg esac 8727ee3138f1Smrg fi 872834977a2fSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 8729b425557eSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8730b425557eSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 873134977a2fSmrg ;; 873234977a2fSmrg esac 8733ee3138f1Smrg 8734ee3138f1Smrg 873534977a2fSmrg # move library search paths that coincide with paths to not yet 873634977a2fSmrg # installed libraries to the beginning of the library search list 873734977a2fSmrg new_libs= 873834977a2fSmrg for path in $notinst_path; do 873934977a2fSmrg case " $new_libs " in 874034977a2fSmrg *" -L$path/$objdir "*) ;; 874134977a2fSmrg *) 874234977a2fSmrg case " $compile_deplibs " in 874334977a2fSmrg *" -L$path/$objdir "*) 87443e72ca8cSmrg func_append new_libs " -L$path/$objdir" ;; 8745ee3138f1Smrg esac 874634977a2fSmrg ;; 874734977a2fSmrg esac 874834977a2fSmrg done 874934977a2fSmrg for deplib in $compile_deplibs; do 875034977a2fSmrg case $deplib in 875134977a2fSmrg -L*) 875234977a2fSmrg case " $new_libs " in 875334977a2fSmrg *" $deplib "*) ;; 87543e72ca8cSmrg *) func_append new_libs " $deplib" ;; 8755ee3138f1Smrg esac 875634977a2fSmrg ;; 87573e72ca8cSmrg *) func_append new_libs " $deplib" ;; 875834977a2fSmrg esac 875934977a2fSmrg done 876034977a2fSmrg compile_deplibs="$new_libs" 8761ee3138f1Smrg 8762ee3138f1Smrg 87633e72ca8cSmrg func_append compile_command " $compile_deplibs" 87643e72ca8cSmrg func_append finalize_command " $finalize_deplibs" 8765ee3138f1Smrg 876634977a2fSmrg if test -n "$rpath$xrpath"; then 876734977a2fSmrg # If the user specified any rpath flags, then add them. 876834977a2fSmrg for libdir in $rpath $xrpath; do 876934977a2fSmrg # This is the magic to use -rpath. 877034977a2fSmrg case "$finalize_rpath " in 877134977a2fSmrg *" $libdir "*) ;; 87723e72ca8cSmrg *) func_append finalize_rpath " $libdir" ;; 877334977a2fSmrg esac 877434977a2fSmrg done 877534977a2fSmrg fi 8776ee3138f1Smrg 877734977a2fSmrg # Now hardcode the library paths 877834977a2fSmrg rpath= 877934977a2fSmrg hardcode_libdirs= 878034977a2fSmrg for libdir in $compile_rpath $finalize_rpath; do 878134977a2fSmrg if test -n "$hardcode_libdir_flag_spec"; then 878234977a2fSmrg if test -n "$hardcode_libdir_separator"; then 878334977a2fSmrg if test -z "$hardcode_libdirs"; then 878434977a2fSmrg hardcode_libdirs="$libdir" 878534977a2fSmrg else 878634977a2fSmrg # Just accumulate the unique libdirs. 878734977a2fSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 878834977a2fSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 878934977a2fSmrg ;; 879034977a2fSmrg *) 87913e72ca8cSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 879234977a2fSmrg ;; 879334977a2fSmrg esac 879434977a2fSmrg fi 8795ee3138f1Smrg else 879634977a2fSmrg eval flag=\"$hardcode_libdir_flag_spec\" 87973e72ca8cSmrg func_append rpath " $flag" 8798ee3138f1Smrg fi 879934977a2fSmrg elif test -n "$runpath_var"; then 880034977a2fSmrg case "$perm_rpath " in 880134977a2fSmrg *" $libdir "*) ;; 88023e72ca8cSmrg *) func_append perm_rpath " $libdir" ;; 880334977a2fSmrg esac 880434977a2fSmrg fi 880534977a2fSmrg case $host in 880634977a2fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 880734977a2fSmrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 880834977a2fSmrg case :$dllsearchpath: in 880934977a2fSmrg *":$libdir:"*) ;; 881034977a2fSmrg ::) dllsearchpath=$libdir;; 88113e72ca8cSmrg *) func_append dllsearchpath ":$libdir";; 881234977a2fSmrg esac 881334977a2fSmrg case :$dllsearchpath: in 881434977a2fSmrg *":$testbindir:"*) ;; 881534977a2fSmrg ::) dllsearchpath=$testbindir;; 88163e72ca8cSmrg *) func_append dllsearchpath ":$testbindir";; 881734977a2fSmrg esac 881834977a2fSmrg ;; 881934977a2fSmrg esac 882034977a2fSmrg done 882134977a2fSmrg # Substitute the hardcoded libdirs into the rpath. 882234977a2fSmrg if test -n "$hardcode_libdir_separator" && 882334977a2fSmrg test -n "$hardcode_libdirs"; then 882434977a2fSmrg libdir="$hardcode_libdirs" 882534977a2fSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 882634977a2fSmrg fi 882734977a2fSmrg compile_rpath="$rpath" 8828ee3138f1Smrg 882934977a2fSmrg rpath= 883034977a2fSmrg hardcode_libdirs= 883134977a2fSmrg for libdir in $finalize_rpath; do 883234977a2fSmrg if test -n "$hardcode_libdir_flag_spec"; then 883334977a2fSmrg if test -n "$hardcode_libdir_separator"; then 883434977a2fSmrg if test -z "$hardcode_libdirs"; then 883534977a2fSmrg hardcode_libdirs="$libdir" 883634977a2fSmrg else 883734977a2fSmrg # Just accumulate the unique libdirs. 883834977a2fSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 883934977a2fSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 884034977a2fSmrg ;; 884134977a2fSmrg *) 88423e72ca8cSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 884334977a2fSmrg ;; 884434977a2fSmrg esac 884534977a2fSmrg fi 8846ee3138f1Smrg else 884734977a2fSmrg eval flag=\"$hardcode_libdir_flag_spec\" 88483e72ca8cSmrg func_append rpath " $flag" 8849ee3138f1Smrg fi 885034977a2fSmrg elif test -n "$runpath_var"; then 885134977a2fSmrg case "$finalize_perm_rpath " in 885234977a2fSmrg *" $libdir "*) ;; 88533e72ca8cSmrg *) func_append finalize_perm_rpath " $libdir" ;; 885434977a2fSmrg esac 8855ee3138f1Smrg fi 885634977a2fSmrg done 885734977a2fSmrg # Substitute the hardcoded libdirs into the rpath. 885834977a2fSmrg if test -n "$hardcode_libdir_separator" && 885934977a2fSmrg test -n "$hardcode_libdirs"; then 886034977a2fSmrg libdir="$hardcode_libdirs" 886134977a2fSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 886234977a2fSmrg fi 886334977a2fSmrg finalize_rpath="$rpath" 8864ee3138f1Smrg 886534977a2fSmrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 886634977a2fSmrg # Transform all the library objects into standard objects. 8867b425557eSmrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8868b425557eSmrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 886934977a2fSmrg fi 8870ee3138f1Smrg 887134977a2fSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8872ee3138f1Smrg 887334977a2fSmrg # template prelinking step 887434977a2fSmrg if test -n "$prelink_cmds"; then 887534977a2fSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 887634977a2fSmrg fi 8877ee3138f1Smrg 887834977a2fSmrg wrappers_required=yes 887934977a2fSmrg case $host in 8880b425557eSmrg *cegcc* | *mingw32ce*) 8881b425557eSmrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 8882b425557eSmrg wrappers_required=no 8883b425557eSmrg ;; 888434977a2fSmrg *cygwin* | *mingw* ) 888534977a2fSmrg if test "$build_libtool_libs" != yes; then 888634977a2fSmrg wrappers_required=no 888734977a2fSmrg fi 888834977a2fSmrg ;; 888934977a2fSmrg *) 889034977a2fSmrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 889134977a2fSmrg wrappers_required=no 889234977a2fSmrg fi 889334977a2fSmrg ;; 889434977a2fSmrg esac 889534977a2fSmrg if test "$wrappers_required" = no; then 889634977a2fSmrg # Replace the output file specification. 8897b425557eSmrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 889834977a2fSmrg link_command="$compile_command$compile_rpath" 8899ee3138f1Smrg 890034977a2fSmrg # We have no uninstalled library dependencies, so finalize right now. 890134977a2fSmrg exit_status=0 890234977a2fSmrg func_show_eval "$link_command" 'exit_status=$?' 8903ee3138f1Smrg 89043e72ca8cSmrg if test -n "$postlink_cmds"; then 89053e72ca8cSmrg func_to_tool_file "$output" 89063e72ca8cSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 89073e72ca8cSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 89083e72ca8cSmrg fi 89093e72ca8cSmrg 891034977a2fSmrg # Delete the generated files. 891134977a2fSmrg if test -f "$output_objdir/${outputname}S.${objext}"; then 891234977a2fSmrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 8913ee3138f1Smrg fi 8914ee3138f1Smrg 891534977a2fSmrg exit $exit_status 891634977a2fSmrg fi 8917ee3138f1Smrg 891834977a2fSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 891934977a2fSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 892034977a2fSmrg fi 892134977a2fSmrg if test -n "$finalize_shlibpath"; then 892234977a2fSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 892334977a2fSmrg fi 8924ee3138f1Smrg 892534977a2fSmrg compile_var= 892634977a2fSmrg finalize_var= 892734977a2fSmrg if test -n "$runpath_var"; then 892834977a2fSmrg if test -n "$perm_rpath"; then 892934977a2fSmrg # We should set the runpath_var. 893034977a2fSmrg rpath= 893134977a2fSmrg for dir in $perm_rpath; do 89323e72ca8cSmrg func_append rpath "$dir:" 893334977a2fSmrg done 893434977a2fSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8935ee3138f1Smrg fi 893634977a2fSmrg if test -n "$finalize_perm_rpath"; then 893734977a2fSmrg # We should set the runpath_var. 893834977a2fSmrg rpath= 893934977a2fSmrg for dir in $finalize_perm_rpath; do 89403e72ca8cSmrg func_append rpath "$dir:" 894134977a2fSmrg done 894234977a2fSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 8943ee3138f1Smrg fi 894434977a2fSmrg fi 8945ee3138f1Smrg 894634977a2fSmrg if test "$no_install" = yes; then 894734977a2fSmrg # We don't need to create a wrapper script. 894834977a2fSmrg link_command="$compile_var$compile_command$compile_rpath" 894934977a2fSmrg # Replace the output file specification. 8950b425557eSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 895134977a2fSmrg # Delete the old output file. 895234977a2fSmrg $opt_dry_run || $RM $output 895334977a2fSmrg # Link the executable and exit 895434977a2fSmrg func_show_eval "$link_command" 'exit $?' 89553e72ca8cSmrg 89563e72ca8cSmrg if test -n "$postlink_cmds"; then 89573e72ca8cSmrg func_to_tool_file "$output" 89583e72ca8cSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 89593e72ca8cSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 89603e72ca8cSmrg fi 89613e72ca8cSmrg 8962ee3138f1Smrg exit $EXIT_SUCCESS 896334977a2fSmrg fi 8964ee3138f1Smrg 896534977a2fSmrg if test "$hardcode_action" = relink; then 896634977a2fSmrg # Fast installation is not supported 896734977a2fSmrg link_command="$compile_var$compile_command$compile_rpath" 896834977a2fSmrg relink_command="$finalize_var$finalize_command$finalize_rpath" 896934977a2fSmrg 897034977a2fSmrg func_warning "this platform does not like uninstalled shared libraries" 897134977a2fSmrg func_warning "\`$output' will be relinked during installation" 897234977a2fSmrg else 897334977a2fSmrg if test "$fast_install" != no; then 897434977a2fSmrg link_command="$finalize_var$compile_command$finalize_rpath" 897534977a2fSmrg if test "$fast_install" = yes; then 8976b425557eSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 897734977a2fSmrg else 897834977a2fSmrg # fast_install is set to needless 897934977a2fSmrg relink_command= 898034977a2fSmrg fi 8981ee3138f1Smrg else 898234977a2fSmrg link_command="$compile_var$compile_command$compile_rpath" 898334977a2fSmrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8984ee3138f1Smrg fi 898534977a2fSmrg fi 8986ee3138f1Smrg 898734977a2fSmrg # Replace the output file specification. 8988b425557eSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 8989ee3138f1Smrg 899034977a2fSmrg # Delete the old output files. 899134977a2fSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 8992ee3138f1Smrg 899334977a2fSmrg func_show_eval "$link_command" 'exit $?' 8994ee3138f1Smrg 89953e72ca8cSmrg if test -n "$postlink_cmds"; then 89963e72ca8cSmrg func_to_tool_file "$output_objdir/$outputname" 89973e72ca8cSmrg 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'` 89983e72ca8cSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 89993e72ca8cSmrg fi 90003e72ca8cSmrg 900134977a2fSmrg # Now create the wrapper script. 900234977a2fSmrg func_verbose "creating $output" 9003ee3138f1Smrg 900434977a2fSmrg # Quote the relink command for shipping. 900534977a2fSmrg if test -n "$relink_command"; then 900634977a2fSmrg # Preserve any variables that may affect compiler behavior 900734977a2fSmrg for var in $variables_saved_for_relink; do 900834977a2fSmrg if eval test -z \"\${$var+set}\"; then 900934977a2fSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 901034977a2fSmrg elif eval var_value=\$$var; test -z "$var_value"; then 901134977a2fSmrg relink_command="$var=; export $var; $relink_command" 9012ee3138f1Smrg else 901334977a2fSmrg func_quote_for_eval "$var_value" 901434977a2fSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9015ee3138f1Smrg fi 901634977a2fSmrg done 901734977a2fSmrg relink_command="(cd `pwd`; $relink_command)" 9018b425557eSmrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 901934977a2fSmrg fi 902034977a2fSmrg 902134977a2fSmrg # Only actually do things if not in dry run mode. 902234977a2fSmrg $opt_dry_run || { 902334977a2fSmrg # win32 will think the script is a binary if it has 902434977a2fSmrg # a .exe suffix, so we strip it off here. 902534977a2fSmrg case $output in 902634977a2fSmrg *.exe) func_stripname '' '.exe' "$output" 902734977a2fSmrg output=$func_stripname_result ;; 902834977a2fSmrg esac 902934977a2fSmrg # test for cygwin because mv fails w/o .exe extensions 903034977a2fSmrg case $host in 903134977a2fSmrg *cygwin*) 903234977a2fSmrg exeext=.exe 903334977a2fSmrg func_stripname '' '.exe' "$outputname" 903434977a2fSmrg outputname=$func_stripname_result ;; 903534977a2fSmrg *) exeext= ;; 9036ee3138f1Smrg esac 903734977a2fSmrg case $host in 903834977a2fSmrg *cygwin* | *mingw* ) 903934977a2fSmrg func_dirname_and_basename "$output" "" "." 904034977a2fSmrg output_name=$func_basename_result 904134977a2fSmrg output_path=$func_dirname_result 904234977a2fSmrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 904334977a2fSmrg cwrapper="$output_path/$output_name.exe" 904434977a2fSmrg $RM $cwrappersource $cwrapper 904534977a2fSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 904634977a2fSmrg 904734977a2fSmrg func_emit_cwrapperexe_src > $cwrappersource 904834977a2fSmrg 904934977a2fSmrg # The wrapper executable is built using the $host compiler, 905034977a2fSmrg # because it contains $host paths and files. If cross- 905134977a2fSmrg # compiling, it, like the target executable, must be 905234977a2fSmrg # executed on the $host or under an emulation environment. 905334977a2fSmrg $opt_dry_run || { 905434977a2fSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 905534977a2fSmrg $STRIP $cwrapper 905634977a2fSmrg } 9057ee3138f1Smrg 905834977a2fSmrg # Now, create the wrapper script for func_source use: 905934977a2fSmrg func_ltwrapper_scriptname $cwrapper 906034977a2fSmrg $RM $func_ltwrapper_scriptname_result 906134977a2fSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 906234977a2fSmrg $opt_dry_run || { 906334977a2fSmrg # note: this script will not be executed, so do not chmod. 906434977a2fSmrg if test "x$build" = "x$host" ; then 906534977a2fSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 906634977a2fSmrg else 906734977a2fSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 906834977a2fSmrg fi 906934977a2fSmrg } 907034977a2fSmrg ;; 907134977a2fSmrg * ) 907234977a2fSmrg $RM $output 907334977a2fSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 9074ee3138f1Smrg 907534977a2fSmrg func_emit_wrapper no > $output 907634977a2fSmrg chmod +x $output 907734977a2fSmrg ;; 907834977a2fSmrg esac 907934977a2fSmrg } 908034977a2fSmrg exit $EXIT_SUCCESS 908134977a2fSmrg ;; 908234977a2fSmrg esac 9083ee3138f1Smrg 908434977a2fSmrg # See if we need to build an old-fashioned archive. 908534977a2fSmrg for oldlib in $oldlibs; do 9086ee3138f1Smrg 908734977a2fSmrg if test "$build_libtool_libs" = convenience; then 908834977a2fSmrg oldobjs="$libobjs_save $symfileobj" 908934977a2fSmrg addlibs="$convenience" 909034977a2fSmrg build_libtool_libs=no 909134977a2fSmrg else 909234977a2fSmrg if test "$build_libtool_libs" = module; then 909334977a2fSmrg oldobjs="$libobjs_save" 909434977a2fSmrg build_libtool_libs=no 909534977a2fSmrg else 909634977a2fSmrg oldobjs="$old_deplibs $non_pic_objects" 909734977a2fSmrg if test "$preload" = yes && test -f "$symfileobj"; then 90983e72ca8cSmrg func_append oldobjs " $symfileobj" 909934977a2fSmrg fi 910034977a2fSmrg fi 910134977a2fSmrg addlibs="$old_convenience" 9102ee3138f1Smrg fi 9103ee3138f1Smrg 910434977a2fSmrg if test -n "$addlibs"; then 910534977a2fSmrg gentop="$output_objdir/${outputname}x" 91063e72ca8cSmrg func_append generated " $gentop" 9107ee3138f1Smrg 910834977a2fSmrg func_extract_archives $gentop $addlibs 91093e72ca8cSmrg func_append oldobjs " $func_extract_archives_result" 911034977a2fSmrg fi 9111ee3138f1Smrg 911234977a2fSmrg # Do each command in the archive commands. 911334977a2fSmrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 911434977a2fSmrg cmds=$old_archive_from_new_cmds 911534977a2fSmrg else 9116ee3138f1Smrg 911734977a2fSmrg # Add any objects from preloaded convenience libraries 911834977a2fSmrg if test -n "$dlprefiles"; then 911934977a2fSmrg gentop="$output_objdir/${outputname}x" 91203e72ca8cSmrg func_append generated " $gentop" 9121ee3138f1Smrg 912234977a2fSmrg func_extract_archives $gentop $dlprefiles 91233e72ca8cSmrg func_append oldobjs " $func_extract_archives_result" 912434977a2fSmrg fi 9125ee3138f1Smrg 912634977a2fSmrg # POSIX demands no paths to be encoded in archives. We have 912734977a2fSmrg # to avoid creating archives with duplicate basenames if we 912834977a2fSmrg # might have to extract them afterwards, e.g., when creating a 912934977a2fSmrg # static archive out of a convenience library, or when linking 913034977a2fSmrg # the entirety of a libtool archive into another (currently 913134977a2fSmrg # not supported by libtool). 913234977a2fSmrg if (for obj in $oldobjs 913334977a2fSmrg do 913434977a2fSmrg func_basename "$obj" 913534977a2fSmrg $ECHO "$func_basename_result" 913634977a2fSmrg done | sort | sort -uc >/dev/null 2>&1); then 913734977a2fSmrg : 913834977a2fSmrg else 9139b425557eSmrg echo "copying selected object files to avoid basename conflicts..." 914034977a2fSmrg gentop="$output_objdir/${outputname}x" 91413e72ca8cSmrg func_append generated " $gentop" 914234977a2fSmrg func_mkdir_p "$gentop" 914334977a2fSmrg save_oldobjs=$oldobjs 914434977a2fSmrg oldobjs= 914534977a2fSmrg counter=1 914634977a2fSmrg for obj in $save_oldobjs 914734977a2fSmrg do 914834977a2fSmrg func_basename "$obj" 914934977a2fSmrg objbase="$func_basename_result" 915034977a2fSmrg case " $oldobjs " in 915134977a2fSmrg " ") oldobjs=$obj ;; 915234977a2fSmrg *[\ /]"$objbase "*) 915334977a2fSmrg while :; do 915434977a2fSmrg # Make sure we don't pick an alternate name that also 915534977a2fSmrg # overlaps. 915634977a2fSmrg newobj=lt$counter-$objbase 915734977a2fSmrg func_arith $counter + 1 915834977a2fSmrg counter=$func_arith_result 915934977a2fSmrg case " $oldobjs " in 916034977a2fSmrg *[\ /]"$newobj "*) ;; 916134977a2fSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 916234977a2fSmrg esac 916334977a2fSmrg done 916434977a2fSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 91653e72ca8cSmrg func_append oldobjs " $gentop/$newobj" 916634977a2fSmrg ;; 91673e72ca8cSmrg *) func_append oldobjs " $obj" ;; 916834977a2fSmrg esac 9169ee3138f1Smrg done 9170ee3138f1Smrg fi 91713e72ca8cSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 91723e72ca8cSmrg tool_oldlib=$func_to_tool_file_result 917334977a2fSmrg eval cmds=\"$old_archive_cmds\" 9174ee3138f1Smrg 917534977a2fSmrg func_len " $cmds" 917634977a2fSmrg len=$func_len_result 917734977a2fSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 917834977a2fSmrg cmds=$old_archive_cmds 91793e72ca8cSmrg elif test -n "$archiver_list_spec"; then 91803e72ca8cSmrg func_verbose "using command file archive linking..." 91813e72ca8cSmrg for obj in $oldobjs 91823e72ca8cSmrg do 91833e72ca8cSmrg func_to_tool_file "$obj" 91843e72ca8cSmrg $ECHO "$func_to_tool_file_result" 91853e72ca8cSmrg done > $output_objdir/$libname.libcmd 91863e72ca8cSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 91873e72ca8cSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 91883e72ca8cSmrg cmds=$old_archive_cmds 918934977a2fSmrg else 919034977a2fSmrg # the command line is too long to link in one step, link in parts 919134977a2fSmrg func_verbose "using piecewise archive linking..." 919234977a2fSmrg save_RANLIB=$RANLIB 919334977a2fSmrg RANLIB=: 919434977a2fSmrg objlist= 919534977a2fSmrg concat_cmds= 919634977a2fSmrg save_oldobjs=$oldobjs 919734977a2fSmrg oldobjs= 919834977a2fSmrg # Is there a better way of finding the last object in the list? 919934977a2fSmrg for obj in $save_oldobjs 920034977a2fSmrg do 920134977a2fSmrg last_oldobj=$obj 920234977a2fSmrg done 920334977a2fSmrg eval test_cmds=\"$old_archive_cmds\" 920434977a2fSmrg func_len " $test_cmds" 920534977a2fSmrg len0=$func_len_result 920634977a2fSmrg len=$len0 920734977a2fSmrg for obj in $save_oldobjs 920834977a2fSmrg do 920934977a2fSmrg func_len " $obj" 921034977a2fSmrg func_arith $len + $func_len_result 921134977a2fSmrg len=$func_arith_result 921234977a2fSmrg func_append objlist " $obj" 921334977a2fSmrg if test "$len" -lt "$max_cmd_len"; then 921434977a2fSmrg : 921534977a2fSmrg else 921634977a2fSmrg # the above command should be used before it gets too long 921734977a2fSmrg oldobjs=$objlist 921834977a2fSmrg if test "$obj" = "$last_oldobj" ; then 921934977a2fSmrg RANLIB=$save_RANLIB 922034977a2fSmrg fi 922134977a2fSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 922234977a2fSmrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 922334977a2fSmrg objlist= 922434977a2fSmrg len=$len0 922534977a2fSmrg fi 922634977a2fSmrg done 922734977a2fSmrg RANLIB=$save_RANLIB 922834977a2fSmrg oldobjs=$objlist 922934977a2fSmrg if test "X$oldobjs" = "X" ; then 923034977a2fSmrg eval cmds=\"\$concat_cmds\" 923134977a2fSmrg else 923234977a2fSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 923334977a2fSmrg fi 923434977a2fSmrg fi 923534977a2fSmrg fi 923634977a2fSmrg func_execute_cmds "$cmds" 'exit $?' 9237ee3138f1Smrg done 9238ee3138f1Smrg 923934977a2fSmrg test -n "$generated" && \ 924034977a2fSmrg func_show_eval "${RM}r$generated" 9241ee3138f1Smrg 924234977a2fSmrg # Now create the libtool archive. 924334977a2fSmrg case $output in 924434977a2fSmrg *.la) 924534977a2fSmrg old_library= 924634977a2fSmrg test "$build_old_libs" = yes && old_library="$libname.$libext" 924734977a2fSmrg func_verbose "creating $output" 9248ee3138f1Smrg 924934977a2fSmrg # Preserve any variables that may affect compiler behavior 925034977a2fSmrg for var in $variables_saved_for_relink; do 925134977a2fSmrg if eval test -z \"\${$var+set}\"; then 925234977a2fSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 925334977a2fSmrg elif eval var_value=\$$var; test -z "$var_value"; then 925434977a2fSmrg relink_command="$var=; export $var; $relink_command" 9255ee3138f1Smrg else 925634977a2fSmrg func_quote_for_eval "$var_value" 925734977a2fSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9258ee3138f1Smrg fi 925934977a2fSmrg done 926034977a2fSmrg # Quote the link command for shipping. 926134977a2fSmrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 9262b425557eSmrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 926334977a2fSmrg if test "$hardcode_automatic" = yes ; then 926434977a2fSmrg relink_command= 926534977a2fSmrg fi 9266ee3138f1Smrg 926734977a2fSmrg # Only create the output if not a dry run. 926834977a2fSmrg $opt_dry_run || { 926934977a2fSmrg for installed in no yes; do 927034977a2fSmrg if test "$installed" = yes; then 927134977a2fSmrg if test -z "$install_libdir"; then 927234977a2fSmrg break 927334977a2fSmrg fi 927434977a2fSmrg output="$output_objdir/$outputname"i 927534977a2fSmrg # Replace all uninstalled libtool libraries with the installed ones 927634977a2fSmrg newdependency_libs= 927734977a2fSmrg for deplib in $dependency_libs; do 927834977a2fSmrg case $deplib in 927934977a2fSmrg *.la) 928034977a2fSmrg func_basename "$deplib" 928134977a2fSmrg name="$func_basename_result" 92823e72ca8cSmrg func_resolve_sysroot "$deplib" 92833e72ca8cSmrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 928434977a2fSmrg test -z "$libdir" && \ 928534977a2fSmrg func_fatal_error "\`$deplib' is not a valid libtool archive" 92863e72ca8cSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 92873e72ca8cSmrg ;; 92883e72ca8cSmrg -L*) 92893e72ca8cSmrg func_stripname -L '' "$deplib" 92903e72ca8cSmrg func_replace_sysroot "$func_stripname_result" 92913e72ca8cSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 92923e72ca8cSmrg ;; 92933e72ca8cSmrg -R*) 92943e72ca8cSmrg func_stripname -R '' "$deplib" 92953e72ca8cSmrg func_replace_sysroot "$func_stripname_result" 92963e72ca8cSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 929734977a2fSmrg ;; 92983e72ca8cSmrg *) func_append newdependency_libs " $deplib" ;; 929934977a2fSmrg esac 930034977a2fSmrg done 930134977a2fSmrg dependency_libs="$newdependency_libs" 930234977a2fSmrg newdlfiles= 930334977a2fSmrg 930434977a2fSmrg for lib in $dlfiles; do 930534977a2fSmrg case $lib in 930634977a2fSmrg *.la) 930734977a2fSmrg func_basename "$lib" 930834977a2fSmrg name="$func_basename_result" 930934977a2fSmrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 931034977a2fSmrg test -z "$libdir" && \ 931134977a2fSmrg func_fatal_error "\`$lib' is not a valid libtool archive" 93123e72ca8cSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 931334977a2fSmrg ;; 93143e72ca8cSmrg *) func_append newdlfiles " $lib" ;; 931534977a2fSmrg esac 931634977a2fSmrg done 931734977a2fSmrg dlfiles="$newdlfiles" 931834977a2fSmrg newdlprefiles= 931934977a2fSmrg for lib in $dlprefiles; do 932034977a2fSmrg case $lib in 932134977a2fSmrg *.la) 932234977a2fSmrg # Only pass preopened files to the pseudo-archive (for 932334977a2fSmrg # eventual linking with the app. that links it) if we 932434977a2fSmrg # didn't already link the preopened objects directly into 932534977a2fSmrg # the library: 932634977a2fSmrg func_basename "$lib" 932734977a2fSmrg name="$func_basename_result" 932834977a2fSmrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 932934977a2fSmrg test -z "$libdir" && \ 933034977a2fSmrg func_fatal_error "\`$lib' is not a valid libtool archive" 93313e72ca8cSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 933234977a2fSmrg ;; 933334977a2fSmrg esac 933434977a2fSmrg done 933534977a2fSmrg dlprefiles="$newdlprefiles" 933634977a2fSmrg else 933734977a2fSmrg newdlfiles= 933834977a2fSmrg for lib in $dlfiles; do 933934977a2fSmrg case $lib in 934034977a2fSmrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 934134977a2fSmrg *) abs=`pwd`"/$lib" ;; 934234977a2fSmrg esac 93433e72ca8cSmrg func_append newdlfiles " $abs" 934434977a2fSmrg done 934534977a2fSmrg dlfiles="$newdlfiles" 934634977a2fSmrg newdlprefiles= 934734977a2fSmrg for lib in $dlprefiles; do 934834977a2fSmrg case $lib in 934934977a2fSmrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 935034977a2fSmrg *) abs=`pwd`"/$lib" ;; 935134977a2fSmrg esac 93523e72ca8cSmrg func_append newdlprefiles " $abs" 935334977a2fSmrg done 935434977a2fSmrg dlprefiles="$newdlprefiles" 935534977a2fSmrg fi 935634977a2fSmrg $RM $output 935734977a2fSmrg # place dlname in correct position for cygwin 9358b425557eSmrg # In fact, it would be nice if we could use this code for all target 9359b425557eSmrg # systems that can't hard-code library paths into their executables 9360b425557eSmrg # and that have no shared library path variable independent of PATH, 9361b425557eSmrg # but it turns out we can't easily determine that from inspecting 9362b425557eSmrg # libtool variables, so we have to hard-code the OSs to which it 9363b425557eSmrg # applies here; at the moment, that means platforms that use the PE 9364b425557eSmrg # object format with DLL files. See the long comment at the top of 9365b425557eSmrg # tests/bindir.at for full details. 936634977a2fSmrg tdlname=$dlname 936734977a2fSmrg case $host,$output,$installed,$module,$dlname in 9368b425557eSmrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 9369b425557eSmrg # If a -bindir argument was supplied, place the dll there. 9370b425557eSmrg if test "x$bindir" != x ; 9371b425557eSmrg then 9372b425557eSmrg func_relative_path "$install_libdir" "$bindir" 9373b425557eSmrg tdlname=$func_relative_path_result$dlname 9374b425557eSmrg else 9375b425557eSmrg # Otherwise fall back on heuristic. 9376b425557eSmrg tdlname=../bin/$dlname 9377b425557eSmrg fi 9378b425557eSmrg ;; 937934977a2fSmrg esac 938034977a2fSmrg $ECHO > $output "\ 938134977a2fSmrg# $outputname - a libtool library file 938234977a2fSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 938334977a2fSmrg# 938434977a2fSmrg# Please DO NOT delete this file! 938534977a2fSmrg# It is necessary for linking the library. 9386ee3138f1Smrg 938734977a2fSmrg# The name that we can dlopen(3). 938834977a2fSmrgdlname='$tdlname' 9389ee3138f1Smrg 939034977a2fSmrg# Names of this library. 939134977a2fSmrglibrary_names='$library_names' 9392ee3138f1Smrg 939334977a2fSmrg# The name of the static archive. 939434977a2fSmrgold_library='$old_library' 9395ee3138f1Smrg 939634977a2fSmrg# Linker flags that can not go in dependency_libs. 939734977a2fSmrginherited_linker_flags='$new_inherited_linker_flags' 9398ee3138f1Smrg 939934977a2fSmrg# Libraries that this one depends upon. 940034977a2fSmrgdependency_libs='$dependency_libs' 9401ee3138f1Smrg 940234977a2fSmrg# Names of additional weak libraries provided by this library 940334977a2fSmrgweak_library_names='$weak_libs' 9404ee3138f1Smrg 940534977a2fSmrg# Version information for $libname. 940634977a2fSmrgcurrent=$current 940734977a2fSmrgage=$age 940834977a2fSmrgrevision=$revision 9409ee3138f1Smrg 941034977a2fSmrg# Is this an already installed library? 941134977a2fSmrginstalled=$installed 9412ee3138f1Smrg 941334977a2fSmrg# Should we warn about portability when linking against -modules? 941434977a2fSmrgshouldnotlink=$module 9415ee3138f1Smrg 941634977a2fSmrg# Files to dlopen/dlpreopen 941734977a2fSmrgdlopen='$dlfiles' 941834977a2fSmrgdlpreopen='$dlprefiles' 9419ee3138f1Smrg 942034977a2fSmrg# Directory that this library needs to be installed in: 942134977a2fSmrglibdir='$install_libdir'" 942234977a2fSmrg if test "$installed" = no && test "$need_relink" = yes; then 942334977a2fSmrg $ECHO >> $output "\ 942434977a2fSmrgrelink_command=\"$relink_command\"" 942534977a2fSmrg fi 942634977a2fSmrg done 942734977a2fSmrg } 9428ee3138f1Smrg 942934977a2fSmrg # Do a symbolic link so that the libtool archive can be found in 943034977a2fSmrg # LD_LIBRARY_PATH before the program is installed. 943134977a2fSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 943234977a2fSmrg ;; 943334977a2fSmrg esac 943434977a2fSmrg exit $EXIT_SUCCESS 943534977a2fSmrg} 9436ee3138f1Smrg 94373e72ca8cSmrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 943834977a2fSmrg func_mode_link ${1+"$@"} 9439ee3138f1Smrg 9440ee3138f1Smrg 944134977a2fSmrg# func_mode_uninstall arg... 944234977a2fSmrgfunc_mode_uninstall () 944334977a2fSmrg{ 944434977a2fSmrg $opt_debug 944534977a2fSmrg RM="$nonopt" 9446ee3138f1Smrg files= 9447ee3138f1Smrg rmforce= 9448ee3138f1Smrg exit_status=0 9449ee3138f1Smrg 9450ee3138f1Smrg # This variable tells wrapper scripts just to set variables rather 9451ee3138f1Smrg # than running their programs. 9452ee3138f1Smrg libtool_install_magic="$magic" 9453ee3138f1Smrg 9454ee3138f1Smrg for arg 9455ee3138f1Smrg do 9456ee3138f1Smrg case $arg in 94573e72ca8cSmrg -f) func_append RM " $arg"; rmforce=yes ;; 94583e72ca8cSmrg -*) func_append RM " $arg" ;; 94593e72ca8cSmrg *) func_append files " $arg" ;; 9460ee3138f1Smrg esac 9461ee3138f1Smrg done 9462ee3138f1Smrg 946334977a2fSmrg test -z "$RM" && \ 946434977a2fSmrg func_fatal_help "you must specify an RM program" 9465ee3138f1Smrg 9466ee3138f1Smrg rmdirs= 9467ee3138f1Smrg 9468ee3138f1Smrg for file in $files; do 946934977a2fSmrg func_dirname "$file" "" "." 947034977a2fSmrg dir="$func_dirname_result" 947134977a2fSmrg if test "X$dir" = X.; then 94723e72ca8cSmrg odir="$objdir" 9473ee3138f1Smrg else 94743e72ca8cSmrg odir="$dir/$objdir" 9475ee3138f1Smrg fi 947634977a2fSmrg func_basename "$file" 947734977a2fSmrg name="$func_basename_result" 94783e72ca8cSmrg test "$opt_mode" = uninstall && odir="$dir" 9479ee3138f1Smrg 94803e72ca8cSmrg # Remember odir for removal later, being careful to avoid duplicates 94813e72ca8cSmrg if test "$opt_mode" = clean; then 9482ee3138f1Smrg case " $rmdirs " in 94833e72ca8cSmrg *" $odir "*) ;; 94843e72ca8cSmrg *) func_append rmdirs " $odir" ;; 9485ee3138f1Smrg esac 9486ee3138f1Smrg fi 9487ee3138f1Smrg 9488ee3138f1Smrg # Don't error if the file doesn't exist and rm -f was used. 948934977a2fSmrg if { test -L "$file"; } >/dev/null 2>&1 || 949034977a2fSmrg { test -h "$file"; } >/dev/null 2>&1 || 949134977a2fSmrg test -f "$file"; then 9492ee3138f1Smrg : 9493ee3138f1Smrg elif test -d "$file"; then 9494ee3138f1Smrg exit_status=1 9495ee3138f1Smrg continue 9496ee3138f1Smrg elif test "$rmforce" = yes; then 9497ee3138f1Smrg continue 9498ee3138f1Smrg fi 9499ee3138f1Smrg 9500ee3138f1Smrg rmfiles="$file" 9501ee3138f1Smrg 9502ee3138f1Smrg case $name in 9503ee3138f1Smrg *.la) 9504ee3138f1Smrg # Possibly a libtool archive, so verify it. 950534977a2fSmrg if func_lalib_p "$file"; then 950634977a2fSmrg func_source $dir/$name 9507ee3138f1Smrg 9508ee3138f1Smrg # Delete the libtool libraries and symlinks. 9509ee3138f1Smrg for n in $library_names; do 95103e72ca8cSmrg func_append rmfiles " $odir/$n" 9511ee3138f1Smrg done 95123e72ca8cSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 9513ee3138f1Smrg 95143e72ca8cSmrg case "$opt_mode" in 9515ee3138f1Smrg clean) 95163e72ca8cSmrg case " $library_names " in 9517ee3138f1Smrg *" $dlname "*) ;; 95183e72ca8cSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 9519ee3138f1Smrg esac 95203e72ca8cSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 9521ee3138f1Smrg ;; 9522ee3138f1Smrg uninstall) 9523ee3138f1Smrg if test -n "$library_names"; then 9524ee3138f1Smrg # Do each command in the postuninstall commands. 952534977a2fSmrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9526ee3138f1Smrg fi 9527ee3138f1Smrg 9528ee3138f1Smrg if test -n "$old_library"; then 9529ee3138f1Smrg # Do each command in the old_postuninstall commands. 953034977a2fSmrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9531ee3138f1Smrg fi 9532ee3138f1Smrg # FIXME: should reinstall the best remaining shared library. 9533ee3138f1Smrg ;; 9534ee3138f1Smrg esac 9535ee3138f1Smrg fi 9536ee3138f1Smrg ;; 9537ee3138f1Smrg 9538ee3138f1Smrg *.lo) 9539ee3138f1Smrg # Possibly a libtool object, so verify it. 954034977a2fSmrg if func_lalib_p "$file"; then 9541ee3138f1Smrg 9542ee3138f1Smrg # Read the .lo file 954334977a2fSmrg func_source $dir/$name 9544ee3138f1Smrg 9545ee3138f1Smrg # Add PIC object to the list of files to remove. 954634977a2fSmrg if test -n "$pic_object" && 954734977a2fSmrg test "$pic_object" != none; then 95483e72ca8cSmrg func_append rmfiles " $dir/$pic_object" 9549ee3138f1Smrg fi 9550ee3138f1Smrg 9551ee3138f1Smrg # Add non-PIC object to the list of files to remove. 955234977a2fSmrg if test -n "$non_pic_object" && 955334977a2fSmrg test "$non_pic_object" != none; then 95543e72ca8cSmrg func_append rmfiles " $dir/$non_pic_object" 9555ee3138f1Smrg fi 9556ee3138f1Smrg fi 9557ee3138f1Smrg ;; 9558ee3138f1Smrg 9559ee3138f1Smrg *) 95603e72ca8cSmrg if test "$opt_mode" = clean ; then 9561ee3138f1Smrg noexename=$name 9562ee3138f1Smrg case $file in 9563ee3138f1Smrg *.exe) 956434977a2fSmrg func_stripname '' '.exe' "$file" 956534977a2fSmrg file=$func_stripname_result 956634977a2fSmrg func_stripname '' '.exe' "$name" 956734977a2fSmrg noexename=$func_stripname_result 9568ee3138f1Smrg # $file with .exe has already been added to rmfiles, 9569ee3138f1Smrg # add $file without .exe 95703e72ca8cSmrg func_append rmfiles " $file" 9571ee3138f1Smrg ;; 9572ee3138f1Smrg esac 9573ee3138f1Smrg # Do a test to see if this is a libtool program. 957434977a2fSmrg if func_ltwrapper_p "$file"; then 957534977a2fSmrg if func_ltwrapper_executable_p "$file"; then 957634977a2fSmrg func_ltwrapper_scriptname "$file" 957734977a2fSmrg relink_command= 957834977a2fSmrg func_source $func_ltwrapper_scriptname_result 95793e72ca8cSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 958034977a2fSmrg else 958134977a2fSmrg relink_command= 958234977a2fSmrg func_source $dir/$noexename 958334977a2fSmrg fi 9584ee3138f1Smrg 9585ee3138f1Smrg # note $name still contains .exe if it was in $file originally 9586ee3138f1Smrg # as does the version of $file that was added into $rmfiles 95873e72ca8cSmrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9588ee3138f1Smrg if test "$fast_install" = yes && test -n "$relink_command"; then 95893e72ca8cSmrg func_append rmfiles " $odir/lt-$name" 9590ee3138f1Smrg fi 9591ee3138f1Smrg if test "X$noexename" != "X$name" ; then 95923e72ca8cSmrg func_append rmfiles " $odir/lt-${noexename}.c" 9593ee3138f1Smrg fi 9594ee3138f1Smrg fi 9595ee3138f1Smrg fi 9596ee3138f1Smrg ;; 9597ee3138f1Smrg esac 959834977a2fSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 9599ee3138f1Smrg done 9600ee3138f1Smrg 9601ee3138f1Smrg # Try to remove the ${objdir}s in the directories where we deleted files 9602ee3138f1Smrg for dir in $rmdirs; do 9603ee3138f1Smrg if test -d "$dir"; then 960434977a2fSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 9605ee3138f1Smrg fi 9606ee3138f1Smrg done 9607ee3138f1Smrg 9608ee3138f1Smrg exit $exit_status 960934977a2fSmrg} 9610ee3138f1Smrg 96113e72ca8cSmrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 961234977a2fSmrg func_mode_uninstall ${1+"$@"} 9613ee3138f1Smrg 96143e72ca8cSmrgtest -z "$opt_mode" && { 961534977a2fSmrg help="$generic_help" 961634977a2fSmrg func_fatal_help "you must specify a MODE" 961734977a2fSmrg} 961834977a2fSmrg 961934977a2fSmrgtest -z "$exec_cmd" && \ 96203e72ca8cSmrg func_fatal_help "invalid operation mode \`$opt_mode'" 9621ee3138f1Smrg 9622ee3138f1Smrgif test -n "$exec_cmd"; then 962334977a2fSmrg eval exec "$exec_cmd" 9624ee3138f1Smrg exit $EXIT_FAILURE 9625ee3138f1Smrgfi 9626ee3138f1Smrg 962734977a2fSmrgexit $exit_status 9628ee3138f1Smrg 9629ee3138f1Smrg 9630ee3138f1Smrg# The TAGs below are defined such that we never get into a situation 9631ee3138f1Smrg# in which we disable both kinds of libraries. Given conflicting 9632ee3138f1Smrg# choices, we go for a static library, that is the most portable, 9633ee3138f1Smrg# since we can't tell whether shared libraries were disabled because 9634ee3138f1Smrg# the user asked for that or because the platform doesn't support 9635ee3138f1Smrg# them. This is particularly important on AIX, because we don't 9636ee3138f1Smrg# support having both static and shared libraries enabled at the same 9637ee3138f1Smrg# time on that platform, so we default to a shared-only configuration. 9638ee3138f1Smrg# If a disable-shared tag is given, we'll fallback to a static-only 9639ee3138f1Smrg# configuration. But we'll never go from static-only to shared-only. 9640ee3138f1Smrg 9641ee3138f1Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 964234977a2fSmrgbuild_libtool_libs=no 964334977a2fSmrgbuild_old_libs=yes 9644ee3138f1Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 9645ee3138f1Smrg 9646ee3138f1Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 964734977a2fSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 9648ee3138f1Smrg# ### END LIBTOOL TAG CONFIG: disable-static 9649ee3138f1Smrg 9650ee3138f1Smrg# Local Variables: 9651ee3138f1Smrg# mode:shell-script 9652ee3138f1Smrg# sh-indentation:2 9653ee3138f1Smrg# End: 965434977a2fSmrg# vi:sw=2 965534977a2fSmrg 9656