ltmain.sh revision c63293b5
1e169010aSmrg 2c63293b5Smrg# libtool (GNU libtool) 2.4 3e169010aSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 4e169010aSmrg 5e8ead290Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 6e8ead290Smrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 7e169010aSmrg# This is free software; see the source for copying conditions. There is NO 8e169010aSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9e169010aSmrg 10e169010aSmrg# GNU Libtool is free software; you can redistribute it and/or modify 117914d74bSmrg# it under the terms of the GNU General Public License as published by 127914d74bSmrg# the Free Software Foundation; either version 2 of the License, or 137914d74bSmrg# (at your option) any later version. 147914d74bSmrg# 15e169010aSmrg# As a special exception to the GNU General Public License, 16e169010aSmrg# if you distribute this file as part of a program or library that 17e169010aSmrg# is built using GNU Libtool, you may include this file under the 18e169010aSmrg# same distribution terms that you use for the rest of that program. 19e169010aSmrg# 20e169010aSmrg# GNU Libtool is distributed in the hope that it will be useful, but 217914d74bSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 227914d74bSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 237914d74bSmrg# General Public License for more details. 247914d74bSmrg# 257914d74bSmrg# You should have received a copy of the GNU General Public License 26e169010aSmrg# along with GNU Libtool; see the file COPYING. If not, a copy 27e169010aSmrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 28e169010aSmrg# or obtained by writing to the Free Software Foundation, Inc., 29e169010aSmrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 30e169010aSmrg 31e169010aSmrg# Usage: $progname [OPTION]... [MODE-ARG]... 32e169010aSmrg# 33e169010aSmrg# Provide generalized library-building support services. 347914d74bSmrg# 35e8ead290Smrg# --config show all configuration variables 36e8ead290Smrg# --debug enable verbose shell tracing 37e8ead290Smrg# -n, --dry-run display commands without modifying any files 38e8ead290Smrg# --features display basic configuration information and exit 39e8ead290Smrg# --mode=MODE use operation mode MODE 40e8ead290Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 41e8ead290Smrg# --quiet, --silent don't print informational messages 42e8ead290Smrg# --no-quiet, --no-silent 43e8ead290Smrg# print informational messages (default) 44e8ead290Smrg# --tag=TAG use configuration variables from tag TAG 45e8ead290Smrg# -v, --verbose print more informational messages than default 46e8ead290Smrg# --no-verbose don't print the extra informational messages 47e8ead290Smrg# --version print version information 48e8ead290Smrg# -h, --help, --help-all print short, long, or detailed help message 49e169010aSmrg# 50e169010aSmrg# MODE must be one of the following: 51e169010aSmrg# 52e8ead290Smrg# clean remove files from the build directory 53e8ead290Smrg# compile compile a source file into a libtool object 54e8ead290Smrg# execute automatically set library path, then run a program 55e8ead290Smrg# finish complete the installation of libtool libraries 56e8ead290Smrg# install install libraries or executables 57e8ead290Smrg# link create a library or an executable 58e8ead290Smrg# uninstall remove libraries from an installed directory 59e169010aSmrg# 60e8ead290Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 61e8ead290Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 62e169010aSmrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 63e169010aSmrg# 64e169010aSmrg# When reporting a bug, please describe a test case to reproduce it and 65e169010aSmrg# include the following information: 66e169010aSmrg# 67e8ead290Smrg# host-triplet: $host 68e8ead290Smrg# shell: $SHELL 69e8ead290Smrg# compiler: $LTCC 70e8ead290Smrg# compiler flags: $LTCFLAGS 71e8ead290Smrg# linker: $LD (gnu? $with_gnu_ld) 72c63293b5Smrg# $progname: (GNU libtool) 2.4 73e8ead290Smrg# automake: $automake_version 74e8ead290Smrg# autoconf: $autoconf_version 75e169010aSmrg# 76e169010aSmrg# Report bugs to <bug-libtool@gnu.org>. 77c63293b5Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 78c63293b5Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 79e169010aSmrg 80e8ead290SmrgPROGRAM=libtool 81e169010aSmrgPACKAGE=libtool 82c63293b5SmrgVERSION=2.4 83e169010aSmrgTIMESTAMP="" 84c63293b5Smrgpackage_revision=1.3293 85e169010aSmrg 86e169010aSmrg# Be Bourne compatible 87e169010aSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 88e169010aSmrg emulate sh 89e169010aSmrg NULLCMD=: 90e169010aSmrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 91e169010aSmrg # is contrary to our usage. Disable this feature. 92e169010aSmrg alias -g '${1+"$@"}'='"$@"' 93e169010aSmrg setopt NO_GLOB_SUBST 94e169010aSmrgelse 95e169010aSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 96e169010aSmrgfi 97e169010aSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 98e169010aSmrgDUALCASE=1; export DUALCASE # for MKS sh 99e169010aSmrg 100e8ead290Smrg# A function that is used when there is no print builtin or printf. 101e8ead290Smrgfunc_fallback_echo () 102e8ead290Smrg{ 103e8ead290Smrg eval 'cat <<_LTECHO_EOF 104e8ead290Smrg$1 105e8ead290Smrg_LTECHO_EOF' 106e8ead290Smrg} 107e8ead290Smrg 108e169010aSmrg# NLS nuisances: We save the old values to restore during execute mode. 109e169010aSmrglt_user_locale= 110e169010aSmrglt_safe_locale= 111e169010aSmrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 112e169010aSmrgdo 113e169010aSmrg eval "if test \"\${$lt_var+set}\" = set; then 114e169010aSmrg save_$lt_var=\$$lt_var 115e169010aSmrg $lt_var=C 116e169010aSmrg export $lt_var 117e169010aSmrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 118e169010aSmrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 119e169010aSmrg fi" 120e169010aSmrgdone 121e8ead290SmrgLC_ALL=C 122e8ead290SmrgLANGUAGE=C 123e8ead290Smrgexport LANGUAGE LC_ALL 124e169010aSmrg 125e169010aSmrg$lt_unset CDPATH 126e169010aSmrg 127e169010aSmrg 128e8ead290Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 129e8ead290Smrg# is ksh but when the shell is invoked as "sh" and the current value of 130e8ead290Smrg# the _XPG environment variable is not equal to 1 (one), the special 131e8ead290Smrg# positional parameter $0, within a function call, is the name of the 132e8ead290Smrg# function. 133e8ead290Smrgprogpath="$0" 134e169010aSmrg 135e169010aSmrg 136e169010aSmrg 137e169010aSmrg: ${CP="cp -f"} 138e8ead290Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 139e8ead290Smrg: ${EGREP="grep -E"} 140e8ead290Smrg: ${FGREP="grep -F"} 141e8ead290Smrg: ${GREP="grep"} 142e169010aSmrg: ${LN_S="ln -s"} 143e169010aSmrg: ${MAKE="make"} 144e169010aSmrg: ${MKDIR="mkdir"} 145e169010aSmrg: ${MV="mv -f"} 146e169010aSmrg: ${RM="rm -f"} 147e8ead290Smrg: ${SED="sed"} 148e169010aSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 149e169010aSmrg: ${Xsed="$SED -e 1s/^X//"} 1507914d74bSmrg 151e169010aSmrg# Global variables: 152e169010aSmrgEXIT_SUCCESS=0 153e169010aSmrgEXIT_FAILURE=1 154e169010aSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 155e169010aSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 156e169010aSmrg 157e169010aSmrgexit_status=$EXIT_SUCCESS 158e169010aSmrg 159e169010aSmrg# Make sure IFS has a sensible default 160e169010aSmrglt_nl=' 161e169010aSmrg' 162e169010aSmrgIFS=" $lt_nl" 163e169010aSmrg 164e169010aSmrgdirname="s,/[^/]*$,," 165e169010aSmrgbasename="s,^.*/,," 166e169010aSmrg 167c63293b5Smrg# func_dirname file append nondir_replacement 168c63293b5Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 169c63293b5Smrg# otherwise set result to NONDIR_REPLACEMENT. 170c63293b5Smrgfunc_dirname () 171c63293b5Smrg{ 172c63293b5Smrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 173c63293b5Smrg if test "X$func_dirname_result" = "X${1}"; then 174c63293b5Smrg func_dirname_result="${3}" 175c63293b5Smrg else 176c63293b5Smrg func_dirname_result="$func_dirname_result${2}" 177c63293b5Smrg fi 178c63293b5Smrg} # func_dirname may be replaced by extended shell implementation 179c63293b5Smrg 180c63293b5Smrg 181c63293b5Smrg# func_basename file 182c63293b5Smrgfunc_basename () 183c63293b5Smrg{ 184c63293b5Smrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 185c63293b5Smrg} # func_basename may be replaced by extended shell implementation 186c63293b5Smrg 187c63293b5Smrg 188e169010aSmrg# func_dirname_and_basename file append nondir_replacement 189e169010aSmrg# perform func_basename and func_dirname in a single function 190e169010aSmrg# call: 191e169010aSmrg# dirname: Compute the dirname of FILE. If nonempty, 192e169010aSmrg# add APPEND to the result, otherwise set result 193e169010aSmrg# to NONDIR_REPLACEMENT. 194e169010aSmrg# value returned in "$func_dirname_result" 195e169010aSmrg# basename: Compute filename of FILE. 196e169010aSmrg# value retuned in "$func_basename_result" 197e169010aSmrg# Implementation must be kept synchronized with func_dirname 198e169010aSmrg# and func_basename. For efficiency, we do not delegate to 199e169010aSmrg# those functions but instead duplicate the functionality here. 200e169010aSmrgfunc_dirname_and_basename () 201e169010aSmrg{ 202c63293b5Smrg # Extract subdirectory from the argument. 203c63293b5Smrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 204c63293b5Smrg if test "X$func_dirname_result" = "X${1}"; then 205c63293b5Smrg func_dirname_result="${3}" 206c63293b5Smrg else 207c63293b5Smrg func_dirname_result="$func_dirname_result${2}" 208c63293b5Smrg fi 209c63293b5Smrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 210c63293b5Smrg} # func_dirname_and_basename may be replaced by extended shell implementation 211c63293b5Smrg 212c63293b5Smrg 213c63293b5Smrg# func_stripname prefix suffix name 214c63293b5Smrg# strip PREFIX and SUFFIX off of NAME. 215c63293b5Smrg# PREFIX and SUFFIX must not contain globbing or regex special 216c63293b5Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 217c63293b5Smrg# dot (in which case that matches only a dot). 218c63293b5Smrg# func_strip_suffix prefix name 219c63293b5Smrgfunc_stripname () 220c63293b5Smrg{ 221c63293b5Smrg case ${2} in 222c63293b5Smrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 223c63293b5Smrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 224c63293b5Smrg esac 225c63293b5Smrg} # func_stripname may be replaced by extended shell implementation 226e169010aSmrg 2277914d74bSmrg 228e8ead290Smrg# These SED scripts presuppose an absolute path with a trailing slash. 229e8ead290Smrgpathcar='s,^/\([^/]*\).*$,\1,' 230e8ead290Smrgpathcdr='s,^/[^/]*,,' 231e8ead290Smrgremovedotparts=':dotsl 232e8ead290Smrg s@/\./@/@g 233e8ead290Smrg t dotsl 234e8ead290Smrg s,/\.$,/,' 235e8ead290Smrgcollapseslashes='s@/\{1,\}@/@g' 236e8ead290Smrgfinalslash='s,/*$,/,' 237e8ead290Smrg 238e8ead290Smrg# func_normal_abspath PATH 239e8ead290Smrg# Remove doubled-up and trailing slashes, "." path components, 240e8ead290Smrg# and cancel out any ".." path components in PATH after making 241e8ead290Smrg# it an absolute path. 242e8ead290Smrg# value returned in "$func_normal_abspath_result" 243e8ead290Smrgfunc_normal_abspath () 244e8ead290Smrg{ 245e8ead290Smrg # Start from root dir and reassemble the path. 246e8ead290Smrg func_normal_abspath_result= 247e8ead290Smrg func_normal_abspath_tpath=$1 248e8ead290Smrg func_normal_abspath_altnamespace= 249e8ead290Smrg case $func_normal_abspath_tpath in 250e8ead290Smrg "") 251e8ead290Smrg # Empty path, that just means $cwd. 252e8ead290Smrg func_stripname '' '/' "`pwd`" 253e8ead290Smrg func_normal_abspath_result=$func_stripname_result 254e8ead290Smrg return 255e8ead290Smrg ;; 256e8ead290Smrg # The next three entries are used to spot a run of precisely 257e8ead290Smrg # two leading slashes without using negated character classes; 258e8ead290Smrg # we take advantage of case's first-match behaviour. 259e8ead290Smrg ///*) 260e8ead290Smrg # Unusual form of absolute path, do nothing. 261e8ead290Smrg ;; 262e8ead290Smrg //*) 263e8ead290Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 264e8ead290Smrg # and for example Cygwin uses it to access remote file shares 265e8ead290Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 266e8ead290Smrg func_normal_abspath_altnamespace=/ 267e8ead290Smrg ;; 268e8ead290Smrg /*) 269e8ead290Smrg # Absolute path, do nothing. 270e8ead290Smrg ;; 271e8ead290Smrg *) 272e8ead290Smrg # Relative path, prepend $cwd. 273e8ead290Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 274e8ead290Smrg ;; 275e8ead290Smrg esac 276e8ead290Smrg # Cancel out all the simple stuff to save iterations. We also want 277e8ead290Smrg # the path to end with a slash for ease of parsing, so make sure 278e8ead290Smrg # there is one (and only one) here. 279e8ead290Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 280e8ead290Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 281e8ead290Smrg while :; do 282e8ead290Smrg # Processed it all yet? 283e8ead290Smrg if test "$func_normal_abspath_tpath" = / ; then 284e8ead290Smrg # If we ascended to the root using ".." the result may be empty now. 285e8ead290Smrg if test -z "$func_normal_abspath_result" ; then 286e8ead290Smrg func_normal_abspath_result=/ 287e8ead290Smrg fi 288e8ead290Smrg break 289e8ead290Smrg fi 290e8ead290Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 291e8ead290Smrg -e "$pathcar"` 292e8ead290Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 293e8ead290Smrg -e "$pathcdr"` 294e8ead290Smrg # Figure out what to do with it 295e8ead290Smrg case $func_normal_abspath_tcomponent in 296e8ead290Smrg "") 297e8ead290Smrg # Trailing empty path component, ignore it. 298e8ead290Smrg ;; 299e8ead290Smrg ..) 300e8ead290Smrg # Parent dir; strip last assembled component from result. 301e8ead290Smrg func_dirname "$func_normal_abspath_result" 302e8ead290Smrg func_normal_abspath_result=$func_dirname_result 303e8ead290Smrg ;; 304e8ead290Smrg *) 305e8ead290Smrg # Actual path component, append it. 306e8ead290Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 307e8ead290Smrg ;; 308e8ead290Smrg esac 309e8ead290Smrg done 310e8ead290Smrg # Restore leading double-slash if one was found on entry. 311e8ead290Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 312e8ead290Smrg} 313e8ead290Smrg 314e8ead290Smrg# func_relative_path SRCDIR DSTDIR 315e8ead290Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 316e8ead290Smrg# slash if non-empty, suitable for immediately appending a filename 317e8ead290Smrg# without needing to append a separator. 318e8ead290Smrg# value returned in "$func_relative_path_result" 319e8ead290Smrgfunc_relative_path () 320e8ead290Smrg{ 321e8ead290Smrg func_relative_path_result= 322e8ead290Smrg func_normal_abspath "$1" 323e8ead290Smrg func_relative_path_tlibdir=$func_normal_abspath_result 324e8ead290Smrg func_normal_abspath "$2" 325e8ead290Smrg func_relative_path_tbindir=$func_normal_abspath_result 326e8ead290Smrg 327e8ead290Smrg # Ascend the tree starting from libdir 328e8ead290Smrg while :; do 329e8ead290Smrg # check if we have found a prefix of bindir 330e8ead290Smrg case $func_relative_path_tbindir in 331e8ead290Smrg $func_relative_path_tlibdir) 332e8ead290Smrg # found an exact match 333e8ead290Smrg func_relative_path_tcancelled= 334e8ead290Smrg break 335e8ead290Smrg ;; 336e8ead290Smrg $func_relative_path_tlibdir*) 337e8ead290Smrg # found a matching prefix 338e8ead290Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 339e8ead290Smrg func_relative_path_tcancelled=$func_stripname_result 340e8ead290Smrg if test -z "$func_relative_path_result"; then 341e8ead290Smrg func_relative_path_result=. 342e8ead290Smrg fi 343e8ead290Smrg break 344e8ead290Smrg ;; 345e8ead290Smrg *) 346e8ead290Smrg func_dirname $func_relative_path_tlibdir 347e8ead290Smrg func_relative_path_tlibdir=${func_dirname_result} 348e8ead290Smrg if test "x$func_relative_path_tlibdir" = x ; then 349e8ead290Smrg # Have to descend all the way to the root! 350e8ead290Smrg func_relative_path_result=../$func_relative_path_result 351e8ead290Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 352e8ead290Smrg break 353e8ead290Smrg fi 354e8ead290Smrg func_relative_path_result=../$func_relative_path_result 355e8ead290Smrg ;; 356e8ead290Smrg esac 357e8ead290Smrg done 358e8ead290Smrg 359e8ead290Smrg # Now calculate path; take care to avoid doubling-up slashes. 360e8ead290Smrg func_stripname '' '/' "$func_relative_path_result" 361e8ead290Smrg func_relative_path_result=$func_stripname_result 362e8ead290Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 363e8ead290Smrg if test "x$func_stripname_result" != x ; then 364e8ead290Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 365e8ead290Smrg fi 366e8ead290Smrg 367e8ead290Smrg # Normalisation. If bindir is libdir, return empty string, 368e8ead290Smrg # else relative path ending with a slash; either way, target 369e8ead290Smrg # file name can be directly appended. 370e8ead290Smrg if test ! -z "$func_relative_path_result"; then 371e8ead290Smrg func_stripname './' '' "$func_relative_path_result/" 372e8ead290Smrg func_relative_path_result=$func_stripname_result 373e8ead290Smrg fi 374e8ead290Smrg} 3757914d74bSmrg 3767914d74bSmrg# The name of this program: 377e169010aSmrgfunc_dirname_and_basename "$progpath" 378e169010aSmrgprogname=$func_basename_result 3797914d74bSmrg 380e169010aSmrg# Make sure we have an absolute path for reexecution: 381e169010aSmrgcase $progpath in 382e169010aSmrg [\\/]*|[A-Za-z]:\\*) ;; 383e169010aSmrg *[\\/]*) 384e169010aSmrg progdir=$func_dirname_result 385e169010aSmrg progdir=`cd "$progdir" && pwd` 386e169010aSmrg progpath="$progdir/$progname" 387e169010aSmrg ;; 388e169010aSmrg *) 389e169010aSmrg save_IFS="$IFS" 390e169010aSmrg IFS=: 391e169010aSmrg for progdir in $PATH; do 392e169010aSmrg IFS="$save_IFS" 393e169010aSmrg test -x "$progdir/$progname" && break 394e169010aSmrg done 395e169010aSmrg IFS="$save_IFS" 396e169010aSmrg test -n "$progdir" || progdir=`pwd` 397e169010aSmrg progpath="$progdir/$progname" 398e169010aSmrg ;; 399e169010aSmrgesac 4007914d74bSmrg 401e169010aSmrg# Sed substitution that helps us do robust quoting. It backslashifies 402e169010aSmrg# metacharacters that are still active within double-quoted strings. 403e169010aSmrgXsed="${SED}"' -e 1s/^X//' 404e169010aSmrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 405e169010aSmrg 406e169010aSmrg# Same as above, but do not quote variable references. 407e169010aSmrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 408e169010aSmrg 409c63293b5Smrg# Sed substitution that turns a string into a regex matching for the 410c63293b5Smrg# string literally. 411c63293b5Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 412c63293b5Smrg 413c63293b5Smrg# Sed substitution that converts a w32 file name or path 414c63293b5Smrg# which contains forward slashes, into one that contains 415c63293b5Smrg# (escaped) backslashes. A very naive implementation. 416c63293b5Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 417c63293b5Smrg 418e169010aSmrg# Re-`\' parameter expansions in output of double_quote_subst that were 419e169010aSmrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 420e169010aSmrg# in input to double_quote_subst, that '$' was protected from expansion. 421e169010aSmrg# Since each input `\' is now two `\'s, look for any number of runs of 422e169010aSmrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 423e169010aSmrgbs='\\' 424e169010aSmrgbs2='\\\\' 425e169010aSmrgbs4='\\\\\\\\' 426e169010aSmrgdollar='\$' 427e169010aSmrgsed_double_backslash="\ 428e169010aSmrg s/$bs4/&\\ 429e169010aSmrg/g 430e169010aSmrg s/^$bs2$dollar/$bs&/ 431e169010aSmrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 432e169010aSmrg s/\n//g" 433e169010aSmrg 434e169010aSmrg# Standard options: 435e169010aSmrgopt_dry_run=false 436e169010aSmrgopt_help=false 437e169010aSmrgopt_quiet=false 438e169010aSmrgopt_verbose=false 439e169010aSmrgopt_warning=: 440e169010aSmrg 441e169010aSmrg# func_echo arg... 442e169010aSmrg# Echo program name prefixed message, along with the current mode 443e169010aSmrg# name if it has been set yet. 444e169010aSmrgfunc_echo () 445e169010aSmrg{ 446c63293b5Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 447e169010aSmrg} 4487914d74bSmrg 449e169010aSmrg# func_verbose arg... 450e169010aSmrg# Echo program name prefixed message in verbose mode only. 451e169010aSmrgfunc_verbose () 452e169010aSmrg{ 453e169010aSmrg $opt_verbose && func_echo ${1+"$@"} 4547914d74bSmrg 455e169010aSmrg # A bug in bash halts the script if the last line of a function 456e169010aSmrg # fails when set -e is in force, so we need another command to 457e169010aSmrg # work around that: 458e169010aSmrg : 459e169010aSmrg} 4607914d74bSmrg 461e8ead290Smrg# func_echo_all arg... 462e8ead290Smrg# Invoke $ECHO with all args, space-separated. 463e8ead290Smrgfunc_echo_all () 464e8ead290Smrg{ 465e8ead290Smrg $ECHO "$*" 466e8ead290Smrg} 467e8ead290Smrg 468e169010aSmrg# func_error arg... 469e169010aSmrg# Echo program name prefixed message to standard error. 470e169010aSmrgfunc_error () 471e169010aSmrg{ 472c63293b5Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 473e169010aSmrg} 4747914d74bSmrg 475e169010aSmrg# func_warning arg... 476e169010aSmrg# Echo program name prefixed warning message to standard error. 477e169010aSmrgfunc_warning () 478e169010aSmrg{ 479c63293b5Smrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 4807914d74bSmrg 481e169010aSmrg # bash bug again: 482e169010aSmrg : 483e169010aSmrg} 4847914d74bSmrg 485e169010aSmrg# func_fatal_error arg... 486e169010aSmrg# Echo program name prefixed message to standard error, and exit. 487e169010aSmrgfunc_fatal_error () 488e169010aSmrg{ 489e169010aSmrg func_error ${1+"$@"} 490e169010aSmrg exit $EXIT_FAILURE 491e169010aSmrg} 4927914d74bSmrg 493e169010aSmrg# func_fatal_help arg... 494e169010aSmrg# Echo program name prefixed message to standard error, followed by 495e169010aSmrg# a help hint, and exit. 496e169010aSmrgfunc_fatal_help () 497e169010aSmrg{ 498e169010aSmrg func_error ${1+"$@"} 499e169010aSmrg func_fatal_error "$help" 500e169010aSmrg} 501e169010aSmrghelp="Try \`$progname --help' for more information." ## default 5027914d74bSmrg 5037914d74bSmrg 504e169010aSmrg# func_grep expression filename 505e169010aSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 506e169010aSmrgfunc_grep () 507e169010aSmrg{ 508e169010aSmrg $GREP "$1" "$2" >/dev/null 2>&1 509e169010aSmrg} 510e169010aSmrg 511e169010aSmrg 512e169010aSmrg# func_mkdir_p directory-path 513e169010aSmrg# Make sure the entire path to DIRECTORY-PATH is available. 514e169010aSmrgfunc_mkdir_p () 515e169010aSmrg{ 516e169010aSmrg my_directory_path="$1" 517e169010aSmrg my_dir_list= 518e169010aSmrg 519e169010aSmrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 520e169010aSmrg 521e169010aSmrg # Protect directory names starting with `-' 522e169010aSmrg case $my_directory_path in 523e169010aSmrg -*) my_directory_path="./$my_directory_path" ;; 524e169010aSmrg esac 525e169010aSmrg 526e169010aSmrg # While some portion of DIR does not yet exist... 527e169010aSmrg while test ! -d "$my_directory_path"; do 528e169010aSmrg # ...make a list in topmost first order. Use a colon delimited 529e169010aSmrg # list incase some portion of path contains whitespace. 530e169010aSmrg my_dir_list="$my_directory_path:$my_dir_list" 531e169010aSmrg 532e169010aSmrg # If the last portion added has no slash in it, the list is done 533e169010aSmrg case $my_directory_path in */*) ;; *) break ;; esac 534e169010aSmrg 535e169010aSmrg # ...otherwise throw away the child directory and loop 536e8ead290Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 537e169010aSmrg done 538e8ead290Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 539e169010aSmrg 540e169010aSmrg save_mkdir_p_IFS="$IFS"; IFS=':' 541e169010aSmrg for my_dir in $my_dir_list; do 542e169010aSmrg IFS="$save_mkdir_p_IFS" 543e169010aSmrg # mkdir can fail with a `File exist' error if two processes 544e169010aSmrg # try to create one of the directories concurrently. Don't 545e169010aSmrg # stop in that case! 546e169010aSmrg $MKDIR "$my_dir" 2>/dev/null || : 547e169010aSmrg done 548e169010aSmrg IFS="$save_mkdir_p_IFS" 549e169010aSmrg 550e169010aSmrg # Bail out if we (or some other process) failed to create a directory. 551e169010aSmrg test -d "$my_directory_path" || \ 552e169010aSmrg func_fatal_error "Failed to create \`$1'" 553e169010aSmrg fi 554e169010aSmrg} 5557914d74bSmrg 5567914d74bSmrg 5577914d74bSmrg# func_mktempdir [string] 5587914d74bSmrg# Make a temporary directory that won't clash with other running 5597914d74bSmrg# libtool processes, and avoids race conditions if possible. If 5607914d74bSmrg# given, STRING is the basename for that directory. 5617914d74bSmrgfunc_mktempdir () 5627914d74bSmrg{ 5637914d74bSmrg my_template="${TMPDIR-/tmp}/${1-$progname}" 5647914d74bSmrg 565e169010aSmrg if test "$opt_dry_run" = ":"; then 5667914d74bSmrg # Return a directory name, but don't create it in dry-run mode 5677914d74bSmrg my_tmpdir="${my_template}-$$" 5687914d74bSmrg else 5697914d74bSmrg 5707914d74bSmrg # If mktemp works, use that first and foremost 5717914d74bSmrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 5727914d74bSmrg 5737914d74bSmrg if test ! -d "$my_tmpdir"; then 574e169010aSmrg # Failing that, at least try and use $RANDOM to avoid a race 575e169010aSmrg my_tmpdir="${my_template}-${RANDOM-0}$$" 5767914d74bSmrg 577e169010aSmrg save_mktempdir_umask=`umask` 578e169010aSmrg umask 0077 579e169010aSmrg $MKDIR "$my_tmpdir" 580e169010aSmrg umask $save_mktempdir_umask 5817914d74bSmrg fi 5827914d74bSmrg 5837914d74bSmrg # If we're not in dry-run mode, bomb out on failure 584e169010aSmrg test -d "$my_tmpdir" || \ 585e169010aSmrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 5867914d74bSmrg fi 5877914d74bSmrg 588e8ead290Smrg $ECHO "$my_tmpdir" 5897914d74bSmrg} 5907914d74bSmrg 5917914d74bSmrg 592e169010aSmrg# func_quote_for_eval arg 593e169010aSmrg# Aesthetically quote ARG to be evaled later. 594e169010aSmrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 595e169010aSmrg# is double-quoted, suitable for a subsequent eval, whereas 596e169010aSmrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 597e169010aSmrg# which are still active within double quotes backslashified. 598e169010aSmrgfunc_quote_for_eval () 5997914d74bSmrg{ 600e169010aSmrg case $1 in 601e169010aSmrg *[\\\`\"\$]*) 602e8ead290Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 603e169010aSmrg *) 604e169010aSmrg func_quote_for_eval_unquoted_result="$1" ;; 605e169010aSmrg esac 606e169010aSmrg 607e169010aSmrg case $func_quote_for_eval_unquoted_result in 608e169010aSmrg # Double-quote args containing shell metacharacters to delay 609e169010aSmrg # word splitting, command substitution and and variable 610e169010aSmrg # expansion for a subsequent eval. 611e169010aSmrg # Many Bourne shells cannot handle close brackets correctly 612e169010aSmrg # in scan sets, so we specify it separately. 613e169010aSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 614e169010aSmrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 615e169010aSmrg ;; 616e169010aSmrg *) 617e169010aSmrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 6187914d74bSmrg esac 6197914d74bSmrg} 6207914d74bSmrg 6217914d74bSmrg 622e169010aSmrg# func_quote_for_expand arg 623e169010aSmrg# Aesthetically quote ARG to be evaled later; same as above, 624e169010aSmrg# but do not quote variable references. 625e169010aSmrgfunc_quote_for_expand () 6267914d74bSmrg{ 627e169010aSmrg case $1 in 628e169010aSmrg *[\\\`\"]*) 629e8ead290Smrg my_arg=`$ECHO "$1" | $SED \ 630e169010aSmrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 6317914d74bSmrg *) 632e169010aSmrg my_arg="$1" ;; 633e169010aSmrg esac 634e169010aSmrg 635e169010aSmrg case $my_arg in 636e169010aSmrg # Double-quote args containing shell metacharacters to delay 637e169010aSmrg # word splitting and command substitution for a subsequent eval. 638e169010aSmrg # Many Bourne shells cannot handle close brackets correctly 639e169010aSmrg # in scan sets, so we specify it separately. 640e169010aSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 641e169010aSmrg my_arg="\"$my_arg\"" 642e169010aSmrg ;; 643e169010aSmrg esac 644e169010aSmrg 645e169010aSmrg func_quote_for_expand_result="$my_arg" 6467914d74bSmrg} 6477914d74bSmrg 6487914d74bSmrg 649e169010aSmrg# func_show_eval cmd [fail_exp] 650e169010aSmrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 651e169010aSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 652e169010aSmrg# is given, then evaluate it. 653e169010aSmrgfunc_show_eval () 6547914d74bSmrg{ 655e169010aSmrg my_cmd="$1" 656e169010aSmrg my_fail_exp="${2-:}" 6577914d74bSmrg 658e169010aSmrg ${opt_silent-false} || { 659e169010aSmrg func_quote_for_expand "$my_cmd" 660e169010aSmrg eval "func_echo $func_quote_for_expand_result" 661e169010aSmrg } 662e169010aSmrg 663e169010aSmrg if ${opt_dry_run-false}; then :; else 664e169010aSmrg eval "$my_cmd" 665e169010aSmrg my_status=$? 666e169010aSmrg if test "$my_status" -eq 0; then :; else 667e169010aSmrg eval "(exit $my_status); $my_fail_exp" 668e169010aSmrg fi 6697914d74bSmrg fi 6707914d74bSmrg} 6717914d74bSmrg 672e169010aSmrg 673e169010aSmrg# func_show_eval_locale cmd [fail_exp] 674e169010aSmrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 675e169010aSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 676e169010aSmrg# is given, then evaluate it. Use the saved locale for evaluation. 677e169010aSmrgfunc_show_eval_locale () 6787914d74bSmrg{ 679e169010aSmrg my_cmd="$1" 680e169010aSmrg my_fail_exp="${2-:}" 6817914d74bSmrg 682e169010aSmrg ${opt_silent-false} || { 683e169010aSmrg func_quote_for_expand "$my_cmd" 684e169010aSmrg eval "func_echo $func_quote_for_expand_result" 685e169010aSmrg } 686e169010aSmrg 687e169010aSmrg if ${opt_dry_run-false}; then :; else 688e169010aSmrg eval "$lt_user_locale 689e169010aSmrg $my_cmd" 690e169010aSmrg my_status=$? 691e169010aSmrg eval "$lt_safe_locale" 692e169010aSmrg if test "$my_status" -eq 0; then :; else 693e169010aSmrg eval "(exit $my_status); $my_fail_exp" 6947914d74bSmrg fi 695e169010aSmrg fi 6967914d74bSmrg} 6977914d74bSmrg 698c63293b5Smrg# func_tr_sh 699c63293b5Smrg# Turn $1 into a string suitable for a shell variable name. 700c63293b5Smrg# Result is stored in $func_tr_sh_result. All characters 701c63293b5Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 702c63293b5Smrg# if $1 begins with a digit, a '_' is prepended as well. 703c63293b5Smrgfunc_tr_sh () 704c63293b5Smrg{ 705c63293b5Smrg case $1 in 706c63293b5Smrg [0-9]* | *[!a-zA-Z0-9_]*) 707c63293b5Smrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 708c63293b5Smrg ;; 709c63293b5Smrg * ) 710c63293b5Smrg func_tr_sh_result=$1 711c63293b5Smrg ;; 712c63293b5Smrg esac 713c63293b5Smrg} 714c63293b5Smrg 7157914d74bSmrg 716e169010aSmrg# func_version 717e169010aSmrg# Echo version message to standard output and exit. 718e169010aSmrgfunc_version () 719e169010aSmrg{ 720c63293b5Smrg $opt_debug 721c63293b5Smrg 722e8ead290Smrg $SED -n '/(C)/!b go 723e8ead290Smrg :more 724e8ead290Smrg /\./!{ 725e8ead290Smrg N 726e8ead290Smrg s/\n# / / 727e8ead290Smrg b more 728e8ead290Smrg } 729e8ead290Smrg :go 730e8ead290Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 731e169010aSmrg s/^# // 732e169010aSmrg s/^# *$// 733e169010aSmrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 734e169010aSmrg p 735e169010aSmrg }' < "$progpath" 736e169010aSmrg exit $? 737e169010aSmrg} 738e169010aSmrg 739e169010aSmrg# func_usage 740e169010aSmrg# Echo short help message to standard output and exit. 741e169010aSmrgfunc_usage () 742e169010aSmrg{ 743c63293b5Smrg $opt_debug 744c63293b5Smrg 745e8ead290Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 746e169010aSmrg s/^# // 747e169010aSmrg s/^# *$// 748e169010aSmrg s/\$progname/'$progname'/ 749e169010aSmrg p 750e169010aSmrg }' < "$progpath" 751e8ead290Smrg echo 752e169010aSmrg $ECHO "run \`$progname --help | more' for full usage" 753e169010aSmrg exit $? 754e169010aSmrg} 755e169010aSmrg 756e8ead290Smrg# func_help [NOEXIT] 757e8ead290Smrg# Echo long help message to standard output and exit, 758e8ead290Smrg# unless 'noexit' is passed as argument. 759e169010aSmrgfunc_help () 760e169010aSmrg{ 761c63293b5Smrg $opt_debug 762c63293b5Smrg 763e169010aSmrg $SED -n '/^# Usage:/,/# Report bugs to/ { 764c63293b5Smrg :print 765e169010aSmrg s/^# // 766e169010aSmrg s/^# *$// 767e169010aSmrg s*\$progname*'$progname'* 768e169010aSmrg s*\$host*'"$host"'* 769e169010aSmrg s*\$SHELL*'"$SHELL"'* 770e169010aSmrg s*\$LTCC*'"$LTCC"'* 771e169010aSmrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 772e169010aSmrg s*\$LD*'"$LD"'* 773e169010aSmrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 774e169010aSmrg s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ 775e169010aSmrg s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ 776e169010aSmrg p 777c63293b5Smrg d 778c63293b5Smrg } 779c63293b5Smrg /^# .* home page:/b print 780c63293b5Smrg /^# General help using/b print 781c63293b5Smrg ' < "$progpath" 782e8ead290Smrg ret=$? 783e8ead290Smrg if test -z "$1"; then 784e8ead290Smrg exit $ret 785e8ead290Smrg fi 786e169010aSmrg} 787e169010aSmrg 788e169010aSmrg# func_missing_arg argname 789e169010aSmrg# Echo program name prefixed message to standard error and set global 790e169010aSmrg# exit_cmd. 791e169010aSmrgfunc_missing_arg () 792e169010aSmrg{ 793c63293b5Smrg $opt_debug 794c63293b5Smrg 795e8ead290Smrg func_error "missing argument for $1." 796e169010aSmrg exit_cmd=exit 797e169010aSmrg} 798e169010aSmrg 799e169010aSmrg 800c63293b5Smrg# func_split_short_opt shortopt 801c63293b5Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 802c63293b5Smrg# variables after splitting SHORTOPT after the 2nd character. 803c63293b5Smrgfunc_split_short_opt () 804c63293b5Smrg{ 805c63293b5Smrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 806c63293b5Smrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 807c63293b5Smrg 808c63293b5Smrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 809c63293b5Smrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 810c63293b5Smrg} # func_split_short_opt may be replaced by extended shell implementation 811c63293b5Smrg 812c63293b5Smrg 813c63293b5Smrg# func_split_long_opt longopt 814c63293b5Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 815c63293b5Smrg# variables after splitting LONGOPT at the `=' sign. 816c63293b5Smrgfunc_split_long_opt () 817c63293b5Smrg{ 818c63293b5Smrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 819c63293b5Smrg my_sed_long_arg='1s/^--[^=]*=//' 820c63293b5Smrg 821c63293b5Smrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 822c63293b5Smrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 823c63293b5Smrg} # func_split_long_opt may be replaced by extended shell implementation 824c63293b5Smrg 825c63293b5Smrgexit_cmd=: 826e169010aSmrg 827e169010aSmrg 828e169010aSmrg 829e169010aSmrg 8307914d74bSmrg 831e169010aSmrgmagic="%%%MAGIC variable%%%" 832e169010aSmrgmagic_exe="%%%MAGIC EXE variable%%%" 8337914d74bSmrg 834e169010aSmrg# Global variables. 835e169010aSmrgnonopt= 836e169010aSmrgpreserve_args= 837e169010aSmrglo2o="s/\\.lo\$/.${objext}/" 838e169010aSmrgo2lo="s/\\.${objext}\$/.lo/" 839e169010aSmrgextracted_archives= 840e169010aSmrgextracted_serial=0 8417914d74bSmrg 842e169010aSmrg# If this variable is set in any of the actions, the command in it 843e169010aSmrg# will be execed at the end. This prevents here-documents from being 844e169010aSmrg# left over by shells. 845e169010aSmrgexec_cmd= 8467914d74bSmrg 847c63293b5Smrg# func_append var value 848c63293b5Smrg# Append VALUE to the end of shell variable VAR. 849c63293b5Smrgfunc_append () 850c63293b5Smrg{ 851c63293b5Smrg eval "${1}=\$${1}\${2}" 852c63293b5Smrg} # func_append may be replaced by extended shell implementation 853c63293b5Smrg 854c63293b5Smrg# func_append_quoted var value 855c63293b5Smrg# Quote VALUE and append to the end of shell variable VAR, separated 856c63293b5Smrg# by a space. 857c63293b5Smrgfunc_append_quoted () 858c63293b5Smrg{ 859c63293b5Smrg func_quote_for_eval "${2}" 860c63293b5Smrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 861c63293b5Smrg} # func_append_quoted may be replaced by extended shell implementation 862c63293b5Smrg 863c63293b5Smrg 864c63293b5Smrg# func_arith arithmetic-term... 865c63293b5Smrgfunc_arith () 866c63293b5Smrg{ 867c63293b5Smrg func_arith_result=`expr "${@}"` 868c63293b5Smrg} # func_arith may be replaced by extended shell implementation 869c63293b5Smrg 870c63293b5Smrg 871c63293b5Smrg# func_len string 872c63293b5Smrg# STRING may not start with a hyphen. 873c63293b5Smrgfunc_len () 874c63293b5Smrg{ 875c63293b5Smrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 876c63293b5Smrg} # func_len may be replaced by extended shell implementation 877c63293b5Smrg 878c63293b5Smrg 879c63293b5Smrg# func_lo2o object 880c63293b5Smrgfunc_lo2o () 881c63293b5Smrg{ 882c63293b5Smrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 883c63293b5Smrg} # func_lo2o may be replaced by extended shell implementation 884c63293b5Smrg 885c63293b5Smrg 886c63293b5Smrg# func_xform libobj-or-source 887c63293b5Smrgfunc_xform () 888c63293b5Smrg{ 889c63293b5Smrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 890c63293b5Smrg} # func_xform may be replaced by extended shell implementation 891c63293b5Smrg 892c63293b5Smrg 893e169010aSmrg# func_fatal_configuration arg... 894e169010aSmrg# Echo program name prefixed message to standard error, followed by 895e169010aSmrg# a configuration failure hint, and exit. 896e169010aSmrgfunc_fatal_configuration () 897e169010aSmrg{ 898e169010aSmrg func_error ${1+"$@"} 899e169010aSmrg func_error "See the $PACKAGE documentation for more information." 900e169010aSmrg func_fatal_error "Fatal configuration error." 901e169010aSmrg} 902e169010aSmrg 903e169010aSmrg 904e169010aSmrg# func_config 905e169010aSmrg# Display the configuration for all the tags in this script. 906e169010aSmrgfunc_config () 907e169010aSmrg{ 908e169010aSmrg re_begincf='^# ### BEGIN LIBTOOL' 909e169010aSmrg re_endcf='^# ### END LIBTOOL' 910e169010aSmrg 911e169010aSmrg # Default configuration. 912e169010aSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 9137914d74bSmrg 9147914d74bSmrg # Now print the configurations for the tags. 9157914d74bSmrg for tagname in $taglist; do 916e169010aSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 9177914d74bSmrg done 9187914d74bSmrg 919e169010aSmrg exit $? 920e169010aSmrg} 9217914d74bSmrg 922e169010aSmrg# func_features 923e169010aSmrg# Display the features supported by this script. 924e169010aSmrgfunc_features () 925e169010aSmrg{ 926e8ead290Smrg echo "host: $host" 9277914d74bSmrg if test "$build_libtool_libs" = yes; then 928e8ead290Smrg echo "enable shared libraries" 9297914d74bSmrg else 930e8ead290Smrg echo "disable shared libraries" 9317914d74bSmrg fi 9327914d74bSmrg if test "$build_old_libs" = yes; then 933e8ead290Smrg echo "enable static libraries" 9347914d74bSmrg else 935e8ead290Smrg echo "disable static libraries" 9367914d74bSmrg fi 937e169010aSmrg 9387914d74bSmrg exit $? 939e169010aSmrg} 940e169010aSmrg 941e169010aSmrg# func_enable_tag tagname 942e169010aSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 943e169010aSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 944e169010aSmrg# variable here. 945e169010aSmrgfunc_enable_tag () 946e169010aSmrg{ 947e169010aSmrg # Global variable: 948e169010aSmrg tagname="$1" 9497914d74bSmrg 950e169010aSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 951e169010aSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 952e169010aSmrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 9537914d74bSmrg 954e169010aSmrg # Validate tagname. 955e169010aSmrg case $tagname in 956e169010aSmrg *[!-_A-Za-z0-9,/]*) 957e169010aSmrg func_fatal_error "invalid tag name: $tagname" 958e169010aSmrg ;; 959e169010aSmrg esac 9607914d74bSmrg 961e169010aSmrg # Don't test for the "default" C tag, as we know it's 962e169010aSmrg # there but not specially marked. 963e169010aSmrg case $tagname in 964e169010aSmrg CC) ;; 965e169010aSmrg *) 966e169010aSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 967e169010aSmrg taglist="$taglist $tagname" 968e169010aSmrg 969e169010aSmrg # Evaluate the configuration. Be careful to quote the path 970e169010aSmrg # and the sed script, to avoid splitting on whitespace, but 971e169010aSmrg # also don't use non-portable quotes within backquotes within 972e169010aSmrg # quotes we have to do it in 2 steps: 973e169010aSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 974e169010aSmrg eval "$extractedcf" 975e169010aSmrg else 976e169010aSmrg func_error "ignoring unknown tag $tagname" 977e169010aSmrg fi 978e169010aSmrg ;; 979e169010aSmrg esac 980e169010aSmrg} 9817914d74bSmrg 982c63293b5Smrg# func_check_version_match 983c63293b5Smrg# Ensure that we are using m4 macros, and libtool script from the same 984c63293b5Smrg# release of libtool. 985c63293b5Smrgfunc_check_version_match () 986e169010aSmrg{ 987c63293b5Smrg if test "$package_revision" != "$macro_revision"; then 988c63293b5Smrg if test "$VERSION" != "$macro_version"; then 989c63293b5Smrg if test -z "$macro_version"; then 990c63293b5Smrg cat >&2 <<_LT_EOF 991c63293b5Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 992c63293b5Smrg$progname: definition of this LT_INIT comes from an older release. 993c63293b5Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 994c63293b5Smrg$progname: and run autoconf again. 995c63293b5Smrg_LT_EOF 996c63293b5Smrg else 997c63293b5Smrg cat >&2 <<_LT_EOF 998c63293b5Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 999c63293b5Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 1000c63293b5Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 1001c63293b5Smrg$progname: and run autoconf again. 1002c63293b5Smrg_LT_EOF 1003c63293b5Smrg fi 1004c63293b5Smrg else 1005c63293b5Smrg cat >&2 <<_LT_EOF 1006c63293b5Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 1007c63293b5Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 1008c63293b5Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 1009c63293b5Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 1010c63293b5Smrg_LT_EOF 1011c63293b5Smrg fi 10127914d74bSmrg 1013c63293b5Smrg exit $EXIT_MISMATCH 1014c63293b5Smrg fi 1015c63293b5Smrg} 1016c63293b5Smrg 1017c63293b5Smrg 1018c63293b5Smrg# Shorthand for --mode=foo, only valid as the first argument 1019c63293b5Smrgcase $1 in 1020c63293b5Smrgclean|clea|cle|cl) 1021c63293b5Smrg shift; set dummy --mode clean ${1+"$@"}; shift 1022c63293b5Smrg ;; 1023c63293b5Smrgcompile|compil|compi|comp|com|co|c) 1024c63293b5Smrg shift; set dummy --mode compile ${1+"$@"}; shift 1025c63293b5Smrg ;; 1026c63293b5Smrgexecute|execut|execu|exec|exe|ex|e) 1027c63293b5Smrg shift; set dummy --mode execute ${1+"$@"}; shift 1028c63293b5Smrg ;; 1029c63293b5Smrgfinish|finis|fini|fin|fi|f) 1030c63293b5Smrg shift; set dummy --mode finish ${1+"$@"}; shift 1031c63293b5Smrg ;; 1032c63293b5Smrginstall|instal|insta|inst|ins|in|i) 1033c63293b5Smrg shift; set dummy --mode install ${1+"$@"}; shift 1034c63293b5Smrg ;; 1035c63293b5Smrglink|lin|li|l) 1036c63293b5Smrg shift; set dummy --mode link ${1+"$@"}; shift 1037c63293b5Smrg ;; 1038c63293b5Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 1039c63293b5Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 1040c63293b5Smrg ;; 1041c63293b5Smrgesac 10427914d74bSmrg 1043c63293b5Smrg 1044c63293b5Smrg 1045c63293b5Smrg# Option defaults: 1046c63293b5Smrgopt_debug=: 1047c63293b5Smrgopt_dry_run=false 1048c63293b5Smrgopt_config=false 1049c63293b5Smrgopt_preserve_dup_deps=false 1050c63293b5Smrgopt_features=false 1051c63293b5Smrgopt_finish=false 1052c63293b5Smrgopt_help=false 1053c63293b5Smrgopt_help_all=false 1054c63293b5Smrgopt_silent=: 1055c63293b5Smrgopt_verbose=: 1056c63293b5Smrgopt_silent=false 1057c63293b5Smrgopt_verbose=false 1058c63293b5Smrg 1059c63293b5Smrg 1060c63293b5Smrg# Parse options once, thoroughly. This comes as soon as possible in the 1061c63293b5Smrg# script to make things like `--version' happen as quickly as we can. 1062c63293b5Smrg{ 1063c63293b5Smrg # this just eases exit handling 1064c63293b5Smrg while test $# -gt 0; do 1065e169010aSmrg opt="$1" 1066e169010aSmrg shift 1067e169010aSmrg case $opt in 1068c63293b5Smrg --debug|-x) opt_debug='set -x' 1069e169010aSmrg func_echo "enabling shell trace mode" 1070e169010aSmrg $opt_debug 1071e169010aSmrg ;; 1072c63293b5Smrg --dry-run|--dryrun|-n) 1073c63293b5Smrg opt_dry_run=: 1074e169010aSmrg ;; 1075c63293b5Smrg --config) 1076c63293b5Smrg opt_config=: 1077c63293b5Smrgfunc_config 1078c63293b5Smrg ;; 1079c63293b5Smrg --dlopen|-dlopen) 1080c63293b5Smrg optarg="$1" 1081c63293b5Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 1082c63293b5Smrg}$optarg" 1083e169010aSmrg shift 1084e169010aSmrg ;; 1085e169010aSmrg --preserve-dup-deps) 1086c63293b5Smrg opt_preserve_dup_deps=: 1087e8ead290Smrg ;; 1088c63293b5Smrg --features) 1089c63293b5Smrg opt_features=: 1090c63293b5Smrgfunc_features 1091e169010aSmrg ;; 1092c63293b5Smrg --finish) 1093c63293b5Smrg opt_finish=: 1094c63293b5Smrgset dummy --mode finish ${1+"$@"}; shift 1095c63293b5Smrg ;; 1096c63293b5Smrg --help) 1097c63293b5Smrg opt_help=: 1098c63293b5Smrg ;; 1099c63293b5Smrg --help-all) 1100c63293b5Smrg opt_help_all=: 1101c63293b5Smrgopt_help=': help-all' 1102c63293b5Smrg ;; 1103c63293b5Smrg --mode) 1104c63293b5Smrg test $# = 0 && func_missing_arg $opt && break 1105c63293b5Smrg optarg="$1" 1106c63293b5Smrg opt_mode="$optarg" 1107c63293b5Smrgcase $optarg in 1108c63293b5Smrg # Valid mode arguments: 1109c63293b5Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 1110c63293b5Smrg 1111c63293b5Smrg # Catch anything else as an error 1112c63293b5Smrg *) func_error "invalid argument for $opt" 1113c63293b5Smrg exit_cmd=exit 1114c63293b5Smrg break 1115c63293b5Smrg ;; 1116c63293b5Smrgesac 1117c63293b5Smrg shift 1118c63293b5Smrg ;; 1119c63293b5Smrg --no-silent|--no-quiet) 1120e169010aSmrg opt_silent=false 1121c63293b5Smrgfunc_append preserve_args " $opt" 1122e8ead290Smrg ;; 1123c63293b5Smrg --no-verbose) 1124e8ead290Smrg opt_verbose=false 1125c63293b5Smrgfunc_append preserve_args " $opt" 1126e169010aSmrg ;; 1127c63293b5Smrg --silent|--quiet) 1128c63293b5Smrg opt_silent=: 1129c63293b5Smrgfunc_append preserve_args " $opt" 1130c63293b5Smrg opt_verbose=false 1131c63293b5Smrg ;; 1132c63293b5Smrg --verbose|-v) 1133c63293b5Smrg opt_verbose=: 1134c63293b5Smrgfunc_append preserve_args " $opt" 1135c63293b5Smrgopt_silent=false 1136c63293b5Smrg ;; 1137c63293b5Smrg --tag) 1138c63293b5Smrg test $# = 0 && func_missing_arg $opt && break 1139c63293b5Smrg optarg="$1" 1140c63293b5Smrg opt_tag="$optarg" 1141c63293b5Smrgfunc_append preserve_args " $opt $optarg" 1142c63293b5Smrgfunc_enable_tag "$optarg" 1143e169010aSmrg shift 1144e169010aSmrg ;; 1145e169010aSmrg 1146c63293b5Smrg -\?|-h) func_usage ;; 1147c63293b5Smrg --help) func_help ;; 1148c63293b5Smrg --version) func_version ;; 1149c63293b5Smrg 1150e169010aSmrg # Separate optargs to long options: 1151c63293b5Smrg --*=*) 1152c63293b5Smrg func_split_long_opt "$opt" 1153c63293b5Smrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 1154e169010aSmrg shift 1155e169010aSmrg ;; 1156e169010aSmrg 1157c63293b5Smrg # Separate non-argument short options: 1158c63293b5Smrg -\?*|-h*|-n*|-v*) 1159c63293b5Smrg func_split_short_opt "$opt" 1160c63293b5Smrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 1161c63293b5Smrg shift 1162e169010aSmrg ;; 1163c63293b5Smrg 1164c63293b5Smrg --) break ;; 1165c63293b5Smrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 1166c63293b5Smrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 1167e169010aSmrg esac 1168e169010aSmrg done 1169e169010aSmrg 1170c63293b5Smrg # Validate options: 1171c63293b5Smrg 1172c63293b5Smrg # save first non-option argument 1173c63293b5Smrg if test "$#" -gt 0; then 1174c63293b5Smrg nonopt="$opt" 1175c63293b5Smrg shift 1176c63293b5Smrg fi 1177c63293b5Smrg 1178c63293b5Smrg # preserve --debug 1179c63293b5Smrg test "$opt_debug" = : || func_append preserve_args " --debug" 1180e169010aSmrg 1181e169010aSmrg case $host in 1182e169010aSmrg *cygwin* | *mingw* | *pw32* | *cegcc*) 1183e169010aSmrg # don't eliminate duplications in $postdeps and $predeps 1184e169010aSmrg opt_duplicate_compiler_generated_deps=: 11857914d74bSmrg ;; 11867914d74bSmrg *) 1187c63293b5Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 1188e169010aSmrg ;; 1189e169010aSmrg esac 11907914d74bSmrg 1191c63293b5Smrg $opt_help || { 1192c63293b5Smrg # Sanity checks first: 1193c63293b5Smrg func_check_version_match 1194e169010aSmrg 1195c63293b5Smrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 1196c63293b5Smrg func_fatal_configuration "not configured to build any kind of library" 1197e169010aSmrg fi 1198e169010aSmrg 1199c63293b5Smrg # Darwin sucks 1200c63293b5Smrg eval std_shrext=\"$shrext_cmds\" 1201e169010aSmrg 1202c63293b5Smrg # Only execute mode is allowed to have -dlopen flags. 1203c63293b5Smrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 1204c63293b5Smrg func_error "unrecognized option \`-dlopen'" 1205c63293b5Smrg $ECHO "$help" 1>&2 1206c63293b5Smrg exit $EXIT_FAILURE 1207c63293b5Smrg fi 1208e169010aSmrg 1209c63293b5Smrg # Change the help message to a mode-specific one. 1210c63293b5Smrg generic_help="$help" 1211c63293b5Smrg help="Try \`$progname --help --mode=$opt_mode' for more information." 1212c63293b5Smrg } 1213e169010aSmrg 1214e169010aSmrg 1215c63293b5Smrg # Bail if the options were screwed 1216c63293b5Smrg $exit_cmd $EXIT_FAILURE 1217c63293b5Smrg} 1218e169010aSmrg 1219e169010aSmrg 12207914d74bSmrg 12217914d74bSmrg 1222c63293b5Smrg## ----------- ## 1223c63293b5Smrg## Main. ## 1224c63293b5Smrg## ----------- ## 12257914d74bSmrg 1226e169010aSmrg# func_lalib_p file 1227e169010aSmrg# True iff FILE is a libtool `.la' library or `.lo' object file. 1228e169010aSmrg# This function is only a basic sanity check; it will hardly flush out 1229e169010aSmrg# determined imposters. 1230e169010aSmrgfunc_lalib_p () 1231e169010aSmrg{ 1232e169010aSmrg test -f "$1" && 1233e169010aSmrg $SED -e 4q "$1" 2>/dev/null \ 1234e169010aSmrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 1235e169010aSmrg} 12367914d74bSmrg 1237e169010aSmrg# func_lalib_unsafe_p file 1238e169010aSmrg# True iff FILE is a libtool `.la' library or `.lo' object file. 1239e169010aSmrg# This function implements the same check as func_lalib_p without 1240e169010aSmrg# resorting to external programs. To this end, it redirects stdin and 1241e169010aSmrg# closes it afterwards, without saving the original file descriptor. 1242e169010aSmrg# As a safety measure, use it only where a negative result would be 1243e169010aSmrg# fatal anyway. Works if `file' does not exist. 1244e169010aSmrgfunc_lalib_unsafe_p () 1245e169010aSmrg{ 1246e169010aSmrg lalib_p=no 1247e169010aSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 1248e169010aSmrg for lalib_p_l in 1 2 3 4 1249e169010aSmrg do 1250e169010aSmrg read lalib_p_line 1251e169010aSmrg case "$lalib_p_line" in 1252e169010aSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 1253e169010aSmrg esac 1254e169010aSmrg done 1255e169010aSmrg exec 0<&5 5<&- 1256e169010aSmrg fi 1257e169010aSmrg test "$lalib_p" = yes 1258e169010aSmrg} 12597914d74bSmrg 1260e169010aSmrg# func_ltwrapper_script_p file 1261e169010aSmrg# True iff FILE is a libtool wrapper script 1262e169010aSmrg# This function is only a basic sanity check; it will hardly flush out 1263e169010aSmrg# determined imposters. 1264e169010aSmrgfunc_ltwrapper_script_p () 1265e169010aSmrg{ 1266e169010aSmrg func_lalib_p "$1" 1267e169010aSmrg} 12687914d74bSmrg 1269e169010aSmrg# func_ltwrapper_executable_p file 1270e169010aSmrg# True iff FILE is a libtool wrapper executable 1271e169010aSmrg# This function is only a basic sanity check; it will hardly flush out 1272e169010aSmrg# determined imposters. 1273e169010aSmrgfunc_ltwrapper_executable_p () 1274e169010aSmrg{ 1275e169010aSmrg func_ltwrapper_exec_suffix= 1276e169010aSmrg case $1 in 1277e169010aSmrg *.exe) ;; 1278e169010aSmrg *) func_ltwrapper_exec_suffix=.exe ;; 1279e169010aSmrg esac 1280e169010aSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 1281e169010aSmrg} 12827914d74bSmrg 1283e169010aSmrg# func_ltwrapper_scriptname file 1284e169010aSmrg# Assumes file is an ltwrapper_executable 1285e169010aSmrg# uses $file to determine the appropriate filename for a 1286e169010aSmrg# temporary ltwrapper_script. 1287e169010aSmrgfunc_ltwrapper_scriptname () 1288e169010aSmrg{ 1289c63293b5Smrg func_dirname_and_basename "$1" "" "." 1290c63293b5Smrg func_stripname '' '.exe' "$func_basename_result" 1291c63293b5Smrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 1292e169010aSmrg} 12937914d74bSmrg 1294e169010aSmrg# func_ltwrapper_p file 1295e169010aSmrg# True iff FILE is a libtool wrapper script or wrapper executable 1296e169010aSmrg# This function is only a basic sanity check; it will hardly flush out 1297e169010aSmrg# determined imposters. 1298e169010aSmrgfunc_ltwrapper_p () 1299e169010aSmrg{ 1300e169010aSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 1301e169010aSmrg} 13027914d74bSmrg 13037914d74bSmrg 1304e169010aSmrg# func_execute_cmds commands fail_cmd 1305e169010aSmrg# Execute tilde-delimited COMMANDS. 1306e169010aSmrg# If FAIL_CMD is given, eval that upon failure. 1307e169010aSmrg# FAIL_CMD may read-access the current command in variable CMD! 1308e169010aSmrgfunc_execute_cmds () 1309e169010aSmrg{ 1310e169010aSmrg $opt_debug 1311e169010aSmrg save_ifs=$IFS; IFS='~' 1312e169010aSmrg for cmd in $1; do 1313e169010aSmrg IFS=$save_ifs 1314e169010aSmrg eval cmd=\"$cmd\" 1315e169010aSmrg func_show_eval "$cmd" "${2-:}" 1316e169010aSmrg done 1317e169010aSmrg IFS=$save_ifs 1318e169010aSmrg} 1319e169010aSmrg 1320e169010aSmrg 1321e169010aSmrg# func_source file 1322e169010aSmrg# Source FILE, adding directory component if necessary. 1323e169010aSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 1324e169010aSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 1325e169010aSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 1326e169010aSmrg# `FILE.' does not work on cygwin managed mounts. 1327e169010aSmrgfunc_source () 1328e169010aSmrg{ 1329e169010aSmrg $opt_debug 1330e169010aSmrg case $1 in 1331e169010aSmrg */* | *\\*) . "$1" ;; 1332e169010aSmrg *) . "./$1" ;; 1333e169010aSmrg esac 1334e169010aSmrg} 1335e169010aSmrg 1336e169010aSmrg 1337c63293b5Smrg# func_resolve_sysroot PATH 1338c63293b5Smrg# Replace a leading = in PATH with a sysroot. Store the result into 1339c63293b5Smrg# func_resolve_sysroot_result 1340c63293b5Smrgfunc_resolve_sysroot () 1341c63293b5Smrg{ 1342c63293b5Smrg func_resolve_sysroot_result=$1 1343c63293b5Smrg case $func_resolve_sysroot_result in 1344c63293b5Smrg =*) 1345c63293b5Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 1346c63293b5Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 1347c63293b5Smrg ;; 1348c63293b5Smrg esac 1349c63293b5Smrg} 1350c63293b5Smrg 1351c63293b5Smrg# func_replace_sysroot PATH 1352c63293b5Smrg# If PATH begins with the sysroot, replace it with = and 1353c63293b5Smrg# store the result into func_replace_sysroot_result. 1354c63293b5Smrgfunc_replace_sysroot () 1355c63293b5Smrg{ 1356c63293b5Smrg case "$lt_sysroot:$1" in 1357c63293b5Smrg ?*:"$lt_sysroot"*) 1358c63293b5Smrg func_stripname "$lt_sysroot" '' "$1" 1359c63293b5Smrg func_replace_sysroot_result="=$func_stripname_result" 1360c63293b5Smrg ;; 1361c63293b5Smrg *) 1362c63293b5Smrg # Including no sysroot. 1363c63293b5Smrg func_replace_sysroot_result=$1 1364c63293b5Smrg ;; 1365c63293b5Smrg esac 1366c63293b5Smrg} 1367c63293b5Smrg 1368e169010aSmrg# func_infer_tag arg 1369e169010aSmrg# Infer tagged configuration to use if any are available and 1370e169010aSmrg# if one wasn't chosen via the "--tag" command line option. 1371e169010aSmrg# Only attempt this if the compiler in the base compile 1372e169010aSmrg# command doesn't match the default compiler. 1373e169010aSmrg# arg is usually of the form 'gcc ...' 1374e169010aSmrgfunc_infer_tag () 1375e169010aSmrg{ 1376e169010aSmrg $opt_debug 1377e169010aSmrg if test -n "$available_tags" && test -z "$tagname"; then 1378e169010aSmrg CC_quoted= 1379e169010aSmrg for arg in $CC; do 1380c63293b5Smrg func_append_quoted CC_quoted "$arg" 1381e169010aSmrg done 1382e8ead290Smrg CC_expanded=`func_echo_all $CC` 1383e8ead290Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 1384e169010aSmrg case $@ in 1385e169010aSmrg # Blanks in the command may have been stripped by the calling shell, 1386e169010aSmrg # but not from the CC environment variable when configure was run. 1387e8ead290Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1388e8ead290Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 1389e169010aSmrg # Blanks at the start of $base_compile will cause this to fail 1390e169010aSmrg # if we don't check for them as well. 1391e169010aSmrg *) 1392e169010aSmrg for z in $available_tags; do 1393e169010aSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 1394e169010aSmrg # Evaluate the configuration. 1395e169010aSmrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 1396e169010aSmrg CC_quoted= 1397e169010aSmrg for arg in $CC; do 1398e169010aSmrg # Double-quote args containing other shell metacharacters. 1399c63293b5Smrg func_append_quoted CC_quoted "$arg" 1400e169010aSmrg done 1401e8ead290Smrg CC_expanded=`func_echo_all $CC` 1402e8ead290Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 1403e169010aSmrg case "$@ " in 1404e8ead290Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1405e8ead290Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 1406e169010aSmrg # The compiler in the base compile command matches 1407e169010aSmrg # the one in the tagged configuration. 1408e169010aSmrg # Assume this is the tagged configuration we want. 1409e169010aSmrg tagname=$z 1410e169010aSmrg break 1411e169010aSmrg ;; 14127914d74bSmrg esac 1413e169010aSmrg fi 1414e169010aSmrg done 1415e169010aSmrg # If $tagname still isn't set, then no tagged configuration 1416e169010aSmrg # was found and let the user know that the "--tag" command 1417e169010aSmrg # line option must be used. 1418e169010aSmrg if test -z "$tagname"; then 1419e169010aSmrg func_echo "unable to infer tagged configuration" 1420e169010aSmrg func_fatal_error "specify a tag with \`--tag'" 1421e169010aSmrg# else 1422e169010aSmrg# func_verbose "using $tagname tagged configuration" 1423e169010aSmrg fi 1424e169010aSmrg ;; 1425e169010aSmrg esac 1426e169010aSmrg fi 1427e169010aSmrg} 1428e169010aSmrg 1429e169010aSmrg 1430e169010aSmrg 1431c63293b5Smrg# func_write_libtool_object output_name pic_name nonpic_name 1432c63293b5Smrg# Create a libtool object file (analogous to a ".la" file), 1433c63293b5Smrg# but don't create it if we're doing a dry run. 1434c63293b5Smrgfunc_write_libtool_object () 1435c63293b5Smrg{ 1436c63293b5Smrg write_libobj=${1} 1437c63293b5Smrg if test "$build_libtool_libs" = yes; then 1438c63293b5Smrg write_lobj=\'${2}\' 1439c63293b5Smrg else 1440c63293b5Smrg write_lobj=none 1441c63293b5Smrg fi 1442c63293b5Smrg 1443c63293b5Smrg if test "$build_old_libs" = yes; then 1444c63293b5Smrg write_oldobj=\'${3}\' 1445c63293b5Smrg else 1446c63293b5Smrg write_oldobj=none 1447c63293b5Smrg fi 1448c63293b5Smrg 1449c63293b5Smrg $opt_dry_run || { 1450c63293b5Smrg cat >${write_libobj}T <<EOF 1451c63293b5Smrg# $write_libobj - a libtool object file 1452c63293b5Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 1453c63293b5Smrg# 1454c63293b5Smrg# Please DO NOT delete this file! 1455c63293b5Smrg# It is necessary for linking the library. 1456c63293b5Smrg 1457c63293b5Smrg# Name of the PIC object. 1458c63293b5Smrgpic_object=$write_lobj 1459c63293b5Smrg 1460c63293b5Smrg# Name of the non-PIC object 1461c63293b5Smrgnon_pic_object=$write_oldobj 1462c63293b5Smrg 1463c63293b5SmrgEOF 1464c63293b5Smrg $MV "${write_libobj}T" "${write_libobj}" 1465c63293b5Smrg } 1466c63293b5Smrg} 1467c63293b5Smrg 1468c63293b5Smrg 1469c63293b5Smrg################################################## 1470c63293b5Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 1471c63293b5Smrg################################################## 1472c63293b5Smrg 1473c63293b5Smrg# func_convert_core_file_wine_to_w32 ARG 1474c63293b5Smrg# Helper function used by file name conversion functions when $build is *nix, 1475c63293b5Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 1476c63293b5Smrg# correctly configured wine environment available, with the winepath program 1477c63293b5Smrg# in $build's $PATH. 1478c63293b5Smrg# 1479c63293b5Smrg# ARG is the $build file name to be converted to w32 format. 1480c63293b5Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 1481c63293b5Smrg# be empty on error (or when ARG is empty) 1482c63293b5Smrgfunc_convert_core_file_wine_to_w32 () 1483c63293b5Smrg{ 1484c63293b5Smrg $opt_debug 1485c63293b5Smrg func_convert_core_file_wine_to_w32_result="$1" 1486c63293b5Smrg if test -n "$1"; then 1487c63293b5Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 1488c63293b5Smrg # are forced to check the contents of stdout. On the other hand, if the 1489c63293b5Smrg # command is not found, the shell will set an exit code of 127 and print 1490c63293b5Smrg # *an error message* to stdout. So we must check for both error code of 1491c63293b5Smrg # zero AND non-empty stdout, which explains the odd construction: 1492c63293b5Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 1493c63293b5Smrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 1494c63293b5Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 1495c63293b5Smrg $SED -e "$lt_sed_naive_backslashify"` 1496c63293b5Smrg else 1497c63293b5Smrg func_convert_core_file_wine_to_w32_result= 1498c63293b5Smrg fi 1499c63293b5Smrg fi 1500c63293b5Smrg} 1501c63293b5Smrg# end: func_convert_core_file_wine_to_w32 1502c63293b5Smrg 1503c63293b5Smrg 1504c63293b5Smrg# func_convert_core_path_wine_to_w32 ARG 1505c63293b5Smrg# Helper function used by path conversion functions when $build is *nix, and 1506c63293b5Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 1507c63293b5Smrg# configured wine environment available, with the winepath program in $build's 1508c63293b5Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 1509c63293b5Smrg# 1510c63293b5Smrg# ARG is path to be converted from $build format to win32. 1511c63293b5Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 1512c63293b5Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 1513c63293b5Smrg# are convertible, then the result may be empty. 1514c63293b5Smrgfunc_convert_core_path_wine_to_w32 () 1515c63293b5Smrg{ 1516c63293b5Smrg $opt_debug 1517c63293b5Smrg # unfortunately, winepath doesn't convert paths, only file names 1518c63293b5Smrg func_convert_core_path_wine_to_w32_result="" 1519c63293b5Smrg if test -n "$1"; then 1520c63293b5Smrg oldIFS=$IFS 1521c63293b5Smrg IFS=: 1522c63293b5Smrg for func_convert_core_path_wine_to_w32_f in $1; do 1523c63293b5Smrg IFS=$oldIFS 1524c63293b5Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 1525c63293b5Smrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 1526c63293b5Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 1527c63293b5Smrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 1528c63293b5Smrg else 1529c63293b5Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 1530c63293b5Smrg fi 1531c63293b5Smrg fi 1532c63293b5Smrg done 1533c63293b5Smrg IFS=$oldIFS 1534c63293b5Smrg fi 1535c63293b5Smrg} 1536c63293b5Smrg# end: func_convert_core_path_wine_to_w32 1537c63293b5Smrg 1538c63293b5Smrg 1539c63293b5Smrg# func_cygpath ARGS... 1540c63293b5Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 1541c63293b5Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 1542c63293b5Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 1543c63293b5Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 1544c63293b5Smrg# file name or path is assumed to be in w32 format, as previously converted 1545c63293b5Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 1546c63293b5Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 1547c63293b5Smrg# Cygwin format). Returns an empty string on error. 1548c63293b5Smrg# 1549c63293b5Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 1550c63293b5Smrg# be converted. 1551c63293b5Smrg# 1552c63293b5Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 1553c63293b5Smrg# environment variable; do not put it in $PATH. 1554c63293b5Smrgfunc_cygpath () 1555c63293b5Smrg{ 1556c63293b5Smrg $opt_debug 1557c63293b5Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 1558c63293b5Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 1559c63293b5Smrg if test "$?" -ne 0; then 1560c63293b5Smrg # on failure, ensure result is empty 1561c63293b5Smrg func_cygpath_result= 1562c63293b5Smrg fi 1563c63293b5Smrg else 1564c63293b5Smrg func_cygpath_result= 1565c63293b5Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 1566c63293b5Smrg fi 1567c63293b5Smrg} 1568c63293b5Smrg#end: func_cygpath 1569c63293b5Smrg 1570c63293b5Smrg 1571c63293b5Smrg# func_convert_core_msys_to_w32 ARG 1572c63293b5Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 1573c63293b5Smrg# result in func_convert_core_msys_to_w32_result. 1574c63293b5Smrgfunc_convert_core_msys_to_w32 () 1575c63293b5Smrg{ 1576c63293b5Smrg $opt_debug 1577c63293b5Smrg # awkward: cmd appends spaces to result 1578c63293b5Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 1579c63293b5Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 1580c63293b5Smrg} 1581c63293b5Smrg#end: func_convert_core_msys_to_w32 1582c63293b5Smrg 1583c63293b5Smrg 1584c63293b5Smrg# func_convert_file_check ARG1 ARG2 1585c63293b5Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 1586c63293b5Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 1587c63293b5Smrg# func_to_host_file_result to ARG1). 1588c63293b5Smrgfunc_convert_file_check () 1589c63293b5Smrg{ 1590c63293b5Smrg $opt_debug 1591c63293b5Smrg if test -z "$2" && test -n "$1" ; then 1592c63293b5Smrg func_error "Could not determine host file name corresponding to" 1593c63293b5Smrg func_error " \`$1'" 1594c63293b5Smrg func_error "Continuing, but uninstalled executables may not work." 1595c63293b5Smrg # Fallback: 1596c63293b5Smrg func_to_host_file_result="$1" 1597c63293b5Smrg fi 1598c63293b5Smrg} 1599c63293b5Smrg# end func_convert_file_check 1600c63293b5Smrg 1601c63293b5Smrg 1602c63293b5Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 1603c63293b5Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 1604c63293b5Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 1605c63293b5Smrg# func_to_host_file_result to a simplistic fallback value (see below). 1606c63293b5Smrgfunc_convert_path_check () 1607c63293b5Smrg{ 1608c63293b5Smrg $opt_debug 1609c63293b5Smrg if test -z "$4" && test -n "$3"; then 1610c63293b5Smrg func_error "Could not determine the host path corresponding to" 1611c63293b5Smrg func_error " \`$3'" 1612c63293b5Smrg func_error "Continuing, but uninstalled executables may not work." 1613c63293b5Smrg # Fallback. This is a deliberately simplistic "conversion" and 1614c63293b5Smrg # should not be "improved". See libtool.info. 1615c63293b5Smrg if test "x$1" != "x$2"; then 1616c63293b5Smrg lt_replace_pathsep_chars="s|$1|$2|g" 1617c63293b5Smrg func_to_host_path_result=`echo "$3" | 1618c63293b5Smrg $SED -e "$lt_replace_pathsep_chars"` 1619c63293b5Smrg else 1620c63293b5Smrg func_to_host_path_result="$3" 1621c63293b5Smrg fi 1622c63293b5Smrg fi 1623c63293b5Smrg} 1624c63293b5Smrg# end func_convert_path_check 1625c63293b5Smrg 1626c63293b5Smrg 1627c63293b5Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 1628c63293b5Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 1629c63293b5Smrg# and appending REPL if ORIG matches BACKPAT. 1630c63293b5Smrgfunc_convert_path_front_back_pathsep () 1631c63293b5Smrg{ 1632c63293b5Smrg $opt_debug 1633c63293b5Smrg case $4 in 1634c63293b5Smrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 1635c63293b5Smrg ;; 1636c63293b5Smrg esac 1637c63293b5Smrg case $4 in 1638c63293b5Smrg $2 ) func_append func_to_host_path_result "$3" 1639c63293b5Smrg ;; 1640c63293b5Smrg esac 1641c63293b5Smrg} 1642c63293b5Smrg# end func_convert_path_front_back_pathsep 1643c63293b5Smrg 1644c63293b5Smrg 1645c63293b5Smrg################################################## 1646c63293b5Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 1647c63293b5Smrg################################################## 1648c63293b5Smrg# invoked via `$to_host_file_cmd ARG' 1649c63293b5Smrg# 1650c63293b5Smrg# In each case, ARG is the path to be converted from $build to $host format. 1651c63293b5Smrg# Result will be available in $func_to_host_file_result. 1652c63293b5Smrg 1653c63293b5Smrg 1654c63293b5Smrg# func_to_host_file ARG 1655c63293b5Smrg# Converts the file name ARG from $build format to $host format. Return result 1656c63293b5Smrg# in func_to_host_file_result. 1657c63293b5Smrgfunc_to_host_file () 1658c63293b5Smrg{ 1659c63293b5Smrg $opt_debug 1660c63293b5Smrg $to_host_file_cmd "$1" 1661c63293b5Smrg} 1662c63293b5Smrg# end func_to_host_file 1663c63293b5Smrg 1664c63293b5Smrg 1665c63293b5Smrg# func_to_tool_file ARG LAZY 1666c63293b5Smrg# converts the file name ARG from $build format to toolchain format. Return 1667c63293b5Smrg# result in func_to_tool_file_result. If the conversion in use is listed 1668c63293b5Smrg# in (the comma separated) LAZY, no conversion takes place. 1669c63293b5Smrgfunc_to_tool_file () 1670c63293b5Smrg{ 1671c63293b5Smrg $opt_debug 1672c63293b5Smrg case ,$2, in 1673c63293b5Smrg *,"$to_tool_file_cmd",*) 1674c63293b5Smrg func_to_tool_file_result=$1 1675c63293b5Smrg ;; 1676c63293b5Smrg *) 1677c63293b5Smrg $to_tool_file_cmd "$1" 1678c63293b5Smrg func_to_tool_file_result=$func_to_host_file_result 1679c63293b5Smrg ;; 1680c63293b5Smrg esac 1681c63293b5Smrg} 1682c63293b5Smrg# end func_to_tool_file 1683c63293b5Smrg 1684c63293b5Smrg 1685c63293b5Smrg# func_convert_file_noop ARG 1686c63293b5Smrg# Copy ARG to func_to_host_file_result. 1687c63293b5Smrgfunc_convert_file_noop () 1688c63293b5Smrg{ 1689c63293b5Smrg func_to_host_file_result="$1" 1690c63293b5Smrg} 1691c63293b5Smrg# end func_convert_file_noop 1692c63293b5Smrg 1693c63293b5Smrg 1694c63293b5Smrg# func_convert_file_msys_to_w32 ARG 1695c63293b5Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 1696c63293b5Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 1697c63293b5Smrg# func_to_host_file_result. 1698c63293b5Smrgfunc_convert_file_msys_to_w32 () 1699c63293b5Smrg{ 1700c63293b5Smrg $opt_debug 1701c63293b5Smrg func_to_host_file_result="$1" 1702c63293b5Smrg if test -n "$1"; then 1703c63293b5Smrg func_convert_core_msys_to_w32 "$1" 1704c63293b5Smrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 1705c63293b5Smrg fi 1706c63293b5Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1707c63293b5Smrg} 1708c63293b5Smrg# end func_convert_file_msys_to_w32 1709c63293b5Smrg 1710c63293b5Smrg 1711c63293b5Smrg# func_convert_file_cygwin_to_w32 ARG 1712c63293b5Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 1713c63293b5Smrg# func_to_host_file_result. 1714c63293b5Smrgfunc_convert_file_cygwin_to_w32 () 1715c63293b5Smrg{ 1716c63293b5Smrg $opt_debug 1717c63293b5Smrg func_to_host_file_result="$1" 1718c63293b5Smrg if test -n "$1"; then 1719c63293b5Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 1720c63293b5Smrg # LT_CYGPATH in this case. 1721c63293b5Smrg func_to_host_file_result=`cygpath -m "$1"` 1722c63293b5Smrg fi 1723c63293b5Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1724c63293b5Smrg} 1725c63293b5Smrg# end func_convert_file_cygwin_to_w32 1726c63293b5Smrg 1727c63293b5Smrg 1728c63293b5Smrg# func_convert_file_nix_to_w32 ARG 1729c63293b5Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 1730c63293b5Smrg# and a working winepath. Returns result in func_to_host_file_result. 1731c63293b5Smrgfunc_convert_file_nix_to_w32 () 1732c63293b5Smrg{ 1733c63293b5Smrg $opt_debug 1734c63293b5Smrg func_to_host_file_result="$1" 1735c63293b5Smrg if test -n "$1"; then 1736c63293b5Smrg func_convert_core_file_wine_to_w32 "$1" 1737c63293b5Smrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 1738c63293b5Smrg fi 1739c63293b5Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1740c63293b5Smrg} 1741c63293b5Smrg# end func_convert_file_nix_to_w32 1742c63293b5Smrg 1743c63293b5Smrg 1744c63293b5Smrg# func_convert_file_msys_to_cygwin ARG 1745c63293b5Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1746c63293b5Smrg# Returns result in func_to_host_file_result. 1747c63293b5Smrgfunc_convert_file_msys_to_cygwin () 1748c63293b5Smrg{ 1749c63293b5Smrg $opt_debug 1750c63293b5Smrg func_to_host_file_result="$1" 1751c63293b5Smrg if test -n "$1"; then 1752c63293b5Smrg func_convert_core_msys_to_w32 "$1" 1753c63293b5Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 1754c63293b5Smrg func_to_host_file_result="$func_cygpath_result" 1755c63293b5Smrg fi 1756c63293b5Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1757c63293b5Smrg} 1758c63293b5Smrg# end func_convert_file_msys_to_cygwin 1759c63293b5Smrg 1760c63293b5Smrg 1761c63293b5Smrg# func_convert_file_nix_to_cygwin ARG 1762c63293b5Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 1763c63293b5Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 1764c63293b5Smrg# in func_to_host_file_result. 1765c63293b5Smrgfunc_convert_file_nix_to_cygwin () 1766c63293b5Smrg{ 1767c63293b5Smrg $opt_debug 1768c63293b5Smrg func_to_host_file_result="$1" 1769c63293b5Smrg if test -n "$1"; then 1770c63293b5Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 1771c63293b5Smrg func_convert_core_file_wine_to_w32 "$1" 1772c63293b5Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 1773c63293b5Smrg func_to_host_file_result="$func_cygpath_result" 1774c63293b5Smrg fi 1775c63293b5Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1776c63293b5Smrg} 1777c63293b5Smrg# end func_convert_file_nix_to_cygwin 1778c63293b5Smrg 1779c63293b5Smrg 1780c63293b5Smrg############################################# 1781c63293b5Smrg# $build to $host PATH CONVERSION FUNCTIONS # 1782c63293b5Smrg############################################# 1783c63293b5Smrg# invoked via `$to_host_path_cmd ARG' 1784c63293b5Smrg# 1785c63293b5Smrg# In each case, ARG is the path to be converted from $build to $host format. 1786c63293b5Smrg# The result will be available in $func_to_host_path_result. 1787c63293b5Smrg# 1788c63293b5Smrg# Path separators are also converted from $build format to $host format. If 1789c63293b5Smrg# ARG begins or ends with a path separator character, it is preserved (but 1790c63293b5Smrg# converted to $host format) on output. 1791c63293b5Smrg# 1792c63293b5Smrg# All path conversion functions are named using the following convention: 1793c63293b5Smrg# file name conversion function : func_convert_file_X_to_Y () 1794c63293b5Smrg# path conversion function : func_convert_path_X_to_Y () 1795c63293b5Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 1796c63293b5Smrg# same. If conversion functions are added for new $build/$host combinations, 1797c63293b5Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 1798c63293b5Smrg# will break. 1799c63293b5Smrg 1800c63293b5Smrg 1801c63293b5Smrg# func_init_to_host_path_cmd 1802c63293b5Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 1803c63293b5Smrg# appropriate value, based on the value of $to_host_file_cmd. 1804c63293b5Smrgto_host_path_cmd= 1805c63293b5Smrgfunc_init_to_host_path_cmd () 1806c63293b5Smrg{ 1807c63293b5Smrg $opt_debug 1808c63293b5Smrg if test -z "$to_host_path_cmd"; then 1809c63293b5Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 1810c63293b5Smrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 1811c63293b5Smrg fi 1812c63293b5Smrg} 1813c63293b5Smrg 1814c63293b5Smrg 1815c63293b5Smrg# func_to_host_path ARG 1816c63293b5Smrg# Converts the path ARG from $build format to $host format. Return result 1817c63293b5Smrg# in func_to_host_path_result. 1818c63293b5Smrgfunc_to_host_path () 1819c63293b5Smrg{ 1820c63293b5Smrg $opt_debug 1821c63293b5Smrg func_init_to_host_path_cmd 1822c63293b5Smrg $to_host_path_cmd "$1" 1823c63293b5Smrg} 1824c63293b5Smrg# end func_to_host_path 1825c63293b5Smrg 1826c63293b5Smrg 1827c63293b5Smrg# func_convert_path_noop ARG 1828c63293b5Smrg# Copy ARG to func_to_host_path_result. 1829c63293b5Smrgfunc_convert_path_noop () 1830c63293b5Smrg{ 1831c63293b5Smrg func_to_host_path_result="$1" 1832c63293b5Smrg} 1833c63293b5Smrg# end func_convert_path_noop 1834c63293b5Smrg 1835c63293b5Smrg 1836c63293b5Smrg# func_convert_path_msys_to_w32 ARG 1837c63293b5Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 1838c63293b5Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 1839c63293b5Smrg# func_to_host_path_result. 1840c63293b5Smrgfunc_convert_path_msys_to_w32 () 1841e169010aSmrg{ 1842c63293b5Smrg $opt_debug 1843c63293b5Smrg func_to_host_path_result="$1" 1844c63293b5Smrg if test -n "$1"; then 1845c63293b5Smrg # Remove leading and trailing path separator characters from ARG. MSYS 1846c63293b5Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 1847c63293b5Smrg # and winepath ignores them completely. 1848c63293b5Smrg func_stripname : : "$1" 1849c63293b5Smrg func_to_host_path_tmp1=$func_stripname_result 1850c63293b5Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1851c63293b5Smrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 1852c63293b5Smrg func_convert_path_check : ";" \ 1853c63293b5Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1854c63293b5Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1855c63293b5Smrg fi 1856c63293b5Smrg} 1857c63293b5Smrg# end func_convert_path_msys_to_w32 1858e169010aSmrg 1859e169010aSmrg 1860c63293b5Smrg# func_convert_path_cygwin_to_w32 ARG 1861c63293b5Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 1862c63293b5Smrg# func_to_host_file_result. 1863c63293b5Smrgfunc_convert_path_cygwin_to_w32 () 1864c63293b5Smrg{ 1865c63293b5Smrg $opt_debug 1866c63293b5Smrg func_to_host_path_result="$1" 1867c63293b5Smrg if test -n "$1"; then 1868c63293b5Smrg # See func_convert_path_msys_to_w32: 1869c63293b5Smrg func_stripname : : "$1" 1870c63293b5Smrg func_to_host_path_tmp1=$func_stripname_result 1871c63293b5Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 1872c63293b5Smrg func_convert_path_check : ";" \ 1873c63293b5Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1874c63293b5Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1875c63293b5Smrg fi 1876c63293b5Smrg} 1877c63293b5Smrg# end func_convert_path_cygwin_to_w32 1878e169010aSmrg 1879e169010aSmrg 1880c63293b5Smrg# func_convert_path_nix_to_w32 ARG 1881c63293b5Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 1882c63293b5Smrg# a working winepath. Returns result in func_to_host_file_result. 1883c63293b5Smrgfunc_convert_path_nix_to_w32 () 1884c63293b5Smrg{ 1885c63293b5Smrg $opt_debug 1886c63293b5Smrg func_to_host_path_result="$1" 1887c63293b5Smrg if test -n "$1"; then 1888c63293b5Smrg # See func_convert_path_msys_to_w32: 1889c63293b5Smrg func_stripname : : "$1" 1890c63293b5Smrg func_to_host_path_tmp1=$func_stripname_result 1891c63293b5Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1892c63293b5Smrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 1893c63293b5Smrg func_convert_path_check : ";" \ 1894c63293b5Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1895c63293b5Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1896c63293b5Smrg fi 1897c63293b5Smrg} 1898c63293b5Smrg# end func_convert_path_nix_to_w32 1899e169010aSmrg 1900c63293b5Smrg 1901c63293b5Smrg# func_convert_path_msys_to_cygwin ARG 1902c63293b5Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1903c63293b5Smrg# Returns result in func_to_host_file_result. 1904c63293b5Smrgfunc_convert_path_msys_to_cygwin () 1905c63293b5Smrg{ 1906c63293b5Smrg $opt_debug 1907c63293b5Smrg func_to_host_path_result="$1" 1908c63293b5Smrg if test -n "$1"; then 1909c63293b5Smrg # See func_convert_path_msys_to_w32: 1910c63293b5Smrg func_stripname : : "$1" 1911c63293b5Smrg func_to_host_path_tmp1=$func_stripname_result 1912c63293b5Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1913c63293b5Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 1914c63293b5Smrg func_to_host_path_result="$func_cygpath_result" 1915c63293b5Smrg func_convert_path_check : : \ 1916c63293b5Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1917c63293b5Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1918c63293b5Smrg fi 1919c63293b5Smrg} 1920c63293b5Smrg# end func_convert_path_msys_to_cygwin 1921c63293b5Smrg 1922c63293b5Smrg 1923c63293b5Smrg# func_convert_path_nix_to_cygwin ARG 1924c63293b5Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 1925c63293b5Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 1926c63293b5Smrg# func_to_host_file_result. 1927c63293b5Smrgfunc_convert_path_nix_to_cygwin () 1928c63293b5Smrg{ 1929c63293b5Smrg $opt_debug 1930c63293b5Smrg func_to_host_path_result="$1" 1931c63293b5Smrg if test -n "$1"; then 1932c63293b5Smrg # Remove leading and trailing path separator characters from 1933c63293b5Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 1934c63293b5Smrg # into '.;' and ';.', and winepath ignores them completely. 1935c63293b5Smrg func_stripname : : "$1" 1936c63293b5Smrg func_to_host_path_tmp1=$func_stripname_result 1937c63293b5Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1938c63293b5Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 1939c63293b5Smrg func_to_host_path_result="$func_cygpath_result" 1940c63293b5Smrg func_convert_path_check : : \ 1941c63293b5Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1942c63293b5Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1943c63293b5Smrg fi 1944e169010aSmrg} 1945c63293b5Smrg# end func_convert_path_nix_to_cygwin 1946c63293b5Smrg 1947e169010aSmrg 1948e169010aSmrg# func_mode_compile arg... 1949e169010aSmrgfunc_mode_compile () 1950e169010aSmrg{ 1951e169010aSmrg $opt_debug 1952e169010aSmrg # Get the compilation command and the source file. 1953e169010aSmrg base_compile= 1954e169010aSmrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 1955e169010aSmrg suppress_opt=yes 1956e169010aSmrg suppress_output= 1957e169010aSmrg arg_mode=normal 1958e169010aSmrg libobj= 1959e169010aSmrg later= 1960e169010aSmrg pie_flag= 1961e169010aSmrg 1962e169010aSmrg for arg 1963e169010aSmrg do 1964e169010aSmrg case $arg_mode in 1965e169010aSmrg arg ) 1966e169010aSmrg # do not "continue". Instead, add this to base_compile 1967e169010aSmrg lastarg="$arg" 1968e169010aSmrg arg_mode=normal 1969e169010aSmrg ;; 1970e169010aSmrg 1971e169010aSmrg target ) 1972e169010aSmrg libobj="$arg" 1973e169010aSmrg arg_mode=normal 1974e169010aSmrg continue 1975e169010aSmrg ;; 1976e169010aSmrg 1977e169010aSmrg normal ) 1978e169010aSmrg # Accept any command-line options. 1979e169010aSmrg case $arg in 1980e169010aSmrg -o) 1981e169010aSmrg test -n "$libobj" && \ 1982e169010aSmrg func_fatal_error "you cannot specify \`-o' more than once" 1983e169010aSmrg arg_mode=target 1984e169010aSmrg continue 1985e169010aSmrg ;; 1986e169010aSmrg 1987e169010aSmrg -pie | -fpie | -fPIE) 1988c63293b5Smrg func_append pie_flag " $arg" 1989e169010aSmrg continue 1990e169010aSmrg ;; 1991e169010aSmrg 1992e169010aSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 1993c63293b5Smrg func_append later " $arg" 1994e169010aSmrg continue 1995e169010aSmrg ;; 1996e169010aSmrg 1997e169010aSmrg -no-suppress) 1998e169010aSmrg suppress_opt=no 1999e169010aSmrg continue 2000e169010aSmrg ;; 2001e169010aSmrg 2002e169010aSmrg -Xcompiler) 2003e169010aSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 2004e169010aSmrg continue # The current "srcfile" will either be retained or 2005e169010aSmrg ;; # replaced later. I would guess that would be a bug. 2006e169010aSmrg 2007e169010aSmrg -Wc,*) 2008e169010aSmrg func_stripname '-Wc,' '' "$arg" 2009e169010aSmrg args=$func_stripname_result 2010e169010aSmrg lastarg= 2011e169010aSmrg save_ifs="$IFS"; IFS=',' 2012e169010aSmrg for arg in $args; do 2013e169010aSmrg IFS="$save_ifs" 2014c63293b5Smrg func_append_quoted lastarg "$arg" 20157914d74bSmrg done 20167914d74bSmrg IFS="$save_ifs" 2017e169010aSmrg func_stripname ' ' '' "$lastarg" 2018e169010aSmrg lastarg=$func_stripname_result 20197914d74bSmrg 20207914d74bSmrg # Add the arguments to base_compile. 2021c63293b5Smrg func_append base_compile " $lastarg" 20227914d74bSmrg continue 20237914d74bSmrg ;; 20247914d74bSmrg 2025e169010aSmrg *) 20267914d74bSmrg # Accept the current argument as the source file. 20277914d74bSmrg # The previous "srcfile" becomes the current argument. 20287914d74bSmrg # 20297914d74bSmrg lastarg="$srcfile" 20307914d74bSmrg srcfile="$arg" 20317914d74bSmrg ;; 20327914d74bSmrg esac # case $arg 20337914d74bSmrg ;; 20347914d74bSmrg esac # case $arg_mode 20357914d74bSmrg 20367914d74bSmrg # Aesthetically quote the previous argument. 2037c63293b5Smrg func_append_quoted base_compile "$lastarg" 20387914d74bSmrg done # for arg 20397914d74bSmrg 20407914d74bSmrg case $arg_mode in 20417914d74bSmrg arg) 2042e169010aSmrg func_fatal_error "you must specify an argument for -Xcompile" 20437914d74bSmrg ;; 20447914d74bSmrg target) 2045e169010aSmrg func_fatal_error "you must specify a target with \`-o'" 20467914d74bSmrg ;; 20477914d74bSmrg *) 20487914d74bSmrg # Get the name of the library object. 2049e169010aSmrg test -z "$libobj" && { 2050e169010aSmrg func_basename "$srcfile" 2051e169010aSmrg libobj="$func_basename_result" 2052e169010aSmrg } 20537914d74bSmrg ;; 20547914d74bSmrg esac 20557914d74bSmrg 20567914d74bSmrg # Recognize several different file suffixes. 20577914d74bSmrg # If the user specifies -o file.o, it is replaced with file.lo 20587914d74bSmrg case $libobj in 2059e169010aSmrg *.[cCFSifmso] | \ 2060e169010aSmrg *.ada | *.adb | *.ads | *.asm | \ 2061e169010aSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 2062e8ead290Smrg *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup) 2063e169010aSmrg func_xform "$libobj" 2064e169010aSmrg libobj=$func_xform_result 2065e169010aSmrg ;; 20667914d74bSmrg esac 20677914d74bSmrg 20687914d74bSmrg case $libobj in 2069e169010aSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 20707914d74bSmrg *) 2071e169010aSmrg func_fatal_error "cannot determine name of library object from \`$libobj'" 20727914d74bSmrg ;; 20737914d74bSmrg esac 20747914d74bSmrg 20757914d74bSmrg func_infer_tag $base_compile 20767914d74bSmrg 20777914d74bSmrg for arg in $later; do 20787914d74bSmrg case $arg in 2079e169010aSmrg -shared) 2080e169010aSmrg test "$build_libtool_libs" != yes && \ 2081e169010aSmrg func_fatal_configuration "can not build a shared library" 2082e169010aSmrg build_old_libs=no 2083e169010aSmrg continue 2084e169010aSmrg ;; 2085e169010aSmrg 20867914d74bSmrg -static) 2087e169010aSmrg build_libtool_libs=no 20887914d74bSmrg build_old_libs=yes 20897914d74bSmrg continue 20907914d74bSmrg ;; 20917914d74bSmrg 20927914d74bSmrg -prefer-pic) 20937914d74bSmrg pic_mode=yes 20947914d74bSmrg continue 20957914d74bSmrg ;; 20967914d74bSmrg 20977914d74bSmrg -prefer-non-pic) 20987914d74bSmrg pic_mode=no 20997914d74bSmrg continue 21007914d74bSmrg ;; 21017914d74bSmrg esac 21027914d74bSmrg done 21037914d74bSmrg 2104e169010aSmrg func_quote_for_eval "$libobj" 2105e169010aSmrg test "X$libobj" != "X$func_quote_for_eval_result" \ 2106e169010aSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 2107e169010aSmrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 2108e169010aSmrg func_dirname_and_basename "$obj" "/" "" 2109e169010aSmrg objname="$func_basename_result" 2110e169010aSmrg xdir="$func_dirname_result" 21117914d74bSmrg lobj=${xdir}$objdir/$objname 21127914d74bSmrg 2113e169010aSmrg test -z "$base_compile" && \ 2114e169010aSmrg func_fatal_help "you must specify a compilation command" 21157914d74bSmrg 21167914d74bSmrg # Delete any leftover library objects. 21177914d74bSmrg if test "$build_old_libs" = yes; then 21187914d74bSmrg removelist="$obj $lobj $libobj ${libobj}T" 21197914d74bSmrg else 21207914d74bSmrg removelist="$lobj $libobj ${libobj}T" 21217914d74bSmrg fi 21227914d74bSmrg 21237914d74bSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 21247914d74bSmrg case $host_os in 2125e169010aSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 21267914d74bSmrg pic_mode=default 21277914d74bSmrg ;; 21287914d74bSmrg esac 21297914d74bSmrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 21307914d74bSmrg # non-PIC code in shared libraries is not supported 21317914d74bSmrg pic_mode=default 21327914d74bSmrg fi 21337914d74bSmrg 21347914d74bSmrg # Calculate the filename of the output object if compiler does 21357914d74bSmrg # not support -o with -c 21367914d74bSmrg if test "$compiler_c_o" = no; then 2137e8ead290Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 21387914d74bSmrg lockfile="$output_obj.lock" 21397914d74bSmrg else 21407914d74bSmrg output_obj= 21417914d74bSmrg need_locks=no 21427914d74bSmrg lockfile= 21437914d74bSmrg fi 21447914d74bSmrg 21457914d74bSmrg # Lock this critical section if it is needed 21467914d74bSmrg # We use this script file to make the link, it avoids creating a new file 21477914d74bSmrg if test "$need_locks" = yes; then 2148e169010aSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 2149e169010aSmrg func_echo "Waiting for $lockfile to be removed" 21507914d74bSmrg sleep 2 21517914d74bSmrg done 21527914d74bSmrg elif test "$need_locks" = warn; then 21537914d74bSmrg if test -f "$lockfile"; then 2154e169010aSmrg $ECHO "\ 21557914d74bSmrg*** ERROR, $lockfile exists and contains: 21567914d74bSmrg`cat $lockfile 2>/dev/null` 21577914d74bSmrg 21587914d74bSmrgThis indicates that another process is trying to use the same 21597914d74bSmrgtemporary object file, and libtool could not work around it because 21607914d74bSmrgyour compiler does not support \`-c' and \`-o' together. If you 21617914d74bSmrgrepeat this compilation, it may succeed, by chance, but you had better 21627914d74bSmrgavoid parallel builds (make -j) in this platform, or get a better 21637914d74bSmrgcompiler." 21647914d74bSmrg 2165e169010aSmrg $opt_dry_run || $RM $removelist 21667914d74bSmrg exit $EXIT_FAILURE 21677914d74bSmrg fi 2168c63293b5Smrg func_append removelist " $output_obj" 2169e169010aSmrg $ECHO "$srcfile" > "$lockfile" 21707914d74bSmrg fi 21717914d74bSmrg 2172e169010aSmrg $opt_dry_run || $RM $removelist 2173c63293b5Smrg func_append removelist " $lockfile" 2174e169010aSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 2175e169010aSmrg 2176c63293b5Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 2177c63293b5Smrg srcfile=$func_to_tool_file_result 2178e169010aSmrg func_quote_for_eval "$srcfile" 2179e169010aSmrg qsrcfile=$func_quote_for_eval_result 21807914d74bSmrg 21817914d74bSmrg # Only build a PIC object if we are building libtool libraries. 21827914d74bSmrg if test "$build_libtool_libs" = yes; then 21837914d74bSmrg # Without this assignment, base_compile gets emptied. 21847914d74bSmrg fbsd_hideous_sh_bug=$base_compile 21857914d74bSmrg 21867914d74bSmrg if test "$pic_mode" != no; then 21877914d74bSmrg command="$base_compile $qsrcfile $pic_flag" 21887914d74bSmrg else 21897914d74bSmrg # Don't build PIC code 21907914d74bSmrg command="$base_compile $qsrcfile" 21917914d74bSmrg fi 21927914d74bSmrg 2193e169010aSmrg func_mkdir_p "$xdir$objdir" 21947914d74bSmrg 21957914d74bSmrg if test -z "$output_obj"; then 21967914d74bSmrg # Place PIC objects in $objdir 2197c63293b5Smrg func_append command " -o $lobj" 21987914d74bSmrg fi 21997914d74bSmrg 2200e169010aSmrg func_show_eval_locale "$command" \ 2201e169010aSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 22027914d74bSmrg 22037914d74bSmrg if test "$need_locks" = warn && 22047914d74bSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2205e169010aSmrg $ECHO "\ 22067914d74bSmrg*** ERROR, $lockfile contains: 22077914d74bSmrg`cat $lockfile 2>/dev/null` 22087914d74bSmrg 22097914d74bSmrgbut it should contain: 22107914d74bSmrg$srcfile 22117914d74bSmrg 22127914d74bSmrgThis indicates that another process is trying to use the same 22137914d74bSmrgtemporary object file, and libtool could not work around it because 22147914d74bSmrgyour compiler does not support \`-c' and \`-o' together. If you 22157914d74bSmrgrepeat this compilation, it may succeed, by chance, but you had better 22167914d74bSmrgavoid parallel builds (make -j) in this platform, or get a better 22177914d74bSmrgcompiler." 22187914d74bSmrg 2219e169010aSmrg $opt_dry_run || $RM $removelist 22207914d74bSmrg exit $EXIT_FAILURE 22217914d74bSmrg fi 22227914d74bSmrg 22237914d74bSmrg # Just move the object if needed, then go on to compile the next one 22247914d74bSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 2225e169010aSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 2226e169010aSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 22277914d74bSmrg fi 22287914d74bSmrg 22297914d74bSmrg # Allow error messages only from the first compilation. 22307914d74bSmrg if test "$suppress_opt" = yes; then 2231e169010aSmrg suppress_output=' >/dev/null 2>&1' 22327914d74bSmrg fi 22337914d74bSmrg fi 22347914d74bSmrg 22357914d74bSmrg # Only build a position-dependent object if we build old libraries. 22367914d74bSmrg if test "$build_old_libs" = yes; then 22377914d74bSmrg if test "$pic_mode" != yes; then 22387914d74bSmrg # Don't build PIC code 2239e169010aSmrg command="$base_compile $qsrcfile$pie_flag" 22407914d74bSmrg else 22417914d74bSmrg command="$base_compile $qsrcfile $pic_flag" 22427914d74bSmrg fi 22437914d74bSmrg if test "$compiler_c_o" = yes; then 2244c63293b5Smrg func_append command " -o $obj" 22457914d74bSmrg fi 22467914d74bSmrg 22477914d74bSmrg # Suppress compiler output if we already did a PIC compilation. 2248c63293b5Smrg func_append command "$suppress_output" 2249e169010aSmrg func_show_eval_locale "$command" \ 2250e169010aSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 22517914d74bSmrg 22527914d74bSmrg if test "$need_locks" = warn && 22537914d74bSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2254e169010aSmrg $ECHO "\ 22557914d74bSmrg*** ERROR, $lockfile contains: 22567914d74bSmrg`cat $lockfile 2>/dev/null` 22577914d74bSmrg 22587914d74bSmrgbut it should contain: 22597914d74bSmrg$srcfile 22607914d74bSmrg 22617914d74bSmrgThis indicates that another process is trying to use the same 22627914d74bSmrgtemporary object file, and libtool could not work around it because 22637914d74bSmrgyour compiler does not support \`-c' and \`-o' together. If you 22647914d74bSmrgrepeat this compilation, it may succeed, by chance, but you had better 22657914d74bSmrgavoid parallel builds (make -j) in this platform, or get a better 22667914d74bSmrgcompiler." 22677914d74bSmrg 2268e169010aSmrg $opt_dry_run || $RM $removelist 22697914d74bSmrg exit $EXIT_FAILURE 22707914d74bSmrg fi 22717914d74bSmrg 22727914d74bSmrg # Just move the object if needed 22737914d74bSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 2274e169010aSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 2275e169010aSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 22767914d74bSmrg fi 22777914d74bSmrg fi 22787914d74bSmrg 2279e169010aSmrg $opt_dry_run || { 2280e169010aSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 22817914d74bSmrg 2282e169010aSmrg # Unlock the critical section if it was locked 2283e169010aSmrg if test "$need_locks" != no; then 2284e169010aSmrg removelist=$lockfile 2285e169010aSmrg $RM "$lockfile" 2286e169010aSmrg fi 2287e169010aSmrg } 22887914d74bSmrg 22897914d74bSmrg exit $EXIT_SUCCESS 2290e169010aSmrg} 22917914d74bSmrg 2292e169010aSmrg$opt_help || { 2293c63293b5Smrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 2294e169010aSmrg} 22957914d74bSmrg 2296e169010aSmrgfunc_mode_help () 2297e169010aSmrg{ 2298e169010aSmrg # We need to display help for each of the modes. 2299c63293b5Smrg case $opt_mode in 2300e169010aSmrg "") 2301e169010aSmrg # Generic help is extracted from the usage comments 2302e169010aSmrg # at the start of this file. 2303e169010aSmrg func_help 2304e169010aSmrg ;; 23057914d74bSmrg 2306e169010aSmrg clean) 2307e169010aSmrg $ECHO \ 2308e169010aSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 23097914d74bSmrg 2310e169010aSmrgRemove files from the build directory. 23117914d74bSmrg 2312e169010aSmrgRM is the name of the program to use to delete files associated with each FILE 2313e169010aSmrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2314e169010aSmrgto RM. 23157914d74bSmrg 2316e169010aSmrgIf FILE is a libtool library, object or program, all the files associated 2317e169010aSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 2318e169010aSmrg ;; 23197914d74bSmrg 2320e169010aSmrg compile) 2321e169010aSmrg $ECHO \ 2322e169010aSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 23237914d74bSmrg 2324e169010aSmrgCompile a source file into a libtool library object. 23257914d74bSmrg 2326e169010aSmrgThis mode accepts the following additional options: 23277914d74bSmrg 2328e169010aSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 2329e169010aSmrg -no-suppress do not suppress compiler output for multiple passes 2330e8ead290Smrg -prefer-pic try to build PIC objects only 2331e8ead290Smrg -prefer-non-pic try to build non-PIC objects only 2332e169010aSmrg -shared do not build a \`.o' file suitable for static linking 2333e169010aSmrg -static only build a \`.o' file suitable for static linking 2334e8ead290Smrg -Wc,FLAG pass FLAG directly to the compiler 23357914d74bSmrg 2336e169010aSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 2337e169010aSmrgfrom the given SOURCEFILE. 23387914d74bSmrg 2339e169010aSmrgThe output file name is determined by removing the directory component from 2340e169010aSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 2341e169010aSmrglibrary object suffix, \`.lo'." 2342e169010aSmrg ;; 23437914d74bSmrg 2344e169010aSmrg execute) 2345e169010aSmrg $ECHO \ 2346e169010aSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 23477914d74bSmrg 2348e169010aSmrgAutomatically set library path, then run a program. 23497914d74bSmrg 2350e169010aSmrgThis mode accepts the following additional options: 23517914d74bSmrg 2352e169010aSmrg -dlopen FILE add the directory containing FILE to the library path 23537914d74bSmrg 2354e169010aSmrgThis mode sets the library path environment variable according to \`-dlopen' 2355e169010aSmrgflags. 23567914d74bSmrg 2357e169010aSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 2358e169010aSmrginto their corresponding uninstalled binary, and any of their required library 2359e169010aSmrgdirectories are added to the library path. 23607914d74bSmrg 2361e169010aSmrgThen, COMMAND is executed, with ARGS as arguments." 2362e169010aSmrg ;; 23637914d74bSmrg 2364e169010aSmrg finish) 2365e169010aSmrg $ECHO \ 2366e169010aSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 23677914d74bSmrg 2368e169010aSmrgComplete the installation of libtool libraries. 23697914d74bSmrg 2370e169010aSmrgEach LIBDIR is a directory that contains libtool libraries. 23717914d74bSmrg 2372e169010aSmrgThe commands that this mode executes may require superuser privileges. Use 2373e169010aSmrgthe \`--dry-run' option if you just want to see what would be executed." 2374e169010aSmrg ;; 23757914d74bSmrg 2376e169010aSmrg install) 2377e169010aSmrg $ECHO \ 2378e169010aSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 23797914d74bSmrg 2380e169010aSmrgInstall executables or libraries. 23817914d74bSmrg 2382e169010aSmrgINSTALL-COMMAND is the installation command. The first component should be 2383e169010aSmrgeither the \`install' or \`cp' program. 23847914d74bSmrg 2385e169010aSmrgThe following components of INSTALL-COMMAND are treated specially: 23867914d74bSmrg 2387e8ead290Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 23887914d74bSmrg 2389e169010aSmrgThe rest of the components are interpreted as arguments to that command (only 2390e169010aSmrgBSD-compatible install options are recognized)." 2391e169010aSmrg ;; 23927914d74bSmrg 2393e169010aSmrg link) 2394e169010aSmrg $ECHO \ 2395e169010aSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 23967914d74bSmrg 2397e169010aSmrgLink object files or libraries together to form another library, or to 2398e169010aSmrgcreate an executable program. 23997914d74bSmrg 2400e169010aSmrgLINK-COMMAND is a command using the C compiler that you would use to create 2401e169010aSmrga program from several object files. 24027914d74bSmrg 2403e169010aSmrgThe following components of LINK-COMMAND are treated specially: 24047914d74bSmrg 2405e169010aSmrg -all-static do not do any dynamic linking at all 2406e169010aSmrg -avoid-version do not add a version suffix if possible 2407e8ead290Smrg -bindir BINDIR specify path to binaries directory (for systems where 2408e8ead290Smrg libraries must be found in the PATH setting at runtime) 2409e169010aSmrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 2410e169010aSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 2411e169010aSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 2412e169010aSmrg -export-symbols SYMFILE 2413e169010aSmrg try to export only the symbols listed in SYMFILE 2414e169010aSmrg -export-symbols-regex REGEX 2415e169010aSmrg try to export only the symbols matching REGEX 2416e169010aSmrg -LLIBDIR search LIBDIR for required installed libraries 2417e169010aSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 2418e169010aSmrg -module build a library that can dlopened 2419e169010aSmrg -no-fast-install disable the fast-install mode 2420e169010aSmrg -no-install link a not-installable executable 2421e169010aSmrg -no-undefined declare that a library does not refer to external symbols 2422e169010aSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 2423e169010aSmrg -objectlist FILE Use a list of object files found in FILE to specify objects 2424e169010aSmrg -precious-files-regex REGEX 2425e169010aSmrg don't remove output files matching REGEX 2426e169010aSmrg -release RELEASE specify package release information 2427e169010aSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 2428e169010aSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 2429e169010aSmrg -shared only do dynamic linking of libtool libraries 2430e169010aSmrg -shrext SUFFIX override the standard shared library file extension 2431e169010aSmrg -static do not do any dynamic linking of uninstalled libtool libraries 2432e169010aSmrg -static-libtool-libs 2433e169010aSmrg do not do any dynamic linking of libtool libraries 2434e169010aSmrg -version-info CURRENT[:REVISION[:AGE]] 2435e169010aSmrg specify library version info [each variable defaults to 0] 2436e169010aSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 2437e8ead290Smrg -Wc,FLAG 2438e8ead290Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 2439e8ead290Smrg -Wl,FLAG 2440e8ead290Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 2441e8ead290Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 24427914d74bSmrg 2443e169010aSmrgAll other options (arguments beginning with \`-') are ignored. 24447914d74bSmrg 2445e169010aSmrgEvery other argument is treated as a filename. Files ending in \`.la' are 2446e169010aSmrgtreated as uninstalled libtool libraries, other files are standard or library 2447e169010aSmrgobject files. 24487914d74bSmrg 2449e169010aSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 2450e169010aSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 2451e169010aSmrgrequired, except when creating a convenience library. 24527914d74bSmrg 2453e169010aSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 2454e169010aSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 24557914d74bSmrg 2456e169010aSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 2457e169010aSmrgis created, otherwise an executable program is created." 24587914d74bSmrg ;; 24597914d74bSmrg 2460e169010aSmrg uninstall) 2461e169010aSmrg $ECHO \ 2462e169010aSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 24637914d74bSmrg 2464e169010aSmrgRemove libraries from an installation directory. 24657914d74bSmrg 2466e169010aSmrgRM is the name of the program to use to delete files associated with each FILE 2467e169010aSmrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2468e169010aSmrgto RM. 24697914d74bSmrg 2470e169010aSmrgIf FILE is a libtool library, all the files associated with it are deleted. 2471e169010aSmrgOtherwise, only FILE itself is deleted using RM." 2472e169010aSmrg ;; 24737914d74bSmrg 2474e169010aSmrg *) 2475c63293b5Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 2476e169010aSmrg ;; 2477e169010aSmrg esac 24787914d74bSmrg 2479e8ead290Smrg echo 2480e169010aSmrg $ECHO "Try \`$progname --help' for more information about other modes." 2481e169010aSmrg} 24827914d74bSmrg 2483e8ead290Smrg# Now that we've collected a possible --mode arg, show help if necessary 2484e8ead290Smrgif $opt_help; then 2485e8ead290Smrg if test "$opt_help" = :; then 2486e8ead290Smrg func_mode_help 2487e8ead290Smrg else 2488e8ead290Smrg { 2489e8ead290Smrg func_help noexit 2490c63293b5Smrg for opt_mode in compile link execute install finish uninstall clean; do 2491e8ead290Smrg func_mode_help 2492e8ead290Smrg done 2493e8ead290Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 2494e8ead290Smrg { 2495e8ead290Smrg func_help noexit 2496c63293b5Smrg for opt_mode in compile link execute install finish uninstall clean; do 2497e8ead290Smrg echo 2498e8ead290Smrg func_mode_help 2499e8ead290Smrg done 2500e8ead290Smrg } | 2501e8ead290Smrg sed '1d 2502e8ead290Smrg /^When reporting/,/^Report/{ 2503e8ead290Smrg H 2504e8ead290Smrg d 2505e8ead290Smrg } 2506e8ead290Smrg $x 2507e8ead290Smrg /information about other modes/d 2508e8ead290Smrg /more detailed .*MODE/d 2509e8ead290Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 2510e8ead290Smrg fi 2511e8ead290Smrg exit $? 2512e8ead290Smrgfi 25137914d74bSmrg 25147914d74bSmrg 2515e169010aSmrg# func_mode_execute arg... 2516e169010aSmrgfunc_mode_execute () 2517e169010aSmrg{ 2518e169010aSmrg $opt_debug 2519e169010aSmrg # The first argument is the command name. 2520e169010aSmrg cmd="$nonopt" 2521e169010aSmrg test -z "$cmd" && \ 2522e169010aSmrg func_fatal_help "you must specify a COMMAND" 25237914d74bSmrg 2524e169010aSmrg # Handle -dlopen flags immediately. 2525c63293b5Smrg for file in $opt_dlopen; do 2526e169010aSmrg test -f "$file" \ 2527e169010aSmrg || func_fatal_help "\`$file' is not a file" 25287914d74bSmrg 2529e169010aSmrg dir= 2530e169010aSmrg case $file in 2531e169010aSmrg *.la) 2532c63293b5Smrg func_resolve_sysroot "$file" 2533c63293b5Smrg file=$func_resolve_sysroot_result 2534c63293b5Smrg 2535e169010aSmrg # Check to see that this really is a libtool archive. 2536e169010aSmrg func_lalib_unsafe_p "$file" \ 2537e169010aSmrg || func_fatal_help "\`$lib' is not a valid libtool archive" 25387914d74bSmrg 2539e169010aSmrg # Read the libtool library. 2540e169010aSmrg dlname= 2541e169010aSmrg library_names= 2542e169010aSmrg func_source "$file" 25437914d74bSmrg 2544e169010aSmrg # Skip this library if it cannot be dlopened. 2545e169010aSmrg if test -z "$dlname"; then 2546e169010aSmrg # Warn if it was a shared library. 2547e169010aSmrg test -n "$library_names" && \ 2548e169010aSmrg func_warning "\`$file' was not linked with \`-export-dynamic'" 2549e169010aSmrg continue 2550e169010aSmrg fi 25517914d74bSmrg 2552e169010aSmrg func_dirname "$file" "" "." 2553e169010aSmrg dir="$func_dirname_result" 25547914d74bSmrg 2555e169010aSmrg if test -f "$dir/$objdir/$dlname"; then 2556c63293b5Smrg func_append dir "/$objdir" 2557e169010aSmrg else 2558e169010aSmrg if test ! -f "$dir/$dlname"; then 2559e169010aSmrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 2560e169010aSmrg fi 2561e169010aSmrg fi 25627914d74bSmrg ;; 25637914d74bSmrg 2564e169010aSmrg *.lo) 2565e169010aSmrg # Just add the directory containing the .lo file. 2566e169010aSmrg func_dirname "$file" "" "." 2567e169010aSmrg dir="$func_dirname_result" 25687914d74bSmrg ;; 25697914d74bSmrg 2570e169010aSmrg *) 2571e169010aSmrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 25727914d74bSmrg continue 25737914d74bSmrg ;; 2574e169010aSmrg esac 25757914d74bSmrg 2576e169010aSmrg # Get the absolute pathname. 2577e169010aSmrg absdir=`cd "$dir" && pwd` 2578e169010aSmrg test -n "$absdir" && dir="$absdir" 25797914d74bSmrg 2580e169010aSmrg # Now add the directory to shlibpath_var. 2581e169010aSmrg if eval "test -z \"\$$shlibpath_var\""; then 2582e169010aSmrg eval "$shlibpath_var=\"\$dir\"" 2583e169010aSmrg else 2584e169010aSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 2585e169010aSmrg fi 2586e169010aSmrg done 25877914d74bSmrg 2588e169010aSmrg # This variable tells wrapper scripts just to set shlibpath_var 2589e169010aSmrg # rather than running their programs. 2590e169010aSmrg libtool_execute_magic="$magic" 25917914d74bSmrg 2592e169010aSmrg # Check if any of the arguments is a wrapper script. 2593e169010aSmrg args= 2594e169010aSmrg for file 2595e169010aSmrg do 2596e169010aSmrg case $file in 2597e8ead290Smrg -* | *.la | *.lo ) ;; 2598e169010aSmrg *) 2599e169010aSmrg # Do a test to see if this is really a libtool program. 2600e169010aSmrg if func_ltwrapper_script_p "$file"; then 2601e169010aSmrg func_source "$file" 2602e169010aSmrg # Transform arg to wrapped name. 2603e169010aSmrg file="$progdir/$program" 2604e169010aSmrg elif func_ltwrapper_executable_p "$file"; then 2605e169010aSmrg func_ltwrapper_scriptname "$file" 2606e169010aSmrg func_source "$func_ltwrapper_scriptname_result" 2607e169010aSmrg # Transform arg to wrapped name. 2608e169010aSmrg file="$progdir/$program" 2609e169010aSmrg fi 2610e169010aSmrg ;; 2611e169010aSmrg esac 2612e169010aSmrg # Quote arguments (to preserve shell metacharacters). 2613c63293b5Smrg func_append_quoted args "$file" 2614e169010aSmrg done 26157914d74bSmrg 2616e169010aSmrg if test "X$opt_dry_run" = Xfalse; then 2617e169010aSmrg if test -n "$shlibpath_var"; then 2618e169010aSmrg # Export the shlibpath_var. 2619e169010aSmrg eval "export $shlibpath_var" 2620e169010aSmrg fi 26217914d74bSmrg 2622e169010aSmrg # Restore saved environment variables 2623e169010aSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 2624e169010aSmrg do 2625e169010aSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 2626e169010aSmrg $lt_var=\$save_$lt_var; export $lt_var 2627e169010aSmrg else 2628e169010aSmrg $lt_unset $lt_var 2629e169010aSmrg fi" 2630e169010aSmrg done 26317914d74bSmrg 2632e169010aSmrg # Now prepare to actually exec the command. 2633e169010aSmrg exec_cmd="\$cmd$args" 2634e169010aSmrg else 2635e169010aSmrg # Display what would be done. 2636e169010aSmrg if test -n "$shlibpath_var"; then 2637e169010aSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 2638e8ead290Smrg echo "export $shlibpath_var" 2639e169010aSmrg fi 2640e169010aSmrg $ECHO "$cmd$args" 2641e169010aSmrg exit $EXIT_SUCCESS 2642e169010aSmrg fi 2643e169010aSmrg} 26447914d74bSmrg 2645c63293b5Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 26467914d74bSmrg 26477914d74bSmrg 2648e169010aSmrg# func_mode_finish arg... 2649e169010aSmrgfunc_mode_finish () 2650e169010aSmrg{ 2651e169010aSmrg $opt_debug 2652c63293b5Smrg libs= 2653c63293b5Smrg libdirs= 2654e169010aSmrg admincmds= 26557914d74bSmrg 2656c63293b5Smrg for opt in "$nonopt" ${1+"$@"} 2657c63293b5Smrg do 2658c63293b5Smrg if test -d "$opt"; then 2659c63293b5Smrg func_append libdirs " $opt" 2660c63293b5Smrg 2661c63293b5Smrg elif test -f "$opt"; then 2662c63293b5Smrg if func_lalib_unsafe_p "$opt"; then 2663c63293b5Smrg func_append libs " $opt" 2664c63293b5Smrg else 2665c63293b5Smrg func_warning "\`$opt' is not a valid libtool archive" 2666c63293b5Smrg fi 2667c63293b5Smrg 2668c63293b5Smrg else 2669c63293b5Smrg func_fatal_error "invalid argument \`$opt'" 2670c63293b5Smrg fi 2671c63293b5Smrg done 2672c63293b5Smrg 2673c63293b5Smrg if test -n "$libs"; then 2674c63293b5Smrg if test -n "$lt_sysroot"; then 2675c63293b5Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 2676c63293b5Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 2677c63293b5Smrg else 2678c63293b5Smrg sysroot_cmd= 2679c63293b5Smrg fi 2680c63293b5Smrg 2681c63293b5Smrg # Remove sysroot references 2682c63293b5Smrg if $opt_dry_run; then 2683c63293b5Smrg for lib in $libs; do 2684c63293b5Smrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 2685c63293b5Smrg done 2686c63293b5Smrg else 2687c63293b5Smrg tmpdir=`func_mktempdir` 2688c63293b5Smrg for lib in $libs; do 2689c63293b5Smrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 2690c63293b5Smrg > $tmpdir/tmp-la 2691c63293b5Smrg mv -f $tmpdir/tmp-la $lib 2692c63293b5Smrg done 2693c63293b5Smrg ${RM}r "$tmpdir" 2694c63293b5Smrg fi 2695c63293b5Smrg fi 26967914d74bSmrg 2697c63293b5Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2698e169010aSmrg for libdir in $libdirs; do 2699e169010aSmrg if test -n "$finish_cmds"; then 2700e169010aSmrg # Do each command in the finish commands. 2701e169010aSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 2702e169010aSmrg'"$cmd"'"' 2703e169010aSmrg fi 2704e169010aSmrg if test -n "$finish_eval"; then 2705e169010aSmrg # Do the single finish_eval. 2706e169010aSmrg eval cmds=\"$finish_eval\" 2707c63293b5Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 2708e169010aSmrg $cmds" 2709e169010aSmrg fi 2710e169010aSmrg done 2711e169010aSmrg fi 27127914d74bSmrg 2713e169010aSmrg # Exit here if they wanted silent mode. 2714e169010aSmrg $opt_silent && exit $EXIT_SUCCESS 27157914d74bSmrg 2716c63293b5Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2717c63293b5Smrg echo "----------------------------------------------------------------------" 2718c63293b5Smrg echo "Libraries have been installed in:" 2719c63293b5Smrg for libdir in $libdirs; do 2720c63293b5Smrg $ECHO " $libdir" 2721c63293b5Smrg done 2722c63293b5Smrg echo 2723c63293b5Smrg echo "If you ever happen to want to link against installed libraries" 2724c63293b5Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 2725c63293b5Smrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 2726c63293b5Smrg echo "flag during linking and do at least one of the following:" 2727c63293b5Smrg if test -n "$shlibpath_var"; then 2728c63293b5Smrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 2729c63293b5Smrg echo " during execution" 2730c63293b5Smrg fi 2731c63293b5Smrg if test -n "$runpath_var"; then 2732c63293b5Smrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 2733c63293b5Smrg echo " during linking" 2734c63293b5Smrg fi 2735c63293b5Smrg if test -n "$hardcode_libdir_flag_spec"; then 2736c63293b5Smrg libdir=LIBDIR 2737c63293b5Smrg eval flag=\"$hardcode_libdir_flag_spec\" 27387914d74bSmrg 2739c63293b5Smrg $ECHO " - use the \`$flag' linker flag" 2740c63293b5Smrg fi 2741c63293b5Smrg if test -n "$admincmds"; then 2742c63293b5Smrg $ECHO " - have your system administrator run these commands:$admincmds" 2743c63293b5Smrg fi 2744c63293b5Smrg if test -f /etc/ld.so.conf; then 2745c63293b5Smrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 2746c63293b5Smrg fi 2747c63293b5Smrg echo 27487914d74bSmrg 2749c63293b5Smrg echo "See any operating system documentation about shared libraries for" 2750c63293b5Smrg case $host in 2751c63293b5Smrg solaris2.[6789]|solaris2.1[0-9]) 2752c63293b5Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 2753c63293b5Smrg echo "pages." 2754c63293b5Smrg ;; 2755c63293b5Smrg *) 2756c63293b5Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 2757c63293b5Smrg ;; 2758c63293b5Smrg esac 2759c63293b5Smrg echo "----------------------------------------------------------------------" 2760c63293b5Smrg fi 2761e169010aSmrg exit $EXIT_SUCCESS 2762e169010aSmrg} 27637914d74bSmrg 2764c63293b5Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 27657914d74bSmrg 27667914d74bSmrg 2767e169010aSmrg# func_mode_install arg... 2768e169010aSmrgfunc_mode_install () 2769e169010aSmrg{ 2770e169010aSmrg $opt_debug 2771e169010aSmrg # There may be an optional sh(1) argument at the beginning of 2772e169010aSmrg # install_prog (especially on Windows NT). 2773e169010aSmrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 2774e169010aSmrg # Allow the use of GNU shtool's install command. 2775e8ead290Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 2776e169010aSmrg # Aesthetically quote it. 2777e169010aSmrg func_quote_for_eval "$nonopt" 2778e169010aSmrg install_prog="$func_quote_for_eval_result " 2779e169010aSmrg arg=$1 2780e169010aSmrg shift 2781e169010aSmrg else 2782e169010aSmrg install_prog= 2783e169010aSmrg arg=$nonopt 2784e169010aSmrg fi 27857914d74bSmrg 2786e169010aSmrg # The real first argument should be the name of the installation program. 2787e169010aSmrg # Aesthetically quote it. 2788e169010aSmrg func_quote_for_eval "$arg" 2789c63293b5Smrg func_append install_prog "$func_quote_for_eval_result" 2790e8ead290Smrg install_shared_prog=$install_prog 2791e8ead290Smrg case " $install_prog " in 2792e8ead290Smrg *[\\\ /]cp\ *) install_cp=: ;; 2793e8ead290Smrg *) install_cp=false ;; 2794e8ead290Smrg esac 2795e169010aSmrg 2796e169010aSmrg # We need to accept at least all the BSD install flags. 2797e169010aSmrg dest= 2798e169010aSmrg files= 2799e169010aSmrg opts= 2800e169010aSmrg prev= 2801e169010aSmrg install_type= 2802e169010aSmrg isdir=no 2803e169010aSmrg stripme= 2804e8ead290Smrg no_mode=: 2805e169010aSmrg for arg 2806e169010aSmrg do 2807e8ead290Smrg arg2= 2808e169010aSmrg if test -n "$dest"; then 2809c63293b5Smrg func_append files " $dest" 2810e169010aSmrg dest=$arg 2811e169010aSmrg continue 28127914d74bSmrg fi 28137914d74bSmrg 2814e169010aSmrg case $arg in 2815e169010aSmrg -d) isdir=yes ;; 2816e169010aSmrg -f) 2817e8ead290Smrg if $install_cp; then :; else 2818e8ead290Smrg prev=$arg 2819e8ead290Smrg fi 2820e169010aSmrg ;; 2821e169010aSmrg -g | -m | -o) 2822e169010aSmrg prev=$arg 2823e169010aSmrg ;; 2824e169010aSmrg -s) 2825e169010aSmrg stripme=" -s" 2826e169010aSmrg continue 2827e169010aSmrg ;; 2828e169010aSmrg -*) 2829e169010aSmrg ;; 2830e169010aSmrg *) 2831e169010aSmrg # If the previous option needed an argument, then skip it. 2832e169010aSmrg if test -n "$prev"; then 2833e8ead290Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 2834e8ead290Smrg arg2=$install_override_mode 2835e8ead290Smrg no_mode=false 2836e8ead290Smrg fi 2837e169010aSmrg prev= 2838e169010aSmrg else 2839e169010aSmrg dest=$arg 2840e169010aSmrg continue 2841e169010aSmrg fi 2842e169010aSmrg ;; 2843e169010aSmrg esac 28447914d74bSmrg 2845e169010aSmrg # Aesthetically quote the argument. 2846e169010aSmrg func_quote_for_eval "$arg" 2847c63293b5Smrg func_append install_prog " $func_quote_for_eval_result" 2848e8ead290Smrg if test -n "$arg2"; then 2849e8ead290Smrg func_quote_for_eval "$arg2" 2850e8ead290Smrg fi 2851c63293b5Smrg func_append install_shared_prog " $func_quote_for_eval_result" 2852e169010aSmrg done 28537914d74bSmrg 2854e169010aSmrg test -z "$install_prog" && \ 2855e169010aSmrg func_fatal_help "you must specify an install program" 28567914d74bSmrg 2857e169010aSmrg test -n "$prev" && \ 2858e169010aSmrg func_fatal_help "the \`$prev' option requires an argument" 28597914d74bSmrg 2860e8ead290Smrg if test -n "$install_override_mode" && $no_mode; then 2861e8ead290Smrg if $install_cp; then :; else 2862e8ead290Smrg func_quote_for_eval "$install_override_mode" 2863c63293b5Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 2864e8ead290Smrg fi 2865e8ead290Smrg fi 2866e8ead290Smrg 2867e169010aSmrg if test -z "$files"; then 2868e169010aSmrg if test -z "$dest"; then 2869e169010aSmrg func_fatal_help "no file or destination specified" 2870e169010aSmrg else 2871e169010aSmrg func_fatal_help "you must specify a destination" 28727914d74bSmrg fi 28737914d74bSmrg fi 28747914d74bSmrg 2875e169010aSmrg # Strip any trailing slash from the destination. 2876e169010aSmrg func_stripname '' '/' "$dest" 2877e169010aSmrg dest=$func_stripname_result 28787914d74bSmrg 2879e169010aSmrg # Check to see that the destination is a directory. 2880e169010aSmrg test -d "$dest" && isdir=yes 2881e169010aSmrg if test "$isdir" = yes; then 2882e169010aSmrg destdir="$dest" 2883e169010aSmrg destname= 2884e169010aSmrg else 2885e169010aSmrg func_dirname_and_basename "$dest" "" "." 2886e169010aSmrg destdir="$func_dirname_result" 2887e169010aSmrg destname="$func_basename_result" 2888e169010aSmrg 2889e169010aSmrg # Not a directory, so check to see that there is only one file specified. 2890e169010aSmrg set dummy $files; shift 2891e169010aSmrg test "$#" -gt 1 && \ 2892e169010aSmrg func_fatal_help "\`$dest' is not a directory" 2893e169010aSmrg fi 2894e169010aSmrg case $destdir in 2895e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 28967914d74bSmrg *) 2897e169010aSmrg for file in $files; do 2898e169010aSmrg case $file in 2899e169010aSmrg *.lo) ;; 2900e169010aSmrg *) 2901e169010aSmrg func_fatal_help "\`$destdir' must be an absolute directory name" 2902e169010aSmrg ;; 2903e169010aSmrg esac 2904e169010aSmrg done 29057914d74bSmrg ;; 29067914d74bSmrg esac 29077914d74bSmrg 2908e169010aSmrg # This variable tells wrapper scripts just to set variables rather 2909e169010aSmrg # than running their programs. 2910e169010aSmrg libtool_install_magic="$magic" 29117914d74bSmrg 2912e169010aSmrg staticlibs= 2913e169010aSmrg future_libdirs= 2914e169010aSmrg current_libdirs= 2915e169010aSmrg for file in $files; do 29167914d74bSmrg 2917e169010aSmrg # Do each installation. 2918e169010aSmrg case $file in 2919e169010aSmrg *.$libext) 2920e169010aSmrg # Do the static libraries later. 2921c63293b5Smrg func_append staticlibs " $file" 2922e169010aSmrg ;; 2923e169010aSmrg 2924e169010aSmrg *.la) 2925c63293b5Smrg func_resolve_sysroot "$file" 2926c63293b5Smrg file=$func_resolve_sysroot_result 2927c63293b5Smrg 2928e169010aSmrg # Check to see that this really is a libtool archive. 2929e169010aSmrg func_lalib_unsafe_p "$file" \ 2930e169010aSmrg || func_fatal_help "\`$file' is not a valid libtool archive" 2931e169010aSmrg 2932e169010aSmrg library_names= 2933e169010aSmrg old_library= 2934e169010aSmrg relink_command= 2935e169010aSmrg func_source "$file" 2936e169010aSmrg 2937e169010aSmrg # Add the libdir to current_libdirs if it is the destination. 2938e169010aSmrg if test "X$destdir" = "X$libdir"; then 2939e169010aSmrg case "$current_libdirs " in 2940e169010aSmrg *" $libdir "*) ;; 2941c63293b5Smrg *) func_append current_libdirs " $libdir" ;; 29427914d74bSmrg esac 2943e169010aSmrg else 2944e169010aSmrg # Note the libdir as a future libdir. 2945e169010aSmrg case "$future_libdirs " in 2946e169010aSmrg *" $libdir "*) ;; 2947c63293b5Smrg *) func_append future_libdirs " $libdir" ;; 2948e169010aSmrg esac 2949e169010aSmrg fi 29507914d74bSmrg 2951e169010aSmrg func_dirname "$file" "/" "" 2952e169010aSmrg dir="$func_dirname_result" 2953c63293b5Smrg func_append dir "$objdir" 2954e169010aSmrg 2955e169010aSmrg if test -n "$relink_command"; then 2956e169010aSmrg # Determine the prefix the user has applied to our future dir. 2957e8ead290Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 2958e169010aSmrg 2959e169010aSmrg # Don't allow the user to place us outside of our expected 2960e169010aSmrg # location b/c this prevents finding dependent libraries that 2961e169010aSmrg # are installed to the same prefix. 2962e169010aSmrg # At present, this check doesn't affect windows .dll's that 2963e169010aSmrg # are installed into $libdir/../bin (currently, that works fine) 2964e169010aSmrg # but it's something to keep an eye on. 2965e169010aSmrg test "$inst_prefix_dir" = "$destdir" && \ 2966e169010aSmrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 2967e169010aSmrg 2968e169010aSmrg if test -n "$inst_prefix_dir"; then 2969e169010aSmrg # Stick the inst_prefix_dir data into the link command. 2970e8ead290Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 2971e169010aSmrg else 2972e8ead290Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 2973e169010aSmrg fi 2974e169010aSmrg 2975e169010aSmrg func_warning "relinking \`$file'" 2976e169010aSmrg func_show_eval "$relink_command" \ 2977e169010aSmrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 2978e169010aSmrg fi 2979e169010aSmrg 2980e169010aSmrg # See the names of the shared library. 2981e169010aSmrg set dummy $library_names; shift 2982e169010aSmrg if test -n "$1"; then 2983e169010aSmrg realname="$1" 2984e169010aSmrg shift 2985e169010aSmrg 2986e169010aSmrg srcname="$realname" 2987e169010aSmrg test -n "$relink_command" && srcname="$realname"T 2988e169010aSmrg 2989e169010aSmrg # Install the shared library and build the symlinks. 2990e8ead290Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 2991e169010aSmrg 'exit $?' 2992e169010aSmrg tstripme="$stripme" 2993e169010aSmrg case $host_os in 2994e169010aSmrg cygwin* | mingw* | pw32* | cegcc*) 2995e169010aSmrg case $realname in 2996e169010aSmrg *.dll.a) 2997e169010aSmrg tstripme="" 2998e169010aSmrg ;; 2999e169010aSmrg esac 30007914d74bSmrg ;; 30017914d74bSmrg esac 3002e169010aSmrg if test -n "$tstripme" && test -n "$striplib"; then 3003e169010aSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 30047914d74bSmrg fi 3005e169010aSmrg 3006e169010aSmrg if test "$#" -gt 0; then 3007e169010aSmrg # Delete the old symlinks, and create new ones. 3008e169010aSmrg # Try `ln -sf' first, because the `ln' binary might depend on 3009e169010aSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 3010e169010aSmrg # so we also need to try rm && ln -s. 3011e169010aSmrg for linkname 3012e169010aSmrg do 3013e169010aSmrg test "$linkname" != "$realname" \ 3014e169010aSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 30157914d74bSmrg done 30167914d74bSmrg fi 30177914d74bSmrg 3018e169010aSmrg # Do each command in the postinstall commands. 3019e169010aSmrg lib="$destdir/$realname" 3020e169010aSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 30217914d74bSmrg fi 30227914d74bSmrg 3023e169010aSmrg # Install the pseudo-library for information purposes. 3024e169010aSmrg func_basename "$file" 3025e169010aSmrg name="$func_basename_result" 3026e169010aSmrg instname="$dir/$name"i 3027e169010aSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 30287914d74bSmrg 3029e169010aSmrg # Maybe install the static library, too. 3030c63293b5Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 3031e169010aSmrg ;; 30327914d74bSmrg 3033e169010aSmrg *.lo) 3034e169010aSmrg # Install (i.e. copy) a libtool object. 30357914d74bSmrg 3036e169010aSmrg # Figure out destination file name, if it wasn't already specified. 3037e169010aSmrg if test -n "$destname"; then 3038e169010aSmrg destfile="$destdir/$destname" 3039e169010aSmrg else 3040e169010aSmrg func_basename "$file" 3041e169010aSmrg destfile="$func_basename_result" 3042e169010aSmrg destfile="$destdir/$destfile" 3043e169010aSmrg fi 3044e169010aSmrg 3045e169010aSmrg # Deduce the name of the destination old-style object file. 3046e169010aSmrg case $destfile in 3047e169010aSmrg *.lo) 3048e169010aSmrg func_lo2o "$destfile" 3049e169010aSmrg staticdest=$func_lo2o_result 3050e169010aSmrg ;; 3051e169010aSmrg *.$objext) 3052e169010aSmrg staticdest="$destfile" 3053e169010aSmrg destfile= 3054e169010aSmrg ;; 3055e169010aSmrg *) 3056e169010aSmrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 3057e169010aSmrg ;; 30587914d74bSmrg esac 30597914d74bSmrg 3060e169010aSmrg # Install the libtool object if requested. 3061e169010aSmrg test -n "$destfile" && \ 3062e169010aSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 3063e169010aSmrg 3064e169010aSmrg # Install the old object if enabled. 3065e169010aSmrg if test "$build_old_libs" = yes; then 3066e169010aSmrg # Deduce the name of the old-style object file. 3067e169010aSmrg func_lo2o "$file" 3068e169010aSmrg staticobj=$func_lo2o_result 3069e169010aSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 30707914d74bSmrg fi 3071e169010aSmrg exit $EXIT_SUCCESS 3072e169010aSmrg ;; 30737914d74bSmrg 3074e169010aSmrg *) 3075e169010aSmrg # Figure out destination file name, if it wasn't already specified. 3076e169010aSmrg if test -n "$destname"; then 3077e169010aSmrg destfile="$destdir/$destname" 3078e169010aSmrg else 3079e169010aSmrg func_basename "$file" 3080e169010aSmrg destfile="$func_basename_result" 3081e169010aSmrg destfile="$destdir/$destfile" 3082e169010aSmrg fi 3083e169010aSmrg 3084e169010aSmrg # If the file is missing, and there is a .exe on the end, strip it 3085e169010aSmrg # because it is most likely a libtool script we actually want to 3086e169010aSmrg # install 3087e169010aSmrg stripped_ext="" 3088e169010aSmrg case $file in 3089e169010aSmrg *.exe) 3090e169010aSmrg if test ! -f "$file"; then 3091e169010aSmrg func_stripname '' '.exe' "$file" 3092e169010aSmrg file=$func_stripname_result 3093e169010aSmrg stripped_ext=".exe" 30947914d74bSmrg fi 3095e169010aSmrg ;; 3096e169010aSmrg esac 30977914d74bSmrg 3098e169010aSmrg # Do a test to see if this is really a libtool program. 3099e169010aSmrg case $host in 3100e169010aSmrg *cygwin* | *mingw*) 3101e169010aSmrg if func_ltwrapper_executable_p "$file"; then 3102e169010aSmrg func_ltwrapper_scriptname "$file" 3103e169010aSmrg wrapper=$func_ltwrapper_scriptname_result 3104e169010aSmrg else 3105e169010aSmrg func_stripname '' '.exe' "$file" 3106e169010aSmrg wrapper=$func_stripname_result 3107e169010aSmrg fi 3108e169010aSmrg ;; 3109e169010aSmrg *) 3110e169010aSmrg wrapper=$file 3111e169010aSmrg ;; 3112e169010aSmrg esac 3113e169010aSmrg if func_ltwrapper_script_p "$wrapper"; then 3114e169010aSmrg notinst_deplibs= 3115e169010aSmrg relink_command= 31167914d74bSmrg 3117e169010aSmrg func_source "$wrapper" 31187914d74bSmrg 3119e169010aSmrg # Check the variables that should have been set. 3120e169010aSmrg test -z "$generated_by_libtool_version" && \ 3121e169010aSmrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 3122e169010aSmrg 3123e169010aSmrg finalize=yes 3124e169010aSmrg for lib in $notinst_deplibs; do 3125e169010aSmrg # Check to see that each library is installed. 3126e169010aSmrg libdir= 3127e169010aSmrg if test -f "$lib"; then 3128e169010aSmrg func_source "$lib" 3129e169010aSmrg fi 3130e8ead290Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 3131e169010aSmrg if test -n "$libdir" && test ! -f "$libfile"; then 3132e169010aSmrg func_warning "\`$lib' has not been installed in \`$libdir'" 3133e169010aSmrg finalize=no 3134e169010aSmrg fi 3135e169010aSmrg done 3136e169010aSmrg 3137e169010aSmrg relink_command= 3138e169010aSmrg func_source "$wrapper" 3139e169010aSmrg 3140e169010aSmrg outputname= 3141e169010aSmrg if test "$fast_install" = no && test -n "$relink_command"; then 3142e169010aSmrg $opt_dry_run || { 3143e169010aSmrg if test "$finalize" = yes; then 3144e169010aSmrg tmpdir=`func_mktempdir` 3145e169010aSmrg func_basename "$file$stripped_ext" 3146e169010aSmrg file="$func_basename_result" 3147e169010aSmrg outputname="$tmpdir/$file" 3148e169010aSmrg # Replace the output file specification. 3149e8ead290Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 3150e169010aSmrg 3151e169010aSmrg $opt_silent || { 3152e169010aSmrg func_quote_for_expand "$relink_command" 3153e169010aSmrg eval "func_echo $func_quote_for_expand_result" 3154e169010aSmrg } 3155e169010aSmrg if eval "$relink_command"; then : 3156e169010aSmrg else 3157e169010aSmrg func_error "error: relink \`$file' with the above command before installing it" 3158e169010aSmrg $opt_dry_run || ${RM}r "$tmpdir" 3159e169010aSmrg continue 3160e169010aSmrg fi 3161e169010aSmrg file="$outputname" 3162e169010aSmrg else 3163e169010aSmrg func_warning "cannot relink \`$file'" 3164e169010aSmrg fi 3165e169010aSmrg } 31667914d74bSmrg else 3167e169010aSmrg # Install the binary that we compiled earlier. 3168e8ead290Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 31697914d74bSmrg fi 3170e169010aSmrg fi 31717914d74bSmrg 3172e169010aSmrg # remove .exe since cygwin /usr/bin/install will append another 3173e169010aSmrg # one anyway 3174e169010aSmrg case $install_prog,$host in 3175e169010aSmrg */usr/bin/install*,*cygwin*) 3176e169010aSmrg case $file:$destfile in 3177e169010aSmrg *.exe:*.exe) 3178e169010aSmrg # this is ok 3179e169010aSmrg ;; 3180e169010aSmrg *.exe:*) 3181e169010aSmrg destfile=$destfile.exe 3182e169010aSmrg ;; 3183e169010aSmrg *:*.exe) 3184e169010aSmrg func_stripname '' '.exe' "$destfile" 3185e169010aSmrg destfile=$func_stripname_result 3186e169010aSmrg ;; 3187e169010aSmrg esac 31887914d74bSmrg ;; 31897914d74bSmrg esac 3190e169010aSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 3191e169010aSmrg $opt_dry_run || if test -n "$outputname"; then 3192e169010aSmrg ${RM}r "$tmpdir" 3193e169010aSmrg fi 3194e169010aSmrg ;; 3195e169010aSmrg esac 3196e169010aSmrg done 31977914d74bSmrg 3198e169010aSmrg for file in $staticlibs; do 3199e169010aSmrg func_basename "$file" 3200e169010aSmrg name="$func_basename_result" 32017914d74bSmrg 3202e169010aSmrg # Set up the ranlib parameters. 3203e169010aSmrg oldlib="$destdir/$name" 32047914d74bSmrg 3205e169010aSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 32067914d74bSmrg 3207e169010aSmrg if test -n "$stripme" && test -n "$old_striplib"; then 3208e169010aSmrg func_show_eval "$old_striplib $oldlib" 'exit $?' 3209e169010aSmrg fi 32107914d74bSmrg 3211e169010aSmrg # Do each command in the postinstall commands. 3212e169010aSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 3213e169010aSmrg done 32147914d74bSmrg 3215e169010aSmrg test -n "$future_libdirs" && \ 3216e169010aSmrg func_warning "remember to run \`$progname --finish$future_libdirs'" 32177914d74bSmrg 3218e169010aSmrg if test -n "$current_libdirs"; then 3219e169010aSmrg # Maybe just do a dry run. 3220e169010aSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 3221e169010aSmrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 3222e169010aSmrg else 3223e169010aSmrg exit $EXIT_SUCCESS 3224e169010aSmrg fi 3225e169010aSmrg} 32267914d74bSmrg 3227c63293b5Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 32287914d74bSmrg 32297914d74bSmrg 3230e169010aSmrg# func_generate_dlsyms outputname originator pic_p 3231e169010aSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 3232e169010aSmrg# a dlpreopen symbol table. 3233e169010aSmrgfunc_generate_dlsyms () 3234e169010aSmrg{ 3235e169010aSmrg $opt_debug 3236e169010aSmrg my_outputname="$1" 3237e169010aSmrg my_originator="$2" 3238e169010aSmrg my_pic_p="${3-no}" 3239e169010aSmrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 3240e169010aSmrg my_dlsyms= 3241e169010aSmrg 3242e169010aSmrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 3243e169010aSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 3244e169010aSmrg my_dlsyms="${my_outputname}S.c" 3245e169010aSmrg else 3246e169010aSmrg func_error "not configured to extract global symbols from dlpreopened files" 3247e169010aSmrg fi 3248e169010aSmrg fi 32497914d74bSmrg 3250e169010aSmrg if test -n "$my_dlsyms"; then 3251e169010aSmrg case $my_dlsyms in 3252e169010aSmrg "") ;; 3253e169010aSmrg *.c) 3254e169010aSmrg # Discover the nlist of each of the dlfiles. 3255e169010aSmrg nlist="$output_objdir/${my_outputname}.nm" 3256e169010aSmrg 3257e169010aSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 3258e169010aSmrg 3259e169010aSmrg # Parse the name list into a source file. 3260e169010aSmrg func_verbose "creating $output_objdir/$my_dlsyms" 3261e169010aSmrg 3262e169010aSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 3263e169010aSmrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 3264e169010aSmrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 3265e169010aSmrg 3266e169010aSmrg#ifdef __cplusplus 3267e169010aSmrgextern \"C\" { 3268e169010aSmrg#endif 3269e169010aSmrg 3270e8ead290Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 3271e8ead290Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 3272e8ead290Smrg#endif 3273e8ead290Smrg 3274c63293b5Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 3275c63293b5Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 3276c63293b5Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 3277c63293b5Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 3278c63293b5Smrg# define LT_DLSYM_CONST 3279c63293b5Smrg#elif defined(__osf__) 3280c63293b5Smrg/* This system does not cope well with relocations in const data. */ 3281c63293b5Smrg# define LT_DLSYM_CONST 3282c63293b5Smrg#else 3283c63293b5Smrg# define LT_DLSYM_CONST const 3284c63293b5Smrg#endif 3285c63293b5Smrg 3286e169010aSmrg/* External symbol declarations for the compiler. */\ 3287e169010aSmrg" 3288e169010aSmrg 3289e169010aSmrg if test "$dlself" = yes; then 3290e169010aSmrg func_verbose "generating symbol list for \`$output'" 3291e169010aSmrg 3292e169010aSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 3293e169010aSmrg 3294e169010aSmrg # Add our own program objects to the symbol list. 3295e8ead290Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 3296e169010aSmrg for progfile in $progfiles; do 3297c63293b5Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 3298c63293b5Smrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 3299c63293b5Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 3300e169010aSmrg done 3301e169010aSmrg 3302e169010aSmrg if test -n "$exclude_expsyms"; then 3303e169010aSmrg $opt_dry_run || { 3304e169010aSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 3305e169010aSmrg eval '$MV "$nlist"T "$nlist"' 3306e169010aSmrg } 33077914d74bSmrg fi 33087914d74bSmrg 3309e169010aSmrg if test -n "$export_symbols_regex"; then 3310e169010aSmrg $opt_dry_run || { 3311e169010aSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 3312e169010aSmrg eval '$MV "$nlist"T "$nlist"' 3313e169010aSmrg } 33147914d74bSmrg fi 3315e169010aSmrg 3316e169010aSmrg # Prepare the list of exported symbols 3317e169010aSmrg if test -z "$export_symbols"; then 3318e169010aSmrg export_symbols="$output_objdir/$outputname.exp" 3319e169010aSmrg $opt_dry_run || { 3320e169010aSmrg $RM $export_symbols 3321e169010aSmrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 3322e169010aSmrg case $host in 3323e169010aSmrg *cygwin* | *mingw* | *cegcc* ) 3324e169010aSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3325e169010aSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 3326e169010aSmrg ;; 33277914d74bSmrg esac 3328e169010aSmrg } 3329e169010aSmrg else 3330e169010aSmrg $opt_dry_run || { 3331e169010aSmrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 3332e169010aSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 3333e169010aSmrg eval '$MV "$nlist"T "$nlist"' 3334e169010aSmrg case $host in 3335e8ead290Smrg *cygwin* | *mingw* | *cegcc* ) 3336e169010aSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3337e169010aSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 3338e169010aSmrg ;; 33397914d74bSmrg esac 3340e169010aSmrg } 33417914d74bSmrg fi 3342e169010aSmrg fi 33437914d74bSmrg 3344e169010aSmrg for dlprefile in $dlprefiles; do 3345e169010aSmrg func_verbose "extracting global C symbols from \`$dlprefile'" 3346e169010aSmrg func_basename "$dlprefile" 3347e169010aSmrg name="$func_basename_result" 3348c63293b5Smrg case $host in 3349c63293b5Smrg *cygwin* | *mingw* | *cegcc* ) 3350c63293b5Smrg # if an import library, we need to obtain dlname 3351c63293b5Smrg if func_win32_import_lib_p "$dlprefile"; then 3352c63293b5Smrg func_tr_sh "$dlprefile" 3353c63293b5Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 3354c63293b5Smrg dlprefile_dlbasename="" 3355c63293b5Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 3356c63293b5Smrg # Use subshell, to avoid clobbering current variable values 3357c63293b5Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 3358c63293b5Smrg if test -n "$dlprefile_dlname" ; then 3359c63293b5Smrg func_basename "$dlprefile_dlname" 3360c63293b5Smrg dlprefile_dlbasename="$func_basename_result" 3361c63293b5Smrg else 3362c63293b5Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 3363c63293b5Smrg $sharedlib_from_linklib_cmd "$dlprefile" 3364c63293b5Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 3365c63293b5Smrg fi 3366c63293b5Smrg fi 3367c63293b5Smrg $opt_dry_run || { 3368c63293b5Smrg if test -n "$dlprefile_dlbasename" ; then 3369c63293b5Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 3370c63293b5Smrg else 3371c63293b5Smrg func_warning "Could not compute DLL name from $name" 3372c63293b5Smrg eval '$ECHO ": $name " >> "$nlist"' 3373c63293b5Smrg fi 3374c63293b5Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3375c63293b5Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 3376c63293b5Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 3377c63293b5Smrg } 3378c63293b5Smrg else # not an import lib 3379c63293b5Smrg $opt_dry_run || { 3380c63293b5Smrg eval '$ECHO ": $name " >> "$nlist"' 3381c63293b5Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3382c63293b5Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3383c63293b5Smrg } 3384c63293b5Smrg fi 3385c63293b5Smrg ;; 3386c63293b5Smrg *) 3387c63293b5Smrg $opt_dry_run || { 3388c63293b5Smrg eval '$ECHO ": $name " >> "$nlist"' 3389c63293b5Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3390c63293b5Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3391c63293b5Smrg } 3392c63293b5Smrg ;; 3393c63293b5Smrg esac 3394e169010aSmrg done 33957914d74bSmrg 3396e169010aSmrg $opt_dry_run || { 3397e169010aSmrg # Make sure we have at least an empty file. 3398e169010aSmrg test -f "$nlist" || : > "$nlist" 33997914d74bSmrg 3400e169010aSmrg if test -n "$exclude_expsyms"; then 3401e169010aSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 3402e169010aSmrg $MV "$nlist"T "$nlist" 34037914d74bSmrg fi 34047914d74bSmrg 3405e169010aSmrg # Try sorting and uniquifying the output. 3406e169010aSmrg if $GREP -v "^: " < "$nlist" | 3407e169010aSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 3408e169010aSmrg sort -k 3 34097914d74bSmrg else 3410e169010aSmrg sort +2 3411e169010aSmrg fi | 3412e169010aSmrg uniq > "$nlist"S; then 3413e169010aSmrg : 34147914d74bSmrg else 3415e169010aSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 34167914d74bSmrg fi 34177914d74bSmrg 3418e169010aSmrg if test -f "$nlist"S; then 3419e169010aSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 34207914d74bSmrg else 3421e8ead290Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 34227914d74bSmrg fi 34237914d74bSmrg 3424e8ead290Smrg echo >> "$output_objdir/$my_dlsyms" "\ 34257914d74bSmrg 3426e169010aSmrg/* The mapping between symbol names and symbols. */ 3427e169010aSmrgtypedef struct { 3428e169010aSmrg const char *name; 3429e169010aSmrg void *address; 3430e169010aSmrg} lt_dlsymlist; 3431c63293b5Smrgextern LT_DLSYM_CONST lt_dlsymlist 3432e169010aSmrglt_${my_prefix}_LTX_preloaded_symbols[]; 3433c63293b5SmrgLT_DLSYM_CONST lt_dlsymlist 3434e169010aSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 3435e169010aSmrg{\ 3436e169010aSmrg { \"$my_originator\", (void *) 0 }," 3437e169010aSmrg 3438e169010aSmrg case $need_lib_prefix in 3439e169010aSmrg no) 3440e169010aSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 3441e169010aSmrg ;; 3442e169010aSmrg *) 3443e169010aSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 3444e169010aSmrg ;; 3445e169010aSmrg esac 3446e8ead290Smrg echo >> "$output_objdir/$my_dlsyms" "\ 3447e169010aSmrg {0, (void *) 0} 3448e169010aSmrg}; 3449e169010aSmrg 3450e169010aSmrg/* This works around a problem in FreeBSD linker */ 3451e169010aSmrg#ifdef FREEBSD_WORKAROUND 3452e169010aSmrgstatic const void *lt_preloaded_setup() { 3453e169010aSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 3454e169010aSmrg} 3455e169010aSmrg#endif 3456e169010aSmrg 3457e169010aSmrg#ifdef __cplusplus 3458e169010aSmrg} 3459e169010aSmrg#endif\ 3460e169010aSmrg" 3461e169010aSmrg } # !$opt_dry_run 3462e169010aSmrg 3463e169010aSmrg pic_flag_for_symtable= 3464e169010aSmrg case "$compile_command " in 3465e169010aSmrg *" -static "*) ;; 3466e169010aSmrg *) 3467e169010aSmrg case $host in 3468e169010aSmrg # compiling the symbol table file with pic_flag works around 3469e169010aSmrg # a FreeBSD bug that causes programs to crash when -lm is 3470e169010aSmrg # linked before any other PIC object. But we must not use 3471e169010aSmrg # pic_flag when linking with -static. The problem exists in 3472e169010aSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 3473e169010aSmrg *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 3474e169010aSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 3475e169010aSmrg *-*-hpux*) 3476e169010aSmrg pic_flag_for_symtable=" $pic_flag" ;; 3477e169010aSmrg *) 3478e169010aSmrg if test "X$my_pic_p" != Xno; then 3479e169010aSmrg pic_flag_for_symtable=" $pic_flag" 34807914d74bSmrg fi 3481e169010aSmrg ;; 3482e169010aSmrg esac 3483e169010aSmrg ;; 3484e169010aSmrg esac 3485e169010aSmrg symtab_cflags= 3486e169010aSmrg for arg in $LTCFLAGS; do 3487e169010aSmrg case $arg in 3488e169010aSmrg -pie | -fpie | -fPIE) ;; 3489c63293b5Smrg *) func_append symtab_cflags " $arg" ;; 3490e169010aSmrg esac 3491e169010aSmrg done 34927914d74bSmrg 3493e169010aSmrg # Now compile the dynamic symbol file. 3494e169010aSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 34957914d74bSmrg 3496e169010aSmrg # Clean up the generated files. 3497e169010aSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 3498e169010aSmrg 3499e169010aSmrg # Transform the symbol file into the correct name. 3500e169010aSmrg symfileobj="$output_objdir/${my_outputname}S.$objext" 3501e169010aSmrg case $host in 3502e169010aSmrg *cygwin* | *mingw* | *cegcc* ) 3503e169010aSmrg if test -f "$output_objdir/$my_outputname.def"; then 3504e8ead290Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3505e8ead290Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3506e169010aSmrg else 3507e8ead290Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3508e8ead290Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3509e169010aSmrg fi 3510e169010aSmrg ;; 3511e169010aSmrg *) 3512e8ead290Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3513e8ead290Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 35147914d74bSmrg ;; 35157914d74bSmrg esac 3516e169010aSmrg ;; 3517e169010aSmrg *) 3518e169010aSmrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 3519e169010aSmrg ;; 3520e169010aSmrg esac 3521e169010aSmrg else 3522e169010aSmrg # We keep going just in case the user didn't refer to 3523e169010aSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 3524e169010aSmrg # really was required. 3525e169010aSmrg 3526e169010aSmrg # Nullify the symbol file. 3527e8ead290Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 3528e8ead290Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 35297914d74bSmrg fi 3530e169010aSmrg} 35317914d74bSmrg 3532e169010aSmrg# func_win32_libid arg 3533e169010aSmrg# return the library type of file 'arg' 3534e169010aSmrg# 3535e169010aSmrg# Need a lot of goo to handle *both* DLLs and import libs 3536e169010aSmrg# Has to be a shell function in order to 'eat' the argument 3537e169010aSmrg# that is supplied when $file_magic_command is called. 3538e8ead290Smrg# Despite the name, also deal with 64 bit binaries. 3539e169010aSmrgfunc_win32_libid () 3540e169010aSmrg{ 3541e169010aSmrg $opt_debug 3542e169010aSmrg win32_libid_type="unknown" 3543e169010aSmrg win32_fileres=`file -L $1 2>/dev/null` 3544e169010aSmrg case $win32_fileres in 3545e169010aSmrg *ar\ archive\ import\ library*) # definitely import 3546e169010aSmrg win32_libid_type="x86 archive import" 3547e169010aSmrg ;; 3548e169010aSmrg *ar\ archive*) # could be an import, or static 3549e8ead290Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 3550e169010aSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 3551e8ead290Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 3552c63293b5Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3553c63293b5Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 3554e169010aSmrg $SED -n -e ' 3555e169010aSmrg 1,100{ 3556e169010aSmrg / I /{ 3557e169010aSmrg s,.*,import, 3558e169010aSmrg p 3559e169010aSmrg q 3560e169010aSmrg } 3561e169010aSmrg }'` 3562e169010aSmrg case $win32_nmres in 3563e169010aSmrg import*) win32_libid_type="x86 archive import";; 3564e169010aSmrg *) win32_libid_type="x86 archive static";; 3565e169010aSmrg esac 3566e169010aSmrg fi 3567e169010aSmrg ;; 3568e169010aSmrg *DLL*) 3569e169010aSmrg win32_libid_type="x86 DLL" 3570e169010aSmrg ;; 3571e169010aSmrg *executable*) # but shell scripts are "executable" too... 3572e169010aSmrg case $win32_fileres in 3573e169010aSmrg *MS\ Windows\ PE\ Intel*) 3574e169010aSmrg win32_libid_type="x86 DLL" 3575e169010aSmrg ;; 3576e169010aSmrg esac 3577e169010aSmrg ;; 3578e169010aSmrg esac 3579e169010aSmrg $ECHO "$win32_libid_type" 3580e169010aSmrg} 35817914d74bSmrg 3582c63293b5Smrg# func_cygming_dll_for_implib ARG 3583c63293b5Smrg# 3584c63293b5Smrg# Platform-specific function to extract the 3585c63293b5Smrg# name of the DLL associated with the specified 3586c63293b5Smrg# import library ARG. 3587c63293b5Smrg# Invoked by eval'ing the libtool variable 3588c63293b5Smrg# $sharedlib_from_linklib_cmd 3589c63293b5Smrg# Result is available in the variable 3590c63293b5Smrg# $sharedlib_from_linklib_result 3591c63293b5Smrgfunc_cygming_dll_for_implib () 3592c63293b5Smrg{ 3593c63293b5Smrg $opt_debug 3594c63293b5Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 3595c63293b5Smrg} 3596c63293b5Smrg 3597c63293b5Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 3598c63293b5Smrg# 3599c63293b5Smrg# The is the core of a fallback implementation of a 3600c63293b5Smrg# platform-specific function to extract the name of the 3601c63293b5Smrg# DLL associated with the specified import library LIBNAME. 3602c63293b5Smrg# 3603c63293b5Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 3604c63293b5Smrg# on the platform and compiler that created the implib. 3605c63293b5Smrg# 3606c63293b5Smrg# Echos the name of the DLL associated with the 3607c63293b5Smrg# specified import library. 3608c63293b5Smrgfunc_cygming_dll_for_implib_fallback_core () 3609c63293b5Smrg{ 3610c63293b5Smrg $opt_debug 3611c63293b5Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 3612c63293b5Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 3613c63293b5Smrg $SED '/^Contents of section '"$match_literal"':/{ 3614c63293b5Smrg # Place marker at beginning of archive member dllname section 3615c63293b5Smrg s/.*/====MARK====/ 3616c63293b5Smrg p 3617c63293b5Smrg d 3618c63293b5Smrg } 3619c63293b5Smrg # These lines can sometimes be longer than 43 characters, but 3620c63293b5Smrg # are always uninteresting 3621c63293b5Smrg /:[ ]*file format pe[i]\{,1\}-/d 3622c63293b5Smrg /^In archive [^:]*:/d 3623c63293b5Smrg # Ensure marker is printed 3624c63293b5Smrg /^====MARK====/p 3625c63293b5Smrg # Remove all lines with less than 43 characters 3626c63293b5Smrg /^.\{43\}/!d 3627c63293b5Smrg # From remaining lines, remove first 43 characters 3628c63293b5Smrg s/^.\{43\}//' | 3629c63293b5Smrg $SED -n ' 3630c63293b5Smrg # Join marker and all lines until next marker into a single line 3631c63293b5Smrg /^====MARK====/ b para 3632c63293b5Smrg H 3633c63293b5Smrg $ b para 3634c63293b5Smrg b 3635c63293b5Smrg :para 3636c63293b5Smrg x 3637c63293b5Smrg s/\n//g 3638c63293b5Smrg # Remove the marker 3639c63293b5Smrg s/^====MARK====// 3640c63293b5Smrg # Remove trailing dots and whitespace 3641c63293b5Smrg s/[\. \t]*$// 3642c63293b5Smrg # Print 3643c63293b5Smrg /./p' | 3644c63293b5Smrg # we now have a list, one entry per line, of the stringified 3645c63293b5Smrg # contents of the appropriate section of all members of the 3646c63293b5Smrg # archive which possess that section. Heuristic: eliminate 3647c63293b5Smrg # all those which have a first or second character that is 3648c63293b5Smrg # a '.' (that is, objdump's representation of an unprintable 3649c63293b5Smrg # character.) This should work for all archives with less than 3650c63293b5Smrg # 0x302f exports -- but will fail for DLLs whose name actually 3651c63293b5Smrg # begins with a literal '.' or a single character followed by 3652c63293b5Smrg # a '.'. 3653c63293b5Smrg # 3654c63293b5Smrg # Of those that remain, print the first one. 3655c63293b5Smrg $SED -e '/^\./d;/^.\./d;q' 3656c63293b5Smrg} 3657c63293b5Smrg 3658c63293b5Smrg# func_cygming_gnu_implib_p ARG 3659c63293b5Smrg# This predicate returns with zero status (TRUE) if 3660c63293b5Smrg# ARG is a GNU/binutils-style import library. Returns 3661c63293b5Smrg# with nonzero status (FALSE) otherwise. 3662c63293b5Smrgfunc_cygming_gnu_implib_p () 3663c63293b5Smrg{ 3664c63293b5Smrg $opt_debug 3665c63293b5Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3666c63293b5Smrg 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)$'` 3667c63293b5Smrg test -n "$func_cygming_gnu_implib_tmp" 3668c63293b5Smrg} 3669c63293b5Smrg 3670c63293b5Smrg# func_cygming_ms_implib_p ARG 3671c63293b5Smrg# This predicate returns with zero status (TRUE) if 3672c63293b5Smrg# ARG is an MS-style import library. Returns 3673c63293b5Smrg# with nonzero status (FALSE) otherwise. 3674c63293b5Smrgfunc_cygming_ms_implib_p () 3675c63293b5Smrg{ 3676c63293b5Smrg $opt_debug 3677c63293b5Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3678c63293b5Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 3679c63293b5Smrg test -n "$func_cygming_ms_implib_tmp" 3680c63293b5Smrg} 3681c63293b5Smrg 3682c63293b5Smrg# func_cygming_dll_for_implib_fallback ARG 3683c63293b5Smrg# Platform-specific function to extract the 3684c63293b5Smrg# name of the DLL associated with the specified 3685c63293b5Smrg# import library ARG. 3686c63293b5Smrg# 3687c63293b5Smrg# This fallback implementation is for use when $DLLTOOL 3688c63293b5Smrg# does not support the --identify-strict option. 3689c63293b5Smrg# Invoked by eval'ing the libtool variable 3690c63293b5Smrg# $sharedlib_from_linklib_cmd 3691c63293b5Smrg# Result is available in the variable 3692c63293b5Smrg# $sharedlib_from_linklib_result 3693c63293b5Smrgfunc_cygming_dll_for_implib_fallback () 3694c63293b5Smrg{ 3695c63293b5Smrg $opt_debug 3696c63293b5Smrg if func_cygming_gnu_implib_p "$1" ; then 3697c63293b5Smrg # binutils import library 3698c63293b5Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 3699c63293b5Smrg elif func_cygming_ms_implib_p "$1" ; then 3700c63293b5Smrg # ms-generated import library 3701c63293b5Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 3702c63293b5Smrg else 3703c63293b5Smrg # unknown 3704c63293b5Smrg sharedlib_from_linklib_result="" 3705c63293b5Smrg fi 3706c63293b5Smrg} 37077914d74bSmrg 37087914d74bSmrg 3709e169010aSmrg# func_extract_an_archive dir oldlib 3710e169010aSmrgfunc_extract_an_archive () 3711e169010aSmrg{ 3712e169010aSmrg $opt_debug 3713e169010aSmrg f_ex_an_ar_dir="$1"; shift 3714e169010aSmrg f_ex_an_ar_oldlib="$1" 3715e8ead290Smrg if test "$lock_old_archive_extraction" = yes; then 3716e8ead290Smrg lockfile=$f_ex_an_ar_oldlib.lock 3717e8ead290Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3718e8ead290Smrg func_echo "Waiting for $lockfile to be removed" 3719e8ead290Smrg sleep 2 3720e8ead290Smrg done 3721e8ead290Smrg fi 3722e8ead290Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 3723e8ead290Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 3724e8ead290Smrg if test "$lock_old_archive_extraction" = yes; then 3725e8ead290Smrg $opt_dry_run || rm -f "$lockfile" 3726e8ead290Smrg fi 3727e169010aSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 3728e169010aSmrg : 3729e169010aSmrg else 3730e169010aSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 3731e169010aSmrg fi 3732e169010aSmrg} 37337914d74bSmrg 37347914d74bSmrg 3735e169010aSmrg# func_extract_archives gentop oldlib ... 3736e169010aSmrgfunc_extract_archives () 3737e169010aSmrg{ 3738e169010aSmrg $opt_debug 3739e169010aSmrg my_gentop="$1"; shift 3740e169010aSmrg my_oldlibs=${1+"$@"} 3741e169010aSmrg my_oldobjs="" 3742e169010aSmrg my_xlib="" 3743e169010aSmrg my_xabs="" 3744e169010aSmrg my_xdir="" 37457914d74bSmrg 3746e169010aSmrg for my_xlib in $my_oldlibs; do 3747e169010aSmrg # Extract the objects. 3748e169010aSmrg case $my_xlib in 3749e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 3750e169010aSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 3751e169010aSmrg esac 3752e169010aSmrg func_basename "$my_xlib" 3753e169010aSmrg my_xlib="$func_basename_result" 3754e169010aSmrg my_xlib_u=$my_xlib 3755e169010aSmrg while :; do 3756e169010aSmrg case " $extracted_archives " in 3757e169010aSmrg *" $my_xlib_u "*) 3758e169010aSmrg func_arith $extracted_serial + 1 3759e169010aSmrg extracted_serial=$func_arith_result 3760e169010aSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 3761e169010aSmrg *) break ;; 3762e169010aSmrg esac 3763e169010aSmrg done 3764e169010aSmrg extracted_archives="$extracted_archives $my_xlib_u" 3765e169010aSmrg my_xdir="$my_gentop/$my_xlib_u" 37667914d74bSmrg 3767e169010aSmrg func_mkdir_p "$my_xdir" 37687914d74bSmrg 3769e169010aSmrg case $host in 3770e169010aSmrg *-darwin*) 3771e169010aSmrg func_verbose "Extracting $my_xabs" 3772e169010aSmrg # Do not bother doing anything if just a dry run 3773e169010aSmrg $opt_dry_run || { 3774e169010aSmrg darwin_orig_dir=`pwd` 3775e169010aSmrg cd $my_xdir || exit $? 3776e169010aSmrg darwin_archive=$my_xabs 3777e169010aSmrg darwin_curdir=`pwd` 3778e169010aSmrg darwin_base_archive=`basename "$darwin_archive"` 3779e169010aSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 3780e169010aSmrg if test -n "$darwin_arches"; then 3781e169010aSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 3782e169010aSmrg darwin_arch= 3783e169010aSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 3784e169010aSmrg for darwin_arch in $darwin_arches ; do 3785e169010aSmrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3786e169010aSmrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 3787e169010aSmrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3788e169010aSmrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 3789e169010aSmrg cd "$darwin_curdir" 3790e169010aSmrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 3791e169010aSmrg done # $darwin_arches 3792e169010aSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 3793e169010aSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 3794e169010aSmrg darwin_file= 3795e169010aSmrg darwin_files= 3796e169010aSmrg for darwin_file in $darwin_filelist; do 3797e8ead290Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 3798e169010aSmrg $LIPO -create -output "$darwin_file" $darwin_files 3799e169010aSmrg done # $darwin_filelist 3800e169010aSmrg $RM -rf unfat-$$ 3801e169010aSmrg cd "$darwin_orig_dir" 3802e169010aSmrg else 3803e169010aSmrg cd $darwin_orig_dir 3804e169010aSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 3805e169010aSmrg fi # $darwin_arches 3806e169010aSmrg } # !$opt_dry_run 3807e169010aSmrg ;; 3808e169010aSmrg *) 3809e169010aSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 3810e169010aSmrg ;; 38117914d74bSmrg esac 3812e8ead290Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 3813e169010aSmrg done 38147914d74bSmrg 3815e169010aSmrg func_extract_archives_result="$my_oldobjs" 3816e169010aSmrg} 38177914d74bSmrg 38187914d74bSmrg 3819e8ead290Smrg# func_emit_wrapper [arg=no] 3820e8ead290Smrg# 3821e8ead290Smrg# Emit a libtool wrapper script on stdout. 3822e8ead290Smrg# Don't directly open a file because we may want to 3823e8ead290Smrg# incorporate the script contents within a cygwin/mingw 3824e8ead290Smrg# wrapper executable. Must ONLY be called from within 3825e8ead290Smrg# func_mode_link because it depends on a number of variables 3826e8ead290Smrg# set therein. 3827e169010aSmrg# 3828e8ead290Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 3829e8ead290Smrg# variable will take. If 'yes', then the emitted script 3830e8ead290Smrg# will assume that the directory in which it is stored is 3831e8ead290Smrg# the $objdir directory. This is a cygwin/mingw-specific 3832e8ead290Smrg# behavior. 3833e8ead290Smrgfunc_emit_wrapper () 3834e169010aSmrg{ 3835e8ead290Smrg func_emit_wrapper_arg1=${1-no} 38367914d74bSmrg 3837e169010aSmrg $ECHO "\ 3838e169010aSmrg#! $SHELL 38397914d74bSmrg 3840e169010aSmrg# $output - temporary wrapper script for $objdir/$outputname 3841e169010aSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 3842e169010aSmrg# 3843e169010aSmrg# The $output program cannot be directly executed until all the libtool 3844e169010aSmrg# libraries that it depends on are installed. 3845e169010aSmrg# 3846e169010aSmrg# This wrapper script should never be moved out of the build directory. 3847e169010aSmrg# If it is, it will not operate correctly. 38487914d74bSmrg 3849e169010aSmrg# Sed substitution that helps us do robust quoting. It backslashifies 3850e169010aSmrg# metacharacters that are still active within double-quoted strings. 3851e169010aSmrgsed_quote_subst='$sed_quote_subst' 38527914d74bSmrg 3853e169010aSmrg# Be Bourne compatible 3854e169010aSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 3855e169010aSmrg emulate sh 3856e169010aSmrg NULLCMD=: 3857e169010aSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 3858e169010aSmrg # is contrary to our usage. Disable this feature. 3859e169010aSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 3860e169010aSmrg setopt NO_GLOB_SUBST 3861e169010aSmrgelse 3862e169010aSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 3863e169010aSmrgfi 3864e169010aSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 3865e169010aSmrgDUALCASE=1; export DUALCASE # for MKS sh 38667914d74bSmrg 3867e169010aSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 3868e169010aSmrg# if CDPATH is set. 3869e169010aSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 38707914d74bSmrg 3871e169010aSmrgrelink_command=\"$relink_command\" 38727914d74bSmrg 3873e169010aSmrg# This environment variable determines our operation mode. 3874e169010aSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 3875e169010aSmrg # install mode needs the following variables: 3876e169010aSmrg generated_by_libtool_version='$macro_version' 3877e169010aSmrg notinst_deplibs='$notinst_deplibs' 3878e169010aSmrgelse 3879e169010aSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 3880e169010aSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 3881e8ead290Smrg file=\"\$0\"" 3882e8ead290Smrg 3883e8ead290Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 3884e8ead290Smrg $ECHO "\ 3885e8ead290Smrg 3886e8ead290Smrg# A function that is used when there is no print builtin or printf. 3887e8ead290Smrgfunc_fallback_echo () 3888e8ead290Smrg{ 3889e8ead290Smrg eval 'cat <<_LTECHO_EOF 3890e8ead290Smrg\$1 3891e8ead290Smrg_LTECHO_EOF' 3892e8ead290Smrg} 3893e8ead290Smrg ECHO=\"$qECHO\" 3894e8ead290Smrg fi 3895e8ead290Smrg 3896e8ead290Smrg# Very basic option parsing. These options are (a) specific to 3897e8ead290Smrg# the libtool wrapper, (b) are identical between the wrapper 3898e8ead290Smrg# /script/ and the wrapper /executable/ which is used only on 3899e8ead290Smrg# windows platforms, and (c) all begin with the string "--lt-" 3900e8ead290Smrg# (application programs are unlikely to have options which match 3901e8ead290Smrg# this pattern). 3902e8ead290Smrg# 3903e8ead290Smrg# There are only two supported options: --lt-debug and 3904e8ead290Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 3905e8ead290Smrg# 3906e8ead290Smrg# The first argument to this parsing function should be the 3907e8ead290Smrg# script's $0 value, followed by "$@". 3908e8ead290Smrglt_option_debug= 3909e8ead290Smrgfunc_parse_lt_options () 3910e8ead290Smrg{ 3911e8ead290Smrg lt_script_arg0=\$0 3912e8ead290Smrg shift 3913e8ead290Smrg for lt_opt 3914e8ead290Smrg do 3915e8ead290Smrg case \"\$lt_opt\" in 3916e8ead290Smrg --lt-debug) lt_option_debug=1 ;; 3917e8ead290Smrg --lt-dump-script) 3918e8ead290Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 3919e8ead290Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 3920e8ead290Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 3921e8ead290Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 3922e8ead290Smrg exit 0 3923e8ead290Smrg ;; 3924e8ead290Smrg --lt-*) 3925e8ead290Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 3926e8ead290Smrg exit 1 3927e8ead290Smrg ;; 3928e8ead290Smrg esac 3929e8ead290Smrg done 3930e8ead290Smrg 3931e8ead290Smrg # Print the debug banner immediately: 3932e8ead290Smrg if test -n \"\$lt_option_debug\"; then 3933e8ead290Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 3934e8ead290Smrg fi 3935e8ead290Smrg} 3936e8ead290Smrg 3937e8ead290Smrg# Used when --lt-debug. Prints its arguments to stdout 3938e8ead290Smrg# (redirection is the responsibility of the caller) 3939e8ead290Smrgfunc_lt_dump_args () 3940e8ead290Smrg{ 3941e8ead290Smrg lt_dump_args_N=1; 3942e8ead290Smrg for lt_arg 3943e8ead290Smrg do 3944e8ead290Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 3945e8ead290Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 3946e8ead290Smrg done 3947e8ead290Smrg} 3948e8ead290Smrg 3949e8ead290Smrg# Core function for launching the target application 3950e8ead290Smrgfunc_exec_program_core () 3951e8ead290Smrg{ 3952e169010aSmrg" 3953e8ead290Smrg case $host in 3954e8ead290Smrg # Backslashes separate directories on plain windows 3955e8ead290Smrg *-*-mingw | *-*-os2* | *-cegcc*) 3956e8ead290Smrg $ECHO "\ 3957e8ead290Smrg if test -n \"\$lt_option_debug\"; then 3958e8ead290Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 3959e8ead290Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 3960e8ead290Smrg fi 3961e8ead290Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 3962e8ead290Smrg" 3963e8ead290Smrg ;; 3964e8ead290Smrg 3965e8ead290Smrg *) 3966e8ead290Smrg $ECHO "\ 3967e8ead290Smrg if test -n \"\$lt_option_debug\"; then 3968e8ead290Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 3969e8ead290Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 3970e8ead290Smrg fi 3971e8ead290Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 3972e8ead290Smrg" 3973e8ead290Smrg ;; 3974e8ead290Smrg esac 3975e8ead290Smrg $ECHO "\ 3976e8ead290Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 3977e8ead290Smrg exit 1 3978e8ead290Smrg} 3979e8ead290Smrg 3980e8ead290Smrg# A function to encapsulate launching the target application 3981e8ead290Smrg# Strips options in the --lt-* namespace from \$@ and 3982e8ead290Smrg# launches target application with the remaining arguments. 3983e8ead290Smrgfunc_exec_program () 3984e8ead290Smrg{ 3985e8ead290Smrg for lt_wr_arg 3986e8ead290Smrg do 3987e8ead290Smrg case \$lt_wr_arg in 3988e8ead290Smrg --lt-*) ;; 3989e8ead290Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 3990e8ead290Smrg esac 3991e8ead290Smrg shift 3992e8ead290Smrg done 3993e8ead290Smrg func_exec_program_core \${1+\"\$@\"} 3994e8ead290Smrg} 3995e8ead290Smrg 3996e8ead290Smrg # Parse options 3997e8ead290Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 39987914d74bSmrg 3999e169010aSmrg # Find the directory that this script lives in. 4000e8ead290Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 4001e169010aSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 40027914d74bSmrg 4003e169010aSmrg # Follow symbolic links until we get to the real thisdir. 4004e8ead290Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 4005e169010aSmrg while test -n \"\$file\"; do 4006e8ead290Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 40077914d74bSmrg 4008e169010aSmrg # If there was a directory component, then change thisdir. 4009e169010aSmrg if test \"x\$destdir\" != \"x\$file\"; then 4010e169010aSmrg case \"\$destdir\" in 4011e169010aSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 4012e169010aSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 4013e169010aSmrg esac 4014e169010aSmrg fi 40157914d74bSmrg 4016e8ead290Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 4017e8ead290Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 4018e169010aSmrg done 40197914d74bSmrg 4020e169010aSmrg # Usually 'no', except on cygwin/mingw when embedded into 4021e169010aSmrg # the cwrapper. 4022e8ead290Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 4023e169010aSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 4024e169010aSmrg # special case for '.' 4025e169010aSmrg if test \"\$thisdir\" = \".\"; then 4026e169010aSmrg thisdir=\`pwd\` 4027e169010aSmrg fi 4028e169010aSmrg # remove .libs from thisdir 4029e169010aSmrg case \"\$thisdir\" in 4030e8ead290Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 4031e169010aSmrg $objdir ) thisdir=. ;; 4032e169010aSmrg esac 4033e169010aSmrg fi 40347914d74bSmrg 4035e169010aSmrg # Try to get the absolute directory name. 4036e169010aSmrg absdir=\`cd \"\$thisdir\" && pwd\` 4037e169010aSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 4038e169010aSmrg" 40397914d74bSmrg 4040e169010aSmrg if test "$fast_install" = yes; then 4041e169010aSmrg $ECHO "\ 4042e169010aSmrg program=lt-'$outputname'$exeext 4043e169010aSmrg progdir=\"\$thisdir/$objdir\" 40447914d74bSmrg 4045e169010aSmrg if test ! -f \"\$progdir/\$program\" || 4046e169010aSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 4047e169010aSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 40487914d74bSmrg 4049e169010aSmrg file=\"\$\$-\$program\" 40507914d74bSmrg 4051e169010aSmrg if test ! -d \"\$progdir\"; then 4052e169010aSmrg $MKDIR \"\$progdir\" 4053e169010aSmrg else 4054e169010aSmrg $RM \"\$progdir/\$file\" 4055e169010aSmrg fi" 40567914d74bSmrg 4057e169010aSmrg $ECHO "\ 40587914d74bSmrg 4059e169010aSmrg # relink executable if necessary 4060e169010aSmrg if test -n \"\$relink_command\"; then 4061e169010aSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 4062e169010aSmrg else 4063e169010aSmrg $ECHO \"\$relink_command_output\" >&2 4064e169010aSmrg $RM \"\$progdir/\$file\" 4065e169010aSmrg exit 1 4066e169010aSmrg fi 4067e169010aSmrg fi 40687914d74bSmrg 4069e169010aSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 4070e169010aSmrg { $RM \"\$progdir/\$program\"; 4071e169010aSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 4072e169010aSmrg $RM \"\$progdir/\$file\" 4073e169010aSmrg fi" 4074e169010aSmrg else 4075e169010aSmrg $ECHO "\ 4076e169010aSmrg program='$outputname' 4077e169010aSmrg progdir=\"\$thisdir/$objdir\" 4078e169010aSmrg" 4079e169010aSmrg fi 40807914d74bSmrg 4081e169010aSmrg $ECHO "\ 40827914d74bSmrg 4083e169010aSmrg if test -f \"\$progdir/\$program\"; then" 40847914d74bSmrg 4085c63293b5Smrg # fixup the dll searchpath if we need to. 4086c63293b5Smrg # 4087c63293b5Smrg # Fix the DLL searchpath if we need to. Do this before prepending 4088c63293b5Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 4089c63293b5Smrg # libraries must come first. 4090c63293b5Smrg if test -n "$dllsearchpath"; then 4091c63293b5Smrg $ECHO "\ 4092c63293b5Smrg # Add the dll search path components to the executable PATH 4093c63293b5Smrg PATH=$dllsearchpath:\$PATH 4094c63293b5Smrg" 4095c63293b5Smrg fi 4096c63293b5Smrg 4097e169010aSmrg # Export our shlibpath_var if we have one. 4098e169010aSmrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4099e169010aSmrg $ECHO "\ 4100e169010aSmrg # Add our own library path to $shlibpath_var 4101e169010aSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 41027914d74bSmrg 4103e169010aSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 4104e169010aSmrg # The second colon is a workaround for a bug in BeOS R4 sed 4105e8ead290Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 41067914d74bSmrg 4107e169010aSmrg export $shlibpath_var 4108e169010aSmrg" 41097914d74bSmrg fi 41107914d74bSmrg 4111e169010aSmrg $ECHO "\ 4112e169010aSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 4113e169010aSmrg # Run the actual program with our arguments. 4114e8ead290Smrg func_exec_program \${1+\"\$@\"} 4115e169010aSmrg fi 4116e169010aSmrg else 4117e169010aSmrg # The program doesn't exist. 4118e169010aSmrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 4119e169010aSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 4120e8ead290Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 4121e169010aSmrg exit 1 4122e169010aSmrg fi 4123e169010aSmrgfi\ 4124e169010aSmrg" 4125e169010aSmrg} 41267914d74bSmrg 41277914d74bSmrg 4128e169010aSmrg# func_emit_cwrapperexe_src 4129e169010aSmrg# emit the source code for a wrapper executable on stdout 4130e169010aSmrg# Must ONLY be called from within func_mode_link because 4131e169010aSmrg# it depends on a number of variable set therein. 4132e169010aSmrgfunc_emit_cwrapperexe_src () 4133e169010aSmrg{ 4134e169010aSmrg cat <<EOF 41357914d74bSmrg 4136e169010aSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 4137e169010aSmrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 41387914d74bSmrg 4139e169010aSmrg The $output program cannot be directly executed until all the libtool 4140e169010aSmrg libraries that it depends on are installed. 41417914d74bSmrg 4142e169010aSmrg This wrapper executable should never be moved out of the build directory. 4143e169010aSmrg If it is, it will not operate correctly. 4144e169010aSmrg*/ 4145e169010aSmrgEOF 4146e169010aSmrg cat <<"EOF" 4147e8ead290Smrg#ifdef _MSC_VER 4148e8ead290Smrg# define _CRT_SECURE_NO_DEPRECATE 1 4149e8ead290Smrg#endif 4150e169010aSmrg#include <stdio.h> 4151e169010aSmrg#include <stdlib.h> 4152e169010aSmrg#ifdef _MSC_VER 4153e169010aSmrg# include <direct.h> 4154e169010aSmrg# include <process.h> 4155e169010aSmrg# include <io.h> 4156e169010aSmrg#else 4157e169010aSmrg# include <unistd.h> 4158e169010aSmrg# include <stdint.h> 4159e169010aSmrg# ifdef __CYGWIN__ 4160e169010aSmrg# include <io.h> 4161e169010aSmrg# endif 4162e169010aSmrg#endif 4163e169010aSmrg#include <malloc.h> 4164e169010aSmrg#include <stdarg.h> 4165e169010aSmrg#include <assert.h> 4166e169010aSmrg#include <string.h> 4167e169010aSmrg#include <ctype.h> 4168e169010aSmrg#include <errno.h> 4169e169010aSmrg#include <fcntl.h> 4170e169010aSmrg#include <sys/stat.h> 4171e169010aSmrg 4172e8ead290Smrg/* declarations of non-ANSI functions */ 4173e8ead290Smrg#if defined(__MINGW32__) 4174e8ead290Smrg# ifdef __STRICT_ANSI__ 4175e8ead290Smrgint _putenv (const char *); 4176e8ead290Smrg# endif 4177e8ead290Smrg#elif defined(__CYGWIN__) 4178e8ead290Smrg# ifdef __STRICT_ANSI__ 4179e8ead290Smrgchar *realpath (const char *, char *); 4180e8ead290Smrgint putenv (char *); 4181e8ead290Smrgint setenv (const char *, const char *, int); 4182e8ead290Smrg# endif 4183e8ead290Smrg/* #elif defined (other platforms) ... */ 4184e8ead290Smrg#endif 4185e8ead290Smrg 4186e8ead290Smrg/* portability defines, excluding path handling macros */ 4187e8ead290Smrg#if defined(_MSC_VER) 4188e8ead290Smrg# define setmode _setmode 4189e8ead290Smrg# define stat _stat 4190e8ead290Smrg# define chmod _chmod 4191e8ead290Smrg# define getcwd _getcwd 4192e8ead290Smrg# define putenv _putenv 4193e8ead290Smrg# define S_IXUSR _S_IEXEC 4194e8ead290Smrg# ifndef _INTPTR_T_DEFINED 4195e8ead290Smrg# define _INTPTR_T_DEFINED 4196e8ead290Smrg# define intptr_t int 4197e8ead290Smrg# endif 4198e8ead290Smrg#elif defined(__MINGW32__) 4199e8ead290Smrg# define setmode _setmode 4200e8ead290Smrg# define stat _stat 4201e8ead290Smrg# define chmod _chmod 4202e8ead290Smrg# define getcwd _getcwd 4203e8ead290Smrg# define putenv _putenv 4204e8ead290Smrg#elif defined(__CYGWIN__) 4205e8ead290Smrg# define HAVE_SETENV 4206e8ead290Smrg# define FOPEN_WB "wb" 4207e8ead290Smrg/* #elif defined (other platforms) ... */ 4208e8ead290Smrg#endif 4209e8ead290Smrg 4210e169010aSmrg#if defined(PATH_MAX) 4211e169010aSmrg# define LT_PATHMAX PATH_MAX 4212e169010aSmrg#elif defined(MAXPATHLEN) 4213e169010aSmrg# define LT_PATHMAX MAXPATHLEN 4214e169010aSmrg#else 4215e169010aSmrg# define LT_PATHMAX 1024 4216e169010aSmrg#endif 4217e169010aSmrg 4218e169010aSmrg#ifndef S_IXOTH 4219e169010aSmrg# define S_IXOTH 0 4220e169010aSmrg#endif 4221e169010aSmrg#ifndef S_IXGRP 4222e169010aSmrg# define S_IXGRP 0 4223e169010aSmrg#endif 4224e169010aSmrg 4225e8ead290Smrg/* path handling portability macros */ 4226e169010aSmrg#ifndef DIR_SEPARATOR 4227e169010aSmrg# define DIR_SEPARATOR '/' 4228e169010aSmrg# define PATH_SEPARATOR ':' 4229e169010aSmrg#endif 4230e169010aSmrg 4231e169010aSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 4232e169010aSmrg defined (__OS2__) 4233e169010aSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 4234e169010aSmrg# define FOPEN_WB "wb" 4235e169010aSmrg# ifndef DIR_SEPARATOR_2 4236e169010aSmrg# define DIR_SEPARATOR_2 '\\' 4237e169010aSmrg# endif 4238e169010aSmrg# ifndef PATH_SEPARATOR_2 4239e169010aSmrg# define PATH_SEPARATOR_2 ';' 4240e169010aSmrg# endif 4241e169010aSmrg#endif 4242e169010aSmrg 4243e169010aSmrg#ifndef DIR_SEPARATOR_2 4244e169010aSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 4245e169010aSmrg#else /* DIR_SEPARATOR_2 */ 4246e169010aSmrg# define IS_DIR_SEPARATOR(ch) \ 4247e169010aSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 4248e169010aSmrg#endif /* DIR_SEPARATOR_2 */ 4249e169010aSmrg 4250e169010aSmrg#ifndef PATH_SEPARATOR_2 4251e169010aSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 4252e169010aSmrg#else /* PATH_SEPARATOR_2 */ 4253e169010aSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 4254e169010aSmrg#endif /* PATH_SEPARATOR_2 */ 4255e169010aSmrg 4256e169010aSmrg#ifndef FOPEN_WB 4257e169010aSmrg# define FOPEN_WB "w" 4258e169010aSmrg#endif 4259e169010aSmrg#ifndef _O_BINARY 4260e169010aSmrg# define _O_BINARY 0 4261e169010aSmrg#endif 4262e169010aSmrg 4263e169010aSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 4264e169010aSmrg#define XFREE(stale) do { \ 4265e169010aSmrg if (stale) { free ((void *) stale); stale = 0; } \ 4266e169010aSmrg} while (0) 4267e169010aSmrg 4268e8ead290Smrg#if defined(LT_DEBUGWRAPPER) 4269e8ead290Smrgstatic int lt_debug = 1; 4270e169010aSmrg#else 4271e8ead290Smrgstatic int lt_debug = 0; 4272e169010aSmrg#endif 4273e169010aSmrg 4274e8ead290Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 4275e169010aSmrg 4276e169010aSmrgvoid *xmalloc (size_t num); 4277e169010aSmrgchar *xstrdup (const char *string); 4278e169010aSmrgconst char *base_name (const char *name); 4279e169010aSmrgchar *find_executable (const char *wrapper); 4280e169010aSmrgchar *chase_symlinks (const char *pathspec); 4281e169010aSmrgint make_executable (const char *path); 4282e169010aSmrgint check_executable (const char *path); 4283e169010aSmrgchar *strendzap (char *str, const char *pat); 4284e8ead290Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 4285e8ead290Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 4286e8ead290Smrgstatic const char *nonnull (const char *s); 4287e8ead290Smrgstatic const char *nonempty (const char *s); 4288e169010aSmrgvoid lt_setenv (const char *name, const char *value); 4289e169010aSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 4290e169010aSmrgvoid lt_update_exe_path (const char *name, const char *value); 4291e169010aSmrgvoid lt_update_lib_path (const char *name, const char *value); 4292e8ead290Smrgchar **prepare_spawn (char **argv); 4293e8ead290Smrgvoid lt_dump_script (FILE *f); 4294e169010aSmrgEOF 4295e169010aSmrg 4296e169010aSmrg cat <<EOF 4297c63293b5Smrgvolatile const char * MAGIC_EXE = "$magic_exe"; 4298e169010aSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 4299e169010aSmrgEOF 4300e169010aSmrg 4301e169010aSmrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4302c63293b5Smrg func_to_host_path "$temp_rpath" 4303e169010aSmrg cat <<EOF 4304c63293b5Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 43057914d74bSmrgEOF 43067914d74bSmrg else 4307e169010aSmrg cat <<"EOF" 4308e169010aSmrgconst char * LIB_PATH_VALUE = ""; 4309e169010aSmrgEOF 43107914d74bSmrg fi 4311e169010aSmrg 4312e169010aSmrg if test -n "$dllsearchpath"; then 4313c63293b5Smrg func_to_host_path "$dllsearchpath:" 4314e169010aSmrg cat <<EOF 4315e169010aSmrgconst char * EXE_PATH_VARNAME = "PATH"; 4316c63293b5Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 4317e169010aSmrgEOF 43187914d74bSmrg else 4319e169010aSmrg cat <<"EOF" 4320e169010aSmrgconst char * EXE_PATH_VARNAME = ""; 4321e169010aSmrgconst char * EXE_PATH_VALUE = ""; 4322e169010aSmrgEOF 43237914d74bSmrg fi 4324e169010aSmrg 4325e169010aSmrg if test "$fast_install" = yes; then 4326e169010aSmrg cat <<EOF 4327e169010aSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 4328e169010aSmrgEOF 43297914d74bSmrg else 4330e169010aSmrg cat <<EOF 4331e169010aSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 4332e169010aSmrgEOF 43337914d74bSmrg fi 43347914d74bSmrg 43357914d74bSmrg 4336e169010aSmrg cat <<"EOF" 43377914d74bSmrg 4338e169010aSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 43397914d74bSmrg 4340e169010aSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 4341e169010aSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 4342e8ead290Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 43437914d74bSmrg 4344e169010aSmrgint 4345e169010aSmrgmain (int argc, char *argv[]) 4346e169010aSmrg{ 4347e169010aSmrg char **newargz; 4348e169010aSmrg int newargc; 4349e169010aSmrg char *tmp_pathspec; 4350e169010aSmrg char *actual_cwrapper_path; 4351e169010aSmrg char *actual_cwrapper_name; 4352e169010aSmrg char *target_name; 4353e169010aSmrg char *lt_argv_zero; 4354e169010aSmrg intptr_t rval = 127; 43557914d74bSmrg 4356e169010aSmrg int i; 43577914d74bSmrg 4358e169010aSmrg program_name = (char *) xstrdup (base_name (argv[0])); 4359e8ead290Smrg newargz = XMALLOC (char *, argc + 1); 43607914d74bSmrg 4361e8ead290Smrg /* very simple arg parsing; don't want to rely on getopt 4362e8ead290Smrg * also, copy all non cwrapper options to newargz, except 4363e8ead290Smrg * argz[0], which is handled differently 4364e8ead290Smrg */ 4365e8ead290Smrg newargc=0; 4366e169010aSmrg for (i = 1; i < argc; i++) 4367e169010aSmrg { 4368e169010aSmrg if (strcmp (argv[i], dumpscript_opt) == 0) 4369e169010aSmrg { 4370e169010aSmrgEOF 4371e169010aSmrg case "$host" in 4372e169010aSmrg *mingw* | *cygwin* ) 4373e169010aSmrg # make stdout use "unix" line endings 4374e169010aSmrg echo " setmode(1,_O_BINARY);" 4375e169010aSmrg ;; 4376e169010aSmrg esac 43777914d74bSmrg 4378e169010aSmrg cat <<"EOF" 4379e8ead290Smrg lt_dump_script (stdout); 4380e169010aSmrg return 0; 4381e169010aSmrg } 4382e8ead290Smrg if (strcmp (argv[i], debug_opt) == 0) 4383e8ead290Smrg { 4384e8ead290Smrg lt_debug = 1; 4385e8ead290Smrg continue; 4386e8ead290Smrg } 4387e8ead290Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 4388e8ead290Smrg { 4389e8ead290Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 4390e8ead290Smrg namespace, but it is not one of the ones we know about and 4391e8ead290Smrg have already dealt with, above (inluding dump-script), then 4392e8ead290Smrg report an error. Otherwise, targets might begin to believe 4393e8ead290Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 4394e8ead290Smrg namespace. The first time any user complains about this, we'll 4395e8ead290Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 4396e8ead290Smrg or a configure.ac-settable value. 4397e8ead290Smrg */ 4398e8ead290Smrg lt_fatal (__FILE__, __LINE__, 4399e8ead290Smrg "unrecognized %s option: '%s'", 4400e8ead290Smrg ltwrapper_option_prefix, argv[i]); 4401e8ead290Smrg } 4402e8ead290Smrg /* otherwise ... */ 4403e8ead290Smrg newargz[++newargc] = xstrdup (argv[i]); 4404e169010aSmrg } 4405e8ead290Smrg newargz[++newargc] = NULL; 4406e8ead290Smrg 4407e8ead290SmrgEOF 4408e8ead290Smrg cat <<EOF 4409e8ead290Smrg /* The GNU banner must be the first non-error debug message */ 4410e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 4411e8ead290SmrgEOF 4412e8ead290Smrg cat <<"EOF" 4413e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 4414e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 44157914d74bSmrg 4416e169010aSmrg tmp_pathspec = find_executable (argv[0]); 4417e169010aSmrg if (tmp_pathspec == NULL) 4418e8ead290Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 4419e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 4420e8ead290Smrg "(main) found exe (before symlink chase) at: %s\n", 4421e8ead290Smrg tmp_pathspec); 4422e169010aSmrg 4423e169010aSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 4424e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 4425e8ead290Smrg "(main) found exe (after symlink chase) at: %s\n", 4426e8ead290Smrg actual_cwrapper_path); 4427e169010aSmrg XFREE (tmp_pathspec); 4428e169010aSmrg 4429e8ead290Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 4430e169010aSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 4431e169010aSmrg 4432e169010aSmrg /* wrapper name transforms */ 4433e169010aSmrg strendzap (actual_cwrapper_name, ".exe"); 4434e169010aSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 4435e169010aSmrg XFREE (actual_cwrapper_name); 4436e169010aSmrg actual_cwrapper_name = tmp_pathspec; 4437e169010aSmrg tmp_pathspec = 0; 4438e169010aSmrg 4439e169010aSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 4440e169010aSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 4441e169010aSmrg strendzap (target_name, ".exe"); 4442e169010aSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 4443e169010aSmrg XFREE (target_name); 4444e169010aSmrg target_name = tmp_pathspec; 4445e169010aSmrg tmp_pathspec = 0; 4446e169010aSmrg 4447e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 4448e8ead290Smrg "(main) libtool target name: %s\n", 4449e8ead290Smrg target_name); 4450e169010aSmrgEOF 44517914d74bSmrg 4452e169010aSmrg cat <<EOF 4453e169010aSmrg newargz[0] = 4454e169010aSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 4455e169010aSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 4456e169010aSmrg strcpy (newargz[0], actual_cwrapper_path); 4457e169010aSmrg strcat (newargz[0], "$objdir"); 4458e169010aSmrg strcat (newargz[0], "/"); 4459e169010aSmrgEOF 44607914d74bSmrg 4461e169010aSmrg cat <<"EOF" 4462e169010aSmrg /* stop here, and copy so we don't have to do this twice */ 4463e169010aSmrg tmp_pathspec = xstrdup (newargz[0]); 44647914d74bSmrg 4465e169010aSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 4466e169010aSmrg strcat (newargz[0], actual_cwrapper_name); 44677914d74bSmrg 4468e169010aSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 4469e169010aSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 4470e169010aSmrg XFREE (tmp_pathspec); 4471e169010aSmrg tmp_pathspec = NULL; 4472e169010aSmrgEOF 44737914d74bSmrg 4474e169010aSmrg case $host_os in 4475e169010aSmrg mingw*) 4476e169010aSmrg cat <<"EOF" 4477e169010aSmrg { 4478e169010aSmrg char* p; 4479e169010aSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 4480e169010aSmrg { 4481e169010aSmrg *p = '/'; 4482e169010aSmrg } 4483e169010aSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 4484e169010aSmrg { 4485e169010aSmrg *p = '/'; 4486e169010aSmrg } 4487e169010aSmrg } 4488e169010aSmrgEOF 4489e169010aSmrg ;; 4490e169010aSmrg esac 44917914d74bSmrg 4492e169010aSmrg cat <<"EOF" 4493e169010aSmrg XFREE (target_name); 4494e169010aSmrg XFREE (actual_cwrapper_path); 4495e169010aSmrg XFREE (actual_cwrapper_name); 44967914d74bSmrg 4497e169010aSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 4498e169010aSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 4499c63293b5Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 4500c63293b5Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 4501c63293b5Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 4502c63293b5Smrg libraries must come first. */ 4503e169010aSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 4504c63293b5Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 45057914d74bSmrg 4506e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 4507e8ead290Smrg nonnull (lt_argv_zero)); 4508e169010aSmrg for (i = 0; i < newargc; i++) 4509e169010aSmrg { 4510e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 4511e8ead290Smrg i, nonnull (newargz[i])); 4512e169010aSmrg } 45137914d74bSmrg 4514e169010aSmrgEOF 45157914d74bSmrg 4516e169010aSmrg case $host_os in 4517e169010aSmrg mingw*) 4518e169010aSmrg cat <<"EOF" 4519e169010aSmrg /* execv doesn't actually work on mingw as expected on unix */ 4520e8ead290Smrg newargz = prepare_spawn (newargz); 4521e169010aSmrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 4522e169010aSmrg if (rval == -1) 4523e169010aSmrg { 4524e169010aSmrg /* failed to start process */ 4525e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 4526e8ead290Smrg "(main) failed to launch target \"%s\": %s\n", 4527e8ead290Smrg lt_argv_zero, nonnull (strerror (errno))); 4528e169010aSmrg return 127; 4529e169010aSmrg } 4530e169010aSmrg return rval; 4531e169010aSmrgEOF 4532e169010aSmrg ;; 4533e169010aSmrg *) 4534e169010aSmrg cat <<"EOF" 4535e169010aSmrg execv (lt_argv_zero, newargz); 4536e169010aSmrg return rval; /* =127, but avoids unused variable warning */ 4537e169010aSmrgEOF 4538e169010aSmrg ;; 4539e169010aSmrg esac 45407914d74bSmrg 4541e169010aSmrg cat <<"EOF" 4542e169010aSmrg} 45437914d74bSmrg 4544e169010aSmrgvoid * 4545e169010aSmrgxmalloc (size_t num) 4546e169010aSmrg{ 4547e169010aSmrg void *p = (void *) malloc (num); 4548e169010aSmrg if (!p) 4549e8ead290Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 45507914d74bSmrg 4551e169010aSmrg return p; 4552e169010aSmrg} 45537914d74bSmrg 4554e169010aSmrgchar * 4555e169010aSmrgxstrdup (const char *string) 4556e169010aSmrg{ 4557e169010aSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 4558e169010aSmrg string) : NULL; 4559e169010aSmrg} 45607914d74bSmrg 4561e169010aSmrgconst char * 4562e169010aSmrgbase_name (const char *name) 4563e169010aSmrg{ 4564e169010aSmrg const char *base; 45657914d74bSmrg 4566e169010aSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4567e169010aSmrg /* Skip over the disk name in MSDOS pathnames. */ 4568e169010aSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 4569e169010aSmrg name += 2; 4570e169010aSmrg#endif 45717914d74bSmrg 4572e169010aSmrg for (base = name; *name; name++) 4573e169010aSmrg if (IS_DIR_SEPARATOR (*name)) 4574e169010aSmrg base = name + 1; 4575e169010aSmrg return base; 4576e169010aSmrg} 45777914d74bSmrg 4578e169010aSmrgint 4579e169010aSmrgcheck_executable (const char *path) 4580e169010aSmrg{ 4581e169010aSmrg struct stat st; 45827914d74bSmrg 4583e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 4584e8ead290Smrg nonempty (path)); 4585e169010aSmrg if ((!path) || (!*path)) 4586e169010aSmrg return 0; 45877914d74bSmrg 4588e169010aSmrg if ((stat (path, &st) >= 0) 4589e169010aSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 4590e169010aSmrg return 1; 4591e169010aSmrg else 4592e169010aSmrg return 0; 4593e169010aSmrg} 45947914d74bSmrg 4595e169010aSmrgint 4596e169010aSmrgmake_executable (const char *path) 4597e169010aSmrg{ 4598e169010aSmrg int rval = 0; 4599e169010aSmrg struct stat st; 46007914d74bSmrg 4601e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 4602e8ead290Smrg nonempty (path)); 4603e169010aSmrg if ((!path) || (!*path)) 4604e169010aSmrg return 0; 46057914d74bSmrg 4606e169010aSmrg if (stat (path, &st) >= 0) 4607e169010aSmrg { 4608e169010aSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 4609e169010aSmrg } 4610e169010aSmrg return rval; 4611e169010aSmrg} 46127914d74bSmrg 4613e169010aSmrg/* Searches for the full path of the wrapper. Returns 4614e169010aSmrg newly allocated full path name if found, NULL otherwise 4615e169010aSmrg Does not chase symlinks, even on platforms that support them. 4616e169010aSmrg*/ 4617e169010aSmrgchar * 4618e169010aSmrgfind_executable (const char *wrapper) 4619e169010aSmrg{ 4620e169010aSmrg int has_slash = 0; 4621e169010aSmrg const char *p; 4622e169010aSmrg const char *p_next; 4623e169010aSmrg /* static buffer for getcwd */ 4624e169010aSmrg char tmp[LT_PATHMAX + 1]; 4625e169010aSmrg int tmp_len; 4626e169010aSmrg char *concat_name; 46277914d74bSmrg 4628e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 4629e8ead290Smrg nonempty (wrapper)); 46307914d74bSmrg 4631e169010aSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 4632e169010aSmrg return NULL; 46337914d74bSmrg 4634e169010aSmrg /* Absolute path? */ 4635e169010aSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4636e169010aSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 4637e169010aSmrg { 4638e169010aSmrg concat_name = xstrdup (wrapper); 4639e169010aSmrg if (check_executable (concat_name)) 4640e169010aSmrg return concat_name; 4641e169010aSmrg XFREE (concat_name); 4642e169010aSmrg } 4643e169010aSmrg else 4644e169010aSmrg { 4645e169010aSmrg#endif 4646e169010aSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 4647e169010aSmrg { 4648e169010aSmrg concat_name = xstrdup (wrapper); 4649e169010aSmrg if (check_executable (concat_name)) 4650e169010aSmrg return concat_name; 4651e169010aSmrg XFREE (concat_name); 4652e169010aSmrg } 4653e169010aSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4654e169010aSmrg } 4655e169010aSmrg#endif 46567914d74bSmrg 4657e169010aSmrg for (p = wrapper; *p; p++) 4658e169010aSmrg if (*p == '/') 4659e169010aSmrg { 4660e169010aSmrg has_slash = 1; 4661e169010aSmrg break; 4662e169010aSmrg } 4663e169010aSmrg if (!has_slash) 4664e169010aSmrg { 4665e169010aSmrg /* no slashes; search PATH */ 4666e169010aSmrg const char *path = getenv ("PATH"); 4667e169010aSmrg if (path != NULL) 4668e169010aSmrg { 4669e169010aSmrg for (p = path; *p; p = p_next) 4670e169010aSmrg { 4671e169010aSmrg const char *q; 4672e169010aSmrg size_t p_len; 4673e169010aSmrg for (q = p; *q; q++) 4674e169010aSmrg if (IS_PATH_SEPARATOR (*q)) 4675e169010aSmrg break; 4676e169010aSmrg p_len = q - p; 4677e169010aSmrg p_next = (*q == '\0' ? q : q + 1); 4678e169010aSmrg if (p_len == 0) 4679e169010aSmrg { 4680e169010aSmrg /* empty path: current directory */ 4681e169010aSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 4682e8ead290Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4683e8ead290Smrg nonnull (strerror (errno))); 4684e169010aSmrg tmp_len = strlen (tmp); 4685e169010aSmrg concat_name = 4686e169010aSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4687e169010aSmrg memcpy (concat_name, tmp, tmp_len); 4688e169010aSmrg concat_name[tmp_len] = '/'; 4689e169010aSmrg strcpy (concat_name + tmp_len + 1, wrapper); 4690e169010aSmrg } 4691e169010aSmrg else 4692e169010aSmrg { 4693e169010aSmrg concat_name = 4694e169010aSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 4695e169010aSmrg memcpy (concat_name, p, p_len); 4696e169010aSmrg concat_name[p_len] = '/'; 4697e169010aSmrg strcpy (concat_name + p_len + 1, wrapper); 4698e169010aSmrg } 4699e169010aSmrg if (check_executable (concat_name)) 4700e169010aSmrg return concat_name; 4701e169010aSmrg XFREE (concat_name); 4702e169010aSmrg } 4703e169010aSmrg } 4704e169010aSmrg /* not found in PATH; assume curdir */ 4705e169010aSmrg } 4706e169010aSmrg /* Relative path | not found in path: prepend cwd */ 4707e169010aSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 4708e8ead290Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4709e8ead290Smrg nonnull (strerror (errno))); 4710e169010aSmrg tmp_len = strlen (tmp); 4711e169010aSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4712e169010aSmrg memcpy (concat_name, tmp, tmp_len); 4713e169010aSmrg concat_name[tmp_len] = '/'; 4714e169010aSmrg strcpy (concat_name + tmp_len + 1, wrapper); 47157914d74bSmrg 4716e169010aSmrg if (check_executable (concat_name)) 4717e169010aSmrg return concat_name; 4718e169010aSmrg XFREE (concat_name); 4719e169010aSmrg return NULL; 4720e169010aSmrg} 47217914d74bSmrg 4722e169010aSmrgchar * 4723e169010aSmrgchase_symlinks (const char *pathspec) 4724e169010aSmrg{ 4725e169010aSmrg#ifndef S_ISLNK 4726e169010aSmrg return xstrdup (pathspec); 4727e169010aSmrg#else 4728e169010aSmrg char buf[LT_PATHMAX]; 4729e169010aSmrg struct stat s; 4730e169010aSmrg char *tmp_pathspec = xstrdup (pathspec); 4731e169010aSmrg char *p; 4732e169010aSmrg int has_symlinks = 0; 4733e169010aSmrg while (strlen (tmp_pathspec) && !has_symlinks) 4734e169010aSmrg { 4735e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 4736e8ead290Smrg "checking path component for symlinks: %s\n", 4737e8ead290Smrg tmp_pathspec); 4738e169010aSmrg if (lstat (tmp_pathspec, &s) == 0) 4739e169010aSmrg { 4740e169010aSmrg if (S_ISLNK (s.st_mode) != 0) 4741e169010aSmrg { 4742e169010aSmrg has_symlinks = 1; 4743e169010aSmrg break; 4744e169010aSmrg } 47457914d74bSmrg 4746e169010aSmrg /* search backwards for last DIR_SEPARATOR */ 4747e169010aSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 4748e169010aSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4749e169010aSmrg p--; 4750e169010aSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4751e169010aSmrg { 4752e169010aSmrg /* no more DIR_SEPARATORS left */ 4753e169010aSmrg break; 4754e169010aSmrg } 4755e169010aSmrg *p = '\0'; 4756e169010aSmrg } 4757e169010aSmrg else 4758e169010aSmrg { 4759e8ead290Smrg lt_fatal (__FILE__, __LINE__, 4760e8ead290Smrg "error accessing file \"%s\": %s", 4761e8ead290Smrg tmp_pathspec, nonnull (strerror (errno))); 4762e169010aSmrg } 4763e169010aSmrg } 4764e169010aSmrg XFREE (tmp_pathspec); 47657914d74bSmrg 4766e169010aSmrg if (!has_symlinks) 4767e169010aSmrg { 4768e169010aSmrg return xstrdup (pathspec); 4769e169010aSmrg } 47707914d74bSmrg 4771e169010aSmrg tmp_pathspec = realpath (pathspec, buf); 4772e169010aSmrg if (tmp_pathspec == 0) 4773e169010aSmrg { 4774e8ead290Smrg lt_fatal (__FILE__, __LINE__, 4775e8ead290Smrg "could not follow symlinks for %s", pathspec); 4776e169010aSmrg } 4777e169010aSmrg return xstrdup (tmp_pathspec); 4778e169010aSmrg#endif 4779e169010aSmrg} 47807914d74bSmrg 4781e169010aSmrgchar * 4782e169010aSmrgstrendzap (char *str, const char *pat) 4783e169010aSmrg{ 4784e169010aSmrg size_t len, patlen; 47857914d74bSmrg 4786e169010aSmrg assert (str != NULL); 4787e169010aSmrg assert (pat != NULL); 47887914d74bSmrg 4789e169010aSmrg len = strlen (str); 4790e169010aSmrg patlen = strlen (pat); 47917914d74bSmrg 4792e169010aSmrg if (patlen <= len) 4793e169010aSmrg { 4794e169010aSmrg str += len - patlen; 4795e169010aSmrg if (strcmp (str, pat) == 0) 4796e169010aSmrg *str = '\0'; 4797e169010aSmrg } 4798e169010aSmrg return str; 4799e169010aSmrg} 48007914d74bSmrg 4801e8ead290Smrgvoid 4802e8ead290Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 4803e8ead290Smrg{ 4804e8ead290Smrg va_list args; 4805e8ead290Smrg if (lt_debug) 4806e8ead290Smrg { 4807e8ead290Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 4808e8ead290Smrg va_start (args, fmt); 4809e8ead290Smrg (void) vfprintf (stderr, fmt, args); 4810e8ead290Smrg va_end (args); 4811e8ead290Smrg } 4812e8ead290Smrg} 4813e8ead290Smrg 4814e169010aSmrgstatic void 4815e8ead290Smrglt_error_core (int exit_status, const char *file, 4816e8ead290Smrg int line, const char *mode, 4817e169010aSmrg const char *message, va_list ap) 4818e169010aSmrg{ 4819e8ead290Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 4820e169010aSmrg vfprintf (stderr, message, ap); 4821e169010aSmrg fprintf (stderr, ".\n"); 48227914d74bSmrg 4823e169010aSmrg if (exit_status >= 0) 4824e169010aSmrg exit (exit_status); 4825e169010aSmrg} 48267914d74bSmrg 4827e169010aSmrgvoid 4828e8ead290Smrglt_fatal (const char *file, int line, const char *message, ...) 4829e169010aSmrg{ 4830e169010aSmrg va_list ap; 4831e169010aSmrg va_start (ap, message); 4832e8ead290Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 4833e169010aSmrg va_end (ap); 4834e169010aSmrg} 48357914d74bSmrg 4836e8ead290Smrgstatic const char * 4837e8ead290Smrgnonnull (const char *s) 4838e8ead290Smrg{ 4839e8ead290Smrg return s ? s : "(null)"; 4840e8ead290Smrg} 4841e8ead290Smrg 4842e8ead290Smrgstatic const char * 4843e8ead290Smrgnonempty (const char *s) 4844e8ead290Smrg{ 4845e8ead290Smrg return (s && !*s) ? "(empty)" : nonnull (s); 4846e8ead290Smrg} 4847e8ead290Smrg 4848e169010aSmrgvoid 4849e169010aSmrglt_setenv (const char *name, const char *value) 4850e169010aSmrg{ 4851e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 4852e8ead290Smrg "(lt_setenv) setting '%s' to '%s'\n", 4853e8ead290Smrg nonnull (name), nonnull (value)); 4854e169010aSmrg { 4855e169010aSmrg#ifdef HAVE_SETENV 4856e169010aSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 4857e169010aSmrg char *str = xstrdup (value); 4858e169010aSmrg setenv (name, str, 1); 4859e169010aSmrg#else 4860e169010aSmrg int len = strlen (name) + 1 + strlen (value) + 1; 4861e169010aSmrg char *str = XMALLOC (char, len); 4862e169010aSmrg sprintf (str, "%s=%s", name, value); 4863e169010aSmrg if (putenv (str) != EXIT_SUCCESS) 4864e169010aSmrg { 4865e169010aSmrg XFREE (str); 4866e169010aSmrg } 4867e169010aSmrg#endif 4868e169010aSmrg } 4869e169010aSmrg} 48707914d74bSmrg 4871e169010aSmrgchar * 4872e169010aSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 4873e169010aSmrg{ 4874e169010aSmrg char *new_value; 4875e169010aSmrg if (orig_value && *orig_value) 4876e169010aSmrg { 4877e169010aSmrg int orig_value_len = strlen (orig_value); 4878e169010aSmrg int add_len = strlen (add); 4879e169010aSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 4880e169010aSmrg if (to_end) 4881e169010aSmrg { 4882e169010aSmrg strcpy (new_value, orig_value); 4883e169010aSmrg strcpy (new_value + orig_value_len, add); 4884e169010aSmrg } 4885e169010aSmrg else 4886e169010aSmrg { 4887e169010aSmrg strcpy (new_value, add); 4888e169010aSmrg strcpy (new_value + add_len, orig_value); 4889e169010aSmrg } 4890e169010aSmrg } 4891e169010aSmrg else 4892e169010aSmrg { 4893e169010aSmrg new_value = xstrdup (add); 4894e169010aSmrg } 4895e169010aSmrg return new_value; 4896e169010aSmrg} 48977914d74bSmrg 4898e169010aSmrgvoid 4899e169010aSmrglt_update_exe_path (const char *name, const char *value) 4900e169010aSmrg{ 4901e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 4902e8ead290Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 4903e8ead290Smrg nonnull (name), nonnull (value)); 49047914d74bSmrg 4905e169010aSmrg if (name && *name && value && *value) 4906e169010aSmrg { 4907e169010aSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 4908e169010aSmrg /* some systems can't cope with a ':'-terminated path #' */ 4909e169010aSmrg int len = strlen (new_value); 4910e169010aSmrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 4911e169010aSmrg { 4912e169010aSmrg new_value[len-1] = '\0'; 4913e169010aSmrg } 4914e169010aSmrg lt_setenv (name, new_value); 4915e169010aSmrg XFREE (new_value); 4916e169010aSmrg } 4917e169010aSmrg} 49187914d74bSmrg 4919e169010aSmrgvoid 4920e169010aSmrglt_update_lib_path (const char *name, const char *value) 4921e169010aSmrg{ 4922e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 4923e8ead290Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 4924e8ead290Smrg nonnull (name), nonnull (value)); 49257914d74bSmrg 4926e169010aSmrg if (name && *name && value && *value) 4927e169010aSmrg { 4928e169010aSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 4929e169010aSmrg lt_setenv (name, new_value); 4930e169010aSmrg XFREE (new_value); 4931e169010aSmrg } 4932e169010aSmrg} 49337914d74bSmrg 4934e8ead290SmrgEOF 4935e8ead290Smrg case $host_os in 4936e8ead290Smrg mingw*) 4937e8ead290Smrg cat <<"EOF" 4938e8ead290Smrg 4939e8ead290Smrg/* Prepares an argument vector before calling spawn(). 4940e8ead290Smrg Note that spawn() does not by itself call the command interpreter 4941e8ead290Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 4942e8ead290Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 4943e8ead290Smrg GetVersionEx(&v); 4944e8ead290Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 4945e8ead290Smrg }) ? "cmd.exe" : "command.com"). 4946e8ead290Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 4947e8ead290Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 4948e8ead290Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 4949e8ead290Smrg special way: 4950e8ead290Smrg - Space and tab are interpreted as delimiters. They are not treated as 4951e8ead290Smrg delimiters if they are surrounded by double quotes: "...". 4952e8ead290Smrg - Unescaped double quotes are removed from the input. Their only effect is 4953e8ead290Smrg that within double quotes, space and tab are treated like normal 4954e8ead290Smrg characters. 4955e8ead290Smrg - Backslashes not followed by double quotes are not special. 4956e8ead290Smrg - But 2*n+1 backslashes followed by a double quote become 4957e8ead290Smrg n backslashes followed by a double quote (n >= 0): 4958e8ead290Smrg \" -> " 4959e8ead290Smrg \\\" -> \" 4960e8ead290Smrg \\\\\" -> \\" 4961e8ead290Smrg */ 4962e8ead290Smrg#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" 4963e8ead290Smrg#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" 4964e8ead290Smrgchar ** 4965e8ead290Smrgprepare_spawn (char **argv) 4966e8ead290Smrg{ 4967e8ead290Smrg size_t argc; 4968e8ead290Smrg char **new_argv; 4969e8ead290Smrg size_t i; 4970e8ead290Smrg 4971e8ead290Smrg /* Count number of arguments. */ 4972e8ead290Smrg for (argc = 0; argv[argc] != NULL; argc++) 4973e8ead290Smrg ; 4974e8ead290Smrg 4975e8ead290Smrg /* Allocate new argument vector. */ 4976e8ead290Smrg new_argv = XMALLOC (char *, argc + 1); 4977e8ead290Smrg 4978e8ead290Smrg /* Put quoted arguments into the new argument vector. */ 4979e8ead290Smrg for (i = 0; i < argc; i++) 4980e8ead290Smrg { 4981e8ead290Smrg const char *string = argv[i]; 4982e8ead290Smrg 4983e8ead290Smrg if (string[0] == '\0') 4984e8ead290Smrg new_argv[i] = xstrdup ("\"\""); 4985e8ead290Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 4986e8ead290Smrg { 4987e8ead290Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 4988e8ead290Smrg size_t length; 4989e8ead290Smrg unsigned int backslashes; 4990e8ead290Smrg const char *s; 4991e8ead290Smrg char *quoted_string; 4992e8ead290Smrg char *p; 4993e8ead290Smrg 4994e8ead290Smrg length = 0; 4995e8ead290Smrg backslashes = 0; 4996e8ead290Smrg if (quote_around) 4997e8ead290Smrg length++; 4998e8ead290Smrg for (s = string; *s != '\0'; s++) 4999e8ead290Smrg { 5000e8ead290Smrg char c = *s; 5001e8ead290Smrg if (c == '"') 5002e8ead290Smrg length += backslashes + 1; 5003e8ead290Smrg length++; 5004e8ead290Smrg if (c == '\\') 5005e8ead290Smrg backslashes++; 5006e8ead290Smrg else 5007e8ead290Smrg backslashes = 0; 5008e8ead290Smrg } 5009e8ead290Smrg if (quote_around) 5010e8ead290Smrg length += backslashes + 1; 5011e8ead290Smrg 5012e8ead290Smrg quoted_string = XMALLOC (char, length + 1); 5013e8ead290Smrg 5014e8ead290Smrg p = quoted_string; 5015e8ead290Smrg backslashes = 0; 5016e8ead290Smrg if (quote_around) 5017e8ead290Smrg *p++ = '"'; 5018e8ead290Smrg for (s = string; *s != '\0'; s++) 5019e8ead290Smrg { 5020e8ead290Smrg char c = *s; 5021e8ead290Smrg if (c == '"') 5022e8ead290Smrg { 5023e8ead290Smrg unsigned int j; 5024e8ead290Smrg for (j = backslashes + 1; j > 0; j--) 5025e8ead290Smrg *p++ = '\\'; 5026e8ead290Smrg } 5027e8ead290Smrg *p++ = c; 5028e8ead290Smrg if (c == '\\') 5029e8ead290Smrg backslashes++; 5030e8ead290Smrg else 5031e8ead290Smrg backslashes = 0; 5032e8ead290Smrg } 5033e8ead290Smrg if (quote_around) 5034e8ead290Smrg { 5035e8ead290Smrg unsigned int j; 5036e8ead290Smrg for (j = backslashes; j > 0; j--) 5037e8ead290Smrg *p++ = '\\'; 5038e8ead290Smrg *p++ = '"'; 5039e8ead290Smrg } 5040e8ead290Smrg *p = '\0'; 5041e8ead290Smrg 5042e8ead290Smrg new_argv[i] = quoted_string; 5043e8ead290Smrg } 5044e8ead290Smrg else 5045e8ead290Smrg new_argv[i] = (char *) string; 5046e8ead290Smrg } 5047e8ead290Smrg new_argv[argc] = NULL; 5048e8ead290Smrg 5049e8ead290Smrg return new_argv; 5050e8ead290Smrg} 5051e8ead290SmrgEOF 5052e8ead290Smrg ;; 5053e8ead290Smrg esac 5054e8ead290Smrg 5055e8ead290Smrg cat <<"EOF" 5056e8ead290Smrgvoid lt_dump_script (FILE* f) 5057e8ead290Smrg{ 5058e8ead290SmrgEOF 5059e8ead290Smrg func_emit_wrapper yes | 5060e8ead290Smrg $SED -e 's/\([\\"]\)/\\\1/g' \ 5061e8ead290Smrg -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' 50627914d74bSmrg 5063e8ead290Smrg cat <<"EOF" 5064e8ead290Smrg} 5065e169010aSmrgEOF 5066e169010aSmrg} 5067e169010aSmrg# end: func_emit_cwrapperexe_src 50687914d74bSmrg 5069e8ead290Smrg# func_win32_import_lib_p ARG 5070e8ead290Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 5071e8ead290Smrgfunc_win32_import_lib_p () 5072e8ead290Smrg{ 5073e8ead290Smrg $opt_debug 5074e8ead290Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 5075e8ead290Smrg *import*) : ;; 5076e8ead290Smrg *) false ;; 5077e8ead290Smrg esac 5078e8ead290Smrg} 5079e8ead290Smrg 5080e169010aSmrg# func_mode_link arg... 5081e169010aSmrgfunc_mode_link () 5082e169010aSmrg{ 5083e169010aSmrg $opt_debug 5084e169010aSmrg case $host in 5085e169010aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5086e169010aSmrg # It is impossible to link a dll without this setting, and 5087e169010aSmrg # we shouldn't force the makefile maintainer to figure out 5088e169010aSmrg # which system we are compiling for in order to pass an extra 5089e169010aSmrg # flag for every libtool invocation. 5090e169010aSmrg # allow_undefined=no 50917914d74bSmrg 5092e169010aSmrg # FIXME: Unfortunately, there are problems with the above when trying 5093e169010aSmrg # to make a dll which has undefined symbols, in which case not 5094e169010aSmrg # even a static library is built. For now, we need to specify 5095e169010aSmrg # -no-undefined on the libtool link line when we can be certain 5096e169010aSmrg # that all symbols are satisfied, otherwise we get a static library. 5097e169010aSmrg allow_undefined=yes 5098e169010aSmrg ;; 5099e169010aSmrg *) 5100e169010aSmrg allow_undefined=yes 5101e169010aSmrg ;; 5102e169010aSmrg esac 5103e169010aSmrg libtool_args=$nonopt 5104e169010aSmrg base_compile="$nonopt $@" 5105e169010aSmrg compile_command=$nonopt 5106e169010aSmrg finalize_command=$nonopt 51077914d74bSmrg 5108e169010aSmrg compile_rpath= 5109e169010aSmrg finalize_rpath= 5110e169010aSmrg compile_shlibpath= 5111e169010aSmrg finalize_shlibpath= 5112e169010aSmrg convenience= 5113e169010aSmrg old_convenience= 5114e169010aSmrg deplibs= 5115e169010aSmrg old_deplibs= 5116e169010aSmrg compiler_flags= 5117e169010aSmrg linker_flags= 5118e169010aSmrg dllsearchpath= 5119e169010aSmrg lib_search_path=`pwd` 5120e169010aSmrg inst_prefix_dir= 5121e169010aSmrg new_inherited_linker_flags= 51227914d74bSmrg 5123e169010aSmrg avoid_version=no 5124e8ead290Smrg bindir= 5125e169010aSmrg dlfiles= 5126e169010aSmrg dlprefiles= 5127e169010aSmrg dlself=no 5128e169010aSmrg export_dynamic=no 5129e169010aSmrg export_symbols= 5130e169010aSmrg export_symbols_regex= 5131e169010aSmrg generated= 5132e169010aSmrg libobjs= 5133e169010aSmrg ltlibs= 5134e169010aSmrg module=no 5135e169010aSmrg no_install=no 5136e169010aSmrg objs= 5137e169010aSmrg non_pic_objects= 5138e169010aSmrg precious_files_regex= 5139e169010aSmrg prefer_static_libs=no 5140e169010aSmrg preload=no 5141e169010aSmrg prev= 5142e169010aSmrg prevarg= 5143e169010aSmrg release= 5144e169010aSmrg rpath= 5145e169010aSmrg xrpath= 5146e169010aSmrg perm_rpath= 5147e169010aSmrg temp_rpath= 5148e169010aSmrg thread_safe=no 5149e169010aSmrg vinfo= 5150e169010aSmrg vinfo_number=no 5151e169010aSmrg weak_libs= 5152e169010aSmrg single_module="${wl}-single_module" 5153e169010aSmrg func_infer_tag $base_compile 51547914d74bSmrg 5155e169010aSmrg # We need to know -static, to get the right output filenames. 5156e169010aSmrg for arg 5157e169010aSmrg do 5158e169010aSmrg case $arg in 5159e169010aSmrg -shared) 5160e169010aSmrg test "$build_libtool_libs" != yes && \ 5161e169010aSmrg func_fatal_configuration "can not build a shared library" 5162e169010aSmrg build_old_libs=no 5163e169010aSmrg break 5164e169010aSmrg ;; 5165e169010aSmrg -all-static | -static | -static-libtool-libs) 5166e169010aSmrg case $arg in 5167e169010aSmrg -all-static) 5168e169010aSmrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 5169e169010aSmrg func_warning "complete static linking is impossible in this configuration" 51707914d74bSmrg fi 5171e169010aSmrg if test -n "$link_static_flag"; then 5172e169010aSmrg dlopen_self=$dlopen_self_static 51737914d74bSmrg fi 5174e169010aSmrg prefer_static_libs=yes 51757914d74bSmrg ;; 5176e169010aSmrg -static) 5177e169010aSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 5178e169010aSmrg dlopen_self=$dlopen_self_static 5179e169010aSmrg fi 5180e169010aSmrg prefer_static_libs=built 5181e169010aSmrg ;; 5182e169010aSmrg -static-libtool-libs) 5183e169010aSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 5184e169010aSmrg dlopen_self=$dlopen_self_static 5185e169010aSmrg fi 5186e169010aSmrg prefer_static_libs=yes 51877914d74bSmrg ;; 51887914d74bSmrg esac 5189e169010aSmrg build_libtool_libs=no 5190e169010aSmrg build_old_libs=yes 5191e169010aSmrg break 5192e169010aSmrg ;; 5193e169010aSmrg esac 5194e169010aSmrg done 51957914d74bSmrg 5196e169010aSmrg # See if our shared archives depend on static archives. 5197e169010aSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 51987914d74bSmrg 5199e169010aSmrg # Go through the arguments, transforming them on the way. 5200e169010aSmrg while test "$#" -gt 0; do 5201e169010aSmrg arg="$1" 5202e169010aSmrg shift 5203e169010aSmrg func_quote_for_eval "$arg" 5204e169010aSmrg qarg=$func_quote_for_eval_unquoted_result 5205e169010aSmrg func_append libtool_args " $func_quote_for_eval_result" 52067914d74bSmrg 5207e169010aSmrg # If the previous option needs an argument, assign it. 5208e169010aSmrg if test -n "$prev"; then 5209e169010aSmrg case $prev in 5210e169010aSmrg output) 5211e169010aSmrg func_append compile_command " @OUTPUT@" 5212e169010aSmrg func_append finalize_command " @OUTPUT@" 5213e169010aSmrg ;; 5214e169010aSmrg esac 52157914d74bSmrg 5216e169010aSmrg case $prev in 5217e8ead290Smrg bindir) 5218e8ead290Smrg bindir="$arg" 5219e8ead290Smrg prev= 5220e8ead290Smrg continue 5221e8ead290Smrg ;; 5222e169010aSmrg dlfiles|dlprefiles) 5223e169010aSmrg if test "$preload" = no; then 5224e169010aSmrg # Add the symbol object into the linking commands. 5225e169010aSmrg func_append compile_command " @SYMFILE@" 5226e169010aSmrg func_append finalize_command " @SYMFILE@" 5227e169010aSmrg preload=yes 5228e169010aSmrg fi 5229e169010aSmrg case $arg in 5230e169010aSmrg *.la | *.lo) ;; # We handle these cases below. 5231e169010aSmrg force) 5232e169010aSmrg if test "$dlself" = no; then 5233e169010aSmrg dlself=needless 5234e169010aSmrg export_dynamic=yes 5235e169010aSmrg fi 5236e169010aSmrg prev= 5237e169010aSmrg continue 5238e169010aSmrg ;; 5239e169010aSmrg self) 5240e169010aSmrg if test "$prev" = dlprefiles; then 5241e169010aSmrg dlself=yes 5242e169010aSmrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 5243e169010aSmrg dlself=yes 5244e169010aSmrg else 5245e169010aSmrg dlself=needless 5246e169010aSmrg export_dynamic=yes 5247e169010aSmrg fi 5248e169010aSmrg prev= 5249e169010aSmrg continue 52507914d74bSmrg ;; 52517914d74bSmrg *) 5252e169010aSmrg if test "$prev" = dlfiles; then 5253c63293b5Smrg func_append dlfiles " $arg" 5254e169010aSmrg else 5255c63293b5Smrg func_append dlprefiles " $arg" 5256e169010aSmrg fi 5257e169010aSmrg prev= 5258e169010aSmrg continue 52597914d74bSmrg ;; 52607914d74bSmrg esac 5261e169010aSmrg ;; 5262e169010aSmrg expsyms) 5263e169010aSmrg export_symbols="$arg" 5264e169010aSmrg test -f "$arg" \ 5265e169010aSmrg || func_fatal_error "symbol file \`$arg' does not exist" 5266e169010aSmrg prev= 5267e169010aSmrg continue 5268e169010aSmrg ;; 5269e169010aSmrg expsyms_regex) 5270e169010aSmrg export_symbols_regex="$arg" 5271e169010aSmrg prev= 5272e169010aSmrg continue 5273e169010aSmrg ;; 5274e169010aSmrg framework) 5275e169010aSmrg case $host in 5276e169010aSmrg *-*-darwin*) 5277e169010aSmrg case "$deplibs " in 5278e169010aSmrg *" $qarg.ltframework "*) ;; 5279c63293b5Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 5280e169010aSmrg ;; 5281e169010aSmrg esac 5282e169010aSmrg ;; 5283e169010aSmrg esac 5284e169010aSmrg prev= 5285e169010aSmrg continue 5286e169010aSmrg ;; 5287e169010aSmrg inst_prefix) 5288e169010aSmrg inst_prefix_dir="$arg" 5289e169010aSmrg prev= 5290e169010aSmrg continue 5291e169010aSmrg ;; 5292e169010aSmrg objectlist) 5293e169010aSmrg if test -f "$arg"; then 5294e169010aSmrg save_arg=$arg 5295e169010aSmrg moreargs= 5296e169010aSmrg for fil in `cat "$save_arg"` 5297e169010aSmrg do 5298c63293b5Smrg# func_append moreargs " $fil" 5299e169010aSmrg arg=$fil 5300e169010aSmrg # A libtool-controlled object. 53017914d74bSmrg 5302e169010aSmrg # Check to see that this really is a libtool object. 5303e169010aSmrg if func_lalib_unsafe_p "$arg"; then 5304e169010aSmrg pic_object= 5305e169010aSmrg non_pic_object= 53067914d74bSmrg 5307e169010aSmrg # Read the .lo file 5308e169010aSmrg func_source "$arg" 53097914d74bSmrg 5310e169010aSmrg if test -z "$pic_object" || 5311e169010aSmrg test -z "$non_pic_object" || 5312e169010aSmrg test "$pic_object" = none && 5313e169010aSmrg test "$non_pic_object" = none; then 5314e169010aSmrg func_fatal_error "cannot find name of object for \`$arg'" 5315e169010aSmrg fi 53167914d74bSmrg 5317e169010aSmrg # Extract subdirectory from the argument. 5318e169010aSmrg func_dirname "$arg" "/" "" 5319e169010aSmrg xdir="$func_dirname_result" 53207914d74bSmrg 5321e169010aSmrg if test "$pic_object" != none; then 5322e169010aSmrg # Prepend the subdirectory the object is found in. 5323e169010aSmrg pic_object="$xdir$pic_object" 53247914d74bSmrg 5325e169010aSmrg if test "$prev" = dlfiles; then 5326e169010aSmrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5327c63293b5Smrg func_append dlfiles " $pic_object" 5328e169010aSmrg prev= 5329e169010aSmrg continue 5330e169010aSmrg else 5331e169010aSmrg # If libtool objects are unsupported, then we need to preload. 5332e169010aSmrg prev=dlprefiles 5333e169010aSmrg fi 5334e169010aSmrg fi 53357914d74bSmrg 5336e169010aSmrg # CHECK ME: I think I busted this. -Ossama 5337e169010aSmrg if test "$prev" = dlprefiles; then 5338e169010aSmrg # Preload the old-style object. 5339c63293b5Smrg func_append dlprefiles " $pic_object" 5340e169010aSmrg prev= 5341e169010aSmrg fi 53427914d74bSmrg 5343e169010aSmrg # A PIC object. 5344e169010aSmrg func_append libobjs " $pic_object" 5345e169010aSmrg arg="$pic_object" 5346e169010aSmrg fi 53477914d74bSmrg 5348e169010aSmrg # Non-PIC object. 5349e169010aSmrg if test "$non_pic_object" != none; then 5350e169010aSmrg # Prepend the subdirectory the object is found in. 5351e169010aSmrg non_pic_object="$xdir$non_pic_object" 53527914d74bSmrg 5353e169010aSmrg # A standard non-PIC object 5354e169010aSmrg func_append non_pic_objects " $non_pic_object" 5355e169010aSmrg if test -z "$pic_object" || test "$pic_object" = none ; then 5356e169010aSmrg arg="$non_pic_object" 5357e169010aSmrg fi 5358e169010aSmrg else 5359e169010aSmrg # If the PIC object exists, use it instead. 5360e169010aSmrg # $xdir was prepended to $pic_object above. 5361e169010aSmrg non_pic_object="$pic_object" 5362e169010aSmrg func_append non_pic_objects " $non_pic_object" 5363e169010aSmrg fi 5364e169010aSmrg else 5365e169010aSmrg # Only an error if not doing a dry-run. 5366e169010aSmrg if $opt_dry_run; then 5367e169010aSmrg # Extract subdirectory from the argument. 5368e169010aSmrg func_dirname "$arg" "/" "" 5369e169010aSmrg xdir="$func_dirname_result" 5370e169010aSmrg 5371e169010aSmrg func_lo2o "$arg" 5372e169010aSmrg pic_object=$xdir$objdir/$func_lo2o_result 5373e169010aSmrg non_pic_object=$xdir$func_lo2o_result 5374e169010aSmrg func_append libobjs " $pic_object" 5375e169010aSmrg func_append non_pic_objects " $non_pic_object" 5376e169010aSmrg else 5377e169010aSmrg func_fatal_error "\`$arg' is not a valid libtool object" 5378e169010aSmrg fi 5379e169010aSmrg fi 5380e169010aSmrg done 5381e169010aSmrg else 5382e169010aSmrg func_fatal_error "link input file \`$arg' does not exist" 5383e169010aSmrg fi 5384e169010aSmrg arg=$save_arg 5385e169010aSmrg prev= 5386e169010aSmrg continue 5387e169010aSmrg ;; 5388e169010aSmrg precious_regex) 5389e169010aSmrg precious_files_regex="$arg" 5390e169010aSmrg prev= 5391e169010aSmrg continue 5392e169010aSmrg ;; 5393e169010aSmrg release) 5394e169010aSmrg release="-$arg" 5395e169010aSmrg prev= 5396e169010aSmrg continue 5397e169010aSmrg ;; 5398e169010aSmrg rpath | xrpath) 5399e169010aSmrg # We need an absolute path. 5400e169010aSmrg case $arg in 5401e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5402e169010aSmrg *) 5403e169010aSmrg func_fatal_error "only absolute run-paths are allowed" 5404e169010aSmrg ;; 5405e169010aSmrg esac 5406e169010aSmrg if test "$prev" = rpath; then 5407e169010aSmrg case "$rpath " in 5408e169010aSmrg *" $arg "*) ;; 5409c63293b5Smrg *) func_append rpath " $arg" ;; 5410e169010aSmrg esac 5411e169010aSmrg else 5412e169010aSmrg case "$xrpath " in 5413e169010aSmrg *" $arg "*) ;; 5414c63293b5Smrg *) func_append xrpath " $arg" ;; 5415e169010aSmrg esac 5416e169010aSmrg fi 5417e169010aSmrg prev= 5418e169010aSmrg continue 5419e169010aSmrg ;; 5420e169010aSmrg shrext) 5421e169010aSmrg shrext_cmds="$arg" 5422e169010aSmrg prev= 5423e169010aSmrg continue 5424e169010aSmrg ;; 5425e169010aSmrg weak) 5426c63293b5Smrg func_append weak_libs " $arg" 5427e169010aSmrg prev= 5428e169010aSmrg continue 5429e169010aSmrg ;; 5430e169010aSmrg xcclinker) 5431c63293b5Smrg func_append linker_flags " $qarg" 5432c63293b5Smrg func_append compiler_flags " $qarg" 5433e169010aSmrg prev= 5434e169010aSmrg func_append compile_command " $qarg" 5435e169010aSmrg func_append finalize_command " $qarg" 5436e169010aSmrg continue 5437e169010aSmrg ;; 5438e169010aSmrg xcompiler) 5439c63293b5Smrg func_append compiler_flags " $qarg" 5440e169010aSmrg prev= 5441e169010aSmrg func_append compile_command " $qarg" 5442e169010aSmrg func_append finalize_command " $qarg" 5443e169010aSmrg continue 5444e169010aSmrg ;; 5445e169010aSmrg xlinker) 5446c63293b5Smrg func_append linker_flags " $qarg" 5447c63293b5Smrg func_append compiler_flags " $wl$qarg" 5448e169010aSmrg prev= 5449e169010aSmrg func_append compile_command " $wl$qarg" 5450e169010aSmrg func_append finalize_command " $wl$qarg" 5451e169010aSmrg continue 5452e169010aSmrg ;; 5453e169010aSmrg *) 5454e169010aSmrg eval "$prev=\"\$arg\"" 5455e169010aSmrg prev= 5456e169010aSmrg continue 5457e169010aSmrg ;; 54587914d74bSmrg esac 5459e169010aSmrg fi # test -n "$prev" 54607914d74bSmrg 5461e169010aSmrg prevarg="$arg" 54627914d74bSmrg 5463e169010aSmrg case $arg in 5464e169010aSmrg -all-static) 5465e169010aSmrg if test -n "$link_static_flag"; then 5466e169010aSmrg # See comment for -static flag below, for more details. 5467e169010aSmrg func_append compile_command " $link_static_flag" 5468e169010aSmrg func_append finalize_command " $link_static_flag" 5469e169010aSmrg fi 5470e169010aSmrg continue 5471e169010aSmrg ;; 54727914d74bSmrg 5473e169010aSmrg -allow-undefined) 5474e169010aSmrg # FIXME: remove this flag sometime in the future. 5475e169010aSmrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 5476e169010aSmrg ;; 54777914d74bSmrg 5478e169010aSmrg -avoid-version) 5479e169010aSmrg avoid_version=yes 5480e169010aSmrg continue 5481e169010aSmrg ;; 54827914d74bSmrg 5483e8ead290Smrg -bindir) 5484e8ead290Smrg prev=bindir 5485e8ead290Smrg continue 5486e8ead290Smrg ;; 5487e8ead290Smrg 5488e169010aSmrg -dlopen) 5489e169010aSmrg prev=dlfiles 5490e169010aSmrg continue 5491e169010aSmrg ;; 54927914d74bSmrg 5493e169010aSmrg -dlpreopen) 5494e169010aSmrg prev=dlprefiles 5495e169010aSmrg continue 5496e169010aSmrg ;; 54977914d74bSmrg 5498e169010aSmrg -export-dynamic) 5499e169010aSmrg export_dynamic=yes 5500e169010aSmrg continue 5501e169010aSmrg ;; 55027914d74bSmrg 5503e169010aSmrg -export-symbols | -export-symbols-regex) 5504e169010aSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 5505e169010aSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 5506e169010aSmrg fi 5507e169010aSmrg if test "X$arg" = "X-export-symbols"; then 5508e169010aSmrg prev=expsyms 5509e169010aSmrg else 5510e169010aSmrg prev=expsyms_regex 5511e169010aSmrg fi 5512e169010aSmrg continue 5513e169010aSmrg ;; 55147914d74bSmrg 5515e169010aSmrg -framework) 5516e169010aSmrg prev=framework 5517e169010aSmrg continue 5518e169010aSmrg ;; 55197914d74bSmrg 5520e169010aSmrg -inst-prefix-dir) 5521e169010aSmrg prev=inst_prefix 5522e169010aSmrg continue 5523e169010aSmrg ;; 55247914d74bSmrg 5525e169010aSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 5526e169010aSmrg # so, if we see these flags be careful not to treat them like -L 5527e169010aSmrg -L[A-Z][A-Z]*:*) 5528e169010aSmrg case $with_gcc/$host in 5529e169010aSmrg no/*-*-irix* | /*-*-irix*) 5530e169010aSmrg func_append compile_command " $arg" 5531e169010aSmrg func_append finalize_command " $arg" 5532e169010aSmrg ;; 5533e169010aSmrg esac 5534e169010aSmrg continue 5535e169010aSmrg ;; 55367914d74bSmrg 5537e169010aSmrg -L*) 5538c63293b5Smrg func_stripname "-L" '' "$arg" 5539c63293b5Smrg if test -z "$func_stripname_result"; then 5540e169010aSmrg if test "$#" -gt 0; then 5541e169010aSmrg func_fatal_error "require no space between \`-L' and \`$1'" 5542e169010aSmrg else 5543e169010aSmrg func_fatal_error "need path for \`-L' option" 5544e169010aSmrg fi 5545e169010aSmrg fi 5546c63293b5Smrg func_resolve_sysroot "$func_stripname_result" 5547c63293b5Smrg dir=$func_resolve_sysroot_result 5548e169010aSmrg # We need an absolute path. 5549e169010aSmrg case $dir in 5550e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5551e169010aSmrg *) 5552e169010aSmrg absdir=`cd "$dir" && pwd` 5553e169010aSmrg test -z "$absdir" && \ 5554e169010aSmrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 5555e169010aSmrg dir="$absdir" 5556e169010aSmrg ;; 5557e169010aSmrg esac 5558e169010aSmrg case "$deplibs " in 5559c63293b5Smrg *" -L$dir "* | *" $arg "*) 5560c63293b5Smrg # Will only happen for absolute or sysroot arguments 5561c63293b5Smrg ;; 5562e169010aSmrg *) 5563c63293b5Smrg # Preserve sysroot, but never include relative directories 5564c63293b5Smrg case $dir in 5565c63293b5Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 5566c63293b5Smrg *) func_append deplibs " -L$dir" ;; 5567c63293b5Smrg esac 5568c63293b5Smrg func_append lib_search_path " $dir" 5569e169010aSmrg ;; 5570e169010aSmrg esac 5571e169010aSmrg case $host in 5572e169010aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5573e8ead290Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 5574e169010aSmrg case :$dllsearchpath: in 5575e169010aSmrg *":$dir:"*) ;; 5576e169010aSmrg ::) dllsearchpath=$dir;; 5577c63293b5Smrg *) func_append dllsearchpath ":$dir";; 5578e169010aSmrg esac 5579e169010aSmrg case :$dllsearchpath: in 5580e169010aSmrg *":$testbindir:"*) ;; 5581e169010aSmrg ::) dllsearchpath=$testbindir;; 5582c63293b5Smrg *) func_append dllsearchpath ":$testbindir";; 5583e169010aSmrg esac 5584e169010aSmrg ;; 5585e169010aSmrg esac 5586e169010aSmrg continue 5587e169010aSmrg ;; 55887914d74bSmrg 5589e169010aSmrg -l*) 5590e169010aSmrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 5591e169010aSmrg case $host in 5592e8ead290Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 5593e169010aSmrg # These systems don't actually have a C or math library (as such) 5594e169010aSmrg continue 5595e169010aSmrg ;; 5596e169010aSmrg *-*-os2*) 5597e169010aSmrg # These systems don't actually have a C library (as such) 5598e169010aSmrg test "X$arg" = "X-lc" && continue 5599e169010aSmrg ;; 5600e169010aSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5601e169010aSmrg # Do not include libc due to us having libc/libc_r. 5602e169010aSmrg test "X$arg" = "X-lc" && continue 5603e169010aSmrg ;; 5604e169010aSmrg *-*-rhapsody* | *-*-darwin1.[012]) 5605e169010aSmrg # Rhapsody C and math libraries are in the System framework 5606c63293b5Smrg func_append deplibs " System.ltframework" 5607e169010aSmrg continue 5608e169010aSmrg ;; 5609e169010aSmrg *-*-sco3.2v5* | *-*-sco5v6*) 5610e169010aSmrg # Causes problems with __ctype 5611e169010aSmrg test "X$arg" = "X-lc" && continue 5612e169010aSmrg ;; 5613e169010aSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 5614e169010aSmrg # Compiler inserts libc in the correct place for threads to work 5615e169010aSmrg test "X$arg" = "X-lc" && continue 5616e169010aSmrg ;; 5617e169010aSmrg esac 5618e169010aSmrg elif test "X$arg" = "X-lc_r"; then 5619e169010aSmrg case $host in 5620e169010aSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5621e169010aSmrg # Do not include libc_r directly, use -pthread flag. 5622e169010aSmrg continue 5623e169010aSmrg ;; 5624e169010aSmrg esac 5625e169010aSmrg fi 5626c63293b5Smrg func_append deplibs " $arg" 5627e169010aSmrg continue 5628e169010aSmrg ;; 56297914d74bSmrg 5630e169010aSmrg -module) 5631e169010aSmrg module=yes 5632e169010aSmrg continue 5633e169010aSmrg ;; 56347914d74bSmrg 5635e169010aSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 5636e169010aSmrg # classes, name mangling, and exception handling. 5637e169010aSmrg # Darwin uses the -arch flag to determine output architecture. 5638c63293b5Smrg -model|-arch|-isysroot|--sysroot) 5639c63293b5Smrg func_append compiler_flags " $arg" 5640e169010aSmrg func_append compile_command " $arg" 5641e169010aSmrg func_append finalize_command " $arg" 5642e169010aSmrg prev=xcompiler 5643e169010aSmrg continue 5644e169010aSmrg ;; 56457914d74bSmrg 5646e169010aSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 5647c63293b5Smrg func_append compiler_flags " $arg" 5648e169010aSmrg func_append compile_command " $arg" 5649e169010aSmrg func_append finalize_command " $arg" 5650e169010aSmrg case "$new_inherited_linker_flags " in 5651e169010aSmrg *" $arg "*) ;; 5652c63293b5Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 5653e169010aSmrg esac 5654e169010aSmrg continue 5655e169010aSmrg ;; 56567914d74bSmrg 5657e169010aSmrg -multi_module) 5658e169010aSmrg single_module="${wl}-multi_module" 5659e169010aSmrg continue 5660e169010aSmrg ;; 56617914d74bSmrg 5662e169010aSmrg -no-fast-install) 5663e169010aSmrg fast_install=no 5664e169010aSmrg continue 5665e169010aSmrg ;; 56667914d74bSmrg 5667e169010aSmrg -no-install) 5668e169010aSmrg case $host in 5669e169010aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 5670e169010aSmrg # The PATH hackery in wrapper scripts is required on Windows 5671e169010aSmrg # and Darwin in order for the loader to find any dlls it needs. 5672e169010aSmrg func_warning "\`-no-install' is ignored for $host" 5673e169010aSmrg func_warning "assuming \`-no-fast-install' instead" 5674e169010aSmrg fast_install=no 5675e169010aSmrg ;; 5676e169010aSmrg *) no_install=yes ;; 5677e169010aSmrg esac 5678e169010aSmrg continue 5679e169010aSmrg ;; 56807914d74bSmrg 5681e169010aSmrg -no-undefined) 5682e169010aSmrg allow_undefined=no 5683e169010aSmrg continue 5684e169010aSmrg ;; 56857914d74bSmrg 5686e169010aSmrg -objectlist) 5687e169010aSmrg prev=objectlist 5688e169010aSmrg continue 5689e169010aSmrg ;; 56907914d74bSmrg 5691e169010aSmrg -o) prev=output ;; 56927914d74bSmrg 5693e169010aSmrg -precious-files-regex) 5694e169010aSmrg prev=precious_regex 5695e169010aSmrg continue 5696e169010aSmrg ;; 56977914d74bSmrg 5698e169010aSmrg -release) 5699e169010aSmrg prev=release 5700e169010aSmrg continue 5701e169010aSmrg ;; 57027914d74bSmrg 5703e169010aSmrg -rpath) 5704e169010aSmrg prev=rpath 5705e169010aSmrg continue 5706e169010aSmrg ;; 57077914d74bSmrg 5708e169010aSmrg -R) 5709e169010aSmrg prev=xrpath 5710e169010aSmrg continue 5711e169010aSmrg ;; 57127914d74bSmrg 5713e169010aSmrg -R*) 5714e169010aSmrg func_stripname '-R' '' "$arg" 5715e169010aSmrg dir=$func_stripname_result 5716e169010aSmrg # We need an absolute path. 5717e169010aSmrg case $dir in 5718e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5719c63293b5Smrg =*) 5720c63293b5Smrg func_stripname '=' '' "$dir" 5721c63293b5Smrg dir=$lt_sysroot$func_stripname_result 5722c63293b5Smrg ;; 5723e169010aSmrg *) 5724e169010aSmrg func_fatal_error "only absolute run-paths are allowed" 5725e169010aSmrg ;; 5726e169010aSmrg esac 5727e169010aSmrg case "$xrpath " in 5728e169010aSmrg *" $dir "*) ;; 5729c63293b5Smrg *) func_append xrpath " $dir" ;; 5730e169010aSmrg esac 5731e169010aSmrg continue 5732e169010aSmrg ;; 57337914d74bSmrg 5734e169010aSmrg -shared) 5735e169010aSmrg # The effects of -shared are defined in a previous loop. 5736e169010aSmrg continue 5737e169010aSmrg ;; 57387914d74bSmrg 5739e169010aSmrg -shrext) 5740e169010aSmrg prev=shrext 5741e169010aSmrg continue 5742e169010aSmrg ;; 57437914d74bSmrg 5744e169010aSmrg -static | -static-libtool-libs) 5745e169010aSmrg # The effects of -static are defined in a previous loop. 5746e169010aSmrg # We used to do the same as -all-static on platforms that 5747e169010aSmrg # didn't have a PIC flag, but the assumption that the effects 5748e169010aSmrg # would be equivalent was wrong. It would break on at least 5749e169010aSmrg # Digital Unix and AIX. 5750e169010aSmrg continue 5751e169010aSmrg ;; 57527914d74bSmrg 5753e169010aSmrg -thread-safe) 5754e169010aSmrg thread_safe=yes 5755e169010aSmrg continue 5756e169010aSmrg ;; 57577914d74bSmrg 5758e169010aSmrg -version-info) 5759e169010aSmrg prev=vinfo 5760e169010aSmrg continue 5761e169010aSmrg ;; 57627914d74bSmrg 5763e169010aSmrg -version-number) 5764e169010aSmrg prev=vinfo 5765e169010aSmrg vinfo_number=yes 5766e169010aSmrg continue 5767e169010aSmrg ;; 57687914d74bSmrg 5769e169010aSmrg -weak) 5770e169010aSmrg prev=weak 5771e169010aSmrg continue 5772e169010aSmrg ;; 57737914d74bSmrg 5774e169010aSmrg -Wc,*) 5775e169010aSmrg func_stripname '-Wc,' '' "$arg" 5776e169010aSmrg args=$func_stripname_result 5777e169010aSmrg arg= 5778e169010aSmrg save_ifs="$IFS"; IFS=',' 5779e169010aSmrg for flag in $args; do 5780e169010aSmrg IFS="$save_ifs" 5781e169010aSmrg func_quote_for_eval "$flag" 5782c63293b5Smrg func_append arg " $func_quote_for_eval_result" 5783c63293b5Smrg func_append compiler_flags " $func_quote_for_eval_result" 5784e169010aSmrg done 5785e169010aSmrg IFS="$save_ifs" 5786e169010aSmrg func_stripname ' ' '' "$arg" 5787e169010aSmrg arg=$func_stripname_result 5788e169010aSmrg ;; 57897914d74bSmrg 5790e169010aSmrg -Wl,*) 5791e169010aSmrg func_stripname '-Wl,' '' "$arg" 5792e169010aSmrg args=$func_stripname_result 5793e169010aSmrg arg= 5794e169010aSmrg save_ifs="$IFS"; IFS=',' 5795e169010aSmrg for flag in $args; do 5796e169010aSmrg IFS="$save_ifs" 5797e169010aSmrg func_quote_for_eval "$flag" 5798c63293b5Smrg func_append arg " $wl$func_quote_for_eval_result" 5799c63293b5Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 5800c63293b5Smrg func_append linker_flags " $func_quote_for_eval_result" 5801e169010aSmrg done 5802e169010aSmrg IFS="$save_ifs" 5803e169010aSmrg func_stripname ' ' '' "$arg" 5804e169010aSmrg arg=$func_stripname_result 5805e169010aSmrg ;; 58067914d74bSmrg 5807e169010aSmrg -Xcompiler) 5808e169010aSmrg prev=xcompiler 5809e169010aSmrg continue 5810e169010aSmrg ;; 58117914d74bSmrg 5812e169010aSmrg -Xlinker) 5813e169010aSmrg prev=xlinker 5814e169010aSmrg continue 5815e169010aSmrg ;; 58167914d74bSmrg 5817e169010aSmrg -XCClinker) 5818e169010aSmrg prev=xcclinker 5819e169010aSmrg continue 5820e169010aSmrg ;; 58217914d74bSmrg 5822e169010aSmrg # -msg_* for osf cc 5823e169010aSmrg -msg_*) 5824e169010aSmrg func_quote_for_eval "$arg" 5825e169010aSmrg arg="$func_quote_for_eval_result" 5826e169010aSmrg ;; 58277914d74bSmrg 5828e8ead290Smrg # Flags to be passed through unchanged, with rationale: 5829e8ead290Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 5830e8ead290Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 5831e8ead290Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 5832e8ead290Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 5833e8ead290Smrg # -q* compiler args for the IBM compiler 5834e8ead290Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 5835e8ead290Smrg # -F/path path to uninstalled frameworks, gcc on darwin 5836e8ead290Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 5837e8ead290Smrg # @file GCC response files 5838e8ead290Smrg # -tp=* Portland pgcc target processor selection 5839c63293b5Smrg # --sysroot=* for sysroot support 5840c63293b5Smrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 5841e169010aSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 5842c63293b5Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 5843c63293b5Smrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 5844e169010aSmrg func_quote_for_eval "$arg" 5845e169010aSmrg arg="$func_quote_for_eval_result" 5846e169010aSmrg func_append compile_command " $arg" 5847e169010aSmrg func_append finalize_command " $arg" 5848c63293b5Smrg func_append compiler_flags " $arg" 5849e169010aSmrg continue 5850e169010aSmrg ;; 58517914d74bSmrg 5852e169010aSmrg # Some other compiler flag. 5853e169010aSmrg -* | +*) 5854e169010aSmrg func_quote_for_eval "$arg" 5855e169010aSmrg arg="$func_quote_for_eval_result" 5856e169010aSmrg ;; 58577914d74bSmrg 5858e169010aSmrg *.$objext) 5859e169010aSmrg # A standard object. 5860c63293b5Smrg func_append objs " $arg" 5861e169010aSmrg ;; 5862e169010aSmrg 5863e169010aSmrg *.lo) 5864e169010aSmrg # A libtool-controlled object. 5865e169010aSmrg 5866e169010aSmrg # Check to see that this really is a libtool object. 5867e169010aSmrg if func_lalib_unsafe_p "$arg"; then 5868e169010aSmrg pic_object= 5869e169010aSmrg non_pic_object= 5870e169010aSmrg 5871e169010aSmrg # Read the .lo file 5872e169010aSmrg func_source "$arg" 5873e169010aSmrg 5874e169010aSmrg if test -z "$pic_object" || 5875e169010aSmrg test -z "$non_pic_object" || 5876e169010aSmrg test "$pic_object" = none && 5877e169010aSmrg test "$non_pic_object" = none; then 5878e169010aSmrg func_fatal_error "cannot find name of object for \`$arg'" 5879e169010aSmrg fi 5880e169010aSmrg 5881e169010aSmrg # Extract subdirectory from the argument. 5882e169010aSmrg func_dirname "$arg" "/" "" 5883e169010aSmrg xdir="$func_dirname_result" 5884e169010aSmrg 5885e169010aSmrg if test "$pic_object" != none; then 5886e169010aSmrg # Prepend the subdirectory the object is found in. 5887e169010aSmrg pic_object="$xdir$pic_object" 5888e169010aSmrg 5889e169010aSmrg if test "$prev" = dlfiles; then 5890e169010aSmrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5891c63293b5Smrg func_append dlfiles " $pic_object" 5892e169010aSmrg prev= 5893e169010aSmrg continue 5894e169010aSmrg else 5895e169010aSmrg # If libtool objects are unsupported, then we need to preload. 5896e169010aSmrg prev=dlprefiles 5897e169010aSmrg fi 5898e169010aSmrg fi 5899e169010aSmrg 5900e169010aSmrg # CHECK ME: I think I busted this. -Ossama 5901e169010aSmrg if test "$prev" = dlprefiles; then 5902e169010aSmrg # Preload the old-style object. 5903c63293b5Smrg func_append dlprefiles " $pic_object" 5904e169010aSmrg prev= 5905e169010aSmrg fi 5906e169010aSmrg 5907e169010aSmrg # A PIC object. 5908e169010aSmrg func_append libobjs " $pic_object" 5909e169010aSmrg arg="$pic_object" 5910e169010aSmrg fi 5911e169010aSmrg 5912e169010aSmrg # Non-PIC object. 5913e169010aSmrg if test "$non_pic_object" != none; then 5914e169010aSmrg # Prepend the subdirectory the object is found in. 5915e169010aSmrg non_pic_object="$xdir$non_pic_object" 5916e169010aSmrg 5917e169010aSmrg # A standard non-PIC object 5918e169010aSmrg func_append non_pic_objects " $non_pic_object" 5919e169010aSmrg if test -z "$pic_object" || test "$pic_object" = none ; then 5920e169010aSmrg arg="$non_pic_object" 5921e169010aSmrg fi 5922e169010aSmrg else 5923e169010aSmrg # If the PIC object exists, use it instead. 5924e169010aSmrg # $xdir was prepended to $pic_object above. 5925e169010aSmrg non_pic_object="$pic_object" 5926e169010aSmrg func_append non_pic_objects " $non_pic_object" 5927e169010aSmrg fi 5928e169010aSmrg else 5929e169010aSmrg # Only an error if not doing a dry-run. 5930e169010aSmrg if $opt_dry_run; then 5931e169010aSmrg # Extract subdirectory from the argument. 5932e169010aSmrg func_dirname "$arg" "/" "" 5933e169010aSmrg xdir="$func_dirname_result" 5934e169010aSmrg 5935e169010aSmrg func_lo2o "$arg" 5936e169010aSmrg pic_object=$xdir$objdir/$func_lo2o_result 5937e169010aSmrg non_pic_object=$xdir$func_lo2o_result 5938e169010aSmrg func_append libobjs " $pic_object" 5939e169010aSmrg func_append non_pic_objects " $non_pic_object" 5940e169010aSmrg else 5941e169010aSmrg func_fatal_error "\`$arg' is not a valid libtool object" 5942e169010aSmrg fi 5943e169010aSmrg fi 5944e169010aSmrg ;; 5945e169010aSmrg 5946e169010aSmrg *.$libext) 5947e169010aSmrg # An archive. 5948c63293b5Smrg func_append deplibs " $arg" 5949c63293b5Smrg func_append old_deplibs " $arg" 5950e169010aSmrg continue 5951e169010aSmrg ;; 5952e169010aSmrg 5953e169010aSmrg *.la) 5954e169010aSmrg # A libtool-controlled library. 5955e169010aSmrg 5956c63293b5Smrg func_resolve_sysroot "$arg" 5957e169010aSmrg if test "$prev" = dlfiles; then 5958e169010aSmrg # This library was specified with -dlopen. 5959c63293b5Smrg func_append dlfiles " $func_resolve_sysroot_result" 5960e169010aSmrg prev= 5961e169010aSmrg elif test "$prev" = dlprefiles; then 5962e169010aSmrg # The library was specified with -dlpreopen. 5963c63293b5Smrg func_append dlprefiles " $func_resolve_sysroot_result" 5964e169010aSmrg prev= 5965e169010aSmrg else 5966c63293b5Smrg func_append deplibs " $func_resolve_sysroot_result" 5967e169010aSmrg fi 5968e169010aSmrg continue 5969e169010aSmrg ;; 5970e169010aSmrg 5971e169010aSmrg # Some other compiler argument. 5972e169010aSmrg *) 5973e169010aSmrg # Unknown arguments in both finalize_command and compile_command need 5974e169010aSmrg # to be aesthetically quoted because they are evaled later. 5975e169010aSmrg func_quote_for_eval "$arg" 5976e169010aSmrg arg="$func_quote_for_eval_result" 5977e169010aSmrg ;; 5978e169010aSmrg esac # arg 5979e169010aSmrg 5980e169010aSmrg # Now actually substitute the argument into the commands. 5981e169010aSmrg if test -n "$arg"; then 5982e169010aSmrg func_append compile_command " $arg" 5983e169010aSmrg func_append finalize_command " $arg" 5984e169010aSmrg fi 5985e169010aSmrg done # argument parsing loop 5986e169010aSmrg 5987e169010aSmrg test -n "$prev" && \ 5988e169010aSmrg func_fatal_help "the \`$prevarg' option requires an argument" 5989e169010aSmrg 5990e169010aSmrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 5991e169010aSmrg eval arg=\"$export_dynamic_flag_spec\" 5992e169010aSmrg func_append compile_command " $arg" 5993e169010aSmrg func_append finalize_command " $arg" 5994e169010aSmrg fi 5995e169010aSmrg 5996e169010aSmrg oldlibs= 5997e169010aSmrg # calculate the name of the file, without its directory 5998e169010aSmrg func_basename "$output" 5999e169010aSmrg outputname="$func_basename_result" 6000e169010aSmrg libobjs_save="$libobjs" 6001e169010aSmrg 6002e169010aSmrg if test -n "$shlibpath_var"; then 6003e169010aSmrg # get the directories listed in $shlibpath_var 6004e8ead290Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 60057914d74bSmrg else 6006e169010aSmrg shlib_search_path= 60077914d74bSmrg fi 6008e169010aSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 6009e169010aSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 60107914d74bSmrg 6011e169010aSmrg func_dirname "$output" "/" "" 6012e169010aSmrg output_objdir="$func_dirname_result$objdir" 6013c63293b5Smrg func_to_tool_file "$output_objdir/" 6014c63293b5Smrg tool_output_objdir=$func_to_tool_file_result 6015e169010aSmrg # Create the object directory. 6016e169010aSmrg func_mkdir_p "$output_objdir" 60177914d74bSmrg 6018e169010aSmrg # Determine the type of output 6019e169010aSmrg case $output in 6020e169010aSmrg "") 6021e169010aSmrg func_fatal_help "you must specify an output file" 6022e169010aSmrg ;; 6023e169010aSmrg *.$libext) linkmode=oldlib ;; 6024e169010aSmrg *.lo | *.$objext) linkmode=obj ;; 6025e169010aSmrg *.la) linkmode=lib ;; 6026e169010aSmrg *) linkmode=prog ;; # Anything else should be a program. 6027e169010aSmrg esac 6028e169010aSmrg 6029e169010aSmrg specialdeplibs= 6030e169010aSmrg 6031e169010aSmrg libs= 6032e169010aSmrg # Find all interdependent deplibs by searching for libraries 6033e169010aSmrg # that are linked more than once (e.g. -la -lb -la) 6034e169010aSmrg for deplib in $deplibs; do 6035c63293b5Smrg if $opt_preserve_dup_deps ; then 6036e169010aSmrg case "$libs " in 6037c63293b5Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6038e169010aSmrg esac 6039e169010aSmrg fi 6040c63293b5Smrg func_append libs " $deplib" 6041e169010aSmrg done 6042e169010aSmrg 6043e169010aSmrg if test "$linkmode" = lib; then 6044e169010aSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 6045e169010aSmrg 6046e169010aSmrg # Compute libraries that are listed more than once in $predeps 6047e169010aSmrg # $postdeps and mark them as special (i.e., whose duplicates are 6048e169010aSmrg # not to be eliminated). 6049e169010aSmrg pre_post_deps= 6050e169010aSmrg if $opt_duplicate_compiler_generated_deps; then 6051e169010aSmrg for pre_post_dep in $predeps $postdeps; do 6052e169010aSmrg case "$pre_post_deps " in 6053c63293b5Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 6054e169010aSmrg esac 6055c63293b5Smrg func_append pre_post_deps " $pre_post_dep" 6056e169010aSmrg done 6057e169010aSmrg fi 6058e169010aSmrg pre_post_deps= 6059e169010aSmrg fi 6060e169010aSmrg 6061e169010aSmrg deplibs= 6062e169010aSmrg newdependency_libs= 6063e169010aSmrg newlib_search_path= 6064e169010aSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 6065e169010aSmrg notinst_deplibs= # not-installed libtool libraries 6066e169010aSmrg notinst_path= # paths that contain not-installed libtool libraries 6067e169010aSmrg 6068e169010aSmrg case $linkmode in 6069e169010aSmrg lib) 6070e169010aSmrg passes="conv dlpreopen link" 6071e169010aSmrg for file in $dlfiles $dlprefiles; do 6072e169010aSmrg case $file in 6073e169010aSmrg *.la) ;; 6074e169010aSmrg *) 6075e169010aSmrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 6076e169010aSmrg ;; 6077e169010aSmrg esac 6078e169010aSmrg done 6079e169010aSmrg ;; 6080e169010aSmrg prog) 6081e169010aSmrg compile_deplibs= 6082e169010aSmrg finalize_deplibs= 6083e169010aSmrg alldeplibs=no 6084e169010aSmrg newdlfiles= 6085e169010aSmrg newdlprefiles= 6086e169010aSmrg passes="conv scan dlopen dlpreopen link" 6087e169010aSmrg ;; 6088e169010aSmrg *) passes="conv" 6089e169010aSmrg ;; 6090e169010aSmrg esac 6091e169010aSmrg 6092e169010aSmrg for pass in $passes; do 6093e169010aSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 6094e169010aSmrg # so that -L comes before libs that need it for instance... 6095e169010aSmrg if test "$linkmode,$pass" = "lib,link"; then 6096e169010aSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 6097e169010aSmrg ## order, and fix it there properly 6098e169010aSmrg tmp_deplibs= 6099e169010aSmrg for deplib in $deplibs; do 6100e169010aSmrg tmp_deplibs="$deplib $tmp_deplibs" 6101e169010aSmrg done 6102e169010aSmrg deplibs="$tmp_deplibs" 6103e169010aSmrg fi 6104e169010aSmrg 6105e169010aSmrg if test "$linkmode,$pass" = "lib,link" || 6106e169010aSmrg test "$linkmode,$pass" = "prog,scan"; then 6107e169010aSmrg libs="$deplibs" 6108e169010aSmrg deplibs= 6109e169010aSmrg fi 6110e169010aSmrg if test "$linkmode" = prog; then 6111e169010aSmrg case $pass in 6112e169010aSmrg dlopen) libs="$dlfiles" ;; 6113e169010aSmrg dlpreopen) libs="$dlprefiles" ;; 6114e169010aSmrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 6115e169010aSmrg esac 6116e169010aSmrg fi 6117e169010aSmrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 6118e169010aSmrg # Collect and forward deplibs of preopened libtool libs 6119e169010aSmrg for lib in $dlprefiles; do 6120e169010aSmrg # Ignore non-libtool-libs 6121e169010aSmrg dependency_libs= 6122c63293b5Smrg func_resolve_sysroot "$lib" 6123e169010aSmrg case $lib in 6124c63293b5Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 6125e169010aSmrg esac 6126e169010aSmrg 6127e169010aSmrg # Collect preopened libtool deplibs, except any this library 6128e169010aSmrg # has declared as weak libs 6129e169010aSmrg for deplib in $dependency_libs; do 6130e8ead290Smrg func_basename "$deplib" 6131e8ead290Smrg deplib_base=$func_basename_result 6132e169010aSmrg case " $weak_libs " in 6133e169010aSmrg *" $deplib_base "*) ;; 6134c63293b5Smrg *) func_append deplibs " $deplib" ;; 6135e169010aSmrg esac 6136e169010aSmrg done 6137e169010aSmrg done 6138e169010aSmrg libs="$dlprefiles" 6139e169010aSmrg fi 6140e169010aSmrg if test "$pass" = dlopen; then 6141e169010aSmrg # Collect dlpreopened libraries 6142e169010aSmrg save_deplibs="$deplibs" 6143e169010aSmrg deplibs= 6144e169010aSmrg fi 6145e169010aSmrg 6146e169010aSmrg for deplib in $libs; do 6147e169010aSmrg lib= 6148e169010aSmrg found=no 6149e169010aSmrg case $deplib in 6150e169010aSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 6151e169010aSmrg if test "$linkmode,$pass" = "prog,link"; then 6152e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 6153e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 6154e169010aSmrg else 6155c63293b5Smrg func_append compiler_flags " $deplib" 6156e169010aSmrg if test "$linkmode" = lib ; then 6157e169010aSmrg case "$new_inherited_linker_flags " in 6158e169010aSmrg *" $deplib "*) ;; 6159c63293b5Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 6160e169010aSmrg esac 6161e169010aSmrg fi 6162e169010aSmrg fi 6163e169010aSmrg continue 6164e169010aSmrg ;; 6165e169010aSmrg -l*) 6166e169010aSmrg if test "$linkmode" != lib && test "$linkmode" != prog; then 6167e169010aSmrg func_warning "\`-l' is ignored for archives/objects" 6168e169010aSmrg continue 6169e169010aSmrg fi 6170e169010aSmrg func_stripname '-l' '' "$deplib" 6171e169010aSmrg name=$func_stripname_result 6172e169010aSmrg if test "$linkmode" = lib; then 6173e169010aSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 6174e169010aSmrg else 6175e169010aSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 6176e169010aSmrg fi 6177e169010aSmrg for searchdir in $searchdirs; do 6178e169010aSmrg for search_ext in .la $std_shrext .so .a; do 6179e169010aSmrg # Search the libtool library 6180e169010aSmrg lib="$searchdir/lib${name}${search_ext}" 6181e169010aSmrg if test -f "$lib"; then 6182e169010aSmrg if test "$search_ext" = ".la"; then 6183e169010aSmrg found=yes 6184e169010aSmrg else 6185e169010aSmrg found=no 6186e169010aSmrg fi 6187e169010aSmrg break 2 6188e169010aSmrg fi 6189e169010aSmrg done 6190e169010aSmrg done 6191e169010aSmrg if test "$found" != yes; then 6192e169010aSmrg # deplib doesn't seem to be a libtool library 6193e169010aSmrg if test "$linkmode,$pass" = "prog,link"; then 6194e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 6195e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 6196e169010aSmrg else 6197e169010aSmrg deplibs="$deplib $deplibs" 6198e169010aSmrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6199e169010aSmrg fi 6200e169010aSmrg continue 6201e169010aSmrg else # deplib is a libtool library 6202e169010aSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 6203e169010aSmrg # We need to do some special things here, and not later. 6204e169010aSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 6205e169010aSmrg case " $predeps $postdeps " in 6206e169010aSmrg *" $deplib "*) 6207e169010aSmrg if func_lalib_p "$lib"; then 6208e169010aSmrg library_names= 6209e169010aSmrg old_library= 6210e169010aSmrg func_source "$lib" 6211e169010aSmrg for l in $old_library $library_names; do 6212e169010aSmrg ll="$l" 6213e169010aSmrg done 6214e169010aSmrg if test "X$ll" = "X$old_library" ; then # only static version available 6215e169010aSmrg found=no 6216e169010aSmrg func_dirname "$lib" "" "." 6217e169010aSmrg ladir="$func_dirname_result" 6218e169010aSmrg lib=$ladir/$old_library 6219e169010aSmrg if test "$linkmode,$pass" = "prog,link"; then 6220e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 6221e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 6222e169010aSmrg else 6223e169010aSmrg deplibs="$deplib $deplibs" 6224e169010aSmrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6225e169010aSmrg fi 6226e169010aSmrg continue 6227e169010aSmrg fi 6228e169010aSmrg fi 6229e169010aSmrg ;; 6230e169010aSmrg *) ;; 6231e169010aSmrg esac 6232e169010aSmrg fi 6233e169010aSmrg fi 6234e169010aSmrg ;; # -l 6235e169010aSmrg *.ltframework) 6236e169010aSmrg if test "$linkmode,$pass" = "prog,link"; then 6237e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 6238e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 6239e169010aSmrg else 6240e169010aSmrg deplibs="$deplib $deplibs" 6241e169010aSmrg if test "$linkmode" = lib ; then 6242e169010aSmrg case "$new_inherited_linker_flags " in 6243e169010aSmrg *" $deplib "*) ;; 6244c63293b5Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 6245e169010aSmrg esac 6246e169010aSmrg fi 6247e169010aSmrg fi 6248e169010aSmrg continue 6249e169010aSmrg ;; 6250e169010aSmrg -L*) 6251e169010aSmrg case $linkmode in 6252e169010aSmrg lib) 6253e169010aSmrg deplibs="$deplib $deplibs" 6254e169010aSmrg test "$pass" = conv && continue 6255e169010aSmrg newdependency_libs="$deplib $newdependency_libs" 6256e169010aSmrg func_stripname '-L' '' "$deplib" 6257c63293b5Smrg func_resolve_sysroot "$func_stripname_result" 6258c63293b5Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 6259e169010aSmrg ;; 6260e169010aSmrg prog) 6261e169010aSmrg if test "$pass" = conv; then 6262e169010aSmrg deplibs="$deplib $deplibs" 6263e169010aSmrg continue 6264e169010aSmrg fi 6265e169010aSmrg if test "$pass" = scan; then 6266e169010aSmrg deplibs="$deplib $deplibs" 6267e169010aSmrg else 6268e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 6269e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 6270e169010aSmrg fi 6271e169010aSmrg func_stripname '-L' '' "$deplib" 6272c63293b5Smrg func_resolve_sysroot "$func_stripname_result" 6273c63293b5Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 6274e169010aSmrg ;; 6275e169010aSmrg *) 6276e169010aSmrg func_warning "\`-L' is ignored for archives/objects" 6277e169010aSmrg ;; 6278e169010aSmrg esac # linkmode 6279e169010aSmrg continue 6280e169010aSmrg ;; # -L 6281e169010aSmrg -R*) 6282e169010aSmrg if test "$pass" = link; then 6283e169010aSmrg func_stripname '-R' '' "$deplib" 6284c63293b5Smrg func_resolve_sysroot "$func_stripname_result" 6285c63293b5Smrg dir=$func_resolve_sysroot_result 6286e169010aSmrg # Make sure the xrpath contains only unique directories. 6287e169010aSmrg case "$xrpath " in 6288e169010aSmrg *" $dir "*) ;; 6289c63293b5Smrg *) func_append xrpath " $dir" ;; 6290e169010aSmrg esac 6291e169010aSmrg fi 6292e169010aSmrg deplibs="$deplib $deplibs" 6293e169010aSmrg continue 6294e169010aSmrg ;; 6295c63293b5Smrg *.la) 6296c63293b5Smrg func_resolve_sysroot "$deplib" 6297c63293b5Smrg lib=$func_resolve_sysroot_result 6298c63293b5Smrg ;; 6299e169010aSmrg *.$libext) 6300e169010aSmrg if test "$pass" = conv; then 6301e169010aSmrg deplibs="$deplib $deplibs" 6302e169010aSmrg continue 6303e169010aSmrg fi 6304e169010aSmrg case $linkmode in 6305e169010aSmrg lib) 6306e169010aSmrg # Linking convenience modules into shared libraries is allowed, 6307e169010aSmrg # but linking other static libraries is non-portable. 6308e169010aSmrg case " $dlpreconveniencelibs " in 6309e169010aSmrg *" $deplib "*) ;; 6310e169010aSmrg *) 6311e169010aSmrg valid_a_lib=no 6312e169010aSmrg case $deplibs_check_method in 6313e169010aSmrg match_pattern*) 6314e169010aSmrg set dummy $deplibs_check_method; shift 6315e169010aSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 6316e8ead290Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 6317e169010aSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 6318e169010aSmrg valid_a_lib=yes 6319e169010aSmrg fi 6320e169010aSmrg ;; 6321e169010aSmrg pass_all) 6322e169010aSmrg valid_a_lib=yes 6323e169010aSmrg ;; 6324e169010aSmrg esac 6325e169010aSmrg if test "$valid_a_lib" != yes; then 6326e8ead290Smrg echo 6327e169010aSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 6328e8ead290Smrg echo "*** I have the capability to make that library automatically link in when" 6329e8ead290Smrg echo "*** you link to this library. But I can only do this if you have a" 6330e8ead290Smrg echo "*** shared version of the library, which you do not appear to have" 6331e8ead290Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 6332e8ead290Smrg echo "*** that it is just a static archive that I should not use here." 6333e169010aSmrg else 6334e8ead290Smrg echo 6335e169010aSmrg $ECHO "*** Warning: Linking the shared library $output against the" 6336e169010aSmrg $ECHO "*** static library $deplib is not portable!" 6337e169010aSmrg deplibs="$deplib $deplibs" 6338e169010aSmrg fi 6339e169010aSmrg ;; 6340e169010aSmrg esac 6341e169010aSmrg continue 6342e169010aSmrg ;; 6343e169010aSmrg prog) 6344e169010aSmrg if test "$pass" != link; then 6345e169010aSmrg deplibs="$deplib $deplibs" 6346e169010aSmrg else 6347e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 6348e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 6349e169010aSmrg fi 6350e169010aSmrg continue 6351e169010aSmrg ;; 6352e169010aSmrg esac # linkmode 6353e169010aSmrg ;; # *.$libext 6354e169010aSmrg *.lo | *.$objext) 6355e169010aSmrg if test "$pass" = conv; then 6356e169010aSmrg deplibs="$deplib $deplibs" 6357e169010aSmrg elif test "$linkmode" = prog; then 6358e169010aSmrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 6359e169010aSmrg # If there is no dlopen support or we're linking statically, 6360e169010aSmrg # we need to preload. 6361c63293b5Smrg func_append newdlprefiles " $deplib" 6362e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 6363e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 6364e169010aSmrg else 6365c63293b5Smrg func_append newdlfiles " $deplib" 6366e169010aSmrg fi 6367e169010aSmrg fi 6368e169010aSmrg continue 6369e169010aSmrg ;; 6370e169010aSmrg %DEPLIBS%) 6371e169010aSmrg alldeplibs=yes 6372e169010aSmrg continue 6373e169010aSmrg ;; 6374e169010aSmrg esac # case $deplib 6375e169010aSmrg 6376e169010aSmrg if test "$found" = yes || test -f "$lib"; then : 6377e169010aSmrg else 6378e169010aSmrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 6379e169010aSmrg fi 6380e169010aSmrg 6381e169010aSmrg # Check to see that this really is a libtool archive. 6382e169010aSmrg func_lalib_unsafe_p "$lib" \ 6383e169010aSmrg || func_fatal_error "\`$lib' is not a valid libtool archive" 6384e169010aSmrg 6385e169010aSmrg func_dirname "$lib" "" "." 6386e169010aSmrg ladir="$func_dirname_result" 6387e169010aSmrg 6388e169010aSmrg dlname= 6389e169010aSmrg dlopen= 6390e169010aSmrg dlpreopen= 6391e169010aSmrg libdir= 6392e169010aSmrg library_names= 6393e169010aSmrg old_library= 6394e169010aSmrg inherited_linker_flags= 6395e169010aSmrg # If the library was installed with an old release of libtool, 6396e169010aSmrg # it will not redefine variables installed, or shouldnotlink 6397e169010aSmrg installed=yes 6398e169010aSmrg shouldnotlink=no 6399e169010aSmrg avoidtemprpath= 6400e169010aSmrg 6401e169010aSmrg 6402e169010aSmrg # Read the .la file 6403e169010aSmrg func_source "$lib" 6404e169010aSmrg 6405e169010aSmrg # Convert "-framework foo" to "foo.ltframework" 6406e169010aSmrg if test -n "$inherited_linker_flags"; then 6407e8ead290Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 6408e169010aSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 6409e169010aSmrg case " $new_inherited_linker_flags " in 6410e169010aSmrg *" $tmp_inherited_linker_flag "*) ;; 6411c63293b5Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 6412e169010aSmrg esac 6413e169010aSmrg done 6414e169010aSmrg fi 6415e8ead290Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 6416e169010aSmrg if test "$linkmode,$pass" = "lib,link" || 6417e169010aSmrg test "$linkmode,$pass" = "prog,scan" || 6418e169010aSmrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 6419c63293b5Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 6420c63293b5Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 6421e169010aSmrg fi 6422e169010aSmrg 6423e169010aSmrg if test "$pass" = conv; then 6424e169010aSmrg # Only check for convenience libraries 6425e169010aSmrg deplibs="$lib $deplibs" 6426e169010aSmrg if test -z "$libdir"; then 6427e169010aSmrg if test -z "$old_library"; then 6428e169010aSmrg func_fatal_error "cannot find name of link library for \`$lib'" 6429e169010aSmrg fi 6430e169010aSmrg # It is a libtool convenience library, so add in its objects. 6431c63293b5Smrg func_append convenience " $ladir/$objdir/$old_library" 6432c63293b5Smrg func_append old_convenience " $ladir/$objdir/$old_library" 6433e169010aSmrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 6434e169010aSmrg func_fatal_error "\`$lib' is not a convenience library" 6435e169010aSmrg fi 6436e169010aSmrg tmp_libs= 6437e169010aSmrg for deplib in $dependency_libs; do 6438e169010aSmrg deplibs="$deplib $deplibs" 6439c63293b5Smrg if $opt_preserve_dup_deps ; then 6440e169010aSmrg case "$tmp_libs " in 6441c63293b5Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6442e169010aSmrg esac 6443e169010aSmrg fi 6444c63293b5Smrg func_append tmp_libs " $deplib" 6445e169010aSmrg done 6446e169010aSmrg continue 6447e169010aSmrg fi # $pass = conv 6448e169010aSmrg 6449e169010aSmrg 6450e169010aSmrg # Get the name of the library we link against. 6451e169010aSmrg linklib= 6452c63293b5Smrg if test -n "$old_library" && 6453c63293b5Smrg { test "$prefer_static_libs" = yes || 6454c63293b5Smrg test "$prefer_static_libs,$installed" = "built,no"; }; then 6455c63293b5Smrg linklib=$old_library 6456c63293b5Smrg else 6457c63293b5Smrg for l in $old_library $library_names; do 6458c63293b5Smrg linklib="$l" 6459c63293b5Smrg done 6460c63293b5Smrg fi 6461e169010aSmrg if test -z "$linklib"; then 6462e169010aSmrg func_fatal_error "cannot find name of link library for \`$lib'" 6463e169010aSmrg fi 6464e169010aSmrg 6465e169010aSmrg # This library was specified with -dlopen. 6466e169010aSmrg if test "$pass" = dlopen; then 6467e169010aSmrg if test -z "$libdir"; then 6468e169010aSmrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 6469e169010aSmrg fi 6470e169010aSmrg if test -z "$dlname" || 6471e169010aSmrg test "$dlopen_support" != yes || 6472e169010aSmrg test "$build_libtool_libs" = no; then 6473e169010aSmrg # If there is no dlname, no dlopen support or we're linking 6474e169010aSmrg # statically, we need to preload. We also need to preload any 6475e169010aSmrg # dependent libraries so libltdl's deplib preloader doesn't 6476e169010aSmrg # bomb out in the load deplibs phase. 6477c63293b5Smrg func_append dlprefiles " $lib $dependency_libs" 6478e169010aSmrg else 6479c63293b5Smrg func_append newdlfiles " $lib" 6480e169010aSmrg fi 6481e169010aSmrg continue 6482e169010aSmrg fi # $pass = dlopen 6483e169010aSmrg 6484e169010aSmrg # We need an absolute path. 6485e169010aSmrg case $ladir in 6486e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 6487e169010aSmrg *) 6488e169010aSmrg abs_ladir=`cd "$ladir" && pwd` 6489e169010aSmrg if test -z "$abs_ladir"; then 6490e169010aSmrg func_warning "cannot determine absolute directory name of \`$ladir'" 6491e169010aSmrg func_warning "passing it literally to the linker, although it might fail" 6492e169010aSmrg abs_ladir="$ladir" 6493e169010aSmrg fi 6494e169010aSmrg ;; 6495e169010aSmrg esac 6496e169010aSmrg func_basename "$lib" 6497e169010aSmrg laname="$func_basename_result" 6498e169010aSmrg 6499e169010aSmrg # Find the relevant object directory and library name. 6500e169010aSmrg if test "X$installed" = Xyes; then 6501c63293b5Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6502e169010aSmrg func_warning "library \`$lib' was moved." 6503e169010aSmrg dir="$ladir" 6504e169010aSmrg absdir="$abs_ladir" 6505e169010aSmrg libdir="$abs_ladir" 6506e169010aSmrg else 6507c63293b5Smrg dir="$lt_sysroot$libdir" 6508c63293b5Smrg absdir="$lt_sysroot$libdir" 6509e169010aSmrg fi 6510e169010aSmrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 6511e169010aSmrg else 6512e169010aSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6513e169010aSmrg dir="$ladir" 6514e169010aSmrg absdir="$abs_ladir" 6515e169010aSmrg # Remove this search path later 6516c63293b5Smrg func_append notinst_path " $abs_ladir" 6517e169010aSmrg else 6518e169010aSmrg dir="$ladir/$objdir" 6519e169010aSmrg absdir="$abs_ladir/$objdir" 6520e169010aSmrg # Remove this search path later 6521c63293b5Smrg func_append notinst_path " $abs_ladir" 6522e169010aSmrg fi 6523e169010aSmrg fi # $installed = yes 6524e169010aSmrg func_stripname 'lib' '.la' "$laname" 6525e169010aSmrg name=$func_stripname_result 6526e169010aSmrg 6527e169010aSmrg # This library was specified with -dlpreopen. 6528e169010aSmrg if test "$pass" = dlpreopen; then 6529e169010aSmrg if test -z "$libdir" && test "$linkmode" = prog; then 6530e169010aSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 6531e169010aSmrg fi 6532c63293b5Smrg case "$host" in 6533c63293b5Smrg # special handling for platforms with PE-DLLs. 6534c63293b5Smrg *cygwin* | *mingw* | *cegcc* ) 6535c63293b5Smrg # Linker will automatically link against shared library if both 6536c63293b5Smrg # static and shared are present. Therefore, ensure we extract 6537c63293b5Smrg # symbols from the import library if a shared library is present 6538c63293b5Smrg # (otherwise, the dlopen module name will be incorrect). We do 6539c63293b5Smrg # this by putting the import library name into $newdlprefiles. 6540c63293b5Smrg # We recover the dlopen module name by 'saving' the la file 6541c63293b5Smrg # name in a special purpose variable, and (later) extracting the 6542c63293b5Smrg # dlname from the la file. 6543c63293b5Smrg if test -n "$dlname"; then 6544c63293b5Smrg func_tr_sh "$dir/$linklib" 6545c63293b5Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 6546c63293b5Smrg func_append newdlprefiles " $dir/$linklib" 6547c63293b5Smrg else 6548c63293b5Smrg func_append newdlprefiles " $dir/$old_library" 6549c63293b5Smrg # Keep a list of preopened convenience libraries to check 6550c63293b5Smrg # that they are being used correctly in the link pass. 6551c63293b5Smrg test -z "$libdir" && \ 6552c63293b5Smrg func_append dlpreconveniencelibs " $dir/$old_library" 6553c63293b5Smrg fi 6554c63293b5Smrg ;; 6555c63293b5Smrg * ) 6556c63293b5Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 6557c63293b5Smrg # are required to link). 6558c63293b5Smrg if test -n "$old_library"; then 6559c63293b5Smrg func_append newdlprefiles " $dir/$old_library" 6560c63293b5Smrg # Keep a list of preopened convenience libraries to check 6561c63293b5Smrg # that they are being used correctly in the link pass. 6562c63293b5Smrg test -z "$libdir" && \ 6563c63293b5Smrg func_append dlpreconveniencelibs " $dir/$old_library" 6564c63293b5Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 6565c63293b5Smrg elif test -n "$dlname"; then 6566c63293b5Smrg func_append newdlprefiles " $dir/$dlname" 6567c63293b5Smrg else 6568c63293b5Smrg func_append newdlprefiles " $dir/$linklib" 6569c63293b5Smrg fi 6570c63293b5Smrg ;; 6571c63293b5Smrg esac 6572e169010aSmrg fi # $pass = dlpreopen 6573e169010aSmrg 6574e169010aSmrg if test -z "$libdir"; then 6575e169010aSmrg # Link the convenience library 6576e169010aSmrg if test "$linkmode" = lib; then 6577e169010aSmrg deplibs="$dir/$old_library $deplibs" 6578e169010aSmrg elif test "$linkmode,$pass" = "prog,link"; then 6579e169010aSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 6580e169010aSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 6581e169010aSmrg else 6582e169010aSmrg deplibs="$lib $deplibs" # used for prog,scan pass 6583e169010aSmrg fi 6584e169010aSmrg continue 6585e169010aSmrg fi 6586e169010aSmrg 6587e169010aSmrg 6588e169010aSmrg if test "$linkmode" = prog && test "$pass" != link; then 6589c63293b5Smrg func_append newlib_search_path " $ladir" 6590e169010aSmrg deplibs="$lib $deplibs" 6591e169010aSmrg 6592e169010aSmrg linkalldeplibs=no 6593e169010aSmrg if test "$link_all_deplibs" != no || test -z "$library_names" || 6594e169010aSmrg test "$build_libtool_libs" = no; then 6595e169010aSmrg linkalldeplibs=yes 6596e169010aSmrg fi 6597e169010aSmrg 6598e169010aSmrg tmp_libs= 6599e169010aSmrg for deplib in $dependency_libs; do 6600e169010aSmrg case $deplib in 6601e169010aSmrg -L*) func_stripname '-L' '' "$deplib" 6602c63293b5Smrg func_resolve_sysroot "$func_stripname_result" 6603c63293b5Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 6604e169010aSmrg ;; 6605e169010aSmrg esac 6606e169010aSmrg # Need to link against all dependency_libs? 6607e169010aSmrg if test "$linkalldeplibs" = yes; then 6608e169010aSmrg deplibs="$deplib $deplibs" 6609e169010aSmrg else 6610e169010aSmrg # Need to hardcode shared library paths 6611e169010aSmrg # or/and link against static libraries 6612e169010aSmrg newdependency_libs="$deplib $newdependency_libs" 6613e169010aSmrg fi 6614c63293b5Smrg if $opt_preserve_dup_deps ; then 6615e169010aSmrg case "$tmp_libs " in 6616c63293b5Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6617e169010aSmrg esac 6618e169010aSmrg fi 6619c63293b5Smrg func_append tmp_libs " $deplib" 6620e169010aSmrg done # for deplib 6621e169010aSmrg continue 6622e169010aSmrg fi # $linkmode = prog... 6623e169010aSmrg 6624e169010aSmrg if test "$linkmode,$pass" = "prog,link"; then 6625e169010aSmrg if test -n "$library_names" && 6626e169010aSmrg { { test "$prefer_static_libs" = no || 6627e169010aSmrg test "$prefer_static_libs,$installed" = "built,yes"; } || 6628e169010aSmrg test -z "$old_library"; }; then 6629e169010aSmrg # We need to hardcode the library path 6630e169010aSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 6631e169010aSmrg # Make sure the rpath contains only unique directories. 6632e169010aSmrg case "$temp_rpath:" in 6633e169010aSmrg *"$absdir:"*) ;; 6634c63293b5Smrg *) func_append temp_rpath "$absdir:" ;; 6635e169010aSmrg esac 6636e169010aSmrg fi 6637e169010aSmrg 6638e169010aSmrg # Hardcode the library path. 6639e169010aSmrg # Skip directories that are in the system default run-time 6640e169010aSmrg # search path. 6641e169010aSmrg case " $sys_lib_dlsearch_path " in 6642e169010aSmrg *" $absdir "*) ;; 6643e169010aSmrg *) 6644e169010aSmrg case "$compile_rpath " in 6645e169010aSmrg *" $absdir "*) ;; 6646c63293b5Smrg *) func_append compile_rpath " $absdir" ;; 6647e169010aSmrg esac 6648e169010aSmrg ;; 6649e169010aSmrg esac 6650e169010aSmrg case " $sys_lib_dlsearch_path " in 6651e169010aSmrg *" $libdir "*) ;; 6652e169010aSmrg *) 6653e169010aSmrg case "$finalize_rpath " in 6654e169010aSmrg *" $libdir "*) ;; 6655c63293b5Smrg *) func_append finalize_rpath " $libdir" ;; 6656e169010aSmrg esac 6657e169010aSmrg ;; 6658e169010aSmrg esac 6659e169010aSmrg fi # $linkmode,$pass = prog,link... 6660e169010aSmrg 6661e169010aSmrg if test "$alldeplibs" = yes && 6662e169010aSmrg { test "$deplibs_check_method" = pass_all || 6663e169010aSmrg { test "$build_libtool_libs" = yes && 6664e169010aSmrg test -n "$library_names"; }; }; then 6665e169010aSmrg # We only need to search for static libraries 6666e169010aSmrg continue 6667e169010aSmrg fi 6668e169010aSmrg fi 6669e169010aSmrg 6670e169010aSmrg link_static=no # Whether the deplib will be linked statically 6671e169010aSmrg use_static_libs=$prefer_static_libs 6672e169010aSmrg if test "$use_static_libs" = built && test "$installed" = yes; then 6673e169010aSmrg use_static_libs=no 6674e169010aSmrg fi 6675e169010aSmrg if test -n "$library_names" && 6676e169010aSmrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 6677e169010aSmrg case $host in 6678e169010aSmrg *cygwin* | *mingw* | *cegcc*) 6679e169010aSmrg # No point in relinking DLLs because paths are not encoded 6680c63293b5Smrg func_append notinst_deplibs " $lib" 6681e169010aSmrg need_relink=no 6682e169010aSmrg ;; 6683e169010aSmrg *) 6684e169010aSmrg if test "$installed" = no; then 6685c63293b5Smrg func_append notinst_deplibs " $lib" 6686e169010aSmrg need_relink=yes 6687e169010aSmrg fi 6688e169010aSmrg ;; 6689e169010aSmrg esac 6690e169010aSmrg # This is a shared library 6691e169010aSmrg 6692e169010aSmrg # Warn about portability, can't link against -module's on some 6693e169010aSmrg # systems (darwin). Don't bleat about dlopened modules though! 6694e169010aSmrg dlopenmodule="" 6695e169010aSmrg for dlpremoduletest in $dlprefiles; do 6696e169010aSmrg if test "X$dlpremoduletest" = "X$lib"; then 6697e169010aSmrg dlopenmodule="$dlpremoduletest" 6698e169010aSmrg break 6699e169010aSmrg fi 6700e169010aSmrg done 6701e169010aSmrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 6702e8ead290Smrg echo 6703e169010aSmrg if test "$linkmode" = prog; then 6704e169010aSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 6705e169010aSmrg else 6706e169010aSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 6707e169010aSmrg fi 6708e169010aSmrg $ECHO "*** $linklib is not portable!" 6709e169010aSmrg fi 6710e169010aSmrg if test "$linkmode" = lib && 6711e169010aSmrg test "$hardcode_into_libs" = yes; then 6712e169010aSmrg # Hardcode the library path. 6713e169010aSmrg # Skip directories that are in the system default run-time 6714e169010aSmrg # search path. 6715e169010aSmrg case " $sys_lib_dlsearch_path " in 6716e169010aSmrg *" $absdir "*) ;; 6717e169010aSmrg *) 6718e169010aSmrg case "$compile_rpath " in 6719e169010aSmrg *" $absdir "*) ;; 6720c63293b5Smrg *) func_append compile_rpath " $absdir" ;; 6721e169010aSmrg esac 6722e169010aSmrg ;; 6723e169010aSmrg esac 6724e169010aSmrg case " $sys_lib_dlsearch_path " in 6725e169010aSmrg *" $libdir "*) ;; 6726e169010aSmrg *) 6727e169010aSmrg case "$finalize_rpath " in 6728e169010aSmrg *" $libdir "*) ;; 6729c63293b5Smrg *) func_append finalize_rpath " $libdir" ;; 6730e169010aSmrg esac 6731e169010aSmrg ;; 6732e169010aSmrg esac 6733e169010aSmrg fi 6734e169010aSmrg 6735e169010aSmrg if test -n "$old_archive_from_expsyms_cmds"; then 6736e169010aSmrg # figure out the soname 6737e169010aSmrg set dummy $library_names 6738e169010aSmrg shift 6739e169010aSmrg realname="$1" 6740e169010aSmrg shift 6741e169010aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 6742e169010aSmrg # use dlname if we got it. it's perfectly good, no? 6743e169010aSmrg if test -n "$dlname"; then 6744e169010aSmrg soname="$dlname" 6745e169010aSmrg elif test -n "$soname_spec"; then 6746e169010aSmrg # bleh windows 6747e169010aSmrg case $host in 6748e169010aSmrg *cygwin* | mingw* | *cegcc*) 6749e169010aSmrg func_arith $current - $age 6750e169010aSmrg major=$func_arith_result 6751e169010aSmrg versuffix="-$major" 6752e169010aSmrg ;; 6753e169010aSmrg esac 6754e169010aSmrg eval soname=\"$soname_spec\" 6755e169010aSmrg else 6756e169010aSmrg soname="$realname" 6757e169010aSmrg fi 6758e169010aSmrg 6759e169010aSmrg # Make a new name for the extract_expsyms_cmds to use 6760e169010aSmrg soroot="$soname" 6761e169010aSmrg func_basename "$soroot" 6762e169010aSmrg soname="$func_basename_result" 6763e169010aSmrg func_stripname 'lib' '.dll' "$soname" 6764e169010aSmrg newlib=libimp-$func_stripname_result.a 6765e169010aSmrg 6766e169010aSmrg # If the library has no export list, then create one now 6767e169010aSmrg if test -f "$output_objdir/$soname-def"; then : 6768e169010aSmrg else 6769e169010aSmrg func_verbose "extracting exported symbol list from \`$soname'" 6770e169010aSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 6771e169010aSmrg fi 6772e169010aSmrg 6773e169010aSmrg # Create $newlib 6774e169010aSmrg if test -f "$output_objdir/$newlib"; then :; else 6775e169010aSmrg func_verbose "generating import library for \`$soname'" 6776e169010aSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 6777e169010aSmrg fi 6778e169010aSmrg # make sure the library variables are pointing to the new library 6779e169010aSmrg dir=$output_objdir 6780e169010aSmrg linklib=$newlib 6781e169010aSmrg fi # test -n "$old_archive_from_expsyms_cmds" 6782e169010aSmrg 6783c63293b5Smrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 6784e169010aSmrg add_shlibpath= 6785e169010aSmrg add_dir= 6786e169010aSmrg add= 6787e169010aSmrg lib_linked=yes 6788e169010aSmrg case $hardcode_action in 6789e169010aSmrg immediate | unsupported) 6790e169010aSmrg if test "$hardcode_direct" = no; then 6791e169010aSmrg add="$dir/$linklib" 6792e169010aSmrg case $host in 6793e169010aSmrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 6794e169010aSmrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 6795e169010aSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 6796e169010aSmrg *-*-unixware7*) add_dir="-L$dir" ;; 6797e169010aSmrg *-*-darwin* ) 6798e169010aSmrg # if the lib is a (non-dlopened) module then we can not 6799e169010aSmrg # link against it, someone is ignoring the earlier warnings 6800e169010aSmrg if /usr/bin/file -L $add 2> /dev/null | 6801e169010aSmrg $GREP ": [^:]* bundle" >/dev/null ; then 6802e169010aSmrg if test "X$dlopenmodule" != "X$lib"; then 6803e169010aSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 6804e169010aSmrg if test -z "$old_library" ; then 6805e8ead290Smrg echo 6806e8ead290Smrg echo "*** And there doesn't seem to be a static archive available" 6807e8ead290Smrg echo "*** The link will probably fail, sorry" 6808e169010aSmrg else 6809e169010aSmrg add="$dir/$old_library" 6810e169010aSmrg fi 6811e169010aSmrg elif test -n "$old_library"; then 6812e169010aSmrg add="$dir/$old_library" 6813e169010aSmrg fi 6814e169010aSmrg fi 6815e169010aSmrg esac 6816e169010aSmrg elif test "$hardcode_minus_L" = no; then 6817e169010aSmrg case $host in 6818e169010aSmrg *-*-sunos*) add_shlibpath="$dir" ;; 6819e169010aSmrg esac 6820e169010aSmrg add_dir="-L$dir" 6821e169010aSmrg add="-l$name" 6822e169010aSmrg elif test "$hardcode_shlibpath_var" = no; then 6823e169010aSmrg add_shlibpath="$dir" 6824e169010aSmrg add="-l$name" 6825e169010aSmrg else 6826e169010aSmrg lib_linked=no 6827e169010aSmrg fi 6828e169010aSmrg ;; 6829e169010aSmrg relink) 6830e169010aSmrg if test "$hardcode_direct" = yes && 6831e169010aSmrg test "$hardcode_direct_absolute" = no; then 6832e169010aSmrg add="$dir/$linklib" 6833e169010aSmrg elif test "$hardcode_minus_L" = yes; then 6834e169010aSmrg add_dir="-L$dir" 6835e169010aSmrg # Try looking first in the location we're being installed to. 6836e169010aSmrg if test -n "$inst_prefix_dir"; then 6837e169010aSmrg case $libdir in 6838e169010aSmrg [\\/]*) 6839c63293b5Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 6840e169010aSmrg ;; 6841e169010aSmrg esac 6842e169010aSmrg fi 6843e169010aSmrg add="-l$name" 6844e169010aSmrg elif test "$hardcode_shlibpath_var" = yes; then 6845e169010aSmrg add_shlibpath="$dir" 6846e169010aSmrg add="-l$name" 6847e169010aSmrg else 6848e169010aSmrg lib_linked=no 6849e169010aSmrg fi 6850e169010aSmrg ;; 6851e169010aSmrg *) lib_linked=no ;; 6852e169010aSmrg esac 6853e169010aSmrg 6854e169010aSmrg if test "$lib_linked" != yes; then 6855e169010aSmrg func_fatal_configuration "unsupported hardcode properties" 6856e169010aSmrg fi 6857e169010aSmrg 6858e169010aSmrg if test -n "$add_shlibpath"; then 6859e169010aSmrg case :$compile_shlibpath: in 6860e169010aSmrg *":$add_shlibpath:"*) ;; 6861c63293b5Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 6862e169010aSmrg esac 6863e169010aSmrg fi 6864e169010aSmrg if test "$linkmode" = prog; then 6865e169010aSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 6866e169010aSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 6867e169010aSmrg else 6868e169010aSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 6869e169010aSmrg test -n "$add" && deplibs="$add $deplibs" 6870e169010aSmrg if test "$hardcode_direct" != yes && 6871e169010aSmrg test "$hardcode_minus_L" != yes && 6872e169010aSmrg test "$hardcode_shlibpath_var" = yes; then 6873e169010aSmrg case :$finalize_shlibpath: in 6874e169010aSmrg *":$libdir:"*) ;; 6875c63293b5Smrg *) func_append finalize_shlibpath "$libdir:" ;; 6876e169010aSmrg esac 6877e169010aSmrg fi 6878e169010aSmrg fi 6879e169010aSmrg fi 6880e169010aSmrg 6881c63293b5Smrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 6882e169010aSmrg add_shlibpath= 6883e169010aSmrg add_dir= 6884e169010aSmrg add= 6885e169010aSmrg # Finalize command for both is simple: just hardcode it. 6886e169010aSmrg if test "$hardcode_direct" = yes && 6887e169010aSmrg test "$hardcode_direct_absolute" = no; then 6888e169010aSmrg add="$libdir/$linklib" 6889e169010aSmrg elif test "$hardcode_minus_L" = yes; then 6890e169010aSmrg add_dir="-L$libdir" 6891e169010aSmrg add="-l$name" 6892e169010aSmrg elif test "$hardcode_shlibpath_var" = yes; then 6893e169010aSmrg case :$finalize_shlibpath: in 6894e169010aSmrg *":$libdir:"*) ;; 6895c63293b5Smrg *) func_append finalize_shlibpath "$libdir:" ;; 6896e169010aSmrg esac 6897e169010aSmrg add="-l$name" 6898e169010aSmrg elif test "$hardcode_automatic" = yes; then 6899e169010aSmrg if test -n "$inst_prefix_dir" && 6900e169010aSmrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 6901e169010aSmrg add="$inst_prefix_dir$libdir/$linklib" 6902e169010aSmrg else 6903e169010aSmrg add="$libdir/$linklib" 6904e169010aSmrg fi 6905e169010aSmrg else 6906e169010aSmrg # We cannot seem to hardcode it, guess we'll fake it. 6907e169010aSmrg add_dir="-L$libdir" 6908e169010aSmrg # Try looking first in the location we're being installed to. 6909e169010aSmrg if test -n "$inst_prefix_dir"; then 6910e169010aSmrg case $libdir in 6911e169010aSmrg [\\/]*) 6912c63293b5Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 6913e169010aSmrg ;; 6914e169010aSmrg esac 6915e169010aSmrg fi 6916e169010aSmrg add="-l$name" 6917e169010aSmrg fi 6918e169010aSmrg 6919e169010aSmrg if test "$linkmode" = prog; then 6920e169010aSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 6921e169010aSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 6922e169010aSmrg else 6923e169010aSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 6924e169010aSmrg test -n "$add" && deplibs="$add $deplibs" 6925e169010aSmrg fi 6926e169010aSmrg fi 6927e169010aSmrg elif test "$linkmode" = prog; then 6928e169010aSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 6929e169010aSmrg # is not unsupported. This is valid on all known static and 6930e169010aSmrg # shared platforms. 6931e169010aSmrg if test "$hardcode_direct" != unsupported; then 6932e169010aSmrg test -n "$old_library" && linklib="$old_library" 6933e169010aSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 6934e169010aSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 6935e169010aSmrg else 6936e169010aSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 6937e169010aSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 6938e169010aSmrg fi 6939e169010aSmrg elif test "$build_libtool_libs" = yes; then 6940e169010aSmrg # Not a shared library 6941e169010aSmrg if test "$deplibs_check_method" != pass_all; then 6942e169010aSmrg # We're trying link a shared library against a static one 6943e169010aSmrg # but the system doesn't support it. 6944e169010aSmrg 6945e169010aSmrg # Just print a warning and add the library to dependency_libs so 6946e169010aSmrg # that the program can be linked against the static library. 6947e8ead290Smrg echo 6948e169010aSmrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 6949e8ead290Smrg echo "*** I have the capability to make that library automatically link in when" 6950e8ead290Smrg echo "*** you link to this library. But I can only do this if you have a" 6951e8ead290Smrg echo "*** shared version of the library, which you do not appear to have." 6952e169010aSmrg if test "$module" = yes; then 6953e8ead290Smrg echo "*** But as you try to build a module library, libtool will still create " 6954e8ead290Smrg echo "*** a static module, that should work as long as the dlopening application" 6955e8ead290Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 6956e169010aSmrg if test -z "$global_symbol_pipe"; then 6957e8ead290Smrg echo 6958e8ead290Smrg echo "*** However, this would only work if libtool was able to extract symbol" 6959e8ead290Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 6960e8ead290Smrg echo "*** not find such a program. So, this module is probably useless." 6961e8ead290Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 6962e169010aSmrg fi 6963e169010aSmrg if test "$build_old_libs" = no; then 6964e169010aSmrg build_libtool_libs=module 6965e169010aSmrg build_old_libs=yes 6966e169010aSmrg else 6967e169010aSmrg build_libtool_libs=no 6968e169010aSmrg fi 6969e169010aSmrg fi 6970e169010aSmrg else 6971e169010aSmrg deplibs="$dir/$old_library $deplibs" 6972e169010aSmrg link_static=yes 6973e169010aSmrg fi 6974e169010aSmrg fi # link shared/static library? 6975e169010aSmrg 6976e169010aSmrg if test "$linkmode" = lib; then 6977e169010aSmrg if test -n "$dependency_libs" && 6978e169010aSmrg { test "$hardcode_into_libs" != yes || 6979e169010aSmrg test "$build_old_libs" = yes || 6980e169010aSmrg test "$link_static" = yes; }; then 6981e169010aSmrg # Extract -R from dependency_libs 6982e169010aSmrg temp_deplibs= 6983e169010aSmrg for libdir in $dependency_libs; do 6984e169010aSmrg case $libdir in 6985e169010aSmrg -R*) func_stripname '-R' '' "$libdir" 6986e169010aSmrg temp_xrpath=$func_stripname_result 6987e169010aSmrg case " $xrpath " in 6988e169010aSmrg *" $temp_xrpath "*) ;; 6989c63293b5Smrg *) func_append xrpath " $temp_xrpath";; 6990e169010aSmrg esac;; 6991c63293b5Smrg *) func_append temp_deplibs " $libdir";; 6992e169010aSmrg esac 6993e169010aSmrg done 6994e169010aSmrg dependency_libs="$temp_deplibs" 6995e169010aSmrg fi 6996e169010aSmrg 6997c63293b5Smrg func_append newlib_search_path " $absdir" 6998e169010aSmrg # Link against this library 6999e169010aSmrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 7000e169010aSmrg # ... and its dependency_libs 7001e169010aSmrg tmp_libs= 7002e169010aSmrg for deplib in $dependency_libs; do 7003e169010aSmrg newdependency_libs="$deplib $newdependency_libs" 7004c63293b5Smrg case $deplib in 7005c63293b5Smrg -L*) func_stripname '-L' '' "$deplib" 7006c63293b5Smrg func_resolve_sysroot "$func_stripname_result";; 7007c63293b5Smrg *) func_resolve_sysroot "$deplib" ;; 7008c63293b5Smrg esac 7009c63293b5Smrg if $opt_preserve_dup_deps ; then 7010e169010aSmrg case "$tmp_libs " in 7011c63293b5Smrg *" $func_resolve_sysroot_result "*) 7012c63293b5Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 7013e169010aSmrg esac 7014e169010aSmrg fi 7015c63293b5Smrg func_append tmp_libs " $func_resolve_sysroot_result" 7016e169010aSmrg done 7017e169010aSmrg 7018e169010aSmrg if test "$link_all_deplibs" != no; then 7019e169010aSmrg # Add the search paths of all dependency libraries 7020e169010aSmrg for deplib in $dependency_libs; do 7021e8ead290Smrg path= 7022e169010aSmrg case $deplib in 7023e169010aSmrg -L*) path="$deplib" ;; 7024e169010aSmrg *.la) 7025c63293b5Smrg func_resolve_sysroot "$deplib" 7026c63293b5Smrg deplib=$func_resolve_sysroot_result 7027e169010aSmrg func_dirname "$deplib" "" "." 7028c63293b5Smrg dir=$func_dirname_result 7029e169010aSmrg # We need an absolute path. 7030e169010aSmrg case $dir in 7031e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 7032e169010aSmrg *) 7033e169010aSmrg absdir=`cd "$dir" && pwd` 7034e169010aSmrg if test -z "$absdir"; then 7035e169010aSmrg func_warning "cannot determine absolute directory name of \`$dir'" 7036e169010aSmrg absdir="$dir" 7037e169010aSmrg fi 7038e169010aSmrg ;; 7039e169010aSmrg esac 7040e169010aSmrg if $GREP "^installed=no" $deplib > /dev/null; then 7041e169010aSmrg case $host in 7042e169010aSmrg *-*-darwin*) 7043e169010aSmrg depdepl= 7044e169010aSmrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 7045e169010aSmrg if test -n "$deplibrary_names" ; then 7046e169010aSmrg for tmp in $deplibrary_names ; do 7047e169010aSmrg depdepl=$tmp 7048e169010aSmrg done 7049e169010aSmrg if test -f "$absdir/$objdir/$depdepl" ; then 7050e169010aSmrg depdepl="$absdir/$objdir/$depdepl" 7051e169010aSmrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7052e169010aSmrg if test -z "$darwin_install_name"; then 7053e169010aSmrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7054e169010aSmrg fi 7055c63293b5Smrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 7056c63293b5Smrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 7057e169010aSmrg path= 7058e169010aSmrg fi 7059e169010aSmrg fi 7060e169010aSmrg ;; 7061e169010aSmrg *) 7062e169010aSmrg path="-L$absdir/$objdir" 7063e169010aSmrg ;; 7064e169010aSmrg esac 7065e169010aSmrg else 7066e169010aSmrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 7067e169010aSmrg test -z "$libdir" && \ 7068e169010aSmrg func_fatal_error "\`$deplib' is not a valid libtool archive" 7069e169010aSmrg test "$absdir" != "$libdir" && \ 7070e169010aSmrg func_warning "\`$deplib' seems to be moved" 7071e169010aSmrg 7072e169010aSmrg path="-L$absdir" 7073e169010aSmrg fi 7074e169010aSmrg ;; 7075e169010aSmrg esac 7076e169010aSmrg case " $deplibs " in 7077e169010aSmrg *" $path "*) ;; 7078e169010aSmrg *) deplibs="$path $deplibs" ;; 7079e169010aSmrg esac 7080e169010aSmrg done 7081e169010aSmrg fi # link_all_deplibs != no 7082e169010aSmrg fi # linkmode = lib 7083e169010aSmrg done # for deplib in $libs 7084e169010aSmrg if test "$pass" = link; then 7085e169010aSmrg if test "$linkmode" = "prog"; then 7086e169010aSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 7087e169010aSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 7088e169010aSmrg else 7089e8ead290Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7090e169010aSmrg fi 7091e169010aSmrg fi 7092e169010aSmrg dependency_libs="$newdependency_libs" 7093e169010aSmrg if test "$pass" = dlpreopen; then 7094e169010aSmrg # Link the dlpreopened libraries before other libraries 7095e169010aSmrg for deplib in $save_deplibs; do 7096e169010aSmrg deplibs="$deplib $deplibs" 7097e169010aSmrg done 7098e169010aSmrg fi 7099e169010aSmrg if test "$pass" != dlopen; then 7100e169010aSmrg if test "$pass" != conv; then 7101e169010aSmrg # Make sure lib_search_path contains only unique directories. 7102e169010aSmrg lib_search_path= 7103e169010aSmrg for dir in $newlib_search_path; do 7104e169010aSmrg case "$lib_search_path " in 7105e169010aSmrg *" $dir "*) ;; 7106c63293b5Smrg *) func_append lib_search_path " $dir" ;; 7107e169010aSmrg esac 7108e169010aSmrg done 7109e169010aSmrg newlib_search_path= 7110e169010aSmrg fi 7111e169010aSmrg 7112e169010aSmrg if test "$linkmode,$pass" != "prog,link"; then 7113e169010aSmrg vars="deplibs" 7114e169010aSmrg else 7115e169010aSmrg vars="compile_deplibs finalize_deplibs" 7116e169010aSmrg fi 7117e169010aSmrg for var in $vars dependency_libs; do 7118e169010aSmrg # Add libraries to $var in reverse order 7119e169010aSmrg eval tmp_libs=\"\$$var\" 7120e169010aSmrg new_libs= 7121e169010aSmrg for deplib in $tmp_libs; do 7122e169010aSmrg # FIXME: Pedantically, this is the right thing to do, so 7123e169010aSmrg # that some nasty dependency loop isn't accidentally 7124e169010aSmrg # broken: 7125e169010aSmrg #new_libs="$deplib $new_libs" 7126e169010aSmrg # Pragmatically, this seems to cause very few problems in 7127e169010aSmrg # practice: 7128e169010aSmrg case $deplib in 7129e169010aSmrg -L*) new_libs="$deplib $new_libs" ;; 7130e169010aSmrg -R*) ;; 7131e169010aSmrg *) 7132e169010aSmrg # And here is the reason: when a library appears more 7133e169010aSmrg # than once as an explicit dependence of a library, or 7134e169010aSmrg # is implicitly linked in more than once by the 7135e169010aSmrg # compiler, it is considered special, and multiple 7136e169010aSmrg # occurrences thereof are not removed. Compare this 7137e169010aSmrg # with having the same library being listed as a 7138e169010aSmrg # dependency of multiple other libraries: in this case, 7139e169010aSmrg # we know (pedantically, we assume) the library does not 7140e169010aSmrg # need to be listed more than once, so we keep only the 7141e169010aSmrg # last copy. This is not always right, but it is rare 7142e169010aSmrg # enough that we require users that really mean to play 7143e169010aSmrg # such unportable linking tricks to link the library 7144e169010aSmrg # using -Wl,-lname, so that libtool does not consider it 7145e169010aSmrg # for duplicate removal. 7146e169010aSmrg case " $specialdeplibs " in 7147e169010aSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 7148e169010aSmrg *) 7149e169010aSmrg case " $new_libs " in 7150e169010aSmrg *" $deplib "*) ;; 7151e169010aSmrg *) new_libs="$deplib $new_libs" ;; 7152e169010aSmrg esac 7153e169010aSmrg ;; 7154e169010aSmrg esac 7155e169010aSmrg ;; 7156e169010aSmrg esac 7157e169010aSmrg done 7158e169010aSmrg tmp_libs= 7159e169010aSmrg for deplib in $new_libs; do 7160e169010aSmrg case $deplib in 7161e169010aSmrg -L*) 7162e169010aSmrg case " $tmp_libs " in 7163e169010aSmrg *" $deplib "*) ;; 7164c63293b5Smrg *) func_append tmp_libs " $deplib" ;; 7165e169010aSmrg esac 7166e169010aSmrg ;; 7167c63293b5Smrg *) func_append tmp_libs " $deplib" ;; 7168e169010aSmrg esac 7169e169010aSmrg done 7170e169010aSmrg eval $var=\"$tmp_libs\" 7171e169010aSmrg done # for var 7172e169010aSmrg fi 7173e169010aSmrg # Last step: remove runtime libs from dependency_libs 7174e169010aSmrg # (they stay in deplibs) 7175e169010aSmrg tmp_libs= 7176e169010aSmrg for i in $dependency_libs ; do 7177e169010aSmrg case " $predeps $postdeps $compiler_lib_search_path " in 7178e169010aSmrg *" $i "*) 7179e169010aSmrg i="" 7180e169010aSmrg ;; 7181e169010aSmrg esac 7182e169010aSmrg if test -n "$i" ; then 7183c63293b5Smrg func_append tmp_libs " $i" 7184e169010aSmrg fi 7185e169010aSmrg done 7186e169010aSmrg dependency_libs=$tmp_libs 7187e169010aSmrg done # for pass 7188e169010aSmrg if test "$linkmode" = prog; then 7189e169010aSmrg dlfiles="$newdlfiles" 7190e169010aSmrg fi 7191e169010aSmrg if test "$linkmode" = prog || test "$linkmode" = lib; then 7192e169010aSmrg dlprefiles="$newdlprefiles" 7193e169010aSmrg fi 7194e169010aSmrg 7195e169010aSmrg case $linkmode in 7196e169010aSmrg oldlib) 7197e169010aSmrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 7198e169010aSmrg func_warning "\`-dlopen' is ignored for archives" 7199e169010aSmrg fi 7200e169010aSmrg 7201e169010aSmrg case " $deplibs" in 7202e169010aSmrg *\ -l* | *\ -L*) 7203e169010aSmrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 7204e169010aSmrg esac 7205e169010aSmrg 7206e169010aSmrg test -n "$rpath" && \ 7207e169010aSmrg func_warning "\`-rpath' is ignored for archives" 7208e169010aSmrg 7209e169010aSmrg test -n "$xrpath" && \ 7210e169010aSmrg func_warning "\`-R' is ignored for archives" 7211e169010aSmrg 7212e169010aSmrg test -n "$vinfo" && \ 7213e169010aSmrg func_warning "\`-version-info/-version-number' is ignored for archives" 7214e169010aSmrg 7215e169010aSmrg test -n "$release" && \ 7216e169010aSmrg func_warning "\`-release' is ignored for archives" 7217e169010aSmrg 7218e169010aSmrg test -n "$export_symbols$export_symbols_regex" && \ 7219e169010aSmrg func_warning "\`-export-symbols' is ignored for archives" 7220e169010aSmrg 7221e169010aSmrg # Now set the variables for building old libraries. 7222e169010aSmrg build_libtool_libs=no 7223e169010aSmrg oldlibs="$output" 7224c63293b5Smrg func_append objs "$old_deplibs" 7225e169010aSmrg ;; 7226e169010aSmrg 7227e169010aSmrg lib) 7228e169010aSmrg # Make sure we only generate libraries of the form `libNAME.la'. 7229e169010aSmrg case $outputname in 7230e169010aSmrg lib*) 7231e169010aSmrg func_stripname 'lib' '.la' "$outputname" 7232e169010aSmrg name=$func_stripname_result 7233e169010aSmrg eval shared_ext=\"$shrext_cmds\" 7234e169010aSmrg eval libname=\"$libname_spec\" 7235e169010aSmrg ;; 7236e169010aSmrg *) 7237e169010aSmrg test "$module" = no && \ 7238e169010aSmrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 7239e169010aSmrg 7240e169010aSmrg if test "$need_lib_prefix" != no; then 7241e169010aSmrg # Add the "lib" prefix for modules if required 7242e169010aSmrg func_stripname '' '.la' "$outputname" 7243e169010aSmrg name=$func_stripname_result 7244e169010aSmrg eval shared_ext=\"$shrext_cmds\" 7245e169010aSmrg eval libname=\"$libname_spec\" 7246e169010aSmrg else 7247e169010aSmrg func_stripname '' '.la' "$outputname" 7248e169010aSmrg libname=$func_stripname_result 7249e169010aSmrg fi 7250e169010aSmrg ;; 7251e169010aSmrg esac 7252e169010aSmrg 7253e169010aSmrg if test -n "$objs"; then 7254e169010aSmrg if test "$deplibs_check_method" != pass_all; then 7255e169010aSmrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 7256e169010aSmrg else 7257e8ead290Smrg echo 7258e169010aSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 7259e169010aSmrg $ECHO "*** objects $objs is not portable!" 7260c63293b5Smrg func_append libobjs " $objs" 7261e169010aSmrg fi 7262e169010aSmrg fi 7263e169010aSmrg 7264e169010aSmrg test "$dlself" != no && \ 7265e169010aSmrg func_warning "\`-dlopen self' is ignored for libtool libraries" 7266e169010aSmrg 7267e169010aSmrg set dummy $rpath 7268e169010aSmrg shift 7269e169010aSmrg test "$#" -gt 1 && \ 7270e169010aSmrg func_warning "ignoring multiple \`-rpath's for a libtool library" 7271e169010aSmrg 7272e169010aSmrg install_libdir="$1" 7273e169010aSmrg 7274e169010aSmrg oldlibs= 7275e169010aSmrg if test -z "$rpath"; then 7276e169010aSmrg if test "$build_libtool_libs" = yes; then 7277e169010aSmrg # Building a libtool convenience library. 7278e169010aSmrg # Some compilers have problems with a `.al' extension so 7279e169010aSmrg # convenience libraries should have the same extension an 7280e169010aSmrg # archive normally would. 7281e169010aSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 7282e169010aSmrg build_libtool_libs=convenience 7283e169010aSmrg build_old_libs=yes 7284e169010aSmrg fi 7285e169010aSmrg 7286e169010aSmrg test -n "$vinfo" && \ 7287e169010aSmrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 7288e169010aSmrg 7289e169010aSmrg test -n "$release" && \ 7290e169010aSmrg func_warning "\`-release' is ignored for convenience libraries" 7291e169010aSmrg else 7292e169010aSmrg 7293e169010aSmrg # Parse the version information argument. 7294e169010aSmrg save_ifs="$IFS"; IFS=':' 7295e169010aSmrg set dummy $vinfo 0 0 0 7296e169010aSmrg shift 7297e169010aSmrg IFS="$save_ifs" 7298e169010aSmrg 7299e169010aSmrg test -n "$7" && \ 7300e169010aSmrg func_fatal_help "too many parameters to \`-version-info'" 7301e169010aSmrg 7302e169010aSmrg # convert absolute version numbers to libtool ages 7303e169010aSmrg # this retains compatibility with .la files and attempts 7304e169010aSmrg # to make the code below a bit more comprehensible 7305e169010aSmrg 7306e169010aSmrg case $vinfo_number in 7307e169010aSmrg yes) 7308e169010aSmrg number_major="$1" 7309e169010aSmrg number_minor="$2" 7310e169010aSmrg number_revision="$3" 7311e169010aSmrg # 7312e169010aSmrg # There are really only two kinds -- those that 7313e169010aSmrg # use the current revision as the major version 7314e169010aSmrg # and those that subtract age and use age as 7315e169010aSmrg # a minor version. But, then there is irix 7316e169010aSmrg # which has an extra 1 added just for fun 7317e169010aSmrg # 7318e169010aSmrg case $version_type in 7319e169010aSmrg darwin|linux|osf|windows|none) 7320e169010aSmrg func_arith $number_major + $number_minor 7321e169010aSmrg current=$func_arith_result 7322e169010aSmrg age="$number_minor" 7323e169010aSmrg revision="$number_revision" 7324e169010aSmrg ;; 7325e8ead290Smrg freebsd-aout|freebsd-elf|qnx|sunos) 7326e169010aSmrg current="$number_major" 7327e169010aSmrg revision="$number_minor" 7328e169010aSmrg age="0" 7329e169010aSmrg ;; 7330e169010aSmrg irix|nonstopux) 7331e169010aSmrg func_arith $number_major + $number_minor 7332e169010aSmrg current=$func_arith_result 7333e169010aSmrg age="$number_minor" 7334e169010aSmrg revision="$number_minor" 7335e169010aSmrg lt_irix_increment=no 7336e169010aSmrg ;; 7337e169010aSmrg esac 7338e169010aSmrg ;; 7339e169010aSmrg no) 7340e169010aSmrg current="$1" 7341e169010aSmrg revision="$2" 7342e169010aSmrg age="$3" 7343e169010aSmrg ;; 7344e169010aSmrg esac 7345e169010aSmrg 7346e169010aSmrg # Check that each of the things are valid numbers. 7347e169010aSmrg case $current in 7348e169010aSmrg 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]) ;; 7349e169010aSmrg *) 7350e169010aSmrg func_error "CURRENT \`$current' must be a nonnegative integer" 7351e169010aSmrg func_fatal_error "\`$vinfo' is not valid version information" 7352e169010aSmrg ;; 7353e169010aSmrg esac 7354e169010aSmrg 7355e169010aSmrg case $revision in 7356e169010aSmrg 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]) ;; 7357e169010aSmrg *) 7358e169010aSmrg func_error "REVISION \`$revision' must be a nonnegative integer" 7359e169010aSmrg func_fatal_error "\`$vinfo' is not valid version information" 7360e169010aSmrg ;; 7361e169010aSmrg esac 7362e169010aSmrg 7363e169010aSmrg case $age in 7364e169010aSmrg 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]) ;; 7365e169010aSmrg *) 7366e169010aSmrg func_error "AGE \`$age' must be a nonnegative integer" 7367e169010aSmrg func_fatal_error "\`$vinfo' is not valid version information" 7368e169010aSmrg ;; 7369e169010aSmrg esac 7370e169010aSmrg 7371e169010aSmrg if test "$age" -gt "$current"; then 7372e169010aSmrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 7373e169010aSmrg func_fatal_error "\`$vinfo' is not valid version information" 7374e169010aSmrg fi 7375e169010aSmrg 7376e169010aSmrg # Calculate the version variables. 7377e169010aSmrg major= 7378e169010aSmrg versuffix= 7379e169010aSmrg verstring= 7380e169010aSmrg case $version_type in 7381e169010aSmrg none) ;; 7382e169010aSmrg 7383e169010aSmrg darwin) 7384e169010aSmrg # Like Linux, but with the current version available in 7385e169010aSmrg # verstring for coding it into the library header 7386e169010aSmrg func_arith $current - $age 7387e169010aSmrg major=.$func_arith_result 7388e169010aSmrg versuffix="$major.$age.$revision" 7389e169010aSmrg # Darwin ld doesn't like 0 for these options... 7390e169010aSmrg func_arith $current + 1 7391e169010aSmrg minor_current=$func_arith_result 7392e169010aSmrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 7393e169010aSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 7394e169010aSmrg ;; 7395e169010aSmrg 7396e169010aSmrg freebsd-aout) 7397e169010aSmrg major=".$current" 7398e169010aSmrg versuffix=".$current.$revision"; 7399e169010aSmrg ;; 7400e169010aSmrg 7401e169010aSmrg freebsd-elf) 7402e169010aSmrg major=".$current" 7403e169010aSmrg versuffix=".$current" 7404e169010aSmrg ;; 7405e169010aSmrg 7406e169010aSmrg irix | nonstopux) 7407e169010aSmrg if test "X$lt_irix_increment" = "Xno"; then 7408e169010aSmrg func_arith $current - $age 7409e169010aSmrg else 7410e169010aSmrg func_arith $current - $age + 1 7411e169010aSmrg fi 7412e169010aSmrg major=$func_arith_result 7413e169010aSmrg 7414e169010aSmrg case $version_type in 7415e169010aSmrg nonstopux) verstring_prefix=nonstopux ;; 7416e169010aSmrg *) verstring_prefix=sgi ;; 7417e169010aSmrg esac 7418e169010aSmrg verstring="$verstring_prefix$major.$revision" 7419e169010aSmrg 7420e169010aSmrg # Add in all the interfaces that we are compatible with. 7421e169010aSmrg loop=$revision 7422e169010aSmrg while test "$loop" -ne 0; do 7423e169010aSmrg func_arith $revision - $loop 7424e169010aSmrg iface=$func_arith_result 7425e169010aSmrg func_arith $loop - 1 7426e169010aSmrg loop=$func_arith_result 7427e169010aSmrg verstring="$verstring_prefix$major.$iface:$verstring" 7428e169010aSmrg done 7429e169010aSmrg 7430e169010aSmrg # Before this point, $major must not contain `.'. 7431e169010aSmrg major=.$major 7432e169010aSmrg versuffix="$major.$revision" 7433e169010aSmrg ;; 7434e169010aSmrg 7435e169010aSmrg linux) 7436e169010aSmrg func_arith $current - $age 7437e169010aSmrg major=.$func_arith_result 7438e169010aSmrg versuffix="$major.$age.$revision" 7439e169010aSmrg ;; 7440e169010aSmrg 7441e169010aSmrg osf) 7442e169010aSmrg func_arith $current - $age 7443e169010aSmrg major=.$func_arith_result 7444e169010aSmrg versuffix=".$current.$age.$revision" 7445e169010aSmrg verstring="$current.$age.$revision" 7446e169010aSmrg 7447e169010aSmrg # Add in all the interfaces that we are compatible with. 7448e169010aSmrg loop=$age 7449e169010aSmrg while test "$loop" -ne 0; do 7450e169010aSmrg func_arith $current - $loop 7451e169010aSmrg iface=$func_arith_result 7452e169010aSmrg func_arith $loop - 1 7453e169010aSmrg loop=$func_arith_result 7454e169010aSmrg verstring="$verstring:${iface}.0" 7455e169010aSmrg done 7456e169010aSmrg 7457e169010aSmrg # Make executables depend on our current version. 7458c63293b5Smrg func_append verstring ":${current}.0" 7459e169010aSmrg ;; 7460e169010aSmrg 7461e169010aSmrg qnx) 7462e169010aSmrg major=".$current" 7463e169010aSmrg versuffix=".$current" 7464e169010aSmrg ;; 7465e169010aSmrg 7466e169010aSmrg sunos) 7467e169010aSmrg major=".$current" 7468e169010aSmrg versuffix=".$current.$revision" 7469e169010aSmrg ;; 7470e169010aSmrg 7471e169010aSmrg windows) 7472e169010aSmrg # Use '-' rather than '.', since we only want one 7473e169010aSmrg # extension on DOS 8.3 filesystems. 7474e169010aSmrg func_arith $current - $age 7475e169010aSmrg major=$func_arith_result 7476e169010aSmrg versuffix="-$major" 7477e169010aSmrg ;; 7478e169010aSmrg 7479e169010aSmrg *) 7480e169010aSmrg func_fatal_configuration "unknown library version type \`$version_type'" 7481e169010aSmrg ;; 7482e169010aSmrg esac 7483e169010aSmrg 7484e169010aSmrg # Clear the version info if we defaulted, and they specified a release. 7485e169010aSmrg if test -z "$vinfo" && test -n "$release"; then 7486e169010aSmrg major= 7487e169010aSmrg case $version_type in 7488e169010aSmrg darwin) 7489e169010aSmrg # we can't check for "0.0" in archive_cmds due to quoting 7490e169010aSmrg # problems, so we reset it completely 7491e169010aSmrg verstring= 7492e169010aSmrg ;; 7493e169010aSmrg *) 7494e169010aSmrg verstring="0.0" 7495e169010aSmrg ;; 7496e169010aSmrg esac 7497e169010aSmrg if test "$need_version" = no; then 7498e169010aSmrg versuffix= 7499e169010aSmrg else 7500e169010aSmrg versuffix=".0.0" 7501e169010aSmrg fi 7502e169010aSmrg fi 7503e169010aSmrg 7504e169010aSmrg # Remove version info from name if versioning should be avoided 7505e169010aSmrg if test "$avoid_version" = yes && test "$need_version" = no; then 7506e169010aSmrg major= 7507e169010aSmrg versuffix= 7508e169010aSmrg verstring="" 7509e169010aSmrg fi 7510e169010aSmrg 7511e169010aSmrg # Check to see if the archive will have undefined symbols. 7512e169010aSmrg if test "$allow_undefined" = yes; then 7513e169010aSmrg if test "$allow_undefined_flag" = unsupported; then 7514e169010aSmrg func_warning "undefined symbols not allowed in $host shared libraries" 7515e169010aSmrg build_libtool_libs=no 7516e169010aSmrg build_old_libs=yes 7517e169010aSmrg fi 7518e169010aSmrg else 7519e169010aSmrg # Don't allow undefined symbols. 7520e169010aSmrg allow_undefined_flag="$no_undefined_flag" 7521e169010aSmrg fi 7522e169010aSmrg 7523e169010aSmrg fi 7524e169010aSmrg 7525e169010aSmrg func_generate_dlsyms "$libname" "$libname" "yes" 7526c63293b5Smrg func_append libobjs " $symfileobj" 7527e169010aSmrg test "X$libobjs" = "X " && libobjs= 7528e169010aSmrg 7529c63293b5Smrg if test "$opt_mode" != relink; then 7530e169010aSmrg # Remove our outputs, but don't remove object files since they 7531e169010aSmrg # may have been created when compiling PIC objects. 7532e169010aSmrg removelist= 7533e169010aSmrg tempremovelist=`$ECHO "$output_objdir/*"` 7534e169010aSmrg for p in $tempremovelist; do 7535e169010aSmrg case $p in 7536e169010aSmrg *.$objext | *.gcno) 7537e169010aSmrg ;; 7538e169010aSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 7539e169010aSmrg if test "X$precious_files_regex" != "X"; then 7540e169010aSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 7541e169010aSmrg then 7542e169010aSmrg continue 7543e169010aSmrg fi 7544e169010aSmrg fi 7545c63293b5Smrg func_append removelist " $p" 7546e169010aSmrg ;; 7547e169010aSmrg *) ;; 7548e169010aSmrg esac 7549e169010aSmrg done 7550e169010aSmrg test -n "$removelist" && \ 7551e169010aSmrg func_show_eval "${RM}r \$removelist" 7552e169010aSmrg fi 7553e169010aSmrg 7554e169010aSmrg # Now set the variables for building old libraries. 7555e169010aSmrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 7556c63293b5Smrg func_append oldlibs " $output_objdir/$libname.$libext" 7557e169010aSmrg 7558e169010aSmrg # Transform .lo files to .o files. 7559e8ead290Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 7560e169010aSmrg fi 7561e169010aSmrg 7562e169010aSmrg # Eliminate all temporary directories. 7563e169010aSmrg #for path in $notinst_path; do 7564e8ead290Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 7565e8ead290Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 7566e8ead290Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 7567e169010aSmrg #done 7568e169010aSmrg 7569e169010aSmrg if test -n "$xrpath"; then 7570e169010aSmrg # If the user specified any rpath flags, then add them. 7571e169010aSmrg temp_xrpath= 7572e169010aSmrg for libdir in $xrpath; do 7573c63293b5Smrg func_replace_sysroot "$libdir" 7574c63293b5Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 7575e169010aSmrg case "$finalize_rpath " in 7576e169010aSmrg *" $libdir "*) ;; 7577c63293b5Smrg *) func_append finalize_rpath " $libdir" ;; 7578e169010aSmrg esac 7579e169010aSmrg done 7580e169010aSmrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 7581e169010aSmrg dependency_libs="$temp_xrpath $dependency_libs" 7582e169010aSmrg fi 7583e169010aSmrg fi 7584e169010aSmrg 7585e169010aSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 7586e169010aSmrg old_dlfiles="$dlfiles" 7587e169010aSmrg dlfiles= 7588e169010aSmrg for lib in $old_dlfiles; do 7589e169010aSmrg case " $dlprefiles $dlfiles " in 7590e169010aSmrg *" $lib "*) ;; 7591c63293b5Smrg *) func_append dlfiles " $lib" ;; 7592e169010aSmrg esac 7593e169010aSmrg done 7594e169010aSmrg 7595e169010aSmrg # Make sure dlprefiles contains only unique files 7596e169010aSmrg old_dlprefiles="$dlprefiles" 7597e169010aSmrg dlprefiles= 7598e169010aSmrg for lib in $old_dlprefiles; do 7599e169010aSmrg case "$dlprefiles " in 7600e169010aSmrg *" $lib "*) ;; 7601c63293b5Smrg *) func_append dlprefiles " $lib" ;; 7602e169010aSmrg esac 7603e169010aSmrg done 7604e169010aSmrg 7605e169010aSmrg if test "$build_libtool_libs" = yes; then 7606e169010aSmrg if test -n "$rpath"; then 7607e169010aSmrg case $host in 7608e8ead290Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 7609e169010aSmrg # these systems don't actually have a c library (as such)! 7610e169010aSmrg ;; 7611e169010aSmrg *-*-rhapsody* | *-*-darwin1.[012]) 7612e169010aSmrg # Rhapsody C library is in the System framework 7613c63293b5Smrg func_append deplibs " System.ltframework" 7614e169010aSmrg ;; 7615e169010aSmrg *-*-netbsd*) 7616e169010aSmrg # Don't link with libc until the a.out ld.so is fixed. 7617e169010aSmrg ;; 7618e169010aSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 7619e169010aSmrg # Do not include libc due to us having libc/libc_r. 7620e169010aSmrg ;; 7621e169010aSmrg *-*-sco3.2v5* | *-*-sco5v6*) 7622e169010aSmrg # Causes problems with __ctype 7623e169010aSmrg ;; 7624e169010aSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7625e169010aSmrg # Compiler inserts libc in the correct place for threads to work 7626e169010aSmrg ;; 7627e169010aSmrg *) 7628e169010aSmrg # Add libc to deplibs on all other systems if necessary. 7629e169010aSmrg if test "$build_libtool_need_lc" = "yes"; then 7630c63293b5Smrg func_append deplibs " -lc" 7631e169010aSmrg fi 7632e169010aSmrg ;; 7633e169010aSmrg esac 7634e169010aSmrg fi 7635e169010aSmrg 7636e169010aSmrg # Transform deplibs into only deplibs that can be linked in shared. 7637e169010aSmrg name_save=$name 7638e169010aSmrg libname_save=$libname 7639e169010aSmrg release_save=$release 7640e169010aSmrg versuffix_save=$versuffix 7641e169010aSmrg major_save=$major 7642e169010aSmrg # I'm not sure if I'm treating the release correctly. I think 7643e169010aSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 7644e169010aSmrg # add it in twice. Is that correct? 7645e169010aSmrg release="" 7646e169010aSmrg versuffix="" 7647e169010aSmrg major="" 7648e169010aSmrg newdeplibs= 7649e169010aSmrg droppeddeps=no 7650e169010aSmrg case $deplibs_check_method in 7651e169010aSmrg pass_all) 7652e169010aSmrg # Don't check for shared/static. Everything works. 7653e169010aSmrg # This might be a little naive. We might want to check 7654e169010aSmrg # whether the library exists or not. But this is on 7655e169010aSmrg # osf3 & osf4 and I'm not really sure... Just 7656e169010aSmrg # implementing what was already the behavior. 7657e169010aSmrg newdeplibs=$deplibs 7658e169010aSmrg ;; 7659e169010aSmrg test_compile) 7660e169010aSmrg # This code stresses the "libraries are programs" paradigm to its 7661e169010aSmrg # limits. Maybe even breaks it. We compile a program, linking it 7662e169010aSmrg # against the deplibs as a proxy for the library. Then we can check 7663e169010aSmrg # whether they linked in statically or dynamically with ldd. 7664e169010aSmrg $opt_dry_run || $RM conftest.c 7665e169010aSmrg cat > conftest.c <<EOF 7666e169010aSmrg int main() { return 0; } 7667e169010aSmrgEOF 7668e169010aSmrg $opt_dry_run || $RM conftest 7669e169010aSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 7670e169010aSmrg ldd_output=`ldd conftest` 7671e169010aSmrg for i in $deplibs; do 7672e169010aSmrg case $i in 7673e169010aSmrg -l*) 7674e169010aSmrg func_stripname -l '' "$i" 7675e169010aSmrg name=$func_stripname_result 7676e169010aSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7677e169010aSmrg case " $predeps $postdeps " in 7678e169010aSmrg *" $i "*) 7679c63293b5Smrg func_append newdeplibs " $i" 7680e169010aSmrg i="" 7681e169010aSmrg ;; 7682e169010aSmrg esac 7683e169010aSmrg fi 7684e169010aSmrg if test -n "$i" ; then 7685e169010aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 7686e169010aSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7687e169010aSmrg set dummy $deplib_matches; shift 7688e169010aSmrg deplib_match=$1 7689e169010aSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7690c63293b5Smrg func_append newdeplibs " $i" 7691e169010aSmrg else 7692e169010aSmrg droppeddeps=yes 7693e8ead290Smrg echo 7694e169010aSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7695e8ead290Smrg echo "*** I have the capability to make that library automatically link in when" 7696e8ead290Smrg echo "*** you link to this library. But I can only do this if you have a" 7697e8ead290Smrg echo "*** shared version of the library, which I believe you do not have" 7698e8ead290Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 7699e8ead290Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 7700e169010aSmrg fi 7701e169010aSmrg fi 7702e169010aSmrg ;; 7703e169010aSmrg *) 7704c63293b5Smrg func_append newdeplibs " $i" 7705e169010aSmrg ;; 7706e169010aSmrg esac 7707e169010aSmrg done 7708e169010aSmrg else 7709e169010aSmrg # Error occurred in the first compile. Let's try to salvage 7710e169010aSmrg # the situation: Compile a separate program for each library. 7711e169010aSmrg for i in $deplibs; do 7712e169010aSmrg case $i in 7713e169010aSmrg -l*) 7714e169010aSmrg func_stripname -l '' "$i" 7715e169010aSmrg name=$func_stripname_result 7716e169010aSmrg $opt_dry_run || $RM conftest 7717e169010aSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 7718e169010aSmrg ldd_output=`ldd conftest` 7719e169010aSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7720e169010aSmrg case " $predeps $postdeps " in 7721e169010aSmrg *" $i "*) 7722c63293b5Smrg func_append newdeplibs " $i" 7723e169010aSmrg i="" 7724e169010aSmrg ;; 7725e169010aSmrg esac 7726e169010aSmrg fi 7727e169010aSmrg if test -n "$i" ; then 7728e169010aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 7729e169010aSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7730e169010aSmrg set dummy $deplib_matches; shift 7731e169010aSmrg deplib_match=$1 7732e169010aSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7733c63293b5Smrg func_append newdeplibs " $i" 7734e169010aSmrg else 7735e169010aSmrg droppeddeps=yes 7736e8ead290Smrg echo 7737e169010aSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7738e8ead290Smrg echo "*** I have the capability to make that library automatically link in when" 7739e8ead290Smrg echo "*** you link to this library. But I can only do this if you have a" 7740e8ead290Smrg echo "*** shared version of the library, which you do not appear to have" 7741e8ead290Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 7742e8ead290Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 7743e169010aSmrg fi 7744e169010aSmrg fi 7745e169010aSmrg else 7746e169010aSmrg droppeddeps=yes 7747e8ead290Smrg echo 7748e169010aSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 7749e8ead290Smrg echo "*** make it link in! You will probably need to install it or some" 7750e8ead290Smrg echo "*** library that it depends on before this library will be fully" 7751e8ead290Smrg echo "*** functional. Installing it before continuing would be even better." 7752e169010aSmrg fi 7753e169010aSmrg ;; 7754e169010aSmrg *) 7755c63293b5Smrg func_append newdeplibs " $i" 7756e169010aSmrg ;; 7757e169010aSmrg esac 7758e169010aSmrg done 7759e169010aSmrg fi 7760e169010aSmrg ;; 7761e169010aSmrg file_magic*) 7762e169010aSmrg set dummy $deplibs_check_method; shift 7763e169010aSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7764e169010aSmrg for a_deplib in $deplibs; do 7765e169010aSmrg case $a_deplib in 7766e169010aSmrg -l*) 7767e169010aSmrg func_stripname -l '' "$a_deplib" 7768e169010aSmrg name=$func_stripname_result 7769e169010aSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7770e169010aSmrg case " $predeps $postdeps " in 7771e169010aSmrg *" $a_deplib "*) 7772c63293b5Smrg func_append newdeplibs " $a_deplib" 7773e169010aSmrg a_deplib="" 7774e169010aSmrg ;; 7775e169010aSmrg esac 7776e169010aSmrg fi 7777e169010aSmrg if test -n "$a_deplib" ; then 7778e169010aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 7779c63293b5Smrg if test -n "$file_magic_glob"; then 7780c63293b5Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 7781c63293b5Smrg else 7782c63293b5Smrg libnameglob=$libname 7783c63293b5Smrg fi 7784c63293b5Smrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 7785e169010aSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7786c63293b5Smrg if test "$want_nocaseglob" = yes; then 7787c63293b5Smrg shopt -s nocaseglob 7788c63293b5Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7789c63293b5Smrg $nocaseglob 7790c63293b5Smrg else 7791c63293b5Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7792c63293b5Smrg fi 7793e169010aSmrg for potent_lib in $potential_libs; do 7794e169010aSmrg # Follow soft links. 7795e169010aSmrg if ls -lLd "$potent_lib" 2>/dev/null | 7796e169010aSmrg $GREP " -> " >/dev/null; then 7797e169010aSmrg continue 7798e169010aSmrg fi 7799e169010aSmrg # The statement above tries to avoid entering an 7800e169010aSmrg # endless loop below, in case of cyclic links. 7801e169010aSmrg # We might still enter an endless loop, since a link 7802e169010aSmrg # loop can be closed while we follow links, 7803e169010aSmrg # but so what? 7804e169010aSmrg potlib="$potent_lib" 7805e169010aSmrg while test -h "$potlib" 2>/dev/null; do 7806e169010aSmrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 7807e169010aSmrg case $potliblink in 7808e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 7809e8ead290Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 7810e169010aSmrg esac 7811e169010aSmrg done 7812e169010aSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 7813e169010aSmrg $SED -e 10q | 7814e169010aSmrg $EGREP "$file_magic_regex" > /dev/null; then 7815c63293b5Smrg func_append newdeplibs " $a_deplib" 7816e169010aSmrg a_deplib="" 7817e169010aSmrg break 2 7818e169010aSmrg fi 7819e169010aSmrg done 7820e169010aSmrg done 7821e169010aSmrg fi 7822e169010aSmrg if test -n "$a_deplib" ; then 7823e169010aSmrg droppeddeps=yes 7824e8ead290Smrg echo 7825e169010aSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7826e8ead290Smrg echo "*** I have the capability to make that library automatically link in when" 7827e8ead290Smrg echo "*** you link to this library. But I can only do this if you have a" 7828e8ead290Smrg echo "*** shared version of the library, which you do not appear to have" 7829e8ead290Smrg echo "*** because I did check the linker path looking for a file starting" 7830e169010aSmrg if test -z "$potlib" ; then 7831e169010aSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 7832e169010aSmrg else 7833e169010aSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 7834e169010aSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 7835e169010aSmrg fi 7836e169010aSmrg fi 7837e169010aSmrg ;; 7838e169010aSmrg *) 7839e169010aSmrg # Add a -L argument. 7840c63293b5Smrg func_append newdeplibs " $a_deplib" 7841e169010aSmrg ;; 7842e169010aSmrg esac 7843e169010aSmrg done # Gone through all deplibs. 7844e169010aSmrg ;; 7845e169010aSmrg match_pattern*) 7846e169010aSmrg set dummy $deplibs_check_method; shift 7847e169010aSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7848e169010aSmrg for a_deplib in $deplibs; do 7849e169010aSmrg case $a_deplib in 7850e169010aSmrg -l*) 7851e169010aSmrg func_stripname -l '' "$a_deplib" 7852e169010aSmrg name=$func_stripname_result 7853e169010aSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7854e169010aSmrg case " $predeps $postdeps " in 7855e169010aSmrg *" $a_deplib "*) 7856c63293b5Smrg func_append newdeplibs " $a_deplib" 7857e169010aSmrg a_deplib="" 7858e169010aSmrg ;; 7859e169010aSmrg esac 7860e169010aSmrg fi 7861e169010aSmrg if test -n "$a_deplib" ; then 7862e169010aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 7863e169010aSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7864e169010aSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 7865e169010aSmrg for potent_lib in $potential_libs; do 7866e169010aSmrg potlib="$potent_lib" # see symlink-check above in file_magic test 7867e8ead290Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 7868e169010aSmrg $EGREP "$match_pattern_regex" > /dev/null; then 7869c63293b5Smrg func_append newdeplibs " $a_deplib" 7870e169010aSmrg a_deplib="" 7871e169010aSmrg break 2 7872e169010aSmrg fi 7873e169010aSmrg done 7874e169010aSmrg done 7875e169010aSmrg fi 7876e169010aSmrg if test -n "$a_deplib" ; then 7877e169010aSmrg droppeddeps=yes 7878e8ead290Smrg echo 7879e169010aSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7880e8ead290Smrg echo "*** I have the capability to make that library automatically link in when" 7881e8ead290Smrg echo "*** you link to this library. But I can only do this if you have a" 7882e8ead290Smrg echo "*** shared version of the library, which you do not appear to have" 7883e8ead290Smrg echo "*** because I did check the linker path looking for a file starting" 7884e169010aSmrg if test -z "$potlib" ; then 7885e169010aSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 7886e169010aSmrg else 7887e169010aSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 7888e169010aSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 7889e169010aSmrg fi 7890e169010aSmrg fi 7891e169010aSmrg ;; 7892e169010aSmrg *) 7893e169010aSmrg # Add a -L argument. 7894c63293b5Smrg func_append newdeplibs " $a_deplib" 7895e169010aSmrg ;; 7896e169010aSmrg esac 7897e169010aSmrg done # Gone through all deplibs. 7898e169010aSmrg ;; 7899e169010aSmrg none | unknown | *) 7900e169010aSmrg newdeplibs="" 7901e8ead290Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 7902e169010aSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7903e169010aSmrg for i in $predeps $postdeps ; do 7904e169010aSmrg # can't use Xsed below, because $i might contain '/' 7905e8ead290Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 7906e169010aSmrg done 7907e169010aSmrg fi 7908e8ead290Smrg case $tmp_deplibs in 7909e8ead290Smrg *[!\ \ ]*) 7910e8ead290Smrg echo 7911e169010aSmrg if test "X$deplibs_check_method" = "Xnone"; then 7912e8ead290Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 7913e169010aSmrg else 7914e8ead290Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 7915e169010aSmrg fi 7916e8ead290Smrg echo "*** All declared inter-library dependencies are being dropped." 7917e169010aSmrg droppeddeps=yes 7918e8ead290Smrg ;; 7919e8ead290Smrg esac 7920e169010aSmrg ;; 7921e169010aSmrg esac 7922e169010aSmrg versuffix=$versuffix_save 7923e169010aSmrg major=$major_save 7924e169010aSmrg release=$release_save 7925e169010aSmrg libname=$libname_save 7926e169010aSmrg name=$name_save 7927e169010aSmrg 7928e169010aSmrg case $host in 7929e169010aSmrg *-*-rhapsody* | *-*-darwin1.[012]) 7930e169010aSmrg # On Rhapsody replace the C library with the System framework 7931e8ead290Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 7932e169010aSmrg ;; 7933e169010aSmrg esac 7934e169010aSmrg 7935e169010aSmrg if test "$droppeddeps" = yes; then 7936e169010aSmrg if test "$module" = yes; then 7937e8ead290Smrg echo 7938e8ead290Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 7939e169010aSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 7940e8ead290Smrg echo "*** a static module, that should work as long as the dlopening" 7941e8ead290Smrg echo "*** application is linked with the -dlopen flag." 7942e169010aSmrg if test -z "$global_symbol_pipe"; then 7943e8ead290Smrg echo 7944e8ead290Smrg echo "*** However, this would only work if libtool was able to extract symbol" 7945e8ead290Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 7946e8ead290Smrg echo "*** not find such a program. So, this module is probably useless." 7947e8ead290Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 7948e169010aSmrg fi 7949e169010aSmrg if test "$build_old_libs" = no; then 7950e169010aSmrg oldlibs="$output_objdir/$libname.$libext" 7951e169010aSmrg build_libtool_libs=module 7952e169010aSmrg build_old_libs=yes 7953e169010aSmrg else 7954e169010aSmrg build_libtool_libs=no 7955e169010aSmrg fi 7956e169010aSmrg else 7957e8ead290Smrg echo "*** The inter-library dependencies that have been dropped here will be" 7958e8ead290Smrg echo "*** automatically added whenever a program is linked with this library" 7959e8ead290Smrg echo "*** or is declared to -dlopen it." 7960e169010aSmrg 7961e169010aSmrg if test "$allow_undefined" = no; then 7962e8ead290Smrg echo 7963e8ead290Smrg echo "*** Since this library must not contain undefined symbols," 7964e8ead290Smrg echo "*** because either the platform does not support them or" 7965e8ead290Smrg echo "*** it was explicitly requested with -no-undefined," 7966e8ead290Smrg echo "*** libtool will only create a static version of it." 7967e169010aSmrg if test "$build_old_libs" = no; then 7968e169010aSmrg oldlibs="$output_objdir/$libname.$libext" 7969e169010aSmrg build_libtool_libs=module 7970e169010aSmrg build_old_libs=yes 7971e169010aSmrg else 7972e169010aSmrg build_libtool_libs=no 7973e169010aSmrg fi 7974e169010aSmrg fi 7975e169010aSmrg fi 7976e169010aSmrg fi 7977e169010aSmrg # Done checking deplibs! 7978e169010aSmrg deplibs=$newdeplibs 7979e169010aSmrg fi 7980e169010aSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 7981e169010aSmrg case $host in 7982e169010aSmrg *-*-darwin*) 7983e8ead290Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7984e8ead290Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7985e8ead290Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7986e169010aSmrg ;; 7987e169010aSmrg esac 7988e169010aSmrg 7989e169010aSmrg # move library search paths that coincide with paths to not yet 7990e169010aSmrg # installed libraries to the beginning of the library search list 7991e169010aSmrg new_libs= 7992e169010aSmrg for path in $notinst_path; do 7993e169010aSmrg case " $new_libs " in 7994e169010aSmrg *" -L$path/$objdir "*) ;; 7995e169010aSmrg *) 7996e169010aSmrg case " $deplibs " in 7997e169010aSmrg *" -L$path/$objdir "*) 7998c63293b5Smrg func_append new_libs " -L$path/$objdir" ;; 7999e169010aSmrg esac 8000e169010aSmrg ;; 8001e169010aSmrg esac 8002e169010aSmrg done 8003e169010aSmrg for deplib in $deplibs; do 8004e169010aSmrg case $deplib in 8005e169010aSmrg -L*) 8006e169010aSmrg case " $new_libs " in 8007e169010aSmrg *" $deplib "*) ;; 8008c63293b5Smrg *) func_append new_libs " $deplib" ;; 8009e169010aSmrg esac 8010e169010aSmrg ;; 8011c63293b5Smrg *) func_append new_libs " $deplib" ;; 8012e169010aSmrg esac 8013e169010aSmrg done 8014e169010aSmrg deplibs="$new_libs" 8015e169010aSmrg 8016e169010aSmrg # All the library-specific variables (install_libdir is set above). 8017e169010aSmrg library_names= 8018e169010aSmrg old_library= 8019e169010aSmrg dlname= 8020e169010aSmrg 8021e169010aSmrg # Test again, we may have decided not to build it any more 8022e169010aSmrg if test "$build_libtool_libs" = yes; then 8023e169010aSmrg if test "$hardcode_into_libs" = yes; then 8024e169010aSmrg # Hardcode the library paths 8025e169010aSmrg hardcode_libdirs= 8026e169010aSmrg dep_rpath= 8027e169010aSmrg rpath="$finalize_rpath" 8028c63293b5Smrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 8029e169010aSmrg for libdir in $rpath; do 8030e169010aSmrg if test -n "$hardcode_libdir_flag_spec"; then 8031e169010aSmrg if test -n "$hardcode_libdir_separator"; then 8032c63293b5Smrg func_replace_sysroot "$libdir" 8033c63293b5Smrg libdir=$func_replace_sysroot_result 8034e169010aSmrg if test -z "$hardcode_libdirs"; then 8035e169010aSmrg hardcode_libdirs="$libdir" 8036e169010aSmrg else 8037e169010aSmrg # Just accumulate the unique libdirs. 8038e169010aSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8039e169010aSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8040e169010aSmrg ;; 8041e169010aSmrg *) 8042c63293b5Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8043e169010aSmrg ;; 8044e169010aSmrg esac 8045e169010aSmrg fi 8046e169010aSmrg else 8047e169010aSmrg eval flag=\"$hardcode_libdir_flag_spec\" 8048c63293b5Smrg func_append dep_rpath " $flag" 8049e169010aSmrg fi 8050e169010aSmrg elif test -n "$runpath_var"; then 8051e169010aSmrg case "$perm_rpath " in 8052e169010aSmrg *" $libdir "*) ;; 8053c63293b5Smrg *) func_apped perm_rpath " $libdir" ;; 8054e169010aSmrg esac 8055e169010aSmrg fi 8056e169010aSmrg done 8057e169010aSmrg # Substitute the hardcoded libdirs into the rpath. 8058e169010aSmrg if test -n "$hardcode_libdir_separator" && 8059e169010aSmrg test -n "$hardcode_libdirs"; then 8060e169010aSmrg libdir="$hardcode_libdirs" 8061e169010aSmrg if test -n "$hardcode_libdir_flag_spec_ld"; then 8062e169010aSmrg eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" 8063e169010aSmrg else 8064e169010aSmrg eval dep_rpath=\"$hardcode_libdir_flag_spec\" 8065e169010aSmrg fi 8066e169010aSmrg fi 8067e169010aSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 8068e169010aSmrg # We should set the runpath_var. 8069e169010aSmrg rpath= 8070e169010aSmrg for dir in $perm_rpath; do 8071c63293b5Smrg func_append rpath "$dir:" 8072e169010aSmrg done 8073e169010aSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 8074e169010aSmrg fi 8075e169010aSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 8076e169010aSmrg fi 80777914d74bSmrg 8078e169010aSmrg shlibpath="$finalize_shlibpath" 8079c63293b5Smrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 8080e169010aSmrg if test -n "$shlibpath"; then 8081e169010aSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 8082e169010aSmrg fi 80837914d74bSmrg 8084e169010aSmrg # Get the real and link names of the library. 8085e169010aSmrg eval shared_ext=\"$shrext_cmds\" 8086e169010aSmrg eval library_names=\"$library_names_spec\" 8087e169010aSmrg set dummy $library_names 8088e169010aSmrg shift 8089e169010aSmrg realname="$1" 8090e169010aSmrg shift 80917914d74bSmrg 8092e169010aSmrg if test -n "$soname_spec"; then 8093e169010aSmrg eval soname=\"$soname_spec\" 8094e169010aSmrg else 8095e169010aSmrg soname="$realname" 8096e169010aSmrg fi 8097e169010aSmrg if test -z "$dlname"; then 8098e169010aSmrg dlname=$soname 8099e169010aSmrg fi 81007914d74bSmrg 8101e169010aSmrg lib="$output_objdir/$realname" 8102e169010aSmrg linknames= 8103e169010aSmrg for link 8104e169010aSmrg do 8105c63293b5Smrg func_append linknames " $link" 8106e169010aSmrg done 81077914d74bSmrg 8108e169010aSmrg # Use standard objects if they are pic 8109e8ead290Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 8110e169010aSmrg test "X$libobjs" = "X " && libobjs= 81117914d74bSmrg 8112e169010aSmrg delfiles= 8113e169010aSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8114e169010aSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 8115e169010aSmrg export_symbols="$output_objdir/$libname.uexp" 8116c63293b5Smrg func_append delfiles " $export_symbols" 8117e169010aSmrg fi 81187914d74bSmrg 8119e169010aSmrg orig_export_symbols= 8120e169010aSmrg case $host_os in 8121e169010aSmrg cygwin* | mingw* | cegcc*) 8122e169010aSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 8123e169010aSmrg # exporting using user supplied symfile 8124e169010aSmrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 8125e169010aSmrg # and it's NOT already a .def file. Must figure out 8126e169010aSmrg # which of the given symbols are data symbols and tag 8127e169010aSmrg # them as such. So, trigger use of export_symbols_cmds. 8128e169010aSmrg # export_symbols gets reassigned inside the "prepare 8129e169010aSmrg # the list of exported symbols" if statement, so the 8130e169010aSmrg # include_expsyms logic still works. 8131e169010aSmrg orig_export_symbols="$export_symbols" 8132e169010aSmrg export_symbols= 8133e169010aSmrg always_export_symbols=yes 8134e169010aSmrg fi 8135e169010aSmrg fi 8136e169010aSmrg ;; 8137e169010aSmrg esac 81387914d74bSmrg 8139e169010aSmrg # Prepare the list of exported symbols 8140e169010aSmrg if test -z "$export_symbols"; then 8141e169010aSmrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 8142e169010aSmrg func_verbose "generating symbol list for \`$libname.la'" 8143e169010aSmrg export_symbols="$output_objdir/$libname.exp" 8144e169010aSmrg $opt_dry_run || $RM $export_symbols 8145e169010aSmrg cmds=$export_symbols_cmds 8146e169010aSmrg save_ifs="$IFS"; IFS='~' 8147c63293b5Smrg for cmd1 in $cmds; do 8148e169010aSmrg IFS="$save_ifs" 8149c63293b5Smrg # Take the normal branch if the nm_file_list_spec branch 8150c63293b5Smrg # doesn't work or if tool conversion is not needed. 8151c63293b5Smrg case $nm_file_list_spec~$to_tool_file_cmd in 8152c63293b5Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 8153c63293b5Smrg try_normal_branch=yes 8154c63293b5Smrg eval cmd=\"$cmd1\" 8155c63293b5Smrg func_len " $cmd" 8156c63293b5Smrg len=$func_len_result 8157c63293b5Smrg ;; 8158c63293b5Smrg *) 8159c63293b5Smrg try_normal_branch=no 8160c63293b5Smrg ;; 8161c63293b5Smrg esac 8162c63293b5Smrg if test "$try_normal_branch" = yes \ 8163c63293b5Smrg && { test "$len" -lt "$max_cmd_len" \ 8164c63293b5Smrg || test "$max_cmd_len" -le -1; } 8165c63293b5Smrg then 8166c63293b5Smrg func_show_eval "$cmd" 'exit $?' 8167c63293b5Smrg skipped_export=false 8168c63293b5Smrg elif test -n "$nm_file_list_spec"; then 8169c63293b5Smrg func_basename "$output" 8170c63293b5Smrg output_la=$func_basename_result 8171c63293b5Smrg save_libobjs=$libobjs 8172c63293b5Smrg save_output=$output 8173c63293b5Smrg output=${output_objdir}/${output_la}.nm 8174c63293b5Smrg func_to_tool_file "$output" 8175c63293b5Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 8176c63293b5Smrg func_append delfiles " $output" 8177c63293b5Smrg func_verbose "creating $NM input file list: $output" 8178c63293b5Smrg for obj in $save_libobjs; do 8179c63293b5Smrg func_to_tool_file "$obj" 8180c63293b5Smrg $ECHO "$func_to_tool_file_result" 8181c63293b5Smrg done > "$output" 8182c63293b5Smrg eval cmd=\"$cmd1\" 8183e169010aSmrg func_show_eval "$cmd" 'exit $?' 8184c63293b5Smrg output=$save_output 8185c63293b5Smrg libobjs=$save_libobjs 8186e169010aSmrg skipped_export=false 8187e169010aSmrg else 8188e169010aSmrg # The command line is too long to execute in one step. 8189e169010aSmrg func_verbose "using reloadable object file for export list..." 8190e169010aSmrg skipped_export=: 8191e169010aSmrg # Break out early, otherwise skipped_export may be 8192e169010aSmrg # set to false by a later but shorter cmd. 8193e169010aSmrg break 8194e169010aSmrg fi 8195e169010aSmrg done 8196e169010aSmrg IFS="$save_ifs" 8197e169010aSmrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 8198e169010aSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8199e169010aSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8200e169010aSmrg fi 8201e169010aSmrg fi 8202e169010aSmrg fi 82037914d74bSmrg 8204e169010aSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8205e169010aSmrg tmp_export_symbols="$export_symbols" 8206e169010aSmrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8207e8ead290Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8208e169010aSmrg fi 82097914d74bSmrg 8210e169010aSmrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 8211e169010aSmrg # The given exports_symbols file has to be filtered, so filter it. 8212e169010aSmrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8213e169010aSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 8214e169010aSmrg # 's' commands which not all seds can handle. GNU sed should be fine 8215e169010aSmrg # though. Also, the filter scales superlinearly with the number of 8216e169010aSmrg # global variables. join(1) would be nice here, but unfortunately 8217e169010aSmrg # isn't a blessed tool. 8218e169010aSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8219c63293b5Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8220e169010aSmrg export_symbols=$output_objdir/$libname.def 8221e169010aSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 82227914d74bSmrg fi 82237914d74bSmrg 8224e169010aSmrg tmp_deplibs= 8225e169010aSmrg for test_deplib in $deplibs; do 8226e169010aSmrg case " $convenience " in 8227e169010aSmrg *" $test_deplib "*) ;; 8228e169010aSmrg *) 8229c63293b5Smrg func_append tmp_deplibs " $test_deplib" 8230e169010aSmrg ;; 8231e169010aSmrg esac 8232e169010aSmrg done 8233e169010aSmrg deplibs="$tmp_deplibs" 82347914d74bSmrg 8235e169010aSmrg if test -n "$convenience"; then 8236e169010aSmrg if test -n "$whole_archive_flag_spec" && 8237e169010aSmrg test "$compiler_needs_object" = yes && 8238e169010aSmrg test -z "$libobjs"; then 8239e169010aSmrg # extract the archives, so we have objects to list. 8240e169010aSmrg # TODO: could optimize this to just extract one archive. 8241e169010aSmrg whole_archive_flag_spec= 8242e169010aSmrg fi 8243e169010aSmrg if test -n "$whole_archive_flag_spec"; then 8244e169010aSmrg save_libobjs=$libobjs 8245e169010aSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8246e169010aSmrg test "X$libobjs" = "X " && libobjs= 8247e169010aSmrg else 8248e169010aSmrg gentop="$output_objdir/${outputname}x" 8249c63293b5Smrg func_append generated " $gentop" 82507914d74bSmrg 8251e169010aSmrg func_extract_archives $gentop $convenience 8252c63293b5Smrg func_append libobjs " $func_extract_archives_result" 8253e169010aSmrg test "X$libobjs" = "X " && libobjs= 8254e169010aSmrg fi 8255e169010aSmrg fi 82567914d74bSmrg 8257e169010aSmrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 8258e169010aSmrg eval flag=\"$thread_safe_flag_spec\" 8259c63293b5Smrg func_append linker_flags " $flag" 8260e169010aSmrg fi 82617914d74bSmrg 8262e169010aSmrg # Make a backup of the uninstalled library when relinking 8263c63293b5Smrg if test "$opt_mode" = relink; then 8264e169010aSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 82657914d74bSmrg fi 82667914d74bSmrg 8267e169010aSmrg # Do each of the archive commands. 8268e169010aSmrg if test "$module" = yes && test -n "$module_cmds" ; then 8269e169010aSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8270e169010aSmrg eval test_cmds=\"$module_expsym_cmds\" 8271e169010aSmrg cmds=$module_expsym_cmds 8272e169010aSmrg else 8273e169010aSmrg eval test_cmds=\"$module_cmds\" 8274e169010aSmrg cmds=$module_cmds 8275e169010aSmrg fi 8276e169010aSmrg else 8277e169010aSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8278e169010aSmrg eval test_cmds=\"$archive_expsym_cmds\" 8279e169010aSmrg cmds=$archive_expsym_cmds 8280e169010aSmrg else 8281e169010aSmrg eval test_cmds=\"$archive_cmds\" 8282e169010aSmrg cmds=$archive_cmds 8283e169010aSmrg fi 82847914d74bSmrg fi 82857914d74bSmrg 8286e169010aSmrg if test "X$skipped_export" != "X:" && 8287e169010aSmrg func_len " $test_cmds" && 8288e169010aSmrg len=$func_len_result && 8289e169010aSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 8290e169010aSmrg : 8291e169010aSmrg else 8292e169010aSmrg # The command line is too long to link in one step, link piecewise 8293e169010aSmrg # or, if using GNU ld and skipped_export is not :, use a linker 8294e169010aSmrg # script. 82957914d74bSmrg 8296e169010aSmrg # Save the value of $output and $libobjs because we want to 8297e169010aSmrg # use them later. If we have whole_archive_flag_spec, we 8298e169010aSmrg # want to use save_libobjs as it was before 8299e169010aSmrg # whole_archive_flag_spec was expanded, because we can't 8300e169010aSmrg # assume the linker understands whole_archive_flag_spec. 8301e169010aSmrg # This may have to be revisited, in case too many 8302e169010aSmrg # convenience libraries get linked in and end up exceeding 8303e169010aSmrg # the spec. 8304e169010aSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 8305e169010aSmrg save_libobjs=$libobjs 8306e169010aSmrg fi 8307e169010aSmrg save_output=$output 8308e8ead290Smrg func_basename "$output" 8309e8ead290Smrg output_la=$func_basename_result 83107914d74bSmrg 8311e169010aSmrg # Clear the reloadable object creation command queue and 8312e169010aSmrg # initialize k to one. 8313e169010aSmrg test_cmds= 8314e169010aSmrg concat_cmds= 8315e169010aSmrg objlist= 8316e169010aSmrg last_robj= 8317e169010aSmrg k=1 83187914d74bSmrg 8319e169010aSmrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 8320e169010aSmrg output=${output_objdir}/${output_la}.lnkscript 8321e169010aSmrg func_verbose "creating GNU ld script: $output" 8322e8ead290Smrg echo 'INPUT (' > $output 8323e169010aSmrg for obj in $save_libobjs 8324e169010aSmrg do 8325c63293b5Smrg func_to_tool_file "$obj" 8326c63293b5Smrg $ECHO "$func_to_tool_file_result" >> $output 8327e169010aSmrg done 8328e8ead290Smrg echo ')' >> $output 8329c63293b5Smrg func_append delfiles " $output" 8330c63293b5Smrg func_to_tool_file "$output" 8331c63293b5Smrg output=$func_to_tool_file_result 8332e169010aSmrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 8333e169010aSmrg output=${output_objdir}/${output_la}.lnk 8334e169010aSmrg func_verbose "creating linker input file list: $output" 8335e169010aSmrg : > $output 8336e169010aSmrg set x $save_libobjs 8337e169010aSmrg shift 8338e169010aSmrg firstobj= 8339e169010aSmrg if test "$compiler_needs_object" = yes; then 8340e169010aSmrg firstobj="$1 " 8341e169010aSmrg shift 8342e169010aSmrg fi 8343e169010aSmrg for obj 8344e169010aSmrg do 8345c63293b5Smrg func_to_tool_file "$obj" 8346c63293b5Smrg $ECHO "$func_to_tool_file_result" >> $output 8347e169010aSmrg done 8348c63293b5Smrg func_append delfiles " $output" 8349c63293b5Smrg func_to_tool_file "$output" 8350c63293b5Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 8351e169010aSmrg else 8352e169010aSmrg if test -n "$save_libobjs"; then 8353e169010aSmrg func_verbose "creating reloadable object files..." 8354e169010aSmrg output=$output_objdir/$output_la-${k}.$objext 8355e169010aSmrg eval test_cmds=\"$reload_cmds\" 8356e169010aSmrg func_len " $test_cmds" 8357e169010aSmrg len0=$func_len_result 8358e169010aSmrg len=$len0 8359e169010aSmrg 8360e169010aSmrg # Loop over the list of objects to be linked. 8361e169010aSmrg for obj in $save_libobjs 8362e169010aSmrg do 8363e169010aSmrg func_len " $obj" 8364e169010aSmrg func_arith $len + $func_len_result 8365e169010aSmrg len=$func_arith_result 8366e169010aSmrg if test "X$objlist" = X || 8367e169010aSmrg test "$len" -lt "$max_cmd_len"; then 8368e169010aSmrg func_append objlist " $obj" 8369e169010aSmrg else 8370e169010aSmrg # The command $test_cmds is almost too long, add a 8371e169010aSmrg # command to the queue. 8372e169010aSmrg if test "$k" -eq 1 ; then 8373e169010aSmrg # The first file doesn't have a previous command to add. 8374e8ead290Smrg reload_objs=$objlist 8375e8ead290Smrg eval concat_cmds=\"$reload_cmds\" 8376e169010aSmrg else 8377e169010aSmrg # All subsequent reloadable object files will link in 8378e169010aSmrg # the last one created. 8379e8ead290Smrg reload_objs="$objlist $last_robj" 8380e8ead290Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 8381e169010aSmrg fi 8382e169010aSmrg last_robj=$output_objdir/$output_la-${k}.$objext 8383e169010aSmrg func_arith $k + 1 8384e169010aSmrg k=$func_arith_result 8385e169010aSmrg output=$output_objdir/$output_la-${k}.$objext 8386e8ead290Smrg objlist=" $obj" 8387e169010aSmrg func_len " $last_robj" 8388e169010aSmrg func_arith $len0 + $func_len_result 8389e169010aSmrg len=$func_arith_result 8390e169010aSmrg fi 8391e169010aSmrg done 8392e169010aSmrg # Handle the remaining objects by creating one last 8393e169010aSmrg # reloadable object file. All subsequent reloadable object 8394e169010aSmrg # files will link in the last one created. 8395e169010aSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8396e8ead290Smrg reload_objs="$objlist $last_robj" 8397e8ead290Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 8398e169010aSmrg if test -n "$last_robj"; then 8399e169010aSmrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 8400e169010aSmrg fi 8401c63293b5Smrg func_append delfiles " $output" 84027914d74bSmrg 8403e169010aSmrg else 8404e169010aSmrg output= 8405e169010aSmrg fi 84067914d74bSmrg 8407e169010aSmrg if ${skipped_export-false}; then 8408e169010aSmrg func_verbose "generating symbol list for \`$libname.la'" 8409e169010aSmrg export_symbols="$output_objdir/$libname.exp" 8410e169010aSmrg $opt_dry_run || $RM $export_symbols 8411e169010aSmrg libobjs=$output 8412e169010aSmrg # Append the command to create the export file. 8413e169010aSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8414e169010aSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 8415e169010aSmrg if test -n "$last_robj"; then 8416e169010aSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 8417e169010aSmrg fi 8418e169010aSmrg fi 84197914d74bSmrg 8420e169010aSmrg test -n "$save_libobjs" && 8421e169010aSmrg func_verbose "creating a temporary reloadable object file: $output" 84227914d74bSmrg 8423e169010aSmrg # Loop through the commands generated above and execute them. 8424e169010aSmrg save_ifs="$IFS"; IFS='~' 8425e169010aSmrg for cmd in $concat_cmds; do 8426e169010aSmrg IFS="$save_ifs" 8427e169010aSmrg $opt_silent || { 8428e169010aSmrg func_quote_for_expand "$cmd" 8429e169010aSmrg eval "func_echo $func_quote_for_expand_result" 8430e169010aSmrg } 8431e169010aSmrg $opt_dry_run || eval "$cmd" || { 8432e169010aSmrg lt_exit=$? 8433e169010aSmrg 8434e169010aSmrg # Restore the uninstalled library and exit 8435c63293b5Smrg if test "$opt_mode" = relink; then 8436e169010aSmrg ( cd "$output_objdir" && \ 8437e169010aSmrg $RM "${realname}T" && \ 8438e169010aSmrg $MV "${realname}U" "$realname" ) 8439e169010aSmrg fi 84407914d74bSmrg 8441e169010aSmrg exit $lt_exit 8442e169010aSmrg } 8443e169010aSmrg done 8444e169010aSmrg IFS="$save_ifs" 8445e169010aSmrg 8446e169010aSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 8447e169010aSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8448e169010aSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 84497914d74bSmrg fi 84507914d74bSmrg fi 84517914d74bSmrg 8452e169010aSmrg if ${skipped_export-false}; then 8453e169010aSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8454e169010aSmrg tmp_export_symbols="$export_symbols" 8455e169010aSmrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8456e8ead290Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8457e169010aSmrg fi 84587914d74bSmrg 8459e169010aSmrg if test -n "$orig_export_symbols"; then 8460e169010aSmrg # The given exports_symbols file has to be filtered, so filter it. 8461e169010aSmrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8462e169010aSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 8463e169010aSmrg # 's' commands which not all seds can handle. GNU sed should be fine 8464e169010aSmrg # though. Also, the filter scales superlinearly with the number of 8465e169010aSmrg # global variables. join(1) would be nice here, but unfortunately 8466e169010aSmrg # isn't a blessed tool. 8467e169010aSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8468c63293b5Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8469e169010aSmrg export_symbols=$output_objdir/$libname.def 8470e169010aSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8471e169010aSmrg fi 8472e169010aSmrg fi 84737914d74bSmrg 8474e169010aSmrg libobjs=$output 8475e169010aSmrg # Restore the value of output. 8476e169010aSmrg output=$save_output 84777914d74bSmrg 8478e169010aSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 8479e169010aSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8480e169010aSmrg test "X$libobjs" = "X " && libobjs= 8481e169010aSmrg fi 8482e169010aSmrg # Expand the library linking commands again to reset the 8483e169010aSmrg # value of $libobjs for piecewise linking. 8484e169010aSmrg 8485e169010aSmrg # Do each of the archive commands. 8486e169010aSmrg if test "$module" = yes && test -n "$module_cmds" ; then 8487e169010aSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8488e169010aSmrg cmds=$module_expsym_cmds 84897914d74bSmrg else 8490e169010aSmrg cmds=$module_cmds 84917914d74bSmrg fi 84927914d74bSmrg else 8493e169010aSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8494e169010aSmrg cmds=$archive_expsym_cmds 8495e169010aSmrg else 8496e169010aSmrg cmds=$archive_cmds 8497e169010aSmrg fi 84987914d74bSmrg fi 84997914d74bSmrg fi 85007914d74bSmrg 8501e169010aSmrg if test -n "$delfiles"; then 8502e169010aSmrg # Append the command to remove temporary files to $cmds. 8503e169010aSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 8504e169010aSmrg fi 85057914d74bSmrg 8506e169010aSmrg # Add any objects from preloaded convenience libraries 8507e169010aSmrg if test -n "$dlprefiles"; then 8508e169010aSmrg gentop="$output_objdir/${outputname}x" 8509c63293b5Smrg func_append generated " $gentop" 85107914d74bSmrg 8511e169010aSmrg func_extract_archives $gentop $dlprefiles 8512c63293b5Smrg func_append libobjs " $func_extract_archives_result" 8513e169010aSmrg test "X$libobjs" = "X " && libobjs= 85147914d74bSmrg fi 85157914d74bSmrg 8516e169010aSmrg save_ifs="$IFS"; IFS='~' 8517e169010aSmrg for cmd in $cmds; do 8518e169010aSmrg IFS="$save_ifs" 8519e169010aSmrg eval cmd=\"$cmd\" 8520e169010aSmrg $opt_silent || { 8521e169010aSmrg func_quote_for_expand "$cmd" 8522e169010aSmrg eval "func_echo $func_quote_for_expand_result" 8523e169010aSmrg } 8524e169010aSmrg $opt_dry_run || eval "$cmd" || { 8525e169010aSmrg lt_exit=$? 85267914d74bSmrg 8527e169010aSmrg # Restore the uninstalled library and exit 8528c63293b5Smrg if test "$opt_mode" = relink; then 8529e169010aSmrg ( cd "$output_objdir" && \ 8530e169010aSmrg $RM "${realname}T" && \ 8531e169010aSmrg $MV "${realname}U" "$realname" ) 8532e169010aSmrg fi 8533e169010aSmrg 8534e169010aSmrg exit $lt_exit 8535e169010aSmrg } 8536e169010aSmrg done 8537e169010aSmrg IFS="$save_ifs" 8538e169010aSmrg 8539e169010aSmrg # Restore the uninstalled library and exit 8540c63293b5Smrg if test "$opt_mode" = relink; then 8541e169010aSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 8542e169010aSmrg 8543e169010aSmrg if test -n "$convenience"; then 8544e169010aSmrg if test -z "$whole_archive_flag_spec"; then 8545e169010aSmrg func_show_eval '${RM}r "$gentop"' 85467914d74bSmrg fi 85477914d74bSmrg fi 85487914d74bSmrg 8549e169010aSmrg exit $EXIT_SUCCESS 8550e169010aSmrg fi 85517914d74bSmrg 8552e169010aSmrg # Create links to the real library. 8553e169010aSmrg for linkname in $linknames; do 8554e169010aSmrg if test "$realname" != "$linkname"; then 8555e169010aSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 8556e169010aSmrg fi 8557e169010aSmrg done 8558e169010aSmrg 8559e169010aSmrg # If -module or -export-dynamic was specified, set the dlname. 8560e169010aSmrg if test "$module" = yes || test "$export_dynamic" = yes; then 8561e169010aSmrg # On all known operating systems, these are identical. 8562e169010aSmrg dlname="$soname" 8563e169010aSmrg fi 8564e169010aSmrg fi 8565e169010aSmrg ;; 8566e169010aSmrg 8567e169010aSmrg obj) 8568e169010aSmrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 8569e169010aSmrg func_warning "\`-dlopen' is ignored for objects" 8570e169010aSmrg fi 8571e169010aSmrg 8572e169010aSmrg case " $deplibs" in 8573e169010aSmrg *\ -l* | *\ -L*) 8574e169010aSmrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 8575e169010aSmrg esac 8576e169010aSmrg 8577e169010aSmrg test -n "$rpath" && \ 8578e169010aSmrg func_warning "\`-rpath' is ignored for objects" 8579e169010aSmrg 8580e169010aSmrg test -n "$xrpath" && \ 8581e169010aSmrg func_warning "\`-R' is ignored for objects" 8582e169010aSmrg 8583e169010aSmrg test -n "$vinfo" && \ 8584e169010aSmrg func_warning "\`-version-info' is ignored for objects" 8585e169010aSmrg 8586e169010aSmrg test -n "$release" && \ 8587e169010aSmrg func_warning "\`-release' is ignored for objects" 8588e169010aSmrg 8589e169010aSmrg case $output in 8590e169010aSmrg *.lo) 8591e169010aSmrg test -n "$objs$old_deplibs" && \ 8592e169010aSmrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 8593e169010aSmrg 8594e169010aSmrg libobj=$output 8595e169010aSmrg func_lo2o "$libobj" 8596e169010aSmrg obj=$func_lo2o_result 8597e169010aSmrg ;; 8598e169010aSmrg *) 8599e169010aSmrg libobj= 8600e169010aSmrg obj="$output" 8601e169010aSmrg ;; 8602e169010aSmrg esac 8603e169010aSmrg 8604e169010aSmrg # Delete the old objects. 8605e169010aSmrg $opt_dry_run || $RM $obj $libobj 8606e169010aSmrg 8607e169010aSmrg # Objects from convenience libraries. This assumes 8608e169010aSmrg # single-version convenience libraries. Whenever we create 8609e169010aSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 8610e169010aSmrg # the extraction. 8611e169010aSmrg reload_conv_objs= 8612e169010aSmrg gentop= 8613e169010aSmrg # reload_cmds runs $LD directly, so let us get rid of 8614e169010aSmrg # -Wl from whole_archive_flag_spec and hope we can get by with 8615e169010aSmrg # turning comma into space.. 8616e169010aSmrg wl= 8617e169010aSmrg 8618e169010aSmrg if test -n "$convenience"; then 8619e169010aSmrg if test -n "$whole_archive_flag_spec"; then 8620e169010aSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 8621e8ead290Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 8622e169010aSmrg else 8623e169010aSmrg gentop="$output_objdir/${obj}x" 8624c63293b5Smrg func_append generated " $gentop" 8625e169010aSmrg 8626e169010aSmrg func_extract_archives $gentop $convenience 8627e169010aSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 8628e169010aSmrg fi 8629e169010aSmrg fi 86307914d74bSmrg 8631c63293b5Smrg # If we're not building shared, we need to use non_pic_objs 8632c63293b5Smrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 8633c63293b5Smrg 8634e169010aSmrg # Create the old-style object. 8635e8ead290Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 86367914d74bSmrg 8637e169010aSmrg output="$obj" 8638e169010aSmrg func_execute_cmds "$reload_cmds" 'exit $?' 86397914d74bSmrg 8640e169010aSmrg # Exit if we aren't doing a library object file. 8641e169010aSmrg if test -z "$libobj"; then 8642e169010aSmrg if test -n "$gentop"; then 8643e169010aSmrg func_show_eval '${RM}r "$gentop"' 8644e169010aSmrg fi 86457914d74bSmrg 8646e169010aSmrg exit $EXIT_SUCCESS 8647e169010aSmrg fi 86487914d74bSmrg 8649e169010aSmrg if test "$build_libtool_libs" != yes; then 8650e169010aSmrg if test -n "$gentop"; then 8651e169010aSmrg func_show_eval '${RM}r "$gentop"' 8652e169010aSmrg fi 86537914d74bSmrg 8654e169010aSmrg # Create an invalid libtool object if no PIC, so that we don't 8655e169010aSmrg # accidentally link it into a program. 8656e169010aSmrg # $show "echo timestamp > $libobj" 8657e169010aSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 8658e169010aSmrg exit $EXIT_SUCCESS 8659e169010aSmrg fi 86607914d74bSmrg 8661e169010aSmrg if test -n "$pic_flag" || test "$pic_mode" != default; then 8662e169010aSmrg # Only do commands if we really have different PIC objects. 8663e169010aSmrg reload_objs="$libobjs $reload_conv_objs" 8664e169010aSmrg output="$libobj" 8665e169010aSmrg func_execute_cmds "$reload_cmds" 'exit $?' 86667914d74bSmrg fi 86677914d74bSmrg 8668e169010aSmrg if test -n "$gentop"; then 8669e169010aSmrg func_show_eval '${RM}r "$gentop"' 8670e169010aSmrg fi 86717914d74bSmrg 8672e169010aSmrg exit $EXIT_SUCCESS 8673e169010aSmrg ;; 86747914d74bSmrg 8675e169010aSmrg prog) 8676e169010aSmrg case $host in 8677e169010aSmrg *cygwin*) func_stripname '' '.exe' "$output" 8678e169010aSmrg output=$func_stripname_result.exe;; 86797914d74bSmrg esac 8680e169010aSmrg test -n "$vinfo" && \ 8681e169010aSmrg func_warning "\`-version-info' is ignored for programs" 86827914d74bSmrg 8683e169010aSmrg test -n "$release" && \ 8684e169010aSmrg func_warning "\`-release' is ignored for programs" 86857914d74bSmrg 8686e169010aSmrg test "$preload" = yes \ 8687e169010aSmrg && test "$dlopen_support" = unknown \ 8688e169010aSmrg && test "$dlopen_self" = unknown \ 8689e169010aSmrg && test "$dlopen_self_static" = unknown && \ 8690e169010aSmrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 86917914d74bSmrg 8692e169010aSmrg case $host in 8693e169010aSmrg *-*-rhapsody* | *-*-darwin1.[012]) 8694e169010aSmrg # On Rhapsody replace the C library is the System framework 8695e8ead290Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 8696e8ead290Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 86977914d74bSmrg ;; 86987914d74bSmrg esac 86997914d74bSmrg 8700e169010aSmrg case $host in 8701e169010aSmrg *-*-darwin*) 8702e169010aSmrg # Don't allow lazy linking, it breaks C++ global constructors 8703e169010aSmrg # But is supposedly fixed on 10.4 or later (yay!). 8704e169010aSmrg if test "$tagname" = CXX ; then 8705e169010aSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 8706e169010aSmrg 10.[0123]) 8707c63293b5Smrg func_append compile_command " ${wl}-bind_at_load" 8708c63293b5Smrg func_append finalize_command " ${wl}-bind_at_load" 8709e169010aSmrg ;; 8710e169010aSmrg esac 8711e169010aSmrg fi 8712e169010aSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 8713e8ead290Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8714e8ead290Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 87157914d74bSmrg ;; 87167914d74bSmrg esac 87177914d74bSmrg 87187914d74bSmrg 8719e169010aSmrg # move library search paths that coincide with paths to not yet 8720e169010aSmrg # installed libraries to the beginning of the library search list 8721e169010aSmrg new_libs= 8722e169010aSmrg for path in $notinst_path; do 8723e169010aSmrg case " $new_libs " in 8724e169010aSmrg *" -L$path/$objdir "*) ;; 87257914d74bSmrg *) 8726e169010aSmrg case " $compile_deplibs " in 8727e169010aSmrg *" -L$path/$objdir "*) 8728c63293b5Smrg func_append new_libs " -L$path/$objdir" ;; 8729e169010aSmrg esac 87307914d74bSmrg ;; 87317914d74bSmrg esac 87327914d74bSmrg done 8733e169010aSmrg for deplib in $compile_deplibs; do 8734e169010aSmrg case $deplib in 8735e169010aSmrg -L*) 8736e169010aSmrg case " $new_libs " in 8737e169010aSmrg *" $deplib "*) ;; 8738c63293b5Smrg *) func_append new_libs " $deplib" ;; 8739e169010aSmrg esac 8740e169010aSmrg ;; 8741c63293b5Smrg *) func_append new_libs " $deplib" ;; 8742e169010aSmrg esac 8743e169010aSmrg done 8744e169010aSmrg compile_deplibs="$new_libs" 87457914d74bSmrg 87467914d74bSmrg 8747c63293b5Smrg func_append compile_command " $compile_deplibs" 8748c63293b5Smrg func_append finalize_command " $finalize_deplibs" 87497914d74bSmrg 8750e169010aSmrg if test -n "$rpath$xrpath"; then 8751e169010aSmrg # If the user specified any rpath flags, then add them. 8752e169010aSmrg for libdir in $rpath $xrpath; do 8753e169010aSmrg # This is the magic to use -rpath. 8754e169010aSmrg case "$finalize_rpath " in 8755e169010aSmrg *" $libdir "*) ;; 8756c63293b5Smrg *) func_append finalize_rpath " $libdir" ;; 8757e169010aSmrg esac 8758e169010aSmrg done 8759e169010aSmrg fi 87607914d74bSmrg 8761e169010aSmrg # Now hardcode the library paths 8762e169010aSmrg rpath= 8763e169010aSmrg hardcode_libdirs= 8764e169010aSmrg for libdir in $compile_rpath $finalize_rpath; do 8765e169010aSmrg if test -n "$hardcode_libdir_flag_spec"; then 8766e169010aSmrg if test -n "$hardcode_libdir_separator"; then 8767e169010aSmrg if test -z "$hardcode_libdirs"; then 8768e169010aSmrg hardcode_libdirs="$libdir" 8769e169010aSmrg else 8770e169010aSmrg # Just accumulate the unique libdirs. 8771e169010aSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8772e169010aSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8773e169010aSmrg ;; 8774e169010aSmrg *) 8775c63293b5Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8776e169010aSmrg ;; 8777e169010aSmrg esac 8778e169010aSmrg fi 8779e169010aSmrg else 8780e169010aSmrg eval flag=\"$hardcode_libdir_flag_spec\" 8781c63293b5Smrg func_append rpath " $flag" 8782e169010aSmrg fi 8783e169010aSmrg elif test -n "$runpath_var"; then 8784e169010aSmrg case "$perm_rpath " in 87857914d74bSmrg *" $libdir "*) ;; 8786c63293b5Smrg *) func_append perm_rpath " $libdir" ;; 87877914d74bSmrg esac 8788e169010aSmrg fi 8789e169010aSmrg case $host in 8790e169010aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 8791e169010aSmrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 8792e169010aSmrg case :$dllsearchpath: in 8793e169010aSmrg *":$libdir:"*) ;; 8794e169010aSmrg ::) dllsearchpath=$libdir;; 8795c63293b5Smrg *) func_append dllsearchpath ":$libdir";; 8796e169010aSmrg esac 8797e169010aSmrg case :$dllsearchpath: in 8798e169010aSmrg *":$testbindir:"*) ;; 8799e169010aSmrg ::) dllsearchpath=$testbindir;; 8800c63293b5Smrg *) func_append dllsearchpath ":$testbindir";; 8801e169010aSmrg esac 8802e169010aSmrg ;; 8803e169010aSmrg esac 8804e169010aSmrg done 8805e169010aSmrg # Substitute the hardcoded libdirs into the rpath. 8806e169010aSmrg if test -n "$hardcode_libdir_separator" && 8807e169010aSmrg test -n "$hardcode_libdirs"; then 8808e169010aSmrg libdir="$hardcode_libdirs" 8809e169010aSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 8810e169010aSmrg fi 8811e169010aSmrg compile_rpath="$rpath" 8812e169010aSmrg 8813e169010aSmrg rpath= 8814e169010aSmrg hardcode_libdirs= 8815e169010aSmrg for libdir in $finalize_rpath; do 8816e169010aSmrg if test -n "$hardcode_libdir_flag_spec"; then 8817e169010aSmrg if test -n "$hardcode_libdir_separator"; then 8818e169010aSmrg if test -z "$hardcode_libdirs"; then 8819e169010aSmrg hardcode_libdirs="$libdir" 8820e169010aSmrg else 8821e169010aSmrg # Just accumulate the unique libdirs. 8822e169010aSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8823e169010aSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8824e169010aSmrg ;; 8825e169010aSmrg *) 8826c63293b5Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8827e169010aSmrg ;; 8828e169010aSmrg esac 8829e169010aSmrg fi 8830e169010aSmrg else 8831e169010aSmrg eval flag=\"$hardcode_libdir_flag_spec\" 8832c63293b5Smrg func_append rpath " $flag" 8833e169010aSmrg fi 8834e169010aSmrg elif test -n "$runpath_var"; then 8835e169010aSmrg case "$finalize_perm_rpath " in 88367914d74bSmrg *" $libdir "*) ;; 8837c63293b5Smrg *) func_append finalize_perm_rpath " $libdir" ;; 88387914d74bSmrg esac 88397914d74bSmrg fi 8840e169010aSmrg done 8841e169010aSmrg # Substitute the hardcoded libdirs into the rpath. 8842e169010aSmrg if test -n "$hardcode_libdir_separator" && 8843e169010aSmrg test -n "$hardcode_libdirs"; then 8844e169010aSmrg libdir="$hardcode_libdirs" 8845e169010aSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 8846e169010aSmrg fi 8847e169010aSmrg finalize_rpath="$rpath" 88487914d74bSmrg 8849e169010aSmrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 8850e169010aSmrg # Transform all the library objects into standard objects. 8851e8ead290Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8852e8ead290Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8853e169010aSmrg fi 88547914d74bSmrg 8855e169010aSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 88567914d74bSmrg 8857e169010aSmrg # template prelinking step 8858e169010aSmrg if test -n "$prelink_cmds"; then 8859e169010aSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 8860e169010aSmrg fi 88617914d74bSmrg 8862e169010aSmrg wrappers_required=yes 8863e169010aSmrg case $host in 8864e8ead290Smrg *cegcc* | *mingw32ce*) 8865e8ead290Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 8866e8ead290Smrg wrappers_required=no 8867e8ead290Smrg ;; 8868e169010aSmrg *cygwin* | *mingw* ) 8869e169010aSmrg if test "$build_libtool_libs" != yes; then 8870e169010aSmrg wrappers_required=no 8871e169010aSmrg fi 8872e169010aSmrg ;; 8873e169010aSmrg *) 8874e169010aSmrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 8875e169010aSmrg wrappers_required=no 8876e169010aSmrg fi 8877e169010aSmrg ;; 8878e169010aSmrg esac 8879e169010aSmrg if test "$wrappers_required" = no; then 8880e169010aSmrg # Replace the output file specification. 8881e8ead290Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8882e169010aSmrg link_command="$compile_command$compile_rpath" 88837914d74bSmrg 8884e169010aSmrg # We have no uninstalled library dependencies, so finalize right now. 8885e169010aSmrg exit_status=0 8886e169010aSmrg func_show_eval "$link_command" 'exit_status=$?' 88877914d74bSmrg 8888c63293b5Smrg if test -n "$postlink_cmds"; then 8889c63293b5Smrg func_to_tool_file "$output" 8890c63293b5Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8891c63293b5Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 8892c63293b5Smrg fi 8893c63293b5Smrg 8894e169010aSmrg # Delete the generated files. 8895e169010aSmrg if test -f "$output_objdir/${outputname}S.${objext}"; then 8896e169010aSmrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 8897e169010aSmrg fi 88987914d74bSmrg 8899e169010aSmrg exit $exit_status 8900e169010aSmrg fi 89017914d74bSmrg 8902e169010aSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 8903e169010aSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 8904e169010aSmrg fi 8905e169010aSmrg if test -n "$finalize_shlibpath"; then 8906e169010aSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 8907e169010aSmrg fi 89087914d74bSmrg 8909e169010aSmrg compile_var= 8910e169010aSmrg finalize_var= 8911e169010aSmrg if test -n "$runpath_var"; then 8912e169010aSmrg if test -n "$perm_rpath"; then 8913e169010aSmrg # We should set the runpath_var. 8914e169010aSmrg rpath= 8915e169010aSmrg for dir in $perm_rpath; do 8916c63293b5Smrg func_append rpath "$dir:" 89177914d74bSmrg done 8918e169010aSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 89197914d74bSmrg fi 8920e169010aSmrg if test -n "$finalize_perm_rpath"; then 8921e169010aSmrg # We should set the runpath_var. 8922e169010aSmrg rpath= 8923e169010aSmrg for dir in $finalize_perm_rpath; do 8924c63293b5Smrg func_append rpath "$dir:" 8925e169010aSmrg done 8926e169010aSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 8927e169010aSmrg fi 8928e169010aSmrg fi 89297914d74bSmrg 8930e169010aSmrg if test "$no_install" = yes; then 8931e169010aSmrg # We don't need to create a wrapper script. 8932e169010aSmrg link_command="$compile_var$compile_command$compile_rpath" 8933e169010aSmrg # Replace the output file specification. 8934e8ead290Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8935e169010aSmrg # Delete the old output file. 8936e169010aSmrg $opt_dry_run || $RM $output 8937e169010aSmrg # Link the executable and exit 8938e169010aSmrg func_show_eval "$link_command" 'exit $?' 8939c63293b5Smrg 8940c63293b5Smrg if test -n "$postlink_cmds"; then 8941c63293b5Smrg func_to_tool_file "$output" 8942c63293b5Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8943c63293b5Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 8944c63293b5Smrg fi 8945c63293b5Smrg 8946e169010aSmrg exit $EXIT_SUCCESS 8947e169010aSmrg fi 89487914d74bSmrg 8949e169010aSmrg if test "$hardcode_action" = relink; then 8950e169010aSmrg # Fast installation is not supported 8951e169010aSmrg link_command="$compile_var$compile_command$compile_rpath" 8952e169010aSmrg relink_command="$finalize_var$finalize_command$finalize_rpath" 89537914d74bSmrg 8954e169010aSmrg func_warning "this platform does not like uninstalled shared libraries" 8955e169010aSmrg func_warning "\`$output' will be relinked during installation" 8956e169010aSmrg else 8957e169010aSmrg if test "$fast_install" != no; then 8958e169010aSmrg link_command="$finalize_var$compile_command$finalize_rpath" 8959e169010aSmrg if test "$fast_install" = yes; then 8960e8ead290Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 8961e169010aSmrg else 8962e169010aSmrg # fast_install is set to needless 8963e169010aSmrg relink_command= 8964e169010aSmrg fi 89657914d74bSmrg else 8966e169010aSmrg link_command="$compile_var$compile_command$compile_rpath" 8967e169010aSmrg relink_command="$finalize_var$finalize_command$finalize_rpath" 89687914d74bSmrg fi 8969e169010aSmrg fi 89707914d74bSmrg 8971e169010aSmrg # Replace the output file specification. 8972e8ead290Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 89737914d74bSmrg 8974e169010aSmrg # Delete the old output files. 8975e169010aSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 89767914d74bSmrg 8977e169010aSmrg func_show_eval "$link_command" 'exit $?' 89787914d74bSmrg 8979c63293b5Smrg if test -n "$postlink_cmds"; then 8980c63293b5Smrg func_to_tool_file "$output_objdir/$outputname" 8981c63293b5Smrg 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'` 8982c63293b5Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 8983c63293b5Smrg fi 8984c63293b5Smrg 8985e169010aSmrg # Now create the wrapper script. 8986e169010aSmrg func_verbose "creating $output" 89877914d74bSmrg 8988e169010aSmrg # Quote the relink command for shipping. 8989e169010aSmrg if test -n "$relink_command"; then 8990e169010aSmrg # Preserve any variables that may affect compiler behavior 8991e169010aSmrg for var in $variables_saved_for_relink; do 8992e169010aSmrg if eval test -z \"\${$var+set}\"; then 8993e169010aSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 8994e169010aSmrg elif eval var_value=\$$var; test -z "$var_value"; then 8995e169010aSmrg relink_command="$var=; export $var; $relink_command" 8996e169010aSmrg else 8997e169010aSmrg func_quote_for_eval "$var_value" 8998e169010aSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 8999e169010aSmrg fi 9000e169010aSmrg done 9001e169010aSmrg relink_command="(cd `pwd`; $relink_command)" 9002e8ead290Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9003e169010aSmrg fi 90047914d74bSmrg 9005e169010aSmrg # Only actually do things if not in dry run mode. 9006e169010aSmrg $opt_dry_run || { 9007e169010aSmrg # win32 will think the script is a binary if it has 9008e169010aSmrg # a .exe suffix, so we strip it off here. 9009e169010aSmrg case $output in 9010e169010aSmrg *.exe) func_stripname '' '.exe' "$output" 9011e169010aSmrg output=$func_stripname_result ;; 9012e169010aSmrg esac 9013e169010aSmrg # test for cygwin because mv fails w/o .exe extensions 90147914d74bSmrg case $host in 9015e169010aSmrg *cygwin*) 9016e169010aSmrg exeext=.exe 9017e169010aSmrg func_stripname '' '.exe' "$outputname" 9018e169010aSmrg outputname=$func_stripname_result ;; 9019e169010aSmrg *) exeext= ;; 90207914d74bSmrg esac 9021e169010aSmrg case $host in 9022e169010aSmrg *cygwin* | *mingw* ) 9023e169010aSmrg func_dirname_and_basename "$output" "" "." 9024e169010aSmrg output_name=$func_basename_result 9025e169010aSmrg output_path=$func_dirname_result 9026e169010aSmrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 9027e169010aSmrg cwrapper="$output_path/$output_name.exe" 9028e169010aSmrg $RM $cwrappersource $cwrapper 9029e169010aSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 9030e169010aSmrg 9031e169010aSmrg func_emit_cwrapperexe_src > $cwrappersource 9032e169010aSmrg 9033e169010aSmrg # The wrapper executable is built using the $host compiler, 9034e169010aSmrg # because it contains $host paths and files. If cross- 9035e169010aSmrg # compiling, it, like the target executable, must be 9036e169010aSmrg # executed on the $host or under an emulation environment. 9037e169010aSmrg $opt_dry_run || { 9038e169010aSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 9039e169010aSmrg $STRIP $cwrapper 9040e169010aSmrg } 90417914d74bSmrg 9042e169010aSmrg # Now, create the wrapper script for func_source use: 9043e169010aSmrg func_ltwrapper_scriptname $cwrapper 9044e169010aSmrg $RM $func_ltwrapper_scriptname_result 9045e169010aSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 9046e169010aSmrg $opt_dry_run || { 9047e169010aSmrg # note: this script will not be executed, so do not chmod. 9048e169010aSmrg if test "x$build" = "x$host" ; then 9049e169010aSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 90507914d74bSmrg else 9051e169010aSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 90527914d74bSmrg fi 9053e169010aSmrg } 9054e169010aSmrg ;; 9055e169010aSmrg * ) 9056e169010aSmrg $RM $output 9057e169010aSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 90587914d74bSmrg 9059e169010aSmrg func_emit_wrapper no > $output 9060e169010aSmrg chmod +x $output 90617914d74bSmrg ;; 90627914d74bSmrg esac 9063e169010aSmrg } 9064e169010aSmrg exit $EXIT_SUCCESS 9065e169010aSmrg ;; 9066e169010aSmrg esac 90677914d74bSmrg 9068e169010aSmrg # See if we need to build an old-fashioned archive. 9069e169010aSmrg for oldlib in $oldlibs; do 90707914d74bSmrg 9071e169010aSmrg if test "$build_libtool_libs" = convenience; then 9072e169010aSmrg oldobjs="$libobjs_save $symfileobj" 9073e169010aSmrg addlibs="$convenience" 9074e169010aSmrg build_libtool_libs=no 9075e169010aSmrg else 9076e169010aSmrg if test "$build_libtool_libs" = module; then 9077e169010aSmrg oldobjs="$libobjs_save" 9078e169010aSmrg build_libtool_libs=no 9079e169010aSmrg else 9080e169010aSmrg oldobjs="$old_deplibs $non_pic_objects" 9081e169010aSmrg if test "$preload" = yes && test -f "$symfileobj"; then 9082c63293b5Smrg func_append oldobjs " $symfileobj" 9083e169010aSmrg fi 9084e169010aSmrg fi 9085e169010aSmrg addlibs="$old_convenience" 90867914d74bSmrg fi 90877914d74bSmrg 9088e169010aSmrg if test -n "$addlibs"; then 9089e169010aSmrg gentop="$output_objdir/${outputname}x" 9090c63293b5Smrg func_append generated " $gentop" 90917914d74bSmrg 9092e169010aSmrg func_extract_archives $gentop $addlibs 9093c63293b5Smrg func_append oldobjs " $func_extract_archives_result" 9094e169010aSmrg fi 90957914d74bSmrg 9096e169010aSmrg # Do each command in the archive commands. 9097e169010aSmrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 9098e169010aSmrg cmds=$old_archive_from_new_cmds 9099e169010aSmrg else 91007914d74bSmrg 9101e169010aSmrg # Add any objects from preloaded convenience libraries 9102e169010aSmrg if test -n "$dlprefiles"; then 9103e169010aSmrg gentop="$output_objdir/${outputname}x" 9104c63293b5Smrg func_append generated " $gentop" 91057914d74bSmrg 9106e169010aSmrg func_extract_archives $gentop $dlprefiles 9107c63293b5Smrg func_append oldobjs " $func_extract_archives_result" 9108e169010aSmrg fi 91097914d74bSmrg 9110e169010aSmrg # POSIX demands no paths to be encoded in archives. We have 9111e169010aSmrg # to avoid creating archives with duplicate basenames if we 9112e169010aSmrg # might have to extract them afterwards, e.g., when creating a 9113e169010aSmrg # static archive out of a convenience library, or when linking 9114e169010aSmrg # the entirety of a libtool archive into another (currently 9115e169010aSmrg # not supported by libtool). 9116e169010aSmrg if (for obj in $oldobjs 9117e169010aSmrg do 9118e169010aSmrg func_basename "$obj" 9119e169010aSmrg $ECHO "$func_basename_result" 9120e169010aSmrg done | sort | sort -uc >/dev/null 2>&1); then 9121e169010aSmrg : 9122e169010aSmrg else 9123e8ead290Smrg echo "copying selected object files to avoid basename conflicts..." 9124e169010aSmrg gentop="$output_objdir/${outputname}x" 9125c63293b5Smrg func_append generated " $gentop" 9126e169010aSmrg func_mkdir_p "$gentop" 9127e169010aSmrg save_oldobjs=$oldobjs 9128e169010aSmrg oldobjs= 9129e169010aSmrg counter=1 9130e169010aSmrg for obj in $save_oldobjs 9131e169010aSmrg do 9132e169010aSmrg func_basename "$obj" 9133e169010aSmrg objbase="$func_basename_result" 9134e169010aSmrg case " $oldobjs " in 9135e169010aSmrg " ") oldobjs=$obj ;; 9136e169010aSmrg *[\ /]"$objbase "*) 9137e169010aSmrg while :; do 9138e169010aSmrg # Make sure we don't pick an alternate name that also 9139e169010aSmrg # overlaps. 9140e169010aSmrg newobj=lt$counter-$objbase 9141e169010aSmrg func_arith $counter + 1 9142e169010aSmrg counter=$func_arith_result 9143e169010aSmrg case " $oldobjs " in 9144e169010aSmrg *[\ /]"$newobj "*) ;; 9145e169010aSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 9146e169010aSmrg esac 9147e169010aSmrg done 9148e169010aSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 9149c63293b5Smrg func_append oldobjs " $gentop/$newobj" 9150e169010aSmrg ;; 9151c63293b5Smrg *) func_append oldobjs " $obj" ;; 9152e169010aSmrg esac 91537914d74bSmrg done 91547914d74bSmrg fi 9155e169010aSmrg eval cmds=\"$old_archive_cmds\" 91567914d74bSmrg 9157e169010aSmrg func_len " $cmds" 9158e169010aSmrg len=$func_len_result 9159e169010aSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9160e169010aSmrg cmds=$old_archive_cmds 9161c63293b5Smrg elif test -n "$archiver_list_spec"; then 9162c63293b5Smrg func_verbose "using command file archive linking..." 9163c63293b5Smrg for obj in $oldobjs 9164c63293b5Smrg do 9165c63293b5Smrg func_to_tool_file "$obj" 9166c63293b5Smrg $ECHO "$func_to_tool_file_result" 9167c63293b5Smrg done > $output_objdir/$libname.libcmd 9168c63293b5Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 9169c63293b5Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 9170c63293b5Smrg cmds=$old_archive_cmds 9171e169010aSmrg else 9172e169010aSmrg # the command line is too long to link in one step, link in parts 9173e169010aSmrg func_verbose "using piecewise archive linking..." 9174e169010aSmrg save_RANLIB=$RANLIB 9175e169010aSmrg RANLIB=: 9176e169010aSmrg objlist= 9177e169010aSmrg concat_cmds= 9178e169010aSmrg save_oldobjs=$oldobjs 9179e169010aSmrg oldobjs= 9180e169010aSmrg # Is there a better way of finding the last object in the list? 9181e169010aSmrg for obj in $save_oldobjs 9182e169010aSmrg do 9183e169010aSmrg last_oldobj=$obj 9184e169010aSmrg done 9185e169010aSmrg eval test_cmds=\"$old_archive_cmds\" 9186e169010aSmrg func_len " $test_cmds" 9187e169010aSmrg len0=$func_len_result 9188e169010aSmrg len=$len0 9189e169010aSmrg for obj in $save_oldobjs 9190e169010aSmrg do 9191e169010aSmrg func_len " $obj" 9192e169010aSmrg func_arith $len + $func_len_result 9193e169010aSmrg len=$func_arith_result 9194e169010aSmrg func_append objlist " $obj" 9195e169010aSmrg if test "$len" -lt "$max_cmd_len"; then 9196e169010aSmrg : 9197e169010aSmrg else 9198e169010aSmrg # the above command should be used before it gets too long 9199e169010aSmrg oldobjs=$objlist 9200e169010aSmrg if test "$obj" = "$last_oldobj" ; then 9201e169010aSmrg RANLIB=$save_RANLIB 9202e169010aSmrg fi 9203e169010aSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9204e169010aSmrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 9205e169010aSmrg objlist= 9206e169010aSmrg len=$len0 9207e169010aSmrg fi 9208e169010aSmrg done 9209e169010aSmrg RANLIB=$save_RANLIB 9210e169010aSmrg oldobjs=$objlist 9211e169010aSmrg if test "X$oldobjs" = "X" ; then 9212e169010aSmrg eval cmds=\"\$concat_cmds\" 9213e169010aSmrg else 9214e169010aSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 9215e169010aSmrg fi 9216e169010aSmrg fi 9217e169010aSmrg fi 9218e169010aSmrg func_execute_cmds "$cmds" 'exit $?' 92197914d74bSmrg done 92207914d74bSmrg 9221e169010aSmrg test -n "$generated" && \ 9222e169010aSmrg func_show_eval "${RM}r$generated" 92237914d74bSmrg 9224e169010aSmrg # Now create the libtool archive. 9225e169010aSmrg case $output in 9226e169010aSmrg *.la) 9227e169010aSmrg old_library= 9228e169010aSmrg test "$build_old_libs" = yes && old_library="$libname.$libext" 9229e169010aSmrg func_verbose "creating $output" 92307914d74bSmrg 9231e169010aSmrg # Preserve any variables that may affect compiler behavior 9232e169010aSmrg for var in $variables_saved_for_relink; do 9233e169010aSmrg if eval test -z \"\${$var+set}\"; then 9234e169010aSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9235e169010aSmrg elif eval var_value=\$$var; test -z "$var_value"; then 9236e169010aSmrg relink_command="$var=; export $var; $relink_command" 92377914d74bSmrg else 9238e169010aSmrg func_quote_for_eval "$var_value" 9239e169010aSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 92407914d74bSmrg fi 9241e169010aSmrg done 9242e169010aSmrg # Quote the link command for shipping. 9243e169010aSmrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 9244e8ead290Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9245e169010aSmrg if test "$hardcode_automatic" = yes ; then 9246e169010aSmrg relink_command= 9247e169010aSmrg fi 92487914d74bSmrg 9249e169010aSmrg # Only create the output if not a dry run. 9250e169010aSmrg $opt_dry_run || { 9251e169010aSmrg for installed in no yes; do 9252e169010aSmrg if test "$installed" = yes; then 9253e169010aSmrg if test -z "$install_libdir"; then 9254e169010aSmrg break 9255e169010aSmrg fi 9256e169010aSmrg output="$output_objdir/$outputname"i 9257e169010aSmrg # Replace all uninstalled libtool libraries with the installed ones 9258e169010aSmrg newdependency_libs= 9259e169010aSmrg for deplib in $dependency_libs; do 9260e169010aSmrg case $deplib in 9261e169010aSmrg *.la) 9262e169010aSmrg func_basename "$deplib" 9263e169010aSmrg name="$func_basename_result" 9264e169010aSmrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 9265e169010aSmrg test -z "$libdir" && \ 9266e169010aSmrg func_fatal_error "\`$deplib' is not a valid libtool archive" 9267c63293b5Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 9268c63293b5Smrg ;; 9269c63293b5Smrg -L*) 9270c63293b5Smrg func_stripname -L '' "$deplib" 9271c63293b5Smrg func_replace_sysroot "$func_stripname_result" 9272c63293b5Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 9273c63293b5Smrg ;; 9274c63293b5Smrg -R*) 9275c63293b5Smrg func_stripname -R '' "$deplib" 9276c63293b5Smrg func_replace_sysroot "$func_stripname_result" 9277c63293b5Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 9278e169010aSmrg ;; 9279c63293b5Smrg *) func_append newdependency_libs " $deplib" ;; 9280e169010aSmrg esac 9281e169010aSmrg done 9282e169010aSmrg dependency_libs="$newdependency_libs" 9283e169010aSmrg newdlfiles= 9284e169010aSmrg 9285e169010aSmrg for lib in $dlfiles; do 9286e169010aSmrg case $lib in 9287e169010aSmrg *.la) 9288e169010aSmrg func_basename "$lib" 9289e169010aSmrg name="$func_basename_result" 9290e169010aSmrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9291e169010aSmrg test -z "$libdir" && \ 9292e169010aSmrg func_fatal_error "\`$lib' is not a valid libtool archive" 9293c63293b5Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 9294e169010aSmrg ;; 9295c63293b5Smrg *) func_append newdlfiles " $lib" ;; 9296e169010aSmrg esac 9297e169010aSmrg done 9298e169010aSmrg dlfiles="$newdlfiles" 9299e169010aSmrg newdlprefiles= 9300e169010aSmrg for lib in $dlprefiles; do 9301e169010aSmrg case $lib in 9302e169010aSmrg *.la) 9303e169010aSmrg # Only pass preopened files to the pseudo-archive (for 9304e169010aSmrg # eventual linking with the app. that links it) if we 9305e169010aSmrg # didn't already link the preopened objects directly into 9306e169010aSmrg # the library: 9307e169010aSmrg func_basename "$lib" 9308e169010aSmrg name="$func_basename_result" 9309e169010aSmrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9310e169010aSmrg test -z "$libdir" && \ 9311e169010aSmrg func_fatal_error "\`$lib' is not a valid libtool archive" 9312c63293b5Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 9313e169010aSmrg ;; 9314e169010aSmrg esac 9315e169010aSmrg done 9316e169010aSmrg dlprefiles="$newdlprefiles" 9317e169010aSmrg else 9318e169010aSmrg newdlfiles= 9319e169010aSmrg for lib in $dlfiles; do 9320e169010aSmrg case $lib in 9321e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9322e169010aSmrg *) abs=`pwd`"/$lib" ;; 9323e169010aSmrg esac 9324c63293b5Smrg func_append newdlfiles " $abs" 9325e169010aSmrg done 9326e169010aSmrg dlfiles="$newdlfiles" 9327e169010aSmrg newdlprefiles= 9328e169010aSmrg for lib in $dlprefiles; do 9329e169010aSmrg case $lib in 9330e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9331e169010aSmrg *) abs=`pwd`"/$lib" ;; 9332e169010aSmrg esac 9333c63293b5Smrg func_append newdlprefiles " $abs" 9334e169010aSmrg done 9335e169010aSmrg dlprefiles="$newdlprefiles" 9336e169010aSmrg fi 9337e169010aSmrg $RM $output 9338e169010aSmrg # place dlname in correct position for cygwin 9339e8ead290Smrg # In fact, it would be nice if we could use this code for all target 9340e8ead290Smrg # systems that can't hard-code library paths into their executables 9341e8ead290Smrg # and that have no shared library path variable independent of PATH, 9342e8ead290Smrg # but it turns out we can't easily determine that from inspecting 9343e8ead290Smrg # libtool variables, so we have to hard-code the OSs to which it 9344e8ead290Smrg # applies here; at the moment, that means platforms that use the PE 9345e8ead290Smrg # object format with DLL files. See the long comment at the top of 9346e8ead290Smrg # tests/bindir.at for full details. 9347e169010aSmrg tdlname=$dlname 9348e169010aSmrg case $host,$output,$installed,$module,$dlname in 9349e8ead290Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 9350e8ead290Smrg # If a -bindir argument was supplied, place the dll there. 9351e8ead290Smrg if test "x$bindir" != x ; 9352e8ead290Smrg then 9353e8ead290Smrg func_relative_path "$install_libdir" "$bindir" 9354e8ead290Smrg tdlname=$func_relative_path_result$dlname 9355e8ead290Smrg else 9356e8ead290Smrg # Otherwise fall back on heuristic. 9357e8ead290Smrg tdlname=../bin/$dlname 9358e8ead290Smrg fi 9359e8ead290Smrg ;; 9360e169010aSmrg esac 9361e169010aSmrg $ECHO > $output "\ 9362e169010aSmrg# $outputname - a libtool library file 9363e169010aSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 9364e169010aSmrg# 9365e169010aSmrg# Please DO NOT delete this file! 9366e169010aSmrg# It is necessary for linking the library. 93677914d74bSmrg 9368e169010aSmrg# The name that we can dlopen(3). 9369e169010aSmrgdlname='$tdlname' 93707914d74bSmrg 9371e169010aSmrg# Names of this library. 9372e169010aSmrglibrary_names='$library_names' 93737914d74bSmrg 9374e169010aSmrg# The name of the static archive. 9375e169010aSmrgold_library='$old_library' 93767914d74bSmrg 9377e169010aSmrg# Linker flags that can not go in dependency_libs. 9378e169010aSmrginherited_linker_flags='$new_inherited_linker_flags' 93797914d74bSmrg 9380e169010aSmrg# Libraries that this one depends upon. 9381e169010aSmrgdependency_libs='$dependency_libs' 93827914d74bSmrg 9383e169010aSmrg# Names of additional weak libraries provided by this library 9384e169010aSmrgweak_library_names='$weak_libs' 93857914d74bSmrg 9386e169010aSmrg# Version information for $libname. 9387e169010aSmrgcurrent=$current 9388e169010aSmrgage=$age 9389e169010aSmrgrevision=$revision 93907914d74bSmrg 9391e169010aSmrg# Is this an already installed library? 9392e169010aSmrginstalled=$installed 93937914d74bSmrg 9394e169010aSmrg# Should we warn about portability when linking against -modules? 9395e169010aSmrgshouldnotlink=$module 93967914d74bSmrg 9397e169010aSmrg# Files to dlopen/dlpreopen 9398e169010aSmrgdlopen='$dlfiles' 9399e169010aSmrgdlpreopen='$dlprefiles' 94007914d74bSmrg 9401e169010aSmrg# Directory that this library needs to be installed in: 9402e169010aSmrglibdir='$install_libdir'" 9403e169010aSmrg if test "$installed" = no && test "$need_relink" = yes; then 9404e169010aSmrg $ECHO >> $output "\ 9405e169010aSmrgrelink_command=\"$relink_command\"" 9406e169010aSmrg fi 9407e169010aSmrg done 9408e169010aSmrg } 94097914d74bSmrg 9410e169010aSmrg # Do a symbolic link so that the libtool archive can be found in 9411e169010aSmrg # LD_LIBRARY_PATH before the program is installed. 9412e169010aSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 9413e169010aSmrg ;; 9414e169010aSmrg esac 9415e169010aSmrg exit $EXIT_SUCCESS 9416e169010aSmrg} 94177914d74bSmrg 9418c63293b5Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 9419e169010aSmrg func_mode_link ${1+"$@"} 94207914d74bSmrg 94217914d74bSmrg 9422e169010aSmrg# func_mode_uninstall arg... 9423e169010aSmrgfunc_mode_uninstall () 9424e169010aSmrg{ 9425e169010aSmrg $opt_debug 9426e169010aSmrg RM="$nonopt" 94277914d74bSmrg files= 94287914d74bSmrg rmforce= 94297914d74bSmrg exit_status=0 94307914d74bSmrg 94317914d74bSmrg # This variable tells wrapper scripts just to set variables rather 94327914d74bSmrg # than running their programs. 94337914d74bSmrg libtool_install_magic="$magic" 94347914d74bSmrg 94357914d74bSmrg for arg 94367914d74bSmrg do 94377914d74bSmrg case $arg in 9438c63293b5Smrg -f) func_append RM " $arg"; rmforce=yes ;; 9439c63293b5Smrg -*) func_append RM " $arg" ;; 9440c63293b5Smrg *) func_append files " $arg" ;; 94417914d74bSmrg esac 94427914d74bSmrg done 94437914d74bSmrg 9444e169010aSmrg test -z "$RM" && \ 9445e169010aSmrg func_fatal_help "you must specify an RM program" 94467914d74bSmrg 94477914d74bSmrg rmdirs= 94487914d74bSmrg 94497914d74bSmrg for file in $files; do 9450e169010aSmrg func_dirname "$file" "" "." 9451e169010aSmrg dir="$func_dirname_result" 9452e169010aSmrg if test "X$dir" = X.; then 9453c63293b5Smrg odir="$objdir" 94547914d74bSmrg else 9455c63293b5Smrg odir="$dir/$objdir" 94567914d74bSmrg fi 9457e169010aSmrg func_basename "$file" 9458e169010aSmrg name="$func_basename_result" 9459c63293b5Smrg test "$opt_mode" = uninstall && odir="$dir" 94607914d74bSmrg 9461c63293b5Smrg # Remember odir for removal later, being careful to avoid duplicates 9462c63293b5Smrg if test "$opt_mode" = clean; then 94637914d74bSmrg case " $rmdirs " in 9464c63293b5Smrg *" $odir "*) ;; 9465c63293b5Smrg *) func_append rmdirs " $odir" ;; 94667914d74bSmrg esac 94677914d74bSmrg fi 94687914d74bSmrg 94697914d74bSmrg # Don't error if the file doesn't exist and rm -f was used. 9470e169010aSmrg if { test -L "$file"; } >/dev/null 2>&1 || 9471e169010aSmrg { test -h "$file"; } >/dev/null 2>&1 || 9472e169010aSmrg test -f "$file"; then 94737914d74bSmrg : 94747914d74bSmrg elif test -d "$file"; then 94757914d74bSmrg exit_status=1 94767914d74bSmrg continue 94777914d74bSmrg elif test "$rmforce" = yes; then 94787914d74bSmrg continue 94797914d74bSmrg fi 94807914d74bSmrg 94817914d74bSmrg rmfiles="$file" 94827914d74bSmrg 94837914d74bSmrg case $name in 94847914d74bSmrg *.la) 94857914d74bSmrg # Possibly a libtool archive, so verify it. 9486e169010aSmrg if func_lalib_p "$file"; then 9487e169010aSmrg func_source $dir/$name 94887914d74bSmrg 94897914d74bSmrg # Delete the libtool libraries and symlinks. 94907914d74bSmrg for n in $library_names; do 9491c63293b5Smrg func_append rmfiles " $odir/$n" 94927914d74bSmrg done 9493c63293b5Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 94947914d74bSmrg 9495c63293b5Smrg case "$opt_mode" in 94967914d74bSmrg clean) 9497c63293b5Smrg case " $library_names " in 94987914d74bSmrg *" $dlname "*) ;; 9499c63293b5Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 95007914d74bSmrg esac 9501c63293b5Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 95027914d74bSmrg ;; 95037914d74bSmrg uninstall) 95047914d74bSmrg if test -n "$library_names"; then 95057914d74bSmrg # Do each command in the postuninstall commands. 9506e169010aSmrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 95077914d74bSmrg fi 95087914d74bSmrg 95097914d74bSmrg if test -n "$old_library"; then 95107914d74bSmrg # Do each command in the old_postuninstall commands. 9511e169010aSmrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 95127914d74bSmrg fi 95137914d74bSmrg # FIXME: should reinstall the best remaining shared library. 95147914d74bSmrg ;; 95157914d74bSmrg esac 95167914d74bSmrg fi 95177914d74bSmrg ;; 95187914d74bSmrg 95197914d74bSmrg *.lo) 95207914d74bSmrg # Possibly a libtool object, so verify it. 9521e169010aSmrg if func_lalib_p "$file"; then 95227914d74bSmrg 95237914d74bSmrg # Read the .lo file 9524e169010aSmrg func_source $dir/$name 95257914d74bSmrg 95267914d74bSmrg # Add PIC object to the list of files to remove. 9527e169010aSmrg if test -n "$pic_object" && 9528e169010aSmrg test "$pic_object" != none; then 9529c63293b5Smrg func_append rmfiles " $dir/$pic_object" 95307914d74bSmrg fi 95317914d74bSmrg 95327914d74bSmrg # Add non-PIC object to the list of files to remove. 9533e169010aSmrg if test -n "$non_pic_object" && 9534e169010aSmrg test "$non_pic_object" != none; then 9535c63293b5Smrg func_append rmfiles " $dir/$non_pic_object" 95367914d74bSmrg fi 95377914d74bSmrg fi 95387914d74bSmrg ;; 95397914d74bSmrg 95407914d74bSmrg *) 9541c63293b5Smrg if test "$opt_mode" = clean ; then 95427914d74bSmrg noexename=$name 95437914d74bSmrg case $file in 95447914d74bSmrg *.exe) 9545e169010aSmrg func_stripname '' '.exe' "$file" 9546e169010aSmrg file=$func_stripname_result 9547e169010aSmrg func_stripname '' '.exe' "$name" 9548e169010aSmrg noexename=$func_stripname_result 95497914d74bSmrg # $file with .exe has already been added to rmfiles, 95507914d74bSmrg # add $file without .exe 9551c63293b5Smrg func_append rmfiles " $file" 95527914d74bSmrg ;; 95537914d74bSmrg esac 95547914d74bSmrg # Do a test to see if this is a libtool program. 9555e169010aSmrg if func_ltwrapper_p "$file"; then 9556e169010aSmrg if func_ltwrapper_executable_p "$file"; then 9557e169010aSmrg func_ltwrapper_scriptname "$file" 9558e169010aSmrg relink_command= 9559e169010aSmrg func_source $func_ltwrapper_scriptname_result 9560c63293b5Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 9561e169010aSmrg else 9562e169010aSmrg relink_command= 9563e169010aSmrg func_source $dir/$noexename 9564e169010aSmrg fi 95657914d74bSmrg 95667914d74bSmrg # note $name still contains .exe if it was in $file originally 95677914d74bSmrg # as does the version of $file that was added into $rmfiles 9568c63293b5Smrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 95697914d74bSmrg if test "$fast_install" = yes && test -n "$relink_command"; then 9570c63293b5Smrg func_append rmfiles " $odir/lt-$name" 95717914d74bSmrg fi 95727914d74bSmrg if test "X$noexename" != "X$name" ; then 9573c63293b5Smrg func_append rmfiles " $odir/lt-${noexename}.c" 95747914d74bSmrg fi 95757914d74bSmrg fi 95767914d74bSmrg fi 95777914d74bSmrg ;; 95787914d74bSmrg esac 9579e169010aSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 95807914d74bSmrg done 95817914d74bSmrg 95827914d74bSmrg # Try to remove the ${objdir}s in the directories where we deleted files 95837914d74bSmrg for dir in $rmdirs; do 95847914d74bSmrg if test -d "$dir"; then 9585e169010aSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 95867914d74bSmrg fi 95877914d74bSmrg done 95887914d74bSmrg 95897914d74bSmrg exit $exit_status 9590e169010aSmrg} 95917914d74bSmrg 9592c63293b5Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 9593e169010aSmrg func_mode_uninstall ${1+"$@"} 95947914d74bSmrg 9595c63293b5Smrgtest -z "$opt_mode" && { 9596e169010aSmrg help="$generic_help" 9597e169010aSmrg func_fatal_help "you must specify a MODE" 9598e169010aSmrg} 9599e169010aSmrg 9600e169010aSmrgtest -z "$exec_cmd" && \ 9601c63293b5Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 96027914d74bSmrg 96037914d74bSmrgif test -n "$exec_cmd"; then 9604e169010aSmrg eval exec "$exec_cmd" 96057914d74bSmrg exit $EXIT_FAILURE 96067914d74bSmrgfi 96077914d74bSmrg 9608e169010aSmrgexit $exit_status 96097914d74bSmrg 96107914d74bSmrg 96117914d74bSmrg# The TAGs below are defined such that we never get into a situation 96127914d74bSmrg# in which we disable both kinds of libraries. Given conflicting 96137914d74bSmrg# choices, we go for a static library, that is the most portable, 96147914d74bSmrg# since we can't tell whether shared libraries were disabled because 96157914d74bSmrg# the user asked for that or because the platform doesn't support 96167914d74bSmrg# them. This is particularly important on AIX, because we don't 96177914d74bSmrg# support having both static and shared libraries enabled at the same 96187914d74bSmrg# time on that platform, so we default to a shared-only configuration. 96197914d74bSmrg# If a disable-shared tag is given, we'll fallback to a static-only 96207914d74bSmrg# configuration. But we'll never go from static-only to shared-only. 96217914d74bSmrg 96227914d74bSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 9623e169010aSmrgbuild_libtool_libs=no 9624e169010aSmrgbuild_old_libs=yes 96257914d74bSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 96267914d74bSmrg 96277914d74bSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 9628e169010aSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 96297914d74bSmrg# ### END LIBTOOL TAG CONFIG: disable-static 96307914d74bSmrg 96317914d74bSmrg# Local Variables: 96327914d74bSmrg# mode:shell-script 96337914d74bSmrg# sh-indentation:2 96347914d74bSmrg# End: 9635e169010aSmrg# vi:sw=2 9636e169010aSmrg 9637