ltmain.sh revision 880c7e28
10b661123Smrg 2880c7e28Smrg# libtool (GNU libtool) 2.4.2 30b661123Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 40b661123Smrg 5880c7e28Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 6880c7e28Smrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 70b661123Smrg# This is free software; see the source for copying conditions. There is NO 80b661123Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 90b661123Smrg 100b661123Smrg# GNU Libtool is free software; you can redistribute it and/or modify 11bdcaa8d0Smrg# it under the terms of the GNU General Public License as published by 12bdcaa8d0Smrg# the Free Software Foundation; either version 2 of the License, or 13bdcaa8d0Smrg# (at your option) any later version. 14bdcaa8d0Smrg# 150b661123Smrg# As a special exception to the GNU General Public License, 160b661123Smrg# if you distribute this file as part of a program or library that 170b661123Smrg# is built using GNU Libtool, you may include this file under the 180b661123Smrg# same distribution terms that you use for the rest of that program. 190b661123Smrg# 200b661123Smrg# GNU Libtool is distributed in the hope that it will be useful, but 21bdcaa8d0Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 22bdcaa8d0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23bdcaa8d0Smrg# General Public License for more details. 24bdcaa8d0Smrg# 25bdcaa8d0Smrg# You should have received a copy of the GNU General Public License 260b661123Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 270b661123Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 280b661123Smrg# or obtained by writing to the Free Software Foundation, Inc., 290b661123Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 3096ce994aSmrg 310b661123Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 320b661123Smrg# 330b661123Smrg# Provide generalized library-building support services. 340b661123Smrg# 35880c7e28Smrg# --config show all configuration variables 36880c7e28Smrg# --debug enable verbose shell tracing 37880c7e28Smrg# -n, --dry-run display commands without modifying any files 38880c7e28Smrg# --features display basic configuration information and exit 39880c7e28Smrg# --mode=MODE use operation mode MODE 40880c7e28Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 41880c7e28Smrg# --quiet, --silent don't print informational messages 42880c7e28Smrg# --no-quiet, --no-silent 43880c7e28Smrg# print informational messages (default) 44880c7e28Smrg# --no-warn don't display warning messages 45880c7e28Smrg# --tag=TAG use configuration variables from tag TAG 46880c7e28Smrg# -v, --verbose print more informational messages than default 47880c7e28Smrg# --no-verbose don't print the extra informational messages 48880c7e28Smrg# --version print version information 49880c7e28Smrg# -h, --help, --help-all print short, long, or detailed help message 500b661123Smrg# 510b661123Smrg# MODE must be one of the following: 520b661123Smrg# 53880c7e28Smrg# clean remove files from the build directory 54880c7e28Smrg# compile compile a source file into a libtool object 55880c7e28Smrg# execute automatically set library path, then run a program 56880c7e28Smrg# finish complete the installation of libtool libraries 57880c7e28Smrg# install install libraries or executables 58880c7e28Smrg# link create a library or an executable 59880c7e28Smrg# uninstall remove libraries from an installed directory 600b661123Smrg# 61880c7e28Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 62880c7e28Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 630b661123Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 640b661123Smrg# 650b661123Smrg# When reporting a bug, please describe a test case to reproduce it and 660b661123Smrg# include the following information: 670b661123Smrg# 68880c7e28Smrg# host-triplet: $host 69880c7e28Smrg# shell: $SHELL 70880c7e28Smrg# compiler: $LTCC 71880c7e28Smrg# compiler flags: $LTCFLAGS 72880c7e28Smrg# linker: $LD (gnu? $with_gnu_ld) 73880c7e28Smrg# $progname: (GNU libtool) 2.4.2 74880c7e28Smrg# automake: $automake_version 75880c7e28Smrg# autoconf: $autoconf_version 760b661123Smrg# 770b661123Smrg# Report bugs to <bug-libtool@gnu.org>. 78880c7e28Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 79880c7e28Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 8072313efbSmrg 81880c7e28SmrgPROGRAM=libtool 8272313efbSmrgPACKAGE=libtool 83880c7e28SmrgVERSION=2.4.2 840b661123SmrgTIMESTAMP="" 85880c7e28Smrgpackage_revision=1.3337 8672313efbSmrg 870b661123Smrg# Be Bourne compatible 8872313efbSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 8972313efbSmrg emulate sh 9072313efbSmrg NULLCMD=: 9172313efbSmrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 9272313efbSmrg # is contrary to our usage. Disable this feature. 9372313efbSmrg alias -g '${1+"$@"}'='"$@"' 9472313efbSmrg setopt NO_GLOB_SUBST 9572313efbSmrgelse 9672313efbSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 9772313efbSmrgfi 9872313efbSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 9972313efbSmrgDUALCASE=1; export DUALCASE # for MKS sh 10072313efbSmrg 101880c7e28Smrg# A function that is used when there is no print builtin or printf. 102880c7e28Smrgfunc_fallback_echo () 103880c7e28Smrg{ 104880c7e28Smrg eval 'cat <<_LTECHO_EOF 105880c7e28Smrg$1 106880c7e28Smrg_LTECHO_EOF' 107880c7e28Smrg} 108880c7e28Smrg 1090b661123Smrg# NLS nuisances: We save the old values to restore during execute mode. 1100b661123Smrglt_user_locale= 1110b661123Smrglt_safe_locale= 11272313efbSmrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 11372313efbSmrgdo 11472313efbSmrg eval "if test \"\${$lt_var+set}\" = set; then 1150b661123Smrg save_$lt_var=\$$lt_var 1160b661123Smrg $lt_var=C 11772313efbSmrg export $lt_var 1180b661123Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 1190b661123Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 12072313efbSmrg fi" 12172313efbSmrgdone 122880c7e28SmrgLC_ALL=C 123880c7e28SmrgLANGUAGE=C 124880c7e28Smrgexport LANGUAGE LC_ALL 12572313efbSmrg 1260b661123Smrg$lt_unset CDPATH 1270b661123Smrg 1280b661123Smrg 129880c7e28Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 130880c7e28Smrg# is ksh but when the shell is invoked as "sh" and the current value of 131880c7e28Smrg# the _XPG environment variable is not equal to 1 (one), the special 132880c7e28Smrg# positional parameter $0, within a function call, is the name of the 133880c7e28Smrg# function. 134880c7e28Smrgprogpath="$0" 1350b661123Smrg 1360b661123Smrg 1370b661123Smrg 1380b661123Smrg: ${CP="cp -f"} 139880c7e28Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 1400b661123Smrg: ${MAKE="make"} 1410b661123Smrg: ${MKDIR="mkdir"} 1420b661123Smrg: ${MV="mv -f"} 1430b661123Smrg: ${RM="rm -f"} 1440b661123Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 1450b661123Smrg: ${Xsed="$SED -e 1s/^X//"} 1460b661123Smrg 1470b661123Smrg# Global variables: 1480b661123SmrgEXIT_SUCCESS=0 1490b661123SmrgEXIT_FAILURE=1 1500b661123SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 1510b661123SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 1520b661123Smrg 1530b661123Smrgexit_status=$EXIT_SUCCESS 15472313efbSmrg 15572313efbSmrg# Make sure IFS has a sensible default 15672313efbSmrglt_nl=' 15772313efbSmrg' 15872313efbSmrgIFS=" $lt_nl" 15972313efbSmrg 1600b661123Smrgdirname="s,/[^/]*$,," 1610b661123Smrgbasename="s,^.*/,," 1620b661123Smrg 163880c7e28Smrg# func_dirname file append nondir_replacement 164880c7e28Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 165880c7e28Smrg# otherwise set result to NONDIR_REPLACEMENT. 166880c7e28Smrgfunc_dirname () 167880c7e28Smrg{ 168880c7e28Smrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 169880c7e28Smrg if test "X$func_dirname_result" = "X${1}"; then 170880c7e28Smrg func_dirname_result="${3}" 171880c7e28Smrg else 172880c7e28Smrg func_dirname_result="$func_dirname_result${2}" 173880c7e28Smrg fi 174880c7e28Smrg} # func_dirname may be replaced by extended shell implementation 175880c7e28Smrg 176880c7e28Smrg 177880c7e28Smrg# func_basename file 178880c7e28Smrgfunc_basename () 179880c7e28Smrg{ 180880c7e28Smrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 181880c7e28Smrg} # func_basename may be replaced by extended shell implementation 182880c7e28Smrg 183880c7e28Smrg 1840b661123Smrg# func_dirname_and_basename file append nondir_replacement 1850b661123Smrg# perform func_basename and func_dirname in a single function 1860b661123Smrg# call: 1870b661123Smrg# dirname: Compute the dirname of FILE. If nonempty, 1880b661123Smrg# add APPEND to the result, otherwise set result 1890b661123Smrg# to NONDIR_REPLACEMENT. 1900b661123Smrg# value returned in "$func_dirname_result" 1910b661123Smrg# basename: Compute filename of FILE. 1920b661123Smrg# value retuned in "$func_basename_result" 1930b661123Smrg# Implementation must be kept synchronized with func_dirname 1940b661123Smrg# and func_basename. For efficiency, we do not delegate to 1950b661123Smrg# those functions but instead duplicate the functionality here. 1960b661123Smrgfunc_dirname_and_basename () 1970b661123Smrg{ 198880c7e28Smrg # Extract subdirectory from the argument. 199880c7e28Smrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 200880c7e28Smrg if test "X$func_dirname_result" = "X${1}"; then 201880c7e28Smrg func_dirname_result="${3}" 202880c7e28Smrg else 203880c7e28Smrg func_dirname_result="$func_dirname_result${2}" 204880c7e28Smrg fi 205880c7e28Smrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 206880c7e28Smrg} # func_dirname_and_basename may be replaced by extended shell implementation 207880c7e28Smrg 208880c7e28Smrg 209880c7e28Smrg# func_stripname prefix suffix name 210880c7e28Smrg# strip PREFIX and SUFFIX off of NAME. 211880c7e28Smrg# PREFIX and SUFFIX must not contain globbing or regex special 212880c7e28Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 213880c7e28Smrg# dot (in which case that matches only a dot). 214880c7e28Smrg# func_strip_suffix prefix name 215880c7e28Smrgfunc_stripname () 216880c7e28Smrg{ 217880c7e28Smrg case ${2} in 218880c7e28Smrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 219880c7e28Smrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 220880c7e28Smrg esac 221880c7e28Smrg} # func_stripname may be replaced by extended shell implementation 222880c7e28Smrg 223880c7e28Smrg 224880c7e28Smrg# These SED scripts presuppose an absolute path with a trailing slash. 225880c7e28Smrgpathcar='s,^/\([^/]*\).*$,\1,' 226880c7e28Smrgpathcdr='s,^/[^/]*,,' 227880c7e28Smrgremovedotparts=':dotsl 228880c7e28Smrg s@/\./@/@g 229880c7e28Smrg t dotsl 230880c7e28Smrg s,/\.$,/,' 231880c7e28Smrgcollapseslashes='s@/\{1,\}@/@g' 232880c7e28Smrgfinalslash='s,/*$,/,' 233880c7e28Smrg 234880c7e28Smrg# func_normal_abspath PATH 235880c7e28Smrg# Remove doubled-up and trailing slashes, "." path components, 236880c7e28Smrg# and cancel out any ".." path components in PATH after making 237880c7e28Smrg# it an absolute path. 238880c7e28Smrg# value returned in "$func_normal_abspath_result" 239880c7e28Smrgfunc_normal_abspath () 240880c7e28Smrg{ 241880c7e28Smrg # Start from root dir and reassemble the path. 242880c7e28Smrg func_normal_abspath_result= 243880c7e28Smrg func_normal_abspath_tpath=$1 244880c7e28Smrg func_normal_abspath_altnamespace= 245880c7e28Smrg case $func_normal_abspath_tpath in 246880c7e28Smrg "") 247880c7e28Smrg # Empty path, that just means $cwd. 248880c7e28Smrg func_stripname '' '/' "`pwd`" 249880c7e28Smrg func_normal_abspath_result=$func_stripname_result 250880c7e28Smrg return 251880c7e28Smrg ;; 252880c7e28Smrg # The next three entries are used to spot a run of precisely 253880c7e28Smrg # two leading slashes without using negated character classes; 254880c7e28Smrg # we take advantage of case's first-match behaviour. 255880c7e28Smrg ///*) 256880c7e28Smrg # Unusual form of absolute path, do nothing. 257880c7e28Smrg ;; 258880c7e28Smrg //*) 259880c7e28Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 260880c7e28Smrg # and for example Cygwin uses it to access remote file shares 261880c7e28Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 262880c7e28Smrg func_normal_abspath_altnamespace=/ 263880c7e28Smrg ;; 264880c7e28Smrg /*) 265880c7e28Smrg # Absolute path, do nothing. 266880c7e28Smrg ;; 267880c7e28Smrg *) 268880c7e28Smrg # Relative path, prepend $cwd. 269880c7e28Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 270880c7e28Smrg ;; 271880c7e28Smrg esac 272880c7e28Smrg # Cancel out all the simple stuff to save iterations. We also want 273880c7e28Smrg # the path to end with a slash for ease of parsing, so make sure 274880c7e28Smrg # there is one (and only one) here. 275880c7e28Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 276880c7e28Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 277880c7e28Smrg while :; do 278880c7e28Smrg # Processed it all yet? 279880c7e28Smrg if test "$func_normal_abspath_tpath" = / ; then 280880c7e28Smrg # If we ascended to the root using ".." the result may be empty now. 281880c7e28Smrg if test -z "$func_normal_abspath_result" ; then 282880c7e28Smrg func_normal_abspath_result=/ 283880c7e28Smrg fi 284880c7e28Smrg break 285880c7e28Smrg fi 286880c7e28Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 287880c7e28Smrg -e "$pathcar"` 288880c7e28Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 289880c7e28Smrg -e "$pathcdr"` 290880c7e28Smrg # Figure out what to do with it 291880c7e28Smrg case $func_normal_abspath_tcomponent in 292880c7e28Smrg "") 293880c7e28Smrg # Trailing empty path component, ignore it. 294880c7e28Smrg ;; 295880c7e28Smrg ..) 296880c7e28Smrg # Parent dir; strip last assembled component from result. 297880c7e28Smrg func_dirname "$func_normal_abspath_result" 298880c7e28Smrg func_normal_abspath_result=$func_dirname_result 299880c7e28Smrg ;; 300880c7e28Smrg *) 301880c7e28Smrg # Actual path component, append it. 302880c7e28Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 303880c7e28Smrg ;; 304880c7e28Smrg esac 305880c7e28Smrg done 306880c7e28Smrg # Restore leading double-slash if one was found on entry. 307880c7e28Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 3080b661123Smrg} 30972313efbSmrg 310880c7e28Smrg# func_relative_path SRCDIR DSTDIR 311880c7e28Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 312880c7e28Smrg# slash if non-empty, suitable for immediately appending a filename 313880c7e28Smrg# without needing to append a separator. 314880c7e28Smrg# value returned in "$func_relative_path_result" 315880c7e28Smrgfunc_relative_path () 316880c7e28Smrg{ 317880c7e28Smrg func_relative_path_result= 318880c7e28Smrg func_normal_abspath "$1" 319880c7e28Smrg func_relative_path_tlibdir=$func_normal_abspath_result 320880c7e28Smrg func_normal_abspath "$2" 321880c7e28Smrg func_relative_path_tbindir=$func_normal_abspath_result 322880c7e28Smrg 323880c7e28Smrg # Ascend the tree starting from libdir 324880c7e28Smrg while :; do 325880c7e28Smrg # check if we have found a prefix of bindir 326880c7e28Smrg case $func_relative_path_tbindir in 327880c7e28Smrg $func_relative_path_tlibdir) 328880c7e28Smrg # found an exact match 329880c7e28Smrg func_relative_path_tcancelled= 330880c7e28Smrg break 331880c7e28Smrg ;; 332880c7e28Smrg $func_relative_path_tlibdir*) 333880c7e28Smrg # found a matching prefix 334880c7e28Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 335880c7e28Smrg func_relative_path_tcancelled=$func_stripname_result 336880c7e28Smrg if test -z "$func_relative_path_result"; then 337880c7e28Smrg func_relative_path_result=. 338880c7e28Smrg fi 339880c7e28Smrg break 340880c7e28Smrg ;; 341880c7e28Smrg *) 342880c7e28Smrg func_dirname $func_relative_path_tlibdir 343880c7e28Smrg func_relative_path_tlibdir=${func_dirname_result} 344880c7e28Smrg if test "x$func_relative_path_tlibdir" = x ; then 345880c7e28Smrg # Have to descend all the way to the root! 346880c7e28Smrg func_relative_path_result=../$func_relative_path_result 347880c7e28Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 348880c7e28Smrg break 349880c7e28Smrg fi 350880c7e28Smrg func_relative_path_result=../$func_relative_path_result 351880c7e28Smrg ;; 352880c7e28Smrg esac 353880c7e28Smrg done 3540b661123Smrg 355880c7e28Smrg # Now calculate path; take care to avoid doubling-up slashes. 356880c7e28Smrg func_stripname '' '/' "$func_relative_path_result" 357880c7e28Smrg func_relative_path_result=$func_stripname_result 358880c7e28Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 359880c7e28Smrg if test "x$func_stripname_result" != x ; then 360880c7e28Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 361880c7e28Smrg fi 362880c7e28Smrg 363880c7e28Smrg # Normalisation. If bindir is libdir, return empty string, 364880c7e28Smrg # else relative path ending with a slash; either way, target 365880c7e28Smrg # file name can be directly appended. 366880c7e28Smrg if test ! -z "$func_relative_path_result"; then 367880c7e28Smrg func_stripname './' '' "$func_relative_path_result/" 368880c7e28Smrg func_relative_path_result=$func_stripname_result 369880c7e28Smrg fi 370880c7e28Smrg} 3710b661123Smrg 3720b661123Smrg# The name of this program: 3730b661123Smrgfunc_dirname_and_basename "$progpath" 3740b661123Smrgprogname=$func_basename_result 3750b661123Smrg 3760b661123Smrg# Make sure we have an absolute path for reexecution: 3770b661123Smrgcase $progpath in 3780b661123Smrg [\\/]*|[A-Za-z]:\\*) ;; 3790b661123Smrg *[\\/]*) 3800b661123Smrg progdir=$func_dirname_result 3810b661123Smrg progdir=`cd "$progdir" && pwd` 3820b661123Smrg progpath="$progdir/$progname" 3830b661123Smrg ;; 3840b661123Smrg *) 3850b661123Smrg save_IFS="$IFS" 386880c7e28Smrg IFS=${PATH_SEPARATOR-:} 3870b661123Smrg for progdir in $PATH; do 3880b661123Smrg IFS="$save_IFS" 3890b661123Smrg test -x "$progdir/$progname" && break 3900b661123Smrg done 3910b661123Smrg IFS="$save_IFS" 3920b661123Smrg test -n "$progdir" || progdir=`pwd` 3930b661123Smrg progpath="$progdir/$progname" 3940b661123Smrg ;; 3950b661123Smrgesac 3960b661123Smrg 3970b661123Smrg# Sed substitution that helps us do robust quoting. It backslashifies 3980b661123Smrg# metacharacters that are still active within double-quoted strings. 3990b661123SmrgXsed="${SED}"' -e 1s/^X//' 4000b661123Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 4010b661123Smrg 4020b661123Smrg# Same as above, but do not quote variable references. 4030b661123Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 4040b661123Smrg 405880c7e28Smrg# Sed substitution that turns a string into a regex matching for the 406880c7e28Smrg# string literally. 407880c7e28Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 408880c7e28Smrg 409880c7e28Smrg# Sed substitution that converts a w32 file name or path 410880c7e28Smrg# which contains forward slashes, into one that contains 411880c7e28Smrg# (escaped) backslashes. A very naive implementation. 412880c7e28Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 413880c7e28Smrg 4140b661123Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 4150b661123Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 4160b661123Smrg# in input to double_quote_subst, that '$' was protected from expansion. 4170b661123Smrg# Since each input `\' is now two `\'s, look for any number of runs of 4180b661123Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 4190b661123Smrgbs='\\' 4200b661123Smrgbs2='\\\\' 4210b661123Smrgbs4='\\\\\\\\' 4220b661123Smrgdollar='\$' 4230b661123Smrgsed_double_backslash="\ 4240b661123Smrg s/$bs4/&\\ 4250b661123Smrg/g 4260b661123Smrg s/^$bs2$dollar/$bs&/ 4270b661123Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 4280b661123Smrg s/\n//g" 4290b661123Smrg 4300b661123Smrg# Standard options: 4310b661123Smrgopt_dry_run=false 4320b661123Smrgopt_help=false 4330b661123Smrgopt_quiet=false 4340b661123Smrgopt_verbose=false 4350b661123Smrgopt_warning=: 4360b661123Smrg 4370b661123Smrg# func_echo arg... 4380b661123Smrg# Echo program name prefixed message, along with the current mode 4390b661123Smrg# name if it has been set yet. 4400b661123Smrgfunc_echo () 4410b661123Smrg{ 442880c7e28Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 4430b661123Smrg} 4440b661123Smrg 4450b661123Smrg# func_verbose arg... 4460b661123Smrg# Echo program name prefixed message in verbose mode only. 4470b661123Smrgfunc_verbose () 4480b661123Smrg{ 4490b661123Smrg $opt_verbose && func_echo ${1+"$@"} 4500b661123Smrg 4510b661123Smrg # A bug in bash halts the script if the last line of a function 4520b661123Smrg # fails when set -e is in force, so we need another command to 4530b661123Smrg # work around that: 4540b661123Smrg : 4550b661123Smrg} 4560b661123Smrg 457880c7e28Smrg# func_echo_all arg... 458880c7e28Smrg# Invoke $ECHO with all args, space-separated. 459880c7e28Smrgfunc_echo_all () 460880c7e28Smrg{ 461880c7e28Smrg $ECHO "$*" 462880c7e28Smrg} 463880c7e28Smrg 4640b661123Smrg# func_error arg... 4650b661123Smrg# Echo program name prefixed message to standard error. 4660b661123Smrgfunc_error () 4670b661123Smrg{ 468880c7e28Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 4690b661123Smrg} 4700b661123Smrg 4710b661123Smrg# func_warning arg... 4720b661123Smrg# Echo program name prefixed warning message to standard error. 4730b661123Smrgfunc_warning () 4740b661123Smrg{ 475880c7e28Smrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 4760b661123Smrg 4770b661123Smrg # bash bug again: 4780b661123Smrg : 4790b661123Smrg} 4800b661123Smrg 4810b661123Smrg# func_fatal_error arg... 4820b661123Smrg# Echo program name prefixed message to standard error, and exit. 4830b661123Smrgfunc_fatal_error () 4840b661123Smrg{ 4850b661123Smrg func_error ${1+"$@"} 4860b661123Smrg exit $EXIT_FAILURE 4870b661123Smrg} 4880b661123Smrg 4890b661123Smrg# func_fatal_help arg... 4900b661123Smrg# Echo program name prefixed message to standard error, followed by 4910b661123Smrg# a help hint, and exit. 4920b661123Smrgfunc_fatal_help () 4930b661123Smrg{ 4940b661123Smrg func_error ${1+"$@"} 4950b661123Smrg func_fatal_error "$help" 4960b661123Smrg} 4970b661123Smrghelp="Try \`$progname --help' for more information." ## default 4980b661123Smrg 4990b661123Smrg 5000b661123Smrg# func_grep expression filename 5010b661123Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 5020b661123Smrgfunc_grep () 5030b661123Smrg{ 5040b661123Smrg $GREP "$1" "$2" >/dev/null 2>&1 5050b661123Smrg} 5060b661123Smrg 5070b661123Smrg 5080b661123Smrg# func_mkdir_p directory-path 5090b661123Smrg# Make sure the entire path to DIRECTORY-PATH is available. 5100b661123Smrgfunc_mkdir_p () 5110b661123Smrg{ 5120b661123Smrg my_directory_path="$1" 5130b661123Smrg my_dir_list= 5140b661123Smrg 5150b661123Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 5160b661123Smrg 5170b661123Smrg # Protect directory names starting with `-' 5180b661123Smrg case $my_directory_path in 5190b661123Smrg -*) my_directory_path="./$my_directory_path" ;; 5200b661123Smrg esac 5210b661123Smrg 5220b661123Smrg # While some portion of DIR does not yet exist... 5230b661123Smrg while test ! -d "$my_directory_path"; do 5240b661123Smrg # ...make a list in topmost first order. Use a colon delimited 5250b661123Smrg # list incase some portion of path contains whitespace. 5260b661123Smrg my_dir_list="$my_directory_path:$my_dir_list" 5270b661123Smrg 5280b661123Smrg # If the last portion added has no slash in it, the list is done 5290b661123Smrg case $my_directory_path in */*) ;; *) break ;; esac 5300b661123Smrg 5310b661123Smrg # ...otherwise throw away the child directory and loop 532880c7e28Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 5330b661123Smrg done 534880c7e28Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 5350b661123Smrg 5360b661123Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 5370b661123Smrg for my_dir in $my_dir_list; do 5380b661123Smrg IFS="$save_mkdir_p_IFS" 5390b661123Smrg # mkdir can fail with a `File exist' error if two processes 5400b661123Smrg # try to create one of the directories concurrently. Don't 5410b661123Smrg # stop in that case! 5420b661123Smrg $MKDIR "$my_dir" 2>/dev/null || : 5430b661123Smrg done 5440b661123Smrg IFS="$save_mkdir_p_IFS" 5450b661123Smrg 5460b661123Smrg # Bail out if we (or some other process) failed to create a directory. 5470b661123Smrg test -d "$my_directory_path" || \ 5480b661123Smrg func_fatal_error "Failed to create \`$1'" 5490b661123Smrg fi 5500b661123Smrg} 551bdcaa8d0Smrg 552bdcaa8d0Smrg 553bdcaa8d0Smrg# func_mktempdir [string] 554bdcaa8d0Smrg# Make a temporary directory that won't clash with other running 555bdcaa8d0Smrg# libtool processes, and avoids race conditions if possible. If 556bdcaa8d0Smrg# given, STRING is the basename for that directory. 557bdcaa8d0Smrgfunc_mktempdir () 558bdcaa8d0Smrg{ 559bdcaa8d0Smrg my_template="${TMPDIR-/tmp}/${1-$progname}" 560bdcaa8d0Smrg 5610b661123Smrg if test "$opt_dry_run" = ":"; then 562bdcaa8d0Smrg # Return a directory name, but don't create it in dry-run mode 563bdcaa8d0Smrg my_tmpdir="${my_template}-$$" 564bdcaa8d0Smrg else 565bdcaa8d0Smrg 566bdcaa8d0Smrg # If mktemp works, use that first and foremost 567bdcaa8d0Smrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 568bdcaa8d0Smrg 569bdcaa8d0Smrg if test ! -d "$my_tmpdir"; then 5700b661123Smrg # Failing that, at least try and use $RANDOM to avoid a race 5710b661123Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 572bdcaa8d0Smrg 5730b661123Smrg save_mktempdir_umask=`umask` 5740b661123Smrg umask 0077 5750b661123Smrg $MKDIR "$my_tmpdir" 5760b661123Smrg umask $save_mktempdir_umask 577bdcaa8d0Smrg fi 578bdcaa8d0Smrg 579bdcaa8d0Smrg # If we're not in dry-run mode, bomb out on failure 5800b661123Smrg test -d "$my_tmpdir" || \ 5810b661123Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 582bdcaa8d0Smrg fi 583bdcaa8d0Smrg 584880c7e28Smrg $ECHO "$my_tmpdir" 585bdcaa8d0Smrg} 586bdcaa8d0Smrg 587bdcaa8d0Smrg 5880b661123Smrg# func_quote_for_eval arg 5890b661123Smrg# Aesthetically quote ARG to be evaled later. 5900b661123Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 5910b661123Smrg# is double-quoted, suitable for a subsequent eval, whereas 5920b661123Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 5930b661123Smrg# which are still active within double quotes backslashified. 5940b661123Smrgfunc_quote_for_eval () 595bdcaa8d0Smrg{ 5960b661123Smrg case $1 in 5970b661123Smrg *[\\\`\"\$]*) 598880c7e28Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 5990b661123Smrg *) 6000b661123Smrg func_quote_for_eval_unquoted_result="$1" ;; 6010b661123Smrg esac 6020b661123Smrg 6030b661123Smrg case $func_quote_for_eval_unquoted_result in 6040b661123Smrg # Double-quote args containing shell metacharacters to delay 6050b661123Smrg # word splitting, command substitution and and variable 6060b661123Smrg # expansion for a subsequent eval. 6070b661123Smrg # Many Bourne shells cannot handle close brackets correctly 6080b661123Smrg # in scan sets, so we specify it separately. 6090b661123Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 6100b661123Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 6110b661123Smrg ;; 6120b661123Smrg *) 6130b661123Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 614bdcaa8d0Smrg esac 615bdcaa8d0Smrg} 616bdcaa8d0Smrg 617bdcaa8d0Smrg 6180b661123Smrg# func_quote_for_expand arg 6190b661123Smrg# Aesthetically quote ARG to be evaled later; same as above, 6200b661123Smrg# but do not quote variable references. 6210b661123Smrgfunc_quote_for_expand () 622bdcaa8d0Smrg{ 6230b661123Smrg case $1 in 6240b661123Smrg *[\\\`\"]*) 625880c7e28Smrg my_arg=`$ECHO "$1" | $SED \ 6260b661123Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 627bdcaa8d0Smrg *) 6280b661123Smrg my_arg="$1" ;; 6290b661123Smrg esac 6300b661123Smrg 6310b661123Smrg case $my_arg in 6320b661123Smrg # Double-quote args containing shell metacharacters to delay 6330b661123Smrg # word splitting and command substitution for a subsequent eval. 6340b661123Smrg # Many Bourne shells cannot handle close brackets correctly 6350b661123Smrg # in scan sets, so we specify it separately. 6360b661123Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 6370b661123Smrg my_arg="\"$my_arg\"" 6380b661123Smrg ;; 6390b661123Smrg esac 6400b661123Smrg 6410b661123Smrg func_quote_for_expand_result="$my_arg" 642bdcaa8d0Smrg} 643bdcaa8d0Smrg 644bdcaa8d0Smrg 6450b661123Smrg# func_show_eval cmd [fail_exp] 6460b661123Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 6470b661123Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 6480b661123Smrg# is given, then evaluate it. 6490b661123Smrgfunc_show_eval () 650bdcaa8d0Smrg{ 6510b661123Smrg my_cmd="$1" 6520b661123Smrg my_fail_exp="${2-:}" 65372313efbSmrg 6540b661123Smrg ${opt_silent-false} || { 6550b661123Smrg func_quote_for_expand "$my_cmd" 6560b661123Smrg eval "func_echo $func_quote_for_expand_result" 6570b661123Smrg } 6580b661123Smrg 6590b661123Smrg if ${opt_dry_run-false}; then :; else 6600b661123Smrg eval "$my_cmd" 6610b661123Smrg my_status=$? 6620b661123Smrg if test "$my_status" -eq 0; then :; else 6630b661123Smrg eval "(exit $my_status); $my_fail_exp" 6640b661123Smrg fi 665bdcaa8d0Smrg fi 666bdcaa8d0Smrg} 667bdcaa8d0Smrg 6680b661123Smrg 6690b661123Smrg# func_show_eval_locale cmd [fail_exp] 6700b661123Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 6710b661123Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 6720b661123Smrg# is given, then evaluate it. Use the saved locale for evaluation. 6730b661123Smrgfunc_show_eval_locale () 674bdcaa8d0Smrg{ 6750b661123Smrg my_cmd="$1" 6760b661123Smrg my_fail_exp="${2-:}" 6770b661123Smrg 6780b661123Smrg ${opt_silent-false} || { 6790b661123Smrg func_quote_for_expand "$my_cmd" 6800b661123Smrg eval "func_echo $func_quote_for_expand_result" 6810b661123Smrg } 6820b661123Smrg 6830b661123Smrg if ${opt_dry_run-false}; then :; else 6840b661123Smrg eval "$lt_user_locale 6850b661123Smrg $my_cmd" 6860b661123Smrg my_status=$? 6870b661123Smrg eval "$lt_safe_locale" 6880b661123Smrg if test "$my_status" -eq 0; then :; else 6890b661123Smrg eval "(exit $my_status); $my_fail_exp" 6900b661123Smrg fi 69172313efbSmrg fi 6920b661123Smrg} 693bdcaa8d0Smrg 694880c7e28Smrg# func_tr_sh 695880c7e28Smrg# Turn $1 into a string suitable for a shell variable name. 696880c7e28Smrg# Result is stored in $func_tr_sh_result. All characters 697880c7e28Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 698880c7e28Smrg# if $1 begins with a digit, a '_' is prepended as well. 699880c7e28Smrgfunc_tr_sh () 700880c7e28Smrg{ 701880c7e28Smrg case $1 in 702880c7e28Smrg [0-9]* | *[!a-zA-Z0-9_]*) 703880c7e28Smrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 704880c7e28Smrg ;; 705880c7e28Smrg * ) 706880c7e28Smrg func_tr_sh_result=$1 707880c7e28Smrg ;; 708880c7e28Smrg esac 709880c7e28Smrg} 7100b661123Smrg 7110b661123Smrg 7120b661123Smrg# func_version 7130b661123Smrg# Echo version message to standard output and exit. 7140b661123Smrgfunc_version () 7150b661123Smrg{ 716880c7e28Smrg $opt_debug 717880c7e28Smrg 718880c7e28Smrg $SED -n '/(C)/!b go 719880c7e28Smrg :more 720880c7e28Smrg /\./!{ 721880c7e28Smrg N 722880c7e28Smrg s/\n# / / 723880c7e28Smrg b more 724880c7e28Smrg } 725880c7e28Smrg :go 726880c7e28Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 7270b661123Smrg s/^# // 7280b661123Smrg s/^# *$// 7290b661123Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 7300b661123Smrg p 7310b661123Smrg }' < "$progpath" 7320b661123Smrg exit $? 7330b661123Smrg} 7340b661123Smrg 7350b661123Smrg# func_usage 7360b661123Smrg# Echo short help message to standard output and exit. 7370b661123Smrgfunc_usage () 7380b661123Smrg{ 739880c7e28Smrg $opt_debug 740880c7e28Smrg 741880c7e28Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 7420b661123Smrg s/^# // 7430b661123Smrg s/^# *$// 7440b661123Smrg s/\$progname/'$progname'/ 7450b661123Smrg p 7460b661123Smrg }' < "$progpath" 747880c7e28Smrg echo 7480b661123Smrg $ECHO "run \`$progname --help | more' for full usage" 7490b661123Smrg exit $? 7500b661123Smrg} 7510b661123Smrg 752880c7e28Smrg# func_help [NOEXIT] 753880c7e28Smrg# Echo long help message to standard output and exit, 754880c7e28Smrg# unless 'noexit' is passed as argument. 7550b661123Smrgfunc_help () 7560b661123Smrg{ 757880c7e28Smrg $opt_debug 758880c7e28Smrg 7590b661123Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 760880c7e28Smrg :print 7610b661123Smrg s/^# // 7620b661123Smrg s/^# *$// 7630b661123Smrg s*\$progname*'$progname'* 7640b661123Smrg s*\$host*'"$host"'* 7650b661123Smrg s*\$SHELL*'"$SHELL"'* 7660b661123Smrg s*\$LTCC*'"$LTCC"'* 7670b661123Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 7680b661123Smrg s*\$LD*'"$LD"'* 7690b661123Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 770880c7e28Smrg s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ 771880c7e28Smrg s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ 7720b661123Smrg p 773880c7e28Smrg d 774880c7e28Smrg } 775880c7e28Smrg /^# .* home page:/b print 776880c7e28Smrg /^# General help using/b print 777880c7e28Smrg ' < "$progpath" 778880c7e28Smrg ret=$? 779880c7e28Smrg if test -z "$1"; then 780880c7e28Smrg exit $ret 781880c7e28Smrg fi 7820b661123Smrg} 7830b661123Smrg 7840b661123Smrg# func_missing_arg argname 7850b661123Smrg# Echo program name prefixed message to standard error and set global 7860b661123Smrg# exit_cmd. 7870b661123Smrgfunc_missing_arg () 7880b661123Smrg{ 789880c7e28Smrg $opt_debug 790880c7e28Smrg 791880c7e28Smrg func_error "missing argument for $1." 7920b661123Smrg exit_cmd=exit 79372313efbSmrg} 79472313efbSmrg 79572313efbSmrg 796880c7e28Smrg# func_split_short_opt shortopt 797880c7e28Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 798880c7e28Smrg# variables after splitting SHORTOPT after the 2nd character. 799880c7e28Smrgfunc_split_short_opt () 800880c7e28Smrg{ 801880c7e28Smrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 802880c7e28Smrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 80372313efbSmrg 804880c7e28Smrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 805880c7e28Smrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 806880c7e28Smrg} # func_split_short_opt may be replaced by extended shell implementation 807880c7e28Smrg 808880c7e28Smrg 809880c7e28Smrg# func_split_long_opt longopt 810880c7e28Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 811880c7e28Smrg# variables after splitting LONGOPT at the `=' sign. 812880c7e28Smrgfunc_split_long_opt () 813880c7e28Smrg{ 814880c7e28Smrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 815880c7e28Smrg my_sed_long_arg='1s/^--[^=]*=//' 816880c7e28Smrg 817880c7e28Smrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 818880c7e28Smrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 819880c7e28Smrg} # func_split_long_opt may be replaced by extended shell implementation 820880c7e28Smrg 821880c7e28Smrgexit_cmd=: 8220b661123Smrg 8230b661123Smrg 8240b661123Smrg 825bdcaa8d0Smrg 826bdcaa8d0Smrg 8270b661123Smrgmagic="%%%MAGIC variable%%%" 8280b661123Smrgmagic_exe="%%%MAGIC EXE variable%%%" 829bdcaa8d0Smrg 8300b661123Smrg# Global variables. 8310b661123Smrgnonopt= 8320b661123Smrgpreserve_args= 8330b661123Smrglo2o="s/\\.lo\$/.${objext}/" 8340b661123Smrgo2lo="s/\\.${objext}\$/.lo/" 8350b661123Smrgextracted_archives= 8360b661123Smrgextracted_serial=0 837bdcaa8d0Smrg 8380b661123Smrg# If this variable is set in any of the actions, the command in it 8390b661123Smrg# will be execed at the end. This prevents here-documents from being 8400b661123Smrg# left over by shells. 8410b661123Smrgexec_cmd= 8420b661123Smrg 843880c7e28Smrg# func_append var value 844880c7e28Smrg# Append VALUE to the end of shell variable VAR. 845880c7e28Smrgfunc_append () 846880c7e28Smrg{ 847880c7e28Smrg eval "${1}=\$${1}\${2}" 848880c7e28Smrg} # func_append may be replaced by extended shell implementation 849880c7e28Smrg 850880c7e28Smrg# func_append_quoted var value 851880c7e28Smrg# Quote VALUE and append to the end of shell variable VAR, separated 852880c7e28Smrg# by a space. 853880c7e28Smrgfunc_append_quoted () 854880c7e28Smrg{ 855880c7e28Smrg func_quote_for_eval "${2}" 856880c7e28Smrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 857880c7e28Smrg} # func_append_quoted may be replaced by extended shell implementation 858880c7e28Smrg 859880c7e28Smrg 860880c7e28Smrg# func_arith arithmetic-term... 861880c7e28Smrgfunc_arith () 862880c7e28Smrg{ 863880c7e28Smrg func_arith_result=`expr "${@}"` 864880c7e28Smrg} # func_arith may be replaced by extended shell implementation 865880c7e28Smrg 866880c7e28Smrg 867880c7e28Smrg# func_len string 868880c7e28Smrg# STRING may not start with a hyphen. 869880c7e28Smrgfunc_len () 870880c7e28Smrg{ 871880c7e28Smrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 872880c7e28Smrg} # func_len may be replaced by extended shell implementation 873880c7e28Smrg 874880c7e28Smrg 875880c7e28Smrg# func_lo2o object 876880c7e28Smrgfunc_lo2o () 877880c7e28Smrg{ 878880c7e28Smrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 879880c7e28Smrg} # func_lo2o may be replaced by extended shell implementation 880880c7e28Smrg 881880c7e28Smrg 882880c7e28Smrg# func_xform libobj-or-source 883880c7e28Smrgfunc_xform () 884880c7e28Smrg{ 885880c7e28Smrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 886880c7e28Smrg} # func_xform may be replaced by extended shell implementation 887880c7e28Smrg 888880c7e28Smrg 8890b661123Smrg# func_fatal_configuration arg... 8900b661123Smrg# Echo program name prefixed message to standard error, followed by 8910b661123Smrg# a configuration failure hint, and exit. 8920b661123Smrgfunc_fatal_configuration () 8930b661123Smrg{ 8940b661123Smrg func_error ${1+"$@"} 8950b661123Smrg func_error "See the $PACKAGE documentation for more information." 8960b661123Smrg func_fatal_error "Fatal configuration error." 8970b661123Smrg} 89872313efbSmrg 89972313efbSmrg 9000b661123Smrg# func_config 9010b661123Smrg# Display the configuration for all the tags in this script. 9020b661123Smrgfunc_config () 9030b661123Smrg{ 9040b661123Smrg re_begincf='^# ### BEGIN LIBTOOL' 9050b661123Smrg re_endcf='^# ### END LIBTOOL' 9060b661123Smrg 9070b661123Smrg # Default configuration. 9080b661123Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 909bdcaa8d0Smrg 910bdcaa8d0Smrg # Now print the configurations for the tags. 911bdcaa8d0Smrg for tagname in $taglist; do 9120b661123Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 913bdcaa8d0Smrg done 91496ce994aSmrg 9150b661123Smrg exit $? 9160b661123Smrg} 91796ce994aSmrg 9180b661123Smrg# func_features 9190b661123Smrg# Display the features supported by this script. 9200b661123Smrgfunc_features () 9210b661123Smrg{ 922880c7e28Smrg echo "host: $host" 923bdcaa8d0Smrg if test "$build_libtool_libs" = yes; then 924880c7e28Smrg echo "enable shared libraries" 925bdcaa8d0Smrg else 926880c7e28Smrg echo "disable shared libraries" 927bdcaa8d0Smrg fi 928bdcaa8d0Smrg if test "$build_old_libs" = yes; then 929880c7e28Smrg echo "enable static libraries" 930bdcaa8d0Smrg else 931880c7e28Smrg echo "disable static libraries" 932bdcaa8d0Smrg fi 9330b661123Smrg 934bdcaa8d0Smrg exit $? 9350b661123Smrg} 936bdcaa8d0Smrg 9370b661123Smrg# func_enable_tag tagname 9380b661123Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 9390b661123Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 9400b661123Smrg# variable here. 9410b661123Smrgfunc_enable_tag () 9420b661123Smrg{ 9430b661123Smrg # Global variable: 9440b661123Smrg tagname="$1" 945bdcaa8d0Smrg 9460b661123Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 9470b661123Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 9480b661123Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 949bdcaa8d0Smrg 9500b661123Smrg # Validate tagname. 9510b661123Smrg case $tagname in 9520b661123Smrg *[!-_A-Za-z0-9,/]*) 9530b661123Smrg func_fatal_error "invalid tag name: $tagname" 9540b661123Smrg ;; 9550b661123Smrg esac 956bdcaa8d0Smrg 9570b661123Smrg # Don't test for the "default" C tag, as we know it's 9580b661123Smrg # there but not specially marked. 9590b661123Smrg case $tagname in 9600b661123Smrg CC) ;; 9610b661123Smrg *) 9620b661123Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 9630b661123Smrg taglist="$taglist $tagname" 9640b661123Smrg 9650b661123Smrg # Evaluate the configuration. Be careful to quote the path 9660b661123Smrg # and the sed script, to avoid splitting on whitespace, but 9670b661123Smrg # also don't use non-portable quotes within backquotes within 9680b661123Smrg # quotes we have to do it in 2 steps: 9690b661123Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 9700b661123Smrg eval "$extractedcf" 9710b661123Smrg else 9720b661123Smrg func_error "ignoring unknown tag $tagname" 9730b661123Smrg fi 9740b661123Smrg ;; 9750b661123Smrg esac 9760b661123Smrg} 9770b661123Smrg 978880c7e28Smrg# func_check_version_match 979880c7e28Smrg# Ensure that we are using m4 macros, and libtool script from the same 980880c7e28Smrg# release of libtool. 981880c7e28Smrgfunc_check_version_match () 9820b661123Smrg{ 983880c7e28Smrg if test "$package_revision" != "$macro_revision"; then 984880c7e28Smrg if test "$VERSION" != "$macro_version"; then 985880c7e28Smrg if test -z "$macro_version"; then 986880c7e28Smrg cat >&2 <<_LT_EOF 987880c7e28Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 988880c7e28Smrg$progname: definition of this LT_INIT comes from an older release. 989880c7e28Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 990880c7e28Smrg$progname: and run autoconf again. 991880c7e28Smrg_LT_EOF 992880c7e28Smrg else 993880c7e28Smrg cat >&2 <<_LT_EOF 994880c7e28Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 995880c7e28Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 996880c7e28Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 997880c7e28Smrg$progname: and run autoconf again. 998880c7e28Smrg_LT_EOF 999880c7e28Smrg fi 1000880c7e28Smrg else 1001880c7e28Smrg cat >&2 <<_LT_EOF 1002880c7e28Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 1003880c7e28Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 1004880c7e28Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 1005880c7e28Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 1006880c7e28Smrg_LT_EOF 1007880c7e28Smrg fi 1008880c7e28Smrg 1009880c7e28Smrg exit $EXIT_MISMATCH 1010880c7e28Smrg fi 1011880c7e28Smrg} 1012880c7e28Smrg 1013880c7e28Smrg 1014880c7e28Smrg# Shorthand for --mode=foo, only valid as the first argument 1015880c7e28Smrgcase $1 in 1016880c7e28Smrgclean|clea|cle|cl) 1017880c7e28Smrg shift; set dummy --mode clean ${1+"$@"}; shift 1018880c7e28Smrg ;; 1019880c7e28Smrgcompile|compil|compi|comp|com|co|c) 1020880c7e28Smrg shift; set dummy --mode compile ${1+"$@"}; shift 1021880c7e28Smrg ;; 1022880c7e28Smrgexecute|execut|execu|exec|exe|ex|e) 1023880c7e28Smrg shift; set dummy --mode execute ${1+"$@"}; shift 1024880c7e28Smrg ;; 1025880c7e28Smrgfinish|finis|fini|fin|fi|f) 1026880c7e28Smrg shift; set dummy --mode finish ${1+"$@"}; shift 1027880c7e28Smrg ;; 1028880c7e28Smrginstall|instal|insta|inst|ins|in|i) 1029880c7e28Smrg shift; set dummy --mode install ${1+"$@"}; shift 1030880c7e28Smrg ;; 1031880c7e28Smrglink|lin|li|l) 1032880c7e28Smrg shift; set dummy --mode link ${1+"$@"}; shift 1033880c7e28Smrg ;; 1034880c7e28Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 1035880c7e28Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 1036880c7e28Smrg ;; 1037880c7e28Smrgesac 1038880c7e28Smrg 1039880c7e28Smrg 1040880c7e28Smrg 1041880c7e28Smrg# Option defaults: 1042880c7e28Smrgopt_debug=: 1043880c7e28Smrgopt_dry_run=false 1044880c7e28Smrgopt_config=false 1045880c7e28Smrgopt_preserve_dup_deps=false 1046880c7e28Smrgopt_features=false 1047880c7e28Smrgopt_finish=false 1048880c7e28Smrgopt_help=false 1049880c7e28Smrgopt_help_all=false 1050880c7e28Smrgopt_silent=: 1051880c7e28Smrgopt_warning=: 1052880c7e28Smrgopt_verbose=: 1053880c7e28Smrgopt_silent=false 1054880c7e28Smrgopt_verbose=false 105596ce994aSmrg 1056bdcaa8d0Smrg 1057880c7e28Smrg# Parse options once, thoroughly. This comes as soon as possible in the 1058880c7e28Smrg# script to make things like `--version' happen as quickly as we can. 1059880c7e28Smrg{ 1060880c7e28Smrg # this just eases exit handling 1061880c7e28Smrg while test $# -gt 0; do 10620b661123Smrg opt="$1" 10630b661123Smrg shift 10640b661123Smrg case $opt in 1065880c7e28Smrg --debug|-x) opt_debug='set -x' 10660b661123Smrg func_echo "enabling shell trace mode" 10670b661123Smrg $opt_debug 10680b661123Smrg ;; 1069880c7e28Smrg --dry-run|--dryrun|-n) 1070880c7e28Smrg opt_dry_run=: 10710b661123Smrg ;; 1072880c7e28Smrg --config) 1073880c7e28Smrg opt_config=: 1074880c7e28Smrgfunc_config 1075880c7e28Smrg ;; 1076880c7e28Smrg --dlopen|-dlopen) 1077880c7e28Smrg optarg="$1" 1078880c7e28Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 1079880c7e28Smrg}$optarg" 10800b661123Smrg shift 10810b661123Smrg ;; 10820b661123Smrg --preserve-dup-deps) 1083880c7e28Smrg opt_preserve_dup_deps=: 10840b661123Smrg ;; 1085880c7e28Smrg --features) 1086880c7e28Smrg opt_features=: 1087880c7e28Smrgfunc_features 1088880c7e28Smrg ;; 1089880c7e28Smrg --finish) 1090880c7e28Smrg opt_finish=: 1091880c7e28Smrgset dummy --mode finish ${1+"$@"}; shift 1092880c7e28Smrg ;; 1093880c7e28Smrg --help) 1094880c7e28Smrg opt_help=: 1095880c7e28Smrg ;; 1096880c7e28Smrg --help-all) 1097880c7e28Smrg opt_help_all=: 1098880c7e28Smrgopt_help=': help-all' 1099880c7e28Smrg ;; 1100880c7e28Smrg --mode) 1101880c7e28Smrg test $# = 0 && func_missing_arg $opt && break 1102880c7e28Smrg optarg="$1" 1103880c7e28Smrg opt_mode="$optarg" 1104880c7e28Smrgcase $optarg in 1105880c7e28Smrg # Valid mode arguments: 1106880c7e28Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 1107880c7e28Smrg 1108880c7e28Smrg # Catch anything else as an error 1109880c7e28Smrg *) func_error "invalid argument for $opt" 1110880c7e28Smrg exit_cmd=exit 1111880c7e28Smrg break 1112880c7e28Smrg ;; 1113880c7e28Smrgesac 1114880c7e28Smrg shift 1115880c7e28Smrg ;; 1116880c7e28Smrg --no-silent|--no-quiet) 11170b661123Smrg opt_silent=false 1118880c7e28Smrgfunc_append preserve_args " $opt" 11190b661123Smrg ;; 1120880c7e28Smrg --no-warning|--no-warn) 1121880c7e28Smrg opt_warning=false 1122880c7e28Smrgfunc_append preserve_args " $opt" 1123880c7e28Smrg ;; 1124880c7e28Smrg --no-verbose) 1125880c7e28Smrg opt_verbose=false 1126880c7e28Smrgfunc_append preserve_args " $opt" 1127880c7e28Smrg ;; 1128880c7e28Smrg --silent|--quiet) 1129880c7e28Smrg opt_silent=: 1130880c7e28Smrgfunc_append preserve_args " $opt" 1131880c7e28Smrg opt_verbose=false 1132880c7e28Smrg ;; 1133880c7e28Smrg --verbose|-v) 1134880c7e28Smrg opt_verbose=: 1135880c7e28Smrgfunc_append preserve_args " $opt" 1136880c7e28Smrgopt_silent=false 1137880c7e28Smrg ;; 1138880c7e28Smrg --tag) 1139880c7e28Smrg test $# = 0 && func_missing_arg $opt && break 1140880c7e28Smrg optarg="$1" 1141880c7e28Smrg opt_tag="$optarg" 1142880c7e28Smrgfunc_append preserve_args " $opt $optarg" 1143880c7e28Smrgfunc_enable_tag "$optarg" 11440b661123Smrg shift 11450b661123Smrg ;; 11460b661123Smrg 1147880c7e28Smrg -\?|-h) func_usage ;; 1148880c7e28Smrg --help) func_help ;; 1149880c7e28Smrg --version) func_version ;; 1150880c7e28Smrg 11510b661123Smrg # Separate optargs to long options: 1152880c7e28Smrg --*=*) 1153880c7e28Smrg func_split_long_opt "$opt" 1154880c7e28Smrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 11550b661123Smrg shift 11560b661123Smrg ;; 11570b661123Smrg 1158880c7e28Smrg # Separate non-argument short options: 1159880c7e28Smrg -\?*|-h*|-n*|-v*) 1160880c7e28Smrg func_split_short_opt "$opt" 1161880c7e28Smrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 1162880c7e28Smrg shift 11630b661123Smrg ;; 1164880c7e28Smrg 1165880c7e28Smrg --) break ;; 1166880c7e28Smrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 1167880c7e28Smrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 11680b661123Smrg esac 11690b661123Smrg done 11700b661123Smrg 1171880c7e28Smrg # Validate options: 1172880c7e28Smrg 1173880c7e28Smrg # save first non-option argument 1174880c7e28Smrg if test "$#" -gt 0; then 1175880c7e28Smrg nonopt="$opt" 1176880c7e28Smrg shift 1177880c7e28Smrg fi 1178880c7e28Smrg 1179880c7e28Smrg # preserve --debug 1180880c7e28Smrg test "$opt_debug" = : || func_append preserve_args " --debug" 11810b661123Smrg 11820b661123Smrg case $host in 11830b661123Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 11840b661123Smrg # don't eliminate duplications in $postdeps and $predeps 11850b661123Smrg opt_duplicate_compiler_generated_deps=: 118696ce994aSmrg ;; 118796ce994aSmrg *) 1188880c7e28Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 11890b661123Smrg ;; 11900b661123Smrg esac 119172313efbSmrg 1192880c7e28Smrg $opt_help || { 1193880c7e28Smrg # Sanity checks first: 1194880c7e28Smrg func_check_version_match 11950b661123Smrg 1196880c7e28Smrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 1197880c7e28Smrg func_fatal_configuration "not configured to build any kind of library" 11980b661123Smrg fi 11990b661123Smrg 1200880c7e28Smrg # Darwin sucks 1201880c7e28Smrg eval std_shrext=\"$shrext_cmds\" 12020b661123Smrg 1203880c7e28Smrg # Only execute mode is allowed to have -dlopen flags. 1204880c7e28Smrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 1205880c7e28Smrg func_error "unrecognized option \`-dlopen'" 1206880c7e28Smrg $ECHO "$help" 1>&2 1207880c7e28Smrg exit $EXIT_FAILURE 1208880c7e28Smrg fi 1209bdcaa8d0Smrg 1210880c7e28Smrg # Change the help message to a mode-specific one. 1211880c7e28Smrg generic_help="$help" 1212880c7e28Smrg help="Try \`$progname --help --mode=$opt_mode' for more information." 1213880c7e28Smrg } 12140b661123Smrg 12150b661123Smrg 1216880c7e28Smrg # Bail if the options were screwed 1217880c7e28Smrg $exit_cmd $EXIT_FAILURE 1218880c7e28Smrg} 12190b661123Smrg 12200b661123Smrg 1221bdcaa8d0Smrg 1222bdcaa8d0Smrg 1223880c7e28Smrg## ----------- ## 1224880c7e28Smrg## Main. ## 1225880c7e28Smrg## ----------- ## 1226bdcaa8d0Smrg 12270b661123Smrg# func_lalib_p file 12280b661123Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 12290b661123Smrg# This function is only a basic sanity check; it will hardly flush out 12300b661123Smrg# determined imposters. 12310b661123Smrgfunc_lalib_p () 12320b661123Smrg{ 12330b661123Smrg test -f "$1" && 12340b661123Smrg $SED -e 4q "$1" 2>/dev/null \ 12350b661123Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 12360b661123Smrg} 1237bdcaa8d0Smrg 12380b661123Smrg# func_lalib_unsafe_p file 12390b661123Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 12400b661123Smrg# This function implements the same check as func_lalib_p without 12410b661123Smrg# resorting to external programs. To this end, it redirects stdin and 12420b661123Smrg# closes it afterwards, without saving the original file descriptor. 12430b661123Smrg# As a safety measure, use it only where a negative result would be 12440b661123Smrg# fatal anyway. Works if `file' does not exist. 12450b661123Smrgfunc_lalib_unsafe_p () 12460b661123Smrg{ 12470b661123Smrg lalib_p=no 12480b661123Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 12490b661123Smrg for lalib_p_l in 1 2 3 4 12500b661123Smrg do 12510b661123Smrg read lalib_p_line 12520b661123Smrg case "$lalib_p_line" in 12530b661123Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 12540b661123Smrg esac 12550b661123Smrg done 12560b661123Smrg exec 0<&5 5<&- 12570b661123Smrg fi 12580b661123Smrg test "$lalib_p" = yes 12590b661123Smrg} 1260bdcaa8d0Smrg 12610b661123Smrg# func_ltwrapper_script_p file 12620b661123Smrg# True iff FILE is a libtool wrapper script 12630b661123Smrg# This function is only a basic sanity check; it will hardly flush out 12640b661123Smrg# determined imposters. 12650b661123Smrgfunc_ltwrapper_script_p () 12660b661123Smrg{ 12670b661123Smrg func_lalib_p "$1" 12680b661123Smrg} 1269bdcaa8d0Smrg 12700b661123Smrg# func_ltwrapper_executable_p file 12710b661123Smrg# True iff FILE is a libtool wrapper executable 12720b661123Smrg# This function is only a basic sanity check; it will hardly flush out 12730b661123Smrg# determined imposters. 12740b661123Smrgfunc_ltwrapper_executable_p () 12750b661123Smrg{ 12760b661123Smrg func_ltwrapper_exec_suffix= 12770b661123Smrg case $1 in 12780b661123Smrg *.exe) ;; 12790b661123Smrg *) func_ltwrapper_exec_suffix=.exe ;; 12800b661123Smrg esac 12810b661123Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 12820b661123Smrg} 128372313efbSmrg 12840b661123Smrg# func_ltwrapper_scriptname file 12850b661123Smrg# Assumes file is an ltwrapper_executable 12860b661123Smrg# uses $file to determine the appropriate filename for a 12870b661123Smrg# temporary ltwrapper_script. 12880b661123Smrgfunc_ltwrapper_scriptname () 12890b661123Smrg{ 1290880c7e28Smrg func_dirname_and_basename "$1" "" "." 1291880c7e28Smrg func_stripname '' '.exe' "$func_basename_result" 1292880c7e28Smrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 12930b661123Smrg} 12940b661123Smrg 12950b661123Smrg# func_ltwrapper_p file 12960b661123Smrg# True iff FILE is a libtool wrapper script or wrapper executable 12970b661123Smrg# This function is only a basic sanity check; it will hardly flush out 12980b661123Smrg# determined imposters. 12990b661123Smrgfunc_ltwrapper_p () 13000b661123Smrg{ 13010b661123Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 13020b661123Smrg} 13030b661123Smrg 13040b661123Smrg 13050b661123Smrg# func_execute_cmds commands fail_cmd 13060b661123Smrg# Execute tilde-delimited COMMANDS. 13070b661123Smrg# If FAIL_CMD is given, eval that upon failure. 13080b661123Smrg# FAIL_CMD may read-access the current command in variable CMD! 13090b661123Smrgfunc_execute_cmds () 13100b661123Smrg{ 13110b661123Smrg $opt_debug 13120b661123Smrg save_ifs=$IFS; IFS='~' 13130b661123Smrg for cmd in $1; do 13140b661123Smrg IFS=$save_ifs 13150b661123Smrg eval cmd=\"$cmd\" 13160b661123Smrg func_show_eval "$cmd" "${2-:}" 13170b661123Smrg done 13180b661123Smrg IFS=$save_ifs 13190b661123Smrg} 13200b661123Smrg 13210b661123Smrg 13220b661123Smrg# func_source file 13230b661123Smrg# Source FILE, adding directory component if necessary. 13240b661123Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 13250b661123Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 13260b661123Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 13270b661123Smrg# `FILE.' does not work on cygwin managed mounts. 13280b661123Smrgfunc_source () 13290b661123Smrg{ 13300b661123Smrg $opt_debug 13310b661123Smrg case $1 in 13320b661123Smrg */* | *\\*) . "$1" ;; 13330b661123Smrg *) . "./$1" ;; 13340b661123Smrg esac 13350b661123Smrg} 13360b661123Smrg 13370b661123Smrg 1338880c7e28Smrg# func_resolve_sysroot PATH 1339880c7e28Smrg# Replace a leading = in PATH with a sysroot. Store the result into 1340880c7e28Smrg# func_resolve_sysroot_result 1341880c7e28Smrgfunc_resolve_sysroot () 1342880c7e28Smrg{ 1343880c7e28Smrg func_resolve_sysroot_result=$1 1344880c7e28Smrg case $func_resolve_sysroot_result in 1345880c7e28Smrg =*) 1346880c7e28Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 1347880c7e28Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 1348880c7e28Smrg ;; 1349880c7e28Smrg esac 1350880c7e28Smrg} 1351880c7e28Smrg 1352880c7e28Smrg# func_replace_sysroot PATH 1353880c7e28Smrg# If PATH begins with the sysroot, replace it with = and 1354880c7e28Smrg# store the result into func_replace_sysroot_result. 1355880c7e28Smrgfunc_replace_sysroot () 1356880c7e28Smrg{ 1357880c7e28Smrg case "$lt_sysroot:$1" in 1358880c7e28Smrg ?*:"$lt_sysroot"*) 1359880c7e28Smrg func_stripname "$lt_sysroot" '' "$1" 1360880c7e28Smrg func_replace_sysroot_result="=$func_stripname_result" 1361880c7e28Smrg ;; 1362880c7e28Smrg *) 1363880c7e28Smrg # Including no sysroot. 1364880c7e28Smrg func_replace_sysroot_result=$1 1365880c7e28Smrg ;; 1366880c7e28Smrg esac 1367880c7e28Smrg} 1368880c7e28Smrg 13690b661123Smrg# func_infer_tag arg 13700b661123Smrg# Infer tagged configuration to use if any are available and 13710b661123Smrg# if one wasn't chosen via the "--tag" command line option. 13720b661123Smrg# Only attempt this if the compiler in the base compile 13730b661123Smrg# command doesn't match the default compiler. 13740b661123Smrg# arg is usually of the form 'gcc ...' 13750b661123Smrgfunc_infer_tag () 13760b661123Smrg{ 13770b661123Smrg $opt_debug 13780b661123Smrg if test -n "$available_tags" && test -z "$tagname"; then 13790b661123Smrg CC_quoted= 13800b661123Smrg for arg in $CC; do 1381880c7e28Smrg func_append_quoted CC_quoted "$arg" 13820b661123Smrg done 1383880c7e28Smrg CC_expanded=`func_echo_all $CC` 1384880c7e28Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 13850b661123Smrg case $@ in 13860b661123Smrg # Blanks in the command may have been stripped by the calling shell, 13870b661123Smrg # but not from the CC environment variable when configure was run. 1388880c7e28Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1389880c7e28Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 13900b661123Smrg # Blanks at the start of $base_compile will cause this to fail 13910b661123Smrg # if we don't check for them as well. 13920b661123Smrg *) 13930b661123Smrg for z in $available_tags; do 13940b661123Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 13950b661123Smrg # Evaluate the configuration. 13960b661123Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 13970b661123Smrg CC_quoted= 13980b661123Smrg for arg in $CC; do 13990b661123Smrg # Double-quote args containing other shell metacharacters. 1400880c7e28Smrg func_append_quoted CC_quoted "$arg" 14010b661123Smrg done 1402880c7e28Smrg CC_expanded=`func_echo_all $CC` 1403880c7e28Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 14040b661123Smrg case "$@ " in 1405880c7e28Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1406880c7e28Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 14070b661123Smrg # The compiler in the base compile command matches 14080b661123Smrg # the one in the tagged configuration. 14090b661123Smrg # Assume this is the tagged configuration we want. 14100b661123Smrg tagname=$z 14110b661123Smrg break 14120b661123Smrg ;; 14130b661123Smrg esac 14140b661123Smrg fi 14150b661123Smrg done 14160b661123Smrg # If $tagname still isn't set, then no tagged configuration 14170b661123Smrg # was found and let the user know that the "--tag" command 14180b661123Smrg # line option must be used. 14190b661123Smrg if test -z "$tagname"; then 14200b661123Smrg func_echo "unable to infer tagged configuration" 14210b661123Smrg func_fatal_error "specify a tag with \`--tag'" 14220b661123Smrg# else 14230b661123Smrg# func_verbose "using $tagname tagged configuration" 14240b661123Smrg fi 14250b661123Smrg ;; 14260b661123Smrg esac 14270b661123Smrg fi 14280b661123Smrg} 14290b661123Smrg 14300b661123Smrg 14310b661123Smrg 14320b661123Smrg# func_write_libtool_object output_name pic_name nonpic_name 14330b661123Smrg# Create a libtool object file (analogous to a ".la" file), 14340b661123Smrg# but don't create it if we're doing a dry run. 14350b661123Smrgfunc_write_libtool_object () 14360b661123Smrg{ 14370b661123Smrg write_libobj=${1} 14380b661123Smrg if test "$build_libtool_libs" = yes; then 14390b661123Smrg write_lobj=\'${2}\' 14400b661123Smrg else 14410b661123Smrg write_lobj=none 14420b661123Smrg fi 14430b661123Smrg 14440b661123Smrg if test "$build_old_libs" = yes; then 14450b661123Smrg write_oldobj=\'${3}\' 14460b661123Smrg else 14470b661123Smrg write_oldobj=none 14480b661123Smrg fi 14490b661123Smrg 14500b661123Smrg $opt_dry_run || { 14510b661123Smrg cat >${write_libobj}T <<EOF 14520b661123Smrg# $write_libobj - a libtool object file 14530b661123Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 14540b661123Smrg# 14550b661123Smrg# Please DO NOT delete this file! 14560b661123Smrg# It is necessary for linking the library. 14570b661123Smrg 14580b661123Smrg# Name of the PIC object. 14590b661123Smrgpic_object=$write_lobj 14600b661123Smrg 14610b661123Smrg# Name of the non-PIC object 14620b661123Smrgnon_pic_object=$write_oldobj 14630b661123Smrg 14640b661123SmrgEOF 14650b661123Smrg $MV "${write_libobj}T" "${write_libobj}" 14660b661123Smrg } 14670b661123Smrg} 14680b661123Smrg 1469880c7e28Smrg 1470880c7e28Smrg################################################## 1471880c7e28Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 1472880c7e28Smrg################################################## 1473880c7e28Smrg 1474880c7e28Smrg# func_convert_core_file_wine_to_w32 ARG 1475880c7e28Smrg# Helper function used by file name conversion functions when $build is *nix, 1476880c7e28Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 1477880c7e28Smrg# correctly configured wine environment available, with the winepath program 1478880c7e28Smrg# in $build's $PATH. 1479880c7e28Smrg# 1480880c7e28Smrg# ARG is the $build file name to be converted to w32 format. 1481880c7e28Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 1482880c7e28Smrg# be empty on error (or when ARG is empty) 1483880c7e28Smrgfunc_convert_core_file_wine_to_w32 () 1484880c7e28Smrg{ 1485880c7e28Smrg $opt_debug 1486880c7e28Smrg func_convert_core_file_wine_to_w32_result="$1" 1487880c7e28Smrg if test -n "$1"; then 1488880c7e28Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 1489880c7e28Smrg # are forced to check the contents of stdout. On the other hand, if the 1490880c7e28Smrg # command is not found, the shell will set an exit code of 127 and print 1491880c7e28Smrg # *an error message* to stdout. So we must check for both error code of 1492880c7e28Smrg # zero AND non-empty stdout, which explains the odd construction: 1493880c7e28Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 1494880c7e28Smrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 1495880c7e28Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 1496880c7e28Smrg $SED -e "$lt_sed_naive_backslashify"` 1497880c7e28Smrg else 1498880c7e28Smrg func_convert_core_file_wine_to_w32_result= 1499880c7e28Smrg fi 1500880c7e28Smrg fi 1501880c7e28Smrg} 1502880c7e28Smrg# end: func_convert_core_file_wine_to_w32 1503880c7e28Smrg 1504880c7e28Smrg 1505880c7e28Smrg# func_convert_core_path_wine_to_w32 ARG 1506880c7e28Smrg# Helper function used by path conversion functions when $build is *nix, and 1507880c7e28Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 1508880c7e28Smrg# configured wine environment available, with the winepath program in $build's 1509880c7e28Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 1510880c7e28Smrg# 1511880c7e28Smrg# ARG is path to be converted from $build format to win32. 1512880c7e28Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 1513880c7e28Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 1514880c7e28Smrg# are convertible, then the result may be empty. 1515880c7e28Smrgfunc_convert_core_path_wine_to_w32 () 1516880c7e28Smrg{ 1517880c7e28Smrg $opt_debug 1518880c7e28Smrg # unfortunately, winepath doesn't convert paths, only file names 1519880c7e28Smrg func_convert_core_path_wine_to_w32_result="" 1520880c7e28Smrg if test -n "$1"; then 1521880c7e28Smrg oldIFS=$IFS 1522880c7e28Smrg IFS=: 1523880c7e28Smrg for func_convert_core_path_wine_to_w32_f in $1; do 1524880c7e28Smrg IFS=$oldIFS 1525880c7e28Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 1526880c7e28Smrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 1527880c7e28Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 1528880c7e28Smrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 1529880c7e28Smrg else 1530880c7e28Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 1531880c7e28Smrg fi 1532880c7e28Smrg fi 1533880c7e28Smrg done 1534880c7e28Smrg IFS=$oldIFS 1535880c7e28Smrg fi 1536880c7e28Smrg} 1537880c7e28Smrg# end: func_convert_core_path_wine_to_w32 1538880c7e28Smrg 1539880c7e28Smrg 1540880c7e28Smrg# func_cygpath ARGS... 1541880c7e28Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 1542880c7e28Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 1543880c7e28Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 1544880c7e28Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 1545880c7e28Smrg# file name or path is assumed to be in w32 format, as previously converted 1546880c7e28Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 1547880c7e28Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 1548880c7e28Smrg# Cygwin format). Returns an empty string on error. 1549880c7e28Smrg# 1550880c7e28Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 1551880c7e28Smrg# be converted. 1552880c7e28Smrg# 1553880c7e28Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 1554880c7e28Smrg# environment variable; do not put it in $PATH. 1555880c7e28Smrgfunc_cygpath () 1556880c7e28Smrg{ 1557880c7e28Smrg $opt_debug 1558880c7e28Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 1559880c7e28Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 1560880c7e28Smrg if test "$?" -ne 0; then 1561880c7e28Smrg # on failure, ensure result is empty 1562880c7e28Smrg func_cygpath_result= 1563880c7e28Smrg fi 1564880c7e28Smrg else 1565880c7e28Smrg func_cygpath_result= 1566880c7e28Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 1567880c7e28Smrg fi 1568880c7e28Smrg} 1569880c7e28Smrg#end: func_cygpath 1570880c7e28Smrg 1571880c7e28Smrg 1572880c7e28Smrg# func_convert_core_msys_to_w32 ARG 1573880c7e28Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 1574880c7e28Smrg# result in func_convert_core_msys_to_w32_result. 1575880c7e28Smrgfunc_convert_core_msys_to_w32 () 1576880c7e28Smrg{ 1577880c7e28Smrg $opt_debug 1578880c7e28Smrg # awkward: cmd appends spaces to result 1579880c7e28Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 1580880c7e28Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 1581880c7e28Smrg} 1582880c7e28Smrg#end: func_convert_core_msys_to_w32 1583880c7e28Smrg 1584880c7e28Smrg 1585880c7e28Smrg# func_convert_file_check ARG1 ARG2 1586880c7e28Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 1587880c7e28Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 1588880c7e28Smrg# func_to_host_file_result to ARG1). 1589880c7e28Smrgfunc_convert_file_check () 1590880c7e28Smrg{ 1591880c7e28Smrg $opt_debug 1592880c7e28Smrg if test -z "$2" && test -n "$1" ; then 1593880c7e28Smrg func_error "Could not determine host file name corresponding to" 1594880c7e28Smrg func_error " \`$1'" 1595880c7e28Smrg func_error "Continuing, but uninstalled executables may not work." 1596880c7e28Smrg # Fallback: 1597880c7e28Smrg func_to_host_file_result="$1" 1598880c7e28Smrg fi 1599880c7e28Smrg} 1600880c7e28Smrg# end func_convert_file_check 1601880c7e28Smrg 1602880c7e28Smrg 1603880c7e28Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 1604880c7e28Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 1605880c7e28Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 1606880c7e28Smrg# func_to_host_file_result to a simplistic fallback value (see below). 1607880c7e28Smrgfunc_convert_path_check () 1608880c7e28Smrg{ 1609880c7e28Smrg $opt_debug 1610880c7e28Smrg if test -z "$4" && test -n "$3"; then 1611880c7e28Smrg func_error "Could not determine the host path corresponding to" 1612880c7e28Smrg func_error " \`$3'" 1613880c7e28Smrg func_error "Continuing, but uninstalled executables may not work." 1614880c7e28Smrg # Fallback. This is a deliberately simplistic "conversion" and 1615880c7e28Smrg # should not be "improved". See libtool.info. 1616880c7e28Smrg if test "x$1" != "x$2"; then 1617880c7e28Smrg lt_replace_pathsep_chars="s|$1|$2|g" 1618880c7e28Smrg func_to_host_path_result=`echo "$3" | 1619880c7e28Smrg $SED -e "$lt_replace_pathsep_chars"` 1620880c7e28Smrg else 1621880c7e28Smrg func_to_host_path_result="$3" 1622880c7e28Smrg fi 1623880c7e28Smrg fi 1624880c7e28Smrg} 1625880c7e28Smrg# end func_convert_path_check 1626880c7e28Smrg 1627880c7e28Smrg 1628880c7e28Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 1629880c7e28Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 1630880c7e28Smrg# and appending REPL if ORIG matches BACKPAT. 1631880c7e28Smrgfunc_convert_path_front_back_pathsep () 1632880c7e28Smrg{ 1633880c7e28Smrg $opt_debug 1634880c7e28Smrg case $4 in 1635880c7e28Smrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 1636880c7e28Smrg ;; 1637880c7e28Smrg esac 1638880c7e28Smrg case $4 in 1639880c7e28Smrg $2 ) func_append func_to_host_path_result "$3" 1640880c7e28Smrg ;; 1641880c7e28Smrg esac 1642880c7e28Smrg} 1643880c7e28Smrg# end func_convert_path_front_back_pathsep 1644880c7e28Smrg 1645880c7e28Smrg 1646880c7e28Smrg################################################## 1647880c7e28Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 1648880c7e28Smrg################################################## 1649880c7e28Smrg# invoked via `$to_host_file_cmd ARG' 1650880c7e28Smrg# 1651880c7e28Smrg# In each case, ARG is the path to be converted from $build to $host format. 1652880c7e28Smrg# Result will be available in $func_to_host_file_result. 1653880c7e28Smrg 1654880c7e28Smrg 1655880c7e28Smrg# func_to_host_file ARG 1656880c7e28Smrg# Converts the file name ARG from $build format to $host format. Return result 1657880c7e28Smrg# in func_to_host_file_result. 1658880c7e28Smrgfunc_to_host_file () 1659880c7e28Smrg{ 1660880c7e28Smrg $opt_debug 1661880c7e28Smrg $to_host_file_cmd "$1" 1662880c7e28Smrg} 1663880c7e28Smrg# end func_to_host_file 1664880c7e28Smrg 1665880c7e28Smrg 1666880c7e28Smrg# func_to_tool_file ARG LAZY 1667880c7e28Smrg# converts the file name ARG from $build format to toolchain format. Return 1668880c7e28Smrg# result in func_to_tool_file_result. If the conversion in use is listed 1669880c7e28Smrg# in (the comma separated) LAZY, no conversion takes place. 1670880c7e28Smrgfunc_to_tool_file () 1671880c7e28Smrg{ 1672880c7e28Smrg $opt_debug 1673880c7e28Smrg case ,$2, in 1674880c7e28Smrg *,"$to_tool_file_cmd",*) 1675880c7e28Smrg func_to_tool_file_result=$1 1676880c7e28Smrg ;; 1677880c7e28Smrg *) 1678880c7e28Smrg $to_tool_file_cmd "$1" 1679880c7e28Smrg func_to_tool_file_result=$func_to_host_file_result 1680880c7e28Smrg ;; 1681880c7e28Smrg esac 1682880c7e28Smrg} 1683880c7e28Smrg# end func_to_tool_file 1684880c7e28Smrg 1685880c7e28Smrg 1686880c7e28Smrg# func_convert_file_noop ARG 1687880c7e28Smrg# Copy ARG to func_to_host_file_result. 1688880c7e28Smrgfunc_convert_file_noop () 1689880c7e28Smrg{ 1690880c7e28Smrg func_to_host_file_result="$1" 1691880c7e28Smrg} 1692880c7e28Smrg# end func_convert_file_noop 1693880c7e28Smrg 1694880c7e28Smrg 1695880c7e28Smrg# func_convert_file_msys_to_w32 ARG 1696880c7e28Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 1697880c7e28Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 1698880c7e28Smrg# func_to_host_file_result. 1699880c7e28Smrgfunc_convert_file_msys_to_w32 () 1700880c7e28Smrg{ 1701880c7e28Smrg $opt_debug 1702880c7e28Smrg func_to_host_file_result="$1" 1703880c7e28Smrg if test -n "$1"; then 1704880c7e28Smrg func_convert_core_msys_to_w32 "$1" 1705880c7e28Smrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 1706880c7e28Smrg fi 1707880c7e28Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1708880c7e28Smrg} 1709880c7e28Smrg# end func_convert_file_msys_to_w32 1710880c7e28Smrg 1711880c7e28Smrg 1712880c7e28Smrg# func_convert_file_cygwin_to_w32 ARG 1713880c7e28Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 1714880c7e28Smrg# func_to_host_file_result. 1715880c7e28Smrgfunc_convert_file_cygwin_to_w32 () 1716880c7e28Smrg{ 1717880c7e28Smrg $opt_debug 1718880c7e28Smrg func_to_host_file_result="$1" 1719880c7e28Smrg if test -n "$1"; then 1720880c7e28Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 1721880c7e28Smrg # LT_CYGPATH in this case. 1722880c7e28Smrg func_to_host_file_result=`cygpath -m "$1"` 1723880c7e28Smrg fi 1724880c7e28Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1725880c7e28Smrg} 1726880c7e28Smrg# end func_convert_file_cygwin_to_w32 1727880c7e28Smrg 1728880c7e28Smrg 1729880c7e28Smrg# func_convert_file_nix_to_w32 ARG 1730880c7e28Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 1731880c7e28Smrg# and a working winepath. Returns result in func_to_host_file_result. 1732880c7e28Smrgfunc_convert_file_nix_to_w32 () 1733880c7e28Smrg{ 1734880c7e28Smrg $opt_debug 1735880c7e28Smrg func_to_host_file_result="$1" 1736880c7e28Smrg if test -n "$1"; then 1737880c7e28Smrg func_convert_core_file_wine_to_w32 "$1" 1738880c7e28Smrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 1739880c7e28Smrg fi 1740880c7e28Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1741880c7e28Smrg} 1742880c7e28Smrg# end func_convert_file_nix_to_w32 1743880c7e28Smrg 1744880c7e28Smrg 1745880c7e28Smrg# func_convert_file_msys_to_cygwin ARG 1746880c7e28Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1747880c7e28Smrg# Returns result in func_to_host_file_result. 1748880c7e28Smrgfunc_convert_file_msys_to_cygwin () 1749880c7e28Smrg{ 1750880c7e28Smrg $opt_debug 1751880c7e28Smrg func_to_host_file_result="$1" 1752880c7e28Smrg if test -n "$1"; then 1753880c7e28Smrg func_convert_core_msys_to_w32 "$1" 1754880c7e28Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 1755880c7e28Smrg func_to_host_file_result="$func_cygpath_result" 1756880c7e28Smrg fi 1757880c7e28Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1758880c7e28Smrg} 1759880c7e28Smrg# end func_convert_file_msys_to_cygwin 1760880c7e28Smrg 1761880c7e28Smrg 1762880c7e28Smrg# func_convert_file_nix_to_cygwin ARG 1763880c7e28Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 1764880c7e28Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 1765880c7e28Smrg# in func_to_host_file_result. 1766880c7e28Smrgfunc_convert_file_nix_to_cygwin () 1767880c7e28Smrg{ 1768880c7e28Smrg $opt_debug 1769880c7e28Smrg func_to_host_file_result="$1" 1770880c7e28Smrg if test -n "$1"; then 1771880c7e28Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 1772880c7e28Smrg func_convert_core_file_wine_to_w32 "$1" 1773880c7e28Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 1774880c7e28Smrg func_to_host_file_result="$func_cygpath_result" 1775880c7e28Smrg fi 1776880c7e28Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1777880c7e28Smrg} 1778880c7e28Smrg# end func_convert_file_nix_to_cygwin 1779880c7e28Smrg 1780880c7e28Smrg 1781880c7e28Smrg############################################# 1782880c7e28Smrg# $build to $host PATH CONVERSION FUNCTIONS # 1783880c7e28Smrg############################################# 1784880c7e28Smrg# invoked via `$to_host_path_cmd ARG' 1785880c7e28Smrg# 1786880c7e28Smrg# In each case, ARG is the path to be converted from $build to $host format. 1787880c7e28Smrg# The result will be available in $func_to_host_path_result. 1788880c7e28Smrg# 1789880c7e28Smrg# Path separators are also converted from $build format to $host format. If 1790880c7e28Smrg# ARG begins or ends with a path separator character, it is preserved (but 1791880c7e28Smrg# converted to $host format) on output. 1792880c7e28Smrg# 1793880c7e28Smrg# All path conversion functions are named using the following convention: 1794880c7e28Smrg# file name conversion function : func_convert_file_X_to_Y () 1795880c7e28Smrg# path conversion function : func_convert_path_X_to_Y () 1796880c7e28Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 1797880c7e28Smrg# same. If conversion functions are added for new $build/$host combinations, 1798880c7e28Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 1799880c7e28Smrg# will break. 1800880c7e28Smrg 1801880c7e28Smrg 1802880c7e28Smrg# func_init_to_host_path_cmd 1803880c7e28Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 1804880c7e28Smrg# appropriate value, based on the value of $to_host_file_cmd. 1805880c7e28Smrgto_host_path_cmd= 1806880c7e28Smrgfunc_init_to_host_path_cmd () 1807880c7e28Smrg{ 1808880c7e28Smrg $opt_debug 1809880c7e28Smrg if test -z "$to_host_path_cmd"; then 1810880c7e28Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 1811880c7e28Smrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 1812880c7e28Smrg fi 1813880c7e28Smrg} 1814880c7e28Smrg 1815880c7e28Smrg 1816880c7e28Smrg# func_to_host_path ARG 1817880c7e28Smrg# Converts the path ARG from $build format to $host format. Return result 1818880c7e28Smrg# in func_to_host_path_result. 1819880c7e28Smrgfunc_to_host_path () 1820880c7e28Smrg{ 1821880c7e28Smrg $opt_debug 1822880c7e28Smrg func_init_to_host_path_cmd 1823880c7e28Smrg $to_host_path_cmd "$1" 1824880c7e28Smrg} 1825880c7e28Smrg# end func_to_host_path 1826880c7e28Smrg 1827880c7e28Smrg 1828880c7e28Smrg# func_convert_path_noop ARG 1829880c7e28Smrg# Copy ARG to func_to_host_path_result. 1830880c7e28Smrgfunc_convert_path_noop () 1831880c7e28Smrg{ 1832880c7e28Smrg func_to_host_path_result="$1" 1833880c7e28Smrg} 1834880c7e28Smrg# end func_convert_path_noop 1835880c7e28Smrg 1836880c7e28Smrg 1837880c7e28Smrg# func_convert_path_msys_to_w32 ARG 1838880c7e28Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 1839880c7e28Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 1840880c7e28Smrg# func_to_host_path_result. 1841880c7e28Smrgfunc_convert_path_msys_to_w32 () 1842880c7e28Smrg{ 1843880c7e28Smrg $opt_debug 1844880c7e28Smrg func_to_host_path_result="$1" 1845880c7e28Smrg if test -n "$1"; then 1846880c7e28Smrg # Remove leading and trailing path separator characters from ARG. MSYS 1847880c7e28Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 1848880c7e28Smrg # and winepath ignores them completely. 1849880c7e28Smrg func_stripname : : "$1" 1850880c7e28Smrg func_to_host_path_tmp1=$func_stripname_result 1851880c7e28Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1852880c7e28Smrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 1853880c7e28Smrg func_convert_path_check : ";" \ 1854880c7e28Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1855880c7e28Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1856880c7e28Smrg fi 1857880c7e28Smrg} 1858880c7e28Smrg# end func_convert_path_msys_to_w32 1859880c7e28Smrg 1860880c7e28Smrg 1861880c7e28Smrg# func_convert_path_cygwin_to_w32 ARG 1862880c7e28Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 1863880c7e28Smrg# func_to_host_file_result. 1864880c7e28Smrgfunc_convert_path_cygwin_to_w32 () 1865880c7e28Smrg{ 1866880c7e28Smrg $opt_debug 1867880c7e28Smrg func_to_host_path_result="$1" 1868880c7e28Smrg if test -n "$1"; then 1869880c7e28Smrg # See func_convert_path_msys_to_w32: 1870880c7e28Smrg func_stripname : : "$1" 1871880c7e28Smrg func_to_host_path_tmp1=$func_stripname_result 1872880c7e28Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 1873880c7e28Smrg func_convert_path_check : ";" \ 1874880c7e28Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1875880c7e28Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1876880c7e28Smrg fi 1877880c7e28Smrg} 1878880c7e28Smrg# end func_convert_path_cygwin_to_w32 1879880c7e28Smrg 1880880c7e28Smrg 1881880c7e28Smrg# func_convert_path_nix_to_w32 ARG 1882880c7e28Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 1883880c7e28Smrg# a working winepath. Returns result in func_to_host_file_result. 1884880c7e28Smrgfunc_convert_path_nix_to_w32 () 1885880c7e28Smrg{ 1886880c7e28Smrg $opt_debug 1887880c7e28Smrg func_to_host_path_result="$1" 1888880c7e28Smrg if test -n "$1"; then 1889880c7e28Smrg # See func_convert_path_msys_to_w32: 1890880c7e28Smrg func_stripname : : "$1" 1891880c7e28Smrg func_to_host_path_tmp1=$func_stripname_result 1892880c7e28Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1893880c7e28Smrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 1894880c7e28Smrg func_convert_path_check : ";" \ 1895880c7e28Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1896880c7e28Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1897880c7e28Smrg fi 1898880c7e28Smrg} 1899880c7e28Smrg# end func_convert_path_nix_to_w32 1900880c7e28Smrg 1901880c7e28Smrg 1902880c7e28Smrg# func_convert_path_msys_to_cygwin ARG 1903880c7e28Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1904880c7e28Smrg# Returns result in func_to_host_file_result. 1905880c7e28Smrgfunc_convert_path_msys_to_cygwin () 1906880c7e28Smrg{ 1907880c7e28Smrg $opt_debug 1908880c7e28Smrg func_to_host_path_result="$1" 1909880c7e28Smrg if test -n "$1"; then 1910880c7e28Smrg # See func_convert_path_msys_to_w32: 1911880c7e28Smrg func_stripname : : "$1" 1912880c7e28Smrg func_to_host_path_tmp1=$func_stripname_result 1913880c7e28Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1914880c7e28Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 1915880c7e28Smrg func_to_host_path_result="$func_cygpath_result" 1916880c7e28Smrg func_convert_path_check : : \ 1917880c7e28Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1918880c7e28Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1919880c7e28Smrg fi 1920880c7e28Smrg} 1921880c7e28Smrg# end func_convert_path_msys_to_cygwin 1922880c7e28Smrg 1923880c7e28Smrg 1924880c7e28Smrg# func_convert_path_nix_to_cygwin ARG 1925880c7e28Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 1926880c7e28Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 1927880c7e28Smrg# func_to_host_file_result. 1928880c7e28Smrgfunc_convert_path_nix_to_cygwin () 1929880c7e28Smrg{ 1930880c7e28Smrg $opt_debug 1931880c7e28Smrg func_to_host_path_result="$1" 1932880c7e28Smrg if test -n "$1"; then 1933880c7e28Smrg # Remove leading and trailing path separator characters from 1934880c7e28Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 1935880c7e28Smrg # into '.;' and ';.', and winepath ignores them completely. 1936880c7e28Smrg func_stripname : : "$1" 1937880c7e28Smrg func_to_host_path_tmp1=$func_stripname_result 1938880c7e28Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1939880c7e28Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 1940880c7e28Smrg func_to_host_path_result="$func_cygpath_result" 1941880c7e28Smrg func_convert_path_check : : \ 1942880c7e28Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1943880c7e28Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1944880c7e28Smrg fi 1945880c7e28Smrg} 1946880c7e28Smrg# end func_convert_path_nix_to_cygwin 1947880c7e28Smrg 1948880c7e28Smrg 19490b661123Smrg# func_mode_compile arg... 19500b661123Smrgfunc_mode_compile () 19510b661123Smrg{ 19520b661123Smrg $opt_debug 19530b661123Smrg # Get the compilation command and the source file. 19540b661123Smrg base_compile= 19550b661123Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 19560b661123Smrg suppress_opt=yes 19570b661123Smrg suppress_output= 19580b661123Smrg arg_mode=normal 19590b661123Smrg libobj= 19600b661123Smrg later= 19610b661123Smrg pie_flag= 19620b661123Smrg 19630b661123Smrg for arg 19640b661123Smrg do 19650b661123Smrg case $arg_mode in 19660b661123Smrg arg ) 19670b661123Smrg # do not "continue". Instead, add this to base_compile 19680b661123Smrg lastarg="$arg" 19690b661123Smrg arg_mode=normal 19700b661123Smrg ;; 19710b661123Smrg 19720b661123Smrg target ) 19730b661123Smrg libobj="$arg" 19740b661123Smrg arg_mode=normal 19750b661123Smrg continue 19760b661123Smrg ;; 19770b661123Smrg 19780b661123Smrg normal ) 19790b661123Smrg # Accept any command-line options. 19800b661123Smrg case $arg in 19810b661123Smrg -o) 19820b661123Smrg test -n "$libobj" && \ 19830b661123Smrg func_fatal_error "you cannot specify \`-o' more than once" 19840b661123Smrg arg_mode=target 19850b661123Smrg continue 19860b661123Smrg ;; 19870b661123Smrg 19880b661123Smrg -pie | -fpie | -fPIE) 1989880c7e28Smrg func_append pie_flag " $arg" 19900b661123Smrg continue 19910b661123Smrg ;; 19920b661123Smrg 19930b661123Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 1994880c7e28Smrg func_append later " $arg" 19950b661123Smrg continue 19960b661123Smrg ;; 19970b661123Smrg 19980b661123Smrg -no-suppress) 199972313efbSmrg suppress_opt=no 200072313efbSmrg continue 200172313efbSmrg ;; 200272313efbSmrg 200372313efbSmrg -Xcompiler) 200472313efbSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 200572313efbSmrg continue # The current "srcfile" will either be retained or 200672313efbSmrg ;; # replaced later. I would guess that would be a bug. 200772313efbSmrg 200872313efbSmrg -Wc,*) 20090b661123Smrg func_stripname '-Wc,' '' "$arg" 20100b661123Smrg args=$func_stripname_result 201172313efbSmrg lastarg= 201272313efbSmrg save_ifs="$IFS"; IFS=',' 20130b661123Smrg for arg in $args; do 201472313efbSmrg IFS="$save_ifs" 2015880c7e28Smrg func_append_quoted lastarg "$arg" 2016bdcaa8d0Smrg done 2017bdcaa8d0Smrg IFS="$save_ifs" 20180b661123Smrg func_stripname ' ' '' "$lastarg" 20190b661123Smrg lastarg=$func_stripname_result 2020bdcaa8d0Smrg 2021bdcaa8d0Smrg # Add the arguments to base_compile. 2022880c7e28Smrg func_append base_compile " $lastarg" 2023bdcaa8d0Smrg continue 2024bdcaa8d0Smrg ;; 2025bdcaa8d0Smrg 20260b661123Smrg *) 2027bdcaa8d0Smrg # Accept the current argument as the source file. 2028bdcaa8d0Smrg # The previous "srcfile" becomes the current argument. 2029bdcaa8d0Smrg # 2030bdcaa8d0Smrg lastarg="$srcfile" 2031bdcaa8d0Smrg srcfile="$arg" 2032bdcaa8d0Smrg ;; 2033bdcaa8d0Smrg esac # case $arg 2034bdcaa8d0Smrg ;; 2035bdcaa8d0Smrg esac # case $arg_mode 2036bdcaa8d0Smrg 2037bdcaa8d0Smrg # Aesthetically quote the previous argument. 2038880c7e28Smrg func_append_quoted base_compile "$lastarg" 2039bdcaa8d0Smrg done # for arg 2040bdcaa8d0Smrg 2041bdcaa8d0Smrg case $arg_mode in 2042bdcaa8d0Smrg arg) 20430b661123Smrg func_fatal_error "you must specify an argument for -Xcompile" 2044bdcaa8d0Smrg ;; 2045bdcaa8d0Smrg target) 20460b661123Smrg func_fatal_error "you must specify a target with \`-o'" 2047bdcaa8d0Smrg ;; 2048bdcaa8d0Smrg *) 2049bdcaa8d0Smrg # Get the name of the library object. 20500b661123Smrg test -z "$libobj" && { 20510b661123Smrg func_basename "$srcfile" 20520b661123Smrg libobj="$func_basename_result" 20530b661123Smrg } 2054bdcaa8d0Smrg ;; 2055bdcaa8d0Smrg esac 2056bdcaa8d0Smrg 2057bdcaa8d0Smrg # Recognize several different file suffixes. 2058bdcaa8d0Smrg # If the user specifies -o file.o, it is replaced with file.lo 2059bdcaa8d0Smrg case $libobj in 20600b661123Smrg *.[cCFSifmso] | \ 20610b661123Smrg *.ada | *.adb | *.ads | *.asm | \ 20620b661123Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 2063880c7e28Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 20640b661123Smrg func_xform "$libobj" 20650b661123Smrg libobj=$func_xform_result 20660b661123Smrg ;; 2067bdcaa8d0Smrg esac 2068bdcaa8d0Smrg 2069bdcaa8d0Smrg case $libobj in 20700b661123Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 2071bdcaa8d0Smrg *) 20720b661123Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 2073bdcaa8d0Smrg ;; 2074bdcaa8d0Smrg esac 2075bdcaa8d0Smrg 2076bdcaa8d0Smrg func_infer_tag $base_compile 2077bdcaa8d0Smrg 2078bdcaa8d0Smrg for arg in $later; do 2079bdcaa8d0Smrg case $arg in 20800b661123Smrg -shared) 20810b661123Smrg test "$build_libtool_libs" != yes && \ 20820b661123Smrg func_fatal_configuration "can not build a shared library" 20830b661123Smrg build_old_libs=no 20840b661123Smrg continue 20850b661123Smrg ;; 20860b661123Smrg 2087bdcaa8d0Smrg -static) 20880b661123Smrg build_libtool_libs=no 2089bdcaa8d0Smrg build_old_libs=yes 2090bdcaa8d0Smrg continue 2091bdcaa8d0Smrg ;; 2092bdcaa8d0Smrg 2093bdcaa8d0Smrg -prefer-pic) 2094bdcaa8d0Smrg pic_mode=yes 2095bdcaa8d0Smrg continue 2096bdcaa8d0Smrg ;; 2097bdcaa8d0Smrg 2098bdcaa8d0Smrg -prefer-non-pic) 2099bdcaa8d0Smrg pic_mode=no 2100bdcaa8d0Smrg continue 2101bdcaa8d0Smrg ;; 2102bdcaa8d0Smrg esac 2103bdcaa8d0Smrg done 2104bdcaa8d0Smrg 21050b661123Smrg func_quote_for_eval "$libobj" 21060b661123Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 21070b661123Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 21080b661123Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 21090b661123Smrg func_dirname_and_basename "$obj" "/" "" 21100b661123Smrg objname="$func_basename_result" 21110b661123Smrg xdir="$func_dirname_result" 2112bdcaa8d0Smrg lobj=${xdir}$objdir/$objname 2113bdcaa8d0Smrg 21140b661123Smrg test -z "$base_compile" && \ 21150b661123Smrg func_fatal_help "you must specify a compilation command" 2116bdcaa8d0Smrg 2117bdcaa8d0Smrg # Delete any leftover library objects. 2118bdcaa8d0Smrg if test "$build_old_libs" = yes; then 2119bdcaa8d0Smrg removelist="$obj $lobj $libobj ${libobj}T" 2120bdcaa8d0Smrg else 2121bdcaa8d0Smrg removelist="$lobj $libobj ${libobj}T" 2122bdcaa8d0Smrg fi 2123bdcaa8d0Smrg 2124bdcaa8d0Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 2125bdcaa8d0Smrg case $host_os in 21260b661123Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 2127bdcaa8d0Smrg pic_mode=default 2128bdcaa8d0Smrg ;; 2129bdcaa8d0Smrg esac 2130bdcaa8d0Smrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 2131bdcaa8d0Smrg # non-PIC code in shared libraries is not supported 2132bdcaa8d0Smrg pic_mode=default 2133bdcaa8d0Smrg fi 2134bdcaa8d0Smrg 2135bdcaa8d0Smrg # Calculate the filename of the output object if compiler does 2136bdcaa8d0Smrg # not support -o with -c 2137bdcaa8d0Smrg if test "$compiler_c_o" = no; then 2138880c7e28Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 2139bdcaa8d0Smrg lockfile="$output_obj.lock" 2140bdcaa8d0Smrg else 2141bdcaa8d0Smrg output_obj= 2142bdcaa8d0Smrg need_locks=no 2143bdcaa8d0Smrg lockfile= 2144bdcaa8d0Smrg fi 2145bdcaa8d0Smrg 2146bdcaa8d0Smrg # Lock this critical section if it is needed 2147bdcaa8d0Smrg # We use this script file to make the link, it avoids creating a new file 2148bdcaa8d0Smrg if test "$need_locks" = yes; then 21490b661123Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 21500b661123Smrg func_echo "Waiting for $lockfile to be removed" 2151bdcaa8d0Smrg sleep 2 2152bdcaa8d0Smrg done 2153bdcaa8d0Smrg elif test "$need_locks" = warn; then 2154bdcaa8d0Smrg if test -f "$lockfile"; then 21550b661123Smrg $ECHO "\ 2156bdcaa8d0Smrg*** ERROR, $lockfile exists and contains: 2157bdcaa8d0Smrg`cat $lockfile 2>/dev/null` 2158bdcaa8d0Smrg 2159bdcaa8d0SmrgThis indicates that another process is trying to use the same 2160bdcaa8d0Smrgtemporary object file, and libtool could not work around it because 2161bdcaa8d0Smrgyour compiler does not support \`-c' and \`-o' together. If you 2162bdcaa8d0Smrgrepeat this compilation, it may succeed, by chance, but you had better 2163bdcaa8d0Smrgavoid parallel builds (make -j) in this platform, or get a better 2164bdcaa8d0Smrgcompiler." 2165bdcaa8d0Smrg 21660b661123Smrg $opt_dry_run || $RM $removelist 2167bdcaa8d0Smrg exit $EXIT_FAILURE 2168bdcaa8d0Smrg fi 2169880c7e28Smrg func_append removelist " $output_obj" 21700b661123Smrg $ECHO "$srcfile" > "$lockfile" 2171bdcaa8d0Smrg fi 2172bdcaa8d0Smrg 21730b661123Smrg $opt_dry_run || $RM $removelist 2174880c7e28Smrg func_append removelist " $lockfile" 21750b661123Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 21760b661123Smrg 2177880c7e28Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 2178880c7e28Smrg srcfile=$func_to_tool_file_result 21790b661123Smrg func_quote_for_eval "$srcfile" 21800b661123Smrg qsrcfile=$func_quote_for_eval_result 2181bdcaa8d0Smrg 2182bdcaa8d0Smrg # Only build a PIC object if we are building libtool libraries. 2183bdcaa8d0Smrg if test "$build_libtool_libs" = yes; then 2184bdcaa8d0Smrg # Without this assignment, base_compile gets emptied. 2185bdcaa8d0Smrg fbsd_hideous_sh_bug=$base_compile 2186bdcaa8d0Smrg 2187bdcaa8d0Smrg if test "$pic_mode" != no; then 2188bdcaa8d0Smrg command="$base_compile $qsrcfile $pic_flag" 2189bdcaa8d0Smrg else 2190bdcaa8d0Smrg # Don't build PIC code 2191bdcaa8d0Smrg command="$base_compile $qsrcfile" 2192bdcaa8d0Smrg fi 2193bdcaa8d0Smrg 21940b661123Smrg func_mkdir_p "$xdir$objdir" 2195bdcaa8d0Smrg 2196bdcaa8d0Smrg if test -z "$output_obj"; then 2197bdcaa8d0Smrg # Place PIC objects in $objdir 2198880c7e28Smrg func_append command " -o $lobj" 2199bdcaa8d0Smrg fi 2200bdcaa8d0Smrg 22010b661123Smrg func_show_eval_locale "$command" \ 22020b661123Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 2203bdcaa8d0Smrg 2204bdcaa8d0Smrg if test "$need_locks" = warn && 2205bdcaa8d0Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 22060b661123Smrg $ECHO "\ 2207bdcaa8d0Smrg*** ERROR, $lockfile contains: 2208bdcaa8d0Smrg`cat $lockfile 2>/dev/null` 2209bdcaa8d0Smrg 2210bdcaa8d0Smrgbut it should contain: 2211bdcaa8d0Smrg$srcfile 2212bdcaa8d0Smrg 2213bdcaa8d0SmrgThis indicates that another process is trying to use the same 2214bdcaa8d0Smrgtemporary object file, and libtool could not work around it because 2215bdcaa8d0Smrgyour compiler does not support \`-c' and \`-o' together. If you 2216bdcaa8d0Smrgrepeat this compilation, it may succeed, by chance, but you had better 2217bdcaa8d0Smrgavoid parallel builds (make -j) in this platform, or get a better 2218bdcaa8d0Smrgcompiler." 2219bdcaa8d0Smrg 22200b661123Smrg $opt_dry_run || $RM $removelist 2221bdcaa8d0Smrg exit $EXIT_FAILURE 2222bdcaa8d0Smrg fi 2223bdcaa8d0Smrg 2224bdcaa8d0Smrg # Just move the object if needed, then go on to compile the next one 2225bdcaa8d0Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 22260b661123Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 22270b661123Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2228bdcaa8d0Smrg fi 2229bdcaa8d0Smrg 2230bdcaa8d0Smrg # Allow error messages only from the first compilation. 2231bdcaa8d0Smrg if test "$suppress_opt" = yes; then 22320b661123Smrg suppress_output=' >/dev/null 2>&1' 2233bdcaa8d0Smrg fi 2234bdcaa8d0Smrg fi 2235bdcaa8d0Smrg 2236bdcaa8d0Smrg # Only build a position-dependent object if we build old libraries. 2237bdcaa8d0Smrg if test "$build_old_libs" = yes; then 2238bdcaa8d0Smrg if test "$pic_mode" != yes; then 2239bdcaa8d0Smrg # Don't build PIC code 22400b661123Smrg command="$base_compile $qsrcfile$pie_flag" 2241bdcaa8d0Smrg else 2242bdcaa8d0Smrg command="$base_compile $qsrcfile $pic_flag" 2243bdcaa8d0Smrg fi 2244bdcaa8d0Smrg if test "$compiler_c_o" = yes; then 2245880c7e28Smrg func_append command " -o $obj" 2246bdcaa8d0Smrg fi 2247bdcaa8d0Smrg 2248bdcaa8d0Smrg # Suppress compiler output if we already did a PIC compilation. 2249880c7e28Smrg func_append command "$suppress_output" 22500b661123Smrg func_show_eval_locale "$command" \ 22510b661123Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 2252bdcaa8d0Smrg 2253bdcaa8d0Smrg if test "$need_locks" = warn && 2254bdcaa8d0Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 22550b661123Smrg $ECHO "\ 2256bdcaa8d0Smrg*** ERROR, $lockfile contains: 2257bdcaa8d0Smrg`cat $lockfile 2>/dev/null` 2258bdcaa8d0Smrg 2259bdcaa8d0Smrgbut it should contain: 2260bdcaa8d0Smrg$srcfile 2261bdcaa8d0Smrg 2262bdcaa8d0SmrgThis indicates that another process is trying to use the same 2263bdcaa8d0Smrgtemporary object file, and libtool could not work around it because 2264bdcaa8d0Smrgyour compiler does not support \`-c' and \`-o' together. If you 2265bdcaa8d0Smrgrepeat this compilation, it may succeed, by chance, but you had better 2266bdcaa8d0Smrgavoid parallel builds (make -j) in this platform, or get a better 2267bdcaa8d0Smrgcompiler." 2268bdcaa8d0Smrg 22690b661123Smrg $opt_dry_run || $RM $removelist 2270bdcaa8d0Smrg exit $EXIT_FAILURE 2271bdcaa8d0Smrg fi 2272bdcaa8d0Smrg 2273bdcaa8d0Smrg # Just move the object if needed 2274bdcaa8d0Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 22750b661123Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 22760b661123Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2277bdcaa8d0Smrg fi 2278bdcaa8d0Smrg fi 2279bdcaa8d0Smrg 22800b661123Smrg $opt_dry_run || { 22810b661123Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 2282bdcaa8d0Smrg 22830b661123Smrg # Unlock the critical section if it was locked 22840b661123Smrg if test "$need_locks" != no; then 22850b661123Smrg removelist=$lockfile 22860b661123Smrg $RM "$lockfile" 22870b661123Smrg fi 22880b661123Smrg } 2289bdcaa8d0Smrg 2290bdcaa8d0Smrg exit $EXIT_SUCCESS 22910b661123Smrg} 2292bdcaa8d0Smrg 22930b661123Smrg$opt_help || { 2294880c7e28Smrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 22950b661123Smrg} 2296bdcaa8d0Smrg 22970b661123Smrgfunc_mode_help () 22980b661123Smrg{ 22990b661123Smrg # We need to display help for each of the modes. 2300880c7e28Smrg case $opt_mode in 23010b661123Smrg "") 23020b661123Smrg # Generic help is extracted from the usage comments 23030b661123Smrg # at the start of this file. 23040b661123Smrg func_help 23050b661123Smrg ;; 2306bdcaa8d0Smrg 23070b661123Smrg clean) 23080b661123Smrg $ECHO \ 23090b661123Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 2310bdcaa8d0Smrg 23110b661123SmrgRemove files from the build directory. 2312bdcaa8d0Smrg 23130b661123SmrgRM is the name of the program to use to delete files associated with each FILE 23140b661123Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 23150b661123Smrgto RM. 2316bdcaa8d0Smrg 23170b661123SmrgIf FILE is a libtool library, object or program, all the files associated 23180b661123Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 23190b661123Smrg ;; 2320bdcaa8d0Smrg 23210b661123Smrg compile) 23220b661123Smrg $ECHO \ 23230b661123Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 2324bdcaa8d0Smrg 23250b661123SmrgCompile a source file into a libtool library object. 2326bdcaa8d0Smrg 23270b661123SmrgThis mode accepts the following additional options: 2328bdcaa8d0Smrg 23290b661123Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 23300b661123Smrg -no-suppress do not suppress compiler output for multiple passes 2331880c7e28Smrg -prefer-pic try to build PIC objects only 2332880c7e28Smrg -prefer-non-pic try to build non-PIC objects only 23330b661123Smrg -shared do not build a \`.o' file suitable for static linking 23340b661123Smrg -static only build a \`.o' file suitable for static linking 2335880c7e28Smrg -Wc,FLAG pass FLAG directly to the compiler 2336bdcaa8d0Smrg 23370b661123SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 23380b661123Smrgfrom the given SOURCEFILE. 2339bdcaa8d0Smrg 23400b661123SmrgThe output file name is determined by removing the directory component from 23410b661123SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 23420b661123Smrglibrary object suffix, \`.lo'." 23430b661123Smrg ;; 2344bdcaa8d0Smrg 23450b661123Smrg execute) 23460b661123Smrg $ECHO \ 23470b661123Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 2348bdcaa8d0Smrg 23490b661123SmrgAutomatically set library path, then run a program. 2350bdcaa8d0Smrg 23510b661123SmrgThis mode accepts the following additional options: 2352bdcaa8d0Smrg 23530b661123Smrg -dlopen FILE add the directory containing FILE to the library path 2354bdcaa8d0Smrg 23550b661123SmrgThis mode sets the library path environment variable according to \`-dlopen' 23560b661123Smrgflags. 2357bdcaa8d0Smrg 23580b661123SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 23590b661123Smrginto their corresponding uninstalled binary, and any of their required library 23600b661123Smrgdirectories are added to the library path. 2361bdcaa8d0Smrg 23620b661123SmrgThen, COMMAND is executed, with ARGS as arguments." 23630b661123Smrg ;; 2364bdcaa8d0Smrg 23650b661123Smrg finish) 23660b661123Smrg $ECHO \ 23670b661123Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 2368bdcaa8d0Smrg 23690b661123SmrgComplete the installation of libtool libraries. 2370bdcaa8d0Smrg 23710b661123SmrgEach LIBDIR is a directory that contains libtool libraries. 2372bdcaa8d0Smrg 23730b661123SmrgThe commands that this mode executes may require superuser privileges. Use 23740b661123Smrgthe \`--dry-run' option if you just want to see what would be executed." 23750b661123Smrg ;; 2376bdcaa8d0Smrg 23770b661123Smrg install) 23780b661123Smrg $ECHO \ 23790b661123Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 2380bdcaa8d0Smrg 23810b661123SmrgInstall executables or libraries. 2382bdcaa8d0Smrg 23830b661123SmrgINSTALL-COMMAND is the installation command. The first component should be 23840b661123Smrgeither the \`install' or \`cp' program. 2385bdcaa8d0Smrg 23860b661123SmrgThe following components of INSTALL-COMMAND are treated specially: 2387bdcaa8d0Smrg 2388880c7e28Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 2389bdcaa8d0Smrg 23900b661123SmrgThe rest of the components are interpreted as arguments to that command (only 23910b661123SmrgBSD-compatible install options are recognized)." 23920b661123Smrg ;; 2393bdcaa8d0Smrg 23940b661123Smrg link) 23950b661123Smrg $ECHO \ 23960b661123Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 2397bdcaa8d0Smrg 23980b661123SmrgLink object files or libraries together to form another library, or to 23990b661123Smrgcreate an executable program. 2400bdcaa8d0Smrg 24010b661123SmrgLINK-COMMAND is a command using the C compiler that you would use to create 24020b661123Smrga program from several object files. 2403bdcaa8d0Smrg 24040b661123SmrgThe following components of LINK-COMMAND are treated specially: 2405bdcaa8d0Smrg 24060b661123Smrg -all-static do not do any dynamic linking at all 24070b661123Smrg -avoid-version do not add a version suffix if possible 2408880c7e28Smrg -bindir BINDIR specify path to binaries directory (for systems where 2409880c7e28Smrg libraries must be found in the PATH setting at runtime) 24100b661123Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 24110b661123Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 24120b661123Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 24130b661123Smrg -export-symbols SYMFILE 24140b661123Smrg try to export only the symbols listed in SYMFILE 24150b661123Smrg -export-symbols-regex REGEX 24160b661123Smrg try to export only the symbols matching REGEX 24170b661123Smrg -LLIBDIR search LIBDIR for required installed libraries 24180b661123Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 24190b661123Smrg -module build a library that can dlopened 24200b661123Smrg -no-fast-install disable the fast-install mode 24210b661123Smrg -no-install link a not-installable executable 24220b661123Smrg -no-undefined declare that a library does not refer to external symbols 24230b661123Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 24240b661123Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 24250b661123Smrg -precious-files-regex REGEX 24260b661123Smrg don't remove output files matching REGEX 24270b661123Smrg -release RELEASE specify package release information 24280b661123Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 24290b661123Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 24300b661123Smrg -shared only do dynamic linking of libtool libraries 24310b661123Smrg -shrext SUFFIX override the standard shared library file extension 24320b661123Smrg -static do not do any dynamic linking of uninstalled libtool libraries 24330b661123Smrg -static-libtool-libs 24340b661123Smrg do not do any dynamic linking of libtool libraries 24350b661123Smrg -version-info CURRENT[:REVISION[:AGE]] 24360b661123Smrg specify library version info [each variable defaults to 0] 24370b661123Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 2438880c7e28Smrg -Wc,FLAG 2439880c7e28Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 2440880c7e28Smrg -Wl,FLAG 2441880c7e28Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 2442880c7e28Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 2443bdcaa8d0Smrg 24440b661123SmrgAll other options (arguments beginning with \`-') are ignored. 2445bdcaa8d0Smrg 24460b661123SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 24470b661123Smrgtreated as uninstalled libtool libraries, other files are standard or library 24480b661123Smrgobject files. 2449bdcaa8d0Smrg 24500b661123SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 24510b661123Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 24520b661123Smrgrequired, except when creating a convenience library. 2453bdcaa8d0Smrg 24540b661123SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 24550b661123Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 2456bdcaa8d0Smrg 24570b661123SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 24580b661123Smrgis created, otherwise an executable program is created." 245996ce994aSmrg ;; 2460bdcaa8d0Smrg 24610b661123Smrg uninstall) 24620b661123Smrg $ECHO \ 24630b661123Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 2464bdcaa8d0Smrg 24650b661123SmrgRemove libraries from an installation directory. 2466bdcaa8d0Smrg 24670b661123SmrgRM is the name of the program to use to delete files associated with each FILE 24680b661123Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 24690b661123Smrgto RM. 2470bdcaa8d0Smrg 24710b661123SmrgIf FILE is a libtool library, all the files associated with it are deleted. 24720b661123SmrgOtherwise, only FILE itself is deleted using RM." 24730b661123Smrg ;; 2474bdcaa8d0Smrg 24750b661123Smrg *) 2476880c7e28Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 24770b661123Smrg ;; 24780b661123Smrg esac 2479bdcaa8d0Smrg 2480880c7e28Smrg echo 24810b661123Smrg $ECHO "Try \`$progname --help' for more information about other modes." 24820b661123Smrg} 2483bdcaa8d0Smrg 2484880c7e28Smrg# Now that we've collected a possible --mode arg, show help if necessary 2485880c7e28Smrgif $opt_help; then 2486880c7e28Smrg if test "$opt_help" = :; then 2487880c7e28Smrg func_mode_help 2488880c7e28Smrg else 2489880c7e28Smrg { 2490880c7e28Smrg func_help noexit 2491880c7e28Smrg for opt_mode in compile link execute install finish uninstall clean; do 2492880c7e28Smrg func_mode_help 2493880c7e28Smrg done 2494880c7e28Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 2495880c7e28Smrg { 2496880c7e28Smrg func_help noexit 2497880c7e28Smrg for opt_mode in compile link execute install finish uninstall clean; do 2498880c7e28Smrg echo 2499880c7e28Smrg func_mode_help 2500880c7e28Smrg done 2501880c7e28Smrg } | 2502880c7e28Smrg sed '1d 2503880c7e28Smrg /^When reporting/,/^Report/{ 2504880c7e28Smrg H 2505880c7e28Smrg d 2506880c7e28Smrg } 2507880c7e28Smrg $x 2508880c7e28Smrg /information about other modes/d 2509880c7e28Smrg /more detailed .*MODE/d 2510880c7e28Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 2511880c7e28Smrg fi 2512880c7e28Smrg exit $? 2513880c7e28Smrgfi 251472313efbSmrg 2515bdcaa8d0Smrg 25160b661123Smrg# func_mode_execute arg... 25170b661123Smrgfunc_mode_execute () 25180b661123Smrg{ 25190b661123Smrg $opt_debug 25200b661123Smrg # The first argument is the command name. 25210b661123Smrg cmd="$nonopt" 25220b661123Smrg test -z "$cmd" && \ 25230b661123Smrg func_fatal_help "you must specify a COMMAND" 252496ce994aSmrg 25250b661123Smrg # Handle -dlopen flags immediately. 2526880c7e28Smrg for file in $opt_dlopen; do 25270b661123Smrg test -f "$file" \ 25280b661123Smrg || func_fatal_help "\`$file' is not a file" 252996ce994aSmrg 25300b661123Smrg dir= 25310b661123Smrg case $file in 25320b661123Smrg *.la) 2533880c7e28Smrg func_resolve_sysroot "$file" 2534880c7e28Smrg file=$func_resolve_sysroot_result 2535880c7e28Smrg 25360b661123Smrg # Check to see that this really is a libtool archive. 25370b661123Smrg func_lalib_unsafe_p "$file" \ 25380b661123Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 253996ce994aSmrg 25400b661123Smrg # Read the libtool library. 25410b661123Smrg dlname= 25420b661123Smrg library_names= 25430b661123Smrg func_source "$file" 2544bdcaa8d0Smrg 25450b661123Smrg # Skip this library if it cannot be dlopened. 25460b661123Smrg if test -z "$dlname"; then 25470b661123Smrg # Warn if it was a shared library. 25480b661123Smrg test -n "$library_names" && \ 25490b661123Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 25500b661123Smrg continue 25510b661123Smrg fi 2552bdcaa8d0Smrg 25530b661123Smrg func_dirname "$file" "" "." 25540b661123Smrg dir="$func_dirname_result" 2555bdcaa8d0Smrg 25560b661123Smrg if test -f "$dir/$objdir/$dlname"; then 2557880c7e28Smrg func_append dir "/$objdir" 25580b661123Smrg else 25590b661123Smrg if test ! -f "$dir/$dlname"; then 25600b661123Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 25610b661123Smrg fi 25620b661123Smrg fi 256396ce994aSmrg ;; 2564bdcaa8d0Smrg 25650b661123Smrg *.lo) 25660b661123Smrg # Just add the directory containing the .lo file. 25670b661123Smrg func_dirname "$file" "" "." 25680b661123Smrg dir="$func_dirname_result" 256996ce994aSmrg ;; 2570bdcaa8d0Smrg 25710b661123Smrg *) 25720b661123Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 257396ce994aSmrg continue 257496ce994aSmrg ;; 25750b661123Smrg esac 257672313efbSmrg 25770b661123Smrg # Get the absolute pathname. 25780b661123Smrg absdir=`cd "$dir" && pwd` 25790b661123Smrg test -n "$absdir" && dir="$absdir" 258072313efbSmrg 25810b661123Smrg # Now add the directory to shlibpath_var. 25820b661123Smrg if eval "test -z \"\$$shlibpath_var\""; then 25830b661123Smrg eval "$shlibpath_var=\"\$dir\"" 25840b661123Smrg else 25850b661123Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 25860b661123Smrg fi 25870b661123Smrg done 258872313efbSmrg 25890b661123Smrg # This variable tells wrapper scripts just to set shlibpath_var 25900b661123Smrg # rather than running their programs. 25910b661123Smrg libtool_execute_magic="$magic" 259272313efbSmrg 25930b661123Smrg # Check if any of the arguments is a wrapper script. 25940b661123Smrg args= 25950b661123Smrg for file 25960b661123Smrg do 25970b661123Smrg case $file in 2598880c7e28Smrg -* | *.la | *.lo ) ;; 25990b661123Smrg *) 26000b661123Smrg # Do a test to see if this is really a libtool program. 26010b661123Smrg if func_ltwrapper_script_p "$file"; then 26020b661123Smrg func_source "$file" 26030b661123Smrg # Transform arg to wrapped name. 26040b661123Smrg file="$progdir/$program" 26050b661123Smrg elif func_ltwrapper_executable_p "$file"; then 26060b661123Smrg func_ltwrapper_scriptname "$file" 26070b661123Smrg func_source "$func_ltwrapper_scriptname_result" 26080b661123Smrg # Transform arg to wrapped name. 26090b661123Smrg file="$progdir/$program" 26100b661123Smrg fi 26110b661123Smrg ;; 26120b661123Smrg esac 26130b661123Smrg # Quote arguments (to preserve shell metacharacters). 2614880c7e28Smrg func_append_quoted args "$file" 26150b661123Smrg done 261672313efbSmrg 26170b661123Smrg if test "X$opt_dry_run" = Xfalse; then 26180b661123Smrg if test -n "$shlibpath_var"; then 26190b661123Smrg # Export the shlibpath_var. 26200b661123Smrg eval "export $shlibpath_var" 26210b661123Smrg fi 262272313efbSmrg 26230b661123Smrg # Restore saved environment variables 26240b661123Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 26250b661123Smrg do 26260b661123Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 26270b661123Smrg $lt_var=\$save_$lt_var; export $lt_var 262896ce994aSmrg else 26290b661123Smrg $lt_unset $lt_var 26300b661123Smrg fi" 26310b661123Smrg done 263272313efbSmrg 26330b661123Smrg # Now prepare to actually exec the command. 26340b661123Smrg exec_cmd="\$cmd$args" 26350b661123Smrg else 26360b661123Smrg # Display what would be done. 26370b661123Smrg if test -n "$shlibpath_var"; then 26380b661123Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 2639880c7e28Smrg echo "export $shlibpath_var" 26400b661123Smrg fi 26410b661123Smrg $ECHO "$cmd$args" 26420b661123Smrg exit $EXIT_SUCCESS 26430b661123Smrg fi 26440b661123Smrg} 264572313efbSmrg 2646880c7e28Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 264772313efbSmrg 264896ce994aSmrg 26490b661123Smrg# func_mode_finish arg... 26500b661123Smrgfunc_mode_finish () 26510b661123Smrg{ 26520b661123Smrg $opt_debug 2653880c7e28Smrg libs= 2654880c7e28Smrg libdirs= 26550b661123Smrg admincmds= 2656bdcaa8d0Smrg 2657880c7e28Smrg for opt in "$nonopt" ${1+"$@"} 2658880c7e28Smrg do 2659880c7e28Smrg if test -d "$opt"; then 2660880c7e28Smrg func_append libdirs " $opt" 2661880c7e28Smrg 2662880c7e28Smrg elif test -f "$opt"; then 2663880c7e28Smrg if func_lalib_unsafe_p "$opt"; then 2664880c7e28Smrg func_append libs " $opt" 2665880c7e28Smrg else 2666880c7e28Smrg func_warning "\`$opt' is not a valid libtool archive" 2667880c7e28Smrg fi 2668880c7e28Smrg 2669880c7e28Smrg else 2670880c7e28Smrg func_fatal_error "invalid argument \`$opt'" 2671880c7e28Smrg fi 2672880c7e28Smrg done 2673880c7e28Smrg 2674880c7e28Smrg if test -n "$libs"; then 2675880c7e28Smrg if test -n "$lt_sysroot"; then 2676880c7e28Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 2677880c7e28Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 2678880c7e28Smrg else 2679880c7e28Smrg sysroot_cmd= 2680880c7e28Smrg fi 2681880c7e28Smrg 2682880c7e28Smrg # Remove sysroot references 2683880c7e28Smrg if $opt_dry_run; then 2684880c7e28Smrg for lib in $libs; do 2685880c7e28Smrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 2686880c7e28Smrg done 2687880c7e28Smrg else 2688880c7e28Smrg tmpdir=`func_mktempdir` 2689880c7e28Smrg for lib in $libs; do 2690880c7e28Smrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 2691880c7e28Smrg > $tmpdir/tmp-la 2692880c7e28Smrg mv -f $tmpdir/tmp-la $lib 2693880c7e28Smrg done 2694880c7e28Smrg ${RM}r "$tmpdir" 2695880c7e28Smrg fi 2696880c7e28Smrg fi 2697bdcaa8d0Smrg 2698880c7e28Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 26990b661123Smrg for libdir in $libdirs; do 27000b661123Smrg if test -n "$finish_cmds"; then 27010b661123Smrg # Do each command in the finish commands. 27020b661123Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 27030b661123Smrg'"$cmd"'"' 270496ce994aSmrg fi 27050b661123Smrg if test -n "$finish_eval"; then 27060b661123Smrg # Do the single finish_eval. 27070b661123Smrg eval cmds=\"$finish_eval\" 2708880c7e28Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 27090b661123Smrg $cmds" 27100b661123Smrg fi 27110b661123Smrg done 27120b661123Smrg fi 2713bdcaa8d0Smrg 27140b661123Smrg # Exit here if they wanted silent mode. 27150b661123Smrg $opt_silent && exit $EXIT_SUCCESS 2716bdcaa8d0Smrg 2717880c7e28Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2718880c7e28Smrg echo "----------------------------------------------------------------------" 2719880c7e28Smrg echo "Libraries have been installed in:" 2720880c7e28Smrg for libdir in $libdirs; do 2721880c7e28Smrg $ECHO " $libdir" 2722880c7e28Smrg done 2723880c7e28Smrg echo 2724880c7e28Smrg echo "If you ever happen to want to link against installed libraries" 2725880c7e28Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 2726880c7e28Smrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 2727880c7e28Smrg echo "flag during linking and do at least one of the following:" 2728880c7e28Smrg if test -n "$shlibpath_var"; then 2729880c7e28Smrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 2730880c7e28Smrg echo " during execution" 2731880c7e28Smrg fi 2732880c7e28Smrg if test -n "$runpath_var"; then 2733880c7e28Smrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 2734880c7e28Smrg echo " during linking" 2735880c7e28Smrg fi 2736880c7e28Smrg if test -n "$hardcode_libdir_flag_spec"; then 2737880c7e28Smrg libdir=LIBDIR 2738880c7e28Smrg eval flag=\"$hardcode_libdir_flag_spec\" 27390b661123Smrg 2740880c7e28Smrg $ECHO " - use the \`$flag' linker flag" 2741880c7e28Smrg fi 2742880c7e28Smrg if test -n "$admincmds"; then 2743880c7e28Smrg $ECHO " - have your system administrator run these commands:$admincmds" 2744880c7e28Smrg fi 2745880c7e28Smrg if test -f /etc/ld.so.conf; then 2746880c7e28Smrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 2747880c7e28Smrg fi 2748880c7e28Smrg echo 27490b661123Smrg 2750880c7e28Smrg echo "See any operating system documentation about shared libraries for" 2751880c7e28Smrg case $host in 2752880c7e28Smrg solaris2.[6789]|solaris2.1[0-9]) 2753880c7e28Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 2754880c7e28Smrg echo "pages." 2755880c7e28Smrg ;; 2756880c7e28Smrg *) 2757880c7e28Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 2758880c7e28Smrg ;; 2759880c7e28Smrg esac 2760880c7e28Smrg echo "----------------------------------------------------------------------" 2761880c7e28Smrg fi 27620b661123Smrg exit $EXIT_SUCCESS 27630b661123Smrg} 27640b661123Smrg 2765880c7e28Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 27660b661123Smrg 27670b661123Smrg 27680b661123Smrg# func_mode_install arg... 27690b661123Smrgfunc_mode_install () 27700b661123Smrg{ 27710b661123Smrg $opt_debug 27720b661123Smrg # There may be an optional sh(1) argument at the beginning of 27730b661123Smrg # install_prog (especially on Windows NT). 27740b661123Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 27750b661123Smrg # Allow the use of GNU shtool's install command. 2776880c7e28Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 27770b661123Smrg # Aesthetically quote it. 27780b661123Smrg func_quote_for_eval "$nonopt" 27790b661123Smrg install_prog="$func_quote_for_eval_result " 27800b661123Smrg arg=$1 27810b661123Smrg shift 27820b661123Smrg else 27830b661123Smrg install_prog= 27840b661123Smrg arg=$nonopt 27850b661123Smrg fi 27860b661123Smrg 27870b661123Smrg # The real first argument should be the name of the installation program. 27880b661123Smrg # Aesthetically quote it. 27890b661123Smrg func_quote_for_eval "$arg" 2790880c7e28Smrg func_append install_prog "$func_quote_for_eval_result" 2791880c7e28Smrg install_shared_prog=$install_prog 2792880c7e28Smrg case " $install_prog " in 2793880c7e28Smrg *[\\\ /]cp\ *) install_cp=: ;; 2794880c7e28Smrg *) install_cp=false ;; 2795880c7e28Smrg esac 27960b661123Smrg 27970b661123Smrg # We need to accept at least all the BSD install flags. 27980b661123Smrg dest= 27990b661123Smrg files= 28000b661123Smrg opts= 28010b661123Smrg prev= 28020b661123Smrg install_type= 28030b661123Smrg isdir=no 28040b661123Smrg stripme= 2805880c7e28Smrg no_mode=: 28060b661123Smrg for arg 28070b661123Smrg do 2808880c7e28Smrg arg2= 28090b661123Smrg if test -n "$dest"; then 2810880c7e28Smrg func_append files " $dest" 28110b661123Smrg dest=$arg 28120b661123Smrg continue 28130b661123Smrg fi 28140b661123Smrg 28150b661123Smrg case $arg in 28160b661123Smrg -d) isdir=yes ;; 28170b661123Smrg -f) 2818880c7e28Smrg if $install_cp; then :; else 2819880c7e28Smrg prev=$arg 2820880c7e28Smrg fi 28210b661123Smrg ;; 28220b661123Smrg -g | -m | -o) 28230b661123Smrg prev=$arg 28240b661123Smrg ;; 28250b661123Smrg -s) 28260b661123Smrg stripme=" -s" 28270b661123Smrg continue 28280b661123Smrg ;; 28290b661123Smrg -*) 28300b661123Smrg ;; 28310b661123Smrg *) 28320b661123Smrg # If the previous option needed an argument, then skip it. 28330b661123Smrg if test -n "$prev"; then 2834880c7e28Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 2835880c7e28Smrg arg2=$install_override_mode 2836880c7e28Smrg no_mode=false 2837880c7e28Smrg fi 283896ce994aSmrg prev= 283972313efbSmrg else 28400b661123Smrg dest=$arg 28410b661123Smrg continue 284272313efbSmrg fi 284396ce994aSmrg ;; 28440b661123Smrg esac 284572313efbSmrg 28460b661123Smrg # Aesthetically quote the argument. 28470b661123Smrg func_quote_for_eval "$arg" 2848880c7e28Smrg func_append install_prog " $func_quote_for_eval_result" 2849880c7e28Smrg if test -n "$arg2"; then 2850880c7e28Smrg func_quote_for_eval "$arg2" 2851880c7e28Smrg fi 2852880c7e28Smrg func_append install_shared_prog " $func_quote_for_eval_result" 28530b661123Smrg done 2854bdcaa8d0Smrg 28550b661123Smrg test -z "$install_prog" && \ 28560b661123Smrg func_fatal_help "you must specify an install program" 285772313efbSmrg 28580b661123Smrg test -n "$prev" && \ 28590b661123Smrg func_fatal_help "the \`$prev' option requires an argument" 2860bdcaa8d0Smrg 2861880c7e28Smrg if test -n "$install_override_mode" && $no_mode; then 2862880c7e28Smrg if $install_cp; then :; else 2863880c7e28Smrg func_quote_for_eval "$install_override_mode" 2864880c7e28Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 2865880c7e28Smrg fi 2866880c7e28Smrg fi 2867880c7e28Smrg 28680b661123Smrg if test -z "$files"; then 28690b661123Smrg if test -z "$dest"; then 28700b661123Smrg func_fatal_help "no file or destination specified" 28710b661123Smrg else 28720b661123Smrg func_fatal_help "you must specify a destination" 28730b661123Smrg fi 287496ce994aSmrg fi 2875bdcaa8d0Smrg 28760b661123Smrg # Strip any trailing slash from the destination. 28770b661123Smrg func_stripname '' '/' "$dest" 28780b661123Smrg dest=$func_stripname_result 2879bdcaa8d0Smrg 28800b661123Smrg # Check to see that the destination is a directory. 28810b661123Smrg test -d "$dest" && isdir=yes 28820b661123Smrg if test "$isdir" = yes; then 28830b661123Smrg destdir="$dest" 28840b661123Smrg destname= 288596ce994aSmrg else 28860b661123Smrg func_dirname_and_basename "$dest" "" "." 28870b661123Smrg destdir="$func_dirname_result" 28880b661123Smrg destname="$func_basename_result" 288972313efbSmrg 28900b661123Smrg # Not a directory, so check to see that there is only one file specified. 28910b661123Smrg set dummy $files; shift 28920b661123Smrg test "$#" -gt 1 && \ 28930b661123Smrg func_fatal_help "\`$dest' is not a directory" 289472313efbSmrg fi 28950b661123Smrg case $destdir in 28960b661123Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 289796ce994aSmrg *) 28980b661123Smrg for file in $files; do 28990b661123Smrg case $file in 29000b661123Smrg *.lo) ;; 29010b661123Smrg *) 29020b661123Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 29030b661123Smrg ;; 29040b661123Smrg esac 29050b661123Smrg done 290696ce994aSmrg ;; 290796ce994aSmrg esac 2908bdcaa8d0Smrg 29090b661123Smrg # This variable tells wrapper scripts just to set variables rather 29100b661123Smrg # than running their programs. 29110b661123Smrg libtool_install_magic="$magic" 291272313efbSmrg 29130b661123Smrg staticlibs= 29140b661123Smrg future_libdirs= 29150b661123Smrg current_libdirs= 29160b661123Smrg for file in $files; do 291772313efbSmrg 29180b661123Smrg # Do each installation. 29190b661123Smrg case $file in 29200b661123Smrg *.$libext) 29210b661123Smrg # Do the static libraries later. 2922880c7e28Smrg func_append staticlibs " $file" 29230b661123Smrg ;; 29240b661123Smrg 29250b661123Smrg *.la) 2926880c7e28Smrg func_resolve_sysroot "$file" 2927880c7e28Smrg file=$func_resolve_sysroot_result 2928880c7e28Smrg 29290b661123Smrg # Check to see that this really is a libtool archive. 29300b661123Smrg func_lalib_unsafe_p "$file" \ 29310b661123Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 29320b661123Smrg 29330b661123Smrg library_names= 29340b661123Smrg old_library= 29350b661123Smrg relink_command= 29360b661123Smrg func_source "$file" 29370b661123Smrg 29380b661123Smrg # Add the libdir to current_libdirs if it is the destination. 29390b661123Smrg if test "X$destdir" = "X$libdir"; then 29400b661123Smrg case "$current_libdirs " in 29410b661123Smrg *" $libdir "*) ;; 2942880c7e28Smrg *) func_append current_libdirs " $libdir" ;; 294372313efbSmrg esac 29440b661123Smrg else 29450b661123Smrg # Note the libdir as a future libdir. 29460b661123Smrg case "$future_libdirs " in 29470b661123Smrg *" $libdir "*) ;; 2948880c7e28Smrg *) func_append future_libdirs " $libdir" ;; 29490b661123Smrg esac 29500b661123Smrg fi 295172313efbSmrg 29520b661123Smrg func_dirname "$file" "/" "" 29530b661123Smrg dir="$func_dirname_result" 2954880c7e28Smrg func_append dir "$objdir" 29550b661123Smrg 29560b661123Smrg if test -n "$relink_command"; then 29570b661123Smrg # Determine the prefix the user has applied to our future dir. 2958880c7e28Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 29590b661123Smrg 29600b661123Smrg # Don't allow the user to place us outside of our expected 29610b661123Smrg # location b/c this prevents finding dependent libraries that 29620b661123Smrg # are installed to the same prefix. 29630b661123Smrg # At present, this check doesn't affect windows .dll's that 29640b661123Smrg # are installed into $libdir/../bin (currently, that works fine) 29650b661123Smrg # but it's something to keep an eye on. 29660b661123Smrg test "$inst_prefix_dir" = "$destdir" && \ 29670b661123Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 29680b661123Smrg 29690b661123Smrg if test -n "$inst_prefix_dir"; then 29700b661123Smrg # Stick the inst_prefix_dir data into the link command. 2971880c7e28Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 29720b661123Smrg else 2973880c7e28Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 29740b661123Smrg fi 29750b661123Smrg 29760b661123Smrg func_warning "relinking \`$file'" 29770b661123Smrg func_show_eval "$relink_command" \ 29780b661123Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 29790b661123Smrg fi 29800b661123Smrg 29810b661123Smrg # See the names of the shared library. 29820b661123Smrg set dummy $library_names; shift 29830b661123Smrg if test -n "$1"; then 29840b661123Smrg realname="$1" 29850b661123Smrg shift 29860b661123Smrg 29870b661123Smrg srcname="$realname" 29880b661123Smrg test -n "$relink_command" && srcname="$realname"T 29890b661123Smrg 29900b661123Smrg # Install the shared library and build the symlinks. 2991880c7e28Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 29920b661123Smrg 'exit $?' 29930b661123Smrg tstripme="$stripme" 29940b661123Smrg case $host_os in 29950b661123Smrg cygwin* | mingw* | pw32* | cegcc*) 29960b661123Smrg case $realname in 29970b661123Smrg *.dll.a) 29980b661123Smrg tstripme="" 29990b661123Smrg ;; 30000b661123Smrg esac 300172313efbSmrg ;; 300272313efbSmrg esac 30030b661123Smrg if test -n "$tstripme" && test -n "$striplib"; then 30040b661123Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 300596ce994aSmrg fi 30060b661123Smrg 30070b661123Smrg if test "$#" -gt 0; then 30080b661123Smrg # Delete the old symlinks, and create new ones. 30090b661123Smrg # Try `ln -sf' first, because the `ln' binary might depend on 30100b661123Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 30110b661123Smrg # so we also need to try rm && ln -s. 30120b661123Smrg for linkname 30130b661123Smrg do 30140b661123Smrg test "$linkname" != "$realname" \ 30150b661123Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 301696ce994aSmrg done 301796ce994aSmrg fi 3018bdcaa8d0Smrg 30190b661123Smrg # Do each command in the postinstall commands. 30200b661123Smrg lib="$destdir/$realname" 30210b661123Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 302296ce994aSmrg fi 3023bdcaa8d0Smrg 30240b661123Smrg # Install the pseudo-library for information purposes. 30250b661123Smrg func_basename "$file" 30260b661123Smrg name="$func_basename_result" 30270b661123Smrg instname="$dir/$name"i 30280b661123Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 3029bdcaa8d0Smrg 30300b661123Smrg # Maybe install the static library, too. 3031880c7e28Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 30320b661123Smrg ;; 3033bdcaa8d0Smrg 30340b661123Smrg *.lo) 30350b661123Smrg # Install (i.e. copy) a libtool object. 3036bdcaa8d0Smrg 30370b661123Smrg # Figure out destination file name, if it wasn't already specified. 30380b661123Smrg if test -n "$destname"; then 30390b661123Smrg destfile="$destdir/$destname" 30400b661123Smrg else 30410b661123Smrg func_basename "$file" 30420b661123Smrg destfile="$func_basename_result" 30430b661123Smrg destfile="$destdir/$destfile" 304496ce994aSmrg fi 3045bdcaa8d0Smrg 30460b661123Smrg # Deduce the name of the destination old-style object file. 30470b661123Smrg case $destfile in 30480b661123Smrg *.lo) 30490b661123Smrg func_lo2o "$destfile" 30500b661123Smrg staticdest=$func_lo2o_result 30510b661123Smrg ;; 30520b661123Smrg *.$objext) 30530b661123Smrg staticdest="$destfile" 30540b661123Smrg destfile= 30550b661123Smrg ;; 30560b661123Smrg *) 30570b661123Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 30580b661123Smrg ;; 30590b661123Smrg esac 3060bdcaa8d0Smrg 30610b661123Smrg # Install the libtool object if requested. 30620b661123Smrg test -n "$destfile" && \ 30630b661123Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 3064bdcaa8d0Smrg 30650b661123Smrg # Install the old object if enabled. 30660b661123Smrg if test "$build_old_libs" = yes; then 30670b661123Smrg # Deduce the name of the old-style object file. 30680b661123Smrg func_lo2o "$file" 30690b661123Smrg staticobj=$func_lo2o_result 30700b661123Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 3071bdcaa8d0Smrg fi 30720b661123Smrg exit $EXIT_SUCCESS 30730b661123Smrg ;; 3074bdcaa8d0Smrg 30750b661123Smrg *) 30760b661123Smrg # Figure out destination file name, if it wasn't already specified. 30770b661123Smrg if test -n "$destname"; then 30780b661123Smrg destfile="$destdir/$destname" 30790b661123Smrg else 30800b661123Smrg func_basename "$file" 30810b661123Smrg destfile="$func_basename_result" 30820b661123Smrg destfile="$destdir/$destfile" 30830b661123Smrg fi 3084bdcaa8d0Smrg 30850b661123Smrg # If the file is missing, and there is a .exe on the end, strip it 30860b661123Smrg # because it is most likely a libtool script we actually want to 30870b661123Smrg # install 30880b661123Smrg stripped_ext="" 30890b661123Smrg case $file in 30900b661123Smrg *.exe) 30910b661123Smrg if test ! -f "$file"; then 30920b661123Smrg func_stripname '' '.exe' "$file" 30930b661123Smrg file=$func_stripname_result 30940b661123Smrg stripped_ext=".exe" 30950b661123Smrg fi 30960b661123Smrg ;; 30970b661123Smrg esac 30980b661123Smrg 30990b661123Smrg # Do a test to see if this is really a libtool program. 31000b661123Smrg case $host in 31010b661123Smrg *cygwin* | *mingw*) 31020b661123Smrg if func_ltwrapper_executable_p "$file"; then 31030b661123Smrg func_ltwrapper_scriptname "$file" 31040b661123Smrg wrapper=$func_ltwrapper_scriptname_result 31050b661123Smrg else 31060b661123Smrg func_stripname '' '.exe' "$file" 31070b661123Smrg wrapper=$func_stripname_result 31080b661123Smrg fi 31090b661123Smrg ;; 311096ce994aSmrg *) 31110b661123Smrg wrapper=$file 31120b661123Smrg ;; 31130b661123Smrg esac 31140b661123Smrg if func_ltwrapper_script_p "$wrapper"; then 31150b661123Smrg notinst_deplibs= 31160b661123Smrg relink_command= 31170b661123Smrg 31180b661123Smrg func_source "$wrapper" 31190b661123Smrg 31200b661123Smrg # Check the variables that should have been set. 31210b661123Smrg test -z "$generated_by_libtool_version" && \ 31220b661123Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 31230b661123Smrg 31240b661123Smrg finalize=yes 31250b661123Smrg for lib in $notinst_deplibs; do 31260b661123Smrg # Check to see that each library is installed. 31270b661123Smrg libdir= 31280b661123Smrg if test -f "$lib"; then 31290b661123Smrg func_source "$lib" 31300b661123Smrg fi 3131880c7e28Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 31320b661123Smrg if test -n "$libdir" && test ! -f "$libfile"; then 31330b661123Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 31340b661123Smrg finalize=no 31350b661123Smrg fi 31360b661123Smrg done 31370b661123Smrg 31380b661123Smrg relink_command= 31390b661123Smrg func_source "$wrapper" 31400b661123Smrg 31410b661123Smrg outputname= 31420b661123Smrg if test "$fast_install" = no && test -n "$relink_command"; then 31430b661123Smrg $opt_dry_run || { 31440b661123Smrg if test "$finalize" = yes; then 31450b661123Smrg tmpdir=`func_mktempdir` 31460b661123Smrg func_basename "$file$stripped_ext" 31470b661123Smrg file="$func_basename_result" 31480b661123Smrg outputname="$tmpdir/$file" 31490b661123Smrg # Replace the output file specification. 3150880c7e28Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 31510b661123Smrg 31520b661123Smrg $opt_silent || { 31530b661123Smrg func_quote_for_expand "$relink_command" 31540b661123Smrg eval "func_echo $func_quote_for_expand_result" 31550b661123Smrg } 31560b661123Smrg if eval "$relink_command"; then : 31570b661123Smrg else 31580b661123Smrg func_error "error: relink \`$file' with the above command before installing it" 31590b661123Smrg $opt_dry_run || ${RM}r "$tmpdir" 31600b661123Smrg continue 31610b661123Smrg fi 31620b661123Smrg file="$outputname" 31630b661123Smrg else 31640b661123Smrg func_warning "cannot relink \`$file'" 31650b661123Smrg fi 31660b661123Smrg } 31670b661123Smrg else 31680b661123Smrg # Install the binary that we compiled earlier. 3169880c7e28Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 317096ce994aSmrg fi 31710b661123Smrg fi 31720b661123Smrg 31730b661123Smrg # remove .exe since cygwin /usr/bin/install will append another 31740b661123Smrg # one anyway 31750b661123Smrg case $install_prog,$host in 31760b661123Smrg */usr/bin/install*,*cygwin*) 31770b661123Smrg case $file:$destfile in 31780b661123Smrg *.exe:*.exe) 31790b661123Smrg # this is ok 31800b661123Smrg ;; 31810b661123Smrg *.exe:*) 31820b661123Smrg destfile=$destfile.exe 31830b661123Smrg ;; 31840b661123Smrg *:*.exe) 31850b661123Smrg func_stripname '' '.exe' "$destfile" 31860b661123Smrg destfile=$func_stripname_result 31870b661123Smrg ;; 31880b661123Smrg esac 318996ce994aSmrg ;; 319096ce994aSmrg esac 31910b661123Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 31920b661123Smrg $opt_dry_run || if test -n "$outputname"; then 31930b661123Smrg ${RM}r "$tmpdir" 31940b661123Smrg fi 31950b661123Smrg ;; 31960b661123Smrg esac 31970b661123Smrg done 3198bdcaa8d0Smrg 31990b661123Smrg for file in $staticlibs; do 32000b661123Smrg func_basename "$file" 32010b661123Smrg name="$func_basename_result" 32020b661123Smrg 32030b661123Smrg # Set up the ranlib parameters. 32040b661123Smrg oldlib="$destdir/$name" 3205880c7e28Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 3206880c7e28Smrg tool_oldlib=$func_to_tool_file_result 32070b661123Smrg 32080b661123Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 32090b661123Smrg 32100b661123Smrg if test -n "$stripme" && test -n "$old_striplib"; then 3211880c7e28Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 32120b661123Smrg fi 32130b661123Smrg 32140b661123Smrg # Do each command in the postinstall commands. 32150b661123Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 32160b661123Smrg done 32170b661123Smrg 32180b661123Smrg test -n "$future_libdirs" && \ 32190b661123Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 32200b661123Smrg 32210b661123Smrg if test -n "$current_libdirs"; then 32220b661123Smrg # Maybe just do a dry run. 32230b661123Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 32240b661123Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 32250b661123Smrg else 32260b661123Smrg exit $EXIT_SUCCESS 32270b661123Smrg fi 32280b661123Smrg} 32290b661123Smrg 3230880c7e28Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 32310b661123Smrg 32320b661123Smrg 32330b661123Smrg# func_generate_dlsyms outputname originator pic_p 32340b661123Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 32350b661123Smrg# a dlpreopen symbol table. 32360b661123Smrgfunc_generate_dlsyms () 32370b661123Smrg{ 32380b661123Smrg $opt_debug 32390b661123Smrg my_outputname="$1" 32400b661123Smrg my_originator="$2" 32410b661123Smrg my_pic_p="${3-no}" 32420b661123Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 32430b661123Smrg my_dlsyms= 32440b661123Smrg 32450b661123Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 32460b661123Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 32470b661123Smrg my_dlsyms="${my_outputname}S.c" 32480b661123Smrg else 32490b661123Smrg func_error "not configured to extract global symbols from dlpreopened files" 32500b661123Smrg fi 32510b661123Smrg fi 32520b661123Smrg 32530b661123Smrg if test -n "$my_dlsyms"; then 32540b661123Smrg case $my_dlsyms in 32550b661123Smrg "") ;; 32560b661123Smrg *.c) 32570b661123Smrg # Discover the nlist of each of the dlfiles. 32580b661123Smrg nlist="$output_objdir/${my_outputname}.nm" 32590b661123Smrg 32600b661123Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 32610b661123Smrg 32620b661123Smrg # Parse the name list into a source file. 32630b661123Smrg func_verbose "creating $output_objdir/$my_dlsyms" 32640b661123Smrg 32650b661123Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 32660b661123Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 32670b661123Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 32680b661123Smrg 32690b661123Smrg#ifdef __cplusplus 32700b661123Smrgextern \"C\" { 32710b661123Smrg#endif 32720b661123Smrg 3273880c7e28Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 3274880c7e28Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 3275880c7e28Smrg#endif 3276880c7e28Smrg 3277880c7e28Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 3278880c7e28Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 3279880c7e28Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 3280880c7e28Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 3281880c7e28Smrg# define LT_DLSYM_CONST 3282880c7e28Smrg#elif defined(__osf__) 3283880c7e28Smrg/* This system does not cope well with relocations in const data. */ 3284880c7e28Smrg# define LT_DLSYM_CONST 3285880c7e28Smrg#else 3286880c7e28Smrg# define LT_DLSYM_CONST const 3287880c7e28Smrg#endif 3288880c7e28Smrg 32890b661123Smrg/* External symbol declarations for the compiler. */\ 32900b661123Smrg" 32910b661123Smrg 32920b661123Smrg if test "$dlself" = yes; then 32930b661123Smrg func_verbose "generating symbol list for \`$output'" 32940b661123Smrg 32950b661123Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 32960b661123Smrg 32970b661123Smrg # Add our own program objects to the symbol list. 3298880c7e28Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 32990b661123Smrg for progfile in $progfiles; do 3300880c7e28Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 3301880c7e28Smrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 3302880c7e28Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 33030b661123Smrg done 33040b661123Smrg 33050b661123Smrg if test -n "$exclude_expsyms"; then 33060b661123Smrg $opt_dry_run || { 33070b661123Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 33080b661123Smrg eval '$MV "$nlist"T "$nlist"' 33090b661123Smrg } 331096ce994aSmrg fi 33110b661123Smrg 33120b661123Smrg if test -n "$export_symbols_regex"; then 33130b661123Smrg $opt_dry_run || { 33140b661123Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 33150b661123Smrg eval '$MV "$nlist"T "$nlist"' 33160b661123Smrg } 33170b661123Smrg fi 33180b661123Smrg 33190b661123Smrg # Prepare the list of exported symbols 33200b661123Smrg if test -z "$export_symbols"; then 33210b661123Smrg export_symbols="$output_objdir/$outputname.exp" 33220b661123Smrg $opt_dry_run || { 33230b661123Smrg $RM $export_symbols 33240b661123Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 33250b661123Smrg case $host in 33260b661123Smrg *cygwin* | *mingw* | *cegcc* ) 33270b661123Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 33280b661123Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 33290b661123Smrg ;; 33300b661123Smrg esac 33310b661123Smrg } 333296ce994aSmrg else 33330b661123Smrg $opt_dry_run || { 33340b661123Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 33350b661123Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 33360b661123Smrg eval '$MV "$nlist"T "$nlist"' 33370b661123Smrg case $host in 3338880c7e28Smrg *cygwin* | *mingw* | *cegcc* ) 33390b661123Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 33400b661123Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 33410b661123Smrg ;; 33420b661123Smrg esac 33430b661123Smrg } 334496ce994aSmrg fi 33450b661123Smrg fi 3346bdcaa8d0Smrg 33470b661123Smrg for dlprefile in $dlprefiles; do 33480b661123Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 33490b661123Smrg func_basename "$dlprefile" 33500b661123Smrg name="$func_basename_result" 3351880c7e28Smrg case $host in 3352880c7e28Smrg *cygwin* | *mingw* | *cegcc* ) 3353880c7e28Smrg # if an import library, we need to obtain dlname 3354880c7e28Smrg if func_win32_import_lib_p "$dlprefile"; then 3355880c7e28Smrg func_tr_sh "$dlprefile" 3356880c7e28Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 3357880c7e28Smrg dlprefile_dlbasename="" 3358880c7e28Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 3359880c7e28Smrg # Use subshell, to avoid clobbering current variable values 3360880c7e28Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 3361880c7e28Smrg if test -n "$dlprefile_dlname" ; then 3362880c7e28Smrg func_basename "$dlprefile_dlname" 3363880c7e28Smrg dlprefile_dlbasename="$func_basename_result" 3364880c7e28Smrg else 3365880c7e28Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 3366880c7e28Smrg $sharedlib_from_linklib_cmd "$dlprefile" 3367880c7e28Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 3368880c7e28Smrg fi 3369880c7e28Smrg fi 3370880c7e28Smrg $opt_dry_run || { 3371880c7e28Smrg if test -n "$dlprefile_dlbasename" ; then 3372880c7e28Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 3373880c7e28Smrg else 3374880c7e28Smrg func_warning "Could not compute DLL name from $name" 3375880c7e28Smrg eval '$ECHO ": $name " >> "$nlist"' 3376880c7e28Smrg fi 3377880c7e28Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3378880c7e28Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 3379880c7e28Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 3380880c7e28Smrg } 3381880c7e28Smrg else # not an import lib 3382880c7e28Smrg $opt_dry_run || { 3383880c7e28Smrg eval '$ECHO ": $name " >> "$nlist"' 3384880c7e28Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3385880c7e28Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3386880c7e28Smrg } 3387880c7e28Smrg fi 3388880c7e28Smrg ;; 3389880c7e28Smrg *) 3390880c7e28Smrg $opt_dry_run || { 3391880c7e28Smrg eval '$ECHO ": $name " >> "$nlist"' 3392880c7e28Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3393880c7e28Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3394880c7e28Smrg } 3395880c7e28Smrg ;; 3396880c7e28Smrg esac 33970b661123Smrg done 33980b661123Smrg 33990b661123Smrg $opt_dry_run || { 34000b661123Smrg # Make sure we have at least an empty file. 34010b661123Smrg test -f "$nlist" || : > "$nlist" 34020b661123Smrg 34030b661123Smrg if test -n "$exclude_expsyms"; then 34040b661123Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 34050b661123Smrg $MV "$nlist"T "$nlist" 340696ce994aSmrg fi 34070b661123Smrg 34080b661123Smrg # Try sorting and uniquifying the output. 34090b661123Smrg if $GREP -v "^: " < "$nlist" | 34100b661123Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 34110b661123Smrg sort -k 3 34120b661123Smrg else 34130b661123Smrg sort +2 34140b661123Smrg fi | 34150b661123Smrg uniq > "$nlist"S; then 34160b661123Smrg : 341796ce994aSmrg else 34180b661123Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 341996ce994aSmrg fi 3420bdcaa8d0Smrg 34210b661123Smrg if test -f "$nlist"S; then 34220b661123Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 342396ce994aSmrg else 3424880c7e28Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 342596ce994aSmrg fi 3426bdcaa8d0Smrg 3427880c7e28Smrg echo >> "$output_objdir/$my_dlsyms" "\ 3428bdcaa8d0Smrg 34290b661123Smrg/* The mapping between symbol names and symbols. */ 34300b661123Smrgtypedef struct { 34310b661123Smrg const char *name; 34320b661123Smrg void *address; 34330b661123Smrg} lt_dlsymlist; 3434880c7e28Smrgextern LT_DLSYM_CONST lt_dlsymlist 34350b661123Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 3436880c7e28SmrgLT_DLSYM_CONST lt_dlsymlist 34370b661123Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 34380b661123Smrg{\ 34390b661123Smrg { \"$my_originator\", (void *) 0 }," 3440bdcaa8d0Smrg 34410b661123Smrg case $need_lib_prefix in 34420b661123Smrg no) 34430b661123Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 34440b661123Smrg ;; 34450b661123Smrg *) 34460b661123Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 34470b661123Smrg ;; 34480b661123Smrg esac 3449880c7e28Smrg echo >> "$output_objdir/$my_dlsyms" "\ 34500b661123Smrg {0, (void *) 0} 34510b661123Smrg}; 3452bdcaa8d0Smrg 34530b661123Smrg/* This works around a problem in FreeBSD linker */ 34540b661123Smrg#ifdef FREEBSD_WORKAROUND 34550b661123Smrgstatic const void *lt_preloaded_setup() { 34560b661123Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 34570b661123Smrg} 34580b661123Smrg#endif 34590b661123Smrg 34600b661123Smrg#ifdef __cplusplus 34610b661123Smrg} 34620b661123Smrg#endif\ 34630b661123Smrg" 34640b661123Smrg } # !$opt_dry_run 34650b661123Smrg 34660b661123Smrg pic_flag_for_symtable= 34670b661123Smrg case "$compile_command " in 34680b661123Smrg *" -static "*) ;; 34690b661123Smrg *) 34700b661123Smrg case $host in 34710b661123Smrg # compiling the symbol table file with pic_flag works around 34720b661123Smrg # a FreeBSD bug that causes programs to crash when -lm is 34730b661123Smrg # linked before any other PIC object. But we must not use 34740b661123Smrg # pic_flag when linking with -static. The problem exists in 34750b661123Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 3476880c7e28Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 34770b661123Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 34780b661123Smrg *-*-hpux*) 34790b661123Smrg pic_flag_for_symtable=" $pic_flag" ;; 34800b661123Smrg *) 34810b661123Smrg if test "X$my_pic_p" != Xno; then 34820b661123Smrg pic_flag_for_symtable=" $pic_flag" 348396ce994aSmrg fi 34840b661123Smrg ;; 34850b661123Smrg esac 34860b661123Smrg ;; 34870b661123Smrg esac 34880b661123Smrg symtab_cflags= 34890b661123Smrg for arg in $LTCFLAGS; do 34900b661123Smrg case $arg in 34910b661123Smrg -pie | -fpie | -fPIE) ;; 3492880c7e28Smrg *) func_append symtab_cflags " $arg" ;; 34930b661123Smrg esac 34940b661123Smrg done 3495bdcaa8d0Smrg 34960b661123Smrg # Now compile the dynamic symbol file. 34970b661123Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 3498bdcaa8d0Smrg 34990b661123Smrg # Clean up the generated files. 35000b661123Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 3501bdcaa8d0Smrg 35020b661123Smrg # Transform the symbol file into the correct name. 35030b661123Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 35040b661123Smrg case $host in 35050b661123Smrg *cygwin* | *mingw* | *cegcc* ) 35060b661123Smrg if test -f "$output_objdir/$my_outputname.def"; then 3507880c7e28Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3508880c7e28Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 35090b661123Smrg else 3510880c7e28Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3511880c7e28Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351296ce994aSmrg fi 35130b661123Smrg ;; 35140b661123Smrg *) 3515880c7e28Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3516880c7e28Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 35170b661123Smrg ;; 35180b661123Smrg esac 35190b661123Smrg ;; 35200b661123Smrg *) 35210b661123Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 35220b661123Smrg ;; 35230b661123Smrg esac 35240b661123Smrg else 35250b661123Smrg # We keep going just in case the user didn't refer to 35260b661123Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 35270b661123Smrg # really was required. 3528bdcaa8d0Smrg 35290b661123Smrg # Nullify the symbol file. 3530880c7e28Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 3531880c7e28Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 35320b661123Smrg fi 35330b661123Smrg} 3534bdcaa8d0Smrg 35350b661123Smrg# func_win32_libid arg 35360b661123Smrg# return the library type of file 'arg' 35370b661123Smrg# 35380b661123Smrg# Need a lot of goo to handle *both* DLLs and import libs 35390b661123Smrg# Has to be a shell function in order to 'eat' the argument 35400b661123Smrg# that is supplied when $file_magic_command is called. 3541880c7e28Smrg# Despite the name, also deal with 64 bit binaries. 35420b661123Smrgfunc_win32_libid () 35430b661123Smrg{ 35440b661123Smrg $opt_debug 35450b661123Smrg win32_libid_type="unknown" 35460b661123Smrg win32_fileres=`file -L $1 2>/dev/null` 35470b661123Smrg case $win32_fileres in 35480b661123Smrg *ar\ archive\ import\ library*) # definitely import 35490b661123Smrg win32_libid_type="x86 archive import" 35500b661123Smrg ;; 35510b661123Smrg *ar\ archive*) # could be an import, or static 3552880c7e28Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 35530b661123Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 3554880c7e28Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 3555880c7e28Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3556880c7e28Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 35570b661123Smrg $SED -n -e ' 35580b661123Smrg 1,100{ 35590b661123Smrg / I /{ 35600b661123Smrg s,.*,import, 35610b661123Smrg p 35620b661123Smrg q 35630b661123Smrg } 35640b661123Smrg }'` 35650b661123Smrg case $win32_nmres in 35660b661123Smrg import*) win32_libid_type="x86 archive import";; 35670b661123Smrg *) win32_libid_type="x86 archive static";; 35680b661123Smrg esac 35690b661123Smrg fi 35700b661123Smrg ;; 35710b661123Smrg *DLL*) 35720b661123Smrg win32_libid_type="x86 DLL" 35730b661123Smrg ;; 35740b661123Smrg *executable*) # but shell scripts are "executable" too... 35750b661123Smrg case $win32_fileres in 35760b661123Smrg *MS\ Windows\ PE\ Intel*) 35770b661123Smrg win32_libid_type="x86 DLL" 35780b661123Smrg ;; 35790b661123Smrg esac 35800b661123Smrg ;; 35810b661123Smrg esac 35820b661123Smrg $ECHO "$win32_libid_type" 35830b661123Smrg} 3584bdcaa8d0Smrg 3585880c7e28Smrg# func_cygming_dll_for_implib ARG 3586880c7e28Smrg# 3587880c7e28Smrg# Platform-specific function to extract the 3588880c7e28Smrg# name of the DLL associated with the specified 3589880c7e28Smrg# import library ARG. 3590880c7e28Smrg# Invoked by eval'ing the libtool variable 3591880c7e28Smrg# $sharedlib_from_linklib_cmd 3592880c7e28Smrg# Result is available in the variable 3593880c7e28Smrg# $sharedlib_from_linklib_result 3594880c7e28Smrgfunc_cygming_dll_for_implib () 3595880c7e28Smrg{ 3596880c7e28Smrg $opt_debug 3597880c7e28Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 3598880c7e28Smrg} 3599880c7e28Smrg 3600880c7e28Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 3601880c7e28Smrg# 3602880c7e28Smrg# The is the core of a fallback implementation of a 3603880c7e28Smrg# platform-specific function to extract the name of the 3604880c7e28Smrg# DLL associated with the specified import library LIBNAME. 3605880c7e28Smrg# 3606880c7e28Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 3607880c7e28Smrg# on the platform and compiler that created the implib. 3608880c7e28Smrg# 3609880c7e28Smrg# Echos the name of the DLL associated with the 3610880c7e28Smrg# specified import library. 3611880c7e28Smrgfunc_cygming_dll_for_implib_fallback_core () 3612880c7e28Smrg{ 3613880c7e28Smrg $opt_debug 3614880c7e28Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 3615880c7e28Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 3616880c7e28Smrg $SED '/^Contents of section '"$match_literal"':/{ 3617880c7e28Smrg # Place marker at beginning of archive member dllname section 3618880c7e28Smrg s/.*/====MARK====/ 3619880c7e28Smrg p 3620880c7e28Smrg d 3621880c7e28Smrg } 3622880c7e28Smrg # These lines can sometimes be longer than 43 characters, but 3623880c7e28Smrg # are always uninteresting 3624880c7e28Smrg /:[ ]*file format pe[i]\{,1\}-/d 3625880c7e28Smrg /^In archive [^:]*:/d 3626880c7e28Smrg # Ensure marker is printed 3627880c7e28Smrg /^====MARK====/p 3628880c7e28Smrg # Remove all lines with less than 43 characters 3629880c7e28Smrg /^.\{43\}/!d 3630880c7e28Smrg # From remaining lines, remove first 43 characters 3631880c7e28Smrg s/^.\{43\}//' | 3632880c7e28Smrg $SED -n ' 3633880c7e28Smrg # Join marker and all lines until next marker into a single line 3634880c7e28Smrg /^====MARK====/ b para 3635880c7e28Smrg H 3636880c7e28Smrg $ b para 3637880c7e28Smrg b 3638880c7e28Smrg :para 3639880c7e28Smrg x 3640880c7e28Smrg s/\n//g 3641880c7e28Smrg # Remove the marker 3642880c7e28Smrg s/^====MARK====// 3643880c7e28Smrg # Remove trailing dots and whitespace 3644880c7e28Smrg s/[\. \t]*$// 3645880c7e28Smrg # Print 3646880c7e28Smrg /./p' | 3647880c7e28Smrg # we now have a list, one entry per line, of the stringified 3648880c7e28Smrg # contents of the appropriate section of all members of the 3649880c7e28Smrg # archive which possess that section. Heuristic: eliminate 3650880c7e28Smrg # all those which have a first or second character that is 3651880c7e28Smrg # a '.' (that is, objdump's representation of an unprintable 3652880c7e28Smrg # character.) This should work for all archives with less than 3653880c7e28Smrg # 0x302f exports -- but will fail for DLLs whose name actually 3654880c7e28Smrg # begins with a literal '.' or a single character followed by 3655880c7e28Smrg # a '.'. 3656880c7e28Smrg # 3657880c7e28Smrg # Of those that remain, print the first one. 3658880c7e28Smrg $SED -e '/^\./d;/^.\./d;q' 3659880c7e28Smrg} 3660880c7e28Smrg 3661880c7e28Smrg# func_cygming_gnu_implib_p ARG 3662880c7e28Smrg# This predicate returns with zero status (TRUE) if 3663880c7e28Smrg# ARG is a GNU/binutils-style import library. Returns 3664880c7e28Smrg# with nonzero status (FALSE) otherwise. 3665880c7e28Smrgfunc_cygming_gnu_implib_p () 3666880c7e28Smrg{ 3667880c7e28Smrg $opt_debug 3668880c7e28Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3669880c7e28Smrg 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)$'` 3670880c7e28Smrg test -n "$func_cygming_gnu_implib_tmp" 3671880c7e28Smrg} 3672880c7e28Smrg 3673880c7e28Smrg# func_cygming_ms_implib_p ARG 3674880c7e28Smrg# This predicate returns with zero status (TRUE) if 3675880c7e28Smrg# ARG is an MS-style import library. Returns 3676880c7e28Smrg# with nonzero status (FALSE) otherwise. 3677880c7e28Smrgfunc_cygming_ms_implib_p () 3678880c7e28Smrg{ 3679880c7e28Smrg $opt_debug 3680880c7e28Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3681880c7e28Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 3682880c7e28Smrg test -n "$func_cygming_ms_implib_tmp" 3683880c7e28Smrg} 3684880c7e28Smrg 3685880c7e28Smrg# func_cygming_dll_for_implib_fallback ARG 3686880c7e28Smrg# Platform-specific function to extract the 3687880c7e28Smrg# name of the DLL associated with the specified 3688880c7e28Smrg# import library ARG. 3689880c7e28Smrg# 3690880c7e28Smrg# This fallback implementation is for use when $DLLTOOL 3691880c7e28Smrg# does not support the --identify-strict option. 3692880c7e28Smrg# Invoked by eval'ing the libtool variable 3693880c7e28Smrg# $sharedlib_from_linklib_cmd 3694880c7e28Smrg# Result is available in the variable 3695880c7e28Smrg# $sharedlib_from_linklib_result 3696880c7e28Smrgfunc_cygming_dll_for_implib_fallback () 3697880c7e28Smrg{ 3698880c7e28Smrg $opt_debug 3699880c7e28Smrg if func_cygming_gnu_implib_p "$1" ; then 3700880c7e28Smrg # binutils import library 3701880c7e28Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 3702880c7e28Smrg elif func_cygming_ms_implib_p "$1" ; then 3703880c7e28Smrg # ms-generated import library 3704880c7e28Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 3705880c7e28Smrg else 3706880c7e28Smrg # unknown 3707880c7e28Smrg sharedlib_from_linklib_result="" 3708880c7e28Smrg fi 3709880c7e28Smrg} 3710bdcaa8d0Smrg 3711bdcaa8d0Smrg 37120b661123Smrg# func_extract_an_archive dir oldlib 37130b661123Smrgfunc_extract_an_archive () 37140b661123Smrg{ 37150b661123Smrg $opt_debug 37160b661123Smrg f_ex_an_ar_dir="$1"; shift 37170b661123Smrg f_ex_an_ar_oldlib="$1" 3718880c7e28Smrg if test "$lock_old_archive_extraction" = yes; then 3719880c7e28Smrg lockfile=$f_ex_an_ar_oldlib.lock 3720880c7e28Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3721880c7e28Smrg func_echo "Waiting for $lockfile to be removed" 3722880c7e28Smrg sleep 2 3723880c7e28Smrg done 3724880c7e28Smrg fi 3725880c7e28Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 3726880c7e28Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 3727880c7e28Smrg if test "$lock_old_archive_extraction" = yes; then 3728880c7e28Smrg $opt_dry_run || rm -f "$lockfile" 3729880c7e28Smrg fi 37300b661123Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 37310b661123Smrg : 37320b661123Smrg else 37330b661123Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 37340b661123Smrg fi 37350b661123Smrg} 3736bdcaa8d0Smrg 3737bdcaa8d0Smrg 37380b661123Smrg# func_extract_archives gentop oldlib ... 37390b661123Smrgfunc_extract_archives () 37400b661123Smrg{ 37410b661123Smrg $opt_debug 37420b661123Smrg my_gentop="$1"; shift 37430b661123Smrg my_oldlibs=${1+"$@"} 37440b661123Smrg my_oldobjs="" 37450b661123Smrg my_xlib="" 37460b661123Smrg my_xabs="" 37470b661123Smrg my_xdir="" 3748bdcaa8d0Smrg 37490b661123Smrg for my_xlib in $my_oldlibs; do 37500b661123Smrg # Extract the objects. 37510b661123Smrg case $my_xlib in 37520b661123Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 37530b661123Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 37540b661123Smrg esac 37550b661123Smrg func_basename "$my_xlib" 37560b661123Smrg my_xlib="$func_basename_result" 37570b661123Smrg my_xlib_u=$my_xlib 37580b661123Smrg while :; do 37590b661123Smrg case " $extracted_archives " in 37600b661123Smrg *" $my_xlib_u "*) 37610b661123Smrg func_arith $extracted_serial + 1 37620b661123Smrg extracted_serial=$func_arith_result 37630b661123Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 37640b661123Smrg *) break ;; 37650b661123Smrg esac 37660b661123Smrg done 37670b661123Smrg extracted_archives="$extracted_archives $my_xlib_u" 37680b661123Smrg my_xdir="$my_gentop/$my_xlib_u" 3769bdcaa8d0Smrg 37700b661123Smrg func_mkdir_p "$my_xdir" 3771bdcaa8d0Smrg 37720b661123Smrg case $host in 37730b661123Smrg *-darwin*) 37740b661123Smrg func_verbose "Extracting $my_xabs" 37750b661123Smrg # Do not bother doing anything if just a dry run 37760b661123Smrg $opt_dry_run || { 37770b661123Smrg darwin_orig_dir=`pwd` 37780b661123Smrg cd $my_xdir || exit $? 37790b661123Smrg darwin_archive=$my_xabs 37800b661123Smrg darwin_curdir=`pwd` 37810b661123Smrg darwin_base_archive=`basename "$darwin_archive"` 37820b661123Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 37830b661123Smrg if test -n "$darwin_arches"; then 37840b661123Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 37850b661123Smrg darwin_arch= 37860b661123Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 37870b661123Smrg for darwin_arch in $darwin_arches ; do 37880b661123Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 37890b661123Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 37900b661123Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 37910b661123Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 37920b661123Smrg cd "$darwin_curdir" 37930b661123Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 37940b661123Smrg done # $darwin_arches 37950b661123Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 37960b661123Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 37970b661123Smrg darwin_file= 37980b661123Smrg darwin_files= 37990b661123Smrg for darwin_file in $darwin_filelist; do 3800880c7e28Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 38010b661123Smrg $LIPO -create -output "$darwin_file" $darwin_files 38020b661123Smrg done # $darwin_filelist 38030b661123Smrg $RM -rf unfat-$$ 38040b661123Smrg cd "$darwin_orig_dir" 380596ce994aSmrg else 38060b661123Smrg cd $darwin_orig_dir 38070b661123Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 38080b661123Smrg fi # $darwin_arches 38090b661123Smrg } # !$opt_dry_run 38100b661123Smrg ;; 38110b661123Smrg *) 38120b661123Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 38130b661123Smrg ;; 38140b661123Smrg esac 3815880c7e28Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 38160b661123Smrg done 3817bdcaa8d0Smrg 38180b661123Smrg func_extract_archives_result="$my_oldobjs" 38190b661123Smrg} 3820bdcaa8d0Smrg 3821bdcaa8d0Smrg 3822880c7e28Smrg# func_emit_wrapper [arg=no] 3823880c7e28Smrg# 3824880c7e28Smrg# Emit a libtool wrapper script on stdout. 3825880c7e28Smrg# Don't directly open a file because we may want to 3826880c7e28Smrg# incorporate the script contents within a cygwin/mingw 3827880c7e28Smrg# wrapper executable. Must ONLY be called from within 3828880c7e28Smrg# func_mode_link because it depends on a number of variables 3829880c7e28Smrg# set therein. 38300b661123Smrg# 3831880c7e28Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 3832880c7e28Smrg# variable will take. If 'yes', then the emitted script 3833880c7e28Smrg# will assume that the directory in which it is stored is 3834880c7e28Smrg# the $objdir directory. This is a cygwin/mingw-specific 3835880c7e28Smrg# behavior. 3836880c7e28Smrgfunc_emit_wrapper () 38370b661123Smrg{ 3838880c7e28Smrg func_emit_wrapper_arg1=${1-no} 383996ce994aSmrg 38400b661123Smrg $ECHO "\ 38410b661123Smrg#! $SHELL 384272313efbSmrg 38430b661123Smrg# $output - temporary wrapper script for $objdir/$outputname 38440b661123Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 38450b661123Smrg# 38460b661123Smrg# The $output program cannot be directly executed until all the libtool 38470b661123Smrg# libraries that it depends on are installed. 38480b661123Smrg# 38490b661123Smrg# This wrapper script should never be moved out of the build directory. 38500b661123Smrg# If it is, it will not operate correctly. 385172313efbSmrg 38520b661123Smrg# Sed substitution that helps us do robust quoting. It backslashifies 38530b661123Smrg# metacharacters that are still active within double-quoted strings. 38540b661123Smrgsed_quote_subst='$sed_quote_subst' 3855bdcaa8d0Smrg 38560b661123Smrg# Be Bourne compatible 38570b661123Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 38580b661123Smrg emulate sh 38590b661123Smrg NULLCMD=: 38600b661123Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 38610b661123Smrg # is contrary to our usage. Disable this feature. 38620b661123Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 38630b661123Smrg setopt NO_GLOB_SUBST 38640b661123Smrgelse 38650b661123Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 38660b661123Smrgfi 38670b661123SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 38680b661123SmrgDUALCASE=1; export DUALCASE # for MKS sh 3869bdcaa8d0Smrg 38700b661123Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 38710b661123Smrg# if CDPATH is set. 38720b661123Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 3873bdcaa8d0Smrg 38740b661123Smrgrelink_command=\"$relink_command\" 3875bdcaa8d0Smrg 38760b661123Smrg# This environment variable determines our operation mode. 38770b661123Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 38780b661123Smrg # install mode needs the following variables: 38790b661123Smrg generated_by_libtool_version='$macro_version' 38800b661123Smrg notinst_deplibs='$notinst_deplibs' 38810b661123Smrgelse 38820b661123Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 38830b661123Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 3884880c7e28Smrg file=\"\$0\"" 3885880c7e28Smrg 3886880c7e28Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 3887880c7e28Smrg $ECHO "\ 3888880c7e28Smrg 3889880c7e28Smrg# A function that is used when there is no print builtin or printf. 3890880c7e28Smrgfunc_fallback_echo () 3891880c7e28Smrg{ 3892880c7e28Smrg eval 'cat <<_LTECHO_EOF 3893880c7e28Smrg\$1 3894880c7e28Smrg_LTECHO_EOF' 3895880c7e28Smrg} 3896880c7e28Smrg ECHO=\"$qECHO\" 3897880c7e28Smrg fi 3898880c7e28Smrg 3899880c7e28Smrg# Very basic option parsing. These options are (a) specific to 3900880c7e28Smrg# the libtool wrapper, (b) are identical between the wrapper 3901880c7e28Smrg# /script/ and the wrapper /executable/ which is used only on 3902880c7e28Smrg# windows platforms, and (c) all begin with the string "--lt-" 3903880c7e28Smrg# (application programs are unlikely to have options which match 3904880c7e28Smrg# this pattern). 3905880c7e28Smrg# 3906880c7e28Smrg# There are only two supported options: --lt-debug and 3907880c7e28Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 3908880c7e28Smrg# 3909880c7e28Smrg# The first argument to this parsing function should be the 3910880c7e28Smrg# script's $0 value, followed by "$@". 3911880c7e28Smrglt_option_debug= 3912880c7e28Smrgfunc_parse_lt_options () 3913880c7e28Smrg{ 3914880c7e28Smrg lt_script_arg0=\$0 3915880c7e28Smrg shift 3916880c7e28Smrg for lt_opt 3917880c7e28Smrg do 3918880c7e28Smrg case \"\$lt_opt\" in 3919880c7e28Smrg --lt-debug) lt_option_debug=1 ;; 3920880c7e28Smrg --lt-dump-script) 3921880c7e28Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 3922880c7e28Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 3923880c7e28Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 3924880c7e28Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 3925880c7e28Smrg exit 0 3926880c7e28Smrg ;; 3927880c7e28Smrg --lt-*) 3928880c7e28Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 3929880c7e28Smrg exit 1 3930880c7e28Smrg ;; 3931880c7e28Smrg esac 3932880c7e28Smrg done 3933880c7e28Smrg 3934880c7e28Smrg # Print the debug banner immediately: 3935880c7e28Smrg if test -n \"\$lt_option_debug\"; then 3936880c7e28Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 3937880c7e28Smrg fi 3938880c7e28Smrg} 3939880c7e28Smrg 3940880c7e28Smrg# Used when --lt-debug. Prints its arguments to stdout 3941880c7e28Smrg# (redirection is the responsibility of the caller) 3942880c7e28Smrgfunc_lt_dump_args () 3943880c7e28Smrg{ 3944880c7e28Smrg lt_dump_args_N=1; 3945880c7e28Smrg for lt_arg 3946880c7e28Smrg do 3947880c7e28Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 3948880c7e28Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 3949880c7e28Smrg done 3950880c7e28Smrg} 3951880c7e28Smrg 3952880c7e28Smrg# Core function for launching the target application 3953880c7e28Smrgfunc_exec_program_core () 3954880c7e28Smrg{ 39550b661123Smrg" 3956880c7e28Smrg case $host in 3957880c7e28Smrg # Backslashes separate directories on plain windows 3958880c7e28Smrg *-*-mingw | *-*-os2* | *-cegcc*) 3959880c7e28Smrg $ECHO "\ 3960880c7e28Smrg if test -n \"\$lt_option_debug\"; then 3961880c7e28Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 3962880c7e28Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 3963880c7e28Smrg fi 3964880c7e28Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 3965880c7e28Smrg" 3966880c7e28Smrg ;; 3967880c7e28Smrg 3968880c7e28Smrg *) 3969880c7e28Smrg $ECHO "\ 3970880c7e28Smrg if test -n \"\$lt_option_debug\"; then 3971880c7e28Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 3972880c7e28Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 3973880c7e28Smrg fi 3974880c7e28Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 3975880c7e28Smrg" 3976880c7e28Smrg ;; 3977880c7e28Smrg esac 3978880c7e28Smrg $ECHO "\ 3979880c7e28Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 3980880c7e28Smrg exit 1 3981880c7e28Smrg} 3982880c7e28Smrg 3983880c7e28Smrg# A function to encapsulate launching the target application 3984880c7e28Smrg# Strips options in the --lt-* namespace from \$@ and 3985880c7e28Smrg# launches target application with the remaining arguments. 3986880c7e28Smrgfunc_exec_program () 3987880c7e28Smrg{ 3988880c7e28Smrg case \" \$* \" in 3989880c7e28Smrg *\\ --lt-*) 3990880c7e28Smrg for lt_wr_arg 3991880c7e28Smrg do 3992880c7e28Smrg case \$lt_wr_arg in 3993880c7e28Smrg --lt-*) ;; 3994880c7e28Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 3995880c7e28Smrg esac 3996880c7e28Smrg shift 3997880c7e28Smrg done ;; 3998880c7e28Smrg esac 3999880c7e28Smrg func_exec_program_core \${1+\"\$@\"} 4000880c7e28Smrg} 4001880c7e28Smrg 4002880c7e28Smrg # Parse options 4003880c7e28Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 4004bdcaa8d0Smrg 40050b661123Smrg # Find the directory that this script lives in. 4006880c7e28Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 40070b661123Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 4008bdcaa8d0Smrg 40090b661123Smrg # Follow symbolic links until we get to the real thisdir. 4010880c7e28Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 40110b661123Smrg while test -n \"\$file\"; do 4012880c7e28Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 4013bdcaa8d0Smrg 40140b661123Smrg # If there was a directory component, then change thisdir. 40150b661123Smrg if test \"x\$destdir\" != \"x\$file\"; then 40160b661123Smrg case \"\$destdir\" in 40170b661123Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 40180b661123Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 401996ce994aSmrg esac 40200b661123Smrg fi 402172313efbSmrg 4022880c7e28Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 4023880c7e28Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 40240b661123Smrg done 402572313efbSmrg 40260b661123Smrg # Usually 'no', except on cygwin/mingw when embedded into 40270b661123Smrg # the cwrapper. 4028880c7e28Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 40290b661123Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 40300b661123Smrg # special case for '.' 40310b661123Smrg if test \"\$thisdir\" = \".\"; then 40320b661123Smrg thisdir=\`pwd\` 40330b661123Smrg fi 40340b661123Smrg # remove .libs from thisdir 40350b661123Smrg case \"\$thisdir\" in 4036880c7e28Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 40370b661123Smrg $objdir ) thisdir=. ;; 40380b661123Smrg esac 40390b661123Smrg fi 40400b661123Smrg 40410b661123Smrg # Try to get the absolute directory name. 40420b661123Smrg absdir=\`cd \"\$thisdir\" && pwd\` 40430b661123Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 40440b661123Smrg" 40450b661123Smrg 40460b661123Smrg if test "$fast_install" = yes; then 40470b661123Smrg $ECHO "\ 40480b661123Smrg program=lt-'$outputname'$exeext 40490b661123Smrg progdir=\"\$thisdir/$objdir\" 40500b661123Smrg 40510b661123Smrg if test ! -f \"\$progdir/\$program\" || 40520b661123Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 40530b661123Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 40540b661123Smrg 40550b661123Smrg file=\"\$\$-\$program\" 40560b661123Smrg 40570b661123Smrg if test ! -d \"\$progdir\"; then 40580b661123Smrg $MKDIR \"\$progdir\" 40590b661123Smrg else 40600b661123Smrg $RM \"\$progdir/\$file\" 40610b661123Smrg fi" 40620b661123Smrg 40630b661123Smrg $ECHO "\ 40640b661123Smrg 40650b661123Smrg # relink executable if necessary 40660b661123Smrg if test -n \"\$relink_command\"; then 40670b661123Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 40680b661123Smrg else 40690b661123Smrg $ECHO \"\$relink_command_output\" >&2 40700b661123Smrg $RM \"\$progdir/\$file\" 40710b661123Smrg exit 1 407296ce994aSmrg fi 40730b661123Smrg fi 407472313efbSmrg 40750b661123Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 40760b661123Smrg { $RM \"\$progdir/\$program\"; 40770b661123Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 40780b661123Smrg $RM \"\$progdir/\$file\" 40790b661123Smrg fi" 40800b661123Smrg else 40810b661123Smrg $ECHO "\ 40820b661123Smrg program='$outputname' 40830b661123Smrg progdir=\"\$thisdir/$objdir\" 40840b661123Smrg" 408596ce994aSmrg fi 408672313efbSmrg 40870b661123Smrg $ECHO "\ 408872313efbSmrg 40890b661123Smrg if test -f \"\$progdir/\$program\"; then" 409072313efbSmrg 4091880c7e28Smrg # fixup the dll searchpath if we need to. 4092880c7e28Smrg # 4093880c7e28Smrg # Fix the DLL searchpath if we need to. Do this before prepending 4094880c7e28Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 4095880c7e28Smrg # libraries must come first. 4096880c7e28Smrg if test -n "$dllsearchpath"; then 4097880c7e28Smrg $ECHO "\ 4098880c7e28Smrg # Add the dll search path components to the executable PATH 4099880c7e28Smrg PATH=$dllsearchpath:\$PATH 4100880c7e28Smrg" 4101880c7e28Smrg fi 4102880c7e28Smrg 41030b661123Smrg # Export our shlibpath_var if we have one. 41040b661123Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 41050b661123Smrg $ECHO "\ 41060b661123Smrg # Add our own library path to $shlibpath_var 41070b661123Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 41080b661123Smrg 41090b661123Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 41100b661123Smrg # The second colon is a workaround for a bug in BeOS R4 sed 4111880c7e28Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 411272313efbSmrg 41130b661123Smrg export $shlibpath_var 41140b661123Smrg" 411596ce994aSmrg fi 411672313efbSmrg 41170b661123Smrg $ECHO "\ 41180b661123Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 41190b661123Smrg # Run the actual program with our arguments. 4120880c7e28Smrg func_exec_program \${1+\"\$@\"} 41210b661123Smrg fi 41220b661123Smrg else 41230b661123Smrg # The program doesn't exist. 41240b661123Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 41250b661123Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 4126880c7e28Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 41270b661123Smrg exit 1 41280b661123Smrg fi 41290b661123Smrgfi\ 41300b661123Smrg" 41310b661123Smrg} 413272313efbSmrg 413372313efbSmrg 41340b661123Smrg# func_emit_cwrapperexe_src 41350b661123Smrg# emit the source code for a wrapper executable on stdout 41360b661123Smrg# Must ONLY be called from within func_mode_link because 41370b661123Smrg# it depends on a number of variable set therein. 41380b661123Smrgfunc_emit_cwrapperexe_src () 41390b661123Smrg{ 41400b661123Smrg cat <<EOF 4141bdcaa8d0Smrg 41420b661123Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 41430b661123Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4144bdcaa8d0Smrg 41450b661123Smrg The $output program cannot be directly executed until all the libtool 41460b661123Smrg libraries that it depends on are installed. 4147bdcaa8d0Smrg 41480b661123Smrg This wrapper executable should never be moved out of the build directory. 41490b661123Smrg If it is, it will not operate correctly. 41500b661123Smrg*/ 41510b661123SmrgEOF 41520b661123Smrg cat <<"EOF" 4153880c7e28Smrg#ifdef _MSC_VER 4154880c7e28Smrg# define _CRT_SECURE_NO_DEPRECATE 1 4155880c7e28Smrg#endif 41560b661123Smrg#include <stdio.h> 41570b661123Smrg#include <stdlib.h> 41580b661123Smrg#ifdef _MSC_VER 41590b661123Smrg# include <direct.h> 41600b661123Smrg# include <process.h> 41610b661123Smrg# include <io.h> 41620b661123Smrg#else 41630b661123Smrg# include <unistd.h> 41640b661123Smrg# include <stdint.h> 41650b661123Smrg# ifdef __CYGWIN__ 41660b661123Smrg# include <io.h> 41670b661123Smrg# endif 41680b661123Smrg#endif 41690b661123Smrg#include <malloc.h> 41700b661123Smrg#include <stdarg.h> 41710b661123Smrg#include <assert.h> 41720b661123Smrg#include <string.h> 41730b661123Smrg#include <ctype.h> 41740b661123Smrg#include <errno.h> 41750b661123Smrg#include <fcntl.h> 41760b661123Smrg#include <sys/stat.h> 4177bdcaa8d0Smrg 4178880c7e28Smrg/* declarations of non-ANSI functions */ 4179880c7e28Smrg#if defined(__MINGW32__) 4180880c7e28Smrg# ifdef __STRICT_ANSI__ 4181880c7e28Smrgint _putenv (const char *); 4182880c7e28Smrg# endif 4183880c7e28Smrg#elif defined(__CYGWIN__) 4184880c7e28Smrg# ifdef __STRICT_ANSI__ 4185880c7e28Smrgchar *realpath (const char *, char *); 4186880c7e28Smrgint putenv (char *); 4187880c7e28Smrgint setenv (const char *, const char *, int); 4188880c7e28Smrg# endif 4189880c7e28Smrg/* #elif defined (other platforms) ... */ 4190880c7e28Smrg#endif 4191880c7e28Smrg 4192880c7e28Smrg/* portability defines, excluding path handling macros */ 4193880c7e28Smrg#if defined(_MSC_VER) 4194880c7e28Smrg# define setmode _setmode 4195880c7e28Smrg# define stat _stat 4196880c7e28Smrg# define chmod _chmod 4197880c7e28Smrg# define getcwd _getcwd 4198880c7e28Smrg# define putenv _putenv 4199880c7e28Smrg# define S_IXUSR _S_IEXEC 4200880c7e28Smrg# ifndef _INTPTR_T_DEFINED 4201880c7e28Smrg# define _INTPTR_T_DEFINED 4202880c7e28Smrg# define intptr_t int 4203880c7e28Smrg# endif 4204880c7e28Smrg#elif defined(__MINGW32__) 4205880c7e28Smrg# define setmode _setmode 4206880c7e28Smrg# define stat _stat 4207880c7e28Smrg# define chmod _chmod 4208880c7e28Smrg# define getcwd _getcwd 4209880c7e28Smrg# define putenv _putenv 4210880c7e28Smrg#elif defined(__CYGWIN__) 4211880c7e28Smrg# define HAVE_SETENV 4212880c7e28Smrg# define FOPEN_WB "wb" 4213880c7e28Smrg/* #elif defined (other platforms) ... */ 4214880c7e28Smrg#endif 4215880c7e28Smrg 42160b661123Smrg#if defined(PATH_MAX) 42170b661123Smrg# define LT_PATHMAX PATH_MAX 42180b661123Smrg#elif defined(MAXPATHLEN) 42190b661123Smrg# define LT_PATHMAX MAXPATHLEN 42200b661123Smrg#else 42210b661123Smrg# define LT_PATHMAX 1024 42220b661123Smrg#endif 4223bdcaa8d0Smrg 42240b661123Smrg#ifndef S_IXOTH 42250b661123Smrg# define S_IXOTH 0 42260b661123Smrg#endif 42270b661123Smrg#ifndef S_IXGRP 42280b661123Smrg# define S_IXGRP 0 42290b661123Smrg#endif 4230bdcaa8d0Smrg 4231880c7e28Smrg/* path handling portability macros */ 42320b661123Smrg#ifndef DIR_SEPARATOR 42330b661123Smrg# define DIR_SEPARATOR '/' 42340b661123Smrg# define PATH_SEPARATOR ':' 42350b661123Smrg#endif 4236bdcaa8d0Smrg 42370b661123Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 42380b661123Smrg defined (__OS2__) 42390b661123Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 42400b661123Smrg# define FOPEN_WB "wb" 42410b661123Smrg# ifndef DIR_SEPARATOR_2 42420b661123Smrg# define DIR_SEPARATOR_2 '\\' 42430b661123Smrg# endif 42440b661123Smrg# ifndef PATH_SEPARATOR_2 42450b661123Smrg# define PATH_SEPARATOR_2 ';' 42460b661123Smrg# endif 42470b661123Smrg#endif 4248bdcaa8d0Smrg 42490b661123Smrg#ifndef DIR_SEPARATOR_2 42500b661123Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 42510b661123Smrg#else /* DIR_SEPARATOR_2 */ 42520b661123Smrg# define IS_DIR_SEPARATOR(ch) \ 42530b661123Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 42540b661123Smrg#endif /* DIR_SEPARATOR_2 */ 4255bdcaa8d0Smrg 42560b661123Smrg#ifndef PATH_SEPARATOR_2 42570b661123Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 42580b661123Smrg#else /* PATH_SEPARATOR_2 */ 42590b661123Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 42600b661123Smrg#endif /* PATH_SEPARATOR_2 */ 4261bdcaa8d0Smrg 42620b661123Smrg#ifndef FOPEN_WB 42630b661123Smrg# define FOPEN_WB "w" 42640b661123Smrg#endif 42650b661123Smrg#ifndef _O_BINARY 42660b661123Smrg# define _O_BINARY 0 42670b661123Smrg#endif 4268bdcaa8d0Smrg 42690b661123Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 42700b661123Smrg#define XFREE(stale) do { \ 42710b661123Smrg if (stale) { free ((void *) stale); stale = 0; } \ 42720b661123Smrg} while (0) 4273bdcaa8d0Smrg 4274880c7e28Smrg#if defined(LT_DEBUGWRAPPER) 4275880c7e28Smrgstatic int lt_debug = 1; 42760b661123Smrg#else 4277880c7e28Smrgstatic int lt_debug = 0; 42780b661123Smrg#endif 4279bdcaa8d0Smrg 4280880c7e28Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 4281bdcaa8d0Smrg 42820b661123Smrgvoid *xmalloc (size_t num); 42830b661123Smrgchar *xstrdup (const char *string); 42840b661123Smrgconst char *base_name (const char *name); 42850b661123Smrgchar *find_executable (const char *wrapper); 42860b661123Smrgchar *chase_symlinks (const char *pathspec); 42870b661123Smrgint make_executable (const char *path); 42880b661123Smrgint check_executable (const char *path); 42890b661123Smrgchar *strendzap (char *str, const char *pat); 4290880c7e28Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 4291880c7e28Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 4292880c7e28Smrgstatic const char *nonnull (const char *s); 4293880c7e28Smrgstatic const char *nonempty (const char *s); 42940b661123Smrgvoid lt_setenv (const char *name, const char *value); 42950b661123Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 42960b661123Smrgvoid lt_update_exe_path (const char *name, const char *value); 42970b661123Smrgvoid lt_update_lib_path (const char *name, const char *value); 4298880c7e28Smrgchar **prepare_spawn (char **argv); 4299880c7e28Smrgvoid lt_dump_script (FILE *f); 43000b661123SmrgEOF 43010b661123Smrg 43020b661123Smrg cat <<EOF 4303880c7e28Smrgvolatile const char * MAGIC_EXE = "$magic_exe"; 43040b661123Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 43050b661123SmrgEOF 4306bdcaa8d0Smrg 43070b661123Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4308880c7e28Smrg func_to_host_path "$temp_rpath" 43090b661123Smrg cat <<EOF 4310880c7e28Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 43110b661123SmrgEOF 43120b661123Smrg else 43130b661123Smrg cat <<"EOF" 43140b661123Smrgconst char * LIB_PATH_VALUE = ""; 43150b661123SmrgEOF 431696ce994aSmrg fi 4317bdcaa8d0Smrg 43180b661123Smrg if test -n "$dllsearchpath"; then 4319880c7e28Smrg func_to_host_path "$dllsearchpath:" 43200b661123Smrg cat <<EOF 43210b661123Smrgconst char * EXE_PATH_VARNAME = "PATH"; 4322880c7e28Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 432396ce994aSmrgEOF 432496ce994aSmrg else 43250b661123Smrg cat <<"EOF" 43260b661123Smrgconst char * EXE_PATH_VARNAME = ""; 43270b661123Smrgconst char * EXE_PATH_VALUE = ""; 43280b661123SmrgEOF 432996ce994aSmrg fi 43300b661123Smrg 43310b661123Smrg if test "$fast_install" = yes; then 43320b661123Smrg cat <<EOF 43330b661123Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 43340b661123SmrgEOF 433596ce994aSmrg else 43360b661123Smrg cat <<EOF 43370b661123Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 43380b661123SmrgEOF 433996ce994aSmrg fi 4340bdcaa8d0Smrg 4341bdcaa8d0Smrg 43420b661123Smrg cat <<"EOF" 4343bdcaa8d0Smrg 43440b661123Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 4345bdcaa8d0Smrg 43460b661123Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 43470b661123Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 4348880c7e28Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 4349bdcaa8d0Smrg 43500b661123Smrgint 43510b661123Smrgmain (int argc, char *argv[]) 43520b661123Smrg{ 43530b661123Smrg char **newargz; 43540b661123Smrg int newargc; 43550b661123Smrg char *tmp_pathspec; 43560b661123Smrg char *actual_cwrapper_path; 43570b661123Smrg char *actual_cwrapper_name; 43580b661123Smrg char *target_name; 43590b661123Smrg char *lt_argv_zero; 43600b661123Smrg intptr_t rval = 127; 4361bdcaa8d0Smrg 43620b661123Smrg int i; 4363bdcaa8d0Smrg 43640b661123Smrg program_name = (char *) xstrdup (base_name (argv[0])); 4365880c7e28Smrg newargz = XMALLOC (char *, argc + 1); 4366bdcaa8d0Smrg 4367880c7e28Smrg /* very simple arg parsing; don't want to rely on getopt 4368880c7e28Smrg * also, copy all non cwrapper options to newargz, except 4369880c7e28Smrg * argz[0], which is handled differently 4370880c7e28Smrg */ 4371880c7e28Smrg newargc=0; 43720b661123Smrg for (i = 1; i < argc; i++) 43730b661123Smrg { 43740b661123Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 43750b661123Smrg { 43760b661123SmrgEOF 43770b661123Smrg case "$host" in 43780b661123Smrg *mingw* | *cygwin* ) 43790b661123Smrg # make stdout use "unix" line endings 43800b661123Smrg echo " setmode(1,_O_BINARY);" 43810b661123Smrg ;; 43820b661123Smrg esac 4383bdcaa8d0Smrg 43840b661123Smrg cat <<"EOF" 4385880c7e28Smrg lt_dump_script (stdout); 43860b661123Smrg return 0; 43870b661123Smrg } 4388880c7e28Smrg if (strcmp (argv[i], debug_opt) == 0) 4389880c7e28Smrg { 4390880c7e28Smrg lt_debug = 1; 4391880c7e28Smrg continue; 4392880c7e28Smrg } 4393880c7e28Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 4394880c7e28Smrg { 4395880c7e28Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 4396880c7e28Smrg namespace, but it is not one of the ones we know about and 4397880c7e28Smrg have already dealt with, above (inluding dump-script), then 4398880c7e28Smrg report an error. Otherwise, targets might begin to believe 4399880c7e28Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 4400880c7e28Smrg namespace. The first time any user complains about this, we'll 4401880c7e28Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 4402880c7e28Smrg or a configure.ac-settable value. 4403880c7e28Smrg */ 4404880c7e28Smrg lt_fatal (__FILE__, __LINE__, 4405880c7e28Smrg "unrecognized %s option: '%s'", 4406880c7e28Smrg ltwrapper_option_prefix, argv[i]); 4407880c7e28Smrg } 4408880c7e28Smrg /* otherwise ... */ 4409880c7e28Smrg newargz[++newargc] = xstrdup (argv[i]); 44100b661123Smrg } 4411880c7e28Smrg newargz[++newargc] = NULL; 4412880c7e28Smrg 4413880c7e28SmrgEOF 4414880c7e28Smrg cat <<EOF 4415880c7e28Smrg /* The GNU banner must be the first non-error debug message */ 4416880c7e28Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 4417880c7e28SmrgEOF 4418880c7e28Smrg cat <<"EOF" 4419880c7e28Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 4420880c7e28Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 4421bdcaa8d0Smrg 44220b661123Smrg tmp_pathspec = find_executable (argv[0]); 44230b661123Smrg if (tmp_pathspec == NULL) 4424880c7e28Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 4425880c7e28Smrg lt_debugprintf (__FILE__, __LINE__, 4426880c7e28Smrg "(main) found exe (before symlink chase) at: %s\n", 4427880c7e28Smrg tmp_pathspec); 44280b661123Smrg 44290b661123Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 4430880c7e28Smrg lt_debugprintf (__FILE__, __LINE__, 4431880c7e28Smrg "(main) found exe (after symlink chase) at: %s\n", 4432880c7e28Smrg actual_cwrapper_path); 44330b661123Smrg XFREE (tmp_pathspec); 44340b661123Smrg 4435880c7e28Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 44360b661123Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 44370b661123Smrg 44380b661123Smrg /* wrapper name transforms */ 44390b661123Smrg strendzap (actual_cwrapper_name, ".exe"); 44400b661123Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 44410b661123Smrg XFREE (actual_cwrapper_name); 44420b661123Smrg actual_cwrapper_name = tmp_pathspec; 44430b661123Smrg tmp_pathspec = 0; 44440b661123Smrg 44450b661123Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 44460b661123Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 44470b661123Smrg strendzap (target_name, ".exe"); 44480b661123Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 44490b661123Smrg XFREE (target_name); 44500b661123Smrg target_name = tmp_pathspec; 44510b661123Smrg tmp_pathspec = 0; 44520b661123Smrg 4453880c7e28Smrg lt_debugprintf (__FILE__, __LINE__, 4454880c7e28Smrg "(main) libtool target name: %s\n", 4455880c7e28Smrg target_name); 44560b661123SmrgEOF 4457bdcaa8d0Smrg 44580b661123Smrg cat <<EOF 44590b661123Smrg newargz[0] = 44600b661123Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 44610b661123Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 44620b661123Smrg strcpy (newargz[0], actual_cwrapper_path); 44630b661123Smrg strcat (newargz[0], "$objdir"); 44640b661123Smrg strcat (newargz[0], "/"); 44650b661123SmrgEOF 4466bdcaa8d0Smrg 44670b661123Smrg cat <<"EOF" 44680b661123Smrg /* stop here, and copy so we don't have to do this twice */ 44690b661123Smrg tmp_pathspec = xstrdup (newargz[0]); 4470bdcaa8d0Smrg 44710b661123Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 44720b661123Smrg strcat (newargz[0], actual_cwrapper_name); 4473bdcaa8d0Smrg 44740b661123Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 44750b661123Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 44760b661123Smrg XFREE (tmp_pathspec); 44770b661123Smrg tmp_pathspec = NULL; 44780b661123SmrgEOF 4479bdcaa8d0Smrg 44800b661123Smrg case $host_os in 44810b661123Smrg mingw*) 44820b661123Smrg cat <<"EOF" 44830b661123Smrg { 44840b661123Smrg char* p; 44850b661123Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 44860b661123Smrg { 44870b661123Smrg *p = '/'; 44880b661123Smrg } 44890b661123Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 44900b661123Smrg { 44910b661123Smrg *p = '/'; 44920b661123Smrg } 44930b661123Smrg } 44940b661123SmrgEOF 44950b661123Smrg ;; 44960b661123Smrg esac 4497bdcaa8d0Smrg 44980b661123Smrg cat <<"EOF" 44990b661123Smrg XFREE (target_name); 45000b661123Smrg XFREE (actual_cwrapper_path); 45010b661123Smrg XFREE (actual_cwrapper_name); 4502bdcaa8d0Smrg 45030b661123Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 45040b661123Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 4505880c7e28Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 4506880c7e28Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 4507880c7e28Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 4508880c7e28Smrg libraries must come first. */ 45090b661123Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 4510880c7e28Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 4511bdcaa8d0Smrg 4512880c7e28Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 4513880c7e28Smrg nonnull (lt_argv_zero)); 45140b661123Smrg for (i = 0; i < newargc; i++) 45150b661123Smrg { 4516880c7e28Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 4517880c7e28Smrg i, nonnull (newargz[i])); 45180b661123Smrg } 4519bdcaa8d0Smrg 45200b661123SmrgEOF 4521bdcaa8d0Smrg 45220b661123Smrg case $host_os in 45230b661123Smrg mingw*) 45240b661123Smrg cat <<"EOF" 45250b661123Smrg /* execv doesn't actually work on mingw as expected on unix */ 4526880c7e28Smrg newargz = prepare_spawn (newargz); 45270b661123Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 45280b661123Smrg if (rval == -1) 45290b661123Smrg { 45300b661123Smrg /* failed to start process */ 4531880c7e28Smrg lt_debugprintf (__FILE__, __LINE__, 4532880c7e28Smrg "(main) failed to launch target \"%s\": %s\n", 4533880c7e28Smrg lt_argv_zero, nonnull (strerror (errno))); 45340b661123Smrg return 127; 45350b661123Smrg } 45360b661123Smrg return rval; 45370b661123SmrgEOF 45380b661123Smrg ;; 45390b661123Smrg *) 45400b661123Smrg cat <<"EOF" 45410b661123Smrg execv (lt_argv_zero, newargz); 45420b661123Smrg return rval; /* =127, but avoids unused variable warning */ 45430b661123SmrgEOF 45440b661123Smrg ;; 45450b661123Smrg esac 4546bdcaa8d0Smrg 45470b661123Smrg cat <<"EOF" 45480b661123Smrg} 4549bdcaa8d0Smrg 45500b661123Smrgvoid * 45510b661123Smrgxmalloc (size_t num) 45520b661123Smrg{ 45530b661123Smrg void *p = (void *) malloc (num); 45540b661123Smrg if (!p) 4555880c7e28Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 4556bdcaa8d0Smrg 45570b661123Smrg return p; 45580b661123Smrg} 4559bdcaa8d0Smrg 45600b661123Smrgchar * 45610b661123Smrgxstrdup (const char *string) 45620b661123Smrg{ 45630b661123Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 45640b661123Smrg string) : NULL; 45650b661123Smrg} 4566bdcaa8d0Smrg 45670b661123Smrgconst char * 45680b661123Smrgbase_name (const char *name) 45690b661123Smrg{ 45700b661123Smrg const char *base; 457196ce994aSmrg 45720b661123Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 45730b661123Smrg /* Skip over the disk name in MSDOS pathnames. */ 45740b661123Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 45750b661123Smrg name += 2; 45760b661123Smrg#endif 457796ce994aSmrg 45780b661123Smrg for (base = name; *name; name++) 45790b661123Smrg if (IS_DIR_SEPARATOR (*name)) 45800b661123Smrg base = name + 1; 45810b661123Smrg return base; 45820b661123Smrg} 458396ce994aSmrg 45840b661123Smrgint 45850b661123Smrgcheck_executable (const char *path) 45860b661123Smrg{ 45870b661123Smrg struct stat st; 458896ce994aSmrg 4589880c7e28Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 4590880c7e28Smrg nonempty (path)); 45910b661123Smrg if ((!path) || (!*path)) 45920b661123Smrg return 0; 459396ce994aSmrg 45940b661123Smrg if ((stat (path, &st) >= 0) 45950b661123Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 45960b661123Smrg return 1; 45970b661123Smrg else 45980b661123Smrg return 0; 45990b661123Smrg} 4600bdcaa8d0Smrg 46010b661123Smrgint 46020b661123Smrgmake_executable (const char *path) 46030b661123Smrg{ 46040b661123Smrg int rval = 0; 46050b661123Smrg struct stat st; 4606bdcaa8d0Smrg 4607880c7e28Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 4608880c7e28Smrg nonempty (path)); 46090b661123Smrg if ((!path) || (!*path)) 46100b661123Smrg return 0; 4611bdcaa8d0Smrg 46120b661123Smrg if (stat (path, &st) >= 0) 46130b661123Smrg { 46140b661123Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 46150b661123Smrg } 46160b661123Smrg return rval; 46170b661123Smrg} 461896ce994aSmrg 46190b661123Smrg/* Searches for the full path of the wrapper. Returns 46200b661123Smrg newly allocated full path name if found, NULL otherwise 46210b661123Smrg Does not chase symlinks, even on platforms that support them. 46220b661123Smrg*/ 46230b661123Smrgchar * 46240b661123Smrgfind_executable (const char *wrapper) 46250b661123Smrg{ 46260b661123Smrg int has_slash = 0; 46270b661123Smrg const char *p; 46280b661123Smrg const char *p_next; 46290b661123Smrg /* static buffer for getcwd */ 46300b661123Smrg char tmp[LT_PATHMAX + 1]; 46310b661123Smrg int tmp_len; 46320b661123Smrg char *concat_name; 463396ce994aSmrg 4634880c7e28Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 4635880c7e28Smrg nonempty (wrapper)); 463696ce994aSmrg 46370b661123Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 46380b661123Smrg return NULL; 463996ce994aSmrg 46400b661123Smrg /* Absolute path? */ 46410b661123Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 46420b661123Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 46430b661123Smrg { 46440b661123Smrg concat_name = xstrdup (wrapper); 46450b661123Smrg if (check_executable (concat_name)) 46460b661123Smrg return concat_name; 46470b661123Smrg XFREE (concat_name); 46480b661123Smrg } 46490b661123Smrg else 46500b661123Smrg { 46510b661123Smrg#endif 46520b661123Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 46530b661123Smrg { 46540b661123Smrg concat_name = xstrdup (wrapper); 46550b661123Smrg if (check_executable (concat_name)) 46560b661123Smrg return concat_name; 46570b661123Smrg XFREE (concat_name); 46580b661123Smrg } 46590b661123Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 46600b661123Smrg } 46610b661123Smrg#endif 4662bdcaa8d0Smrg 46630b661123Smrg for (p = wrapper; *p; p++) 46640b661123Smrg if (*p == '/') 46650b661123Smrg { 46660b661123Smrg has_slash = 1; 46670b661123Smrg break; 46680b661123Smrg } 46690b661123Smrg if (!has_slash) 46700b661123Smrg { 46710b661123Smrg /* no slashes; search PATH */ 46720b661123Smrg const char *path = getenv ("PATH"); 46730b661123Smrg if (path != NULL) 46740b661123Smrg { 46750b661123Smrg for (p = path; *p; p = p_next) 46760b661123Smrg { 46770b661123Smrg const char *q; 46780b661123Smrg size_t p_len; 46790b661123Smrg for (q = p; *q; q++) 46800b661123Smrg if (IS_PATH_SEPARATOR (*q)) 46810b661123Smrg break; 46820b661123Smrg p_len = q - p; 46830b661123Smrg p_next = (*q == '\0' ? q : q + 1); 46840b661123Smrg if (p_len == 0) 46850b661123Smrg { 46860b661123Smrg /* empty path: current directory */ 46870b661123Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 4688880c7e28Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4689880c7e28Smrg nonnull (strerror (errno))); 46900b661123Smrg tmp_len = strlen (tmp); 46910b661123Smrg concat_name = 46920b661123Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 46930b661123Smrg memcpy (concat_name, tmp, tmp_len); 46940b661123Smrg concat_name[tmp_len] = '/'; 46950b661123Smrg strcpy (concat_name + tmp_len + 1, wrapper); 46960b661123Smrg } 46970b661123Smrg else 46980b661123Smrg { 46990b661123Smrg concat_name = 47000b661123Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 47010b661123Smrg memcpy (concat_name, p, p_len); 47020b661123Smrg concat_name[p_len] = '/'; 47030b661123Smrg strcpy (concat_name + p_len + 1, wrapper); 47040b661123Smrg } 47050b661123Smrg if (check_executable (concat_name)) 47060b661123Smrg return concat_name; 47070b661123Smrg XFREE (concat_name); 47080b661123Smrg } 47090b661123Smrg } 47100b661123Smrg /* not found in PATH; assume curdir */ 47110b661123Smrg } 47120b661123Smrg /* Relative path | not found in path: prepend cwd */ 47130b661123Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 4714880c7e28Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4715880c7e28Smrg nonnull (strerror (errno))); 47160b661123Smrg tmp_len = strlen (tmp); 47170b661123Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 47180b661123Smrg memcpy (concat_name, tmp, tmp_len); 47190b661123Smrg concat_name[tmp_len] = '/'; 47200b661123Smrg strcpy (concat_name + tmp_len + 1, wrapper); 4721bdcaa8d0Smrg 47220b661123Smrg if (check_executable (concat_name)) 47230b661123Smrg return concat_name; 47240b661123Smrg XFREE (concat_name); 47250b661123Smrg return NULL; 47260b661123Smrg} 4727bdcaa8d0Smrg 47280b661123Smrgchar * 47290b661123Smrgchase_symlinks (const char *pathspec) 47300b661123Smrg{ 47310b661123Smrg#ifndef S_ISLNK 47320b661123Smrg return xstrdup (pathspec); 47330b661123Smrg#else 47340b661123Smrg char buf[LT_PATHMAX]; 47350b661123Smrg struct stat s; 47360b661123Smrg char *tmp_pathspec = xstrdup (pathspec); 47370b661123Smrg char *p; 47380b661123Smrg int has_symlinks = 0; 47390b661123Smrg while (strlen (tmp_pathspec) && !has_symlinks) 47400b661123Smrg { 4741880c7e28Smrg lt_debugprintf (__FILE__, __LINE__, 4742880c7e28Smrg "checking path component for symlinks: %s\n", 4743880c7e28Smrg tmp_pathspec); 47440b661123Smrg if (lstat (tmp_pathspec, &s) == 0) 47450b661123Smrg { 47460b661123Smrg if (S_ISLNK (s.st_mode) != 0) 47470b661123Smrg { 47480b661123Smrg has_symlinks = 1; 47490b661123Smrg break; 47500b661123Smrg } 4751bdcaa8d0Smrg 47520b661123Smrg /* search backwards for last DIR_SEPARATOR */ 47530b661123Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 47540b661123Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 47550b661123Smrg p--; 47560b661123Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 47570b661123Smrg { 47580b661123Smrg /* no more DIR_SEPARATORS left */ 47590b661123Smrg break; 47600b661123Smrg } 47610b661123Smrg *p = '\0'; 47620b661123Smrg } 47630b661123Smrg else 47640b661123Smrg { 4765880c7e28Smrg lt_fatal (__FILE__, __LINE__, 4766880c7e28Smrg "error accessing file \"%s\": %s", 4767880c7e28Smrg tmp_pathspec, nonnull (strerror (errno))); 47680b661123Smrg } 47690b661123Smrg } 47700b661123Smrg XFREE (tmp_pathspec); 4771bdcaa8d0Smrg 47720b661123Smrg if (!has_symlinks) 47730b661123Smrg { 47740b661123Smrg return xstrdup (pathspec); 47750b661123Smrg } 4776bdcaa8d0Smrg 47770b661123Smrg tmp_pathspec = realpath (pathspec, buf); 47780b661123Smrg if (tmp_pathspec == 0) 47790b661123Smrg { 4780880c7e28Smrg lt_fatal (__FILE__, __LINE__, 4781880c7e28Smrg "could not follow symlinks for %s", pathspec); 47820b661123Smrg } 47830b661123Smrg return xstrdup (tmp_pathspec); 47840b661123Smrg#endif 47850b661123Smrg} 4786bdcaa8d0Smrg 47870b661123Smrgchar * 47880b661123Smrgstrendzap (char *str, const char *pat) 47890b661123Smrg{ 47900b661123Smrg size_t len, patlen; 4791bdcaa8d0Smrg 47920b661123Smrg assert (str != NULL); 47930b661123Smrg assert (pat != NULL); 4794bdcaa8d0Smrg 47950b661123Smrg len = strlen (str); 47960b661123Smrg patlen = strlen (pat); 4797bdcaa8d0Smrg 47980b661123Smrg if (patlen <= len) 47990b661123Smrg { 48000b661123Smrg str += len - patlen; 48010b661123Smrg if (strcmp (str, pat) == 0) 48020b661123Smrg *str = '\0'; 48030b661123Smrg } 48040b661123Smrg return str; 48050b661123Smrg} 4806bdcaa8d0Smrg 4807880c7e28Smrgvoid 4808880c7e28Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 4809880c7e28Smrg{ 4810880c7e28Smrg va_list args; 4811880c7e28Smrg if (lt_debug) 4812880c7e28Smrg { 4813880c7e28Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 4814880c7e28Smrg va_start (args, fmt); 4815880c7e28Smrg (void) vfprintf (stderr, fmt, args); 4816880c7e28Smrg va_end (args); 4817880c7e28Smrg } 4818880c7e28Smrg} 4819880c7e28Smrg 48200b661123Smrgstatic void 4821880c7e28Smrglt_error_core (int exit_status, const char *file, 4822880c7e28Smrg int line, const char *mode, 48230b661123Smrg const char *message, va_list ap) 48240b661123Smrg{ 4825880c7e28Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 48260b661123Smrg vfprintf (stderr, message, ap); 48270b661123Smrg fprintf (stderr, ".\n"); 4828bdcaa8d0Smrg 48290b661123Smrg if (exit_status >= 0) 48300b661123Smrg exit (exit_status); 48310b661123Smrg} 4832bdcaa8d0Smrg 48330b661123Smrgvoid 4834880c7e28Smrglt_fatal (const char *file, int line, const char *message, ...) 48350b661123Smrg{ 48360b661123Smrg va_list ap; 48370b661123Smrg va_start (ap, message); 4838880c7e28Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 48390b661123Smrg va_end (ap); 48400b661123Smrg} 4841bdcaa8d0Smrg 4842880c7e28Smrgstatic const char * 4843880c7e28Smrgnonnull (const char *s) 4844880c7e28Smrg{ 4845880c7e28Smrg return s ? s : "(null)"; 4846880c7e28Smrg} 4847880c7e28Smrg 4848880c7e28Smrgstatic const char * 4849880c7e28Smrgnonempty (const char *s) 4850880c7e28Smrg{ 4851880c7e28Smrg return (s && !*s) ? "(empty)" : nonnull (s); 4852880c7e28Smrg} 4853880c7e28Smrg 48540b661123Smrgvoid 48550b661123Smrglt_setenv (const char *name, const char *value) 48560b661123Smrg{ 4857880c7e28Smrg lt_debugprintf (__FILE__, __LINE__, 4858880c7e28Smrg "(lt_setenv) setting '%s' to '%s'\n", 4859880c7e28Smrg nonnull (name), nonnull (value)); 48600b661123Smrg { 48610b661123Smrg#ifdef HAVE_SETENV 48620b661123Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 48630b661123Smrg char *str = xstrdup (value); 48640b661123Smrg setenv (name, str, 1); 48650b661123Smrg#else 48660b661123Smrg int len = strlen (name) + 1 + strlen (value) + 1; 48670b661123Smrg char *str = XMALLOC (char, len); 48680b661123Smrg sprintf (str, "%s=%s", name, value); 48690b661123Smrg if (putenv (str) != EXIT_SUCCESS) 48700b661123Smrg { 48710b661123Smrg XFREE (str); 48720b661123Smrg } 48730b661123Smrg#endif 48740b661123Smrg } 48750b661123Smrg} 4876bdcaa8d0Smrg 48770b661123Smrgchar * 48780b661123Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 48790b661123Smrg{ 48800b661123Smrg char *new_value; 48810b661123Smrg if (orig_value && *orig_value) 48820b661123Smrg { 48830b661123Smrg int orig_value_len = strlen (orig_value); 48840b661123Smrg int add_len = strlen (add); 48850b661123Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 48860b661123Smrg if (to_end) 48870b661123Smrg { 48880b661123Smrg strcpy (new_value, orig_value); 48890b661123Smrg strcpy (new_value + orig_value_len, add); 48900b661123Smrg } 48910b661123Smrg else 48920b661123Smrg { 48930b661123Smrg strcpy (new_value, add); 48940b661123Smrg strcpy (new_value + add_len, orig_value); 48950b661123Smrg } 48960b661123Smrg } 48970b661123Smrg else 48980b661123Smrg { 48990b661123Smrg new_value = xstrdup (add); 49000b661123Smrg } 49010b661123Smrg return new_value; 49020b661123Smrg} 4903bdcaa8d0Smrg 49040b661123Smrgvoid 49050b661123Smrglt_update_exe_path (const char *name, const char *value) 49060b661123Smrg{ 4907880c7e28Smrg lt_debugprintf (__FILE__, __LINE__, 4908880c7e28Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 4909880c7e28Smrg nonnull (name), nonnull (value)); 4910bdcaa8d0Smrg 49110b661123Smrg if (name && *name && value && *value) 49120b661123Smrg { 49130b661123Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 49140b661123Smrg /* some systems can't cope with a ':'-terminated path #' */ 49150b661123Smrg int len = strlen (new_value); 49160b661123Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 49170b661123Smrg { 49180b661123Smrg new_value[len-1] = '\0'; 49190b661123Smrg } 49200b661123Smrg lt_setenv (name, new_value); 49210b661123Smrg XFREE (new_value); 49220b661123Smrg } 49230b661123Smrg} 4924bdcaa8d0Smrg 49250b661123Smrgvoid 49260b661123Smrglt_update_lib_path (const char *name, const char *value) 49270b661123Smrg{ 4928880c7e28Smrg lt_debugprintf (__FILE__, __LINE__, 4929880c7e28Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 4930880c7e28Smrg nonnull (name), nonnull (value)); 4931bdcaa8d0Smrg 49320b661123Smrg if (name && *name && value && *value) 49330b661123Smrg { 49340b661123Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 49350b661123Smrg lt_setenv (name, new_value); 49360b661123Smrg XFREE (new_value); 49370b661123Smrg } 49380b661123Smrg} 4939bdcaa8d0Smrg 4940880c7e28SmrgEOF 4941880c7e28Smrg case $host_os in 4942880c7e28Smrg mingw*) 4943880c7e28Smrg cat <<"EOF" 4944880c7e28Smrg 4945880c7e28Smrg/* Prepares an argument vector before calling spawn(). 4946880c7e28Smrg Note that spawn() does not by itself call the command interpreter 4947880c7e28Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 4948880c7e28Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 4949880c7e28Smrg GetVersionEx(&v); 4950880c7e28Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 4951880c7e28Smrg }) ? "cmd.exe" : "command.com"). 4952880c7e28Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 4953880c7e28Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 4954880c7e28Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 4955880c7e28Smrg special way: 4956880c7e28Smrg - Space and tab are interpreted as delimiters. They are not treated as 4957880c7e28Smrg delimiters if they are surrounded by double quotes: "...". 4958880c7e28Smrg - Unescaped double quotes are removed from the input. Their only effect is 4959880c7e28Smrg that within double quotes, space and tab are treated like normal 4960880c7e28Smrg characters. 4961880c7e28Smrg - Backslashes not followed by double quotes are not special. 4962880c7e28Smrg - But 2*n+1 backslashes followed by a double quote become 4963880c7e28Smrg n backslashes followed by a double quote (n >= 0): 4964880c7e28Smrg \" -> " 4965880c7e28Smrg \\\" -> \" 4966880c7e28Smrg \\\\\" -> \\" 4967880c7e28Smrg */ 4968880c7e28Smrg#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" 4969880c7e28Smrg#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" 4970880c7e28Smrgchar ** 4971880c7e28Smrgprepare_spawn (char **argv) 4972880c7e28Smrg{ 4973880c7e28Smrg size_t argc; 4974880c7e28Smrg char **new_argv; 4975880c7e28Smrg size_t i; 4976880c7e28Smrg 4977880c7e28Smrg /* Count number of arguments. */ 4978880c7e28Smrg for (argc = 0; argv[argc] != NULL; argc++) 4979880c7e28Smrg ; 4980880c7e28Smrg 4981880c7e28Smrg /* Allocate new argument vector. */ 4982880c7e28Smrg new_argv = XMALLOC (char *, argc + 1); 4983880c7e28Smrg 4984880c7e28Smrg /* Put quoted arguments into the new argument vector. */ 4985880c7e28Smrg for (i = 0; i < argc; i++) 4986880c7e28Smrg { 4987880c7e28Smrg const char *string = argv[i]; 4988880c7e28Smrg 4989880c7e28Smrg if (string[0] == '\0') 4990880c7e28Smrg new_argv[i] = xstrdup ("\"\""); 4991880c7e28Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 4992880c7e28Smrg { 4993880c7e28Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 4994880c7e28Smrg size_t length; 4995880c7e28Smrg unsigned int backslashes; 4996880c7e28Smrg const char *s; 4997880c7e28Smrg char *quoted_string; 4998880c7e28Smrg char *p; 4999880c7e28Smrg 5000880c7e28Smrg length = 0; 5001880c7e28Smrg backslashes = 0; 5002880c7e28Smrg if (quote_around) 5003880c7e28Smrg length++; 5004880c7e28Smrg for (s = string; *s != '\0'; s++) 5005880c7e28Smrg { 5006880c7e28Smrg char c = *s; 5007880c7e28Smrg if (c == '"') 5008880c7e28Smrg length += backslashes + 1; 5009880c7e28Smrg length++; 5010880c7e28Smrg if (c == '\\') 5011880c7e28Smrg backslashes++; 5012880c7e28Smrg else 5013880c7e28Smrg backslashes = 0; 5014880c7e28Smrg } 5015880c7e28Smrg if (quote_around) 5016880c7e28Smrg length += backslashes + 1; 5017880c7e28Smrg 5018880c7e28Smrg quoted_string = XMALLOC (char, length + 1); 5019880c7e28Smrg 5020880c7e28Smrg p = quoted_string; 5021880c7e28Smrg backslashes = 0; 5022880c7e28Smrg if (quote_around) 5023880c7e28Smrg *p++ = '"'; 5024880c7e28Smrg for (s = string; *s != '\0'; s++) 5025880c7e28Smrg { 5026880c7e28Smrg char c = *s; 5027880c7e28Smrg if (c == '"') 5028880c7e28Smrg { 5029880c7e28Smrg unsigned int j; 5030880c7e28Smrg for (j = backslashes + 1; j > 0; j--) 5031880c7e28Smrg *p++ = '\\'; 5032880c7e28Smrg } 5033880c7e28Smrg *p++ = c; 5034880c7e28Smrg if (c == '\\') 5035880c7e28Smrg backslashes++; 5036880c7e28Smrg else 5037880c7e28Smrg backslashes = 0; 5038880c7e28Smrg } 5039880c7e28Smrg if (quote_around) 5040880c7e28Smrg { 5041880c7e28Smrg unsigned int j; 5042880c7e28Smrg for (j = backslashes; j > 0; j--) 5043880c7e28Smrg *p++ = '\\'; 5044880c7e28Smrg *p++ = '"'; 5045880c7e28Smrg } 5046880c7e28Smrg *p = '\0'; 5047880c7e28Smrg 5048880c7e28Smrg new_argv[i] = quoted_string; 5049880c7e28Smrg } 5050880c7e28Smrg else 5051880c7e28Smrg new_argv[i] = (char *) string; 5052880c7e28Smrg } 5053880c7e28Smrg new_argv[argc] = NULL; 5054880c7e28Smrg 5055880c7e28Smrg return new_argv; 5056880c7e28Smrg} 5057880c7e28SmrgEOF 5058880c7e28Smrg ;; 5059880c7e28Smrg esac 5060bdcaa8d0Smrg 5061880c7e28Smrg cat <<"EOF" 5062880c7e28Smrgvoid lt_dump_script (FILE* f) 5063880c7e28Smrg{ 5064880c7e28SmrgEOF 5065880c7e28Smrg func_emit_wrapper yes | 5066880c7e28Smrg $SED -n -e ' 5067880c7e28Smrgs/^\(.\{79\}\)\(..*\)/\1\ 5068880c7e28Smrg\2/ 5069880c7e28Smrgh 5070880c7e28Smrgs/\([\\"]\)/\\\1/g 5071880c7e28Smrgs/$/\\n/ 5072880c7e28Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 5073880c7e28Smrgg 5074880c7e28SmrgD' 5075880c7e28Smrg cat <<"EOF" 5076880c7e28Smrg} 50770b661123SmrgEOF 50780b661123Smrg} 50790b661123Smrg# end: func_emit_cwrapperexe_src 5080bdcaa8d0Smrg 5081880c7e28Smrg# func_win32_import_lib_p ARG 5082880c7e28Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 5083880c7e28Smrgfunc_win32_import_lib_p () 5084880c7e28Smrg{ 5085880c7e28Smrg $opt_debug 5086880c7e28Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 5087880c7e28Smrg *import*) : ;; 5088880c7e28Smrg *) false ;; 5089880c7e28Smrg esac 5090880c7e28Smrg} 5091880c7e28Smrg 50920b661123Smrg# func_mode_link arg... 50930b661123Smrgfunc_mode_link () 50940b661123Smrg{ 50950b661123Smrg $opt_debug 50960b661123Smrg case $host in 50970b661123Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 50980b661123Smrg # It is impossible to link a dll without this setting, and 50990b661123Smrg # we shouldn't force the makefile maintainer to figure out 51000b661123Smrg # which system we are compiling for in order to pass an extra 51010b661123Smrg # flag for every libtool invocation. 51020b661123Smrg # allow_undefined=no 5103bdcaa8d0Smrg 51040b661123Smrg # FIXME: Unfortunately, there are problems with the above when trying 51050b661123Smrg # to make a dll which has undefined symbols, in which case not 51060b661123Smrg # even a static library is built. For now, we need to specify 51070b661123Smrg # -no-undefined on the libtool link line when we can be certain 51080b661123Smrg # that all symbols are satisfied, otherwise we get a static library. 51090b661123Smrg allow_undefined=yes 51100b661123Smrg ;; 51110b661123Smrg *) 51120b661123Smrg allow_undefined=yes 51130b661123Smrg ;; 51140b661123Smrg esac 51150b661123Smrg libtool_args=$nonopt 51160b661123Smrg base_compile="$nonopt $@" 51170b661123Smrg compile_command=$nonopt 51180b661123Smrg finalize_command=$nonopt 5119bdcaa8d0Smrg 51200b661123Smrg compile_rpath= 51210b661123Smrg finalize_rpath= 51220b661123Smrg compile_shlibpath= 51230b661123Smrg finalize_shlibpath= 51240b661123Smrg convenience= 51250b661123Smrg old_convenience= 51260b661123Smrg deplibs= 51270b661123Smrg old_deplibs= 51280b661123Smrg compiler_flags= 51290b661123Smrg linker_flags= 51300b661123Smrg dllsearchpath= 51310b661123Smrg lib_search_path=`pwd` 51320b661123Smrg inst_prefix_dir= 51330b661123Smrg new_inherited_linker_flags= 5134bdcaa8d0Smrg 51350b661123Smrg avoid_version=no 5136880c7e28Smrg bindir= 51370b661123Smrg dlfiles= 51380b661123Smrg dlprefiles= 51390b661123Smrg dlself=no 51400b661123Smrg export_dynamic=no 51410b661123Smrg export_symbols= 51420b661123Smrg export_symbols_regex= 51430b661123Smrg generated= 51440b661123Smrg libobjs= 51450b661123Smrg ltlibs= 51460b661123Smrg module=no 51470b661123Smrg no_install=no 51480b661123Smrg objs= 51490b661123Smrg non_pic_objects= 51500b661123Smrg precious_files_regex= 51510b661123Smrg prefer_static_libs=no 51520b661123Smrg preload=no 51530b661123Smrg prev= 51540b661123Smrg prevarg= 51550b661123Smrg release= 51560b661123Smrg rpath= 51570b661123Smrg xrpath= 51580b661123Smrg perm_rpath= 51590b661123Smrg temp_rpath= 51600b661123Smrg thread_safe=no 51610b661123Smrg vinfo= 51620b661123Smrg vinfo_number=no 51630b661123Smrg weak_libs= 51640b661123Smrg single_module="${wl}-single_module" 51650b661123Smrg func_infer_tag $base_compile 51660b661123Smrg 51670b661123Smrg # We need to know -static, to get the right output filenames. 51680b661123Smrg for arg 51690b661123Smrg do 51700b661123Smrg case $arg in 51710b661123Smrg -shared) 51720b661123Smrg test "$build_libtool_libs" != yes && \ 51730b661123Smrg func_fatal_configuration "can not build a shared library" 51740b661123Smrg build_old_libs=no 51750b661123Smrg break 51760b661123Smrg ;; 51770b661123Smrg -all-static | -static | -static-libtool-libs) 51780b661123Smrg case $arg in 51790b661123Smrg -all-static) 51800b661123Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 51810b661123Smrg func_warning "complete static linking is impossible in this configuration" 51820b661123Smrg fi 51830b661123Smrg if test -n "$link_static_flag"; then 51840b661123Smrg dlopen_self=$dlopen_self_static 51850b661123Smrg fi 51860b661123Smrg prefer_static_libs=yes 51870b661123Smrg ;; 51880b661123Smrg -static) 51890b661123Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 51900b661123Smrg dlopen_self=$dlopen_self_static 51910b661123Smrg fi 51920b661123Smrg prefer_static_libs=built 51930b661123Smrg ;; 51940b661123Smrg -static-libtool-libs) 51950b661123Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 51960b661123Smrg dlopen_self=$dlopen_self_static 519796ce994aSmrg fi 51980b661123Smrg prefer_static_libs=yes 51990b661123Smrg ;; 52000b661123Smrg esac 52010b661123Smrg build_libtool_libs=no 52020b661123Smrg build_old_libs=yes 52030b661123Smrg break 52040b661123Smrg ;; 52050b661123Smrg esac 52060b661123Smrg done 5207bdcaa8d0Smrg 52080b661123Smrg # See if our shared archives depend on static archives. 52090b661123Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 5210bdcaa8d0Smrg 52110b661123Smrg # Go through the arguments, transforming them on the way. 52120b661123Smrg while test "$#" -gt 0; do 52130b661123Smrg arg="$1" 52140b661123Smrg shift 52150b661123Smrg func_quote_for_eval "$arg" 52160b661123Smrg qarg=$func_quote_for_eval_unquoted_result 52170b661123Smrg func_append libtool_args " $func_quote_for_eval_result" 5218bdcaa8d0Smrg 52190b661123Smrg # If the previous option needs an argument, assign it. 52200b661123Smrg if test -n "$prev"; then 52210b661123Smrg case $prev in 52220b661123Smrg output) 52230b661123Smrg func_append compile_command " @OUTPUT@" 52240b661123Smrg func_append finalize_command " @OUTPUT@" 52250b661123Smrg ;; 52260b661123Smrg esac 5227bdcaa8d0Smrg 52280b661123Smrg case $prev in 5229880c7e28Smrg bindir) 5230880c7e28Smrg bindir="$arg" 5231880c7e28Smrg prev= 5232880c7e28Smrg continue 5233880c7e28Smrg ;; 52340b661123Smrg dlfiles|dlprefiles) 52350b661123Smrg if test "$preload" = no; then 52360b661123Smrg # Add the symbol object into the linking commands. 52370b661123Smrg func_append compile_command " @SYMFILE@" 52380b661123Smrg func_append finalize_command " @SYMFILE@" 52390b661123Smrg preload=yes 52400b661123Smrg fi 52410b661123Smrg case $arg in 52420b661123Smrg *.la | *.lo) ;; # We handle these cases below. 52430b661123Smrg force) 52440b661123Smrg if test "$dlself" = no; then 52450b661123Smrg dlself=needless 52460b661123Smrg export_dynamic=yes 52470b661123Smrg fi 52480b661123Smrg prev= 52490b661123Smrg continue 52500b661123Smrg ;; 52510b661123Smrg self) 52520b661123Smrg if test "$prev" = dlprefiles; then 52530b661123Smrg dlself=yes 52540b661123Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 52550b661123Smrg dlself=yes 525696ce994aSmrg else 52570b661123Smrg dlself=needless 52580b661123Smrg export_dynamic=yes 525996ce994aSmrg fi 52600b661123Smrg prev= 52610b661123Smrg continue 52620b661123Smrg ;; 52630b661123Smrg *) 52640b661123Smrg if test "$prev" = dlfiles; then 5265880c7e28Smrg func_append dlfiles " $arg" 526696ce994aSmrg else 5267880c7e28Smrg func_append dlprefiles " $arg" 526896ce994aSmrg fi 52690b661123Smrg prev= 52700b661123Smrg continue 52710b661123Smrg ;; 52720b661123Smrg esac 52730b661123Smrg ;; 52740b661123Smrg expsyms) 52750b661123Smrg export_symbols="$arg" 52760b661123Smrg test -f "$arg" \ 52770b661123Smrg || func_fatal_error "symbol file \`$arg' does not exist" 52780b661123Smrg prev= 52790b661123Smrg continue 52800b661123Smrg ;; 52810b661123Smrg expsyms_regex) 52820b661123Smrg export_symbols_regex="$arg" 52830b661123Smrg prev= 52840b661123Smrg continue 52850b661123Smrg ;; 52860b661123Smrg framework) 528796ce994aSmrg case $host in 52880b661123Smrg *-*-darwin*) 52890b661123Smrg case "$deplibs " in 52900b661123Smrg *" $qarg.ltframework "*) ;; 5291880c7e28Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 52920b661123Smrg ;; 52930b661123Smrg esac 52940b661123Smrg ;; 529596ce994aSmrg esac 52960b661123Smrg prev= 52970b661123Smrg continue 529896ce994aSmrg ;; 52990b661123Smrg inst_prefix) 53000b661123Smrg inst_prefix_dir="$arg" 53010b661123Smrg prev= 53020b661123Smrg continue 530396ce994aSmrg ;; 53040b661123Smrg objectlist) 53050b661123Smrg if test -f "$arg"; then 53060b661123Smrg save_arg=$arg 53070b661123Smrg moreargs= 53080b661123Smrg for fil in `cat "$save_arg"` 53090b661123Smrg do 5310880c7e28Smrg# func_append moreargs " $fil" 53110b661123Smrg arg=$fil 53120b661123Smrg # A libtool-controlled object. 531372313efbSmrg 53140b661123Smrg # Check to see that this really is a libtool object. 53150b661123Smrg if func_lalib_unsafe_p "$arg"; then 53160b661123Smrg pic_object= 53170b661123Smrg non_pic_object= 531872313efbSmrg 53190b661123Smrg # Read the .lo file 53200b661123Smrg func_source "$arg" 532172313efbSmrg 53220b661123Smrg if test -z "$pic_object" || 53230b661123Smrg test -z "$non_pic_object" || 53240b661123Smrg test "$pic_object" = none && 53250b661123Smrg test "$non_pic_object" = none; then 53260b661123Smrg func_fatal_error "cannot find name of object for \`$arg'" 53270b661123Smrg fi 532872313efbSmrg 53290b661123Smrg # Extract subdirectory from the argument. 53300b661123Smrg func_dirname "$arg" "/" "" 53310b661123Smrg xdir="$func_dirname_result" 533272313efbSmrg 53330b661123Smrg if test "$pic_object" != none; then 53340b661123Smrg # Prepend the subdirectory the object is found in. 53350b661123Smrg pic_object="$xdir$pic_object" 533672313efbSmrg 53370b661123Smrg if test "$prev" = dlfiles; then 53380b661123Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5339880c7e28Smrg func_append dlfiles " $pic_object" 53400b661123Smrg prev= 53410b661123Smrg continue 53420b661123Smrg else 53430b661123Smrg # If libtool objects are unsupported, then we need to preload. 53440b661123Smrg prev=dlprefiles 53450b661123Smrg fi 53460b661123Smrg fi 534772313efbSmrg 53480b661123Smrg # CHECK ME: I think I busted this. -Ossama 53490b661123Smrg if test "$prev" = dlprefiles; then 53500b661123Smrg # Preload the old-style object. 5351880c7e28Smrg func_append dlprefiles " $pic_object" 53520b661123Smrg prev= 53530b661123Smrg fi 535472313efbSmrg 53550b661123Smrg # A PIC object. 53560b661123Smrg func_append libobjs " $pic_object" 53570b661123Smrg arg="$pic_object" 53580b661123Smrg fi 535972313efbSmrg 53600b661123Smrg # Non-PIC object. 53610b661123Smrg if test "$non_pic_object" != none; then 53620b661123Smrg # Prepend the subdirectory the object is found in. 53630b661123Smrg non_pic_object="$xdir$non_pic_object" 536472313efbSmrg 53650b661123Smrg # A standard non-PIC object 53660b661123Smrg func_append non_pic_objects " $non_pic_object" 53670b661123Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 53680b661123Smrg arg="$non_pic_object" 53690b661123Smrg fi 53700b661123Smrg else 53710b661123Smrg # If the PIC object exists, use it instead. 53720b661123Smrg # $xdir was prepended to $pic_object above. 53730b661123Smrg non_pic_object="$pic_object" 53740b661123Smrg func_append non_pic_objects " $non_pic_object" 53750b661123Smrg fi 53760b661123Smrg else 53770b661123Smrg # Only an error if not doing a dry-run. 53780b661123Smrg if $opt_dry_run; then 53790b661123Smrg # Extract subdirectory from the argument. 53800b661123Smrg func_dirname "$arg" "/" "" 53810b661123Smrg xdir="$func_dirname_result" 53820b661123Smrg 53830b661123Smrg func_lo2o "$arg" 53840b661123Smrg pic_object=$xdir$objdir/$func_lo2o_result 53850b661123Smrg non_pic_object=$xdir$func_lo2o_result 53860b661123Smrg func_append libobjs " $pic_object" 53870b661123Smrg func_append non_pic_objects " $non_pic_object" 53880b661123Smrg else 53890b661123Smrg func_fatal_error "\`$arg' is not a valid libtool object" 53900b661123Smrg fi 53910b661123Smrg fi 53920b661123Smrg done 539396ce994aSmrg else 53940b661123Smrg func_fatal_error "link input file \`$arg' does not exist" 539596ce994aSmrg fi 53960b661123Smrg arg=$save_arg 53970b661123Smrg prev= 53980b661123Smrg continue 53990b661123Smrg ;; 54000b661123Smrg precious_regex) 54010b661123Smrg precious_files_regex="$arg" 54020b661123Smrg prev= 54030b661123Smrg continue 54040b661123Smrg ;; 54050b661123Smrg release) 54060b661123Smrg release="-$arg" 54070b661123Smrg prev= 54080b661123Smrg continue 54090b661123Smrg ;; 54100b661123Smrg rpath | xrpath) 54110b661123Smrg # We need an absolute path. 54120b661123Smrg case $arg in 54130b661123Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 54140b661123Smrg *) 54150b661123Smrg func_fatal_error "only absolute run-paths are allowed" 54160b661123Smrg ;; 54170b661123Smrg esac 54180b661123Smrg if test "$prev" = rpath; then 54190b661123Smrg case "$rpath " in 54200b661123Smrg *" $arg "*) ;; 5421880c7e28Smrg *) func_append rpath " $arg" ;; 54220b661123Smrg esac 542396ce994aSmrg else 54240b661123Smrg case "$xrpath " in 54250b661123Smrg *" $arg "*) ;; 5426880c7e28Smrg *) func_append xrpath " $arg" ;; 54270b661123Smrg esac 542896ce994aSmrg fi 54290b661123Smrg prev= 54300b661123Smrg continue 54310b661123Smrg ;; 54320b661123Smrg shrext) 54330b661123Smrg shrext_cmds="$arg" 54340b661123Smrg prev= 54350b661123Smrg continue 54360b661123Smrg ;; 54370b661123Smrg weak) 5438880c7e28Smrg func_append weak_libs " $arg" 54390b661123Smrg prev= 54400b661123Smrg continue 54410b661123Smrg ;; 54420b661123Smrg xcclinker) 5443880c7e28Smrg func_append linker_flags " $qarg" 5444880c7e28Smrg func_append compiler_flags " $qarg" 54450b661123Smrg prev= 54460b661123Smrg func_append compile_command " $qarg" 54470b661123Smrg func_append finalize_command " $qarg" 54480b661123Smrg continue 54490b661123Smrg ;; 54500b661123Smrg xcompiler) 5451880c7e28Smrg func_append compiler_flags " $qarg" 54520b661123Smrg prev= 54530b661123Smrg func_append compile_command " $qarg" 54540b661123Smrg func_append finalize_command " $qarg" 54550b661123Smrg continue 54560b661123Smrg ;; 54570b661123Smrg xlinker) 5458880c7e28Smrg func_append linker_flags " $qarg" 5459880c7e28Smrg func_append compiler_flags " $wl$qarg" 54600b661123Smrg prev= 54610b661123Smrg func_append compile_command " $wl$qarg" 54620b661123Smrg func_append finalize_command " $wl$qarg" 54630b661123Smrg continue 54640b661123Smrg ;; 54650b661123Smrg *) 54660b661123Smrg eval "$prev=\"\$arg\"" 54670b661123Smrg prev= 54680b661123Smrg continue 54690b661123Smrg ;; 547072313efbSmrg esac 54710b661123Smrg fi # test -n "$prev" 547272313efbSmrg 54730b661123Smrg prevarg="$arg" 547472313efbSmrg 54750b661123Smrg case $arg in 54760b661123Smrg -all-static) 54770b661123Smrg if test -n "$link_static_flag"; then 54780b661123Smrg # See comment for -static flag below, for more details. 54790b661123Smrg func_append compile_command " $link_static_flag" 54800b661123Smrg func_append finalize_command " $link_static_flag" 54810b661123Smrg fi 54820b661123Smrg continue 54830b661123Smrg ;; 548472313efbSmrg 54850b661123Smrg -allow-undefined) 54860b661123Smrg # FIXME: remove this flag sometime in the future. 54870b661123Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 54880b661123Smrg ;; 548972313efbSmrg 54900b661123Smrg -avoid-version) 54910b661123Smrg avoid_version=yes 54920b661123Smrg continue 54930b661123Smrg ;; 549472313efbSmrg 5495880c7e28Smrg -bindir) 5496880c7e28Smrg prev=bindir 5497880c7e28Smrg continue 5498880c7e28Smrg ;; 5499880c7e28Smrg 55000b661123Smrg -dlopen) 55010b661123Smrg prev=dlfiles 55020b661123Smrg continue 55030b661123Smrg ;; 550472313efbSmrg 55050b661123Smrg -dlpreopen) 55060b661123Smrg prev=dlprefiles 55070b661123Smrg continue 55080b661123Smrg ;; 550972313efbSmrg 55100b661123Smrg -export-dynamic) 55110b661123Smrg export_dynamic=yes 55120b661123Smrg continue 55130b661123Smrg ;; 551472313efbSmrg 55150b661123Smrg -export-symbols | -export-symbols-regex) 55160b661123Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 55170b661123Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 55180b661123Smrg fi 55190b661123Smrg if test "X$arg" = "X-export-symbols"; then 55200b661123Smrg prev=expsyms 55210b661123Smrg else 55220b661123Smrg prev=expsyms_regex 55230b661123Smrg fi 55240b661123Smrg continue 55250b661123Smrg ;; 552672313efbSmrg 55270b661123Smrg -framework) 55280b661123Smrg prev=framework 55290b661123Smrg continue 55300b661123Smrg ;; 553172313efbSmrg 55320b661123Smrg -inst-prefix-dir) 55330b661123Smrg prev=inst_prefix 55340b661123Smrg continue 55350b661123Smrg ;; 553672313efbSmrg 55370b661123Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 55380b661123Smrg # so, if we see these flags be careful not to treat them like -L 55390b661123Smrg -L[A-Z][A-Z]*:*) 55400b661123Smrg case $with_gcc/$host in 55410b661123Smrg no/*-*-irix* | /*-*-irix*) 55420b661123Smrg func_append compile_command " $arg" 55430b661123Smrg func_append finalize_command " $arg" 55440b661123Smrg ;; 55450b661123Smrg esac 55460b661123Smrg continue 55470b661123Smrg ;; 554872313efbSmrg 55490b661123Smrg -L*) 5550880c7e28Smrg func_stripname "-L" '' "$arg" 5551880c7e28Smrg if test -z "$func_stripname_result"; then 55520b661123Smrg if test "$#" -gt 0; then 55530b661123Smrg func_fatal_error "require no space between \`-L' and \`$1'" 55540b661123Smrg else 55550b661123Smrg func_fatal_error "need path for \`-L' option" 55560b661123Smrg fi 55570b661123Smrg fi 5558880c7e28Smrg func_resolve_sysroot "$func_stripname_result" 5559880c7e28Smrg dir=$func_resolve_sysroot_result 55600b661123Smrg # We need an absolute path. 55610b661123Smrg case $dir in 55620b661123Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 55630b661123Smrg *) 55640b661123Smrg absdir=`cd "$dir" && pwd` 55650b661123Smrg test -z "$absdir" && \ 55660b661123Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 55670b661123Smrg dir="$absdir" 55680b661123Smrg ;; 55690b661123Smrg esac 55700b661123Smrg case "$deplibs " in 5571880c7e28Smrg *" -L$dir "* | *" $arg "*) 5572880c7e28Smrg # Will only happen for absolute or sysroot arguments 5573880c7e28Smrg ;; 55740b661123Smrg *) 5575880c7e28Smrg # Preserve sysroot, but never include relative directories 5576880c7e28Smrg case $dir in 5577880c7e28Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 5578880c7e28Smrg *) func_append deplibs " -L$dir" ;; 5579880c7e28Smrg esac 5580880c7e28Smrg func_append lib_search_path " $dir" 55810b661123Smrg ;; 55820b661123Smrg esac 55830b661123Smrg case $host in 55840b661123Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5585880c7e28Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 55860b661123Smrg case :$dllsearchpath: in 55870b661123Smrg *":$dir:"*) ;; 55880b661123Smrg ::) dllsearchpath=$dir;; 5589880c7e28Smrg *) func_append dllsearchpath ":$dir";; 55900b661123Smrg esac 55910b661123Smrg case :$dllsearchpath: in 55920b661123Smrg *":$testbindir:"*) ;; 55930b661123Smrg ::) dllsearchpath=$testbindir;; 5594880c7e28Smrg *) func_append dllsearchpath ":$testbindir";; 55950b661123Smrg esac 55960b661123Smrg ;; 55970b661123Smrg esac 55980b661123Smrg continue 55990b661123Smrg ;; 560072313efbSmrg 56010b661123Smrg -l*) 56020b661123Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 56030b661123Smrg case $host in 5604880c7e28Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 56050b661123Smrg # These systems don't actually have a C or math library (as such) 56060b661123Smrg continue 56070b661123Smrg ;; 56080b661123Smrg *-*-os2*) 56090b661123Smrg # These systems don't actually have a C library (as such) 56100b661123Smrg test "X$arg" = "X-lc" && continue 56110b661123Smrg ;; 56120b661123Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 56130b661123Smrg # Do not include libc due to us having libc/libc_r. 56140b661123Smrg test "X$arg" = "X-lc" && continue 56150b661123Smrg ;; 56160b661123Smrg *-*-rhapsody* | *-*-darwin1.[012]) 56170b661123Smrg # Rhapsody C and math libraries are in the System framework 5618880c7e28Smrg func_append deplibs " System.ltframework" 56190b661123Smrg continue 56200b661123Smrg ;; 56210b661123Smrg *-*-sco3.2v5* | *-*-sco5v6*) 56220b661123Smrg # Causes problems with __ctype 56230b661123Smrg test "X$arg" = "X-lc" && continue 56240b661123Smrg ;; 56250b661123Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 56260b661123Smrg # Compiler inserts libc in the correct place for threads to work 56270b661123Smrg test "X$arg" = "X-lc" && continue 56280b661123Smrg ;; 56290b661123Smrg esac 56300b661123Smrg elif test "X$arg" = "X-lc_r"; then 56310b661123Smrg case $host in 56320b661123Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 56330b661123Smrg # Do not include libc_r directly, use -pthread flag. 56340b661123Smrg continue 56350b661123Smrg ;; 56360b661123Smrg esac 56370b661123Smrg fi 5638880c7e28Smrg func_append deplibs " $arg" 56390b661123Smrg continue 56400b661123Smrg ;; 564172313efbSmrg 56420b661123Smrg -module) 56430b661123Smrg module=yes 56440b661123Smrg continue 56450b661123Smrg ;; 564672313efbSmrg 56470b661123Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 56480b661123Smrg # classes, name mangling, and exception handling. 56490b661123Smrg # Darwin uses the -arch flag to determine output architecture. 5650880c7e28Smrg -model|-arch|-isysroot|--sysroot) 5651880c7e28Smrg func_append compiler_flags " $arg" 56520b661123Smrg func_append compile_command " $arg" 56530b661123Smrg func_append finalize_command " $arg" 56540b661123Smrg prev=xcompiler 56550b661123Smrg continue 56560b661123Smrg ;; 565772313efbSmrg 5658880c7e28Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 5659880c7e28Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 5660880c7e28Smrg func_append compiler_flags " $arg" 56610b661123Smrg func_append compile_command " $arg" 56620b661123Smrg func_append finalize_command " $arg" 56630b661123Smrg case "$new_inherited_linker_flags " in 56640b661123Smrg *" $arg "*) ;; 5665880c7e28Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 56660b661123Smrg esac 56670b661123Smrg continue 56680b661123Smrg ;; 566972313efbSmrg 56700b661123Smrg -multi_module) 56710b661123Smrg single_module="${wl}-multi_module" 56720b661123Smrg continue 56730b661123Smrg ;; 567472313efbSmrg 56750b661123Smrg -no-fast-install) 56760b661123Smrg fast_install=no 56770b661123Smrg continue 56780b661123Smrg ;; 567972313efbSmrg 56800b661123Smrg -no-install) 56810b661123Smrg case $host in 56820b661123Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 56830b661123Smrg # The PATH hackery in wrapper scripts is required on Windows 56840b661123Smrg # and Darwin in order for the loader to find any dlls it needs. 56850b661123Smrg func_warning "\`-no-install' is ignored for $host" 56860b661123Smrg func_warning "assuming \`-no-fast-install' instead" 56870b661123Smrg fast_install=no 56880b661123Smrg ;; 56890b661123Smrg *) no_install=yes ;; 56900b661123Smrg esac 56910b661123Smrg continue 56920b661123Smrg ;; 569372313efbSmrg 56940b661123Smrg -no-undefined) 56950b661123Smrg allow_undefined=no 56960b661123Smrg continue 56970b661123Smrg ;; 569872313efbSmrg 56990b661123Smrg -objectlist) 57000b661123Smrg prev=objectlist 57010b661123Smrg continue 57020b661123Smrg ;; 570372313efbSmrg 57040b661123Smrg -o) prev=output ;; 570572313efbSmrg 57060b661123Smrg -precious-files-regex) 57070b661123Smrg prev=precious_regex 57080b661123Smrg continue 57090b661123Smrg ;; 571072313efbSmrg 57110b661123Smrg -release) 57120b661123Smrg prev=release 57130b661123Smrg continue 57140b661123Smrg ;; 571572313efbSmrg 57160b661123Smrg -rpath) 57170b661123Smrg prev=rpath 57180b661123Smrg continue 57190b661123Smrg ;; 572072313efbSmrg 57210b661123Smrg -R) 57220b661123Smrg prev=xrpath 57230b661123Smrg continue 57240b661123Smrg ;; 572572313efbSmrg 57260b661123Smrg -R*) 57270b661123Smrg func_stripname '-R' '' "$arg" 57280b661123Smrg dir=$func_stripname_result 57290b661123Smrg # We need an absolute path. 57300b661123Smrg case $dir in 57310b661123Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5732880c7e28Smrg =*) 5733880c7e28Smrg func_stripname '=' '' "$dir" 5734880c7e28Smrg dir=$lt_sysroot$func_stripname_result 5735880c7e28Smrg ;; 57360b661123Smrg *) 57370b661123Smrg func_fatal_error "only absolute run-paths are allowed" 57380b661123Smrg ;; 57390b661123Smrg esac 57400b661123Smrg case "$xrpath " in 57410b661123Smrg *" $dir "*) ;; 5742880c7e28Smrg *) func_append xrpath " $dir" ;; 57430b661123Smrg esac 57440b661123Smrg continue 57450b661123Smrg ;; 574672313efbSmrg 57470b661123Smrg -shared) 57480b661123Smrg # The effects of -shared are defined in a previous loop. 57490b661123Smrg continue 57500b661123Smrg ;; 575172313efbSmrg 57520b661123Smrg -shrext) 57530b661123Smrg prev=shrext 57540b661123Smrg continue 57550b661123Smrg ;; 575672313efbSmrg 57570b661123Smrg -static | -static-libtool-libs) 57580b661123Smrg # The effects of -static are defined in a previous loop. 57590b661123Smrg # We used to do the same as -all-static on platforms that 57600b661123Smrg # didn't have a PIC flag, but the assumption that the effects 57610b661123Smrg # would be equivalent was wrong. It would break on at least 57620b661123Smrg # Digital Unix and AIX. 57630b661123Smrg continue 57640b661123Smrg ;; 576572313efbSmrg 57660b661123Smrg -thread-safe) 57670b661123Smrg thread_safe=yes 57680b661123Smrg continue 57690b661123Smrg ;; 577072313efbSmrg 57710b661123Smrg -version-info) 57720b661123Smrg prev=vinfo 57730b661123Smrg continue 57740b661123Smrg ;; 577572313efbSmrg 57760b661123Smrg -version-number) 57770b661123Smrg prev=vinfo 57780b661123Smrg vinfo_number=yes 57790b661123Smrg continue 57800b661123Smrg ;; 578172313efbSmrg 57820b661123Smrg -weak) 57830b661123Smrg prev=weak 57840b661123Smrg continue 57850b661123Smrg ;; 5786bdcaa8d0Smrg 57870b661123Smrg -Wc,*) 57880b661123Smrg func_stripname '-Wc,' '' "$arg" 57890b661123Smrg args=$func_stripname_result 57900b661123Smrg arg= 57910b661123Smrg save_ifs="$IFS"; IFS=',' 57920b661123Smrg for flag in $args; do 57930b661123Smrg IFS="$save_ifs" 57940b661123Smrg func_quote_for_eval "$flag" 5795880c7e28Smrg func_append arg " $func_quote_for_eval_result" 5796880c7e28Smrg func_append compiler_flags " $func_quote_for_eval_result" 57970b661123Smrg done 57980b661123Smrg IFS="$save_ifs" 57990b661123Smrg func_stripname ' ' '' "$arg" 58000b661123Smrg arg=$func_stripname_result 58010b661123Smrg ;; 580296ce994aSmrg 58030b661123Smrg -Wl,*) 58040b661123Smrg func_stripname '-Wl,' '' "$arg" 58050b661123Smrg args=$func_stripname_result 58060b661123Smrg arg= 58070b661123Smrg save_ifs="$IFS"; IFS=',' 58080b661123Smrg for flag in $args; do 58090b661123Smrg IFS="$save_ifs" 58100b661123Smrg func_quote_for_eval "$flag" 5811880c7e28Smrg func_append arg " $wl$func_quote_for_eval_result" 5812880c7e28Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 5813880c7e28Smrg func_append linker_flags " $func_quote_for_eval_result" 58140b661123Smrg done 58150b661123Smrg IFS="$save_ifs" 58160b661123Smrg func_stripname ' ' '' "$arg" 58170b661123Smrg arg=$func_stripname_result 58180b661123Smrg ;; 581996ce994aSmrg 58200b661123Smrg -Xcompiler) 58210b661123Smrg prev=xcompiler 58220b661123Smrg continue 58230b661123Smrg ;; 582496ce994aSmrg 58250b661123Smrg -Xlinker) 58260b661123Smrg prev=xlinker 58270b661123Smrg continue 58280b661123Smrg ;; 582996ce994aSmrg 58300b661123Smrg -XCClinker) 58310b661123Smrg prev=xcclinker 58320b661123Smrg continue 58330b661123Smrg ;; 583496ce994aSmrg 58350b661123Smrg # -msg_* for osf cc 58360b661123Smrg -msg_*) 58370b661123Smrg func_quote_for_eval "$arg" 58380b661123Smrg arg="$func_quote_for_eval_result" 58390b661123Smrg ;; 584096ce994aSmrg 5841880c7e28Smrg # Flags to be passed through unchanged, with rationale: 5842880c7e28Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 5843880c7e28Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 5844880c7e28Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 5845880c7e28Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 5846880c7e28Smrg # -q* compiler args for the IBM compiler 5847880c7e28Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 5848880c7e28Smrg # -F/path path to uninstalled frameworks, gcc on darwin 5849880c7e28Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 5850880c7e28Smrg # @file GCC response files 5851880c7e28Smrg # -tp=* Portland pgcc target processor selection 5852880c7e28Smrg # --sysroot=* for sysroot support 5853880c7e28Smrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 58540b661123Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 5855880c7e28Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 5856880c7e28Smrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 58570b661123Smrg func_quote_for_eval "$arg" 58580b661123Smrg arg="$func_quote_for_eval_result" 58590b661123Smrg func_append compile_command " $arg" 58600b661123Smrg func_append finalize_command " $arg" 5861880c7e28Smrg func_append compiler_flags " $arg" 58620b661123Smrg continue 58630b661123Smrg ;; 586496ce994aSmrg 58650b661123Smrg # Some other compiler flag. 58660b661123Smrg -* | +*) 58670b661123Smrg func_quote_for_eval "$arg" 58680b661123Smrg arg="$func_quote_for_eval_result" 58690b661123Smrg ;; 587096ce994aSmrg 58710b661123Smrg *.$objext) 58720b661123Smrg # A standard object. 5873880c7e28Smrg func_append objs " $arg" 58740b661123Smrg ;; 587596ce994aSmrg 58760b661123Smrg *.lo) 58770b661123Smrg # A libtool-controlled object. 587896ce994aSmrg 58790b661123Smrg # Check to see that this really is a libtool object. 58800b661123Smrg if func_lalib_unsafe_p "$arg"; then 58810b661123Smrg pic_object= 58820b661123Smrg non_pic_object= 588396ce994aSmrg 58840b661123Smrg # Read the .lo file 58850b661123Smrg func_source "$arg" 588696ce994aSmrg 58870b661123Smrg if test -z "$pic_object" || 58880b661123Smrg test -z "$non_pic_object" || 58890b661123Smrg test "$pic_object" = none && 58900b661123Smrg test "$non_pic_object" = none; then 58910b661123Smrg func_fatal_error "cannot find name of object for \`$arg'" 58920b661123Smrg fi 589396ce994aSmrg 58940b661123Smrg # Extract subdirectory from the argument. 58950b661123Smrg func_dirname "$arg" "/" "" 58960b661123Smrg xdir="$func_dirname_result" 589796ce994aSmrg 58980b661123Smrg if test "$pic_object" != none; then 58990b661123Smrg # Prepend the subdirectory the object is found in. 59000b661123Smrg pic_object="$xdir$pic_object" 590196ce994aSmrg 59020b661123Smrg if test "$prev" = dlfiles; then 59030b661123Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5904880c7e28Smrg func_append dlfiles " $pic_object" 59050b661123Smrg prev= 59060b661123Smrg continue 59070b661123Smrg else 59080b661123Smrg # If libtool objects are unsupported, then we need to preload. 59090b661123Smrg prev=dlprefiles 59100b661123Smrg fi 59110b661123Smrg fi 591296ce994aSmrg 59130b661123Smrg # CHECK ME: I think I busted this. -Ossama 59140b661123Smrg if test "$prev" = dlprefiles; then 59150b661123Smrg # Preload the old-style object. 5916880c7e28Smrg func_append dlprefiles " $pic_object" 59170b661123Smrg prev= 59180b661123Smrg fi 5919bdcaa8d0Smrg 59200b661123Smrg # A PIC object. 59210b661123Smrg func_append libobjs " $pic_object" 59220b661123Smrg arg="$pic_object" 59230b661123Smrg fi 5924bdcaa8d0Smrg 59250b661123Smrg # Non-PIC object. 59260b661123Smrg if test "$non_pic_object" != none; then 59270b661123Smrg # Prepend the subdirectory the object is found in. 59280b661123Smrg non_pic_object="$xdir$non_pic_object" 5929bdcaa8d0Smrg 59300b661123Smrg # A standard non-PIC object 59310b661123Smrg func_append non_pic_objects " $non_pic_object" 59320b661123Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 59330b661123Smrg arg="$non_pic_object" 59340b661123Smrg fi 59350b661123Smrg else 59360b661123Smrg # If the PIC object exists, use it instead. 59370b661123Smrg # $xdir was prepended to $pic_object above. 59380b661123Smrg non_pic_object="$pic_object" 59390b661123Smrg func_append non_pic_objects " $non_pic_object" 59400b661123Smrg fi 59410b661123Smrg else 59420b661123Smrg # Only an error if not doing a dry-run. 59430b661123Smrg if $opt_dry_run; then 59440b661123Smrg # Extract subdirectory from the argument. 59450b661123Smrg func_dirname "$arg" "/" "" 59460b661123Smrg xdir="$func_dirname_result" 59470b661123Smrg 59480b661123Smrg func_lo2o "$arg" 59490b661123Smrg pic_object=$xdir$objdir/$func_lo2o_result 59500b661123Smrg non_pic_object=$xdir$func_lo2o_result 59510b661123Smrg func_append libobjs " $pic_object" 59520b661123Smrg func_append non_pic_objects " $non_pic_object" 59530b661123Smrg else 59540b661123Smrg func_fatal_error "\`$arg' is not a valid libtool object" 59550b661123Smrg fi 59560b661123Smrg fi 59570b661123Smrg ;; 5958bdcaa8d0Smrg 59590b661123Smrg *.$libext) 59600b661123Smrg # An archive. 5961880c7e28Smrg func_append deplibs " $arg" 5962880c7e28Smrg func_append old_deplibs " $arg" 59630b661123Smrg continue 59640b661123Smrg ;; 59650b661123Smrg 59660b661123Smrg *.la) 59670b661123Smrg # A libtool-controlled library. 59680b661123Smrg 5969880c7e28Smrg func_resolve_sysroot "$arg" 59700b661123Smrg if test "$prev" = dlfiles; then 59710b661123Smrg # This library was specified with -dlopen. 5972880c7e28Smrg func_append dlfiles " $func_resolve_sysroot_result" 59730b661123Smrg prev= 59740b661123Smrg elif test "$prev" = dlprefiles; then 59750b661123Smrg # The library was specified with -dlpreopen. 5976880c7e28Smrg func_append dlprefiles " $func_resolve_sysroot_result" 59770b661123Smrg prev= 59780b661123Smrg else 5979880c7e28Smrg func_append deplibs " $func_resolve_sysroot_result" 59800b661123Smrg fi 59810b661123Smrg continue 59820b661123Smrg ;; 59830b661123Smrg 59840b661123Smrg # Some other compiler argument. 59850b661123Smrg *) 59860b661123Smrg # Unknown arguments in both finalize_command and compile_command need 59870b661123Smrg # to be aesthetically quoted because they are evaled later. 59880b661123Smrg func_quote_for_eval "$arg" 59890b661123Smrg arg="$func_quote_for_eval_result" 59900b661123Smrg ;; 59910b661123Smrg esac # arg 59920b661123Smrg 59930b661123Smrg # Now actually substitute the argument into the commands. 59940b661123Smrg if test -n "$arg"; then 59950b661123Smrg func_append compile_command " $arg" 59960b661123Smrg func_append finalize_command " $arg" 59970b661123Smrg fi 59980b661123Smrg done # argument parsing loop 59990b661123Smrg 60000b661123Smrg test -n "$prev" && \ 60010b661123Smrg func_fatal_help "the \`$prevarg' option requires an argument" 60020b661123Smrg 60030b661123Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 60040b661123Smrg eval arg=\"$export_dynamic_flag_spec\" 60050b661123Smrg func_append compile_command " $arg" 60060b661123Smrg func_append finalize_command " $arg" 60070b661123Smrg fi 60080b661123Smrg 60090b661123Smrg oldlibs= 60100b661123Smrg # calculate the name of the file, without its directory 60110b661123Smrg func_basename "$output" 60120b661123Smrg outputname="$func_basename_result" 60130b661123Smrg libobjs_save="$libobjs" 60140b661123Smrg 60150b661123Smrg if test -n "$shlibpath_var"; then 60160b661123Smrg # get the directories listed in $shlibpath_var 6017880c7e28Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 60180b661123Smrg else 60190b661123Smrg shlib_search_path= 60200b661123Smrg fi 60210b661123Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 60220b661123Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 60230b661123Smrg 60240b661123Smrg func_dirname "$output" "/" "" 60250b661123Smrg output_objdir="$func_dirname_result$objdir" 6026880c7e28Smrg func_to_tool_file "$output_objdir/" 6027880c7e28Smrg tool_output_objdir=$func_to_tool_file_result 60280b661123Smrg # Create the object directory. 60290b661123Smrg func_mkdir_p "$output_objdir" 60300b661123Smrg 60310b661123Smrg # Determine the type of output 60320b661123Smrg case $output in 60330b661123Smrg "") 60340b661123Smrg func_fatal_help "you must specify an output file" 60350b661123Smrg ;; 60360b661123Smrg *.$libext) linkmode=oldlib ;; 60370b661123Smrg *.lo | *.$objext) linkmode=obj ;; 60380b661123Smrg *.la) linkmode=lib ;; 60390b661123Smrg *) linkmode=prog ;; # Anything else should be a program. 60400b661123Smrg esac 60410b661123Smrg 60420b661123Smrg specialdeplibs= 60430b661123Smrg 60440b661123Smrg libs= 60450b661123Smrg # Find all interdependent deplibs by searching for libraries 60460b661123Smrg # that are linked more than once (e.g. -la -lb -la) 60470b661123Smrg for deplib in $deplibs; do 6048880c7e28Smrg if $opt_preserve_dup_deps ; then 60490b661123Smrg case "$libs " in 6050880c7e28Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 60510b661123Smrg esac 60520b661123Smrg fi 6053880c7e28Smrg func_append libs " $deplib" 60540b661123Smrg done 60550b661123Smrg 60560b661123Smrg if test "$linkmode" = lib; then 60570b661123Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 60580b661123Smrg 60590b661123Smrg # Compute libraries that are listed more than once in $predeps 60600b661123Smrg # $postdeps and mark them as special (i.e., whose duplicates are 60610b661123Smrg # not to be eliminated). 60620b661123Smrg pre_post_deps= 60630b661123Smrg if $opt_duplicate_compiler_generated_deps; then 60640b661123Smrg for pre_post_dep in $predeps $postdeps; do 60650b661123Smrg case "$pre_post_deps " in 6066880c7e28Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 60670b661123Smrg esac 6068880c7e28Smrg func_append pre_post_deps " $pre_post_dep" 60690b661123Smrg done 60700b661123Smrg fi 60710b661123Smrg pre_post_deps= 60720b661123Smrg fi 60730b661123Smrg 60740b661123Smrg deplibs= 60750b661123Smrg newdependency_libs= 60760b661123Smrg newlib_search_path= 60770b661123Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 60780b661123Smrg notinst_deplibs= # not-installed libtool libraries 60790b661123Smrg notinst_path= # paths that contain not-installed libtool libraries 60800b661123Smrg 60810b661123Smrg case $linkmode in 60820b661123Smrg lib) 60830b661123Smrg passes="conv dlpreopen link" 60840b661123Smrg for file in $dlfiles $dlprefiles; do 60850b661123Smrg case $file in 60860b661123Smrg *.la) ;; 60870b661123Smrg *) 60880b661123Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 60890b661123Smrg ;; 60900b661123Smrg esac 60910b661123Smrg done 60920b661123Smrg ;; 60930b661123Smrg prog) 60940b661123Smrg compile_deplibs= 60950b661123Smrg finalize_deplibs= 60960b661123Smrg alldeplibs=no 60970b661123Smrg newdlfiles= 60980b661123Smrg newdlprefiles= 60990b661123Smrg passes="conv scan dlopen dlpreopen link" 61000b661123Smrg ;; 61010b661123Smrg *) passes="conv" 61020b661123Smrg ;; 61030b661123Smrg esac 61040b661123Smrg 61050b661123Smrg for pass in $passes; do 61060b661123Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 61070b661123Smrg # so that -L comes before libs that need it for instance... 61080b661123Smrg if test "$linkmode,$pass" = "lib,link"; then 61090b661123Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 61100b661123Smrg ## order, and fix it there properly 61110b661123Smrg tmp_deplibs= 61120b661123Smrg for deplib in $deplibs; do 61130b661123Smrg tmp_deplibs="$deplib $tmp_deplibs" 61140b661123Smrg done 61150b661123Smrg deplibs="$tmp_deplibs" 61160b661123Smrg fi 61170b661123Smrg 61180b661123Smrg if test "$linkmode,$pass" = "lib,link" || 61190b661123Smrg test "$linkmode,$pass" = "prog,scan"; then 61200b661123Smrg libs="$deplibs" 61210b661123Smrg deplibs= 61220b661123Smrg fi 61230b661123Smrg if test "$linkmode" = prog; then 61240b661123Smrg case $pass in 61250b661123Smrg dlopen) libs="$dlfiles" ;; 61260b661123Smrg dlpreopen) libs="$dlprefiles" ;; 61270b661123Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 61280b661123Smrg esac 61290b661123Smrg fi 61300b661123Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 61310b661123Smrg # Collect and forward deplibs of preopened libtool libs 61320b661123Smrg for lib in $dlprefiles; do 61330b661123Smrg # Ignore non-libtool-libs 61340b661123Smrg dependency_libs= 6135880c7e28Smrg func_resolve_sysroot "$lib" 61360b661123Smrg case $lib in 6137880c7e28Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 61380b661123Smrg esac 61390b661123Smrg 61400b661123Smrg # Collect preopened libtool deplibs, except any this library 61410b661123Smrg # has declared as weak libs 61420b661123Smrg for deplib in $dependency_libs; do 6143880c7e28Smrg func_basename "$deplib" 6144880c7e28Smrg deplib_base=$func_basename_result 61450b661123Smrg case " $weak_libs " in 61460b661123Smrg *" $deplib_base "*) ;; 6147880c7e28Smrg *) func_append deplibs " $deplib" ;; 61480b661123Smrg esac 61490b661123Smrg done 61500b661123Smrg done 61510b661123Smrg libs="$dlprefiles" 61520b661123Smrg fi 61530b661123Smrg if test "$pass" = dlopen; then 61540b661123Smrg # Collect dlpreopened libraries 61550b661123Smrg save_deplibs="$deplibs" 61560b661123Smrg deplibs= 61570b661123Smrg fi 61580b661123Smrg 61590b661123Smrg for deplib in $libs; do 61600b661123Smrg lib= 61610b661123Smrg found=no 61620b661123Smrg case $deplib in 6163880c7e28Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 6164880c7e28Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 61650b661123Smrg if test "$linkmode,$pass" = "prog,link"; then 61660b661123Smrg compile_deplibs="$deplib $compile_deplibs" 61670b661123Smrg finalize_deplibs="$deplib $finalize_deplibs" 61680b661123Smrg else 6169880c7e28Smrg func_append compiler_flags " $deplib" 61700b661123Smrg if test "$linkmode" = lib ; then 61710b661123Smrg case "$new_inherited_linker_flags " in 61720b661123Smrg *" $deplib "*) ;; 6173880c7e28Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 61740b661123Smrg esac 61750b661123Smrg fi 61760b661123Smrg fi 61770b661123Smrg continue 61780b661123Smrg ;; 61790b661123Smrg -l*) 61800b661123Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 61810b661123Smrg func_warning "\`-l' is ignored for archives/objects" 61820b661123Smrg continue 61830b661123Smrg fi 61840b661123Smrg func_stripname '-l' '' "$deplib" 61850b661123Smrg name=$func_stripname_result 61860b661123Smrg if test "$linkmode" = lib; then 61870b661123Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 61880b661123Smrg else 61890b661123Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 61900b661123Smrg fi 61910b661123Smrg for searchdir in $searchdirs; do 61920b661123Smrg for search_ext in .la $std_shrext .so .a; do 61930b661123Smrg # Search the libtool library 61940b661123Smrg lib="$searchdir/lib${name}${search_ext}" 61950b661123Smrg if test -f "$lib"; then 61960b661123Smrg if test "$search_ext" = ".la"; then 61970b661123Smrg found=yes 61980b661123Smrg else 61990b661123Smrg found=no 62000b661123Smrg fi 62010b661123Smrg break 2 62020b661123Smrg fi 62030b661123Smrg done 62040b661123Smrg done 62050b661123Smrg if test "$found" != yes; then 62060b661123Smrg # deplib doesn't seem to be a libtool library 62070b661123Smrg if test "$linkmode,$pass" = "prog,link"; then 62080b661123Smrg compile_deplibs="$deplib $compile_deplibs" 62090b661123Smrg finalize_deplibs="$deplib $finalize_deplibs" 62100b661123Smrg else 62110b661123Smrg deplibs="$deplib $deplibs" 62120b661123Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 62130b661123Smrg fi 62140b661123Smrg continue 62150b661123Smrg else # deplib is a libtool library 62160b661123Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 62170b661123Smrg # We need to do some special things here, and not later. 62180b661123Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 62190b661123Smrg case " $predeps $postdeps " in 62200b661123Smrg *" $deplib "*) 62210b661123Smrg if func_lalib_p "$lib"; then 62220b661123Smrg library_names= 62230b661123Smrg old_library= 62240b661123Smrg func_source "$lib" 62250b661123Smrg for l in $old_library $library_names; do 62260b661123Smrg ll="$l" 62270b661123Smrg done 62280b661123Smrg if test "X$ll" = "X$old_library" ; then # only static version available 62290b661123Smrg found=no 62300b661123Smrg func_dirname "$lib" "" "." 62310b661123Smrg ladir="$func_dirname_result" 62320b661123Smrg lib=$ladir/$old_library 62330b661123Smrg if test "$linkmode,$pass" = "prog,link"; then 62340b661123Smrg compile_deplibs="$deplib $compile_deplibs" 62350b661123Smrg finalize_deplibs="$deplib $finalize_deplibs" 62360b661123Smrg else 62370b661123Smrg deplibs="$deplib $deplibs" 62380b661123Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 62390b661123Smrg fi 62400b661123Smrg continue 62410b661123Smrg fi 62420b661123Smrg fi 62430b661123Smrg ;; 62440b661123Smrg *) ;; 62450b661123Smrg esac 62460b661123Smrg fi 62470b661123Smrg fi 62480b661123Smrg ;; # -l 62490b661123Smrg *.ltframework) 62500b661123Smrg if test "$linkmode,$pass" = "prog,link"; then 62510b661123Smrg compile_deplibs="$deplib $compile_deplibs" 62520b661123Smrg finalize_deplibs="$deplib $finalize_deplibs" 62530b661123Smrg else 62540b661123Smrg deplibs="$deplib $deplibs" 62550b661123Smrg if test "$linkmode" = lib ; then 62560b661123Smrg case "$new_inherited_linker_flags " in 62570b661123Smrg *" $deplib "*) ;; 6258880c7e28Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 62590b661123Smrg esac 62600b661123Smrg fi 62610b661123Smrg fi 62620b661123Smrg continue 62630b661123Smrg ;; 62640b661123Smrg -L*) 62650b661123Smrg case $linkmode in 62660b661123Smrg lib) 62670b661123Smrg deplibs="$deplib $deplibs" 62680b661123Smrg test "$pass" = conv && continue 62690b661123Smrg newdependency_libs="$deplib $newdependency_libs" 62700b661123Smrg func_stripname '-L' '' "$deplib" 6271880c7e28Smrg func_resolve_sysroot "$func_stripname_result" 6272880c7e28Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 62730b661123Smrg ;; 62740b661123Smrg prog) 62750b661123Smrg if test "$pass" = conv; then 62760b661123Smrg deplibs="$deplib $deplibs" 62770b661123Smrg continue 62780b661123Smrg fi 62790b661123Smrg if test "$pass" = scan; then 62800b661123Smrg deplibs="$deplib $deplibs" 62810b661123Smrg else 62820b661123Smrg compile_deplibs="$deplib $compile_deplibs" 62830b661123Smrg finalize_deplibs="$deplib $finalize_deplibs" 62840b661123Smrg fi 62850b661123Smrg func_stripname '-L' '' "$deplib" 6286880c7e28Smrg func_resolve_sysroot "$func_stripname_result" 6287880c7e28Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 62880b661123Smrg ;; 62890b661123Smrg *) 62900b661123Smrg func_warning "\`-L' is ignored for archives/objects" 62910b661123Smrg ;; 62920b661123Smrg esac # linkmode 62930b661123Smrg continue 62940b661123Smrg ;; # -L 62950b661123Smrg -R*) 62960b661123Smrg if test "$pass" = link; then 62970b661123Smrg func_stripname '-R' '' "$deplib" 6298880c7e28Smrg func_resolve_sysroot "$func_stripname_result" 6299880c7e28Smrg dir=$func_resolve_sysroot_result 63000b661123Smrg # Make sure the xrpath contains only unique directories. 63010b661123Smrg case "$xrpath " in 63020b661123Smrg *" $dir "*) ;; 6303880c7e28Smrg *) func_append xrpath " $dir" ;; 63040b661123Smrg esac 63050b661123Smrg fi 63060b661123Smrg deplibs="$deplib $deplibs" 63070b661123Smrg continue 63080b661123Smrg ;; 6309880c7e28Smrg *.la) 6310880c7e28Smrg func_resolve_sysroot "$deplib" 6311880c7e28Smrg lib=$func_resolve_sysroot_result 6312880c7e28Smrg ;; 63130b661123Smrg *.$libext) 63140b661123Smrg if test "$pass" = conv; then 63150b661123Smrg deplibs="$deplib $deplibs" 63160b661123Smrg continue 63170b661123Smrg fi 63180b661123Smrg case $linkmode in 63190b661123Smrg lib) 63200b661123Smrg # Linking convenience modules into shared libraries is allowed, 63210b661123Smrg # but linking other static libraries is non-portable. 63220b661123Smrg case " $dlpreconveniencelibs " in 63230b661123Smrg *" $deplib "*) ;; 63240b661123Smrg *) 63250b661123Smrg valid_a_lib=no 63260b661123Smrg case $deplibs_check_method in 63270b661123Smrg match_pattern*) 63280b661123Smrg set dummy $deplibs_check_method; shift 63290b661123Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 6330880c7e28Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 63310b661123Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 63320b661123Smrg valid_a_lib=yes 63330b661123Smrg fi 63340b661123Smrg ;; 63350b661123Smrg pass_all) 63360b661123Smrg valid_a_lib=yes 63370b661123Smrg ;; 63380b661123Smrg esac 63390b661123Smrg if test "$valid_a_lib" != yes; then 6340880c7e28Smrg echo 63410b661123Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 6342880c7e28Smrg echo "*** I have the capability to make that library automatically link in when" 6343880c7e28Smrg echo "*** you link to this library. But I can only do this if you have a" 6344880c7e28Smrg echo "*** shared version of the library, which you do not appear to have" 6345880c7e28Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 6346880c7e28Smrg echo "*** that it is just a static archive that I should not use here." 63470b661123Smrg else 6348880c7e28Smrg echo 63490b661123Smrg $ECHO "*** Warning: Linking the shared library $output against the" 63500b661123Smrg $ECHO "*** static library $deplib is not portable!" 63510b661123Smrg deplibs="$deplib $deplibs" 63520b661123Smrg fi 63530b661123Smrg ;; 63540b661123Smrg esac 63550b661123Smrg continue 63560b661123Smrg ;; 63570b661123Smrg prog) 63580b661123Smrg if test "$pass" != link; then 63590b661123Smrg deplibs="$deplib $deplibs" 63600b661123Smrg else 63610b661123Smrg compile_deplibs="$deplib $compile_deplibs" 63620b661123Smrg finalize_deplibs="$deplib $finalize_deplibs" 63630b661123Smrg fi 63640b661123Smrg continue 63650b661123Smrg ;; 63660b661123Smrg esac # linkmode 63670b661123Smrg ;; # *.$libext 63680b661123Smrg *.lo | *.$objext) 63690b661123Smrg if test "$pass" = conv; then 63700b661123Smrg deplibs="$deplib $deplibs" 63710b661123Smrg elif test "$linkmode" = prog; then 63720b661123Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 63730b661123Smrg # If there is no dlopen support or we're linking statically, 63740b661123Smrg # we need to preload. 6375880c7e28Smrg func_append newdlprefiles " $deplib" 63760b661123Smrg compile_deplibs="$deplib $compile_deplibs" 63770b661123Smrg finalize_deplibs="$deplib $finalize_deplibs" 63780b661123Smrg else 6379880c7e28Smrg func_append newdlfiles " $deplib" 63800b661123Smrg fi 63810b661123Smrg fi 63820b661123Smrg continue 63830b661123Smrg ;; 63840b661123Smrg %DEPLIBS%) 63850b661123Smrg alldeplibs=yes 63860b661123Smrg continue 63870b661123Smrg ;; 63880b661123Smrg esac # case $deplib 63890b661123Smrg 63900b661123Smrg if test "$found" = yes || test -f "$lib"; then : 63910b661123Smrg else 63920b661123Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 63930b661123Smrg fi 63940b661123Smrg 63950b661123Smrg # Check to see that this really is a libtool archive. 63960b661123Smrg func_lalib_unsafe_p "$lib" \ 63970b661123Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 63980b661123Smrg 63990b661123Smrg func_dirname "$lib" "" "." 64000b661123Smrg ladir="$func_dirname_result" 64010b661123Smrg 64020b661123Smrg dlname= 64030b661123Smrg dlopen= 64040b661123Smrg dlpreopen= 64050b661123Smrg libdir= 64060b661123Smrg library_names= 64070b661123Smrg old_library= 64080b661123Smrg inherited_linker_flags= 64090b661123Smrg # If the library was installed with an old release of libtool, 64100b661123Smrg # it will not redefine variables installed, or shouldnotlink 64110b661123Smrg installed=yes 64120b661123Smrg shouldnotlink=no 64130b661123Smrg avoidtemprpath= 64140b661123Smrg 64150b661123Smrg 64160b661123Smrg # Read the .la file 64170b661123Smrg func_source "$lib" 64180b661123Smrg 64190b661123Smrg # Convert "-framework foo" to "foo.ltframework" 64200b661123Smrg if test -n "$inherited_linker_flags"; then 6421880c7e28Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 64220b661123Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 64230b661123Smrg case " $new_inherited_linker_flags " in 64240b661123Smrg *" $tmp_inherited_linker_flag "*) ;; 6425880c7e28Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 64260b661123Smrg esac 64270b661123Smrg done 64280b661123Smrg fi 6429880c7e28Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 64300b661123Smrg if test "$linkmode,$pass" = "lib,link" || 64310b661123Smrg test "$linkmode,$pass" = "prog,scan" || 64320b661123Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 6433880c7e28Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 6434880c7e28Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 64350b661123Smrg fi 64360b661123Smrg 64370b661123Smrg if test "$pass" = conv; then 64380b661123Smrg # Only check for convenience libraries 64390b661123Smrg deplibs="$lib $deplibs" 64400b661123Smrg if test -z "$libdir"; then 64410b661123Smrg if test -z "$old_library"; then 64420b661123Smrg func_fatal_error "cannot find name of link library for \`$lib'" 64430b661123Smrg fi 64440b661123Smrg # It is a libtool convenience library, so add in its objects. 6445880c7e28Smrg func_append convenience " $ladir/$objdir/$old_library" 6446880c7e28Smrg func_append old_convenience " $ladir/$objdir/$old_library" 64470b661123Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 64480b661123Smrg func_fatal_error "\`$lib' is not a convenience library" 64490b661123Smrg fi 64500b661123Smrg tmp_libs= 64510b661123Smrg for deplib in $dependency_libs; do 64520b661123Smrg deplibs="$deplib $deplibs" 6453880c7e28Smrg if $opt_preserve_dup_deps ; then 64540b661123Smrg case "$tmp_libs " in 6455880c7e28Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 64560b661123Smrg esac 64570b661123Smrg fi 6458880c7e28Smrg func_append tmp_libs " $deplib" 64590b661123Smrg done 64600b661123Smrg continue 64610b661123Smrg fi # $pass = conv 64620b661123Smrg 64630b661123Smrg 64640b661123Smrg # Get the name of the library we link against. 64650b661123Smrg linklib= 6466880c7e28Smrg if test -n "$old_library" && 6467880c7e28Smrg { test "$prefer_static_libs" = yes || 6468880c7e28Smrg test "$prefer_static_libs,$installed" = "built,no"; }; then 6469880c7e28Smrg linklib=$old_library 6470880c7e28Smrg else 6471880c7e28Smrg for l in $old_library $library_names; do 6472880c7e28Smrg linklib="$l" 6473880c7e28Smrg done 6474880c7e28Smrg fi 64750b661123Smrg if test -z "$linklib"; then 64760b661123Smrg func_fatal_error "cannot find name of link library for \`$lib'" 64770b661123Smrg fi 64780b661123Smrg 64790b661123Smrg # This library was specified with -dlopen. 64800b661123Smrg if test "$pass" = dlopen; then 64810b661123Smrg if test -z "$libdir"; then 64820b661123Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 64830b661123Smrg fi 64840b661123Smrg if test -z "$dlname" || 64850b661123Smrg test "$dlopen_support" != yes || 64860b661123Smrg test "$build_libtool_libs" = no; then 64870b661123Smrg # If there is no dlname, no dlopen support or we're linking 64880b661123Smrg # statically, we need to preload. We also need to preload any 64890b661123Smrg # dependent libraries so libltdl's deplib preloader doesn't 64900b661123Smrg # bomb out in the load deplibs phase. 6491880c7e28Smrg func_append dlprefiles " $lib $dependency_libs" 64920b661123Smrg else 6493880c7e28Smrg func_append newdlfiles " $lib" 64940b661123Smrg fi 64950b661123Smrg continue 64960b661123Smrg fi # $pass = dlopen 64970b661123Smrg 64980b661123Smrg # We need an absolute path. 64990b661123Smrg case $ladir in 65000b661123Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 65010b661123Smrg *) 65020b661123Smrg abs_ladir=`cd "$ladir" && pwd` 65030b661123Smrg if test -z "$abs_ladir"; then 65040b661123Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 65050b661123Smrg func_warning "passing it literally to the linker, although it might fail" 65060b661123Smrg abs_ladir="$ladir" 65070b661123Smrg fi 65080b661123Smrg ;; 65090b661123Smrg esac 65100b661123Smrg func_basename "$lib" 65110b661123Smrg laname="$func_basename_result" 65120b661123Smrg 65130b661123Smrg # Find the relevant object directory and library name. 65140b661123Smrg if test "X$installed" = Xyes; then 6515880c7e28Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 65160b661123Smrg func_warning "library \`$lib' was moved." 65170b661123Smrg dir="$ladir" 65180b661123Smrg absdir="$abs_ladir" 65190b661123Smrg libdir="$abs_ladir" 65200b661123Smrg else 6521880c7e28Smrg dir="$lt_sysroot$libdir" 6522880c7e28Smrg absdir="$lt_sysroot$libdir" 65230b661123Smrg fi 65240b661123Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 65250b661123Smrg else 65260b661123Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 65270b661123Smrg dir="$ladir" 65280b661123Smrg absdir="$abs_ladir" 65290b661123Smrg # Remove this search path later 6530880c7e28Smrg func_append notinst_path " $abs_ladir" 65310b661123Smrg else 65320b661123Smrg dir="$ladir/$objdir" 65330b661123Smrg absdir="$abs_ladir/$objdir" 65340b661123Smrg # Remove this search path later 6535880c7e28Smrg func_append notinst_path " $abs_ladir" 65360b661123Smrg fi 65370b661123Smrg fi # $installed = yes 65380b661123Smrg func_stripname 'lib' '.la' "$laname" 65390b661123Smrg name=$func_stripname_result 65400b661123Smrg 65410b661123Smrg # This library was specified with -dlpreopen. 65420b661123Smrg if test "$pass" = dlpreopen; then 65430b661123Smrg if test -z "$libdir" && test "$linkmode" = prog; then 65440b661123Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 65450b661123Smrg fi 6546880c7e28Smrg case "$host" in 6547880c7e28Smrg # special handling for platforms with PE-DLLs. 6548880c7e28Smrg *cygwin* | *mingw* | *cegcc* ) 6549880c7e28Smrg # Linker will automatically link against shared library if both 6550880c7e28Smrg # static and shared are present. Therefore, ensure we extract 6551880c7e28Smrg # symbols from the import library if a shared library is present 6552880c7e28Smrg # (otherwise, the dlopen module name will be incorrect). We do 6553880c7e28Smrg # this by putting the import library name into $newdlprefiles. 6554880c7e28Smrg # We recover the dlopen module name by 'saving' the la file 6555880c7e28Smrg # name in a special purpose variable, and (later) extracting the 6556880c7e28Smrg # dlname from the la file. 6557880c7e28Smrg if test -n "$dlname"; then 6558880c7e28Smrg func_tr_sh "$dir/$linklib" 6559880c7e28Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 6560880c7e28Smrg func_append newdlprefiles " $dir/$linklib" 6561880c7e28Smrg else 6562880c7e28Smrg func_append newdlprefiles " $dir/$old_library" 6563880c7e28Smrg # Keep a list of preopened convenience libraries to check 6564880c7e28Smrg # that they are being used correctly in the link pass. 6565880c7e28Smrg test -z "$libdir" && \ 6566880c7e28Smrg func_append dlpreconveniencelibs " $dir/$old_library" 6567880c7e28Smrg fi 6568880c7e28Smrg ;; 6569880c7e28Smrg * ) 6570880c7e28Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 6571880c7e28Smrg # are required to link). 6572880c7e28Smrg if test -n "$old_library"; then 6573880c7e28Smrg func_append newdlprefiles " $dir/$old_library" 6574880c7e28Smrg # Keep a list of preopened convenience libraries to check 6575880c7e28Smrg # that they are being used correctly in the link pass. 6576880c7e28Smrg test -z "$libdir" && \ 6577880c7e28Smrg func_append dlpreconveniencelibs " $dir/$old_library" 6578880c7e28Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 6579880c7e28Smrg elif test -n "$dlname"; then 6580880c7e28Smrg func_append newdlprefiles " $dir/$dlname" 6581880c7e28Smrg else 6582880c7e28Smrg func_append newdlprefiles " $dir/$linklib" 6583880c7e28Smrg fi 6584880c7e28Smrg ;; 6585880c7e28Smrg esac 65860b661123Smrg fi # $pass = dlpreopen 65870b661123Smrg 65880b661123Smrg if test -z "$libdir"; then 65890b661123Smrg # Link the convenience library 65900b661123Smrg if test "$linkmode" = lib; then 65910b661123Smrg deplibs="$dir/$old_library $deplibs" 65920b661123Smrg elif test "$linkmode,$pass" = "prog,link"; then 65930b661123Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 65940b661123Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 65950b661123Smrg else 65960b661123Smrg deplibs="$lib $deplibs" # used for prog,scan pass 65970b661123Smrg fi 65980b661123Smrg continue 65990b661123Smrg fi 66000b661123Smrg 66010b661123Smrg 66020b661123Smrg if test "$linkmode" = prog && test "$pass" != link; then 6603880c7e28Smrg func_append newlib_search_path " $ladir" 66040b661123Smrg deplibs="$lib $deplibs" 66050b661123Smrg 66060b661123Smrg linkalldeplibs=no 66070b661123Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 66080b661123Smrg test "$build_libtool_libs" = no; then 66090b661123Smrg linkalldeplibs=yes 66100b661123Smrg fi 66110b661123Smrg 66120b661123Smrg tmp_libs= 66130b661123Smrg for deplib in $dependency_libs; do 66140b661123Smrg case $deplib in 66150b661123Smrg -L*) func_stripname '-L' '' "$deplib" 6616880c7e28Smrg func_resolve_sysroot "$func_stripname_result" 6617880c7e28Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 66180b661123Smrg ;; 66190b661123Smrg esac 66200b661123Smrg # Need to link against all dependency_libs? 66210b661123Smrg if test "$linkalldeplibs" = yes; then 66220b661123Smrg deplibs="$deplib $deplibs" 66230b661123Smrg else 66240b661123Smrg # Need to hardcode shared library paths 66250b661123Smrg # or/and link against static libraries 66260b661123Smrg newdependency_libs="$deplib $newdependency_libs" 66270b661123Smrg fi 6628880c7e28Smrg if $opt_preserve_dup_deps ; then 66290b661123Smrg case "$tmp_libs " in 6630880c7e28Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 66310b661123Smrg esac 66320b661123Smrg fi 6633880c7e28Smrg func_append tmp_libs " $deplib" 66340b661123Smrg done # for deplib 66350b661123Smrg continue 66360b661123Smrg fi # $linkmode = prog... 66370b661123Smrg 66380b661123Smrg if test "$linkmode,$pass" = "prog,link"; then 66390b661123Smrg if test -n "$library_names" && 66400b661123Smrg { { test "$prefer_static_libs" = no || 66410b661123Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 66420b661123Smrg test -z "$old_library"; }; then 66430b661123Smrg # We need to hardcode the library path 66440b661123Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 66450b661123Smrg # Make sure the rpath contains only unique directories. 66460b661123Smrg case "$temp_rpath:" in 66470b661123Smrg *"$absdir:"*) ;; 6648880c7e28Smrg *) func_append temp_rpath "$absdir:" ;; 66490b661123Smrg esac 66500b661123Smrg fi 66510b661123Smrg 66520b661123Smrg # Hardcode the library path. 66530b661123Smrg # Skip directories that are in the system default run-time 66540b661123Smrg # search path. 66550b661123Smrg case " $sys_lib_dlsearch_path " in 66560b661123Smrg *" $absdir "*) ;; 66570b661123Smrg *) 66580b661123Smrg case "$compile_rpath " in 66590b661123Smrg *" $absdir "*) ;; 6660880c7e28Smrg *) func_append compile_rpath " $absdir" ;; 66610b661123Smrg esac 66620b661123Smrg ;; 66630b661123Smrg esac 66640b661123Smrg case " $sys_lib_dlsearch_path " in 66650b661123Smrg *" $libdir "*) ;; 66660b661123Smrg *) 66670b661123Smrg case "$finalize_rpath " in 66680b661123Smrg *" $libdir "*) ;; 6669880c7e28Smrg *) func_append finalize_rpath " $libdir" ;; 66700b661123Smrg esac 66710b661123Smrg ;; 66720b661123Smrg esac 66730b661123Smrg fi # $linkmode,$pass = prog,link... 66740b661123Smrg 66750b661123Smrg if test "$alldeplibs" = yes && 66760b661123Smrg { test "$deplibs_check_method" = pass_all || 66770b661123Smrg { test "$build_libtool_libs" = yes && 66780b661123Smrg test -n "$library_names"; }; }; then 66790b661123Smrg # We only need to search for static libraries 66800b661123Smrg continue 66810b661123Smrg fi 66820b661123Smrg fi 66830b661123Smrg 66840b661123Smrg link_static=no # Whether the deplib will be linked statically 66850b661123Smrg use_static_libs=$prefer_static_libs 66860b661123Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 66870b661123Smrg use_static_libs=no 66880b661123Smrg fi 66890b661123Smrg if test -n "$library_names" && 66900b661123Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 66910b661123Smrg case $host in 66920b661123Smrg *cygwin* | *mingw* | *cegcc*) 66930b661123Smrg # No point in relinking DLLs because paths are not encoded 6694880c7e28Smrg func_append notinst_deplibs " $lib" 66950b661123Smrg need_relink=no 66960b661123Smrg ;; 66970b661123Smrg *) 66980b661123Smrg if test "$installed" = no; then 6699880c7e28Smrg func_append notinst_deplibs " $lib" 67000b661123Smrg need_relink=yes 67010b661123Smrg fi 67020b661123Smrg ;; 67030b661123Smrg esac 67040b661123Smrg # This is a shared library 67050b661123Smrg 67060b661123Smrg # Warn about portability, can't link against -module's on some 67070b661123Smrg # systems (darwin). Don't bleat about dlopened modules though! 67080b661123Smrg dlopenmodule="" 67090b661123Smrg for dlpremoduletest in $dlprefiles; do 67100b661123Smrg if test "X$dlpremoduletest" = "X$lib"; then 67110b661123Smrg dlopenmodule="$dlpremoduletest" 67120b661123Smrg break 67130b661123Smrg fi 67140b661123Smrg done 67150b661123Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 6716880c7e28Smrg echo 67170b661123Smrg if test "$linkmode" = prog; then 67180b661123Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 67190b661123Smrg else 67200b661123Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 67210b661123Smrg fi 67220b661123Smrg $ECHO "*** $linklib is not portable!" 67230b661123Smrg fi 67240b661123Smrg if test "$linkmode" = lib && 67250b661123Smrg test "$hardcode_into_libs" = yes; then 67260b661123Smrg # Hardcode the library path. 67270b661123Smrg # Skip directories that are in the system default run-time 67280b661123Smrg # search path. 67290b661123Smrg case " $sys_lib_dlsearch_path " in 67300b661123Smrg *" $absdir "*) ;; 67310b661123Smrg *) 67320b661123Smrg case "$compile_rpath " in 67330b661123Smrg *" $absdir "*) ;; 6734880c7e28Smrg *) func_append compile_rpath " $absdir" ;; 67350b661123Smrg esac 67360b661123Smrg ;; 67370b661123Smrg esac 67380b661123Smrg case " $sys_lib_dlsearch_path " in 67390b661123Smrg *" $libdir "*) ;; 67400b661123Smrg *) 67410b661123Smrg case "$finalize_rpath " in 67420b661123Smrg *" $libdir "*) ;; 6743880c7e28Smrg *) func_append finalize_rpath " $libdir" ;; 67440b661123Smrg esac 67450b661123Smrg ;; 67460b661123Smrg esac 67470b661123Smrg fi 67480b661123Smrg 67490b661123Smrg if test -n "$old_archive_from_expsyms_cmds"; then 67500b661123Smrg # figure out the soname 67510b661123Smrg set dummy $library_names 67520b661123Smrg shift 67530b661123Smrg realname="$1" 67540b661123Smrg shift 67550b661123Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 67560b661123Smrg # use dlname if we got it. it's perfectly good, no? 67570b661123Smrg if test -n "$dlname"; then 67580b661123Smrg soname="$dlname" 67590b661123Smrg elif test -n "$soname_spec"; then 67600b661123Smrg # bleh windows 67610b661123Smrg case $host in 67620b661123Smrg *cygwin* | mingw* | *cegcc*) 67630b661123Smrg func_arith $current - $age 67640b661123Smrg major=$func_arith_result 67650b661123Smrg versuffix="-$major" 67660b661123Smrg ;; 67670b661123Smrg esac 67680b661123Smrg eval soname=\"$soname_spec\" 67690b661123Smrg else 67700b661123Smrg soname="$realname" 67710b661123Smrg fi 67720b661123Smrg 67730b661123Smrg # Make a new name for the extract_expsyms_cmds to use 67740b661123Smrg soroot="$soname" 67750b661123Smrg func_basename "$soroot" 67760b661123Smrg soname="$func_basename_result" 67770b661123Smrg func_stripname 'lib' '.dll' "$soname" 67780b661123Smrg newlib=libimp-$func_stripname_result.a 67790b661123Smrg 67800b661123Smrg # If the library has no export list, then create one now 67810b661123Smrg if test -f "$output_objdir/$soname-def"; then : 67820b661123Smrg else 67830b661123Smrg func_verbose "extracting exported symbol list from \`$soname'" 67840b661123Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 67850b661123Smrg fi 67860b661123Smrg 67870b661123Smrg # Create $newlib 67880b661123Smrg if test -f "$output_objdir/$newlib"; then :; else 67890b661123Smrg func_verbose "generating import library for \`$soname'" 67900b661123Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 67910b661123Smrg fi 67920b661123Smrg # make sure the library variables are pointing to the new library 67930b661123Smrg dir=$output_objdir 67940b661123Smrg linklib=$newlib 67950b661123Smrg fi # test -n "$old_archive_from_expsyms_cmds" 67960b661123Smrg 6797880c7e28Smrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 67980b661123Smrg add_shlibpath= 67990b661123Smrg add_dir= 68000b661123Smrg add= 68010b661123Smrg lib_linked=yes 68020b661123Smrg case $hardcode_action in 68030b661123Smrg immediate | unsupported) 68040b661123Smrg if test "$hardcode_direct" = no; then 68050b661123Smrg add="$dir/$linklib" 68060b661123Smrg case $host in 68070b661123Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 68080b661123Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 68090b661123Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 68100b661123Smrg *-*-unixware7*) add_dir="-L$dir" ;; 68110b661123Smrg *-*-darwin* ) 68120b661123Smrg # if the lib is a (non-dlopened) module then we can not 68130b661123Smrg # link against it, someone is ignoring the earlier warnings 68140b661123Smrg if /usr/bin/file -L $add 2> /dev/null | 68150b661123Smrg $GREP ": [^:]* bundle" >/dev/null ; then 68160b661123Smrg if test "X$dlopenmodule" != "X$lib"; then 68170b661123Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 68180b661123Smrg if test -z "$old_library" ; then 6819880c7e28Smrg echo 6820880c7e28Smrg echo "*** And there doesn't seem to be a static archive available" 6821880c7e28Smrg echo "*** The link will probably fail, sorry" 68220b661123Smrg else 68230b661123Smrg add="$dir/$old_library" 68240b661123Smrg fi 68250b661123Smrg elif test -n "$old_library"; then 68260b661123Smrg add="$dir/$old_library" 68270b661123Smrg fi 68280b661123Smrg fi 68290b661123Smrg esac 68300b661123Smrg elif test "$hardcode_minus_L" = no; then 68310b661123Smrg case $host in 68320b661123Smrg *-*-sunos*) add_shlibpath="$dir" ;; 68330b661123Smrg esac 68340b661123Smrg add_dir="-L$dir" 68350b661123Smrg add="-l$name" 68360b661123Smrg elif test "$hardcode_shlibpath_var" = no; then 68370b661123Smrg add_shlibpath="$dir" 68380b661123Smrg add="-l$name" 68390b661123Smrg else 68400b661123Smrg lib_linked=no 68410b661123Smrg fi 68420b661123Smrg ;; 68430b661123Smrg relink) 68440b661123Smrg if test "$hardcode_direct" = yes && 68450b661123Smrg test "$hardcode_direct_absolute" = no; then 68460b661123Smrg add="$dir/$linklib" 68470b661123Smrg elif test "$hardcode_minus_L" = yes; then 6848880c7e28Smrg add_dir="-L$absdir" 68490b661123Smrg # Try looking first in the location we're being installed to. 68500b661123Smrg if test -n "$inst_prefix_dir"; then 68510b661123Smrg case $libdir in 68520b661123Smrg [\\/]*) 6853880c7e28Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 68540b661123Smrg ;; 68550b661123Smrg esac 68560b661123Smrg fi 68570b661123Smrg add="-l$name" 68580b661123Smrg elif test "$hardcode_shlibpath_var" = yes; then 68590b661123Smrg add_shlibpath="$dir" 68600b661123Smrg add="-l$name" 68610b661123Smrg else 68620b661123Smrg lib_linked=no 68630b661123Smrg fi 68640b661123Smrg ;; 68650b661123Smrg *) lib_linked=no ;; 68660b661123Smrg esac 68670b661123Smrg 68680b661123Smrg if test "$lib_linked" != yes; then 68690b661123Smrg func_fatal_configuration "unsupported hardcode properties" 68700b661123Smrg fi 68710b661123Smrg 68720b661123Smrg if test -n "$add_shlibpath"; then 68730b661123Smrg case :$compile_shlibpath: in 68740b661123Smrg *":$add_shlibpath:"*) ;; 6875880c7e28Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 68760b661123Smrg esac 68770b661123Smrg fi 68780b661123Smrg if test "$linkmode" = prog; then 68790b661123Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 68800b661123Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 68810b661123Smrg else 68820b661123Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 68830b661123Smrg test -n "$add" && deplibs="$add $deplibs" 68840b661123Smrg if test "$hardcode_direct" != yes && 68850b661123Smrg test "$hardcode_minus_L" != yes && 68860b661123Smrg test "$hardcode_shlibpath_var" = yes; then 68870b661123Smrg case :$finalize_shlibpath: in 68880b661123Smrg *":$libdir:"*) ;; 6889880c7e28Smrg *) func_append finalize_shlibpath "$libdir:" ;; 68900b661123Smrg esac 68910b661123Smrg fi 68920b661123Smrg fi 68930b661123Smrg fi 68940b661123Smrg 6895880c7e28Smrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 68960b661123Smrg add_shlibpath= 68970b661123Smrg add_dir= 68980b661123Smrg add= 68990b661123Smrg # Finalize command for both is simple: just hardcode it. 69000b661123Smrg if test "$hardcode_direct" = yes && 69010b661123Smrg test "$hardcode_direct_absolute" = no; then 69020b661123Smrg add="$libdir/$linklib" 69030b661123Smrg elif test "$hardcode_minus_L" = yes; then 69040b661123Smrg add_dir="-L$libdir" 69050b661123Smrg add="-l$name" 69060b661123Smrg elif test "$hardcode_shlibpath_var" = yes; then 69070b661123Smrg case :$finalize_shlibpath: in 69080b661123Smrg *":$libdir:"*) ;; 6909880c7e28Smrg *) func_append finalize_shlibpath "$libdir:" ;; 69100b661123Smrg esac 69110b661123Smrg add="-l$name" 69120b661123Smrg elif test "$hardcode_automatic" = yes; then 69130b661123Smrg if test -n "$inst_prefix_dir" && 69140b661123Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 69150b661123Smrg add="$inst_prefix_dir$libdir/$linklib" 69160b661123Smrg else 69170b661123Smrg add="$libdir/$linklib" 69180b661123Smrg fi 69190b661123Smrg else 69200b661123Smrg # We cannot seem to hardcode it, guess we'll fake it. 69210b661123Smrg add_dir="-L$libdir" 69220b661123Smrg # Try looking first in the location we're being installed to. 69230b661123Smrg if test -n "$inst_prefix_dir"; then 69240b661123Smrg case $libdir in 69250b661123Smrg [\\/]*) 6926880c7e28Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 69270b661123Smrg ;; 69280b661123Smrg esac 69290b661123Smrg fi 69300b661123Smrg add="-l$name" 69310b661123Smrg fi 69320b661123Smrg 69330b661123Smrg if test "$linkmode" = prog; then 69340b661123Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 69350b661123Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 69360b661123Smrg else 69370b661123Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 69380b661123Smrg test -n "$add" && deplibs="$add $deplibs" 69390b661123Smrg fi 69400b661123Smrg fi 69410b661123Smrg elif test "$linkmode" = prog; then 69420b661123Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 69430b661123Smrg # is not unsupported. This is valid on all known static and 69440b661123Smrg # shared platforms. 69450b661123Smrg if test "$hardcode_direct" != unsupported; then 69460b661123Smrg test -n "$old_library" && linklib="$old_library" 69470b661123Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 69480b661123Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 69490b661123Smrg else 69500b661123Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 69510b661123Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 69520b661123Smrg fi 69530b661123Smrg elif test "$build_libtool_libs" = yes; then 69540b661123Smrg # Not a shared library 69550b661123Smrg if test "$deplibs_check_method" != pass_all; then 69560b661123Smrg # We're trying link a shared library against a static one 69570b661123Smrg # but the system doesn't support it. 69580b661123Smrg 69590b661123Smrg # Just print a warning and add the library to dependency_libs so 69600b661123Smrg # that the program can be linked against the static library. 6961880c7e28Smrg echo 69620b661123Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 6963880c7e28Smrg echo "*** I have the capability to make that library automatically link in when" 6964880c7e28Smrg echo "*** you link to this library. But I can only do this if you have a" 6965880c7e28Smrg echo "*** shared version of the library, which you do not appear to have." 69660b661123Smrg if test "$module" = yes; then 6967880c7e28Smrg echo "*** But as you try to build a module library, libtool will still create " 6968880c7e28Smrg echo "*** a static module, that should work as long as the dlopening application" 6969880c7e28Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 69700b661123Smrg if test -z "$global_symbol_pipe"; then 6971880c7e28Smrg echo 6972880c7e28Smrg echo "*** However, this would only work if libtool was able to extract symbol" 6973880c7e28Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 6974880c7e28Smrg echo "*** not find such a program. So, this module is probably useless." 6975880c7e28Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 69760b661123Smrg fi 69770b661123Smrg if test "$build_old_libs" = no; then 69780b661123Smrg build_libtool_libs=module 69790b661123Smrg build_old_libs=yes 69800b661123Smrg else 69810b661123Smrg build_libtool_libs=no 69820b661123Smrg fi 69830b661123Smrg fi 69840b661123Smrg else 69850b661123Smrg deplibs="$dir/$old_library $deplibs" 69860b661123Smrg link_static=yes 69870b661123Smrg fi 69880b661123Smrg fi # link shared/static library? 69890b661123Smrg 69900b661123Smrg if test "$linkmode" = lib; then 69910b661123Smrg if test -n "$dependency_libs" && 69920b661123Smrg { test "$hardcode_into_libs" != yes || 69930b661123Smrg test "$build_old_libs" = yes || 69940b661123Smrg test "$link_static" = yes; }; then 69950b661123Smrg # Extract -R from dependency_libs 69960b661123Smrg temp_deplibs= 69970b661123Smrg for libdir in $dependency_libs; do 69980b661123Smrg case $libdir in 69990b661123Smrg -R*) func_stripname '-R' '' "$libdir" 70000b661123Smrg temp_xrpath=$func_stripname_result 70010b661123Smrg case " $xrpath " in 70020b661123Smrg *" $temp_xrpath "*) ;; 7003880c7e28Smrg *) func_append xrpath " $temp_xrpath";; 70040b661123Smrg esac;; 7005880c7e28Smrg *) func_append temp_deplibs " $libdir";; 70060b661123Smrg esac 70070b661123Smrg done 70080b661123Smrg dependency_libs="$temp_deplibs" 70090b661123Smrg fi 70100b661123Smrg 7011880c7e28Smrg func_append newlib_search_path " $absdir" 70120b661123Smrg # Link against this library 70130b661123Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 70140b661123Smrg # ... and its dependency_libs 70150b661123Smrg tmp_libs= 70160b661123Smrg for deplib in $dependency_libs; do 70170b661123Smrg newdependency_libs="$deplib $newdependency_libs" 7018880c7e28Smrg case $deplib in 7019880c7e28Smrg -L*) func_stripname '-L' '' "$deplib" 7020880c7e28Smrg func_resolve_sysroot "$func_stripname_result";; 7021880c7e28Smrg *) func_resolve_sysroot "$deplib" ;; 7022880c7e28Smrg esac 7023880c7e28Smrg if $opt_preserve_dup_deps ; then 70240b661123Smrg case "$tmp_libs " in 7025880c7e28Smrg *" $func_resolve_sysroot_result "*) 7026880c7e28Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 70270b661123Smrg esac 70280b661123Smrg fi 7029880c7e28Smrg func_append tmp_libs " $func_resolve_sysroot_result" 70300b661123Smrg done 70310b661123Smrg 70320b661123Smrg if test "$link_all_deplibs" != no; then 70330b661123Smrg # Add the search paths of all dependency libraries 70340b661123Smrg for deplib in $dependency_libs; do 7035880c7e28Smrg path= 70360b661123Smrg case $deplib in 70370b661123Smrg -L*) path="$deplib" ;; 70380b661123Smrg *.la) 7039880c7e28Smrg func_resolve_sysroot "$deplib" 7040880c7e28Smrg deplib=$func_resolve_sysroot_result 70410b661123Smrg func_dirname "$deplib" "" "." 7042880c7e28Smrg dir=$func_dirname_result 70430b661123Smrg # We need an absolute path. 70440b661123Smrg case $dir in 70450b661123Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 70460b661123Smrg *) 70470b661123Smrg absdir=`cd "$dir" && pwd` 70480b661123Smrg if test -z "$absdir"; then 70490b661123Smrg func_warning "cannot determine absolute directory name of \`$dir'" 70500b661123Smrg absdir="$dir" 70510b661123Smrg fi 70520b661123Smrg ;; 70530b661123Smrg esac 70540b661123Smrg if $GREP "^installed=no" $deplib > /dev/null; then 70550b661123Smrg case $host in 70560b661123Smrg *-*-darwin*) 70570b661123Smrg depdepl= 70580b661123Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 70590b661123Smrg if test -n "$deplibrary_names" ; then 70600b661123Smrg for tmp in $deplibrary_names ; do 70610b661123Smrg depdepl=$tmp 70620b661123Smrg done 70630b661123Smrg if test -f "$absdir/$objdir/$depdepl" ; then 70640b661123Smrg depdepl="$absdir/$objdir/$depdepl" 70650b661123Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 70660b661123Smrg if test -z "$darwin_install_name"; then 70670b661123Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 70680b661123Smrg fi 7069880c7e28Smrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 7070880c7e28Smrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 70710b661123Smrg path= 70720b661123Smrg fi 70730b661123Smrg fi 70740b661123Smrg ;; 70750b661123Smrg *) 70760b661123Smrg path="-L$absdir/$objdir" 70770b661123Smrg ;; 70780b661123Smrg esac 70790b661123Smrg else 70800b661123Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 70810b661123Smrg test -z "$libdir" && \ 70820b661123Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 70830b661123Smrg test "$absdir" != "$libdir" && \ 70840b661123Smrg func_warning "\`$deplib' seems to be moved" 70850b661123Smrg 70860b661123Smrg path="-L$absdir" 70870b661123Smrg fi 70880b661123Smrg ;; 70890b661123Smrg esac 70900b661123Smrg case " $deplibs " in 70910b661123Smrg *" $path "*) ;; 70920b661123Smrg *) deplibs="$path $deplibs" ;; 70930b661123Smrg esac 70940b661123Smrg done 70950b661123Smrg fi # link_all_deplibs != no 70960b661123Smrg fi # linkmode = lib 70970b661123Smrg done # for deplib in $libs 70980b661123Smrg if test "$pass" = link; then 70990b661123Smrg if test "$linkmode" = "prog"; then 71000b661123Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 71010b661123Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 71020b661123Smrg else 7103880c7e28Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 71040b661123Smrg fi 71050b661123Smrg fi 71060b661123Smrg dependency_libs="$newdependency_libs" 71070b661123Smrg if test "$pass" = dlpreopen; then 71080b661123Smrg # Link the dlpreopened libraries before other libraries 71090b661123Smrg for deplib in $save_deplibs; do 71100b661123Smrg deplibs="$deplib $deplibs" 71110b661123Smrg done 71120b661123Smrg fi 71130b661123Smrg if test "$pass" != dlopen; then 71140b661123Smrg if test "$pass" != conv; then 71150b661123Smrg # Make sure lib_search_path contains only unique directories. 71160b661123Smrg lib_search_path= 71170b661123Smrg for dir in $newlib_search_path; do 71180b661123Smrg case "$lib_search_path " in 71190b661123Smrg *" $dir "*) ;; 7120880c7e28Smrg *) func_append lib_search_path " $dir" ;; 71210b661123Smrg esac 71220b661123Smrg done 71230b661123Smrg newlib_search_path= 71240b661123Smrg fi 71250b661123Smrg 71260b661123Smrg if test "$linkmode,$pass" != "prog,link"; then 71270b661123Smrg vars="deplibs" 71280b661123Smrg else 71290b661123Smrg vars="compile_deplibs finalize_deplibs" 71300b661123Smrg fi 71310b661123Smrg for var in $vars dependency_libs; do 71320b661123Smrg # Add libraries to $var in reverse order 71330b661123Smrg eval tmp_libs=\"\$$var\" 71340b661123Smrg new_libs= 71350b661123Smrg for deplib in $tmp_libs; do 71360b661123Smrg # FIXME: Pedantically, this is the right thing to do, so 71370b661123Smrg # that some nasty dependency loop isn't accidentally 71380b661123Smrg # broken: 71390b661123Smrg #new_libs="$deplib $new_libs" 71400b661123Smrg # Pragmatically, this seems to cause very few problems in 71410b661123Smrg # practice: 71420b661123Smrg case $deplib in 71430b661123Smrg -L*) new_libs="$deplib $new_libs" ;; 71440b661123Smrg -R*) ;; 71450b661123Smrg *) 71460b661123Smrg # And here is the reason: when a library appears more 71470b661123Smrg # than once as an explicit dependence of a library, or 71480b661123Smrg # is implicitly linked in more than once by the 71490b661123Smrg # compiler, it is considered special, and multiple 71500b661123Smrg # occurrences thereof are not removed. Compare this 71510b661123Smrg # with having the same library being listed as a 71520b661123Smrg # dependency of multiple other libraries: in this case, 71530b661123Smrg # we know (pedantically, we assume) the library does not 71540b661123Smrg # need to be listed more than once, so we keep only the 71550b661123Smrg # last copy. This is not always right, but it is rare 71560b661123Smrg # enough that we require users that really mean to play 71570b661123Smrg # such unportable linking tricks to link the library 71580b661123Smrg # using -Wl,-lname, so that libtool does not consider it 71590b661123Smrg # for duplicate removal. 71600b661123Smrg case " $specialdeplibs " in 71610b661123Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 71620b661123Smrg *) 71630b661123Smrg case " $new_libs " in 71640b661123Smrg *" $deplib "*) ;; 71650b661123Smrg *) new_libs="$deplib $new_libs" ;; 71660b661123Smrg esac 71670b661123Smrg ;; 71680b661123Smrg esac 71690b661123Smrg ;; 71700b661123Smrg esac 71710b661123Smrg done 71720b661123Smrg tmp_libs= 71730b661123Smrg for deplib in $new_libs; do 71740b661123Smrg case $deplib in 71750b661123Smrg -L*) 71760b661123Smrg case " $tmp_libs " in 71770b661123Smrg *" $deplib "*) ;; 7178880c7e28Smrg *) func_append tmp_libs " $deplib" ;; 71790b661123Smrg esac 71800b661123Smrg ;; 7181880c7e28Smrg *) func_append tmp_libs " $deplib" ;; 71820b661123Smrg esac 71830b661123Smrg done 71840b661123Smrg eval $var=\"$tmp_libs\" 71850b661123Smrg done # for var 71860b661123Smrg fi 71870b661123Smrg # Last step: remove runtime libs from dependency_libs 71880b661123Smrg # (they stay in deplibs) 71890b661123Smrg tmp_libs= 71900b661123Smrg for i in $dependency_libs ; do 71910b661123Smrg case " $predeps $postdeps $compiler_lib_search_path " in 71920b661123Smrg *" $i "*) 71930b661123Smrg i="" 71940b661123Smrg ;; 71950b661123Smrg esac 71960b661123Smrg if test -n "$i" ; then 7197880c7e28Smrg func_append tmp_libs " $i" 71980b661123Smrg fi 71990b661123Smrg done 72000b661123Smrg dependency_libs=$tmp_libs 72010b661123Smrg done # for pass 72020b661123Smrg if test "$linkmode" = prog; then 72030b661123Smrg dlfiles="$newdlfiles" 72040b661123Smrg fi 72050b661123Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 72060b661123Smrg dlprefiles="$newdlprefiles" 72070b661123Smrg fi 72080b661123Smrg 72090b661123Smrg case $linkmode in 72100b661123Smrg oldlib) 72110b661123Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 72120b661123Smrg func_warning "\`-dlopen' is ignored for archives" 72130b661123Smrg fi 72140b661123Smrg 72150b661123Smrg case " $deplibs" in 72160b661123Smrg *\ -l* | *\ -L*) 72170b661123Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 72180b661123Smrg esac 72190b661123Smrg 72200b661123Smrg test -n "$rpath" && \ 72210b661123Smrg func_warning "\`-rpath' is ignored for archives" 72220b661123Smrg 72230b661123Smrg test -n "$xrpath" && \ 72240b661123Smrg func_warning "\`-R' is ignored for archives" 72250b661123Smrg 72260b661123Smrg test -n "$vinfo" && \ 72270b661123Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 72280b661123Smrg 72290b661123Smrg test -n "$release" && \ 72300b661123Smrg func_warning "\`-release' is ignored for archives" 72310b661123Smrg 72320b661123Smrg test -n "$export_symbols$export_symbols_regex" && \ 72330b661123Smrg func_warning "\`-export-symbols' is ignored for archives" 72340b661123Smrg 72350b661123Smrg # Now set the variables for building old libraries. 72360b661123Smrg build_libtool_libs=no 72370b661123Smrg oldlibs="$output" 7238880c7e28Smrg func_append objs "$old_deplibs" 72390b661123Smrg ;; 72400b661123Smrg 72410b661123Smrg lib) 72420b661123Smrg # Make sure we only generate libraries of the form `libNAME.la'. 72430b661123Smrg case $outputname in 72440b661123Smrg lib*) 72450b661123Smrg func_stripname 'lib' '.la' "$outputname" 72460b661123Smrg name=$func_stripname_result 72470b661123Smrg eval shared_ext=\"$shrext_cmds\" 72480b661123Smrg eval libname=\"$libname_spec\" 72490b661123Smrg ;; 72500b661123Smrg *) 72510b661123Smrg test "$module" = no && \ 72520b661123Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 72530b661123Smrg 72540b661123Smrg if test "$need_lib_prefix" != no; then 72550b661123Smrg # Add the "lib" prefix for modules if required 72560b661123Smrg func_stripname '' '.la' "$outputname" 72570b661123Smrg name=$func_stripname_result 72580b661123Smrg eval shared_ext=\"$shrext_cmds\" 72590b661123Smrg eval libname=\"$libname_spec\" 72600b661123Smrg else 72610b661123Smrg func_stripname '' '.la' "$outputname" 72620b661123Smrg libname=$func_stripname_result 72630b661123Smrg fi 72640b661123Smrg ;; 72650b661123Smrg esac 72660b661123Smrg 72670b661123Smrg if test -n "$objs"; then 72680b661123Smrg if test "$deplibs_check_method" != pass_all; then 72690b661123Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 72700b661123Smrg else 7271880c7e28Smrg echo 72720b661123Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 72730b661123Smrg $ECHO "*** objects $objs is not portable!" 7274880c7e28Smrg func_append libobjs " $objs" 72750b661123Smrg fi 72760b661123Smrg fi 72770b661123Smrg 72780b661123Smrg test "$dlself" != no && \ 72790b661123Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 72800b661123Smrg 72810b661123Smrg set dummy $rpath 72820b661123Smrg shift 72830b661123Smrg test "$#" -gt 1 && \ 72840b661123Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 72850b661123Smrg 72860b661123Smrg install_libdir="$1" 72870b661123Smrg 72880b661123Smrg oldlibs= 72890b661123Smrg if test -z "$rpath"; then 72900b661123Smrg if test "$build_libtool_libs" = yes; then 72910b661123Smrg # Building a libtool convenience library. 72920b661123Smrg # Some compilers have problems with a `.al' extension so 72930b661123Smrg # convenience libraries should have the same extension an 72940b661123Smrg # archive normally would. 72950b661123Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 72960b661123Smrg build_libtool_libs=convenience 72970b661123Smrg build_old_libs=yes 72980b661123Smrg fi 72990b661123Smrg 73000b661123Smrg test -n "$vinfo" && \ 73010b661123Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 73020b661123Smrg 73030b661123Smrg test -n "$release" && \ 73040b661123Smrg func_warning "\`-release' is ignored for convenience libraries" 73050b661123Smrg else 73060b661123Smrg 73070b661123Smrg # Parse the version information argument. 73080b661123Smrg save_ifs="$IFS"; IFS=':' 73090b661123Smrg set dummy $vinfo 0 0 0 73100b661123Smrg shift 73110b661123Smrg IFS="$save_ifs" 73120b661123Smrg 73130b661123Smrg test -n "$7" && \ 73140b661123Smrg func_fatal_help "too many parameters to \`-version-info'" 73150b661123Smrg 73160b661123Smrg # convert absolute version numbers to libtool ages 73170b661123Smrg # this retains compatibility with .la files and attempts 73180b661123Smrg # to make the code below a bit more comprehensible 73190b661123Smrg 73200b661123Smrg case $vinfo_number in 73210b661123Smrg yes) 73220b661123Smrg number_major="$1" 73230b661123Smrg number_minor="$2" 73240b661123Smrg number_revision="$3" 73250b661123Smrg # 73260b661123Smrg # There are really only two kinds -- those that 73270b661123Smrg # use the current revision as the major version 73280b661123Smrg # and those that subtract age and use age as 73290b661123Smrg # a minor version. But, then there is irix 73300b661123Smrg # which has an extra 1 added just for fun 73310b661123Smrg # 73320b661123Smrg case $version_type in 7333880c7e28Smrg # correct linux to gnu/linux during the next big refactor 73340b661123Smrg darwin|linux|osf|windows|none) 73350b661123Smrg func_arith $number_major + $number_minor 73360b661123Smrg current=$func_arith_result 73370b661123Smrg age="$number_minor" 73380b661123Smrg revision="$number_revision" 73390b661123Smrg ;; 7340880c7e28Smrg freebsd-aout|freebsd-elf|qnx|sunos) 73410b661123Smrg current="$number_major" 73420b661123Smrg revision="$number_minor" 73430b661123Smrg age="0" 73440b661123Smrg ;; 73450b661123Smrg irix|nonstopux) 73460b661123Smrg func_arith $number_major + $number_minor 73470b661123Smrg current=$func_arith_result 73480b661123Smrg age="$number_minor" 73490b661123Smrg revision="$number_minor" 73500b661123Smrg lt_irix_increment=no 73510b661123Smrg ;; 73520b661123Smrg esac 73530b661123Smrg ;; 73540b661123Smrg no) 73550b661123Smrg current="$1" 73560b661123Smrg revision="$2" 73570b661123Smrg age="$3" 73580b661123Smrg ;; 73590b661123Smrg esac 73600b661123Smrg 73610b661123Smrg # Check that each of the things are valid numbers. 73620b661123Smrg case $current in 73630b661123Smrg 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]) ;; 73640b661123Smrg *) 73650b661123Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 73660b661123Smrg func_fatal_error "\`$vinfo' is not valid version information" 73670b661123Smrg ;; 73680b661123Smrg esac 73690b661123Smrg 73700b661123Smrg case $revision in 73710b661123Smrg 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]) ;; 73720b661123Smrg *) 73730b661123Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 73740b661123Smrg func_fatal_error "\`$vinfo' is not valid version information" 73750b661123Smrg ;; 73760b661123Smrg esac 73770b661123Smrg 73780b661123Smrg case $age in 73790b661123Smrg 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]) ;; 73800b661123Smrg *) 73810b661123Smrg func_error "AGE \`$age' must be a nonnegative integer" 73820b661123Smrg func_fatal_error "\`$vinfo' is not valid version information" 73830b661123Smrg ;; 73840b661123Smrg esac 73850b661123Smrg 73860b661123Smrg if test "$age" -gt "$current"; then 73870b661123Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 73880b661123Smrg func_fatal_error "\`$vinfo' is not valid version information" 73890b661123Smrg fi 73900b661123Smrg 73910b661123Smrg # Calculate the version variables. 73920b661123Smrg major= 73930b661123Smrg versuffix= 73940b661123Smrg verstring= 73950b661123Smrg case $version_type in 73960b661123Smrg none) ;; 73970b661123Smrg 73980b661123Smrg darwin) 73990b661123Smrg # Like Linux, but with the current version available in 74000b661123Smrg # verstring for coding it into the library header 74010b661123Smrg func_arith $current - $age 74020b661123Smrg major=.$func_arith_result 74030b661123Smrg versuffix="$major.$age.$revision" 74040b661123Smrg # Darwin ld doesn't like 0 for these options... 74050b661123Smrg func_arith $current + 1 74060b661123Smrg minor_current=$func_arith_result 74070b661123Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 74080b661123Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 74090b661123Smrg ;; 74100b661123Smrg 74110b661123Smrg freebsd-aout) 74120b661123Smrg major=".$current" 74130b661123Smrg versuffix=".$current.$revision"; 74140b661123Smrg ;; 74150b661123Smrg 74160b661123Smrg freebsd-elf) 74170b661123Smrg major=".$current" 74180b661123Smrg versuffix=".$current" 74190b661123Smrg ;; 74200b661123Smrg 74210b661123Smrg irix | nonstopux) 74220b661123Smrg if test "X$lt_irix_increment" = "Xno"; then 74230b661123Smrg func_arith $current - $age 74240b661123Smrg else 74250b661123Smrg func_arith $current - $age + 1 74260b661123Smrg fi 74270b661123Smrg major=$func_arith_result 74280b661123Smrg 74290b661123Smrg case $version_type in 74300b661123Smrg nonstopux) verstring_prefix=nonstopux ;; 74310b661123Smrg *) verstring_prefix=sgi ;; 74320b661123Smrg esac 74330b661123Smrg verstring="$verstring_prefix$major.$revision" 74340b661123Smrg 74350b661123Smrg # Add in all the interfaces that we are compatible with. 74360b661123Smrg loop=$revision 74370b661123Smrg while test "$loop" -ne 0; do 74380b661123Smrg func_arith $revision - $loop 74390b661123Smrg iface=$func_arith_result 74400b661123Smrg func_arith $loop - 1 74410b661123Smrg loop=$func_arith_result 74420b661123Smrg verstring="$verstring_prefix$major.$iface:$verstring" 74430b661123Smrg done 74440b661123Smrg 74450b661123Smrg # Before this point, $major must not contain `.'. 74460b661123Smrg major=.$major 74470b661123Smrg versuffix="$major.$revision" 74480b661123Smrg ;; 74490b661123Smrg 7450880c7e28Smrg linux) # correct to gnu/linux during the next big refactor 74510b661123Smrg func_arith $current - $age 74520b661123Smrg major=.$func_arith_result 74530b661123Smrg versuffix="$major.$age.$revision" 74540b661123Smrg ;; 74550b661123Smrg 74560b661123Smrg osf) 74570b661123Smrg func_arith $current - $age 74580b661123Smrg major=.$func_arith_result 74590b661123Smrg versuffix=".$current.$age.$revision" 74600b661123Smrg verstring="$current.$age.$revision" 74610b661123Smrg 74620b661123Smrg # Add in all the interfaces that we are compatible with. 74630b661123Smrg loop=$age 74640b661123Smrg while test "$loop" -ne 0; do 74650b661123Smrg func_arith $current - $loop 74660b661123Smrg iface=$func_arith_result 74670b661123Smrg func_arith $loop - 1 74680b661123Smrg loop=$func_arith_result 74690b661123Smrg verstring="$verstring:${iface}.0" 74700b661123Smrg done 74710b661123Smrg 74720b661123Smrg # Make executables depend on our current version. 7473880c7e28Smrg func_append verstring ":${current}.0" 74740b661123Smrg ;; 74750b661123Smrg 74760b661123Smrg qnx) 74770b661123Smrg major=".$current" 74780b661123Smrg versuffix=".$current" 74790b661123Smrg ;; 74800b661123Smrg 74810b661123Smrg sunos) 74820b661123Smrg major=".$current" 74830b661123Smrg versuffix=".$current.$revision" 74840b661123Smrg ;; 74850b661123Smrg 74860b661123Smrg windows) 74870b661123Smrg # Use '-' rather than '.', since we only want one 74880b661123Smrg # extension on DOS 8.3 filesystems. 74890b661123Smrg func_arith $current - $age 74900b661123Smrg major=$func_arith_result 74910b661123Smrg versuffix="-$major" 74920b661123Smrg ;; 74930b661123Smrg 74940b661123Smrg *) 74950b661123Smrg func_fatal_configuration "unknown library version type \`$version_type'" 74960b661123Smrg ;; 74970b661123Smrg esac 74980b661123Smrg 74990b661123Smrg # Clear the version info if we defaulted, and they specified a release. 75000b661123Smrg if test -z "$vinfo" && test -n "$release"; then 75010b661123Smrg major= 75020b661123Smrg case $version_type in 75030b661123Smrg darwin) 75040b661123Smrg # we can't check for "0.0" in archive_cmds due to quoting 75050b661123Smrg # problems, so we reset it completely 75060b661123Smrg verstring= 75070b661123Smrg ;; 75080b661123Smrg *) 75090b661123Smrg verstring="0.0" 75100b661123Smrg ;; 75110b661123Smrg esac 75120b661123Smrg if test "$need_version" = no; then 75130b661123Smrg versuffix= 75140b661123Smrg else 75150b661123Smrg versuffix=".0.0" 75160b661123Smrg fi 75170b661123Smrg fi 75180b661123Smrg 75190b661123Smrg # Remove version info from name if versioning should be avoided 75200b661123Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 75210b661123Smrg major= 75220b661123Smrg versuffix= 75230b661123Smrg verstring="" 75240b661123Smrg fi 75250b661123Smrg 75260b661123Smrg # Check to see if the archive will have undefined symbols. 75270b661123Smrg if test "$allow_undefined" = yes; then 75280b661123Smrg if test "$allow_undefined_flag" = unsupported; then 75290b661123Smrg func_warning "undefined symbols not allowed in $host shared libraries" 75300b661123Smrg build_libtool_libs=no 75310b661123Smrg build_old_libs=yes 75320b661123Smrg fi 75330b661123Smrg else 75340b661123Smrg # Don't allow undefined symbols. 75350b661123Smrg allow_undefined_flag="$no_undefined_flag" 75360b661123Smrg fi 75370b661123Smrg 75380b661123Smrg fi 75390b661123Smrg 75400b661123Smrg func_generate_dlsyms "$libname" "$libname" "yes" 7541880c7e28Smrg func_append libobjs " $symfileobj" 75420b661123Smrg test "X$libobjs" = "X " && libobjs= 75430b661123Smrg 7544880c7e28Smrg if test "$opt_mode" != relink; then 75450b661123Smrg # Remove our outputs, but don't remove object files since they 75460b661123Smrg # may have been created when compiling PIC objects. 75470b661123Smrg removelist= 75480b661123Smrg tempremovelist=`$ECHO "$output_objdir/*"` 75490b661123Smrg for p in $tempremovelist; do 75500b661123Smrg case $p in 75510b661123Smrg *.$objext | *.gcno) 75520b661123Smrg ;; 75530b661123Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 75540b661123Smrg if test "X$precious_files_regex" != "X"; then 75550b661123Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 75560b661123Smrg then 75570b661123Smrg continue 75580b661123Smrg fi 75590b661123Smrg fi 7560880c7e28Smrg func_append removelist " $p" 75610b661123Smrg ;; 75620b661123Smrg *) ;; 75630b661123Smrg esac 75640b661123Smrg done 75650b661123Smrg test -n "$removelist" && \ 75660b661123Smrg func_show_eval "${RM}r \$removelist" 75670b661123Smrg fi 75680b661123Smrg 75690b661123Smrg # Now set the variables for building old libraries. 75700b661123Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 7571880c7e28Smrg func_append oldlibs " $output_objdir/$libname.$libext" 75720b661123Smrg 75730b661123Smrg # Transform .lo files to .o files. 7574880c7e28Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 75750b661123Smrg fi 75760b661123Smrg 75770b661123Smrg # Eliminate all temporary directories. 75780b661123Smrg #for path in $notinst_path; do 7579880c7e28Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 7580880c7e28Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 7581880c7e28Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 75820b661123Smrg #done 75830b661123Smrg 75840b661123Smrg if test -n "$xrpath"; then 75850b661123Smrg # If the user specified any rpath flags, then add them. 75860b661123Smrg temp_xrpath= 75870b661123Smrg for libdir in $xrpath; do 7588880c7e28Smrg func_replace_sysroot "$libdir" 7589880c7e28Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 75900b661123Smrg case "$finalize_rpath " in 75910b661123Smrg *" $libdir "*) ;; 7592880c7e28Smrg *) func_append finalize_rpath " $libdir" ;; 75930b661123Smrg esac 75940b661123Smrg done 75950b661123Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 75960b661123Smrg dependency_libs="$temp_xrpath $dependency_libs" 75970b661123Smrg fi 75980b661123Smrg fi 75990b661123Smrg 76000b661123Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 76010b661123Smrg old_dlfiles="$dlfiles" 76020b661123Smrg dlfiles= 76030b661123Smrg for lib in $old_dlfiles; do 76040b661123Smrg case " $dlprefiles $dlfiles " in 76050b661123Smrg *" $lib "*) ;; 7606880c7e28Smrg *) func_append dlfiles " $lib" ;; 76070b661123Smrg esac 76080b661123Smrg done 76090b661123Smrg 76100b661123Smrg # Make sure dlprefiles contains only unique files 76110b661123Smrg old_dlprefiles="$dlprefiles" 76120b661123Smrg dlprefiles= 76130b661123Smrg for lib in $old_dlprefiles; do 76140b661123Smrg case "$dlprefiles " in 76150b661123Smrg *" $lib "*) ;; 7616880c7e28Smrg *) func_append dlprefiles " $lib" ;; 76170b661123Smrg esac 76180b661123Smrg done 76190b661123Smrg 76200b661123Smrg if test "$build_libtool_libs" = yes; then 76210b661123Smrg if test -n "$rpath"; then 76220b661123Smrg case $host in 7623880c7e28Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 76240b661123Smrg # these systems don't actually have a c library (as such)! 76250b661123Smrg ;; 76260b661123Smrg *-*-rhapsody* | *-*-darwin1.[012]) 76270b661123Smrg # Rhapsody C library is in the System framework 7628880c7e28Smrg func_append deplibs " System.ltframework" 76290b661123Smrg ;; 76300b661123Smrg *-*-netbsd*) 76310b661123Smrg # Don't link with libc until the a.out ld.so is fixed. 76320b661123Smrg ;; 76330b661123Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 76340b661123Smrg # Do not include libc due to us having libc/libc_r. 76350b661123Smrg ;; 76360b661123Smrg *-*-sco3.2v5* | *-*-sco5v6*) 76370b661123Smrg # Causes problems with __ctype 76380b661123Smrg ;; 76390b661123Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 76400b661123Smrg # Compiler inserts libc in the correct place for threads to work 76410b661123Smrg ;; 76420b661123Smrg *) 76430b661123Smrg # Add libc to deplibs on all other systems if necessary. 76440b661123Smrg if test "$build_libtool_need_lc" = "yes"; then 7645880c7e28Smrg func_append deplibs " -lc" 76460b661123Smrg fi 76470b661123Smrg ;; 76480b661123Smrg esac 76490b661123Smrg fi 76500b661123Smrg 76510b661123Smrg # Transform deplibs into only deplibs that can be linked in shared. 76520b661123Smrg name_save=$name 76530b661123Smrg libname_save=$libname 76540b661123Smrg release_save=$release 76550b661123Smrg versuffix_save=$versuffix 76560b661123Smrg major_save=$major 76570b661123Smrg # I'm not sure if I'm treating the release correctly. I think 76580b661123Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 76590b661123Smrg # add it in twice. Is that correct? 76600b661123Smrg release="" 76610b661123Smrg versuffix="" 76620b661123Smrg major="" 76630b661123Smrg newdeplibs= 76640b661123Smrg droppeddeps=no 76650b661123Smrg case $deplibs_check_method in 76660b661123Smrg pass_all) 76670b661123Smrg # Don't check for shared/static. Everything works. 76680b661123Smrg # This might be a little naive. We might want to check 76690b661123Smrg # whether the library exists or not. But this is on 76700b661123Smrg # osf3 & osf4 and I'm not really sure... Just 76710b661123Smrg # implementing what was already the behavior. 76720b661123Smrg newdeplibs=$deplibs 76730b661123Smrg ;; 76740b661123Smrg test_compile) 76750b661123Smrg # This code stresses the "libraries are programs" paradigm to its 76760b661123Smrg # limits. Maybe even breaks it. We compile a program, linking it 76770b661123Smrg # against the deplibs as a proxy for the library. Then we can check 76780b661123Smrg # whether they linked in statically or dynamically with ldd. 76790b661123Smrg $opt_dry_run || $RM conftest.c 76800b661123Smrg cat > conftest.c <<EOF 76810b661123Smrg int main() { return 0; } 76820b661123SmrgEOF 76830b661123Smrg $opt_dry_run || $RM conftest 76840b661123Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 76850b661123Smrg ldd_output=`ldd conftest` 76860b661123Smrg for i in $deplibs; do 76870b661123Smrg case $i in 76880b661123Smrg -l*) 76890b661123Smrg func_stripname -l '' "$i" 76900b661123Smrg name=$func_stripname_result 76910b661123Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 76920b661123Smrg case " $predeps $postdeps " in 76930b661123Smrg *" $i "*) 7694880c7e28Smrg func_append newdeplibs " $i" 76950b661123Smrg i="" 76960b661123Smrg ;; 76970b661123Smrg esac 76980b661123Smrg fi 76990b661123Smrg if test -n "$i" ; then 77000b661123Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 77010b661123Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 77020b661123Smrg set dummy $deplib_matches; shift 77030b661123Smrg deplib_match=$1 77040b661123Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7705880c7e28Smrg func_append newdeplibs " $i" 77060b661123Smrg else 77070b661123Smrg droppeddeps=yes 7708880c7e28Smrg echo 77090b661123Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7710880c7e28Smrg echo "*** I have the capability to make that library automatically link in when" 7711880c7e28Smrg echo "*** you link to this library. But I can only do this if you have a" 7712880c7e28Smrg echo "*** shared version of the library, which I believe you do not have" 7713880c7e28Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 7714880c7e28Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 77150b661123Smrg fi 77160b661123Smrg fi 77170b661123Smrg ;; 77180b661123Smrg *) 7719880c7e28Smrg func_append newdeplibs " $i" 77200b661123Smrg ;; 77210b661123Smrg esac 77220b661123Smrg done 77230b661123Smrg else 77240b661123Smrg # Error occurred in the first compile. Let's try to salvage 77250b661123Smrg # the situation: Compile a separate program for each library. 77260b661123Smrg for i in $deplibs; do 77270b661123Smrg case $i in 77280b661123Smrg -l*) 77290b661123Smrg func_stripname -l '' "$i" 77300b661123Smrg name=$func_stripname_result 77310b661123Smrg $opt_dry_run || $RM conftest 77320b661123Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 77330b661123Smrg ldd_output=`ldd conftest` 77340b661123Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 77350b661123Smrg case " $predeps $postdeps " in 77360b661123Smrg *" $i "*) 7737880c7e28Smrg func_append newdeplibs " $i" 77380b661123Smrg i="" 77390b661123Smrg ;; 77400b661123Smrg esac 77410b661123Smrg fi 77420b661123Smrg if test -n "$i" ; then 77430b661123Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 77440b661123Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 77450b661123Smrg set dummy $deplib_matches; shift 77460b661123Smrg deplib_match=$1 77470b661123Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7748880c7e28Smrg func_append newdeplibs " $i" 77490b661123Smrg else 77500b661123Smrg droppeddeps=yes 7751880c7e28Smrg echo 77520b661123Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7753880c7e28Smrg echo "*** I have the capability to make that library automatically link in when" 7754880c7e28Smrg echo "*** you link to this library. But I can only do this if you have a" 7755880c7e28Smrg echo "*** shared version of the library, which you do not appear to have" 7756880c7e28Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 7757880c7e28Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 77580b661123Smrg fi 77590b661123Smrg fi 77600b661123Smrg else 77610b661123Smrg droppeddeps=yes 7762880c7e28Smrg echo 77630b661123Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 7764880c7e28Smrg echo "*** make it link in! You will probably need to install it or some" 7765880c7e28Smrg echo "*** library that it depends on before this library will be fully" 7766880c7e28Smrg echo "*** functional. Installing it before continuing would be even better." 77670b661123Smrg fi 77680b661123Smrg ;; 77690b661123Smrg *) 7770880c7e28Smrg func_append newdeplibs " $i" 77710b661123Smrg ;; 77720b661123Smrg esac 77730b661123Smrg done 77740b661123Smrg fi 77750b661123Smrg ;; 77760b661123Smrg file_magic*) 77770b661123Smrg set dummy $deplibs_check_method; shift 77780b661123Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 77790b661123Smrg for a_deplib in $deplibs; do 77800b661123Smrg case $a_deplib in 77810b661123Smrg -l*) 77820b661123Smrg func_stripname -l '' "$a_deplib" 77830b661123Smrg name=$func_stripname_result 77840b661123Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 77850b661123Smrg case " $predeps $postdeps " in 77860b661123Smrg *" $a_deplib "*) 7787880c7e28Smrg func_append newdeplibs " $a_deplib" 77880b661123Smrg a_deplib="" 77890b661123Smrg ;; 77900b661123Smrg esac 77910b661123Smrg fi 77920b661123Smrg if test -n "$a_deplib" ; then 77930b661123Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7794880c7e28Smrg if test -n "$file_magic_glob"; then 7795880c7e28Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 7796880c7e28Smrg else 7797880c7e28Smrg libnameglob=$libname 7798880c7e28Smrg fi 7799880c7e28Smrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 78000b661123Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7801880c7e28Smrg if test "$want_nocaseglob" = yes; then 7802880c7e28Smrg shopt -s nocaseglob 7803880c7e28Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7804880c7e28Smrg $nocaseglob 7805880c7e28Smrg else 7806880c7e28Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7807880c7e28Smrg fi 78080b661123Smrg for potent_lib in $potential_libs; do 78090b661123Smrg # Follow soft links. 78100b661123Smrg if ls -lLd "$potent_lib" 2>/dev/null | 78110b661123Smrg $GREP " -> " >/dev/null; then 78120b661123Smrg continue 78130b661123Smrg fi 78140b661123Smrg # The statement above tries to avoid entering an 78150b661123Smrg # endless loop below, in case of cyclic links. 78160b661123Smrg # We might still enter an endless loop, since a link 78170b661123Smrg # loop can be closed while we follow links, 78180b661123Smrg # but so what? 78190b661123Smrg potlib="$potent_lib" 78200b661123Smrg while test -h "$potlib" 2>/dev/null; do 78210b661123Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 78220b661123Smrg case $potliblink in 78230b661123Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 7824880c7e28Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 78250b661123Smrg esac 78260b661123Smrg done 78270b661123Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 78280b661123Smrg $SED -e 10q | 78290b661123Smrg $EGREP "$file_magic_regex" > /dev/null; then 7830880c7e28Smrg func_append newdeplibs " $a_deplib" 78310b661123Smrg a_deplib="" 78320b661123Smrg break 2 78330b661123Smrg fi 78340b661123Smrg done 78350b661123Smrg done 78360b661123Smrg fi 78370b661123Smrg if test -n "$a_deplib" ; then 78380b661123Smrg droppeddeps=yes 7839880c7e28Smrg echo 78400b661123Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7841880c7e28Smrg echo "*** I have the capability to make that library automatically link in when" 7842880c7e28Smrg echo "*** you link to this library. But I can only do this if you have a" 7843880c7e28Smrg echo "*** shared version of the library, which you do not appear to have" 7844880c7e28Smrg echo "*** because I did check the linker path looking for a file starting" 78450b661123Smrg if test -z "$potlib" ; then 78460b661123Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 78470b661123Smrg else 78480b661123Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 78490b661123Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 78500b661123Smrg fi 78510b661123Smrg fi 78520b661123Smrg ;; 78530b661123Smrg *) 78540b661123Smrg # Add a -L argument. 7855880c7e28Smrg func_append newdeplibs " $a_deplib" 78560b661123Smrg ;; 78570b661123Smrg esac 78580b661123Smrg done # Gone through all deplibs. 78590b661123Smrg ;; 78600b661123Smrg match_pattern*) 78610b661123Smrg set dummy $deplibs_check_method; shift 78620b661123Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 78630b661123Smrg for a_deplib in $deplibs; do 78640b661123Smrg case $a_deplib in 78650b661123Smrg -l*) 78660b661123Smrg func_stripname -l '' "$a_deplib" 78670b661123Smrg name=$func_stripname_result 78680b661123Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 78690b661123Smrg case " $predeps $postdeps " in 78700b661123Smrg *" $a_deplib "*) 7871880c7e28Smrg func_append newdeplibs " $a_deplib" 78720b661123Smrg a_deplib="" 78730b661123Smrg ;; 78740b661123Smrg esac 78750b661123Smrg fi 78760b661123Smrg if test -n "$a_deplib" ; then 78770b661123Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 78780b661123Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 78790b661123Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 78800b661123Smrg for potent_lib in $potential_libs; do 78810b661123Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 7882880c7e28Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 78830b661123Smrg $EGREP "$match_pattern_regex" > /dev/null; then 7884880c7e28Smrg func_append newdeplibs " $a_deplib" 78850b661123Smrg a_deplib="" 78860b661123Smrg break 2 78870b661123Smrg fi 78880b661123Smrg done 78890b661123Smrg done 78900b661123Smrg fi 78910b661123Smrg if test -n "$a_deplib" ; then 78920b661123Smrg droppeddeps=yes 7893880c7e28Smrg echo 78940b661123Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7895880c7e28Smrg echo "*** I have the capability to make that library automatically link in when" 7896880c7e28Smrg echo "*** you link to this library. But I can only do this if you have a" 7897880c7e28Smrg echo "*** shared version of the library, which you do not appear to have" 7898880c7e28Smrg echo "*** because I did check the linker path looking for a file starting" 78990b661123Smrg if test -z "$potlib" ; then 79000b661123Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 79010b661123Smrg else 79020b661123Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 79030b661123Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 79040b661123Smrg fi 79050b661123Smrg fi 79060b661123Smrg ;; 79070b661123Smrg *) 79080b661123Smrg # Add a -L argument. 7909880c7e28Smrg func_append newdeplibs " $a_deplib" 79100b661123Smrg ;; 79110b661123Smrg esac 79120b661123Smrg done # Gone through all deplibs. 79130b661123Smrg ;; 79140b661123Smrg none | unknown | *) 79150b661123Smrg newdeplibs="" 7916880c7e28Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 79170b661123Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 79180b661123Smrg for i in $predeps $postdeps ; do 79190b661123Smrg # can't use Xsed below, because $i might contain '/' 7920880c7e28Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 79210b661123Smrg done 79220b661123Smrg fi 7923880c7e28Smrg case $tmp_deplibs in 7924880c7e28Smrg *[!\ \ ]*) 7925880c7e28Smrg echo 79260b661123Smrg if test "X$deplibs_check_method" = "Xnone"; then 7927880c7e28Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 79280b661123Smrg else 7929880c7e28Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 79300b661123Smrg fi 7931880c7e28Smrg echo "*** All declared inter-library dependencies are being dropped." 79320b661123Smrg droppeddeps=yes 7933880c7e28Smrg ;; 7934880c7e28Smrg esac 79350b661123Smrg ;; 79360b661123Smrg esac 79370b661123Smrg versuffix=$versuffix_save 79380b661123Smrg major=$major_save 79390b661123Smrg release=$release_save 79400b661123Smrg libname=$libname_save 79410b661123Smrg name=$name_save 79420b661123Smrg 79430b661123Smrg case $host in 79440b661123Smrg *-*-rhapsody* | *-*-darwin1.[012]) 79450b661123Smrg # On Rhapsody replace the C library with the System framework 7946880c7e28Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 79470b661123Smrg ;; 79480b661123Smrg esac 79490b661123Smrg 79500b661123Smrg if test "$droppeddeps" = yes; then 79510b661123Smrg if test "$module" = yes; then 7952880c7e28Smrg echo 7953880c7e28Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 79540b661123Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 7955880c7e28Smrg echo "*** a static module, that should work as long as the dlopening" 7956880c7e28Smrg echo "*** application is linked with the -dlopen flag." 79570b661123Smrg if test -z "$global_symbol_pipe"; then 7958880c7e28Smrg echo 7959880c7e28Smrg echo "*** However, this would only work if libtool was able to extract symbol" 7960880c7e28Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 7961880c7e28Smrg echo "*** not find such a program. So, this module is probably useless." 7962880c7e28Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 79630b661123Smrg fi 79640b661123Smrg if test "$build_old_libs" = no; then 79650b661123Smrg oldlibs="$output_objdir/$libname.$libext" 79660b661123Smrg build_libtool_libs=module 79670b661123Smrg build_old_libs=yes 79680b661123Smrg else 79690b661123Smrg build_libtool_libs=no 79700b661123Smrg fi 79710b661123Smrg else 7972880c7e28Smrg echo "*** The inter-library dependencies that have been dropped here will be" 7973880c7e28Smrg echo "*** automatically added whenever a program is linked with this library" 7974880c7e28Smrg echo "*** or is declared to -dlopen it." 79750b661123Smrg 79760b661123Smrg if test "$allow_undefined" = no; then 7977880c7e28Smrg echo 7978880c7e28Smrg echo "*** Since this library must not contain undefined symbols," 7979880c7e28Smrg echo "*** because either the platform does not support them or" 7980880c7e28Smrg echo "*** it was explicitly requested with -no-undefined," 7981880c7e28Smrg echo "*** libtool will only create a static version of it." 79820b661123Smrg if test "$build_old_libs" = no; then 79830b661123Smrg oldlibs="$output_objdir/$libname.$libext" 79840b661123Smrg build_libtool_libs=module 79850b661123Smrg build_old_libs=yes 79860b661123Smrg else 79870b661123Smrg build_libtool_libs=no 79880b661123Smrg fi 79890b661123Smrg fi 79900b661123Smrg fi 79910b661123Smrg fi 79920b661123Smrg # Done checking deplibs! 79930b661123Smrg deplibs=$newdeplibs 79940b661123Smrg fi 79950b661123Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 79960b661123Smrg case $host in 79970b661123Smrg *-*-darwin*) 7998880c7e28Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7999880c7e28Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8000880c7e28Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 80010b661123Smrg ;; 80020b661123Smrg esac 80030b661123Smrg 80040b661123Smrg # move library search paths that coincide with paths to not yet 80050b661123Smrg # installed libraries to the beginning of the library search list 80060b661123Smrg new_libs= 80070b661123Smrg for path in $notinst_path; do 80080b661123Smrg case " $new_libs " in 80090b661123Smrg *" -L$path/$objdir "*) ;; 80100b661123Smrg *) 80110b661123Smrg case " $deplibs " in 80120b661123Smrg *" -L$path/$objdir "*) 8013880c7e28Smrg func_append new_libs " -L$path/$objdir" ;; 80140b661123Smrg esac 80150b661123Smrg ;; 80160b661123Smrg esac 80170b661123Smrg done 80180b661123Smrg for deplib in $deplibs; do 80190b661123Smrg case $deplib in 80200b661123Smrg -L*) 80210b661123Smrg case " $new_libs " in 80220b661123Smrg *" $deplib "*) ;; 8023880c7e28Smrg *) func_append new_libs " $deplib" ;; 80240b661123Smrg esac 80250b661123Smrg ;; 8026880c7e28Smrg *) func_append new_libs " $deplib" ;; 80270b661123Smrg esac 80280b661123Smrg done 80290b661123Smrg deplibs="$new_libs" 80300b661123Smrg 80310b661123Smrg # All the library-specific variables (install_libdir is set above). 80320b661123Smrg library_names= 80330b661123Smrg old_library= 80340b661123Smrg dlname= 80350b661123Smrg 80360b661123Smrg # Test again, we may have decided not to build it any more 80370b661123Smrg if test "$build_libtool_libs" = yes; then 8038880c7e28Smrg # Remove ${wl} instances when linking with ld. 8039880c7e28Smrg # FIXME: should test the right _cmds variable. 8040880c7e28Smrg case $archive_cmds in 8041880c7e28Smrg *\$LD\ *) wl= ;; 8042880c7e28Smrg esac 80430b661123Smrg if test "$hardcode_into_libs" = yes; then 80440b661123Smrg # Hardcode the library paths 80450b661123Smrg hardcode_libdirs= 80460b661123Smrg dep_rpath= 80470b661123Smrg rpath="$finalize_rpath" 8048880c7e28Smrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 80490b661123Smrg for libdir in $rpath; do 80500b661123Smrg if test -n "$hardcode_libdir_flag_spec"; then 80510b661123Smrg if test -n "$hardcode_libdir_separator"; then 8052880c7e28Smrg func_replace_sysroot "$libdir" 8053880c7e28Smrg libdir=$func_replace_sysroot_result 80540b661123Smrg if test -z "$hardcode_libdirs"; then 80550b661123Smrg hardcode_libdirs="$libdir" 80560b661123Smrg else 80570b661123Smrg # Just accumulate the unique libdirs. 80580b661123Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 80590b661123Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 80600b661123Smrg ;; 80610b661123Smrg *) 8062880c7e28Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 80630b661123Smrg ;; 80640b661123Smrg esac 80650b661123Smrg fi 80660b661123Smrg else 80670b661123Smrg eval flag=\"$hardcode_libdir_flag_spec\" 8068880c7e28Smrg func_append dep_rpath " $flag" 80690b661123Smrg fi 80700b661123Smrg elif test -n "$runpath_var"; then 80710b661123Smrg case "$perm_rpath " in 80720b661123Smrg *" $libdir "*) ;; 8073880c7e28Smrg *) func_append perm_rpath " $libdir" ;; 80740b661123Smrg esac 80750b661123Smrg fi 80760b661123Smrg done 80770b661123Smrg # Substitute the hardcoded libdirs into the rpath. 80780b661123Smrg if test -n "$hardcode_libdir_separator" && 80790b661123Smrg test -n "$hardcode_libdirs"; then 80800b661123Smrg libdir="$hardcode_libdirs" 8081880c7e28Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 80820b661123Smrg fi 80830b661123Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 80840b661123Smrg # We should set the runpath_var. 80850b661123Smrg rpath= 80860b661123Smrg for dir in $perm_rpath; do 8087880c7e28Smrg func_append rpath "$dir:" 80880b661123Smrg done 80890b661123Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 80900b661123Smrg fi 80910b661123Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 80920b661123Smrg fi 8093bdcaa8d0Smrg 80940b661123Smrg shlibpath="$finalize_shlibpath" 8095880c7e28Smrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 80960b661123Smrg if test -n "$shlibpath"; then 80970b661123Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 80980b661123Smrg fi 8099bdcaa8d0Smrg 81000b661123Smrg # Get the real and link names of the library. 81010b661123Smrg eval shared_ext=\"$shrext_cmds\" 81020b661123Smrg eval library_names=\"$library_names_spec\" 81030b661123Smrg set dummy $library_names 81040b661123Smrg shift 81050b661123Smrg realname="$1" 81060b661123Smrg shift 8107bdcaa8d0Smrg 81080b661123Smrg if test -n "$soname_spec"; then 81090b661123Smrg eval soname=\"$soname_spec\" 81100b661123Smrg else 81110b661123Smrg soname="$realname" 81120b661123Smrg fi 81130b661123Smrg if test -z "$dlname"; then 81140b661123Smrg dlname=$soname 81150b661123Smrg fi 8116bdcaa8d0Smrg 81170b661123Smrg lib="$output_objdir/$realname" 81180b661123Smrg linknames= 81190b661123Smrg for link 81200b661123Smrg do 8121880c7e28Smrg func_append linknames " $link" 81220b661123Smrg done 8123bdcaa8d0Smrg 81240b661123Smrg # Use standard objects if they are pic 8125880c7e28Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 81260b661123Smrg test "X$libobjs" = "X " && libobjs= 8127bdcaa8d0Smrg 81280b661123Smrg delfiles= 81290b661123Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 81300b661123Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 81310b661123Smrg export_symbols="$output_objdir/$libname.uexp" 8132880c7e28Smrg func_append delfiles " $export_symbols" 81330b661123Smrg fi 8134bdcaa8d0Smrg 81350b661123Smrg orig_export_symbols= 81360b661123Smrg case $host_os in 81370b661123Smrg cygwin* | mingw* | cegcc*) 81380b661123Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 81390b661123Smrg # exporting using user supplied symfile 81400b661123Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 81410b661123Smrg # and it's NOT already a .def file. Must figure out 81420b661123Smrg # which of the given symbols are data symbols and tag 81430b661123Smrg # them as such. So, trigger use of export_symbols_cmds. 81440b661123Smrg # export_symbols gets reassigned inside the "prepare 81450b661123Smrg # the list of exported symbols" if statement, so the 81460b661123Smrg # include_expsyms logic still works. 81470b661123Smrg orig_export_symbols="$export_symbols" 81480b661123Smrg export_symbols= 81490b661123Smrg always_export_symbols=yes 81500b661123Smrg fi 81510b661123Smrg fi 81520b661123Smrg ;; 81530b661123Smrg esac 8154bdcaa8d0Smrg 81550b661123Smrg # Prepare the list of exported symbols 81560b661123Smrg if test -z "$export_symbols"; then 81570b661123Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 81580b661123Smrg func_verbose "generating symbol list for \`$libname.la'" 81590b661123Smrg export_symbols="$output_objdir/$libname.exp" 81600b661123Smrg $opt_dry_run || $RM $export_symbols 81610b661123Smrg cmds=$export_symbols_cmds 81620b661123Smrg save_ifs="$IFS"; IFS='~' 8163880c7e28Smrg for cmd1 in $cmds; do 81640b661123Smrg IFS="$save_ifs" 8165880c7e28Smrg # Take the normal branch if the nm_file_list_spec branch 8166880c7e28Smrg # doesn't work or if tool conversion is not needed. 8167880c7e28Smrg case $nm_file_list_spec~$to_tool_file_cmd in 8168880c7e28Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 8169880c7e28Smrg try_normal_branch=yes 8170880c7e28Smrg eval cmd=\"$cmd1\" 8171880c7e28Smrg func_len " $cmd" 8172880c7e28Smrg len=$func_len_result 8173880c7e28Smrg ;; 8174880c7e28Smrg *) 8175880c7e28Smrg try_normal_branch=no 8176880c7e28Smrg ;; 8177880c7e28Smrg esac 8178880c7e28Smrg if test "$try_normal_branch" = yes \ 8179880c7e28Smrg && { test "$len" -lt "$max_cmd_len" \ 8180880c7e28Smrg || test "$max_cmd_len" -le -1; } 8181880c7e28Smrg then 8182880c7e28Smrg func_show_eval "$cmd" 'exit $?' 8183880c7e28Smrg skipped_export=false 8184880c7e28Smrg elif test -n "$nm_file_list_spec"; then 8185880c7e28Smrg func_basename "$output" 8186880c7e28Smrg output_la=$func_basename_result 8187880c7e28Smrg save_libobjs=$libobjs 8188880c7e28Smrg save_output=$output 8189880c7e28Smrg output=${output_objdir}/${output_la}.nm 8190880c7e28Smrg func_to_tool_file "$output" 8191880c7e28Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 8192880c7e28Smrg func_append delfiles " $output" 8193880c7e28Smrg func_verbose "creating $NM input file list: $output" 8194880c7e28Smrg for obj in $save_libobjs; do 8195880c7e28Smrg func_to_tool_file "$obj" 8196880c7e28Smrg $ECHO "$func_to_tool_file_result" 8197880c7e28Smrg done > "$output" 8198880c7e28Smrg eval cmd=\"$cmd1\" 81990b661123Smrg func_show_eval "$cmd" 'exit $?' 8200880c7e28Smrg output=$save_output 8201880c7e28Smrg libobjs=$save_libobjs 82020b661123Smrg skipped_export=false 82030b661123Smrg else 82040b661123Smrg # The command line is too long to execute in one step. 82050b661123Smrg func_verbose "using reloadable object file for export list..." 82060b661123Smrg skipped_export=: 82070b661123Smrg # Break out early, otherwise skipped_export may be 82080b661123Smrg # set to false by a later but shorter cmd. 82090b661123Smrg break 82100b661123Smrg fi 82110b661123Smrg done 82120b661123Smrg IFS="$save_ifs" 82130b661123Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 82140b661123Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 82150b661123Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 82160b661123Smrg fi 82170b661123Smrg fi 821872313efbSmrg fi 8219bdcaa8d0Smrg 82200b661123Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 82210b661123Smrg tmp_export_symbols="$export_symbols" 82220b661123Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8223880c7e28Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 82240b661123Smrg fi 8225bdcaa8d0Smrg 82260b661123Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 82270b661123Smrg # The given exports_symbols file has to be filtered, so filter it. 82280b661123Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 82290b661123Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 82300b661123Smrg # 's' commands which not all seds can handle. GNU sed should be fine 82310b661123Smrg # though. Also, the filter scales superlinearly with the number of 82320b661123Smrg # global variables. join(1) would be nice here, but unfortunately 82330b661123Smrg # isn't a blessed tool. 82340b661123Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8235880c7e28Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 82360b661123Smrg export_symbols=$output_objdir/$libname.def 82370b661123Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 82380b661123Smrg fi 8239bdcaa8d0Smrg 82400b661123Smrg tmp_deplibs= 82410b661123Smrg for test_deplib in $deplibs; do 82420b661123Smrg case " $convenience " in 82430b661123Smrg *" $test_deplib "*) ;; 82440b661123Smrg *) 8245880c7e28Smrg func_append tmp_deplibs " $test_deplib" 82460b661123Smrg ;; 82470b661123Smrg esac 82480b661123Smrg done 82490b661123Smrg deplibs="$tmp_deplibs" 8250bdcaa8d0Smrg 82510b661123Smrg if test -n "$convenience"; then 82520b661123Smrg if test -n "$whole_archive_flag_spec" && 82530b661123Smrg test "$compiler_needs_object" = yes && 82540b661123Smrg test -z "$libobjs"; then 82550b661123Smrg # extract the archives, so we have objects to list. 82560b661123Smrg # TODO: could optimize this to just extract one archive. 82570b661123Smrg whole_archive_flag_spec= 82580b661123Smrg fi 82590b661123Smrg if test -n "$whole_archive_flag_spec"; then 82600b661123Smrg save_libobjs=$libobjs 82610b661123Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 82620b661123Smrg test "X$libobjs" = "X " && libobjs= 82630b661123Smrg else 82640b661123Smrg gentop="$output_objdir/${outputname}x" 8265880c7e28Smrg func_append generated " $gentop" 8266bdcaa8d0Smrg 82670b661123Smrg func_extract_archives $gentop $convenience 8268880c7e28Smrg func_append libobjs " $func_extract_archives_result" 82690b661123Smrg test "X$libobjs" = "X " && libobjs= 82700b661123Smrg fi 827196ce994aSmrg fi 8272bdcaa8d0Smrg 82730b661123Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 82740b661123Smrg eval flag=\"$thread_safe_flag_spec\" 8275880c7e28Smrg func_append linker_flags " $flag" 827696ce994aSmrg fi 8277bdcaa8d0Smrg 82780b661123Smrg # Make a backup of the uninstalled library when relinking 8279880c7e28Smrg if test "$opt_mode" = relink; then 82800b661123Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 82810b661123Smrg fi 8282bdcaa8d0Smrg 82830b661123Smrg # Do each of the archive commands. 82840b661123Smrg if test "$module" = yes && test -n "$module_cmds" ; then 82850b661123Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 82860b661123Smrg eval test_cmds=\"$module_expsym_cmds\" 82870b661123Smrg cmds=$module_expsym_cmds 82880b661123Smrg else 82890b661123Smrg eval test_cmds=\"$module_cmds\" 82900b661123Smrg cmds=$module_cmds 82910b661123Smrg fi 829296ce994aSmrg else 82930b661123Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 82940b661123Smrg eval test_cmds=\"$archive_expsym_cmds\" 82950b661123Smrg cmds=$archive_expsym_cmds 82960b661123Smrg else 82970b661123Smrg eval test_cmds=\"$archive_cmds\" 82980b661123Smrg cmds=$archive_cmds 82990b661123Smrg fi 830096ce994aSmrg fi 8301bdcaa8d0Smrg 83020b661123Smrg if test "X$skipped_export" != "X:" && 83030b661123Smrg func_len " $test_cmds" && 83040b661123Smrg len=$func_len_result && 83050b661123Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 83060b661123Smrg : 83070b661123Smrg else 83080b661123Smrg # The command line is too long to link in one step, link piecewise 83090b661123Smrg # or, if using GNU ld and skipped_export is not :, use a linker 83100b661123Smrg # script. 8311bdcaa8d0Smrg 83120b661123Smrg # Save the value of $output and $libobjs because we want to 83130b661123Smrg # use them later. If we have whole_archive_flag_spec, we 83140b661123Smrg # want to use save_libobjs as it was before 83150b661123Smrg # whole_archive_flag_spec was expanded, because we can't 83160b661123Smrg # assume the linker understands whole_archive_flag_spec. 83170b661123Smrg # This may have to be revisited, in case too many 83180b661123Smrg # convenience libraries get linked in and end up exceeding 83190b661123Smrg # the spec. 83200b661123Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 83210b661123Smrg save_libobjs=$libobjs 83220b661123Smrg fi 83230b661123Smrg save_output=$output 8324880c7e28Smrg func_basename "$output" 8325880c7e28Smrg output_la=$func_basename_result 832672313efbSmrg 83270b661123Smrg # Clear the reloadable object creation command queue and 83280b661123Smrg # initialize k to one. 83290b661123Smrg test_cmds= 83300b661123Smrg concat_cmds= 83310b661123Smrg objlist= 83320b661123Smrg last_robj= 83330b661123Smrg k=1 83340b661123Smrg 83350b661123Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 83360b661123Smrg output=${output_objdir}/${output_la}.lnkscript 83370b661123Smrg func_verbose "creating GNU ld script: $output" 8338880c7e28Smrg echo 'INPUT (' > $output 83390b661123Smrg for obj in $save_libobjs 834096ce994aSmrg do 8341880c7e28Smrg func_to_tool_file "$obj" 8342880c7e28Smrg $ECHO "$func_to_tool_file_result" >> $output 83430b661123Smrg done 8344880c7e28Smrg echo ')' >> $output 8345880c7e28Smrg func_append delfiles " $output" 8346880c7e28Smrg func_to_tool_file "$output" 8347880c7e28Smrg output=$func_to_tool_file_result 83480b661123Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 83490b661123Smrg output=${output_objdir}/${output_la}.lnk 83500b661123Smrg func_verbose "creating linker input file list: $output" 83510b661123Smrg : > $output 83520b661123Smrg set x $save_libobjs 83530b661123Smrg shift 83540b661123Smrg firstobj= 83550b661123Smrg if test "$compiler_needs_object" = yes; then 83560b661123Smrg firstobj="$1 " 83570b661123Smrg shift 83580b661123Smrg fi 83590b661123Smrg for obj 83600b661123Smrg do 8361880c7e28Smrg func_to_tool_file "$obj" 8362880c7e28Smrg $ECHO "$func_to_tool_file_result" >> $output 83630b661123Smrg done 8364880c7e28Smrg func_append delfiles " $output" 8365880c7e28Smrg func_to_tool_file "$output" 8366880c7e28Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 83670b661123Smrg else 83680b661123Smrg if test -n "$save_libobjs"; then 83690b661123Smrg func_verbose "creating reloadable object files..." 83700b661123Smrg output=$output_objdir/$output_la-${k}.$objext 83710b661123Smrg eval test_cmds=\"$reload_cmds\" 83720b661123Smrg func_len " $test_cmds" 83730b661123Smrg len0=$func_len_result 83740b661123Smrg len=$len0 83750b661123Smrg 83760b661123Smrg # Loop over the list of objects to be linked. 83770b661123Smrg for obj in $save_libobjs 83780b661123Smrg do 83790b661123Smrg func_len " $obj" 83800b661123Smrg func_arith $len + $func_len_result 83810b661123Smrg len=$func_arith_result 83820b661123Smrg if test "X$objlist" = X || 83830b661123Smrg test "$len" -lt "$max_cmd_len"; then 83840b661123Smrg func_append objlist " $obj" 83850b661123Smrg else 83860b661123Smrg # The command $test_cmds is almost too long, add a 83870b661123Smrg # command to the queue. 83880b661123Smrg if test "$k" -eq 1 ; then 83890b661123Smrg # The first file doesn't have a previous command to add. 8390880c7e28Smrg reload_objs=$objlist 8391880c7e28Smrg eval concat_cmds=\"$reload_cmds\" 83920b661123Smrg else 83930b661123Smrg # All subsequent reloadable object files will link in 83940b661123Smrg # the last one created. 8395880c7e28Smrg reload_objs="$objlist $last_robj" 8396880c7e28Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 83970b661123Smrg fi 83980b661123Smrg last_robj=$output_objdir/$output_la-${k}.$objext 83990b661123Smrg func_arith $k + 1 84000b661123Smrg k=$func_arith_result 84010b661123Smrg output=$output_objdir/$output_la-${k}.$objext 8402880c7e28Smrg objlist=" $obj" 84030b661123Smrg func_len " $last_robj" 84040b661123Smrg func_arith $len0 + $func_len_result 84050b661123Smrg len=$func_arith_result 84060b661123Smrg fi 84070b661123Smrg done 84080b661123Smrg # Handle the remaining objects by creating one last 84090b661123Smrg # reloadable object file. All subsequent reloadable object 84100b661123Smrg # files will link in the last one created. 84110b661123Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8412880c7e28Smrg reload_objs="$objlist $last_robj" 8413880c7e28Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 84140b661123Smrg if test -n "$last_robj"; then 84150b661123Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 84160b661123Smrg fi 8417880c7e28Smrg func_append delfiles " $output" 8418bdcaa8d0Smrg 84190b661123Smrg else 84200b661123Smrg output= 84210b661123Smrg fi 8422bdcaa8d0Smrg 84230b661123Smrg if ${skipped_export-false}; then 84240b661123Smrg func_verbose "generating symbol list for \`$libname.la'" 84250b661123Smrg export_symbols="$output_objdir/$libname.exp" 84260b661123Smrg $opt_dry_run || $RM $export_symbols 84270b661123Smrg libobjs=$output 84280b661123Smrg # Append the command to create the export file. 84290b661123Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 84300b661123Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 84310b661123Smrg if test -n "$last_robj"; then 84320b661123Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 84330b661123Smrg fi 843472313efbSmrg fi 8435bdcaa8d0Smrg 84360b661123Smrg test -n "$save_libobjs" && 84370b661123Smrg func_verbose "creating a temporary reloadable object file: $output" 8438bdcaa8d0Smrg 84390b661123Smrg # Loop through the commands generated above and execute them. 84400b661123Smrg save_ifs="$IFS"; IFS='~' 84410b661123Smrg for cmd in $concat_cmds; do 84420b661123Smrg IFS="$save_ifs" 84430b661123Smrg $opt_silent || { 84440b661123Smrg func_quote_for_expand "$cmd" 84450b661123Smrg eval "func_echo $func_quote_for_expand_result" 84460b661123Smrg } 84470b661123Smrg $opt_dry_run || eval "$cmd" || { 84480b661123Smrg lt_exit=$? 84490b661123Smrg 84500b661123Smrg # Restore the uninstalled library and exit 8451880c7e28Smrg if test "$opt_mode" = relink; then 84520b661123Smrg ( cd "$output_objdir" && \ 84530b661123Smrg $RM "${realname}T" && \ 84540b661123Smrg $MV "${realname}U" "$realname" ) 84550b661123Smrg fi 845672313efbSmrg 84570b661123Smrg exit $lt_exit 84580b661123Smrg } 84590b661123Smrg done 84600b661123Smrg IFS="$save_ifs" 846196ce994aSmrg 84620b661123Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 84630b661123Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 84640b661123Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8465bdcaa8d0Smrg fi 8466bdcaa8d0Smrg fi 846772313efbSmrg 84680b661123Smrg if ${skipped_export-false}; then 84690b661123Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 84700b661123Smrg tmp_export_symbols="$export_symbols" 84710b661123Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8472880c7e28Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 84730b661123Smrg fi 8474bdcaa8d0Smrg 84750b661123Smrg if test -n "$orig_export_symbols"; then 84760b661123Smrg # The given exports_symbols file has to be filtered, so filter it. 84770b661123Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 84780b661123Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 84790b661123Smrg # 's' commands which not all seds can handle. GNU sed should be fine 84800b661123Smrg # though. Also, the filter scales superlinearly with the number of 84810b661123Smrg # global variables. join(1) would be nice here, but unfortunately 84820b661123Smrg # isn't a blessed tool. 84830b661123Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8484880c7e28Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 84850b661123Smrg export_symbols=$output_objdir/$libname.def 84860b661123Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 84870b661123Smrg fi 84880b661123Smrg fi 848972313efbSmrg 84900b661123Smrg libobjs=$output 84910b661123Smrg # Restore the value of output. 84920b661123Smrg output=$save_output 849372313efbSmrg 84940b661123Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 84950b661123Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 84960b661123Smrg test "X$libobjs" = "X " && libobjs= 84970b661123Smrg fi 84980b661123Smrg # Expand the library linking commands again to reset the 84990b661123Smrg # value of $libobjs for piecewise linking. 850072313efbSmrg 85010b661123Smrg # Do each of the archive commands. 85020b661123Smrg if test "$module" = yes && test -n "$module_cmds" ; then 85030b661123Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 85040b661123Smrg cmds=$module_expsym_cmds 85050b661123Smrg else 85060b661123Smrg cmds=$module_cmds 850796ce994aSmrg fi 850896ce994aSmrg else 85090b661123Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 85100b661123Smrg cmds=$archive_expsym_cmds 85110b661123Smrg else 85120b661123Smrg cmds=$archive_cmds 85130b661123Smrg fi 851496ce994aSmrg fi 85150b661123Smrg fi 851672313efbSmrg 85170b661123Smrg if test -n "$delfiles"; then 85180b661123Smrg # Append the command to remove temporary files to $cmds. 85190b661123Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 85200b661123Smrg fi 8521bdcaa8d0Smrg 85220b661123Smrg # Add any objects from preloaded convenience libraries 85230b661123Smrg if test -n "$dlprefiles"; then 85240b661123Smrg gentop="$output_objdir/${outputname}x" 8525880c7e28Smrg func_append generated " $gentop" 8526bdcaa8d0Smrg 85270b661123Smrg func_extract_archives $gentop $dlprefiles 8528880c7e28Smrg func_append libobjs " $func_extract_archives_result" 85290b661123Smrg test "X$libobjs" = "X " && libobjs= 85300b661123Smrg fi 8531bdcaa8d0Smrg 85320b661123Smrg save_ifs="$IFS"; IFS='~' 85330b661123Smrg for cmd in $cmds; do 85340b661123Smrg IFS="$save_ifs" 85350b661123Smrg eval cmd=\"$cmd\" 85360b661123Smrg $opt_silent || { 85370b661123Smrg func_quote_for_expand "$cmd" 85380b661123Smrg eval "func_echo $func_quote_for_expand_result" 85390b661123Smrg } 85400b661123Smrg $opt_dry_run || eval "$cmd" || { 85410b661123Smrg lt_exit=$? 8542bdcaa8d0Smrg 85430b661123Smrg # Restore the uninstalled library and exit 8544880c7e28Smrg if test "$opt_mode" = relink; then 85450b661123Smrg ( cd "$output_objdir" && \ 85460b661123Smrg $RM "${realname}T" && \ 85470b661123Smrg $MV "${realname}U" "$realname" ) 85480b661123Smrg fi 8549bdcaa8d0Smrg 85500b661123Smrg exit $lt_exit 85510b661123Smrg } 85520b661123Smrg done 85530b661123Smrg IFS="$save_ifs" 8554bdcaa8d0Smrg 85550b661123Smrg # Restore the uninstalled library and exit 8556880c7e28Smrg if test "$opt_mode" = relink; then 85570b661123Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 8558bdcaa8d0Smrg 85590b661123Smrg if test -n "$convenience"; then 85600b661123Smrg if test -z "$whole_archive_flag_spec"; then 85610b661123Smrg func_show_eval '${RM}r "$gentop"' 85620b661123Smrg fi 85630b661123Smrg fi 8564bdcaa8d0Smrg 85650b661123Smrg exit $EXIT_SUCCESS 85660b661123Smrg fi 85670b661123Smrg 85680b661123Smrg # Create links to the real library. 85690b661123Smrg for linkname in $linknames; do 85700b661123Smrg if test "$realname" != "$linkname"; then 85710b661123Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 857296ce994aSmrg fi 857396ce994aSmrg done 8574bdcaa8d0Smrg 85750b661123Smrg # If -module or -export-dynamic was specified, set the dlname. 85760b661123Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 85770b661123Smrg # On all known operating systems, these are identical. 85780b661123Smrg dlname="$soname" 85790b661123Smrg fi 85800b661123Smrg fi 858172313efbSmrg ;; 8582bdcaa8d0Smrg 85830b661123Smrg obj) 85840b661123Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 85850b661123Smrg func_warning "\`-dlopen' is ignored for objects" 85860b661123Smrg fi 858796ce994aSmrg 85880b661123Smrg case " $deplibs" in 85890b661123Smrg *\ -l* | *\ -L*) 85900b661123Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 8591bdcaa8d0Smrg esac 8592bdcaa8d0Smrg 85930b661123Smrg test -n "$rpath" && \ 85940b661123Smrg func_warning "\`-rpath' is ignored for objects" 85950b661123Smrg 85960b661123Smrg test -n "$xrpath" && \ 85970b661123Smrg func_warning "\`-R' is ignored for objects" 8598bdcaa8d0Smrg 85990b661123Smrg test -n "$vinfo" && \ 86000b661123Smrg func_warning "\`-version-info' is ignored for objects" 8601bdcaa8d0Smrg 86020b661123Smrg test -n "$release" && \ 86030b661123Smrg func_warning "\`-release' is ignored for objects" 86040b661123Smrg 86050b661123Smrg case $output in 86060b661123Smrg *.lo) 86070b661123Smrg test -n "$objs$old_deplibs" && \ 86080b661123Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 86090b661123Smrg 86100b661123Smrg libobj=$output 86110b661123Smrg func_lo2o "$libobj" 86120b661123Smrg obj=$func_lo2o_result 861396ce994aSmrg ;; 861496ce994aSmrg *) 86150b661123Smrg libobj= 86160b661123Smrg obj="$output" 8617bdcaa8d0Smrg ;; 8618bdcaa8d0Smrg esac 8619bdcaa8d0Smrg 86200b661123Smrg # Delete the old objects. 86210b661123Smrg $opt_dry_run || $RM $obj $libobj 8622bdcaa8d0Smrg 86230b661123Smrg # Objects from convenience libraries. This assumes 86240b661123Smrg # single-version convenience libraries. Whenever we create 86250b661123Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 86260b661123Smrg # the extraction. 86270b661123Smrg reload_conv_objs= 86280b661123Smrg gentop= 86290b661123Smrg # reload_cmds runs $LD directly, so let us get rid of 86300b661123Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 86310b661123Smrg # turning comma into space.. 86320b661123Smrg wl= 8633bdcaa8d0Smrg 86340b661123Smrg if test -n "$convenience"; then 86350b661123Smrg if test -n "$whole_archive_flag_spec"; then 86360b661123Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 8637880c7e28Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 86380b661123Smrg else 86390b661123Smrg gentop="$output_objdir/${obj}x" 8640880c7e28Smrg func_append generated " $gentop" 864196ce994aSmrg 86420b661123Smrg func_extract_archives $gentop $convenience 86430b661123Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 86440b661123Smrg fi 864596ce994aSmrg fi 864696ce994aSmrg 8647880c7e28Smrg # If we're not building shared, we need to use non_pic_objs 8648880c7e28Smrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 8649880c7e28Smrg 86500b661123Smrg # Create the old-style object. 8651880c7e28Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 865296ce994aSmrg 86530b661123Smrg output="$obj" 86540b661123Smrg func_execute_cmds "$reload_cmds" 'exit $?' 865596ce994aSmrg 86560b661123Smrg # Exit if we aren't doing a library object file. 86570b661123Smrg if test -z "$libobj"; then 86580b661123Smrg if test -n "$gentop"; then 86590b661123Smrg func_show_eval '${RM}r "$gentop"' 86600b661123Smrg fi 86610b661123Smrg 86620b661123Smrg exit $EXIT_SUCCESS 866396ce994aSmrg fi 86640b661123Smrg 86650b661123Smrg if test "$build_libtool_libs" != yes; then 86660b661123Smrg if test -n "$gentop"; then 86670b661123Smrg func_show_eval '${RM}r "$gentop"' 86680b661123Smrg fi 86690b661123Smrg 86700b661123Smrg # Create an invalid libtool object if no PIC, so that we don't 86710b661123Smrg # accidentally link it into a program. 86720b661123Smrg # $show "echo timestamp > $libobj" 86730b661123Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 86740b661123Smrg exit $EXIT_SUCCESS 86750b661123Smrg fi 86760b661123Smrg 86770b661123Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 86780b661123Smrg # Only do commands if we really have different PIC objects. 86790b661123Smrg reload_objs="$libobjs $reload_conv_objs" 86800b661123Smrg output="$libobj" 86810b661123Smrg func_execute_cmds "$reload_cmds" 'exit $?' 86820b661123Smrg fi 86830b661123Smrg 86840b661123Smrg if test -n "$gentop"; then 86850b661123Smrg func_show_eval '${RM}r "$gentop"' 86860b661123Smrg fi 86870b661123Smrg 86880b661123Smrg exit $EXIT_SUCCESS 868996ce994aSmrg ;; 8690bdcaa8d0Smrg 86910b661123Smrg prog) 86920b661123Smrg case $host in 86930b661123Smrg *cygwin*) func_stripname '' '.exe' "$output" 86940b661123Smrg output=$func_stripname_result.exe;; 86950b661123Smrg esac 86960b661123Smrg test -n "$vinfo" && \ 86970b661123Smrg func_warning "\`-version-info' is ignored for programs" 8698bdcaa8d0Smrg 86990b661123Smrg test -n "$release" && \ 87000b661123Smrg func_warning "\`-release' is ignored for programs" 8701bdcaa8d0Smrg 87020b661123Smrg test "$preload" = yes \ 87030b661123Smrg && test "$dlopen_support" = unknown \ 87040b661123Smrg && test "$dlopen_self" = unknown \ 87050b661123Smrg && test "$dlopen_self_static" = unknown && \ 87060b661123Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 87070b661123Smrg 87080b661123Smrg case $host in 87090b661123Smrg *-*-rhapsody* | *-*-darwin1.[012]) 87100b661123Smrg # On Rhapsody replace the C library is the System framework 8711880c7e28Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 8712880c7e28Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 871396ce994aSmrg ;; 87140b661123Smrg esac 871596ce994aSmrg 87160b661123Smrg case $host in 87170b661123Smrg *-*-darwin*) 87180b661123Smrg # Don't allow lazy linking, it breaks C++ global constructors 87190b661123Smrg # But is supposedly fixed on 10.4 or later (yay!). 87200b661123Smrg if test "$tagname" = CXX ; then 87210b661123Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 87220b661123Smrg 10.[0123]) 8723880c7e28Smrg func_append compile_command " ${wl}-bind_at_load" 8724880c7e28Smrg func_append finalize_command " ${wl}-bind_at_load" 87250b661123Smrg ;; 87260b661123Smrg esac 872796ce994aSmrg fi 87280b661123Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 8729880c7e28Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8730880c7e28Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 87310b661123Smrg ;; 87320b661123Smrg esac 873396ce994aSmrg 873496ce994aSmrg 87350b661123Smrg # move library search paths that coincide with paths to not yet 87360b661123Smrg # installed libraries to the beginning of the library search list 87370b661123Smrg new_libs= 87380b661123Smrg for path in $notinst_path; do 87390b661123Smrg case " $new_libs " in 87400b661123Smrg *" -L$path/$objdir "*) ;; 87410b661123Smrg *) 87420b661123Smrg case " $compile_deplibs " in 87430b661123Smrg *" -L$path/$objdir "*) 8744880c7e28Smrg func_append new_libs " -L$path/$objdir" ;; 874572313efbSmrg esac 87460b661123Smrg ;; 87470b661123Smrg esac 87480b661123Smrg done 87490b661123Smrg for deplib in $compile_deplibs; do 87500b661123Smrg case $deplib in 87510b661123Smrg -L*) 87520b661123Smrg case " $new_libs " in 87530b661123Smrg *" $deplib "*) ;; 8754880c7e28Smrg *) func_append new_libs " $deplib" ;; 8755bdcaa8d0Smrg esac 87560b661123Smrg ;; 8757880c7e28Smrg *) func_append new_libs " $deplib" ;; 87580b661123Smrg esac 87590b661123Smrg done 87600b661123Smrg compile_deplibs="$new_libs" 876172313efbSmrg 876296ce994aSmrg 8763880c7e28Smrg func_append compile_command " $compile_deplibs" 8764880c7e28Smrg func_append finalize_command " $finalize_deplibs" 876596ce994aSmrg 87660b661123Smrg if test -n "$rpath$xrpath"; then 87670b661123Smrg # If the user specified any rpath flags, then add them. 87680b661123Smrg for libdir in $rpath $xrpath; do 87690b661123Smrg # This is the magic to use -rpath. 87700b661123Smrg case "$finalize_rpath " in 87710b661123Smrg *" $libdir "*) ;; 8772880c7e28Smrg *) func_append finalize_rpath " $libdir" ;; 87730b661123Smrg esac 87740b661123Smrg done 87750b661123Smrg fi 877696ce994aSmrg 87770b661123Smrg # Now hardcode the library paths 87780b661123Smrg rpath= 87790b661123Smrg hardcode_libdirs= 87800b661123Smrg for libdir in $compile_rpath $finalize_rpath; do 87810b661123Smrg if test -n "$hardcode_libdir_flag_spec"; then 87820b661123Smrg if test -n "$hardcode_libdir_separator"; then 87830b661123Smrg if test -z "$hardcode_libdirs"; then 87840b661123Smrg hardcode_libdirs="$libdir" 87850b661123Smrg else 87860b661123Smrg # Just accumulate the unique libdirs. 87870b661123Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 87880b661123Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 87890b661123Smrg ;; 87900b661123Smrg *) 8791880c7e28Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 87920b661123Smrg ;; 87930b661123Smrg esac 87940b661123Smrg fi 879596ce994aSmrg else 87960b661123Smrg eval flag=\"$hardcode_libdir_flag_spec\" 8797880c7e28Smrg func_append rpath " $flag" 879896ce994aSmrg fi 87990b661123Smrg elif test -n "$runpath_var"; then 88000b661123Smrg case "$perm_rpath " in 88010b661123Smrg *" $libdir "*) ;; 8802880c7e28Smrg *) func_append perm_rpath " $libdir" ;; 88030b661123Smrg esac 88040b661123Smrg fi 88050b661123Smrg case $host in 88060b661123Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 88070b661123Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 88080b661123Smrg case :$dllsearchpath: in 88090b661123Smrg *":$libdir:"*) ;; 88100b661123Smrg ::) dllsearchpath=$libdir;; 8811880c7e28Smrg *) func_append dllsearchpath ":$libdir";; 88120b661123Smrg esac 88130b661123Smrg case :$dllsearchpath: in 88140b661123Smrg *":$testbindir:"*) ;; 88150b661123Smrg ::) dllsearchpath=$testbindir;; 8816880c7e28Smrg *) func_append dllsearchpath ":$testbindir";; 88170b661123Smrg esac 88180b661123Smrg ;; 88190b661123Smrg esac 88200b661123Smrg done 88210b661123Smrg # Substitute the hardcoded libdirs into the rpath. 88220b661123Smrg if test -n "$hardcode_libdir_separator" && 88230b661123Smrg test -n "$hardcode_libdirs"; then 88240b661123Smrg libdir="$hardcode_libdirs" 88250b661123Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 88260b661123Smrg fi 88270b661123Smrg compile_rpath="$rpath" 882896ce994aSmrg 88290b661123Smrg rpath= 88300b661123Smrg hardcode_libdirs= 88310b661123Smrg for libdir in $finalize_rpath; do 88320b661123Smrg if test -n "$hardcode_libdir_flag_spec"; then 88330b661123Smrg if test -n "$hardcode_libdir_separator"; then 88340b661123Smrg if test -z "$hardcode_libdirs"; then 88350b661123Smrg hardcode_libdirs="$libdir" 88360b661123Smrg else 88370b661123Smrg # Just accumulate the unique libdirs. 88380b661123Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 88390b661123Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 88400b661123Smrg ;; 88410b661123Smrg *) 8842880c7e28Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 88430b661123Smrg ;; 88440b661123Smrg esac 88450b661123Smrg fi 884672313efbSmrg else 88470b661123Smrg eval flag=\"$hardcode_libdir_flag_spec\" 8848880c7e28Smrg func_append rpath " $flag" 884972313efbSmrg fi 88500b661123Smrg elif test -n "$runpath_var"; then 88510b661123Smrg case "$finalize_perm_rpath " in 88520b661123Smrg *" $libdir "*) ;; 8853880c7e28Smrg *) func_append finalize_perm_rpath " $libdir" ;; 88540b661123Smrg esac 8855bdcaa8d0Smrg fi 88560b661123Smrg done 88570b661123Smrg # Substitute the hardcoded libdirs into the rpath. 88580b661123Smrg if test -n "$hardcode_libdir_separator" && 88590b661123Smrg test -n "$hardcode_libdirs"; then 88600b661123Smrg libdir="$hardcode_libdirs" 88610b661123Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 88620b661123Smrg fi 88630b661123Smrg finalize_rpath="$rpath" 8864bdcaa8d0Smrg 88650b661123Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 88660b661123Smrg # Transform all the library objects into standard objects. 8867880c7e28Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8868880c7e28Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 88690b661123Smrg fi 8870bdcaa8d0Smrg 88710b661123Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8872bdcaa8d0Smrg 88730b661123Smrg # template prelinking step 88740b661123Smrg if test -n "$prelink_cmds"; then 88750b661123Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 88760b661123Smrg fi 8877bdcaa8d0Smrg 88780b661123Smrg wrappers_required=yes 88790b661123Smrg case $host in 8880880c7e28Smrg *cegcc* | *mingw32ce*) 8881880c7e28Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 8882880c7e28Smrg wrappers_required=no 8883880c7e28Smrg ;; 88840b661123Smrg *cygwin* | *mingw* ) 88850b661123Smrg if test "$build_libtool_libs" != yes; then 88860b661123Smrg wrappers_required=no 88870b661123Smrg fi 88880b661123Smrg ;; 88890b661123Smrg *) 88900b661123Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 88910b661123Smrg wrappers_required=no 88920b661123Smrg fi 88930b661123Smrg ;; 88940b661123Smrg esac 88950b661123Smrg if test "$wrappers_required" = no; then 88960b661123Smrg # Replace the output file specification. 8897880c7e28Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 88980b661123Smrg link_command="$compile_command$compile_rpath" 8899bdcaa8d0Smrg 89000b661123Smrg # We have no uninstalled library dependencies, so finalize right now. 89010b661123Smrg exit_status=0 89020b661123Smrg func_show_eval "$link_command" 'exit_status=$?' 8903bdcaa8d0Smrg 8904880c7e28Smrg if test -n "$postlink_cmds"; then 8905880c7e28Smrg func_to_tool_file "$output" 8906880c7e28Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8907880c7e28Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 8908880c7e28Smrg fi 8909880c7e28Smrg 89100b661123Smrg # Delete the generated files. 89110b661123Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 89120b661123Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 891372313efbSmrg fi 8914bdcaa8d0Smrg 89150b661123Smrg exit $exit_status 89160b661123Smrg fi 8917bdcaa8d0Smrg 89180b661123Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 89190b661123Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 89200b661123Smrg fi 89210b661123Smrg if test -n "$finalize_shlibpath"; then 89220b661123Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 89230b661123Smrg fi 892496ce994aSmrg 89250b661123Smrg compile_var= 89260b661123Smrg finalize_var= 89270b661123Smrg if test -n "$runpath_var"; then 89280b661123Smrg if test -n "$perm_rpath"; then 89290b661123Smrg # We should set the runpath_var. 89300b661123Smrg rpath= 89310b661123Smrg for dir in $perm_rpath; do 8932880c7e28Smrg func_append rpath "$dir:" 89330b661123Smrg done 89340b661123Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8935bdcaa8d0Smrg fi 89360b661123Smrg if test -n "$finalize_perm_rpath"; then 89370b661123Smrg # We should set the runpath_var. 89380b661123Smrg rpath= 89390b661123Smrg for dir in $finalize_perm_rpath; do 8940880c7e28Smrg func_append rpath "$dir:" 89410b661123Smrg done 89420b661123Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 894372313efbSmrg fi 89440b661123Smrg fi 8945bdcaa8d0Smrg 89460b661123Smrg if test "$no_install" = yes; then 89470b661123Smrg # We don't need to create a wrapper script. 89480b661123Smrg link_command="$compile_var$compile_command$compile_rpath" 89490b661123Smrg # Replace the output file specification. 8950880c7e28Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 89510b661123Smrg # Delete the old output file. 89520b661123Smrg $opt_dry_run || $RM $output 89530b661123Smrg # Link the executable and exit 89540b661123Smrg func_show_eval "$link_command" 'exit $?' 8955880c7e28Smrg 8956880c7e28Smrg if test -n "$postlink_cmds"; then 8957880c7e28Smrg func_to_tool_file "$output" 8958880c7e28Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8959880c7e28Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 8960880c7e28Smrg fi 8961880c7e28Smrg 896296ce994aSmrg exit $EXIT_SUCCESS 89630b661123Smrg fi 8964bdcaa8d0Smrg 89650b661123Smrg if test "$hardcode_action" = relink; then 89660b661123Smrg # Fast installation is not supported 89670b661123Smrg link_command="$compile_var$compile_command$compile_rpath" 89680b661123Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 89690b661123Smrg 89700b661123Smrg func_warning "this platform does not like uninstalled shared libraries" 89710b661123Smrg func_warning "\`$output' will be relinked during installation" 89720b661123Smrg else 89730b661123Smrg if test "$fast_install" != no; then 89740b661123Smrg link_command="$finalize_var$compile_command$finalize_rpath" 89750b661123Smrg if test "$fast_install" = yes; then 8976880c7e28Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 89770b661123Smrg else 89780b661123Smrg # fast_install is set to needless 89790b661123Smrg relink_command= 89800b661123Smrg fi 8981bdcaa8d0Smrg else 89820b661123Smrg link_command="$compile_var$compile_command$compile_rpath" 89830b661123Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8984bdcaa8d0Smrg fi 89850b661123Smrg fi 8986bdcaa8d0Smrg 89870b661123Smrg # Replace the output file specification. 8988880c7e28Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 8989bdcaa8d0Smrg 89900b661123Smrg # Delete the old output files. 89910b661123Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 8992bdcaa8d0Smrg 89930b661123Smrg func_show_eval "$link_command" 'exit $?' 899496ce994aSmrg 8995880c7e28Smrg if test -n "$postlink_cmds"; then 8996880c7e28Smrg func_to_tool_file "$output_objdir/$outputname" 8997880c7e28Smrg 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'` 8998880c7e28Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 8999880c7e28Smrg fi 9000880c7e28Smrg 90010b661123Smrg # Now create the wrapper script. 90020b661123Smrg func_verbose "creating $output" 900396ce994aSmrg 90040b661123Smrg # Quote the relink command for shipping. 90050b661123Smrg if test -n "$relink_command"; then 90060b661123Smrg # Preserve any variables that may affect compiler behavior 90070b661123Smrg for var in $variables_saved_for_relink; do 90080b661123Smrg if eval test -z \"\${$var+set}\"; then 90090b661123Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 90100b661123Smrg elif eval var_value=\$$var; test -z "$var_value"; then 90110b661123Smrg relink_command="$var=; export $var; $relink_command" 901272313efbSmrg else 90130b661123Smrg func_quote_for_eval "$var_value" 90140b661123Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 901572313efbSmrg fi 90160b661123Smrg done 90170b661123Smrg relink_command="(cd `pwd`; $relink_command)" 9018880c7e28Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 90190b661123Smrg fi 90200b661123Smrg 90210b661123Smrg # Only actually do things if not in dry run mode. 90220b661123Smrg $opt_dry_run || { 90230b661123Smrg # win32 will think the script is a binary if it has 90240b661123Smrg # a .exe suffix, so we strip it off here. 90250b661123Smrg case $output in 90260b661123Smrg *.exe) func_stripname '' '.exe' "$output" 90270b661123Smrg output=$func_stripname_result ;; 90280b661123Smrg esac 90290b661123Smrg # test for cygwin because mv fails w/o .exe extensions 90300b661123Smrg case $host in 90310b661123Smrg *cygwin*) 90320b661123Smrg exeext=.exe 90330b661123Smrg func_stripname '' '.exe' "$outputname" 90340b661123Smrg outputname=$func_stripname_result ;; 90350b661123Smrg *) exeext= ;; 9036bdcaa8d0Smrg esac 90370b661123Smrg case $host in 90380b661123Smrg *cygwin* | *mingw* ) 90390b661123Smrg func_dirname_and_basename "$output" "" "." 90400b661123Smrg output_name=$func_basename_result 90410b661123Smrg output_path=$func_dirname_result 90420b661123Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 90430b661123Smrg cwrapper="$output_path/$output_name.exe" 90440b661123Smrg $RM $cwrappersource $cwrapper 90450b661123Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 90460b661123Smrg 90470b661123Smrg func_emit_cwrapperexe_src > $cwrappersource 90480b661123Smrg 90490b661123Smrg # The wrapper executable is built using the $host compiler, 90500b661123Smrg # because it contains $host paths and files. If cross- 90510b661123Smrg # compiling, it, like the target executable, must be 90520b661123Smrg # executed on the $host or under an emulation environment. 90530b661123Smrg $opt_dry_run || { 90540b661123Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 90550b661123Smrg $STRIP $cwrapper 90560b661123Smrg } 9057bdcaa8d0Smrg 90580b661123Smrg # Now, create the wrapper script for func_source use: 90590b661123Smrg func_ltwrapper_scriptname $cwrapper 90600b661123Smrg $RM $func_ltwrapper_scriptname_result 90610b661123Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 90620b661123Smrg $opt_dry_run || { 90630b661123Smrg # note: this script will not be executed, so do not chmod. 90640b661123Smrg if test "x$build" = "x$host" ; then 90650b661123Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 90660b661123Smrg else 90670b661123Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 90680b661123Smrg fi 90690b661123Smrg } 90700b661123Smrg ;; 90710b661123Smrg * ) 90720b661123Smrg $RM $output 90730b661123Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 9074bdcaa8d0Smrg 90750b661123Smrg func_emit_wrapper no > $output 90760b661123Smrg chmod +x $output 90770b661123Smrg ;; 90780b661123Smrg esac 90790b661123Smrg } 90800b661123Smrg exit $EXIT_SUCCESS 90810b661123Smrg ;; 90820b661123Smrg esac 9083bdcaa8d0Smrg 90840b661123Smrg # See if we need to build an old-fashioned archive. 90850b661123Smrg for oldlib in $oldlibs; do 9086bdcaa8d0Smrg 90870b661123Smrg if test "$build_libtool_libs" = convenience; then 90880b661123Smrg oldobjs="$libobjs_save $symfileobj" 90890b661123Smrg addlibs="$convenience" 90900b661123Smrg build_libtool_libs=no 90910b661123Smrg else 90920b661123Smrg if test "$build_libtool_libs" = module; then 90930b661123Smrg oldobjs="$libobjs_save" 90940b661123Smrg build_libtool_libs=no 90950b661123Smrg else 90960b661123Smrg oldobjs="$old_deplibs $non_pic_objects" 90970b661123Smrg if test "$preload" = yes && test -f "$symfileobj"; then 9098880c7e28Smrg func_append oldobjs " $symfileobj" 90990b661123Smrg fi 91000b661123Smrg fi 91010b661123Smrg addlibs="$old_convenience" 9102bdcaa8d0Smrg fi 9103bdcaa8d0Smrg 91040b661123Smrg if test -n "$addlibs"; then 91050b661123Smrg gentop="$output_objdir/${outputname}x" 9106880c7e28Smrg func_append generated " $gentop" 9107bdcaa8d0Smrg 91080b661123Smrg func_extract_archives $gentop $addlibs 9109880c7e28Smrg func_append oldobjs " $func_extract_archives_result" 91100b661123Smrg fi 9111bdcaa8d0Smrg 91120b661123Smrg # Do each command in the archive commands. 91130b661123Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 91140b661123Smrg cmds=$old_archive_from_new_cmds 91150b661123Smrg else 9116bdcaa8d0Smrg 91170b661123Smrg # Add any objects from preloaded convenience libraries 91180b661123Smrg if test -n "$dlprefiles"; then 91190b661123Smrg gentop="$output_objdir/${outputname}x" 9120880c7e28Smrg func_append generated " $gentop" 9121bdcaa8d0Smrg 91220b661123Smrg func_extract_archives $gentop $dlprefiles 9123880c7e28Smrg func_append oldobjs " $func_extract_archives_result" 91240b661123Smrg fi 9125bdcaa8d0Smrg 91260b661123Smrg # POSIX demands no paths to be encoded in archives. We have 91270b661123Smrg # to avoid creating archives with duplicate basenames if we 91280b661123Smrg # might have to extract them afterwards, e.g., when creating a 91290b661123Smrg # static archive out of a convenience library, or when linking 91300b661123Smrg # the entirety of a libtool archive into another (currently 91310b661123Smrg # not supported by libtool). 91320b661123Smrg if (for obj in $oldobjs 91330b661123Smrg do 91340b661123Smrg func_basename "$obj" 91350b661123Smrg $ECHO "$func_basename_result" 91360b661123Smrg done | sort | sort -uc >/dev/null 2>&1); then 91370b661123Smrg : 91380b661123Smrg else 9139880c7e28Smrg echo "copying selected object files to avoid basename conflicts..." 91400b661123Smrg gentop="$output_objdir/${outputname}x" 9141880c7e28Smrg func_append generated " $gentop" 91420b661123Smrg func_mkdir_p "$gentop" 91430b661123Smrg save_oldobjs=$oldobjs 91440b661123Smrg oldobjs= 91450b661123Smrg counter=1 91460b661123Smrg for obj in $save_oldobjs 91470b661123Smrg do 91480b661123Smrg func_basename "$obj" 91490b661123Smrg objbase="$func_basename_result" 91500b661123Smrg case " $oldobjs " in 91510b661123Smrg " ") oldobjs=$obj ;; 91520b661123Smrg *[\ /]"$objbase "*) 91530b661123Smrg while :; do 91540b661123Smrg # Make sure we don't pick an alternate name that also 91550b661123Smrg # overlaps. 91560b661123Smrg newobj=lt$counter-$objbase 91570b661123Smrg func_arith $counter + 1 91580b661123Smrg counter=$func_arith_result 91590b661123Smrg case " $oldobjs " in 91600b661123Smrg *[\ /]"$newobj "*) ;; 91610b661123Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 91620b661123Smrg esac 91630b661123Smrg done 91640b661123Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 9165880c7e28Smrg func_append oldobjs " $gentop/$newobj" 91660b661123Smrg ;; 9167880c7e28Smrg *) func_append oldobjs " $obj" ;; 91680b661123Smrg esac 9169bdcaa8d0Smrg done 917072313efbSmrg fi 9171880c7e28Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 9172880c7e28Smrg tool_oldlib=$func_to_tool_file_result 91730b661123Smrg eval cmds=\"$old_archive_cmds\" 917496ce994aSmrg 91750b661123Smrg func_len " $cmds" 91760b661123Smrg len=$func_len_result 91770b661123Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 91780b661123Smrg cmds=$old_archive_cmds 9179880c7e28Smrg elif test -n "$archiver_list_spec"; then 9180880c7e28Smrg func_verbose "using command file archive linking..." 9181880c7e28Smrg for obj in $oldobjs 9182880c7e28Smrg do 9183880c7e28Smrg func_to_tool_file "$obj" 9184880c7e28Smrg $ECHO "$func_to_tool_file_result" 9185880c7e28Smrg done > $output_objdir/$libname.libcmd 9186880c7e28Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 9187880c7e28Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 9188880c7e28Smrg cmds=$old_archive_cmds 91890b661123Smrg else 91900b661123Smrg # the command line is too long to link in one step, link in parts 91910b661123Smrg func_verbose "using piecewise archive linking..." 91920b661123Smrg save_RANLIB=$RANLIB 91930b661123Smrg RANLIB=: 91940b661123Smrg objlist= 91950b661123Smrg concat_cmds= 91960b661123Smrg save_oldobjs=$oldobjs 91970b661123Smrg oldobjs= 91980b661123Smrg # Is there a better way of finding the last object in the list? 91990b661123Smrg for obj in $save_oldobjs 92000b661123Smrg do 92010b661123Smrg last_oldobj=$obj 92020b661123Smrg done 92030b661123Smrg eval test_cmds=\"$old_archive_cmds\" 92040b661123Smrg func_len " $test_cmds" 92050b661123Smrg len0=$func_len_result 92060b661123Smrg len=$len0 92070b661123Smrg for obj in $save_oldobjs 92080b661123Smrg do 92090b661123Smrg func_len " $obj" 92100b661123Smrg func_arith $len + $func_len_result 92110b661123Smrg len=$func_arith_result 92120b661123Smrg func_append objlist " $obj" 92130b661123Smrg if test "$len" -lt "$max_cmd_len"; then 92140b661123Smrg : 92150b661123Smrg else 92160b661123Smrg # the above command should be used before it gets too long 92170b661123Smrg oldobjs=$objlist 92180b661123Smrg if test "$obj" = "$last_oldobj" ; then 92190b661123Smrg RANLIB=$save_RANLIB 92200b661123Smrg fi 92210b661123Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 92220b661123Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 92230b661123Smrg objlist= 92240b661123Smrg len=$len0 92250b661123Smrg fi 92260b661123Smrg done 92270b661123Smrg RANLIB=$save_RANLIB 92280b661123Smrg oldobjs=$objlist 92290b661123Smrg if test "X$oldobjs" = "X" ; then 92300b661123Smrg eval cmds=\"\$concat_cmds\" 92310b661123Smrg else 92320b661123Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 92330b661123Smrg fi 92340b661123Smrg fi 92350b661123Smrg fi 92360b661123Smrg func_execute_cmds "$cmds" 'exit $?' 9237bdcaa8d0Smrg done 9238bdcaa8d0Smrg 92390b661123Smrg test -n "$generated" && \ 92400b661123Smrg func_show_eval "${RM}r$generated" 9241bdcaa8d0Smrg 92420b661123Smrg # Now create the libtool archive. 92430b661123Smrg case $output in 92440b661123Smrg *.la) 92450b661123Smrg old_library= 92460b661123Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 92470b661123Smrg func_verbose "creating $output" 924872313efbSmrg 92490b661123Smrg # Preserve any variables that may affect compiler behavior 92500b661123Smrg for var in $variables_saved_for_relink; do 92510b661123Smrg if eval test -z \"\${$var+set}\"; then 92520b661123Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 92530b661123Smrg elif eval var_value=\$$var; test -z "$var_value"; then 92540b661123Smrg relink_command="$var=; export $var; $relink_command" 925596ce994aSmrg else 92560b661123Smrg func_quote_for_eval "$var_value" 92570b661123Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 925896ce994aSmrg fi 92590b661123Smrg done 92600b661123Smrg # Quote the link command for shipping. 92610b661123Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 9262880c7e28Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 92630b661123Smrg if test "$hardcode_automatic" = yes ; then 92640b661123Smrg relink_command= 92650b661123Smrg fi 9266bdcaa8d0Smrg 92670b661123Smrg # Only create the output if not a dry run. 92680b661123Smrg $opt_dry_run || { 92690b661123Smrg for installed in no yes; do 92700b661123Smrg if test "$installed" = yes; then 92710b661123Smrg if test -z "$install_libdir"; then 92720b661123Smrg break 92730b661123Smrg fi 92740b661123Smrg output="$output_objdir/$outputname"i 92750b661123Smrg # Replace all uninstalled libtool libraries with the installed ones 92760b661123Smrg newdependency_libs= 92770b661123Smrg for deplib in $dependency_libs; do 92780b661123Smrg case $deplib in 92790b661123Smrg *.la) 92800b661123Smrg func_basename "$deplib" 92810b661123Smrg name="$func_basename_result" 9282880c7e28Smrg func_resolve_sysroot "$deplib" 9283880c7e28Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 92840b661123Smrg test -z "$libdir" && \ 92850b661123Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 9286880c7e28Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 9287880c7e28Smrg ;; 9288880c7e28Smrg -L*) 9289880c7e28Smrg func_stripname -L '' "$deplib" 9290880c7e28Smrg func_replace_sysroot "$func_stripname_result" 9291880c7e28Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 92920b661123Smrg ;; 9293880c7e28Smrg -R*) 9294880c7e28Smrg func_stripname -R '' "$deplib" 9295880c7e28Smrg func_replace_sysroot "$func_stripname_result" 9296880c7e28Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 9297880c7e28Smrg ;; 9298880c7e28Smrg *) func_append newdependency_libs " $deplib" ;; 92990b661123Smrg esac 93000b661123Smrg done 93010b661123Smrg dependency_libs="$newdependency_libs" 93020b661123Smrg newdlfiles= 93030b661123Smrg 93040b661123Smrg for lib in $dlfiles; do 93050b661123Smrg case $lib in 93060b661123Smrg *.la) 93070b661123Smrg func_basename "$lib" 93080b661123Smrg name="$func_basename_result" 93090b661123Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 93100b661123Smrg test -z "$libdir" && \ 93110b661123Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 9312880c7e28Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 93130b661123Smrg ;; 9314880c7e28Smrg *) func_append newdlfiles " $lib" ;; 93150b661123Smrg esac 93160b661123Smrg done 93170b661123Smrg dlfiles="$newdlfiles" 93180b661123Smrg newdlprefiles= 93190b661123Smrg for lib in $dlprefiles; do 93200b661123Smrg case $lib in 93210b661123Smrg *.la) 93220b661123Smrg # Only pass preopened files to the pseudo-archive (for 93230b661123Smrg # eventual linking with the app. that links it) if we 93240b661123Smrg # didn't already link the preopened objects directly into 93250b661123Smrg # the library: 93260b661123Smrg func_basename "$lib" 93270b661123Smrg name="$func_basename_result" 93280b661123Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 93290b661123Smrg test -z "$libdir" && \ 93300b661123Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 9331880c7e28Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 93320b661123Smrg ;; 93330b661123Smrg esac 93340b661123Smrg done 93350b661123Smrg dlprefiles="$newdlprefiles" 93360b661123Smrg else 93370b661123Smrg newdlfiles= 93380b661123Smrg for lib in $dlfiles; do 93390b661123Smrg case $lib in 93400b661123Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 93410b661123Smrg *) abs=`pwd`"/$lib" ;; 93420b661123Smrg esac 9343880c7e28Smrg func_append newdlfiles " $abs" 93440b661123Smrg done 93450b661123Smrg dlfiles="$newdlfiles" 93460b661123Smrg newdlprefiles= 93470b661123Smrg for lib in $dlprefiles; do 93480b661123Smrg case $lib in 93490b661123Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 93500b661123Smrg *) abs=`pwd`"/$lib" ;; 93510b661123Smrg esac 9352880c7e28Smrg func_append newdlprefiles " $abs" 93530b661123Smrg done 93540b661123Smrg dlprefiles="$newdlprefiles" 93550b661123Smrg fi 93560b661123Smrg $RM $output 93570b661123Smrg # place dlname in correct position for cygwin 9358880c7e28Smrg # In fact, it would be nice if we could use this code for all target 9359880c7e28Smrg # systems that can't hard-code library paths into their executables 9360880c7e28Smrg # and that have no shared library path variable independent of PATH, 9361880c7e28Smrg # but it turns out we can't easily determine that from inspecting 9362880c7e28Smrg # libtool variables, so we have to hard-code the OSs to which it 9363880c7e28Smrg # applies here; at the moment, that means platforms that use the PE 9364880c7e28Smrg # object format with DLL files. See the long comment at the top of 9365880c7e28Smrg # tests/bindir.at for full details. 93660b661123Smrg tdlname=$dlname 93670b661123Smrg case $host,$output,$installed,$module,$dlname in 9368880c7e28Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 9369880c7e28Smrg # If a -bindir argument was supplied, place the dll there. 9370880c7e28Smrg if test "x$bindir" != x ; 9371880c7e28Smrg then 9372880c7e28Smrg func_relative_path "$install_libdir" "$bindir" 9373880c7e28Smrg tdlname=$func_relative_path_result$dlname 9374880c7e28Smrg else 9375880c7e28Smrg # Otherwise fall back on heuristic. 9376880c7e28Smrg tdlname=../bin/$dlname 9377880c7e28Smrg fi 9378880c7e28Smrg ;; 93790b661123Smrg esac 93800b661123Smrg $ECHO > $output "\ 93810b661123Smrg# $outputname - a libtool library file 93820b661123Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 93830b661123Smrg# 93840b661123Smrg# Please DO NOT delete this file! 93850b661123Smrg# It is necessary for linking the library. 9386bdcaa8d0Smrg 93870b661123Smrg# The name that we can dlopen(3). 93880b661123Smrgdlname='$tdlname' 9389bdcaa8d0Smrg 93900b661123Smrg# Names of this library. 93910b661123Smrglibrary_names='$library_names' 9392bdcaa8d0Smrg 93930b661123Smrg# The name of the static archive. 93940b661123Smrgold_library='$old_library' 9395bdcaa8d0Smrg 93960b661123Smrg# Linker flags that can not go in dependency_libs. 93970b661123Smrginherited_linker_flags='$new_inherited_linker_flags' 9398bdcaa8d0Smrg 93990b661123Smrg# Libraries that this one depends upon. 94000b661123Smrgdependency_libs='$dependency_libs' 9401bdcaa8d0Smrg 94020b661123Smrg# Names of additional weak libraries provided by this library 94030b661123Smrgweak_library_names='$weak_libs' 9404bdcaa8d0Smrg 94050b661123Smrg# Version information for $libname. 94060b661123Smrgcurrent=$current 94070b661123Smrgage=$age 94080b661123Smrgrevision=$revision 9409bdcaa8d0Smrg 94100b661123Smrg# Is this an already installed library? 94110b661123Smrginstalled=$installed 9412bdcaa8d0Smrg 94130b661123Smrg# Should we warn about portability when linking against -modules? 94140b661123Smrgshouldnotlink=$module 9415bdcaa8d0Smrg 94160b661123Smrg# Files to dlopen/dlpreopen 94170b661123Smrgdlopen='$dlfiles' 94180b661123Smrgdlpreopen='$dlprefiles' 9419bdcaa8d0Smrg 94200b661123Smrg# Directory that this library needs to be installed in: 94210b661123Smrglibdir='$install_libdir'" 94220b661123Smrg if test "$installed" = no && test "$need_relink" = yes; then 94230b661123Smrg $ECHO >> $output "\ 94240b661123Smrgrelink_command=\"$relink_command\"" 94250b661123Smrg fi 94260b661123Smrg done 94270b661123Smrg } 9428bdcaa8d0Smrg 94290b661123Smrg # Do a symbolic link so that the libtool archive can be found in 94300b661123Smrg # LD_LIBRARY_PATH before the program is installed. 94310b661123Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 94320b661123Smrg ;; 94330b661123Smrg esac 94340b661123Smrg exit $EXIT_SUCCESS 94350b661123Smrg} 943696ce994aSmrg 9437880c7e28Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 94380b661123Smrg func_mode_link ${1+"$@"} 9439bdcaa8d0Smrg 9440bdcaa8d0Smrg 94410b661123Smrg# func_mode_uninstall arg... 94420b661123Smrgfunc_mode_uninstall () 94430b661123Smrg{ 94440b661123Smrg $opt_debug 94450b661123Smrg RM="$nonopt" 9446bdcaa8d0Smrg files= 9447bdcaa8d0Smrg rmforce= 9448bdcaa8d0Smrg exit_status=0 9449bdcaa8d0Smrg 9450bdcaa8d0Smrg # This variable tells wrapper scripts just to set variables rather 9451bdcaa8d0Smrg # than running their programs. 9452bdcaa8d0Smrg libtool_install_magic="$magic" 9453bdcaa8d0Smrg 9454bdcaa8d0Smrg for arg 9455bdcaa8d0Smrg do 9456bdcaa8d0Smrg case $arg in 9457880c7e28Smrg -f) func_append RM " $arg"; rmforce=yes ;; 9458880c7e28Smrg -*) func_append RM " $arg" ;; 9459880c7e28Smrg *) func_append files " $arg" ;; 9460bdcaa8d0Smrg esac 9461bdcaa8d0Smrg done 9462bdcaa8d0Smrg 94630b661123Smrg test -z "$RM" && \ 94640b661123Smrg func_fatal_help "you must specify an RM program" 9465bdcaa8d0Smrg 9466bdcaa8d0Smrg rmdirs= 9467bdcaa8d0Smrg 9468bdcaa8d0Smrg for file in $files; do 94690b661123Smrg func_dirname "$file" "" "." 94700b661123Smrg dir="$func_dirname_result" 94710b661123Smrg if test "X$dir" = X.; then 9472880c7e28Smrg odir="$objdir" 9473bdcaa8d0Smrg else 9474880c7e28Smrg odir="$dir/$objdir" 9475bdcaa8d0Smrg fi 94760b661123Smrg func_basename "$file" 94770b661123Smrg name="$func_basename_result" 9478880c7e28Smrg test "$opt_mode" = uninstall && odir="$dir" 9479bdcaa8d0Smrg 9480880c7e28Smrg # Remember odir for removal later, being careful to avoid duplicates 9481880c7e28Smrg if test "$opt_mode" = clean; then 9482bdcaa8d0Smrg case " $rmdirs " in 9483880c7e28Smrg *" $odir "*) ;; 9484880c7e28Smrg *) func_append rmdirs " $odir" ;; 9485bdcaa8d0Smrg esac 9486bdcaa8d0Smrg fi 9487bdcaa8d0Smrg 9488bdcaa8d0Smrg # Don't error if the file doesn't exist and rm -f was used. 94890b661123Smrg if { test -L "$file"; } >/dev/null 2>&1 || 94900b661123Smrg { test -h "$file"; } >/dev/null 2>&1 || 94910b661123Smrg test -f "$file"; then 9492bdcaa8d0Smrg : 9493bdcaa8d0Smrg elif test -d "$file"; then 9494bdcaa8d0Smrg exit_status=1 9495bdcaa8d0Smrg continue 9496bdcaa8d0Smrg elif test "$rmforce" = yes; then 9497bdcaa8d0Smrg continue 9498bdcaa8d0Smrg fi 9499bdcaa8d0Smrg 9500bdcaa8d0Smrg rmfiles="$file" 9501bdcaa8d0Smrg 9502bdcaa8d0Smrg case $name in 9503bdcaa8d0Smrg *.la) 9504bdcaa8d0Smrg # Possibly a libtool archive, so verify it. 95050b661123Smrg if func_lalib_p "$file"; then 95060b661123Smrg func_source $dir/$name 9507bdcaa8d0Smrg 9508bdcaa8d0Smrg # Delete the libtool libraries and symlinks. 9509bdcaa8d0Smrg for n in $library_names; do 9510880c7e28Smrg func_append rmfiles " $odir/$n" 9511bdcaa8d0Smrg done 9512880c7e28Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 9513bdcaa8d0Smrg 9514880c7e28Smrg case "$opt_mode" in 9515bdcaa8d0Smrg clean) 9516880c7e28Smrg case " $library_names " in 9517bdcaa8d0Smrg *" $dlname "*) ;; 9518880c7e28Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 9519bdcaa8d0Smrg esac 9520880c7e28Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 9521bdcaa8d0Smrg ;; 9522bdcaa8d0Smrg uninstall) 9523bdcaa8d0Smrg if test -n "$library_names"; then 9524bdcaa8d0Smrg # Do each command in the postuninstall commands. 95250b661123Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9526bdcaa8d0Smrg fi 9527bdcaa8d0Smrg 9528bdcaa8d0Smrg if test -n "$old_library"; then 9529bdcaa8d0Smrg # Do each command in the old_postuninstall commands. 95300b661123Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9531bdcaa8d0Smrg fi 9532bdcaa8d0Smrg # FIXME: should reinstall the best remaining shared library. 9533bdcaa8d0Smrg ;; 9534bdcaa8d0Smrg esac 9535bdcaa8d0Smrg fi 9536bdcaa8d0Smrg ;; 9537bdcaa8d0Smrg 9538bdcaa8d0Smrg *.lo) 9539bdcaa8d0Smrg # Possibly a libtool object, so verify it. 95400b661123Smrg if func_lalib_p "$file"; then 9541bdcaa8d0Smrg 9542bdcaa8d0Smrg # Read the .lo file 95430b661123Smrg func_source $dir/$name 9544bdcaa8d0Smrg 9545bdcaa8d0Smrg # Add PIC object to the list of files to remove. 95460b661123Smrg if test -n "$pic_object" && 95470b661123Smrg test "$pic_object" != none; then 9548880c7e28Smrg func_append rmfiles " $dir/$pic_object" 9549bdcaa8d0Smrg fi 9550bdcaa8d0Smrg 9551bdcaa8d0Smrg # Add non-PIC object to the list of files to remove. 95520b661123Smrg if test -n "$non_pic_object" && 95530b661123Smrg test "$non_pic_object" != none; then 9554880c7e28Smrg func_append rmfiles " $dir/$non_pic_object" 9555bdcaa8d0Smrg fi 9556bdcaa8d0Smrg fi 9557bdcaa8d0Smrg ;; 9558bdcaa8d0Smrg 9559bdcaa8d0Smrg *) 9560880c7e28Smrg if test "$opt_mode" = clean ; then 9561bdcaa8d0Smrg noexename=$name 9562bdcaa8d0Smrg case $file in 9563bdcaa8d0Smrg *.exe) 95640b661123Smrg func_stripname '' '.exe' "$file" 95650b661123Smrg file=$func_stripname_result 95660b661123Smrg func_stripname '' '.exe' "$name" 95670b661123Smrg noexename=$func_stripname_result 9568bdcaa8d0Smrg # $file with .exe has already been added to rmfiles, 9569bdcaa8d0Smrg # add $file without .exe 9570880c7e28Smrg func_append rmfiles " $file" 9571bdcaa8d0Smrg ;; 9572bdcaa8d0Smrg esac 9573bdcaa8d0Smrg # Do a test to see if this is a libtool program. 95740b661123Smrg if func_ltwrapper_p "$file"; then 95750b661123Smrg if func_ltwrapper_executable_p "$file"; then 95760b661123Smrg func_ltwrapper_scriptname "$file" 95770b661123Smrg relink_command= 95780b661123Smrg func_source $func_ltwrapper_scriptname_result 9579880c7e28Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 95800b661123Smrg else 95810b661123Smrg relink_command= 95820b661123Smrg func_source $dir/$noexename 95830b661123Smrg fi 9584bdcaa8d0Smrg 9585bdcaa8d0Smrg # note $name still contains .exe if it was in $file originally 9586bdcaa8d0Smrg # as does the version of $file that was added into $rmfiles 9587880c7e28Smrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9588bdcaa8d0Smrg if test "$fast_install" = yes && test -n "$relink_command"; then 9589880c7e28Smrg func_append rmfiles " $odir/lt-$name" 9590bdcaa8d0Smrg fi 9591bdcaa8d0Smrg if test "X$noexename" != "X$name" ; then 9592880c7e28Smrg func_append rmfiles " $odir/lt-${noexename}.c" 9593bdcaa8d0Smrg fi 9594bdcaa8d0Smrg fi 9595bdcaa8d0Smrg fi 9596bdcaa8d0Smrg ;; 9597bdcaa8d0Smrg esac 95980b661123Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 9599bdcaa8d0Smrg done 9600bdcaa8d0Smrg 9601bdcaa8d0Smrg # Try to remove the ${objdir}s in the directories where we deleted files 9602bdcaa8d0Smrg for dir in $rmdirs; do 9603bdcaa8d0Smrg if test -d "$dir"; then 96040b661123Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 9605bdcaa8d0Smrg fi 9606bdcaa8d0Smrg done 9607bdcaa8d0Smrg 9608bdcaa8d0Smrg exit $exit_status 96090b661123Smrg} 9610bdcaa8d0Smrg 9611880c7e28Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 96120b661123Smrg func_mode_uninstall ${1+"$@"} 961372313efbSmrg 9614880c7e28Smrgtest -z "$opt_mode" && { 96150b661123Smrg help="$generic_help" 96160b661123Smrg func_fatal_help "you must specify a MODE" 96170b661123Smrg} 96180b661123Smrg 96190b661123Smrgtest -z "$exec_cmd" && \ 9620880c7e28Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 9621bdcaa8d0Smrg 9622bdcaa8d0Smrgif test -n "$exec_cmd"; then 96230b661123Smrg eval exec "$exec_cmd" 9624bdcaa8d0Smrg exit $EXIT_FAILURE 9625bdcaa8d0Smrgfi 9626bdcaa8d0Smrg 96270b661123Smrgexit $exit_status 9628bdcaa8d0Smrg 9629bdcaa8d0Smrg 9630bdcaa8d0Smrg# The TAGs below are defined such that we never get into a situation 9631bdcaa8d0Smrg# in which we disable both kinds of libraries. Given conflicting 9632bdcaa8d0Smrg# choices, we go for a static library, that is the most portable, 9633bdcaa8d0Smrg# since we can't tell whether shared libraries were disabled because 9634bdcaa8d0Smrg# the user asked for that or because the platform doesn't support 9635bdcaa8d0Smrg# them. This is particularly important on AIX, because we don't 9636bdcaa8d0Smrg# support having both static and shared libraries enabled at the same 9637bdcaa8d0Smrg# time on that platform, so we default to a shared-only configuration. 9638bdcaa8d0Smrg# If a disable-shared tag is given, we'll fallback to a static-only 9639bdcaa8d0Smrg# configuration. But we'll never go from static-only to shared-only. 9640bdcaa8d0Smrg 9641bdcaa8d0Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 96420b661123Smrgbuild_libtool_libs=no 96430b661123Smrgbuild_old_libs=yes 9644bdcaa8d0Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 9645bdcaa8d0Smrg 9646bdcaa8d0Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 96470b661123Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 9648bdcaa8d0Smrg# ### END LIBTOOL TAG CONFIG: disable-static 9649bdcaa8d0Smrg 9650bdcaa8d0Smrg# Local Variables: 9651bdcaa8d0Smrg# mode:shell-script 9652bdcaa8d0Smrg# sh-indentation:2 9653bdcaa8d0Smrg# End: 96540b661123Smrg# vi:sw=2 96550b661123Smrg 9656