ltmain.sh revision 42a55b46
142a55b46Smrg 242a55b46Smrg# libtool (GNU libtool) 2.4.2 342a55b46Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 442a55b46Smrg 5c582b7e3Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 642a55b46Smrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 742a55b46Smrg# This is free software; see the source for copying conditions. There is NO 842a55b46Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 942a55b46Smrg 1042a55b46Smrg# GNU Libtool is free software; you can redistribute it and/or modify 11c582b7e3Smrg# it under the terms of the GNU General Public License as published by 12c582b7e3Smrg# the Free Software Foundation; either version 2 of the License, or 13c582b7e3Smrg# (at your option) any later version. 14c582b7e3Smrg# 1542a55b46Smrg# As a special exception to the GNU General Public License, 1642a55b46Smrg# if you distribute this file as part of a program or library that 1742a55b46Smrg# is built using GNU Libtool, you may include this file under the 1842a55b46Smrg# same distribution terms that you use for the rest of that program. 1942a55b46Smrg# 2042a55b46Smrg# GNU Libtool is distributed in the hope that it will be useful, but 21c582b7e3Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 22c582b7e3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23c582b7e3Smrg# General Public License for more details. 24c582b7e3Smrg# 25c582b7e3Smrg# You should have received a copy of the GNU General Public License 2642a55b46Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 2742a55b46Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 2842a55b46Smrg# or obtained by writing to the Free Software Foundation, Inc., 2942a55b46Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 30c582b7e3Smrg 3142a55b46Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 3242a55b46Smrg# 3342a55b46Smrg# Provide generalized library-building support services. 3442a55b46Smrg# 3542a55b46Smrg# --config show all configuration variables 3642a55b46Smrg# --debug enable verbose shell tracing 3742a55b46Smrg# -n, --dry-run display commands without modifying any files 3842a55b46Smrg# --features display basic configuration information and exit 3942a55b46Smrg# --mode=MODE use operation mode MODE 4042a55b46Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 4142a55b46Smrg# --quiet, --silent don't print informational messages 4242a55b46Smrg# --no-quiet, --no-silent 4342a55b46Smrg# print informational messages (default) 4442a55b46Smrg# --no-warn don't display warning messages 4542a55b46Smrg# --tag=TAG use configuration variables from tag TAG 4642a55b46Smrg# -v, --verbose print more informational messages than default 4742a55b46Smrg# --no-verbose don't print the extra informational messages 4842a55b46Smrg# --version print version information 4942a55b46Smrg# -h, --help, --help-all print short, long, or detailed help message 5042a55b46Smrg# 5142a55b46Smrg# MODE must be one of the following: 5242a55b46Smrg# 5342a55b46Smrg# clean remove files from the build directory 5442a55b46Smrg# compile compile a source file into a libtool object 5542a55b46Smrg# execute automatically set library path, then run a program 5642a55b46Smrg# finish complete the installation of libtool libraries 5742a55b46Smrg# install install libraries or executables 5842a55b46Smrg# link create a library or an executable 5942a55b46Smrg# uninstall remove libraries from an installed directory 6042a55b46Smrg# 6142a55b46Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 6242a55b46Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 6342a55b46Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 6442a55b46Smrg# 6542a55b46Smrg# When reporting a bug, please describe a test case to reproduce it and 6642a55b46Smrg# include the following information: 6742a55b46Smrg# 6842a55b46Smrg# host-triplet: $host 6942a55b46Smrg# shell: $SHELL 7042a55b46Smrg# compiler: $LTCC 7142a55b46Smrg# compiler flags: $LTCFLAGS 7242a55b46Smrg# linker: $LD (gnu? $with_gnu_ld) 7342a55b46Smrg# $progname: (GNU libtool) 2.4.2 7442a55b46Smrg# automake: $automake_version 7542a55b46Smrg# autoconf: $autoconf_version 7642a55b46Smrg# 7742a55b46Smrg# Report bugs to <bug-libtool@gnu.org>. 7842a55b46Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 7942a55b46Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 80c582b7e3Smrg 8142a55b46SmrgPROGRAM=libtool 82c582b7e3SmrgPACKAGE=libtool 8342a55b46SmrgVERSION=2.4.2 8442a55b46SmrgTIMESTAMP="" 8542a55b46Smrgpackage_revision=1.3337 86c582b7e3Smrg 8742a55b46Smrg# Be Bourne compatible 88c582b7e3Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 89c582b7e3Smrg emulate sh 90c582b7e3Smrg NULLCMD=: 91c582b7e3Smrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 92c582b7e3Smrg # is contrary to our usage. Disable this feature. 93c582b7e3Smrg alias -g '${1+"$@"}'='"$@"' 94c582b7e3Smrg setopt NO_GLOB_SUBST 95c582b7e3Smrgelse 96c582b7e3Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 97c582b7e3Smrgfi 98c582b7e3SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 99c582b7e3SmrgDUALCASE=1; export DUALCASE # for MKS sh 100c582b7e3Smrg 10142a55b46Smrg# A function that is used when there is no print builtin or printf. 10242a55b46Smrgfunc_fallback_echo () 10342a55b46Smrg{ 10442a55b46Smrg eval 'cat <<_LTECHO_EOF 10542a55b46Smrg$1 10642a55b46Smrg_LTECHO_EOF' 10742a55b46Smrg} 108c582b7e3Smrg 10942a55b46Smrg# NLS nuisances: We save the old values to restore during execute mode. 11042a55b46Smrglt_user_locale= 11142a55b46Smrglt_safe_locale= 11219019ffeSmrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 113c582b7e3Smrgdo 114c582b7e3Smrg eval "if test \"\${$lt_var+set}\" = set; then 11542a55b46Smrg save_$lt_var=\$$lt_var 11642a55b46Smrg $lt_var=C 117c582b7e3Smrg export $lt_var 11842a55b46Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 11942a55b46Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 120c582b7e3Smrg fi" 121c582b7e3Smrgdone 12242a55b46SmrgLC_ALL=C 12342a55b46SmrgLANGUAGE=C 12442a55b46Smrgexport LANGUAGE LC_ALL 12542a55b46Smrg 12642a55b46Smrg$lt_unset CDPATH 127c582b7e3Smrg 12842a55b46Smrg 12942a55b46Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 13042a55b46Smrg# is ksh but when the shell is invoked as "sh" and the current value of 13142a55b46Smrg# the _XPG environment variable is not equal to 1 (one), the special 13242a55b46Smrg# positional parameter $0, within a function call, is the name of the 13342a55b46Smrg# function. 13442a55b46Smrgprogpath="$0" 13542a55b46Smrg 13642a55b46Smrg 13742a55b46Smrg 13842a55b46Smrg: ${CP="cp -f"} 13942a55b46Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 14042a55b46Smrg: ${MAKE="make"} 14142a55b46Smrg: ${MKDIR="mkdir"} 14242a55b46Smrg: ${MV="mv -f"} 14342a55b46Smrg: ${RM="rm -f"} 14442a55b46Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 14542a55b46Smrg: ${Xsed="$SED -e 1s/^X//"} 14642a55b46Smrg 14742a55b46Smrg# Global variables: 14842a55b46SmrgEXIT_SUCCESS=0 14942a55b46SmrgEXIT_FAILURE=1 15042a55b46SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 15142a55b46SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 15242a55b46Smrg 15342a55b46Smrgexit_status=$EXIT_SUCCESS 15419019ffeSmrg 155c582b7e3Smrg# Make sure IFS has a sensible default 156c582b7e3Smrglt_nl=' 157c582b7e3Smrg' 158c582b7e3SmrgIFS=" $lt_nl" 159c582b7e3Smrg 16042a55b46Smrgdirname="s,/[^/]*$,," 16142a55b46Smrgbasename="s,^.*/,," 162c582b7e3Smrg 16342a55b46Smrg# func_dirname file append nondir_replacement 16442a55b46Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 16542a55b46Smrg# otherwise set result to NONDIR_REPLACEMENT. 16642a55b46Smrgfunc_dirname () 16742a55b46Smrg{ 16842a55b46Smrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 16942a55b46Smrg if test "X$func_dirname_result" = "X${1}"; then 17042a55b46Smrg func_dirname_result="${3}" 17142a55b46Smrg else 17242a55b46Smrg func_dirname_result="$func_dirname_result${2}" 17342a55b46Smrg fi 17442a55b46Smrg} # func_dirname may be replaced by extended shell implementation 17542a55b46Smrg 17642a55b46Smrg 17742a55b46Smrg# func_basename file 17842a55b46Smrgfunc_basename () 17942a55b46Smrg{ 18042a55b46Smrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 18142a55b46Smrg} # func_basename may be replaced by extended shell implementation 18242a55b46Smrg 18342a55b46Smrg 18442a55b46Smrg# func_dirname_and_basename file append nondir_replacement 18542a55b46Smrg# perform func_basename and func_dirname in a single function 18642a55b46Smrg# call: 18742a55b46Smrg# dirname: Compute the dirname of FILE. If nonempty, 18842a55b46Smrg# add APPEND to the result, otherwise set result 18942a55b46Smrg# to NONDIR_REPLACEMENT. 19042a55b46Smrg# value returned in "$func_dirname_result" 19142a55b46Smrg# basename: Compute filename of FILE. 19242a55b46Smrg# value retuned in "$func_basename_result" 19342a55b46Smrg# Implementation must be kept synchronized with func_dirname 19442a55b46Smrg# and func_basename. For efficiency, we do not delegate to 19542a55b46Smrg# those functions but instead duplicate the functionality here. 19642a55b46Smrgfunc_dirname_and_basename () 19742a55b46Smrg{ 19842a55b46Smrg # Extract subdirectory from the argument. 19942a55b46Smrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 20042a55b46Smrg if test "X$func_dirname_result" = "X${1}"; then 20142a55b46Smrg func_dirname_result="${3}" 20242a55b46Smrg else 20342a55b46Smrg func_dirname_result="$func_dirname_result${2}" 20442a55b46Smrg fi 20542a55b46Smrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 20642a55b46Smrg} # func_dirname_and_basename may be replaced by extended shell implementation 20742a55b46Smrg 20842a55b46Smrg 20942a55b46Smrg# func_stripname prefix suffix name 21042a55b46Smrg# strip PREFIX and SUFFIX off of NAME. 21142a55b46Smrg# PREFIX and SUFFIX must not contain globbing or regex special 21242a55b46Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 21342a55b46Smrg# dot (in which case that matches only a dot). 21442a55b46Smrg# func_strip_suffix prefix name 21542a55b46Smrgfunc_stripname () 21642a55b46Smrg{ 21742a55b46Smrg case ${2} in 21842a55b46Smrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 21942a55b46Smrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 22042a55b46Smrg esac 22142a55b46Smrg} # func_stripname may be replaced by extended shell implementation 22242a55b46Smrg 22342a55b46Smrg 22442a55b46Smrg# These SED scripts presuppose an absolute path with a trailing slash. 22542a55b46Smrgpathcar='s,^/\([^/]*\).*$,\1,' 22642a55b46Smrgpathcdr='s,^/[^/]*,,' 22742a55b46Smrgremovedotparts=':dotsl 22842a55b46Smrg s@/\./@/@g 22942a55b46Smrg t dotsl 23042a55b46Smrg s,/\.$,/,' 23142a55b46Smrgcollapseslashes='s@/\{1,\}@/@g' 23242a55b46Smrgfinalslash='s,/*$,/,' 23342a55b46Smrg 23442a55b46Smrg# func_normal_abspath PATH 23542a55b46Smrg# Remove doubled-up and trailing slashes, "." path components, 23642a55b46Smrg# and cancel out any ".." path components in PATH after making 23742a55b46Smrg# it an absolute path. 23842a55b46Smrg# value returned in "$func_normal_abspath_result" 23942a55b46Smrgfunc_normal_abspath () 24042a55b46Smrg{ 24142a55b46Smrg # Start from root dir and reassemble the path. 24242a55b46Smrg func_normal_abspath_result= 24342a55b46Smrg func_normal_abspath_tpath=$1 24442a55b46Smrg func_normal_abspath_altnamespace= 24542a55b46Smrg case $func_normal_abspath_tpath in 24642a55b46Smrg "") 24742a55b46Smrg # Empty path, that just means $cwd. 24842a55b46Smrg func_stripname '' '/' "`pwd`" 24942a55b46Smrg func_normal_abspath_result=$func_stripname_result 25042a55b46Smrg return 25142a55b46Smrg ;; 25242a55b46Smrg # The next three entries are used to spot a run of precisely 25342a55b46Smrg # two leading slashes without using negated character classes; 25442a55b46Smrg # we take advantage of case's first-match behaviour. 25542a55b46Smrg ///*) 25642a55b46Smrg # Unusual form of absolute path, do nothing. 25742a55b46Smrg ;; 25842a55b46Smrg //*) 25942a55b46Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 26042a55b46Smrg # and for example Cygwin uses it to access remote file shares 26142a55b46Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 26242a55b46Smrg func_normal_abspath_altnamespace=/ 26342a55b46Smrg ;; 26442a55b46Smrg /*) 26542a55b46Smrg # Absolute path, do nothing. 26642a55b46Smrg ;; 26742a55b46Smrg *) 26842a55b46Smrg # Relative path, prepend $cwd. 26942a55b46Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 27042a55b46Smrg ;; 27142a55b46Smrg esac 27242a55b46Smrg # Cancel out all the simple stuff to save iterations. We also want 27342a55b46Smrg # the path to end with a slash for ease of parsing, so make sure 27442a55b46Smrg # there is one (and only one) here. 27542a55b46Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 27642a55b46Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 27742a55b46Smrg while :; do 27842a55b46Smrg # Processed it all yet? 27942a55b46Smrg if test "$func_normal_abspath_tpath" = / ; then 28042a55b46Smrg # If we ascended to the root using ".." the result may be empty now. 28142a55b46Smrg if test -z "$func_normal_abspath_result" ; then 28242a55b46Smrg func_normal_abspath_result=/ 28342a55b46Smrg fi 28442a55b46Smrg break 28542a55b46Smrg fi 28642a55b46Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 28742a55b46Smrg -e "$pathcar"` 28842a55b46Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 28942a55b46Smrg -e "$pathcdr"` 29042a55b46Smrg # Figure out what to do with it 29142a55b46Smrg case $func_normal_abspath_tcomponent in 29242a55b46Smrg "") 29342a55b46Smrg # Trailing empty path component, ignore it. 29442a55b46Smrg ;; 29542a55b46Smrg ..) 29642a55b46Smrg # Parent dir; strip last assembled component from result. 29742a55b46Smrg func_dirname "$func_normal_abspath_result" 29842a55b46Smrg func_normal_abspath_result=$func_dirname_result 29942a55b46Smrg ;; 30042a55b46Smrg *) 30142a55b46Smrg # Actual path component, append it. 30242a55b46Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 30342a55b46Smrg ;; 30442a55b46Smrg esac 30542a55b46Smrg done 30642a55b46Smrg # Restore leading double-slash if one was found on entry. 30742a55b46Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 30842a55b46Smrg} 30942a55b46Smrg 31042a55b46Smrg# func_relative_path SRCDIR DSTDIR 31142a55b46Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 31242a55b46Smrg# slash if non-empty, suitable for immediately appending a filename 31342a55b46Smrg# without needing to append a separator. 31442a55b46Smrg# value returned in "$func_relative_path_result" 31542a55b46Smrgfunc_relative_path () 31642a55b46Smrg{ 31742a55b46Smrg func_relative_path_result= 31842a55b46Smrg func_normal_abspath "$1" 31942a55b46Smrg func_relative_path_tlibdir=$func_normal_abspath_result 32042a55b46Smrg func_normal_abspath "$2" 32142a55b46Smrg func_relative_path_tbindir=$func_normal_abspath_result 32242a55b46Smrg 32342a55b46Smrg # Ascend the tree starting from libdir 32442a55b46Smrg while :; do 32542a55b46Smrg # check if we have found a prefix of bindir 32642a55b46Smrg case $func_relative_path_tbindir in 32742a55b46Smrg $func_relative_path_tlibdir) 32842a55b46Smrg # found an exact match 32942a55b46Smrg func_relative_path_tcancelled= 33042a55b46Smrg break 33142a55b46Smrg ;; 33242a55b46Smrg $func_relative_path_tlibdir*) 33342a55b46Smrg # found a matching prefix 33442a55b46Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 33542a55b46Smrg func_relative_path_tcancelled=$func_stripname_result 33642a55b46Smrg if test -z "$func_relative_path_result"; then 33742a55b46Smrg func_relative_path_result=. 33842a55b46Smrg fi 33942a55b46Smrg break 34042a55b46Smrg ;; 34142a55b46Smrg *) 34242a55b46Smrg func_dirname $func_relative_path_tlibdir 34342a55b46Smrg func_relative_path_tlibdir=${func_dirname_result} 34442a55b46Smrg if test "x$func_relative_path_tlibdir" = x ; then 34542a55b46Smrg # Have to descend all the way to the root! 34642a55b46Smrg func_relative_path_result=../$func_relative_path_result 34742a55b46Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 34842a55b46Smrg break 34942a55b46Smrg fi 35042a55b46Smrg func_relative_path_result=../$func_relative_path_result 35142a55b46Smrg ;; 35242a55b46Smrg esac 35342a55b46Smrg done 35442a55b46Smrg 35542a55b46Smrg # Now calculate path; take care to avoid doubling-up slashes. 35642a55b46Smrg func_stripname '' '/' "$func_relative_path_result" 35742a55b46Smrg func_relative_path_result=$func_stripname_result 35842a55b46Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 35942a55b46Smrg if test "x$func_stripname_result" != x ; then 36042a55b46Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 36142a55b46Smrg fi 36242a55b46Smrg 36342a55b46Smrg # Normalisation. If bindir is libdir, return empty string, 36442a55b46Smrg # else relative path ending with a slash; either way, target 36542a55b46Smrg # file name can be directly appended. 36642a55b46Smrg if test ! -z "$func_relative_path_result"; then 36742a55b46Smrg func_stripname './' '' "$func_relative_path_result/" 36842a55b46Smrg func_relative_path_result=$func_stripname_result 36942a55b46Smrg fi 37042a55b46Smrg} 37142a55b46Smrg 37242a55b46Smrg# The name of this program: 37342a55b46Smrgfunc_dirname_and_basename "$progpath" 37442a55b46Smrgprogname=$func_basename_result 37542a55b46Smrg 37642a55b46Smrg# Make sure we have an absolute path for reexecution: 37742a55b46Smrgcase $progpath in 37842a55b46Smrg [\\/]*|[A-Za-z]:\\*) ;; 37942a55b46Smrg *[\\/]*) 38042a55b46Smrg progdir=$func_dirname_result 38142a55b46Smrg progdir=`cd "$progdir" && pwd` 38242a55b46Smrg progpath="$progdir/$progname" 38342a55b46Smrg ;; 38442a55b46Smrg *) 38542a55b46Smrg save_IFS="$IFS" 38642a55b46Smrg IFS=${PATH_SEPARATOR-:} 38742a55b46Smrg for progdir in $PATH; do 38842a55b46Smrg IFS="$save_IFS" 38942a55b46Smrg test -x "$progdir/$progname" && break 39042a55b46Smrg done 39142a55b46Smrg IFS="$save_IFS" 39242a55b46Smrg test -n "$progdir" || progdir=`pwd` 39342a55b46Smrg progpath="$progdir/$progname" 39442a55b46Smrg ;; 39542a55b46Smrgesac 39642a55b46Smrg 39742a55b46Smrg# Sed substitution that helps us do robust quoting. It backslashifies 39842a55b46Smrg# metacharacters that are still active within double-quoted strings. 39942a55b46SmrgXsed="${SED}"' -e 1s/^X//' 40042a55b46Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 40142a55b46Smrg 40242a55b46Smrg# Same as above, but do not quote variable references. 40342a55b46Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 40442a55b46Smrg 40542a55b46Smrg# Sed substitution that turns a string into a regex matching for the 40642a55b46Smrg# string literally. 40742a55b46Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 40842a55b46Smrg 40942a55b46Smrg# Sed substitution that converts a w32 file name or path 41042a55b46Smrg# which contains forward slashes, into one that contains 41142a55b46Smrg# (escaped) backslashes. A very naive implementation. 41242a55b46Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 41342a55b46Smrg 41442a55b46Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 41542a55b46Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 41642a55b46Smrg# in input to double_quote_subst, that '$' was protected from expansion. 41742a55b46Smrg# Since each input `\' is now two `\'s, look for any number of runs of 41842a55b46Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 41942a55b46Smrgbs='\\' 42042a55b46Smrgbs2='\\\\' 42142a55b46Smrgbs4='\\\\\\\\' 42242a55b46Smrgdollar='\$' 42342a55b46Smrgsed_double_backslash="\ 42442a55b46Smrg s/$bs4/&\\ 42542a55b46Smrg/g 42642a55b46Smrg s/^$bs2$dollar/$bs&/ 42742a55b46Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 42842a55b46Smrg s/\n//g" 42942a55b46Smrg 43042a55b46Smrg# Standard options: 43142a55b46Smrgopt_dry_run=false 43242a55b46Smrgopt_help=false 43342a55b46Smrgopt_quiet=false 43442a55b46Smrgopt_verbose=false 43542a55b46Smrgopt_warning=: 43642a55b46Smrg 43742a55b46Smrg# func_echo arg... 43842a55b46Smrg# Echo program name prefixed message, along with the current mode 43942a55b46Smrg# name if it has been set yet. 44042a55b46Smrgfunc_echo () 44142a55b46Smrg{ 44242a55b46Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 44342a55b46Smrg} 44442a55b46Smrg 44542a55b46Smrg# func_verbose arg... 44642a55b46Smrg# Echo program name prefixed message in verbose mode only. 44742a55b46Smrgfunc_verbose () 44842a55b46Smrg{ 44942a55b46Smrg $opt_verbose && func_echo ${1+"$@"} 45042a55b46Smrg 45142a55b46Smrg # A bug in bash halts the script if the last line of a function 45242a55b46Smrg # fails when set -e is in force, so we need another command to 45342a55b46Smrg # work around that: 45442a55b46Smrg : 45542a55b46Smrg} 45642a55b46Smrg 45742a55b46Smrg# func_echo_all arg... 45842a55b46Smrg# Invoke $ECHO with all args, space-separated. 45942a55b46Smrgfunc_echo_all () 46042a55b46Smrg{ 46142a55b46Smrg $ECHO "$*" 46242a55b46Smrg} 46342a55b46Smrg 46442a55b46Smrg# func_error arg... 46542a55b46Smrg# Echo program name prefixed message to standard error. 46642a55b46Smrgfunc_error () 46742a55b46Smrg{ 46842a55b46Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 46942a55b46Smrg} 47042a55b46Smrg 47142a55b46Smrg# func_warning arg... 47242a55b46Smrg# Echo program name prefixed warning message to standard error. 47342a55b46Smrgfunc_warning () 47442a55b46Smrg{ 47542a55b46Smrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 47642a55b46Smrg 47742a55b46Smrg # bash bug again: 47842a55b46Smrg : 47942a55b46Smrg} 48042a55b46Smrg 48142a55b46Smrg# func_fatal_error arg... 48242a55b46Smrg# Echo program name prefixed message to standard error, and exit. 48342a55b46Smrgfunc_fatal_error () 48442a55b46Smrg{ 48542a55b46Smrg func_error ${1+"$@"} 48642a55b46Smrg exit $EXIT_FAILURE 48742a55b46Smrg} 48842a55b46Smrg 48942a55b46Smrg# func_fatal_help arg... 49042a55b46Smrg# Echo program name prefixed message to standard error, followed by 49142a55b46Smrg# a help hint, and exit. 49242a55b46Smrgfunc_fatal_help () 49342a55b46Smrg{ 49442a55b46Smrg func_error ${1+"$@"} 49542a55b46Smrg func_fatal_error "$help" 49642a55b46Smrg} 49742a55b46Smrghelp="Try \`$progname --help' for more information." ## default 49842a55b46Smrg 49942a55b46Smrg 50042a55b46Smrg# func_grep expression filename 50142a55b46Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 50242a55b46Smrgfunc_grep () 50342a55b46Smrg{ 50442a55b46Smrg $GREP "$1" "$2" >/dev/null 2>&1 50542a55b46Smrg} 50642a55b46Smrg 50742a55b46Smrg 50842a55b46Smrg# func_mkdir_p directory-path 50942a55b46Smrg# Make sure the entire path to DIRECTORY-PATH is available. 51042a55b46Smrgfunc_mkdir_p () 51142a55b46Smrg{ 51242a55b46Smrg my_directory_path="$1" 51342a55b46Smrg my_dir_list= 51442a55b46Smrg 51542a55b46Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 51642a55b46Smrg 51742a55b46Smrg # Protect directory names starting with `-' 51842a55b46Smrg case $my_directory_path in 51942a55b46Smrg -*) my_directory_path="./$my_directory_path" ;; 52042a55b46Smrg esac 52142a55b46Smrg 52242a55b46Smrg # While some portion of DIR does not yet exist... 52342a55b46Smrg while test ! -d "$my_directory_path"; do 52442a55b46Smrg # ...make a list in topmost first order. Use a colon delimited 52542a55b46Smrg # list incase some portion of path contains whitespace. 52642a55b46Smrg my_dir_list="$my_directory_path:$my_dir_list" 52742a55b46Smrg 52842a55b46Smrg # If the last portion added has no slash in it, the list is done 52942a55b46Smrg case $my_directory_path in */*) ;; *) break ;; esac 53042a55b46Smrg 53142a55b46Smrg # ...otherwise throw away the child directory and loop 53242a55b46Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 53342a55b46Smrg done 53442a55b46Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 53542a55b46Smrg 53642a55b46Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 53742a55b46Smrg for my_dir in $my_dir_list; do 53842a55b46Smrg IFS="$save_mkdir_p_IFS" 53942a55b46Smrg # mkdir can fail with a `File exist' error if two processes 54042a55b46Smrg # try to create one of the directories concurrently. Don't 54142a55b46Smrg # stop in that case! 54242a55b46Smrg $MKDIR "$my_dir" 2>/dev/null || : 54342a55b46Smrg done 54442a55b46Smrg IFS="$save_mkdir_p_IFS" 54542a55b46Smrg 54642a55b46Smrg # Bail out if we (or some other process) failed to create a directory. 54742a55b46Smrg test -d "$my_directory_path" || \ 54842a55b46Smrg func_fatal_error "Failed to create \`$1'" 54942a55b46Smrg fi 55042a55b46Smrg} 551c582b7e3Smrg 552c582b7e3Smrg 553c582b7e3Smrg# func_mktempdir [string] 554c582b7e3Smrg# Make a temporary directory that won't clash with other running 555c582b7e3Smrg# libtool processes, and avoids race conditions if possible. If 556c582b7e3Smrg# given, STRING is the basename for that directory. 557c582b7e3Smrgfunc_mktempdir () 558c582b7e3Smrg{ 559c582b7e3Smrg my_template="${TMPDIR-/tmp}/${1-$progname}" 560c582b7e3Smrg 56142a55b46Smrg if test "$opt_dry_run" = ":"; then 562c582b7e3Smrg # Return a directory name, but don't create it in dry-run mode 563c582b7e3Smrg my_tmpdir="${my_template}-$$" 564c582b7e3Smrg else 565c582b7e3Smrg 566c582b7e3Smrg # If mktemp works, use that first and foremost 567c582b7e3Smrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 568c582b7e3Smrg 569c582b7e3Smrg if test ! -d "$my_tmpdir"; then 57042a55b46Smrg # Failing that, at least try and use $RANDOM to avoid a race 57142a55b46Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 572c582b7e3Smrg 57342a55b46Smrg save_mktempdir_umask=`umask` 57442a55b46Smrg umask 0077 57542a55b46Smrg $MKDIR "$my_tmpdir" 57642a55b46Smrg umask $save_mktempdir_umask 577c582b7e3Smrg fi 578c582b7e3Smrg 579c582b7e3Smrg # If we're not in dry-run mode, bomb out on failure 58042a55b46Smrg test -d "$my_tmpdir" || \ 58142a55b46Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 582c582b7e3Smrg fi 583c582b7e3Smrg 58442a55b46Smrg $ECHO "$my_tmpdir" 585c582b7e3Smrg} 586c582b7e3Smrg 587c582b7e3Smrg 58842a55b46Smrg# func_quote_for_eval arg 58942a55b46Smrg# Aesthetically quote ARG to be evaled later. 59042a55b46Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 59142a55b46Smrg# is double-quoted, suitable for a subsequent eval, whereas 59242a55b46Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 59342a55b46Smrg# which are still active within double quotes backslashified. 59442a55b46Smrgfunc_quote_for_eval () 595c582b7e3Smrg{ 59642a55b46Smrg case $1 in 59742a55b46Smrg *[\\\`\"\$]*) 59842a55b46Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 59942a55b46Smrg *) 60042a55b46Smrg func_quote_for_eval_unquoted_result="$1" ;; 60142a55b46Smrg esac 60242a55b46Smrg 60342a55b46Smrg case $func_quote_for_eval_unquoted_result in 60442a55b46Smrg # Double-quote args containing shell metacharacters to delay 60542a55b46Smrg # word splitting, command substitution and and variable 60642a55b46Smrg # expansion for a subsequent eval. 60742a55b46Smrg # Many Bourne shells cannot handle close brackets correctly 60842a55b46Smrg # in scan sets, so we specify it separately. 60942a55b46Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 61042a55b46Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 61142a55b46Smrg ;; 61242a55b46Smrg *) 61342a55b46Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 61442a55b46Smrg esac 61542a55b46Smrg} 61642a55b46Smrg 61742a55b46Smrg 61842a55b46Smrg# func_quote_for_expand arg 61942a55b46Smrg# Aesthetically quote ARG to be evaled later; same as above, 62042a55b46Smrg# but do not quote variable references. 62142a55b46Smrgfunc_quote_for_expand () 62242a55b46Smrg{ 62342a55b46Smrg case $1 in 62442a55b46Smrg *[\\\`\"]*) 62542a55b46Smrg my_arg=`$ECHO "$1" | $SED \ 62642a55b46Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 62742a55b46Smrg *) 62842a55b46Smrg my_arg="$1" ;; 62942a55b46Smrg esac 63042a55b46Smrg 63142a55b46Smrg case $my_arg in 63242a55b46Smrg # Double-quote args containing shell metacharacters to delay 63342a55b46Smrg # word splitting and command substitution for a subsequent eval. 63442a55b46Smrg # Many Bourne shells cannot handle close brackets correctly 63542a55b46Smrg # in scan sets, so we specify it separately. 63642a55b46Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 63742a55b46Smrg my_arg="\"$my_arg\"" 63842a55b46Smrg ;; 63942a55b46Smrg esac 64042a55b46Smrg 64142a55b46Smrg func_quote_for_expand_result="$my_arg" 64242a55b46Smrg} 64342a55b46Smrg 64442a55b46Smrg 64542a55b46Smrg# func_show_eval cmd [fail_exp] 64642a55b46Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 64742a55b46Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 64842a55b46Smrg# is given, then evaluate it. 64942a55b46Smrgfunc_show_eval () 65042a55b46Smrg{ 65142a55b46Smrg my_cmd="$1" 65242a55b46Smrg my_fail_exp="${2-:}" 65342a55b46Smrg 65442a55b46Smrg ${opt_silent-false} || { 65542a55b46Smrg func_quote_for_expand "$my_cmd" 65642a55b46Smrg eval "func_echo $func_quote_for_expand_result" 65742a55b46Smrg } 65842a55b46Smrg 65942a55b46Smrg if ${opt_dry_run-false}; then :; else 66042a55b46Smrg eval "$my_cmd" 66142a55b46Smrg my_status=$? 66242a55b46Smrg if test "$my_status" -eq 0; then :; else 66342a55b46Smrg eval "(exit $my_status); $my_fail_exp" 66442a55b46Smrg fi 665c582b7e3Smrg fi 66642a55b46Smrg} 66742a55b46Smrg 66842a55b46Smrg 66942a55b46Smrg# func_show_eval_locale cmd [fail_exp] 67042a55b46Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 67142a55b46Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 67242a55b46Smrg# is given, then evaluate it. Use the saved locale for evaluation. 67342a55b46Smrgfunc_show_eval_locale () 67442a55b46Smrg{ 67542a55b46Smrg my_cmd="$1" 67642a55b46Smrg my_fail_exp="${2-:}" 67742a55b46Smrg 67842a55b46Smrg ${opt_silent-false} || { 67942a55b46Smrg func_quote_for_expand "$my_cmd" 68042a55b46Smrg eval "func_echo $func_quote_for_expand_result" 68142a55b46Smrg } 68242a55b46Smrg 68342a55b46Smrg if ${opt_dry_run-false}; then :; else 68442a55b46Smrg eval "$lt_user_locale 68542a55b46Smrg $my_cmd" 68642a55b46Smrg my_status=$? 68742a55b46Smrg eval "$lt_safe_locale" 68842a55b46Smrg if test "$my_status" -eq 0; then :; else 68942a55b46Smrg eval "(exit $my_status); $my_fail_exp" 69042a55b46Smrg fi 69142a55b46Smrg fi 69242a55b46Smrg} 69342a55b46Smrg 69442a55b46Smrg# func_tr_sh 69542a55b46Smrg# Turn $1 into a string suitable for a shell variable name. 69642a55b46Smrg# Result is stored in $func_tr_sh_result. All characters 69742a55b46Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 69842a55b46Smrg# if $1 begins with a digit, a '_' is prepended as well. 69942a55b46Smrgfunc_tr_sh () 70042a55b46Smrg{ 70142a55b46Smrg case $1 in 70242a55b46Smrg [0-9]* | *[!a-zA-Z0-9_]*) 70342a55b46Smrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 704c582b7e3Smrg ;; 70542a55b46Smrg * ) 70642a55b46Smrg func_tr_sh_result=$1 707c582b7e3Smrg ;; 708c582b7e3Smrg esac 709c582b7e3Smrg} 710c582b7e3Smrg 711c582b7e3Smrg 71242a55b46Smrg# func_version 71342a55b46Smrg# Echo version message to standard output and exit. 71442a55b46Smrgfunc_version () 715c582b7e3Smrg{ 71642a55b46Smrg $opt_debug 71742a55b46Smrg 71842a55b46Smrg $SED -n '/(C)/!b go 71942a55b46Smrg :more 72042a55b46Smrg /\./!{ 72142a55b46Smrg N 72242a55b46Smrg s/\n# / / 72342a55b46Smrg b more 72442a55b46Smrg } 72542a55b46Smrg :go 72642a55b46Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 72742a55b46Smrg s/^# // 72842a55b46Smrg s/^# *$// 72942a55b46Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 73042a55b46Smrg p 73142a55b46Smrg }' < "$progpath" 73242a55b46Smrg exit $? 733c582b7e3Smrg} 734c582b7e3Smrg 73542a55b46Smrg# func_usage 73642a55b46Smrg# Echo short help message to standard output and exit. 73742a55b46Smrgfunc_usage () 738c582b7e3Smrg{ 73942a55b46Smrg $opt_debug 74042a55b46Smrg 74142a55b46Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 74242a55b46Smrg s/^# // 74342a55b46Smrg s/^# *$// 74442a55b46Smrg s/\$progname/'$progname'/ 74542a55b46Smrg p 74642a55b46Smrg }' < "$progpath" 74742a55b46Smrg echo 74842a55b46Smrg $ECHO "run \`$progname --help | more' for full usage" 74942a55b46Smrg exit $? 750c582b7e3Smrg} 751c582b7e3Smrg 75242a55b46Smrg# func_help [NOEXIT] 75342a55b46Smrg# Echo long help message to standard output and exit, 75442a55b46Smrg# unless 'noexit' is passed as argument. 75542a55b46Smrgfunc_help () 756c582b7e3Smrg{ 75742a55b46Smrg $opt_debug 75842a55b46Smrg 75942a55b46Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 76042a55b46Smrg :print 76142a55b46Smrg s/^# // 76242a55b46Smrg s/^# *$// 76342a55b46Smrg s*\$progname*'$progname'* 76442a55b46Smrg s*\$host*'"$host"'* 76542a55b46Smrg s*\$SHELL*'"$SHELL"'* 76642a55b46Smrg s*\$LTCC*'"$LTCC"'* 76742a55b46Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 76842a55b46Smrg s*\$LD*'"$LD"'* 76942a55b46Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 77042a55b46Smrg s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ 77142a55b46Smrg s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ 77242a55b46Smrg p 77342a55b46Smrg d 77442a55b46Smrg } 77542a55b46Smrg /^# .* home page:/b print 77642a55b46Smrg /^# General help using/b print 77742a55b46Smrg ' < "$progpath" 77842a55b46Smrg ret=$? 77942a55b46Smrg if test -z "$1"; then 78042a55b46Smrg exit $ret 781c582b7e3Smrg fi 78242a55b46Smrg} 783c582b7e3Smrg 78442a55b46Smrg# func_missing_arg argname 78542a55b46Smrg# Echo program name prefixed message to standard error and set global 78642a55b46Smrg# exit_cmd. 78742a55b46Smrgfunc_missing_arg () 78842a55b46Smrg{ 78942a55b46Smrg $opt_debug 790c582b7e3Smrg 79142a55b46Smrg func_error "missing argument for $1." 79242a55b46Smrg exit_cmd=exit 793c582b7e3Smrg} 794c582b7e3Smrg 795c582b7e3Smrg 79642a55b46Smrg# func_split_short_opt shortopt 79742a55b46Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 79842a55b46Smrg# variables after splitting SHORTOPT after the 2nd character. 79942a55b46Smrgfunc_split_short_opt () 80042a55b46Smrg{ 80142a55b46Smrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 80242a55b46Smrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 80342a55b46Smrg 80442a55b46Smrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 80542a55b46Smrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 80642a55b46Smrg} # func_split_short_opt may be replaced by extended shell implementation 807c582b7e3Smrg 808c582b7e3Smrg 80942a55b46Smrg# func_split_long_opt longopt 81042a55b46Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 81142a55b46Smrg# variables after splitting LONGOPT at the `=' sign. 81242a55b46Smrgfunc_split_long_opt () 81342a55b46Smrg{ 81442a55b46Smrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 81542a55b46Smrg my_sed_long_arg='1s/^--[^=]*=//' 816c582b7e3Smrg 81742a55b46Smrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 81842a55b46Smrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 81942a55b46Smrg} # func_split_long_opt may be replaced by extended shell implementation 820c582b7e3Smrg 82142a55b46Smrgexit_cmd=: 822c582b7e3Smrg 823c582b7e3Smrg 824c582b7e3Smrg 825c582b7e3Smrg 826c582b7e3Smrg 82742a55b46Smrgmagic="%%%MAGIC variable%%%" 82842a55b46Smrgmagic_exe="%%%MAGIC EXE variable%%%" 82942a55b46Smrg 83042a55b46Smrg# Global variables. 83142a55b46Smrgnonopt= 83242a55b46Smrgpreserve_args= 83342a55b46Smrglo2o="s/\\.lo\$/.${objext}/" 83442a55b46Smrgo2lo="s/\\.${objext}\$/.lo/" 83542a55b46Smrgextracted_archives= 83642a55b46Smrgextracted_serial=0 83742a55b46Smrg 83842a55b46Smrg# If this variable is set in any of the actions, the command in it 83942a55b46Smrg# will be execed at the end. This prevents here-documents from being 84042a55b46Smrg# left over by shells. 84142a55b46Smrgexec_cmd= 84242a55b46Smrg 84342a55b46Smrg# func_append var value 84442a55b46Smrg# Append VALUE to the end of shell variable VAR. 84542a55b46Smrgfunc_append () 84642a55b46Smrg{ 84742a55b46Smrg eval "${1}=\$${1}\${2}" 84842a55b46Smrg} # func_append may be replaced by extended shell implementation 84942a55b46Smrg 85042a55b46Smrg# func_append_quoted var value 85142a55b46Smrg# Quote VALUE and append to the end of shell variable VAR, separated 85242a55b46Smrg# by a space. 85342a55b46Smrgfunc_append_quoted () 85442a55b46Smrg{ 85542a55b46Smrg func_quote_for_eval "${2}" 85642a55b46Smrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 85742a55b46Smrg} # func_append_quoted may be replaced by extended shell implementation 85842a55b46Smrg 85942a55b46Smrg 86042a55b46Smrg# func_arith arithmetic-term... 86142a55b46Smrgfunc_arith () 86242a55b46Smrg{ 86342a55b46Smrg func_arith_result=`expr "${@}"` 86442a55b46Smrg} # func_arith may be replaced by extended shell implementation 86542a55b46Smrg 86642a55b46Smrg 86742a55b46Smrg# func_len string 86842a55b46Smrg# STRING may not start with a hyphen. 86942a55b46Smrgfunc_len () 87042a55b46Smrg{ 87142a55b46Smrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 87242a55b46Smrg} # func_len may be replaced by extended shell implementation 87342a55b46Smrg 87442a55b46Smrg 87542a55b46Smrg# func_lo2o object 87642a55b46Smrgfunc_lo2o () 87742a55b46Smrg{ 87842a55b46Smrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 87942a55b46Smrg} # func_lo2o may be replaced by extended shell implementation 88042a55b46Smrg 88142a55b46Smrg 88242a55b46Smrg# func_xform libobj-or-source 88342a55b46Smrgfunc_xform () 88442a55b46Smrg{ 88542a55b46Smrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 88642a55b46Smrg} # func_xform may be replaced by extended shell implementation 88742a55b46Smrg 88842a55b46Smrg 88942a55b46Smrg# func_fatal_configuration arg... 89042a55b46Smrg# Echo program name prefixed message to standard error, followed by 89142a55b46Smrg# a configuration failure hint, and exit. 89242a55b46Smrgfunc_fatal_configuration () 89342a55b46Smrg{ 89442a55b46Smrg func_error ${1+"$@"} 89542a55b46Smrg func_error "See the $PACKAGE documentation for more information." 89642a55b46Smrg func_fatal_error "Fatal configuration error." 89742a55b46Smrg} 89842a55b46Smrg 89942a55b46Smrg 90042a55b46Smrg# func_config 90142a55b46Smrg# Display the configuration for all the tags in this script. 90242a55b46Smrgfunc_config () 90342a55b46Smrg{ 90442a55b46Smrg re_begincf='^# ### BEGIN LIBTOOL' 90542a55b46Smrg re_endcf='^# ### END LIBTOOL' 90642a55b46Smrg 90742a55b46Smrg # Default configuration. 90842a55b46Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 90942a55b46Smrg 910c582b7e3Smrg # Now print the configurations for the tags. 911c582b7e3Smrg for tagname in $taglist; do 91242a55b46Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 913c582b7e3Smrg done 914c582b7e3Smrg 91542a55b46Smrg exit $? 91642a55b46Smrg} 917c582b7e3Smrg 91842a55b46Smrg# func_features 91942a55b46Smrg# Display the features supported by this script. 92042a55b46Smrgfunc_features () 92142a55b46Smrg{ 92242a55b46Smrg echo "host: $host" 923c582b7e3Smrg if test "$build_libtool_libs" = yes; then 92442a55b46Smrg echo "enable shared libraries" 925c582b7e3Smrg else 92642a55b46Smrg echo "disable shared libraries" 927c582b7e3Smrg fi 928c582b7e3Smrg if test "$build_old_libs" = yes; then 92942a55b46Smrg echo "enable static libraries" 930c582b7e3Smrg else 93142a55b46Smrg echo "disable static libraries" 932c582b7e3Smrg fi 933c582b7e3Smrg 93442a55b46Smrg exit $? 93542a55b46Smrg} 936c582b7e3Smrg 93742a55b46Smrg# func_enable_tag tagname 93842a55b46Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 93942a55b46Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 94042a55b46Smrg# variable here. 94142a55b46Smrgfunc_enable_tag () 94242a55b46Smrg{ 94342a55b46Smrg # Global variable: 94442a55b46Smrg tagname="$1" 945c582b7e3Smrg 94642a55b46Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 94742a55b46Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 94842a55b46Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 949c582b7e3Smrg 95042a55b46Smrg # Validate tagname. 95142a55b46Smrg case $tagname in 95242a55b46Smrg *[!-_A-Za-z0-9,/]*) 95342a55b46Smrg func_fatal_error "invalid tag name: $tagname" 95442a55b46Smrg ;; 95542a55b46Smrg esac 956c582b7e3Smrg 95742a55b46Smrg # Don't test for the "default" C tag, as we know it's 95842a55b46Smrg # there but not specially marked. 95942a55b46Smrg case $tagname in 96042a55b46Smrg CC) ;; 96142a55b46Smrg *) 96242a55b46Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 96342a55b46Smrg taglist="$taglist $tagname" 96442a55b46Smrg 96542a55b46Smrg # Evaluate the configuration. Be careful to quote the path 96642a55b46Smrg # and the sed script, to avoid splitting on whitespace, but 96742a55b46Smrg # also don't use non-portable quotes within backquotes within 96842a55b46Smrg # quotes we have to do it in 2 steps: 96942a55b46Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 97042a55b46Smrg eval "$extractedcf" 97142a55b46Smrg else 97242a55b46Smrg func_error "ignoring unknown tag $tagname" 97342a55b46Smrg fi 97442a55b46Smrg ;; 97542a55b46Smrg esac 97642a55b46Smrg} 977c582b7e3Smrg 97842a55b46Smrg# func_check_version_match 97942a55b46Smrg# Ensure that we are using m4 macros, and libtool script from the same 98042a55b46Smrg# release of libtool. 98142a55b46Smrgfunc_check_version_match () 98242a55b46Smrg{ 98342a55b46Smrg if test "$package_revision" != "$macro_revision"; then 98442a55b46Smrg if test "$VERSION" != "$macro_version"; then 98542a55b46Smrg if test -z "$macro_version"; then 98642a55b46Smrg cat >&2 <<_LT_EOF 98742a55b46Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 98842a55b46Smrg$progname: definition of this LT_INIT comes from an older release. 98942a55b46Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 99042a55b46Smrg$progname: and run autoconf again. 99142a55b46Smrg_LT_EOF 99242a55b46Smrg else 99342a55b46Smrg cat >&2 <<_LT_EOF 99442a55b46Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 99542a55b46Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 99642a55b46Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 99742a55b46Smrg$progname: and run autoconf again. 99842a55b46Smrg_LT_EOF 99942a55b46Smrg fi 100042a55b46Smrg else 100142a55b46Smrg cat >&2 <<_LT_EOF 100242a55b46Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 100342a55b46Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 100442a55b46Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 100542a55b46Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 100642a55b46Smrg_LT_EOF 100742a55b46Smrg fi 1008c582b7e3Smrg 100942a55b46Smrg exit $EXIT_MISMATCH 101042a55b46Smrg fi 101142a55b46Smrg} 1012c582b7e3Smrg 1013c582b7e3Smrg 101442a55b46Smrg# Shorthand for --mode=foo, only valid as the first argument 101542a55b46Smrgcase $1 in 101642a55b46Smrgclean|clea|cle|cl) 101742a55b46Smrg shift; set dummy --mode clean ${1+"$@"}; shift 101842a55b46Smrg ;; 101942a55b46Smrgcompile|compil|compi|comp|com|co|c) 102042a55b46Smrg shift; set dummy --mode compile ${1+"$@"}; shift 102142a55b46Smrg ;; 102242a55b46Smrgexecute|execut|execu|exec|exe|ex|e) 102342a55b46Smrg shift; set dummy --mode execute ${1+"$@"}; shift 102442a55b46Smrg ;; 102542a55b46Smrgfinish|finis|fini|fin|fi|f) 102642a55b46Smrg shift; set dummy --mode finish ${1+"$@"}; shift 1027c582b7e3Smrg ;; 102842a55b46Smrginstall|instal|insta|inst|ins|in|i) 102942a55b46Smrg shift; set dummy --mode install ${1+"$@"}; shift 1030c582b7e3Smrg ;; 103142a55b46Smrglink|lin|li|l) 103242a55b46Smrg shift; set dummy --mode link ${1+"$@"}; shift 103342a55b46Smrg ;; 103442a55b46Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 103542a55b46Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 1036c582b7e3Smrg ;; 1037c582b7e3Smrgesac 1038c582b7e3Smrg 1039c582b7e3Smrg 1040c582b7e3Smrg 104142a55b46Smrg# Option defaults: 104242a55b46Smrgopt_debug=: 104342a55b46Smrgopt_dry_run=false 104442a55b46Smrgopt_config=false 104542a55b46Smrgopt_preserve_dup_deps=false 104642a55b46Smrgopt_features=false 104742a55b46Smrgopt_finish=false 104842a55b46Smrgopt_help=false 104942a55b46Smrgopt_help_all=false 105042a55b46Smrgopt_silent=: 105142a55b46Smrgopt_warning=: 105242a55b46Smrgopt_verbose=: 105342a55b46Smrgopt_silent=false 105442a55b46Smrgopt_verbose=false 1055c582b7e3Smrg 105642a55b46Smrg 105742a55b46Smrg# Parse options once, thoroughly. This comes as soon as possible in the 105842a55b46Smrg# script to make things like `--version' happen as quickly as we can. 105942a55b46Smrg{ 106042a55b46Smrg # this just eases exit handling 106142a55b46Smrg while test $# -gt 0; do 106242a55b46Smrg opt="$1" 106342a55b46Smrg shift 106442a55b46Smrg case $opt in 106542a55b46Smrg --debug|-x) opt_debug='set -x' 106642a55b46Smrg func_echo "enabling shell trace mode" 106742a55b46Smrg $opt_debug 106842a55b46Smrg ;; 106942a55b46Smrg --dry-run|--dryrun|-n) 107042a55b46Smrg opt_dry_run=: 107142a55b46Smrg ;; 107242a55b46Smrg --config) 107342a55b46Smrg opt_config=: 107442a55b46Smrgfunc_config 107542a55b46Smrg ;; 107642a55b46Smrg --dlopen|-dlopen) 107742a55b46Smrg optarg="$1" 107842a55b46Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 107942a55b46Smrg}$optarg" 108042a55b46Smrg shift 108142a55b46Smrg ;; 108242a55b46Smrg --preserve-dup-deps) 108342a55b46Smrg opt_preserve_dup_deps=: 108442a55b46Smrg ;; 108542a55b46Smrg --features) 108642a55b46Smrg opt_features=: 108742a55b46Smrgfunc_features 108842a55b46Smrg ;; 108942a55b46Smrg --finish) 109042a55b46Smrg opt_finish=: 109142a55b46Smrgset dummy --mode finish ${1+"$@"}; shift 109242a55b46Smrg ;; 109342a55b46Smrg --help) 109442a55b46Smrg opt_help=: 109542a55b46Smrg ;; 109642a55b46Smrg --help-all) 109742a55b46Smrg opt_help_all=: 109842a55b46Smrgopt_help=': help-all' 109942a55b46Smrg ;; 110042a55b46Smrg --mode) 110142a55b46Smrg test $# = 0 && func_missing_arg $opt && break 110242a55b46Smrg optarg="$1" 110342a55b46Smrg opt_mode="$optarg" 110442a55b46Smrgcase $optarg in 110542a55b46Smrg # Valid mode arguments: 110642a55b46Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 110742a55b46Smrg 110842a55b46Smrg # Catch anything else as an error 110942a55b46Smrg *) func_error "invalid argument for $opt" 111042a55b46Smrg exit_cmd=exit 111142a55b46Smrg break 111242a55b46Smrg ;; 111342a55b46Smrgesac 111442a55b46Smrg shift 111542a55b46Smrg ;; 111642a55b46Smrg --no-silent|--no-quiet) 111742a55b46Smrg opt_silent=false 111842a55b46Smrgfunc_append preserve_args " $opt" 111942a55b46Smrg ;; 112042a55b46Smrg --no-warning|--no-warn) 112142a55b46Smrg opt_warning=false 112242a55b46Smrgfunc_append preserve_args " $opt" 112342a55b46Smrg ;; 112442a55b46Smrg --no-verbose) 112542a55b46Smrg opt_verbose=false 112642a55b46Smrgfunc_append preserve_args " $opt" 112742a55b46Smrg ;; 112842a55b46Smrg --silent|--quiet) 112942a55b46Smrg opt_silent=: 113042a55b46Smrgfunc_append preserve_args " $opt" 113142a55b46Smrg opt_verbose=false 113242a55b46Smrg ;; 113342a55b46Smrg --verbose|-v) 113442a55b46Smrg opt_verbose=: 113542a55b46Smrgfunc_append preserve_args " $opt" 113642a55b46Smrgopt_silent=false 113742a55b46Smrg ;; 113842a55b46Smrg --tag) 113942a55b46Smrg test $# = 0 && func_missing_arg $opt && break 114042a55b46Smrg optarg="$1" 114142a55b46Smrg opt_tag="$optarg" 114242a55b46Smrgfunc_append preserve_args " $opt $optarg" 114342a55b46Smrgfunc_enable_tag "$optarg" 114442a55b46Smrg shift 114542a55b46Smrg ;; 114642a55b46Smrg 114742a55b46Smrg -\?|-h) func_usage ;; 114842a55b46Smrg --help) func_help ;; 114942a55b46Smrg --version) func_version ;; 115042a55b46Smrg 115142a55b46Smrg # Separate optargs to long options: 115242a55b46Smrg --*=*) 115342a55b46Smrg func_split_long_opt "$opt" 115442a55b46Smrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 115542a55b46Smrg shift 115642a55b46Smrg ;; 115742a55b46Smrg 115842a55b46Smrg # Separate non-argument short options: 115942a55b46Smrg -\?*|-h*|-n*|-v*) 116042a55b46Smrg func_split_short_opt "$opt" 116142a55b46Smrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 116242a55b46Smrg shift 116342a55b46Smrg ;; 116442a55b46Smrg 116542a55b46Smrg --) break ;; 116642a55b46Smrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 116742a55b46Smrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 1168c582b7e3Smrg esac 116942a55b46Smrg done 1170c582b7e3Smrg 117142a55b46Smrg # Validate options: 117242a55b46Smrg 117342a55b46Smrg # save first non-option argument 117442a55b46Smrg if test "$#" -gt 0; then 117542a55b46Smrg nonopt="$opt" 117642a55b46Smrg shift 1177c582b7e3Smrg fi 1178c582b7e3Smrg 117942a55b46Smrg # preserve --debug 118042a55b46Smrg test "$opt_debug" = : || func_append preserve_args " --debug" 1181c582b7e3Smrg 118242a55b46Smrg case $host in 118342a55b46Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 118442a55b46Smrg # don't eliminate duplications in $postdeps and $predeps 118542a55b46Smrg opt_duplicate_compiler_generated_deps=: 118642a55b46Smrg ;; 118742a55b46Smrg *) 118842a55b46Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 118942a55b46Smrg ;; 119042a55b46Smrg esac 1191c582b7e3Smrg 119242a55b46Smrg $opt_help || { 119342a55b46Smrg # Sanity checks first: 119442a55b46Smrg func_check_version_match 1195c582b7e3Smrg 119642a55b46Smrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 119742a55b46Smrg func_fatal_configuration "not configured to build any kind of library" 119842a55b46Smrg fi 1199c582b7e3Smrg 120042a55b46Smrg # Darwin sucks 120142a55b46Smrg eval std_shrext=\"$shrext_cmds\" 1202c582b7e3Smrg 120342a55b46Smrg # Only execute mode is allowed to have -dlopen flags. 120442a55b46Smrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 120542a55b46Smrg func_error "unrecognized option \`-dlopen'" 120642a55b46Smrg $ECHO "$help" 1>&2 120742a55b46Smrg exit $EXIT_FAILURE 120842a55b46Smrg fi 1209c582b7e3Smrg 121042a55b46Smrg # Change the help message to a mode-specific one. 121142a55b46Smrg generic_help="$help" 121242a55b46Smrg help="Try \`$progname --help --mode=$opt_mode' for more information." 121342a55b46Smrg } 1214c582b7e3Smrg 1215c582b7e3Smrg 121642a55b46Smrg # Bail if the options were screwed 121742a55b46Smrg $exit_cmd $EXIT_FAILURE 121842a55b46Smrg} 1219c582b7e3Smrg 1220c582b7e3Smrg 1221c582b7e3Smrg 1222c582b7e3Smrg 122342a55b46Smrg## ----------- ## 122442a55b46Smrg## Main. ## 122542a55b46Smrg## ----------- ## 1226c582b7e3Smrg 122742a55b46Smrg# func_lalib_p file 122842a55b46Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 122942a55b46Smrg# This function is only a basic sanity check; it will hardly flush out 123042a55b46Smrg# determined imposters. 123142a55b46Smrgfunc_lalib_p () 123242a55b46Smrg{ 123342a55b46Smrg test -f "$1" && 123442a55b46Smrg $SED -e 4q "$1" 2>/dev/null \ 123542a55b46Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 123642a55b46Smrg} 1237c582b7e3Smrg 123842a55b46Smrg# func_lalib_unsafe_p file 123942a55b46Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 124042a55b46Smrg# This function implements the same check as func_lalib_p without 124142a55b46Smrg# resorting to external programs. To this end, it redirects stdin and 124242a55b46Smrg# closes it afterwards, without saving the original file descriptor. 124342a55b46Smrg# As a safety measure, use it only where a negative result would be 124442a55b46Smrg# fatal anyway. Works if `file' does not exist. 124542a55b46Smrgfunc_lalib_unsafe_p () 124642a55b46Smrg{ 124742a55b46Smrg lalib_p=no 124842a55b46Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 124942a55b46Smrg for lalib_p_l in 1 2 3 4 125042a55b46Smrg do 125142a55b46Smrg read lalib_p_line 125242a55b46Smrg case "$lalib_p_line" in 125342a55b46Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 125442a55b46Smrg esac 125542a55b46Smrg done 125642a55b46Smrg exec 0<&5 5<&- 125742a55b46Smrg fi 125842a55b46Smrg test "$lalib_p" = yes 125942a55b46Smrg} 1260c582b7e3Smrg 126142a55b46Smrg# func_ltwrapper_script_p file 126242a55b46Smrg# True iff FILE is a libtool wrapper script 126342a55b46Smrg# This function is only a basic sanity check; it will hardly flush out 126442a55b46Smrg# determined imposters. 126542a55b46Smrgfunc_ltwrapper_script_p () 126642a55b46Smrg{ 126742a55b46Smrg func_lalib_p "$1" 126842a55b46Smrg} 1269c582b7e3Smrg 127042a55b46Smrg# func_ltwrapper_executable_p file 127142a55b46Smrg# True iff FILE is a libtool wrapper executable 127242a55b46Smrg# This function is only a basic sanity check; it will hardly flush out 127342a55b46Smrg# determined imposters. 127442a55b46Smrgfunc_ltwrapper_executable_p () 127542a55b46Smrg{ 127642a55b46Smrg func_ltwrapper_exec_suffix= 127742a55b46Smrg case $1 in 127842a55b46Smrg *.exe) ;; 127942a55b46Smrg *) func_ltwrapper_exec_suffix=.exe ;; 1280c582b7e3Smrg esac 128142a55b46Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 128242a55b46Smrg} 1283c582b7e3Smrg 128442a55b46Smrg# func_ltwrapper_scriptname file 128542a55b46Smrg# Assumes file is an ltwrapper_executable 128642a55b46Smrg# uses $file to determine the appropriate filename for a 128742a55b46Smrg# temporary ltwrapper_script. 128842a55b46Smrgfunc_ltwrapper_scriptname () 128942a55b46Smrg{ 129042a55b46Smrg func_dirname_and_basename "$1" "" "." 129142a55b46Smrg func_stripname '' '.exe' "$func_basename_result" 129242a55b46Smrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 129342a55b46Smrg} 1294c582b7e3Smrg 129542a55b46Smrg# func_ltwrapper_p file 129642a55b46Smrg# True iff FILE is a libtool wrapper script or wrapper executable 129742a55b46Smrg# This function is only a basic sanity check; it will hardly flush out 129842a55b46Smrg# determined imposters. 129942a55b46Smrgfunc_ltwrapper_p () 130042a55b46Smrg{ 130142a55b46Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 130242a55b46Smrg} 1303c582b7e3Smrg 1304c582b7e3Smrg 130542a55b46Smrg# func_execute_cmds commands fail_cmd 130642a55b46Smrg# Execute tilde-delimited COMMANDS. 130742a55b46Smrg# If FAIL_CMD is given, eval that upon failure. 130842a55b46Smrg# FAIL_CMD may read-access the current command in variable CMD! 130942a55b46Smrgfunc_execute_cmds () 131042a55b46Smrg{ 131142a55b46Smrg $opt_debug 131242a55b46Smrg save_ifs=$IFS; IFS='~' 131342a55b46Smrg for cmd in $1; do 131442a55b46Smrg IFS=$save_ifs 131542a55b46Smrg eval cmd=\"$cmd\" 131642a55b46Smrg func_show_eval "$cmd" "${2-:}" 1317c582b7e3Smrg done 131842a55b46Smrg IFS=$save_ifs 131942a55b46Smrg} 1320c582b7e3Smrg 1321c582b7e3Smrg 132242a55b46Smrg# func_source file 132342a55b46Smrg# Source FILE, adding directory component if necessary. 132442a55b46Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 132542a55b46Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 132642a55b46Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 132742a55b46Smrg# `FILE.' does not work on cygwin managed mounts. 132842a55b46Smrgfunc_source () 132942a55b46Smrg{ 133042a55b46Smrg $opt_debug 133142a55b46Smrg case $1 in 133242a55b46Smrg */* | *\\*) . "$1" ;; 133342a55b46Smrg *) . "./$1" ;; 133442a55b46Smrg esac 133542a55b46Smrg} 1336c582b7e3Smrg 1337c582b7e3Smrg 133842a55b46Smrg# func_resolve_sysroot PATH 133942a55b46Smrg# Replace a leading = in PATH with a sysroot. Store the result into 134042a55b46Smrg# func_resolve_sysroot_result 134142a55b46Smrgfunc_resolve_sysroot () 134242a55b46Smrg{ 134342a55b46Smrg func_resolve_sysroot_result=$1 134442a55b46Smrg case $func_resolve_sysroot_result in 134542a55b46Smrg =*) 134642a55b46Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 134742a55b46Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 134842a55b46Smrg ;; 134942a55b46Smrg esac 135042a55b46Smrg} 1351c582b7e3Smrg 135242a55b46Smrg# func_replace_sysroot PATH 135342a55b46Smrg# If PATH begins with the sysroot, replace it with = and 135442a55b46Smrg# store the result into func_replace_sysroot_result. 135542a55b46Smrgfunc_replace_sysroot () 135642a55b46Smrg{ 135742a55b46Smrg case "$lt_sysroot:$1" in 135842a55b46Smrg ?*:"$lt_sysroot"*) 135942a55b46Smrg func_stripname "$lt_sysroot" '' "$1" 136042a55b46Smrg func_replace_sysroot_result="=$func_stripname_result" 136142a55b46Smrg ;; 136242a55b46Smrg *) 136342a55b46Smrg # Including no sysroot. 136442a55b46Smrg func_replace_sysroot_result=$1 136542a55b46Smrg ;; 136642a55b46Smrg esac 136742a55b46Smrg} 1368c582b7e3Smrg 136942a55b46Smrg# func_infer_tag arg 137042a55b46Smrg# Infer tagged configuration to use if any are available and 137142a55b46Smrg# if one wasn't chosen via the "--tag" command line option. 137242a55b46Smrg# Only attempt this if the compiler in the base compile 137342a55b46Smrg# command doesn't match the default compiler. 137442a55b46Smrg# arg is usually of the form 'gcc ...' 137542a55b46Smrgfunc_infer_tag () 137642a55b46Smrg{ 137742a55b46Smrg $opt_debug 137842a55b46Smrg if test -n "$available_tags" && test -z "$tagname"; then 137942a55b46Smrg CC_quoted= 138042a55b46Smrg for arg in $CC; do 138142a55b46Smrg func_append_quoted CC_quoted "$arg" 138242a55b46Smrg done 138342a55b46Smrg CC_expanded=`func_echo_all $CC` 138442a55b46Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 138542a55b46Smrg case $@ in 138642a55b46Smrg # Blanks in the command may have been stripped by the calling shell, 138742a55b46Smrg # but not from the CC environment variable when configure was run. 138842a55b46Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 138942a55b46Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 139042a55b46Smrg # Blanks at the start of $base_compile will cause this to fail 139142a55b46Smrg # if we don't check for them as well. 139242a55b46Smrg *) 139342a55b46Smrg for z in $available_tags; do 139442a55b46Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 139542a55b46Smrg # Evaluate the configuration. 139642a55b46Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 139742a55b46Smrg CC_quoted= 139842a55b46Smrg for arg in $CC; do 139942a55b46Smrg # Double-quote args containing other shell metacharacters. 140042a55b46Smrg func_append_quoted CC_quoted "$arg" 140142a55b46Smrg done 140242a55b46Smrg CC_expanded=`func_echo_all $CC` 140342a55b46Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 140442a55b46Smrg case "$@ " in 140542a55b46Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 140642a55b46Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 140742a55b46Smrg # The compiler in the base compile command matches 140842a55b46Smrg # the one in the tagged configuration. 140942a55b46Smrg # Assume this is the tagged configuration we want. 141042a55b46Smrg tagname=$z 141142a55b46Smrg break 141242a55b46Smrg ;; 141342a55b46Smrg esac 141442a55b46Smrg fi 141542a55b46Smrg done 141642a55b46Smrg # If $tagname still isn't set, then no tagged configuration 141742a55b46Smrg # was found and let the user know that the "--tag" command 141842a55b46Smrg # line option must be used. 141942a55b46Smrg if test -z "$tagname"; then 142042a55b46Smrg func_echo "unable to infer tagged configuration" 142142a55b46Smrg func_fatal_error "specify a tag with \`--tag'" 142242a55b46Smrg# else 142342a55b46Smrg# func_verbose "using $tagname tagged configuration" 142442a55b46Smrg fi 142542a55b46Smrg ;; 142642a55b46Smrg esac 1427c582b7e3Smrg fi 142842a55b46Smrg} 1429c582b7e3Smrg 1430c582b7e3Smrg 1431c582b7e3Smrg 143242a55b46Smrg# func_write_libtool_object output_name pic_name nonpic_name 143342a55b46Smrg# Create a libtool object file (analogous to a ".la" file), 143442a55b46Smrg# but don't create it if we're doing a dry run. 143542a55b46Smrgfunc_write_libtool_object () 143642a55b46Smrg{ 143742a55b46Smrg write_libobj=${1} 143842a55b46Smrg if test "$build_libtool_libs" = yes; then 143942a55b46Smrg write_lobj=\'${2}\' 144042a55b46Smrg else 144142a55b46Smrg write_lobj=none 1442c582b7e3Smrg fi 1443c582b7e3Smrg 144442a55b46Smrg if test "$build_old_libs" = yes; then 144542a55b46Smrg write_oldobj=\'${3}\' 144642a55b46Smrg else 144742a55b46Smrg write_oldobj=none 1448c582b7e3Smrg fi 1449c582b7e3Smrg 145042a55b46Smrg $opt_dry_run || { 145142a55b46Smrg cat >${write_libobj}T <<EOF 145242a55b46Smrg# $write_libobj - a libtool object file 145342a55b46Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 1454c582b7e3Smrg# 1455c582b7e3Smrg# Please DO NOT delete this file! 1456c582b7e3Smrg# It is necessary for linking the library. 1457c582b7e3Smrg 1458c582b7e3Smrg# Name of the PIC object. 145942a55b46Smrgpic_object=$write_lobj 1460c582b7e3Smrg 146142a55b46Smrg# Name of the non-PIC object 146242a55b46Smrgnon_pic_object=$write_oldobj 1463c582b7e3Smrg 146442a55b46SmrgEOF 146542a55b46Smrg $MV "${write_libobj}T" "${write_libobj}" 146642a55b46Smrg } 146742a55b46Smrg} 1468c582b7e3Smrg 1469c582b7e3Smrg 147042a55b46Smrg################################################## 147142a55b46Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 147242a55b46Smrg################################################## 1473c582b7e3Smrg 147442a55b46Smrg# func_convert_core_file_wine_to_w32 ARG 147542a55b46Smrg# Helper function used by file name conversion functions when $build is *nix, 147642a55b46Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 147742a55b46Smrg# correctly configured wine environment available, with the winepath program 147842a55b46Smrg# in $build's $PATH. 147942a55b46Smrg# 148042a55b46Smrg# ARG is the $build file name to be converted to w32 format. 148142a55b46Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 148242a55b46Smrg# be empty on error (or when ARG is empty) 148342a55b46Smrgfunc_convert_core_file_wine_to_w32 () 148442a55b46Smrg{ 148542a55b46Smrg $opt_debug 148642a55b46Smrg func_convert_core_file_wine_to_w32_result="$1" 148742a55b46Smrg if test -n "$1"; then 148842a55b46Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 148942a55b46Smrg # are forced to check the contents of stdout. On the other hand, if the 149042a55b46Smrg # command is not found, the shell will set an exit code of 127 and print 149142a55b46Smrg # *an error message* to stdout. So we must check for both error code of 149242a55b46Smrg # zero AND non-empty stdout, which explains the odd construction: 149342a55b46Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 149442a55b46Smrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 149542a55b46Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 149642a55b46Smrg $SED -e "$lt_sed_naive_backslashify"` 149742a55b46Smrg else 149842a55b46Smrg func_convert_core_file_wine_to_w32_result= 149942a55b46Smrg fi 150042a55b46Smrg fi 150142a55b46Smrg} 150242a55b46Smrg# end: func_convert_core_file_wine_to_w32 1503c582b7e3Smrg 150442a55b46Smrg 150542a55b46Smrg# func_convert_core_path_wine_to_w32 ARG 150642a55b46Smrg# Helper function used by path conversion functions when $build is *nix, and 150742a55b46Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 150842a55b46Smrg# configured wine environment available, with the winepath program in $build's 150942a55b46Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 151042a55b46Smrg# 151142a55b46Smrg# ARG is path to be converted from $build format to win32. 151242a55b46Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 151342a55b46Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 151442a55b46Smrg# are convertible, then the result may be empty. 151542a55b46Smrgfunc_convert_core_path_wine_to_w32 () 151642a55b46Smrg{ 151742a55b46Smrg $opt_debug 151842a55b46Smrg # unfortunately, winepath doesn't convert paths, only file names 151942a55b46Smrg func_convert_core_path_wine_to_w32_result="" 152042a55b46Smrg if test -n "$1"; then 152142a55b46Smrg oldIFS=$IFS 152242a55b46Smrg IFS=: 152342a55b46Smrg for func_convert_core_path_wine_to_w32_f in $1; do 152442a55b46Smrg IFS=$oldIFS 152542a55b46Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 152642a55b46Smrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 152742a55b46Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 152842a55b46Smrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 152942a55b46Smrg else 153042a55b46Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 153142a55b46Smrg fi 1532c582b7e3Smrg fi 153342a55b46Smrg done 153442a55b46Smrg IFS=$oldIFS 153542a55b46Smrg fi 153642a55b46Smrg} 153742a55b46Smrg# end: func_convert_core_path_wine_to_w32 153842a55b46Smrg 153942a55b46Smrg 154042a55b46Smrg# func_cygpath ARGS... 154142a55b46Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 154242a55b46Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 154342a55b46Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 154442a55b46Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 154542a55b46Smrg# file name or path is assumed to be in w32 format, as previously converted 154642a55b46Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 154742a55b46Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 154842a55b46Smrg# Cygwin format). Returns an empty string on error. 154942a55b46Smrg# 155042a55b46Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 155142a55b46Smrg# be converted. 155242a55b46Smrg# 155342a55b46Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 155442a55b46Smrg# environment variable; do not put it in $PATH. 155542a55b46Smrgfunc_cygpath () 155642a55b46Smrg{ 155742a55b46Smrg $opt_debug 155842a55b46Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 155942a55b46Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 156042a55b46Smrg if test "$?" -ne 0; then 156142a55b46Smrg # on failure, ensure result is empty 156242a55b46Smrg func_cygpath_result= 156342a55b46Smrg fi 156442a55b46Smrg else 156542a55b46Smrg func_cygpath_result= 156642a55b46Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 156742a55b46Smrg fi 156842a55b46Smrg} 156942a55b46Smrg#end: func_cygpath 1570c582b7e3Smrg 1571c582b7e3Smrg 157242a55b46Smrg# func_convert_core_msys_to_w32 ARG 157342a55b46Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 157442a55b46Smrg# result in func_convert_core_msys_to_w32_result. 157542a55b46Smrgfunc_convert_core_msys_to_w32 () 157642a55b46Smrg{ 157742a55b46Smrg $opt_debug 157842a55b46Smrg # awkward: cmd appends spaces to result 157942a55b46Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 158042a55b46Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 158142a55b46Smrg} 158242a55b46Smrg#end: func_convert_core_msys_to_w32 1583c582b7e3Smrg 1584c582b7e3Smrg 158542a55b46Smrg# func_convert_file_check ARG1 ARG2 158642a55b46Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 158742a55b46Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 158842a55b46Smrg# func_to_host_file_result to ARG1). 158942a55b46Smrgfunc_convert_file_check () 159042a55b46Smrg{ 159142a55b46Smrg $opt_debug 159242a55b46Smrg if test -z "$2" && test -n "$1" ; then 159342a55b46Smrg func_error "Could not determine host file name corresponding to" 159442a55b46Smrg func_error " \`$1'" 159542a55b46Smrg func_error "Continuing, but uninstalled executables may not work." 159642a55b46Smrg # Fallback: 159742a55b46Smrg func_to_host_file_result="$1" 159842a55b46Smrg fi 159942a55b46Smrg} 160042a55b46Smrg# end func_convert_file_check 1601c582b7e3Smrg 1602c582b7e3Smrg 160342a55b46Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 160442a55b46Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 160542a55b46Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 160642a55b46Smrg# func_to_host_file_result to a simplistic fallback value (see below). 160742a55b46Smrgfunc_convert_path_check () 160842a55b46Smrg{ 160942a55b46Smrg $opt_debug 161042a55b46Smrg if test -z "$4" && test -n "$3"; then 161142a55b46Smrg func_error "Could not determine the host path corresponding to" 161242a55b46Smrg func_error " \`$3'" 161342a55b46Smrg func_error "Continuing, but uninstalled executables may not work." 161442a55b46Smrg # Fallback. This is a deliberately simplistic "conversion" and 161542a55b46Smrg # should not be "improved". See libtool.info. 161642a55b46Smrg if test "x$1" != "x$2"; then 161742a55b46Smrg lt_replace_pathsep_chars="s|$1|$2|g" 161842a55b46Smrg func_to_host_path_result=`echo "$3" | 161942a55b46Smrg $SED -e "$lt_replace_pathsep_chars"` 162042a55b46Smrg else 162142a55b46Smrg func_to_host_path_result="$3" 162242a55b46Smrg fi 162342a55b46Smrg fi 162442a55b46Smrg} 162542a55b46Smrg# end func_convert_path_check 1626c582b7e3Smrg 1627c582b7e3Smrg 162842a55b46Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 162942a55b46Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 163042a55b46Smrg# and appending REPL if ORIG matches BACKPAT. 163142a55b46Smrgfunc_convert_path_front_back_pathsep () 163242a55b46Smrg{ 163342a55b46Smrg $opt_debug 163442a55b46Smrg case $4 in 163542a55b46Smrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 163642a55b46Smrg ;; 163742a55b46Smrg esac 163842a55b46Smrg case $4 in 163942a55b46Smrg $2 ) func_append func_to_host_path_result "$3" 164042a55b46Smrg ;; 164142a55b46Smrg esac 164242a55b46Smrg} 164342a55b46Smrg# end func_convert_path_front_back_pathsep 1644c582b7e3Smrg 1645c582b7e3Smrg 164642a55b46Smrg################################################## 164742a55b46Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 164842a55b46Smrg################################################## 164942a55b46Smrg# invoked via `$to_host_file_cmd ARG' 165042a55b46Smrg# 165142a55b46Smrg# In each case, ARG is the path to be converted from $build to $host format. 165242a55b46Smrg# Result will be available in $func_to_host_file_result. 1653c582b7e3Smrg 1654c582b7e3Smrg 165542a55b46Smrg# func_to_host_file ARG 165642a55b46Smrg# Converts the file name ARG from $build format to $host format. Return result 165742a55b46Smrg# in func_to_host_file_result. 165842a55b46Smrgfunc_to_host_file () 165942a55b46Smrg{ 166042a55b46Smrg $opt_debug 166142a55b46Smrg $to_host_file_cmd "$1" 166242a55b46Smrg} 166342a55b46Smrg# end func_to_host_file 1664c582b7e3Smrg 1665c582b7e3Smrg 166642a55b46Smrg# func_to_tool_file ARG LAZY 166742a55b46Smrg# converts the file name ARG from $build format to toolchain format. Return 166842a55b46Smrg# result in func_to_tool_file_result. If the conversion in use is listed 166942a55b46Smrg# in (the comma separated) LAZY, no conversion takes place. 167042a55b46Smrgfunc_to_tool_file () 167142a55b46Smrg{ 167242a55b46Smrg $opt_debug 167342a55b46Smrg case ,$2, in 167442a55b46Smrg *,"$to_tool_file_cmd",*) 167542a55b46Smrg func_to_tool_file_result=$1 167642a55b46Smrg ;; 167742a55b46Smrg *) 167842a55b46Smrg $to_tool_file_cmd "$1" 167942a55b46Smrg func_to_tool_file_result=$func_to_host_file_result 168042a55b46Smrg ;; 168142a55b46Smrg esac 168242a55b46Smrg} 168342a55b46Smrg# end func_to_tool_file 1684c582b7e3Smrg 1685c582b7e3Smrg 168642a55b46Smrg# func_convert_file_noop ARG 168742a55b46Smrg# Copy ARG to func_to_host_file_result. 168842a55b46Smrgfunc_convert_file_noop () 168942a55b46Smrg{ 169042a55b46Smrg func_to_host_file_result="$1" 169142a55b46Smrg} 169242a55b46Smrg# end func_convert_file_noop 1693c582b7e3Smrg 1694c582b7e3Smrg 169542a55b46Smrg# func_convert_file_msys_to_w32 ARG 169642a55b46Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 169742a55b46Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 169842a55b46Smrg# func_to_host_file_result. 169942a55b46Smrgfunc_convert_file_msys_to_w32 () 170042a55b46Smrg{ 170142a55b46Smrg $opt_debug 170242a55b46Smrg func_to_host_file_result="$1" 170342a55b46Smrg if test -n "$1"; then 170442a55b46Smrg func_convert_core_msys_to_w32 "$1" 170542a55b46Smrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 170642a55b46Smrg fi 170742a55b46Smrg func_convert_file_check "$1" "$func_to_host_file_result" 170842a55b46Smrg} 170942a55b46Smrg# end func_convert_file_msys_to_w32 1710c582b7e3Smrg 1711c582b7e3Smrg 171242a55b46Smrg# func_convert_file_cygwin_to_w32 ARG 171342a55b46Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 171442a55b46Smrg# func_to_host_file_result. 171542a55b46Smrgfunc_convert_file_cygwin_to_w32 () 171642a55b46Smrg{ 171742a55b46Smrg $opt_debug 171842a55b46Smrg func_to_host_file_result="$1" 171942a55b46Smrg if test -n "$1"; then 172042a55b46Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 172142a55b46Smrg # LT_CYGPATH in this case. 172242a55b46Smrg func_to_host_file_result=`cygpath -m "$1"` 172342a55b46Smrg fi 172442a55b46Smrg func_convert_file_check "$1" "$func_to_host_file_result" 172542a55b46Smrg} 172642a55b46Smrg# end func_convert_file_cygwin_to_w32 1727c582b7e3Smrg 1728c582b7e3Smrg 172942a55b46Smrg# func_convert_file_nix_to_w32 ARG 173042a55b46Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 173142a55b46Smrg# and a working winepath. Returns result in func_to_host_file_result. 173242a55b46Smrgfunc_convert_file_nix_to_w32 () 173342a55b46Smrg{ 173442a55b46Smrg $opt_debug 173542a55b46Smrg func_to_host_file_result="$1" 173642a55b46Smrg if test -n "$1"; then 173742a55b46Smrg func_convert_core_file_wine_to_w32 "$1" 173842a55b46Smrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 173942a55b46Smrg fi 174042a55b46Smrg func_convert_file_check "$1" "$func_to_host_file_result" 174142a55b46Smrg} 174242a55b46Smrg# end func_convert_file_nix_to_w32 1743c582b7e3Smrg 1744c582b7e3Smrg 174542a55b46Smrg# func_convert_file_msys_to_cygwin ARG 174642a55b46Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 174742a55b46Smrg# Returns result in func_to_host_file_result. 174842a55b46Smrgfunc_convert_file_msys_to_cygwin () 174942a55b46Smrg{ 175042a55b46Smrg $opt_debug 175142a55b46Smrg func_to_host_file_result="$1" 175242a55b46Smrg if test -n "$1"; then 175342a55b46Smrg func_convert_core_msys_to_w32 "$1" 175442a55b46Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 175542a55b46Smrg func_to_host_file_result="$func_cygpath_result" 175642a55b46Smrg fi 175742a55b46Smrg func_convert_file_check "$1" "$func_to_host_file_result" 175842a55b46Smrg} 175942a55b46Smrg# end func_convert_file_msys_to_cygwin 1760c582b7e3Smrg 1761c582b7e3Smrg 176242a55b46Smrg# func_convert_file_nix_to_cygwin ARG 176342a55b46Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 176442a55b46Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 176542a55b46Smrg# in func_to_host_file_result. 176642a55b46Smrgfunc_convert_file_nix_to_cygwin () 176742a55b46Smrg{ 176842a55b46Smrg $opt_debug 176942a55b46Smrg func_to_host_file_result="$1" 177042a55b46Smrg if test -n "$1"; then 177142a55b46Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 177242a55b46Smrg func_convert_core_file_wine_to_w32 "$1" 177342a55b46Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 177442a55b46Smrg func_to_host_file_result="$func_cygpath_result" 177542a55b46Smrg fi 177642a55b46Smrg func_convert_file_check "$1" "$func_to_host_file_result" 177742a55b46Smrg} 177842a55b46Smrg# end func_convert_file_nix_to_cygwin 1779c582b7e3Smrg 1780c582b7e3Smrg 178142a55b46Smrg############################################# 178242a55b46Smrg# $build to $host PATH CONVERSION FUNCTIONS # 178342a55b46Smrg############################################# 178442a55b46Smrg# invoked via `$to_host_path_cmd ARG' 178542a55b46Smrg# 178642a55b46Smrg# In each case, ARG is the path to be converted from $build to $host format. 178742a55b46Smrg# The result will be available in $func_to_host_path_result. 178842a55b46Smrg# 178942a55b46Smrg# Path separators are also converted from $build format to $host format. If 179042a55b46Smrg# ARG begins or ends with a path separator character, it is preserved (but 179142a55b46Smrg# converted to $host format) on output. 179242a55b46Smrg# 179342a55b46Smrg# All path conversion functions are named using the following convention: 179442a55b46Smrg# file name conversion function : func_convert_file_X_to_Y () 179542a55b46Smrg# path conversion function : func_convert_path_X_to_Y () 179642a55b46Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 179742a55b46Smrg# same. If conversion functions are added for new $build/$host combinations, 179842a55b46Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 179942a55b46Smrg# will break. 180042a55b46Smrg 180142a55b46Smrg 180242a55b46Smrg# func_init_to_host_path_cmd 180342a55b46Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 180442a55b46Smrg# appropriate value, based on the value of $to_host_file_cmd. 180542a55b46Smrgto_host_path_cmd= 180642a55b46Smrgfunc_init_to_host_path_cmd () 180742a55b46Smrg{ 180842a55b46Smrg $opt_debug 180942a55b46Smrg if test -z "$to_host_path_cmd"; then 181042a55b46Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 181142a55b46Smrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 181242a55b46Smrg fi 181342a55b46Smrg} 1814c582b7e3Smrg 1815c582b7e3Smrg 181642a55b46Smrg# func_to_host_path ARG 181742a55b46Smrg# Converts the path ARG from $build format to $host format. Return result 181842a55b46Smrg# in func_to_host_path_result. 181942a55b46Smrgfunc_to_host_path () 182042a55b46Smrg{ 182142a55b46Smrg $opt_debug 182242a55b46Smrg func_init_to_host_path_cmd 182342a55b46Smrg $to_host_path_cmd "$1" 182442a55b46Smrg} 182542a55b46Smrg# end func_to_host_path 1826c582b7e3Smrg 1827c582b7e3Smrg 182842a55b46Smrg# func_convert_path_noop ARG 182942a55b46Smrg# Copy ARG to func_to_host_path_result. 183042a55b46Smrgfunc_convert_path_noop () 183142a55b46Smrg{ 183242a55b46Smrg func_to_host_path_result="$1" 183342a55b46Smrg} 183442a55b46Smrg# end func_convert_path_noop 1835c582b7e3Smrg 1836c582b7e3Smrg 183742a55b46Smrg# func_convert_path_msys_to_w32 ARG 183842a55b46Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 183942a55b46Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 184042a55b46Smrg# func_to_host_path_result. 184142a55b46Smrgfunc_convert_path_msys_to_w32 () 184242a55b46Smrg{ 184342a55b46Smrg $opt_debug 184442a55b46Smrg func_to_host_path_result="$1" 184542a55b46Smrg if test -n "$1"; then 184642a55b46Smrg # Remove leading and trailing path separator characters from ARG. MSYS 184742a55b46Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 184842a55b46Smrg # and winepath ignores them completely. 184942a55b46Smrg func_stripname : : "$1" 185042a55b46Smrg func_to_host_path_tmp1=$func_stripname_result 185142a55b46Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 185242a55b46Smrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 185342a55b46Smrg func_convert_path_check : ";" \ 185442a55b46Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 185542a55b46Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 185642a55b46Smrg fi 185742a55b46Smrg} 185842a55b46Smrg# end func_convert_path_msys_to_w32 1859c582b7e3Smrg 1860c582b7e3Smrg 186142a55b46Smrg# func_convert_path_cygwin_to_w32 ARG 186242a55b46Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 186342a55b46Smrg# func_to_host_file_result. 186442a55b46Smrgfunc_convert_path_cygwin_to_w32 () 186542a55b46Smrg{ 186642a55b46Smrg $opt_debug 186742a55b46Smrg func_to_host_path_result="$1" 186842a55b46Smrg if test -n "$1"; then 186942a55b46Smrg # See func_convert_path_msys_to_w32: 187042a55b46Smrg func_stripname : : "$1" 187142a55b46Smrg func_to_host_path_tmp1=$func_stripname_result 187242a55b46Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 187342a55b46Smrg func_convert_path_check : ";" \ 187442a55b46Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 187542a55b46Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 187642a55b46Smrg fi 187742a55b46Smrg} 187842a55b46Smrg# end func_convert_path_cygwin_to_w32 1879c582b7e3Smrg 1880c582b7e3Smrg 188142a55b46Smrg# func_convert_path_nix_to_w32 ARG 188242a55b46Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 188342a55b46Smrg# a working winepath. Returns result in func_to_host_file_result. 188442a55b46Smrgfunc_convert_path_nix_to_w32 () 188542a55b46Smrg{ 188642a55b46Smrg $opt_debug 188742a55b46Smrg func_to_host_path_result="$1" 188842a55b46Smrg if test -n "$1"; then 188942a55b46Smrg # See func_convert_path_msys_to_w32: 189042a55b46Smrg func_stripname : : "$1" 189142a55b46Smrg func_to_host_path_tmp1=$func_stripname_result 189242a55b46Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 189342a55b46Smrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 189442a55b46Smrg func_convert_path_check : ";" \ 189542a55b46Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 189642a55b46Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 189742a55b46Smrg fi 189842a55b46Smrg} 189942a55b46Smrg# end func_convert_path_nix_to_w32 1900c582b7e3Smrg 1901c582b7e3Smrg 190242a55b46Smrg# func_convert_path_msys_to_cygwin ARG 190342a55b46Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 190442a55b46Smrg# Returns result in func_to_host_file_result. 190542a55b46Smrgfunc_convert_path_msys_to_cygwin () 190642a55b46Smrg{ 190742a55b46Smrg $opt_debug 190842a55b46Smrg func_to_host_path_result="$1" 190942a55b46Smrg if test -n "$1"; then 191042a55b46Smrg # See func_convert_path_msys_to_w32: 191142a55b46Smrg func_stripname : : "$1" 191242a55b46Smrg func_to_host_path_tmp1=$func_stripname_result 191342a55b46Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 191442a55b46Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 191542a55b46Smrg func_to_host_path_result="$func_cygpath_result" 191642a55b46Smrg func_convert_path_check : : \ 191742a55b46Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 191842a55b46Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 191942a55b46Smrg fi 192042a55b46Smrg} 192142a55b46Smrg# end func_convert_path_msys_to_cygwin 1922c582b7e3Smrg 1923c582b7e3Smrg 192442a55b46Smrg# func_convert_path_nix_to_cygwin ARG 192542a55b46Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 192642a55b46Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 192742a55b46Smrg# func_to_host_file_result. 192842a55b46Smrgfunc_convert_path_nix_to_cygwin () 192942a55b46Smrg{ 193042a55b46Smrg $opt_debug 193142a55b46Smrg func_to_host_path_result="$1" 193242a55b46Smrg if test -n "$1"; then 193342a55b46Smrg # Remove leading and trailing path separator characters from 193442a55b46Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 193542a55b46Smrg # into '.;' and ';.', and winepath ignores them completely. 193642a55b46Smrg func_stripname : : "$1" 193742a55b46Smrg func_to_host_path_tmp1=$func_stripname_result 193842a55b46Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 193942a55b46Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 194042a55b46Smrg func_to_host_path_result="$func_cygpath_result" 194142a55b46Smrg func_convert_path_check : : \ 194242a55b46Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 194342a55b46Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 194442a55b46Smrg fi 194542a55b46Smrg} 194642a55b46Smrg# end func_convert_path_nix_to_cygwin 1947c582b7e3Smrg 1948c582b7e3Smrg 194942a55b46Smrg# func_mode_compile arg... 195042a55b46Smrgfunc_mode_compile () 195142a55b46Smrg{ 195242a55b46Smrg $opt_debug 195342a55b46Smrg # Get the compilation command and the source file. 195442a55b46Smrg base_compile= 195542a55b46Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 195642a55b46Smrg suppress_opt=yes 195742a55b46Smrg suppress_output= 195842a55b46Smrg arg_mode=normal 195942a55b46Smrg libobj= 196042a55b46Smrg later= 196142a55b46Smrg pie_flag= 196242a55b46Smrg 196342a55b46Smrg for arg 196442a55b46Smrg do 196542a55b46Smrg case $arg_mode in 196642a55b46Smrg arg ) 196742a55b46Smrg # do not "continue". Instead, add this to base_compile 196842a55b46Smrg lastarg="$arg" 196942a55b46Smrg arg_mode=normal 197042a55b46Smrg ;; 197142a55b46Smrg 197242a55b46Smrg target ) 197342a55b46Smrg libobj="$arg" 197442a55b46Smrg arg_mode=normal 197542a55b46Smrg continue 197642a55b46Smrg ;; 197742a55b46Smrg 197842a55b46Smrg normal ) 197942a55b46Smrg # Accept any command-line options. 198042a55b46Smrg case $arg in 198142a55b46Smrg -o) 198242a55b46Smrg test -n "$libobj" && \ 198342a55b46Smrg func_fatal_error "you cannot specify \`-o' more than once" 198442a55b46Smrg arg_mode=target 1985c582b7e3Smrg continue 1986c582b7e3Smrg ;; 198742a55b46Smrg 198842a55b46Smrg -pie | -fpie | -fPIE) 198942a55b46Smrg func_append pie_flag " $arg" 1990c582b7e3Smrg continue 1991c582b7e3Smrg ;; 199242a55b46Smrg 199342a55b46Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 199442a55b46Smrg func_append later " $arg" 1995c582b7e3Smrg continue 1996c582b7e3Smrg ;; 199742a55b46Smrg 199842a55b46Smrg -no-suppress) 199942a55b46Smrg suppress_opt=no 2000c582b7e3Smrg continue 2001c582b7e3Smrg ;; 2002c582b7e3Smrg 200342a55b46Smrg -Xcompiler) 200442a55b46Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 200542a55b46Smrg continue # The current "srcfile" will either be retained or 200642a55b46Smrg ;; # replaced later. I would guess that would be a bug. 2007c582b7e3Smrg 200842a55b46Smrg -Wc,*) 200942a55b46Smrg func_stripname '-Wc,' '' "$arg" 201042a55b46Smrg args=$func_stripname_result 201142a55b46Smrg lastarg= 201242a55b46Smrg save_ifs="$IFS"; IFS=',' 201342a55b46Smrg for arg in $args; do 201442a55b46Smrg IFS="$save_ifs" 201542a55b46Smrg func_append_quoted lastarg "$arg" 201642a55b46Smrg done 201742a55b46Smrg IFS="$save_ifs" 201842a55b46Smrg func_stripname ' ' '' "$lastarg" 201942a55b46Smrg lastarg=$func_stripname_result 2020c582b7e3Smrg 202142a55b46Smrg # Add the arguments to base_compile. 202242a55b46Smrg func_append base_compile " $lastarg" 202342a55b46Smrg continue 202442a55b46Smrg ;; 2025c582b7e3Smrg 202642a55b46Smrg *) 202742a55b46Smrg # Accept the current argument as the source file. 202842a55b46Smrg # The previous "srcfile" becomes the current argument. 202942a55b46Smrg # 203042a55b46Smrg lastarg="$srcfile" 203142a55b46Smrg srcfile="$arg" 203242a55b46Smrg ;; 203342a55b46Smrg esac # case $arg 2034c582b7e3Smrg ;; 203542a55b46Smrg esac # case $arg_mode 2036c582b7e3Smrg 203742a55b46Smrg # Aesthetically quote the previous argument. 203842a55b46Smrg func_append_quoted base_compile "$lastarg" 203942a55b46Smrg done # for arg 2040c582b7e3Smrg 204142a55b46Smrg case $arg_mode in 204242a55b46Smrg arg) 204342a55b46Smrg func_fatal_error "you must specify an argument for -Xcompile" 204442a55b46Smrg ;; 204542a55b46Smrg target) 204642a55b46Smrg func_fatal_error "you must specify a target with \`-o'" 204742a55b46Smrg ;; 204842a55b46Smrg *) 204942a55b46Smrg # Get the name of the library object. 205042a55b46Smrg test -z "$libobj" && { 205142a55b46Smrg func_basename "$srcfile" 205242a55b46Smrg libobj="$func_basename_result" 205342a55b46Smrg } 205442a55b46Smrg ;; 205542a55b46Smrg esac 2056c582b7e3Smrg 205742a55b46Smrg # Recognize several different file suffixes. 205842a55b46Smrg # If the user specifies -o file.o, it is replaced with file.lo 205942a55b46Smrg case $libobj in 206042a55b46Smrg *.[cCFSifmso] | \ 206142a55b46Smrg *.ada | *.adb | *.ads | *.asm | \ 206242a55b46Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 206342a55b46Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 206442a55b46Smrg func_xform "$libobj" 206542a55b46Smrg libobj=$func_xform_result 206642a55b46Smrg ;; 206742a55b46Smrg esac 2068c582b7e3Smrg 206942a55b46Smrg case $libobj in 207042a55b46Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 207142a55b46Smrg *) 207242a55b46Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 207342a55b46Smrg ;; 207442a55b46Smrg esac 2075c582b7e3Smrg 207642a55b46Smrg func_infer_tag $base_compile 2077c582b7e3Smrg 207842a55b46Smrg for arg in $later; do 207942a55b46Smrg case $arg in 208042a55b46Smrg -shared) 208142a55b46Smrg test "$build_libtool_libs" != yes && \ 208242a55b46Smrg func_fatal_configuration "can not build a shared library" 208342a55b46Smrg build_old_libs=no 2084c582b7e3Smrg continue 2085c582b7e3Smrg ;; 2086c582b7e3Smrg 208742a55b46Smrg -static) 208842a55b46Smrg build_libtool_libs=no 208942a55b46Smrg build_old_libs=yes 2090c582b7e3Smrg continue 2091c582b7e3Smrg ;; 2092c582b7e3Smrg 209342a55b46Smrg -prefer-pic) 209442a55b46Smrg pic_mode=yes 2095c582b7e3Smrg continue 2096c582b7e3Smrg ;; 2097c582b7e3Smrg 209842a55b46Smrg -prefer-non-pic) 209942a55b46Smrg pic_mode=no 2100c582b7e3Smrg continue 2101c582b7e3Smrg ;; 210242a55b46Smrg esac 210342a55b46Smrg done 2104c582b7e3Smrg 210542a55b46Smrg func_quote_for_eval "$libobj" 210642a55b46Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 210742a55b46Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 210842a55b46Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 210942a55b46Smrg func_dirname_and_basename "$obj" "/" "" 211042a55b46Smrg objname="$func_basename_result" 211142a55b46Smrg xdir="$func_dirname_result" 211242a55b46Smrg lobj=${xdir}$objdir/$objname 2113c582b7e3Smrg 211442a55b46Smrg test -z "$base_compile" && \ 211542a55b46Smrg func_fatal_help "you must specify a compilation command" 211619019ffeSmrg 211742a55b46Smrg # Delete any leftover library objects. 211842a55b46Smrg if test "$build_old_libs" = yes; then 211942a55b46Smrg removelist="$obj $lobj $libobj ${libobj}T" 212042a55b46Smrg else 212142a55b46Smrg removelist="$lobj $libobj ${libobj}T" 212242a55b46Smrg fi 2123c582b7e3Smrg 212442a55b46Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 212542a55b46Smrg case $host_os in 212642a55b46Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 212742a55b46Smrg pic_mode=default 212842a55b46Smrg ;; 212942a55b46Smrg esac 213042a55b46Smrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 213142a55b46Smrg # non-PIC code in shared libraries is not supported 213242a55b46Smrg pic_mode=default 213342a55b46Smrg fi 2134c582b7e3Smrg 213542a55b46Smrg # Calculate the filename of the output object if compiler does 213642a55b46Smrg # not support -o with -c 213742a55b46Smrg if test "$compiler_c_o" = no; then 213842a55b46Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 213942a55b46Smrg lockfile="$output_obj.lock" 214042a55b46Smrg else 214142a55b46Smrg output_obj= 214242a55b46Smrg need_locks=no 214342a55b46Smrg lockfile= 214442a55b46Smrg fi 2145c582b7e3Smrg 214642a55b46Smrg # Lock this critical section if it is needed 214742a55b46Smrg # We use this script file to make the link, it avoids creating a new file 214842a55b46Smrg if test "$need_locks" = yes; then 214942a55b46Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 215042a55b46Smrg func_echo "Waiting for $lockfile to be removed" 215142a55b46Smrg sleep 2 215242a55b46Smrg done 215342a55b46Smrg elif test "$need_locks" = warn; then 215442a55b46Smrg if test -f "$lockfile"; then 215542a55b46Smrg $ECHO "\ 215642a55b46Smrg*** ERROR, $lockfile exists and contains: 215742a55b46Smrg`cat $lockfile 2>/dev/null` 2158c582b7e3Smrg 215942a55b46SmrgThis indicates that another process is trying to use the same 216042a55b46Smrgtemporary object file, and libtool could not work around it because 216142a55b46Smrgyour compiler does not support \`-c' and \`-o' together. If you 216242a55b46Smrgrepeat this compilation, it may succeed, by chance, but you had better 216342a55b46Smrgavoid parallel builds (make -j) in this platform, or get a better 216442a55b46Smrgcompiler." 2165c582b7e3Smrg 216642a55b46Smrg $opt_dry_run || $RM $removelist 216742a55b46Smrg exit $EXIT_FAILURE 216842a55b46Smrg fi 216942a55b46Smrg func_append removelist " $output_obj" 217042a55b46Smrg $ECHO "$srcfile" > "$lockfile" 217142a55b46Smrg fi 2172c582b7e3Smrg 217342a55b46Smrg $opt_dry_run || $RM $removelist 217442a55b46Smrg func_append removelist " $lockfile" 217542a55b46Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 2176c582b7e3Smrg 217742a55b46Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 217842a55b46Smrg srcfile=$func_to_tool_file_result 217942a55b46Smrg func_quote_for_eval "$srcfile" 218042a55b46Smrg qsrcfile=$func_quote_for_eval_result 2181c582b7e3Smrg 218242a55b46Smrg # Only build a PIC object if we are building libtool libraries. 218342a55b46Smrg if test "$build_libtool_libs" = yes; then 218442a55b46Smrg # Without this assignment, base_compile gets emptied. 218542a55b46Smrg fbsd_hideous_sh_bug=$base_compile 2186c582b7e3Smrg 218742a55b46Smrg if test "$pic_mode" != no; then 218842a55b46Smrg command="$base_compile $qsrcfile $pic_flag" 218942a55b46Smrg else 219042a55b46Smrg # Don't build PIC code 219142a55b46Smrg command="$base_compile $qsrcfile" 219242a55b46Smrg fi 2193c582b7e3Smrg 219442a55b46Smrg func_mkdir_p "$xdir$objdir" 2195c582b7e3Smrg 219642a55b46Smrg if test -z "$output_obj"; then 219742a55b46Smrg # Place PIC objects in $objdir 219842a55b46Smrg func_append command " -o $lobj" 219942a55b46Smrg fi 2200c582b7e3Smrg 220142a55b46Smrg func_show_eval_locale "$command" \ 220242a55b46Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 2203c582b7e3Smrg 220442a55b46Smrg if test "$need_locks" = warn && 220542a55b46Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 220642a55b46Smrg $ECHO "\ 220742a55b46Smrg*** ERROR, $lockfile contains: 220842a55b46Smrg`cat $lockfile 2>/dev/null` 2209c582b7e3Smrg 221042a55b46Smrgbut it should contain: 221142a55b46Smrg$srcfile 2212c582b7e3Smrg 221342a55b46SmrgThis indicates that another process is trying to use the same 221442a55b46Smrgtemporary object file, and libtool could not work around it because 221542a55b46Smrgyour compiler does not support \`-c' and \`-o' together. If you 221642a55b46Smrgrepeat this compilation, it may succeed, by chance, but you had better 221742a55b46Smrgavoid parallel builds (make -j) in this platform, or get a better 221842a55b46Smrgcompiler." 2219c582b7e3Smrg 222042a55b46Smrg $opt_dry_run || $RM $removelist 222142a55b46Smrg exit $EXIT_FAILURE 222242a55b46Smrg fi 2223c582b7e3Smrg 222442a55b46Smrg # Just move the object if needed, then go on to compile the next one 222542a55b46Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 222642a55b46Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 222742a55b46Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 222842a55b46Smrg fi 2229c582b7e3Smrg 223042a55b46Smrg # Allow error messages only from the first compilation. 223142a55b46Smrg if test "$suppress_opt" = yes; then 223242a55b46Smrg suppress_output=' >/dev/null 2>&1' 223342a55b46Smrg fi 223442a55b46Smrg fi 2235c582b7e3Smrg 223642a55b46Smrg # Only build a position-dependent object if we build old libraries. 223742a55b46Smrg if test "$build_old_libs" = yes; then 223842a55b46Smrg if test "$pic_mode" != yes; then 223942a55b46Smrg # Don't build PIC code 224042a55b46Smrg command="$base_compile $qsrcfile$pie_flag" 224142a55b46Smrg else 224242a55b46Smrg command="$base_compile $qsrcfile $pic_flag" 224342a55b46Smrg fi 224442a55b46Smrg if test "$compiler_c_o" = yes; then 224542a55b46Smrg func_append command " -o $obj" 224642a55b46Smrg fi 2247c582b7e3Smrg 224842a55b46Smrg # Suppress compiler output if we already did a PIC compilation. 224942a55b46Smrg func_append command "$suppress_output" 225042a55b46Smrg func_show_eval_locale "$command" \ 225142a55b46Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 2252c582b7e3Smrg 225342a55b46Smrg if test "$need_locks" = warn && 225442a55b46Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 225542a55b46Smrg $ECHO "\ 225642a55b46Smrg*** ERROR, $lockfile contains: 225742a55b46Smrg`cat $lockfile 2>/dev/null` 2258c582b7e3Smrg 225942a55b46Smrgbut it should contain: 226042a55b46Smrg$srcfile 2261c582b7e3Smrg 226242a55b46SmrgThis indicates that another process is trying to use the same 226342a55b46Smrgtemporary object file, and libtool could not work around it because 226442a55b46Smrgyour compiler does not support \`-c' and \`-o' together. If you 226542a55b46Smrgrepeat this compilation, it may succeed, by chance, but you had better 226642a55b46Smrgavoid parallel builds (make -j) in this platform, or get a better 226742a55b46Smrgcompiler." 2268c582b7e3Smrg 226942a55b46Smrg $opt_dry_run || $RM $removelist 227042a55b46Smrg exit $EXIT_FAILURE 227142a55b46Smrg fi 2272c582b7e3Smrg 227342a55b46Smrg # Just move the object if needed 227442a55b46Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 227542a55b46Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 227642a55b46Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 227742a55b46Smrg fi 227842a55b46Smrg fi 2279c582b7e3Smrg 228042a55b46Smrg $opt_dry_run || { 228142a55b46Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 2282c582b7e3Smrg 228342a55b46Smrg # Unlock the critical section if it was locked 228442a55b46Smrg if test "$need_locks" != no; then 228542a55b46Smrg removelist=$lockfile 228642a55b46Smrg $RM "$lockfile" 228742a55b46Smrg fi 228842a55b46Smrg } 2289c582b7e3Smrg 229042a55b46Smrg exit $EXIT_SUCCESS 229142a55b46Smrg} 2292c582b7e3Smrg 229342a55b46Smrg$opt_help || { 229442a55b46Smrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 229542a55b46Smrg} 2296c582b7e3Smrg 229742a55b46Smrgfunc_mode_help () 229842a55b46Smrg{ 229942a55b46Smrg # We need to display help for each of the modes. 230042a55b46Smrg case $opt_mode in 230142a55b46Smrg "") 230242a55b46Smrg # Generic help is extracted from the usage comments 230342a55b46Smrg # at the start of this file. 230442a55b46Smrg func_help 230542a55b46Smrg ;; 2306c582b7e3Smrg 230742a55b46Smrg clean) 230842a55b46Smrg $ECHO \ 230942a55b46Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 2310c582b7e3Smrg 231142a55b46SmrgRemove files from the build directory. 2312c582b7e3Smrg 231342a55b46SmrgRM is the name of the program to use to delete files associated with each FILE 231442a55b46Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 231542a55b46Smrgto RM. 2316c582b7e3Smrg 231742a55b46SmrgIf FILE is a libtool library, object or program, all the files associated 231842a55b46Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 231942a55b46Smrg ;; 2320c582b7e3Smrg 232142a55b46Smrg compile) 232242a55b46Smrg $ECHO \ 232342a55b46Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 2324c582b7e3Smrg 232542a55b46SmrgCompile a source file into a libtool library object. 2326c582b7e3Smrg 232742a55b46SmrgThis mode accepts the following additional options: 2328c582b7e3Smrg 232942a55b46Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 233042a55b46Smrg -no-suppress do not suppress compiler output for multiple passes 233142a55b46Smrg -prefer-pic try to build PIC objects only 233242a55b46Smrg -prefer-non-pic try to build non-PIC objects only 233342a55b46Smrg -shared do not build a \`.o' file suitable for static linking 233442a55b46Smrg -static only build a \`.o' file suitable for static linking 233542a55b46Smrg -Wc,FLAG pass FLAG directly to the compiler 2336c582b7e3Smrg 233742a55b46SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 233842a55b46Smrgfrom the given SOURCEFILE. 2339c582b7e3Smrg 234042a55b46SmrgThe output file name is determined by removing the directory component from 234142a55b46SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 234242a55b46Smrglibrary object suffix, \`.lo'." 234342a55b46Smrg ;; 2344c582b7e3Smrg 234542a55b46Smrg execute) 234642a55b46Smrg $ECHO \ 234742a55b46Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 2348c582b7e3Smrg 234942a55b46SmrgAutomatically set library path, then run a program. 2350c582b7e3Smrg 235142a55b46SmrgThis mode accepts the following additional options: 2352c582b7e3Smrg 235342a55b46Smrg -dlopen FILE add the directory containing FILE to the library path 2354c582b7e3Smrg 235542a55b46SmrgThis mode sets the library path environment variable according to \`-dlopen' 235642a55b46Smrgflags. 2357c582b7e3Smrg 235842a55b46SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 235942a55b46Smrginto their corresponding uninstalled binary, and any of their required library 236042a55b46Smrgdirectories are added to the library path. 2361c582b7e3Smrg 236242a55b46SmrgThen, COMMAND is executed, with ARGS as arguments." 236342a55b46Smrg ;; 236442a55b46Smrg 236542a55b46Smrg finish) 236642a55b46Smrg $ECHO \ 236742a55b46Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 236842a55b46Smrg 236942a55b46SmrgComplete the installation of libtool libraries. 237042a55b46Smrg 237142a55b46SmrgEach LIBDIR is a directory that contains libtool libraries. 237242a55b46Smrg 237342a55b46SmrgThe commands that this mode executes may require superuser privileges. Use 237442a55b46Smrgthe \`--dry-run' option if you just want to see what would be executed." 237542a55b46Smrg ;; 237642a55b46Smrg 237742a55b46Smrg install) 237842a55b46Smrg $ECHO \ 237942a55b46Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 238042a55b46Smrg 238142a55b46SmrgInstall executables or libraries. 238242a55b46Smrg 238342a55b46SmrgINSTALL-COMMAND is the installation command. The first component should be 238442a55b46Smrgeither the \`install' or \`cp' program. 238542a55b46Smrg 238642a55b46SmrgThe following components of INSTALL-COMMAND are treated specially: 238742a55b46Smrg 238842a55b46Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 238942a55b46Smrg 239042a55b46SmrgThe rest of the components are interpreted as arguments to that command (only 239142a55b46SmrgBSD-compatible install options are recognized)." 239242a55b46Smrg ;; 239342a55b46Smrg 239442a55b46Smrg link) 239542a55b46Smrg $ECHO \ 239642a55b46Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 239742a55b46Smrg 239842a55b46SmrgLink object files or libraries together to form another library, or to 239942a55b46Smrgcreate an executable program. 240042a55b46Smrg 240142a55b46SmrgLINK-COMMAND is a command using the C compiler that you would use to create 240242a55b46Smrga program from several object files. 240342a55b46Smrg 240442a55b46SmrgThe following components of LINK-COMMAND are treated specially: 240542a55b46Smrg 240642a55b46Smrg -all-static do not do any dynamic linking at all 240742a55b46Smrg -avoid-version do not add a version suffix if possible 240842a55b46Smrg -bindir BINDIR specify path to binaries directory (for systems where 240942a55b46Smrg libraries must be found in the PATH setting at runtime) 241042a55b46Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 241142a55b46Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 241242a55b46Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 241342a55b46Smrg -export-symbols SYMFILE 241442a55b46Smrg try to export only the symbols listed in SYMFILE 241542a55b46Smrg -export-symbols-regex REGEX 241642a55b46Smrg try to export only the symbols matching REGEX 241742a55b46Smrg -LLIBDIR search LIBDIR for required installed libraries 241842a55b46Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 241942a55b46Smrg -module build a library that can dlopened 242042a55b46Smrg -no-fast-install disable the fast-install mode 242142a55b46Smrg -no-install link a not-installable executable 242242a55b46Smrg -no-undefined declare that a library does not refer to external symbols 242342a55b46Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 242442a55b46Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 242542a55b46Smrg -precious-files-regex REGEX 242642a55b46Smrg don't remove output files matching REGEX 242742a55b46Smrg -release RELEASE specify package release information 242842a55b46Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 242942a55b46Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 243042a55b46Smrg -shared only do dynamic linking of libtool libraries 243142a55b46Smrg -shrext SUFFIX override the standard shared library file extension 243242a55b46Smrg -static do not do any dynamic linking of uninstalled libtool libraries 243342a55b46Smrg -static-libtool-libs 243442a55b46Smrg do not do any dynamic linking of libtool libraries 243542a55b46Smrg -version-info CURRENT[:REVISION[:AGE]] 243642a55b46Smrg specify library version info [each variable defaults to 0] 243742a55b46Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 243842a55b46Smrg -Wc,FLAG 243942a55b46Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 244042a55b46Smrg -Wl,FLAG 244142a55b46Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 244242a55b46Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 244342a55b46Smrg 244442a55b46SmrgAll other options (arguments beginning with \`-') are ignored. 244542a55b46Smrg 244642a55b46SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 244742a55b46Smrgtreated as uninstalled libtool libraries, other files are standard or library 244842a55b46Smrgobject files. 244942a55b46Smrg 245042a55b46SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 245142a55b46Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 245242a55b46Smrgrequired, except when creating a convenience library. 245342a55b46Smrg 245442a55b46SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 245542a55b46Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 245642a55b46Smrg 245742a55b46SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 245842a55b46Smrgis created, otherwise an executable program is created." 245942a55b46Smrg ;; 246042a55b46Smrg 246142a55b46Smrg uninstall) 246242a55b46Smrg $ECHO \ 246342a55b46Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 246442a55b46Smrg 246542a55b46SmrgRemove libraries from an installation directory. 246642a55b46Smrg 246742a55b46SmrgRM is the name of the program to use to delete files associated with each FILE 246842a55b46Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 246942a55b46Smrgto RM. 247042a55b46Smrg 247142a55b46SmrgIf FILE is a libtool library, all the files associated with it are deleted. 247242a55b46SmrgOtherwise, only FILE itself is deleted using RM." 247342a55b46Smrg ;; 247442a55b46Smrg 247542a55b46Smrg *) 247642a55b46Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 247742a55b46Smrg ;; 2478c582b7e3Smrg esac 2479c582b7e3Smrg 248042a55b46Smrg echo 248142a55b46Smrg $ECHO "Try \`$progname --help' for more information about other modes." 248242a55b46Smrg} 2483c582b7e3Smrg 248442a55b46Smrg# Now that we've collected a possible --mode arg, show help if necessary 248542a55b46Smrgif $opt_help; then 248642a55b46Smrg if test "$opt_help" = :; then 248742a55b46Smrg func_mode_help 248842a55b46Smrg else 248942a55b46Smrg { 249042a55b46Smrg func_help noexit 249142a55b46Smrg for opt_mode in compile link execute install finish uninstall clean; do 249242a55b46Smrg func_mode_help 249342a55b46Smrg done 249442a55b46Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 249542a55b46Smrg { 249642a55b46Smrg func_help noexit 249742a55b46Smrg for opt_mode in compile link execute install finish uninstall clean; do 249842a55b46Smrg echo 249942a55b46Smrg func_mode_help 250042a55b46Smrg done 250142a55b46Smrg } | 250242a55b46Smrg sed '1d 250342a55b46Smrg /^When reporting/,/^Report/{ 250442a55b46Smrg H 250542a55b46Smrg d 250642a55b46Smrg } 250742a55b46Smrg $x 250842a55b46Smrg /information about other modes/d 250942a55b46Smrg /more detailed .*MODE/d 251042a55b46Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 251142a55b46Smrg fi 251242a55b46Smrg exit $? 251342a55b46Smrgfi 2514c582b7e3Smrg 2515c582b7e3Smrg 251642a55b46Smrg# func_mode_execute arg... 251742a55b46Smrgfunc_mode_execute () 251842a55b46Smrg{ 251942a55b46Smrg $opt_debug 252042a55b46Smrg # The first argument is the command name. 252142a55b46Smrg cmd="$nonopt" 252242a55b46Smrg test -z "$cmd" && \ 252342a55b46Smrg func_fatal_help "you must specify a COMMAND" 252442a55b46Smrg 252542a55b46Smrg # Handle -dlopen flags immediately. 252642a55b46Smrg for file in $opt_dlopen; do 252742a55b46Smrg test -f "$file" \ 252842a55b46Smrg || func_fatal_help "\`$file' is not a file" 252942a55b46Smrg 253042a55b46Smrg dir= 253142a55b46Smrg case $file in 253242a55b46Smrg *.la) 253342a55b46Smrg func_resolve_sysroot "$file" 253442a55b46Smrg file=$func_resolve_sysroot_result 253542a55b46Smrg 253642a55b46Smrg # Check to see that this really is a libtool archive. 253742a55b46Smrg func_lalib_unsafe_p "$file" \ 253842a55b46Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 253942a55b46Smrg 254042a55b46Smrg # Read the libtool library. 254142a55b46Smrg dlname= 254242a55b46Smrg library_names= 254342a55b46Smrg func_source "$file" 254442a55b46Smrg 254542a55b46Smrg # Skip this library if it cannot be dlopened. 254642a55b46Smrg if test -z "$dlname"; then 254742a55b46Smrg # Warn if it was a shared library. 254842a55b46Smrg test -n "$library_names" && \ 254942a55b46Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 255042a55b46Smrg continue 255142a55b46Smrg fi 255242a55b46Smrg 255342a55b46Smrg func_dirname "$file" "" "." 255442a55b46Smrg dir="$func_dirname_result" 255542a55b46Smrg 255642a55b46Smrg if test -f "$dir/$objdir/$dlname"; then 255742a55b46Smrg func_append dir "/$objdir" 255842a55b46Smrg else 255942a55b46Smrg if test ! -f "$dir/$dlname"; then 256042a55b46Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 256142a55b46Smrg fi 256242a55b46Smrg fi 2563c582b7e3Smrg ;; 256442a55b46Smrg 256542a55b46Smrg *.lo) 256642a55b46Smrg # Just add the directory containing the .lo file. 256742a55b46Smrg func_dirname "$file" "" "." 256842a55b46Smrg dir="$func_dirname_result" 2569c582b7e3Smrg ;; 257042a55b46Smrg 257142a55b46Smrg *) 257242a55b46Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 257342a55b46Smrg continue 2574c582b7e3Smrg ;; 257542a55b46Smrg esac 257642a55b46Smrg 257742a55b46Smrg # Get the absolute pathname. 257842a55b46Smrg absdir=`cd "$dir" && pwd` 257942a55b46Smrg test -n "$absdir" && dir="$absdir" 258042a55b46Smrg 258142a55b46Smrg # Now add the directory to shlibpath_var. 258242a55b46Smrg if eval "test -z \"\$$shlibpath_var\""; then 258342a55b46Smrg eval "$shlibpath_var=\"\$dir\"" 258442a55b46Smrg else 258542a55b46Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 2586c582b7e3Smrg fi 258742a55b46Smrg done 258842a55b46Smrg 258942a55b46Smrg # This variable tells wrapper scripts just to set shlibpath_var 259042a55b46Smrg # rather than running their programs. 259142a55b46Smrg libtool_execute_magic="$magic" 259242a55b46Smrg 259342a55b46Smrg # Check if any of the arguments is a wrapper script. 259442a55b46Smrg args= 259542a55b46Smrg for file 259642a55b46Smrg do 259742a55b46Smrg case $file in 259842a55b46Smrg -* | *.la | *.lo ) ;; 259942a55b46Smrg *) 260042a55b46Smrg # Do a test to see if this is really a libtool program. 260142a55b46Smrg if func_ltwrapper_script_p "$file"; then 260242a55b46Smrg func_source "$file" 260342a55b46Smrg # Transform arg to wrapped name. 260442a55b46Smrg file="$progdir/$program" 260542a55b46Smrg elif func_ltwrapper_executable_p "$file"; then 260642a55b46Smrg func_ltwrapper_scriptname "$file" 260742a55b46Smrg func_source "$func_ltwrapper_scriptname_result" 260842a55b46Smrg # Transform arg to wrapped name. 260942a55b46Smrg file="$progdir/$program" 261042a55b46Smrg fi 261142a55b46Smrg ;; 261242a55b46Smrg esac 261342a55b46Smrg # Quote arguments (to preserve shell metacharacters). 261442a55b46Smrg func_append_quoted args "$file" 261542a55b46Smrg done 261642a55b46Smrg 261742a55b46Smrg if test "X$opt_dry_run" = Xfalse; then 261842a55b46Smrg if test -n "$shlibpath_var"; then 261942a55b46Smrg # Export the shlibpath_var. 262042a55b46Smrg eval "export $shlibpath_var" 2621c582b7e3Smrg fi 262242a55b46Smrg 262342a55b46Smrg # Restore saved environment variables 262442a55b46Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 262542a55b46Smrg do 262642a55b46Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 262742a55b46Smrg $lt_var=\$save_$lt_var; export $lt_var 262842a55b46Smrg else 262942a55b46Smrg $lt_unset $lt_var 263042a55b46Smrg fi" 263142a55b46Smrg done 263242a55b46Smrg 263342a55b46Smrg # Now prepare to actually exec the command. 263442a55b46Smrg exec_cmd="\$cmd$args" 263542a55b46Smrg else 263642a55b46Smrg # Display what would be done. 263742a55b46Smrg if test -n "$shlibpath_var"; then 263842a55b46Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 263942a55b46Smrg echo "export $shlibpath_var" 2640c582b7e3Smrg fi 264142a55b46Smrg $ECHO "$cmd$args" 264242a55b46Smrg exit $EXIT_SUCCESS 264342a55b46Smrg fi 264442a55b46Smrg} 2645c582b7e3Smrg 264642a55b46Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 2647c582b7e3Smrg 2648c582b7e3Smrg 264942a55b46Smrg# func_mode_finish arg... 265042a55b46Smrgfunc_mode_finish () 265142a55b46Smrg{ 265242a55b46Smrg $opt_debug 265342a55b46Smrg libs= 265442a55b46Smrg libdirs= 265542a55b46Smrg admincmds= 2656c582b7e3Smrg 265742a55b46Smrg for opt in "$nonopt" ${1+"$@"} 265842a55b46Smrg do 265942a55b46Smrg if test -d "$opt"; then 266042a55b46Smrg func_append libdirs " $opt" 2661c582b7e3Smrg 266242a55b46Smrg elif test -f "$opt"; then 266342a55b46Smrg if func_lalib_unsafe_p "$opt"; then 266442a55b46Smrg func_append libs " $opt" 266542a55b46Smrg else 266642a55b46Smrg func_warning "\`$opt' is not a valid libtool archive" 2667c582b7e3Smrg fi 2668c582b7e3Smrg 266942a55b46Smrg else 267042a55b46Smrg func_fatal_error "invalid argument \`$opt'" 267142a55b46Smrg fi 267242a55b46Smrg done 2673c582b7e3Smrg 267442a55b46Smrg if test -n "$libs"; then 267542a55b46Smrg if test -n "$lt_sysroot"; then 267642a55b46Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 267742a55b46Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 267842a55b46Smrg else 267942a55b46Smrg sysroot_cmd= 268042a55b46Smrg fi 2681c582b7e3Smrg 268242a55b46Smrg # Remove sysroot references 268342a55b46Smrg if $opt_dry_run; then 268442a55b46Smrg for lib in $libs; do 268542a55b46Smrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 268642a55b46Smrg done 268742a55b46Smrg else 268842a55b46Smrg tmpdir=`func_mktempdir` 268942a55b46Smrg for lib in $libs; do 269042a55b46Smrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 269142a55b46Smrg > $tmpdir/tmp-la 269242a55b46Smrg mv -f $tmpdir/tmp-la $lib 2693c582b7e3Smrg done 269442a55b46Smrg ${RM}r "$tmpdir" 269542a55b46Smrg fi 269642a55b46Smrg fi 269742a55b46Smrg 269842a55b46Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 269942a55b46Smrg for libdir in $libdirs; do 270042a55b46Smrg if test -n "$finish_cmds"; then 270142a55b46Smrg # Do each command in the finish commands. 270242a55b46Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 270342a55b46Smrg'"$cmd"'"' 270442a55b46Smrg fi 270542a55b46Smrg if test -n "$finish_eval"; then 270642a55b46Smrg # Do the single finish_eval. 270742a55b46Smrg eval cmds=\"$finish_eval\" 270842a55b46Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 270942a55b46Smrg $cmds" 2710c582b7e3Smrg fi 271142a55b46Smrg done 271242a55b46Smrg fi 2713c582b7e3Smrg 271442a55b46Smrg # Exit here if they wanted silent mode. 271542a55b46Smrg $opt_silent && exit $EXIT_SUCCESS 2716c582b7e3Smrg 271742a55b46Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 271842a55b46Smrg echo "----------------------------------------------------------------------" 271942a55b46Smrg echo "Libraries have been installed in:" 272042a55b46Smrg for libdir in $libdirs; do 272142a55b46Smrg $ECHO " $libdir" 272242a55b46Smrg done 272342a55b46Smrg echo 272442a55b46Smrg echo "If you ever happen to want to link against installed libraries" 272542a55b46Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 272642a55b46Smrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 272742a55b46Smrg echo "flag during linking and do at least one of the following:" 272842a55b46Smrg if test -n "$shlibpath_var"; then 272942a55b46Smrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 273042a55b46Smrg echo " during execution" 273142a55b46Smrg fi 273242a55b46Smrg if test -n "$runpath_var"; then 273342a55b46Smrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 273442a55b46Smrg echo " during linking" 273542a55b46Smrg fi 273642a55b46Smrg if test -n "$hardcode_libdir_flag_spec"; then 273742a55b46Smrg libdir=LIBDIR 273842a55b46Smrg eval flag=\"$hardcode_libdir_flag_spec\" 273942a55b46Smrg 274042a55b46Smrg $ECHO " - use the \`$flag' linker flag" 274142a55b46Smrg fi 274242a55b46Smrg if test -n "$admincmds"; then 274342a55b46Smrg $ECHO " - have your system administrator run these commands:$admincmds" 274442a55b46Smrg fi 274542a55b46Smrg if test -f /etc/ld.so.conf; then 274642a55b46Smrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 274742a55b46Smrg fi 274842a55b46Smrg echo 274942a55b46Smrg 275042a55b46Smrg echo "See any operating system documentation about shared libraries for" 275142a55b46Smrg case $host in 275242a55b46Smrg solaris2.[6789]|solaris2.1[0-9]) 275342a55b46Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 275442a55b46Smrg echo "pages." 275542a55b46Smrg ;; 2756c582b7e3Smrg *) 275742a55b46Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 2758c582b7e3Smrg ;; 275942a55b46Smrg esac 276042a55b46Smrg echo "----------------------------------------------------------------------" 276142a55b46Smrg fi 276242a55b46Smrg exit $EXIT_SUCCESS 276342a55b46Smrg} 2764c582b7e3Smrg 276542a55b46Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 2766c582b7e3Smrg 2767c582b7e3Smrg 276842a55b46Smrg# func_mode_install arg... 276942a55b46Smrgfunc_mode_install () 277042a55b46Smrg{ 277142a55b46Smrg $opt_debug 277242a55b46Smrg # There may be an optional sh(1) argument at the beginning of 277342a55b46Smrg # install_prog (especially on Windows NT). 277442a55b46Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 277542a55b46Smrg # Allow the use of GNU shtool's install command. 277642a55b46Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 277742a55b46Smrg # Aesthetically quote it. 277842a55b46Smrg func_quote_for_eval "$nonopt" 277942a55b46Smrg install_prog="$func_quote_for_eval_result " 278042a55b46Smrg arg=$1 278142a55b46Smrg shift 278242a55b46Smrg else 278342a55b46Smrg install_prog= 278442a55b46Smrg arg=$nonopt 278542a55b46Smrg fi 278642a55b46Smrg 278742a55b46Smrg # The real first argument should be the name of the installation program. 278842a55b46Smrg # Aesthetically quote it. 278942a55b46Smrg func_quote_for_eval "$arg" 279042a55b46Smrg func_append install_prog "$func_quote_for_eval_result" 279142a55b46Smrg install_shared_prog=$install_prog 279242a55b46Smrg case " $install_prog " in 279342a55b46Smrg *[\\\ /]cp\ *) install_cp=: ;; 279442a55b46Smrg *) install_cp=false ;; 279542a55b46Smrg esac 279642a55b46Smrg 279742a55b46Smrg # We need to accept at least all the BSD install flags. 279842a55b46Smrg dest= 279942a55b46Smrg files= 280042a55b46Smrg opts= 280142a55b46Smrg prev= 280242a55b46Smrg install_type= 280342a55b46Smrg isdir=no 280442a55b46Smrg stripme= 280542a55b46Smrg no_mode=: 280642a55b46Smrg for arg 280742a55b46Smrg do 280842a55b46Smrg arg2= 280942a55b46Smrg if test -n "$dest"; then 281042a55b46Smrg func_append files " $dest" 281142a55b46Smrg dest=$arg 281242a55b46Smrg continue 281342a55b46Smrg fi 281442a55b46Smrg 281542a55b46Smrg case $arg in 281642a55b46Smrg -d) isdir=yes ;; 281742a55b46Smrg -f) 281842a55b46Smrg if $install_cp; then :; else 281942a55b46Smrg prev=$arg 282042a55b46Smrg fi 282142a55b46Smrg ;; 282242a55b46Smrg -g | -m | -o) 282342a55b46Smrg prev=$arg 282442a55b46Smrg ;; 282542a55b46Smrg -s) 282642a55b46Smrg stripme=" -s" 282742a55b46Smrg continue 282842a55b46Smrg ;; 282942a55b46Smrg -*) 283042a55b46Smrg ;; 283142a55b46Smrg *) 283242a55b46Smrg # If the previous option needed an argument, then skip it. 283342a55b46Smrg if test -n "$prev"; then 283442a55b46Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 283542a55b46Smrg arg2=$install_override_mode 283642a55b46Smrg no_mode=false 2837c582b7e3Smrg fi 283842a55b46Smrg prev= 283942a55b46Smrg else 284042a55b46Smrg dest=$arg 2841c582b7e3Smrg continue 2842c582b7e3Smrg fi 284342a55b46Smrg ;; 284442a55b46Smrg esac 2845c582b7e3Smrg 284642a55b46Smrg # Aesthetically quote the argument. 284742a55b46Smrg func_quote_for_eval "$arg" 284842a55b46Smrg func_append install_prog " $func_quote_for_eval_result" 284942a55b46Smrg if test -n "$arg2"; then 285042a55b46Smrg func_quote_for_eval "$arg2" 285142a55b46Smrg fi 285242a55b46Smrg func_append install_shared_prog " $func_quote_for_eval_result" 285342a55b46Smrg done 2854c582b7e3Smrg 285542a55b46Smrg test -z "$install_prog" && \ 285642a55b46Smrg func_fatal_help "you must specify an install program" 2857c582b7e3Smrg 285842a55b46Smrg test -n "$prev" && \ 285942a55b46Smrg func_fatal_help "the \`$prev' option requires an argument" 2860c582b7e3Smrg 286142a55b46Smrg if test -n "$install_override_mode" && $no_mode; then 286242a55b46Smrg if $install_cp; then :; else 286342a55b46Smrg func_quote_for_eval "$install_override_mode" 286442a55b46Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 286542a55b46Smrg fi 286642a55b46Smrg fi 2867c582b7e3Smrg 286842a55b46Smrg if test -z "$files"; then 286942a55b46Smrg if test -z "$dest"; then 287042a55b46Smrg func_fatal_help "no file or destination specified" 287142a55b46Smrg else 287242a55b46Smrg func_fatal_help "you must specify a destination" 287342a55b46Smrg fi 287442a55b46Smrg fi 2875c582b7e3Smrg 287642a55b46Smrg # Strip any trailing slash from the destination. 287742a55b46Smrg func_stripname '' '/' "$dest" 287842a55b46Smrg dest=$func_stripname_result 2879c582b7e3Smrg 288042a55b46Smrg # Check to see that the destination is a directory. 288142a55b46Smrg test -d "$dest" && isdir=yes 288242a55b46Smrg if test "$isdir" = yes; then 288342a55b46Smrg destdir="$dest" 288442a55b46Smrg destname= 288542a55b46Smrg else 288642a55b46Smrg func_dirname_and_basename "$dest" "" "." 288742a55b46Smrg destdir="$func_dirname_result" 288842a55b46Smrg destname="$func_basename_result" 2889c582b7e3Smrg 289042a55b46Smrg # Not a directory, so check to see that there is only one file specified. 289142a55b46Smrg set dummy $files; shift 289242a55b46Smrg test "$#" -gt 1 && \ 289342a55b46Smrg func_fatal_help "\`$dest' is not a directory" 289442a55b46Smrg fi 289542a55b46Smrg case $destdir in 289642a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 289742a55b46Smrg *) 289842a55b46Smrg for file in $files; do 289942a55b46Smrg case $file in 290042a55b46Smrg *.lo) ;; 290142a55b46Smrg *) 290242a55b46Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 290342a55b46Smrg ;; 290442a55b46Smrg esac 290542a55b46Smrg done 290642a55b46Smrg ;; 290742a55b46Smrg esac 2908c582b7e3Smrg 290942a55b46Smrg # This variable tells wrapper scripts just to set variables rather 291042a55b46Smrg # than running their programs. 291142a55b46Smrg libtool_install_magic="$magic" 2912c582b7e3Smrg 291342a55b46Smrg staticlibs= 291442a55b46Smrg future_libdirs= 291542a55b46Smrg current_libdirs= 291642a55b46Smrg for file in $files; do 2917c582b7e3Smrg 291842a55b46Smrg # Do each installation. 291942a55b46Smrg case $file in 292042a55b46Smrg *.$libext) 292142a55b46Smrg # Do the static libraries later. 292242a55b46Smrg func_append staticlibs " $file" 292342a55b46Smrg ;; 2924c582b7e3Smrg 292542a55b46Smrg *.la) 292642a55b46Smrg func_resolve_sysroot "$file" 292742a55b46Smrg file=$func_resolve_sysroot_result 2928c582b7e3Smrg 292942a55b46Smrg # Check to see that this really is a libtool archive. 293042a55b46Smrg func_lalib_unsafe_p "$file" \ 293142a55b46Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 2932c582b7e3Smrg 293342a55b46Smrg library_names= 293442a55b46Smrg old_library= 293542a55b46Smrg relink_command= 293642a55b46Smrg func_source "$file" 2937c582b7e3Smrg 293842a55b46Smrg # Add the libdir to current_libdirs if it is the destination. 293942a55b46Smrg if test "X$destdir" = "X$libdir"; then 294042a55b46Smrg case "$current_libdirs " in 294142a55b46Smrg *" $libdir "*) ;; 294242a55b46Smrg *) func_append current_libdirs " $libdir" ;; 294342a55b46Smrg esac 294442a55b46Smrg else 294542a55b46Smrg # Note the libdir as a future libdir. 294642a55b46Smrg case "$future_libdirs " in 294742a55b46Smrg *" $libdir "*) ;; 294842a55b46Smrg *) func_append future_libdirs " $libdir" ;; 294942a55b46Smrg esac 295042a55b46Smrg fi 2951c582b7e3Smrg 295242a55b46Smrg func_dirname "$file" "/" "" 295342a55b46Smrg dir="$func_dirname_result" 295442a55b46Smrg func_append dir "$objdir" 2955c582b7e3Smrg 295642a55b46Smrg if test -n "$relink_command"; then 295742a55b46Smrg # Determine the prefix the user has applied to our future dir. 295842a55b46Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 2959c582b7e3Smrg 296042a55b46Smrg # Don't allow the user to place us outside of our expected 296142a55b46Smrg # location b/c this prevents finding dependent libraries that 296242a55b46Smrg # are installed to the same prefix. 296342a55b46Smrg # At present, this check doesn't affect windows .dll's that 296442a55b46Smrg # are installed into $libdir/../bin (currently, that works fine) 296542a55b46Smrg # but it's something to keep an eye on. 296642a55b46Smrg test "$inst_prefix_dir" = "$destdir" && \ 296742a55b46Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 296842a55b46Smrg 296942a55b46Smrg if test -n "$inst_prefix_dir"; then 297042a55b46Smrg # Stick the inst_prefix_dir data into the link command. 297142a55b46Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 2972c582b7e3Smrg else 297342a55b46Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 2974c582b7e3Smrg fi 2975c582b7e3Smrg 297642a55b46Smrg func_warning "relinking \`$file'" 297742a55b46Smrg func_show_eval "$relink_command" \ 297842a55b46Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 297942a55b46Smrg fi 298042a55b46Smrg 298142a55b46Smrg # See the names of the shared library. 298242a55b46Smrg set dummy $library_names; shift 298342a55b46Smrg if test -n "$1"; then 298442a55b46Smrg realname="$1" 298542a55b46Smrg shift 298642a55b46Smrg 298742a55b46Smrg srcname="$realname" 298842a55b46Smrg test -n "$relink_command" && srcname="$realname"T 298942a55b46Smrg 299042a55b46Smrg # Install the shared library and build the symlinks. 299142a55b46Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 299242a55b46Smrg 'exit $?' 299342a55b46Smrg tstripme="$stripme" 299442a55b46Smrg case $host_os in 299542a55b46Smrg cygwin* | mingw* | pw32* | cegcc*) 299642a55b46Smrg case $realname in 299742a55b46Smrg *.dll.a) 299842a55b46Smrg tstripme="" 299942a55b46Smrg ;; 300042a55b46Smrg esac 300142a55b46Smrg ;; 300242a55b46Smrg esac 300342a55b46Smrg if test -n "$tstripme" && test -n "$striplib"; then 300442a55b46Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 3005c582b7e3Smrg fi 3006c582b7e3Smrg 300742a55b46Smrg if test "$#" -gt 0; then 300842a55b46Smrg # Delete the old symlinks, and create new ones. 300942a55b46Smrg # Try `ln -sf' first, because the `ln' binary might depend on 301042a55b46Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 301142a55b46Smrg # so we also need to try rm && ln -s. 301242a55b46Smrg for linkname 301342a55b46Smrg do 301442a55b46Smrg test "$linkname" != "$realname" \ 301542a55b46Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 3016c582b7e3Smrg done 3017c582b7e3Smrg fi 3018c582b7e3Smrg 301942a55b46Smrg # Do each command in the postinstall commands. 302042a55b46Smrg lib="$destdir/$realname" 302142a55b46Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 302242a55b46Smrg fi 3023c582b7e3Smrg 302442a55b46Smrg # Install the pseudo-library for information purposes. 302542a55b46Smrg func_basename "$file" 302642a55b46Smrg name="$func_basename_result" 302742a55b46Smrg instname="$dir/$name"i 302842a55b46Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 3029c582b7e3Smrg 303042a55b46Smrg # Maybe install the static library, too. 303142a55b46Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 303242a55b46Smrg ;; 303342a55b46Smrg 303442a55b46Smrg *.lo) 303542a55b46Smrg # Install (i.e. copy) a libtool object. 303642a55b46Smrg 303742a55b46Smrg # Figure out destination file name, if it wasn't already specified. 303842a55b46Smrg if test -n "$destname"; then 303942a55b46Smrg destfile="$destdir/$destname" 3040c582b7e3Smrg else 304142a55b46Smrg func_basename "$file" 304242a55b46Smrg destfile="$func_basename_result" 304342a55b46Smrg destfile="$destdir/$destfile" 3044c582b7e3Smrg fi 304542a55b46Smrg 304642a55b46Smrg # Deduce the name of the destination old-style object file. 304742a55b46Smrg case $destfile in 304842a55b46Smrg *.lo) 304942a55b46Smrg func_lo2o "$destfile" 305042a55b46Smrg staticdest=$func_lo2o_result 305142a55b46Smrg ;; 305242a55b46Smrg *.$objext) 305342a55b46Smrg staticdest="$destfile" 305442a55b46Smrg destfile= 305542a55b46Smrg ;; 305642a55b46Smrg *) 305742a55b46Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 3058c582b7e3Smrg ;; 3059c582b7e3Smrg esac 3060c582b7e3Smrg 306142a55b46Smrg # Install the libtool object if requested. 306242a55b46Smrg test -n "$destfile" && \ 306342a55b46Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 3064c582b7e3Smrg 306542a55b46Smrg # Install the old object if enabled. 306642a55b46Smrg if test "$build_old_libs" = yes; then 306742a55b46Smrg # Deduce the name of the old-style object file. 306842a55b46Smrg func_lo2o "$file" 306942a55b46Smrg staticobj=$func_lo2o_result 307042a55b46Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 307142a55b46Smrg fi 307242a55b46Smrg exit $EXIT_SUCCESS 307342a55b46Smrg ;; 3074c582b7e3Smrg 307542a55b46Smrg *) 307642a55b46Smrg # Figure out destination file name, if it wasn't already specified. 307742a55b46Smrg if test -n "$destname"; then 307842a55b46Smrg destfile="$destdir/$destname" 307942a55b46Smrg else 308042a55b46Smrg func_basename "$file" 308142a55b46Smrg destfile="$func_basename_result" 308242a55b46Smrg destfile="$destdir/$destfile" 308342a55b46Smrg fi 3084c582b7e3Smrg 308542a55b46Smrg # If the file is missing, and there is a .exe on the end, strip it 308642a55b46Smrg # because it is most likely a libtool script we actually want to 308742a55b46Smrg # install 308842a55b46Smrg stripped_ext="" 308942a55b46Smrg case $file in 309042a55b46Smrg *.exe) 309142a55b46Smrg if test ! -f "$file"; then 309242a55b46Smrg func_stripname '' '.exe' "$file" 309342a55b46Smrg file=$func_stripname_result 309442a55b46Smrg stripped_ext=".exe" 309542a55b46Smrg fi 309642a55b46Smrg ;; 309742a55b46Smrg esac 3098c582b7e3Smrg 309942a55b46Smrg # Do a test to see if this is really a libtool program. 310042a55b46Smrg case $host in 310142a55b46Smrg *cygwin* | *mingw*) 310242a55b46Smrg if func_ltwrapper_executable_p "$file"; then 310342a55b46Smrg func_ltwrapper_scriptname "$file" 310442a55b46Smrg wrapper=$func_ltwrapper_scriptname_result 310542a55b46Smrg else 310642a55b46Smrg func_stripname '' '.exe' "$file" 310742a55b46Smrg wrapper=$func_stripname_result 310842a55b46Smrg fi 310942a55b46Smrg ;; 311042a55b46Smrg *) 311142a55b46Smrg wrapper=$file 311242a55b46Smrg ;; 311342a55b46Smrg esac 311442a55b46Smrg if func_ltwrapper_script_p "$wrapper"; then 311542a55b46Smrg notinst_deplibs= 311642a55b46Smrg relink_command= 3117c582b7e3Smrg 311842a55b46Smrg func_source "$wrapper" 3119c582b7e3Smrg 312042a55b46Smrg # Check the variables that should have been set. 312142a55b46Smrg test -z "$generated_by_libtool_version" && \ 312242a55b46Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 3123c582b7e3Smrg 312442a55b46Smrg finalize=yes 312542a55b46Smrg for lib in $notinst_deplibs; do 312642a55b46Smrg # Check to see that each library is installed. 312742a55b46Smrg libdir= 312842a55b46Smrg if test -f "$lib"; then 312942a55b46Smrg func_source "$lib" 313042a55b46Smrg fi 313142a55b46Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 313242a55b46Smrg if test -n "$libdir" && test ! -f "$libfile"; then 313342a55b46Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 313442a55b46Smrg finalize=no 313542a55b46Smrg fi 313642a55b46Smrg done 3137c582b7e3Smrg 313842a55b46Smrg relink_command= 313942a55b46Smrg func_source "$wrapper" 314042a55b46Smrg 314142a55b46Smrg outputname= 314242a55b46Smrg if test "$fast_install" = no && test -n "$relink_command"; then 314342a55b46Smrg $opt_dry_run || { 314442a55b46Smrg if test "$finalize" = yes; then 314542a55b46Smrg tmpdir=`func_mktempdir` 314642a55b46Smrg func_basename "$file$stripped_ext" 314742a55b46Smrg file="$func_basename_result" 314842a55b46Smrg outputname="$tmpdir/$file" 314942a55b46Smrg # Replace the output file specification. 315042a55b46Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 315142a55b46Smrg 315242a55b46Smrg $opt_silent || { 315342a55b46Smrg func_quote_for_expand "$relink_command" 315442a55b46Smrg eval "func_echo $func_quote_for_expand_result" 315542a55b46Smrg } 315642a55b46Smrg if eval "$relink_command"; then : 315742a55b46Smrg else 315842a55b46Smrg func_error "error: relink \`$file' with the above command before installing it" 315942a55b46Smrg $opt_dry_run || ${RM}r "$tmpdir" 316042a55b46Smrg continue 316142a55b46Smrg fi 316242a55b46Smrg file="$outputname" 316342a55b46Smrg else 316442a55b46Smrg func_warning "cannot relink \`$file'" 316542a55b46Smrg fi 316642a55b46Smrg } 316742a55b46Smrg else 316842a55b46Smrg # Install the binary that we compiled earlier. 316942a55b46Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 317042a55b46Smrg fi 3171c582b7e3Smrg fi 317242a55b46Smrg 317342a55b46Smrg # remove .exe since cygwin /usr/bin/install will append another 317442a55b46Smrg # one anyway 317542a55b46Smrg case $install_prog,$host in 317642a55b46Smrg */usr/bin/install*,*cygwin*) 317742a55b46Smrg case $file:$destfile in 317842a55b46Smrg *.exe:*.exe) 317942a55b46Smrg # this is ok 318042a55b46Smrg ;; 318142a55b46Smrg *.exe:*) 318242a55b46Smrg destfile=$destfile.exe 318342a55b46Smrg ;; 318442a55b46Smrg *:*.exe) 318542a55b46Smrg func_stripname '' '.exe' "$destfile" 318642a55b46Smrg destfile=$func_stripname_result 318742a55b46Smrg ;; 318842a55b46Smrg esac 318942a55b46Smrg ;; 319042a55b46Smrg esac 319142a55b46Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 319242a55b46Smrg $opt_dry_run || if test -n "$outputname"; then 319342a55b46Smrg ${RM}r "$tmpdir" 3194c582b7e3Smrg fi 3195c582b7e3Smrg ;; 3196c582b7e3Smrg esac 319742a55b46Smrg done 3198c582b7e3Smrg 319942a55b46Smrg for file in $staticlibs; do 320042a55b46Smrg func_basename "$file" 320142a55b46Smrg name="$func_basename_result" 3202c582b7e3Smrg 320342a55b46Smrg # Set up the ranlib parameters. 320442a55b46Smrg oldlib="$destdir/$name" 320542a55b46Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 320642a55b46Smrg tool_oldlib=$func_to_tool_file_result 3207c582b7e3Smrg 320842a55b46Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 320942a55b46Smrg 321042a55b46Smrg if test -n "$stripme" && test -n "$old_striplib"; then 321142a55b46Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 3212c582b7e3Smrg fi 3213c582b7e3Smrg 321442a55b46Smrg # Do each command in the postinstall commands. 321542a55b46Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 321642a55b46Smrg done 3217c582b7e3Smrg 321842a55b46Smrg test -n "$future_libdirs" && \ 321942a55b46Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 3220c582b7e3Smrg 322142a55b46Smrg if test -n "$current_libdirs"; then 322242a55b46Smrg # Maybe just do a dry run. 322342a55b46Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 322442a55b46Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 322542a55b46Smrg else 322642a55b46Smrg exit $EXIT_SUCCESS 322742a55b46Smrg fi 322842a55b46Smrg} 3229c582b7e3Smrg 323042a55b46Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 3231c582b7e3Smrg 3232c582b7e3Smrg 323342a55b46Smrg# func_generate_dlsyms outputname originator pic_p 323442a55b46Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 323542a55b46Smrg# a dlpreopen symbol table. 323642a55b46Smrgfunc_generate_dlsyms () 323742a55b46Smrg{ 323842a55b46Smrg $opt_debug 323942a55b46Smrg my_outputname="$1" 324042a55b46Smrg my_originator="$2" 324142a55b46Smrg my_pic_p="${3-no}" 324242a55b46Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 324342a55b46Smrg my_dlsyms= 324442a55b46Smrg 324542a55b46Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 324642a55b46Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 324742a55b46Smrg my_dlsyms="${my_outputname}S.c" 324842a55b46Smrg else 324942a55b46Smrg func_error "not configured to extract global symbols from dlpreopened files" 325042a55b46Smrg fi 325142a55b46Smrg fi 3252c582b7e3Smrg 325342a55b46Smrg if test -n "$my_dlsyms"; then 325442a55b46Smrg case $my_dlsyms in 325542a55b46Smrg "") ;; 325642a55b46Smrg *.c) 325742a55b46Smrg # Discover the nlist of each of the dlfiles. 325842a55b46Smrg nlist="$output_objdir/${my_outputname}.nm" 3259c582b7e3Smrg 326042a55b46Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 3261c582b7e3Smrg 326242a55b46Smrg # Parse the name list into a source file. 326342a55b46Smrg func_verbose "creating $output_objdir/$my_dlsyms" 3264c582b7e3Smrg 326542a55b46Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 326642a55b46Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 326742a55b46Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 3268c582b7e3Smrg 326942a55b46Smrg#ifdef __cplusplus 327042a55b46Smrgextern \"C\" { 327142a55b46Smrg#endif 3272c582b7e3Smrg 327342a55b46Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 327442a55b46Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 327542a55b46Smrg#endif 3276c582b7e3Smrg 327742a55b46Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 327842a55b46Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 327942a55b46Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 328042a55b46Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 328142a55b46Smrg# define LT_DLSYM_CONST 328242a55b46Smrg#elif defined(__osf__) 328342a55b46Smrg/* This system does not cope well with relocations in const data. */ 328442a55b46Smrg# define LT_DLSYM_CONST 328542a55b46Smrg#else 328642a55b46Smrg# define LT_DLSYM_CONST const 328742a55b46Smrg#endif 3288c582b7e3Smrg 328942a55b46Smrg/* External symbol declarations for the compiler. */\ 329042a55b46Smrg" 3291c582b7e3Smrg 329242a55b46Smrg if test "$dlself" = yes; then 329342a55b46Smrg func_verbose "generating symbol list for \`$output'" 3294c582b7e3Smrg 329542a55b46Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 3296c582b7e3Smrg 329742a55b46Smrg # Add our own program objects to the symbol list. 329842a55b46Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 329942a55b46Smrg for progfile in $progfiles; do 330042a55b46Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 330142a55b46Smrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 330242a55b46Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 3303c582b7e3Smrg done 3304c582b7e3Smrg 330542a55b46Smrg if test -n "$exclude_expsyms"; then 330642a55b46Smrg $opt_dry_run || { 330742a55b46Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 330842a55b46Smrg eval '$MV "$nlist"T "$nlist"' 330942a55b46Smrg } 331042a55b46Smrg fi 3311c582b7e3Smrg 331242a55b46Smrg if test -n "$export_symbols_regex"; then 331342a55b46Smrg $opt_dry_run || { 331442a55b46Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 331542a55b46Smrg eval '$MV "$nlist"T "$nlist"' 331642a55b46Smrg } 331742a55b46Smrg fi 3318c582b7e3Smrg 331942a55b46Smrg # Prepare the list of exported symbols 332042a55b46Smrg if test -z "$export_symbols"; then 332142a55b46Smrg export_symbols="$output_objdir/$outputname.exp" 332242a55b46Smrg $opt_dry_run || { 332342a55b46Smrg $RM $export_symbols 332442a55b46Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 332542a55b46Smrg case $host in 332642a55b46Smrg *cygwin* | *mingw* | *cegcc* ) 332742a55b46Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 332842a55b46Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 332942a55b46Smrg ;; 333042a55b46Smrg esac 333142a55b46Smrg } 333242a55b46Smrg else 333342a55b46Smrg $opt_dry_run || { 333442a55b46Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 333542a55b46Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 333642a55b46Smrg eval '$MV "$nlist"T "$nlist"' 333742a55b46Smrg case $host in 333842a55b46Smrg *cygwin* | *mingw* | *cegcc* ) 333942a55b46Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 334042a55b46Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 334142a55b46Smrg ;; 334242a55b46Smrg esac 334342a55b46Smrg } 334442a55b46Smrg fi 334542a55b46Smrg fi 3346c582b7e3Smrg 334742a55b46Smrg for dlprefile in $dlprefiles; do 334842a55b46Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 334942a55b46Smrg func_basename "$dlprefile" 335042a55b46Smrg name="$func_basename_result" 335142a55b46Smrg case $host in 335242a55b46Smrg *cygwin* | *mingw* | *cegcc* ) 335342a55b46Smrg # if an import library, we need to obtain dlname 335442a55b46Smrg if func_win32_import_lib_p "$dlprefile"; then 335542a55b46Smrg func_tr_sh "$dlprefile" 335642a55b46Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 335742a55b46Smrg dlprefile_dlbasename="" 335842a55b46Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 335942a55b46Smrg # Use subshell, to avoid clobbering current variable values 336042a55b46Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 336142a55b46Smrg if test -n "$dlprefile_dlname" ; then 336242a55b46Smrg func_basename "$dlprefile_dlname" 336342a55b46Smrg dlprefile_dlbasename="$func_basename_result" 336442a55b46Smrg else 336542a55b46Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 336642a55b46Smrg $sharedlib_from_linklib_cmd "$dlprefile" 336742a55b46Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 336842a55b46Smrg fi 336942a55b46Smrg fi 337042a55b46Smrg $opt_dry_run || { 337142a55b46Smrg if test -n "$dlprefile_dlbasename" ; then 337242a55b46Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 337342a55b46Smrg else 337442a55b46Smrg func_warning "Could not compute DLL name from $name" 337542a55b46Smrg eval '$ECHO ": $name " >> "$nlist"' 337642a55b46Smrg fi 337742a55b46Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 337842a55b46Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 337942a55b46Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 338042a55b46Smrg } 338142a55b46Smrg else # not an import lib 338242a55b46Smrg $opt_dry_run || { 338342a55b46Smrg eval '$ECHO ": $name " >> "$nlist"' 338442a55b46Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 338542a55b46Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 338642a55b46Smrg } 338742a55b46Smrg fi 338842a55b46Smrg ;; 338942a55b46Smrg *) 339042a55b46Smrg $opt_dry_run || { 339142a55b46Smrg eval '$ECHO ": $name " >> "$nlist"' 339242a55b46Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 339342a55b46Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 339442a55b46Smrg } 339542a55b46Smrg ;; 339642a55b46Smrg esac 339742a55b46Smrg done 3398c582b7e3Smrg 339942a55b46Smrg $opt_dry_run || { 340042a55b46Smrg # Make sure we have at least an empty file. 340142a55b46Smrg test -f "$nlist" || : > "$nlist" 3402c582b7e3Smrg 340342a55b46Smrg if test -n "$exclude_expsyms"; then 340442a55b46Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 340542a55b46Smrg $MV "$nlist"T "$nlist" 340642a55b46Smrg fi 3407c582b7e3Smrg 340842a55b46Smrg # Try sorting and uniquifying the output. 340942a55b46Smrg if $GREP -v "^: " < "$nlist" | 341042a55b46Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 341142a55b46Smrg sort -k 3 341242a55b46Smrg else 341342a55b46Smrg sort +2 341442a55b46Smrg fi | 341542a55b46Smrg uniq > "$nlist"S; then 341642a55b46Smrg : 341742a55b46Smrg else 341842a55b46Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 341942a55b46Smrg fi 3420c582b7e3Smrg 342142a55b46Smrg if test -f "$nlist"S; then 342242a55b46Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 342342a55b46Smrg else 342442a55b46Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 342542a55b46Smrg fi 3426c582b7e3Smrg 342742a55b46Smrg echo >> "$output_objdir/$my_dlsyms" "\ 342842a55b46Smrg 342942a55b46Smrg/* The mapping between symbol names and symbols. */ 343042a55b46Smrgtypedef struct { 343142a55b46Smrg const char *name; 343242a55b46Smrg void *address; 343342a55b46Smrg} lt_dlsymlist; 343442a55b46Smrgextern LT_DLSYM_CONST lt_dlsymlist 343542a55b46Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 343642a55b46SmrgLT_DLSYM_CONST lt_dlsymlist 343742a55b46Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 343842a55b46Smrg{\ 343942a55b46Smrg { \"$my_originator\", (void *) 0 }," 344042a55b46Smrg 344142a55b46Smrg case $need_lib_prefix in 344242a55b46Smrg no) 344342a55b46Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 3444c582b7e3Smrg ;; 3445c582b7e3Smrg *) 344642a55b46Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 3447c582b7e3Smrg ;; 3448c582b7e3Smrg esac 344942a55b46Smrg echo >> "$output_objdir/$my_dlsyms" "\ 345042a55b46Smrg {0, (void *) 0} 345142a55b46Smrg}; 3452c582b7e3Smrg 345342a55b46Smrg/* This works around a problem in FreeBSD linker */ 345442a55b46Smrg#ifdef FREEBSD_WORKAROUND 345542a55b46Smrgstatic const void *lt_preloaded_setup() { 345642a55b46Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 345742a55b46Smrg} 345842a55b46Smrg#endif 3459c582b7e3Smrg 346042a55b46Smrg#ifdef __cplusplus 346142a55b46Smrg} 346242a55b46Smrg#endif\ 346342a55b46Smrg" 346442a55b46Smrg } # !$opt_dry_run 3465c582b7e3Smrg 346642a55b46Smrg pic_flag_for_symtable= 346742a55b46Smrg case "$compile_command " in 346842a55b46Smrg *" -static "*) ;; 346942a55b46Smrg *) 347042a55b46Smrg case $host in 347142a55b46Smrg # compiling the symbol table file with pic_flag works around 347242a55b46Smrg # a FreeBSD bug that causes programs to crash when -lm is 347342a55b46Smrg # linked before any other PIC object. But we must not use 347442a55b46Smrg # pic_flag when linking with -static. The problem exists in 347542a55b46Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 347642a55b46Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 347742a55b46Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 347842a55b46Smrg *-*-hpux*) 347942a55b46Smrg pic_flag_for_symtable=" $pic_flag" ;; 348042a55b46Smrg *) 348142a55b46Smrg if test "X$my_pic_p" != Xno; then 348242a55b46Smrg pic_flag_for_symtable=" $pic_flag" 348342a55b46Smrg fi 348442a55b46Smrg ;; 348542a55b46Smrg esac 348642a55b46Smrg ;; 348742a55b46Smrg esac 348842a55b46Smrg symtab_cflags= 348942a55b46Smrg for arg in $LTCFLAGS; do 349042a55b46Smrg case $arg in 349142a55b46Smrg -pie | -fpie | -fPIE) ;; 349242a55b46Smrg *) func_append symtab_cflags " $arg" ;; 3493c582b7e3Smrg esac 3494c582b7e3Smrg done 3495c582b7e3Smrg 349642a55b46Smrg # Now compile the dynamic symbol file. 349742a55b46Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 3498c582b7e3Smrg 349942a55b46Smrg # Clean up the generated files. 350042a55b46Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 3501c582b7e3Smrg 350242a55b46Smrg # Transform the symbol file into the correct name. 350342a55b46Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 350442a55b46Smrg case $host in 350542a55b46Smrg *cygwin* | *mingw* | *cegcc* ) 350642a55b46Smrg if test -f "$output_objdir/$my_outputname.def"; then 350742a55b46Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 350842a55b46Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 350942a55b46Smrg else 351042a55b46Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351142a55b46Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351242a55b46Smrg fi 351342a55b46Smrg ;; 351442a55b46Smrg *) 351542a55b46Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351642a55b46Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351742a55b46Smrg ;; 351842a55b46Smrg esac 351942a55b46Smrg ;; 352042a55b46Smrg *) 352142a55b46Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 352242a55b46Smrg ;; 352342a55b46Smrg esac 352442a55b46Smrg else 352542a55b46Smrg # We keep going just in case the user didn't refer to 352642a55b46Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 352742a55b46Smrg # really was required. 3528c582b7e3Smrg 352942a55b46Smrg # Nullify the symbol file. 353042a55b46Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 353142a55b46Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 353242a55b46Smrg fi 353342a55b46Smrg} 3534c582b7e3Smrg 353542a55b46Smrg# func_win32_libid arg 353642a55b46Smrg# return the library type of file 'arg' 353742a55b46Smrg# 353842a55b46Smrg# Need a lot of goo to handle *both* DLLs and import libs 353942a55b46Smrg# Has to be a shell function in order to 'eat' the argument 354042a55b46Smrg# that is supplied when $file_magic_command is called. 354142a55b46Smrg# Despite the name, also deal with 64 bit binaries. 354242a55b46Smrgfunc_win32_libid () 354342a55b46Smrg{ 354442a55b46Smrg $opt_debug 354542a55b46Smrg win32_libid_type="unknown" 354642a55b46Smrg win32_fileres=`file -L $1 2>/dev/null` 354742a55b46Smrg case $win32_fileres in 354842a55b46Smrg *ar\ archive\ import\ library*) # definitely import 354942a55b46Smrg win32_libid_type="x86 archive import" 355042a55b46Smrg ;; 355142a55b46Smrg *ar\ archive*) # could be an import, or static 355242a55b46Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 355342a55b46Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 355442a55b46Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 355542a55b46Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 355642a55b46Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 355742a55b46Smrg $SED -n -e ' 355842a55b46Smrg 1,100{ 355942a55b46Smrg / I /{ 356042a55b46Smrg s,.*,import, 356142a55b46Smrg p 356242a55b46Smrg q 356342a55b46Smrg } 356442a55b46Smrg }'` 356542a55b46Smrg case $win32_nmres in 356642a55b46Smrg import*) win32_libid_type="x86 archive import";; 356742a55b46Smrg *) win32_libid_type="x86 archive static";; 356842a55b46Smrg esac 356942a55b46Smrg fi 357042a55b46Smrg ;; 357142a55b46Smrg *DLL*) 357242a55b46Smrg win32_libid_type="x86 DLL" 357342a55b46Smrg ;; 357442a55b46Smrg *executable*) # but shell scripts are "executable" too... 357542a55b46Smrg case $win32_fileres in 357642a55b46Smrg *MS\ Windows\ PE\ Intel*) 357742a55b46Smrg win32_libid_type="x86 DLL" 357842a55b46Smrg ;; 357942a55b46Smrg esac 358042a55b46Smrg ;; 358142a55b46Smrg esac 358242a55b46Smrg $ECHO "$win32_libid_type" 358342a55b46Smrg} 358442a55b46Smrg 358542a55b46Smrg# func_cygming_dll_for_implib ARG 358642a55b46Smrg# 358742a55b46Smrg# Platform-specific function to extract the 358842a55b46Smrg# name of the DLL associated with the specified 358942a55b46Smrg# import library ARG. 359042a55b46Smrg# Invoked by eval'ing the libtool variable 359142a55b46Smrg# $sharedlib_from_linklib_cmd 359242a55b46Smrg# Result is available in the variable 359342a55b46Smrg# $sharedlib_from_linklib_result 359442a55b46Smrgfunc_cygming_dll_for_implib () 359542a55b46Smrg{ 359642a55b46Smrg $opt_debug 359742a55b46Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 359842a55b46Smrg} 359942a55b46Smrg 360042a55b46Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 360142a55b46Smrg# 360242a55b46Smrg# The is the core of a fallback implementation of a 360342a55b46Smrg# platform-specific function to extract the name of the 360442a55b46Smrg# DLL associated with the specified import library LIBNAME. 360542a55b46Smrg# 360642a55b46Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 360742a55b46Smrg# on the platform and compiler that created the implib. 360842a55b46Smrg# 360942a55b46Smrg# Echos the name of the DLL associated with the 361042a55b46Smrg# specified import library. 361142a55b46Smrgfunc_cygming_dll_for_implib_fallback_core () 361242a55b46Smrg{ 361342a55b46Smrg $opt_debug 361442a55b46Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 361542a55b46Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 361642a55b46Smrg $SED '/^Contents of section '"$match_literal"':/{ 361742a55b46Smrg # Place marker at beginning of archive member dllname section 361842a55b46Smrg s/.*/====MARK====/ 361942a55b46Smrg p 362042a55b46Smrg d 362142a55b46Smrg } 362242a55b46Smrg # These lines can sometimes be longer than 43 characters, but 362342a55b46Smrg # are always uninteresting 362442a55b46Smrg /:[ ]*file format pe[i]\{,1\}-/d 362542a55b46Smrg /^In archive [^:]*:/d 362642a55b46Smrg # Ensure marker is printed 362742a55b46Smrg /^====MARK====/p 362842a55b46Smrg # Remove all lines with less than 43 characters 362942a55b46Smrg /^.\{43\}/!d 363042a55b46Smrg # From remaining lines, remove first 43 characters 363142a55b46Smrg s/^.\{43\}//' | 363242a55b46Smrg $SED -n ' 363342a55b46Smrg # Join marker and all lines until next marker into a single line 363442a55b46Smrg /^====MARK====/ b para 363542a55b46Smrg H 363642a55b46Smrg $ b para 363742a55b46Smrg b 363842a55b46Smrg :para 363942a55b46Smrg x 364042a55b46Smrg s/\n//g 364142a55b46Smrg # Remove the marker 364242a55b46Smrg s/^====MARK====// 364342a55b46Smrg # Remove trailing dots and whitespace 364442a55b46Smrg s/[\. \t]*$// 364542a55b46Smrg # Print 364642a55b46Smrg /./p' | 364742a55b46Smrg # we now have a list, one entry per line, of the stringified 364842a55b46Smrg # contents of the appropriate section of all members of the 364942a55b46Smrg # archive which possess that section. Heuristic: eliminate 365042a55b46Smrg # all those which have a first or second character that is 365142a55b46Smrg # a '.' (that is, objdump's representation of an unprintable 365242a55b46Smrg # character.) This should work for all archives with less than 365342a55b46Smrg # 0x302f exports -- but will fail for DLLs whose name actually 365442a55b46Smrg # begins with a literal '.' or a single character followed by 365542a55b46Smrg # a '.'. 365642a55b46Smrg # 365742a55b46Smrg # Of those that remain, print the first one. 365842a55b46Smrg $SED -e '/^\./d;/^.\./d;q' 365942a55b46Smrg} 366042a55b46Smrg 366142a55b46Smrg# func_cygming_gnu_implib_p ARG 366242a55b46Smrg# This predicate returns with zero status (TRUE) if 366342a55b46Smrg# ARG is a GNU/binutils-style import library. Returns 366442a55b46Smrg# with nonzero status (FALSE) otherwise. 366542a55b46Smrgfunc_cygming_gnu_implib_p () 366642a55b46Smrg{ 366742a55b46Smrg $opt_debug 366842a55b46Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 366942a55b46Smrg 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)$'` 367042a55b46Smrg test -n "$func_cygming_gnu_implib_tmp" 367142a55b46Smrg} 367242a55b46Smrg 367342a55b46Smrg# func_cygming_ms_implib_p ARG 367442a55b46Smrg# This predicate returns with zero status (TRUE) if 367542a55b46Smrg# ARG is an MS-style import library. Returns 367642a55b46Smrg# with nonzero status (FALSE) otherwise. 367742a55b46Smrgfunc_cygming_ms_implib_p () 367842a55b46Smrg{ 367942a55b46Smrg $opt_debug 368042a55b46Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 368142a55b46Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 368242a55b46Smrg test -n "$func_cygming_ms_implib_tmp" 368342a55b46Smrg} 368442a55b46Smrg 368542a55b46Smrg# func_cygming_dll_for_implib_fallback ARG 368642a55b46Smrg# Platform-specific function to extract the 368742a55b46Smrg# name of the DLL associated with the specified 368842a55b46Smrg# import library ARG. 368942a55b46Smrg# 369042a55b46Smrg# This fallback implementation is for use when $DLLTOOL 369142a55b46Smrg# does not support the --identify-strict option. 369242a55b46Smrg# Invoked by eval'ing the libtool variable 369342a55b46Smrg# $sharedlib_from_linklib_cmd 369442a55b46Smrg# Result is available in the variable 369542a55b46Smrg# $sharedlib_from_linklib_result 369642a55b46Smrgfunc_cygming_dll_for_implib_fallback () 369742a55b46Smrg{ 369842a55b46Smrg $opt_debug 369942a55b46Smrg if func_cygming_gnu_implib_p "$1" ; then 370042a55b46Smrg # binutils import library 370142a55b46Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 370242a55b46Smrg elif func_cygming_ms_implib_p "$1" ; then 370342a55b46Smrg # ms-generated import library 370442a55b46Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 370542a55b46Smrg else 370642a55b46Smrg # unknown 370742a55b46Smrg sharedlib_from_linklib_result="" 370842a55b46Smrg fi 370942a55b46Smrg} 371042a55b46Smrg 371142a55b46Smrg 371242a55b46Smrg# func_extract_an_archive dir oldlib 371342a55b46Smrgfunc_extract_an_archive () 371442a55b46Smrg{ 371542a55b46Smrg $opt_debug 371642a55b46Smrg f_ex_an_ar_dir="$1"; shift 371742a55b46Smrg f_ex_an_ar_oldlib="$1" 371842a55b46Smrg if test "$lock_old_archive_extraction" = yes; then 371942a55b46Smrg lockfile=$f_ex_an_ar_oldlib.lock 372042a55b46Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 372142a55b46Smrg func_echo "Waiting for $lockfile to be removed" 372242a55b46Smrg sleep 2 3723c582b7e3Smrg done 372442a55b46Smrg fi 372542a55b46Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 372642a55b46Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 372742a55b46Smrg if test "$lock_old_archive_extraction" = yes; then 372842a55b46Smrg $opt_dry_run || rm -f "$lockfile" 372942a55b46Smrg fi 373042a55b46Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 373142a55b46Smrg : 373242a55b46Smrg else 373342a55b46Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 373442a55b46Smrg fi 373542a55b46Smrg} 3736c582b7e3Smrg 373742a55b46Smrg 373842a55b46Smrg# func_extract_archives gentop oldlib ... 373942a55b46Smrgfunc_extract_archives () 374042a55b46Smrg{ 374142a55b46Smrg $opt_debug 374242a55b46Smrg my_gentop="$1"; shift 374342a55b46Smrg my_oldlibs=${1+"$@"} 374442a55b46Smrg my_oldobjs="" 374542a55b46Smrg my_xlib="" 374642a55b46Smrg my_xabs="" 374742a55b46Smrg my_xdir="" 374842a55b46Smrg 374942a55b46Smrg for my_xlib in $my_oldlibs; do 375042a55b46Smrg # Extract the objects. 375142a55b46Smrg case $my_xlib in 375242a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 375342a55b46Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 375442a55b46Smrg esac 375542a55b46Smrg func_basename "$my_xlib" 375642a55b46Smrg my_xlib="$func_basename_result" 375742a55b46Smrg my_xlib_u=$my_xlib 375842a55b46Smrg while :; do 375942a55b46Smrg case " $extracted_archives " in 376042a55b46Smrg *" $my_xlib_u "*) 376142a55b46Smrg func_arith $extracted_serial + 1 376242a55b46Smrg extracted_serial=$func_arith_result 376342a55b46Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 376442a55b46Smrg *) break ;; 3765c582b7e3Smrg esac 3766c582b7e3Smrg done 376742a55b46Smrg extracted_archives="$extracted_archives $my_xlib_u" 376842a55b46Smrg my_xdir="$my_gentop/$my_xlib_u" 3769c582b7e3Smrg 377042a55b46Smrg func_mkdir_p "$my_xdir" 3771c582b7e3Smrg 377242a55b46Smrg case $host in 377342a55b46Smrg *-darwin*) 377442a55b46Smrg func_verbose "Extracting $my_xabs" 377542a55b46Smrg # Do not bother doing anything if just a dry run 377642a55b46Smrg $opt_dry_run || { 377742a55b46Smrg darwin_orig_dir=`pwd` 377842a55b46Smrg cd $my_xdir || exit $? 377942a55b46Smrg darwin_archive=$my_xabs 378042a55b46Smrg darwin_curdir=`pwd` 378142a55b46Smrg darwin_base_archive=`basename "$darwin_archive"` 378242a55b46Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 378342a55b46Smrg if test -n "$darwin_arches"; then 378442a55b46Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 378542a55b46Smrg darwin_arch= 378642a55b46Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 378742a55b46Smrg for darwin_arch in $darwin_arches ; do 378842a55b46Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 378942a55b46Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 379042a55b46Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 379142a55b46Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 379242a55b46Smrg cd "$darwin_curdir" 379342a55b46Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 379442a55b46Smrg done # $darwin_arches 379542a55b46Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 379642a55b46Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 379742a55b46Smrg darwin_file= 379842a55b46Smrg darwin_files= 379942a55b46Smrg for darwin_file in $darwin_filelist; do 380042a55b46Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 380142a55b46Smrg $LIPO -create -output "$darwin_file" $darwin_files 380242a55b46Smrg done # $darwin_filelist 380342a55b46Smrg $RM -rf unfat-$$ 380442a55b46Smrg cd "$darwin_orig_dir" 3805c582b7e3Smrg else 380642a55b46Smrg cd $darwin_orig_dir 380742a55b46Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 380842a55b46Smrg fi # $darwin_arches 380942a55b46Smrg } # !$opt_dry_run 381042a55b46Smrg ;; 381142a55b46Smrg *) 381242a55b46Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 381342a55b46Smrg ;; 381442a55b46Smrg esac 381542a55b46Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 381642a55b46Smrg done 3817c582b7e3Smrg 381842a55b46Smrg func_extract_archives_result="$my_oldobjs" 381942a55b46Smrg} 3820c582b7e3Smrg 3821c582b7e3Smrg 382242a55b46Smrg# func_emit_wrapper [arg=no] 382342a55b46Smrg# 382442a55b46Smrg# Emit a libtool wrapper script on stdout. 382542a55b46Smrg# Don't directly open a file because we may want to 382642a55b46Smrg# incorporate the script contents within a cygwin/mingw 382742a55b46Smrg# wrapper executable. Must ONLY be called from within 382842a55b46Smrg# func_mode_link because it depends on a number of variables 382942a55b46Smrg# set therein. 383042a55b46Smrg# 383142a55b46Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 383242a55b46Smrg# variable will take. If 'yes', then the emitted script 383342a55b46Smrg# will assume that the directory in which it is stored is 383442a55b46Smrg# the $objdir directory. This is a cygwin/mingw-specific 383542a55b46Smrg# behavior. 383642a55b46Smrgfunc_emit_wrapper () 383742a55b46Smrg{ 383842a55b46Smrg func_emit_wrapper_arg1=${1-no} 3839c582b7e3Smrg 384042a55b46Smrg $ECHO "\ 384142a55b46Smrg#! $SHELL 3842c582b7e3Smrg 384342a55b46Smrg# $output - temporary wrapper script for $objdir/$outputname 384442a55b46Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 384542a55b46Smrg# 384642a55b46Smrg# The $output program cannot be directly executed until all the libtool 384742a55b46Smrg# libraries that it depends on are installed. 384842a55b46Smrg# 384942a55b46Smrg# This wrapper script should never be moved out of the build directory. 385042a55b46Smrg# If it is, it will not operate correctly. 3851c582b7e3Smrg 385242a55b46Smrg# Sed substitution that helps us do robust quoting. It backslashifies 385342a55b46Smrg# metacharacters that are still active within double-quoted strings. 385442a55b46Smrgsed_quote_subst='$sed_quote_subst' 3855c582b7e3Smrg 385642a55b46Smrg# Be Bourne compatible 385742a55b46Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 385842a55b46Smrg emulate sh 385942a55b46Smrg NULLCMD=: 386042a55b46Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 386142a55b46Smrg # is contrary to our usage. Disable this feature. 386242a55b46Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 386342a55b46Smrg setopt NO_GLOB_SUBST 386442a55b46Smrgelse 386542a55b46Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 386642a55b46Smrgfi 386742a55b46SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 386842a55b46SmrgDUALCASE=1; export DUALCASE # for MKS sh 3869c582b7e3Smrg 387042a55b46Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 387142a55b46Smrg# if CDPATH is set. 387242a55b46Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 3873c582b7e3Smrg 387442a55b46Smrgrelink_command=\"$relink_command\" 3875c582b7e3Smrg 387642a55b46Smrg# This environment variable determines our operation mode. 387742a55b46Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 387842a55b46Smrg # install mode needs the following variables: 387942a55b46Smrg generated_by_libtool_version='$macro_version' 388042a55b46Smrg notinst_deplibs='$notinst_deplibs' 388142a55b46Smrgelse 388242a55b46Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 388342a55b46Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 388442a55b46Smrg file=\"\$0\"" 3885c582b7e3Smrg 388642a55b46Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 388742a55b46Smrg $ECHO "\ 3888c582b7e3Smrg 388942a55b46Smrg# A function that is used when there is no print builtin or printf. 389042a55b46Smrgfunc_fallback_echo () 389142a55b46Smrg{ 389242a55b46Smrg eval 'cat <<_LTECHO_EOF 389342a55b46Smrg\$1 389442a55b46Smrg_LTECHO_EOF' 389542a55b46Smrg} 389642a55b46Smrg ECHO=\"$qECHO\" 389742a55b46Smrg fi 3898c582b7e3Smrg 389942a55b46Smrg# Very basic option parsing. These options are (a) specific to 390042a55b46Smrg# the libtool wrapper, (b) are identical between the wrapper 390142a55b46Smrg# /script/ and the wrapper /executable/ which is used only on 390242a55b46Smrg# windows platforms, and (c) all begin with the string "--lt-" 390342a55b46Smrg# (application programs are unlikely to have options which match 390442a55b46Smrg# this pattern). 390542a55b46Smrg# 390642a55b46Smrg# There are only two supported options: --lt-debug and 390742a55b46Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 390842a55b46Smrg# 390942a55b46Smrg# The first argument to this parsing function should be the 391042a55b46Smrg# script's $0 value, followed by "$@". 391142a55b46Smrglt_option_debug= 391242a55b46Smrgfunc_parse_lt_options () 391342a55b46Smrg{ 391442a55b46Smrg lt_script_arg0=\$0 391542a55b46Smrg shift 391642a55b46Smrg for lt_opt 391742a55b46Smrg do 391842a55b46Smrg case \"\$lt_opt\" in 391942a55b46Smrg --lt-debug) lt_option_debug=1 ;; 392042a55b46Smrg --lt-dump-script) 392142a55b46Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 392242a55b46Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 392342a55b46Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 392442a55b46Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 392542a55b46Smrg exit 0 392642a55b46Smrg ;; 392742a55b46Smrg --lt-*) 392842a55b46Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 392942a55b46Smrg exit 1 393042a55b46Smrg ;; 393142a55b46Smrg esac 393242a55b46Smrg done 3933c582b7e3Smrg 393442a55b46Smrg # Print the debug banner immediately: 393542a55b46Smrg if test -n \"\$lt_option_debug\"; then 393642a55b46Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 393742a55b46Smrg fi 393842a55b46Smrg} 3939c582b7e3Smrg 394042a55b46Smrg# Used when --lt-debug. Prints its arguments to stdout 394142a55b46Smrg# (redirection is the responsibility of the caller) 394242a55b46Smrgfunc_lt_dump_args () 394342a55b46Smrg{ 394442a55b46Smrg lt_dump_args_N=1; 394542a55b46Smrg for lt_arg 394642a55b46Smrg do 394742a55b46Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 394842a55b46Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 394942a55b46Smrg done 395042a55b46Smrg} 3951c582b7e3Smrg 395242a55b46Smrg# Core function for launching the target application 395342a55b46Smrgfunc_exec_program_core () 395442a55b46Smrg{ 395542a55b46Smrg" 395642a55b46Smrg case $host in 395742a55b46Smrg # Backslashes separate directories on plain windows 395842a55b46Smrg *-*-mingw | *-*-os2* | *-cegcc*) 395942a55b46Smrg $ECHO "\ 396042a55b46Smrg if test -n \"\$lt_option_debug\"; then 396142a55b46Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 396242a55b46Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 396342a55b46Smrg fi 396442a55b46Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 396542a55b46Smrg" 396642a55b46Smrg ;; 3967c582b7e3Smrg 396842a55b46Smrg *) 396942a55b46Smrg $ECHO "\ 397042a55b46Smrg if test -n \"\$lt_option_debug\"; then 397142a55b46Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 397242a55b46Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 397342a55b46Smrg fi 397442a55b46Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 397542a55b46Smrg" 397642a55b46Smrg ;; 397742a55b46Smrg esac 397842a55b46Smrg $ECHO "\ 397942a55b46Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 398042a55b46Smrg exit 1 398142a55b46Smrg} 3982c582b7e3Smrg 398342a55b46Smrg# A function to encapsulate launching the target application 398442a55b46Smrg# Strips options in the --lt-* namespace from \$@ and 398542a55b46Smrg# launches target application with the remaining arguments. 398642a55b46Smrgfunc_exec_program () 398742a55b46Smrg{ 398842a55b46Smrg case \" \$* \" in 398942a55b46Smrg *\\ --lt-*) 399042a55b46Smrg for lt_wr_arg 399142a55b46Smrg do 399242a55b46Smrg case \$lt_wr_arg in 399342a55b46Smrg --lt-*) ;; 399442a55b46Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 399542a55b46Smrg esac 399642a55b46Smrg shift 399742a55b46Smrg done ;; 399842a55b46Smrg esac 399942a55b46Smrg func_exec_program_core \${1+\"\$@\"} 400042a55b46Smrg} 4001c582b7e3Smrg 400242a55b46Smrg # Parse options 400342a55b46Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 4004c582b7e3Smrg 400542a55b46Smrg # Find the directory that this script lives in. 400642a55b46Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 400742a55b46Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 4008c582b7e3Smrg 400942a55b46Smrg # Follow symbolic links until we get to the real thisdir. 401042a55b46Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 401142a55b46Smrg while test -n \"\$file\"; do 401242a55b46Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 4013c582b7e3Smrg 401442a55b46Smrg # If there was a directory component, then change thisdir. 401542a55b46Smrg if test \"x\$destdir\" != \"x\$file\"; then 401642a55b46Smrg case \"\$destdir\" in 401742a55b46Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 401842a55b46Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 401942a55b46Smrg esac 402042a55b46Smrg fi 4021c582b7e3Smrg 402242a55b46Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 402342a55b46Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 402442a55b46Smrg done 4025c582b7e3Smrg 402642a55b46Smrg # Usually 'no', except on cygwin/mingw when embedded into 402742a55b46Smrg # the cwrapper. 402842a55b46Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 402942a55b46Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 403042a55b46Smrg # special case for '.' 403142a55b46Smrg if test \"\$thisdir\" = \".\"; then 403242a55b46Smrg thisdir=\`pwd\` 403342a55b46Smrg fi 403442a55b46Smrg # remove .libs from thisdir 403542a55b46Smrg case \"\$thisdir\" in 403642a55b46Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 403742a55b46Smrg $objdir ) thisdir=. ;; 403842a55b46Smrg esac 403942a55b46Smrg fi 4040c582b7e3Smrg 404142a55b46Smrg # Try to get the absolute directory name. 404242a55b46Smrg absdir=\`cd \"\$thisdir\" && pwd\` 404342a55b46Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 404442a55b46Smrg" 4045c582b7e3Smrg 404642a55b46Smrg if test "$fast_install" = yes; then 404742a55b46Smrg $ECHO "\ 404842a55b46Smrg program=lt-'$outputname'$exeext 404942a55b46Smrg progdir=\"\$thisdir/$objdir\" 4050c582b7e3Smrg 405142a55b46Smrg if test ! -f \"\$progdir/\$program\" || 405242a55b46Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 405342a55b46Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 4054c582b7e3Smrg 405542a55b46Smrg file=\"\$\$-\$program\" 4056c582b7e3Smrg 405742a55b46Smrg if test ! -d \"\$progdir\"; then 405842a55b46Smrg $MKDIR \"\$progdir\" 405942a55b46Smrg else 406042a55b46Smrg $RM \"\$progdir/\$file\" 406142a55b46Smrg fi" 4062c582b7e3Smrg 406342a55b46Smrg $ECHO "\ 4064c582b7e3Smrg 406542a55b46Smrg # relink executable if necessary 406642a55b46Smrg if test -n \"\$relink_command\"; then 406742a55b46Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 406842a55b46Smrg else 406942a55b46Smrg $ECHO \"\$relink_command_output\" >&2 407042a55b46Smrg $RM \"\$progdir/\$file\" 407142a55b46Smrg exit 1 407242a55b46Smrg fi 407342a55b46Smrg fi 4074c582b7e3Smrg 407542a55b46Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 407642a55b46Smrg { $RM \"\$progdir/\$program\"; 407742a55b46Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 407842a55b46Smrg $RM \"\$progdir/\$file\" 407942a55b46Smrg fi" 408042a55b46Smrg else 408142a55b46Smrg $ECHO "\ 408242a55b46Smrg program='$outputname' 408342a55b46Smrg progdir=\"\$thisdir/$objdir\" 408442a55b46Smrg" 408542a55b46Smrg fi 4086c582b7e3Smrg 408742a55b46Smrg $ECHO "\ 4088c582b7e3Smrg 408942a55b46Smrg if test -f \"\$progdir/\$program\"; then" 409042a55b46Smrg 409142a55b46Smrg # fixup the dll searchpath if we need to. 409242a55b46Smrg # 409342a55b46Smrg # Fix the DLL searchpath if we need to. Do this before prepending 409442a55b46Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 409542a55b46Smrg # libraries must come first. 409642a55b46Smrg if test -n "$dllsearchpath"; then 409742a55b46Smrg $ECHO "\ 409842a55b46Smrg # Add the dll search path components to the executable PATH 409942a55b46Smrg PATH=$dllsearchpath:\$PATH 410042a55b46Smrg" 4101c582b7e3Smrg fi 4102c582b7e3Smrg 410342a55b46Smrg # Export our shlibpath_var if we have one. 410442a55b46Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 410542a55b46Smrg $ECHO "\ 410642a55b46Smrg # Add our own library path to $shlibpath_var 410742a55b46Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 4108c582b7e3Smrg 410942a55b46Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 411042a55b46Smrg # The second colon is a workaround for a bug in BeOS R4 sed 411142a55b46Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 411242a55b46Smrg 411342a55b46Smrg export $shlibpath_var 411442a55b46Smrg" 4115c582b7e3Smrg fi 4116c582b7e3Smrg 411742a55b46Smrg $ECHO "\ 411842a55b46Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 411942a55b46Smrg # Run the actual program with our arguments. 412042a55b46Smrg func_exec_program \${1+\"\$@\"} 412142a55b46Smrg fi 412242a55b46Smrg else 412342a55b46Smrg # The program doesn't exist. 412442a55b46Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 412542a55b46Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 412642a55b46Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 412742a55b46Smrg exit 1 412842a55b46Smrg fi 412942a55b46Smrgfi\ 413042a55b46Smrg" 413142a55b46Smrg} 4132c582b7e3Smrg 4133c582b7e3Smrg 413442a55b46Smrg# func_emit_cwrapperexe_src 413542a55b46Smrg# emit the source code for a wrapper executable on stdout 413642a55b46Smrg# Must ONLY be called from within func_mode_link because 413742a55b46Smrg# it depends on a number of variable set therein. 413842a55b46Smrgfunc_emit_cwrapperexe_src () 413942a55b46Smrg{ 414042a55b46Smrg cat <<EOF 4141c582b7e3Smrg 414242a55b46Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 414342a55b46Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4144c582b7e3Smrg 414542a55b46Smrg The $output program cannot be directly executed until all the libtool 414642a55b46Smrg libraries that it depends on are installed. 4147c582b7e3Smrg 414842a55b46Smrg This wrapper executable should never be moved out of the build directory. 414942a55b46Smrg If it is, it will not operate correctly. 415042a55b46Smrg*/ 415142a55b46SmrgEOF 415242a55b46Smrg cat <<"EOF" 415342a55b46Smrg#ifdef _MSC_VER 415442a55b46Smrg# define _CRT_SECURE_NO_DEPRECATE 1 415542a55b46Smrg#endif 415642a55b46Smrg#include <stdio.h> 415742a55b46Smrg#include <stdlib.h> 415842a55b46Smrg#ifdef _MSC_VER 415942a55b46Smrg# include <direct.h> 416042a55b46Smrg# include <process.h> 416142a55b46Smrg# include <io.h> 416242a55b46Smrg#else 416342a55b46Smrg# include <unistd.h> 416442a55b46Smrg# include <stdint.h> 416542a55b46Smrg# ifdef __CYGWIN__ 416642a55b46Smrg# include <io.h> 416742a55b46Smrg# endif 416842a55b46Smrg#endif 416942a55b46Smrg#include <malloc.h> 417042a55b46Smrg#include <stdarg.h> 417142a55b46Smrg#include <assert.h> 417242a55b46Smrg#include <string.h> 417342a55b46Smrg#include <ctype.h> 417442a55b46Smrg#include <errno.h> 417542a55b46Smrg#include <fcntl.h> 417642a55b46Smrg#include <sys/stat.h> 4177c582b7e3Smrg 417842a55b46Smrg/* declarations of non-ANSI functions */ 417942a55b46Smrg#if defined(__MINGW32__) 418042a55b46Smrg# ifdef __STRICT_ANSI__ 418142a55b46Smrgint _putenv (const char *); 418242a55b46Smrg# endif 418342a55b46Smrg#elif defined(__CYGWIN__) 418442a55b46Smrg# ifdef __STRICT_ANSI__ 418542a55b46Smrgchar *realpath (const char *, char *); 418642a55b46Smrgint putenv (char *); 418742a55b46Smrgint setenv (const char *, const char *, int); 418842a55b46Smrg# endif 418942a55b46Smrg/* #elif defined (other platforms) ... */ 419042a55b46Smrg#endif 4191c582b7e3Smrg 419242a55b46Smrg/* portability defines, excluding path handling macros */ 419342a55b46Smrg#if defined(_MSC_VER) 419442a55b46Smrg# define setmode _setmode 419542a55b46Smrg# define stat _stat 419642a55b46Smrg# define chmod _chmod 419742a55b46Smrg# define getcwd _getcwd 419842a55b46Smrg# define putenv _putenv 419942a55b46Smrg# define S_IXUSR _S_IEXEC 420042a55b46Smrg# ifndef _INTPTR_T_DEFINED 420142a55b46Smrg# define _INTPTR_T_DEFINED 420242a55b46Smrg# define intptr_t int 420342a55b46Smrg# endif 420442a55b46Smrg#elif defined(__MINGW32__) 420542a55b46Smrg# define setmode _setmode 420642a55b46Smrg# define stat _stat 420742a55b46Smrg# define chmod _chmod 420842a55b46Smrg# define getcwd _getcwd 420942a55b46Smrg# define putenv _putenv 421042a55b46Smrg#elif defined(__CYGWIN__) 421142a55b46Smrg# define HAVE_SETENV 421242a55b46Smrg# define FOPEN_WB "wb" 421342a55b46Smrg/* #elif defined (other platforms) ... */ 421442a55b46Smrg#endif 4215c582b7e3Smrg 421642a55b46Smrg#if defined(PATH_MAX) 421742a55b46Smrg# define LT_PATHMAX PATH_MAX 421842a55b46Smrg#elif defined(MAXPATHLEN) 421942a55b46Smrg# define LT_PATHMAX MAXPATHLEN 422042a55b46Smrg#else 422142a55b46Smrg# define LT_PATHMAX 1024 422242a55b46Smrg#endif 4223c582b7e3Smrg 422442a55b46Smrg#ifndef S_IXOTH 422542a55b46Smrg# define S_IXOTH 0 422642a55b46Smrg#endif 422742a55b46Smrg#ifndef S_IXGRP 422842a55b46Smrg# define S_IXGRP 0 422942a55b46Smrg#endif 4230c582b7e3Smrg 423142a55b46Smrg/* path handling portability macros */ 423242a55b46Smrg#ifndef DIR_SEPARATOR 423342a55b46Smrg# define DIR_SEPARATOR '/' 423442a55b46Smrg# define PATH_SEPARATOR ':' 423542a55b46Smrg#endif 4236c582b7e3Smrg 423742a55b46Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 423842a55b46Smrg defined (__OS2__) 423942a55b46Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 424042a55b46Smrg# define FOPEN_WB "wb" 424142a55b46Smrg# ifndef DIR_SEPARATOR_2 424242a55b46Smrg# define DIR_SEPARATOR_2 '\\' 424342a55b46Smrg# endif 424442a55b46Smrg# ifndef PATH_SEPARATOR_2 424542a55b46Smrg# define PATH_SEPARATOR_2 ';' 424642a55b46Smrg# endif 424742a55b46Smrg#endif 4248c582b7e3Smrg 424942a55b46Smrg#ifndef DIR_SEPARATOR_2 425042a55b46Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 425142a55b46Smrg#else /* DIR_SEPARATOR_2 */ 425242a55b46Smrg# define IS_DIR_SEPARATOR(ch) \ 425342a55b46Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 425442a55b46Smrg#endif /* DIR_SEPARATOR_2 */ 4255c582b7e3Smrg 425642a55b46Smrg#ifndef PATH_SEPARATOR_2 425742a55b46Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 425842a55b46Smrg#else /* PATH_SEPARATOR_2 */ 425942a55b46Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 426042a55b46Smrg#endif /* PATH_SEPARATOR_2 */ 4261c582b7e3Smrg 426242a55b46Smrg#ifndef FOPEN_WB 426342a55b46Smrg# define FOPEN_WB "w" 426442a55b46Smrg#endif 426542a55b46Smrg#ifndef _O_BINARY 426642a55b46Smrg# define _O_BINARY 0 426742a55b46Smrg#endif 4268c582b7e3Smrg 426942a55b46Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 427042a55b46Smrg#define XFREE(stale) do { \ 427142a55b46Smrg if (stale) { free ((void *) stale); stale = 0; } \ 427242a55b46Smrg} while (0) 4273c582b7e3Smrg 427442a55b46Smrg#if defined(LT_DEBUGWRAPPER) 427542a55b46Smrgstatic int lt_debug = 1; 427642a55b46Smrg#else 427742a55b46Smrgstatic int lt_debug = 0; 427842a55b46Smrg#endif 4279c582b7e3Smrg 428042a55b46Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 428142a55b46Smrg 428242a55b46Smrgvoid *xmalloc (size_t num); 428342a55b46Smrgchar *xstrdup (const char *string); 428442a55b46Smrgconst char *base_name (const char *name); 428542a55b46Smrgchar *find_executable (const char *wrapper); 428642a55b46Smrgchar *chase_symlinks (const char *pathspec); 428742a55b46Smrgint make_executable (const char *path); 428842a55b46Smrgint check_executable (const char *path); 428942a55b46Smrgchar *strendzap (char *str, const char *pat); 429042a55b46Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 429142a55b46Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 429242a55b46Smrgstatic const char *nonnull (const char *s); 429342a55b46Smrgstatic const char *nonempty (const char *s); 429442a55b46Smrgvoid lt_setenv (const char *name, const char *value); 429542a55b46Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 429642a55b46Smrgvoid lt_update_exe_path (const char *name, const char *value); 429742a55b46Smrgvoid lt_update_lib_path (const char *name, const char *value); 429842a55b46Smrgchar **prepare_spawn (char **argv); 429942a55b46Smrgvoid lt_dump_script (FILE *f); 430042a55b46SmrgEOF 4301c582b7e3Smrg 430242a55b46Smrg cat <<EOF 430342a55b46Smrgvolatile const char * MAGIC_EXE = "$magic_exe"; 430442a55b46Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 430542a55b46SmrgEOF 4306c582b7e3Smrg 430742a55b46Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 430842a55b46Smrg func_to_host_path "$temp_rpath" 430942a55b46Smrg cat <<EOF 431042a55b46Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 431142a55b46SmrgEOF 431242a55b46Smrg else 431342a55b46Smrg cat <<"EOF" 431442a55b46Smrgconst char * LIB_PATH_VALUE = ""; 431542a55b46SmrgEOF 431642a55b46Smrg fi 4317c582b7e3Smrg 431842a55b46Smrg if test -n "$dllsearchpath"; then 431942a55b46Smrg func_to_host_path "$dllsearchpath:" 432042a55b46Smrg cat <<EOF 432142a55b46Smrgconst char * EXE_PATH_VARNAME = "PATH"; 432242a55b46Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 432342a55b46SmrgEOF 432442a55b46Smrg else 432542a55b46Smrg cat <<"EOF" 432642a55b46Smrgconst char * EXE_PATH_VARNAME = ""; 432742a55b46Smrgconst char * EXE_PATH_VALUE = ""; 432842a55b46SmrgEOF 432942a55b46Smrg fi 4330c582b7e3Smrg 433142a55b46Smrg if test "$fast_install" = yes; then 433242a55b46Smrg cat <<EOF 433342a55b46Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 433442a55b46SmrgEOF 433542a55b46Smrg else 433642a55b46Smrg cat <<EOF 433742a55b46Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 433842a55b46SmrgEOF 433942a55b46Smrg fi 4340c582b7e3Smrg 4341c582b7e3Smrg 434242a55b46Smrg cat <<"EOF" 4343c582b7e3Smrg 434442a55b46Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 4345c582b7e3Smrg 434642a55b46Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 434742a55b46Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 434842a55b46Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 4349c582b7e3Smrg 435042a55b46Smrgint 435142a55b46Smrgmain (int argc, char *argv[]) 435242a55b46Smrg{ 435342a55b46Smrg char **newargz; 435442a55b46Smrg int newargc; 435542a55b46Smrg char *tmp_pathspec; 435642a55b46Smrg char *actual_cwrapper_path; 435742a55b46Smrg char *actual_cwrapper_name; 435842a55b46Smrg char *target_name; 435942a55b46Smrg char *lt_argv_zero; 436042a55b46Smrg intptr_t rval = 127; 436142a55b46Smrg 436242a55b46Smrg int i; 4363c582b7e3Smrg 436442a55b46Smrg program_name = (char *) xstrdup (base_name (argv[0])); 436542a55b46Smrg newargz = XMALLOC (char *, argc + 1); 4366c582b7e3Smrg 436742a55b46Smrg /* very simple arg parsing; don't want to rely on getopt 436842a55b46Smrg * also, copy all non cwrapper options to newargz, except 436942a55b46Smrg * argz[0], which is handled differently 437042a55b46Smrg */ 437142a55b46Smrg newargc=0; 437242a55b46Smrg for (i = 1; i < argc; i++) 437342a55b46Smrg { 437442a55b46Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 437542a55b46Smrg { 437642a55b46SmrgEOF 437742a55b46Smrg case "$host" in 437842a55b46Smrg *mingw* | *cygwin* ) 437942a55b46Smrg # make stdout use "unix" line endings 438042a55b46Smrg echo " setmode(1,_O_BINARY);" 438142a55b46Smrg ;; 438242a55b46Smrg esac 4383c582b7e3Smrg 438442a55b46Smrg cat <<"EOF" 438542a55b46Smrg lt_dump_script (stdout); 438642a55b46Smrg return 0; 438742a55b46Smrg } 438842a55b46Smrg if (strcmp (argv[i], debug_opt) == 0) 438942a55b46Smrg { 439042a55b46Smrg lt_debug = 1; 439142a55b46Smrg continue; 439242a55b46Smrg } 439342a55b46Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 439442a55b46Smrg { 439542a55b46Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 439642a55b46Smrg namespace, but it is not one of the ones we know about and 439742a55b46Smrg have already dealt with, above (inluding dump-script), then 439842a55b46Smrg report an error. Otherwise, targets might begin to believe 439942a55b46Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 440042a55b46Smrg namespace. The first time any user complains about this, we'll 440142a55b46Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 440242a55b46Smrg or a configure.ac-settable value. 440342a55b46Smrg */ 440442a55b46Smrg lt_fatal (__FILE__, __LINE__, 440542a55b46Smrg "unrecognized %s option: '%s'", 440642a55b46Smrg ltwrapper_option_prefix, argv[i]); 440742a55b46Smrg } 440842a55b46Smrg /* otherwise ... */ 440942a55b46Smrg newargz[++newargc] = xstrdup (argv[i]); 441042a55b46Smrg } 441142a55b46Smrg newargz[++newargc] = NULL; 4412c582b7e3Smrg 441342a55b46SmrgEOF 441442a55b46Smrg cat <<EOF 441542a55b46Smrg /* The GNU banner must be the first non-error debug message */ 441642a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 441742a55b46SmrgEOF 441842a55b46Smrg cat <<"EOF" 441942a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 442042a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 442142a55b46Smrg 442242a55b46Smrg tmp_pathspec = find_executable (argv[0]); 442342a55b46Smrg if (tmp_pathspec == NULL) 442442a55b46Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 442542a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 442642a55b46Smrg "(main) found exe (before symlink chase) at: %s\n", 442742a55b46Smrg tmp_pathspec); 442842a55b46Smrg 442942a55b46Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 443042a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 443142a55b46Smrg "(main) found exe (after symlink chase) at: %s\n", 443242a55b46Smrg actual_cwrapper_path); 443342a55b46Smrg XFREE (tmp_pathspec); 443442a55b46Smrg 443542a55b46Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 443642a55b46Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 443742a55b46Smrg 443842a55b46Smrg /* wrapper name transforms */ 443942a55b46Smrg strendzap (actual_cwrapper_name, ".exe"); 444042a55b46Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 444142a55b46Smrg XFREE (actual_cwrapper_name); 444242a55b46Smrg actual_cwrapper_name = tmp_pathspec; 444342a55b46Smrg tmp_pathspec = 0; 444442a55b46Smrg 444542a55b46Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 444642a55b46Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 444742a55b46Smrg strendzap (target_name, ".exe"); 444842a55b46Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 444942a55b46Smrg XFREE (target_name); 445042a55b46Smrg target_name = tmp_pathspec; 445142a55b46Smrg tmp_pathspec = 0; 445242a55b46Smrg 445342a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 445442a55b46Smrg "(main) libtool target name: %s\n", 445542a55b46Smrg target_name); 445642a55b46SmrgEOF 445742a55b46Smrg 445842a55b46Smrg cat <<EOF 445942a55b46Smrg newargz[0] = 446042a55b46Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 446142a55b46Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 446242a55b46Smrg strcpy (newargz[0], actual_cwrapper_path); 446342a55b46Smrg strcat (newargz[0], "$objdir"); 446442a55b46Smrg strcat (newargz[0], "/"); 446542a55b46SmrgEOF 446642a55b46Smrg 446742a55b46Smrg cat <<"EOF" 446842a55b46Smrg /* stop here, and copy so we don't have to do this twice */ 446942a55b46Smrg tmp_pathspec = xstrdup (newargz[0]); 447042a55b46Smrg 447142a55b46Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 447242a55b46Smrg strcat (newargz[0], actual_cwrapper_name); 447342a55b46Smrg 447442a55b46Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 447542a55b46Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 447642a55b46Smrg XFREE (tmp_pathspec); 447742a55b46Smrg tmp_pathspec = NULL; 447842a55b46SmrgEOF 447942a55b46Smrg 448042a55b46Smrg case $host_os in 448142a55b46Smrg mingw*) 448242a55b46Smrg cat <<"EOF" 448342a55b46Smrg { 448442a55b46Smrg char* p; 448542a55b46Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 448642a55b46Smrg { 448742a55b46Smrg *p = '/'; 448842a55b46Smrg } 448942a55b46Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 449042a55b46Smrg { 449142a55b46Smrg *p = '/'; 449242a55b46Smrg } 449342a55b46Smrg } 449442a55b46SmrgEOF 449542a55b46Smrg ;; 449642a55b46Smrg esac 449742a55b46Smrg 449842a55b46Smrg cat <<"EOF" 449942a55b46Smrg XFREE (target_name); 450042a55b46Smrg XFREE (actual_cwrapper_path); 450142a55b46Smrg XFREE (actual_cwrapper_name); 450242a55b46Smrg 450342a55b46Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 450442a55b46Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 450542a55b46Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 450642a55b46Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 450742a55b46Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 450842a55b46Smrg libraries must come first. */ 450942a55b46Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 451042a55b46Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 451142a55b46Smrg 451242a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 451342a55b46Smrg nonnull (lt_argv_zero)); 451442a55b46Smrg for (i = 0; i < newargc; i++) 451542a55b46Smrg { 451642a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 451742a55b46Smrg i, nonnull (newargz[i])); 451842a55b46Smrg } 451942a55b46Smrg 452042a55b46SmrgEOF 452142a55b46Smrg 452242a55b46Smrg case $host_os in 452342a55b46Smrg mingw*) 452442a55b46Smrg cat <<"EOF" 452542a55b46Smrg /* execv doesn't actually work on mingw as expected on unix */ 452642a55b46Smrg newargz = prepare_spawn (newargz); 452742a55b46Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 452842a55b46Smrg if (rval == -1) 452942a55b46Smrg { 453042a55b46Smrg /* failed to start process */ 453142a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 453242a55b46Smrg "(main) failed to launch target \"%s\": %s\n", 453342a55b46Smrg lt_argv_zero, nonnull (strerror (errno))); 453442a55b46Smrg return 127; 453542a55b46Smrg } 453642a55b46Smrg return rval; 453742a55b46SmrgEOF 4538c582b7e3Smrg ;; 4539c582b7e3Smrg *) 454042a55b46Smrg cat <<"EOF" 454142a55b46Smrg execv (lt_argv_zero, newargz); 454242a55b46Smrg return rval; /* =127, but avoids unused variable warning */ 454342a55b46SmrgEOF 4544c582b7e3Smrg ;; 454542a55b46Smrg esac 4546c582b7e3Smrg 454742a55b46Smrg cat <<"EOF" 454842a55b46Smrg} 4549c582b7e3Smrg 455042a55b46Smrgvoid * 455142a55b46Smrgxmalloc (size_t num) 455242a55b46Smrg{ 455342a55b46Smrg void *p = (void *) malloc (num); 455442a55b46Smrg if (!p) 455542a55b46Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 4556c582b7e3Smrg 455742a55b46Smrg return p; 455842a55b46Smrg} 4559c582b7e3Smrg 456042a55b46Smrgchar * 456142a55b46Smrgxstrdup (const char *string) 456242a55b46Smrg{ 456342a55b46Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 456442a55b46Smrg string) : NULL; 456542a55b46Smrg} 4566c582b7e3Smrg 456742a55b46Smrgconst char * 456842a55b46Smrgbase_name (const char *name) 456942a55b46Smrg{ 457042a55b46Smrg const char *base; 4571c582b7e3Smrg 457242a55b46Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 457342a55b46Smrg /* Skip over the disk name in MSDOS pathnames. */ 457442a55b46Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 457542a55b46Smrg name += 2; 4576c582b7e3Smrg#endif 4577c582b7e3Smrg 457842a55b46Smrg for (base = name; *name; name++) 457942a55b46Smrg if (IS_DIR_SEPARATOR (*name)) 458042a55b46Smrg base = name + 1; 458142a55b46Smrg return base; 458242a55b46Smrg} 4583c582b7e3Smrg 458442a55b46Smrgint 458542a55b46Smrgcheck_executable (const char *path) 458642a55b46Smrg{ 458742a55b46Smrg struct stat st; 4588c582b7e3Smrg 458942a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 459042a55b46Smrg nonempty (path)); 459142a55b46Smrg if ((!path) || (!*path)) 459242a55b46Smrg return 0; 4593c582b7e3Smrg 459442a55b46Smrg if ((stat (path, &st) >= 0) 459542a55b46Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 459642a55b46Smrg return 1; 459742a55b46Smrg else 459842a55b46Smrg return 0; 459942a55b46Smrg} 4600c582b7e3Smrg 460142a55b46Smrgint 460242a55b46Smrgmake_executable (const char *path) 460342a55b46Smrg{ 460442a55b46Smrg int rval = 0; 460542a55b46Smrg struct stat st; 4606c582b7e3Smrg 460742a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 460842a55b46Smrg nonempty (path)); 460942a55b46Smrg if ((!path) || (!*path)) 461042a55b46Smrg return 0; 4611c582b7e3Smrg 461242a55b46Smrg if (stat (path, &st) >= 0) 461342a55b46Smrg { 461442a55b46Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 461542a55b46Smrg } 461642a55b46Smrg return rval; 461742a55b46Smrg} 4618c582b7e3Smrg 461942a55b46Smrg/* Searches for the full path of the wrapper. Returns 462042a55b46Smrg newly allocated full path name if found, NULL otherwise 462142a55b46Smrg Does not chase symlinks, even on platforms that support them. 462242a55b46Smrg*/ 462342a55b46Smrgchar * 462442a55b46Smrgfind_executable (const char *wrapper) 462542a55b46Smrg{ 462642a55b46Smrg int has_slash = 0; 462742a55b46Smrg const char *p; 462842a55b46Smrg const char *p_next; 462942a55b46Smrg /* static buffer for getcwd */ 463042a55b46Smrg char tmp[LT_PATHMAX + 1]; 463142a55b46Smrg int tmp_len; 463242a55b46Smrg char *concat_name; 4633c582b7e3Smrg 463442a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 463542a55b46Smrg nonempty (wrapper)); 4636c582b7e3Smrg 463742a55b46Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 463842a55b46Smrg return NULL; 4639c582b7e3Smrg 464042a55b46Smrg /* Absolute path? */ 464142a55b46Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 464242a55b46Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 464342a55b46Smrg { 464442a55b46Smrg concat_name = xstrdup (wrapper); 464542a55b46Smrg if (check_executable (concat_name)) 464642a55b46Smrg return concat_name; 464742a55b46Smrg XFREE (concat_name); 464842a55b46Smrg } 464942a55b46Smrg else 465042a55b46Smrg { 465142a55b46Smrg#endif 465242a55b46Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 465342a55b46Smrg { 465442a55b46Smrg concat_name = xstrdup (wrapper); 465542a55b46Smrg if (check_executable (concat_name)) 465642a55b46Smrg return concat_name; 465742a55b46Smrg XFREE (concat_name); 465842a55b46Smrg } 465942a55b46Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 466042a55b46Smrg } 466142a55b46Smrg#endif 4662c582b7e3Smrg 466342a55b46Smrg for (p = wrapper; *p; p++) 466442a55b46Smrg if (*p == '/') 466542a55b46Smrg { 466642a55b46Smrg has_slash = 1; 466742a55b46Smrg break; 466842a55b46Smrg } 466942a55b46Smrg if (!has_slash) 467042a55b46Smrg { 467142a55b46Smrg /* no slashes; search PATH */ 467242a55b46Smrg const char *path = getenv ("PATH"); 467342a55b46Smrg if (path != NULL) 467442a55b46Smrg { 467542a55b46Smrg for (p = path; *p; p = p_next) 467642a55b46Smrg { 467742a55b46Smrg const char *q; 467842a55b46Smrg size_t p_len; 467942a55b46Smrg for (q = p; *q; q++) 468042a55b46Smrg if (IS_PATH_SEPARATOR (*q)) 468142a55b46Smrg break; 468242a55b46Smrg p_len = q - p; 468342a55b46Smrg p_next = (*q == '\0' ? q : q + 1); 468442a55b46Smrg if (p_len == 0) 468542a55b46Smrg { 468642a55b46Smrg /* empty path: current directory */ 468742a55b46Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 468842a55b46Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 468942a55b46Smrg nonnull (strerror (errno))); 469042a55b46Smrg tmp_len = strlen (tmp); 469142a55b46Smrg concat_name = 469242a55b46Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 469342a55b46Smrg memcpy (concat_name, tmp, tmp_len); 469442a55b46Smrg concat_name[tmp_len] = '/'; 469542a55b46Smrg strcpy (concat_name + tmp_len + 1, wrapper); 469642a55b46Smrg } 469742a55b46Smrg else 469842a55b46Smrg { 469942a55b46Smrg concat_name = 470042a55b46Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 470142a55b46Smrg memcpy (concat_name, p, p_len); 470242a55b46Smrg concat_name[p_len] = '/'; 470342a55b46Smrg strcpy (concat_name + p_len + 1, wrapper); 470442a55b46Smrg } 470542a55b46Smrg if (check_executable (concat_name)) 470642a55b46Smrg return concat_name; 470742a55b46Smrg XFREE (concat_name); 470842a55b46Smrg } 470942a55b46Smrg } 471042a55b46Smrg /* not found in PATH; assume curdir */ 471142a55b46Smrg } 471242a55b46Smrg /* Relative path | not found in path: prepend cwd */ 471342a55b46Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 471442a55b46Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 471542a55b46Smrg nonnull (strerror (errno))); 471642a55b46Smrg tmp_len = strlen (tmp); 471742a55b46Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 471842a55b46Smrg memcpy (concat_name, tmp, tmp_len); 471942a55b46Smrg concat_name[tmp_len] = '/'; 472042a55b46Smrg strcpy (concat_name + tmp_len + 1, wrapper); 4721c582b7e3Smrg 472242a55b46Smrg if (check_executable (concat_name)) 472342a55b46Smrg return concat_name; 472442a55b46Smrg XFREE (concat_name); 472542a55b46Smrg return NULL; 472642a55b46Smrg} 4727c582b7e3Smrg 472842a55b46Smrgchar * 472942a55b46Smrgchase_symlinks (const char *pathspec) 473042a55b46Smrg{ 473142a55b46Smrg#ifndef S_ISLNK 473242a55b46Smrg return xstrdup (pathspec); 473342a55b46Smrg#else 473442a55b46Smrg char buf[LT_PATHMAX]; 473542a55b46Smrg struct stat s; 473642a55b46Smrg char *tmp_pathspec = xstrdup (pathspec); 473742a55b46Smrg char *p; 473842a55b46Smrg int has_symlinks = 0; 473942a55b46Smrg while (strlen (tmp_pathspec) && !has_symlinks) 474042a55b46Smrg { 474142a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 474242a55b46Smrg "checking path component for symlinks: %s\n", 474342a55b46Smrg tmp_pathspec); 474442a55b46Smrg if (lstat (tmp_pathspec, &s) == 0) 474542a55b46Smrg { 474642a55b46Smrg if (S_ISLNK (s.st_mode) != 0) 474742a55b46Smrg { 474842a55b46Smrg has_symlinks = 1; 474942a55b46Smrg break; 475042a55b46Smrg } 475142a55b46Smrg 475242a55b46Smrg /* search backwards for last DIR_SEPARATOR */ 475342a55b46Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 475442a55b46Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 475542a55b46Smrg p--; 475642a55b46Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 475742a55b46Smrg { 475842a55b46Smrg /* no more DIR_SEPARATORS left */ 475942a55b46Smrg break; 476042a55b46Smrg } 476142a55b46Smrg *p = '\0'; 476242a55b46Smrg } 476342a55b46Smrg else 476442a55b46Smrg { 476542a55b46Smrg lt_fatal (__FILE__, __LINE__, 476642a55b46Smrg "error accessing file \"%s\": %s", 476742a55b46Smrg tmp_pathspec, nonnull (strerror (errno))); 476842a55b46Smrg } 476942a55b46Smrg } 477042a55b46Smrg XFREE (tmp_pathspec); 4771c582b7e3Smrg 477242a55b46Smrg if (!has_symlinks) 477342a55b46Smrg { 477442a55b46Smrg return xstrdup (pathspec); 477542a55b46Smrg } 4776c582b7e3Smrg 477742a55b46Smrg tmp_pathspec = realpath (pathspec, buf); 477842a55b46Smrg if (tmp_pathspec == 0) 477942a55b46Smrg { 478042a55b46Smrg lt_fatal (__FILE__, __LINE__, 478142a55b46Smrg "could not follow symlinks for %s", pathspec); 478242a55b46Smrg } 478342a55b46Smrg return xstrdup (tmp_pathspec); 4784c582b7e3Smrg#endif 478542a55b46Smrg} 4786c582b7e3Smrg 478742a55b46Smrgchar * 478842a55b46Smrgstrendzap (char *str, const char *pat) 478942a55b46Smrg{ 479042a55b46Smrg size_t len, patlen; 4791c582b7e3Smrg 479242a55b46Smrg assert (str != NULL); 479342a55b46Smrg assert (pat != NULL); 4794c582b7e3Smrg 479542a55b46Smrg len = strlen (str); 479642a55b46Smrg patlen = strlen (pat); 4797c582b7e3Smrg 479842a55b46Smrg if (patlen <= len) 479942a55b46Smrg { 480042a55b46Smrg str += len - patlen; 480142a55b46Smrg if (strcmp (str, pat) == 0) 480242a55b46Smrg *str = '\0'; 480342a55b46Smrg } 480442a55b46Smrg return str; 4805c582b7e3Smrg} 4806c582b7e3Smrg 480742a55b46Smrgvoid 480842a55b46Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 480942a55b46Smrg{ 481042a55b46Smrg va_list args; 481142a55b46Smrg if (lt_debug) 481242a55b46Smrg { 481342a55b46Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 481442a55b46Smrg va_start (args, fmt); 481542a55b46Smrg (void) vfprintf (stderr, fmt, args); 481642a55b46Smrg va_end (args); 481742a55b46Smrg } 481842a55b46Smrg} 4819c582b7e3Smrg 482042a55b46Smrgstatic void 482142a55b46Smrglt_error_core (int exit_status, const char *file, 482242a55b46Smrg int line, const char *mode, 482342a55b46Smrg const char *message, va_list ap) 482442a55b46Smrg{ 482542a55b46Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 482642a55b46Smrg vfprintf (stderr, message, ap); 482742a55b46Smrg fprintf (stderr, ".\n"); 4828c582b7e3Smrg 482942a55b46Smrg if (exit_status >= 0) 483042a55b46Smrg exit (exit_status); 4831c582b7e3Smrg} 4832c582b7e3Smrg 483342a55b46Smrgvoid 483442a55b46Smrglt_fatal (const char *file, int line, const char *message, ...) 483542a55b46Smrg{ 483642a55b46Smrg va_list ap; 483742a55b46Smrg va_start (ap, message); 483842a55b46Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 483942a55b46Smrg va_end (ap); 4840c582b7e3Smrg} 4841c582b7e3Smrg 484242a55b46Smrgstatic const char * 484342a55b46Smrgnonnull (const char *s) 484442a55b46Smrg{ 484542a55b46Smrg return s ? s : "(null)"; 484642a55b46Smrg} 4847c582b7e3Smrg 484842a55b46Smrgstatic const char * 484942a55b46Smrgnonempty (const char *s) 485042a55b46Smrg{ 485142a55b46Smrg return (s && !*s) ? "(empty)" : nonnull (s); 485242a55b46Smrg} 4853c582b7e3Smrg 485442a55b46Smrgvoid 485542a55b46Smrglt_setenv (const char *name, const char *value) 485642a55b46Smrg{ 485742a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 485842a55b46Smrg "(lt_setenv) setting '%s' to '%s'\n", 485942a55b46Smrg nonnull (name), nonnull (value)); 486042a55b46Smrg { 486142a55b46Smrg#ifdef HAVE_SETENV 486242a55b46Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 486342a55b46Smrg char *str = xstrdup (value); 486442a55b46Smrg setenv (name, str, 1); 486542a55b46Smrg#else 486642a55b46Smrg int len = strlen (name) + 1 + strlen (value) + 1; 486742a55b46Smrg char *str = XMALLOC (char, len); 486842a55b46Smrg sprintf (str, "%s=%s", name, value); 486942a55b46Smrg if (putenv (str) != EXIT_SUCCESS) 487042a55b46Smrg { 487142a55b46Smrg XFREE (str); 487242a55b46Smrg } 487342a55b46Smrg#endif 487442a55b46Smrg } 487542a55b46Smrg} 4876c582b7e3Smrg 487742a55b46Smrgchar * 487842a55b46Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 487942a55b46Smrg{ 488042a55b46Smrg char *new_value; 488142a55b46Smrg if (orig_value && *orig_value) 488242a55b46Smrg { 488342a55b46Smrg int orig_value_len = strlen (orig_value); 488442a55b46Smrg int add_len = strlen (add); 488542a55b46Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 488642a55b46Smrg if (to_end) 488742a55b46Smrg { 488842a55b46Smrg strcpy (new_value, orig_value); 488942a55b46Smrg strcpy (new_value + orig_value_len, add); 489042a55b46Smrg } 4891c582b7e3Smrg else 489242a55b46Smrg { 489342a55b46Smrg strcpy (new_value, add); 489442a55b46Smrg strcpy (new_value + add_len, orig_value); 489542a55b46Smrg } 489642a55b46Smrg } 489742a55b46Smrg else 489842a55b46Smrg { 489942a55b46Smrg new_value = xstrdup (add); 490042a55b46Smrg } 490142a55b46Smrg return new_value; 490242a55b46Smrg} 4903c582b7e3Smrg 490442a55b46Smrgvoid 490542a55b46Smrglt_update_exe_path (const char *name, const char *value) 490642a55b46Smrg{ 490742a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 490842a55b46Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 490942a55b46Smrg nonnull (name), nonnull (value)); 4910c582b7e3Smrg 491142a55b46Smrg if (name && *name && value && *value) 491242a55b46Smrg { 491342a55b46Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 491442a55b46Smrg /* some systems can't cope with a ':'-terminated path #' */ 491542a55b46Smrg int len = strlen (new_value); 491642a55b46Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 491742a55b46Smrg { 491842a55b46Smrg new_value[len-1] = '\0'; 491942a55b46Smrg } 492042a55b46Smrg lt_setenv (name, new_value); 492142a55b46Smrg XFREE (new_value); 492242a55b46Smrg } 492342a55b46Smrg} 4924c582b7e3Smrg 492542a55b46Smrgvoid 492642a55b46Smrglt_update_lib_path (const char *name, const char *value) 492742a55b46Smrg{ 492842a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 492942a55b46Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 493042a55b46Smrg nonnull (name), nonnull (value)); 4931c582b7e3Smrg 493242a55b46Smrg if (name && *name && value && *value) 493342a55b46Smrg { 493442a55b46Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 493542a55b46Smrg lt_setenv (name, new_value); 493642a55b46Smrg XFREE (new_value); 493742a55b46Smrg } 493842a55b46Smrg} 4939c582b7e3Smrg 4940c582b7e3SmrgEOF 494142a55b46Smrg case $host_os in 494242a55b46Smrg mingw*) 494342a55b46Smrg cat <<"EOF" 494442a55b46Smrg 494542a55b46Smrg/* Prepares an argument vector before calling spawn(). 494642a55b46Smrg Note that spawn() does not by itself call the command interpreter 494742a55b46Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 494842a55b46Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 494942a55b46Smrg GetVersionEx(&v); 495042a55b46Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 495142a55b46Smrg }) ? "cmd.exe" : "command.com"). 495242a55b46Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 495342a55b46Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 495442a55b46Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 495542a55b46Smrg special way: 495642a55b46Smrg - Space and tab are interpreted as delimiters. They are not treated as 495742a55b46Smrg delimiters if they are surrounded by double quotes: "...". 495842a55b46Smrg - Unescaped double quotes are removed from the input. Their only effect is 495942a55b46Smrg that within double quotes, space and tab are treated like normal 496042a55b46Smrg characters. 496142a55b46Smrg - Backslashes not followed by double quotes are not special. 496242a55b46Smrg - But 2*n+1 backslashes followed by a double quote become 496342a55b46Smrg n backslashes followed by a double quote (n >= 0): 496442a55b46Smrg \" -> " 496542a55b46Smrg \\\" -> \" 496642a55b46Smrg \\\\\" -> \\" 496742a55b46Smrg */ 496842a55b46Smrg#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" 496942a55b46Smrg#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" 497042a55b46Smrgchar ** 497142a55b46Smrgprepare_spawn (char **argv) 4972c582b7e3Smrg{ 497342a55b46Smrg size_t argc; 497442a55b46Smrg char **new_argv; 497542a55b46Smrg size_t i; 4976c582b7e3Smrg 497742a55b46Smrg /* Count number of arguments. */ 497842a55b46Smrg for (argc = 0; argv[argc] != NULL; argc++) 497942a55b46Smrg ; 4980c582b7e3Smrg 498142a55b46Smrg /* Allocate new argument vector. */ 498242a55b46Smrg new_argv = XMALLOC (char *, argc + 1); 4983c582b7e3Smrg 498442a55b46Smrg /* Put quoted arguments into the new argument vector. */ 498542a55b46Smrg for (i = 0; i < argc; i++) 498642a55b46Smrg { 498742a55b46Smrg const char *string = argv[i]; 498842a55b46Smrg 498942a55b46Smrg if (string[0] == '\0') 499042a55b46Smrg new_argv[i] = xstrdup ("\"\""); 499142a55b46Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 499242a55b46Smrg { 499342a55b46Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 499442a55b46Smrg size_t length; 499542a55b46Smrg unsigned int backslashes; 499642a55b46Smrg const char *s; 499742a55b46Smrg char *quoted_string; 499842a55b46Smrg char *p; 499942a55b46Smrg 500042a55b46Smrg length = 0; 500142a55b46Smrg backslashes = 0; 500242a55b46Smrg if (quote_around) 500342a55b46Smrg length++; 500442a55b46Smrg for (s = string; *s != '\0'; s++) 500542a55b46Smrg { 500642a55b46Smrg char c = *s; 500742a55b46Smrg if (c == '"') 500842a55b46Smrg length += backslashes + 1; 500942a55b46Smrg length++; 501042a55b46Smrg if (c == '\\') 501142a55b46Smrg backslashes++; 501242a55b46Smrg else 501342a55b46Smrg backslashes = 0; 501442a55b46Smrg } 501542a55b46Smrg if (quote_around) 501642a55b46Smrg length += backslashes + 1; 501742a55b46Smrg 501842a55b46Smrg quoted_string = XMALLOC (char, length + 1); 501942a55b46Smrg 502042a55b46Smrg p = quoted_string; 502142a55b46Smrg backslashes = 0; 502242a55b46Smrg if (quote_around) 502342a55b46Smrg *p++ = '"'; 502442a55b46Smrg for (s = string; *s != '\0'; s++) 502542a55b46Smrg { 502642a55b46Smrg char c = *s; 502742a55b46Smrg if (c == '"') 502842a55b46Smrg { 502942a55b46Smrg unsigned int j; 503042a55b46Smrg for (j = backslashes + 1; j > 0; j--) 503142a55b46Smrg *p++ = '\\'; 503242a55b46Smrg } 503342a55b46Smrg *p++ = c; 503442a55b46Smrg if (c == '\\') 503542a55b46Smrg backslashes++; 503642a55b46Smrg else 503742a55b46Smrg backslashes = 0; 503842a55b46Smrg } 503942a55b46Smrg if (quote_around) 504042a55b46Smrg { 504142a55b46Smrg unsigned int j; 504242a55b46Smrg for (j = backslashes; j > 0; j--) 504342a55b46Smrg *p++ = '\\'; 504442a55b46Smrg *p++ = '"'; 504542a55b46Smrg } 504642a55b46Smrg *p = '\0'; 5047c582b7e3Smrg 504842a55b46Smrg new_argv[i] = quoted_string; 504942a55b46Smrg } 505042a55b46Smrg else 505142a55b46Smrg new_argv[i] = (char *) string; 505242a55b46Smrg } 505342a55b46Smrg new_argv[argc] = NULL; 5054c582b7e3Smrg 505542a55b46Smrg return new_argv; 505642a55b46Smrg} 5057c582b7e3SmrgEOF 505842a55b46Smrg ;; 505942a55b46Smrg esac 5060c582b7e3Smrg 506142a55b46Smrg cat <<"EOF" 506242a55b46Smrgvoid lt_dump_script (FILE* f) 506342a55b46Smrg{ 5064c582b7e3SmrgEOF 506542a55b46Smrg func_emit_wrapper yes | 506642a55b46Smrg $SED -n -e ' 506742a55b46Smrgs/^\(.\{79\}\)\(..*\)/\1\ 506842a55b46Smrg\2/ 506942a55b46Smrgh 507042a55b46Smrgs/\([\\"]\)/\\\1/g 507142a55b46Smrgs/$/\\n/ 507242a55b46Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 507342a55b46Smrgg 507442a55b46SmrgD' 507542a55b46Smrg cat <<"EOF" 5076c582b7e3Smrg} 507742a55b46SmrgEOF 5078c582b7e3Smrg} 507942a55b46Smrg# end: func_emit_cwrapperexe_src 5080c582b7e3Smrg 508142a55b46Smrg# func_win32_import_lib_p ARG 508242a55b46Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 508342a55b46Smrgfunc_win32_import_lib_p () 5084c582b7e3Smrg{ 508542a55b46Smrg $opt_debug 508642a55b46Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 508742a55b46Smrg *import*) : ;; 508842a55b46Smrg *) false ;; 508942a55b46Smrg esac 5090c582b7e3Smrg} 5091c582b7e3Smrg 509242a55b46Smrg# func_mode_link arg... 509342a55b46Smrgfunc_mode_link () 5094c582b7e3Smrg{ 509542a55b46Smrg $opt_debug 509642a55b46Smrg case $host in 509742a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 509842a55b46Smrg # It is impossible to link a dll without this setting, and 509942a55b46Smrg # we shouldn't force the makefile maintainer to figure out 510042a55b46Smrg # which system we are compiling for in order to pass an extra 510142a55b46Smrg # flag for every libtool invocation. 510242a55b46Smrg # allow_undefined=no 5103c582b7e3Smrg 510442a55b46Smrg # FIXME: Unfortunately, there are problems with the above when trying 510542a55b46Smrg # to make a dll which has undefined symbols, in which case not 510642a55b46Smrg # even a static library is built. For now, we need to specify 510742a55b46Smrg # -no-undefined on the libtool link line when we can be certain 510842a55b46Smrg # that all symbols are satisfied, otherwise we get a static library. 510942a55b46Smrg allow_undefined=yes 511042a55b46Smrg ;; 511142a55b46Smrg *) 511242a55b46Smrg allow_undefined=yes 511342a55b46Smrg ;; 511442a55b46Smrg esac 511542a55b46Smrg libtool_args=$nonopt 511642a55b46Smrg base_compile="$nonopt $@" 511742a55b46Smrg compile_command=$nonopt 511842a55b46Smrg finalize_command=$nonopt 5119c582b7e3Smrg 512042a55b46Smrg compile_rpath= 512142a55b46Smrg finalize_rpath= 512242a55b46Smrg compile_shlibpath= 512342a55b46Smrg finalize_shlibpath= 512442a55b46Smrg convenience= 512542a55b46Smrg old_convenience= 512642a55b46Smrg deplibs= 512742a55b46Smrg old_deplibs= 512842a55b46Smrg compiler_flags= 512942a55b46Smrg linker_flags= 513042a55b46Smrg dllsearchpath= 513142a55b46Smrg lib_search_path=`pwd` 513242a55b46Smrg inst_prefix_dir= 513342a55b46Smrg new_inherited_linker_flags= 5134c582b7e3Smrg 513542a55b46Smrg avoid_version=no 513642a55b46Smrg bindir= 513742a55b46Smrg dlfiles= 513842a55b46Smrg dlprefiles= 513942a55b46Smrg dlself=no 514042a55b46Smrg export_dynamic=no 514142a55b46Smrg export_symbols= 514242a55b46Smrg export_symbols_regex= 514342a55b46Smrg generated= 514442a55b46Smrg libobjs= 514542a55b46Smrg ltlibs= 514642a55b46Smrg module=no 514742a55b46Smrg no_install=no 514842a55b46Smrg objs= 514942a55b46Smrg non_pic_objects= 515042a55b46Smrg precious_files_regex= 515142a55b46Smrg prefer_static_libs=no 515242a55b46Smrg preload=no 515342a55b46Smrg prev= 515442a55b46Smrg prevarg= 515542a55b46Smrg release= 515642a55b46Smrg rpath= 515742a55b46Smrg xrpath= 515842a55b46Smrg perm_rpath= 515942a55b46Smrg temp_rpath= 516042a55b46Smrg thread_safe=no 516142a55b46Smrg vinfo= 516242a55b46Smrg vinfo_number=no 516342a55b46Smrg weak_libs= 516442a55b46Smrg single_module="${wl}-single_module" 516542a55b46Smrg func_infer_tag $base_compile 5166c582b7e3Smrg 516742a55b46Smrg # We need to know -static, to get the right output filenames. 516842a55b46Smrg for arg 516942a55b46Smrg do 517042a55b46Smrg case $arg in 517142a55b46Smrg -shared) 517242a55b46Smrg test "$build_libtool_libs" != yes && \ 517342a55b46Smrg func_fatal_configuration "can not build a shared library" 517442a55b46Smrg build_old_libs=no 517542a55b46Smrg break 517642a55b46Smrg ;; 517742a55b46Smrg -all-static | -static | -static-libtool-libs) 517842a55b46Smrg case $arg in 517942a55b46Smrg -all-static) 518042a55b46Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 518142a55b46Smrg func_warning "complete static linking is impossible in this configuration" 518242a55b46Smrg fi 518342a55b46Smrg if test -n "$link_static_flag"; then 518442a55b46Smrg dlopen_self=$dlopen_self_static 518542a55b46Smrg fi 518642a55b46Smrg prefer_static_libs=yes 518742a55b46Smrg ;; 518842a55b46Smrg -static) 518942a55b46Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 519042a55b46Smrg dlopen_self=$dlopen_self_static 519142a55b46Smrg fi 519242a55b46Smrg prefer_static_libs=built 519342a55b46Smrg ;; 519442a55b46Smrg -static-libtool-libs) 519542a55b46Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 519642a55b46Smrg dlopen_self=$dlopen_self_static 519742a55b46Smrg fi 519842a55b46Smrg prefer_static_libs=yes 519942a55b46Smrg ;; 520042a55b46Smrg esac 520142a55b46Smrg build_libtool_libs=no 520242a55b46Smrg build_old_libs=yes 520342a55b46Smrg break 520442a55b46Smrg ;; 520542a55b46Smrg esac 520642a55b46Smrg done 5207c582b7e3Smrg 520842a55b46Smrg # See if our shared archives depend on static archives. 520942a55b46Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 5210c582b7e3Smrg 521142a55b46Smrg # Go through the arguments, transforming them on the way. 521242a55b46Smrg while test "$#" -gt 0; do 521342a55b46Smrg arg="$1" 521442a55b46Smrg shift 521542a55b46Smrg func_quote_for_eval "$arg" 521642a55b46Smrg qarg=$func_quote_for_eval_unquoted_result 521742a55b46Smrg func_append libtool_args " $func_quote_for_eval_result" 5218c582b7e3Smrg 521942a55b46Smrg # If the previous option needs an argument, assign it. 522042a55b46Smrg if test -n "$prev"; then 522142a55b46Smrg case $prev in 522242a55b46Smrg output) 522342a55b46Smrg func_append compile_command " @OUTPUT@" 522442a55b46Smrg func_append finalize_command " @OUTPUT@" 522542a55b46Smrg ;; 522642a55b46Smrg esac 5227c582b7e3Smrg 522842a55b46Smrg case $prev in 522942a55b46Smrg bindir) 523042a55b46Smrg bindir="$arg" 523142a55b46Smrg prev= 523242a55b46Smrg continue 523342a55b46Smrg ;; 523442a55b46Smrg dlfiles|dlprefiles) 523542a55b46Smrg if test "$preload" = no; then 523642a55b46Smrg # Add the symbol object into the linking commands. 523742a55b46Smrg func_append compile_command " @SYMFILE@" 523842a55b46Smrg func_append finalize_command " @SYMFILE@" 523942a55b46Smrg preload=yes 524042a55b46Smrg fi 524142a55b46Smrg case $arg in 524242a55b46Smrg *.la | *.lo) ;; # We handle these cases below. 524342a55b46Smrg force) 524442a55b46Smrg if test "$dlself" = no; then 524542a55b46Smrg dlself=needless 524642a55b46Smrg export_dynamic=yes 524742a55b46Smrg fi 524842a55b46Smrg prev= 524942a55b46Smrg continue 525042a55b46Smrg ;; 525142a55b46Smrg self) 525242a55b46Smrg if test "$prev" = dlprefiles; then 525342a55b46Smrg dlself=yes 525442a55b46Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 525542a55b46Smrg dlself=yes 525642a55b46Smrg else 525742a55b46Smrg dlself=needless 525842a55b46Smrg export_dynamic=yes 525942a55b46Smrg fi 526042a55b46Smrg prev= 526142a55b46Smrg continue 526242a55b46Smrg ;; 526342a55b46Smrg *) 526442a55b46Smrg if test "$prev" = dlfiles; then 526542a55b46Smrg func_append dlfiles " $arg" 526642a55b46Smrg else 526742a55b46Smrg func_append dlprefiles " $arg" 526842a55b46Smrg fi 526942a55b46Smrg prev= 527042a55b46Smrg continue 527142a55b46Smrg ;; 527242a55b46Smrg esac 527342a55b46Smrg ;; 527442a55b46Smrg expsyms) 527542a55b46Smrg export_symbols="$arg" 527642a55b46Smrg test -f "$arg" \ 527742a55b46Smrg || func_fatal_error "symbol file \`$arg' does not exist" 527842a55b46Smrg prev= 527942a55b46Smrg continue 528042a55b46Smrg ;; 528142a55b46Smrg expsyms_regex) 528242a55b46Smrg export_symbols_regex="$arg" 528342a55b46Smrg prev= 528442a55b46Smrg continue 528542a55b46Smrg ;; 528642a55b46Smrg framework) 528742a55b46Smrg case $host in 528842a55b46Smrg *-*-darwin*) 528942a55b46Smrg case "$deplibs " in 529042a55b46Smrg *" $qarg.ltframework "*) ;; 529142a55b46Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 529242a55b46Smrg ;; 529342a55b46Smrg esac 529442a55b46Smrg ;; 529542a55b46Smrg esac 529642a55b46Smrg prev= 529742a55b46Smrg continue 529842a55b46Smrg ;; 529942a55b46Smrg inst_prefix) 530042a55b46Smrg inst_prefix_dir="$arg" 530142a55b46Smrg prev= 530242a55b46Smrg continue 530342a55b46Smrg ;; 530442a55b46Smrg objectlist) 530542a55b46Smrg if test -f "$arg"; then 530642a55b46Smrg save_arg=$arg 530742a55b46Smrg moreargs= 530842a55b46Smrg for fil in `cat "$save_arg"` 530942a55b46Smrg do 531042a55b46Smrg# func_append moreargs " $fil" 531142a55b46Smrg arg=$fil 531242a55b46Smrg # A libtool-controlled object. 5313c582b7e3Smrg 531442a55b46Smrg # Check to see that this really is a libtool object. 531542a55b46Smrg if func_lalib_unsafe_p "$arg"; then 531642a55b46Smrg pic_object= 531742a55b46Smrg non_pic_object= 5318c582b7e3Smrg 531942a55b46Smrg # Read the .lo file 532042a55b46Smrg func_source "$arg" 5321c582b7e3Smrg 532242a55b46Smrg if test -z "$pic_object" || 532342a55b46Smrg test -z "$non_pic_object" || 532442a55b46Smrg test "$pic_object" = none && 532542a55b46Smrg test "$non_pic_object" = none; then 532642a55b46Smrg func_fatal_error "cannot find name of object for \`$arg'" 532742a55b46Smrg fi 5328c582b7e3Smrg 532942a55b46Smrg # Extract subdirectory from the argument. 533042a55b46Smrg func_dirname "$arg" "/" "" 533142a55b46Smrg xdir="$func_dirname_result" 5332c582b7e3Smrg 533342a55b46Smrg if test "$pic_object" != none; then 533442a55b46Smrg # Prepend the subdirectory the object is found in. 533542a55b46Smrg pic_object="$xdir$pic_object" 5336c582b7e3Smrg 533742a55b46Smrg if test "$prev" = dlfiles; then 533842a55b46Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 533942a55b46Smrg func_append dlfiles " $pic_object" 534042a55b46Smrg prev= 534142a55b46Smrg continue 534242a55b46Smrg else 534342a55b46Smrg # If libtool objects are unsupported, then we need to preload. 534442a55b46Smrg prev=dlprefiles 534542a55b46Smrg fi 534642a55b46Smrg fi 5347c582b7e3Smrg 534842a55b46Smrg # CHECK ME: I think I busted this. -Ossama 534942a55b46Smrg if test "$prev" = dlprefiles; then 535042a55b46Smrg # Preload the old-style object. 535142a55b46Smrg func_append dlprefiles " $pic_object" 535242a55b46Smrg prev= 535342a55b46Smrg fi 5354c582b7e3Smrg 535542a55b46Smrg # A PIC object. 535642a55b46Smrg func_append libobjs " $pic_object" 535742a55b46Smrg arg="$pic_object" 535842a55b46Smrg fi 5359c582b7e3Smrg 536042a55b46Smrg # Non-PIC object. 536142a55b46Smrg if test "$non_pic_object" != none; then 536242a55b46Smrg # Prepend the subdirectory the object is found in. 536342a55b46Smrg non_pic_object="$xdir$non_pic_object" 5364c582b7e3Smrg 536542a55b46Smrg # A standard non-PIC object 536642a55b46Smrg func_append non_pic_objects " $non_pic_object" 536742a55b46Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 536842a55b46Smrg arg="$non_pic_object" 536942a55b46Smrg fi 537042a55b46Smrg else 537142a55b46Smrg # If the PIC object exists, use it instead. 537242a55b46Smrg # $xdir was prepended to $pic_object above. 537342a55b46Smrg non_pic_object="$pic_object" 537442a55b46Smrg func_append non_pic_objects " $non_pic_object" 537542a55b46Smrg fi 537642a55b46Smrg else 537742a55b46Smrg # Only an error if not doing a dry-run. 537842a55b46Smrg if $opt_dry_run; then 537942a55b46Smrg # Extract subdirectory from the argument. 538042a55b46Smrg func_dirname "$arg" "/" "" 538142a55b46Smrg xdir="$func_dirname_result" 538242a55b46Smrg 538342a55b46Smrg func_lo2o "$arg" 538442a55b46Smrg pic_object=$xdir$objdir/$func_lo2o_result 538542a55b46Smrg non_pic_object=$xdir$func_lo2o_result 538642a55b46Smrg func_append libobjs " $pic_object" 538742a55b46Smrg func_append non_pic_objects " $non_pic_object" 538842a55b46Smrg else 538942a55b46Smrg func_fatal_error "\`$arg' is not a valid libtool object" 539042a55b46Smrg fi 539142a55b46Smrg fi 539242a55b46Smrg done 539342a55b46Smrg else 539442a55b46Smrg func_fatal_error "link input file \`$arg' does not exist" 539542a55b46Smrg fi 539642a55b46Smrg arg=$save_arg 539742a55b46Smrg prev= 539842a55b46Smrg continue 539942a55b46Smrg ;; 540042a55b46Smrg precious_regex) 540142a55b46Smrg precious_files_regex="$arg" 540242a55b46Smrg prev= 540342a55b46Smrg continue 540442a55b46Smrg ;; 540542a55b46Smrg release) 540642a55b46Smrg release="-$arg" 540742a55b46Smrg prev= 540842a55b46Smrg continue 540942a55b46Smrg ;; 541042a55b46Smrg rpath | xrpath) 541142a55b46Smrg # We need an absolute path. 541242a55b46Smrg case $arg in 541342a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 541442a55b46Smrg *) 541542a55b46Smrg func_fatal_error "only absolute run-paths are allowed" 541642a55b46Smrg ;; 541742a55b46Smrg esac 541842a55b46Smrg if test "$prev" = rpath; then 541942a55b46Smrg case "$rpath " in 542042a55b46Smrg *" $arg "*) ;; 542142a55b46Smrg *) func_append rpath " $arg" ;; 542242a55b46Smrg esac 542342a55b46Smrg else 542442a55b46Smrg case "$xrpath " in 542542a55b46Smrg *" $arg "*) ;; 542642a55b46Smrg *) func_append xrpath " $arg" ;; 542742a55b46Smrg esac 542842a55b46Smrg fi 542942a55b46Smrg prev= 543042a55b46Smrg continue 543142a55b46Smrg ;; 543242a55b46Smrg shrext) 543342a55b46Smrg shrext_cmds="$arg" 543442a55b46Smrg prev= 543542a55b46Smrg continue 543642a55b46Smrg ;; 543742a55b46Smrg weak) 543842a55b46Smrg func_append weak_libs " $arg" 543942a55b46Smrg prev= 544042a55b46Smrg continue 544142a55b46Smrg ;; 544242a55b46Smrg xcclinker) 544342a55b46Smrg func_append linker_flags " $qarg" 544442a55b46Smrg func_append compiler_flags " $qarg" 544542a55b46Smrg prev= 544642a55b46Smrg func_append compile_command " $qarg" 544742a55b46Smrg func_append finalize_command " $qarg" 544842a55b46Smrg continue 544942a55b46Smrg ;; 545042a55b46Smrg xcompiler) 545142a55b46Smrg func_append compiler_flags " $qarg" 545242a55b46Smrg prev= 545342a55b46Smrg func_append compile_command " $qarg" 545442a55b46Smrg func_append finalize_command " $qarg" 545542a55b46Smrg continue 545642a55b46Smrg ;; 545742a55b46Smrg xlinker) 545842a55b46Smrg func_append linker_flags " $qarg" 545942a55b46Smrg func_append compiler_flags " $wl$qarg" 546042a55b46Smrg prev= 546142a55b46Smrg func_append compile_command " $wl$qarg" 546242a55b46Smrg func_append finalize_command " $wl$qarg" 546342a55b46Smrg continue 546442a55b46Smrg ;; 546542a55b46Smrg *) 546642a55b46Smrg eval "$prev=\"\$arg\"" 546742a55b46Smrg prev= 546842a55b46Smrg continue 546942a55b46Smrg ;; 547042a55b46Smrg esac 547142a55b46Smrg fi # test -n "$prev" 5472c582b7e3Smrg 547342a55b46Smrg prevarg="$arg" 5474c582b7e3Smrg 547542a55b46Smrg case $arg in 547642a55b46Smrg -all-static) 547742a55b46Smrg if test -n "$link_static_flag"; then 547842a55b46Smrg # See comment for -static flag below, for more details. 547942a55b46Smrg func_append compile_command " $link_static_flag" 548042a55b46Smrg func_append finalize_command " $link_static_flag" 548142a55b46Smrg fi 548242a55b46Smrg continue 548342a55b46Smrg ;; 5484c582b7e3Smrg 548542a55b46Smrg -allow-undefined) 548642a55b46Smrg # FIXME: remove this flag sometime in the future. 548742a55b46Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 548842a55b46Smrg ;; 5489c582b7e3Smrg 549042a55b46Smrg -avoid-version) 549142a55b46Smrg avoid_version=yes 549242a55b46Smrg continue 549342a55b46Smrg ;; 5494c582b7e3Smrg 549542a55b46Smrg -bindir) 549642a55b46Smrg prev=bindir 549742a55b46Smrg continue 549842a55b46Smrg ;; 5499c582b7e3Smrg 550042a55b46Smrg -dlopen) 550142a55b46Smrg prev=dlfiles 550242a55b46Smrg continue 550342a55b46Smrg ;; 5504c582b7e3Smrg 550542a55b46Smrg -dlpreopen) 550642a55b46Smrg prev=dlprefiles 550742a55b46Smrg continue 550842a55b46Smrg ;; 5509c582b7e3Smrg 551042a55b46Smrg -export-dynamic) 551142a55b46Smrg export_dynamic=yes 551242a55b46Smrg continue 551342a55b46Smrg ;; 5514c582b7e3Smrg 551542a55b46Smrg -export-symbols | -export-symbols-regex) 551642a55b46Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 551742a55b46Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 551842a55b46Smrg fi 551942a55b46Smrg if test "X$arg" = "X-export-symbols"; then 552042a55b46Smrg prev=expsyms 552142a55b46Smrg else 552242a55b46Smrg prev=expsyms_regex 552342a55b46Smrg fi 552442a55b46Smrg continue 552542a55b46Smrg ;; 5526c582b7e3Smrg 552742a55b46Smrg -framework) 552842a55b46Smrg prev=framework 552942a55b46Smrg continue 553042a55b46Smrg ;; 5531c582b7e3Smrg 553242a55b46Smrg -inst-prefix-dir) 553342a55b46Smrg prev=inst_prefix 553442a55b46Smrg continue 553542a55b46Smrg ;; 5536c582b7e3Smrg 553742a55b46Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 553842a55b46Smrg # so, if we see these flags be careful not to treat them like -L 553942a55b46Smrg -L[A-Z][A-Z]*:*) 554042a55b46Smrg case $with_gcc/$host in 554142a55b46Smrg no/*-*-irix* | /*-*-irix*) 554242a55b46Smrg func_append compile_command " $arg" 554342a55b46Smrg func_append finalize_command " $arg" 554442a55b46Smrg ;; 554542a55b46Smrg esac 554642a55b46Smrg continue 554742a55b46Smrg ;; 5548c582b7e3Smrg 554942a55b46Smrg -L*) 555042a55b46Smrg func_stripname "-L" '' "$arg" 555142a55b46Smrg if test -z "$func_stripname_result"; then 555242a55b46Smrg if test "$#" -gt 0; then 555342a55b46Smrg func_fatal_error "require no space between \`-L' and \`$1'" 555442a55b46Smrg else 555542a55b46Smrg func_fatal_error "need path for \`-L' option" 555642a55b46Smrg fi 555742a55b46Smrg fi 555842a55b46Smrg func_resolve_sysroot "$func_stripname_result" 555942a55b46Smrg dir=$func_resolve_sysroot_result 556042a55b46Smrg # We need an absolute path. 556142a55b46Smrg case $dir in 556242a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 556342a55b46Smrg *) 556442a55b46Smrg absdir=`cd "$dir" && pwd` 556542a55b46Smrg test -z "$absdir" && \ 556642a55b46Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 556742a55b46Smrg dir="$absdir" 556842a55b46Smrg ;; 556942a55b46Smrg esac 557042a55b46Smrg case "$deplibs " in 557142a55b46Smrg *" -L$dir "* | *" $arg "*) 557242a55b46Smrg # Will only happen for absolute or sysroot arguments 557342a55b46Smrg ;; 557442a55b46Smrg *) 557542a55b46Smrg # Preserve sysroot, but never include relative directories 557642a55b46Smrg case $dir in 557742a55b46Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 557842a55b46Smrg *) func_append deplibs " -L$dir" ;; 557942a55b46Smrg esac 558042a55b46Smrg func_append lib_search_path " $dir" 558142a55b46Smrg ;; 558242a55b46Smrg esac 558342a55b46Smrg case $host in 558442a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 558542a55b46Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 558642a55b46Smrg case :$dllsearchpath: in 558742a55b46Smrg *":$dir:"*) ;; 558842a55b46Smrg ::) dllsearchpath=$dir;; 558942a55b46Smrg *) func_append dllsearchpath ":$dir";; 559042a55b46Smrg esac 559142a55b46Smrg case :$dllsearchpath: in 559242a55b46Smrg *":$testbindir:"*) ;; 559342a55b46Smrg ::) dllsearchpath=$testbindir;; 559442a55b46Smrg *) func_append dllsearchpath ":$testbindir";; 559542a55b46Smrg esac 559642a55b46Smrg ;; 559742a55b46Smrg esac 559842a55b46Smrg continue 559942a55b46Smrg ;; 5600c582b7e3Smrg 560142a55b46Smrg -l*) 560242a55b46Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 560342a55b46Smrg case $host in 560442a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 560542a55b46Smrg # These systems don't actually have a C or math library (as such) 560642a55b46Smrg continue 560742a55b46Smrg ;; 560842a55b46Smrg *-*-os2*) 560942a55b46Smrg # These systems don't actually have a C library (as such) 561042a55b46Smrg test "X$arg" = "X-lc" && continue 561142a55b46Smrg ;; 561242a55b46Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 561342a55b46Smrg # Do not include libc due to us having libc/libc_r. 561442a55b46Smrg test "X$arg" = "X-lc" && continue 561542a55b46Smrg ;; 561642a55b46Smrg *-*-rhapsody* | *-*-darwin1.[012]) 561742a55b46Smrg # Rhapsody C and math libraries are in the System framework 561842a55b46Smrg func_append deplibs " System.ltframework" 561942a55b46Smrg continue 562042a55b46Smrg ;; 562142a55b46Smrg *-*-sco3.2v5* | *-*-sco5v6*) 562242a55b46Smrg # Causes problems with __ctype 562342a55b46Smrg test "X$arg" = "X-lc" && continue 562442a55b46Smrg ;; 562542a55b46Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 562642a55b46Smrg # Compiler inserts libc in the correct place for threads to work 562742a55b46Smrg test "X$arg" = "X-lc" && continue 562842a55b46Smrg ;; 562942a55b46Smrg esac 563042a55b46Smrg elif test "X$arg" = "X-lc_r"; then 563142a55b46Smrg case $host in 563242a55b46Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 563342a55b46Smrg # Do not include libc_r directly, use -pthread flag. 563442a55b46Smrg continue 563542a55b46Smrg ;; 563642a55b46Smrg esac 563742a55b46Smrg fi 563842a55b46Smrg func_append deplibs " $arg" 563942a55b46Smrg continue 564042a55b46Smrg ;; 564142a55b46Smrg 564242a55b46Smrg -module) 564342a55b46Smrg module=yes 564442a55b46Smrg continue 564542a55b46Smrg ;; 564642a55b46Smrg 564742a55b46Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 564842a55b46Smrg # classes, name mangling, and exception handling. 564942a55b46Smrg # Darwin uses the -arch flag to determine output architecture. 565042a55b46Smrg -model|-arch|-isysroot|--sysroot) 565142a55b46Smrg func_append compiler_flags " $arg" 565242a55b46Smrg func_append compile_command " $arg" 565342a55b46Smrg func_append finalize_command " $arg" 565442a55b46Smrg prev=xcompiler 565542a55b46Smrg continue 565642a55b46Smrg ;; 565742a55b46Smrg 565842a55b46Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 565942a55b46Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 566042a55b46Smrg func_append compiler_flags " $arg" 566142a55b46Smrg func_append compile_command " $arg" 566242a55b46Smrg func_append finalize_command " $arg" 566342a55b46Smrg case "$new_inherited_linker_flags " in 566442a55b46Smrg *" $arg "*) ;; 566542a55b46Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 566642a55b46Smrg esac 566742a55b46Smrg continue 566842a55b46Smrg ;; 566942a55b46Smrg 567042a55b46Smrg -multi_module) 567142a55b46Smrg single_module="${wl}-multi_module" 567242a55b46Smrg continue 567342a55b46Smrg ;; 567442a55b46Smrg 567542a55b46Smrg -no-fast-install) 567642a55b46Smrg fast_install=no 567742a55b46Smrg continue 567842a55b46Smrg ;; 567942a55b46Smrg 568042a55b46Smrg -no-install) 568142a55b46Smrg case $host in 568242a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 568342a55b46Smrg # The PATH hackery in wrapper scripts is required on Windows 568442a55b46Smrg # and Darwin in order for the loader to find any dlls it needs. 568542a55b46Smrg func_warning "\`-no-install' is ignored for $host" 568642a55b46Smrg func_warning "assuming \`-no-fast-install' instead" 568742a55b46Smrg fast_install=no 568842a55b46Smrg ;; 568942a55b46Smrg *) no_install=yes ;; 569042a55b46Smrg esac 569142a55b46Smrg continue 569242a55b46Smrg ;; 569342a55b46Smrg 569442a55b46Smrg -no-undefined) 569542a55b46Smrg allow_undefined=no 569642a55b46Smrg continue 569742a55b46Smrg ;; 569842a55b46Smrg 569942a55b46Smrg -objectlist) 570042a55b46Smrg prev=objectlist 570142a55b46Smrg continue 570242a55b46Smrg ;; 570342a55b46Smrg 570442a55b46Smrg -o) prev=output ;; 570542a55b46Smrg 570642a55b46Smrg -precious-files-regex) 570742a55b46Smrg prev=precious_regex 570842a55b46Smrg continue 570942a55b46Smrg ;; 571042a55b46Smrg 571142a55b46Smrg -release) 571242a55b46Smrg prev=release 571342a55b46Smrg continue 571442a55b46Smrg ;; 571542a55b46Smrg 571642a55b46Smrg -rpath) 571742a55b46Smrg prev=rpath 571842a55b46Smrg continue 571942a55b46Smrg ;; 572042a55b46Smrg 572142a55b46Smrg -R) 572242a55b46Smrg prev=xrpath 572342a55b46Smrg continue 572442a55b46Smrg ;; 572542a55b46Smrg 572642a55b46Smrg -R*) 572742a55b46Smrg func_stripname '-R' '' "$arg" 572842a55b46Smrg dir=$func_stripname_result 572942a55b46Smrg # We need an absolute path. 573042a55b46Smrg case $dir in 573142a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 573242a55b46Smrg =*) 573342a55b46Smrg func_stripname '=' '' "$dir" 573442a55b46Smrg dir=$lt_sysroot$func_stripname_result 573542a55b46Smrg ;; 573642a55b46Smrg *) 573742a55b46Smrg func_fatal_error "only absolute run-paths are allowed" 573842a55b46Smrg ;; 573942a55b46Smrg esac 574042a55b46Smrg case "$xrpath " in 574142a55b46Smrg *" $dir "*) ;; 574242a55b46Smrg *) func_append xrpath " $dir" ;; 574342a55b46Smrg esac 574442a55b46Smrg continue 574542a55b46Smrg ;; 574642a55b46Smrg 574742a55b46Smrg -shared) 574842a55b46Smrg # The effects of -shared are defined in a previous loop. 574942a55b46Smrg continue 575042a55b46Smrg ;; 575142a55b46Smrg 575242a55b46Smrg -shrext) 575342a55b46Smrg prev=shrext 575442a55b46Smrg continue 575542a55b46Smrg ;; 575642a55b46Smrg 575742a55b46Smrg -static | -static-libtool-libs) 575842a55b46Smrg # The effects of -static are defined in a previous loop. 575942a55b46Smrg # We used to do the same as -all-static on platforms that 576042a55b46Smrg # didn't have a PIC flag, but the assumption that the effects 576142a55b46Smrg # would be equivalent was wrong. It would break on at least 576242a55b46Smrg # Digital Unix and AIX. 576342a55b46Smrg continue 576442a55b46Smrg ;; 576542a55b46Smrg 576642a55b46Smrg -thread-safe) 576742a55b46Smrg thread_safe=yes 576842a55b46Smrg continue 576942a55b46Smrg ;; 577042a55b46Smrg 577142a55b46Smrg -version-info) 577242a55b46Smrg prev=vinfo 577342a55b46Smrg continue 577442a55b46Smrg ;; 577542a55b46Smrg 577642a55b46Smrg -version-number) 577742a55b46Smrg prev=vinfo 577842a55b46Smrg vinfo_number=yes 577942a55b46Smrg continue 578042a55b46Smrg ;; 578142a55b46Smrg 578242a55b46Smrg -weak) 578342a55b46Smrg prev=weak 578442a55b46Smrg continue 578542a55b46Smrg ;; 578642a55b46Smrg 578742a55b46Smrg -Wc,*) 578842a55b46Smrg func_stripname '-Wc,' '' "$arg" 578942a55b46Smrg args=$func_stripname_result 579042a55b46Smrg arg= 579142a55b46Smrg save_ifs="$IFS"; IFS=',' 579242a55b46Smrg for flag in $args; do 579342a55b46Smrg IFS="$save_ifs" 579442a55b46Smrg func_quote_for_eval "$flag" 579542a55b46Smrg func_append arg " $func_quote_for_eval_result" 579642a55b46Smrg func_append compiler_flags " $func_quote_for_eval_result" 579742a55b46Smrg done 579842a55b46Smrg IFS="$save_ifs" 579942a55b46Smrg func_stripname ' ' '' "$arg" 580042a55b46Smrg arg=$func_stripname_result 580142a55b46Smrg ;; 580242a55b46Smrg 580342a55b46Smrg -Wl,*) 580442a55b46Smrg func_stripname '-Wl,' '' "$arg" 580542a55b46Smrg args=$func_stripname_result 580642a55b46Smrg arg= 580742a55b46Smrg save_ifs="$IFS"; IFS=',' 580842a55b46Smrg for flag in $args; do 580942a55b46Smrg IFS="$save_ifs" 581042a55b46Smrg func_quote_for_eval "$flag" 581142a55b46Smrg func_append arg " $wl$func_quote_for_eval_result" 581242a55b46Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 581342a55b46Smrg func_append linker_flags " $func_quote_for_eval_result" 581442a55b46Smrg done 581542a55b46Smrg IFS="$save_ifs" 581642a55b46Smrg func_stripname ' ' '' "$arg" 581742a55b46Smrg arg=$func_stripname_result 581842a55b46Smrg ;; 581942a55b46Smrg 582042a55b46Smrg -Xcompiler) 582142a55b46Smrg prev=xcompiler 582242a55b46Smrg continue 582342a55b46Smrg ;; 582442a55b46Smrg 582542a55b46Smrg -Xlinker) 582642a55b46Smrg prev=xlinker 582742a55b46Smrg continue 582842a55b46Smrg ;; 582942a55b46Smrg 583042a55b46Smrg -XCClinker) 583142a55b46Smrg prev=xcclinker 583242a55b46Smrg continue 583342a55b46Smrg ;; 583442a55b46Smrg 583542a55b46Smrg # -msg_* for osf cc 583642a55b46Smrg -msg_*) 583742a55b46Smrg func_quote_for_eval "$arg" 583842a55b46Smrg arg="$func_quote_for_eval_result" 583942a55b46Smrg ;; 584042a55b46Smrg 584142a55b46Smrg # Flags to be passed through unchanged, with rationale: 584242a55b46Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 584342a55b46Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 584442a55b46Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 584542a55b46Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 584642a55b46Smrg # -q* compiler args for the IBM compiler 584742a55b46Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 584842a55b46Smrg # -F/path path to uninstalled frameworks, gcc on darwin 584942a55b46Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 585042a55b46Smrg # @file GCC response files 585142a55b46Smrg # -tp=* Portland pgcc target processor selection 585242a55b46Smrg # --sysroot=* for sysroot support 585342a55b46Smrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 585442a55b46Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 585542a55b46Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 585642a55b46Smrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 585742a55b46Smrg func_quote_for_eval "$arg" 585842a55b46Smrg arg="$func_quote_for_eval_result" 585942a55b46Smrg func_append compile_command " $arg" 586042a55b46Smrg func_append finalize_command " $arg" 586142a55b46Smrg func_append compiler_flags " $arg" 586242a55b46Smrg continue 586342a55b46Smrg ;; 586442a55b46Smrg 586542a55b46Smrg # Some other compiler flag. 586642a55b46Smrg -* | +*) 586742a55b46Smrg func_quote_for_eval "$arg" 586842a55b46Smrg arg="$func_quote_for_eval_result" 586942a55b46Smrg ;; 587042a55b46Smrg 587142a55b46Smrg *.$objext) 587242a55b46Smrg # A standard object. 587342a55b46Smrg func_append objs " $arg" 587442a55b46Smrg ;; 587542a55b46Smrg 587642a55b46Smrg *.lo) 587742a55b46Smrg # A libtool-controlled object. 587842a55b46Smrg 587942a55b46Smrg # Check to see that this really is a libtool object. 588042a55b46Smrg if func_lalib_unsafe_p "$arg"; then 588142a55b46Smrg pic_object= 588242a55b46Smrg non_pic_object= 588342a55b46Smrg 588442a55b46Smrg # Read the .lo file 588542a55b46Smrg func_source "$arg" 588642a55b46Smrg 588742a55b46Smrg if test -z "$pic_object" || 588842a55b46Smrg test -z "$non_pic_object" || 588942a55b46Smrg test "$pic_object" = none && 589042a55b46Smrg test "$non_pic_object" = none; then 589142a55b46Smrg func_fatal_error "cannot find name of object for \`$arg'" 589242a55b46Smrg fi 589342a55b46Smrg 589442a55b46Smrg # Extract subdirectory from the argument. 589542a55b46Smrg func_dirname "$arg" "/" "" 589642a55b46Smrg xdir="$func_dirname_result" 589742a55b46Smrg 589842a55b46Smrg if test "$pic_object" != none; then 589942a55b46Smrg # Prepend the subdirectory the object is found in. 590042a55b46Smrg pic_object="$xdir$pic_object" 590142a55b46Smrg 590242a55b46Smrg if test "$prev" = dlfiles; then 590342a55b46Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 590442a55b46Smrg func_append dlfiles " $pic_object" 590542a55b46Smrg prev= 590642a55b46Smrg continue 590742a55b46Smrg else 590842a55b46Smrg # If libtool objects are unsupported, then we need to preload. 590942a55b46Smrg prev=dlprefiles 591042a55b46Smrg fi 591142a55b46Smrg fi 591242a55b46Smrg 591342a55b46Smrg # CHECK ME: I think I busted this. -Ossama 591442a55b46Smrg if test "$prev" = dlprefiles; then 591542a55b46Smrg # Preload the old-style object. 591642a55b46Smrg func_append dlprefiles " $pic_object" 591742a55b46Smrg prev= 591842a55b46Smrg fi 591942a55b46Smrg 592042a55b46Smrg # A PIC object. 592142a55b46Smrg func_append libobjs " $pic_object" 592242a55b46Smrg arg="$pic_object" 592342a55b46Smrg fi 592442a55b46Smrg 592542a55b46Smrg # Non-PIC object. 592642a55b46Smrg if test "$non_pic_object" != none; then 592742a55b46Smrg # Prepend the subdirectory the object is found in. 592842a55b46Smrg non_pic_object="$xdir$non_pic_object" 592942a55b46Smrg 593042a55b46Smrg # A standard non-PIC object 593142a55b46Smrg func_append non_pic_objects " $non_pic_object" 593242a55b46Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 593342a55b46Smrg arg="$non_pic_object" 593442a55b46Smrg fi 593542a55b46Smrg else 593642a55b46Smrg # If the PIC object exists, use it instead. 593742a55b46Smrg # $xdir was prepended to $pic_object above. 593842a55b46Smrg non_pic_object="$pic_object" 593942a55b46Smrg func_append non_pic_objects " $non_pic_object" 594042a55b46Smrg fi 594142a55b46Smrg else 594242a55b46Smrg # Only an error if not doing a dry-run. 594342a55b46Smrg if $opt_dry_run; then 594442a55b46Smrg # Extract subdirectory from the argument. 594542a55b46Smrg func_dirname "$arg" "/" "" 594642a55b46Smrg xdir="$func_dirname_result" 594742a55b46Smrg 594842a55b46Smrg func_lo2o "$arg" 594942a55b46Smrg pic_object=$xdir$objdir/$func_lo2o_result 595042a55b46Smrg non_pic_object=$xdir$func_lo2o_result 595142a55b46Smrg func_append libobjs " $pic_object" 595242a55b46Smrg func_append non_pic_objects " $non_pic_object" 595342a55b46Smrg else 595442a55b46Smrg func_fatal_error "\`$arg' is not a valid libtool object" 595542a55b46Smrg fi 595642a55b46Smrg fi 595742a55b46Smrg ;; 595842a55b46Smrg 595942a55b46Smrg *.$libext) 596042a55b46Smrg # An archive. 596142a55b46Smrg func_append deplibs " $arg" 596242a55b46Smrg func_append old_deplibs " $arg" 596342a55b46Smrg continue 596442a55b46Smrg ;; 596542a55b46Smrg 596642a55b46Smrg *.la) 596742a55b46Smrg # A libtool-controlled library. 596842a55b46Smrg 596942a55b46Smrg func_resolve_sysroot "$arg" 597042a55b46Smrg if test "$prev" = dlfiles; then 597142a55b46Smrg # This library was specified with -dlopen. 597242a55b46Smrg func_append dlfiles " $func_resolve_sysroot_result" 597342a55b46Smrg prev= 597442a55b46Smrg elif test "$prev" = dlprefiles; then 597542a55b46Smrg # The library was specified with -dlpreopen. 597642a55b46Smrg func_append dlprefiles " $func_resolve_sysroot_result" 597742a55b46Smrg prev= 597842a55b46Smrg else 597942a55b46Smrg func_append deplibs " $func_resolve_sysroot_result" 598042a55b46Smrg fi 598142a55b46Smrg continue 598242a55b46Smrg ;; 598342a55b46Smrg 598442a55b46Smrg # Some other compiler argument. 598542a55b46Smrg *) 598642a55b46Smrg # Unknown arguments in both finalize_command and compile_command need 598742a55b46Smrg # to be aesthetically quoted because they are evaled later. 598842a55b46Smrg func_quote_for_eval "$arg" 598942a55b46Smrg arg="$func_quote_for_eval_result" 599042a55b46Smrg ;; 599142a55b46Smrg esac # arg 599242a55b46Smrg 599342a55b46Smrg # Now actually substitute the argument into the commands. 599442a55b46Smrg if test -n "$arg"; then 599542a55b46Smrg func_append compile_command " $arg" 599642a55b46Smrg func_append finalize_command " $arg" 599742a55b46Smrg fi 599842a55b46Smrg done # argument parsing loop 599942a55b46Smrg 600042a55b46Smrg test -n "$prev" && \ 600142a55b46Smrg func_fatal_help "the \`$prevarg' option requires an argument" 600242a55b46Smrg 600342a55b46Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 600442a55b46Smrg eval arg=\"$export_dynamic_flag_spec\" 600542a55b46Smrg func_append compile_command " $arg" 600642a55b46Smrg func_append finalize_command " $arg" 600742a55b46Smrg fi 600842a55b46Smrg 600942a55b46Smrg oldlibs= 601042a55b46Smrg # calculate the name of the file, without its directory 601142a55b46Smrg func_basename "$output" 601242a55b46Smrg outputname="$func_basename_result" 601342a55b46Smrg libobjs_save="$libobjs" 601442a55b46Smrg 601542a55b46Smrg if test -n "$shlibpath_var"; then 601642a55b46Smrg # get the directories listed in $shlibpath_var 601742a55b46Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 601842a55b46Smrg else 601942a55b46Smrg shlib_search_path= 602042a55b46Smrg fi 602142a55b46Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 602242a55b46Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 602342a55b46Smrg 602442a55b46Smrg func_dirname "$output" "/" "" 602542a55b46Smrg output_objdir="$func_dirname_result$objdir" 602642a55b46Smrg func_to_tool_file "$output_objdir/" 602742a55b46Smrg tool_output_objdir=$func_to_tool_file_result 602842a55b46Smrg # Create the object directory. 602942a55b46Smrg func_mkdir_p "$output_objdir" 603042a55b46Smrg 603142a55b46Smrg # Determine the type of output 603242a55b46Smrg case $output in 603342a55b46Smrg "") 603442a55b46Smrg func_fatal_help "you must specify an output file" 603542a55b46Smrg ;; 603642a55b46Smrg *.$libext) linkmode=oldlib ;; 603742a55b46Smrg *.lo | *.$objext) linkmode=obj ;; 603842a55b46Smrg *.la) linkmode=lib ;; 603942a55b46Smrg *) linkmode=prog ;; # Anything else should be a program. 604042a55b46Smrg esac 604142a55b46Smrg 604242a55b46Smrg specialdeplibs= 604342a55b46Smrg 604442a55b46Smrg libs= 604542a55b46Smrg # Find all interdependent deplibs by searching for libraries 604642a55b46Smrg # that are linked more than once (e.g. -la -lb -la) 604742a55b46Smrg for deplib in $deplibs; do 604842a55b46Smrg if $opt_preserve_dup_deps ; then 604942a55b46Smrg case "$libs " in 605042a55b46Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 605142a55b46Smrg esac 605242a55b46Smrg fi 605342a55b46Smrg func_append libs " $deplib" 605442a55b46Smrg done 605542a55b46Smrg 605642a55b46Smrg if test "$linkmode" = lib; then 605742a55b46Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 605842a55b46Smrg 605942a55b46Smrg # Compute libraries that are listed more than once in $predeps 606042a55b46Smrg # $postdeps and mark them as special (i.e., whose duplicates are 606142a55b46Smrg # not to be eliminated). 606242a55b46Smrg pre_post_deps= 606342a55b46Smrg if $opt_duplicate_compiler_generated_deps; then 606442a55b46Smrg for pre_post_dep in $predeps $postdeps; do 606542a55b46Smrg case "$pre_post_deps " in 606642a55b46Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 606742a55b46Smrg esac 606842a55b46Smrg func_append pre_post_deps " $pre_post_dep" 606942a55b46Smrg done 607042a55b46Smrg fi 607142a55b46Smrg pre_post_deps= 607242a55b46Smrg fi 607342a55b46Smrg 607442a55b46Smrg deplibs= 607542a55b46Smrg newdependency_libs= 607642a55b46Smrg newlib_search_path= 607742a55b46Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 607842a55b46Smrg notinst_deplibs= # not-installed libtool libraries 607942a55b46Smrg notinst_path= # paths that contain not-installed libtool libraries 608042a55b46Smrg 608142a55b46Smrg case $linkmode in 608242a55b46Smrg lib) 608342a55b46Smrg passes="conv dlpreopen link" 608442a55b46Smrg for file in $dlfiles $dlprefiles; do 608542a55b46Smrg case $file in 608642a55b46Smrg *.la) ;; 608742a55b46Smrg *) 608842a55b46Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 608942a55b46Smrg ;; 609042a55b46Smrg esac 609142a55b46Smrg done 609242a55b46Smrg ;; 609342a55b46Smrg prog) 609442a55b46Smrg compile_deplibs= 609542a55b46Smrg finalize_deplibs= 609642a55b46Smrg alldeplibs=no 609742a55b46Smrg newdlfiles= 609842a55b46Smrg newdlprefiles= 609942a55b46Smrg passes="conv scan dlopen dlpreopen link" 610042a55b46Smrg ;; 610142a55b46Smrg *) passes="conv" 610242a55b46Smrg ;; 610342a55b46Smrg esac 610442a55b46Smrg 610542a55b46Smrg for pass in $passes; do 610642a55b46Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 610742a55b46Smrg # so that -L comes before libs that need it for instance... 610842a55b46Smrg if test "$linkmode,$pass" = "lib,link"; then 610942a55b46Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 611042a55b46Smrg ## order, and fix it there properly 611142a55b46Smrg tmp_deplibs= 611242a55b46Smrg for deplib in $deplibs; do 611342a55b46Smrg tmp_deplibs="$deplib $tmp_deplibs" 611442a55b46Smrg done 611542a55b46Smrg deplibs="$tmp_deplibs" 611642a55b46Smrg fi 611742a55b46Smrg 611842a55b46Smrg if test "$linkmode,$pass" = "lib,link" || 611942a55b46Smrg test "$linkmode,$pass" = "prog,scan"; then 612042a55b46Smrg libs="$deplibs" 612142a55b46Smrg deplibs= 612242a55b46Smrg fi 612342a55b46Smrg if test "$linkmode" = prog; then 612442a55b46Smrg case $pass in 612542a55b46Smrg dlopen) libs="$dlfiles" ;; 612642a55b46Smrg dlpreopen) libs="$dlprefiles" ;; 612742a55b46Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 612842a55b46Smrg esac 612942a55b46Smrg fi 613042a55b46Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 613142a55b46Smrg # Collect and forward deplibs of preopened libtool libs 613242a55b46Smrg for lib in $dlprefiles; do 613342a55b46Smrg # Ignore non-libtool-libs 613442a55b46Smrg dependency_libs= 613542a55b46Smrg func_resolve_sysroot "$lib" 613642a55b46Smrg case $lib in 613742a55b46Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 613842a55b46Smrg esac 613942a55b46Smrg 614042a55b46Smrg # Collect preopened libtool deplibs, except any this library 614142a55b46Smrg # has declared as weak libs 614242a55b46Smrg for deplib in $dependency_libs; do 614342a55b46Smrg func_basename "$deplib" 614442a55b46Smrg deplib_base=$func_basename_result 614542a55b46Smrg case " $weak_libs " in 614642a55b46Smrg *" $deplib_base "*) ;; 614742a55b46Smrg *) func_append deplibs " $deplib" ;; 614842a55b46Smrg esac 614942a55b46Smrg done 615042a55b46Smrg done 615142a55b46Smrg libs="$dlprefiles" 615242a55b46Smrg fi 615342a55b46Smrg if test "$pass" = dlopen; then 615442a55b46Smrg # Collect dlpreopened libraries 615542a55b46Smrg save_deplibs="$deplibs" 615642a55b46Smrg deplibs= 615742a55b46Smrg fi 615842a55b46Smrg 615942a55b46Smrg for deplib in $libs; do 616042a55b46Smrg lib= 616142a55b46Smrg found=no 616242a55b46Smrg case $deplib in 616342a55b46Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 616442a55b46Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 616542a55b46Smrg if test "$linkmode,$pass" = "prog,link"; then 616642a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 616742a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 616842a55b46Smrg else 616942a55b46Smrg func_append compiler_flags " $deplib" 617042a55b46Smrg if test "$linkmode" = lib ; then 617142a55b46Smrg case "$new_inherited_linker_flags " in 617242a55b46Smrg *" $deplib "*) ;; 617342a55b46Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 617442a55b46Smrg esac 617542a55b46Smrg fi 617642a55b46Smrg fi 617742a55b46Smrg continue 617842a55b46Smrg ;; 617942a55b46Smrg -l*) 618042a55b46Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 618142a55b46Smrg func_warning "\`-l' is ignored for archives/objects" 618242a55b46Smrg continue 618342a55b46Smrg fi 618442a55b46Smrg func_stripname '-l' '' "$deplib" 618542a55b46Smrg name=$func_stripname_result 618642a55b46Smrg if test "$linkmode" = lib; then 618742a55b46Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 618842a55b46Smrg else 618942a55b46Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 619042a55b46Smrg fi 619142a55b46Smrg for searchdir in $searchdirs; do 619242a55b46Smrg for search_ext in .la $std_shrext .so .a; do 619342a55b46Smrg # Search the libtool library 619442a55b46Smrg lib="$searchdir/lib${name}${search_ext}" 619542a55b46Smrg if test -f "$lib"; then 619642a55b46Smrg if test "$search_ext" = ".la"; then 619742a55b46Smrg found=yes 619842a55b46Smrg else 619942a55b46Smrg found=no 620042a55b46Smrg fi 620142a55b46Smrg break 2 620242a55b46Smrg fi 620342a55b46Smrg done 620442a55b46Smrg done 620542a55b46Smrg if test "$found" != yes; then 620642a55b46Smrg # deplib doesn't seem to be a libtool library 620742a55b46Smrg if test "$linkmode,$pass" = "prog,link"; then 620842a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 620942a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 621042a55b46Smrg else 621142a55b46Smrg deplibs="$deplib $deplibs" 621242a55b46Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 621342a55b46Smrg fi 621442a55b46Smrg continue 621542a55b46Smrg else # deplib is a libtool library 621642a55b46Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 621742a55b46Smrg # We need to do some special things here, and not later. 621842a55b46Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 621942a55b46Smrg case " $predeps $postdeps " in 622042a55b46Smrg *" $deplib "*) 622142a55b46Smrg if func_lalib_p "$lib"; then 622242a55b46Smrg library_names= 622342a55b46Smrg old_library= 622442a55b46Smrg func_source "$lib" 622542a55b46Smrg for l in $old_library $library_names; do 622642a55b46Smrg ll="$l" 622742a55b46Smrg done 622842a55b46Smrg if test "X$ll" = "X$old_library" ; then # only static version available 622942a55b46Smrg found=no 623042a55b46Smrg func_dirname "$lib" "" "." 623142a55b46Smrg ladir="$func_dirname_result" 623242a55b46Smrg lib=$ladir/$old_library 623342a55b46Smrg if test "$linkmode,$pass" = "prog,link"; then 623442a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 623542a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 623642a55b46Smrg else 623742a55b46Smrg deplibs="$deplib $deplibs" 623842a55b46Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 623942a55b46Smrg fi 624042a55b46Smrg continue 624142a55b46Smrg fi 624242a55b46Smrg fi 624342a55b46Smrg ;; 624442a55b46Smrg *) ;; 624542a55b46Smrg esac 624642a55b46Smrg fi 624742a55b46Smrg fi 624842a55b46Smrg ;; # -l 624942a55b46Smrg *.ltframework) 625042a55b46Smrg if test "$linkmode,$pass" = "prog,link"; then 625142a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 625242a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 625342a55b46Smrg else 625442a55b46Smrg deplibs="$deplib $deplibs" 625542a55b46Smrg if test "$linkmode" = lib ; then 625642a55b46Smrg case "$new_inherited_linker_flags " in 625742a55b46Smrg *" $deplib "*) ;; 625842a55b46Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 625942a55b46Smrg esac 626042a55b46Smrg fi 626142a55b46Smrg fi 626242a55b46Smrg continue 626342a55b46Smrg ;; 626442a55b46Smrg -L*) 626542a55b46Smrg case $linkmode in 626642a55b46Smrg lib) 626742a55b46Smrg deplibs="$deplib $deplibs" 626842a55b46Smrg test "$pass" = conv && continue 626942a55b46Smrg newdependency_libs="$deplib $newdependency_libs" 627042a55b46Smrg func_stripname '-L' '' "$deplib" 627142a55b46Smrg func_resolve_sysroot "$func_stripname_result" 627242a55b46Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 627342a55b46Smrg ;; 627442a55b46Smrg prog) 627542a55b46Smrg if test "$pass" = conv; then 627642a55b46Smrg deplibs="$deplib $deplibs" 627742a55b46Smrg continue 627842a55b46Smrg fi 627942a55b46Smrg if test "$pass" = scan; then 628042a55b46Smrg deplibs="$deplib $deplibs" 628142a55b46Smrg else 628242a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 628342a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 628442a55b46Smrg fi 628542a55b46Smrg func_stripname '-L' '' "$deplib" 628642a55b46Smrg func_resolve_sysroot "$func_stripname_result" 628742a55b46Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 628842a55b46Smrg ;; 628942a55b46Smrg *) 629042a55b46Smrg func_warning "\`-L' is ignored for archives/objects" 629142a55b46Smrg ;; 629242a55b46Smrg esac # linkmode 629342a55b46Smrg continue 629442a55b46Smrg ;; # -L 629542a55b46Smrg -R*) 629642a55b46Smrg if test "$pass" = link; then 629742a55b46Smrg func_stripname '-R' '' "$deplib" 629842a55b46Smrg func_resolve_sysroot "$func_stripname_result" 629942a55b46Smrg dir=$func_resolve_sysroot_result 630042a55b46Smrg # Make sure the xrpath contains only unique directories. 630142a55b46Smrg case "$xrpath " in 630242a55b46Smrg *" $dir "*) ;; 630342a55b46Smrg *) func_append xrpath " $dir" ;; 630442a55b46Smrg esac 630542a55b46Smrg fi 630642a55b46Smrg deplibs="$deplib $deplibs" 630742a55b46Smrg continue 630842a55b46Smrg ;; 630942a55b46Smrg *.la) 631042a55b46Smrg func_resolve_sysroot "$deplib" 631142a55b46Smrg lib=$func_resolve_sysroot_result 631242a55b46Smrg ;; 631342a55b46Smrg *.$libext) 631442a55b46Smrg if test "$pass" = conv; then 631542a55b46Smrg deplibs="$deplib $deplibs" 631642a55b46Smrg continue 631742a55b46Smrg fi 631842a55b46Smrg case $linkmode in 631942a55b46Smrg lib) 632042a55b46Smrg # Linking convenience modules into shared libraries is allowed, 632142a55b46Smrg # but linking other static libraries is non-portable. 632242a55b46Smrg case " $dlpreconveniencelibs " in 632342a55b46Smrg *" $deplib "*) ;; 632442a55b46Smrg *) 632542a55b46Smrg valid_a_lib=no 632642a55b46Smrg case $deplibs_check_method in 632742a55b46Smrg match_pattern*) 632842a55b46Smrg set dummy $deplibs_check_method; shift 632942a55b46Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 633042a55b46Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 633142a55b46Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 633242a55b46Smrg valid_a_lib=yes 633342a55b46Smrg fi 633442a55b46Smrg ;; 633542a55b46Smrg pass_all) 633642a55b46Smrg valid_a_lib=yes 633742a55b46Smrg ;; 633842a55b46Smrg esac 633942a55b46Smrg if test "$valid_a_lib" != yes; then 634042a55b46Smrg echo 634142a55b46Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 634242a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 634342a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 634442a55b46Smrg echo "*** shared version of the library, which you do not appear to have" 634542a55b46Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 634642a55b46Smrg echo "*** that it is just a static archive that I should not use here." 634742a55b46Smrg else 634842a55b46Smrg echo 634942a55b46Smrg $ECHO "*** Warning: Linking the shared library $output against the" 635042a55b46Smrg $ECHO "*** static library $deplib is not portable!" 635142a55b46Smrg deplibs="$deplib $deplibs" 635242a55b46Smrg fi 635342a55b46Smrg ;; 635442a55b46Smrg esac 635542a55b46Smrg continue 635642a55b46Smrg ;; 635742a55b46Smrg prog) 635842a55b46Smrg if test "$pass" != link; then 635942a55b46Smrg deplibs="$deplib $deplibs" 636042a55b46Smrg else 636142a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 636242a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 636342a55b46Smrg fi 636442a55b46Smrg continue 636542a55b46Smrg ;; 636642a55b46Smrg esac # linkmode 636742a55b46Smrg ;; # *.$libext 636842a55b46Smrg *.lo | *.$objext) 636942a55b46Smrg if test "$pass" = conv; then 637042a55b46Smrg deplibs="$deplib $deplibs" 637142a55b46Smrg elif test "$linkmode" = prog; then 637242a55b46Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 637342a55b46Smrg # If there is no dlopen support or we're linking statically, 637442a55b46Smrg # we need to preload. 637542a55b46Smrg func_append newdlprefiles " $deplib" 637642a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 637742a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 637842a55b46Smrg else 637942a55b46Smrg func_append newdlfiles " $deplib" 638042a55b46Smrg fi 638142a55b46Smrg fi 638242a55b46Smrg continue 638342a55b46Smrg ;; 638442a55b46Smrg %DEPLIBS%) 638542a55b46Smrg alldeplibs=yes 638642a55b46Smrg continue 638742a55b46Smrg ;; 638842a55b46Smrg esac # case $deplib 638942a55b46Smrg 639042a55b46Smrg if test "$found" = yes || test -f "$lib"; then : 639142a55b46Smrg else 639242a55b46Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 639342a55b46Smrg fi 639442a55b46Smrg 639542a55b46Smrg # Check to see that this really is a libtool archive. 639642a55b46Smrg func_lalib_unsafe_p "$lib" \ 639742a55b46Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 639842a55b46Smrg 639942a55b46Smrg func_dirname "$lib" "" "." 640042a55b46Smrg ladir="$func_dirname_result" 640142a55b46Smrg 640242a55b46Smrg dlname= 640342a55b46Smrg dlopen= 640442a55b46Smrg dlpreopen= 640542a55b46Smrg libdir= 640642a55b46Smrg library_names= 640742a55b46Smrg old_library= 640842a55b46Smrg inherited_linker_flags= 640942a55b46Smrg # If the library was installed with an old release of libtool, 641042a55b46Smrg # it will not redefine variables installed, or shouldnotlink 641142a55b46Smrg installed=yes 641242a55b46Smrg shouldnotlink=no 641342a55b46Smrg avoidtemprpath= 641442a55b46Smrg 641542a55b46Smrg 641642a55b46Smrg # Read the .la file 641742a55b46Smrg func_source "$lib" 641842a55b46Smrg 641942a55b46Smrg # Convert "-framework foo" to "foo.ltframework" 642042a55b46Smrg if test -n "$inherited_linker_flags"; then 642142a55b46Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 642242a55b46Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 642342a55b46Smrg case " $new_inherited_linker_flags " in 642442a55b46Smrg *" $tmp_inherited_linker_flag "*) ;; 642542a55b46Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 642642a55b46Smrg esac 642742a55b46Smrg done 642842a55b46Smrg fi 642942a55b46Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 643042a55b46Smrg if test "$linkmode,$pass" = "lib,link" || 643142a55b46Smrg test "$linkmode,$pass" = "prog,scan" || 643242a55b46Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 643342a55b46Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 643442a55b46Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 643542a55b46Smrg fi 643642a55b46Smrg 643742a55b46Smrg if test "$pass" = conv; then 643842a55b46Smrg # Only check for convenience libraries 643942a55b46Smrg deplibs="$lib $deplibs" 644042a55b46Smrg if test -z "$libdir"; then 644142a55b46Smrg if test -z "$old_library"; then 644242a55b46Smrg func_fatal_error "cannot find name of link library for \`$lib'" 644342a55b46Smrg fi 644442a55b46Smrg # It is a libtool convenience library, so add in its objects. 644542a55b46Smrg func_append convenience " $ladir/$objdir/$old_library" 644642a55b46Smrg func_append old_convenience " $ladir/$objdir/$old_library" 644742a55b46Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 644842a55b46Smrg func_fatal_error "\`$lib' is not a convenience library" 644942a55b46Smrg fi 645042a55b46Smrg tmp_libs= 645142a55b46Smrg for deplib in $dependency_libs; do 645242a55b46Smrg deplibs="$deplib $deplibs" 645342a55b46Smrg if $opt_preserve_dup_deps ; then 645442a55b46Smrg case "$tmp_libs " in 645542a55b46Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 645642a55b46Smrg esac 645742a55b46Smrg fi 645842a55b46Smrg func_append tmp_libs " $deplib" 645942a55b46Smrg done 646042a55b46Smrg continue 646142a55b46Smrg fi # $pass = conv 646242a55b46Smrg 646342a55b46Smrg 646442a55b46Smrg # Get the name of the library we link against. 646542a55b46Smrg linklib= 646642a55b46Smrg if test -n "$old_library" && 646742a55b46Smrg { test "$prefer_static_libs" = yes || 646842a55b46Smrg test "$prefer_static_libs,$installed" = "built,no"; }; then 646942a55b46Smrg linklib=$old_library 647042a55b46Smrg else 647142a55b46Smrg for l in $old_library $library_names; do 647242a55b46Smrg linklib="$l" 647342a55b46Smrg done 647442a55b46Smrg fi 647542a55b46Smrg if test -z "$linklib"; then 647642a55b46Smrg func_fatal_error "cannot find name of link library for \`$lib'" 647742a55b46Smrg fi 647842a55b46Smrg 647942a55b46Smrg # This library was specified with -dlopen. 648042a55b46Smrg if test "$pass" = dlopen; then 648142a55b46Smrg if test -z "$libdir"; then 648242a55b46Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 648342a55b46Smrg fi 648442a55b46Smrg if test -z "$dlname" || 648542a55b46Smrg test "$dlopen_support" != yes || 648642a55b46Smrg test "$build_libtool_libs" = no; then 648742a55b46Smrg # If there is no dlname, no dlopen support or we're linking 648842a55b46Smrg # statically, we need to preload. We also need to preload any 648942a55b46Smrg # dependent libraries so libltdl's deplib preloader doesn't 649042a55b46Smrg # bomb out in the load deplibs phase. 649142a55b46Smrg func_append dlprefiles " $lib $dependency_libs" 649242a55b46Smrg else 649342a55b46Smrg func_append newdlfiles " $lib" 649442a55b46Smrg fi 649542a55b46Smrg continue 649642a55b46Smrg fi # $pass = dlopen 649742a55b46Smrg 649842a55b46Smrg # We need an absolute path. 649942a55b46Smrg case $ladir in 650042a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 650142a55b46Smrg *) 650242a55b46Smrg abs_ladir=`cd "$ladir" && pwd` 650342a55b46Smrg if test -z "$abs_ladir"; then 650442a55b46Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 650542a55b46Smrg func_warning "passing it literally to the linker, although it might fail" 650642a55b46Smrg abs_ladir="$ladir" 650742a55b46Smrg fi 650842a55b46Smrg ;; 650942a55b46Smrg esac 651042a55b46Smrg func_basename "$lib" 651142a55b46Smrg laname="$func_basename_result" 651242a55b46Smrg 651342a55b46Smrg # Find the relevant object directory and library name. 651442a55b46Smrg if test "X$installed" = Xyes; then 651542a55b46Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 651642a55b46Smrg func_warning "library \`$lib' was moved." 651742a55b46Smrg dir="$ladir" 651842a55b46Smrg absdir="$abs_ladir" 651942a55b46Smrg libdir="$abs_ladir" 652042a55b46Smrg else 652142a55b46Smrg dir="$lt_sysroot$libdir" 652242a55b46Smrg absdir="$lt_sysroot$libdir" 652342a55b46Smrg fi 652442a55b46Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 652542a55b46Smrg else 652642a55b46Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 652742a55b46Smrg dir="$ladir" 652842a55b46Smrg absdir="$abs_ladir" 652942a55b46Smrg # Remove this search path later 653042a55b46Smrg func_append notinst_path " $abs_ladir" 653142a55b46Smrg else 653242a55b46Smrg dir="$ladir/$objdir" 653342a55b46Smrg absdir="$abs_ladir/$objdir" 653442a55b46Smrg # Remove this search path later 653542a55b46Smrg func_append notinst_path " $abs_ladir" 653642a55b46Smrg fi 653742a55b46Smrg fi # $installed = yes 653842a55b46Smrg func_stripname 'lib' '.la' "$laname" 653942a55b46Smrg name=$func_stripname_result 654042a55b46Smrg 654142a55b46Smrg # This library was specified with -dlpreopen. 654242a55b46Smrg if test "$pass" = dlpreopen; then 654342a55b46Smrg if test -z "$libdir" && test "$linkmode" = prog; then 654442a55b46Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 654542a55b46Smrg fi 654642a55b46Smrg case "$host" in 654742a55b46Smrg # special handling for platforms with PE-DLLs. 654842a55b46Smrg *cygwin* | *mingw* | *cegcc* ) 654942a55b46Smrg # Linker will automatically link against shared library if both 655042a55b46Smrg # static and shared are present. Therefore, ensure we extract 655142a55b46Smrg # symbols from the import library if a shared library is present 655242a55b46Smrg # (otherwise, the dlopen module name will be incorrect). We do 655342a55b46Smrg # this by putting the import library name into $newdlprefiles. 655442a55b46Smrg # We recover the dlopen module name by 'saving' the la file 655542a55b46Smrg # name in a special purpose variable, and (later) extracting the 655642a55b46Smrg # dlname from the la file. 655742a55b46Smrg if test -n "$dlname"; then 655842a55b46Smrg func_tr_sh "$dir/$linklib" 655942a55b46Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 656042a55b46Smrg func_append newdlprefiles " $dir/$linklib" 656142a55b46Smrg else 656242a55b46Smrg func_append newdlprefiles " $dir/$old_library" 656342a55b46Smrg # Keep a list of preopened convenience libraries to check 656442a55b46Smrg # that they are being used correctly in the link pass. 656542a55b46Smrg test -z "$libdir" && \ 656642a55b46Smrg func_append dlpreconveniencelibs " $dir/$old_library" 656742a55b46Smrg fi 656842a55b46Smrg ;; 656942a55b46Smrg * ) 657042a55b46Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 657142a55b46Smrg # are required to link). 657242a55b46Smrg if test -n "$old_library"; then 657342a55b46Smrg func_append newdlprefiles " $dir/$old_library" 657442a55b46Smrg # Keep a list of preopened convenience libraries to check 657542a55b46Smrg # that they are being used correctly in the link pass. 657642a55b46Smrg test -z "$libdir" && \ 657742a55b46Smrg func_append dlpreconveniencelibs " $dir/$old_library" 657842a55b46Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 657942a55b46Smrg elif test -n "$dlname"; then 658042a55b46Smrg func_append newdlprefiles " $dir/$dlname" 658142a55b46Smrg else 658242a55b46Smrg func_append newdlprefiles " $dir/$linklib" 658342a55b46Smrg fi 658442a55b46Smrg ;; 658542a55b46Smrg esac 658642a55b46Smrg fi # $pass = dlpreopen 658742a55b46Smrg 658842a55b46Smrg if test -z "$libdir"; then 658942a55b46Smrg # Link the convenience library 659042a55b46Smrg if test "$linkmode" = lib; then 659142a55b46Smrg deplibs="$dir/$old_library $deplibs" 659242a55b46Smrg elif test "$linkmode,$pass" = "prog,link"; then 659342a55b46Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 659442a55b46Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 659542a55b46Smrg else 659642a55b46Smrg deplibs="$lib $deplibs" # used for prog,scan pass 659742a55b46Smrg fi 659842a55b46Smrg continue 659942a55b46Smrg fi 660042a55b46Smrg 660142a55b46Smrg 660242a55b46Smrg if test "$linkmode" = prog && test "$pass" != link; then 660342a55b46Smrg func_append newlib_search_path " $ladir" 660442a55b46Smrg deplibs="$lib $deplibs" 660542a55b46Smrg 660642a55b46Smrg linkalldeplibs=no 660742a55b46Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 660842a55b46Smrg test "$build_libtool_libs" = no; then 660942a55b46Smrg linkalldeplibs=yes 661042a55b46Smrg fi 661142a55b46Smrg 661242a55b46Smrg tmp_libs= 661342a55b46Smrg for deplib in $dependency_libs; do 661442a55b46Smrg case $deplib in 661542a55b46Smrg -L*) func_stripname '-L' '' "$deplib" 661642a55b46Smrg func_resolve_sysroot "$func_stripname_result" 661742a55b46Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 661842a55b46Smrg ;; 661942a55b46Smrg esac 662042a55b46Smrg # Need to link against all dependency_libs? 662142a55b46Smrg if test "$linkalldeplibs" = yes; then 662242a55b46Smrg deplibs="$deplib $deplibs" 662342a55b46Smrg else 662442a55b46Smrg # Need to hardcode shared library paths 662542a55b46Smrg # or/and link against static libraries 662642a55b46Smrg newdependency_libs="$deplib $newdependency_libs" 662742a55b46Smrg fi 662842a55b46Smrg if $opt_preserve_dup_deps ; then 662942a55b46Smrg case "$tmp_libs " in 663042a55b46Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 663142a55b46Smrg esac 663242a55b46Smrg fi 663342a55b46Smrg func_append tmp_libs " $deplib" 663442a55b46Smrg done # for deplib 663542a55b46Smrg continue 663642a55b46Smrg fi # $linkmode = prog... 663742a55b46Smrg 663842a55b46Smrg if test "$linkmode,$pass" = "prog,link"; then 663942a55b46Smrg if test -n "$library_names" && 664042a55b46Smrg { { test "$prefer_static_libs" = no || 664142a55b46Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 664242a55b46Smrg test -z "$old_library"; }; then 664342a55b46Smrg # We need to hardcode the library path 664442a55b46Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 664542a55b46Smrg # Make sure the rpath contains only unique directories. 664642a55b46Smrg case "$temp_rpath:" in 664742a55b46Smrg *"$absdir:"*) ;; 664842a55b46Smrg *) func_append temp_rpath "$absdir:" ;; 664942a55b46Smrg esac 665042a55b46Smrg fi 665142a55b46Smrg 665242a55b46Smrg # Hardcode the library path. 665342a55b46Smrg # Skip directories that are in the system default run-time 665442a55b46Smrg # search path. 665542a55b46Smrg case " $sys_lib_dlsearch_path " in 665642a55b46Smrg *" $absdir "*) ;; 665742a55b46Smrg *) 665842a55b46Smrg case "$compile_rpath " in 665942a55b46Smrg *" $absdir "*) ;; 666042a55b46Smrg *) func_append compile_rpath " $absdir" ;; 666142a55b46Smrg esac 666242a55b46Smrg ;; 666342a55b46Smrg esac 666442a55b46Smrg case " $sys_lib_dlsearch_path " in 666542a55b46Smrg *" $libdir "*) ;; 666642a55b46Smrg *) 666742a55b46Smrg case "$finalize_rpath " in 666842a55b46Smrg *" $libdir "*) ;; 666942a55b46Smrg *) func_append finalize_rpath " $libdir" ;; 667042a55b46Smrg esac 667142a55b46Smrg ;; 667242a55b46Smrg esac 667342a55b46Smrg fi # $linkmode,$pass = prog,link... 667442a55b46Smrg 667542a55b46Smrg if test "$alldeplibs" = yes && 667642a55b46Smrg { test "$deplibs_check_method" = pass_all || 667742a55b46Smrg { test "$build_libtool_libs" = yes && 667842a55b46Smrg test -n "$library_names"; }; }; then 667942a55b46Smrg # We only need to search for static libraries 668042a55b46Smrg continue 668142a55b46Smrg fi 668242a55b46Smrg fi 668342a55b46Smrg 668442a55b46Smrg link_static=no # Whether the deplib will be linked statically 668542a55b46Smrg use_static_libs=$prefer_static_libs 668642a55b46Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 668742a55b46Smrg use_static_libs=no 668842a55b46Smrg fi 668942a55b46Smrg if test -n "$library_names" && 669042a55b46Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 669142a55b46Smrg case $host in 669242a55b46Smrg *cygwin* | *mingw* | *cegcc*) 669342a55b46Smrg # No point in relinking DLLs because paths are not encoded 669442a55b46Smrg func_append notinst_deplibs " $lib" 669542a55b46Smrg need_relink=no 669642a55b46Smrg ;; 669742a55b46Smrg *) 669842a55b46Smrg if test "$installed" = no; then 669942a55b46Smrg func_append notinst_deplibs " $lib" 670042a55b46Smrg need_relink=yes 670142a55b46Smrg fi 670242a55b46Smrg ;; 670342a55b46Smrg esac 670442a55b46Smrg # This is a shared library 670542a55b46Smrg 670642a55b46Smrg # Warn about portability, can't link against -module's on some 670742a55b46Smrg # systems (darwin). Don't bleat about dlopened modules though! 670842a55b46Smrg dlopenmodule="" 670942a55b46Smrg for dlpremoduletest in $dlprefiles; do 671042a55b46Smrg if test "X$dlpremoduletest" = "X$lib"; then 671142a55b46Smrg dlopenmodule="$dlpremoduletest" 671242a55b46Smrg break 671342a55b46Smrg fi 671442a55b46Smrg done 671542a55b46Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 671642a55b46Smrg echo 671742a55b46Smrg if test "$linkmode" = prog; then 671842a55b46Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 671942a55b46Smrg else 672042a55b46Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 672142a55b46Smrg fi 672242a55b46Smrg $ECHO "*** $linklib is not portable!" 672342a55b46Smrg fi 672442a55b46Smrg if test "$linkmode" = lib && 672542a55b46Smrg test "$hardcode_into_libs" = yes; then 672642a55b46Smrg # Hardcode the library path. 672742a55b46Smrg # Skip directories that are in the system default run-time 672842a55b46Smrg # search path. 672942a55b46Smrg case " $sys_lib_dlsearch_path " in 673042a55b46Smrg *" $absdir "*) ;; 673142a55b46Smrg *) 673242a55b46Smrg case "$compile_rpath " in 673342a55b46Smrg *" $absdir "*) ;; 673442a55b46Smrg *) func_append compile_rpath " $absdir" ;; 673542a55b46Smrg esac 673642a55b46Smrg ;; 673742a55b46Smrg esac 673842a55b46Smrg case " $sys_lib_dlsearch_path " in 673942a55b46Smrg *" $libdir "*) ;; 674042a55b46Smrg *) 674142a55b46Smrg case "$finalize_rpath " in 674242a55b46Smrg *" $libdir "*) ;; 674342a55b46Smrg *) func_append finalize_rpath " $libdir" ;; 674442a55b46Smrg esac 674542a55b46Smrg ;; 674642a55b46Smrg esac 674742a55b46Smrg fi 674842a55b46Smrg 674942a55b46Smrg if test -n "$old_archive_from_expsyms_cmds"; then 675042a55b46Smrg # figure out the soname 675142a55b46Smrg set dummy $library_names 675242a55b46Smrg shift 675342a55b46Smrg realname="$1" 675442a55b46Smrg shift 675542a55b46Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 675642a55b46Smrg # use dlname if we got it. it's perfectly good, no? 675742a55b46Smrg if test -n "$dlname"; then 675842a55b46Smrg soname="$dlname" 675942a55b46Smrg elif test -n "$soname_spec"; then 676042a55b46Smrg # bleh windows 676142a55b46Smrg case $host in 676242a55b46Smrg *cygwin* | mingw* | *cegcc*) 676342a55b46Smrg func_arith $current - $age 676442a55b46Smrg major=$func_arith_result 676542a55b46Smrg versuffix="-$major" 676642a55b46Smrg ;; 676742a55b46Smrg esac 676842a55b46Smrg eval soname=\"$soname_spec\" 676942a55b46Smrg else 677042a55b46Smrg soname="$realname" 677142a55b46Smrg fi 677242a55b46Smrg 677342a55b46Smrg # Make a new name for the extract_expsyms_cmds to use 677442a55b46Smrg soroot="$soname" 677542a55b46Smrg func_basename "$soroot" 677642a55b46Smrg soname="$func_basename_result" 677742a55b46Smrg func_stripname 'lib' '.dll' "$soname" 677842a55b46Smrg newlib=libimp-$func_stripname_result.a 677942a55b46Smrg 678042a55b46Smrg # If the library has no export list, then create one now 678142a55b46Smrg if test -f "$output_objdir/$soname-def"; then : 678242a55b46Smrg else 678342a55b46Smrg func_verbose "extracting exported symbol list from \`$soname'" 678442a55b46Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 678542a55b46Smrg fi 678642a55b46Smrg 678742a55b46Smrg # Create $newlib 678842a55b46Smrg if test -f "$output_objdir/$newlib"; then :; else 678942a55b46Smrg func_verbose "generating import library for \`$soname'" 679042a55b46Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 679142a55b46Smrg fi 679242a55b46Smrg # make sure the library variables are pointing to the new library 679342a55b46Smrg dir=$output_objdir 679442a55b46Smrg linklib=$newlib 679542a55b46Smrg fi # test -n "$old_archive_from_expsyms_cmds" 679642a55b46Smrg 679742a55b46Smrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 679842a55b46Smrg add_shlibpath= 679942a55b46Smrg add_dir= 680042a55b46Smrg add= 680142a55b46Smrg lib_linked=yes 680242a55b46Smrg case $hardcode_action in 680342a55b46Smrg immediate | unsupported) 680442a55b46Smrg if test "$hardcode_direct" = no; then 680542a55b46Smrg add="$dir/$linklib" 680642a55b46Smrg case $host in 680742a55b46Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 680842a55b46Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 680942a55b46Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 681042a55b46Smrg *-*-unixware7*) add_dir="-L$dir" ;; 681142a55b46Smrg *-*-darwin* ) 681242a55b46Smrg # if the lib is a (non-dlopened) module then we can not 681342a55b46Smrg # link against it, someone is ignoring the earlier warnings 681442a55b46Smrg if /usr/bin/file -L $add 2> /dev/null | 681542a55b46Smrg $GREP ": [^:]* bundle" >/dev/null ; then 681642a55b46Smrg if test "X$dlopenmodule" != "X$lib"; then 681742a55b46Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 681842a55b46Smrg if test -z "$old_library" ; then 681942a55b46Smrg echo 682042a55b46Smrg echo "*** And there doesn't seem to be a static archive available" 682142a55b46Smrg echo "*** The link will probably fail, sorry" 682242a55b46Smrg else 682342a55b46Smrg add="$dir/$old_library" 682442a55b46Smrg fi 682542a55b46Smrg elif test -n "$old_library"; then 682642a55b46Smrg add="$dir/$old_library" 682742a55b46Smrg fi 682842a55b46Smrg fi 682942a55b46Smrg esac 683042a55b46Smrg elif test "$hardcode_minus_L" = no; then 683142a55b46Smrg case $host in 683242a55b46Smrg *-*-sunos*) add_shlibpath="$dir" ;; 683342a55b46Smrg esac 683442a55b46Smrg add_dir="-L$dir" 683542a55b46Smrg add="-l$name" 683642a55b46Smrg elif test "$hardcode_shlibpath_var" = no; then 683742a55b46Smrg add_shlibpath="$dir" 683842a55b46Smrg add="-l$name" 683942a55b46Smrg else 684042a55b46Smrg lib_linked=no 684142a55b46Smrg fi 684242a55b46Smrg ;; 684342a55b46Smrg relink) 684442a55b46Smrg if test "$hardcode_direct" = yes && 684542a55b46Smrg test "$hardcode_direct_absolute" = no; then 684642a55b46Smrg add="$dir/$linklib" 684742a55b46Smrg elif test "$hardcode_minus_L" = yes; then 684842a55b46Smrg add_dir="-L$absdir" 684942a55b46Smrg # Try looking first in the location we're being installed to. 685042a55b46Smrg if test -n "$inst_prefix_dir"; then 685142a55b46Smrg case $libdir in 685242a55b46Smrg [\\/]*) 685342a55b46Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 685442a55b46Smrg ;; 685542a55b46Smrg esac 685642a55b46Smrg fi 685742a55b46Smrg add="-l$name" 685842a55b46Smrg elif test "$hardcode_shlibpath_var" = yes; then 685942a55b46Smrg add_shlibpath="$dir" 686042a55b46Smrg add="-l$name" 686142a55b46Smrg else 686242a55b46Smrg lib_linked=no 686342a55b46Smrg fi 686442a55b46Smrg ;; 686542a55b46Smrg *) lib_linked=no ;; 686642a55b46Smrg esac 686742a55b46Smrg 686842a55b46Smrg if test "$lib_linked" != yes; then 686942a55b46Smrg func_fatal_configuration "unsupported hardcode properties" 687042a55b46Smrg fi 687142a55b46Smrg 687242a55b46Smrg if test -n "$add_shlibpath"; then 687342a55b46Smrg case :$compile_shlibpath: in 687442a55b46Smrg *":$add_shlibpath:"*) ;; 687542a55b46Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 687642a55b46Smrg esac 687742a55b46Smrg fi 687842a55b46Smrg if test "$linkmode" = prog; then 687942a55b46Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 688042a55b46Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 688142a55b46Smrg else 688242a55b46Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 688342a55b46Smrg test -n "$add" && deplibs="$add $deplibs" 688442a55b46Smrg if test "$hardcode_direct" != yes && 688542a55b46Smrg test "$hardcode_minus_L" != yes && 688642a55b46Smrg test "$hardcode_shlibpath_var" = yes; then 688742a55b46Smrg case :$finalize_shlibpath: in 688842a55b46Smrg *":$libdir:"*) ;; 688942a55b46Smrg *) func_append finalize_shlibpath "$libdir:" ;; 689042a55b46Smrg esac 689142a55b46Smrg fi 689242a55b46Smrg fi 689342a55b46Smrg fi 689442a55b46Smrg 689542a55b46Smrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 689642a55b46Smrg add_shlibpath= 689742a55b46Smrg add_dir= 689842a55b46Smrg add= 689942a55b46Smrg # Finalize command for both is simple: just hardcode it. 690042a55b46Smrg if test "$hardcode_direct" = yes && 690142a55b46Smrg test "$hardcode_direct_absolute" = no; then 690242a55b46Smrg add="$libdir/$linklib" 690342a55b46Smrg elif test "$hardcode_minus_L" = yes; then 690442a55b46Smrg add_dir="-L$libdir" 690542a55b46Smrg add="-l$name" 690642a55b46Smrg elif test "$hardcode_shlibpath_var" = yes; then 690742a55b46Smrg case :$finalize_shlibpath: in 690842a55b46Smrg *":$libdir:"*) ;; 690942a55b46Smrg *) func_append finalize_shlibpath "$libdir:" ;; 691042a55b46Smrg esac 691142a55b46Smrg add="-l$name" 691242a55b46Smrg elif test "$hardcode_automatic" = yes; then 691342a55b46Smrg if test -n "$inst_prefix_dir" && 691442a55b46Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 691542a55b46Smrg add="$inst_prefix_dir$libdir/$linklib" 691642a55b46Smrg else 691742a55b46Smrg add="$libdir/$linklib" 691842a55b46Smrg fi 691942a55b46Smrg else 692042a55b46Smrg # We cannot seem to hardcode it, guess we'll fake it. 692142a55b46Smrg add_dir="-L$libdir" 692242a55b46Smrg # Try looking first in the location we're being installed to. 692342a55b46Smrg if test -n "$inst_prefix_dir"; then 692442a55b46Smrg case $libdir in 692542a55b46Smrg [\\/]*) 692642a55b46Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 692742a55b46Smrg ;; 692842a55b46Smrg esac 692942a55b46Smrg fi 693042a55b46Smrg add="-l$name" 693142a55b46Smrg fi 693242a55b46Smrg 693342a55b46Smrg if test "$linkmode" = prog; then 693442a55b46Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 693542a55b46Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 693642a55b46Smrg else 693742a55b46Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 693842a55b46Smrg test -n "$add" && deplibs="$add $deplibs" 693942a55b46Smrg fi 694042a55b46Smrg fi 694142a55b46Smrg elif test "$linkmode" = prog; then 694242a55b46Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 694342a55b46Smrg # is not unsupported. This is valid on all known static and 694442a55b46Smrg # shared platforms. 694542a55b46Smrg if test "$hardcode_direct" != unsupported; then 694642a55b46Smrg test -n "$old_library" && linklib="$old_library" 694742a55b46Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 694842a55b46Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 694942a55b46Smrg else 695042a55b46Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 695142a55b46Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 695242a55b46Smrg fi 695342a55b46Smrg elif test "$build_libtool_libs" = yes; then 695442a55b46Smrg # Not a shared library 695542a55b46Smrg if test "$deplibs_check_method" != pass_all; then 695642a55b46Smrg # We're trying link a shared library against a static one 695742a55b46Smrg # but the system doesn't support it. 695842a55b46Smrg 695942a55b46Smrg # Just print a warning and add the library to dependency_libs so 696042a55b46Smrg # that the program can be linked against the static library. 696142a55b46Smrg echo 696242a55b46Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 696342a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 696442a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 696542a55b46Smrg echo "*** shared version of the library, which you do not appear to have." 696642a55b46Smrg if test "$module" = yes; then 696742a55b46Smrg echo "*** But as you try to build a module library, libtool will still create " 696842a55b46Smrg echo "*** a static module, that should work as long as the dlopening application" 696942a55b46Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 697042a55b46Smrg if test -z "$global_symbol_pipe"; then 697142a55b46Smrg echo 697242a55b46Smrg echo "*** However, this would only work if libtool was able to extract symbol" 697342a55b46Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 697442a55b46Smrg echo "*** not find such a program. So, this module is probably useless." 697542a55b46Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 697642a55b46Smrg fi 697742a55b46Smrg if test "$build_old_libs" = no; then 697842a55b46Smrg build_libtool_libs=module 697942a55b46Smrg build_old_libs=yes 698042a55b46Smrg else 698142a55b46Smrg build_libtool_libs=no 698242a55b46Smrg fi 698342a55b46Smrg fi 698442a55b46Smrg else 698542a55b46Smrg deplibs="$dir/$old_library $deplibs" 698642a55b46Smrg link_static=yes 698742a55b46Smrg fi 698842a55b46Smrg fi # link shared/static library? 698942a55b46Smrg 699042a55b46Smrg if test "$linkmode" = lib; then 699142a55b46Smrg if test -n "$dependency_libs" && 699242a55b46Smrg { test "$hardcode_into_libs" != yes || 699342a55b46Smrg test "$build_old_libs" = yes || 699442a55b46Smrg test "$link_static" = yes; }; then 699542a55b46Smrg # Extract -R from dependency_libs 699642a55b46Smrg temp_deplibs= 699742a55b46Smrg for libdir in $dependency_libs; do 699842a55b46Smrg case $libdir in 699942a55b46Smrg -R*) func_stripname '-R' '' "$libdir" 700042a55b46Smrg temp_xrpath=$func_stripname_result 700142a55b46Smrg case " $xrpath " in 700242a55b46Smrg *" $temp_xrpath "*) ;; 700342a55b46Smrg *) func_append xrpath " $temp_xrpath";; 700442a55b46Smrg esac;; 700542a55b46Smrg *) func_append temp_deplibs " $libdir";; 700642a55b46Smrg esac 700742a55b46Smrg done 700842a55b46Smrg dependency_libs="$temp_deplibs" 700942a55b46Smrg fi 701042a55b46Smrg 701142a55b46Smrg func_append newlib_search_path " $absdir" 701242a55b46Smrg # Link against this library 701342a55b46Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 701442a55b46Smrg # ... and its dependency_libs 701542a55b46Smrg tmp_libs= 701642a55b46Smrg for deplib in $dependency_libs; do 701742a55b46Smrg newdependency_libs="$deplib $newdependency_libs" 701842a55b46Smrg case $deplib in 701942a55b46Smrg -L*) func_stripname '-L' '' "$deplib" 702042a55b46Smrg func_resolve_sysroot "$func_stripname_result";; 702142a55b46Smrg *) func_resolve_sysroot "$deplib" ;; 702242a55b46Smrg esac 702342a55b46Smrg if $opt_preserve_dup_deps ; then 702442a55b46Smrg case "$tmp_libs " in 702542a55b46Smrg *" $func_resolve_sysroot_result "*) 702642a55b46Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 702742a55b46Smrg esac 702842a55b46Smrg fi 702942a55b46Smrg func_append tmp_libs " $func_resolve_sysroot_result" 703042a55b46Smrg done 703142a55b46Smrg 703242a55b46Smrg if test "$link_all_deplibs" != no; then 703342a55b46Smrg # Add the search paths of all dependency libraries 703442a55b46Smrg for deplib in $dependency_libs; do 703542a55b46Smrg path= 703642a55b46Smrg case $deplib in 703742a55b46Smrg -L*) path="$deplib" ;; 703842a55b46Smrg *.la) 703942a55b46Smrg func_resolve_sysroot "$deplib" 704042a55b46Smrg deplib=$func_resolve_sysroot_result 704142a55b46Smrg func_dirname "$deplib" "" "." 704242a55b46Smrg dir=$func_dirname_result 704342a55b46Smrg # We need an absolute path. 704442a55b46Smrg case $dir in 704542a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 704642a55b46Smrg *) 704742a55b46Smrg absdir=`cd "$dir" && pwd` 704842a55b46Smrg if test -z "$absdir"; then 704942a55b46Smrg func_warning "cannot determine absolute directory name of \`$dir'" 705042a55b46Smrg absdir="$dir" 705142a55b46Smrg fi 705242a55b46Smrg ;; 705342a55b46Smrg esac 705442a55b46Smrg if $GREP "^installed=no" $deplib > /dev/null; then 705542a55b46Smrg case $host in 705642a55b46Smrg *-*-darwin*) 705742a55b46Smrg depdepl= 705842a55b46Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 705942a55b46Smrg if test -n "$deplibrary_names" ; then 706042a55b46Smrg for tmp in $deplibrary_names ; do 706142a55b46Smrg depdepl=$tmp 706242a55b46Smrg done 706342a55b46Smrg if test -f "$absdir/$objdir/$depdepl" ; then 706442a55b46Smrg depdepl="$absdir/$objdir/$depdepl" 706542a55b46Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 706642a55b46Smrg if test -z "$darwin_install_name"; then 706742a55b46Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 706842a55b46Smrg fi 706942a55b46Smrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 707042a55b46Smrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 707142a55b46Smrg path= 707242a55b46Smrg fi 707342a55b46Smrg fi 707442a55b46Smrg ;; 707542a55b46Smrg *) 707642a55b46Smrg path="-L$absdir/$objdir" 707742a55b46Smrg ;; 707842a55b46Smrg esac 707942a55b46Smrg else 708042a55b46Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 708142a55b46Smrg test -z "$libdir" && \ 708242a55b46Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 708342a55b46Smrg test "$absdir" != "$libdir" && \ 708442a55b46Smrg func_warning "\`$deplib' seems to be moved" 708542a55b46Smrg 708642a55b46Smrg path="-L$absdir" 708742a55b46Smrg fi 708842a55b46Smrg ;; 708942a55b46Smrg esac 709042a55b46Smrg case " $deplibs " in 709142a55b46Smrg *" $path "*) ;; 709242a55b46Smrg *) deplibs="$path $deplibs" ;; 709342a55b46Smrg esac 709442a55b46Smrg done 709542a55b46Smrg fi # link_all_deplibs != no 709642a55b46Smrg fi # linkmode = lib 709742a55b46Smrg done # for deplib in $libs 709842a55b46Smrg if test "$pass" = link; then 709942a55b46Smrg if test "$linkmode" = "prog"; then 710042a55b46Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 710142a55b46Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 710242a55b46Smrg else 710342a55b46Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 710442a55b46Smrg fi 710542a55b46Smrg fi 710642a55b46Smrg dependency_libs="$newdependency_libs" 710742a55b46Smrg if test "$pass" = dlpreopen; then 710842a55b46Smrg # Link the dlpreopened libraries before other libraries 710942a55b46Smrg for deplib in $save_deplibs; do 711042a55b46Smrg deplibs="$deplib $deplibs" 711142a55b46Smrg done 711242a55b46Smrg fi 711342a55b46Smrg if test "$pass" != dlopen; then 711442a55b46Smrg if test "$pass" != conv; then 711542a55b46Smrg # Make sure lib_search_path contains only unique directories. 711642a55b46Smrg lib_search_path= 711742a55b46Smrg for dir in $newlib_search_path; do 711842a55b46Smrg case "$lib_search_path " in 711942a55b46Smrg *" $dir "*) ;; 712042a55b46Smrg *) func_append lib_search_path " $dir" ;; 712142a55b46Smrg esac 712242a55b46Smrg done 712342a55b46Smrg newlib_search_path= 712442a55b46Smrg fi 712542a55b46Smrg 712642a55b46Smrg if test "$linkmode,$pass" != "prog,link"; then 712742a55b46Smrg vars="deplibs" 712842a55b46Smrg else 712942a55b46Smrg vars="compile_deplibs finalize_deplibs" 713042a55b46Smrg fi 713142a55b46Smrg for var in $vars dependency_libs; do 713242a55b46Smrg # Add libraries to $var in reverse order 713342a55b46Smrg eval tmp_libs=\"\$$var\" 713442a55b46Smrg new_libs= 713542a55b46Smrg for deplib in $tmp_libs; do 713642a55b46Smrg # FIXME: Pedantically, this is the right thing to do, so 713742a55b46Smrg # that some nasty dependency loop isn't accidentally 713842a55b46Smrg # broken: 713942a55b46Smrg #new_libs="$deplib $new_libs" 714042a55b46Smrg # Pragmatically, this seems to cause very few problems in 714142a55b46Smrg # practice: 714242a55b46Smrg case $deplib in 714342a55b46Smrg -L*) new_libs="$deplib $new_libs" ;; 714442a55b46Smrg -R*) ;; 714542a55b46Smrg *) 714642a55b46Smrg # And here is the reason: when a library appears more 714742a55b46Smrg # than once as an explicit dependence of a library, or 714842a55b46Smrg # is implicitly linked in more than once by the 714942a55b46Smrg # compiler, it is considered special, and multiple 715042a55b46Smrg # occurrences thereof are not removed. Compare this 715142a55b46Smrg # with having the same library being listed as a 715242a55b46Smrg # dependency of multiple other libraries: in this case, 715342a55b46Smrg # we know (pedantically, we assume) the library does not 715442a55b46Smrg # need to be listed more than once, so we keep only the 715542a55b46Smrg # last copy. This is not always right, but it is rare 715642a55b46Smrg # enough that we require users that really mean to play 715742a55b46Smrg # such unportable linking tricks to link the library 715842a55b46Smrg # using -Wl,-lname, so that libtool does not consider it 715942a55b46Smrg # for duplicate removal. 716042a55b46Smrg case " $specialdeplibs " in 716142a55b46Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 716242a55b46Smrg *) 716342a55b46Smrg case " $new_libs " in 716442a55b46Smrg *" $deplib "*) ;; 716542a55b46Smrg *) new_libs="$deplib $new_libs" ;; 716642a55b46Smrg esac 716742a55b46Smrg ;; 716842a55b46Smrg esac 716942a55b46Smrg ;; 717042a55b46Smrg esac 717142a55b46Smrg done 717242a55b46Smrg tmp_libs= 717342a55b46Smrg for deplib in $new_libs; do 717442a55b46Smrg case $deplib in 717542a55b46Smrg -L*) 717642a55b46Smrg case " $tmp_libs " in 717742a55b46Smrg *" $deplib "*) ;; 717842a55b46Smrg *) func_append tmp_libs " $deplib" ;; 717942a55b46Smrg esac 718042a55b46Smrg ;; 718142a55b46Smrg *) func_append tmp_libs " $deplib" ;; 718242a55b46Smrg esac 718342a55b46Smrg done 718442a55b46Smrg eval $var=\"$tmp_libs\" 718542a55b46Smrg done # for var 718642a55b46Smrg fi 718742a55b46Smrg # Last step: remove runtime libs from dependency_libs 718842a55b46Smrg # (they stay in deplibs) 718942a55b46Smrg tmp_libs= 719042a55b46Smrg for i in $dependency_libs ; do 719142a55b46Smrg case " $predeps $postdeps $compiler_lib_search_path " in 719242a55b46Smrg *" $i "*) 719342a55b46Smrg i="" 719442a55b46Smrg ;; 719542a55b46Smrg esac 719642a55b46Smrg if test -n "$i" ; then 719742a55b46Smrg func_append tmp_libs " $i" 719842a55b46Smrg fi 719942a55b46Smrg done 720042a55b46Smrg dependency_libs=$tmp_libs 720142a55b46Smrg done # for pass 720242a55b46Smrg if test "$linkmode" = prog; then 720342a55b46Smrg dlfiles="$newdlfiles" 720442a55b46Smrg fi 720542a55b46Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 720642a55b46Smrg dlprefiles="$newdlprefiles" 720742a55b46Smrg fi 720842a55b46Smrg 720942a55b46Smrg case $linkmode in 721042a55b46Smrg oldlib) 721142a55b46Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 721242a55b46Smrg func_warning "\`-dlopen' is ignored for archives" 721342a55b46Smrg fi 721442a55b46Smrg 721542a55b46Smrg case " $deplibs" in 721642a55b46Smrg *\ -l* | *\ -L*) 721742a55b46Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 721842a55b46Smrg esac 721942a55b46Smrg 722042a55b46Smrg test -n "$rpath" && \ 722142a55b46Smrg func_warning "\`-rpath' is ignored for archives" 722242a55b46Smrg 722342a55b46Smrg test -n "$xrpath" && \ 722442a55b46Smrg func_warning "\`-R' is ignored for archives" 722542a55b46Smrg 722642a55b46Smrg test -n "$vinfo" && \ 722742a55b46Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 722842a55b46Smrg 722942a55b46Smrg test -n "$release" && \ 723042a55b46Smrg func_warning "\`-release' is ignored for archives" 723142a55b46Smrg 723242a55b46Smrg test -n "$export_symbols$export_symbols_regex" && \ 723342a55b46Smrg func_warning "\`-export-symbols' is ignored for archives" 723442a55b46Smrg 723542a55b46Smrg # Now set the variables for building old libraries. 723642a55b46Smrg build_libtool_libs=no 723742a55b46Smrg oldlibs="$output" 723842a55b46Smrg func_append objs "$old_deplibs" 723942a55b46Smrg ;; 724042a55b46Smrg 724142a55b46Smrg lib) 724242a55b46Smrg # Make sure we only generate libraries of the form `libNAME.la'. 724342a55b46Smrg case $outputname in 724442a55b46Smrg lib*) 724542a55b46Smrg func_stripname 'lib' '.la' "$outputname" 724642a55b46Smrg name=$func_stripname_result 724742a55b46Smrg eval shared_ext=\"$shrext_cmds\" 724842a55b46Smrg eval libname=\"$libname_spec\" 724942a55b46Smrg ;; 725042a55b46Smrg *) 725142a55b46Smrg test "$module" = no && \ 725242a55b46Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 725342a55b46Smrg 725442a55b46Smrg if test "$need_lib_prefix" != no; then 725542a55b46Smrg # Add the "lib" prefix for modules if required 725642a55b46Smrg func_stripname '' '.la' "$outputname" 725742a55b46Smrg name=$func_stripname_result 725842a55b46Smrg eval shared_ext=\"$shrext_cmds\" 725942a55b46Smrg eval libname=\"$libname_spec\" 726042a55b46Smrg else 726142a55b46Smrg func_stripname '' '.la' "$outputname" 726242a55b46Smrg libname=$func_stripname_result 726342a55b46Smrg fi 726442a55b46Smrg ;; 726542a55b46Smrg esac 726642a55b46Smrg 726742a55b46Smrg if test -n "$objs"; then 726842a55b46Smrg if test "$deplibs_check_method" != pass_all; then 726942a55b46Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 727042a55b46Smrg else 727142a55b46Smrg echo 727242a55b46Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 727342a55b46Smrg $ECHO "*** objects $objs is not portable!" 727442a55b46Smrg func_append libobjs " $objs" 727542a55b46Smrg fi 727642a55b46Smrg fi 727742a55b46Smrg 727842a55b46Smrg test "$dlself" != no && \ 727942a55b46Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 728042a55b46Smrg 728142a55b46Smrg set dummy $rpath 728242a55b46Smrg shift 728342a55b46Smrg test "$#" -gt 1 && \ 728442a55b46Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 728542a55b46Smrg 728642a55b46Smrg install_libdir="$1" 728742a55b46Smrg 728842a55b46Smrg oldlibs= 728942a55b46Smrg if test -z "$rpath"; then 729042a55b46Smrg if test "$build_libtool_libs" = yes; then 729142a55b46Smrg # Building a libtool convenience library. 729242a55b46Smrg # Some compilers have problems with a `.al' extension so 729342a55b46Smrg # convenience libraries should have the same extension an 729442a55b46Smrg # archive normally would. 729542a55b46Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 729642a55b46Smrg build_libtool_libs=convenience 729742a55b46Smrg build_old_libs=yes 729842a55b46Smrg fi 729942a55b46Smrg 730042a55b46Smrg test -n "$vinfo" && \ 730142a55b46Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 730242a55b46Smrg 730342a55b46Smrg test -n "$release" && \ 730442a55b46Smrg func_warning "\`-release' is ignored for convenience libraries" 730542a55b46Smrg else 730642a55b46Smrg 730742a55b46Smrg # Parse the version information argument. 730842a55b46Smrg save_ifs="$IFS"; IFS=':' 730942a55b46Smrg set dummy $vinfo 0 0 0 731042a55b46Smrg shift 731142a55b46Smrg IFS="$save_ifs" 731242a55b46Smrg 731342a55b46Smrg test -n "$7" && \ 731442a55b46Smrg func_fatal_help "too many parameters to \`-version-info'" 731542a55b46Smrg 731642a55b46Smrg # convert absolute version numbers to libtool ages 731742a55b46Smrg # this retains compatibility with .la files and attempts 731842a55b46Smrg # to make the code below a bit more comprehensible 731942a55b46Smrg 732042a55b46Smrg case $vinfo_number in 732142a55b46Smrg yes) 732242a55b46Smrg number_major="$1" 732342a55b46Smrg number_minor="$2" 732442a55b46Smrg number_revision="$3" 732542a55b46Smrg # 732642a55b46Smrg # There are really only two kinds -- those that 732742a55b46Smrg # use the current revision as the major version 732842a55b46Smrg # and those that subtract age and use age as 732942a55b46Smrg # a minor version. But, then there is irix 733042a55b46Smrg # which has an extra 1 added just for fun 733142a55b46Smrg # 733242a55b46Smrg case $version_type in 733342a55b46Smrg # correct linux to gnu/linux during the next big refactor 733442a55b46Smrg darwin|linux|osf|windows|none) 733542a55b46Smrg func_arith $number_major + $number_minor 733642a55b46Smrg current=$func_arith_result 733742a55b46Smrg age="$number_minor" 733842a55b46Smrg revision="$number_revision" 733942a55b46Smrg ;; 734042a55b46Smrg freebsd-aout|freebsd-elf|qnx|sunos) 734142a55b46Smrg current="$number_major" 734242a55b46Smrg revision="$number_minor" 734342a55b46Smrg age="0" 734442a55b46Smrg ;; 734542a55b46Smrg irix|nonstopux) 734642a55b46Smrg func_arith $number_major + $number_minor 734742a55b46Smrg current=$func_arith_result 734842a55b46Smrg age="$number_minor" 734942a55b46Smrg revision="$number_minor" 735042a55b46Smrg lt_irix_increment=no 735142a55b46Smrg ;; 735242a55b46Smrg esac 735342a55b46Smrg ;; 735442a55b46Smrg no) 735542a55b46Smrg current="$1" 735642a55b46Smrg revision="$2" 735742a55b46Smrg age="$3" 735842a55b46Smrg ;; 735942a55b46Smrg esac 736042a55b46Smrg 736142a55b46Smrg # Check that each of the things are valid numbers. 736242a55b46Smrg case $current in 736342a55b46Smrg 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]) ;; 736442a55b46Smrg *) 736542a55b46Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 736642a55b46Smrg func_fatal_error "\`$vinfo' is not valid version information" 736742a55b46Smrg ;; 736842a55b46Smrg esac 736942a55b46Smrg 737042a55b46Smrg case $revision in 737142a55b46Smrg 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]) ;; 737242a55b46Smrg *) 737342a55b46Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 737442a55b46Smrg func_fatal_error "\`$vinfo' is not valid version information" 737542a55b46Smrg ;; 737642a55b46Smrg esac 737742a55b46Smrg 737842a55b46Smrg case $age in 737942a55b46Smrg 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]) ;; 738042a55b46Smrg *) 738142a55b46Smrg func_error "AGE \`$age' must be a nonnegative integer" 738242a55b46Smrg func_fatal_error "\`$vinfo' is not valid version information" 738342a55b46Smrg ;; 738442a55b46Smrg esac 738542a55b46Smrg 738642a55b46Smrg if test "$age" -gt "$current"; then 738742a55b46Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 738842a55b46Smrg func_fatal_error "\`$vinfo' is not valid version information" 738942a55b46Smrg fi 739042a55b46Smrg 739142a55b46Smrg # Calculate the version variables. 739242a55b46Smrg major= 739342a55b46Smrg versuffix= 739442a55b46Smrg verstring= 739542a55b46Smrg case $version_type in 739642a55b46Smrg none) ;; 739742a55b46Smrg 739842a55b46Smrg darwin) 739942a55b46Smrg # Like Linux, but with the current version available in 740042a55b46Smrg # verstring for coding it into the library header 740142a55b46Smrg func_arith $current - $age 740242a55b46Smrg major=.$func_arith_result 740342a55b46Smrg versuffix="$major.$age.$revision" 740442a55b46Smrg # Darwin ld doesn't like 0 for these options... 740542a55b46Smrg func_arith $current + 1 740642a55b46Smrg minor_current=$func_arith_result 740742a55b46Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 740842a55b46Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 740942a55b46Smrg ;; 741042a55b46Smrg 741142a55b46Smrg freebsd-aout) 741242a55b46Smrg major=".$current" 741342a55b46Smrg versuffix=".$current.$revision"; 741442a55b46Smrg ;; 741542a55b46Smrg 741642a55b46Smrg freebsd-elf) 741742a55b46Smrg major=".$current" 741842a55b46Smrg versuffix=".$current" 741942a55b46Smrg ;; 742042a55b46Smrg 742142a55b46Smrg irix | nonstopux) 742242a55b46Smrg if test "X$lt_irix_increment" = "Xno"; then 742342a55b46Smrg func_arith $current - $age 742442a55b46Smrg else 742542a55b46Smrg func_arith $current - $age + 1 742642a55b46Smrg fi 742742a55b46Smrg major=$func_arith_result 742842a55b46Smrg 742942a55b46Smrg case $version_type in 743042a55b46Smrg nonstopux) verstring_prefix=nonstopux ;; 743142a55b46Smrg *) verstring_prefix=sgi ;; 743242a55b46Smrg esac 743342a55b46Smrg verstring="$verstring_prefix$major.$revision" 743442a55b46Smrg 743542a55b46Smrg # Add in all the interfaces that we are compatible with. 743642a55b46Smrg loop=$revision 743742a55b46Smrg while test "$loop" -ne 0; do 743842a55b46Smrg func_arith $revision - $loop 743942a55b46Smrg iface=$func_arith_result 744042a55b46Smrg func_arith $loop - 1 744142a55b46Smrg loop=$func_arith_result 744242a55b46Smrg verstring="$verstring_prefix$major.$iface:$verstring" 744342a55b46Smrg done 744442a55b46Smrg 744542a55b46Smrg # Before this point, $major must not contain `.'. 744642a55b46Smrg major=.$major 744742a55b46Smrg versuffix="$major.$revision" 744842a55b46Smrg ;; 744942a55b46Smrg 745042a55b46Smrg linux) # correct to gnu/linux during the next big refactor 745142a55b46Smrg func_arith $current - $age 745242a55b46Smrg major=.$func_arith_result 745342a55b46Smrg versuffix="$major.$age.$revision" 745442a55b46Smrg ;; 745542a55b46Smrg 745642a55b46Smrg osf) 745742a55b46Smrg func_arith $current - $age 745842a55b46Smrg major=.$func_arith_result 745942a55b46Smrg versuffix=".$current.$age.$revision" 746042a55b46Smrg verstring="$current.$age.$revision" 746142a55b46Smrg 746242a55b46Smrg # Add in all the interfaces that we are compatible with. 746342a55b46Smrg loop=$age 746442a55b46Smrg while test "$loop" -ne 0; do 746542a55b46Smrg func_arith $current - $loop 746642a55b46Smrg iface=$func_arith_result 746742a55b46Smrg func_arith $loop - 1 746842a55b46Smrg loop=$func_arith_result 746942a55b46Smrg verstring="$verstring:${iface}.0" 747042a55b46Smrg done 747142a55b46Smrg 747242a55b46Smrg # Make executables depend on our current version. 747342a55b46Smrg func_append verstring ":${current}.0" 747442a55b46Smrg ;; 747542a55b46Smrg 747642a55b46Smrg qnx) 747742a55b46Smrg major=".$current" 747842a55b46Smrg versuffix=".$current" 747942a55b46Smrg ;; 748042a55b46Smrg 748142a55b46Smrg sunos) 748242a55b46Smrg major=".$current" 748342a55b46Smrg versuffix=".$current.$revision" 748442a55b46Smrg ;; 748542a55b46Smrg 748642a55b46Smrg windows) 748742a55b46Smrg # Use '-' rather than '.', since we only want one 748842a55b46Smrg # extension on DOS 8.3 filesystems. 748942a55b46Smrg func_arith $current - $age 749042a55b46Smrg major=$func_arith_result 749142a55b46Smrg versuffix="-$major" 749242a55b46Smrg ;; 749342a55b46Smrg 749442a55b46Smrg *) 749542a55b46Smrg func_fatal_configuration "unknown library version type \`$version_type'" 749642a55b46Smrg ;; 749742a55b46Smrg esac 749842a55b46Smrg 749942a55b46Smrg # Clear the version info if we defaulted, and they specified a release. 750042a55b46Smrg if test -z "$vinfo" && test -n "$release"; then 750142a55b46Smrg major= 750242a55b46Smrg case $version_type in 750342a55b46Smrg darwin) 750442a55b46Smrg # we can't check for "0.0" in archive_cmds due to quoting 750542a55b46Smrg # problems, so we reset it completely 750642a55b46Smrg verstring= 750742a55b46Smrg ;; 750842a55b46Smrg *) 750942a55b46Smrg verstring="0.0" 751042a55b46Smrg ;; 751142a55b46Smrg esac 751242a55b46Smrg if test "$need_version" = no; then 751342a55b46Smrg versuffix= 751442a55b46Smrg else 751542a55b46Smrg versuffix=".0.0" 751642a55b46Smrg fi 751742a55b46Smrg fi 751842a55b46Smrg 751942a55b46Smrg # Remove version info from name if versioning should be avoided 752042a55b46Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 752142a55b46Smrg major= 752242a55b46Smrg versuffix= 752342a55b46Smrg verstring="" 752442a55b46Smrg fi 752542a55b46Smrg 752642a55b46Smrg # Check to see if the archive will have undefined symbols. 752742a55b46Smrg if test "$allow_undefined" = yes; then 752842a55b46Smrg if test "$allow_undefined_flag" = unsupported; then 752942a55b46Smrg func_warning "undefined symbols not allowed in $host shared libraries" 753042a55b46Smrg build_libtool_libs=no 753142a55b46Smrg build_old_libs=yes 753242a55b46Smrg fi 753342a55b46Smrg else 753442a55b46Smrg # Don't allow undefined symbols. 753542a55b46Smrg allow_undefined_flag="$no_undefined_flag" 753642a55b46Smrg fi 753742a55b46Smrg 753842a55b46Smrg fi 753942a55b46Smrg 754042a55b46Smrg func_generate_dlsyms "$libname" "$libname" "yes" 754142a55b46Smrg func_append libobjs " $symfileobj" 754242a55b46Smrg test "X$libobjs" = "X " && libobjs= 754342a55b46Smrg 754442a55b46Smrg if test "$opt_mode" != relink; then 754542a55b46Smrg # Remove our outputs, but don't remove object files since they 754642a55b46Smrg # may have been created when compiling PIC objects. 754742a55b46Smrg removelist= 754842a55b46Smrg tempremovelist=`$ECHO "$output_objdir/*"` 754942a55b46Smrg for p in $tempremovelist; do 755042a55b46Smrg case $p in 755142a55b46Smrg *.$objext | *.gcno) 755242a55b46Smrg ;; 755342a55b46Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 755442a55b46Smrg if test "X$precious_files_regex" != "X"; then 755542a55b46Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 755642a55b46Smrg then 755742a55b46Smrg continue 755842a55b46Smrg fi 755942a55b46Smrg fi 756042a55b46Smrg func_append removelist " $p" 756142a55b46Smrg ;; 756242a55b46Smrg *) ;; 756342a55b46Smrg esac 756442a55b46Smrg done 756542a55b46Smrg test -n "$removelist" && \ 756642a55b46Smrg func_show_eval "${RM}r \$removelist" 756742a55b46Smrg fi 756842a55b46Smrg 756942a55b46Smrg # Now set the variables for building old libraries. 757042a55b46Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 757142a55b46Smrg func_append oldlibs " $output_objdir/$libname.$libext" 757242a55b46Smrg 757342a55b46Smrg # Transform .lo files to .o files. 757442a55b46Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 757542a55b46Smrg fi 757642a55b46Smrg 757742a55b46Smrg # Eliminate all temporary directories. 757842a55b46Smrg #for path in $notinst_path; do 757942a55b46Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 758042a55b46Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 758142a55b46Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 758242a55b46Smrg #done 758342a55b46Smrg 758442a55b46Smrg if test -n "$xrpath"; then 758542a55b46Smrg # If the user specified any rpath flags, then add them. 758642a55b46Smrg temp_xrpath= 758742a55b46Smrg for libdir in $xrpath; do 758842a55b46Smrg func_replace_sysroot "$libdir" 758942a55b46Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 759042a55b46Smrg case "$finalize_rpath " in 759142a55b46Smrg *" $libdir "*) ;; 759242a55b46Smrg *) func_append finalize_rpath " $libdir" ;; 759342a55b46Smrg esac 759442a55b46Smrg done 759542a55b46Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 759642a55b46Smrg dependency_libs="$temp_xrpath $dependency_libs" 759742a55b46Smrg fi 759842a55b46Smrg fi 759942a55b46Smrg 760042a55b46Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 760142a55b46Smrg old_dlfiles="$dlfiles" 760242a55b46Smrg dlfiles= 760342a55b46Smrg for lib in $old_dlfiles; do 760442a55b46Smrg case " $dlprefiles $dlfiles " in 760542a55b46Smrg *" $lib "*) ;; 760642a55b46Smrg *) func_append dlfiles " $lib" ;; 760742a55b46Smrg esac 760842a55b46Smrg done 760942a55b46Smrg 761042a55b46Smrg # Make sure dlprefiles contains only unique files 761142a55b46Smrg old_dlprefiles="$dlprefiles" 761242a55b46Smrg dlprefiles= 761342a55b46Smrg for lib in $old_dlprefiles; do 761442a55b46Smrg case "$dlprefiles " in 761542a55b46Smrg *" $lib "*) ;; 761642a55b46Smrg *) func_append dlprefiles " $lib" ;; 761742a55b46Smrg esac 761842a55b46Smrg done 761942a55b46Smrg 762042a55b46Smrg if test "$build_libtool_libs" = yes; then 762142a55b46Smrg if test -n "$rpath"; then 762242a55b46Smrg case $host in 762342a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 762442a55b46Smrg # these systems don't actually have a c library (as such)! 762542a55b46Smrg ;; 762642a55b46Smrg *-*-rhapsody* | *-*-darwin1.[012]) 762742a55b46Smrg # Rhapsody C library is in the System framework 762842a55b46Smrg func_append deplibs " System.ltframework" 762942a55b46Smrg ;; 763042a55b46Smrg *-*-netbsd*) 763142a55b46Smrg # Don't link with libc until the a.out ld.so is fixed. 763242a55b46Smrg ;; 763342a55b46Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 763442a55b46Smrg # Do not include libc due to us having libc/libc_r. 763542a55b46Smrg ;; 763642a55b46Smrg *-*-sco3.2v5* | *-*-sco5v6*) 763742a55b46Smrg # Causes problems with __ctype 763842a55b46Smrg ;; 763942a55b46Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 764042a55b46Smrg # Compiler inserts libc in the correct place for threads to work 764142a55b46Smrg ;; 764242a55b46Smrg *) 764342a55b46Smrg # Add libc to deplibs on all other systems if necessary. 764442a55b46Smrg if test "$build_libtool_need_lc" = "yes"; then 764542a55b46Smrg func_append deplibs " -lc" 764642a55b46Smrg fi 764742a55b46Smrg ;; 764842a55b46Smrg esac 764942a55b46Smrg fi 765042a55b46Smrg 765142a55b46Smrg # Transform deplibs into only deplibs that can be linked in shared. 765242a55b46Smrg name_save=$name 765342a55b46Smrg libname_save=$libname 765442a55b46Smrg release_save=$release 765542a55b46Smrg versuffix_save=$versuffix 765642a55b46Smrg major_save=$major 765742a55b46Smrg # I'm not sure if I'm treating the release correctly. I think 765842a55b46Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 765942a55b46Smrg # add it in twice. Is that correct? 766042a55b46Smrg release="" 766142a55b46Smrg versuffix="" 766242a55b46Smrg major="" 766342a55b46Smrg newdeplibs= 766442a55b46Smrg droppeddeps=no 766542a55b46Smrg case $deplibs_check_method in 766642a55b46Smrg pass_all) 766742a55b46Smrg # Don't check for shared/static. Everything works. 766842a55b46Smrg # This might be a little naive. We might want to check 766942a55b46Smrg # whether the library exists or not. But this is on 767042a55b46Smrg # osf3 & osf4 and I'm not really sure... Just 767142a55b46Smrg # implementing what was already the behavior. 767242a55b46Smrg newdeplibs=$deplibs 767342a55b46Smrg ;; 767442a55b46Smrg test_compile) 767542a55b46Smrg # This code stresses the "libraries are programs" paradigm to its 767642a55b46Smrg # limits. Maybe even breaks it. We compile a program, linking it 767742a55b46Smrg # against the deplibs as a proxy for the library. Then we can check 767842a55b46Smrg # whether they linked in statically or dynamically with ldd. 767942a55b46Smrg $opt_dry_run || $RM conftest.c 768042a55b46Smrg cat > conftest.c <<EOF 768142a55b46Smrg int main() { return 0; } 768242a55b46SmrgEOF 768342a55b46Smrg $opt_dry_run || $RM conftest 768442a55b46Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 768542a55b46Smrg ldd_output=`ldd conftest` 768642a55b46Smrg for i in $deplibs; do 768742a55b46Smrg case $i in 768842a55b46Smrg -l*) 768942a55b46Smrg func_stripname -l '' "$i" 769042a55b46Smrg name=$func_stripname_result 769142a55b46Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 769242a55b46Smrg case " $predeps $postdeps " in 769342a55b46Smrg *" $i "*) 769442a55b46Smrg func_append newdeplibs " $i" 769542a55b46Smrg i="" 769642a55b46Smrg ;; 769742a55b46Smrg esac 769842a55b46Smrg fi 769942a55b46Smrg if test -n "$i" ; then 770042a55b46Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 770142a55b46Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 770242a55b46Smrg set dummy $deplib_matches; shift 770342a55b46Smrg deplib_match=$1 770442a55b46Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 770542a55b46Smrg func_append newdeplibs " $i" 770642a55b46Smrg else 770742a55b46Smrg droppeddeps=yes 770842a55b46Smrg echo 770942a55b46Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 771042a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 771142a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 771242a55b46Smrg echo "*** shared version of the library, which I believe you do not have" 771342a55b46Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 771442a55b46Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 771542a55b46Smrg fi 771642a55b46Smrg fi 771742a55b46Smrg ;; 771842a55b46Smrg *) 771942a55b46Smrg func_append newdeplibs " $i" 772042a55b46Smrg ;; 772142a55b46Smrg esac 772242a55b46Smrg done 772342a55b46Smrg else 772442a55b46Smrg # Error occurred in the first compile. Let's try to salvage 772542a55b46Smrg # the situation: Compile a separate program for each library. 772642a55b46Smrg for i in $deplibs; do 772742a55b46Smrg case $i in 772842a55b46Smrg -l*) 772942a55b46Smrg func_stripname -l '' "$i" 773042a55b46Smrg name=$func_stripname_result 773142a55b46Smrg $opt_dry_run || $RM conftest 773242a55b46Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 773342a55b46Smrg ldd_output=`ldd conftest` 773442a55b46Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 773542a55b46Smrg case " $predeps $postdeps " in 773642a55b46Smrg *" $i "*) 773742a55b46Smrg func_append newdeplibs " $i" 773842a55b46Smrg i="" 773942a55b46Smrg ;; 774042a55b46Smrg esac 774142a55b46Smrg fi 774242a55b46Smrg if test -n "$i" ; then 774342a55b46Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 774442a55b46Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 774542a55b46Smrg set dummy $deplib_matches; shift 774642a55b46Smrg deplib_match=$1 774742a55b46Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 774842a55b46Smrg func_append newdeplibs " $i" 774942a55b46Smrg else 775042a55b46Smrg droppeddeps=yes 775142a55b46Smrg echo 775242a55b46Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 775342a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 775442a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 775542a55b46Smrg echo "*** shared version of the library, which you do not appear to have" 775642a55b46Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 775742a55b46Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 775842a55b46Smrg fi 775942a55b46Smrg fi 776042a55b46Smrg else 776142a55b46Smrg droppeddeps=yes 776242a55b46Smrg echo 776342a55b46Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 776442a55b46Smrg echo "*** make it link in! You will probably need to install it or some" 776542a55b46Smrg echo "*** library that it depends on before this library will be fully" 776642a55b46Smrg echo "*** functional. Installing it before continuing would be even better." 776742a55b46Smrg fi 776842a55b46Smrg ;; 776942a55b46Smrg *) 777042a55b46Smrg func_append newdeplibs " $i" 777142a55b46Smrg ;; 777242a55b46Smrg esac 777342a55b46Smrg done 777442a55b46Smrg fi 777542a55b46Smrg ;; 777642a55b46Smrg file_magic*) 777742a55b46Smrg set dummy $deplibs_check_method; shift 777842a55b46Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 777942a55b46Smrg for a_deplib in $deplibs; do 778042a55b46Smrg case $a_deplib in 778142a55b46Smrg -l*) 778242a55b46Smrg func_stripname -l '' "$a_deplib" 778342a55b46Smrg name=$func_stripname_result 778442a55b46Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 778542a55b46Smrg case " $predeps $postdeps " in 778642a55b46Smrg *" $a_deplib "*) 778742a55b46Smrg func_append newdeplibs " $a_deplib" 778842a55b46Smrg a_deplib="" 778942a55b46Smrg ;; 779042a55b46Smrg esac 779142a55b46Smrg fi 779242a55b46Smrg if test -n "$a_deplib" ; then 779342a55b46Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 779442a55b46Smrg if test -n "$file_magic_glob"; then 779542a55b46Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 779642a55b46Smrg else 779742a55b46Smrg libnameglob=$libname 779842a55b46Smrg fi 779942a55b46Smrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 780042a55b46Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 780142a55b46Smrg if test "$want_nocaseglob" = yes; then 780242a55b46Smrg shopt -s nocaseglob 780342a55b46Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 780442a55b46Smrg $nocaseglob 780542a55b46Smrg else 780642a55b46Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 780742a55b46Smrg fi 780842a55b46Smrg for potent_lib in $potential_libs; do 780942a55b46Smrg # Follow soft links. 781042a55b46Smrg if ls -lLd "$potent_lib" 2>/dev/null | 781142a55b46Smrg $GREP " -> " >/dev/null; then 781242a55b46Smrg continue 781342a55b46Smrg fi 781442a55b46Smrg # The statement above tries to avoid entering an 781542a55b46Smrg # endless loop below, in case of cyclic links. 781642a55b46Smrg # We might still enter an endless loop, since a link 781742a55b46Smrg # loop can be closed while we follow links, 781842a55b46Smrg # but so what? 781942a55b46Smrg potlib="$potent_lib" 782042a55b46Smrg while test -h "$potlib" 2>/dev/null; do 782142a55b46Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 782242a55b46Smrg case $potliblink in 782342a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 782442a55b46Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 782542a55b46Smrg esac 782642a55b46Smrg done 782742a55b46Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 782842a55b46Smrg $SED -e 10q | 782942a55b46Smrg $EGREP "$file_magic_regex" > /dev/null; then 783042a55b46Smrg func_append newdeplibs " $a_deplib" 783142a55b46Smrg a_deplib="" 783242a55b46Smrg break 2 783342a55b46Smrg fi 783442a55b46Smrg done 783542a55b46Smrg done 783642a55b46Smrg fi 783742a55b46Smrg if test -n "$a_deplib" ; then 783842a55b46Smrg droppeddeps=yes 783942a55b46Smrg echo 784042a55b46Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 784142a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 784242a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 784342a55b46Smrg echo "*** shared version of the library, which you do not appear to have" 784442a55b46Smrg echo "*** because I did check the linker path looking for a file starting" 784542a55b46Smrg if test -z "$potlib" ; then 784642a55b46Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 784742a55b46Smrg else 784842a55b46Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 784942a55b46Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 785042a55b46Smrg fi 785142a55b46Smrg fi 785242a55b46Smrg ;; 785342a55b46Smrg *) 785442a55b46Smrg # Add a -L argument. 785542a55b46Smrg func_append newdeplibs " $a_deplib" 785642a55b46Smrg ;; 785742a55b46Smrg esac 785842a55b46Smrg done # Gone through all deplibs. 785942a55b46Smrg ;; 786042a55b46Smrg match_pattern*) 786142a55b46Smrg set dummy $deplibs_check_method; shift 786242a55b46Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 786342a55b46Smrg for a_deplib in $deplibs; do 786442a55b46Smrg case $a_deplib in 786542a55b46Smrg -l*) 786642a55b46Smrg func_stripname -l '' "$a_deplib" 786742a55b46Smrg name=$func_stripname_result 786842a55b46Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 786942a55b46Smrg case " $predeps $postdeps " in 787042a55b46Smrg *" $a_deplib "*) 787142a55b46Smrg func_append newdeplibs " $a_deplib" 787242a55b46Smrg a_deplib="" 787342a55b46Smrg ;; 787442a55b46Smrg esac 787542a55b46Smrg fi 787642a55b46Smrg if test -n "$a_deplib" ; then 787742a55b46Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 787842a55b46Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 787942a55b46Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 788042a55b46Smrg for potent_lib in $potential_libs; do 788142a55b46Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 788242a55b46Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 788342a55b46Smrg $EGREP "$match_pattern_regex" > /dev/null; then 788442a55b46Smrg func_append newdeplibs " $a_deplib" 788542a55b46Smrg a_deplib="" 788642a55b46Smrg break 2 788742a55b46Smrg fi 788842a55b46Smrg done 788942a55b46Smrg done 789042a55b46Smrg fi 789142a55b46Smrg if test -n "$a_deplib" ; then 789242a55b46Smrg droppeddeps=yes 789342a55b46Smrg echo 789442a55b46Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 789542a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 789642a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 789742a55b46Smrg echo "*** shared version of the library, which you do not appear to have" 789842a55b46Smrg echo "*** because I did check the linker path looking for a file starting" 789942a55b46Smrg if test -z "$potlib" ; then 790042a55b46Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 790142a55b46Smrg else 790242a55b46Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 790342a55b46Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 790442a55b46Smrg fi 790542a55b46Smrg fi 790642a55b46Smrg ;; 790742a55b46Smrg *) 790842a55b46Smrg # Add a -L argument. 790942a55b46Smrg func_append newdeplibs " $a_deplib" 791042a55b46Smrg ;; 791142a55b46Smrg esac 791242a55b46Smrg done # Gone through all deplibs. 791342a55b46Smrg ;; 791442a55b46Smrg none | unknown | *) 791542a55b46Smrg newdeplibs="" 791642a55b46Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 791742a55b46Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 791842a55b46Smrg for i in $predeps $postdeps ; do 791942a55b46Smrg # can't use Xsed below, because $i might contain '/' 792042a55b46Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 792142a55b46Smrg done 792242a55b46Smrg fi 792342a55b46Smrg case $tmp_deplibs in 792442a55b46Smrg *[!\ \ ]*) 792542a55b46Smrg echo 792642a55b46Smrg if test "X$deplibs_check_method" = "Xnone"; then 792742a55b46Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 792842a55b46Smrg else 792942a55b46Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 793042a55b46Smrg fi 793142a55b46Smrg echo "*** All declared inter-library dependencies are being dropped." 793242a55b46Smrg droppeddeps=yes 793342a55b46Smrg ;; 793442a55b46Smrg esac 793542a55b46Smrg ;; 793642a55b46Smrg esac 793742a55b46Smrg versuffix=$versuffix_save 793842a55b46Smrg major=$major_save 793942a55b46Smrg release=$release_save 794042a55b46Smrg libname=$libname_save 794142a55b46Smrg name=$name_save 7942c582b7e3Smrg 794342a55b46Smrg case $host in 794442a55b46Smrg *-*-rhapsody* | *-*-darwin1.[012]) 794542a55b46Smrg # On Rhapsody replace the C library with the System framework 794642a55b46Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 794742a55b46Smrg ;; 794842a55b46Smrg esac 7949c582b7e3Smrg 795042a55b46Smrg if test "$droppeddeps" = yes; then 795142a55b46Smrg if test "$module" = yes; then 795242a55b46Smrg echo 795342a55b46Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 795442a55b46Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 795542a55b46Smrg echo "*** a static module, that should work as long as the dlopening" 795642a55b46Smrg echo "*** application is linked with the -dlopen flag." 795742a55b46Smrg if test -z "$global_symbol_pipe"; then 795842a55b46Smrg echo 795942a55b46Smrg echo "*** However, this would only work if libtool was able to extract symbol" 796042a55b46Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 796142a55b46Smrg echo "*** not find such a program. So, this module is probably useless." 796242a55b46Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 796342a55b46Smrg fi 796442a55b46Smrg if test "$build_old_libs" = no; then 796542a55b46Smrg oldlibs="$output_objdir/$libname.$libext" 796642a55b46Smrg build_libtool_libs=module 796742a55b46Smrg build_old_libs=yes 796842a55b46Smrg else 796942a55b46Smrg build_libtool_libs=no 797042a55b46Smrg fi 797142a55b46Smrg else 797242a55b46Smrg echo "*** The inter-library dependencies that have been dropped here will be" 797342a55b46Smrg echo "*** automatically added whenever a program is linked with this library" 797442a55b46Smrg echo "*** or is declared to -dlopen it." 7975c582b7e3Smrg 797642a55b46Smrg if test "$allow_undefined" = no; then 797742a55b46Smrg echo 797842a55b46Smrg echo "*** Since this library must not contain undefined symbols," 797942a55b46Smrg echo "*** because either the platform does not support them or" 798042a55b46Smrg echo "*** it was explicitly requested with -no-undefined," 798142a55b46Smrg echo "*** libtool will only create a static version of it." 798242a55b46Smrg if test "$build_old_libs" = no; then 798342a55b46Smrg oldlibs="$output_objdir/$libname.$libext" 798442a55b46Smrg build_libtool_libs=module 798542a55b46Smrg build_old_libs=yes 798642a55b46Smrg else 798742a55b46Smrg build_libtool_libs=no 798842a55b46Smrg fi 798942a55b46Smrg fi 799042a55b46Smrg fi 7991c582b7e3Smrg fi 799242a55b46Smrg # Done checking deplibs! 799342a55b46Smrg deplibs=$newdeplibs 799442a55b46Smrg fi 799542a55b46Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 799642a55b46Smrg case $host in 799742a55b46Smrg *-*-darwin*) 799842a55b46Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 799942a55b46Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 800042a55b46Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 800142a55b46Smrg ;; 800242a55b46Smrg esac 8003c582b7e3Smrg 800442a55b46Smrg # move library search paths that coincide with paths to not yet 800542a55b46Smrg # installed libraries to the beginning of the library search list 800642a55b46Smrg new_libs= 800742a55b46Smrg for path in $notinst_path; do 800842a55b46Smrg case " $new_libs " in 800942a55b46Smrg *" -L$path/$objdir "*) ;; 801042a55b46Smrg *) 801142a55b46Smrg case " $deplibs " in 801242a55b46Smrg *" -L$path/$objdir "*) 801342a55b46Smrg func_append new_libs " -L$path/$objdir" ;; 801442a55b46Smrg esac 801542a55b46Smrg ;; 801642a55b46Smrg esac 801742a55b46Smrg done 801842a55b46Smrg for deplib in $deplibs; do 801942a55b46Smrg case $deplib in 802042a55b46Smrg -L*) 802142a55b46Smrg case " $new_libs " in 802242a55b46Smrg *" $deplib "*) ;; 802342a55b46Smrg *) func_append new_libs " $deplib" ;; 802442a55b46Smrg esac 802542a55b46Smrg ;; 802642a55b46Smrg *) func_append new_libs " $deplib" ;; 802742a55b46Smrg esac 802842a55b46Smrg done 802942a55b46Smrg deplibs="$new_libs" 8030c582b7e3Smrg 803142a55b46Smrg # All the library-specific variables (install_libdir is set above). 803242a55b46Smrg library_names= 803342a55b46Smrg old_library= 803442a55b46Smrg dlname= 8035c582b7e3Smrg 803642a55b46Smrg # Test again, we may have decided not to build it any more 803742a55b46Smrg if test "$build_libtool_libs" = yes; then 803842a55b46Smrg # Remove ${wl} instances when linking with ld. 803942a55b46Smrg # FIXME: should test the right _cmds variable. 804042a55b46Smrg case $archive_cmds in 804142a55b46Smrg *\$LD\ *) wl= ;; 804242a55b46Smrg esac 804342a55b46Smrg if test "$hardcode_into_libs" = yes; then 804442a55b46Smrg # Hardcode the library paths 804542a55b46Smrg hardcode_libdirs= 804642a55b46Smrg dep_rpath= 804742a55b46Smrg rpath="$finalize_rpath" 804842a55b46Smrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 804942a55b46Smrg for libdir in $rpath; do 805042a55b46Smrg if test -n "$hardcode_libdir_flag_spec"; then 805142a55b46Smrg if test -n "$hardcode_libdir_separator"; then 805242a55b46Smrg func_replace_sysroot "$libdir" 805342a55b46Smrg libdir=$func_replace_sysroot_result 805442a55b46Smrg if test -z "$hardcode_libdirs"; then 805542a55b46Smrg hardcode_libdirs="$libdir" 805642a55b46Smrg else 805742a55b46Smrg # Just accumulate the unique libdirs. 805842a55b46Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 805942a55b46Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 806042a55b46Smrg ;; 806142a55b46Smrg *) 806242a55b46Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 806342a55b46Smrg ;; 806442a55b46Smrg esac 806542a55b46Smrg fi 806642a55b46Smrg else 806742a55b46Smrg eval flag=\"$hardcode_libdir_flag_spec\" 806842a55b46Smrg func_append dep_rpath " $flag" 806942a55b46Smrg fi 807042a55b46Smrg elif test -n "$runpath_var"; then 807142a55b46Smrg case "$perm_rpath " in 807242a55b46Smrg *" $libdir "*) ;; 807342a55b46Smrg *) func_append perm_rpath " $libdir" ;; 807442a55b46Smrg esac 807542a55b46Smrg fi 807642a55b46Smrg done 807742a55b46Smrg # Substitute the hardcoded libdirs into the rpath. 807842a55b46Smrg if test -n "$hardcode_libdir_separator" && 807942a55b46Smrg test -n "$hardcode_libdirs"; then 808042a55b46Smrg libdir="$hardcode_libdirs" 808142a55b46Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 808242a55b46Smrg fi 808342a55b46Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 808442a55b46Smrg # We should set the runpath_var. 808542a55b46Smrg rpath= 808642a55b46Smrg for dir in $perm_rpath; do 808742a55b46Smrg func_append rpath "$dir:" 808842a55b46Smrg done 808942a55b46Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 809042a55b46Smrg fi 809142a55b46Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 8092c582b7e3Smrg fi 8093c582b7e3Smrg 809442a55b46Smrg shlibpath="$finalize_shlibpath" 809542a55b46Smrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 809642a55b46Smrg if test -n "$shlibpath"; then 809742a55b46Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 8098c582b7e3Smrg fi 8099c582b7e3Smrg 810042a55b46Smrg # Get the real and link names of the library. 810142a55b46Smrg eval shared_ext=\"$shrext_cmds\" 810242a55b46Smrg eval library_names=\"$library_names_spec\" 810342a55b46Smrg set dummy $library_names 810442a55b46Smrg shift 810542a55b46Smrg realname="$1" 810642a55b46Smrg shift 8107c582b7e3Smrg 810842a55b46Smrg if test -n "$soname_spec"; then 810942a55b46Smrg eval soname=\"$soname_spec\" 8110c582b7e3Smrg else 811142a55b46Smrg soname="$realname" 811242a55b46Smrg fi 811342a55b46Smrg if test -z "$dlname"; then 811442a55b46Smrg dlname=$soname 8115c582b7e3Smrg fi 8116c582b7e3Smrg 811742a55b46Smrg lib="$output_objdir/$realname" 811842a55b46Smrg linknames= 811942a55b46Smrg for link 812042a55b46Smrg do 812142a55b46Smrg func_append linknames " $link" 812242a55b46Smrg done 8123c582b7e3Smrg 812442a55b46Smrg # Use standard objects if they are pic 812542a55b46Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 812642a55b46Smrg test "X$libobjs" = "X " && libobjs= 8127c582b7e3Smrg 812842a55b46Smrg delfiles= 812942a55b46Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 813042a55b46Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 813142a55b46Smrg export_symbols="$output_objdir/$libname.uexp" 813242a55b46Smrg func_append delfiles " $export_symbols" 813342a55b46Smrg fi 8134c582b7e3Smrg 813542a55b46Smrg orig_export_symbols= 813642a55b46Smrg case $host_os in 813742a55b46Smrg cygwin* | mingw* | cegcc*) 813842a55b46Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 813942a55b46Smrg # exporting using user supplied symfile 814042a55b46Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 814142a55b46Smrg # and it's NOT already a .def file. Must figure out 814242a55b46Smrg # which of the given symbols are data symbols and tag 814342a55b46Smrg # them as such. So, trigger use of export_symbols_cmds. 814442a55b46Smrg # export_symbols gets reassigned inside the "prepare 814542a55b46Smrg # the list of exported symbols" if statement, so the 814642a55b46Smrg # include_expsyms logic still works. 814742a55b46Smrg orig_export_symbols="$export_symbols" 814842a55b46Smrg export_symbols= 814942a55b46Smrg always_export_symbols=yes 8150c582b7e3Smrg fi 8151c582b7e3Smrg fi 815242a55b46Smrg ;; 815342a55b46Smrg esac 8154c582b7e3Smrg 815542a55b46Smrg # Prepare the list of exported symbols 815642a55b46Smrg if test -z "$export_symbols"; then 815742a55b46Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 815842a55b46Smrg func_verbose "generating symbol list for \`$libname.la'" 815942a55b46Smrg export_symbols="$output_objdir/$libname.exp" 816042a55b46Smrg $opt_dry_run || $RM $export_symbols 816142a55b46Smrg cmds=$export_symbols_cmds 816242a55b46Smrg save_ifs="$IFS"; IFS='~' 816342a55b46Smrg for cmd1 in $cmds; do 816442a55b46Smrg IFS="$save_ifs" 816542a55b46Smrg # Take the normal branch if the nm_file_list_spec branch 816642a55b46Smrg # doesn't work or if tool conversion is not needed. 816742a55b46Smrg case $nm_file_list_spec~$to_tool_file_cmd in 816842a55b46Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 816942a55b46Smrg try_normal_branch=yes 817042a55b46Smrg eval cmd=\"$cmd1\" 817142a55b46Smrg func_len " $cmd" 817242a55b46Smrg len=$func_len_result 817342a55b46Smrg ;; 817442a55b46Smrg *) 817542a55b46Smrg try_normal_branch=no 817642a55b46Smrg ;; 817742a55b46Smrg esac 817842a55b46Smrg if test "$try_normal_branch" = yes \ 817942a55b46Smrg && { test "$len" -lt "$max_cmd_len" \ 818042a55b46Smrg || test "$max_cmd_len" -le -1; } 818142a55b46Smrg then 818242a55b46Smrg func_show_eval "$cmd" 'exit $?' 818342a55b46Smrg skipped_export=false 818442a55b46Smrg elif test -n "$nm_file_list_spec"; then 818542a55b46Smrg func_basename "$output" 818642a55b46Smrg output_la=$func_basename_result 818742a55b46Smrg save_libobjs=$libobjs 818842a55b46Smrg save_output=$output 818942a55b46Smrg output=${output_objdir}/${output_la}.nm 819042a55b46Smrg func_to_tool_file "$output" 819142a55b46Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 819242a55b46Smrg func_append delfiles " $output" 819342a55b46Smrg func_verbose "creating $NM input file list: $output" 819442a55b46Smrg for obj in $save_libobjs; do 819542a55b46Smrg func_to_tool_file "$obj" 819642a55b46Smrg $ECHO "$func_to_tool_file_result" 819742a55b46Smrg done > "$output" 819842a55b46Smrg eval cmd=\"$cmd1\" 819942a55b46Smrg func_show_eval "$cmd" 'exit $?' 820042a55b46Smrg output=$save_output 820142a55b46Smrg libobjs=$save_libobjs 820242a55b46Smrg skipped_export=false 820342a55b46Smrg else 820442a55b46Smrg # The command line is too long to execute in one step. 820542a55b46Smrg func_verbose "using reloadable object file for export list..." 820642a55b46Smrg skipped_export=: 820742a55b46Smrg # Break out early, otherwise skipped_export may be 820842a55b46Smrg # set to false by a later but shorter cmd. 820942a55b46Smrg break 821042a55b46Smrg fi 821142a55b46Smrg done 821242a55b46Smrg IFS="$save_ifs" 821342a55b46Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 821442a55b46Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 821542a55b46Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 821642a55b46Smrg fi 821742a55b46Smrg fi 821842a55b46Smrg fi 821942a55b46Smrg 822042a55b46Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 822142a55b46Smrg tmp_export_symbols="$export_symbols" 822242a55b46Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 822342a55b46Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8224c582b7e3Smrg fi 8225c582b7e3Smrg 822642a55b46Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 822742a55b46Smrg # The given exports_symbols file has to be filtered, so filter it. 822842a55b46Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 822942a55b46Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 823042a55b46Smrg # 's' commands which not all seds can handle. GNU sed should be fine 823142a55b46Smrg # though. Also, the filter scales superlinearly with the number of 823242a55b46Smrg # global variables. join(1) would be nice here, but unfortunately 823342a55b46Smrg # isn't a blessed tool. 823442a55b46Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 823542a55b46Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 823642a55b46Smrg export_symbols=$output_objdir/$libname.def 823742a55b46Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 823842a55b46Smrg fi 8239c582b7e3Smrg 824042a55b46Smrg tmp_deplibs= 824142a55b46Smrg for test_deplib in $deplibs; do 824242a55b46Smrg case " $convenience " in 824342a55b46Smrg *" $test_deplib "*) ;; 824442a55b46Smrg *) 824542a55b46Smrg func_append tmp_deplibs " $test_deplib" 824642a55b46Smrg ;; 824742a55b46Smrg esac 824842a55b46Smrg done 824942a55b46Smrg deplibs="$tmp_deplibs" 8250c582b7e3Smrg 825142a55b46Smrg if test -n "$convenience"; then 825242a55b46Smrg if test -n "$whole_archive_flag_spec" && 825342a55b46Smrg test "$compiler_needs_object" = yes && 825442a55b46Smrg test -z "$libobjs"; then 825542a55b46Smrg # extract the archives, so we have objects to list. 825642a55b46Smrg # TODO: could optimize this to just extract one archive. 825742a55b46Smrg whole_archive_flag_spec= 825842a55b46Smrg fi 825942a55b46Smrg if test -n "$whole_archive_flag_spec"; then 826042a55b46Smrg save_libobjs=$libobjs 826142a55b46Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 826242a55b46Smrg test "X$libobjs" = "X " && libobjs= 8263c582b7e3Smrg else 826442a55b46Smrg gentop="$output_objdir/${outputname}x" 826542a55b46Smrg func_append generated " $gentop" 826642a55b46Smrg 826742a55b46Smrg func_extract_archives $gentop $convenience 826842a55b46Smrg func_append libobjs " $func_extract_archives_result" 826942a55b46Smrg test "X$libobjs" = "X " && libobjs= 8270c582b7e3Smrg fi 8271c582b7e3Smrg fi 8272c582b7e3Smrg 827342a55b46Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 827442a55b46Smrg eval flag=\"$thread_safe_flag_spec\" 827542a55b46Smrg func_append linker_flags " $flag" 827642a55b46Smrg fi 8277c582b7e3Smrg 827842a55b46Smrg # Make a backup of the uninstalled library when relinking 827942a55b46Smrg if test "$opt_mode" = relink; then 828042a55b46Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 828142a55b46Smrg fi 8282c582b7e3Smrg 828342a55b46Smrg # Do each of the archive commands. 828442a55b46Smrg if test "$module" = yes && test -n "$module_cmds" ; then 828542a55b46Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 828642a55b46Smrg eval test_cmds=\"$module_expsym_cmds\" 828742a55b46Smrg cmds=$module_expsym_cmds 828842a55b46Smrg else 828942a55b46Smrg eval test_cmds=\"$module_cmds\" 829042a55b46Smrg cmds=$module_cmds 829142a55b46Smrg fi 8292c582b7e3Smrg else 829342a55b46Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 829442a55b46Smrg eval test_cmds=\"$archive_expsym_cmds\" 829542a55b46Smrg cmds=$archive_expsym_cmds 829642a55b46Smrg else 829742a55b46Smrg eval test_cmds=\"$archive_cmds\" 829842a55b46Smrg cmds=$archive_cmds 829942a55b46Smrg fi 8300c582b7e3Smrg fi 8301c582b7e3Smrg 830242a55b46Smrg if test "X$skipped_export" != "X:" && 830342a55b46Smrg func_len " $test_cmds" && 830442a55b46Smrg len=$func_len_result && 830542a55b46Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 830642a55b46Smrg : 830742a55b46Smrg else 830842a55b46Smrg # The command line is too long to link in one step, link piecewise 830942a55b46Smrg # or, if using GNU ld and skipped_export is not :, use a linker 831042a55b46Smrg # script. 8311c582b7e3Smrg 831242a55b46Smrg # Save the value of $output and $libobjs because we want to 831342a55b46Smrg # use them later. If we have whole_archive_flag_spec, we 831442a55b46Smrg # want to use save_libobjs as it was before 831542a55b46Smrg # whole_archive_flag_spec was expanded, because we can't 831642a55b46Smrg # assume the linker understands whole_archive_flag_spec. 831742a55b46Smrg # This may have to be revisited, in case too many 831842a55b46Smrg # convenience libraries get linked in and end up exceeding 831942a55b46Smrg # the spec. 832042a55b46Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 832142a55b46Smrg save_libobjs=$libobjs 832242a55b46Smrg fi 832342a55b46Smrg save_output=$output 832442a55b46Smrg func_basename "$output" 832542a55b46Smrg output_la=$func_basename_result 832642a55b46Smrg 832742a55b46Smrg # Clear the reloadable object creation command queue and 832842a55b46Smrg # initialize k to one. 832942a55b46Smrg test_cmds= 833042a55b46Smrg concat_cmds= 833142a55b46Smrg objlist= 833242a55b46Smrg last_robj= 833342a55b46Smrg k=1 833442a55b46Smrg 833542a55b46Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 833642a55b46Smrg output=${output_objdir}/${output_la}.lnkscript 833742a55b46Smrg func_verbose "creating GNU ld script: $output" 833842a55b46Smrg echo 'INPUT (' > $output 833942a55b46Smrg for obj in $save_libobjs 834042a55b46Smrg do 834142a55b46Smrg func_to_tool_file "$obj" 834242a55b46Smrg $ECHO "$func_to_tool_file_result" >> $output 834342a55b46Smrg done 834442a55b46Smrg echo ')' >> $output 834542a55b46Smrg func_append delfiles " $output" 834642a55b46Smrg func_to_tool_file "$output" 834742a55b46Smrg output=$func_to_tool_file_result 834842a55b46Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 834942a55b46Smrg output=${output_objdir}/${output_la}.lnk 835042a55b46Smrg func_verbose "creating linker input file list: $output" 835142a55b46Smrg : > $output 835242a55b46Smrg set x $save_libobjs 835342a55b46Smrg shift 835442a55b46Smrg firstobj= 835542a55b46Smrg if test "$compiler_needs_object" = yes; then 835642a55b46Smrg firstobj="$1 " 835742a55b46Smrg shift 8358c582b7e3Smrg fi 835942a55b46Smrg for obj 836042a55b46Smrg do 836142a55b46Smrg func_to_tool_file "$obj" 836242a55b46Smrg $ECHO "$func_to_tool_file_result" >> $output 8363c582b7e3Smrg done 836442a55b46Smrg func_append delfiles " $output" 836542a55b46Smrg func_to_tool_file "$output" 836642a55b46Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 836742a55b46Smrg else 836842a55b46Smrg if test -n "$save_libobjs"; then 836942a55b46Smrg func_verbose "creating reloadable object files..." 837042a55b46Smrg output=$output_objdir/$output_la-${k}.$objext 837142a55b46Smrg eval test_cmds=\"$reload_cmds\" 837242a55b46Smrg func_len " $test_cmds" 837342a55b46Smrg len0=$func_len_result 837442a55b46Smrg len=$len0 837542a55b46Smrg 837642a55b46Smrg # Loop over the list of objects to be linked. 837742a55b46Smrg for obj in $save_libobjs 837842a55b46Smrg do 837942a55b46Smrg func_len " $obj" 838042a55b46Smrg func_arith $len + $func_len_result 838142a55b46Smrg len=$func_arith_result 838242a55b46Smrg if test "X$objlist" = X || 838342a55b46Smrg test "$len" -lt "$max_cmd_len"; then 838442a55b46Smrg func_append objlist " $obj" 838542a55b46Smrg else 838642a55b46Smrg # The command $test_cmds is almost too long, add a 838742a55b46Smrg # command to the queue. 838842a55b46Smrg if test "$k" -eq 1 ; then 838942a55b46Smrg # The first file doesn't have a previous command to add. 839042a55b46Smrg reload_objs=$objlist 839142a55b46Smrg eval concat_cmds=\"$reload_cmds\" 839242a55b46Smrg else 839342a55b46Smrg # All subsequent reloadable object files will link in 839442a55b46Smrg # the last one created. 839542a55b46Smrg reload_objs="$objlist $last_robj" 839642a55b46Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 839742a55b46Smrg fi 839842a55b46Smrg last_robj=$output_objdir/$output_la-${k}.$objext 839942a55b46Smrg func_arith $k + 1 840042a55b46Smrg k=$func_arith_result 840142a55b46Smrg output=$output_objdir/$output_la-${k}.$objext 840242a55b46Smrg objlist=" $obj" 840342a55b46Smrg func_len " $last_robj" 840442a55b46Smrg func_arith $len0 + $func_len_result 840542a55b46Smrg len=$func_arith_result 840642a55b46Smrg fi 840742a55b46Smrg done 840842a55b46Smrg # Handle the remaining objects by creating one last 840942a55b46Smrg # reloadable object file. All subsequent reloadable object 841042a55b46Smrg # files will link in the last one created. 841142a55b46Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 841242a55b46Smrg reload_objs="$objlist $last_robj" 841342a55b46Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 841442a55b46Smrg if test -n "$last_robj"; then 841542a55b46Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 8416c582b7e3Smrg fi 841742a55b46Smrg func_append delfiles " $output" 841842a55b46Smrg 841942a55b46Smrg else 842042a55b46Smrg output= 842142a55b46Smrg fi 842242a55b46Smrg 842342a55b46Smrg if ${skipped_export-false}; then 842442a55b46Smrg func_verbose "generating symbol list for \`$libname.la'" 842542a55b46Smrg export_symbols="$output_objdir/$libname.exp" 842642a55b46Smrg $opt_dry_run || $RM $export_symbols 842742a55b46Smrg libobjs=$output 842842a55b46Smrg # Append the command to create the export file. 842942a55b46Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 843042a55b46Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 843142a55b46Smrg if test -n "$last_robj"; then 843242a55b46Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 8433c582b7e3Smrg fi 843442a55b46Smrg fi 843542a55b46Smrg 843642a55b46Smrg test -n "$save_libobjs" && 843742a55b46Smrg func_verbose "creating a temporary reloadable object file: $output" 843842a55b46Smrg 843942a55b46Smrg # Loop through the commands generated above and execute them. 844042a55b46Smrg save_ifs="$IFS"; IFS='~' 844142a55b46Smrg for cmd in $concat_cmds; do 844242a55b46Smrg IFS="$save_ifs" 844342a55b46Smrg $opt_silent || { 844442a55b46Smrg func_quote_for_expand "$cmd" 844542a55b46Smrg eval "func_echo $func_quote_for_expand_result" 844642a55b46Smrg } 844742a55b46Smrg $opt_dry_run || eval "$cmd" || { 844842a55b46Smrg lt_exit=$? 844942a55b46Smrg 845042a55b46Smrg # Restore the uninstalled library and exit 845142a55b46Smrg if test "$opt_mode" = relink; then 845242a55b46Smrg ( cd "$output_objdir" && \ 845342a55b46Smrg $RM "${realname}T" && \ 845442a55b46Smrg $MV "${realname}U" "$realname" ) 845542a55b46Smrg fi 845642a55b46Smrg 845742a55b46Smrg exit $lt_exit 845842a55b46Smrg } 8459c582b7e3Smrg done 846042a55b46Smrg IFS="$save_ifs" 846142a55b46Smrg 846242a55b46Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 846342a55b46Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 846442a55b46Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 846542a55b46Smrg fi 846642a55b46Smrg fi 846742a55b46Smrg 846842a55b46Smrg if ${skipped_export-false}; then 846942a55b46Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 847042a55b46Smrg tmp_export_symbols="$export_symbols" 847142a55b46Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 847242a55b46Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 847342a55b46Smrg fi 847442a55b46Smrg 847542a55b46Smrg if test -n "$orig_export_symbols"; then 847642a55b46Smrg # The given exports_symbols file has to be filtered, so filter it. 847742a55b46Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 847842a55b46Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 847942a55b46Smrg # 's' commands which not all seds can handle. GNU sed should be fine 848042a55b46Smrg # though. Also, the filter scales superlinearly with the number of 848142a55b46Smrg # global variables. join(1) would be nice here, but unfortunately 848242a55b46Smrg # isn't a blessed tool. 848342a55b46Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 848442a55b46Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 848542a55b46Smrg export_symbols=$output_objdir/$libname.def 848642a55b46Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 848742a55b46Smrg fi 848842a55b46Smrg fi 848942a55b46Smrg 849042a55b46Smrg libobjs=$output 849142a55b46Smrg # Restore the value of output. 849242a55b46Smrg output=$save_output 849342a55b46Smrg 849442a55b46Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 849542a55b46Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 849642a55b46Smrg test "X$libobjs" = "X " && libobjs= 849742a55b46Smrg fi 849842a55b46Smrg # Expand the library linking commands again to reset the 849942a55b46Smrg # value of $libobjs for piecewise linking. 850042a55b46Smrg 850142a55b46Smrg # Do each of the archive commands. 850242a55b46Smrg if test "$module" = yes && test -n "$module_cmds" ; then 850342a55b46Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 850442a55b46Smrg cmds=$module_expsym_cmds 850542a55b46Smrg else 850642a55b46Smrg cmds=$module_cmds 850742a55b46Smrg fi 8508c582b7e3Smrg else 850942a55b46Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 851042a55b46Smrg cmds=$archive_expsym_cmds 851142a55b46Smrg else 851242a55b46Smrg cmds=$archive_cmds 851342a55b46Smrg fi 8514c582b7e3Smrg fi 851542a55b46Smrg fi 8516c582b7e3Smrg 851742a55b46Smrg if test -n "$delfiles"; then 851842a55b46Smrg # Append the command to remove temporary files to $cmds. 851942a55b46Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 852042a55b46Smrg fi 8521c582b7e3Smrg 852242a55b46Smrg # Add any objects from preloaded convenience libraries 852342a55b46Smrg if test -n "$dlprefiles"; then 852442a55b46Smrg gentop="$output_objdir/${outputname}x" 852542a55b46Smrg func_append generated " $gentop" 8526c582b7e3Smrg 852742a55b46Smrg func_extract_archives $gentop $dlprefiles 852842a55b46Smrg func_append libobjs " $func_extract_archives_result" 852942a55b46Smrg test "X$libobjs" = "X " && libobjs= 853042a55b46Smrg fi 8531c582b7e3Smrg 853242a55b46Smrg save_ifs="$IFS"; IFS='~' 853342a55b46Smrg for cmd in $cmds; do 853442a55b46Smrg IFS="$save_ifs" 853542a55b46Smrg eval cmd=\"$cmd\" 853642a55b46Smrg $opt_silent || { 853742a55b46Smrg func_quote_for_expand "$cmd" 853842a55b46Smrg eval "func_echo $func_quote_for_expand_result" 853942a55b46Smrg } 854042a55b46Smrg $opt_dry_run || eval "$cmd" || { 854142a55b46Smrg lt_exit=$? 8542c582b7e3Smrg 854342a55b46Smrg # Restore the uninstalled library and exit 854442a55b46Smrg if test "$opt_mode" = relink; then 854542a55b46Smrg ( cd "$output_objdir" && \ 854642a55b46Smrg $RM "${realname}T" && \ 854742a55b46Smrg $MV "${realname}U" "$realname" ) 854842a55b46Smrg fi 8549c582b7e3Smrg 855042a55b46Smrg exit $lt_exit 855142a55b46Smrg } 855242a55b46Smrg done 855342a55b46Smrg IFS="$save_ifs" 8554c582b7e3Smrg 855542a55b46Smrg # Restore the uninstalled library and exit 855642a55b46Smrg if test "$opt_mode" = relink; then 855742a55b46Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 8558c582b7e3Smrg 855942a55b46Smrg if test -n "$convenience"; then 856042a55b46Smrg if test -z "$whole_archive_flag_spec"; then 856142a55b46Smrg func_show_eval '${RM}r "$gentop"' 856242a55b46Smrg fi 856342a55b46Smrg fi 8564c582b7e3Smrg 856542a55b46Smrg exit $EXIT_SUCCESS 856642a55b46Smrg fi 856742a55b46Smrg 856842a55b46Smrg # Create links to the real library. 856942a55b46Smrg for linkname in $linknames; do 857042a55b46Smrg if test "$realname" != "$linkname"; then 857142a55b46Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 8572c582b7e3Smrg fi 8573c582b7e3Smrg done 8574c582b7e3Smrg 857542a55b46Smrg # If -module or -export-dynamic was specified, set the dlname. 857642a55b46Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 857742a55b46Smrg # On all known operating systems, these are identical. 857842a55b46Smrg dlname="$soname" 857942a55b46Smrg fi 858042a55b46Smrg fi 8581c582b7e3Smrg ;; 8582c582b7e3Smrg 858342a55b46Smrg obj) 858442a55b46Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 858542a55b46Smrg func_warning "\`-dlopen' is ignored for objects" 858642a55b46Smrg fi 8587c582b7e3Smrg 858842a55b46Smrg case " $deplibs" in 858942a55b46Smrg *\ -l* | *\ -L*) 859042a55b46Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 8591c582b7e3Smrg esac 8592c582b7e3Smrg 859342a55b46Smrg test -n "$rpath" && \ 859442a55b46Smrg func_warning "\`-rpath' is ignored for objects" 8595c582b7e3Smrg 859642a55b46Smrg test -n "$xrpath" && \ 859742a55b46Smrg func_warning "\`-R' is ignored for objects" 8598c582b7e3Smrg 859942a55b46Smrg test -n "$vinfo" && \ 860042a55b46Smrg func_warning "\`-version-info' is ignored for objects" 860142a55b46Smrg 860242a55b46Smrg test -n "$release" && \ 860342a55b46Smrg func_warning "\`-release' is ignored for objects" 860442a55b46Smrg 860542a55b46Smrg case $output in 860642a55b46Smrg *.lo) 860742a55b46Smrg test -n "$objs$old_deplibs" && \ 860842a55b46Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 860942a55b46Smrg 861042a55b46Smrg libobj=$output 861142a55b46Smrg func_lo2o "$libobj" 861242a55b46Smrg obj=$func_lo2o_result 8613c582b7e3Smrg ;; 8614c582b7e3Smrg *) 861542a55b46Smrg libobj= 861642a55b46Smrg obj="$output" 8617c582b7e3Smrg ;; 8618c582b7e3Smrg esac 8619c582b7e3Smrg 862042a55b46Smrg # Delete the old objects. 862142a55b46Smrg $opt_dry_run || $RM $obj $libobj 8622c582b7e3Smrg 862342a55b46Smrg # Objects from convenience libraries. This assumes 862442a55b46Smrg # single-version convenience libraries. Whenever we create 862542a55b46Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 862642a55b46Smrg # the extraction. 862742a55b46Smrg reload_conv_objs= 862842a55b46Smrg gentop= 862942a55b46Smrg # reload_cmds runs $LD directly, so let us get rid of 863042a55b46Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 863142a55b46Smrg # turning comma into space.. 863242a55b46Smrg wl= 8633c582b7e3Smrg 863442a55b46Smrg if test -n "$convenience"; then 863542a55b46Smrg if test -n "$whole_archive_flag_spec"; then 863642a55b46Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 863742a55b46Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 863842a55b46Smrg else 863942a55b46Smrg gentop="$output_objdir/${obj}x" 864042a55b46Smrg func_append generated " $gentop" 8641c582b7e3Smrg 864242a55b46Smrg func_extract_archives $gentop $convenience 864342a55b46Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 864442a55b46Smrg fi 8645c582b7e3Smrg fi 8646c582b7e3Smrg 864742a55b46Smrg # If we're not building shared, we need to use non_pic_objs 864842a55b46Smrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 8649c582b7e3Smrg 865042a55b46Smrg # Create the old-style object. 865142a55b46Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 8652c582b7e3Smrg 865342a55b46Smrg output="$obj" 865442a55b46Smrg func_execute_cmds "$reload_cmds" 'exit $?' 865542a55b46Smrg 865642a55b46Smrg # Exit if we aren't doing a library object file. 865742a55b46Smrg if test -z "$libobj"; then 865842a55b46Smrg if test -n "$gentop"; then 865942a55b46Smrg func_show_eval '${RM}r "$gentop"' 866042a55b46Smrg fi 866142a55b46Smrg 866242a55b46Smrg exit $EXIT_SUCCESS 8663c582b7e3Smrg fi 866442a55b46Smrg 866542a55b46Smrg if test "$build_libtool_libs" != yes; then 866642a55b46Smrg if test -n "$gentop"; then 866742a55b46Smrg func_show_eval '${RM}r "$gentop"' 866842a55b46Smrg fi 866942a55b46Smrg 867042a55b46Smrg # Create an invalid libtool object if no PIC, so that we don't 867142a55b46Smrg # accidentally link it into a program. 867242a55b46Smrg # $show "echo timestamp > $libobj" 867342a55b46Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 867442a55b46Smrg exit $EXIT_SUCCESS 867542a55b46Smrg fi 867642a55b46Smrg 867742a55b46Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 867842a55b46Smrg # Only do commands if we really have different PIC objects. 867942a55b46Smrg reload_objs="$libobjs $reload_conv_objs" 868042a55b46Smrg output="$libobj" 868142a55b46Smrg func_execute_cmds "$reload_cmds" 'exit $?' 868242a55b46Smrg fi 868342a55b46Smrg 868442a55b46Smrg if test -n "$gentop"; then 868542a55b46Smrg func_show_eval '${RM}r "$gentop"' 868642a55b46Smrg fi 868742a55b46Smrg 868842a55b46Smrg exit $EXIT_SUCCESS 8689c582b7e3Smrg ;; 8690c582b7e3Smrg 869142a55b46Smrg prog) 869242a55b46Smrg case $host in 869342a55b46Smrg *cygwin*) func_stripname '' '.exe' "$output" 869442a55b46Smrg output=$func_stripname_result.exe;; 869542a55b46Smrg esac 869642a55b46Smrg test -n "$vinfo" && \ 869742a55b46Smrg func_warning "\`-version-info' is ignored for programs" 8698c582b7e3Smrg 869942a55b46Smrg test -n "$release" && \ 870042a55b46Smrg func_warning "\`-release' is ignored for programs" 8701c582b7e3Smrg 870242a55b46Smrg test "$preload" = yes \ 870342a55b46Smrg && test "$dlopen_support" = unknown \ 870442a55b46Smrg && test "$dlopen_self" = unknown \ 870542a55b46Smrg && test "$dlopen_self_static" = unknown && \ 870642a55b46Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 870742a55b46Smrg 870842a55b46Smrg case $host in 870942a55b46Smrg *-*-rhapsody* | *-*-darwin1.[012]) 871042a55b46Smrg # On Rhapsody replace the C library is the System framework 871142a55b46Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 871242a55b46Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 8713c582b7e3Smrg ;; 871442a55b46Smrg esac 8715c582b7e3Smrg 871642a55b46Smrg case $host in 871742a55b46Smrg *-*-darwin*) 871842a55b46Smrg # Don't allow lazy linking, it breaks C++ global constructors 871942a55b46Smrg # But is supposedly fixed on 10.4 or later (yay!). 872042a55b46Smrg if test "$tagname" = CXX ; then 872142a55b46Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 872242a55b46Smrg 10.[0123]) 872342a55b46Smrg func_append compile_command " ${wl}-bind_at_load" 872442a55b46Smrg func_append finalize_command " ${wl}-bind_at_load" 872542a55b46Smrg ;; 872642a55b46Smrg esac 8727c582b7e3Smrg fi 872842a55b46Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 872942a55b46Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 873042a55b46Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 873142a55b46Smrg ;; 873242a55b46Smrg esac 8733c582b7e3Smrg 8734c582b7e3Smrg 873542a55b46Smrg # move library search paths that coincide with paths to not yet 873642a55b46Smrg # installed libraries to the beginning of the library search list 873742a55b46Smrg new_libs= 873842a55b46Smrg for path in $notinst_path; do 873942a55b46Smrg case " $new_libs " in 874042a55b46Smrg *" -L$path/$objdir "*) ;; 874142a55b46Smrg *) 874242a55b46Smrg case " $compile_deplibs " in 874342a55b46Smrg *" -L$path/$objdir "*) 874442a55b46Smrg func_append new_libs " -L$path/$objdir" ;; 8745c582b7e3Smrg esac 874642a55b46Smrg ;; 874742a55b46Smrg esac 874842a55b46Smrg done 874942a55b46Smrg for deplib in $compile_deplibs; do 875042a55b46Smrg case $deplib in 875142a55b46Smrg -L*) 875242a55b46Smrg case " $new_libs " in 875342a55b46Smrg *" $deplib "*) ;; 875442a55b46Smrg *) func_append new_libs " $deplib" ;; 8755c582b7e3Smrg esac 875642a55b46Smrg ;; 875742a55b46Smrg *) func_append new_libs " $deplib" ;; 875842a55b46Smrg esac 875942a55b46Smrg done 876042a55b46Smrg compile_deplibs="$new_libs" 8761c582b7e3Smrg 8762c582b7e3Smrg 876342a55b46Smrg func_append compile_command " $compile_deplibs" 876442a55b46Smrg func_append finalize_command " $finalize_deplibs" 8765c582b7e3Smrg 876642a55b46Smrg if test -n "$rpath$xrpath"; then 876742a55b46Smrg # If the user specified any rpath flags, then add them. 876842a55b46Smrg for libdir in $rpath $xrpath; do 876942a55b46Smrg # This is the magic to use -rpath. 877042a55b46Smrg case "$finalize_rpath " in 877142a55b46Smrg *" $libdir "*) ;; 877242a55b46Smrg *) func_append finalize_rpath " $libdir" ;; 877342a55b46Smrg esac 877442a55b46Smrg done 877542a55b46Smrg fi 8776c582b7e3Smrg 877742a55b46Smrg # Now hardcode the library paths 877842a55b46Smrg rpath= 877942a55b46Smrg hardcode_libdirs= 878042a55b46Smrg for libdir in $compile_rpath $finalize_rpath; do 878142a55b46Smrg if test -n "$hardcode_libdir_flag_spec"; then 878242a55b46Smrg if test -n "$hardcode_libdir_separator"; then 878342a55b46Smrg if test -z "$hardcode_libdirs"; then 878442a55b46Smrg hardcode_libdirs="$libdir" 878542a55b46Smrg else 878642a55b46Smrg # Just accumulate the unique libdirs. 878742a55b46Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 878842a55b46Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 878942a55b46Smrg ;; 879042a55b46Smrg *) 879142a55b46Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 879242a55b46Smrg ;; 879342a55b46Smrg esac 879442a55b46Smrg fi 8795c582b7e3Smrg else 879642a55b46Smrg eval flag=\"$hardcode_libdir_flag_spec\" 879742a55b46Smrg func_append rpath " $flag" 8798c582b7e3Smrg fi 879942a55b46Smrg elif test -n "$runpath_var"; then 880042a55b46Smrg case "$perm_rpath " in 880142a55b46Smrg *" $libdir "*) ;; 880242a55b46Smrg *) func_append perm_rpath " $libdir" ;; 880342a55b46Smrg esac 880442a55b46Smrg fi 880542a55b46Smrg case $host in 880642a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 880742a55b46Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 880842a55b46Smrg case :$dllsearchpath: in 880942a55b46Smrg *":$libdir:"*) ;; 881042a55b46Smrg ::) dllsearchpath=$libdir;; 881142a55b46Smrg *) func_append dllsearchpath ":$libdir";; 881242a55b46Smrg esac 881342a55b46Smrg case :$dllsearchpath: in 881442a55b46Smrg *":$testbindir:"*) ;; 881542a55b46Smrg ::) dllsearchpath=$testbindir;; 881642a55b46Smrg *) func_append dllsearchpath ":$testbindir";; 881742a55b46Smrg esac 881842a55b46Smrg ;; 881942a55b46Smrg esac 882042a55b46Smrg done 882142a55b46Smrg # Substitute the hardcoded libdirs into the rpath. 882242a55b46Smrg if test -n "$hardcode_libdir_separator" && 882342a55b46Smrg test -n "$hardcode_libdirs"; then 882442a55b46Smrg libdir="$hardcode_libdirs" 882542a55b46Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 882642a55b46Smrg fi 882742a55b46Smrg compile_rpath="$rpath" 8828c582b7e3Smrg 882942a55b46Smrg rpath= 883042a55b46Smrg hardcode_libdirs= 883142a55b46Smrg for libdir in $finalize_rpath; do 883242a55b46Smrg if test -n "$hardcode_libdir_flag_spec"; then 883342a55b46Smrg if test -n "$hardcode_libdir_separator"; then 883442a55b46Smrg if test -z "$hardcode_libdirs"; then 883542a55b46Smrg hardcode_libdirs="$libdir" 883642a55b46Smrg else 883742a55b46Smrg # Just accumulate the unique libdirs. 883842a55b46Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 883942a55b46Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 884042a55b46Smrg ;; 884142a55b46Smrg *) 884242a55b46Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 884342a55b46Smrg ;; 884442a55b46Smrg esac 884542a55b46Smrg fi 8846c582b7e3Smrg else 884742a55b46Smrg eval flag=\"$hardcode_libdir_flag_spec\" 884842a55b46Smrg func_append rpath " $flag" 8849c582b7e3Smrg fi 885042a55b46Smrg elif test -n "$runpath_var"; then 885142a55b46Smrg case "$finalize_perm_rpath " in 885242a55b46Smrg *" $libdir "*) ;; 885342a55b46Smrg *) func_append finalize_perm_rpath " $libdir" ;; 885442a55b46Smrg esac 8855c582b7e3Smrg fi 885642a55b46Smrg done 885742a55b46Smrg # Substitute the hardcoded libdirs into the rpath. 885842a55b46Smrg if test -n "$hardcode_libdir_separator" && 885942a55b46Smrg test -n "$hardcode_libdirs"; then 886042a55b46Smrg libdir="$hardcode_libdirs" 886142a55b46Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 886242a55b46Smrg fi 886342a55b46Smrg finalize_rpath="$rpath" 8864c582b7e3Smrg 886542a55b46Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 886642a55b46Smrg # Transform all the library objects into standard objects. 886742a55b46Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 886842a55b46Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 886942a55b46Smrg fi 8870c582b7e3Smrg 887142a55b46Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8872c582b7e3Smrg 887342a55b46Smrg # template prelinking step 887442a55b46Smrg if test -n "$prelink_cmds"; then 887542a55b46Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 887642a55b46Smrg fi 8877c582b7e3Smrg 887842a55b46Smrg wrappers_required=yes 887942a55b46Smrg case $host in 888042a55b46Smrg *cegcc* | *mingw32ce*) 888142a55b46Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 888242a55b46Smrg wrappers_required=no 888342a55b46Smrg ;; 888442a55b46Smrg *cygwin* | *mingw* ) 888542a55b46Smrg if test "$build_libtool_libs" != yes; then 888642a55b46Smrg wrappers_required=no 888742a55b46Smrg fi 888842a55b46Smrg ;; 888942a55b46Smrg *) 889042a55b46Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 889142a55b46Smrg wrappers_required=no 889242a55b46Smrg fi 889342a55b46Smrg ;; 889442a55b46Smrg esac 889542a55b46Smrg if test "$wrappers_required" = no; then 889642a55b46Smrg # Replace the output file specification. 889742a55b46Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 889842a55b46Smrg link_command="$compile_command$compile_rpath" 8899c582b7e3Smrg 890042a55b46Smrg # We have no uninstalled library dependencies, so finalize right now. 890142a55b46Smrg exit_status=0 890242a55b46Smrg func_show_eval "$link_command" 'exit_status=$?' 8903c582b7e3Smrg 890442a55b46Smrg if test -n "$postlink_cmds"; then 890542a55b46Smrg func_to_tool_file "$output" 890642a55b46Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 890742a55b46Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 8908c582b7e3Smrg fi 8909c582b7e3Smrg 891042a55b46Smrg # Delete the generated files. 891142a55b46Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 891242a55b46Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 891342a55b46Smrg fi 8914c582b7e3Smrg 891542a55b46Smrg exit $exit_status 891642a55b46Smrg fi 8917c582b7e3Smrg 891842a55b46Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 891942a55b46Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 892042a55b46Smrg fi 892142a55b46Smrg if test -n "$finalize_shlibpath"; then 892242a55b46Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 892342a55b46Smrg fi 8924c582b7e3Smrg 892542a55b46Smrg compile_var= 892642a55b46Smrg finalize_var= 892742a55b46Smrg if test -n "$runpath_var"; then 892842a55b46Smrg if test -n "$perm_rpath"; then 892942a55b46Smrg # We should set the runpath_var. 893042a55b46Smrg rpath= 893142a55b46Smrg for dir in $perm_rpath; do 893242a55b46Smrg func_append rpath "$dir:" 893342a55b46Smrg done 893442a55b46Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8935c582b7e3Smrg fi 893642a55b46Smrg if test -n "$finalize_perm_rpath"; then 893742a55b46Smrg # We should set the runpath_var. 893842a55b46Smrg rpath= 893942a55b46Smrg for dir in $finalize_perm_rpath; do 894042a55b46Smrg func_append rpath "$dir:" 894142a55b46Smrg done 894242a55b46Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 8943c582b7e3Smrg fi 894442a55b46Smrg fi 8945c582b7e3Smrg 894642a55b46Smrg if test "$no_install" = yes; then 894742a55b46Smrg # We don't need to create a wrapper script. 894842a55b46Smrg link_command="$compile_var$compile_command$compile_rpath" 894942a55b46Smrg # Replace the output file specification. 895042a55b46Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 895142a55b46Smrg # Delete the old output file. 895242a55b46Smrg $opt_dry_run || $RM $output 895342a55b46Smrg # Link the executable and exit 895442a55b46Smrg func_show_eval "$link_command" 'exit $?' 8955c582b7e3Smrg 895642a55b46Smrg if test -n "$postlink_cmds"; then 895742a55b46Smrg func_to_tool_file "$output" 895842a55b46Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 895942a55b46Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 8960c582b7e3Smrg fi 896142a55b46Smrg 8962c582b7e3Smrg exit $EXIT_SUCCESS 896342a55b46Smrg fi 8964c582b7e3Smrg 896542a55b46Smrg if test "$hardcode_action" = relink; then 896642a55b46Smrg # Fast installation is not supported 896742a55b46Smrg link_command="$compile_var$compile_command$compile_rpath" 896842a55b46Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 896942a55b46Smrg 897042a55b46Smrg func_warning "this platform does not like uninstalled shared libraries" 897142a55b46Smrg func_warning "\`$output' will be relinked during installation" 897242a55b46Smrg else 897342a55b46Smrg if test "$fast_install" != no; then 897442a55b46Smrg link_command="$finalize_var$compile_command$finalize_rpath" 897542a55b46Smrg if test "$fast_install" = yes; then 897642a55b46Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 897742a55b46Smrg else 897842a55b46Smrg # fast_install is set to needless 897942a55b46Smrg relink_command= 898042a55b46Smrg fi 8981c582b7e3Smrg else 898242a55b46Smrg link_command="$compile_var$compile_command$compile_rpath" 898342a55b46Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8984c582b7e3Smrg fi 898542a55b46Smrg fi 8986c582b7e3Smrg 898742a55b46Smrg # Replace the output file specification. 898842a55b46Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 8989c582b7e3Smrg 899042a55b46Smrg # Delete the old output files. 899142a55b46Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 8992c582b7e3Smrg 899342a55b46Smrg func_show_eval "$link_command" 'exit $?' 8994c582b7e3Smrg 899542a55b46Smrg if test -n "$postlink_cmds"; then 899642a55b46Smrg func_to_tool_file "$output_objdir/$outputname" 899742a55b46Smrg 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'` 899842a55b46Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 899942a55b46Smrg fi 9000c582b7e3Smrg 900142a55b46Smrg # Now create the wrapper script. 900242a55b46Smrg func_verbose "creating $output" 9003c582b7e3Smrg 900442a55b46Smrg # Quote the relink command for shipping. 900542a55b46Smrg if test -n "$relink_command"; then 900642a55b46Smrg # Preserve any variables that may affect compiler behavior 900742a55b46Smrg for var in $variables_saved_for_relink; do 900842a55b46Smrg if eval test -z \"\${$var+set}\"; then 900942a55b46Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 901042a55b46Smrg elif eval var_value=\$$var; test -z "$var_value"; then 901142a55b46Smrg relink_command="$var=; export $var; $relink_command" 9012c582b7e3Smrg else 901342a55b46Smrg func_quote_for_eval "$var_value" 901442a55b46Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9015c582b7e3Smrg fi 901642a55b46Smrg done 901742a55b46Smrg relink_command="(cd `pwd`; $relink_command)" 901842a55b46Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 901942a55b46Smrg fi 902042a55b46Smrg 902142a55b46Smrg # Only actually do things if not in dry run mode. 902242a55b46Smrg $opt_dry_run || { 902342a55b46Smrg # win32 will think the script is a binary if it has 902442a55b46Smrg # a .exe suffix, so we strip it off here. 902542a55b46Smrg case $output in 902642a55b46Smrg *.exe) func_stripname '' '.exe' "$output" 902742a55b46Smrg output=$func_stripname_result ;; 9028c582b7e3Smrg esac 902942a55b46Smrg # test for cygwin because mv fails w/o .exe extensions 903042a55b46Smrg case $host in 903142a55b46Smrg *cygwin*) 903242a55b46Smrg exeext=.exe 903342a55b46Smrg func_stripname '' '.exe' "$outputname" 903442a55b46Smrg outputname=$func_stripname_result ;; 903542a55b46Smrg *) exeext= ;; 903642a55b46Smrg esac 903742a55b46Smrg case $host in 903842a55b46Smrg *cygwin* | *mingw* ) 903942a55b46Smrg func_dirname_and_basename "$output" "" "." 904042a55b46Smrg output_name=$func_basename_result 904142a55b46Smrg output_path=$func_dirname_result 904242a55b46Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 904342a55b46Smrg cwrapper="$output_path/$output_name.exe" 904442a55b46Smrg $RM $cwrappersource $cwrapper 904542a55b46Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 904642a55b46Smrg 904742a55b46Smrg func_emit_cwrapperexe_src > $cwrappersource 904842a55b46Smrg 904942a55b46Smrg # The wrapper executable is built using the $host compiler, 905042a55b46Smrg # because it contains $host paths and files. If cross- 905142a55b46Smrg # compiling, it, like the target executable, must be 905242a55b46Smrg # executed on the $host or under an emulation environment. 905342a55b46Smrg $opt_dry_run || { 905442a55b46Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 905542a55b46Smrg $STRIP $cwrapper 905642a55b46Smrg } 9057c582b7e3Smrg 905842a55b46Smrg # Now, create the wrapper script for func_source use: 905942a55b46Smrg func_ltwrapper_scriptname $cwrapper 906042a55b46Smrg $RM $func_ltwrapper_scriptname_result 906142a55b46Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 906242a55b46Smrg $opt_dry_run || { 906342a55b46Smrg # note: this script will not be executed, so do not chmod. 906442a55b46Smrg if test "x$build" = "x$host" ; then 906542a55b46Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 906642a55b46Smrg else 906742a55b46Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 906842a55b46Smrg fi 906942a55b46Smrg } 907042a55b46Smrg ;; 907142a55b46Smrg * ) 907242a55b46Smrg $RM $output 907342a55b46Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 9074c582b7e3Smrg 907542a55b46Smrg func_emit_wrapper no > $output 907642a55b46Smrg chmod +x $output 907742a55b46Smrg ;; 907842a55b46Smrg esac 907942a55b46Smrg } 908042a55b46Smrg exit $EXIT_SUCCESS 908142a55b46Smrg ;; 908242a55b46Smrg esac 9083c582b7e3Smrg 908442a55b46Smrg # See if we need to build an old-fashioned archive. 908542a55b46Smrg for oldlib in $oldlibs; do 9086c582b7e3Smrg 908742a55b46Smrg if test "$build_libtool_libs" = convenience; then 908842a55b46Smrg oldobjs="$libobjs_save $symfileobj" 908942a55b46Smrg addlibs="$convenience" 909042a55b46Smrg build_libtool_libs=no 909142a55b46Smrg else 909242a55b46Smrg if test "$build_libtool_libs" = module; then 909342a55b46Smrg oldobjs="$libobjs_save" 909442a55b46Smrg build_libtool_libs=no 909542a55b46Smrg else 909642a55b46Smrg oldobjs="$old_deplibs $non_pic_objects" 909742a55b46Smrg if test "$preload" = yes && test -f "$symfileobj"; then 909842a55b46Smrg func_append oldobjs " $symfileobj" 909942a55b46Smrg fi 910042a55b46Smrg fi 910142a55b46Smrg addlibs="$old_convenience" 9102c582b7e3Smrg fi 9103c582b7e3Smrg 910442a55b46Smrg if test -n "$addlibs"; then 910542a55b46Smrg gentop="$output_objdir/${outputname}x" 910642a55b46Smrg func_append generated " $gentop" 9107c582b7e3Smrg 910842a55b46Smrg func_extract_archives $gentop $addlibs 910942a55b46Smrg func_append oldobjs " $func_extract_archives_result" 911042a55b46Smrg fi 9111c582b7e3Smrg 911242a55b46Smrg # Do each command in the archive commands. 911342a55b46Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 911442a55b46Smrg cmds=$old_archive_from_new_cmds 911542a55b46Smrg else 9116c582b7e3Smrg 911742a55b46Smrg # Add any objects from preloaded convenience libraries 911842a55b46Smrg if test -n "$dlprefiles"; then 911942a55b46Smrg gentop="$output_objdir/${outputname}x" 912042a55b46Smrg func_append generated " $gentop" 9121c582b7e3Smrg 912242a55b46Smrg func_extract_archives $gentop $dlprefiles 912342a55b46Smrg func_append oldobjs " $func_extract_archives_result" 912442a55b46Smrg fi 9125c582b7e3Smrg 912642a55b46Smrg # POSIX demands no paths to be encoded in archives. We have 912742a55b46Smrg # to avoid creating archives with duplicate basenames if we 912842a55b46Smrg # might have to extract them afterwards, e.g., when creating a 912942a55b46Smrg # static archive out of a convenience library, or when linking 913042a55b46Smrg # the entirety of a libtool archive into another (currently 913142a55b46Smrg # not supported by libtool). 913242a55b46Smrg if (for obj in $oldobjs 913342a55b46Smrg do 913442a55b46Smrg func_basename "$obj" 913542a55b46Smrg $ECHO "$func_basename_result" 913642a55b46Smrg done | sort | sort -uc >/dev/null 2>&1); then 913742a55b46Smrg : 913842a55b46Smrg else 913942a55b46Smrg echo "copying selected object files to avoid basename conflicts..." 914042a55b46Smrg gentop="$output_objdir/${outputname}x" 914142a55b46Smrg func_append generated " $gentop" 914242a55b46Smrg func_mkdir_p "$gentop" 914342a55b46Smrg save_oldobjs=$oldobjs 914442a55b46Smrg oldobjs= 914542a55b46Smrg counter=1 914642a55b46Smrg for obj in $save_oldobjs 914742a55b46Smrg do 914842a55b46Smrg func_basename "$obj" 914942a55b46Smrg objbase="$func_basename_result" 915042a55b46Smrg case " $oldobjs " in 915142a55b46Smrg " ") oldobjs=$obj ;; 915242a55b46Smrg *[\ /]"$objbase "*) 915342a55b46Smrg while :; do 915442a55b46Smrg # Make sure we don't pick an alternate name that also 915542a55b46Smrg # overlaps. 915642a55b46Smrg newobj=lt$counter-$objbase 915742a55b46Smrg func_arith $counter + 1 915842a55b46Smrg counter=$func_arith_result 915942a55b46Smrg case " $oldobjs " in 916042a55b46Smrg *[\ /]"$newobj "*) ;; 916142a55b46Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 916242a55b46Smrg esac 916342a55b46Smrg done 916442a55b46Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 916542a55b46Smrg func_append oldobjs " $gentop/$newobj" 916642a55b46Smrg ;; 916742a55b46Smrg *) func_append oldobjs " $obj" ;; 916842a55b46Smrg esac 9169c582b7e3Smrg done 9170c582b7e3Smrg fi 917142a55b46Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 917242a55b46Smrg tool_oldlib=$func_to_tool_file_result 917342a55b46Smrg eval cmds=\"$old_archive_cmds\" 9174c582b7e3Smrg 917542a55b46Smrg func_len " $cmds" 917642a55b46Smrg len=$func_len_result 917742a55b46Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 917842a55b46Smrg cmds=$old_archive_cmds 917942a55b46Smrg elif test -n "$archiver_list_spec"; then 918042a55b46Smrg func_verbose "using command file archive linking..." 918142a55b46Smrg for obj in $oldobjs 918242a55b46Smrg do 918342a55b46Smrg func_to_tool_file "$obj" 918442a55b46Smrg $ECHO "$func_to_tool_file_result" 918542a55b46Smrg done > $output_objdir/$libname.libcmd 918642a55b46Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 918742a55b46Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 918842a55b46Smrg cmds=$old_archive_cmds 918942a55b46Smrg else 919042a55b46Smrg # the command line is too long to link in one step, link in parts 919142a55b46Smrg func_verbose "using piecewise archive linking..." 919242a55b46Smrg save_RANLIB=$RANLIB 919342a55b46Smrg RANLIB=: 919442a55b46Smrg objlist= 919542a55b46Smrg concat_cmds= 919642a55b46Smrg save_oldobjs=$oldobjs 919742a55b46Smrg oldobjs= 919842a55b46Smrg # Is there a better way of finding the last object in the list? 919942a55b46Smrg for obj in $save_oldobjs 920042a55b46Smrg do 920142a55b46Smrg last_oldobj=$obj 920242a55b46Smrg done 920342a55b46Smrg eval test_cmds=\"$old_archive_cmds\" 920442a55b46Smrg func_len " $test_cmds" 920542a55b46Smrg len0=$func_len_result 920642a55b46Smrg len=$len0 920742a55b46Smrg for obj in $save_oldobjs 920842a55b46Smrg do 920942a55b46Smrg func_len " $obj" 921042a55b46Smrg func_arith $len + $func_len_result 921142a55b46Smrg len=$func_arith_result 921242a55b46Smrg func_append objlist " $obj" 921342a55b46Smrg if test "$len" -lt "$max_cmd_len"; then 921442a55b46Smrg : 921542a55b46Smrg else 921642a55b46Smrg # the above command should be used before it gets too long 921742a55b46Smrg oldobjs=$objlist 921842a55b46Smrg if test "$obj" = "$last_oldobj" ; then 921942a55b46Smrg RANLIB=$save_RANLIB 922042a55b46Smrg fi 922142a55b46Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 922242a55b46Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 922342a55b46Smrg objlist= 922442a55b46Smrg len=$len0 922542a55b46Smrg fi 922642a55b46Smrg done 922742a55b46Smrg RANLIB=$save_RANLIB 922842a55b46Smrg oldobjs=$objlist 922942a55b46Smrg if test "X$oldobjs" = "X" ; then 923042a55b46Smrg eval cmds=\"\$concat_cmds\" 923142a55b46Smrg else 923242a55b46Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 923342a55b46Smrg fi 923442a55b46Smrg fi 923542a55b46Smrg fi 923642a55b46Smrg func_execute_cmds "$cmds" 'exit $?' 9237c582b7e3Smrg done 9238c582b7e3Smrg 923942a55b46Smrg test -n "$generated" && \ 924042a55b46Smrg func_show_eval "${RM}r$generated" 9241c582b7e3Smrg 924242a55b46Smrg # Now create the libtool archive. 924342a55b46Smrg case $output in 924442a55b46Smrg *.la) 924542a55b46Smrg old_library= 924642a55b46Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 924742a55b46Smrg func_verbose "creating $output" 9248c582b7e3Smrg 924942a55b46Smrg # Preserve any variables that may affect compiler behavior 925042a55b46Smrg for var in $variables_saved_for_relink; do 925142a55b46Smrg if eval test -z \"\${$var+set}\"; then 925242a55b46Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 925342a55b46Smrg elif eval var_value=\$$var; test -z "$var_value"; then 925442a55b46Smrg relink_command="$var=; export $var; $relink_command" 9255c582b7e3Smrg else 925642a55b46Smrg func_quote_for_eval "$var_value" 925742a55b46Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9258c582b7e3Smrg fi 925942a55b46Smrg done 926042a55b46Smrg # Quote the link command for shipping. 926142a55b46Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 926242a55b46Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 926342a55b46Smrg if test "$hardcode_automatic" = yes ; then 926442a55b46Smrg relink_command= 926542a55b46Smrg fi 9266c582b7e3Smrg 926742a55b46Smrg # Only create the output if not a dry run. 926842a55b46Smrg $opt_dry_run || { 926942a55b46Smrg for installed in no yes; do 927042a55b46Smrg if test "$installed" = yes; then 927142a55b46Smrg if test -z "$install_libdir"; then 927242a55b46Smrg break 927342a55b46Smrg fi 927442a55b46Smrg output="$output_objdir/$outputname"i 927542a55b46Smrg # Replace all uninstalled libtool libraries with the installed ones 927642a55b46Smrg newdependency_libs= 927742a55b46Smrg for deplib in $dependency_libs; do 927842a55b46Smrg case $deplib in 927942a55b46Smrg *.la) 928042a55b46Smrg func_basename "$deplib" 928142a55b46Smrg name="$func_basename_result" 928242a55b46Smrg func_resolve_sysroot "$deplib" 928342a55b46Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 928442a55b46Smrg test -z "$libdir" && \ 928542a55b46Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 928642a55b46Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 928742a55b46Smrg ;; 928842a55b46Smrg -L*) 928942a55b46Smrg func_stripname -L '' "$deplib" 929042a55b46Smrg func_replace_sysroot "$func_stripname_result" 929142a55b46Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 929242a55b46Smrg ;; 929342a55b46Smrg -R*) 929442a55b46Smrg func_stripname -R '' "$deplib" 929542a55b46Smrg func_replace_sysroot "$func_stripname_result" 929642a55b46Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 929742a55b46Smrg ;; 929842a55b46Smrg *) func_append newdependency_libs " $deplib" ;; 929942a55b46Smrg esac 930042a55b46Smrg done 930142a55b46Smrg dependency_libs="$newdependency_libs" 930242a55b46Smrg newdlfiles= 930342a55b46Smrg 930442a55b46Smrg for lib in $dlfiles; do 930542a55b46Smrg case $lib in 930642a55b46Smrg *.la) 930742a55b46Smrg func_basename "$lib" 930842a55b46Smrg name="$func_basename_result" 930942a55b46Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 931042a55b46Smrg test -z "$libdir" && \ 931142a55b46Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 931242a55b46Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 931342a55b46Smrg ;; 931442a55b46Smrg *) func_append newdlfiles " $lib" ;; 931542a55b46Smrg esac 931642a55b46Smrg done 931742a55b46Smrg dlfiles="$newdlfiles" 931842a55b46Smrg newdlprefiles= 931942a55b46Smrg for lib in $dlprefiles; do 932042a55b46Smrg case $lib in 932142a55b46Smrg *.la) 932242a55b46Smrg # Only pass preopened files to the pseudo-archive (for 932342a55b46Smrg # eventual linking with the app. that links it) if we 932442a55b46Smrg # didn't already link the preopened objects directly into 932542a55b46Smrg # the library: 932642a55b46Smrg func_basename "$lib" 932742a55b46Smrg name="$func_basename_result" 932842a55b46Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 932942a55b46Smrg test -z "$libdir" && \ 933042a55b46Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 933142a55b46Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 933242a55b46Smrg ;; 933342a55b46Smrg esac 933442a55b46Smrg done 933542a55b46Smrg dlprefiles="$newdlprefiles" 933642a55b46Smrg else 933742a55b46Smrg newdlfiles= 933842a55b46Smrg for lib in $dlfiles; do 933942a55b46Smrg case $lib in 934042a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 934142a55b46Smrg *) abs=`pwd`"/$lib" ;; 934242a55b46Smrg esac 934342a55b46Smrg func_append newdlfiles " $abs" 934442a55b46Smrg done 934542a55b46Smrg dlfiles="$newdlfiles" 934642a55b46Smrg newdlprefiles= 934742a55b46Smrg for lib in $dlprefiles; do 934842a55b46Smrg case $lib in 934942a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 935042a55b46Smrg *) abs=`pwd`"/$lib" ;; 935142a55b46Smrg esac 935242a55b46Smrg func_append newdlprefiles " $abs" 935342a55b46Smrg done 935442a55b46Smrg dlprefiles="$newdlprefiles" 935542a55b46Smrg fi 935642a55b46Smrg $RM $output 935742a55b46Smrg # place dlname in correct position for cygwin 935842a55b46Smrg # In fact, it would be nice if we could use this code for all target 935942a55b46Smrg # systems that can't hard-code library paths into their executables 936042a55b46Smrg # and that have no shared library path variable independent of PATH, 936142a55b46Smrg # but it turns out we can't easily determine that from inspecting 936242a55b46Smrg # libtool variables, so we have to hard-code the OSs to which it 936342a55b46Smrg # applies here; at the moment, that means platforms that use the PE 936442a55b46Smrg # object format with DLL files. See the long comment at the top of 936542a55b46Smrg # tests/bindir.at for full details. 936642a55b46Smrg tdlname=$dlname 936742a55b46Smrg case $host,$output,$installed,$module,$dlname in 936842a55b46Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 936942a55b46Smrg # If a -bindir argument was supplied, place the dll there. 937042a55b46Smrg if test "x$bindir" != x ; 937142a55b46Smrg then 937242a55b46Smrg func_relative_path "$install_libdir" "$bindir" 937342a55b46Smrg tdlname=$func_relative_path_result$dlname 937442a55b46Smrg else 937542a55b46Smrg # Otherwise fall back on heuristic. 937642a55b46Smrg tdlname=../bin/$dlname 937742a55b46Smrg fi 937842a55b46Smrg ;; 937942a55b46Smrg esac 938042a55b46Smrg $ECHO > $output "\ 938142a55b46Smrg# $outputname - a libtool library file 938242a55b46Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 938342a55b46Smrg# 938442a55b46Smrg# Please DO NOT delete this file! 938542a55b46Smrg# It is necessary for linking the library. 9386c582b7e3Smrg 938742a55b46Smrg# The name that we can dlopen(3). 938842a55b46Smrgdlname='$tdlname' 9389c582b7e3Smrg 939042a55b46Smrg# Names of this library. 939142a55b46Smrglibrary_names='$library_names' 9392c582b7e3Smrg 939342a55b46Smrg# The name of the static archive. 939442a55b46Smrgold_library='$old_library' 9395c582b7e3Smrg 939642a55b46Smrg# Linker flags that can not go in dependency_libs. 939742a55b46Smrginherited_linker_flags='$new_inherited_linker_flags' 9398c582b7e3Smrg 939942a55b46Smrg# Libraries that this one depends upon. 940042a55b46Smrgdependency_libs='$dependency_libs' 9401c582b7e3Smrg 940242a55b46Smrg# Names of additional weak libraries provided by this library 940342a55b46Smrgweak_library_names='$weak_libs' 9404c582b7e3Smrg 940542a55b46Smrg# Version information for $libname. 940642a55b46Smrgcurrent=$current 940742a55b46Smrgage=$age 940842a55b46Smrgrevision=$revision 9409c582b7e3Smrg 941042a55b46Smrg# Is this an already installed library? 941142a55b46Smrginstalled=$installed 9412c582b7e3Smrg 941342a55b46Smrg# Should we warn about portability when linking against -modules? 941442a55b46Smrgshouldnotlink=$module 9415c582b7e3Smrg 941642a55b46Smrg# Files to dlopen/dlpreopen 941742a55b46Smrgdlopen='$dlfiles' 941842a55b46Smrgdlpreopen='$dlprefiles' 9419c582b7e3Smrg 942042a55b46Smrg# Directory that this library needs to be installed in: 942142a55b46Smrglibdir='$install_libdir'" 942242a55b46Smrg if test "$installed" = no && test "$need_relink" = yes; then 942342a55b46Smrg $ECHO >> $output "\ 942442a55b46Smrgrelink_command=\"$relink_command\"" 942542a55b46Smrg fi 942642a55b46Smrg done 942742a55b46Smrg } 9428c582b7e3Smrg 942942a55b46Smrg # Do a symbolic link so that the libtool archive can be found in 943042a55b46Smrg # LD_LIBRARY_PATH before the program is installed. 943142a55b46Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 943242a55b46Smrg ;; 943342a55b46Smrg esac 943442a55b46Smrg exit $EXIT_SUCCESS 943542a55b46Smrg} 9436c582b7e3Smrg 943742a55b46Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 943842a55b46Smrg func_mode_link ${1+"$@"} 9439c582b7e3Smrg 9440c582b7e3Smrg 944142a55b46Smrg# func_mode_uninstall arg... 944242a55b46Smrgfunc_mode_uninstall () 944342a55b46Smrg{ 944442a55b46Smrg $opt_debug 944542a55b46Smrg RM="$nonopt" 9446c582b7e3Smrg files= 9447c582b7e3Smrg rmforce= 9448c582b7e3Smrg exit_status=0 9449c582b7e3Smrg 9450c582b7e3Smrg # This variable tells wrapper scripts just to set variables rather 9451c582b7e3Smrg # than running their programs. 9452c582b7e3Smrg libtool_install_magic="$magic" 9453c582b7e3Smrg 9454c582b7e3Smrg for arg 9455c582b7e3Smrg do 9456c582b7e3Smrg case $arg in 945742a55b46Smrg -f) func_append RM " $arg"; rmforce=yes ;; 945842a55b46Smrg -*) func_append RM " $arg" ;; 945942a55b46Smrg *) func_append files " $arg" ;; 9460c582b7e3Smrg esac 9461c582b7e3Smrg done 9462c582b7e3Smrg 946342a55b46Smrg test -z "$RM" && \ 946442a55b46Smrg func_fatal_help "you must specify an RM program" 9465c582b7e3Smrg 9466c582b7e3Smrg rmdirs= 9467c582b7e3Smrg 9468c582b7e3Smrg for file in $files; do 946942a55b46Smrg func_dirname "$file" "" "." 947042a55b46Smrg dir="$func_dirname_result" 947142a55b46Smrg if test "X$dir" = X.; then 947242a55b46Smrg odir="$objdir" 9473c582b7e3Smrg else 947442a55b46Smrg odir="$dir/$objdir" 9475c582b7e3Smrg fi 947642a55b46Smrg func_basename "$file" 947742a55b46Smrg name="$func_basename_result" 947842a55b46Smrg test "$opt_mode" = uninstall && odir="$dir" 9479c582b7e3Smrg 948042a55b46Smrg # Remember odir for removal later, being careful to avoid duplicates 948142a55b46Smrg if test "$opt_mode" = clean; then 9482c582b7e3Smrg case " $rmdirs " in 948342a55b46Smrg *" $odir "*) ;; 948442a55b46Smrg *) func_append rmdirs " $odir" ;; 9485c582b7e3Smrg esac 9486c582b7e3Smrg fi 9487c582b7e3Smrg 9488c582b7e3Smrg # Don't error if the file doesn't exist and rm -f was used. 948942a55b46Smrg if { test -L "$file"; } >/dev/null 2>&1 || 949042a55b46Smrg { test -h "$file"; } >/dev/null 2>&1 || 949142a55b46Smrg test -f "$file"; then 9492c582b7e3Smrg : 9493c582b7e3Smrg elif test -d "$file"; then 9494c582b7e3Smrg exit_status=1 9495c582b7e3Smrg continue 9496c582b7e3Smrg elif test "$rmforce" = yes; then 9497c582b7e3Smrg continue 9498c582b7e3Smrg fi 9499c582b7e3Smrg 9500c582b7e3Smrg rmfiles="$file" 9501c582b7e3Smrg 9502c582b7e3Smrg case $name in 9503c582b7e3Smrg *.la) 9504c582b7e3Smrg # Possibly a libtool archive, so verify it. 950542a55b46Smrg if func_lalib_p "$file"; then 950642a55b46Smrg func_source $dir/$name 9507c582b7e3Smrg 9508c582b7e3Smrg # Delete the libtool libraries and symlinks. 9509c582b7e3Smrg for n in $library_names; do 951042a55b46Smrg func_append rmfiles " $odir/$n" 9511c582b7e3Smrg done 951242a55b46Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 9513c582b7e3Smrg 951442a55b46Smrg case "$opt_mode" in 9515c582b7e3Smrg clean) 951642a55b46Smrg case " $library_names " in 9517c582b7e3Smrg *" $dlname "*) ;; 951842a55b46Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 9519c582b7e3Smrg esac 952042a55b46Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 9521c582b7e3Smrg ;; 9522c582b7e3Smrg uninstall) 9523c582b7e3Smrg if test -n "$library_names"; then 9524c582b7e3Smrg # Do each command in the postuninstall commands. 952542a55b46Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9526c582b7e3Smrg fi 9527c582b7e3Smrg 9528c582b7e3Smrg if test -n "$old_library"; then 9529c582b7e3Smrg # Do each command in the old_postuninstall commands. 953042a55b46Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9531c582b7e3Smrg fi 9532c582b7e3Smrg # FIXME: should reinstall the best remaining shared library. 9533c582b7e3Smrg ;; 9534c582b7e3Smrg esac 9535c582b7e3Smrg fi 9536c582b7e3Smrg ;; 9537c582b7e3Smrg 9538c582b7e3Smrg *.lo) 9539c582b7e3Smrg # Possibly a libtool object, so verify it. 954042a55b46Smrg if func_lalib_p "$file"; then 9541c582b7e3Smrg 9542c582b7e3Smrg # Read the .lo file 954342a55b46Smrg func_source $dir/$name 9544c582b7e3Smrg 9545c582b7e3Smrg # Add PIC object to the list of files to remove. 954642a55b46Smrg if test -n "$pic_object" && 954742a55b46Smrg test "$pic_object" != none; then 954842a55b46Smrg func_append rmfiles " $dir/$pic_object" 9549c582b7e3Smrg fi 9550c582b7e3Smrg 9551c582b7e3Smrg # Add non-PIC object to the list of files to remove. 955242a55b46Smrg if test -n "$non_pic_object" && 955342a55b46Smrg test "$non_pic_object" != none; then 955442a55b46Smrg func_append rmfiles " $dir/$non_pic_object" 9555c582b7e3Smrg fi 9556c582b7e3Smrg fi 9557c582b7e3Smrg ;; 9558c582b7e3Smrg 9559c582b7e3Smrg *) 956042a55b46Smrg if test "$opt_mode" = clean ; then 9561c582b7e3Smrg noexename=$name 9562c582b7e3Smrg case $file in 9563c582b7e3Smrg *.exe) 956442a55b46Smrg func_stripname '' '.exe' "$file" 956542a55b46Smrg file=$func_stripname_result 956642a55b46Smrg func_stripname '' '.exe' "$name" 956742a55b46Smrg noexename=$func_stripname_result 9568c582b7e3Smrg # $file with .exe has already been added to rmfiles, 9569c582b7e3Smrg # add $file without .exe 957042a55b46Smrg func_append rmfiles " $file" 9571c582b7e3Smrg ;; 9572c582b7e3Smrg esac 9573c582b7e3Smrg # Do a test to see if this is a libtool program. 957442a55b46Smrg if func_ltwrapper_p "$file"; then 957542a55b46Smrg if func_ltwrapper_executable_p "$file"; then 957642a55b46Smrg func_ltwrapper_scriptname "$file" 957742a55b46Smrg relink_command= 957842a55b46Smrg func_source $func_ltwrapper_scriptname_result 957942a55b46Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 958042a55b46Smrg else 958142a55b46Smrg relink_command= 958242a55b46Smrg func_source $dir/$noexename 958342a55b46Smrg fi 9584c582b7e3Smrg 9585c582b7e3Smrg # note $name still contains .exe if it was in $file originally 9586c582b7e3Smrg # as does the version of $file that was added into $rmfiles 958742a55b46Smrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9588c582b7e3Smrg if test "$fast_install" = yes && test -n "$relink_command"; then 958942a55b46Smrg func_append rmfiles " $odir/lt-$name" 9590c582b7e3Smrg fi 9591c582b7e3Smrg if test "X$noexename" != "X$name" ; then 959242a55b46Smrg func_append rmfiles " $odir/lt-${noexename}.c" 9593c582b7e3Smrg fi 9594c582b7e3Smrg fi 9595c582b7e3Smrg fi 9596c582b7e3Smrg ;; 9597c582b7e3Smrg esac 959842a55b46Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 9599c582b7e3Smrg done 9600c582b7e3Smrg 9601c582b7e3Smrg # Try to remove the ${objdir}s in the directories where we deleted files 9602c582b7e3Smrg for dir in $rmdirs; do 9603c582b7e3Smrg if test -d "$dir"; then 960442a55b46Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 9605c582b7e3Smrg fi 9606c582b7e3Smrg done 9607c582b7e3Smrg 9608c582b7e3Smrg exit $exit_status 960942a55b46Smrg} 9610c582b7e3Smrg 961142a55b46Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 961242a55b46Smrg func_mode_uninstall ${1+"$@"} 9613c582b7e3Smrg 961442a55b46Smrgtest -z "$opt_mode" && { 961542a55b46Smrg help="$generic_help" 961642a55b46Smrg func_fatal_help "you must specify a MODE" 961742a55b46Smrg} 961842a55b46Smrg 961942a55b46Smrgtest -z "$exec_cmd" && \ 962042a55b46Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 9621c582b7e3Smrg 9622c582b7e3Smrgif test -n "$exec_cmd"; then 962342a55b46Smrg eval exec "$exec_cmd" 9624c582b7e3Smrg exit $EXIT_FAILURE 9625c582b7e3Smrgfi 9626c582b7e3Smrg 962742a55b46Smrgexit $exit_status 9628c582b7e3Smrg 9629c582b7e3Smrg 9630c582b7e3Smrg# The TAGs below are defined such that we never get into a situation 9631c582b7e3Smrg# in which we disable both kinds of libraries. Given conflicting 9632c582b7e3Smrg# choices, we go for a static library, that is the most portable, 9633c582b7e3Smrg# since we can't tell whether shared libraries were disabled because 9634c582b7e3Smrg# the user asked for that or because the platform doesn't support 9635c582b7e3Smrg# them. This is particularly important on AIX, because we don't 9636c582b7e3Smrg# support having both static and shared libraries enabled at the same 9637c582b7e3Smrg# time on that platform, so we default to a shared-only configuration. 9638c582b7e3Smrg# If a disable-shared tag is given, we'll fallback to a static-only 9639c582b7e3Smrg# configuration. But we'll never go from static-only to shared-only. 9640c582b7e3Smrg 9641c582b7e3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 964242a55b46Smrgbuild_libtool_libs=no 964342a55b46Smrgbuild_old_libs=yes 9644c582b7e3Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 9645c582b7e3Smrg 9646c582b7e3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 964742a55b46Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 9648c582b7e3Smrg# ### END LIBTOOL TAG CONFIG: disable-static 9649c582b7e3Smrg 9650c582b7e3Smrg# Local Variables: 9651c582b7e3Smrg# mode:shell-script 9652c582b7e3Smrg# sh-indentation:2 9653c582b7e3Smrg# End: 965442a55b46Smrg# vi:sw=2 965542a55b46Smrg 9656