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