ltmain.sh revision 65d490d0
165d490d0Smrg 265d490d0Smrg# libtool (GNU libtool) 2.4 365d490d0Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 465d490d0Smrg 5e4da13eeSmacallan# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 665d490d0Smrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 765d490d0Smrg# This is free software; see the source for copying conditions. There is NO 865d490d0Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 965d490d0Smrg 1065d490d0Smrg# GNU Libtool is free software; you can redistribute it and/or modify 11e4da13eeSmacallan# it under the terms of the GNU General Public License as published by 12e4da13eeSmacallan# the Free Software Foundation; either version 2 of the License, or 13e4da13eeSmacallan# (at your option) any later version. 14e4da13eeSmacallan# 1565d490d0Smrg# As a special exception to the GNU General Public License, 1665d490d0Smrg# if you distribute this file as part of a program or library that 1765d490d0Smrg# is built using GNU Libtool, you may include this file under the 1865d490d0Smrg# same distribution terms that you use for the rest of that program. 1965d490d0Smrg# 2065d490d0Smrg# GNU Libtool is distributed in the hope that it will be useful, but 21e4da13eeSmacallan# WITHOUT ANY WARRANTY; without even the implied warranty of 22e4da13eeSmacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23e4da13eeSmacallan# General Public License for more details. 24e4da13eeSmacallan# 25e4da13eeSmacallan# You should have received a copy of the GNU General Public License 2665d490d0Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 2765d490d0Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 2865d490d0Smrg# or obtained by writing to the Free Software Foundation, Inc., 2965d490d0Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 30e4da13eeSmacallan 3165d490d0Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 3265d490d0Smrg# 3365d490d0Smrg# Provide generalized library-building support services. 3465d490d0Smrg# 3565d490d0Smrg# --config show all configuration variables 3665d490d0Smrg# --debug enable verbose shell tracing 3765d490d0Smrg# -n, --dry-run display commands without modifying any files 3865d490d0Smrg# --features display basic configuration information and exit 3965d490d0Smrg# --mode=MODE use operation mode MODE 4065d490d0Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 4165d490d0Smrg# --quiet, --silent don't print informational messages 4265d490d0Smrg# --no-quiet, --no-silent 4365d490d0Smrg# print informational messages (default) 4465d490d0Smrg# --tag=TAG use configuration variables from tag TAG 4565d490d0Smrg# -v, --verbose print more informational messages than default 4665d490d0Smrg# --no-verbose don't print the extra informational messages 4765d490d0Smrg# --version print version information 4865d490d0Smrg# -h, --help, --help-all print short, long, or detailed help message 4965d490d0Smrg# 5065d490d0Smrg# MODE must be one of the following: 5165d490d0Smrg# 5265d490d0Smrg# clean remove files from the build directory 5365d490d0Smrg# compile compile a source file into a libtool object 5465d490d0Smrg# execute automatically set library path, then run a program 5565d490d0Smrg# finish complete the installation of libtool libraries 5665d490d0Smrg# install install libraries or executables 5765d490d0Smrg# link create a library or an executable 5865d490d0Smrg# uninstall remove libraries from an installed directory 5965d490d0Smrg# 6065d490d0Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 6165d490d0Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 6265d490d0Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 6365d490d0Smrg# 6465d490d0Smrg# When reporting a bug, please describe a test case to reproduce it and 6565d490d0Smrg# include the following information: 6665d490d0Smrg# 6765d490d0Smrg# host-triplet: $host 6865d490d0Smrg# shell: $SHELL 6965d490d0Smrg# compiler: $LTCC 7065d490d0Smrg# compiler flags: $LTCFLAGS 7165d490d0Smrg# linker: $LD (gnu? $with_gnu_ld) 7265d490d0Smrg# $progname: (GNU libtool) 2.4 7365d490d0Smrg# automake: $automake_version 7465d490d0Smrg# autoconf: $autoconf_version 7565d490d0Smrg# 7665d490d0Smrg# Report bugs to <bug-libtool@gnu.org>. 7765d490d0Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 7865d490d0Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 79e4da13eeSmacallan 8065d490d0SmrgPROGRAM=libtool 81e4da13eeSmacallanPACKAGE=libtool 8265d490d0SmrgVERSION=2.4 8365d490d0SmrgTIMESTAMP="" 8465d490d0Smrgpackage_revision=1.3293 85e4da13eeSmacallan 8665d490d0Smrg# Be Bourne compatible 87e4da13eeSmacallanif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 88e4da13eeSmacallan emulate sh 89e4da13eeSmacallan NULLCMD=: 90e4da13eeSmacallan # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 91e4da13eeSmacallan # is contrary to our usage. Disable this feature. 92e4da13eeSmacallan alias -g '${1+"$@"}'='"$@"' 93e4da13eeSmacallan setopt NO_GLOB_SUBST 94e4da13eeSmacallanelse 95e4da13eeSmacallan case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 96e4da13eeSmacallanfi 97e4da13eeSmacallanBIN_SH=xpg4; export BIN_SH # for Tru64 98e4da13eeSmacallanDUALCASE=1; export DUALCASE # for MKS sh 99e4da13eeSmacallan 10065d490d0Smrg# A function that is used when there is no print builtin or printf. 10165d490d0Smrgfunc_fallback_echo () 10265d490d0Smrg{ 10365d490d0Smrg eval 'cat <<_LTECHO_EOF 10465d490d0Smrg$1 10565d490d0Smrg_LTECHO_EOF' 10665d490d0Smrg} 107e4da13eeSmacallan 10865d490d0Smrg# NLS nuisances: We save the old values to restore during execute mode. 10965d490d0Smrglt_user_locale= 11065d490d0Smrglt_safe_locale= 111e4da13eeSmacallanfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 112e4da13eeSmacallando 113e4da13eeSmacallan eval "if test \"\${$lt_var+set}\" = set; then 11465d490d0Smrg save_$lt_var=\$$lt_var 11565d490d0Smrg $lt_var=C 116e4da13eeSmacallan export $lt_var 11765d490d0Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 11865d490d0Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 119e4da13eeSmacallan fi" 120e4da13eeSmacallandone 12165d490d0SmrgLC_ALL=C 12265d490d0SmrgLANGUAGE=C 12365d490d0Smrgexport LANGUAGE LC_ALL 12465d490d0Smrg 12565d490d0Smrg$lt_unset CDPATH 126e4da13eeSmacallan 12765d490d0Smrg 12865d490d0Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 12965d490d0Smrg# is ksh but when the shell is invoked as "sh" and the current value of 13065d490d0Smrg# the _XPG environment variable is not equal to 1 (one), the special 13165d490d0Smrg# positional parameter $0, within a function call, is the name of the 13265d490d0Smrg# function. 13365d490d0Smrgprogpath="$0" 13465d490d0Smrg 13565d490d0Smrg 13665d490d0Smrg 13765d490d0Smrg: ${CP="cp -f"} 13865d490d0Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 13965d490d0Smrg: ${EGREP="grep -E"} 14065d490d0Smrg: ${FGREP="grep -F"} 14165d490d0Smrg: ${GREP="grep"} 14265d490d0Smrg: ${LN_S="ln -s"} 14365d490d0Smrg: ${MAKE="make"} 14465d490d0Smrg: ${MKDIR="mkdir"} 14565d490d0Smrg: ${MV="mv -f"} 14665d490d0Smrg: ${RM="rm -f"} 14765d490d0Smrg: ${SED="sed"} 14865d490d0Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 14965d490d0Smrg: ${Xsed="$SED -e 1s/^X//"} 15065d490d0Smrg 15165d490d0Smrg# Global variables: 15265d490d0SmrgEXIT_SUCCESS=0 15365d490d0SmrgEXIT_FAILURE=1 15465d490d0SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 15565d490d0SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 15665d490d0Smrg 15765d490d0Smrgexit_status=$EXIT_SUCCESS 158e4da13eeSmacallan 159e4da13eeSmacallan# Make sure IFS has a sensible default 160e4da13eeSmacallanlt_nl=' 161e4da13eeSmacallan' 162e4da13eeSmacallanIFS=" $lt_nl" 163e4da13eeSmacallan 16465d490d0Smrgdirname="s,/[^/]*$,," 16565d490d0Smrgbasename="s,^.*/,," 166e4da13eeSmacallan 16765d490d0Smrg# func_dirname file append nondir_replacement 16865d490d0Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 16965d490d0Smrg# otherwise set result to NONDIR_REPLACEMENT. 17065d490d0Smrgfunc_dirname () 17165d490d0Smrg{ 17265d490d0Smrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 17365d490d0Smrg if test "X$func_dirname_result" = "X${1}"; then 17465d490d0Smrg func_dirname_result="${3}" 17565d490d0Smrg else 17665d490d0Smrg func_dirname_result="$func_dirname_result${2}" 17765d490d0Smrg fi 17865d490d0Smrg} # func_dirname may be replaced by extended shell implementation 17965d490d0Smrg 18065d490d0Smrg 18165d490d0Smrg# func_basename file 18265d490d0Smrgfunc_basename () 18365d490d0Smrg{ 18465d490d0Smrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 18565d490d0Smrg} # func_basename may be replaced by extended shell implementation 18665d490d0Smrg 18765d490d0Smrg 18865d490d0Smrg# func_dirname_and_basename file append nondir_replacement 18965d490d0Smrg# perform func_basename and func_dirname in a single function 19065d490d0Smrg# call: 19165d490d0Smrg# dirname: Compute the dirname of FILE. If nonempty, 19265d490d0Smrg# add APPEND to the result, otherwise set result 19365d490d0Smrg# to NONDIR_REPLACEMENT. 19465d490d0Smrg# value returned in "$func_dirname_result" 19565d490d0Smrg# basename: Compute filename of FILE. 19665d490d0Smrg# value retuned in "$func_basename_result" 19765d490d0Smrg# Implementation must be kept synchronized with func_dirname 19865d490d0Smrg# and func_basename. For efficiency, we do not delegate to 19965d490d0Smrg# those functions but instead duplicate the functionality here. 20065d490d0Smrgfunc_dirname_and_basename () 20165d490d0Smrg{ 20265d490d0Smrg # Extract subdirectory from the argument. 20365d490d0Smrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 20465d490d0Smrg if test "X$func_dirname_result" = "X${1}"; then 20565d490d0Smrg func_dirname_result="${3}" 20665d490d0Smrg else 20765d490d0Smrg func_dirname_result="$func_dirname_result${2}" 20865d490d0Smrg fi 20965d490d0Smrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 21065d490d0Smrg} # func_dirname_and_basename may be replaced by extended shell implementation 21165d490d0Smrg 21265d490d0Smrg 21365d490d0Smrg# func_stripname prefix suffix name 21465d490d0Smrg# strip PREFIX and SUFFIX off of NAME. 21565d490d0Smrg# PREFIX and SUFFIX must not contain globbing or regex special 21665d490d0Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 21765d490d0Smrg# dot (in which case that matches only a dot). 21865d490d0Smrg# func_strip_suffix prefix name 21965d490d0Smrgfunc_stripname () 22065d490d0Smrg{ 22165d490d0Smrg case ${2} in 22265d490d0Smrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 22365d490d0Smrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 22465d490d0Smrg esac 22565d490d0Smrg} # func_stripname may be replaced by extended shell implementation 22665d490d0Smrg 22765d490d0Smrg 22865d490d0Smrg# These SED scripts presuppose an absolute path with a trailing slash. 22965d490d0Smrgpathcar='s,^/\([^/]*\).*$,\1,' 23065d490d0Smrgpathcdr='s,^/[^/]*,,' 23165d490d0Smrgremovedotparts=':dotsl 23265d490d0Smrg s@/\./@/@g 23365d490d0Smrg t dotsl 23465d490d0Smrg s,/\.$,/,' 23565d490d0Smrgcollapseslashes='s@/\{1,\}@/@g' 23665d490d0Smrgfinalslash='s,/*$,/,' 23765d490d0Smrg 23865d490d0Smrg# func_normal_abspath PATH 23965d490d0Smrg# Remove doubled-up and trailing slashes, "." path components, 24065d490d0Smrg# and cancel out any ".." path components in PATH after making 24165d490d0Smrg# it an absolute path. 24265d490d0Smrg# value returned in "$func_normal_abspath_result" 24365d490d0Smrgfunc_normal_abspath () 24465d490d0Smrg{ 24565d490d0Smrg # Start from root dir and reassemble the path. 24665d490d0Smrg func_normal_abspath_result= 24765d490d0Smrg func_normal_abspath_tpath=$1 24865d490d0Smrg func_normal_abspath_altnamespace= 24965d490d0Smrg case $func_normal_abspath_tpath in 25065d490d0Smrg "") 25165d490d0Smrg # Empty path, that just means $cwd. 25265d490d0Smrg func_stripname '' '/' "`pwd`" 25365d490d0Smrg func_normal_abspath_result=$func_stripname_result 25465d490d0Smrg return 25565d490d0Smrg ;; 25665d490d0Smrg # The next three entries are used to spot a run of precisely 25765d490d0Smrg # two leading slashes without using negated character classes; 25865d490d0Smrg # we take advantage of case's first-match behaviour. 25965d490d0Smrg ///*) 26065d490d0Smrg # Unusual form of absolute path, do nothing. 26165d490d0Smrg ;; 26265d490d0Smrg //*) 26365d490d0Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 26465d490d0Smrg # and for example Cygwin uses it to access remote file shares 26565d490d0Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 26665d490d0Smrg func_normal_abspath_altnamespace=/ 26765d490d0Smrg ;; 26865d490d0Smrg /*) 26965d490d0Smrg # Absolute path, do nothing. 27065d490d0Smrg ;; 27165d490d0Smrg *) 27265d490d0Smrg # Relative path, prepend $cwd. 27365d490d0Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 27465d490d0Smrg ;; 27565d490d0Smrg esac 27665d490d0Smrg # Cancel out all the simple stuff to save iterations. We also want 27765d490d0Smrg # the path to end with a slash for ease of parsing, so make sure 27865d490d0Smrg # there is one (and only one) here. 27965d490d0Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 28065d490d0Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 28165d490d0Smrg while :; do 28265d490d0Smrg # Processed it all yet? 28365d490d0Smrg if test "$func_normal_abspath_tpath" = / ; then 28465d490d0Smrg # If we ascended to the root using ".." the result may be empty now. 28565d490d0Smrg if test -z "$func_normal_abspath_result" ; then 28665d490d0Smrg func_normal_abspath_result=/ 28765d490d0Smrg fi 28865d490d0Smrg break 28965d490d0Smrg fi 29065d490d0Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 29165d490d0Smrg -e "$pathcar"` 29265d490d0Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 29365d490d0Smrg -e "$pathcdr"` 29465d490d0Smrg # Figure out what to do with it 29565d490d0Smrg case $func_normal_abspath_tcomponent in 29665d490d0Smrg "") 29765d490d0Smrg # Trailing empty path component, ignore it. 29865d490d0Smrg ;; 29965d490d0Smrg ..) 30065d490d0Smrg # Parent dir; strip last assembled component from result. 30165d490d0Smrg func_dirname "$func_normal_abspath_result" 30265d490d0Smrg func_normal_abspath_result=$func_dirname_result 30365d490d0Smrg ;; 30465d490d0Smrg *) 30565d490d0Smrg # Actual path component, append it. 30665d490d0Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 30765d490d0Smrg ;; 30865d490d0Smrg esac 30965d490d0Smrg done 31065d490d0Smrg # Restore leading double-slash if one was found on entry. 31165d490d0Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 31265d490d0Smrg} 31365d490d0Smrg 31465d490d0Smrg# func_relative_path SRCDIR DSTDIR 31565d490d0Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 31665d490d0Smrg# slash if non-empty, suitable for immediately appending a filename 31765d490d0Smrg# without needing to append a separator. 31865d490d0Smrg# value returned in "$func_relative_path_result" 31965d490d0Smrgfunc_relative_path () 32065d490d0Smrg{ 32165d490d0Smrg func_relative_path_result= 32265d490d0Smrg func_normal_abspath "$1" 32365d490d0Smrg func_relative_path_tlibdir=$func_normal_abspath_result 32465d490d0Smrg func_normal_abspath "$2" 32565d490d0Smrg func_relative_path_tbindir=$func_normal_abspath_result 32665d490d0Smrg 32765d490d0Smrg # Ascend the tree starting from libdir 32865d490d0Smrg while :; do 32965d490d0Smrg # check if we have found a prefix of bindir 33065d490d0Smrg case $func_relative_path_tbindir in 33165d490d0Smrg $func_relative_path_tlibdir) 33265d490d0Smrg # found an exact match 33365d490d0Smrg func_relative_path_tcancelled= 33465d490d0Smrg break 33565d490d0Smrg ;; 33665d490d0Smrg $func_relative_path_tlibdir*) 33765d490d0Smrg # found a matching prefix 33865d490d0Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 33965d490d0Smrg func_relative_path_tcancelled=$func_stripname_result 34065d490d0Smrg if test -z "$func_relative_path_result"; then 34165d490d0Smrg func_relative_path_result=. 34265d490d0Smrg fi 34365d490d0Smrg break 34465d490d0Smrg ;; 34565d490d0Smrg *) 34665d490d0Smrg func_dirname $func_relative_path_tlibdir 34765d490d0Smrg func_relative_path_tlibdir=${func_dirname_result} 34865d490d0Smrg if test "x$func_relative_path_tlibdir" = x ; then 34965d490d0Smrg # Have to descend all the way to the root! 35065d490d0Smrg func_relative_path_result=../$func_relative_path_result 35165d490d0Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 35265d490d0Smrg break 35365d490d0Smrg fi 35465d490d0Smrg func_relative_path_result=../$func_relative_path_result 35565d490d0Smrg ;; 35665d490d0Smrg esac 35765d490d0Smrg done 35865d490d0Smrg 35965d490d0Smrg # Now calculate path; take care to avoid doubling-up slashes. 36065d490d0Smrg func_stripname '' '/' "$func_relative_path_result" 36165d490d0Smrg func_relative_path_result=$func_stripname_result 36265d490d0Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 36365d490d0Smrg if test "x$func_stripname_result" != x ; then 36465d490d0Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 36565d490d0Smrg fi 36665d490d0Smrg 36765d490d0Smrg # Normalisation. If bindir is libdir, return empty string, 36865d490d0Smrg # else relative path ending with a slash; either way, target 36965d490d0Smrg # file name can be directly appended. 37065d490d0Smrg if test ! -z "$func_relative_path_result"; then 37165d490d0Smrg func_stripname './' '' "$func_relative_path_result/" 37265d490d0Smrg func_relative_path_result=$func_stripname_result 37365d490d0Smrg fi 37465d490d0Smrg} 37565d490d0Smrg 37665d490d0Smrg# The name of this program: 37765d490d0Smrgfunc_dirname_and_basename "$progpath" 37865d490d0Smrgprogname=$func_basename_result 37965d490d0Smrg 38065d490d0Smrg# Make sure we have an absolute path for reexecution: 38165d490d0Smrgcase $progpath in 38265d490d0Smrg [\\/]*|[A-Za-z]:\\*) ;; 38365d490d0Smrg *[\\/]*) 38465d490d0Smrg progdir=$func_dirname_result 38565d490d0Smrg progdir=`cd "$progdir" && pwd` 38665d490d0Smrg progpath="$progdir/$progname" 38765d490d0Smrg ;; 38865d490d0Smrg *) 38965d490d0Smrg save_IFS="$IFS" 39065d490d0Smrg IFS=: 39165d490d0Smrg for progdir in $PATH; do 39265d490d0Smrg IFS="$save_IFS" 39365d490d0Smrg test -x "$progdir/$progname" && break 39465d490d0Smrg done 39565d490d0Smrg IFS="$save_IFS" 39665d490d0Smrg test -n "$progdir" || progdir=`pwd` 39765d490d0Smrg progpath="$progdir/$progname" 39865d490d0Smrg ;; 39965d490d0Smrgesac 40065d490d0Smrg 40165d490d0Smrg# Sed substitution that helps us do robust quoting. It backslashifies 40265d490d0Smrg# metacharacters that are still active within double-quoted strings. 40365d490d0SmrgXsed="${SED}"' -e 1s/^X//' 40465d490d0Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 40565d490d0Smrg 40665d490d0Smrg# Same as above, but do not quote variable references. 40765d490d0Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 40865d490d0Smrg 40965d490d0Smrg# Sed substitution that turns a string into a regex matching for the 41065d490d0Smrg# string literally. 41165d490d0Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 41265d490d0Smrg 41365d490d0Smrg# Sed substitution that converts a w32 file name or path 41465d490d0Smrg# which contains forward slashes, into one that contains 41565d490d0Smrg# (escaped) backslashes. A very naive implementation. 41665d490d0Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 41765d490d0Smrg 41865d490d0Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 41965d490d0Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 42065d490d0Smrg# in input to double_quote_subst, that '$' was protected from expansion. 42165d490d0Smrg# Since each input `\' is now two `\'s, look for any number of runs of 42265d490d0Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 42365d490d0Smrgbs='\\' 42465d490d0Smrgbs2='\\\\' 42565d490d0Smrgbs4='\\\\\\\\' 42665d490d0Smrgdollar='\$' 42765d490d0Smrgsed_double_backslash="\ 42865d490d0Smrg s/$bs4/&\\ 42965d490d0Smrg/g 43065d490d0Smrg s/^$bs2$dollar/$bs&/ 43165d490d0Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 43265d490d0Smrg s/\n//g" 43365d490d0Smrg 43465d490d0Smrg# Standard options: 43565d490d0Smrgopt_dry_run=false 43665d490d0Smrgopt_help=false 43765d490d0Smrgopt_quiet=false 43865d490d0Smrgopt_verbose=false 43965d490d0Smrgopt_warning=: 44065d490d0Smrg 44165d490d0Smrg# func_echo arg... 44265d490d0Smrg# Echo program name prefixed message, along with the current mode 44365d490d0Smrg# name if it has been set yet. 44465d490d0Smrgfunc_echo () 44565d490d0Smrg{ 44665d490d0Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 44765d490d0Smrg} 44865d490d0Smrg 44965d490d0Smrg# func_verbose arg... 45065d490d0Smrg# Echo program name prefixed message in verbose mode only. 45165d490d0Smrgfunc_verbose () 45265d490d0Smrg{ 45365d490d0Smrg $opt_verbose && func_echo ${1+"$@"} 45465d490d0Smrg 45565d490d0Smrg # A bug in bash halts the script if the last line of a function 45665d490d0Smrg # fails when set -e is in force, so we need another command to 45765d490d0Smrg # work around that: 45865d490d0Smrg : 45965d490d0Smrg} 46065d490d0Smrg 46165d490d0Smrg# func_echo_all arg... 46265d490d0Smrg# Invoke $ECHO with all args, space-separated. 46365d490d0Smrgfunc_echo_all () 46465d490d0Smrg{ 46565d490d0Smrg $ECHO "$*" 46665d490d0Smrg} 46765d490d0Smrg 46865d490d0Smrg# func_error arg... 46965d490d0Smrg# Echo program name prefixed message to standard error. 47065d490d0Smrgfunc_error () 47165d490d0Smrg{ 47265d490d0Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 47365d490d0Smrg} 47465d490d0Smrg 47565d490d0Smrg# func_warning arg... 47665d490d0Smrg# Echo program name prefixed warning message to standard error. 47765d490d0Smrgfunc_warning () 47865d490d0Smrg{ 47965d490d0Smrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 48065d490d0Smrg 48165d490d0Smrg # bash bug again: 48265d490d0Smrg : 48365d490d0Smrg} 48465d490d0Smrg 48565d490d0Smrg# func_fatal_error arg... 48665d490d0Smrg# Echo program name prefixed message to standard error, and exit. 48765d490d0Smrgfunc_fatal_error () 48865d490d0Smrg{ 48965d490d0Smrg func_error ${1+"$@"} 49065d490d0Smrg exit $EXIT_FAILURE 49165d490d0Smrg} 49265d490d0Smrg 49365d490d0Smrg# func_fatal_help arg... 49465d490d0Smrg# Echo program name prefixed message to standard error, followed by 49565d490d0Smrg# a help hint, and exit. 49665d490d0Smrgfunc_fatal_help () 49765d490d0Smrg{ 49865d490d0Smrg func_error ${1+"$@"} 49965d490d0Smrg func_fatal_error "$help" 50065d490d0Smrg} 50165d490d0Smrghelp="Try \`$progname --help' for more information." ## default 50265d490d0Smrg 50365d490d0Smrg 50465d490d0Smrg# func_grep expression filename 50565d490d0Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 50665d490d0Smrgfunc_grep () 50765d490d0Smrg{ 50865d490d0Smrg $GREP "$1" "$2" >/dev/null 2>&1 50965d490d0Smrg} 51065d490d0Smrg 51165d490d0Smrg 51265d490d0Smrg# func_mkdir_p directory-path 51365d490d0Smrg# Make sure the entire path to DIRECTORY-PATH is available. 51465d490d0Smrgfunc_mkdir_p () 51565d490d0Smrg{ 51665d490d0Smrg my_directory_path="$1" 51765d490d0Smrg my_dir_list= 51865d490d0Smrg 51965d490d0Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 52065d490d0Smrg 52165d490d0Smrg # Protect directory names starting with `-' 52265d490d0Smrg case $my_directory_path in 52365d490d0Smrg -*) my_directory_path="./$my_directory_path" ;; 52465d490d0Smrg esac 52565d490d0Smrg 52665d490d0Smrg # While some portion of DIR does not yet exist... 52765d490d0Smrg while test ! -d "$my_directory_path"; do 52865d490d0Smrg # ...make a list in topmost first order. Use a colon delimited 52965d490d0Smrg # list incase some portion of path contains whitespace. 53065d490d0Smrg my_dir_list="$my_directory_path:$my_dir_list" 53165d490d0Smrg 53265d490d0Smrg # If the last portion added has no slash in it, the list is done 53365d490d0Smrg case $my_directory_path in */*) ;; *) break ;; esac 53465d490d0Smrg 53565d490d0Smrg # ...otherwise throw away the child directory and loop 53665d490d0Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 53765d490d0Smrg done 53865d490d0Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 53965d490d0Smrg 54065d490d0Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 54165d490d0Smrg for my_dir in $my_dir_list; do 54265d490d0Smrg IFS="$save_mkdir_p_IFS" 54365d490d0Smrg # mkdir can fail with a `File exist' error if two processes 54465d490d0Smrg # try to create one of the directories concurrently. Don't 54565d490d0Smrg # stop in that case! 54665d490d0Smrg $MKDIR "$my_dir" 2>/dev/null || : 54765d490d0Smrg done 54865d490d0Smrg IFS="$save_mkdir_p_IFS" 54965d490d0Smrg 55065d490d0Smrg # Bail out if we (or some other process) failed to create a directory. 55165d490d0Smrg test -d "$my_directory_path" || \ 55265d490d0Smrg func_fatal_error "Failed to create \`$1'" 55365d490d0Smrg fi 55465d490d0Smrg} 555e4da13eeSmacallan 556e4da13eeSmacallan 557e4da13eeSmacallan# func_mktempdir [string] 558e4da13eeSmacallan# Make a temporary directory that won't clash with other running 559e4da13eeSmacallan# libtool processes, and avoids race conditions if possible. If 560e4da13eeSmacallan# given, STRING is the basename for that directory. 561e4da13eeSmacallanfunc_mktempdir () 562e4da13eeSmacallan{ 563e4da13eeSmacallan my_template="${TMPDIR-/tmp}/${1-$progname}" 564e4da13eeSmacallan 56565d490d0Smrg if test "$opt_dry_run" = ":"; then 566e4da13eeSmacallan # Return a directory name, but don't create it in dry-run mode 567e4da13eeSmacallan my_tmpdir="${my_template}-$$" 568e4da13eeSmacallan else 569e4da13eeSmacallan 570e4da13eeSmacallan # If mktemp works, use that first and foremost 571e4da13eeSmacallan my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 572e4da13eeSmacallan 573e4da13eeSmacallan if test ! -d "$my_tmpdir"; then 57465d490d0Smrg # Failing that, at least try and use $RANDOM to avoid a race 57565d490d0Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 576e4da13eeSmacallan 57765d490d0Smrg save_mktempdir_umask=`umask` 57865d490d0Smrg umask 0077 57965d490d0Smrg $MKDIR "$my_tmpdir" 58065d490d0Smrg umask $save_mktempdir_umask 581e4da13eeSmacallan fi 582e4da13eeSmacallan 583e4da13eeSmacallan # If we're not in dry-run mode, bomb out on failure 58465d490d0Smrg test -d "$my_tmpdir" || \ 58565d490d0Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 586e4da13eeSmacallan fi 587e4da13eeSmacallan 58865d490d0Smrg $ECHO "$my_tmpdir" 589e4da13eeSmacallan} 590e4da13eeSmacallan 591e4da13eeSmacallan 59265d490d0Smrg# func_quote_for_eval arg 59365d490d0Smrg# Aesthetically quote ARG to be evaled later. 59465d490d0Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 59565d490d0Smrg# is double-quoted, suitable for a subsequent eval, whereas 59665d490d0Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 59765d490d0Smrg# which are still active within double quotes backslashified. 59865d490d0Smrgfunc_quote_for_eval () 599e4da13eeSmacallan{ 60065d490d0Smrg case $1 in 60165d490d0Smrg *[\\\`\"\$]*) 60265d490d0Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 60365d490d0Smrg *) 60465d490d0Smrg func_quote_for_eval_unquoted_result="$1" ;; 60565d490d0Smrg esac 60665d490d0Smrg 60765d490d0Smrg case $func_quote_for_eval_unquoted_result in 60865d490d0Smrg # Double-quote args containing shell metacharacters to delay 60965d490d0Smrg # word splitting, command substitution and and variable 61065d490d0Smrg # expansion for a subsequent eval. 61165d490d0Smrg # Many Bourne shells cannot handle close brackets correctly 61265d490d0Smrg # in scan sets, so we specify it separately. 61365d490d0Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 61465d490d0Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 61565d490d0Smrg ;; 61665d490d0Smrg *) 61765d490d0Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 61865d490d0Smrg esac 61965d490d0Smrg} 62065d490d0Smrg 62165d490d0Smrg 62265d490d0Smrg# func_quote_for_expand arg 62365d490d0Smrg# Aesthetically quote ARG to be evaled later; same as above, 62465d490d0Smrg# but do not quote variable references. 62565d490d0Smrgfunc_quote_for_expand () 62665d490d0Smrg{ 62765d490d0Smrg case $1 in 62865d490d0Smrg *[\\\`\"]*) 62965d490d0Smrg my_arg=`$ECHO "$1" | $SED \ 63065d490d0Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 63165d490d0Smrg *) 63265d490d0Smrg my_arg="$1" ;; 63365d490d0Smrg esac 63465d490d0Smrg 63565d490d0Smrg case $my_arg in 63665d490d0Smrg # Double-quote args containing shell metacharacters to delay 63765d490d0Smrg # word splitting and command substitution for a subsequent eval. 63865d490d0Smrg # Many Bourne shells cannot handle close brackets correctly 63965d490d0Smrg # in scan sets, so we specify it separately. 64065d490d0Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 64165d490d0Smrg my_arg="\"$my_arg\"" 64265d490d0Smrg ;; 64365d490d0Smrg esac 64465d490d0Smrg 64565d490d0Smrg func_quote_for_expand_result="$my_arg" 64665d490d0Smrg} 64765d490d0Smrg 64865d490d0Smrg 64965d490d0Smrg# func_show_eval cmd [fail_exp] 65065d490d0Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 65165d490d0Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 65265d490d0Smrg# is given, then evaluate it. 65365d490d0Smrgfunc_show_eval () 65465d490d0Smrg{ 65565d490d0Smrg my_cmd="$1" 65665d490d0Smrg my_fail_exp="${2-:}" 65765d490d0Smrg 65865d490d0Smrg ${opt_silent-false} || { 65965d490d0Smrg func_quote_for_expand "$my_cmd" 66065d490d0Smrg eval "func_echo $func_quote_for_expand_result" 66165d490d0Smrg } 66265d490d0Smrg 66365d490d0Smrg if ${opt_dry_run-false}; then :; else 66465d490d0Smrg eval "$my_cmd" 66565d490d0Smrg my_status=$? 66665d490d0Smrg if test "$my_status" -eq 0; then :; else 66765d490d0Smrg eval "(exit $my_status); $my_fail_exp" 66865d490d0Smrg fi 669e4da13eeSmacallan fi 67065d490d0Smrg} 67165d490d0Smrg 67265d490d0Smrg 67365d490d0Smrg# func_show_eval_locale cmd [fail_exp] 67465d490d0Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 67565d490d0Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 67665d490d0Smrg# is given, then evaluate it. Use the saved locale for evaluation. 67765d490d0Smrgfunc_show_eval_locale () 67865d490d0Smrg{ 67965d490d0Smrg my_cmd="$1" 68065d490d0Smrg my_fail_exp="${2-:}" 68165d490d0Smrg 68265d490d0Smrg ${opt_silent-false} || { 68365d490d0Smrg func_quote_for_expand "$my_cmd" 68465d490d0Smrg eval "func_echo $func_quote_for_expand_result" 68565d490d0Smrg } 68665d490d0Smrg 68765d490d0Smrg if ${opt_dry_run-false}; then :; else 68865d490d0Smrg eval "$lt_user_locale 68965d490d0Smrg $my_cmd" 69065d490d0Smrg my_status=$? 69165d490d0Smrg eval "$lt_safe_locale" 69265d490d0Smrg if test "$my_status" -eq 0; then :; else 69365d490d0Smrg eval "(exit $my_status); $my_fail_exp" 69465d490d0Smrg fi 69565d490d0Smrg fi 69665d490d0Smrg} 69765d490d0Smrg 69865d490d0Smrg# func_tr_sh 69965d490d0Smrg# Turn $1 into a string suitable for a shell variable name. 70065d490d0Smrg# Result is stored in $func_tr_sh_result. All characters 70165d490d0Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 70265d490d0Smrg# if $1 begins with a digit, a '_' is prepended as well. 70365d490d0Smrgfunc_tr_sh () 70465d490d0Smrg{ 70565d490d0Smrg case $1 in 70665d490d0Smrg [0-9]* | *[!a-zA-Z0-9_]*) 70765d490d0Smrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 708e4da13eeSmacallan ;; 70965d490d0Smrg * ) 71065d490d0Smrg func_tr_sh_result=$1 711e4da13eeSmacallan ;; 712e4da13eeSmacallan esac 713e4da13eeSmacallan} 714e4da13eeSmacallan 715e4da13eeSmacallan 71665d490d0Smrg# func_version 71765d490d0Smrg# Echo version message to standard output and exit. 71865d490d0Smrgfunc_version () 719e4da13eeSmacallan{ 72065d490d0Smrg $opt_debug 72165d490d0Smrg 72265d490d0Smrg $SED -n '/(C)/!b go 72365d490d0Smrg :more 72465d490d0Smrg /\./!{ 72565d490d0Smrg N 72665d490d0Smrg s/\n# / / 72765d490d0Smrg b more 72865d490d0Smrg } 72965d490d0Smrg :go 73065d490d0Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 73165d490d0Smrg s/^# // 73265d490d0Smrg s/^# *$// 73365d490d0Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 73465d490d0Smrg p 73565d490d0Smrg }' < "$progpath" 73665d490d0Smrg exit $? 737e4da13eeSmacallan} 738e4da13eeSmacallan 73965d490d0Smrg# func_usage 74065d490d0Smrg# Echo short help message to standard output and exit. 74165d490d0Smrgfunc_usage () 742e4da13eeSmacallan{ 74365d490d0Smrg $opt_debug 74465d490d0Smrg 74565d490d0Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 74665d490d0Smrg s/^# // 74765d490d0Smrg s/^# *$// 74865d490d0Smrg s/\$progname/'$progname'/ 74965d490d0Smrg p 75065d490d0Smrg }' < "$progpath" 75165d490d0Smrg echo 75265d490d0Smrg $ECHO "run \`$progname --help | more' for full usage" 75365d490d0Smrg exit $? 754e4da13eeSmacallan} 755e4da13eeSmacallan 75665d490d0Smrg# func_help [NOEXIT] 75765d490d0Smrg# Echo long help message to standard output and exit, 75865d490d0Smrg# unless 'noexit' is passed as argument. 75965d490d0Smrgfunc_help () 760e4da13eeSmacallan{ 76165d490d0Smrg $opt_debug 76265d490d0Smrg 76365d490d0Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 76465d490d0Smrg :print 76565d490d0Smrg s/^# // 76665d490d0Smrg s/^# *$// 76765d490d0Smrg s*\$progname*'$progname'* 76865d490d0Smrg s*\$host*'"$host"'* 76965d490d0Smrg s*\$SHELL*'"$SHELL"'* 77065d490d0Smrg s*\$LTCC*'"$LTCC"'* 77165d490d0Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 77265d490d0Smrg s*\$LD*'"$LD"'* 77365d490d0Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 77465d490d0Smrg s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ 77565d490d0Smrg s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ 77665d490d0Smrg p 77765d490d0Smrg d 77865d490d0Smrg } 77965d490d0Smrg /^# .* home page:/b print 78065d490d0Smrg /^# General help using/b print 78165d490d0Smrg ' < "$progpath" 78265d490d0Smrg ret=$? 78365d490d0Smrg if test -z "$1"; then 78465d490d0Smrg exit $ret 785e4da13eeSmacallan fi 78665d490d0Smrg} 787e4da13eeSmacallan 78865d490d0Smrg# func_missing_arg argname 78965d490d0Smrg# Echo program name prefixed message to standard error and set global 79065d490d0Smrg# exit_cmd. 79165d490d0Smrgfunc_missing_arg () 79265d490d0Smrg{ 79365d490d0Smrg $opt_debug 794e4da13eeSmacallan 79565d490d0Smrg func_error "missing argument for $1." 79665d490d0Smrg exit_cmd=exit 797e4da13eeSmacallan} 798e4da13eeSmacallan 799e4da13eeSmacallan 80065d490d0Smrg# func_split_short_opt shortopt 80165d490d0Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 80265d490d0Smrg# variables after splitting SHORTOPT after the 2nd character. 80365d490d0Smrgfunc_split_short_opt () 80465d490d0Smrg{ 80565d490d0Smrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 80665d490d0Smrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 80765d490d0Smrg 80865d490d0Smrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 80965d490d0Smrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 81065d490d0Smrg} # func_split_short_opt may be replaced by extended shell implementation 811e4da13eeSmacallan 812e4da13eeSmacallan 81365d490d0Smrg# func_split_long_opt longopt 81465d490d0Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 81565d490d0Smrg# variables after splitting LONGOPT at the `=' sign. 81665d490d0Smrgfunc_split_long_opt () 81765d490d0Smrg{ 81865d490d0Smrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 81965d490d0Smrg my_sed_long_arg='1s/^--[^=]*=//' 820e4da13eeSmacallan 82165d490d0Smrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 82265d490d0Smrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 82365d490d0Smrg} # func_split_long_opt may be replaced by extended shell implementation 824e4da13eeSmacallan 82565d490d0Smrgexit_cmd=: 826e4da13eeSmacallan 827e4da13eeSmacallan 828e4da13eeSmacallan 829e4da13eeSmacallan 830e4da13eeSmacallan 83165d490d0Smrgmagic="%%%MAGIC variable%%%" 83265d490d0Smrgmagic_exe="%%%MAGIC EXE variable%%%" 83365d490d0Smrg 83465d490d0Smrg# Global variables. 83565d490d0Smrgnonopt= 83665d490d0Smrgpreserve_args= 83765d490d0Smrglo2o="s/\\.lo\$/.${objext}/" 83865d490d0Smrgo2lo="s/\\.${objext}\$/.lo/" 83965d490d0Smrgextracted_archives= 84065d490d0Smrgextracted_serial=0 84165d490d0Smrg 84265d490d0Smrg# If this variable is set in any of the actions, the command in it 84365d490d0Smrg# will be execed at the end. This prevents here-documents from being 84465d490d0Smrg# left over by shells. 84565d490d0Smrgexec_cmd= 84665d490d0Smrg 84765d490d0Smrg# func_append var value 84865d490d0Smrg# Append VALUE to the end of shell variable VAR. 84965d490d0Smrgfunc_append () 85065d490d0Smrg{ 85165d490d0Smrg eval "${1}=\$${1}\${2}" 85265d490d0Smrg} # func_append may be replaced by extended shell implementation 85365d490d0Smrg 85465d490d0Smrg# func_append_quoted var value 85565d490d0Smrg# Quote VALUE and append to the end of shell variable VAR, separated 85665d490d0Smrg# by a space. 85765d490d0Smrgfunc_append_quoted () 85865d490d0Smrg{ 85965d490d0Smrg func_quote_for_eval "${2}" 86065d490d0Smrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 86165d490d0Smrg} # func_append_quoted may be replaced by extended shell implementation 86265d490d0Smrg 86365d490d0Smrg 86465d490d0Smrg# func_arith arithmetic-term... 86565d490d0Smrgfunc_arith () 86665d490d0Smrg{ 86765d490d0Smrg func_arith_result=`expr "${@}"` 86865d490d0Smrg} # func_arith may be replaced by extended shell implementation 86965d490d0Smrg 87065d490d0Smrg 87165d490d0Smrg# func_len string 87265d490d0Smrg# STRING may not start with a hyphen. 87365d490d0Smrgfunc_len () 87465d490d0Smrg{ 87565d490d0Smrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 87665d490d0Smrg} # func_len may be replaced by extended shell implementation 87765d490d0Smrg 87865d490d0Smrg 87965d490d0Smrg# func_lo2o object 88065d490d0Smrgfunc_lo2o () 88165d490d0Smrg{ 88265d490d0Smrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 88365d490d0Smrg} # func_lo2o may be replaced by extended shell implementation 88465d490d0Smrg 88565d490d0Smrg 88665d490d0Smrg# func_xform libobj-or-source 88765d490d0Smrgfunc_xform () 88865d490d0Smrg{ 88965d490d0Smrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 89065d490d0Smrg} # func_xform may be replaced by extended shell implementation 89165d490d0Smrg 89265d490d0Smrg 89365d490d0Smrg# func_fatal_configuration arg... 89465d490d0Smrg# Echo program name prefixed message to standard error, followed by 89565d490d0Smrg# a configuration failure hint, and exit. 89665d490d0Smrgfunc_fatal_configuration () 89765d490d0Smrg{ 89865d490d0Smrg func_error ${1+"$@"} 89965d490d0Smrg func_error "See the $PACKAGE documentation for more information." 90065d490d0Smrg func_fatal_error "Fatal configuration error." 90165d490d0Smrg} 90265d490d0Smrg 90365d490d0Smrg 90465d490d0Smrg# func_config 90565d490d0Smrg# Display the configuration for all the tags in this script. 90665d490d0Smrgfunc_config () 90765d490d0Smrg{ 90865d490d0Smrg re_begincf='^# ### BEGIN LIBTOOL' 90965d490d0Smrg re_endcf='^# ### END LIBTOOL' 91065d490d0Smrg 91165d490d0Smrg # Default configuration. 91265d490d0Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 91365d490d0Smrg 914e4da13eeSmacallan # Now print the configurations for the tags. 915e4da13eeSmacallan for tagname in $taglist; do 91665d490d0Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 917e4da13eeSmacallan done 918e4da13eeSmacallan 91965d490d0Smrg exit $? 92065d490d0Smrg} 921e4da13eeSmacallan 92265d490d0Smrg# func_features 92365d490d0Smrg# Display the features supported by this script. 92465d490d0Smrgfunc_features () 92565d490d0Smrg{ 92665d490d0Smrg echo "host: $host" 927e4da13eeSmacallan if test "$build_libtool_libs" = yes; then 92865d490d0Smrg echo "enable shared libraries" 929e4da13eeSmacallan else 93065d490d0Smrg echo "disable shared libraries" 931e4da13eeSmacallan fi 932e4da13eeSmacallan if test "$build_old_libs" = yes; then 93365d490d0Smrg echo "enable static libraries" 934e4da13eeSmacallan else 93565d490d0Smrg echo "disable static libraries" 936e4da13eeSmacallan fi 937e4da13eeSmacallan 93865d490d0Smrg exit $? 93965d490d0Smrg} 940e4da13eeSmacallan 94165d490d0Smrg# func_enable_tag tagname 94265d490d0Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 94365d490d0Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 94465d490d0Smrg# variable here. 94565d490d0Smrgfunc_enable_tag () 94665d490d0Smrg{ 94765d490d0Smrg # Global variable: 94865d490d0Smrg tagname="$1" 949e4da13eeSmacallan 95065d490d0Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 95165d490d0Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 95265d490d0Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 953e4da13eeSmacallan 95465d490d0Smrg # Validate tagname. 95565d490d0Smrg case $tagname in 95665d490d0Smrg *[!-_A-Za-z0-9,/]*) 95765d490d0Smrg func_fatal_error "invalid tag name: $tagname" 95865d490d0Smrg ;; 95965d490d0Smrg esac 960e4da13eeSmacallan 96165d490d0Smrg # Don't test for the "default" C tag, as we know it's 96265d490d0Smrg # there but not specially marked. 96365d490d0Smrg case $tagname in 96465d490d0Smrg CC) ;; 96565d490d0Smrg *) 96665d490d0Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 96765d490d0Smrg taglist="$taglist $tagname" 96865d490d0Smrg 96965d490d0Smrg # Evaluate the configuration. Be careful to quote the path 97065d490d0Smrg # and the sed script, to avoid splitting on whitespace, but 97165d490d0Smrg # also don't use non-portable quotes within backquotes within 97265d490d0Smrg # quotes we have to do it in 2 steps: 97365d490d0Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 97465d490d0Smrg eval "$extractedcf" 97565d490d0Smrg else 97665d490d0Smrg func_error "ignoring unknown tag $tagname" 97765d490d0Smrg fi 97865d490d0Smrg ;; 97965d490d0Smrg esac 98065d490d0Smrg} 981e4da13eeSmacallan 98265d490d0Smrg# func_check_version_match 98365d490d0Smrg# Ensure that we are using m4 macros, and libtool script from the same 98465d490d0Smrg# release of libtool. 98565d490d0Smrgfunc_check_version_match () 98665d490d0Smrg{ 98765d490d0Smrg if test "$package_revision" != "$macro_revision"; then 98865d490d0Smrg if test "$VERSION" != "$macro_version"; then 98965d490d0Smrg if test -z "$macro_version"; then 99065d490d0Smrg cat >&2 <<_LT_EOF 99165d490d0Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 99265d490d0Smrg$progname: definition of this LT_INIT comes from an older release. 99365d490d0Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 99465d490d0Smrg$progname: and run autoconf again. 99565d490d0Smrg_LT_EOF 99665d490d0Smrg else 99765d490d0Smrg cat >&2 <<_LT_EOF 99865d490d0Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 99965d490d0Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 100065d490d0Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 100165d490d0Smrg$progname: and run autoconf again. 100265d490d0Smrg_LT_EOF 100365d490d0Smrg fi 100465d490d0Smrg else 100565d490d0Smrg cat >&2 <<_LT_EOF 100665d490d0Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 100765d490d0Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 100865d490d0Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 100965d490d0Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 101065d490d0Smrg_LT_EOF 101165d490d0Smrg fi 1012e4da13eeSmacallan 101365d490d0Smrg exit $EXIT_MISMATCH 101465d490d0Smrg fi 101565d490d0Smrg} 1016e4da13eeSmacallan 1017e4da13eeSmacallan 101865d490d0Smrg# Shorthand for --mode=foo, only valid as the first argument 101965d490d0Smrgcase $1 in 102065d490d0Smrgclean|clea|cle|cl) 102165d490d0Smrg shift; set dummy --mode clean ${1+"$@"}; shift 102265d490d0Smrg ;; 102365d490d0Smrgcompile|compil|compi|comp|com|co|c) 102465d490d0Smrg shift; set dummy --mode compile ${1+"$@"}; shift 102565d490d0Smrg ;; 102665d490d0Smrgexecute|execut|execu|exec|exe|ex|e) 102765d490d0Smrg shift; set dummy --mode execute ${1+"$@"}; shift 102865d490d0Smrg ;; 102965d490d0Smrgfinish|finis|fini|fin|fi|f) 103065d490d0Smrg shift; set dummy --mode finish ${1+"$@"}; shift 1031e4da13eeSmacallan ;; 103265d490d0Smrginstall|instal|insta|inst|ins|in|i) 103365d490d0Smrg shift; set dummy --mode install ${1+"$@"}; shift 1034e4da13eeSmacallan ;; 103565d490d0Smrglink|lin|li|l) 103665d490d0Smrg shift; set dummy --mode link ${1+"$@"}; shift 103765d490d0Smrg ;; 103865d490d0Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 103965d490d0Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 1040e4da13eeSmacallan ;; 1041e4da13eeSmacallanesac 1042e4da13eeSmacallan 1043e4da13eeSmacallan 1044e4da13eeSmacallan 104565d490d0Smrg# Option defaults: 104665d490d0Smrgopt_debug=: 104765d490d0Smrgopt_dry_run=false 104865d490d0Smrgopt_config=false 104965d490d0Smrgopt_preserve_dup_deps=false 105065d490d0Smrgopt_features=false 105165d490d0Smrgopt_finish=false 105265d490d0Smrgopt_help=false 105365d490d0Smrgopt_help_all=false 105465d490d0Smrgopt_silent=: 105565d490d0Smrgopt_verbose=: 105665d490d0Smrgopt_silent=false 105765d490d0Smrgopt_verbose=false 1058e4da13eeSmacallan 105965d490d0Smrg 106065d490d0Smrg# Parse options once, thoroughly. This comes as soon as possible in the 106165d490d0Smrg# script to make things like `--version' happen as quickly as we can. 106265d490d0Smrg{ 106365d490d0Smrg # this just eases exit handling 106465d490d0Smrg while test $# -gt 0; do 106565d490d0Smrg opt="$1" 106665d490d0Smrg shift 106765d490d0Smrg case $opt in 106865d490d0Smrg --debug|-x) opt_debug='set -x' 106965d490d0Smrg func_echo "enabling shell trace mode" 107065d490d0Smrg $opt_debug 107165d490d0Smrg ;; 107265d490d0Smrg --dry-run|--dryrun|-n) 107365d490d0Smrg opt_dry_run=: 107465d490d0Smrg ;; 107565d490d0Smrg --config) 107665d490d0Smrg opt_config=: 107765d490d0Smrgfunc_config 107865d490d0Smrg ;; 107965d490d0Smrg --dlopen|-dlopen) 108065d490d0Smrg optarg="$1" 108165d490d0Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 108265d490d0Smrg}$optarg" 108365d490d0Smrg shift 108465d490d0Smrg ;; 108565d490d0Smrg --preserve-dup-deps) 108665d490d0Smrg opt_preserve_dup_deps=: 108765d490d0Smrg ;; 108865d490d0Smrg --features) 108965d490d0Smrg opt_features=: 109065d490d0Smrgfunc_features 109165d490d0Smrg ;; 109265d490d0Smrg --finish) 109365d490d0Smrg opt_finish=: 109465d490d0Smrgset dummy --mode finish ${1+"$@"}; shift 109565d490d0Smrg ;; 109665d490d0Smrg --help) 109765d490d0Smrg opt_help=: 109865d490d0Smrg ;; 109965d490d0Smrg --help-all) 110065d490d0Smrg opt_help_all=: 110165d490d0Smrgopt_help=': help-all' 110265d490d0Smrg ;; 110365d490d0Smrg --mode) 110465d490d0Smrg test $# = 0 && func_missing_arg $opt && break 110565d490d0Smrg optarg="$1" 110665d490d0Smrg opt_mode="$optarg" 110765d490d0Smrgcase $optarg in 110865d490d0Smrg # Valid mode arguments: 110965d490d0Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 111065d490d0Smrg 111165d490d0Smrg # Catch anything else as an error 111265d490d0Smrg *) func_error "invalid argument for $opt" 111365d490d0Smrg exit_cmd=exit 111465d490d0Smrg break 111565d490d0Smrg ;; 111665d490d0Smrgesac 111765d490d0Smrg shift 111865d490d0Smrg ;; 111965d490d0Smrg --no-silent|--no-quiet) 112065d490d0Smrg opt_silent=false 112165d490d0Smrgfunc_append preserve_args " $opt" 112265d490d0Smrg ;; 112365d490d0Smrg --no-verbose) 112465d490d0Smrg opt_verbose=false 112565d490d0Smrgfunc_append preserve_args " $opt" 112665d490d0Smrg ;; 112765d490d0Smrg --silent|--quiet) 112865d490d0Smrg opt_silent=: 112965d490d0Smrgfunc_append preserve_args " $opt" 113065d490d0Smrg opt_verbose=false 113165d490d0Smrg ;; 113265d490d0Smrg --verbose|-v) 113365d490d0Smrg opt_verbose=: 113465d490d0Smrgfunc_append preserve_args " $opt" 113565d490d0Smrgopt_silent=false 113665d490d0Smrg ;; 113765d490d0Smrg --tag) 113865d490d0Smrg test $# = 0 && func_missing_arg $opt && break 113965d490d0Smrg optarg="$1" 114065d490d0Smrg opt_tag="$optarg" 114165d490d0Smrgfunc_append preserve_args " $opt $optarg" 114265d490d0Smrgfunc_enable_tag "$optarg" 114365d490d0Smrg shift 114465d490d0Smrg ;; 114565d490d0Smrg 114665d490d0Smrg -\?|-h) func_usage ;; 114765d490d0Smrg --help) func_help ;; 114865d490d0Smrg --version) func_version ;; 114965d490d0Smrg 115065d490d0Smrg # Separate optargs to long options: 115165d490d0Smrg --*=*) 115265d490d0Smrg func_split_long_opt "$opt" 115365d490d0Smrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 115465d490d0Smrg shift 115565d490d0Smrg ;; 115665d490d0Smrg 115765d490d0Smrg # Separate non-argument short options: 115865d490d0Smrg -\?*|-h*|-n*|-v*) 115965d490d0Smrg func_split_short_opt "$opt" 116065d490d0Smrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 116165d490d0Smrg shift 116265d490d0Smrg ;; 116365d490d0Smrg 116465d490d0Smrg --) break ;; 116565d490d0Smrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 116665d490d0Smrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 1167e4da13eeSmacallan esac 116865d490d0Smrg done 1169e4da13eeSmacallan 117065d490d0Smrg # Validate options: 117165d490d0Smrg 117265d490d0Smrg # save first non-option argument 117365d490d0Smrg if test "$#" -gt 0; then 117465d490d0Smrg nonopt="$opt" 117565d490d0Smrg shift 1176e4da13eeSmacallan fi 1177e4da13eeSmacallan 117865d490d0Smrg # preserve --debug 117965d490d0Smrg test "$opt_debug" = : || func_append preserve_args " --debug" 1180e4da13eeSmacallan 118165d490d0Smrg case $host in 118265d490d0Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 118365d490d0Smrg # don't eliminate duplications in $postdeps and $predeps 118465d490d0Smrg opt_duplicate_compiler_generated_deps=: 118565d490d0Smrg ;; 118665d490d0Smrg *) 118765d490d0Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 118865d490d0Smrg ;; 118965d490d0Smrg esac 1190e4da13eeSmacallan 119165d490d0Smrg $opt_help || { 119265d490d0Smrg # Sanity checks first: 119365d490d0Smrg func_check_version_match 1194e4da13eeSmacallan 119565d490d0Smrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 119665d490d0Smrg func_fatal_configuration "not configured to build any kind of library" 119765d490d0Smrg fi 1198e4da13eeSmacallan 119965d490d0Smrg # Darwin sucks 120065d490d0Smrg eval std_shrext=\"$shrext_cmds\" 1201e4da13eeSmacallan 120265d490d0Smrg # Only execute mode is allowed to have -dlopen flags. 120365d490d0Smrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 120465d490d0Smrg func_error "unrecognized option \`-dlopen'" 120565d490d0Smrg $ECHO "$help" 1>&2 120665d490d0Smrg exit $EXIT_FAILURE 120765d490d0Smrg fi 1208e4da13eeSmacallan 120965d490d0Smrg # Change the help message to a mode-specific one. 121065d490d0Smrg generic_help="$help" 121165d490d0Smrg help="Try \`$progname --help --mode=$opt_mode' for more information." 121265d490d0Smrg } 1213e4da13eeSmacallan 1214e4da13eeSmacallan 121565d490d0Smrg # Bail if the options were screwed 121665d490d0Smrg $exit_cmd $EXIT_FAILURE 121765d490d0Smrg} 1218e4da13eeSmacallan 1219e4da13eeSmacallan 1220e4da13eeSmacallan 1221e4da13eeSmacallan 122265d490d0Smrg## ----------- ## 122365d490d0Smrg## Main. ## 122465d490d0Smrg## ----------- ## 1225e4da13eeSmacallan 122665d490d0Smrg# func_lalib_p file 122765d490d0Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 122865d490d0Smrg# This function is only a basic sanity check; it will hardly flush out 122965d490d0Smrg# determined imposters. 123065d490d0Smrgfunc_lalib_p () 123165d490d0Smrg{ 123265d490d0Smrg test -f "$1" && 123365d490d0Smrg $SED -e 4q "$1" 2>/dev/null \ 123465d490d0Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 123565d490d0Smrg} 1236e4da13eeSmacallan 123765d490d0Smrg# func_lalib_unsafe_p file 123865d490d0Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 123965d490d0Smrg# This function implements the same check as func_lalib_p without 124065d490d0Smrg# resorting to external programs. To this end, it redirects stdin and 124165d490d0Smrg# closes it afterwards, without saving the original file descriptor. 124265d490d0Smrg# As a safety measure, use it only where a negative result would be 124365d490d0Smrg# fatal anyway. Works if `file' does not exist. 124465d490d0Smrgfunc_lalib_unsafe_p () 124565d490d0Smrg{ 124665d490d0Smrg lalib_p=no 124765d490d0Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 124865d490d0Smrg for lalib_p_l in 1 2 3 4 124965d490d0Smrg do 125065d490d0Smrg read lalib_p_line 125165d490d0Smrg case "$lalib_p_line" in 125265d490d0Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 125365d490d0Smrg esac 125465d490d0Smrg done 125565d490d0Smrg exec 0<&5 5<&- 125665d490d0Smrg fi 125765d490d0Smrg test "$lalib_p" = yes 125865d490d0Smrg} 1259e4da13eeSmacallan 126065d490d0Smrg# func_ltwrapper_script_p file 126165d490d0Smrg# True iff FILE is a libtool wrapper script 126265d490d0Smrg# This function is only a basic sanity check; it will hardly flush out 126365d490d0Smrg# determined imposters. 126465d490d0Smrgfunc_ltwrapper_script_p () 126565d490d0Smrg{ 126665d490d0Smrg func_lalib_p "$1" 126765d490d0Smrg} 1268e4da13eeSmacallan 126965d490d0Smrg# func_ltwrapper_executable_p file 127065d490d0Smrg# True iff FILE is a libtool wrapper executable 127165d490d0Smrg# This function is only a basic sanity check; it will hardly flush out 127265d490d0Smrg# determined imposters. 127365d490d0Smrgfunc_ltwrapper_executable_p () 127465d490d0Smrg{ 127565d490d0Smrg func_ltwrapper_exec_suffix= 127665d490d0Smrg case $1 in 127765d490d0Smrg *.exe) ;; 127865d490d0Smrg *) func_ltwrapper_exec_suffix=.exe ;; 1279e4da13eeSmacallan esac 128065d490d0Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 128165d490d0Smrg} 1282e4da13eeSmacallan 128365d490d0Smrg# func_ltwrapper_scriptname file 128465d490d0Smrg# Assumes file is an ltwrapper_executable 128565d490d0Smrg# uses $file to determine the appropriate filename for a 128665d490d0Smrg# temporary ltwrapper_script. 128765d490d0Smrgfunc_ltwrapper_scriptname () 128865d490d0Smrg{ 128965d490d0Smrg func_dirname_and_basename "$1" "" "." 129065d490d0Smrg func_stripname '' '.exe' "$func_basename_result" 129165d490d0Smrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 129265d490d0Smrg} 1293e4da13eeSmacallan 129465d490d0Smrg# func_ltwrapper_p file 129565d490d0Smrg# True iff FILE is a libtool wrapper script or wrapper executable 129665d490d0Smrg# This function is only a basic sanity check; it will hardly flush out 129765d490d0Smrg# determined imposters. 129865d490d0Smrgfunc_ltwrapper_p () 129965d490d0Smrg{ 130065d490d0Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 130165d490d0Smrg} 1302e4da13eeSmacallan 1303e4da13eeSmacallan 130465d490d0Smrg# func_execute_cmds commands fail_cmd 130565d490d0Smrg# Execute tilde-delimited COMMANDS. 130665d490d0Smrg# If FAIL_CMD is given, eval that upon failure. 130765d490d0Smrg# FAIL_CMD may read-access the current command in variable CMD! 130865d490d0Smrgfunc_execute_cmds () 130965d490d0Smrg{ 131065d490d0Smrg $opt_debug 131165d490d0Smrg save_ifs=$IFS; IFS='~' 131265d490d0Smrg for cmd in $1; do 131365d490d0Smrg IFS=$save_ifs 131465d490d0Smrg eval cmd=\"$cmd\" 131565d490d0Smrg func_show_eval "$cmd" "${2-:}" 1316e4da13eeSmacallan done 131765d490d0Smrg IFS=$save_ifs 131865d490d0Smrg} 1319e4da13eeSmacallan 1320e4da13eeSmacallan 132165d490d0Smrg# func_source file 132265d490d0Smrg# Source FILE, adding directory component if necessary. 132365d490d0Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 132465d490d0Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 132565d490d0Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 132665d490d0Smrg# `FILE.' does not work on cygwin managed mounts. 132765d490d0Smrgfunc_source () 132865d490d0Smrg{ 132965d490d0Smrg $opt_debug 133065d490d0Smrg case $1 in 133165d490d0Smrg */* | *\\*) . "$1" ;; 133265d490d0Smrg *) . "./$1" ;; 133365d490d0Smrg esac 133465d490d0Smrg} 1335e4da13eeSmacallan 1336e4da13eeSmacallan 133765d490d0Smrg# func_resolve_sysroot PATH 133865d490d0Smrg# Replace a leading = in PATH with a sysroot. Store the result into 133965d490d0Smrg# func_resolve_sysroot_result 134065d490d0Smrgfunc_resolve_sysroot () 134165d490d0Smrg{ 134265d490d0Smrg func_resolve_sysroot_result=$1 134365d490d0Smrg case $func_resolve_sysroot_result in 134465d490d0Smrg =*) 134565d490d0Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 134665d490d0Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 134765d490d0Smrg ;; 134865d490d0Smrg esac 134965d490d0Smrg} 1350e4da13eeSmacallan 135165d490d0Smrg# func_replace_sysroot PATH 135265d490d0Smrg# If PATH begins with the sysroot, replace it with = and 135365d490d0Smrg# store the result into func_replace_sysroot_result. 135465d490d0Smrgfunc_replace_sysroot () 135565d490d0Smrg{ 135665d490d0Smrg case "$lt_sysroot:$1" in 135765d490d0Smrg ?*:"$lt_sysroot"*) 135865d490d0Smrg func_stripname "$lt_sysroot" '' "$1" 135965d490d0Smrg func_replace_sysroot_result="=$func_stripname_result" 136065d490d0Smrg ;; 136165d490d0Smrg *) 136265d490d0Smrg # Including no sysroot. 136365d490d0Smrg func_replace_sysroot_result=$1 136465d490d0Smrg ;; 136565d490d0Smrg esac 136665d490d0Smrg} 1367e4da13eeSmacallan 136865d490d0Smrg# func_infer_tag arg 136965d490d0Smrg# Infer tagged configuration to use if any are available and 137065d490d0Smrg# if one wasn't chosen via the "--tag" command line option. 137165d490d0Smrg# Only attempt this if the compiler in the base compile 137265d490d0Smrg# command doesn't match the default compiler. 137365d490d0Smrg# arg is usually of the form 'gcc ...' 137465d490d0Smrgfunc_infer_tag () 137565d490d0Smrg{ 137665d490d0Smrg $opt_debug 137765d490d0Smrg if test -n "$available_tags" && test -z "$tagname"; then 137865d490d0Smrg CC_quoted= 137965d490d0Smrg for arg in $CC; do 138065d490d0Smrg func_append_quoted CC_quoted "$arg" 138165d490d0Smrg done 138265d490d0Smrg CC_expanded=`func_echo_all $CC` 138365d490d0Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 138465d490d0Smrg case $@ in 138565d490d0Smrg # Blanks in the command may have been stripped by the calling shell, 138665d490d0Smrg # but not from the CC environment variable when configure was run. 138765d490d0Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 138865d490d0Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 138965d490d0Smrg # Blanks at the start of $base_compile will cause this to fail 139065d490d0Smrg # if we don't check for them as well. 139165d490d0Smrg *) 139265d490d0Smrg for z in $available_tags; do 139365d490d0Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 139465d490d0Smrg # Evaluate the configuration. 139565d490d0Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 139665d490d0Smrg CC_quoted= 139765d490d0Smrg for arg in $CC; do 139865d490d0Smrg # Double-quote args containing other shell metacharacters. 139965d490d0Smrg func_append_quoted CC_quoted "$arg" 140065d490d0Smrg done 140165d490d0Smrg CC_expanded=`func_echo_all $CC` 140265d490d0Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 140365d490d0Smrg case "$@ " in 140465d490d0Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 140565d490d0Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 140665d490d0Smrg # The compiler in the base compile command matches 140765d490d0Smrg # the one in the tagged configuration. 140865d490d0Smrg # Assume this is the tagged configuration we want. 140965d490d0Smrg tagname=$z 141065d490d0Smrg break 141165d490d0Smrg ;; 141265d490d0Smrg esac 141365d490d0Smrg fi 141465d490d0Smrg done 141565d490d0Smrg # If $tagname still isn't set, then no tagged configuration 141665d490d0Smrg # was found and let the user know that the "--tag" command 141765d490d0Smrg # line option must be used. 141865d490d0Smrg if test -z "$tagname"; then 141965d490d0Smrg func_echo "unable to infer tagged configuration" 142065d490d0Smrg func_fatal_error "specify a tag with \`--tag'" 142165d490d0Smrg# else 142265d490d0Smrg# func_verbose "using $tagname tagged configuration" 142365d490d0Smrg fi 142465d490d0Smrg ;; 142565d490d0Smrg esac 1426e4da13eeSmacallan fi 142765d490d0Smrg} 1428e4da13eeSmacallan 1429e4da13eeSmacallan 1430e4da13eeSmacallan 143165d490d0Smrg# func_write_libtool_object output_name pic_name nonpic_name 143265d490d0Smrg# Create a libtool object file (analogous to a ".la" file), 143365d490d0Smrg# but don't create it if we're doing a dry run. 143465d490d0Smrgfunc_write_libtool_object () 143565d490d0Smrg{ 143665d490d0Smrg write_libobj=${1} 143765d490d0Smrg if test "$build_libtool_libs" = yes; then 143865d490d0Smrg write_lobj=\'${2}\' 143965d490d0Smrg else 144065d490d0Smrg write_lobj=none 1441e4da13eeSmacallan fi 1442e4da13eeSmacallan 144365d490d0Smrg if test "$build_old_libs" = yes; then 144465d490d0Smrg write_oldobj=\'${3}\' 144565d490d0Smrg else 144665d490d0Smrg write_oldobj=none 1447e4da13eeSmacallan fi 1448e4da13eeSmacallan 144965d490d0Smrg $opt_dry_run || { 145065d490d0Smrg cat >${write_libobj}T <<EOF 145165d490d0Smrg# $write_libobj - a libtool object file 145265d490d0Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 1453e4da13eeSmacallan# 1454e4da13eeSmacallan# Please DO NOT delete this file! 1455e4da13eeSmacallan# It is necessary for linking the library. 1456e4da13eeSmacallan 1457e4da13eeSmacallan# Name of the PIC object. 145865d490d0Smrgpic_object=$write_lobj 1459e4da13eeSmacallan 146065d490d0Smrg# Name of the non-PIC object 146165d490d0Smrgnon_pic_object=$write_oldobj 1462e4da13eeSmacallan 146365d490d0SmrgEOF 146465d490d0Smrg $MV "${write_libobj}T" "${write_libobj}" 146565d490d0Smrg } 146665d490d0Smrg} 1467e4da13eeSmacallan 1468e4da13eeSmacallan 146965d490d0Smrg################################################## 147065d490d0Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 147165d490d0Smrg################################################## 1472e4da13eeSmacallan 147365d490d0Smrg# func_convert_core_file_wine_to_w32 ARG 147465d490d0Smrg# Helper function used by file name conversion functions when $build is *nix, 147565d490d0Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 147665d490d0Smrg# correctly configured wine environment available, with the winepath program 147765d490d0Smrg# in $build's $PATH. 147865d490d0Smrg# 147965d490d0Smrg# ARG is the $build file name to be converted to w32 format. 148065d490d0Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 148165d490d0Smrg# be empty on error (or when ARG is empty) 148265d490d0Smrgfunc_convert_core_file_wine_to_w32 () 148365d490d0Smrg{ 148465d490d0Smrg $opt_debug 148565d490d0Smrg func_convert_core_file_wine_to_w32_result="$1" 148665d490d0Smrg if test -n "$1"; then 148765d490d0Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 148865d490d0Smrg # are forced to check the contents of stdout. On the other hand, if the 148965d490d0Smrg # command is not found, the shell will set an exit code of 127 and print 149065d490d0Smrg # *an error message* to stdout. So we must check for both error code of 149165d490d0Smrg # zero AND non-empty stdout, which explains the odd construction: 149265d490d0Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 149365d490d0Smrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 149465d490d0Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 149565d490d0Smrg $SED -e "$lt_sed_naive_backslashify"` 149665d490d0Smrg else 149765d490d0Smrg func_convert_core_file_wine_to_w32_result= 149865d490d0Smrg fi 149965d490d0Smrg fi 150065d490d0Smrg} 150165d490d0Smrg# end: func_convert_core_file_wine_to_w32 1502e4da13eeSmacallan 150365d490d0Smrg 150465d490d0Smrg# func_convert_core_path_wine_to_w32 ARG 150565d490d0Smrg# Helper function used by path conversion functions when $build is *nix, and 150665d490d0Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 150765d490d0Smrg# configured wine environment available, with the winepath program in $build's 150865d490d0Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 150965d490d0Smrg# 151065d490d0Smrg# ARG is path to be converted from $build format to win32. 151165d490d0Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 151265d490d0Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 151365d490d0Smrg# are convertible, then the result may be empty. 151465d490d0Smrgfunc_convert_core_path_wine_to_w32 () 151565d490d0Smrg{ 151665d490d0Smrg $opt_debug 151765d490d0Smrg # unfortunately, winepath doesn't convert paths, only file names 151865d490d0Smrg func_convert_core_path_wine_to_w32_result="" 151965d490d0Smrg if test -n "$1"; then 152065d490d0Smrg oldIFS=$IFS 152165d490d0Smrg IFS=: 152265d490d0Smrg for func_convert_core_path_wine_to_w32_f in $1; do 152365d490d0Smrg IFS=$oldIFS 152465d490d0Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 152565d490d0Smrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 152665d490d0Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 152765d490d0Smrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 152865d490d0Smrg else 152965d490d0Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 153065d490d0Smrg fi 1531e4da13eeSmacallan fi 153265d490d0Smrg done 153365d490d0Smrg IFS=$oldIFS 153465d490d0Smrg fi 153565d490d0Smrg} 153665d490d0Smrg# end: func_convert_core_path_wine_to_w32 153765d490d0Smrg 153865d490d0Smrg 153965d490d0Smrg# func_cygpath ARGS... 154065d490d0Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 154165d490d0Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 154265d490d0Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 154365d490d0Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 154465d490d0Smrg# file name or path is assumed to be in w32 format, as previously converted 154565d490d0Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 154665d490d0Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 154765d490d0Smrg# Cygwin format). Returns an empty string on error. 154865d490d0Smrg# 154965d490d0Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 155065d490d0Smrg# be converted. 155165d490d0Smrg# 155265d490d0Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 155365d490d0Smrg# environment variable; do not put it in $PATH. 155465d490d0Smrgfunc_cygpath () 155565d490d0Smrg{ 155665d490d0Smrg $opt_debug 155765d490d0Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 155865d490d0Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 155965d490d0Smrg if test "$?" -ne 0; then 156065d490d0Smrg # on failure, ensure result is empty 156165d490d0Smrg func_cygpath_result= 156265d490d0Smrg fi 156365d490d0Smrg else 156465d490d0Smrg func_cygpath_result= 156565d490d0Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 156665d490d0Smrg fi 156765d490d0Smrg} 156865d490d0Smrg#end: func_cygpath 1569e4da13eeSmacallan 1570e4da13eeSmacallan 157165d490d0Smrg# func_convert_core_msys_to_w32 ARG 157265d490d0Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 157365d490d0Smrg# result in func_convert_core_msys_to_w32_result. 157465d490d0Smrgfunc_convert_core_msys_to_w32 () 157565d490d0Smrg{ 157665d490d0Smrg $opt_debug 157765d490d0Smrg # awkward: cmd appends spaces to result 157865d490d0Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 157965d490d0Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 158065d490d0Smrg} 158165d490d0Smrg#end: func_convert_core_msys_to_w32 1582e4da13eeSmacallan 1583e4da13eeSmacallan 158465d490d0Smrg# func_convert_file_check ARG1 ARG2 158565d490d0Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 158665d490d0Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 158765d490d0Smrg# func_to_host_file_result to ARG1). 158865d490d0Smrgfunc_convert_file_check () 158965d490d0Smrg{ 159065d490d0Smrg $opt_debug 159165d490d0Smrg if test -z "$2" && test -n "$1" ; then 159265d490d0Smrg func_error "Could not determine host file name corresponding to" 159365d490d0Smrg func_error " \`$1'" 159465d490d0Smrg func_error "Continuing, but uninstalled executables may not work." 159565d490d0Smrg # Fallback: 159665d490d0Smrg func_to_host_file_result="$1" 159765d490d0Smrg fi 159865d490d0Smrg} 159965d490d0Smrg# end func_convert_file_check 1600e4da13eeSmacallan 1601e4da13eeSmacallan 160265d490d0Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 160365d490d0Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 160465d490d0Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 160565d490d0Smrg# func_to_host_file_result to a simplistic fallback value (see below). 160665d490d0Smrgfunc_convert_path_check () 160765d490d0Smrg{ 160865d490d0Smrg $opt_debug 160965d490d0Smrg if test -z "$4" && test -n "$3"; then 161065d490d0Smrg func_error "Could not determine the host path corresponding to" 161165d490d0Smrg func_error " \`$3'" 161265d490d0Smrg func_error "Continuing, but uninstalled executables may not work." 161365d490d0Smrg # Fallback. This is a deliberately simplistic "conversion" and 161465d490d0Smrg # should not be "improved". See libtool.info. 161565d490d0Smrg if test "x$1" != "x$2"; then 161665d490d0Smrg lt_replace_pathsep_chars="s|$1|$2|g" 161765d490d0Smrg func_to_host_path_result=`echo "$3" | 161865d490d0Smrg $SED -e "$lt_replace_pathsep_chars"` 161965d490d0Smrg else 162065d490d0Smrg func_to_host_path_result="$3" 162165d490d0Smrg fi 162265d490d0Smrg fi 162365d490d0Smrg} 162465d490d0Smrg# end func_convert_path_check 1625e4da13eeSmacallan 1626e4da13eeSmacallan 162765d490d0Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 162865d490d0Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 162965d490d0Smrg# and appending REPL if ORIG matches BACKPAT. 163065d490d0Smrgfunc_convert_path_front_back_pathsep () 163165d490d0Smrg{ 163265d490d0Smrg $opt_debug 163365d490d0Smrg case $4 in 163465d490d0Smrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 163565d490d0Smrg ;; 163665d490d0Smrg esac 163765d490d0Smrg case $4 in 163865d490d0Smrg $2 ) func_append func_to_host_path_result "$3" 163965d490d0Smrg ;; 164065d490d0Smrg esac 164165d490d0Smrg} 164265d490d0Smrg# end func_convert_path_front_back_pathsep 1643e4da13eeSmacallan 1644e4da13eeSmacallan 164565d490d0Smrg################################################## 164665d490d0Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 164765d490d0Smrg################################################## 164865d490d0Smrg# invoked via `$to_host_file_cmd ARG' 164965d490d0Smrg# 165065d490d0Smrg# In each case, ARG is the path to be converted from $build to $host format. 165165d490d0Smrg# Result will be available in $func_to_host_file_result. 1652e4da13eeSmacallan 1653e4da13eeSmacallan 165465d490d0Smrg# func_to_host_file ARG 165565d490d0Smrg# Converts the file name ARG from $build format to $host format. Return result 165665d490d0Smrg# in func_to_host_file_result. 165765d490d0Smrgfunc_to_host_file () 165865d490d0Smrg{ 165965d490d0Smrg $opt_debug 166065d490d0Smrg $to_host_file_cmd "$1" 166165d490d0Smrg} 166265d490d0Smrg# end func_to_host_file 1663e4da13eeSmacallan 1664e4da13eeSmacallan 166565d490d0Smrg# func_to_tool_file ARG LAZY 166665d490d0Smrg# converts the file name ARG from $build format to toolchain format. Return 166765d490d0Smrg# result in func_to_tool_file_result. If the conversion in use is listed 166865d490d0Smrg# in (the comma separated) LAZY, no conversion takes place. 166965d490d0Smrgfunc_to_tool_file () 167065d490d0Smrg{ 167165d490d0Smrg $opt_debug 167265d490d0Smrg case ,$2, in 167365d490d0Smrg *,"$to_tool_file_cmd",*) 167465d490d0Smrg func_to_tool_file_result=$1 167565d490d0Smrg ;; 167665d490d0Smrg *) 167765d490d0Smrg $to_tool_file_cmd "$1" 167865d490d0Smrg func_to_tool_file_result=$func_to_host_file_result 167965d490d0Smrg ;; 168065d490d0Smrg esac 168165d490d0Smrg} 168265d490d0Smrg# end func_to_tool_file 1683e4da13eeSmacallan 1684e4da13eeSmacallan 168565d490d0Smrg# func_convert_file_noop ARG 168665d490d0Smrg# Copy ARG to func_to_host_file_result. 168765d490d0Smrgfunc_convert_file_noop () 168865d490d0Smrg{ 168965d490d0Smrg func_to_host_file_result="$1" 169065d490d0Smrg} 169165d490d0Smrg# end func_convert_file_noop 1692e4da13eeSmacallan 1693e4da13eeSmacallan 169465d490d0Smrg# func_convert_file_msys_to_w32 ARG 169565d490d0Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 169665d490d0Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 169765d490d0Smrg# func_to_host_file_result. 169865d490d0Smrgfunc_convert_file_msys_to_w32 () 169965d490d0Smrg{ 170065d490d0Smrg $opt_debug 170165d490d0Smrg func_to_host_file_result="$1" 170265d490d0Smrg if test -n "$1"; then 170365d490d0Smrg func_convert_core_msys_to_w32 "$1" 170465d490d0Smrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 170565d490d0Smrg fi 170665d490d0Smrg func_convert_file_check "$1" "$func_to_host_file_result" 170765d490d0Smrg} 170865d490d0Smrg# end func_convert_file_msys_to_w32 1709e4da13eeSmacallan 1710e4da13eeSmacallan 171165d490d0Smrg# func_convert_file_cygwin_to_w32 ARG 171265d490d0Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 171365d490d0Smrg# func_to_host_file_result. 171465d490d0Smrgfunc_convert_file_cygwin_to_w32 () 171565d490d0Smrg{ 171665d490d0Smrg $opt_debug 171765d490d0Smrg func_to_host_file_result="$1" 171865d490d0Smrg if test -n "$1"; then 171965d490d0Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 172065d490d0Smrg # LT_CYGPATH in this case. 172165d490d0Smrg func_to_host_file_result=`cygpath -m "$1"` 172265d490d0Smrg fi 172365d490d0Smrg func_convert_file_check "$1" "$func_to_host_file_result" 172465d490d0Smrg} 172565d490d0Smrg# end func_convert_file_cygwin_to_w32 1726e4da13eeSmacallan 1727e4da13eeSmacallan 172865d490d0Smrg# func_convert_file_nix_to_w32 ARG 172965d490d0Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 173065d490d0Smrg# and a working winepath. Returns result in func_to_host_file_result. 173165d490d0Smrgfunc_convert_file_nix_to_w32 () 173265d490d0Smrg{ 173365d490d0Smrg $opt_debug 173465d490d0Smrg func_to_host_file_result="$1" 173565d490d0Smrg if test -n "$1"; then 173665d490d0Smrg func_convert_core_file_wine_to_w32 "$1" 173765d490d0Smrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 173865d490d0Smrg fi 173965d490d0Smrg func_convert_file_check "$1" "$func_to_host_file_result" 174065d490d0Smrg} 174165d490d0Smrg# end func_convert_file_nix_to_w32 1742e4da13eeSmacallan 1743e4da13eeSmacallan 174465d490d0Smrg# func_convert_file_msys_to_cygwin ARG 174565d490d0Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 174665d490d0Smrg# Returns result in func_to_host_file_result. 174765d490d0Smrgfunc_convert_file_msys_to_cygwin () 174865d490d0Smrg{ 174965d490d0Smrg $opt_debug 175065d490d0Smrg func_to_host_file_result="$1" 175165d490d0Smrg if test -n "$1"; then 175265d490d0Smrg func_convert_core_msys_to_w32 "$1" 175365d490d0Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 175465d490d0Smrg func_to_host_file_result="$func_cygpath_result" 175565d490d0Smrg fi 175665d490d0Smrg func_convert_file_check "$1" "$func_to_host_file_result" 175765d490d0Smrg} 175865d490d0Smrg# end func_convert_file_msys_to_cygwin 1759e4da13eeSmacallan 1760e4da13eeSmacallan 176165d490d0Smrg# func_convert_file_nix_to_cygwin ARG 176265d490d0Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 176365d490d0Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 176465d490d0Smrg# in func_to_host_file_result. 176565d490d0Smrgfunc_convert_file_nix_to_cygwin () 176665d490d0Smrg{ 176765d490d0Smrg $opt_debug 176865d490d0Smrg func_to_host_file_result="$1" 176965d490d0Smrg if test -n "$1"; then 177065d490d0Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 177165d490d0Smrg func_convert_core_file_wine_to_w32 "$1" 177265d490d0Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 177365d490d0Smrg func_to_host_file_result="$func_cygpath_result" 177465d490d0Smrg fi 177565d490d0Smrg func_convert_file_check "$1" "$func_to_host_file_result" 177665d490d0Smrg} 177765d490d0Smrg# end func_convert_file_nix_to_cygwin 1778e4da13eeSmacallan 1779e4da13eeSmacallan 178065d490d0Smrg############################################# 178165d490d0Smrg# $build to $host PATH CONVERSION FUNCTIONS # 178265d490d0Smrg############################################# 178365d490d0Smrg# invoked via `$to_host_path_cmd ARG' 178465d490d0Smrg# 178565d490d0Smrg# In each case, ARG is the path to be converted from $build to $host format. 178665d490d0Smrg# The result will be available in $func_to_host_path_result. 178765d490d0Smrg# 178865d490d0Smrg# Path separators are also converted from $build format to $host format. If 178965d490d0Smrg# ARG begins or ends with a path separator character, it is preserved (but 179065d490d0Smrg# converted to $host format) on output. 179165d490d0Smrg# 179265d490d0Smrg# All path conversion functions are named using the following convention: 179365d490d0Smrg# file name conversion function : func_convert_file_X_to_Y () 179465d490d0Smrg# path conversion function : func_convert_path_X_to_Y () 179565d490d0Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 179665d490d0Smrg# same. If conversion functions are added for new $build/$host combinations, 179765d490d0Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 179865d490d0Smrg# will break. 179965d490d0Smrg 180065d490d0Smrg 180165d490d0Smrg# func_init_to_host_path_cmd 180265d490d0Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 180365d490d0Smrg# appropriate value, based on the value of $to_host_file_cmd. 180465d490d0Smrgto_host_path_cmd= 180565d490d0Smrgfunc_init_to_host_path_cmd () 180665d490d0Smrg{ 180765d490d0Smrg $opt_debug 180865d490d0Smrg if test -z "$to_host_path_cmd"; then 180965d490d0Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 181065d490d0Smrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 181165d490d0Smrg fi 181265d490d0Smrg} 1813e4da13eeSmacallan 1814e4da13eeSmacallan 181565d490d0Smrg# func_to_host_path ARG 181665d490d0Smrg# Converts the path ARG from $build format to $host format. Return result 181765d490d0Smrg# in func_to_host_path_result. 181865d490d0Smrgfunc_to_host_path () 181965d490d0Smrg{ 182065d490d0Smrg $opt_debug 182165d490d0Smrg func_init_to_host_path_cmd 182265d490d0Smrg $to_host_path_cmd "$1" 182365d490d0Smrg} 182465d490d0Smrg# end func_to_host_path 1825e4da13eeSmacallan 1826e4da13eeSmacallan 182765d490d0Smrg# func_convert_path_noop ARG 182865d490d0Smrg# Copy ARG to func_to_host_path_result. 182965d490d0Smrgfunc_convert_path_noop () 183065d490d0Smrg{ 183165d490d0Smrg func_to_host_path_result="$1" 183265d490d0Smrg} 183365d490d0Smrg# end func_convert_path_noop 1834e4da13eeSmacallan 1835e4da13eeSmacallan 183665d490d0Smrg# func_convert_path_msys_to_w32 ARG 183765d490d0Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 183865d490d0Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 183965d490d0Smrg# func_to_host_path_result. 184065d490d0Smrgfunc_convert_path_msys_to_w32 () 184165d490d0Smrg{ 184265d490d0Smrg $opt_debug 184365d490d0Smrg func_to_host_path_result="$1" 184465d490d0Smrg if test -n "$1"; then 184565d490d0Smrg # Remove leading and trailing path separator characters from ARG. MSYS 184665d490d0Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 184765d490d0Smrg # and winepath ignores them completely. 184865d490d0Smrg func_stripname : : "$1" 184965d490d0Smrg func_to_host_path_tmp1=$func_stripname_result 185065d490d0Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 185165d490d0Smrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 185265d490d0Smrg func_convert_path_check : ";" \ 185365d490d0Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 185465d490d0Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 185565d490d0Smrg fi 185665d490d0Smrg} 185765d490d0Smrg# end func_convert_path_msys_to_w32 1858e4da13eeSmacallan 1859e4da13eeSmacallan 186065d490d0Smrg# func_convert_path_cygwin_to_w32 ARG 186165d490d0Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 186265d490d0Smrg# func_to_host_file_result. 186365d490d0Smrgfunc_convert_path_cygwin_to_w32 () 186465d490d0Smrg{ 186565d490d0Smrg $opt_debug 186665d490d0Smrg func_to_host_path_result="$1" 186765d490d0Smrg if test -n "$1"; then 186865d490d0Smrg # See func_convert_path_msys_to_w32: 186965d490d0Smrg func_stripname : : "$1" 187065d490d0Smrg func_to_host_path_tmp1=$func_stripname_result 187165d490d0Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 187265d490d0Smrg func_convert_path_check : ";" \ 187365d490d0Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 187465d490d0Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 187565d490d0Smrg fi 187665d490d0Smrg} 187765d490d0Smrg# end func_convert_path_cygwin_to_w32 1878e4da13eeSmacallan 1879e4da13eeSmacallan 188065d490d0Smrg# func_convert_path_nix_to_w32 ARG 188165d490d0Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 188265d490d0Smrg# a working winepath. Returns result in func_to_host_file_result. 188365d490d0Smrgfunc_convert_path_nix_to_w32 () 188465d490d0Smrg{ 188565d490d0Smrg $opt_debug 188665d490d0Smrg func_to_host_path_result="$1" 188765d490d0Smrg if test -n "$1"; then 188865d490d0Smrg # See func_convert_path_msys_to_w32: 188965d490d0Smrg func_stripname : : "$1" 189065d490d0Smrg func_to_host_path_tmp1=$func_stripname_result 189165d490d0Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 189265d490d0Smrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 189365d490d0Smrg func_convert_path_check : ";" \ 189465d490d0Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 189565d490d0Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 189665d490d0Smrg fi 189765d490d0Smrg} 189865d490d0Smrg# end func_convert_path_nix_to_w32 1899e4da13eeSmacallan 1900e4da13eeSmacallan 190165d490d0Smrg# func_convert_path_msys_to_cygwin ARG 190265d490d0Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 190365d490d0Smrg# Returns result in func_to_host_file_result. 190465d490d0Smrgfunc_convert_path_msys_to_cygwin () 190565d490d0Smrg{ 190665d490d0Smrg $opt_debug 190765d490d0Smrg func_to_host_path_result="$1" 190865d490d0Smrg if test -n "$1"; then 190965d490d0Smrg # See func_convert_path_msys_to_w32: 191065d490d0Smrg func_stripname : : "$1" 191165d490d0Smrg func_to_host_path_tmp1=$func_stripname_result 191265d490d0Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 191365d490d0Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 191465d490d0Smrg func_to_host_path_result="$func_cygpath_result" 191565d490d0Smrg func_convert_path_check : : \ 191665d490d0Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 191765d490d0Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 191865d490d0Smrg fi 191965d490d0Smrg} 192065d490d0Smrg# end func_convert_path_msys_to_cygwin 1921e4da13eeSmacallan 1922e4da13eeSmacallan 192365d490d0Smrg# func_convert_path_nix_to_cygwin ARG 192465d490d0Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 192565d490d0Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 192665d490d0Smrg# func_to_host_file_result. 192765d490d0Smrgfunc_convert_path_nix_to_cygwin () 192865d490d0Smrg{ 192965d490d0Smrg $opt_debug 193065d490d0Smrg func_to_host_path_result="$1" 193165d490d0Smrg if test -n "$1"; then 193265d490d0Smrg # Remove leading and trailing path separator characters from 193365d490d0Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 193465d490d0Smrg # into '.;' and ';.', and winepath ignores them completely. 193565d490d0Smrg func_stripname : : "$1" 193665d490d0Smrg func_to_host_path_tmp1=$func_stripname_result 193765d490d0Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 193865d490d0Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 193965d490d0Smrg func_to_host_path_result="$func_cygpath_result" 194065d490d0Smrg func_convert_path_check : : \ 194165d490d0Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 194265d490d0Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 194365d490d0Smrg fi 194465d490d0Smrg} 194565d490d0Smrg# end func_convert_path_nix_to_cygwin 1946e4da13eeSmacallan 1947e4da13eeSmacallan 194865d490d0Smrg# func_mode_compile arg... 194965d490d0Smrgfunc_mode_compile () 195065d490d0Smrg{ 195165d490d0Smrg $opt_debug 195265d490d0Smrg # Get the compilation command and the source file. 195365d490d0Smrg base_compile= 195465d490d0Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 195565d490d0Smrg suppress_opt=yes 195665d490d0Smrg suppress_output= 195765d490d0Smrg arg_mode=normal 195865d490d0Smrg libobj= 195965d490d0Smrg later= 196065d490d0Smrg pie_flag= 196165d490d0Smrg 196265d490d0Smrg for arg 196365d490d0Smrg do 196465d490d0Smrg case $arg_mode in 196565d490d0Smrg arg ) 196665d490d0Smrg # do not "continue". Instead, add this to base_compile 196765d490d0Smrg lastarg="$arg" 196865d490d0Smrg arg_mode=normal 196965d490d0Smrg ;; 197065d490d0Smrg 197165d490d0Smrg target ) 197265d490d0Smrg libobj="$arg" 197365d490d0Smrg arg_mode=normal 197465d490d0Smrg continue 197565d490d0Smrg ;; 197665d490d0Smrg 197765d490d0Smrg normal ) 197865d490d0Smrg # Accept any command-line options. 197965d490d0Smrg case $arg in 198065d490d0Smrg -o) 198165d490d0Smrg test -n "$libobj" && \ 198265d490d0Smrg func_fatal_error "you cannot specify \`-o' more than once" 198365d490d0Smrg arg_mode=target 1984e4da13eeSmacallan continue 1985e4da13eeSmacallan ;; 198665d490d0Smrg 198765d490d0Smrg -pie | -fpie | -fPIE) 198865d490d0Smrg func_append pie_flag " $arg" 1989e4da13eeSmacallan continue 1990e4da13eeSmacallan ;; 199165d490d0Smrg 199265d490d0Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 199365d490d0Smrg func_append later " $arg" 1994e4da13eeSmacallan continue 1995e4da13eeSmacallan ;; 199665d490d0Smrg 199765d490d0Smrg -no-suppress) 199865d490d0Smrg suppress_opt=no 1999e4da13eeSmacallan continue 2000e4da13eeSmacallan ;; 2001e4da13eeSmacallan 200265d490d0Smrg -Xcompiler) 200365d490d0Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 200465d490d0Smrg continue # The current "srcfile" will either be retained or 200565d490d0Smrg ;; # replaced later. I would guess that would be a bug. 2006e4da13eeSmacallan 200765d490d0Smrg -Wc,*) 200865d490d0Smrg func_stripname '-Wc,' '' "$arg" 200965d490d0Smrg args=$func_stripname_result 201065d490d0Smrg lastarg= 201165d490d0Smrg save_ifs="$IFS"; IFS=',' 201265d490d0Smrg for arg in $args; do 201365d490d0Smrg IFS="$save_ifs" 201465d490d0Smrg func_append_quoted lastarg "$arg" 201565d490d0Smrg done 201665d490d0Smrg IFS="$save_ifs" 201765d490d0Smrg func_stripname ' ' '' "$lastarg" 201865d490d0Smrg lastarg=$func_stripname_result 2019e4da13eeSmacallan 202065d490d0Smrg # Add the arguments to base_compile. 202165d490d0Smrg func_append base_compile " $lastarg" 202265d490d0Smrg continue 202365d490d0Smrg ;; 2024e4da13eeSmacallan 202565d490d0Smrg *) 202665d490d0Smrg # Accept the current argument as the source file. 202765d490d0Smrg # The previous "srcfile" becomes the current argument. 202865d490d0Smrg # 202965d490d0Smrg lastarg="$srcfile" 203065d490d0Smrg srcfile="$arg" 203165d490d0Smrg ;; 203265d490d0Smrg esac # case $arg 2033e4da13eeSmacallan ;; 203465d490d0Smrg esac # case $arg_mode 2035e4da13eeSmacallan 203665d490d0Smrg # Aesthetically quote the previous argument. 203765d490d0Smrg func_append_quoted base_compile "$lastarg" 203865d490d0Smrg done # for arg 2039e4da13eeSmacallan 204065d490d0Smrg case $arg_mode in 204165d490d0Smrg arg) 204265d490d0Smrg func_fatal_error "you must specify an argument for -Xcompile" 204365d490d0Smrg ;; 204465d490d0Smrg target) 204565d490d0Smrg func_fatal_error "you must specify a target with \`-o'" 204665d490d0Smrg ;; 204765d490d0Smrg *) 204865d490d0Smrg # Get the name of the library object. 204965d490d0Smrg test -z "$libobj" && { 205065d490d0Smrg func_basename "$srcfile" 205165d490d0Smrg libobj="$func_basename_result" 205265d490d0Smrg } 205365d490d0Smrg ;; 205465d490d0Smrg esac 2055e4da13eeSmacallan 205665d490d0Smrg # Recognize several different file suffixes. 205765d490d0Smrg # If the user specifies -o file.o, it is replaced with file.lo 205865d490d0Smrg case $libobj in 205965d490d0Smrg *.[cCFSifmso] | \ 206065d490d0Smrg *.ada | *.adb | *.ads | *.asm | \ 206165d490d0Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 206265d490d0Smrg *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup) 206365d490d0Smrg func_xform "$libobj" 206465d490d0Smrg libobj=$func_xform_result 206565d490d0Smrg ;; 206665d490d0Smrg esac 2067e4da13eeSmacallan 206865d490d0Smrg case $libobj in 206965d490d0Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 207065d490d0Smrg *) 207165d490d0Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 207265d490d0Smrg ;; 207365d490d0Smrg esac 2074e4da13eeSmacallan 207565d490d0Smrg func_infer_tag $base_compile 2076e4da13eeSmacallan 207765d490d0Smrg for arg in $later; do 207865d490d0Smrg case $arg in 207965d490d0Smrg -shared) 208065d490d0Smrg test "$build_libtool_libs" != yes && \ 208165d490d0Smrg func_fatal_configuration "can not build a shared library" 208265d490d0Smrg build_old_libs=no 2083e4da13eeSmacallan continue 2084e4da13eeSmacallan ;; 2085e4da13eeSmacallan 208665d490d0Smrg -static) 208765d490d0Smrg build_libtool_libs=no 208865d490d0Smrg build_old_libs=yes 2089e4da13eeSmacallan continue 2090e4da13eeSmacallan ;; 2091e4da13eeSmacallan 209265d490d0Smrg -prefer-pic) 209365d490d0Smrg pic_mode=yes 2094e4da13eeSmacallan continue 2095e4da13eeSmacallan ;; 2096e4da13eeSmacallan 209765d490d0Smrg -prefer-non-pic) 209865d490d0Smrg pic_mode=no 2099e4da13eeSmacallan continue 2100e4da13eeSmacallan ;; 210165d490d0Smrg esac 210265d490d0Smrg done 2103e4da13eeSmacallan 210465d490d0Smrg func_quote_for_eval "$libobj" 210565d490d0Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 210665d490d0Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 210765d490d0Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 210865d490d0Smrg func_dirname_and_basename "$obj" "/" "" 210965d490d0Smrg objname="$func_basename_result" 211065d490d0Smrg xdir="$func_dirname_result" 211165d490d0Smrg lobj=${xdir}$objdir/$objname 2112e4da13eeSmacallan 211365d490d0Smrg test -z "$base_compile" && \ 211465d490d0Smrg func_fatal_help "you must specify a compilation command" 2115e4da13eeSmacallan 211665d490d0Smrg # Delete any leftover library objects. 211765d490d0Smrg if test "$build_old_libs" = yes; then 211865d490d0Smrg removelist="$obj $lobj $libobj ${libobj}T" 211965d490d0Smrg else 212065d490d0Smrg removelist="$lobj $libobj ${libobj}T" 212165d490d0Smrg fi 2122e4da13eeSmacallan 212365d490d0Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 212465d490d0Smrg case $host_os in 212565d490d0Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 212665d490d0Smrg pic_mode=default 212765d490d0Smrg ;; 212865d490d0Smrg esac 212965d490d0Smrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 213065d490d0Smrg # non-PIC code in shared libraries is not supported 213165d490d0Smrg pic_mode=default 213265d490d0Smrg fi 2133e4da13eeSmacallan 213465d490d0Smrg # Calculate the filename of the output object if compiler does 213565d490d0Smrg # not support -o with -c 213665d490d0Smrg if test "$compiler_c_o" = no; then 213765d490d0Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 213865d490d0Smrg lockfile="$output_obj.lock" 213965d490d0Smrg else 214065d490d0Smrg output_obj= 214165d490d0Smrg need_locks=no 214265d490d0Smrg lockfile= 214365d490d0Smrg fi 2144e4da13eeSmacallan 214565d490d0Smrg # Lock this critical section if it is needed 214665d490d0Smrg # We use this script file to make the link, it avoids creating a new file 214765d490d0Smrg if test "$need_locks" = yes; then 214865d490d0Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 214965d490d0Smrg func_echo "Waiting for $lockfile to be removed" 215065d490d0Smrg sleep 2 215165d490d0Smrg done 215265d490d0Smrg elif test "$need_locks" = warn; then 215365d490d0Smrg if test -f "$lockfile"; then 215465d490d0Smrg $ECHO "\ 215565d490d0Smrg*** ERROR, $lockfile exists and contains: 215665d490d0Smrg`cat $lockfile 2>/dev/null` 2157e4da13eeSmacallan 215865d490d0SmrgThis indicates that another process is trying to use the same 215965d490d0Smrgtemporary object file, and libtool could not work around it because 216065d490d0Smrgyour compiler does not support \`-c' and \`-o' together. If you 216165d490d0Smrgrepeat this compilation, it may succeed, by chance, but you had better 216265d490d0Smrgavoid parallel builds (make -j) in this platform, or get a better 216365d490d0Smrgcompiler." 2164e4da13eeSmacallan 216565d490d0Smrg $opt_dry_run || $RM $removelist 216665d490d0Smrg exit $EXIT_FAILURE 216765d490d0Smrg fi 216865d490d0Smrg func_append removelist " $output_obj" 216965d490d0Smrg $ECHO "$srcfile" > "$lockfile" 217065d490d0Smrg fi 2171e4da13eeSmacallan 217265d490d0Smrg $opt_dry_run || $RM $removelist 217365d490d0Smrg func_append removelist " $lockfile" 217465d490d0Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 2175e4da13eeSmacallan 217665d490d0Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 217765d490d0Smrg srcfile=$func_to_tool_file_result 217865d490d0Smrg func_quote_for_eval "$srcfile" 217965d490d0Smrg qsrcfile=$func_quote_for_eval_result 2180e4da13eeSmacallan 218165d490d0Smrg # Only build a PIC object if we are building libtool libraries. 218265d490d0Smrg if test "$build_libtool_libs" = yes; then 218365d490d0Smrg # Without this assignment, base_compile gets emptied. 218465d490d0Smrg fbsd_hideous_sh_bug=$base_compile 2185e4da13eeSmacallan 218665d490d0Smrg if test "$pic_mode" != no; then 218765d490d0Smrg command="$base_compile $qsrcfile $pic_flag" 218865d490d0Smrg else 218965d490d0Smrg # Don't build PIC code 219065d490d0Smrg command="$base_compile $qsrcfile" 219165d490d0Smrg fi 2192e4da13eeSmacallan 219365d490d0Smrg func_mkdir_p "$xdir$objdir" 2194e4da13eeSmacallan 219565d490d0Smrg if test -z "$output_obj"; then 219665d490d0Smrg # Place PIC objects in $objdir 219765d490d0Smrg func_append command " -o $lobj" 219865d490d0Smrg fi 2199e4da13eeSmacallan 220065d490d0Smrg func_show_eval_locale "$command" \ 220165d490d0Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 2202e4da13eeSmacallan 220365d490d0Smrg if test "$need_locks" = warn && 220465d490d0Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 220565d490d0Smrg $ECHO "\ 220665d490d0Smrg*** ERROR, $lockfile contains: 220765d490d0Smrg`cat $lockfile 2>/dev/null` 2208e4da13eeSmacallan 220965d490d0Smrgbut it should contain: 221065d490d0Smrg$srcfile 2211e4da13eeSmacallan 221265d490d0SmrgThis indicates that another process is trying to use the same 221365d490d0Smrgtemporary object file, and libtool could not work around it because 221465d490d0Smrgyour compiler does not support \`-c' and \`-o' together. If you 221565d490d0Smrgrepeat this compilation, it may succeed, by chance, but you had better 221665d490d0Smrgavoid parallel builds (make -j) in this platform, or get a better 221765d490d0Smrgcompiler." 2218e4da13eeSmacallan 221965d490d0Smrg $opt_dry_run || $RM $removelist 222065d490d0Smrg exit $EXIT_FAILURE 222165d490d0Smrg fi 2222e4da13eeSmacallan 222365d490d0Smrg # Just move the object if needed, then go on to compile the next one 222465d490d0Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 222565d490d0Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 222665d490d0Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 222765d490d0Smrg fi 2228e4da13eeSmacallan 222965d490d0Smrg # Allow error messages only from the first compilation. 223065d490d0Smrg if test "$suppress_opt" = yes; then 223165d490d0Smrg suppress_output=' >/dev/null 2>&1' 223265d490d0Smrg fi 223365d490d0Smrg fi 2234e4da13eeSmacallan 223565d490d0Smrg # Only build a position-dependent object if we build old libraries. 223665d490d0Smrg if test "$build_old_libs" = yes; then 223765d490d0Smrg if test "$pic_mode" != yes; then 223865d490d0Smrg # Don't build PIC code 223965d490d0Smrg command="$base_compile $qsrcfile$pie_flag" 224065d490d0Smrg else 224165d490d0Smrg command="$base_compile $qsrcfile $pic_flag" 224265d490d0Smrg fi 224365d490d0Smrg if test "$compiler_c_o" = yes; then 224465d490d0Smrg func_append command " -o $obj" 224565d490d0Smrg fi 2246e4da13eeSmacallan 224765d490d0Smrg # Suppress compiler output if we already did a PIC compilation. 224865d490d0Smrg func_append command "$suppress_output" 224965d490d0Smrg func_show_eval_locale "$command" \ 225065d490d0Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 2251e4da13eeSmacallan 225265d490d0Smrg if test "$need_locks" = warn && 225365d490d0Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 225465d490d0Smrg $ECHO "\ 225565d490d0Smrg*** ERROR, $lockfile contains: 225665d490d0Smrg`cat $lockfile 2>/dev/null` 2257e4da13eeSmacallan 225865d490d0Smrgbut it should contain: 225965d490d0Smrg$srcfile 2260e4da13eeSmacallan 226165d490d0SmrgThis indicates that another process is trying to use the same 226265d490d0Smrgtemporary object file, and libtool could not work around it because 226365d490d0Smrgyour compiler does not support \`-c' and \`-o' together. If you 226465d490d0Smrgrepeat this compilation, it may succeed, by chance, but you had better 226565d490d0Smrgavoid parallel builds (make -j) in this platform, or get a better 226665d490d0Smrgcompiler." 2267e4da13eeSmacallan 226865d490d0Smrg $opt_dry_run || $RM $removelist 226965d490d0Smrg exit $EXIT_FAILURE 227065d490d0Smrg fi 2271e4da13eeSmacallan 227265d490d0Smrg # Just move the object if needed 227365d490d0Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 227465d490d0Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 227565d490d0Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 227665d490d0Smrg fi 227765d490d0Smrg fi 2278e4da13eeSmacallan 227965d490d0Smrg $opt_dry_run || { 228065d490d0Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 2281e4da13eeSmacallan 228265d490d0Smrg # Unlock the critical section if it was locked 228365d490d0Smrg if test "$need_locks" != no; then 228465d490d0Smrg removelist=$lockfile 228565d490d0Smrg $RM "$lockfile" 228665d490d0Smrg fi 228765d490d0Smrg } 2288e4da13eeSmacallan 228965d490d0Smrg exit $EXIT_SUCCESS 229065d490d0Smrg} 2291e4da13eeSmacallan 229265d490d0Smrg$opt_help || { 229365d490d0Smrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 229465d490d0Smrg} 2295e4da13eeSmacallan 229665d490d0Smrgfunc_mode_help () 229765d490d0Smrg{ 229865d490d0Smrg # We need to display help for each of the modes. 229965d490d0Smrg case $opt_mode in 230065d490d0Smrg "") 230165d490d0Smrg # Generic help is extracted from the usage comments 230265d490d0Smrg # at the start of this file. 230365d490d0Smrg func_help 230465d490d0Smrg ;; 2305e4da13eeSmacallan 230665d490d0Smrg clean) 230765d490d0Smrg $ECHO \ 230865d490d0Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 2309e4da13eeSmacallan 231065d490d0SmrgRemove files from the build directory. 2311e4da13eeSmacallan 231265d490d0SmrgRM is the name of the program to use to delete files associated with each FILE 231365d490d0Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 231465d490d0Smrgto RM. 2315e4da13eeSmacallan 231665d490d0SmrgIf FILE is a libtool library, object or program, all the files associated 231765d490d0Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 231865d490d0Smrg ;; 2319e4da13eeSmacallan 232065d490d0Smrg compile) 232165d490d0Smrg $ECHO \ 232265d490d0Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 2323e4da13eeSmacallan 232465d490d0SmrgCompile a source file into a libtool library object. 2325e4da13eeSmacallan 232665d490d0SmrgThis mode accepts the following additional options: 2327e4da13eeSmacallan 232865d490d0Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 232965d490d0Smrg -no-suppress do not suppress compiler output for multiple passes 233065d490d0Smrg -prefer-pic try to build PIC objects only 233165d490d0Smrg -prefer-non-pic try to build non-PIC objects only 233265d490d0Smrg -shared do not build a \`.o' file suitable for static linking 233365d490d0Smrg -static only build a \`.o' file suitable for static linking 233465d490d0Smrg -Wc,FLAG pass FLAG directly to the compiler 2335e4da13eeSmacallan 233665d490d0SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 233765d490d0Smrgfrom the given SOURCEFILE. 2338e4da13eeSmacallan 233965d490d0SmrgThe output file name is determined by removing the directory component from 234065d490d0SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 234165d490d0Smrglibrary object suffix, \`.lo'." 234265d490d0Smrg ;; 2343e4da13eeSmacallan 234465d490d0Smrg execute) 234565d490d0Smrg $ECHO \ 234665d490d0Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 2347e4da13eeSmacallan 234865d490d0SmrgAutomatically set library path, then run a program. 2349e4da13eeSmacallan 235065d490d0SmrgThis mode accepts the following additional options: 2351e4da13eeSmacallan 235265d490d0Smrg -dlopen FILE add the directory containing FILE to the library path 2353e4da13eeSmacallan 235465d490d0SmrgThis mode sets the library path environment variable according to \`-dlopen' 235565d490d0Smrgflags. 2356e4da13eeSmacallan 235765d490d0SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 235865d490d0Smrginto their corresponding uninstalled binary, and any of their required library 235965d490d0Smrgdirectories are added to the library path. 2360e4da13eeSmacallan 236165d490d0SmrgThen, COMMAND is executed, with ARGS as arguments." 236265d490d0Smrg ;; 2363e4da13eeSmacallan 236465d490d0Smrg finish) 236565d490d0Smrg $ECHO \ 236665d490d0Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 2367e4da13eeSmacallan 236865d490d0SmrgComplete the installation of libtool libraries. 236965d490d0Smrg 237065d490d0SmrgEach LIBDIR is a directory that contains libtool libraries. 237165d490d0Smrg 237265d490d0SmrgThe commands that this mode executes may require superuser privileges. Use 237365d490d0Smrgthe \`--dry-run' option if you just want to see what would be executed." 237465d490d0Smrg ;; 237565d490d0Smrg 237665d490d0Smrg install) 237765d490d0Smrg $ECHO \ 237865d490d0Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 237965d490d0Smrg 238065d490d0SmrgInstall executables or libraries. 238165d490d0Smrg 238265d490d0SmrgINSTALL-COMMAND is the installation command. The first component should be 238365d490d0Smrgeither the \`install' or \`cp' program. 238465d490d0Smrg 238565d490d0SmrgThe following components of INSTALL-COMMAND are treated specially: 238665d490d0Smrg 238765d490d0Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 238865d490d0Smrg 238965d490d0SmrgThe rest of the components are interpreted as arguments to that command (only 239065d490d0SmrgBSD-compatible install options are recognized)." 239165d490d0Smrg ;; 239265d490d0Smrg 239365d490d0Smrg link) 239465d490d0Smrg $ECHO \ 239565d490d0Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 239665d490d0Smrg 239765d490d0SmrgLink object files or libraries together to form another library, or to 239865d490d0Smrgcreate an executable program. 239965d490d0Smrg 240065d490d0SmrgLINK-COMMAND is a command using the C compiler that you would use to create 240165d490d0Smrga program from several object files. 240265d490d0Smrg 240365d490d0SmrgThe following components of LINK-COMMAND are treated specially: 240465d490d0Smrg 240565d490d0Smrg -all-static do not do any dynamic linking at all 240665d490d0Smrg -avoid-version do not add a version suffix if possible 240765d490d0Smrg -bindir BINDIR specify path to binaries directory (for systems where 240865d490d0Smrg libraries must be found in the PATH setting at runtime) 240965d490d0Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 241065d490d0Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 241165d490d0Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 241265d490d0Smrg -export-symbols SYMFILE 241365d490d0Smrg try to export only the symbols listed in SYMFILE 241465d490d0Smrg -export-symbols-regex REGEX 241565d490d0Smrg try to export only the symbols matching REGEX 241665d490d0Smrg -LLIBDIR search LIBDIR for required installed libraries 241765d490d0Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 241865d490d0Smrg -module build a library that can dlopened 241965d490d0Smrg -no-fast-install disable the fast-install mode 242065d490d0Smrg -no-install link a not-installable executable 242165d490d0Smrg -no-undefined declare that a library does not refer to external symbols 242265d490d0Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 242365d490d0Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 242465d490d0Smrg -precious-files-regex REGEX 242565d490d0Smrg don't remove output files matching REGEX 242665d490d0Smrg -release RELEASE specify package release information 242765d490d0Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 242865d490d0Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 242965d490d0Smrg -shared only do dynamic linking of libtool libraries 243065d490d0Smrg -shrext SUFFIX override the standard shared library file extension 243165d490d0Smrg -static do not do any dynamic linking of uninstalled libtool libraries 243265d490d0Smrg -static-libtool-libs 243365d490d0Smrg do not do any dynamic linking of libtool libraries 243465d490d0Smrg -version-info CURRENT[:REVISION[:AGE]] 243565d490d0Smrg specify library version info [each variable defaults to 0] 243665d490d0Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 243765d490d0Smrg -Wc,FLAG 243865d490d0Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 243965d490d0Smrg -Wl,FLAG 244065d490d0Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 244165d490d0Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 244265d490d0Smrg 244365d490d0SmrgAll other options (arguments beginning with \`-') are ignored. 244465d490d0Smrg 244565d490d0SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 244665d490d0Smrgtreated as uninstalled libtool libraries, other files are standard or library 244765d490d0Smrgobject files. 244865d490d0Smrg 244965d490d0SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 245065d490d0Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 245165d490d0Smrgrequired, except when creating a convenience library. 245265d490d0Smrg 245365d490d0SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 245465d490d0Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 245565d490d0Smrg 245665d490d0SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 245765d490d0Smrgis created, otherwise an executable program is created." 245865d490d0Smrg ;; 245965d490d0Smrg 246065d490d0Smrg uninstall) 246165d490d0Smrg $ECHO \ 246265d490d0Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 246365d490d0Smrg 246465d490d0SmrgRemove libraries from an installation directory. 246565d490d0Smrg 246665d490d0SmrgRM is the name of the program to use to delete files associated with each FILE 246765d490d0Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 246865d490d0Smrgto RM. 246965d490d0Smrg 247065d490d0SmrgIf FILE is a libtool library, all the files associated with it are deleted. 247165d490d0SmrgOtherwise, only FILE itself is deleted using RM." 247265d490d0Smrg ;; 247365d490d0Smrg 247465d490d0Smrg *) 247565d490d0Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 247665d490d0Smrg ;; 2477e4da13eeSmacallan esac 2478e4da13eeSmacallan 247965d490d0Smrg echo 248065d490d0Smrg $ECHO "Try \`$progname --help' for more information about other modes." 248165d490d0Smrg} 2482e4da13eeSmacallan 248365d490d0Smrg# Now that we've collected a possible --mode arg, show help if necessary 248465d490d0Smrgif $opt_help; then 248565d490d0Smrg if test "$opt_help" = :; then 248665d490d0Smrg func_mode_help 248765d490d0Smrg else 248865d490d0Smrg { 248965d490d0Smrg func_help noexit 249065d490d0Smrg for opt_mode in compile link execute install finish uninstall clean; do 249165d490d0Smrg func_mode_help 249265d490d0Smrg done 249365d490d0Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 249465d490d0Smrg { 249565d490d0Smrg func_help noexit 249665d490d0Smrg for opt_mode in compile link execute install finish uninstall clean; do 249765d490d0Smrg echo 249865d490d0Smrg func_mode_help 249965d490d0Smrg done 250065d490d0Smrg } | 250165d490d0Smrg sed '1d 250265d490d0Smrg /^When reporting/,/^Report/{ 250365d490d0Smrg H 250465d490d0Smrg d 250565d490d0Smrg } 250665d490d0Smrg $x 250765d490d0Smrg /information about other modes/d 250865d490d0Smrg /more detailed .*MODE/d 250965d490d0Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 251065d490d0Smrg fi 251165d490d0Smrg exit $? 251265d490d0Smrgfi 2513e4da13eeSmacallan 2514e4da13eeSmacallan 251565d490d0Smrg# func_mode_execute arg... 251665d490d0Smrgfunc_mode_execute () 251765d490d0Smrg{ 251865d490d0Smrg $opt_debug 251965d490d0Smrg # The first argument is the command name. 252065d490d0Smrg cmd="$nonopt" 252165d490d0Smrg test -z "$cmd" && \ 252265d490d0Smrg func_fatal_help "you must specify a COMMAND" 252365d490d0Smrg 252465d490d0Smrg # Handle -dlopen flags immediately. 252565d490d0Smrg for file in $opt_dlopen; do 252665d490d0Smrg test -f "$file" \ 252765d490d0Smrg || func_fatal_help "\`$file' is not a file" 252865d490d0Smrg 252965d490d0Smrg dir= 253065d490d0Smrg case $file in 253165d490d0Smrg *.la) 253265d490d0Smrg func_resolve_sysroot "$file" 253365d490d0Smrg file=$func_resolve_sysroot_result 253465d490d0Smrg 253565d490d0Smrg # Check to see that this really is a libtool archive. 253665d490d0Smrg func_lalib_unsafe_p "$file" \ 253765d490d0Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 253865d490d0Smrg 253965d490d0Smrg # Read the libtool library. 254065d490d0Smrg dlname= 254165d490d0Smrg library_names= 254265d490d0Smrg func_source "$file" 254365d490d0Smrg 254465d490d0Smrg # Skip this library if it cannot be dlopened. 254565d490d0Smrg if test -z "$dlname"; then 254665d490d0Smrg # Warn if it was a shared library. 254765d490d0Smrg test -n "$library_names" && \ 254865d490d0Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 254965d490d0Smrg continue 255065d490d0Smrg fi 255165d490d0Smrg 255265d490d0Smrg func_dirname "$file" "" "." 255365d490d0Smrg dir="$func_dirname_result" 255465d490d0Smrg 255565d490d0Smrg if test -f "$dir/$objdir/$dlname"; then 255665d490d0Smrg func_append dir "/$objdir" 255765d490d0Smrg else 255865d490d0Smrg if test ! -f "$dir/$dlname"; then 255965d490d0Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 256065d490d0Smrg fi 256165d490d0Smrg fi 2562e4da13eeSmacallan ;; 256365d490d0Smrg 256465d490d0Smrg *.lo) 256565d490d0Smrg # Just add the directory containing the .lo file. 256665d490d0Smrg func_dirname "$file" "" "." 256765d490d0Smrg dir="$func_dirname_result" 2568e4da13eeSmacallan ;; 256965d490d0Smrg 257065d490d0Smrg *) 257165d490d0Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 257265d490d0Smrg continue 2573e4da13eeSmacallan ;; 257465d490d0Smrg esac 257565d490d0Smrg 257665d490d0Smrg # Get the absolute pathname. 257765d490d0Smrg absdir=`cd "$dir" && pwd` 257865d490d0Smrg test -n "$absdir" && dir="$absdir" 257965d490d0Smrg 258065d490d0Smrg # Now add the directory to shlibpath_var. 258165d490d0Smrg if eval "test -z \"\$$shlibpath_var\""; then 258265d490d0Smrg eval "$shlibpath_var=\"\$dir\"" 258365d490d0Smrg else 258465d490d0Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 2585e4da13eeSmacallan fi 258665d490d0Smrg done 258765d490d0Smrg 258865d490d0Smrg # This variable tells wrapper scripts just to set shlibpath_var 258965d490d0Smrg # rather than running their programs. 259065d490d0Smrg libtool_execute_magic="$magic" 259165d490d0Smrg 259265d490d0Smrg # Check if any of the arguments is a wrapper script. 259365d490d0Smrg args= 259465d490d0Smrg for file 259565d490d0Smrg do 259665d490d0Smrg case $file in 259765d490d0Smrg -* | *.la | *.lo ) ;; 259865d490d0Smrg *) 259965d490d0Smrg # Do a test to see if this is really a libtool program. 260065d490d0Smrg if func_ltwrapper_script_p "$file"; then 260165d490d0Smrg func_source "$file" 260265d490d0Smrg # Transform arg to wrapped name. 260365d490d0Smrg file="$progdir/$program" 260465d490d0Smrg elif func_ltwrapper_executable_p "$file"; then 260565d490d0Smrg func_ltwrapper_scriptname "$file" 260665d490d0Smrg func_source "$func_ltwrapper_scriptname_result" 260765d490d0Smrg # Transform arg to wrapped name. 260865d490d0Smrg file="$progdir/$program" 260965d490d0Smrg fi 261065d490d0Smrg ;; 261165d490d0Smrg esac 261265d490d0Smrg # Quote arguments (to preserve shell metacharacters). 261365d490d0Smrg func_append_quoted args "$file" 261465d490d0Smrg done 261565d490d0Smrg 261665d490d0Smrg if test "X$opt_dry_run" = Xfalse; then 261765d490d0Smrg if test -n "$shlibpath_var"; then 261865d490d0Smrg # Export the shlibpath_var. 261965d490d0Smrg eval "export $shlibpath_var" 2620e4da13eeSmacallan fi 262165d490d0Smrg 262265d490d0Smrg # Restore saved environment variables 262365d490d0Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 262465d490d0Smrg do 262565d490d0Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 262665d490d0Smrg $lt_var=\$save_$lt_var; export $lt_var 262765d490d0Smrg else 262865d490d0Smrg $lt_unset $lt_var 262965d490d0Smrg fi" 263065d490d0Smrg done 263165d490d0Smrg 263265d490d0Smrg # Now prepare to actually exec the command. 263365d490d0Smrg exec_cmd="\$cmd$args" 263465d490d0Smrg else 263565d490d0Smrg # Display what would be done. 263665d490d0Smrg if test -n "$shlibpath_var"; then 263765d490d0Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 263865d490d0Smrg echo "export $shlibpath_var" 2639e4da13eeSmacallan fi 264065d490d0Smrg $ECHO "$cmd$args" 264165d490d0Smrg exit $EXIT_SUCCESS 264265d490d0Smrg fi 264365d490d0Smrg} 2644e4da13eeSmacallan 264565d490d0Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 2646e4da13eeSmacallan 2647e4da13eeSmacallan 264865d490d0Smrg# func_mode_finish arg... 264965d490d0Smrgfunc_mode_finish () 265065d490d0Smrg{ 265165d490d0Smrg $opt_debug 265265d490d0Smrg libs= 265365d490d0Smrg libdirs= 265465d490d0Smrg admincmds= 2655e4da13eeSmacallan 265665d490d0Smrg for opt in "$nonopt" ${1+"$@"} 265765d490d0Smrg do 265865d490d0Smrg if test -d "$opt"; then 265965d490d0Smrg func_append libdirs " $opt" 2660e4da13eeSmacallan 266165d490d0Smrg elif test -f "$opt"; then 266265d490d0Smrg if func_lalib_unsafe_p "$opt"; then 266365d490d0Smrg func_append libs " $opt" 266465d490d0Smrg else 266565d490d0Smrg func_warning "\`$opt' is not a valid libtool archive" 2666e4da13eeSmacallan fi 2667e4da13eeSmacallan 266865d490d0Smrg else 266965d490d0Smrg func_fatal_error "invalid argument \`$opt'" 267065d490d0Smrg fi 267165d490d0Smrg done 2672e4da13eeSmacallan 267365d490d0Smrg if test -n "$libs"; then 267465d490d0Smrg if test -n "$lt_sysroot"; then 267565d490d0Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 267665d490d0Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 267765d490d0Smrg else 267865d490d0Smrg sysroot_cmd= 267965d490d0Smrg fi 2680e4da13eeSmacallan 268165d490d0Smrg # Remove sysroot references 268265d490d0Smrg if $opt_dry_run; then 268365d490d0Smrg for lib in $libs; do 268465d490d0Smrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 268565d490d0Smrg done 268665d490d0Smrg else 268765d490d0Smrg tmpdir=`func_mktempdir` 268865d490d0Smrg for lib in $libs; do 268965d490d0Smrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 269065d490d0Smrg > $tmpdir/tmp-la 269165d490d0Smrg mv -f $tmpdir/tmp-la $lib 2692e4da13eeSmacallan done 269365d490d0Smrg ${RM}r "$tmpdir" 269465d490d0Smrg fi 269565d490d0Smrg fi 269665d490d0Smrg 269765d490d0Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 269865d490d0Smrg for libdir in $libdirs; do 269965d490d0Smrg if test -n "$finish_cmds"; then 270065d490d0Smrg # Do each command in the finish commands. 270165d490d0Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 270265d490d0Smrg'"$cmd"'"' 2703e4da13eeSmacallan fi 270465d490d0Smrg if test -n "$finish_eval"; then 270565d490d0Smrg # Do the single finish_eval. 270665d490d0Smrg eval cmds=\"$finish_eval\" 270765d490d0Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 270865d490d0Smrg $cmds" 270965d490d0Smrg fi 271065d490d0Smrg done 271165d490d0Smrg fi 2712e4da13eeSmacallan 271365d490d0Smrg # Exit here if they wanted silent mode. 271465d490d0Smrg $opt_silent && exit $EXIT_SUCCESS 2715e4da13eeSmacallan 271665d490d0Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 271765d490d0Smrg echo "----------------------------------------------------------------------" 271865d490d0Smrg echo "Libraries have been installed in:" 271965d490d0Smrg for libdir in $libdirs; do 272065d490d0Smrg $ECHO " $libdir" 272165d490d0Smrg done 272265d490d0Smrg echo 272365d490d0Smrg echo "If you ever happen to want to link against installed libraries" 272465d490d0Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 272565d490d0Smrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 272665d490d0Smrg echo "flag during linking and do at least one of the following:" 272765d490d0Smrg if test -n "$shlibpath_var"; then 272865d490d0Smrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 272965d490d0Smrg echo " during execution" 273065d490d0Smrg fi 273165d490d0Smrg if test -n "$runpath_var"; then 273265d490d0Smrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 273365d490d0Smrg echo " during linking" 273465d490d0Smrg fi 273565d490d0Smrg if test -n "$hardcode_libdir_flag_spec"; then 273665d490d0Smrg libdir=LIBDIR 273765d490d0Smrg eval flag=\"$hardcode_libdir_flag_spec\" 273865d490d0Smrg 273965d490d0Smrg $ECHO " - use the \`$flag' linker flag" 274065d490d0Smrg fi 274165d490d0Smrg if test -n "$admincmds"; then 274265d490d0Smrg $ECHO " - have your system administrator run these commands:$admincmds" 274365d490d0Smrg fi 274465d490d0Smrg if test -f /etc/ld.so.conf; then 274565d490d0Smrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 274665d490d0Smrg fi 274765d490d0Smrg echo 274865d490d0Smrg 274965d490d0Smrg echo "See any operating system documentation about shared libraries for" 275065d490d0Smrg case $host in 275165d490d0Smrg solaris2.[6789]|solaris2.1[0-9]) 275265d490d0Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 275365d490d0Smrg echo "pages." 275465d490d0Smrg ;; 2755e4da13eeSmacallan *) 275665d490d0Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 2757e4da13eeSmacallan ;; 275865d490d0Smrg esac 275965d490d0Smrg echo "----------------------------------------------------------------------" 276065d490d0Smrg fi 276165d490d0Smrg exit $EXIT_SUCCESS 276265d490d0Smrg} 2763e4da13eeSmacallan 276465d490d0Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 2765e4da13eeSmacallan 276665d490d0Smrg 276765d490d0Smrg# func_mode_install arg... 276865d490d0Smrgfunc_mode_install () 276965d490d0Smrg{ 277065d490d0Smrg $opt_debug 277165d490d0Smrg # There may be an optional sh(1) argument at the beginning of 277265d490d0Smrg # install_prog (especially on Windows NT). 277365d490d0Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 277465d490d0Smrg # Allow the use of GNU shtool's install command. 277565d490d0Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 277665d490d0Smrg # Aesthetically quote it. 277765d490d0Smrg func_quote_for_eval "$nonopt" 277865d490d0Smrg install_prog="$func_quote_for_eval_result " 277965d490d0Smrg arg=$1 278065d490d0Smrg shift 278165d490d0Smrg else 278265d490d0Smrg install_prog= 278365d490d0Smrg arg=$nonopt 278465d490d0Smrg fi 278565d490d0Smrg 278665d490d0Smrg # The real first argument should be the name of the installation program. 278765d490d0Smrg # Aesthetically quote it. 278865d490d0Smrg func_quote_for_eval "$arg" 278965d490d0Smrg func_append install_prog "$func_quote_for_eval_result" 279065d490d0Smrg install_shared_prog=$install_prog 279165d490d0Smrg case " $install_prog " in 279265d490d0Smrg *[\\\ /]cp\ *) install_cp=: ;; 279365d490d0Smrg *) install_cp=false ;; 279465d490d0Smrg esac 279565d490d0Smrg 279665d490d0Smrg # We need to accept at least all the BSD install flags. 279765d490d0Smrg dest= 279865d490d0Smrg files= 279965d490d0Smrg opts= 280065d490d0Smrg prev= 280165d490d0Smrg install_type= 280265d490d0Smrg isdir=no 280365d490d0Smrg stripme= 280465d490d0Smrg no_mode=: 280565d490d0Smrg for arg 280665d490d0Smrg do 280765d490d0Smrg arg2= 280865d490d0Smrg if test -n "$dest"; then 280965d490d0Smrg func_append files " $dest" 281065d490d0Smrg dest=$arg 281165d490d0Smrg continue 281265d490d0Smrg fi 281365d490d0Smrg 281465d490d0Smrg case $arg in 281565d490d0Smrg -d) isdir=yes ;; 281665d490d0Smrg -f) 281765d490d0Smrg if $install_cp; then :; else 281865d490d0Smrg prev=$arg 281965d490d0Smrg fi 282065d490d0Smrg ;; 282165d490d0Smrg -g | -m | -o) 282265d490d0Smrg prev=$arg 282365d490d0Smrg ;; 282465d490d0Smrg -s) 282565d490d0Smrg stripme=" -s" 282665d490d0Smrg continue 282765d490d0Smrg ;; 282865d490d0Smrg -*) 282965d490d0Smrg ;; 283065d490d0Smrg *) 283165d490d0Smrg # If the previous option needed an argument, then skip it. 283265d490d0Smrg if test -n "$prev"; then 283365d490d0Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 283465d490d0Smrg arg2=$install_override_mode 283565d490d0Smrg no_mode=false 2836e4da13eeSmacallan fi 283765d490d0Smrg prev= 283865d490d0Smrg else 283965d490d0Smrg dest=$arg 2840e4da13eeSmacallan continue 2841e4da13eeSmacallan fi 284265d490d0Smrg ;; 284365d490d0Smrg esac 2844e4da13eeSmacallan 284565d490d0Smrg # Aesthetically quote the argument. 284665d490d0Smrg func_quote_for_eval "$arg" 284765d490d0Smrg func_append install_prog " $func_quote_for_eval_result" 284865d490d0Smrg if test -n "$arg2"; then 284965d490d0Smrg func_quote_for_eval "$arg2" 285065d490d0Smrg fi 285165d490d0Smrg func_append install_shared_prog " $func_quote_for_eval_result" 285265d490d0Smrg done 2853e4da13eeSmacallan 285465d490d0Smrg test -z "$install_prog" && \ 285565d490d0Smrg func_fatal_help "you must specify an install program" 2856e4da13eeSmacallan 285765d490d0Smrg test -n "$prev" && \ 285865d490d0Smrg func_fatal_help "the \`$prev' option requires an argument" 2859e4da13eeSmacallan 286065d490d0Smrg if test -n "$install_override_mode" && $no_mode; then 286165d490d0Smrg if $install_cp; then :; else 286265d490d0Smrg func_quote_for_eval "$install_override_mode" 286365d490d0Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 286465d490d0Smrg fi 286565d490d0Smrg fi 2866e4da13eeSmacallan 286765d490d0Smrg if test -z "$files"; then 286865d490d0Smrg if test -z "$dest"; then 286965d490d0Smrg func_fatal_help "no file or destination specified" 287065d490d0Smrg else 287165d490d0Smrg func_fatal_help "you must specify a destination" 287265d490d0Smrg fi 287365d490d0Smrg fi 2874e4da13eeSmacallan 287565d490d0Smrg # Strip any trailing slash from the destination. 287665d490d0Smrg func_stripname '' '/' "$dest" 287765d490d0Smrg dest=$func_stripname_result 2878e4da13eeSmacallan 287965d490d0Smrg # Check to see that the destination is a directory. 288065d490d0Smrg test -d "$dest" && isdir=yes 288165d490d0Smrg if test "$isdir" = yes; then 288265d490d0Smrg destdir="$dest" 288365d490d0Smrg destname= 288465d490d0Smrg else 288565d490d0Smrg func_dirname_and_basename "$dest" "" "." 288665d490d0Smrg destdir="$func_dirname_result" 288765d490d0Smrg destname="$func_basename_result" 2888e4da13eeSmacallan 288965d490d0Smrg # Not a directory, so check to see that there is only one file specified. 289065d490d0Smrg set dummy $files; shift 289165d490d0Smrg test "$#" -gt 1 && \ 289265d490d0Smrg func_fatal_help "\`$dest' is not a directory" 289365d490d0Smrg fi 289465d490d0Smrg case $destdir in 289565d490d0Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 289665d490d0Smrg *) 289765d490d0Smrg for file in $files; do 289865d490d0Smrg case $file in 289965d490d0Smrg *.lo) ;; 290065d490d0Smrg *) 290165d490d0Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 290265d490d0Smrg ;; 290365d490d0Smrg esac 290465d490d0Smrg done 290565d490d0Smrg ;; 290665d490d0Smrg esac 2907e4da13eeSmacallan 290865d490d0Smrg # This variable tells wrapper scripts just to set variables rather 290965d490d0Smrg # than running their programs. 291065d490d0Smrg libtool_install_magic="$magic" 2911e4da13eeSmacallan 291265d490d0Smrg staticlibs= 291365d490d0Smrg future_libdirs= 291465d490d0Smrg current_libdirs= 291565d490d0Smrg for file in $files; do 2916e4da13eeSmacallan 291765d490d0Smrg # Do each installation. 291865d490d0Smrg case $file in 291965d490d0Smrg *.$libext) 292065d490d0Smrg # Do the static libraries later. 292165d490d0Smrg func_append staticlibs " $file" 292265d490d0Smrg ;; 2923e4da13eeSmacallan 292465d490d0Smrg *.la) 292565d490d0Smrg func_resolve_sysroot "$file" 292665d490d0Smrg file=$func_resolve_sysroot_result 2927e4da13eeSmacallan 292865d490d0Smrg # Check to see that this really is a libtool archive. 292965d490d0Smrg func_lalib_unsafe_p "$file" \ 293065d490d0Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 2931e4da13eeSmacallan 293265d490d0Smrg library_names= 293365d490d0Smrg old_library= 293465d490d0Smrg relink_command= 293565d490d0Smrg func_source "$file" 2936e4da13eeSmacallan 293765d490d0Smrg # Add the libdir to current_libdirs if it is the destination. 293865d490d0Smrg if test "X$destdir" = "X$libdir"; then 293965d490d0Smrg case "$current_libdirs " in 294065d490d0Smrg *" $libdir "*) ;; 294165d490d0Smrg *) func_append current_libdirs " $libdir" ;; 294265d490d0Smrg esac 294365d490d0Smrg else 294465d490d0Smrg # Note the libdir as a future libdir. 294565d490d0Smrg case "$future_libdirs " in 294665d490d0Smrg *" $libdir "*) ;; 294765d490d0Smrg *) func_append future_libdirs " $libdir" ;; 294865d490d0Smrg esac 294965d490d0Smrg fi 2950e4da13eeSmacallan 295165d490d0Smrg func_dirname "$file" "/" "" 295265d490d0Smrg dir="$func_dirname_result" 295365d490d0Smrg func_append dir "$objdir" 2954e4da13eeSmacallan 295565d490d0Smrg if test -n "$relink_command"; then 295665d490d0Smrg # Determine the prefix the user has applied to our future dir. 295765d490d0Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 2958e4da13eeSmacallan 295965d490d0Smrg # Don't allow the user to place us outside of our expected 296065d490d0Smrg # location b/c this prevents finding dependent libraries that 296165d490d0Smrg # are installed to the same prefix. 296265d490d0Smrg # At present, this check doesn't affect windows .dll's that 296365d490d0Smrg # are installed into $libdir/../bin (currently, that works fine) 296465d490d0Smrg # but it's something to keep an eye on. 296565d490d0Smrg test "$inst_prefix_dir" = "$destdir" && \ 296665d490d0Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 296765d490d0Smrg 296865d490d0Smrg if test -n "$inst_prefix_dir"; then 296965d490d0Smrg # Stick the inst_prefix_dir data into the link command. 297065d490d0Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 2971e4da13eeSmacallan else 297265d490d0Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 2973e4da13eeSmacallan fi 2974e4da13eeSmacallan 297565d490d0Smrg func_warning "relinking \`$file'" 297665d490d0Smrg func_show_eval "$relink_command" \ 297765d490d0Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 297865d490d0Smrg fi 297965d490d0Smrg 298065d490d0Smrg # See the names of the shared library. 298165d490d0Smrg set dummy $library_names; shift 298265d490d0Smrg if test -n "$1"; then 298365d490d0Smrg realname="$1" 298465d490d0Smrg shift 298565d490d0Smrg 298665d490d0Smrg srcname="$realname" 298765d490d0Smrg test -n "$relink_command" && srcname="$realname"T 298865d490d0Smrg 298965d490d0Smrg # Install the shared library and build the symlinks. 299065d490d0Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 299165d490d0Smrg 'exit $?' 299265d490d0Smrg tstripme="$stripme" 299365d490d0Smrg case $host_os in 299465d490d0Smrg cygwin* | mingw* | pw32* | cegcc*) 299565d490d0Smrg case $realname in 299665d490d0Smrg *.dll.a) 299765d490d0Smrg tstripme="" 299865d490d0Smrg ;; 299965d490d0Smrg esac 300065d490d0Smrg ;; 300165d490d0Smrg esac 300265d490d0Smrg if test -n "$tstripme" && test -n "$striplib"; then 300365d490d0Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 3004e4da13eeSmacallan fi 3005e4da13eeSmacallan 300665d490d0Smrg if test "$#" -gt 0; then 300765d490d0Smrg # Delete the old symlinks, and create new ones. 300865d490d0Smrg # Try `ln -sf' first, because the `ln' binary might depend on 300965d490d0Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 301065d490d0Smrg # so we also need to try rm && ln -s. 301165d490d0Smrg for linkname 301265d490d0Smrg do 301365d490d0Smrg test "$linkname" != "$realname" \ 301465d490d0Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 3015e4da13eeSmacallan done 3016e4da13eeSmacallan fi 3017e4da13eeSmacallan 301865d490d0Smrg # Do each command in the postinstall commands. 301965d490d0Smrg lib="$destdir/$realname" 302065d490d0Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 302165d490d0Smrg fi 3022e4da13eeSmacallan 302365d490d0Smrg # Install the pseudo-library for information purposes. 302465d490d0Smrg func_basename "$file" 302565d490d0Smrg name="$func_basename_result" 302665d490d0Smrg instname="$dir/$name"i 302765d490d0Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 3028e4da13eeSmacallan 302965d490d0Smrg # Maybe install the static library, too. 303065d490d0Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 303165d490d0Smrg ;; 303265d490d0Smrg 303365d490d0Smrg *.lo) 303465d490d0Smrg # Install (i.e. copy) a libtool object. 303565d490d0Smrg 303665d490d0Smrg # Figure out destination file name, if it wasn't already specified. 303765d490d0Smrg if test -n "$destname"; then 303865d490d0Smrg destfile="$destdir/$destname" 3039e4da13eeSmacallan else 304065d490d0Smrg func_basename "$file" 304165d490d0Smrg destfile="$func_basename_result" 304265d490d0Smrg destfile="$destdir/$destfile" 3043e4da13eeSmacallan fi 304465d490d0Smrg 304565d490d0Smrg # Deduce the name of the destination old-style object file. 304665d490d0Smrg case $destfile in 304765d490d0Smrg *.lo) 304865d490d0Smrg func_lo2o "$destfile" 304965d490d0Smrg staticdest=$func_lo2o_result 305065d490d0Smrg ;; 305165d490d0Smrg *.$objext) 305265d490d0Smrg staticdest="$destfile" 305365d490d0Smrg destfile= 305465d490d0Smrg ;; 305565d490d0Smrg *) 305665d490d0Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 3057e4da13eeSmacallan ;; 3058e4da13eeSmacallan esac 3059e4da13eeSmacallan 306065d490d0Smrg # Install the libtool object if requested. 306165d490d0Smrg test -n "$destfile" && \ 306265d490d0Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 3063e4da13eeSmacallan 306465d490d0Smrg # Install the old object if enabled. 306565d490d0Smrg if test "$build_old_libs" = yes; then 306665d490d0Smrg # Deduce the name of the old-style object file. 306765d490d0Smrg func_lo2o "$file" 306865d490d0Smrg staticobj=$func_lo2o_result 306965d490d0Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 307065d490d0Smrg fi 307165d490d0Smrg exit $EXIT_SUCCESS 307265d490d0Smrg ;; 3073e4da13eeSmacallan 307465d490d0Smrg *) 307565d490d0Smrg # Figure out destination file name, if it wasn't already specified. 307665d490d0Smrg if test -n "$destname"; then 307765d490d0Smrg destfile="$destdir/$destname" 307865d490d0Smrg else 307965d490d0Smrg func_basename "$file" 308065d490d0Smrg destfile="$func_basename_result" 308165d490d0Smrg destfile="$destdir/$destfile" 308265d490d0Smrg fi 3083e4da13eeSmacallan 308465d490d0Smrg # If the file is missing, and there is a .exe on the end, strip it 308565d490d0Smrg # because it is most likely a libtool script we actually want to 308665d490d0Smrg # install 308765d490d0Smrg stripped_ext="" 308865d490d0Smrg case $file in 308965d490d0Smrg *.exe) 309065d490d0Smrg if test ! -f "$file"; then 309165d490d0Smrg func_stripname '' '.exe' "$file" 309265d490d0Smrg file=$func_stripname_result 309365d490d0Smrg stripped_ext=".exe" 309465d490d0Smrg fi 309565d490d0Smrg ;; 309665d490d0Smrg esac 3097e4da13eeSmacallan 309865d490d0Smrg # Do a test to see if this is really a libtool program. 309965d490d0Smrg case $host in 310065d490d0Smrg *cygwin* | *mingw*) 310165d490d0Smrg if func_ltwrapper_executable_p "$file"; then 310265d490d0Smrg func_ltwrapper_scriptname "$file" 310365d490d0Smrg wrapper=$func_ltwrapper_scriptname_result 310465d490d0Smrg else 310565d490d0Smrg func_stripname '' '.exe' "$file" 310665d490d0Smrg wrapper=$func_stripname_result 310765d490d0Smrg fi 310865d490d0Smrg ;; 310965d490d0Smrg *) 311065d490d0Smrg wrapper=$file 311165d490d0Smrg ;; 311265d490d0Smrg esac 311365d490d0Smrg if func_ltwrapper_script_p "$wrapper"; then 311465d490d0Smrg notinst_deplibs= 311565d490d0Smrg relink_command= 3116e4da13eeSmacallan 311765d490d0Smrg func_source "$wrapper" 3118e4da13eeSmacallan 311965d490d0Smrg # Check the variables that should have been set. 312065d490d0Smrg test -z "$generated_by_libtool_version" && \ 312165d490d0Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 3122e4da13eeSmacallan 312365d490d0Smrg finalize=yes 312465d490d0Smrg for lib in $notinst_deplibs; do 312565d490d0Smrg # Check to see that each library is installed. 312665d490d0Smrg libdir= 312765d490d0Smrg if test -f "$lib"; then 312865d490d0Smrg func_source "$lib" 312965d490d0Smrg fi 313065d490d0Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 313165d490d0Smrg if test -n "$libdir" && test ! -f "$libfile"; then 313265d490d0Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 313365d490d0Smrg finalize=no 313465d490d0Smrg fi 313565d490d0Smrg done 3136e4da13eeSmacallan 313765d490d0Smrg relink_command= 313865d490d0Smrg func_source "$wrapper" 313965d490d0Smrg 314065d490d0Smrg outputname= 314165d490d0Smrg if test "$fast_install" = no && test -n "$relink_command"; then 314265d490d0Smrg $opt_dry_run || { 314365d490d0Smrg if test "$finalize" = yes; then 314465d490d0Smrg tmpdir=`func_mktempdir` 314565d490d0Smrg func_basename "$file$stripped_ext" 314665d490d0Smrg file="$func_basename_result" 314765d490d0Smrg outputname="$tmpdir/$file" 314865d490d0Smrg # Replace the output file specification. 314965d490d0Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 315065d490d0Smrg 315165d490d0Smrg $opt_silent || { 315265d490d0Smrg func_quote_for_expand "$relink_command" 315365d490d0Smrg eval "func_echo $func_quote_for_expand_result" 315465d490d0Smrg } 315565d490d0Smrg if eval "$relink_command"; then : 315665d490d0Smrg else 315765d490d0Smrg func_error "error: relink \`$file' with the above command before installing it" 315865d490d0Smrg $opt_dry_run || ${RM}r "$tmpdir" 315965d490d0Smrg continue 316065d490d0Smrg fi 316165d490d0Smrg file="$outputname" 316265d490d0Smrg else 316365d490d0Smrg func_warning "cannot relink \`$file'" 316465d490d0Smrg fi 316565d490d0Smrg } 316665d490d0Smrg else 316765d490d0Smrg # Install the binary that we compiled earlier. 316865d490d0Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 316965d490d0Smrg fi 3170e4da13eeSmacallan fi 317165d490d0Smrg 317265d490d0Smrg # remove .exe since cygwin /usr/bin/install will append another 317365d490d0Smrg # one anyway 317465d490d0Smrg case $install_prog,$host in 317565d490d0Smrg */usr/bin/install*,*cygwin*) 317665d490d0Smrg case $file:$destfile in 317765d490d0Smrg *.exe:*.exe) 317865d490d0Smrg # this is ok 317965d490d0Smrg ;; 318065d490d0Smrg *.exe:*) 318165d490d0Smrg destfile=$destfile.exe 318265d490d0Smrg ;; 318365d490d0Smrg *:*.exe) 318465d490d0Smrg func_stripname '' '.exe' "$destfile" 318565d490d0Smrg destfile=$func_stripname_result 318665d490d0Smrg ;; 318765d490d0Smrg esac 318865d490d0Smrg ;; 318965d490d0Smrg esac 319065d490d0Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 319165d490d0Smrg $opt_dry_run || if test -n "$outputname"; then 319265d490d0Smrg ${RM}r "$tmpdir" 3193e4da13eeSmacallan fi 3194e4da13eeSmacallan ;; 3195e4da13eeSmacallan esac 319665d490d0Smrg done 3197e4da13eeSmacallan 319865d490d0Smrg for file in $staticlibs; do 319965d490d0Smrg func_basename "$file" 320065d490d0Smrg name="$func_basename_result" 3201e4da13eeSmacallan 320265d490d0Smrg # Set up the ranlib parameters. 320365d490d0Smrg oldlib="$destdir/$name" 3204e4da13eeSmacallan 320565d490d0Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 320665d490d0Smrg 320765d490d0Smrg if test -n "$stripme" && test -n "$old_striplib"; then 320865d490d0Smrg func_show_eval "$old_striplib $oldlib" 'exit $?' 3209e4da13eeSmacallan fi 3210e4da13eeSmacallan 321165d490d0Smrg # Do each command in the postinstall commands. 321265d490d0Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 321365d490d0Smrg done 3214e4da13eeSmacallan 321565d490d0Smrg test -n "$future_libdirs" && \ 321665d490d0Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 3217e4da13eeSmacallan 321865d490d0Smrg if test -n "$current_libdirs"; then 321965d490d0Smrg # Maybe just do a dry run. 322065d490d0Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 322165d490d0Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 322265d490d0Smrg else 322365d490d0Smrg exit $EXIT_SUCCESS 322465d490d0Smrg fi 322565d490d0Smrg} 3226e4da13eeSmacallan 322765d490d0Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 3228e4da13eeSmacallan 3229e4da13eeSmacallan 323065d490d0Smrg# func_generate_dlsyms outputname originator pic_p 323165d490d0Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 323265d490d0Smrg# a dlpreopen symbol table. 323365d490d0Smrgfunc_generate_dlsyms () 323465d490d0Smrg{ 323565d490d0Smrg $opt_debug 323665d490d0Smrg my_outputname="$1" 323765d490d0Smrg my_originator="$2" 323865d490d0Smrg my_pic_p="${3-no}" 323965d490d0Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 324065d490d0Smrg my_dlsyms= 324165d490d0Smrg 324265d490d0Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 324365d490d0Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 324465d490d0Smrg my_dlsyms="${my_outputname}S.c" 324565d490d0Smrg else 324665d490d0Smrg func_error "not configured to extract global symbols from dlpreopened files" 324765d490d0Smrg fi 324865d490d0Smrg fi 3249e4da13eeSmacallan 325065d490d0Smrg if test -n "$my_dlsyms"; then 325165d490d0Smrg case $my_dlsyms in 325265d490d0Smrg "") ;; 325365d490d0Smrg *.c) 325465d490d0Smrg # Discover the nlist of each of the dlfiles. 325565d490d0Smrg nlist="$output_objdir/${my_outputname}.nm" 3256e4da13eeSmacallan 325765d490d0Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 3258e4da13eeSmacallan 325965d490d0Smrg # Parse the name list into a source file. 326065d490d0Smrg func_verbose "creating $output_objdir/$my_dlsyms" 3261e4da13eeSmacallan 326265d490d0Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 326365d490d0Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 326465d490d0Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 3265e4da13eeSmacallan 326665d490d0Smrg#ifdef __cplusplus 326765d490d0Smrgextern \"C\" { 326865d490d0Smrg#endif 3269e4da13eeSmacallan 327065d490d0Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 327165d490d0Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 327265d490d0Smrg#endif 3273e4da13eeSmacallan 327465d490d0Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 327565d490d0Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 327665d490d0Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 327765d490d0Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 327865d490d0Smrg# define LT_DLSYM_CONST 327965d490d0Smrg#elif defined(__osf__) 328065d490d0Smrg/* This system does not cope well with relocations in const data. */ 328165d490d0Smrg# define LT_DLSYM_CONST 328265d490d0Smrg#else 328365d490d0Smrg# define LT_DLSYM_CONST const 328465d490d0Smrg#endif 3285e4da13eeSmacallan 328665d490d0Smrg/* External symbol declarations for the compiler. */\ 328765d490d0Smrg" 3288e4da13eeSmacallan 328965d490d0Smrg if test "$dlself" = yes; then 329065d490d0Smrg func_verbose "generating symbol list for \`$output'" 3291e4da13eeSmacallan 329265d490d0Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 3293e4da13eeSmacallan 329465d490d0Smrg # Add our own program objects to the symbol list. 329565d490d0Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 329665d490d0Smrg for progfile in $progfiles; do 329765d490d0Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 329865d490d0Smrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 329965d490d0Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 3300e4da13eeSmacallan done 3301e4da13eeSmacallan 330265d490d0Smrg if test -n "$exclude_expsyms"; then 330365d490d0Smrg $opt_dry_run || { 330465d490d0Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 330565d490d0Smrg eval '$MV "$nlist"T "$nlist"' 330665d490d0Smrg } 330765d490d0Smrg fi 3308e4da13eeSmacallan 330965d490d0Smrg if test -n "$export_symbols_regex"; then 331065d490d0Smrg $opt_dry_run || { 331165d490d0Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 331265d490d0Smrg eval '$MV "$nlist"T "$nlist"' 331365d490d0Smrg } 331465d490d0Smrg fi 3315e4da13eeSmacallan 331665d490d0Smrg # Prepare the list of exported symbols 331765d490d0Smrg if test -z "$export_symbols"; then 331865d490d0Smrg export_symbols="$output_objdir/$outputname.exp" 331965d490d0Smrg $opt_dry_run || { 332065d490d0Smrg $RM $export_symbols 332165d490d0Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 332265d490d0Smrg case $host in 332365d490d0Smrg *cygwin* | *mingw* | *cegcc* ) 332465d490d0Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 332565d490d0Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 332665d490d0Smrg ;; 332765d490d0Smrg esac 332865d490d0Smrg } 332965d490d0Smrg else 333065d490d0Smrg $opt_dry_run || { 333165d490d0Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 333265d490d0Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 333365d490d0Smrg eval '$MV "$nlist"T "$nlist"' 333465d490d0Smrg case $host in 333565d490d0Smrg *cygwin* | *mingw* | *cegcc* ) 333665d490d0Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 333765d490d0Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 333865d490d0Smrg ;; 333965d490d0Smrg esac 334065d490d0Smrg } 334165d490d0Smrg fi 334265d490d0Smrg fi 3343e4da13eeSmacallan 334465d490d0Smrg for dlprefile in $dlprefiles; do 334565d490d0Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 334665d490d0Smrg func_basename "$dlprefile" 334765d490d0Smrg name="$func_basename_result" 334865d490d0Smrg case $host in 334965d490d0Smrg *cygwin* | *mingw* | *cegcc* ) 335065d490d0Smrg # if an import library, we need to obtain dlname 335165d490d0Smrg if func_win32_import_lib_p "$dlprefile"; then 335265d490d0Smrg func_tr_sh "$dlprefile" 335365d490d0Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 335465d490d0Smrg dlprefile_dlbasename="" 335565d490d0Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 335665d490d0Smrg # Use subshell, to avoid clobbering current variable values 335765d490d0Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 335865d490d0Smrg if test -n "$dlprefile_dlname" ; then 335965d490d0Smrg func_basename "$dlprefile_dlname" 336065d490d0Smrg dlprefile_dlbasename="$func_basename_result" 336165d490d0Smrg else 336265d490d0Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 336365d490d0Smrg $sharedlib_from_linklib_cmd "$dlprefile" 336465d490d0Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 336565d490d0Smrg fi 336665d490d0Smrg fi 336765d490d0Smrg $opt_dry_run || { 336865d490d0Smrg if test -n "$dlprefile_dlbasename" ; then 336965d490d0Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 337065d490d0Smrg else 337165d490d0Smrg func_warning "Could not compute DLL name from $name" 337265d490d0Smrg eval '$ECHO ": $name " >> "$nlist"' 337365d490d0Smrg fi 337465d490d0Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 337565d490d0Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 337665d490d0Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 337765d490d0Smrg } 337865d490d0Smrg else # not an import lib 337965d490d0Smrg $opt_dry_run || { 338065d490d0Smrg eval '$ECHO ": $name " >> "$nlist"' 338165d490d0Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 338265d490d0Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 338365d490d0Smrg } 338465d490d0Smrg fi 338565d490d0Smrg ;; 338665d490d0Smrg *) 338765d490d0Smrg $opt_dry_run || { 338865d490d0Smrg eval '$ECHO ": $name " >> "$nlist"' 338965d490d0Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 339065d490d0Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 339165d490d0Smrg } 339265d490d0Smrg ;; 339365d490d0Smrg esac 339465d490d0Smrg done 3395e4da13eeSmacallan 339665d490d0Smrg $opt_dry_run || { 339765d490d0Smrg # Make sure we have at least an empty file. 339865d490d0Smrg test -f "$nlist" || : > "$nlist" 3399e4da13eeSmacallan 340065d490d0Smrg if test -n "$exclude_expsyms"; then 340165d490d0Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 340265d490d0Smrg $MV "$nlist"T "$nlist" 340365d490d0Smrg fi 3404e4da13eeSmacallan 340565d490d0Smrg # Try sorting and uniquifying the output. 340665d490d0Smrg if $GREP -v "^: " < "$nlist" | 340765d490d0Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 340865d490d0Smrg sort -k 3 340965d490d0Smrg else 341065d490d0Smrg sort +2 341165d490d0Smrg fi | 341265d490d0Smrg uniq > "$nlist"S; then 341365d490d0Smrg : 341465d490d0Smrg else 341565d490d0Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 341665d490d0Smrg fi 3417e4da13eeSmacallan 341865d490d0Smrg if test -f "$nlist"S; then 341965d490d0Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 342065d490d0Smrg else 342165d490d0Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 342265d490d0Smrg fi 3423e4da13eeSmacallan 342465d490d0Smrg echo >> "$output_objdir/$my_dlsyms" "\ 342565d490d0Smrg 342665d490d0Smrg/* The mapping between symbol names and symbols. */ 342765d490d0Smrgtypedef struct { 342865d490d0Smrg const char *name; 342965d490d0Smrg void *address; 343065d490d0Smrg} lt_dlsymlist; 343165d490d0Smrgextern LT_DLSYM_CONST lt_dlsymlist 343265d490d0Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 343365d490d0SmrgLT_DLSYM_CONST lt_dlsymlist 343465d490d0Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 343565d490d0Smrg{\ 343665d490d0Smrg { \"$my_originator\", (void *) 0 }," 343765d490d0Smrg 343865d490d0Smrg case $need_lib_prefix in 343965d490d0Smrg no) 344065d490d0Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 3441e4da13eeSmacallan ;; 3442e4da13eeSmacallan *) 344365d490d0Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 3444e4da13eeSmacallan ;; 3445e4da13eeSmacallan esac 344665d490d0Smrg echo >> "$output_objdir/$my_dlsyms" "\ 344765d490d0Smrg {0, (void *) 0} 344865d490d0Smrg}; 3449e4da13eeSmacallan 345065d490d0Smrg/* This works around a problem in FreeBSD linker */ 345165d490d0Smrg#ifdef FREEBSD_WORKAROUND 345265d490d0Smrgstatic const void *lt_preloaded_setup() { 345365d490d0Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 345465d490d0Smrg} 345565d490d0Smrg#endif 3456e4da13eeSmacallan 345765d490d0Smrg#ifdef __cplusplus 345865d490d0Smrg} 345965d490d0Smrg#endif\ 346065d490d0Smrg" 346165d490d0Smrg } # !$opt_dry_run 3462e4da13eeSmacallan 346365d490d0Smrg pic_flag_for_symtable= 346465d490d0Smrg case "$compile_command " in 346565d490d0Smrg *" -static "*) ;; 346665d490d0Smrg *) 346765d490d0Smrg case $host in 346865d490d0Smrg # compiling the symbol table file with pic_flag works around 346965d490d0Smrg # a FreeBSD bug that causes programs to crash when -lm is 347065d490d0Smrg # linked before any other PIC object. But we must not use 347165d490d0Smrg # pic_flag when linking with -static. The problem exists in 347265d490d0Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 347365d490d0Smrg *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 347465d490d0Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 347565d490d0Smrg *-*-hpux*) 347665d490d0Smrg pic_flag_for_symtable=" $pic_flag" ;; 347765d490d0Smrg *) 347865d490d0Smrg if test "X$my_pic_p" != Xno; then 347965d490d0Smrg pic_flag_for_symtable=" $pic_flag" 348065d490d0Smrg fi 348165d490d0Smrg ;; 348265d490d0Smrg esac 348365d490d0Smrg ;; 348465d490d0Smrg esac 348565d490d0Smrg symtab_cflags= 348665d490d0Smrg for arg in $LTCFLAGS; do 348765d490d0Smrg case $arg in 348865d490d0Smrg -pie | -fpie | -fPIE) ;; 348965d490d0Smrg *) func_append symtab_cflags " $arg" ;; 3490e4da13eeSmacallan esac 3491e4da13eeSmacallan done 3492e4da13eeSmacallan 349365d490d0Smrg # Now compile the dynamic symbol file. 349465d490d0Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 3495e4da13eeSmacallan 349665d490d0Smrg # Clean up the generated files. 349765d490d0Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 3498e4da13eeSmacallan 349965d490d0Smrg # Transform the symbol file into the correct name. 350065d490d0Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 350165d490d0Smrg case $host in 350265d490d0Smrg *cygwin* | *mingw* | *cegcc* ) 350365d490d0Smrg if test -f "$output_objdir/$my_outputname.def"; then 350465d490d0Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 350565d490d0Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 350665d490d0Smrg else 350765d490d0Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 350865d490d0Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 350965d490d0Smrg fi 351065d490d0Smrg ;; 351165d490d0Smrg *) 351265d490d0Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351365d490d0Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351465d490d0Smrg ;; 351565d490d0Smrg esac 351665d490d0Smrg ;; 351765d490d0Smrg *) 351865d490d0Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 351965d490d0Smrg ;; 352065d490d0Smrg esac 352165d490d0Smrg else 352265d490d0Smrg # We keep going just in case the user didn't refer to 352365d490d0Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 352465d490d0Smrg # really was required. 3525e4da13eeSmacallan 352665d490d0Smrg # Nullify the symbol file. 352765d490d0Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 352865d490d0Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 352965d490d0Smrg fi 353065d490d0Smrg} 3531e4da13eeSmacallan 353265d490d0Smrg# func_win32_libid arg 353365d490d0Smrg# return the library type of file 'arg' 353465d490d0Smrg# 353565d490d0Smrg# Need a lot of goo to handle *both* DLLs and import libs 353665d490d0Smrg# Has to be a shell function in order to 'eat' the argument 353765d490d0Smrg# that is supplied when $file_magic_command is called. 353865d490d0Smrg# Despite the name, also deal with 64 bit binaries. 353965d490d0Smrgfunc_win32_libid () 354065d490d0Smrg{ 354165d490d0Smrg $opt_debug 354265d490d0Smrg win32_libid_type="unknown" 354365d490d0Smrg win32_fileres=`file -L $1 2>/dev/null` 354465d490d0Smrg case $win32_fileres in 354565d490d0Smrg *ar\ archive\ import\ library*) # definitely import 354665d490d0Smrg win32_libid_type="x86 archive import" 354765d490d0Smrg ;; 354865d490d0Smrg *ar\ archive*) # could be an import, or static 354965d490d0Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 355065d490d0Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 355165d490d0Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 355265d490d0Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 355365d490d0Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 355465d490d0Smrg $SED -n -e ' 355565d490d0Smrg 1,100{ 355665d490d0Smrg / I /{ 355765d490d0Smrg s,.*,import, 355865d490d0Smrg p 355965d490d0Smrg q 356065d490d0Smrg } 356165d490d0Smrg }'` 356265d490d0Smrg case $win32_nmres in 356365d490d0Smrg import*) win32_libid_type="x86 archive import";; 356465d490d0Smrg *) win32_libid_type="x86 archive static";; 356565d490d0Smrg esac 356665d490d0Smrg fi 356765d490d0Smrg ;; 356865d490d0Smrg *DLL*) 356965d490d0Smrg win32_libid_type="x86 DLL" 357065d490d0Smrg ;; 357165d490d0Smrg *executable*) # but shell scripts are "executable" too... 357265d490d0Smrg case $win32_fileres in 357365d490d0Smrg *MS\ Windows\ PE\ Intel*) 357465d490d0Smrg win32_libid_type="x86 DLL" 357565d490d0Smrg ;; 357665d490d0Smrg esac 357765d490d0Smrg ;; 357865d490d0Smrg esac 357965d490d0Smrg $ECHO "$win32_libid_type" 358065d490d0Smrg} 358165d490d0Smrg 358265d490d0Smrg# func_cygming_dll_for_implib ARG 358365d490d0Smrg# 358465d490d0Smrg# Platform-specific function to extract the 358565d490d0Smrg# name of the DLL associated with the specified 358665d490d0Smrg# import library ARG. 358765d490d0Smrg# Invoked by eval'ing the libtool variable 358865d490d0Smrg# $sharedlib_from_linklib_cmd 358965d490d0Smrg# Result is available in the variable 359065d490d0Smrg# $sharedlib_from_linklib_result 359165d490d0Smrgfunc_cygming_dll_for_implib () 359265d490d0Smrg{ 359365d490d0Smrg $opt_debug 359465d490d0Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 359565d490d0Smrg} 359665d490d0Smrg 359765d490d0Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 359865d490d0Smrg# 359965d490d0Smrg# The is the core of a fallback implementation of a 360065d490d0Smrg# platform-specific function to extract the name of the 360165d490d0Smrg# DLL associated with the specified import library LIBNAME. 360265d490d0Smrg# 360365d490d0Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 360465d490d0Smrg# on the platform and compiler that created the implib. 360565d490d0Smrg# 360665d490d0Smrg# Echos the name of the DLL associated with the 360765d490d0Smrg# specified import library. 360865d490d0Smrgfunc_cygming_dll_for_implib_fallback_core () 360965d490d0Smrg{ 361065d490d0Smrg $opt_debug 361165d490d0Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 361265d490d0Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 361365d490d0Smrg $SED '/^Contents of section '"$match_literal"':/{ 361465d490d0Smrg # Place marker at beginning of archive member dllname section 361565d490d0Smrg s/.*/====MARK====/ 361665d490d0Smrg p 361765d490d0Smrg d 361865d490d0Smrg } 361965d490d0Smrg # These lines can sometimes be longer than 43 characters, but 362065d490d0Smrg # are always uninteresting 362165d490d0Smrg /:[ ]*file format pe[i]\{,1\}-/d 362265d490d0Smrg /^In archive [^:]*:/d 362365d490d0Smrg # Ensure marker is printed 362465d490d0Smrg /^====MARK====/p 362565d490d0Smrg # Remove all lines with less than 43 characters 362665d490d0Smrg /^.\{43\}/!d 362765d490d0Smrg # From remaining lines, remove first 43 characters 362865d490d0Smrg s/^.\{43\}//' | 362965d490d0Smrg $SED -n ' 363065d490d0Smrg # Join marker and all lines until next marker into a single line 363165d490d0Smrg /^====MARK====/ b para 363265d490d0Smrg H 363365d490d0Smrg $ b para 363465d490d0Smrg b 363565d490d0Smrg :para 363665d490d0Smrg x 363765d490d0Smrg s/\n//g 363865d490d0Smrg # Remove the marker 363965d490d0Smrg s/^====MARK====// 364065d490d0Smrg # Remove trailing dots and whitespace 364165d490d0Smrg s/[\. \t]*$// 364265d490d0Smrg # Print 364365d490d0Smrg /./p' | 364465d490d0Smrg # we now have a list, one entry per line, of the stringified 364565d490d0Smrg # contents of the appropriate section of all members of the 364665d490d0Smrg # archive which possess that section. Heuristic: eliminate 364765d490d0Smrg # all those which have a first or second character that is 364865d490d0Smrg # a '.' (that is, objdump's representation of an unprintable 364965d490d0Smrg # character.) This should work for all archives with less than 365065d490d0Smrg # 0x302f exports -- but will fail for DLLs whose name actually 365165d490d0Smrg # begins with a literal '.' or a single character followed by 365265d490d0Smrg # a '.'. 365365d490d0Smrg # 365465d490d0Smrg # Of those that remain, print the first one. 365565d490d0Smrg $SED -e '/^\./d;/^.\./d;q' 365665d490d0Smrg} 365765d490d0Smrg 365865d490d0Smrg# func_cygming_gnu_implib_p ARG 365965d490d0Smrg# This predicate returns with zero status (TRUE) if 366065d490d0Smrg# ARG is a GNU/binutils-style import library. Returns 366165d490d0Smrg# with nonzero status (FALSE) otherwise. 366265d490d0Smrgfunc_cygming_gnu_implib_p () 366365d490d0Smrg{ 366465d490d0Smrg $opt_debug 366565d490d0Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 366665d490d0Smrg 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)$'` 366765d490d0Smrg test -n "$func_cygming_gnu_implib_tmp" 366865d490d0Smrg} 366965d490d0Smrg 367065d490d0Smrg# func_cygming_ms_implib_p ARG 367165d490d0Smrg# This predicate returns with zero status (TRUE) if 367265d490d0Smrg# ARG is an MS-style import library. Returns 367365d490d0Smrg# with nonzero status (FALSE) otherwise. 367465d490d0Smrgfunc_cygming_ms_implib_p () 367565d490d0Smrg{ 367665d490d0Smrg $opt_debug 367765d490d0Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 367865d490d0Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 367965d490d0Smrg test -n "$func_cygming_ms_implib_tmp" 368065d490d0Smrg} 368165d490d0Smrg 368265d490d0Smrg# func_cygming_dll_for_implib_fallback ARG 368365d490d0Smrg# Platform-specific function to extract the 368465d490d0Smrg# name of the DLL associated with the specified 368565d490d0Smrg# import library ARG. 368665d490d0Smrg# 368765d490d0Smrg# This fallback implementation is for use when $DLLTOOL 368865d490d0Smrg# does not support the --identify-strict option. 368965d490d0Smrg# Invoked by eval'ing the libtool variable 369065d490d0Smrg# $sharedlib_from_linklib_cmd 369165d490d0Smrg# Result is available in the variable 369265d490d0Smrg# $sharedlib_from_linklib_result 369365d490d0Smrgfunc_cygming_dll_for_implib_fallback () 369465d490d0Smrg{ 369565d490d0Smrg $opt_debug 369665d490d0Smrg if func_cygming_gnu_implib_p "$1" ; then 369765d490d0Smrg # binutils import library 369865d490d0Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 369965d490d0Smrg elif func_cygming_ms_implib_p "$1" ; then 370065d490d0Smrg # ms-generated import library 370165d490d0Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 370265d490d0Smrg else 370365d490d0Smrg # unknown 370465d490d0Smrg sharedlib_from_linklib_result="" 370565d490d0Smrg fi 370665d490d0Smrg} 370765d490d0Smrg 370865d490d0Smrg 370965d490d0Smrg# func_extract_an_archive dir oldlib 371065d490d0Smrgfunc_extract_an_archive () 371165d490d0Smrg{ 371265d490d0Smrg $opt_debug 371365d490d0Smrg f_ex_an_ar_dir="$1"; shift 371465d490d0Smrg f_ex_an_ar_oldlib="$1" 371565d490d0Smrg if test "$lock_old_archive_extraction" = yes; then 371665d490d0Smrg lockfile=$f_ex_an_ar_oldlib.lock 371765d490d0Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 371865d490d0Smrg func_echo "Waiting for $lockfile to be removed" 371965d490d0Smrg sleep 2 3720e4da13eeSmacallan done 372165d490d0Smrg fi 372265d490d0Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 372365d490d0Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 372465d490d0Smrg if test "$lock_old_archive_extraction" = yes; then 372565d490d0Smrg $opt_dry_run || rm -f "$lockfile" 372665d490d0Smrg fi 372765d490d0Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 372865d490d0Smrg : 372965d490d0Smrg else 373065d490d0Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 373165d490d0Smrg fi 373265d490d0Smrg} 3733e4da13eeSmacallan 373465d490d0Smrg 373565d490d0Smrg# func_extract_archives gentop oldlib ... 373665d490d0Smrgfunc_extract_archives () 373765d490d0Smrg{ 373865d490d0Smrg $opt_debug 373965d490d0Smrg my_gentop="$1"; shift 374065d490d0Smrg my_oldlibs=${1+"$@"} 374165d490d0Smrg my_oldobjs="" 374265d490d0Smrg my_xlib="" 374365d490d0Smrg my_xabs="" 374465d490d0Smrg my_xdir="" 374565d490d0Smrg 374665d490d0Smrg for my_xlib in $my_oldlibs; do 374765d490d0Smrg # Extract the objects. 374865d490d0Smrg case $my_xlib in 374965d490d0Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 375065d490d0Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 375165d490d0Smrg esac 375265d490d0Smrg func_basename "$my_xlib" 375365d490d0Smrg my_xlib="$func_basename_result" 375465d490d0Smrg my_xlib_u=$my_xlib 375565d490d0Smrg while :; do 375665d490d0Smrg case " $extracted_archives " in 375765d490d0Smrg *" $my_xlib_u "*) 375865d490d0Smrg func_arith $extracted_serial + 1 375965d490d0Smrg extracted_serial=$func_arith_result 376065d490d0Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 376165d490d0Smrg *) break ;; 3762e4da13eeSmacallan esac 3763e4da13eeSmacallan done 376465d490d0Smrg extracted_archives="$extracted_archives $my_xlib_u" 376565d490d0Smrg my_xdir="$my_gentop/$my_xlib_u" 3766e4da13eeSmacallan 376765d490d0Smrg func_mkdir_p "$my_xdir" 3768e4da13eeSmacallan 376965d490d0Smrg case $host in 377065d490d0Smrg *-darwin*) 377165d490d0Smrg func_verbose "Extracting $my_xabs" 377265d490d0Smrg # Do not bother doing anything if just a dry run 377365d490d0Smrg $opt_dry_run || { 377465d490d0Smrg darwin_orig_dir=`pwd` 377565d490d0Smrg cd $my_xdir || exit $? 377665d490d0Smrg darwin_archive=$my_xabs 377765d490d0Smrg darwin_curdir=`pwd` 377865d490d0Smrg darwin_base_archive=`basename "$darwin_archive"` 377965d490d0Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 378065d490d0Smrg if test -n "$darwin_arches"; then 378165d490d0Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 378265d490d0Smrg darwin_arch= 378365d490d0Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 378465d490d0Smrg for darwin_arch in $darwin_arches ; do 378565d490d0Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 378665d490d0Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 378765d490d0Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 378865d490d0Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 378965d490d0Smrg cd "$darwin_curdir" 379065d490d0Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 379165d490d0Smrg done # $darwin_arches 379265d490d0Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 379365d490d0Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 379465d490d0Smrg darwin_file= 379565d490d0Smrg darwin_files= 379665d490d0Smrg for darwin_file in $darwin_filelist; do 379765d490d0Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 379865d490d0Smrg $LIPO -create -output "$darwin_file" $darwin_files 379965d490d0Smrg done # $darwin_filelist 380065d490d0Smrg $RM -rf unfat-$$ 380165d490d0Smrg cd "$darwin_orig_dir" 3802e4da13eeSmacallan else 380365d490d0Smrg cd $darwin_orig_dir 380465d490d0Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 380565d490d0Smrg fi # $darwin_arches 380665d490d0Smrg } # !$opt_dry_run 380765d490d0Smrg ;; 380865d490d0Smrg *) 380965d490d0Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 381065d490d0Smrg ;; 381165d490d0Smrg esac 381265d490d0Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 381365d490d0Smrg done 3814e4da13eeSmacallan 381565d490d0Smrg func_extract_archives_result="$my_oldobjs" 381665d490d0Smrg} 3817e4da13eeSmacallan 3818e4da13eeSmacallan 381965d490d0Smrg# func_emit_wrapper [arg=no] 382065d490d0Smrg# 382165d490d0Smrg# Emit a libtool wrapper script on stdout. 382265d490d0Smrg# Don't directly open a file because we may want to 382365d490d0Smrg# incorporate the script contents within a cygwin/mingw 382465d490d0Smrg# wrapper executable. Must ONLY be called from within 382565d490d0Smrg# func_mode_link because it depends on a number of variables 382665d490d0Smrg# set therein. 382765d490d0Smrg# 382865d490d0Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 382965d490d0Smrg# variable will take. If 'yes', then the emitted script 383065d490d0Smrg# will assume that the directory in which it is stored is 383165d490d0Smrg# the $objdir directory. This is a cygwin/mingw-specific 383265d490d0Smrg# behavior. 383365d490d0Smrgfunc_emit_wrapper () 383465d490d0Smrg{ 383565d490d0Smrg func_emit_wrapper_arg1=${1-no} 3836e4da13eeSmacallan 383765d490d0Smrg $ECHO "\ 383865d490d0Smrg#! $SHELL 3839e4da13eeSmacallan 384065d490d0Smrg# $output - temporary wrapper script for $objdir/$outputname 384165d490d0Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 384265d490d0Smrg# 384365d490d0Smrg# The $output program cannot be directly executed until all the libtool 384465d490d0Smrg# libraries that it depends on are installed. 384565d490d0Smrg# 384665d490d0Smrg# This wrapper script should never be moved out of the build directory. 384765d490d0Smrg# If it is, it will not operate correctly. 3848e4da13eeSmacallan 384965d490d0Smrg# Sed substitution that helps us do robust quoting. It backslashifies 385065d490d0Smrg# metacharacters that are still active within double-quoted strings. 385165d490d0Smrgsed_quote_subst='$sed_quote_subst' 3852e4da13eeSmacallan 385365d490d0Smrg# Be Bourne compatible 385465d490d0Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 385565d490d0Smrg emulate sh 385665d490d0Smrg NULLCMD=: 385765d490d0Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 385865d490d0Smrg # is contrary to our usage. Disable this feature. 385965d490d0Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 386065d490d0Smrg setopt NO_GLOB_SUBST 386165d490d0Smrgelse 386265d490d0Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 386365d490d0Smrgfi 386465d490d0SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 386565d490d0SmrgDUALCASE=1; export DUALCASE # for MKS sh 3866e4da13eeSmacallan 386765d490d0Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 386865d490d0Smrg# if CDPATH is set. 386965d490d0Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 3870e4da13eeSmacallan 387165d490d0Smrgrelink_command=\"$relink_command\" 3872e4da13eeSmacallan 387365d490d0Smrg# This environment variable determines our operation mode. 387465d490d0Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 387565d490d0Smrg # install mode needs the following variables: 387665d490d0Smrg generated_by_libtool_version='$macro_version' 387765d490d0Smrg notinst_deplibs='$notinst_deplibs' 387865d490d0Smrgelse 387965d490d0Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 388065d490d0Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 388165d490d0Smrg file=\"\$0\"" 3882e4da13eeSmacallan 388365d490d0Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 388465d490d0Smrg $ECHO "\ 3885e4da13eeSmacallan 388665d490d0Smrg# A function that is used when there is no print builtin or printf. 388765d490d0Smrgfunc_fallback_echo () 388865d490d0Smrg{ 388965d490d0Smrg eval 'cat <<_LTECHO_EOF 389065d490d0Smrg\$1 389165d490d0Smrg_LTECHO_EOF' 389265d490d0Smrg} 389365d490d0Smrg ECHO=\"$qECHO\" 389465d490d0Smrg fi 3895e4da13eeSmacallan 389665d490d0Smrg# Very basic option parsing. These options are (a) specific to 389765d490d0Smrg# the libtool wrapper, (b) are identical between the wrapper 389865d490d0Smrg# /script/ and the wrapper /executable/ which is used only on 389965d490d0Smrg# windows platforms, and (c) all begin with the string "--lt-" 390065d490d0Smrg# (application programs are unlikely to have options which match 390165d490d0Smrg# this pattern). 390265d490d0Smrg# 390365d490d0Smrg# There are only two supported options: --lt-debug and 390465d490d0Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 390565d490d0Smrg# 390665d490d0Smrg# The first argument to this parsing function should be the 390765d490d0Smrg# script's $0 value, followed by "$@". 390865d490d0Smrglt_option_debug= 390965d490d0Smrgfunc_parse_lt_options () 391065d490d0Smrg{ 391165d490d0Smrg lt_script_arg0=\$0 391265d490d0Smrg shift 391365d490d0Smrg for lt_opt 391465d490d0Smrg do 391565d490d0Smrg case \"\$lt_opt\" in 391665d490d0Smrg --lt-debug) lt_option_debug=1 ;; 391765d490d0Smrg --lt-dump-script) 391865d490d0Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 391965d490d0Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 392065d490d0Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 392165d490d0Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 392265d490d0Smrg exit 0 392365d490d0Smrg ;; 392465d490d0Smrg --lt-*) 392565d490d0Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 392665d490d0Smrg exit 1 392765d490d0Smrg ;; 392865d490d0Smrg esac 392965d490d0Smrg done 3930e4da13eeSmacallan 393165d490d0Smrg # Print the debug banner immediately: 393265d490d0Smrg if test -n \"\$lt_option_debug\"; then 393365d490d0Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 393465d490d0Smrg fi 393565d490d0Smrg} 3936e4da13eeSmacallan 393765d490d0Smrg# Used when --lt-debug. Prints its arguments to stdout 393865d490d0Smrg# (redirection is the responsibility of the caller) 393965d490d0Smrgfunc_lt_dump_args () 394065d490d0Smrg{ 394165d490d0Smrg lt_dump_args_N=1; 394265d490d0Smrg for lt_arg 394365d490d0Smrg do 394465d490d0Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 394565d490d0Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 394665d490d0Smrg done 394765d490d0Smrg} 3948e4da13eeSmacallan 394965d490d0Smrg# Core function for launching the target application 395065d490d0Smrgfunc_exec_program_core () 395165d490d0Smrg{ 395265d490d0Smrg" 395365d490d0Smrg case $host in 395465d490d0Smrg # Backslashes separate directories on plain windows 395565d490d0Smrg *-*-mingw | *-*-os2* | *-cegcc*) 395665d490d0Smrg $ECHO "\ 395765d490d0Smrg if test -n \"\$lt_option_debug\"; then 395865d490d0Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 395965d490d0Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 396065d490d0Smrg fi 396165d490d0Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 396265d490d0Smrg" 396365d490d0Smrg ;; 3964e4da13eeSmacallan 396565d490d0Smrg *) 396665d490d0Smrg $ECHO "\ 396765d490d0Smrg if test -n \"\$lt_option_debug\"; then 396865d490d0Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 396965d490d0Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 397065d490d0Smrg fi 397165d490d0Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 397265d490d0Smrg" 397365d490d0Smrg ;; 397465d490d0Smrg esac 397565d490d0Smrg $ECHO "\ 397665d490d0Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 397765d490d0Smrg exit 1 397865d490d0Smrg} 3979e4da13eeSmacallan 398065d490d0Smrg# A function to encapsulate launching the target application 398165d490d0Smrg# Strips options in the --lt-* namespace from \$@ and 398265d490d0Smrg# launches target application with the remaining arguments. 398365d490d0Smrgfunc_exec_program () 398465d490d0Smrg{ 398565d490d0Smrg for lt_wr_arg 398665d490d0Smrg do 398765d490d0Smrg case \$lt_wr_arg in 398865d490d0Smrg --lt-*) ;; 398965d490d0Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 399065d490d0Smrg esac 399165d490d0Smrg shift 399265d490d0Smrg done 399365d490d0Smrg func_exec_program_core \${1+\"\$@\"} 399465d490d0Smrg} 3995e4da13eeSmacallan 399665d490d0Smrg # Parse options 399765d490d0Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 3998e4da13eeSmacallan 399965d490d0Smrg # Find the directory that this script lives in. 400065d490d0Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 400165d490d0Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 4002e4da13eeSmacallan 400365d490d0Smrg # Follow symbolic links until we get to the real thisdir. 400465d490d0Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 400565d490d0Smrg while test -n \"\$file\"; do 400665d490d0Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 4007e4da13eeSmacallan 400865d490d0Smrg # If there was a directory component, then change thisdir. 400965d490d0Smrg if test \"x\$destdir\" != \"x\$file\"; then 401065d490d0Smrg case \"\$destdir\" in 401165d490d0Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 401265d490d0Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 401365d490d0Smrg esac 401465d490d0Smrg fi 4015e4da13eeSmacallan 401665d490d0Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 401765d490d0Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 401865d490d0Smrg done 4019e4da13eeSmacallan 402065d490d0Smrg # Usually 'no', except on cygwin/mingw when embedded into 402165d490d0Smrg # the cwrapper. 402265d490d0Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 402365d490d0Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 402465d490d0Smrg # special case for '.' 402565d490d0Smrg if test \"\$thisdir\" = \".\"; then 402665d490d0Smrg thisdir=\`pwd\` 402765d490d0Smrg fi 402865d490d0Smrg # remove .libs from thisdir 402965d490d0Smrg case \"\$thisdir\" in 403065d490d0Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 403165d490d0Smrg $objdir ) thisdir=. ;; 403265d490d0Smrg esac 403365d490d0Smrg fi 4034e4da13eeSmacallan 403565d490d0Smrg # Try to get the absolute directory name. 403665d490d0Smrg absdir=\`cd \"\$thisdir\" && pwd\` 403765d490d0Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 403865d490d0Smrg" 4039e4da13eeSmacallan 404065d490d0Smrg if test "$fast_install" = yes; then 404165d490d0Smrg $ECHO "\ 404265d490d0Smrg program=lt-'$outputname'$exeext 404365d490d0Smrg progdir=\"\$thisdir/$objdir\" 4044e4da13eeSmacallan 404565d490d0Smrg if test ! -f \"\$progdir/\$program\" || 404665d490d0Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 404765d490d0Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 4048e4da13eeSmacallan 404965d490d0Smrg file=\"\$\$-\$program\" 4050e4da13eeSmacallan 405165d490d0Smrg if test ! -d \"\$progdir\"; then 405265d490d0Smrg $MKDIR \"\$progdir\" 405365d490d0Smrg else 405465d490d0Smrg $RM \"\$progdir/\$file\" 405565d490d0Smrg fi" 4056e4da13eeSmacallan 405765d490d0Smrg $ECHO "\ 4058e4da13eeSmacallan 405965d490d0Smrg # relink executable if necessary 406065d490d0Smrg if test -n \"\$relink_command\"; then 406165d490d0Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 406265d490d0Smrg else 406365d490d0Smrg $ECHO \"\$relink_command_output\" >&2 406465d490d0Smrg $RM \"\$progdir/\$file\" 406565d490d0Smrg exit 1 406665d490d0Smrg fi 406765d490d0Smrg fi 4068e4da13eeSmacallan 406965d490d0Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 407065d490d0Smrg { $RM \"\$progdir/\$program\"; 407165d490d0Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 407265d490d0Smrg $RM \"\$progdir/\$file\" 407365d490d0Smrg fi" 407465d490d0Smrg else 407565d490d0Smrg $ECHO "\ 407665d490d0Smrg program='$outputname' 407765d490d0Smrg progdir=\"\$thisdir/$objdir\" 407865d490d0Smrg" 4079e4da13eeSmacallan fi 4080e4da13eeSmacallan 408165d490d0Smrg $ECHO "\ 4082e4da13eeSmacallan 408365d490d0Smrg if test -f \"\$progdir/\$program\"; then" 4084e4da13eeSmacallan 408565d490d0Smrg # fixup the dll searchpath if we need to. 408665d490d0Smrg # 408765d490d0Smrg # Fix the DLL searchpath if we need to. Do this before prepending 408865d490d0Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 408965d490d0Smrg # libraries must come first. 409065d490d0Smrg if test -n "$dllsearchpath"; then 409165d490d0Smrg $ECHO "\ 409265d490d0Smrg # Add the dll search path components to the executable PATH 409365d490d0Smrg PATH=$dllsearchpath:\$PATH 409465d490d0Smrg" 409565d490d0Smrg fi 4096e4da13eeSmacallan 409765d490d0Smrg # Export our shlibpath_var if we have one. 409865d490d0Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 409965d490d0Smrg $ECHO "\ 410065d490d0Smrg # Add our own library path to $shlibpath_var 410165d490d0Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 4102e4da13eeSmacallan 410365d490d0Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 410465d490d0Smrg # The second colon is a workaround for a bug in BeOS R4 sed 410565d490d0Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 4106e4da13eeSmacallan 410765d490d0Smrg export $shlibpath_var 410865d490d0Smrg" 410965d490d0Smrg fi 4110e4da13eeSmacallan 411165d490d0Smrg $ECHO "\ 411265d490d0Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 411365d490d0Smrg # Run the actual program with our arguments. 411465d490d0Smrg func_exec_program \${1+\"\$@\"} 411565d490d0Smrg fi 411665d490d0Smrg else 411765d490d0Smrg # The program doesn't exist. 411865d490d0Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 411965d490d0Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 412065d490d0Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 412165d490d0Smrg exit 1 412265d490d0Smrg fi 412365d490d0Smrgfi\ 412465d490d0Smrg" 412565d490d0Smrg} 4126e4da13eeSmacallan 4127e4da13eeSmacallan 412865d490d0Smrg# func_emit_cwrapperexe_src 412965d490d0Smrg# emit the source code for a wrapper executable on stdout 413065d490d0Smrg# Must ONLY be called from within func_mode_link because 413165d490d0Smrg# it depends on a number of variable set therein. 413265d490d0Smrgfunc_emit_cwrapperexe_src () 413365d490d0Smrg{ 413465d490d0Smrg cat <<EOF 4135e4da13eeSmacallan 413665d490d0Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 413765d490d0Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4138e4da13eeSmacallan 413965d490d0Smrg The $output program cannot be directly executed until all the libtool 414065d490d0Smrg libraries that it depends on are installed. 4141e4da13eeSmacallan 414265d490d0Smrg This wrapper executable should never be moved out of the build directory. 414365d490d0Smrg If it is, it will not operate correctly. 414465d490d0Smrg*/ 414565d490d0SmrgEOF 414665d490d0Smrg cat <<"EOF" 414765d490d0Smrg#ifdef _MSC_VER 414865d490d0Smrg# define _CRT_SECURE_NO_DEPRECATE 1 414965d490d0Smrg#endif 415065d490d0Smrg#include <stdio.h> 415165d490d0Smrg#include <stdlib.h> 415265d490d0Smrg#ifdef _MSC_VER 415365d490d0Smrg# include <direct.h> 415465d490d0Smrg# include <process.h> 415565d490d0Smrg# include <io.h> 415665d490d0Smrg#else 415765d490d0Smrg# include <unistd.h> 415865d490d0Smrg# include <stdint.h> 415965d490d0Smrg# ifdef __CYGWIN__ 416065d490d0Smrg# include <io.h> 416165d490d0Smrg# endif 416265d490d0Smrg#endif 416365d490d0Smrg#include <malloc.h> 416465d490d0Smrg#include <stdarg.h> 416565d490d0Smrg#include <assert.h> 416665d490d0Smrg#include <string.h> 416765d490d0Smrg#include <ctype.h> 416865d490d0Smrg#include <errno.h> 416965d490d0Smrg#include <fcntl.h> 417065d490d0Smrg#include <sys/stat.h> 4171e4da13eeSmacallan 417265d490d0Smrg/* declarations of non-ANSI functions */ 417365d490d0Smrg#if defined(__MINGW32__) 417465d490d0Smrg# ifdef __STRICT_ANSI__ 417565d490d0Smrgint _putenv (const char *); 417665d490d0Smrg# endif 417765d490d0Smrg#elif defined(__CYGWIN__) 417865d490d0Smrg# ifdef __STRICT_ANSI__ 417965d490d0Smrgchar *realpath (const char *, char *); 418065d490d0Smrgint putenv (char *); 418165d490d0Smrgint setenv (const char *, const char *, int); 418265d490d0Smrg# endif 418365d490d0Smrg/* #elif defined (other platforms) ... */ 418465d490d0Smrg#endif 4185e4da13eeSmacallan 418665d490d0Smrg/* portability defines, excluding path handling macros */ 418765d490d0Smrg#if defined(_MSC_VER) 418865d490d0Smrg# define setmode _setmode 418965d490d0Smrg# define stat _stat 419065d490d0Smrg# define chmod _chmod 419165d490d0Smrg# define getcwd _getcwd 419265d490d0Smrg# define putenv _putenv 419365d490d0Smrg# define S_IXUSR _S_IEXEC 419465d490d0Smrg# ifndef _INTPTR_T_DEFINED 419565d490d0Smrg# define _INTPTR_T_DEFINED 419665d490d0Smrg# define intptr_t int 419765d490d0Smrg# endif 419865d490d0Smrg#elif defined(__MINGW32__) 419965d490d0Smrg# define setmode _setmode 420065d490d0Smrg# define stat _stat 420165d490d0Smrg# define chmod _chmod 420265d490d0Smrg# define getcwd _getcwd 420365d490d0Smrg# define putenv _putenv 420465d490d0Smrg#elif defined(__CYGWIN__) 420565d490d0Smrg# define HAVE_SETENV 420665d490d0Smrg# define FOPEN_WB "wb" 420765d490d0Smrg/* #elif defined (other platforms) ... */ 420865d490d0Smrg#endif 4209e4da13eeSmacallan 421065d490d0Smrg#if defined(PATH_MAX) 421165d490d0Smrg# define LT_PATHMAX PATH_MAX 421265d490d0Smrg#elif defined(MAXPATHLEN) 421365d490d0Smrg# define LT_PATHMAX MAXPATHLEN 421465d490d0Smrg#else 421565d490d0Smrg# define LT_PATHMAX 1024 421665d490d0Smrg#endif 4217e4da13eeSmacallan 421865d490d0Smrg#ifndef S_IXOTH 421965d490d0Smrg# define S_IXOTH 0 422065d490d0Smrg#endif 422165d490d0Smrg#ifndef S_IXGRP 422265d490d0Smrg# define S_IXGRP 0 422365d490d0Smrg#endif 4224e4da13eeSmacallan 422565d490d0Smrg/* path handling portability macros */ 422665d490d0Smrg#ifndef DIR_SEPARATOR 422765d490d0Smrg# define DIR_SEPARATOR '/' 422865d490d0Smrg# define PATH_SEPARATOR ':' 422965d490d0Smrg#endif 4230e4da13eeSmacallan 423165d490d0Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 423265d490d0Smrg defined (__OS2__) 423365d490d0Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 423465d490d0Smrg# define FOPEN_WB "wb" 423565d490d0Smrg# ifndef DIR_SEPARATOR_2 423665d490d0Smrg# define DIR_SEPARATOR_2 '\\' 423765d490d0Smrg# endif 423865d490d0Smrg# ifndef PATH_SEPARATOR_2 423965d490d0Smrg# define PATH_SEPARATOR_2 ';' 424065d490d0Smrg# endif 424165d490d0Smrg#endif 4242e4da13eeSmacallan 424365d490d0Smrg#ifndef DIR_SEPARATOR_2 424465d490d0Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 424565d490d0Smrg#else /* DIR_SEPARATOR_2 */ 424665d490d0Smrg# define IS_DIR_SEPARATOR(ch) \ 424765d490d0Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 424865d490d0Smrg#endif /* DIR_SEPARATOR_2 */ 4249e4da13eeSmacallan 425065d490d0Smrg#ifndef PATH_SEPARATOR_2 425165d490d0Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 425265d490d0Smrg#else /* PATH_SEPARATOR_2 */ 425365d490d0Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 425465d490d0Smrg#endif /* PATH_SEPARATOR_2 */ 4255e4da13eeSmacallan 425665d490d0Smrg#ifndef FOPEN_WB 425765d490d0Smrg# define FOPEN_WB "w" 425865d490d0Smrg#endif 425965d490d0Smrg#ifndef _O_BINARY 426065d490d0Smrg# define _O_BINARY 0 426165d490d0Smrg#endif 4262e4da13eeSmacallan 426365d490d0Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 426465d490d0Smrg#define XFREE(stale) do { \ 426565d490d0Smrg if (stale) { free ((void *) stale); stale = 0; } \ 426665d490d0Smrg} while (0) 4267e4da13eeSmacallan 426865d490d0Smrg#if defined(LT_DEBUGWRAPPER) 426965d490d0Smrgstatic int lt_debug = 1; 427065d490d0Smrg#else 427165d490d0Smrgstatic int lt_debug = 0; 427265d490d0Smrg#endif 4273e4da13eeSmacallan 427465d490d0Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 427565d490d0Smrg 427665d490d0Smrgvoid *xmalloc (size_t num); 427765d490d0Smrgchar *xstrdup (const char *string); 427865d490d0Smrgconst char *base_name (const char *name); 427965d490d0Smrgchar *find_executable (const char *wrapper); 428065d490d0Smrgchar *chase_symlinks (const char *pathspec); 428165d490d0Smrgint make_executable (const char *path); 428265d490d0Smrgint check_executable (const char *path); 428365d490d0Smrgchar *strendzap (char *str, const char *pat); 428465d490d0Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 428565d490d0Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 428665d490d0Smrgstatic const char *nonnull (const char *s); 428765d490d0Smrgstatic const char *nonempty (const char *s); 428865d490d0Smrgvoid lt_setenv (const char *name, const char *value); 428965d490d0Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 429065d490d0Smrgvoid lt_update_exe_path (const char *name, const char *value); 429165d490d0Smrgvoid lt_update_lib_path (const char *name, const char *value); 429265d490d0Smrgchar **prepare_spawn (char **argv); 429365d490d0Smrgvoid lt_dump_script (FILE *f); 429465d490d0SmrgEOF 4295e4da13eeSmacallan 429665d490d0Smrg cat <<EOF 429765d490d0Smrgvolatile const char * MAGIC_EXE = "$magic_exe"; 429865d490d0Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 429965d490d0SmrgEOF 4300e4da13eeSmacallan 430165d490d0Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 430265d490d0Smrg func_to_host_path "$temp_rpath" 430365d490d0Smrg cat <<EOF 430465d490d0Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 430565d490d0SmrgEOF 430665d490d0Smrg else 430765d490d0Smrg cat <<"EOF" 430865d490d0Smrgconst char * LIB_PATH_VALUE = ""; 430965d490d0SmrgEOF 431065d490d0Smrg fi 4311e4da13eeSmacallan 431265d490d0Smrg if test -n "$dllsearchpath"; then 431365d490d0Smrg func_to_host_path "$dllsearchpath:" 431465d490d0Smrg cat <<EOF 431565d490d0Smrgconst char * EXE_PATH_VARNAME = "PATH"; 431665d490d0Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 431765d490d0SmrgEOF 431865d490d0Smrg else 431965d490d0Smrg cat <<"EOF" 432065d490d0Smrgconst char * EXE_PATH_VARNAME = ""; 432165d490d0Smrgconst char * EXE_PATH_VALUE = ""; 432265d490d0SmrgEOF 432365d490d0Smrg fi 4324e4da13eeSmacallan 432565d490d0Smrg if test "$fast_install" = yes; then 432665d490d0Smrg cat <<EOF 432765d490d0Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 432865d490d0SmrgEOF 432965d490d0Smrg else 433065d490d0Smrg cat <<EOF 433165d490d0Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 433265d490d0SmrgEOF 433365d490d0Smrg fi 4334e4da13eeSmacallan 4335e4da13eeSmacallan 433665d490d0Smrg cat <<"EOF" 4337e4da13eeSmacallan 433865d490d0Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 4339e4da13eeSmacallan 434065d490d0Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 434165d490d0Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 434265d490d0Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 4343e4da13eeSmacallan 434465d490d0Smrgint 434565d490d0Smrgmain (int argc, char *argv[]) 434665d490d0Smrg{ 434765d490d0Smrg char **newargz; 434865d490d0Smrg int newargc; 434965d490d0Smrg char *tmp_pathspec; 435065d490d0Smrg char *actual_cwrapper_path; 435165d490d0Smrg char *actual_cwrapper_name; 435265d490d0Smrg char *target_name; 435365d490d0Smrg char *lt_argv_zero; 435465d490d0Smrg intptr_t rval = 127; 435565d490d0Smrg 435665d490d0Smrg int i; 435765d490d0Smrg 435865d490d0Smrg program_name = (char *) xstrdup (base_name (argv[0])); 435965d490d0Smrg newargz = XMALLOC (char *, argc + 1); 436065d490d0Smrg 436165d490d0Smrg /* very simple arg parsing; don't want to rely on getopt 436265d490d0Smrg * also, copy all non cwrapper options to newargz, except 436365d490d0Smrg * argz[0], which is handled differently 436465d490d0Smrg */ 436565d490d0Smrg newargc=0; 436665d490d0Smrg for (i = 1; i < argc; i++) 436765d490d0Smrg { 436865d490d0Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 436965d490d0Smrg { 437065d490d0SmrgEOF 437165d490d0Smrg case "$host" in 437265d490d0Smrg *mingw* | *cygwin* ) 437365d490d0Smrg # make stdout use "unix" line endings 437465d490d0Smrg echo " setmode(1,_O_BINARY);" 4375e4da13eeSmacallan ;; 4376e4da13eeSmacallan esac 4377e4da13eeSmacallan 437865d490d0Smrg cat <<"EOF" 437965d490d0Smrg lt_dump_script (stdout); 438065d490d0Smrg return 0; 438165d490d0Smrg } 438265d490d0Smrg if (strcmp (argv[i], debug_opt) == 0) 438365d490d0Smrg { 438465d490d0Smrg lt_debug = 1; 438565d490d0Smrg continue; 438665d490d0Smrg } 438765d490d0Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 438865d490d0Smrg { 438965d490d0Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 439065d490d0Smrg namespace, but it is not one of the ones we know about and 439165d490d0Smrg have already dealt with, above (inluding dump-script), then 439265d490d0Smrg report an error. Otherwise, targets might begin to believe 439365d490d0Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 439465d490d0Smrg namespace. The first time any user complains about this, we'll 439565d490d0Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 439665d490d0Smrg or a configure.ac-settable value. 439765d490d0Smrg */ 439865d490d0Smrg lt_fatal (__FILE__, __LINE__, 439965d490d0Smrg "unrecognized %s option: '%s'", 440065d490d0Smrg ltwrapper_option_prefix, argv[i]); 440165d490d0Smrg } 440265d490d0Smrg /* otherwise ... */ 440365d490d0Smrg newargz[++newargc] = xstrdup (argv[i]); 440465d490d0Smrg } 440565d490d0Smrg newargz[++newargc] = NULL; 4406e4da13eeSmacallan 440765d490d0SmrgEOF 440865d490d0Smrg cat <<EOF 440965d490d0Smrg /* The GNU banner must be the first non-error debug message */ 441065d490d0Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 441165d490d0SmrgEOF 441265d490d0Smrg cat <<"EOF" 441365d490d0Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 441465d490d0Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 441565d490d0Smrg 441665d490d0Smrg tmp_pathspec = find_executable (argv[0]); 441765d490d0Smrg if (tmp_pathspec == NULL) 441865d490d0Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 441965d490d0Smrg lt_debugprintf (__FILE__, __LINE__, 442065d490d0Smrg "(main) found exe (before symlink chase) at: %s\n", 442165d490d0Smrg tmp_pathspec); 442265d490d0Smrg 442365d490d0Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 442465d490d0Smrg lt_debugprintf (__FILE__, __LINE__, 442565d490d0Smrg "(main) found exe (after symlink chase) at: %s\n", 442665d490d0Smrg actual_cwrapper_path); 442765d490d0Smrg XFREE (tmp_pathspec); 442865d490d0Smrg 442965d490d0Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 443065d490d0Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 443165d490d0Smrg 443265d490d0Smrg /* wrapper name transforms */ 443365d490d0Smrg strendzap (actual_cwrapper_name, ".exe"); 443465d490d0Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 443565d490d0Smrg XFREE (actual_cwrapper_name); 443665d490d0Smrg actual_cwrapper_name = tmp_pathspec; 443765d490d0Smrg tmp_pathspec = 0; 443865d490d0Smrg 443965d490d0Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 444065d490d0Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 444165d490d0Smrg strendzap (target_name, ".exe"); 444265d490d0Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 444365d490d0Smrg XFREE (target_name); 444465d490d0Smrg target_name = tmp_pathspec; 444565d490d0Smrg tmp_pathspec = 0; 444665d490d0Smrg 444765d490d0Smrg lt_debugprintf (__FILE__, __LINE__, 444865d490d0Smrg "(main) libtool target name: %s\n", 444965d490d0Smrg target_name); 445065d490d0SmrgEOF 4451e4da13eeSmacallan 445265d490d0Smrg cat <<EOF 445365d490d0Smrg newargz[0] = 445465d490d0Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 445565d490d0Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 445665d490d0Smrg strcpy (newargz[0], actual_cwrapper_path); 445765d490d0Smrg strcat (newargz[0], "$objdir"); 445865d490d0Smrg strcat (newargz[0], "/"); 445965d490d0SmrgEOF 4460e4da13eeSmacallan 446165d490d0Smrg cat <<"EOF" 446265d490d0Smrg /* stop here, and copy so we don't have to do this twice */ 446365d490d0Smrg tmp_pathspec = xstrdup (newargz[0]); 4464e4da13eeSmacallan 446565d490d0Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 446665d490d0Smrg strcat (newargz[0], actual_cwrapper_name); 4467e4da13eeSmacallan 446865d490d0Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 446965d490d0Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 447065d490d0Smrg XFREE (tmp_pathspec); 447165d490d0Smrg tmp_pathspec = NULL; 447265d490d0SmrgEOF 4473e4da13eeSmacallan 447465d490d0Smrg case $host_os in 447565d490d0Smrg mingw*) 447665d490d0Smrg cat <<"EOF" 447765d490d0Smrg { 447865d490d0Smrg char* p; 447965d490d0Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 448065d490d0Smrg { 448165d490d0Smrg *p = '/'; 448265d490d0Smrg } 448365d490d0Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 448465d490d0Smrg { 448565d490d0Smrg *p = '/'; 448665d490d0Smrg } 448765d490d0Smrg } 448865d490d0SmrgEOF 448965d490d0Smrg ;; 449065d490d0Smrg esac 4491e4da13eeSmacallan 449265d490d0Smrg cat <<"EOF" 449365d490d0Smrg XFREE (target_name); 449465d490d0Smrg XFREE (actual_cwrapper_path); 449565d490d0Smrg XFREE (actual_cwrapper_name); 449665d490d0Smrg 449765d490d0Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 449865d490d0Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 449965d490d0Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 450065d490d0Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 450165d490d0Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 450265d490d0Smrg libraries must come first. */ 450365d490d0Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 450465d490d0Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 450565d490d0Smrg 450665d490d0Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 450765d490d0Smrg nonnull (lt_argv_zero)); 450865d490d0Smrg for (i = 0; i < newargc; i++) 450965d490d0Smrg { 451065d490d0Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 451165d490d0Smrg i, nonnull (newargz[i])); 451265d490d0Smrg } 4513e4da13eeSmacallan 451465d490d0SmrgEOF 4515e4da13eeSmacallan 451665d490d0Smrg case $host_os in 451765d490d0Smrg mingw*) 451865d490d0Smrg cat <<"EOF" 451965d490d0Smrg /* execv doesn't actually work on mingw as expected on unix */ 452065d490d0Smrg newargz = prepare_spawn (newargz); 452165d490d0Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 452265d490d0Smrg if (rval == -1) 452365d490d0Smrg { 452465d490d0Smrg /* failed to start process */ 452565d490d0Smrg lt_debugprintf (__FILE__, __LINE__, 452665d490d0Smrg "(main) failed to launch target \"%s\": %s\n", 452765d490d0Smrg lt_argv_zero, nonnull (strerror (errno))); 452865d490d0Smrg return 127; 452965d490d0Smrg } 453065d490d0Smrg return rval; 453165d490d0SmrgEOF 453265d490d0Smrg ;; 453365d490d0Smrg *) 453465d490d0Smrg cat <<"EOF" 453565d490d0Smrg execv (lt_argv_zero, newargz); 453665d490d0Smrg return rval; /* =127, but avoids unused variable warning */ 453765d490d0SmrgEOF 453865d490d0Smrg ;; 453965d490d0Smrg esac 4540e4da13eeSmacallan 454165d490d0Smrg cat <<"EOF" 454265d490d0Smrg} 4543e4da13eeSmacallan 454465d490d0Smrgvoid * 454565d490d0Smrgxmalloc (size_t num) 454665d490d0Smrg{ 454765d490d0Smrg void *p = (void *) malloc (num); 454865d490d0Smrg if (!p) 454965d490d0Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 4550e4da13eeSmacallan 455165d490d0Smrg return p; 455265d490d0Smrg} 4553e4da13eeSmacallan 455465d490d0Smrgchar * 455565d490d0Smrgxstrdup (const char *string) 455665d490d0Smrg{ 455765d490d0Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 455865d490d0Smrg string) : NULL; 455965d490d0Smrg} 4560e4da13eeSmacallan 456165d490d0Smrgconst char * 456265d490d0Smrgbase_name (const char *name) 456365d490d0Smrg{ 456465d490d0Smrg const char *base; 4565e4da13eeSmacallan 456665d490d0Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 456765d490d0Smrg /* Skip over the disk name in MSDOS pathnames. */ 456865d490d0Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 456965d490d0Smrg name += 2; 457065d490d0Smrg#endif 4571e4da13eeSmacallan 457265d490d0Smrg for (base = name; *name; name++) 457365d490d0Smrg if (IS_DIR_SEPARATOR (*name)) 457465d490d0Smrg base = name + 1; 457565d490d0Smrg return base; 457665d490d0Smrg} 4577e4da13eeSmacallan 457865d490d0Smrgint 457965d490d0Smrgcheck_executable (const char *path) 458065d490d0Smrg{ 458165d490d0Smrg struct stat st; 4582e4da13eeSmacallan 458365d490d0Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 458465d490d0Smrg nonempty (path)); 458565d490d0Smrg if ((!path) || (!*path)) 458665d490d0Smrg return 0; 4587e4da13eeSmacallan 458865d490d0Smrg if ((stat (path, &st) >= 0) 458965d490d0Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 459065d490d0Smrg return 1; 459165d490d0Smrg else 459265d490d0Smrg return 0; 459365d490d0Smrg} 4594e4da13eeSmacallan 459565d490d0Smrgint 459665d490d0Smrgmake_executable (const char *path) 459765d490d0Smrg{ 459865d490d0Smrg int rval = 0; 459965d490d0Smrg struct stat st; 4600e4da13eeSmacallan 460165d490d0Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 460265d490d0Smrg nonempty (path)); 460365d490d0Smrg if ((!path) || (!*path)) 460465d490d0Smrg return 0; 4605e4da13eeSmacallan 460665d490d0Smrg if (stat (path, &st) >= 0) 460765d490d0Smrg { 460865d490d0Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 460965d490d0Smrg } 461065d490d0Smrg return rval; 461165d490d0Smrg} 4612e4da13eeSmacallan 461365d490d0Smrg/* Searches for the full path of the wrapper. Returns 461465d490d0Smrg newly allocated full path name if found, NULL otherwise 461565d490d0Smrg Does not chase symlinks, even on platforms that support them. 461665d490d0Smrg*/ 461765d490d0Smrgchar * 461865d490d0Smrgfind_executable (const char *wrapper) 461965d490d0Smrg{ 462065d490d0Smrg int has_slash = 0; 462165d490d0Smrg const char *p; 462265d490d0Smrg const char *p_next; 462365d490d0Smrg /* static buffer for getcwd */ 462465d490d0Smrg char tmp[LT_PATHMAX + 1]; 462565d490d0Smrg int tmp_len; 462665d490d0Smrg char *concat_name; 4627e4da13eeSmacallan 462865d490d0Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 462965d490d0Smrg nonempty (wrapper)); 4630e4da13eeSmacallan 463165d490d0Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 463265d490d0Smrg return NULL; 4633e4da13eeSmacallan 463465d490d0Smrg /* Absolute path? */ 463565d490d0Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 463665d490d0Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 463765d490d0Smrg { 463865d490d0Smrg concat_name = xstrdup (wrapper); 463965d490d0Smrg if (check_executable (concat_name)) 464065d490d0Smrg return concat_name; 464165d490d0Smrg XFREE (concat_name); 464265d490d0Smrg } 464365d490d0Smrg else 464465d490d0Smrg { 464565d490d0Smrg#endif 464665d490d0Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 464765d490d0Smrg { 464865d490d0Smrg concat_name = xstrdup (wrapper); 464965d490d0Smrg if (check_executable (concat_name)) 465065d490d0Smrg return concat_name; 465165d490d0Smrg XFREE (concat_name); 465265d490d0Smrg } 465365d490d0Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 465465d490d0Smrg } 465565d490d0Smrg#endif 4656e4da13eeSmacallan 465765d490d0Smrg for (p = wrapper; *p; p++) 465865d490d0Smrg if (*p == '/') 465965d490d0Smrg { 466065d490d0Smrg has_slash = 1; 466165d490d0Smrg break; 466265d490d0Smrg } 466365d490d0Smrg if (!has_slash) 466465d490d0Smrg { 466565d490d0Smrg /* no slashes; search PATH */ 466665d490d0Smrg const char *path = getenv ("PATH"); 466765d490d0Smrg if (path != NULL) 466865d490d0Smrg { 466965d490d0Smrg for (p = path; *p; p = p_next) 467065d490d0Smrg { 467165d490d0Smrg const char *q; 467265d490d0Smrg size_t p_len; 467365d490d0Smrg for (q = p; *q; q++) 467465d490d0Smrg if (IS_PATH_SEPARATOR (*q)) 467565d490d0Smrg break; 467665d490d0Smrg p_len = q - p; 467765d490d0Smrg p_next = (*q == '\0' ? q : q + 1); 467865d490d0Smrg if (p_len == 0) 467965d490d0Smrg { 468065d490d0Smrg /* empty path: current directory */ 468165d490d0Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 468265d490d0Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 468365d490d0Smrg nonnull (strerror (errno))); 468465d490d0Smrg tmp_len = strlen (tmp); 468565d490d0Smrg concat_name = 468665d490d0Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 468765d490d0Smrg memcpy (concat_name, tmp, tmp_len); 468865d490d0Smrg concat_name[tmp_len] = '/'; 468965d490d0Smrg strcpy (concat_name + tmp_len + 1, wrapper); 469065d490d0Smrg } 469165d490d0Smrg else 469265d490d0Smrg { 469365d490d0Smrg concat_name = 469465d490d0Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 469565d490d0Smrg memcpy (concat_name, p, p_len); 469665d490d0Smrg concat_name[p_len] = '/'; 469765d490d0Smrg strcpy (concat_name + p_len + 1, wrapper); 469865d490d0Smrg } 469965d490d0Smrg if (check_executable (concat_name)) 470065d490d0Smrg return concat_name; 470165d490d0Smrg XFREE (concat_name); 470265d490d0Smrg } 470365d490d0Smrg } 470465d490d0Smrg /* not found in PATH; assume curdir */ 470565d490d0Smrg } 470665d490d0Smrg /* Relative path | not found in path: prepend cwd */ 470765d490d0Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 470865d490d0Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 470965d490d0Smrg nonnull (strerror (errno))); 471065d490d0Smrg tmp_len = strlen (tmp); 471165d490d0Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 471265d490d0Smrg memcpy (concat_name, tmp, tmp_len); 471365d490d0Smrg concat_name[tmp_len] = '/'; 471465d490d0Smrg strcpy (concat_name + tmp_len + 1, wrapper); 471565d490d0Smrg 471665d490d0Smrg if (check_executable (concat_name)) 471765d490d0Smrg return concat_name; 471865d490d0Smrg XFREE (concat_name); 471965d490d0Smrg return NULL; 4720e4da13eeSmacallan} 4721e4da13eeSmacallan 472265d490d0Smrgchar * 472365d490d0Smrgchase_symlinks (const char *pathspec) 472465d490d0Smrg{ 472565d490d0Smrg#ifndef S_ISLNK 472665d490d0Smrg return xstrdup (pathspec); 472765d490d0Smrg#else 472865d490d0Smrg char buf[LT_PATHMAX]; 472965d490d0Smrg struct stat s; 473065d490d0Smrg char *tmp_pathspec = xstrdup (pathspec); 473165d490d0Smrg char *p; 473265d490d0Smrg int has_symlinks = 0; 473365d490d0Smrg while (strlen (tmp_pathspec) && !has_symlinks) 473465d490d0Smrg { 473565d490d0Smrg lt_debugprintf (__FILE__, __LINE__, 473665d490d0Smrg "checking path component for symlinks: %s\n", 473765d490d0Smrg tmp_pathspec); 473865d490d0Smrg if (lstat (tmp_pathspec, &s) == 0) 473965d490d0Smrg { 474065d490d0Smrg if (S_ISLNK (s.st_mode) != 0) 474165d490d0Smrg { 474265d490d0Smrg has_symlinks = 1; 474365d490d0Smrg break; 474465d490d0Smrg } 4745e4da13eeSmacallan 474665d490d0Smrg /* search backwards for last DIR_SEPARATOR */ 474765d490d0Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 474865d490d0Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 474965d490d0Smrg p--; 475065d490d0Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 475165d490d0Smrg { 475265d490d0Smrg /* no more DIR_SEPARATORS left */ 475365d490d0Smrg break; 475465d490d0Smrg } 475565d490d0Smrg *p = '\0'; 475665d490d0Smrg } 475765d490d0Smrg else 475865d490d0Smrg { 475965d490d0Smrg lt_fatal (__FILE__, __LINE__, 476065d490d0Smrg "error accessing file \"%s\": %s", 476165d490d0Smrg tmp_pathspec, nonnull (strerror (errno))); 476265d490d0Smrg } 476365d490d0Smrg } 476465d490d0Smrg XFREE (tmp_pathspec); 4765e4da13eeSmacallan 476665d490d0Smrg if (!has_symlinks) 476765d490d0Smrg { 476865d490d0Smrg return xstrdup (pathspec); 476965d490d0Smrg } 4770e4da13eeSmacallan 477165d490d0Smrg tmp_pathspec = realpath (pathspec, buf); 477265d490d0Smrg if (tmp_pathspec == 0) 477365d490d0Smrg { 477465d490d0Smrg lt_fatal (__FILE__, __LINE__, 477565d490d0Smrg "could not follow symlinks for %s", pathspec); 477665d490d0Smrg } 477765d490d0Smrg return xstrdup (tmp_pathspec); 477865d490d0Smrg#endif 4779e4da13eeSmacallan} 4780e4da13eeSmacallan 478165d490d0Smrgchar * 478265d490d0Smrgstrendzap (char *str, const char *pat) 478365d490d0Smrg{ 478465d490d0Smrg size_t len, patlen; 4785e4da13eeSmacallan 478665d490d0Smrg assert (str != NULL); 478765d490d0Smrg assert (pat != NULL); 4788e4da13eeSmacallan 478965d490d0Smrg len = strlen (str); 479065d490d0Smrg patlen = strlen (pat); 4791e4da13eeSmacallan 479265d490d0Smrg if (patlen <= len) 479365d490d0Smrg { 479465d490d0Smrg str += len - patlen; 479565d490d0Smrg if (strcmp (str, pat) == 0) 479665d490d0Smrg *str = '\0'; 479765d490d0Smrg } 479865d490d0Smrg return str; 479965d490d0Smrg} 4800e4da13eeSmacallan 480165d490d0Smrgvoid 480265d490d0Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 480365d490d0Smrg{ 480465d490d0Smrg va_list args; 480565d490d0Smrg if (lt_debug) 480665d490d0Smrg { 480765d490d0Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 480865d490d0Smrg va_start (args, fmt); 480965d490d0Smrg (void) vfprintf (stderr, fmt, args); 481065d490d0Smrg va_end (args); 481165d490d0Smrg } 481265d490d0Smrg} 4813e4da13eeSmacallan 481465d490d0Smrgstatic void 481565d490d0Smrglt_error_core (int exit_status, const char *file, 481665d490d0Smrg int line, const char *mode, 481765d490d0Smrg const char *message, va_list ap) 481865d490d0Smrg{ 481965d490d0Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 482065d490d0Smrg vfprintf (stderr, message, ap); 482165d490d0Smrg fprintf (stderr, ".\n"); 4822e4da13eeSmacallan 482365d490d0Smrg if (exit_status >= 0) 482465d490d0Smrg exit (exit_status); 482565d490d0Smrg} 4826e4da13eeSmacallan 482765d490d0Smrgvoid 482865d490d0Smrglt_fatal (const char *file, int line, const char *message, ...) 482965d490d0Smrg{ 483065d490d0Smrg va_list ap; 483165d490d0Smrg va_start (ap, message); 483265d490d0Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 483365d490d0Smrg va_end (ap); 483465d490d0Smrg} 4835e4da13eeSmacallan 483665d490d0Smrgstatic const char * 483765d490d0Smrgnonnull (const char *s) 483865d490d0Smrg{ 483965d490d0Smrg return s ? s : "(null)"; 484065d490d0Smrg} 4841e4da13eeSmacallan 484265d490d0Smrgstatic const char * 484365d490d0Smrgnonempty (const char *s) 484465d490d0Smrg{ 484565d490d0Smrg return (s && !*s) ? "(empty)" : nonnull (s); 484665d490d0Smrg} 4847e4da13eeSmacallan 484865d490d0Smrgvoid 484965d490d0Smrglt_setenv (const char *name, const char *value) 485065d490d0Smrg{ 485165d490d0Smrg lt_debugprintf (__FILE__, __LINE__, 485265d490d0Smrg "(lt_setenv) setting '%s' to '%s'\n", 485365d490d0Smrg nonnull (name), nonnull (value)); 485465d490d0Smrg { 485565d490d0Smrg#ifdef HAVE_SETENV 485665d490d0Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 485765d490d0Smrg char *str = xstrdup (value); 485865d490d0Smrg setenv (name, str, 1); 4859e4da13eeSmacallan#else 486065d490d0Smrg int len = strlen (name) + 1 + strlen (value) + 1; 486165d490d0Smrg char *str = XMALLOC (char, len); 486265d490d0Smrg sprintf (str, "%s=%s", name, value); 486365d490d0Smrg if (putenv (str) != EXIT_SUCCESS) 486465d490d0Smrg { 486565d490d0Smrg XFREE (str); 486665d490d0Smrg } 4867e4da13eeSmacallan#endif 486865d490d0Smrg } 486965d490d0Smrg} 4870e4da13eeSmacallan 487165d490d0Smrgchar * 487265d490d0Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 487365d490d0Smrg{ 487465d490d0Smrg char *new_value; 487565d490d0Smrg if (orig_value && *orig_value) 487665d490d0Smrg { 487765d490d0Smrg int orig_value_len = strlen (orig_value); 487865d490d0Smrg int add_len = strlen (add); 487965d490d0Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 488065d490d0Smrg if (to_end) 488165d490d0Smrg { 488265d490d0Smrg strcpy (new_value, orig_value); 488365d490d0Smrg strcpy (new_value + orig_value_len, add); 488465d490d0Smrg } 488565d490d0Smrg else 488665d490d0Smrg { 488765d490d0Smrg strcpy (new_value, add); 488865d490d0Smrg strcpy (new_value + add_len, orig_value); 488965d490d0Smrg } 489065d490d0Smrg } 489165d490d0Smrg else 489265d490d0Smrg { 489365d490d0Smrg new_value = xstrdup (add); 489465d490d0Smrg } 489565d490d0Smrg return new_value; 489665d490d0Smrg} 4897e4da13eeSmacallan 489865d490d0Smrgvoid 489965d490d0Smrglt_update_exe_path (const char *name, const char *value) 490065d490d0Smrg{ 490165d490d0Smrg lt_debugprintf (__FILE__, __LINE__, 490265d490d0Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 490365d490d0Smrg nonnull (name), nonnull (value)); 4904e4da13eeSmacallan 490565d490d0Smrg if (name && *name && value && *value) 490665d490d0Smrg { 490765d490d0Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 490865d490d0Smrg /* some systems can't cope with a ':'-terminated path #' */ 490965d490d0Smrg int len = strlen (new_value); 491065d490d0Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 491165d490d0Smrg { 491265d490d0Smrg new_value[len-1] = '\0'; 491365d490d0Smrg } 491465d490d0Smrg lt_setenv (name, new_value); 491565d490d0Smrg XFREE (new_value); 491665d490d0Smrg } 491765d490d0Smrg} 4918e4da13eeSmacallan 491965d490d0Smrgvoid 492065d490d0Smrglt_update_lib_path (const char *name, const char *value) 4921e4da13eeSmacallan{ 492265d490d0Smrg lt_debugprintf (__FILE__, __LINE__, 492365d490d0Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 492465d490d0Smrg nonnull (name), nonnull (value)); 4925e4da13eeSmacallan 492665d490d0Smrg if (name && *name && value && *value) 492765d490d0Smrg { 492865d490d0Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 492965d490d0Smrg lt_setenv (name, new_value); 493065d490d0Smrg XFREE (new_value); 493165d490d0Smrg } 493265d490d0Smrg} 4933e4da13eeSmacallan 4934e4da13eeSmacallanEOF 493565d490d0Smrg case $host_os in 493665d490d0Smrg mingw*) 493765d490d0Smrg cat <<"EOF" 493865d490d0Smrg 493965d490d0Smrg/* Prepares an argument vector before calling spawn(). 494065d490d0Smrg Note that spawn() does not by itself call the command interpreter 494165d490d0Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 494265d490d0Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 494365d490d0Smrg GetVersionEx(&v); 494465d490d0Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 494565d490d0Smrg }) ? "cmd.exe" : "command.com"). 494665d490d0Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 494765d490d0Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 494865d490d0Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 494965d490d0Smrg special way: 495065d490d0Smrg - Space and tab are interpreted as delimiters. They are not treated as 495165d490d0Smrg delimiters if they are surrounded by double quotes: "...". 495265d490d0Smrg - Unescaped double quotes are removed from the input. Their only effect is 495365d490d0Smrg that within double quotes, space and tab are treated like normal 495465d490d0Smrg characters. 495565d490d0Smrg - Backslashes not followed by double quotes are not special. 495665d490d0Smrg - But 2*n+1 backslashes followed by a double quote become 495765d490d0Smrg n backslashes followed by a double quote (n >= 0): 495865d490d0Smrg \" -> " 495965d490d0Smrg \\\" -> \" 496065d490d0Smrg \\\\\" -> \\" 496165d490d0Smrg */ 496265d490d0Smrg#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" 496365d490d0Smrg#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" 496465d490d0Smrgchar ** 496565d490d0Smrgprepare_spawn (char **argv) 496665d490d0Smrg{ 496765d490d0Smrg size_t argc; 496865d490d0Smrg char **new_argv; 496965d490d0Smrg size_t i; 4970e4da13eeSmacallan 497165d490d0Smrg /* Count number of arguments. */ 497265d490d0Smrg for (argc = 0; argv[argc] != NULL; argc++) 4973e4da13eeSmacallan ; 4974e4da13eeSmacallan 497565d490d0Smrg /* Allocate new argument vector. */ 497665d490d0Smrg new_argv = XMALLOC (char *, argc + 1); 4977e4da13eeSmacallan 497865d490d0Smrg /* Put quoted arguments into the new argument vector. */ 497965d490d0Smrg for (i = 0; i < argc; i++) 498065d490d0Smrg { 498165d490d0Smrg const char *string = argv[i]; 498265d490d0Smrg 498365d490d0Smrg if (string[0] == '\0') 498465d490d0Smrg new_argv[i] = xstrdup ("\"\""); 498565d490d0Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 498665d490d0Smrg { 498765d490d0Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 498865d490d0Smrg size_t length; 498965d490d0Smrg unsigned int backslashes; 499065d490d0Smrg const char *s; 499165d490d0Smrg char *quoted_string; 499265d490d0Smrg char *p; 499365d490d0Smrg 499465d490d0Smrg length = 0; 499565d490d0Smrg backslashes = 0; 499665d490d0Smrg if (quote_around) 499765d490d0Smrg length++; 499865d490d0Smrg for (s = string; *s != '\0'; s++) 499965d490d0Smrg { 500065d490d0Smrg char c = *s; 500165d490d0Smrg if (c == '"') 500265d490d0Smrg length += backslashes + 1; 500365d490d0Smrg length++; 500465d490d0Smrg if (c == '\\') 500565d490d0Smrg backslashes++; 500665d490d0Smrg else 500765d490d0Smrg backslashes = 0; 500865d490d0Smrg } 500965d490d0Smrg if (quote_around) 501065d490d0Smrg length += backslashes + 1; 501165d490d0Smrg 501265d490d0Smrg quoted_string = XMALLOC (char, length + 1); 501365d490d0Smrg 501465d490d0Smrg p = quoted_string; 501565d490d0Smrg backslashes = 0; 501665d490d0Smrg if (quote_around) 501765d490d0Smrg *p++ = '"'; 501865d490d0Smrg for (s = string; *s != '\0'; s++) 501965d490d0Smrg { 502065d490d0Smrg char c = *s; 502165d490d0Smrg if (c == '"') 502265d490d0Smrg { 502365d490d0Smrg unsigned int j; 502465d490d0Smrg for (j = backslashes + 1; j > 0; j--) 502565d490d0Smrg *p++ = '\\'; 502665d490d0Smrg } 502765d490d0Smrg *p++ = c; 502865d490d0Smrg if (c == '\\') 502965d490d0Smrg backslashes++; 503065d490d0Smrg else 503165d490d0Smrg backslashes = 0; 503265d490d0Smrg } 503365d490d0Smrg if (quote_around) 503465d490d0Smrg { 503565d490d0Smrg unsigned int j; 503665d490d0Smrg for (j = backslashes; j > 0; j--) 503765d490d0Smrg *p++ = '\\'; 503865d490d0Smrg *p++ = '"'; 503965d490d0Smrg } 504065d490d0Smrg *p = '\0'; 504165d490d0Smrg 504265d490d0Smrg new_argv[i] = quoted_string; 504365d490d0Smrg } 504465d490d0Smrg else 504565d490d0Smrg new_argv[i] = (char *) string; 504665d490d0Smrg } 504765d490d0Smrg new_argv[argc] = NULL; 5048e4da13eeSmacallan 504965d490d0Smrg return new_argv; 5050e4da13eeSmacallan} 505165d490d0SmrgEOF 505265d490d0Smrg ;; 505365d490d0Smrg esac 5054e4da13eeSmacallan 505565d490d0Smrg cat <<"EOF" 505665d490d0Smrgvoid lt_dump_script (FILE* f) 5057e4da13eeSmacallan{ 505865d490d0SmrgEOF 505965d490d0Smrg func_emit_wrapper yes | 506065d490d0Smrg $SED -e 's/\([\\"]\)/\\\1/g' \ 506165d490d0Smrg -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' 5062e4da13eeSmacallan 506365d490d0Smrg cat <<"EOF" 5064e4da13eeSmacallan} 506565d490d0SmrgEOF 5066e4da13eeSmacallan} 506765d490d0Smrg# end: func_emit_cwrapperexe_src 5068e4da13eeSmacallan 506965d490d0Smrg# func_win32_import_lib_p ARG 507065d490d0Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 507165d490d0Smrgfunc_win32_import_lib_p () 5072e4da13eeSmacallan{ 507365d490d0Smrg $opt_debug 507465d490d0Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 507565d490d0Smrg *import*) : ;; 507665d490d0Smrg *) false ;; 507765d490d0Smrg esac 5078e4da13eeSmacallan} 5079e4da13eeSmacallan 508065d490d0Smrg# func_mode_link arg... 508165d490d0Smrgfunc_mode_link () 5082e4da13eeSmacallan{ 508365d490d0Smrg $opt_debug 508465d490d0Smrg case $host in 508565d490d0Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 508665d490d0Smrg # It is impossible to link a dll without this setting, and 508765d490d0Smrg # we shouldn't force the makefile maintainer to figure out 508865d490d0Smrg # which system we are compiling for in order to pass an extra 508965d490d0Smrg # flag for every libtool invocation. 509065d490d0Smrg # allow_undefined=no 5091e4da13eeSmacallan 509265d490d0Smrg # FIXME: Unfortunately, there are problems with the above when trying 509365d490d0Smrg # to make a dll which has undefined symbols, in which case not 509465d490d0Smrg # even a static library is built. For now, we need to specify 509565d490d0Smrg # -no-undefined on the libtool link line when we can be certain 509665d490d0Smrg # that all symbols are satisfied, otherwise we get a static library. 509765d490d0Smrg allow_undefined=yes 509865d490d0Smrg ;; 509965d490d0Smrg *) 510065d490d0Smrg allow_undefined=yes 510165d490d0Smrg ;; 510265d490d0Smrg esac 510365d490d0Smrg libtool_args=$nonopt 510465d490d0Smrg base_compile="$nonopt $@" 510565d490d0Smrg compile_command=$nonopt 510665d490d0Smrg finalize_command=$nonopt 5107e4da13eeSmacallan 510865d490d0Smrg compile_rpath= 510965d490d0Smrg finalize_rpath= 511065d490d0Smrg compile_shlibpath= 511165d490d0Smrg finalize_shlibpath= 511265d490d0Smrg convenience= 511365d490d0Smrg old_convenience= 511465d490d0Smrg deplibs= 511565d490d0Smrg old_deplibs= 511665d490d0Smrg compiler_flags= 511765d490d0Smrg linker_flags= 511865d490d0Smrg dllsearchpath= 511965d490d0Smrg lib_search_path=`pwd` 512065d490d0Smrg inst_prefix_dir= 512165d490d0Smrg new_inherited_linker_flags= 5122e4da13eeSmacallan 512365d490d0Smrg avoid_version=no 512465d490d0Smrg bindir= 512565d490d0Smrg dlfiles= 512665d490d0Smrg dlprefiles= 512765d490d0Smrg dlself=no 512865d490d0Smrg export_dynamic=no 512965d490d0Smrg export_symbols= 513065d490d0Smrg export_symbols_regex= 513165d490d0Smrg generated= 513265d490d0Smrg libobjs= 513365d490d0Smrg ltlibs= 513465d490d0Smrg module=no 513565d490d0Smrg no_install=no 513665d490d0Smrg objs= 513765d490d0Smrg non_pic_objects= 513865d490d0Smrg precious_files_regex= 513965d490d0Smrg prefer_static_libs=no 514065d490d0Smrg preload=no 514165d490d0Smrg prev= 514265d490d0Smrg prevarg= 514365d490d0Smrg release= 514465d490d0Smrg rpath= 514565d490d0Smrg xrpath= 514665d490d0Smrg perm_rpath= 514765d490d0Smrg temp_rpath= 514865d490d0Smrg thread_safe=no 514965d490d0Smrg vinfo= 515065d490d0Smrg vinfo_number=no 515165d490d0Smrg weak_libs= 515265d490d0Smrg single_module="${wl}-single_module" 515365d490d0Smrg func_infer_tag $base_compile 5154e4da13eeSmacallan 515565d490d0Smrg # We need to know -static, to get the right output filenames. 515665d490d0Smrg for arg 515765d490d0Smrg do 515865d490d0Smrg case $arg in 515965d490d0Smrg -shared) 516065d490d0Smrg test "$build_libtool_libs" != yes && \ 516165d490d0Smrg func_fatal_configuration "can not build a shared library" 516265d490d0Smrg build_old_libs=no 516365d490d0Smrg break 516465d490d0Smrg ;; 516565d490d0Smrg -all-static | -static | -static-libtool-libs) 516665d490d0Smrg case $arg in 516765d490d0Smrg -all-static) 516865d490d0Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 516965d490d0Smrg func_warning "complete static linking is impossible in this configuration" 517065d490d0Smrg fi 517165d490d0Smrg if test -n "$link_static_flag"; then 517265d490d0Smrg dlopen_self=$dlopen_self_static 517365d490d0Smrg fi 517465d490d0Smrg prefer_static_libs=yes 517565d490d0Smrg ;; 517665d490d0Smrg -static) 517765d490d0Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 517865d490d0Smrg dlopen_self=$dlopen_self_static 517965d490d0Smrg fi 518065d490d0Smrg prefer_static_libs=built 518165d490d0Smrg ;; 518265d490d0Smrg -static-libtool-libs) 518365d490d0Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 518465d490d0Smrg dlopen_self=$dlopen_self_static 518565d490d0Smrg fi 518665d490d0Smrg prefer_static_libs=yes 518765d490d0Smrg ;; 518865d490d0Smrg esac 518965d490d0Smrg build_libtool_libs=no 519065d490d0Smrg build_old_libs=yes 519165d490d0Smrg break 519265d490d0Smrg ;; 519365d490d0Smrg esac 519465d490d0Smrg done 5195e4da13eeSmacallan 519665d490d0Smrg # See if our shared archives depend on static archives. 519765d490d0Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 5198e4da13eeSmacallan 519965d490d0Smrg # Go through the arguments, transforming them on the way. 520065d490d0Smrg while test "$#" -gt 0; do 520165d490d0Smrg arg="$1" 520265d490d0Smrg shift 520365d490d0Smrg func_quote_for_eval "$arg" 520465d490d0Smrg qarg=$func_quote_for_eval_unquoted_result 520565d490d0Smrg func_append libtool_args " $func_quote_for_eval_result" 5206e4da13eeSmacallan 520765d490d0Smrg # If the previous option needs an argument, assign it. 520865d490d0Smrg if test -n "$prev"; then 520965d490d0Smrg case $prev in 521065d490d0Smrg output) 521165d490d0Smrg func_append compile_command " @OUTPUT@" 521265d490d0Smrg func_append finalize_command " @OUTPUT@" 521365d490d0Smrg ;; 521465d490d0Smrg esac 5215e4da13eeSmacallan 521665d490d0Smrg case $prev in 521765d490d0Smrg bindir) 521865d490d0Smrg bindir="$arg" 521965d490d0Smrg prev= 522065d490d0Smrg continue 522165d490d0Smrg ;; 522265d490d0Smrg dlfiles|dlprefiles) 522365d490d0Smrg if test "$preload" = no; then 522465d490d0Smrg # Add the symbol object into the linking commands. 522565d490d0Smrg func_append compile_command " @SYMFILE@" 522665d490d0Smrg func_append finalize_command " @SYMFILE@" 522765d490d0Smrg preload=yes 522865d490d0Smrg fi 522965d490d0Smrg case $arg in 523065d490d0Smrg *.la | *.lo) ;; # We handle these cases below. 523165d490d0Smrg force) 523265d490d0Smrg if test "$dlself" = no; then 523365d490d0Smrg dlself=needless 523465d490d0Smrg export_dynamic=yes 523565d490d0Smrg fi 523665d490d0Smrg prev= 523765d490d0Smrg continue 523865d490d0Smrg ;; 523965d490d0Smrg self) 524065d490d0Smrg if test "$prev" = dlprefiles; then 524165d490d0Smrg dlself=yes 524265d490d0Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 524365d490d0Smrg dlself=yes 524465d490d0Smrg else 524565d490d0Smrg dlself=needless 524665d490d0Smrg export_dynamic=yes 524765d490d0Smrg fi 524865d490d0Smrg prev= 524965d490d0Smrg continue 525065d490d0Smrg ;; 525165d490d0Smrg *) 525265d490d0Smrg if test "$prev" = dlfiles; then 525365d490d0Smrg func_append dlfiles " $arg" 525465d490d0Smrg else 525565d490d0Smrg func_append dlprefiles " $arg" 525665d490d0Smrg fi 525765d490d0Smrg prev= 525865d490d0Smrg continue 525965d490d0Smrg ;; 526065d490d0Smrg esac 526165d490d0Smrg ;; 526265d490d0Smrg expsyms) 526365d490d0Smrg export_symbols="$arg" 526465d490d0Smrg test -f "$arg" \ 526565d490d0Smrg || func_fatal_error "symbol file \`$arg' does not exist" 526665d490d0Smrg prev= 526765d490d0Smrg continue 526865d490d0Smrg ;; 526965d490d0Smrg expsyms_regex) 527065d490d0Smrg export_symbols_regex="$arg" 527165d490d0Smrg prev= 527265d490d0Smrg continue 527365d490d0Smrg ;; 527465d490d0Smrg framework) 527565d490d0Smrg case $host in 527665d490d0Smrg *-*-darwin*) 527765d490d0Smrg case "$deplibs " in 527865d490d0Smrg *" $qarg.ltframework "*) ;; 527965d490d0Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 528065d490d0Smrg ;; 528165d490d0Smrg esac 528265d490d0Smrg ;; 528365d490d0Smrg esac 528465d490d0Smrg prev= 528565d490d0Smrg continue 528665d490d0Smrg ;; 528765d490d0Smrg inst_prefix) 528865d490d0Smrg inst_prefix_dir="$arg" 528965d490d0Smrg prev= 529065d490d0Smrg continue 529165d490d0Smrg ;; 529265d490d0Smrg objectlist) 529365d490d0Smrg if test -f "$arg"; then 529465d490d0Smrg save_arg=$arg 529565d490d0Smrg moreargs= 529665d490d0Smrg for fil in `cat "$save_arg"` 529765d490d0Smrg do 529865d490d0Smrg# func_append moreargs " $fil" 529965d490d0Smrg arg=$fil 530065d490d0Smrg # A libtool-controlled object. 5301e4da13eeSmacallan 530265d490d0Smrg # Check to see that this really is a libtool object. 530365d490d0Smrg if func_lalib_unsafe_p "$arg"; then 530465d490d0Smrg pic_object= 530565d490d0Smrg non_pic_object= 5306e4da13eeSmacallan 530765d490d0Smrg # Read the .lo file 530865d490d0Smrg func_source "$arg" 5309e4da13eeSmacallan 531065d490d0Smrg if test -z "$pic_object" || 531165d490d0Smrg test -z "$non_pic_object" || 531265d490d0Smrg test "$pic_object" = none && 531365d490d0Smrg test "$non_pic_object" = none; then 531465d490d0Smrg func_fatal_error "cannot find name of object for \`$arg'" 531565d490d0Smrg fi 5316e4da13eeSmacallan 531765d490d0Smrg # Extract subdirectory from the argument. 531865d490d0Smrg func_dirname "$arg" "/" "" 531965d490d0Smrg xdir="$func_dirname_result" 5320e4da13eeSmacallan 532165d490d0Smrg if test "$pic_object" != none; then 532265d490d0Smrg # Prepend the subdirectory the object is found in. 532365d490d0Smrg pic_object="$xdir$pic_object" 5324e4da13eeSmacallan 532565d490d0Smrg if test "$prev" = dlfiles; then 532665d490d0Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 532765d490d0Smrg func_append dlfiles " $pic_object" 532865d490d0Smrg prev= 532965d490d0Smrg continue 533065d490d0Smrg else 533165d490d0Smrg # If libtool objects are unsupported, then we need to preload. 533265d490d0Smrg prev=dlprefiles 533365d490d0Smrg fi 533465d490d0Smrg fi 5335e4da13eeSmacallan 533665d490d0Smrg # CHECK ME: I think I busted this. -Ossama 533765d490d0Smrg if test "$prev" = dlprefiles; then 533865d490d0Smrg # Preload the old-style object. 533965d490d0Smrg func_append dlprefiles " $pic_object" 534065d490d0Smrg prev= 534165d490d0Smrg fi 5342e4da13eeSmacallan 534365d490d0Smrg # A PIC object. 534465d490d0Smrg func_append libobjs " $pic_object" 534565d490d0Smrg arg="$pic_object" 534665d490d0Smrg fi 5347e4da13eeSmacallan 534865d490d0Smrg # Non-PIC object. 534965d490d0Smrg if test "$non_pic_object" != none; then 535065d490d0Smrg # Prepend the subdirectory the object is found in. 535165d490d0Smrg non_pic_object="$xdir$non_pic_object" 5352e4da13eeSmacallan 535365d490d0Smrg # A standard non-PIC object 535465d490d0Smrg func_append non_pic_objects " $non_pic_object" 535565d490d0Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 535665d490d0Smrg arg="$non_pic_object" 535765d490d0Smrg fi 535865d490d0Smrg else 535965d490d0Smrg # If the PIC object exists, use it instead. 536065d490d0Smrg # $xdir was prepended to $pic_object above. 536165d490d0Smrg non_pic_object="$pic_object" 536265d490d0Smrg func_append non_pic_objects " $non_pic_object" 536365d490d0Smrg fi 536465d490d0Smrg else 536565d490d0Smrg # Only an error if not doing a dry-run. 536665d490d0Smrg if $opt_dry_run; then 536765d490d0Smrg # Extract subdirectory from the argument. 536865d490d0Smrg func_dirname "$arg" "/" "" 536965d490d0Smrg xdir="$func_dirname_result" 537065d490d0Smrg 537165d490d0Smrg func_lo2o "$arg" 537265d490d0Smrg pic_object=$xdir$objdir/$func_lo2o_result 537365d490d0Smrg non_pic_object=$xdir$func_lo2o_result 537465d490d0Smrg func_append libobjs " $pic_object" 537565d490d0Smrg func_append non_pic_objects " $non_pic_object" 537665d490d0Smrg else 537765d490d0Smrg func_fatal_error "\`$arg' is not a valid libtool object" 537865d490d0Smrg fi 537965d490d0Smrg fi 538065d490d0Smrg done 538165d490d0Smrg else 538265d490d0Smrg func_fatal_error "link input file \`$arg' does not exist" 538365d490d0Smrg fi 538465d490d0Smrg arg=$save_arg 538565d490d0Smrg prev= 538665d490d0Smrg continue 538765d490d0Smrg ;; 538865d490d0Smrg precious_regex) 538965d490d0Smrg precious_files_regex="$arg" 539065d490d0Smrg prev= 539165d490d0Smrg continue 539265d490d0Smrg ;; 539365d490d0Smrg release) 539465d490d0Smrg release="-$arg" 539565d490d0Smrg prev= 539665d490d0Smrg continue 539765d490d0Smrg ;; 539865d490d0Smrg rpath | xrpath) 539965d490d0Smrg # We need an absolute path. 540065d490d0Smrg case $arg in 540165d490d0Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 540265d490d0Smrg *) 540365d490d0Smrg func_fatal_error "only absolute run-paths are allowed" 540465d490d0Smrg ;; 540565d490d0Smrg esac 540665d490d0Smrg if test "$prev" = rpath; then 540765d490d0Smrg case "$rpath " in 540865d490d0Smrg *" $arg "*) ;; 540965d490d0Smrg *) func_append rpath " $arg" ;; 541065d490d0Smrg esac 541165d490d0Smrg else 541265d490d0Smrg case "$xrpath " in 541365d490d0Smrg *" $arg "*) ;; 541465d490d0Smrg *) func_append xrpath " $arg" ;; 541565d490d0Smrg esac 541665d490d0Smrg fi 541765d490d0Smrg prev= 541865d490d0Smrg continue 541965d490d0Smrg ;; 542065d490d0Smrg shrext) 542165d490d0Smrg shrext_cmds="$arg" 542265d490d0Smrg prev= 542365d490d0Smrg continue 542465d490d0Smrg ;; 542565d490d0Smrg weak) 542665d490d0Smrg func_append weak_libs " $arg" 542765d490d0Smrg prev= 542865d490d0Smrg continue 542965d490d0Smrg ;; 543065d490d0Smrg xcclinker) 543165d490d0Smrg func_append linker_flags " $qarg" 543265d490d0Smrg func_append compiler_flags " $qarg" 543365d490d0Smrg prev= 543465d490d0Smrg func_append compile_command " $qarg" 543565d490d0Smrg func_append finalize_command " $qarg" 543665d490d0Smrg continue 543765d490d0Smrg ;; 543865d490d0Smrg xcompiler) 543965d490d0Smrg func_append compiler_flags " $qarg" 544065d490d0Smrg prev= 544165d490d0Smrg func_append compile_command " $qarg" 544265d490d0Smrg func_append finalize_command " $qarg" 544365d490d0Smrg continue 544465d490d0Smrg ;; 544565d490d0Smrg xlinker) 544665d490d0Smrg func_append linker_flags " $qarg" 544765d490d0Smrg func_append compiler_flags " $wl$qarg" 544865d490d0Smrg prev= 544965d490d0Smrg func_append compile_command " $wl$qarg" 545065d490d0Smrg func_append finalize_command " $wl$qarg" 545165d490d0Smrg continue 545265d490d0Smrg ;; 545365d490d0Smrg *) 545465d490d0Smrg eval "$prev=\"\$arg\"" 545565d490d0Smrg prev= 545665d490d0Smrg continue 545765d490d0Smrg ;; 545865d490d0Smrg esac 545965d490d0Smrg fi # test -n "$prev" 5460e4da13eeSmacallan 546165d490d0Smrg prevarg="$arg" 5462e4da13eeSmacallan 546365d490d0Smrg case $arg in 546465d490d0Smrg -all-static) 546565d490d0Smrg if test -n "$link_static_flag"; then 546665d490d0Smrg # See comment for -static flag below, for more details. 546765d490d0Smrg func_append compile_command " $link_static_flag" 546865d490d0Smrg func_append finalize_command " $link_static_flag" 546965d490d0Smrg fi 547065d490d0Smrg continue 547165d490d0Smrg ;; 5472e4da13eeSmacallan 547365d490d0Smrg -allow-undefined) 547465d490d0Smrg # FIXME: remove this flag sometime in the future. 547565d490d0Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 547665d490d0Smrg ;; 5477e4da13eeSmacallan 547865d490d0Smrg -avoid-version) 547965d490d0Smrg avoid_version=yes 548065d490d0Smrg continue 548165d490d0Smrg ;; 5482e4da13eeSmacallan 548365d490d0Smrg -bindir) 548465d490d0Smrg prev=bindir 548565d490d0Smrg continue 548665d490d0Smrg ;; 548765d490d0Smrg 548865d490d0Smrg -dlopen) 548965d490d0Smrg prev=dlfiles 549065d490d0Smrg continue 549165d490d0Smrg ;; 549265d490d0Smrg 549365d490d0Smrg -dlpreopen) 549465d490d0Smrg prev=dlprefiles 549565d490d0Smrg continue 549665d490d0Smrg ;; 549765d490d0Smrg 549865d490d0Smrg -export-dynamic) 549965d490d0Smrg export_dynamic=yes 550065d490d0Smrg continue 550165d490d0Smrg ;; 550265d490d0Smrg 550365d490d0Smrg -export-symbols | -export-symbols-regex) 550465d490d0Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 550565d490d0Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 550665d490d0Smrg fi 550765d490d0Smrg if test "X$arg" = "X-export-symbols"; then 550865d490d0Smrg prev=expsyms 550965d490d0Smrg else 551065d490d0Smrg prev=expsyms_regex 551165d490d0Smrg fi 551265d490d0Smrg continue 551365d490d0Smrg ;; 551465d490d0Smrg 551565d490d0Smrg -framework) 551665d490d0Smrg prev=framework 551765d490d0Smrg continue 551865d490d0Smrg ;; 551965d490d0Smrg 552065d490d0Smrg -inst-prefix-dir) 552165d490d0Smrg prev=inst_prefix 552265d490d0Smrg continue 552365d490d0Smrg ;; 552465d490d0Smrg 552565d490d0Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 552665d490d0Smrg # so, if we see these flags be careful not to treat them like -L 552765d490d0Smrg -L[A-Z][A-Z]*:*) 552865d490d0Smrg case $with_gcc/$host in 552965d490d0Smrg no/*-*-irix* | /*-*-irix*) 553065d490d0Smrg func_append compile_command " $arg" 553165d490d0Smrg func_append finalize_command " $arg" 553265d490d0Smrg ;; 553365d490d0Smrg esac 553465d490d0Smrg continue 553565d490d0Smrg ;; 553665d490d0Smrg 553765d490d0Smrg -L*) 553865d490d0Smrg func_stripname "-L" '' "$arg" 553965d490d0Smrg if test -z "$func_stripname_result"; then 554065d490d0Smrg if test "$#" -gt 0; then 554165d490d0Smrg func_fatal_error "require no space between \`-L' and \`$1'" 554265d490d0Smrg else 554365d490d0Smrg func_fatal_error "need path for \`-L' option" 554465d490d0Smrg fi 554565d490d0Smrg fi 554665d490d0Smrg func_resolve_sysroot "$func_stripname_result" 554765d490d0Smrg dir=$func_resolve_sysroot_result 554865d490d0Smrg # We need an absolute path. 554965d490d0Smrg case $dir in 555065d490d0Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 555165d490d0Smrg *) 555265d490d0Smrg absdir=`cd "$dir" && pwd` 555365d490d0Smrg test -z "$absdir" && \ 555465d490d0Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 555565d490d0Smrg dir="$absdir" 555665d490d0Smrg ;; 555765d490d0Smrg esac 555865d490d0Smrg case "$deplibs " in 555965d490d0Smrg *" -L$dir "* | *" $arg "*) 556065d490d0Smrg # Will only happen for absolute or sysroot arguments 556165d490d0Smrg ;; 556265d490d0Smrg *) 556365d490d0Smrg # Preserve sysroot, but never include relative directories 556465d490d0Smrg case $dir in 556565d490d0Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 556665d490d0Smrg *) func_append deplibs " -L$dir" ;; 556765d490d0Smrg esac 556865d490d0Smrg func_append lib_search_path " $dir" 556965d490d0Smrg ;; 557065d490d0Smrg esac 557165d490d0Smrg case $host in 557265d490d0Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 557365d490d0Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 557465d490d0Smrg case :$dllsearchpath: in 557565d490d0Smrg *":$dir:"*) ;; 557665d490d0Smrg ::) dllsearchpath=$dir;; 557765d490d0Smrg *) func_append dllsearchpath ":$dir";; 557865d490d0Smrg esac 557965d490d0Smrg case :$dllsearchpath: in 558065d490d0Smrg *":$testbindir:"*) ;; 558165d490d0Smrg ::) dllsearchpath=$testbindir;; 558265d490d0Smrg *) func_append dllsearchpath ":$testbindir";; 558365d490d0Smrg esac 558465d490d0Smrg ;; 558565d490d0Smrg esac 558665d490d0Smrg continue 558765d490d0Smrg ;; 558865d490d0Smrg 558965d490d0Smrg -l*) 559065d490d0Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 559165d490d0Smrg case $host in 559265d490d0Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 559365d490d0Smrg # These systems don't actually have a C or math library (as such) 559465d490d0Smrg continue 559565d490d0Smrg ;; 559665d490d0Smrg *-*-os2*) 559765d490d0Smrg # These systems don't actually have a C library (as such) 559865d490d0Smrg test "X$arg" = "X-lc" && continue 559965d490d0Smrg ;; 560065d490d0Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 560165d490d0Smrg # Do not include libc due to us having libc/libc_r. 560265d490d0Smrg test "X$arg" = "X-lc" && continue 560365d490d0Smrg ;; 560465d490d0Smrg *-*-rhapsody* | *-*-darwin1.[012]) 560565d490d0Smrg # Rhapsody C and math libraries are in the System framework 560665d490d0Smrg func_append deplibs " System.ltframework" 560765d490d0Smrg continue 560865d490d0Smrg ;; 560965d490d0Smrg *-*-sco3.2v5* | *-*-sco5v6*) 561065d490d0Smrg # Causes problems with __ctype 561165d490d0Smrg test "X$arg" = "X-lc" && continue 561265d490d0Smrg ;; 561365d490d0Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 561465d490d0Smrg # Compiler inserts libc in the correct place for threads to work 561565d490d0Smrg test "X$arg" = "X-lc" && continue 561665d490d0Smrg ;; 561765d490d0Smrg esac 561865d490d0Smrg elif test "X$arg" = "X-lc_r"; then 561965d490d0Smrg case $host in 562065d490d0Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 562165d490d0Smrg # Do not include libc_r directly, use -pthread flag. 562265d490d0Smrg continue 562365d490d0Smrg ;; 562465d490d0Smrg esac 562565d490d0Smrg fi 562665d490d0Smrg func_append deplibs " $arg" 562765d490d0Smrg continue 562865d490d0Smrg ;; 562965d490d0Smrg 563065d490d0Smrg -module) 563165d490d0Smrg module=yes 563265d490d0Smrg continue 563365d490d0Smrg ;; 563465d490d0Smrg 563565d490d0Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 563665d490d0Smrg # classes, name mangling, and exception handling. 563765d490d0Smrg # Darwin uses the -arch flag to determine output architecture. 563865d490d0Smrg -model|-arch|-isysroot|--sysroot) 563965d490d0Smrg func_append compiler_flags " $arg" 564065d490d0Smrg func_append compile_command " $arg" 564165d490d0Smrg func_append finalize_command " $arg" 564265d490d0Smrg prev=xcompiler 564365d490d0Smrg continue 564465d490d0Smrg ;; 564565d490d0Smrg 564665d490d0Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 564765d490d0Smrg func_append compiler_flags " $arg" 564865d490d0Smrg func_append compile_command " $arg" 564965d490d0Smrg func_append finalize_command " $arg" 565065d490d0Smrg case "$new_inherited_linker_flags " in 565165d490d0Smrg *" $arg "*) ;; 565265d490d0Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 565365d490d0Smrg esac 565465d490d0Smrg continue 565565d490d0Smrg ;; 565665d490d0Smrg 565765d490d0Smrg -multi_module) 565865d490d0Smrg single_module="${wl}-multi_module" 565965d490d0Smrg continue 566065d490d0Smrg ;; 566165d490d0Smrg 566265d490d0Smrg -no-fast-install) 566365d490d0Smrg fast_install=no 566465d490d0Smrg continue 566565d490d0Smrg ;; 566665d490d0Smrg 566765d490d0Smrg -no-install) 566865d490d0Smrg case $host in 566965d490d0Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 567065d490d0Smrg # The PATH hackery in wrapper scripts is required on Windows 567165d490d0Smrg # and Darwin in order for the loader to find any dlls it needs. 567265d490d0Smrg func_warning "\`-no-install' is ignored for $host" 567365d490d0Smrg func_warning "assuming \`-no-fast-install' instead" 567465d490d0Smrg fast_install=no 567565d490d0Smrg ;; 567665d490d0Smrg *) no_install=yes ;; 567765d490d0Smrg esac 567865d490d0Smrg continue 567965d490d0Smrg ;; 568065d490d0Smrg 568165d490d0Smrg -no-undefined) 568265d490d0Smrg allow_undefined=no 568365d490d0Smrg continue 568465d490d0Smrg ;; 568565d490d0Smrg 568665d490d0Smrg -objectlist) 568765d490d0Smrg prev=objectlist 568865d490d0Smrg continue 568965d490d0Smrg ;; 569065d490d0Smrg 569165d490d0Smrg -o) prev=output ;; 569265d490d0Smrg 569365d490d0Smrg -precious-files-regex) 569465d490d0Smrg prev=precious_regex 569565d490d0Smrg continue 569665d490d0Smrg ;; 569765d490d0Smrg 569865d490d0Smrg -release) 569965d490d0Smrg prev=release 570065d490d0Smrg continue 570165d490d0Smrg ;; 570265d490d0Smrg 570365d490d0Smrg -rpath) 570465d490d0Smrg prev=rpath 570565d490d0Smrg continue 570665d490d0Smrg ;; 570765d490d0Smrg 570865d490d0Smrg -R) 570965d490d0Smrg prev=xrpath 571065d490d0Smrg continue 571165d490d0Smrg ;; 571265d490d0Smrg 571365d490d0Smrg -R*) 571465d490d0Smrg func_stripname '-R' '' "$arg" 571565d490d0Smrg dir=$func_stripname_result 571665d490d0Smrg # We need an absolute path. 571765d490d0Smrg case $dir in 571865d490d0Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 571965d490d0Smrg =*) 572065d490d0Smrg func_stripname '=' '' "$dir" 572165d490d0Smrg dir=$lt_sysroot$func_stripname_result 572265d490d0Smrg ;; 572365d490d0Smrg *) 572465d490d0Smrg func_fatal_error "only absolute run-paths are allowed" 572565d490d0Smrg ;; 572665d490d0Smrg esac 572765d490d0Smrg case "$xrpath " in 572865d490d0Smrg *" $dir "*) ;; 572965d490d0Smrg *) func_append xrpath " $dir" ;; 573065d490d0Smrg esac 573165d490d0Smrg continue 573265d490d0Smrg ;; 573365d490d0Smrg 573465d490d0Smrg -shared) 573565d490d0Smrg # The effects of -shared are defined in a previous loop. 573665d490d0Smrg continue 573765d490d0Smrg ;; 573865d490d0Smrg 573965d490d0Smrg -shrext) 574065d490d0Smrg prev=shrext 574165d490d0Smrg continue 574265d490d0Smrg ;; 574365d490d0Smrg 574465d490d0Smrg -static | -static-libtool-libs) 574565d490d0Smrg # The effects of -static are defined in a previous loop. 574665d490d0Smrg # We used to do the same as -all-static on platforms that 574765d490d0Smrg # didn't have a PIC flag, but the assumption that the effects 574865d490d0Smrg # would be equivalent was wrong. It would break on at least 574965d490d0Smrg # Digital Unix and AIX. 575065d490d0Smrg continue 575165d490d0Smrg ;; 575265d490d0Smrg 575365d490d0Smrg -thread-safe) 575465d490d0Smrg thread_safe=yes 575565d490d0Smrg continue 575665d490d0Smrg ;; 575765d490d0Smrg 575865d490d0Smrg -version-info) 575965d490d0Smrg prev=vinfo 576065d490d0Smrg continue 576165d490d0Smrg ;; 576265d490d0Smrg 576365d490d0Smrg -version-number) 576465d490d0Smrg prev=vinfo 576565d490d0Smrg vinfo_number=yes 576665d490d0Smrg continue 576765d490d0Smrg ;; 576865d490d0Smrg 576965d490d0Smrg -weak) 577065d490d0Smrg prev=weak 577165d490d0Smrg continue 577265d490d0Smrg ;; 577365d490d0Smrg 577465d490d0Smrg -Wc,*) 577565d490d0Smrg func_stripname '-Wc,' '' "$arg" 577665d490d0Smrg args=$func_stripname_result 577765d490d0Smrg arg= 577865d490d0Smrg save_ifs="$IFS"; IFS=',' 577965d490d0Smrg for flag in $args; do 578065d490d0Smrg IFS="$save_ifs" 578165d490d0Smrg func_quote_for_eval "$flag" 578265d490d0Smrg func_append arg " $func_quote_for_eval_result" 578365d490d0Smrg func_append compiler_flags " $func_quote_for_eval_result" 578465d490d0Smrg done 578565d490d0Smrg IFS="$save_ifs" 578665d490d0Smrg func_stripname ' ' '' "$arg" 578765d490d0Smrg arg=$func_stripname_result 578865d490d0Smrg ;; 578965d490d0Smrg 579065d490d0Smrg -Wl,*) 579165d490d0Smrg func_stripname '-Wl,' '' "$arg" 579265d490d0Smrg args=$func_stripname_result 579365d490d0Smrg arg= 579465d490d0Smrg save_ifs="$IFS"; IFS=',' 579565d490d0Smrg for flag in $args; do 579665d490d0Smrg IFS="$save_ifs" 579765d490d0Smrg func_quote_for_eval "$flag" 579865d490d0Smrg func_append arg " $wl$func_quote_for_eval_result" 579965d490d0Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 580065d490d0Smrg func_append linker_flags " $func_quote_for_eval_result" 580165d490d0Smrg done 580265d490d0Smrg IFS="$save_ifs" 580365d490d0Smrg func_stripname ' ' '' "$arg" 580465d490d0Smrg arg=$func_stripname_result 580565d490d0Smrg ;; 580665d490d0Smrg 580765d490d0Smrg -Xcompiler) 580865d490d0Smrg prev=xcompiler 580965d490d0Smrg continue 581065d490d0Smrg ;; 581165d490d0Smrg 581265d490d0Smrg -Xlinker) 581365d490d0Smrg prev=xlinker 581465d490d0Smrg continue 581565d490d0Smrg ;; 581665d490d0Smrg 581765d490d0Smrg -XCClinker) 581865d490d0Smrg prev=xcclinker 581965d490d0Smrg continue 582065d490d0Smrg ;; 582165d490d0Smrg 582265d490d0Smrg # -msg_* for osf cc 582365d490d0Smrg -msg_*) 582465d490d0Smrg func_quote_for_eval "$arg" 582565d490d0Smrg arg="$func_quote_for_eval_result" 582665d490d0Smrg ;; 582765d490d0Smrg 582865d490d0Smrg # Flags to be passed through unchanged, with rationale: 582965d490d0Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 583065d490d0Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 583165d490d0Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 583265d490d0Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 583365d490d0Smrg # -q* compiler args for the IBM compiler 583465d490d0Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 583565d490d0Smrg # -F/path path to uninstalled frameworks, gcc on darwin 583665d490d0Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 583765d490d0Smrg # @file GCC response files 583865d490d0Smrg # -tp=* Portland pgcc target processor selection 583965d490d0Smrg # --sysroot=* for sysroot support 584065d490d0Smrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 584165d490d0Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 584265d490d0Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 584365d490d0Smrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 584465d490d0Smrg func_quote_for_eval "$arg" 584565d490d0Smrg arg="$func_quote_for_eval_result" 584665d490d0Smrg func_append compile_command " $arg" 584765d490d0Smrg func_append finalize_command " $arg" 584865d490d0Smrg func_append compiler_flags " $arg" 584965d490d0Smrg continue 585065d490d0Smrg ;; 585165d490d0Smrg 585265d490d0Smrg # Some other compiler flag. 585365d490d0Smrg -* | +*) 585465d490d0Smrg func_quote_for_eval "$arg" 585565d490d0Smrg arg="$func_quote_for_eval_result" 585665d490d0Smrg ;; 585765d490d0Smrg 585865d490d0Smrg *.$objext) 585965d490d0Smrg # A standard object. 586065d490d0Smrg func_append objs " $arg" 586165d490d0Smrg ;; 586265d490d0Smrg 586365d490d0Smrg *.lo) 586465d490d0Smrg # A libtool-controlled object. 586565d490d0Smrg 586665d490d0Smrg # Check to see that this really is a libtool object. 586765d490d0Smrg if func_lalib_unsafe_p "$arg"; then 586865d490d0Smrg pic_object= 586965d490d0Smrg non_pic_object= 587065d490d0Smrg 587165d490d0Smrg # Read the .lo file 587265d490d0Smrg func_source "$arg" 587365d490d0Smrg 587465d490d0Smrg if test -z "$pic_object" || 587565d490d0Smrg test -z "$non_pic_object" || 587665d490d0Smrg test "$pic_object" = none && 587765d490d0Smrg test "$non_pic_object" = none; then 587865d490d0Smrg func_fatal_error "cannot find name of object for \`$arg'" 587965d490d0Smrg fi 588065d490d0Smrg 588165d490d0Smrg # Extract subdirectory from the argument. 588265d490d0Smrg func_dirname "$arg" "/" "" 588365d490d0Smrg xdir="$func_dirname_result" 588465d490d0Smrg 588565d490d0Smrg if test "$pic_object" != none; then 588665d490d0Smrg # Prepend the subdirectory the object is found in. 588765d490d0Smrg pic_object="$xdir$pic_object" 588865d490d0Smrg 588965d490d0Smrg if test "$prev" = dlfiles; then 589065d490d0Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 589165d490d0Smrg func_append dlfiles " $pic_object" 589265d490d0Smrg prev= 589365d490d0Smrg continue 589465d490d0Smrg else 589565d490d0Smrg # If libtool objects are unsupported, then we need to preload. 589665d490d0Smrg prev=dlprefiles 589765d490d0Smrg fi 589865d490d0Smrg fi 589965d490d0Smrg 590065d490d0Smrg # CHECK ME: I think I busted this. -Ossama 590165d490d0Smrg if test "$prev" = dlprefiles; then 590265d490d0Smrg # Preload the old-style object. 590365d490d0Smrg func_append dlprefiles " $pic_object" 590465d490d0Smrg prev= 590565d490d0Smrg fi 590665d490d0Smrg 590765d490d0Smrg # A PIC object. 590865d490d0Smrg func_append libobjs " $pic_object" 590965d490d0Smrg arg="$pic_object" 591065d490d0Smrg fi 591165d490d0Smrg 591265d490d0Smrg # Non-PIC object. 591365d490d0Smrg if test "$non_pic_object" != none; then 591465d490d0Smrg # Prepend the subdirectory the object is found in. 591565d490d0Smrg non_pic_object="$xdir$non_pic_object" 591665d490d0Smrg 591765d490d0Smrg # A standard non-PIC object 591865d490d0Smrg func_append non_pic_objects " $non_pic_object" 591965d490d0Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 592065d490d0Smrg arg="$non_pic_object" 592165d490d0Smrg fi 592265d490d0Smrg else 592365d490d0Smrg # If the PIC object exists, use it instead. 592465d490d0Smrg # $xdir was prepended to $pic_object above. 592565d490d0Smrg non_pic_object="$pic_object" 592665d490d0Smrg func_append non_pic_objects " $non_pic_object" 592765d490d0Smrg fi 592865d490d0Smrg else 592965d490d0Smrg # Only an error if not doing a dry-run. 593065d490d0Smrg if $opt_dry_run; then 593165d490d0Smrg # Extract subdirectory from the argument. 593265d490d0Smrg func_dirname "$arg" "/" "" 593365d490d0Smrg xdir="$func_dirname_result" 593465d490d0Smrg 593565d490d0Smrg func_lo2o "$arg" 593665d490d0Smrg pic_object=$xdir$objdir/$func_lo2o_result 593765d490d0Smrg non_pic_object=$xdir$func_lo2o_result 593865d490d0Smrg func_append libobjs " $pic_object" 593965d490d0Smrg func_append non_pic_objects " $non_pic_object" 594065d490d0Smrg else 594165d490d0Smrg func_fatal_error "\`$arg' is not a valid libtool object" 594265d490d0Smrg fi 594365d490d0Smrg fi 594465d490d0Smrg ;; 594565d490d0Smrg 594665d490d0Smrg *.$libext) 594765d490d0Smrg # An archive. 594865d490d0Smrg func_append deplibs " $arg" 594965d490d0Smrg func_append old_deplibs " $arg" 595065d490d0Smrg continue 595165d490d0Smrg ;; 595265d490d0Smrg 595365d490d0Smrg *.la) 595465d490d0Smrg # A libtool-controlled library. 595565d490d0Smrg 595665d490d0Smrg func_resolve_sysroot "$arg" 595765d490d0Smrg if test "$prev" = dlfiles; then 595865d490d0Smrg # This library was specified with -dlopen. 595965d490d0Smrg func_append dlfiles " $func_resolve_sysroot_result" 596065d490d0Smrg prev= 596165d490d0Smrg elif test "$prev" = dlprefiles; then 596265d490d0Smrg # The library was specified with -dlpreopen. 596365d490d0Smrg func_append dlprefiles " $func_resolve_sysroot_result" 596465d490d0Smrg prev= 596565d490d0Smrg else 596665d490d0Smrg func_append deplibs " $func_resolve_sysroot_result" 596765d490d0Smrg fi 596865d490d0Smrg continue 596965d490d0Smrg ;; 597065d490d0Smrg 597165d490d0Smrg # Some other compiler argument. 597265d490d0Smrg *) 597365d490d0Smrg # Unknown arguments in both finalize_command and compile_command need 597465d490d0Smrg # to be aesthetically quoted because they are evaled later. 597565d490d0Smrg func_quote_for_eval "$arg" 597665d490d0Smrg arg="$func_quote_for_eval_result" 597765d490d0Smrg ;; 597865d490d0Smrg esac # arg 597965d490d0Smrg 598065d490d0Smrg # Now actually substitute the argument into the commands. 598165d490d0Smrg if test -n "$arg"; then 598265d490d0Smrg func_append compile_command " $arg" 598365d490d0Smrg func_append finalize_command " $arg" 598465d490d0Smrg fi 598565d490d0Smrg done # argument parsing loop 598665d490d0Smrg 598765d490d0Smrg test -n "$prev" && \ 598865d490d0Smrg func_fatal_help "the \`$prevarg' option requires an argument" 598965d490d0Smrg 599065d490d0Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 599165d490d0Smrg eval arg=\"$export_dynamic_flag_spec\" 599265d490d0Smrg func_append compile_command " $arg" 599365d490d0Smrg func_append finalize_command " $arg" 599465d490d0Smrg fi 599565d490d0Smrg 599665d490d0Smrg oldlibs= 599765d490d0Smrg # calculate the name of the file, without its directory 599865d490d0Smrg func_basename "$output" 599965d490d0Smrg outputname="$func_basename_result" 600065d490d0Smrg libobjs_save="$libobjs" 600165d490d0Smrg 600265d490d0Smrg if test -n "$shlibpath_var"; then 600365d490d0Smrg # get the directories listed in $shlibpath_var 600465d490d0Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 600565d490d0Smrg else 600665d490d0Smrg shlib_search_path= 600765d490d0Smrg fi 600865d490d0Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 600965d490d0Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 601065d490d0Smrg 601165d490d0Smrg func_dirname "$output" "/" "" 601265d490d0Smrg output_objdir="$func_dirname_result$objdir" 601365d490d0Smrg func_to_tool_file "$output_objdir/" 601465d490d0Smrg tool_output_objdir=$func_to_tool_file_result 601565d490d0Smrg # Create the object directory. 601665d490d0Smrg func_mkdir_p "$output_objdir" 601765d490d0Smrg 601865d490d0Smrg # Determine the type of output 601965d490d0Smrg case $output in 602065d490d0Smrg "") 602165d490d0Smrg func_fatal_help "you must specify an output file" 602265d490d0Smrg ;; 602365d490d0Smrg *.$libext) linkmode=oldlib ;; 602465d490d0Smrg *.lo | *.$objext) linkmode=obj ;; 602565d490d0Smrg *.la) linkmode=lib ;; 602665d490d0Smrg *) linkmode=prog ;; # Anything else should be a program. 602765d490d0Smrg esac 602865d490d0Smrg 602965d490d0Smrg specialdeplibs= 603065d490d0Smrg 603165d490d0Smrg libs= 603265d490d0Smrg # Find all interdependent deplibs by searching for libraries 603365d490d0Smrg # that are linked more than once (e.g. -la -lb -la) 603465d490d0Smrg for deplib in $deplibs; do 603565d490d0Smrg if $opt_preserve_dup_deps ; then 603665d490d0Smrg case "$libs " in 603765d490d0Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 603865d490d0Smrg esac 603965d490d0Smrg fi 604065d490d0Smrg func_append libs " $deplib" 604165d490d0Smrg done 604265d490d0Smrg 604365d490d0Smrg if test "$linkmode" = lib; then 604465d490d0Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 604565d490d0Smrg 604665d490d0Smrg # Compute libraries that are listed more than once in $predeps 604765d490d0Smrg # $postdeps and mark them as special (i.e., whose duplicates are 604865d490d0Smrg # not to be eliminated). 604965d490d0Smrg pre_post_deps= 605065d490d0Smrg if $opt_duplicate_compiler_generated_deps; then 605165d490d0Smrg for pre_post_dep in $predeps $postdeps; do 605265d490d0Smrg case "$pre_post_deps " in 605365d490d0Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 605465d490d0Smrg esac 605565d490d0Smrg func_append pre_post_deps " $pre_post_dep" 605665d490d0Smrg done 605765d490d0Smrg fi 605865d490d0Smrg pre_post_deps= 605965d490d0Smrg fi 606065d490d0Smrg 606165d490d0Smrg deplibs= 606265d490d0Smrg newdependency_libs= 606365d490d0Smrg newlib_search_path= 606465d490d0Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 606565d490d0Smrg notinst_deplibs= # not-installed libtool libraries 606665d490d0Smrg notinst_path= # paths that contain not-installed libtool libraries 606765d490d0Smrg 606865d490d0Smrg case $linkmode in 606965d490d0Smrg lib) 607065d490d0Smrg passes="conv dlpreopen link" 607165d490d0Smrg for file in $dlfiles $dlprefiles; do 607265d490d0Smrg case $file in 607365d490d0Smrg *.la) ;; 607465d490d0Smrg *) 607565d490d0Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 607665d490d0Smrg ;; 607765d490d0Smrg esac 607865d490d0Smrg done 607965d490d0Smrg ;; 608065d490d0Smrg prog) 608165d490d0Smrg compile_deplibs= 608265d490d0Smrg finalize_deplibs= 608365d490d0Smrg alldeplibs=no 608465d490d0Smrg newdlfiles= 608565d490d0Smrg newdlprefiles= 608665d490d0Smrg passes="conv scan dlopen dlpreopen link" 608765d490d0Smrg ;; 608865d490d0Smrg *) passes="conv" 608965d490d0Smrg ;; 609065d490d0Smrg esac 609165d490d0Smrg 609265d490d0Smrg for pass in $passes; do 609365d490d0Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 609465d490d0Smrg # so that -L comes before libs that need it for instance... 609565d490d0Smrg if test "$linkmode,$pass" = "lib,link"; then 609665d490d0Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 609765d490d0Smrg ## order, and fix it there properly 609865d490d0Smrg tmp_deplibs= 609965d490d0Smrg for deplib in $deplibs; do 610065d490d0Smrg tmp_deplibs="$deplib $tmp_deplibs" 610165d490d0Smrg done 610265d490d0Smrg deplibs="$tmp_deplibs" 610365d490d0Smrg fi 610465d490d0Smrg 610565d490d0Smrg if test "$linkmode,$pass" = "lib,link" || 610665d490d0Smrg test "$linkmode,$pass" = "prog,scan"; then 610765d490d0Smrg libs="$deplibs" 610865d490d0Smrg deplibs= 610965d490d0Smrg fi 611065d490d0Smrg if test "$linkmode" = prog; then 611165d490d0Smrg case $pass in 611265d490d0Smrg dlopen) libs="$dlfiles" ;; 611365d490d0Smrg dlpreopen) libs="$dlprefiles" ;; 611465d490d0Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 611565d490d0Smrg esac 611665d490d0Smrg fi 611765d490d0Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 611865d490d0Smrg # Collect and forward deplibs of preopened libtool libs 611965d490d0Smrg for lib in $dlprefiles; do 612065d490d0Smrg # Ignore non-libtool-libs 612165d490d0Smrg dependency_libs= 612265d490d0Smrg func_resolve_sysroot "$lib" 612365d490d0Smrg case $lib in 612465d490d0Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 612565d490d0Smrg esac 612665d490d0Smrg 612765d490d0Smrg # Collect preopened libtool deplibs, except any this library 612865d490d0Smrg # has declared as weak libs 612965d490d0Smrg for deplib in $dependency_libs; do 613065d490d0Smrg func_basename "$deplib" 613165d490d0Smrg deplib_base=$func_basename_result 613265d490d0Smrg case " $weak_libs " in 613365d490d0Smrg *" $deplib_base "*) ;; 613465d490d0Smrg *) func_append deplibs " $deplib" ;; 613565d490d0Smrg esac 613665d490d0Smrg done 613765d490d0Smrg done 613865d490d0Smrg libs="$dlprefiles" 613965d490d0Smrg fi 614065d490d0Smrg if test "$pass" = dlopen; then 614165d490d0Smrg # Collect dlpreopened libraries 614265d490d0Smrg save_deplibs="$deplibs" 614365d490d0Smrg deplibs= 614465d490d0Smrg fi 614565d490d0Smrg 614665d490d0Smrg for deplib in $libs; do 614765d490d0Smrg lib= 614865d490d0Smrg found=no 614965d490d0Smrg case $deplib in 615065d490d0Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 615165d490d0Smrg if test "$linkmode,$pass" = "prog,link"; then 615265d490d0Smrg compile_deplibs="$deplib $compile_deplibs" 615365d490d0Smrg finalize_deplibs="$deplib $finalize_deplibs" 615465d490d0Smrg else 615565d490d0Smrg func_append compiler_flags " $deplib" 615665d490d0Smrg if test "$linkmode" = lib ; then 615765d490d0Smrg case "$new_inherited_linker_flags " in 615865d490d0Smrg *" $deplib "*) ;; 615965d490d0Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 616065d490d0Smrg esac 616165d490d0Smrg fi 616265d490d0Smrg fi 616365d490d0Smrg continue 616465d490d0Smrg ;; 616565d490d0Smrg -l*) 616665d490d0Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 616765d490d0Smrg func_warning "\`-l' is ignored for archives/objects" 616865d490d0Smrg continue 616965d490d0Smrg fi 617065d490d0Smrg func_stripname '-l' '' "$deplib" 617165d490d0Smrg name=$func_stripname_result 617265d490d0Smrg if test "$linkmode" = lib; then 617365d490d0Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 617465d490d0Smrg else 617565d490d0Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 617665d490d0Smrg fi 617765d490d0Smrg for searchdir in $searchdirs; do 617865d490d0Smrg for search_ext in .la $std_shrext .so .a; do 617965d490d0Smrg # Search the libtool library 618065d490d0Smrg lib="$searchdir/lib${name}${search_ext}" 618165d490d0Smrg if test -f "$lib"; then 618265d490d0Smrg if test "$search_ext" = ".la"; then 618365d490d0Smrg found=yes 618465d490d0Smrg else 618565d490d0Smrg found=no 618665d490d0Smrg fi 618765d490d0Smrg break 2 618865d490d0Smrg fi 618965d490d0Smrg done 619065d490d0Smrg done 619165d490d0Smrg if test "$found" != yes; then 619265d490d0Smrg # deplib doesn't seem to be a libtool library 619365d490d0Smrg if test "$linkmode,$pass" = "prog,link"; then 619465d490d0Smrg compile_deplibs="$deplib $compile_deplibs" 619565d490d0Smrg finalize_deplibs="$deplib $finalize_deplibs" 619665d490d0Smrg else 619765d490d0Smrg deplibs="$deplib $deplibs" 619865d490d0Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 619965d490d0Smrg fi 620065d490d0Smrg continue 620165d490d0Smrg else # deplib is a libtool library 620265d490d0Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 620365d490d0Smrg # We need to do some special things here, and not later. 620465d490d0Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 620565d490d0Smrg case " $predeps $postdeps " in 620665d490d0Smrg *" $deplib "*) 620765d490d0Smrg if func_lalib_p "$lib"; then 620865d490d0Smrg library_names= 620965d490d0Smrg old_library= 621065d490d0Smrg func_source "$lib" 621165d490d0Smrg for l in $old_library $library_names; do 621265d490d0Smrg ll="$l" 621365d490d0Smrg done 621465d490d0Smrg if test "X$ll" = "X$old_library" ; then # only static version available 621565d490d0Smrg found=no 621665d490d0Smrg func_dirname "$lib" "" "." 621765d490d0Smrg ladir="$func_dirname_result" 621865d490d0Smrg lib=$ladir/$old_library 621965d490d0Smrg if test "$linkmode,$pass" = "prog,link"; then 622065d490d0Smrg compile_deplibs="$deplib $compile_deplibs" 622165d490d0Smrg finalize_deplibs="$deplib $finalize_deplibs" 622265d490d0Smrg else 622365d490d0Smrg deplibs="$deplib $deplibs" 622465d490d0Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 622565d490d0Smrg fi 622665d490d0Smrg continue 622765d490d0Smrg fi 622865d490d0Smrg fi 622965d490d0Smrg ;; 623065d490d0Smrg *) ;; 623165d490d0Smrg esac 623265d490d0Smrg fi 623365d490d0Smrg fi 623465d490d0Smrg ;; # -l 623565d490d0Smrg *.ltframework) 623665d490d0Smrg if test "$linkmode,$pass" = "prog,link"; then 623765d490d0Smrg compile_deplibs="$deplib $compile_deplibs" 623865d490d0Smrg finalize_deplibs="$deplib $finalize_deplibs" 623965d490d0Smrg else 624065d490d0Smrg deplibs="$deplib $deplibs" 624165d490d0Smrg if test "$linkmode" = lib ; then 624265d490d0Smrg case "$new_inherited_linker_flags " in 624365d490d0Smrg *" $deplib "*) ;; 624465d490d0Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 624565d490d0Smrg esac 624665d490d0Smrg fi 624765d490d0Smrg fi 624865d490d0Smrg continue 624965d490d0Smrg ;; 625065d490d0Smrg -L*) 625165d490d0Smrg case $linkmode in 625265d490d0Smrg lib) 625365d490d0Smrg deplibs="$deplib $deplibs" 625465d490d0Smrg test "$pass" = conv && continue 625565d490d0Smrg newdependency_libs="$deplib $newdependency_libs" 625665d490d0Smrg func_stripname '-L' '' "$deplib" 625765d490d0Smrg func_resolve_sysroot "$func_stripname_result" 625865d490d0Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 625965d490d0Smrg ;; 626065d490d0Smrg prog) 626165d490d0Smrg if test "$pass" = conv; then 626265d490d0Smrg deplibs="$deplib $deplibs" 626365d490d0Smrg continue 626465d490d0Smrg fi 626565d490d0Smrg if test "$pass" = scan; then 626665d490d0Smrg deplibs="$deplib $deplibs" 626765d490d0Smrg else 626865d490d0Smrg compile_deplibs="$deplib $compile_deplibs" 626965d490d0Smrg finalize_deplibs="$deplib $finalize_deplibs" 627065d490d0Smrg fi 627165d490d0Smrg func_stripname '-L' '' "$deplib" 627265d490d0Smrg func_resolve_sysroot "$func_stripname_result" 627365d490d0Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 627465d490d0Smrg ;; 627565d490d0Smrg *) 627665d490d0Smrg func_warning "\`-L' is ignored for archives/objects" 627765d490d0Smrg ;; 627865d490d0Smrg esac # linkmode 627965d490d0Smrg continue 628065d490d0Smrg ;; # -L 628165d490d0Smrg -R*) 628265d490d0Smrg if test "$pass" = link; then 628365d490d0Smrg func_stripname '-R' '' "$deplib" 628465d490d0Smrg func_resolve_sysroot "$func_stripname_result" 628565d490d0Smrg dir=$func_resolve_sysroot_result 628665d490d0Smrg # Make sure the xrpath contains only unique directories. 628765d490d0Smrg case "$xrpath " in 628865d490d0Smrg *" $dir "*) ;; 628965d490d0Smrg *) func_append xrpath " $dir" ;; 629065d490d0Smrg esac 629165d490d0Smrg fi 629265d490d0Smrg deplibs="$deplib $deplibs" 629365d490d0Smrg continue 629465d490d0Smrg ;; 629565d490d0Smrg *.la) 629665d490d0Smrg func_resolve_sysroot "$deplib" 629765d490d0Smrg lib=$func_resolve_sysroot_result 629865d490d0Smrg ;; 629965d490d0Smrg *.$libext) 630065d490d0Smrg if test "$pass" = conv; then 630165d490d0Smrg deplibs="$deplib $deplibs" 630265d490d0Smrg continue 630365d490d0Smrg fi 630465d490d0Smrg case $linkmode in 630565d490d0Smrg lib) 630665d490d0Smrg # Linking convenience modules into shared libraries is allowed, 630765d490d0Smrg # but linking other static libraries is non-portable. 630865d490d0Smrg case " $dlpreconveniencelibs " in 630965d490d0Smrg *" $deplib "*) ;; 631065d490d0Smrg *) 631165d490d0Smrg valid_a_lib=no 631265d490d0Smrg case $deplibs_check_method in 631365d490d0Smrg match_pattern*) 631465d490d0Smrg set dummy $deplibs_check_method; shift 631565d490d0Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 631665d490d0Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 631765d490d0Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 631865d490d0Smrg valid_a_lib=yes 631965d490d0Smrg fi 632065d490d0Smrg ;; 632165d490d0Smrg pass_all) 632265d490d0Smrg valid_a_lib=yes 632365d490d0Smrg ;; 632465d490d0Smrg esac 632565d490d0Smrg if test "$valid_a_lib" != yes; then 632665d490d0Smrg echo 632765d490d0Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 632865d490d0Smrg echo "*** I have the capability to make that library automatically link in when" 632965d490d0Smrg echo "*** you link to this library. But I can only do this if you have a" 633065d490d0Smrg echo "*** shared version of the library, which you do not appear to have" 633165d490d0Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 633265d490d0Smrg echo "*** that it is just a static archive that I should not use here." 633365d490d0Smrg else 633465d490d0Smrg echo 633565d490d0Smrg $ECHO "*** Warning: Linking the shared library $output against the" 633665d490d0Smrg $ECHO "*** static library $deplib is not portable!" 633765d490d0Smrg deplibs="$deplib $deplibs" 633865d490d0Smrg fi 633965d490d0Smrg ;; 634065d490d0Smrg esac 634165d490d0Smrg continue 634265d490d0Smrg ;; 634365d490d0Smrg prog) 634465d490d0Smrg if test "$pass" != link; then 634565d490d0Smrg deplibs="$deplib $deplibs" 634665d490d0Smrg else 634765d490d0Smrg compile_deplibs="$deplib $compile_deplibs" 634865d490d0Smrg finalize_deplibs="$deplib $finalize_deplibs" 634965d490d0Smrg fi 635065d490d0Smrg continue 635165d490d0Smrg ;; 635265d490d0Smrg esac # linkmode 635365d490d0Smrg ;; # *.$libext 635465d490d0Smrg *.lo | *.$objext) 635565d490d0Smrg if test "$pass" = conv; then 635665d490d0Smrg deplibs="$deplib $deplibs" 635765d490d0Smrg elif test "$linkmode" = prog; then 635865d490d0Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 635965d490d0Smrg # If there is no dlopen support or we're linking statically, 636065d490d0Smrg # we need to preload. 636165d490d0Smrg func_append newdlprefiles " $deplib" 636265d490d0Smrg compile_deplibs="$deplib $compile_deplibs" 636365d490d0Smrg finalize_deplibs="$deplib $finalize_deplibs" 636465d490d0Smrg else 636565d490d0Smrg func_append newdlfiles " $deplib" 636665d490d0Smrg fi 636765d490d0Smrg fi 636865d490d0Smrg continue 636965d490d0Smrg ;; 637065d490d0Smrg %DEPLIBS%) 637165d490d0Smrg alldeplibs=yes 637265d490d0Smrg continue 637365d490d0Smrg ;; 637465d490d0Smrg esac # case $deplib 637565d490d0Smrg 637665d490d0Smrg if test "$found" = yes || test -f "$lib"; then : 637765d490d0Smrg else 637865d490d0Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 637965d490d0Smrg fi 638065d490d0Smrg 638165d490d0Smrg # Check to see that this really is a libtool archive. 638265d490d0Smrg func_lalib_unsafe_p "$lib" \ 638365d490d0Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 638465d490d0Smrg 638565d490d0Smrg func_dirname "$lib" "" "." 638665d490d0Smrg ladir="$func_dirname_result" 638765d490d0Smrg 638865d490d0Smrg dlname= 638965d490d0Smrg dlopen= 639065d490d0Smrg dlpreopen= 639165d490d0Smrg libdir= 639265d490d0Smrg library_names= 639365d490d0Smrg old_library= 639465d490d0Smrg inherited_linker_flags= 639565d490d0Smrg # If the library was installed with an old release of libtool, 639665d490d0Smrg # it will not redefine variables installed, or shouldnotlink 639765d490d0Smrg installed=yes 639865d490d0Smrg shouldnotlink=no 639965d490d0Smrg avoidtemprpath= 640065d490d0Smrg 640165d490d0Smrg 640265d490d0Smrg # Read the .la file 640365d490d0Smrg func_source "$lib" 640465d490d0Smrg 640565d490d0Smrg # Convert "-framework foo" to "foo.ltframework" 640665d490d0Smrg if test -n "$inherited_linker_flags"; then 640765d490d0Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 640865d490d0Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 640965d490d0Smrg case " $new_inherited_linker_flags " in 641065d490d0Smrg *" $tmp_inherited_linker_flag "*) ;; 641165d490d0Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 641265d490d0Smrg esac 641365d490d0Smrg done 641465d490d0Smrg fi 641565d490d0Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 641665d490d0Smrg if test "$linkmode,$pass" = "lib,link" || 641765d490d0Smrg test "$linkmode,$pass" = "prog,scan" || 641865d490d0Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 641965d490d0Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 642065d490d0Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 642165d490d0Smrg fi 642265d490d0Smrg 642365d490d0Smrg if test "$pass" = conv; then 642465d490d0Smrg # Only check for convenience libraries 642565d490d0Smrg deplibs="$lib $deplibs" 642665d490d0Smrg if test -z "$libdir"; then 642765d490d0Smrg if test -z "$old_library"; then 642865d490d0Smrg func_fatal_error "cannot find name of link library for \`$lib'" 642965d490d0Smrg fi 643065d490d0Smrg # It is a libtool convenience library, so add in its objects. 643165d490d0Smrg func_append convenience " $ladir/$objdir/$old_library" 643265d490d0Smrg func_append old_convenience " $ladir/$objdir/$old_library" 643365d490d0Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 643465d490d0Smrg func_fatal_error "\`$lib' is not a convenience library" 643565d490d0Smrg fi 643665d490d0Smrg tmp_libs= 643765d490d0Smrg for deplib in $dependency_libs; do 643865d490d0Smrg deplibs="$deplib $deplibs" 643965d490d0Smrg if $opt_preserve_dup_deps ; then 644065d490d0Smrg case "$tmp_libs " in 644165d490d0Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 644265d490d0Smrg esac 644365d490d0Smrg fi 644465d490d0Smrg func_append tmp_libs " $deplib" 644565d490d0Smrg done 644665d490d0Smrg continue 644765d490d0Smrg fi # $pass = conv 644865d490d0Smrg 644965d490d0Smrg 645065d490d0Smrg # Get the name of the library we link against. 645165d490d0Smrg linklib= 645265d490d0Smrg if test -n "$old_library" && 645365d490d0Smrg { test "$prefer_static_libs" = yes || 645465d490d0Smrg test "$prefer_static_libs,$installed" = "built,no"; }; then 645565d490d0Smrg linklib=$old_library 645665d490d0Smrg else 645765d490d0Smrg for l in $old_library $library_names; do 645865d490d0Smrg linklib="$l" 645965d490d0Smrg done 646065d490d0Smrg fi 646165d490d0Smrg if test -z "$linklib"; then 646265d490d0Smrg func_fatal_error "cannot find name of link library for \`$lib'" 646365d490d0Smrg fi 646465d490d0Smrg 646565d490d0Smrg # This library was specified with -dlopen. 646665d490d0Smrg if test "$pass" = dlopen; then 646765d490d0Smrg if test -z "$libdir"; then 646865d490d0Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 646965d490d0Smrg fi 647065d490d0Smrg if test -z "$dlname" || 647165d490d0Smrg test "$dlopen_support" != yes || 647265d490d0Smrg test "$build_libtool_libs" = no; then 647365d490d0Smrg # If there is no dlname, no dlopen support or we're linking 647465d490d0Smrg # statically, we need to preload. We also need to preload any 647565d490d0Smrg # dependent libraries so libltdl's deplib preloader doesn't 647665d490d0Smrg # bomb out in the load deplibs phase. 647765d490d0Smrg func_append dlprefiles " $lib $dependency_libs" 647865d490d0Smrg else 647965d490d0Smrg func_append newdlfiles " $lib" 648065d490d0Smrg fi 648165d490d0Smrg continue 648265d490d0Smrg fi # $pass = dlopen 648365d490d0Smrg 648465d490d0Smrg # We need an absolute path. 648565d490d0Smrg case $ladir in 648665d490d0Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 648765d490d0Smrg *) 648865d490d0Smrg abs_ladir=`cd "$ladir" && pwd` 648965d490d0Smrg if test -z "$abs_ladir"; then 649065d490d0Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 649165d490d0Smrg func_warning "passing it literally to the linker, although it might fail" 649265d490d0Smrg abs_ladir="$ladir" 649365d490d0Smrg fi 649465d490d0Smrg ;; 649565d490d0Smrg esac 649665d490d0Smrg func_basename "$lib" 649765d490d0Smrg laname="$func_basename_result" 649865d490d0Smrg 649965d490d0Smrg # Find the relevant object directory and library name. 650065d490d0Smrg if test "X$installed" = Xyes; then 650165d490d0Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 650265d490d0Smrg func_warning "library \`$lib' was moved." 650365d490d0Smrg dir="$ladir" 650465d490d0Smrg absdir="$abs_ladir" 650565d490d0Smrg libdir="$abs_ladir" 650665d490d0Smrg else 650765d490d0Smrg dir="$lt_sysroot$libdir" 650865d490d0Smrg absdir="$lt_sysroot$libdir" 650965d490d0Smrg fi 651065d490d0Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 651165d490d0Smrg else 651265d490d0Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 651365d490d0Smrg dir="$ladir" 651465d490d0Smrg absdir="$abs_ladir" 651565d490d0Smrg # Remove this search path later 651665d490d0Smrg func_append notinst_path " $abs_ladir" 651765d490d0Smrg else 651865d490d0Smrg dir="$ladir/$objdir" 651965d490d0Smrg absdir="$abs_ladir/$objdir" 652065d490d0Smrg # Remove this search path later 652165d490d0Smrg func_append notinst_path " $abs_ladir" 652265d490d0Smrg fi 652365d490d0Smrg fi # $installed = yes 652465d490d0Smrg func_stripname 'lib' '.la' "$laname" 652565d490d0Smrg name=$func_stripname_result 652665d490d0Smrg 652765d490d0Smrg # This library was specified with -dlpreopen. 652865d490d0Smrg if test "$pass" = dlpreopen; then 652965d490d0Smrg if test -z "$libdir" && test "$linkmode" = prog; then 653065d490d0Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 653165d490d0Smrg fi 653265d490d0Smrg case "$host" in 653365d490d0Smrg # special handling for platforms with PE-DLLs. 653465d490d0Smrg *cygwin* | *mingw* | *cegcc* ) 653565d490d0Smrg # Linker will automatically link against shared library if both 653665d490d0Smrg # static and shared are present. Therefore, ensure we extract 653765d490d0Smrg # symbols from the import library if a shared library is present 653865d490d0Smrg # (otherwise, the dlopen module name will be incorrect). We do 653965d490d0Smrg # this by putting the import library name into $newdlprefiles. 654065d490d0Smrg # We recover the dlopen module name by 'saving' the la file 654165d490d0Smrg # name in a special purpose variable, and (later) extracting the 654265d490d0Smrg # dlname from the la file. 654365d490d0Smrg if test -n "$dlname"; then 654465d490d0Smrg func_tr_sh "$dir/$linklib" 654565d490d0Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 654665d490d0Smrg func_append newdlprefiles " $dir/$linklib" 654765d490d0Smrg else 654865d490d0Smrg func_append newdlprefiles " $dir/$old_library" 654965d490d0Smrg # Keep a list of preopened convenience libraries to check 655065d490d0Smrg # that they are being used correctly in the link pass. 655165d490d0Smrg test -z "$libdir" && \ 655265d490d0Smrg func_append dlpreconveniencelibs " $dir/$old_library" 655365d490d0Smrg fi 655465d490d0Smrg ;; 655565d490d0Smrg * ) 655665d490d0Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 655765d490d0Smrg # are required to link). 655865d490d0Smrg if test -n "$old_library"; then 655965d490d0Smrg func_append newdlprefiles " $dir/$old_library" 656065d490d0Smrg # Keep a list of preopened convenience libraries to check 656165d490d0Smrg # that they are being used correctly in the link pass. 656265d490d0Smrg test -z "$libdir" && \ 656365d490d0Smrg func_append dlpreconveniencelibs " $dir/$old_library" 656465d490d0Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 656565d490d0Smrg elif test -n "$dlname"; then 656665d490d0Smrg func_append newdlprefiles " $dir/$dlname" 656765d490d0Smrg else 656865d490d0Smrg func_append newdlprefiles " $dir/$linklib" 656965d490d0Smrg fi 657065d490d0Smrg ;; 657165d490d0Smrg esac 657265d490d0Smrg fi # $pass = dlpreopen 657365d490d0Smrg 657465d490d0Smrg if test -z "$libdir"; then 657565d490d0Smrg # Link the convenience library 657665d490d0Smrg if test "$linkmode" = lib; then 657765d490d0Smrg deplibs="$dir/$old_library $deplibs" 657865d490d0Smrg elif test "$linkmode,$pass" = "prog,link"; then 657965d490d0Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 658065d490d0Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 658165d490d0Smrg else 658265d490d0Smrg deplibs="$lib $deplibs" # used for prog,scan pass 658365d490d0Smrg fi 658465d490d0Smrg continue 658565d490d0Smrg fi 658665d490d0Smrg 658765d490d0Smrg 658865d490d0Smrg if test "$linkmode" = prog && test "$pass" != link; then 658965d490d0Smrg func_append newlib_search_path " $ladir" 659065d490d0Smrg deplibs="$lib $deplibs" 659165d490d0Smrg 659265d490d0Smrg linkalldeplibs=no 659365d490d0Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 659465d490d0Smrg test "$build_libtool_libs" = no; then 659565d490d0Smrg linkalldeplibs=yes 659665d490d0Smrg fi 659765d490d0Smrg 659865d490d0Smrg tmp_libs= 659965d490d0Smrg for deplib in $dependency_libs; do 660065d490d0Smrg case $deplib in 660165d490d0Smrg -L*) func_stripname '-L' '' "$deplib" 660265d490d0Smrg func_resolve_sysroot "$func_stripname_result" 660365d490d0Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 660465d490d0Smrg ;; 660565d490d0Smrg esac 660665d490d0Smrg # Need to link against all dependency_libs? 660765d490d0Smrg if test "$linkalldeplibs" = yes; then 660865d490d0Smrg deplibs="$deplib $deplibs" 660965d490d0Smrg else 661065d490d0Smrg # Need to hardcode shared library paths 661165d490d0Smrg # or/and link against static libraries 661265d490d0Smrg newdependency_libs="$deplib $newdependency_libs" 661365d490d0Smrg fi 661465d490d0Smrg if $opt_preserve_dup_deps ; then 661565d490d0Smrg case "$tmp_libs " in 661665d490d0Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 661765d490d0Smrg esac 661865d490d0Smrg fi 661965d490d0Smrg func_append tmp_libs " $deplib" 662065d490d0Smrg done # for deplib 662165d490d0Smrg continue 662265d490d0Smrg fi # $linkmode = prog... 662365d490d0Smrg 662465d490d0Smrg if test "$linkmode,$pass" = "prog,link"; then 662565d490d0Smrg if test -n "$library_names" && 662665d490d0Smrg { { test "$prefer_static_libs" = no || 662765d490d0Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 662865d490d0Smrg test -z "$old_library"; }; then 662965d490d0Smrg # We need to hardcode the library path 663065d490d0Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 663165d490d0Smrg # Make sure the rpath contains only unique directories. 663265d490d0Smrg case "$temp_rpath:" in 663365d490d0Smrg *"$absdir:"*) ;; 663465d490d0Smrg *) func_append temp_rpath "$absdir:" ;; 663565d490d0Smrg esac 663665d490d0Smrg fi 663765d490d0Smrg 663865d490d0Smrg # Hardcode the library path. 663965d490d0Smrg # Skip directories that are in the system default run-time 664065d490d0Smrg # search path. 664165d490d0Smrg case " $sys_lib_dlsearch_path " in 664265d490d0Smrg *" $absdir "*) ;; 664365d490d0Smrg *) 664465d490d0Smrg case "$compile_rpath " in 664565d490d0Smrg *" $absdir "*) ;; 664665d490d0Smrg *) func_append compile_rpath " $absdir" ;; 664765d490d0Smrg esac 664865d490d0Smrg ;; 664965d490d0Smrg esac 665065d490d0Smrg case " $sys_lib_dlsearch_path " in 665165d490d0Smrg *" $libdir "*) ;; 665265d490d0Smrg *) 665365d490d0Smrg case "$finalize_rpath " in 665465d490d0Smrg *" $libdir "*) ;; 665565d490d0Smrg *) func_append finalize_rpath " $libdir" ;; 665665d490d0Smrg esac 665765d490d0Smrg ;; 665865d490d0Smrg esac 665965d490d0Smrg fi # $linkmode,$pass = prog,link... 666065d490d0Smrg 666165d490d0Smrg if test "$alldeplibs" = yes && 666265d490d0Smrg { test "$deplibs_check_method" = pass_all || 666365d490d0Smrg { test "$build_libtool_libs" = yes && 666465d490d0Smrg test -n "$library_names"; }; }; then 666565d490d0Smrg # We only need to search for static libraries 666665d490d0Smrg continue 666765d490d0Smrg fi 666865d490d0Smrg fi 666965d490d0Smrg 667065d490d0Smrg link_static=no # Whether the deplib will be linked statically 667165d490d0Smrg use_static_libs=$prefer_static_libs 667265d490d0Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 667365d490d0Smrg use_static_libs=no 667465d490d0Smrg fi 667565d490d0Smrg if test -n "$library_names" && 667665d490d0Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 667765d490d0Smrg case $host in 667865d490d0Smrg *cygwin* | *mingw* | *cegcc*) 667965d490d0Smrg # No point in relinking DLLs because paths are not encoded 668065d490d0Smrg func_append notinst_deplibs " $lib" 668165d490d0Smrg need_relink=no 668265d490d0Smrg ;; 668365d490d0Smrg *) 668465d490d0Smrg if test "$installed" = no; then 668565d490d0Smrg func_append notinst_deplibs " $lib" 668665d490d0Smrg need_relink=yes 668765d490d0Smrg fi 668865d490d0Smrg ;; 668965d490d0Smrg esac 669065d490d0Smrg # This is a shared library 669165d490d0Smrg 669265d490d0Smrg # Warn about portability, can't link against -module's on some 669365d490d0Smrg # systems (darwin). Don't bleat about dlopened modules though! 669465d490d0Smrg dlopenmodule="" 669565d490d0Smrg for dlpremoduletest in $dlprefiles; do 669665d490d0Smrg if test "X$dlpremoduletest" = "X$lib"; then 669765d490d0Smrg dlopenmodule="$dlpremoduletest" 669865d490d0Smrg break 669965d490d0Smrg fi 670065d490d0Smrg done 670165d490d0Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 670265d490d0Smrg echo 670365d490d0Smrg if test "$linkmode" = prog; then 670465d490d0Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 670565d490d0Smrg else 670665d490d0Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 670765d490d0Smrg fi 670865d490d0Smrg $ECHO "*** $linklib is not portable!" 670965d490d0Smrg fi 671065d490d0Smrg if test "$linkmode" = lib && 671165d490d0Smrg test "$hardcode_into_libs" = yes; then 671265d490d0Smrg # Hardcode the library path. 671365d490d0Smrg # Skip directories that are in the system default run-time 671465d490d0Smrg # search path. 671565d490d0Smrg case " $sys_lib_dlsearch_path " in 671665d490d0Smrg *" $absdir "*) ;; 671765d490d0Smrg *) 671865d490d0Smrg case "$compile_rpath " in 671965d490d0Smrg *" $absdir "*) ;; 672065d490d0Smrg *) func_append compile_rpath " $absdir" ;; 672165d490d0Smrg esac 672265d490d0Smrg ;; 672365d490d0Smrg esac 672465d490d0Smrg case " $sys_lib_dlsearch_path " in 672565d490d0Smrg *" $libdir "*) ;; 672665d490d0Smrg *) 672765d490d0Smrg case "$finalize_rpath " in 672865d490d0Smrg *" $libdir "*) ;; 672965d490d0Smrg *) func_append finalize_rpath " $libdir" ;; 673065d490d0Smrg esac 673165d490d0Smrg ;; 673265d490d0Smrg esac 673365d490d0Smrg fi 673465d490d0Smrg 673565d490d0Smrg if test -n "$old_archive_from_expsyms_cmds"; then 673665d490d0Smrg # figure out the soname 673765d490d0Smrg set dummy $library_names 673865d490d0Smrg shift 673965d490d0Smrg realname="$1" 674065d490d0Smrg shift 674165d490d0Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 674265d490d0Smrg # use dlname if we got it. it's perfectly good, no? 674365d490d0Smrg if test -n "$dlname"; then 674465d490d0Smrg soname="$dlname" 674565d490d0Smrg elif test -n "$soname_spec"; then 674665d490d0Smrg # bleh windows 674765d490d0Smrg case $host in 674865d490d0Smrg *cygwin* | mingw* | *cegcc*) 674965d490d0Smrg func_arith $current - $age 675065d490d0Smrg major=$func_arith_result 675165d490d0Smrg versuffix="-$major" 675265d490d0Smrg ;; 675365d490d0Smrg esac 675465d490d0Smrg eval soname=\"$soname_spec\" 675565d490d0Smrg else 675665d490d0Smrg soname="$realname" 675765d490d0Smrg fi 675865d490d0Smrg 675965d490d0Smrg # Make a new name for the extract_expsyms_cmds to use 676065d490d0Smrg soroot="$soname" 676165d490d0Smrg func_basename "$soroot" 676265d490d0Smrg soname="$func_basename_result" 676365d490d0Smrg func_stripname 'lib' '.dll' "$soname" 676465d490d0Smrg newlib=libimp-$func_stripname_result.a 676565d490d0Smrg 676665d490d0Smrg # If the library has no export list, then create one now 676765d490d0Smrg if test -f "$output_objdir/$soname-def"; then : 676865d490d0Smrg else 676965d490d0Smrg func_verbose "extracting exported symbol list from \`$soname'" 677065d490d0Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 677165d490d0Smrg fi 677265d490d0Smrg 677365d490d0Smrg # Create $newlib 677465d490d0Smrg if test -f "$output_objdir/$newlib"; then :; else 677565d490d0Smrg func_verbose "generating import library for \`$soname'" 677665d490d0Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 677765d490d0Smrg fi 677865d490d0Smrg # make sure the library variables are pointing to the new library 677965d490d0Smrg dir=$output_objdir 678065d490d0Smrg linklib=$newlib 678165d490d0Smrg fi # test -n "$old_archive_from_expsyms_cmds" 678265d490d0Smrg 678365d490d0Smrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 678465d490d0Smrg add_shlibpath= 678565d490d0Smrg add_dir= 678665d490d0Smrg add= 678765d490d0Smrg lib_linked=yes 678865d490d0Smrg case $hardcode_action in 678965d490d0Smrg immediate | unsupported) 679065d490d0Smrg if test "$hardcode_direct" = no; then 679165d490d0Smrg add="$dir/$linklib" 679265d490d0Smrg case $host in 679365d490d0Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 679465d490d0Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 679565d490d0Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 679665d490d0Smrg *-*-unixware7*) add_dir="-L$dir" ;; 679765d490d0Smrg *-*-darwin* ) 679865d490d0Smrg # if the lib is a (non-dlopened) module then we can not 679965d490d0Smrg # link against it, someone is ignoring the earlier warnings 680065d490d0Smrg if /usr/bin/file -L $add 2> /dev/null | 680165d490d0Smrg $GREP ": [^:]* bundle" >/dev/null ; then 680265d490d0Smrg if test "X$dlopenmodule" != "X$lib"; then 680365d490d0Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 680465d490d0Smrg if test -z "$old_library" ; then 680565d490d0Smrg echo 680665d490d0Smrg echo "*** And there doesn't seem to be a static archive available" 680765d490d0Smrg echo "*** The link will probably fail, sorry" 680865d490d0Smrg else 680965d490d0Smrg add="$dir/$old_library" 681065d490d0Smrg fi 681165d490d0Smrg elif test -n "$old_library"; then 681265d490d0Smrg add="$dir/$old_library" 681365d490d0Smrg fi 681465d490d0Smrg fi 681565d490d0Smrg esac 681665d490d0Smrg elif test "$hardcode_minus_L" = no; then 681765d490d0Smrg case $host in 681865d490d0Smrg *-*-sunos*) add_shlibpath="$dir" ;; 681965d490d0Smrg esac 682065d490d0Smrg add_dir="-L$dir" 682165d490d0Smrg add="-l$name" 682265d490d0Smrg elif test "$hardcode_shlibpath_var" = no; then 682365d490d0Smrg add_shlibpath="$dir" 682465d490d0Smrg add="-l$name" 682565d490d0Smrg else 682665d490d0Smrg lib_linked=no 682765d490d0Smrg fi 682865d490d0Smrg ;; 682965d490d0Smrg relink) 683065d490d0Smrg if test "$hardcode_direct" = yes && 683165d490d0Smrg test "$hardcode_direct_absolute" = no; then 683265d490d0Smrg add="$dir/$linklib" 683365d490d0Smrg elif test "$hardcode_minus_L" = yes; then 683465d490d0Smrg add_dir="-L$dir" 683565d490d0Smrg # Try looking first in the location we're being installed to. 683665d490d0Smrg if test -n "$inst_prefix_dir"; then 683765d490d0Smrg case $libdir in 683865d490d0Smrg [\\/]*) 683965d490d0Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 684065d490d0Smrg ;; 684165d490d0Smrg esac 684265d490d0Smrg fi 684365d490d0Smrg add="-l$name" 684465d490d0Smrg elif test "$hardcode_shlibpath_var" = yes; then 684565d490d0Smrg add_shlibpath="$dir" 684665d490d0Smrg add="-l$name" 684765d490d0Smrg else 684865d490d0Smrg lib_linked=no 684965d490d0Smrg fi 685065d490d0Smrg ;; 685165d490d0Smrg *) lib_linked=no ;; 685265d490d0Smrg esac 685365d490d0Smrg 685465d490d0Smrg if test "$lib_linked" != yes; then 685565d490d0Smrg func_fatal_configuration "unsupported hardcode properties" 685665d490d0Smrg fi 685765d490d0Smrg 685865d490d0Smrg if test -n "$add_shlibpath"; then 685965d490d0Smrg case :$compile_shlibpath: in 686065d490d0Smrg *":$add_shlibpath:"*) ;; 686165d490d0Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 686265d490d0Smrg esac 686365d490d0Smrg fi 686465d490d0Smrg if test "$linkmode" = prog; then 686565d490d0Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 686665d490d0Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 686765d490d0Smrg else 686865d490d0Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 686965d490d0Smrg test -n "$add" && deplibs="$add $deplibs" 687065d490d0Smrg if test "$hardcode_direct" != yes && 687165d490d0Smrg test "$hardcode_minus_L" != yes && 687265d490d0Smrg test "$hardcode_shlibpath_var" = yes; then 687365d490d0Smrg case :$finalize_shlibpath: in 687465d490d0Smrg *":$libdir:"*) ;; 687565d490d0Smrg *) func_append finalize_shlibpath "$libdir:" ;; 687665d490d0Smrg esac 687765d490d0Smrg fi 687865d490d0Smrg fi 687965d490d0Smrg fi 688065d490d0Smrg 688165d490d0Smrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 688265d490d0Smrg add_shlibpath= 688365d490d0Smrg add_dir= 688465d490d0Smrg add= 688565d490d0Smrg # Finalize command for both is simple: just hardcode it. 688665d490d0Smrg if test "$hardcode_direct" = yes && 688765d490d0Smrg test "$hardcode_direct_absolute" = no; then 688865d490d0Smrg add="$libdir/$linklib" 688965d490d0Smrg elif test "$hardcode_minus_L" = yes; then 689065d490d0Smrg add_dir="-L$libdir" 689165d490d0Smrg add="-l$name" 689265d490d0Smrg elif test "$hardcode_shlibpath_var" = yes; then 689365d490d0Smrg case :$finalize_shlibpath: in 689465d490d0Smrg *":$libdir:"*) ;; 689565d490d0Smrg *) func_append finalize_shlibpath "$libdir:" ;; 689665d490d0Smrg esac 689765d490d0Smrg add="-l$name" 689865d490d0Smrg elif test "$hardcode_automatic" = yes; then 689965d490d0Smrg if test -n "$inst_prefix_dir" && 690065d490d0Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 690165d490d0Smrg add="$inst_prefix_dir$libdir/$linklib" 690265d490d0Smrg else 690365d490d0Smrg add="$libdir/$linklib" 690465d490d0Smrg fi 690565d490d0Smrg else 690665d490d0Smrg # We cannot seem to hardcode it, guess we'll fake it. 690765d490d0Smrg add_dir="-L$libdir" 690865d490d0Smrg # Try looking first in the location we're being installed to. 690965d490d0Smrg if test -n "$inst_prefix_dir"; then 691065d490d0Smrg case $libdir in 691165d490d0Smrg [\\/]*) 691265d490d0Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 691365d490d0Smrg ;; 691465d490d0Smrg esac 691565d490d0Smrg fi 691665d490d0Smrg add="-l$name" 691765d490d0Smrg fi 691865d490d0Smrg 691965d490d0Smrg if test "$linkmode" = prog; then 692065d490d0Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 692165d490d0Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 692265d490d0Smrg else 692365d490d0Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 692465d490d0Smrg test -n "$add" && deplibs="$add $deplibs" 692565d490d0Smrg fi 692665d490d0Smrg fi 692765d490d0Smrg elif test "$linkmode" = prog; then 692865d490d0Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 692965d490d0Smrg # is not unsupported. This is valid on all known static and 693065d490d0Smrg # shared platforms. 693165d490d0Smrg if test "$hardcode_direct" != unsupported; then 693265d490d0Smrg test -n "$old_library" && linklib="$old_library" 693365d490d0Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 693465d490d0Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 693565d490d0Smrg else 693665d490d0Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 693765d490d0Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 693865d490d0Smrg fi 693965d490d0Smrg elif test "$build_libtool_libs" = yes; then 694065d490d0Smrg # Not a shared library 694165d490d0Smrg if test "$deplibs_check_method" != pass_all; then 694265d490d0Smrg # We're trying link a shared library against a static one 694365d490d0Smrg # but the system doesn't support it. 694465d490d0Smrg 694565d490d0Smrg # Just print a warning and add the library to dependency_libs so 694665d490d0Smrg # that the program can be linked against the static library. 694765d490d0Smrg echo 694865d490d0Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 694965d490d0Smrg echo "*** I have the capability to make that library automatically link in when" 695065d490d0Smrg echo "*** you link to this library. But I can only do this if you have a" 695165d490d0Smrg echo "*** shared version of the library, which you do not appear to have." 695265d490d0Smrg if test "$module" = yes; then 695365d490d0Smrg echo "*** But as you try to build a module library, libtool will still create " 695465d490d0Smrg echo "*** a static module, that should work as long as the dlopening application" 695565d490d0Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 695665d490d0Smrg if test -z "$global_symbol_pipe"; then 695765d490d0Smrg echo 695865d490d0Smrg echo "*** However, this would only work if libtool was able to extract symbol" 695965d490d0Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 696065d490d0Smrg echo "*** not find such a program. So, this module is probably useless." 696165d490d0Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 696265d490d0Smrg fi 696365d490d0Smrg if test "$build_old_libs" = no; then 696465d490d0Smrg build_libtool_libs=module 696565d490d0Smrg build_old_libs=yes 696665d490d0Smrg else 696765d490d0Smrg build_libtool_libs=no 696865d490d0Smrg fi 696965d490d0Smrg fi 697065d490d0Smrg else 697165d490d0Smrg deplibs="$dir/$old_library $deplibs" 697265d490d0Smrg link_static=yes 697365d490d0Smrg fi 697465d490d0Smrg fi # link shared/static library? 697565d490d0Smrg 697665d490d0Smrg if test "$linkmode" = lib; then 697765d490d0Smrg if test -n "$dependency_libs" && 697865d490d0Smrg { test "$hardcode_into_libs" != yes || 697965d490d0Smrg test "$build_old_libs" = yes || 698065d490d0Smrg test "$link_static" = yes; }; then 698165d490d0Smrg # Extract -R from dependency_libs 698265d490d0Smrg temp_deplibs= 698365d490d0Smrg for libdir in $dependency_libs; do 698465d490d0Smrg case $libdir in 698565d490d0Smrg -R*) func_stripname '-R' '' "$libdir" 698665d490d0Smrg temp_xrpath=$func_stripname_result 698765d490d0Smrg case " $xrpath " in 698865d490d0Smrg *" $temp_xrpath "*) ;; 698965d490d0Smrg *) func_append xrpath " $temp_xrpath";; 699065d490d0Smrg esac;; 699165d490d0Smrg *) func_append temp_deplibs " $libdir";; 699265d490d0Smrg esac 699365d490d0Smrg done 699465d490d0Smrg dependency_libs="$temp_deplibs" 699565d490d0Smrg fi 699665d490d0Smrg 699765d490d0Smrg func_append newlib_search_path " $absdir" 699865d490d0Smrg # Link against this library 699965d490d0Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 700065d490d0Smrg # ... and its dependency_libs 700165d490d0Smrg tmp_libs= 700265d490d0Smrg for deplib in $dependency_libs; do 700365d490d0Smrg newdependency_libs="$deplib $newdependency_libs" 700465d490d0Smrg case $deplib in 700565d490d0Smrg -L*) func_stripname '-L' '' "$deplib" 700665d490d0Smrg func_resolve_sysroot "$func_stripname_result";; 700765d490d0Smrg *) func_resolve_sysroot "$deplib" ;; 700865d490d0Smrg esac 700965d490d0Smrg if $opt_preserve_dup_deps ; then 701065d490d0Smrg case "$tmp_libs " in 701165d490d0Smrg *" $func_resolve_sysroot_result "*) 701265d490d0Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 701365d490d0Smrg esac 701465d490d0Smrg fi 701565d490d0Smrg func_append tmp_libs " $func_resolve_sysroot_result" 701665d490d0Smrg done 701765d490d0Smrg 701865d490d0Smrg if test "$link_all_deplibs" != no; then 701965d490d0Smrg # Add the search paths of all dependency libraries 702065d490d0Smrg for deplib in $dependency_libs; do 702165d490d0Smrg path= 702265d490d0Smrg case $deplib in 702365d490d0Smrg -L*) path="$deplib" ;; 702465d490d0Smrg *.la) 702565d490d0Smrg func_resolve_sysroot "$deplib" 702665d490d0Smrg deplib=$func_resolve_sysroot_result 702765d490d0Smrg func_dirname "$deplib" "" "." 702865d490d0Smrg dir=$func_dirname_result 702965d490d0Smrg # We need an absolute path. 703065d490d0Smrg case $dir in 703165d490d0Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 703265d490d0Smrg *) 703365d490d0Smrg absdir=`cd "$dir" && pwd` 703465d490d0Smrg if test -z "$absdir"; then 703565d490d0Smrg func_warning "cannot determine absolute directory name of \`$dir'" 703665d490d0Smrg absdir="$dir" 703765d490d0Smrg fi 703865d490d0Smrg ;; 703965d490d0Smrg esac 704065d490d0Smrg if $GREP "^installed=no" $deplib > /dev/null; then 704165d490d0Smrg case $host in 704265d490d0Smrg *-*-darwin*) 704365d490d0Smrg depdepl= 704465d490d0Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 704565d490d0Smrg if test -n "$deplibrary_names" ; then 704665d490d0Smrg for tmp in $deplibrary_names ; do 704765d490d0Smrg depdepl=$tmp 704865d490d0Smrg done 704965d490d0Smrg if test -f "$absdir/$objdir/$depdepl" ; then 705065d490d0Smrg depdepl="$absdir/$objdir/$depdepl" 705165d490d0Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 705265d490d0Smrg if test -z "$darwin_install_name"; then 705365d490d0Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 705465d490d0Smrg fi 705565d490d0Smrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 705665d490d0Smrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 705765d490d0Smrg path= 705865d490d0Smrg fi 705965d490d0Smrg fi 706065d490d0Smrg ;; 706165d490d0Smrg *) 706265d490d0Smrg path="-L$absdir/$objdir" 706365d490d0Smrg ;; 706465d490d0Smrg esac 706565d490d0Smrg else 706665d490d0Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 706765d490d0Smrg test -z "$libdir" && \ 706865d490d0Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 706965d490d0Smrg test "$absdir" != "$libdir" && \ 707065d490d0Smrg func_warning "\`$deplib' seems to be moved" 707165d490d0Smrg 707265d490d0Smrg path="-L$absdir" 707365d490d0Smrg fi 707465d490d0Smrg ;; 707565d490d0Smrg esac 707665d490d0Smrg case " $deplibs " in 707765d490d0Smrg *" $path "*) ;; 707865d490d0Smrg *) deplibs="$path $deplibs" ;; 707965d490d0Smrg esac 708065d490d0Smrg done 708165d490d0Smrg fi # link_all_deplibs != no 708265d490d0Smrg fi # linkmode = lib 708365d490d0Smrg done # for deplib in $libs 708465d490d0Smrg if test "$pass" = link; then 708565d490d0Smrg if test "$linkmode" = "prog"; then 708665d490d0Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 708765d490d0Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 708865d490d0Smrg else 708965d490d0Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 709065d490d0Smrg fi 709165d490d0Smrg fi 709265d490d0Smrg dependency_libs="$newdependency_libs" 709365d490d0Smrg if test "$pass" = dlpreopen; then 709465d490d0Smrg # Link the dlpreopened libraries before other libraries 709565d490d0Smrg for deplib in $save_deplibs; do 709665d490d0Smrg deplibs="$deplib $deplibs" 709765d490d0Smrg done 709865d490d0Smrg fi 709965d490d0Smrg if test "$pass" != dlopen; then 710065d490d0Smrg if test "$pass" != conv; then 710165d490d0Smrg # Make sure lib_search_path contains only unique directories. 710265d490d0Smrg lib_search_path= 710365d490d0Smrg for dir in $newlib_search_path; do 710465d490d0Smrg case "$lib_search_path " in 710565d490d0Smrg *" $dir "*) ;; 710665d490d0Smrg *) func_append lib_search_path " $dir" ;; 710765d490d0Smrg esac 710865d490d0Smrg done 710965d490d0Smrg newlib_search_path= 711065d490d0Smrg fi 711165d490d0Smrg 711265d490d0Smrg if test "$linkmode,$pass" != "prog,link"; then 711365d490d0Smrg vars="deplibs" 711465d490d0Smrg else 711565d490d0Smrg vars="compile_deplibs finalize_deplibs" 711665d490d0Smrg fi 711765d490d0Smrg for var in $vars dependency_libs; do 711865d490d0Smrg # Add libraries to $var in reverse order 711965d490d0Smrg eval tmp_libs=\"\$$var\" 712065d490d0Smrg new_libs= 712165d490d0Smrg for deplib in $tmp_libs; do 712265d490d0Smrg # FIXME: Pedantically, this is the right thing to do, so 712365d490d0Smrg # that some nasty dependency loop isn't accidentally 712465d490d0Smrg # broken: 712565d490d0Smrg #new_libs="$deplib $new_libs" 712665d490d0Smrg # Pragmatically, this seems to cause very few problems in 712765d490d0Smrg # practice: 712865d490d0Smrg case $deplib in 712965d490d0Smrg -L*) new_libs="$deplib $new_libs" ;; 713065d490d0Smrg -R*) ;; 713165d490d0Smrg *) 713265d490d0Smrg # And here is the reason: when a library appears more 713365d490d0Smrg # than once as an explicit dependence of a library, or 713465d490d0Smrg # is implicitly linked in more than once by the 713565d490d0Smrg # compiler, it is considered special, and multiple 713665d490d0Smrg # occurrences thereof are not removed. Compare this 713765d490d0Smrg # with having the same library being listed as a 713865d490d0Smrg # dependency of multiple other libraries: in this case, 713965d490d0Smrg # we know (pedantically, we assume) the library does not 714065d490d0Smrg # need to be listed more than once, so we keep only the 714165d490d0Smrg # last copy. This is not always right, but it is rare 714265d490d0Smrg # enough that we require users that really mean to play 714365d490d0Smrg # such unportable linking tricks to link the library 714465d490d0Smrg # using -Wl,-lname, so that libtool does not consider it 714565d490d0Smrg # for duplicate removal. 714665d490d0Smrg case " $specialdeplibs " in 714765d490d0Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 714865d490d0Smrg *) 714965d490d0Smrg case " $new_libs " in 715065d490d0Smrg *" $deplib "*) ;; 715165d490d0Smrg *) new_libs="$deplib $new_libs" ;; 715265d490d0Smrg esac 715365d490d0Smrg ;; 715465d490d0Smrg esac 715565d490d0Smrg ;; 715665d490d0Smrg esac 715765d490d0Smrg done 715865d490d0Smrg tmp_libs= 715965d490d0Smrg for deplib in $new_libs; do 716065d490d0Smrg case $deplib in 716165d490d0Smrg -L*) 716265d490d0Smrg case " $tmp_libs " in 716365d490d0Smrg *" $deplib "*) ;; 716465d490d0Smrg *) func_append tmp_libs " $deplib" ;; 716565d490d0Smrg esac 716665d490d0Smrg ;; 716765d490d0Smrg *) func_append tmp_libs " $deplib" ;; 716865d490d0Smrg esac 716965d490d0Smrg done 717065d490d0Smrg eval $var=\"$tmp_libs\" 717165d490d0Smrg done # for var 717265d490d0Smrg fi 717365d490d0Smrg # Last step: remove runtime libs from dependency_libs 717465d490d0Smrg # (they stay in deplibs) 717565d490d0Smrg tmp_libs= 717665d490d0Smrg for i in $dependency_libs ; do 717765d490d0Smrg case " $predeps $postdeps $compiler_lib_search_path " in 717865d490d0Smrg *" $i "*) 717965d490d0Smrg i="" 718065d490d0Smrg ;; 718165d490d0Smrg esac 718265d490d0Smrg if test -n "$i" ; then 718365d490d0Smrg func_append tmp_libs " $i" 718465d490d0Smrg fi 718565d490d0Smrg done 718665d490d0Smrg dependency_libs=$tmp_libs 718765d490d0Smrg done # for pass 718865d490d0Smrg if test "$linkmode" = prog; then 718965d490d0Smrg dlfiles="$newdlfiles" 719065d490d0Smrg fi 719165d490d0Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 719265d490d0Smrg dlprefiles="$newdlprefiles" 719365d490d0Smrg fi 719465d490d0Smrg 719565d490d0Smrg case $linkmode in 719665d490d0Smrg oldlib) 719765d490d0Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 719865d490d0Smrg func_warning "\`-dlopen' is ignored for archives" 719965d490d0Smrg fi 720065d490d0Smrg 720165d490d0Smrg case " $deplibs" in 720265d490d0Smrg *\ -l* | *\ -L*) 720365d490d0Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 720465d490d0Smrg esac 720565d490d0Smrg 720665d490d0Smrg test -n "$rpath" && \ 720765d490d0Smrg func_warning "\`-rpath' is ignored for archives" 720865d490d0Smrg 720965d490d0Smrg test -n "$xrpath" && \ 721065d490d0Smrg func_warning "\`-R' is ignored for archives" 721165d490d0Smrg 721265d490d0Smrg test -n "$vinfo" && \ 721365d490d0Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 721465d490d0Smrg 721565d490d0Smrg test -n "$release" && \ 721665d490d0Smrg func_warning "\`-release' is ignored for archives" 721765d490d0Smrg 721865d490d0Smrg test -n "$export_symbols$export_symbols_regex" && \ 721965d490d0Smrg func_warning "\`-export-symbols' is ignored for archives" 722065d490d0Smrg 722165d490d0Smrg # Now set the variables for building old libraries. 722265d490d0Smrg build_libtool_libs=no 722365d490d0Smrg oldlibs="$output" 722465d490d0Smrg func_append objs "$old_deplibs" 722565d490d0Smrg ;; 722665d490d0Smrg 722765d490d0Smrg lib) 722865d490d0Smrg # Make sure we only generate libraries of the form `libNAME.la'. 722965d490d0Smrg case $outputname in 723065d490d0Smrg lib*) 723165d490d0Smrg func_stripname 'lib' '.la' "$outputname" 723265d490d0Smrg name=$func_stripname_result 723365d490d0Smrg eval shared_ext=\"$shrext_cmds\" 723465d490d0Smrg eval libname=\"$libname_spec\" 723565d490d0Smrg ;; 723665d490d0Smrg *) 723765d490d0Smrg test "$module" = no && \ 723865d490d0Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 723965d490d0Smrg 724065d490d0Smrg if test "$need_lib_prefix" != no; then 724165d490d0Smrg # Add the "lib" prefix for modules if required 724265d490d0Smrg func_stripname '' '.la' "$outputname" 724365d490d0Smrg name=$func_stripname_result 724465d490d0Smrg eval shared_ext=\"$shrext_cmds\" 724565d490d0Smrg eval libname=\"$libname_spec\" 724665d490d0Smrg else 724765d490d0Smrg func_stripname '' '.la' "$outputname" 724865d490d0Smrg libname=$func_stripname_result 724965d490d0Smrg fi 725065d490d0Smrg ;; 725165d490d0Smrg esac 725265d490d0Smrg 725365d490d0Smrg if test -n "$objs"; then 725465d490d0Smrg if test "$deplibs_check_method" != pass_all; then 725565d490d0Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 725665d490d0Smrg else 725765d490d0Smrg echo 725865d490d0Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 725965d490d0Smrg $ECHO "*** objects $objs is not portable!" 726065d490d0Smrg func_append libobjs " $objs" 726165d490d0Smrg fi 726265d490d0Smrg fi 726365d490d0Smrg 726465d490d0Smrg test "$dlself" != no && \ 726565d490d0Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 726665d490d0Smrg 726765d490d0Smrg set dummy $rpath 726865d490d0Smrg shift 726965d490d0Smrg test "$#" -gt 1 && \ 727065d490d0Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 727165d490d0Smrg 727265d490d0Smrg install_libdir="$1" 727365d490d0Smrg 727465d490d0Smrg oldlibs= 727565d490d0Smrg if test -z "$rpath"; then 727665d490d0Smrg if test "$build_libtool_libs" = yes; then 727765d490d0Smrg # Building a libtool convenience library. 727865d490d0Smrg # Some compilers have problems with a `.al' extension so 727965d490d0Smrg # convenience libraries should have the same extension an 728065d490d0Smrg # archive normally would. 728165d490d0Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 728265d490d0Smrg build_libtool_libs=convenience 728365d490d0Smrg build_old_libs=yes 728465d490d0Smrg fi 728565d490d0Smrg 728665d490d0Smrg test -n "$vinfo" && \ 728765d490d0Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 728865d490d0Smrg 728965d490d0Smrg test -n "$release" && \ 729065d490d0Smrg func_warning "\`-release' is ignored for convenience libraries" 729165d490d0Smrg else 729265d490d0Smrg 729365d490d0Smrg # Parse the version information argument. 729465d490d0Smrg save_ifs="$IFS"; IFS=':' 729565d490d0Smrg set dummy $vinfo 0 0 0 729665d490d0Smrg shift 729765d490d0Smrg IFS="$save_ifs" 729865d490d0Smrg 729965d490d0Smrg test -n "$7" && \ 730065d490d0Smrg func_fatal_help "too many parameters to \`-version-info'" 730165d490d0Smrg 730265d490d0Smrg # convert absolute version numbers to libtool ages 730365d490d0Smrg # this retains compatibility with .la files and attempts 730465d490d0Smrg # to make the code below a bit more comprehensible 730565d490d0Smrg 730665d490d0Smrg case $vinfo_number in 730765d490d0Smrg yes) 730865d490d0Smrg number_major="$1" 730965d490d0Smrg number_minor="$2" 731065d490d0Smrg number_revision="$3" 731165d490d0Smrg # 731265d490d0Smrg # There are really only two kinds -- those that 731365d490d0Smrg # use the current revision as the major version 731465d490d0Smrg # and those that subtract age and use age as 731565d490d0Smrg # a minor version. But, then there is irix 731665d490d0Smrg # which has an extra 1 added just for fun 731765d490d0Smrg # 731865d490d0Smrg case $version_type in 731965d490d0Smrg darwin|linux|osf|windows|none) 732065d490d0Smrg func_arith $number_major + $number_minor 732165d490d0Smrg current=$func_arith_result 732265d490d0Smrg age="$number_minor" 732365d490d0Smrg revision="$number_revision" 732465d490d0Smrg ;; 732565d490d0Smrg freebsd-aout|freebsd-elf|qnx|sunos) 732665d490d0Smrg current="$number_major" 732765d490d0Smrg revision="$number_minor" 732865d490d0Smrg age="0" 732965d490d0Smrg ;; 733065d490d0Smrg irix|nonstopux) 733165d490d0Smrg func_arith $number_major + $number_minor 733265d490d0Smrg current=$func_arith_result 733365d490d0Smrg age="$number_minor" 733465d490d0Smrg revision="$number_minor" 733565d490d0Smrg lt_irix_increment=no 733665d490d0Smrg ;; 733765d490d0Smrg esac 733865d490d0Smrg ;; 733965d490d0Smrg no) 734065d490d0Smrg current="$1" 734165d490d0Smrg revision="$2" 734265d490d0Smrg age="$3" 734365d490d0Smrg ;; 734465d490d0Smrg esac 734565d490d0Smrg 734665d490d0Smrg # Check that each of the things are valid numbers. 734765d490d0Smrg case $current in 734865d490d0Smrg 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]) ;; 734965d490d0Smrg *) 735065d490d0Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 735165d490d0Smrg func_fatal_error "\`$vinfo' is not valid version information" 735265d490d0Smrg ;; 735365d490d0Smrg esac 735465d490d0Smrg 735565d490d0Smrg case $revision in 735665d490d0Smrg 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]) ;; 735765d490d0Smrg *) 735865d490d0Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 735965d490d0Smrg func_fatal_error "\`$vinfo' is not valid version information" 736065d490d0Smrg ;; 736165d490d0Smrg esac 736265d490d0Smrg 736365d490d0Smrg case $age in 736465d490d0Smrg 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]) ;; 736565d490d0Smrg *) 736665d490d0Smrg func_error "AGE \`$age' must be a nonnegative integer" 736765d490d0Smrg func_fatal_error "\`$vinfo' is not valid version information" 736865d490d0Smrg ;; 736965d490d0Smrg esac 737065d490d0Smrg 737165d490d0Smrg if test "$age" -gt "$current"; then 737265d490d0Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 737365d490d0Smrg func_fatal_error "\`$vinfo' is not valid version information" 737465d490d0Smrg fi 737565d490d0Smrg 737665d490d0Smrg # Calculate the version variables. 737765d490d0Smrg major= 737865d490d0Smrg versuffix= 737965d490d0Smrg verstring= 738065d490d0Smrg case $version_type in 738165d490d0Smrg none) ;; 738265d490d0Smrg 738365d490d0Smrg darwin) 738465d490d0Smrg # Like Linux, but with the current version available in 738565d490d0Smrg # verstring for coding it into the library header 738665d490d0Smrg func_arith $current - $age 738765d490d0Smrg major=.$func_arith_result 738865d490d0Smrg versuffix="$major.$age.$revision" 738965d490d0Smrg # Darwin ld doesn't like 0 for these options... 739065d490d0Smrg func_arith $current + 1 739165d490d0Smrg minor_current=$func_arith_result 739265d490d0Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 739365d490d0Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 739465d490d0Smrg ;; 739565d490d0Smrg 739665d490d0Smrg freebsd-aout) 739765d490d0Smrg major=".$current" 739865d490d0Smrg versuffix=".$current.$revision"; 739965d490d0Smrg ;; 740065d490d0Smrg 740165d490d0Smrg freebsd-elf) 740265d490d0Smrg major=".$current" 740365d490d0Smrg versuffix=".$current" 740465d490d0Smrg ;; 740565d490d0Smrg 740665d490d0Smrg irix | nonstopux) 740765d490d0Smrg if test "X$lt_irix_increment" = "Xno"; then 740865d490d0Smrg func_arith $current - $age 740965d490d0Smrg else 741065d490d0Smrg func_arith $current - $age + 1 741165d490d0Smrg fi 741265d490d0Smrg major=$func_arith_result 741365d490d0Smrg 741465d490d0Smrg case $version_type in 741565d490d0Smrg nonstopux) verstring_prefix=nonstopux ;; 741665d490d0Smrg *) verstring_prefix=sgi ;; 741765d490d0Smrg esac 741865d490d0Smrg verstring="$verstring_prefix$major.$revision" 741965d490d0Smrg 742065d490d0Smrg # Add in all the interfaces that we are compatible with. 742165d490d0Smrg loop=$revision 742265d490d0Smrg while test "$loop" -ne 0; do 742365d490d0Smrg func_arith $revision - $loop 742465d490d0Smrg iface=$func_arith_result 742565d490d0Smrg func_arith $loop - 1 742665d490d0Smrg loop=$func_arith_result 742765d490d0Smrg verstring="$verstring_prefix$major.$iface:$verstring" 742865d490d0Smrg done 742965d490d0Smrg 743065d490d0Smrg # Before this point, $major must not contain `.'. 743165d490d0Smrg major=.$major 743265d490d0Smrg versuffix="$major.$revision" 743365d490d0Smrg ;; 743465d490d0Smrg 743565d490d0Smrg linux) 743665d490d0Smrg func_arith $current - $age 743765d490d0Smrg major=.$func_arith_result 743865d490d0Smrg versuffix="$major.$age.$revision" 743965d490d0Smrg ;; 744065d490d0Smrg 744165d490d0Smrg osf) 744265d490d0Smrg func_arith $current - $age 744365d490d0Smrg major=.$func_arith_result 744465d490d0Smrg versuffix=".$current.$age.$revision" 744565d490d0Smrg verstring="$current.$age.$revision" 744665d490d0Smrg 744765d490d0Smrg # Add in all the interfaces that we are compatible with. 744865d490d0Smrg loop=$age 744965d490d0Smrg while test "$loop" -ne 0; do 745065d490d0Smrg func_arith $current - $loop 745165d490d0Smrg iface=$func_arith_result 745265d490d0Smrg func_arith $loop - 1 745365d490d0Smrg loop=$func_arith_result 745465d490d0Smrg verstring="$verstring:${iface}.0" 745565d490d0Smrg done 745665d490d0Smrg 745765d490d0Smrg # Make executables depend on our current version. 745865d490d0Smrg func_append verstring ":${current}.0" 745965d490d0Smrg ;; 746065d490d0Smrg 746165d490d0Smrg qnx) 746265d490d0Smrg major=".$current" 746365d490d0Smrg versuffix=".$current" 746465d490d0Smrg ;; 746565d490d0Smrg 746665d490d0Smrg sunos) 746765d490d0Smrg major=".$current" 746865d490d0Smrg versuffix=".$current.$revision" 746965d490d0Smrg ;; 747065d490d0Smrg 747165d490d0Smrg windows) 747265d490d0Smrg # Use '-' rather than '.', since we only want one 747365d490d0Smrg # extension on DOS 8.3 filesystems. 747465d490d0Smrg func_arith $current - $age 747565d490d0Smrg major=$func_arith_result 747665d490d0Smrg versuffix="-$major" 747765d490d0Smrg ;; 747865d490d0Smrg 747965d490d0Smrg *) 748065d490d0Smrg func_fatal_configuration "unknown library version type \`$version_type'" 748165d490d0Smrg ;; 748265d490d0Smrg esac 748365d490d0Smrg 748465d490d0Smrg # Clear the version info if we defaulted, and they specified a release. 748565d490d0Smrg if test -z "$vinfo" && test -n "$release"; then 748665d490d0Smrg major= 748765d490d0Smrg case $version_type in 748865d490d0Smrg darwin) 748965d490d0Smrg # we can't check for "0.0" in archive_cmds due to quoting 749065d490d0Smrg # problems, so we reset it completely 749165d490d0Smrg verstring= 749265d490d0Smrg ;; 749365d490d0Smrg *) 749465d490d0Smrg verstring="0.0" 749565d490d0Smrg ;; 749665d490d0Smrg esac 749765d490d0Smrg if test "$need_version" = no; then 749865d490d0Smrg versuffix= 749965d490d0Smrg else 750065d490d0Smrg versuffix=".0.0" 750165d490d0Smrg fi 750265d490d0Smrg fi 750365d490d0Smrg 750465d490d0Smrg # Remove version info from name if versioning should be avoided 750565d490d0Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 750665d490d0Smrg major= 750765d490d0Smrg versuffix= 750865d490d0Smrg verstring="" 750965d490d0Smrg fi 751065d490d0Smrg 751165d490d0Smrg # Check to see if the archive will have undefined symbols. 751265d490d0Smrg if test "$allow_undefined" = yes; then 751365d490d0Smrg if test "$allow_undefined_flag" = unsupported; then 751465d490d0Smrg func_warning "undefined symbols not allowed in $host shared libraries" 751565d490d0Smrg build_libtool_libs=no 751665d490d0Smrg build_old_libs=yes 751765d490d0Smrg fi 751865d490d0Smrg else 751965d490d0Smrg # Don't allow undefined symbols. 752065d490d0Smrg allow_undefined_flag="$no_undefined_flag" 752165d490d0Smrg fi 752265d490d0Smrg 752365d490d0Smrg fi 752465d490d0Smrg 752565d490d0Smrg func_generate_dlsyms "$libname" "$libname" "yes" 752665d490d0Smrg func_append libobjs " $symfileobj" 752765d490d0Smrg test "X$libobjs" = "X " && libobjs= 752865d490d0Smrg 752965d490d0Smrg if test "$opt_mode" != relink; then 753065d490d0Smrg # Remove our outputs, but don't remove object files since they 753165d490d0Smrg # may have been created when compiling PIC objects. 753265d490d0Smrg removelist= 753365d490d0Smrg tempremovelist=`$ECHO "$output_objdir/*"` 753465d490d0Smrg for p in $tempremovelist; do 753565d490d0Smrg case $p in 753665d490d0Smrg *.$objext | *.gcno) 753765d490d0Smrg ;; 753865d490d0Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 753965d490d0Smrg if test "X$precious_files_regex" != "X"; then 754065d490d0Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 754165d490d0Smrg then 754265d490d0Smrg continue 754365d490d0Smrg fi 754465d490d0Smrg fi 754565d490d0Smrg func_append removelist " $p" 754665d490d0Smrg ;; 754765d490d0Smrg *) ;; 754865d490d0Smrg esac 754965d490d0Smrg done 755065d490d0Smrg test -n "$removelist" && \ 755165d490d0Smrg func_show_eval "${RM}r \$removelist" 755265d490d0Smrg fi 755365d490d0Smrg 755465d490d0Smrg # Now set the variables for building old libraries. 755565d490d0Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 755665d490d0Smrg func_append oldlibs " $output_objdir/$libname.$libext" 755765d490d0Smrg 755865d490d0Smrg # Transform .lo files to .o files. 755965d490d0Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 756065d490d0Smrg fi 756165d490d0Smrg 756265d490d0Smrg # Eliminate all temporary directories. 756365d490d0Smrg #for path in $notinst_path; do 756465d490d0Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 756565d490d0Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 756665d490d0Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 756765d490d0Smrg #done 756865d490d0Smrg 756965d490d0Smrg if test -n "$xrpath"; then 757065d490d0Smrg # If the user specified any rpath flags, then add them. 757165d490d0Smrg temp_xrpath= 757265d490d0Smrg for libdir in $xrpath; do 757365d490d0Smrg func_replace_sysroot "$libdir" 757465d490d0Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 757565d490d0Smrg case "$finalize_rpath " in 757665d490d0Smrg *" $libdir "*) ;; 757765d490d0Smrg *) func_append finalize_rpath " $libdir" ;; 757865d490d0Smrg esac 757965d490d0Smrg done 758065d490d0Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 758165d490d0Smrg dependency_libs="$temp_xrpath $dependency_libs" 758265d490d0Smrg fi 758365d490d0Smrg fi 758465d490d0Smrg 758565d490d0Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 758665d490d0Smrg old_dlfiles="$dlfiles" 758765d490d0Smrg dlfiles= 758865d490d0Smrg for lib in $old_dlfiles; do 758965d490d0Smrg case " $dlprefiles $dlfiles " in 759065d490d0Smrg *" $lib "*) ;; 759165d490d0Smrg *) func_append dlfiles " $lib" ;; 759265d490d0Smrg esac 759365d490d0Smrg done 759465d490d0Smrg 759565d490d0Smrg # Make sure dlprefiles contains only unique files 759665d490d0Smrg old_dlprefiles="$dlprefiles" 759765d490d0Smrg dlprefiles= 759865d490d0Smrg for lib in $old_dlprefiles; do 759965d490d0Smrg case "$dlprefiles " in 760065d490d0Smrg *" $lib "*) ;; 760165d490d0Smrg *) func_append dlprefiles " $lib" ;; 760265d490d0Smrg esac 760365d490d0Smrg done 760465d490d0Smrg 760565d490d0Smrg if test "$build_libtool_libs" = yes; then 760665d490d0Smrg if test -n "$rpath"; then 760765d490d0Smrg case $host in 760865d490d0Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 760965d490d0Smrg # these systems don't actually have a c library (as such)! 761065d490d0Smrg ;; 761165d490d0Smrg *-*-rhapsody* | *-*-darwin1.[012]) 761265d490d0Smrg # Rhapsody C library is in the System framework 761365d490d0Smrg func_append deplibs " System.ltframework" 761465d490d0Smrg ;; 761565d490d0Smrg *-*-netbsd*) 761665d490d0Smrg # Don't link with libc until the a.out ld.so is fixed. 761765d490d0Smrg ;; 761865d490d0Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 761965d490d0Smrg # Do not include libc due to us having libc/libc_r. 762065d490d0Smrg ;; 762165d490d0Smrg *-*-sco3.2v5* | *-*-sco5v6*) 762265d490d0Smrg # Causes problems with __ctype 762365d490d0Smrg ;; 762465d490d0Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 762565d490d0Smrg # Compiler inserts libc in the correct place for threads to work 762665d490d0Smrg ;; 762765d490d0Smrg *) 762865d490d0Smrg # Add libc to deplibs on all other systems if necessary. 762965d490d0Smrg if test "$build_libtool_need_lc" = "yes"; then 763065d490d0Smrg func_append deplibs " -lc" 763165d490d0Smrg fi 763265d490d0Smrg ;; 763365d490d0Smrg esac 763465d490d0Smrg fi 763565d490d0Smrg 763665d490d0Smrg # Transform deplibs into only deplibs that can be linked in shared. 763765d490d0Smrg name_save=$name 763865d490d0Smrg libname_save=$libname 763965d490d0Smrg release_save=$release 764065d490d0Smrg versuffix_save=$versuffix 764165d490d0Smrg major_save=$major 764265d490d0Smrg # I'm not sure if I'm treating the release correctly. I think 764365d490d0Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 764465d490d0Smrg # add it in twice. Is that correct? 764565d490d0Smrg release="" 764665d490d0Smrg versuffix="" 764765d490d0Smrg major="" 764865d490d0Smrg newdeplibs= 764965d490d0Smrg droppeddeps=no 765065d490d0Smrg case $deplibs_check_method in 765165d490d0Smrg pass_all) 765265d490d0Smrg # Don't check for shared/static. Everything works. 765365d490d0Smrg # This might be a little naive. We might want to check 765465d490d0Smrg # whether the library exists or not. But this is on 765565d490d0Smrg # osf3 & osf4 and I'm not really sure... Just 765665d490d0Smrg # implementing what was already the behavior. 765765d490d0Smrg newdeplibs=$deplibs 765865d490d0Smrg ;; 765965d490d0Smrg test_compile) 766065d490d0Smrg # This code stresses the "libraries are programs" paradigm to its 766165d490d0Smrg # limits. Maybe even breaks it. We compile a program, linking it 766265d490d0Smrg # against the deplibs as a proxy for the library. Then we can check 766365d490d0Smrg # whether they linked in statically or dynamically with ldd. 766465d490d0Smrg $opt_dry_run || $RM conftest.c 766565d490d0Smrg cat > conftest.c <<EOF 766665d490d0Smrg int main() { return 0; } 766765d490d0SmrgEOF 766865d490d0Smrg $opt_dry_run || $RM conftest 766965d490d0Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 767065d490d0Smrg ldd_output=`ldd conftest` 767165d490d0Smrg for i in $deplibs; do 767265d490d0Smrg case $i in 767365d490d0Smrg -l*) 767465d490d0Smrg func_stripname -l '' "$i" 767565d490d0Smrg name=$func_stripname_result 767665d490d0Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 767765d490d0Smrg case " $predeps $postdeps " in 767865d490d0Smrg *" $i "*) 767965d490d0Smrg func_append newdeplibs " $i" 768065d490d0Smrg i="" 768165d490d0Smrg ;; 768265d490d0Smrg esac 768365d490d0Smrg fi 768465d490d0Smrg if test -n "$i" ; then 768565d490d0Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 768665d490d0Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 768765d490d0Smrg set dummy $deplib_matches; shift 768865d490d0Smrg deplib_match=$1 768965d490d0Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 769065d490d0Smrg func_append newdeplibs " $i" 769165d490d0Smrg else 769265d490d0Smrg droppeddeps=yes 769365d490d0Smrg echo 769465d490d0Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 769565d490d0Smrg echo "*** I have the capability to make that library automatically link in when" 769665d490d0Smrg echo "*** you link to this library. But I can only do this if you have a" 769765d490d0Smrg echo "*** shared version of the library, which I believe you do not have" 769865d490d0Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 769965d490d0Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 770065d490d0Smrg fi 770165d490d0Smrg fi 770265d490d0Smrg ;; 770365d490d0Smrg *) 770465d490d0Smrg func_append newdeplibs " $i" 770565d490d0Smrg ;; 770665d490d0Smrg esac 770765d490d0Smrg done 770865d490d0Smrg else 770965d490d0Smrg # Error occurred in the first compile. Let's try to salvage 771065d490d0Smrg # the situation: Compile a separate program for each library. 771165d490d0Smrg for i in $deplibs; do 771265d490d0Smrg case $i in 771365d490d0Smrg -l*) 771465d490d0Smrg func_stripname -l '' "$i" 771565d490d0Smrg name=$func_stripname_result 771665d490d0Smrg $opt_dry_run || $RM conftest 771765d490d0Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 771865d490d0Smrg ldd_output=`ldd conftest` 771965d490d0Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 772065d490d0Smrg case " $predeps $postdeps " in 772165d490d0Smrg *" $i "*) 772265d490d0Smrg func_append newdeplibs " $i" 772365d490d0Smrg i="" 772465d490d0Smrg ;; 772565d490d0Smrg esac 772665d490d0Smrg fi 772765d490d0Smrg if test -n "$i" ; then 772865d490d0Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 772965d490d0Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 773065d490d0Smrg set dummy $deplib_matches; shift 773165d490d0Smrg deplib_match=$1 773265d490d0Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 773365d490d0Smrg func_append newdeplibs " $i" 773465d490d0Smrg else 773565d490d0Smrg droppeddeps=yes 773665d490d0Smrg echo 773765d490d0Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 773865d490d0Smrg echo "*** I have the capability to make that library automatically link in when" 773965d490d0Smrg echo "*** you link to this library. But I can only do this if you have a" 774065d490d0Smrg echo "*** shared version of the library, which you do not appear to have" 774165d490d0Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 774265d490d0Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 774365d490d0Smrg fi 774465d490d0Smrg fi 774565d490d0Smrg else 774665d490d0Smrg droppeddeps=yes 774765d490d0Smrg echo 774865d490d0Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 774965d490d0Smrg echo "*** make it link in! You will probably need to install it or some" 775065d490d0Smrg echo "*** library that it depends on before this library will be fully" 775165d490d0Smrg echo "*** functional. Installing it before continuing would be even better." 775265d490d0Smrg fi 775365d490d0Smrg ;; 775465d490d0Smrg *) 775565d490d0Smrg func_append newdeplibs " $i" 775665d490d0Smrg ;; 775765d490d0Smrg esac 775865d490d0Smrg done 775965d490d0Smrg fi 776065d490d0Smrg ;; 776165d490d0Smrg file_magic*) 776265d490d0Smrg set dummy $deplibs_check_method; shift 776365d490d0Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 776465d490d0Smrg for a_deplib in $deplibs; do 776565d490d0Smrg case $a_deplib in 776665d490d0Smrg -l*) 776765d490d0Smrg func_stripname -l '' "$a_deplib" 776865d490d0Smrg name=$func_stripname_result 776965d490d0Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 777065d490d0Smrg case " $predeps $postdeps " in 777165d490d0Smrg *" $a_deplib "*) 777265d490d0Smrg func_append newdeplibs " $a_deplib" 777365d490d0Smrg a_deplib="" 777465d490d0Smrg ;; 777565d490d0Smrg esac 777665d490d0Smrg fi 777765d490d0Smrg if test -n "$a_deplib" ; then 777865d490d0Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 777965d490d0Smrg if test -n "$file_magic_glob"; then 778065d490d0Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 778165d490d0Smrg else 778265d490d0Smrg libnameglob=$libname 778365d490d0Smrg fi 778465d490d0Smrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 778565d490d0Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 778665d490d0Smrg if test "$want_nocaseglob" = yes; then 778765d490d0Smrg shopt -s nocaseglob 778865d490d0Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 778965d490d0Smrg $nocaseglob 779065d490d0Smrg else 779165d490d0Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 779265d490d0Smrg fi 779365d490d0Smrg for potent_lib in $potential_libs; do 779465d490d0Smrg # Follow soft links. 779565d490d0Smrg if ls -lLd "$potent_lib" 2>/dev/null | 779665d490d0Smrg $GREP " -> " >/dev/null; then 779765d490d0Smrg continue 779865d490d0Smrg fi 779965d490d0Smrg # The statement above tries to avoid entering an 780065d490d0Smrg # endless loop below, in case of cyclic links. 780165d490d0Smrg # We might still enter an endless loop, since a link 780265d490d0Smrg # loop can be closed while we follow links, 780365d490d0Smrg # but so what? 780465d490d0Smrg potlib="$potent_lib" 780565d490d0Smrg while test -h "$potlib" 2>/dev/null; do 780665d490d0Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 780765d490d0Smrg case $potliblink in 780865d490d0Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 780965d490d0Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 781065d490d0Smrg esac 781165d490d0Smrg done 781265d490d0Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 781365d490d0Smrg $SED -e 10q | 781465d490d0Smrg $EGREP "$file_magic_regex" > /dev/null; then 781565d490d0Smrg func_append newdeplibs " $a_deplib" 781665d490d0Smrg a_deplib="" 781765d490d0Smrg break 2 781865d490d0Smrg fi 781965d490d0Smrg done 782065d490d0Smrg done 782165d490d0Smrg fi 782265d490d0Smrg if test -n "$a_deplib" ; then 782365d490d0Smrg droppeddeps=yes 782465d490d0Smrg echo 782565d490d0Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 782665d490d0Smrg echo "*** I have the capability to make that library automatically link in when" 782765d490d0Smrg echo "*** you link to this library. But I can only do this if you have a" 782865d490d0Smrg echo "*** shared version of the library, which you do not appear to have" 782965d490d0Smrg echo "*** because I did check the linker path looking for a file starting" 783065d490d0Smrg if test -z "$potlib" ; then 783165d490d0Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 783265d490d0Smrg else 783365d490d0Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 783465d490d0Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 783565d490d0Smrg fi 783665d490d0Smrg fi 783765d490d0Smrg ;; 783865d490d0Smrg *) 783965d490d0Smrg # Add a -L argument. 784065d490d0Smrg func_append newdeplibs " $a_deplib" 784165d490d0Smrg ;; 784265d490d0Smrg esac 784365d490d0Smrg done # Gone through all deplibs. 784465d490d0Smrg ;; 784565d490d0Smrg match_pattern*) 784665d490d0Smrg set dummy $deplibs_check_method; shift 784765d490d0Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 784865d490d0Smrg for a_deplib in $deplibs; do 784965d490d0Smrg case $a_deplib in 785065d490d0Smrg -l*) 785165d490d0Smrg func_stripname -l '' "$a_deplib" 785265d490d0Smrg name=$func_stripname_result 785365d490d0Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 785465d490d0Smrg case " $predeps $postdeps " in 785565d490d0Smrg *" $a_deplib "*) 785665d490d0Smrg func_append newdeplibs " $a_deplib" 785765d490d0Smrg a_deplib="" 785865d490d0Smrg ;; 785965d490d0Smrg esac 786065d490d0Smrg fi 786165d490d0Smrg if test -n "$a_deplib" ; then 786265d490d0Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 786365d490d0Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 786465d490d0Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 786565d490d0Smrg for potent_lib in $potential_libs; do 786665d490d0Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 786765d490d0Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 786865d490d0Smrg $EGREP "$match_pattern_regex" > /dev/null; then 786965d490d0Smrg func_append newdeplibs " $a_deplib" 787065d490d0Smrg a_deplib="" 787165d490d0Smrg break 2 787265d490d0Smrg fi 787365d490d0Smrg done 787465d490d0Smrg done 787565d490d0Smrg fi 787665d490d0Smrg if test -n "$a_deplib" ; then 787765d490d0Smrg droppeddeps=yes 787865d490d0Smrg echo 787965d490d0Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 788065d490d0Smrg echo "*** I have the capability to make that library automatically link in when" 788165d490d0Smrg echo "*** you link to this library. But I can only do this if you have a" 788265d490d0Smrg echo "*** shared version of the library, which you do not appear to have" 788365d490d0Smrg echo "*** because I did check the linker path looking for a file starting" 788465d490d0Smrg if test -z "$potlib" ; then 788565d490d0Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 788665d490d0Smrg else 788765d490d0Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 788865d490d0Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 788965d490d0Smrg fi 789065d490d0Smrg fi 789165d490d0Smrg ;; 789265d490d0Smrg *) 789365d490d0Smrg # Add a -L argument. 789465d490d0Smrg func_append newdeplibs " $a_deplib" 789565d490d0Smrg ;; 789665d490d0Smrg esac 789765d490d0Smrg done # Gone through all deplibs. 789865d490d0Smrg ;; 789965d490d0Smrg none | unknown | *) 790065d490d0Smrg newdeplibs="" 790165d490d0Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 790265d490d0Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 790365d490d0Smrg for i in $predeps $postdeps ; do 790465d490d0Smrg # can't use Xsed below, because $i might contain '/' 790565d490d0Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 790665d490d0Smrg done 790765d490d0Smrg fi 790865d490d0Smrg case $tmp_deplibs in 790965d490d0Smrg *[!\ \ ]*) 791065d490d0Smrg echo 791165d490d0Smrg if test "X$deplibs_check_method" = "Xnone"; then 791265d490d0Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 791365d490d0Smrg else 791465d490d0Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 791565d490d0Smrg fi 791665d490d0Smrg echo "*** All declared inter-library dependencies are being dropped." 791765d490d0Smrg droppeddeps=yes 791865d490d0Smrg ;; 791965d490d0Smrg esac 792065d490d0Smrg ;; 792165d490d0Smrg esac 792265d490d0Smrg versuffix=$versuffix_save 792365d490d0Smrg major=$major_save 792465d490d0Smrg release=$release_save 792565d490d0Smrg libname=$libname_save 792665d490d0Smrg name=$name_save 792765d490d0Smrg 792865d490d0Smrg case $host in 792965d490d0Smrg *-*-rhapsody* | *-*-darwin1.[012]) 793065d490d0Smrg # On Rhapsody replace the C library with the System framework 793165d490d0Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 793265d490d0Smrg ;; 793365d490d0Smrg esac 793465d490d0Smrg 793565d490d0Smrg if test "$droppeddeps" = yes; then 793665d490d0Smrg if test "$module" = yes; then 793765d490d0Smrg echo 793865d490d0Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 793965d490d0Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 794065d490d0Smrg echo "*** a static module, that should work as long as the dlopening" 794165d490d0Smrg echo "*** application is linked with the -dlopen flag." 794265d490d0Smrg if test -z "$global_symbol_pipe"; then 794365d490d0Smrg echo 794465d490d0Smrg echo "*** However, this would only work if libtool was able to extract symbol" 794565d490d0Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 794665d490d0Smrg echo "*** not find such a program. So, this module is probably useless." 794765d490d0Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 794865d490d0Smrg fi 794965d490d0Smrg if test "$build_old_libs" = no; then 795065d490d0Smrg oldlibs="$output_objdir/$libname.$libext" 795165d490d0Smrg build_libtool_libs=module 795265d490d0Smrg build_old_libs=yes 795365d490d0Smrg else 795465d490d0Smrg build_libtool_libs=no 795565d490d0Smrg fi 795665d490d0Smrg else 795765d490d0Smrg echo "*** The inter-library dependencies that have been dropped here will be" 795865d490d0Smrg echo "*** automatically added whenever a program is linked with this library" 795965d490d0Smrg echo "*** or is declared to -dlopen it." 7960e4da13eeSmacallan 796165d490d0Smrg if test "$allow_undefined" = no; then 796265d490d0Smrg echo 796365d490d0Smrg echo "*** Since this library must not contain undefined symbols," 796465d490d0Smrg echo "*** because either the platform does not support them or" 796565d490d0Smrg echo "*** it was explicitly requested with -no-undefined," 796665d490d0Smrg echo "*** libtool will only create a static version of it." 796765d490d0Smrg if test "$build_old_libs" = no; then 796865d490d0Smrg oldlibs="$output_objdir/$libname.$libext" 796965d490d0Smrg build_libtool_libs=module 797065d490d0Smrg build_old_libs=yes 797165d490d0Smrg else 797265d490d0Smrg build_libtool_libs=no 797365d490d0Smrg fi 797465d490d0Smrg fi 797565d490d0Smrg fi 797665d490d0Smrg fi 797765d490d0Smrg # Done checking deplibs! 797865d490d0Smrg deplibs=$newdeplibs 797965d490d0Smrg fi 798065d490d0Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 798165d490d0Smrg case $host in 798265d490d0Smrg *-*-darwin*) 798365d490d0Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 798465d490d0Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 798565d490d0Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 798665d490d0Smrg ;; 798765d490d0Smrg esac 7988e4da13eeSmacallan 798965d490d0Smrg # move library search paths that coincide with paths to not yet 799065d490d0Smrg # installed libraries to the beginning of the library search list 799165d490d0Smrg new_libs= 799265d490d0Smrg for path in $notinst_path; do 799365d490d0Smrg case " $new_libs " in 799465d490d0Smrg *" -L$path/$objdir "*) ;; 799565d490d0Smrg *) 799665d490d0Smrg case " $deplibs " in 799765d490d0Smrg *" -L$path/$objdir "*) 799865d490d0Smrg func_append new_libs " -L$path/$objdir" ;; 799965d490d0Smrg esac 800065d490d0Smrg ;; 800165d490d0Smrg esac 800265d490d0Smrg done 800365d490d0Smrg for deplib in $deplibs; do 800465d490d0Smrg case $deplib in 800565d490d0Smrg -L*) 800665d490d0Smrg case " $new_libs " in 800765d490d0Smrg *" $deplib "*) ;; 800865d490d0Smrg *) func_append new_libs " $deplib" ;; 800965d490d0Smrg esac 801065d490d0Smrg ;; 801165d490d0Smrg *) func_append new_libs " $deplib" ;; 801265d490d0Smrg esac 801365d490d0Smrg done 801465d490d0Smrg deplibs="$new_libs" 8015e4da13eeSmacallan 801665d490d0Smrg # All the library-specific variables (install_libdir is set above). 801765d490d0Smrg library_names= 801865d490d0Smrg old_library= 801965d490d0Smrg dlname= 8020e4da13eeSmacallan 802165d490d0Smrg # Test again, we may have decided not to build it any more 802265d490d0Smrg if test "$build_libtool_libs" = yes; then 802365d490d0Smrg if test "$hardcode_into_libs" = yes; then 802465d490d0Smrg # Hardcode the library paths 802565d490d0Smrg hardcode_libdirs= 802665d490d0Smrg dep_rpath= 802765d490d0Smrg rpath="$finalize_rpath" 802865d490d0Smrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 802965d490d0Smrg for libdir in $rpath; do 803065d490d0Smrg if test -n "$hardcode_libdir_flag_spec"; then 803165d490d0Smrg if test -n "$hardcode_libdir_separator"; then 803265d490d0Smrg func_replace_sysroot "$libdir" 803365d490d0Smrg libdir=$func_replace_sysroot_result 803465d490d0Smrg if test -z "$hardcode_libdirs"; then 803565d490d0Smrg hardcode_libdirs="$libdir" 803665d490d0Smrg else 803765d490d0Smrg # Just accumulate the unique libdirs. 803865d490d0Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 803965d490d0Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 804065d490d0Smrg ;; 804165d490d0Smrg *) 804265d490d0Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 804365d490d0Smrg ;; 804465d490d0Smrg esac 804565d490d0Smrg fi 804665d490d0Smrg else 804765d490d0Smrg eval flag=\"$hardcode_libdir_flag_spec\" 804865d490d0Smrg func_append dep_rpath " $flag" 804965d490d0Smrg fi 805065d490d0Smrg elif test -n "$runpath_var"; then 805165d490d0Smrg case "$perm_rpath " in 805265d490d0Smrg *" $libdir "*) ;; 805365d490d0Smrg *) func_apped perm_rpath " $libdir" ;; 805465d490d0Smrg esac 805565d490d0Smrg fi 805665d490d0Smrg done 805765d490d0Smrg # Substitute the hardcoded libdirs into the rpath. 805865d490d0Smrg if test -n "$hardcode_libdir_separator" && 805965d490d0Smrg test -n "$hardcode_libdirs"; then 806065d490d0Smrg libdir="$hardcode_libdirs" 806165d490d0Smrg if test -n "$hardcode_libdir_flag_spec_ld"; then 806265d490d0Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" 806365d490d0Smrg else 806465d490d0Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec\" 806565d490d0Smrg fi 806665d490d0Smrg fi 806765d490d0Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 806865d490d0Smrg # We should set the runpath_var. 806965d490d0Smrg rpath= 807065d490d0Smrg for dir in $perm_rpath; do 807165d490d0Smrg func_append rpath "$dir:" 807265d490d0Smrg done 807365d490d0Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 807465d490d0Smrg fi 807565d490d0Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 807665d490d0Smrg fi 8077e4da13eeSmacallan 807865d490d0Smrg shlibpath="$finalize_shlibpath" 807965d490d0Smrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 808065d490d0Smrg if test -n "$shlibpath"; then 808165d490d0Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 808265d490d0Smrg fi 8083e4da13eeSmacallan 808465d490d0Smrg # Get the real and link names of the library. 808565d490d0Smrg eval shared_ext=\"$shrext_cmds\" 808665d490d0Smrg eval library_names=\"$library_names_spec\" 808765d490d0Smrg set dummy $library_names 808865d490d0Smrg shift 808965d490d0Smrg realname="$1" 809065d490d0Smrg shift 8091e4da13eeSmacallan 809265d490d0Smrg if test -n "$soname_spec"; then 809365d490d0Smrg eval soname=\"$soname_spec\" 8094e4da13eeSmacallan else 809565d490d0Smrg soname="$realname" 809665d490d0Smrg fi 809765d490d0Smrg if test -z "$dlname"; then 809865d490d0Smrg dlname=$soname 8099e4da13eeSmacallan fi 8100e4da13eeSmacallan 810165d490d0Smrg lib="$output_objdir/$realname" 810265d490d0Smrg linknames= 810365d490d0Smrg for link 810465d490d0Smrg do 810565d490d0Smrg func_append linknames " $link" 810665d490d0Smrg done 8107e4da13eeSmacallan 810865d490d0Smrg # Use standard objects if they are pic 810965d490d0Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 811065d490d0Smrg test "X$libobjs" = "X " && libobjs= 8111e4da13eeSmacallan 811265d490d0Smrg delfiles= 811365d490d0Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 811465d490d0Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 811565d490d0Smrg export_symbols="$output_objdir/$libname.uexp" 811665d490d0Smrg func_append delfiles " $export_symbols" 811765d490d0Smrg fi 8118e4da13eeSmacallan 811965d490d0Smrg orig_export_symbols= 812065d490d0Smrg case $host_os in 812165d490d0Smrg cygwin* | mingw* | cegcc*) 812265d490d0Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 812365d490d0Smrg # exporting using user supplied symfile 812465d490d0Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 812565d490d0Smrg # and it's NOT already a .def file. Must figure out 812665d490d0Smrg # which of the given symbols are data symbols and tag 812765d490d0Smrg # them as such. So, trigger use of export_symbols_cmds. 812865d490d0Smrg # export_symbols gets reassigned inside the "prepare 812965d490d0Smrg # the list of exported symbols" if statement, so the 813065d490d0Smrg # include_expsyms logic still works. 813165d490d0Smrg orig_export_symbols="$export_symbols" 813265d490d0Smrg export_symbols= 813365d490d0Smrg always_export_symbols=yes 813465d490d0Smrg fi 813565d490d0Smrg fi 813665d490d0Smrg ;; 813765d490d0Smrg esac 8138e4da13eeSmacallan 813965d490d0Smrg # Prepare the list of exported symbols 814065d490d0Smrg if test -z "$export_symbols"; then 814165d490d0Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 814265d490d0Smrg func_verbose "generating symbol list for \`$libname.la'" 814365d490d0Smrg export_symbols="$output_objdir/$libname.exp" 814465d490d0Smrg $opt_dry_run || $RM $export_symbols 814565d490d0Smrg cmds=$export_symbols_cmds 814665d490d0Smrg save_ifs="$IFS"; IFS='~' 814765d490d0Smrg for cmd1 in $cmds; do 814865d490d0Smrg IFS="$save_ifs" 814965d490d0Smrg # Take the normal branch if the nm_file_list_spec branch 815065d490d0Smrg # doesn't work or if tool conversion is not needed. 815165d490d0Smrg case $nm_file_list_spec~$to_tool_file_cmd in 815265d490d0Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 815365d490d0Smrg try_normal_branch=yes 815465d490d0Smrg eval cmd=\"$cmd1\" 815565d490d0Smrg func_len " $cmd" 815665d490d0Smrg len=$func_len_result 815765d490d0Smrg ;; 815865d490d0Smrg *) 815965d490d0Smrg try_normal_branch=no 816065d490d0Smrg ;; 816165d490d0Smrg esac 816265d490d0Smrg if test "$try_normal_branch" = yes \ 816365d490d0Smrg && { test "$len" -lt "$max_cmd_len" \ 816465d490d0Smrg || test "$max_cmd_len" -le -1; } 816565d490d0Smrg then 816665d490d0Smrg func_show_eval "$cmd" 'exit $?' 816765d490d0Smrg skipped_export=false 816865d490d0Smrg elif test -n "$nm_file_list_spec"; then 816965d490d0Smrg func_basename "$output" 817065d490d0Smrg output_la=$func_basename_result 817165d490d0Smrg save_libobjs=$libobjs 817265d490d0Smrg save_output=$output 817365d490d0Smrg output=${output_objdir}/${output_la}.nm 817465d490d0Smrg func_to_tool_file "$output" 817565d490d0Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 817665d490d0Smrg func_append delfiles " $output" 817765d490d0Smrg func_verbose "creating $NM input file list: $output" 817865d490d0Smrg for obj in $save_libobjs; do 817965d490d0Smrg func_to_tool_file "$obj" 818065d490d0Smrg $ECHO "$func_to_tool_file_result" 818165d490d0Smrg done > "$output" 818265d490d0Smrg eval cmd=\"$cmd1\" 818365d490d0Smrg func_show_eval "$cmd" 'exit $?' 818465d490d0Smrg output=$save_output 818565d490d0Smrg libobjs=$save_libobjs 818665d490d0Smrg skipped_export=false 818765d490d0Smrg else 818865d490d0Smrg # The command line is too long to execute in one step. 818965d490d0Smrg func_verbose "using reloadable object file for export list..." 819065d490d0Smrg skipped_export=: 819165d490d0Smrg # Break out early, otherwise skipped_export may be 819265d490d0Smrg # set to false by a later but shorter cmd. 819365d490d0Smrg break 819465d490d0Smrg fi 819565d490d0Smrg done 819665d490d0Smrg IFS="$save_ifs" 819765d490d0Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 819865d490d0Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 819965d490d0Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 820065d490d0Smrg fi 820165d490d0Smrg fi 8202e4da13eeSmacallan fi 8203e4da13eeSmacallan 820465d490d0Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 820565d490d0Smrg tmp_export_symbols="$export_symbols" 820665d490d0Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 820765d490d0Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8208e4da13eeSmacallan fi 8209e4da13eeSmacallan 821065d490d0Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 821165d490d0Smrg # The given exports_symbols file has to be filtered, so filter it. 821265d490d0Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 821365d490d0Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 821465d490d0Smrg # 's' commands which not all seds can handle. GNU sed should be fine 821565d490d0Smrg # though. Also, the filter scales superlinearly with the number of 821665d490d0Smrg # global variables. join(1) would be nice here, but unfortunately 821765d490d0Smrg # isn't a blessed tool. 821865d490d0Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 821965d490d0Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 822065d490d0Smrg export_symbols=$output_objdir/$libname.def 822165d490d0Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 822265d490d0Smrg fi 8223e4da13eeSmacallan 822465d490d0Smrg tmp_deplibs= 822565d490d0Smrg for test_deplib in $deplibs; do 822665d490d0Smrg case " $convenience " in 822765d490d0Smrg *" $test_deplib "*) ;; 822865d490d0Smrg *) 822965d490d0Smrg func_append tmp_deplibs " $test_deplib" 823065d490d0Smrg ;; 823165d490d0Smrg esac 823265d490d0Smrg done 823365d490d0Smrg deplibs="$tmp_deplibs" 8234e4da13eeSmacallan 823565d490d0Smrg if test -n "$convenience"; then 823665d490d0Smrg if test -n "$whole_archive_flag_spec" && 823765d490d0Smrg test "$compiler_needs_object" = yes && 823865d490d0Smrg test -z "$libobjs"; then 823965d490d0Smrg # extract the archives, so we have objects to list. 824065d490d0Smrg # TODO: could optimize this to just extract one archive. 824165d490d0Smrg whole_archive_flag_spec= 824265d490d0Smrg fi 824365d490d0Smrg if test -n "$whole_archive_flag_spec"; then 824465d490d0Smrg save_libobjs=$libobjs 824565d490d0Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 824665d490d0Smrg test "X$libobjs" = "X " && libobjs= 824765d490d0Smrg else 824865d490d0Smrg gentop="$output_objdir/${outputname}x" 824965d490d0Smrg func_append generated " $gentop" 8250e4da13eeSmacallan 825165d490d0Smrg func_extract_archives $gentop $convenience 825265d490d0Smrg func_append libobjs " $func_extract_archives_result" 825365d490d0Smrg test "X$libobjs" = "X " && libobjs= 825465d490d0Smrg fi 8255e4da13eeSmacallan fi 8256e4da13eeSmacallan 825765d490d0Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 825865d490d0Smrg eval flag=\"$thread_safe_flag_spec\" 825965d490d0Smrg func_append linker_flags " $flag" 826065d490d0Smrg fi 8261e4da13eeSmacallan 826265d490d0Smrg # Make a backup of the uninstalled library when relinking 826365d490d0Smrg if test "$opt_mode" = relink; then 826465d490d0Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 826565d490d0Smrg fi 826665d490d0Smrg 826765d490d0Smrg # Do each of the archive commands. 826865d490d0Smrg if test "$module" = yes && test -n "$module_cmds" ; then 826965d490d0Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 827065d490d0Smrg eval test_cmds=\"$module_expsym_cmds\" 827165d490d0Smrg cmds=$module_expsym_cmds 827265d490d0Smrg else 827365d490d0Smrg eval test_cmds=\"$module_cmds\" 827465d490d0Smrg cmds=$module_cmds 827565d490d0Smrg fi 827665d490d0Smrg else 827765d490d0Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 827865d490d0Smrg eval test_cmds=\"$archive_expsym_cmds\" 827965d490d0Smrg cmds=$archive_expsym_cmds 828065d490d0Smrg else 828165d490d0Smrg eval test_cmds=\"$archive_cmds\" 828265d490d0Smrg cmds=$archive_cmds 828365d490d0Smrg fi 828465d490d0Smrg fi 8285e4da13eeSmacallan 828665d490d0Smrg if test "X$skipped_export" != "X:" && 828765d490d0Smrg func_len " $test_cmds" && 828865d490d0Smrg len=$func_len_result && 828965d490d0Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 8290e4da13eeSmacallan : 8291e4da13eeSmacallan else 829265d490d0Smrg # The command line is too long to link in one step, link piecewise 829365d490d0Smrg # or, if using GNU ld and skipped_export is not :, use a linker 829465d490d0Smrg # script. 8295e4da13eeSmacallan 829665d490d0Smrg # Save the value of $output and $libobjs because we want to 829765d490d0Smrg # use them later. If we have whole_archive_flag_spec, we 829865d490d0Smrg # want to use save_libobjs as it was before 829965d490d0Smrg # whole_archive_flag_spec was expanded, because we can't 830065d490d0Smrg # assume the linker understands whole_archive_flag_spec. 830165d490d0Smrg # This may have to be revisited, in case too many 830265d490d0Smrg # convenience libraries get linked in and end up exceeding 830365d490d0Smrg # the spec. 830465d490d0Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 830565d490d0Smrg save_libobjs=$libobjs 8306e4da13eeSmacallan fi 830765d490d0Smrg save_output=$output 830865d490d0Smrg func_basename "$output" 830965d490d0Smrg output_la=$func_basename_result 8310e4da13eeSmacallan 831165d490d0Smrg # Clear the reloadable object creation command queue and 831265d490d0Smrg # initialize k to one. 831365d490d0Smrg test_cmds= 8314e4da13eeSmacallan concat_cmds= 831565d490d0Smrg objlist= 831665d490d0Smrg last_robj= 831765d490d0Smrg k=1 8318e4da13eeSmacallan 831965d490d0Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 832065d490d0Smrg output=${output_objdir}/${output_la}.lnkscript 832165d490d0Smrg func_verbose "creating GNU ld script: $output" 832265d490d0Smrg echo 'INPUT (' > $output 832365d490d0Smrg for obj in $save_libobjs 832465d490d0Smrg do 832565d490d0Smrg func_to_tool_file "$obj" 832665d490d0Smrg $ECHO "$func_to_tool_file_result" >> $output 832765d490d0Smrg done 832865d490d0Smrg echo ')' >> $output 832965d490d0Smrg func_append delfiles " $output" 833065d490d0Smrg func_to_tool_file "$output" 833165d490d0Smrg output=$func_to_tool_file_result 833265d490d0Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 833365d490d0Smrg output=${output_objdir}/${output_la}.lnk 833465d490d0Smrg func_verbose "creating linker input file list: $output" 833565d490d0Smrg : > $output 833665d490d0Smrg set x $save_libobjs 833765d490d0Smrg shift 833865d490d0Smrg firstobj= 833965d490d0Smrg if test "$compiler_needs_object" = yes; then 834065d490d0Smrg firstobj="$1 " 834165d490d0Smrg shift 834265d490d0Smrg fi 834365d490d0Smrg for obj 834465d490d0Smrg do 834565d490d0Smrg func_to_tool_file "$obj" 834665d490d0Smrg $ECHO "$func_to_tool_file_result" >> $output 834765d490d0Smrg done 834865d490d0Smrg func_append delfiles " $output" 834965d490d0Smrg func_to_tool_file "$output" 835065d490d0Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 835165d490d0Smrg else 835265d490d0Smrg if test -n "$save_libobjs"; then 835365d490d0Smrg func_verbose "creating reloadable object files..." 835465d490d0Smrg output=$output_objdir/$output_la-${k}.$objext 835565d490d0Smrg eval test_cmds=\"$reload_cmds\" 835665d490d0Smrg func_len " $test_cmds" 835765d490d0Smrg len0=$func_len_result 835865d490d0Smrg len=$len0 835965d490d0Smrg 836065d490d0Smrg # Loop over the list of objects to be linked. 836165d490d0Smrg for obj in $save_libobjs 836265d490d0Smrg do 836365d490d0Smrg func_len " $obj" 836465d490d0Smrg func_arith $len + $func_len_result 836565d490d0Smrg len=$func_arith_result 836665d490d0Smrg if test "X$objlist" = X || 836765d490d0Smrg test "$len" -lt "$max_cmd_len"; then 836865d490d0Smrg func_append objlist " $obj" 836965d490d0Smrg else 837065d490d0Smrg # The command $test_cmds is almost too long, add a 837165d490d0Smrg # command to the queue. 837265d490d0Smrg if test "$k" -eq 1 ; then 837365d490d0Smrg # The first file doesn't have a previous command to add. 837465d490d0Smrg reload_objs=$objlist 837565d490d0Smrg eval concat_cmds=\"$reload_cmds\" 837665d490d0Smrg else 837765d490d0Smrg # All subsequent reloadable object files will link in 837865d490d0Smrg # the last one created. 837965d490d0Smrg reload_objs="$objlist $last_robj" 838065d490d0Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 838165d490d0Smrg fi 838265d490d0Smrg last_robj=$output_objdir/$output_la-${k}.$objext 838365d490d0Smrg func_arith $k + 1 838465d490d0Smrg k=$func_arith_result 838565d490d0Smrg output=$output_objdir/$output_la-${k}.$objext 838665d490d0Smrg objlist=" $obj" 838765d490d0Smrg func_len " $last_robj" 838865d490d0Smrg func_arith $len0 + $func_len_result 838965d490d0Smrg len=$func_arith_result 839065d490d0Smrg fi 839165d490d0Smrg done 839265d490d0Smrg # Handle the remaining objects by creating one last 839365d490d0Smrg # reloadable object file. All subsequent reloadable object 839465d490d0Smrg # files will link in the last one created. 839565d490d0Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 839665d490d0Smrg reload_objs="$objlist $last_robj" 839765d490d0Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 839865d490d0Smrg if test -n "$last_robj"; then 839965d490d0Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 8400e4da13eeSmacallan fi 840165d490d0Smrg func_append delfiles " $output" 840265d490d0Smrg 840365d490d0Smrg else 840465d490d0Smrg output= 840565d490d0Smrg fi 840665d490d0Smrg 840765d490d0Smrg if ${skipped_export-false}; then 840865d490d0Smrg func_verbose "generating symbol list for \`$libname.la'" 840965d490d0Smrg export_symbols="$output_objdir/$libname.exp" 841065d490d0Smrg $opt_dry_run || $RM $export_symbols 841165d490d0Smrg libobjs=$output 841265d490d0Smrg # Append the command to create the export file. 8413e4da13eeSmacallan test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 841465d490d0Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 841565d490d0Smrg if test -n "$last_robj"; then 841665d490d0Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 841765d490d0Smrg fi 841865d490d0Smrg fi 841965d490d0Smrg 842065d490d0Smrg test -n "$save_libobjs" && 842165d490d0Smrg func_verbose "creating a temporary reloadable object file: $output" 842265d490d0Smrg 842365d490d0Smrg # Loop through the commands generated above and execute them. 842465d490d0Smrg save_ifs="$IFS"; IFS='~' 842565d490d0Smrg for cmd in $concat_cmds; do 842665d490d0Smrg IFS="$save_ifs" 842765d490d0Smrg $opt_silent || { 842865d490d0Smrg func_quote_for_expand "$cmd" 842965d490d0Smrg eval "func_echo $func_quote_for_expand_result" 843065d490d0Smrg } 843165d490d0Smrg $opt_dry_run || eval "$cmd" || { 843265d490d0Smrg lt_exit=$? 843365d490d0Smrg 843465d490d0Smrg # Restore the uninstalled library and exit 843565d490d0Smrg if test "$opt_mode" = relink; then 843665d490d0Smrg ( cd "$output_objdir" && \ 843765d490d0Smrg $RM "${realname}T" && \ 843865d490d0Smrg $MV "${realname}U" "$realname" ) 843965d490d0Smrg fi 844065d490d0Smrg 844165d490d0Smrg exit $lt_exit 844265d490d0Smrg } 844365d490d0Smrg done 844465d490d0Smrg IFS="$save_ifs" 844565d490d0Smrg 844665d490d0Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 844765d490d0Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 844865d490d0Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8449e4da13eeSmacallan fi 8450e4da13eeSmacallan fi 8451e4da13eeSmacallan 845265d490d0Smrg if ${skipped_export-false}; then 845365d490d0Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 845465d490d0Smrg tmp_export_symbols="$export_symbols" 845565d490d0Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 845665d490d0Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 845765d490d0Smrg fi 8458e4da13eeSmacallan 845965d490d0Smrg if test -n "$orig_export_symbols"; then 846065d490d0Smrg # The given exports_symbols file has to be filtered, so filter it. 846165d490d0Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 846265d490d0Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 846365d490d0Smrg # 's' commands which not all seds can handle. GNU sed should be fine 846465d490d0Smrg # though. Also, the filter scales superlinearly with the number of 846565d490d0Smrg # global variables. join(1) would be nice here, but unfortunately 846665d490d0Smrg # isn't a blessed tool. 846765d490d0Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 846865d490d0Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 846965d490d0Smrg export_symbols=$output_objdir/$libname.def 847065d490d0Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 847165d490d0Smrg fi 847265d490d0Smrg fi 8473e4da13eeSmacallan 847465d490d0Smrg libobjs=$output 847565d490d0Smrg # Restore the value of output. 847665d490d0Smrg output=$save_output 8477e4da13eeSmacallan 847865d490d0Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 847965d490d0Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 848065d490d0Smrg test "X$libobjs" = "X " && libobjs= 848165d490d0Smrg fi 848265d490d0Smrg # Expand the library linking commands again to reset the 848365d490d0Smrg # value of $libobjs for piecewise linking. 8484e4da13eeSmacallan 848565d490d0Smrg # Do each of the archive commands. 848665d490d0Smrg if test "$module" = yes && test -n "$module_cmds" ; then 848765d490d0Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 848865d490d0Smrg cmds=$module_expsym_cmds 848965d490d0Smrg else 849065d490d0Smrg cmds=$module_cmds 8491e4da13eeSmacallan fi 8492e4da13eeSmacallan else 849365d490d0Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 849465d490d0Smrg cmds=$archive_expsym_cmds 849565d490d0Smrg else 849665d490d0Smrg cmds=$archive_cmds 849765d490d0Smrg fi 8498e4da13eeSmacallan fi 849965d490d0Smrg fi 8500e4da13eeSmacallan 850165d490d0Smrg if test -n "$delfiles"; then 850265d490d0Smrg # Append the command to remove temporary files to $cmds. 850365d490d0Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 850465d490d0Smrg fi 8505e4da13eeSmacallan 850665d490d0Smrg # Add any objects from preloaded convenience libraries 850765d490d0Smrg if test -n "$dlprefiles"; then 850865d490d0Smrg gentop="$output_objdir/${outputname}x" 850965d490d0Smrg func_append generated " $gentop" 8510e4da13eeSmacallan 851165d490d0Smrg func_extract_archives $gentop $dlprefiles 851265d490d0Smrg func_append libobjs " $func_extract_archives_result" 851365d490d0Smrg test "X$libobjs" = "X " && libobjs= 851465d490d0Smrg fi 8515e4da13eeSmacallan 851665d490d0Smrg save_ifs="$IFS"; IFS='~' 851765d490d0Smrg for cmd in $cmds; do 851865d490d0Smrg IFS="$save_ifs" 851965d490d0Smrg eval cmd=\"$cmd\" 852065d490d0Smrg $opt_silent || { 852165d490d0Smrg func_quote_for_expand "$cmd" 852265d490d0Smrg eval "func_echo $func_quote_for_expand_result" 852365d490d0Smrg } 852465d490d0Smrg $opt_dry_run || eval "$cmd" || { 852565d490d0Smrg lt_exit=$? 8526e4da13eeSmacallan 852765d490d0Smrg # Restore the uninstalled library and exit 852865d490d0Smrg if test "$opt_mode" = relink; then 852965d490d0Smrg ( cd "$output_objdir" && \ 853065d490d0Smrg $RM "${realname}T" && \ 853165d490d0Smrg $MV "${realname}U" "$realname" ) 853265d490d0Smrg fi 8533e4da13eeSmacallan 853465d490d0Smrg exit $lt_exit 853565d490d0Smrg } 853665d490d0Smrg done 853765d490d0Smrg IFS="$save_ifs" 8538e4da13eeSmacallan 853965d490d0Smrg # Restore the uninstalled library and exit 854065d490d0Smrg if test "$opt_mode" = relink; then 854165d490d0Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 8542e4da13eeSmacallan 854365d490d0Smrg if test -n "$convenience"; then 854465d490d0Smrg if test -z "$whole_archive_flag_spec"; then 854565d490d0Smrg func_show_eval '${RM}r "$gentop"' 854665d490d0Smrg fi 854765d490d0Smrg fi 8548e4da13eeSmacallan 854965d490d0Smrg exit $EXIT_SUCCESS 855065d490d0Smrg fi 855165d490d0Smrg 855265d490d0Smrg # Create links to the real library. 855365d490d0Smrg for linkname in $linknames; do 855465d490d0Smrg if test "$realname" != "$linkname"; then 855565d490d0Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 8556e4da13eeSmacallan fi 8557e4da13eeSmacallan done 8558e4da13eeSmacallan 855965d490d0Smrg # If -module or -export-dynamic was specified, set the dlname. 856065d490d0Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 856165d490d0Smrg # On all known operating systems, these are identical. 856265d490d0Smrg dlname="$soname" 856365d490d0Smrg fi 856465d490d0Smrg fi 8565e4da13eeSmacallan ;; 8566e4da13eeSmacallan 856765d490d0Smrg obj) 856865d490d0Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 856965d490d0Smrg func_warning "\`-dlopen' is ignored for objects" 857065d490d0Smrg fi 8571e4da13eeSmacallan 857265d490d0Smrg case " $deplibs" in 857365d490d0Smrg *\ -l* | *\ -L*) 857465d490d0Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 8575e4da13eeSmacallan esac 8576e4da13eeSmacallan 857765d490d0Smrg test -n "$rpath" && \ 857865d490d0Smrg func_warning "\`-rpath' is ignored for objects" 8579e4da13eeSmacallan 858065d490d0Smrg test -n "$xrpath" && \ 858165d490d0Smrg func_warning "\`-R' is ignored for objects" 8582e4da13eeSmacallan 858365d490d0Smrg test -n "$vinfo" && \ 858465d490d0Smrg func_warning "\`-version-info' is ignored for objects" 858565d490d0Smrg 858665d490d0Smrg test -n "$release" && \ 858765d490d0Smrg func_warning "\`-release' is ignored for objects" 858865d490d0Smrg 858965d490d0Smrg case $output in 859065d490d0Smrg *.lo) 859165d490d0Smrg test -n "$objs$old_deplibs" && \ 859265d490d0Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 859365d490d0Smrg 859465d490d0Smrg libobj=$output 859565d490d0Smrg func_lo2o "$libobj" 859665d490d0Smrg obj=$func_lo2o_result 8597e4da13eeSmacallan ;; 8598e4da13eeSmacallan *) 859965d490d0Smrg libobj= 860065d490d0Smrg obj="$output" 8601e4da13eeSmacallan ;; 8602e4da13eeSmacallan esac 8603e4da13eeSmacallan 860465d490d0Smrg # Delete the old objects. 860565d490d0Smrg $opt_dry_run || $RM $obj $libobj 8606e4da13eeSmacallan 860765d490d0Smrg # Objects from convenience libraries. This assumes 860865d490d0Smrg # single-version convenience libraries. Whenever we create 860965d490d0Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 861065d490d0Smrg # the extraction. 861165d490d0Smrg reload_conv_objs= 861265d490d0Smrg gentop= 861365d490d0Smrg # reload_cmds runs $LD directly, so let us get rid of 861465d490d0Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 861565d490d0Smrg # turning comma into space.. 861665d490d0Smrg wl= 8617e4da13eeSmacallan 861865d490d0Smrg if test -n "$convenience"; then 861965d490d0Smrg if test -n "$whole_archive_flag_spec"; then 862065d490d0Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 862165d490d0Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 862265d490d0Smrg else 862365d490d0Smrg gentop="$output_objdir/${obj}x" 862465d490d0Smrg func_append generated " $gentop" 8625e4da13eeSmacallan 862665d490d0Smrg func_extract_archives $gentop $convenience 862765d490d0Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 862865d490d0Smrg fi 8629e4da13eeSmacallan fi 8630e4da13eeSmacallan 863165d490d0Smrg # If we're not building shared, we need to use non_pic_objs 863265d490d0Smrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 8633e4da13eeSmacallan 863465d490d0Smrg # Create the old-style object. 863565d490d0Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 8636e4da13eeSmacallan 863765d490d0Smrg output="$obj" 863865d490d0Smrg func_execute_cmds "$reload_cmds" 'exit $?' 863965d490d0Smrg 864065d490d0Smrg # Exit if we aren't doing a library object file. 864165d490d0Smrg if test -z "$libobj"; then 864265d490d0Smrg if test -n "$gentop"; then 864365d490d0Smrg func_show_eval '${RM}r "$gentop"' 864465d490d0Smrg fi 864565d490d0Smrg 864665d490d0Smrg exit $EXIT_SUCCESS 8647e4da13eeSmacallan fi 864865d490d0Smrg 864965d490d0Smrg if test "$build_libtool_libs" != yes; then 865065d490d0Smrg if test -n "$gentop"; then 865165d490d0Smrg func_show_eval '${RM}r "$gentop"' 865265d490d0Smrg fi 865365d490d0Smrg 865465d490d0Smrg # Create an invalid libtool object if no PIC, so that we don't 865565d490d0Smrg # accidentally link it into a program. 865665d490d0Smrg # $show "echo timestamp > $libobj" 865765d490d0Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 865865d490d0Smrg exit $EXIT_SUCCESS 865965d490d0Smrg fi 866065d490d0Smrg 866165d490d0Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 866265d490d0Smrg # Only do commands if we really have different PIC objects. 866365d490d0Smrg reload_objs="$libobjs $reload_conv_objs" 866465d490d0Smrg output="$libobj" 866565d490d0Smrg func_execute_cmds "$reload_cmds" 'exit $?' 866665d490d0Smrg fi 866765d490d0Smrg 866865d490d0Smrg if test -n "$gentop"; then 866965d490d0Smrg func_show_eval '${RM}r "$gentop"' 867065d490d0Smrg fi 867165d490d0Smrg 867265d490d0Smrg exit $EXIT_SUCCESS 8673e4da13eeSmacallan ;; 8674e4da13eeSmacallan 867565d490d0Smrg prog) 867665d490d0Smrg case $host in 867765d490d0Smrg *cygwin*) func_stripname '' '.exe' "$output" 867865d490d0Smrg output=$func_stripname_result.exe;; 867965d490d0Smrg esac 868065d490d0Smrg test -n "$vinfo" && \ 868165d490d0Smrg func_warning "\`-version-info' is ignored for programs" 8682e4da13eeSmacallan 868365d490d0Smrg test -n "$release" && \ 868465d490d0Smrg func_warning "\`-release' is ignored for programs" 8685e4da13eeSmacallan 868665d490d0Smrg test "$preload" = yes \ 868765d490d0Smrg && test "$dlopen_support" = unknown \ 868865d490d0Smrg && test "$dlopen_self" = unknown \ 868965d490d0Smrg && test "$dlopen_self_static" = unknown && \ 869065d490d0Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 869165d490d0Smrg 869265d490d0Smrg case $host in 869365d490d0Smrg *-*-rhapsody* | *-*-darwin1.[012]) 869465d490d0Smrg # On Rhapsody replace the C library is the System framework 869565d490d0Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 869665d490d0Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 8697e4da13eeSmacallan ;; 869865d490d0Smrg esac 8699e4da13eeSmacallan 870065d490d0Smrg case $host in 870165d490d0Smrg *-*-darwin*) 870265d490d0Smrg # Don't allow lazy linking, it breaks C++ global constructors 870365d490d0Smrg # But is supposedly fixed on 10.4 or later (yay!). 870465d490d0Smrg if test "$tagname" = CXX ; then 870565d490d0Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 870665d490d0Smrg 10.[0123]) 870765d490d0Smrg func_append compile_command " ${wl}-bind_at_load" 870865d490d0Smrg func_append finalize_command " ${wl}-bind_at_load" 870965d490d0Smrg ;; 871065d490d0Smrg esac 8711e4da13eeSmacallan fi 871265d490d0Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 871365d490d0Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 871465d490d0Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 871565d490d0Smrg ;; 871665d490d0Smrg esac 8717e4da13eeSmacallan 8718e4da13eeSmacallan 871965d490d0Smrg # move library search paths that coincide with paths to not yet 872065d490d0Smrg # installed libraries to the beginning of the library search list 872165d490d0Smrg new_libs= 872265d490d0Smrg for path in $notinst_path; do 872365d490d0Smrg case " $new_libs " in 872465d490d0Smrg *" -L$path/$objdir "*) ;; 872565d490d0Smrg *) 872665d490d0Smrg case " $compile_deplibs " in 872765d490d0Smrg *" -L$path/$objdir "*) 872865d490d0Smrg func_append new_libs " -L$path/$objdir" ;; 8729e4da13eeSmacallan esac 873065d490d0Smrg ;; 873165d490d0Smrg esac 873265d490d0Smrg done 873365d490d0Smrg for deplib in $compile_deplibs; do 873465d490d0Smrg case $deplib in 873565d490d0Smrg -L*) 873665d490d0Smrg case " $new_libs " in 873765d490d0Smrg *" $deplib "*) ;; 873865d490d0Smrg *) func_append new_libs " $deplib" ;; 8739e4da13eeSmacallan esac 874065d490d0Smrg ;; 874165d490d0Smrg *) func_append new_libs " $deplib" ;; 874265d490d0Smrg esac 874365d490d0Smrg done 874465d490d0Smrg compile_deplibs="$new_libs" 8745e4da13eeSmacallan 8746e4da13eeSmacallan 874765d490d0Smrg func_append compile_command " $compile_deplibs" 874865d490d0Smrg func_append finalize_command " $finalize_deplibs" 8749e4da13eeSmacallan 875065d490d0Smrg if test -n "$rpath$xrpath"; then 875165d490d0Smrg # If the user specified any rpath flags, then add them. 875265d490d0Smrg for libdir in $rpath $xrpath; do 875365d490d0Smrg # This is the magic to use -rpath. 875465d490d0Smrg case "$finalize_rpath " in 875565d490d0Smrg *" $libdir "*) ;; 875665d490d0Smrg *) func_append finalize_rpath " $libdir" ;; 875765d490d0Smrg esac 875865d490d0Smrg done 875965d490d0Smrg fi 8760e4da13eeSmacallan 876165d490d0Smrg # Now hardcode the library paths 876265d490d0Smrg rpath= 876365d490d0Smrg hardcode_libdirs= 876465d490d0Smrg for libdir in $compile_rpath $finalize_rpath; do 876565d490d0Smrg if test -n "$hardcode_libdir_flag_spec"; then 876665d490d0Smrg if test -n "$hardcode_libdir_separator"; then 876765d490d0Smrg if test -z "$hardcode_libdirs"; then 876865d490d0Smrg hardcode_libdirs="$libdir" 876965d490d0Smrg else 877065d490d0Smrg # Just accumulate the unique libdirs. 877165d490d0Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 877265d490d0Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 877365d490d0Smrg ;; 877465d490d0Smrg *) 877565d490d0Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 877665d490d0Smrg ;; 877765d490d0Smrg esac 877865d490d0Smrg fi 8779e4da13eeSmacallan else 878065d490d0Smrg eval flag=\"$hardcode_libdir_flag_spec\" 878165d490d0Smrg func_append rpath " $flag" 8782e4da13eeSmacallan fi 878365d490d0Smrg elif test -n "$runpath_var"; then 878465d490d0Smrg case "$perm_rpath " in 878565d490d0Smrg *" $libdir "*) ;; 878665d490d0Smrg *) func_append perm_rpath " $libdir" ;; 878765d490d0Smrg esac 878865d490d0Smrg fi 878965d490d0Smrg case $host in 879065d490d0Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 879165d490d0Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 879265d490d0Smrg case :$dllsearchpath: in 879365d490d0Smrg *":$libdir:"*) ;; 879465d490d0Smrg ::) dllsearchpath=$libdir;; 879565d490d0Smrg *) func_append dllsearchpath ":$libdir";; 879665d490d0Smrg esac 879765d490d0Smrg case :$dllsearchpath: in 879865d490d0Smrg *":$testbindir:"*) ;; 879965d490d0Smrg ::) dllsearchpath=$testbindir;; 880065d490d0Smrg *) func_append dllsearchpath ":$testbindir";; 880165d490d0Smrg esac 880265d490d0Smrg ;; 880365d490d0Smrg esac 880465d490d0Smrg done 880565d490d0Smrg # Substitute the hardcoded libdirs into the rpath. 880665d490d0Smrg if test -n "$hardcode_libdir_separator" && 880765d490d0Smrg test -n "$hardcode_libdirs"; then 880865d490d0Smrg libdir="$hardcode_libdirs" 880965d490d0Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 881065d490d0Smrg fi 881165d490d0Smrg compile_rpath="$rpath" 8812e4da13eeSmacallan 881365d490d0Smrg rpath= 881465d490d0Smrg hardcode_libdirs= 881565d490d0Smrg for libdir in $finalize_rpath; do 881665d490d0Smrg if test -n "$hardcode_libdir_flag_spec"; then 881765d490d0Smrg if test -n "$hardcode_libdir_separator"; then 881865d490d0Smrg if test -z "$hardcode_libdirs"; then 881965d490d0Smrg hardcode_libdirs="$libdir" 882065d490d0Smrg else 882165d490d0Smrg # Just accumulate the unique libdirs. 882265d490d0Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 882365d490d0Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 882465d490d0Smrg ;; 882565d490d0Smrg *) 882665d490d0Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 882765d490d0Smrg ;; 882865d490d0Smrg esac 882965d490d0Smrg fi 8830e4da13eeSmacallan else 883165d490d0Smrg eval flag=\"$hardcode_libdir_flag_spec\" 883265d490d0Smrg func_append rpath " $flag" 8833e4da13eeSmacallan fi 883465d490d0Smrg elif test -n "$runpath_var"; then 883565d490d0Smrg case "$finalize_perm_rpath " in 883665d490d0Smrg *" $libdir "*) ;; 883765d490d0Smrg *) func_append finalize_perm_rpath " $libdir" ;; 883865d490d0Smrg esac 8839e4da13eeSmacallan fi 884065d490d0Smrg done 884165d490d0Smrg # Substitute the hardcoded libdirs into the rpath. 884265d490d0Smrg if test -n "$hardcode_libdir_separator" && 884365d490d0Smrg test -n "$hardcode_libdirs"; then 884465d490d0Smrg libdir="$hardcode_libdirs" 884565d490d0Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 884665d490d0Smrg fi 884765d490d0Smrg finalize_rpath="$rpath" 8848e4da13eeSmacallan 884965d490d0Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 885065d490d0Smrg # Transform all the library objects into standard objects. 885165d490d0Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 885265d490d0Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 885365d490d0Smrg fi 8854e4da13eeSmacallan 885565d490d0Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8856e4da13eeSmacallan 885765d490d0Smrg # template prelinking step 885865d490d0Smrg if test -n "$prelink_cmds"; then 885965d490d0Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 886065d490d0Smrg fi 8861e4da13eeSmacallan 886265d490d0Smrg wrappers_required=yes 886365d490d0Smrg case $host in 886465d490d0Smrg *cegcc* | *mingw32ce*) 886565d490d0Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 886665d490d0Smrg wrappers_required=no 886765d490d0Smrg ;; 886865d490d0Smrg *cygwin* | *mingw* ) 886965d490d0Smrg if test "$build_libtool_libs" != yes; then 887065d490d0Smrg wrappers_required=no 887165d490d0Smrg fi 887265d490d0Smrg ;; 887365d490d0Smrg *) 887465d490d0Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 887565d490d0Smrg wrappers_required=no 887665d490d0Smrg fi 887765d490d0Smrg ;; 887865d490d0Smrg esac 887965d490d0Smrg if test "$wrappers_required" = no; then 888065d490d0Smrg # Replace the output file specification. 888165d490d0Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 888265d490d0Smrg link_command="$compile_command$compile_rpath" 8883e4da13eeSmacallan 888465d490d0Smrg # We have no uninstalled library dependencies, so finalize right now. 888565d490d0Smrg exit_status=0 888665d490d0Smrg func_show_eval "$link_command" 'exit_status=$?' 8887e4da13eeSmacallan 888865d490d0Smrg if test -n "$postlink_cmds"; then 888965d490d0Smrg func_to_tool_file "$output" 889065d490d0Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 889165d490d0Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 8892e4da13eeSmacallan fi 8893e4da13eeSmacallan 889465d490d0Smrg # Delete the generated files. 889565d490d0Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 889665d490d0Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 889765d490d0Smrg fi 8898e4da13eeSmacallan 889965d490d0Smrg exit $exit_status 890065d490d0Smrg fi 8901e4da13eeSmacallan 890265d490d0Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 890365d490d0Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 890465d490d0Smrg fi 890565d490d0Smrg if test -n "$finalize_shlibpath"; then 890665d490d0Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 890765d490d0Smrg fi 8908e4da13eeSmacallan 890965d490d0Smrg compile_var= 891065d490d0Smrg finalize_var= 891165d490d0Smrg if test -n "$runpath_var"; then 891265d490d0Smrg if test -n "$perm_rpath"; then 891365d490d0Smrg # We should set the runpath_var. 891465d490d0Smrg rpath= 891565d490d0Smrg for dir in $perm_rpath; do 891665d490d0Smrg func_append rpath "$dir:" 891765d490d0Smrg done 891865d490d0Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8919e4da13eeSmacallan fi 892065d490d0Smrg if test -n "$finalize_perm_rpath"; then 892165d490d0Smrg # We should set the runpath_var. 892265d490d0Smrg rpath= 892365d490d0Smrg for dir in $finalize_perm_rpath; do 892465d490d0Smrg func_append rpath "$dir:" 892565d490d0Smrg done 892665d490d0Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 8927e4da13eeSmacallan fi 892865d490d0Smrg fi 8929e4da13eeSmacallan 893065d490d0Smrg if test "$no_install" = yes; then 893165d490d0Smrg # We don't need to create a wrapper script. 893265d490d0Smrg link_command="$compile_var$compile_command$compile_rpath" 893365d490d0Smrg # Replace the output file specification. 893465d490d0Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 893565d490d0Smrg # Delete the old output file. 893665d490d0Smrg $opt_dry_run || $RM $output 893765d490d0Smrg # Link the executable and exit 893865d490d0Smrg func_show_eval "$link_command" 'exit $?' 8939e4da13eeSmacallan 894065d490d0Smrg if test -n "$postlink_cmds"; then 894165d490d0Smrg func_to_tool_file "$output" 894265d490d0Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 894365d490d0Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 8944e4da13eeSmacallan fi 894565d490d0Smrg 8946e4da13eeSmacallan exit $EXIT_SUCCESS 894765d490d0Smrg fi 8948e4da13eeSmacallan 894965d490d0Smrg if test "$hardcode_action" = relink; then 895065d490d0Smrg # Fast installation is not supported 895165d490d0Smrg link_command="$compile_var$compile_command$compile_rpath" 895265d490d0Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 895365d490d0Smrg 895465d490d0Smrg func_warning "this platform does not like uninstalled shared libraries" 895565d490d0Smrg func_warning "\`$output' will be relinked during installation" 895665d490d0Smrg else 895765d490d0Smrg if test "$fast_install" != no; then 895865d490d0Smrg link_command="$finalize_var$compile_command$finalize_rpath" 895965d490d0Smrg if test "$fast_install" = yes; then 896065d490d0Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 896165d490d0Smrg else 896265d490d0Smrg # fast_install is set to needless 896365d490d0Smrg relink_command= 896465d490d0Smrg fi 8965e4da13eeSmacallan else 896665d490d0Smrg link_command="$compile_var$compile_command$compile_rpath" 896765d490d0Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8968e4da13eeSmacallan fi 896965d490d0Smrg fi 8970e4da13eeSmacallan 897165d490d0Smrg # Replace the output file specification. 897265d490d0Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 8973e4da13eeSmacallan 897465d490d0Smrg # Delete the old output files. 897565d490d0Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 8976e4da13eeSmacallan 897765d490d0Smrg func_show_eval "$link_command" 'exit $?' 8978e4da13eeSmacallan 897965d490d0Smrg if test -n "$postlink_cmds"; then 898065d490d0Smrg func_to_tool_file "$output_objdir/$outputname" 898165d490d0Smrg 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'` 898265d490d0Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 898365d490d0Smrg fi 8984e4da13eeSmacallan 898565d490d0Smrg # Now create the wrapper script. 898665d490d0Smrg func_verbose "creating $output" 8987e4da13eeSmacallan 898865d490d0Smrg # Quote the relink command for shipping. 898965d490d0Smrg if test -n "$relink_command"; then 899065d490d0Smrg # Preserve any variables that may affect compiler behavior 899165d490d0Smrg for var in $variables_saved_for_relink; do 899265d490d0Smrg if eval test -z \"\${$var+set}\"; then 899365d490d0Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 899465d490d0Smrg elif eval var_value=\$$var; test -z "$var_value"; then 899565d490d0Smrg relink_command="$var=; export $var; $relink_command" 8996e4da13eeSmacallan else 899765d490d0Smrg func_quote_for_eval "$var_value" 899865d490d0Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 8999e4da13eeSmacallan fi 900065d490d0Smrg done 900165d490d0Smrg relink_command="(cd `pwd`; $relink_command)" 900265d490d0Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 900365d490d0Smrg fi 900465d490d0Smrg 900565d490d0Smrg # Only actually do things if not in dry run mode. 900665d490d0Smrg $opt_dry_run || { 900765d490d0Smrg # win32 will think the script is a binary if it has 900865d490d0Smrg # a .exe suffix, so we strip it off here. 900965d490d0Smrg case $output in 901065d490d0Smrg *.exe) func_stripname '' '.exe' "$output" 901165d490d0Smrg output=$func_stripname_result ;; 9012e4da13eeSmacallan esac 901365d490d0Smrg # test for cygwin because mv fails w/o .exe extensions 901465d490d0Smrg case $host in 901565d490d0Smrg *cygwin*) 901665d490d0Smrg exeext=.exe 901765d490d0Smrg func_stripname '' '.exe' "$outputname" 901865d490d0Smrg outputname=$func_stripname_result ;; 901965d490d0Smrg *) exeext= ;; 902065d490d0Smrg esac 902165d490d0Smrg case $host in 902265d490d0Smrg *cygwin* | *mingw* ) 902365d490d0Smrg func_dirname_and_basename "$output" "" "." 902465d490d0Smrg output_name=$func_basename_result 902565d490d0Smrg output_path=$func_dirname_result 902665d490d0Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 902765d490d0Smrg cwrapper="$output_path/$output_name.exe" 902865d490d0Smrg $RM $cwrappersource $cwrapper 902965d490d0Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 903065d490d0Smrg 903165d490d0Smrg func_emit_cwrapperexe_src > $cwrappersource 903265d490d0Smrg 903365d490d0Smrg # The wrapper executable is built using the $host compiler, 903465d490d0Smrg # because it contains $host paths and files. If cross- 903565d490d0Smrg # compiling, it, like the target executable, must be 903665d490d0Smrg # executed on the $host or under an emulation environment. 903765d490d0Smrg $opt_dry_run || { 903865d490d0Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 903965d490d0Smrg $STRIP $cwrapper 904065d490d0Smrg } 9041e4da13eeSmacallan 904265d490d0Smrg # Now, create the wrapper script for func_source use: 904365d490d0Smrg func_ltwrapper_scriptname $cwrapper 904465d490d0Smrg $RM $func_ltwrapper_scriptname_result 904565d490d0Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 904665d490d0Smrg $opt_dry_run || { 904765d490d0Smrg # note: this script will not be executed, so do not chmod. 904865d490d0Smrg if test "x$build" = "x$host" ; then 904965d490d0Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 905065d490d0Smrg else 905165d490d0Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 905265d490d0Smrg fi 905365d490d0Smrg } 905465d490d0Smrg ;; 905565d490d0Smrg * ) 905665d490d0Smrg $RM $output 905765d490d0Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 9058e4da13eeSmacallan 905965d490d0Smrg func_emit_wrapper no > $output 906065d490d0Smrg chmod +x $output 906165d490d0Smrg ;; 906265d490d0Smrg esac 906365d490d0Smrg } 906465d490d0Smrg exit $EXIT_SUCCESS 906565d490d0Smrg ;; 906665d490d0Smrg esac 9067e4da13eeSmacallan 906865d490d0Smrg # See if we need to build an old-fashioned archive. 906965d490d0Smrg for oldlib in $oldlibs; do 9070e4da13eeSmacallan 907165d490d0Smrg if test "$build_libtool_libs" = convenience; then 907265d490d0Smrg oldobjs="$libobjs_save $symfileobj" 907365d490d0Smrg addlibs="$convenience" 907465d490d0Smrg build_libtool_libs=no 907565d490d0Smrg else 907665d490d0Smrg if test "$build_libtool_libs" = module; then 907765d490d0Smrg oldobjs="$libobjs_save" 907865d490d0Smrg build_libtool_libs=no 907965d490d0Smrg else 908065d490d0Smrg oldobjs="$old_deplibs $non_pic_objects" 908165d490d0Smrg if test "$preload" = yes && test -f "$symfileobj"; then 908265d490d0Smrg func_append oldobjs " $symfileobj" 908365d490d0Smrg fi 908465d490d0Smrg fi 908565d490d0Smrg addlibs="$old_convenience" 9086e4da13eeSmacallan fi 9087e4da13eeSmacallan 908865d490d0Smrg if test -n "$addlibs"; then 908965d490d0Smrg gentop="$output_objdir/${outputname}x" 909065d490d0Smrg func_append generated " $gentop" 9091e4da13eeSmacallan 909265d490d0Smrg func_extract_archives $gentop $addlibs 909365d490d0Smrg func_append oldobjs " $func_extract_archives_result" 909465d490d0Smrg fi 9095e4da13eeSmacallan 909665d490d0Smrg # Do each command in the archive commands. 909765d490d0Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 909865d490d0Smrg cmds=$old_archive_from_new_cmds 909965d490d0Smrg else 9100e4da13eeSmacallan 910165d490d0Smrg # Add any objects from preloaded convenience libraries 910265d490d0Smrg if test -n "$dlprefiles"; then 910365d490d0Smrg gentop="$output_objdir/${outputname}x" 910465d490d0Smrg func_append generated " $gentop" 9105e4da13eeSmacallan 910665d490d0Smrg func_extract_archives $gentop $dlprefiles 910765d490d0Smrg func_append oldobjs " $func_extract_archives_result" 910865d490d0Smrg fi 9109e4da13eeSmacallan 911065d490d0Smrg # POSIX demands no paths to be encoded in archives. We have 911165d490d0Smrg # to avoid creating archives with duplicate basenames if we 911265d490d0Smrg # might have to extract them afterwards, e.g., when creating a 911365d490d0Smrg # static archive out of a convenience library, or when linking 911465d490d0Smrg # the entirety of a libtool archive into another (currently 911565d490d0Smrg # not supported by libtool). 911665d490d0Smrg if (for obj in $oldobjs 911765d490d0Smrg do 911865d490d0Smrg func_basename "$obj" 911965d490d0Smrg $ECHO "$func_basename_result" 912065d490d0Smrg done | sort | sort -uc >/dev/null 2>&1); then 912165d490d0Smrg : 912265d490d0Smrg else 912365d490d0Smrg echo "copying selected object files to avoid basename conflicts..." 912465d490d0Smrg gentop="$output_objdir/${outputname}x" 912565d490d0Smrg func_append generated " $gentop" 912665d490d0Smrg func_mkdir_p "$gentop" 912765d490d0Smrg save_oldobjs=$oldobjs 912865d490d0Smrg oldobjs= 912965d490d0Smrg counter=1 913065d490d0Smrg for obj in $save_oldobjs 913165d490d0Smrg do 913265d490d0Smrg func_basename "$obj" 913365d490d0Smrg objbase="$func_basename_result" 913465d490d0Smrg case " $oldobjs " in 913565d490d0Smrg " ") oldobjs=$obj ;; 913665d490d0Smrg *[\ /]"$objbase "*) 913765d490d0Smrg while :; do 913865d490d0Smrg # Make sure we don't pick an alternate name that also 913965d490d0Smrg # overlaps. 914065d490d0Smrg newobj=lt$counter-$objbase 914165d490d0Smrg func_arith $counter + 1 914265d490d0Smrg counter=$func_arith_result 914365d490d0Smrg case " $oldobjs " in 914465d490d0Smrg *[\ /]"$newobj "*) ;; 914565d490d0Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 914665d490d0Smrg esac 914765d490d0Smrg done 914865d490d0Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 914965d490d0Smrg func_append oldobjs " $gentop/$newobj" 915065d490d0Smrg ;; 915165d490d0Smrg *) func_append oldobjs " $obj" ;; 915265d490d0Smrg esac 9153e4da13eeSmacallan done 9154e4da13eeSmacallan fi 915565d490d0Smrg eval cmds=\"$old_archive_cmds\" 9156e4da13eeSmacallan 915765d490d0Smrg func_len " $cmds" 915865d490d0Smrg len=$func_len_result 915965d490d0Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 916065d490d0Smrg cmds=$old_archive_cmds 916165d490d0Smrg elif test -n "$archiver_list_spec"; then 916265d490d0Smrg func_verbose "using command file archive linking..." 916365d490d0Smrg for obj in $oldobjs 916465d490d0Smrg do 916565d490d0Smrg func_to_tool_file "$obj" 916665d490d0Smrg $ECHO "$func_to_tool_file_result" 916765d490d0Smrg done > $output_objdir/$libname.libcmd 916865d490d0Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 916965d490d0Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 917065d490d0Smrg cmds=$old_archive_cmds 917165d490d0Smrg else 917265d490d0Smrg # the command line is too long to link in one step, link in parts 917365d490d0Smrg func_verbose "using piecewise archive linking..." 917465d490d0Smrg save_RANLIB=$RANLIB 917565d490d0Smrg RANLIB=: 917665d490d0Smrg objlist= 917765d490d0Smrg concat_cmds= 917865d490d0Smrg save_oldobjs=$oldobjs 917965d490d0Smrg oldobjs= 918065d490d0Smrg # Is there a better way of finding the last object in the list? 918165d490d0Smrg for obj in $save_oldobjs 918265d490d0Smrg do 918365d490d0Smrg last_oldobj=$obj 918465d490d0Smrg done 918565d490d0Smrg eval test_cmds=\"$old_archive_cmds\" 918665d490d0Smrg func_len " $test_cmds" 918765d490d0Smrg len0=$func_len_result 918865d490d0Smrg len=$len0 918965d490d0Smrg for obj in $save_oldobjs 919065d490d0Smrg do 919165d490d0Smrg func_len " $obj" 919265d490d0Smrg func_arith $len + $func_len_result 919365d490d0Smrg len=$func_arith_result 919465d490d0Smrg func_append objlist " $obj" 919565d490d0Smrg if test "$len" -lt "$max_cmd_len"; then 919665d490d0Smrg : 919765d490d0Smrg else 919865d490d0Smrg # the above command should be used before it gets too long 919965d490d0Smrg oldobjs=$objlist 920065d490d0Smrg if test "$obj" = "$last_oldobj" ; then 920165d490d0Smrg RANLIB=$save_RANLIB 920265d490d0Smrg fi 920365d490d0Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 920465d490d0Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 920565d490d0Smrg objlist= 920665d490d0Smrg len=$len0 920765d490d0Smrg fi 920865d490d0Smrg done 920965d490d0Smrg RANLIB=$save_RANLIB 921065d490d0Smrg oldobjs=$objlist 921165d490d0Smrg if test "X$oldobjs" = "X" ; then 921265d490d0Smrg eval cmds=\"\$concat_cmds\" 921365d490d0Smrg else 921465d490d0Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 921565d490d0Smrg fi 921665d490d0Smrg fi 921765d490d0Smrg fi 921865d490d0Smrg func_execute_cmds "$cmds" 'exit $?' 9219e4da13eeSmacallan done 9220e4da13eeSmacallan 922165d490d0Smrg test -n "$generated" && \ 922265d490d0Smrg func_show_eval "${RM}r$generated" 9223e4da13eeSmacallan 922465d490d0Smrg # Now create the libtool archive. 922565d490d0Smrg case $output in 922665d490d0Smrg *.la) 922765d490d0Smrg old_library= 922865d490d0Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 922965d490d0Smrg func_verbose "creating $output" 9230e4da13eeSmacallan 923165d490d0Smrg # Preserve any variables that may affect compiler behavior 923265d490d0Smrg for var in $variables_saved_for_relink; do 923365d490d0Smrg if eval test -z \"\${$var+set}\"; then 923465d490d0Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 923565d490d0Smrg elif eval var_value=\$$var; test -z "$var_value"; then 923665d490d0Smrg relink_command="$var=; export $var; $relink_command" 9237e4da13eeSmacallan else 923865d490d0Smrg func_quote_for_eval "$var_value" 923965d490d0Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9240e4da13eeSmacallan fi 924165d490d0Smrg done 924265d490d0Smrg # Quote the link command for shipping. 924365d490d0Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 924465d490d0Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 924565d490d0Smrg if test "$hardcode_automatic" = yes ; then 924665d490d0Smrg relink_command= 924765d490d0Smrg fi 9248e4da13eeSmacallan 924965d490d0Smrg # Only create the output if not a dry run. 925065d490d0Smrg $opt_dry_run || { 925165d490d0Smrg for installed in no yes; do 925265d490d0Smrg if test "$installed" = yes; then 925365d490d0Smrg if test -z "$install_libdir"; then 925465d490d0Smrg break 925565d490d0Smrg fi 925665d490d0Smrg output="$output_objdir/$outputname"i 925765d490d0Smrg # Replace all uninstalled libtool libraries with the installed ones 925865d490d0Smrg newdependency_libs= 925965d490d0Smrg for deplib in $dependency_libs; do 926065d490d0Smrg case $deplib in 926165d490d0Smrg *.la) 926265d490d0Smrg func_basename "$deplib" 926365d490d0Smrg name="$func_basename_result" 926465d490d0Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 926565d490d0Smrg test -z "$libdir" && \ 926665d490d0Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 926765d490d0Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 926865d490d0Smrg ;; 926965d490d0Smrg -L*) 927065d490d0Smrg func_stripname -L '' "$deplib" 927165d490d0Smrg func_replace_sysroot "$func_stripname_result" 927265d490d0Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 927365d490d0Smrg ;; 927465d490d0Smrg -R*) 927565d490d0Smrg func_stripname -R '' "$deplib" 927665d490d0Smrg func_replace_sysroot "$func_stripname_result" 927765d490d0Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 927865d490d0Smrg ;; 927965d490d0Smrg *) func_append newdependency_libs " $deplib" ;; 928065d490d0Smrg esac 928165d490d0Smrg done 928265d490d0Smrg dependency_libs="$newdependency_libs" 928365d490d0Smrg newdlfiles= 928465d490d0Smrg 928565d490d0Smrg for lib in $dlfiles; do 928665d490d0Smrg case $lib in 928765d490d0Smrg *.la) 928865d490d0Smrg func_basename "$lib" 928965d490d0Smrg name="$func_basename_result" 929065d490d0Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 929165d490d0Smrg test -z "$libdir" && \ 929265d490d0Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 929365d490d0Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 929465d490d0Smrg ;; 929565d490d0Smrg *) func_append newdlfiles " $lib" ;; 929665d490d0Smrg esac 929765d490d0Smrg done 929865d490d0Smrg dlfiles="$newdlfiles" 929965d490d0Smrg newdlprefiles= 930065d490d0Smrg for lib in $dlprefiles; do 930165d490d0Smrg case $lib in 930265d490d0Smrg *.la) 930365d490d0Smrg # Only pass preopened files to the pseudo-archive (for 930465d490d0Smrg # eventual linking with the app. that links it) if we 930565d490d0Smrg # didn't already link the preopened objects directly into 930665d490d0Smrg # the library: 930765d490d0Smrg func_basename "$lib" 930865d490d0Smrg name="$func_basename_result" 930965d490d0Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 931065d490d0Smrg test -z "$libdir" && \ 931165d490d0Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 931265d490d0Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 931365d490d0Smrg ;; 931465d490d0Smrg esac 931565d490d0Smrg done 931665d490d0Smrg dlprefiles="$newdlprefiles" 931765d490d0Smrg else 931865d490d0Smrg newdlfiles= 931965d490d0Smrg for lib in $dlfiles; do 932065d490d0Smrg case $lib in 932165d490d0Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 932265d490d0Smrg *) abs=`pwd`"/$lib" ;; 932365d490d0Smrg esac 932465d490d0Smrg func_append newdlfiles " $abs" 932565d490d0Smrg done 932665d490d0Smrg dlfiles="$newdlfiles" 932765d490d0Smrg newdlprefiles= 932865d490d0Smrg for lib in $dlprefiles; do 932965d490d0Smrg case $lib in 933065d490d0Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 933165d490d0Smrg *) abs=`pwd`"/$lib" ;; 933265d490d0Smrg esac 933365d490d0Smrg func_append newdlprefiles " $abs" 933465d490d0Smrg done 933565d490d0Smrg dlprefiles="$newdlprefiles" 933665d490d0Smrg fi 933765d490d0Smrg $RM $output 933865d490d0Smrg # place dlname in correct position for cygwin 933965d490d0Smrg # In fact, it would be nice if we could use this code for all target 934065d490d0Smrg # systems that can't hard-code library paths into their executables 934165d490d0Smrg # and that have no shared library path variable independent of PATH, 934265d490d0Smrg # but it turns out we can't easily determine that from inspecting 934365d490d0Smrg # libtool variables, so we have to hard-code the OSs to which it 934465d490d0Smrg # applies here; at the moment, that means platforms that use the PE 934565d490d0Smrg # object format with DLL files. See the long comment at the top of 934665d490d0Smrg # tests/bindir.at for full details. 934765d490d0Smrg tdlname=$dlname 934865d490d0Smrg case $host,$output,$installed,$module,$dlname in 934965d490d0Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 935065d490d0Smrg # If a -bindir argument was supplied, place the dll there. 935165d490d0Smrg if test "x$bindir" != x ; 935265d490d0Smrg then 935365d490d0Smrg func_relative_path "$install_libdir" "$bindir" 935465d490d0Smrg tdlname=$func_relative_path_result$dlname 935565d490d0Smrg else 935665d490d0Smrg # Otherwise fall back on heuristic. 935765d490d0Smrg tdlname=../bin/$dlname 935865d490d0Smrg fi 935965d490d0Smrg ;; 936065d490d0Smrg esac 936165d490d0Smrg $ECHO > $output "\ 936265d490d0Smrg# $outputname - a libtool library file 936365d490d0Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 936465d490d0Smrg# 936565d490d0Smrg# Please DO NOT delete this file! 936665d490d0Smrg# It is necessary for linking the library. 9367e4da13eeSmacallan 936865d490d0Smrg# The name that we can dlopen(3). 936965d490d0Smrgdlname='$tdlname' 9370e4da13eeSmacallan 937165d490d0Smrg# Names of this library. 937265d490d0Smrglibrary_names='$library_names' 9373e4da13eeSmacallan 937465d490d0Smrg# The name of the static archive. 937565d490d0Smrgold_library='$old_library' 9376e4da13eeSmacallan 937765d490d0Smrg# Linker flags that can not go in dependency_libs. 937865d490d0Smrginherited_linker_flags='$new_inherited_linker_flags' 9379e4da13eeSmacallan 938065d490d0Smrg# Libraries that this one depends upon. 938165d490d0Smrgdependency_libs='$dependency_libs' 9382e4da13eeSmacallan 938365d490d0Smrg# Names of additional weak libraries provided by this library 938465d490d0Smrgweak_library_names='$weak_libs' 9385e4da13eeSmacallan 938665d490d0Smrg# Version information for $libname. 938765d490d0Smrgcurrent=$current 938865d490d0Smrgage=$age 938965d490d0Smrgrevision=$revision 9390e4da13eeSmacallan 939165d490d0Smrg# Is this an already installed library? 939265d490d0Smrginstalled=$installed 9393e4da13eeSmacallan 939465d490d0Smrg# Should we warn about portability when linking against -modules? 939565d490d0Smrgshouldnotlink=$module 9396e4da13eeSmacallan 939765d490d0Smrg# Files to dlopen/dlpreopen 939865d490d0Smrgdlopen='$dlfiles' 939965d490d0Smrgdlpreopen='$dlprefiles' 9400e4da13eeSmacallan 940165d490d0Smrg# Directory that this library needs to be installed in: 940265d490d0Smrglibdir='$install_libdir'" 940365d490d0Smrg if test "$installed" = no && test "$need_relink" = yes; then 940465d490d0Smrg $ECHO >> $output "\ 940565d490d0Smrgrelink_command=\"$relink_command\"" 940665d490d0Smrg fi 940765d490d0Smrg done 940865d490d0Smrg } 9409e4da13eeSmacallan 941065d490d0Smrg # Do a symbolic link so that the libtool archive can be found in 941165d490d0Smrg # LD_LIBRARY_PATH before the program is installed. 941265d490d0Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 941365d490d0Smrg ;; 941465d490d0Smrg esac 941565d490d0Smrg exit $EXIT_SUCCESS 941665d490d0Smrg} 9417e4da13eeSmacallan 941865d490d0Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 941965d490d0Smrg func_mode_link ${1+"$@"} 9420e4da13eeSmacallan 9421e4da13eeSmacallan 942265d490d0Smrg# func_mode_uninstall arg... 942365d490d0Smrgfunc_mode_uninstall () 942465d490d0Smrg{ 942565d490d0Smrg $opt_debug 942665d490d0Smrg RM="$nonopt" 9427e4da13eeSmacallan files= 9428e4da13eeSmacallan rmforce= 9429e4da13eeSmacallan exit_status=0 9430e4da13eeSmacallan 9431e4da13eeSmacallan # This variable tells wrapper scripts just to set variables rather 9432e4da13eeSmacallan # than running their programs. 9433e4da13eeSmacallan libtool_install_magic="$magic" 9434e4da13eeSmacallan 9435e4da13eeSmacallan for arg 9436e4da13eeSmacallan do 9437e4da13eeSmacallan case $arg in 943865d490d0Smrg -f) func_append RM " $arg"; rmforce=yes ;; 943965d490d0Smrg -*) func_append RM " $arg" ;; 944065d490d0Smrg *) func_append files " $arg" ;; 9441e4da13eeSmacallan esac 9442e4da13eeSmacallan done 9443e4da13eeSmacallan 944465d490d0Smrg test -z "$RM" && \ 944565d490d0Smrg func_fatal_help "you must specify an RM program" 9446e4da13eeSmacallan 9447e4da13eeSmacallan rmdirs= 9448e4da13eeSmacallan 9449e4da13eeSmacallan for file in $files; do 945065d490d0Smrg func_dirname "$file" "" "." 945165d490d0Smrg dir="$func_dirname_result" 945265d490d0Smrg if test "X$dir" = X.; then 945365d490d0Smrg odir="$objdir" 9454e4da13eeSmacallan else 945565d490d0Smrg odir="$dir/$objdir" 9456e4da13eeSmacallan fi 945765d490d0Smrg func_basename "$file" 945865d490d0Smrg name="$func_basename_result" 945965d490d0Smrg test "$opt_mode" = uninstall && odir="$dir" 9460e4da13eeSmacallan 946165d490d0Smrg # Remember odir for removal later, being careful to avoid duplicates 946265d490d0Smrg if test "$opt_mode" = clean; then 9463e4da13eeSmacallan case " $rmdirs " in 946465d490d0Smrg *" $odir "*) ;; 946565d490d0Smrg *) func_append rmdirs " $odir" ;; 9466e4da13eeSmacallan esac 9467e4da13eeSmacallan fi 9468e4da13eeSmacallan 9469e4da13eeSmacallan # Don't error if the file doesn't exist and rm -f was used. 947065d490d0Smrg if { test -L "$file"; } >/dev/null 2>&1 || 947165d490d0Smrg { test -h "$file"; } >/dev/null 2>&1 || 947265d490d0Smrg test -f "$file"; then 9473e4da13eeSmacallan : 9474e4da13eeSmacallan elif test -d "$file"; then 9475e4da13eeSmacallan exit_status=1 9476e4da13eeSmacallan continue 9477e4da13eeSmacallan elif test "$rmforce" = yes; then 9478e4da13eeSmacallan continue 9479e4da13eeSmacallan fi 9480e4da13eeSmacallan 9481e4da13eeSmacallan rmfiles="$file" 9482e4da13eeSmacallan 9483e4da13eeSmacallan case $name in 9484e4da13eeSmacallan *.la) 9485e4da13eeSmacallan # Possibly a libtool archive, so verify it. 948665d490d0Smrg if func_lalib_p "$file"; then 948765d490d0Smrg func_source $dir/$name 9488e4da13eeSmacallan 9489e4da13eeSmacallan # Delete the libtool libraries and symlinks. 9490e4da13eeSmacallan for n in $library_names; do 949165d490d0Smrg func_append rmfiles " $odir/$n" 9492e4da13eeSmacallan done 949365d490d0Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 9494e4da13eeSmacallan 949565d490d0Smrg case "$opt_mode" in 9496e4da13eeSmacallan clean) 949765d490d0Smrg case " $library_names " in 9498e4da13eeSmacallan *" $dlname "*) ;; 949965d490d0Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 9500e4da13eeSmacallan esac 950165d490d0Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 9502e4da13eeSmacallan ;; 9503e4da13eeSmacallan uninstall) 9504e4da13eeSmacallan if test -n "$library_names"; then 9505e4da13eeSmacallan # Do each command in the postuninstall commands. 950665d490d0Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9507e4da13eeSmacallan fi 9508e4da13eeSmacallan 9509e4da13eeSmacallan if test -n "$old_library"; then 9510e4da13eeSmacallan # Do each command in the old_postuninstall commands. 951165d490d0Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9512e4da13eeSmacallan fi 9513e4da13eeSmacallan # FIXME: should reinstall the best remaining shared library. 9514e4da13eeSmacallan ;; 9515e4da13eeSmacallan esac 9516e4da13eeSmacallan fi 9517e4da13eeSmacallan ;; 9518e4da13eeSmacallan 9519e4da13eeSmacallan *.lo) 9520e4da13eeSmacallan # Possibly a libtool object, so verify it. 952165d490d0Smrg if func_lalib_p "$file"; then 9522e4da13eeSmacallan 9523e4da13eeSmacallan # Read the .lo file 952465d490d0Smrg func_source $dir/$name 9525e4da13eeSmacallan 9526e4da13eeSmacallan # Add PIC object to the list of files to remove. 952765d490d0Smrg if test -n "$pic_object" && 952865d490d0Smrg test "$pic_object" != none; then 952965d490d0Smrg func_append rmfiles " $dir/$pic_object" 9530e4da13eeSmacallan fi 9531e4da13eeSmacallan 9532e4da13eeSmacallan # Add non-PIC object to the list of files to remove. 953365d490d0Smrg if test -n "$non_pic_object" && 953465d490d0Smrg test "$non_pic_object" != none; then 953565d490d0Smrg func_append rmfiles " $dir/$non_pic_object" 9536e4da13eeSmacallan fi 9537e4da13eeSmacallan fi 9538e4da13eeSmacallan ;; 9539e4da13eeSmacallan 9540e4da13eeSmacallan *) 954165d490d0Smrg if test "$opt_mode" = clean ; then 9542e4da13eeSmacallan noexename=$name 9543e4da13eeSmacallan case $file in 9544e4da13eeSmacallan *.exe) 954565d490d0Smrg func_stripname '' '.exe' "$file" 954665d490d0Smrg file=$func_stripname_result 954765d490d0Smrg func_stripname '' '.exe' "$name" 954865d490d0Smrg noexename=$func_stripname_result 9549e4da13eeSmacallan # $file with .exe has already been added to rmfiles, 9550e4da13eeSmacallan # add $file without .exe 955165d490d0Smrg func_append rmfiles " $file" 9552e4da13eeSmacallan ;; 9553e4da13eeSmacallan esac 9554e4da13eeSmacallan # Do a test to see if this is a libtool program. 955565d490d0Smrg if func_ltwrapper_p "$file"; then 955665d490d0Smrg if func_ltwrapper_executable_p "$file"; then 955765d490d0Smrg func_ltwrapper_scriptname "$file" 955865d490d0Smrg relink_command= 955965d490d0Smrg func_source $func_ltwrapper_scriptname_result 956065d490d0Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 956165d490d0Smrg else 956265d490d0Smrg relink_command= 956365d490d0Smrg func_source $dir/$noexename 956465d490d0Smrg fi 9565e4da13eeSmacallan 9566e4da13eeSmacallan # note $name still contains .exe if it was in $file originally 9567e4da13eeSmacallan # as does the version of $file that was added into $rmfiles 956865d490d0Smrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9569e4da13eeSmacallan if test "$fast_install" = yes && test -n "$relink_command"; then 957065d490d0Smrg func_append rmfiles " $odir/lt-$name" 9571e4da13eeSmacallan fi 9572e4da13eeSmacallan if test "X$noexename" != "X$name" ; then 957365d490d0Smrg func_append rmfiles " $odir/lt-${noexename}.c" 9574e4da13eeSmacallan fi 9575e4da13eeSmacallan fi 9576e4da13eeSmacallan fi 9577e4da13eeSmacallan ;; 9578e4da13eeSmacallan esac 957965d490d0Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 9580e4da13eeSmacallan done 9581e4da13eeSmacallan 9582e4da13eeSmacallan # Try to remove the ${objdir}s in the directories where we deleted files 9583e4da13eeSmacallan for dir in $rmdirs; do 9584e4da13eeSmacallan if test -d "$dir"; then 958565d490d0Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 9586e4da13eeSmacallan fi 9587e4da13eeSmacallan done 9588e4da13eeSmacallan 9589e4da13eeSmacallan exit $exit_status 959065d490d0Smrg} 9591e4da13eeSmacallan 959265d490d0Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 959365d490d0Smrg func_mode_uninstall ${1+"$@"} 9594e4da13eeSmacallan 959565d490d0Smrgtest -z "$opt_mode" && { 959665d490d0Smrg help="$generic_help" 959765d490d0Smrg func_fatal_help "you must specify a MODE" 959865d490d0Smrg} 959965d490d0Smrg 960065d490d0Smrgtest -z "$exec_cmd" && \ 960165d490d0Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 9602e4da13eeSmacallan 9603e4da13eeSmacallanif test -n "$exec_cmd"; then 960465d490d0Smrg eval exec "$exec_cmd" 9605e4da13eeSmacallan exit $EXIT_FAILURE 9606e4da13eeSmacallanfi 9607e4da13eeSmacallan 960865d490d0Smrgexit $exit_status 9609e4da13eeSmacallan 9610e4da13eeSmacallan 9611e4da13eeSmacallan# The TAGs below are defined such that we never get into a situation 9612e4da13eeSmacallan# in which we disable both kinds of libraries. Given conflicting 9613e4da13eeSmacallan# choices, we go for a static library, that is the most portable, 9614e4da13eeSmacallan# since we can't tell whether shared libraries were disabled because 9615e4da13eeSmacallan# the user asked for that or because the platform doesn't support 9616e4da13eeSmacallan# them. This is particularly important on AIX, because we don't 9617e4da13eeSmacallan# support having both static and shared libraries enabled at the same 9618e4da13eeSmacallan# time on that platform, so we default to a shared-only configuration. 9619e4da13eeSmacallan# If a disable-shared tag is given, we'll fallback to a static-only 9620e4da13eeSmacallan# configuration. But we'll never go from static-only to shared-only. 9621e4da13eeSmacallan 9622e4da13eeSmacallan# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 962365d490d0Smrgbuild_libtool_libs=no 962465d490d0Smrgbuild_old_libs=yes 9625e4da13eeSmacallan# ### END LIBTOOL TAG CONFIG: disable-shared 9626e4da13eeSmacallan 9627e4da13eeSmacallan# ### BEGIN LIBTOOL TAG CONFIG: disable-static 962865d490d0Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 9629e4da13eeSmacallan# ### END LIBTOOL TAG CONFIG: disable-static 9630e4da13eeSmacallan 9631e4da13eeSmacallan# Local Variables: 9632e4da13eeSmacallan# mode:shell-script 9633e4da13eeSmacallan# sh-indentation:2 9634e4da13eeSmacallan# End: 963565d490d0Smrg# vi:sw=2 963665d490d0Smrg 9637