ltmain.sh revision 67ab2ff2
1f05b35a2Smrg 267ab2ff2Smrg# libtool (GNU libtool) 2.4 3f05b35a2Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 4f05b35a2Smrg 549e108a1Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 649e108a1Smrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 7f05b35a2Smrg# This is free software; see the source for copying conditions. There is NO 8f05b35a2Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9f05b35a2Smrg 10f05b35a2Smrg# GNU Libtool is free software; you can redistribute it and/or modify 11e0963edeSmrg# it under the terms of the GNU General Public License as published by 12e0963edeSmrg# the Free Software Foundation; either version 2 of the License, or 13e0963edeSmrg# (at your option) any later version. 14e0963edeSmrg# 15f05b35a2Smrg# As a special exception to the GNU General Public License, 16f05b35a2Smrg# if you distribute this file as part of a program or library that 17f05b35a2Smrg# is built using GNU Libtool, you may include this file under the 18f05b35a2Smrg# same distribution terms that you use for the rest of that program. 19f05b35a2Smrg# 20f05b35a2Smrg# GNU Libtool is distributed in the hope that it will be useful, but 21e0963edeSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 22e0963edeSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23e0963edeSmrg# General Public License for more details. 24e0963edeSmrg# 25e0963edeSmrg# You should have received a copy of the GNU General Public License 26f05b35a2Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 27f05b35a2Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 28f05b35a2Smrg# or obtained by writing to the Free Software Foundation, Inc., 29f05b35a2Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 30e0963edeSmrg 31f05b35a2Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 32f05b35a2Smrg# 33f05b35a2Smrg# Provide generalized library-building support services. 34f05b35a2Smrg# 3549e108a1Smrg# --config show all configuration variables 3649e108a1Smrg# --debug enable verbose shell tracing 3749e108a1Smrg# -n, --dry-run display commands without modifying any files 3849e108a1Smrg# --features display basic configuration information and exit 3949e108a1Smrg# --mode=MODE use operation mode MODE 4049e108a1Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 4149e108a1Smrg# --quiet, --silent don't print informational messages 4249e108a1Smrg# --no-quiet, --no-silent 4349e108a1Smrg# print informational messages (default) 4449e108a1Smrg# --tag=TAG use configuration variables from tag TAG 4549e108a1Smrg# -v, --verbose print more informational messages than default 4649e108a1Smrg# --no-verbose don't print the extra informational messages 4749e108a1Smrg# --version print version information 4849e108a1Smrg# -h, --help, --help-all print short, long, or detailed help message 49f05b35a2Smrg# 50f05b35a2Smrg# MODE must be one of the following: 51f05b35a2Smrg# 5249e108a1Smrg# clean remove files from the build directory 5349e108a1Smrg# compile compile a source file into a libtool object 5449e108a1Smrg# execute automatically set library path, then run a program 5549e108a1Smrg# finish complete the installation of libtool libraries 5649e108a1Smrg# install install libraries or executables 5749e108a1Smrg# link create a library or an executable 5849e108a1Smrg# uninstall remove libraries from an installed directory 59f05b35a2Smrg# 6049e108a1Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 6149e108a1Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 62f05b35a2Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 63f05b35a2Smrg# 64f05b35a2Smrg# When reporting a bug, please describe a test case to reproduce it and 65f05b35a2Smrg# include the following information: 66f05b35a2Smrg# 6749e108a1Smrg# host-triplet: $host 6849e108a1Smrg# shell: $SHELL 6949e108a1Smrg# compiler: $LTCC 7049e108a1Smrg# compiler flags: $LTCFLAGS 7149e108a1Smrg# linker: $LD (gnu? $with_gnu_ld) 7267ab2ff2Smrg# $progname: (GNU libtool) 2.4 7349e108a1Smrg# automake: $automake_version 7449e108a1Smrg# autoconf: $autoconf_version 75f05b35a2Smrg# 76f05b35a2Smrg# Report bugs to <bug-libtool@gnu.org>. 7767ab2ff2Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 7867ab2ff2Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 79e0963edeSmrg 8049e108a1SmrgPROGRAM=libtool 81e0963edeSmrgPACKAGE=libtool 8267ab2ff2SmrgVERSION=2.4 83f05b35a2SmrgTIMESTAMP="" 8467ab2ff2Smrgpackage_revision=1.3293 85e0963edeSmrg 86f05b35a2Smrg# Be Bourne compatible 87e0963edeSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 88e0963edeSmrg emulate sh 89e0963edeSmrg NULLCMD=: 90e0963edeSmrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 91e0963edeSmrg # is contrary to our usage. Disable this feature. 92e0963edeSmrg alias -g '${1+"$@"}'='"$@"' 93e0963edeSmrg setopt NO_GLOB_SUBST 94e0963edeSmrgelse 95e0963edeSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 96e0963edeSmrgfi 97e0963edeSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 98e0963edeSmrgDUALCASE=1; export DUALCASE # for MKS sh 99e0963edeSmrg 10049e108a1Smrg# A function that is used when there is no print builtin or printf. 10149e108a1Smrgfunc_fallback_echo () 10249e108a1Smrg{ 10349e108a1Smrg eval 'cat <<_LTECHO_EOF 10449e108a1Smrg$1 10549e108a1Smrg_LTECHO_EOF' 10649e108a1Smrg} 10749e108a1Smrg 108f05b35a2Smrg# NLS nuisances: We save the old values to restore during execute mode. 109f05b35a2Smrglt_user_locale= 110f05b35a2Smrglt_safe_locale= 111f05b35a2Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 112e0963edeSmrgdo 113e0963edeSmrg eval "if test \"\${$lt_var+set}\" = set; then 114f05b35a2Smrg save_$lt_var=\$$lt_var 115f05b35a2Smrg $lt_var=C 116e0963edeSmrg export $lt_var 117f05b35a2Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 118f05b35a2Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 119e0963edeSmrg fi" 120e0963edeSmrgdone 12149e108a1SmrgLC_ALL=C 12249e108a1SmrgLANGUAGE=C 12349e108a1Smrgexport LANGUAGE LC_ALL 124e0963edeSmrg 125f05b35a2Smrg$lt_unset CDPATH 126f05b35a2Smrg 127f05b35a2Smrg 12849e108a1Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 12949e108a1Smrg# is ksh but when the shell is invoked as "sh" and the current value of 13049e108a1Smrg# the _XPG environment variable is not equal to 1 (one), the special 13149e108a1Smrg# positional parameter $0, within a function call, is the name of the 13249e108a1Smrg# function. 13349e108a1Smrgprogpath="$0" 134f05b35a2Smrg 135f05b35a2Smrg 136f05b35a2Smrg 137f05b35a2Smrg: ${CP="cp -f"} 13849e108a1Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 13949e108a1Smrg: ${EGREP="grep -E"} 14049e108a1Smrg: ${FGREP="grep -F"} 14149e108a1Smrg: ${GREP="grep"} 142f05b35a2Smrg: ${LN_S="ln -s"} 143f05b35a2Smrg: ${MAKE="make"} 144f05b35a2Smrg: ${MKDIR="mkdir"} 145f05b35a2Smrg: ${MV="mv -f"} 146f05b35a2Smrg: ${RM="rm -f"} 14749e108a1Smrg: ${SED="sed"} 148f05b35a2Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 149f05b35a2Smrg: ${Xsed="$SED -e 1s/^X//"} 150f05b35a2Smrg 151f05b35a2Smrg# Global variables: 152f05b35a2SmrgEXIT_SUCCESS=0 153f05b35a2SmrgEXIT_FAILURE=1 154f05b35a2SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 155f05b35a2SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 156f05b35a2Smrg 157f05b35a2Smrgexit_status=$EXIT_SUCCESS 158f05b35a2Smrg 159e0963edeSmrg# Make sure IFS has a sensible default 160e0963edeSmrglt_nl=' 161e0963edeSmrg' 162e0963edeSmrgIFS=" $lt_nl" 163e0963edeSmrg 164f05b35a2Smrgdirname="s,/[^/]*$,," 165f05b35a2Smrgbasename="s,^.*/,," 166f05b35a2Smrg 16767ab2ff2Smrg# func_dirname file append nondir_replacement 16867ab2ff2Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 16967ab2ff2Smrg# otherwise set result to NONDIR_REPLACEMENT. 17067ab2ff2Smrgfunc_dirname () 17167ab2ff2Smrg{ 17267ab2ff2Smrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 17367ab2ff2Smrg if test "X$func_dirname_result" = "X${1}"; then 17467ab2ff2Smrg func_dirname_result="${3}" 17567ab2ff2Smrg else 17667ab2ff2Smrg func_dirname_result="$func_dirname_result${2}" 17767ab2ff2Smrg fi 17867ab2ff2Smrg} # func_dirname may be replaced by extended shell implementation 17967ab2ff2Smrg 18067ab2ff2Smrg 18167ab2ff2Smrg# func_basename file 18267ab2ff2Smrgfunc_basename () 18367ab2ff2Smrg{ 18467ab2ff2Smrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 18567ab2ff2Smrg} # func_basename may be replaced by extended shell implementation 18667ab2ff2Smrg 18767ab2ff2Smrg 188f05b35a2Smrg# func_dirname_and_basename file append nondir_replacement 189f05b35a2Smrg# perform func_basename and func_dirname in a single function 190f05b35a2Smrg# call: 191f05b35a2Smrg# dirname: Compute the dirname of FILE. If nonempty, 192f05b35a2Smrg# add APPEND to the result, otherwise set result 193f05b35a2Smrg# to NONDIR_REPLACEMENT. 194f05b35a2Smrg# value returned in "$func_dirname_result" 195f05b35a2Smrg# basename: Compute filename of FILE. 196f05b35a2Smrg# value retuned in "$func_basename_result" 197f05b35a2Smrg# Implementation must be kept synchronized with func_dirname 198f05b35a2Smrg# and func_basename. For efficiency, we do not delegate to 199f05b35a2Smrg# those functions but instead duplicate the functionality here. 200f05b35a2Smrgfunc_dirname_and_basename () 201f05b35a2Smrg{ 20267ab2ff2Smrg # Extract subdirectory from the argument. 20367ab2ff2Smrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 20467ab2ff2Smrg if test "X$func_dirname_result" = "X${1}"; then 20567ab2ff2Smrg func_dirname_result="${3}" 20667ab2ff2Smrg else 20767ab2ff2Smrg func_dirname_result="$func_dirname_result${2}" 20867ab2ff2Smrg fi 20967ab2ff2Smrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 21067ab2ff2Smrg} # func_dirname_and_basename may be replaced by extended shell implementation 21167ab2ff2Smrg 21267ab2ff2Smrg 21367ab2ff2Smrg# func_stripname prefix suffix name 21467ab2ff2Smrg# strip PREFIX and SUFFIX off of NAME. 21567ab2ff2Smrg# PREFIX and SUFFIX must not contain globbing or regex special 21667ab2ff2Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 21767ab2ff2Smrg# dot (in which case that matches only a dot). 21867ab2ff2Smrg# func_strip_suffix prefix name 21967ab2ff2Smrgfunc_stripname () 22067ab2ff2Smrg{ 22167ab2ff2Smrg case ${2} in 22267ab2ff2Smrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 22367ab2ff2Smrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 22467ab2ff2Smrg esac 22567ab2ff2Smrg} # func_stripname may be replaced by extended shell implementation 226e0963edeSmrg 227f05b35a2Smrg 22849e108a1Smrg# These SED scripts presuppose an absolute path with a trailing slash. 22949e108a1Smrgpathcar='s,^/\([^/]*\).*$,\1,' 23049e108a1Smrgpathcdr='s,^/[^/]*,,' 23149e108a1Smrgremovedotparts=':dotsl 23249e108a1Smrg s@/\./@/@g 23349e108a1Smrg t dotsl 23449e108a1Smrg s,/\.$,/,' 23549e108a1Smrgcollapseslashes='s@/\{1,\}@/@g' 23649e108a1Smrgfinalslash='s,/*$,/,' 23749e108a1Smrg 23849e108a1Smrg# func_normal_abspath PATH 23949e108a1Smrg# Remove doubled-up and trailing slashes, "." path components, 24049e108a1Smrg# and cancel out any ".." path components in PATH after making 24149e108a1Smrg# it an absolute path. 24249e108a1Smrg# value returned in "$func_normal_abspath_result" 24349e108a1Smrgfunc_normal_abspath () 24449e108a1Smrg{ 24549e108a1Smrg # Start from root dir and reassemble the path. 24649e108a1Smrg func_normal_abspath_result= 24749e108a1Smrg func_normal_abspath_tpath=$1 24849e108a1Smrg func_normal_abspath_altnamespace= 24949e108a1Smrg case $func_normal_abspath_tpath in 25049e108a1Smrg "") 25149e108a1Smrg # Empty path, that just means $cwd. 25249e108a1Smrg func_stripname '' '/' "`pwd`" 25349e108a1Smrg func_normal_abspath_result=$func_stripname_result 25449e108a1Smrg return 25549e108a1Smrg ;; 25649e108a1Smrg # The next three entries are used to spot a run of precisely 25749e108a1Smrg # two leading slashes without using negated character classes; 25849e108a1Smrg # we take advantage of case's first-match behaviour. 25949e108a1Smrg ///*) 26049e108a1Smrg # Unusual form of absolute path, do nothing. 26149e108a1Smrg ;; 26249e108a1Smrg //*) 26349e108a1Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 26449e108a1Smrg # and for example Cygwin uses it to access remote file shares 26549e108a1Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 26649e108a1Smrg func_normal_abspath_altnamespace=/ 26749e108a1Smrg ;; 26849e108a1Smrg /*) 26949e108a1Smrg # Absolute path, do nothing. 27049e108a1Smrg ;; 27149e108a1Smrg *) 27249e108a1Smrg # Relative path, prepend $cwd. 27349e108a1Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 27449e108a1Smrg ;; 27549e108a1Smrg esac 27649e108a1Smrg # Cancel out all the simple stuff to save iterations. We also want 27749e108a1Smrg # the path to end with a slash for ease of parsing, so make sure 27849e108a1Smrg # there is one (and only one) here. 27949e108a1Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 28049e108a1Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 28149e108a1Smrg while :; do 28249e108a1Smrg # Processed it all yet? 28349e108a1Smrg if test "$func_normal_abspath_tpath" = / ; then 28449e108a1Smrg # If we ascended to the root using ".." the result may be empty now. 28549e108a1Smrg if test -z "$func_normal_abspath_result" ; then 28649e108a1Smrg func_normal_abspath_result=/ 28749e108a1Smrg fi 28849e108a1Smrg break 28949e108a1Smrg fi 29049e108a1Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 29149e108a1Smrg -e "$pathcar"` 29249e108a1Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 29349e108a1Smrg -e "$pathcdr"` 29449e108a1Smrg # Figure out what to do with it 29549e108a1Smrg case $func_normal_abspath_tcomponent in 29649e108a1Smrg "") 29749e108a1Smrg # Trailing empty path component, ignore it. 29849e108a1Smrg ;; 29949e108a1Smrg ..) 30049e108a1Smrg # Parent dir; strip last assembled component from result. 30149e108a1Smrg func_dirname "$func_normal_abspath_result" 30249e108a1Smrg func_normal_abspath_result=$func_dirname_result 30349e108a1Smrg ;; 30449e108a1Smrg *) 30549e108a1Smrg # Actual path component, append it. 30649e108a1Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 30749e108a1Smrg ;; 30849e108a1Smrg esac 30949e108a1Smrg done 31049e108a1Smrg # Restore leading double-slash if one was found on entry. 31149e108a1Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 31249e108a1Smrg} 31349e108a1Smrg 31449e108a1Smrg# func_relative_path SRCDIR DSTDIR 31549e108a1Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 31649e108a1Smrg# slash if non-empty, suitable for immediately appending a filename 31749e108a1Smrg# without needing to append a separator. 31849e108a1Smrg# value returned in "$func_relative_path_result" 31949e108a1Smrgfunc_relative_path () 32049e108a1Smrg{ 32149e108a1Smrg func_relative_path_result= 32249e108a1Smrg func_normal_abspath "$1" 32349e108a1Smrg func_relative_path_tlibdir=$func_normal_abspath_result 32449e108a1Smrg func_normal_abspath "$2" 32549e108a1Smrg func_relative_path_tbindir=$func_normal_abspath_result 32649e108a1Smrg 32749e108a1Smrg # Ascend the tree starting from libdir 32849e108a1Smrg while :; do 32949e108a1Smrg # check if we have found a prefix of bindir 33049e108a1Smrg case $func_relative_path_tbindir in 33149e108a1Smrg $func_relative_path_tlibdir) 33249e108a1Smrg # found an exact match 33349e108a1Smrg func_relative_path_tcancelled= 33449e108a1Smrg break 33549e108a1Smrg ;; 33649e108a1Smrg $func_relative_path_tlibdir*) 33749e108a1Smrg # found a matching prefix 33849e108a1Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 33949e108a1Smrg func_relative_path_tcancelled=$func_stripname_result 34049e108a1Smrg if test -z "$func_relative_path_result"; then 34149e108a1Smrg func_relative_path_result=. 34249e108a1Smrg fi 34349e108a1Smrg break 34449e108a1Smrg ;; 34549e108a1Smrg *) 34649e108a1Smrg func_dirname $func_relative_path_tlibdir 34749e108a1Smrg func_relative_path_tlibdir=${func_dirname_result} 34849e108a1Smrg if test "x$func_relative_path_tlibdir" = x ; then 34949e108a1Smrg # Have to descend all the way to the root! 35049e108a1Smrg func_relative_path_result=../$func_relative_path_result 35149e108a1Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 35249e108a1Smrg break 35349e108a1Smrg fi 35449e108a1Smrg func_relative_path_result=../$func_relative_path_result 35549e108a1Smrg ;; 35649e108a1Smrg esac 35749e108a1Smrg done 35849e108a1Smrg 35949e108a1Smrg # Now calculate path; take care to avoid doubling-up slashes. 36049e108a1Smrg func_stripname '' '/' "$func_relative_path_result" 36149e108a1Smrg func_relative_path_result=$func_stripname_result 36249e108a1Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 36349e108a1Smrg if test "x$func_stripname_result" != x ; then 36449e108a1Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 36549e108a1Smrg fi 36649e108a1Smrg 36749e108a1Smrg # Normalisation. If bindir is libdir, return empty string, 36849e108a1Smrg # else relative path ending with a slash; either way, target 36949e108a1Smrg # file name can be directly appended. 37049e108a1Smrg if test ! -z "$func_relative_path_result"; then 37149e108a1Smrg func_stripname './' '' "$func_relative_path_result/" 37249e108a1Smrg func_relative_path_result=$func_stripname_result 37349e108a1Smrg fi 37449e108a1Smrg} 375f05b35a2Smrg 376f05b35a2Smrg# The name of this program: 377f05b35a2Smrgfunc_dirname_and_basename "$progpath" 378f05b35a2Smrgprogname=$func_basename_result 379f05b35a2Smrg 380f05b35a2Smrg# Make sure we have an absolute path for reexecution: 381f05b35a2Smrgcase $progpath in 382f05b35a2Smrg [\\/]*|[A-Za-z]:\\*) ;; 383f05b35a2Smrg *[\\/]*) 384f05b35a2Smrg progdir=$func_dirname_result 385f05b35a2Smrg progdir=`cd "$progdir" && pwd` 386f05b35a2Smrg progpath="$progdir/$progname" 387f05b35a2Smrg ;; 388f05b35a2Smrg *) 389f05b35a2Smrg save_IFS="$IFS" 390f05b35a2Smrg IFS=: 391f05b35a2Smrg for progdir in $PATH; do 392f05b35a2Smrg IFS="$save_IFS" 393f05b35a2Smrg test -x "$progdir/$progname" && break 394f05b35a2Smrg done 395f05b35a2Smrg IFS="$save_IFS" 396f05b35a2Smrg test -n "$progdir" || progdir=`pwd` 397f05b35a2Smrg progpath="$progdir/$progname" 398f05b35a2Smrg ;; 399f05b35a2Smrgesac 400f05b35a2Smrg 401f05b35a2Smrg# Sed substitution that helps us do robust quoting. It backslashifies 402f05b35a2Smrg# metacharacters that are still active within double-quoted strings. 403f05b35a2SmrgXsed="${SED}"' -e 1s/^X//' 404f05b35a2Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 405f05b35a2Smrg 406f05b35a2Smrg# Same as above, but do not quote variable references. 407f05b35a2Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 408f05b35a2Smrg 40967ab2ff2Smrg# Sed substitution that turns a string into a regex matching for the 41067ab2ff2Smrg# string literally. 41167ab2ff2Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 41267ab2ff2Smrg 41367ab2ff2Smrg# Sed substitution that converts a w32 file name or path 41467ab2ff2Smrg# which contains forward slashes, into one that contains 41567ab2ff2Smrg# (escaped) backslashes. A very naive implementation. 41667ab2ff2Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 41767ab2ff2Smrg 418f05b35a2Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 419f05b35a2Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 420f05b35a2Smrg# in input to double_quote_subst, that '$' was protected from expansion. 421f05b35a2Smrg# Since each input `\' is now two `\'s, look for any number of runs of 422f05b35a2Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 423f05b35a2Smrgbs='\\' 424f05b35a2Smrgbs2='\\\\' 425f05b35a2Smrgbs4='\\\\\\\\' 426f05b35a2Smrgdollar='\$' 427f05b35a2Smrgsed_double_backslash="\ 428f05b35a2Smrg s/$bs4/&\\ 429f05b35a2Smrg/g 430f05b35a2Smrg s/^$bs2$dollar/$bs&/ 431f05b35a2Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 432f05b35a2Smrg s/\n//g" 433f05b35a2Smrg 434f05b35a2Smrg# Standard options: 435f05b35a2Smrgopt_dry_run=false 436f05b35a2Smrgopt_help=false 437f05b35a2Smrgopt_quiet=false 438f05b35a2Smrgopt_verbose=false 439f05b35a2Smrgopt_warning=: 440f05b35a2Smrg 441f05b35a2Smrg# func_echo arg... 442f05b35a2Smrg# Echo program name prefixed message, along with the current mode 443f05b35a2Smrg# name if it has been set yet. 444f05b35a2Smrgfunc_echo () 445f05b35a2Smrg{ 44667ab2ff2Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 447f05b35a2Smrg} 448f05b35a2Smrg 449f05b35a2Smrg# func_verbose arg... 450f05b35a2Smrg# Echo program name prefixed message in verbose mode only. 451f05b35a2Smrgfunc_verbose () 452f05b35a2Smrg{ 453f05b35a2Smrg $opt_verbose && func_echo ${1+"$@"} 454f05b35a2Smrg 455f05b35a2Smrg # A bug in bash halts the script if the last line of a function 456f05b35a2Smrg # fails when set -e is in force, so we need another command to 457f05b35a2Smrg # work around that: 458f05b35a2Smrg : 459f05b35a2Smrg} 460f05b35a2Smrg 46149e108a1Smrg# func_echo_all arg... 46249e108a1Smrg# Invoke $ECHO with all args, space-separated. 46349e108a1Smrgfunc_echo_all () 46449e108a1Smrg{ 46549e108a1Smrg $ECHO "$*" 46649e108a1Smrg} 46749e108a1Smrg 468f05b35a2Smrg# func_error arg... 469f05b35a2Smrg# Echo program name prefixed message to standard error. 470f05b35a2Smrgfunc_error () 471f05b35a2Smrg{ 47267ab2ff2Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 473f05b35a2Smrg} 474f05b35a2Smrg 475f05b35a2Smrg# func_warning arg... 476f05b35a2Smrg# Echo program name prefixed warning message to standard error. 477f05b35a2Smrgfunc_warning () 478f05b35a2Smrg{ 47967ab2ff2Smrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 480f05b35a2Smrg 481f05b35a2Smrg # bash bug again: 482f05b35a2Smrg : 483f05b35a2Smrg} 484f05b35a2Smrg 485f05b35a2Smrg# func_fatal_error arg... 486f05b35a2Smrg# Echo program name prefixed message to standard error, and exit. 487f05b35a2Smrgfunc_fatal_error () 488f05b35a2Smrg{ 489f05b35a2Smrg func_error ${1+"$@"} 490f05b35a2Smrg exit $EXIT_FAILURE 491f05b35a2Smrg} 492f05b35a2Smrg 493f05b35a2Smrg# func_fatal_help arg... 494f05b35a2Smrg# Echo program name prefixed message to standard error, followed by 495f05b35a2Smrg# a help hint, and exit. 496f05b35a2Smrgfunc_fatal_help () 497f05b35a2Smrg{ 498f05b35a2Smrg func_error ${1+"$@"} 499f05b35a2Smrg func_fatal_error "$help" 500f05b35a2Smrg} 501f05b35a2Smrghelp="Try \`$progname --help' for more information." ## default 502f05b35a2Smrg 503f05b35a2Smrg 504f05b35a2Smrg# func_grep expression filename 505f05b35a2Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 506f05b35a2Smrgfunc_grep () 507f05b35a2Smrg{ 508f05b35a2Smrg $GREP "$1" "$2" >/dev/null 2>&1 509f05b35a2Smrg} 510f05b35a2Smrg 511f05b35a2Smrg 512f05b35a2Smrg# func_mkdir_p directory-path 513f05b35a2Smrg# Make sure the entire path to DIRECTORY-PATH is available. 514f05b35a2Smrgfunc_mkdir_p () 515f05b35a2Smrg{ 516f05b35a2Smrg my_directory_path="$1" 517f05b35a2Smrg my_dir_list= 518f05b35a2Smrg 519f05b35a2Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 520f05b35a2Smrg 521f05b35a2Smrg # Protect directory names starting with `-' 522f05b35a2Smrg case $my_directory_path in 523f05b35a2Smrg -*) my_directory_path="./$my_directory_path" ;; 524f05b35a2Smrg esac 525f05b35a2Smrg 526f05b35a2Smrg # While some portion of DIR does not yet exist... 527f05b35a2Smrg while test ! -d "$my_directory_path"; do 528f05b35a2Smrg # ...make a list in topmost first order. Use a colon delimited 529f05b35a2Smrg # list incase some portion of path contains whitespace. 530f05b35a2Smrg my_dir_list="$my_directory_path:$my_dir_list" 531f05b35a2Smrg 532f05b35a2Smrg # If the last portion added has no slash in it, the list is done 533f05b35a2Smrg case $my_directory_path in */*) ;; *) break ;; esac 534f05b35a2Smrg 535f05b35a2Smrg # ...otherwise throw away the child directory and loop 53649e108a1Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 537f05b35a2Smrg done 53849e108a1Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 539f05b35a2Smrg 540f05b35a2Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 541f05b35a2Smrg for my_dir in $my_dir_list; do 542f05b35a2Smrg IFS="$save_mkdir_p_IFS" 543f05b35a2Smrg # mkdir can fail with a `File exist' error if two processes 544f05b35a2Smrg # try to create one of the directories concurrently. Don't 545f05b35a2Smrg # stop in that case! 546f05b35a2Smrg $MKDIR "$my_dir" 2>/dev/null || : 547f05b35a2Smrg done 548f05b35a2Smrg IFS="$save_mkdir_p_IFS" 549f05b35a2Smrg 550f05b35a2Smrg # Bail out if we (or some other process) failed to create a directory. 551f05b35a2Smrg test -d "$my_directory_path" || \ 552f05b35a2Smrg func_fatal_error "Failed to create \`$1'" 553f05b35a2Smrg fi 554f05b35a2Smrg} 555e0963edeSmrg 556e0963edeSmrg 557e0963edeSmrg# func_mktempdir [string] 558e0963edeSmrg# Make a temporary directory that won't clash with other running 559e0963edeSmrg# libtool processes, and avoids race conditions if possible. If 560e0963edeSmrg# given, STRING is the basename for that directory. 561e0963edeSmrgfunc_mktempdir () 562e0963edeSmrg{ 563e0963edeSmrg my_template="${TMPDIR-/tmp}/${1-$progname}" 564e0963edeSmrg 565f05b35a2Smrg if test "$opt_dry_run" = ":"; then 566e0963edeSmrg # Return a directory name, but don't create it in dry-run mode 567e0963edeSmrg my_tmpdir="${my_template}-$$" 568e0963edeSmrg else 569e0963edeSmrg 570e0963edeSmrg # If mktemp works, use that first and foremost 571e0963edeSmrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 572e0963edeSmrg 573e0963edeSmrg if test ! -d "$my_tmpdir"; then 574f05b35a2Smrg # Failing that, at least try and use $RANDOM to avoid a race 575f05b35a2Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 576e0963edeSmrg 577f05b35a2Smrg save_mktempdir_umask=`umask` 578f05b35a2Smrg umask 0077 579f05b35a2Smrg $MKDIR "$my_tmpdir" 580f05b35a2Smrg umask $save_mktempdir_umask 581e0963edeSmrg fi 582e0963edeSmrg 583e0963edeSmrg # If we're not in dry-run mode, bomb out on failure 584f05b35a2Smrg test -d "$my_tmpdir" || \ 585f05b35a2Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 586e0963edeSmrg fi 587e0963edeSmrg 58849e108a1Smrg $ECHO "$my_tmpdir" 589e0963edeSmrg} 590e0963edeSmrg 591e0963edeSmrg 592f05b35a2Smrg# func_quote_for_eval arg 593f05b35a2Smrg# Aesthetically quote ARG to be evaled later. 594f05b35a2Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 595f05b35a2Smrg# is double-quoted, suitable for a subsequent eval, whereas 596f05b35a2Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 597f05b35a2Smrg# which are still active within double quotes backslashified. 598f05b35a2Smrgfunc_quote_for_eval () 599e0963edeSmrg{ 600f05b35a2Smrg case $1 in 601f05b35a2Smrg *[\\\`\"\$]*) 60249e108a1Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 603f05b35a2Smrg *) 604f05b35a2Smrg func_quote_for_eval_unquoted_result="$1" ;; 605f05b35a2Smrg esac 606f05b35a2Smrg 607f05b35a2Smrg case $func_quote_for_eval_unquoted_result in 608f05b35a2Smrg # Double-quote args containing shell metacharacters to delay 609f05b35a2Smrg # word splitting, command substitution and and variable 610f05b35a2Smrg # expansion for a subsequent eval. 611f05b35a2Smrg # Many Bourne shells cannot handle close brackets correctly 612f05b35a2Smrg # in scan sets, so we specify it separately. 613f05b35a2Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 614f05b35a2Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 615f05b35a2Smrg ;; 616f05b35a2Smrg *) 617f05b35a2Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 618e0963edeSmrg esac 619e0963edeSmrg} 620e0963edeSmrg 621e0963edeSmrg 622f05b35a2Smrg# func_quote_for_expand arg 623f05b35a2Smrg# Aesthetically quote ARG to be evaled later; same as above, 624f05b35a2Smrg# but do not quote variable references. 625f05b35a2Smrgfunc_quote_for_expand () 626e0963edeSmrg{ 627f05b35a2Smrg case $1 in 628f05b35a2Smrg *[\\\`\"]*) 62949e108a1Smrg my_arg=`$ECHO "$1" | $SED \ 630f05b35a2Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 631e0963edeSmrg *) 632f05b35a2Smrg my_arg="$1" ;; 633f05b35a2Smrg esac 634f05b35a2Smrg 635f05b35a2Smrg case $my_arg in 636f05b35a2Smrg # Double-quote args containing shell metacharacters to delay 637f05b35a2Smrg # word splitting and command substitution for a subsequent eval. 638f05b35a2Smrg # Many Bourne shells cannot handle close brackets correctly 639f05b35a2Smrg # in scan sets, so we specify it separately. 640f05b35a2Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 641f05b35a2Smrg my_arg="\"$my_arg\"" 642f05b35a2Smrg ;; 643f05b35a2Smrg esac 644f05b35a2Smrg 645f05b35a2Smrg func_quote_for_expand_result="$my_arg" 646e0963edeSmrg} 647e0963edeSmrg 648e0963edeSmrg 649f05b35a2Smrg# func_show_eval cmd [fail_exp] 650f05b35a2Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 651f05b35a2Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 652f05b35a2Smrg# is given, then evaluate it. 653f05b35a2Smrgfunc_show_eval () 654e0963edeSmrg{ 655f05b35a2Smrg my_cmd="$1" 656f05b35a2Smrg my_fail_exp="${2-:}" 657e0963edeSmrg 658f05b35a2Smrg ${opt_silent-false} || { 659f05b35a2Smrg func_quote_for_expand "$my_cmd" 660f05b35a2Smrg eval "func_echo $func_quote_for_expand_result" 661f05b35a2Smrg } 662f05b35a2Smrg 663f05b35a2Smrg if ${opt_dry_run-false}; then :; else 664f05b35a2Smrg eval "$my_cmd" 665f05b35a2Smrg my_status=$? 666f05b35a2Smrg if test "$my_status" -eq 0; then :; else 667f05b35a2Smrg eval "(exit $my_status); $my_fail_exp" 668f05b35a2Smrg fi 669e0963edeSmrg fi 670e0963edeSmrg} 671e0963edeSmrg 672f05b35a2Smrg 673f05b35a2Smrg# func_show_eval_locale cmd [fail_exp] 674f05b35a2Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 675f05b35a2Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 676f05b35a2Smrg# is given, then evaluate it. Use the saved locale for evaluation. 677f05b35a2Smrgfunc_show_eval_locale () 678e0963edeSmrg{ 679f05b35a2Smrg my_cmd="$1" 680f05b35a2Smrg my_fail_exp="${2-:}" 681f05b35a2Smrg 682f05b35a2Smrg ${opt_silent-false} || { 683f05b35a2Smrg func_quote_for_expand "$my_cmd" 684f05b35a2Smrg eval "func_echo $func_quote_for_expand_result" 685f05b35a2Smrg } 686f05b35a2Smrg 687f05b35a2Smrg if ${opt_dry_run-false}; then :; else 688f05b35a2Smrg eval "$lt_user_locale 689f05b35a2Smrg $my_cmd" 690f05b35a2Smrg my_status=$? 691f05b35a2Smrg eval "$lt_safe_locale" 692f05b35a2Smrg if test "$my_status" -eq 0; then :; else 693f05b35a2Smrg eval "(exit $my_status); $my_fail_exp" 694f05b35a2Smrg fi 695e0963edeSmrg fi 696f05b35a2Smrg} 697e0963edeSmrg 69867ab2ff2Smrg# func_tr_sh 69967ab2ff2Smrg# Turn $1 into a string suitable for a shell variable name. 70067ab2ff2Smrg# Result is stored in $func_tr_sh_result. All characters 70167ab2ff2Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 70267ab2ff2Smrg# if $1 begins with a digit, a '_' is prepended as well. 70367ab2ff2Smrgfunc_tr_sh () 70467ab2ff2Smrg{ 70567ab2ff2Smrg case $1 in 70667ab2ff2Smrg [0-9]* | *[!a-zA-Z0-9_]*) 70767ab2ff2Smrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 70867ab2ff2Smrg ;; 70967ab2ff2Smrg * ) 71067ab2ff2Smrg func_tr_sh_result=$1 71167ab2ff2Smrg ;; 71267ab2ff2Smrg esac 71367ab2ff2Smrg} 71467ab2ff2Smrg 715e0963edeSmrg 716f05b35a2Smrg# func_version 717f05b35a2Smrg# Echo version message to standard output and exit. 718f05b35a2Smrgfunc_version () 719f05b35a2Smrg{ 72067ab2ff2Smrg $opt_debug 72167ab2ff2Smrg 72249e108a1Smrg $SED -n '/(C)/!b go 72349e108a1Smrg :more 72449e108a1Smrg /\./!{ 72549e108a1Smrg N 72649e108a1Smrg s/\n# / / 72749e108a1Smrg b more 72849e108a1Smrg } 72949e108a1Smrg :go 73049e108a1Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 731f05b35a2Smrg s/^# // 732f05b35a2Smrg s/^# *$// 733f05b35a2Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 734f05b35a2Smrg p 735f05b35a2Smrg }' < "$progpath" 736f05b35a2Smrg exit $? 737f05b35a2Smrg} 738f05b35a2Smrg 739f05b35a2Smrg# func_usage 740f05b35a2Smrg# Echo short help message to standard output and exit. 741f05b35a2Smrgfunc_usage () 742f05b35a2Smrg{ 74367ab2ff2Smrg $opt_debug 74467ab2ff2Smrg 74549e108a1Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 746f05b35a2Smrg s/^# // 747f05b35a2Smrg s/^# *$// 748f05b35a2Smrg s/\$progname/'$progname'/ 749f05b35a2Smrg p 750f05b35a2Smrg }' < "$progpath" 75149e108a1Smrg echo 752f05b35a2Smrg $ECHO "run \`$progname --help | more' for full usage" 753f05b35a2Smrg exit $? 754f05b35a2Smrg} 755f05b35a2Smrg 75649e108a1Smrg# func_help [NOEXIT] 75749e108a1Smrg# Echo long help message to standard output and exit, 75849e108a1Smrg# unless 'noexit' is passed as argument. 759f05b35a2Smrgfunc_help () 760f05b35a2Smrg{ 76167ab2ff2Smrg $opt_debug 76267ab2ff2Smrg 763f05b35a2Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 76467ab2ff2Smrg :print 765f05b35a2Smrg s/^# // 766f05b35a2Smrg s/^# *$// 767f05b35a2Smrg s*\$progname*'$progname'* 768f05b35a2Smrg s*\$host*'"$host"'* 769f05b35a2Smrg s*\$SHELL*'"$SHELL"'* 770f05b35a2Smrg s*\$LTCC*'"$LTCC"'* 771f05b35a2Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 772f05b35a2Smrg s*\$LD*'"$LD"'* 773f05b35a2Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 774f05b35a2Smrg s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ 775f05b35a2Smrg s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ 776f05b35a2Smrg p 77767ab2ff2Smrg d 77867ab2ff2Smrg } 77967ab2ff2Smrg /^# .* home page:/b print 78067ab2ff2Smrg /^# General help using/b print 78167ab2ff2Smrg ' < "$progpath" 78249e108a1Smrg ret=$? 78349e108a1Smrg if test -z "$1"; then 78449e108a1Smrg exit $ret 78549e108a1Smrg fi 786f05b35a2Smrg} 787f05b35a2Smrg 788f05b35a2Smrg# func_missing_arg argname 789f05b35a2Smrg# Echo program name prefixed message to standard error and set global 790f05b35a2Smrg# exit_cmd. 791f05b35a2Smrgfunc_missing_arg () 792f05b35a2Smrg{ 79367ab2ff2Smrg $opt_debug 79467ab2ff2Smrg 79549e108a1Smrg func_error "missing argument for $1." 796f05b35a2Smrg exit_cmd=exit 797e0963edeSmrg} 798e0963edeSmrg 799e0963edeSmrg 80067ab2ff2Smrg# func_split_short_opt shortopt 80167ab2ff2Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 80267ab2ff2Smrg# variables after splitting SHORTOPT after the 2nd character. 80367ab2ff2Smrgfunc_split_short_opt () 80467ab2ff2Smrg{ 80567ab2ff2Smrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 80667ab2ff2Smrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 80767ab2ff2Smrg 80867ab2ff2Smrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 80967ab2ff2Smrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 81067ab2ff2Smrg} # func_split_short_opt may be replaced by extended shell implementation 81167ab2ff2Smrg 81267ab2ff2Smrg 81367ab2ff2Smrg# func_split_long_opt longopt 81467ab2ff2Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 81567ab2ff2Smrg# variables after splitting LONGOPT at the `=' sign. 81667ab2ff2Smrgfunc_split_long_opt () 81767ab2ff2Smrg{ 81867ab2ff2Smrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 81967ab2ff2Smrg my_sed_long_arg='1s/^--[^=]*=//' 82067ab2ff2Smrg 82167ab2ff2Smrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 82267ab2ff2Smrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 82367ab2ff2Smrg} # func_split_long_opt may be replaced by extended shell implementation 82467ab2ff2Smrg 82567ab2ff2Smrgexit_cmd=: 826e0963edeSmrg 827f05b35a2Smrg 828f05b35a2Smrg 829f05b35a2Smrg 830e0963edeSmrg 831f05b35a2Smrgmagic="%%%MAGIC variable%%%" 832f05b35a2Smrgmagic_exe="%%%MAGIC EXE variable%%%" 833e0963edeSmrg 834f05b35a2Smrg# Global variables. 835f05b35a2Smrgnonopt= 836f05b35a2Smrgpreserve_args= 837f05b35a2Smrglo2o="s/\\.lo\$/.${objext}/" 838f05b35a2Smrgo2lo="s/\\.${objext}\$/.lo/" 839f05b35a2Smrgextracted_archives= 840f05b35a2Smrgextracted_serial=0 841e0963edeSmrg 842f05b35a2Smrg# If this variable is set in any of the actions, the command in it 843f05b35a2Smrg# will be execed at the end. This prevents here-documents from being 844f05b35a2Smrg# left over by shells. 845f05b35a2Smrgexec_cmd= 846f05b35a2Smrg 84767ab2ff2Smrg# func_append var value 84867ab2ff2Smrg# Append VALUE to the end of shell variable VAR. 84967ab2ff2Smrgfunc_append () 85067ab2ff2Smrg{ 85167ab2ff2Smrg eval "${1}=\$${1}\${2}" 85267ab2ff2Smrg} # func_append may be replaced by extended shell implementation 85367ab2ff2Smrg 85467ab2ff2Smrg# func_append_quoted var value 85567ab2ff2Smrg# Quote VALUE and append to the end of shell variable VAR, separated 85667ab2ff2Smrg# by a space. 85767ab2ff2Smrgfunc_append_quoted () 85867ab2ff2Smrg{ 85967ab2ff2Smrg func_quote_for_eval "${2}" 86067ab2ff2Smrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 86167ab2ff2Smrg} # func_append_quoted may be replaced by extended shell implementation 86267ab2ff2Smrg 86367ab2ff2Smrg 86467ab2ff2Smrg# func_arith arithmetic-term... 86567ab2ff2Smrgfunc_arith () 86667ab2ff2Smrg{ 86767ab2ff2Smrg func_arith_result=`expr "${@}"` 86867ab2ff2Smrg} # func_arith may be replaced by extended shell implementation 86967ab2ff2Smrg 87067ab2ff2Smrg 87167ab2ff2Smrg# func_len string 87267ab2ff2Smrg# STRING may not start with a hyphen. 87367ab2ff2Smrgfunc_len () 87467ab2ff2Smrg{ 87567ab2ff2Smrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 87667ab2ff2Smrg} # func_len may be replaced by extended shell implementation 87767ab2ff2Smrg 87867ab2ff2Smrg 87967ab2ff2Smrg# func_lo2o object 88067ab2ff2Smrgfunc_lo2o () 88167ab2ff2Smrg{ 88267ab2ff2Smrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 88367ab2ff2Smrg} # func_lo2o may be replaced by extended shell implementation 88467ab2ff2Smrg 88567ab2ff2Smrg 88667ab2ff2Smrg# func_xform libobj-or-source 88767ab2ff2Smrgfunc_xform () 88867ab2ff2Smrg{ 88967ab2ff2Smrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 89067ab2ff2Smrg} # func_xform may be replaced by extended shell implementation 89167ab2ff2Smrg 89267ab2ff2Smrg 893f05b35a2Smrg# func_fatal_configuration arg... 894f05b35a2Smrg# Echo program name prefixed message to standard error, followed by 895f05b35a2Smrg# a configuration failure hint, and exit. 896f05b35a2Smrgfunc_fatal_configuration () 897f05b35a2Smrg{ 898f05b35a2Smrg func_error ${1+"$@"} 899f05b35a2Smrg func_error "See the $PACKAGE documentation for more information." 900f05b35a2Smrg func_fatal_error "Fatal configuration error." 901f05b35a2Smrg} 902e0963edeSmrg 903e0963edeSmrg 904f05b35a2Smrg# func_config 905f05b35a2Smrg# Display the configuration for all the tags in this script. 906f05b35a2Smrgfunc_config () 907f05b35a2Smrg{ 908f05b35a2Smrg re_begincf='^# ### BEGIN LIBTOOL' 909f05b35a2Smrg re_endcf='^# ### END LIBTOOL' 910f05b35a2Smrg 911f05b35a2Smrg # Default configuration. 912f05b35a2Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 913e0963edeSmrg 914e0963edeSmrg # Now print the configurations for the tags. 915e0963edeSmrg for tagname in $taglist; do 916f05b35a2Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 917e0963edeSmrg done 918e0963edeSmrg 919f05b35a2Smrg exit $? 920f05b35a2Smrg} 921e0963edeSmrg 922f05b35a2Smrg# func_features 923f05b35a2Smrg# Display the features supported by this script. 924f05b35a2Smrgfunc_features () 925f05b35a2Smrg{ 92649e108a1Smrg echo "host: $host" 927e0963edeSmrg if test "$build_libtool_libs" = yes; then 92849e108a1Smrg echo "enable shared libraries" 929e0963edeSmrg else 93049e108a1Smrg echo "disable shared libraries" 931e0963edeSmrg fi 932e0963edeSmrg if test "$build_old_libs" = yes; then 93349e108a1Smrg echo "enable static libraries" 934e0963edeSmrg else 93549e108a1Smrg echo "disable static libraries" 936e0963edeSmrg fi 937f05b35a2Smrg 938e0963edeSmrg exit $? 939f05b35a2Smrg} 940e0963edeSmrg 941f05b35a2Smrg# func_enable_tag tagname 942f05b35a2Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 943f05b35a2Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 944f05b35a2Smrg# variable here. 945f05b35a2Smrgfunc_enable_tag () 946f05b35a2Smrg{ 947f05b35a2Smrg # Global variable: 948f05b35a2Smrg tagname="$1" 949e0963edeSmrg 950f05b35a2Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 951f05b35a2Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 952f05b35a2Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 953e0963edeSmrg 954f05b35a2Smrg # Validate tagname. 955f05b35a2Smrg case $tagname in 956f05b35a2Smrg *[!-_A-Za-z0-9,/]*) 957f05b35a2Smrg func_fatal_error "invalid tag name: $tagname" 958f05b35a2Smrg ;; 959f05b35a2Smrg esac 960e0963edeSmrg 961f05b35a2Smrg # Don't test for the "default" C tag, as we know it's 962f05b35a2Smrg # there but not specially marked. 963f05b35a2Smrg case $tagname in 964f05b35a2Smrg CC) ;; 965f05b35a2Smrg *) 966f05b35a2Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 967f05b35a2Smrg taglist="$taglist $tagname" 968f05b35a2Smrg 969f05b35a2Smrg # Evaluate the configuration. Be careful to quote the path 970f05b35a2Smrg # and the sed script, to avoid splitting on whitespace, but 971f05b35a2Smrg # also don't use non-portable quotes within backquotes within 972f05b35a2Smrg # quotes we have to do it in 2 steps: 973f05b35a2Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 974f05b35a2Smrg eval "$extractedcf" 975f05b35a2Smrg else 976f05b35a2Smrg func_error "ignoring unknown tag $tagname" 977f05b35a2Smrg fi 978f05b35a2Smrg ;; 979f05b35a2Smrg esac 980f05b35a2Smrg} 981f05b35a2Smrg 98267ab2ff2Smrg# func_check_version_match 98367ab2ff2Smrg# Ensure that we are using m4 macros, and libtool script from the same 98467ab2ff2Smrg# release of libtool. 98567ab2ff2Smrgfunc_check_version_match () 986f05b35a2Smrg{ 98767ab2ff2Smrg if test "$package_revision" != "$macro_revision"; then 98867ab2ff2Smrg if test "$VERSION" != "$macro_version"; then 98967ab2ff2Smrg if test -z "$macro_version"; then 99067ab2ff2Smrg cat >&2 <<_LT_EOF 99167ab2ff2Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 99267ab2ff2Smrg$progname: definition of this LT_INIT comes from an older release. 99367ab2ff2Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 99467ab2ff2Smrg$progname: and run autoconf again. 99567ab2ff2Smrg_LT_EOF 99667ab2ff2Smrg else 99767ab2ff2Smrg cat >&2 <<_LT_EOF 99867ab2ff2Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 99967ab2ff2Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 100067ab2ff2Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 100167ab2ff2Smrg$progname: and run autoconf again. 100267ab2ff2Smrg_LT_EOF 100367ab2ff2Smrg fi 100467ab2ff2Smrg else 100567ab2ff2Smrg cat >&2 <<_LT_EOF 100667ab2ff2Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 100767ab2ff2Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 100867ab2ff2Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 100967ab2ff2Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 101067ab2ff2Smrg_LT_EOF 101167ab2ff2Smrg fi 1012e0963edeSmrg 101367ab2ff2Smrg exit $EXIT_MISMATCH 101467ab2ff2Smrg fi 101567ab2ff2Smrg} 101667ab2ff2Smrg 101767ab2ff2Smrg 101867ab2ff2Smrg# Shorthand for --mode=foo, only valid as the first argument 101967ab2ff2Smrgcase $1 in 102067ab2ff2Smrgclean|clea|cle|cl) 102167ab2ff2Smrg shift; set dummy --mode clean ${1+"$@"}; shift 102267ab2ff2Smrg ;; 102367ab2ff2Smrgcompile|compil|compi|comp|com|co|c) 102467ab2ff2Smrg shift; set dummy --mode compile ${1+"$@"}; shift 102567ab2ff2Smrg ;; 102667ab2ff2Smrgexecute|execut|execu|exec|exe|ex|e) 102767ab2ff2Smrg shift; set dummy --mode execute ${1+"$@"}; shift 102867ab2ff2Smrg ;; 102967ab2ff2Smrgfinish|finis|fini|fin|fi|f) 103067ab2ff2Smrg shift; set dummy --mode finish ${1+"$@"}; shift 103167ab2ff2Smrg ;; 103267ab2ff2Smrginstall|instal|insta|inst|ins|in|i) 103367ab2ff2Smrg shift; set dummy --mode install ${1+"$@"}; shift 103467ab2ff2Smrg ;; 103567ab2ff2Smrglink|lin|li|l) 103667ab2ff2Smrg shift; set dummy --mode link ${1+"$@"}; shift 103767ab2ff2Smrg ;; 103867ab2ff2Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 103967ab2ff2Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 104067ab2ff2Smrg ;; 104167ab2ff2Smrgesac 1042e0963edeSmrg 104367ab2ff2Smrg 104467ab2ff2Smrg 104567ab2ff2Smrg# Option defaults: 104667ab2ff2Smrgopt_debug=: 104767ab2ff2Smrgopt_dry_run=false 104867ab2ff2Smrgopt_config=false 104967ab2ff2Smrgopt_preserve_dup_deps=false 105067ab2ff2Smrgopt_features=false 105167ab2ff2Smrgopt_finish=false 105267ab2ff2Smrgopt_help=false 105367ab2ff2Smrgopt_help_all=false 105467ab2ff2Smrgopt_silent=: 105567ab2ff2Smrgopt_verbose=: 105667ab2ff2Smrgopt_silent=false 105767ab2ff2Smrgopt_verbose=false 105867ab2ff2Smrg 105967ab2ff2Smrg 106067ab2ff2Smrg# Parse options once, thoroughly. This comes as soon as possible in the 106167ab2ff2Smrg# script to make things like `--version' happen as quickly as we can. 106267ab2ff2Smrg{ 106367ab2ff2Smrg # this just eases exit handling 106467ab2ff2Smrg while test $# -gt 0; do 1065f05b35a2Smrg opt="$1" 1066f05b35a2Smrg shift 1067f05b35a2Smrg case $opt in 106867ab2ff2Smrg --debug|-x) opt_debug='set -x' 1069f05b35a2Smrg func_echo "enabling shell trace mode" 1070f05b35a2Smrg $opt_debug 1071f05b35a2Smrg ;; 107267ab2ff2Smrg --dry-run|--dryrun|-n) 107367ab2ff2Smrg opt_dry_run=: 1074f05b35a2Smrg ;; 107567ab2ff2Smrg --config) 107667ab2ff2Smrg opt_config=: 107767ab2ff2Smrgfunc_config 107867ab2ff2Smrg ;; 107967ab2ff2Smrg --dlopen|-dlopen) 108067ab2ff2Smrg optarg="$1" 108167ab2ff2Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 108267ab2ff2Smrg}$optarg" 1083f05b35a2Smrg shift 1084f05b35a2Smrg ;; 1085f05b35a2Smrg --preserve-dup-deps) 108667ab2ff2Smrg opt_preserve_dup_deps=: 108749e108a1Smrg ;; 108867ab2ff2Smrg --features) 108967ab2ff2Smrg opt_features=: 109067ab2ff2Smrgfunc_features 1091f05b35a2Smrg ;; 109267ab2ff2Smrg --finish) 109367ab2ff2Smrg opt_finish=: 109467ab2ff2Smrgset dummy --mode finish ${1+"$@"}; shift 109567ab2ff2Smrg ;; 109667ab2ff2Smrg --help) 109767ab2ff2Smrg opt_help=: 109867ab2ff2Smrg ;; 109967ab2ff2Smrg --help-all) 110067ab2ff2Smrg opt_help_all=: 110167ab2ff2Smrgopt_help=': help-all' 110267ab2ff2Smrg ;; 110367ab2ff2Smrg --mode) 110467ab2ff2Smrg test $# = 0 && func_missing_arg $opt && break 110567ab2ff2Smrg optarg="$1" 110667ab2ff2Smrg opt_mode="$optarg" 110767ab2ff2Smrgcase $optarg in 110867ab2ff2Smrg # Valid mode arguments: 110967ab2ff2Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 111067ab2ff2Smrg 111167ab2ff2Smrg # Catch anything else as an error 111267ab2ff2Smrg *) func_error "invalid argument for $opt" 111367ab2ff2Smrg exit_cmd=exit 111467ab2ff2Smrg break 111567ab2ff2Smrg ;; 111667ab2ff2Smrgesac 111767ab2ff2Smrg shift 111867ab2ff2Smrg ;; 111967ab2ff2Smrg --no-silent|--no-quiet) 1120f05b35a2Smrg opt_silent=false 112167ab2ff2Smrgfunc_append preserve_args " $opt" 112249e108a1Smrg ;; 112367ab2ff2Smrg --no-verbose) 112449e108a1Smrg opt_verbose=false 112567ab2ff2Smrgfunc_append preserve_args " $opt" 1126f05b35a2Smrg ;; 112767ab2ff2Smrg --silent|--quiet) 112867ab2ff2Smrg opt_silent=: 112967ab2ff2Smrgfunc_append preserve_args " $opt" 113067ab2ff2Smrg opt_verbose=false 113167ab2ff2Smrg ;; 113267ab2ff2Smrg --verbose|-v) 113367ab2ff2Smrg opt_verbose=: 113467ab2ff2Smrgfunc_append preserve_args " $opt" 113567ab2ff2Smrgopt_silent=false 113667ab2ff2Smrg ;; 113767ab2ff2Smrg --tag) 113867ab2ff2Smrg test $# = 0 && func_missing_arg $opt && break 113967ab2ff2Smrg optarg="$1" 114067ab2ff2Smrg opt_tag="$optarg" 114167ab2ff2Smrgfunc_append preserve_args " $opt $optarg" 114267ab2ff2Smrgfunc_enable_tag "$optarg" 1143f05b35a2Smrg shift 1144f05b35a2Smrg ;; 1145f05b35a2Smrg 114667ab2ff2Smrg -\?|-h) func_usage ;; 114767ab2ff2Smrg --help) func_help ;; 114867ab2ff2Smrg --version) func_version ;; 114967ab2ff2Smrg 1150f05b35a2Smrg # Separate optargs to long options: 115167ab2ff2Smrg --*=*) 115267ab2ff2Smrg func_split_long_opt "$opt" 115367ab2ff2Smrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 1154f05b35a2Smrg shift 1155f05b35a2Smrg ;; 1156f05b35a2Smrg 115767ab2ff2Smrg # Separate non-argument short options: 115867ab2ff2Smrg -\?*|-h*|-n*|-v*) 115967ab2ff2Smrg func_split_short_opt "$opt" 116067ab2ff2Smrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 116167ab2ff2Smrg shift 1162f05b35a2Smrg ;; 116367ab2ff2Smrg 116467ab2ff2Smrg --) break ;; 116567ab2ff2Smrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 116667ab2ff2Smrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 1167f05b35a2Smrg esac 1168f05b35a2Smrg done 1169f05b35a2Smrg 117067ab2ff2Smrg # Validate options: 117167ab2ff2Smrg 117267ab2ff2Smrg # save first non-option argument 117367ab2ff2Smrg if test "$#" -gt 0; then 117467ab2ff2Smrg nonopt="$opt" 117567ab2ff2Smrg shift 117667ab2ff2Smrg fi 117767ab2ff2Smrg 117867ab2ff2Smrg # preserve --debug 117967ab2ff2Smrg test "$opt_debug" = : || func_append preserve_args " --debug" 1180f05b35a2Smrg 1181f05b35a2Smrg case $host in 1182f05b35a2Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 1183f05b35a2Smrg # don't eliminate duplications in $postdeps and $predeps 1184f05b35a2Smrg opt_duplicate_compiler_generated_deps=: 1185e0963edeSmrg ;; 1186e0963edeSmrg *) 118767ab2ff2Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 1188f05b35a2Smrg ;; 1189f05b35a2Smrg esac 1190e0963edeSmrg 119167ab2ff2Smrg $opt_help || { 119267ab2ff2Smrg # Sanity checks first: 119367ab2ff2Smrg func_check_version_match 1194f05b35a2Smrg 119567ab2ff2Smrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 119667ab2ff2Smrg func_fatal_configuration "not configured to build any kind of library" 1197f05b35a2Smrg fi 1198f05b35a2Smrg 119967ab2ff2Smrg # Darwin sucks 120067ab2ff2Smrg eval std_shrext=\"$shrext_cmds\" 1201f05b35a2Smrg 120267ab2ff2Smrg # Only execute mode is allowed to have -dlopen flags. 120367ab2ff2Smrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 120467ab2ff2Smrg func_error "unrecognized option \`-dlopen'" 120567ab2ff2Smrg $ECHO "$help" 1>&2 120667ab2ff2Smrg exit $EXIT_FAILURE 120767ab2ff2Smrg fi 1208f05b35a2Smrg 120967ab2ff2Smrg # Change the help message to a mode-specific one. 121067ab2ff2Smrg generic_help="$help" 121167ab2ff2Smrg help="Try \`$progname --help --mode=$opt_mode' for more information." 121267ab2ff2Smrg } 1213f05b35a2Smrg 1214f05b35a2Smrg 121567ab2ff2Smrg # Bail if the options were screwed 121667ab2ff2Smrg $exit_cmd $EXIT_FAILURE 121767ab2ff2Smrg} 1218f05b35a2Smrg 1219f05b35a2Smrg 1220e0963edeSmrg 1221e0963edeSmrg 122267ab2ff2Smrg## ----------- ## 122367ab2ff2Smrg## Main. ## 122467ab2ff2Smrg## ----------- ## 1225e0963edeSmrg 1226f05b35a2Smrg# func_lalib_p file 1227f05b35a2Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 1228f05b35a2Smrg# This function is only a basic sanity check; it will hardly flush out 1229f05b35a2Smrg# determined imposters. 1230f05b35a2Smrgfunc_lalib_p () 1231f05b35a2Smrg{ 1232f05b35a2Smrg test -f "$1" && 1233f05b35a2Smrg $SED -e 4q "$1" 2>/dev/null \ 1234f05b35a2Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 1235f05b35a2Smrg} 1236e0963edeSmrg 1237f05b35a2Smrg# func_lalib_unsafe_p file 1238f05b35a2Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 1239f05b35a2Smrg# This function implements the same check as func_lalib_p without 1240f05b35a2Smrg# resorting to external programs. To this end, it redirects stdin and 1241f05b35a2Smrg# closes it afterwards, without saving the original file descriptor. 1242f05b35a2Smrg# As a safety measure, use it only where a negative result would be 1243f05b35a2Smrg# fatal anyway. Works if `file' does not exist. 1244f05b35a2Smrgfunc_lalib_unsafe_p () 1245f05b35a2Smrg{ 1246f05b35a2Smrg lalib_p=no 1247f05b35a2Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 1248f05b35a2Smrg for lalib_p_l in 1 2 3 4 1249f05b35a2Smrg do 1250f05b35a2Smrg read lalib_p_line 1251f05b35a2Smrg case "$lalib_p_line" in 1252f05b35a2Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 1253f05b35a2Smrg esac 1254f05b35a2Smrg done 1255f05b35a2Smrg exec 0<&5 5<&- 1256f05b35a2Smrg fi 1257f05b35a2Smrg test "$lalib_p" = yes 1258f05b35a2Smrg} 1259e0963edeSmrg 1260f05b35a2Smrg# func_ltwrapper_script_p file 1261f05b35a2Smrg# True iff FILE is a libtool wrapper script 1262f05b35a2Smrg# This function is only a basic sanity check; it will hardly flush out 1263f05b35a2Smrg# determined imposters. 1264f05b35a2Smrgfunc_ltwrapper_script_p () 1265f05b35a2Smrg{ 1266f05b35a2Smrg func_lalib_p "$1" 1267f05b35a2Smrg} 1268e0963edeSmrg 1269f05b35a2Smrg# func_ltwrapper_executable_p file 1270f05b35a2Smrg# True iff FILE is a libtool wrapper executable 1271f05b35a2Smrg# This function is only a basic sanity check; it will hardly flush out 1272f05b35a2Smrg# determined imposters. 1273f05b35a2Smrgfunc_ltwrapper_executable_p () 1274f05b35a2Smrg{ 1275f05b35a2Smrg func_ltwrapper_exec_suffix= 1276f05b35a2Smrg case $1 in 1277f05b35a2Smrg *.exe) ;; 1278f05b35a2Smrg *) func_ltwrapper_exec_suffix=.exe ;; 1279f05b35a2Smrg esac 1280f05b35a2Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 1281f05b35a2Smrg} 1282e0963edeSmrg 1283f05b35a2Smrg# func_ltwrapper_scriptname file 1284f05b35a2Smrg# Assumes file is an ltwrapper_executable 1285f05b35a2Smrg# uses $file to determine the appropriate filename for a 1286f05b35a2Smrg# temporary ltwrapper_script. 1287f05b35a2Smrgfunc_ltwrapper_scriptname () 1288f05b35a2Smrg{ 128967ab2ff2Smrg func_dirname_and_basename "$1" "" "." 129067ab2ff2Smrg func_stripname '' '.exe' "$func_basename_result" 129167ab2ff2Smrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 1292f05b35a2Smrg} 1293f05b35a2Smrg 1294f05b35a2Smrg# func_ltwrapper_p file 1295f05b35a2Smrg# True iff FILE is a libtool wrapper script or wrapper executable 1296f05b35a2Smrg# This function is only a basic sanity check; it will hardly flush out 1297f05b35a2Smrg# determined imposters. 1298f05b35a2Smrgfunc_ltwrapper_p () 1299f05b35a2Smrg{ 1300f05b35a2Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 1301f05b35a2Smrg} 1302f05b35a2Smrg 1303f05b35a2Smrg 1304f05b35a2Smrg# func_execute_cmds commands fail_cmd 1305f05b35a2Smrg# Execute tilde-delimited COMMANDS. 1306f05b35a2Smrg# If FAIL_CMD is given, eval that upon failure. 1307f05b35a2Smrg# FAIL_CMD may read-access the current command in variable CMD! 1308f05b35a2Smrgfunc_execute_cmds () 1309f05b35a2Smrg{ 1310f05b35a2Smrg $opt_debug 1311f05b35a2Smrg save_ifs=$IFS; IFS='~' 1312f05b35a2Smrg for cmd in $1; do 1313f05b35a2Smrg IFS=$save_ifs 1314f05b35a2Smrg eval cmd=\"$cmd\" 1315f05b35a2Smrg func_show_eval "$cmd" "${2-:}" 1316f05b35a2Smrg done 1317f05b35a2Smrg IFS=$save_ifs 1318f05b35a2Smrg} 1319f05b35a2Smrg 1320f05b35a2Smrg 1321f05b35a2Smrg# func_source file 1322f05b35a2Smrg# Source FILE, adding directory component if necessary. 1323f05b35a2Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 1324f05b35a2Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 1325f05b35a2Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 1326f05b35a2Smrg# `FILE.' does not work on cygwin managed mounts. 1327f05b35a2Smrgfunc_source () 1328f05b35a2Smrg{ 1329f05b35a2Smrg $opt_debug 1330f05b35a2Smrg case $1 in 1331f05b35a2Smrg */* | *\\*) . "$1" ;; 1332f05b35a2Smrg *) . "./$1" ;; 1333f05b35a2Smrg esac 1334f05b35a2Smrg} 1335f05b35a2Smrg 1336f05b35a2Smrg 133767ab2ff2Smrg# func_resolve_sysroot PATH 133867ab2ff2Smrg# Replace a leading = in PATH with a sysroot. Store the result into 133967ab2ff2Smrg# func_resolve_sysroot_result 134067ab2ff2Smrgfunc_resolve_sysroot () 134167ab2ff2Smrg{ 134267ab2ff2Smrg func_resolve_sysroot_result=$1 134367ab2ff2Smrg case $func_resolve_sysroot_result in 134467ab2ff2Smrg =*) 134567ab2ff2Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 134667ab2ff2Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 134767ab2ff2Smrg ;; 134867ab2ff2Smrg esac 134967ab2ff2Smrg} 135067ab2ff2Smrg 135167ab2ff2Smrg# func_replace_sysroot PATH 135267ab2ff2Smrg# If PATH begins with the sysroot, replace it with = and 135367ab2ff2Smrg# store the result into func_replace_sysroot_result. 135467ab2ff2Smrgfunc_replace_sysroot () 135567ab2ff2Smrg{ 135667ab2ff2Smrg case "$lt_sysroot:$1" in 135767ab2ff2Smrg ?*:"$lt_sysroot"*) 135867ab2ff2Smrg func_stripname "$lt_sysroot" '' "$1" 135967ab2ff2Smrg func_replace_sysroot_result="=$func_stripname_result" 136067ab2ff2Smrg ;; 136167ab2ff2Smrg *) 136267ab2ff2Smrg # Including no sysroot. 136367ab2ff2Smrg func_replace_sysroot_result=$1 136467ab2ff2Smrg ;; 136567ab2ff2Smrg esac 136667ab2ff2Smrg} 136767ab2ff2Smrg 1368f05b35a2Smrg# func_infer_tag arg 1369f05b35a2Smrg# Infer tagged configuration to use if any are available and 1370f05b35a2Smrg# if one wasn't chosen via the "--tag" command line option. 1371f05b35a2Smrg# Only attempt this if the compiler in the base compile 1372f05b35a2Smrg# command doesn't match the default compiler. 1373f05b35a2Smrg# arg is usually of the form 'gcc ...' 1374f05b35a2Smrgfunc_infer_tag () 1375f05b35a2Smrg{ 1376f05b35a2Smrg $opt_debug 1377f05b35a2Smrg if test -n "$available_tags" && test -z "$tagname"; then 1378f05b35a2Smrg CC_quoted= 1379f05b35a2Smrg for arg in $CC; do 138067ab2ff2Smrg func_append_quoted CC_quoted "$arg" 1381f05b35a2Smrg done 138249e108a1Smrg CC_expanded=`func_echo_all $CC` 138349e108a1Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 1384f05b35a2Smrg case $@ in 1385f05b35a2Smrg # Blanks in the command may have been stripped by the calling shell, 1386f05b35a2Smrg # but not from the CC environment variable when configure was run. 138749e108a1Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 138849e108a1Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 1389f05b35a2Smrg # Blanks at the start of $base_compile will cause this to fail 1390f05b35a2Smrg # if we don't check for them as well. 1391f05b35a2Smrg *) 1392f05b35a2Smrg for z in $available_tags; do 1393f05b35a2Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 1394f05b35a2Smrg # Evaluate the configuration. 1395f05b35a2Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 1396f05b35a2Smrg CC_quoted= 1397f05b35a2Smrg for arg in $CC; do 1398f05b35a2Smrg # Double-quote args containing other shell metacharacters. 139967ab2ff2Smrg func_append_quoted CC_quoted "$arg" 1400f05b35a2Smrg done 140149e108a1Smrg CC_expanded=`func_echo_all $CC` 140249e108a1Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 1403f05b35a2Smrg case "$@ " in 140449e108a1Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 140549e108a1Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 1406f05b35a2Smrg # The compiler in the base compile command matches 1407f05b35a2Smrg # the one in the tagged configuration. 1408f05b35a2Smrg # Assume this is the tagged configuration we want. 1409f05b35a2Smrg tagname=$z 1410f05b35a2Smrg break 1411f05b35a2Smrg ;; 1412f05b35a2Smrg esac 1413f05b35a2Smrg fi 1414f05b35a2Smrg done 1415f05b35a2Smrg # If $tagname still isn't set, then no tagged configuration 1416f05b35a2Smrg # was found and let the user know that the "--tag" command 1417f05b35a2Smrg # line option must be used. 1418f05b35a2Smrg if test -z "$tagname"; then 1419f05b35a2Smrg func_echo "unable to infer tagged configuration" 1420f05b35a2Smrg func_fatal_error "specify a tag with \`--tag'" 1421f05b35a2Smrg# else 1422f05b35a2Smrg# func_verbose "using $tagname tagged configuration" 1423f05b35a2Smrg fi 1424f05b35a2Smrg ;; 1425f05b35a2Smrg esac 1426f05b35a2Smrg fi 1427f05b35a2Smrg} 1428f05b35a2Smrg 1429f05b35a2Smrg 1430f05b35a2Smrg 143167ab2ff2Smrg# func_write_libtool_object output_name pic_name nonpic_name 143267ab2ff2Smrg# Create a libtool object file (analogous to a ".la" file), 143367ab2ff2Smrg# but don't create it if we're doing a dry run. 143467ab2ff2Smrgfunc_write_libtool_object () 143567ab2ff2Smrg{ 143667ab2ff2Smrg write_libobj=${1} 143767ab2ff2Smrg if test "$build_libtool_libs" = yes; then 143867ab2ff2Smrg write_lobj=\'${2}\' 143967ab2ff2Smrg else 144067ab2ff2Smrg write_lobj=none 144167ab2ff2Smrg fi 144267ab2ff2Smrg 144367ab2ff2Smrg if test "$build_old_libs" = yes; then 144467ab2ff2Smrg write_oldobj=\'${3}\' 144567ab2ff2Smrg else 144667ab2ff2Smrg write_oldobj=none 144767ab2ff2Smrg fi 144867ab2ff2Smrg 144967ab2ff2Smrg $opt_dry_run || { 145067ab2ff2Smrg cat >${write_libobj}T <<EOF 145167ab2ff2Smrg# $write_libobj - a libtool object file 145267ab2ff2Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 145367ab2ff2Smrg# 145467ab2ff2Smrg# Please DO NOT delete this file! 145567ab2ff2Smrg# It is necessary for linking the library. 145667ab2ff2Smrg 145767ab2ff2Smrg# Name of the PIC object. 145867ab2ff2Smrgpic_object=$write_lobj 145967ab2ff2Smrg 146067ab2ff2Smrg# Name of the non-PIC object 146167ab2ff2Smrgnon_pic_object=$write_oldobj 146267ab2ff2Smrg 146367ab2ff2SmrgEOF 146467ab2ff2Smrg $MV "${write_libobj}T" "${write_libobj}" 146567ab2ff2Smrg } 146667ab2ff2Smrg} 146767ab2ff2Smrg 146867ab2ff2Smrg 146967ab2ff2Smrg################################################## 147067ab2ff2Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 147167ab2ff2Smrg################################################## 147267ab2ff2Smrg 147367ab2ff2Smrg# func_convert_core_file_wine_to_w32 ARG 147467ab2ff2Smrg# Helper function used by file name conversion functions when $build is *nix, 147567ab2ff2Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 147667ab2ff2Smrg# correctly configured wine environment available, with the winepath program 147767ab2ff2Smrg# in $build's $PATH. 147867ab2ff2Smrg# 147967ab2ff2Smrg# ARG is the $build file name to be converted to w32 format. 148067ab2ff2Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 148167ab2ff2Smrg# be empty on error (or when ARG is empty) 148267ab2ff2Smrgfunc_convert_core_file_wine_to_w32 () 148367ab2ff2Smrg{ 148467ab2ff2Smrg $opt_debug 148567ab2ff2Smrg func_convert_core_file_wine_to_w32_result="$1" 148667ab2ff2Smrg if test -n "$1"; then 148767ab2ff2Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 148867ab2ff2Smrg # are forced to check the contents of stdout. On the other hand, if the 148967ab2ff2Smrg # command is not found, the shell will set an exit code of 127 and print 149067ab2ff2Smrg # *an error message* to stdout. So we must check for both error code of 149167ab2ff2Smrg # zero AND non-empty stdout, which explains the odd construction: 149267ab2ff2Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 149367ab2ff2Smrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 149467ab2ff2Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 149567ab2ff2Smrg $SED -e "$lt_sed_naive_backslashify"` 149667ab2ff2Smrg else 149767ab2ff2Smrg func_convert_core_file_wine_to_w32_result= 149867ab2ff2Smrg fi 149967ab2ff2Smrg fi 150067ab2ff2Smrg} 150167ab2ff2Smrg# end: func_convert_core_file_wine_to_w32 150267ab2ff2Smrg 150367ab2ff2Smrg 150467ab2ff2Smrg# func_convert_core_path_wine_to_w32 ARG 150567ab2ff2Smrg# Helper function used by path conversion functions when $build is *nix, and 150667ab2ff2Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 150767ab2ff2Smrg# configured wine environment available, with the winepath program in $build's 150867ab2ff2Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 150967ab2ff2Smrg# 151067ab2ff2Smrg# ARG is path to be converted from $build format to win32. 151167ab2ff2Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 151267ab2ff2Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 151367ab2ff2Smrg# are convertible, then the result may be empty. 151467ab2ff2Smrgfunc_convert_core_path_wine_to_w32 () 151567ab2ff2Smrg{ 151667ab2ff2Smrg $opt_debug 151767ab2ff2Smrg # unfortunately, winepath doesn't convert paths, only file names 151867ab2ff2Smrg func_convert_core_path_wine_to_w32_result="" 151967ab2ff2Smrg if test -n "$1"; then 152067ab2ff2Smrg oldIFS=$IFS 152167ab2ff2Smrg IFS=: 152267ab2ff2Smrg for func_convert_core_path_wine_to_w32_f in $1; do 152367ab2ff2Smrg IFS=$oldIFS 152467ab2ff2Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 152567ab2ff2Smrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 152667ab2ff2Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 152767ab2ff2Smrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 152867ab2ff2Smrg else 152967ab2ff2Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 153067ab2ff2Smrg fi 153167ab2ff2Smrg fi 153267ab2ff2Smrg done 153367ab2ff2Smrg IFS=$oldIFS 153467ab2ff2Smrg fi 153567ab2ff2Smrg} 153667ab2ff2Smrg# end: func_convert_core_path_wine_to_w32 153767ab2ff2Smrg 153867ab2ff2Smrg 153967ab2ff2Smrg# func_cygpath ARGS... 154067ab2ff2Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 154167ab2ff2Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 154267ab2ff2Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 154367ab2ff2Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 154467ab2ff2Smrg# file name or path is assumed to be in w32 format, as previously converted 154567ab2ff2Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 154667ab2ff2Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 154767ab2ff2Smrg# Cygwin format). Returns an empty string on error. 154867ab2ff2Smrg# 154967ab2ff2Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 155067ab2ff2Smrg# be converted. 155167ab2ff2Smrg# 155267ab2ff2Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 155367ab2ff2Smrg# environment variable; do not put it in $PATH. 155467ab2ff2Smrgfunc_cygpath () 155567ab2ff2Smrg{ 155667ab2ff2Smrg $opt_debug 155767ab2ff2Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 155867ab2ff2Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 155967ab2ff2Smrg if test "$?" -ne 0; then 156067ab2ff2Smrg # on failure, ensure result is empty 156167ab2ff2Smrg func_cygpath_result= 156267ab2ff2Smrg fi 156367ab2ff2Smrg else 156467ab2ff2Smrg func_cygpath_result= 156567ab2ff2Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 156667ab2ff2Smrg fi 156767ab2ff2Smrg} 156867ab2ff2Smrg#end: func_cygpath 156967ab2ff2Smrg 157067ab2ff2Smrg 157167ab2ff2Smrg# func_convert_core_msys_to_w32 ARG 157267ab2ff2Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 157367ab2ff2Smrg# result in func_convert_core_msys_to_w32_result. 157467ab2ff2Smrgfunc_convert_core_msys_to_w32 () 157567ab2ff2Smrg{ 157667ab2ff2Smrg $opt_debug 157767ab2ff2Smrg # awkward: cmd appends spaces to result 157867ab2ff2Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 157967ab2ff2Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 158067ab2ff2Smrg} 158167ab2ff2Smrg#end: func_convert_core_msys_to_w32 158267ab2ff2Smrg 158367ab2ff2Smrg 158467ab2ff2Smrg# func_convert_file_check ARG1 ARG2 158567ab2ff2Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 158667ab2ff2Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 158767ab2ff2Smrg# func_to_host_file_result to ARG1). 158867ab2ff2Smrgfunc_convert_file_check () 158967ab2ff2Smrg{ 159067ab2ff2Smrg $opt_debug 159167ab2ff2Smrg if test -z "$2" && test -n "$1" ; then 159267ab2ff2Smrg func_error "Could not determine host file name corresponding to" 159367ab2ff2Smrg func_error " \`$1'" 159467ab2ff2Smrg func_error "Continuing, but uninstalled executables may not work." 159567ab2ff2Smrg # Fallback: 159667ab2ff2Smrg func_to_host_file_result="$1" 159767ab2ff2Smrg fi 159867ab2ff2Smrg} 159967ab2ff2Smrg# end func_convert_file_check 160067ab2ff2Smrg 160167ab2ff2Smrg 160267ab2ff2Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 160367ab2ff2Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 160467ab2ff2Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 160567ab2ff2Smrg# func_to_host_file_result to a simplistic fallback value (see below). 160667ab2ff2Smrgfunc_convert_path_check () 160767ab2ff2Smrg{ 160867ab2ff2Smrg $opt_debug 160967ab2ff2Smrg if test -z "$4" && test -n "$3"; then 161067ab2ff2Smrg func_error "Could not determine the host path corresponding to" 161167ab2ff2Smrg func_error " \`$3'" 161267ab2ff2Smrg func_error "Continuing, but uninstalled executables may not work." 161367ab2ff2Smrg # Fallback. This is a deliberately simplistic "conversion" and 161467ab2ff2Smrg # should not be "improved". See libtool.info. 161567ab2ff2Smrg if test "x$1" != "x$2"; then 161667ab2ff2Smrg lt_replace_pathsep_chars="s|$1|$2|g" 161767ab2ff2Smrg func_to_host_path_result=`echo "$3" | 161867ab2ff2Smrg $SED -e "$lt_replace_pathsep_chars"` 161967ab2ff2Smrg else 162067ab2ff2Smrg func_to_host_path_result="$3" 162167ab2ff2Smrg fi 162267ab2ff2Smrg fi 162367ab2ff2Smrg} 162467ab2ff2Smrg# end func_convert_path_check 162567ab2ff2Smrg 162667ab2ff2Smrg 162767ab2ff2Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 162867ab2ff2Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 162967ab2ff2Smrg# and appending REPL if ORIG matches BACKPAT. 163067ab2ff2Smrgfunc_convert_path_front_back_pathsep () 163167ab2ff2Smrg{ 163267ab2ff2Smrg $opt_debug 163367ab2ff2Smrg case $4 in 163467ab2ff2Smrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 163567ab2ff2Smrg ;; 163667ab2ff2Smrg esac 163767ab2ff2Smrg case $4 in 163867ab2ff2Smrg $2 ) func_append func_to_host_path_result "$3" 163967ab2ff2Smrg ;; 164067ab2ff2Smrg esac 164167ab2ff2Smrg} 164267ab2ff2Smrg# end func_convert_path_front_back_pathsep 164367ab2ff2Smrg 164467ab2ff2Smrg 164567ab2ff2Smrg################################################## 164667ab2ff2Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 164767ab2ff2Smrg################################################## 164867ab2ff2Smrg# invoked via `$to_host_file_cmd ARG' 164967ab2ff2Smrg# 165067ab2ff2Smrg# In each case, ARG is the path to be converted from $build to $host format. 165167ab2ff2Smrg# Result will be available in $func_to_host_file_result. 165267ab2ff2Smrg 165367ab2ff2Smrg 165467ab2ff2Smrg# func_to_host_file ARG 165567ab2ff2Smrg# Converts the file name ARG from $build format to $host format. Return result 165667ab2ff2Smrg# in func_to_host_file_result. 165767ab2ff2Smrgfunc_to_host_file () 165867ab2ff2Smrg{ 165967ab2ff2Smrg $opt_debug 166067ab2ff2Smrg $to_host_file_cmd "$1" 166167ab2ff2Smrg} 166267ab2ff2Smrg# end func_to_host_file 166367ab2ff2Smrg 166467ab2ff2Smrg 166567ab2ff2Smrg# func_to_tool_file ARG LAZY 166667ab2ff2Smrg# converts the file name ARG from $build format to toolchain format. Return 166767ab2ff2Smrg# result in func_to_tool_file_result. If the conversion in use is listed 166867ab2ff2Smrg# in (the comma separated) LAZY, no conversion takes place. 166967ab2ff2Smrgfunc_to_tool_file () 167067ab2ff2Smrg{ 167167ab2ff2Smrg $opt_debug 167267ab2ff2Smrg case ,$2, in 167367ab2ff2Smrg *,"$to_tool_file_cmd",*) 167467ab2ff2Smrg func_to_tool_file_result=$1 167567ab2ff2Smrg ;; 167667ab2ff2Smrg *) 167767ab2ff2Smrg $to_tool_file_cmd "$1" 167867ab2ff2Smrg func_to_tool_file_result=$func_to_host_file_result 167967ab2ff2Smrg ;; 168067ab2ff2Smrg esac 168167ab2ff2Smrg} 168267ab2ff2Smrg# end func_to_tool_file 168367ab2ff2Smrg 168467ab2ff2Smrg 168567ab2ff2Smrg# func_convert_file_noop ARG 168667ab2ff2Smrg# Copy ARG to func_to_host_file_result. 168767ab2ff2Smrgfunc_convert_file_noop () 168867ab2ff2Smrg{ 168967ab2ff2Smrg func_to_host_file_result="$1" 169067ab2ff2Smrg} 169167ab2ff2Smrg# end func_convert_file_noop 169267ab2ff2Smrg 169367ab2ff2Smrg 169467ab2ff2Smrg# func_convert_file_msys_to_w32 ARG 169567ab2ff2Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 169667ab2ff2Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 169767ab2ff2Smrg# func_to_host_file_result. 169867ab2ff2Smrgfunc_convert_file_msys_to_w32 () 169967ab2ff2Smrg{ 170067ab2ff2Smrg $opt_debug 170167ab2ff2Smrg func_to_host_file_result="$1" 170267ab2ff2Smrg if test -n "$1"; then 170367ab2ff2Smrg func_convert_core_msys_to_w32 "$1" 170467ab2ff2Smrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 170567ab2ff2Smrg fi 170667ab2ff2Smrg func_convert_file_check "$1" "$func_to_host_file_result" 170767ab2ff2Smrg} 170867ab2ff2Smrg# end func_convert_file_msys_to_w32 170967ab2ff2Smrg 171067ab2ff2Smrg 171167ab2ff2Smrg# func_convert_file_cygwin_to_w32 ARG 171267ab2ff2Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 171367ab2ff2Smrg# func_to_host_file_result. 171467ab2ff2Smrgfunc_convert_file_cygwin_to_w32 () 171567ab2ff2Smrg{ 171667ab2ff2Smrg $opt_debug 171767ab2ff2Smrg func_to_host_file_result="$1" 171867ab2ff2Smrg if test -n "$1"; then 171967ab2ff2Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 172067ab2ff2Smrg # LT_CYGPATH in this case. 172167ab2ff2Smrg func_to_host_file_result=`cygpath -m "$1"` 172267ab2ff2Smrg fi 172367ab2ff2Smrg func_convert_file_check "$1" "$func_to_host_file_result" 172467ab2ff2Smrg} 172567ab2ff2Smrg# end func_convert_file_cygwin_to_w32 172667ab2ff2Smrg 172767ab2ff2Smrg 172867ab2ff2Smrg# func_convert_file_nix_to_w32 ARG 172967ab2ff2Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 173067ab2ff2Smrg# and a working winepath. Returns result in func_to_host_file_result. 173167ab2ff2Smrgfunc_convert_file_nix_to_w32 () 173267ab2ff2Smrg{ 173367ab2ff2Smrg $opt_debug 173467ab2ff2Smrg func_to_host_file_result="$1" 173567ab2ff2Smrg if test -n "$1"; then 173667ab2ff2Smrg func_convert_core_file_wine_to_w32 "$1" 173767ab2ff2Smrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 173867ab2ff2Smrg fi 173967ab2ff2Smrg func_convert_file_check "$1" "$func_to_host_file_result" 174067ab2ff2Smrg} 174167ab2ff2Smrg# end func_convert_file_nix_to_w32 174267ab2ff2Smrg 174367ab2ff2Smrg 174467ab2ff2Smrg# func_convert_file_msys_to_cygwin ARG 174567ab2ff2Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 174667ab2ff2Smrg# Returns result in func_to_host_file_result. 174767ab2ff2Smrgfunc_convert_file_msys_to_cygwin () 174867ab2ff2Smrg{ 174967ab2ff2Smrg $opt_debug 175067ab2ff2Smrg func_to_host_file_result="$1" 175167ab2ff2Smrg if test -n "$1"; then 175267ab2ff2Smrg func_convert_core_msys_to_w32 "$1" 175367ab2ff2Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 175467ab2ff2Smrg func_to_host_file_result="$func_cygpath_result" 175567ab2ff2Smrg fi 175667ab2ff2Smrg func_convert_file_check "$1" "$func_to_host_file_result" 175767ab2ff2Smrg} 175867ab2ff2Smrg# end func_convert_file_msys_to_cygwin 175967ab2ff2Smrg 176067ab2ff2Smrg 176167ab2ff2Smrg# func_convert_file_nix_to_cygwin ARG 176267ab2ff2Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 176367ab2ff2Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 176467ab2ff2Smrg# in func_to_host_file_result. 176567ab2ff2Smrgfunc_convert_file_nix_to_cygwin () 176667ab2ff2Smrg{ 176767ab2ff2Smrg $opt_debug 176867ab2ff2Smrg func_to_host_file_result="$1" 176967ab2ff2Smrg if test -n "$1"; then 177067ab2ff2Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 177167ab2ff2Smrg func_convert_core_file_wine_to_w32 "$1" 177267ab2ff2Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 177367ab2ff2Smrg func_to_host_file_result="$func_cygpath_result" 177467ab2ff2Smrg fi 177567ab2ff2Smrg func_convert_file_check "$1" "$func_to_host_file_result" 177667ab2ff2Smrg} 177767ab2ff2Smrg# end func_convert_file_nix_to_cygwin 177867ab2ff2Smrg 177967ab2ff2Smrg 178067ab2ff2Smrg############################################# 178167ab2ff2Smrg# $build to $host PATH CONVERSION FUNCTIONS # 178267ab2ff2Smrg############################################# 178367ab2ff2Smrg# invoked via `$to_host_path_cmd ARG' 178467ab2ff2Smrg# 178567ab2ff2Smrg# In each case, ARG is the path to be converted from $build to $host format. 178667ab2ff2Smrg# The result will be available in $func_to_host_path_result. 178767ab2ff2Smrg# 178867ab2ff2Smrg# Path separators are also converted from $build format to $host format. If 178967ab2ff2Smrg# ARG begins or ends with a path separator character, it is preserved (but 179067ab2ff2Smrg# converted to $host format) on output. 179167ab2ff2Smrg# 179267ab2ff2Smrg# All path conversion functions are named using the following convention: 179367ab2ff2Smrg# file name conversion function : func_convert_file_X_to_Y () 179467ab2ff2Smrg# path conversion function : func_convert_path_X_to_Y () 179567ab2ff2Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 179667ab2ff2Smrg# same. If conversion functions are added for new $build/$host combinations, 179767ab2ff2Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 179867ab2ff2Smrg# will break. 179967ab2ff2Smrg 180067ab2ff2Smrg 180167ab2ff2Smrg# func_init_to_host_path_cmd 180267ab2ff2Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 180367ab2ff2Smrg# appropriate value, based on the value of $to_host_file_cmd. 180467ab2ff2Smrgto_host_path_cmd= 180567ab2ff2Smrgfunc_init_to_host_path_cmd () 180667ab2ff2Smrg{ 180767ab2ff2Smrg $opt_debug 180867ab2ff2Smrg if test -z "$to_host_path_cmd"; then 180967ab2ff2Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 181067ab2ff2Smrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 181167ab2ff2Smrg fi 181267ab2ff2Smrg} 181367ab2ff2Smrg 181467ab2ff2Smrg 181567ab2ff2Smrg# func_to_host_path ARG 181667ab2ff2Smrg# Converts the path ARG from $build format to $host format. Return result 181767ab2ff2Smrg# in func_to_host_path_result. 181867ab2ff2Smrgfunc_to_host_path () 181967ab2ff2Smrg{ 182067ab2ff2Smrg $opt_debug 182167ab2ff2Smrg func_init_to_host_path_cmd 182267ab2ff2Smrg $to_host_path_cmd "$1" 182367ab2ff2Smrg} 182467ab2ff2Smrg# end func_to_host_path 182567ab2ff2Smrg 182667ab2ff2Smrg 182767ab2ff2Smrg# func_convert_path_noop ARG 182867ab2ff2Smrg# Copy ARG to func_to_host_path_result. 182967ab2ff2Smrgfunc_convert_path_noop () 183067ab2ff2Smrg{ 183167ab2ff2Smrg func_to_host_path_result="$1" 183267ab2ff2Smrg} 183367ab2ff2Smrg# end func_convert_path_noop 183467ab2ff2Smrg 183567ab2ff2Smrg 183667ab2ff2Smrg# func_convert_path_msys_to_w32 ARG 183767ab2ff2Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 183867ab2ff2Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 183967ab2ff2Smrg# func_to_host_path_result. 184067ab2ff2Smrgfunc_convert_path_msys_to_w32 () 1841f05b35a2Smrg{ 184267ab2ff2Smrg $opt_debug 184367ab2ff2Smrg func_to_host_path_result="$1" 184467ab2ff2Smrg if test -n "$1"; then 184567ab2ff2Smrg # Remove leading and trailing path separator characters from ARG. MSYS 184667ab2ff2Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 184767ab2ff2Smrg # and winepath ignores them completely. 184867ab2ff2Smrg func_stripname : : "$1" 184967ab2ff2Smrg func_to_host_path_tmp1=$func_stripname_result 185067ab2ff2Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 185167ab2ff2Smrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 185267ab2ff2Smrg func_convert_path_check : ";" \ 185367ab2ff2Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 185467ab2ff2Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 185567ab2ff2Smrg fi 185667ab2ff2Smrg} 185767ab2ff2Smrg# end func_convert_path_msys_to_w32 1858f05b35a2Smrg 1859f05b35a2Smrg 186067ab2ff2Smrg# func_convert_path_cygwin_to_w32 ARG 186167ab2ff2Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 186267ab2ff2Smrg# func_to_host_file_result. 186367ab2ff2Smrgfunc_convert_path_cygwin_to_w32 () 186467ab2ff2Smrg{ 186567ab2ff2Smrg $opt_debug 186667ab2ff2Smrg func_to_host_path_result="$1" 186767ab2ff2Smrg if test -n "$1"; then 186867ab2ff2Smrg # See func_convert_path_msys_to_w32: 186967ab2ff2Smrg func_stripname : : "$1" 187067ab2ff2Smrg func_to_host_path_tmp1=$func_stripname_result 187167ab2ff2Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 187267ab2ff2Smrg func_convert_path_check : ";" \ 187367ab2ff2Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 187467ab2ff2Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 187567ab2ff2Smrg fi 187667ab2ff2Smrg} 187767ab2ff2Smrg# end func_convert_path_cygwin_to_w32 1878f05b35a2Smrg 1879f05b35a2Smrg 188067ab2ff2Smrg# func_convert_path_nix_to_w32 ARG 188167ab2ff2Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 188267ab2ff2Smrg# a working winepath. Returns result in func_to_host_file_result. 188367ab2ff2Smrgfunc_convert_path_nix_to_w32 () 188467ab2ff2Smrg{ 188567ab2ff2Smrg $opt_debug 188667ab2ff2Smrg func_to_host_path_result="$1" 188767ab2ff2Smrg if test -n "$1"; then 188867ab2ff2Smrg # See func_convert_path_msys_to_w32: 188967ab2ff2Smrg func_stripname : : "$1" 189067ab2ff2Smrg func_to_host_path_tmp1=$func_stripname_result 189167ab2ff2Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 189267ab2ff2Smrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 189367ab2ff2Smrg func_convert_path_check : ";" \ 189467ab2ff2Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 189567ab2ff2Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 189667ab2ff2Smrg fi 189767ab2ff2Smrg} 189867ab2ff2Smrg# end func_convert_path_nix_to_w32 1899f05b35a2Smrg 190067ab2ff2Smrg 190167ab2ff2Smrg# func_convert_path_msys_to_cygwin ARG 190267ab2ff2Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 190367ab2ff2Smrg# Returns result in func_to_host_file_result. 190467ab2ff2Smrgfunc_convert_path_msys_to_cygwin () 190567ab2ff2Smrg{ 190667ab2ff2Smrg $opt_debug 190767ab2ff2Smrg func_to_host_path_result="$1" 190867ab2ff2Smrg if test -n "$1"; then 190967ab2ff2Smrg # See func_convert_path_msys_to_w32: 191067ab2ff2Smrg func_stripname : : "$1" 191167ab2ff2Smrg func_to_host_path_tmp1=$func_stripname_result 191267ab2ff2Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 191367ab2ff2Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 191467ab2ff2Smrg func_to_host_path_result="$func_cygpath_result" 191567ab2ff2Smrg func_convert_path_check : : \ 191667ab2ff2Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 191767ab2ff2Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 191867ab2ff2Smrg fi 191967ab2ff2Smrg} 192067ab2ff2Smrg# end func_convert_path_msys_to_cygwin 192167ab2ff2Smrg 192267ab2ff2Smrg 192367ab2ff2Smrg# func_convert_path_nix_to_cygwin ARG 192467ab2ff2Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 192567ab2ff2Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 192667ab2ff2Smrg# func_to_host_file_result. 192767ab2ff2Smrgfunc_convert_path_nix_to_cygwin () 192867ab2ff2Smrg{ 192967ab2ff2Smrg $opt_debug 193067ab2ff2Smrg func_to_host_path_result="$1" 193167ab2ff2Smrg if test -n "$1"; then 193267ab2ff2Smrg # Remove leading and trailing path separator characters from 193367ab2ff2Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 193467ab2ff2Smrg # into '.;' and ';.', and winepath ignores them completely. 193567ab2ff2Smrg func_stripname : : "$1" 193667ab2ff2Smrg func_to_host_path_tmp1=$func_stripname_result 193767ab2ff2Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 193867ab2ff2Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 193967ab2ff2Smrg func_to_host_path_result="$func_cygpath_result" 194067ab2ff2Smrg func_convert_path_check : : \ 194167ab2ff2Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 194267ab2ff2Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 194367ab2ff2Smrg fi 1944f05b35a2Smrg} 194567ab2ff2Smrg# end func_convert_path_nix_to_cygwin 194667ab2ff2Smrg 1947f05b35a2Smrg 1948f05b35a2Smrg# func_mode_compile arg... 1949f05b35a2Smrgfunc_mode_compile () 1950f05b35a2Smrg{ 1951f05b35a2Smrg $opt_debug 1952f05b35a2Smrg # Get the compilation command and the source file. 1953f05b35a2Smrg base_compile= 1954f05b35a2Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 1955f05b35a2Smrg suppress_opt=yes 1956f05b35a2Smrg suppress_output= 1957f05b35a2Smrg arg_mode=normal 1958f05b35a2Smrg libobj= 1959f05b35a2Smrg later= 1960f05b35a2Smrg pie_flag= 1961f05b35a2Smrg 1962f05b35a2Smrg for arg 1963f05b35a2Smrg do 1964f05b35a2Smrg case $arg_mode in 1965f05b35a2Smrg arg ) 1966f05b35a2Smrg # do not "continue". Instead, add this to base_compile 1967f05b35a2Smrg lastarg="$arg" 1968f05b35a2Smrg arg_mode=normal 1969f05b35a2Smrg ;; 1970f05b35a2Smrg 1971f05b35a2Smrg target ) 1972f05b35a2Smrg libobj="$arg" 1973f05b35a2Smrg arg_mode=normal 1974f05b35a2Smrg continue 1975f05b35a2Smrg ;; 1976f05b35a2Smrg 1977f05b35a2Smrg normal ) 1978f05b35a2Smrg # Accept any command-line options. 1979f05b35a2Smrg case $arg in 1980f05b35a2Smrg -o) 1981f05b35a2Smrg test -n "$libobj" && \ 1982f05b35a2Smrg func_fatal_error "you cannot specify \`-o' more than once" 1983f05b35a2Smrg arg_mode=target 1984f05b35a2Smrg continue 1985f05b35a2Smrg ;; 1986f05b35a2Smrg 1987f05b35a2Smrg -pie | -fpie | -fPIE) 198867ab2ff2Smrg func_append pie_flag " $arg" 1989f05b35a2Smrg continue 1990f05b35a2Smrg ;; 1991f05b35a2Smrg 1992f05b35a2Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 199367ab2ff2Smrg func_append later " $arg" 1994f05b35a2Smrg continue 1995f05b35a2Smrg ;; 1996f05b35a2Smrg 1997f05b35a2Smrg -no-suppress) 1998e0963edeSmrg suppress_opt=no 1999e0963edeSmrg continue 2000e0963edeSmrg ;; 2001e0963edeSmrg 2002e0963edeSmrg -Xcompiler) 2003e0963edeSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 2004e0963edeSmrg continue # The current "srcfile" will either be retained or 2005e0963edeSmrg ;; # replaced later. I would guess that would be a bug. 2006e0963edeSmrg 2007e0963edeSmrg -Wc,*) 2008f05b35a2Smrg func_stripname '-Wc,' '' "$arg" 2009f05b35a2Smrg args=$func_stripname_result 2010e0963edeSmrg lastarg= 2011e0963edeSmrg save_ifs="$IFS"; IFS=',' 2012f05b35a2Smrg for arg in $args; do 2013e0963edeSmrg IFS="$save_ifs" 201467ab2ff2Smrg func_append_quoted lastarg "$arg" 2015e0963edeSmrg done 2016e0963edeSmrg IFS="$save_ifs" 2017f05b35a2Smrg func_stripname ' ' '' "$lastarg" 2018f05b35a2Smrg lastarg=$func_stripname_result 2019e0963edeSmrg 2020e0963edeSmrg # Add the arguments to base_compile. 202167ab2ff2Smrg func_append base_compile " $lastarg" 2022e0963edeSmrg continue 2023e0963edeSmrg ;; 2024e0963edeSmrg 2025f05b35a2Smrg *) 2026e0963edeSmrg # Accept the current argument as the source file. 2027e0963edeSmrg # The previous "srcfile" becomes the current argument. 2028e0963edeSmrg # 2029e0963edeSmrg lastarg="$srcfile" 2030e0963edeSmrg srcfile="$arg" 2031e0963edeSmrg ;; 2032e0963edeSmrg esac # case $arg 2033e0963edeSmrg ;; 2034e0963edeSmrg esac # case $arg_mode 2035e0963edeSmrg 2036e0963edeSmrg # Aesthetically quote the previous argument. 203767ab2ff2Smrg func_append_quoted base_compile "$lastarg" 2038e0963edeSmrg done # for arg 2039e0963edeSmrg 2040e0963edeSmrg case $arg_mode in 2041e0963edeSmrg arg) 2042f05b35a2Smrg func_fatal_error "you must specify an argument for -Xcompile" 2043e0963edeSmrg ;; 2044e0963edeSmrg target) 2045f05b35a2Smrg func_fatal_error "you must specify a target with \`-o'" 2046e0963edeSmrg ;; 2047e0963edeSmrg *) 2048e0963edeSmrg # Get the name of the library object. 2049f05b35a2Smrg test -z "$libobj" && { 2050f05b35a2Smrg func_basename "$srcfile" 2051f05b35a2Smrg libobj="$func_basename_result" 2052f05b35a2Smrg } 2053e0963edeSmrg ;; 2054e0963edeSmrg esac 2055e0963edeSmrg 2056e0963edeSmrg # Recognize several different file suffixes. 2057e0963edeSmrg # If the user specifies -o file.o, it is replaced with file.lo 2058e0963edeSmrg case $libobj in 2059f05b35a2Smrg *.[cCFSifmso] | \ 2060f05b35a2Smrg *.ada | *.adb | *.ads | *.asm | \ 2061f05b35a2Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 206249e108a1Smrg *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup) 2063f05b35a2Smrg func_xform "$libobj" 2064f05b35a2Smrg libobj=$func_xform_result 2065f05b35a2Smrg ;; 2066e0963edeSmrg esac 2067e0963edeSmrg 2068e0963edeSmrg case $libobj in 2069f05b35a2Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 2070e0963edeSmrg *) 2071f05b35a2Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 2072e0963edeSmrg ;; 2073e0963edeSmrg esac 2074e0963edeSmrg 2075e0963edeSmrg func_infer_tag $base_compile 2076e0963edeSmrg 2077e0963edeSmrg for arg in $later; do 2078e0963edeSmrg case $arg in 2079f05b35a2Smrg -shared) 2080f05b35a2Smrg test "$build_libtool_libs" != yes && \ 2081f05b35a2Smrg func_fatal_configuration "can not build a shared library" 2082f05b35a2Smrg build_old_libs=no 2083f05b35a2Smrg continue 2084f05b35a2Smrg ;; 2085f05b35a2Smrg 2086e0963edeSmrg -static) 2087f05b35a2Smrg build_libtool_libs=no 2088e0963edeSmrg build_old_libs=yes 2089e0963edeSmrg continue 2090e0963edeSmrg ;; 2091e0963edeSmrg 2092e0963edeSmrg -prefer-pic) 2093e0963edeSmrg pic_mode=yes 2094e0963edeSmrg continue 2095e0963edeSmrg ;; 2096e0963edeSmrg 2097e0963edeSmrg -prefer-non-pic) 2098e0963edeSmrg pic_mode=no 2099e0963edeSmrg continue 2100e0963edeSmrg ;; 2101e0963edeSmrg esac 2102e0963edeSmrg done 2103e0963edeSmrg 2104f05b35a2Smrg func_quote_for_eval "$libobj" 2105f05b35a2Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 2106f05b35a2Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 2107f05b35a2Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 2108f05b35a2Smrg func_dirname_and_basename "$obj" "/" "" 2109f05b35a2Smrg objname="$func_basename_result" 2110f05b35a2Smrg xdir="$func_dirname_result" 2111e0963edeSmrg lobj=${xdir}$objdir/$objname 2112e0963edeSmrg 2113f05b35a2Smrg test -z "$base_compile" && \ 2114f05b35a2Smrg func_fatal_help "you must specify a compilation command" 2115e0963edeSmrg 2116e0963edeSmrg # Delete any leftover library objects. 2117e0963edeSmrg if test "$build_old_libs" = yes; then 2118e0963edeSmrg removelist="$obj $lobj $libobj ${libobj}T" 2119e0963edeSmrg else 2120e0963edeSmrg removelist="$lobj $libobj ${libobj}T" 2121e0963edeSmrg fi 2122e0963edeSmrg 2123e0963edeSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 2124e0963edeSmrg case $host_os in 2125f05b35a2Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 2126e0963edeSmrg pic_mode=default 2127e0963edeSmrg ;; 2128e0963edeSmrg esac 2129e0963edeSmrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 2130e0963edeSmrg # non-PIC code in shared libraries is not supported 2131e0963edeSmrg pic_mode=default 2132e0963edeSmrg fi 2133e0963edeSmrg 2134e0963edeSmrg # Calculate the filename of the output object if compiler does 2135e0963edeSmrg # not support -o with -c 2136e0963edeSmrg if test "$compiler_c_o" = no; then 213749e108a1Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 2138e0963edeSmrg lockfile="$output_obj.lock" 2139e0963edeSmrg else 2140e0963edeSmrg output_obj= 2141e0963edeSmrg need_locks=no 2142e0963edeSmrg lockfile= 2143e0963edeSmrg fi 2144e0963edeSmrg 2145e0963edeSmrg # Lock this critical section if it is needed 2146e0963edeSmrg # We use this script file to make the link, it avoids creating a new file 2147e0963edeSmrg if test "$need_locks" = yes; then 2148f05b35a2Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 2149f05b35a2Smrg func_echo "Waiting for $lockfile to be removed" 2150e0963edeSmrg sleep 2 2151e0963edeSmrg done 2152e0963edeSmrg elif test "$need_locks" = warn; then 2153e0963edeSmrg if test -f "$lockfile"; then 2154f05b35a2Smrg $ECHO "\ 2155e0963edeSmrg*** ERROR, $lockfile exists and contains: 2156e0963edeSmrg`cat $lockfile 2>/dev/null` 2157e0963edeSmrg 2158e0963edeSmrgThis indicates that another process is trying to use the same 2159e0963edeSmrgtemporary object file, and libtool could not work around it because 2160e0963edeSmrgyour compiler does not support \`-c' and \`-o' together. If you 2161e0963edeSmrgrepeat this compilation, it may succeed, by chance, but you had better 2162e0963edeSmrgavoid parallel builds (make -j) in this platform, or get a better 2163e0963edeSmrgcompiler." 2164e0963edeSmrg 2165f05b35a2Smrg $opt_dry_run || $RM $removelist 2166e0963edeSmrg exit $EXIT_FAILURE 2167e0963edeSmrg fi 216867ab2ff2Smrg func_append removelist " $output_obj" 2169f05b35a2Smrg $ECHO "$srcfile" > "$lockfile" 2170e0963edeSmrg fi 2171e0963edeSmrg 2172f05b35a2Smrg $opt_dry_run || $RM $removelist 217367ab2ff2Smrg func_append removelist " $lockfile" 2174f05b35a2Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 2175f05b35a2Smrg 217667ab2ff2Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 217767ab2ff2Smrg srcfile=$func_to_tool_file_result 2178f05b35a2Smrg func_quote_for_eval "$srcfile" 2179f05b35a2Smrg qsrcfile=$func_quote_for_eval_result 2180e0963edeSmrg 2181e0963edeSmrg # Only build a PIC object if we are building libtool libraries. 2182e0963edeSmrg if test "$build_libtool_libs" = yes; then 2183e0963edeSmrg # Without this assignment, base_compile gets emptied. 2184e0963edeSmrg fbsd_hideous_sh_bug=$base_compile 2185e0963edeSmrg 2186e0963edeSmrg if test "$pic_mode" != no; then 2187e0963edeSmrg command="$base_compile $qsrcfile $pic_flag" 2188e0963edeSmrg else 2189e0963edeSmrg # Don't build PIC code 2190e0963edeSmrg command="$base_compile $qsrcfile" 2191e0963edeSmrg fi 2192e0963edeSmrg 2193f05b35a2Smrg func_mkdir_p "$xdir$objdir" 2194e0963edeSmrg 2195e0963edeSmrg if test -z "$output_obj"; then 2196e0963edeSmrg # Place PIC objects in $objdir 219767ab2ff2Smrg func_append command " -o $lobj" 2198e0963edeSmrg fi 2199e0963edeSmrg 2200f05b35a2Smrg func_show_eval_locale "$command" \ 2201f05b35a2Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 2202e0963edeSmrg 2203e0963edeSmrg if test "$need_locks" = warn && 2204e0963edeSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2205f05b35a2Smrg $ECHO "\ 2206e0963edeSmrg*** ERROR, $lockfile contains: 2207e0963edeSmrg`cat $lockfile 2>/dev/null` 2208e0963edeSmrg 2209e0963edeSmrgbut it should contain: 2210e0963edeSmrg$srcfile 2211e0963edeSmrg 2212e0963edeSmrgThis indicates that another process is trying to use the same 2213e0963edeSmrgtemporary object file, and libtool could not work around it because 2214e0963edeSmrgyour compiler does not support \`-c' and \`-o' together. If you 2215e0963edeSmrgrepeat this compilation, it may succeed, by chance, but you had better 2216e0963edeSmrgavoid parallel builds (make -j) in this platform, or get a better 2217e0963edeSmrgcompiler." 2218e0963edeSmrg 2219f05b35a2Smrg $opt_dry_run || $RM $removelist 2220e0963edeSmrg exit $EXIT_FAILURE 2221e0963edeSmrg fi 2222e0963edeSmrg 2223e0963edeSmrg # Just move the object if needed, then go on to compile the next one 2224e0963edeSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 2225f05b35a2Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 2226f05b35a2Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2227e0963edeSmrg fi 2228e0963edeSmrg 2229e0963edeSmrg # Allow error messages only from the first compilation. 2230e0963edeSmrg if test "$suppress_opt" = yes; then 2231f05b35a2Smrg suppress_output=' >/dev/null 2>&1' 2232e0963edeSmrg fi 2233e0963edeSmrg fi 2234e0963edeSmrg 2235e0963edeSmrg # Only build a position-dependent object if we build old libraries. 2236e0963edeSmrg if test "$build_old_libs" = yes; then 2237e0963edeSmrg if test "$pic_mode" != yes; then 2238e0963edeSmrg # Don't build PIC code 2239f05b35a2Smrg command="$base_compile $qsrcfile$pie_flag" 2240e0963edeSmrg else 2241e0963edeSmrg command="$base_compile $qsrcfile $pic_flag" 2242e0963edeSmrg fi 2243e0963edeSmrg if test "$compiler_c_o" = yes; then 224467ab2ff2Smrg func_append command " -o $obj" 2245e0963edeSmrg fi 2246e0963edeSmrg 2247e0963edeSmrg # Suppress compiler output if we already did a PIC compilation. 224867ab2ff2Smrg func_append command "$suppress_output" 2249f05b35a2Smrg func_show_eval_locale "$command" \ 2250f05b35a2Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 2251e0963edeSmrg 2252e0963edeSmrg if test "$need_locks" = warn && 2253e0963edeSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2254f05b35a2Smrg $ECHO "\ 2255e0963edeSmrg*** ERROR, $lockfile contains: 2256e0963edeSmrg`cat $lockfile 2>/dev/null` 2257e0963edeSmrg 2258e0963edeSmrgbut it should contain: 2259e0963edeSmrg$srcfile 2260e0963edeSmrg 2261e0963edeSmrgThis indicates that another process is trying to use the same 2262e0963edeSmrgtemporary object file, and libtool could not work around it because 2263e0963edeSmrgyour compiler does not support \`-c' and \`-o' together. If you 2264e0963edeSmrgrepeat this compilation, it may succeed, by chance, but you had better 2265e0963edeSmrgavoid parallel builds (make -j) in this platform, or get a better 2266e0963edeSmrgcompiler." 2267e0963edeSmrg 2268f05b35a2Smrg $opt_dry_run || $RM $removelist 2269e0963edeSmrg exit $EXIT_FAILURE 2270e0963edeSmrg fi 2271e0963edeSmrg 2272e0963edeSmrg # Just move the object if needed 2273e0963edeSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 2274f05b35a2Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 2275f05b35a2Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2276e0963edeSmrg fi 2277e0963edeSmrg fi 2278e0963edeSmrg 2279f05b35a2Smrg $opt_dry_run || { 2280f05b35a2Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 2281e0963edeSmrg 2282f05b35a2Smrg # Unlock the critical section if it was locked 2283f05b35a2Smrg if test "$need_locks" != no; then 2284f05b35a2Smrg removelist=$lockfile 2285f05b35a2Smrg $RM "$lockfile" 2286f05b35a2Smrg fi 2287f05b35a2Smrg } 2288e0963edeSmrg 2289e0963edeSmrg exit $EXIT_SUCCESS 2290f05b35a2Smrg} 2291e0963edeSmrg 2292f05b35a2Smrg$opt_help || { 229367ab2ff2Smrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 2294f05b35a2Smrg} 2295e0963edeSmrg 2296f05b35a2Smrgfunc_mode_help () 2297f05b35a2Smrg{ 2298f05b35a2Smrg # We need to display help for each of the modes. 229967ab2ff2Smrg case $opt_mode in 2300f05b35a2Smrg "") 2301f05b35a2Smrg # Generic help is extracted from the usage comments 2302f05b35a2Smrg # at the start of this file. 2303f05b35a2Smrg func_help 2304f05b35a2Smrg ;; 2305e0963edeSmrg 2306f05b35a2Smrg clean) 2307f05b35a2Smrg $ECHO \ 2308f05b35a2Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 2309e0963edeSmrg 2310f05b35a2SmrgRemove files from the build directory. 2311e0963edeSmrg 2312f05b35a2SmrgRM is the name of the program to use to delete files associated with each FILE 2313f05b35a2Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2314f05b35a2Smrgto RM. 2315e0963edeSmrg 2316f05b35a2SmrgIf FILE is a libtool library, object or program, all the files associated 2317f05b35a2Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 2318f05b35a2Smrg ;; 2319e0963edeSmrg 2320f05b35a2Smrg compile) 2321f05b35a2Smrg $ECHO \ 2322f05b35a2Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 2323e0963edeSmrg 2324f05b35a2SmrgCompile a source file into a libtool library object. 2325e0963edeSmrg 2326f05b35a2SmrgThis mode accepts the following additional options: 2327e0963edeSmrg 2328f05b35a2Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 2329f05b35a2Smrg -no-suppress do not suppress compiler output for multiple passes 233049e108a1Smrg -prefer-pic try to build PIC objects only 233149e108a1Smrg -prefer-non-pic try to build non-PIC objects only 2332f05b35a2Smrg -shared do not build a \`.o' file suitable for static linking 2333f05b35a2Smrg -static only build a \`.o' file suitable for static linking 233449e108a1Smrg -Wc,FLAG pass FLAG directly to the compiler 2335e0963edeSmrg 2336f05b35a2SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 2337f05b35a2Smrgfrom the given SOURCEFILE. 2338e0963edeSmrg 2339f05b35a2SmrgThe output file name is determined by removing the directory component from 2340f05b35a2SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 2341f05b35a2Smrglibrary object suffix, \`.lo'." 2342f05b35a2Smrg ;; 2343e0963edeSmrg 2344f05b35a2Smrg execute) 2345f05b35a2Smrg $ECHO \ 2346f05b35a2Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 2347e0963edeSmrg 2348f05b35a2SmrgAutomatically set library path, then run a program. 2349e0963edeSmrg 2350f05b35a2SmrgThis mode accepts the following additional options: 2351e0963edeSmrg 2352f05b35a2Smrg -dlopen FILE add the directory containing FILE to the library path 2353e0963edeSmrg 2354f05b35a2SmrgThis mode sets the library path environment variable according to \`-dlopen' 2355f05b35a2Smrgflags. 2356e0963edeSmrg 2357f05b35a2SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 2358f05b35a2Smrginto their corresponding uninstalled binary, and any of their required library 2359f05b35a2Smrgdirectories are added to the library path. 2360e0963edeSmrg 2361f05b35a2SmrgThen, COMMAND is executed, with ARGS as arguments." 2362f05b35a2Smrg ;; 2363e0963edeSmrg 2364f05b35a2Smrg finish) 2365f05b35a2Smrg $ECHO \ 2366f05b35a2Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 2367e0963edeSmrg 2368f05b35a2SmrgComplete the installation of libtool libraries. 2369e0963edeSmrg 2370f05b35a2SmrgEach LIBDIR is a directory that contains libtool libraries. 2371e0963edeSmrg 2372f05b35a2SmrgThe commands that this mode executes may require superuser privileges. Use 2373f05b35a2Smrgthe \`--dry-run' option if you just want to see what would be executed." 2374f05b35a2Smrg ;; 2375e0963edeSmrg 2376f05b35a2Smrg install) 2377f05b35a2Smrg $ECHO \ 2378f05b35a2Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 2379e0963edeSmrg 2380f05b35a2SmrgInstall executables or libraries. 2381e0963edeSmrg 2382f05b35a2SmrgINSTALL-COMMAND is the installation command. The first component should be 2383f05b35a2Smrgeither the \`install' or \`cp' program. 2384e0963edeSmrg 2385f05b35a2SmrgThe following components of INSTALL-COMMAND are treated specially: 2386e0963edeSmrg 238749e108a1Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 2388e0963edeSmrg 2389f05b35a2SmrgThe rest of the components are interpreted as arguments to that command (only 2390f05b35a2SmrgBSD-compatible install options are recognized)." 2391f05b35a2Smrg ;; 2392e0963edeSmrg 2393f05b35a2Smrg link) 2394f05b35a2Smrg $ECHO \ 2395f05b35a2Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 2396e0963edeSmrg 2397f05b35a2SmrgLink object files or libraries together to form another library, or to 2398f05b35a2Smrgcreate an executable program. 2399e0963edeSmrg 2400f05b35a2SmrgLINK-COMMAND is a command using the C compiler that you would use to create 2401f05b35a2Smrga program from several object files. 2402e0963edeSmrg 2403f05b35a2SmrgThe following components of LINK-COMMAND are treated specially: 2404e0963edeSmrg 2405f05b35a2Smrg -all-static do not do any dynamic linking at all 2406f05b35a2Smrg -avoid-version do not add a version suffix if possible 240749e108a1Smrg -bindir BINDIR specify path to binaries directory (for systems where 240849e108a1Smrg libraries must be found in the PATH setting at runtime) 2409f05b35a2Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 2410f05b35a2Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 2411f05b35a2Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 2412f05b35a2Smrg -export-symbols SYMFILE 2413f05b35a2Smrg try to export only the symbols listed in SYMFILE 2414f05b35a2Smrg -export-symbols-regex REGEX 2415f05b35a2Smrg try to export only the symbols matching REGEX 2416f05b35a2Smrg -LLIBDIR search LIBDIR for required installed libraries 2417f05b35a2Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 2418f05b35a2Smrg -module build a library that can dlopened 2419f05b35a2Smrg -no-fast-install disable the fast-install mode 2420f05b35a2Smrg -no-install link a not-installable executable 2421f05b35a2Smrg -no-undefined declare that a library does not refer to external symbols 2422f05b35a2Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 2423f05b35a2Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 2424f05b35a2Smrg -precious-files-regex REGEX 2425f05b35a2Smrg don't remove output files matching REGEX 2426f05b35a2Smrg -release RELEASE specify package release information 2427f05b35a2Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 2428f05b35a2Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 2429f05b35a2Smrg -shared only do dynamic linking of libtool libraries 2430f05b35a2Smrg -shrext SUFFIX override the standard shared library file extension 2431f05b35a2Smrg -static do not do any dynamic linking of uninstalled libtool libraries 2432f05b35a2Smrg -static-libtool-libs 2433f05b35a2Smrg do not do any dynamic linking of libtool libraries 2434f05b35a2Smrg -version-info CURRENT[:REVISION[:AGE]] 2435f05b35a2Smrg specify library version info [each variable defaults to 0] 2436f05b35a2Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 243749e108a1Smrg -Wc,FLAG 243849e108a1Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 243949e108a1Smrg -Wl,FLAG 244049e108a1Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 244149e108a1Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 2442e0963edeSmrg 2443f05b35a2SmrgAll other options (arguments beginning with \`-') are ignored. 2444e0963edeSmrg 2445f05b35a2SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 2446f05b35a2Smrgtreated as uninstalled libtool libraries, other files are standard or library 2447f05b35a2Smrgobject files. 2448e0963edeSmrg 2449f05b35a2SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 2450f05b35a2Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 2451f05b35a2Smrgrequired, except when creating a convenience library. 2452e0963edeSmrg 2453f05b35a2SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 2454f05b35a2Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 2455e0963edeSmrg 2456f05b35a2SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 2457f05b35a2Smrgis created, otherwise an executable program is created." 2458e0963edeSmrg ;; 2459e0963edeSmrg 2460f05b35a2Smrg uninstall) 2461f05b35a2Smrg $ECHO \ 2462f05b35a2Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 2463e0963edeSmrg 2464f05b35a2SmrgRemove libraries from an installation directory. 2465e0963edeSmrg 2466f05b35a2SmrgRM is the name of the program to use to delete files associated with each FILE 2467f05b35a2Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2468f05b35a2Smrgto RM. 2469e0963edeSmrg 2470f05b35a2SmrgIf FILE is a libtool library, all the files associated with it are deleted. 2471f05b35a2SmrgOtherwise, only FILE itself is deleted using RM." 2472f05b35a2Smrg ;; 2473e0963edeSmrg 2474f05b35a2Smrg *) 247567ab2ff2Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 2476f05b35a2Smrg ;; 2477f05b35a2Smrg esac 2478e0963edeSmrg 247949e108a1Smrg echo 2480f05b35a2Smrg $ECHO "Try \`$progname --help' for more information about other modes." 2481f05b35a2Smrg} 2482e0963edeSmrg 248349e108a1Smrg# Now that we've collected a possible --mode arg, show help if necessary 248449e108a1Smrgif $opt_help; then 248549e108a1Smrg if test "$opt_help" = :; then 248649e108a1Smrg func_mode_help 248749e108a1Smrg else 248849e108a1Smrg { 248949e108a1Smrg func_help noexit 249067ab2ff2Smrg for opt_mode in compile link execute install finish uninstall clean; do 249149e108a1Smrg func_mode_help 249249e108a1Smrg done 249349e108a1Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 249449e108a1Smrg { 249549e108a1Smrg func_help noexit 249667ab2ff2Smrg for opt_mode in compile link execute install finish uninstall clean; do 249749e108a1Smrg echo 249849e108a1Smrg func_mode_help 249949e108a1Smrg done 250049e108a1Smrg } | 250149e108a1Smrg sed '1d 250249e108a1Smrg /^When reporting/,/^Report/{ 250349e108a1Smrg H 250449e108a1Smrg d 250549e108a1Smrg } 250649e108a1Smrg $x 250749e108a1Smrg /information about other modes/d 250849e108a1Smrg /more detailed .*MODE/d 250949e108a1Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 251049e108a1Smrg fi 251149e108a1Smrg exit $? 251249e108a1Smrgfi 2513e0963edeSmrg 2514e0963edeSmrg 2515f05b35a2Smrg# func_mode_execute arg... 2516f05b35a2Smrgfunc_mode_execute () 2517f05b35a2Smrg{ 2518f05b35a2Smrg $opt_debug 2519f05b35a2Smrg # The first argument is the command name. 2520f05b35a2Smrg cmd="$nonopt" 2521f05b35a2Smrg test -z "$cmd" && \ 2522f05b35a2Smrg func_fatal_help "you must specify a COMMAND" 2523e0963edeSmrg 2524f05b35a2Smrg # Handle -dlopen flags immediately. 252567ab2ff2Smrg for file in $opt_dlopen; do 2526f05b35a2Smrg test -f "$file" \ 2527f05b35a2Smrg || func_fatal_help "\`$file' is not a file" 2528e0963edeSmrg 2529f05b35a2Smrg dir= 2530f05b35a2Smrg case $file in 2531f05b35a2Smrg *.la) 253267ab2ff2Smrg func_resolve_sysroot "$file" 253367ab2ff2Smrg file=$func_resolve_sysroot_result 253467ab2ff2Smrg 2535f05b35a2Smrg # Check to see that this really is a libtool archive. 2536f05b35a2Smrg func_lalib_unsafe_p "$file" \ 2537f05b35a2Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 2538e0963edeSmrg 2539f05b35a2Smrg # Read the libtool library. 2540f05b35a2Smrg dlname= 2541f05b35a2Smrg library_names= 2542f05b35a2Smrg func_source "$file" 2543e0963edeSmrg 2544f05b35a2Smrg # Skip this library if it cannot be dlopened. 2545f05b35a2Smrg if test -z "$dlname"; then 2546f05b35a2Smrg # Warn if it was a shared library. 2547f05b35a2Smrg test -n "$library_names" && \ 2548f05b35a2Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 2549f05b35a2Smrg continue 2550f05b35a2Smrg fi 2551e0963edeSmrg 2552f05b35a2Smrg func_dirname "$file" "" "." 2553f05b35a2Smrg dir="$func_dirname_result" 2554e0963edeSmrg 2555f05b35a2Smrg if test -f "$dir/$objdir/$dlname"; then 255667ab2ff2Smrg func_append dir "/$objdir" 2557f05b35a2Smrg else 2558f05b35a2Smrg if test ! -f "$dir/$dlname"; then 2559f05b35a2Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 2560f05b35a2Smrg fi 2561f05b35a2Smrg fi 2562e0963edeSmrg ;; 2563e0963edeSmrg 2564f05b35a2Smrg *.lo) 2565f05b35a2Smrg # Just add the directory containing the .lo file. 2566f05b35a2Smrg func_dirname "$file" "" "." 2567f05b35a2Smrg dir="$func_dirname_result" 2568e0963edeSmrg ;; 2569e0963edeSmrg 2570f05b35a2Smrg *) 2571f05b35a2Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 2572e0963edeSmrg continue 2573e0963edeSmrg ;; 2574f05b35a2Smrg esac 2575e0963edeSmrg 2576f05b35a2Smrg # Get the absolute pathname. 2577f05b35a2Smrg absdir=`cd "$dir" && pwd` 2578f05b35a2Smrg test -n "$absdir" && dir="$absdir" 2579e0963edeSmrg 2580f05b35a2Smrg # Now add the directory to shlibpath_var. 2581f05b35a2Smrg if eval "test -z \"\$$shlibpath_var\""; then 2582f05b35a2Smrg eval "$shlibpath_var=\"\$dir\"" 2583f05b35a2Smrg else 2584f05b35a2Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 2585f05b35a2Smrg fi 2586f05b35a2Smrg done 2587e0963edeSmrg 2588f05b35a2Smrg # This variable tells wrapper scripts just to set shlibpath_var 2589f05b35a2Smrg # rather than running their programs. 2590f05b35a2Smrg libtool_execute_magic="$magic" 2591e0963edeSmrg 2592f05b35a2Smrg # Check if any of the arguments is a wrapper script. 2593f05b35a2Smrg args= 2594f05b35a2Smrg for file 2595f05b35a2Smrg do 2596f05b35a2Smrg case $file in 259749e108a1Smrg -* | *.la | *.lo ) ;; 2598f05b35a2Smrg *) 2599f05b35a2Smrg # Do a test to see if this is really a libtool program. 2600f05b35a2Smrg if func_ltwrapper_script_p "$file"; then 2601f05b35a2Smrg func_source "$file" 2602f05b35a2Smrg # Transform arg to wrapped name. 2603f05b35a2Smrg file="$progdir/$program" 2604f05b35a2Smrg elif func_ltwrapper_executable_p "$file"; then 2605f05b35a2Smrg func_ltwrapper_scriptname "$file" 2606f05b35a2Smrg func_source "$func_ltwrapper_scriptname_result" 2607f05b35a2Smrg # Transform arg to wrapped name. 2608f05b35a2Smrg file="$progdir/$program" 2609f05b35a2Smrg fi 2610f05b35a2Smrg ;; 2611f05b35a2Smrg esac 2612f05b35a2Smrg # Quote arguments (to preserve shell metacharacters). 261367ab2ff2Smrg func_append_quoted args "$file" 2614f05b35a2Smrg done 2615e0963edeSmrg 2616f05b35a2Smrg if test "X$opt_dry_run" = Xfalse; then 2617f05b35a2Smrg if test -n "$shlibpath_var"; then 2618f05b35a2Smrg # Export the shlibpath_var. 2619f05b35a2Smrg eval "export $shlibpath_var" 2620f05b35a2Smrg fi 2621e0963edeSmrg 2622f05b35a2Smrg # Restore saved environment variables 2623f05b35a2Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 2624f05b35a2Smrg do 2625f05b35a2Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 2626f05b35a2Smrg $lt_var=\$save_$lt_var; export $lt_var 2627e0963edeSmrg else 2628f05b35a2Smrg $lt_unset $lt_var 2629f05b35a2Smrg fi" 2630f05b35a2Smrg done 2631e0963edeSmrg 2632f05b35a2Smrg # Now prepare to actually exec the command. 2633f05b35a2Smrg exec_cmd="\$cmd$args" 2634f05b35a2Smrg else 2635f05b35a2Smrg # Display what would be done. 2636f05b35a2Smrg if test -n "$shlibpath_var"; then 2637f05b35a2Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 263849e108a1Smrg echo "export $shlibpath_var" 2639f05b35a2Smrg fi 2640f05b35a2Smrg $ECHO "$cmd$args" 2641f05b35a2Smrg exit $EXIT_SUCCESS 2642f05b35a2Smrg fi 2643f05b35a2Smrg} 2644e0963edeSmrg 264567ab2ff2Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 2646e0963edeSmrg 2647e0963edeSmrg 2648f05b35a2Smrg# func_mode_finish arg... 2649f05b35a2Smrgfunc_mode_finish () 2650f05b35a2Smrg{ 2651f05b35a2Smrg $opt_debug 265267ab2ff2Smrg libs= 265367ab2ff2Smrg libdirs= 2654f05b35a2Smrg admincmds= 2655e0963edeSmrg 265667ab2ff2Smrg for opt in "$nonopt" ${1+"$@"} 265767ab2ff2Smrg do 265867ab2ff2Smrg if test -d "$opt"; then 265967ab2ff2Smrg func_append libdirs " $opt" 266067ab2ff2Smrg 266167ab2ff2Smrg elif test -f "$opt"; then 266267ab2ff2Smrg if func_lalib_unsafe_p "$opt"; then 266367ab2ff2Smrg func_append libs " $opt" 266467ab2ff2Smrg else 266567ab2ff2Smrg func_warning "\`$opt' is not a valid libtool archive" 266667ab2ff2Smrg fi 266767ab2ff2Smrg 266867ab2ff2Smrg else 266967ab2ff2Smrg func_fatal_error "invalid argument \`$opt'" 267067ab2ff2Smrg fi 267167ab2ff2Smrg done 267267ab2ff2Smrg 267367ab2ff2Smrg if test -n "$libs"; then 267467ab2ff2Smrg if test -n "$lt_sysroot"; then 267567ab2ff2Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 267667ab2ff2Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 267767ab2ff2Smrg else 267867ab2ff2Smrg sysroot_cmd= 267967ab2ff2Smrg fi 268067ab2ff2Smrg 268167ab2ff2Smrg # Remove sysroot references 268267ab2ff2Smrg if $opt_dry_run; then 268367ab2ff2Smrg for lib in $libs; do 268467ab2ff2Smrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 268567ab2ff2Smrg done 268667ab2ff2Smrg else 268767ab2ff2Smrg tmpdir=`func_mktempdir` 268867ab2ff2Smrg for lib in $libs; do 268967ab2ff2Smrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 269067ab2ff2Smrg > $tmpdir/tmp-la 269167ab2ff2Smrg mv -f $tmpdir/tmp-la $lib 269267ab2ff2Smrg done 269367ab2ff2Smrg ${RM}r "$tmpdir" 269467ab2ff2Smrg fi 269567ab2ff2Smrg fi 2696e0963edeSmrg 269767ab2ff2Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2698f05b35a2Smrg for libdir in $libdirs; do 2699f05b35a2Smrg if test -n "$finish_cmds"; then 2700f05b35a2Smrg # Do each command in the finish commands. 2701f05b35a2Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 2702f05b35a2Smrg'"$cmd"'"' 2703e0963edeSmrg fi 2704f05b35a2Smrg if test -n "$finish_eval"; then 2705f05b35a2Smrg # Do the single finish_eval. 2706f05b35a2Smrg eval cmds=\"$finish_eval\" 270767ab2ff2Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 2708f05b35a2Smrg $cmds" 2709f05b35a2Smrg fi 2710f05b35a2Smrg done 2711f05b35a2Smrg fi 2712e0963edeSmrg 2713f05b35a2Smrg # Exit here if they wanted silent mode. 2714f05b35a2Smrg $opt_silent && exit $EXIT_SUCCESS 2715e0963edeSmrg 271667ab2ff2Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 271767ab2ff2Smrg echo "----------------------------------------------------------------------" 271867ab2ff2Smrg echo "Libraries have been installed in:" 271967ab2ff2Smrg for libdir in $libdirs; do 272067ab2ff2Smrg $ECHO " $libdir" 272167ab2ff2Smrg done 272267ab2ff2Smrg echo 272367ab2ff2Smrg echo "If you ever happen to want to link against installed libraries" 272467ab2ff2Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 272567ab2ff2Smrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 272667ab2ff2Smrg echo "flag during linking and do at least one of the following:" 272767ab2ff2Smrg if test -n "$shlibpath_var"; then 272867ab2ff2Smrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 272967ab2ff2Smrg echo " during execution" 273067ab2ff2Smrg fi 273167ab2ff2Smrg if test -n "$runpath_var"; then 273267ab2ff2Smrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 273367ab2ff2Smrg echo " during linking" 273467ab2ff2Smrg fi 273567ab2ff2Smrg if test -n "$hardcode_libdir_flag_spec"; then 273667ab2ff2Smrg libdir=LIBDIR 273767ab2ff2Smrg eval flag=\"$hardcode_libdir_flag_spec\" 2738e0963edeSmrg 273967ab2ff2Smrg $ECHO " - use the \`$flag' linker flag" 274067ab2ff2Smrg fi 274167ab2ff2Smrg if test -n "$admincmds"; then 274267ab2ff2Smrg $ECHO " - have your system administrator run these commands:$admincmds" 274367ab2ff2Smrg fi 274467ab2ff2Smrg if test -f /etc/ld.so.conf; then 274567ab2ff2Smrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 274667ab2ff2Smrg fi 274767ab2ff2Smrg echo 2748f05b35a2Smrg 274967ab2ff2Smrg echo "See any operating system documentation about shared libraries for" 275067ab2ff2Smrg case $host in 275167ab2ff2Smrg solaris2.[6789]|solaris2.1[0-9]) 275267ab2ff2Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 275367ab2ff2Smrg echo "pages." 275467ab2ff2Smrg ;; 275567ab2ff2Smrg *) 275667ab2ff2Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 275767ab2ff2Smrg ;; 275867ab2ff2Smrg esac 275967ab2ff2Smrg echo "----------------------------------------------------------------------" 276067ab2ff2Smrg fi 2761f05b35a2Smrg exit $EXIT_SUCCESS 2762f05b35a2Smrg} 2763f05b35a2Smrg 276467ab2ff2Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 2765f05b35a2Smrg 2766f05b35a2Smrg 2767f05b35a2Smrg# func_mode_install arg... 2768f05b35a2Smrgfunc_mode_install () 2769f05b35a2Smrg{ 2770f05b35a2Smrg $opt_debug 2771f05b35a2Smrg # There may be an optional sh(1) argument at the beginning of 2772f05b35a2Smrg # install_prog (especially on Windows NT). 2773f05b35a2Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 2774f05b35a2Smrg # Allow the use of GNU shtool's install command. 277549e108a1Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 2776f05b35a2Smrg # Aesthetically quote it. 2777f05b35a2Smrg func_quote_for_eval "$nonopt" 2778f05b35a2Smrg install_prog="$func_quote_for_eval_result " 2779f05b35a2Smrg arg=$1 2780f05b35a2Smrg shift 2781f05b35a2Smrg else 2782f05b35a2Smrg install_prog= 2783f05b35a2Smrg arg=$nonopt 2784f05b35a2Smrg fi 2785f05b35a2Smrg 2786f05b35a2Smrg # The real first argument should be the name of the installation program. 2787f05b35a2Smrg # Aesthetically quote it. 2788f05b35a2Smrg func_quote_for_eval "$arg" 278967ab2ff2Smrg func_append install_prog "$func_quote_for_eval_result" 279049e108a1Smrg install_shared_prog=$install_prog 279149e108a1Smrg case " $install_prog " in 279249e108a1Smrg *[\\\ /]cp\ *) install_cp=: ;; 279349e108a1Smrg *) install_cp=false ;; 279449e108a1Smrg esac 2795f05b35a2Smrg 2796f05b35a2Smrg # We need to accept at least all the BSD install flags. 2797f05b35a2Smrg dest= 2798f05b35a2Smrg files= 2799f05b35a2Smrg opts= 2800f05b35a2Smrg prev= 2801f05b35a2Smrg install_type= 2802f05b35a2Smrg isdir=no 2803f05b35a2Smrg stripme= 280449e108a1Smrg no_mode=: 2805f05b35a2Smrg for arg 2806f05b35a2Smrg do 280749e108a1Smrg arg2= 2808f05b35a2Smrg if test -n "$dest"; then 280967ab2ff2Smrg func_append files " $dest" 2810f05b35a2Smrg dest=$arg 2811f05b35a2Smrg continue 2812f05b35a2Smrg fi 2813f05b35a2Smrg 2814f05b35a2Smrg case $arg in 2815f05b35a2Smrg -d) isdir=yes ;; 2816f05b35a2Smrg -f) 281749e108a1Smrg if $install_cp; then :; else 281849e108a1Smrg prev=$arg 281949e108a1Smrg fi 2820f05b35a2Smrg ;; 2821f05b35a2Smrg -g | -m | -o) 2822f05b35a2Smrg prev=$arg 2823f05b35a2Smrg ;; 2824f05b35a2Smrg -s) 2825f05b35a2Smrg stripme=" -s" 2826f05b35a2Smrg continue 2827f05b35a2Smrg ;; 2828f05b35a2Smrg -*) 2829f05b35a2Smrg ;; 2830f05b35a2Smrg *) 2831f05b35a2Smrg # If the previous option needed an argument, then skip it. 2832f05b35a2Smrg if test -n "$prev"; then 283349e108a1Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 283449e108a1Smrg arg2=$install_override_mode 283549e108a1Smrg no_mode=false 283649e108a1Smrg fi 2837e0963edeSmrg prev= 2838e0963edeSmrg else 2839f05b35a2Smrg dest=$arg 2840f05b35a2Smrg continue 2841e0963edeSmrg fi 2842e0963edeSmrg ;; 2843f05b35a2Smrg esac 2844e0963edeSmrg 2845f05b35a2Smrg # Aesthetically quote the argument. 2846f05b35a2Smrg func_quote_for_eval "$arg" 284767ab2ff2Smrg func_append install_prog " $func_quote_for_eval_result" 284849e108a1Smrg if test -n "$arg2"; then 284949e108a1Smrg func_quote_for_eval "$arg2" 285049e108a1Smrg fi 285167ab2ff2Smrg func_append install_shared_prog " $func_quote_for_eval_result" 2852f05b35a2Smrg done 2853e0963edeSmrg 2854f05b35a2Smrg test -z "$install_prog" && \ 2855f05b35a2Smrg func_fatal_help "you must specify an install program" 2856e0963edeSmrg 2857f05b35a2Smrg test -n "$prev" && \ 2858f05b35a2Smrg func_fatal_help "the \`$prev' option requires an argument" 2859e0963edeSmrg 286049e108a1Smrg if test -n "$install_override_mode" && $no_mode; then 286149e108a1Smrg if $install_cp; then :; else 286249e108a1Smrg func_quote_for_eval "$install_override_mode" 286367ab2ff2Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 286449e108a1Smrg fi 286549e108a1Smrg fi 286649e108a1Smrg 2867f05b35a2Smrg if test -z "$files"; then 2868f05b35a2Smrg if test -z "$dest"; then 2869f05b35a2Smrg func_fatal_help "no file or destination specified" 2870f05b35a2Smrg else 2871f05b35a2Smrg func_fatal_help "you must specify a destination" 2872f05b35a2Smrg fi 2873e0963edeSmrg fi 2874e0963edeSmrg 2875f05b35a2Smrg # Strip any trailing slash from the destination. 2876f05b35a2Smrg func_stripname '' '/' "$dest" 2877f05b35a2Smrg dest=$func_stripname_result 2878e0963edeSmrg 2879f05b35a2Smrg # Check to see that the destination is a directory. 2880f05b35a2Smrg test -d "$dest" && isdir=yes 2881f05b35a2Smrg if test "$isdir" = yes; then 2882f05b35a2Smrg destdir="$dest" 2883f05b35a2Smrg destname= 2884e0963edeSmrg else 2885f05b35a2Smrg func_dirname_and_basename "$dest" "" "." 2886f05b35a2Smrg destdir="$func_dirname_result" 2887f05b35a2Smrg destname="$func_basename_result" 2888e0963edeSmrg 2889f05b35a2Smrg # Not a directory, so check to see that there is only one file specified. 2890f05b35a2Smrg set dummy $files; shift 2891f05b35a2Smrg test "$#" -gt 1 && \ 2892f05b35a2Smrg func_fatal_help "\`$dest' is not a directory" 2893e0963edeSmrg fi 2894f05b35a2Smrg case $destdir in 2895f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 2896e0963edeSmrg *) 2897f05b35a2Smrg for file in $files; do 2898f05b35a2Smrg case $file in 2899f05b35a2Smrg *.lo) ;; 2900f05b35a2Smrg *) 2901f05b35a2Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 2902f05b35a2Smrg ;; 2903f05b35a2Smrg esac 2904f05b35a2Smrg done 2905e0963edeSmrg ;; 2906e0963edeSmrg esac 2907e0963edeSmrg 2908f05b35a2Smrg # This variable tells wrapper scripts just to set variables rather 2909f05b35a2Smrg # than running their programs. 2910f05b35a2Smrg libtool_install_magic="$magic" 2911e0963edeSmrg 2912f05b35a2Smrg staticlibs= 2913f05b35a2Smrg future_libdirs= 2914f05b35a2Smrg current_libdirs= 2915f05b35a2Smrg for file in $files; do 2916e0963edeSmrg 2917f05b35a2Smrg # Do each installation. 2918f05b35a2Smrg case $file in 2919f05b35a2Smrg *.$libext) 2920f05b35a2Smrg # Do the static libraries later. 292167ab2ff2Smrg func_append staticlibs " $file" 2922f05b35a2Smrg ;; 2923f05b35a2Smrg 2924f05b35a2Smrg *.la) 292567ab2ff2Smrg func_resolve_sysroot "$file" 292667ab2ff2Smrg file=$func_resolve_sysroot_result 292767ab2ff2Smrg 2928f05b35a2Smrg # Check to see that this really is a libtool archive. 2929f05b35a2Smrg func_lalib_unsafe_p "$file" \ 2930f05b35a2Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 2931f05b35a2Smrg 2932f05b35a2Smrg library_names= 2933f05b35a2Smrg old_library= 2934f05b35a2Smrg relink_command= 2935f05b35a2Smrg func_source "$file" 2936f05b35a2Smrg 2937f05b35a2Smrg # Add the libdir to current_libdirs if it is the destination. 2938f05b35a2Smrg if test "X$destdir" = "X$libdir"; then 2939f05b35a2Smrg case "$current_libdirs " in 2940f05b35a2Smrg *" $libdir "*) ;; 294167ab2ff2Smrg *) func_append current_libdirs " $libdir" ;; 2942e0963edeSmrg esac 2943f05b35a2Smrg else 2944f05b35a2Smrg # Note the libdir as a future libdir. 2945f05b35a2Smrg case "$future_libdirs " in 2946f05b35a2Smrg *" $libdir "*) ;; 294767ab2ff2Smrg *) func_append future_libdirs " $libdir" ;; 2948f05b35a2Smrg esac 2949f05b35a2Smrg fi 2950e0963edeSmrg 2951f05b35a2Smrg func_dirname "$file" "/" "" 2952f05b35a2Smrg dir="$func_dirname_result" 295367ab2ff2Smrg func_append dir "$objdir" 2954f05b35a2Smrg 2955f05b35a2Smrg if test -n "$relink_command"; then 2956f05b35a2Smrg # Determine the prefix the user has applied to our future dir. 295749e108a1Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 2958f05b35a2Smrg 2959f05b35a2Smrg # Don't allow the user to place us outside of our expected 2960f05b35a2Smrg # location b/c this prevents finding dependent libraries that 2961f05b35a2Smrg # are installed to the same prefix. 2962f05b35a2Smrg # At present, this check doesn't affect windows .dll's that 2963f05b35a2Smrg # are installed into $libdir/../bin (currently, that works fine) 2964f05b35a2Smrg # but it's something to keep an eye on. 2965f05b35a2Smrg test "$inst_prefix_dir" = "$destdir" && \ 2966f05b35a2Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 2967f05b35a2Smrg 2968f05b35a2Smrg if test -n "$inst_prefix_dir"; then 2969f05b35a2Smrg # Stick the inst_prefix_dir data into the link command. 297049e108a1Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 2971f05b35a2Smrg else 297249e108a1Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 2973f05b35a2Smrg fi 2974f05b35a2Smrg 2975f05b35a2Smrg func_warning "relinking \`$file'" 2976f05b35a2Smrg func_show_eval "$relink_command" \ 2977f05b35a2Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 2978f05b35a2Smrg fi 2979f05b35a2Smrg 2980f05b35a2Smrg # See the names of the shared library. 2981f05b35a2Smrg set dummy $library_names; shift 2982f05b35a2Smrg if test -n "$1"; then 2983f05b35a2Smrg realname="$1" 2984f05b35a2Smrg shift 2985f05b35a2Smrg 2986f05b35a2Smrg srcname="$realname" 2987f05b35a2Smrg test -n "$relink_command" && srcname="$realname"T 2988f05b35a2Smrg 2989f05b35a2Smrg # Install the shared library and build the symlinks. 299049e108a1Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 2991f05b35a2Smrg 'exit $?' 2992f05b35a2Smrg tstripme="$stripme" 2993f05b35a2Smrg case $host_os in 2994f05b35a2Smrg cygwin* | mingw* | pw32* | cegcc*) 2995f05b35a2Smrg case $realname in 2996f05b35a2Smrg *.dll.a) 2997f05b35a2Smrg tstripme="" 2998f05b35a2Smrg ;; 2999f05b35a2Smrg esac 3000e0963edeSmrg ;; 3001e0963edeSmrg esac 3002f05b35a2Smrg if test -n "$tstripme" && test -n "$striplib"; then 3003f05b35a2Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 3004e0963edeSmrg fi 3005f05b35a2Smrg 3006f05b35a2Smrg if test "$#" -gt 0; then 3007f05b35a2Smrg # Delete the old symlinks, and create new ones. 3008f05b35a2Smrg # Try `ln -sf' first, because the `ln' binary might depend on 3009f05b35a2Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 3010f05b35a2Smrg # so we also need to try rm && ln -s. 3011f05b35a2Smrg for linkname 3012f05b35a2Smrg do 3013f05b35a2Smrg test "$linkname" != "$realname" \ 3014f05b35a2Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 3015e0963edeSmrg done 3016e0963edeSmrg fi 3017e0963edeSmrg 3018f05b35a2Smrg # Do each command in the postinstall commands. 3019f05b35a2Smrg lib="$destdir/$realname" 3020f05b35a2Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 3021e0963edeSmrg fi 3022e0963edeSmrg 3023f05b35a2Smrg # Install the pseudo-library for information purposes. 3024f05b35a2Smrg func_basename "$file" 3025f05b35a2Smrg name="$func_basename_result" 3026f05b35a2Smrg instname="$dir/$name"i 3027f05b35a2Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 3028e0963edeSmrg 3029f05b35a2Smrg # Maybe install the static library, too. 303067ab2ff2Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 3031f05b35a2Smrg ;; 3032e0963edeSmrg 3033f05b35a2Smrg *.lo) 3034f05b35a2Smrg # Install (i.e. copy) a libtool object. 3035e0963edeSmrg 3036f05b35a2Smrg # Figure out destination file name, if it wasn't already specified. 3037f05b35a2Smrg if test -n "$destname"; then 3038f05b35a2Smrg destfile="$destdir/$destname" 3039f05b35a2Smrg else 3040f05b35a2Smrg func_basename "$file" 3041f05b35a2Smrg destfile="$func_basename_result" 3042f05b35a2Smrg destfile="$destdir/$destfile" 3043e0963edeSmrg fi 3044e0963edeSmrg 3045f05b35a2Smrg # Deduce the name of the destination old-style object file. 3046f05b35a2Smrg case $destfile in 3047f05b35a2Smrg *.lo) 3048f05b35a2Smrg func_lo2o "$destfile" 3049f05b35a2Smrg staticdest=$func_lo2o_result 3050f05b35a2Smrg ;; 3051f05b35a2Smrg *.$objext) 3052f05b35a2Smrg staticdest="$destfile" 3053f05b35a2Smrg destfile= 3054f05b35a2Smrg ;; 3055f05b35a2Smrg *) 3056f05b35a2Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 3057f05b35a2Smrg ;; 3058f05b35a2Smrg esac 3059e0963edeSmrg 3060f05b35a2Smrg # Install the libtool object if requested. 3061f05b35a2Smrg test -n "$destfile" && \ 3062f05b35a2Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 3063e0963edeSmrg 3064f05b35a2Smrg # Install the old object if enabled. 3065f05b35a2Smrg if test "$build_old_libs" = yes; then 3066f05b35a2Smrg # Deduce the name of the old-style object file. 3067f05b35a2Smrg func_lo2o "$file" 3068f05b35a2Smrg staticobj=$func_lo2o_result 3069f05b35a2Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 3070e0963edeSmrg fi 3071f05b35a2Smrg exit $EXIT_SUCCESS 3072f05b35a2Smrg ;; 3073e0963edeSmrg 3074f05b35a2Smrg *) 3075f05b35a2Smrg # Figure out destination file name, if it wasn't already specified. 3076f05b35a2Smrg if test -n "$destname"; then 3077f05b35a2Smrg destfile="$destdir/$destname" 3078f05b35a2Smrg else 3079f05b35a2Smrg func_basename "$file" 3080f05b35a2Smrg destfile="$func_basename_result" 3081f05b35a2Smrg destfile="$destdir/$destfile" 3082f05b35a2Smrg fi 3083e0963edeSmrg 3084f05b35a2Smrg # If the file is missing, and there is a .exe on the end, strip it 3085f05b35a2Smrg # because it is most likely a libtool script we actually want to 3086f05b35a2Smrg # install 3087f05b35a2Smrg stripped_ext="" 3088f05b35a2Smrg case $file in 3089f05b35a2Smrg *.exe) 3090f05b35a2Smrg if test ! -f "$file"; then 3091f05b35a2Smrg func_stripname '' '.exe' "$file" 3092f05b35a2Smrg file=$func_stripname_result 3093f05b35a2Smrg stripped_ext=".exe" 3094f05b35a2Smrg fi 3095f05b35a2Smrg ;; 3096f05b35a2Smrg esac 3097f05b35a2Smrg 3098f05b35a2Smrg # Do a test to see if this is really a libtool program. 3099f05b35a2Smrg case $host in 3100f05b35a2Smrg *cygwin* | *mingw*) 3101f05b35a2Smrg if func_ltwrapper_executable_p "$file"; then 3102f05b35a2Smrg func_ltwrapper_scriptname "$file" 3103f05b35a2Smrg wrapper=$func_ltwrapper_scriptname_result 3104f05b35a2Smrg else 3105f05b35a2Smrg func_stripname '' '.exe' "$file" 3106f05b35a2Smrg wrapper=$func_stripname_result 3107f05b35a2Smrg fi 3108f05b35a2Smrg ;; 3109e0963edeSmrg *) 3110f05b35a2Smrg wrapper=$file 3111f05b35a2Smrg ;; 3112f05b35a2Smrg esac 3113f05b35a2Smrg if func_ltwrapper_script_p "$wrapper"; then 3114f05b35a2Smrg notinst_deplibs= 3115f05b35a2Smrg relink_command= 3116f05b35a2Smrg 3117f05b35a2Smrg func_source "$wrapper" 3118f05b35a2Smrg 3119f05b35a2Smrg # Check the variables that should have been set. 3120f05b35a2Smrg test -z "$generated_by_libtool_version" && \ 3121f05b35a2Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 3122f05b35a2Smrg 3123f05b35a2Smrg finalize=yes 3124f05b35a2Smrg for lib in $notinst_deplibs; do 3125f05b35a2Smrg # Check to see that each library is installed. 3126f05b35a2Smrg libdir= 3127f05b35a2Smrg if test -f "$lib"; then 3128f05b35a2Smrg func_source "$lib" 3129f05b35a2Smrg fi 313049e108a1Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 3131f05b35a2Smrg if test -n "$libdir" && test ! -f "$libfile"; then 3132f05b35a2Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 3133f05b35a2Smrg finalize=no 3134f05b35a2Smrg fi 3135f05b35a2Smrg done 3136f05b35a2Smrg 3137f05b35a2Smrg relink_command= 3138f05b35a2Smrg func_source "$wrapper" 3139f05b35a2Smrg 3140f05b35a2Smrg outputname= 3141f05b35a2Smrg if test "$fast_install" = no && test -n "$relink_command"; then 3142f05b35a2Smrg $opt_dry_run || { 3143f05b35a2Smrg if test "$finalize" = yes; then 3144f05b35a2Smrg tmpdir=`func_mktempdir` 3145f05b35a2Smrg func_basename "$file$stripped_ext" 3146f05b35a2Smrg file="$func_basename_result" 3147f05b35a2Smrg outputname="$tmpdir/$file" 3148f05b35a2Smrg # Replace the output file specification. 314949e108a1Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 3150f05b35a2Smrg 3151f05b35a2Smrg $opt_silent || { 3152f05b35a2Smrg func_quote_for_expand "$relink_command" 3153f05b35a2Smrg eval "func_echo $func_quote_for_expand_result" 3154f05b35a2Smrg } 3155f05b35a2Smrg if eval "$relink_command"; then : 3156f05b35a2Smrg else 3157f05b35a2Smrg func_error "error: relink \`$file' with the above command before installing it" 3158f05b35a2Smrg $opt_dry_run || ${RM}r "$tmpdir" 3159f05b35a2Smrg continue 3160f05b35a2Smrg fi 3161f05b35a2Smrg file="$outputname" 3162f05b35a2Smrg else 3163f05b35a2Smrg func_warning "cannot relink \`$file'" 3164f05b35a2Smrg fi 3165f05b35a2Smrg } 3166f05b35a2Smrg else 3167f05b35a2Smrg # Install the binary that we compiled earlier. 316849e108a1Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 3169e0963edeSmrg fi 3170f05b35a2Smrg fi 3171f05b35a2Smrg 3172f05b35a2Smrg # remove .exe since cygwin /usr/bin/install will append another 3173f05b35a2Smrg # one anyway 3174f05b35a2Smrg case $install_prog,$host in 3175f05b35a2Smrg */usr/bin/install*,*cygwin*) 3176f05b35a2Smrg case $file:$destfile in 3177f05b35a2Smrg *.exe:*.exe) 3178f05b35a2Smrg # this is ok 3179f05b35a2Smrg ;; 3180f05b35a2Smrg *.exe:*) 3181f05b35a2Smrg destfile=$destfile.exe 3182f05b35a2Smrg ;; 3183f05b35a2Smrg *:*.exe) 3184f05b35a2Smrg func_stripname '' '.exe' "$destfile" 3185f05b35a2Smrg destfile=$func_stripname_result 3186f05b35a2Smrg ;; 3187f05b35a2Smrg esac 3188e0963edeSmrg ;; 3189e0963edeSmrg esac 3190f05b35a2Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 3191f05b35a2Smrg $opt_dry_run || if test -n "$outputname"; then 3192f05b35a2Smrg ${RM}r "$tmpdir" 3193f05b35a2Smrg fi 3194f05b35a2Smrg ;; 3195f05b35a2Smrg esac 3196f05b35a2Smrg done 3197e0963edeSmrg 3198f05b35a2Smrg for file in $staticlibs; do 3199f05b35a2Smrg func_basename "$file" 3200f05b35a2Smrg name="$func_basename_result" 3201f05b35a2Smrg 3202f05b35a2Smrg # Set up the ranlib parameters. 3203f05b35a2Smrg oldlib="$destdir/$name" 3204f05b35a2Smrg 3205f05b35a2Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 3206f05b35a2Smrg 3207f05b35a2Smrg if test -n "$stripme" && test -n "$old_striplib"; then 3208f05b35a2Smrg func_show_eval "$old_striplib $oldlib" 'exit $?' 3209f05b35a2Smrg fi 3210f05b35a2Smrg 3211f05b35a2Smrg # Do each command in the postinstall commands. 3212f05b35a2Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 3213f05b35a2Smrg done 3214f05b35a2Smrg 3215f05b35a2Smrg test -n "$future_libdirs" && \ 3216f05b35a2Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 3217f05b35a2Smrg 3218f05b35a2Smrg if test -n "$current_libdirs"; then 3219f05b35a2Smrg # Maybe just do a dry run. 3220f05b35a2Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 3221f05b35a2Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 3222f05b35a2Smrg else 3223f05b35a2Smrg exit $EXIT_SUCCESS 3224f05b35a2Smrg fi 3225f05b35a2Smrg} 3226f05b35a2Smrg 322767ab2ff2Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 3228f05b35a2Smrg 3229f05b35a2Smrg 3230f05b35a2Smrg# func_generate_dlsyms outputname originator pic_p 3231f05b35a2Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 3232f05b35a2Smrg# a dlpreopen symbol table. 3233f05b35a2Smrgfunc_generate_dlsyms () 3234f05b35a2Smrg{ 3235f05b35a2Smrg $opt_debug 3236f05b35a2Smrg my_outputname="$1" 3237f05b35a2Smrg my_originator="$2" 3238f05b35a2Smrg my_pic_p="${3-no}" 3239f05b35a2Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 3240f05b35a2Smrg my_dlsyms= 3241f05b35a2Smrg 3242f05b35a2Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 3243f05b35a2Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 3244f05b35a2Smrg my_dlsyms="${my_outputname}S.c" 3245f05b35a2Smrg else 3246f05b35a2Smrg func_error "not configured to extract global symbols from dlpreopened files" 3247f05b35a2Smrg fi 3248f05b35a2Smrg fi 3249f05b35a2Smrg 3250f05b35a2Smrg if test -n "$my_dlsyms"; then 3251f05b35a2Smrg case $my_dlsyms in 3252f05b35a2Smrg "") ;; 3253f05b35a2Smrg *.c) 3254f05b35a2Smrg # Discover the nlist of each of the dlfiles. 3255f05b35a2Smrg nlist="$output_objdir/${my_outputname}.nm" 3256f05b35a2Smrg 3257f05b35a2Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 3258f05b35a2Smrg 3259f05b35a2Smrg # Parse the name list into a source file. 3260f05b35a2Smrg func_verbose "creating $output_objdir/$my_dlsyms" 3261f05b35a2Smrg 3262f05b35a2Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 3263f05b35a2Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 3264f05b35a2Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 3265f05b35a2Smrg 3266f05b35a2Smrg#ifdef __cplusplus 3267f05b35a2Smrgextern \"C\" { 3268f05b35a2Smrg#endif 3269f05b35a2Smrg 327049e108a1Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 327149e108a1Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 327249e108a1Smrg#endif 327349e108a1Smrg 327467ab2ff2Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 327567ab2ff2Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 327667ab2ff2Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 327767ab2ff2Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 327867ab2ff2Smrg# define LT_DLSYM_CONST 327967ab2ff2Smrg#elif defined(__osf__) 328067ab2ff2Smrg/* This system does not cope well with relocations in const data. */ 328167ab2ff2Smrg# define LT_DLSYM_CONST 328267ab2ff2Smrg#else 328367ab2ff2Smrg# define LT_DLSYM_CONST const 328467ab2ff2Smrg#endif 328567ab2ff2Smrg 3286f05b35a2Smrg/* External symbol declarations for the compiler. */\ 3287f05b35a2Smrg" 3288f05b35a2Smrg 3289f05b35a2Smrg if test "$dlself" = yes; then 3290f05b35a2Smrg func_verbose "generating symbol list for \`$output'" 3291f05b35a2Smrg 3292f05b35a2Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 3293f05b35a2Smrg 3294f05b35a2Smrg # Add our own program objects to the symbol list. 329549e108a1Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 3296f05b35a2Smrg for progfile in $progfiles; do 329767ab2ff2Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 329867ab2ff2Smrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 329967ab2ff2Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 3300f05b35a2Smrg done 3301f05b35a2Smrg 3302f05b35a2Smrg if test -n "$exclude_expsyms"; then 3303f05b35a2Smrg $opt_dry_run || { 3304f05b35a2Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 3305f05b35a2Smrg eval '$MV "$nlist"T "$nlist"' 3306f05b35a2Smrg } 3307e0963edeSmrg fi 3308f05b35a2Smrg 3309f05b35a2Smrg if test -n "$export_symbols_regex"; then 3310f05b35a2Smrg $opt_dry_run || { 3311f05b35a2Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 3312f05b35a2Smrg eval '$MV "$nlist"T "$nlist"' 3313f05b35a2Smrg } 3314f05b35a2Smrg fi 3315f05b35a2Smrg 3316f05b35a2Smrg # Prepare the list of exported symbols 3317f05b35a2Smrg if test -z "$export_symbols"; then 3318f05b35a2Smrg export_symbols="$output_objdir/$outputname.exp" 3319f05b35a2Smrg $opt_dry_run || { 3320f05b35a2Smrg $RM $export_symbols 3321f05b35a2Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 3322f05b35a2Smrg case $host in 3323f05b35a2Smrg *cygwin* | *mingw* | *cegcc* ) 3324f05b35a2Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3325f05b35a2Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 3326f05b35a2Smrg ;; 3327f05b35a2Smrg esac 3328f05b35a2Smrg } 3329e0963edeSmrg else 3330f05b35a2Smrg $opt_dry_run || { 3331f05b35a2Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 3332f05b35a2Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 3333f05b35a2Smrg eval '$MV "$nlist"T "$nlist"' 3334f05b35a2Smrg case $host in 333549e108a1Smrg *cygwin* | *mingw* | *cegcc* ) 3336f05b35a2Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3337f05b35a2Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 3338f05b35a2Smrg ;; 3339f05b35a2Smrg esac 3340f05b35a2Smrg } 3341e0963edeSmrg fi 3342f05b35a2Smrg fi 3343e0963edeSmrg 3344f05b35a2Smrg for dlprefile in $dlprefiles; do 3345f05b35a2Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 3346f05b35a2Smrg func_basename "$dlprefile" 3347f05b35a2Smrg name="$func_basename_result" 334867ab2ff2Smrg case $host in 334967ab2ff2Smrg *cygwin* | *mingw* | *cegcc* ) 335067ab2ff2Smrg # if an import library, we need to obtain dlname 335167ab2ff2Smrg if func_win32_import_lib_p "$dlprefile"; then 335267ab2ff2Smrg func_tr_sh "$dlprefile" 335367ab2ff2Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 335467ab2ff2Smrg dlprefile_dlbasename="" 335567ab2ff2Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 335667ab2ff2Smrg # Use subshell, to avoid clobbering current variable values 335767ab2ff2Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 335867ab2ff2Smrg if test -n "$dlprefile_dlname" ; then 335967ab2ff2Smrg func_basename "$dlprefile_dlname" 336067ab2ff2Smrg dlprefile_dlbasename="$func_basename_result" 336167ab2ff2Smrg else 336267ab2ff2Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 336367ab2ff2Smrg $sharedlib_from_linklib_cmd "$dlprefile" 336467ab2ff2Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 336567ab2ff2Smrg fi 336667ab2ff2Smrg fi 336767ab2ff2Smrg $opt_dry_run || { 336867ab2ff2Smrg if test -n "$dlprefile_dlbasename" ; then 336967ab2ff2Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 337067ab2ff2Smrg else 337167ab2ff2Smrg func_warning "Could not compute DLL name from $name" 337267ab2ff2Smrg eval '$ECHO ": $name " >> "$nlist"' 337367ab2ff2Smrg fi 337467ab2ff2Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 337567ab2ff2Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 337667ab2ff2Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 337767ab2ff2Smrg } 337867ab2ff2Smrg else # not an import lib 337967ab2ff2Smrg $opt_dry_run || { 338067ab2ff2Smrg eval '$ECHO ": $name " >> "$nlist"' 338167ab2ff2Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 338267ab2ff2Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 338367ab2ff2Smrg } 338467ab2ff2Smrg fi 338567ab2ff2Smrg ;; 338667ab2ff2Smrg *) 338767ab2ff2Smrg $opt_dry_run || { 338867ab2ff2Smrg eval '$ECHO ": $name " >> "$nlist"' 338967ab2ff2Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 339067ab2ff2Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 339167ab2ff2Smrg } 339267ab2ff2Smrg ;; 339367ab2ff2Smrg esac 3394f05b35a2Smrg done 3395f05b35a2Smrg 3396f05b35a2Smrg $opt_dry_run || { 3397f05b35a2Smrg # Make sure we have at least an empty file. 3398f05b35a2Smrg test -f "$nlist" || : > "$nlist" 3399f05b35a2Smrg 3400f05b35a2Smrg if test -n "$exclude_expsyms"; then 3401f05b35a2Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 3402f05b35a2Smrg $MV "$nlist"T "$nlist" 3403e0963edeSmrg fi 3404f05b35a2Smrg 3405f05b35a2Smrg # Try sorting and uniquifying the output. 3406f05b35a2Smrg if $GREP -v "^: " < "$nlist" | 3407f05b35a2Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 3408f05b35a2Smrg sort -k 3 3409f05b35a2Smrg else 3410f05b35a2Smrg sort +2 3411f05b35a2Smrg fi | 3412f05b35a2Smrg uniq > "$nlist"S; then 3413f05b35a2Smrg : 3414e0963edeSmrg else 3415f05b35a2Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 3416e0963edeSmrg fi 3417e0963edeSmrg 3418f05b35a2Smrg if test -f "$nlist"S; then 3419f05b35a2Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 3420e0963edeSmrg else 342149e108a1Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 3422e0963edeSmrg fi 3423e0963edeSmrg 342449e108a1Smrg echo >> "$output_objdir/$my_dlsyms" "\ 3425e0963edeSmrg 3426f05b35a2Smrg/* The mapping between symbol names and symbols. */ 3427f05b35a2Smrgtypedef struct { 3428f05b35a2Smrg const char *name; 3429f05b35a2Smrg void *address; 3430f05b35a2Smrg} lt_dlsymlist; 343167ab2ff2Smrgextern LT_DLSYM_CONST lt_dlsymlist 3432f05b35a2Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 343367ab2ff2SmrgLT_DLSYM_CONST lt_dlsymlist 3434f05b35a2Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 3435f05b35a2Smrg{\ 3436f05b35a2Smrg { \"$my_originator\", (void *) 0 }," 3437e0963edeSmrg 3438f05b35a2Smrg case $need_lib_prefix in 3439f05b35a2Smrg no) 3440f05b35a2Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 3441f05b35a2Smrg ;; 3442f05b35a2Smrg *) 3443f05b35a2Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 3444f05b35a2Smrg ;; 3445f05b35a2Smrg esac 344649e108a1Smrg echo >> "$output_objdir/$my_dlsyms" "\ 3447f05b35a2Smrg {0, (void *) 0} 3448f05b35a2Smrg}; 3449e0963edeSmrg 3450f05b35a2Smrg/* This works around a problem in FreeBSD linker */ 3451f05b35a2Smrg#ifdef FREEBSD_WORKAROUND 3452f05b35a2Smrgstatic const void *lt_preloaded_setup() { 3453f05b35a2Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 3454f05b35a2Smrg} 3455f05b35a2Smrg#endif 3456e0963edeSmrg 3457f05b35a2Smrg#ifdef __cplusplus 3458f05b35a2Smrg} 3459f05b35a2Smrg#endif\ 3460f05b35a2Smrg" 3461f05b35a2Smrg } # !$opt_dry_run 3462e0963edeSmrg 3463f05b35a2Smrg pic_flag_for_symtable= 3464f05b35a2Smrg case "$compile_command " in 3465f05b35a2Smrg *" -static "*) ;; 3466f05b35a2Smrg *) 3467f05b35a2Smrg case $host in 3468f05b35a2Smrg # compiling the symbol table file with pic_flag works around 3469f05b35a2Smrg # a FreeBSD bug that causes programs to crash when -lm is 3470f05b35a2Smrg # linked before any other PIC object. But we must not use 3471f05b35a2Smrg # pic_flag when linking with -static. The problem exists in 3472f05b35a2Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 3473f05b35a2Smrg *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 3474f05b35a2Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 3475f05b35a2Smrg *-*-hpux*) 3476f05b35a2Smrg pic_flag_for_symtable=" $pic_flag" ;; 3477f05b35a2Smrg *) 3478f05b35a2Smrg if test "X$my_pic_p" != Xno; then 3479f05b35a2Smrg pic_flag_for_symtable=" $pic_flag" 3480f05b35a2Smrg fi 3481f05b35a2Smrg ;; 3482f05b35a2Smrg esac 3483f05b35a2Smrg ;; 3484f05b35a2Smrg esac 3485f05b35a2Smrg symtab_cflags= 3486f05b35a2Smrg for arg in $LTCFLAGS; do 3487f05b35a2Smrg case $arg in 3488f05b35a2Smrg -pie | -fpie | -fPIE) ;; 348967ab2ff2Smrg *) func_append symtab_cflags " $arg" ;; 3490f05b35a2Smrg esac 3491f05b35a2Smrg done 3492e0963edeSmrg 3493f05b35a2Smrg # Now compile the dynamic symbol file. 3494f05b35a2Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 3495e0963edeSmrg 3496f05b35a2Smrg # Clean up the generated files. 3497f05b35a2Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 3498e0963edeSmrg 3499f05b35a2Smrg # Transform the symbol file into the correct name. 3500f05b35a2Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 3501f05b35a2Smrg case $host in 3502f05b35a2Smrg *cygwin* | *mingw* | *cegcc* ) 3503f05b35a2Smrg if test -f "$output_objdir/$my_outputname.def"; then 350449e108a1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 350549e108a1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3506f05b35a2Smrg else 350749e108a1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 350849e108a1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3509f05b35a2Smrg fi 3510f05b35a2Smrg ;; 3511f05b35a2Smrg *) 351249e108a1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351349e108a1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3514f05b35a2Smrg ;; 3515f05b35a2Smrg esac 3516f05b35a2Smrg ;; 3517f05b35a2Smrg *) 3518f05b35a2Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 3519f05b35a2Smrg ;; 3520f05b35a2Smrg esac 3521f05b35a2Smrg else 3522f05b35a2Smrg # We keep going just in case the user didn't refer to 3523f05b35a2Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 3524f05b35a2Smrg # really was required. 3525e0963edeSmrg 3526f05b35a2Smrg # Nullify the symbol file. 352749e108a1Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 352849e108a1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 3529f05b35a2Smrg fi 3530f05b35a2Smrg} 3531e0963edeSmrg 3532f05b35a2Smrg# func_win32_libid arg 3533f05b35a2Smrg# return the library type of file 'arg' 3534f05b35a2Smrg# 3535f05b35a2Smrg# Need a lot of goo to handle *both* DLLs and import libs 3536f05b35a2Smrg# Has to be a shell function in order to 'eat' the argument 3537f05b35a2Smrg# that is supplied when $file_magic_command is called. 353849e108a1Smrg# Despite the name, also deal with 64 bit binaries. 3539f05b35a2Smrgfunc_win32_libid () 3540f05b35a2Smrg{ 3541f05b35a2Smrg $opt_debug 3542f05b35a2Smrg win32_libid_type="unknown" 3543f05b35a2Smrg win32_fileres=`file -L $1 2>/dev/null` 3544f05b35a2Smrg case $win32_fileres in 3545f05b35a2Smrg *ar\ archive\ import\ library*) # definitely import 3546f05b35a2Smrg win32_libid_type="x86 archive import" 3547f05b35a2Smrg ;; 3548f05b35a2Smrg *ar\ archive*) # could be an import, or static 354949e108a1Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 3550f05b35a2Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 355149e108a1Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 355267ab2ff2Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 355367ab2ff2Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 3554f05b35a2Smrg $SED -n -e ' 3555f05b35a2Smrg 1,100{ 3556f05b35a2Smrg / I /{ 3557f05b35a2Smrg s,.*,import, 3558f05b35a2Smrg p 3559f05b35a2Smrg q 3560f05b35a2Smrg } 3561f05b35a2Smrg }'` 3562f05b35a2Smrg case $win32_nmres in 3563f05b35a2Smrg import*) win32_libid_type="x86 archive import";; 3564f05b35a2Smrg *) win32_libid_type="x86 archive static";; 3565f05b35a2Smrg esac 3566f05b35a2Smrg fi 3567f05b35a2Smrg ;; 3568f05b35a2Smrg *DLL*) 3569f05b35a2Smrg win32_libid_type="x86 DLL" 3570f05b35a2Smrg ;; 3571f05b35a2Smrg *executable*) # but shell scripts are "executable" too... 3572f05b35a2Smrg case $win32_fileres in 3573f05b35a2Smrg *MS\ Windows\ PE\ Intel*) 3574f05b35a2Smrg win32_libid_type="x86 DLL" 3575f05b35a2Smrg ;; 3576f05b35a2Smrg esac 3577f05b35a2Smrg ;; 3578f05b35a2Smrg esac 3579f05b35a2Smrg $ECHO "$win32_libid_type" 3580f05b35a2Smrg} 3581e0963edeSmrg 358267ab2ff2Smrg# func_cygming_dll_for_implib ARG 358367ab2ff2Smrg# 358467ab2ff2Smrg# Platform-specific function to extract the 358567ab2ff2Smrg# name of the DLL associated with the specified 358667ab2ff2Smrg# import library ARG. 358767ab2ff2Smrg# Invoked by eval'ing the libtool variable 358867ab2ff2Smrg# $sharedlib_from_linklib_cmd 358967ab2ff2Smrg# Result is available in the variable 359067ab2ff2Smrg# $sharedlib_from_linklib_result 359167ab2ff2Smrgfunc_cygming_dll_for_implib () 359267ab2ff2Smrg{ 359367ab2ff2Smrg $opt_debug 359467ab2ff2Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 359567ab2ff2Smrg} 359667ab2ff2Smrg 359767ab2ff2Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 359867ab2ff2Smrg# 359967ab2ff2Smrg# The is the core of a fallback implementation of a 360067ab2ff2Smrg# platform-specific function to extract the name of the 360167ab2ff2Smrg# DLL associated with the specified import library LIBNAME. 360267ab2ff2Smrg# 360367ab2ff2Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 360467ab2ff2Smrg# on the platform and compiler that created the implib. 360567ab2ff2Smrg# 360667ab2ff2Smrg# Echos the name of the DLL associated with the 360767ab2ff2Smrg# specified import library. 360867ab2ff2Smrgfunc_cygming_dll_for_implib_fallback_core () 360967ab2ff2Smrg{ 361067ab2ff2Smrg $opt_debug 361167ab2ff2Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 361267ab2ff2Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 361367ab2ff2Smrg $SED '/^Contents of section '"$match_literal"':/{ 361467ab2ff2Smrg # Place marker at beginning of archive member dllname section 361567ab2ff2Smrg s/.*/====MARK====/ 361667ab2ff2Smrg p 361767ab2ff2Smrg d 361867ab2ff2Smrg } 361967ab2ff2Smrg # These lines can sometimes be longer than 43 characters, but 362067ab2ff2Smrg # are always uninteresting 362167ab2ff2Smrg /:[ ]*file format pe[i]\{,1\}-/d 362267ab2ff2Smrg /^In archive [^:]*:/d 362367ab2ff2Smrg # Ensure marker is printed 362467ab2ff2Smrg /^====MARK====/p 362567ab2ff2Smrg # Remove all lines with less than 43 characters 362667ab2ff2Smrg /^.\{43\}/!d 362767ab2ff2Smrg # From remaining lines, remove first 43 characters 362867ab2ff2Smrg s/^.\{43\}//' | 362967ab2ff2Smrg $SED -n ' 363067ab2ff2Smrg # Join marker and all lines until next marker into a single line 363167ab2ff2Smrg /^====MARK====/ b para 363267ab2ff2Smrg H 363367ab2ff2Smrg $ b para 363467ab2ff2Smrg b 363567ab2ff2Smrg :para 363667ab2ff2Smrg x 363767ab2ff2Smrg s/\n//g 363867ab2ff2Smrg # Remove the marker 363967ab2ff2Smrg s/^====MARK====// 364067ab2ff2Smrg # Remove trailing dots and whitespace 364167ab2ff2Smrg s/[\. \t]*$// 364267ab2ff2Smrg # Print 364367ab2ff2Smrg /./p' | 364467ab2ff2Smrg # we now have a list, one entry per line, of the stringified 364567ab2ff2Smrg # contents of the appropriate section of all members of the 364667ab2ff2Smrg # archive which possess that section. Heuristic: eliminate 364767ab2ff2Smrg # all those which have a first or second character that is 364867ab2ff2Smrg # a '.' (that is, objdump's representation of an unprintable 364967ab2ff2Smrg # character.) This should work for all archives with less than 365067ab2ff2Smrg # 0x302f exports -- but will fail for DLLs whose name actually 365167ab2ff2Smrg # begins with a literal '.' or a single character followed by 365267ab2ff2Smrg # a '.'. 365367ab2ff2Smrg # 365467ab2ff2Smrg # Of those that remain, print the first one. 365567ab2ff2Smrg $SED -e '/^\./d;/^.\./d;q' 365667ab2ff2Smrg} 365767ab2ff2Smrg 365867ab2ff2Smrg# func_cygming_gnu_implib_p ARG 365967ab2ff2Smrg# This predicate returns with zero status (TRUE) if 366067ab2ff2Smrg# ARG is a GNU/binutils-style import library. Returns 366167ab2ff2Smrg# with nonzero status (FALSE) otherwise. 366267ab2ff2Smrgfunc_cygming_gnu_implib_p () 366367ab2ff2Smrg{ 366467ab2ff2Smrg $opt_debug 366567ab2ff2Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 366667ab2ff2Smrg 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)$'` 366767ab2ff2Smrg test -n "$func_cygming_gnu_implib_tmp" 366867ab2ff2Smrg} 366967ab2ff2Smrg 367067ab2ff2Smrg# func_cygming_ms_implib_p ARG 367167ab2ff2Smrg# This predicate returns with zero status (TRUE) if 367267ab2ff2Smrg# ARG is an MS-style import library. Returns 367367ab2ff2Smrg# with nonzero status (FALSE) otherwise. 367467ab2ff2Smrgfunc_cygming_ms_implib_p () 367567ab2ff2Smrg{ 367667ab2ff2Smrg $opt_debug 367767ab2ff2Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 367867ab2ff2Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 367967ab2ff2Smrg test -n "$func_cygming_ms_implib_tmp" 368067ab2ff2Smrg} 368167ab2ff2Smrg 368267ab2ff2Smrg# func_cygming_dll_for_implib_fallback ARG 368367ab2ff2Smrg# Platform-specific function to extract the 368467ab2ff2Smrg# name of the DLL associated with the specified 368567ab2ff2Smrg# import library ARG. 368667ab2ff2Smrg# 368767ab2ff2Smrg# This fallback implementation is for use when $DLLTOOL 368867ab2ff2Smrg# does not support the --identify-strict option. 368967ab2ff2Smrg# Invoked by eval'ing the libtool variable 369067ab2ff2Smrg# $sharedlib_from_linklib_cmd 369167ab2ff2Smrg# Result is available in the variable 369267ab2ff2Smrg# $sharedlib_from_linklib_result 369367ab2ff2Smrgfunc_cygming_dll_for_implib_fallback () 369467ab2ff2Smrg{ 369567ab2ff2Smrg $opt_debug 369667ab2ff2Smrg if func_cygming_gnu_implib_p "$1" ; then 369767ab2ff2Smrg # binutils import library 369867ab2ff2Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 369967ab2ff2Smrg elif func_cygming_ms_implib_p "$1" ; then 370067ab2ff2Smrg # ms-generated import library 370167ab2ff2Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 370267ab2ff2Smrg else 370367ab2ff2Smrg # unknown 370467ab2ff2Smrg sharedlib_from_linklib_result="" 370567ab2ff2Smrg fi 370667ab2ff2Smrg} 3707e0963edeSmrg 3708e0963edeSmrg 3709f05b35a2Smrg# func_extract_an_archive dir oldlib 3710f05b35a2Smrgfunc_extract_an_archive () 3711f05b35a2Smrg{ 3712f05b35a2Smrg $opt_debug 3713f05b35a2Smrg f_ex_an_ar_dir="$1"; shift 3714f05b35a2Smrg f_ex_an_ar_oldlib="$1" 371549e108a1Smrg if test "$lock_old_archive_extraction" = yes; then 371649e108a1Smrg lockfile=$f_ex_an_ar_oldlib.lock 371749e108a1Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 371849e108a1Smrg func_echo "Waiting for $lockfile to be removed" 371949e108a1Smrg sleep 2 372049e108a1Smrg done 372149e108a1Smrg fi 372249e108a1Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 372349e108a1Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 372449e108a1Smrg if test "$lock_old_archive_extraction" = yes; then 372549e108a1Smrg $opt_dry_run || rm -f "$lockfile" 372649e108a1Smrg fi 3727f05b35a2Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 3728f05b35a2Smrg : 3729f05b35a2Smrg else 3730f05b35a2Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 3731f05b35a2Smrg fi 3732f05b35a2Smrg} 3733e0963edeSmrg 3734e0963edeSmrg 3735f05b35a2Smrg# func_extract_archives gentop oldlib ... 3736f05b35a2Smrgfunc_extract_archives () 3737f05b35a2Smrg{ 3738f05b35a2Smrg $opt_debug 3739f05b35a2Smrg my_gentop="$1"; shift 3740f05b35a2Smrg my_oldlibs=${1+"$@"} 3741f05b35a2Smrg my_oldobjs="" 3742f05b35a2Smrg my_xlib="" 3743f05b35a2Smrg my_xabs="" 3744f05b35a2Smrg my_xdir="" 3745e0963edeSmrg 3746f05b35a2Smrg for my_xlib in $my_oldlibs; do 3747f05b35a2Smrg # Extract the objects. 3748f05b35a2Smrg case $my_xlib in 3749f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 3750f05b35a2Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 3751f05b35a2Smrg esac 3752f05b35a2Smrg func_basename "$my_xlib" 3753f05b35a2Smrg my_xlib="$func_basename_result" 3754f05b35a2Smrg my_xlib_u=$my_xlib 3755f05b35a2Smrg while :; do 3756f05b35a2Smrg case " $extracted_archives " in 3757f05b35a2Smrg *" $my_xlib_u "*) 3758f05b35a2Smrg func_arith $extracted_serial + 1 3759f05b35a2Smrg extracted_serial=$func_arith_result 3760f05b35a2Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 3761f05b35a2Smrg *) break ;; 3762f05b35a2Smrg esac 3763f05b35a2Smrg done 3764f05b35a2Smrg extracted_archives="$extracted_archives $my_xlib_u" 3765f05b35a2Smrg my_xdir="$my_gentop/$my_xlib_u" 3766e0963edeSmrg 3767f05b35a2Smrg func_mkdir_p "$my_xdir" 3768f05b35a2Smrg 3769f05b35a2Smrg case $host in 3770f05b35a2Smrg *-darwin*) 3771f05b35a2Smrg func_verbose "Extracting $my_xabs" 3772f05b35a2Smrg # Do not bother doing anything if just a dry run 3773f05b35a2Smrg $opt_dry_run || { 3774f05b35a2Smrg darwin_orig_dir=`pwd` 3775f05b35a2Smrg cd $my_xdir || exit $? 3776f05b35a2Smrg darwin_archive=$my_xabs 3777f05b35a2Smrg darwin_curdir=`pwd` 3778f05b35a2Smrg darwin_base_archive=`basename "$darwin_archive"` 3779f05b35a2Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 3780f05b35a2Smrg if test -n "$darwin_arches"; then 3781f05b35a2Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 3782f05b35a2Smrg darwin_arch= 3783f05b35a2Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 3784f05b35a2Smrg for darwin_arch in $darwin_arches ; do 3785f05b35a2Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3786f05b35a2Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 3787f05b35a2Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3788f05b35a2Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 3789f05b35a2Smrg cd "$darwin_curdir" 3790f05b35a2Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 3791f05b35a2Smrg done # $darwin_arches 3792f05b35a2Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 3793f05b35a2Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 3794f05b35a2Smrg darwin_file= 3795f05b35a2Smrg darwin_files= 3796f05b35a2Smrg for darwin_file in $darwin_filelist; do 379749e108a1Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 3798f05b35a2Smrg $LIPO -create -output "$darwin_file" $darwin_files 3799f05b35a2Smrg done # $darwin_filelist 3800f05b35a2Smrg $RM -rf unfat-$$ 3801f05b35a2Smrg cd "$darwin_orig_dir" 3802e0963edeSmrg else 3803f05b35a2Smrg cd $darwin_orig_dir 3804f05b35a2Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 3805f05b35a2Smrg fi # $darwin_arches 3806f05b35a2Smrg } # !$opt_dry_run 3807f05b35a2Smrg ;; 3808f05b35a2Smrg *) 3809f05b35a2Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 3810f05b35a2Smrg ;; 3811f05b35a2Smrg esac 381249e108a1Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 3813f05b35a2Smrg done 3814e0963edeSmrg 3815f05b35a2Smrg func_extract_archives_result="$my_oldobjs" 3816f05b35a2Smrg} 3817e0963edeSmrg 3818e0963edeSmrg 381949e108a1Smrg# func_emit_wrapper [arg=no] 382049e108a1Smrg# 382149e108a1Smrg# Emit a libtool wrapper script on stdout. 382249e108a1Smrg# Don't directly open a file because we may want to 382349e108a1Smrg# incorporate the script contents within a cygwin/mingw 382449e108a1Smrg# wrapper executable. Must ONLY be called from within 382549e108a1Smrg# func_mode_link because it depends on a number of variables 382649e108a1Smrg# set therein. 3827f05b35a2Smrg# 382849e108a1Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 382949e108a1Smrg# variable will take. If 'yes', then the emitted script 383049e108a1Smrg# will assume that the directory in which it is stored is 383149e108a1Smrg# the $objdir directory. This is a cygwin/mingw-specific 383249e108a1Smrg# behavior. 383349e108a1Smrgfunc_emit_wrapper () 3834f05b35a2Smrg{ 383549e108a1Smrg func_emit_wrapper_arg1=${1-no} 3836e0963edeSmrg 3837f05b35a2Smrg $ECHO "\ 3838f05b35a2Smrg#! $SHELL 3839e0963edeSmrg 3840f05b35a2Smrg# $output - temporary wrapper script for $objdir/$outputname 3841f05b35a2Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 3842f05b35a2Smrg# 3843f05b35a2Smrg# The $output program cannot be directly executed until all the libtool 3844f05b35a2Smrg# libraries that it depends on are installed. 3845f05b35a2Smrg# 3846f05b35a2Smrg# This wrapper script should never be moved out of the build directory. 3847f05b35a2Smrg# If it is, it will not operate correctly. 3848e0963edeSmrg 3849f05b35a2Smrg# Sed substitution that helps us do robust quoting. It backslashifies 3850f05b35a2Smrg# metacharacters that are still active within double-quoted strings. 3851f05b35a2Smrgsed_quote_subst='$sed_quote_subst' 3852e0963edeSmrg 3853f05b35a2Smrg# Be Bourne compatible 3854f05b35a2Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 3855f05b35a2Smrg emulate sh 3856f05b35a2Smrg NULLCMD=: 3857f05b35a2Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 3858f05b35a2Smrg # is contrary to our usage. Disable this feature. 3859f05b35a2Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 3860f05b35a2Smrg setopt NO_GLOB_SUBST 3861f05b35a2Smrgelse 3862f05b35a2Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 3863f05b35a2Smrgfi 3864f05b35a2SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 3865f05b35a2SmrgDUALCASE=1; export DUALCASE # for MKS sh 3866e0963edeSmrg 3867f05b35a2Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 3868f05b35a2Smrg# if CDPATH is set. 3869f05b35a2Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 3870e0963edeSmrg 3871f05b35a2Smrgrelink_command=\"$relink_command\" 3872e0963edeSmrg 3873f05b35a2Smrg# This environment variable determines our operation mode. 3874f05b35a2Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 3875f05b35a2Smrg # install mode needs the following variables: 3876f05b35a2Smrg generated_by_libtool_version='$macro_version' 3877f05b35a2Smrg notinst_deplibs='$notinst_deplibs' 3878f05b35a2Smrgelse 3879f05b35a2Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 3880f05b35a2Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 388149e108a1Smrg file=\"\$0\"" 388249e108a1Smrg 388349e108a1Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 388449e108a1Smrg $ECHO "\ 388549e108a1Smrg 388649e108a1Smrg# A function that is used when there is no print builtin or printf. 388749e108a1Smrgfunc_fallback_echo () 388849e108a1Smrg{ 388949e108a1Smrg eval 'cat <<_LTECHO_EOF 389049e108a1Smrg\$1 389149e108a1Smrg_LTECHO_EOF' 389249e108a1Smrg} 389349e108a1Smrg ECHO=\"$qECHO\" 389449e108a1Smrg fi 389549e108a1Smrg 389649e108a1Smrg# Very basic option parsing. These options are (a) specific to 389749e108a1Smrg# the libtool wrapper, (b) are identical between the wrapper 389849e108a1Smrg# /script/ and the wrapper /executable/ which is used only on 389949e108a1Smrg# windows platforms, and (c) all begin with the string "--lt-" 390049e108a1Smrg# (application programs are unlikely to have options which match 390149e108a1Smrg# this pattern). 390249e108a1Smrg# 390349e108a1Smrg# There are only two supported options: --lt-debug and 390449e108a1Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 390549e108a1Smrg# 390649e108a1Smrg# The first argument to this parsing function should be the 390749e108a1Smrg# script's $0 value, followed by "$@". 390849e108a1Smrglt_option_debug= 390949e108a1Smrgfunc_parse_lt_options () 391049e108a1Smrg{ 391149e108a1Smrg lt_script_arg0=\$0 391249e108a1Smrg shift 391349e108a1Smrg for lt_opt 391449e108a1Smrg do 391549e108a1Smrg case \"\$lt_opt\" in 391649e108a1Smrg --lt-debug) lt_option_debug=1 ;; 391749e108a1Smrg --lt-dump-script) 391849e108a1Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 391949e108a1Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 392049e108a1Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 392149e108a1Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 392249e108a1Smrg exit 0 392349e108a1Smrg ;; 392449e108a1Smrg --lt-*) 392549e108a1Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 392649e108a1Smrg exit 1 392749e108a1Smrg ;; 392849e108a1Smrg esac 392949e108a1Smrg done 393049e108a1Smrg 393149e108a1Smrg # Print the debug banner immediately: 393249e108a1Smrg if test -n \"\$lt_option_debug\"; then 393349e108a1Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 393449e108a1Smrg fi 393549e108a1Smrg} 393649e108a1Smrg 393749e108a1Smrg# Used when --lt-debug. Prints its arguments to stdout 393849e108a1Smrg# (redirection is the responsibility of the caller) 393949e108a1Smrgfunc_lt_dump_args () 394049e108a1Smrg{ 394149e108a1Smrg lt_dump_args_N=1; 394249e108a1Smrg for lt_arg 394349e108a1Smrg do 394449e108a1Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 394549e108a1Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 394649e108a1Smrg done 394749e108a1Smrg} 394849e108a1Smrg 394949e108a1Smrg# Core function for launching the target application 395049e108a1Smrgfunc_exec_program_core () 395149e108a1Smrg{ 3952f05b35a2Smrg" 395349e108a1Smrg case $host in 395449e108a1Smrg # Backslashes separate directories on plain windows 395549e108a1Smrg *-*-mingw | *-*-os2* | *-cegcc*) 395649e108a1Smrg $ECHO "\ 395749e108a1Smrg if test -n \"\$lt_option_debug\"; then 395849e108a1Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 395949e108a1Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 396049e108a1Smrg fi 396149e108a1Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 396249e108a1Smrg" 396349e108a1Smrg ;; 396449e108a1Smrg 396549e108a1Smrg *) 396649e108a1Smrg $ECHO "\ 396749e108a1Smrg if test -n \"\$lt_option_debug\"; then 396849e108a1Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 396949e108a1Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 397049e108a1Smrg fi 397149e108a1Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 397249e108a1Smrg" 397349e108a1Smrg ;; 397449e108a1Smrg esac 397549e108a1Smrg $ECHO "\ 397649e108a1Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 397749e108a1Smrg exit 1 397849e108a1Smrg} 397949e108a1Smrg 398049e108a1Smrg# A function to encapsulate launching the target application 398149e108a1Smrg# Strips options in the --lt-* namespace from \$@ and 398249e108a1Smrg# launches target application with the remaining arguments. 398349e108a1Smrgfunc_exec_program () 398449e108a1Smrg{ 398549e108a1Smrg for lt_wr_arg 398649e108a1Smrg do 398749e108a1Smrg case \$lt_wr_arg in 398849e108a1Smrg --lt-*) ;; 398949e108a1Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 399049e108a1Smrg esac 399149e108a1Smrg shift 399249e108a1Smrg done 399349e108a1Smrg func_exec_program_core \${1+\"\$@\"} 399449e108a1Smrg} 399549e108a1Smrg 399649e108a1Smrg # Parse options 399749e108a1Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 3998e0963edeSmrg 3999f05b35a2Smrg # Find the directory that this script lives in. 400049e108a1Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 4001f05b35a2Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 4002e0963edeSmrg 4003f05b35a2Smrg # Follow symbolic links until we get to the real thisdir. 400449e108a1Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 4005f05b35a2Smrg while test -n \"\$file\"; do 400649e108a1Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 4007f05b35a2Smrg 4008f05b35a2Smrg # If there was a directory component, then change thisdir. 4009f05b35a2Smrg if test \"x\$destdir\" != \"x\$file\"; then 4010f05b35a2Smrg case \"\$destdir\" in 4011f05b35a2Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 4012f05b35a2Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 4013e0963edeSmrg esac 4014f05b35a2Smrg fi 4015e0963edeSmrg 401649e108a1Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 401749e108a1Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 4018f05b35a2Smrg done 4019e0963edeSmrg 4020f05b35a2Smrg # Usually 'no', except on cygwin/mingw when embedded into 4021f05b35a2Smrg # the cwrapper. 402249e108a1Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 4023f05b35a2Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 4024f05b35a2Smrg # special case for '.' 4025f05b35a2Smrg if test \"\$thisdir\" = \".\"; then 4026f05b35a2Smrg thisdir=\`pwd\` 4027f05b35a2Smrg fi 4028f05b35a2Smrg # remove .libs from thisdir 4029f05b35a2Smrg case \"\$thisdir\" in 403049e108a1Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 4031f05b35a2Smrg $objdir ) thisdir=. ;; 4032f05b35a2Smrg esac 4033f05b35a2Smrg fi 4034f05b35a2Smrg 4035f05b35a2Smrg # Try to get the absolute directory name. 4036f05b35a2Smrg absdir=\`cd \"\$thisdir\" && pwd\` 4037f05b35a2Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 4038f05b35a2Smrg" 4039f05b35a2Smrg 4040f05b35a2Smrg if test "$fast_install" = yes; then 4041f05b35a2Smrg $ECHO "\ 4042f05b35a2Smrg program=lt-'$outputname'$exeext 4043f05b35a2Smrg progdir=\"\$thisdir/$objdir\" 4044f05b35a2Smrg 4045f05b35a2Smrg if test ! -f \"\$progdir/\$program\" || 4046f05b35a2Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 4047f05b35a2Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 4048f05b35a2Smrg 4049f05b35a2Smrg file=\"\$\$-\$program\" 4050f05b35a2Smrg 4051f05b35a2Smrg if test ! -d \"\$progdir\"; then 4052f05b35a2Smrg $MKDIR \"\$progdir\" 4053f05b35a2Smrg else 4054f05b35a2Smrg $RM \"\$progdir/\$file\" 4055f05b35a2Smrg fi" 4056f05b35a2Smrg 4057f05b35a2Smrg $ECHO "\ 4058f05b35a2Smrg 4059f05b35a2Smrg # relink executable if necessary 4060f05b35a2Smrg if test -n \"\$relink_command\"; then 4061f05b35a2Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 4062f05b35a2Smrg else 4063f05b35a2Smrg $ECHO \"\$relink_command_output\" >&2 4064f05b35a2Smrg $RM \"\$progdir/\$file\" 4065f05b35a2Smrg exit 1 4066e0963edeSmrg fi 4067f05b35a2Smrg fi 4068e0963edeSmrg 4069f05b35a2Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 4070f05b35a2Smrg { $RM \"\$progdir/\$program\"; 4071f05b35a2Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 4072f05b35a2Smrg $RM \"\$progdir/\$file\" 4073f05b35a2Smrg fi" 4074f05b35a2Smrg else 4075f05b35a2Smrg $ECHO "\ 4076f05b35a2Smrg program='$outputname' 4077f05b35a2Smrg progdir=\"\$thisdir/$objdir\" 4078f05b35a2Smrg" 4079e0963edeSmrg fi 4080e0963edeSmrg 4081f05b35a2Smrg $ECHO "\ 4082f05b35a2Smrg 4083f05b35a2Smrg if test -f \"\$progdir/\$program\"; then" 4084f05b35a2Smrg 408567ab2ff2Smrg # fixup the dll searchpath if we need to. 408667ab2ff2Smrg # 408767ab2ff2Smrg # Fix the DLL searchpath if we need to. Do this before prepending 408867ab2ff2Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 408967ab2ff2Smrg # libraries must come first. 409067ab2ff2Smrg if test -n "$dllsearchpath"; then 409167ab2ff2Smrg $ECHO "\ 409267ab2ff2Smrg # Add the dll search path components to the executable PATH 409367ab2ff2Smrg PATH=$dllsearchpath:\$PATH 409467ab2ff2Smrg" 409567ab2ff2Smrg fi 409667ab2ff2Smrg 4097f05b35a2Smrg # Export our shlibpath_var if we have one. 4098f05b35a2Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4099f05b35a2Smrg $ECHO "\ 4100f05b35a2Smrg # Add our own library path to $shlibpath_var 4101f05b35a2Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 4102f05b35a2Smrg 4103f05b35a2Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 4104f05b35a2Smrg # The second colon is a workaround for a bug in BeOS R4 sed 410549e108a1Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 4106f05b35a2Smrg 4107f05b35a2Smrg export $shlibpath_var 4108f05b35a2Smrg" 4109e0963edeSmrg fi 4110e0963edeSmrg 4111f05b35a2Smrg $ECHO "\ 4112f05b35a2Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 4113f05b35a2Smrg # Run the actual program with our arguments. 411449e108a1Smrg func_exec_program \${1+\"\$@\"} 4115f05b35a2Smrg fi 4116f05b35a2Smrg else 4117f05b35a2Smrg # The program doesn't exist. 4118f05b35a2Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 4119f05b35a2Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 412049e108a1Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 4121f05b35a2Smrg exit 1 4122f05b35a2Smrg fi 4123f05b35a2Smrgfi\ 4124f05b35a2Smrg" 4125f05b35a2Smrg} 4126e0963edeSmrg 4127e0963edeSmrg 4128f05b35a2Smrg# func_emit_cwrapperexe_src 4129f05b35a2Smrg# emit the source code for a wrapper executable on stdout 4130f05b35a2Smrg# Must ONLY be called from within func_mode_link because 4131f05b35a2Smrg# it depends on a number of variable set therein. 4132f05b35a2Smrgfunc_emit_cwrapperexe_src () 4133f05b35a2Smrg{ 4134f05b35a2Smrg cat <<EOF 4135e0963edeSmrg 4136f05b35a2Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 4137f05b35a2Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4138e0963edeSmrg 4139f05b35a2Smrg The $output program cannot be directly executed until all the libtool 4140f05b35a2Smrg libraries that it depends on are installed. 4141e0963edeSmrg 4142f05b35a2Smrg This wrapper executable should never be moved out of the build directory. 4143f05b35a2Smrg If it is, it will not operate correctly. 4144f05b35a2Smrg*/ 4145f05b35a2SmrgEOF 4146f05b35a2Smrg cat <<"EOF" 414749e108a1Smrg#ifdef _MSC_VER 414849e108a1Smrg# define _CRT_SECURE_NO_DEPRECATE 1 414949e108a1Smrg#endif 4150f05b35a2Smrg#include <stdio.h> 4151f05b35a2Smrg#include <stdlib.h> 4152f05b35a2Smrg#ifdef _MSC_VER 4153f05b35a2Smrg# include <direct.h> 4154f05b35a2Smrg# include <process.h> 4155f05b35a2Smrg# include <io.h> 4156f05b35a2Smrg#else 4157f05b35a2Smrg# include <unistd.h> 4158f05b35a2Smrg# include <stdint.h> 4159f05b35a2Smrg# ifdef __CYGWIN__ 4160f05b35a2Smrg# include <io.h> 4161f05b35a2Smrg# endif 4162f05b35a2Smrg#endif 4163f05b35a2Smrg#include <malloc.h> 4164f05b35a2Smrg#include <stdarg.h> 4165f05b35a2Smrg#include <assert.h> 4166f05b35a2Smrg#include <string.h> 4167f05b35a2Smrg#include <ctype.h> 4168f05b35a2Smrg#include <errno.h> 4169f05b35a2Smrg#include <fcntl.h> 4170f05b35a2Smrg#include <sys/stat.h> 4171e0963edeSmrg 417249e108a1Smrg/* declarations of non-ANSI functions */ 417349e108a1Smrg#if defined(__MINGW32__) 417449e108a1Smrg# ifdef __STRICT_ANSI__ 417549e108a1Smrgint _putenv (const char *); 417649e108a1Smrg# endif 417749e108a1Smrg#elif defined(__CYGWIN__) 417849e108a1Smrg# ifdef __STRICT_ANSI__ 417949e108a1Smrgchar *realpath (const char *, char *); 418049e108a1Smrgint putenv (char *); 418149e108a1Smrgint setenv (const char *, const char *, int); 418249e108a1Smrg# endif 418349e108a1Smrg/* #elif defined (other platforms) ... */ 418449e108a1Smrg#endif 418549e108a1Smrg 418649e108a1Smrg/* portability defines, excluding path handling macros */ 418749e108a1Smrg#if defined(_MSC_VER) 418849e108a1Smrg# define setmode _setmode 418949e108a1Smrg# define stat _stat 419049e108a1Smrg# define chmod _chmod 419149e108a1Smrg# define getcwd _getcwd 419249e108a1Smrg# define putenv _putenv 419349e108a1Smrg# define S_IXUSR _S_IEXEC 419449e108a1Smrg# ifndef _INTPTR_T_DEFINED 419549e108a1Smrg# define _INTPTR_T_DEFINED 419649e108a1Smrg# define intptr_t int 419749e108a1Smrg# endif 419849e108a1Smrg#elif defined(__MINGW32__) 419949e108a1Smrg# define setmode _setmode 420049e108a1Smrg# define stat _stat 420149e108a1Smrg# define chmod _chmod 420249e108a1Smrg# define getcwd _getcwd 420349e108a1Smrg# define putenv _putenv 420449e108a1Smrg#elif defined(__CYGWIN__) 420549e108a1Smrg# define HAVE_SETENV 420649e108a1Smrg# define FOPEN_WB "wb" 420749e108a1Smrg/* #elif defined (other platforms) ... */ 420849e108a1Smrg#endif 420949e108a1Smrg 4210f05b35a2Smrg#if defined(PATH_MAX) 4211f05b35a2Smrg# define LT_PATHMAX PATH_MAX 4212f05b35a2Smrg#elif defined(MAXPATHLEN) 4213f05b35a2Smrg# define LT_PATHMAX MAXPATHLEN 4214f05b35a2Smrg#else 4215f05b35a2Smrg# define LT_PATHMAX 1024 4216f05b35a2Smrg#endif 4217e0963edeSmrg 4218f05b35a2Smrg#ifndef S_IXOTH 4219f05b35a2Smrg# define S_IXOTH 0 4220f05b35a2Smrg#endif 4221f05b35a2Smrg#ifndef S_IXGRP 4222f05b35a2Smrg# define S_IXGRP 0 4223f05b35a2Smrg#endif 4224e0963edeSmrg 422549e108a1Smrg/* path handling portability macros */ 4226f05b35a2Smrg#ifndef DIR_SEPARATOR 4227f05b35a2Smrg# define DIR_SEPARATOR '/' 4228f05b35a2Smrg# define PATH_SEPARATOR ':' 4229f05b35a2Smrg#endif 4230e0963edeSmrg 4231f05b35a2Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 4232f05b35a2Smrg defined (__OS2__) 4233f05b35a2Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 4234f05b35a2Smrg# define FOPEN_WB "wb" 4235f05b35a2Smrg# ifndef DIR_SEPARATOR_2 4236f05b35a2Smrg# define DIR_SEPARATOR_2 '\\' 4237f05b35a2Smrg# endif 4238f05b35a2Smrg# ifndef PATH_SEPARATOR_2 4239f05b35a2Smrg# define PATH_SEPARATOR_2 ';' 4240f05b35a2Smrg# endif 4241f05b35a2Smrg#endif 4242e0963edeSmrg 4243f05b35a2Smrg#ifndef DIR_SEPARATOR_2 4244f05b35a2Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 4245f05b35a2Smrg#else /* DIR_SEPARATOR_2 */ 4246f05b35a2Smrg# define IS_DIR_SEPARATOR(ch) \ 4247f05b35a2Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 4248f05b35a2Smrg#endif /* DIR_SEPARATOR_2 */ 4249e0963edeSmrg 4250f05b35a2Smrg#ifndef PATH_SEPARATOR_2 4251f05b35a2Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 4252f05b35a2Smrg#else /* PATH_SEPARATOR_2 */ 4253f05b35a2Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 4254f05b35a2Smrg#endif /* PATH_SEPARATOR_2 */ 4255e0963edeSmrg 4256f05b35a2Smrg#ifndef FOPEN_WB 4257f05b35a2Smrg# define FOPEN_WB "w" 4258f05b35a2Smrg#endif 4259f05b35a2Smrg#ifndef _O_BINARY 4260f05b35a2Smrg# define _O_BINARY 0 4261f05b35a2Smrg#endif 4262e0963edeSmrg 4263f05b35a2Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 4264f05b35a2Smrg#define XFREE(stale) do { \ 4265f05b35a2Smrg if (stale) { free ((void *) stale); stale = 0; } \ 4266f05b35a2Smrg} while (0) 4267e0963edeSmrg 426849e108a1Smrg#if defined(LT_DEBUGWRAPPER) 426949e108a1Smrgstatic int lt_debug = 1; 4270f05b35a2Smrg#else 427149e108a1Smrgstatic int lt_debug = 0; 4272f05b35a2Smrg#endif 4273e0963edeSmrg 427449e108a1Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 4275e0963edeSmrg 4276f05b35a2Smrgvoid *xmalloc (size_t num); 4277f05b35a2Smrgchar *xstrdup (const char *string); 4278f05b35a2Smrgconst char *base_name (const char *name); 4279f05b35a2Smrgchar *find_executable (const char *wrapper); 4280f05b35a2Smrgchar *chase_symlinks (const char *pathspec); 4281f05b35a2Smrgint make_executable (const char *path); 4282f05b35a2Smrgint check_executable (const char *path); 4283f05b35a2Smrgchar *strendzap (char *str, const char *pat); 428449e108a1Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 428549e108a1Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 428649e108a1Smrgstatic const char *nonnull (const char *s); 428749e108a1Smrgstatic const char *nonempty (const char *s); 4288f05b35a2Smrgvoid lt_setenv (const char *name, const char *value); 4289f05b35a2Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 4290f05b35a2Smrgvoid lt_update_exe_path (const char *name, const char *value); 4291f05b35a2Smrgvoid lt_update_lib_path (const char *name, const char *value); 429249e108a1Smrgchar **prepare_spawn (char **argv); 429349e108a1Smrgvoid lt_dump_script (FILE *f); 4294f05b35a2SmrgEOF 4295f05b35a2Smrg 4296f05b35a2Smrg cat <<EOF 429767ab2ff2Smrgvolatile const char * MAGIC_EXE = "$magic_exe"; 4298f05b35a2Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 4299f05b35a2SmrgEOF 4300e0963edeSmrg 4301f05b35a2Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 430267ab2ff2Smrg func_to_host_path "$temp_rpath" 4303f05b35a2Smrg cat <<EOF 430467ab2ff2Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 4305f05b35a2SmrgEOF 4306f05b35a2Smrg else 4307f05b35a2Smrg cat <<"EOF" 4308f05b35a2Smrgconst char * LIB_PATH_VALUE = ""; 4309f05b35a2SmrgEOF 4310f05b35a2Smrg fi 4311e0963edeSmrg 4312f05b35a2Smrg if test -n "$dllsearchpath"; then 431367ab2ff2Smrg func_to_host_path "$dllsearchpath:" 4314f05b35a2Smrg cat <<EOF 4315f05b35a2Smrgconst char * EXE_PATH_VARNAME = "PATH"; 431667ab2ff2Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 4317f05b35a2SmrgEOF 4318f05b35a2Smrg else 4319f05b35a2Smrg cat <<"EOF" 4320f05b35a2Smrgconst char * EXE_PATH_VARNAME = ""; 4321f05b35a2Smrgconst char * EXE_PATH_VALUE = ""; 4322f05b35a2SmrgEOF 4323f05b35a2Smrg fi 4324e0963edeSmrg 4325f05b35a2Smrg if test "$fast_install" = yes; then 4326f05b35a2Smrg cat <<EOF 4327f05b35a2Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 4328f05b35a2SmrgEOF 4329f05b35a2Smrg else 4330f05b35a2Smrg cat <<EOF 4331f05b35a2Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 4332f05b35a2SmrgEOF 4333f05b35a2Smrg fi 4334e0963edeSmrg 4335e0963edeSmrg 4336f05b35a2Smrg cat <<"EOF" 4337e0963edeSmrg 4338f05b35a2Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 4339e0963edeSmrg 4340f05b35a2Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 4341f05b35a2Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 434249e108a1Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 4343f05b35a2Smrg 4344f05b35a2Smrgint 4345f05b35a2Smrgmain (int argc, char *argv[]) 4346f05b35a2Smrg{ 4347f05b35a2Smrg char **newargz; 4348f05b35a2Smrg int newargc; 4349f05b35a2Smrg char *tmp_pathspec; 4350f05b35a2Smrg char *actual_cwrapper_path; 4351f05b35a2Smrg char *actual_cwrapper_name; 4352f05b35a2Smrg char *target_name; 4353f05b35a2Smrg char *lt_argv_zero; 4354f05b35a2Smrg intptr_t rval = 127; 4355f05b35a2Smrg 4356f05b35a2Smrg int i; 4357f05b35a2Smrg 4358f05b35a2Smrg program_name = (char *) xstrdup (base_name (argv[0])); 435949e108a1Smrg newargz = XMALLOC (char *, argc + 1); 4360f05b35a2Smrg 436149e108a1Smrg /* very simple arg parsing; don't want to rely on getopt 436249e108a1Smrg * also, copy all non cwrapper options to newargz, except 436349e108a1Smrg * argz[0], which is handled differently 436449e108a1Smrg */ 436549e108a1Smrg newargc=0; 4366f05b35a2Smrg for (i = 1; i < argc; i++) 4367f05b35a2Smrg { 4368f05b35a2Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 4369f05b35a2Smrg { 4370f05b35a2SmrgEOF 4371f05b35a2Smrg case "$host" in 4372f05b35a2Smrg *mingw* | *cygwin* ) 4373f05b35a2Smrg # make stdout use "unix" line endings 4374f05b35a2Smrg echo " setmode(1,_O_BINARY);" 4375f05b35a2Smrg ;; 4376f05b35a2Smrg esac 4377f05b35a2Smrg 4378f05b35a2Smrg cat <<"EOF" 437949e108a1Smrg lt_dump_script (stdout); 4380f05b35a2Smrg return 0; 4381f05b35a2Smrg } 438249e108a1Smrg if (strcmp (argv[i], debug_opt) == 0) 438349e108a1Smrg { 438449e108a1Smrg lt_debug = 1; 438549e108a1Smrg continue; 438649e108a1Smrg } 438749e108a1Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 438849e108a1Smrg { 438949e108a1Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 439049e108a1Smrg namespace, but it is not one of the ones we know about and 439149e108a1Smrg have already dealt with, above (inluding dump-script), then 439249e108a1Smrg report an error. Otherwise, targets might begin to believe 439349e108a1Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 439449e108a1Smrg namespace. The first time any user complains about this, we'll 439549e108a1Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 439649e108a1Smrg or a configure.ac-settable value. 439749e108a1Smrg */ 439849e108a1Smrg lt_fatal (__FILE__, __LINE__, 439949e108a1Smrg "unrecognized %s option: '%s'", 440049e108a1Smrg ltwrapper_option_prefix, argv[i]); 440149e108a1Smrg } 440249e108a1Smrg /* otherwise ... */ 440349e108a1Smrg newargz[++newargc] = xstrdup (argv[i]); 4404f05b35a2Smrg } 440549e108a1Smrg newargz[++newargc] = NULL; 440649e108a1Smrg 440749e108a1SmrgEOF 440849e108a1Smrg cat <<EOF 440949e108a1Smrg /* The GNU banner must be the first non-error debug message */ 441049e108a1Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 441149e108a1SmrgEOF 441249e108a1Smrg cat <<"EOF" 441349e108a1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 441449e108a1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 4415f05b35a2Smrg 4416f05b35a2Smrg tmp_pathspec = find_executable (argv[0]); 4417f05b35a2Smrg if (tmp_pathspec == NULL) 441849e108a1Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 441949e108a1Smrg lt_debugprintf (__FILE__, __LINE__, 442049e108a1Smrg "(main) found exe (before symlink chase) at: %s\n", 442149e108a1Smrg tmp_pathspec); 4422f05b35a2Smrg 4423f05b35a2Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 442449e108a1Smrg lt_debugprintf (__FILE__, __LINE__, 442549e108a1Smrg "(main) found exe (after symlink chase) at: %s\n", 442649e108a1Smrg actual_cwrapper_path); 4427f05b35a2Smrg XFREE (tmp_pathspec); 4428f05b35a2Smrg 442949e108a1Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 4430f05b35a2Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 4431f05b35a2Smrg 4432f05b35a2Smrg /* wrapper name transforms */ 4433f05b35a2Smrg strendzap (actual_cwrapper_name, ".exe"); 4434f05b35a2Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 4435f05b35a2Smrg XFREE (actual_cwrapper_name); 4436f05b35a2Smrg actual_cwrapper_name = tmp_pathspec; 4437f05b35a2Smrg tmp_pathspec = 0; 4438f05b35a2Smrg 4439f05b35a2Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 4440f05b35a2Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 4441f05b35a2Smrg strendzap (target_name, ".exe"); 4442f05b35a2Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 4443f05b35a2Smrg XFREE (target_name); 4444f05b35a2Smrg target_name = tmp_pathspec; 4445f05b35a2Smrg tmp_pathspec = 0; 4446f05b35a2Smrg 444749e108a1Smrg lt_debugprintf (__FILE__, __LINE__, 444849e108a1Smrg "(main) libtool target name: %s\n", 444949e108a1Smrg target_name); 4450f05b35a2SmrgEOF 4451f05b35a2Smrg 4452f05b35a2Smrg cat <<EOF 4453f05b35a2Smrg newargz[0] = 4454f05b35a2Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 4455f05b35a2Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 4456f05b35a2Smrg strcpy (newargz[0], actual_cwrapper_path); 4457f05b35a2Smrg strcat (newargz[0], "$objdir"); 4458f05b35a2Smrg strcat (newargz[0], "/"); 4459f05b35a2SmrgEOF 4460f05b35a2Smrg 4461f05b35a2Smrg cat <<"EOF" 4462f05b35a2Smrg /* stop here, and copy so we don't have to do this twice */ 4463f05b35a2Smrg tmp_pathspec = xstrdup (newargz[0]); 4464f05b35a2Smrg 4465f05b35a2Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 4466f05b35a2Smrg strcat (newargz[0], actual_cwrapper_name); 4467f05b35a2Smrg 4468f05b35a2Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 4469f05b35a2Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 4470f05b35a2Smrg XFREE (tmp_pathspec); 4471f05b35a2Smrg tmp_pathspec = NULL; 4472f05b35a2SmrgEOF 4473f05b35a2Smrg 4474f05b35a2Smrg case $host_os in 4475f05b35a2Smrg mingw*) 4476f05b35a2Smrg cat <<"EOF" 4477f05b35a2Smrg { 4478f05b35a2Smrg char* p; 4479f05b35a2Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 4480f05b35a2Smrg { 4481f05b35a2Smrg *p = '/'; 4482f05b35a2Smrg } 4483f05b35a2Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 4484f05b35a2Smrg { 4485f05b35a2Smrg *p = '/'; 4486f05b35a2Smrg } 4487f05b35a2Smrg } 4488f05b35a2SmrgEOF 4489e0963edeSmrg ;; 4490f05b35a2Smrg esac 4491f05b35a2Smrg 4492f05b35a2Smrg cat <<"EOF" 4493f05b35a2Smrg XFREE (target_name); 4494f05b35a2Smrg XFREE (actual_cwrapper_path); 4495f05b35a2Smrg XFREE (actual_cwrapper_name); 4496f05b35a2Smrg 4497f05b35a2Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 4498f05b35a2Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 449967ab2ff2Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 450067ab2ff2Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 450167ab2ff2Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 450267ab2ff2Smrg libraries must come first. */ 4503f05b35a2Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 450467ab2ff2Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 4505f05b35a2Smrg 450649e108a1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 450749e108a1Smrg nonnull (lt_argv_zero)); 4508f05b35a2Smrg for (i = 0; i < newargc; i++) 4509f05b35a2Smrg { 451049e108a1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 451149e108a1Smrg i, nonnull (newargz[i])); 4512f05b35a2Smrg } 4513e0963edeSmrg 4514e0963edeSmrgEOF 4515e0963edeSmrg 4516f05b35a2Smrg case $host_os in 4517f05b35a2Smrg mingw*) 4518f05b35a2Smrg cat <<"EOF" 4519f05b35a2Smrg /* execv doesn't actually work on mingw as expected on unix */ 452049e108a1Smrg newargz = prepare_spawn (newargz); 4521f05b35a2Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 4522f05b35a2Smrg if (rval == -1) 4523f05b35a2Smrg { 4524f05b35a2Smrg /* failed to start process */ 452549e108a1Smrg lt_debugprintf (__FILE__, __LINE__, 452649e108a1Smrg "(main) failed to launch target \"%s\": %s\n", 452749e108a1Smrg lt_argv_zero, nonnull (strerror (errno))); 4528f05b35a2Smrg return 127; 4529f05b35a2Smrg } 4530f05b35a2Smrg return rval; 4531f05b35a2SmrgEOF 4532f05b35a2Smrg ;; 4533f05b35a2Smrg *) 4534f05b35a2Smrg cat <<"EOF" 4535f05b35a2Smrg execv (lt_argv_zero, newargz); 4536f05b35a2Smrg return rval; /* =127, but avoids unused variable warning */ 4537f05b35a2SmrgEOF 4538f05b35a2Smrg ;; 4539f05b35a2Smrg esac 4540e0963edeSmrg 4541f05b35a2Smrg cat <<"EOF" 4542f05b35a2Smrg} 4543e0963edeSmrg 4544f05b35a2Smrgvoid * 4545f05b35a2Smrgxmalloc (size_t num) 4546f05b35a2Smrg{ 4547f05b35a2Smrg void *p = (void *) malloc (num); 4548f05b35a2Smrg if (!p) 454949e108a1Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 4550e0963edeSmrg 4551f05b35a2Smrg return p; 4552f05b35a2Smrg} 4553e0963edeSmrg 4554f05b35a2Smrgchar * 4555f05b35a2Smrgxstrdup (const char *string) 4556f05b35a2Smrg{ 4557f05b35a2Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 4558f05b35a2Smrg string) : NULL; 4559f05b35a2Smrg} 4560e0963edeSmrg 4561f05b35a2Smrgconst char * 4562f05b35a2Smrgbase_name (const char *name) 4563f05b35a2Smrg{ 4564f05b35a2Smrg const char *base; 4565e0963edeSmrg 4566f05b35a2Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4567f05b35a2Smrg /* Skip over the disk name in MSDOS pathnames. */ 4568f05b35a2Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 4569f05b35a2Smrg name += 2; 4570f05b35a2Smrg#endif 4571e0963edeSmrg 4572f05b35a2Smrg for (base = name; *name; name++) 4573f05b35a2Smrg if (IS_DIR_SEPARATOR (*name)) 4574f05b35a2Smrg base = name + 1; 4575f05b35a2Smrg return base; 4576f05b35a2Smrg} 4577e0963edeSmrg 4578f05b35a2Smrgint 4579f05b35a2Smrgcheck_executable (const char *path) 4580f05b35a2Smrg{ 4581f05b35a2Smrg struct stat st; 4582e0963edeSmrg 458349e108a1Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 458449e108a1Smrg nonempty (path)); 4585f05b35a2Smrg if ((!path) || (!*path)) 4586f05b35a2Smrg return 0; 4587e0963edeSmrg 4588f05b35a2Smrg if ((stat (path, &st) >= 0) 4589f05b35a2Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 4590f05b35a2Smrg return 1; 4591f05b35a2Smrg else 4592f05b35a2Smrg return 0; 4593f05b35a2Smrg} 4594e0963edeSmrg 4595f05b35a2Smrgint 4596f05b35a2Smrgmake_executable (const char *path) 4597f05b35a2Smrg{ 4598f05b35a2Smrg int rval = 0; 4599f05b35a2Smrg struct stat st; 4600e0963edeSmrg 460149e108a1Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 460249e108a1Smrg nonempty (path)); 4603f05b35a2Smrg if ((!path) || (!*path)) 4604f05b35a2Smrg return 0; 4605e0963edeSmrg 4606f05b35a2Smrg if (stat (path, &st) >= 0) 4607f05b35a2Smrg { 4608f05b35a2Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 4609f05b35a2Smrg } 4610f05b35a2Smrg return rval; 4611f05b35a2Smrg} 4612e0963edeSmrg 4613f05b35a2Smrg/* Searches for the full path of the wrapper. Returns 4614f05b35a2Smrg newly allocated full path name if found, NULL otherwise 4615f05b35a2Smrg Does not chase symlinks, even on platforms that support them. 4616f05b35a2Smrg*/ 4617f05b35a2Smrgchar * 4618f05b35a2Smrgfind_executable (const char *wrapper) 4619f05b35a2Smrg{ 4620f05b35a2Smrg int has_slash = 0; 4621f05b35a2Smrg const char *p; 4622f05b35a2Smrg const char *p_next; 4623f05b35a2Smrg /* static buffer for getcwd */ 4624f05b35a2Smrg char tmp[LT_PATHMAX + 1]; 4625f05b35a2Smrg int tmp_len; 4626f05b35a2Smrg char *concat_name; 4627e0963edeSmrg 462849e108a1Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 462949e108a1Smrg nonempty (wrapper)); 4630e0963edeSmrg 4631f05b35a2Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 4632f05b35a2Smrg return NULL; 4633e0963edeSmrg 4634f05b35a2Smrg /* Absolute path? */ 4635f05b35a2Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4636f05b35a2Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 4637f05b35a2Smrg { 4638f05b35a2Smrg concat_name = xstrdup (wrapper); 4639f05b35a2Smrg if (check_executable (concat_name)) 4640f05b35a2Smrg return concat_name; 4641f05b35a2Smrg XFREE (concat_name); 4642f05b35a2Smrg } 4643f05b35a2Smrg else 4644f05b35a2Smrg { 4645f05b35a2Smrg#endif 4646f05b35a2Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 4647f05b35a2Smrg { 4648f05b35a2Smrg concat_name = xstrdup (wrapper); 4649f05b35a2Smrg if (check_executable (concat_name)) 4650f05b35a2Smrg return concat_name; 4651f05b35a2Smrg XFREE (concat_name); 4652f05b35a2Smrg } 4653f05b35a2Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4654f05b35a2Smrg } 4655f05b35a2Smrg#endif 4656e0963edeSmrg 4657f05b35a2Smrg for (p = wrapper; *p; p++) 4658f05b35a2Smrg if (*p == '/') 4659f05b35a2Smrg { 4660f05b35a2Smrg has_slash = 1; 4661f05b35a2Smrg break; 4662f05b35a2Smrg } 4663f05b35a2Smrg if (!has_slash) 4664f05b35a2Smrg { 4665f05b35a2Smrg /* no slashes; search PATH */ 4666f05b35a2Smrg const char *path = getenv ("PATH"); 4667f05b35a2Smrg if (path != NULL) 4668f05b35a2Smrg { 4669f05b35a2Smrg for (p = path; *p; p = p_next) 4670f05b35a2Smrg { 4671f05b35a2Smrg const char *q; 4672f05b35a2Smrg size_t p_len; 4673f05b35a2Smrg for (q = p; *q; q++) 4674f05b35a2Smrg if (IS_PATH_SEPARATOR (*q)) 4675f05b35a2Smrg break; 4676f05b35a2Smrg p_len = q - p; 4677f05b35a2Smrg p_next = (*q == '\0' ? q : q + 1); 4678f05b35a2Smrg if (p_len == 0) 4679f05b35a2Smrg { 4680f05b35a2Smrg /* empty path: current directory */ 4681f05b35a2Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 468249e108a1Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 468349e108a1Smrg nonnull (strerror (errno))); 4684f05b35a2Smrg tmp_len = strlen (tmp); 4685f05b35a2Smrg concat_name = 4686f05b35a2Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4687f05b35a2Smrg memcpy (concat_name, tmp, tmp_len); 4688f05b35a2Smrg concat_name[tmp_len] = '/'; 4689f05b35a2Smrg strcpy (concat_name + tmp_len + 1, wrapper); 4690f05b35a2Smrg } 4691f05b35a2Smrg else 4692f05b35a2Smrg { 4693f05b35a2Smrg concat_name = 4694f05b35a2Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 4695f05b35a2Smrg memcpy (concat_name, p, p_len); 4696f05b35a2Smrg concat_name[p_len] = '/'; 4697f05b35a2Smrg strcpy (concat_name + p_len + 1, wrapper); 4698f05b35a2Smrg } 4699f05b35a2Smrg if (check_executable (concat_name)) 4700f05b35a2Smrg return concat_name; 4701f05b35a2Smrg XFREE (concat_name); 4702f05b35a2Smrg } 4703f05b35a2Smrg } 4704f05b35a2Smrg /* not found in PATH; assume curdir */ 4705f05b35a2Smrg } 4706f05b35a2Smrg /* Relative path | not found in path: prepend cwd */ 4707f05b35a2Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 470849e108a1Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 470949e108a1Smrg nonnull (strerror (errno))); 4710f05b35a2Smrg tmp_len = strlen (tmp); 4711f05b35a2Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4712f05b35a2Smrg memcpy (concat_name, tmp, tmp_len); 4713f05b35a2Smrg concat_name[tmp_len] = '/'; 4714f05b35a2Smrg strcpy (concat_name + tmp_len + 1, wrapper); 4715e0963edeSmrg 4716f05b35a2Smrg if (check_executable (concat_name)) 4717f05b35a2Smrg return concat_name; 4718f05b35a2Smrg XFREE (concat_name); 4719f05b35a2Smrg return NULL; 4720f05b35a2Smrg} 4721e0963edeSmrg 4722f05b35a2Smrgchar * 4723f05b35a2Smrgchase_symlinks (const char *pathspec) 4724f05b35a2Smrg{ 4725f05b35a2Smrg#ifndef S_ISLNK 4726f05b35a2Smrg return xstrdup (pathspec); 4727f05b35a2Smrg#else 4728f05b35a2Smrg char buf[LT_PATHMAX]; 4729f05b35a2Smrg struct stat s; 4730f05b35a2Smrg char *tmp_pathspec = xstrdup (pathspec); 4731f05b35a2Smrg char *p; 4732f05b35a2Smrg int has_symlinks = 0; 4733f05b35a2Smrg while (strlen (tmp_pathspec) && !has_symlinks) 4734f05b35a2Smrg { 473549e108a1Smrg lt_debugprintf (__FILE__, __LINE__, 473649e108a1Smrg "checking path component for symlinks: %s\n", 473749e108a1Smrg tmp_pathspec); 4738f05b35a2Smrg if (lstat (tmp_pathspec, &s) == 0) 4739f05b35a2Smrg { 4740f05b35a2Smrg if (S_ISLNK (s.st_mode) != 0) 4741f05b35a2Smrg { 4742f05b35a2Smrg has_symlinks = 1; 4743f05b35a2Smrg break; 4744f05b35a2Smrg } 4745e0963edeSmrg 4746f05b35a2Smrg /* search backwards for last DIR_SEPARATOR */ 4747f05b35a2Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 4748f05b35a2Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4749f05b35a2Smrg p--; 4750f05b35a2Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4751f05b35a2Smrg { 4752f05b35a2Smrg /* no more DIR_SEPARATORS left */ 4753f05b35a2Smrg break; 4754f05b35a2Smrg } 4755f05b35a2Smrg *p = '\0'; 4756f05b35a2Smrg } 4757f05b35a2Smrg else 4758f05b35a2Smrg { 475949e108a1Smrg lt_fatal (__FILE__, __LINE__, 476049e108a1Smrg "error accessing file \"%s\": %s", 476149e108a1Smrg tmp_pathspec, nonnull (strerror (errno))); 4762f05b35a2Smrg } 4763f05b35a2Smrg } 4764f05b35a2Smrg XFREE (tmp_pathspec); 4765e0963edeSmrg 4766f05b35a2Smrg if (!has_symlinks) 4767f05b35a2Smrg { 4768f05b35a2Smrg return xstrdup (pathspec); 4769f05b35a2Smrg } 4770e0963edeSmrg 4771f05b35a2Smrg tmp_pathspec = realpath (pathspec, buf); 4772f05b35a2Smrg if (tmp_pathspec == 0) 4773f05b35a2Smrg { 477449e108a1Smrg lt_fatal (__FILE__, __LINE__, 477549e108a1Smrg "could not follow symlinks for %s", pathspec); 4776f05b35a2Smrg } 4777f05b35a2Smrg return xstrdup (tmp_pathspec); 4778f05b35a2Smrg#endif 4779f05b35a2Smrg} 4780e0963edeSmrg 4781f05b35a2Smrgchar * 4782f05b35a2Smrgstrendzap (char *str, const char *pat) 4783f05b35a2Smrg{ 4784f05b35a2Smrg size_t len, patlen; 4785e0963edeSmrg 4786f05b35a2Smrg assert (str != NULL); 4787f05b35a2Smrg assert (pat != NULL); 4788e0963edeSmrg 4789f05b35a2Smrg len = strlen (str); 4790f05b35a2Smrg patlen = strlen (pat); 4791e0963edeSmrg 4792f05b35a2Smrg if (patlen <= len) 4793f05b35a2Smrg { 4794f05b35a2Smrg str += len - patlen; 4795f05b35a2Smrg if (strcmp (str, pat) == 0) 4796f05b35a2Smrg *str = '\0'; 4797f05b35a2Smrg } 4798f05b35a2Smrg return str; 4799f05b35a2Smrg} 4800e0963edeSmrg 480149e108a1Smrgvoid 480249e108a1Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 480349e108a1Smrg{ 480449e108a1Smrg va_list args; 480549e108a1Smrg if (lt_debug) 480649e108a1Smrg { 480749e108a1Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 480849e108a1Smrg va_start (args, fmt); 480949e108a1Smrg (void) vfprintf (stderr, fmt, args); 481049e108a1Smrg va_end (args); 481149e108a1Smrg } 481249e108a1Smrg} 481349e108a1Smrg 4814f05b35a2Smrgstatic void 481549e108a1Smrglt_error_core (int exit_status, const char *file, 481649e108a1Smrg int line, const char *mode, 4817f05b35a2Smrg const char *message, va_list ap) 4818f05b35a2Smrg{ 481949e108a1Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 4820f05b35a2Smrg vfprintf (stderr, message, ap); 4821f05b35a2Smrg fprintf (stderr, ".\n"); 4822e0963edeSmrg 4823f05b35a2Smrg if (exit_status >= 0) 4824f05b35a2Smrg exit (exit_status); 4825f05b35a2Smrg} 4826e0963edeSmrg 4827f05b35a2Smrgvoid 482849e108a1Smrglt_fatal (const char *file, int line, const char *message, ...) 4829f05b35a2Smrg{ 4830f05b35a2Smrg va_list ap; 4831f05b35a2Smrg va_start (ap, message); 483249e108a1Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 4833f05b35a2Smrg va_end (ap); 4834f05b35a2Smrg} 4835e0963edeSmrg 483649e108a1Smrgstatic const char * 483749e108a1Smrgnonnull (const char *s) 483849e108a1Smrg{ 483949e108a1Smrg return s ? s : "(null)"; 484049e108a1Smrg} 484149e108a1Smrg 484249e108a1Smrgstatic const char * 484349e108a1Smrgnonempty (const char *s) 484449e108a1Smrg{ 484549e108a1Smrg return (s && !*s) ? "(empty)" : nonnull (s); 484649e108a1Smrg} 484749e108a1Smrg 4848f05b35a2Smrgvoid 4849f05b35a2Smrglt_setenv (const char *name, const char *value) 4850f05b35a2Smrg{ 485149e108a1Smrg lt_debugprintf (__FILE__, __LINE__, 485249e108a1Smrg "(lt_setenv) setting '%s' to '%s'\n", 485349e108a1Smrg nonnull (name), nonnull (value)); 4854f05b35a2Smrg { 4855f05b35a2Smrg#ifdef HAVE_SETENV 4856f05b35a2Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 4857f05b35a2Smrg char *str = xstrdup (value); 4858f05b35a2Smrg setenv (name, str, 1); 4859f05b35a2Smrg#else 4860f05b35a2Smrg int len = strlen (name) + 1 + strlen (value) + 1; 4861f05b35a2Smrg char *str = XMALLOC (char, len); 4862f05b35a2Smrg sprintf (str, "%s=%s", name, value); 4863f05b35a2Smrg if (putenv (str) != EXIT_SUCCESS) 4864f05b35a2Smrg { 4865f05b35a2Smrg XFREE (str); 4866f05b35a2Smrg } 4867f05b35a2Smrg#endif 4868f05b35a2Smrg } 4869f05b35a2Smrg} 4870e0963edeSmrg 4871f05b35a2Smrgchar * 4872f05b35a2Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 4873f05b35a2Smrg{ 4874f05b35a2Smrg char *new_value; 4875f05b35a2Smrg if (orig_value && *orig_value) 4876f05b35a2Smrg { 4877f05b35a2Smrg int orig_value_len = strlen (orig_value); 4878f05b35a2Smrg int add_len = strlen (add); 4879f05b35a2Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 4880f05b35a2Smrg if (to_end) 4881f05b35a2Smrg { 4882f05b35a2Smrg strcpy (new_value, orig_value); 4883f05b35a2Smrg strcpy (new_value + orig_value_len, add); 4884f05b35a2Smrg } 4885f05b35a2Smrg else 4886f05b35a2Smrg { 4887f05b35a2Smrg strcpy (new_value, add); 4888f05b35a2Smrg strcpy (new_value + add_len, orig_value); 4889f05b35a2Smrg } 4890f05b35a2Smrg } 4891f05b35a2Smrg else 4892f05b35a2Smrg { 4893f05b35a2Smrg new_value = xstrdup (add); 4894f05b35a2Smrg } 4895f05b35a2Smrg return new_value; 4896f05b35a2Smrg} 4897e0963edeSmrg 4898f05b35a2Smrgvoid 4899f05b35a2Smrglt_update_exe_path (const char *name, const char *value) 4900f05b35a2Smrg{ 490149e108a1Smrg lt_debugprintf (__FILE__, __LINE__, 490249e108a1Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 490349e108a1Smrg nonnull (name), nonnull (value)); 4904e0963edeSmrg 4905f05b35a2Smrg if (name && *name && value && *value) 4906f05b35a2Smrg { 4907f05b35a2Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 4908f05b35a2Smrg /* some systems can't cope with a ':'-terminated path #' */ 4909f05b35a2Smrg int len = strlen (new_value); 4910f05b35a2Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 4911f05b35a2Smrg { 4912f05b35a2Smrg new_value[len-1] = '\0'; 4913f05b35a2Smrg } 4914f05b35a2Smrg lt_setenv (name, new_value); 4915f05b35a2Smrg XFREE (new_value); 4916f05b35a2Smrg } 4917f05b35a2Smrg} 4918e0963edeSmrg 4919f05b35a2Smrgvoid 4920f05b35a2Smrglt_update_lib_path (const char *name, const char *value) 4921f05b35a2Smrg{ 492249e108a1Smrg lt_debugprintf (__FILE__, __LINE__, 492349e108a1Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 492449e108a1Smrg nonnull (name), nonnull (value)); 4925e0963edeSmrg 4926f05b35a2Smrg if (name && *name && value && *value) 4927f05b35a2Smrg { 4928f05b35a2Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 4929f05b35a2Smrg lt_setenv (name, new_value); 4930f05b35a2Smrg XFREE (new_value); 4931f05b35a2Smrg } 4932f05b35a2Smrg} 4933e0963edeSmrg 493449e108a1SmrgEOF 493549e108a1Smrg case $host_os in 493649e108a1Smrg mingw*) 493749e108a1Smrg cat <<"EOF" 493849e108a1Smrg 493949e108a1Smrg/* Prepares an argument vector before calling spawn(). 494049e108a1Smrg Note that spawn() does not by itself call the command interpreter 494149e108a1Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 494249e108a1Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 494349e108a1Smrg GetVersionEx(&v); 494449e108a1Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 494549e108a1Smrg }) ? "cmd.exe" : "command.com"). 494649e108a1Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 494749e108a1Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 494849e108a1Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 494949e108a1Smrg special way: 495049e108a1Smrg - Space and tab are interpreted as delimiters. They are not treated as 495149e108a1Smrg delimiters if they are surrounded by double quotes: "...". 495249e108a1Smrg - Unescaped double quotes are removed from the input. Their only effect is 495349e108a1Smrg that within double quotes, space and tab are treated like normal 495449e108a1Smrg characters. 495549e108a1Smrg - Backslashes not followed by double quotes are not special. 495649e108a1Smrg - But 2*n+1 backslashes followed by a double quote become 495749e108a1Smrg n backslashes followed by a double quote (n >= 0): 495849e108a1Smrg \" -> " 495949e108a1Smrg \\\" -> \" 496049e108a1Smrg \\\\\" -> \\" 496149e108a1Smrg */ 496249e108a1Smrg#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" 496349e108a1Smrg#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" 496449e108a1Smrgchar ** 496549e108a1Smrgprepare_spawn (char **argv) 496649e108a1Smrg{ 496749e108a1Smrg size_t argc; 496849e108a1Smrg char **new_argv; 496949e108a1Smrg size_t i; 497049e108a1Smrg 497149e108a1Smrg /* Count number of arguments. */ 497249e108a1Smrg for (argc = 0; argv[argc] != NULL; argc++) 497349e108a1Smrg ; 497449e108a1Smrg 497549e108a1Smrg /* Allocate new argument vector. */ 497649e108a1Smrg new_argv = XMALLOC (char *, argc + 1); 497749e108a1Smrg 497849e108a1Smrg /* Put quoted arguments into the new argument vector. */ 497949e108a1Smrg for (i = 0; i < argc; i++) 498049e108a1Smrg { 498149e108a1Smrg const char *string = argv[i]; 498249e108a1Smrg 498349e108a1Smrg if (string[0] == '\0') 498449e108a1Smrg new_argv[i] = xstrdup ("\"\""); 498549e108a1Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 498649e108a1Smrg { 498749e108a1Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 498849e108a1Smrg size_t length; 498949e108a1Smrg unsigned int backslashes; 499049e108a1Smrg const char *s; 499149e108a1Smrg char *quoted_string; 499249e108a1Smrg char *p; 499349e108a1Smrg 499449e108a1Smrg length = 0; 499549e108a1Smrg backslashes = 0; 499649e108a1Smrg if (quote_around) 499749e108a1Smrg length++; 499849e108a1Smrg for (s = string; *s != '\0'; s++) 499949e108a1Smrg { 500049e108a1Smrg char c = *s; 500149e108a1Smrg if (c == '"') 500249e108a1Smrg length += backslashes + 1; 500349e108a1Smrg length++; 500449e108a1Smrg if (c == '\\') 500549e108a1Smrg backslashes++; 500649e108a1Smrg else 500749e108a1Smrg backslashes = 0; 500849e108a1Smrg } 500949e108a1Smrg if (quote_around) 501049e108a1Smrg length += backslashes + 1; 501149e108a1Smrg 501249e108a1Smrg quoted_string = XMALLOC (char, length + 1); 501349e108a1Smrg 501449e108a1Smrg p = quoted_string; 501549e108a1Smrg backslashes = 0; 501649e108a1Smrg if (quote_around) 501749e108a1Smrg *p++ = '"'; 501849e108a1Smrg for (s = string; *s != '\0'; s++) 501949e108a1Smrg { 502049e108a1Smrg char c = *s; 502149e108a1Smrg if (c == '"') 502249e108a1Smrg { 502349e108a1Smrg unsigned int j; 502449e108a1Smrg for (j = backslashes + 1; j > 0; j--) 502549e108a1Smrg *p++ = '\\'; 502649e108a1Smrg } 502749e108a1Smrg *p++ = c; 502849e108a1Smrg if (c == '\\') 502949e108a1Smrg backslashes++; 503049e108a1Smrg else 503149e108a1Smrg backslashes = 0; 503249e108a1Smrg } 503349e108a1Smrg if (quote_around) 503449e108a1Smrg { 503549e108a1Smrg unsigned int j; 503649e108a1Smrg for (j = backslashes; j > 0; j--) 503749e108a1Smrg *p++ = '\\'; 503849e108a1Smrg *p++ = '"'; 503949e108a1Smrg } 504049e108a1Smrg *p = '\0'; 504149e108a1Smrg 504249e108a1Smrg new_argv[i] = quoted_string; 504349e108a1Smrg } 504449e108a1Smrg else 504549e108a1Smrg new_argv[i] = (char *) string; 504649e108a1Smrg } 504749e108a1Smrg new_argv[argc] = NULL; 504849e108a1Smrg 504949e108a1Smrg return new_argv; 505049e108a1Smrg} 505149e108a1SmrgEOF 505249e108a1Smrg ;; 505349e108a1Smrg esac 505449e108a1Smrg 505549e108a1Smrg cat <<"EOF" 505649e108a1Smrgvoid lt_dump_script (FILE* f) 505749e108a1Smrg{ 505849e108a1SmrgEOF 505949e108a1Smrg func_emit_wrapper yes | 506049e108a1Smrg $SED -e 's/\([\\"]\)/\\\1/g' \ 506149e108a1Smrg -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' 5062e0963edeSmrg 506349e108a1Smrg cat <<"EOF" 506449e108a1Smrg} 5065f05b35a2SmrgEOF 5066f05b35a2Smrg} 5067f05b35a2Smrg# end: func_emit_cwrapperexe_src 5068e0963edeSmrg 506949e108a1Smrg# func_win32_import_lib_p ARG 507049e108a1Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 507149e108a1Smrgfunc_win32_import_lib_p () 507249e108a1Smrg{ 507349e108a1Smrg $opt_debug 507449e108a1Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 507549e108a1Smrg *import*) : ;; 507649e108a1Smrg *) false ;; 507749e108a1Smrg esac 507849e108a1Smrg} 507949e108a1Smrg 5080f05b35a2Smrg# func_mode_link arg... 5081f05b35a2Smrgfunc_mode_link () 5082f05b35a2Smrg{ 5083f05b35a2Smrg $opt_debug 5084f05b35a2Smrg case $host in 5085f05b35a2Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5086f05b35a2Smrg # It is impossible to link a dll without this setting, and 5087f05b35a2Smrg # we shouldn't force the makefile maintainer to figure out 5088f05b35a2Smrg # which system we are compiling for in order to pass an extra 5089f05b35a2Smrg # flag for every libtool invocation. 5090f05b35a2Smrg # allow_undefined=no 5091e0963edeSmrg 5092f05b35a2Smrg # FIXME: Unfortunately, there are problems with the above when trying 5093f05b35a2Smrg # to make a dll which has undefined symbols, in which case not 5094f05b35a2Smrg # even a static library is built. For now, we need to specify 5095f05b35a2Smrg # -no-undefined on the libtool link line when we can be certain 5096f05b35a2Smrg # that all symbols are satisfied, otherwise we get a static library. 5097f05b35a2Smrg allow_undefined=yes 5098f05b35a2Smrg ;; 5099f05b35a2Smrg *) 5100f05b35a2Smrg allow_undefined=yes 5101f05b35a2Smrg ;; 5102f05b35a2Smrg esac 5103f05b35a2Smrg libtool_args=$nonopt 5104f05b35a2Smrg base_compile="$nonopt $@" 5105f05b35a2Smrg compile_command=$nonopt 5106f05b35a2Smrg finalize_command=$nonopt 5107e0963edeSmrg 5108f05b35a2Smrg compile_rpath= 5109f05b35a2Smrg finalize_rpath= 5110f05b35a2Smrg compile_shlibpath= 5111f05b35a2Smrg finalize_shlibpath= 5112f05b35a2Smrg convenience= 5113f05b35a2Smrg old_convenience= 5114f05b35a2Smrg deplibs= 5115f05b35a2Smrg old_deplibs= 5116f05b35a2Smrg compiler_flags= 5117f05b35a2Smrg linker_flags= 5118f05b35a2Smrg dllsearchpath= 5119f05b35a2Smrg lib_search_path=`pwd` 5120f05b35a2Smrg inst_prefix_dir= 5121f05b35a2Smrg new_inherited_linker_flags= 5122e0963edeSmrg 5123f05b35a2Smrg avoid_version=no 512449e108a1Smrg bindir= 5125f05b35a2Smrg dlfiles= 5126f05b35a2Smrg dlprefiles= 5127f05b35a2Smrg dlself=no 5128f05b35a2Smrg export_dynamic=no 5129f05b35a2Smrg export_symbols= 5130f05b35a2Smrg export_symbols_regex= 5131f05b35a2Smrg generated= 5132f05b35a2Smrg libobjs= 5133f05b35a2Smrg ltlibs= 5134f05b35a2Smrg module=no 5135f05b35a2Smrg no_install=no 5136f05b35a2Smrg objs= 5137f05b35a2Smrg non_pic_objects= 5138f05b35a2Smrg precious_files_regex= 5139f05b35a2Smrg prefer_static_libs=no 5140f05b35a2Smrg preload=no 5141f05b35a2Smrg prev= 5142f05b35a2Smrg prevarg= 5143f05b35a2Smrg release= 5144f05b35a2Smrg rpath= 5145f05b35a2Smrg xrpath= 5146f05b35a2Smrg perm_rpath= 5147f05b35a2Smrg temp_rpath= 5148f05b35a2Smrg thread_safe=no 5149f05b35a2Smrg vinfo= 5150f05b35a2Smrg vinfo_number=no 5151f05b35a2Smrg weak_libs= 5152f05b35a2Smrg single_module="${wl}-single_module" 5153f05b35a2Smrg func_infer_tag $base_compile 5154e0963edeSmrg 5155f05b35a2Smrg # We need to know -static, to get the right output filenames. 5156f05b35a2Smrg for arg 5157f05b35a2Smrg do 5158f05b35a2Smrg case $arg in 5159f05b35a2Smrg -shared) 5160f05b35a2Smrg test "$build_libtool_libs" != yes && \ 5161f05b35a2Smrg func_fatal_configuration "can not build a shared library" 5162f05b35a2Smrg build_old_libs=no 5163f05b35a2Smrg break 5164f05b35a2Smrg ;; 5165f05b35a2Smrg -all-static | -static | -static-libtool-libs) 5166f05b35a2Smrg case $arg in 5167f05b35a2Smrg -all-static) 5168f05b35a2Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 5169f05b35a2Smrg func_warning "complete static linking is impossible in this configuration" 5170f05b35a2Smrg fi 5171f05b35a2Smrg if test -n "$link_static_flag"; then 5172f05b35a2Smrg dlopen_self=$dlopen_self_static 5173f05b35a2Smrg fi 5174f05b35a2Smrg prefer_static_libs=yes 5175f05b35a2Smrg ;; 5176f05b35a2Smrg -static) 5177f05b35a2Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 5178f05b35a2Smrg dlopen_self=$dlopen_self_static 5179f05b35a2Smrg fi 5180f05b35a2Smrg prefer_static_libs=built 5181f05b35a2Smrg ;; 5182f05b35a2Smrg -static-libtool-libs) 5183f05b35a2Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 5184f05b35a2Smrg dlopen_self=$dlopen_self_static 5185f05b35a2Smrg fi 5186f05b35a2Smrg prefer_static_libs=yes 5187f05b35a2Smrg ;; 5188f05b35a2Smrg esac 5189f05b35a2Smrg build_libtool_libs=no 5190f05b35a2Smrg build_old_libs=yes 5191f05b35a2Smrg break 5192e0963edeSmrg ;; 5193e0963edeSmrg esac 5194f05b35a2Smrg done 5195e0963edeSmrg 5196f05b35a2Smrg # See if our shared archives depend on static archives. 5197f05b35a2Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 5198e0963edeSmrg 5199f05b35a2Smrg # Go through the arguments, transforming them on the way. 5200f05b35a2Smrg while test "$#" -gt 0; do 5201f05b35a2Smrg arg="$1" 5202f05b35a2Smrg shift 5203f05b35a2Smrg func_quote_for_eval "$arg" 5204f05b35a2Smrg qarg=$func_quote_for_eval_unquoted_result 5205f05b35a2Smrg func_append libtool_args " $func_quote_for_eval_result" 5206e0963edeSmrg 5207f05b35a2Smrg # If the previous option needs an argument, assign it. 5208f05b35a2Smrg if test -n "$prev"; then 5209f05b35a2Smrg case $prev in 5210f05b35a2Smrg output) 5211f05b35a2Smrg func_append compile_command " @OUTPUT@" 5212f05b35a2Smrg func_append finalize_command " @OUTPUT@" 5213e0963edeSmrg ;; 5214e0963edeSmrg esac 5215e0963edeSmrg 5216f05b35a2Smrg case $prev in 521749e108a1Smrg bindir) 521849e108a1Smrg bindir="$arg" 521949e108a1Smrg prev= 522049e108a1Smrg continue 522149e108a1Smrg ;; 5222f05b35a2Smrg dlfiles|dlprefiles) 5223f05b35a2Smrg if test "$preload" = no; then 5224f05b35a2Smrg # Add the symbol object into the linking commands. 5225f05b35a2Smrg func_append compile_command " @SYMFILE@" 5226f05b35a2Smrg func_append finalize_command " @SYMFILE@" 5227f05b35a2Smrg preload=yes 5228f05b35a2Smrg fi 5229f05b35a2Smrg case $arg in 5230f05b35a2Smrg *.la | *.lo) ;; # We handle these cases below. 5231f05b35a2Smrg force) 5232f05b35a2Smrg if test "$dlself" = no; then 5233f05b35a2Smrg dlself=needless 5234f05b35a2Smrg export_dynamic=yes 5235f05b35a2Smrg fi 5236f05b35a2Smrg prev= 5237f05b35a2Smrg continue 5238f05b35a2Smrg ;; 5239f05b35a2Smrg self) 5240f05b35a2Smrg if test "$prev" = dlprefiles; then 5241f05b35a2Smrg dlself=yes 5242f05b35a2Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 5243f05b35a2Smrg dlself=yes 5244e0963edeSmrg else 5245f05b35a2Smrg dlself=needless 5246f05b35a2Smrg export_dynamic=yes 5247e0963edeSmrg fi 5248f05b35a2Smrg prev= 5249f05b35a2Smrg continue 5250f05b35a2Smrg ;; 5251f05b35a2Smrg *) 5252f05b35a2Smrg if test "$prev" = dlfiles; then 525367ab2ff2Smrg func_append dlfiles " $arg" 5254f05b35a2Smrg else 525567ab2ff2Smrg func_append dlprefiles " $arg" 5256f05b35a2Smrg fi 5257f05b35a2Smrg prev= 5258f05b35a2Smrg continue 5259f05b35a2Smrg ;; 5260e0963edeSmrg esac 5261e0963edeSmrg ;; 5262f05b35a2Smrg expsyms) 5263f05b35a2Smrg export_symbols="$arg" 5264f05b35a2Smrg test -f "$arg" \ 5265f05b35a2Smrg || func_fatal_error "symbol file \`$arg' does not exist" 5266f05b35a2Smrg prev= 5267f05b35a2Smrg continue 5268f05b35a2Smrg ;; 5269f05b35a2Smrg expsyms_regex) 5270f05b35a2Smrg export_symbols_regex="$arg" 5271f05b35a2Smrg prev= 5272f05b35a2Smrg continue 5273f05b35a2Smrg ;; 5274f05b35a2Smrg framework) 5275f05b35a2Smrg case $host in 5276f05b35a2Smrg *-*-darwin*) 5277f05b35a2Smrg case "$deplibs " in 5278f05b35a2Smrg *" $qarg.ltframework "*) ;; 527967ab2ff2Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 5280f05b35a2Smrg ;; 5281e0963edeSmrg esac 5282f05b35a2Smrg ;; 5283e0963edeSmrg esac 5284f05b35a2Smrg prev= 5285f05b35a2Smrg continue 5286f05b35a2Smrg ;; 5287f05b35a2Smrg inst_prefix) 5288f05b35a2Smrg inst_prefix_dir="$arg" 5289f05b35a2Smrg prev= 5290f05b35a2Smrg continue 5291f05b35a2Smrg ;; 5292f05b35a2Smrg objectlist) 5293f05b35a2Smrg if test -f "$arg"; then 5294f05b35a2Smrg save_arg=$arg 5295f05b35a2Smrg moreargs= 5296f05b35a2Smrg for fil in `cat "$save_arg"` 5297f05b35a2Smrg do 529867ab2ff2Smrg# func_append moreargs " $fil" 5299f05b35a2Smrg arg=$fil 5300f05b35a2Smrg # A libtool-controlled object. 5301e0963edeSmrg 5302f05b35a2Smrg # Check to see that this really is a libtool object. 5303f05b35a2Smrg if func_lalib_unsafe_p "$arg"; then 5304f05b35a2Smrg pic_object= 5305f05b35a2Smrg non_pic_object= 5306e0963edeSmrg 5307f05b35a2Smrg # Read the .lo file 5308f05b35a2Smrg func_source "$arg" 5309e0963edeSmrg 5310f05b35a2Smrg if test -z "$pic_object" || 5311f05b35a2Smrg test -z "$non_pic_object" || 5312f05b35a2Smrg test "$pic_object" = none && 5313f05b35a2Smrg test "$non_pic_object" = none; then 5314f05b35a2Smrg func_fatal_error "cannot find name of object for \`$arg'" 5315f05b35a2Smrg fi 5316e0963edeSmrg 5317f05b35a2Smrg # Extract subdirectory from the argument. 5318f05b35a2Smrg func_dirname "$arg" "/" "" 5319f05b35a2Smrg xdir="$func_dirname_result" 5320e0963edeSmrg 5321f05b35a2Smrg if test "$pic_object" != none; then 5322f05b35a2Smrg # Prepend the subdirectory the object is found in. 5323f05b35a2Smrg pic_object="$xdir$pic_object" 5324e0963edeSmrg 5325f05b35a2Smrg if test "$prev" = dlfiles; then 5326f05b35a2Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 532767ab2ff2Smrg func_append dlfiles " $pic_object" 5328f05b35a2Smrg prev= 5329f05b35a2Smrg continue 5330f05b35a2Smrg else 5331f05b35a2Smrg # If libtool objects are unsupported, then we need to preload. 5332f05b35a2Smrg prev=dlprefiles 5333f05b35a2Smrg fi 5334f05b35a2Smrg fi 5335e0963edeSmrg 5336f05b35a2Smrg # CHECK ME: I think I busted this. -Ossama 5337f05b35a2Smrg if test "$prev" = dlprefiles; then 5338f05b35a2Smrg # Preload the old-style object. 533967ab2ff2Smrg func_append dlprefiles " $pic_object" 5340f05b35a2Smrg prev= 5341f05b35a2Smrg fi 5342e0963edeSmrg 5343f05b35a2Smrg # A PIC object. 5344f05b35a2Smrg func_append libobjs " $pic_object" 5345f05b35a2Smrg arg="$pic_object" 5346f05b35a2Smrg fi 5347e0963edeSmrg 5348f05b35a2Smrg # Non-PIC object. 5349f05b35a2Smrg if test "$non_pic_object" != none; then 5350f05b35a2Smrg # Prepend the subdirectory the object is found in. 5351f05b35a2Smrg non_pic_object="$xdir$non_pic_object" 5352e0963edeSmrg 5353f05b35a2Smrg # A standard non-PIC object 5354f05b35a2Smrg func_append non_pic_objects " $non_pic_object" 5355f05b35a2Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 5356f05b35a2Smrg arg="$non_pic_object" 5357f05b35a2Smrg fi 5358f05b35a2Smrg else 5359f05b35a2Smrg # If the PIC object exists, use it instead. 5360f05b35a2Smrg # $xdir was prepended to $pic_object above. 5361f05b35a2Smrg non_pic_object="$pic_object" 5362f05b35a2Smrg func_append non_pic_objects " $non_pic_object" 5363f05b35a2Smrg fi 5364f05b35a2Smrg else 5365f05b35a2Smrg # Only an error if not doing a dry-run. 5366f05b35a2Smrg if $opt_dry_run; then 5367f05b35a2Smrg # Extract subdirectory from the argument. 5368f05b35a2Smrg func_dirname "$arg" "/" "" 5369f05b35a2Smrg xdir="$func_dirname_result" 5370f05b35a2Smrg 5371f05b35a2Smrg func_lo2o "$arg" 5372f05b35a2Smrg pic_object=$xdir$objdir/$func_lo2o_result 5373f05b35a2Smrg non_pic_object=$xdir$func_lo2o_result 5374f05b35a2Smrg func_append libobjs " $pic_object" 5375f05b35a2Smrg func_append non_pic_objects " $non_pic_object" 5376f05b35a2Smrg else 5377f05b35a2Smrg func_fatal_error "\`$arg' is not a valid libtool object" 5378f05b35a2Smrg fi 5379f05b35a2Smrg fi 5380e0963edeSmrg done 5381f05b35a2Smrg else 5382f05b35a2Smrg func_fatal_error "link input file \`$arg' does not exist" 5383e0963edeSmrg fi 5384f05b35a2Smrg arg=$save_arg 5385f05b35a2Smrg prev= 5386f05b35a2Smrg continue 5387f05b35a2Smrg ;; 5388f05b35a2Smrg precious_regex) 5389f05b35a2Smrg precious_files_regex="$arg" 5390f05b35a2Smrg prev= 5391f05b35a2Smrg continue 5392f05b35a2Smrg ;; 5393f05b35a2Smrg release) 5394f05b35a2Smrg release="-$arg" 5395f05b35a2Smrg prev= 5396f05b35a2Smrg continue 5397f05b35a2Smrg ;; 5398f05b35a2Smrg rpath | xrpath) 5399f05b35a2Smrg # We need an absolute path. 5400f05b35a2Smrg case $arg in 5401f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5402f05b35a2Smrg *) 5403f05b35a2Smrg func_fatal_error "only absolute run-paths are allowed" 5404f05b35a2Smrg ;; 5405e0963edeSmrg esac 5406f05b35a2Smrg if test "$prev" = rpath; then 5407f05b35a2Smrg case "$rpath " in 5408f05b35a2Smrg *" $arg "*) ;; 540967ab2ff2Smrg *) func_append rpath " $arg" ;; 5410f05b35a2Smrg esac 5411f05b35a2Smrg else 5412f05b35a2Smrg case "$xrpath " in 5413f05b35a2Smrg *" $arg "*) ;; 541467ab2ff2Smrg *) func_append xrpath " $arg" ;; 5415f05b35a2Smrg esac 5416f05b35a2Smrg fi 5417f05b35a2Smrg prev= 5418f05b35a2Smrg continue 5419f05b35a2Smrg ;; 5420f05b35a2Smrg shrext) 5421f05b35a2Smrg shrext_cmds="$arg" 5422f05b35a2Smrg prev= 5423f05b35a2Smrg continue 5424f05b35a2Smrg ;; 5425f05b35a2Smrg weak) 542667ab2ff2Smrg func_append weak_libs " $arg" 5427f05b35a2Smrg prev= 5428f05b35a2Smrg continue 5429f05b35a2Smrg ;; 5430f05b35a2Smrg xcclinker) 543167ab2ff2Smrg func_append linker_flags " $qarg" 543267ab2ff2Smrg func_append compiler_flags " $qarg" 5433f05b35a2Smrg prev= 5434f05b35a2Smrg func_append compile_command " $qarg" 5435f05b35a2Smrg func_append finalize_command " $qarg" 5436f05b35a2Smrg continue 5437f05b35a2Smrg ;; 5438f05b35a2Smrg xcompiler) 543967ab2ff2Smrg func_append compiler_flags " $qarg" 5440f05b35a2Smrg prev= 5441f05b35a2Smrg func_append compile_command " $qarg" 5442f05b35a2Smrg func_append finalize_command " $qarg" 5443f05b35a2Smrg continue 5444f05b35a2Smrg ;; 5445f05b35a2Smrg xlinker) 544667ab2ff2Smrg func_append linker_flags " $qarg" 544767ab2ff2Smrg func_append compiler_flags " $wl$qarg" 5448f05b35a2Smrg prev= 5449f05b35a2Smrg func_append compile_command " $wl$qarg" 5450f05b35a2Smrg func_append finalize_command " $wl$qarg" 5451f05b35a2Smrg continue 5452e0963edeSmrg ;; 5453e0963edeSmrg *) 5454f05b35a2Smrg eval "$prev=\"\$arg\"" 5455f05b35a2Smrg prev= 5456f05b35a2Smrg continue 5457e0963edeSmrg ;; 5458e0963edeSmrg esac 5459f05b35a2Smrg fi # test -n "$prev" 5460e0963edeSmrg 5461f05b35a2Smrg prevarg="$arg" 5462e0963edeSmrg 5463f05b35a2Smrg case $arg in 5464f05b35a2Smrg -all-static) 5465f05b35a2Smrg if test -n "$link_static_flag"; then 5466f05b35a2Smrg # See comment for -static flag below, for more details. 5467f05b35a2Smrg func_append compile_command " $link_static_flag" 5468f05b35a2Smrg func_append finalize_command " $link_static_flag" 5469e0963edeSmrg fi 5470f05b35a2Smrg continue 5471f05b35a2Smrg ;; 5472e0963edeSmrg 5473f05b35a2Smrg -allow-undefined) 5474f05b35a2Smrg # FIXME: remove this flag sometime in the future. 5475f05b35a2Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 5476f05b35a2Smrg ;; 5477e0963edeSmrg 5478f05b35a2Smrg -avoid-version) 5479f05b35a2Smrg avoid_version=yes 5480f05b35a2Smrg continue 5481f05b35a2Smrg ;; 5482e0963edeSmrg 548349e108a1Smrg -bindir) 548449e108a1Smrg prev=bindir 548549e108a1Smrg continue 548649e108a1Smrg ;; 548749e108a1Smrg 5488f05b35a2Smrg -dlopen) 5489f05b35a2Smrg prev=dlfiles 5490f05b35a2Smrg continue 5491f05b35a2Smrg ;; 5492e0963edeSmrg 5493f05b35a2Smrg -dlpreopen) 5494f05b35a2Smrg prev=dlprefiles 5495f05b35a2Smrg continue 5496f05b35a2Smrg ;; 5497e0963edeSmrg 5498f05b35a2Smrg -export-dynamic) 5499f05b35a2Smrg export_dynamic=yes 5500f05b35a2Smrg continue 5501f05b35a2Smrg ;; 5502e0963edeSmrg 5503f05b35a2Smrg -export-symbols | -export-symbols-regex) 5504f05b35a2Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 5505f05b35a2Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 5506f05b35a2Smrg fi 5507f05b35a2Smrg if test "X$arg" = "X-export-symbols"; then 5508f05b35a2Smrg prev=expsyms 5509e0963edeSmrg else 5510f05b35a2Smrg prev=expsyms_regex 5511e0963edeSmrg fi 5512f05b35a2Smrg continue 5513f05b35a2Smrg ;; 5514e0963edeSmrg 5515f05b35a2Smrg -framework) 5516f05b35a2Smrg prev=framework 5517f05b35a2Smrg continue 5518f05b35a2Smrg ;; 5519e0963edeSmrg 5520f05b35a2Smrg -inst-prefix-dir) 5521f05b35a2Smrg prev=inst_prefix 5522f05b35a2Smrg continue 5523f05b35a2Smrg ;; 5524e0963edeSmrg 5525f05b35a2Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 5526f05b35a2Smrg # so, if we see these flags be careful not to treat them like -L 5527f05b35a2Smrg -L[A-Z][A-Z]*:*) 5528f05b35a2Smrg case $with_gcc/$host in 5529f05b35a2Smrg no/*-*-irix* | /*-*-irix*) 5530f05b35a2Smrg func_append compile_command " $arg" 5531f05b35a2Smrg func_append finalize_command " $arg" 5532f05b35a2Smrg ;; 5533f05b35a2Smrg esac 5534f05b35a2Smrg continue 5535f05b35a2Smrg ;; 5536e0963edeSmrg 5537f05b35a2Smrg -L*) 553867ab2ff2Smrg func_stripname "-L" '' "$arg" 553967ab2ff2Smrg if test -z "$func_stripname_result"; then 5540f05b35a2Smrg if test "$#" -gt 0; then 5541f05b35a2Smrg func_fatal_error "require no space between \`-L' and \`$1'" 5542e0963edeSmrg else 5543f05b35a2Smrg func_fatal_error "need path for \`-L' option" 5544e0963edeSmrg fi 5545f05b35a2Smrg fi 554667ab2ff2Smrg func_resolve_sysroot "$func_stripname_result" 554767ab2ff2Smrg dir=$func_resolve_sysroot_result 5548f05b35a2Smrg # We need an absolute path. 5549f05b35a2Smrg case $dir in 5550f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5551f05b35a2Smrg *) 5552f05b35a2Smrg absdir=`cd "$dir" && pwd` 5553f05b35a2Smrg test -z "$absdir" && \ 5554f05b35a2Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 5555f05b35a2Smrg dir="$absdir" 5556f05b35a2Smrg ;; 5557e0963edeSmrg esac 5558f05b35a2Smrg case "$deplibs " in 555967ab2ff2Smrg *" -L$dir "* | *" $arg "*) 556067ab2ff2Smrg # Will only happen for absolute or sysroot arguments 556167ab2ff2Smrg ;; 5562f05b35a2Smrg *) 556367ab2ff2Smrg # Preserve sysroot, but never include relative directories 556467ab2ff2Smrg case $dir in 556567ab2ff2Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 556667ab2ff2Smrg *) func_append deplibs " -L$dir" ;; 556767ab2ff2Smrg esac 556867ab2ff2Smrg func_append lib_search_path " $dir" 5569f05b35a2Smrg ;; 5570e0963edeSmrg esac 5571e0963edeSmrg case $host in 5572f05b35a2Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 557349e108a1Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 5574f05b35a2Smrg case :$dllsearchpath: in 5575f05b35a2Smrg *":$dir:"*) ;; 5576f05b35a2Smrg ::) dllsearchpath=$dir;; 557767ab2ff2Smrg *) func_append dllsearchpath ":$dir";; 5578f05b35a2Smrg esac 5579f05b35a2Smrg case :$dllsearchpath: in 5580f05b35a2Smrg *":$testbindir:"*) ;; 5581f05b35a2Smrg ::) dllsearchpath=$testbindir;; 558267ab2ff2Smrg *) func_append dllsearchpath ":$testbindir";; 5583f05b35a2Smrg esac 5584f05b35a2Smrg ;; 5585e0963edeSmrg esac 5586f05b35a2Smrg continue 5587f05b35a2Smrg ;; 5588e0963edeSmrg 5589f05b35a2Smrg -l*) 5590f05b35a2Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 5591f05b35a2Smrg case $host in 559249e108a1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 5593f05b35a2Smrg # These systems don't actually have a C or math library (as such) 5594f05b35a2Smrg continue 5595f05b35a2Smrg ;; 5596f05b35a2Smrg *-*-os2*) 5597f05b35a2Smrg # These systems don't actually have a C library (as such) 5598f05b35a2Smrg test "X$arg" = "X-lc" && continue 5599f05b35a2Smrg ;; 5600f05b35a2Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5601f05b35a2Smrg # Do not include libc due to us having libc/libc_r. 5602f05b35a2Smrg test "X$arg" = "X-lc" && continue 5603f05b35a2Smrg ;; 5604f05b35a2Smrg *-*-rhapsody* | *-*-darwin1.[012]) 5605f05b35a2Smrg # Rhapsody C and math libraries are in the System framework 560667ab2ff2Smrg func_append deplibs " System.ltframework" 5607f05b35a2Smrg continue 5608f05b35a2Smrg ;; 5609f05b35a2Smrg *-*-sco3.2v5* | *-*-sco5v6*) 5610f05b35a2Smrg # Causes problems with __ctype 5611f05b35a2Smrg test "X$arg" = "X-lc" && continue 5612f05b35a2Smrg ;; 5613f05b35a2Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 5614f05b35a2Smrg # Compiler inserts libc in the correct place for threads to work 5615f05b35a2Smrg test "X$arg" = "X-lc" && continue 5616f05b35a2Smrg ;; 5617f05b35a2Smrg esac 5618f05b35a2Smrg elif test "X$arg" = "X-lc_r"; then 5619f05b35a2Smrg case $host in 5620f05b35a2Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5621f05b35a2Smrg # Do not include libc_r directly, use -pthread flag. 5622f05b35a2Smrg continue 5623f05b35a2Smrg ;; 5624f05b35a2Smrg esac 5625f05b35a2Smrg fi 562667ab2ff2Smrg func_append deplibs " $arg" 5627f05b35a2Smrg continue 5628f05b35a2Smrg ;; 5629e0963edeSmrg 5630f05b35a2Smrg -module) 5631f05b35a2Smrg module=yes 5632f05b35a2Smrg continue 5633f05b35a2Smrg ;; 5634e0963edeSmrg 5635f05b35a2Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 5636f05b35a2Smrg # classes, name mangling, and exception handling. 5637f05b35a2Smrg # Darwin uses the -arch flag to determine output architecture. 563867ab2ff2Smrg -model|-arch|-isysroot|--sysroot) 563967ab2ff2Smrg func_append compiler_flags " $arg" 5640f05b35a2Smrg func_append compile_command " $arg" 5641f05b35a2Smrg func_append finalize_command " $arg" 5642f05b35a2Smrg prev=xcompiler 5643f05b35a2Smrg continue 5644f05b35a2Smrg ;; 5645e0963edeSmrg 5646f05b35a2Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 564767ab2ff2Smrg func_append compiler_flags " $arg" 5648f05b35a2Smrg func_append compile_command " $arg" 5649f05b35a2Smrg func_append finalize_command " $arg" 5650f05b35a2Smrg case "$new_inherited_linker_flags " in 5651f05b35a2Smrg *" $arg "*) ;; 565267ab2ff2Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 5653f05b35a2Smrg esac 5654f05b35a2Smrg continue 5655f05b35a2Smrg ;; 5656e0963edeSmrg 5657f05b35a2Smrg -multi_module) 5658f05b35a2Smrg single_module="${wl}-multi_module" 5659f05b35a2Smrg continue 5660f05b35a2Smrg ;; 5661e0963edeSmrg 5662f05b35a2Smrg -no-fast-install) 5663f05b35a2Smrg fast_install=no 5664f05b35a2Smrg continue 5665f05b35a2Smrg ;; 5666e0963edeSmrg 5667f05b35a2Smrg -no-install) 5668f05b35a2Smrg case $host in 5669f05b35a2Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 5670f05b35a2Smrg # The PATH hackery in wrapper scripts is required on Windows 5671f05b35a2Smrg # and Darwin in order for the loader to find any dlls it needs. 5672f05b35a2Smrg func_warning "\`-no-install' is ignored for $host" 5673f05b35a2Smrg func_warning "assuming \`-no-fast-install' instead" 5674f05b35a2Smrg fast_install=no 5675f05b35a2Smrg ;; 5676f05b35a2Smrg *) no_install=yes ;; 5677f05b35a2Smrg esac 5678f05b35a2Smrg continue 5679f05b35a2Smrg ;; 5680e0963edeSmrg 5681f05b35a2Smrg -no-undefined) 5682f05b35a2Smrg allow_undefined=no 5683f05b35a2Smrg continue 5684f05b35a2Smrg ;; 5685e0963edeSmrg 5686f05b35a2Smrg -objectlist) 5687f05b35a2Smrg prev=objectlist 5688f05b35a2Smrg continue 5689f05b35a2Smrg ;; 5690e0963edeSmrg 5691f05b35a2Smrg -o) prev=output ;; 5692e0963edeSmrg 5693f05b35a2Smrg -precious-files-regex) 5694f05b35a2Smrg prev=precious_regex 5695f05b35a2Smrg continue 5696f05b35a2Smrg ;; 5697e0963edeSmrg 5698f05b35a2Smrg -release) 5699f05b35a2Smrg prev=release 5700f05b35a2Smrg continue 5701f05b35a2Smrg ;; 5702e0963edeSmrg 5703f05b35a2Smrg -rpath) 5704f05b35a2Smrg prev=rpath 5705f05b35a2Smrg continue 5706f05b35a2Smrg ;; 5707e0963edeSmrg 5708f05b35a2Smrg -R) 5709f05b35a2Smrg prev=xrpath 5710f05b35a2Smrg continue 5711f05b35a2Smrg ;; 5712e0963edeSmrg 5713f05b35a2Smrg -R*) 5714f05b35a2Smrg func_stripname '-R' '' "$arg" 5715f05b35a2Smrg dir=$func_stripname_result 5716f05b35a2Smrg # We need an absolute path. 5717f05b35a2Smrg case $dir in 5718f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 571967ab2ff2Smrg =*) 572067ab2ff2Smrg func_stripname '=' '' "$dir" 572167ab2ff2Smrg dir=$lt_sysroot$func_stripname_result 572267ab2ff2Smrg ;; 5723f05b35a2Smrg *) 5724f05b35a2Smrg func_fatal_error "only absolute run-paths are allowed" 5725f05b35a2Smrg ;; 5726f05b35a2Smrg esac 5727f05b35a2Smrg case "$xrpath " in 5728f05b35a2Smrg *" $dir "*) ;; 572967ab2ff2Smrg *) func_append xrpath " $dir" ;; 5730f05b35a2Smrg esac 5731f05b35a2Smrg continue 5732f05b35a2Smrg ;; 5733e0963edeSmrg 5734f05b35a2Smrg -shared) 5735f05b35a2Smrg # The effects of -shared are defined in a previous loop. 5736f05b35a2Smrg continue 5737f05b35a2Smrg ;; 5738e0963edeSmrg 5739f05b35a2Smrg -shrext) 5740f05b35a2Smrg prev=shrext 5741f05b35a2Smrg continue 5742f05b35a2Smrg ;; 5743e0963edeSmrg 5744f05b35a2Smrg -static | -static-libtool-libs) 5745f05b35a2Smrg # The effects of -static are defined in a previous loop. 5746f05b35a2Smrg # We used to do the same as -all-static on platforms that 5747f05b35a2Smrg # didn't have a PIC flag, but the assumption that the effects 5748f05b35a2Smrg # would be equivalent was wrong. It would break on at least 5749f05b35a2Smrg # Digital Unix and AIX. 5750f05b35a2Smrg continue 5751f05b35a2Smrg ;; 5752e0963edeSmrg 5753f05b35a2Smrg -thread-safe) 5754f05b35a2Smrg thread_safe=yes 5755f05b35a2Smrg continue 5756f05b35a2Smrg ;; 5757e0963edeSmrg 5758f05b35a2Smrg -version-info) 5759f05b35a2Smrg prev=vinfo 5760f05b35a2Smrg continue 5761f05b35a2Smrg ;; 5762e0963edeSmrg 5763f05b35a2Smrg -version-number) 5764f05b35a2Smrg prev=vinfo 5765f05b35a2Smrg vinfo_number=yes 5766f05b35a2Smrg continue 5767f05b35a2Smrg ;; 5768e0963edeSmrg 5769f05b35a2Smrg -weak) 5770f05b35a2Smrg prev=weak 5771f05b35a2Smrg continue 5772f05b35a2Smrg ;; 5773e0963edeSmrg 5774f05b35a2Smrg -Wc,*) 5775f05b35a2Smrg func_stripname '-Wc,' '' "$arg" 5776f05b35a2Smrg args=$func_stripname_result 5777f05b35a2Smrg arg= 5778f05b35a2Smrg save_ifs="$IFS"; IFS=',' 5779f05b35a2Smrg for flag in $args; do 5780f05b35a2Smrg IFS="$save_ifs" 5781f05b35a2Smrg func_quote_for_eval "$flag" 578267ab2ff2Smrg func_append arg " $func_quote_for_eval_result" 578367ab2ff2Smrg func_append compiler_flags " $func_quote_for_eval_result" 5784f05b35a2Smrg done 5785f05b35a2Smrg IFS="$save_ifs" 5786f05b35a2Smrg func_stripname ' ' '' "$arg" 5787f05b35a2Smrg arg=$func_stripname_result 5788f05b35a2Smrg ;; 5789e0963edeSmrg 5790f05b35a2Smrg -Wl,*) 5791f05b35a2Smrg func_stripname '-Wl,' '' "$arg" 5792f05b35a2Smrg args=$func_stripname_result 5793f05b35a2Smrg arg= 5794f05b35a2Smrg save_ifs="$IFS"; IFS=',' 5795f05b35a2Smrg for flag in $args; do 5796f05b35a2Smrg IFS="$save_ifs" 5797f05b35a2Smrg func_quote_for_eval "$flag" 579867ab2ff2Smrg func_append arg " $wl$func_quote_for_eval_result" 579967ab2ff2Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 580067ab2ff2Smrg func_append linker_flags " $func_quote_for_eval_result" 5801f05b35a2Smrg done 5802f05b35a2Smrg IFS="$save_ifs" 5803f05b35a2Smrg func_stripname ' ' '' "$arg" 5804f05b35a2Smrg arg=$func_stripname_result 5805f05b35a2Smrg ;; 5806e0963edeSmrg 5807f05b35a2Smrg -Xcompiler) 5808f05b35a2Smrg prev=xcompiler 5809f05b35a2Smrg continue 5810f05b35a2Smrg ;; 5811e0963edeSmrg 5812f05b35a2Smrg -Xlinker) 5813f05b35a2Smrg prev=xlinker 5814f05b35a2Smrg continue 5815f05b35a2Smrg ;; 5816e0963edeSmrg 5817f05b35a2Smrg -XCClinker) 5818f05b35a2Smrg prev=xcclinker 5819f05b35a2Smrg continue 5820f05b35a2Smrg ;; 5821e0963edeSmrg 5822f05b35a2Smrg # -msg_* for osf cc 5823f05b35a2Smrg -msg_*) 5824f05b35a2Smrg func_quote_for_eval "$arg" 5825f05b35a2Smrg arg="$func_quote_for_eval_result" 5826f05b35a2Smrg ;; 5827e0963edeSmrg 582849e108a1Smrg # Flags to be passed through unchanged, with rationale: 582949e108a1Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 583049e108a1Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 583149e108a1Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 583249e108a1Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 583349e108a1Smrg # -q* compiler args for the IBM compiler 583449e108a1Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 583549e108a1Smrg # -F/path path to uninstalled frameworks, gcc on darwin 583649e108a1Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 583749e108a1Smrg # @file GCC response files 583849e108a1Smrg # -tp=* Portland pgcc target processor selection 583967ab2ff2Smrg # --sysroot=* for sysroot support 584067ab2ff2Smrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 5841f05b35a2Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 584267ab2ff2Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 584367ab2ff2Smrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 5844f05b35a2Smrg func_quote_for_eval "$arg" 5845f05b35a2Smrg arg="$func_quote_for_eval_result" 5846f05b35a2Smrg func_append compile_command " $arg" 5847f05b35a2Smrg func_append finalize_command " $arg" 584867ab2ff2Smrg func_append compiler_flags " $arg" 5849f05b35a2Smrg continue 5850f05b35a2Smrg ;; 5851e0963edeSmrg 5852f05b35a2Smrg # Some other compiler flag. 5853f05b35a2Smrg -* | +*) 5854f05b35a2Smrg func_quote_for_eval "$arg" 5855f05b35a2Smrg arg="$func_quote_for_eval_result" 5856f05b35a2Smrg ;; 5857e0963edeSmrg 5858f05b35a2Smrg *.$objext) 5859f05b35a2Smrg # A standard object. 586067ab2ff2Smrg func_append objs " $arg" 5861f05b35a2Smrg ;; 5862e0963edeSmrg 5863f05b35a2Smrg *.lo) 5864f05b35a2Smrg # A libtool-controlled object. 5865e0963edeSmrg 5866f05b35a2Smrg # Check to see that this really is a libtool object. 5867f05b35a2Smrg if func_lalib_unsafe_p "$arg"; then 5868f05b35a2Smrg pic_object= 5869f05b35a2Smrg non_pic_object= 5870e0963edeSmrg 5871f05b35a2Smrg # Read the .lo file 5872f05b35a2Smrg func_source "$arg" 5873e0963edeSmrg 5874f05b35a2Smrg if test -z "$pic_object" || 5875f05b35a2Smrg test -z "$non_pic_object" || 5876f05b35a2Smrg test "$pic_object" = none && 5877f05b35a2Smrg test "$non_pic_object" = none; then 5878f05b35a2Smrg func_fatal_error "cannot find name of object for \`$arg'" 5879f05b35a2Smrg fi 5880e0963edeSmrg 5881f05b35a2Smrg # Extract subdirectory from the argument. 5882f05b35a2Smrg func_dirname "$arg" "/" "" 5883f05b35a2Smrg xdir="$func_dirname_result" 5884e0963edeSmrg 5885f05b35a2Smrg if test "$pic_object" != none; then 5886f05b35a2Smrg # Prepend the subdirectory the object is found in. 5887f05b35a2Smrg pic_object="$xdir$pic_object" 5888e0963edeSmrg 5889f05b35a2Smrg if test "$prev" = dlfiles; then 5890f05b35a2Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 589167ab2ff2Smrg func_append dlfiles " $pic_object" 5892f05b35a2Smrg prev= 5893f05b35a2Smrg continue 5894f05b35a2Smrg else 5895f05b35a2Smrg # If libtool objects are unsupported, then we need to preload. 5896f05b35a2Smrg prev=dlprefiles 5897f05b35a2Smrg fi 5898f05b35a2Smrg fi 5899e0963edeSmrg 5900f05b35a2Smrg # CHECK ME: I think I busted this. -Ossama 5901f05b35a2Smrg if test "$prev" = dlprefiles; then 5902f05b35a2Smrg # Preload the old-style object. 590367ab2ff2Smrg func_append dlprefiles " $pic_object" 5904f05b35a2Smrg prev= 5905f05b35a2Smrg fi 5906e0963edeSmrg 5907f05b35a2Smrg # A PIC object. 5908f05b35a2Smrg func_append libobjs " $pic_object" 5909f05b35a2Smrg arg="$pic_object" 5910f05b35a2Smrg fi 5911e0963edeSmrg 5912f05b35a2Smrg # Non-PIC object. 5913f05b35a2Smrg if test "$non_pic_object" != none; then 5914f05b35a2Smrg # Prepend the subdirectory the object is found in. 5915f05b35a2Smrg non_pic_object="$xdir$non_pic_object" 5916e0963edeSmrg 5917f05b35a2Smrg # A standard non-PIC object 5918f05b35a2Smrg func_append non_pic_objects " $non_pic_object" 5919f05b35a2Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 5920f05b35a2Smrg arg="$non_pic_object" 5921f05b35a2Smrg fi 5922f05b35a2Smrg else 5923f05b35a2Smrg # If the PIC object exists, use it instead. 5924f05b35a2Smrg # $xdir was prepended to $pic_object above. 5925f05b35a2Smrg non_pic_object="$pic_object" 5926f05b35a2Smrg func_append non_pic_objects " $non_pic_object" 5927f05b35a2Smrg fi 5928f05b35a2Smrg else 5929f05b35a2Smrg # Only an error if not doing a dry-run. 5930f05b35a2Smrg if $opt_dry_run; then 5931f05b35a2Smrg # Extract subdirectory from the argument. 5932f05b35a2Smrg func_dirname "$arg" "/" "" 5933f05b35a2Smrg xdir="$func_dirname_result" 5934f05b35a2Smrg 5935f05b35a2Smrg func_lo2o "$arg" 5936f05b35a2Smrg pic_object=$xdir$objdir/$func_lo2o_result 5937f05b35a2Smrg non_pic_object=$xdir$func_lo2o_result 5938f05b35a2Smrg func_append libobjs " $pic_object" 5939f05b35a2Smrg func_append non_pic_objects " $non_pic_object" 5940f05b35a2Smrg else 5941f05b35a2Smrg func_fatal_error "\`$arg' is not a valid libtool object" 5942f05b35a2Smrg fi 5943f05b35a2Smrg fi 5944f05b35a2Smrg ;; 5945e0963edeSmrg 5946f05b35a2Smrg *.$libext) 5947f05b35a2Smrg # An archive. 594867ab2ff2Smrg func_append deplibs " $arg" 594967ab2ff2Smrg func_append old_deplibs " $arg" 5950f05b35a2Smrg continue 5951f05b35a2Smrg ;; 5952e0963edeSmrg 5953f05b35a2Smrg *.la) 5954f05b35a2Smrg # A libtool-controlled library. 5955e0963edeSmrg 595667ab2ff2Smrg func_resolve_sysroot "$arg" 5957f05b35a2Smrg if test "$prev" = dlfiles; then 5958f05b35a2Smrg # This library was specified with -dlopen. 595967ab2ff2Smrg func_append dlfiles " $func_resolve_sysroot_result" 5960f05b35a2Smrg prev= 5961f05b35a2Smrg elif test "$prev" = dlprefiles; then 5962f05b35a2Smrg # The library was specified with -dlpreopen. 596367ab2ff2Smrg func_append dlprefiles " $func_resolve_sysroot_result" 5964f05b35a2Smrg prev= 5965f05b35a2Smrg else 596667ab2ff2Smrg func_append deplibs " $func_resolve_sysroot_result" 5967f05b35a2Smrg fi 5968f05b35a2Smrg continue 5969f05b35a2Smrg ;; 5970e0963edeSmrg 5971f05b35a2Smrg # Some other compiler argument. 5972f05b35a2Smrg *) 5973f05b35a2Smrg # Unknown arguments in both finalize_command and compile_command need 5974f05b35a2Smrg # to be aesthetically quoted because they are evaled later. 5975f05b35a2Smrg func_quote_for_eval "$arg" 5976f05b35a2Smrg arg="$func_quote_for_eval_result" 5977f05b35a2Smrg ;; 5978f05b35a2Smrg esac # arg 5979e0963edeSmrg 5980f05b35a2Smrg # Now actually substitute the argument into the commands. 5981f05b35a2Smrg if test -n "$arg"; then 5982f05b35a2Smrg func_append compile_command " $arg" 5983f05b35a2Smrg func_append finalize_command " $arg" 5984f05b35a2Smrg fi 5985f05b35a2Smrg done # argument parsing loop 5986e0963edeSmrg 5987f05b35a2Smrg test -n "$prev" && \ 5988f05b35a2Smrg func_fatal_help "the \`$prevarg' option requires an argument" 5989e0963edeSmrg 5990f05b35a2Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 5991f05b35a2Smrg eval arg=\"$export_dynamic_flag_spec\" 5992f05b35a2Smrg func_append compile_command " $arg" 5993f05b35a2Smrg func_append finalize_command " $arg" 5994f05b35a2Smrg fi 5995e0963edeSmrg 5996f05b35a2Smrg oldlibs= 5997f05b35a2Smrg # calculate the name of the file, without its directory 5998f05b35a2Smrg func_basename "$output" 5999f05b35a2Smrg outputname="$func_basename_result" 6000f05b35a2Smrg libobjs_save="$libobjs" 6001f05b35a2Smrg 6002f05b35a2Smrg if test -n "$shlibpath_var"; then 6003f05b35a2Smrg # get the directories listed in $shlibpath_var 600449e108a1Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 6005e0963edeSmrg else 6006f05b35a2Smrg shlib_search_path= 6007e0963edeSmrg fi 6008f05b35a2Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 6009f05b35a2Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 6010e0963edeSmrg 6011f05b35a2Smrg func_dirname "$output" "/" "" 6012f05b35a2Smrg output_objdir="$func_dirname_result$objdir" 601367ab2ff2Smrg func_to_tool_file "$output_objdir/" 601467ab2ff2Smrg tool_output_objdir=$func_to_tool_file_result 6015f05b35a2Smrg # Create the object directory. 6016f05b35a2Smrg func_mkdir_p "$output_objdir" 6017e0963edeSmrg 6018f05b35a2Smrg # Determine the type of output 6019f05b35a2Smrg case $output in 6020f05b35a2Smrg "") 6021f05b35a2Smrg func_fatal_help "you must specify an output file" 6022f05b35a2Smrg ;; 6023f05b35a2Smrg *.$libext) linkmode=oldlib ;; 6024f05b35a2Smrg *.lo | *.$objext) linkmode=obj ;; 6025f05b35a2Smrg *.la) linkmode=lib ;; 6026f05b35a2Smrg *) linkmode=prog ;; # Anything else should be a program. 6027f05b35a2Smrg esac 6028f05b35a2Smrg 6029f05b35a2Smrg specialdeplibs= 6030f05b35a2Smrg 6031f05b35a2Smrg libs= 6032f05b35a2Smrg # Find all interdependent deplibs by searching for libraries 6033f05b35a2Smrg # that are linked more than once (e.g. -la -lb -la) 6034f05b35a2Smrg for deplib in $deplibs; do 603567ab2ff2Smrg if $opt_preserve_dup_deps ; then 6036f05b35a2Smrg case "$libs " in 603767ab2ff2Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6038f05b35a2Smrg esac 6039f05b35a2Smrg fi 604067ab2ff2Smrg func_append libs " $deplib" 6041f05b35a2Smrg done 6042f05b35a2Smrg 6043f05b35a2Smrg if test "$linkmode" = lib; then 6044f05b35a2Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 6045f05b35a2Smrg 6046f05b35a2Smrg # Compute libraries that are listed more than once in $predeps 6047f05b35a2Smrg # $postdeps and mark them as special (i.e., whose duplicates are 6048f05b35a2Smrg # not to be eliminated). 6049f05b35a2Smrg pre_post_deps= 6050f05b35a2Smrg if $opt_duplicate_compiler_generated_deps; then 6051f05b35a2Smrg for pre_post_dep in $predeps $postdeps; do 6052f05b35a2Smrg case "$pre_post_deps " in 605367ab2ff2Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 6054f05b35a2Smrg esac 605567ab2ff2Smrg func_append pre_post_deps " $pre_post_dep" 6056f05b35a2Smrg done 6057f05b35a2Smrg fi 6058f05b35a2Smrg pre_post_deps= 6059f05b35a2Smrg fi 6060f05b35a2Smrg 6061f05b35a2Smrg deplibs= 6062f05b35a2Smrg newdependency_libs= 6063f05b35a2Smrg newlib_search_path= 6064f05b35a2Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 6065f05b35a2Smrg notinst_deplibs= # not-installed libtool libraries 6066f05b35a2Smrg notinst_path= # paths that contain not-installed libtool libraries 6067f05b35a2Smrg 6068f05b35a2Smrg case $linkmode in 6069f05b35a2Smrg lib) 6070f05b35a2Smrg passes="conv dlpreopen link" 6071f05b35a2Smrg for file in $dlfiles $dlprefiles; do 6072f05b35a2Smrg case $file in 6073f05b35a2Smrg *.la) ;; 6074f05b35a2Smrg *) 6075f05b35a2Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 6076f05b35a2Smrg ;; 6077f05b35a2Smrg esac 6078f05b35a2Smrg done 6079f05b35a2Smrg ;; 6080f05b35a2Smrg prog) 6081f05b35a2Smrg compile_deplibs= 6082f05b35a2Smrg finalize_deplibs= 6083f05b35a2Smrg alldeplibs=no 6084f05b35a2Smrg newdlfiles= 6085f05b35a2Smrg newdlprefiles= 6086f05b35a2Smrg passes="conv scan dlopen dlpreopen link" 6087f05b35a2Smrg ;; 6088f05b35a2Smrg *) passes="conv" 6089f05b35a2Smrg ;; 6090f05b35a2Smrg esac 6091f05b35a2Smrg 6092f05b35a2Smrg for pass in $passes; do 6093f05b35a2Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 6094f05b35a2Smrg # so that -L comes before libs that need it for instance... 6095f05b35a2Smrg if test "$linkmode,$pass" = "lib,link"; then 6096f05b35a2Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 6097f05b35a2Smrg ## order, and fix it there properly 6098f05b35a2Smrg tmp_deplibs= 6099f05b35a2Smrg for deplib in $deplibs; do 6100f05b35a2Smrg tmp_deplibs="$deplib $tmp_deplibs" 6101f05b35a2Smrg done 6102f05b35a2Smrg deplibs="$tmp_deplibs" 6103f05b35a2Smrg fi 6104f05b35a2Smrg 6105f05b35a2Smrg if test "$linkmode,$pass" = "lib,link" || 6106f05b35a2Smrg test "$linkmode,$pass" = "prog,scan"; then 6107f05b35a2Smrg libs="$deplibs" 6108f05b35a2Smrg deplibs= 6109f05b35a2Smrg fi 6110f05b35a2Smrg if test "$linkmode" = prog; then 6111f05b35a2Smrg case $pass in 6112f05b35a2Smrg dlopen) libs="$dlfiles" ;; 6113f05b35a2Smrg dlpreopen) libs="$dlprefiles" ;; 6114f05b35a2Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 6115f05b35a2Smrg esac 6116f05b35a2Smrg fi 6117f05b35a2Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 6118f05b35a2Smrg # Collect and forward deplibs of preopened libtool libs 6119f05b35a2Smrg for lib in $dlprefiles; do 6120f05b35a2Smrg # Ignore non-libtool-libs 6121f05b35a2Smrg dependency_libs= 612267ab2ff2Smrg func_resolve_sysroot "$lib" 6123f05b35a2Smrg case $lib in 612467ab2ff2Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 6125f05b35a2Smrg esac 6126f05b35a2Smrg 6127f05b35a2Smrg # Collect preopened libtool deplibs, except any this library 6128f05b35a2Smrg # has declared as weak libs 6129f05b35a2Smrg for deplib in $dependency_libs; do 613049e108a1Smrg func_basename "$deplib" 613149e108a1Smrg deplib_base=$func_basename_result 6132f05b35a2Smrg case " $weak_libs " in 6133f05b35a2Smrg *" $deplib_base "*) ;; 613467ab2ff2Smrg *) func_append deplibs " $deplib" ;; 6135f05b35a2Smrg esac 6136f05b35a2Smrg done 6137f05b35a2Smrg done 6138f05b35a2Smrg libs="$dlprefiles" 6139f05b35a2Smrg fi 6140f05b35a2Smrg if test "$pass" = dlopen; then 6141f05b35a2Smrg # Collect dlpreopened libraries 6142f05b35a2Smrg save_deplibs="$deplibs" 6143f05b35a2Smrg deplibs= 6144f05b35a2Smrg fi 6145f05b35a2Smrg 6146f05b35a2Smrg for deplib in $libs; do 6147f05b35a2Smrg lib= 6148f05b35a2Smrg found=no 6149f05b35a2Smrg case $deplib in 6150f05b35a2Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 6151f05b35a2Smrg if test "$linkmode,$pass" = "prog,link"; then 6152f05b35a2Smrg compile_deplibs="$deplib $compile_deplibs" 6153f05b35a2Smrg finalize_deplibs="$deplib $finalize_deplibs" 6154f05b35a2Smrg else 615567ab2ff2Smrg func_append compiler_flags " $deplib" 6156f05b35a2Smrg if test "$linkmode" = lib ; then 6157f05b35a2Smrg case "$new_inherited_linker_flags " in 6158f05b35a2Smrg *" $deplib "*) ;; 615967ab2ff2Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 6160f05b35a2Smrg esac 6161f05b35a2Smrg fi 6162f05b35a2Smrg fi 6163f05b35a2Smrg continue 6164f05b35a2Smrg ;; 6165f05b35a2Smrg -l*) 6166f05b35a2Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 6167f05b35a2Smrg func_warning "\`-l' is ignored for archives/objects" 6168f05b35a2Smrg continue 6169f05b35a2Smrg fi 6170f05b35a2Smrg func_stripname '-l' '' "$deplib" 6171f05b35a2Smrg name=$func_stripname_result 6172f05b35a2Smrg if test "$linkmode" = lib; then 6173f05b35a2Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 6174f05b35a2Smrg else 6175f05b35a2Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 6176f05b35a2Smrg fi 6177f05b35a2Smrg for searchdir in $searchdirs; do 6178f05b35a2Smrg for search_ext in .la $std_shrext .so .a; do 6179f05b35a2Smrg # Search the libtool library 6180f05b35a2Smrg lib="$searchdir/lib${name}${search_ext}" 6181f05b35a2Smrg if test -f "$lib"; then 6182f05b35a2Smrg if test "$search_ext" = ".la"; then 6183f05b35a2Smrg found=yes 6184f05b35a2Smrg else 6185f05b35a2Smrg found=no 6186f05b35a2Smrg fi 6187f05b35a2Smrg break 2 6188f05b35a2Smrg fi 6189f05b35a2Smrg done 6190f05b35a2Smrg done 6191f05b35a2Smrg if test "$found" != yes; then 6192f05b35a2Smrg # deplib doesn't seem to be a libtool library 6193f05b35a2Smrg if test "$linkmode,$pass" = "prog,link"; then 6194f05b35a2Smrg compile_deplibs="$deplib $compile_deplibs" 6195f05b35a2Smrg finalize_deplibs="$deplib $finalize_deplibs" 6196f05b35a2Smrg else 6197f05b35a2Smrg deplibs="$deplib $deplibs" 6198f05b35a2Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6199f05b35a2Smrg fi 6200f05b35a2Smrg continue 6201f05b35a2Smrg else # deplib is a libtool library 6202f05b35a2Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 6203f05b35a2Smrg # We need to do some special things here, and not later. 6204f05b35a2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 6205f05b35a2Smrg case " $predeps $postdeps " in 6206f05b35a2Smrg *" $deplib "*) 6207f05b35a2Smrg if func_lalib_p "$lib"; then 6208f05b35a2Smrg library_names= 6209f05b35a2Smrg old_library= 6210f05b35a2Smrg func_source "$lib" 6211f05b35a2Smrg for l in $old_library $library_names; do 6212f05b35a2Smrg ll="$l" 6213f05b35a2Smrg done 6214f05b35a2Smrg if test "X$ll" = "X$old_library" ; then # only static version available 6215f05b35a2Smrg found=no 6216f05b35a2Smrg func_dirname "$lib" "" "." 6217f05b35a2Smrg ladir="$func_dirname_result" 6218f05b35a2Smrg lib=$ladir/$old_library 6219f05b35a2Smrg if test "$linkmode,$pass" = "prog,link"; then 6220f05b35a2Smrg compile_deplibs="$deplib $compile_deplibs" 6221f05b35a2Smrg finalize_deplibs="$deplib $finalize_deplibs" 6222f05b35a2Smrg else 6223f05b35a2Smrg deplibs="$deplib $deplibs" 6224f05b35a2Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6225f05b35a2Smrg fi 6226f05b35a2Smrg continue 6227f05b35a2Smrg fi 6228f05b35a2Smrg fi 6229f05b35a2Smrg ;; 6230f05b35a2Smrg *) ;; 6231f05b35a2Smrg esac 6232f05b35a2Smrg fi 6233f05b35a2Smrg fi 6234f05b35a2Smrg ;; # -l 6235f05b35a2Smrg *.ltframework) 6236f05b35a2Smrg if test "$linkmode,$pass" = "prog,link"; then 6237f05b35a2Smrg compile_deplibs="$deplib $compile_deplibs" 6238f05b35a2Smrg finalize_deplibs="$deplib $finalize_deplibs" 6239f05b35a2Smrg else 6240f05b35a2Smrg deplibs="$deplib $deplibs" 6241f05b35a2Smrg if test "$linkmode" = lib ; then 6242f05b35a2Smrg case "$new_inherited_linker_flags " in 6243f05b35a2Smrg *" $deplib "*) ;; 624467ab2ff2Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 6245f05b35a2Smrg esac 6246f05b35a2Smrg fi 6247f05b35a2Smrg fi 6248f05b35a2Smrg continue 6249f05b35a2Smrg ;; 6250f05b35a2Smrg -L*) 6251f05b35a2Smrg case $linkmode in 6252f05b35a2Smrg lib) 6253f05b35a2Smrg deplibs="$deplib $deplibs" 6254f05b35a2Smrg test "$pass" = conv && continue 6255f05b35a2Smrg newdependency_libs="$deplib $newdependency_libs" 6256f05b35a2Smrg func_stripname '-L' '' "$deplib" 625767ab2ff2Smrg func_resolve_sysroot "$func_stripname_result" 625867ab2ff2Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 6259f05b35a2Smrg ;; 6260f05b35a2Smrg prog) 6261f05b35a2Smrg if test "$pass" = conv; then 6262f05b35a2Smrg deplibs="$deplib $deplibs" 6263f05b35a2Smrg continue 6264f05b35a2Smrg fi 6265f05b35a2Smrg if test "$pass" = scan; then 6266f05b35a2Smrg deplibs="$deplib $deplibs" 6267f05b35a2Smrg else 6268f05b35a2Smrg compile_deplibs="$deplib $compile_deplibs" 6269f05b35a2Smrg finalize_deplibs="$deplib $finalize_deplibs" 6270f05b35a2Smrg fi 6271f05b35a2Smrg func_stripname '-L' '' "$deplib" 627267ab2ff2Smrg func_resolve_sysroot "$func_stripname_result" 627367ab2ff2Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 6274f05b35a2Smrg ;; 6275f05b35a2Smrg *) 6276f05b35a2Smrg func_warning "\`-L' is ignored for archives/objects" 6277f05b35a2Smrg ;; 6278f05b35a2Smrg esac # linkmode 6279f05b35a2Smrg continue 6280f05b35a2Smrg ;; # -L 6281f05b35a2Smrg -R*) 6282f05b35a2Smrg if test "$pass" = link; then 6283f05b35a2Smrg func_stripname '-R' '' "$deplib" 628467ab2ff2Smrg func_resolve_sysroot "$func_stripname_result" 628567ab2ff2Smrg dir=$func_resolve_sysroot_result 6286f05b35a2Smrg # Make sure the xrpath contains only unique directories. 6287f05b35a2Smrg case "$xrpath " in 6288f05b35a2Smrg *" $dir "*) ;; 628967ab2ff2Smrg *) func_append xrpath " $dir" ;; 6290f05b35a2Smrg esac 6291f05b35a2Smrg fi 6292f05b35a2Smrg deplibs="$deplib $deplibs" 6293f05b35a2Smrg continue 6294f05b35a2Smrg ;; 629567ab2ff2Smrg *.la) 629667ab2ff2Smrg func_resolve_sysroot "$deplib" 629767ab2ff2Smrg lib=$func_resolve_sysroot_result 629867ab2ff2Smrg ;; 6299f05b35a2Smrg *.$libext) 6300f05b35a2Smrg if test "$pass" = conv; then 6301f05b35a2Smrg deplibs="$deplib $deplibs" 6302f05b35a2Smrg continue 6303f05b35a2Smrg fi 6304f05b35a2Smrg case $linkmode in 6305f05b35a2Smrg lib) 6306f05b35a2Smrg # Linking convenience modules into shared libraries is allowed, 6307f05b35a2Smrg # but linking other static libraries is non-portable. 6308f05b35a2Smrg case " $dlpreconveniencelibs " in 6309f05b35a2Smrg *" $deplib "*) ;; 6310f05b35a2Smrg *) 6311f05b35a2Smrg valid_a_lib=no 6312f05b35a2Smrg case $deplibs_check_method in 6313f05b35a2Smrg match_pattern*) 6314f05b35a2Smrg set dummy $deplibs_check_method; shift 6315f05b35a2Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 631649e108a1Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 6317f05b35a2Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 6318f05b35a2Smrg valid_a_lib=yes 6319f05b35a2Smrg fi 6320f05b35a2Smrg ;; 6321f05b35a2Smrg pass_all) 6322f05b35a2Smrg valid_a_lib=yes 6323f05b35a2Smrg ;; 6324f05b35a2Smrg esac 6325f05b35a2Smrg if test "$valid_a_lib" != yes; then 632649e108a1Smrg echo 6327f05b35a2Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 632849e108a1Smrg echo "*** I have the capability to make that library automatically link in when" 632949e108a1Smrg echo "*** you link to this library. But I can only do this if you have a" 633049e108a1Smrg echo "*** shared version of the library, which you do not appear to have" 633149e108a1Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 633249e108a1Smrg echo "*** that it is just a static archive that I should not use here." 6333f05b35a2Smrg else 633449e108a1Smrg echo 6335f05b35a2Smrg $ECHO "*** Warning: Linking the shared library $output against the" 6336f05b35a2Smrg $ECHO "*** static library $deplib is not portable!" 6337f05b35a2Smrg deplibs="$deplib $deplibs" 6338f05b35a2Smrg fi 6339f05b35a2Smrg ;; 6340f05b35a2Smrg esac 6341f05b35a2Smrg continue 6342f05b35a2Smrg ;; 6343f05b35a2Smrg prog) 6344f05b35a2Smrg if test "$pass" != link; then 6345f05b35a2Smrg deplibs="$deplib $deplibs" 6346f05b35a2Smrg else 6347f05b35a2Smrg compile_deplibs="$deplib $compile_deplibs" 6348f05b35a2Smrg finalize_deplibs="$deplib $finalize_deplibs" 6349f05b35a2Smrg fi 6350f05b35a2Smrg continue 6351f05b35a2Smrg ;; 6352f05b35a2Smrg esac # linkmode 6353f05b35a2Smrg ;; # *.$libext 6354f05b35a2Smrg *.lo | *.$objext) 6355f05b35a2Smrg if test "$pass" = conv; then 6356f05b35a2Smrg deplibs="$deplib $deplibs" 6357f05b35a2Smrg elif test "$linkmode" = prog; then 6358f05b35a2Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 6359f05b35a2Smrg # If there is no dlopen support or we're linking statically, 6360f05b35a2Smrg # we need to preload. 636167ab2ff2Smrg func_append newdlprefiles " $deplib" 6362f05b35a2Smrg compile_deplibs="$deplib $compile_deplibs" 6363f05b35a2Smrg finalize_deplibs="$deplib $finalize_deplibs" 6364f05b35a2Smrg else 636567ab2ff2Smrg func_append newdlfiles " $deplib" 6366f05b35a2Smrg fi 6367f05b35a2Smrg fi 6368f05b35a2Smrg continue 6369f05b35a2Smrg ;; 6370f05b35a2Smrg %DEPLIBS%) 6371f05b35a2Smrg alldeplibs=yes 6372f05b35a2Smrg continue 6373f05b35a2Smrg ;; 6374f05b35a2Smrg esac # case $deplib 6375f05b35a2Smrg 6376f05b35a2Smrg if test "$found" = yes || test -f "$lib"; then : 6377f05b35a2Smrg else 6378f05b35a2Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 6379f05b35a2Smrg fi 6380f05b35a2Smrg 6381f05b35a2Smrg # Check to see that this really is a libtool archive. 6382f05b35a2Smrg func_lalib_unsafe_p "$lib" \ 6383f05b35a2Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 6384f05b35a2Smrg 6385f05b35a2Smrg func_dirname "$lib" "" "." 6386f05b35a2Smrg ladir="$func_dirname_result" 6387f05b35a2Smrg 6388f05b35a2Smrg dlname= 6389f05b35a2Smrg dlopen= 6390f05b35a2Smrg dlpreopen= 6391f05b35a2Smrg libdir= 6392f05b35a2Smrg library_names= 6393f05b35a2Smrg old_library= 6394f05b35a2Smrg inherited_linker_flags= 6395f05b35a2Smrg # If the library was installed with an old release of libtool, 6396f05b35a2Smrg # it will not redefine variables installed, or shouldnotlink 6397f05b35a2Smrg installed=yes 6398f05b35a2Smrg shouldnotlink=no 6399f05b35a2Smrg avoidtemprpath= 6400f05b35a2Smrg 6401f05b35a2Smrg 6402f05b35a2Smrg # Read the .la file 6403f05b35a2Smrg func_source "$lib" 6404f05b35a2Smrg 6405f05b35a2Smrg # Convert "-framework foo" to "foo.ltframework" 6406f05b35a2Smrg if test -n "$inherited_linker_flags"; then 640749e108a1Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 6408f05b35a2Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 6409f05b35a2Smrg case " $new_inherited_linker_flags " in 6410f05b35a2Smrg *" $tmp_inherited_linker_flag "*) ;; 641167ab2ff2Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 6412f05b35a2Smrg esac 6413f05b35a2Smrg done 6414f05b35a2Smrg fi 641549e108a1Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 6416f05b35a2Smrg if test "$linkmode,$pass" = "lib,link" || 6417f05b35a2Smrg test "$linkmode,$pass" = "prog,scan" || 6418f05b35a2Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 641967ab2ff2Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 642067ab2ff2Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 6421f05b35a2Smrg fi 6422f05b35a2Smrg 6423f05b35a2Smrg if test "$pass" = conv; then 6424f05b35a2Smrg # Only check for convenience libraries 6425f05b35a2Smrg deplibs="$lib $deplibs" 6426f05b35a2Smrg if test -z "$libdir"; then 6427f05b35a2Smrg if test -z "$old_library"; then 6428f05b35a2Smrg func_fatal_error "cannot find name of link library for \`$lib'" 6429f05b35a2Smrg fi 6430f05b35a2Smrg # It is a libtool convenience library, so add in its objects. 643167ab2ff2Smrg func_append convenience " $ladir/$objdir/$old_library" 643267ab2ff2Smrg func_append old_convenience " $ladir/$objdir/$old_library" 6433f05b35a2Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 6434f05b35a2Smrg func_fatal_error "\`$lib' is not a convenience library" 6435f05b35a2Smrg fi 6436f05b35a2Smrg tmp_libs= 6437f05b35a2Smrg for deplib in $dependency_libs; do 6438f05b35a2Smrg deplibs="$deplib $deplibs" 643967ab2ff2Smrg if $opt_preserve_dup_deps ; then 6440f05b35a2Smrg case "$tmp_libs " in 644167ab2ff2Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6442f05b35a2Smrg esac 6443f05b35a2Smrg fi 644467ab2ff2Smrg func_append tmp_libs " $deplib" 6445f05b35a2Smrg done 6446f05b35a2Smrg continue 6447f05b35a2Smrg fi # $pass = conv 6448f05b35a2Smrg 6449f05b35a2Smrg 6450f05b35a2Smrg # Get the name of the library we link against. 6451f05b35a2Smrg linklib= 645267ab2ff2Smrg if test -n "$old_library" && 645367ab2ff2Smrg { test "$prefer_static_libs" = yes || 645467ab2ff2Smrg test "$prefer_static_libs,$installed" = "built,no"; }; then 645567ab2ff2Smrg linklib=$old_library 645667ab2ff2Smrg else 645767ab2ff2Smrg for l in $old_library $library_names; do 645867ab2ff2Smrg linklib="$l" 645967ab2ff2Smrg done 646067ab2ff2Smrg fi 6461f05b35a2Smrg if test -z "$linklib"; then 6462f05b35a2Smrg func_fatal_error "cannot find name of link library for \`$lib'" 6463f05b35a2Smrg fi 6464f05b35a2Smrg 6465f05b35a2Smrg # This library was specified with -dlopen. 6466f05b35a2Smrg if test "$pass" = dlopen; then 6467f05b35a2Smrg if test -z "$libdir"; then 6468f05b35a2Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 6469f05b35a2Smrg fi 6470f05b35a2Smrg if test -z "$dlname" || 6471f05b35a2Smrg test "$dlopen_support" != yes || 6472f05b35a2Smrg test "$build_libtool_libs" = no; then 6473f05b35a2Smrg # If there is no dlname, no dlopen support or we're linking 6474f05b35a2Smrg # statically, we need to preload. We also need to preload any 6475f05b35a2Smrg # dependent libraries so libltdl's deplib preloader doesn't 6476f05b35a2Smrg # bomb out in the load deplibs phase. 647767ab2ff2Smrg func_append dlprefiles " $lib $dependency_libs" 6478f05b35a2Smrg else 647967ab2ff2Smrg func_append newdlfiles " $lib" 6480f05b35a2Smrg fi 6481f05b35a2Smrg continue 6482f05b35a2Smrg fi # $pass = dlopen 6483f05b35a2Smrg 6484f05b35a2Smrg # We need an absolute path. 6485f05b35a2Smrg case $ladir in 6486f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 6487f05b35a2Smrg *) 6488f05b35a2Smrg abs_ladir=`cd "$ladir" && pwd` 6489f05b35a2Smrg if test -z "$abs_ladir"; then 6490f05b35a2Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 6491f05b35a2Smrg func_warning "passing it literally to the linker, although it might fail" 6492f05b35a2Smrg abs_ladir="$ladir" 6493f05b35a2Smrg fi 6494f05b35a2Smrg ;; 6495f05b35a2Smrg esac 6496f05b35a2Smrg func_basename "$lib" 6497f05b35a2Smrg laname="$func_basename_result" 6498f05b35a2Smrg 6499f05b35a2Smrg # Find the relevant object directory and library name. 6500f05b35a2Smrg if test "X$installed" = Xyes; then 650167ab2ff2Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6502f05b35a2Smrg func_warning "library \`$lib' was moved." 6503f05b35a2Smrg dir="$ladir" 6504f05b35a2Smrg absdir="$abs_ladir" 6505f05b35a2Smrg libdir="$abs_ladir" 6506f05b35a2Smrg else 650767ab2ff2Smrg dir="$lt_sysroot$libdir" 650867ab2ff2Smrg absdir="$lt_sysroot$libdir" 6509f05b35a2Smrg fi 6510f05b35a2Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 6511f05b35a2Smrg else 6512f05b35a2Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6513f05b35a2Smrg dir="$ladir" 6514f05b35a2Smrg absdir="$abs_ladir" 6515f05b35a2Smrg # Remove this search path later 651667ab2ff2Smrg func_append notinst_path " $abs_ladir" 6517f05b35a2Smrg else 6518f05b35a2Smrg dir="$ladir/$objdir" 6519f05b35a2Smrg absdir="$abs_ladir/$objdir" 6520f05b35a2Smrg # Remove this search path later 652167ab2ff2Smrg func_append notinst_path " $abs_ladir" 6522f05b35a2Smrg fi 6523f05b35a2Smrg fi # $installed = yes 6524f05b35a2Smrg func_stripname 'lib' '.la' "$laname" 6525f05b35a2Smrg name=$func_stripname_result 6526f05b35a2Smrg 6527f05b35a2Smrg # This library was specified with -dlpreopen. 6528f05b35a2Smrg if test "$pass" = dlpreopen; then 6529f05b35a2Smrg if test -z "$libdir" && test "$linkmode" = prog; then 6530f05b35a2Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 6531f05b35a2Smrg fi 653267ab2ff2Smrg case "$host" in 653367ab2ff2Smrg # special handling for platforms with PE-DLLs. 653467ab2ff2Smrg *cygwin* | *mingw* | *cegcc* ) 653567ab2ff2Smrg # Linker will automatically link against shared library if both 653667ab2ff2Smrg # static and shared are present. Therefore, ensure we extract 653767ab2ff2Smrg # symbols from the import library if a shared library is present 653867ab2ff2Smrg # (otherwise, the dlopen module name will be incorrect). We do 653967ab2ff2Smrg # this by putting the import library name into $newdlprefiles. 654067ab2ff2Smrg # We recover the dlopen module name by 'saving' the la file 654167ab2ff2Smrg # name in a special purpose variable, and (later) extracting the 654267ab2ff2Smrg # dlname from the la file. 654367ab2ff2Smrg if test -n "$dlname"; then 654467ab2ff2Smrg func_tr_sh "$dir/$linklib" 654567ab2ff2Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 654667ab2ff2Smrg func_append newdlprefiles " $dir/$linklib" 654767ab2ff2Smrg else 654867ab2ff2Smrg func_append newdlprefiles " $dir/$old_library" 654967ab2ff2Smrg # Keep a list of preopened convenience libraries to check 655067ab2ff2Smrg # that they are being used correctly in the link pass. 655167ab2ff2Smrg test -z "$libdir" && \ 655267ab2ff2Smrg func_append dlpreconveniencelibs " $dir/$old_library" 655367ab2ff2Smrg fi 655467ab2ff2Smrg ;; 655567ab2ff2Smrg * ) 655667ab2ff2Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 655767ab2ff2Smrg # are required to link). 655867ab2ff2Smrg if test -n "$old_library"; then 655967ab2ff2Smrg func_append newdlprefiles " $dir/$old_library" 656067ab2ff2Smrg # Keep a list of preopened convenience libraries to check 656167ab2ff2Smrg # that they are being used correctly in the link pass. 656267ab2ff2Smrg test -z "$libdir" && \ 656367ab2ff2Smrg func_append dlpreconveniencelibs " $dir/$old_library" 656467ab2ff2Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 656567ab2ff2Smrg elif test -n "$dlname"; then 656667ab2ff2Smrg func_append newdlprefiles " $dir/$dlname" 656767ab2ff2Smrg else 656867ab2ff2Smrg func_append newdlprefiles " $dir/$linklib" 656967ab2ff2Smrg fi 657067ab2ff2Smrg ;; 657167ab2ff2Smrg esac 6572f05b35a2Smrg fi # $pass = dlpreopen 6573f05b35a2Smrg 6574f05b35a2Smrg if test -z "$libdir"; then 6575f05b35a2Smrg # Link the convenience library 6576f05b35a2Smrg if test "$linkmode" = lib; then 6577f05b35a2Smrg deplibs="$dir/$old_library $deplibs" 6578f05b35a2Smrg elif test "$linkmode,$pass" = "prog,link"; then 6579f05b35a2Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 6580f05b35a2Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 6581f05b35a2Smrg else 6582f05b35a2Smrg deplibs="$lib $deplibs" # used for prog,scan pass 6583f05b35a2Smrg fi 6584f05b35a2Smrg continue 6585f05b35a2Smrg fi 6586f05b35a2Smrg 6587f05b35a2Smrg 6588f05b35a2Smrg if test "$linkmode" = prog && test "$pass" != link; then 658967ab2ff2Smrg func_append newlib_search_path " $ladir" 6590f05b35a2Smrg deplibs="$lib $deplibs" 6591f05b35a2Smrg 6592f05b35a2Smrg linkalldeplibs=no 6593f05b35a2Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 6594f05b35a2Smrg test "$build_libtool_libs" = no; then 6595f05b35a2Smrg linkalldeplibs=yes 6596f05b35a2Smrg fi 6597f05b35a2Smrg 6598f05b35a2Smrg tmp_libs= 6599f05b35a2Smrg for deplib in $dependency_libs; do 6600f05b35a2Smrg case $deplib in 6601f05b35a2Smrg -L*) func_stripname '-L' '' "$deplib" 660267ab2ff2Smrg func_resolve_sysroot "$func_stripname_result" 660367ab2ff2Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 6604f05b35a2Smrg ;; 6605f05b35a2Smrg esac 6606f05b35a2Smrg # Need to link against all dependency_libs? 6607f05b35a2Smrg if test "$linkalldeplibs" = yes; then 6608f05b35a2Smrg deplibs="$deplib $deplibs" 6609f05b35a2Smrg else 6610f05b35a2Smrg # Need to hardcode shared library paths 6611f05b35a2Smrg # or/and link against static libraries 6612f05b35a2Smrg newdependency_libs="$deplib $newdependency_libs" 6613f05b35a2Smrg fi 661467ab2ff2Smrg if $opt_preserve_dup_deps ; then 6615f05b35a2Smrg case "$tmp_libs " in 661667ab2ff2Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6617f05b35a2Smrg esac 6618f05b35a2Smrg fi 661967ab2ff2Smrg func_append tmp_libs " $deplib" 6620f05b35a2Smrg done # for deplib 6621f05b35a2Smrg continue 6622f05b35a2Smrg fi # $linkmode = prog... 6623f05b35a2Smrg 6624f05b35a2Smrg if test "$linkmode,$pass" = "prog,link"; then 6625f05b35a2Smrg if test -n "$library_names" && 6626f05b35a2Smrg { { test "$prefer_static_libs" = no || 6627f05b35a2Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 6628f05b35a2Smrg test -z "$old_library"; }; then 6629f05b35a2Smrg # We need to hardcode the library path 6630f05b35a2Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 6631f05b35a2Smrg # Make sure the rpath contains only unique directories. 6632f05b35a2Smrg case "$temp_rpath:" in 6633f05b35a2Smrg *"$absdir:"*) ;; 663467ab2ff2Smrg *) func_append temp_rpath "$absdir:" ;; 6635f05b35a2Smrg esac 6636f05b35a2Smrg fi 6637f05b35a2Smrg 6638f05b35a2Smrg # Hardcode the library path. 6639f05b35a2Smrg # Skip directories that are in the system default run-time 6640f05b35a2Smrg # search path. 6641f05b35a2Smrg case " $sys_lib_dlsearch_path " in 6642f05b35a2Smrg *" $absdir "*) ;; 6643f05b35a2Smrg *) 6644f05b35a2Smrg case "$compile_rpath " in 6645f05b35a2Smrg *" $absdir "*) ;; 664667ab2ff2Smrg *) func_append compile_rpath " $absdir" ;; 6647f05b35a2Smrg esac 6648f05b35a2Smrg ;; 6649f05b35a2Smrg esac 6650f05b35a2Smrg case " $sys_lib_dlsearch_path " in 6651f05b35a2Smrg *" $libdir "*) ;; 6652f05b35a2Smrg *) 6653f05b35a2Smrg case "$finalize_rpath " in 6654f05b35a2Smrg *" $libdir "*) ;; 665567ab2ff2Smrg *) func_append finalize_rpath " $libdir" ;; 6656f05b35a2Smrg esac 6657f05b35a2Smrg ;; 6658f05b35a2Smrg esac 6659f05b35a2Smrg fi # $linkmode,$pass = prog,link... 6660f05b35a2Smrg 6661f05b35a2Smrg if test "$alldeplibs" = yes && 6662f05b35a2Smrg { test "$deplibs_check_method" = pass_all || 6663f05b35a2Smrg { test "$build_libtool_libs" = yes && 6664f05b35a2Smrg test -n "$library_names"; }; }; then 6665f05b35a2Smrg # We only need to search for static libraries 6666f05b35a2Smrg continue 6667f05b35a2Smrg fi 6668f05b35a2Smrg fi 6669f05b35a2Smrg 6670f05b35a2Smrg link_static=no # Whether the deplib will be linked statically 6671f05b35a2Smrg use_static_libs=$prefer_static_libs 6672f05b35a2Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 6673f05b35a2Smrg use_static_libs=no 6674f05b35a2Smrg fi 6675f05b35a2Smrg if test -n "$library_names" && 6676f05b35a2Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 6677f05b35a2Smrg case $host in 6678f05b35a2Smrg *cygwin* | *mingw* | *cegcc*) 6679f05b35a2Smrg # No point in relinking DLLs because paths are not encoded 668067ab2ff2Smrg func_append notinst_deplibs " $lib" 6681f05b35a2Smrg need_relink=no 6682f05b35a2Smrg ;; 6683f05b35a2Smrg *) 6684f05b35a2Smrg if test "$installed" = no; then 668567ab2ff2Smrg func_append notinst_deplibs " $lib" 6686f05b35a2Smrg need_relink=yes 6687f05b35a2Smrg fi 6688f05b35a2Smrg ;; 6689f05b35a2Smrg esac 6690f05b35a2Smrg # This is a shared library 6691f05b35a2Smrg 6692f05b35a2Smrg # Warn about portability, can't link against -module's on some 6693f05b35a2Smrg # systems (darwin). Don't bleat about dlopened modules though! 6694f05b35a2Smrg dlopenmodule="" 6695f05b35a2Smrg for dlpremoduletest in $dlprefiles; do 6696f05b35a2Smrg if test "X$dlpremoduletest" = "X$lib"; then 6697f05b35a2Smrg dlopenmodule="$dlpremoduletest" 6698f05b35a2Smrg break 6699f05b35a2Smrg fi 6700f05b35a2Smrg done 6701f05b35a2Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 670249e108a1Smrg echo 6703f05b35a2Smrg if test "$linkmode" = prog; then 6704f05b35a2Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 6705f05b35a2Smrg else 6706f05b35a2Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 6707f05b35a2Smrg fi 6708f05b35a2Smrg $ECHO "*** $linklib is not portable!" 6709f05b35a2Smrg fi 6710f05b35a2Smrg if test "$linkmode" = lib && 6711f05b35a2Smrg test "$hardcode_into_libs" = yes; then 6712f05b35a2Smrg # Hardcode the library path. 6713f05b35a2Smrg # Skip directories that are in the system default run-time 6714f05b35a2Smrg # search path. 6715f05b35a2Smrg case " $sys_lib_dlsearch_path " in 6716f05b35a2Smrg *" $absdir "*) ;; 6717f05b35a2Smrg *) 6718f05b35a2Smrg case "$compile_rpath " in 6719f05b35a2Smrg *" $absdir "*) ;; 672067ab2ff2Smrg *) func_append compile_rpath " $absdir" ;; 6721f05b35a2Smrg esac 6722f05b35a2Smrg ;; 6723f05b35a2Smrg esac 6724f05b35a2Smrg case " $sys_lib_dlsearch_path " in 6725f05b35a2Smrg *" $libdir "*) ;; 6726f05b35a2Smrg *) 6727f05b35a2Smrg case "$finalize_rpath " in 6728f05b35a2Smrg *" $libdir "*) ;; 672967ab2ff2Smrg *) func_append finalize_rpath " $libdir" ;; 6730f05b35a2Smrg esac 6731f05b35a2Smrg ;; 6732f05b35a2Smrg esac 6733f05b35a2Smrg fi 6734f05b35a2Smrg 6735f05b35a2Smrg if test -n "$old_archive_from_expsyms_cmds"; then 6736f05b35a2Smrg # figure out the soname 6737f05b35a2Smrg set dummy $library_names 6738f05b35a2Smrg shift 6739f05b35a2Smrg realname="$1" 6740f05b35a2Smrg shift 6741f05b35a2Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 6742f05b35a2Smrg # use dlname if we got it. it's perfectly good, no? 6743f05b35a2Smrg if test -n "$dlname"; then 6744f05b35a2Smrg soname="$dlname" 6745f05b35a2Smrg elif test -n "$soname_spec"; then 6746f05b35a2Smrg # bleh windows 6747f05b35a2Smrg case $host in 6748f05b35a2Smrg *cygwin* | mingw* | *cegcc*) 6749f05b35a2Smrg func_arith $current - $age 6750f05b35a2Smrg major=$func_arith_result 6751f05b35a2Smrg versuffix="-$major" 6752f05b35a2Smrg ;; 6753f05b35a2Smrg esac 6754f05b35a2Smrg eval soname=\"$soname_spec\" 6755f05b35a2Smrg else 6756f05b35a2Smrg soname="$realname" 6757f05b35a2Smrg fi 6758f05b35a2Smrg 6759f05b35a2Smrg # Make a new name for the extract_expsyms_cmds to use 6760f05b35a2Smrg soroot="$soname" 6761f05b35a2Smrg func_basename "$soroot" 6762f05b35a2Smrg soname="$func_basename_result" 6763f05b35a2Smrg func_stripname 'lib' '.dll' "$soname" 6764f05b35a2Smrg newlib=libimp-$func_stripname_result.a 6765f05b35a2Smrg 6766f05b35a2Smrg # If the library has no export list, then create one now 6767f05b35a2Smrg if test -f "$output_objdir/$soname-def"; then : 6768f05b35a2Smrg else 6769f05b35a2Smrg func_verbose "extracting exported symbol list from \`$soname'" 6770f05b35a2Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 6771f05b35a2Smrg fi 6772f05b35a2Smrg 6773f05b35a2Smrg # Create $newlib 6774f05b35a2Smrg if test -f "$output_objdir/$newlib"; then :; else 6775f05b35a2Smrg func_verbose "generating import library for \`$soname'" 6776f05b35a2Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 6777f05b35a2Smrg fi 6778f05b35a2Smrg # make sure the library variables are pointing to the new library 6779f05b35a2Smrg dir=$output_objdir 6780f05b35a2Smrg linklib=$newlib 6781f05b35a2Smrg fi # test -n "$old_archive_from_expsyms_cmds" 6782f05b35a2Smrg 678367ab2ff2Smrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 6784f05b35a2Smrg add_shlibpath= 6785f05b35a2Smrg add_dir= 6786f05b35a2Smrg add= 6787f05b35a2Smrg lib_linked=yes 6788f05b35a2Smrg case $hardcode_action in 6789f05b35a2Smrg immediate | unsupported) 6790f05b35a2Smrg if test "$hardcode_direct" = no; then 6791f05b35a2Smrg add="$dir/$linklib" 6792f05b35a2Smrg case $host in 6793f05b35a2Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 6794f05b35a2Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 6795f05b35a2Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 6796f05b35a2Smrg *-*-unixware7*) add_dir="-L$dir" ;; 6797f05b35a2Smrg *-*-darwin* ) 6798f05b35a2Smrg # if the lib is a (non-dlopened) module then we can not 6799f05b35a2Smrg # link against it, someone is ignoring the earlier warnings 6800f05b35a2Smrg if /usr/bin/file -L $add 2> /dev/null | 6801f05b35a2Smrg $GREP ": [^:]* bundle" >/dev/null ; then 6802f05b35a2Smrg if test "X$dlopenmodule" != "X$lib"; then 6803f05b35a2Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 6804f05b35a2Smrg if test -z "$old_library" ; then 680549e108a1Smrg echo 680649e108a1Smrg echo "*** And there doesn't seem to be a static archive available" 680749e108a1Smrg echo "*** The link will probably fail, sorry" 6808f05b35a2Smrg else 6809f05b35a2Smrg add="$dir/$old_library" 6810f05b35a2Smrg fi 6811f05b35a2Smrg elif test -n "$old_library"; then 6812f05b35a2Smrg add="$dir/$old_library" 6813f05b35a2Smrg fi 6814f05b35a2Smrg fi 6815f05b35a2Smrg esac 6816f05b35a2Smrg elif test "$hardcode_minus_L" = no; then 6817f05b35a2Smrg case $host in 6818f05b35a2Smrg *-*-sunos*) add_shlibpath="$dir" ;; 6819f05b35a2Smrg esac 6820f05b35a2Smrg add_dir="-L$dir" 6821f05b35a2Smrg add="-l$name" 6822f05b35a2Smrg elif test "$hardcode_shlibpath_var" = no; then 6823f05b35a2Smrg add_shlibpath="$dir" 6824f05b35a2Smrg add="-l$name" 6825f05b35a2Smrg else 6826f05b35a2Smrg lib_linked=no 6827f05b35a2Smrg fi 6828f05b35a2Smrg ;; 6829f05b35a2Smrg relink) 6830f05b35a2Smrg if test "$hardcode_direct" = yes && 6831f05b35a2Smrg test "$hardcode_direct_absolute" = no; then 6832f05b35a2Smrg add="$dir/$linklib" 6833f05b35a2Smrg elif test "$hardcode_minus_L" = yes; then 6834f05b35a2Smrg add_dir="-L$dir" 6835f05b35a2Smrg # Try looking first in the location we're being installed to. 6836f05b35a2Smrg if test -n "$inst_prefix_dir"; then 6837f05b35a2Smrg case $libdir in 6838f05b35a2Smrg [\\/]*) 683967ab2ff2Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 6840f05b35a2Smrg ;; 6841f05b35a2Smrg esac 6842f05b35a2Smrg fi 6843f05b35a2Smrg add="-l$name" 6844f05b35a2Smrg elif test "$hardcode_shlibpath_var" = yes; then 6845f05b35a2Smrg add_shlibpath="$dir" 6846f05b35a2Smrg add="-l$name" 6847f05b35a2Smrg else 6848f05b35a2Smrg lib_linked=no 6849f05b35a2Smrg fi 6850f05b35a2Smrg ;; 6851f05b35a2Smrg *) lib_linked=no ;; 6852f05b35a2Smrg esac 6853f05b35a2Smrg 6854f05b35a2Smrg if test "$lib_linked" != yes; then 6855f05b35a2Smrg func_fatal_configuration "unsupported hardcode properties" 6856f05b35a2Smrg fi 6857f05b35a2Smrg 6858f05b35a2Smrg if test -n "$add_shlibpath"; then 6859f05b35a2Smrg case :$compile_shlibpath: in 6860f05b35a2Smrg *":$add_shlibpath:"*) ;; 686167ab2ff2Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 6862f05b35a2Smrg esac 6863f05b35a2Smrg fi 6864f05b35a2Smrg if test "$linkmode" = prog; then 6865f05b35a2Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 6866f05b35a2Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 6867f05b35a2Smrg else 6868f05b35a2Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 6869f05b35a2Smrg test -n "$add" && deplibs="$add $deplibs" 6870f05b35a2Smrg if test "$hardcode_direct" != yes && 6871f05b35a2Smrg test "$hardcode_minus_L" != yes && 6872f05b35a2Smrg test "$hardcode_shlibpath_var" = yes; then 6873f05b35a2Smrg case :$finalize_shlibpath: in 6874f05b35a2Smrg *":$libdir:"*) ;; 687567ab2ff2Smrg *) func_append finalize_shlibpath "$libdir:" ;; 6876f05b35a2Smrg esac 6877f05b35a2Smrg fi 6878f05b35a2Smrg fi 6879f05b35a2Smrg fi 6880f05b35a2Smrg 688167ab2ff2Smrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 6882f05b35a2Smrg add_shlibpath= 6883f05b35a2Smrg add_dir= 6884f05b35a2Smrg add= 6885f05b35a2Smrg # Finalize command for both is simple: just hardcode it. 6886f05b35a2Smrg if test "$hardcode_direct" = yes && 6887f05b35a2Smrg test "$hardcode_direct_absolute" = no; then 6888f05b35a2Smrg add="$libdir/$linklib" 6889f05b35a2Smrg elif test "$hardcode_minus_L" = yes; then 6890f05b35a2Smrg add_dir="-L$libdir" 6891f05b35a2Smrg add="-l$name" 6892f05b35a2Smrg elif test "$hardcode_shlibpath_var" = yes; then 6893f05b35a2Smrg case :$finalize_shlibpath: in 6894f05b35a2Smrg *":$libdir:"*) ;; 689567ab2ff2Smrg *) func_append finalize_shlibpath "$libdir:" ;; 6896f05b35a2Smrg esac 6897f05b35a2Smrg add="-l$name" 6898f05b35a2Smrg elif test "$hardcode_automatic" = yes; then 6899f05b35a2Smrg if test -n "$inst_prefix_dir" && 6900f05b35a2Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 6901f05b35a2Smrg add="$inst_prefix_dir$libdir/$linklib" 6902f05b35a2Smrg else 6903f05b35a2Smrg add="$libdir/$linklib" 6904f05b35a2Smrg fi 6905f05b35a2Smrg else 6906f05b35a2Smrg # We cannot seem to hardcode it, guess we'll fake it. 6907f05b35a2Smrg add_dir="-L$libdir" 6908f05b35a2Smrg # Try looking first in the location we're being installed to. 6909f05b35a2Smrg if test -n "$inst_prefix_dir"; then 6910f05b35a2Smrg case $libdir in 6911f05b35a2Smrg [\\/]*) 691267ab2ff2Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 6913f05b35a2Smrg ;; 6914f05b35a2Smrg esac 6915f05b35a2Smrg fi 6916f05b35a2Smrg add="-l$name" 6917f05b35a2Smrg fi 6918f05b35a2Smrg 6919f05b35a2Smrg if test "$linkmode" = prog; then 6920f05b35a2Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 6921f05b35a2Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 6922f05b35a2Smrg else 6923f05b35a2Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 6924f05b35a2Smrg test -n "$add" && deplibs="$add $deplibs" 6925f05b35a2Smrg fi 6926f05b35a2Smrg fi 6927f05b35a2Smrg elif test "$linkmode" = prog; then 6928f05b35a2Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 6929f05b35a2Smrg # is not unsupported. This is valid on all known static and 6930f05b35a2Smrg # shared platforms. 6931f05b35a2Smrg if test "$hardcode_direct" != unsupported; then 6932f05b35a2Smrg test -n "$old_library" && linklib="$old_library" 6933f05b35a2Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 6934f05b35a2Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 6935f05b35a2Smrg else 6936f05b35a2Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 6937f05b35a2Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 6938f05b35a2Smrg fi 6939f05b35a2Smrg elif test "$build_libtool_libs" = yes; then 6940f05b35a2Smrg # Not a shared library 6941f05b35a2Smrg if test "$deplibs_check_method" != pass_all; then 6942f05b35a2Smrg # We're trying link a shared library against a static one 6943f05b35a2Smrg # but the system doesn't support it. 6944f05b35a2Smrg 6945f05b35a2Smrg # Just print a warning and add the library to dependency_libs so 6946f05b35a2Smrg # that the program can be linked against the static library. 694749e108a1Smrg echo 6948f05b35a2Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 694949e108a1Smrg echo "*** I have the capability to make that library automatically link in when" 695049e108a1Smrg echo "*** you link to this library. But I can only do this if you have a" 695149e108a1Smrg echo "*** shared version of the library, which you do not appear to have." 6952f05b35a2Smrg if test "$module" = yes; then 695349e108a1Smrg echo "*** But as you try to build a module library, libtool will still create " 695449e108a1Smrg echo "*** a static module, that should work as long as the dlopening application" 695549e108a1Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 6956f05b35a2Smrg if test -z "$global_symbol_pipe"; then 695749e108a1Smrg echo 695849e108a1Smrg echo "*** However, this would only work if libtool was able to extract symbol" 695949e108a1Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 696049e108a1Smrg echo "*** not find such a program. So, this module is probably useless." 696149e108a1Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 6962f05b35a2Smrg fi 6963f05b35a2Smrg if test "$build_old_libs" = no; then 6964f05b35a2Smrg build_libtool_libs=module 6965f05b35a2Smrg build_old_libs=yes 6966f05b35a2Smrg else 6967f05b35a2Smrg build_libtool_libs=no 6968f05b35a2Smrg fi 6969f05b35a2Smrg fi 6970f05b35a2Smrg else 6971f05b35a2Smrg deplibs="$dir/$old_library $deplibs" 6972f05b35a2Smrg link_static=yes 6973f05b35a2Smrg fi 6974f05b35a2Smrg fi # link shared/static library? 6975f05b35a2Smrg 6976f05b35a2Smrg if test "$linkmode" = lib; then 6977f05b35a2Smrg if test -n "$dependency_libs" && 6978f05b35a2Smrg { test "$hardcode_into_libs" != yes || 6979f05b35a2Smrg test "$build_old_libs" = yes || 6980f05b35a2Smrg test "$link_static" = yes; }; then 6981f05b35a2Smrg # Extract -R from dependency_libs 6982f05b35a2Smrg temp_deplibs= 6983f05b35a2Smrg for libdir in $dependency_libs; do 6984f05b35a2Smrg case $libdir in 6985f05b35a2Smrg -R*) func_stripname '-R' '' "$libdir" 6986f05b35a2Smrg temp_xrpath=$func_stripname_result 6987f05b35a2Smrg case " $xrpath " in 6988f05b35a2Smrg *" $temp_xrpath "*) ;; 698967ab2ff2Smrg *) func_append xrpath " $temp_xrpath";; 6990f05b35a2Smrg esac;; 699167ab2ff2Smrg *) func_append temp_deplibs " $libdir";; 6992f05b35a2Smrg esac 6993f05b35a2Smrg done 6994f05b35a2Smrg dependency_libs="$temp_deplibs" 6995f05b35a2Smrg fi 6996f05b35a2Smrg 699767ab2ff2Smrg func_append newlib_search_path " $absdir" 6998f05b35a2Smrg # Link against this library 6999f05b35a2Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 7000f05b35a2Smrg # ... and its dependency_libs 7001f05b35a2Smrg tmp_libs= 7002f05b35a2Smrg for deplib in $dependency_libs; do 7003f05b35a2Smrg newdependency_libs="$deplib $newdependency_libs" 700467ab2ff2Smrg case $deplib in 700567ab2ff2Smrg -L*) func_stripname '-L' '' "$deplib" 700667ab2ff2Smrg func_resolve_sysroot "$func_stripname_result";; 700767ab2ff2Smrg *) func_resolve_sysroot "$deplib" ;; 700867ab2ff2Smrg esac 700967ab2ff2Smrg if $opt_preserve_dup_deps ; then 7010f05b35a2Smrg case "$tmp_libs " in 701167ab2ff2Smrg *" $func_resolve_sysroot_result "*) 701267ab2ff2Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 7013f05b35a2Smrg esac 7014f05b35a2Smrg fi 701567ab2ff2Smrg func_append tmp_libs " $func_resolve_sysroot_result" 7016f05b35a2Smrg done 7017f05b35a2Smrg 7018f05b35a2Smrg if test "$link_all_deplibs" != no; then 7019f05b35a2Smrg # Add the search paths of all dependency libraries 7020f05b35a2Smrg for deplib in $dependency_libs; do 702149e108a1Smrg path= 7022f05b35a2Smrg case $deplib in 7023f05b35a2Smrg -L*) path="$deplib" ;; 7024f05b35a2Smrg *.la) 702567ab2ff2Smrg func_resolve_sysroot "$deplib" 702667ab2ff2Smrg deplib=$func_resolve_sysroot_result 7027f05b35a2Smrg func_dirname "$deplib" "" "." 702867ab2ff2Smrg dir=$func_dirname_result 7029f05b35a2Smrg # We need an absolute path. 7030f05b35a2Smrg case $dir in 7031f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 7032f05b35a2Smrg *) 7033f05b35a2Smrg absdir=`cd "$dir" && pwd` 7034f05b35a2Smrg if test -z "$absdir"; then 7035f05b35a2Smrg func_warning "cannot determine absolute directory name of \`$dir'" 7036f05b35a2Smrg absdir="$dir" 7037f05b35a2Smrg fi 7038f05b35a2Smrg ;; 7039f05b35a2Smrg esac 7040f05b35a2Smrg if $GREP "^installed=no" $deplib > /dev/null; then 7041f05b35a2Smrg case $host in 7042f05b35a2Smrg *-*-darwin*) 7043f05b35a2Smrg depdepl= 7044f05b35a2Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 7045f05b35a2Smrg if test -n "$deplibrary_names" ; then 7046f05b35a2Smrg for tmp in $deplibrary_names ; do 7047f05b35a2Smrg depdepl=$tmp 7048f05b35a2Smrg done 7049f05b35a2Smrg if test -f "$absdir/$objdir/$depdepl" ; then 7050f05b35a2Smrg depdepl="$absdir/$objdir/$depdepl" 7051f05b35a2Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7052f05b35a2Smrg if test -z "$darwin_install_name"; then 7053f05b35a2Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7054f05b35a2Smrg fi 705567ab2ff2Smrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 705667ab2ff2Smrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 7057f05b35a2Smrg path= 7058f05b35a2Smrg fi 7059f05b35a2Smrg fi 7060f05b35a2Smrg ;; 7061f05b35a2Smrg *) 7062f05b35a2Smrg path="-L$absdir/$objdir" 7063f05b35a2Smrg ;; 7064f05b35a2Smrg esac 7065f05b35a2Smrg else 7066f05b35a2Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 7067f05b35a2Smrg test -z "$libdir" && \ 7068f05b35a2Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 7069f05b35a2Smrg test "$absdir" != "$libdir" && \ 7070f05b35a2Smrg func_warning "\`$deplib' seems to be moved" 7071f05b35a2Smrg 7072f05b35a2Smrg path="-L$absdir" 7073f05b35a2Smrg fi 7074f05b35a2Smrg ;; 7075f05b35a2Smrg esac 7076f05b35a2Smrg case " $deplibs " in 7077f05b35a2Smrg *" $path "*) ;; 7078f05b35a2Smrg *) deplibs="$path $deplibs" ;; 7079f05b35a2Smrg esac 7080f05b35a2Smrg done 7081f05b35a2Smrg fi # link_all_deplibs != no 7082f05b35a2Smrg fi # linkmode = lib 7083f05b35a2Smrg done # for deplib in $libs 7084f05b35a2Smrg if test "$pass" = link; then 7085f05b35a2Smrg if test "$linkmode" = "prog"; then 7086f05b35a2Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 7087f05b35a2Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 7088f05b35a2Smrg else 708949e108a1Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7090f05b35a2Smrg fi 7091f05b35a2Smrg fi 7092f05b35a2Smrg dependency_libs="$newdependency_libs" 7093f05b35a2Smrg if test "$pass" = dlpreopen; then 7094f05b35a2Smrg # Link the dlpreopened libraries before other libraries 7095f05b35a2Smrg for deplib in $save_deplibs; do 7096f05b35a2Smrg deplibs="$deplib $deplibs" 7097f05b35a2Smrg done 7098f05b35a2Smrg fi 7099f05b35a2Smrg if test "$pass" != dlopen; then 7100f05b35a2Smrg if test "$pass" != conv; then 7101f05b35a2Smrg # Make sure lib_search_path contains only unique directories. 7102f05b35a2Smrg lib_search_path= 7103f05b35a2Smrg for dir in $newlib_search_path; do 7104f05b35a2Smrg case "$lib_search_path " in 7105f05b35a2Smrg *" $dir "*) ;; 710667ab2ff2Smrg *) func_append lib_search_path " $dir" ;; 7107f05b35a2Smrg esac 7108f05b35a2Smrg done 7109f05b35a2Smrg newlib_search_path= 7110f05b35a2Smrg fi 7111f05b35a2Smrg 7112f05b35a2Smrg if test "$linkmode,$pass" != "prog,link"; then 7113f05b35a2Smrg vars="deplibs" 7114f05b35a2Smrg else 7115f05b35a2Smrg vars="compile_deplibs finalize_deplibs" 7116f05b35a2Smrg fi 7117f05b35a2Smrg for var in $vars dependency_libs; do 7118f05b35a2Smrg # Add libraries to $var in reverse order 7119f05b35a2Smrg eval tmp_libs=\"\$$var\" 7120f05b35a2Smrg new_libs= 7121f05b35a2Smrg for deplib in $tmp_libs; do 7122f05b35a2Smrg # FIXME: Pedantically, this is the right thing to do, so 7123f05b35a2Smrg # that some nasty dependency loop isn't accidentally 7124f05b35a2Smrg # broken: 7125f05b35a2Smrg #new_libs="$deplib $new_libs" 7126f05b35a2Smrg # Pragmatically, this seems to cause very few problems in 7127f05b35a2Smrg # practice: 7128f05b35a2Smrg case $deplib in 7129f05b35a2Smrg -L*) new_libs="$deplib $new_libs" ;; 7130f05b35a2Smrg -R*) ;; 7131f05b35a2Smrg *) 7132f05b35a2Smrg # And here is the reason: when a library appears more 7133f05b35a2Smrg # than once as an explicit dependence of a library, or 7134f05b35a2Smrg # is implicitly linked in more than once by the 7135f05b35a2Smrg # compiler, it is considered special, and multiple 7136f05b35a2Smrg # occurrences thereof are not removed. Compare this 7137f05b35a2Smrg # with having the same library being listed as a 7138f05b35a2Smrg # dependency of multiple other libraries: in this case, 7139f05b35a2Smrg # we know (pedantically, we assume) the library does not 7140f05b35a2Smrg # need to be listed more than once, so we keep only the 7141f05b35a2Smrg # last copy. This is not always right, but it is rare 7142f05b35a2Smrg # enough that we require users that really mean to play 7143f05b35a2Smrg # such unportable linking tricks to link the library 7144f05b35a2Smrg # using -Wl,-lname, so that libtool does not consider it 7145f05b35a2Smrg # for duplicate removal. 7146f05b35a2Smrg case " $specialdeplibs " in 7147f05b35a2Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 7148f05b35a2Smrg *) 7149f05b35a2Smrg case " $new_libs " in 7150f05b35a2Smrg *" $deplib "*) ;; 7151f05b35a2Smrg *) new_libs="$deplib $new_libs" ;; 7152f05b35a2Smrg esac 7153f05b35a2Smrg ;; 7154f05b35a2Smrg esac 7155f05b35a2Smrg ;; 7156f05b35a2Smrg esac 7157f05b35a2Smrg done 7158f05b35a2Smrg tmp_libs= 7159f05b35a2Smrg for deplib in $new_libs; do 7160f05b35a2Smrg case $deplib in 7161f05b35a2Smrg -L*) 7162f05b35a2Smrg case " $tmp_libs " in 7163f05b35a2Smrg *" $deplib "*) ;; 716467ab2ff2Smrg *) func_append tmp_libs " $deplib" ;; 7165f05b35a2Smrg esac 7166f05b35a2Smrg ;; 716767ab2ff2Smrg *) func_append tmp_libs " $deplib" ;; 7168f05b35a2Smrg esac 7169f05b35a2Smrg done 7170f05b35a2Smrg eval $var=\"$tmp_libs\" 7171f05b35a2Smrg done # for var 7172f05b35a2Smrg fi 7173f05b35a2Smrg # Last step: remove runtime libs from dependency_libs 7174f05b35a2Smrg # (they stay in deplibs) 7175f05b35a2Smrg tmp_libs= 7176f05b35a2Smrg for i in $dependency_libs ; do 7177f05b35a2Smrg case " $predeps $postdeps $compiler_lib_search_path " in 7178f05b35a2Smrg *" $i "*) 7179f05b35a2Smrg i="" 7180f05b35a2Smrg ;; 7181f05b35a2Smrg esac 7182f05b35a2Smrg if test -n "$i" ; then 718367ab2ff2Smrg func_append tmp_libs " $i" 7184f05b35a2Smrg fi 7185f05b35a2Smrg done 7186f05b35a2Smrg dependency_libs=$tmp_libs 7187f05b35a2Smrg done # for pass 7188f05b35a2Smrg if test "$linkmode" = prog; then 7189f05b35a2Smrg dlfiles="$newdlfiles" 7190f05b35a2Smrg fi 7191f05b35a2Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 7192f05b35a2Smrg dlprefiles="$newdlprefiles" 7193f05b35a2Smrg fi 7194f05b35a2Smrg 7195f05b35a2Smrg case $linkmode in 7196f05b35a2Smrg oldlib) 7197f05b35a2Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 7198f05b35a2Smrg func_warning "\`-dlopen' is ignored for archives" 7199f05b35a2Smrg fi 7200f05b35a2Smrg 7201f05b35a2Smrg case " $deplibs" in 7202f05b35a2Smrg *\ -l* | *\ -L*) 7203f05b35a2Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 7204f05b35a2Smrg esac 7205f05b35a2Smrg 7206f05b35a2Smrg test -n "$rpath" && \ 7207f05b35a2Smrg func_warning "\`-rpath' is ignored for archives" 7208f05b35a2Smrg 7209f05b35a2Smrg test -n "$xrpath" && \ 7210f05b35a2Smrg func_warning "\`-R' is ignored for archives" 7211f05b35a2Smrg 7212f05b35a2Smrg test -n "$vinfo" && \ 7213f05b35a2Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 7214f05b35a2Smrg 7215f05b35a2Smrg test -n "$release" && \ 7216f05b35a2Smrg func_warning "\`-release' is ignored for archives" 7217f05b35a2Smrg 7218f05b35a2Smrg test -n "$export_symbols$export_symbols_regex" && \ 7219f05b35a2Smrg func_warning "\`-export-symbols' is ignored for archives" 7220f05b35a2Smrg 7221f05b35a2Smrg # Now set the variables for building old libraries. 7222f05b35a2Smrg build_libtool_libs=no 7223f05b35a2Smrg oldlibs="$output" 722467ab2ff2Smrg func_append objs "$old_deplibs" 7225f05b35a2Smrg ;; 7226f05b35a2Smrg 7227f05b35a2Smrg lib) 7228f05b35a2Smrg # Make sure we only generate libraries of the form `libNAME.la'. 7229f05b35a2Smrg case $outputname in 7230f05b35a2Smrg lib*) 7231f05b35a2Smrg func_stripname 'lib' '.la' "$outputname" 7232f05b35a2Smrg name=$func_stripname_result 7233f05b35a2Smrg eval shared_ext=\"$shrext_cmds\" 7234f05b35a2Smrg eval libname=\"$libname_spec\" 7235f05b35a2Smrg ;; 7236f05b35a2Smrg *) 7237f05b35a2Smrg test "$module" = no && \ 7238f05b35a2Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 7239f05b35a2Smrg 7240f05b35a2Smrg if test "$need_lib_prefix" != no; then 7241f05b35a2Smrg # Add the "lib" prefix for modules if required 7242f05b35a2Smrg func_stripname '' '.la' "$outputname" 7243f05b35a2Smrg name=$func_stripname_result 7244f05b35a2Smrg eval shared_ext=\"$shrext_cmds\" 7245f05b35a2Smrg eval libname=\"$libname_spec\" 7246f05b35a2Smrg else 7247f05b35a2Smrg func_stripname '' '.la' "$outputname" 7248f05b35a2Smrg libname=$func_stripname_result 7249f05b35a2Smrg fi 7250f05b35a2Smrg ;; 7251f05b35a2Smrg esac 7252f05b35a2Smrg 7253f05b35a2Smrg if test -n "$objs"; then 7254f05b35a2Smrg if test "$deplibs_check_method" != pass_all; then 7255f05b35a2Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 7256f05b35a2Smrg else 725749e108a1Smrg echo 7258f05b35a2Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 7259f05b35a2Smrg $ECHO "*** objects $objs is not portable!" 726067ab2ff2Smrg func_append libobjs " $objs" 7261f05b35a2Smrg fi 7262f05b35a2Smrg fi 7263f05b35a2Smrg 7264f05b35a2Smrg test "$dlself" != no && \ 7265f05b35a2Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 7266f05b35a2Smrg 7267f05b35a2Smrg set dummy $rpath 7268f05b35a2Smrg shift 7269f05b35a2Smrg test "$#" -gt 1 && \ 7270f05b35a2Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 7271f05b35a2Smrg 7272f05b35a2Smrg install_libdir="$1" 7273f05b35a2Smrg 7274f05b35a2Smrg oldlibs= 7275f05b35a2Smrg if test -z "$rpath"; then 7276f05b35a2Smrg if test "$build_libtool_libs" = yes; then 7277f05b35a2Smrg # Building a libtool convenience library. 7278f05b35a2Smrg # Some compilers have problems with a `.al' extension so 7279f05b35a2Smrg # convenience libraries should have the same extension an 7280f05b35a2Smrg # archive normally would. 7281f05b35a2Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 7282f05b35a2Smrg build_libtool_libs=convenience 7283f05b35a2Smrg build_old_libs=yes 7284f05b35a2Smrg fi 7285f05b35a2Smrg 7286f05b35a2Smrg test -n "$vinfo" && \ 7287f05b35a2Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 7288f05b35a2Smrg 7289f05b35a2Smrg test -n "$release" && \ 7290f05b35a2Smrg func_warning "\`-release' is ignored for convenience libraries" 7291f05b35a2Smrg else 7292f05b35a2Smrg 7293f05b35a2Smrg # Parse the version information argument. 7294f05b35a2Smrg save_ifs="$IFS"; IFS=':' 7295f05b35a2Smrg set dummy $vinfo 0 0 0 7296f05b35a2Smrg shift 7297f05b35a2Smrg IFS="$save_ifs" 7298f05b35a2Smrg 7299f05b35a2Smrg test -n "$7" && \ 7300f05b35a2Smrg func_fatal_help "too many parameters to \`-version-info'" 7301f05b35a2Smrg 7302f05b35a2Smrg # convert absolute version numbers to libtool ages 7303f05b35a2Smrg # this retains compatibility with .la files and attempts 7304f05b35a2Smrg # to make the code below a bit more comprehensible 7305f05b35a2Smrg 7306f05b35a2Smrg case $vinfo_number in 7307f05b35a2Smrg yes) 7308f05b35a2Smrg number_major="$1" 7309f05b35a2Smrg number_minor="$2" 7310f05b35a2Smrg number_revision="$3" 7311f05b35a2Smrg # 7312f05b35a2Smrg # There are really only two kinds -- those that 7313f05b35a2Smrg # use the current revision as the major version 7314f05b35a2Smrg # and those that subtract age and use age as 7315f05b35a2Smrg # a minor version. But, then there is irix 7316f05b35a2Smrg # which has an extra 1 added just for fun 7317f05b35a2Smrg # 7318f05b35a2Smrg case $version_type in 7319f05b35a2Smrg darwin|linux|osf|windows|none) 7320f05b35a2Smrg func_arith $number_major + $number_minor 7321f05b35a2Smrg current=$func_arith_result 7322f05b35a2Smrg age="$number_minor" 7323f05b35a2Smrg revision="$number_revision" 7324f05b35a2Smrg ;; 732549e108a1Smrg freebsd-aout|freebsd-elf|qnx|sunos) 7326f05b35a2Smrg current="$number_major" 7327f05b35a2Smrg revision="$number_minor" 7328f05b35a2Smrg age="0" 7329f05b35a2Smrg ;; 7330f05b35a2Smrg irix|nonstopux) 7331f05b35a2Smrg func_arith $number_major + $number_minor 7332f05b35a2Smrg current=$func_arith_result 7333f05b35a2Smrg age="$number_minor" 7334f05b35a2Smrg revision="$number_minor" 7335f05b35a2Smrg lt_irix_increment=no 7336f05b35a2Smrg ;; 7337f05b35a2Smrg esac 7338f05b35a2Smrg ;; 7339f05b35a2Smrg no) 7340f05b35a2Smrg current="$1" 7341f05b35a2Smrg revision="$2" 7342f05b35a2Smrg age="$3" 7343f05b35a2Smrg ;; 7344f05b35a2Smrg esac 7345f05b35a2Smrg 7346f05b35a2Smrg # Check that each of the things are valid numbers. 7347f05b35a2Smrg case $current in 7348f05b35a2Smrg 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]) ;; 7349f05b35a2Smrg *) 7350f05b35a2Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 7351f05b35a2Smrg func_fatal_error "\`$vinfo' is not valid version information" 7352f05b35a2Smrg ;; 7353f05b35a2Smrg esac 7354f05b35a2Smrg 7355f05b35a2Smrg case $revision in 7356f05b35a2Smrg 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]) ;; 7357f05b35a2Smrg *) 7358f05b35a2Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 7359f05b35a2Smrg func_fatal_error "\`$vinfo' is not valid version information" 7360f05b35a2Smrg ;; 7361f05b35a2Smrg esac 7362f05b35a2Smrg 7363f05b35a2Smrg case $age in 7364f05b35a2Smrg 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]) ;; 7365f05b35a2Smrg *) 7366f05b35a2Smrg func_error "AGE \`$age' must be a nonnegative integer" 7367f05b35a2Smrg func_fatal_error "\`$vinfo' is not valid version information" 7368f05b35a2Smrg ;; 7369f05b35a2Smrg esac 7370f05b35a2Smrg 7371f05b35a2Smrg if test "$age" -gt "$current"; then 7372f05b35a2Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 7373f05b35a2Smrg func_fatal_error "\`$vinfo' is not valid version information" 7374f05b35a2Smrg fi 7375f05b35a2Smrg 7376f05b35a2Smrg # Calculate the version variables. 7377f05b35a2Smrg major= 7378f05b35a2Smrg versuffix= 7379f05b35a2Smrg verstring= 7380f05b35a2Smrg case $version_type in 7381f05b35a2Smrg none) ;; 7382f05b35a2Smrg 7383f05b35a2Smrg darwin) 7384f05b35a2Smrg # Like Linux, but with the current version available in 7385f05b35a2Smrg # verstring for coding it into the library header 7386f05b35a2Smrg func_arith $current - $age 7387f05b35a2Smrg major=.$func_arith_result 7388f05b35a2Smrg versuffix="$major.$age.$revision" 7389f05b35a2Smrg # Darwin ld doesn't like 0 for these options... 7390f05b35a2Smrg func_arith $current + 1 7391f05b35a2Smrg minor_current=$func_arith_result 7392f05b35a2Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 7393f05b35a2Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 7394f05b35a2Smrg ;; 7395f05b35a2Smrg 7396f05b35a2Smrg freebsd-aout) 7397f05b35a2Smrg major=".$current" 7398f05b35a2Smrg versuffix=".$current.$revision"; 7399f05b35a2Smrg ;; 7400f05b35a2Smrg 7401f05b35a2Smrg freebsd-elf) 7402f05b35a2Smrg major=".$current" 7403f05b35a2Smrg versuffix=".$current" 7404f05b35a2Smrg ;; 7405f05b35a2Smrg 7406f05b35a2Smrg irix | nonstopux) 7407f05b35a2Smrg if test "X$lt_irix_increment" = "Xno"; then 7408f05b35a2Smrg func_arith $current - $age 7409f05b35a2Smrg else 7410f05b35a2Smrg func_arith $current - $age + 1 7411f05b35a2Smrg fi 7412f05b35a2Smrg major=$func_arith_result 7413f05b35a2Smrg 7414f05b35a2Smrg case $version_type in 7415f05b35a2Smrg nonstopux) verstring_prefix=nonstopux ;; 7416f05b35a2Smrg *) verstring_prefix=sgi ;; 7417f05b35a2Smrg esac 7418f05b35a2Smrg verstring="$verstring_prefix$major.$revision" 7419f05b35a2Smrg 7420f05b35a2Smrg # Add in all the interfaces that we are compatible with. 7421f05b35a2Smrg loop=$revision 7422f05b35a2Smrg while test "$loop" -ne 0; do 7423f05b35a2Smrg func_arith $revision - $loop 7424f05b35a2Smrg iface=$func_arith_result 7425f05b35a2Smrg func_arith $loop - 1 7426f05b35a2Smrg loop=$func_arith_result 7427f05b35a2Smrg verstring="$verstring_prefix$major.$iface:$verstring" 7428f05b35a2Smrg done 7429f05b35a2Smrg 7430f05b35a2Smrg # Before this point, $major must not contain `.'. 7431f05b35a2Smrg major=.$major 7432f05b35a2Smrg versuffix="$major.$revision" 7433f05b35a2Smrg ;; 7434f05b35a2Smrg 7435f05b35a2Smrg linux) 7436f05b35a2Smrg func_arith $current - $age 7437f05b35a2Smrg major=.$func_arith_result 7438f05b35a2Smrg versuffix="$major.$age.$revision" 7439f05b35a2Smrg ;; 7440f05b35a2Smrg 7441f05b35a2Smrg osf) 7442f05b35a2Smrg func_arith $current - $age 7443f05b35a2Smrg major=.$func_arith_result 7444f05b35a2Smrg versuffix=".$current.$age.$revision" 7445f05b35a2Smrg verstring="$current.$age.$revision" 7446f05b35a2Smrg 7447f05b35a2Smrg # Add in all the interfaces that we are compatible with. 7448f05b35a2Smrg loop=$age 7449f05b35a2Smrg while test "$loop" -ne 0; do 7450f05b35a2Smrg func_arith $current - $loop 7451f05b35a2Smrg iface=$func_arith_result 7452f05b35a2Smrg func_arith $loop - 1 7453f05b35a2Smrg loop=$func_arith_result 7454f05b35a2Smrg verstring="$verstring:${iface}.0" 7455f05b35a2Smrg done 7456f05b35a2Smrg 7457f05b35a2Smrg # Make executables depend on our current version. 745867ab2ff2Smrg func_append verstring ":${current}.0" 7459f05b35a2Smrg ;; 7460f05b35a2Smrg 7461f05b35a2Smrg qnx) 7462f05b35a2Smrg major=".$current" 7463f05b35a2Smrg versuffix=".$current" 7464f05b35a2Smrg ;; 7465f05b35a2Smrg 7466f05b35a2Smrg sunos) 7467f05b35a2Smrg major=".$current" 7468f05b35a2Smrg versuffix=".$current.$revision" 7469f05b35a2Smrg ;; 7470f05b35a2Smrg 7471f05b35a2Smrg windows) 7472f05b35a2Smrg # Use '-' rather than '.', since we only want one 7473f05b35a2Smrg # extension on DOS 8.3 filesystems. 7474f05b35a2Smrg func_arith $current - $age 7475f05b35a2Smrg major=$func_arith_result 7476f05b35a2Smrg versuffix="-$major" 7477f05b35a2Smrg ;; 7478f05b35a2Smrg 7479f05b35a2Smrg *) 7480f05b35a2Smrg func_fatal_configuration "unknown library version type \`$version_type'" 7481f05b35a2Smrg ;; 7482f05b35a2Smrg esac 7483f05b35a2Smrg 7484f05b35a2Smrg # Clear the version info if we defaulted, and they specified a release. 7485f05b35a2Smrg if test -z "$vinfo" && test -n "$release"; then 7486f05b35a2Smrg major= 7487f05b35a2Smrg case $version_type in 7488f05b35a2Smrg darwin) 7489f05b35a2Smrg # we can't check for "0.0" in archive_cmds due to quoting 7490f05b35a2Smrg # problems, so we reset it completely 7491f05b35a2Smrg verstring= 7492f05b35a2Smrg ;; 7493f05b35a2Smrg *) 7494f05b35a2Smrg verstring="0.0" 7495f05b35a2Smrg ;; 7496f05b35a2Smrg esac 7497f05b35a2Smrg if test "$need_version" = no; then 7498f05b35a2Smrg versuffix= 7499f05b35a2Smrg else 7500f05b35a2Smrg versuffix=".0.0" 7501f05b35a2Smrg fi 7502f05b35a2Smrg fi 7503f05b35a2Smrg 7504f05b35a2Smrg # Remove version info from name if versioning should be avoided 7505f05b35a2Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 7506f05b35a2Smrg major= 7507f05b35a2Smrg versuffix= 7508f05b35a2Smrg verstring="" 7509f05b35a2Smrg fi 7510f05b35a2Smrg 7511f05b35a2Smrg # Check to see if the archive will have undefined symbols. 7512f05b35a2Smrg if test "$allow_undefined" = yes; then 7513f05b35a2Smrg if test "$allow_undefined_flag" = unsupported; then 7514f05b35a2Smrg func_warning "undefined symbols not allowed in $host shared libraries" 7515f05b35a2Smrg build_libtool_libs=no 7516f05b35a2Smrg build_old_libs=yes 7517f05b35a2Smrg fi 7518f05b35a2Smrg else 7519f05b35a2Smrg # Don't allow undefined symbols. 7520f05b35a2Smrg allow_undefined_flag="$no_undefined_flag" 7521f05b35a2Smrg fi 7522f05b35a2Smrg 7523f05b35a2Smrg fi 7524f05b35a2Smrg 7525f05b35a2Smrg func_generate_dlsyms "$libname" "$libname" "yes" 752667ab2ff2Smrg func_append libobjs " $symfileobj" 7527f05b35a2Smrg test "X$libobjs" = "X " && libobjs= 7528f05b35a2Smrg 752967ab2ff2Smrg if test "$opt_mode" != relink; then 7530f05b35a2Smrg # Remove our outputs, but don't remove object files since they 7531f05b35a2Smrg # may have been created when compiling PIC objects. 7532f05b35a2Smrg removelist= 7533f05b35a2Smrg tempremovelist=`$ECHO "$output_objdir/*"` 7534f05b35a2Smrg for p in $tempremovelist; do 7535f05b35a2Smrg case $p in 7536f05b35a2Smrg *.$objext | *.gcno) 7537f05b35a2Smrg ;; 7538f05b35a2Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 7539f05b35a2Smrg if test "X$precious_files_regex" != "X"; then 7540f05b35a2Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 7541f05b35a2Smrg then 7542f05b35a2Smrg continue 7543f05b35a2Smrg fi 7544f05b35a2Smrg fi 754567ab2ff2Smrg func_append removelist " $p" 7546f05b35a2Smrg ;; 7547f05b35a2Smrg *) ;; 7548f05b35a2Smrg esac 7549f05b35a2Smrg done 7550f05b35a2Smrg test -n "$removelist" && \ 7551f05b35a2Smrg func_show_eval "${RM}r \$removelist" 7552f05b35a2Smrg fi 7553f05b35a2Smrg 7554f05b35a2Smrg # Now set the variables for building old libraries. 7555f05b35a2Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 755667ab2ff2Smrg func_append oldlibs " $output_objdir/$libname.$libext" 7557f05b35a2Smrg 7558f05b35a2Smrg # Transform .lo files to .o files. 755949e108a1Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 7560f05b35a2Smrg fi 7561f05b35a2Smrg 7562f05b35a2Smrg # Eliminate all temporary directories. 7563f05b35a2Smrg #for path in $notinst_path; do 756449e108a1Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 756549e108a1Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 756649e108a1Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 7567f05b35a2Smrg #done 7568f05b35a2Smrg 7569f05b35a2Smrg if test -n "$xrpath"; then 7570f05b35a2Smrg # If the user specified any rpath flags, then add them. 7571f05b35a2Smrg temp_xrpath= 7572f05b35a2Smrg for libdir in $xrpath; do 757367ab2ff2Smrg func_replace_sysroot "$libdir" 757467ab2ff2Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 7575f05b35a2Smrg case "$finalize_rpath " in 7576f05b35a2Smrg *" $libdir "*) ;; 757767ab2ff2Smrg *) func_append finalize_rpath " $libdir" ;; 7578f05b35a2Smrg esac 7579f05b35a2Smrg done 7580f05b35a2Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 7581f05b35a2Smrg dependency_libs="$temp_xrpath $dependency_libs" 7582f05b35a2Smrg fi 7583f05b35a2Smrg fi 7584f05b35a2Smrg 7585f05b35a2Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 7586f05b35a2Smrg old_dlfiles="$dlfiles" 7587f05b35a2Smrg dlfiles= 7588f05b35a2Smrg for lib in $old_dlfiles; do 7589f05b35a2Smrg case " $dlprefiles $dlfiles " in 7590f05b35a2Smrg *" $lib "*) ;; 759167ab2ff2Smrg *) func_append dlfiles " $lib" ;; 7592f05b35a2Smrg esac 7593f05b35a2Smrg done 7594f05b35a2Smrg 7595f05b35a2Smrg # Make sure dlprefiles contains only unique files 7596f05b35a2Smrg old_dlprefiles="$dlprefiles" 7597f05b35a2Smrg dlprefiles= 7598f05b35a2Smrg for lib in $old_dlprefiles; do 7599f05b35a2Smrg case "$dlprefiles " in 7600f05b35a2Smrg *" $lib "*) ;; 760167ab2ff2Smrg *) func_append dlprefiles " $lib" ;; 7602f05b35a2Smrg esac 7603f05b35a2Smrg done 7604f05b35a2Smrg 7605f05b35a2Smrg if test "$build_libtool_libs" = yes; then 7606f05b35a2Smrg if test -n "$rpath"; then 7607f05b35a2Smrg case $host in 760849e108a1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 7609f05b35a2Smrg # these systems don't actually have a c library (as such)! 7610f05b35a2Smrg ;; 7611f05b35a2Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7612f05b35a2Smrg # Rhapsody C library is in the System framework 761367ab2ff2Smrg func_append deplibs " System.ltframework" 7614f05b35a2Smrg ;; 7615f05b35a2Smrg *-*-netbsd*) 7616f05b35a2Smrg # Don't link with libc until the a.out ld.so is fixed. 7617f05b35a2Smrg ;; 7618f05b35a2Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 7619f05b35a2Smrg # Do not include libc due to us having libc/libc_r. 7620f05b35a2Smrg ;; 7621f05b35a2Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7622f05b35a2Smrg # Causes problems with __ctype 7623f05b35a2Smrg ;; 7624f05b35a2Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7625f05b35a2Smrg # Compiler inserts libc in the correct place for threads to work 7626f05b35a2Smrg ;; 7627f05b35a2Smrg *) 7628f05b35a2Smrg # Add libc to deplibs on all other systems if necessary. 7629f05b35a2Smrg if test "$build_libtool_need_lc" = "yes"; then 763067ab2ff2Smrg func_append deplibs " -lc" 7631f05b35a2Smrg fi 7632f05b35a2Smrg ;; 7633f05b35a2Smrg esac 7634f05b35a2Smrg fi 7635f05b35a2Smrg 7636f05b35a2Smrg # Transform deplibs into only deplibs that can be linked in shared. 7637f05b35a2Smrg name_save=$name 7638f05b35a2Smrg libname_save=$libname 7639f05b35a2Smrg release_save=$release 7640f05b35a2Smrg versuffix_save=$versuffix 7641f05b35a2Smrg major_save=$major 7642f05b35a2Smrg # I'm not sure if I'm treating the release correctly. I think 7643f05b35a2Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 7644f05b35a2Smrg # add it in twice. Is that correct? 7645f05b35a2Smrg release="" 7646f05b35a2Smrg versuffix="" 7647f05b35a2Smrg major="" 7648f05b35a2Smrg newdeplibs= 7649f05b35a2Smrg droppeddeps=no 7650f05b35a2Smrg case $deplibs_check_method in 7651f05b35a2Smrg pass_all) 7652f05b35a2Smrg # Don't check for shared/static. Everything works. 7653f05b35a2Smrg # This might be a little naive. We might want to check 7654f05b35a2Smrg # whether the library exists or not. But this is on 7655f05b35a2Smrg # osf3 & osf4 and I'm not really sure... Just 7656f05b35a2Smrg # implementing what was already the behavior. 7657f05b35a2Smrg newdeplibs=$deplibs 7658f05b35a2Smrg ;; 7659f05b35a2Smrg test_compile) 7660f05b35a2Smrg # This code stresses the "libraries are programs" paradigm to its 7661f05b35a2Smrg # limits. Maybe even breaks it. We compile a program, linking it 7662f05b35a2Smrg # against the deplibs as a proxy for the library. Then we can check 7663f05b35a2Smrg # whether they linked in statically or dynamically with ldd. 7664f05b35a2Smrg $opt_dry_run || $RM conftest.c 7665f05b35a2Smrg cat > conftest.c <<EOF 7666f05b35a2Smrg int main() { return 0; } 7667f05b35a2SmrgEOF 7668f05b35a2Smrg $opt_dry_run || $RM conftest 7669f05b35a2Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 7670f05b35a2Smrg ldd_output=`ldd conftest` 7671f05b35a2Smrg for i in $deplibs; do 7672f05b35a2Smrg case $i in 7673f05b35a2Smrg -l*) 7674f05b35a2Smrg func_stripname -l '' "$i" 7675f05b35a2Smrg name=$func_stripname_result 7676f05b35a2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7677f05b35a2Smrg case " $predeps $postdeps " in 7678f05b35a2Smrg *" $i "*) 767967ab2ff2Smrg func_append newdeplibs " $i" 7680f05b35a2Smrg i="" 7681f05b35a2Smrg ;; 7682f05b35a2Smrg esac 7683f05b35a2Smrg fi 7684f05b35a2Smrg if test -n "$i" ; then 7685f05b35a2Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7686f05b35a2Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7687f05b35a2Smrg set dummy $deplib_matches; shift 7688f05b35a2Smrg deplib_match=$1 7689f05b35a2Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 769067ab2ff2Smrg func_append newdeplibs " $i" 7691f05b35a2Smrg else 7692f05b35a2Smrg droppeddeps=yes 769349e108a1Smrg echo 7694f05b35a2Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 769549e108a1Smrg echo "*** I have the capability to make that library automatically link in when" 769649e108a1Smrg echo "*** you link to this library. But I can only do this if you have a" 769749e108a1Smrg echo "*** shared version of the library, which I believe you do not have" 769849e108a1Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 769949e108a1Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 7700f05b35a2Smrg fi 7701f05b35a2Smrg fi 7702f05b35a2Smrg ;; 7703f05b35a2Smrg *) 770467ab2ff2Smrg func_append newdeplibs " $i" 7705f05b35a2Smrg ;; 7706f05b35a2Smrg esac 7707f05b35a2Smrg done 7708f05b35a2Smrg else 7709f05b35a2Smrg # Error occurred in the first compile. Let's try to salvage 7710f05b35a2Smrg # the situation: Compile a separate program for each library. 7711f05b35a2Smrg for i in $deplibs; do 7712f05b35a2Smrg case $i in 7713f05b35a2Smrg -l*) 7714f05b35a2Smrg func_stripname -l '' "$i" 7715f05b35a2Smrg name=$func_stripname_result 7716f05b35a2Smrg $opt_dry_run || $RM conftest 7717f05b35a2Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 7718f05b35a2Smrg ldd_output=`ldd conftest` 7719f05b35a2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7720f05b35a2Smrg case " $predeps $postdeps " in 7721f05b35a2Smrg *" $i "*) 772267ab2ff2Smrg func_append newdeplibs " $i" 7723f05b35a2Smrg i="" 7724f05b35a2Smrg ;; 7725f05b35a2Smrg esac 7726f05b35a2Smrg fi 7727f05b35a2Smrg if test -n "$i" ; then 7728f05b35a2Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7729f05b35a2Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7730f05b35a2Smrg set dummy $deplib_matches; shift 7731f05b35a2Smrg deplib_match=$1 7732f05b35a2Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 773367ab2ff2Smrg func_append newdeplibs " $i" 7734f05b35a2Smrg else 7735f05b35a2Smrg droppeddeps=yes 773649e108a1Smrg echo 7737f05b35a2Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 773849e108a1Smrg echo "*** I have the capability to make that library automatically link in when" 773949e108a1Smrg echo "*** you link to this library. But I can only do this if you have a" 774049e108a1Smrg echo "*** shared version of the library, which you do not appear to have" 774149e108a1Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 774249e108a1Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 7743f05b35a2Smrg fi 7744f05b35a2Smrg fi 7745f05b35a2Smrg else 7746f05b35a2Smrg droppeddeps=yes 774749e108a1Smrg echo 7748f05b35a2Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 774949e108a1Smrg echo "*** make it link in! You will probably need to install it or some" 775049e108a1Smrg echo "*** library that it depends on before this library will be fully" 775149e108a1Smrg echo "*** functional. Installing it before continuing would be even better." 7752f05b35a2Smrg fi 7753f05b35a2Smrg ;; 7754f05b35a2Smrg *) 775567ab2ff2Smrg func_append newdeplibs " $i" 7756f05b35a2Smrg ;; 7757f05b35a2Smrg esac 7758f05b35a2Smrg done 7759f05b35a2Smrg fi 7760f05b35a2Smrg ;; 7761f05b35a2Smrg file_magic*) 7762f05b35a2Smrg set dummy $deplibs_check_method; shift 7763f05b35a2Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7764f05b35a2Smrg for a_deplib in $deplibs; do 7765f05b35a2Smrg case $a_deplib in 7766f05b35a2Smrg -l*) 7767f05b35a2Smrg func_stripname -l '' "$a_deplib" 7768f05b35a2Smrg name=$func_stripname_result 7769f05b35a2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7770f05b35a2Smrg case " $predeps $postdeps " in 7771f05b35a2Smrg *" $a_deplib "*) 777267ab2ff2Smrg func_append newdeplibs " $a_deplib" 7773f05b35a2Smrg a_deplib="" 7774f05b35a2Smrg ;; 7775f05b35a2Smrg esac 7776f05b35a2Smrg fi 7777f05b35a2Smrg if test -n "$a_deplib" ; then 7778f05b35a2Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 777967ab2ff2Smrg if test -n "$file_magic_glob"; then 778067ab2ff2Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 778167ab2ff2Smrg else 778267ab2ff2Smrg libnameglob=$libname 778367ab2ff2Smrg fi 778467ab2ff2Smrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 7785f05b35a2Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 778667ab2ff2Smrg if test "$want_nocaseglob" = yes; then 778767ab2ff2Smrg shopt -s nocaseglob 778867ab2ff2Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 778967ab2ff2Smrg $nocaseglob 779067ab2ff2Smrg else 779167ab2ff2Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 779267ab2ff2Smrg fi 7793f05b35a2Smrg for potent_lib in $potential_libs; do 7794f05b35a2Smrg # Follow soft links. 7795f05b35a2Smrg if ls -lLd "$potent_lib" 2>/dev/null | 7796f05b35a2Smrg $GREP " -> " >/dev/null; then 7797f05b35a2Smrg continue 7798f05b35a2Smrg fi 7799f05b35a2Smrg # The statement above tries to avoid entering an 7800f05b35a2Smrg # endless loop below, in case of cyclic links. 7801f05b35a2Smrg # We might still enter an endless loop, since a link 7802f05b35a2Smrg # loop can be closed while we follow links, 7803f05b35a2Smrg # but so what? 7804f05b35a2Smrg potlib="$potent_lib" 7805f05b35a2Smrg while test -h "$potlib" 2>/dev/null; do 7806f05b35a2Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 7807f05b35a2Smrg case $potliblink in 7808f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 780949e108a1Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 7810f05b35a2Smrg esac 7811f05b35a2Smrg done 7812f05b35a2Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 7813f05b35a2Smrg $SED -e 10q | 7814f05b35a2Smrg $EGREP "$file_magic_regex" > /dev/null; then 781567ab2ff2Smrg func_append newdeplibs " $a_deplib" 7816f05b35a2Smrg a_deplib="" 7817f05b35a2Smrg break 2 7818f05b35a2Smrg fi 7819f05b35a2Smrg done 7820f05b35a2Smrg done 7821f05b35a2Smrg fi 7822f05b35a2Smrg if test -n "$a_deplib" ; then 7823f05b35a2Smrg droppeddeps=yes 782449e108a1Smrg echo 7825f05b35a2Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 782649e108a1Smrg echo "*** I have the capability to make that library automatically link in when" 782749e108a1Smrg echo "*** you link to this library. But I can only do this if you have a" 782849e108a1Smrg echo "*** shared version of the library, which you do not appear to have" 782949e108a1Smrg echo "*** because I did check the linker path looking for a file starting" 7830f05b35a2Smrg if test -z "$potlib" ; then 7831f05b35a2Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 7832f05b35a2Smrg else 7833f05b35a2Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 7834f05b35a2Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 7835f05b35a2Smrg fi 7836f05b35a2Smrg fi 7837f05b35a2Smrg ;; 7838f05b35a2Smrg *) 7839f05b35a2Smrg # Add a -L argument. 784067ab2ff2Smrg func_append newdeplibs " $a_deplib" 7841f05b35a2Smrg ;; 7842f05b35a2Smrg esac 7843f05b35a2Smrg done # Gone through all deplibs. 7844f05b35a2Smrg ;; 7845f05b35a2Smrg match_pattern*) 7846f05b35a2Smrg set dummy $deplibs_check_method; shift 7847f05b35a2Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7848f05b35a2Smrg for a_deplib in $deplibs; do 7849f05b35a2Smrg case $a_deplib in 7850f05b35a2Smrg -l*) 7851f05b35a2Smrg func_stripname -l '' "$a_deplib" 7852f05b35a2Smrg name=$func_stripname_result 7853f05b35a2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7854f05b35a2Smrg case " $predeps $postdeps " in 7855f05b35a2Smrg *" $a_deplib "*) 785667ab2ff2Smrg func_append newdeplibs " $a_deplib" 7857f05b35a2Smrg a_deplib="" 7858f05b35a2Smrg ;; 7859f05b35a2Smrg esac 7860f05b35a2Smrg fi 7861f05b35a2Smrg if test -n "$a_deplib" ; then 7862f05b35a2Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7863f05b35a2Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7864f05b35a2Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 7865f05b35a2Smrg for potent_lib in $potential_libs; do 7866f05b35a2Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 786749e108a1Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 7868f05b35a2Smrg $EGREP "$match_pattern_regex" > /dev/null; then 786967ab2ff2Smrg func_append newdeplibs " $a_deplib" 7870f05b35a2Smrg a_deplib="" 7871f05b35a2Smrg break 2 7872f05b35a2Smrg fi 7873f05b35a2Smrg done 7874f05b35a2Smrg done 7875f05b35a2Smrg fi 7876f05b35a2Smrg if test -n "$a_deplib" ; then 7877f05b35a2Smrg droppeddeps=yes 787849e108a1Smrg echo 7879f05b35a2Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 788049e108a1Smrg echo "*** I have the capability to make that library automatically link in when" 788149e108a1Smrg echo "*** you link to this library. But I can only do this if you have a" 788249e108a1Smrg echo "*** shared version of the library, which you do not appear to have" 788349e108a1Smrg echo "*** because I did check the linker path looking for a file starting" 7884f05b35a2Smrg if test -z "$potlib" ; then 7885f05b35a2Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 7886f05b35a2Smrg else 7887f05b35a2Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 7888f05b35a2Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 7889f05b35a2Smrg fi 7890f05b35a2Smrg fi 7891f05b35a2Smrg ;; 7892f05b35a2Smrg *) 7893f05b35a2Smrg # Add a -L argument. 789467ab2ff2Smrg func_append newdeplibs " $a_deplib" 7895f05b35a2Smrg ;; 7896f05b35a2Smrg esac 7897f05b35a2Smrg done # Gone through all deplibs. 7898f05b35a2Smrg ;; 7899f05b35a2Smrg none | unknown | *) 7900f05b35a2Smrg newdeplibs="" 790149e108a1Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 7902f05b35a2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7903f05b35a2Smrg for i in $predeps $postdeps ; do 7904f05b35a2Smrg # can't use Xsed below, because $i might contain '/' 790549e108a1Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 7906f05b35a2Smrg done 7907f05b35a2Smrg fi 790849e108a1Smrg case $tmp_deplibs in 790949e108a1Smrg *[!\ \ ]*) 791049e108a1Smrg echo 7911f05b35a2Smrg if test "X$deplibs_check_method" = "Xnone"; then 791249e108a1Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 7913f05b35a2Smrg else 791449e108a1Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 7915f05b35a2Smrg fi 791649e108a1Smrg echo "*** All declared inter-library dependencies are being dropped." 7917f05b35a2Smrg droppeddeps=yes 791849e108a1Smrg ;; 791949e108a1Smrg esac 7920f05b35a2Smrg ;; 7921f05b35a2Smrg esac 7922f05b35a2Smrg versuffix=$versuffix_save 7923f05b35a2Smrg major=$major_save 7924f05b35a2Smrg release=$release_save 7925f05b35a2Smrg libname=$libname_save 7926f05b35a2Smrg name=$name_save 7927f05b35a2Smrg 7928f05b35a2Smrg case $host in 7929f05b35a2Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7930f05b35a2Smrg # On Rhapsody replace the C library with the System framework 793149e108a1Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 7932f05b35a2Smrg ;; 7933f05b35a2Smrg esac 7934f05b35a2Smrg 7935f05b35a2Smrg if test "$droppeddeps" = yes; then 7936f05b35a2Smrg if test "$module" = yes; then 793749e108a1Smrg echo 793849e108a1Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 7939f05b35a2Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 794049e108a1Smrg echo "*** a static module, that should work as long as the dlopening" 794149e108a1Smrg echo "*** application is linked with the -dlopen flag." 7942f05b35a2Smrg if test -z "$global_symbol_pipe"; then 794349e108a1Smrg echo 794449e108a1Smrg echo "*** However, this would only work if libtool was able to extract symbol" 794549e108a1Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 794649e108a1Smrg echo "*** not find such a program. So, this module is probably useless." 794749e108a1Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 7948f05b35a2Smrg fi 7949f05b35a2Smrg if test "$build_old_libs" = no; then 7950f05b35a2Smrg oldlibs="$output_objdir/$libname.$libext" 7951f05b35a2Smrg build_libtool_libs=module 7952f05b35a2Smrg build_old_libs=yes 7953f05b35a2Smrg else 7954f05b35a2Smrg build_libtool_libs=no 7955f05b35a2Smrg fi 7956f05b35a2Smrg else 795749e108a1Smrg echo "*** The inter-library dependencies that have been dropped here will be" 795849e108a1Smrg echo "*** automatically added whenever a program is linked with this library" 795949e108a1Smrg echo "*** or is declared to -dlopen it." 7960f05b35a2Smrg 7961f05b35a2Smrg if test "$allow_undefined" = no; then 796249e108a1Smrg echo 796349e108a1Smrg echo "*** Since this library must not contain undefined symbols," 796449e108a1Smrg echo "*** because either the platform does not support them or" 796549e108a1Smrg echo "*** it was explicitly requested with -no-undefined," 796649e108a1Smrg echo "*** libtool will only create a static version of it." 7967f05b35a2Smrg if test "$build_old_libs" = no; then 7968f05b35a2Smrg oldlibs="$output_objdir/$libname.$libext" 7969f05b35a2Smrg build_libtool_libs=module 7970f05b35a2Smrg build_old_libs=yes 7971f05b35a2Smrg else 7972f05b35a2Smrg build_libtool_libs=no 7973f05b35a2Smrg fi 7974f05b35a2Smrg fi 7975f05b35a2Smrg fi 7976f05b35a2Smrg fi 7977f05b35a2Smrg # Done checking deplibs! 7978f05b35a2Smrg deplibs=$newdeplibs 7979f05b35a2Smrg fi 7980f05b35a2Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 7981f05b35a2Smrg case $host in 7982f05b35a2Smrg *-*-darwin*) 798349e108a1Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 798449e108a1Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 798549e108a1Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7986f05b35a2Smrg ;; 7987f05b35a2Smrg esac 7988f05b35a2Smrg 7989f05b35a2Smrg # move library search paths that coincide with paths to not yet 7990f05b35a2Smrg # installed libraries to the beginning of the library search list 7991f05b35a2Smrg new_libs= 7992f05b35a2Smrg for path in $notinst_path; do 7993f05b35a2Smrg case " $new_libs " in 7994f05b35a2Smrg *" -L$path/$objdir "*) ;; 7995f05b35a2Smrg *) 7996f05b35a2Smrg case " $deplibs " in 7997f05b35a2Smrg *" -L$path/$objdir "*) 799867ab2ff2Smrg func_append new_libs " -L$path/$objdir" ;; 7999f05b35a2Smrg esac 8000f05b35a2Smrg ;; 8001f05b35a2Smrg esac 8002f05b35a2Smrg done 8003f05b35a2Smrg for deplib in $deplibs; do 8004f05b35a2Smrg case $deplib in 8005f05b35a2Smrg -L*) 8006f05b35a2Smrg case " $new_libs " in 8007f05b35a2Smrg *" $deplib "*) ;; 800867ab2ff2Smrg *) func_append new_libs " $deplib" ;; 8009f05b35a2Smrg esac 8010f05b35a2Smrg ;; 801167ab2ff2Smrg *) func_append new_libs " $deplib" ;; 8012f05b35a2Smrg esac 8013f05b35a2Smrg done 8014f05b35a2Smrg deplibs="$new_libs" 8015f05b35a2Smrg 8016f05b35a2Smrg # All the library-specific variables (install_libdir is set above). 8017f05b35a2Smrg library_names= 8018f05b35a2Smrg old_library= 8019f05b35a2Smrg dlname= 8020f05b35a2Smrg 8021f05b35a2Smrg # Test again, we may have decided not to build it any more 8022f05b35a2Smrg if test "$build_libtool_libs" = yes; then 8023f05b35a2Smrg if test "$hardcode_into_libs" = yes; then 8024f05b35a2Smrg # Hardcode the library paths 8025f05b35a2Smrg hardcode_libdirs= 8026f05b35a2Smrg dep_rpath= 8027f05b35a2Smrg rpath="$finalize_rpath" 802867ab2ff2Smrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 8029f05b35a2Smrg for libdir in $rpath; do 8030f05b35a2Smrg if test -n "$hardcode_libdir_flag_spec"; then 8031f05b35a2Smrg if test -n "$hardcode_libdir_separator"; then 803267ab2ff2Smrg func_replace_sysroot "$libdir" 803367ab2ff2Smrg libdir=$func_replace_sysroot_result 8034f05b35a2Smrg if test -z "$hardcode_libdirs"; then 8035f05b35a2Smrg hardcode_libdirs="$libdir" 8036f05b35a2Smrg else 8037f05b35a2Smrg # Just accumulate the unique libdirs. 8038f05b35a2Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8039f05b35a2Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8040f05b35a2Smrg ;; 8041f05b35a2Smrg *) 804267ab2ff2Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8043f05b35a2Smrg ;; 8044f05b35a2Smrg esac 8045f05b35a2Smrg fi 8046f05b35a2Smrg else 8047f05b35a2Smrg eval flag=\"$hardcode_libdir_flag_spec\" 804867ab2ff2Smrg func_append dep_rpath " $flag" 8049f05b35a2Smrg fi 8050f05b35a2Smrg elif test -n "$runpath_var"; then 8051f05b35a2Smrg case "$perm_rpath " in 8052f05b35a2Smrg *" $libdir "*) ;; 805367ab2ff2Smrg *) func_apped perm_rpath " $libdir" ;; 8054f05b35a2Smrg esac 8055f05b35a2Smrg fi 8056f05b35a2Smrg done 8057f05b35a2Smrg # Substitute the hardcoded libdirs into the rpath. 8058f05b35a2Smrg if test -n "$hardcode_libdir_separator" && 8059f05b35a2Smrg test -n "$hardcode_libdirs"; then 8060f05b35a2Smrg libdir="$hardcode_libdirs" 8061f05b35a2Smrg if test -n "$hardcode_libdir_flag_spec_ld"; then 8062f05b35a2Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" 8063f05b35a2Smrg else 8064f05b35a2Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec\" 8065f05b35a2Smrg fi 8066f05b35a2Smrg fi 8067f05b35a2Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 8068f05b35a2Smrg # We should set the runpath_var. 8069f05b35a2Smrg rpath= 8070f05b35a2Smrg for dir in $perm_rpath; do 807167ab2ff2Smrg func_append rpath "$dir:" 8072f05b35a2Smrg done 8073f05b35a2Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 8074f05b35a2Smrg fi 8075f05b35a2Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 8076f05b35a2Smrg fi 8077e0963edeSmrg 8078f05b35a2Smrg shlibpath="$finalize_shlibpath" 807967ab2ff2Smrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 8080f05b35a2Smrg if test -n "$shlibpath"; then 8081f05b35a2Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 8082f05b35a2Smrg fi 8083e0963edeSmrg 8084f05b35a2Smrg # Get the real and link names of the library. 8085f05b35a2Smrg eval shared_ext=\"$shrext_cmds\" 8086f05b35a2Smrg eval library_names=\"$library_names_spec\" 8087f05b35a2Smrg set dummy $library_names 8088f05b35a2Smrg shift 8089f05b35a2Smrg realname="$1" 8090f05b35a2Smrg shift 8091e0963edeSmrg 8092f05b35a2Smrg if test -n "$soname_spec"; then 8093f05b35a2Smrg eval soname=\"$soname_spec\" 8094f05b35a2Smrg else 8095f05b35a2Smrg soname="$realname" 8096f05b35a2Smrg fi 8097f05b35a2Smrg if test -z "$dlname"; then 8098f05b35a2Smrg dlname=$soname 8099f05b35a2Smrg fi 8100e0963edeSmrg 8101f05b35a2Smrg lib="$output_objdir/$realname" 8102f05b35a2Smrg linknames= 8103f05b35a2Smrg for link 8104f05b35a2Smrg do 810567ab2ff2Smrg func_append linknames " $link" 8106f05b35a2Smrg done 8107e0963edeSmrg 8108f05b35a2Smrg # Use standard objects if they are pic 810949e108a1Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 8110f05b35a2Smrg test "X$libobjs" = "X " && libobjs= 8111e0963edeSmrg 8112f05b35a2Smrg delfiles= 8113f05b35a2Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8114f05b35a2Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 8115f05b35a2Smrg export_symbols="$output_objdir/$libname.uexp" 811667ab2ff2Smrg func_append delfiles " $export_symbols" 8117f05b35a2Smrg fi 8118e0963edeSmrg 8119f05b35a2Smrg orig_export_symbols= 8120f05b35a2Smrg case $host_os in 8121f05b35a2Smrg cygwin* | mingw* | cegcc*) 8122f05b35a2Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 8123f05b35a2Smrg # exporting using user supplied symfile 8124f05b35a2Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 8125f05b35a2Smrg # and it's NOT already a .def file. Must figure out 8126f05b35a2Smrg # which of the given symbols are data symbols and tag 8127f05b35a2Smrg # them as such. So, trigger use of export_symbols_cmds. 8128f05b35a2Smrg # export_symbols gets reassigned inside the "prepare 8129f05b35a2Smrg # the list of exported symbols" if statement, so the 8130f05b35a2Smrg # include_expsyms logic still works. 8131f05b35a2Smrg orig_export_symbols="$export_symbols" 8132f05b35a2Smrg export_symbols= 8133f05b35a2Smrg always_export_symbols=yes 8134f05b35a2Smrg fi 8135f05b35a2Smrg fi 8136f05b35a2Smrg ;; 8137f05b35a2Smrg esac 8138e0963edeSmrg 8139f05b35a2Smrg # Prepare the list of exported symbols 8140f05b35a2Smrg if test -z "$export_symbols"; then 8141f05b35a2Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 8142f05b35a2Smrg func_verbose "generating symbol list for \`$libname.la'" 8143f05b35a2Smrg export_symbols="$output_objdir/$libname.exp" 8144f05b35a2Smrg $opt_dry_run || $RM $export_symbols 8145f05b35a2Smrg cmds=$export_symbols_cmds 8146f05b35a2Smrg save_ifs="$IFS"; IFS='~' 814767ab2ff2Smrg for cmd1 in $cmds; do 8148f05b35a2Smrg IFS="$save_ifs" 814967ab2ff2Smrg # Take the normal branch if the nm_file_list_spec branch 815067ab2ff2Smrg # doesn't work or if tool conversion is not needed. 815167ab2ff2Smrg case $nm_file_list_spec~$to_tool_file_cmd in 815267ab2ff2Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 815367ab2ff2Smrg try_normal_branch=yes 815467ab2ff2Smrg eval cmd=\"$cmd1\" 815567ab2ff2Smrg func_len " $cmd" 815667ab2ff2Smrg len=$func_len_result 815767ab2ff2Smrg ;; 815867ab2ff2Smrg *) 815967ab2ff2Smrg try_normal_branch=no 816067ab2ff2Smrg ;; 816167ab2ff2Smrg esac 816267ab2ff2Smrg if test "$try_normal_branch" = yes \ 816367ab2ff2Smrg && { test "$len" -lt "$max_cmd_len" \ 816467ab2ff2Smrg || test "$max_cmd_len" -le -1; } 816567ab2ff2Smrg then 816667ab2ff2Smrg func_show_eval "$cmd" 'exit $?' 816767ab2ff2Smrg skipped_export=false 816867ab2ff2Smrg elif test -n "$nm_file_list_spec"; then 816967ab2ff2Smrg func_basename "$output" 817067ab2ff2Smrg output_la=$func_basename_result 817167ab2ff2Smrg save_libobjs=$libobjs 817267ab2ff2Smrg save_output=$output 817367ab2ff2Smrg output=${output_objdir}/${output_la}.nm 817467ab2ff2Smrg func_to_tool_file "$output" 817567ab2ff2Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 817667ab2ff2Smrg func_append delfiles " $output" 817767ab2ff2Smrg func_verbose "creating $NM input file list: $output" 817867ab2ff2Smrg for obj in $save_libobjs; do 817967ab2ff2Smrg func_to_tool_file "$obj" 818067ab2ff2Smrg $ECHO "$func_to_tool_file_result" 818167ab2ff2Smrg done > "$output" 818267ab2ff2Smrg eval cmd=\"$cmd1\" 8183f05b35a2Smrg func_show_eval "$cmd" 'exit $?' 818467ab2ff2Smrg output=$save_output 818567ab2ff2Smrg libobjs=$save_libobjs 8186f05b35a2Smrg skipped_export=false 8187f05b35a2Smrg else 8188f05b35a2Smrg # The command line is too long to execute in one step. 8189f05b35a2Smrg func_verbose "using reloadable object file for export list..." 8190f05b35a2Smrg skipped_export=: 8191f05b35a2Smrg # Break out early, otherwise skipped_export may be 8192f05b35a2Smrg # set to false by a later but shorter cmd. 8193f05b35a2Smrg break 8194f05b35a2Smrg fi 8195f05b35a2Smrg done 8196f05b35a2Smrg IFS="$save_ifs" 8197f05b35a2Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 8198f05b35a2Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8199f05b35a2Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8200f05b35a2Smrg fi 8201f05b35a2Smrg fi 8202f05b35a2Smrg fi 8203e0963edeSmrg 8204f05b35a2Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8205f05b35a2Smrg tmp_export_symbols="$export_symbols" 8206f05b35a2Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 820749e108a1Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8208f05b35a2Smrg fi 8209e0963edeSmrg 8210f05b35a2Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 8211f05b35a2Smrg # The given exports_symbols file has to be filtered, so filter it. 8212f05b35a2Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8213f05b35a2Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 8214f05b35a2Smrg # 's' commands which not all seds can handle. GNU sed should be fine 8215f05b35a2Smrg # though. Also, the filter scales superlinearly with the number of 8216f05b35a2Smrg # global variables. join(1) would be nice here, but unfortunately 8217f05b35a2Smrg # isn't a blessed tool. 8218f05b35a2Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 821967ab2ff2Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8220f05b35a2Smrg export_symbols=$output_objdir/$libname.def 8221f05b35a2Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8222e0963edeSmrg fi 8223e0963edeSmrg 8224f05b35a2Smrg tmp_deplibs= 8225f05b35a2Smrg for test_deplib in $deplibs; do 8226f05b35a2Smrg case " $convenience " in 8227f05b35a2Smrg *" $test_deplib "*) ;; 8228f05b35a2Smrg *) 822967ab2ff2Smrg func_append tmp_deplibs " $test_deplib" 8230f05b35a2Smrg ;; 8231f05b35a2Smrg esac 8232f05b35a2Smrg done 8233f05b35a2Smrg deplibs="$tmp_deplibs" 8234e0963edeSmrg 8235f05b35a2Smrg if test -n "$convenience"; then 8236f05b35a2Smrg if test -n "$whole_archive_flag_spec" && 8237f05b35a2Smrg test "$compiler_needs_object" = yes && 8238f05b35a2Smrg test -z "$libobjs"; then 8239f05b35a2Smrg # extract the archives, so we have objects to list. 8240f05b35a2Smrg # TODO: could optimize this to just extract one archive. 8241f05b35a2Smrg whole_archive_flag_spec= 8242f05b35a2Smrg fi 8243f05b35a2Smrg if test -n "$whole_archive_flag_spec"; then 8244f05b35a2Smrg save_libobjs=$libobjs 8245f05b35a2Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8246f05b35a2Smrg test "X$libobjs" = "X " && libobjs= 8247f05b35a2Smrg else 8248f05b35a2Smrg gentop="$output_objdir/${outputname}x" 824967ab2ff2Smrg func_append generated " $gentop" 8250e0963edeSmrg 8251f05b35a2Smrg func_extract_archives $gentop $convenience 825267ab2ff2Smrg func_append libobjs " $func_extract_archives_result" 8253f05b35a2Smrg test "X$libobjs" = "X " && libobjs= 8254f05b35a2Smrg fi 8255f05b35a2Smrg fi 8256e0963edeSmrg 8257f05b35a2Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 8258f05b35a2Smrg eval flag=\"$thread_safe_flag_spec\" 825967ab2ff2Smrg func_append linker_flags " $flag" 8260f05b35a2Smrg fi 8261e0963edeSmrg 8262f05b35a2Smrg # Make a backup of the uninstalled library when relinking 826367ab2ff2Smrg if test "$opt_mode" = relink; then 8264f05b35a2Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 8265e0963edeSmrg fi 8266e0963edeSmrg 8267f05b35a2Smrg # Do each of the archive commands. 8268f05b35a2Smrg if test "$module" = yes && test -n "$module_cmds" ; then 8269f05b35a2Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8270f05b35a2Smrg eval test_cmds=\"$module_expsym_cmds\" 8271f05b35a2Smrg cmds=$module_expsym_cmds 8272f05b35a2Smrg else 8273f05b35a2Smrg eval test_cmds=\"$module_cmds\" 8274f05b35a2Smrg cmds=$module_cmds 8275f05b35a2Smrg fi 8276f05b35a2Smrg else 8277f05b35a2Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8278f05b35a2Smrg eval test_cmds=\"$archive_expsym_cmds\" 8279f05b35a2Smrg cmds=$archive_expsym_cmds 8280f05b35a2Smrg else 8281f05b35a2Smrg eval test_cmds=\"$archive_cmds\" 8282f05b35a2Smrg cmds=$archive_cmds 8283f05b35a2Smrg fi 8284e0963edeSmrg fi 8285e0963edeSmrg 8286f05b35a2Smrg if test "X$skipped_export" != "X:" && 8287f05b35a2Smrg func_len " $test_cmds" && 8288f05b35a2Smrg len=$func_len_result && 8289f05b35a2Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 8290f05b35a2Smrg : 8291f05b35a2Smrg else 8292f05b35a2Smrg # The command line is too long to link in one step, link piecewise 8293f05b35a2Smrg # or, if using GNU ld and skipped_export is not :, use a linker 8294f05b35a2Smrg # script. 8295e0963edeSmrg 8296f05b35a2Smrg # Save the value of $output and $libobjs because we want to 8297f05b35a2Smrg # use them later. If we have whole_archive_flag_spec, we 8298f05b35a2Smrg # want to use save_libobjs as it was before 8299f05b35a2Smrg # whole_archive_flag_spec was expanded, because we can't 8300f05b35a2Smrg # assume the linker understands whole_archive_flag_spec. 8301f05b35a2Smrg # This may have to be revisited, in case too many 8302f05b35a2Smrg # convenience libraries get linked in and end up exceeding 8303f05b35a2Smrg # the spec. 8304f05b35a2Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 8305f05b35a2Smrg save_libobjs=$libobjs 8306f05b35a2Smrg fi 8307f05b35a2Smrg save_output=$output 830849e108a1Smrg func_basename "$output" 830949e108a1Smrg output_la=$func_basename_result 8310e0963edeSmrg 8311f05b35a2Smrg # Clear the reloadable object creation command queue and 8312f05b35a2Smrg # initialize k to one. 8313f05b35a2Smrg test_cmds= 8314f05b35a2Smrg concat_cmds= 8315f05b35a2Smrg objlist= 8316f05b35a2Smrg last_robj= 8317f05b35a2Smrg k=1 8318e0963edeSmrg 8319f05b35a2Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 8320f05b35a2Smrg output=${output_objdir}/${output_la}.lnkscript 8321f05b35a2Smrg func_verbose "creating GNU ld script: $output" 832249e108a1Smrg echo 'INPUT (' > $output 8323f05b35a2Smrg for obj in $save_libobjs 8324f05b35a2Smrg do 832567ab2ff2Smrg func_to_tool_file "$obj" 832667ab2ff2Smrg $ECHO "$func_to_tool_file_result" >> $output 8327f05b35a2Smrg done 832849e108a1Smrg echo ')' >> $output 832967ab2ff2Smrg func_append delfiles " $output" 833067ab2ff2Smrg func_to_tool_file "$output" 833167ab2ff2Smrg output=$func_to_tool_file_result 8332f05b35a2Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 8333f05b35a2Smrg output=${output_objdir}/${output_la}.lnk 8334f05b35a2Smrg func_verbose "creating linker input file list: $output" 8335f05b35a2Smrg : > $output 8336f05b35a2Smrg set x $save_libobjs 8337f05b35a2Smrg shift 8338f05b35a2Smrg firstobj= 8339f05b35a2Smrg if test "$compiler_needs_object" = yes; then 8340f05b35a2Smrg firstobj="$1 " 8341f05b35a2Smrg shift 8342f05b35a2Smrg fi 8343f05b35a2Smrg for obj 8344f05b35a2Smrg do 834567ab2ff2Smrg func_to_tool_file "$obj" 834667ab2ff2Smrg $ECHO "$func_to_tool_file_result" >> $output 8347f05b35a2Smrg done 834867ab2ff2Smrg func_append delfiles " $output" 834967ab2ff2Smrg func_to_tool_file "$output" 835067ab2ff2Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 8351f05b35a2Smrg else 8352f05b35a2Smrg if test -n "$save_libobjs"; then 8353f05b35a2Smrg func_verbose "creating reloadable object files..." 8354f05b35a2Smrg output=$output_objdir/$output_la-${k}.$objext 8355f05b35a2Smrg eval test_cmds=\"$reload_cmds\" 8356f05b35a2Smrg func_len " $test_cmds" 8357f05b35a2Smrg len0=$func_len_result 8358f05b35a2Smrg len=$len0 8359f05b35a2Smrg 8360f05b35a2Smrg # Loop over the list of objects to be linked. 8361f05b35a2Smrg for obj in $save_libobjs 8362f05b35a2Smrg do 8363f05b35a2Smrg func_len " $obj" 8364f05b35a2Smrg func_arith $len + $func_len_result 8365f05b35a2Smrg len=$func_arith_result 8366f05b35a2Smrg if test "X$objlist" = X || 8367f05b35a2Smrg test "$len" -lt "$max_cmd_len"; then 8368f05b35a2Smrg func_append objlist " $obj" 8369f05b35a2Smrg else 8370f05b35a2Smrg # The command $test_cmds is almost too long, add a 8371f05b35a2Smrg # command to the queue. 8372f05b35a2Smrg if test "$k" -eq 1 ; then 8373f05b35a2Smrg # The first file doesn't have a previous command to add. 837449e108a1Smrg reload_objs=$objlist 837549e108a1Smrg eval concat_cmds=\"$reload_cmds\" 8376f05b35a2Smrg else 8377f05b35a2Smrg # All subsequent reloadable object files will link in 8378f05b35a2Smrg # the last one created. 837949e108a1Smrg reload_objs="$objlist $last_robj" 838049e108a1Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 8381f05b35a2Smrg fi 8382f05b35a2Smrg last_robj=$output_objdir/$output_la-${k}.$objext 8383f05b35a2Smrg func_arith $k + 1 8384f05b35a2Smrg k=$func_arith_result 8385f05b35a2Smrg output=$output_objdir/$output_la-${k}.$objext 838649e108a1Smrg objlist=" $obj" 8387f05b35a2Smrg func_len " $last_robj" 8388f05b35a2Smrg func_arith $len0 + $func_len_result 8389f05b35a2Smrg len=$func_arith_result 8390f05b35a2Smrg fi 8391f05b35a2Smrg done 8392f05b35a2Smrg # Handle the remaining objects by creating one last 8393f05b35a2Smrg # reloadable object file. All subsequent reloadable object 8394f05b35a2Smrg # files will link in the last one created. 8395f05b35a2Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 839649e108a1Smrg reload_objs="$objlist $last_robj" 839749e108a1Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 8398f05b35a2Smrg if test -n "$last_robj"; then 8399f05b35a2Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 8400f05b35a2Smrg fi 840167ab2ff2Smrg func_append delfiles " $output" 8402e0963edeSmrg 8403f05b35a2Smrg else 8404f05b35a2Smrg output= 8405f05b35a2Smrg fi 8406f05b35a2Smrg 8407f05b35a2Smrg if ${skipped_export-false}; then 8408f05b35a2Smrg func_verbose "generating symbol list for \`$libname.la'" 8409f05b35a2Smrg export_symbols="$output_objdir/$libname.exp" 8410f05b35a2Smrg $opt_dry_run || $RM $export_symbols 8411f05b35a2Smrg libobjs=$output 8412f05b35a2Smrg # Append the command to create the export file. 8413f05b35a2Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8414f05b35a2Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 8415f05b35a2Smrg if test -n "$last_robj"; then 8416f05b35a2Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 8417f05b35a2Smrg fi 8418f05b35a2Smrg fi 8419e0963edeSmrg 8420f05b35a2Smrg test -n "$save_libobjs" && 8421f05b35a2Smrg func_verbose "creating a temporary reloadable object file: $output" 8422e0963edeSmrg 8423f05b35a2Smrg # Loop through the commands generated above and execute them. 8424f05b35a2Smrg save_ifs="$IFS"; IFS='~' 8425f05b35a2Smrg for cmd in $concat_cmds; do 8426f05b35a2Smrg IFS="$save_ifs" 8427f05b35a2Smrg $opt_silent || { 8428f05b35a2Smrg func_quote_for_expand "$cmd" 8429f05b35a2Smrg eval "func_echo $func_quote_for_expand_result" 8430f05b35a2Smrg } 8431f05b35a2Smrg $opt_dry_run || eval "$cmd" || { 8432f05b35a2Smrg lt_exit=$? 8433f05b35a2Smrg 8434f05b35a2Smrg # Restore the uninstalled library and exit 843567ab2ff2Smrg if test "$opt_mode" = relink; then 8436f05b35a2Smrg ( cd "$output_objdir" && \ 8437f05b35a2Smrg $RM "${realname}T" && \ 8438f05b35a2Smrg $MV "${realname}U" "$realname" ) 8439f05b35a2Smrg fi 8440e0963edeSmrg 8441f05b35a2Smrg exit $lt_exit 8442f05b35a2Smrg } 8443f05b35a2Smrg done 8444f05b35a2Smrg IFS="$save_ifs" 8445e0963edeSmrg 8446f05b35a2Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 8447f05b35a2Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8448f05b35a2Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8449e0963edeSmrg fi 8450e0963edeSmrg fi 8451e0963edeSmrg 8452f05b35a2Smrg if ${skipped_export-false}; then 8453f05b35a2Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8454f05b35a2Smrg tmp_export_symbols="$export_symbols" 8455f05b35a2Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 845649e108a1Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8457f05b35a2Smrg fi 8458e0963edeSmrg 8459f05b35a2Smrg if test -n "$orig_export_symbols"; then 8460f05b35a2Smrg # The given exports_symbols file has to be filtered, so filter it. 8461f05b35a2Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8462f05b35a2Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 8463f05b35a2Smrg # 's' commands which not all seds can handle. GNU sed should be fine 8464f05b35a2Smrg # though. Also, the filter scales superlinearly with the number of 8465f05b35a2Smrg # global variables. join(1) would be nice here, but unfortunately 8466f05b35a2Smrg # isn't a blessed tool. 8467f05b35a2Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 846867ab2ff2Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8469f05b35a2Smrg export_symbols=$output_objdir/$libname.def 8470f05b35a2Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8471f05b35a2Smrg fi 8472f05b35a2Smrg fi 8473e0963edeSmrg 8474f05b35a2Smrg libobjs=$output 8475f05b35a2Smrg # Restore the value of output. 8476f05b35a2Smrg output=$save_output 8477e0963edeSmrg 8478f05b35a2Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 8479f05b35a2Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8480f05b35a2Smrg test "X$libobjs" = "X " && libobjs= 8481f05b35a2Smrg fi 8482f05b35a2Smrg # Expand the library linking commands again to reset the 8483f05b35a2Smrg # value of $libobjs for piecewise linking. 8484f05b35a2Smrg 8485f05b35a2Smrg # Do each of the archive commands. 8486f05b35a2Smrg if test "$module" = yes && test -n "$module_cmds" ; then 8487f05b35a2Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8488f05b35a2Smrg cmds=$module_expsym_cmds 8489e0963edeSmrg else 8490f05b35a2Smrg cmds=$module_cmds 8491e0963edeSmrg fi 8492e0963edeSmrg else 8493f05b35a2Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8494f05b35a2Smrg cmds=$archive_expsym_cmds 8495f05b35a2Smrg else 8496f05b35a2Smrg cmds=$archive_cmds 8497f05b35a2Smrg fi 8498e0963edeSmrg fi 8499e0963edeSmrg fi 8500e0963edeSmrg 8501f05b35a2Smrg if test -n "$delfiles"; then 8502f05b35a2Smrg # Append the command to remove temporary files to $cmds. 8503f05b35a2Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 8504f05b35a2Smrg fi 8505e0963edeSmrg 8506f05b35a2Smrg # Add any objects from preloaded convenience libraries 8507f05b35a2Smrg if test -n "$dlprefiles"; then 8508f05b35a2Smrg gentop="$output_objdir/${outputname}x" 850967ab2ff2Smrg func_append generated " $gentop" 8510e0963edeSmrg 8511f05b35a2Smrg func_extract_archives $gentop $dlprefiles 851267ab2ff2Smrg func_append libobjs " $func_extract_archives_result" 8513f05b35a2Smrg test "X$libobjs" = "X " && libobjs= 8514e0963edeSmrg fi 8515e0963edeSmrg 8516f05b35a2Smrg save_ifs="$IFS"; IFS='~' 8517f05b35a2Smrg for cmd in $cmds; do 8518f05b35a2Smrg IFS="$save_ifs" 8519f05b35a2Smrg eval cmd=\"$cmd\" 8520f05b35a2Smrg $opt_silent || { 8521f05b35a2Smrg func_quote_for_expand "$cmd" 8522f05b35a2Smrg eval "func_echo $func_quote_for_expand_result" 8523f05b35a2Smrg } 8524f05b35a2Smrg $opt_dry_run || eval "$cmd" || { 8525f05b35a2Smrg lt_exit=$? 8526e0963edeSmrg 8527f05b35a2Smrg # Restore the uninstalled library and exit 852867ab2ff2Smrg if test "$opt_mode" = relink; then 8529f05b35a2Smrg ( cd "$output_objdir" && \ 8530f05b35a2Smrg $RM "${realname}T" && \ 8531f05b35a2Smrg $MV "${realname}U" "$realname" ) 8532e0963edeSmrg fi 8533e0963edeSmrg 8534f05b35a2Smrg exit $lt_exit 8535f05b35a2Smrg } 8536f05b35a2Smrg done 8537f05b35a2Smrg IFS="$save_ifs" 8538e0963edeSmrg 8539f05b35a2Smrg # Restore the uninstalled library and exit 854067ab2ff2Smrg if test "$opt_mode" = relink; then 8541f05b35a2Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 8542e0963edeSmrg 8543f05b35a2Smrg if test -n "$convenience"; then 8544f05b35a2Smrg if test -z "$whole_archive_flag_spec"; then 8545f05b35a2Smrg func_show_eval '${RM}r "$gentop"' 8546f05b35a2Smrg fi 8547f05b35a2Smrg fi 8548e0963edeSmrg 8549f05b35a2Smrg exit $EXIT_SUCCESS 8550f05b35a2Smrg fi 8551e0963edeSmrg 8552f05b35a2Smrg # Create links to the real library. 8553f05b35a2Smrg for linkname in $linknames; do 8554f05b35a2Smrg if test "$realname" != "$linkname"; then 8555f05b35a2Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 8556e0963edeSmrg fi 8557e0963edeSmrg done 8558e0963edeSmrg 8559f05b35a2Smrg # If -module or -export-dynamic was specified, set the dlname. 8560f05b35a2Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 8561f05b35a2Smrg # On all known operating systems, these are identical. 8562f05b35a2Smrg dlname="$soname" 8563f05b35a2Smrg fi 8564f05b35a2Smrg fi 8565e0963edeSmrg ;; 8566e0963edeSmrg 8567f05b35a2Smrg obj) 8568f05b35a2Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 8569f05b35a2Smrg func_warning "\`-dlopen' is ignored for objects" 8570f05b35a2Smrg fi 8571e0963edeSmrg 8572f05b35a2Smrg case " $deplibs" in 8573f05b35a2Smrg *\ -l* | *\ -L*) 8574f05b35a2Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 8575e0963edeSmrg esac 8576e0963edeSmrg 8577f05b35a2Smrg test -n "$rpath" && \ 8578f05b35a2Smrg func_warning "\`-rpath' is ignored for objects" 8579e0963edeSmrg 8580f05b35a2Smrg test -n "$xrpath" && \ 8581f05b35a2Smrg func_warning "\`-R' is ignored for objects" 8582e0963edeSmrg 8583f05b35a2Smrg test -n "$vinfo" && \ 8584f05b35a2Smrg func_warning "\`-version-info' is ignored for objects" 8585f05b35a2Smrg 8586f05b35a2Smrg test -n "$release" && \ 8587f05b35a2Smrg func_warning "\`-release' is ignored for objects" 8588f05b35a2Smrg 8589f05b35a2Smrg case $output in 8590f05b35a2Smrg *.lo) 8591f05b35a2Smrg test -n "$objs$old_deplibs" && \ 8592f05b35a2Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 8593f05b35a2Smrg 8594f05b35a2Smrg libobj=$output 8595f05b35a2Smrg func_lo2o "$libobj" 8596f05b35a2Smrg obj=$func_lo2o_result 8597e0963edeSmrg ;; 8598e0963edeSmrg *) 8599f05b35a2Smrg libobj= 8600f05b35a2Smrg obj="$output" 8601e0963edeSmrg ;; 8602e0963edeSmrg esac 8603e0963edeSmrg 8604f05b35a2Smrg # Delete the old objects. 8605f05b35a2Smrg $opt_dry_run || $RM $obj $libobj 8606e0963edeSmrg 8607f05b35a2Smrg # Objects from convenience libraries. This assumes 8608f05b35a2Smrg # single-version convenience libraries. Whenever we create 8609f05b35a2Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 8610f05b35a2Smrg # the extraction. 8611f05b35a2Smrg reload_conv_objs= 8612f05b35a2Smrg gentop= 8613f05b35a2Smrg # reload_cmds runs $LD directly, so let us get rid of 8614f05b35a2Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 8615f05b35a2Smrg # turning comma into space.. 8616f05b35a2Smrg wl= 8617e0963edeSmrg 8618f05b35a2Smrg if test -n "$convenience"; then 8619f05b35a2Smrg if test -n "$whole_archive_flag_spec"; then 8620f05b35a2Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 862149e108a1Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 8622f05b35a2Smrg else 8623f05b35a2Smrg gentop="$output_objdir/${obj}x" 862467ab2ff2Smrg func_append generated " $gentop" 8625e0963edeSmrg 8626f05b35a2Smrg func_extract_archives $gentop $convenience 8627f05b35a2Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 8628f05b35a2Smrg fi 8629e0963edeSmrg fi 8630e0963edeSmrg 863167ab2ff2Smrg # If we're not building shared, we need to use non_pic_objs 863267ab2ff2Smrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 863367ab2ff2Smrg 8634f05b35a2Smrg # Create the old-style object. 863549e108a1Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 8636e0963edeSmrg 8637f05b35a2Smrg output="$obj" 8638f05b35a2Smrg func_execute_cmds "$reload_cmds" 'exit $?' 8639e0963edeSmrg 8640f05b35a2Smrg # Exit if we aren't doing a library object file. 8641f05b35a2Smrg if test -z "$libobj"; then 8642f05b35a2Smrg if test -n "$gentop"; then 8643f05b35a2Smrg func_show_eval '${RM}r "$gentop"' 8644f05b35a2Smrg fi 8645f05b35a2Smrg 8646f05b35a2Smrg exit $EXIT_SUCCESS 8647e0963edeSmrg fi 8648f05b35a2Smrg 8649f05b35a2Smrg if test "$build_libtool_libs" != yes; then 8650f05b35a2Smrg if test -n "$gentop"; then 8651f05b35a2Smrg func_show_eval '${RM}r "$gentop"' 8652f05b35a2Smrg fi 8653f05b35a2Smrg 8654f05b35a2Smrg # Create an invalid libtool object if no PIC, so that we don't 8655f05b35a2Smrg # accidentally link it into a program. 8656f05b35a2Smrg # $show "echo timestamp > $libobj" 8657f05b35a2Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 8658f05b35a2Smrg exit $EXIT_SUCCESS 8659f05b35a2Smrg fi 8660f05b35a2Smrg 8661f05b35a2Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 8662f05b35a2Smrg # Only do commands if we really have different PIC objects. 8663f05b35a2Smrg reload_objs="$libobjs $reload_conv_objs" 8664f05b35a2Smrg output="$libobj" 8665f05b35a2Smrg func_execute_cmds "$reload_cmds" 'exit $?' 8666f05b35a2Smrg fi 8667f05b35a2Smrg 8668f05b35a2Smrg if test -n "$gentop"; then 8669f05b35a2Smrg func_show_eval '${RM}r "$gentop"' 8670f05b35a2Smrg fi 8671f05b35a2Smrg 8672f05b35a2Smrg exit $EXIT_SUCCESS 8673e0963edeSmrg ;; 8674e0963edeSmrg 8675f05b35a2Smrg prog) 8676f05b35a2Smrg case $host in 8677f05b35a2Smrg *cygwin*) func_stripname '' '.exe' "$output" 8678f05b35a2Smrg output=$func_stripname_result.exe;; 8679f05b35a2Smrg esac 8680f05b35a2Smrg test -n "$vinfo" && \ 8681f05b35a2Smrg func_warning "\`-version-info' is ignored for programs" 8682e0963edeSmrg 8683f05b35a2Smrg test -n "$release" && \ 8684f05b35a2Smrg func_warning "\`-release' is ignored for programs" 8685e0963edeSmrg 8686f05b35a2Smrg test "$preload" = yes \ 8687f05b35a2Smrg && test "$dlopen_support" = unknown \ 8688f05b35a2Smrg && test "$dlopen_self" = unknown \ 8689f05b35a2Smrg && test "$dlopen_self_static" = unknown && \ 8690f05b35a2Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 8691f05b35a2Smrg 8692f05b35a2Smrg case $host in 8693f05b35a2Smrg *-*-rhapsody* | *-*-darwin1.[012]) 8694f05b35a2Smrg # On Rhapsody replace the C library is the System framework 869549e108a1Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 869649e108a1Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 8697e0963edeSmrg ;; 8698f05b35a2Smrg esac 8699e0963edeSmrg 8700f05b35a2Smrg case $host in 8701f05b35a2Smrg *-*-darwin*) 8702f05b35a2Smrg # Don't allow lazy linking, it breaks C++ global constructors 8703f05b35a2Smrg # But is supposedly fixed on 10.4 or later (yay!). 8704f05b35a2Smrg if test "$tagname" = CXX ; then 8705f05b35a2Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 8706f05b35a2Smrg 10.[0123]) 870767ab2ff2Smrg func_append compile_command " ${wl}-bind_at_load" 870867ab2ff2Smrg func_append finalize_command " ${wl}-bind_at_load" 8709f05b35a2Smrg ;; 8710f05b35a2Smrg esac 8711e0963edeSmrg fi 8712f05b35a2Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 871349e108a1Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 871449e108a1Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8715f05b35a2Smrg ;; 8716f05b35a2Smrg esac 8717e0963edeSmrg 8718e0963edeSmrg 8719f05b35a2Smrg # move library search paths that coincide with paths to not yet 8720f05b35a2Smrg # installed libraries to the beginning of the library search list 8721f05b35a2Smrg new_libs= 8722f05b35a2Smrg for path in $notinst_path; do 8723f05b35a2Smrg case " $new_libs " in 8724f05b35a2Smrg *" -L$path/$objdir "*) ;; 8725f05b35a2Smrg *) 8726f05b35a2Smrg case " $compile_deplibs " in 8727f05b35a2Smrg *" -L$path/$objdir "*) 872867ab2ff2Smrg func_append new_libs " -L$path/$objdir" ;; 8729e0963edeSmrg esac 8730f05b35a2Smrg ;; 8731f05b35a2Smrg esac 8732f05b35a2Smrg done 8733f05b35a2Smrg for deplib in $compile_deplibs; do 8734f05b35a2Smrg case $deplib in 8735f05b35a2Smrg -L*) 8736f05b35a2Smrg case " $new_libs " in 8737f05b35a2Smrg *" $deplib "*) ;; 873867ab2ff2Smrg *) func_append new_libs " $deplib" ;; 8739e0963edeSmrg esac 8740f05b35a2Smrg ;; 874167ab2ff2Smrg *) func_append new_libs " $deplib" ;; 8742f05b35a2Smrg esac 8743f05b35a2Smrg done 8744f05b35a2Smrg compile_deplibs="$new_libs" 8745e0963edeSmrg 8746e0963edeSmrg 874767ab2ff2Smrg func_append compile_command " $compile_deplibs" 874867ab2ff2Smrg func_append finalize_command " $finalize_deplibs" 8749e0963edeSmrg 8750f05b35a2Smrg if test -n "$rpath$xrpath"; then 8751f05b35a2Smrg # If the user specified any rpath flags, then add them. 8752f05b35a2Smrg for libdir in $rpath $xrpath; do 8753f05b35a2Smrg # This is the magic to use -rpath. 8754f05b35a2Smrg case "$finalize_rpath " in 8755f05b35a2Smrg *" $libdir "*) ;; 875667ab2ff2Smrg *) func_append finalize_rpath " $libdir" ;; 8757f05b35a2Smrg esac 8758f05b35a2Smrg done 8759f05b35a2Smrg fi 8760e0963edeSmrg 8761f05b35a2Smrg # Now hardcode the library paths 8762f05b35a2Smrg rpath= 8763f05b35a2Smrg hardcode_libdirs= 8764f05b35a2Smrg for libdir in $compile_rpath $finalize_rpath; do 8765f05b35a2Smrg if test -n "$hardcode_libdir_flag_spec"; then 8766f05b35a2Smrg if test -n "$hardcode_libdir_separator"; then 8767f05b35a2Smrg if test -z "$hardcode_libdirs"; then 8768f05b35a2Smrg hardcode_libdirs="$libdir" 8769f05b35a2Smrg else 8770f05b35a2Smrg # Just accumulate the unique libdirs. 8771f05b35a2Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8772f05b35a2Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8773f05b35a2Smrg ;; 8774f05b35a2Smrg *) 877567ab2ff2Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8776f05b35a2Smrg ;; 8777f05b35a2Smrg esac 8778f05b35a2Smrg fi 8779e0963edeSmrg else 8780f05b35a2Smrg eval flag=\"$hardcode_libdir_flag_spec\" 878167ab2ff2Smrg func_append rpath " $flag" 8782e0963edeSmrg fi 8783f05b35a2Smrg elif test -n "$runpath_var"; then 8784f05b35a2Smrg case "$perm_rpath " in 8785f05b35a2Smrg *" $libdir "*) ;; 878667ab2ff2Smrg *) func_append perm_rpath " $libdir" ;; 8787f05b35a2Smrg esac 8788f05b35a2Smrg fi 8789f05b35a2Smrg case $host in 8790f05b35a2Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 8791f05b35a2Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 8792f05b35a2Smrg case :$dllsearchpath: in 8793f05b35a2Smrg *":$libdir:"*) ;; 8794f05b35a2Smrg ::) dllsearchpath=$libdir;; 879567ab2ff2Smrg *) func_append dllsearchpath ":$libdir";; 8796f05b35a2Smrg esac 8797f05b35a2Smrg case :$dllsearchpath: in 8798f05b35a2Smrg *":$testbindir:"*) ;; 8799f05b35a2Smrg ::) dllsearchpath=$testbindir;; 880067ab2ff2Smrg *) func_append dllsearchpath ":$testbindir";; 8801f05b35a2Smrg esac 8802f05b35a2Smrg ;; 8803f05b35a2Smrg esac 8804f05b35a2Smrg done 8805f05b35a2Smrg # Substitute the hardcoded libdirs into the rpath. 8806f05b35a2Smrg if test -n "$hardcode_libdir_separator" && 8807f05b35a2Smrg test -n "$hardcode_libdirs"; then 8808f05b35a2Smrg libdir="$hardcode_libdirs" 8809f05b35a2Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 8810f05b35a2Smrg fi 8811f05b35a2Smrg compile_rpath="$rpath" 8812e0963edeSmrg 8813f05b35a2Smrg rpath= 8814f05b35a2Smrg hardcode_libdirs= 8815f05b35a2Smrg for libdir in $finalize_rpath; do 8816f05b35a2Smrg if test -n "$hardcode_libdir_flag_spec"; then 8817f05b35a2Smrg if test -n "$hardcode_libdir_separator"; then 8818f05b35a2Smrg if test -z "$hardcode_libdirs"; then 8819f05b35a2Smrg hardcode_libdirs="$libdir" 8820f05b35a2Smrg else 8821f05b35a2Smrg # Just accumulate the unique libdirs. 8822f05b35a2Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8823f05b35a2Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8824f05b35a2Smrg ;; 8825f05b35a2Smrg *) 882667ab2ff2Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8827f05b35a2Smrg ;; 8828f05b35a2Smrg esac 8829f05b35a2Smrg fi 8830e0963edeSmrg else 8831f05b35a2Smrg eval flag=\"$hardcode_libdir_flag_spec\" 883267ab2ff2Smrg func_append rpath " $flag" 8833e0963edeSmrg fi 8834f05b35a2Smrg elif test -n "$runpath_var"; then 8835f05b35a2Smrg case "$finalize_perm_rpath " in 8836f05b35a2Smrg *" $libdir "*) ;; 883767ab2ff2Smrg *) func_append finalize_perm_rpath " $libdir" ;; 8838f05b35a2Smrg esac 8839e0963edeSmrg fi 8840f05b35a2Smrg done 8841f05b35a2Smrg # Substitute the hardcoded libdirs into the rpath. 8842f05b35a2Smrg if test -n "$hardcode_libdir_separator" && 8843f05b35a2Smrg test -n "$hardcode_libdirs"; then 8844f05b35a2Smrg libdir="$hardcode_libdirs" 8845f05b35a2Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 8846f05b35a2Smrg fi 8847f05b35a2Smrg finalize_rpath="$rpath" 8848e0963edeSmrg 8849f05b35a2Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 8850f05b35a2Smrg # Transform all the library objects into standard objects. 885149e108a1Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 885249e108a1Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8853f05b35a2Smrg fi 8854e0963edeSmrg 8855f05b35a2Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8856e0963edeSmrg 8857f05b35a2Smrg # template prelinking step 8858f05b35a2Smrg if test -n "$prelink_cmds"; then 8859f05b35a2Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 8860f05b35a2Smrg fi 8861e0963edeSmrg 8862f05b35a2Smrg wrappers_required=yes 8863f05b35a2Smrg case $host in 886449e108a1Smrg *cegcc* | *mingw32ce*) 886549e108a1Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 886649e108a1Smrg wrappers_required=no 886749e108a1Smrg ;; 8868f05b35a2Smrg *cygwin* | *mingw* ) 8869f05b35a2Smrg if test "$build_libtool_libs" != yes; then 8870f05b35a2Smrg wrappers_required=no 8871f05b35a2Smrg fi 8872f05b35a2Smrg ;; 8873f05b35a2Smrg *) 8874f05b35a2Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 8875f05b35a2Smrg wrappers_required=no 8876f05b35a2Smrg fi 8877f05b35a2Smrg ;; 8878f05b35a2Smrg esac 8879f05b35a2Smrg if test "$wrappers_required" = no; then 8880f05b35a2Smrg # Replace the output file specification. 888149e108a1Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8882f05b35a2Smrg link_command="$compile_command$compile_rpath" 8883e0963edeSmrg 8884f05b35a2Smrg # We have no uninstalled library dependencies, so finalize right now. 8885f05b35a2Smrg exit_status=0 8886f05b35a2Smrg func_show_eval "$link_command" 'exit_status=$?' 8887e0963edeSmrg 888867ab2ff2Smrg if test -n "$postlink_cmds"; then 888967ab2ff2Smrg func_to_tool_file "$output" 889067ab2ff2Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 889167ab2ff2Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 889267ab2ff2Smrg fi 889367ab2ff2Smrg 8894f05b35a2Smrg # Delete the generated files. 8895f05b35a2Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 8896f05b35a2Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 8897e0963edeSmrg fi 8898e0963edeSmrg 8899f05b35a2Smrg exit $exit_status 8900f05b35a2Smrg fi 8901e0963edeSmrg 8902f05b35a2Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 8903f05b35a2Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 8904f05b35a2Smrg fi 8905f05b35a2Smrg if test -n "$finalize_shlibpath"; then 8906f05b35a2Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 8907f05b35a2Smrg fi 8908e0963edeSmrg 8909f05b35a2Smrg compile_var= 8910f05b35a2Smrg finalize_var= 8911f05b35a2Smrg if test -n "$runpath_var"; then 8912f05b35a2Smrg if test -n "$perm_rpath"; then 8913f05b35a2Smrg # We should set the runpath_var. 8914f05b35a2Smrg rpath= 8915f05b35a2Smrg for dir in $perm_rpath; do 891667ab2ff2Smrg func_append rpath "$dir:" 8917f05b35a2Smrg done 8918f05b35a2Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8919e0963edeSmrg fi 8920f05b35a2Smrg if test -n "$finalize_perm_rpath"; then 8921f05b35a2Smrg # We should set the runpath_var. 8922f05b35a2Smrg rpath= 8923f05b35a2Smrg for dir in $finalize_perm_rpath; do 892467ab2ff2Smrg func_append rpath "$dir:" 8925f05b35a2Smrg done 8926f05b35a2Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 8927e0963edeSmrg fi 8928f05b35a2Smrg fi 8929e0963edeSmrg 8930f05b35a2Smrg if test "$no_install" = yes; then 8931f05b35a2Smrg # We don't need to create a wrapper script. 8932f05b35a2Smrg link_command="$compile_var$compile_command$compile_rpath" 8933f05b35a2Smrg # Replace the output file specification. 893449e108a1Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8935f05b35a2Smrg # Delete the old output file. 8936f05b35a2Smrg $opt_dry_run || $RM $output 8937f05b35a2Smrg # Link the executable and exit 8938f05b35a2Smrg func_show_eval "$link_command" 'exit $?' 893967ab2ff2Smrg 894067ab2ff2Smrg if test -n "$postlink_cmds"; then 894167ab2ff2Smrg func_to_tool_file "$output" 894267ab2ff2Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 894367ab2ff2Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 894467ab2ff2Smrg fi 894567ab2ff2Smrg 8946e0963edeSmrg exit $EXIT_SUCCESS 8947f05b35a2Smrg fi 8948e0963edeSmrg 8949f05b35a2Smrg if test "$hardcode_action" = relink; then 8950f05b35a2Smrg # Fast installation is not supported 8951f05b35a2Smrg link_command="$compile_var$compile_command$compile_rpath" 8952f05b35a2Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8953f05b35a2Smrg 8954f05b35a2Smrg func_warning "this platform does not like uninstalled shared libraries" 8955f05b35a2Smrg func_warning "\`$output' will be relinked during installation" 8956f05b35a2Smrg else 8957f05b35a2Smrg if test "$fast_install" != no; then 8958f05b35a2Smrg link_command="$finalize_var$compile_command$finalize_rpath" 8959f05b35a2Smrg if test "$fast_install" = yes; then 896049e108a1Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 8961f05b35a2Smrg else 8962f05b35a2Smrg # fast_install is set to needless 8963f05b35a2Smrg relink_command= 8964f05b35a2Smrg fi 8965e0963edeSmrg else 8966f05b35a2Smrg link_command="$compile_var$compile_command$compile_rpath" 8967f05b35a2Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8968e0963edeSmrg fi 8969f05b35a2Smrg fi 8970e0963edeSmrg 8971f05b35a2Smrg # Replace the output file specification. 897249e108a1Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 8973e0963edeSmrg 8974f05b35a2Smrg # Delete the old output files. 8975f05b35a2Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 8976e0963edeSmrg 8977f05b35a2Smrg func_show_eval "$link_command" 'exit $?' 8978e0963edeSmrg 897967ab2ff2Smrg if test -n "$postlink_cmds"; then 898067ab2ff2Smrg func_to_tool_file "$output_objdir/$outputname" 898167ab2ff2Smrg 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'` 898267ab2ff2Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 898367ab2ff2Smrg fi 898467ab2ff2Smrg 8985f05b35a2Smrg # Now create the wrapper script. 8986f05b35a2Smrg func_verbose "creating $output" 8987e0963edeSmrg 8988f05b35a2Smrg # Quote the relink command for shipping. 8989f05b35a2Smrg if test -n "$relink_command"; then 8990f05b35a2Smrg # Preserve any variables that may affect compiler behavior 8991f05b35a2Smrg for var in $variables_saved_for_relink; do 8992f05b35a2Smrg if eval test -z \"\${$var+set}\"; then 8993f05b35a2Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 8994f05b35a2Smrg elif eval var_value=\$$var; test -z "$var_value"; then 8995f05b35a2Smrg relink_command="$var=; export $var; $relink_command" 8996e0963edeSmrg else 8997f05b35a2Smrg func_quote_for_eval "$var_value" 8998f05b35a2Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 8999e0963edeSmrg fi 9000f05b35a2Smrg done 9001f05b35a2Smrg relink_command="(cd `pwd`; $relink_command)" 900249e108a1Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9003f05b35a2Smrg fi 9004f05b35a2Smrg 9005f05b35a2Smrg # Only actually do things if not in dry run mode. 9006f05b35a2Smrg $opt_dry_run || { 9007f05b35a2Smrg # win32 will think the script is a binary if it has 9008f05b35a2Smrg # a .exe suffix, so we strip it off here. 9009f05b35a2Smrg case $output in 9010f05b35a2Smrg *.exe) func_stripname '' '.exe' "$output" 9011f05b35a2Smrg output=$func_stripname_result ;; 9012f05b35a2Smrg esac 9013f05b35a2Smrg # test for cygwin because mv fails w/o .exe extensions 9014f05b35a2Smrg case $host in 9015f05b35a2Smrg *cygwin*) 9016f05b35a2Smrg exeext=.exe 9017f05b35a2Smrg func_stripname '' '.exe' "$outputname" 9018f05b35a2Smrg outputname=$func_stripname_result ;; 9019f05b35a2Smrg *) exeext= ;; 9020e0963edeSmrg esac 9021f05b35a2Smrg case $host in 9022f05b35a2Smrg *cygwin* | *mingw* ) 9023f05b35a2Smrg func_dirname_and_basename "$output" "" "." 9024f05b35a2Smrg output_name=$func_basename_result 9025f05b35a2Smrg output_path=$func_dirname_result 9026f05b35a2Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 9027f05b35a2Smrg cwrapper="$output_path/$output_name.exe" 9028f05b35a2Smrg $RM $cwrappersource $cwrapper 9029f05b35a2Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 9030f05b35a2Smrg 9031f05b35a2Smrg func_emit_cwrapperexe_src > $cwrappersource 9032f05b35a2Smrg 9033f05b35a2Smrg # The wrapper executable is built using the $host compiler, 9034f05b35a2Smrg # because it contains $host paths and files. If cross- 9035f05b35a2Smrg # compiling, it, like the target executable, must be 9036f05b35a2Smrg # executed on the $host or under an emulation environment. 9037f05b35a2Smrg $opt_dry_run || { 9038f05b35a2Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 9039f05b35a2Smrg $STRIP $cwrapper 9040f05b35a2Smrg } 9041e0963edeSmrg 9042f05b35a2Smrg # Now, create the wrapper script for func_source use: 9043f05b35a2Smrg func_ltwrapper_scriptname $cwrapper 9044f05b35a2Smrg $RM $func_ltwrapper_scriptname_result 9045f05b35a2Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 9046f05b35a2Smrg $opt_dry_run || { 9047f05b35a2Smrg # note: this script will not be executed, so do not chmod. 9048f05b35a2Smrg if test "x$build" = "x$host" ; then 9049f05b35a2Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 9050f05b35a2Smrg else 9051f05b35a2Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 9052f05b35a2Smrg fi 9053f05b35a2Smrg } 9054f05b35a2Smrg ;; 9055f05b35a2Smrg * ) 9056f05b35a2Smrg $RM $output 9057f05b35a2Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 9058e0963edeSmrg 9059f05b35a2Smrg func_emit_wrapper no > $output 9060f05b35a2Smrg chmod +x $output 9061f05b35a2Smrg ;; 9062f05b35a2Smrg esac 9063f05b35a2Smrg } 9064f05b35a2Smrg exit $EXIT_SUCCESS 9065f05b35a2Smrg ;; 9066f05b35a2Smrg esac 9067e0963edeSmrg 9068f05b35a2Smrg # See if we need to build an old-fashioned archive. 9069f05b35a2Smrg for oldlib in $oldlibs; do 9070e0963edeSmrg 9071f05b35a2Smrg if test "$build_libtool_libs" = convenience; then 9072f05b35a2Smrg oldobjs="$libobjs_save $symfileobj" 9073f05b35a2Smrg addlibs="$convenience" 9074f05b35a2Smrg build_libtool_libs=no 9075f05b35a2Smrg else 9076f05b35a2Smrg if test "$build_libtool_libs" = module; then 9077f05b35a2Smrg oldobjs="$libobjs_save" 9078f05b35a2Smrg build_libtool_libs=no 9079f05b35a2Smrg else 9080f05b35a2Smrg oldobjs="$old_deplibs $non_pic_objects" 9081f05b35a2Smrg if test "$preload" = yes && test -f "$symfileobj"; then 908267ab2ff2Smrg func_append oldobjs " $symfileobj" 9083f05b35a2Smrg fi 9084f05b35a2Smrg fi 9085f05b35a2Smrg addlibs="$old_convenience" 9086e0963edeSmrg fi 9087e0963edeSmrg 9088f05b35a2Smrg if test -n "$addlibs"; then 9089f05b35a2Smrg gentop="$output_objdir/${outputname}x" 909067ab2ff2Smrg func_append generated " $gentop" 9091e0963edeSmrg 9092f05b35a2Smrg func_extract_archives $gentop $addlibs 909367ab2ff2Smrg func_append oldobjs " $func_extract_archives_result" 9094f05b35a2Smrg fi 9095e0963edeSmrg 9096f05b35a2Smrg # Do each command in the archive commands. 9097f05b35a2Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 9098f05b35a2Smrg cmds=$old_archive_from_new_cmds 9099f05b35a2Smrg else 9100e0963edeSmrg 9101f05b35a2Smrg # Add any objects from preloaded convenience libraries 9102f05b35a2Smrg if test -n "$dlprefiles"; then 9103f05b35a2Smrg gentop="$output_objdir/${outputname}x" 910467ab2ff2Smrg func_append generated " $gentop" 9105e0963edeSmrg 9106f05b35a2Smrg func_extract_archives $gentop $dlprefiles 910767ab2ff2Smrg func_append oldobjs " $func_extract_archives_result" 9108f05b35a2Smrg fi 9109e0963edeSmrg 9110f05b35a2Smrg # POSIX demands no paths to be encoded in archives. We have 9111f05b35a2Smrg # to avoid creating archives with duplicate basenames if we 9112f05b35a2Smrg # might have to extract them afterwards, e.g., when creating a 9113f05b35a2Smrg # static archive out of a convenience library, or when linking 9114f05b35a2Smrg # the entirety of a libtool archive into another (currently 9115f05b35a2Smrg # not supported by libtool). 9116f05b35a2Smrg if (for obj in $oldobjs 9117f05b35a2Smrg do 9118f05b35a2Smrg func_basename "$obj" 9119f05b35a2Smrg $ECHO "$func_basename_result" 9120f05b35a2Smrg done | sort | sort -uc >/dev/null 2>&1); then 9121f05b35a2Smrg : 9122f05b35a2Smrg else 912349e108a1Smrg echo "copying selected object files to avoid basename conflicts..." 9124f05b35a2Smrg gentop="$output_objdir/${outputname}x" 912567ab2ff2Smrg func_append generated " $gentop" 9126f05b35a2Smrg func_mkdir_p "$gentop" 9127f05b35a2Smrg save_oldobjs=$oldobjs 9128f05b35a2Smrg oldobjs= 9129f05b35a2Smrg counter=1 9130f05b35a2Smrg for obj in $save_oldobjs 9131f05b35a2Smrg do 9132f05b35a2Smrg func_basename "$obj" 9133f05b35a2Smrg objbase="$func_basename_result" 9134f05b35a2Smrg case " $oldobjs " in 9135f05b35a2Smrg " ") oldobjs=$obj ;; 9136f05b35a2Smrg *[\ /]"$objbase "*) 9137f05b35a2Smrg while :; do 9138f05b35a2Smrg # Make sure we don't pick an alternate name that also 9139f05b35a2Smrg # overlaps. 9140f05b35a2Smrg newobj=lt$counter-$objbase 9141f05b35a2Smrg func_arith $counter + 1 9142f05b35a2Smrg counter=$func_arith_result 9143f05b35a2Smrg case " $oldobjs " in 9144f05b35a2Smrg *[\ /]"$newobj "*) ;; 9145f05b35a2Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 9146f05b35a2Smrg esac 9147f05b35a2Smrg done 9148f05b35a2Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 914967ab2ff2Smrg func_append oldobjs " $gentop/$newobj" 9150f05b35a2Smrg ;; 915167ab2ff2Smrg *) func_append oldobjs " $obj" ;; 9152f05b35a2Smrg esac 9153e0963edeSmrg done 9154e0963edeSmrg fi 9155f05b35a2Smrg eval cmds=\"$old_archive_cmds\" 9156e0963edeSmrg 9157f05b35a2Smrg func_len " $cmds" 9158f05b35a2Smrg len=$func_len_result 9159f05b35a2Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9160f05b35a2Smrg cmds=$old_archive_cmds 916167ab2ff2Smrg elif test -n "$archiver_list_spec"; then 916267ab2ff2Smrg func_verbose "using command file archive linking..." 916367ab2ff2Smrg for obj in $oldobjs 916467ab2ff2Smrg do 916567ab2ff2Smrg func_to_tool_file "$obj" 916667ab2ff2Smrg $ECHO "$func_to_tool_file_result" 916767ab2ff2Smrg done > $output_objdir/$libname.libcmd 916867ab2ff2Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 916967ab2ff2Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 917067ab2ff2Smrg cmds=$old_archive_cmds 9171f05b35a2Smrg else 9172f05b35a2Smrg # the command line is too long to link in one step, link in parts 9173f05b35a2Smrg func_verbose "using piecewise archive linking..." 9174f05b35a2Smrg save_RANLIB=$RANLIB 9175f05b35a2Smrg RANLIB=: 9176f05b35a2Smrg objlist= 9177f05b35a2Smrg concat_cmds= 9178f05b35a2Smrg save_oldobjs=$oldobjs 9179f05b35a2Smrg oldobjs= 9180f05b35a2Smrg # Is there a better way of finding the last object in the list? 9181f05b35a2Smrg for obj in $save_oldobjs 9182f05b35a2Smrg do 9183f05b35a2Smrg last_oldobj=$obj 9184f05b35a2Smrg done 9185f05b35a2Smrg eval test_cmds=\"$old_archive_cmds\" 9186f05b35a2Smrg func_len " $test_cmds" 9187f05b35a2Smrg len0=$func_len_result 9188f05b35a2Smrg len=$len0 9189f05b35a2Smrg for obj in $save_oldobjs 9190f05b35a2Smrg do 9191f05b35a2Smrg func_len " $obj" 9192f05b35a2Smrg func_arith $len + $func_len_result 9193f05b35a2Smrg len=$func_arith_result 9194f05b35a2Smrg func_append objlist " $obj" 9195f05b35a2Smrg if test "$len" -lt "$max_cmd_len"; then 9196f05b35a2Smrg : 9197f05b35a2Smrg else 9198f05b35a2Smrg # the above command should be used before it gets too long 9199f05b35a2Smrg oldobjs=$objlist 9200f05b35a2Smrg if test "$obj" = "$last_oldobj" ; then 9201f05b35a2Smrg RANLIB=$save_RANLIB 9202f05b35a2Smrg fi 9203f05b35a2Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9204f05b35a2Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 9205f05b35a2Smrg objlist= 9206f05b35a2Smrg len=$len0 9207f05b35a2Smrg fi 9208f05b35a2Smrg done 9209f05b35a2Smrg RANLIB=$save_RANLIB 9210f05b35a2Smrg oldobjs=$objlist 9211f05b35a2Smrg if test "X$oldobjs" = "X" ; then 9212f05b35a2Smrg eval cmds=\"\$concat_cmds\" 9213f05b35a2Smrg else 9214f05b35a2Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 9215f05b35a2Smrg fi 9216f05b35a2Smrg fi 9217f05b35a2Smrg fi 9218f05b35a2Smrg func_execute_cmds "$cmds" 'exit $?' 9219e0963edeSmrg done 9220e0963edeSmrg 9221f05b35a2Smrg test -n "$generated" && \ 9222f05b35a2Smrg func_show_eval "${RM}r$generated" 9223e0963edeSmrg 9224f05b35a2Smrg # Now create the libtool archive. 9225f05b35a2Smrg case $output in 9226f05b35a2Smrg *.la) 9227f05b35a2Smrg old_library= 9228f05b35a2Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 9229f05b35a2Smrg func_verbose "creating $output" 9230e0963edeSmrg 9231f05b35a2Smrg # Preserve any variables that may affect compiler behavior 9232f05b35a2Smrg for var in $variables_saved_for_relink; do 9233f05b35a2Smrg if eval test -z \"\${$var+set}\"; then 9234f05b35a2Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9235f05b35a2Smrg elif eval var_value=\$$var; test -z "$var_value"; then 9236f05b35a2Smrg relink_command="$var=; export $var; $relink_command" 9237e0963edeSmrg else 9238f05b35a2Smrg func_quote_for_eval "$var_value" 9239f05b35a2Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9240e0963edeSmrg fi 9241f05b35a2Smrg done 9242f05b35a2Smrg # Quote the link command for shipping. 9243f05b35a2Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 924449e108a1Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9245f05b35a2Smrg if test "$hardcode_automatic" = yes ; then 9246f05b35a2Smrg relink_command= 9247f05b35a2Smrg fi 9248e0963edeSmrg 9249f05b35a2Smrg # Only create the output if not a dry run. 9250f05b35a2Smrg $opt_dry_run || { 9251f05b35a2Smrg for installed in no yes; do 9252f05b35a2Smrg if test "$installed" = yes; then 9253f05b35a2Smrg if test -z "$install_libdir"; then 9254f05b35a2Smrg break 9255f05b35a2Smrg fi 9256f05b35a2Smrg output="$output_objdir/$outputname"i 9257f05b35a2Smrg # Replace all uninstalled libtool libraries with the installed ones 9258f05b35a2Smrg newdependency_libs= 9259f05b35a2Smrg for deplib in $dependency_libs; do 9260f05b35a2Smrg case $deplib in 9261f05b35a2Smrg *.la) 9262f05b35a2Smrg func_basename "$deplib" 9263f05b35a2Smrg name="$func_basename_result" 9264f05b35a2Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 9265f05b35a2Smrg test -z "$libdir" && \ 9266f05b35a2Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 926767ab2ff2Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 926867ab2ff2Smrg ;; 926967ab2ff2Smrg -L*) 927067ab2ff2Smrg func_stripname -L '' "$deplib" 927167ab2ff2Smrg func_replace_sysroot "$func_stripname_result" 927267ab2ff2Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 927367ab2ff2Smrg ;; 927467ab2ff2Smrg -R*) 927567ab2ff2Smrg func_stripname -R '' "$deplib" 927667ab2ff2Smrg func_replace_sysroot "$func_stripname_result" 927767ab2ff2Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 9278f05b35a2Smrg ;; 927967ab2ff2Smrg *) func_append newdependency_libs " $deplib" ;; 9280f05b35a2Smrg esac 9281f05b35a2Smrg done 9282f05b35a2Smrg dependency_libs="$newdependency_libs" 9283f05b35a2Smrg newdlfiles= 9284f05b35a2Smrg 9285f05b35a2Smrg for lib in $dlfiles; do 9286f05b35a2Smrg case $lib in 9287f05b35a2Smrg *.la) 9288f05b35a2Smrg func_basename "$lib" 9289f05b35a2Smrg name="$func_basename_result" 9290f05b35a2Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9291f05b35a2Smrg test -z "$libdir" && \ 9292f05b35a2Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 929367ab2ff2Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 9294f05b35a2Smrg ;; 929567ab2ff2Smrg *) func_append newdlfiles " $lib" ;; 9296f05b35a2Smrg esac 9297f05b35a2Smrg done 9298f05b35a2Smrg dlfiles="$newdlfiles" 9299f05b35a2Smrg newdlprefiles= 9300f05b35a2Smrg for lib in $dlprefiles; do 9301f05b35a2Smrg case $lib in 9302f05b35a2Smrg *.la) 9303f05b35a2Smrg # Only pass preopened files to the pseudo-archive (for 9304f05b35a2Smrg # eventual linking with the app. that links it) if we 9305f05b35a2Smrg # didn't already link the preopened objects directly into 9306f05b35a2Smrg # the library: 9307f05b35a2Smrg func_basename "$lib" 9308f05b35a2Smrg name="$func_basename_result" 9309f05b35a2Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9310f05b35a2Smrg test -z "$libdir" && \ 9311f05b35a2Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 931267ab2ff2Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 9313f05b35a2Smrg ;; 9314f05b35a2Smrg esac 9315f05b35a2Smrg done 9316f05b35a2Smrg dlprefiles="$newdlprefiles" 9317f05b35a2Smrg else 9318f05b35a2Smrg newdlfiles= 9319f05b35a2Smrg for lib in $dlfiles; do 9320f05b35a2Smrg case $lib in 9321f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9322f05b35a2Smrg *) abs=`pwd`"/$lib" ;; 9323f05b35a2Smrg esac 932467ab2ff2Smrg func_append newdlfiles " $abs" 9325f05b35a2Smrg done 9326f05b35a2Smrg dlfiles="$newdlfiles" 9327f05b35a2Smrg newdlprefiles= 9328f05b35a2Smrg for lib in $dlprefiles; do 9329f05b35a2Smrg case $lib in 9330f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9331f05b35a2Smrg *) abs=`pwd`"/$lib" ;; 9332f05b35a2Smrg esac 933367ab2ff2Smrg func_append newdlprefiles " $abs" 9334f05b35a2Smrg done 9335f05b35a2Smrg dlprefiles="$newdlprefiles" 9336f05b35a2Smrg fi 9337f05b35a2Smrg $RM $output 9338f05b35a2Smrg # place dlname in correct position for cygwin 933949e108a1Smrg # In fact, it would be nice if we could use this code for all target 934049e108a1Smrg # systems that can't hard-code library paths into their executables 934149e108a1Smrg # and that have no shared library path variable independent of PATH, 934249e108a1Smrg # but it turns out we can't easily determine that from inspecting 934349e108a1Smrg # libtool variables, so we have to hard-code the OSs to which it 934449e108a1Smrg # applies here; at the moment, that means platforms that use the PE 934549e108a1Smrg # object format with DLL files. See the long comment at the top of 934649e108a1Smrg # tests/bindir.at for full details. 9347f05b35a2Smrg tdlname=$dlname 9348f05b35a2Smrg case $host,$output,$installed,$module,$dlname in 934949e108a1Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 935049e108a1Smrg # If a -bindir argument was supplied, place the dll there. 935149e108a1Smrg if test "x$bindir" != x ; 935249e108a1Smrg then 935349e108a1Smrg func_relative_path "$install_libdir" "$bindir" 935449e108a1Smrg tdlname=$func_relative_path_result$dlname 935549e108a1Smrg else 935649e108a1Smrg # Otherwise fall back on heuristic. 935749e108a1Smrg tdlname=../bin/$dlname 935849e108a1Smrg fi 935949e108a1Smrg ;; 9360f05b35a2Smrg esac 9361f05b35a2Smrg $ECHO > $output "\ 9362f05b35a2Smrg# $outputname - a libtool library file 9363f05b35a2Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 9364f05b35a2Smrg# 9365f05b35a2Smrg# Please DO NOT delete this file! 9366f05b35a2Smrg# It is necessary for linking the library. 9367e0963edeSmrg 9368f05b35a2Smrg# The name that we can dlopen(3). 9369f05b35a2Smrgdlname='$tdlname' 9370e0963edeSmrg 9371f05b35a2Smrg# Names of this library. 9372f05b35a2Smrglibrary_names='$library_names' 9373e0963edeSmrg 9374f05b35a2Smrg# The name of the static archive. 9375f05b35a2Smrgold_library='$old_library' 9376e0963edeSmrg 9377f05b35a2Smrg# Linker flags that can not go in dependency_libs. 9378f05b35a2Smrginherited_linker_flags='$new_inherited_linker_flags' 9379e0963edeSmrg 9380f05b35a2Smrg# Libraries that this one depends upon. 9381f05b35a2Smrgdependency_libs='$dependency_libs' 9382e0963edeSmrg 9383f05b35a2Smrg# Names of additional weak libraries provided by this library 9384f05b35a2Smrgweak_library_names='$weak_libs' 9385e0963edeSmrg 9386f05b35a2Smrg# Version information for $libname. 9387f05b35a2Smrgcurrent=$current 9388f05b35a2Smrgage=$age 9389f05b35a2Smrgrevision=$revision 9390e0963edeSmrg 9391f05b35a2Smrg# Is this an already installed library? 9392f05b35a2Smrginstalled=$installed 9393e0963edeSmrg 9394f05b35a2Smrg# Should we warn about portability when linking against -modules? 9395f05b35a2Smrgshouldnotlink=$module 9396e0963edeSmrg 9397f05b35a2Smrg# Files to dlopen/dlpreopen 9398f05b35a2Smrgdlopen='$dlfiles' 9399f05b35a2Smrgdlpreopen='$dlprefiles' 9400e0963edeSmrg 9401f05b35a2Smrg# Directory that this library needs to be installed in: 9402f05b35a2Smrglibdir='$install_libdir'" 9403f05b35a2Smrg if test "$installed" = no && test "$need_relink" = yes; then 9404f05b35a2Smrg $ECHO >> $output "\ 9405f05b35a2Smrgrelink_command=\"$relink_command\"" 9406f05b35a2Smrg fi 9407f05b35a2Smrg done 9408f05b35a2Smrg } 9409e0963edeSmrg 9410f05b35a2Smrg # Do a symbolic link so that the libtool archive can be found in 9411f05b35a2Smrg # LD_LIBRARY_PATH before the program is installed. 9412f05b35a2Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 9413f05b35a2Smrg ;; 9414f05b35a2Smrg esac 9415f05b35a2Smrg exit $EXIT_SUCCESS 9416f05b35a2Smrg} 9417e0963edeSmrg 941867ab2ff2Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 9419f05b35a2Smrg func_mode_link ${1+"$@"} 9420e0963edeSmrg 9421e0963edeSmrg 9422f05b35a2Smrg# func_mode_uninstall arg... 9423f05b35a2Smrgfunc_mode_uninstall () 9424f05b35a2Smrg{ 9425f05b35a2Smrg $opt_debug 9426f05b35a2Smrg RM="$nonopt" 9427e0963edeSmrg files= 9428e0963edeSmrg rmforce= 9429e0963edeSmrg exit_status=0 9430e0963edeSmrg 9431e0963edeSmrg # This variable tells wrapper scripts just to set variables rather 9432e0963edeSmrg # than running their programs. 9433e0963edeSmrg libtool_install_magic="$magic" 9434e0963edeSmrg 9435e0963edeSmrg for arg 9436e0963edeSmrg do 9437e0963edeSmrg case $arg in 943867ab2ff2Smrg -f) func_append RM " $arg"; rmforce=yes ;; 943967ab2ff2Smrg -*) func_append RM " $arg" ;; 944067ab2ff2Smrg *) func_append files " $arg" ;; 9441e0963edeSmrg esac 9442e0963edeSmrg done 9443e0963edeSmrg 9444f05b35a2Smrg test -z "$RM" && \ 9445f05b35a2Smrg func_fatal_help "you must specify an RM program" 9446e0963edeSmrg 9447e0963edeSmrg rmdirs= 9448e0963edeSmrg 9449e0963edeSmrg for file in $files; do 9450f05b35a2Smrg func_dirname "$file" "" "." 9451f05b35a2Smrg dir="$func_dirname_result" 9452f05b35a2Smrg if test "X$dir" = X.; then 945367ab2ff2Smrg odir="$objdir" 9454e0963edeSmrg else 945567ab2ff2Smrg odir="$dir/$objdir" 9456e0963edeSmrg fi 9457f05b35a2Smrg func_basename "$file" 9458f05b35a2Smrg name="$func_basename_result" 945967ab2ff2Smrg test "$opt_mode" = uninstall && odir="$dir" 9460e0963edeSmrg 946167ab2ff2Smrg # Remember odir for removal later, being careful to avoid duplicates 946267ab2ff2Smrg if test "$opt_mode" = clean; then 9463e0963edeSmrg case " $rmdirs " in 946467ab2ff2Smrg *" $odir "*) ;; 946567ab2ff2Smrg *) func_append rmdirs " $odir" ;; 9466e0963edeSmrg esac 9467e0963edeSmrg fi 9468e0963edeSmrg 9469e0963edeSmrg # Don't error if the file doesn't exist and rm -f was used. 9470f05b35a2Smrg if { test -L "$file"; } >/dev/null 2>&1 || 9471f05b35a2Smrg { test -h "$file"; } >/dev/null 2>&1 || 9472f05b35a2Smrg test -f "$file"; then 9473e0963edeSmrg : 9474e0963edeSmrg elif test -d "$file"; then 9475e0963edeSmrg exit_status=1 9476e0963edeSmrg continue 9477e0963edeSmrg elif test "$rmforce" = yes; then 9478e0963edeSmrg continue 9479e0963edeSmrg fi 9480e0963edeSmrg 9481e0963edeSmrg rmfiles="$file" 9482e0963edeSmrg 9483e0963edeSmrg case $name in 9484e0963edeSmrg *.la) 9485e0963edeSmrg # Possibly a libtool archive, so verify it. 9486f05b35a2Smrg if func_lalib_p "$file"; then 9487f05b35a2Smrg func_source $dir/$name 9488e0963edeSmrg 9489e0963edeSmrg # Delete the libtool libraries and symlinks. 9490e0963edeSmrg for n in $library_names; do 949167ab2ff2Smrg func_append rmfiles " $odir/$n" 9492e0963edeSmrg done 949367ab2ff2Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 9494e0963edeSmrg 949567ab2ff2Smrg case "$opt_mode" in 9496e0963edeSmrg clean) 949767ab2ff2Smrg case " $library_names " in 9498e0963edeSmrg *" $dlname "*) ;; 949967ab2ff2Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 9500e0963edeSmrg esac 950167ab2ff2Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 9502e0963edeSmrg ;; 9503e0963edeSmrg uninstall) 9504e0963edeSmrg if test -n "$library_names"; then 9505e0963edeSmrg # Do each command in the postuninstall commands. 9506f05b35a2Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9507e0963edeSmrg fi 9508e0963edeSmrg 9509e0963edeSmrg if test -n "$old_library"; then 9510e0963edeSmrg # Do each command in the old_postuninstall commands. 9511f05b35a2Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9512e0963edeSmrg fi 9513e0963edeSmrg # FIXME: should reinstall the best remaining shared library. 9514e0963edeSmrg ;; 9515e0963edeSmrg esac 9516e0963edeSmrg fi 9517e0963edeSmrg ;; 9518e0963edeSmrg 9519e0963edeSmrg *.lo) 9520e0963edeSmrg # Possibly a libtool object, so verify it. 9521f05b35a2Smrg if func_lalib_p "$file"; then 9522e0963edeSmrg 9523e0963edeSmrg # Read the .lo file 9524f05b35a2Smrg func_source $dir/$name 9525e0963edeSmrg 9526e0963edeSmrg # Add PIC object to the list of files to remove. 9527f05b35a2Smrg if test -n "$pic_object" && 9528f05b35a2Smrg test "$pic_object" != none; then 952967ab2ff2Smrg func_append rmfiles " $dir/$pic_object" 9530e0963edeSmrg fi 9531e0963edeSmrg 9532e0963edeSmrg # Add non-PIC object to the list of files to remove. 9533f05b35a2Smrg if test -n "$non_pic_object" && 9534f05b35a2Smrg test "$non_pic_object" != none; then 953567ab2ff2Smrg func_append rmfiles " $dir/$non_pic_object" 9536e0963edeSmrg fi 9537e0963edeSmrg fi 9538e0963edeSmrg ;; 9539e0963edeSmrg 9540e0963edeSmrg *) 954167ab2ff2Smrg if test "$opt_mode" = clean ; then 9542e0963edeSmrg noexename=$name 9543e0963edeSmrg case $file in 9544e0963edeSmrg *.exe) 9545f05b35a2Smrg func_stripname '' '.exe' "$file" 9546f05b35a2Smrg file=$func_stripname_result 9547f05b35a2Smrg func_stripname '' '.exe' "$name" 9548f05b35a2Smrg noexename=$func_stripname_result 9549e0963edeSmrg # $file with .exe has already been added to rmfiles, 9550e0963edeSmrg # add $file without .exe 955167ab2ff2Smrg func_append rmfiles " $file" 9552e0963edeSmrg ;; 9553e0963edeSmrg esac 9554e0963edeSmrg # Do a test to see if this is a libtool program. 9555f05b35a2Smrg if func_ltwrapper_p "$file"; then 9556f05b35a2Smrg if func_ltwrapper_executable_p "$file"; then 9557f05b35a2Smrg func_ltwrapper_scriptname "$file" 9558f05b35a2Smrg relink_command= 9559f05b35a2Smrg func_source $func_ltwrapper_scriptname_result 956067ab2ff2Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 9561f05b35a2Smrg else 9562f05b35a2Smrg relink_command= 9563f05b35a2Smrg func_source $dir/$noexename 9564f05b35a2Smrg fi 9565e0963edeSmrg 9566e0963edeSmrg # note $name still contains .exe if it was in $file originally 9567e0963edeSmrg # as does the version of $file that was added into $rmfiles 956867ab2ff2Smrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9569e0963edeSmrg if test "$fast_install" = yes && test -n "$relink_command"; then 957067ab2ff2Smrg func_append rmfiles " $odir/lt-$name" 9571e0963edeSmrg fi 9572e0963edeSmrg if test "X$noexename" != "X$name" ; then 957367ab2ff2Smrg func_append rmfiles " $odir/lt-${noexename}.c" 9574e0963edeSmrg fi 9575e0963edeSmrg fi 9576e0963edeSmrg fi 9577e0963edeSmrg ;; 9578e0963edeSmrg esac 9579f05b35a2Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 9580e0963edeSmrg done 9581e0963edeSmrg 9582e0963edeSmrg # Try to remove the ${objdir}s in the directories where we deleted files 9583e0963edeSmrg for dir in $rmdirs; do 9584e0963edeSmrg if test -d "$dir"; then 9585f05b35a2Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 9586e0963edeSmrg fi 9587e0963edeSmrg done 9588e0963edeSmrg 9589e0963edeSmrg exit $exit_status 9590f05b35a2Smrg} 9591e0963edeSmrg 959267ab2ff2Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 9593f05b35a2Smrg func_mode_uninstall ${1+"$@"} 9594e0963edeSmrg 959567ab2ff2Smrgtest -z "$opt_mode" && { 9596f05b35a2Smrg help="$generic_help" 9597f05b35a2Smrg func_fatal_help "you must specify a MODE" 9598f05b35a2Smrg} 9599f05b35a2Smrg 9600f05b35a2Smrgtest -z "$exec_cmd" && \ 960167ab2ff2Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 9602e0963edeSmrg 9603e0963edeSmrgif test -n "$exec_cmd"; then 9604f05b35a2Smrg eval exec "$exec_cmd" 9605e0963edeSmrg exit $EXIT_FAILURE 9606e0963edeSmrgfi 9607e0963edeSmrg 9608f05b35a2Smrgexit $exit_status 9609e0963edeSmrg 9610e0963edeSmrg 9611e0963edeSmrg# The TAGs below are defined such that we never get into a situation 9612e0963edeSmrg# in which we disable both kinds of libraries. Given conflicting 9613e0963edeSmrg# choices, we go for a static library, that is the most portable, 9614e0963edeSmrg# since we can't tell whether shared libraries were disabled because 9615e0963edeSmrg# the user asked for that or because the platform doesn't support 9616e0963edeSmrg# them. This is particularly important on AIX, because we don't 9617e0963edeSmrg# support having both static and shared libraries enabled at the same 9618e0963edeSmrg# time on that platform, so we default to a shared-only configuration. 9619e0963edeSmrg# If a disable-shared tag is given, we'll fallback to a static-only 9620e0963edeSmrg# configuration. But we'll never go from static-only to shared-only. 9621e0963edeSmrg 9622e0963edeSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 9623f05b35a2Smrgbuild_libtool_libs=no 9624f05b35a2Smrgbuild_old_libs=yes 9625e0963edeSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 9626e0963edeSmrg 9627e0963edeSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 9628f05b35a2Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 9629e0963edeSmrg# ### END LIBTOOL TAG CONFIG: disable-static 9630e0963edeSmrg 9631e0963edeSmrg# Local Variables: 9632e0963edeSmrg# mode:shell-script 9633e0963edeSmrg# sh-indentation:2 9634e0963edeSmrg# End: 9635f05b35a2Smrg# vi:sw=2 9636f05b35a2Smrg 9637