ltmain.sh revision e494fffd
1f05b35a2Smrg 2e494fffdSmrg# libtool (GNU libtool) 2.4.2 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, 6e494fffdSmrg# 2007, 2008, 2009, 2010, 2011 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) 44e494fffdSmrg# --no-warn don't display warning messages 4549e108a1Smrg# --tag=TAG use configuration variables from tag TAG 4649e108a1Smrg# -v, --verbose print more informational messages than default 4749e108a1Smrg# --no-verbose don't print the extra informational messages 4849e108a1Smrg# --version print version information 4949e108a1Smrg# -h, --help, --help-all print short, long, or detailed help message 50f05b35a2Smrg# 51f05b35a2Smrg# MODE must be one of the following: 52f05b35a2Smrg# 5349e108a1Smrg# clean remove files from the build directory 5449e108a1Smrg# compile compile a source file into a libtool object 5549e108a1Smrg# execute automatically set library path, then run a program 5649e108a1Smrg# finish complete the installation of libtool libraries 5749e108a1Smrg# install install libraries or executables 5849e108a1Smrg# link create a library or an executable 5949e108a1Smrg# uninstall remove libraries from an installed directory 60f05b35a2Smrg# 6149e108a1Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 6249e108a1Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 63f05b35a2Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 64f05b35a2Smrg# 65f05b35a2Smrg# When reporting a bug, please describe a test case to reproduce it and 66f05b35a2Smrg# include the following information: 67f05b35a2Smrg# 6849e108a1Smrg# host-triplet: $host 6949e108a1Smrg# shell: $SHELL 7049e108a1Smrg# compiler: $LTCC 7149e108a1Smrg# compiler flags: $LTCFLAGS 7249e108a1Smrg# linker: $LD (gnu? $with_gnu_ld) 73e494fffdSmrg# $progname: (GNU libtool) 2.4.2 7449e108a1Smrg# automake: $automake_version 7549e108a1Smrg# autoconf: $autoconf_version 76f05b35a2Smrg# 77f05b35a2Smrg# Report bugs to <bug-libtool@gnu.org>. 7867ab2ff2Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 7967ab2ff2Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 80e0963edeSmrg 8149e108a1SmrgPROGRAM=libtool 82e0963edeSmrgPACKAGE=libtool 83e494fffdSmrgVERSION=2.4.2 84f05b35a2SmrgTIMESTAMP="" 85e494fffdSmrgpackage_revision=1.3337 86e0963edeSmrg 87f05b35a2Smrg# Be Bourne compatible 88e0963edeSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 89e0963edeSmrg emulate sh 90e0963edeSmrg NULLCMD=: 91e0963edeSmrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 92e0963edeSmrg # is contrary to our usage. Disable this feature. 93e0963edeSmrg alias -g '${1+"$@"}'='"$@"' 94e0963edeSmrg setopt NO_GLOB_SUBST 95e0963edeSmrgelse 96e0963edeSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 97e0963edeSmrgfi 98e0963edeSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 99e0963edeSmrgDUALCASE=1; export DUALCASE # for MKS sh 100e0963edeSmrg 10149e108a1Smrg# A function that is used when there is no print builtin or printf. 10249e108a1Smrgfunc_fallback_echo () 10349e108a1Smrg{ 10449e108a1Smrg eval 'cat <<_LTECHO_EOF 10549e108a1Smrg$1 10649e108a1Smrg_LTECHO_EOF' 10749e108a1Smrg} 10849e108a1Smrg 109f05b35a2Smrg# NLS nuisances: We save the old values to restore during execute mode. 110f05b35a2Smrglt_user_locale= 111f05b35a2Smrglt_safe_locale= 112f05b35a2Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 113e0963edeSmrgdo 114e0963edeSmrg eval "if test \"\${$lt_var+set}\" = set; then 115f05b35a2Smrg save_$lt_var=\$$lt_var 116f05b35a2Smrg $lt_var=C 117e0963edeSmrg export $lt_var 118f05b35a2Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 119f05b35a2Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 120e0963edeSmrg fi" 121e0963edeSmrgdone 12249e108a1SmrgLC_ALL=C 12349e108a1SmrgLANGUAGE=C 12449e108a1Smrgexport LANGUAGE LC_ALL 125e0963edeSmrg 126f05b35a2Smrg$lt_unset CDPATH 127f05b35a2Smrg 128f05b35a2Smrg 12949e108a1Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 13049e108a1Smrg# is ksh but when the shell is invoked as "sh" and the current value of 13149e108a1Smrg# the _XPG environment variable is not equal to 1 (one), the special 13249e108a1Smrg# positional parameter $0, within a function call, is the name of the 13349e108a1Smrg# function. 13449e108a1Smrgprogpath="$0" 135f05b35a2Smrg 136f05b35a2Smrg 137f05b35a2Smrg 138f05b35a2Smrg: ${CP="cp -f"} 13949e108a1Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 140f05b35a2Smrg: ${MAKE="make"} 141f05b35a2Smrg: ${MKDIR="mkdir"} 142f05b35a2Smrg: ${MV="mv -f"} 143f05b35a2Smrg: ${RM="rm -f"} 144f05b35a2Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 145f05b35a2Smrg: ${Xsed="$SED -e 1s/^X//"} 146f05b35a2Smrg 147f05b35a2Smrg# Global variables: 148f05b35a2SmrgEXIT_SUCCESS=0 149f05b35a2SmrgEXIT_FAILURE=1 150f05b35a2SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 151f05b35a2SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 152f05b35a2Smrg 153f05b35a2Smrgexit_status=$EXIT_SUCCESS 154f05b35a2Smrg 155e0963edeSmrg# Make sure IFS has a sensible default 156e0963edeSmrglt_nl=' 157e0963edeSmrg' 158e0963edeSmrgIFS=" $lt_nl" 159e0963edeSmrg 160f05b35a2Smrgdirname="s,/[^/]*$,," 161f05b35a2Smrgbasename="s,^.*/,," 162f05b35a2Smrg 16367ab2ff2Smrg# func_dirname file append nondir_replacement 16467ab2ff2Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 16567ab2ff2Smrg# otherwise set result to NONDIR_REPLACEMENT. 16667ab2ff2Smrgfunc_dirname () 16767ab2ff2Smrg{ 16867ab2ff2Smrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 16967ab2ff2Smrg if test "X$func_dirname_result" = "X${1}"; then 17067ab2ff2Smrg func_dirname_result="${3}" 17167ab2ff2Smrg else 17267ab2ff2Smrg func_dirname_result="$func_dirname_result${2}" 17367ab2ff2Smrg fi 17467ab2ff2Smrg} # func_dirname may be replaced by extended shell implementation 17567ab2ff2Smrg 17667ab2ff2Smrg 17767ab2ff2Smrg# func_basename file 17867ab2ff2Smrgfunc_basename () 17967ab2ff2Smrg{ 18067ab2ff2Smrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 18167ab2ff2Smrg} # func_basename may be replaced by extended shell implementation 18267ab2ff2Smrg 18367ab2ff2Smrg 184f05b35a2Smrg# func_dirname_and_basename file append nondir_replacement 185f05b35a2Smrg# perform func_basename and func_dirname in a single function 186f05b35a2Smrg# call: 187f05b35a2Smrg# dirname: Compute the dirname of FILE. If nonempty, 188f05b35a2Smrg# add APPEND to the result, otherwise set result 189f05b35a2Smrg# to NONDIR_REPLACEMENT. 190f05b35a2Smrg# value returned in "$func_dirname_result" 191f05b35a2Smrg# basename: Compute filename of FILE. 192f05b35a2Smrg# value retuned in "$func_basename_result" 193f05b35a2Smrg# Implementation must be kept synchronized with func_dirname 194f05b35a2Smrg# and func_basename. For efficiency, we do not delegate to 195f05b35a2Smrg# those functions but instead duplicate the functionality here. 196f05b35a2Smrgfunc_dirname_and_basename () 197f05b35a2Smrg{ 19867ab2ff2Smrg # Extract subdirectory from the argument. 19967ab2ff2Smrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 20067ab2ff2Smrg if test "X$func_dirname_result" = "X${1}"; then 20167ab2ff2Smrg func_dirname_result="${3}" 20267ab2ff2Smrg else 20367ab2ff2Smrg func_dirname_result="$func_dirname_result${2}" 20467ab2ff2Smrg fi 20567ab2ff2Smrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 20667ab2ff2Smrg} # func_dirname_and_basename may be replaced by extended shell implementation 20767ab2ff2Smrg 20867ab2ff2Smrg 20967ab2ff2Smrg# func_stripname prefix suffix name 21067ab2ff2Smrg# strip PREFIX and SUFFIX off of NAME. 21167ab2ff2Smrg# PREFIX and SUFFIX must not contain globbing or regex special 21267ab2ff2Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 21367ab2ff2Smrg# dot (in which case that matches only a dot). 21467ab2ff2Smrg# func_strip_suffix prefix name 21567ab2ff2Smrgfunc_stripname () 21667ab2ff2Smrg{ 21767ab2ff2Smrg case ${2} in 21867ab2ff2Smrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 21967ab2ff2Smrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 22067ab2ff2Smrg esac 22167ab2ff2Smrg} # func_stripname may be replaced by extended shell implementation 222e0963edeSmrg 223f05b35a2Smrg 22449e108a1Smrg# These SED scripts presuppose an absolute path with a trailing slash. 22549e108a1Smrgpathcar='s,^/\([^/]*\).*$,\1,' 22649e108a1Smrgpathcdr='s,^/[^/]*,,' 22749e108a1Smrgremovedotparts=':dotsl 22849e108a1Smrg s@/\./@/@g 22949e108a1Smrg t dotsl 23049e108a1Smrg s,/\.$,/,' 23149e108a1Smrgcollapseslashes='s@/\{1,\}@/@g' 23249e108a1Smrgfinalslash='s,/*$,/,' 23349e108a1Smrg 23449e108a1Smrg# func_normal_abspath PATH 23549e108a1Smrg# Remove doubled-up and trailing slashes, "." path components, 23649e108a1Smrg# and cancel out any ".." path components in PATH after making 23749e108a1Smrg# it an absolute path. 23849e108a1Smrg# value returned in "$func_normal_abspath_result" 23949e108a1Smrgfunc_normal_abspath () 24049e108a1Smrg{ 24149e108a1Smrg # Start from root dir and reassemble the path. 24249e108a1Smrg func_normal_abspath_result= 24349e108a1Smrg func_normal_abspath_tpath=$1 24449e108a1Smrg func_normal_abspath_altnamespace= 24549e108a1Smrg case $func_normal_abspath_tpath in 24649e108a1Smrg "") 24749e108a1Smrg # Empty path, that just means $cwd. 24849e108a1Smrg func_stripname '' '/' "`pwd`" 24949e108a1Smrg func_normal_abspath_result=$func_stripname_result 25049e108a1Smrg return 25149e108a1Smrg ;; 25249e108a1Smrg # The next three entries are used to spot a run of precisely 25349e108a1Smrg # two leading slashes without using negated character classes; 25449e108a1Smrg # we take advantage of case's first-match behaviour. 25549e108a1Smrg ///*) 25649e108a1Smrg # Unusual form of absolute path, do nothing. 25749e108a1Smrg ;; 25849e108a1Smrg //*) 25949e108a1Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 26049e108a1Smrg # and for example Cygwin uses it to access remote file shares 26149e108a1Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 26249e108a1Smrg func_normal_abspath_altnamespace=/ 26349e108a1Smrg ;; 26449e108a1Smrg /*) 26549e108a1Smrg # Absolute path, do nothing. 26649e108a1Smrg ;; 26749e108a1Smrg *) 26849e108a1Smrg # Relative path, prepend $cwd. 26949e108a1Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 27049e108a1Smrg ;; 27149e108a1Smrg esac 27249e108a1Smrg # Cancel out all the simple stuff to save iterations. We also want 27349e108a1Smrg # the path to end with a slash for ease of parsing, so make sure 27449e108a1Smrg # there is one (and only one) here. 27549e108a1Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 27649e108a1Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 27749e108a1Smrg while :; do 27849e108a1Smrg # Processed it all yet? 27949e108a1Smrg if test "$func_normal_abspath_tpath" = / ; then 28049e108a1Smrg # If we ascended to the root using ".." the result may be empty now. 28149e108a1Smrg if test -z "$func_normal_abspath_result" ; then 28249e108a1Smrg func_normal_abspath_result=/ 28349e108a1Smrg fi 28449e108a1Smrg break 28549e108a1Smrg fi 28649e108a1Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 28749e108a1Smrg -e "$pathcar"` 28849e108a1Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 28949e108a1Smrg -e "$pathcdr"` 29049e108a1Smrg # Figure out what to do with it 29149e108a1Smrg case $func_normal_abspath_tcomponent in 29249e108a1Smrg "") 29349e108a1Smrg # Trailing empty path component, ignore it. 29449e108a1Smrg ;; 29549e108a1Smrg ..) 29649e108a1Smrg # Parent dir; strip last assembled component from result. 29749e108a1Smrg func_dirname "$func_normal_abspath_result" 29849e108a1Smrg func_normal_abspath_result=$func_dirname_result 29949e108a1Smrg ;; 30049e108a1Smrg *) 30149e108a1Smrg # Actual path component, append it. 30249e108a1Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 30349e108a1Smrg ;; 30449e108a1Smrg esac 30549e108a1Smrg done 30649e108a1Smrg # Restore leading double-slash if one was found on entry. 30749e108a1Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 30849e108a1Smrg} 30949e108a1Smrg 31049e108a1Smrg# func_relative_path SRCDIR DSTDIR 31149e108a1Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 31249e108a1Smrg# slash if non-empty, suitable for immediately appending a filename 31349e108a1Smrg# without needing to append a separator. 31449e108a1Smrg# value returned in "$func_relative_path_result" 31549e108a1Smrgfunc_relative_path () 31649e108a1Smrg{ 31749e108a1Smrg func_relative_path_result= 31849e108a1Smrg func_normal_abspath "$1" 31949e108a1Smrg func_relative_path_tlibdir=$func_normal_abspath_result 32049e108a1Smrg func_normal_abspath "$2" 32149e108a1Smrg func_relative_path_tbindir=$func_normal_abspath_result 32249e108a1Smrg 32349e108a1Smrg # Ascend the tree starting from libdir 32449e108a1Smrg while :; do 32549e108a1Smrg # check if we have found a prefix of bindir 32649e108a1Smrg case $func_relative_path_tbindir in 32749e108a1Smrg $func_relative_path_tlibdir) 32849e108a1Smrg # found an exact match 32949e108a1Smrg func_relative_path_tcancelled= 33049e108a1Smrg break 33149e108a1Smrg ;; 33249e108a1Smrg $func_relative_path_tlibdir*) 33349e108a1Smrg # found a matching prefix 33449e108a1Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 33549e108a1Smrg func_relative_path_tcancelled=$func_stripname_result 33649e108a1Smrg if test -z "$func_relative_path_result"; then 33749e108a1Smrg func_relative_path_result=. 33849e108a1Smrg fi 33949e108a1Smrg break 34049e108a1Smrg ;; 34149e108a1Smrg *) 34249e108a1Smrg func_dirname $func_relative_path_tlibdir 34349e108a1Smrg func_relative_path_tlibdir=${func_dirname_result} 34449e108a1Smrg if test "x$func_relative_path_tlibdir" = x ; then 34549e108a1Smrg # Have to descend all the way to the root! 34649e108a1Smrg func_relative_path_result=../$func_relative_path_result 34749e108a1Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 34849e108a1Smrg break 34949e108a1Smrg fi 35049e108a1Smrg func_relative_path_result=../$func_relative_path_result 35149e108a1Smrg ;; 35249e108a1Smrg esac 35349e108a1Smrg done 35449e108a1Smrg 35549e108a1Smrg # Now calculate path; take care to avoid doubling-up slashes. 35649e108a1Smrg func_stripname '' '/' "$func_relative_path_result" 35749e108a1Smrg func_relative_path_result=$func_stripname_result 35849e108a1Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 35949e108a1Smrg if test "x$func_stripname_result" != x ; then 36049e108a1Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 36149e108a1Smrg fi 36249e108a1Smrg 36349e108a1Smrg # Normalisation. If bindir is libdir, return empty string, 36449e108a1Smrg # else relative path ending with a slash; either way, target 36549e108a1Smrg # file name can be directly appended. 36649e108a1Smrg if test ! -z "$func_relative_path_result"; then 36749e108a1Smrg func_stripname './' '' "$func_relative_path_result/" 36849e108a1Smrg func_relative_path_result=$func_stripname_result 36949e108a1Smrg fi 37049e108a1Smrg} 371f05b35a2Smrg 372f05b35a2Smrg# The name of this program: 373f05b35a2Smrgfunc_dirname_and_basename "$progpath" 374f05b35a2Smrgprogname=$func_basename_result 375f05b35a2Smrg 376f05b35a2Smrg# Make sure we have an absolute path for reexecution: 377f05b35a2Smrgcase $progpath in 378f05b35a2Smrg [\\/]*|[A-Za-z]:\\*) ;; 379f05b35a2Smrg *[\\/]*) 380f05b35a2Smrg progdir=$func_dirname_result 381f05b35a2Smrg progdir=`cd "$progdir" && pwd` 382f05b35a2Smrg progpath="$progdir/$progname" 383f05b35a2Smrg ;; 384f05b35a2Smrg *) 385f05b35a2Smrg save_IFS="$IFS" 386e494fffdSmrg IFS=${PATH_SEPARATOR-:} 387f05b35a2Smrg for progdir in $PATH; do 388f05b35a2Smrg IFS="$save_IFS" 389f05b35a2Smrg test -x "$progdir/$progname" && break 390f05b35a2Smrg done 391f05b35a2Smrg IFS="$save_IFS" 392f05b35a2Smrg test -n "$progdir" || progdir=`pwd` 393f05b35a2Smrg progpath="$progdir/$progname" 394f05b35a2Smrg ;; 395f05b35a2Smrgesac 396f05b35a2Smrg 397f05b35a2Smrg# Sed substitution that helps us do robust quoting. It backslashifies 398f05b35a2Smrg# metacharacters that are still active within double-quoted strings. 399f05b35a2SmrgXsed="${SED}"' -e 1s/^X//' 400f05b35a2Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 401f05b35a2Smrg 402f05b35a2Smrg# Same as above, but do not quote variable references. 403f05b35a2Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 404f05b35a2Smrg 40567ab2ff2Smrg# Sed substitution that turns a string into a regex matching for the 40667ab2ff2Smrg# string literally. 40767ab2ff2Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 40867ab2ff2Smrg 40967ab2ff2Smrg# Sed substitution that converts a w32 file name or path 41067ab2ff2Smrg# which contains forward slashes, into one that contains 41167ab2ff2Smrg# (escaped) backslashes. A very naive implementation. 41267ab2ff2Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 41367ab2ff2Smrg 414f05b35a2Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 415f05b35a2Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 416f05b35a2Smrg# in input to double_quote_subst, that '$' was protected from expansion. 417f05b35a2Smrg# Since each input `\' is now two `\'s, look for any number of runs of 418f05b35a2Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 419f05b35a2Smrgbs='\\' 420f05b35a2Smrgbs2='\\\\' 421f05b35a2Smrgbs4='\\\\\\\\' 422f05b35a2Smrgdollar='\$' 423f05b35a2Smrgsed_double_backslash="\ 424f05b35a2Smrg s/$bs4/&\\ 425f05b35a2Smrg/g 426f05b35a2Smrg s/^$bs2$dollar/$bs&/ 427f05b35a2Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 428f05b35a2Smrg s/\n//g" 429f05b35a2Smrg 430f05b35a2Smrg# Standard options: 431f05b35a2Smrgopt_dry_run=false 432f05b35a2Smrgopt_help=false 433f05b35a2Smrgopt_quiet=false 434f05b35a2Smrgopt_verbose=false 435f05b35a2Smrgopt_warning=: 436f05b35a2Smrg 437f05b35a2Smrg# func_echo arg... 438f05b35a2Smrg# Echo program name prefixed message, along with the current mode 439f05b35a2Smrg# name if it has been set yet. 440f05b35a2Smrgfunc_echo () 441f05b35a2Smrg{ 44267ab2ff2Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 443f05b35a2Smrg} 444f05b35a2Smrg 445f05b35a2Smrg# func_verbose arg... 446f05b35a2Smrg# Echo program name prefixed message in verbose mode only. 447f05b35a2Smrgfunc_verbose () 448f05b35a2Smrg{ 449f05b35a2Smrg $opt_verbose && func_echo ${1+"$@"} 450f05b35a2Smrg 451f05b35a2Smrg # A bug in bash halts the script if the last line of a function 452f05b35a2Smrg # fails when set -e is in force, so we need another command to 453f05b35a2Smrg # work around that: 454f05b35a2Smrg : 455f05b35a2Smrg} 456f05b35a2Smrg 45749e108a1Smrg# func_echo_all arg... 45849e108a1Smrg# Invoke $ECHO with all args, space-separated. 45949e108a1Smrgfunc_echo_all () 46049e108a1Smrg{ 46149e108a1Smrg $ECHO "$*" 46249e108a1Smrg} 46349e108a1Smrg 464f05b35a2Smrg# func_error arg... 465f05b35a2Smrg# Echo program name prefixed message to standard error. 466f05b35a2Smrgfunc_error () 467f05b35a2Smrg{ 46867ab2ff2Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 469f05b35a2Smrg} 470f05b35a2Smrg 471f05b35a2Smrg# func_warning arg... 472f05b35a2Smrg# Echo program name prefixed warning message to standard error. 473f05b35a2Smrgfunc_warning () 474f05b35a2Smrg{ 47567ab2ff2Smrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 476f05b35a2Smrg 477f05b35a2Smrg # bash bug again: 478f05b35a2Smrg : 479f05b35a2Smrg} 480f05b35a2Smrg 481f05b35a2Smrg# func_fatal_error arg... 482f05b35a2Smrg# Echo program name prefixed message to standard error, and exit. 483f05b35a2Smrgfunc_fatal_error () 484f05b35a2Smrg{ 485f05b35a2Smrg func_error ${1+"$@"} 486f05b35a2Smrg exit $EXIT_FAILURE 487f05b35a2Smrg} 488f05b35a2Smrg 489f05b35a2Smrg# func_fatal_help arg... 490f05b35a2Smrg# Echo program name prefixed message to standard error, followed by 491f05b35a2Smrg# a help hint, and exit. 492f05b35a2Smrgfunc_fatal_help () 493f05b35a2Smrg{ 494f05b35a2Smrg func_error ${1+"$@"} 495f05b35a2Smrg func_fatal_error "$help" 496f05b35a2Smrg} 497f05b35a2Smrghelp="Try \`$progname --help' for more information." ## default 498f05b35a2Smrg 499f05b35a2Smrg 500f05b35a2Smrg# func_grep expression filename 501f05b35a2Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 502f05b35a2Smrgfunc_grep () 503f05b35a2Smrg{ 504f05b35a2Smrg $GREP "$1" "$2" >/dev/null 2>&1 505f05b35a2Smrg} 506f05b35a2Smrg 507f05b35a2Smrg 508f05b35a2Smrg# func_mkdir_p directory-path 509f05b35a2Smrg# Make sure the entire path to DIRECTORY-PATH is available. 510f05b35a2Smrgfunc_mkdir_p () 511f05b35a2Smrg{ 512f05b35a2Smrg my_directory_path="$1" 513f05b35a2Smrg my_dir_list= 514f05b35a2Smrg 515f05b35a2Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 516f05b35a2Smrg 517f05b35a2Smrg # Protect directory names starting with `-' 518f05b35a2Smrg case $my_directory_path in 519f05b35a2Smrg -*) my_directory_path="./$my_directory_path" ;; 520f05b35a2Smrg esac 521f05b35a2Smrg 522f05b35a2Smrg # While some portion of DIR does not yet exist... 523f05b35a2Smrg while test ! -d "$my_directory_path"; do 524f05b35a2Smrg # ...make a list in topmost first order. Use a colon delimited 525f05b35a2Smrg # list incase some portion of path contains whitespace. 526f05b35a2Smrg my_dir_list="$my_directory_path:$my_dir_list" 527f05b35a2Smrg 528f05b35a2Smrg # If the last portion added has no slash in it, the list is done 529f05b35a2Smrg case $my_directory_path in */*) ;; *) break ;; esac 530f05b35a2Smrg 531f05b35a2Smrg # ...otherwise throw away the child directory and loop 53249e108a1Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 533f05b35a2Smrg done 53449e108a1Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 535f05b35a2Smrg 536f05b35a2Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 537f05b35a2Smrg for my_dir in $my_dir_list; do 538f05b35a2Smrg IFS="$save_mkdir_p_IFS" 539f05b35a2Smrg # mkdir can fail with a `File exist' error if two processes 540f05b35a2Smrg # try to create one of the directories concurrently. Don't 541f05b35a2Smrg # stop in that case! 542f05b35a2Smrg $MKDIR "$my_dir" 2>/dev/null || : 543f05b35a2Smrg done 544f05b35a2Smrg IFS="$save_mkdir_p_IFS" 545f05b35a2Smrg 546f05b35a2Smrg # Bail out if we (or some other process) failed to create a directory. 547f05b35a2Smrg test -d "$my_directory_path" || \ 548f05b35a2Smrg func_fatal_error "Failed to create \`$1'" 549f05b35a2Smrg fi 550f05b35a2Smrg} 551e0963edeSmrg 552e0963edeSmrg 553e0963edeSmrg# func_mktempdir [string] 554e0963edeSmrg# Make a temporary directory that won't clash with other running 555e0963edeSmrg# libtool processes, and avoids race conditions if possible. If 556e0963edeSmrg# given, STRING is the basename for that directory. 557e0963edeSmrgfunc_mktempdir () 558e0963edeSmrg{ 559e0963edeSmrg my_template="${TMPDIR-/tmp}/${1-$progname}" 560e0963edeSmrg 561f05b35a2Smrg if test "$opt_dry_run" = ":"; then 562e0963edeSmrg # Return a directory name, but don't create it in dry-run mode 563e0963edeSmrg my_tmpdir="${my_template}-$$" 564e0963edeSmrg else 565e0963edeSmrg 566e0963edeSmrg # If mktemp works, use that first and foremost 567e0963edeSmrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 568e0963edeSmrg 569e0963edeSmrg if test ! -d "$my_tmpdir"; then 570f05b35a2Smrg # Failing that, at least try and use $RANDOM to avoid a race 571f05b35a2Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 572e0963edeSmrg 573f05b35a2Smrg save_mktempdir_umask=`umask` 574f05b35a2Smrg umask 0077 575f05b35a2Smrg $MKDIR "$my_tmpdir" 576f05b35a2Smrg umask $save_mktempdir_umask 577e0963edeSmrg fi 578e0963edeSmrg 579e0963edeSmrg # If we're not in dry-run mode, bomb out on failure 580f05b35a2Smrg test -d "$my_tmpdir" || \ 581f05b35a2Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 582e0963edeSmrg fi 583e0963edeSmrg 58449e108a1Smrg $ECHO "$my_tmpdir" 585e0963edeSmrg} 586e0963edeSmrg 587e0963edeSmrg 588f05b35a2Smrg# func_quote_for_eval arg 589f05b35a2Smrg# Aesthetically quote ARG to be evaled later. 590f05b35a2Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 591f05b35a2Smrg# is double-quoted, suitable for a subsequent eval, whereas 592f05b35a2Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 593f05b35a2Smrg# which are still active within double quotes backslashified. 594f05b35a2Smrgfunc_quote_for_eval () 595e0963edeSmrg{ 596f05b35a2Smrg case $1 in 597f05b35a2Smrg *[\\\`\"\$]*) 59849e108a1Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 599f05b35a2Smrg *) 600f05b35a2Smrg func_quote_for_eval_unquoted_result="$1" ;; 601f05b35a2Smrg esac 602f05b35a2Smrg 603f05b35a2Smrg case $func_quote_for_eval_unquoted_result in 604f05b35a2Smrg # Double-quote args containing shell metacharacters to delay 605f05b35a2Smrg # word splitting, command substitution and and variable 606f05b35a2Smrg # expansion for a subsequent eval. 607f05b35a2Smrg # Many Bourne shells cannot handle close brackets correctly 608f05b35a2Smrg # in scan sets, so we specify it separately. 609f05b35a2Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 610f05b35a2Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 611f05b35a2Smrg ;; 612f05b35a2Smrg *) 613f05b35a2Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 614e0963edeSmrg esac 615e0963edeSmrg} 616e0963edeSmrg 617e0963edeSmrg 618f05b35a2Smrg# func_quote_for_expand arg 619f05b35a2Smrg# Aesthetically quote ARG to be evaled later; same as above, 620f05b35a2Smrg# but do not quote variable references. 621f05b35a2Smrgfunc_quote_for_expand () 622e0963edeSmrg{ 623f05b35a2Smrg case $1 in 624f05b35a2Smrg *[\\\`\"]*) 62549e108a1Smrg my_arg=`$ECHO "$1" | $SED \ 626f05b35a2Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 627e0963edeSmrg *) 628f05b35a2Smrg my_arg="$1" ;; 629f05b35a2Smrg esac 630f05b35a2Smrg 631f05b35a2Smrg case $my_arg in 632f05b35a2Smrg # Double-quote args containing shell metacharacters to delay 633f05b35a2Smrg # word splitting and command substitution for a subsequent eval. 634f05b35a2Smrg # Many Bourne shells cannot handle close brackets correctly 635f05b35a2Smrg # in scan sets, so we specify it separately. 636f05b35a2Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 637f05b35a2Smrg my_arg="\"$my_arg\"" 638f05b35a2Smrg ;; 639f05b35a2Smrg esac 640f05b35a2Smrg 641f05b35a2Smrg func_quote_for_expand_result="$my_arg" 642e0963edeSmrg} 643e0963edeSmrg 644e0963edeSmrg 645f05b35a2Smrg# func_show_eval cmd [fail_exp] 646f05b35a2Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 647f05b35a2Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 648f05b35a2Smrg# is given, then evaluate it. 649f05b35a2Smrgfunc_show_eval () 650e0963edeSmrg{ 651f05b35a2Smrg my_cmd="$1" 652f05b35a2Smrg my_fail_exp="${2-:}" 653e0963edeSmrg 654f05b35a2Smrg ${opt_silent-false} || { 655f05b35a2Smrg func_quote_for_expand "$my_cmd" 656f05b35a2Smrg eval "func_echo $func_quote_for_expand_result" 657f05b35a2Smrg } 658f05b35a2Smrg 659f05b35a2Smrg if ${opt_dry_run-false}; then :; else 660f05b35a2Smrg eval "$my_cmd" 661f05b35a2Smrg my_status=$? 662f05b35a2Smrg if test "$my_status" -eq 0; then :; else 663f05b35a2Smrg eval "(exit $my_status); $my_fail_exp" 664f05b35a2Smrg fi 665e0963edeSmrg fi 666e0963edeSmrg} 667e0963edeSmrg 668f05b35a2Smrg 669f05b35a2Smrg# func_show_eval_locale cmd [fail_exp] 670f05b35a2Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 671f05b35a2Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 672f05b35a2Smrg# is given, then evaluate it. Use the saved locale for evaluation. 673f05b35a2Smrgfunc_show_eval_locale () 674e0963edeSmrg{ 675f05b35a2Smrg my_cmd="$1" 676f05b35a2Smrg my_fail_exp="${2-:}" 677f05b35a2Smrg 678f05b35a2Smrg ${opt_silent-false} || { 679f05b35a2Smrg func_quote_for_expand "$my_cmd" 680f05b35a2Smrg eval "func_echo $func_quote_for_expand_result" 681f05b35a2Smrg } 682f05b35a2Smrg 683f05b35a2Smrg if ${opt_dry_run-false}; then :; else 684f05b35a2Smrg eval "$lt_user_locale 685f05b35a2Smrg $my_cmd" 686f05b35a2Smrg my_status=$? 687f05b35a2Smrg eval "$lt_safe_locale" 688f05b35a2Smrg if test "$my_status" -eq 0; then :; else 689f05b35a2Smrg eval "(exit $my_status); $my_fail_exp" 690f05b35a2Smrg fi 691e0963edeSmrg fi 692f05b35a2Smrg} 693e0963edeSmrg 69467ab2ff2Smrg# func_tr_sh 69567ab2ff2Smrg# Turn $1 into a string suitable for a shell variable name. 69667ab2ff2Smrg# Result is stored in $func_tr_sh_result. All characters 69767ab2ff2Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 69867ab2ff2Smrg# if $1 begins with a digit, a '_' is prepended as well. 69967ab2ff2Smrgfunc_tr_sh () 70067ab2ff2Smrg{ 70167ab2ff2Smrg case $1 in 70267ab2ff2Smrg [0-9]* | *[!a-zA-Z0-9_]*) 70367ab2ff2Smrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 70467ab2ff2Smrg ;; 70567ab2ff2Smrg * ) 70667ab2ff2Smrg func_tr_sh_result=$1 70767ab2ff2Smrg ;; 70867ab2ff2Smrg esac 70967ab2ff2Smrg} 71067ab2ff2Smrg 711e0963edeSmrg 712f05b35a2Smrg# func_version 713f05b35a2Smrg# Echo version message to standard output and exit. 714f05b35a2Smrgfunc_version () 715f05b35a2Smrg{ 71667ab2ff2Smrg $opt_debug 71767ab2ff2Smrg 71849e108a1Smrg $SED -n '/(C)/!b go 71949e108a1Smrg :more 72049e108a1Smrg /\./!{ 72149e108a1Smrg N 72249e108a1Smrg s/\n# / / 72349e108a1Smrg b more 72449e108a1Smrg } 72549e108a1Smrg :go 72649e108a1Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 727f05b35a2Smrg s/^# // 728f05b35a2Smrg s/^# *$// 729f05b35a2Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 730f05b35a2Smrg p 731f05b35a2Smrg }' < "$progpath" 732f05b35a2Smrg exit $? 733f05b35a2Smrg} 734f05b35a2Smrg 735f05b35a2Smrg# func_usage 736f05b35a2Smrg# Echo short help message to standard output and exit. 737f05b35a2Smrgfunc_usage () 738f05b35a2Smrg{ 73967ab2ff2Smrg $opt_debug 74067ab2ff2Smrg 74149e108a1Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 742f05b35a2Smrg s/^# // 743f05b35a2Smrg s/^# *$// 744f05b35a2Smrg s/\$progname/'$progname'/ 745f05b35a2Smrg p 746f05b35a2Smrg }' < "$progpath" 74749e108a1Smrg echo 748f05b35a2Smrg $ECHO "run \`$progname --help | more' for full usage" 749f05b35a2Smrg exit $? 750f05b35a2Smrg} 751f05b35a2Smrg 75249e108a1Smrg# func_help [NOEXIT] 75349e108a1Smrg# Echo long help message to standard output and exit, 75449e108a1Smrg# unless 'noexit' is passed as argument. 755f05b35a2Smrgfunc_help () 756f05b35a2Smrg{ 75767ab2ff2Smrg $opt_debug 75867ab2ff2Smrg 759f05b35a2Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 76067ab2ff2Smrg :print 761f05b35a2Smrg s/^# // 762f05b35a2Smrg s/^# *$// 763f05b35a2Smrg s*\$progname*'$progname'* 764f05b35a2Smrg s*\$host*'"$host"'* 765f05b35a2Smrg s*\$SHELL*'"$SHELL"'* 766f05b35a2Smrg s*\$LTCC*'"$LTCC"'* 767f05b35a2Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 768f05b35a2Smrg s*\$LD*'"$LD"'* 769f05b35a2Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 770e494fffdSmrg s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ 771e494fffdSmrg s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ 772f05b35a2Smrg p 77367ab2ff2Smrg d 77467ab2ff2Smrg } 77567ab2ff2Smrg /^# .* home page:/b print 77667ab2ff2Smrg /^# General help using/b print 77767ab2ff2Smrg ' < "$progpath" 77849e108a1Smrg ret=$? 77949e108a1Smrg if test -z "$1"; then 78049e108a1Smrg exit $ret 78149e108a1Smrg fi 782f05b35a2Smrg} 783f05b35a2Smrg 784f05b35a2Smrg# func_missing_arg argname 785f05b35a2Smrg# Echo program name prefixed message to standard error and set global 786f05b35a2Smrg# exit_cmd. 787f05b35a2Smrgfunc_missing_arg () 788f05b35a2Smrg{ 78967ab2ff2Smrg $opt_debug 79067ab2ff2Smrg 79149e108a1Smrg func_error "missing argument for $1." 792f05b35a2Smrg exit_cmd=exit 793e0963edeSmrg} 794e0963edeSmrg 795e0963edeSmrg 79667ab2ff2Smrg# func_split_short_opt shortopt 79767ab2ff2Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 79867ab2ff2Smrg# variables after splitting SHORTOPT after the 2nd character. 79967ab2ff2Smrgfunc_split_short_opt () 80067ab2ff2Smrg{ 80167ab2ff2Smrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 80267ab2ff2Smrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 80367ab2ff2Smrg 80467ab2ff2Smrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 80567ab2ff2Smrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 80667ab2ff2Smrg} # func_split_short_opt may be replaced by extended shell implementation 80767ab2ff2Smrg 80867ab2ff2Smrg 80967ab2ff2Smrg# func_split_long_opt longopt 81067ab2ff2Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 81167ab2ff2Smrg# variables after splitting LONGOPT at the `=' sign. 81267ab2ff2Smrgfunc_split_long_opt () 81367ab2ff2Smrg{ 81467ab2ff2Smrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 81567ab2ff2Smrg my_sed_long_arg='1s/^--[^=]*=//' 81667ab2ff2Smrg 81767ab2ff2Smrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 81867ab2ff2Smrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 81967ab2ff2Smrg} # func_split_long_opt may be replaced by extended shell implementation 82067ab2ff2Smrg 82167ab2ff2Smrgexit_cmd=: 822e0963edeSmrg 823f05b35a2Smrg 824f05b35a2Smrg 825f05b35a2Smrg 826e0963edeSmrg 827f05b35a2Smrgmagic="%%%MAGIC variable%%%" 828f05b35a2Smrgmagic_exe="%%%MAGIC EXE variable%%%" 829e0963edeSmrg 830f05b35a2Smrg# Global variables. 831f05b35a2Smrgnonopt= 832f05b35a2Smrgpreserve_args= 833f05b35a2Smrglo2o="s/\\.lo\$/.${objext}/" 834f05b35a2Smrgo2lo="s/\\.${objext}\$/.lo/" 835f05b35a2Smrgextracted_archives= 836f05b35a2Smrgextracted_serial=0 837e0963edeSmrg 838f05b35a2Smrg# If this variable is set in any of the actions, the command in it 839f05b35a2Smrg# will be execed at the end. This prevents here-documents from being 840f05b35a2Smrg# left over by shells. 841f05b35a2Smrgexec_cmd= 842f05b35a2Smrg 84367ab2ff2Smrg# func_append var value 84467ab2ff2Smrg# Append VALUE to the end of shell variable VAR. 84567ab2ff2Smrgfunc_append () 84667ab2ff2Smrg{ 84767ab2ff2Smrg eval "${1}=\$${1}\${2}" 84867ab2ff2Smrg} # func_append may be replaced by extended shell implementation 84967ab2ff2Smrg 85067ab2ff2Smrg# func_append_quoted var value 85167ab2ff2Smrg# Quote VALUE and append to the end of shell variable VAR, separated 85267ab2ff2Smrg# by a space. 85367ab2ff2Smrgfunc_append_quoted () 85467ab2ff2Smrg{ 85567ab2ff2Smrg func_quote_for_eval "${2}" 85667ab2ff2Smrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 85767ab2ff2Smrg} # func_append_quoted may be replaced by extended shell implementation 85867ab2ff2Smrg 85967ab2ff2Smrg 86067ab2ff2Smrg# func_arith arithmetic-term... 86167ab2ff2Smrgfunc_arith () 86267ab2ff2Smrg{ 86367ab2ff2Smrg func_arith_result=`expr "${@}"` 86467ab2ff2Smrg} # func_arith may be replaced by extended shell implementation 86567ab2ff2Smrg 86667ab2ff2Smrg 86767ab2ff2Smrg# func_len string 86867ab2ff2Smrg# STRING may not start with a hyphen. 86967ab2ff2Smrgfunc_len () 87067ab2ff2Smrg{ 87167ab2ff2Smrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 87267ab2ff2Smrg} # func_len may be replaced by extended shell implementation 87367ab2ff2Smrg 87467ab2ff2Smrg 87567ab2ff2Smrg# func_lo2o object 87667ab2ff2Smrgfunc_lo2o () 87767ab2ff2Smrg{ 87867ab2ff2Smrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 87967ab2ff2Smrg} # func_lo2o may be replaced by extended shell implementation 88067ab2ff2Smrg 88167ab2ff2Smrg 88267ab2ff2Smrg# func_xform libobj-or-source 88367ab2ff2Smrgfunc_xform () 88467ab2ff2Smrg{ 88567ab2ff2Smrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 88667ab2ff2Smrg} # func_xform may be replaced by extended shell implementation 88767ab2ff2Smrg 88867ab2ff2Smrg 889f05b35a2Smrg# func_fatal_configuration arg... 890f05b35a2Smrg# Echo program name prefixed message to standard error, followed by 891f05b35a2Smrg# a configuration failure hint, and exit. 892f05b35a2Smrgfunc_fatal_configuration () 893f05b35a2Smrg{ 894f05b35a2Smrg func_error ${1+"$@"} 895f05b35a2Smrg func_error "See the $PACKAGE documentation for more information." 896f05b35a2Smrg func_fatal_error "Fatal configuration error." 897f05b35a2Smrg} 898e0963edeSmrg 899e0963edeSmrg 900f05b35a2Smrg# func_config 901f05b35a2Smrg# Display the configuration for all the tags in this script. 902f05b35a2Smrgfunc_config () 903f05b35a2Smrg{ 904f05b35a2Smrg re_begincf='^# ### BEGIN LIBTOOL' 905f05b35a2Smrg re_endcf='^# ### END LIBTOOL' 906f05b35a2Smrg 907f05b35a2Smrg # Default configuration. 908f05b35a2Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 909e0963edeSmrg 910e0963edeSmrg # Now print the configurations for the tags. 911e0963edeSmrg for tagname in $taglist; do 912f05b35a2Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 913e0963edeSmrg done 914e0963edeSmrg 915f05b35a2Smrg exit $? 916f05b35a2Smrg} 917e0963edeSmrg 918f05b35a2Smrg# func_features 919f05b35a2Smrg# Display the features supported by this script. 920f05b35a2Smrgfunc_features () 921f05b35a2Smrg{ 92249e108a1Smrg echo "host: $host" 923e0963edeSmrg if test "$build_libtool_libs" = yes; then 92449e108a1Smrg echo "enable shared libraries" 925e0963edeSmrg else 92649e108a1Smrg echo "disable shared libraries" 927e0963edeSmrg fi 928e0963edeSmrg if test "$build_old_libs" = yes; then 92949e108a1Smrg echo "enable static libraries" 930e0963edeSmrg else 93149e108a1Smrg echo "disable static libraries" 932e0963edeSmrg fi 933f05b35a2Smrg 934e0963edeSmrg exit $? 935f05b35a2Smrg} 936e0963edeSmrg 937f05b35a2Smrg# func_enable_tag tagname 938f05b35a2Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 939f05b35a2Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 940f05b35a2Smrg# variable here. 941f05b35a2Smrgfunc_enable_tag () 942f05b35a2Smrg{ 943f05b35a2Smrg # Global variable: 944f05b35a2Smrg tagname="$1" 945e0963edeSmrg 946f05b35a2Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 947f05b35a2Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 948f05b35a2Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 949e0963edeSmrg 950f05b35a2Smrg # Validate tagname. 951f05b35a2Smrg case $tagname in 952f05b35a2Smrg *[!-_A-Za-z0-9,/]*) 953f05b35a2Smrg func_fatal_error "invalid tag name: $tagname" 954f05b35a2Smrg ;; 955f05b35a2Smrg esac 956e0963edeSmrg 957f05b35a2Smrg # Don't test for the "default" C tag, as we know it's 958f05b35a2Smrg # there but not specially marked. 959f05b35a2Smrg case $tagname in 960f05b35a2Smrg CC) ;; 961f05b35a2Smrg *) 962f05b35a2Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 963f05b35a2Smrg taglist="$taglist $tagname" 964f05b35a2Smrg 965f05b35a2Smrg # Evaluate the configuration. Be careful to quote the path 966f05b35a2Smrg # and the sed script, to avoid splitting on whitespace, but 967f05b35a2Smrg # also don't use non-portable quotes within backquotes within 968f05b35a2Smrg # quotes we have to do it in 2 steps: 969f05b35a2Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 970f05b35a2Smrg eval "$extractedcf" 971f05b35a2Smrg else 972f05b35a2Smrg func_error "ignoring unknown tag $tagname" 973f05b35a2Smrg fi 974f05b35a2Smrg ;; 975f05b35a2Smrg esac 976f05b35a2Smrg} 977f05b35a2Smrg 97867ab2ff2Smrg# func_check_version_match 97967ab2ff2Smrg# Ensure that we are using m4 macros, and libtool script from the same 98067ab2ff2Smrg# release of libtool. 98167ab2ff2Smrgfunc_check_version_match () 982f05b35a2Smrg{ 98367ab2ff2Smrg if test "$package_revision" != "$macro_revision"; then 98467ab2ff2Smrg if test "$VERSION" != "$macro_version"; then 98567ab2ff2Smrg if test -z "$macro_version"; then 98667ab2ff2Smrg cat >&2 <<_LT_EOF 98767ab2ff2Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 98867ab2ff2Smrg$progname: definition of this LT_INIT comes from an older release. 98967ab2ff2Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 99067ab2ff2Smrg$progname: and run autoconf again. 99167ab2ff2Smrg_LT_EOF 99267ab2ff2Smrg else 99367ab2ff2Smrg cat >&2 <<_LT_EOF 99467ab2ff2Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 99567ab2ff2Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 99667ab2ff2Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 99767ab2ff2Smrg$progname: and run autoconf again. 99867ab2ff2Smrg_LT_EOF 99967ab2ff2Smrg fi 100067ab2ff2Smrg else 100167ab2ff2Smrg cat >&2 <<_LT_EOF 100267ab2ff2Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 100367ab2ff2Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 100467ab2ff2Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 100567ab2ff2Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 100667ab2ff2Smrg_LT_EOF 100767ab2ff2Smrg fi 1008e0963edeSmrg 100967ab2ff2Smrg exit $EXIT_MISMATCH 101067ab2ff2Smrg fi 101167ab2ff2Smrg} 101267ab2ff2Smrg 101367ab2ff2Smrg 101467ab2ff2Smrg# Shorthand for --mode=foo, only valid as the first argument 101567ab2ff2Smrgcase $1 in 101667ab2ff2Smrgclean|clea|cle|cl) 101767ab2ff2Smrg shift; set dummy --mode clean ${1+"$@"}; shift 101867ab2ff2Smrg ;; 101967ab2ff2Smrgcompile|compil|compi|comp|com|co|c) 102067ab2ff2Smrg shift; set dummy --mode compile ${1+"$@"}; shift 102167ab2ff2Smrg ;; 102267ab2ff2Smrgexecute|execut|execu|exec|exe|ex|e) 102367ab2ff2Smrg shift; set dummy --mode execute ${1+"$@"}; shift 102467ab2ff2Smrg ;; 102567ab2ff2Smrgfinish|finis|fini|fin|fi|f) 102667ab2ff2Smrg shift; set dummy --mode finish ${1+"$@"}; shift 102767ab2ff2Smrg ;; 102867ab2ff2Smrginstall|instal|insta|inst|ins|in|i) 102967ab2ff2Smrg shift; set dummy --mode install ${1+"$@"}; shift 103067ab2ff2Smrg ;; 103167ab2ff2Smrglink|lin|li|l) 103267ab2ff2Smrg shift; set dummy --mode link ${1+"$@"}; shift 103367ab2ff2Smrg ;; 103467ab2ff2Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 103567ab2ff2Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 103667ab2ff2Smrg ;; 103767ab2ff2Smrgesac 1038e0963edeSmrg 103967ab2ff2Smrg 104067ab2ff2Smrg 104167ab2ff2Smrg# Option defaults: 104267ab2ff2Smrgopt_debug=: 104367ab2ff2Smrgopt_dry_run=false 104467ab2ff2Smrgopt_config=false 104567ab2ff2Smrgopt_preserve_dup_deps=false 104667ab2ff2Smrgopt_features=false 104767ab2ff2Smrgopt_finish=false 104867ab2ff2Smrgopt_help=false 104967ab2ff2Smrgopt_help_all=false 105067ab2ff2Smrgopt_silent=: 1051e494fffdSmrgopt_warning=: 105267ab2ff2Smrgopt_verbose=: 105367ab2ff2Smrgopt_silent=false 105467ab2ff2Smrgopt_verbose=false 105567ab2ff2Smrg 105667ab2ff2Smrg 105767ab2ff2Smrg# Parse options once, thoroughly. This comes as soon as possible in the 105867ab2ff2Smrg# script to make things like `--version' happen as quickly as we can. 105967ab2ff2Smrg{ 106067ab2ff2Smrg # this just eases exit handling 106167ab2ff2Smrg while test $# -gt 0; do 1062f05b35a2Smrg opt="$1" 1063f05b35a2Smrg shift 1064f05b35a2Smrg case $opt in 106567ab2ff2Smrg --debug|-x) opt_debug='set -x' 1066f05b35a2Smrg func_echo "enabling shell trace mode" 1067f05b35a2Smrg $opt_debug 1068f05b35a2Smrg ;; 106967ab2ff2Smrg --dry-run|--dryrun|-n) 107067ab2ff2Smrg opt_dry_run=: 1071f05b35a2Smrg ;; 107267ab2ff2Smrg --config) 107367ab2ff2Smrg opt_config=: 107467ab2ff2Smrgfunc_config 107567ab2ff2Smrg ;; 107667ab2ff2Smrg --dlopen|-dlopen) 107767ab2ff2Smrg optarg="$1" 107867ab2ff2Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 107967ab2ff2Smrg}$optarg" 1080f05b35a2Smrg shift 1081f05b35a2Smrg ;; 1082f05b35a2Smrg --preserve-dup-deps) 108367ab2ff2Smrg opt_preserve_dup_deps=: 108449e108a1Smrg ;; 108567ab2ff2Smrg --features) 108667ab2ff2Smrg opt_features=: 108767ab2ff2Smrgfunc_features 1088f05b35a2Smrg ;; 108967ab2ff2Smrg --finish) 109067ab2ff2Smrg opt_finish=: 109167ab2ff2Smrgset dummy --mode finish ${1+"$@"}; shift 109267ab2ff2Smrg ;; 109367ab2ff2Smrg --help) 109467ab2ff2Smrg opt_help=: 109567ab2ff2Smrg ;; 109667ab2ff2Smrg --help-all) 109767ab2ff2Smrg opt_help_all=: 109867ab2ff2Smrgopt_help=': help-all' 109967ab2ff2Smrg ;; 110067ab2ff2Smrg --mode) 110167ab2ff2Smrg test $# = 0 && func_missing_arg $opt && break 110267ab2ff2Smrg optarg="$1" 110367ab2ff2Smrg opt_mode="$optarg" 110467ab2ff2Smrgcase $optarg in 110567ab2ff2Smrg # Valid mode arguments: 110667ab2ff2Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 110767ab2ff2Smrg 110867ab2ff2Smrg # Catch anything else as an error 110967ab2ff2Smrg *) func_error "invalid argument for $opt" 111067ab2ff2Smrg exit_cmd=exit 111167ab2ff2Smrg break 111267ab2ff2Smrg ;; 111367ab2ff2Smrgesac 111467ab2ff2Smrg shift 111567ab2ff2Smrg ;; 111667ab2ff2Smrg --no-silent|--no-quiet) 1117f05b35a2Smrg opt_silent=false 1118e494fffdSmrgfunc_append preserve_args " $opt" 1119e494fffdSmrg ;; 1120e494fffdSmrg --no-warning|--no-warn) 1121e494fffdSmrg opt_warning=false 112267ab2ff2Smrgfunc_append preserve_args " $opt" 112349e108a1Smrg ;; 112467ab2ff2Smrg --no-verbose) 112549e108a1Smrg opt_verbose=false 112667ab2ff2Smrgfunc_append preserve_args " $opt" 1127f05b35a2Smrg ;; 112867ab2ff2Smrg --silent|--quiet) 112967ab2ff2Smrg opt_silent=: 113067ab2ff2Smrgfunc_append preserve_args " $opt" 113167ab2ff2Smrg opt_verbose=false 113267ab2ff2Smrg ;; 113367ab2ff2Smrg --verbose|-v) 113467ab2ff2Smrg opt_verbose=: 113567ab2ff2Smrgfunc_append preserve_args " $opt" 113667ab2ff2Smrgopt_silent=false 113767ab2ff2Smrg ;; 113867ab2ff2Smrg --tag) 113967ab2ff2Smrg test $# = 0 && func_missing_arg $opt && break 114067ab2ff2Smrg optarg="$1" 114167ab2ff2Smrg opt_tag="$optarg" 114267ab2ff2Smrgfunc_append preserve_args " $opt $optarg" 114367ab2ff2Smrgfunc_enable_tag "$optarg" 1144f05b35a2Smrg shift 1145f05b35a2Smrg ;; 1146f05b35a2Smrg 114767ab2ff2Smrg -\?|-h) func_usage ;; 114867ab2ff2Smrg --help) func_help ;; 114967ab2ff2Smrg --version) func_version ;; 115067ab2ff2Smrg 1151f05b35a2Smrg # Separate optargs to long options: 115267ab2ff2Smrg --*=*) 115367ab2ff2Smrg func_split_long_opt "$opt" 115467ab2ff2Smrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 1155f05b35a2Smrg shift 1156f05b35a2Smrg ;; 1157f05b35a2Smrg 115867ab2ff2Smrg # Separate non-argument short options: 115967ab2ff2Smrg -\?*|-h*|-n*|-v*) 116067ab2ff2Smrg func_split_short_opt "$opt" 116167ab2ff2Smrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 116267ab2ff2Smrg shift 1163f05b35a2Smrg ;; 116467ab2ff2Smrg 116567ab2ff2Smrg --) break ;; 116667ab2ff2Smrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 116767ab2ff2Smrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 1168f05b35a2Smrg esac 1169f05b35a2Smrg done 1170f05b35a2Smrg 117167ab2ff2Smrg # Validate options: 117267ab2ff2Smrg 117367ab2ff2Smrg # save first non-option argument 117467ab2ff2Smrg if test "$#" -gt 0; then 117567ab2ff2Smrg nonopt="$opt" 117667ab2ff2Smrg shift 117767ab2ff2Smrg fi 117867ab2ff2Smrg 117967ab2ff2Smrg # preserve --debug 118067ab2ff2Smrg test "$opt_debug" = : || func_append preserve_args " --debug" 1181f05b35a2Smrg 1182f05b35a2Smrg case $host in 1183f05b35a2Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 1184f05b35a2Smrg # don't eliminate duplications in $postdeps and $predeps 1185f05b35a2Smrg opt_duplicate_compiler_generated_deps=: 1186e0963edeSmrg ;; 1187e0963edeSmrg *) 118867ab2ff2Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 1189f05b35a2Smrg ;; 1190f05b35a2Smrg esac 1191e0963edeSmrg 119267ab2ff2Smrg $opt_help || { 119367ab2ff2Smrg # Sanity checks first: 119467ab2ff2Smrg func_check_version_match 1195f05b35a2Smrg 119667ab2ff2Smrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 119767ab2ff2Smrg func_fatal_configuration "not configured to build any kind of library" 1198f05b35a2Smrg fi 1199f05b35a2Smrg 120067ab2ff2Smrg # Darwin sucks 120167ab2ff2Smrg eval std_shrext=\"$shrext_cmds\" 1202f05b35a2Smrg 120367ab2ff2Smrg # Only execute mode is allowed to have -dlopen flags. 120467ab2ff2Smrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 120567ab2ff2Smrg func_error "unrecognized option \`-dlopen'" 120667ab2ff2Smrg $ECHO "$help" 1>&2 120767ab2ff2Smrg exit $EXIT_FAILURE 120867ab2ff2Smrg fi 1209f05b35a2Smrg 121067ab2ff2Smrg # Change the help message to a mode-specific one. 121167ab2ff2Smrg generic_help="$help" 121267ab2ff2Smrg help="Try \`$progname --help --mode=$opt_mode' for more information." 121367ab2ff2Smrg } 1214f05b35a2Smrg 1215f05b35a2Smrg 121667ab2ff2Smrg # Bail if the options were screwed 121767ab2ff2Smrg $exit_cmd $EXIT_FAILURE 121867ab2ff2Smrg} 1219f05b35a2Smrg 1220f05b35a2Smrg 1221e0963edeSmrg 1222e0963edeSmrg 122367ab2ff2Smrg## ----------- ## 122467ab2ff2Smrg## Main. ## 122567ab2ff2Smrg## ----------- ## 1226e0963edeSmrg 1227f05b35a2Smrg# func_lalib_p file 1228f05b35a2Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 1229f05b35a2Smrg# This function is only a basic sanity check; it will hardly flush out 1230f05b35a2Smrg# determined imposters. 1231f05b35a2Smrgfunc_lalib_p () 1232f05b35a2Smrg{ 1233f05b35a2Smrg test -f "$1" && 1234f05b35a2Smrg $SED -e 4q "$1" 2>/dev/null \ 1235f05b35a2Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 1236f05b35a2Smrg} 1237e0963edeSmrg 1238f05b35a2Smrg# func_lalib_unsafe_p file 1239f05b35a2Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 1240f05b35a2Smrg# This function implements the same check as func_lalib_p without 1241f05b35a2Smrg# resorting to external programs. To this end, it redirects stdin and 1242f05b35a2Smrg# closes it afterwards, without saving the original file descriptor. 1243f05b35a2Smrg# As a safety measure, use it only where a negative result would be 1244f05b35a2Smrg# fatal anyway. Works if `file' does not exist. 1245f05b35a2Smrgfunc_lalib_unsafe_p () 1246f05b35a2Smrg{ 1247f05b35a2Smrg lalib_p=no 1248f05b35a2Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 1249f05b35a2Smrg for lalib_p_l in 1 2 3 4 1250f05b35a2Smrg do 1251f05b35a2Smrg read lalib_p_line 1252f05b35a2Smrg case "$lalib_p_line" in 1253f05b35a2Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 1254f05b35a2Smrg esac 1255f05b35a2Smrg done 1256f05b35a2Smrg exec 0<&5 5<&- 1257f05b35a2Smrg fi 1258f05b35a2Smrg test "$lalib_p" = yes 1259f05b35a2Smrg} 1260e0963edeSmrg 1261f05b35a2Smrg# func_ltwrapper_script_p file 1262f05b35a2Smrg# True iff FILE is a libtool wrapper script 1263f05b35a2Smrg# This function is only a basic sanity check; it will hardly flush out 1264f05b35a2Smrg# determined imposters. 1265f05b35a2Smrgfunc_ltwrapper_script_p () 1266f05b35a2Smrg{ 1267f05b35a2Smrg func_lalib_p "$1" 1268f05b35a2Smrg} 1269e0963edeSmrg 1270f05b35a2Smrg# func_ltwrapper_executable_p file 1271f05b35a2Smrg# True iff FILE is a libtool wrapper executable 1272f05b35a2Smrg# This function is only a basic sanity check; it will hardly flush out 1273f05b35a2Smrg# determined imposters. 1274f05b35a2Smrgfunc_ltwrapper_executable_p () 1275f05b35a2Smrg{ 1276f05b35a2Smrg func_ltwrapper_exec_suffix= 1277f05b35a2Smrg case $1 in 1278f05b35a2Smrg *.exe) ;; 1279f05b35a2Smrg *) func_ltwrapper_exec_suffix=.exe ;; 1280f05b35a2Smrg esac 1281f05b35a2Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 1282f05b35a2Smrg} 1283e0963edeSmrg 1284f05b35a2Smrg# func_ltwrapper_scriptname file 1285f05b35a2Smrg# Assumes file is an ltwrapper_executable 1286f05b35a2Smrg# uses $file to determine the appropriate filename for a 1287f05b35a2Smrg# temporary ltwrapper_script. 1288f05b35a2Smrgfunc_ltwrapper_scriptname () 1289f05b35a2Smrg{ 129067ab2ff2Smrg func_dirname_and_basename "$1" "" "." 129167ab2ff2Smrg func_stripname '' '.exe' "$func_basename_result" 129267ab2ff2Smrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 1293f05b35a2Smrg} 1294f05b35a2Smrg 1295f05b35a2Smrg# func_ltwrapper_p file 1296f05b35a2Smrg# True iff FILE is a libtool wrapper script or wrapper executable 1297f05b35a2Smrg# This function is only a basic sanity check; it will hardly flush out 1298f05b35a2Smrg# determined imposters. 1299f05b35a2Smrgfunc_ltwrapper_p () 1300f05b35a2Smrg{ 1301f05b35a2Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 1302f05b35a2Smrg} 1303f05b35a2Smrg 1304f05b35a2Smrg 1305f05b35a2Smrg# func_execute_cmds commands fail_cmd 1306f05b35a2Smrg# Execute tilde-delimited COMMANDS. 1307f05b35a2Smrg# If FAIL_CMD is given, eval that upon failure. 1308f05b35a2Smrg# FAIL_CMD may read-access the current command in variable CMD! 1309f05b35a2Smrgfunc_execute_cmds () 1310f05b35a2Smrg{ 1311f05b35a2Smrg $opt_debug 1312f05b35a2Smrg save_ifs=$IFS; IFS='~' 1313f05b35a2Smrg for cmd in $1; do 1314f05b35a2Smrg IFS=$save_ifs 1315f05b35a2Smrg eval cmd=\"$cmd\" 1316f05b35a2Smrg func_show_eval "$cmd" "${2-:}" 1317f05b35a2Smrg done 1318f05b35a2Smrg IFS=$save_ifs 1319f05b35a2Smrg} 1320f05b35a2Smrg 1321f05b35a2Smrg 1322f05b35a2Smrg# func_source file 1323f05b35a2Smrg# Source FILE, adding directory component if necessary. 1324f05b35a2Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 1325f05b35a2Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 1326f05b35a2Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 1327f05b35a2Smrg# `FILE.' does not work on cygwin managed mounts. 1328f05b35a2Smrgfunc_source () 1329f05b35a2Smrg{ 1330f05b35a2Smrg $opt_debug 1331f05b35a2Smrg case $1 in 1332f05b35a2Smrg */* | *\\*) . "$1" ;; 1333f05b35a2Smrg *) . "./$1" ;; 1334f05b35a2Smrg esac 1335f05b35a2Smrg} 1336f05b35a2Smrg 1337f05b35a2Smrg 133867ab2ff2Smrg# func_resolve_sysroot PATH 133967ab2ff2Smrg# Replace a leading = in PATH with a sysroot. Store the result into 134067ab2ff2Smrg# func_resolve_sysroot_result 134167ab2ff2Smrgfunc_resolve_sysroot () 134267ab2ff2Smrg{ 134367ab2ff2Smrg func_resolve_sysroot_result=$1 134467ab2ff2Smrg case $func_resolve_sysroot_result in 134567ab2ff2Smrg =*) 134667ab2ff2Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 134767ab2ff2Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 134867ab2ff2Smrg ;; 134967ab2ff2Smrg esac 135067ab2ff2Smrg} 135167ab2ff2Smrg 135267ab2ff2Smrg# func_replace_sysroot PATH 135367ab2ff2Smrg# If PATH begins with the sysroot, replace it with = and 135467ab2ff2Smrg# store the result into func_replace_sysroot_result. 135567ab2ff2Smrgfunc_replace_sysroot () 135667ab2ff2Smrg{ 135767ab2ff2Smrg case "$lt_sysroot:$1" in 135867ab2ff2Smrg ?*:"$lt_sysroot"*) 135967ab2ff2Smrg func_stripname "$lt_sysroot" '' "$1" 136067ab2ff2Smrg func_replace_sysroot_result="=$func_stripname_result" 136167ab2ff2Smrg ;; 136267ab2ff2Smrg *) 136367ab2ff2Smrg # Including no sysroot. 136467ab2ff2Smrg func_replace_sysroot_result=$1 136567ab2ff2Smrg ;; 136667ab2ff2Smrg esac 136767ab2ff2Smrg} 136867ab2ff2Smrg 1369f05b35a2Smrg# func_infer_tag arg 1370f05b35a2Smrg# Infer tagged configuration to use if any are available and 1371f05b35a2Smrg# if one wasn't chosen via the "--tag" command line option. 1372f05b35a2Smrg# Only attempt this if the compiler in the base compile 1373f05b35a2Smrg# command doesn't match the default compiler. 1374f05b35a2Smrg# arg is usually of the form 'gcc ...' 1375f05b35a2Smrgfunc_infer_tag () 1376f05b35a2Smrg{ 1377f05b35a2Smrg $opt_debug 1378f05b35a2Smrg if test -n "$available_tags" && test -z "$tagname"; then 1379f05b35a2Smrg CC_quoted= 1380f05b35a2Smrg for arg in $CC; do 138167ab2ff2Smrg func_append_quoted CC_quoted "$arg" 1382f05b35a2Smrg done 138349e108a1Smrg CC_expanded=`func_echo_all $CC` 138449e108a1Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 1385f05b35a2Smrg case $@ in 1386f05b35a2Smrg # Blanks in the command may have been stripped by the calling shell, 1387f05b35a2Smrg # but not from the CC environment variable when configure was run. 138849e108a1Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 138949e108a1Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 1390f05b35a2Smrg # Blanks at the start of $base_compile will cause this to fail 1391f05b35a2Smrg # if we don't check for them as well. 1392f05b35a2Smrg *) 1393f05b35a2Smrg for z in $available_tags; do 1394f05b35a2Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 1395f05b35a2Smrg # Evaluate the configuration. 1396f05b35a2Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 1397f05b35a2Smrg CC_quoted= 1398f05b35a2Smrg for arg in $CC; do 1399f05b35a2Smrg # Double-quote args containing other shell metacharacters. 140067ab2ff2Smrg func_append_quoted CC_quoted "$arg" 1401f05b35a2Smrg done 140249e108a1Smrg CC_expanded=`func_echo_all $CC` 140349e108a1Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 1404f05b35a2Smrg case "$@ " in 140549e108a1Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 140649e108a1Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 1407f05b35a2Smrg # The compiler in the base compile command matches 1408f05b35a2Smrg # the one in the tagged configuration. 1409f05b35a2Smrg # Assume this is the tagged configuration we want. 1410f05b35a2Smrg tagname=$z 1411f05b35a2Smrg break 1412f05b35a2Smrg ;; 1413f05b35a2Smrg esac 1414f05b35a2Smrg fi 1415f05b35a2Smrg done 1416f05b35a2Smrg # If $tagname still isn't set, then no tagged configuration 1417f05b35a2Smrg # was found and let the user know that the "--tag" command 1418f05b35a2Smrg # line option must be used. 1419f05b35a2Smrg if test -z "$tagname"; then 1420f05b35a2Smrg func_echo "unable to infer tagged configuration" 1421f05b35a2Smrg func_fatal_error "specify a tag with \`--tag'" 1422f05b35a2Smrg# else 1423f05b35a2Smrg# func_verbose "using $tagname tagged configuration" 1424f05b35a2Smrg fi 1425f05b35a2Smrg ;; 1426f05b35a2Smrg esac 1427f05b35a2Smrg fi 1428f05b35a2Smrg} 1429f05b35a2Smrg 1430f05b35a2Smrg 1431f05b35a2Smrg 143267ab2ff2Smrg# func_write_libtool_object output_name pic_name nonpic_name 143367ab2ff2Smrg# Create a libtool object file (analogous to a ".la" file), 143467ab2ff2Smrg# but don't create it if we're doing a dry run. 143567ab2ff2Smrgfunc_write_libtool_object () 143667ab2ff2Smrg{ 143767ab2ff2Smrg write_libobj=${1} 143867ab2ff2Smrg if test "$build_libtool_libs" = yes; then 143967ab2ff2Smrg write_lobj=\'${2}\' 144067ab2ff2Smrg else 144167ab2ff2Smrg write_lobj=none 144267ab2ff2Smrg fi 144367ab2ff2Smrg 144467ab2ff2Smrg if test "$build_old_libs" = yes; then 144567ab2ff2Smrg write_oldobj=\'${3}\' 144667ab2ff2Smrg else 144767ab2ff2Smrg write_oldobj=none 144867ab2ff2Smrg fi 144967ab2ff2Smrg 145067ab2ff2Smrg $opt_dry_run || { 145167ab2ff2Smrg cat >${write_libobj}T <<EOF 145267ab2ff2Smrg# $write_libobj - a libtool object file 145367ab2ff2Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 145467ab2ff2Smrg# 145567ab2ff2Smrg# Please DO NOT delete this file! 145667ab2ff2Smrg# It is necessary for linking the library. 145767ab2ff2Smrg 145867ab2ff2Smrg# Name of the PIC object. 145967ab2ff2Smrgpic_object=$write_lobj 146067ab2ff2Smrg 146167ab2ff2Smrg# Name of the non-PIC object 146267ab2ff2Smrgnon_pic_object=$write_oldobj 146367ab2ff2Smrg 146467ab2ff2SmrgEOF 146567ab2ff2Smrg $MV "${write_libobj}T" "${write_libobj}" 146667ab2ff2Smrg } 146767ab2ff2Smrg} 146867ab2ff2Smrg 146967ab2ff2Smrg 147067ab2ff2Smrg################################################## 147167ab2ff2Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 147267ab2ff2Smrg################################################## 147367ab2ff2Smrg 147467ab2ff2Smrg# func_convert_core_file_wine_to_w32 ARG 147567ab2ff2Smrg# Helper function used by file name conversion functions when $build is *nix, 147667ab2ff2Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 147767ab2ff2Smrg# correctly configured wine environment available, with the winepath program 147867ab2ff2Smrg# in $build's $PATH. 147967ab2ff2Smrg# 148067ab2ff2Smrg# ARG is the $build file name to be converted to w32 format. 148167ab2ff2Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 148267ab2ff2Smrg# be empty on error (or when ARG is empty) 148367ab2ff2Smrgfunc_convert_core_file_wine_to_w32 () 148467ab2ff2Smrg{ 148567ab2ff2Smrg $opt_debug 148667ab2ff2Smrg func_convert_core_file_wine_to_w32_result="$1" 148767ab2ff2Smrg if test -n "$1"; then 148867ab2ff2Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 148967ab2ff2Smrg # are forced to check the contents of stdout. On the other hand, if the 149067ab2ff2Smrg # command is not found, the shell will set an exit code of 127 and print 149167ab2ff2Smrg # *an error message* to stdout. So we must check for both error code of 149267ab2ff2Smrg # zero AND non-empty stdout, which explains the odd construction: 149367ab2ff2Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 149467ab2ff2Smrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 149567ab2ff2Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 149667ab2ff2Smrg $SED -e "$lt_sed_naive_backslashify"` 149767ab2ff2Smrg else 149867ab2ff2Smrg func_convert_core_file_wine_to_w32_result= 149967ab2ff2Smrg fi 150067ab2ff2Smrg fi 150167ab2ff2Smrg} 150267ab2ff2Smrg# end: func_convert_core_file_wine_to_w32 150367ab2ff2Smrg 150467ab2ff2Smrg 150567ab2ff2Smrg# func_convert_core_path_wine_to_w32 ARG 150667ab2ff2Smrg# Helper function used by path conversion functions when $build is *nix, and 150767ab2ff2Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 150867ab2ff2Smrg# configured wine environment available, with the winepath program in $build's 150967ab2ff2Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 151067ab2ff2Smrg# 151167ab2ff2Smrg# ARG is path to be converted from $build format to win32. 151267ab2ff2Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 151367ab2ff2Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 151467ab2ff2Smrg# are convertible, then the result may be empty. 151567ab2ff2Smrgfunc_convert_core_path_wine_to_w32 () 151667ab2ff2Smrg{ 151767ab2ff2Smrg $opt_debug 151867ab2ff2Smrg # unfortunately, winepath doesn't convert paths, only file names 151967ab2ff2Smrg func_convert_core_path_wine_to_w32_result="" 152067ab2ff2Smrg if test -n "$1"; then 152167ab2ff2Smrg oldIFS=$IFS 152267ab2ff2Smrg IFS=: 152367ab2ff2Smrg for func_convert_core_path_wine_to_w32_f in $1; do 152467ab2ff2Smrg IFS=$oldIFS 152567ab2ff2Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 152667ab2ff2Smrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 152767ab2ff2Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 152867ab2ff2Smrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 152967ab2ff2Smrg else 153067ab2ff2Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 153167ab2ff2Smrg fi 153267ab2ff2Smrg fi 153367ab2ff2Smrg done 153467ab2ff2Smrg IFS=$oldIFS 153567ab2ff2Smrg fi 153667ab2ff2Smrg} 153767ab2ff2Smrg# end: func_convert_core_path_wine_to_w32 153867ab2ff2Smrg 153967ab2ff2Smrg 154067ab2ff2Smrg# func_cygpath ARGS... 154167ab2ff2Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 154267ab2ff2Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 154367ab2ff2Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 154467ab2ff2Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 154567ab2ff2Smrg# file name or path is assumed to be in w32 format, as previously converted 154667ab2ff2Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 154767ab2ff2Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 154867ab2ff2Smrg# Cygwin format). Returns an empty string on error. 154967ab2ff2Smrg# 155067ab2ff2Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 155167ab2ff2Smrg# be converted. 155267ab2ff2Smrg# 155367ab2ff2Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 155467ab2ff2Smrg# environment variable; do not put it in $PATH. 155567ab2ff2Smrgfunc_cygpath () 155667ab2ff2Smrg{ 155767ab2ff2Smrg $opt_debug 155867ab2ff2Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 155967ab2ff2Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 156067ab2ff2Smrg if test "$?" -ne 0; then 156167ab2ff2Smrg # on failure, ensure result is empty 156267ab2ff2Smrg func_cygpath_result= 156367ab2ff2Smrg fi 156467ab2ff2Smrg else 156567ab2ff2Smrg func_cygpath_result= 156667ab2ff2Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 156767ab2ff2Smrg fi 156867ab2ff2Smrg} 156967ab2ff2Smrg#end: func_cygpath 157067ab2ff2Smrg 157167ab2ff2Smrg 157267ab2ff2Smrg# func_convert_core_msys_to_w32 ARG 157367ab2ff2Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 157467ab2ff2Smrg# result in func_convert_core_msys_to_w32_result. 157567ab2ff2Smrgfunc_convert_core_msys_to_w32 () 157667ab2ff2Smrg{ 157767ab2ff2Smrg $opt_debug 157867ab2ff2Smrg # awkward: cmd appends spaces to result 157967ab2ff2Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 158067ab2ff2Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 158167ab2ff2Smrg} 158267ab2ff2Smrg#end: func_convert_core_msys_to_w32 158367ab2ff2Smrg 158467ab2ff2Smrg 158567ab2ff2Smrg# func_convert_file_check ARG1 ARG2 158667ab2ff2Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 158767ab2ff2Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 158867ab2ff2Smrg# func_to_host_file_result to ARG1). 158967ab2ff2Smrgfunc_convert_file_check () 159067ab2ff2Smrg{ 159167ab2ff2Smrg $opt_debug 159267ab2ff2Smrg if test -z "$2" && test -n "$1" ; then 159367ab2ff2Smrg func_error "Could not determine host file name corresponding to" 159467ab2ff2Smrg func_error " \`$1'" 159567ab2ff2Smrg func_error "Continuing, but uninstalled executables may not work." 159667ab2ff2Smrg # Fallback: 159767ab2ff2Smrg func_to_host_file_result="$1" 159867ab2ff2Smrg fi 159967ab2ff2Smrg} 160067ab2ff2Smrg# end func_convert_file_check 160167ab2ff2Smrg 160267ab2ff2Smrg 160367ab2ff2Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 160467ab2ff2Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 160567ab2ff2Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 160667ab2ff2Smrg# func_to_host_file_result to a simplistic fallback value (see below). 160767ab2ff2Smrgfunc_convert_path_check () 160867ab2ff2Smrg{ 160967ab2ff2Smrg $opt_debug 161067ab2ff2Smrg if test -z "$4" && test -n "$3"; then 161167ab2ff2Smrg func_error "Could not determine the host path corresponding to" 161267ab2ff2Smrg func_error " \`$3'" 161367ab2ff2Smrg func_error "Continuing, but uninstalled executables may not work." 161467ab2ff2Smrg # Fallback. This is a deliberately simplistic "conversion" and 161567ab2ff2Smrg # should not be "improved". See libtool.info. 161667ab2ff2Smrg if test "x$1" != "x$2"; then 161767ab2ff2Smrg lt_replace_pathsep_chars="s|$1|$2|g" 161867ab2ff2Smrg func_to_host_path_result=`echo "$3" | 161967ab2ff2Smrg $SED -e "$lt_replace_pathsep_chars"` 162067ab2ff2Smrg else 162167ab2ff2Smrg func_to_host_path_result="$3" 162267ab2ff2Smrg fi 162367ab2ff2Smrg fi 162467ab2ff2Smrg} 162567ab2ff2Smrg# end func_convert_path_check 162667ab2ff2Smrg 162767ab2ff2Smrg 162867ab2ff2Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 162967ab2ff2Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 163067ab2ff2Smrg# and appending REPL if ORIG matches BACKPAT. 163167ab2ff2Smrgfunc_convert_path_front_back_pathsep () 163267ab2ff2Smrg{ 163367ab2ff2Smrg $opt_debug 163467ab2ff2Smrg case $4 in 163567ab2ff2Smrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 163667ab2ff2Smrg ;; 163767ab2ff2Smrg esac 163867ab2ff2Smrg case $4 in 163967ab2ff2Smrg $2 ) func_append func_to_host_path_result "$3" 164067ab2ff2Smrg ;; 164167ab2ff2Smrg esac 164267ab2ff2Smrg} 164367ab2ff2Smrg# end func_convert_path_front_back_pathsep 164467ab2ff2Smrg 164567ab2ff2Smrg 164667ab2ff2Smrg################################################## 164767ab2ff2Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 164867ab2ff2Smrg################################################## 164967ab2ff2Smrg# invoked via `$to_host_file_cmd ARG' 165067ab2ff2Smrg# 165167ab2ff2Smrg# In each case, ARG is the path to be converted from $build to $host format. 165267ab2ff2Smrg# Result will be available in $func_to_host_file_result. 165367ab2ff2Smrg 165467ab2ff2Smrg 165567ab2ff2Smrg# func_to_host_file ARG 165667ab2ff2Smrg# Converts the file name ARG from $build format to $host format. Return result 165767ab2ff2Smrg# in func_to_host_file_result. 165867ab2ff2Smrgfunc_to_host_file () 165967ab2ff2Smrg{ 166067ab2ff2Smrg $opt_debug 166167ab2ff2Smrg $to_host_file_cmd "$1" 166267ab2ff2Smrg} 166367ab2ff2Smrg# end func_to_host_file 166467ab2ff2Smrg 166567ab2ff2Smrg 166667ab2ff2Smrg# func_to_tool_file ARG LAZY 166767ab2ff2Smrg# converts the file name ARG from $build format to toolchain format. Return 166867ab2ff2Smrg# result in func_to_tool_file_result. If the conversion in use is listed 166967ab2ff2Smrg# in (the comma separated) LAZY, no conversion takes place. 167067ab2ff2Smrgfunc_to_tool_file () 167167ab2ff2Smrg{ 167267ab2ff2Smrg $opt_debug 167367ab2ff2Smrg case ,$2, in 167467ab2ff2Smrg *,"$to_tool_file_cmd",*) 167567ab2ff2Smrg func_to_tool_file_result=$1 167667ab2ff2Smrg ;; 167767ab2ff2Smrg *) 167867ab2ff2Smrg $to_tool_file_cmd "$1" 167967ab2ff2Smrg func_to_tool_file_result=$func_to_host_file_result 168067ab2ff2Smrg ;; 168167ab2ff2Smrg esac 168267ab2ff2Smrg} 168367ab2ff2Smrg# end func_to_tool_file 168467ab2ff2Smrg 168567ab2ff2Smrg 168667ab2ff2Smrg# func_convert_file_noop ARG 168767ab2ff2Smrg# Copy ARG to func_to_host_file_result. 168867ab2ff2Smrgfunc_convert_file_noop () 168967ab2ff2Smrg{ 169067ab2ff2Smrg func_to_host_file_result="$1" 169167ab2ff2Smrg} 169267ab2ff2Smrg# end func_convert_file_noop 169367ab2ff2Smrg 169467ab2ff2Smrg 169567ab2ff2Smrg# func_convert_file_msys_to_w32 ARG 169667ab2ff2Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 169767ab2ff2Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 169867ab2ff2Smrg# func_to_host_file_result. 169967ab2ff2Smrgfunc_convert_file_msys_to_w32 () 170067ab2ff2Smrg{ 170167ab2ff2Smrg $opt_debug 170267ab2ff2Smrg func_to_host_file_result="$1" 170367ab2ff2Smrg if test -n "$1"; then 170467ab2ff2Smrg func_convert_core_msys_to_w32 "$1" 170567ab2ff2Smrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 170667ab2ff2Smrg fi 170767ab2ff2Smrg func_convert_file_check "$1" "$func_to_host_file_result" 170867ab2ff2Smrg} 170967ab2ff2Smrg# end func_convert_file_msys_to_w32 171067ab2ff2Smrg 171167ab2ff2Smrg 171267ab2ff2Smrg# func_convert_file_cygwin_to_w32 ARG 171367ab2ff2Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 171467ab2ff2Smrg# func_to_host_file_result. 171567ab2ff2Smrgfunc_convert_file_cygwin_to_w32 () 171667ab2ff2Smrg{ 171767ab2ff2Smrg $opt_debug 171867ab2ff2Smrg func_to_host_file_result="$1" 171967ab2ff2Smrg if test -n "$1"; then 172067ab2ff2Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 172167ab2ff2Smrg # LT_CYGPATH in this case. 172267ab2ff2Smrg func_to_host_file_result=`cygpath -m "$1"` 172367ab2ff2Smrg fi 172467ab2ff2Smrg func_convert_file_check "$1" "$func_to_host_file_result" 172567ab2ff2Smrg} 172667ab2ff2Smrg# end func_convert_file_cygwin_to_w32 172767ab2ff2Smrg 172867ab2ff2Smrg 172967ab2ff2Smrg# func_convert_file_nix_to_w32 ARG 173067ab2ff2Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 173167ab2ff2Smrg# and a working winepath. Returns result in func_to_host_file_result. 173267ab2ff2Smrgfunc_convert_file_nix_to_w32 () 173367ab2ff2Smrg{ 173467ab2ff2Smrg $opt_debug 173567ab2ff2Smrg func_to_host_file_result="$1" 173667ab2ff2Smrg if test -n "$1"; then 173767ab2ff2Smrg func_convert_core_file_wine_to_w32 "$1" 173867ab2ff2Smrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 173967ab2ff2Smrg fi 174067ab2ff2Smrg func_convert_file_check "$1" "$func_to_host_file_result" 174167ab2ff2Smrg} 174267ab2ff2Smrg# end func_convert_file_nix_to_w32 174367ab2ff2Smrg 174467ab2ff2Smrg 174567ab2ff2Smrg# func_convert_file_msys_to_cygwin ARG 174667ab2ff2Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 174767ab2ff2Smrg# Returns result in func_to_host_file_result. 174867ab2ff2Smrgfunc_convert_file_msys_to_cygwin () 174967ab2ff2Smrg{ 175067ab2ff2Smrg $opt_debug 175167ab2ff2Smrg func_to_host_file_result="$1" 175267ab2ff2Smrg if test -n "$1"; then 175367ab2ff2Smrg func_convert_core_msys_to_w32 "$1" 175467ab2ff2Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 175567ab2ff2Smrg func_to_host_file_result="$func_cygpath_result" 175667ab2ff2Smrg fi 175767ab2ff2Smrg func_convert_file_check "$1" "$func_to_host_file_result" 175867ab2ff2Smrg} 175967ab2ff2Smrg# end func_convert_file_msys_to_cygwin 176067ab2ff2Smrg 176167ab2ff2Smrg 176267ab2ff2Smrg# func_convert_file_nix_to_cygwin ARG 176367ab2ff2Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 176467ab2ff2Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 176567ab2ff2Smrg# in func_to_host_file_result. 176667ab2ff2Smrgfunc_convert_file_nix_to_cygwin () 176767ab2ff2Smrg{ 176867ab2ff2Smrg $opt_debug 176967ab2ff2Smrg func_to_host_file_result="$1" 177067ab2ff2Smrg if test -n "$1"; then 177167ab2ff2Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 177267ab2ff2Smrg func_convert_core_file_wine_to_w32 "$1" 177367ab2ff2Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 177467ab2ff2Smrg func_to_host_file_result="$func_cygpath_result" 177567ab2ff2Smrg fi 177667ab2ff2Smrg func_convert_file_check "$1" "$func_to_host_file_result" 177767ab2ff2Smrg} 177867ab2ff2Smrg# end func_convert_file_nix_to_cygwin 177967ab2ff2Smrg 178067ab2ff2Smrg 178167ab2ff2Smrg############################################# 178267ab2ff2Smrg# $build to $host PATH CONVERSION FUNCTIONS # 178367ab2ff2Smrg############################################# 178467ab2ff2Smrg# invoked via `$to_host_path_cmd ARG' 178567ab2ff2Smrg# 178667ab2ff2Smrg# In each case, ARG is the path to be converted from $build to $host format. 178767ab2ff2Smrg# The result will be available in $func_to_host_path_result. 178867ab2ff2Smrg# 178967ab2ff2Smrg# Path separators are also converted from $build format to $host format. If 179067ab2ff2Smrg# ARG begins or ends with a path separator character, it is preserved (but 179167ab2ff2Smrg# converted to $host format) on output. 179267ab2ff2Smrg# 179367ab2ff2Smrg# All path conversion functions are named using the following convention: 179467ab2ff2Smrg# file name conversion function : func_convert_file_X_to_Y () 179567ab2ff2Smrg# path conversion function : func_convert_path_X_to_Y () 179667ab2ff2Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 179767ab2ff2Smrg# same. If conversion functions are added for new $build/$host combinations, 179867ab2ff2Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 179967ab2ff2Smrg# will break. 180067ab2ff2Smrg 180167ab2ff2Smrg 180267ab2ff2Smrg# func_init_to_host_path_cmd 180367ab2ff2Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 180467ab2ff2Smrg# appropriate value, based on the value of $to_host_file_cmd. 180567ab2ff2Smrgto_host_path_cmd= 180667ab2ff2Smrgfunc_init_to_host_path_cmd () 180767ab2ff2Smrg{ 180867ab2ff2Smrg $opt_debug 180967ab2ff2Smrg if test -z "$to_host_path_cmd"; then 181067ab2ff2Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 181167ab2ff2Smrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 181267ab2ff2Smrg fi 181367ab2ff2Smrg} 181467ab2ff2Smrg 181567ab2ff2Smrg 181667ab2ff2Smrg# func_to_host_path ARG 181767ab2ff2Smrg# Converts the path ARG from $build format to $host format. Return result 181867ab2ff2Smrg# in func_to_host_path_result. 181967ab2ff2Smrgfunc_to_host_path () 182067ab2ff2Smrg{ 182167ab2ff2Smrg $opt_debug 182267ab2ff2Smrg func_init_to_host_path_cmd 182367ab2ff2Smrg $to_host_path_cmd "$1" 182467ab2ff2Smrg} 182567ab2ff2Smrg# end func_to_host_path 182667ab2ff2Smrg 182767ab2ff2Smrg 182867ab2ff2Smrg# func_convert_path_noop ARG 182967ab2ff2Smrg# Copy ARG to func_to_host_path_result. 183067ab2ff2Smrgfunc_convert_path_noop () 183167ab2ff2Smrg{ 183267ab2ff2Smrg func_to_host_path_result="$1" 183367ab2ff2Smrg} 183467ab2ff2Smrg# end func_convert_path_noop 183567ab2ff2Smrg 183667ab2ff2Smrg 183767ab2ff2Smrg# func_convert_path_msys_to_w32 ARG 183867ab2ff2Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 183967ab2ff2Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 184067ab2ff2Smrg# func_to_host_path_result. 184167ab2ff2Smrgfunc_convert_path_msys_to_w32 () 1842f05b35a2Smrg{ 184367ab2ff2Smrg $opt_debug 184467ab2ff2Smrg func_to_host_path_result="$1" 184567ab2ff2Smrg if test -n "$1"; then 184667ab2ff2Smrg # Remove leading and trailing path separator characters from ARG. MSYS 184767ab2ff2Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 184867ab2ff2Smrg # and winepath ignores them completely. 184967ab2ff2Smrg func_stripname : : "$1" 185067ab2ff2Smrg func_to_host_path_tmp1=$func_stripname_result 185167ab2ff2Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 185267ab2ff2Smrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 185367ab2ff2Smrg func_convert_path_check : ";" \ 185467ab2ff2Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 185567ab2ff2Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 185667ab2ff2Smrg fi 185767ab2ff2Smrg} 185867ab2ff2Smrg# end func_convert_path_msys_to_w32 1859f05b35a2Smrg 1860f05b35a2Smrg 186167ab2ff2Smrg# func_convert_path_cygwin_to_w32 ARG 186267ab2ff2Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 186367ab2ff2Smrg# func_to_host_file_result. 186467ab2ff2Smrgfunc_convert_path_cygwin_to_w32 () 186567ab2ff2Smrg{ 186667ab2ff2Smrg $opt_debug 186767ab2ff2Smrg func_to_host_path_result="$1" 186867ab2ff2Smrg if test -n "$1"; then 186967ab2ff2Smrg # See func_convert_path_msys_to_w32: 187067ab2ff2Smrg func_stripname : : "$1" 187167ab2ff2Smrg func_to_host_path_tmp1=$func_stripname_result 187267ab2ff2Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 187367ab2ff2Smrg func_convert_path_check : ";" \ 187467ab2ff2Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 187567ab2ff2Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 187667ab2ff2Smrg fi 187767ab2ff2Smrg} 187867ab2ff2Smrg# end func_convert_path_cygwin_to_w32 1879f05b35a2Smrg 1880f05b35a2Smrg 188167ab2ff2Smrg# func_convert_path_nix_to_w32 ARG 188267ab2ff2Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 188367ab2ff2Smrg# a working winepath. Returns result in func_to_host_file_result. 188467ab2ff2Smrgfunc_convert_path_nix_to_w32 () 188567ab2ff2Smrg{ 188667ab2ff2Smrg $opt_debug 188767ab2ff2Smrg func_to_host_path_result="$1" 188867ab2ff2Smrg if test -n "$1"; then 188967ab2ff2Smrg # See func_convert_path_msys_to_w32: 189067ab2ff2Smrg func_stripname : : "$1" 189167ab2ff2Smrg func_to_host_path_tmp1=$func_stripname_result 189267ab2ff2Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 189367ab2ff2Smrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 189467ab2ff2Smrg func_convert_path_check : ";" \ 189567ab2ff2Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 189667ab2ff2Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 189767ab2ff2Smrg fi 189867ab2ff2Smrg} 189967ab2ff2Smrg# end func_convert_path_nix_to_w32 1900f05b35a2Smrg 190167ab2ff2Smrg 190267ab2ff2Smrg# func_convert_path_msys_to_cygwin ARG 190367ab2ff2Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 190467ab2ff2Smrg# Returns result in func_to_host_file_result. 190567ab2ff2Smrgfunc_convert_path_msys_to_cygwin () 190667ab2ff2Smrg{ 190767ab2ff2Smrg $opt_debug 190867ab2ff2Smrg func_to_host_path_result="$1" 190967ab2ff2Smrg if test -n "$1"; then 191067ab2ff2Smrg # See func_convert_path_msys_to_w32: 191167ab2ff2Smrg func_stripname : : "$1" 191267ab2ff2Smrg func_to_host_path_tmp1=$func_stripname_result 191367ab2ff2Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 191467ab2ff2Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 191567ab2ff2Smrg func_to_host_path_result="$func_cygpath_result" 191667ab2ff2Smrg func_convert_path_check : : \ 191767ab2ff2Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 191867ab2ff2Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 191967ab2ff2Smrg fi 192067ab2ff2Smrg} 192167ab2ff2Smrg# end func_convert_path_msys_to_cygwin 192267ab2ff2Smrg 192367ab2ff2Smrg 192467ab2ff2Smrg# func_convert_path_nix_to_cygwin ARG 192567ab2ff2Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 192667ab2ff2Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 192767ab2ff2Smrg# func_to_host_file_result. 192867ab2ff2Smrgfunc_convert_path_nix_to_cygwin () 192967ab2ff2Smrg{ 193067ab2ff2Smrg $opt_debug 193167ab2ff2Smrg func_to_host_path_result="$1" 193267ab2ff2Smrg if test -n "$1"; then 193367ab2ff2Smrg # Remove leading and trailing path separator characters from 193467ab2ff2Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 193567ab2ff2Smrg # into '.;' and ';.', and winepath ignores them completely. 193667ab2ff2Smrg func_stripname : : "$1" 193767ab2ff2Smrg func_to_host_path_tmp1=$func_stripname_result 193867ab2ff2Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 193967ab2ff2Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 194067ab2ff2Smrg func_to_host_path_result="$func_cygpath_result" 194167ab2ff2Smrg func_convert_path_check : : \ 194267ab2ff2Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 194367ab2ff2Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 194467ab2ff2Smrg fi 1945f05b35a2Smrg} 194667ab2ff2Smrg# end func_convert_path_nix_to_cygwin 194767ab2ff2Smrg 1948f05b35a2Smrg 1949f05b35a2Smrg# func_mode_compile arg... 1950f05b35a2Smrgfunc_mode_compile () 1951f05b35a2Smrg{ 1952f05b35a2Smrg $opt_debug 1953f05b35a2Smrg # Get the compilation command and the source file. 1954f05b35a2Smrg base_compile= 1955f05b35a2Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 1956f05b35a2Smrg suppress_opt=yes 1957f05b35a2Smrg suppress_output= 1958f05b35a2Smrg arg_mode=normal 1959f05b35a2Smrg libobj= 1960f05b35a2Smrg later= 1961f05b35a2Smrg pie_flag= 1962f05b35a2Smrg 1963f05b35a2Smrg for arg 1964f05b35a2Smrg do 1965f05b35a2Smrg case $arg_mode in 1966f05b35a2Smrg arg ) 1967f05b35a2Smrg # do not "continue". Instead, add this to base_compile 1968f05b35a2Smrg lastarg="$arg" 1969f05b35a2Smrg arg_mode=normal 1970f05b35a2Smrg ;; 1971f05b35a2Smrg 1972f05b35a2Smrg target ) 1973f05b35a2Smrg libobj="$arg" 1974f05b35a2Smrg arg_mode=normal 1975f05b35a2Smrg continue 1976f05b35a2Smrg ;; 1977f05b35a2Smrg 1978f05b35a2Smrg normal ) 1979f05b35a2Smrg # Accept any command-line options. 1980f05b35a2Smrg case $arg in 1981f05b35a2Smrg -o) 1982f05b35a2Smrg test -n "$libobj" && \ 1983f05b35a2Smrg func_fatal_error "you cannot specify \`-o' more than once" 1984f05b35a2Smrg arg_mode=target 1985f05b35a2Smrg continue 1986f05b35a2Smrg ;; 1987f05b35a2Smrg 1988f05b35a2Smrg -pie | -fpie | -fPIE) 198967ab2ff2Smrg func_append pie_flag " $arg" 1990f05b35a2Smrg continue 1991f05b35a2Smrg ;; 1992f05b35a2Smrg 1993f05b35a2Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 199467ab2ff2Smrg func_append later " $arg" 1995f05b35a2Smrg continue 1996f05b35a2Smrg ;; 1997f05b35a2Smrg 1998f05b35a2Smrg -no-suppress) 1999e0963edeSmrg suppress_opt=no 2000e0963edeSmrg continue 2001e0963edeSmrg ;; 2002e0963edeSmrg 2003e0963edeSmrg -Xcompiler) 2004e0963edeSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 2005e0963edeSmrg continue # The current "srcfile" will either be retained or 2006e0963edeSmrg ;; # replaced later. I would guess that would be a bug. 2007e0963edeSmrg 2008e0963edeSmrg -Wc,*) 2009f05b35a2Smrg func_stripname '-Wc,' '' "$arg" 2010f05b35a2Smrg args=$func_stripname_result 2011e0963edeSmrg lastarg= 2012e0963edeSmrg save_ifs="$IFS"; IFS=',' 2013f05b35a2Smrg for arg in $args; do 2014e0963edeSmrg IFS="$save_ifs" 201567ab2ff2Smrg func_append_quoted lastarg "$arg" 2016e0963edeSmrg done 2017e0963edeSmrg IFS="$save_ifs" 2018f05b35a2Smrg func_stripname ' ' '' "$lastarg" 2019f05b35a2Smrg lastarg=$func_stripname_result 2020e0963edeSmrg 2021e0963edeSmrg # Add the arguments to base_compile. 202267ab2ff2Smrg func_append base_compile " $lastarg" 2023e0963edeSmrg continue 2024e0963edeSmrg ;; 2025e0963edeSmrg 2026f05b35a2Smrg *) 2027e0963edeSmrg # Accept the current argument as the source file. 2028e0963edeSmrg # The previous "srcfile" becomes the current argument. 2029e0963edeSmrg # 2030e0963edeSmrg lastarg="$srcfile" 2031e0963edeSmrg srcfile="$arg" 2032e0963edeSmrg ;; 2033e0963edeSmrg esac # case $arg 2034e0963edeSmrg ;; 2035e0963edeSmrg esac # case $arg_mode 2036e0963edeSmrg 2037e0963edeSmrg # Aesthetically quote the previous argument. 203867ab2ff2Smrg func_append_quoted base_compile "$lastarg" 2039e0963edeSmrg done # for arg 2040e0963edeSmrg 2041e0963edeSmrg case $arg_mode in 2042e0963edeSmrg arg) 2043f05b35a2Smrg func_fatal_error "you must specify an argument for -Xcompile" 2044e0963edeSmrg ;; 2045e0963edeSmrg target) 2046f05b35a2Smrg func_fatal_error "you must specify a target with \`-o'" 2047e0963edeSmrg ;; 2048e0963edeSmrg *) 2049e0963edeSmrg # Get the name of the library object. 2050f05b35a2Smrg test -z "$libobj" && { 2051f05b35a2Smrg func_basename "$srcfile" 2052f05b35a2Smrg libobj="$func_basename_result" 2053f05b35a2Smrg } 2054e0963edeSmrg ;; 2055e0963edeSmrg esac 2056e0963edeSmrg 2057e0963edeSmrg # Recognize several different file suffixes. 2058e0963edeSmrg # If the user specifies -o file.o, it is replaced with file.lo 2059e0963edeSmrg case $libobj in 2060f05b35a2Smrg *.[cCFSifmso] | \ 2061f05b35a2Smrg *.ada | *.adb | *.ads | *.asm | \ 2062f05b35a2Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 2063e494fffdSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 2064f05b35a2Smrg func_xform "$libobj" 2065f05b35a2Smrg libobj=$func_xform_result 2066f05b35a2Smrg ;; 2067e0963edeSmrg esac 2068e0963edeSmrg 2069e0963edeSmrg case $libobj in 2070f05b35a2Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 2071e0963edeSmrg *) 2072f05b35a2Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 2073e0963edeSmrg ;; 2074e0963edeSmrg esac 2075e0963edeSmrg 2076e0963edeSmrg func_infer_tag $base_compile 2077e0963edeSmrg 2078e0963edeSmrg for arg in $later; do 2079e0963edeSmrg case $arg in 2080f05b35a2Smrg -shared) 2081f05b35a2Smrg test "$build_libtool_libs" != yes && \ 2082f05b35a2Smrg func_fatal_configuration "can not build a shared library" 2083f05b35a2Smrg build_old_libs=no 2084f05b35a2Smrg continue 2085f05b35a2Smrg ;; 2086f05b35a2Smrg 2087e0963edeSmrg -static) 2088f05b35a2Smrg build_libtool_libs=no 2089e0963edeSmrg build_old_libs=yes 2090e0963edeSmrg continue 2091e0963edeSmrg ;; 2092e0963edeSmrg 2093e0963edeSmrg -prefer-pic) 2094e0963edeSmrg pic_mode=yes 2095e0963edeSmrg continue 2096e0963edeSmrg ;; 2097e0963edeSmrg 2098e0963edeSmrg -prefer-non-pic) 2099e0963edeSmrg pic_mode=no 2100e0963edeSmrg continue 2101e0963edeSmrg ;; 2102e0963edeSmrg esac 2103e0963edeSmrg done 2104e0963edeSmrg 2105f05b35a2Smrg func_quote_for_eval "$libobj" 2106f05b35a2Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 2107f05b35a2Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 2108f05b35a2Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 2109f05b35a2Smrg func_dirname_and_basename "$obj" "/" "" 2110f05b35a2Smrg objname="$func_basename_result" 2111f05b35a2Smrg xdir="$func_dirname_result" 2112e0963edeSmrg lobj=${xdir}$objdir/$objname 2113e0963edeSmrg 2114f05b35a2Smrg test -z "$base_compile" && \ 2115f05b35a2Smrg func_fatal_help "you must specify a compilation command" 2116e0963edeSmrg 2117e0963edeSmrg # Delete any leftover library objects. 2118e0963edeSmrg if test "$build_old_libs" = yes; then 2119e0963edeSmrg removelist="$obj $lobj $libobj ${libobj}T" 2120e0963edeSmrg else 2121e0963edeSmrg removelist="$lobj $libobj ${libobj}T" 2122e0963edeSmrg fi 2123e0963edeSmrg 2124e0963edeSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 2125e0963edeSmrg case $host_os in 2126f05b35a2Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 2127e0963edeSmrg pic_mode=default 2128e0963edeSmrg ;; 2129e0963edeSmrg esac 2130e0963edeSmrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 2131e0963edeSmrg # non-PIC code in shared libraries is not supported 2132e0963edeSmrg pic_mode=default 2133e0963edeSmrg fi 2134e0963edeSmrg 2135e0963edeSmrg # Calculate the filename of the output object if compiler does 2136e0963edeSmrg # not support -o with -c 2137e0963edeSmrg if test "$compiler_c_o" = no; then 213849e108a1Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 2139e0963edeSmrg lockfile="$output_obj.lock" 2140e0963edeSmrg else 2141e0963edeSmrg output_obj= 2142e0963edeSmrg need_locks=no 2143e0963edeSmrg lockfile= 2144e0963edeSmrg fi 2145e0963edeSmrg 2146e0963edeSmrg # Lock this critical section if it is needed 2147e0963edeSmrg # We use this script file to make the link, it avoids creating a new file 2148e0963edeSmrg if test "$need_locks" = yes; then 2149f05b35a2Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 2150f05b35a2Smrg func_echo "Waiting for $lockfile to be removed" 2151e0963edeSmrg sleep 2 2152e0963edeSmrg done 2153e0963edeSmrg elif test "$need_locks" = warn; then 2154e0963edeSmrg if test -f "$lockfile"; then 2155f05b35a2Smrg $ECHO "\ 2156e0963edeSmrg*** ERROR, $lockfile exists and contains: 2157e0963edeSmrg`cat $lockfile 2>/dev/null` 2158e0963edeSmrg 2159e0963edeSmrgThis indicates that another process is trying to use the same 2160e0963edeSmrgtemporary object file, and libtool could not work around it because 2161e0963edeSmrgyour compiler does not support \`-c' and \`-o' together. If you 2162e0963edeSmrgrepeat this compilation, it may succeed, by chance, but you had better 2163e0963edeSmrgavoid parallel builds (make -j) in this platform, or get a better 2164e0963edeSmrgcompiler." 2165e0963edeSmrg 2166f05b35a2Smrg $opt_dry_run || $RM $removelist 2167e0963edeSmrg exit $EXIT_FAILURE 2168e0963edeSmrg fi 216967ab2ff2Smrg func_append removelist " $output_obj" 2170f05b35a2Smrg $ECHO "$srcfile" > "$lockfile" 2171e0963edeSmrg fi 2172e0963edeSmrg 2173f05b35a2Smrg $opt_dry_run || $RM $removelist 217467ab2ff2Smrg func_append removelist " $lockfile" 2175f05b35a2Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 2176f05b35a2Smrg 217767ab2ff2Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 217867ab2ff2Smrg srcfile=$func_to_tool_file_result 2179f05b35a2Smrg func_quote_for_eval "$srcfile" 2180f05b35a2Smrg qsrcfile=$func_quote_for_eval_result 2181e0963edeSmrg 2182e0963edeSmrg # Only build a PIC object if we are building libtool libraries. 2183e0963edeSmrg if test "$build_libtool_libs" = yes; then 2184e0963edeSmrg # Without this assignment, base_compile gets emptied. 2185e0963edeSmrg fbsd_hideous_sh_bug=$base_compile 2186e0963edeSmrg 2187e0963edeSmrg if test "$pic_mode" != no; then 2188e0963edeSmrg command="$base_compile $qsrcfile $pic_flag" 2189e0963edeSmrg else 2190e0963edeSmrg # Don't build PIC code 2191e0963edeSmrg command="$base_compile $qsrcfile" 2192e0963edeSmrg fi 2193e0963edeSmrg 2194f05b35a2Smrg func_mkdir_p "$xdir$objdir" 2195e0963edeSmrg 2196e0963edeSmrg if test -z "$output_obj"; then 2197e0963edeSmrg # Place PIC objects in $objdir 219867ab2ff2Smrg func_append command " -o $lobj" 2199e0963edeSmrg fi 2200e0963edeSmrg 2201f05b35a2Smrg func_show_eval_locale "$command" \ 2202f05b35a2Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 2203e0963edeSmrg 2204e0963edeSmrg if test "$need_locks" = warn && 2205e0963edeSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2206f05b35a2Smrg $ECHO "\ 2207e0963edeSmrg*** ERROR, $lockfile contains: 2208e0963edeSmrg`cat $lockfile 2>/dev/null` 2209e0963edeSmrg 2210e0963edeSmrgbut it should contain: 2211e0963edeSmrg$srcfile 2212e0963edeSmrg 2213e0963edeSmrgThis indicates that another process is trying to use the same 2214e0963edeSmrgtemporary object file, and libtool could not work around it because 2215e0963edeSmrgyour compiler does not support \`-c' and \`-o' together. If you 2216e0963edeSmrgrepeat this compilation, it may succeed, by chance, but you had better 2217e0963edeSmrgavoid parallel builds (make -j) in this platform, or get a better 2218e0963edeSmrgcompiler." 2219e0963edeSmrg 2220f05b35a2Smrg $opt_dry_run || $RM $removelist 2221e0963edeSmrg exit $EXIT_FAILURE 2222e0963edeSmrg fi 2223e0963edeSmrg 2224e0963edeSmrg # Just move the object if needed, then go on to compile the next one 2225e0963edeSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 2226f05b35a2Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 2227f05b35a2Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2228e0963edeSmrg fi 2229e0963edeSmrg 2230e0963edeSmrg # Allow error messages only from the first compilation. 2231e0963edeSmrg if test "$suppress_opt" = yes; then 2232f05b35a2Smrg suppress_output=' >/dev/null 2>&1' 2233e0963edeSmrg fi 2234e0963edeSmrg fi 2235e0963edeSmrg 2236e0963edeSmrg # Only build a position-dependent object if we build old libraries. 2237e0963edeSmrg if test "$build_old_libs" = yes; then 2238e0963edeSmrg if test "$pic_mode" != yes; then 2239e0963edeSmrg # Don't build PIC code 2240f05b35a2Smrg command="$base_compile $qsrcfile$pie_flag" 2241e0963edeSmrg else 2242e0963edeSmrg command="$base_compile $qsrcfile $pic_flag" 2243e0963edeSmrg fi 2244e0963edeSmrg if test "$compiler_c_o" = yes; then 224567ab2ff2Smrg func_append command " -o $obj" 2246e0963edeSmrg fi 2247e0963edeSmrg 2248e0963edeSmrg # Suppress compiler output if we already did a PIC compilation. 224967ab2ff2Smrg func_append command "$suppress_output" 2250f05b35a2Smrg func_show_eval_locale "$command" \ 2251f05b35a2Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 2252e0963edeSmrg 2253e0963edeSmrg if test "$need_locks" = warn && 2254e0963edeSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2255f05b35a2Smrg $ECHO "\ 2256e0963edeSmrg*** ERROR, $lockfile contains: 2257e0963edeSmrg`cat $lockfile 2>/dev/null` 2258e0963edeSmrg 2259e0963edeSmrgbut it should contain: 2260e0963edeSmrg$srcfile 2261e0963edeSmrg 2262e0963edeSmrgThis indicates that another process is trying to use the same 2263e0963edeSmrgtemporary object file, and libtool could not work around it because 2264e0963edeSmrgyour compiler does not support \`-c' and \`-o' together. If you 2265e0963edeSmrgrepeat this compilation, it may succeed, by chance, but you had better 2266e0963edeSmrgavoid parallel builds (make -j) in this platform, or get a better 2267e0963edeSmrgcompiler." 2268e0963edeSmrg 2269f05b35a2Smrg $opt_dry_run || $RM $removelist 2270e0963edeSmrg exit $EXIT_FAILURE 2271e0963edeSmrg fi 2272e0963edeSmrg 2273e0963edeSmrg # Just move the object if needed 2274e0963edeSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 2275f05b35a2Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 2276f05b35a2Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2277e0963edeSmrg fi 2278e0963edeSmrg fi 2279e0963edeSmrg 2280f05b35a2Smrg $opt_dry_run || { 2281f05b35a2Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 2282e0963edeSmrg 2283f05b35a2Smrg # Unlock the critical section if it was locked 2284f05b35a2Smrg if test "$need_locks" != no; then 2285f05b35a2Smrg removelist=$lockfile 2286f05b35a2Smrg $RM "$lockfile" 2287f05b35a2Smrg fi 2288f05b35a2Smrg } 2289e0963edeSmrg 2290e0963edeSmrg exit $EXIT_SUCCESS 2291f05b35a2Smrg} 2292e0963edeSmrg 2293f05b35a2Smrg$opt_help || { 229467ab2ff2Smrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 2295f05b35a2Smrg} 2296e0963edeSmrg 2297f05b35a2Smrgfunc_mode_help () 2298f05b35a2Smrg{ 2299f05b35a2Smrg # We need to display help for each of the modes. 230067ab2ff2Smrg case $opt_mode in 2301f05b35a2Smrg "") 2302f05b35a2Smrg # Generic help is extracted from the usage comments 2303f05b35a2Smrg # at the start of this file. 2304f05b35a2Smrg func_help 2305f05b35a2Smrg ;; 2306e0963edeSmrg 2307f05b35a2Smrg clean) 2308f05b35a2Smrg $ECHO \ 2309f05b35a2Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 2310e0963edeSmrg 2311f05b35a2SmrgRemove files from the build directory. 2312e0963edeSmrg 2313f05b35a2SmrgRM is the name of the program to use to delete files associated with each FILE 2314f05b35a2Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2315f05b35a2Smrgto RM. 2316e0963edeSmrg 2317f05b35a2SmrgIf FILE is a libtool library, object or program, all the files associated 2318f05b35a2Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 2319f05b35a2Smrg ;; 2320e0963edeSmrg 2321f05b35a2Smrg compile) 2322f05b35a2Smrg $ECHO \ 2323f05b35a2Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 2324e0963edeSmrg 2325f05b35a2SmrgCompile a source file into a libtool library object. 2326e0963edeSmrg 2327f05b35a2SmrgThis mode accepts the following additional options: 2328e0963edeSmrg 2329f05b35a2Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 2330f05b35a2Smrg -no-suppress do not suppress compiler output for multiple passes 233149e108a1Smrg -prefer-pic try to build PIC objects only 233249e108a1Smrg -prefer-non-pic try to build non-PIC objects only 2333f05b35a2Smrg -shared do not build a \`.o' file suitable for static linking 2334f05b35a2Smrg -static only build a \`.o' file suitable for static linking 233549e108a1Smrg -Wc,FLAG pass FLAG directly to the compiler 2336e0963edeSmrg 2337f05b35a2SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 2338f05b35a2Smrgfrom the given SOURCEFILE. 2339e0963edeSmrg 2340f05b35a2SmrgThe output file name is determined by removing the directory component from 2341f05b35a2SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 2342f05b35a2Smrglibrary object suffix, \`.lo'." 2343f05b35a2Smrg ;; 2344e0963edeSmrg 2345f05b35a2Smrg execute) 2346f05b35a2Smrg $ECHO \ 2347f05b35a2Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 2348e0963edeSmrg 2349f05b35a2SmrgAutomatically set library path, then run a program. 2350e0963edeSmrg 2351f05b35a2SmrgThis mode accepts the following additional options: 2352e0963edeSmrg 2353f05b35a2Smrg -dlopen FILE add the directory containing FILE to the library path 2354e0963edeSmrg 2355f05b35a2SmrgThis mode sets the library path environment variable according to \`-dlopen' 2356f05b35a2Smrgflags. 2357e0963edeSmrg 2358f05b35a2SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 2359f05b35a2Smrginto their corresponding uninstalled binary, and any of their required library 2360f05b35a2Smrgdirectories are added to the library path. 2361e0963edeSmrg 2362f05b35a2SmrgThen, COMMAND is executed, with ARGS as arguments." 2363f05b35a2Smrg ;; 2364e0963edeSmrg 2365f05b35a2Smrg finish) 2366f05b35a2Smrg $ECHO \ 2367f05b35a2Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 2368e0963edeSmrg 2369f05b35a2SmrgComplete the installation of libtool libraries. 2370e0963edeSmrg 2371f05b35a2SmrgEach LIBDIR is a directory that contains libtool libraries. 2372e0963edeSmrg 2373f05b35a2SmrgThe commands that this mode executes may require superuser privileges. Use 2374f05b35a2Smrgthe \`--dry-run' option if you just want to see what would be executed." 2375f05b35a2Smrg ;; 2376e0963edeSmrg 2377f05b35a2Smrg install) 2378f05b35a2Smrg $ECHO \ 2379f05b35a2Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 2380e0963edeSmrg 2381f05b35a2SmrgInstall executables or libraries. 2382e0963edeSmrg 2383f05b35a2SmrgINSTALL-COMMAND is the installation command. The first component should be 2384f05b35a2Smrgeither the \`install' or \`cp' program. 2385e0963edeSmrg 2386f05b35a2SmrgThe following components of INSTALL-COMMAND are treated specially: 2387e0963edeSmrg 238849e108a1Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 2389e0963edeSmrg 2390f05b35a2SmrgThe rest of the components are interpreted as arguments to that command (only 2391f05b35a2SmrgBSD-compatible install options are recognized)." 2392f05b35a2Smrg ;; 2393e0963edeSmrg 2394f05b35a2Smrg link) 2395f05b35a2Smrg $ECHO \ 2396f05b35a2Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 2397e0963edeSmrg 2398f05b35a2SmrgLink object files or libraries together to form another library, or to 2399f05b35a2Smrgcreate an executable program. 2400e0963edeSmrg 2401f05b35a2SmrgLINK-COMMAND is a command using the C compiler that you would use to create 2402f05b35a2Smrga program from several object files. 2403e0963edeSmrg 2404f05b35a2SmrgThe following components of LINK-COMMAND are treated specially: 2405e0963edeSmrg 2406f05b35a2Smrg -all-static do not do any dynamic linking at all 2407f05b35a2Smrg -avoid-version do not add a version suffix if possible 240849e108a1Smrg -bindir BINDIR specify path to binaries directory (for systems where 240949e108a1Smrg libraries must be found in the PATH setting at runtime) 2410f05b35a2Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 2411f05b35a2Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 2412f05b35a2Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 2413f05b35a2Smrg -export-symbols SYMFILE 2414f05b35a2Smrg try to export only the symbols listed in SYMFILE 2415f05b35a2Smrg -export-symbols-regex REGEX 2416f05b35a2Smrg try to export only the symbols matching REGEX 2417f05b35a2Smrg -LLIBDIR search LIBDIR for required installed libraries 2418f05b35a2Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 2419f05b35a2Smrg -module build a library that can dlopened 2420f05b35a2Smrg -no-fast-install disable the fast-install mode 2421f05b35a2Smrg -no-install link a not-installable executable 2422f05b35a2Smrg -no-undefined declare that a library does not refer to external symbols 2423f05b35a2Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 2424f05b35a2Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 2425f05b35a2Smrg -precious-files-regex REGEX 2426f05b35a2Smrg don't remove output files matching REGEX 2427f05b35a2Smrg -release RELEASE specify package release information 2428f05b35a2Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 2429f05b35a2Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 2430f05b35a2Smrg -shared only do dynamic linking of libtool libraries 2431f05b35a2Smrg -shrext SUFFIX override the standard shared library file extension 2432f05b35a2Smrg -static do not do any dynamic linking of uninstalled libtool libraries 2433f05b35a2Smrg -static-libtool-libs 2434f05b35a2Smrg do not do any dynamic linking of libtool libraries 2435f05b35a2Smrg -version-info CURRENT[:REVISION[:AGE]] 2436f05b35a2Smrg specify library version info [each variable defaults to 0] 2437f05b35a2Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 243849e108a1Smrg -Wc,FLAG 243949e108a1Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 244049e108a1Smrg -Wl,FLAG 244149e108a1Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 244249e108a1Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 2443e0963edeSmrg 2444f05b35a2SmrgAll other options (arguments beginning with \`-') are ignored. 2445e0963edeSmrg 2446f05b35a2SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 2447f05b35a2Smrgtreated as uninstalled libtool libraries, other files are standard or library 2448f05b35a2Smrgobject files. 2449e0963edeSmrg 2450f05b35a2SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 2451f05b35a2Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 2452f05b35a2Smrgrequired, except when creating a convenience library. 2453e0963edeSmrg 2454f05b35a2SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 2455f05b35a2Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 2456e0963edeSmrg 2457f05b35a2SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 2458f05b35a2Smrgis created, otherwise an executable program is created." 2459e0963edeSmrg ;; 2460e0963edeSmrg 2461f05b35a2Smrg uninstall) 2462f05b35a2Smrg $ECHO \ 2463f05b35a2Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 2464e0963edeSmrg 2465f05b35a2SmrgRemove libraries from an installation directory. 2466e0963edeSmrg 2467f05b35a2SmrgRM is the name of the program to use to delete files associated with each FILE 2468f05b35a2Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2469f05b35a2Smrgto RM. 2470e0963edeSmrg 2471f05b35a2SmrgIf FILE is a libtool library, all the files associated with it are deleted. 2472f05b35a2SmrgOtherwise, only FILE itself is deleted using RM." 2473f05b35a2Smrg ;; 2474e0963edeSmrg 2475f05b35a2Smrg *) 247667ab2ff2Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 2477f05b35a2Smrg ;; 2478f05b35a2Smrg esac 2479e0963edeSmrg 248049e108a1Smrg echo 2481f05b35a2Smrg $ECHO "Try \`$progname --help' for more information about other modes." 2482f05b35a2Smrg} 2483e0963edeSmrg 248449e108a1Smrg# Now that we've collected a possible --mode arg, show help if necessary 248549e108a1Smrgif $opt_help; then 248649e108a1Smrg if test "$opt_help" = :; then 248749e108a1Smrg func_mode_help 248849e108a1Smrg else 248949e108a1Smrg { 249049e108a1Smrg func_help noexit 249167ab2ff2Smrg for opt_mode in compile link execute install finish uninstall clean; do 249249e108a1Smrg func_mode_help 249349e108a1Smrg done 249449e108a1Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 249549e108a1Smrg { 249649e108a1Smrg func_help noexit 249767ab2ff2Smrg for opt_mode in compile link execute install finish uninstall clean; do 249849e108a1Smrg echo 249949e108a1Smrg func_mode_help 250049e108a1Smrg done 250149e108a1Smrg } | 250249e108a1Smrg sed '1d 250349e108a1Smrg /^When reporting/,/^Report/{ 250449e108a1Smrg H 250549e108a1Smrg d 250649e108a1Smrg } 250749e108a1Smrg $x 250849e108a1Smrg /information about other modes/d 250949e108a1Smrg /more detailed .*MODE/d 251049e108a1Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 251149e108a1Smrg fi 251249e108a1Smrg exit $? 251349e108a1Smrgfi 2514e0963edeSmrg 2515e0963edeSmrg 2516f05b35a2Smrg# func_mode_execute arg... 2517f05b35a2Smrgfunc_mode_execute () 2518f05b35a2Smrg{ 2519f05b35a2Smrg $opt_debug 2520f05b35a2Smrg # The first argument is the command name. 2521f05b35a2Smrg cmd="$nonopt" 2522f05b35a2Smrg test -z "$cmd" && \ 2523f05b35a2Smrg func_fatal_help "you must specify a COMMAND" 2524e0963edeSmrg 2525f05b35a2Smrg # Handle -dlopen flags immediately. 252667ab2ff2Smrg for file in $opt_dlopen; do 2527f05b35a2Smrg test -f "$file" \ 2528f05b35a2Smrg || func_fatal_help "\`$file' is not a file" 2529e0963edeSmrg 2530f05b35a2Smrg dir= 2531f05b35a2Smrg case $file in 2532f05b35a2Smrg *.la) 253367ab2ff2Smrg func_resolve_sysroot "$file" 253467ab2ff2Smrg file=$func_resolve_sysroot_result 253567ab2ff2Smrg 2536f05b35a2Smrg # Check to see that this really is a libtool archive. 2537f05b35a2Smrg func_lalib_unsafe_p "$file" \ 2538f05b35a2Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 2539e0963edeSmrg 2540f05b35a2Smrg # Read the libtool library. 2541f05b35a2Smrg dlname= 2542f05b35a2Smrg library_names= 2543f05b35a2Smrg func_source "$file" 2544e0963edeSmrg 2545f05b35a2Smrg # Skip this library if it cannot be dlopened. 2546f05b35a2Smrg if test -z "$dlname"; then 2547f05b35a2Smrg # Warn if it was a shared library. 2548f05b35a2Smrg test -n "$library_names" && \ 2549f05b35a2Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 2550f05b35a2Smrg continue 2551f05b35a2Smrg fi 2552e0963edeSmrg 2553f05b35a2Smrg func_dirname "$file" "" "." 2554f05b35a2Smrg dir="$func_dirname_result" 2555e0963edeSmrg 2556f05b35a2Smrg if test -f "$dir/$objdir/$dlname"; then 255767ab2ff2Smrg func_append dir "/$objdir" 2558f05b35a2Smrg else 2559f05b35a2Smrg if test ! -f "$dir/$dlname"; then 2560f05b35a2Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 2561f05b35a2Smrg fi 2562f05b35a2Smrg fi 2563e0963edeSmrg ;; 2564e0963edeSmrg 2565f05b35a2Smrg *.lo) 2566f05b35a2Smrg # Just add the directory containing the .lo file. 2567f05b35a2Smrg func_dirname "$file" "" "." 2568f05b35a2Smrg dir="$func_dirname_result" 2569e0963edeSmrg ;; 2570e0963edeSmrg 2571f05b35a2Smrg *) 2572f05b35a2Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 2573e0963edeSmrg continue 2574e0963edeSmrg ;; 2575f05b35a2Smrg esac 2576e0963edeSmrg 2577f05b35a2Smrg # Get the absolute pathname. 2578f05b35a2Smrg absdir=`cd "$dir" && pwd` 2579f05b35a2Smrg test -n "$absdir" && dir="$absdir" 2580e0963edeSmrg 2581f05b35a2Smrg # Now add the directory to shlibpath_var. 2582f05b35a2Smrg if eval "test -z \"\$$shlibpath_var\""; then 2583f05b35a2Smrg eval "$shlibpath_var=\"\$dir\"" 2584f05b35a2Smrg else 2585f05b35a2Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 2586f05b35a2Smrg fi 2587f05b35a2Smrg done 2588e0963edeSmrg 2589f05b35a2Smrg # This variable tells wrapper scripts just to set shlibpath_var 2590f05b35a2Smrg # rather than running their programs. 2591f05b35a2Smrg libtool_execute_magic="$magic" 2592e0963edeSmrg 2593f05b35a2Smrg # Check if any of the arguments is a wrapper script. 2594f05b35a2Smrg args= 2595f05b35a2Smrg for file 2596f05b35a2Smrg do 2597f05b35a2Smrg case $file in 259849e108a1Smrg -* | *.la | *.lo ) ;; 2599f05b35a2Smrg *) 2600f05b35a2Smrg # Do a test to see if this is really a libtool program. 2601f05b35a2Smrg if func_ltwrapper_script_p "$file"; then 2602f05b35a2Smrg func_source "$file" 2603f05b35a2Smrg # Transform arg to wrapped name. 2604f05b35a2Smrg file="$progdir/$program" 2605f05b35a2Smrg elif func_ltwrapper_executable_p "$file"; then 2606f05b35a2Smrg func_ltwrapper_scriptname "$file" 2607f05b35a2Smrg func_source "$func_ltwrapper_scriptname_result" 2608f05b35a2Smrg # Transform arg to wrapped name. 2609f05b35a2Smrg file="$progdir/$program" 2610f05b35a2Smrg fi 2611f05b35a2Smrg ;; 2612f05b35a2Smrg esac 2613f05b35a2Smrg # Quote arguments (to preserve shell metacharacters). 261467ab2ff2Smrg func_append_quoted args "$file" 2615f05b35a2Smrg done 2616e0963edeSmrg 2617f05b35a2Smrg if test "X$opt_dry_run" = Xfalse; then 2618f05b35a2Smrg if test -n "$shlibpath_var"; then 2619f05b35a2Smrg # Export the shlibpath_var. 2620f05b35a2Smrg eval "export $shlibpath_var" 2621f05b35a2Smrg fi 2622e0963edeSmrg 2623f05b35a2Smrg # Restore saved environment variables 2624f05b35a2Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 2625f05b35a2Smrg do 2626f05b35a2Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 2627f05b35a2Smrg $lt_var=\$save_$lt_var; export $lt_var 2628e0963edeSmrg else 2629f05b35a2Smrg $lt_unset $lt_var 2630f05b35a2Smrg fi" 2631f05b35a2Smrg done 2632e0963edeSmrg 2633f05b35a2Smrg # Now prepare to actually exec the command. 2634f05b35a2Smrg exec_cmd="\$cmd$args" 2635f05b35a2Smrg else 2636f05b35a2Smrg # Display what would be done. 2637f05b35a2Smrg if test -n "$shlibpath_var"; then 2638f05b35a2Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 263949e108a1Smrg echo "export $shlibpath_var" 2640f05b35a2Smrg fi 2641f05b35a2Smrg $ECHO "$cmd$args" 2642f05b35a2Smrg exit $EXIT_SUCCESS 2643f05b35a2Smrg fi 2644f05b35a2Smrg} 2645e0963edeSmrg 264667ab2ff2Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 2647e0963edeSmrg 2648e0963edeSmrg 2649f05b35a2Smrg# func_mode_finish arg... 2650f05b35a2Smrgfunc_mode_finish () 2651f05b35a2Smrg{ 2652f05b35a2Smrg $opt_debug 265367ab2ff2Smrg libs= 265467ab2ff2Smrg libdirs= 2655f05b35a2Smrg admincmds= 2656e0963edeSmrg 265767ab2ff2Smrg for opt in "$nonopt" ${1+"$@"} 265867ab2ff2Smrg do 265967ab2ff2Smrg if test -d "$opt"; then 266067ab2ff2Smrg func_append libdirs " $opt" 266167ab2ff2Smrg 266267ab2ff2Smrg elif test -f "$opt"; then 266367ab2ff2Smrg if func_lalib_unsafe_p "$opt"; then 266467ab2ff2Smrg func_append libs " $opt" 266567ab2ff2Smrg else 266667ab2ff2Smrg func_warning "\`$opt' is not a valid libtool archive" 266767ab2ff2Smrg fi 266867ab2ff2Smrg 266967ab2ff2Smrg else 267067ab2ff2Smrg func_fatal_error "invalid argument \`$opt'" 267167ab2ff2Smrg fi 267267ab2ff2Smrg done 267367ab2ff2Smrg 267467ab2ff2Smrg if test -n "$libs"; then 267567ab2ff2Smrg if test -n "$lt_sysroot"; then 267667ab2ff2Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 267767ab2ff2Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 267867ab2ff2Smrg else 267967ab2ff2Smrg sysroot_cmd= 268067ab2ff2Smrg fi 268167ab2ff2Smrg 268267ab2ff2Smrg # Remove sysroot references 268367ab2ff2Smrg if $opt_dry_run; then 268467ab2ff2Smrg for lib in $libs; do 268567ab2ff2Smrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 268667ab2ff2Smrg done 268767ab2ff2Smrg else 268867ab2ff2Smrg tmpdir=`func_mktempdir` 268967ab2ff2Smrg for lib in $libs; do 269067ab2ff2Smrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 269167ab2ff2Smrg > $tmpdir/tmp-la 269267ab2ff2Smrg mv -f $tmpdir/tmp-la $lib 269367ab2ff2Smrg done 269467ab2ff2Smrg ${RM}r "$tmpdir" 269567ab2ff2Smrg fi 269667ab2ff2Smrg fi 2697e0963edeSmrg 269867ab2ff2Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2699f05b35a2Smrg for libdir in $libdirs; do 2700f05b35a2Smrg if test -n "$finish_cmds"; then 2701f05b35a2Smrg # Do each command in the finish commands. 2702f05b35a2Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 2703f05b35a2Smrg'"$cmd"'"' 2704e0963edeSmrg fi 2705f05b35a2Smrg if test -n "$finish_eval"; then 2706f05b35a2Smrg # Do the single finish_eval. 2707f05b35a2Smrg eval cmds=\"$finish_eval\" 270867ab2ff2Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 2709f05b35a2Smrg $cmds" 2710f05b35a2Smrg fi 2711f05b35a2Smrg done 2712f05b35a2Smrg fi 2713e0963edeSmrg 2714f05b35a2Smrg # Exit here if they wanted silent mode. 2715f05b35a2Smrg $opt_silent && exit $EXIT_SUCCESS 2716e0963edeSmrg 271767ab2ff2Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 271867ab2ff2Smrg echo "----------------------------------------------------------------------" 271967ab2ff2Smrg echo "Libraries have been installed in:" 272067ab2ff2Smrg for libdir in $libdirs; do 272167ab2ff2Smrg $ECHO " $libdir" 272267ab2ff2Smrg done 272367ab2ff2Smrg echo 272467ab2ff2Smrg echo "If you ever happen to want to link against installed libraries" 272567ab2ff2Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 272667ab2ff2Smrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 272767ab2ff2Smrg echo "flag during linking and do at least one of the following:" 272867ab2ff2Smrg if test -n "$shlibpath_var"; then 272967ab2ff2Smrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 273067ab2ff2Smrg echo " during execution" 273167ab2ff2Smrg fi 273267ab2ff2Smrg if test -n "$runpath_var"; then 273367ab2ff2Smrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 273467ab2ff2Smrg echo " during linking" 273567ab2ff2Smrg fi 273667ab2ff2Smrg if test -n "$hardcode_libdir_flag_spec"; then 273767ab2ff2Smrg libdir=LIBDIR 273867ab2ff2Smrg eval flag=\"$hardcode_libdir_flag_spec\" 2739e0963edeSmrg 274067ab2ff2Smrg $ECHO " - use the \`$flag' linker flag" 274167ab2ff2Smrg fi 274267ab2ff2Smrg if test -n "$admincmds"; then 274367ab2ff2Smrg $ECHO " - have your system administrator run these commands:$admincmds" 274467ab2ff2Smrg fi 274567ab2ff2Smrg if test -f /etc/ld.so.conf; then 274667ab2ff2Smrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 274767ab2ff2Smrg fi 274867ab2ff2Smrg echo 2749f05b35a2Smrg 275067ab2ff2Smrg echo "See any operating system documentation about shared libraries for" 275167ab2ff2Smrg case $host in 275267ab2ff2Smrg solaris2.[6789]|solaris2.1[0-9]) 275367ab2ff2Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 275467ab2ff2Smrg echo "pages." 275567ab2ff2Smrg ;; 275667ab2ff2Smrg *) 275767ab2ff2Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 275867ab2ff2Smrg ;; 275967ab2ff2Smrg esac 276067ab2ff2Smrg echo "----------------------------------------------------------------------" 276167ab2ff2Smrg fi 2762f05b35a2Smrg exit $EXIT_SUCCESS 2763f05b35a2Smrg} 2764f05b35a2Smrg 276567ab2ff2Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 2766f05b35a2Smrg 2767f05b35a2Smrg 2768f05b35a2Smrg# func_mode_install arg... 2769f05b35a2Smrgfunc_mode_install () 2770f05b35a2Smrg{ 2771f05b35a2Smrg $opt_debug 2772f05b35a2Smrg # There may be an optional sh(1) argument at the beginning of 2773f05b35a2Smrg # install_prog (especially on Windows NT). 2774f05b35a2Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 2775f05b35a2Smrg # Allow the use of GNU shtool's install command. 277649e108a1Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 2777f05b35a2Smrg # Aesthetically quote it. 2778f05b35a2Smrg func_quote_for_eval "$nonopt" 2779f05b35a2Smrg install_prog="$func_quote_for_eval_result " 2780f05b35a2Smrg arg=$1 2781f05b35a2Smrg shift 2782f05b35a2Smrg else 2783f05b35a2Smrg install_prog= 2784f05b35a2Smrg arg=$nonopt 2785f05b35a2Smrg fi 2786f05b35a2Smrg 2787f05b35a2Smrg # The real first argument should be the name of the installation program. 2788f05b35a2Smrg # Aesthetically quote it. 2789f05b35a2Smrg func_quote_for_eval "$arg" 279067ab2ff2Smrg func_append install_prog "$func_quote_for_eval_result" 279149e108a1Smrg install_shared_prog=$install_prog 279249e108a1Smrg case " $install_prog " in 279349e108a1Smrg *[\\\ /]cp\ *) install_cp=: ;; 279449e108a1Smrg *) install_cp=false ;; 279549e108a1Smrg esac 2796f05b35a2Smrg 2797f05b35a2Smrg # We need to accept at least all the BSD install flags. 2798f05b35a2Smrg dest= 2799f05b35a2Smrg files= 2800f05b35a2Smrg opts= 2801f05b35a2Smrg prev= 2802f05b35a2Smrg install_type= 2803f05b35a2Smrg isdir=no 2804f05b35a2Smrg stripme= 280549e108a1Smrg no_mode=: 2806f05b35a2Smrg for arg 2807f05b35a2Smrg do 280849e108a1Smrg arg2= 2809f05b35a2Smrg if test -n "$dest"; then 281067ab2ff2Smrg func_append files " $dest" 2811f05b35a2Smrg dest=$arg 2812f05b35a2Smrg continue 2813f05b35a2Smrg fi 2814f05b35a2Smrg 2815f05b35a2Smrg case $arg in 2816f05b35a2Smrg -d) isdir=yes ;; 2817f05b35a2Smrg -f) 281849e108a1Smrg if $install_cp; then :; else 281949e108a1Smrg prev=$arg 282049e108a1Smrg fi 2821f05b35a2Smrg ;; 2822f05b35a2Smrg -g | -m | -o) 2823f05b35a2Smrg prev=$arg 2824f05b35a2Smrg ;; 2825f05b35a2Smrg -s) 2826f05b35a2Smrg stripme=" -s" 2827f05b35a2Smrg continue 2828f05b35a2Smrg ;; 2829f05b35a2Smrg -*) 2830f05b35a2Smrg ;; 2831f05b35a2Smrg *) 2832f05b35a2Smrg # If the previous option needed an argument, then skip it. 2833f05b35a2Smrg if test -n "$prev"; then 283449e108a1Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 283549e108a1Smrg arg2=$install_override_mode 283649e108a1Smrg no_mode=false 283749e108a1Smrg fi 2838e0963edeSmrg prev= 2839e0963edeSmrg else 2840f05b35a2Smrg dest=$arg 2841f05b35a2Smrg continue 2842e0963edeSmrg fi 2843e0963edeSmrg ;; 2844f05b35a2Smrg esac 2845e0963edeSmrg 2846f05b35a2Smrg # Aesthetically quote the argument. 2847f05b35a2Smrg func_quote_for_eval "$arg" 284867ab2ff2Smrg func_append install_prog " $func_quote_for_eval_result" 284949e108a1Smrg if test -n "$arg2"; then 285049e108a1Smrg func_quote_for_eval "$arg2" 285149e108a1Smrg fi 285267ab2ff2Smrg func_append install_shared_prog " $func_quote_for_eval_result" 2853f05b35a2Smrg done 2854e0963edeSmrg 2855f05b35a2Smrg test -z "$install_prog" && \ 2856f05b35a2Smrg func_fatal_help "you must specify an install program" 2857e0963edeSmrg 2858f05b35a2Smrg test -n "$prev" && \ 2859f05b35a2Smrg func_fatal_help "the \`$prev' option requires an argument" 2860e0963edeSmrg 286149e108a1Smrg if test -n "$install_override_mode" && $no_mode; then 286249e108a1Smrg if $install_cp; then :; else 286349e108a1Smrg func_quote_for_eval "$install_override_mode" 286467ab2ff2Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 286549e108a1Smrg fi 286649e108a1Smrg fi 286749e108a1Smrg 2868f05b35a2Smrg if test -z "$files"; then 2869f05b35a2Smrg if test -z "$dest"; then 2870f05b35a2Smrg func_fatal_help "no file or destination specified" 2871f05b35a2Smrg else 2872f05b35a2Smrg func_fatal_help "you must specify a destination" 2873f05b35a2Smrg fi 2874e0963edeSmrg fi 2875e0963edeSmrg 2876f05b35a2Smrg # Strip any trailing slash from the destination. 2877f05b35a2Smrg func_stripname '' '/' "$dest" 2878f05b35a2Smrg dest=$func_stripname_result 2879e0963edeSmrg 2880f05b35a2Smrg # Check to see that the destination is a directory. 2881f05b35a2Smrg test -d "$dest" && isdir=yes 2882f05b35a2Smrg if test "$isdir" = yes; then 2883f05b35a2Smrg destdir="$dest" 2884f05b35a2Smrg destname= 2885e0963edeSmrg else 2886f05b35a2Smrg func_dirname_and_basename "$dest" "" "." 2887f05b35a2Smrg destdir="$func_dirname_result" 2888f05b35a2Smrg destname="$func_basename_result" 2889e0963edeSmrg 2890f05b35a2Smrg # Not a directory, so check to see that there is only one file specified. 2891f05b35a2Smrg set dummy $files; shift 2892f05b35a2Smrg test "$#" -gt 1 && \ 2893f05b35a2Smrg func_fatal_help "\`$dest' is not a directory" 2894e0963edeSmrg fi 2895f05b35a2Smrg case $destdir in 2896f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 2897e0963edeSmrg *) 2898f05b35a2Smrg for file in $files; do 2899f05b35a2Smrg case $file in 2900f05b35a2Smrg *.lo) ;; 2901f05b35a2Smrg *) 2902f05b35a2Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 2903f05b35a2Smrg ;; 2904f05b35a2Smrg esac 2905f05b35a2Smrg done 2906e0963edeSmrg ;; 2907e0963edeSmrg esac 2908e0963edeSmrg 2909f05b35a2Smrg # This variable tells wrapper scripts just to set variables rather 2910f05b35a2Smrg # than running their programs. 2911f05b35a2Smrg libtool_install_magic="$magic" 2912e0963edeSmrg 2913f05b35a2Smrg staticlibs= 2914f05b35a2Smrg future_libdirs= 2915f05b35a2Smrg current_libdirs= 2916f05b35a2Smrg for file in $files; do 2917e0963edeSmrg 2918f05b35a2Smrg # Do each installation. 2919f05b35a2Smrg case $file in 2920f05b35a2Smrg *.$libext) 2921f05b35a2Smrg # Do the static libraries later. 292267ab2ff2Smrg func_append staticlibs " $file" 2923f05b35a2Smrg ;; 2924f05b35a2Smrg 2925f05b35a2Smrg *.la) 292667ab2ff2Smrg func_resolve_sysroot "$file" 292767ab2ff2Smrg file=$func_resolve_sysroot_result 292867ab2ff2Smrg 2929f05b35a2Smrg # Check to see that this really is a libtool archive. 2930f05b35a2Smrg func_lalib_unsafe_p "$file" \ 2931f05b35a2Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 2932f05b35a2Smrg 2933f05b35a2Smrg library_names= 2934f05b35a2Smrg old_library= 2935f05b35a2Smrg relink_command= 2936f05b35a2Smrg func_source "$file" 2937f05b35a2Smrg 2938f05b35a2Smrg # Add the libdir to current_libdirs if it is the destination. 2939f05b35a2Smrg if test "X$destdir" = "X$libdir"; then 2940f05b35a2Smrg case "$current_libdirs " in 2941f05b35a2Smrg *" $libdir "*) ;; 294267ab2ff2Smrg *) func_append current_libdirs " $libdir" ;; 2943e0963edeSmrg esac 2944f05b35a2Smrg else 2945f05b35a2Smrg # Note the libdir as a future libdir. 2946f05b35a2Smrg case "$future_libdirs " in 2947f05b35a2Smrg *" $libdir "*) ;; 294867ab2ff2Smrg *) func_append future_libdirs " $libdir" ;; 2949f05b35a2Smrg esac 2950f05b35a2Smrg fi 2951e0963edeSmrg 2952f05b35a2Smrg func_dirname "$file" "/" "" 2953f05b35a2Smrg dir="$func_dirname_result" 295467ab2ff2Smrg func_append dir "$objdir" 2955f05b35a2Smrg 2956f05b35a2Smrg if test -n "$relink_command"; then 2957f05b35a2Smrg # Determine the prefix the user has applied to our future dir. 295849e108a1Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 2959f05b35a2Smrg 2960f05b35a2Smrg # Don't allow the user to place us outside of our expected 2961f05b35a2Smrg # location b/c this prevents finding dependent libraries that 2962f05b35a2Smrg # are installed to the same prefix. 2963f05b35a2Smrg # At present, this check doesn't affect windows .dll's that 2964f05b35a2Smrg # are installed into $libdir/../bin (currently, that works fine) 2965f05b35a2Smrg # but it's something to keep an eye on. 2966f05b35a2Smrg test "$inst_prefix_dir" = "$destdir" && \ 2967f05b35a2Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 2968f05b35a2Smrg 2969f05b35a2Smrg if test -n "$inst_prefix_dir"; then 2970f05b35a2Smrg # Stick the inst_prefix_dir data into the link command. 297149e108a1Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 2972f05b35a2Smrg else 297349e108a1Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 2974f05b35a2Smrg fi 2975f05b35a2Smrg 2976f05b35a2Smrg func_warning "relinking \`$file'" 2977f05b35a2Smrg func_show_eval "$relink_command" \ 2978f05b35a2Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 2979f05b35a2Smrg fi 2980f05b35a2Smrg 2981f05b35a2Smrg # See the names of the shared library. 2982f05b35a2Smrg set dummy $library_names; shift 2983f05b35a2Smrg if test -n "$1"; then 2984f05b35a2Smrg realname="$1" 2985f05b35a2Smrg shift 2986f05b35a2Smrg 2987f05b35a2Smrg srcname="$realname" 2988f05b35a2Smrg test -n "$relink_command" && srcname="$realname"T 2989f05b35a2Smrg 2990f05b35a2Smrg # Install the shared library and build the symlinks. 299149e108a1Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 2992f05b35a2Smrg 'exit $?' 2993f05b35a2Smrg tstripme="$stripme" 2994f05b35a2Smrg case $host_os in 2995f05b35a2Smrg cygwin* | mingw* | pw32* | cegcc*) 2996f05b35a2Smrg case $realname in 2997f05b35a2Smrg *.dll.a) 2998f05b35a2Smrg tstripme="" 2999f05b35a2Smrg ;; 3000f05b35a2Smrg esac 3001e0963edeSmrg ;; 3002e0963edeSmrg esac 3003f05b35a2Smrg if test -n "$tstripme" && test -n "$striplib"; then 3004f05b35a2Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 3005e0963edeSmrg fi 3006f05b35a2Smrg 3007f05b35a2Smrg if test "$#" -gt 0; then 3008f05b35a2Smrg # Delete the old symlinks, and create new ones. 3009f05b35a2Smrg # Try `ln -sf' first, because the `ln' binary might depend on 3010f05b35a2Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 3011f05b35a2Smrg # so we also need to try rm && ln -s. 3012f05b35a2Smrg for linkname 3013f05b35a2Smrg do 3014f05b35a2Smrg test "$linkname" != "$realname" \ 3015f05b35a2Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 3016e0963edeSmrg done 3017e0963edeSmrg fi 3018e0963edeSmrg 3019f05b35a2Smrg # Do each command in the postinstall commands. 3020f05b35a2Smrg lib="$destdir/$realname" 3021f05b35a2Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 3022e0963edeSmrg fi 3023e0963edeSmrg 3024f05b35a2Smrg # Install the pseudo-library for information purposes. 3025f05b35a2Smrg func_basename "$file" 3026f05b35a2Smrg name="$func_basename_result" 3027f05b35a2Smrg instname="$dir/$name"i 3028f05b35a2Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 3029e0963edeSmrg 3030f05b35a2Smrg # Maybe install the static library, too. 303167ab2ff2Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 3032f05b35a2Smrg ;; 3033e0963edeSmrg 3034f05b35a2Smrg *.lo) 3035f05b35a2Smrg # Install (i.e. copy) a libtool object. 3036e0963edeSmrg 3037f05b35a2Smrg # Figure out destination file name, if it wasn't already specified. 3038f05b35a2Smrg if test -n "$destname"; then 3039f05b35a2Smrg destfile="$destdir/$destname" 3040f05b35a2Smrg else 3041f05b35a2Smrg func_basename "$file" 3042f05b35a2Smrg destfile="$func_basename_result" 3043f05b35a2Smrg destfile="$destdir/$destfile" 3044e0963edeSmrg fi 3045e0963edeSmrg 3046f05b35a2Smrg # Deduce the name of the destination old-style object file. 3047f05b35a2Smrg case $destfile in 3048f05b35a2Smrg *.lo) 3049f05b35a2Smrg func_lo2o "$destfile" 3050f05b35a2Smrg staticdest=$func_lo2o_result 3051f05b35a2Smrg ;; 3052f05b35a2Smrg *.$objext) 3053f05b35a2Smrg staticdest="$destfile" 3054f05b35a2Smrg destfile= 3055f05b35a2Smrg ;; 3056f05b35a2Smrg *) 3057f05b35a2Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 3058f05b35a2Smrg ;; 3059f05b35a2Smrg esac 3060e0963edeSmrg 3061f05b35a2Smrg # Install the libtool object if requested. 3062f05b35a2Smrg test -n "$destfile" && \ 3063f05b35a2Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 3064e0963edeSmrg 3065f05b35a2Smrg # Install the old object if enabled. 3066f05b35a2Smrg if test "$build_old_libs" = yes; then 3067f05b35a2Smrg # Deduce the name of the old-style object file. 3068f05b35a2Smrg func_lo2o "$file" 3069f05b35a2Smrg staticobj=$func_lo2o_result 3070f05b35a2Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 3071e0963edeSmrg fi 3072f05b35a2Smrg exit $EXIT_SUCCESS 3073f05b35a2Smrg ;; 3074e0963edeSmrg 3075f05b35a2Smrg *) 3076f05b35a2Smrg # Figure out destination file name, if it wasn't already specified. 3077f05b35a2Smrg if test -n "$destname"; then 3078f05b35a2Smrg destfile="$destdir/$destname" 3079f05b35a2Smrg else 3080f05b35a2Smrg func_basename "$file" 3081f05b35a2Smrg destfile="$func_basename_result" 3082f05b35a2Smrg destfile="$destdir/$destfile" 3083f05b35a2Smrg fi 3084e0963edeSmrg 3085f05b35a2Smrg # If the file is missing, and there is a .exe on the end, strip it 3086f05b35a2Smrg # because it is most likely a libtool script we actually want to 3087f05b35a2Smrg # install 3088f05b35a2Smrg stripped_ext="" 3089f05b35a2Smrg case $file in 3090f05b35a2Smrg *.exe) 3091f05b35a2Smrg if test ! -f "$file"; then 3092f05b35a2Smrg func_stripname '' '.exe' "$file" 3093f05b35a2Smrg file=$func_stripname_result 3094f05b35a2Smrg stripped_ext=".exe" 3095f05b35a2Smrg fi 3096f05b35a2Smrg ;; 3097f05b35a2Smrg esac 3098f05b35a2Smrg 3099f05b35a2Smrg # Do a test to see if this is really a libtool program. 3100f05b35a2Smrg case $host in 3101f05b35a2Smrg *cygwin* | *mingw*) 3102f05b35a2Smrg if func_ltwrapper_executable_p "$file"; then 3103f05b35a2Smrg func_ltwrapper_scriptname "$file" 3104f05b35a2Smrg wrapper=$func_ltwrapper_scriptname_result 3105f05b35a2Smrg else 3106f05b35a2Smrg func_stripname '' '.exe' "$file" 3107f05b35a2Smrg wrapper=$func_stripname_result 3108f05b35a2Smrg fi 3109f05b35a2Smrg ;; 3110e0963edeSmrg *) 3111f05b35a2Smrg wrapper=$file 3112f05b35a2Smrg ;; 3113f05b35a2Smrg esac 3114f05b35a2Smrg if func_ltwrapper_script_p "$wrapper"; then 3115f05b35a2Smrg notinst_deplibs= 3116f05b35a2Smrg relink_command= 3117f05b35a2Smrg 3118f05b35a2Smrg func_source "$wrapper" 3119f05b35a2Smrg 3120f05b35a2Smrg # Check the variables that should have been set. 3121f05b35a2Smrg test -z "$generated_by_libtool_version" && \ 3122f05b35a2Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 3123f05b35a2Smrg 3124f05b35a2Smrg finalize=yes 3125f05b35a2Smrg for lib in $notinst_deplibs; do 3126f05b35a2Smrg # Check to see that each library is installed. 3127f05b35a2Smrg libdir= 3128f05b35a2Smrg if test -f "$lib"; then 3129f05b35a2Smrg func_source "$lib" 3130f05b35a2Smrg fi 313149e108a1Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 3132f05b35a2Smrg if test -n "$libdir" && test ! -f "$libfile"; then 3133f05b35a2Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 3134f05b35a2Smrg finalize=no 3135f05b35a2Smrg fi 3136f05b35a2Smrg done 3137f05b35a2Smrg 3138f05b35a2Smrg relink_command= 3139f05b35a2Smrg func_source "$wrapper" 3140f05b35a2Smrg 3141f05b35a2Smrg outputname= 3142f05b35a2Smrg if test "$fast_install" = no && test -n "$relink_command"; then 3143f05b35a2Smrg $opt_dry_run || { 3144f05b35a2Smrg if test "$finalize" = yes; then 3145f05b35a2Smrg tmpdir=`func_mktempdir` 3146f05b35a2Smrg func_basename "$file$stripped_ext" 3147f05b35a2Smrg file="$func_basename_result" 3148f05b35a2Smrg outputname="$tmpdir/$file" 3149f05b35a2Smrg # Replace the output file specification. 315049e108a1Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 3151f05b35a2Smrg 3152f05b35a2Smrg $opt_silent || { 3153f05b35a2Smrg func_quote_for_expand "$relink_command" 3154f05b35a2Smrg eval "func_echo $func_quote_for_expand_result" 3155f05b35a2Smrg } 3156f05b35a2Smrg if eval "$relink_command"; then : 3157f05b35a2Smrg else 3158f05b35a2Smrg func_error "error: relink \`$file' with the above command before installing it" 3159f05b35a2Smrg $opt_dry_run || ${RM}r "$tmpdir" 3160f05b35a2Smrg continue 3161f05b35a2Smrg fi 3162f05b35a2Smrg file="$outputname" 3163f05b35a2Smrg else 3164f05b35a2Smrg func_warning "cannot relink \`$file'" 3165f05b35a2Smrg fi 3166f05b35a2Smrg } 3167f05b35a2Smrg else 3168f05b35a2Smrg # Install the binary that we compiled earlier. 316949e108a1Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 3170e0963edeSmrg fi 3171f05b35a2Smrg fi 3172f05b35a2Smrg 3173f05b35a2Smrg # remove .exe since cygwin /usr/bin/install will append another 3174f05b35a2Smrg # one anyway 3175f05b35a2Smrg case $install_prog,$host in 3176f05b35a2Smrg */usr/bin/install*,*cygwin*) 3177f05b35a2Smrg case $file:$destfile in 3178f05b35a2Smrg *.exe:*.exe) 3179f05b35a2Smrg # this is ok 3180f05b35a2Smrg ;; 3181f05b35a2Smrg *.exe:*) 3182f05b35a2Smrg destfile=$destfile.exe 3183f05b35a2Smrg ;; 3184f05b35a2Smrg *:*.exe) 3185f05b35a2Smrg func_stripname '' '.exe' "$destfile" 3186f05b35a2Smrg destfile=$func_stripname_result 3187f05b35a2Smrg ;; 3188f05b35a2Smrg esac 3189e0963edeSmrg ;; 3190e0963edeSmrg esac 3191f05b35a2Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 3192f05b35a2Smrg $opt_dry_run || if test -n "$outputname"; then 3193f05b35a2Smrg ${RM}r "$tmpdir" 3194f05b35a2Smrg fi 3195f05b35a2Smrg ;; 3196f05b35a2Smrg esac 3197f05b35a2Smrg done 3198e0963edeSmrg 3199f05b35a2Smrg for file in $staticlibs; do 3200f05b35a2Smrg func_basename "$file" 3201f05b35a2Smrg name="$func_basename_result" 3202f05b35a2Smrg 3203f05b35a2Smrg # Set up the ranlib parameters. 3204f05b35a2Smrg oldlib="$destdir/$name" 3205e494fffdSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 3206e494fffdSmrg tool_oldlib=$func_to_tool_file_result 3207f05b35a2Smrg 3208f05b35a2Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 3209f05b35a2Smrg 3210f05b35a2Smrg if test -n "$stripme" && test -n "$old_striplib"; then 3211e494fffdSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 3212f05b35a2Smrg fi 3213f05b35a2Smrg 3214f05b35a2Smrg # Do each command in the postinstall commands. 3215f05b35a2Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 3216f05b35a2Smrg done 3217f05b35a2Smrg 3218f05b35a2Smrg test -n "$future_libdirs" && \ 3219f05b35a2Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 3220f05b35a2Smrg 3221f05b35a2Smrg if test -n "$current_libdirs"; then 3222f05b35a2Smrg # Maybe just do a dry run. 3223f05b35a2Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 3224f05b35a2Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 3225f05b35a2Smrg else 3226f05b35a2Smrg exit $EXIT_SUCCESS 3227f05b35a2Smrg fi 3228f05b35a2Smrg} 3229f05b35a2Smrg 323067ab2ff2Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 3231f05b35a2Smrg 3232f05b35a2Smrg 3233f05b35a2Smrg# func_generate_dlsyms outputname originator pic_p 3234f05b35a2Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 3235f05b35a2Smrg# a dlpreopen symbol table. 3236f05b35a2Smrgfunc_generate_dlsyms () 3237f05b35a2Smrg{ 3238f05b35a2Smrg $opt_debug 3239f05b35a2Smrg my_outputname="$1" 3240f05b35a2Smrg my_originator="$2" 3241f05b35a2Smrg my_pic_p="${3-no}" 3242f05b35a2Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 3243f05b35a2Smrg my_dlsyms= 3244f05b35a2Smrg 3245f05b35a2Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 3246f05b35a2Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 3247f05b35a2Smrg my_dlsyms="${my_outputname}S.c" 3248f05b35a2Smrg else 3249f05b35a2Smrg func_error "not configured to extract global symbols from dlpreopened files" 3250f05b35a2Smrg fi 3251f05b35a2Smrg fi 3252f05b35a2Smrg 3253f05b35a2Smrg if test -n "$my_dlsyms"; then 3254f05b35a2Smrg case $my_dlsyms in 3255f05b35a2Smrg "") ;; 3256f05b35a2Smrg *.c) 3257f05b35a2Smrg # Discover the nlist of each of the dlfiles. 3258f05b35a2Smrg nlist="$output_objdir/${my_outputname}.nm" 3259f05b35a2Smrg 3260f05b35a2Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 3261f05b35a2Smrg 3262f05b35a2Smrg # Parse the name list into a source file. 3263f05b35a2Smrg func_verbose "creating $output_objdir/$my_dlsyms" 3264f05b35a2Smrg 3265f05b35a2Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 3266f05b35a2Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 3267f05b35a2Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 3268f05b35a2Smrg 3269f05b35a2Smrg#ifdef __cplusplus 3270f05b35a2Smrgextern \"C\" { 3271f05b35a2Smrg#endif 3272f05b35a2Smrg 327349e108a1Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 327449e108a1Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 327549e108a1Smrg#endif 327649e108a1Smrg 327767ab2ff2Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 327867ab2ff2Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 327967ab2ff2Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 328067ab2ff2Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 328167ab2ff2Smrg# define LT_DLSYM_CONST 328267ab2ff2Smrg#elif defined(__osf__) 328367ab2ff2Smrg/* This system does not cope well with relocations in const data. */ 328467ab2ff2Smrg# define LT_DLSYM_CONST 328567ab2ff2Smrg#else 328667ab2ff2Smrg# define LT_DLSYM_CONST const 328767ab2ff2Smrg#endif 328867ab2ff2Smrg 3289f05b35a2Smrg/* External symbol declarations for the compiler. */\ 3290f05b35a2Smrg" 3291f05b35a2Smrg 3292f05b35a2Smrg if test "$dlself" = yes; then 3293f05b35a2Smrg func_verbose "generating symbol list for \`$output'" 3294f05b35a2Smrg 3295f05b35a2Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 3296f05b35a2Smrg 3297f05b35a2Smrg # Add our own program objects to the symbol list. 329849e108a1Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 3299f05b35a2Smrg for progfile in $progfiles; do 330067ab2ff2Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 330167ab2ff2Smrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 330267ab2ff2Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 3303f05b35a2Smrg done 3304f05b35a2Smrg 3305f05b35a2Smrg if test -n "$exclude_expsyms"; then 3306f05b35a2Smrg $opt_dry_run || { 3307f05b35a2Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 3308f05b35a2Smrg eval '$MV "$nlist"T "$nlist"' 3309f05b35a2Smrg } 3310e0963edeSmrg fi 3311f05b35a2Smrg 3312f05b35a2Smrg if test -n "$export_symbols_regex"; then 3313f05b35a2Smrg $opt_dry_run || { 3314f05b35a2Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 3315f05b35a2Smrg eval '$MV "$nlist"T "$nlist"' 3316f05b35a2Smrg } 3317f05b35a2Smrg fi 3318f05b35a2Smrg 3319f05b35a2Smrg # Prepare the list of exported symbols 3320f05b35a2Smrg if test -z "$export_symbols"; then 3321f05b35a2Smrg export_symbols="$output_objdir/$outputname.exp" 3322f05b35a2Smrg $opt_dry_run || { 3323f05b35a2Smrg $RM $export_symbols 3324f05b35a2Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 3325f05b35a2Smrg case $host in 3326f05b35a2Smrg *cygwin* | *mingw* | *cegcc* ) 3327f05b35a2Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3328f05b35a2Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 3329f05b35a2Smrg ;; 3330f05b35a2Smrg esac 3331f05b35a2Smrg } 3332e0963edeSmrg else 3333f05b35a2Smrg $opt_dry_run || { 3334f05b35a2Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 3335f05b35a2Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 3336f05b35a2Smrg eval '$MV "$nlist"T "$nlist"' 3337f05b35a2Smrg case $host in 333849e108a1Smrg *cygwin* | *mingw* | *cegcc* ) 3339f05b35a2Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3340f05b35a2Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 3341f05b35a2Smrg ;; 3342f05b35a2Smrg esac 3343f05b35a2Smrg } 3344e0963edeSmrg fi 3345f05b35a2Smrg fi 3346e0963edeSmrg 3347f05b35a2Smrg for dlprefile in $dlprefiles; do 3348f05b35a2Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 3349f05b35a2Smrg func_basename "$dlprefile" 3350f05b35a2Smrg name="$func_basename_result" 335167ab2ff2Smrg case $host in 335267ab2ff2Smrg *cygwin* | *mingw* | *cegcc* ) 335367ab2ff2Smrg # if an import library, we need to obtain dlname 335467ab2ff2Smrg if func_win32_import_lib_p "$dlprefile"; then 335567ab2ff2Smrg func_tr_sh "$dlprefile" 335667ab2ff2Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 335767ab2ff2Smrg dlprefile_dlbasename="" 335867ab2ff2Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 335967ab2ff2Smrg # Use subshell, to avoid clobbering current variable values 336067ab2ff2Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 336167ab2ff2Smrg if test -n "$dlprefile_dlname" ; then 336267ab2ff2Smrg func_basename "$dlprefile_dlname" 336367ab2ff2Smrg dlprefile_dlbasename="$func_basename_result" 336467ab2ff2Smrg else 336567ab2ff2Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 336667ab2ff2Smrg $sharedlib_from_linklib_cmd "$dlprefile" 336767ab2ff2Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 336867ab2ff2Smrg fi 336967ab2ff2Smrg fi 337067ab2ff2Smrg $opt_dry_run || { 337167ab2ff2Smrg if test -n "$dlprefile_dlbasename" ; then 337267ab2ff2Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 337367ab2ff2Smrg else 337467ab2ff2Smrg func_warning "Could not compute DLL name from $name" 337567ab2ff2Smrg eval '$ECHO ": $name " >> "$nlist"' 337667ab2ff2Smrg fi 337767ab2ff2Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 337867ab2ff2Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 337967ab2ff2Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 338067ab2ff2Smrg } 338167ab2ff2Smrg else # not an import lib 338267ab2ff2Smrg $opt_dry_run || { 338367ab2ff2Smrg eval '$ECHO ": $name " >> "$nlist"' 338467ab2ff2Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 338567ab2ff2Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 338667ab2ff2Smrg } 338767ab2ff2Smrg fi 338867ab2ff2Smrg ;; 338967ab2ff2Smrg *) 339067ab2ff2Smrg $opt_dry_run || { 339167ab2ff2Smrg eval '$ECHO ": $name " >> "$nlist"' 339267ab2ff2Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 339367ab2ff2Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 339467ab2ff2Smrg } 339567ab2ff2Smrg ;; 339667ab2ff2Smrg esac 3397f05b35a2Smrg done 3398f05b35a2Smrg 3399f05b35a2Smrg $opt_dry_run || { 3400f05b35a2Smrg # Make sure we have at least an empty file. 3401f05b35a2Smrg test -f "$nlist" || : > "$nlist" 3402f05b35a2Smrg 3403f05b35a2Smrg if test -n "$exclude_expsyms"; then 3404f05b35a2Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 3405f05b35a2Smrg $MV "$nlist"T "$nlist" 3406e0963edeSmrg fi 3407f05b35a2Smrg 3408f05b35a2Smrg # Try sorting and uniquifying the output. 3409f05b35a2Smrg if $GREP -v "^: " < "$nlist" | 3410f05b35a2Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 3411f05b35a2Smrg sort -k 3 3412f05b35a2Smrg else 3413f05b35a2Smrg sort +2 3414f05b35a2Smrg fi | 3415f05b35a2Smrg uniq > "$nlist"S; then 3416f05b35a2Smrg : 3417e0963edeSmrg else 3418f05b35a2Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 3419e0963edeSmrg fi 3420e0963edeSmrg 3421f05b35a2Smrg if test -f "$nlist"S; then 3422f05b35a2Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 3423e0963edeSmrg else 342449e108a1Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 3425e0963edeSmrg fi 3426e0963edeSmrg 342749e108a1Smrg echo >> "$output_objdir/$my_dlsyms" "\ 3428e0963edeSmrg 3429f05b35a2Smrg/* The mapping between symbol names and symbols. */ 3430f05b35a2Smrgtypedef struct { 3431f05b35a2Smrg const char *name; 3432f05b35a2Smrg void *address; 3433f05b35a2Smrg} lt_dlsymlist; 343467ab2ff2Smrgextern LT_DLSYM_CONST lt_dlsymlist 3435f05b35a2Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 343667ab2ff2SmrgLT_DLSYM_CONST lt_dlsymlist 3437f05b35a2Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 3438f05b35a2Smrg{\ 3439f05b35a2Smrg { \"$my_originator\", (void *) 0 }," 3440e0963edeSmrg 3441f05b35a2Smrg case $need_lib_prefix in 3442f05b35a2Smrg no) 3443f05b35a2Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 3444f05b35a2Smrg ;; 3445f05b35a2Smrg *) 3446f05b35a2Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 3447f05b35a2Smrg ;; 3448f05b35a2Smrg esac 344949e108a1Smrg echo >> "$output_objdir/$my_dlsyms" "\ 3450f05b35a2Smrg {0, (void *) 0} 3451f05b35a2Smrg}; 3452e0963edeSmrg 3453f05b35a2Smrg/* This works around a problem in FreeBSD linker */ 3454f05b35a2Smrg#ifdef FREEBSD_WORKAROUND 3455f05b35a2Smrgstatic const void *lt_preloaded_setup() { 3456f05b35a2Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 3457f05b35a2Smrg} 3458f05b35a2Smrg#endif 3459e0963edeSmrg 3460f05b35a2Smrg#ifdef __cplusplus 3461f05b35a2Smrg} 3462f05b35a2Smrg#endif\ 3463f05b35a2Smrg" 3464f05b35a2Smrg } # !$opt_dry_run 3465e0963edeSmrg 3466f05b35a2Smrg pic_flag_for_symtable= 3467f05b35a2Smrg case "$compile_command " in 3468f05b35a2Smrg *" -static "*) ;; 3469f05b35a2Smrg *) 3470f05b35a2Smrg case $host in 3471f05b35a2Smrg # compiling the symbol table file with pic_flag works around 3472f05b35a2Smrg # a FreeBSD bug that causes programs to crash when -lm is 3473f05b35a2Smrg # linked before any other PIC object. But we must not use 3474f05b35a2Smrg # pic_flag when linking with -static. The problem exists in 3475f05b35a2Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 3476e494fffdSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 3477f05b35a2Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 3478f05b35a2Smrg *-*-hpux*) 3479f05b35a2Smrg pic_flag_for_symtable=" $pic_flag" ;; 3480f05b35a2Smrg *) 3481f05b35a2Smrg if test "X$my_pic_p" != Xno; then 3482f05b35a2Smrg pic_flag_for_symtable=" $pic_flag" 3483f05b35a2Smrg fi 3484f05b35a2Smrg ;; 3485f05b35a2Smrg esac 3486f05b35a2Smrg ;; 3487f05b35a2Smrg esac 3488f05b35a2Smrg symtab_cflags= 3489f05b35a2Smrg for arg in $LTCFLAGS; do 3490f05b35a2Smrg case $arg in 3491f05b35a2Smrg -pie | -fpie | -fPIE) ;; 349267ab2ff2Smrg *) func_append symtab_cflags " $arg" ;; 3493f05b35a2Smrg esac 3494f05b35a2Smrg done 3495e0963edeSmrg 3496f05b35a2Smrg # Now compile the dynamic symbol file. 3497f05b35a2Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 3498e0963edeSmrg 3499f05b35a2Smrg # Clean up the generated files. 3500f05b35a2Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 3501e0963edeSmrg 3502f05b35a2Smrg # Transform the symbol file into the correct name. 3503f05b35a2Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 3504f05b35a2Smrg case $host in 3505f05b35a2Smrg *cygwin* | *mingw* | *cegcc* ) 3506f05b35a2Smrg if test -f "$output_objdir/$my_outputname.def"; then 350749e108a1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 350849e108a1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3509f05b35a2Smrg else 351049e108a1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351149e108a1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3512f05b35a2Smrg fi 3513f05b35a2Smrg ;; 3514f05b35a2Smrg *) 351549e108a1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351649e108a1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3517f05b35a2Smrg ;; 3518f05b35a2Smrg esac 3519f05b35a2Smrg ;; 3520f05b35a2Smrg *) 3521f05b35a2Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 3522f05b35a2Smrg ;; 3523f05b35a2Smrg esac 3524f05b35a2Smrg else 3525f05b35a2Smrg # We keep going just in case the user didn't refer to 3526f05b35a2Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 3527f05b35a2Smrg # really was required. 3528e0963edeSmrg 3529f05b35a2Smrg # Nullify the symbol file. 353049e108a1Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 353149e108a1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 3532f05b35a2Smrg fi 3533f05b35a2Smrg} 3534e0963edeSmrg 3535f05b35a2Smrg# func_win32_libid arg 3536f05b35a2Smrg# return the library type of file 'arg' 3537f05b35a2Smrg# 3538f05b35a2Smrg# Need a lot of goo to handle *both* DLLs and import libs 3539f05b35a2Smrg# Has to be a shell function in order to 'eat' the argument 3540f05b35a2Smrg# that is supplied when $file_magic_command is called. 354149e108a1Smrg# Despite the name, also deal with 64 bit binaries. 3542f05b35a2Smrgfunc_win32_libid () 3543f05b35a2Smrg{ 3544f05b35a2Smrg $opt_debug 3545f05b35a2Smrg win32_libid_type="unknown" 3546f05b35a2Smrg win32_fileres=`file -L $1 2>/dev/null` 3547f05b35a2Smrg case $win32_fileres in 3548f05b35a2Smrg *ar\ archive\ import\ library*) # definitely import 3549f05b35a2Smrg win32_libid_type="x86 archive import" 3550f05b35a2Smrg ;; 3551f05b35a2Smrg *ar\ archive*) # could be an import, or static 355249e108a1Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 3553f05b35a2Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 355449e108a1Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 355567ab2ff2Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 355667ab2ff2Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 3557f05b35a2Smrg $SED -n -e ' 3558f05b35a2Smrg 1,100{ 3559f05b35a2Smrg / I /{ 3560f05b35a2Smrg s,.*,import, 3561f05b35a2Smrg p 3562f05b35a2Smrg q 3563f05b35a2Smrg } 3564f05b35a2Smrg }'` 3565f05b35a2Smrg case $win32_nmres in 3566f05b35a2Smrg import*) win32_libid_type="x86 archive import";; 3567f05b35a2Smrg *) win32_libid_type="x86 archive static";; 3568f05b35a2Smrg esac 3569f05b35a2Smrg fi 3570f05b35a2Smrg ;; 3571f05b35a2Smrg *DLL*) 3572f05b35a2Smrg win32_libid_type="x86 DLL" 3573f05b35a2Smrg ;; 3574f05b35a2Smrg *executable*) # but shell scripts are "executable" too... 3575f05b35a2Smrg case $win32_fileres in 3576f05b35a2Smrg *MS\ Windows\ PE\ Intel*) 3577f05b35a2Smrg win32_libid_type="x86 DLL" 3578f05b35a2Smrg ;; 3579f05b35a2Smrg esac 3580f05b35a2Smrg ;; 3581f05b35a2Smrg esac 3582f05b35a2Smrg $ECHO "$win32_libid_type" 3583f05b35a2Smrg} 3584e0963edeSmrg 358567ab2ff2Smrg# func_cygming_dll_for_implib ARG 358667ab2ff2Smrg# 358767ab2ff2Smrg# Platform-specific function to extract the 358867ab2ff2Smrg# name of the DLL associated with the specified 358967ab2ff2Smrg# import library ARG. 359067ab2ff2Smrg# Invoked by eval'ing the libtool variable 359167ab2ff2Smrg# $sharedlib_from_linklib_cmd 359267ab2ff2Smrg# Result is available in the variable 359367ab2ff2Smrg# $sharedlib_from_linklib_result 359467ab2ff2Smrgfunc_cygming_dll_for_implib () 359567ab2ff2Smrg{ 359667ab2ff2Smrg $opt_debug 359767ab2ff2Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 359867ab2ff2Smrg} 359967ab2ff2Smrg 360067ab2ff2Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 360167ab2ff2Smrg# 360267ab2ff2Smrg# The is the core of a fallback implementation of a 360367ab2ff2Smrg# platform-specific function to extract the name of the 360467ab2ff2Smrg# DLL associated with the specified import library LIBNAME. 360567ab2ff2Smrg# 360667ab2ff2Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 360767ab2ff2Smrg# on the platform and compiler that created the implib. 360867ab2ff2Smrg# 360967ab2ff2Smrg# Echos the name of the DLL associated with the 361067ab2ff2Smrg# specified import library. 361167ab2ff2Smrgfunc_cygming_dll_for_implib_fallback_core () 361267ab2ff2Smrg{ 361367ab2ff2Smrg $opt_debug 361467ab2ff2Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 361567ab2ff2Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 361667ab2ff2Smrg $SED '/^Contents of section '"$match_literal"':/{ 361767ab2ff2Smrg # Place marker at beginning of archive member dllname section 361867ab2ff2Smrg s/.*/====MARK====/ 361967ab2ff2Smrg p 362067ab2ff2Smrg d 362167ab2ff2Smrg } 362267ab2ff2Smrg # These lines can sometimes be longer than 43 characters, but 362367ab2ff2Smrg # are always uninteresting 362467ab2ff2Smrg /:[ ]*file format pe[i]\{,1\}-/d 362567ab2ff2Smrg /^In archive [^:]*:/d 362667ab2ff2Smrg # Ensure marker is printed 362767ab2ff2Smrg /^====MARK====/p 362867ab2ff2Smrg # Remove all lines with less than 43 characters 362967ab2ff2Smrg /^.\{43\}/!d 363067ab2ff2Smrg # From remaining lines, remove first 43 characters 363167ab2ff2Smrg s/^.\{43\}//' | 363267ab2ff2Smrg $SED -n ' 363367ab2ff2Smrg # Join marker and all lines until next marker into a single line 363467ab2ff2Smrg /^====MARK====/ b para 363567ab2ff2Smrg H 363667ab2ff2Smrg $ b para 363767ab2ff2Smrg b 363867ab2ff2Smrg :para 363967ab2ff2Smrg x 364067ab2ff2Smrg s/\n//g 364167ab2ff2Smrg # Remove the marker 364267ab2ff2Smrg s/^====MARK====// 364367ab2ff2Smrg # Remove trailing dots and whitespace 364467ab2ff2Smrg s/[\. \t]*$// 364567ab2ff2Smrg # Print 364667ab2ff2Smrg /./p' | 364767ab2ff2Smrg # we now have a list, one entry per line, of the stringified 364867ab2ff2Smrg # contents of the appropriate section of all members of the 364967ab2ff2Smrg # archive which possess that section. Heuristic: eliminate 365067ab2ff2Smrg # all those which have a first or second character that is 365167ab2ff2Smrg # a '.' (that is, objdump's representation of an unprintable 365267ab2ff2Smrg # character.) This should work for all archives with less than 365367ab2ff2Smrg # 0x302f exports -- but will fail for DLLs whose name actually 365467ab2ff2Smrg # begins with a literal '.' or a single character followed by 365567ab2ff2Smrg # a '.'. 365667ab2ff2Smrg # 365767ab2ff2Smrg # Of those that remain, print the first one. 365867ab2ff2Smrg $SED -e '/^\./d;/^.\./d;q' 365967ab2ff2Smrg} 366067ab2ff2Smrg 366167ab2ff2Smrg# func_cygming_gnu_implib_p ARG 366267ab2ff2Smrg# This predicate returns with zero status (TRUE) if 366367ab2ff2Smrg# ARG is a GNU/binutils-style import library. Returns 366467ab2ff2Smrg# with nonzero status (FALSE) otherwise. 366567ab2ff2Smrgfunc_cygming_gnu_implib_p () 366667ab2ff2Smrg{ 366767ab2ff2Smrg $opt_debug 366867ab2ff2Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 366967ab2ff2Smrg 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)$'` 367067ab2ff2Smrg test -n "$func_cygming_gnu_implib_tmp" 367167ab2ff2Smrg} 367267ab2ff2Smrg 367367ab2ff2Smrg# func_cygming_ms_implib_p ARG 367467ab2ff2Smrg# This predicate returns with zero status (TRUE) if 367567ab2ff2Smrg# ARG is an MS-style import library. Returns 367667ab2ff2Smrg# with nonzero status (FALSE) otherwise. 367767ab2ff2Smrgfunc_cygming_ms_implib_p () 367867ab2ff2Smrg{ 367967ab2ff2Smrg $opt_debug 368067ab2ff2Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 368167ab2ff2Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 368267ab2ff2Smrg test -n "$func_cygming_ms_implib_tmp" 368367ab2ff2Smrg} 368467ab2ff2Smrg 368567ab2ff2Smrg# func_cygming_dll_for_implib_fallback ARG 368667ab2ff2Smrg# Platform-specific function to extract the 368767ab2ff2Smrg# name of the DLL associated with the specified 368867ab2ff2Smrg# import library ARG. 368967ab2ff2Smrg# 369067ab2ff2Smrg# This fallback implementation is for use when $DLLTOOL 369167ab2ff2Smrg# does not support the --identify-strict option. 369267ab2ff2Smrg# Invoked by eval'ing the libtool variable 369367ab2ff2Smrg# $sharedlib_from_linklib_cmd 369467ab2ff2Smrg# Result is available in the variable 369567ab2ff2Smrg# $sharedlib_from_linklib_result 369667ab2ff2Smrgfunc_cygming_dll_for_implib_fallback () 369767ab2ff2Smrg{ 369867ab2ff2Smrg $opt_debug 369967ab2ff2Smrg if func_cygming_gnu_implib_p "$1" ; then 370067ab2ff2Smrg # binutils import library 370167ab2ff2Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 370267ab2ff2Smrg elif func_cygming_ms_implib_p "$1" ; then 370367ab2ff2Smrg # ms-generated import library 370467ab2ff2Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 370567ab2ff2Smrg else 370667ab2ff2Smrg # unknown 370767ab2ff2Smrg sharedlib_from_linklib_result="" 370867ab2ff2Smrg fi 370967ab2ff2Smrg} 3710e0963edeSmrg 3711e0963edeSmrg 3712f05b35a2Smrg# func_extract_an_archive dir oldlib 3713f05b35a2Smrgfunc_extract_an_archive () 3714f05b35a2Smrg{ 3715f05b35a2Smrg $opt_debug 3716f05b35a2Smrg f_ex_an_ar_dir="$1"; shift 3717f05b35a2Smrg f_ex_an_ar_oldlib="$1" 371849e108a1Smrg if test "$lock_old_archive_extraction" = yes; then 371949e108a1Smrg lockfile=$f_ex_an_ar_oldlib.lock 372049e108a1Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 372149e108a1Smrg func_echo "Waiting for $lockfile to be removed" 372249e108a1Smrg sleep 2 372349e108a1Smrg done 372449e108a1Smrg fi 372549e108a1Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 372649e108a1Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 372749e108a1Smrg if test "$lock_old_archive_extraction" = yes; then 372849e108a1Smrg $opt_dry_run || rm -f "$lockfile" 372949e108a1Smrg fi 3730f05b35a2Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 3731f05b35a2Smrg : 3732f05b35a2Smrg else 3733f05b35a2Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 3734f05b35a2Smrg fi 3735f05b35a2Smrg} 3736e0963edeSmrg 3737e0963edeSmrg 3738f05b35a2Smrg# func_extract_archives gentop oldlib ... 3739f05b35a2Smrgfunc_extract_archives () 3740f05b35a2Smrg{ 3741f05b35a2Smrg $opt_debug 3742f05b35a2Smrg my_gentop="$1"; shift 3743f05b35a2Smrg my_oldlibs=${1+"$@"} 3744f05b35a2Smrg my_oldobjs="" 3745f05b35a2Smrg my_xlib="" 3746f05b35a2Smrg my_xabs="" 3747f05b35a2Smrg my_xdir="" 3748e0963edeSmrg 3749f05b35a2Smrg for my_xlib in $my_oldlibs; do 3750f05b35a2Smrg # Extract the objects. 3751f05b35a2Smrg case $my_xlib in 3752f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 3753f05b35a2Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 3754f05b35a2Smrg esac 3755f05b35a2Smrg func_basename "$my_xlib" 3756f05b35a2Smrg my_xlib="$func_basename_result" 3757f05b35a2Smrg my_xlib_u=$my_xlib 3758f05b35a2Smrg while :; do 3759f05b35a2Smrg case " $extracted_archives " in 3760f05b35a2Smrg *" $my_xlib_u "*) 3761f05b35a2Smrg func_arith $extracted_serial + 1 3762f05b35a2Smrg extracted_serial=$func_arith_result 3763f05b35a2Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 3764f05b35a2Smrg *) break ;; 3765f05b35a2Smrg esac 3766f05b35a2Smrg done 3767f05b35a2Smrg extracted_archives="$extracted_archives $my_xlib_u" 3768f05b35a2Smrg my_xdir="$my_gentop/$my_xlib_u" 3769e0963edeSmrg 3770f05b35a2Smrg func_mkdir_p "$my_xdir" 3771f05b35a2Smrg 3772f05b35a2Smrg case $host in 3773f05b35a2Smrg *-darwin*) 3774f05b35a2Smrg func_verbose "Extracting $my_xabs" 3775f05b35a2Smrg # Do not bother doing anything if just a dry run 3776f05b35a2Smrg $opt_dry_run || { 3777f05b35a2Smrg darwin_orig_dir=`pwd` 3778f05b35a2Smrg cd $my_xdir || exit $? 3779f05b35a2Smrg darwin_archive=$my_xabs 3780f05b35a2Smrg darwin_curdir=`pwd` 3781f05b35a2Smrg darwin_base_archive=`basename "$darwin_archive"` 3782f05b35a2Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 3783f05b35a2Smrg if test -n "$darwin_arches"; then 3784f05b35a2Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 3785f05b35a2Smrg darwin_arch= 3786f05b35a2Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 3787f05b35a2Smrg for darwin_arch in $darwin_arches ; do 3788f05b35a2Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3789f05b35a2Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 3790f05b35a2Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3791f05b35a2Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 3792f05b35a2Smrg cd "$darwin_curdir" 3793f05b35a2Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 3794f05b35a2Smrg done # $darwin_arches 3795f05b35a2Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 3796f05b35a2Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 3797f05b35a2Smrg darwin_file= 3798f05b35a2Smrg darwin_files= 3799f05b35a2Smrg for darwin_file in $darwin_filelist; do 380049e108a1Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 3801f05b35a2Smrg $LIPO -create -output "$darwin_file" $darwin_files 3802f05b35a2Smrg done # $darwin_filelist 3803f05b35a2Smrg $RM -rf unfat-$$ 3804f05b35a2Smrg cd "$darwin_orig_dir" 3805e0963edeSmrg else 3806f05b35a2Smrg cd $darwin_orig_dir 3807f05b35a2Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 3808f05b35a2Smrg fi # $darwin_arches 3809f05b35a2Smrg } # !$opt_dry_run 3810f05b35a2Smrg ;; 3811f05b35a2Smrg *) 3812f05b35a2Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 3813f05b35a2Smrg ;; 3814f05b35a2Smrg esac 381549e108a1Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 3816f05b35a2Smrg done 3817e0963edeSmrg 3818f05b35a2Smrg func_extract_archives_result="$my_oldobjs" 3819f05b35a2Smrg} 3820e0963edeSmrg 3821e0963edeSmrg 382249e108a1Smrg# func_emit_wrapper [arg=no] 382349e108a1Smrg# 382449e108a1Smrg# Emit a libtool wrapper script on stdout. 382549e108a1Smrg# Don't directly open a file because we may want to 382649e108a1Smrg# incorporate the script contents within a cygwin/mingw 382749e108a1Smrg# wrapper executable. Must ONLY be called from within 382849e108a1Smrg# func_mode_link because it depends on a number of variables 382949e108a1Smrg# set therein. 3830f05b35a2Smrg# 383149e108a1Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 383249e108a1Smrg# variable will take. If 'yes', then the emitted script 383349e108a1Smrg# will assume that the directory in which it is stored is 383449e108a1Smrg# the $objdir directory. This is a cygwin/mingw-specific 383549e108a1Smrg# behavior. 383649e108a1Smrgfunc_emit_wrapper () 3837f05b35a2Smrg{ 383849e108a1Smrg func_emit_wrapper_arg1=${1-no} 3839e0963edeSmrg 3840f05b35a2Smrg $ECHO "\ 3841f05b35a2Smrg#! $SHELL 3842e0963edeSmrg 3843f05b35a2Smrg# $output - temporary wrapper script for $objdir/$outputname 3844f05b35a2Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 3845f05b35a2Smrg# 3846f05b35a2Smrg# The $output program cannot be directly executed until all the libtool 3847f05b35a2Smrg# libraries that it depends on are installed. 3848f05b35a2Smrg# 3849f05b35a2Smrg# This wrapper script should never be moved out of the build directory. 3850f05b35a2Smrg# If it is, it will not operate correctly. 3851e0963edeSmrg 3852f05b35a2Smrg# Sed substitution that helps us do robust quoting. It backslashifies 3853f05b35a2Smrg# metacharacters that are still active within double-quoted strings. 3854f05b35a2Smrgsed_quote_subst='$sed_quote_subst' 3855e0963edeSmrg 3856f05b35a2Smrg# Be Bourne compatible 3857f05b35a2Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 3858f05b35a2Smrg emulate sh 3859f05b35a2Smrg NULLCMD=: 3860f05b35a2Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 3861f05b35a2Smrg # is contrary to our usage. Disable this feature. 3862f05b35a2Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 3863f05b35a2Smrg setopt NO_GLOB_SUBST 3864f05b35a2Smrgelse 3865f05b35a2Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 3866f05b35a2Smrgfi 3867f05b35a2SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 3868f05b35a2SmrgDUALCASE=1; export DUALCASE # for MKS sh 3869e0963edeSmrg 3870f05b35a2Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 3871f05b35a2Smrg# if CDPATH is set. 3872f05b35a2Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 3873e0963edeSmrg 3874f05b35a2Smrgrelink_command=\"$relink_command\" 3875e0963edeSmrg 3876f05b35a2Smrg# This environment variable determines our operation mode. 3877f05b35a2Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 3878f05b35a2Smrg # install mode needs the following variables: 3879f05b35a2Smrg generated_by_libtool_version='$macro_version' 3880f05b35a2Smrg notinst_deplibs='$notinst_deplibs' 3881f05b35a2Smrgelse 3882f05b35a2Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 3883f05b35a2Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 388449e108a1Smrg file=\"\$0\"" 388549e108a1Smrg 388649e108a1Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 388749e108a1Smrg $ECHO "\ 388849e108a1Smrg 388949e108a1Smrg# A function that is used when there is no print builtin or printf. 389049e108a1Smrgfunc_fallback_echo () 389149e108a1Smrg{ 389249e108a1Smrg eval 'cat <<_LTECHO_EOF 389349e108a1Smrg\$1 389449e108a1Smrg_LTECHO_EOF' 389549e108a1Smrg} 389649e108a1Smrg ECHO=\"$qECHO\" 389749e108a1Smrg fi 389849e108a1Smrg 389949e108a1Smrg# Very basic option parsing. These options are (a) specific to 390049e108a1Smrg# the libtool wrapper, (b) are identical between the wrapper 390149e108a1Smrg# /script/ and the wrapper /executable/ which is used only on 390249e108a1Smrg# windows platforms, and (c) all begin with the string "--lt-" 390349e108a1Smrg# (application programs are unlikely to have options which match 390449e108a1Smrg# this pattern). 390549e108a1Smrg# 390649e108a1Smrg# There are only two supported options: --lt-debug and 390749e108a1Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 390849e108a1Smrg# 390949e108a1Smrg# The first argument to this parsing function should be the 391049e108a1Smrg# script's $0 value, followed by "$@". 391149e108a1Smrglt_option_debug= 391249e108a1Smrgfunc_parse_lt_options () 391349e108a1Smrg{ 391449e108a1Smrg lt_script_arg0=\$0 391549e108a1Smrg shift 391649e108a1Smrg for lt_opt 391749e108a1Smrg do 391849e108a1Smrg case \"\$lt_opt\" in 391949e108a1Smrg --lt-debug) lt_option_debug=1 ;; 392049e108a1Smrg --lt-dump-script) 392149e108a1Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 392249e108a1Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 392349e108a1Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 392449e108a1Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 392549e108a1Smrg exit 0 392649e108a1Smrg ;; 392749e108a1Smrg --lt-*) 392849e108a1Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 392949e108a1Smrg exit 1 393049e108a1Smrg ;; 393149e108a1Smrg esac 393249e108a1Smrg done 393349e108a1Smrg 393449e108a1Smrg # Print the debug banner immediately: 393549e108a1Smrg if test -n \"\$lt_option_debug\"; then 393649e108a1Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 393749e108a1Smrg fi 393849e108a1Smrg} 393949e108a1Smrg 394049e108a1Smrg# Used when --lt-debug. Prints its arguments to stdout 394149e108a1Smrg# (redirection is the responsibility of the caller) 394249e108a1Smrgfunc_lt_dump_args () 394349e108a1Smrg{ 394449e108a1Smrg lt_dump_args_N=1; 394549e108a1Smrg for lt_arg 394649e108a1Smrg do 394749e108a1Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 394849e108a1Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 394949e108a1Smrg done 395049e108a1Smrg} 395149e108a1Smrg 395249e108a1Smrg# Core function for launching the target application 395349e108a1Smrgfunc_exec_program_core () 395449e108a1Smrg{ 3955f05b35a2Smrg" 395649e108a1Smrg case $host in 395749e108a1Smrg # Backslashes separate directories on plain windows 395849e108a1Smrg *-*-mingw | *-*-os2* | *-cegcc*) 395949e108a1Smrg $ECHO "\ 396049e108a1Smrg if test -n \"\$lt_option_debug\"; then 396149e108a1Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 396249e108a1Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 396349e108a1Smrg fi 396449e108a1Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 396549e108a1Smrg" 396649e108a1Smrg ;; 396749e108a1Smrg 396849e108a1Smrg *) 396949e108a1Smrg $ECHO "\ 397049e108a1Smrg if test -n \"\$lt_option_debug\"; then 397149e108a1Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 397249e108a1Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 397349e108a1Smrg fi 397449e108a1Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 397549e108a1Smrg" 397649e108a1Smrg ;; 397749e108a1Smrg esac 397849e108a1Smrg $ECHO "\ 397949e108a1Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 398049e108a1Smrg exit 1 398149e108a1Smrg} 398249e108a1Smrg 398349e108a1Smrg# A function to encapsulate launching the target application 398449e108a1Smrg# Strips options in the --lt-* namespace from \$@ and 398549e108a1Smrg# launches target application with the remaining arguments. 398649e108a1Smrgfunc_exec_program () 398749e108a1Smrg{ 3988e494fffdSmrg case \" \$* \" in 3989e494fffdSmrg *\\ --lt-*) 3990e494fffdSmrg for lt_wr_arg 3991e494fffdSmrg do 3992e494fffdSmrg case \$lt_wr_arg in 3993e494fffdSmrg --lt-*) ;; 3994e494fffdSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 3995e494fffdSmrg esac 3996e494fffdSmrg shift 3997e494fffdSmrg done ;; 3998e494fffdSmrg esac 399949e108a1Smrg func_exec_program_core \${1+\"\$@\"} 400049e108a1Smrg} 400149e108a1Smrg 400249e108a1Smrg # Parse options 400349e108a1Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 4004e0963edeSmrg 4005f05b35a2Smrg # Find the directory that this script lives in. 400649e108a1Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 4007f05b35a2Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 4008e0963edeSmrg 4009f05b35a2Smrg # Follow symbolic links until we get to the real thisdir. 401049e108a1Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 4011f05b35a2Smrg while test -n \"\$file\"; do 401249e108a1Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 4013f05b35a2Smrg 4014f05b35a2Smrg # If there was a directory component, then change thisdir. 4015f05b35a2Smrg if test \"x\$destdir\" != \"x\$file\"; then 4016f05b35a2Smrg case \"\$destdir\" in 4017f05b35a2Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 4018f05b35a2Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 4019e0963edeSmrg esac 4020f05b35a2Smrg fi 4021e0963edeSmrg 402249e108a1Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 402349e108a1Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 4024f05b35a2Smrg done 4025e0963edeSmrg 4026f05b35a2Smrg # Usually 'no', except on cygwin/mingw when embedded into 4027f05b35a2Smrg # the cwrapper. 402849e108a1Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 4029f05b35a2Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 4030f05b35a2Smrg # special case for '.' 4031f05b35a2Smrg if test \"\$thisdir\" = \".\"; then 4032f05b35a2Smrg thisdir=\`pwd\` 4033f05b35a2Smrg fi 4034f05b35a2Smrg # remove .libs from thisdir 4035f05b35a2Smrg case \"\$thisdir\" in 403649e108a1Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 4037f05b35a2Smrg $objdir ) thisdir=. ;; 4038f05b35a2Smrg esac 4039f05b35a2Smrg fi 4040f05b35a2Smrg 4041f05b35a2Smrg # Try to get the absolute directory name. 4042f05b35a2Smrg absdir=\`cd \"\$thisdir\" && pwd\` 4043f05b35a2Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 4044f05b35a2Smrg" 4045f05b35a2Smrg 4046f05b35a2Smrg if test "$fast_install" = yes; then 4047f05b35a2Smrg $ECHO "\ 4048f05b35a2Smrg program=lt-'$outputname'$exeext 4049f05b35a2Smrg progdir=\"\$thisdir/$objdir\" 4050f05b35a2Smrg 4051f05b35a2Smrg if test ! -f \"\$progdir/\$program\" || 4052f05b35a2Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 4053f05b35a2Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 4054f05b35a2Smrg 4055f05b35a2Smrg file=\"\$\$-\$program\" 4056f05b35a2Smrg 4057f05b35a2Smrg if test ! -d \"\$progdir\"; then 4058f05b35a2Smrg $MKDIR \"\$progdir\" 4059f05b35a2Smrg else 4060f05b35a2Smrg $RM \"\$progdir/\$file\" 4061f05b35a2Smrg fi" 4062f05b35a2Smrg 4063f05b35a2Smrg $ECHO "\ 4064f05b35a2Smrg 4065f05b35a2Smrg # relink executable if necessary 4066f05b35a2Smrg if test -n \"\$relink_command\"; then 4067f05b35a2Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 4068f05b35a2Smrg else 4069f05b35a2Smrg $ECHO \"\$relink_command_output\" >&2 4070f05b35a2Smrg $RM \"\$progdir/\$file\" 4071f05b35a2Smrg exit 1 4072e0963edeSmrg fi 4073f05b35a2Smrg fi 4074e0963edeSmrg 4075f05b35a2Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 4076f05b35a2Smrg { $RM \"\$progdir/\$program\"; 4077f05b35a2Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 4078f05b35a2Smrg $RM \"\$progdir/\$file\" 4079f05b35a2Smrg fi" 4080f05b35a2Smrg else 4081f05b35a2Smrg $ECHO "\ 4082f05b35a2Smrg program='$outputname' 4083f05b35a2Smrg progdir=\"\$thisdir/$objdir\" 4084f05b35a2Smrg" 4085e0963edeSmrg fi 4086e0963edeSmrg 4087f05b35a2Smrg $ECHO "\ 4088f05b35a2Smrg 4089f05b35a2Smrg if test -f \"\$progdir/\$program\"; then" 4090f05b35a2Smrg 409167ab2ff2Smrg # fixup the dll searchpath if we need to. 409267ab2ff2Smrg # 409367ab2ff2Smrg # Fix the DLL searchpath if we need to. Do this before prepending 409467ab2ff2Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 409567ab2ff2Smrg # libraries must come first. 409667ab2ff2Smrg if test -n "$dllsearchpath"; then 409767ab2ff2Smrg $ECHO "\ 409867ab2ff2Smrg # Add the dll search path components to the executable PATH 409967ab2ff2Smrg PATH=$dllsearchpath:\$PATH 410067ab2ff2Smrg" 410167ab2ff2Smrg fi 410267ab2ff2Smrg 4103f05b35a2Smrg # Export our shlibpath_var if we have one. 4104f05b35a2Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4105f05b35a2Smrg $ECHO "\ 4106f05b35a2Smrg # Add our own library path to $shlibpath_var 4107f05b35a2Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 4108f05b35a2Smrg 4109f05b35a2Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 4110f05b35a2Smrg # The second colon is a workaround for a bug in BeOS R4 sed 411149e108a1Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 4112f05b35a2Smrg 4113f05b35a2Smrg export $shlibpath_var 4114f05b35a2Smrg" 4115e0963edeSmrg fi 4116e0963edeSmrg 4117f05b35a2Smrg $ECHO "\ 4118f05b35a2Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 4119f05b35a2Smrg # Run the actual program with our arguments. 412049e108a1Smrg func_exec_program \${1+\"\$@\"} 4121f05b35a2Smrg fi 4122f05b35a2Smrg else 4123f05b35a2Smrg # The program doesn't exist. 4124f05b35a2Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 4125f05b35a2Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 412649e108a1Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 4127f05b35a2Smrg exit 1 4128f05b35a2Smrg fi 4129f05b35a2Smrgfi\ 4130f05b35a2Smrg" 4131f05b35a2Smrg} 4132e0963edeSmrg 4133e0963edeSmrg 4134f05b35a2Smrg# func_emit_cwrapperexe_src 4135f05b35a2Smrg# emit the source code for a wrapper executable on stdout 4136f05b35a2Smrg# Must ONLY be called from within func_mode_link because 4137f05b35a2Smrg# it depends on a number of variable set therein. 4138f05b35a2Smrgfunc_emit_cwrapperexe_src () 4139f05b35a2Smrg{ 4140f05b35a2Smrg cat <<EOF 4141e0963edeSmrg 4142f05b35a2Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 4143f05b35a2Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4144e0963edeSmrg 4145f05b35a2Smrg The $output program cannot be directly executed until all the libtool 4146f05b35a2Smrg libraries that it depends on are installed. 4147e0963edeSmrg 4148f05b35a2Smrg This wrapper executable should never be moved out of the build directory. 4149f05b35a2Smrg If it is, it will not operate correctly. 4150f05b35a2Smrg*/ 4151f05b35a2SmrgEOF 4152f05b35a2Smrg cat <<"EOF" 415349e108a1Smrg#ifdef _MSC_VER 415449e108a1Smrg# define _CRT_SECURE_NO_DEPRECATE 1 415549e108a1Smrg#endif 4156f05b35a2Smrg#include <stdio.h> 4157f05b35a2Smrg#include <stdlib.h> 4158f05b35a2Smrg#ifdef _MSC_VER 4159f05b35a2Smrg# include <direct.h> 4160f05b35a2Smrg# include <process.h> 4161f05b35a2Smrg# include <io.h> 4162f05b35a2Smrg#else 4163f05b35a2Smrg# include <unistd.h> 4164f05b35a2Smrg# include <stdint.h> 4165f05b35a2Smrg# ifdef __CYGWIN__ 4166f05b35a2Smrg# include <io.h> 4167f05b35a2Smrg# endif 4168f05b35a2Smrg#endif 4169f05b35a2Smrg#include <malloc.h> 4170f05b35a2Smrg#include <stdarg.h> 4171f05b35a2Smrg#include <assert.h> 4172f05b35a2Smrg#include <string.h> 4173f05b35a2Smrg#include <ctype.h> 4174f05b35a2Smrg#include <errno.h> 4175f05b35a2Smrg#include <fcntl.h> 4176f05b35a2Smrg#include <sys/stat.h> 4177e0963edeSmrg 417849e108a1Smrg/* declarations of non-ANSI functions */ 417949e108a1Smrg#if defined(__MINGW32__) 418049e108a1Smrg# ifdef __STRICT_ANSI__ 418149e108a1Smrgint _putenv (const char *); 418249e108a1Smrg# endif 418349e108a1Smrg#elif defined(__CYGWIN__) 418449e108a1Smrg# ifdef __STRICT_ANSI__ 418549e108a1Smrgchar *realpath (const char *, char *); 418649e108a1Smrgint putenv (char *); 418749e108a1Smrgint setenv (const char *, const char *, int); 418849e108a1Smrg# endif 418949e108a1Smrg/* #elif defined (other platforms) ... */ 419049e108a1Smrg#endif 419149e108a1Smrg 419249e108a1Smrg/* portability defines, excluding path handling macros */ 419349e108a1Smrg#if defined(_MSC_VER) 419449e108a1Smrg# define setmode _setmode 419549e108a1Smrg# define stat _stat 419649e108a1Smrg# define chmod _chmod 419749e108a1Smrg# define getcwd _getcwd 419849e108a1Smrg# define putenv _putenv 419949e108a1Smrg# define S_IXUSR _S_IEXEC 420049e108a1Smrg# ifndef _INTPTR_T_DEFINED 420149e108a1Smrg# define _INTPTR_T_DEFINED 420249e108a1Smrg# define intptr_t int 420349e108a1Smrg# endif 420449e108a1Smrg#elif defined(__MINGW32__) 420549e108a1Smrg# define setmode _setmode 420649e108a1Smrg# define stat _stat 420749e108a1Smrg# define chmod _chmod 420849e108a1Smrg# define getcwd _getcwd 420949e108a1Smrg# define putenv _putenv 421049e108a1Smrg#elif defined(__CYGWIN__) 421149e108a1Smrg# define HAVE_SETENV 421249e108a1Smrg# define FOPEN_WB "wb" 421349e108a1Smrg/* #elif defined (other platforms) ... */ 421449e108a1Smrg#endif 421549e108a1Smrg 4216f05b35a2Smrg#if defined(PATH_MAX) 4217f05b35a2Smrg# define LT_PATHMAX PATH_MAX 4218f05b35a2Smrg#elif defined(MAXPATHLEN) 4219f05b35a2Smrg# define LT_PATHMAX MAXPATHLEN 4220f05b35a2Smrg#else 4221f05b35a2Smrg# define LT_PATHMAX 1024 4222f05b35a2Smrg#endif 4223e0963edeSmrg 4224f05b35a2Smrg#ifndef S_IXOTH 4225f05b35a2Smrg# define S_IXOTH 0 4226f05b35a2Smrg#endif 4227f05b35a2Smrg#ifndef S_IXGRP 4228f05b35a2Smrg# define S_IXGRP 0 4229f05b35a2Smrg#endif 4230e0963edeSmrg 423149e108a1Smrg/* path handling portability macros */ 4232f05b35a2Smrg#ifndef DIR_SEPARATOR 4233f05b35a2Smrg# define DIR_SEPARATOR '/' 4234f05b35a2Smrg# define PATH_SEPARATOR ':' 4235f05b35a2Smrg#endif 4236e0963edeSmrg 4237f05b35a2Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 4238f05b35a2Smrg defined (__OS2__) 4239f05b35a2Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 4240f05b35a2Smrg# define FOPEN_WB "wb" 4241f05b35a2Smrg# ifndef DIR_SEPARATOR_2 4242f05b35a2Smrg# define DIR_SEPARATOR_2 '\\' 4243f05b35a2Smrg# endif 4244f05b35a2Smrg# ifndef PATH_SEPARATOR_2 4245f05b35a2Smrg# define PATH_SEPARATOR_2 ';' 4246f05b35a2Smrg# endif 4247f05b35a2Smrg#endif 4248e0963edeSmrg 4249f05b35a2Smrg#ifndef DIR_SEPARATOR_2 4250f05b35a2Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 4251f05b35a2Smrg#else /* DIR_SEPARATOR_2 */ 4252f05b35a2Smrg# define IS_DIR_SEPARATOR(ch) \ 4253f05b35a2Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 4254f05b35a2Smrg#endif /* DIR_SEPARATOR_2 */ 4255e0963edeSmrg 4256f05b35a2Smrg#ifndef PATH_SEPARATOR_2 4257f05b35a2Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 4258f05b35a2Smrg#else /* PATH_SEPARATOR_2 */ 4259f05b35a2Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 4260f05b35a2Smrg#endif /* PATH_SEPARATOR_2 */ 4261e0963edeSmrg 4262f05b35a2Smrg#ifndef FOPEN_WB 4263f05b35a2Smrg# define FOPEN_WB "w" 4264f05b35a2Smrg#endif 4265f05b35a2Smrg#ifndef _O_BINARY 4266f05b35a2Smrg# define _O_BINARY 0 4267f05b35a2Smrg#endif 4268e0963edeSmrg 4269f05b35a2Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 4270f05b35a2Smrg#define XFREE(stale) do { \ 4271f05b35a2Smrg if (stale) { free ((void *) stale); stale = 0; } \ 4272f05b35a2Smrg} while (0) 4273e0963edeSmrg 427449e108a1Smrg#if defined(LT_DEBUGWRAPPER) 427549e108a1Smrgstatic int lt_debug = 1; 4276f05b35a2Smrg#else 427749e108a1Smrgstatic int lt_debug = 0; 4278f05b35a2Smrg#endif 4279e0963edeSmrg 428049e108a1Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 4281e0963edeSmrg 4282f05b35a2Smrgvoid *xmalloc (size_t num); 4283f05b35a2Smrgchar *xstrdup (const char *string); 4284f05b35a2Smrgconst char *base_name (const char *name); 4285f05b35a2Smrgchar *find_executable (const char *wrapper); 4286f05b35a2Smrgchar *chase_symlinks (const char *pathspec); 4287f05b35a2Smrgint make_executable (const char *path); 4288f05b35a2Smrgint check_executable (const char *path); 4289f05b35a2Smrgchar *strendzap (char *str, const char *pat); 429049e108a1Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 429149e108a1Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 429249e108a1Smrgstatic const char *nonnull (const char *s); 429349e108a1Smrgstatic const char *nonempty (const char *s); 4294f05b35a2Smrgvoid lt_setenv (const char *name, const char *value); 4295f05b35a2Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 4296f05b35a2Smrgvoid lt_update_exe_path (const char *name, const char *value); 4297f05b35a2Smrgvoid lt_update_lib_path (const char *name, const char *value); 429849e108a1Smrgchar **prepare_spawn (char **argv); 429949e108a1Smrgvoid lt_dump_script (FILE *f); 4300f05b35a2SmrgEOF 4301f05b35a2Smrg 4302f05b35a2Smrg cat <<EOF 430367ab2ff2Smrgvolatile const char * MAGIC_EXE = "$magic_exe"; 4304f05b35a2Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 4305f05b35a2SmrgEOF 4306e0963edeSmrg 4307f05b35a2Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 430867ab2ff2Smrg func_to_host_path "$temp_rpath" 4309f05b35a2Smrg cat <<EOF 431067ab2ff2Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 4311f05b35a2SmrgEOF 4312f05b35a2Smrg else 4313f05b35a2Smrg cat <<"EOF" 4314f05b35a2Smrgconst char * LIB_PATH_VALUE = ""; 4315f05b35a2SmrgEOF 4316f05b35a2Smrg fi 4317e0963edeSmrg 4318f05b35a2Smrg if test -n "$dllsearchpath"; then 431967ab2ff2Smrg func_to_host_path "$dllsearchpath:" 4320f05b35a2Smrg cat <<EOF 4321f05b35a2Smrgconst char * EXE_PATH_VARNAME = "PATH"; 432267ab2ff2Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 4323f05b35a2SmrgEOF 4324f05b35a2Smrg else 4325f05b35a2Smrg cat <<"EOF" 4326f05b35a2Smrgconst char * EXE_PATH_VARNAME = ""; 4327f05b35a2Smrgconst char * EXE_PATH_VALUE = ""; 4328f05b35a2SmrgEOF 4329f05b35a2Smrg fi 4330e0963edeSmrg 4331f05b35a2Smrg if test "$fast_install" = yes; then 4332f05b35a2Smrg cat <<EOF 4333f05b35a2Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 4334f05b35a2SmrgEOF 4335f05b35a2Smrg else 4336f05b35a2Smrg cat <<EOF 4337f05b35a2Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 4338f05b35a2SmrgEOF 4339f05b35a2Smrg fi 4340e0963edeSmrg 4341e0963edeSmrg 4342f05b35a2Smrg cat <<"EOF" 4343e0963edeSmrg 4344f05b35a2Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 4345e0963edeSmrg 4346f05b35a2Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 4347f05b35a2Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 434849e108a1Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 4349f05b35a2Smrg 4350f05b35a2Smrgint 4351f05b35a2Smrgmain (int argc, char *argv[]) 4352f05b35a2Smrg{ 4353f05b35a2Smrg char **newargz; 4354f05b35a2Smrg int newargc; 4355f05b35a2Smrg char *tmp_pathspec; 4356f05b35a2Smrg char *actual_cwrapper_path; 4357f05b35a2Smrg char *actual_cwrapper_name; 4358f05b35a2Smrg char *target_name; 4359f05b35a2Smrg char *lt_argv_zero; 4360f05b35a2Smrg intptr_t rval = 127; 4361f05b35a2Smrg 4362f05b35a2Smrg int i; 4363f05b35a2Smrg 4364f05b35a2Smrg program_name = (char *) xstrdup (base_name (argv[0])); 436549e108a1Smrg newargz = XMALLOC (char *, argc + 1); 4366f05b35a2Smrg 436749e108a1Smrg /* very simple arg parsing; don't want to rely on getopt 436849e108a1Smrg * also, copy all non cwrapper options to newargz, except 436949e108a1Smrg * argz[0], which is handled differently 437049e108a1Smrg */ 437149e108a1Smrg newargc=0; 4372f05b35a2Smrg for (i = 1; i < argc; i++) 4373f05b35a2Smrg { 4374f05b35a2Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 4375f05b35a2Smrg { 4376f05b35a2SmrgEOF 4377f05b35a2Smrg case "$host" in 4378f05b35a2Smrg *mingw* | *cygwin* ) 4379f05b35a2Smrg # make stdout use "unix" line endings 4380f05b35a2Smrg echo " setmode(1,_O_BINARY);" 4381f05b35a2Smrg ;; 4382f05b35a2Smrg esac 4383f05b35a2Smrg 4384f05b35a2Smrg cat <<"EOF" 438549e108a1Smrg lt_dump_script (stdout); 4386f05b35a2Smrg return 0; 4387f05b35a2Smrg } 438849e108a1Smrg if (strcmp (argv[i], debug_opt) == 0) 438949e108a1Smrg { 439049e108a1Smrg lt_debug = 1; 439149e108a1Smrg continue; 439249e108a1Smrg } 439349e108a1Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 439449e108a1Smrg { 439549e108a1Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 439649e108a1Smrg namespace, but it is not one of the ones we know about and 439749e108a1Smrg have already dealt with, above (inluding dump-script), then 439849e108a1Smrg report an error. Otherwise, targets might begin to believe 439949e108a1Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 440049e108a1Smrg namespace. The first time any user complains about this, we'll 440149e108a1Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 440249e108a1Smrg or a configure.ac-settable value. 440349e108a1Smrg */ 440449e108a1Smrg lt_fatal (__FILE__, __LINE__, 440549e108a1Smrg "unrecognized %s option: '%s'", 440649e108a1Smrg ltwrapper_option_prefix, argv[i]); 440749e108a1Smrg } 440849e108a1Smrg /* otherwise ... */ 440949e108a1Smrg newargz[++newargc] = xstrdup (argv[i]); 4410f05b35a2Smrg } 441149e108a1Smrg newargz[++newargc] = NULL; 441249e108a1Smrg 441349e108a1SmrgEOF 441449e108a1Smrg cat <<EOF 441549e108a1Smrg /* The GNU banner must be the first non-error debug message */ 441649e108a1Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 441749e108a1SmrgEOF 441849e108a1Smrg cat <<"EOF" 441949e108a1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 442049e108a1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 4421f05b35a2Smrg 4422f05b35a2Smrg tmp_pathspec = find_executable (argv[0]); 4423f05b35a2Smrg if (tmp_pathspec == NULL) 442449e108a1Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 442549e108a1Smrg lt_debugprintf (__FILE__, __LINE__, 442649e108a1Smrg "(main) found exe (before symlink chase) at: %s\n", 442749e108a1Smrg tmp_pathspec); 4428f05b35a2Smrg 4429f05b35a2Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 443049e108a1Smrg lt_debugprintf (__FILE__, __LINE__, 443149e108a1Smrg "(main) found exe (after symlink chase) at: %s\n", 443249e108a1Smrg actual_cwrapper_path); 4433f05b35a2Smrg XFREE (tmp_pathspec); 4434f05b35a2Smrg 443549e108a1Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 4436f05b35a2Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 4437f05b35a2Smrg 4438f05b35a2Smrg /* wrapper name transforms */ 4439f05b35a2Smrg strendzap (actual_cwrapper_name, ".exe"); 4440f05b35a2Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 4441f05b35a2Smrg XFREE (actual_cwrapper_name); 4442f05b35a2Smrg actual_cwrapper_name = tmp_pathspec; 4443f05b35a2Smrg tmp_pathspec = 0; 4444f05b35a2Smrg 4445f05b35a2Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 4446f05b35a2Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 4447f05b35a2Smrg strendzap (target_name, ".exe"); 4448f05b35a2Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 4449f05b35a2Smrg XFREE (target_name); 4450f05b35a2Smrg target_name = tmp_pathspec; 4451f05b35a2Smrg tmp_pathspec = 0; 4452f05b35a2Smrg 445349e108a1Smrg lt_debugprintf (__FILE__, __LINE__, 445449e108a1Smrg "(main) libtool target name: %s\n", 445549e108a1Smrg target_name); 4456f05b35a2SmrgEOF 4457f05b35a2Smrg 4458f05b35a2Smrg cat <<EOF 4459f05b35a2Smrg newargz[0] = 4460f05b35a2Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 4461f05b35a2Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 4462f05b35a2Smrg strcpy (newargz[0], actual_cwrapper_path); 4463f05b35a2Smrg strcat (newargz[0], "$objdir"); 4464f05b35a2Smrg strcat (newargz[0], "/"); 4465f05b35a2SmrgEOF 4466f05b35a2Smrg 4467f05b35a2Smrg cat <<"EOF" 4468f05b35a2Smrg /* stop here, and copy so we don't have to do this twice */ 4469f05b35a2Smrg tmp_pathspec = xstrdup (newargz[0]); 4470f05b35a2Smrg 4471f05b35a2Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 4472f05b35a2Smrg strcat (newargz[0], actual_cwrapper_name); 4473f05b35a2Smrg 4474f05b35a2Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 4475f05b35a2Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 4476f05b35a2Smrg XFREE (tmp_pathspec); 4477f05b35a2Smrg tmp_pathspec = NULL; 4478f05b35a2SmrgEOF 4479f05b35a2Smrg 4480f05b35a2Smrg case $host_os in 4481f05b35a2Smrg mingw*) 4482f05b35a2Smrg cat <<"EOF" 4483f05b35a2Smrg { 4484f05b35a2Smrg char* p; 4485f05b35a2Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 4486f05b35a2Smrg { 4487f05b35a2Smrg *p = '/'; 4488f05b35a2Smrg } 4489f05b35a2Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 4490f05b35a2Smrg { 4491f05b35a2Smrg *p = '/'; 4492f05b35a2Smrg } 4493f05b35a2Smrg } 4494f05b35a2SmrgEOF 4495e0963edeSmrg ;; 4496f05b35a2Smrg esac 4497f05b35a2Smrg 4498f05b35a2Smrg cat <<"EOF" 4499f05b35a2Smrg XFREE (target_name); 4500f05b35a2Smrg XFREE (actual_cwrapper_path); 4501f05b35a2Smrg XFREE (actual_cwrapper_name); 4502f05b35a2Smrg 4503f05b35a2Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 4504f05b35a2Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 450567ab2ff2Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 450667ab2ff2Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 450767ab2ff2Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 450867ab2ff2Smrg libraries must come first. */ 4509f05b35a2Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 451067ab2ff2Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 4511f05b35a2Smrg 451249e108a1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 451349e108a1Smrg nonnull (lt_argv_zero)); 4514f05b35a2Smrg for (i = 0; i < newargc; i++) 4515f05b35a2Smrg { 451649e108a1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 451749e108a1Smrg i, nonnull (newargz[i])); 4518f05b35a2Smrg } 4519e0963edeSmrg 4520e0963edeSmrgEOF 4521e0963edeSmrg 4522f05b35a2Smrg case $host_os in 4523f05b35a2Smrg mingw*) 4524f05b35a2Smrg cat <<"EOF" 4525f05b35a2Smrg /* execv doesn't actually work on mingw as expected on unix */ 452649e108a1Smrg newargz = prepare_spawn (newargz); 4527f05b35a2Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 4528f05b35a2Smrg if (rval == -1) 4529f05b35a2Smrg { 4530f05b35a2Smrg /* failed to start process */ 453149e108a1Smrg lt_debugprintf (__FILE__, __LINE__, 453249e108a1Smrg "(main) failed to launch target \"%s\": %s\n", 453349e108a1Smrg lt_argv_zero, nonnull (strerror (errno))); 4534f05b35a2Smrg return 127; 4535f05b35a2Smrg } 4536f05b35a2Smrg return rval; 4537f05b35a2SmrgEOF 4538f05b35a2Smrg ;; 4539f05b35a2Smrg *) 4540f05b35a2Smrg cat <<"EOF" 4541f05b35a2Smrg execv (lt_argv_zero, newargz); 4542f05b35a2Smrg return rval; /* =127, but avoids unused variable warning */ 4543f05b35a2SmrgEOF 4544f05b35a2Smrg ;; 4545f05b35a2Smrg esac 4546e0963edeSmrg 4547f05b35a2Smrg cat <<"EOF" 4548f05b35a2Smrg} 4549e0963edeSmrg 4550f05b35a2Smrgvoid * 4551f05b35a2Smrgxmalloc (size_t num) 4552f05b35a2Smrg{ 4553f05b35a2Smrg void *p = (void *) malloc (num); 4554f05b35a2Smrg if (!p) 455549e108a1Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 4556e0963edeSmrg 4557f05b35a2Smrg return p; 4558f05b35a2Smrg} 4559e0963edeSmrg 4560f05b35a2Smrgchar * 4561f05b35a2Smrgxstrdup (const char *string) 4562f05b35a2Smrg{ 4563f05b35a2Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 4564f05b35a2Smrg string) : NULL; 4565f05b35a2Smrg} 4566e0963edeSmrg 4567f05b35a2Smrgconst char * 4568f05b35a2Smrgbase_name (const char *name) 4569f05b35a2Smrg{ 4570f05b35a2Smrg const char *base; 4571e0963edeSmrg 4572f05b35a2Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4573f05b35a2Smrg /* Skip over the disk name in MSDOS pathnames. */ 4574f05b35a2Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 4575f05b35a2Smrg name += 2; 4576f05b35a2Smrg#endif 4577e0963edeSmrg 4578f05b35a2Smrg for (base = name; *name; name++) 4579f05b35a2Smrg if (IS_DIR_SEPARATOR (*name)) 4580f05b35a2Smrg base = name + 1; 4581f05b35a2Smrg return base; 4582f05b35a2Smrg} 4583e0963edeSmrg 4584f05b35a2Smrgint 4585f05b35a2Smrgcheck_executable (const char *path) 4586f05b35a2Smrg{ 4587f05b35a2Smrg struct stat st; 4588e0963edeSmrg 458949e108a1Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 459049e108a1Smrg nonempty (path)); 4591f05b35a2Smrg if ((!path) || (!*path)) 4592f05b35a2Smrg return 0; 4593e0963edeSmrg 4594f05b35a2Smrg if ((stat (path, &st) >= 0) 4595f05b35a2Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 4596f05b35a2Smrg return 1; 4597f05b35a2Smrg else 4598f05b35a2Smrg return 0; 4599f05b35a2Smrg} 4600e0963edeSmrg 4601f05b35a2Smrgint 4602f05b35a2Smrgmake_executable (const char *path) 4603f05b35a2Smrg{ 4604f05b35a2Smrg int rval = 0; 4605f05b35a2Smrg struct stat st; 4606e0963edeSmrg 460749e108a1Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 460849e108a1Smrg nonempty (path)); 4609f05b35a2Smrg if ((!path) || (!*path)) 4610f05b35a2Smrg return 0; 4611e0963edeSmrg 4612f05b35a2Smrg if (stat (path, &st) >= 0) 4613f05b35a2Smrg { 4614f05b35a2Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 4615f05b35a2Smrg } 4616f05b35a2Smrg return rval; 4617f05b35a2Smrg} 4618e0963edeSmrg 4619f05b35a2Smrg/* Searches for the full path of the wrapper. Returns 4620f05b35a2Smrg newly allocated full path name if found, NULL otherwise 4621f05b35a2Smrg Does not chase symlinks, even on platforms that support them. 4622f05b35a2Smrg*/ 4623f05b35a2Smrgchar * 4624f05b35a2Smrgfind_executable (const char *wrapper) 4625f05b35a2Smrg{ 4626f05b35a2Smrg int has_slash = 0; 4627f05b35a2Smrg const char *p; 4628f05b35a2Smrg const char *p_next; 4629f05b35a2Smrg /* static buffer for getcwd */ 4630f05b35a2Smrg char tmp[LT_PATHMAX + 1]; 4631f05b35a2Smrg int tmp_len; 4632f05b35a2Smrg char *concat_name; 4633e0963edeSmrg 463449e108a1Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 463549e108a1Smrg nonempty (wrapper)); 4636e0963edeSmrg 4637f05b35a2Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 4638f05b35a2Smrg return NULL; 4639e0963edeSmrg 4640f05b35a2Smrg /* Absolute path? */ 4641f05b35a2Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4642f05b35a2Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 4643f05b35a2Smrg { 4644f05b35a2Smrg concat_name = xstrdup (wrapper); 4645f05b35a2Smrg if (check_executable (concat_name)) 4646f05b35a2Smrg return concat_name; 4647f05b35a2Smrg XFREE (concat_name); 4648f05b35a2Smrg } 4649f05b35a2Smrg else 4650f05b35a2Smrg { 4651f05b35a2Smrg#endif 4652f05b35a2Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 4653f05b35a2Smrg { 4654f05b35a2Smrg concat_name = xstrdup (wrapper); 4655f05b35a2Smrg if (check_executable (concat_name)) 4656f05b35a2Smrg return concat_name; 4657f05b35a2Smrg XFREE (concat_name); 4658f05b35a2Smrg } 4659f05b35a2Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4660f05b35a2Smrg } 4661f05b35a2Smrg#endif 4662e0963edeSmrg 4663f05b35a2Smrg for (p = wrapper; *p; p++) 4664f05b35a2Smrg if (*p == '/') 4665f05b35a2Smrg { 4666f05b35a2Smrg has_slash = 1; 4667f05b35a2Smrg break; 4668f05b35a2Smrg } 4669f05b35a2Smrg if (!has_slash) 4670f05b35a2Smrg { 4671f05b35a2Smrg /* no slashes; search PATH */ 4672f05b35a2Smrg const char *path = getenv ("PATH"); 4673f05b35a2Smrg if (path != NULL) 4674f05b35a2Smrg { 4675f05b35a2Smrg for (p = path; *p; p = p_next) 4676f05b35a2Smrg { 4677f05b35a2Smrg const char *q; 4678f05b35a2Smrg size_t p_len; 4679f05b35a2Smrg for (q = p; *q; q++) 4680f05b35a2Smrg if (IS_PATH_SEPARATOR (*q)) 4681f05b35a2Smrg break; 4682f05b35a2Smrg p_len = q - p; 4683f05b35a2Smrg p_next = (*q == '\0' ? q : q + 1); 4684f05b35a2Smrg if (p_len == 0) 4685f05b35a2Smrg { 4686f05b35a2Smrg /* empty path: current directory */ 4687f05b35a2Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 468849e108a1Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 468949e108a1Smrg nonnull (strerror (errno))); 4690f05b35a2Smrg tmp_len = strlen (tmp); 4691f05b35a2Smrg concat_name = 4692f05b35a2Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4693f05b35a2Smrg memcpy (concat_name, tmp, tmp_len); 4694f05b35a2Smrg concat_name[tmp_len] = '/'; 4695f05b35a2Smrg strcpy (concat_name + tmp_len + 1, wrapper); 4696f05b35a2Smrg } 4697f05b35a2Smrg else 4698f05b35a2Smrg { 4699f05b35a2Smrg concat_name = 4700f05b35a2Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 4701f05b35a2Smrg memcpy (concat_name, p, p_len); 4702f05b35a2Smrg concat_name[p_len] = '/'; 4703f05b35a2Smrg strcpy (concat_name + p_len + 1, wrapper); 4704f05b35a2Smrg } 4705f05b35a2Smrg if (check_executable (concat_name)) 4706f05b35a2Smrg return concat_name; 4707f05b35a2Smrg XFREE (concat_name); 4708f05b35a2Smrg } 4709f05b35a2Smrg } 4710f05b35a2Smrg /* not found in PATH; assume curdir */ 4711f05b35a2Smrg } 4712f05b35a2Smrg /* Relative path | not found in path: prepend cwd */ 4713f05b35a2Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 471449e108a1Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 471549e108a1Smrg nonnull (strerror (errno))); 4716f05b35a2Smrg tmp_len = strlen (tmp); 4717f05b35a2Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4718f05b35a2Smrg memcpy (concat_name, tmp, tmp_len); 4719f05b35a2Smrg concat_name[tmp_len] = '/'; 4720f05b35a2Smrg strcpy (concat_name + tmp_len + 1, wrapper); 4721e0963edeSmrg 4722f05b35a2Smrg if (check_executable (concat_name)) 4723f05b35a2Smrg return concat_name; 4724f05b35a2Smrg XFREE (concat_name); 4725f05b35a2Smrg return NULL; 4726f05b35a2Smrg} 4727e0963edeSmrg 4728f05b35a2Smrgchar * 4729f05b35a2Smrgchase_symlinks (const char *pathspec) 4730f05b35a2Smrg{ 4731f05b35a2Smrg#ifndef S_ISLNK 4732f05b35a2Smrg return xstrdup (pathspec); 4733f05b35a2Smrg#else 4734f05b35a2Smrg char buf[LT_PATHMAX]; 4735f05b35a2Smrg struct stat s; 4736f05b35a2Smrg char *tmp_pathspec = xstrdup (pathspec); 4737f05b35a2Smrg char *p; 4738f05b35a2Smrg int has_symlinks = 0; 4739f05b35a2Smrg while (strlen (tmp_pathspec) && !has_symlinks) 4740f05b35a2Smrg { 474149e108a1Smrg lt_debugprintf (__FILE__, __LINE__, 474249e108a1Smrg "checking path component for symlinks: %s\n", 474349e108a1Smrg tmp_pathspec); 4744f05b35a2Smrg if (lstat (tmp_pathspec, &s) == 0) 4745f05b35a2Smrg { 4746f05b35a2Smrg if (S_ISLNK (s.st_mode) != 0) 4747f05b35a2Smrg { 4748f05b35a2Smrg has_symlinks = 1; 4749f05b35a2Smrg break; 4750f05b35a2Smrg } 4751e0963edeSmrg 4752f05b35a2Smrg /* search backwards for last DIR_SEPARATOR */ 4753f05b35a2Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 4754f05b35a2Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4755f05b35a2Smrg p--; 4756f05b35a2Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4757f05b35a2Smrg { 4758f05b35a2Smrg /* no more DIR_SEPARATORS left */ 4759f05b35a2Smrg break; 4760f05b35a2Smrg } 4761f05b35a2Smrg *p = '\0'; 4762f05b35a2Smrg } 4763f05b35a2Smrg else 4764f05b35a2Smrg { 476549e108a1Smrg lt_fatal (__FILE__, __LINE__, 476649e108a1Smrg "error accessing file \"%s\": %s", 476749e108a1Smrg tmp_pathspec, nonnull (strerror (errno))); 4768f05b35a2Smrg } 4769f05b35a2Smrg } 4770f05b35a2Smrg XFREE (tmp_pathspec); 4771e0963edeSmrg 4772f05b35a2Smrg if (!has_symlinks) 4773f05b35a2Smrg { 4774f05b35a2Smrg return xstrdup (pathspec); 4775f05b35a2Smrg } 4776e0963edeSmrg 4777f05b35a2Smrg tmp_pathspec = realpath (pathspec, buf); 4778f05b35a2Smrg if (tmp_pathspec == 0) 4779f05b35a2Smrg { 478049e108a1Smrg lt_fatal (__FILE__, __LINE__, 478149e108a1Smrg "could not follow symlinks for %s", pathspec); 4782f05b35a2Smrg } 4783f05b35a2Smrg return xstrdup (tmp_pathspec); 4784f05b35a2Smrg#endif 4785f05b35a2Smrg} 4786e0963edeSmrg 4787f05b35a2Smrgchar * 4788f05b35a2Smrgstrendzap (char *str, const char *pat) 4789f05b35a2Smrg{ 4790f05b35a2Smrg size_t len, patlen; 4791e0963edeSmrg 4792f05b35a2Smrg assert (str != NULL); 4793f05b35a2Smrg assert (pat != NULL); 4794e0963edeSmrg 4795f05b35a2Smrg len = strlen (str); 4796f05b35a2Smrg patlen = strlen (pat); 4797e0963edeSmrg 4798f05b35a2Smrg if (patlen <= len) 4799f05b35a2Smrg { 4800f05b35a2Smrg str += len - patlen; 4801f05b35a2Smrg if (strcmp (str, pat) == 0) 4802f05b35a2Smrg *str = '\0'; 4803f05b35a2Smrg } 4804f05b35a2Smrg return str; 4805f05b35a2Smrg} 4806e0963edeSmrg 480749e108a1Smrgvoid 480849e108a1Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 480949e108a1Smrg{ 481049e108a1Smrg va_list args; 481149e108a1Smrg if (lt_debug) 481249e108a1Smrg { 481349e108a1Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 481449e108a1Smrg va_start (args, fmt); 481549e108a1Smrg (void) vfprintf (stderr, fmt, args); 481649e108a1Smrg va_end (args); 481749e108a1Smrg } 481849e108a1Smrg} 481949e108a1Smrg 4820f05b35a2Smrgstatic void 482149e108a1Smrglt_error_core (int exit_status, const char *file, 482249e108a1Smrg int line, const char *mode, 4823f05b35a2Smrg const char *message, va_list ap) 4824f05b35a2Smrg{ 482549e108a1Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 4826f05b35a2Smrg vfprintf (stderr, message, ap); 4827f05b35a2Smrg fprintf (stderr, ".\n"); 4828e0963edeSmrg 4829f05b35a2Smrg if (exit_status >= 0) 4830f05b35a2Smrg exit (exit_status); 4831f05b35a2Smrg} 4832e0963edeSmrg 4833f05b35a2Smrgvoid 483449e108a1Smrglt_fatal (const char *file, int line, const char *message, ...) 4835f05b35a2Smrg{ 4836f05b35a2Smrg va_list ap; 4837f05b35a2Smrg va_start (ap, message); 483849e108a1Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 4839f05b35a2Smrg va_end (ap); 4840f05b35a2Smrg} 4841e0963edeSmrg 484249e108a1Smrgstatic const char * 484349e108a1Smrgnonnull (const char *s) 484449e108a1Smrg{ 484549e108a1Smrg return s ? s : "(null)"; 484649e108a1Smrg} 484749e108a1Smrg 484849e108a1Smrgstatic const char * 484949e108a1Smrgnonempty (const char *s) 485049e108a1Smrg{ 485149e108a1Smrg return (s && !*s) ? "(empty)" : nonnull (s); 485249e108a1Smrg} 485349e108a1Smrg 4854f05b35a2Smrgvoid 4855f05b35a2Smrglt_setenv (const char *name, const char *value) 4856f05b35a2Smrg{ 485749e108a1Smrg lt_debugprintf (__FILE__, __LINE__, 485849e108a1Smrg "(lt_setenv) setting '%s' to '%s'\n", 485949e108a1Smrg nonnull (name), nonnull (value)); 4860f05b35a2Smrg { 4861f05b35a2Smrg#ifdef HAVE_SETENV 4862f05b35a2Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 4863f05b35a2Smrg char *str = xstrdup (value); 4864f05b35a2Smrg setenv (name, str, 1); 4865f05b35a2Smrg#else 4866f05b35a2Smrg int len = strlen (name) + 1 + strlen (value) + 1; 4867f05b35a2Smrg char *str = XMALLOC (char, len); 4868f05b35a2Smrg sprintf (str, "%s=%s", name, value); 4869f05b35a2Smrg if (putenv (str) != EXIT_SUCCESS) 4870f05b35a2Smrg { 4871f05b35a2Smrg XFREE (str); 4872f05b35a2Smrg } 4873f05b35a2Smrg#endif 4874f05b35a2Smrg } 4875f05b35a2Smrg} 4876e0963edeSmrg 4877f05b35a2Smrgchar * 4878f05b35a2Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 4879f05b35a2Smrg{ 4880f05b35a2Smrg char *new_value; 4881f05b35a2Smrg if (orig_value && *orig_value) 4882f05b35a2Smrg { 4883f05b35a2Smrg int orig_value_len = strlen (orig_value); 4884f05b35a2Smrg int add_len = strlen (add); 4885f05b35a2Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 4886f05b35a2Smrg if (to_end) 4887f05b35a2Smrg { 4888f05b35a2Smrg strcpy (new_value, orig_value); 4889f05b35a2Smrg strcpy (new_value + orig_value_len, add); 4890f05b35a2Smrg } 4891f05b35a2Smrg else 4892f05b35a2Smrg { 4893f05b35a2Smrg strcpy (new_value, add); 4894f05b35a2Smrg strcpy (new_value + add_len, orig_value); 4895f05b35a2Smrg } 4896f05b35a2Smrg } 4897f05b35a2Smrg else 4898f05b35a2Smrg { 4899f05b35a2Smrg new_value = xstrdup (add); 4900f05b35a2Smrg } 4901f05b35a2Smrg return new_value; 4902f05b35a2Smrg} 4903e0963edeSmrg 4904f05b35a2Smrgvoid 4905f05b35a2Smrglt_update_exe_path (const char *name, const char *value) 4906f05b35a2Smrg{ 490749e108a1Smrg lt_debugprintf (__FILE__, __LINE__, 490849e108a1Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 490949e108a1Smrg nonnull (name), nonnull (value)); 4910e0963edeSmrg 4911f05b35a2Smrg if (name && *name && value && *value) 4912f05b35a2Smrg { 4913f05b35a2Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 4914f05b35a2Smrg /* some systems can't cope with a ':'-terminated path #' */ 4915f05b35a2Smrg int len = strlen (new_value); 4916f05b35a2Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 4917f05b35a2Smrg { 4918f05b35a2Smrg new_value[len-1] = '\0'; 4919f05b35a2Smrg } 4920f05b35a2Smrg lt_setenv (name, new_value); 4921f05b35a2Smrg XFREE (new_value); 4922f05b35a2Smrg } 4923f05b35a2Smrg} 4924e0963edeSmrg 4925f05b35a2Smrgvoid 4926f05b35a2Smrglt_update_lib_path (const char *name, const char *value) 4927f05b35a2Smrg{ 492849e108a1Smrg lt_debugprintf (__FILE__, __LINE__, 492949e108a1Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 493049e108a1Smrg nonnull (name), nonnull (value)); 4931e0963edeSmrg 4932f05b35a2Smrg if (name && *name && value && *value) 4933f05b35a2Smrg { 4934f05b35a2Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 4935f05b35a2Smrg lt_setenv (name, new_value); 4936f05b35a2Smrg XFREE (new_value); 4937f05b35a2Smrg } 4938f05b35a2Smrg} 4939e0963edeSmrg 494049e108a1SmrgEOF 494149e108a1Smrg case $host_os in 494249e108a1Smrg mingw*) 494349e108a1Smrg cat <<"EOF" 494449e108a1Smrg 494549e108a1Smrg/* Prepares an argument vector before calling spawn(). 494649e108a1Smrg Note that spawn() does not by itself call the command interpreter 494749e108a1Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 494849e108a1Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 494949e108a1Smrg GetVersionEx(&v); 495049e108a1Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 495149e108a1Smrg }) ? "cmd.exe" : "command.com"). 495249e108a1Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 495349e108a1Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 495449e108a1Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 495549e108a1Smrg special way: 495649e108a1Smrg - Space and tab are interpreted as delimiters. They are not treated as 495749e108a1Smrg delimiters if they are surrounded by double quotes: "...". 495849e108a1Smrg - Unescaped double quotes are removed from the input. Their only effect is 495949e108a1Smrg that within double quotes, space and tab are treated like normal 496049e108a1Smrg characters. 496149e108a1Smrg - Backslashes not followed by double quotes are not special. 496249e108a1Smrg - But 2*n+1 backslashes followed by a double quote become 496349e108a1Smrg n backslashes followed by a double quote (n >= 0): 496449e108a1Smrg \" -> " 496549e108a1Smrg \\\" -> \" 496649e108a1Smrg \\\\\" -> \\" 496749e108a1Smrg */ 496849e108a1Smrg#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" 496949e108a1Smrg#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" 497049e108a1Smrgchar ** 497149e108a1Smrgprepare_spawn (char **argv) 497249e108a1Smrg{ 497349e108a1Smrg size_t argc; 497449e108a1Smrg char **new_argv; 497549e108a1Smrg size_t i; 497649e108a1Smrg 497749e108a1Smrg /* Count number of arguments. */ 497849e108a1Smrg for (argc = 0; argv[argc] != NULL; argc++) 497949e108a1Smrg ; 498049e108a1Smrg 498149e108a1Smrg /* Allocate new argument vector. */ 498249e108a1Smrg new_argv = XMALLOC (char *, argc + 1); 498349e108a1Smrg 498449e108a1Smrg /* Put quoted arguments into the new argument vector. */ 498549e108a1Smrg for (i = 0; i < argc; i++) 498649e108a1Smrg { 498749e108a1Smrg const char *string = argv[i]; 498849e108a1Smrg 498949e108a1Smrg if (string[0] == '\0') 499049e108a1Smrg new_argv[i] = xstrdup ("\"\""); 499149e108a1Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 499249e108a1Smrg { 499349e108a1Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 499449e108a1Smrg size_t length; 499549e108a1Smrg unsigned int backslashes; 499649e108a1Smrg const char *s; 499749e108a1Smrg char *quoted_string; 499849e108a1Smrg char *p; 499949e108a1Smrg 500049e108a1Smrg length = 0; 500149e108a1Smrg backslashes = 0; 500249e108a1Smrg if (quote_around) 500349e108a1Smrg length++; 500449e108a1Smrg for (s = string; *s != '\0'; s++) 500549e108a1Smrg { 500649e108a1Smrg char c = *s; 500749e108a1Smrg if (c == '"') 500849e108a1Smrg length += backslashes + 1; 500949e108a1Smrg length++; 501049e108a1Smrg if (c == '\\') 501149e108a1Smrg backslashes++; 501249e108a1Smrg else 501349e108a1Smrg backslashes = 0; 501449e108a1Smrg } 501549e108a1Smrg if (quote_around) 501649e108a1Smrg length += backslashes + 1; 501749e108a1Smrg 501849e108a1Smrg quoted_string = XMALLOC (char, length + 1); 501949e108a1Smrg 502049e108a1Smrg p = quoted_string; 502149e108a1Smrg backslashes = 0; 502249e108a1Smrg if (quote_around) 502349e108a1Smrg *p++ = '"'; 502449e108a1Smrg for (s = string; *s != '\0'; s++) 502549e108a1Smrg { 502649e108a1Smrg char c = *s; 502749e108a1Smrg if (c == '"') 502849e108a1Smrg { 502949e108a1Smrg unsigned int j; 503049e108a1Smrg for (j = backslashes + 1; j > 0; j--) 503149e108a1Smrg *p++ = '\\'; 503249e108a1Smrg } 503349e108a1Smrg *p++ = c; 503449e108a1Smrg if (c == '\\') 503549e108a1Smrg backslashes++; 503649e108a1Smrg else 503749e108a1Smrg backslashes = 0; 503849e108a1Smrg } 503949e108a1Smrg if (quote_around) 504049e108a1Smrg { 504149e108a1Smrg unsigned int j; 504249e108a1Smrg for (j = backslashes; j > 0; j--) 504349e108a1Smrg *p++ = '\\'; 504449e108a1Smrg *p++ = '"'; 504549e108a1Smrg } 504649e108a1Smrg *p = '\0'; 504749e108a1Smrg 504849e108a1Smrg new_argv[i] = quoted_string; 504949e108a1Smrg } 505049e108a1Smrg else 505149e108a1Smrg new_argv[i] = (char *) string; 505249e108a1Smrg } 505349e108a1Smrg new_argv[argc] = NULL; 505449e108a1Smrg 505549e108a1Smrg return new_argv; 505649e108a1Smrg} 505749e108a1SmrgEOF 505849e108a1Smrg ;; 505949e108a1Smrg esac 506049e108a1Smrg 506149e108a1Smrg cat <<"EOF" 506249e108a1Smrgvoid lt_dump_script (FILE* f) 506349e108a1Smrg{ 506449e108a1SmrgEOF 506549e108a1Smrg func_emit_wrapper yes | 5066e494fffdSmrg $SED -n -e ' 5067e494fffdSmrgs/^\(.\{79\}\)\(..*\)/\1\ 5068e494fffdSmrg\2/ 5069e494fffdSmrgh 5070e494fffdSmrgs/\([\\"]\)/\\\1/g 5071e494fffdSmrgs/$/\\n/ 5072e494fffdSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 5073e494fffdSmrgg 5074e494fffdSmrgD' 507549e108a1Smrg cat <<"EOF" 507649e108a1Smrg} 5077f05b35a2SmrgEOF 5078f05b35a2Smrg} 5079f05b35a2Smrg# end: func_emit_cwrapperexe_src 5080e0963edeSmrg 508149e108a1Smrg# func_win32_import_lib_p ARG 508249e108a1Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 508349e108a1Smrgfunc_win32_import_lib_p () 508449e108a1Smrg{ 508549e108a1Smrg $opt_debug 508649e108a1Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 508749e108a1Smrg *import*) : ;; 508849e108a1Smrg *) false ;; 508949e108a1Smrg esac 509049e108a1Smrg} 509149e108a1Smrg 5092f05b35a2Smrg# func_mode_link arg... 5093f05b35a2Smrgfunc_mode_link () 5094f05b35a2Smrg{ 5095f05b35a2Smrg $opt_debug 5096f05b35a2Smrg case $host in 5097f05b35a2Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5098f05b35a2Smrg # It is impossible to link a dll without this setting, and 5099f05b35a2Smrg # we shouldn't force the makefile maintainer to figure out 5100f05b35a2Smrg # which system we are compiling for in order to pass an extra 5101f05b35a2Smrg # flag for every libtool invocation. 5102f05b35a2Smrg # allow_undefined=no 5103e0963edeSmrg 5104f05b35a2Smrg # FIXME: Unfortunately, there are problems with the above when trying 5105f05b35a2Smrg # to make a dll which has undefined symbols, in which case not 5106f05b35a2Smrg # even a static library is built. For now, we need to specify 5107f05b35a2Smrg # -no-undefined on the libtool link line when we can be certain 5108f05b35a2Smrg # that all symbols are satisfied, otherwise we get a static library. 5109f05b35a2Smrg allow_undefined=yes 5110f05b35a2Smrg ;; 5111f05b35a2Smrg *) 5112f05b35a2Smrg allow_undefined=yes 5113f05b35a2Smrg ;; 5114f05b35a2Smrg esac 5115f05b35a2Smrg libtool_args=$nonopt 5116f05b35a2Smrg base_compile="$nonopt $@" 5117f05b35a2Smrg compile_command=$nonopt 5118f05b35a2Smrg finalize_command=$nonopt 5119e0963edeSmrg 5120f05b35a2Smrg compile_rpath= 5121f05b35a2Smrg finalize_rpath= 5122f05b35a2Smrg compile_shlibpath= 5123f05b35a2Smrg finalize_shlibpath= 5124f05b35a2Smrg convenience= 5125f05b35a2Smrg old_convenience= 5126f05b35a2Smrg deplibs= 5127f05b35a2Smrg old_deplibs= 5128f05b35a2Smrg compiler_flags= 5129f05b35a2Smrg linker_flags= 5130f05b35a2Smrg dllsearchpath= 5131f05b35a2Smrg lib_search_path=`pwd` 5132f05b35a2Smrg inst_prefix_dir= 5133f05b35a2Smrg new_inherited_linker_flags= 5134e0963edeSmrg 5135f05b35a2Smrg avoid_version=no 513649e108a1Smrg bindir= 5137f05b35a2Smrg dlfiles= 5138f05b35a2Smrg dlprefiles= 5139f05b35a2Smrg dlself=no 5140f05b35a2Smrg export_dynamic=no 5141f05b35a2Smrg export_symbols= 5142f05b35a2Smrg export_symbols_regex= 5143f05b35a2Smrg generated= 5144f05b35a2Smrg libobjs= 5145f05b35a2Smrg ltlibs= 5146f05b35a2Smrg module=no 5147f05b35a2Smrg no_install=no 5148f05b35a2Smrg objs= 5149f05b35a2Smrg non_pic_objects= 5150f05b35a2Smrg precious_files_regex= 5151f05b35a2Smrg prefer_static_libs=no 5152f05b35a2Smrg preload=no 5153f05b35a2Smrg prev= 5154f05b35a2Smrg prevarg= 5155f05b35a2Smrg release= 5156f05b35a2Smrg rpath= 5157f05b35a2Smrg xrpath= 5158f05b35a2Smrg perm_rpath= 5159f05b35a2Smrg temp_rpath= 5160f05b35a2Smrg thread_safe=no 5161f05b35a2Smrg vinfo= 5162f05b35a2Smrg vinfo_number=no 5163f05b35a2Smrg weak_libs= 5164f05b35a2Smrg single_module="${wl}-single_module" 5165f05b35a2Smrg func_infer_tag $base_compile 5166e0963edeSmrg 5167f05b35a2Smrg # We need to know -static, to get the right output filenames. 5168f05b35a2Smrg for arg 5169f05b35a2Smrg do 5170f05b35a2Smrg case $arg in 5171f05b35a2Smrg -shared) 5172f05b35a2Smrg test "$build_libtool_libs" != yes && \ 5173f05b35a2Smrg func_fatal_configuration "can not build a shared library" 5174f05b35a2Smrg build_old_libs=no 5175f05b35a2Smrg break 5176f05b35a2Smrg ;; 5177f05b35a2Smrg -all-static | -static | -static-libtool-libs) 5178f05b35a2Smrg case $arg in 5179f05b35a2Smrg -all-static) 5180f05b35a2Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 5181f05b35a2Smrg func_warning "complete static linking is impossible in this configuration" 5182f05b35a2Smrg fi 5183f05b35a2Smrg if test -n "$link_static_flag"; then 5184f05b35a2Smrg dlopen_self=$dlopen_self_static 5185f05b35a2Smrg fi 5186f05b35a2Smrg prefer_static_libs=yes 5187f05b35a2Smrg ;; 5188f05b35a2Smrg -static) 5189f05b35a2Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 5190f05b35a2Smrg dlopen_self=$dlopen_self_static 5191f05b35a2Smrg fi 5192f05b35a2Smrg prefer_static_libs=built 5193f05b35a2Smrg ;; 5194f05b35a2Smrg -static-libtool-libs) 5195f05b35a2Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 5196f05b35a2Smrg dlopen_self=$dlopen_self_static 5197f05b35a2Smrg fi 5198f05b35a2Smrg prefer_static_libs=yes 5199f05b35a2Smrg ;; 5200f05b35a2Smrg esac 5201f05b35a2Smrg build_libtool_libs=no 5202f05b35a2Smrg build_old_libs=yes 5203f05b35a2Smrg break 5204e0963edeSmrg ;; 5205e0963edeSmrg esac 5206f05b35a2Smrg done 5207e0963edeSmrg 5208f05b35a2Smrg # See if our shared archives depend on static archives. 5209f05b35a2Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 5210e0963edeSmrg 5211f05b35a2Smrg # Go through the arguments, transforming them on the way. 5212f05b35a2Smrg while test "$#" -gt 0; do 5213f05b35a2Smrg arg="$1" 5214f05b35a2Smrg shift 5215f05b35a2Smrg func_quote_for_eval "$arg" 5216f05b35a2Smrg qarg=$func_quote_for_eval_unquoted_result 5217f05b35a2Smrg func_append libtool_args " $func_quote_for_eval_result" 5218e0963edeSmrg 5219f05b35a2Smrg # If the previous option needs an argument, assign it. 5220f05b35a2Smrg if test -n "$prev"; then 5221f05b35a2Smrg case $prev in 5222f05b35a2Smrg output) 5223f05b35a2Smrg func_append compile_command " @OUTPUT@" 5224f05b35a2Smrg func_append finalize_command " @OUTPUT@" 5225e0963edeSmrg ;; 5226e0963edeSmrg esac 5227e0963edeSmrg 5228f05b35a2Smrg case $prev in 522949e108a1Smrg bindir) 523049e108a1Smrg bindir="$arg" 523149e108a1Smrg prev= 523249e108a1Smrg continue 523349e108a1Smrg ;; 5234f05b35a2Smrg dlfiles|dlprefiles) 5235f05b35a2Smrg if test "$preload" = no; then 5236f05b35a2Smrg # Add the symbol object into the linking commands. 5237f05b35a2Smrg func_append compile_command " @SYMFILE@" 5238f05b35a2Smrg func_append finalize_command " @SYMFILE@" 5239f05b35a2Smrg preload=yes 5240f05b35a2Smrg fi 5241f05b35a2Smrg case $arg in 5242f05b35a2Smrg *.la | *.lo) ;; # We handle these cases below. 5243f05b35a2Smrg force) 5244f05b35a2Smrg if test "$dlself" = no; then 5245f05b35a2Smrg dlself=needless 5246f05b35a2Smrg export_dynamic=yes 5247f05b35a2Smrg fi 5248f05b35a2Smrg prev= 5249f05b35a2Smrg continue 5250f05b35a2Smrg ;; 5251f05b35a2Smrg self) 5252f05b35a2Smrg if test "$prev" = dlprefiles; then 5253f05b35a2Smrg dlself=yes 5254f05b35a2Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 5255f05b35a2Smrg dlself=yes 5256e0963edeSmrg else 5257f05b35a2Smrg dlself=needless 5258f05b35a2Smrg export_dynamic=yes 5259e0963edeSmrg fi 5260f05b35a2Smrg prev= 5261f05b35a2Smrg continue 5262f05b35a2Smrg ;; 5263f05b35a2Smrg *) 5264f05b35a2Smrg if test "$prev" = dlfiles; then 526567ab2ff2Smrg func_append dlfiles " $arg" 5266f05b35a2Smrg else 526767ab2ff2Smrg func_append dlprefiles " $arg" 5268f05b35a2Smrg fi 5269f05b35a2Smrg prev= 5270f05b35a2Smrg continue 5271f05b35a2Smrg ;; 5272e0963edeSmrg esac 5273e0963edeSmrg ;; 5274f05b35a2Smrg expsyms) 5275f05b35a2Smrg export_symbols="$arg" 5276f05b35a2Smrg test -f "$arg" \ 5277f05b35a2Smrg || func_fatal_error "symbol file \`$arg' does not exist" 5278f05b35a2Smrg prev= 5279f05b35a2Smrg continue 5280f05b35a2Smrg ;; 5281f05b35a2Smrg expsyms_regex) 5282f05b35a2Smrg export_symbols_regex="$arg" 5283f05b35a2Smrg prev= 5284f05b35a2Smrg continue 5285f05b35a2Smrg ;; 5286f05b35a2Smrg framework) 5287f05b35a2Smrg case $host in 5288f05b35a2Smrg *-*-darwin*) 5289f05b35a2Smrg case "$deplibs " in 5290f05b35a2Smrg *" $qarg.ltframework "*) ;; 529167ab2ff2Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 5292f05b35a2Smrg ;; 5293e0963edeSmrg esac 5294f05b35a2Smrg ;; 5295e0963edeSmrg esac 5296f05b35a2Smrg prev= 5297f05b35a2Smrg continue 5298f05b35a2Smrg ;; 5299f05b35a2Smrg inst_prefix) 5300f05b35a2Smrg inst_prefix_dir="$arg" 5301f05b35a2Smrg prev= 5302f05b35a2Smrg continue 5303f05b35a2Smrg ;; 5304f05b35a2Smrg objectlist) 5305f05b35a2Smrg if test -f "$arg"; then 5306f05b35a2Smrg save_arg=$arg 5307f05b35a2Smrg moreargs= 5308f05b35a2Smrg for fil in `cat "$save_arg"` 5309f05b35a2Smrg do 531067ab2ff2Smrg# func_append moreargs " $fil" 5311f05b35a2Smrg arg=$fil 5312f05b35a2Smrg # A libtool-controlled object. 5313e0963edeSmrg 5314f05b35a2Smrg # Check to see that this really is a libtool object. 5315f05b35a2Smrg if func_lalib_unsafe_p "$arg"; then 5316f05b35a2Smrg pic_object= 5317f05b35a2Smrg non_pic_object= 5318e0963edeSmrg 5319f05b35a2Smrg # Read the .lo file 5320f05b35a2Smrg func_source "$arg" 5321e0963edeSmrg 5322f05b35a2Smrg if test -z "$pic_object" || 5323f05b35a2Smrg test -z "$non_pic_object" || 5324f05b35a2Smrg test "$pic_object" = none && 5325f05b35a2Smrg test "$non_pic_object" = none; then 5326f05b35a2Smrg func_fatal_error "cannot find name of object for \`$arg'" 5327f05b35a2Smrg fi 5328e0963edeSmrg 5329f05b35a2Smrg # Extract subdirectory from the argument. 5330f05b35a2Smrg func_dirname "$arg" "/" "" 5331f05b35a2Smrg xdir="$func_dirname_result" 5332e0963edeSmrg 5333f05b35a2Smrg if test "$pic_object" != none; then 5334f05b35a2Smrg # Prepend the subdirectory the object is found in. 5335f05b35a2Smrg pic_object="$xdir$pic_object" 5336e0963edeSmrg 5337f05b35a2Smrg if test "$prev" = dlfiles; then 5338f05b35a2Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 533967ab2ff2Smrg func_append dlfiles " $pic_object" 5340f05b35a2Smrg prev= 5341f05b35a2Smrg continue 5342f05b35a2Smrg else 5343f05b35a2Smrg # If libtool objects are unsupported, then we need to preload. 5344f05b35a2Smrg prev=dlprefiles 5345f05b35a2Smrg fi 5346f05b35a2Smrg fi 5347e0963edeSmrg 5348f05b35a2Smrg # CHECK ME: I think I busted this. -Ossama 5349f05b35a2Smrg if test "$prev" = dlprefiles; then 5350f05b35a2Smrg # Preload the old-style object. 535167ab2ff2Smrg func_append dlprefiles " $pic_object" 5352f05b35a2Smrg prev= 5353f05b35a2Smrg fi 5354e0963edeSmrg 5355f05b35a2Smrg # A PIC object. 5356f05b35a2Smrg func_append libobjs " $pic_object" 5357f05b35a2Smrg arg="$pic_object" 5358f05b35a2Smrg fi 5359e0963edeSmrg 5360f05b35a2Smrg # Non-PIC object. 5361f05b35a2Smrg if test "$non_pic_object" != none; then 5362f05b35a2Smrg # Prepend the subdirectory the object is found in. 5363f05b35a2Smrg non_pic_object="$xdir$non_pic_object" 5364e0963edeSmrg 5365f05b35a2Smrg # A standard non-PIC object 5366f05b35a2Smrg func_append non_pic_objects " $non_pic_object" 5367f05b35a2Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 5368f05b35a2Smrg arg="$non_pic_object" 5369f05b35a2Smrg fi 5370f05b35a2Smrg else 5371f05b35a2Smrg # If the PIC object exists, use it instead. 5372f05b35a2Smrg # $xdir was prepended to $pic_object above. 5373f05b35a2Smrg non_pic_object="$pic_object" 5374f05b35a2Smrg func_append non_pic_objects " $non_pic_object" 5375f05b35a2Smrg fi 5376f05b35a2Smrg else 5377f05b35a2Smrg # Only an error if not doing a dry-run. 5378f05b35a2Smrg if $opt_dry_run; then 5379f05b35a2Smrg # Extract subdirectory from the argument. 5380f05b35a2Smrg func_dirname "$arg" "/" "" 5381f05b35a2Smrg xdir="$func_dirname_result" 5382f05b35a2Smrg 5383f05b35a2Smrg func_lo2o "$arg" 5384f05b35a2Smrg pic_object=$xdir$objdir/$func_lo2o_result 5385f05b35a2Smrg non_pic_object=$xdir$func_lo2o_result 5386f05b35a2Smrg func_append libobjs " $pic_object" 5387f05b35a2Smrg func_append non_pic_objects " $non_pic_object" 5388f05b35a2Smrg else 5389f05b35a2Smrg func_fatal_error "\`$arg' is not a valid libtool object" 5390f05b35a2Smrg fi 5391f05b35a2Smrg fi 5392e0963edeSmrg done 5393f05b35a2Smrg else 5394f05b35a2Smrg func_fatal_error "link input file \`$arg' does not exist" 5395e0963edeSmrg fi 5396f05b35a2Smrg arg=$save_arg 5397f05b35a2Smrg prev= 5398f05b35a2Smrg continue 5399f05b35a2Smrg ;; 5400f05b35a2Smrg precious_regex) 5401f05b35a2Smrg precious_files_regex="$arg" 5402f05b35a2Smrg prev= 5403f05b35a2Smrg continue 5404f05b35a2Smrg ;; 5405f05b35a2Smrg release) 5406f05b35a2Smrg release="-$arg" 5407f05b35a2Smrg prev= 5408f05b35a2Smrg continue 5409f05b35a2Smrg ;; 5410f05b35a2Smrg rpath | xrpath) 5411f05b35a2Smrg # We need an absolute path. 5412f05b35a2Smrg case $arg in 5413f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5414f05b35a2Smrg *) 5415f05b35a2Smrg func_fatal_error "only absolute run-paths are allowed" 5416f05b35a2Smrg ;; 5417e0963edeSmrg esac 5418f05b35a2Smrg if test "$prev" = rpath; then 5419f05b35a2Smrg case "$rpath " in 5420f05b35a2Smrg *" $arg "*) ;; 542167ab2ff2Smrg *) func_append rpath " $arg" ;; 5422f05b35a2Smrg esac 5423f05b35a2Smrg else 5424f05b35a2Smrg case "$xrpath " in 5425f05b35a2Smrg *" $arg "*) ;; 542667ab2ff2Smrg *) func_append xrpath " $arg" ;; 5427f05b35a2Smrg esac 5428f05b35a2Smrg fi 5429f05b35a2Smrg prev= 5430f05b35a2Smrg continue 5431f05b35a2Smrg ;; 5432f05b35a2Smrg shrext) 5433f05b35a2Smrg shrext_cmds="$arg" 5434f05b35a2Smrg prev= 5435f05b35a2Smrg continue 5436f05b35a2Smrg ;; 5437f05b35a2Smrg weak) 543867ab2ff2Smrg func_append weak_libs " $arg" 5439f05b35a2Smrg prev= 5440f05b35a2Smrg continue 5441f05b35a2Smrg ;; 5442f05b35a2Smrg xcclinker) 544367ab2ff2Smrg func_append linker_flags " $qarg" 544467ab2ff2Smrg func_append compiler_flags " $qarg" 5445f05b35a2Smrg prev= 5446f05b35a2Smrg func_append compile_command " $qarg" 5447f05b35a2Smrg func_append finalize_command " $qarg" 5448f05b35a2Smrg continue 5449f05b35a2Smrg ;; 5450f05b35a2Smrg xcompiler) 545167ab2ff2Smrg func_append compiler_flags " $qarg" 5452f05b35a2Smrg prev= 5453f05b35a2Smrg func_append compile_command " $qarg" 5454f05b35a2Smrg func_append finalize_command " $qarg" 5455f05b35a2Smrg continue 5456f05b35a2Smrg ;; 5457f05b35a2Smrg xlinker) 545867ab2ff2Smrg func_append linker_flags " $qarg" 545967ab2ff2Smrg func_append compiler_flags " $wl$qarg" 5460f05b35a2Smrg prev= 5461f05b35a2Smrg func_append compile_command " $wl$qarg" 5462f05b35a2Smrg func_append finalize_command " $wl$qarg" 5463f05b35a2Smrg continue 5464e0963edeSmrg ;; 5465e0963edeSmrg *) 5466f05b35a2Smrg eval "$prev=\"\$arg\"" 5467f05b35a2Smrg prev= 5468f05b35a2Smrg continue 5469e0963edeSmrg ;; 5470e0963edeSmrg esac 5471f05b35a2Smrg fi # test -n "$prev" 5472e0963edeSmrg 5473f05b35a2Smrg prevarg="$arg" 5474e0963edeSmrg 5475f05b35a2Smrg case $arg in 5476f05b35a2Smrg -all-static) 5477f05b35a2Smrg if test -n "$link_static_flag"; then 5478f05b35a2Smrg # See comment for -static flag below, for more details. 5479f05b35a2Smrg func_append compile_command " $link_static_flag" 5480f05b35a2Smrg func_append finalize_command " $link_static_flag" 5481e0963edeSmrg fi 5482f05b35a2Smrg continue 5483f05b35a2Smrg ;; 5484e0963edeSmrg 5485f05b35a2Smrg -allow-undefined) 5486f05b35a2Smrg # FIXME: remove this flag sometime in the future. 5487f05b35a2Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 5488f05b35a2Smrg ;; 5489e0963edeSmrg 5490f05b35a2Smrg -avoid-version) 5491f05b35a2Smrg avoid_version=yes 5492f05b35a2Smrg continue 5493f05b35a2Smrg ;; 5494e0963edeSmrg 549549e108a1Smrg -bindir) 549649e108a1Smrg prev=bindir 549749e108a1Smrg continue 549849e108a1Smrg ;; 549949e108a1Smrg 5500f05b35a2Smrg -dlopen) 5501f05b35a2Smrg prev=dlfiles 5502f05b35a2Smrg continue 5503f05b35a2Smrg ;; 5504e0963edeSmrg 5505f05b35a2Smrg -dlpreopen) 5506f05b35a2Smrg prev=dlprefiles 5507f05b35a2Smrg continue 5508f05b35a2Smrg ;; 5509e0963edeSmrg 5510f05b35a2Smrg -export-dynamic) 5511f05b35a2Smrg export_dynamic=yes 5512f05b35a2Smrg continue 5513f05b35a2Smrg ;; 5514e0963edeSmrg 5515f05b35a2Smrg -export-symbols | -export-symbols-regex) 5516f05b35a2Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 5517f05b35a2Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 5518f05b35a2Smrg fi 5519f05b35a2Smrg if test "X$arg" = "X-export-symbols"; then 5520f05b35a2Smrg prev=expsyms 5521e0963edeSmrg else 5522f05b35a2Smrg prev=expsyms_regex 5523e0963edeSmrg fi 5524f05b35a2Smrg continue 5525f05b35a2Smrg ;; 5526e0963edeSmrg 5527f05b35a2Smrg -framework) 5528f05b35a2Smrg prev=framework 5529f05b35a2Smrg continue 5530f05b35a2Smrg ;; 5531e0963edeSmrg 5532f05b35a2Smrg -inst-prefix-dir) 5533f05b35a2Smrg prev=inst_prefix 5534f05b35a2Smrg continue 5535f05b35a2Smrg ;; 5536e0963edeSmrg 5537f05b35a2Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 5538f05b35a2Smrg # so, if we see these flags be careful not to treat them like -L 5539f05b35a2Smrg -L[A-Z][A-Z]*:*) 5540f05b35a2Smrg case $with_gcc/$host in 5541f05b35a2Smrg no/*-*-irix* | /*-*-irix*) 5542f05b35a2Smrg func_append compile_command " $arg" 5543f05b35a2Smrg func_append finalize_command " $arg" 5544f05b35a2Smrg ;; 5545f05b35a2Smrg esac 5546f05b35a2Smrg continue 5547f05b35a2Smrg ;; 5548e0963edeSmrg 5549f05b35a2Smrg -L*) 555067ab2ff2Smrg func_stripname "-L" '' "$arg" 555167ab2ff2Smrg if test -z "$func_stripname_result"; then 5552f05b35a2Smrg if test "$#" -gt 0; then 5553f05b35a2Smrg func_fatal_error "require no space between \`-L' and \`$1'" 5554e0963edeSmrg else 5555f05b35a2Smrg func_fatal_error "need path for \`-L' option" 5556e0963edeSmrg fi 5557f05b35a2Smrg fi 555867ab2ff2Smrg func_resolve_sysroot "$func_stripname_result" 555967ab2ff2Smrg dir=$func_resolve_sysroot_result 5560f05b35a2Smrg # We need an absolute path. 5561f05b35a2Smrg case $dir in 5562f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5563f05b35a2Smrg *) 5564f05b35a2Smrg absdir=`cd "$dir" && pwd` 5565f05b35a2Smrg test -z "$absdir" && \ 5566f05b35a2Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 5567f05b35a2Smrg dir="$absdir" 5568f05b35a2Smrg ;; 5569e0963edeSmrg esac 5570f05b35a2Smrg case "$deplibs " in 557167ab2ff2Smrg *" -L$dir "* | *" $arg "*) 557267ab2ff2Smrg # Will only happen for absolute or sysroot arguments 557367ab2ff2Smrg ;; 5574f05b35a2Smrg *) 557567ab2ff2Smrg # Preserve sysroot, but never include relative directories 557667ab2ff2Smrg case $dir in 557767ab2ff2Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 557867ab2ff2Smrg *) func_append deplibs " -L$dir" ;; 557967ab2ff2Smrg esac 558067ab2ff2Smrg func_append lib_search_path " $dir" 5581f05b35a2Smrg ;; 5582e0963edeSmrg esac 5583e0963edeSmrg case $host in 5584f05b35a2Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 558549e108a1Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 5586f05b35a2Smrg case :$dllsearchpath: in 5587f05b35a2Smrg *":$dir:"*) ;; 5588f05b35a2Smrg ::) dllsearchpath=$dir;; 558967ab2ff2Smrg *) func_append dllsearchpath ":$dir";; 5590f05b35a2Smrg esac 5591f05b35a2Smrg case :$dllsearchpath: in 5592f05b35a2Smrg *":$testbindir:"*) ;; 5593f05b35a2Smrg ::) dllsearchpath=$testbindir;; 559467ab2ff2Smrg *) func_append dllsearchpath ":$testbindir";; 5595f05b35a2Smrg esac 5596f05b35a2Smrg ;; 5597e0963edeSmrg esac 5598f05b35a2Smrg continue 5599f05b35a2Smrg ;; 5600e0963edeSmrg 5601f05b35a2Smrg -l*) 5602f05b35a2Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 5603f05b35a2Smrg case $host in 560449e108a1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 5605f05b35a2Smrg # These systems don't actually have a C or math library (as such) 5606f05b35a2Smrg continue 5607f05b35a2Smrg ;; 5608f05b35a2Smrg *-*-os2*) 5609f05b35a2Smrg # These systems don't actually have a C library (as such) 5610f05b35a2Smrg test "X$arg" = "X-lc" && continue 5611f05b35a2Smrg ;; 5612f05b35a2Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5613f05b35a2Smrg # Do not include libc due to us having libc/libc_r. 5614f05b35a2Smrg test "X$arg" = "X-lc" && continue 5615f05b35a2Smrg ;; 5616f05b35a2Smrg *-*-rhapsody* | *-*-darwin1.[012]) 5617f05b35a2Smrg # Rhapsody C and math libraries are in the System framework 561867ab2ff2Smrg func_append deplibs " System.ltframework" 5619f05b35a2Smrg continue 5620f05b35a2Smrg ;; 5621f05b35a2Smrg *-*-sco3.2v5* | *-*-sco5v6*) 5622f05b35a2Smrg # Causes problems with __ctype 5623f05b35a2Smrg test "X$arg" = "X-lc" && continue 5624f05b35a2Smrg ;; 5625f05b35a2Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 5626f05b35a2Smrg # Compiler inserts libc in the correct place for threads to work 5627f05b35a2Smrg test "X$arg" = "X-lc" && continue 5628f05b35a2Smrg ;; 5629f05b35a2Smrg esac 5630f05b35a2Smrg elif test "X$arg" = "X-lc_r"; then 5631f05b35a2Smrg case $host in 5632f05b35a2Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5633f05b35a2Smrg # Do not include libc_r directly, use -pthread flag. 5634f05b35a2Smrg continue 5635f05b35a2Smrg ;; 5636f05b35a2Smrg esac 5637f05b35a2Smrg fi 563867ab2ff2Smrg func_append deplibs " $arg" 5639f05b35a2Smrg continue 5640f05b35a2Smrg ;; 5641e0963edeSmrg 5642f05b35a2Smrg -module) 5643f05b35a2Smrg module=yes 5644f05b35a2Smrg continue 5645f05b35a2Smrg ;; 5646e0963edeSmrg 5647f05b35a2Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 5648f05b35a2Smrg # classes, name mangling, and exception handling. 5649f05b35a2Smrg # Darwin uses the -arch flag to determine output architecture. 565067ab2ff2Smrg -model|-arch|-isysroot|--sysroot) 565167ab2ff2Smrg func_append compiler_flags " $arg" 5652f05b35a2Smrg func_append compile_command " $arg" 5653f05b35a2Smrg func_append finalize_command " $arg" 5654f05b35a2Smrg prev=xcompiler 5655f05b35a2Smrg continue 5656f05b35a2Smrg ;; 5657e0963edeSmrg 5658e494fffdSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 5659e494fffdSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 566067ab2ff2Smrg func_append compiler_flags " $arg" 5661f05b35a2Smrg func_append compile_command " $arg" 5662f05b35a2Smrg func_append finalize_command " $arg" 5663f05b35a2Smrg case "$new_inherited_linker_flags " in 5664f05b35a2Smrg *" $arg "*) ;; 566567ab2ff2Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 5666f05b35a2Smrg esac 5667f05b35a2Smrg continue 5668f05b35a2Smrg ;; 5669e0963edeSmrg 5670f05b35a2Smrg -multi_module) 5671f05b35a2Smrg single_module="${wl}-multi_module" 5672f05b35a2Smrg continue 5673f05b35a2Smrg ;; 5674e0963edeSmrg 5675f05b35a2Smrg -no-fast-install) 5676f05b35a2Smrg fast_install=no 5677f05b35a2Smrg continue 5678f05b35a2Smrg ;; 5679e0963edeSmrg 5680f05b35a2Smrg -no-install) 5681f05b35a2Smrg case $host in 5682f05b35a2Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 5683f05b35a2Smrg # The PATH hackery in wrapper scripts is required on Windows 5684f05b35a2Smrg # and Darwin in order for the loader to find any dlls it needs. 5685f05b35a2Smrg func_warning "\`-no-install' is ignored for $host" 5686f05b35a2Smrg func_warning "assuming \`-no-fast-install' instead" 5687f05b35a2Smrg fast_install=no 5688f05b35a2Smrg ;; 5689f05b35a2Smrg *) no_install=yes ;; 5690f05b35a2Smrg esac 5691f05b35a2Smrg continue 5692f05b35a2Smrg ;; 5693e0963edeSmrg 5694f05b35a2Smrg -no-undefined) 5695f05b35a2Smrg allow_undefined=no 5696f05b35a2Smrg continue 5697f05b35a2Smrg ;; 5698e0963edeSmrg 5699f05b35a2Smrg -objectlist) 5700f05b35a2Smrg prev=objectlist 5701f05b35a2Smrg continue 5702f05b35a2Smrg ;; 5703e0963edeSmrg 5704f05b35a2Smrg -o) prev=output ;; 5705e0963edeSmrg 5706f05b35a2Smrg -precious-files-regex) 5707f05b35a2Smrg prev=precious_regex 5708f05b35a2Smrg continue 5709f05b35a2Smrg ;; 5710e0963edeSmrg 5711f05b35a2Smrg -release) 5712f05b35a2Smrg prev=release 5713f05b35a2Smrg continue 5714f05b35a2Smrg ;; 5715e0963edeSmrg 5716f05b35a2Smrg -rpath) 5717f05b35a2Smrg prev=rpath 5718f05b35a2Smrg continue 5719f05b35a2Smrg ;; 5720e0963edeSmrg 5721f05b35a2Smrg -R) 5722f05b35a2Smrg prev=xrpath 5723f05b35a2Smrg continue 5724f05b35a2Smrg ;; 5725e0963edeSmrg 5726f05b35a2Smrg -R*) 5727f05b35a2Smrg func_stripname '-R' '' "$arg" 5728f05b35a2Smrg dir=$func_stripname_result 5729f05b35a2Smrg # We need an absolute path. 5730f05b35a2Smrg case $dir in 5731f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 573267ab2ff2Smrg =*) 573367ab2ff2Smrg func_stripname '=' '' "$dir" 573467ab2ff2Smrg dir=$lt_sysroot$func_stripname_result 573567ab2ff2Smrg ;; 5736f05b35a2Smrg *) 5737f05b35a2Smrg func_fatal_error "only absolute run-paths are allowed" 5738f05b35a2Smrg ;; 5739f05b35a2Smrg esac 5740f05b35a2Smrg case "$xrpath " in 5741f05b35a2Smrg *" $dir "*) ;; 574267ab2ff2Smrg *) func_append xrpath " $dir" ;; 5743f05b35a2Smrg esac 5744f05b35a2Smrg continue 5745f05b35a2Smrg ;; 5746e0963edeSmrg 5747f05b35a2Smrg -shared) 5748f05b35a2Smrg # The effects of -shared are defined in a previous loop. 5749f05b35a2Smrg continue 5750f05b35a2Smrg ;; 5751e0963edeSmrg 5752f05b35a2Smrg -shrext) 5753f05b35a2Smrg prev=shrext 5754f05b35a2Smrg continue 5755f05b35a2Smrg ;; 5756e0963edeSmrg 5757f05b35a2Smrg -static | -static-libtool-libs) 5758f05b35a2Smrg # The effects of -static are defined in a previous loop. 5759f05b35a2Smrg # We used to do the same as -all-static on platforms that 5760f05b35a2Smrg # didn't have a PIC flag, but the assumption that the effects 5761f05b35a2Smrg # would be equivalent was wrong. It would break on at least 5762f05b35a2Smrg # Digital Unix and AIX. 5763f05b35a2Smrg continue 5764f05b35a2Smrg ;; 5765e0963edeSmrg 5766f05b35a2Smrg -thread-safe) 5767f05b35a2Smrg thread_safe=yes 5768f05b35a2Smrg continue 5769f05b35a2Smrg ;; 5770e0963edeSmrg 5771f05b35a2Smrg -version-info) 5772f05b35a2Smrg prev=vinfo 5773f05b35a2Smrg continue 5774f05b35a2Smrg ;; 5775e0963edeSmrg 5776f05b35a2Smrg -version-number) 5777f05b35a2Smrg prev=vinfo 5778f05b35a2Smrg vinfo_number=yes 5779f05b35a2Smrg continue 5780f05b35a2Smrg ;; 5781e0963edeSmrg 5782f05b35a2Smrg -weak) 5783f05b35a2Smrg prev=weak 5784f05b35a2Smrg continue 5785f05b35a2Smrg ;; 5786e0963edeSmrg 5787f05b35a2Smrg -Wc,*) 5788f05b35a2Smrg func_stripname '-Wc,' '' "$arg" 5789f05b35a2Smrg args=$func_stripname_result 5790f05b35a2Smrg arg= 5791f05b35a2Smrg save_ifs="$IFS"; IFS=',' 5792f05b35a2Smrg for flag in $args; do 5793f05b35a2Smrg IFS="$save_ifs" 5794f05b35a2Smrg func_quote_for_eval "$flag" 579567ab2ff2Smrg func_append arg " $func_quote_for_eval_result" 579667ab2ff2Smrg func_append compiler_flags " $func_quote_for_eval_result" 5797f05b35a2Smrg done 5798f05b35a2Smrg IFS="$save_ifs" 5799f05b35a2Smrg func_stripname ' ' '' "$arg" 5800f05b35a2Smrg arg=$func_stripname_result 5801f05b35a2Smrg ;; 5802e0963edeSmrg 5803f05b35a2Smrg -Wl,*) 5804f05b35a2Smrg func_stripname '-Wl,' '' "$arg" 5805f05b35a2Smrg args=$func_stripname_result 5806f05b35a2Smrg arg= 5807f05b35a2Smrg save_ifs="$IFS"; IFS=',' 5808f05b35a2Smrg for flag in $args; do 5809f05b35a2Smrg IFS="$save_ifs" 5810f05b35a2Smrg func_quote_for_eval "$flag" 581167ab2ff2Smrg func_append arg " $wl$func_quote_for_eval_result" 581267ab2ff2Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 581367ab2ff2Smrg func_append linker_flags " $func_quote_for_eval_result" 5814f05b35a2Smrg done 5815f05b35a2Smrg IFS="$save_ifs" 5816f05b35a2Smrg func_stripname ' ' '' "$arg" 5817f05b35a2Smrg arg=$func_stripname_result 5818f05b35a2Smrg ;; 5819e0963edeSmrg 5820f05b35a2Smrg -Xcompiler) 5821f05b35a2Smrg prev=xcompiler 5822f05b35a2Smrg continue 5823f05b35a2Smrg ;; 5824e0963edeSmrg 5825f05b35a2Smrg -Xlinker) 5826f05b35a2Smrg prev=xlinker 5827f05b35a2Smrg continue 5828f05b35a2Smrg ;; 5829e0963edeSmrg 5830f05b35a2Smrg -XCClinker) 5831f05b35a2Smrg prev=xcclinker 5832f05b35a2Smrg continue 5833f05b35a2Smrg ;; 5834e0963edeSmrg 5835f05b35a2Smrg # -msg_* for osf cc 5836f05b35a2Smrg -msg_*) 5837f05b35a2Smrg func_quote_for_eval "$arg" 5838f05b35a2Smrg arg="$func_quote_for_eval_result" 5839f05b35a2Smrg ;; 5840e0963edeSmrg 584149e108a1Smrg # Flags to be passed through unchanged, with rationale: 584249e108a1Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 584349e108a1Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 584449e108a1Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 584549e108a1Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 584649e108a1Smrg # -q* compiler args for the IBM compiler 584749e108a1Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 584849e108a1Smrg # -F/path path to uninstalled frameworks, gcc on darwin 584949e108a1Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 585049e108a1Smrg # @file GCC response files 585149e108a1Smrg # -tp=* Portland pgcc target processor selection 585267ab2ff2Smrg # --sysroot=* for sysroot support 585367ab2ff2Smrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 5854f05b35a2Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 585567ab2ff2Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 585667ab2ff2Smrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 5857f05b35a2Smrg func_quote_for_eval "$arg" 5858f05b35a2Smrg arg="$func_quote_for_eval_result" 5859f05b35a2Smrg func_append compile_command " $arg" 5860f05b35a2Smrg func_append finalize_command " $arg" 586167ab2ff2Smrg func_append compiler_flags " $arg" 5862f05b35a2Smrg continue 5863f05b35a2Smrg ;; 5864e0963edeSmrg 5865f05b35a2Smrg # Some other compiler flag. 5866f05b35a2Smrg -* | +*) 5867f05b35a2Smrg func_quote_for_eval "$arg" 5868f05b35a2Smrg arg="$func_quote_for_eval_result" 5869f05b35a2Smrg ;; 5870e0963edeSmrg 5871f05b35a2Smrg *.$objext) 5872f05b35a2Smrg # A standard object. 587367ab2ff2Smrg func_append objs " $arg" 5874f05b35a2Smrg ;; 5875e0963edeSmrg 5876f05b35a2Smrg *.lo) 5877f05b35a2Smrg # A libtool-controlled object. 5878e0963edeSmrg 5879f05b35a2Smrg # Check to see that this really is a libtool object. 5880f05b35a2Smrg if func_lalib_unsafe_p "$arg"; then 5881f05b35a2Smrg pic_object= 5882f05b35a2Smrg non_pic_object= 5883e0963edeSmrg 5884f05b35a2Smrg # Read the .lo file 5885f05b35a2Smrg func_source "$arg" 5886e0963edeSmrg 5887f05b35a2Smrg if test -z "$pic_object" || 5888f05b35a2Smrg test -z "$non_pic_object" || 5889f05b35a2Smrg test "$pic_object" = none && 5890f05b35a2Smrg test "$non_pic_object" = none; then 5891f05b35a2Smrg func_fatal_error "cannot find name of object for \`$arg'" 5892f05b35a2Smrg fi 5893e0963edeSmrg 5894f05b35a2Smrg # Extract subdirectory from the argument. 5895f05b35a2Smrg func_dirname "$arg" "/" "" 5896f05b35a2Smrg xdir="$func_dirname_result" 5897e0963edeSmrg 5898f05b35a2Smrg if test "$pic_object" != none; then 5899f05b35a2Smrg # Prepend the subdirectory the object is found in. 5900f05b35a2Smrg pic_object="$xdir$pic_object" 5901e0963edeSmrg 5902f05b35a2Smrg if test "$prev" = dlfiles; then 5903f05b35a2Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 590467ab2ff2Smrg func_append dlfiles " $pic_object" 5905f05b35a2Smrg prev= 5906f05b35a2Smrg continue 5907f05b35a2Smrg else 5908f05b35a2Smrg # If libtool objects are unsupported, then we need to preload. 5909f05b35a2Smrg prev=dlprefiles 5910f05b35a2Smrg fi 5911f05b35a2Smrg fi 5912e0963edeSmrg 5913f05b35a2Smrg # CHECK ME: I think I busted this. -Ossama 5914f05b35a2Smrg if test "$prev" = dlprefiles; then 5915f05b35a2Smrg # Preload the old-style object. 591667ab2ff2Smrg func_append dlprefiles " $pic_object" 5917f05b35a2Smrg prev= 5918f05b35a2Smrg fi 5919e0963edeSmrg 5920f05b35a2Smrg # A PIC object. 5921f05b35a2Smrg func_append libobjs " $pic_object" 5922f05b35a2Smrg arg="$pic_object" 5923f05b35a2Smrg fi 5924e0963edeSmrg 5925f05b35a2Smrg # Non-PIC object. 5926f05b35a2Smrg if test "$non_pic_object" != none; then 5927f05b35a2Smrg # Prepend the subdirectory the object is found in. 5928f05b35a2Smrg non_pic_object="$xdir$non_pic_object" 5929e0963edeSmrg 5930f05b35a2Smrg # A standard non-PIC object 5931f05b35a2Smrg func_append non_pic_objects " $non_pic_object" 5932f05b35a2Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 5933f05b35a2Smrg arg="$non_pic_object" 5934f05b35a2Smrg fi 5935f05b35a2Smrg else 5936f05b35a2Smrg # If the PIC object exists, use it instead. 5937f05b35a2Smrg # $xdir was prepended to $pic_object above. 5938f05b35a2Smrg non_pic_object="$pic_object" 5939f05b35a2Smrg func_append non_pic_objects " $non_pic_object" 5940f05b35a2Smrg fi 5941f05b35a2Smrg else 5942f05b35a2Smrg # Only an error if not doing a dry-run. 5943f05b35a2Smrg if $opt_dry_run; then 5944f05b35a2Smrg # Extract subdirectory from the argument. 5945f05b35a2Smrg func_dirname "$arg" "/" "" 5946f05b35a2Smrg xdir="$func_dirname_result" 5947f05b35a2Smrg 5948f05b35a2Smrg func_lo2o "$arg" 5949f05b35a2Smrg pic_object=$xdir$objdir/$func_lo2o_result 5950f05b35a2Smrg non_pic_object=$xdir$func_lo2o_result 5951f05b35a2Smrg func_append libobjs " $pic_object" 5952f05b35a2Smrg func_append non_pic_objects " $non_pic_object" 5953f05b35a2Smrg else 5954f05b35a2Smrg func_fatal_error "\`$arg' is not a valid libtool object" 5955f05b35a2Smrg fi 5956f05b35a2Smrg fi 5957f05b35a2Smrg ;; 5958e0963edeSmrg 5959f05b35a2Smrg *.$libext) 5960f05b35a2Smrg # An archive. 596167ab2ff2Smrg func_append deplibs " $arg" 596267ab2ff2Smrg func_append old_deplibs " $arg" 5963f05b35a2Smrg continue 5964f05b35a2Smrg ;; 5965e0963edeSmrg 5966f05b35a2Smrg *.la) 5967f05b35a2Smrg # A libtool-controlled library. 5968e0963edeSmrg 596967ab2ff2Smrg func_resolve_sysroot "$arg" 5970f05b35a2Smrg if test "$prev" = dlfiles; then 5971f05b35a2Smrg # This library was specified with -dlopen. 597267ab2ff2Smrg func_append dlfiles " $func_resolve_sysroot_result" 5973f05b35a2Smrg prev= 5974f05b35a2Smrg elif test "$prev" = dlprefiles; then 5975f05b35a2Smrg # The library was specified with -dlpreopen. 597667ab2ff2Smrg func_append dlprefiles " $func_resolve_sysroot_result" 5977f05b35a2Smrg prev= 5978f05b35a2Smrg else 597967ab2ff2Smrg func_append deplibs " $func_resolve_sysroot_result" 5980f05b35a2Smrg fi 5981f05b35a2Smrg continue 5982f05b35a2Smrg ;; 5983e0963edeSmrg 5984f05b35a2Smrg # Some other compiler argument. 5985f05b35a2Smrg *) 5986f05b35a2Smrg # Unknown arguments in both finalize_command and compile_command need 5987f05b35a2Smrg # to be aesthetically quoted because they are evaled later. 5988f05b35a2Smrg func_quote_for_eval "$arg" 5989f05b35a2Smrg arg="$func_quote_for_eval_result" 5990f05b35a2Smrg ;; 5991f05b35a2Smrg esac # arg 5992e0963edeSmrg 5993f05b35a2Smrg # Now actually substitute the argument into the commands. 5994f05b35a2Smrg if test -n "$arg"; then 5995f05b35a2Smrg func_append compile_command " $arg" 5996f05b35a2Smrg func_append finalize_command " $arg" 5997f05b35a2Smrg fi 5998f05b35a2Smrg done # argument parsing loop 5999e0963edeSmrg 6000f05b35a2Smrg test -n "$prev" && \ 6001f05b35a2Smrg func_fatal_help "the \`$prevarg' option requires an argument" 6002e0963edeSmrg 6003f05b35a2Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 6004f05b35a2Smrg eval arg=\"$export_dynamic_flag_spec\" 6005f05b35a2Smrg func_append compile_command " $arg" 6006f05b35a2Smrg func_append finalize_command " $arg" 6007f05b35a2Smrg fi 6008e0963edeSmrg 6009f05b35a2Smrg oldlibs= 6010f05b35a2Smrg # calculate the name of the file, without its directory 6011f05b35a2Smrg func_basename "$output" 6012f05b35a2Smrg outputname="$func_basename_result" 6013f05b35a2Smrg libobjs_save="$libobjs" 6014f05b35a2Smrg 6015f05b35a2Smrg if test -n "$shlibpath_var"; then 6016f05b35a2Smrg # get the directories listed in $shlibpath_var 601749e108a1Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 6018e0963edeSmrg else 6019f05b35a2Smrg shlib_search_path= 6020e0963edeSmrg fi 6021f05b35a2Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 6022f05b35a2Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 6023e0963edeSmrg 6024f05b35a2Smrg func_dirname "$output" "/" "" 6025f05b35a2Smrg output_objdir="$func_dirname_result$objdir" 602667ab2ff2Smrg func_to_tool_file "$output_objdir/" 602767ab2ff2Smrg tool_output_objdir=$func_to_tool_file_result 6028f05b35a2Smrg # Create the object directory. 6029f05b35a2Smrg func_mkdir_p "$output_objdir" 6030e0963edeSmrg 6031f05b35a2Smrg # Determine the type of output 6032f05b35a2Smrg case $output in 6033f05b35a2Smrg "") 6034f05b35a2Smrg func_fatal_help "you must specify an output file" 6035f05b35a2Smrg ;; 6036f05b35a2Smrg *.$libext) linkmode=oldlib ;; 6037f05b35a2Smrg *.lo | *.$objext) linkmode=obj ;; 6038f05b35a2Smrg *.la) linkmode=lib ;; 6039f05b35a2Smrg *) linkmode=prog ;; # Anything else should be a program. 6040f05b35a2Smrg esac 6041f05b35a2Smrg 6042f05b35a2Smrg specialdeplibs= 6043f05b35a2Smrg 6044f05b35a2Smrg libs= 6045f05b35a2Smrg # Find all interdependent deplibs by searching for libraries 6046f05b35a2Smrg # that are linked more than once (e.g. -la -lb -la) 6047f05b35a2Smrg for deplib in $deplibs; do 604867ab2ff2Smrg if $opt_preserve_dup_deps ; then 6049f05b35a2Smrg case "$libs " in 605067ab2ff2Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6051f05b35a2Smrg esac 6052f05b35a2Smrg fi 605367ab2ff2Smrg func_append libs " $deplib" 6054f05b35a2Smrg done 6055f05b35a2Smrg 6056f05b35a2Smrg if test "$linkmode" = lib; then 6057f05b35a2Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 6058f05b35a2Smrg 6059f05b35a2Smrg # Compute libraries that are listed more than once in $predeps 6060f05b35a2Smrg # $postdeps and mark them as special (i.e., whose duplicates are 6061f05b35a2Smrg # not to be eliminated). 6062f05b35a2Smrg pre_post_deps= 6063f05b35a2Smrg if $opt_duplicate_compiler_generated_deps; then 6064f05b35a2Smrg for pre_post_dep in $predeps $postdeps; do 6065f05b35a2Smrg case "$pre_post_deps " in 606667ab2ff2Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 6067f05b35a2Smrg esac 606867ab2ff2Smrg func_append pre_post_deps " $pre_post_dep" 6069f05b35a2Smrg done 6070f05b35a2Smrg fi 6071f05b35a2Smrg pre_post_deps= 6072f05b35a2Smrg fi 6073f05b35a2Smrg 6074f05b35a2Smrg deplibs= 6075f05b35a2Smrg newdependency_libs= 6076f05b35a2Smrg newlib_search_path= 6077f05b35a2Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 6078f05b35a2Smrg notinst_deplibs= # not-installed libtool libraries 6079f05b35a2Smrg notinst_path= # paths that contain not-installed libtool libraries 6080f05b35a2Smrg 6081f05b35a2Smrg case $linkmode in 6082f05b35a2Smrg lib) 6083f05b35a2Smrg passes="conv dlpreopen link" 6084f05b35a2Smrg for file in $dlfiles $dlprefiles; do 6085f05b35a2Smrg case $file in 6086f05b35a2Smrg *.la) ;; 6087f05b35a2Smrg *) 6088f05b35a2Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 6089f05b35a2Smrg ;; 6090f05b35a2Smrg esac 6091f05b35a2Smrg done 6092f05b35a2Smrg ;; 6093f05b35a2Smrg prog) 6094f05b35a2Smrg compile_deplibs= 6095f05b35a2Smrg finalize_deplibs= 6096f05b35a2Smrg alldeplibs=no 6097f05b35a2Smrg newdlfiles= 6098f05b35a2Smrg newdlprefiles= 6099f05b35a2Smrg passes="conv scan dlopen dlpreopen link" 6100f05b35a2Smrg ;; 6101f05b35a2Smrg *) passes="conv" 6102f05b35a2Smrg ;; 6103f05b35a2Smrg esac 6104f05b35a2Smrg 6105f05b35a2Smrg for pass in $passes; do 6106f05b35a2Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 6107f05b35a2Smrg # so that -L comes before libs that need it for instance... 6108f05b35a2Smrg if test "$linkmode,$pass" = "lib,link"; then 6109f05b35a2Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 6110f05b35a2Smrg ## order, and fix it there properly 6111f05b35a2Smrg tmp_deplibs= 6112f05b35a2Smrg for deplib in $deplibs; do 6113f05b35a2Smrg tmp_deplibs="$deplib $tmp_deplibs" 6114f05b35a2Smrg done 6115f05b35a2Smrg deplibs="$tmp_deplibs" 6116f05b35a2Smrg fi 6117f05b35a2Smrg 6118f05b35a2Smrg if test "$linkmode,$pass" = "lib,link" || 6119f05b35a2Smrg test "$linkmode,$pass" = "prog,scan"; then 6120f05b35a2Smrg libs="$deplibs" 6121f05b35a2Smrg deplibs= 6122f05b35a2Smrg fi 6123f05b35a2Smrg if test "$linkmode" = prog; then 6124f05b35a2Smrg case $pass in 6125f05b35a2Smrg dlopen) libs="$dlfiles" ;; 6126f05b35a2Smrg dlpreopen) libs="$dlprefiles" ;; 6127f05b35a2Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 6128f05b35a2Smrg esac 6129f05b35a2Smrg fi 6130f05b35a2Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 6131f05b35a2Smrg # Collect and forward deplibs of preopened libtool libs 6132f05b35a2Smrg for lib in $dlprefiles; do 6133f05b35a2Smrg # Ignore non-libtool-libs 6134f05b35a2Smrg dependency_libs= 613567ab2ff2Smrg func_resolve_sysroot "$lib" 6136f05b35a2Smrg case $lib in 613767ab2ff2Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 6138f05b35a2Smrg esac 6139f05b35a2Smrg 6140f05b35a2Smrg # Collect preopened libtool deplibs, except any this library 6141f05b35a2Smrg # has declared as weak libs 6142f05b35a2Smrg for deplib in $dependency_libs; do 614349e108a1Smrg func_basename "$deplib" 614449e108a1Smrg deplib_base=$func_basename_result 6145f05b35a2Smrg case " $weak_libs " in 6146f05b35a2Smrg *" $deplib_base "*) ;; 614767ab2ff2Smrg *) func_append deplibs " $deplib" ;; 6148f05b35a2Smrg esac 6149f05b35a2Smrg done 6150f05b35a2Smrg done 6151f05b35a2Smrg libs="$dlprefiles" 6152f05b35a2Smrg fi 6153f05b35a2Smrg if test "$pass" = dlopen; then 6154f05b35a2Smrg # Collect dlpreopened libraries 6155f05b35a2Smrg save_deplibs="$deplibs" 6156f05b35a2Smrg deplibs= 6157f05b35a2Smrg fi 6158f05b35a2Smrg 6159f05b35a2Smrg for deplib in $libs; do 6160f05b35a2Smrg lib= 6161f05b35a2Smrg found=no 6162f05b35a2Smrg case $deplib in 6163e494fffdSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 6164e494fffdSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 6165f05b35a2Smrg if test "$linkmode,$pass" = "prog,link"; then 6166f05b35a2Smrg compile_deplibs="$deplib $compile_deplibs" 6167f05b35a2Smrg finalize_deplibs="$deplib $finalize_deplibs" 6168f05b35a2Smrg else 616967ab2ff2Smrg func_append compiler_flags " $deplib" 6170f05b35a2Smrg if test "$linkmode" = lib ; then 6171f05b35a2Smrg case "$new_inherited_linker_flags " in 6172f05b35a2Smrg *" $deplib "*) ;; 617367ab2ff2Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 6174f05b35a2Smrg esac 6175f05b35a2Smrg fi 6176f05b35a2Smrg fi 6177f05b35a2Smrg continue 6178f05b35a2Smrg ;; 6179f05b35a2Smrg -l*) 6180f05b35a2Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 6181f05b35a2Smrg func_warning "\`-l' is ignored for archives/objects" 6182f05b35a2Smrg continue 6183f05b35a2Smrg fi 6184f05b35a2Smrg func_stripname '-l' '' "$deplib" 6185f05b35a2Smrg name=$func_stripname_result 6186f05b35a2Smrg if test "$linkmode" = lib; then 6187f05b35a2Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 6188f05b35a2Smrg else 6189f05b35a2Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 6190f05b35a2Smrg fi 6191f05b35a2Smrg for searchdir in $searchdirs; do 6192f05b35a2Smrg for search_ext in .la $std_shrext .so .a; do 6193f05b35a2Smrg # Search the libtool library 6194f05b35a2Smrg lib="$searchdir/lib${name}${search_ext}" 6195f05b35a2Smrg if test -f "$lib"; then 6196f05b35a2Smrg if test "$search_ext" = ".la"; then 6197f05b35a2Smrg found=yes 6198f05b35a2Smrg else 6199f05b35a2Smrg found=no 6200f05b35a2Smrg fi 6201f05b35a2Smrg break 2 6202f05b35a2Smrg fi 6203f05b35a2Smrg done 6204f05b35a2Smrg done 6205f05b35a2Smrg if test "$found" != yes; then 6206f05b35a2Smrg # deplib doesn't seem to be a libtool library 6207f05b35a2Smrg if test "$linkmode,$pass" = "prog,link"; then 6208f05b35a2Smrg compile_deplibs="$deplib $compile_deplibs" 6209f05b35a2Smrg finalize_deplibs="$deplib $finalize_deplibs" 6210f05b35a2Smrg else 6211f05b35a2Smrg deplibs="$deplib $deplibs" 6212f05b35a2Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6213f05b35a2Smrg fi 6214f05b35a2Smrg continue 6215f05b35a2Smrg else # deplib is a libtool library 6216f05b35a2Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 6217f05b35a2Smrg # We need to do some special things here, and not later. 6218f05b35a2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 6219f05b35a2Smrg case " $predeps $postdeps " in 6220f05b35a2Smrg *" $deplib "*) 6221f05b35a2Smrg if func_lalib_p "$lib"; then 6222f05b35a2Smrg library_names= 6223f05b35a2Smrg old_library= 6224f05b35a2Smrg func_source "$lib" 6225f05b35a2Smrg for l in $old_library $library_names; do 6226f05b35a2Smrg ll="$l" 6227f05b35a2Smrg done 6228f05b35a2Smrg if test "X$ll" = "X$old_library" ; then # only static version available 6229f05b35a2Smrg found=no 6230f05b35a2Smrg func_dirname "$lib" "" "." 6231f05b35a2Smrg ladir="$func_dirname_result" 6232f05b35a2Smrg lib=$ladir/$old_library 6233f05b35a2Smrg if test "$linkmode,$pass" = "prog,link"; then 6234f05b35a2Smrg compile_deplibs="$deplib $compile_deplibs" 6235f05b35a2Smrg finalize_deplibs="$deplib $finalize_deplibs" 6236f05b35a2Smrg else 6237f05b35a2Smrg deplibs="$deplib $deplibs" 6238f05b35a2Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6239f05b35a2Smrg fi 6240f05b35a2Smrg continue 6241f05b35a2Smrg fi 6242f05b35a2Smrg fi 6243f05b35a2Smrg ;; 6244f05b35a2Smrg *) ;; 6245f05b35a2Smrg esac 6246f05b35a2Smrg fi 6247f05b35a2Smrg fi 6248f05b35a2Smrg ;; # -l 6249f05b35a2Smrg *.ltframework) 6250f05b35a2Smrg if test "$linkmode,$pass" = "prog,link"; then 6251f05b35a2Smrg compile_deplibs="$deplib $compile_deplibs" 6252f05b35a2Smrg finalize_deplibs="$deplib $finalize_deplibs" 6253f05b35a2Smrg else 6254f05b35a2Smrg deplibs="$deplib $deplibs" 6255f05b35a2Smrg if test "$linkmode" = lib ; then 6256f05b35a2Smrg case "$new_inherited_linker_flags " in 6257f05b35a2Smrg *" $deplib "*) ;; 625867ab2ff2Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 6259f05b35a2Smrg esac 6260f05b35a2Smrg fi 6261f05b35a2Smrg fi 6262f05b35a2Smrg continue 6263f05b35a2Smrg ;; 6264f05b35a2Smrg -L*) 6265f05b35a2Smrg case $linkmode in 6266f05b35a2Smrg lib) 6267f05b35a2Smrg deplibs="$deplib $deplibs" 6268f05b35a2Smrg test "$pass" = conv && continue 6269f05b35a2Smrg newdependency_libs="$deplib $newdependency_libs" 6270f05b35a2Smrg func_stripname '-L' '' "$deplib" 627167ab2ff2Smrg func_resolve_sysroot "$func_stripname_result" 627267ab2ff2Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 6273f05b35a2Smrg ;; 6274f05b35a2Smrg prog) 6275f05b35a2Smrg if test "$pass" = conv; then 6276f05b35a2Smrg deplibs="$deplib $deplibs" 6277f05b35a2Smrg continue 6278f05b35a2Smrg fi 6279f05b35a2Smrg if test "$pass" = scan; then 6280f05b35a2Smrg deplibs="$deplib $deplibs" 6281f05b35a2Smrg else 6282f05b35a2Smrg compile_deplibs="$deplib $compile_deplibs" 6283f05b35a2Smrg finalize_deplibs="$deplib $finalize_deplibs" 6284f05b35a2Smrg fi 6285f05b35a2Smrg func_stripname '-L' '' "$deplib" 628667ab2ff2Smrg func_resolve_sysroot "$func_stripname_result" 628767ab2ff2Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 6288f05b35a2Smrg ;; 6289f05b35a2Smrg *) 6290f05b35a2Smrg func_warning "\`-L' is ignored for archives/objects" 6291f05b35a2Smrg ;; 6292f05b35a2Smrg esac # linkmode 6293f05b35a2Smrg continue 6294f05b35a2Smrg ;; # -L 6295f05b35a2Smrg -R*) 6296f05b35a2Smrg if test "$pass" = link; then 6297f05b35a2Smrg func_stripname '-R' '' "$deplib" 629867ab2ff2Smrg func_resolve_sysroot "$func_stripname_result" 629967ab2ff2Smrg dir=$func_resolve_sysroot_result 6300f05b35a2Smrg # Make sure the xrpath contains only unique directories. 6301f05b35a2Smrg case "$xrpath " in 6302f05b35a2Smrg *" $dir "*) ;; 630367ab2ff2Smrg *) func_append xrpath " $dir" ;; 6304f05b35a2Smrg esac 6305f05b35a2Smrg fi 6306f05b35a2Smrg deplibs="$deplib $deplibs" 6307f05b35a2Smrg continue 6308f05b35a2Smrg ;; 630967ab2ff2Smrg *.la) 631067ab2ff2Smrg func_resolve_sysroot "$deplib" 631167ab2ff2Smrg lib=$func_resolve_sysroot_result 631267ab2ff2Smrg ;; 6313f05b35a2Smrg *.$libext) 6314f05b35a2Smrg if test "$pass" = conv; then 6315f05b35a2Smrg deplibs="$deplib $deplibs" 6316f05b35a2Smrg continue 6317f05b35a2Smrg fi 6318f05b35a2Smrg case $linkmode in 6319f05b35a2Smrg lib) 6320f05b35a2Smrg # Linking convenience modules into shared libraries is allowed, 6321f05b35a2Smrg # but linking other static libraries is non-portable. 6322f05b35a2Smrg case " $dlpreconveniencelibs " in 6323f05b35a2Smrg *" $deplib "*) ;; 6324f05b35a2Smrg *) 6325f05b35a2Smrg valid_a_lib=no 6326f05b35a2Smrg case $deplibs_check_method in 6327f05b35a2Smrg match_pattern*) 6328f05b35a2Smrg set dummy $deplibs_check_method; shift 6329f05b35a2Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 633049e108a1Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 6331f05b35a2Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 6332f05b35a2Smrg valid_a_lib=yes 6333f05b35a2Smrg fi 6334f05b35a2Smrg ;; 6335f05b35a2Smrg pass_all) 6336f05b35a2Smrg valid_a_lib=yes 6337f05b35a2Smrg ;; 6338f05b35a2Smrg esac 6339f05b35a2Smrg if test "$valid_a_lib" != yes; then 634049e108a1Smrg echo 6341f05b35a2Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 634249e108a1Smrg echo "*** I have the capability to make that library automatically link in when" 634349e108a1Smrg echo "*** you link to this library. But I can only do this if you have a" 634449e108a1Smrg echo "*** shared version of the library, which you do not appear to have" 634549e108a1Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 634649e108a1Smrg echo "*** that it is just a static archive that I should not use here." 6347f05b35a2Smrg else 634849e108a1Smrg echo 6349f05b35a2Smrg $ECHO "*** Warning: Linking the shared library $output against the" 6350f05b35a2Smrg $ECHO "*** static library $deplib is not portable!" 6351f05b35a2Smrg deplibs="$deplib $deplibs" 6352f05b35a2Smrg fi 6353f05b35a2Smrg ;; 6354f05b35a2Smrg esac 6355f05b35a2Smrg continue 6356f05b35a2Smrg ;; 6357f05b35a2Smrg prog) 6358f05b35a2Smrg if test "$pass" != link; then 6359f05b35a2Smrg deplibs="$deplib $deplibs" 6360f05b35a2Smrg else 6361f05b35a2Smrg compile_deplibs="$deplib $compile_deplibs" 6362f05b35a2Smrg finalize_deplibs="$deplib $finalize_deplibs" 6363f05b35a2Smrg fi 6364f05b35a2Smrg continue 6365f05b35a2Smrg ;; 6366f05b35a2Smrg esac # linkmode 6367f05b35a2Smrg ;; # *.$libext 6368f05b35a2Smrg *.lo | *.$objext) 6369f05b35a2Smrg if test "$pass" = conv; then 6370f05b35a2Smrg deplibs="$deplib $deplibs" 6371f05b35a2Smrg elif test "$linkmode" = prog; then 6372f05b35a2Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 6373f05b35a2Smrg # If there is no dlopen support or we're linking statically, 6374f05b35a2Smrg # we need to preload. 637567ab2ff2Smrg func_append newdlprefiles " $deplib" 6376f05b35a2Smrg compile_deplibs="$deplib $compile_deplibs" 6377f05b35a2Smrg finalize_deplibs="$deplib $finalize_deplibs" 6378f05b35a2Smrg else 637967ab2ff2Smrg func_append newdlfiles " $deplib" 6380f05b35a2Smrg fi 6381f05b35a2Smrg fi 6382f05b35a2Smrg continue 6383f05b35a2Smrg ;; 6384f05b35a2Smrg %DEPLIBS%) 6385f05b35a2Smrg alldeplibs=yes 6386f05b35a2Smrg continue 6387f05b35a2Smrg ;; 6388f05b35a2Smrg esac # case $deplib 6389f05b35a2Smrg 6390f05b35a2Smrg if test "$found" = yes || test -f "$lib"; then : 6391f05b35a2Smrg else 6392f05b35a2Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 6393f05b35a2Smrg fi 6394f05b35a2Smrg 6395f05b35a2Smrg # Check to see that this really is a libtool archive. 6396f05b35a2Smrg func_lalib_unsafe_p "$lib" \ 6397f05b35a2Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 6398f05b35a2Smrg 6399f05b35a2Smrg func_dirname "$lib" "" "." 6400f05b35a2Smrg ladir="$func_dirname_result" 6401f05b35a2Smrg 6402f05b35a2Smrg dlname= 6403f05b35a2Smrg dlopen= 6404f05b35a2Smrg dlpreopen= 6405f05b35a2Smrg libdir= 6406f05b35a2Smrg library_names= 6407f05b35a2Smrg old_library= 6408f05b35a2Smrg inherited_linker_flags= 6409f05b35a2Smrg # If the library was installed with an old release of libtool, 6410f05b35a2Smrg # it will not redefine variables installed, or shouldnotlink 6411f05b35a2Smrg installed=yes 6412f05b35a2Smrg shouldnotlink=no 6413f05b35a2Smrg avoidtemprpath= 6414f05b35a2Smrg 6415f05b35a2Smrg 6416f05b35a2Smrg # Read the .la file 6417f05b35a2Smrg func_source "$lib" 6418f05b35a2Smrg 6419f05b35a2Smrg # Convert "-framework foo" to "foo.ltframework" 6420f05b35a2Smrg if test -n "$inherited_linker_flags"; then 642149e108a1Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 6422f05b35a2Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 6423f05b35a2Smrg case " $new_inherited_linker_flags " in 6424f05b35a2Smrg *" $tmp_inherited_linker_flag "*) ;; 642567ab2ff2Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 6426f05b35a2Smrg esac 6427f05b35a2Smrg done 6428f05b35a2Smrg fi 642949e108a1Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 6430f05b35a2Smrg if test "$linkmode,$pass" = "lib,link" || 6431f05b35a2Smrg test "$linkmode,$pass" = "prog,scan" || 6432f05b35a2Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 643367ab2ff2Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 643467ab2ff2Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 6435f05b35a2Smrg fi 6436f05b35a2Smrg 6437f05b35a2Smrg if test "$pass" = conv; then 6438f05b35a2Smrg # Only check for convenience libraries 6439f05b35a2Smrg deplibs="$lib $deplibs" 6440f05b35a2Smrg if test -z "$libdir"; then 6441f05b35a2Smrg if test -z "$old_library"; then 6442f05b35a2Smrg func_fatal_error "cannot find name of link library for \`$lib'" 6443f05b35a2Smrg fi 6444f05b35a2Smrg # It is a libtool convenience library, so add in its objects. 644567ab2ff2Smrg func_append convenience " $ladir/$objdir/$old_library" 644667ab2ff2Smrg func_append old_convenience " $ladir/$objdir/$old_library" 6447f05b35a2Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 6448f05b35a2Smrg func_fatal_error "\`$lib' is not a convenience library" 6449f05b35a2Smrg fi 6450f05b35a2Smrg tmp_libs= 6451f05b35a2Smrg for deplib in $dependency_libs; do 6452f05b35a2Smrg deplibs="$deplib $deplibs" 645367ab2ff2Smrg if $opt_preserve_dup_deps ; then 6454f05b35a2Smrg case "$tmp_libs " in 645567ab2ff2Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6456f05b35a2Smrg esac 6457f05b35a2Smrg fi 645867ab2ff2Smrg func_append tmp_libs " $deplib" 6459f05b35a2Smrg done 6460f05b35a2Smrg continue 6461f05b35a2Smrg fi # $pass = conv 6462f05b35a2Smrg 6463f05b35a2Smrg 6464f05b35a2Smrg # Get the name of the library we link against. 6465f05b35a2Smrg linklib= 646667ab2ff2Smrg if test -n "$old_library" && 646767ab2ff2Smrg { test "$prefer_static_libs" = yes || 646867ab2ff2Smrg test "$prefer_static_libs,$installed" = "built,no"; }; then 646967ab2ff2Smrg linklib=$old_library 647067ab2ff2Smrg else 647167ab2ff2Smrg for l in $old_library $library_names; do 647267ab2ff2Smrg linklib="$l" 647367ab2ff2Smrg done 647467ab2ff2Smrg fi 6475f05b35a2Smrg if test -z "$linklib"; then 6476f05b35a2Smrg func_fatal_error "cannot find name of link library for \`$lib'" 6477f05b35a2Smrg fi 6478f05b35a2Smrg 6479f05b35a2Smrg # This library was specified with -dlopen. 6480f05b35a2Smrg if test "$pass" = dlopen; then 6481f05b35a2Smrg if test -z "$libdir"; then 6482f05b35a2Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 6483f05b35a2Smrg fi 6484f05b35a2Smrg if test -z "$dlname" || 6485f05b35a2Smrg test "$dlopen_support" != yes || 6486f05b35a2Smrg test "$build_libtool_libs" = no; then 6487f05b35a2Smrg # If there is no dlname, no dlopen support or we're linking 6488f05b35a2Smrg # statically, we need to preload. We also need to preload any 6489f05b35a2Smrg # dependent libraries so libltdl's deplib preloader doesn't 6490f05b35a2Smrg # bomb out in the load deplibs phase. 649167ab2ff2Smrg func_append dlprefiles " $lib $dependency_libs" 6492f05b35a2Smrg else 649367ab2ff2Smrg func_append newdlfiles " $lib" 6494f05b35a2Smrg fi 6495f05b35a2Smrg continue 6496f05b35a2Smrg fi # $pass = dlopen 6497f05b35a2Smrg 6498f05b35a2Smrg # We need an absolute path. 6499f05b35a2Smrg case $ladir in 6500f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 6501f05b35a2Smrg *) 6502f05b35a2Smrg abs_ladir=`cd "$ladir" && pwd` 6503f05b35a2Smrg if test -z "$abs_ladir"; then 6504f05b35a2Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 6505f05b35a2Smrg func_warning "passing it literally to the linker, although it might fail" 6506f05b35a2Smrg abs_ladir="$ladir" 6507f05b35a2Smrg fi 6508f05b35a2Smrg ;; 6509f05b35a2Smrg esac 6510f05b35a2Smrg func_basename "$lib" 6511f05b35a2Smrg laname="$func_basename_result" 6512f05b35a2Smrg 6513f05b35a2Smrg # Find the relevant object directory and library name. 6514f05b35a2Smrg if test "X$installed" = Xyes; then 651567ab2ff2Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6516f05b35a2Smrg func_warning "library \`$lib' was moved." 6517f05b35a2Smrg dir="$ladir" 6518f05b35a2Smrg absdir="$abs_ladir" 6519f05b35a2Smrg libdir="$abs_ladir" 6520f05b35a2Smrg else 652167ab2ff2Smrg dir="$lt_sysroot$libdir" 652267ab2ff2Smrg absdir="$lt_sysroot$libdir" 6523f05b35a2Smrg fi 6524f05b35a2Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 6525f05b35a2Smrg else 6526f05b35a2Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6527f05b35a2Smrg dir="$ladir" 6528f05b35a2Smrg absdir="$abs_ladir" 6529f05b35a2Smrg # Remove this search path later 653067ab2ff2Smrg func_append notinst_path " $abs_ladir" 6531f05b35a2Smrg else 6532f05b35a2Smrg dir="$ladir/$objdir" 6533f05b35a2Smrg absdir="$abs_ladir/$objdir" 6534f05b35a2Smrg # Remove this search path later 653567ab2ff2Smrg func_append notinst_path " $abs_ladir" 6536f05b35a2Smrg fi 6537f05b35a2Smrg fi # $installed = yes 6538f05b35a2Smrg func_stripname 'lib' '.la' "$laname" 6539f05b35a2Smrg name=$func_stripname_result 6540f05b35a2Smrg 6541f05b35a2Smrg # This library was specified with -dlpreopen. 6542f05b35a2Smrg if test "$pass" = dlpreopen; then 6543f05b35a2Smrg if test -z "$libdir" && test "$linkmode" = prog; then 6544f05b35a2Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 6545f05b35a2Smrg fi 654667ab2ff2Smrg case "$host" in 654767ab2ff2Smrg # special handling for platforms with PE-DLLs. 654867ab2ff2Smrg *cygwin* | *mingw* | *cegcc* ) 654967ab2ff2Smrg # Linker will automatically link against shared library if both 655067ab2ff2Smrg # static and shared are present. Therefore, ensure we extract 655167ab2ff2Smrg # symbols from the import library if a shared library is present 655267ab2ff2Smrg # (otherwise, the dlopen module name will be incorrect). We do 655367ab2ff2Smrg # this by putting the import library name into $newdlprefiles. 655467ab2ff2Smrg # We recover the dlopen module name by 'saving' the la file 655567ab2ff2Smrg # name in a special purpose variable, and (later) extracting the 655667ab2ff2Smrg # dlname from the la file. 655767ab2ff2Smrg if test -n "$dlname"; then 655867ab2ff2Smrg func_tr_sh "$dir/$linklib" 655967ab2ff2Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 656067ab2ff2Smrg func_append newdlprefiles " $dir/$linklib" 656167ab2ff2Smrg else 656267ab2ff2Smrg func_append newdlprefiles " $dir/$old_library" 656367ab2ff2Smrg # Keep a list of preopened convenience libraries to check 656467ab2ff2Smrg # that they are being used correctly in the link pass. 656567ab2ff2Smrg test -z "$libdir" && \ 656667ab2ff2Smrg func_append dlpreconveniencelibs " $dir/$old_library" 656767ab2ff2Smrg fi 656867ab2ff2Smrg ;; 656967ab2ff2Smrg * ) 657067ab2ff2Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 657167ab2ff2Smrg # are required to link). 657267ab2ff2Smrg if test -n "$old_library"; then 657367ab2ff2Smrg func_append newdlprefiles " $dir/$old_library" 657467ab2ff2Smrg # Keep a list of preopened convenience libraries to check 657567ab2ff2Smrg # that they are being used correctly in the link pass. 657667ab2ff2Smrg test -z "$libdir" && \ 657767ab2ff2Smrg func_append dlpreconveniencelibs " $dir/$old_library" 657867ab2ff2Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 657967ab2ff2Smrg elif test -n "$dlname"; then 658067ab2ff2Smrg func_append newdlprefiles " $dir/$dlname" 658167ab2ff2Smrg else 658267ab2ff2Smrg func_append newdlprefiles " $dir/$linklib" 658367ab2ff2Smrg fi 658467ab2ff2Smrg ;; 658567ab2ff2Smrg esac 6586f05b35a2Smrg fi # $pass = dlpreopen 6587f05b35a2Smrg 6588f05b35a2Smrg if test -z "$libdir"; then 6589f05b35a2Smrg # Link the convenience library 6590f05b35a2Smrg if test "$linkmode" = lib; then 6591f05b35a2Smrg deplibs="$dir/$old_library $deplibs" 6592f05b35a2Smrg elif test "$linkmode,$pass" = "prog,link"; then 6593f05b35a2Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 6594f05b35a2Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 6595f05b35a2Smrg else 6596f05b35a2Smrg deplibs="$lib $deplibs" # used for prog,scan pass 6597f05b35a2Smrg fi 6598f05b35a2Smrg continue 6599f05b35a2Smrg fi 6600f05b35a2Smrg 6601f05b35a2Smrg 6602f05b35a2Smrg if test "$linkmode" = prog && test "$pass" != link; then 660367ab2ff2Smrg func_append newlib_search_path " $ladir" 6604f05b35a2Smrg deplibs="$lib $deplibs" 6605f05b35a2Smrg 6606f05b35a2Smrg linkalldeplibs=no 6607f05b35a2Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 6608f05b35a2Smrg test "$build_libtool_libs" = no; then 6609f05b35a2Smrg linkalldeplibs=yes 6610f05b35a2Smrg fi 6611f05b35a2Smrg 6612f05b35a2Smrg tmp_libs= 6613f05b35a2Smrg for deplib in $dependency_libs; do 6614f05b35a2Smrg case $deplib in 6615f05b35a2Smrg -L*) func_stripname '-L' '' "$deplib" 661667ab2ff2Smrg func_resolve_sysroot "$func_stripname_result" 661767ab2ff2Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 6618f05b35a2Smrg ;; 6619f05b35a2Smrg esac 6620f05b35a2Smrg # Need to link against all dependency_libs? 6621f05b35a2Smrg if test "$linkalldeplibs" = yes; then 6622f05b35a2Smrg deplibs="$deplib $deplibs" 6623f05b35a2Smrg else 6624f05b35a2Smrg # Need to hardcode shared library paths 6625f05b35a2Smrg # or/and link against static libraries 6626f05b35a2Smrg newdependency_libs="$deplib $newdependency_libs" 6627f05b35a2Smrg fi 662867ab2ff2Smrg if $opt_preserve_dup_deps ; then 6629f05b35a2Smrg case "$tmp_libs " in 663067ab2ff2Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6631f05b35a2Smrg esac 6632f05b35a2Smrg fi 663367ab2ff2Smrg func_append tmp_libs " $deplib" 6634f05b35a2Smrg done # for deplib 6635f05b35a2Smrg continue 6636f05b35a2Smrg fi # $linkmode = prog... 6637f05b35a2Smrg 6638f05b35a2Smrg if test "$linkmode,$pass" = "prog,link"; then 6639f05b35a2Smrg if test -n "$library_names" && 6640f05b35a2Smrg { { test "$prefer_static_libs" = no || 6641f05b35a2Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 6642f05b35a2Smrg test -z "$old_library"; }; then 6643f05b35a2Smrg # We need to hardcode the library path 6644f05b35a2Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 6645f05b35a2Smrg # Make sure the rpath contains only unique directories. 6646f05b35a2Smrg case "$temp_rpath:" in 6647f05b35a2Smrg *"$absdir:"*) ;; 664867ab2ff2Smrg *) func_append temp_rpath "$absdir:" ;; 6649f05b35a2Smrg esac 6650f05b35a2Smrg fi 6651f05b35a2Smrg 6652f05b35a2Smrg # Hardcode the library path. 6653f05b35a2Smrg # Skip directories that are in the system default run-time 6654f05b35a2Smrg # search path. 6655f05b35a2Smrg case " $sys_lib_dlsearch_path " in 6656f05b35a2Smrg *" $absdir "*) ;; 6657f05b35a2Smrg *) 6658f05b35a2Smrg case "$compile_rpath " in 6659f05b35a2Smrg *" $absdir "*) ;; 666067ab2ff2Smrg *) func_append compile_rpath " $absdir" ;; 6661f05b35a2Smrg esac 6662f05b35a2Smrg ;; 6663f05b35a2Smrg esac 6664f05b35a2Smrg case " $sys_lib_dlsearch_path " in 6665f05b35a2Smrg *" $libdir "*) ;; 6666f05b35a2Smrg *) 6667f05b35a2Smrg case "$finalize_rpath " in 6668f05b35a2Smrg *" $libdir "*) ;; 666967ab2ff2Smrg *) func_append finalize_rpath " $libdir" ;; 6670f05b35a2Smrg esac 6671f05b35a2Smrg ;; 6672f05b35a2Smrg esac 6673f05b35a2Smrg fi # $linkmode,$pass = prog,link... 6674f05b35a2Smrg 6675f05b35a2Smrg if test "$alldeplibs" = yes && 6676f05b35a2Smrg { test "$deplibs_check_method" = pass_all || 6677f05b35a2Smrg { test "$build_libtool_libs" = yes && 6678f05b35a2Smrg test -n "$library_names"; }; }; then 6679f05b35a2Smrg # We only need to search for static libraries 6680f05b35a2Smrg continue 6681f05b35a2Smrg fi 6682f05b35a2Smrg fi 6683f05b35a2Smrg 6684f05b35a2Smrg link_static=no # Whether the deplib will be linked statically 6685f05b35a2Smrg use_static_libs=$prefer_static_libs 6686f05b35a2Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 6687f05b35a2Smrg use_static_libs=no 6688f05b35a2Smrg fi 6689f05b35a2Smrg if test -n "$library_names" && 6690f05b35a2Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 6691f05b35a2Smrg case $host in 6692f05b35a2Smrg *cygwin* | *mingw* | *cegcc*) 6693f05b35a2Smrg # No point in relinking DLLs because paths are not encoded 669467ab2ff2Smrg func_append notinst_deplibs " $lib" 6695f05b35a2Smrg need_relink=no 6696f05b35a2Smrg ;; 6697f05b35a2Smrg *) 6698f05b35a2Smrg if test "$installed" = no; then 669967ab2ff2Smrg func_append notinst_deplibs " $lib" 6700f05b35a2Smrg need_relink=yes 6701f05b35a2Smrg fi 6702f05b35a2Smrg ;; 6703f05b35a2Smrg esac 6704f05b35a2Smrg # This is a shared library 6705f05b35a2Smrg 6706f05b35a2Smrg # Warn about portability, can't link against -module's on some 6707f05b35a2Smrg # systems (darwin). Don't bleat about dlopened modules though! 6708f05b35a2Smrg dlopenmodule="" 6709f05b35a2Smrg for dlpremoduletest in $dlprefiles; do 6710f05b35a2Smrg if test "X$dlpremoduletest" = "X$lib"; then 6711f05b35a2Smrg dlopenmodule="$dlpremoduletest" 6712f05b35a2Smrg break 6713f05b35a2Smrg fi 6714f05b35a2Smrg done 6715f05b35a2Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 671649e108a1Smrg echo 6717f05b35a2Smrg if test "$linkmode" = prog; then 6718f05b35a2Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 6719f05b35a2Smrg else 6720f05b35a2Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 6721f05b35a2Smrg fi 6722f05b35a2Smrg $ECHO "*** $linklib is not portable!" 6723f05b35a2Smrg fi 6724f05b35a2Smrg if test "$linkmode" = lib && 6725f05b35a2Smrg test "$hardcode_into_libs" = yes; then 6726f05b35a2Smrg # Hardcode the library path. 6727f05b35a2Smrg # Skip directories that are in the system default run-time 6728f05b35a2Smrg # search path. 6729f05b35a2Smrg case " $sys_lib_dlsearch_path " in 6730f05b35a2Smrg *" $absdir "*) ;; 6731f05b35a2Smrg *) 6732f05b35a2Smrg case "$compile_rpath " in 6733f05b35a2Smrg *" $absdir "*) ;; 673467ab2ff2Smrg *) func_append compile_rpath " $absdir" ;; 6735f05b35a2Smrg esac 6736f05b35a2Smrg ;; 6737f05b35a2Smrg esac 6738f05b35a2Smrg case " $sys_lib_dlsearch_path " in 6739f05b35a2Smrg *" $libdir "*) ;; 6740f05b35a2Smrg *) 6741f05b35a2Smrg case "$finalize_rpath " in 6742f05b35a2Smrg *" $libdir "*) ;; 674367ab2ff2Smrg *) func_append finalize_rpath " $libdir" ;; 6744f05b35a2Smrg esac 6745f05b35a2Smrg ;; 6746f05b35a2Smrg esac 6747f05b35a2Smrg fi 6748f05b35a2Smrg 6749f05b35a2Smrg if test -n "$old_archive_from_expsyms_cmds"; then 6750f05b35a2Smrg # figure out the soname 6751f05b35a2Smrg set dummy $library_names 6752f05b35a2Smrg shift 6753f05b35a2Smrg realname="$1" 6754f05b35a2Smrg shift 6755f05b35a2Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 6756f05b35a2Smrg # use dlname if we got it. it's perfectly good, no? 6757f05b35a2Smrg if test -n "$dlname"; then 6758f05b35a2Smrg soname="$dlname" 6759f05b35a2Smrg elif test -n "$soname_spec"; then 6760f05b35a2Smrg # bleh windows 6761f05b35a2Smrg case $host in 6762f05b35a2Smrg *cygwin* | mingw* | *cegcc*) 6763f05b35a2Smrg func_arith $current - $age 6764f05b35a2Smrg major=$func_arith_result 6765f05b35a2Smrg versuffix="-$major" 6766f05b35a2Smrg ;; 6767f05b35a2Smrg esac 6768f05b35a2Smrg eval soname=\"$soname_spec\" 6769f05b35a2Smrg else 6770f05b35a2Smrg soname="$realname" 6771f05b35a2Smrg fi 6772f05b35a2Smrg 6773f05b35a2Smrg # Make a new name for the extract_expsyms_cmds to use 6774f05b35a2Smrg soroot="$soname" 6775f05b35a2Smrg func_basename "$soroot" 6776f05b35a2Smrg soname="$func_basename_result" 6777f05b35a2Smrg func_stripname 'lib' '.dll' "$soname" 6778f05b35a2Smrg newlib=libimp-$func_stripname_result.a 6779f05b35a2Smrg 6780f05b35a2Smrg # If the library has no export list, then create one now 6781f05b35a2Smrg if test -f "$output_objdir/$soname-def"; then : 6782f05b35a2Smrg else 6783f05b35a2Smrg func_verbose "extracting exported symbol list from \`$soname'" 6784f05b35a2Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 6785f05b35a2Smrg fi 6786f05b35a2Smrg 6787f05b35a2Smrg # Create $newlib 6788f05b35a2Smrg if test -f "$output_objdir/$newlib"; then :; else 6789f05b35a2Smrg func_verbose "generating import library for \`$soname'" 6790f05b35a2Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 6791f05b35a2Smrg fi 6792f05b35a2Smrg # make sure the library variables are pointing to the new library 6793f05b35a2Smrg dir=$output_objdir 6794f05b35a2Smrg linklib=$newlib 6795f05b35a2Smrg fi # test -n "$old_archive_from_expsyms_cmds" 6796f05b35a2Smrg 679767ab2ff2Smrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 6798f05b35a2Smrg add_shlibpath= 6799f05b35a2Smrg add_dir= 6800f05b35a2Smrg add= 6801f05b35a2Smrg lib_linked=yes 6802f05b35a2Smrg case $hardcode_action in 6803f05b35a2Smrg immediate | unsupported) 6804f05b35a2Smrg if test "$hardcode_direct" = no; then 6805f05b35a2Smrg add="$dir/$linklib" 6806f05b35a2Smrg case $host in 6807f05b35a2Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 6808f05b35a2Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 6809f05b35a2Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 6810f05b35a2Smrg *-*-unixware7*) add_dir="-L$dir" ;; 6811f05b35a2Smrg *-*-darwin* ) 6812f05b35a2Smrg # if the lib is a (non-dlopened) module then we can not 6813f05b35a2Smrg # link against it, someone is ignoring the earlier warnings 6814f05b35a2Smrg if /usr/bin/file -L $add 2> /dev/null | 6815f05b35a2Smrg $GREP ": [^:]* bundle" >/dev/null ; then 6816f05b35a2Smrg if test "X$dlopenmodule" != "X$lib"; then 6817f05b35a2Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 6818f05b35a2Smrg if test -z "$old_library" ; then 681949e108a1Smrg echo 682049e108a1Smrg echo "*** And there doesn't seem to be a static archive available" 682149e108a1Smrg echo "*** The link will probably fail, sorry" 6822f05b35a2Smrg else 6823f05b35a2Smrg add="$dir/$old_library" 6824f05b35a2Smrg fi 6825f05b35a2Smrg elif test -n "$old_library"; then 6826f05b35a2Smrg add="$dir/$old_library" 6827f05b35a2Smrg fi 6828f05b35a2Smrg fi 6829f05b35a2Smrg esac 6830f05b35a2Smrg elif test "$hardcode_minus_L" = no; then 6831f05b35a2Smrg case $host in 6832f05b35a2Smrg *-*-sunos*) add_shlibpath="$dir" ;; 6833f05b35a2Smrg esac 6834f05b35a2Smrg add_dir="-L$dir" 6835f05b35a2Smrg add="-l$name" 6836f05b35a2Smrg elif test "$hardcode_shlibpath_var" = no; then 6837f05b35a2Smrg add_shlibpath="$dir" 6838f05b35a2Smrg add="-l$name" 6839f05b35a2Smrg else 6840f05b35a2Smrg lib_linked=no 6841f05b35a2Smrg fi 6842f05b35a2Smrg ;; 6843f05b35a2Smrg relink) 6844f05b35a2Smrg if test "$hardcode_direct" = yes && 6845f05b35a2Smrg test "$hardcode_direct_absolute" = no; then 6846f05b35a2Smrg add="$dir/$linklib" 6847f05b35a2Smrg elif test "$hardcode_minus_L" = yes; then 6848e494fffdSmrg add_dir="-L$absdir" 6849f05b35a2Smrg # Try looking first in the location we're being installed to. 6850f05b35a2Smrg if test -n "$inst_prefix_dir"; then 6851f05b35a2Smrg case $libdir in 6852f05b35a2Smrg [\\/]*) 685367ab2ff2Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 6854f05b35a2Smrg ;; 6855f05b35a2Smrg esac 6856f05b35a2Smrg fi 6857f05b35a2Smrg add="-l$name" 6858f05b35a2Smrg elif test "$hardcode_shlibpath_var" = yes; then 6859f05b35a2Smrg add_shlibpath="$dir" 6860f05b35a2Smrg add="-l$name" 6861f05b35a2Smrg else 6862f05b35a2Smrg lib_linked=no 6863f05b35a2Smrg fi 6864f05b35a2Smrg ;; 6865f05b35a2Smrg *) lib_linked=no ;; 6866f05b35a2Smrg esac 6867f05b35a2Smrg 6868f05b35a2Smrg if test "$lib_linked" != yes; then 6869f05b35a2Smrg func_fatal_configuration "unsupported hardcode properties" 6870f05b35a2Smrg fi 6871f05b35a2Smrg 6872f05b35a2Smrg if test -n "$add_shlibpath"; then 6873f05b35a2Smrg case :$compile_shlibpath: in 6874f05b35a2Smrg *":$add_shlibpath:"*) ;; 687567ab2ff2Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 6876f05b35a2Smrg esac 6877f05b35a2Smrg fi 6878f05b35a2Smrg if test "$linkmode" = prog; then 6879f05b35a2Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 6880f05b35a2Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 6881f05b35a2Smrg else 6882f05b35a2Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 6883f05b35a2Smrg test -n "$add" && deplibs="$add $deplibs" 6884f05b35a2Smrg if test "$hardcode_direct" != yes && 6885f05b35a2Smrg test "$hardcode_minus_L" != yes && 6886f05b35a2Smrg test "$hardcode_shlibpath_var" = yes; then 6887f05b35a2Smrg case :$finalize_shlibpath: in 6888f05b35a2Smrg *":$libdir:"*) ;; 688967ab2ff2Smrg *) func_append finalize_shlibpath "$libdir:" ;; 6890f05b35a2Smrg esac 6891f05b35a2Smrg fi 6892f05b35a2Smrg fi 6893f05b35a2Smrg fi 6894f05b35a2Smrg 689567ab2ff2Smrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 6896f05b35a2Smrg add_shlibpath= 6897f05b35a2Smrg add_dir= 6898f05b35a2Smrg add= 6899f05b35a2Smrg # Finalize command for both is simple: just hardcode it. 6900f05b35a2Smrg if test "$hardcode_direct" = yes && 6901f05b35a2Smrg test "$hardcode_direct_absolute" = no; then 6902f05b35a2Smrg add="$libdir/$linklib" 6903f05b35a2Smrg elif test "$hardcode_minus_L" = yes; then 6904f05b35a2Smrg add_dir="-L$libdir" 6905f05b35a2Smrg add="-l$name" 6906f05b35a2Smrg elif test "$hardcode_shlibpath_var" = yes; then 6907f05b35a2Smrg case :$finalize_shlibpath: in 6908f05b35a2Smrg *":$libdir:"*) ;; 690967ab2ff2Smrg *) func_append finalize_shlibpath "$libdir:" ;; 6910f05b35a2Smrg esac 6911f05b35a2Smrg add="-l$name" 6912f05b35a2Smrg elif test "$hardcode_automatic" = yes; then 6913f05b35a2Smrg if test -n "$inst_prefix_dir" && 6914f05b35a2Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 6915f05b35a2Smrg add="$inst_prefix_dir$libdir/$linklib" 6916f05b35a2Smrg else 6917f05b35a2Smrg add="$libdir/$linklib" 6918f05b35a2Smrg fi 6919f05b35a2Smrg else 6920f05b35a2Smrg # We cannot seem to hardcode it, guess we'll fake it. 6921f05b35a2Smrg add_dir="-L$libdir" 6922f05b35a2Smrg # Try looking first in the location we're being installed to. 6923f05b35a2Smrg if test -n "$inst_prefix_dir"; then 6924f05b35a2Smrg case $libdir in 6925f05b35a2Smrg [\\/]*) 692667ab2ff2Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 6927f05b35a2Smrg ;; 6928f05b35a2Smrg esac 6929f05b35a2Smrg fi 6930f05b35a2Smrg add="-l$name" 6931f05b35a2Smrg fi 6932f05b35a2Smrg 6933f05b35a2Smrg if test "$linkmode" = prog; then 6934f05b35a2Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 6935f05b35a2Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 6936f05b35a2Smrg else 6937f05b35a2Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 6938f05b35a2Smrg test -n "$add" && deplibs="$add $deplibs" 6939f05b35a2Smrg fi 6940f05b35a2Smrg fi 6941f05b35a2Smrg elif test "$linkmode" = prog; then 6942f05b35a2Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 6943f05b35a2Smrg # is not unsupported. This is valid on all known static and 6944f05b35a2Smrg # shared platforms. 6945f05b35a2Smrg if test "$hardcode_direct" != unsupported; then 6946f05b35a2Smrg test -n "$old_library" && linklib="$old_library" 6947f05b35a2Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 6948f05b35a2Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 6949f05b35a2Smrg else 6950f05b35a2Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 6951f05b35a2Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 6952f05b35a2Smrg fi 6953f05b35a2Smrg elif test "$build_libtool_libs" = yes; then 6954f05b35a2Smrg # Not a shared library 6955f05b35a2Smrg if test "$deplibs_check_method" != pass_all; then 6956f05b35a2Smrg # We're trying link a shared library against a static one 6957f05b35a2Smrg # but the system doesn't support it. 6958f05b35a2Smrg 6959f05b35a2Smrg # Just print a warning and add the library to dependency_libs so 6960f05b35a2Smrg # that the program can be linked against the static library. 696149e108a1Smrg echo 6962f05b35a2Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 696349e108a1Smrg echo "*** I have the capability to make that library automatically link in when" 696449e108a1Smrg echo "*** you link to this library. But I can only do this if you have a" 696549e108a1Smrg echo "*** shared version of the library, which you do not appear to have." 6966f05b35a2Smrg if test "$module" = yes; then 696749e108a1Smrg echo "*** But as you try to build a module library, libtool will still create " 696849e108a1Smrg echo "*** a static module, that should work as long as the dlopening application" 696949e108a1Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 6970f05b35a2Smrg if test -z "$global_symbol_pipe"; then 697149e108a1Smrg echo 697249e108a1Smrg echo "*** However, this would only work if libtool was able to extract symbol" 697349e108a1Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 697449e108a1Smrg echo "*** not find such a program. So, this module is probably useless." 697549e108a1Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 6976f05b35a2Smrg fi 6977f05b35a2Smrg if test "$build_old_libs" = no; then 6978f05b35a2Smrg build_libtool_libs=module 6979f05b35a2Smrg build_old_libs=yes 6980f05b35a2Smrg else 6981f05b35a2Smrg build_libtool_libs=no 6982f05b35a2Smrg fi 6983f05b35a2Smrg fi 6984f05b35a2Smrg else 6985f05b35a2Smrg deplibs="$dir/$old_library $deplibs" 6986f05b35a2Smrg link_static=yes 6987f05b35a2Smrg fi 6988f05b35a2Smrg fi # link shared/static library? 6989f05b35a2Smrg 6990f05b35a2Smrg if test "$linkmode" = lib; then 6991f05b35a2Smrg if test -n "$dependency_libs" && 6992f05b35a2Smrg { test "$hardcode_into_libs" != yes || 6993f05b35a2Smrg test "$build_old_libs" = yes || 6994f05b35a2Smrg test "$link_static" = yes; }; then 6995f05b35a2Smrg # Extract -R from dependency_libs 6996f05b35a2Smrg temp_deplibs= 6997f05b35a2Smrg for libdir in $dependency_libs; do 6998f05b35a2Smrg case $libdir in 6999f05b35a2Smrg -R*) func_stripname '-R' '' "$libdir" 7000f05b35a2Smrg temp_xrpath=$func_stripname_result 7001f05b35a2Smrg case " $xrpath " in 7002f05b35a2Smrg *" $temp_xrpath "*) ;; 700367ab2ff2Smrg *) func_append xrpath " $temp_xrpath";; 7004f05b35a2Smrg esac;; 700567ab2ff2Smrg *) func_append temp_deplibs " $libdir";; 7006f05b35a2Smrg esac 7007f05b35a2Smrg done 7008f05b35a2Smrg dependency_libs="$temp_deplibs" 7009f05b35a2Smrg fi 7010f05b35a2Smrg 701167ab2ff2Smrg func_append newlib_search_path " $absdir" 7012f05b35a2Smrg # Link against this library 7013f05b35a2Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 7014f05b35a2Smrg # ... and its dependency_libs 7015f05b35a2Smrg tmp_libs= 7016f05b35a2Smrg for deplib in $dependency_libs; do 7017f05b35a2Smrg newdependency_libs="$deplib $newdependency_libs" 701867ab2ff2Smrg case $deplib in 701967ab2ff2Smrg -L*) func_stripname '-L' '' "$deplib" 702067ab2ff2Smrg func_resolve_sysroot "$func_stripname_result";; 702167ab2ff2Smrg *) func_resolve_sysroot "$deplib" ;; 702267ab2ff2Smrg esac 702367ab2ff2Smrg if $opt_preserve_dup_deps ; then 7024f05b35a2Smrg case "$tmp_libs " in 702567ab2ff2Smrg *" $func_resolve_sysroot_result "*) 702667ab2ff2Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 7027f05b35a2Smrg esac 7028f05b35a2Smrg fi 702967ab2ff2Smrg func_append tmp_libs " $func_resolve_sysroot_result" 7030f05b35a2Smrg done 7031f05b35a2Smrg 7032f05b35a2Smrg if test "$link_all_deplibs" != no; then 7033f05b35a2Smrg # Add the search paths of all dependency libraries 7034f05b35a2Smrg for deplib in $dependency_libs; do 703549e108a1Smrg path= 7036f05b35a2Smrg case $deplib in 7037f05b35a2Smrg -L*) path="$deplib" ;; 7038f05b35a2Smrg *.la) 703967ab2ff2Smrg func_resolve_sysroot "$deplib" 704067ab2ff2Smrg deplib=$func_resolve_sysroot_result 7041f05b35a2Smrg func_dirname "$deplib" "" "." 704267ab2ff2Smrg dir=$func_dirname_result 7043f05b35a2Smrg # We need an absolute path. 7044f05b35a2Smrg case $dir in 7045f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 7046f05b35a2Smrg *) 7047f05b35a2Smrg absdir=`cd "$dir" && pwd` 7048f05b35a2Smrg if test -z "$absdir"; then 7049f05b35a2Smrg func_warning "cannot determine absolute directory name of \`$dir'" 7050f05b35a2Smrg absdir="$dir" 7051f05b35a2Smrg fi 7052f05b35a2Smrg ;; 7053f05b35a2Smrg esac 7054f05b35a2Smrg if $GREP "^installed=no" $deplib > /dev/null; then 7055f05b35a2Smrg case $host in 7056f05b35a2Smrg *-*-darwin*) 7057f05b35a2Smrg depdepl= 7058f05b35a2Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 7059f05b35a2Smrg if test -n "$deplibrary_names" ; then 7060f05b35a2Smrg for tmp in $deplibrary_names ; do 7061f05b35a2Smrg depdepl=$tmp 7062f05b35a2Smrg done 7063f05b35a2Smrg if test -f "$absdir/$objdir/$depdepl" ; then 7064f05b35a2Smrg depdepl="$absdir/$objdir/$depdepl" 7065f05b35a2Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7066f05b35a2Smrg if test -z "$darwin_install_name"; then 7067f05b35a2Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7068f05b35a2Smrg fi 706967ab2ff2Smrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 707067ab2ff2Smrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 7071f05b35a2Smrg path= 7072f05b35a2Smrg fi 7073f05b35a2Smrg fi 7074f05b35a2Smrg ;; 7075f05b35a2Smrg *) 7076f05b35a2Smrg path="-L$absdir/$objdir" 7077f05b35a2Smrg ;; 7078f05b35a2Smrg esac 7079f05b35a2Smrg else 7080f05b35a2Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 7081f05b35a2Smrg test -z "$libdir" && \ 7082f05b35a2Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 7083f05b35a2Smrg test "$absdir" != "$libdir" && \ 7084f05b35a2Smrg func_warning "\`$deplib' seems to be moved" 7085f05b35a2Smrg 7086f05b35a2Smrg path="-L$absdir" 7087f05b35a2Smrg fi 7088f05b35a2Smrg ;; 7089f05b35a2Smrg esac 7090f05b35a2Smrg case " $deplibs " in 7091f05b35a2Smrg *" $path "*) ;; 7092f05b35a2Smrg *) deplibs="$path $deplibs" ;; 7093f05b35a2Smrg esac 7094f05b35a2Smrg done 7095f05b35a2Smrg fi # link_all_deplibs != no 7096f05b35a2Smrg fi # linkmode = lib 7097f05b35a2Smrg done # for deplib in $libs 7098f05b35a2Smrg if test "$pass" = link; then 7099f05b35a2Smrg if test "$linkmode" = "prog"; then 7100f05b35a2Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 7101f05b35a2Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 7102f05b35a2Smrg else 710349e108a1Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7104f05b35a2Smrg fi 7105f05b35a2Smrg fi 7106f05b35a2Smrg dependency_libs="$newdependency_libs" 7107f05b35a2Smrg if test "$pass" = dlpreopen; then 7108f05b35a2Smrg # Link the dlpreopened libraries before other libraries 7109f05b35a2Smrg for deplib in $save_deplibs; do 7110f05b35a2Smrg deplibs="$deplib $deplibs" 7111f05b35a2Smrg done 7112f05b35a2Smrg fi 7113f05b35a2Smrg if test "$pass" != dlopen; then 7114f05b35a2Smrg if test "$pass" != conv; then 7115f05b35a2Smrg # Make sure lib_search_path contains only unique directories. 7116f05b35a2Smrg lib_search_path= 7117f05b35a2Smrg for dir in $newlib_search_path; do 7118f05b35a2Smrg case "$lib_search_path " in 7119f05b35a2Smrg *" $dir "*) ;; 712067ab2ff2Smrg *) func_append lib_search_path " $dir" ;; 7121f05b35a2Smrg esac 7122f05b35a2Smrg done 7123f05b35a2Smrg newlib_search_path= 7124f05b35a2Smrg fi 7125f05b35a2Smrg 7126f05b35a2Smrg if test "$linkmode,$pass" != "prog,link"; then 7127f05b35a2Smrg vars="deplibs" 7128f05b35a2Smrg else 7129f05b35a2Smrg vars="compile_deplibs finalize_deplibs" 7130f05b35a2Smrg fi 7131f05b35a2Smrg for var in $vars dependency_libs; do 7132f05b35a2Smrg # Add libraries to $var in reverse order 7133f05b35a2Smrg eval tmp_libs=\"\$$var\" 7134f05b35a2Smrg new_libs= 7135f05b35a2Smrg for deplib in $tmp_libs; do 7136f05b35a2Smrg # FIXME: Pedantically, this is the right thing to do, so 7137f05b35a2Smrg # that some nasty dependency loop isn't accidentally 7138f05b35a2Smrg # broken: 7139f05b35a2Smrg #new_libs="$deplib $new_libs" 7140f05b35a2Smrg # Pragmatically, this seems to cause very few problems in 7141f05b35a2Smrg # practice: 7142f05b35a2Smrg case $deplib in 7143f05b35a2Smrg -L*) new_libs="$deplib $new_libs" ;; 7144f05b35a2Smrg -R*) ;; 7145f05b35a2Smrg *) 7146f05b35a2Smrg # And here is the reason: when a library appears more 7147f05b35a2Smrg # than once as an explicit dependence of a library, or 7148f05b35a2Smrg # is implicitly linked in more than once by the 7149f05b35a2Smrg # compiler, it is considered special, and multiple 7150f05b35a2Smrg # occurrences thereof are not removed. Compare this 7151f05b35a2Smrg # with having the same library being listed as a 7152f05b35a2Smrg # dependency of multiple other libraries: in this case, 7153f05b35a2Smrg # we know (pedantically, we assume) the library does not 7154f05b35a2Smrg # need to be listed more than once, so we keep only the 7155f05b35a2Smrg # last copy. This is not always right, but it is rare 7156f05b35a2Smrg # enough that we require users that really mean to play 7157f05b35a2Smrg # such unportable linking tricks to link the library 7158f05b35a2Smrg # using -Wl,-lname, so that libtool does not consider it 7159f05b35a2Smrg # for duplicate removal. 7160f05b35a2Smrg case " $specialdeplibs " in 7161f05b35a2Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 7162f05b35a2Smrg *) 7163f05b35a2Smrg case " $new_libs " in 7164f05b35a2Smrg *" $deplib "*) ;; 7165f05b35a2Smrg *) new_libs="$deplib $new_libs" ;; 7166f05b35a2Smrg esac 7167f05b35a2Smrg ;; 7168f05b35a2Smrg esac 7169f05b35a2Smrg ;; 7170f05b35a2Smrg esac 7171f05b35a2Smrg done 7172f05b35a2Smrg tmp_libs= 7173f05b35a2Smrg for deplib in $new_libs; do 7174f05b35a2Smrg case $deplib in 7175f05b35a2Smrg -L*) 7176f05b35a2Smrg case " $tmp_libs " in 7177f05b35a2Smrg *" $deplib "*) ;; 717867ab2ff2Smrg *) func_append tmp_libs " $deplib" ;; 7179f05b35a2Smrg esac 7180f05b35a2Smrg ;; 718167ab2ff2Smrg *) func_append tmp_libs " $deplib" ;; 7182f05b35a2Smrg esac 7183f05b35a2Smrg done 7184f05b35a2Smrg eval $var=\"$tmp_libs\" 7185f05b35a2Smrg done # for var 7186f05b35a2Smrg fi 7187f05b35a2Smrg # Last step: remove runtime libs from dependency_libs 7188f05b35a2Smrg # (they stay in deplibs) 7189f05b35a2Smrg tmp_libs= 7190f05b35a2Smrg for i in $dependency_libs ; do 7191f05b35a2Smrg case " $predeps $postdeps $compiler_lib_search_path " in 7192f05b35a2Smrg *" $i "*) 7193f05b35a2Smrg i="" 7194f05b35a2Smrg ;; 7195f05b35a2Smrg esac 7196f05b35a2Smrg if test -n "$i" ; then 719767ab2ff2Smrg func_append tmp_libs " $i" 7198f05b35a2Smrg fi 7199f05b35a2Smrg done 7200f05b35a2Smrg dependency_libs=$tmp_libs 7201f05b35a2Smrg done # for pass 7202f05b35a2Smrg if test "$linkmode" = prog; then 7203f05b35a2Smrg dlfiles="$newdlfiles" 7204f05b35a2Smrg fi 7205f05b35a2Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 7206f05b35a2Smrg dlprefiles="$newdlprefiles" 7207f05b35a2Smrg fi 7208f05b35a2Smrg 7209f05b35a2Smrg case $linkmode in 7210f05b35a2Smrg oldlib) 7211f05b35a2Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 7212f05b35a2Smrg func_warning "\`-dlopen' is ignored for archives" 7213f05b35a2Smrg fi 7214f05b35a2Smrg 7215f05b35a2Smrg case " $deplibs" in 7216f05b35a2Smrg *\ -l* | *\ -L*) 7217f05b35a2Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 7218f05b35a2Smrg esac 7219f05b35a2Smrg 7220f05b35a2Smrg test -n "$rpath" && \ 7221f05b35a2Smrg func_warning "\`-rpath' is ignored for archives" 7222f05b35a2Smrg 7223f05b35a2Smrg test -n "$xrpath" && \ 7224f05b35a2Smrg func_warning "\`-R' is ignored for archives" 7225f05b35a2Smrg 7226f05b35a2Smrg test -n "$vinfo" && \ 7227f05b35a2Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 7228f05b35a2Smrg 7229f05b35a2Smrg test -n "$release" && \ 7230f05b35a2Smrg func_warning "\`-release' is ignored for archives" 7231f05b35a2Smrg 7232f05b35a2Smrg test -n "$export_symbols$export_symbols_regex" && \ 7233f05b35a2Smrg func_warning "\`-export-symbols' is ignored for archives" 7234f05b35a2Smrg 7235f05b35a2Smrg # Now set the variables for building old libraries. 7236f05b35a2Smrg build_libtool_libs=no 7237f05b35a2Smrg oldlibs="$output" 723867ab2ff2Smrg func_append objs "$old_deplibs" 7239f05b35a2Smrg ;; 7240f05b35a2Smrg 7241f05b35a2Smrg lib) 7242f05b35a2Smrg # Make sure we only generate libraries of the form `libNAME.la'. 7243f05b35a2Smrg case $outputname in 7244f05b35a2Smrg lib*) 7245f05b35a2Smrg func_stripname 'lib' '.la' "$outputname" 7246f05b35a2Smrg name=$func_stripname_result 7247f05b35a2Smrg eval shared_ext=\"$shrext_cmds\" 7248f05b35a2Smrg eval libname=\"$libname_spec\" 7249f05b35a2Smrg ;; 7250f05b35a2Smrg *) 7251f05b35a2Smrg test "$module" = no && \ 7252f05b35a2Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 7253f05b35a2Smrg 7254f05b35a2Smrg if test "$need_lib_prefix" != no; then 7255f05b35a2Smrg # Add the "lib" prefix for modules if required 7256f05b35a2Smrg func_stripname '' '.la' "$outputname" 7257f05b35a2Smrg name=$func_stripname_result 7258f05b35a2Smrg eval shared_ext=\"$shrext_cmds\" 7259f05b35a2Smrg eval libname=\"$libname_spec\" 7260f05b35a2Smrg else 7261f05b35a2Smrg func_stripname '' '.la' "$outputname" 7262f05b35a2Smrg libname=$func_stripname_result 7263f05b35a2Smrg fi 7264f05b35a2Smrg ;; 7265f05b35a2Smrg esac 7266f05b35a2Smrg 7267f05b35a2Smrg if test -n "$objs"; then 7268f05b35a2Smrg if test "$deplibs_check_method" != pass_all; then 7269f05b35a2Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 7270f05b35a2Smrg else 727149e108a1Smrg echo 7272f05b35a2Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 7273f05b35a2Smrg $ECHO "*** objects $objs is not portable!" 727467ab2ff2Smrg func_append libobjs " $objs" 7275f05b35a2Smrg fi 7276f05b35a2Smrg fi 7277f05b35a2Smrg 7278f05b35a2Smrg test "$dlself" != no && \ 7279f05b35a2Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 7280f05b35a2Smrg 7281f05b35a2Smrg set dummy $rpath 7282f05b35a2Smrg shift 7283f05b35a2Smrg test "$#" -gt 1 && \ 7284f05b35a2Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 7285f05b35a2Smrg 7286f05b35a2Smrg install_libdir="$1" 7287f05b35a2Smrg 7288f05b35a2Smrg oldlibs= 7289f05b35a2Smrg if test -z "$rpath"; then 7290f05b35a2Smrg if test "$build_libtool_libs" = yes; then 7291f05b35a2Smrg # Building a libtool convenience library. 7292f05b35a2Smrg # Some compilers have problems with a `.al' extension so 7293f05b35a2Smrg # convenience libraries should have the same extension an 7294f05b35a2Smrg # archive normally would. 7295f05b35a2Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 7296f05b35a2Smrg build_libtool_libs=convenience 7297f05b35a2Smrg build_old_libs=yes 7298f05b35a2Smrg fi 7299f05b35a2Smrg 7300f05b35a2Smrg test -n "$vinfo" && \ 7301f05b35a2Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 7302f05b35a2Smrg 7303f05b35a2Smrg test -n "$release" && \ 7304f05b35a2Smrg func_warning "\`-release' is ignored for convenience libraries" 7305f05b35a2Smrg else 7306f05b35a2Smrg 7307f05b35a2Smrg # Parse the version information argument. 7308f05b35a2Smrg save_ifs="$IFS"; IFS=':' 7309f05b35a2Smrg set dummy $vinfo 0 0 0 7310f05b35a2Smrg shift 7311f05b35a2Smrg IFS="$save_ifs" 7312f05b35a2Smrg 7313f05b35a2Smrg test -n "$7" && \ 7314f05b35a2Smrg func_fatal_help "too many parameters to \`-version-info'" 7315f05b35a2Smrg 7316f05b35a2Smrg # convert absolute version numbers to libtool ages 7317f05b35a2Smrg # this retains compatibility with .la files and attempts 7318f05b35a2Smrg # to make the code below a bit more comprehensible 7319f05b35a2Smrg 7320f05b35a2Smrg case $vinfo_number in 7321f05b35a2Smrg yes) 7322f05b35a2Smrg number_major="$1" 7323f05b35a2Smrg number_minor="$2" 7324f05b35a2Smrg number_revision="$3" 7325f05b35a2Smrg # 7326f05b35a2Smrg # There are really only two kinds -- those that 7327f05b35a2Smrg # use the current revision as the major version 7328f05b35a2Smrg # and those that subtract age and use age as 7329f05b35a2Smrg # a minor version. But, then there is irix 7330f05b35a2Smrg # which has an extra 1 added just for fun 7331f05b35a2Smrg # 7332f05b35a2Smrg case $version_type in 7333e494fffdSmrg # correct linux to gnu/linux during the next big refactor 7334f05b35a2Smrg darwin|linux|osf|windows|none) 7335f05b35a2Smrg func_arith $number_major + $number_minor 7336f05b35a2Smrg current=$func_arith_result 7337f05b35a2Smrg age="$number_minor" 7338f05b35a2Smrg revision="$number_revision" 7339f05b35a2Smrg ;; 734049e108a1Smrg freebsd-aout|freebsd-elf|qnx|sunos) 7341f05b35a2Smrg current="$number_major" 7342f05b35a2Smrg revision="$number_minor" 7343f05b35a2Smrg age="0" 7344f05b35a2Smrg ;; 7345f05b35a2Smrg irix|nonstopux) 7346f05b35a2Smrg func_arith $number_major + $number_minor 7347f05b35a2Smrg current=$func_arith_result 7348f05b35a2Smrg age="$number_minor" 7349f05b35a2Smrg revision="$number_minor" 7350f05b35a2Smrg lt_irix_increment=no 7351f05b35a2Smrg ;; 7352f05b35a2Smrg esac 7353f05b35a2Smrg ;; 7354f05b35a2Smrg no) 7355f05b35a2Smrg current="$1" 7356f05b35a2Smrg revision="$2" 7357f05b35a2Smrg age="$3" 7358f05b35a2Smrg ;; 7359f05b35a2Smrg esac 7360f05b35a2Smrg 7361f05b35a2Smrg # Check that each of the things are valid numbers. 7362f05b35a2Smrg case $current in 7363f05b35a2Smrg 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]) ;; 7364f05b35a2Smrg *) 7365f05b35a2Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 7366f05b35a2Smrg func_fatal_error "\`$vinfo' is not valid version information" 7367f05b35a2Smrg ;; 7368f05b35a2Smrg esac 7369f05b35a2Smrg 7370f05b35a2Smrg case $revision in 7371f05b35a2Smrg 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]) ;; 7372f05b35a2Smrg *) 7373f05b35a2Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 7374f05b35a2Smrg func_fatal_error "\`$vinfo' is not valid version information" 7375f05b35a2Smrg ;; 7376f05b35a2Smrg esac 7377f05b35a2Smrg 7378f05b35a2Smrg case $age in 7379f05b35a2Smrg 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]) ;; 7380f05b35a2Smrg *) 7381f05b35a2Smrg func_error "AGE \`$age' must be a nonnegative integer" 7382f05b35a2Smrg func_fatal_error "\`$vinfo' is not valid version information" 7383f05b35a2Smrg ;; 7384f05b35a2Smrg esac 7385f05b35a2Smrg 7386f05b35a2Smrg if test "$age" -gt "$current"; then 7387f05b35a2Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 7388f05b35a2Smrg func_fatal_error "\`$vinfo' is not valid version information" 7389f05b35a2Smrg fi 7390f05b35a2Smrg 7391f05b35a2Smrg # Calculate the version variables. 7392f05b35a2Smrg major= 7393f05b35a2Smrg versuffix= 7394f05b35a2Smrg verstring= 7395f05b35a2Smrg case $version_type in 7396f05b35a2Smrg none) ;; 7397f05b35a2Smrg 7398f05b35a2Smrg darwin) 7399f05b35a2Smrg # Like Linux, but with the current version available in 7400f05b35a2Smrg # verstring for coding it into the library header 7401f05b35a2Smrg func_arith $current - $age 7402f05b35a2Smrg major=.$func_arith_result 7403f05b35a2Smrg versuffix="$major.$age.$revision" 7404f05b35a2Smrg # Darwin ld doesn't like 0 for these options... 7405f05b35a2Smrg func_arith $current + 1 7406f05b35a2Smrg minor_current=$func_arith_result 7407f05b35a2Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 7408f05b35a2Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 7409f05b35a2Smrg ;; 7410f05b35a2Smrg 7411f05b35a2Smrg freebsd-aout) 7412f05b35a2Smrg major=".$current" 7413f05b35a2Smrg versuffix=".$current.$revision"; 7414f05b35a2Smrg ;; 7415f05b35a2Smrg 7416f05b35a2Smrg freebsd-elf) 7417f05b35a2Smrg major=".$current" 7418f05b35a2Smrg versuffix=".$current" 7419f05b35a2Smrg ;; 7420f05b35a2Smrg 7421f05b35a2Smrg irix | nonstopux) 7422f05b35a2Smrg if test "X$lt_irix_increment" = "Xno"; then 7423f05b35a2Smrg func_arith $current - $age 7424f05b35a2Smrg else 7425f05b35a2Smrg func_arith $current - $age + 1 7426f05b35a2Smrg fi 7427f05b35a2Smrg major=$func_arith_result 7428f05b35a2Smrg 7429f05b35a2Smrg case $version_type in 7430f05b35a2Smrg nonstopux) verstring_prefix=nonstopux ;; 7431f05b35a2Smrg *) verstring_prefix=sgi ;; 7432f05b35a2Smrg esac 7433f05b35a2Smrg verstring="$verstring_prefix$major.$revision" 7434f05b35a2Smrg 7435f05b35a2Smrg # Add in all the interfaces that we are compatible with. 7436f05b35a2Smrg loop=$revision 7437f05b35a2Smrg while test "$loop" -ne 0; do 7438f05b35a2Smrg func_arith $revision - $loop 7439f05b35a2Smrg iface=$func_arith_result 7440f05b35a2Smrg func_arith $loop - 1 7441f05b35a2Smrg loop=$func_arith_result 7442f05b35a2Smrg verstring="$verstring_prefix$major.$iface:$verstring" 7443f05b35a2Smrg done 7444f05b35a2Smrg 7445f05b35a2Smrg # Before this point, $major must not contain `.'. 7446f05b35a2Smrg major=.$major 7447f05b35a2Smrg versuffix="$major.$revision" 7448f05b35a2Smrg ;; 7449f05b35a2Smrg 7450e494fffdSmrg linux) # correct to gnu/linux during the next big refactor 7451f05b35a2Smrg func_arith $current - $age 7452f05b35a2Smrg major=.$func_arith_result 7453f05b35a2Smrg versuffix="$major.$age.$revision" 7454f05b35a2Smrg ;; 7455f05b35a2Smrg 7456f05b35a2Smrg osf) 7457f05b35a2Smrg func_arith $current - $age 7458f05b35a2Smrg major=.$func_arith_result 7459f05b35a2Smrg versuffix=".$current.$age.$revision" 7460f05b35a2Smrg verstring="$current.$age.$revision" 7461f05b35a2Smrg 7462f05b35a2Smrg # Add in all the interfaces that we are compatible with. 7463f05b35a2Smrg loop=$age 7464f05b35a2Smrg while test "$loop" -ne 0; do 7465f05b35a2Smrg func_arith $current - $loop 7466f05b35a2Smrg iface=$func_arith_result 7467f05b35a2Smrg func_arith $loop - 1 7468f05b35a2Smrg loop=$func_arith_result 7469f05b35a2Smrg verstring="$verstring:${iface}.0" 7470f05b35a2Smrg done 7471f05b35a2Smrg 7472f05b35a2Smrg # Make executables depend on our current version. 747367ab2ff2Smrg func_append verstring ":${current}.0" 7474f05b35a2Smrg ;; 7475f05b35a2Smrg 7476f05b35a2Smrg qnx) 7477f05b35a2Smrg major=".$current" 7478f05b35a2Smrg versuffix=".$current" 7479f05b35a2Smrg ;; 7480f05b35a2Smrg 7481f05b35a2Smrg sunos) 7482f05b35a2Smrg major=".$current" 7483f05b35a2Smrg versuffix=".$current.$revision" 7484f05b35a2Smrg ;; 7485f05b35a2Smrg 7486f05b35a2Smrg windows) 7487f05b35a2Smrg # Use '-' rather than '.', since we only want one 7488f05b35a2Smrg # extension on DOS 8.3 filesystems. 7489f05b35a2Smrg func_arith $current - $age 7490f05b35a2Smrg major=$func_arith_result 7491f05b35a2Smrg versuffix="-$major" 7492f05b35a2Smrg ;; 7493f05b35a2Smrg 7494f05b35a2Smrg *) 7495f05b35a2Smrg func_fatal_configuration "unknown library version type \`$version_type'" 7496f05b35a2Smrg ;; 7497f05b35a2Smrg esac 7498f05b35a2Smrg 7499f05b35a2Smrg # Clear the version info if we defaulted, and they specified a release. 7500f05b35a2Smrg if test -z "$vinfo" && test -n "$release"; then 7501f05b35a2Smrg major= 7502f05b35a2Smrg case $version_type in 7503f05b35a2Smrg darwin) 7504f05b35a2Smrg # we can't check for "0.0" in archive_cmds due to quoting 7505f05b35a2Smrg # problems, so we reset it completely 7506f05b35a2Smrg verstring= 7507f05b35a2Smrg ;; 7508f05b35a2Smrg *) 7509f05b35a2Smrg verstring="0.0" 7510f05b35a2Smrg ;; 7511f05b35a2Smrg esac 7512f05b35a2Smrg if test "$need_version" = no; then 7513f05b35a2Smrg versuffix= 7514f05b35a2Smrg else 7515f05b35a2Smrg versuffix=".0.0" 7516f05b35a2Smrg fi 7517f05b35a2Smrg fi 7518f05b35a2Smrg 7519f05b35a2Smrg # Remove version info from name if versioning should be avoided 7520f05b35a2Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 7521f05b35a2Smrg major= 7522f05b35a2Smrg versuffix= 7523f05b35a2Smrg verstring="" 7524f05b35a2Smrg fi 7525f05b35a2Smrg 7526f05b35a2Smrg # Check to see if the archive will have undefined symbols. 7527f05b35a2Smrg if test "$allow_undefined" = yes; then 7528f05b35a2Smrg if test "$allow_undefined_flag" = unsupported; then 7529f05b35a2Smrg func_warning "undefined symbols not allowed in $host shared libraries" 7530f05b35a2Smrg build_libtool_libs=no 7531f05b35a2Smrg build_old_libs=yes 7532f05b35a2Smrg fi 7533f05b35a2Smrg else 7534f05b35a2Smrg # Don't allow undefined symbols. 7535f05b35a2Smrg allow_undefined_flag="$no_undefined_flag" 7536f05b35a2Smrg fi 7537f05b35a2Smrg 7538f05b35a2Smrg fi 7539f05b35a2Smrg 7540f05b35a2Smrg func_generate_dlsyms "$libname" "$libname" "yes" 754167ab2ff2Smrg func_append libobjs " $symfileobj" 7542f05b35a2Smrg test "X$libobjs" = "X " && libobjs= 7543f05b35a2Smrg 754467ab2ff2Smrg if test "$opt_mode" != relink; then 7545f05b35a2Smrg # Remove our outputs, but don't remove object files since they 7546f05b35a2Smrg # may have been created when compiling PIC objects. 7547f05b35a2Smrg removelist= 7548f05b35a2Smrg tempremovelist=`$ECHO "$output_objdir/*"` 7549f05b35a2Smrg for p in $tempremovelist; do 7550f05b35a2Smrg case $p in 7551f05b35a2Smrg *.$objext | *.gcno) 7552f05b35a2Smrg ;; 7553f05b35a2Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 7554f05b35a2Smrg if test "X$precious_files_regex" != "X"; then 7555f05b35a2Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 7556f05b35a2Smrg then 7557f05b35a2Smrg continue 7558f05b35a2Smrg fi 7559f05b35a2Smrg fi 756067ab2ff2Smrg func_append removelist " $p" 7561f05b35a2Smrg ;; 7562f05b35a2Smrg *) ;; 7563f05b35a2Smrg esac 7564f05b35a2Smrg done 7565f05b35a2Smrg test -n "$removelist" && \ 7566f05b35a2Smrg func_show_eval "${RM}r \$removelist" 7567f05b35a2Smrg fi 7568f05b35a2Smrg 7569f05b35a2Smrg # Now set the variables for building old libraries. 7570f05b35a2Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 757167ab2ff2Smrg func_append oldlibs " $output_objdir/$libname.$libext" 7572f05b35a2Smrg 7573f05b35a2Smrg # Transform .lo files to .o files. 757449e108a1Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 7575f05b35a2Smrg fi 7576f05b35a2Smrg 7577f05b35a2Smrg # Eliminate all temporary directories. 7578f05b35a2Smrg #for path in $notinst_path; do 757949e108a1Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 758049e108a1Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 758149e108a1Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 7582f05b35a2Smrg #done 7583f05b35a2Smrg 7584f05b35a2Smrg if test -n "$xrpath"; then 7585f05b35a2Smrg # If the user specified any rpath flags, then add them. 7586f05b35a2Smrg temp_xrpath= 7587f05b35a2Smrg for libdir in $xrpath; do 758867ab2ff2Smrg func_replace_sysroot "$libdir" 758967ab2ff2Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 7590f05b35a2Smrg case "$finalize_rpath " in 7591f05b35a2Smrg *" $libdir "*) ;; 759267ab2ff2Smrg *) func_append finalize_rpath " $libdir" ;; 7593f05b35a2Smrg esac 7594f05b35a2Smrg done 7595f05b35a2Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 7596f05b35a2Smrg dependency_libs="$temp_xrpath $dependency_libs" 7597f05b35a2Smrg fi 7598f05b35a2Smrg fi 7599f05b35a2Smrg 7600f05b35a2Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 7601f05b35a2Smrg old_dlfiles="$dlfiles" 7602f05b35a2Smrg dlfiles= 7603f05b35a2Smrg for lib in $old_dlfiles; do 7604f05b35a2Smrg case " $dlprefiles $dlfiles " in 7605f05b35a2Smrg *" $lib "*) ;; 760667ab2ff2Smrg *) func_append dlfiles " $lib" ;; 7607f05b35a2Smrg esac 7608f05b35a2Smrg done 7609f05b35a2Smrg 7610f05b35a2Smrg # Make sure dlprefiles contains only unique files 7611f05b35a2Smrg old_dlprefiles="$dlprefiles" 7612f05b35a2Smrg dlprefiles= 7613f05b35a2Smrg for lib in $old_dlprefiles; do 7614f05b35a2Smrg case "$dlprefiles " in 7615f05b35a2Smrg *" $lib "*) ;; 761667ab2ff2Smrg *) func_append dlprefiles " $lib" ;; 7617f05b35a2Smrg esac 7618f05b35a2Smrg done 7619f05b35a2Smrg 7620f05b35a2Smrg if test "$build_libtool_libs" = yes; then 7621f05b35a2Smrg if test -n "$rpath"; then 7622f05b35a2Smrg case $host in 762349e108a1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 7624f05b35a2Smrg # these systems don't actually have a c library (as such)! 7625f05b35a2Smrg ;; 7626f05b35a2Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7627f05b35a2Smrg # Rhapsody C library is in the System framework 762867ab2ff2Smrg func_append deplibs " System.ltframework" 7629f05b35a2Smrg ;; 7630f05b35a2Smrg *-*-netbsd*) 7631f05b35a2Smrg # Don't link with libc until the a.out ld.so is fixed. 7632f05b35a2Smrg ;; 7633f05b35a2Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 7634f05b35a2Smrg # Do not include libc due to us having libc/libc_r. 7635f05b35a2Smrg ;; 7636f05b35a2Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7637f05b35a2Smrg # Causes problems with __ctype 7638f05b35a2Smrg ;; 7639f05b35a2Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7640f05b35a2Smrg # Compiler inserts libc in the correct place for threads to work 7641f05b35a2Smrg ;; 7642f05b35a2Smrg *) 7643f05b35a2Smrg # Add libc to deplibs on all other systems if necessary. 7644f05b35a2Smrg if test "$build_libtool_need_lc" = "yes"; then 764567ab2ff2Smrg func_append deplibs " -lc" 7646f05b35a2Smrg fi 7647f05b35a2Smrg ;; 7648f05b35a2Smrg esac 7649f05b35a2Smrg fi 7650f05b35a2Smrg 7651f05b35a2Smrg # Transform deplibs into only deplibs that can be linked in shared. 7652f05b35a2Smrg name_save=$name 7653f05b35a2Smrg libname_save=$libname 7654f05b35a2Smrg release_save=$release 7655f05b35a2Smrg versuffix_save=$versuffix 7656f05b35a2Smrg major_save=$major 7657f05b35a2Smrg # I'm not sure if I'm treating the release correctly. I think 7658f05b35a2Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 7659f05b35a2Smrg # add it in twice. Is that correct? 7660f05b35a2Smrg release="" 7661f05b35a2Smrg versuffix="" 7662f05b35a2Smrg major="" 7663f05b35a2Smrg newdeplibs= 7664f05b35a2Smrg droppeddeps=no 7665f05b35a2Smrg case $deplibs_check_method in 7666f05b35a2Smrg pass_all) 7667f05b35a2Smrg # Don't check for shared/static. Everything works. 7668f05b35a2Smrg # This might be a little naive. We might want to check 7669f05b35a2Smrg # whether the library exists or not. But this is on 7670f05b35a2Smrg # osf3 & osf4 and I'm not really sure... Just 7671f05b35a2Smrg # implementing what was already the behavior. 7672f05b35a2Smrg newdeplibs=$deplibs 7673f05b35a2Smrg ;; 7674f05b35a2Smrg test_compile) 7675f05b35a2Smrg # This code stresses the "libraries are programs" paradigm to its 7676f05b35a2Smrg # limits. Maybe even breaks it. We compile a program, linking it 7677f05b35a2Smrg # against the deplibs as a proxy for the library. Then we can check 7678f05b35a2Smrg # whether they linked in statically or dynamically with ldd. 7679f05b35a2Smrg $opt_dry_run || $RM conftest.c 7680f05b35a2Smrg cat > conftest.c <<EOF 7681f05b35a2Smrg int main() { return 0; } 7682f05b35a2SmrgEOF 7683f05b35a2Smrg $opt_dry_run || $RM conftest 7684f05b35a2Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 7685f05b35a2Smrg ldd_output=`ldd conftest` 7686f05b35a2Smrg for i in $deplibs; do 7687f05b35a2Smrg case $i in 7688f05b35a2Smrg -l*) 7689f05b35a2Smrg func_stripname -l '' "$i" 7690f05b35a2Smrg name=$func_stripname_result 7691f05b35a2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7692f05b35a2Smrg case " $predeps $postdeps " in 7693f05b35a2Smrg *" $i "*) 769467ab2ff2Smrg func_append newdeplibs " $i" 7695f05b35a2Smrg i="" 7696f05b35a2Smrg ;; 7697f05b35a2Smrg esac 7698f05b35a2Smrg fi 7699f05b35a2Smrg if test -n "$i" ; then 7700f05b35a2Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7701f05b35a2Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7702f05b35a2Smrg set dummy $deplib_matches; shift 7703f05b35a2Smrg deplib_match=$1 7704f05b35a2Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 770567ab2ff2Smrg func_append newdeplibs " $i" 7706f05b35a2Smrg else 7707f05b35a2Smrg droppeddeps=yes 770849e108a1Smrg echo 7709f05b35a2Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 771049e108a1Smrg echo "*** I have the capability to make that library automatically link in when" 771149e108a1Smrg echo "*** you link to this library. But I can only do this if you have a" 771249e108a1Smrg echo "*** shared version of the library, which I believe you do not have" 771349e108a1Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 771449e108a1Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 7715f05b35a2Smrg fi 7716f05b35a2Smrg fi 7717f05b35a2Smrg ;; 7718f05b35a2Smrg *) 771967ab2ff2Smrg func_append newdeplibs " $i" 7720f05b35a2Smrg ;; 7721f05b35a2Smrg esac 7722f05b35a2Smrg done 7723f05b35a2Smrg else 7724f05b35a2Smrg # Error occurred in the first compile. Let's try to salvage 7725f05b35a2Smrg # the situation: Compile a separate program for each library. 7726f05b35a2Smrg for i in $deplibs; do 7727f05b35a2Smrg case $i in 7728f05b35a2Smrg -l*) 7729f05b35a2Smrg func_stripname -l '' "$i" 7730f05b35a2Smrg name=$func_stripname_result 7731f05b35a2Smrg $opt_dry_run || $RM conftest 7732f05b35a2Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 7733f05b35a2Smrg ldd_output=`ldd conftest` 7734f05b35a2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7735f05b35a2Smrg case " $predeps $postdeps " in 7736f05b35a2Smrg *" $i "*) 773767ab2ff2Smrg func_append newdeplibs " $i" 7738f05b35a2Smrg i="" 7739f05b35a2Smrg ;; 7740f05b35a2Smrg esac 7741f05b35a2Smrg fi 7742f05b35a2Smrg if test -n "$i" ; then 7743f05b35a2Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7744f05b35a2Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7745f05b35a2Smrg set dummy $deplib_matches; shift 7746f05b35a2Smrg deplib_match=$1 7747f05b35a2Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 774867ab2ff2Smrg func_append newdeplibs " $i" 7749f05b35a2Smrg else 7750f05b35a2Smrg droppeddeps=yes 775149e108a1Smrg echo 7752f05b35a2Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 775349e108a1Smrg echo "*** I have the capability to make that library automatically link in when" 775449e108a1Smrg echo "*** you link to this library. But I can only do this if you have a" 775549e108a1Smrg echo "*** shared version of the library, which you do not appear to have" 775649e108a1Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 775749e108a1Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 7758f05b35a2Smrg fi 7759f05b35a2Smrg fi 7760f05b35a2Smrg else 7761f05b35a2Smrg droppeddeps=yes 776249e108a1Smrg echo 7763f05b35a2Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 776449e108a1Smrg echo "*** make it link in! You will probably need to install it or some" 776549e108a1Smrg echo "*** library that it depends on before this library will be fully" 776649e108a1Smrg echo "*** functional. Installing it before continuing would be even better." 7767f05b35a2Smrg fi 7768f05b35a2Smrg ;; 7769f05b35a2Smrg *) 777067ab2ff2Smrg func_append newdeplibs " $i" 7771f05b35a2Smrg ;; 7772f05b35a2Smrg esac 7773f05b35a2Smrg done 7774f05b35a2Smrg fi 7775f05b35a2Smrg ;; 7776f05b35a2Smrg file_magic*) 7777f05b35a2Smrg set dummy $deplibs_check_method; shift 7778f05b35a2Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7779f05b35a2Smrg for a_deplib in $deplibs; do 7780f05b35a2Smrg case $a_deplib in 7781f05b35a2Smrg -l*) 7782f05b35a2Smrg func_stripname -l '' "$a_deplib" 7783f05b35a2Smrg name=$func_stripname_result 7784f05b35a2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7785f05b35a2Smrg case " $predeps $postdeps " in 7786f05b35a2Smrg *" $a_deplib "*) 778767ab2ff2Smrg func_append newdeplibs " $a_deplib" 7788f05b35a2Smrg a_deplib="" 7789f05b35a2Smrg ;; 7790f05b35a2Smrg esac 7791f05b35a2Smrg fi 7792f05b35a2Smrg if test -n "$a_deplib" ; then 7793f05b35a2Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 779467ab2ff2Smrg if test -n "$file_magic_glob"; then 779567ab2ff2Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 779667ab2ff2Smrg else 779767ab2ff2Smrg libnameglob=$libname 779867ab2ff2Smrg fi 779967ab2ff2Smrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 7800f05b35a2Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 780167ab2ff2Smrg if test "$want_nocaseglob" = yes; then 780267ab2ff2Smrg shopt -s nocaseglob 780367ab2ff2Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 780467ab2ff2Smrg $nocaseglob 780567ab2ff2Smrg else 780667ab2ff2Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 780767ab2ff2Smrg fi 7808f05b35a2Smrg for potent_lib in $potential_libs; do 7809f05b35a2Smrg # Follow soft links. 7810f05b35a2Smrg if ls -lLd "$potent_lib" 2>/dev/null | 7811f05b35a2Smrg $GREP " -> " >/dev/null; then 7812f05b35a2Smrg continue 7813f05b35a2Smrg fi 7814f05b35a2Smrg # The statement above tries to avoid entering an 7815f05b35a2Smrg # endless loop below, in case of cyclic links. 7816f05b35a2Smrg # We might still enter an endless loop, since a link 7817f05b35a2Smrg # loop can be closed while we follow links, 7818f05b35a2Smrg # but so what? 7819f05b35a2Smrg potlib="$potent_lib" 7820f05b35a2Smrg while test -h "$potlib" 2>/dev/null; do 7821f05b35a2Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 7822f05b35a2Smrg case $potliblink in 7823f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 782449e108a1Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 7825f05b35a2Smrg esac 7826f05b35a2Smrg done 7827f05b35a2Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 7828f05b35a2Smrg $SED -e 10q | 7829f05b35a2Smrg $EGREP "$file_magic_regex" > /dev/null; then 783067ab2ff2Smrg func_append newdeplibs " $a_deplib" 7831f05b35a2Smrg a_deplib="" 7832f05b35a2Smrg break 2 7833f05b35a2Smrg fi 7834f05b35a2Smrg done 7835f05b35a2Smrg done 7836f05b35a2Smrg fi 7837f05b35a2Smrg if test -n "$a_deplib" ; then 7838f05b35a2Smrg droppeddeps=yes 783949e108a1Smrg echo 7840f05b35a2Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 784149e108a1Smrg echo "*** I have the capability to make that library automatically link in when" 784249e108a1Smrg echo "*** you link to this library. But I can only do this if you have a" 784349e108a1Smrg echo "*** shared version of the library, which you do not appear to have" 784449e108a1Smrg echo "*** because I did check the linker path looking for a file starting" 7845f05b35a2Smrg if test -z "$potlib" ; then 7846f05b35a2Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 7847f05b35a2Smrg else 7848f05b35a2Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 7849f05b35a2Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 7850f05b35a2Smrg fi 7851f05b35a2Smrg fi 7852f05b35a2Smrg ;; 7853f05b35a2Smrg *) 7854f05b35a2Smrg # Add a -L argument. 785567ab2ff2Smrg func_append newdeplibs " $a_deplib" 7856f05b35a2Smrg ;; 7857f05b35a2Smrg esac 7858f05b35a2Smrg done # Gone through all deplibs. 7859f05b35a2Smrg ;; 7860f05b35a2Smrg match_pattern*) 7861f05b35a2Smrg set dummy $deplibs_check_method; shift 7862f05b35a2Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7863f05b35a2Smrg for a_deplib in $deplibs; do 7864f05b35a2Smrg case $a_deplib in 7865f05b35a2Smrg -l*) 7866f05b35a2Smrg func_stripname -l '' "$a_deplib" 7867f05b35a2Smrg name=$func_stripname_result 7868f05b35a2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7869f05b35a2Smrg case " $predeps $postdeps " in 7870f05b35a2Smrg *" $a_deplib "*) 787167ab2ff2Smrg func_append newdeplibs " $a_deplib" 7872f05b35a2Smrg a_deplib="" 7873f05b35a2Smrg ;; 7874f05b35a2Smrg esac 7875f05b35a2Smrg fi 7876f05b35a2Smrg if test -n "$a_deplib" ; then 7877f05b35a2Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7878f05b35a2Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7879f05b35a2Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 7880f05b35a2Smrg for potent_lib in $potential_libs; do 7881f05b35a2Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 788249e108a1Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 7883f05b35a2Smrg $EGREP "$match_pattern_regex" > /dev/null; then 788467ab2ff2Smrg func_append newdeplibs " $a_deplib" 7885f05b35a2Smrg a_deplib="" 7886f05b35a2Smrg break 2 7887f05b35a2Smrg fi 7888f05b35a2Smrg done 7889f05b35a2Smrg done 7890f05b35a2Smrg fi 7891f05b35a2Smrg if test -n "$a_deplib" ; then 7892f05b35a2Smrg droppeddeps=yes 789349e108a1Smrg echo 7894f05b35a2Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 789549e108a1Smrg echo "*** I have the capability to make that library automatically link in when" 789649e108a1Smrg echo "*** you link to this library. But I can only do this if you have a" 789749e108a1Smrg echo "*** shared version of the library, which you do not appear to have" 789849e108a1Smrg echo "*** because I did check the linker path looking for a file starting" 7899f05b35a2Smrg if test -z "$potlib" ; then 7900f05b35a2Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 7901f05b35a2Smrg else 7902f05b35a2Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 7903f05b35a2Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 7904f05b35a2Smrg fi 7905f05b35a2Smrg fi 7906f05b35a2Smrg ;; 7907f05b35a2Smrg *) 7908f05b35a2Smrg # Add a -L argument. 790967ab2ff2Smrg func_append newdeplibs " $a_deplib" 7910f05b35a2Smrg ;; 7911f05b35a2Smrg esac 7912f05b35a2Smrg done # Gone through all deplibs. 7913f05b35a2Smrg ;; 7914f05b35a2Smrg none | unknown | *) 7915f05b35a2Smrg newdeplibs="" 791649e108a1Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 7917f05b35a2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7918f05b35a2Smrg for i in $predeps $postdeps ; do 7919f05b35a2Smrg # can't use Xsed below, because $i might contain '/' 792049e108a1Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 7921f05b35a2Smrg done 7922f05b35a2Smrg fi 792349e108a1Smrg case $tmp_deplibs in 792449e108a1Smrg *[!\ \ ]*) 792549e108a1Smrg echo 7926f05b35a2Smrg if test "X$deplibs_check_method" = "Xnone"; then 792749e108a1Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 7928f05b35a2Smrg else 792949e108a1Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 7930f05b35a2Smrg fi 793149e108a1Smrg echo "*** All declared inter-library dependencies are being dropped." 7932f05b35a2Smrg droppeddeps=yes 793349e108a1Smrg ;; 793449e108a1Smrg esac 7935f05b35a2Smrg ;; 7936f05b35a2Smrg esac 7937f05b35a2Smrg versuffix=$versuffix_save 7938f05b35a2Smrg major=$major_save 7939f05b35a2Smrg release=$release_save 7940f05b35a2Smrg libname=$libname_save 7941f05b35a2Smrg name=$name_save 7942f05b35a2Smrg 7943f05b35a2Smrg case $host in 7944f05b35a2Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7945f05b35a2Smrg # On Rhapsody replace the C library with the System framework 794649e108a1Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 7947f05b35a2Smrg ;; 7948f05b35a2Smrg esac 7949f05b35a2Smrg 7950f05b35a2Smrg if test "$droppeddeps" = yes; then 7951f05b35a2Smrg if test "$module" = yes; then 795249e108a1Smrg echo 795349e108a1Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 7954f05b35a2Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 795549e108a1Smrg echo "*** a static module, that should work as long as the dlopening" 795649e108a1Smrg echo "*** application is linked with the -dlopen flag." 7957f05b35a2Smrg if test -z "$global_symbol_pipe"; then 795849e108a1Smrg echo 795949e108a1Smrg echo "*** However, this would only work if libtool was able to extract symbol" 796049e108a1Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 796149e108a1Smrg echo "*** not find such a program. So, this module is probably useless." 796249e108a1Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 7963f05b35a2Smrg fi 7964f05b35a2Smrg if test "$build_old_libs" = no; then 7965f05b35a2Smrg oldlibs="$output_objdir/$libname.$libext" 7966f05b35a2Smrg build_libtool_libs=module 7967f05b35a2Smrg build_old_libs=yes 7968f05b35a2Smrg else 7969f05b35a2Smrg build_libtool_libs=no 7970f05b35a2Smrg fi 7971f05b35a2Smrg else 797249e108a1Smrg echo "*** The inter-library dependencies that have been dropped here will be" 797349e108a1Smrg echo "*** automatically added whenever a program is linked with this library" 797449e108a1Smrg echo "*** or is declared to -dlopen it." 7975f05b35a2Smrg 7976f05b35a2Smrg if test "$allow_undefined" = no; then 797749e108a1Smrg echo 797849e108a1Smrg echo "*** Since this library must not contain undefined symbols," 797949e108a1Smrg echo "*** because either the platform does not support them or" 798049e108a1Smrg echo "*** it was explicitly requested with -no-undefined," 798149e108a1Smrg echo "*** libtool will only create a static version of it." 7982f05b35a2Smrg if test "$build_old_libs" = no; then 7983f05b35a2Smrg oldlibs="$output_objdir/$libname.$libext" 7984f05b35a2Smrg build_libtool_libs=module 7985f05b35a2Smrg build_old_libs=yes 7986f05b35a2Smrg else 7987f05b35a2Smrg build_libtool_libs=no 7988f05b35a2Smrg fi 7989f05b35a2Smrg fi 7990f05b35a2Smrg fi 7991f05b35a2Smrg fi 7992f05b35a2Smrg # Done checking deplibs! 7993f05b35a2Smrg deplibs=$newdeplibs 7994f05b35a2Smrg fi 7995f05b35a2Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 7996f05b35a2Smrg case $host in 7997f05b35a2Smrg *-*-darwin*) 799849e108a1Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 799949e108a1Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 800049e108a1Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8001f05b35a2Smrg ;; 8002f05b35a2Smrg esac 8003f05b35a2Smrg 8004f05b35a2Smrg # move library search paths that coincide with paths to not yet 8005f05b35a2Smrg # installed libraries to the beginning of the library search list 8006f05b35a2Smrg new_libs= 8007f05b35a2Smrg for path in $notinst_path; do 8008f05b35a2Smrg case " $new_libs " in 8009f05b35a2Smrg *" -L$path/$objdir "*) ;; 8010f05b35a2Smrg *) 8011f05b35a2Smrg case " $deplibs " in 8012f05b35a2Smrg *" -L$path/$objdir "*) 801367ab2ff2Smrg func_append new_libs " -L$path/$objdir" ;; 8014f05b35a2Smrg esac 8015f05b35a2Smrg ;; 8016f05b35a2Smrg esac 8017f05b35a2Smrg done 8018f05b35a2Smrg for deplib in $deplibs; do 8019f05b35a2Smrg case $deplib in 8020f05b35a2Smrg -L*) 8021f05b35a2Smrg case " $new_libs " in 8022f05b35a2Smrg *" $deplib "*) ;; 802367ab2ff2Smrg *) func_append new_libs " $deplib" ;; 8024f05b35a2Smrg esac 8025f05b35a2Smrg ;; 802667ab2ff2Smrg *) func_append new_libs " $deplib" ;; 8027f05b35a2Smrg esac 8028f05b35a2Smrg done 8029f05b35a2Smrg deplibs="$new_libs" 8030f05b35a2Smrg 8031f05b35a2Smrg # All the library-specific variables (install_libdir is set above). 8032f05b35a2Smrg library_names= 8033f05b35a2Smrg old_library= 8034f05b35a2Smrg dlname= 8035f05b35a2Smrg 8036f05b35a2Smrg # Test again, we may have decided not to build it any more 8037f05b35a2Smrg if test "$build_libtool_libs" = yes; then 8038e494fffdSmrg # Remove ${wl} instances when linking with ld. 8039e494fffdSmrg # FIXME: should test the right _cmds variable. 8040e494fffdSmrg case $archive_cmds in 8041e494fffdSmrg *\$LD\ *) wl= ;; 8042e494fffdSmrg esac 8043f05b35a2Smrg if test "$hardcode_into_libs" = yes; then 8044f05b35a2Smrg # Hardcode the library paths 8045f05b35a2Smrg hardcode_libdirs= 8046f05b35a2Smrg dep_rpath= 8047f05b35a2Smrg rpath="$finalize_rpath" 804867ab2ff2Smrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 8049f05b35a2Smrg for libdir in $rpath; do 8050f05b35a2Smrg if test -n "$hardcode_libdir_flag_spec"; then 8051f05b35a2Smrg if test -n "$hardcode_libdir_separator"; then 805267ab2ff2Smrg func_replace_sysroot "$libdir" 805367ab2ff2Smrg libdir=$func_replace_sysroot_result 8054f05b35a2Smrg if test -z "$hardcode_libdirs"; then 8055f05b35a2Smrg hardcode_libdirs="$libdir" 8056f05b35a2Smrg else 8057f05b35a2Smrg # Just accumulate the unique libdirs. 8058f05b35a2Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8059f05b35a2Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8060f05b35a2Smrg ;; 8061f05b35a2Smrg *) 806267ab2ff2Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8063f05b35a2Smrg ;; 8064f05b35a2Smrg esac 8065f05b35a2Smrg fi 8066f05b35a2Smrg else 8067f05b35a2Smrg eval flag=\"$hardcode_libdir_flag_spec\" 806867ab2ff2Smrg func_append dep_rpath " $flag" 8069f05b35a2Smrg fi 8070f05b35a2Smrg elif test -n "$runpath_var"; then 8071f05b35a2Smrg case "$perm_rpath " in 8072f05b35a2Smrg *" $libdir "*) ;; 8073e494fffdSmrg *) func_append perm_rpath " $libdir" ;; 8074f05b35a2Smrg esac 8075f05b35a2Smrg fi 8076f05b35a2Smrg done 8077f05b35a2Smrg # Substitute the hardcoded libdirs into the rpath. 8078f05b35a2Smrg if test -n "$hardcode_libdir_separator" && 8079f05b35a2Smrg test -n "$hardcode_libdirs"; then 8080f05b35a2Smrg libdir="$hardcode_libdirs" 8081e494fffdSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 8082f05b35a2Smrg fi 8083f05b35a2Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 8084f05b35a2Smrg # We should set the runpath_var. 8085f05b35a2Smrg rpath= 8086f05b35a2Smrg for dir in $perm_rpath; do 808767ab2ff2Smrg func_append rpath "$dir:" 8088f05b35a2Smrg done 8089f05b35a2Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 8090f05b35a2Smrg fi 8091f05b35a2Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 8092f05b35a2Smrg fi 8093e0963edeSmrg 8094f05b35a2Smrg shlibpath="$finalize_shlibpath" 809567ab2ff2Smrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 8096f05b35a2Smrg if test -n "$shlibpath"; then 8097f05b35a2Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 8098f05b35a2Smrg fi 8099e0963edeSmrg 8100f05b35a2Smrg # Get the real and link names of the library. 8101f05b35a2Smrg eval shared_ext=\"$shrext_cmds\" 8102f05b35a2Smrg eval library_names=\"$library_names_spec\" 8103f05b35a2Smrg set dummy $library_names 8104f05b35a2Smrg shift 8105f05b35a2Smrg realname="$1" 8106f05b35a2Smrg shift 8107e0963edeSmrg 8108f05b35a2Smrg if test -n "$soname_spec"; then 8109f05b35a2Smrg eval soname=\"$soname_spec\" 8110f05b35a2Smrg else 8111f05b35a2Smrg soname="$realname" 8112f05b35a2Smrg fi 8113f05b35a2Smrg if test -z "$dlname"; then 8114f05b35a2Smrg dlname=$soname 8115f05b35a2Smrg fi 8116e0963edeSmrg 8117f05b35a2Smrg lib="$output_objdir/$realname" 8118f05b35a2Smrg linknames= 8119f05b35a2Smrg for link 8120f05b35a2Smrg do 812167ab2ff2Smrg func_append linknames " $link" 8122f05b35a2Smrg done 8123e0963edeSmrg 8124f05b35a2Smrg # Use standard objects if they are pic 812549e108a1Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 8126f05b35a2Smrg test "X$libobjs" = "X " && libobjs= 8127e0963edeSmrg 8128f05b35a2Smrg delfiles= 8129f05b35a2Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8130f05b35a2Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 8131f05b35a2Smrg export_symbols="$output_objdir/$libname.uexp" 813267ab2ff2Smrg func_append delfiles " $export_symbols" 8133f05b35a2Smrg fi 8134e0963edeSmrg 8135f05b35a2Smrg orig_export_symbols= 8136f05b35a2Smrg case $host_os in 8137f05b35a2Smrg cygwin* | mingw* | cegcc*) 8138f05b35a2Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 8139f05b35a2Smrg # exporting using user supplied symfile 8140f05b35a2Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 8141f05b35a2Smrg # and it's NOT already a .def file. Must figure out 8142f05b35a2Smrg # which of the given symbols are data symbols and tag 8143f05b35a2Smrg # them as such. So, trigger use of export_symbols_cmds. 8144f05b35a2Smrg # export_symbols gets reassigned inside the "prepare 8145f05b35a2Smrg # the list of exported symbols" if statement, so the 8146f05b35a2Smrg # include_expsyms logic still works. 8147f05b35a2Smrg orig_export_symbols="$export_symbols" 8148f05b35a2Smrg export_symbols= 8149f05b35a2Smrg always_export_symbols=yes 8150f05b35a2Smrg fi 8151f05b35a2Smrg fi 8152f05b35a2Smrg ;; 8153f05b35a2Smrg esac 8154e0963edeSmrg 8155f05b35a2Smrg # Prepare the list of exported symbols 8156f05b35a2Smrg if test -z "$export_symbols"; then 8157f05b35a2Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 8158f05b35a2Smrg func_verbose "generating symbol list for \`$libname.la'" 8159f05b35a2Smrg export_symbols="$output_objdir/$libname.exp" 8160f05b35a2Smrg $opt_dry_run || $RM $export_symbols 8161f05b35a2Smrg cmds=$export_symbols_cmds 8162f05b35a2Smrg save_ifs="$IFS"; IFS='~' 816367ab2ff2Smrg for cmd1 in $cmds; do 8164f05b35a2Smrg IFS="$save_ifs" 816567ab2ff2Smrg # Take the normal branch if the nm_file_list_spec branch 816667ab2ff2Smrg # doesn't work or if tool conversion is not needed. 816767ab2ff2Smrg case $nm_file_list_spec~$to_tool_file_cmd in 816867ab2ff2Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 816967ab2ff2Smrg try_normal_branch=yes 817067ab2ff2Smrg eval cmd=\"$cmd1\" 817167ab2ff2Smrg func_len " $cmd" 817267ab2ff2Smrg len=$func_len_result 817367ab2ff2Smrg ;; 817467ab2ff2Smrg *) 817567ab2ff2Smrg try_normal_branch=no 817667ab2ff2Smrg ;; 817767ab2ff2Smrg esac 817867ab2ff2Smrg if test "$try_normal_branch" = yes \ 817967ab2ff2Smrg && { test "$len" -lt "$max_cmd_len" \ 818067ab2ff2Smrg || test "$max_cmd_len" -le -1; } 818167ab2ff2Smrg then 818267ab2ff2Smrg func_show_eval "$cmd" 'exit $?' 818367ab2ff2Smrg skipped_export=false 818467ab2ff2Smrg elif test -n "$nm_file_list_spec"; then 818567ab2ff2Smrg func_basename "$output" 818667ab2ff2Smrg output_la=$func_basename_result 818767ab2ff2Smrg save_libobjs=$libobjs 818867ab2ff2Smrg save_output=$output 818967ab2ff2Smrg output=${output_objdir}/${output_la}.nm 819067ab2ff2Smrg func_to_tool_file "$output" 819167ab2ff2Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 819267ab2ff2Smrg func_append delfiles " $output" 819367ab2ff2Smrg func_verbose "creating $NM input file list: $output" 819467ab2ff2Smrg for obj in $save_libobjs; do 819567ab2ff2Smrg func_to_tool_file "$obj" 819667ab2ff2Smrg $ECHO "$func_to_tool_file_result" 819767ab2ff2Smrg done > "$output" 819867ab2ff2Smrg eval cmd=\"$cmd1\" 8199f05b35a2Smrg func_show_eval "$cmd" 'exit $?' 820067ab2ff2Smrg output=$save_output 820167ab2ff2Smrg libobjs=$save_libobjs 8202f05b35a2Smrg skipped_export=false 8203f05b35a2Smrg else 8204f05b35a2Smrg # The command line is too long to execute in one step. 8205f05b35a2Smrg func_verbose "using reloadable object file for export list..." 8206f05b35a2Smrg skipped_export=: 8207f05b35a2Smrg # Break out early, otherwise skipped_export may be 8208f05b35a2Smrg # set to false by a later but shorter cmd. 8209f05b35a2Smrg break 8210f05b35a2Smrg fi 8211f05b35a2Smrg done 8212f05b35a2Smrg IFS="$save_ifs" 8213f05b35a2Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 8214f05b35a2Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8215f05b35a2Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8216f05b35a2Smrg fi 8217f05b35a2Smrg fi 8218f05b35a2Smrg fi 8219e0963edeSmrg 8220f05b35a2Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8221f05b35a2Smrg tmp_export_symbols="$export_symbols" 8222f05b35a2Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 822349e108a1Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8224f05b35a2Smrg fi 8225e0963edeSmrg 8226f05b35a2Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 8227f05b35a2Smrg # The given exports_symbols file has to be filtered, so filter it. 8228f05b35a2Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8229f05b35a2Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 8230f05b35a2Smrg # 's' commands which not all seds can handle. GNU sed should be fine 8231f05b35a2Smrg # though. Also, the filter scales superlinearly with the number of 8232f05b35a2Smrg # global variables. join(1) would be nice here, but unfortunately 8233f05b35a2Smrg # isn't a blessed tool. 8234f05b35a2Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 823567ab2ff2Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8236f05b35a2Smrg export_symbols=$output_objdir/$libname.def 8237f05b35a2Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8238e0963edeSmrg fi 8239e0963edeSmrg 8240f05b35a2Smrg tmp_deplibs= 8241f05b35a2Smrg for test_deplib in $deplibs; do 8242f05b35a2Smrg case " $convenience " in 8243f05b35a2Smrg *" $test_deplib "*) ;; 8244f05b35a2Smrg *) 824567ab2ff2Smrg func_append tmp_deplibs " $test_deplib" 8246f05b35a2Smrg ;; 8247f05b35a2Smrg esac 8248f05b35a2Smrg done 8249f05b35a2Smrg deplibs="$tmp_deplibs" 8250e0963edeSmrg 8251f05b35a2Smrg if test -n "$convenience"; then 8252f05b35a2Smrg if test -n "$whole_archive_flag_spec" && 8253f05b35a2Smrg test "$compiler_needs_object" = yes && 8254f05b35a2Smrg test -z "$libobjs"; then 8255f05b35a2Smrg # extract the archives, so we have objects to list. 8256f05b35a2Smrg # TODO: could optimize this to just extract one archive. 8257f05b35a2Smrg whole_archive_flag_spec= 8258f05b35a2Smrg fi 8259f05b35a2Smrg if test -n "$whole_archive_flag_spec"; then 8260f05b35a2Smrg save_libobjs=$libobjs 8261f05b35a2Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8262f05b35a2Smrg test "X$libobjs" = "X " && libobjs= 8263f05b35a2Smrg else 8264f05b35a2Smrg gentop="$output_objdir/${outputname}x" 826567ab2ff2Smrg func_append generated " $gentop" 8266e0963edeSmrg 8267f05b35a2Smrg func_extract_archives $gentop $convenience 826867ab2ff2Smrg func_append libobjs " $func_extract_archives_result" 8269f05b35a2Smrg test "X$libobjs" = "X " && libobjs= 8270f05b35a2Smrg fi 8271f05b35a2Smrg fi 8272e0963edeSmrg 8273f05b35a2Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 8274f05b35a2Smrg eval flag=\"$thread_safe_flag_spec\" 827567ab2ff2Smrg func_append linker_flags " $flag" 8276f05b35a2Smrg fi 8277e0963edeSmrg 8278f05b35a2Smrg # Make a backup of the uninstalled library when relinking 827967ab2ff2Smrg if test "$opt_mode" = relink; then 8280f05b35a2Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 8281e0963edeSmrg fi 8282e0963edeSmrg 8283f05b35a2Smrg # Do each of the archive commands. 8284f05b35a2Smrg if test "$module" = yes && test -n "$module_cmds" ; then 8285f05b35a2Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8286f05b35a2Smrg eval test_cmds=\"$module_expsym_cmds\" 8287f05b35a2Smrg cmds=$module_expsym_cmds 8288f05b35a2Smrg else 8289f05b35a2Smrg eval test_cmds=\"$module_cmds\" 8290f05b35a2Smrg cmds=$module_cmds 8291f05b35a2Smrg fi 8292f05b35a2Smrg else 8293f05b35a2Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8294f05b35a2Smrg eval test_cmds=\"$archive_expsym_cmds\" 8295f05b35a2Smrg cmds=$archive_expsym_cmds 8296f05b35a2Smrg else 8297f05b35a2Smrg eval test_cmds=\"$archive_cmds\" 8298f05b35a2Smrg cmds=$archive_cmds 8299f05b35a2Smrg fi 8300e0963edeSmrg fi 8301e0963edeSmrg 8302f05b35a2Smrg if test "X$skipped_export" != "X:" && 8303f05b35a2Smrg func_len " $test_cmds" && 8304f05b35a2Smrg len=$func_len_result && 8305f05b35a2Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 8306f05b35a2Smrg : 8307f05b35a2Smrg else 8308f05b35a2Smrg # The command line is too long to link in one step, link piecewise 8309f05b35a2Smrg # or, if using GNU ld and skipped_export is not :, use a linker 8310f05b35a2Smrg # script. 8311e0963edeSmrg 8312f05b35a2Smrg # Save the value of $output and $libobjs because we want to 8313f05b35a2Smrg # use them later. If we have whole_archive_flag_spec, we 8314f05b35a2Smrg # want to use save_libobjs as it was before 8315f05b35a2Smrg # whole_archive_flag_spec was expanded, because we can't 8316f05b35a2Smrg # assume the linker understands whole_archive_flag_spec. 8317f05b35a2Smrg # This may have to be revisited, in case too many 8318f05b35a2Smrg # convenience libraries get linked in and end up exceeding 8319f05b35a2Smrg # the spec. 8320f05b35a2Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 8321f05b35a2Smrg save_libobjs=$libobjs 8322f05b35a2Smrg fi 8323f05b35a2Smrg save_output=$output 832449e108a1Smrg func_basename "$output" 832549e108a1Smrg output_la=$func_basename_result 8326e0963edeSmrg 8327f05b35a2Smrg # Clear the reloadable object creation command queue and 8328f05b35a2Smrg # initialize k to one. 8329f05b35a2Smrg test_cmds= 8330f05b35a2Smrg concat_cmds= 8331f05b35a2Smrg objlist= 8332f05b35a2Smrg last_robj= 8333f05b35a2Smrg k=1 8334e0963edeSmrg 8335f05b35a2Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 8336f05b35a2Smrg output=${output_objdir}/${output_la}.lnkscript 8337f05b35a2Smrg func_verbose "creating GNU ld script: $output" 833849e108a1Smrg echo 'INPUT (' > $output 8339f05b35a2Smrg for obj in $save_libobjs 8340f05b35a2Smrg do 834167ab2ff2Smrg func_to_tool_file "$obj" 834267ab2ff2Smrg $ECHO "$func_to_tool_file_result" >> $output 8343f05b35a2Smrg done 834449e108a1Smrg echo ')' >> $output 834567ab2ff2Smrg func_append delfiles " $output" 834667ab2ff2Smrg func_to_tool_file "$output" 834767ab2ff2Smrg output=$func_to_tool_file_result 8348f05b35a2Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 8349f05b35a2Smrg output=${output_objdir}/${output_la}.lnk 8350f05b35a2Smrg func_verbose "creating linker input file list: $output" 8351f05b35a2Smrg : > $output 8352f05b35a2Smrg set x $save_libobjs 8353f05b35a2Smrg shift 8354f05b35a2Smrg firstobj= 8355f05b35a2Smrg if test "$compiler_needs_object" = yes; then 8356f05b35a2Smrg firstobj="$1 " 8357f05b35a2Smrg shift 8358f05b35a2Smrg fi 8359f05b35a2Smrg for obj 8360f05b35a2Smrg do 836167ab2ff2Smrg func_to_tool_file "$obj" 836267ab2ff2Smrg $ECHO "$func_to_tool_file_result" >> $output 8363f05b35a2Smrg done 836467ab2ff2Smrg func_append delfiles " $output" 836567ab2ff2Smrg func_to_tool_file "$output" 836667ab2ff2Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 8367f05b35a2Smrg else 8368f05b35a2Smrg if test -n "$save_libobjs"; then 8369f05b35a2Smrg func_verbose "creating reloadable object files..." 8370f05b35a2Smrg output=$output_objdir/$output_la-${k}.$objext 8371f05b35a2Smrg eval test_cmds=\"$reload_cmds\" 8372f05b35a2Smrg func_len " $test_cmds" 8373f05b35a2Smrg len0=$func_len_result 8374f05b35a2Smrg len=$len0 8375f05b35a2Smrg 8376f05b35a2Smrg # Loop over the list of objects to be linked. 8377f05b35a2Smrg for obj in $save_libobjs 8378f05b35a2Smrg do 8379f05b35a2Smrg func_len " $obj" 8380f05b35a2Smrg func_arith $len + $func_len_result 8381f05b35a2Smrg len=$func_arith_result 8382f05b35a2Smrg if test "X$objlist" = X || 8383f05b35a2Smrg test "$len" -lt "$max_cmd_len"; then 8384f05b35a2Smrg func_append objlist " $obj" 8385f05b35a2Smrg else 8386f05b35a2Smrg # The command $test_cmds is almost too long, add a 8387f05b35a2Smrg # command to the queue. 8388f05b35a2Smrg if test "$k" -eq 1 ; then 8389f05b35a2Smrg # The first file doesn't have a previous command to add. 839049e108a1Smrg reload_objs=$objlist 839149e108a1Smrg eval concat_cmds=\"$reload_cmds\" 8392f05b35a2Smrg else 8393f05b35a2Smrg # All subsequent reloadable object files will link in 8394f05b35a2Smrg # the last one created. 839549e108a1Smrg reload_objs="$objlist $last_robj" 839649e108a1Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 8397f05b35a2Smrg fi 8398f05b35a2Smrg last_robj=$output_objdir/$output_la-${k}.$objext 8399f05b35a2Smrg func_arith $k + 1 8400f05b35a2Smrg k=$func_arith_result 8401f05b35a2Smrg output=$output_objdir/$output_la-${k}.$objext 840249e108a1Smrg objlist=" $obj" 8403f05b35a2Smrg func_len " $last_robj" 8404f05b35a2Smrg func_arith $len0 + $func_len_result 8405f05b35a2Smrg len=$func_arith_result 8406f05b35a2Smrg fi 8407f05b35a2Smrg done 8408f05b35a2Smrg # Handle the remaining objects by creating one last 8409f05b35a2Smrg # reloadable object file. All subsequent reloadable object 8410f05b35a2Smrg # files will link in the last one created. 8411f05b35a2Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 841249e108a1Smrg reload_objs="$objlist $last_robj" 841349e108a1Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 8414f05b35a2Smrg if test -n "$last_robj"; then 8415f05b35a2Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 8416f05b35a2Smrg fi 841767ab2ff2Smrg func_append delfiles " $output" 8418e0963edeSmrg 8419f05b35a2Smrg else 8420f05b35a2Smrg output= 8421f05b35a2Smrg fi 8422f05b35a2Smrg 8423f05b35a2Smrg if ${skipped_export-false}; then 8424f05b35a2Smrg func_verbose "generating symbol list for \`$libname.la'" 8425f05b35a2Smrg export_symbols="$output_objdir/$libname.exp" 8426f05b35a2Smrg $opt_dry_run || $RM $export_symbols 8427f05b35a2Smrg libobjs=$output 8428f05b35a2Smrg # Append the command to create the export file. 8429f05b35a2Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8430f05b35a2Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 8431f05b35a2Smrg if test -n "$last_robj"; then 8432f05b35a2Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 8433f05b35a2Smrg fi 8434f05b35a2Smrg fi 8435e0963edeSmrg 8436f05b35a2Smrg test -n "$save_libobjs" && 8437f05b35a2Smrg func_verbose "creating a temporary reloadable object file: $output" 8438e0963edeSmrg 8439f05b35a2Smrg # Loop through the commands generated above and execute them. 8440f05b35a2Smrg save_ifs="$IFS"; IFS='~' 8441f05b35a2Smrg for cmd in $concat_cmds; do 8442f05b35a2Smrg IFS="$save_ifs" 8443f05b35a2Smrg $opt_silent || { 8444f05b35a2Smrg func_quote_for_expand "$cmd" 8445f05b35a2Smrg eval "func_echo $func_quote_for_expand_result" 8446f05b35a2Smrg } 8447f05b35a2Smrg $opt_dry_run || eval "$cmd" || { 8448f05b35a2Smrg lt_exit=$? 8449f05b35a2Smrg 8450f05b35a2Smrg # Restore the uninstalled library and exit 845167ab2ff2Smrg if test "$opt_mode" = relink; then 8452f05b35a2Smrg ( cd "$output_objdir" && \ 8453f05b35a2Smrg $RM "${realname}T" && \ 8454f05b35a2Smrg $MV "${realname}U" "$realname" ) 8455f05b35a2Smrg fi 8456e0963edeSmrg 8457f05b35a2Smrg exit $lt_exit 8458f05b35a2Smrg } 8459f05b35a2Smrg done 8460f05b35a2Smrg IFS="$save_ifs" 8461e0963edeSmrg 8462f05b35a2Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 8463f05b35a2Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8464f05b35a2Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8465e0963edeSmrg fi 8466e0963edeSmrg fi 8467e0963edeSmrg 8468f05b35a2Smrg if ${skipped_export-false}; then 8469f05b35a2Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8470f05b35a2Smrg tmp_export_symbols="$export_symbols" 8471f05b35a2Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 847249e108a1Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8473f05b35a2Smrg fi 8474e0963edeSmrg 8475f05b35a2Smrg if test -n "$orig_export_symbols"; then 8476f05b35a2Smrg # The given exports_symbols file has to be filtered, so filter it. 8477f05b35a2Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8478f05b35a2Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 8479f05b35a2Smrg # 's' commands which not all seds can handle. GNU sed should be fine 8480f05b35a2Smrg # though. Also, the filter scales superlinearly with the number of 8481f05b35a2Smrg # global variables. join(1) would be nice here, but unfortunately 8482f05b35a2Smrg # isn't a blessed tool. 8483f05b35a2Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 848467ab2ff2Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8485f05b35a2Smrg export_symbols=$output_objdir/$libname.def 8486f05b35a2Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8487f05b35a2Smrg fi 8488f05b35a2Smrg fi 8489e0963edeSmrg 8490f05b35a2Smrg libobjs=$output 8491f05b35a2Smrg # Restore the value of output. 8492f05b35a2Smrg output=$save_output 8493e0963edeSmrg 8494f05b35a2Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 8495f05b35a2Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8496f05b35a2Smrg test "X$libobjs" = "X " && libobjs= 8497f05b35a2Smrg fi 8498f05b35a2Smrg # Expand the library linking commands again to reset the 8499f05b35a2Smrg # value of $libobjs for piecewise linking. 8500f05b35a2Smrg 8501f05b35a2Smrg # Do each of the archive commands. 8502f05b35a2Smrg if test "$module" = yes && test -n "$module_cmds" ; then 8503f05b35a2Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8504f05b35a2Smrg cmds=$module_expsym_cmds 8505e0963edeSmrg else 8506f05b35a2Smrg cmds=$module_cmds 8507e0963edeSmrg fi 8508e0963edeSmrg else 8509f05b35a2Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8510f05b35a2Smrg cmds=$archive_expsym_cmds 8511f05b35a2Smrg else 8512f05b35a2Smrg cmds=$archive_cmds 8513f05b35a2Smrg fi 8514e0963edeSmrg fi 8515e0963edeSmrg fi 8516e0963edeSmrg 8517f05b35a2Smrg if test -n "$delfiles"; then 8518f05b35a2Smrg # Append the command to remove temporary files to $cmds. 8519f05b35a2Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 8520f05b35a2Smrg fi 8521e0963edeSmrg 8522f05b35a2Smrg # Add any objects from preloaded convenience libraries 8523f05b35a2Smrg if test -n "$dlprefiles"; then 8524f05b35a2Smrg gentop="$output_objdir/${outputname}x" 852567ab2ff2Smrg func_append generated " $gentop" 8526e0963edeSmrg 8527f05b35a2Smrg func_extract_archives $gentop $dlprefiles 852867ab2ff2Smrg func_append libobjs " $func_extract_archives_result" 8529f05b35a2Smrg test "X$libobjs" = "X " && libobjs= 8530e0963edeSmrg fi 8531e0963edeSmrg 8532f05b35a2Smrg save_ifs="$IFS"; IFS='~' 8533f05b35a2Smrg for cmd in $cmds; do 8534f05b35a2Smrg IFS="$save_ifs" 8535f05b35a2Smrg eval cmd=\"$cmd\" 8536f05b35a2Smrg $opt_silent || { 8537f05b35a2Smrg func_quote_for_expand "$cmd" 8538f05b35a2Smrg eval "func_echo $func_quote_for_expand_result" 8539f05b35a2Smrg } 8540f05b35a2Smrg $opt_dry_run || eval "$cmd" || { 8541f05b35a2Smrg lt_exit=$? 8542e0963edeSmrg 8543f05b35a2Smrg # Restore the uninstalled library and exit 854467ab2ff2Smrg if test "$opt_mode" = relink; then 8545f05b35a2Smrg ( cd "$output_objdir" && \ 8546f05b35a2Smrg $RM "${realname}T" && \ 8547f05b35a2Smrg $MV "${realname}U" "$realname" ) 8548e0963edeSmrg fi 8549e0963edeSmrg 8550f05b35a2Smrg exit $lt_exit 8551f05b35a2Smrg } 8552f05b35a2Smrg done 8553f05b35a2Smrg IFS="$save_ifs" 8554e0963edeSmrg 8555f05b35a2Smrg # Restore the uninstalled library and exit 855667ab2ff2Smrg if test "$opt_mode" = relink; then 8557f05b35a2Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 8558e0963edeSmrg 8559f05b35a2Smrg if test -n "$convenience"; then 8560f05b35a2Smrg if test -z "$whole_archive_flag_spec"; then 8561f05b35a2Smrg func_show_eval '${RM}r "$gentop"' 8562f05b35a2Smrg fi 8563f05b35a2Smrg fi 8564e0963edeSmrg 8565f05b35a2Smrg exit $EXIT_SUCCESS 8566f05b35a2Smrg fi 8567e0963edeSmrg 8568f05b35a2Smrg # Create links to the real library. 8569f05b35a2Smrg for linkname in $linknames; do 8570f05b35a2Smrg if test "$realname" != "$linkname"; then 8571f05b35a2Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 8572e0963edeSmrg fi 8573e0963edeSmrg done 8574e0963edeSmrg 8575f05b35a2Smrg # If -module or -export-dynamic was specified, set the dlname. 8576f05b35a2Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 8577f05b35a2Smrg # On all known operating systems, these are identical. 8578f05b35a2Smrg dlname="$soname" 8579f05b35a2Smrg fi 8580f05b35a2Smrg fi 8581e0963edeSmrg ;; 8582e0963edeSmrg 8583f05b35a2Smrg obj) 8584f05b35a2Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 8585f05b35a2Smrg func_warning "\`-dlopen' is ignored for objects" 8586f05b35a2Smrg fi 8587e0963edeSmrg 8588f05b35a2Smrg case " $deplibs" in 8589f05b35a2Smrg *\ -l* | *\ -L*) 8590f05b35a2Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 8591e0963edeSmrg esac 8592e0963edeSmrg 8593f05b35a2Smrg test -n "$rpath" && \ 8594f05b35a2Smrg func_warning "\`-rpath' is ignored for objects" 8595e0963edeSmrg 8596f05b35a2Smrg test -n "$xrpath" && \ 8597f05b35a2Smrg func_warning "\`-R' is ignored for objects" 8598e0963edeSmrg 8599f05b35a2Smrg test -n "$vinfo" && \ 8600f05b35a2Smrg func_warning "\`-version-info' is ignored for objects" 8601f05b35a2Smrg 8602f05b35a2Smrg test -n "$release" && \ 8603f05b35a2Smrg func_warning "\`-release' is ignored for objects" 8604f05b35a2Smrg 8605f05b35a2Smrg case $output in 8606f05b35a2Smrg *.lo) 8607f05b35a2Smrg test -n "$objs$old_deplibs" && \ 8608f05b35a2Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 8609f05b35a2Smrg 8610f05b35a2Smrg libobj=$output 8611f05b35a2Smrg func_lo2o "$libobj" 8612f05b35a2Smrg obj=$func_lo2o_result 8613e0963edeSmrg ;; 8614e0963edeSmrg *) 8615f05b35a2Smrg libobj= 8616f05b35a2Smrg obj="$output" 8617e0963edeSmrg ;; 8618e0963edeSmrg esac 8619e0963edeSmrg 8620f05b35a2Smrg # Delete the old objects. 8621f05b35a2Smrg $opt_dry_run || $RM $obj $libobj 8622e0963edeSmrg 8623f05b35a2Smrg # Objects from convenience libraries. This assumes 8624f05b35a2Smrg # single-version convenience libraries. Whenever we create 8625f05b35a2Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 8626f05b35a2Smrg # the extraction. 8627f05b35a2Smrg reload_conv_objs= 8628f05b35a2Smrg gentop= 8629f05b35a2Smrg # reload_cmds runs $LD directly, so let us get rid of 8630f05b35a2Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 8631f05b35a2Smrg # turning comma into space.. 8632f05b35a2Smrg wl= 8633e0963edeSmrg 8634f05b35a2Smrg if test -n "$convenience"; then 8635f05b35a2Smrg if test -n "$whole_archive_flag_spec"; then 8636f05b35a2Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 863749e108a1Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 8638f05b35a2Smrg else 8639f05b35a2Smrg gentop="$output_objdir/${obj}x" 864067ab2ff2Smrg func_append generated " $gentop" 8641e0963edeSmrg 8642f05b35a2Smrg func_extract_archives $gentop $convenience 8643f05b35a2Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 8644f05b35a2Smrg fi 8645e0963edeSmrg fi 8646e0963edeSmrg 864767ab2ff2Smrg # If we're not building shared, we need to use non_pic_objs 864867ab2ff2Smrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 864967ab2ff2Smrg 8650f05b35a2Smrg # Create the old-style object. 865149e108a1Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 8652e0963edeSmrg 8653f05b35a2Smrg output="$obj" 8654f05b35a2Smrg func_execute_cmds "$reload_cmds" 'exit $?' 8655e0963edeSmrg 8656f05b35a2Smrg # Exit if we aren't doing a library object file. 8657f05b35a2Smrg if test -z "$libobj"; then 8658f05b35a2Smrg if test -n "$gentop"; then 8659f05b35a2Smrg func_show_eval '${RM}r "$gentop"' 8660f05b35a2Smrg fi 8661f05b35a2Smrg 8662f05b35a2Smrg exit $EXIT_SUCCESS 8663e0963edeSmrg fi 8664f05b35a2Smrg 8665f05b35a2Smrg if test "$build_libtool_libs" != yes; then 8666f05b35a2Smrg if test -n "$gentop"; then 8667f05b35a2Smrg func_show_eval '${RM}r "$gentop"' 8668f05b35a2Smrg fi 8669f05b35a2Smrg 8670f05b35a2Smrg # Create an invalid libtool object if no PIC, so that we don't 8671f05b35a2Smrg # accidentally link it into a program. 8672f05b35a2Smrg # $show "echo timestamp > $libobj" 8673f05b35a2Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 8674f05b35a2Smrg exit $EXIT_SUCCESS 8675f05b35a2Smrg fi 8676f05b35a2Smrg 8677f05b35a2Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 8678f05b35a2Smrg # Only do commands if we really have different PIC objects. 8679f05b35a2Smrg reload_objs="$libobjs $reload_conv_objs" 8680f05b35a2Smrg output="$libobj" 8681f05b35a2Smrg func_execute_cmds "$reload_cmds" 'exit $?' 8682f05b35a2Smrg fi 8683f05b35a2Smrg 8684f05b35a2Smrg if test -n "$gentop"; then 8685f05b35a2Smrg func_show_eval '${RM}r "$gentop"' 8686f05b35a2Smrg fi 8687f05b35a2Smrg 8688f05b35a2Smrg exit $EXIT_SUCCESS 8689e0963edeSmrg ;; 8690e0963edeSmrg 8691f05b35a2Smrg prog) 8692f05b35a2Smrg case $host in 8693f05b35a2Smrg *cygwin*) func_stripname '' '.exe' "$output" 8694f05b35a2Smrg output=$func_stripname_result.exe;; 8695f05b35a2Smrg esac 8696f05b35a2Smrg test -n "$vinfo" && \ 8697f05b35a2Smrg func_warning "\`-version-info' is ignored for programs" 8698e0963edeSmrg 8699f05b35a2Smrg test -n "$release" && \ 8700f05b35a2Smrg func_warning "\`-release' is ignored for programs" 8701e0963edeSmrg 8702f05b35a2Smrg test "$preload" = yes \ 8703f05b35a2Smrg && test "$dlopen_support" = unknown \ 8704f05b35a2Smrg && test "$dlopen_self" = unknown \ 8705f05b35a2Smrg && test "$dlopen_self_static" = unknown && \ 8706f05b35a2Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 8707f05b35a2Smrg 8708f05b35a2Smrg case $host in 8709f05b35a2Smrg *-*-rhapsody* | *-*-darwin1.[012]) 8710f05b35a2Smrg # On Rhapsody replace the C library is the System framework 871149e108a1Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 871249e108a1Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 8713e0963edeSmrg ;; 8714f05b35a2Smrg esac 8715e0963edeSmrg 8716f05b35a2Smrg case $host in 8717f05b35a2Smrg *-*-darwin*) 8718f05b35a2Smrg # Don't allow lazy linking, it breaks C++ global constructors 8719f05b35a2Smrg # But is supposedly fixed on 10.4 or later (yay!). 8720f05b35a2Smrg if test "$tagname" = CXX ; then 8721f05b35a2Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 8722f05b35a2Smrg 10.[0123]) 872367ab2ff2Smrg func_append compile_command " ${wl}-bind_at_load" 872467ab2ff2Smrg func_append finalize_command " ${wl}-bind_at_load" 8725f05b35a2Smrg ;; 8726f05b35a2Smrg esac 8727e0963edeSmrg fi 8728f05b35a2Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 872949e108a1Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 873049e108a1Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8731f05b35a2Smrg ;; 8732f05b35a2Smrg esac 8733e0963edeSmrg 8734e0963edeSmrg 8735f05b35a2Smrg # move library search paths that coincide with paths to not yet 8736f05b35a2Smrg # installed libraries to the beginning of the library search list 8737f05b35a2Smrg new_libs= 8738f05b35a2Smrg for path in $notinst_path; do 8739f05b35a2Smrg case " $new_libs " in 8740f05b35a2Smrg *" -L$path/$objdir "*) ;; 8741f05b35a2Smrg *) 8742f05b35a2Smrg case " $compile_deplibs " in 8743f05b35a2Smrg *" -L$path/$objdir "*) 874467ab2ff2Smrg func_append new_libs " -L$path/$objdir" ;; 8745e0963edeSmrg esac 8746f05b35a2Smrg ;; 8747f05b35a2Smrg esac 8748f05b35a2Smrg done 8749f05b35a2Smrg for deplib in $compile_deplibs; do 8750f05b35a2Smrg case $deplib in 8751f05b35a2Smrg -L*) 8752f05b35a2Smrg case " $new_libs " in 8753f05b35a2Smrg *" $deplib "*) ;; 875467ab2ff2Smrg *) func_append new_libs " $deplib" ;; 8755e0963edeSmrg esac 8756f05b35a2Smrg ;; 875767ab2ff2Smrg *) func_append new_libs " $deplib" ;; 8758f05b35a2Smrg esac 8759f05b35a2Smrg done 8760f05b35a2Smrg compile_deplibs="$new_libs" 8761e0963edeSmrg 8762e0963edeSmrg 876367ab2ff2Smrg func_append compile_command " $compile_deplibs" 876467ab2ff2Smrg func_append finalize_command " $finalize_deplibs" 8765e0963edeSmrg 8766f05b35a2Smrg if test -n "$rpath$xrpath"; then 8767f05b35a2Smrg # If the user specified any rpath flags, then add them. 8768f05b35a2Smrg for libdir in $rpath $xrpath; do 8769f05b35a2Smrg # This is the magic to use -rpath. 8770f05b35a2Smrg case "$finalize_rpath " in 8771f05b35a2Smrg *" $libdir "*) ;; 877267ab2ff2Smrg *) func_append finalize_rpath " $libdir" ;; 8773f05b35a2Smrg esac 8774f05b35a2Smrg done 8775f05b35a2Smrg fi 8776e0963edeSmrg 8777f05b35a2Smrg # Now hardcode the library paths 8778f05b35a2Smrg rpath= 8779f05b35a2Smrg hardcode_libdirs= 8780f05b35a2Smrg for libdir in $compile_rpath $finalize_rpath; do 8781f05b35a2Smrg if test -n "$hardcode_libdir_flag_spec"; then 8782f05b35a2Smrg if test -n "$hardcode_libdir_separator"; then 8783f05b35a2Smrg if test -z "$hardcode_libdirs"; then 8784f05b35a2Smrg hardcode_libdirs="$libdir" 8785f05b35a2Smrg else 8786f05b35a2Smrg # Just accumulate the unique libdirs. 8787f05b35a2Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8788f05b35a2Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8789f05b35a2Smrg ;; 8790f05b35a2Smrg *) 879167ab2ff2Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8792f05b35a2Smrg ;; 8793f05b35a2Smrg esac 8794f05b35a2Smrg fi 8795e0963edeSmrg else 8796f05b35a2Smrg eval flag=\"$hardcode_libdir_flag_spec\" 879767ab2ff2Smrg func_append rpath " $flag" 8798e0963edeSmrg fi 8799f05b35a2Smrg elif test -n "$runpath_var"; then 8800f05b35a2Smrg case "$perm_rpath " in 8801f05b35a2Smrg *" $libdir "*) ;; 880267ab2ff2Smrg *) func_append perm_rpath " $libdir" ;; 8803f05b35a2Smrg esac 8804f05b35a2Smrg fi 8805f05b35a2Smrg case $host in 8806f05b35a2Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 8807f05b35a2Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 8808f05b35a2Smrg case :$dllsearchpath: in 8809f05b35a2Smrg *":$libdir:"*) ;; 8810f05b35a2Smrg ::) dllsearchpath=$libdir;; 881167ab2ff2Smrg *) func_append dllsearchpath ":$libdir";; 8812f05b35a2Smrg esac 8813f05b35a2Smrg case :$dllsearchpath: in 8814f05b35a2Smrg *":$testbindir:"*) ;; 8815f05b35a2Smrg ::) dllsearchpath=$testbindir;; 881667ab2ff2Smrg *) func_append dllsearchpath ":$testbindir";; 8817f05b35a2Smrg esac 8818f05b35a2Smrg ;; 8819f05b35a2Smrg esac 8820f05b35a2Smrg done 8821f05b35a2Smrg # Substitute the hardcoded libdirs into the rpath. 8822f05b35a2Smrg if test -n "$hardcode_libdir_separator" && 8823f05b35a2Smrg test -n "$hardcode_libdirs"; then 8824f05b35a2Smrg libdir="$hardcode_libdirs" 8825f05b35a2Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 8826f05b35a2Smrg fi 8827f05b35a2Smrg compile_rpath="$rpath" 8828e0963edeSmrg 8829f05b35a2Smrg rpath= 8830f05b35a2Smrg hardcode_libdirs= 8831f05b35a2Smrg for libdir in $finalize_rpath; do 8832f05b35a2Smrg if test -n "$hardcode_libdir_flag_spec"; then 8833f05b35a2Smrg if test -n "$hardcode_libdir_separator"; then 8834f05b35a2Smrg if test -z "$hardcode_libdirs"; then 8835f05b35a2Smrg hardcode_libdirs="$libdir" 8836f05b35a2Smrg else 8837f05b35a2Smrg # Just accumulate the unique libdirs. 8838f05b35a2Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8839f05b35a2Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8840f05b35a2Smrg ;; 8841f05b35a2Smrg *) 884267ab2ff2Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8843f05b35a2Smrg ;; 8844f05b35a2Smrg esac 8845f05b35a2Smrg fi 8846e0963edeSmrg else 8847f05b35a2Smrg eval flag=\"$hardcode_libdir_flag_spec\" 884867ab2ff2Smrg func_append rpath " $flag" 8849e0963edeSmrg fi 8850f05b35a2Smrg elif test -n "$runpath_var"; then 8851f05b35a2Smrg case "$finalize_perm_rpath " in 8852f05b35a2Smrg *" $libdir "*) ;; 885367ab2ff2Smrg *) func_append finalize_perm_rpath " $libdir" ;; 8854f05b35a2Smrg esac 8855e0963edeSmrg fi 8856f05b35a2Smrg done 8857f05b35a2Smrg # Substitute the hardcoded libdirs into the rpath. 8858f05b35a2Smrg if test -n "$hardcode_libdir_separator" && 8859f05b35a2Smrg test -n "$hardcode_libdirs"; then 8860f05b35a2Smrg libdir="$hardcode_libdirs" 8861f05b35a2Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 8862f05b35a2Smrg fi 8863f05b35a2Smrg finalize_rpath="$rpath" 8864e0963edeSmrg 8865f05b35a2Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 8866f05b35a2Smrg # Transform all the library objects into standard objects. 886749e108a1Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 886849e108a1Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8869f05b35a2Smrg fi 8870e0963edeSmrg 8871f05b35a2Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8872e0963edeSmrg 8873f05b35a2Smrg # template prelinking step 8874f05b35a2Smrg if test -n "$prelink_cmds"; then 8875f05b35a2Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 8876f05b35a2Smrg fi 8877e0963edeSmrg 8878f05b35a2Smrg wrappers_required=yes 8879f05b35a2Smrg case $host in 888049e108a1Smrg *cegcc* | *mingw32ce*) 888149e108a1Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 888249e108a1Smrg wrappers_required=no 888349e108a1Smrg ;; 8884f05b35a2Smrg *cygwin* | *mingw* ) 8885f05b35a2Smrg if test "$build_libtool_libs" != yes; then 8886f05b35a2Smrg wrappers_required=no 8887f05b35a2Smrg fi 8888f05b35a2Smrg ;; 8889f05b35a2Smrg *) 8890f05b35a2Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 8891f05b35a2Smrg wrappers_required=no 8892f05b35a2Smrg fi 8893f05b35a2Smrg ;; 8894f05b35a2Smrg esac 8895f05b35a2Smrg if test "$wrappers_required" = no; then 8896f05b35a2Smrg # Replace the output file specification. 889749e108a1Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8898f05b35a2Smrg link_command="$compile_command$compile_rpath" 8899e0963edeSmrg 8900f05b35a2Smrg # We have no uninstalled library dependencies, so finalize right now. 8901f05b35a2Smrg exit_status=0 8902f05b35a2Smrg func_show_eval "$link_command" 'exit_status=$?' 8903e0963edeSmrg 890467ab2ff2Smrg if test -n "$postlink_cmds"; then 890567ab2ff2Smrg func_to_tool_file "$output" 890667ab2ff2Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 890767ab2ff2Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 890867ab2ff2Smrg fi 890967ab2ff2Smrg 8910f05b35a2Smrg # Delete the generated files. 8911f05b35a2Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 8912f05b35a2Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 8913e0963edeSmrg fi 8914e0963edeSmrg 8915f05b35a2Smrg exit $exit_status 8916f05b35a2Smrg fi 8917e0963edeSmrg 8918f05b35a2Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 8919f05b35a2Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 8920f05b35a2Smrg fi 8921f05b35a2Smrg if test -n "$finalize_shlibpath"; then 8922f05b35a2Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 8923f05b35a2Smrg fi 8924e0963edeSmrg 8925f05b35a2Smrg compile_var= 8926f05b35a2Smrg finalize_var= 8927f05b35a2Smrg if test -n "$runpath_var"; then 8928f05b35a2Smrg if test -n "$perm_rpath"; then 8929f05b35a2Smrg # We should set the runpath_var. 8930f05b35a2Smrg rpath= 8931f05b35a2Smrg for dir in $perm_rpath; do 893267ab2ff2Smrg func_append rpath "$dir:" 8933f05b35a2Smrg done 8934f05b35a2Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8935e0963edeSmrg fi 8936f05b35a2Smrg if test -n "$finalize_perm_rpath"; then 8937f05b35a2Smrg # We should set the runpath_var. 8938f05b35a2Smrg rpath= 8939f05b35a2Smrg for dir in $finalize_perm_rpath; do 894067ab2ff2Smrg func_append rpath "$dir:" 8941f05b35a2Smrg done 8942f05b35a2Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 8943e0963edeSmrg fi 8944f05b35a2Smrg fi 8945e0963edeSmrg 8946f05b35a2Smrg if test "$no_install" = yes; then 8947f05b35a2Smrg # We don't need to create a wrapper script. 8948f05b35a2Smrg link_command="$compile_var$compile_command$compile_rpath" 8949f05b35a2Smrg # Replace the output file specification. 895049e108a1Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8951f05b35a2Smrg # Delete the old output file. 8952f05b35a2Smrg $opt_dry_run || $RM $output 8953f05b35a2Smrg # Link the executable and exit 8954f05b35a2Smrg func_show_eval "$link_command" 'exit $?' 895567ab2ff2Smrg 895667ab2ff2Smrg if test -n "$postlink_cmds"; then 895767ab2ff2Smrg func_to_tool_file "$output" 895867ab2ff2Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 895967ab2ff2Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 896067ab2ff2Smrg fi 896167ab2ff2Smrg 8962e0963edeSmrg exit $EXIT_SUCCESS 8963f05b35a2Smrg fi 8964e0963edeSmrg 8965f05b35a2Smrg if test "$hardcode_action" = relink; then 8966f05b35a2Smrg # Fast installation is not supported 8967f05b35a2Smrg link_command="$compile_var$compile_command$compile_rpath" 8968f05b35a2Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8969f05b35a2Smrg 8970f05b35a2Smrg func_warning "this platform does not like uninstalled shared libraries" 8971f05b35a2Smrg func_warning "\`$output' will be relinked during installation" 8972f05b35a2Smrg else 8973f05b35a2Smrg if test "$fast_install" != no; then 8974f05b35a2Smrg link_command="$finalize_var$compile_command$finalize_rpath" 8975f05b35a2Smrg if test "$fast_install" = yes; then 897649e108a1Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 8977f05b35a2Smrg else 8978f05b35a2Smrg # fast_install is set to needless 8979f05b35a2Smrg relink_command= 8980f05b35a2Smrg fi 8981e0963edeSmrg else 8982f05b35a2Smrg link_command="$compile_var$compile_command$compile_rpath" 8983f05b35a2Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8984e0963edeSmrg fi 8985f05b35a2Smrg fi 8986e0963edeSmrg 8987f05b35a2Smrg # Replace the output file specification. 898849e108a1Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 8989e0963edeSmrg 8990f05b35a2Smrg # Delete the old output files. 8991f05b35a2Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 8992e0963edeSmrg 8993f05b35a2Smrg func_show_eval "$link_command" 'exit $?' 8994e0963edeSmrg 899567ab2ff2Smrg if test -n "$postlink_cmds"; then 899667ab2ff2Smrg func_to_tool_file "$output_objdir/$outputname" 899767ab2ff2Smrg 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'` 899867ab2ff2Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 899967ab2ff2Smrg fi 900067ab2ff2Smrg 9001f05b35a2Smrg # Now create the wrapper script. 9002f05b35a2Smrg func_verbose "creating $output" 9003e0963edeSmrg 9004f05b35a2Smrg # Quote the relink command for shipping. 9005f05b35a2Smrg if test -n "$relink_command"; then 9006f05b35a2Smrg # Preserve any variables that may affect compiler behavior 9007f05b35a2Smrg for var in $variables_saved_for_relink; do 9008f05b35a2Smrg if eval test -z \"\${$var+set}\"; then 9009f05b35a2Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9010f05b35a2Smrg elif eval var_value=\$$var; test -z "$var_value"; then 9011f05b35a2Smrg relink_command="$var=; export $var; $relink_command" 9012e0963edeSmrg else 9013f05b35a2Smrg func_quote_for_eval "$var_value" 9014f05b35a2Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9015e0963edeSmrg fi 9016f05b35a2Smrg done 9017f05b35a2Smrg relink_command="(cd `pwd`; $relink_command)" 901849e108a1Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9019f05b35a2Smrg fi 9020f05b35a2Smrg 9021f05b35a2Smrg # Only actually do things if not in dry run mode. 9022f05b35a2Smrg $opt_dry_run || { 9023f05b35a2Smrg # win32 will think the script is a binary if it has 9024f05b35a2Smrg # a .exe suffix, so we strip it off here. 9025f05b35a2Smrg case $output in 9026f05b35a2Smrg *.exe) func_stripname '' '.exe' "$output" 9027f05b35a2Smrg output=$func_stripname_result ;; 9028f05b35a2Smrg esac 9029f05b35a2Smrg # test for cygwin because mv fails w/o .exe extensions 9030f05b35a2Smrg case $host in 9031f05b35a2Smrg *cygwin*) 9032f05b35a2Smrg exeext=.exe 9033f05b35a2Smrg func_stripname '' '.exe' "$outputname" 9034f05b35a2Smrg outputname=$func_stripname_result ;; 9035f05b35a2Smrg *) exeext= ;; 9036e0963edeSmrg esac 9037f05b35a2Smrg case $host in 9038f05b35a2Smrg *cygwin* | *mingw* ) 9039f05b35a2Smrg func_dirname_and_basename "$output" "" "." 9040f05b35a2Smrg output_name=$func_basename_result 9041f05b35a2Smrg output_path=$func_dirname_result 9042f05b35a2Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 9043f05b35a2Smrg cwrapper="$output_path/$output_name.exe" 9044f05b35a2Smrg $RM $cwrappersource $cwrapper 9045f05b35a2Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 9046f05b35a2Smrg 9047f05b35a2Smrg func_emit_cwrapperexe_src > $cwrappersource 9048f05b35a2Smrg 9049f05b35a2Smrg # The wrapper executable is built using the $host compiler, 9050f05b35a2Smrg # because it contains $host paths and files. If cross- 9051f05b35a2Smrg # compiling, it, like the target executable, must be 9052f05b35a2Smrg # executed on the $host or under an emulation environment. 9053f05b35a2Smrg $opt_dry_run || { 9054f05b35a2Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 9055f05b35a2Smrg $STRIP $cwrapper 9056f05b35a2Smrg } 9057e0963edeSmrg 9058f05b35a2Smrg # Now, create the wrapper script for func_source use: 9059f05b35a2Smrg func_ltwrapper_scriptname $cwrapper 9060f05b35a2Smrg $RM $func_ltwrapper_scriptname_result 9061f05b35a2Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 9062f05b35a2Smrg $opt_dry_run || { 9063f05b35a2Smrg # note: this script will not be executed, so do not chmod. 9064f05b35a2Smrg if test "x$build" = "x$host" ; then 9065f05b35a2Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 9066f05b35a2Smrg else 9067f05b35a2Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 9068f05b35a2Smrg fi 9069f05b35a2Smrg } 9070f05b35a2Smrg ;; 9071f05b35a2Smrg * ) 9072f05b35a2Smrg $RM $output 9073f05b35a2Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 9074e0963edeSmrg 9075f05b35a2Smrg func_emit_wrapper no > $output 9076f05b35a2Smrg chmod +x $output 9077f05b35a2Smrg ;; 9078f05b35a2Smrg esac 9079f05b35a2Smrg } 9080f05b35a2Smrg exit $EXIT_SUCCESS 9081f05b35a2Smrg ;; 9082f05b35a2Smrg esac 9083e0963edeSmrg 9084f05b35a2Smrg # See if we need to build an old-fashioned archive. 9085f05b35a2Smrg for oldlib in $oldlibs; do 9086e0963edeSmrg 9087f05b35a2Smrg if test "$build_libtool_libs" = convenience; then 9088f05b35a2Smrg oldobjs="$libobjs_save $symfileobj" 9089f05b35a2Smrg addlibs="$convenience" 9090f05b35a2Smrg build_libtool_libs=no 9091f05b35a2Smrg else 9092f05b35a2Smrg if test "$build_libtool_libs" = module; then 9093f05b35a2Smrg oldobjs="$libobjs_save" 9094f05b35a2Smrg build_libtool_libs=no 9095f05b35a2Smrg else 9096f05b35a2Smrg oldobjs="$old_deplibs $non_pic_objects" 9097f05b35a2Smrg if test "$preload" = yes && test -f "$symfileobj"; then 909867ab2ff2Smrg func_append oldobjs " $symfileobj" 9099f05b35a2Smrg fi 9100f05b35a2Smrg fi 9101f05b35a2Smrg addlibs="$old_convenience" 9102e0963edeSmrg fi 9103e0963edeSmrg 9104f05b35a2Smrg if test -n "$addlibs"; then 9105f05b35a2Smrg gentop="$output_objdir/${outputname}x" 910667ab2ff2Smrg func_append generated " $gentop" 9107e0963edeSmrg 9108f05b35a2Smrg func_extract_archives $gentop $addlibs 910967ab2ff2Smrg func_append oldobjs " $func_extract_archives_result" 9110f05b35a2Smrg fi 9111e0963edeSmrg 9112f05b35a2Smrg # Do each command in the archive commands. 9113f05b35a2Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 9114f05b35a2Smrg cmds=$old_archive_from_new_cmds 9115f05b35a2Smrg else 9116e0963edeSmrg 9117f05b35a2Smrg # Add any objects from preloaded convenience libraries 9118f05b35a2Smrg if test -n "$dlprefiles"; then 9119f05b35a2Smrg gentop="$output_objdir/${outputname}x" 912067ab2ff2Smrg func_append generated " $gentop" 9121e0963edeSmrg 9122f05b35a2Smrg func_extract_archives $gentop $dlprefiles 912367ab2ff2Smrg func_append oldobjs " $func_extract_archives_result" 9124f05b35a2Smrg fi 9125e0963edeSmrg 9126f05b35a2Smrg # POSIX demands no paths to be encoded in archives. We have 9127f05b35a2Smrg # to avoid creating archives with duplicate basenames if we 9128f05b35a2Smrg # might have to extract them afterwards, e.g., when creating a 9129f05b35a2Smrg # static archive out of a convenience library, or when linking 9130f05b35a2Smrg # the entirety of a libtool archive into another (currently 9131f05b35a2Smrg # not supported by libtool). 9132f05b35a2Smrg if (for obj in $oldobjs 9133f05b35a2Smrg do 9134f05b35a2Smrg func_basename "$obj" 9135f05b35a2Smrg $ECHO "$func_basename_result" 9136f05b35a2Smrg done | sort | sort -uc >/dev/null 2>&1); then 9137f05b35a2Smrg : 9138f05b35a2Smrg else 913949e108a1Smrg echo "copying selected object files to avoid basename conflicts..." 9140f05b35a2Smrg gentop="$output_objdir/${outputname}x" 914167ab2ff2Smrg func_append generated " $gentop" 9142f05b35a2Smrg func_mkdir_p "$gentop" 9143f05b35a2Smrg save_oldobjs=$oldobjs 9144f05b35a2Smrg oldobjs= 9145f05b35a2Smrg counter=1 9146f05b35a2Smrg for obj in $save_oldobjs 9147f05b35a2Smrg do 9148f05b35a2Smrg func_basename "$obj" 9149f05b35a2Smrg objbase="$func_basename_result" 9150f05b35a2Smrg case " $oldobjs " in 9151f05b35a2Smrg " ") oldobjs=$obj ;; 9152f05b35a2Smrg *[\ /]"$objbase "*) 9153f05b35a2Smrg while :; do 9154f05b35a2Smrg # Make sure we don't pick an alternate name that also 9155f05b35a2Smrg # overlaps. 9156f05b35a2Smrg newobj=lt$counter-$objbase 9157f05b35a2Smrg func_arith $counter + 1 9158f05b35a2Smrg counter=$func_arith_result 9159f05b35a2Smrg case " $oldobjs " in 9160f05b35a2Smrg *[\ /]"$newobj "*) ;; 9161f05b35a2Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 9162f05b35a2Smrg esac 9163f05b35a2Smrg done 9164f05b35a2Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 916567ab2ff2Smrg func_append oldobjs " $gentop/$newobj" 9166f05b35a2Smrg ;; 916767ab2ff2Smrg *) func_append oldobjs " $obj" ;; 9168f05b35a2Smrg esac 9169e0963edeSmrg done 9170e0963edeSmrg fi 9171e494fffdSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 9172e494fffdSmrg tool_oldlib=$func_to_tool_file_result 9173f05b35a2Smrg eval cmds=\"$old_archive_cmds\" 9174e0963edeSmrg 9175f05b35a2Smrg func_len " $cmds" 9176f05b35a2Smrg len=$func_len_result 9177f05b35a2Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9178f05b35a2Smrg cmds=$old_archive_cmds 917967ab2ff2Smrg elif test -n "$archiver_list_spec"; then 918067ab2ff2Smrg func_verbose "using command file archive linking..." 918167ab2ff2Smrg for obj in $oldobjs 918267ab2ff2Smrg do 918367ab2ff2Smrg func_to_tool_file "$obj" 918467ab2ff2Smrg $ECHO "$func_to_tool_file_result" 918567ab2ff2Smrg done > $output_objdir/$libname.libcmd 918667ab2ff2Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 918767ab2ff2Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 918867ab2ff2Smrg cmds=$old_archive_cmds 9189f05b35a2Smrg else 9190f05b35a2Smrg # the command line is too long to link in one step, link in parts 9191f05b35a2Smrg func_verbose "using piecewise archive linking..." 9192f05b35a2Smrg save_RANLIB=$RANLIB 9193f05b35a2Smrg RANLIB=: 9194f05b35a2Smrg objlist= 9195f05b35a2Smrg concat_cmds= 9196f05b35a2Smrg save_oldobjs=$oldobjs 9197f05b35a2Smrg oldobjs= 9198f05b35a2Smrg # Is there a better way of finding the last object in the list? 9199f05b35a2Smrg for obj in $save_oldobjs 9200f05b35a2Smrg do 9201f05b35a2Smrg last_oldobj=$obj 9202f05b35a2Smrg done 9203f05b35a2Smrg eval test_cmds=\"$old_archive_cmds\" 9204f05b35a2Smrg func_len " $test_cmds" 9205f05b35a2Smrg len0=$func_len_result 9206f05b35a2Smrg len=$len0 9207f05b35a2Smrg for obj in $save_oldobjs 9208f05b35a2Smrg do 9209f05b35a2Smrg func_len " $obj" 9210f05b35a2Smrg func_arith $len + $func_len_result 9211f05b35a2Smrg len=$func_arith_result 9212f05b35a2Smrg func_append objlist " $obj" 9213f05b35a2Smrg if test "$len" -lt "$max_cmd_len"; then 9214f05b35a2Smrg : 9215f05b35a2Smrg else 9216f05b35a2Smrg # the above command should be used before it gets too long 9217f05b35a2Smrg oldobjs=$objlist 9218f05b35a2Smrg if test "$obj" = "$last_oldobj" ; then 9219f05b35a2Smrg RANLIB=$save_RANLIB 9220f05b35a2Smrg fi 9221f05b35a2Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9222f05b35a2Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 9223f05b35a2Smrg objlist= 9224f05b35a2Smrg len=$len0 9225f05b35a2Smrg fi 9226f05b35a2Smrg done 9227f05b35a2Smrg RANLIB=$save_RANLIB 9228f05b35a2Smrg oldobjs=$objlist 9229f05b35a2Smrg if test "X$oldobjs" = "X" ; then 9230f05b35a2Smrg eval cmds=\"\$concat_cmds\" 9231f05b35a2Smrg else 9232f05b35a2Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 9233f05b35a2Smrg fi 9234f05b35a2Smrg fi 9235f05b35a2Smrg fi 9236f05b35a2Smrg func_execute_cmds "$cmds" 'exit $?' 9237e0963edeSmrg done 9238e0963edeSmrg 9239f05b35a2Smrg test -n "$generated" && \ 9240f05b35a2Smrg func_show_eval "${RM}r$generated" 9241e0963edeSmrg 9242f05b35a2Smrg # Now create the libtool archive. 9243f05b35a2Smrg case $output in 9244f05b35a2Smrg *.la) 9245f05b35a2Smrg old_library= 9246f05b35a2Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 9247f05b35a2Smrg func_verbose "creating $output" 9248e0963edeSmrg 9249f05b35a2Smrg # Preserve any variables that may affect compiler behavior 9250f05b35a2Smrg for var in $variables_saved_for_relink; do 9251f05b35a2Smrg if eval test -z \"\${$var+set}\"; then 9252f05b35a2Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9253f05b35a2Smrg elif eval var_value=\$$var; test -z "$var_value"; then 9254f05b35a2Smrg relink_command="$var=; export $var; $relink_command" 9255e0963edeSmrg else 9256f05b35a2Smrg func_quote_for_eval "$var_value" 9257f05b35a2Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9258e0963edeSmrg fi 9259f05b35a2Smrg done 9260f05b35a2Smrg # Quote the link command for shipping. 9261f05b35a2Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 926249e108a1Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9263f05b35a2Smrg if test "$hardcode_automatic" = yes ; then 9264f05b35a2Smrg relink_command= 9265f05b35a2Smrg fi 9266e0963edeSmrg 9267f05b35a2Smrg # Only create the output if not a dry run. 9268f05b35a2Smrg $opt_dry_run || { 9269f05b35a2Smrg for installed in no yes; do 9270f05b35a2Smrg if test "$installed" = yes; then 9271f05b35a2Smrg if test -z "$install_libdir"; then 9272f05b35a2Smrg break 9273f05b35a2Smrg fi 9274f05b35a2Smrg output="$output_objdir/$outputname"i 9275f05b35a2Smrg # Replace all uninstalled libtool libraries with the installed ones 9276f05b35a2Smrg newdependency_libs= 9277f05b35a2Smrg for deplib in $dependency_libs; do 9278f05b35a2Smrg case $deplib in 9279f05b35a2Smrg *.la) 9280f05b35a2Smrg func_basename "$deplib" 9281f05b35a2Smrg name="$func_basename_result" 9282e494fffdSmrg func_resolve_sysroot "$deplib" 9283e494fffdSmrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 9284f05b35a2Smrg test -z "$libdir" && \ 9285f05b35a2Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 928667ab2ff2Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 928767ab2ff2Smrg ;; 928867ab2ff2Smrg -L*) 928967ab2ff2Smrg func_stripname -L '' "$deplib" 929067ab2ff2Smrg func_replace_sysroot "$func_stripname_result" 929167ab2ff2Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 929267ab2ff2Smrg ;; 929367ab2ff2Smrg -R*) 929467ab2ff2Smrg func_stripname -R '' "$deplib" 929567ab2ff2Smrg func_replace_sysroot "$func_stripname_result" 929667ab2ff2Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 9297f05b35a2Smrg ;; 929867ab2ff2Smrg *) func_append newdependency_libs " $deplib" ;; 9299f05b35a2Smrg esac 9300f05b35a2Smrg done 9301f05b35a2Smrg dependency_libs="$newdependency_libs" 9302f05b35a2Smrg newdlfiles= 9303f05b35a2Smrg 9304f05b35a2Smrg for lib in $dlfiles; do 9305f05b35a2Smrg case $lib in 9306f05b35a2Smrg *.la) 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 newdlfiles " ${lt_sysroot:+=}$libdir/$name" 9313f05b35a2Smrg ;; 931467ab2ff2Smrg *) func_append newdlfiles " $lib" ;; 9315f05b35a2Smrg esac 9316f05b35a2Smrg done 9317f05b35a2Smrg dlfiles="$newdlfiles" 9318f05b35a2Smrg newdlprefiles= 9319f05b35a2Smrg for lib in $dlprefiles; do 9320f05b35a2Smrg case $lib in 9321f05b35a2Smrg *.la) 9322f05b35a2Smrg # Only pass preopened files to the pseudo-archive (for 9323f05b35a2Smrg # eventual linking with the app. that links it) if we 9324f05b35a2Smrg # didn't already link the preopened objects directly into 9325f05b35a2Smrg # the library: 9326f05b35a2Smrg func_basename "$lib" 9327f05b35a2Smrg name="$func_basename_result" 9328f05b35a2Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9329f05b35a2Smrg test -z "$libdir" && \ 9330f05b35a2Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 933167ab2ff2Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 9332f05b35a2Smrg ;; 9333f05b35a2Smrg esac 9334f05b35a2Smrg done 9335f05b35a2Smrg dlprefiles="$newdlprefiles" 9336f05b35a2Smrg else 9337f05b35a2Smrg newdlfiles= 9338f05b35a2Smrg for lib in $dlfiles; do 9339f05b35a2Smrg case $lib in 9340f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9341f05b35a2Smrg *) abs=`pwd`"/$lib" ;; 9342f05b35a2Smrg esac 934367ab2ff2Smrg func_append newdlfiles " $abs" 9344f05b35a2Smrg done 9345f05b35a2Smrg dlfiles="$newdlfiles" 9346f05b35a2Smrg newdlprefiles= 9347f05b35a2Smrg for lib in $dlprefiles; do 9348f05b35a2Smrg case $lib in 9349f05b35a2Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9350f05b35a2Smrg *) abs=`pwd`"/$lib" ;; 9351f05b35a2Smrg esac 935267ab2ff2Smrg func_append newdlprefiles " $abs" 9353f05b35a2Smrg done 9354f05b35a2Smrg dlprefiles="$newdlprefiles" 9355f05b35a2Smrg fi 9356f05b35a2Smrg $RM $output 9357f05b35a2Smrg # place dlname in correct position for cygwin 935849e108a1Smrg # In fact, it would be nice if we could use this code for all target 935949e108a1Smrg # systems that can't hard-code library paths into their executables 936049e108a1Smrg # and that have no shared library path variable independent of PATH, 936149e108a1Smrg # but it turns out we can't easily determine that from inspecting 936249e108a1Smrg # libtool variables, so we have to hard-code the OSs to which it 936349e108a1Smrg # applies here; at the moment, that means platforms that use the PE 936449e108a1Smrg # object format with DLL files. See the long comment at the top of 936549e108a1Smrg # tests/bindir.at for full details. 9366f05b35a2Smrg tdlname=$dlname 9367f05b35a2Smrg case $host,$output,$installed,$module,$dlname in 936849e108a1Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 936949e108a1Smrg # If a -bindir argument was supplied, place the dll there. 937049e108a1Smrg if test "x$bindir" != x ; 937149e108a1Smrg then 937249e108a1Smrg func_relative_path "$install_libdir" "$bindir" 937349e108a1Smrg tdlname=$func_relative_path_result$dlname 937449e108a1Smrg else 937549e108a1Smrg # Otherwise fall back on heuristic. 937649e108a1Smrg tdlname=../bin/$dlname 937749e108a1Smrg fi 937849e108a1Smrg ;; 9379f05b35a2Smrg esac 9380f05b35a2Smrg $ECHO > $output "\ 9381f05b35a2Smrg# $outputname - a libtool library file 9382f05b35a2Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 9383f05b35a2Smrg# 9384f05b35a2Smrg# Please DO NOT delete this file! 9385f05b35a2Smrg# It is necessary for linking the library. 9386e0963edeSmrg 9387f05b35a2Smrg# The name that we can dlopen(3). 9388f05b35a2Smrgdlname='$tdlname' 9389e0963edeSmrg 9390f05b35a2Smrg# Names of this library. 9391f05b35a2Smrglibrary_names='$library_names' 9392e0963edeSmrg 9393f05b35a2Smrg# The name of the static archive. 9394f05b35a2Smrgold_library='$old_library' 9395e0963edeSmrg 9396f05b35a2Smrg# Linker flags that can not go in dependency_libs. 9397f05b35a2Smrginherited_linker_flags='$new_inherited_linker_flags' 9398e0963edeSmrg 9399f05b35a2Smrg# Libraries that this one depends upon. 9400f05b35a2Smrgdependency_libs='$dependency_libs' 9401e0963edeSmrg 9402f05b35a2Smrg# Names of additional weak libraries provided by this library 9403f05b35a2Smrgweak_library_names='$weak_libs' 9404e0963edeSmrg 9405f05b35a2Smrg# Version information for $libname. 9406f05b35a2Smrgcurrent=$current 9407f05b35a2Smrgage=$age 9408f05b35a2Smrgrevision=$revision 9409e0963edeSmrg 9410f05b35a2Smrg# Is this an already installed library? 9411f05b35a2Smrginstalled=$installed 9412e0963edeSmrg 9413f05b35a2Smrg# Should we warn about portability when linking against -modules? 9414f05b35a2Smrgshouldnotlink=$module 9415e0963edeSmrg 9416f05b35a2Smrg# Files to dlopen/dlpreopen 9417f05b35a2Smrgdlopen='$dlfiles' 9418f05b35a2Smrgdlpreopen='$dlprefiles' 9419e0963edeSmrg 9420f05b35a2Smrg# Directory that this library needs to be installed in: 9421f05b35a2Smrglibdir='$install_libdir'" 9422f05b35a2Smrg if test "$installed" = no && test "$need_relink" = yes; then 9423f05b35a2Smrg $ECHO >> $output "\ 9424f05b35a2Smrgrelink_command=\"$relink_command\"" 9425f05b35a2Smrg fi 9426f05b35a2Smrg done 9427f05b35a2Smrg } 9428e0963edeSmrg 9429f05b35a2Smrg # Do a symbolic link so that the libtool archive can be found in 9430f05b35a2Smrg # LD_LIBRARY_PATH before the program is installed. 9431f05b35a2Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 9432f05b35a2Smrg ;; 9433f05b35a2Smrg esac 9434f05b35a2Smrg exit $EXIT_SUCCESS 9435f05b35a2Smrg} 9436e0963edeSmrg 943767ab2ff2Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 9438f05b35a2Smrg func_mode_link ${1+"$@"} 9439e0963edeSmrg 9440e0963edeSmrg 9441f05b35a2Smrg# func_mode_uninstall arg... 9442f05b35a2Smrgfunc_mode_uninstall () 9443f05b35a2Smrg{ 9444f05b35a2Smrg $opt_debug 9445f05b35a2Smrg RM="$nonopt" 9446e0963edeSmrg files= 9447e0963edeSmrg rmforce= 9448e0963edeSmrg exit_status=0 9449e0963edeSmrg 9450e0963edeSmrg # This variable tells wrapper scripts just to set variables rather 9451e0963edeSmrg # than running their programs. 9452e0963edeSmrg libtool_install_magic="$magic" 9453e0963edeSmrg 9454e0963edeSmrg for arg 9455e0963edeSmrg do 9456e0963edeSmrg case $arg in 945767ab2ff2Smrg -f) func_append RM " $arg"; rmforce=yes ;; 945867ab2ff2Smrg -*) func_append RM " $arg" ;; 945967ab2ff2Smrg *) func_append files " $arg" ;; 9460e0963edeSmrg esac 9461e0963edeSmrg done 9462e0963edeSmrg 9463f05b35a2Smrg test -z "$RM" && \ 9464f05b35a2Smrg func_fatal_help "you must specify an RM program" 9465e0963edeSmrg 9466e0963edeSmrg rmdirs= 9467e0963edeSmrg 9468e0963edeSmrg for file in $files; do 9469f05b35a2Smrg func_dirname "$file" "" "." 9470f05b35a2Smrg dir="$func_dirname_result" 9471f05b35a2Smrg if test "X$dir" = X.; then 947267ab2ff2Smrg odir="$objdir" 9473e0963edeSmrg else 947467ab2ff2Smrg odir="$dir/$objdir" 9475e0963edeSmrg fi 9476f05b35a2Smrg func_basename "$file" 9477f05b35a2Smrg name="$func_basename_result" 947867ab2ff2Smrg test "$opt_mode" = uninstall && odir="$dir" 9479e0963edeSmrg 948067ab2ff2Smrg # Remember odir for removal later, being careful to avoid duplicates 948167ab2ff2Smrg if test "$opt_mode" = clean; then 9482e0963edeSmrg case " $rmdirs " in 948367ab2ff2Smrg *" $odir "*) ;; 948467ab2ff2Smrg *) func_append rmdirs " $odir" ;; 9485e0963edeSmrg esac 9486e0963edeSmrg fi 9487e0963edeSmrg 9488e0963edeSmrg # Don't error if the file doesn't exist and rm -f was used. 9489f05b35a2Smrg if { test -L "$file"; } >/dev/null 2>&1 || 9490f05b35a2Smrg { test -h "$file"; } >/dev/null 2>&1 || 9491f05b35a2Smrg test -f "$file"; then 9492e0963edeSmrg : 9493e0963edeSmrg elif test -d "$file"; then 9494e0963edeSmrg exit_status=1 9495e0963edeSmrg continue 9496e0963edeSmrg elif test "$rmforce" = yes; then 9497e0963edeSmrg continue 9498e0963edeSmrg fi 9499e0963edeSmrg 9500e0963edeSmrg rmfiles="$file" 9501e0963edeSmrg 9502e0963edeSmrg case $name in 9503e0963edeSmrg *.la) 9504e0963edeSmrg # Possibly a libtool archive, so verify it. 9505f05b35a2Smrg if func_lalib_p "$file"; then 9506f05b35a2Smrg func_source $dir/$name 9507e0963edeSmrg 9508e0963edeSmrg # Delete the libtool libraries and symlinks. 9509e0963edeSmrg for n in $library_names; do 951067ab2ff2Smrg func_append rmfiles " $odir/$n" 9511e0963edeSmrg done 951267ab2ff2Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 9513e0963edeSmrg 951467ab2ff2Smrg case "$opt_mode" in 9515e0963edeSmrg clean) 951667ab2ff2Smrg case " $library_names " in 9517e0963edeSmrg *" $dlname "*) ;; 951867ab2ff2Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 9519e0963edeSmrg esac 952067ab2ff2Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 9521e0963edeSmrg ;; 9522e0963edeSmrg uninstall) 9523e0963edeSmrg if test -n "$library_names"; then 9524e0963edeSmrg # Do each command in the postuninstall commands. 9525f05b35a2Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9526e0963edeSmrg fi 9527e0963edeSmrg 9528e0963edeSmrg if test -n "$old_library"; then 9529e0963edeSmrg # Do each command in the old_postuninstall commands. 9530f05b35a2Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9531e0963edeSmrg fi 9532e0963edeSmrg # FIXME: should reinstall the best remaining shared library. 9533e0963edeSmrg ;; 9534e0963edeSmrg esac 9535e0963edeSmrg fi 9536e0963edeSmrg ;; 9537e0963edeSmrg 9538e0963edeSmrg *.lo) 9539e0963edeSmrg # Possibly a libtool object, so verify it. 9540f05b35a2Smrg if func_lalib_p "$file"; then 9541e0963edeSmrg 9542e0963edeSmrg # Read the .lo file 9543f05b35a2Smrg func_source $dir/$name 9544e0963edeSmrg 9545e0963edeSmrg # Add PIC object to the list of files to remove. 9546f05b35a2Smrg if test -n "$pic_object" && 9547f05b35a2Smrg test "$pic_object" != none; then 954867ab2ff2Smrg func_append rmfiles " $dir/$pic_object" 9549e0963edeSmrg fi 9550e0963edeSmrg 9551e0963edeSmrg # Add non-PIC object to the list of files to remove. 9552f05b35a2Smrg if test -n "$non_pic_object" && 9553f05b35a2Smrg test "$non_pic_object" != none; then 955467ab2ff2Smrg func_append rmfiles " $dir/$non_pic_object" 9555e0963edeSmrg fi 9556e0963edeSmrg fi 9557e0963edeSmrg ;; 9558e0963edeSmrg 9559e0963edeSmrg *) 956067ab2ff2Smrg if test "$opt_mode" = clean ; then 9561e0963edeSmrg noexename=$name 9562e0963edeSmrg case $file in 9563e0963edeSmrg *.exe) 9564f05b35a2Smrg func_stripname '' '.exe' "$file" 9565f05b35a2Smrg file=$func_stripname_result 9566f05b35a2Smrg func_stripname '' '.exe' "$name" 9567f05b35a2Smrg noexename=$func_stripname_result 9568e0963edeSmrg # $file with .exe has already been added to rmfiles, 9569e0963edeSmrg # add $file without .exe 957067ab2ff2Smrg func_append rmfiles " $file" 9571e0963edeSmrg ;; 9572e0963edeSmrg esac 9573e0963edeSmrg # Do a test to see if this is a libtool program. 9574f05b35a2Smrg if func_ltwrapper_p "$file"; then 9575f05b35a2Smrg if func_ltwrapper_executable_p "$file"; then 9576f05b35a2Smrg func_ltwrapper_scriptname "$file" 9577f05b35a2Smrg relink_command= 9578f05b35a2Smrg func_source $func_ltwrapper_scriptname_result 957967ab2ff2Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 9580f05b35a2Smrg else 9581f05b35a2Smrg relink_command= 9582f05b35a2Smrg func_source $dir/$noexename 9583f05b35a2Smrg fi 9584e0963edeSmrg 9585e0963edeSmrg # note $name still contains .exe if it was in $file originally 9586e0963edeSmrg # as does the version of $file that was added into $rmfiles 958767ab2ff2Smrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9588e0963edeSmrg if test "$fast_install" = yes && test -n "$relink_command"; then 958967ab2ff2Smrg func_append rmfiles " $odir/lt-$name" 9590e0963edeSmrg fi 9591e0963edeSmrg if test "X$noexename" != "X$name" ; then 959267ab2ff2Smrg func_append rmfiles " $odir/lt-${noexename}.c" 9593e0963edeSmrg fi 9594e0963edeSmrg fi 9595e0963edeSmrg fi 9596e0963edeSmrg ;; 9597e0963edeSmrg esac 9598f05b35a2Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 9599e0963edeSmrg done 9600e0963edeSmrg 9601e0963edeSmrg # Try to remove the ${objdir}s in the directories where we deleted files 9602e0963edeSmrg for dir in $rmdirs; do 9603e0963edeSmrg if test -d "$dir"; then 9604f05b35a2Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 9605e0963edeSmrg fi 9606e0963edeSmrg done 9607e0963edeSmrg 9608e0963edeSmrg exit $exit_status 9609f05b35a2Smrg} 9610e0963edeSmrg 961167ab2ff2Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 9612f05b35a2Smrg func_mode_uninstall ${1+"$@"} 9613e0963edeSmrg 961467ab2ff2Smrgtest -z "$opt_mode" && { 9615f05b35a2Smrg help="$generic_help" 9616f05b35a2Smrg func_fatal_help "you must specify a MODE" 9617f05b35a2Smrg} 9618f05b35a2Smrg 9619f05b35a2Smrgtest -z "$exec_cmd" && \ 962067ab2ff2Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 9621e0963edeSmrg 9622e0963edeSmrgif test -n "$exec_cmd"; then 9623f05b35a2Smrg eval exec "$exec_cmd" 9624e0963edeSmrg exit $EXIT_FAILURE 9625e0963edeSmrgfi 9626e0963edeSmrg 9627f05b35a2Smrgexit $exit_status 9628e0963edeSmrg 9629e0963edeSmrg 9630e0963edeSmrg# The TAGs below are defined such that we never get into a situation 9631e0963edeSmrg# in which we disable both kinds of libraries. Given conflicting 9632e0963edeSmrg# choices, we go for a static library, that is the most portable, 9633e0963edeSmrg# since we can't tell whether shared libraries were disabled because 9634e0963edeSmrg# the user asked for that or because the platform doesn't support 9635e0963edeSmrg# them. This is particularly important on AIX, because we don't 9636e0963edeSmrg# support having both static and shared libraries enabled at the same 9637e0963edeSmrg# time on that platform, so we default to a shared-only configuration. 9638e0963edeSmrg# If a disable-shared tag is given, we'll fallback to a static-only 9639e0963edeSmrg# configuration. But we'll never go from static-only to shared-only. 9640e0963edeSmrg 9641e0963edeSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 9642f05b35a2Smrgbuild_libtool_libs=no 9643f05b35a2Smrgbuild_old_libs=yes 9644e0963edeSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 9645e0963edeSmrg 9646e0963edeSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 9647f05b35a2Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 9648e0963edeSmrg# ### END LIBTOOL TAG CONFIG: disable-static 9649e0963edeSmrg 9650e0963edeSmrg# Local Variables: 9651e0963edeSmrg# mode:shell-script 9652e0963edeSmrg# sh-indentation:2 9653e0963edeSmrg# End: 9654f05b35a2Smrg# vi:sw=2 9655f05b35a2Smrg 9656